@ai-ecoverse/sliccy-browser 0.1.42 → 0.1.44
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/package.json +1 -1
- package/src/credential-origins.js +14 -0
- package/src/guard.js +40 -1
- package/src/protected.js +49 -0
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/sliccy-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "sliccy:browser for jsh, over CDP. Discovers Chrome via SLICC_CDP_URL, slicc browsers --json, DevToolsActivePort under slicc profiles (live /json/version must match the file's websocket path), then 127.0.0.1:9222. Discovered endpoints refuse seven/vault/extension/error pages; pre-attach websocket frames are dropped with a one-time warning.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const CREDENTIAL_ORIGIN_FLOOR = [
|
|
2
|
+
'https://ims-na1.adobelogin.com',
|
|
3
|
+
'https://ims-na1-stg1.adobelogin.com',
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
export const CATALOG_CREDENTIAL_ORIGINS = {
|
|
7
|
+
origins: ['https://ims-na1.adobelogin.com', 'https://ims-na1-stg1.adobelogin.com'],
|
|
8
|
+
refusal: 'slicc: refused: this origin holds sign-in credentials',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const CREDENTIAL_ORIGINS = {
|
|
12
|
+
origins: [...new Set([...CREDENTIAL_ORIGIN_FLOOR, ...CATALOG_CREDENTIAL_ORIGINS.origins])],
|
|
13
|
+
refusal: CATALOG_CREDENTIAL_ORIGINS.refusal,
|
|
14
|
+
};
|
package/src/guard.js
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CREDENTIAL_ORIGINS as CREDENTIAL_ORIGIN_RULES } from './credential-origins.js';
|
|
2
|
+
import { credentialOrigins as credentialOriginsOf, protectedOrigins } from './protected.js';
|
|
2
3
|
import { PROTECTED_ORIGINS } from './protected-origins.js';
|
|
3
4
|
|
|
4
5
|
export const REFUSAL = PROTECTED_ORIGINS.refusal;
|
|
5
6
|
|
|
6
7
|
const guard = protectedOrigins(PROTECTED_ORIGINS);
|
|
8
|
+
const credential = credentialOriginsOf(CREDENTIAL_ORIGIN_RULES);
|
|
9
|
+
|
|
10
|
+
export const CREDENTIAL_ORIGINS = CREDENTIAL_ORIGIN_RULES.origins;
|
|
11
|
+
export const CREDENTIAL_REFUSAL = CREDENTIAL_ORIGIN_RULES.refusal;
|
|
12
|
+
|
|
13
|
+
const credentialHosts = credential.hosts();
|
|
14
|
+
|
|
15
|
+
function coversCredential(domain) {
|
|
16
|
+
return domain.length > 0 && credentialHosts.some((host) => under(host, domain));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function credentialUrl(text) {
|
|
20
|
+
let host;
|
|
21
|
+
try {
|
|
22
|
+
host = hostOf(asHttp(text));
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (host.startsWith('[') || /^[0-9.]+$/u.test(host)) return false;
|
|
27
|
+
const labels = host.split('.');
|
|
28
|
+
for (let at = 0; at < labels.length - 1; at += 1) {
|
|
29
|
+
if (coversCredential(labels.slice(at).join('.'))) return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function credentialCookie(cookie) {
|
|
35
|
+
if (!cookie || typeof cookie !== 'object') return true;
|
|
36
|
+
if (typeof cookie.domain === 'string' && credential.cookieDomain(cookie.domain)) return true;
|
|
37
|
+
if (typeof cookie.url === 'string' && credentialUrl(cookie.url)) return true;
|
|
38
|
+
const key = cookie.partitionKey;
|
|
39
|
+
if (typeof key === 'string') return credential.topLevelSite(key);
|
|
40
|
+
if (key && typeof key === 'object' && typeof key.topLevelSite === 'string') {
|
|
41
|
+
return credential.topLevelSite(key.topLevelSite);
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
7
45
|
|
|
8
46
|
function under(host, domain) {
|
|
9
47
|
return host === domain || host.endsWith(`.${domain}`);
|
|
@@ -66,6 +104,7 @@ function siteProtected(site) {
|
|
|
66
104
|
|
|
67
105
|
export function cookieProtected(cookie) {
|
|
68
106
|
if (!cookie || typeof cookie !== 'object') return true;
|
|
107
|
+
if (credentialCookie(cookie)) return true;
|
|
69
108
|
if (typeof cookie.domain === 'string' && guard.cookieDomain(cookie.domain)) return true;
|
|
70
109
|
if (typeof cookie.url === 'string') {
|
|
71
110
|
if (isProtectedUrl(cookie.url)) return true;
|
package/src/protected.js
CHANGED
|
@@ -113,3 +113,52 @@ export function protectedOrigins(rules, extraOrigins = []) {
|
|
|
113
113
|
|
|
114
114
|
return { url, target, cookieDomain, storageKey, unparseable, extensionFrame };
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
export function credentialOrigins(rules) {
|
|
118
|
+
const hosts = (rules?.origins ?? [])
|
|
119
|
+
.map((text) => {
|
|
120
|
+
const u = parse(text);
|
|
121
|
+
return u?.host ? hostOf(u) : null;
|
|
122
|
+
})
|
|
123
|
+
.filter(Boolean);
|
|
124
|
+
|
|
125
|
+
const hostMatch = (text) => {
|
|
126
|
+
const u = parse(text);
|
|
127
|
+
if (!u || !['http', 'https'].includes(scheme(u))) return false;
|
|
128
|
+
const h = hostOf(u);
|
|
129
|
+
return hosts.includes(h);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const cookieDomain = (domain) => {
|
|
133
|
+
let d = String(domain ?? '').toLowerCase();
|
|
134
|
+
if (d.startsWith('.')) d = d.slice(1);
|
|
135
|
+
if (d.endsWith('.')) d = d.slice(0, -1);
|
|
136
|
+
if (d === '') return false;
|
|
137
|
+
return hosts.some((h) => under(h, d));
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const topLevelSite = (text) => {
|
|
141
|
+
const u = parse(text);
|
|
142
|
+
if (!u || !['http', 'https'].includes(scheme(u))) return false;
|
|
143
|
+
const site = hostOf(u);
|
|
144
|
+
return hosts.some((h) => under(h, site));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const storageKey = (key) => {
|
|
148
|
+
const [first, ...rest] = String(key ?? '').split('^');
|
|
149
|
+
if (hostMatch(first)) return true;
|
|
150
|
+
return rest
|
|
151
|
+
.filter((p) => p.startsWith('0'))
|
|
152
|
+
.map((p) => p.slice(1))
|
|
153
|
+
.some((text) => topLevelSite(text));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
url: hostMatch,
|
|
158
|
+
cookieDomain,
|
|
159
|
+
topLevelSite,
|
|
160
|
+
storageKey,
|
|
161
|
+
hosts: () => [...hosts],
|
|
162
|
+
refusal: () => rules?.refusal ?? '',
|
|
163
|
+
};
|
|
164
|
+
}
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.44';
|