@plitzi/sdk-shared 0.39.16 → 0.39.18
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/CHANGELOG.md +11 -0
- package/dist/auth/failureChannel.d.ts +3 -0
- package/dist/auth/failureChannel.mjs +13 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.39.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 71ad357: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
|
|
10
|
+
## 0.39.17
|
|
11
|
+
|
|
12
|
+
No changes in this release.
|
|
13
|
+
|
|
3
14
|
## 0.39.16
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -15,6 +15,9 @@ export type AuthFailureListener = (signal: AuthFailureSignal) => Promise<boolean
|
|
|
15
15
|
* coming back after its token's life — is answered by a renewal, and the request that was refused can be asked again,
|
|
16
16
|
* once, instead of leaving its section in an error a reload would have cleared. A refused request never ran, so asking
|
|
17
17
|
* it again repeats nothing.
|
|
18
|
+
*
|
|
19
|
+
* Never silent: a refusal no listener hears is said once on the page — what hid the builder's own copy of this channel
|
|
20
|
+
* — and a listener that fails is said and counted as not renewing, never a rejection the caller (often `void`) loses.
|
|
18
21
|
*/
|
|
19
22
|
export declare const reportAuthFailure: (signal: AuthFailureSignal) => Promise<boolean>;
|
|
20
23
|
export declare const onAuthFailure: (listener: AuthFailureListener) => (() => void);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var e = Symbol.for("plitzi.authFailureListeners.v1"), t = ((t) => {
|
|
2
|
+
let n = t[e];
|
|
3
|
+
if (n === void 0) {
|
|
4
|
+
let n = /* @__PURE__ */ new Set();
|
|
5
|
+
return t[e] = n, n;
|
|
6
|
+
}
|
|
7
|
+
return n instanceof Set ? n : (console.error(`[auth] ${e.toString()} holds ${typeof n}, not the set of listeners every copy of @plitzi/sdk-shared shares: this copy keeps its own, so a refusal it reports reaches only the auth of this copy. Something else wrote that key, or a copy changed its shape without bumping CHANNEL_VERSION.`), /* @__PURE__ */ new Set());
|
|
8
|
+
})(globalThis), n = !1, r = async (e) => t.size === 0 ? (!n && typeof window < "u" && (n = !0, console.warn(`[auth] A refused credential (${e.reason}${e.url ? `, ${e.url}` : ""}) was reported, but nothing on this page listens for it, so the session is not renewed. Said once; every later refusal is answered as it was.`)), !1) : (await Promise.allSettled([...t].map(async (t) => t(e)))).some((e) => e.status === "rejected" ? (console.error("[auth] A listener failed on a refused credential; it is counted as not renewing:", e.reason), !1) : e.value === !0), i = (e) => (t.add(e), () => t.delete(e)), a = [
|
|
3
9
|
"missing",
|
|
4
10
|
"expired",
|
|
5
11
|
"revoked",
|
|
@@ -9,17 +15,17 @@ var e = /* @__PURE__ */ new Set(), t = async (t) => (await Promise.all([...e].ma
|
|
|
9
15
|
"malformed",
|
|
10
16
|
"outdated",
|
|
11
17
|
"network"
|
|
12
|
-
],
|
|
18
|
+
], o = (e, t) => {
|
|
13
19
|
if (e !== 401) return;
|
|
14
20
|
let n = t?.reason;
|
|
15
|
-
return typeof n == "string" &&
|
|
16
|
-
},
|
|
21
|
+
return typeof n == "string" && a.includes(n) ? n : "expired";
|
|
22
|
+
}, s = (e) => /([^.]+\.[^.]+)$/.exec(e)?.[1] ?? e, c = (e, t) => {
|
|
17
23
|
if (!e || !t) return !1;
|
|
18
24
|
try {
|
|
19
25
|
let n = typeof window > "u" ? void 0 : window.location.href;
|
|
20
|
-
return
|
|
26
|
+
return s(new URL(e, n).hostname) === s(new URL(t, n).hostname);
|
|
21
27
|
} catch {
|
|
22
28
|
return !1;
|
|
23
29
|
}
|
|
24
30
|
};
|
|
25
|
-
export {
|
|
31
|
+
export { o as authFailureFromResponse, i as onAuthFailure, r as reportAuthFailure, c as sameRegistrableDomain };
|