@axa-fr/oidc-client 7.26.7 → 7.27.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/README.md +2 -1
- package/dist/index.js +661 -591
- package/dist/index.umd.cjs +2 -2
- package/dist/initSession.d.ts +1 -1
- package/dist/initSession.d.ts.map +1 -1
- package/dist/initSession.spec.d.ts +2 -0
- package/dist/initSession.spec.d.ts.map +1 -0
- package/dist/initWorker.d.ts.map +1 -1
- package/dist/keepSession.d.ts.map +1 -1
- package/dist/login.d.ts.map +1 -1
- package/dist/logout.d.ts.map +1 -1
- package/dist/oidc.d.ts.map +1 -1
- package/dist/renewTokens.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/initSession.spec.ts +215 -0
- package/src/initSession.ts +21 -9
- package/src/initWorker.ts +71 -24
- package/src/keepSession.ts +6 -2
- package/src/login.ts +16 -3
- package/src/logout.ts +5 -1
- package/src/oidc.ts +10 -2
- package/src/renewTokens.ts +20 -4
- package/src/types.ts +1 -0
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class Q {
|
|
2
2
|
open(n) {
|
|
3
3
|
window.location.href = n;
|
|
4
4
|
}
|
|
@@ -16,10 +16,10 @@ class j {
|
|
|
16
16
|
return window.origin;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
class
|
|
21
|
-
constructor(n, t, s, o =
|
|
22
|
-
this._callback = n, this._client_id = t, this._url = s, this._interval = o ||
|
|
19
|
+
const ye = 2e3, K = console;
|
|
20
|
+
class $e {
|
|
21
|
+
constructor(n, t, s, o = ye, i = !0) {
|
|
22
|
+
this._callback = n, this._client_id = t, this._url = s, this._interval = o || ye, this._stopOnError = i;
|
|
23
23
|
const r = s.indexOf("/", s.indexOf("//") + 2);
|
|
24
24
|
this._frame_origin = s.substring(0, r), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = s;
|
|
25
25
|
}
|
|
@@ -31,10 +31,10 @@ class De {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
_message(n) {
|
|
34
|
-
n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (
|
|
34
|
+
n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (K.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : n.data === "changed" ? (K.debug(n), K.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : K.debug("CheckSessionIFrame: " + n.data + " message from check session op iframe"));
|
|
35
35
|
}
|
|
36
36
|
start(n) {
|
|
37
|
-
|
|
37
|
+
K.debug("CheckSessionIFrame.start :" + n), this.stop();
|
|
38
38
|
const t = () => {
|
|
39
39
|
this._frame.contentWindow.postMessage(
|
|
40
40
|
this._client_id + " " + n,
|
|
@@ -44,10 +44,10 @@ class De {
|
|
|
44
44
|
t(), this._timer = window.setInterval(t, this._interval);
|
|
45
45
|
}
|
|
46
46
|
stop() {
|
|
47
|
-
this._timer && (
|
|
47
|
+
this._timer && (K.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const k = {
|
|
51
51
|
service_worker_not_supported_by_browser: "service_worker_not_supported_by_browser",
|
|
52
52
|
token_acquired: "token_acquired",
|
|
53
53
|
logout_from_another_tab: "logout_from_another_tab",
|
|
@@ -76,89 +76,89 @@ const p = {
|
|
|
76
76
|
syncTokensAsync_end: "syncTokensAsync_end",
|
|
77
77
|
syncTokensAsync_error: "syncTokensAsync_error",
|
|
78
78
|
tokensInvalidAndWaitingActionsToRefresh: "tokensInvalidAndWaitingActionsToRefresh"
|
|
79
|
-
},
|
|
80
|
-
const t = (
|
|
79
|
+
}, C = (e, n = sessionStorage, t) => {
|
|
80
|
+
const s = t ?? n, o = (w) => (n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: w }), delete n[`oidc.${e}.userInfo`], t && t !== n && (delete s[`oidc.login.${e}`], delete s[`oidc.state.${e}`], delete s[`oidc.code_verifier.${e}`], delete s[`oidc.nonce.${e}`]), Promise.resolve()), i = async () => {
|
|
81
81
|
if (!n[`oidc.${e}`])
|
|
82
82
|
return n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
|
|
83
|
-
const
|
|
84
|
-
return Promise.resolve({ tokens:
|
|
85
|
-
},
|
|
86
|
-
n[`oidc.${e}`] = JSON.stringify({ tokens:
|
|
87
|
-
},
|
|
88
|
-
n[`oidc.session_state.${e}`] =
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
n[`oidc.jwk.${e}`] = JSON.stringify(
|
|
93
|
-
},
|
|
94
|
-
n[`oidc.dpop_nonce.${e}`] =
|
|
95
|
-
},
|
|
83
|
+
const w = JSON.parse(n[`oidc.${e}`]);
|
|
84
|
+
return Promise.resolve({ tokens: w.tokens, status: w.status });
|
|
85
|
+
}, r = (w) => {
|
|
86
|
+
n[`oidc.${e}`] = JSON.stringify({ tokens: w });
|
|
87
|
+
}, a = async (w) => {
|
|
88
|
+
n[`oidc.session_state.${e}`] = w;
|
|
89
|
+
}, c = async () => n[`oidc.session_state.${e}`], f = (w) => {
|
|
90
|
+
s[`oidc.nonce.${e}`] = w.nonce;
|
|
91
|
+
}, u = (w) => {
|
|
92
|
+
n[`oidc.jwk.${e}`] = JSON.stringify(w);
|
|
93
|
+
}, l = () => JSON.parse(n[`oidc.jwk.${e}`]), h = async () => ({ nonce: s[`oidc.nonce.${e}`] }), _ = async (w) => {
|
|
94
|
+
n[`oidc.dpop_nonce.${e}`] = w;
|
|
95
|
+
}, m = () => n[`oidc.dpop_nonce.${e}`], p = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, g = {};
|
|
96
96
|
return {
|
|
97
|
-
clearAsync:
|
|
98
|
-
initAsync:
|
|
99
|
-
setTokens:
|
|
100
|
-
getTokens:
|
|
101
|
-
setSessionStateAsync:
|
|
102
|
-
getSessionStateAsync:
|
|
103
|
-
setNonceAsync:
|
|
104
|
-
getNonceAsync:
|
|
105
|
-
setLoginParams: (
|
|
106
|
-
|
|
97
|
+
clearAsync: o,
|
|
98
|
+
initAsync: i,
|
|
99
|
+
setTokens: r,
|
|
100
|
+
getTokens: p,
|
|
101
|
+
setSessionStateAsync: a,
|
|
102
|
+
getSessionStateAsync: c,
|
|
103
|
+
setNonceAsync: f,
|
|
104
|
+
getNonceAsync: h,
|
|
105
|
+
setLoginParams: (w) => {
|
|
106
|
+
g[e] = w, s[`oidc.login.${e}`] = JSON.stringify(w);
|
|
107
107
|
},
|
|
108
108
|
getLoginParams: () => {
|
|
109
|
-
const
|
|
110
|
-
return
|
|
109
|
+
const w = s[`oidc.login.${e}`];
|
|
110
|
+
return w ? (g[e] || (g[e] = JSON.parse(w)), g[e]) : (console.warn(
|
|
111
111
|
`storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`
|
|
112
112
|
), null);
|
|
113
113
|
},
|
|
114
|
-
getStateAsync: async () =>
|
|
115
|
-
setStateAsync: async (
|
|
116
|
-
|
|
114
|
+
getStateAsync: async () => s[`oidc.state.${e}`],
|
|
115
|
+
setStateAsync: async (w) => {
|
|
116
|
+
s[`oidc.state.${e}`] = w;
|
|
117
117
|
},
|
|
118
|
-
getCodeVerifierAsync: async () =>
|
|
119
|
-
setCodeVerifierAsync: async (
|
|
120
|
-
|
|
118
|
+
getCodeVerifierAsync: async () => s[`oidc.code_verifier.${e}`],
|
|
119
|
+
setCodeVerifierAsync: async (w) => {
|
|
120
|
+
s[`oidc.code_verifier.${e}`] = w;
|
|
121
121
|
},
|
|
122
|
-
setDemonstratingProofOfPossessionNonce:
|
|
123
|
-
getDemonstratingProofOfPossessionNonce:
|
|
124
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
125
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
122
|
+
setDemonstratingProofOfPossessionNonce: _,
|
|
123
|
+
getDemonstratingProofOfPossessionNonce: m,
|
|
124
|
+
setDemonstratingProofOfPossessionJwkAsync: u,
|
|
125
|
+
getDemonstratingProofOfPossessionJwkAsync: l
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
var
|
|
128
|
+
var H = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(H || {});
|
|
129
129
|
const Re = (e) => decodeURIComponent(
|
|
130
130
|
Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
131
|
-
),
|
|
131
|
+
), Ke = (e) => JSON.parse(Re(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), ke = (e) => {
|
|
132
132
|
try {
|
|
133
|
-
return e &&
|
|
133
|
+
return e && Ue(e, ".") === 2 ? Ke(e.split(".")[1]) : null;
|
|
134
134
|
} catch (n) {
|
|
135
135
|
console.warn(n);
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
138
|
-
},
|
|
138
|
+
}, Ue = (e, n) => e.split(n).length - 1, oe = {
|
|
139
139
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
140
140
|
access_token_invalid: "access_token_invalid",
|
|
141
141
|
id_token_invalid: "id_token_invalid"
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function Ve(e, n, t) {
|
|
144
144
|
if (e.issuedAt) {
|
|
145
145
|
if (typeof e.issuedAt == "string")
|
|
146
146
|
return parseInt(e.issuedAt, 10);
|
|
147
147
|
} else return n && n.iat ? n.iat : t && t.iat ? t.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
148
148
|
return e.issuedAt;
|
|
149
149
|
}
|
|
150
|
-
const
|
|
150
|
+
const ue = (e, n = null, t) => {
|
|
151
151
|
if (!e)
|
|
152
152
|
return null;
|
|
153
153
|
let s;
|
|
154
154
|
const o = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
155
|
-
e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s =
|
|
155
|
+
e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s = ke(e.accessToken);
|
|
156
156
|
let i;
|
|
157
157
|
n != null && "idToken" in n && !("idToken" in e) ? i = n.idToken : i = e.idToken;
|
|
158
|
-
const r = e.idTokenPayload ? e.idTokenPayload :
|
|
159
|
-
e.issuedAt =
|
|
158
|
+
const r = e.idTokenPayload ? e.idTokenPayload : ke(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = s && s.exp ? s.exp : e.issuedAt + o;
|
|
159
|
+
e.issuedAt = Ve(e, s, r);
|
|
160
160
|
let f;
|
|
161
|
-
e.expiresAt ? f = e.expiresAt : t ===
|
|
161
|
+
e.expiresAt ? f = e.expiresAt : t === oe.access_token_invalid ? f = c : t === oe.id_token_invalid ? f = a : f = a < c ? a : c;
|
|
162
162
|
const u = {
|
|
163
163
|
...e,
|
|
164
164
|
idTokenPayload: r,
|
|
@@ -171,7 +171,7 @@ const ie = (e, n = null, t) => {
|
|
|
171
171
|
return { ...u, refreshToken: l };
|
|
172
172
|
}
|
|
173
173
|
return u;
|
|
174
|
-
},
|
|
174
|
+
}, _e = (e, n, t) => {
|
|
175
175
|
if (!e)
|
|
176
176
|
return null;
|
|
177
177
|
if (!e.issued_at) {
|
|
@@ -186,30 +186,30 @@ const ie = (e, n = null, t) => {
|
|
|
186
186
|
tokenType: e.token_type,
|
|
187
187
|
issuedAt: e.issued_at
|
|
188
188
|
};
|
|
189
|
-
return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload),
|
|
190
|
-
},
|
|
189
|
+
return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload), ue(s, n, t);
|
|
190
|
+
}, B = (e, n) => {
|
|
191
191
|
const t = (/* @__PURE__ */ new Date()).getTime() / 1e3, s = n - t;
|
|
192
192
|
return Math.round(s - e);
|
|
193
|
-
},
|
|
193
|
+
}, Fe = (e, n = 0) => e ? B(n, e.expiresAt) > 0 : !1, ve = async (e, n = 200, t = 50) => {
|
|
194
194
|
let s = t, o = await e.syncTokensInfoAsync();
|
|
195
195
|
for (; [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
b.REQUIRE_SYNC_TOKENS,
|
|
197
|
+
b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
|
|
198
|
+
b.TOKENS_INVALID
|
|
199
199
|
].includes(o) && s > 0; ) {
|
|
200
|
-
if (e.configuration.token_automatic_renew_mode ==
|
|
200
|
+
if (e.configuration.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted) {
|
|
201
201
|
await e.renewTokensAsync({});
|
|
202
202
|
break;
|
|
203
203
|
} else
|
|
204
|
-
await
|
|
204
|
+
await ne({ milliseconds: n });
|
|
205
205
|
s = s - 1, o = await e.syncTokensInfoAsync();
|
|
206
206
|
}
|
|
207
207
|
return {
|
|
208
|
-
isTokensValid:
|
|
208
|
+
isTokensValid: Fe(e.getTokens()),
|
|
209
209
|
tokens: e.getTokens(),
|
|
210
210
|
numberWaited: s - t
|
|
211
211
|
};
|
|
212
|
-
},
|
|
212
|
+
}, Ee = (e, n, t) => {
|
|
213
213
|
if (e.idTokenPayload) {
|
|
214
214
|
const s = e.idTokenPayload;
|
|
215
215
|
if (t.issuer !== s.iss)
|
|
@@ -236,7 +236,7 @@ const ie = (e, n = null, t) => {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
return { isValid: !0, reason: "" };
|
|
239
|
-
},
|
|
239
|
+
}, $ = (function() {
|
|
240
240
|
const e = typeof window > "u" ? global : window;
|
|
241
241
|
return {
|
|
242
242
|
setTimeout: setTimeout.bind(e),
|
|
@@ -244,32 +244,32 @@ const ie = (e, n = null, t) => {
|
|
|
244
244
|
setInterval: setInterval.bind(e),
|
|
245
245
|
clearInterval: clearInterval.bind(e)
|
|
246
246
|
};
|
|
247
|
-
})(),
|
|
248
|
-
let
|
|
249
|
-
const
|
|
247
|
+
})(), te = "7.27.0";
|
|
248
|
+
let me = null, Z;
|
|
249
|
+
const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe = (e = "/") => {
|
|
250
250
|
try {
|
|
251
|
-
|
|
251
|
+
Z = new AbortController(), fetch(
|
|
252
252
|
`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,
|
|
253
|
-
{ signal:
|
|
253
|
+
{ signal: Z.signal }
|
|
254
254
|
).catch((s) => {
|
|
255
255
|
console.log(s);
|
|
256
|
-
}),
|
|
257
|
-
() =>
|
|
256
|
+
}), ne({ milliseconds: 150 * 1e3 }).then(
|
|
257
|
+
() => Oe(e)
|
|
258
258
|
);
|
|
259
259
|
} catch (n) {
|
|
260
260
|
console.log(n);
|
|
261
261
|
}
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
},
|
|
262
|
+
}, X = () => {
|
|
263
|
+
Z && Z.abort();
|
|
264
|
+
}, be = (e) => {
|
|
265
265
|
const n = `oidc.tabId.${e}`, t = sessionStorage.getItem(n);
|
|
266
266
|
if (t) return t;
|
|
267
267
|
const s = globalThis.crypto.randomUUID();
|
|
268
268
|
return sessionStorage.setItem(n, s), s;
|
|
269
|
-
},
|
|
270
|
-
const s = n?.timeoutMs ??
|
|
269
|
+
}, Me = 5e3, Be = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, I = (e, n) => (t) => {
|
|
270
|
+
const s = n?.timeoutMs ?? Me;
|
|
271
271
|
return new Promise((o, i) => {
|
|
272
|
-
const r =
|
|
272
|
+
const r = Be(e);
|
|
273
273
|
if (!r) {
|
|
274
274
|
i(
|
|
275
275
|
new Error(
|
|
@@ -282,12 +282,12 @@ const ae = ({ milliseconds: e }) => new Promise((n) => D.setTimeout(n, e)), Te =
|
|
|
282
282
|
let c = null;
|
|
283
283
|
const f = () => {
|
|
284
284
|
try {
|
|
285
|
-
c != null && (
|
|
285
|
+
c != null && ($.clearTimeout(c), c = null), a.port1.onmessage = null, a.port1.close(), a.port2.close();
|
|
286
286
|
} catch (u) {
|
|
287
287
|
console.error(u);
|
|
288
288
|
}
|
|
289
289
|
};
|
|
290
|
-
c =
|
|
290
|
+
c = $.setTimeout(() => {
|
|
291
291
|
f(), i(
|
|
292
292
|
new Error(`Service worker did not respond within ${s}ms (type=${t?.type})`)
|
|
293
293
|
);
|
|
@@ -296,213 +296,238 @@ const ae = ({ milliseconds: e }) => new Promise((n) => D.setTimeout(n, e)), Te =
|
|
|
296
296
|
};
|
|
297
297
|
try {
|
|
298
298
|
const u = t?.configurationName;
|
|
299
|
-
r.postMessage({ ...t, tabId:
|
|
299
|
+
r.postMessage({ ...t, tabId: be(u ?? "default") }, [
|
|
300
300
|
a.port2
|
|
301
301
|
]);
|
|
302
302
|
} catch (u) {
|
|
303
303
|
f(), i(u);
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
|
-
},
|
|
306
|
+
}, Je = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((n) => {
|
|
307
307
|
let t = !1;
|
|
308
308
|
const s = () => {
|
|
309
309
|
t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
|
|
310
310
|
};
|
|
311
|
-
navigator.serviceWorker.addEventListener("controllerchange", s),
|
|
311
|
+
navigator.serviceWorker.addEventListener("controllerchange", s), $.setTimeout(() => {
|
|
312
312
|
t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
|
|
313
313
|
}, e);
|
|
314
|
-
}),
|
|
314
|
+
}), x = async (e, n) => {
|
|
315
315
|
const t = e.service_worker_relative_url;
|
|
316
316
|
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !t || e.service_worker_activate() === !1)
|
|
317
317
|
return null;
|
|
318
|
-
const s = `${t}?v=${
|
|
318
|
+
const s = `${t}?v=${te}`;
|
|
319
319
|
let o = null;
|
|
320
320
|
e.service_worker_register ? o = await e.service_worker_register(t) : o = await navigator.serviceWorker.register(s, {
|
|
321
321
|
updateViaCache: "none"
|
|
322
322
|
});
|
|
323
|
+
const i = `oidc.sw.version_mismatch_reload.${n}`, r = async () => {
|
|
324
|
+
X(), console.log("New SW waiting – SKIP_WAITING");
|
|
325
|
+
try {
|
|
326
|
+
await I(o, { timeoutMs: 8e3 })({
|
|
327
|
+
type: "SKIP_WAITING",
|
|
328
|
+
configurationName: n,
|
|
329
|
+
data: null
|
|
330
|
+
});
|
|
331
|
+
} catch (d) {
|
|
332
|
+
console.warn("SKIP_WAITING failed", d);
|
|
333
|
+
}
|
|
334
|
+
}, a = (d) => {
|
|
335
|
+
X(), d.addEventListener("statechange", async () => {
|
|
336
|
+
d.state === "installed" && navigator.serviceWorker.controller && await r();
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
o.addEventListener("updatefound", () => {
|
|
340
|
+
const d = o.installing;
|
|
341
|
+
d && a(d);
|
|
342
|
+
}), o.installing ? a(o.installing) : o.waiting && navigator.serviceWorker.controller && r();
|
|
323
343
|
try {
|
|
324
344
|
await o.update();
|
|
325
|
-
} catch (
|
|
326
|
-
console.error(
|
|
345
|
+
} catch (d) {
|
|
346
|
+
console.error(d);
|
|
327
347
|
}
|
|
328
|
-
|
|
329
|
-
const k = o.installing;
|
|
330
|
-
z(), k?.addEventListener("statechange", async () => {
|
|
331
|
-
if (k.state === "installed" && navigator.serviceWorker.controller) {
|
|
332
|
-
z(), console.log("New SW waiting – SKIP_WAITING");
|
|
333
|
-
try {
|
|
334
|
-
await O(o, { timeoutMs: 8e3 })({
|
|
335
|
-
type: "SKIP_WAITING",
|
|
336
|
-
configurationName: n,
|
|
337
|
-
data: null
|
|
338
|
-
});
|
|
339
|
-
} catch (b) {
|
|
340
|
-
console.warn("SKIP_WAITING failed", b);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
const i = `oidc.sw.controllerchange.reloaded.${n}`;
|
|
348
|
+
const c = `oidc.sw.controllerchange.reloaded.${n}`;
|
|
346
349
|
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
347
350
|
try {
|
|
348
|
-
if (sessionStorage.getItem(
|
|
349
|
-
sessionStorage.setItem(
|
|
351
|
+
if (sessionStorage.getItem(c) === "1") return;
|
|
352
|
+
sessionStorage.setItem(c, "1");
|
|
350
353
|
} catch {
|
|
351
354
|
}
|
|
352
|
-
console.log("SW controller changed – reloading page"),
|
|
355
|
+
console.log("SW controller changed – reloading page"), X(), window.location.reload();
|
|
353
356
|
});
|
|
354
357
|
try {
|
|
355
|
-
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await
|
|
358
|
+
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await I(o, { timeoutMs: 8e3 })({
|
|
356
359
|
type: "claim",
|
|
357
360
|
configurationName: n,
|
|
358
361
|
data: null
|
|
359
|
-
}), await
|
|
360
|
-
} catch (
|
|
361
|
-
return console.warn(`Failed init ServiceWorker ${
|
|
362
|
+
}), await Je(2e3));
|
|
363
|
+
} catch (d) {
|
|
364
|
+
return console.warn(`Failed init ServiceWorker ${d?.toString?.() ?? String(d)}`), null;
|
|
362
365
|
}
|
|
363
|
-
const
|
|
364
|
-
const
|
|
366
|
+
const f = async (d) => I(o)({ type: "clear", data: { status: d }, configurationName: n }), u = async (d, D, E) => {
|
|
367
|
+
const P = await I(o)({
|
|
365
368
|
type: "init",
|
|
366
369
|
data: {
|
|
367
|
-
oidcServerConfiguration:
|
|
368
|
-
where:
|
|
370
|
+
oidcServerConfiguration: d,
|
|
371
|
+
where: D,
|
|
369
372
|
oidcConfiguration: {
|
|
370
|
-
token_renew_mode:
|
|
371
|
-
service_worker_convert_all_requests_to_cors:
|
|
373
|
+
token_renew_mode: E.token_renew_mode,
|
|
374
|
+
service_worker_convert_all_requests_to_cors: E.service_worker_convert_all_requests_to_cors
|
|
372
375
|
}
|
|
373
376
|
},
|
|
374
377
|
configurationName: n
|
|
375
|
-
}),
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
}), q = P.version;
|
|
379
|
+
if (q !== te) {
|
|
380
|
+
console.warn(
|
|
381
|
+
`Service worker ${q} version mismatch with js client version ${te}, unregistering and reloading`
|
|
382
|
+
);
|
|
383
|
+
const M = parseInt(sessionStorage.getItem(i) ?? "0", 10);
|
|
384
|
+
if (M < 3)
|
|
385
|
+
if (sessionStorage.setItem(i, String(M + 1)), o.waiting)
|
|
386
|
+
await r();
|
|
387
|
+
else {
|
|
388
|
+
X();
|
|
389
|
+
try {
|
|
390
|
+
await o.update();
|
|
391
|
+
} catch (he) {
|
|
392
|
+
console.error(he);
|
|
393
|
+
}
|
|
394
|
+
const Y = await o.unregister();
|
|
395
|
+
console.log(`Service worker unregistering ${Y}`), await ne({ milliseconds: 2e3 }), window.location.reload();
|
|
396
|
+
}
|
|
397
|
+
else
|
|
398
|
+
console.error(
|
|
399
|
+
`Service worker version mismatch persists after ${M} attempt(s). Continuing with mismatched version.`
|
|
400
|
+
), sessionStorage.removeItem(i);
|
|
401
|
+
} else
|
|
402
|
+
sessionStorage.removeItem(i);
|
|
403
|
+
return {
|
|
404
|
+
tokens: _e(P.tokens, null, E.token_renew_mode),
|
|
405
|
+
status: P.status
|
|
381
406
|
};
|
|
382
|
-
},
|
|
383
|
-
|
|
384
|
-
},
|
|
407
|
+
}, l = (d = "/") => {
|
|
408
|
+
me == null && (me = "not_null", Oe(d));
|
|
409
|
+
}, h = (d) => I(o)({
|
|
385
410
|
type: "setSessionState",
|
|
386
|
-
data: { sessionState:
|
|
411
|
+
data: { sessionState: d },
|
|
387
412
|
configurationName: n
|
|
388
|
-
}),
|
|
413
|
+
}), _ = async () => (await I(o)({
|
|
389
414
|
type: "getSessionState",
|
|
390
415
|
data: null,
|
|
391
416
|
configurationName: n
|
|
392
|
-
})).sessionState,
|
|
417
|
+
})).sessionState, m = (d) => (sessionStorage[`oidc.nonce.${n}`] = d.nonce, I(o)({
|
|
393
418
|
type: "setNonce",
|
|
394
|
-
data: { nonce:
|
|
419
|
+
data: { nonce: d },
|
|
395
420
|
configurationName: n
|
|
396
|
-
})),
|
|
397
|
-
let
|
|
421
|
+
})), p = async (d = !0) => {
|
|
422
|
+
let E = (await I(o)({
|
|
398
423
|
type: "getNonce",
|
|
399
424
|
data: null,
|
|
400
425
|
configurationName: n
|
|
401
426
|
})).nonce;
|
|
402
|
-
return
|
|
403
|
-
},
|
|
404
|
-
|
|
427
|
+
return E || (E = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), d && (await m(E), E = (await p(!1)).nonce)), { nonce: E };
|
|
428
|
+
}, g = {}, y = (d) => {
|
|
429
|
+
g[n] = d, localStorage[`oidc.login.${n}`] = JSON.stringify(d);
|
|
405
430
|
}, A = () => {
|
|
406
|
-
const
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
await
|
|
431
|
+
const d = localStorage[`oidc.login.${n}`];
|
|
432
|
+
return g[n] || (g[n] = JSON.parse(d)), g[n];
|
|
433
|
+
}, S = async (d) => {
|
|
434
|
+
await I(o)({
|
|
410
435
|
type: "setDemonstratingProofOfPossessionNonce",
|
|
411
|
-
data: { demonstratingProofOfPossessionNonce:
|
|
436
|
+
data: { demonstratingProofOfPossessionNonce: d },
|
|
412
437
|
configurationName: n
|
|
413
438
|
});
|
|
414
|
-
},
|
|
439
|
+
}, O = async () => (await I(o)({
|
|
415
440
|
type: "getDemonstratingProofOfPossessionNonce",
|
|
416
441
|
data: null,
|
|
417
442
|
configurationName: n
|
|
418
|
-
})).demonstratingProofOfPossessionNonce,
|
|
419
|
-
const
|
|
420
|
-
await
|
|
443
|
+
})).demonstratingProofOfPossessionNonce, T = async (d) => {
|
|
444
|
+
const D = JSON.stringify(d);
|
|
445
|
+
await I(o)({
|
|
421
446
|
type: "setDemonstratingProofOfPossessionJwk",
|
|
422
|
-
data: { demonstratingProofOfPossessionJwkJson:
|
|
447
|
+
data: { demonstratingProofOfPossessionJwkJson: D },
|
|
423
448
|
configurationName: n
|
|
424
449
|
});
|
|
425
|
-
},
|
|
426
|
-
const
|
|
450
|
+
}, N = async () => {
|
|
451
|
+
const d = await I(o)({
|
|
427
452
|
type: "getDemonstratingProofOfPossessionJwk",
|
|
428
453
|
data: null,
|
|
429
454
|
configurationName: n
|
|
430
455
|
});
|
|
431
|
-
return
|
|
432
|
-
},
|
|
433
|
-
let
|
|
456
|
+
return d.demonstratingProofOfPossessionJwkJson ? JSON.parse(d.demonstratingProofOfPossessionJwkJson) : null;
|
|
457
|
+
}, w = async (d = !0) => {
|
|
458
|
+
let E = (await I(o)({
|
|
434
459
|
type: "getState",
|
|
435
460
|
data: null,
|
|
436
461
|
configurationName: n
|
|
437
462
|
})).state;
|
|
438
|
-
return
|
|
439
|
-
},
|
|
463
|
+
return E || (E = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await F(E), E = await w(!1))), E;
|
|
464
|
+
}, F = async (d) => (sessionStorage[`oidc.state.${n}`] = d, I(o)({
|
|
440
465
|
type: "setState",
|
|
441
|
-
data: { state:
|
|
466
|
+
data: { state: d },
|
|
442
467
|
configurationName: n
|
|
443
|
-
})),
|
|
444
|
-
let
|
|
468
|
+
})), L = async (d = !0) => {
|
|
469
|
+
let E = (await I(o)({
|
|
445
470
|
type: "getCodeVerifier",
|
|
446
471
|
data: null,
|
|
447
472
|
configurationName: n
|
|
448
473
|
})).codeVerifier;
|
|
449
|
-
return
|
|
450
|
-
},
|
|
474
|
+
return E || (E = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), d && (await v(E), E = await L(!1))), E;
|
|
475
|
+
}, v = async (d) => (sessionStorage[`oidc.code_verifier.${n}`] = d, I(o)({
|
|
451
476
|
type: "setCodeVerifier",
|
|
452
|
-
data: { codeVerifier:
|
|
477
|
+
data: { codeVerifier: d },
|
|
453
478
|
configurationName: n
|
|
454
479
|
}));
|
|
455
480
|
return {
|
|
456
|
-
clearAsync:
|
|
457
|
-
initAsync:
|
|
458
|
-
startKeepAliveServiceWorker: () =>
|
|
459
|
-
setSessionStateAsync:
|
|
460
|
-
getSessionStateAsync:
|
|
461
|
-
setNonceAsync:
|
|
462
|
-
getNonceAsync:
|
|
463
|
-
setLoginParams:
|
|
481
|
+
clearAsync: f,
|
|
482
|
+
initAsync: u,
|
|
483
|
+
startKeepAliveServiceWorker: () => l(e.service_worker_keep_alive_path),
|
|
484
|
+
setSessionStateAsync: h,
|
|
485
|
+
getSessionStateAsync: _,
|
|
486
|
+
setNonceAsync: m,
|
|
487
|
+
getNonceAsync: p,
|
|
488
|
+
setLoginParams: y,
|
|
464
489
|
getLoginParams: A,
|
|
465
|
-
getStateAsync:
|
|
466
|
-
setStateAsync:
|
|
467
|
-
getCodeVerifierAsync:
|
|
468
|
-
setCodeVerifierAsync:
|
|
469
|
-
setDemonstratingProofOfPossessionNonce:
|
|
470
|
-
getDemonstratingProofOfPossessionNonce:
|
|
471
|
-
setDemonstratingProofOfPossessionJwkAsync:
|
|
472
|
-
getDemonstratingProofOfPossessionJwkAsync:
|
|
490
|
+
getStateAsync: w,
|
|
491
|
+
setStateAsync: F,
|
|
492
|
+
getCodeVerifierAsync: L,
|
|
493
|
+
setCodeVerifierAsync: v,
|
|
494
|
+
setDemonstratingProofOfPossessionNonce: S,
|
|
495
|
+
getDemonstratingProofOfPossessionNonce: O,
|
|
496
|
+
setDemonstratingProofOfPossessionJwkAsync: T,
|
|
497
|
+
getDemonstratingProofOfPossessionJwkAsync: N
|
|
473
498
|
};
|
|
474
|
-
},
|
|
475
|
-
if (!
|
|
499
|
+
}, U = {}, He = (e, n = window.sessionStorage, t) => {
|
|
500
|
+
if (!U[e] && n) {
|
|
476
501
|
const o = n.getItem(e);
|
|
477
|
-
o && (
|
|
502
|
+
o && (U[e] = JSON.parse(o));
|
|
478
503
|
}
|
|
479
504
|
const s = 1e3 * t;
|
|
480
|
-
return
|
|
481
|
-
},
|
|
505
|
+
return U[e] && U[e].timestamp + s > Date.now() ? U[e].result : null;
|
|
506
|
+
}, Ge = (e, n, t = window.sessionStorage) => {
|
|
482
507
|
const s = Date.now();
|
|
483
|
-
|
|
508
|
+
U[e] = { result: n, timestamp: s }, t && t.setItem(e, JSON.stringify({ result: n, timestamp: s }));
|
|
484
509
|
};
|
|
485
|
-
function
|
|
510
|
+
function Pe(e) {
|
|
486
511
|
return new TextEncoder().encode(e);
|
|
487
512
|
}
|
|
488
|
-
function
|
|
513
|
+
function Ie(e) {
|
|
489
514
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
490
515
|
}
|
|
491
|
-
function
|
|
516
|
+
function je(e) {
|
|
492
517
|
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, s) {
|
|
493
518
|
return String.fromCharCode(parseInt(s, 16));
|
|
494
519
|
});
|
|
495
520
|
}
|
|
496
|
-
const
|
|
521
|
+
const fe = (e) => {
|
|
497
522
|
let n = "";
|
|
498
523
|
return e.forEach(function(t) {
|
|
499
524
|
n += String.fromCharCode(t);
|
|
500
|
-
}),
|
|
525
|
+
}), Ie(n);
|
|
501
526
|
};
|
|
502
|
-
function
|
|
503
|
-
return
|
|
527
|
+
function we(e) {
|
|
528
|
+
return Ie(je(e));
|
|
504
529
|
}
|
|
505
|
-
const
|
|
530
|
+
const qe = {
|
|
506
531
|
importKeyAlgorithm: {
|
|
507
532
|
name: "ECDSA",
|
|
508
533
|
namedCurve: "P-256",
|
|
@@ -515,7 +540,7 @@ const je = {
|
|
|
515
540
|
},
|
|
516
541
|
digestAlgorithm: { name: "SHA-256" },
|
|
517
542
|
jwtHeaderAlgorithm: "ES256"
|
|
518
|
-
},
|
|
543
|
+
}, Ye = (e) => async (n, t, s, o, i = "dpop+jwt") => {
|
|
519
544
|
switch (n = Object.assign({}, n), t.typ = i, t.alg = o.jwtHeaderAlgorithm, t.alg) {
|
|
520
545
|
case "ES256":
|
|
521
546
|
t.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y };
|
|
@@ -529,22 +554,22 @@ const je = {
|
|
|
529
554
|
const r = {
|
|
530
555
|
// @ts-ignore
|
|
531
556
|
// JWT "headers" really means JWS "protected headers"
|
|
532
|
-
protected:
|
|
557
|
+
protected: we(JSON.stringify(t)),
|
|
533
558
|
// @ts-ignore
|
|
534
559
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
535
|
-
payload:
|
|
536
|
-
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l =
|
|
537
|
-
return r.signature =
|
|
538
|
-
},
|
|
560
|
+
payload: we(JSON.stringify(s))
|
|
561
|
+
}, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l = Pe(`${r.protected}.${r.payload}`), h = o.signAlgorithm, _ = await e.crypto.subtle.sign(h, u, l);
|
|
562
|
+
return r.signature = fe(new Uint8Array(_)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
563
|
+
}, Xe = { sign: Ye }, ze = (e) => async (n) => {
|
|
539
564
|
const t = n, s = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(t, s, o);
|
|
540
565
|
return await e.crypto.subtle.exportKey("jwk", i.privateKey);
|
|
541
|
-
},
|
|
566
|
+
}, Qe = (e) => {
|
|
542
567
|
const n = Object.assign({}, e);
|
|
543
568
|
return delete n.d, n.key_ops = ["verify"], n;
|
|
544
|
-
},
|
|
545
|
-
generate:
|
|
546
|
-
neuter:
|
|
547
|
-
},
|
|
569
|
+
}, Ze = {
|
|
570
|
+
generate: ze,
|
|
571
|
+
neuter: Qe
|
|
572
|
+
}, en = (e) => async (n, t) => {
|
|
548
573
|
let s;
|
|
549
574
|
switch (n.kty) {
|
|
550
575
|
case "EC":
|
|
@@ -556,80 +581,80 @@ const je = {
|
|
|
556
581
|
default:
|
|
557
582
|
throw new Error("Unknown or not implemented JWK type");
|
|
558
583
|
}
|
|
559
|
-
const o = await e.crypto.subtle.digest(t,
|
|
560
|
-
return
|
|
561
|
-
},
|
|
584
|
+
const o = await e.crypto.subtle.digest(t, Pe(s));
|
|
585
|
+
return fe(new Uint8Array(o));
|
|
586
|
+
}, nn = { thumbprint: en }, tn = (e) => async (n) => await Ze.generate(e)(n), Ne = (e) => (n) => async (t, s = "POST", o, i = {}) => {
|
|
562
587
|
const r = {
|
|
563
588
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
564
|
-
jti: btoa(
|
|
589
|
+
jti: btoa(sn()),
|
|
565
590
|
htm: s,
|
|
566
591
|
htu: o,
|
|
567
592
|
iat: Math.round(Date.now() / 1e3),
|
|
568
593
|
...i
|
|
569
|
-
}, a = await
|
|
594
|
+
}, a = await nn.thumbprint(e)(
|
|
570
595
|
t,
|
|
571
596
|
n.digestAlgorithm
|
|
572
597
|
);
|
|
573
|
-
return await
|
|
598
|
+
return await Xe.sign(e)(
|
|
574
599
|
t,
|
|
575
600
|
{ kid: a },
|
|
576
601
|
r,
|
|
577
602
|
n
|
|
578
603
|
);
|
|
579
|
-
},
|
|
604
|
+
}, sn = () => {
|
|
580
605
|
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
|
|
581
606
|
let t = 0, s = "";
|
|
582
607
|
for (let o = 0; o < 36; o++)
|
|
583
608
|
e[o] !== "-" && e[o] !== "4" && (t = Math.random() * 16 | 0), e[o] === "x" ? s += n[t] : e[o] === "y" ? (t &= 3, t |= 8, s += n[t]) : s += e[o];
|
|
584
609
|
return s;
|
|
585
|
-
},
|
|
610
|
+
}, Ce = () => {
|
|
586
611
|
const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
|
|
587
612
|
return { hasCrypto: e, hasSubtleCrypto: n };
|
|
588
|
-
},
|
|
613
|
+
}, ie = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", on = (e) => {
|
|
589
614
|
const n = [];
|
|
590
615
|
for (let t = 0; t < e.byteLength; t += 1) {
|
|
591
|
-
const s = e[t] %
|
|
592
|
-
n.push(
|
|
616
|
+
const s = e[t] % ie.length;
|
|
617
|
+
n.push(ie[s]);
|
|
593
618
|
}
|
|
594
619
|
return n.join("");
|
|
595
|
-
},
|
|
596
|
-
const n = new Uint8Array(e), { hasCrypto: t } =
|
|
620
|
+
}, re = (e) => {
|
|
621
|
+
const n = new Uint8Array(e), { hasCrypto: t } = Ce();
|
|
597
622
|
if (t)
|
|
598
623
|
window.crypto.getRandomValues(n);
|
|
599
624
|
else
|
|
600
625
|
for (let s = 0; s < e; s += 1)
|
|
601
|
-
n[s] = Math.random() *
|
|
602
|
-
return
|
|
626
|
+
n[s] = Math.random() * ie.length | 0;
|
|
627
|
+
return on(n);
|
|
603
628
|
};
|
|
604
|
-
function
|
|
629
|
+
function rn(e) {
|
|
605
630
|
const n = new ArrayBuffer(e.length), t = new Uint8Array(n);
|
|
606
631
|
for (let s = 0; s < e.length; s++)
|
|
607
632
|
t[s] = e.charCodeAt(s);
|
|
608
633
|
return t;
|
|
609
634
|
}
|
|
610
|
-
function
|
|
635
|
+
function xe(e) {
|
|
611
636
|
return new Promise((n, t) => {
|
|
612
|
-
crypto.subtle.digest("SHA-256",
|
|
613
|
-
(s) => n(
|
|
637
|
+
crypto.subtle.digest("SHA-256", rn(e)).then(
|
|
638
|
+
(s) => n(fe(new Uint8Array(s))),
|
|
614
639
|
(s) => t(s)
|
|
615
640
|
);
|
|
616
641
|
});
|
|
617
642
|
}
|
|
618
|
-
const
|
|
643
|
+
const an = (e) => {
|
|
619
644
|
if (e.length < 43 || e.length > 128)
|
|
620
645
|
return Promise.reject(new Error("Invalid code length."));
|
|
621
|
-
const { hasSubtleCrypto: n } =
|
|
622
|
-
return n ?
|
|
623
|
-
},
|
|
624
|
-
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a =
|
|
646
|
+
const { hasSubtleCrypto: n } = Ce();
|
|
647
|
+
return n ? xe(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
648
|
+
}, cn = 3600, ln = (e) => async (n, t = cn, s = window.sessionStorage, o = 1e4) => {
|
|
649
|
+
const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = He(r, s, t);
|
|
625
650
|
if (a)
|
|
626
|
-
return new
|
|
627
|
-
const c = await
|
|
651
|
+
return new le(a);
|
|
652
|
+
const c = await j(e)(i, {}, o);
|
|
628
653
|
if (c.status !== 200)
|
|
629
654
|
return null;
|
|
630
655
|
const f = await c.json();
|
|
631
|
-
return
|
|
632
|
-
},
|
|
656
|
+
return Ge(r, f, s), new le(f);
|
|
657
|
+
}, j = (e) => async (n, t = {}, s = 1e4, o = 0) => {
|
|
633
658
|
let i;
|
|
634
659
|
try {
|
|
635
660
|
const r = new AbortController();
|
|
@@ -637,30 +662,30 @@ const rn = (e) => {
|
|
|
637
662
|
} catch (r) {
|
|
638
663
|
if (r.name === "AbortError" || r.message === "Network request failed") {
|
|
639
664
|
if (o <= 1)
|
|
640
|
-
return await
|
|
665
|
+
return await j(e)(n, t, s, o + 1);
|
|
641
666
|
throw r;
|
|
642
667
|
} else
|
|
643
668
|
throw console.error(r.message), r;
|
|
644
669
|
}
|
|
645
670
|
return i;
|
|
646
|
-
},
|
|
671
|
+
}, ae = {
|
|
647
672
|
refresh_token: "refresh_token",
|
|
648
673
|
access_token: "access_token"
|
|
649
|
-
},
|
|
674
|
+
}, pe = (e) => async (n, t, s = ae.refresh_token, o, i = {}, r = 1e4) => {
|
|
650
675
|
const a = {
|
|
651
676
|
token: t,
|
|
652
677
|
token_type_hint: s,
|
|
653
678
|
client_id: o
|
|
654
679
|
};
|
|
655
|
-
for (const [l,
|
|
656
|
-
a[l] === void 0 && (a[l] =
|
|
680
|
+
for (const [l, h] of Object.entries(i))
|
|
681
|
+
a[l] === void 0 && (a[l] = h);
|
|
657
682
|
const c = [];
|
|
658
683
|
for (const l in a) {
|
|
659
|
-
const
|
|
660
|
-
c.push(`${
|
|
684
|
+
const h = encodeURIComponent(l), _ = encodeURIComponent(a[l]);
|
|
685
|
+
c.push(`${h}=${_}`);
|
|
661
686
|
}
|
|
662
687
|
const f = c.join("&");
|
|
663
|
-
return (await
|
|
688
|
+
return (await j(e)(
|
|
664
689
|
n,
|
|
665
690
|
{
|
|
666
691
|
method: "POST",
|
|
@@ -673,15 +698,15 @@ const rn = (e) => {
|
|
|
673
698
|
)).status !== 200 ? { success: !1 } : {
|
|
674
699
|
success: !0
|
|
675
700
|
};
|
|
676
|
-
},
|
|
677
|
-
for (const [_,
|
|
678
|
-
t[_] === void 0 && (t[_] =
|
|
701
|
+
}, un = (e) => async (n, t, s, o, i = {}, r, a = 1e4) => {
|
|
702
|
+
for (const [_, m] of Object.entries(s))
|
|
703
|
+
t[_] === void 0 && (t[_] = m);
|
|
679
704
|
const c = [];
|
|
680
705
|
for (const _ in t) {
|
|
681
|
-
const
|
|
682
|
-
c.push(`${
|
|
706
|
+
const m = encodeURIComponent(_), p = encodeURIComponent(t[_]);
|
|
707
|
+
c.push(`${m}=${p}`);
|
|
683
708
|
}
|
|
684
|
-
const f = c.join("&"), u = await
|
|
709
|
+
const f = c.join("&"), u = await j(e)(
|
|
685
710
|
n,
|
|
686
711
|
{
|
|
687
712
|
method: "POST",
|
|
@@ -700,32 +725,32 @@ const rn = (e) => {
|
|
|
700
725
|
demonstratingProofOfPossessionNonce: null
|
|
701
726
|
};
|
|
702
727
|
const l = await u.json();
|
|
703
|
-
let
|
|
704
|
-
return u.headers.has(
|
|
705
|
-
|
|
728
|
+
let h = null;
|
|
729
|
+
return u.headers.has(ee) && (h = u.headers.get(
|
|
730
|
+
ee
|
|
706
731
|
)), {
|
|
707
732
|
success: !0,
|
|
708
733
|
status: u.status,
|
|
709
|
-
data:
|
|
710
|
-
demonstratingProofOfPossessionNonce:
|
|
734
|
+
data: _e(l, o, r),
|
|
735
|
+
demonstratingProofOfPossessionNonce: h
|
|
711
736
|
};
|
|
712
|
-
},
|
|
737
|
+
}, _n = (e, n) => async (t, s) => {
|
|
713
738
|
s = s ? { ...s } : {};
|
|
714
|
-
const o =
|
|
739
|
+
const o = re(128), i = await an(o);
|
|
715
740
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(s.state), s.code_challenge = i, s.code_challenge_method = "S256";
|
|
716
741
|
let r = "";
|
|
717
742
|
if (s)
|
|
718
743
|
for (const [a, c] of Object.entries(s))
|
|
719
744
|
r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(c)}`;
|
|
720
745
|
n.open(`${t}${r}`);
|
|
721
|
-
},
|
|
746
|
+
}, ee = "DPoP-Nonce", fn = (e) => async (n, t, s, o, i = 1e4) => {
|
|
722
747
|
t = t ? { ...t } : {}, t.code_verifier = await e.getCodeVerifierAsync();
|
|
723
748
|
const r = [];
|
|
724
749
|
for (const l in t) {
|
|
725
|
-
const
|
|
726
|
-
r.push(`${
|
|
750
|
+
const h = encodeURIComponent(l), _ = encodeURIComponent(t[l]);
|
|
751
|
+
r.push(`${h}=${_}`);
|
|
727
752
|
}
|
|
728
|
-
const a = r.join("&"), c = await
|
|
753
|
+
const a = r.join("&"), c = await j(fetch)(
|
|
729
754
|
n,
|
|
730
755
|
{
|
|
731
756
|
method: "POST",
|
|
@@ -740,23 +765,23 @@ const rn = (e) => {
|
|
|
740
765
|
if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), c.status !== 200)
|
|
741
766
|
return { success: !1, status: c.status };
|
|
742
767
|
let f = null;
|
|
743
|
-
c.headers.has(
|
|
744
|
-
|
|
768
|
+
c.headers.has(ee) && (f = c.headers.get(
|
|
769
|
+
ee
|
|
745
770
|
));
|
|
746
771
|
const u = await c.json();
|
|
747
772
|
return {
|
|
748
773
|
success: !0,
|
|
749
774
|
data: {
|
|
750
775
|
state: t.state,
|
|
751
|
-
tokens:
|
|
776
|
+
tokens: _e(u, null, o),
|
|
752
777
|
demonstratingProofOfPossessionNonce: f
|
|
753
778
|
}
|
|
754
779
|
};
|
|
755
780
|
};
|
|
756
|
-
async function
|
|
781
|
+
async function Ae(e, n, t, s = null) {
|
|
757
782
|
const o = (c) => {
|
|
758
783
|
e.tokens = c;
|
|
759
|
-
}, { tokens: i, status: r } = await
|
|
784
|
+
}, { tokens: i, status: r } = await z(e)(
|
|
760
785
|
o,
|
|
761
786
|
0,
|
|
762
787
|
0,
|
|
@@ -764,35 +789,39 @@ async function me(e, n, t, s = null) {
|
|
|
764
789
|
t,
|
|
765
790
|
s
|
|
766
791
|
);
|
|
767
|
-
return await
|
|
792
|
+
return await x(e.configuration, e.configurationName) || C(
|
|
793
|
+
e.configurationName,
|
|
794
|
+
e.configuration.storage,
|
|
795
|
+
e.configuration.login_state_storage ?? e.configuration.storage
|
|
796
|
+
).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
|
|
768
797
|
}
|
|
769
|
-
async function
|
|
798
|
+
async function We(e, n = !1, t = null, s = null) {
|
|
770
799
|
const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
|
|
771
800
|
let r;
|
|
772
|
-
const a = await
|
|
801
|
+
const a = await x(e.configuration, e.configurationName);
|
|
773
802
|
if (o?.storage === window?.sessionStorage && !a || !navigator.locks)
|
|
774
|
-
r = await
|
|
803
|
+
r = await Ae(e, n, t, s);
|
|
775
804
|
else {
|
|
776
805
|
let c = "retry";
|
|
777
806
|
for (; c === "retry"; )
|
|
778
807
|
c = await navigator.locks.request(
|
|
779
808
|
i,
|
|
780
809
|
{ ifAvailable: !0 },
|
|
781
|
-
async (f) => f ? await
|
|
810
|
+
async (f) => f ? await Ae(e, n, t, s) : (e.publishEvent(W.eventNames.syncTokensAsync_lock_not_available, {
|
|
782
811
|
lock: "lock not available"
|
|
783
812
|
}), "retry")
|
|
784
813
|
);
|
|
785
814
|
r = c;
|
|
786
815
|
}
|
|
787
|
-
return r ? (e.timeoutId && (e.timeoutId =
|
|
816
|
+
return r ? (e.timeoutId && (e.timeoutId = G(e, e.tokens.expiresAt, t, s)), e.tokens) : null;
|
|
788
817
|
}
|
|
789
|
-
const
|
|
818
|
+
const G = (e, n, t = null, s = null) => {
|
|
790
819
|
const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
791
|
-
return e.timeoutId &&
|
|
792
|
-
const r = { timeLeft:
|
|
793
|
-
e.publishEvent(
|
|
820
|
+
return e.timeoutId && $.clearTimeout(e.timeoutId), $.setTimeout(async () => {
|
|
821
|
+
const r = { timeLeft: B(o, n) };
|
|
822
|
+
e.publishEvent(W.eventNames.token_timer, r), await We(e, !1, t, s);
|
|
794
823
|
}, 1e3);
|
|
795
|
-
},
|
|
824
|
+
}, b = {
|
|
796
825
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
797
826
|
SESSION_LOST: "SESSION_LOST",
|
|
798
827
|
NOT_CONNECTED: "NOT_CONNECTED",
|
|
@@ -802,17 +831,17 @@ const J = (e, n, t = null, s = null) => {
|
|
|
802
831
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
803
832
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
|
|
804
833
|
TOKENS_INVALID: "TOKENS_INVALID"
|
|
805
|
-
},
|
|
834
|
+
}, de = (e) => async (n, t, s, o = !1) => {
|
|
806
835
|
const i = { nonce: null };
|
|
807
836
|
if (!s)
|
|
808
|
-
return { tokens: null, status:
|
|
837
|
+
return { tokens: null, status: b.NOT_CONNECTED, nonce: i };
|
|
809
838
|
let r = i;
|
|
810
839
|
const a = await e.initAsync(
|
|
811
840
|
n.authority,
|
|
812
841
|
n.authority_configuration
|
|
813
|
-
), c = await
|
|
842
|
+
), c = await x(n, t);
|
|
814
843
|
if (c) {
|
|
815
|
-
const { status: l, tokens:
|
|
844
|
+
const { status: l, tokens: h } = await c.initAsync(
|
|
816
845
|
a,
|
|
817
846
|
"syncTokensAsync",
|
|
818
847
|
n
|
|
@@ -820,95 +849,103 @@ const J = (e, n, t = null, s = null) => {
|
|
|
820
849
|
if (l === "LOGGED_OUT")
|
|
821
850
|
return {
|
|
822
851
|
tokens: null,
|
|
823
|
-
status:
|
|
852
|
+
status: b.LOGOUT_FROM_ANOTHER_TAB,
|
|
824
853
|
nonce: i
|
|
825
854
|
};
|
|
826
855
|
if (l === "SESSIONS_LOST")
|
|
827
|
-
return { tokens: null, status:
|
|
828
|
-
if (!l || !
|
|
856
|
+
return { tokens: null, status: b.SESSION_LOST, nonce: i };
|
|
857
|
+
if (!l || !h)
|
|
829
858
|
return {
|
|
830
859
|
tokens: null,
|
|
831
|
-
status:
|
|
860
|
+
status: b.REQUIRE_SYNC_TOKENS,
|
|
832
861
|
nonce: i
|
|
833
862
|
};
|
|
834
|
-
if (
|
|
835
|
-
const
|
|
863
|
+
if (h.issuedAt !== s.issuedAt) {
|
|
864
|
+
const m = B(
|
|
836
865
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
837
|
-
|
|
838
|
-
) > 0 ?
|
|
839
|
-
return { tokens:
|
|
866
|
+
h.expiresAt
|
|
867
|
+
) > 0 ? b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, p = await c.getNonceAsync();
|
|
868
|
+
return { tokens: h, status: m, nonce: p };
|
|
840
869
|
}
|
|
841
870
|
r = await c.getNonceAsync();
|
|
842
871
|
} else {
|
|
843
|
-
const l =
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
872
|
+
const l = C(
|
|
873
|
+
t,
|
|
874
|
+
n.storage ?? sessionStorage,
|
|
875
|
+
n.login_state_storage ?? n.storage ?? sessionStorage
|
|
876
|
+
), h = await l.initAsync();
|
|
877
|
+
let { tokens: _ } = h;
|
|
878
|
+
const { status: m } = h;
|
|
879
|
+
if (_ && (_ = ue(_, e.tokens, n.token_renew_mode)), _) {
|
|
880
|
+
if (m === "SESSIONS_LOST")
|
|
881
|
+
return { tokens: null, status: b.SESSION_LOST, nonce: i };
|
|
849
882
|
if (_.issuedAt !== s.issuedAt) {
|
|
850
|
-
const g =
|
|
883
|
+
const g = B(
|
|
851
884
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
852
885
|
_.expiresAt
|
|
853
|
-
) > 0 ?
|
|
886
|
+
) > 0 ? b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, y = await l.getNonceAsync();
|
|
854
887
|
return { tokens: _, status: g, nonce: y };
|
|
855
888
|
}
|
|
856
889
|
} else return {
|
|
857
890
|
tokens: null,
|
|
858
|
-
status:
|
|
891
|
+
status: b.LOGOUT_FROM_ANOTHER_TAB,
|
|
859
892
|
nonce: i
|
|
860
893
|
};
|
|
861
894
|
r = await l.getNonceAsync();
|
|
862
895
|
}
|
|
863
|
-
const u =
|
|
896
|
+
const u = B(
|
|
864
897
|
n.refresh_time_before_tokens_expiration_in_second,
|
|
865
898
|
s.expiresAt
|
|
866
899
|
) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
867
900
|
return o ? { tokens: s, status: "FORCE_REFRESH", nonce: r } : { tokens: s, status: u, nonce: r };
|
|
868
|
-
},
|
|
901
|
+
}, z = (e) => async (n, t = 0, s = 0, o = !1, i = null, r = null) => {
|
|
869
902
|
if (!navigator.onLine && document.hidden)
|
|
870
903
|
return { tokens: e.tokens, status: "GIVE_UP" };
|
|
871
904
|
let a = 6;
|
|
872
905
|
const c = o ? 2 : 5, f = 5;
|
|
873
906
|
for (; !navigator.onLine && a > 0; )
|
|
874
|
-
await
|
|
907
|
+
await ne({ milliseconds: 1e3 }), a--, e.publishEvent(k.refreshTokensAsync, {
|
|
875
908
|
message: `wait because navigator is offline try ${a}`
|
|
876
909
|
});
|
|
877
|
-
const u = document.hidden, l = u ? t : t + 1,
|
|
910
|
+
const u = document.hidden, l = u ? t : t + 1, h = u ? s + 1 : s;
|
|
878
911
|
if (t >= c || s >= f)
|
|
879
|
-
return n(null), e.publishEvent(
|
|
912
|
+
return n(null), e.publishEvent(k.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
|
|
880
913
|
i || (i = {});
|
|
881
|
-
const _ = e.configuration,
|
|
914
|
+
const _ = e.configuration, m = (g, y = null, A = null) => ge(
|
|
882
915
|
e.configurationName,
|
|
883
916
|
e.configuration,
|
|
884
917
|
e.publishEvent.bind(e)
|
|
885
|
-
)(g, y,
|
|
918
|
+
)(g, y, A), p = async () => {
|
|
886
919
|
try {
|
|
887
920
|
let g;
|
|
888
|
-
const y = await
|
|
889
|
-
y ? g = y.getLoginParams() : g =
|
|
890
|
-
|
|
921
|
+
const y = await x(_, e.configurationName);
|
|
922
|
+
y ? g = y.getLoginParams() : g = C(
|
|
923
|
+
e.configurationName,
|
|
924
|
+
_.storage,
|
|
925
|
+
_.login_state_storage ?? _.storage
|
|
926
|
+
).getLoginParams();
|
|
927
|
+
const A = {};
|
|
891
928
|
if (g && g.extras)
|
|
892
|
-
for (const [
|
|
893
|
-
|
|
929
|
+
for (const [O, T] of Object.entries(g.extras))
|
|
930
|
+
T != null && (A[O] = T);
|
|
894
931
|
if (i)
|
|
895
|
-
for (const [
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
return
|
|
932
|
+
for (const [O, T] of Object.entries(i))
|
|
933
|
+
T != null && (A[O] = T);
|
|
934
|
+
A.prompt = "none", r && (A.scope = r);
|
|
935
|
+
const S = await m(A);
|
|
936
|
+
return S ? S.error ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
900
937
|
message: "refresh token silent"
|
|
901
|
-
}), { tokens: null, status: "SESSION_LOST" }) : (n(
|
|
938
|
+
}), { tokens: null, status: "SESSION_LOST" }) : (n(S.tokens), e.publishEvent(W.eventNames.token_renewed, {}), { tokens: S.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
902
939
|
message: "refresh token silent not active"
|
|
903
940
|
}), { tokens: null, status: "SESSION_LOST" });
|
|
904
941
|
} catch (g) {
|
|
905
|
-
return console.error(g), e.publishEvent(
|
|
942
|
+
return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
906
943
|
message: "exceptionSilent",
|
|
907
944
|
exception: g.message
|
|
908
|
-
}), await
|
|
945
|
+
}), await z(e)(
|
|
909
946
|
n,
|
|
910
947
|
l,
|
|
911
|
-
|
|
948
|
+
h,
|
|
912
949
|
o,
|
|
913
950
|
i,
|
|
914
951
|
r
|
|
@@ -916,99 +953,103 @@ const J = (e, n, t = null, s = null) => {
|
|
|
916
953
|
}
|
|
917
954
|
};
|
|
918
955
|
try {
|
|
919
|
-
const { status: g, tokens: y, nonce:
|
|
956
|
+
const { status: g, tokens: y, nonce: A } = await de(e)(
|
|
920
957
|
_,
|
|
921
958
|
e.configurationName,
|
|
922
959
|
e.tokens,
|
|
923
960
|
o
|
|
924
961
|
);
|
|
925
962
|
switch (g) {
|
|
926
|
-
case
|
|
927
|
-
return n(null), e.publishEvent(
|
|
963
|
+
case b.SESSION_LOST:
|
|
964
|
+
return n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
928
965
|
message: "refresh token session lost"
|
|
929
966
|
}), { tokens: null, status: "SESSION_LOST" };
|
|
930
|
-
case
|
|
967
|
+
case b.NOT_CONNECTED:
|
|
931
968
|
return n(null), { tokens: null, status: null };
|
|
932
|
-
case
|
|
969
|
+
case b.TOKENS_VALID:
|
|
933
970
|
return n(y), { tokens: y, status: "LOGGED_IN" };
|
|
934
|
-
case
|
|
935
|
-
return n(y), e.publishEvent(
|
|
971
|
+
case b.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
|
|
972
|
+
return n(y), e.publishEvent(W.eventNames.token_renewed, {
|
|
936
973
|
reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"
|
|
937
974
|
}), { tokens: y, status: "LOGGED_IN" };
|
|
938
|
-
case
|
|
939
|
-
return n(null), e.publishEvent(
|
|
975
|
+
case b.LOGOUT_FROM_ANOTHER_TAB:
|
|
976
|
+
return n(null), e.publishEvent(k.logout_from_another_tab, {
|
|
940
977
|
status: "session syncTokensAsync"
|
|
941
978
|
}), { tokens: null, status: "LOGGED_OUT" };
|
|
942
|
-
case
|
|
943
|
-
return _.token_automatic_renew_mode ==
|
|
979
|
+
case b.REQUIRE_SYNC_TOKENS:
|
|
980
|
+
return _.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted && !o ? (e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(k.refreshTokensAsync_begin, { tryNumber: t }), await p());
|
|
944
981
|
default: {
|
|
945
|
-
if (_.token_automatic_renew_mode ==
|
|
946
|
-
return e.publishEvent(
|
|
947
|
-
if (e.publishEvent(
|
|
982
|
+
if (_.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted && b.FORCE_REFRESH !== g)
|
|
983
|
+
return e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
|
|
984
|
+
if (e.publishEvent(k.refreshTokensAsync_begin, {
|
|
948
985
|
refreshToken: y.refreshToken,
|
|
949
986
|
status: g,
|
|
950
987
|
tryNumber: t,
|
|
951
988
|
backgroundTry: s
|
|
952
989
|
}), !y.refreshToken)
|
|
953
|
-
return await
|
|
954
|
-
const
|
|
955
|
-
for (const [
|
|
956
|
-
|
|
990
|
+
return await p();
|
|
991
|
+
const S = _.client_id, O = _.redirect_uri, T = _.authority, w = { ..._.token_request_extras ? _.token_request_extras : {} };
|
|
992
|
+
for (const [L, v] of Object.entries(i))
|
|
993
|
+
L.endsWith(":token_request") && (w[L.replace(":token_request", "")] = v);
|
|
957
994
|
return await (async () => {
|
|
958
|
-
const
|
|
959
|
-
client_id:
|
|
960
|
-
redirect_uri:
|
|
995
|
+
const L = {
|
|
996
|
+
client_id: S,
|
|
997
|
+
redirect_uri: O,
|
|
961
998
|
grant_type: "refresh_token",
|
|
962
999
|
refresh_token: y.refreshToken
|
|
963
|
-
},
|
|
964
|
-
|
|
1000
|
+
}, v = await e.initAsync(
|
|
1001
|
+
T,
|
|
965
1002
|
_.authority_configuration
|
|
966
|
-
),
|
|
967
|
-
_.demonstrating_proof_of_possession && (
|
|
1003
|
+
), d = document.hidden ? 1e4 : 3e4 * 10, D = v.tokenEndpoint, E = {};
|
|
1004
|
+
_.demonstrating_proof_of_possession && (E.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
|
|
968
1005
|
y.accessToken,
|
|
969
|
-
|
|
1006
|
+
D,
|
|
970
1007
|
"POST"
|
|
971
1008
|
));
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1009
|
+
const P = await un(e.getFetch())(
|
|
1010
|
+
D,
|
|
1011
|
+
L,
|
|
1012
|
+
w,
|
|
976
1013
|
y,
|
|
977
|
-
|
|
1014
|
+
E,
|
|
978
1015
|
_.token_renew_mode,
|
|
979
|
-
|
|
1016
|
+
d
|
|
980
1017
|
);
|
|
981
|
-
if (
|
|
982
|
-
const { isValid:
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
1018
|
+
if (P.success) {
|
|
1019
|
+
const { isValid: q, reason: M } = Ee(
|
|
1020
|
+
P.data,
|
|
1021
|
+
A.nonce,
|
|
1022
|
+
v
|
|
986
1023
|
);
|
|
987
|
-
if (!
|
|
988
|
-
return n(null), e.publishEvent(
|
|
989
|
-
message: `refresh token return not valid tokens, reason: ${
|
|
1024
|
+
if (!q)
|
|
1025
|
+
return n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
1026
|
+
message: `refresh token return not valid tokens, reason: ${M}`
|
|
990
1027
|
}), { tokens: null, status: "SESSION_LOST" };
|
|
991
|
-
if (n(
|
|
992
|
-
const
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
) : await
|
|
996
|
-
|
|
1028
|
+
if (n(P.data), P.demonstratingProofOfPossessionNonce) {
|
|
1029
|
+
const Y = await x(_, e.configurationName);
|
|
1030
|
+
Y ? await Y.setDemonstratingProofOfPossessionNonce(
|
|
1031
|
+
P.demonstratingProofOfPossessionNonce
|
|
1032
|
+
) : await C(
|
|
1033
|
+
e.configurationName,
|
|
1034
|
+
_.storage,
|
|
1035
|
+
_.login_state_storage ?? _.storage
|
|
1036
|
+
).setDemonstratingProofOfPossessionNonce(
|
|
1037
|
+
P.demonstratingProofOfPossessionNonce
|
|
997
1038
|
);
|
|
998
1039
|
}
|
|
999
|
-
return e.publishEvent(
|
|
1000
|
-
success:
|
|
1001
|
-
}), e.publishEvent(
|
|
1040
|
+
return e.publishEvent(k.refreshTokensAsync_end, {
|
|
1041
|
+
success: P.success
|
|
1042
|
+
}), e.publishEvent(W.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: P.data, status: "LOGGED_IN" };
|
|
1002
1043
|
} else
|
|
1003
|
-
return e.publishEvent(
|
|
1044
|
+
return e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
1004
1045
|
message: "bad request",
|
|
1005
|
-
tokenResponse:
|
|
1006
|
-
}),
|
|
1007
|
-
message: `session lost: ${
|
|
1008
|
-
}), { tokens: null, status: "SESSION_LOST" }) : await
|
|
1046
|
+
tokenResponse: P
|
|
1047
|
+
}), P.status >= 400 && P.status < 500 ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
|
|
1048
|
+
message: `session lost: ${P.status}`
|
|
1049
|
+
}), { tokens: null, status: "SESSION_LOST" }) : await z(e)(
|
|
1009
1050
|
n,
|
|
1010
1051
|
l,
|
|
1011
|
-
|
|
1052
|
+
h,
|
|
1012
1053
|
o,
|
|
1013
1054
|
i,
|
|
1014
1055
|
r
|
|
@@ -1017,75 +1058,75 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1017
1058
|
}
|
|
1018
1059
|
}
|
|
1019
1060
|
} catch (g) {
|
|
1020
|
-
return console.error(g), e.publishEvent(
|
|
1061
|
+
return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
|
|
1021
1062
|
message: "exception",
|
|
1022
1063
|
exception: g.message
|
|
1023
|
-
}), new Promise((y,
|
|
1064
|
+
}), new Promise((y, A) => {
|
|
1024
1065
|
setTimeout(() => {
|
|
1025
|
-
|
|
1066
|
+
z(e)(
|
|
1026
1067
|
n,
|
|
1027
1068
|
l,
|
|
1028
|
-
|
|
1069
|
+
h,
|
|
1029
1070
|
o,
|
|
1030
1071
|
i,
|
|
1031
1072
|
r
|
|
1032
|
-
).then(y).catch(
|
|
1073
|
+
).then(y).catch(A);
|
|
1033
1074
|
}, 1e3);
|
|
1034
1075
|
});
|
|
1035
1076
|
}
|
|
1036
|
-
},
|
|
1077
|
+
}, ge = (e, n, t) => (s = null, o = null, i = null) => {
|
|
1037
1078
|
if (!n.silent_redirect_uri || !n.silent_login_uri)
|
|
1038
1079
|
return Promise.resolve(null);
|
|
1039
1080
|
try {
|
|
1040
|
-
t(
|
|
1081
|
+
t(k.silentLoginAsync_begin, {});
|
|
1041
1082
|
let r = "";
|
|
1042
1083
|
if (o && (s == null && (s = {}), s.state = o), i != null && (s == null && (s = {}), s.scope = i), s != null)
|
|
1043
|
-
for (const [l,
|
|
1044
|
-
|
|
1084
|
+
for (const [l, h] of Object.entries(s))
|
|
1085
|
+
h != null && (r === "" ? r = `?${encodeURIComponent(l)}=${encodeURIComponent(h)}` : r += `&${encodeURIComponent(l)}=${encodeURIComponent(h)}`);
|
|
1045
1086
|
const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), f = a.substring(0, c), u = document.createElement("iframe");
|
|
1046
|
-
return u.width = "0px", u.height = "0px", u.id = `${e}_oidc_iframe`, u.setAttribute("src", a), u.style.display = "none", document.body.appendChild(u), new Promise((l,
|
|
1087
|
+
return u.width = "0px", u.height = "0px", u.id = `${e}_oidc_iframe`, u.setAttribute("src", a), u.style.display = "none", document.body.appendChild(u), new Promise((l, h) => {
|
|
1047
1088
|
let _ = !1;
|
|
1048
|
-
const
|
|
1049
|
-
window.removeEventListener("message",
|
|
1050
|
-
},
|
|
1089
|
+
const m = () => {
|
|
1090
|
+
window.removeEventListener("message", p), u.remove(), _ = !0;
|
|
1091
|
+
}, p = (g) => {
|
|
1051
1092
|
if (g.origin === f && g.source === u.contentWindow) {
|
|
1052
|
-
const y = `${e}_oidc_tokens:`,
|
|
1053
|
-
if (
|
|
1054
|
-
if (
|
|
1055
|
-
const
|
|
1056
|
-
t(
|
|
1057
|
-
} else if (
|
|
1058
|
-
const
|
|
1059
|
-
t(
|
|
1060
|
-
} else if (
|
|
1061
|
-
const
|
|
1062
|
-
t(
|
|
1093
|
+
const y = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`, S = `${e}_oidc_exception:`, O = g.data;
|
|
1094
|
+
if (O && typeof O == "string" && !_) {
|
|
1095
|
+
if (O.startsWith(y)) {
|
|
1096
|
+
const T = JSON.parse(g.data.replace(y, ""));
|
|
1097
|
+
t(k.silentLoginAsync_end, {}), l(T), m();
|
|
1098
|
+
} else if (O.startsWith(A)) {
|
|
1099
|
+
const T = JSON.parse(g.data.replace(A, ""));
|
|
1100
|
+
t(k.silentLoginAsync_error, T), l({ error: "oidc_" + T.error, tokens: null, sessionState: null }), m();
|
|
1101
|
+
} else if (O.startsWith(S)) {
|
|
1102
|
+
const T = JSON.parse(g.data.replace(S, ""));
|
|
1103
|
+
t(k.silentLoginAsync_error, T), h(new Error(T.error)), m();
|
|
1063
1104
|
}
|
|
1064
1105
|
}
|
|
1065
1106
|
}
|
|
1066
1107
|
};
|
|
1067
1108
|
try {
|
|
1068
|
-
window.addEventListener("message",
|
|
1109
|
+
window.addEventListener("message", p);
|
|
1069
1110
|
const g = n.silent_login_timeout;
|
|
1070
1111
|
setTimeout(() => {
|
|
1071
|
-
_ || (
|
|
1112
|
+
_ || (m(), t(k.silentLoginAsync_error, { reason: "timeout" }), h(new Error("timeout")));
|
|
1072
1113
|
}, g);
|
|
1073
1114
|
} catch (g) {
|
|
1074
|
-
|
|
1115
|
+
m(), t(k.silentLoginAsync_error, g), h(g);
|
|
1075
1116
|
}
|
|
1076
1117
|
});
|
|
1077
1118
|
} catch (r) {
|
|
1078
|
-
throw t(
|
|
1119
|
+
throw t(k.silentLoginAsync_error, r), r;
|
|
1079
1120
|
}
|
|
1080
|
-
},
|
|
1121
|
+
}, dn = (e, n, t, s, o) => (i = null, r = void 0) => {
|
|
1081
1122
|
i = { ...i };
|
|
1082
|
-
const a = (f, u, l) =>
|
|
1123
|
+
const a = (f, u, l) => ge(n, t, s.bind(o))(
|
|
1083
1124
|
f,
|
|
1084
1125
|
u,
|
|
1085
1126
|
l
|
|
1086
1127
|
);
|
|
1087
1128
|
return (async () => {
|
|
1088
|
-
o.timeoutId &&
|
|
1129
|
+
o.timeoutId && $.clearTimeout(o.timeoutId);
|
|
1089
1130
|
let f;
|
|
1090
1131
|
i && "state" in i && (f = i.state, delete i.state);
|
|
1091
1132
|
try {
|
|
@@ -1098,13 +1139,13 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1098
1139
|
r
|
|
1099
1140
|
);
|
|
1100
1141
|
if (l)
|
|
1101
|
-
return o.tokens = l.tokens, s(
|
|
1142
|
+
return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId = G(o, o.tokens.expiresAt, i, r), {};
|
|
1102
1143
|
} catch (u) {
|
|
1103
1144
|
return u;
|
|
1104
1145
|
}
|
|
1105
1146
|
})();
|
|
1106
|
-
},
|
|
1107
|
-
const a = (c, f = void 0, u = void 0) =>
|
|
1147
|
+
}, gn = (e, n, t) => (s, o, i, r = !1) => {
|
|
1148
|
+
const a = (c, f = void 0, u = void 0) => ge(e.configurationName, t, e.publishEvent.bind(e))(
|
|
1108
1149
|
c,
|
|
1109
1150
|
f,
|
|
1110
1151
|
u
|
|
@@ -1116,18 +1157,18 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1116
1157
|
const l = e.tokens;
|
|
1117
1158
|
if (l === null)
|
|
1118
1159
|
return;
|
|
1119
|
-
const
|
|
1160
|
+
const h = l.idToken, _ = l.idTokenPayload;
|
|
1120
1161
|
return a({
|
|
1121
1162
|
prompt: "none",
|
|
1122
|
-
id_token_hint:
|
|
1163
|
+
id_token_hint: h,
|
|
1123
1164
|
scope: t.scope || "openid"
|
|
1124
|
-
}).then((
|
|
1125
|
-
if (
|
|
1126
|
-
throw new Error(
|
|
1127
|
-
const
|
|
1128
|
-
if (_.sub ===
|
|
1129
|
-
const g =
|
|
1130
|
-
e.checkSessionIFrame.start(
|
|
1165
|
+
}).then((m) => {
|
|
1166
|
+
if (m.error)
|
|
1167
|
+
throw new Error(m.error);
|
|
1168
|
+
const p = m.tokens.idTokenPayload;
|
|
1169
|
+
if (_.sub === p.sub) {
|
|
1170
|
+
const g = m.sessionState;
|
|
1171
|
+
e.checkSessionIFrame.start(m.sessionState), _.sid === p.sid ? console.debug(
|
|
1131
1172
|
"SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",
|
|
1132
1173
|
g
|
|
1133
1174
|
) : console.debug(
|
|
@@ -1137,18 +1178,18 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1137
1178
|
} else
|
|
1138
1179
|
console.debug(
|
|
1139
1180
|
"SessionMonitor._callback: Different subject signed into OP:",
|
|
1140
|
-
|
|
1181
|
+
p.sub
|
|
1141
1182
|
);
|
|
1142
|
-
}).catch(async (
|
|
1183
|
+
}).catch(async (m) => {
|
|
1143
1184
|
console.warn(
|
|
1144
1185
|
"SessionMonitor._callback: Silent login failed, logging out other tabs:",
|
|
1145
|
-
|
|
1186
|
+
m
|
|
1146
1187
|
);
|
|
1147
|
-
for (const [,
|
|
1148
|
-
await
|
|
1188
|
+
for (const [, p] of Object.entries(n))
|
|
1189
|
+
await p.logoutOtherTabAsync(t.client_id, _.sub);
|
|
1149
1190
|
});
|
|
1150
1191
|
};
|
|
1151
|
-
e.checkSessionIFrame = new
|
|
1192
|
+
e.checkSessionIFrame = new $e(
|
|
1152
1193
|
u,
|
|
1153
1194
|
o,
|
|
1154
1195
|
s
|
|
@@ -1160,7 +1201,7 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1160
1201
|
} else
|
|
1161
1202
|
c(null);
|
|
1162
1203
|
});
|
|
1163
|
-
}, hn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")),
|
|
1204
|
+
}, hn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), yn = (e) => {
|
|
1164
1205
|
const n = e.appVersion, t = e.userAgent, s = "-";
|
|
1165
1206
|
let o = s;
|
|
1166
1207
|
const i = [
|
|
@@ -1220,7 +1261,7 @@ const J = (e, n, t = null, s = null) => {
|
|
|
1220
1261
|
osVersion: r
|
|
1221
1262
|
};
|
|
1222
1263
|
};
|
|
1223
|
-
function
|
|
1264
|
+
function kn() {
|
|
1224
1265
|
const e = navigator.userAgent;
|
|
1225
1266
|
let n, t = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1226
1267
|
if (/trident/i.test(t[1]))
|
|
@@ -1238,23 +1279,23 @@ function yn() {
|
|
|
1238
1279
|
version: t[1]
|
|
1239
1280
|
};
|
|
1240
1281
|
}
|
|
1241
|
-
const
|
|
1242
|
-
const { name: e, version: n } =
|
|
1282
|
+
const mn = () => {
|
|
1283
|
+
const { name: e, version: n } = kn();
|
|
1243
1284
|
if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
|
|
1244
1285
|
return !1;
|
|
1245
|
-
const t =
|
|
1286
|
+
const t = yn(navigator);
|
|
1246
1287
|
return !hn(t);
|
|
1247
|
-
},
|
|
1288
|
+
}, wn = async (e) => {
|
|
1248
1289
|
let n;
|
|
1249
1290
|
if (e.tokens != null)
|
|
1250
1291
|
return !1;
|
|
1251
|
-
e.publishEvent(
|
|
1292
|
+
e.publishEvent(k.tryKeepExistingSessionAsync_begin, {});
|
|
1252
1293
|
try {
|
|
1253
1294
|
const t = e.configuration, s = await e.initAsync(
|
|
1254
1295
|
t.authority,
|
|
1255
1296
|
t.authority_configuration
|
|
1256
1297
|
);
|
|
1257
|
-
if (n = await
|
|
1298
|
+
if (n = await x(t, e.configurationName), n) {
|
|
1258
1299
|
const { tokens: o } = await n.initAsync(
|
|
1259
1300
|
s,
|
|
1260
1301
|
"tryKeepExistingSessionAsync",
|
|
@@ -1263,7 +1304,7 @@ const kn = () => {
|
|
|
1263
1304
|
if (o) {
|
|
1264
1305
|
n.startKeepAliveServiceWorker(), e.tokens = o;
|
|
1265
1306
|
const i = n.getLoginParams(e.configurationName);
|
|
1266
|
-
e.timeoutId =
|
|
1307
|
+
e.timeoutId = G(
|
|
1267
1308
|
e,
|
|
1268
1309
|
e.tokens.expiresAt,
|
|
1269
1310
|
i.extras,
|
|
@@ -1274,24 +1315,28 @@ const kn = () => {
|
|
|
1274
1315
|
s.checkSessionIframe,
|
|
1275
1316
|
t.client_id,
|
|
1276
1317
|
r
|
|
1277
|
-
), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(
|
|
1318
|
+
), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(k.tryKeepExistingSessionAsync_end, {
|
|
1278
1319
|
success: !0,
|
|
1279
1320
|
message: "tokens inside ServiceWorker are valid"
|
|
1280
1321
|
}), !0;
|
|
1281
1322
|
}
|
|
1282
|
-
e.publishEvent(
|
|
1323
|
+
e.publishEvent(k.tryKeepExistingSessionAsync_end, {
|
|
1283
1324
|
success: !1,
|
|
1284
1325
|
message: "no exiting session found"
|
|
1285
1326
|
});
|
|
1286
1327
|
} else {
|
|
1287
|
-
t.service_worker_relative_url && e.publishEvent(
|
|
1328
|
+
t.service_worker_relative_url && e.publishEvent(k.service_worker_not_supported_by_browser, {
|
|
1288
1329
|
message: "service worker is not supported by this browser"
|
|
1289
1330
|
});
|
|
1290
|
-
const o =
|
|
1331
|
+
const o = C(
|
|
1332
|
+
e.configurationName,
|
|
1333
|
+
t.storage ?? sessionStorage,
|
|
1334
|
+
t.login_state_storage ?? t.storage ?? sessionStorage
|
|
1335
|
+
), { tokens: i } = await o.initAsync();
|
|
1291
1336
|
if (i) {
|
|
1292
|
-
e.tokens =
|
|
1337
|
+
e.tokens = ue(i, null, t.token_renew_mode);
|
|
1293
1338
|
const r = o.getLoginParams();
|
|
1294
|
-
e.timeoutId =
|
|
1339
|
+
e.timeoutId = G(
|
|
1295
1340
|
e,
|
|
1296
1341
|
e.tokens.expiresAt,
|
|
1297
1342
|
r.extras,
|
|
@@ -1302,23 +1347,23 @@ const kn = () => {
|
|
|
1302
1347
|
s.checkSessionIframe,
|
|
1303
1348
|
t.client_id,
|
|
1304
1349
|
a
|
|
1305
|
-
), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(
|
|
1350
|
+
), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(k.tryKeepExistingSessionAsync_end, {
|
|
1306
1351
|
success: !0,
|
|
1307
1352
|
message: "tokens inside storage are valid"
|
|
1308
1353
|
}), !0;
|
|
1309
1354
|
}
|
|
1310
1355
|
}
|
|
1311
|
-
return e.publishEvent(
|
|
1356
|
+
return e.publishEvent(k.tryKeepExistingSessionAsync_end, {
|
|
1312
1357
|
success: !1,
|
|
1313
1358
|
message: n ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
|
|
1314
1359
|
}), !1;
|
|
1315
1360
|
} catch (t) {
|
|
1316
1361
|
return console.error(t), n && await n.clearAsync(), e.publishEvent(
|
|
1317
|
-
|
|
1362
|
+
k.tryKeepExistingSessionAsync_error,
|
|
1318
1363
|
"tokens inside ServiceWorker are invalid"
|
|
1319
1364
|
), !1;
|
|
1320
1365
|
}
|
|
1321
|
-
},
|
|
1366
|
+
}, Le = (e) => {
|
|
1322
1367
|
const n = e.match(
|
|
1323
1368
|
// eslint-disable-next-line no-useless-escape
|
|
1324
1369
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
@@ -1341,75 +1386,80 @@ const kn = () => {
|
|
|
1341
1386
|
hash: s
|
|
1342
1387
|
};
|
|
1343
1388
|
}, Cn = (e) => {
|
|
1344
|
-
const n =
|
|
1389
|
+
const n = Le(e);
|
|
1345
1390
|
let { path: t } = n;
|
|
1346
1391
|
t.endsWith("/") && (t = t.slice(0, -1));
|
|
1347
1392
|
let { hash: s } = n;
|
|
1348
1393
|
return s === "#_=_" && (s = ""), s && (t += s), t;
|
|
1349
|
-
},
|
|
1350
|
-
const n =
|
|
1351
|
-
return
|
|
1352
|
-
},
|
|
1394
|
+
}, ce = (e) => {
|
|
1395
|
+
const n = Le(e), { search: t } = n;
|
|
1396
|
+
return pn(t);
|
|
1397
|
+
}, pn = (e) => {
|
|
1353
1398
|
const n = {};
|
|
1354
1399
|
let t, s, o;
|
|
1355
1400
|
const i = e.split("&");
|
|
1356
1401
|
for (s = 0, o = i.length; s < o; s++)
|
|
1357
1402
|
t = i[s].split("="), n[decodeURIComponent(t[0])] = decodeURIComponent(t[1]);
|
|
1358
1403
|
return n;
|
|
1359
|
-
},
|
|
1404
|
+
}, An = (e, n, t, s, o) => (i = void 0, r = null, a = !1, c = void 0) => {
|
|
1360
1405
|
const f = r;
|
|
1361
1406
|
return r = { ...r }, (async () => {
|
|
1362
1407
|
const l = i || o.getPath();
|
|
1363
|
-
if ("state" in r || (r.state =
|
|
1364
|
-
for (const
|
|
1365
|
-
|
|
1408
|
+
if ("state" in r || (r.state = re(16)), t(k.loginAsync_begin, {}), r)
|
|
1409
|
+
for (const h of Object.keys(r))
|
|
1410
|
+
h.endsWith(":token_request") && delete r[h];
|
|
1366
1411
|
try {
|
|
1367
|
-
const
|
|
1412
|
+
const h = a ? n.silent_redirect_uri : n.redirect_uri;
|
|
1368
1413
|
c || (c = n.scope);
|
|
1369
1414
|
const _ = n.extras ? { ...n.extras, ...r } : r;
|
|
1370
|
-
_.nonce || (_.nonce =
|
|
1371
|
-
const
|
|
1415
|
+
_.nonce || (_.nonce = re(12));
|
|
1416
|
+
const m = { nonce: _.nonce }, p = await x(n, e), g = await s(
|
|
1372
1417
|
n.authority,
|
|
1373
1418
|
n.authority_configuration
|
|
1374
1419
|
);
|
|
1375
1420
|
let y;
|
|
1376
|
-
if (
|
|
1377
|
-
|
|
1421
|
+
if (p)
|
|
1422
|
+
p.setLoginParams({ callbackPath: l, extras: f, scope: c }), await p.initAsync(g, "loginAsync", n), await p.setNonceAsync(m), p.startKeepAliveServiceWorker(), y = p;
|
|
1378
1423
|
else {
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1424
|
+
const S = C(
|
|
1425
|
+
e,
|
|
1426
|
+
n.storage ?? sessionStorage,
|
|
1427
|
+
n.login_state_storage ?? n.storage ?? sessionStorage
|
|
1428
|
+
);
|
|
1429
|
+
S.setLoginParams({ callbackPath: l, extras: f, scope: c }), await S.setNonceAsync(m), y = S;
|
|
1381
1430
|
}
|
|
1382
|
-
const
|
|
1431
|
+
const A = {
|
|
1383
1432
|
client_id: n.client_id,
|
|
1384
|
-
redirect_uri:
|
|
1433
|
+
redirect_uri: h,
|
|
1385
1434
|
scope: c,
|
|
1386
1435
|
response_type: "code",
|
|
1387
1436
|
..._
|
|
1388
1437
|
};
|
|
1389
|
-
await
|
|
1438
|
+
await _n(y, o)(
|
|
1390
1439
|
g.authorizationEndpoint,
|
|
1391
|
-
|
|
1440
|
+
A
|
|
1392
1441
|
);
|
|
1393
|
-
} catch (
|
|
1394
|
-
throw t(
|
|
1442
|
+
} catch (h) {
|
|
1443
|
+
throw t(k.loginAsync_error, h), h;
|
|
1395
1444
|
}
|
|
1396
1445
|
})();
|
|
1397
|
-
},
|
|
1446
|
+
}, Sn = (e) => async (n = !1) => {
|
|
1398
1447
|
try {
|
|
1399
|
-
e.publishEvent(
|
|
1448
|
+
e.publishEvent(k.loginCallbackAsync_begin, {});
|
|
1400
1449
|
const t = e.configuration, s = t.client_id, o = n ? t.silent_redirect_uri : t.redirect_uri, i = t.authority, r = t.token_request_timeout, a = await e.initAsync(
|
|
1401
1450
|
i,
|
|
1402
1451
|
t.authority_configuration
|
|
1403
|
-
), c = e.location.getCurrentHref(), f =
|
|
1404
|
-
let
|
|
1452
|
+
), c = e.location.getCurrentHref(), f = ce(c), u = f.session_state, l = await x(t, e.configurationName);
|
|
1453
|
+
let h, _, m, p;
|
|
1405
1454
|
if (l)
|
|
1406
|
-
await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), _ = await l.getNonceAsync(),
|
|
1455
|
+
await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), _ = await l.getNonceAsync(), m = l.getLoginParams(), p = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
|
|
1407
1456
|
else {
|
|
1408
|
-
const
|
|
1457
|
+
const v = C(
|
|
1409
1458
|
e.configurationName,
|
|
1410
|
-
t.storage ?? sessionStorage
|
|
1459
|
+
t.storage ?? sessionStorage,
|
|
1460
|
+
t.login_state_storage ?? t.storage ?? sessionStorage
|
|
1411
1461
|
);
|
|
1412
|
-
await
|
|
1462
|
+
await v.setSessionStateAsync(u), _ = await v.getNonceAsync(), m = v.getLoginParams(), p = await v.getStateAsync(), h = v;
|
|
1413
1463
|
}
|
|
1414
1464
|
if (f.error || f.error_description)
|
|
1415
1465
|
throw new Error(
|
|
@@ -1419,8 +1469,8 @@ const kn = () => {
|
|
|
1419
1469
|
throw console.error(), new Error(
|
|
1420
1470
|
`Issuer not valid (expected: ${a.issuer}, received: ${f.iss})`
|
|
1421
1471
|
);
|
|
1422
|
-
if (f.state && f.state !==
|
|
1423
|
-
throw new Error(`State not valid (expected: ${
|
|
1472
|
+
if (f.state && f.state !== p)
|
|
1473
|
+
throw new Error(`State not valid (expected: ${p}, received: ${f.state})`);
|
|
1424
1474
|
const g = {
|
|
1425
1475
|
code: f.code,
|
|
1426
1476
|
grant_type: "authorization_code",
|
|
@@ -1428,78 +1478,86 @@ const kn = () => {
|
|
|
1428
1478
|
redirect_uri: o
|
|
1429
1479
|
}, y = {};
|
|
1430
1480
|
if (t.token_request_extras)
|
|
1431
|
-
for (const [
|
|
1432
|
-
y[
|
|
1433
|
-
if (
|
|
1434
|
-
for (const [
|
|
1435
|
-
|
|
1436
|
-
const
|
|
1481
|
+
for (const [v, d] of Object.entries(t.token_request_extras))
|
|
1482
|
+
y[v] = d;
|
|
1483
|
+
if (m?.extras)
|
|
1484
|
+
for (const [v, d] of Object.entries(m.extras))
|
|
1485
|
+
v.endsWith(":token_request") && (y[v.replace(":token_request", "")] = d);
|
|
1486
|
+
const A = a.tokenEndpoint, S = {};
|
|
1437
1487
|
if (t.demonstrating_proof_of_possession)
|
|
1438
1488
|
if (l)
|
|
1439
|
-
|
|
1489
|
+
S.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
|
|
1440
1490
|
else {
|
|
1441
|
-
const
|
|
1491
|
+
const v = await tn(window)(
|
|
1442
1492
|
t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
|
|
1443
1493
|
);
|
|
1444
|
-
await
|
|
1494
|
+
await C(
|
|
1495
|
+
e.configurationName,
|
|
1496
|
+
t.storage,
|
|
1497
|
+
t.login_state_storage ?? t.storage
|
|
1498
|
+
).setDemonstratingProofOfPossessionJwkAsync(v), S.DPoP = await Ne(window)(
|
|
1445
1499
|
t.demonstrating_proof_of_possession_configuration
|
|
1446
|
-
)(
|
|
1500
|
+
)(v, "POST", A);
|
|
1447
1501
|
}
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1502
|
+
const O = await fn(h)(
|
|
1503
|
+
A,
|
|
1450
1504
|
{ ...g, ...y },
|
|
1451
|
-
|
|
1505
|
+
S,
|
|
1452
1506
|
e.configuration.token_renew_mode,
|
|
1453
1507
|
r
|
|
1454
1508
|
);
|
|
1455
|
-
if (!
|
|
1509
|
+
if (!O.success)
|
|
1456
1510
|
throw new Error("Token request failed");
|
|
1457
|
-
let
|
|
1458
|
-
const
|
|
1459
|
-
if (
|
|
1511
|
+
let T;
|
|
1512
|
+
const N = O.data.tokens, w = O.data.demonstratingProofOfPossessionNonce;
|
|
1513
|
+
if (O.data.state !== y.state)
|
|
1460
1514
|
throw new Error("state is not valid");
|
|
1461
|
-
const { isValid:
|
|
1462
|
-
|
|
1515
|
+
const { isValid: F, reason: L } = Ee(
|
|
1516
|
+
N,
|
|
1463
1517
|
_.nonce,
|
|
1464
1518
|
a
|
|
1465
1519
|
);
|
|
1466
|
-
if (!
|
|
1467
|
-
throw new Error(`Tokens are not OpenID valid, reason: ${
|
|
1520
|
+
if (!F)
|
|
1521
|
+
throw new Error(`Tokens are not OpenID valid, reason: ${L}`);
|
|
1468
1522
|
if (l) {
|
|
1469
|
-
if (
|
|
1523
|
+
if (N.refreshToken && !N.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
1470
1524
|
throw new Error("Refresh token should be hidden by service worker");
|
|
1471
|
-
if (
|
|
1525
|
+
if (w && N?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
|
|
1472
1526
|
throw new Error(
|
|
1473
1527
|
"Demonstration of proof of possession require Access token not hidden by service worker"
|
|
1474
1528
|
);
|
|
1475
1529
|
}
|
|
1476
1530
|
if (l)
|
|
1477
|
-
await l.initAsync(a, "syncTokensAsync", t),
|
|
1478
|
-
|
|
1531
|
+
await l.initAsync(a, "syncTokensAsync", t), T = l.getLoginParams(), w && await l.setDemonstratingProofOfPossessionNonce(
|
|
1532
|
+
w
|
|
1479
1533
|
);
|
|
1480
1534
|
else {
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1535
|
+
const v = C(
|
|
1536
|
+
e.configurationName,
|
|
1537
|
+
t.storage,
|
|
1538
|
+
t.login_state_storage ?? t.storage
|
|
1539
|
+
);
|
|
1540
|
+
T = v.getLoginParams(), w && await v.setDemonstratingProofOfPossessionNonce(w);
|
|
1483
1541
|
}
|
|
1484
1542
|
return await e.startCheckSessionAsync(
|
|
1485
1543
|
a.checkSessionIframe,
|
|
1486
1544
|
s,
|
|
1487
1545
|
u,
|
|
1488
1546
|
n
|
|
1489
|
-
), e.publishEvent(
|
|
1490
|
-
tokens:
|
|
1547
|
+
), e.publishEvent(k.loginCallbackAsync_end, {}), {
|
|
1548
|
+
tokens: N,
|
|
1491
1549
|
state: "request.state",
|
|
1492
|
-
callbackPath:
|
|
1550
|
+
callbackPath: T.callbackPath,
|
|
1493
1551
|
scope: f.scope,
|
|
1494
|
-
extras:
|
|
1552
|
+
extras: T.extras
|
|
1495
1553
|
};
|
|
1496
1554
|
} catch (t) {
|
|
1497
|
-
throw console.error(t), e.publishEvent(
|
|
1555
|
+
throw console.error(t), e.publishEvent(k.loginCallbackAsync_error, t), t;
|
|
1498
1556
|
}
|
|
1499
|
-
},
|
|
1557
|
+
}, Se = {
|
|
1500
1558
|
access_token: "access_token",
|
|
1501
1559
|
refresh_token: "refresh_token"
|
|
1502
|
-
},
|
|
1560
|
+
}, se = (e, n) => {
|
|
1503
1561
|
const t = {};
|
|
1504
1562
|
if (e) {
|
|
1505
1563
|
for (const [s, o] of Object.entries(e))
|
|
@@ -1510,7 +1568,7 @@ const kn = () => {
|
|
|
1510
1568
|
return t;
|
|
1511
1569
|
}
|
|
1512
1570
|
return t;
|
|
1513
|
-
},
|
|
1571
|
+
}, Tn = (e) => {
|
|
1514
1572
|
const n = {};
|
|
1515
1573
|
if (e) {
|
|
1516
1574
|
for (const [t, s] of Object.entries(e))
|
|
@@ -1518,11 +1576,15 @@ const kn = () => {
|
|
|
1518
1576
|
return n;
|
|
1519
1577
|
}
|
|
1520
1578
|
return n;
|
|
1521
|
-
},
|
|
1522
|
-
|
|
1523
|
-
const t = await
|
|
1524
|
-
t ? await t.clearAsync(n) : await
|
|
1525
|
-
|
|
1579
|
+
}, vn = (e) => async (n) => {
|
|
1580
|
+
$.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
1581
|
+
const t = await x(e.configuration, e.configurationName);
|
|
1582
|
+
t ? await t.clearAsync(n) : await C(
|
|
1583
|
+
e.configurationName,
|
|
1584
|
+
e.configuration.storage,
|
|
1585
|
+
e.configuration.login_state_storage ?? e.configuration.storage
|
|
1586
|
+
).clearAsync(n), e.tokens = null, e.userInfo = null;
|
|
1587
|
+
}, En = (e, n, t, s, o) => async (i = void 0, r = null) => {
|
|
1526
1588
|
const a = e.configuration, c = await e.initAsync(
|
|
1527
1589
|
a.authority,
|
|
1528
1590
|
a.authority_configuration
|
|
@@ -1531,33 +1593,33 @@ const kn = () => {
|
|
|
1531
1593
|
const f = i ?? o.getPath();
|
|
1532
1594
|
let u = !1;
|
|
1533
1595
|
i && (u = i.includes("https://") || i.includes("http://"));
|
|
1534
|
-
const l = u ? i : o.getOrigin() + f,
|
|
1596
|
+
const l = u ? i : o.getOrigin() + f, h = e.tokens ? e.tokens.idToken : "";
|
|
1535
1597
|
try {
|
|
1536
1598
|
const y = c.revocationEndpoint;
|
|
1537
1599
|
if (y) {
|
|
1538
|
-
const
|
|
1539
|
-
if (
|
|
1540
|
-
const
|
|
1600
|
+
const A = [], S = e.tokens ? e.tokens.accessToken : null;
|
|
1601
|
+
if (S && a.logout_tokens_to_invalidate.includes(Se.access_token)) {
|
|
1602
|
+
const T = se(r, ":revoke_access_token"), N = pe(t)(
|
|
1541
1603
|
y,
|
|
1542
|
-
|
|
1543
|
-
|
|
1604
|
+
S,
|
|
1605
|
+
ae.access_token,
|
|
1544
1606
|
a.client_id,
|
|
1545
|
-
|
|
1607
|
+
T
|
|
1546
1608
|
);
|
|
1547
|
-
|
|
1609
|
+
A.push(N);
|
|
1548
1610
|
}
|
|
1549
|
-
const
|
|
1550
|
-
if (
|
|
1551
|
-
const
|
|
1611
|
+
const O = e.tokens ? e.tokens.refreshToken : null;
|
|
1612
|
+
if (O && a.logout_tokens_to_invalidate.includes(Se.refresh_token)) {
|
|
1613
|
+
const T = se(r, ":revoke_refresh_token"), N = pe(t)(
|
|
1552
1614
|
y,
|
|
1553
|
-
|
|
1554
|
-
|
|
1615
|
+
O,
|
|
1616
|
+
ae.refresh_token,
|
|
1555
1617
|
a.client_id,
|
|
1556
|
-
|
|
1618
|
+
T
|
|
1557
1619
|
);
|
|
1558
|
-
|
|
1620
|
+
A.push(N);
|
|
1559
1621
|
}
|
|
1560
|
-
|
|
1622
|
+
A.length > 0 && await Promise.all(A);
|
|
1561
1623
|
}
|
|
1562
1624
|
} catch (y) {
|
|
1563
1625
|
s.warn(
|
|
@@ -1567,20 +1629,20 @@ const kn = () => {
|
|
|
1567
1629
|
const _ = e.tokens?.idTokenPayload?.sub ?? null;
|
|
1568
1630
|
await e.destroyAsync("LOGGED_OUT");
|
|
1569
1631
|
for (const [, y] of Object.entries(n))
|
|
1570
|
-
y !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(
|
|
1571
|
-
const
|
|
1572
|
-
if (
|
|
1632
|
+
y !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(k.logout_from_same_tab, {});
|
|
1633
|
+
const m = se(r, ":oidc");
|
|
1634
|
+
if (m && m.no_reload === "true")
|
|
1573
1635
|
return;
|
|
1574
|
-
const g =
|
|
1636
|
+
const g = Tn(r);
|
|
1575
1637
|
if (c.endSessionEndpoint) {
|
|
1576
|
-
"id_token_hint" in g || (g.id_token_hint =
|
|
1638
|
+
"id_token_hint" in g || (g.id_token_hint = h), !("post_logout_redirect_uri" in g) && i !== null && (g.post_logout_redirect_uri = l);
|
|
1577
1639
|
let y = "";
|
|
1578
|
-
for (const [
|
|
1579
|
-
|
|
1640
|
+
for (const [A, S] of Object.entries(g))
|
|
1641
|
+
S != null && (y === "" ? y += "?" : y += "&", y += `${A}=${encodeURIComponent(S)}`);
|
|
1580
1642
|
o.open(`${c.endSessionEndpoint}${y}`);
|
|
1581
1643
|
} else
|
|
1582
1644
|
o.reload();
|
|
1583
|
-
},
|
|
1645
|
+
}, De = (e, n, t = !1) => async (...s) => {
|
|
1584
1646
|
const [o, i, ...r] = s, a = i ? { ...i } : { method: "GET" };
|
|
1585
1647
|
let c = new Headers();
|
|
1586
1648
|
a.headers && (c = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
|
|
@@ -1591,7 +1653,7 @@ const kn = () => {
|
|
|
1591
1653
|
refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1592
1654
|
},
|
|
1593
1655
|
syncTokensInfoAsync: async () => {
|
|
1594
|
-
const { status: _ } = await
|
|
1656
|
+
const { status: _ } = await de(n)(
|
|
1595
1657
|
n.configuration,
|
|
1596
1658
|
n.configurationName,
|
|
1597
1659
|
n.tokens,
|
|
@@ -1600,7 +1662,7 @@ const kn = () => {
|
|
|
1600
1662
|
return _;
|
|
1601
1663
|
},
|
|
1602
1664
|
renewTokensAsync: n.renewTokensAsync.bind(n)
|
|
1603
|
-
}, l = (await
|
|
1665
|
+
}, l = (await ve(f))?.tokens?.accessToken;
|
|
1604
1666
|
if (c.has("Accept") || c.set("Accept", "application/json"), l) {
|
|
1605
1667
|
if (n.configuration.demonstrating_proof_of_possession && t) {
|
|
1606
1668
|
const _ = await n.generateDemonstrationOfProofOfPossessionAsync(
|
|
@@ -1613,9 +1675,9 @@ const kn = () => {
|
|
|
1613
1675
|
c.set("Authorization", `Bearer ${l}`);
|
|
1614
1676
|
a.credentials || (a.credentials = "same-origin");
|
|
1615
1677
|
}
|
|
1616
|
-
const
|
|
1617
|
-
return await e(o,
|
|
1618
|
-
},
|
|
1678
|
+
const h = { ...a, headers: c };
|
|
1679
|
+
return await e(o, h, ...r);
|
|
1680
|
+
}, On = (e) => async (n = !1, t = !1) => {
|
|
1619
1681
|
if (e.userInfo != null && !n)
|
|
1620
1682
|
return e.userInfo;
|
|
1621
1683
|
const s = !n && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
|
|
@@ -1625,49 +1687,49 @@ const kn = () => {
|
|
|
1625
1687
|
o.authority,
|
|
1626
1688
|
o.authority_configuration
|
|
1627
1689
|
)).userInfoEndpoint, c = await (async () => {
|
|
1628
|
-
const u = await
|
|
1690
|
+
const u = await De(fetch, e, t)(r);
|
|
1629
1691
|
return u.status !== 200 ? null : u.json();
|
|
1630
1692
|
})();
|
|
1631
1693
|
return e.userInfo = c, c && e.configuration.storage?.setItem(
|
|
1632
1694
|
`oidc.${e.configurationName}.userInfo`,
|
|
1633
1695
|
JSON.stringify(c)
|
|
1634
1696
|
), c;
|
|
1635
|
-
},
|
|
1636
|
-
class
|
|
1697
|
+
}, bn = () => fetch;
|
|
1698
|
+
class le {
|
|
1637
1699
|
constructor(n) {
|
|
1638
1700
|
this.authorizationEndpoint = n.authorization_endpoint, this.tokenEndpoint = n.token_endpoint, this.revocationEndpoint = n.revocation_endpoint, this.userInfoEndpoint = n.userinfo_endpoint, this.checkSessionIframe = n.check_session_iframe, this.issuer = n.issuer, this.endSessionEndpoint = n.end_session_endpoint;
|
|
1639
1701
|
}
|
|
1640
1702
|
}
|
|
1641
|
-
const R = {},
|
|
1703
|
+
const R = {}, Pn = (e, n = new Q()) => (t, s = "default") => (R[s] || (R[s] = new W(t, s, e, n)), R[s]), In = async (e) => {
|
|
1642
1704
|
const { parsedTokens: n, callbackPath: t, extras: s, scope: o } = await e.loginCallbackAsync();
|
|
1643
|
-
return e.timeoutId =
|
|
1644
|
-
},
|
|
1645
|
-
constructor(n, t = "default", s, o = new
|
|
1705
|
+
return e.timeoutId = G(e, n.expiresAt, s, o), { callbackPath: t };
|
|
1706
|
+
}, Nn = (e) => Math.floor(Math.random() * e), J = class J {
|
|
1707
|
+
constructor(n, t = "default", s, o = new Q()) {
|
|
1646
1708
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1647
1709
|
let i = n.silent_login_uri;
|
|
1648
1710
|
n.silent_redirect_uri && !n.silent_login_uri && (i = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1649
1711
|
let r = n.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1650
|
-
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new
|
|
1712
|
+
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new Q(), this.configuration = {
|
|
1651
1713
|
...n,
|
|
1652
1714
|
silent_login_uri: i,
|
|
1653
|
-
token_automatic_renew_mode: n.token_automatic_renew_mode ??
|
|
1715
|
+
token_automatic_renew_mode: n.token_automatic_renew_mode ?? H.AutomaticBeforeTokenExpiration,
|
|
1654
1716
|
monitor_session: n.monitor_session ?? !1,
|
|
1655
1717
|
refresh_time_before_tokens_expiration_in_second: r,
|
|
1656
1718
|
silent_login_timeout: n.silent_login_timeout ?? 12e3,
|
|
1657
|
-
token_renew_mode: n.token_renew_mode ??
|
|
1719
|
+
token_renew_mode: n.token_renew_mode ?? oe.access_token_or_id_token_invalid,
|
|
1658
1720
|
demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
|
|
1659
1721
|
authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1660
1722
|
logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? [
|
|
1661
1723
|
"access_token",
|
|
1662
1724
|
"refresh_token"
|
|
1663
1725
|
],
|
|
1664
|
-
service_worker_activate: n.service_worker_activate ??
|
|
1665
|
-
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ??
|
|
1726
|
+
service_worker_activate: n.service_worker_activate ?? mn,
|
|
1727
|
+
demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? qe,
|
|
1666
1728
|
preload_user_info: n.preload_user_info ?? !1
|
|
1667
|
-
}, this.getFetch = s ??
|
|
1729
|
+
}, this.getFetch = s ?? bn, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1668
1730
|
}
|
|
1669
1731
|
subscribeEvents(n) {
|
|
1670
|
-
const t =
|
|
1732
|
+
const t = Nn(9999999999999).toString();
|
|
1671
1733
|
return this.events.push({ id: t, func: n }), t;
|
|
1672
1734
|
}
|
|
1673
1735
|
removeEventSubscription(n) {
|
|
@@ -1688,7 +1750,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1688
1750
|
}
|
|
1689
1751
|
_silentLoginCallbackFromIFrame() {
|
|
1690
1752
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1691
|
-
const n = this.location, t =
|
|
1753
|
+
const n = this.location, t = ce(n.getCurrentHref());
|
|
1692
1754
|
window.parent.postMessage(
|
|
1693
1755
|
`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: t.session_state })}`,
|
|
1694
1756
|
n.getOrigin()
|
|
@@ -1697,7 +1759,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1697
1759
|
}
|
|
1698
1760
|
_silentLoginErrorCallbackFromIFrame(n = null) {
|
|
1699
1761
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1700
|
-
const t = this.location, s =
|
|
1762
|
+
const t = this.location, s = ce(t.getCurrentHref());
|
|
1701
1763
|
s.error ? window.parent.postMessage(
|
|
1702
1764
|
`${this.configurationName}_oidc_error:${JSON.stringify({ error: s.error })}`,
|
|
1703
1765
|
t.getOrigin()
|
|
@@ -1719,7 +1781,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1719
1781
|
return this.initPromise;
|
|
1720
1782
|
const s = async () => {
|
|
1721
1783
|
if (t != null)
|
|
1722
|
-
return new
|
|
1784
|
+
return new le({
|
|
1723
1785
|
authorization_endpoint: t.authorization_endpoint,
|
|
1724
1786
|
end_session_endpoint: t.end_session_endpoint,
|
|
1725
1787
|
revocation_endpoint: t.revocation_endpoint,
|
|
@@ -1728,8 +1790,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1728
1790
|
check_session_iframe: t.check_session_iframe,
|
|
1729
1791
|
issuer: t.issuer
|
|
1730
1792
|
});
|
|
1731
|
-
const i = await
|
|
1732
|
-
return await
|
|
1793
|
+
const i = await x(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
|
|
1794
|
+
return await ln(this.getFetch())(
|
|
1733
1795
|
n,
|
|
1734
1796
|
this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600,
|
|
1735
1797
|
i,
|
|
@@ -1741,12 +1803,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1741
1803
|
});
|
|
1742
1804
|
}
|
|
1743
1805
|
async tryKeepExistingSessionAsync() {
|
|
1744
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1806
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = wn(this), this.tryKeepExistingSessionPromise.finally(() => {
|
|
1745
1807
|
this.tryKeepExistingSessionPromise = null;
|
|
1746
1808
|
}));
|
|
1747
1809
|
}
|
|
1748
1810
|
async startCheckSessionAsync(n, t, s, o = !1) {
|
|
1749
|
-
await
|
|
1811
|
+
await gn(this, R, this.configuration)(
|
|
1750
1812
|
n,
|
|
1751
1813
|
t,
|
|
1752
1814
|
s,
|
|
@@ -1754,13 +1816,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1754
1816
|
);
|
|
1755
1817
|
}
|
|
1756
1818
|
async loginAsync(n = void 0, t = null, s = !1, o = void 0, i = !1) {
|
|
1757
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise =
|
|
1819
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = dn(
|
|
1758
1820
|
window,
|
|
1759
1821
|
this.configurationName,
|
|
1760
1822
|
this.configuration,
|
|
1761
1823
|
this.publishEvent.bind(this),
|
|
1762
1824
|
this
|
|
1763
|
-
)(t, o) : this.loginPromise =
|
|
1825
|
+
)(t, o) : this.loginPromise = An(
|
|
1764
1826
|
this.configurationName,
|
|
1765
1827
|
this.configuration,
|
|
1766
1828
|
this.publishEvent.bind(this),
|
|
@@ -1774,8 +1836,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1774
1836
|
if (this.loginCallbackPromise !== null)
|
|
1775
1837
|
return this.loginCallbackPromise;
|
|
1776
1838
|
const t = async () => {
|
|
1777
|
-
const s = await
|
|
1778
|
-
return this.tokens = o, await
|
|
1839
|
+
const s = await Sn(this)(n), o = s.tokens;
|
|
1840
|
+
return this.tokens = o, await x(this.configuration, this.configurationName) || C(
|
|
1841
|
+
this.configurationName,
|
|
1842
|
+
this.configuration.storage,
|
|
1843
|
+
this.configuration.login_state_storage ?? this.configuration.storage
|
|
1844
|
+
).setTokens(o), this.publishEvent(J.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
|
|
1779
1845
|
parsedTokens: o,
|
|
1780
1846
|
state: s.state,
|
|
1781
1847
|
callbackPath: s.callbackPath,
|
|
@@ -1789,23 +1855,27 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1789
1855
|
}
|
|
1790
1856
|
async generateDemonstrationOfProofOfPossessionAsync(n, t, s, o = {}) {
|
|
1791
1857
|
const i = this.configuration, r = {
|
|
1792
|
-
ath: await
|
|
1858
|
+
ath: await xe(n),
|
|
1793
1859
|
...o
|
|
1794
1860
|
};
|
|
1795
|
-
if (await
|
|
1796
|
-
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${
|
|
1797
|
-
const c =
|
|
1798
|
-
|
|
1861
|
+
if (await x(i, this.configurationName))
|
|
1862
|
+
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${be(this.configurationName)}`;
|
|
1863
|
+
const c = C(
|
|
1864
|
+
this.configurationName,
|
|
1865
|
+
i.storage,
|
|
1866
|
+
i.login_state_storage ?? i.storage
|
|
1867
|
+
), f = await c.getDemonstratingProofOfPossessionJwkAsync(), u = c.getDemonstratingProofOfPossessionNonce();
|
|
1868
|
+
return u && (r.nonce = u), await Ne(window)(
|
|
1799
1869
|
i.demonstrating_proof_of_possession_configuration
|
|
1800
1870
|
)(f, s, t, r);
|
|
1801
1871
|
}
|
|
1802
1872
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1803
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1873
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = In(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
|
|
1804
1874
|
this.loginCallbackWithAutoTokensRenewPromise = null;
|
|
1805
1875
|
}));
|
|
1806
1876
|
}
|
|
1807
1877
|
userInfoAsync(n = !1, t = !1) {
|
|
1808
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1878
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = On(this)(n, t), this.userInfoPromise.finally(() => {
|
|
1809
1879
|
this.userInfoPromise = null;
|
|
1810
1880
|
}));
|
|
1811
1881
|
}
|
|
@@ -1813,21 +1883,21 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1813
1883
|
if (this.renewTokensPromise !== null)
|
|
1814
1884
|
return this.renewTokensPromise;
|
|
1815
1885
|
if (this.timeoutId)
|
|
1816
|
-
return
|
|
1886
|
+
return $.clearTimeout(this.timeoutId), this.renewTokensPromise = We(this, !0, n, t), this.renewTokensPromise.finally(() => {
|
|
1817
1887
|
this.renewTokensPromise = null;
|
|
1818
1888
|
});
|
|
1819
1889
|
}
|
|
1820
1890
|
async destroyAsync(n) {
|
|
1821
|
-
return await
|
|
1891
|
+
return await vn(this)(n);
|
|
1822
1892
|
}
|
|
1823
1893
|
async logoutSameTabAsync(n, t) {
|
|
1824
|
-
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(
|
|
1894
|
+
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_same_tab, { mmessage: "SessionMonitor", sub: t }));
|
|
1825
1895
|
}
|
|
1826
1896
|
async logoutOtherTabAsync(n, t) {
|
|
1827
|
-
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(
|
|
1897
|
+
this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_another_tab, { message: "SessionMonitor", sub: t }));
|
|
1828
1898
|
}
|
|
1829
1899
|
async logoutAsync(n = void 0, t = null) {
|
|
1830
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1900
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = En(
|
|
1831
1901
|
this,
|
|
1832
1902
|
R,
|
|
1833
1903
|
this.getFetch(),
|
|
@@ -1838,9 +1908,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1838
1908
|
}));
|
|
1839
1909
|
}
|
|
1840
1910
|
};
|
|
1841
|
-
|
|
1842
|
-
let
|
|
1843
|
-
const
|
|
1911
|
+
J.getOrCreate = (n, t) => (s, o = "default") => Pn(n, t)(s, o), J.eventNames = k;
|
|
1912
|
+
let W = J;
|
|
1913
|
+
const V = class V {
|
|
1844
1914
|
constructor(n) {
|
|
1845
1915
|
this._oidc = n;
|
|
1846
1916
|
}
|
|
@@ -1854,7 +1924,7 @@ const U = class U {
|
|
|
1854
1924
|
this._oidc.publishEvent(n, t);
|
|
1855
1925
|
}
|
|
1856
1926
|
static get(n = "default") {
|
|
1857
|
-
return new
|
|
1927
|
+
return new V(W.get(n));
|
|
1858
1928
|
}
|
|
1859
1929
|
tryKeepExistingSessionAsync() {
|
|
1860
1930
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
@@ -1896,7 +1966,7 @@ const U = class U {
|
|
|
1896
1966
|
refresh_time_before_tokens_expiration_in_second: s.configuration.refresh_time_before_tokens_expiration_in_second
|
|
1897
1967
|
},
|
|
1898
1968
|
syncTokensInfoAsync: async () => {
|
|
1899
|
-
const { status: i } = await
|
|
1969
|
+
const { status: i } = await de(s)(
|
|
1900
1970
|
s.configuration,
|
|
1901
1971
|
s.configurationName,
|
|
1902
1972
|
s.tokens,
|
|
@@ -1906,10 +1976,10 @@ const U = class U {
|
|
|
1906
1976
|
},
|
|
1907
1977
|
renewTokensAsync: s.renewTokensAsync.bind(s)
|
|
1908
1978
|
};
|
|
1909
|
-
return
|
|
1979
|
+
return ve(o, n, t);
|
|
1910
1980
|
}
|
|
1911
1981
|
fetchWithTokens(n, t = !1) {
|
|
1912
|
-
return
|
|
1982
|
+
return De(n, this._oidc, t);
|
|
1913
1983
|
}
|
|
1914
1984
|
async userInfoAsync(n = !1, t = !1) {
|
|
1915
1985
|
return this._oidc.userInfoAsync(n, t);
|
|
@@ -1918,14 +1988,14 @@ const U = class U {
|
|
|
1918
1988
|
return this._oidc.userInfo;
|
|
1919
1989
|
}
|
|
1920
1990
|
};
|
|
1921
|
-
|
|
1922
|
-
let
|
|
1991
|
+
V.getOrCreate = (n, t = new Q()) => (s, o = "default") => new V(W.getOrCreate(n, t)(s, o)), V.eventNames = W.eventNames;
|
|
1992
|
+
let Te = V;
|
|
1923
1993
|
export {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1994
|
+
Te as OidcClient,
|
|
1995
|
+
Q as OidcLocation,
|
|
1996
|
+
H as TokenAutomaticRenewMode,
|
|
1997
|
+
oe as TokenRenewMode,
|
|
1998
|
+
bn as getFetchDefault,
|
|
1999
|
+
ce as getParseQueryStringFromLocation,
|
|
1930
2000
|
Cn as getPath
|
|
1931
2001
|
};
|