@aglyn/shared-util-dom 1.0.0-beta.275 → 1.0.0-beta.282
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 +2 -2
- package/src/lib/clear-service-worker-caches.d.ts +42 -0
- package/src/lib/clear-service-worker-caches.js +57 -0
- package/src/lib/clear-service-worker-caches.js.map +1 -0
- package/src/lib/is-mobile-browser.d.ts +26 -0
- package/src/lib/is-mobile-browser.js +34 -0
- package/src/lib/is-mobile-browser.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/shared-util-dom",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.282",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
28
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.282",
|
|
29
29
|
"@swc/helpers": "0.5.23",
|
|
30
30
|
"mobx": "^7.0.5",
|
|
31
31
|
"rxjs": "^7.8.2"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Drop every Cache Storage entry for this origin (AGL-1056).
|
|
19
|
+
*
|
|
20
|
+
* The other half of AGL-1054's isolation guarantee: nothing this session put
|
|
21
|
+
* on disk may outlive it on a shared or kiosk machine. Called on sign-out —
|
|
22
|
+
* which includes the staff **impersonation exit**, the case where one user's
|
|
23
|
+
* bytes most obviously must not survive.
|
|
24
|
+
*
|
|
25
|
+
* ## Why caches and not `unregister()`
|
|
26
|
+
*
|
|
27
|
+
* A deliberate split, not an oversight. The registration holds no user data —
|
|
28
|
+
* it is a pointer to a script that is identical for everyone. The *cache* is
|
|
29
|
+
* the only thing that could hold bytes, so the cache is what gets cleared.
|
|
30
|
+
*
|
|
31
|
+
* Unregistering would also throw away the precached offline page, so the next
|
|
32
|
+
* person to sign in on this device would get the browser's error page instead
|
|
33
|
+
* of ours the first time their network dropped — a real loss, for no isolation
|
|
34
|
+
* gain. If the worker ever caches something user-scoped, this decision has to
|
|
35
|
+
* be revisited, which is why the reasoning is written down rather than implied.
|
|
36
|
+
*
|
|
37
|
+
* Best effort throughout: a sign-out must never fail because a cache would not
|
|
38
|
+
* open. The session cookie and the Firebase sign-out are what actually end the
|
|
39
|
+
* session; this is defence in depth behind them.
|
|
40
|
+
*/
|
|
41
|
+
export declare function clearServiceWorkerCaches(): Promise<number>;
|
|
42
|
+
export default clearServiceWorkerCaches;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* Drop every Cache Storage entry for this origin (AGL-1056).
|
|
18
|
+
*
|
|
19
|
+
* The other half of AGL-1054's isolation guarantee: nothing this session put
|
|
20
|
+
* on disk may outlive it on a shared or kiosk machine. Called on sign-out —
|
|
21
|
+
* which includes the staff **impersonation exit**, the case where one user's
|
|
22
|
+
* bytes most obviously must not survive.
|
|
23
|
+
*
|
|
24
|
+
* ## Why caches and not `unregister()`
|
|
25
|
+
*
|
|
26
|
+
* A deliberate split, not an oversight. The registration holds no user data —
|
|
27
|
+
* it is a pointer to a script that is identical for everyone. The *cache* is
|
|
28
|
+
* the only thing that could hold bytes, so the cache is what gets cleared.
|
|
29
|
+
*
|
|
30
|
+
* Unregistering would also throw away the precached offline page, so the next
|
|
31
|
+
* person to sign in on this device would get the browser's error page instead
|
|
32
|
+
* of ours the first time their network dropped — a real loss, for no isolation
|
|
33
|
+
* gain. If the worker ever caches something user-scoped, this decision has to
|
|
34
|
+
* be revisited, which is why the reasoning is written down rather than implied.
|
|
35
|
+
*
|
|
36
|
+
* Best effort throughout: a sign-out must never fail because a cache would not
|
|
37
|
+
* open. The session cookie and the Firebase sign-out are what actually end the
|
|
38
|
+
* session; this is defence in depth behind them.
|
|
39
|
+
*/ export async function clearServiceWorkerCaches() {
|
|
40
|
+
// Guarded on `caches` itself rather than on `window`. It is the only global
|
|
41
|
+
// this touches, and keying on `window` made the function untestable outside
|
|
42
|
+
// a DOM for no benefit — the narrower check was also strictly weaker, since
|
|
43
|
+
// `caches` can be absent in a window that exists.
|
|
44
|
+
if (typeof caches === 'undefined') return 0;
|
|
45
|
+
try {
|
|
46
|
+
const names = await caches.keys();
|
|
47
|
+
const results = await Promise.all(names.map((name)=>caches.delete(name).catch(()=>false)));
|
|
48
|
+
return results.filter(Boolean).length;
|
|
49
|
+
} catch (unused) {
|
|
50
|
+
// Storage can be unavailable in a private window or under a strict
|
|
51
|
+
// policy. Nothing was cached in that case either.
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export default clearServiceWorkerCaches;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=clear-service-worker-caches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/clear-service-worker-caches.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Drop every Cache Storage entry for this origin (AGL-1056).\n *\n * The other half of AGL-1054's isolation guarantee: nothing this session put\n * on disk may outlive it on a shared or kiosk machine. Called on sign-out —\n * which includes the staff **impersonation exit**, the case where one user's\n * bytes most obviously must not survive.\n *\n * ## Why caches and not `unregister()`\n *\n * A deliberate split, not an oversight. The registration holds no user data —\n * it is a pointer to a script that is identical for everyone. The *cache* is\n * the only thing that could hold bytes, so the cache is what gets cleared.\n *\n * Unregistering would also throw away the precached offline page, so the next\n * person to sign in on this device would get the browser's error page instead\n * of ours the first time their network dropped — a real loss, for no isolation\n * gain. If the worker ever caches something user-scoped, this decision has to\n * be revisited, which is why the reasoning is written down rather than implied.\n *\n * Best effort throughout: a sign-out must never fail because a cache would not\n * open. The session cookie and the Firebase sign-out are what actually end the\n * session; this is defence in depth behind them.\n */\nexport async function clearServiceWorkerCaches(): Promise<number> {\n // Guarded on `caches` itself rather than on `window`. It is the only global\n // this touches, and keying on `window` made the function untestable outside\n // a DOM for no benefit — the narrower check was also strictly weaker, since\n // `caches` can be absent in a window that exists.\n if (typeof caches === 'undefined') return 0\n try {\n const names = await caches.keys()\n const results = await Promise.all(\n names.map((name) => caches.delete(name).catch(() => false)),\n )\n return results.filter(Boolean).length\n } catch {\n // Storage can be unavailable in a private window or under a strict\n // policy. Nothing was cached in that case either.\n return 0\n }\n}\n\nexport default clearServiceWorkerCaches\n"],"names":["clearServiceWorkerCaches","caches","names","keys","results","Promise","all","map","name","delete","catch","filter","Boolean","length"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GACD,OAAO,eAAeA;IACpB,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,kDAAkD;IAClD,IAAI,OAAOC,WAAW,aAAa,OAAO;IAC1C,IAAI;QACF,MAAMC,QAAQ,MAAMD,OAAOE,IAAI;QAC/B,MAAMC,UAAU,MAAMC,QAAQC,GAAG,CAC/BJ,MAAMK,GAAG,CAAC,CAACC,OAASP,OAAOQ,MAAM,CAACD,MAAME,KAAK,CAAC,IAAM;QAEtD,OAAON,QAAQO,MAAM,CAACC,SAASC,MAAM;IACvC,EAAE,eAAM;QACN,mEAAmE;QACnE,kDAAkD;QAClD,OAAO;IACT;AACF;AAEA,eAAeb,yBAAwB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* OAuth flow selector (AGL-462): mobile browsers turn `signInWithPopup`
|
|
19
|
+
* into a new tab whose handle the SDK loses (COOP + partitioned storage),
|
|
20
|
+
* so sign-in completes on Google's side but never reaches the app —
|
|
21
|
+
* those environments must use the redirect flow instead. Heuristic, not
|
|
22
|
+
* biometric: prefer UA-Client-Hints, fall back to UA sniffing, and catch
|
|
23
|
+
* iPadOS masquerading as macOS via its touch surface.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isMobileBrowser(): boolean;
|
|
26
|
+
export default isMobileBrowser;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* OAuth flow selector (AGL-462): mobile browsers turn `signInWithPopup`
|
|
18
|
+
* into a new tab whose handle the SDK loses (COOP + partitioned storage),
|
|
19
|
+
* so sign-in completes on Google's side but never reaches the app —
|
|
20
|
+
* those environments must use the redirect flow instead. Heuristic, not
|
|
21
|
+
* biometric: prefer UA-Client-Hints, fall back to UA sniffing, and catch
|
|
22
|
+
* iPadOS masquerading as macOS via its touch surface.
|
|
23
|
+
*/ export function isMobileBrowser() {
|
|
24
|
+
if (typeof navigator === 'undefined') return false;
|
|
25
|
+
const uaData = navigator.userAgentData;
|
|
26
|
+
if (typeof (uaData == null ? void 0 : uaData.mobile) === 'boolean') return uaData.mobile;
|
|
27
|
+
if (/Android|iPhone|iPad|iPod|Mobile|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return /Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints > 1;
|
|
31
|
+
}
|
|
32
|
+
export default isMobileBrowser;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=is-mobile-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/shared/util/dom/src/lib/is-mobile-browser.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * OAuth flow selector (AGL-462): mobile browsers turn `signInWithPopup`\n * into a new tab whose handle the SDK loses (COOP + partitioned storage),\n * so sign-in completes on Google's side but never reaches the app —\n * those environments must use the redirect flow instead. Heuristic, not\n * biometric: prefer UA-Client-Hints, fall back to UA sniffing, and catch\n * iPadOS masquerading as macOS via its touch surface.\n */\nexport function isMobileBrowser(): boolean {\n if (typeof navigator === 'undefined') return false\n const uaData = (\n navigator as Navigator & { userAgentData?: { mobile?: boolean } }\n ).userAgentData\n if (typeof uaData?.mobile === 'boolean') return uaData.mobile\n if (/Android|iPhone|iPad|iPod|Mobile|IEMobile|Opera Mini/i.test(navigator.userAgent)) {\n return true\n }\n return /Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints > 1\n}\n\nexport default isMobileBrowser\n"],"names":["isMobileBrowser","navigator","uaData","userAgentData","mobile","test","userAgent","maxTouchPoints"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC,GACD,OAAO,SAASA;IACd,IAAI,OAAOC,cAAc,aAAa,OAAO;IAC7C,MAAMC,SAAS,AACbD,UACAE,aAAa;IACf,IAAI,QAAOD,0BAAAA,OAAQE,MAAM,MAAK,WAAW,OAAOF,OAAOE,MAAM;IAC7D,IAAI,uDAAuDC,IAAI,CAACJ,UAAUK,SAAS,GAAG;QACpF,OAAO;IACT;IACA,OAAO,aAAaD,IAAI,CAACJ,UAAUK,SAAS,KAAKL,UAAUM,cAAc,GAAG;AAC9E;AAEA,eAAeP,gBAAe"}
|