orkestrator 2.38.3-beta → 2.39.1-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,15 +95,12 @@ function shortcutFocus(target) {
95
95
  return target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement ? "text" : "page";
96
96
  }
97
97
 
98
- // ../protocol/src/design-runtime.ts
99
- function installDesignRuntime(matchesShortcut, shortcuts, claimsShortcut, focusedSurface) {
100
- const MAX_HTML_BYTES = 256 * 1024;
101
- const MAX_ELEMENTS = 5000;
98
+ // ../protocol/src/static-html-sanitizer.ts
99
+ function createStaticHtmlSanitizer() {
102
100
  const forbidden = "script,iframe,frame,object,embed,base,meta,link,portal,applet";
103
101
  const externalUrl = /^\s*(?:https?:)?\/\//i;
104
102
  const cssExternal = /url\(\s*['"]?\s*(?:https?:)?\/\//gi;
105
103
  const cssImport = /@import\s/gi;
106
- let mode = "inspect";
107
104
  const emptyCounts = () => ({
108
105
  scripts: 0,
109
106
  handlers: 0,
@@ -160,6 +157,15 @@ function installDesignRuntime(matchesShortcut, shortcuts, claimsShortcut, focuse
160
157
  }
161
158
  return total;
162
159
  }
160
+ return { emptyCounts, clean, elementCount };
161
+ }
162
+
163
+ // ../protocol/src/design-runtime.ts
164
+ function installDesignRuntime(createSanitizer, matchesShortcut, shortcuts, claimsShortcut, focusedSurface) {
165
+ const MAX_HTML_BYTES = 256 * 1024;
166
+ const MAX_ELEMENTS = 5000;
167
+ const { clean, elementCount, emptyCounts } = createSanitizer();
168
+ let mode = "inspect";
163
169
  function depthOf(root) {
164
170
  if (!root)
165
171
  return 0;
@@ -610,7 +616,7 @@ function designDocument(scriptSource, scriptAttributes, script) {
610
616
  return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src ${scriptSource}; style-src 'unsafe-inline'; img-src data:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'"></head><body><script${scriptAttributes}>${script}</script></body></html>`;
611
617
  }
612
618
  function designRuntimeScript() {
613
- return `(${installDesignRuntime.toString()})(${matchAppShortcut.toString()}, ${JSON.stringify(APP_SHORTCUTS)}, ${appClaimsShortcut.toString()}, ${shortcutFocus.toString()});`;
619
+ return `(${installDesignRuntime.toString()})(${createStaticHtmlSanitizer.toString()}, ${matchAppShortcut.toString()}, ${JSON.stringify(APP_SHORTCUTS)}, ${appClaimsShortcut.toString()}, ${shortcutFocus.toString()});`;
614
620
  }
615
621
  function designBootstrap(nonce) {
616
622
  if (!/^[a-zA-Z0-9-]{16,80}$/.test(nonce))
@@ -94,15 +94,12 @@ function shortcutFocus(target) {
94
94
  return target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement ? "text" : "page";
95
95
  }
96
96
 
97
- // packages/protocol/src/design-runtime.ts
98
- function installDesignRuntime(matchesShortcut, shortcuts, claimsShortcut, focusedSurface) {
99
- const MAX_HTML_BYTES = 256 * 1024;
100
- const MAX_ELEMENTS = 5000;
97
+ // packages/protocol/src/static-html-sanitizer.ts
98
+ function createStaticHtmlSanitizer() {
101
99
  const forbidden = "script,iframe,frame,object,embed,base,meta,link,portal,applet";
102
100
  const externalUrl = /^\s*(?:https?:)?\/\//i;
103
101
  const cssExternal = /url\(\s*['"]?\s*(?:https?:)?\/\//gi;
104
102
  const cssImport = /@import\s/gi;
105
- let mode = "inspect";
106
103
  const emptyCounts = () => ({
107
104
  scripts: 0,
108
105
  handlers: 0,
@@ -159,6 +156,15 @@ function installDesignRuntime(matchesShortcut, shortcuts, claimsShortcut, focuse
159
156
  }
160
157
  return total;
161
158
  }
159
+ return { emptyCounts, clean, elementCount };
160
+ }
161
+
162
+ // packages/protocol/src/design-runtime.ts
163
+ function installDesignRuntime(createSanitizer, matchesShortcut, shortcuts, claimsShortcut, focusedSurface) {
164
+ const MAX_HTML_BYTES = 256 * 1024;
165
+ const MAX_ELEMENTS = 5000;
166
+ const { clean, elementCount, emptyCounts } = createSanitizer();
167
+ let mode = "inspect";
162
168
  function depthOf(root) {
163
169
  if (!root)
164
170
  return 0;
@@ -609,7 +615,7 @@ function designDocument(scriptSource, scriptAttributes, script) {
609
615
  return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src ${scriptSource}; style-src 'unsafe-inline'; img-src data:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'"></head><body><script${scriptAttributes}>${script}</script></body></html>`;
610
616
  }
611
617
  function designRuntimeScript() {
612
- return `(${installDesignRuntime.toString()})(${matchAppShortcut.toString()}, ${JSON.stringify(APP_SHORTCUTS)}, ${appClaimsShortcut.toString()}, ${shortcutFocus.toString()});`;
618
+ return `(${installDesignRuntime.toString()})(${createStaticHtmlSanitizer.toString()}, ${matchAppShortcut.toString()}, ${JSON.stringify(APP_SHORTCUTS)}, ${appClaimsShortcut.toString()}, ${shortcutFocus.toString()});`;
613
619
  }
614
620
  function designBootstrap(nonce) {
615
621
  if (!/^[a-zA-Z0-9-]{16,80}$/.test(nonce))