Skip to content

Commit

Permalink
feat: add iframe sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
hatemhosny committed Jan 19, 2021
1 parent 41b85b6 commit 217d7ee
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/localpen/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ export const app = async (config: Pen) => {
function createIframe(container: string, template = resultTemplate) {
return new Promise((resolve) => {
const iframe = document.createElement('iframe');
iframe.setAttribute(
'allow',
'accelerometer; camera; encrypted-media; geolocation; gyroscope; microphone; midi',
);
iframe.setAttribute('allowfullscreen', 'true');
iframe.setAttribute('allowtransparency', 'true');
iframe.setAttribute(
'sandbox',
'allow-downloads allow-forms allow-modals allow-pointer-lock allow-presentation allow-same-origin allow-scripts',
);

const containerEl = document.querySelector(container);
if (!containerEl) return;
containerEl.innerHTML = '';
Expand Down

0 comments on commit 217d7ee

Please sign in to comment.