@zoreal/oauth2-js 0.1.21 → 0.1.22
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/dist/index.cjs +26 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -328,7 +328,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
|
|
|
328
328
|
* auth-code mode leaves it to the RP backend.
|
|
329
329
|
*/
|
|
330
330
|
declare const WIRE_VERSION = 1;
|
|
331
|
-
declare const SDK_VERSION = "0.1.
|
|
331
|
+
declare const SDK_VERSION = "0.1.22";
|
|
332
332
|
declare const SDK_NAME = "@zoreal/oauth2-js";
|
|
333
333
|
declare const DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
334
334
|
/** Pending TTL is short. Poll gently; over-polling cancels the request. */
|
package/dist/index.d.ts
CHANGED
|
@@ -328,7 +328,7 @@ declare function mountPairingModal(state: PairingState, options: PairingModalOpt
|
|
|
328
328
|
* auth-code mode leaves it to the RP backend.
|
|
329
329
|
*/
|
|
330
330
|
declare const WIRE_VERSION = 1;
|
|
331
|
-
declare const SDK_VERSION = "0.1.
|
|
331
|
+
declare const SDK_VERSION = "0.1.22";
|
|
332
332
|
declare const SDK_NAME = "@zoreal/oauth2-js";
|
|
333
333
|
declare const DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
334
334
|
/** Pending TTL is short. Poll gently; over-polling cancels the request. */
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ function unsafeClaims(idToken) {
|
|
|
14
14
|
|
|
15
15
|
// src/wire.ts
|
|
16
16
|
var WIRE_VERSION = 1;
|
|
17
|
-
var SDK_VERSION = "0.1.
|
|
17
|
+
var SDK_VERSION = "0.1.22";
|
|
18
18
|
var SDK_NAME = "@zoreal/oauth2-js";
|
|
19
19
|
var DEFAULT_ISSUER = "https://id.zoreal.com";
|
|
20
20
|
var POLL_INTERVAL_MS = 2e3;
|
|
@@ -816,6 +816,30 @@ function markReturnDone(requestId) {
|
|
|
816
816
|
function isReturnDone(requestId) {
|
|
817
817
|
return storage()?.getItem(DONE + requestId) !== null && storage()?.getItem(DONE + requestId) !== void 0;
|
|
818
818
|
}
|
|
819
|
+
function visibleOrDone(requestId, signal) {
|
|
820
|
+
if (typeof document === "undefined" || document.visibilityState !== "hidden") {
|
|
821
|
+
return Promise.resolve(!isReturnDone(requestId));
|
|
822
|
+
}
|
|
823
|
+
return new Promise((resolve) => {
|
|
824
|
+
const finish = (value) => {
|
|
825
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
826
|
+
window.removeEventListener("storage", onStorage);
|
|
827
|
+
signal?.removeEventListener("abort", onAbort);
|
|
828
|
+
resolve(value);
|
|
829
|
+
};
|
|
830
|
+
const onVisible = () => {
|
|
831
|
+
if (document.visibilityState !== "hidden") finish(!isReturnDone(requestId));
|
|
832
|
+
};
|
|
833
|
+
const onStorage = () => {
|
|
834
|
+
if (isReturnDone(requestId)) finish(false);
|
|
835
|
+
};
|
|
836
|
+
const onAbort = () => finish(false);
|
|
837
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
838
|
+
window.addEventListener("storage", onStorage);
|
|
839
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
840
|
+
if (isReturnDone(requestId)) finish(false);
|
|
841
|
+
});
|
|
842
|
+
}
|
|
819
843
|
function returnToUrl() {
|
|
820
844
|
if (typeof window === "undefined") return void 0;
|
|
821
845
|
const { href } = window.location;
|
|
@@ -2127,7 +2151,7 @@ function startLogin(options) {
|
|
|
2127
2151
|
controller.signal,
|
|
2128
2152
|
{ tolerateUnknownUntil: Date.now() + 15e3 }
|
|
2129
2153
|
);
|
|
2130
|
-
if (
|
|
2154
|
+
if (!await visibleOrDone(requestId, controller.signal)) {
|
|
2131
2155
|
throw new DOMException("aborted", "AbortError");
|
|
2132
2156
|
}
|
|
2133
2157
|
} else {
|