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