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