Skip to content

Commit e038020

Browse files
committed
add all csp and permissions to host capabilities + update SEP
1 parent 0e4e524 commit e038020

File tree

17 files changed

+271
-113
lines changed

17 files changed

+271
-113
lines changed

examples/basic-host/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@vitejs/plugin-react": "^4.3.4",
2626
"concurrently": "^9.2.1",
2727
"cors": "^2.8.5",
28+
"cross-env": "^10.1.0",
2829
"express": "^5.1.0",
2930
"prettier": "^3.6.2",
3031
"vite": "^6.0.0",

examples/basic-server-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@vitejs/plugin-react": "^4.3.4",
2727
"concurrently": "^9.2.1",
2828
"cors": "^2.8.5",
29+
"cross-env": "^10.1.0",
2930
"express": "^5.1.0",
3031
"typescript": "^5.9.3",
3132
"vite": "^6.0.0",

examples/basic-server-vanillajs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@types/node": "^22.0.0",
2222
"concurrently": "^9.2.1",
2323
"cors": "^2.8.5",
24+
"cross-env": "^10.1.0",
2425
"express": "^5.1.0",
2526
"typescript": "^5.9.3",
2627
"vite": "^6.0.0",

examples/budget-allocator-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/node": "^22.0.0",
2626
"concurrently": "^9.2.1",
2727
"cors": "^2.8.5",
28+
"cross-env": "^10.1.0",
2829
"express": "^5.1.0",
2930
"typescript": "^5.9.3",
3031
"vite": "^6.0.0",

examples/cohort-heatmap-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@vitejs/plugin-react": "^4.3.4",
3030
"concurrently": "^9.2.1",
3131
"cors": "^2.8.5",
32+
"cross-env": "^10.1.0",
3233
"express": "^5.1.0",
3334
"typescript": "^5.9.3",
3435
"vite": "^6.0.0",

examples/customer-segmentation-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@types/node": "^22.0.0",
2626
"concurrently": "^9.2.1",
2727
"cors": "^2.8.5",
28+
"cross-env": "^10.1.0",
2829
"express": "^5.1.0",
2930
"typescript": "^5.9.3",
3031
"vite": "^6.0.0",

examples/scenario-modeler-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"@vitejs/plugin-react": "^4.3.4",
3131
"concurrently": "^9.2.1",
3232
"cors": "^2.8.5",
33+
"cross-env": "^10.1.0",
3334
"express": "^5.1.0",
3435
"typescript": "^5.9.3",
3536
"vite": "^6.0.0",

examples/simple-host/sandbox.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,21 @@
5757
inner.setAttribute('sandbox', 'allow-scripts allow-same-origin');
5858
document.body.appendChild(inner);
5959

60+
// Build iframe allow attribute from permissions
61+
function buildAllowAttribute(permissions) {
62+
if (!permissions) return '';
63+
const allowList = [];
64+
if (permissions.camera) allowList.push('camera');
65+
if (permissions.microphone) allowList.push('microphone');
66+
if (permissions.geolocation) allowList.push('geolocation');
67+
return allowList.join('; ');
68+
}
69+
6070
window.addEventListener('message', async (event) => {
6171
if (event.source === window.parent) {
6272
if (event.data && event.data.method === 'ui/notifications/sandbox-resource-ready') {
63-
const { html, sandbox } = event.data.params || {};
73+
const { html, sandbox, permissions } = event.data.params || {};
74+
// Note: csp is not extracted here - CSP is set via HTTP response headers in serve.ts
6475
if (typeof sandbox === 'string') {
6576
// Ensure allow-same-origin is present for document.write to work
6677
let finalSandbox = sandbox;
@@ -69,6 +80,11 @@
6980
}
7081
inner.setAttribute('sandbox', finalSandbox);
7182
}
83+
// Set Permission Policy allow attribute if permissions are provided
84+
const allowAttribute = buildAllowAttribute(permissions);
85+
if (allowAttribute) {
86+
inner.setAttribute('allow', allowAttribute);
87+
}
7288
if (typeof html === 'string') {
7389
// Use document.write instead of srcdoc to avoid CSP base-uri issues
7490
// document.write allows the browser to resolve relative URLs correctly

examples/system-monitor-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@types/node": "^22.0.0",
2727
"concurrently": "^9.2.1",
2828
"cors": "^2.8.5",
29+
"cross-env": "^10.1.0",
2930
"express": "^5.1.0",
3031
"typescript": "^5.9.3",
3132
"vite": "^6.0.0",

examples/threejs-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@vitejs/plugin-react": "^4.3.4",
3232
"concurrently": "^9.2.1",
3333
"cors": "^2.8.5",
34+
"cross-env": "^10.1.0",
3435
"express": "^5.1.0",
3536
"typescript": "^5.9.3",
3637
"vite": "^6.0.0",

0 commit comments

Comments
 (0)