@serene-pub/conformance 0.6.0-pr-6 → 0.6.0-pr-7

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -3
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -962,8 +962,9 @@ export const REQUIREMENTS = [
962
962
  `grant nobody decided`);
963
963
  for (const [kind, storage, fetch] of table) {
964
964
  const g = hookCtxGrants(kind);
965
- must(g.storage === storage && g.fetch === fetch, `the grant table hands a '${kind}' hook ${JSON.stringify(g)}; the law is ` +
966
- `{ storage: ${storage}, fetch: ${fetch} }`);
965
+ // `package` (M2a) is granted exactly where `storage` is.
966
+ must(g.storage === storage && g.package === storage && g.fetch === fetch, `the grant table hands a '${kind}' hook ${JSON.stringify(g)}; the law is ` +
967
+ `{ storage: ${storage}, package: ${storage}, fetch: ${fetch} }`);
967
968
  }
968
969
  must(hookCtxKeysFor('task').join(' ') === 'random now log signal', `a plugin task's context is random, now, log and signal — this build hands it ` +
969
970
  `[${hookCtxKeysFor('task').join(', ')}]`);
@@ -1049,7 +1050,21 @@ export const REQUIREMENTS = [
1049
1050
  // and only the hosts the package declared and an administrator
1050
1051
  // left granted — the same grant `ctx.fetch` is metered by. The
1051
1052
  // reporting directives take a URL by definition.
1052
- if (name === 'connect-src' || name === 'report-uri' || name === 'report-to')
1053
+ if (name === 'connect-src') {
1054
+ // 🚧 (M2a) Judged, not skipped: the frame's own GET doors
1055
+ // (`<host>/plugin-assets/<id>/`, `<host>/plugin-data/<id>/`, a
1056
+ // path under the document's own host) and granted network hosts
1057
+ // (`https://h`, `ws://h`, …, with no path) are the only sources.
1058
+ // `'self'`, `*`, a bare scheme and any other path are the app.
1059
+ const door = /^[A-Za-z0-9.\-:[\]]+\/plugin-(assets|data)\/[a-z0-9][a-z0-9._-]*\/$/;
1060
+ const granted = /^(https?|wss?):\/\/[^/*\s]+$/;
1061
+ const bad = sources.filter((src) => src !== "'none'" && !door.test(src) && !granted.test(src));
1062
+ must(bad.length === 0, `\`${shown('connect-src')}\` — ${bad.join(', ')} opens more than the frame's own ` +
1063
+ `/plugin-assets/<id>/ and /plugin-data/<id>/ (GET) and its granted network hosts: ` +
1064
+ `'self', a wildcard, a bare scheme or another path lets a frame call the app's API`);
1065
+ continue;
1066
+ }
1067
+ if (name === 'report-uri' || name === 'report-to')
1053
1068
  continue;
1054
1069
  const off = sources.filter((src) => !local(src));
1055
1070
  must(off.length === 0, `\`${name}\` names ${off.join(', ')} — a frame's resources come from the package's own files, ` +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serene-pub/conformance",
3
- "version": "0.6.0-pr-6",
3
+ "version": "0.6.0-pr-7",
4
4
  "description": "The host conformance kit: thirty-three executable requirements a Serene Pub executor must satisfy. Run by Serene Pub and by any alternate host; its package cases (C28–C33) by plugin authors over a built package.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/SerenePub/serene-pub-sdk/tree/main/conformance#readme",
@@ -33,13 +33,13 @@
33
33
  "./package.json": "./package.json"
34
34
  },
35
35
  "peerDependencies": {
36
- "@serene-pub/sdk": "^0.6.0-pr-6"
36
+ "@serene-pub/sdk": "^0.6.0-pr-7"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.build.json"
40
40
  },
41
41
  "devDependencies": {
42
- "@serene-pub/sdk": "0.6.0-pr-6"
42
+ "@serene-pub/sdk": "0.6.0-pr-7"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public",