@ai-ecoverse/slicc-browsers 1.1.0 → 1.3.0

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.
package/protected.json ADDED
@@ -0,0 +1,141 @@
1
+ {
2
+ "schema": 1,
3
+ "origins": ["http://127.0.0.1:5710", "https://seven.example.test"],
4
+ "urls": [
5
+ { "url": "https://seven.sliccy.ai/", "protected": true },
6
+ { "url": "https://seven.sliccy.ai", "protected": true },
7
+ { "url": "https://seven.sliccy.ai/index.html?x=1#y", "protected": true },
8
+ { "url": "https://SEVEN.SLICCY.AI/", "protected": true },
9
+ { "url": "https://seven.sliccy.ai:443/", "protected": true },
10
+ { "url": "https://seven.sliccy.ai:8443/", "protected": true },
11
+ { "url": "http://seven.sliccy.ai/", "protected": true },
12
+ { "url": "https://main--seven.sliccy.ai/", "protected": true },
13
+ { "url": "https://www.sliccy.ai/", "protected": true },
14
+ { "url": "https://sliccy.ai/", "protected": true },
15
+ { "url": "https://a.b.sliccy.ai/", "protected": true },
16
+ { "url": "https://seven.sliccy.ai./", "protected": true },
17
+ { "url": "https://user:secret@seven.sliccy.ai/", "protected": true },
18
+ { "url": "https:\\\\seven.sliccy.ai\\x", "protected": true },
19
+ { "url": " https://seven.sliccy.ai/ ", "protected": true },
20
+ { "url": "ht\ttps://seven.sli\nccy.ai/", "protected": true },
21
+ { "url": "https:seven.sliccy.ai", "protected": true },
22
+ { "url": "https:///seven.sliccy.ai/", "protected": true },
23
+ { "url": "https://seven%2Esliccy%2Eai/", "protected": true },
24
+ { "url": "https://seven\u3002sliccy\u3002ai/", "protected": true },
25
+ { "url": "https://\uff53\uff45\uff56\uff45\uff4e.sliccy.ai/", "protected": true },
26
+ { "url": "https://se\u00adven.sliccy.ai/", "protected": true },
27
+ {
28
+ "url": "blob:https://seven.sliccy.ai/0b9e0f6c-1f0e-4c1a-9a43-5d3f6e2c7a10",
29
+ "protected": true
30
+ },
31
+ { "url": "filesystem:https://seven.sliccy.ai/temporary/notes.txt", "protected": true },
32
+ { "url": "view-source:https://seven.sliccy.ai/", "protected": true },
33
+ { "url": "view-source:blob:https://seven.sliccy.ai/0b9e0f6c", "protected": true },
34
+ {
35
+ "url": "devtools://devtools/bundled/inspector.html?ws=127.0.0.1:5711/devtools/page/AB12",
36
+ "protected": true
37
+ },
38
+ { "url": "http://127.0.0.1:5710/", "protected": true },
39
+ { "url": "http://127.0.0.1:5710", "protected": true },
40
+ { "url": "http://2130706433:5710/", "protected": true },
41
+ { "url": "http://0x7f.1:5710/", "protected": true },
42
+ { "url": "blob:http://127.0.0.1:5710/0b9e0f6c", "protected": true },
43
+ { "url": "https://seven.example.test/", "protected": true },
44
+ { "url": "https://SEVEN.example.test:443/x", "protected": true },
45
+ { "url": "https://seven.example.test./", "protected": true },
46
+ { "url": "http://localhost:5710/", "protected": false },
47
+ { "url": "http://127.0.0.1:5711/", "protected": false },
48
+ { "url": "https://127.0.0.1:5710/", "protected": false },
49
+ { "url": "http://127.0.0.1/", "protected": false },
50
+ { "url": "http://seven.example.test/", "protected": false },
51
+ { "url": "https://seven.example.test:8443/", "protected": false },
52
+ { "url": "https://x.seven.example.test/", "protected": false },
53
+ { "url": "https://example.test/", "protected": false },
54
+ { "url": "https://sliccy.ai.example.com/", "protected": false },
55
+ { "url": "https://notsliccy.ai/", "protected": false },
56
+ { "url": "https://seven.sliccy.ai.example/", "protected": false },
57
+ { "url": "https://sliccy.aix/", "protected": false },
58
+ { "url": "https://sliccy-ai.example/", "protected": false },
59
+ { "url": "https://example.com/?next=https://seven.sliccy.ai/", "protected": false },
60
+ { "url": "https://example.com/#https://seven.sliccy.ai/", "protected": false },
61
+ { "url": "https://seven.sliccy.ai@example.com/", "protected": false },
62
+ { "url": "wss://seven.sliccy.ai/", "protected": false },
63
+ { "url": "ftp://seven.sliccy.ai/", "protected": false },
64
+ { "url": "http://5173.kernel.localhost/", "protected": false },
65
+ { "url": "http://seven.sliccy.ai.kernel.localhost/", "protected": false },
66
+ { "url": "https://example.com/", "protected": false },
67
+ { "url": "about:blank", "protected": false },
68
+ { "url": "about:srcdoc", "protected": false },
69
+ { "url": "data:text/html,<a href=https://seven.sliccy.ai/>x</a>", "protected": false },
70
+ { "url": "blob:null/0b9e0f6c", "protected": false },
71
+ { "url": "blob:https://example.com/0b9e0f6c", "protected": false },
72
+ { "url": "filesystem:https://example.com/temporary/x", "protected": false },
73
+ { "url": "view-source:https://example.com/", "protected": false },
74
+ { "url": "javascript:location='https://seven.sliccy.ai/'", "protected": false },
75
+ { "url": "chrome://version/", "protected": false },
76
+ { "url": "chrome-extension://abcdefghijklmnopabcdefghijklmnop/page.html", "protected": false },
77
+ { "url": "file:///tmp/seven.sliccy.ai/index.html", "protected": false },
78
+ { "url": "", "protected": false },
79
+ { "url": "https://", "protected": false },
80
+ { "url": "seven.sliccy.ai", "protected": false },
81
+ { "url": "not a url", "protected": false }
82
+ ],
83
+ "targets": [
84
+ { "url": "https://seven.sliccy.ai/", "protected": true },
85
+ { "url": "https://example.com/", "protected": false },
86
+ { "url": "https://example.com/", "previous": true, "protected": false },
87
+ { "url": "https://example.com/", "opener": "protected", "protected": false },
88
+ { "url": "about:blank", "protected": false },
89
+ { "url": "about:blank", "opener": "unprotected", "protected": false },
90
+ { "url": "about:blank", "opener": "protected", "protected": true },
91
+ { "url": "about:blank", "opener": "unknown", "protected": true },
92
+ { "url": "about:blank", "previous": true, "protected": true },
93
+ { "url": "about:blank", "previous": true, "opener": "unprotected", "protected": true },
94
+ { "url": "about:blank#top", "previous": true, "protected": true },
95
+ { "url": "about:blank?x=1", "opener": "protected", "protected": true },
96
+ { "url": "about:srcdoc", "previous": true, "protected": true },
97
+ { "url": "about:srcdoc", "opener": "unprotected", "protected": false },
98
+ { "url": "", "opener": "protected", "protected": true },
99
+ { "url": "", "protected": false },
100
+ { "url": "about:version", "previous": true, "protected": false },
101
+ { "url": "data:text/html,x", "previous": true, "protected": false },
102
+ { "url": "blob:https://seven.sliccy.ai/0b9e0f6c", "protected": true },
103
+ { "url": "devtools://devtools/bundled/devtools_app.html", "protected": true },
104
+ { "url": "http://127.0.0.1:5710/index.html", "protected": true },
105
+ { "url": "http://127.0.0.1:5711/index.html", "previous": true, "protected": false }
106
+ ],
107
+ "cookieDomains": [
108
+ { "domain": "sliccy.ai", "protected": true },
109
+ { "domain": ".sliccy.ai", "protected": true },
110
+ { "domain": "seven.sliccy.ai", "protected": true },
111
+ { "domain": ".www.sliccy.ai", "protected": true },
112
+ { "domain": "SLICCY.AI", "protected": true },
113
+ { "domain": "sliccy.ai.", "protected": true },
114
+ { "domain": "a.b.sliccy.ai", "protected": true },
115
+ { "domain": "127.0.0.1", "protected": true },
116
+ { "domain": "seven.example.test", "protected": true },
117
+ { "domain": ".example.test", "protected": true },
118
+ { "domain": "x.seven.example.test", "protected": false },
119
+ { "domain": "other.example.test", "protected": false },
120
+ { "domain": "notsliccy.ai", "protected": false },
121
+ { "domain": "sliccy.ai.example", "protected": false },
122
+ { "domain": "localhost", "protected": false },
123
+ { "domain": "5173.kernel.localhost", "protected": false },
124
+ { "domain": "example.com", "protected": false },
125
+ { "domain": "", "protected": false },
126
+ { "domain": ".", "protected": false }
127
+ ],
128
+ "storageKeys": [
129
+ { "key": "https://seven.sliccy.ai/", "protected": true },
130
+ { "key": "https://sliccy.ai/", "protected": true },
131
+ { "key": "http://127.0.0.1:5710/", "protected": true },
132
+ { "key": "https://widget.example/^0https://sliccy.ai", "protected": true },
133
+ { "key": "https://seven.sliccy.ai/^31", "protected": true },
134
+ { "key": "https://seven.sliccy.ai/^112345^267890", "protected": true },
135
+ { "key": "https://example.com/", "protected": false },
136
+ { "key": "https://example.com/^0https://example.org", "protected": false },
137
+ { "key": "https://example.com/^112345^2https://sliccy.ai", "protected": false },
138
+ { "key": "http://127.0.0.1:5711/", "protected": false },
139
+ { "key": "", "protected": false }
140
+ ]
141
+ }
package/protected.mjs ADDED
@@ -0,0 +1,77 @@
1
+ const parse = (text) => {
2
+ try {
3
+ return new URL(text);
4
+ } catch {
5
+ return null;
6
+ }
7
+ };
8
+
9
+ const scheme = (u) => u.protocol.slice(0, -1);
10
+
11
+ const hostOf = (u) => {
12
+ const h = u.hostname.toLowerCase();
13
+ return h.endsWith('.') ? h.slice(0, -1) : h;
14
+ };
15
+
16
+ const originOf = (u) => {
17
+ if (!u?.host) return null;
18
+ return `${scheme(u)}://${hostOf(u)}${u.port ? `:${u.port}` : ''}`;
19
+ };
20
+
21
+ const under = (host, domain) => host === domain || host.endsWith(`.${domain}`);
22
+
23
+ export function protectedOrigins(rules, extraOrigins = []) {
24
+ const extra = extraOrigins.map((o) => originOf(parse(o))).filter(Boolean);
25
+ const extraHosts = extraOrigins
26
+ .map((o) => parse(o))
27
+ .filter((u) => u?.host)
28
+ .map(hostOf);
29
+
30
+ const unwrap = (u) => {
31
+ for (let i = 0; u && rules.innerSchemes.includes(scheme(u)) && i < 8; i += 1) {
32
+ u = parse(u.href.slice(u.protocol.length));
33
+ }
34
+ return u;
35
+ };
36
+
37
+ const url = (text) => {
38
+ const u = unwrap(parse(text));
39
+ if (!u) return false;
40
+ const s = scheme(u);
41
+ if (rules.anySchemes.includes(s)) return true;
42
+ if (rules.schemes.includes(s) && rules.domains.some((d) => under(hostOf(u), d))) return true;
43
+ const o = originOf(u);
44
+ return o !== null && extra.includes(o);
45
+ };
46
+
47
+ const inheriting = (text) => {
48
+ if (text === '') return true;
49
+ const u = parse(text);
50
+ return (
51
+ u !== null &&
52
+ scheme(u) === 'about' &&
53
+ rules.inheriting.includes(`about:${u.pathname.toLowerCase()}`)
54
+ );
55
+ };
56
+
57
+ const target = ({ url: text, previous = false, opener }) => {
58
+ if (inheriting(text)) return previous || opener === 'protected' || opener === 'unknown';
59
+ return url(text);
60
+ };
61
+
62
+ const cookieDomain = (domain) => {
63
+ let d = domain.toLowerCase();
64
+ if (d.startsWith('.')) d = d.slice(1);
65
+ if (d.endsWith('.')) d = d.slice(0, -1);
66
+ if (d === '') return false;
67
+ if (rules.domains.some((x) => under(d, x))) return true;
68
+ return [...rules.domains, ...extraHosts].some((h) => under(h, d));
69
+ };
70
+
71
+ const storageKey = (key) => {
72
+ const [first, ...rest] = key.split('^');
73
+ return [first, ...rest.filter((p) => p.startsWith('0')).map((p) => p.slice(1))].some(url);
74
+ };
75
+
76
+ return { url, target, cookieDomain, storageKey };
77
+ }
@@ -17,7 +17,7 @@
17
17
  "properties": {
18
18
  "id": { "$ref": "#/$defs/text" },
19
19
  "kind": { "enum": ["endpoint", "installed"] },
20
- "tier": { "type": "integer", "minimum": 1, "maximum": 5 },
20
+ "tier": { "type": "integer", "minimum": 1, "maximum": 6 },
21
21
  "name": { "type": "string" },
22
22
  "version": { "$ref": "#/$defs/text" },
23
23
  "endpoint": { "$ref": "#/$defs/endpoint" },
@@ -28,10 +28,15 @@
28
28
  "properties": {
29
29
  "kind": { "const": "endpoint" },
30
30
  "id": { "type": "string", "pattern": "^cdp:" },
31
- "tier": { "enum": [1, 2] }
31
+ "tier": { "enum": [1, 2, 6] }
32
32
  },
33
33
  "required": ["endpoint"],
34
- "not": { "required": ["installed"] }
34
+ "not": { "required": ["installed"] },
35
+ "if": { "properties": { "tier": { "const": 6 } } },
36
+ "then": { "properties": { "endpoint": { "type": "object", "required": ["six"] } } },
37
+ "else": {
38
+ "properties": { "endpoint": { "type": "object", "not": { "required": ["six"] } } }
39
+ }
35
40
  },
36
41
  {
37
42
  "properties": {
@@ -68,6 +73,7 @@
68
73
  "userDataDir": { "$ref": "#/$defs/text" },
69
74
  "profile": { "$ref": "#/$defs/text" },
70
75
  "wsOnly": { "const": true },
76
+ "six": { "const": true },
71
77
  "sevenOpen": { "type": "boolean" },
72
78
  "sevenTabs": { "type": "array", "items": { "$ref": "#/$defs/tab" } }
73
79
  }
@@ -12,6 +12,7 @@
12
12
  "rank",
13
13
  "discovery",
14
14
  "seven",
15
+ "protectedOrigins",
15
16
  "profiles",
16
17
  "launch",
17
18
  "platforms"
@@ -54,13 +55,14 @@
54
55
  "tiers": {
55
56
  "type": "object",
56
57
  "additionalProperties": false,
57
- "required": ["sevenOpen", "endpoint", "chrome", "chromium", "electron"],
58
+ "required": ["sevenOpen", "endpoint", "chrome", "chromium", "electron", "six"],
58
59
  "properties": {
59
60
  "sevenOpen": { "$ref": "#/$defs/tier" },
60
61
  "endpoint": { "$ref": "#/$defs/tier" },
61
62
  "chrome": { "$ref": "#/$defs/tier" },
62
63
  "chromium": { "$ref": "#/$defs/tier" },
63
- "electron": { "$ref": "#/$defs/tier" }
64
+ "electron": { "$ref": "#/$defs/tier" },
65
+ "six": { "$ref": "#/$defs/tier" }
64
66
  }
65
67
  },
66
68
  "chromeId": { "$ref": "#/$defs/id" }
@@ -168,16 +170,63 @@
168
170
  "cleanExit": { "type": "array", "items": { "$ref": "#/$defs/pref" } }
169
171
  }
170
172
  },
173
+ "protectedOrigins": {
174
+ "type": "object",
175
+ "additionalProperties": false,
176
+ "required": ["domains", "schemes", "innerSchemes", "anySchemes", "inheriting", "refusal"],
177
+ "properties": {
178
+ "domains": {
179
+ "type": "array",
180
+ "minItems": 1,
181
+ "uniqueItems": true,
182
+ "items": {
183
+ "type": "string",
184
+ "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$"
185
+ }
186
+ },
187
+ "schemes": { "$ref": "#/$defs/schemes", "type": "array", "minItems": 1 },
188
+ "innerSchemes": { "$ref": "#/$defs/schemes" },
189
+ "anySchemes": { "$ref": "#/$defs/schemes" },
190
+ "inheriting": {
191
+ "type": "array",
192
+ "uniqueItems": true,
193
+ "items": { "type": "string", "pattern": "^about:[a-z]+$" }
194
+ },
195
+ "refusal": { "$ref": "#/$defs/name" }
196
+ }
197
+ },
171
198
  "profiles": {
172
199
  "type": "object",
173
200
  "additionalProperties": false,
174
- "required": ["root", "snapRoot", "legacyRoot", "sixProfilePattern", "namePattern"],
201
+ "required": ["root", "snapRoot", "legacyRoot", "sixProfilePattern", "namePattern", "six"],
175
202
  "properties": {
176
203
  "root": { "$ref": "#/$defs/segments" },
177
204
  "snapRoot": { "$ref": "#/$defs/segments" },
178
205
  "legacyRoot": { "$ref": "#/$defs/segments" },
179
206
  "sixProfilePattern": { "type": "string", "format": "regex" },
180
- "namePattern": { "type": "string", "format": "regex" }
207
+ "namePattern": { "type": "string", "format": "regex" },
208
+ "six": {
209
+ "description": "SLICC six's Chrome profiles, used in place and never written to.",
210
+ "type": "object",
211
+ "additionalProperties": false,
212
+ "required": ["roots", "defaultName", "defaultPort", "portSuffix", "userDataDirEnv"],
213
+ "properties": {
214
+ "roots": {
215
+ "type": "object",
216
+ "additionalProperties": false,
217
+ "required": ["macos", "linux", "windows"],
218
+ "properties": {
219
+ "macos": { "$ref": "#/$defs/sixRoot" },
220
+ "linux": { "$ref": "#/$defs/sixRoot" },
221
+ "windows": { "$ref": "#/$defs/sixRoot" }
222
+ }
223
+ },
224
+ "defaultName": { "$ref": "#/$defs/name" },
225
+ "defaultPort": { "$ref": "#/$defs/port" },
226
+ "portSuffix": { "type": "string", "pattern": "\\{port\\}" },
227
+ "userDataDirEnv": { "$ref": "#/$defs/name" }
228
+ }
229
+ }
181
230
  }
182
231
  },
183
232
  "launch": {
@@ -244,6 +293,11 @@
244
293
  "$defs": {
245
294
  "name": { "type": "string", "minLength": 1 },
246
295
  "names": { "type": "array", "items": { "$ref": "#/$defs/name" } },
296
+ "schemes": {
297
+ "type": "array",
298
+ "uniqueItems": true,
299
+ "items": { "type": "string", "pattern": "^[a-z][a-z0-9+.-]*$" }
300
+ },
247
301
  "id": { "type": "string", "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$" },
248
302
  "segments": {
249
303
  "description": "A relative path, one segment per item.",
@@ -253,7 +307,7 @@
253
307
  },
254
308
  "port": { "type": "integer", "minimum": 1, "maximum": 65535 },
255
309
  "ports": { "type": "array", "items": { "$ref": "#/$defs/port" } },
256
- "tier": { "type": "integer", "minimum": 1, "maximum": 5 },
310
+ "tier": { "type": "integer", "minimum": 1, "maximum": 6 },
257
311
  "form": { "enum": ["six", "chrome-154"] },
258
312
  "pref": {
259
313
  "type": "object",
@@ -265,6 +319,16 @@
265
319
  "form": { "$ref": "#/$defs/form" }
266
320
  }
267
321
  },
322
+ "sixRoot": {
323
+ "description": "A base location, then path segments under it.",
324
+ "type": "object",
325
+ "additionalProperties": false,
326
+ "required": ["base", "path"],
327
+ "properties": {
328
+ "base": { "$ref": "#/$defs/location" },
329
+ "path": { "$ref": "#/$defs/segments" }
330
+ }
331
+ },
268
332
  "location": {
269
333
  "description": "An environment variable, else a dir under the home dir or an absolute path.",
270
334
  "type": "object",
@@ -46,7 +46,8 @@
46
46
  "process",
47
47
  "probe",
48
48
  "origins",
49
- "installed"
49
+ "installed",
50
+ "six"
50
51
  ]
51
52
  }
52
53
  },
@@ -55,7 +56,7 @@
55
56
  "type": "object",
56
57
  "propertyNames": {
57
58
  "type": "string",
58
- "pattern": "^\\{(home|config|sevenProfiles|userData:[a-z0-9-]+)\\}/[^\\\\]+$"
59
+ "pattern": "^\\{(home|config|sevenProfiles|sixProfiles|userData:[a-z0-9-]+)\\}/[^\\\\]+$"
59
60
  },
60
61
  "additionalProperties": { "type": "string" }
61
62
  },
@@ -99,6 +100,10 @@
99
100
  "installed": {
100
101
  "type": "array",
101
102
  "items": { "$ref": "browsers.schema.json#/$defs/installed" }
103
+ },
104
+ "auto": {
105
+ "description": "With needs six: the id of the first entry that isn't six's, or null.",
106
+ "type": ["string", "null"]
102
107
  }
103
108
  }
104
109
  }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/ai-ecoverse/slicc-browsers/schema/protected.schema.json",
4
+ "title": "slicc-browsers protected-origin test vectors, schema 1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schema", "origins", "urls", "targets", "cookieDomains", "storageKeys"],
8
+ "properties": {
9
+ "schema": { "const": 1 },
10
+ "origins": { "type": "array", "items": { "type": "string", "minLength": 1 } },
11
+ "urls": {
12
+ "type": "array",
13
+ "items": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": ["url", "protected"],
17
+ "properties": {
18
+ "url": { "type": "string" },
19
+ "protected": { "type": "boolean" }
20
+ }
21
+ }
22
+ },
23
+ "targets": {
24
+ "type": "array",
25
+ "items": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["url", "protected"],
29
+ "properties": {
30
+ "url": { "type": "string" },
31
+ "previous": { "type": "boolean" },
32
+ "opener": { "enum": ["protected", "unprotected", "unknown"] },
33
+ "protected": { "type": "boolean" }
34
+ }
35
+ }
36
+ },
37
+ "cookieDomains": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object",
41
+ "additionalProperties": false,
42
+ "required": ["domain", "protected"],
43
+ "properties": {
44
+ "domain": { "type": "string" },
45
+ "protected": { "type": "boolean" }
46
+ }
47
+ }
48
+ },
49
+ "storageKeys": {
50
+ "type": "array",
51
+ "items": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": ["key", "protected"],
55
+ "properties": {
56
+ "key": { "type": "string" },
57
+ "protected": { "type": "boolean" }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }