@axa-fr/oidc-client 7.13.8 → 7.13.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +430 -429
- package/dist/index.umd.cjs +2 -2
- package/dist/initWorkerOption.d.ts.map +1 -1
- package/dist/renewTokens.d.ts.map +1 -1
- package/dist/requests.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/initWorkerOption.ts +5 -5
- package/src/renewTokens.ts +4 -2
- package/src/requests.ts +0 -1
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const L = console;
|
|
2
2
|
class Ie {
|
|
3
|
-
constructor(e,
|
|
4
|
-
this._callback = e, this._client_id =
|
|
3
|
+
constructor(e, s, t, o = 2e3, i = !0) {
|
|
4
|
+
this._callback = e, this._client_id = s, this._url = t, this._interval = o || 2e3, this._stopOnError = i;
|
|
5
5
|
const r = t.indexOf("/", t.indexOf("//") + 2);
|
|
6
6
|
this._frame_origin = t.substr(0, r), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = t;
|
|
7
7
|
}
|
|
@@ -17,10 +17,10 @@ class Ie {
|
|
|
17
17
|
}
|
|
18
18
|
start(e) {
|
|
19
19
|
L.debug("CheckSessionIFrame.start :" + e), this.stop();
|
|
20
|
-
const
|
|
20
|
+
const s = () => {
|
|
21
21
|
this._frame.contentWindow.postMessage(this._client_id + " " + e, this._frame_origin);
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
s(), this._timer = window.setInterval(s, this._interval);
|
|
24
24
|
}
|
|
25
25
|
stop() {
|
|
26
26
|
this._timer && (L.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
|
|
@@ -54,26 +54,26 @@ const m = {
|
|
|
54
54
|
syncTokensAsync_lock_not_available: "syncTokensAsync_lock_not_available",
|
|
55
55
|
syncTokensAsync_end: "syncTokensAsync_end",
|
|
56
56
|
syncTokensAsync_error: "syncTokensAsync_error"
|
|
57
|
-
}, I = (
|
|
58
|
-
const
|
|
59
|
-
if (!e[`oidc.${
|
|
60
|
-
return e[`oidc.${
|
|
61
|
-
const p = JSON.parse(e[`oidc.${
|
|
57
|
+
}, I = (n, e = sessionStorage) => {
|
|
58
|
+
const s = (p) => (e[`oidc.${n}`] = JSON.stringify({ tokens: null, status: p }), Promise.resolve()), t = async () => {
|
|
59
|
+
if (!e[`oidc.${n}`])
|
|
60
|
+
return e[`oidc.${n}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
|
|
61
|
+
const p = JSON.parse(e[`oidc.${n}`]);
|
|
62
62
|
return Promise.resolve({ tokens: p.tokens, status: p.status });
|
|
63
63
|
}, o = (p) => {
|
|
64
|
-
e[`oidc.${
|
|
64
|
+
e[`oidc.${n}`] = JSON.stringify({ tokens: p });
|
|
65
65
|
}, i = async (p) => {
|
|
66
|
-
e[`oidc.session_state.${
|
|
67
|
-
}, r = async () => e[`oidc.session_state.${
|
|
68
|
-
e[`oidc.nonce.${
|
|
66
|
+
e[`oidc.session_state.${n}`] = p;
|
|
67
|
+
}, r = async () => e[`oidc.session_state.${n}`], c = (p) => {
|
|
68
|
+
e[`oidc.nonce.${n}`] = p.nonce;
|
|
69
69
|
}, a = (p) => {
|
|
70
|
-
e[`oidc.jwk.${
|
|
71
|
-
}, u = () => JSON.parse(e[`oidc.jwk.${
|
|
72
|
-
e[`oidc.dpop_nonce.${
|
|
73
|
-
}, l = () => e[`oidc.dpop_nonce.${
|
|
70
|
+
e[`oidc.jwk.${n}`] = JSON.stringify(p);
|
|
71
|
+
}, u = () => JSON.parse(e[`oidc.jwk.${n}`]), f = async () => ({ nonce: e[`oidc.nonce.${n}`] }), d = async (p) => {
|
|
72
|
+
e[`oidc.dpop_nonce.${n}`] = p;
|
|
73
|
+
}, l = () => e[`oidc.dpop_nonce.${n}`], h = () => e[`oidc.${n}`] ? JSON.stringify({ tokens: JSON.parse(e[`oidc.${n}`]).tokens }) : null;
|
|
74
74
|
let y = {};
|
|
75
75
|
return {
|
|
76
|
-
clearAsync:
|
|
76
|
+
clearAsync: s,
|
|
77
77
|
initAsync: t,
|
|
78
78
|
setTokens: o,
|
|
79
79
|
getTokens: h,
|
|
@@ -82,96 +82,96 @@ const m = {
|
|
|
82
82
|
setNonceAsync: c,
|
|
83
83
|
getNonceAsync: f,
|
|
84
84
|
setLoginParams: (p) => {
|
|
85
|
-
y[
|
|
85
|
+
y[n] = p, e[`oidc.login.${n}`] = JSON.stringify(p);
|
|
86
86
|
},
|
|
87
87
|
getLoginParams: () => {
|
|
88
|
-
const p = e[`oidc.login.${
|
|
89
|
-
return y[
|
|
88
|
+
const p = e[`oidc.login.${n}`];
|
|
89
|
+
return y[n] || (y[n] = JSON.parse(p)), y[n];
|
|
90
90
|
},
|
|
91
|
-
getStateAsync: async () => e[`oidc.state.${
|
|
91
|
+
getStateAsync: async () => e[`oidc.state.${n}`],
|
|
92
92
|
setStateAsync: async (p) => {
|
|
93
|
-
e[`oidc.state.${
|
|
93
|
+
e[`oidc.state.${n}`] = p;
|
|
94
94
|
},
|
|
95
|
-
getCodeVerifierAsync: async () => e[`oidc.code_verifier.${
|
|
95
|
+
getCodeVerifierAsync: async () => e[`oidc.code_verifier.${n}`],
|
|
96
96
|
setCodeVerifierAsync: async (p) => {
|
|
97
|
-
e[`oidc.code_verifier.${
|
|
97
|
+
e[`oidc.code_verifier.${n}`] = p;
|
|
98
98
|
},
|
|
99
99
|
setDemonstratingProofOfPossessionNonce: d,
|
|
100
100
|
getDemonstratingProofOfPossessionNonce: l,
|
|
101
101
|
setDemonstratingProofOfPossessionJwkAsync: a,
|
|
102
102
|
getDemonstratingProofOfPossessionJwkAsync: u
|
|
103
103
|
};
|
|
104
|
-
}, Ce = (
|
|
104
|
+
}, Ce = (n) => decodeURIComponent(Array.prototype.map.call(atob(n), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), xe = (n) => JSON.parse(Ce(n.split(".")[1].replace("-", "+").replace("_", "/"))), ce = (n) => {
|
|
105
105
|
try {
|
|
106
|
-
return
|
|
106
|
+
return n && Ne(n, ".") === 2 ? xe(n) : null;
|
|
107
107
|
} catch (e) {
|
|
108
108
|
console.warn(e);
|
|
109
109
|
}
|
|
110
110
|
return null;
|
|
111
|
-
}, Ne = (
|
|
111
|
+
}, Ne = (n, e) => n.split(e).length - 1, Y = {
|
|
112
112
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
113
113
|
access_token_invalid: "access_token_invalid",
|
|
114
114
|
id_token_invalid: "id_token_invalid"
|
|
115
115
|
};
|
|
116
|
-
function We(
|
|
117
|
-
if (
|
|
118
|
-
if (typeof
|
|
119
|
-
return parseInt(
|
|
116
|
+
function We(n, e, s) {
|
|
117
|
+
if (n.issuedAt) {
|
|
118
|
+
if (typeof n.issuedAt == "string")
|
|
119
|
+
return parseInt(n.issuedAt, 10);
|
|
120
120
|
} else
|
|
121
|
-
return e && e.iat ? e.iat :
|
|
122
|
-
return
|
|
121
|
+
return e && e.iat ? e.iat : s && s.iat ? s.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
122
|
+
return n.issuedAt;
|
|
123
123
|
}
|
|
124
|
-
const
|
|
125
|
-
if (!
|
|
124
|
+
const se = (n, e = null, s) => {
|
|
125
|
+
if (!n)
|
|
126
126
|
return null;
|
|
127
127
|
let t;
|
|
128
|
-
const o = typeof
|
|
129
|
-
|
|
130
|
-
const i =
|
|
131
|
-
|
|
128
|
+
const o = typeof n.expiresIn == "string" ? parseInt(n.expiresIn, 10) : n.expiresIn;
|
|
129
|
+
n.accessTokenPayload !== void 0 ? t = n.accessTokenPayload : t = ce(n.accessToken);
|
|
130
|
+
const i = n.idTokenPayload ? n.idTokenPayload : ce(n.idToken), r = i && i.exp ? i.exp : Number.MAX_VALUE, c = t && t.exp ? t.exp : n.issuedAt + o;
|
|
131
|
+
n.issuedAt = We(n, t, i);
|
|
132
132
|
let a;
|
|
133
|
-
|
|
134
|
-
const u = { ...
|
|
135
|
-
if (e != null && "refreshToken" in e && !("refreshToken" in
|
|
133
|
+
n.expiresAt ? a = n.expiresAt : s === Y.access_token_invalid ? a = c : s === Y.id_token_invalid ? a = r : a = r < c ? r : c;
|
|
134
|
+
const u = { ...n, idTokenPayload: i, accessTokenPayload: t, expiresAt: a };
|
|
135
|
+
if (e != null && "refreshToken" in e && !("refreshToken" in n)) {
|
|
136
136
|
const f = e.refreshToken;
|
|
137
137
|
return { ...u, refreshToken: f };
|
|
138
138
|
}
|
|
139
139
|
return u;
|
|
140
|
-
},
|
|
141
|
-
if (!
|
|
140
|
+
}, te = (n, e, s) => {
|
|
141
|
+
if (!n)
|
|
142
142
|
return null;
|
|
143
|
-
if (!
|
|
143
|
+
if (!n.issued_at) {
|
|
144
144
|
const o = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
145
|
-
|
|
145
|
+
n.issued_at = o;
|
|
146
146
|
}
|
|
147
147
|
const t = {
|
|
148
|
-
accessToken:
|
|
149
|
-
expiresIn:
|
|
150
|
-
idToken:
|
|
151
|
-
scope:
|
|
152
|
-
tokenType:
|
|
153
|
-
issuedAt:
|
|
148
|
+
accessToken: n.access_token,
|
|
149
|
+
expiresIn: n.expires_in,
|
|
150
|
+
idToken: n.id_token,
|
|
151
|
+
scope: n.scope,
|
|
152
|
+
tokenType: n.token_type,
|
|
153
|
+
issuedAt: n.issued_at
|
|
154
154
|
};
|
|
155
|
-
return "refresh_token" in
|
|
156
|
-
}, V = (
|
|
157
|
-
const
|
|
158
|
-
return Math.round(t -
|
|
159
|
-
}, z = (
|
|
160
|
-
let t =
|
|
161
|
-
if (!
|
|
155
|
+
return "refresh_token" in n && (t.refreshToken = n.refresh_token), n.accessTokenPayload !== void 0 && (t.accessTokenPayload = n.accessTokenPayload), n.idTokenPayload !== void 0 && (t.idTokenPayload = n.idTokenPayload), se(t, e, s);
|
|
156
|
+
}, V = (n, e) => {
|
|
157
|
+
const s = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = e - s;
|
|
158
|
+
return Math.round(t - n);
|
|
159
|
+
}, z = (n) => n ? V(0, n.expiresAt) > 0 : !1, Le = async (n, e = 200, s = 50) => {
|
|
160
|
+
let t = s;
|
|
161
|
+
if (!n.tokens)
|
|
162
162
|
return null;
|
|
163
|
-
for (; !z(
|
|
163
|
+
for (; !z(n.tokens) && t > 0; )
|
|
164
164
|
await $({ milliseconds: e }), t = t - 1;
|
|
165
165
|
return {
|
|
166
|
-
isTokensValid: z(
|
|
167
|
-
tokens:
|
|
168
|
-
numberWaited: t -
|
|
166
|
+
isTokensValid: z(n.tokens),
|
|
167
|
+
tokens: n.tokens,
|
|
168
|
+
numberWaited: t - s
|
|
169
169
|
};
|
|
170
|
-
}, ge = (
|
|
171
|
-
if (
|
|
172
|
-
const t =
|
|
173
|
-
if (
|
|
174
|
-
return { isValid: !1, reason: `Issuer does not match (oidcServerConfiguration issuer) ${
|
|
170
|
+
}, ge = (n, e, s) => {
|
|
171
|
+
if (n.idTokenPayload) {
|
|
172
|
+
const t = n.idTokenPayload;
|
|
173
|
+
if (s.issuer !== t.iss)
|
|
174
|
+
return { isValid: !1, reason: `Issuer does not match (oidcServerConfiguration issuer) ${s.issuer} !== (idTokenPayload issuer) ${t.iss}` };
|
|
175
175
|
const o = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
176
176
|
if (t.exp && t.exp < o)
|
|
177
177
|
return { isValid: !1, reason: `Token expired (idTokenPayload exp) ${t.exp} < (currentTimeUnixSecond) ${o}` };
|
|
@@ -183,7 +183,7 @@ const ye = (s, e = null, n) => {
|
|
|
183
183
|
}
|
|
184
184
|
return { isValid: !0, reason: "" };
|
|
185
185
|
}, M = function() {
|
|
186
|
-
const
|
|
186
|
+
const n = function() {
|
|
187
187
|
let a, u;
|
|
188
188
|
const f = (function() {
|
|
189
189
|
const l = {}, h = {
|
|
@@ -238,7 +238,7 @@ const ye = (s, e = null, n) => {
|
|
|
238
238
|
}
|
|
239
239
|
return null;
|
|
240
240
|
}();
|
|
241
|
-
if (!
|
|
241
|
+
if (!n) {
|
|
242
242
|
const a = typeof window > "u" ? global : window;
|
|
243
243
|
return {
|
|
244
244
|
setTimeout: setTimeout.bind(a),
|
|
@@ -252,11 +252,11 @@ const ye = (s, e = null, n) => {
|
|
|
252
252
|
return function() {
|
|
253
253
|
return a++, a;
|
|
254
254
|
};
|
|
255
|
-
}(),
|
|
256
|
-
|
|
257
|
-
const u = a.data, f =
|
|
255
|
+
}(), s = {}, t = {};
|
|
256
|
+
n.onmessage = function(a) {
|
|
257
|
+
const u = a.data, f = s[u];
|
|
258
258
|
if (f) {
|
|
259
|
-
f(),
|
|
259
|
+
f(), s[u] = null;
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
262
|
const d = t[u];
|
|
@@ -264,17 +264,17 @@ const ye = (s, e = null, n) => {
|
|
|
264
264
|
};
|
|
265
265
|
function o(a, u) {
|
|
266
266
|
const f = e();
|
|
267
|
-
return
|
|
267
|
+
return n.postMessage(["setTimeout", f, u]), s[f] = a, f;
|
|
268
268
|
}
|
|
269
269
|
function i(a) {
|
|
270
|
-
|
|
270
|
+
n.postMessage(["clearTimeout", a]), s[a] = null;
|
|
271
271
|
}
|
|
272
272
|
function r(a, u) {
|
|
273
273
|
const f = e();
|
|
274
|
-
return
|
|
274
|
+
return n.postMessage(["setInterval", f, u]), t[f] = a, f;
|
|
275
275
|
}
|
|
276
276
|
function c(a) {
|
|
277
|
-
|
|
277
|
+
n.postMessage(["clearInterval", a]), t[a] = null;
|
|
278
278
|
}
|
|
279
279
|
return {
|
|
280
280
|
setTimeout: o,
|
|
@@ -282,11 +282,11 @@ const ye = (s, e = null, n) => {
|
|
|
282
282
|
setInterval: r,
|
|
283
283
|
clearInterval: c
|
|
284
284
|
};
|
|
285
|
-
}(),
|
|
286
|
-
let
|
|
287
|
-
const $ = ({ milliseconds:
|
|
285
|
+
}(), le = "7.13.10";
|
|
286
|
+
let ue = null, q;
|
|
287
|
+
const $ = ({ milliseconds: n }) => new Promise((e) => M.setTimeout(e, n)), ke = (n = "/") => {
|
|
288
288
|
try {
|
|
289
|
-
q = new AbortController(), fetch(`${
|
|
289
|
+
q = new AbortController(), fetch(`${n}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((t) => {
|
|
290
290
|
console.log(t);
|
|
291
291
|
}), $({ milliseconds: 150 * 1e3 }).then(ke);
|
|
292
292
|
} catch (e) {
|
|
@@ -294,27 +294,27 @@ const $ = ({ milliseconds: s }) => new Promise((e) => M.setTimeout(e, s)), ke =
|
|
|
294
294
|
}
|
|
295
295
|
}, De = () => {
|
|
296
296
|
q && q.abort();
|
|
297
|
-
}, $e = (
|
|
297
|
+
}, $e = (n = "/") => fetch(`${n}OidcKeepAliveServiceWorker.json`, {
|
|
298
298
|
headers: {
|
|
299
299
|
"oidc-vanilla": "true"
|
|
300
300
|
}
|
|
301
301
|
}).then((e) => e.statusText === "oidc-service-worker").catch((e) => {
|
|
302
302
|
console.log(e);
|
|
303
|
-
}), Re = (
|
|
304
|
-
|
|
303
|
+
}), Re = (n) => async (e, s) => {
|
|
304
|
+
s(), await e.update();
|
|
305
305
|
const t = await e.unregister();
|
|
306
|
-
console.log(`Service worker unregistering ${t}`), await $({ milliseconds: 2e3 }),
|
|
307
|
-
}, b = (
|
|
306
|
+
console.log(`Service worker unregistering ${t}`), await $({ milliseconds: 2e3 }), n.reload();
|
|
307
|
+
}, b = (n) => (e) => new Promise(function(s, t) {
|
|
308
308
|
const o = new MessageChannel();
|
|
309
309
|
o.port1.onmessage = function(i) {
|
|
310
|
-
i.data && i.data.error ? t(i.data.error) :
|
|
311
|
-
},
|
|
312
|
-
}), E = async (
|
|
313
|
-
const
|
|
314
|
-
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !
|
|
310
|
+
i.data && i.data.error ? t(i.data.error) : s(i.data);
|
|
311
|
+
}, n.active.postMessage(e, [o.port2]);
|
|
312
|
+
}), E = async (n, e) => {
|
|
313
|
+
const s = n.service_worker_relative_url;
|
|
314
|
+
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !s || n.service_worker_activate() === !1)
|
|
315
315
|
return null;
|
|
316
316
|
let t = null;
|
|
317
|
-
|
|
317
|
+
n.register ? t = await n.service_worker_register(s) : t = await navigator.serviceWorker.register(s);
|
|
318
318
|
try {
|
|
319
319
|
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await b(t)({ type: "claim" });
|
|
320
320
|
} catch {
|
|
@@ -333,9 +333,9 @@ const $ = ({ milliseconds: s }) => new Promise((e) => M.setTimeout(e, s)), ke =
|
|
|
333
333
|
},
|
|
334
334
|
configurationName: e
|
|
335
335
|
}), P = x.version;
|
|
336
|
-
return P !==
|
|
336
|
+
return P !== le && (console.warn(`Service worker ${P} version mismatch with js client version ${le}, unregistering and reloading`), await O.service_worker_update_require_callback(t, De)), { tokens: te(x.tokens, null, O.token_renew_mode), status: x.status };
|
|
337
337
|
}, r = (k = "/") => {
|
|
338
|
-
|
|
338
|
+
ue == null && (ue = "not_null", ke(k));
|
|
339
339
|
}, c = (k) => b(t)({ type: "setSessionState", data: { sessionState: k }, configurationName: e }), a = async () => (await b(t)({ type: "getSessionState", data: null, configurationName: e })).sessionState, u = (k) => (sessionStorage[`oidc.nonce.${e}`] = k.nonce, b(t)({ type: "setNonce", data: { nonce: k }, configurationName: e })), f = async () => {
|
|
340
340
|
let A = (await b(t)({ type: "getNonce", data: null, configurationName: e })).nonce;
|
|
341
341
|
return A || (A = sessionStorage[`oidc.nonce.${e}`], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: A };
|
|
@@ -344,8 +344,8 @@ const $ = ({ milliseconds: s }) => new Promise((e) => M.setTimeout(e, s)), ke =
|
|
|
344
344
|
return {
|
|
345
345
|
clearAsync: o,
|
|
346
346
|
initAsync: i,
|
|
347
|
-
startKeepAliveServiceWorker: () => r(
|
|
348
|
-
isServiceWorkerProxyActiveAsync: () => $e(
|
|
347
|
+
startKeepAliveServiceWorker: () => r(n.service_worker_keep_alive_path),
|
|
348
|
+
isServiceWorkerProxyActiveAsync: () => $e(n.service_worker_keep_alive_path),
|
|
349
349
|
setSessionStateAsync: c,
|
|
350
350
|
getSessionStateAsync: a,
|
|
351
351
|
setNonceAsync: u,
|
|
@@ -381,81 +381,82 @@ const $ = ({ milliseconds: s }) => new Promise((e) => M.setTimeout(e, s)), ke =
|
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
};
|
|
384
|
-
async function
|
|
384
|
+
async function de(n, e, s, t) {
|
|
385
385
|
const o = (a) => {
|
|
386
|
-
|
|
387
|
-
}, { tokens: i, status: r } = await
|
|
388
|
-
return await E(
|
|
386
|
+
n.tokens = a;
|
|
387
|
+
}, { tokens: i, status: r } = await n.synchroniseTokensAsync(e, 0, s, t, o);
|
|
388
|
+
return await E(n.configuration, n.configurationName) || await I(n.configurationName, n.configuration.storage).setTokens(n.tokens), n.tokens ? i : (await n.destroyAsync(r), null);
|
|
389
389
|
}
|
|
390
|
-
async function Fe(
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
const t = await
|
|
390
|
+
async function Fe(n, e) {
|
|
391
|
+
const s = await E(e, n.configurationName);
|
|
392
|
+
if (s) {
|
|
393
|
+
const t = await n.initAsync(e.authority, e.authority_configuration), { tokens: o } = await s.initAsync(t, "tryKeepExistingSessionAsync", e);
|
|
394
394
|
return o;
|
|
395
395
|
} else {
|
|
396
|
-
const t = I(
|
|
397
|
-
|
|
396
|
+
const t = I(n.configurationName, e.storage ?? sessionStorage);
|
|
397
|
+
let { tokens: o } = await t.initAsync();
|
|
398
|
+
return o = se(o, n.tokens, e.token_renew_mode), o;
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
|
-
async function me(
|
|
401
|
-
const o =
|
|
401
|
+
async function me(n, e, s = !1, t = null) {
|
|
402
|
+
const o = n.configuration, i = `${o.client_id}_${n.configurationName}_${o.authority}`;
|
|
402
403
|
let r;
|
|
403
|
-
const c = await E(
|
|
404
|
-
return (o == null ? void 0 : o.storage) === (window == null ? void 0 : window.sessionStorage) && !c ? r = await
|
|
404
|
+
const c = await E(n.configuration, n.configurationName);
|
|
405
|
+
return (o == null ? void 0 : o.storage) === (window == null ? void 0 : window.sessionStorage) && !c ? r = await de(n, e, s, t) : r = await navigator.locks.request(i, { ifAvailable: !0 }, async (a) => a ? await de(n, e, s, t) : (n.publishEvent(R.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), await Fe(n, o))), r ? (n.timeoutId && (n.timeoutId = K(n, r.refreshToken, n.tokens.expiresAt, t)), n.tokens) : null;
|
|
405
406
|
}
|
|
406
|
-
const K = (
|
|
407
|
-
const o =
|
|
407
|
+
const K = (n, e, s, t = null) => {
|
|
408
|
+
const o = n.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
408
409
|
return M.setTimeout(async () => {
|
|
409
|
-
const r = { timeLeft: V(o,
|
|
410
|
-
|
|
410
|
+
const r = { timeLeft: V(o, s) };
|
|
411
|
+
n.publishEvent(R.eventNames.token_timer, r), await me(n, e, !1, t);
|
|
411
412
|
}, 1e3);
|
|
412
|
-
},
|
|
413
|
+
}, oe = (n, e, s) => (t = null, o = null, i = null) => {
|
|
413
414
|
if (!e.silent_redirect_uri || !e.silent_login_uri)
|
|
414
415
|
return Promise.resolve(null);
|
|
415
416
|
try {
|
|
416
|
-
|
|
417
|
+
s(m.silentLoginAsync_begin, {});
|
|
417
418
|
let r = "";
|
|
418
419
|
if (o && (t == null && (t = {}), t.state = o), i && (t == null && (t = {}), t.scope = i), t != null)
|
|
419
420
|
for (const [d, l] of Object.entries(t))
|
|
420
421
|
r === "" ? r = `?${encodeURIComponent(d)}=${encodeURIComponent(l)}` : r += `&${encodeURIComponent(d)}=${encodeURIComponent(l)}`;
|
|
421
422
|
const c = e.silent_login_uri + r, a = c.indexOf("/", c.indexOf("//") + 2), u = c.substr(0, a), f = document.createElement("iframe");
|
|
422
|
-
return f.width = "0px", f.height = "0px", f.id = `${
|
|
423
|
+
return f.width = "0px", f.height = "0px", f.id = `${n}_oidc_iframe`, f.setAttribute("src", c), document.body.appendChild(f), new Promise((d, l) => {
|
|
423
424
|
try {
|
|
424
425
|
let h = !1;
|
|
425
426
|
window.onmessage = (_) => {
|
|
426
427
|
if (_.origin === u && _.source === f.contentWindow) {
|
|
427
|
-
const g = `${
|
|
428
|
+
const g = `${n}_oidc_tokens:`, w = `${n}_oidc_error:`, v = _.data;
|
|
428
429
|
if (v && typeof v == "string" && !h) {
|
|
429
430
|
if (v.startsWith(g)) {
|
|
430
431
|
const T = JSON.parse(_.data.replace(g, ""));
|
|
431
|
-
|
|
432
|
+
s(m.silentLoginAsync_end, {}), f.remove(), h = !0, d(T);
|
|
432
433
|
} else if (v.startsWith(w)) {
|
|
433
434
|
const T = JSON.parse(_.data.replace(w, ""));
|
|
434
|
-
|
|
435
|
+
s(m.silentLoginAsync_error, T), f.remove(), h = !0, l(new Error("oidc_" + T.error));
|
|
435
436
|
}
|
|
436
437
|
}
|
|
437
438
|
}
|
|
438
439
|
};
|
|
439
440
|
const y = e.silent_login_timeout;
|
|
440
441
|
setTimeout(() => {
|
|
441
|
-
h || (
|
|
442
|
+
h || (s(m.silentLoginAsync_error, { reason: "timeout" }), f.remove(), h = !0, l(new Error("timeout")));
|
|
442
443
|
}, y);
|
|
443
444
|
} catch (h) {
|
|
444
|
-
f.remove(),
|
|
445
|
+
f.remove(), s(m.silentLoginAsync_error, h), l(h);
|
|
445
446
|
}
|
|
446
447
|
});
|
|
447
448
|
} catch (r) {
|
|
448
|
-
throw
|
|
449
|
+
throw s(m.silentLoginAsync_error, r), r;
|
|
449
450
|
}
|
|
450
|
-
}, Ue = (
|
|
451
|
+
}, Ue = (n, e, s, t, o) => (i = null, r = void 0) => {
|
|
451
452
|
i = { ...i };
|
|
452
|
-
const c = (u, f, d) =>
|
|
453
|
+
const c = (u, f, d) => oe(e, s, t.bind(o))(u, f, d);
|
|
453
454
|
return (async () => {
|
|
454
455
|
o.timeoutId && M.clearTimeout(o.timeoutId);
|
|
455
456
|
let u;
|
|
456
457
|
i && "state" in i && (u = i.state, delete i.state);
|
|
457
458
|
try {
|
|
458
|
-
const f =
|
|
459
|
+
const f = s.extras ? { ...s.extras, ...i } : i, d = await c({
|
|
459
460
|
...f,
|
|
460
461
|
prompt: "none"
|
|
461
462
|
}, u, r);
|
|
@@ -465,35 +466,35 @@ const K = (s, e, n, t = null) => {
|
|
|
465
466
|
return f;
|
|
466
467
|
}
|
|
467
468
|
})();
|
|
468
|
-
}, Ve = (
|
|
469
|
-
const c = (a, u = void 0, f = void 0) =>
|
|
469
|
+
}, Ve = (n, e, s) => (t, o, i, r = !1) => {
|
|
470
|
+
const c = (a, u = void 0, f = void 0) => oe(n.configurationName, s, n.publishEvent.bind(n))(a, u, f);
|
|
470
471
|
return new Promise((a, u) => {
|
|
471
|
-
if (
|
|
472
|
+
if (s.silent_login_uri && s.silent_redirect_uri && s.monitor_session && t && i && !r) {
|
|
472
473
|
const f = () => {
|
|
473
|
-
|
|
474
|
-
const d =
|
|
474
|
+
n.checkSessionIFrame.stop();
|
|
475
|
+
const d = n.tokens;
|
|
475
476
|
if (d === null)
|
|
476
477
|
return;
|
|
477
478
|
const l = d.idToken, h = d.idTokenPayload;
|
|
478
479
|
return c({
|
|
479
480
|
prompt: "none",
|
|
480
481
|
id_token_hint: l,
|
|
481
|
-
scope:
|
|
482
|
+
scope: s.scope || "openid"
|
|
482
483
|
}).then((y) => {
|
|
483
484
|
const _ = y.tokens.idTokenPayload;
|
|
484
485
|
if (h.sub === _.sub) {
|
|
485
486
|
const g = y.sessionState;
|
|
486
|
-
|
|
487
|
+
n.checkSessionIFrame.start(y.sessionState), h.sid === _.sid ? console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:", g) : console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:", g);
|
|
487
488
|
} else
|
|
488
489
|
console.debug("SessionMonitor._callback: Different subject signed into OP:", _.sub);
|
|
489
490
|
}).catch(async (y) => {
|
|
490
491
|
console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:", y);
|
|
491
492
|
for (const [_, g] of Object.entries(e))
|
|
492
|
-
await g.logoutOtherTabAsync(
|
|
493
|
+
await g.logoutOtherTabAsync(s.client_id, h.sub);
|
|
493
494
|
});
|
|
494
495
|
};
|
|
495
|
-
|
|
496
|
-
|
|
496
|
+
n.checkSessionIFrame = new Ie(f, o, t), n.checkSessionIFrame.load().then(() => {
|
|
497
|
+
n.checkSessionIFrame.start(i), a(n.checkSessionIFrame);
|
|
497
498
|
}).catch((d) => {
|
|
498
499
|
u(d);
|
|
499
500
|
});
|
|
@@ -501,89 +502,89 @@ const K = (s, e, n, t = null) => {
|
|
|
501
502
|
a(null);
|
|
502
503
|
});
|
|
503
504
|
};
|
|
504
|
-
var Ke = qe, C = [],
|
|
505
|
-
for (var B = 0, Me =
|
|
506
|
-
C[B] =
|
|
507
|
-
function Je(
|
|
508
|
-
return C[
|
|
505
|
+
var Ke = qe, C = [], fe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
506
|
+
for (var B = 0, Me = fe.length; B < Me; ++B)
|
|
507
|
+
C[B] = fe[B];
|
|
508
|
+
function Je(n) {
|
|
509
|
+
return C[n >> 18 & 63] + C[n >> 12 & 63] + C[n >> 6 & 63] + C[n & 63];
|
|
509
510
|
}
|
|
510
|
-
function Be(
|
|
511
|
-
for (var t, o = [], i = e; i <
|
|
512
|
-
t = (
|
|
511
|
+
function Be(n, e, s) {
|
|
512
|
+
for (var t, o = [], i = e; i < s; i += 3)
|
|
513
|
+
t = (n[i] << 16 & 16711680) + (n[i + 1] << 8 & 65280) + (n[i + 2] & 255), o.push(Je(t));
|
|
513
514
|
return o.join("");
|
|
514
515
|
}
|
|
515
|
-
function qe(
|
|
516
|
-
for (var e,
|
|
517
|
-
o.push(Be(
|
|
518
|
-
return t === 1 ? (e = s
|
|
516
|
+
function qe(n) {
|
|
517
|
+
for (var e, s = n.length, t = s % 3, o = [], i = 16383, r = 0, c = s - t; r < c; r += i)
|
|
518
|
+
o.push(Be(n, r, r + i > c ? c : r + i));
|
|
519
|
+
return t === 1 ? (e = n[s - 1], o.push(
|
|
519
520
|
C[e >> 2] + C[e << 4 & 63] + "=="
|
|
520
|
-
)) : t === 2 && (e = (s
|
|
521
|
+
)) : t === 2 && (e = (n[s - 2] << 8) + n[s - 1], o.push(
|
|
521
522
|
C[e >> 10] + C[e >> 4 & 63] + C[e << 2 & 63] + "="
|
|
522
523
|
)), o.join("");
|
|
523
524
|
}
|
|
524
525
|
const pe = () => {
|
|
525
|
-
const
|
|
526
|
-
return { hasCrypto:
|
|
527
|
-
}, Q = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", je = (
|
|
526
|
+
const n = typeof window < "u" && !!window.crypto, e = n && !!window.crypto.subtle;
|
|
527
|
+
return { hasCrypto: n, hasSubtleCrypto: e };
|
|
528
|
+
}, Q = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", je = (n) => {
|
|
528
529
|
const e = [];
|
|
529
|
-
for (let
|
|
530
|
-
const t = s
|
|
530
|
+
for (let s = 0; s < n.byteLength; s += 1) {
|
|
531
|
+
const t = n[s] % Q.length;
|
|
531
532
|
e.push(Q[t]);
|
|
532
533
|
}
|
|
533
534
|
return e.join("");
|
|
534
|
-
}, He = (
|
|
535
|
-
const e = new Uint8Array(
|
|
536
|
-
if (
|
|
535
|
+
}, He = (n) => Ke(new Uint8Array(n)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), Z = (n) => {
|
|
536
|
+
const e = new Uint8Array(n), { hasCrypto: s } = pe();
|
|
537
|
+
if (s)
|
|
537
538
|
window.crypto.getRandomValues(e);
|
|
538
539
|
else
|
|
539
|
-
for (let t = 0; t <
|
|
540
|
+
for (let t = 0; t < n; t += 1)
|
|
540
541
|
e[t] = Math.random() * Q.length | 0;
|
|
541
542
|
return je(e);
|
|
542
543
|
};
|
|
543
|
-
function Ge(
|
|
544
|
-
const e = new ArrayBuffer(
|
|
545
|
-
for (let t = 0; t <
|
|
546
|
-
|
|
547
|
-
return
|
|
544
|
+
function Ge(n) {
|
|
545
|
+
const e = new ArrayBuffer(n.length), s = new Uint8Array(e);
|
|
546
|
+
for (let t = 0; t < n.length; t++)
|
|
547
|
+
s[t] = n.charCodeAt(t);
|
|
548
|
+
return s;
|
|
548
549
|
}
|
|
549
|
-
function we(
|
|
550
|
-
return new Promise((e,
|
|
551
|
-
crypto.subtle.digest("SHA-256", Ge(
|
|
550
|
+
function we(n) {
|
|
551
|
+
return new Promise((e, s) => {
|
|
552
|
+
crypto.subtle.digest("SHA-256", Ge(n)).then((t) => e(He(new Uint8Array(t))), (t) => s(t));
|
|
552
553
|
});
|
|
553
554
|
}
|
|
554
|
-
const Xe = (
|
|
555
|
-
if (
|
|
555
|
+
const Xe = (n) => {
|
|
556
|
+
if (n.length < 43 || n.length > 128)
|
|
556
557
|
return Promise.reject(new Error("Invalid code length."));
|
|
557
558
|
const { hasSubtleCrypto: e } = pe();
|
|
558
|
-
return e ? we(
|
|
559
|
-
}, D = {}, Ye = (
|
|
560
|
-
if (!D[
|
|
561
|
-
const o = e.getItem(
|
|
562
|
-
o && (D[
|
|
563
|
-
}
|
|
564
|
-
const t = 1e3 *
|
|
565
|
-
return D[
|
|
566
|
-
}, ze = (
|
|
559
|
+
return e ? we(n) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
560
|
+
}, D = {}, Ye = (n, e = window.sessionStorage, s) => {
|
|
561
|
+
if (!D[n] && e) {
|
|
562
|
+
const o = e.getItem(n);
|
|
563
|
+
o && (D[n] = JSON.parse(o));
|
|
564
|
+
}
|
|
565
|
+
const t = 1e3 * s;
|
|
566
|
+
return D[n] && D[n].timestamp + t > Date.now() ? D[n].result : null;
|
|
567
|
+
}, ze = (n, e, s = window.sessionStorage) => {
|
|
567
568
|
const t = Date.now();
|
|
568
|
-
D[
|
|
569
|
-
}, Qe = 60 * 60, Ze = (
|
|
570
|
-
const i = `${e}/.well-known/openid-configuration`, r = `oidc.server:${e}`, c = Ye(r, t,
|
|
569
|
+
D[n] = { result: e, timestamp: t }, s && s.setItem(n, JSON.stringify({ result: e, timestamp: t }));
|
|
570
|
+
}, Qe = 60 * 60, Ze = (n) => async (e, s = Qe, t = window.sessionStorage, o = 1e4) => {
|
|
571
|
+
const i = `${e}/.well-known/openid-configuration`, r = `oidc.server:${e}`, c = Ye(r, t, s);
|
|
571
572
|
if (c)
|
|
572
|
-
return new
|
|
573
|
-
const a = await J(
|
|
573
|
+
return new ne(c);
|
|
574
|
+
const a = await J(n)(i, {}, o);
|
|
574
575
|
if (a.status !== 200)
|
|
575
576
|
return null;
|
|
576
577
|
const u = await a.json();
|
|
577
|
-
return ze(r, u, t), new
|
|
578
|
-
}, J = (
|
|
578
|
+
return ze(r, u, t), new ne(u);
|
|
579
|
+
}, J = (n) => async (e, s = {}, t = 1e4, o = 0) => {
|
|
579
580
|
let i;
|
|
580
581
|
try {
|
|
581
582
|
const r = new AbortController();
|
|
582
|
-
setTimeout(() => r.abort(), t), i = await
|
|
583
|
+
setTimeout(() => r.abort(), t), i = await n(e, { ...s, signal: r.signal });
|
|
583
584
|
} catch (r) {
|
|
584
585
|
if (r.name === "AbortError" || r.message === "Network request failed") {
|
|
585
586
|
if (o <= 1)
|
|
586
|
-
return await J(
|
|
587
|
+
return await J(n)(e, s, t, o + 1);
|
|
587
588
|
throw r;
|
|
588
589
|
} else
|
|
589
590
|
throw console.error(r.message), r;
|
|
@@ -592,9 +593,9 @@ const Xe = (s) => {
|
|
|
592
593
|
}, ee = {
|
|
593
594
|
refresh_token: "refresh_token",
|
|
594
595
|
access_token: "access_token"
|
|
595
|
-
},
|
|
596
|
+
}, he = (n) => async (e, s, t = ee.refresh_token, o, i = 1e4) => {
|
|
596
597
|
const r = {
|
|
597
|
-
token:
|
|
598
|
+
token: s,
|
|
598
599
|
token_type_hint: t,
|
|
599
600
|
client_id: o
|
|
600
601
|
}, c = [];
|
|
@@ -603,7 +604,7 @@ const Xe = (s) => {
|
|
|
603
604
|
c.push(`${d}=${l}`);
|
|
604
605
|
}
|
|
605
606
|
const a = c.join("&");
|
|
606
|
-
return (await J(
|
|
607
|
+
return (await J(n)(e, {
|
|
607
608
|
method: "POST",
|
|
608
609
|
headers: {
|
|
609
610
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
@@ -612,15 +613,15 @@ const Xe = (s) => {
|
|
|
612
613
|
}, i)).status !== 200 ? { success: !1 } : {
|
|
613
614
|
success: !0
|
|
614
615
|
};
|
|
615
|
-
},
|
|
616
|
+
}, en = (n) => async (e, s, t, o, i = {}, r, c = 1e4) => {
|
|
616
617
|
for (const [h, y] of Object.entries(t))
|
|
617
|
-
|
|
618
|
+
s[h] === void 0 && (s[h] = y);
|
|
618
619
|
const a = [];
|
|
619
|
-
for (const h in
|
|
620
|
-
const y = encodeURIComponent(h), _ = encodeURIComponent(
|
|
620
|
+
for (const h in s) {
|
|
621
|
+
const y = encodeURIComponent(h), _ = encodeURIComponent(s[h]);
|
|
621
622
|
a.push(`${y}=${_}`);
|
|
622
623
|
}
|
|
623
|
-
const u = a.join("&"), f = await J(
|
|
624
|
+
const u = a.join("&"), f = await J(n)(e, {
|
|
624
625
|
method: "POST",
|
|
625
626
|
headers: {
|
|
626
627
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -634,23 +635,23 @@ const Xe = (s) => {
|
|
|
634
635
|
let l = null;
|
|
635
636
|
return f.headers.has(j) && (l = f.headers.get(j)), {
|
|
636
637
|
success: !0,
|
|
637
|
-
data:
|
|
638
|
+
data: te(d, o, r),
|
|
638
639
|
demonstratingProofOfPossessionNonce: l
|
|
639
640
|
};
|
|
640
|
-
},
|
|
641
|
+
}, nn = (n, e) => async (s, t) => {
|
|
641
642
|
t = t ? { ...t } : {};
|
|
642
643
|
const o = Z(128), i = await Xe(o);
|
|
643
|
-
await
|
|
644
|
+
await n.setCodeVerifierAsync(o), await n.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
|
|
644
645
|
let r = "";
|
|
645
646
|
if (t)
|
|
646
647
|
for (const [c, a] of Object.entries(t))
|
|
647
648
|
r === "" ? r += "?" : r += "&", r += `${c}=${encodeURIComponent(a)}`;
|
|
648
|
-
e.open(`${
|
|
649
|
-
}, j = "DPoP-Nonce",
|
|
650
|
-
|
|
649
|
+
e.open(`${s}${r}`);
|
|
650
|
+
}, j = "DPoP-Nonce", sn = (n) => async (e, s, t, o, i = 1e4) => {
|
|
651
|
+
s = s ? { ...s } : {}, s.code_verifier = await n.getCodeVerifierAsync();
|
|
651
652
|
const r = [];
|
|
652
|
-
for (const d in
|
|
653
|
-
const l = encodeURIComponent(d), h = encodeURIComponent(
|
|
653
|
+
for (const d in s) {
|
|
654
|
+
const l = encodeURIComponent(d), h = encodeURIComponent(s[d]);
|
|
654
655
|
r.push(`${l}=${h}`);
|
|
655
656
|
}
|
|
656
657
|
const c = r.join("&"), a = await J(fetch)(e, {
|
|
@@ -661,7 +662,7 @@ const Xe = (s) => {
|
|
|
661
662
|
},
|
|
662
663
|
body: c
|
|
663
664
|
}, i);
|
|
664
|
-
if (await Promise.all([
|
|
665
|
+
if (await Promise.all([n.setCodeVerifierAsync(null), n.setStateAsync(null)]), a.status !== 200)
|
|
665
666
|
return { success: !1, status: a.status };
|
|
666
667
|
let u = null;
|
|
667
668
|
a.headers.has(j) && (u = a.headers.get(j));
|
|
@@ -669,142 +670,142 @@ const Xe = (s) => {
|
|
|
669
670
|
return {
|
|
670
671
|
success: !0,
|
|
671
672
|
data: {
|
|
672
|
-
state:
|
|
673
|
-
tokens:
|
|
673
|
+
state: s.state,
|
|
674
|
+
tokens: te(f, null, o),
|
|
674
675
|
demonstratingProofOfPossessionNonce: u
|
|
675
676
|
}
|
|
676
677
|
};
|
|
677
|
-
}, Ae = (
|
|
678
|
-
const e =
|
|
678
|
+
}, Ae = (n) => {
|
|
679
|
+
const e = n.match(
|
|
679
680
|
// eslint-disable-next-line no-useless-escape
|
|
680
681
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
681
682
|
);
|
|
682
683
|
if (!e)
|
|
683
684
|
throw new Error("Invalid URL");
|
|
684
|
-
let
|
|
685
|
+
let s = e[6], t = e[7];
|
|
685
686
|
if (t) {
|
|
686
687
|
const o = t.split("?");
|
|
687
|
-
o.length === 2 && (t = o[0],
|
|
688
|
+
o.length === 2 && (t = o[0], s = o[1]);
|
|
688
689
|
}
|
|
689
|
-
return
|
|
690
|
-
href:
|
|
690
|
+
return s.startsWith("?") && (s = s.slice(1)), e && {
|
|
691
|
+
href: n,
|
|
691
692
|
protocol: e[1],
|
|
692
693
|
host: e[2],
|
|
693
694
|
hostname: e[3],
|
|
694
695
|
port: e[4],
|
|
695
696
|
path: e[5],
|
|
696
|
-
search:
|
|
697
|
+
search: s,
|
|
697
698
|
hash: t
|
|
698
699
|
};
|
|
699
|
-
},
|
|
700
|
-
const e = Ae(
|
|
701
|
-
let { path:
|
|
702
|
-
|
|
700
|
+
}, Sn = (n) => {
|
|
701
|
+
const e = Ae(n);
|
|
702
|
+
let { path: s } = e;
|
|
703
|
+
s.endsWith("/") && (s = s.slice(0, -1));
|
|
703
704
|
let { hash: t } = e;
|
|
704
|
-
return t === "#_=_" && (t = ""), t && (
|
|
705
|
-
}, H = (
|
|
706
|
-
const e = Ae(
|
|
707
|
-
return
|
|
708
|
-
},
|
|
705
|
+
return t === "#_=_" && (t = ""), t && (s += t), s;
|
|
706
|
+
}, H = (n) => {
|
|
707
|
+
const e = Ae(n), { search: s } = e;
|
|
708
|
+
return tn(s);
|
|
709
|
+
}, tn = (n) => {
|
|
709
710
|
const e = {};
|
|
710
|
-
let
|
|
711
|
-
const i =
|
|
711
|
+
let s, t, o;
|
|
712
|
+
const i = n.split("&");
|
|
712
713
|
for (t = 0, o = i.length; t < o; t++)
|
|
713
|
-
|
|
714
|
+
s = i[t].split("="), e[decodeURIComponent(s[0])] = decodeURIComponent(s[1]);
|
|
714
715
|
return e;
|
|
715
716
|
};
|
|
716
|
-
function ve(
|
|
717
|
-
return new TextEncoder().encode(
|
|
717
|
+
function ve(n) {
|
|
718
|
+
return new TextEncoder().encode(n);
|
|
718
719
|
}
|
|
719
|
-
function Se(
|
|
720
|
-
return btoa(
|
|
720
|
+
function Se(n) {
|
|
721
|
+
return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
721
722
|
}
|
|
722
|
-
function
|
|
723
|
-
return encodeURIComponent(
|
|
723
|
+
function on(n) {
|
|
724
|
+
return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g, function(t, o) {
|
|
724
725
|
return String.fromCharCode(parseInt(o, 16));
|
|
725
726
|
});
|
|
726
727
|
}
|
|
727
|
-
function Te(
|
|
728
|
+
function Te(n) {
|
|
728
729
|
let e = "";
|
|
729
|
-
return
|
|
730
|
-
e += String.fromCharCode(
|
|
730
|
+
return n.forEach(function(s) {
|
|
731
|
+
e += String.fromCharCode(s);
|
|
731
732
|
}), Se(e);
|
|
732
733
|
}
|
|
733
|
-
function
|
|
734
|
-
return Se(
|
|
734
|
+
function _e(n) {
|
|
735
|
+
return Se(on(n));
|
|
735
736
|
}
|
|
736
737
|
var be = {};
|
|
737
|
-
be.sign = (
|
|
738
|
-
|
|
738
|
+
be.sign = (n, e, s, t = "dpop+jwt") => {
|
|
739
|
+
n = Object.assign({}, n), e.typ = t, e.alg = "ES256", e.kid || (e.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y });
|
|
739
740
|
const o = {
|
|
740
741
|
// @ts-ignore
|
|
741
742
|
// JWT "headers" really means JWS "protected headers"
|
|
742
|
-
protected:
|
|
743
|
+
protected: _e(JSON.stringify(e)),
|
|
743
744
|
// @ts-ignore
|
|
744
745
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
745
|
-
payload:
|
|
746
|
+
payload: _e(JSON.stringify(s))
|
|
746
747
|
}, i = {
|
|
747
748
|
name: "ECDSA",
|
|
748
749
|
namedCurve: "P-256",
|
|
749
750
|
hash: { name: "ES256" }
|
|
750
751
|
}, r = !0, c = ["sign"];
|
|
751
|
-
return window.crypto.subtle.importKey("jwk",
|
|
752
|
+
return window.crypto.subtle.importKey("jwk", n, i, r, c).then(function(a) {
|
|
752
753
|
const u = ve(o.protected + "." + o.payload), f = { name: "ECDSA", hash: { name: "SHA-256" } };
|
|
753
754
|
return window.crypto.subtle.sign(f, a, u).then(function(d) {
|
|
754
755
|
return o.signature = Te(new Uint8Array(d)), o.protected + "." + o.payload + "." + o.signature;
|
|
755
756
|
});
|
|
756
757
|
});
|
|
757
758
|
};
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
const
|
|
759
|
+
const ie = {};
|
|
760
|
+
ie.generate = function() {
|
|
761
|
+
const n = {
|
|
761
762
|
name: "ECDSA",
|
|
762
763
|
namedCurve: "P-256"
|
|
763
|
-
}, e = !0,
|
|
764
|
-
return window.crypto.subtle.generateKey(
|
|
764
|
+
}, e = !0, s = ["sign", "verify"];
|
|
765
|
+
return window.crypto.subtle.generateKey(n, e, s).then(function(t) {
|
|
765
766
|
return window.crypto.subtle.exportKey("jwk", t.privateKey);
|
|
766
767
|
});
|
|
767
768
|
};
|
|
768
|
-
|
|
769
|
-
const e = Object.assign({},
|
|
769
|
+
ie.neuter = function(n) {
|
|
770
|
+
const e = Object.assign({}, n);
|
|
770
771
|
return delete e.d, e.key_ops = ["verify"], e;
|
|
771
772
|
};
|
|
772
773
|
var Pe = {};
|
|
773
|
-
Pe.thumbprint = function(
|
|
774
|
-
const e = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",
|
|
775
|
-
return window.crypto.subtle.digest({ name: "SHA-256" }, ve(e)).then(function(
|
|
776
|
-
return Te(new Uint8Array(
|
|
774
|
+
Pe.thumbprint = function(n) {
|
|
775
|
+
const e = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV", n.crv).replace("X", n.x).replace("Y", n.y);
|
|
776
|
+
return window.crypto.subtle.digest({ name: "SHA-256" }, ve(e)).then(function(s) {
|
|
777
|
+
return Te(new Uint8Array(s));
|
|
777
778
|
});
|
|
778
779
|
};
|
|
779
|
-
const
|
|
780
|
-
const
|
|
781
|
-
let
|
|
780
|
+
const rn = function() {
|
|
781
|
+
const n = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", e = "0123456789abcdef";
|
|
782
|
+
let s = 0, t = "";
|
|
782
783
|
for (let o = 0; o < 36; o++)
|
|
783
|
-
|
|
784
|
+
n[o] !== "-" && n[o] !== "4" && (s = Math.random() * 16 | 0), n[o] === "x" ? t += e[s] : n[o] === "y" ? (s &= 3, s |= 8, t += e[s]) : t += n[o];
|
|
784
785
|
return t;
|
|
785
|
-
},
|
|
786
|
-
return
|
|
787
|
-
}), Oe = (
|
|
786
|
+
}, an = () => ie.generate().then(function(n) {
|
|
787
|
+
return n;
|
|
788
|
+
}), Oe = (n, e = "POST", s, t = {}) => {
|
|
788
789
|
const o = {
|
|
789
790
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
790
|
-
jit: btoa(
|
|
791
|
+
jit: btoa(rn()),
|
|
791
792
|
htm: e,
|
|
792
|
-
htu:
|
|
793
|
+
htu: s,
|
|
793
794
|
iat: Math.round(Date.now() / 1e3),
|
|
794
795
|
...t
|
|
795
796
|
};
|
|
796
|
-
return Pe.thumbprint(
|
|
797
|
-
return be.sign(
|
|
797
|
+
return Pe.thumbprint(n).then(function(i) {
|
|
798
|
+
return be.sign(n, {
|
|
798
799
|
/*kid: kid*/
|
|
799
800
|
}, o).then(function(r) {
|
|
800
801
|
return r;
|
|
801
802
|
});
|
|
802
803
|
});
|
|
803
|
-
},
|
|
804
|
+
}, cn = (n, e, s, t, o) => (i = void 0, r = null, c = !1, a = void 0) => {
|
|
804
805
|
const u = r;
|
|
805
806
|
return r = { ...r }, (async () => {
|
|
806
807
|
const d = i || o.getPath();
|
|
807
|
-
if ("state" in r || (r.state = Z(16)),
|
|
808
|
+
if ("state" in r || (r.state = Z(16)), s(m.loginAsync_begin, {}), r)
|
|
808
809
|
for (const l of Object.keys(r))
|
|
809
810
|
l.endsWith(":token_request") && delete r[l];
|
|
810
811
|
try {
|
|
@@ -812,12 +813,12 @@ const is = function() {
|
|
|
812
813
|
a || (a = e.scope);
|
|
813
814
|
const h = e.extras ? { ...e.extras, ...r } : r;
|
|
814
815
|
h.nonce || (h.nonce = Z(12));
|
|
815
|
-
const y = { nonce: h.nonce }, _ = await E(e,
|
|
816
|
+
const y = { nonce: h.nonce }, _ = await E(e, n), g = await t(e.authority, e.authority_configuration);
|
|
816
817
|
let w;
|
|
817
818
|
if (_)
|
|
818
819
|
_.setLoginParams({ callbackPath: d, extras: u }), await _.initAsync(g, "loginAsync", e), await _.setNonceAsync(y), _.startKeepAliveServiceWorker(), w = _;
|
|
819
820
|
else {
|
|
820
|
-
const T = I(
|
|
821
|
+
const T = I(n, e.storage ?? sessionStorage);
|
|
821
822
|
T.setLoginParams({ callbackPath: d, extras: u }), await T.setNonceAsync(y), w = T;
|
|
822
823
|
}
|
|
823
824
|
const v = {
|
|
@@ -827,20 +828,20 @@ const is = function() {
|
|
|
827
828
|
response_type: "code",
|
|
828
829
|
...h
|
|
829
830
|
};
|
|
830
|
-
await
|
|
831
|
+
await nn(w, o)(g.authorizationEndpoint, v);
|
|
831
832
|
} catch (l) {
|
|
832
|
-
throw
|
|
833
|
+
throw s(m.loginAsync_error, l), l;
|
|
833
834
|
}
|
|
834
835
|
})();
|
|
835
|
-
},
|
|
836
|
+
}, ln = (n) => async (e = !1) => {
|
|
836
837
|
try {
|
|
837
|
-
|
|
838
|
-
const
|
|
838
|
+
n.publishEvent(m.loginCallbackAsync_begin, {});
|
|
839
|
+
const s = n.configuration, t = s.client_id, o = e ? s.silent_redirect_uri : s.redirect_uri, i = s.authority, r = s.token_request_timeout, c = await n.initAsync(i, s.authority_configuration), a = n.location.getCurrentHref(), f = H(a).session_state, d = await E(s, n.configurationName);
|
|
839
840
|
let l, h, y, _;
|
|
840
841
|
if (d)
|
|
841
|
-
await d.initAsync(c, "loginCallbackAsync",
|
|
842
|
+
await d.initAsync(c, "loginCallbackAsync", s), await d.setSessionStateAsync(f), h = await d.getNonceAsync(), y = d.getLoginParams(), _ = await d.getStateAsync(), d.startKeepAliveServiceWorker(), l = d;
|
|
842
843
|
else {
|
|
843
|
-
const S = I(
|
|
844
|
+
const S = I(n.configurationName, s.storage ?? sessionStorage);
|
|
844
845
|
await S.setSessionStateAsync(f), h = await S.getNonceAsync(), y = S.getLoginParams(), _ = await S.getStateAsync(), l = S;
|
|
845
846
|
}
|
|
846
847
|
const g = H(a);
|
|
@@ -851,25 +852,25 @@ const is = function() {
|
|
|
851
852
|
const w = {
|
|
852
853
|
code: g.code,
|
|
853
854
|
grant_type: "authorization_code",
|
|
854
|
-
client_id:
|
|
855
|
+
client_id: s.client_id,
|
|
855
856
|
redirect_uri: o
|
|
856
857
|
}, v = {};
|
|
857
|
-
if (
|
|
858
|
-
for (const [S, W] of Object.entries(
|
|
858
|
+
if (s.token_request_extras)
|
|
859
|
+
for (const [S, W] of Object.entries(s.token_request_extras))
|
|
859
860
|
v[S] = W;
|
|
860
861
|
if (y && y.extras)
|
|
861
862
|
for (const [S, W] of Object.entries(y.extras))
|
|
862
863
|
S.endsWith(":token_request") && (v[S.replace(":token_request", "")] = W);
|
|
863
864
|
const T = c.tokenEndpoint, F = {};
|
|
864
|
-
if (
|
|
865
|
-
const S = await
|
|
866
|
-
d ? await d.setDemonstratingProofOfPossessionJwkAsync(S) : await I(
|
|
865
|
+
if (s.demonstrating_proof_of_possession) {
|
|
866
|
+
const S = await an();
|
|
867
|
+
d ? await d.setDemonstratingProofOfPossessionJwkAsync(S) : await I(n.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(S), F.DPoP = await Oe(S, "POST", T);
|
|
867
868
|
}
|
|
868
|
-
const p = await
|
|
869
|
+
const p = await sn(l)(
|
|
869
870
|
T,
|
|
870
871
|
{ ...w, ...v },
|
|
871
872
|
F,
|
|
872
|
-
|
|
873
|
+
n.configuration.token_renew_mode,
|
|
873
874
|
r
|
|
874
875
|
);
|
|
875
876
|
if (!p.success)
|
|
@@ -888,44 +889,44 @@ const is = function() {
|
|
|
888
889
|
throw new Error("Demonstration of proof of possession require Access token not hidden by service worker");
|
|
889
890
|
}
|
|
890
891
|
if (d)
|
|
891
|
-
await d.initAsync(o, "syncTokensAsync",
|
|
892
|
+
await d.initAsync(o, "syncTokensAsync", s), k = d.getLoginParams(), O && await d.setDemonstratingProofOfPossessionNonce(O);
|
|
892
893
|
else {
|
|
893
|
-
const S = I(
|
|
894
|
+
const S = I(n.configurationName, s.storage);
|
|
894
895
|
k = S.getLoginParams(), O && await S.setDemonstratingProofOfPossessionNonce(O);
|
|
895
896
|
}
|
|
896
|
-
return await
|
|
897
|
+
return await n.startCheckSessionAsync(c.checkSessionIframe, t, f, e), n.publishEvent(m.loginCallbackAsync_end, {}), {
|
|
897
898
|
tokens: A,
|
|
898
899
|
state: "request.state",
|
|
899
900
|
callbackPath: k.callbackPath
|
|
900
901
|
};
|
|
901
|
-
} catch (
|
|
902
|
-
throw console.error(
|
|
902
|
+
} catch (s) {
|
|
903
|
+
throw console.error(s), n.publishEvent(m.loginCallbackAsync_error, s), s;
|
|
903
904
|
}
|
|
904
|
-
},
|
|
905
|
+
}, ye = {
|
|
905
906
|
access_token: "access_token",
|
|
906
907
|
refresh_token: "refresh_token"
|
|
907
|
-
},
|
|
908
|
-
M.clearTimeout(
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
},
|
|
912
|
-
const c =
|
|
908
|
+
}, un = (n) => async (e) => {
|
|
909
|
+
M.clearTimeout(n.timeoutId), n.timeoutId = null, n.checkSessionIFrame && n.checkSessionIFrame.stop();
|
|
910
|
+
const s = await E(n.configuration, n.configurationName);
|
|
911
|
+
s ? await s.clearAsync(e) : await I(n.configurationName, n.configuration.storage).clearAsync(e), n.tokens = null, n.userInfo = null;
|
|
912
|
+
}, dn = (n, e, s, t, o) => async (i = void 0, r = null) => {
|
|
913
|
+
const c = n.configuration, a = await n.initAsync(c.authority, c.authority_configuration);
|
|
913
914
|
i && typeof i != "string" && (i = void 0, t.warn("callbackPathOrUrl path is not a string"));
|
|
914
915
|
const u = i ?? o.getPath();
|
|
915
916
|
let f = !1;
|
|
916
917
|
i && (f = i.includes("https://") || i.includes("http://"));
|
|
917
|
-
const d = f ? i : o.getOrigin() + u, l =
|
|
918
|
+
const d = f ? i : o.getOrigin() + u, l = n.tokens ? n.tokens.idToken : "";
|
|
918
919
|
try {
|
|
919
920
|
const y = a.revocationEndpoint;
|
|
920
921
|
if (y) {
|
|
921
|
-
const _ = [], g =
|
|
922
|
-
if (g && c.logout_tokens_to_invalidate.includes(
|
|
923
|
-
const v =
|
|
922
|
+
const _ = [], g = n.tokens ? n.tokens.accessToken : null;
|
|
923
|
+
if (g && c.logout_tokens_to_invalidate.includes(ye.access_token)) {
|
|
924
|
+
const v = he(s)(y, g, ee.access_token, c.client_id);
|
|
924
925
|
_.push(v);
|
|
925
926
|
}
|
|
926
|
-
const w =
|
|
927
|
-
if (w && c.logout_tokens_to_invalidate.includes(
|
|
928
|
-
const v =
|
|
927
|
+
const w = n.tokens ? n.tokens.refreshToken : null;
|
|
928
|
+
if (w && c.logout_tokens_to_invalidate.includes(ye.refresh_token)) {
|
|
929
|
+
const v = he(s)(y, w, ee.refresh_token, c.client_id);
|
|
929
930
|
_.push(v);
|
|
930
931
|
}
|
|
931
932
|
_.length > 0 && await Promise.all(_);
|
|
@@ -933,10 +934,10 @@ const is = function() {
|
|
|
933
934
|
} catch (y) {
|
|
934
935
|
t.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), t.warn(y);
|
|
935
936
|
}
|
|
936
|
-
const h =
|
|
937
|
-
await
|
|
937
|
+
const h = n.tokens && n.tokens.idTokenPayload ? n.tokens.idTokenPayload.sub : null;
|
|
938
|
+
await n.destroyAsync("LOGGED_OUT");
|
|
938
939
|
for (const [y, _] of Object.entries(e))
|
|
939
|
-
_ !==
|
|
940
|
+
_ !== n && await n.logoutSameTabAsync(n.configuration.client_id, h);
|
|
940
941
|
if (a.endSessionEndpoint) {
|
|
941
942
|
r || (r = {
|
|
942
943
|
id_token_hint: l
|
|
@@ -948,25 +949,25 @@ const is = function() {
|
|
|
948
949
|
o.open(`${a.endSessionEndpoint}${y}`);
|
|
949
950
|
} else
|
|
950
951
|
o.reload();
|
|
951
|
-
},
|
|
952
|
-
if (
|
|
953
|
-
return
|
|
954
|
-
for (;
|
|
952
|
+
}, fn = (n) => async (e = !1) => {
|
|
953
|
+
if (n.userInfo != null && !e)
|
|
954
|
+
return n.userInfo;
|
|
955
|
+
for (; n.tokens && !z(n.tokens); )
|
|
955
956
|
await $({ milliseconds: 200 });
|
|
956
|
-
if (!
|
|
957
|
+
if (!n.tokens)
|
|
957
958
|
return null;
|
|
958
|
-
const
|
|
959
|
-
if (!
|
|
959
|
+
const s = n.tokens.accessToken;
|
|
960
|
+
if (!s)
|
|
960
961
|
return null;
|
|
961
|
-
const t =
|
|
962
|
+
const t = n.configuration, i = (await n.initAsync(t.authority, t.authority_configuration)).userInfoEndpoint, c = await (async (a) => {
|
|
962
963
|
const u = await fetch(i, {
|
|
963
964
|
headers: {
|
|
964
965
|
authorization: `Bearer ${a}`
|
|
965
966
|
}
|
|
966
967
|
});
|
|
967
968
|
return u.status !== 200 ? null : u.json();
|
|
968
|
-
})(
|
|
969
|
-
return
|
|
969
|
+
})(s);
|
|
970
|
+
return n.userInfo = c, c;
|
|
970
971
|
};
|
|
971
972
|
class G {
|
|
972
973
|
open(e) {
|
|
@@ -986,8 +987,8 @@ class G {
|
|
|
986
987
|
return window.origin;
|
|
987
988
|
}
|
|
988
989
|
}
|
|
989
|
-
const
|
|
990
|
-
const e =
|
|
990
|
+
const hn = (n) => !!(n.os === "iOS" && n.osVersion.startsWith("12") || n.os === "Mac OS X" && n.osVersion.startsWith("10_15_6")), _n = (n) => {
|
|
991
|
+
const e = n.appVersion, s = n.userAgent, t = "-";
|
|
991
992
|
let o = t;
|
|
992
993
|
const i = [
|
|
993
994
|
{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
|
|
@@ -1020,7 +1021,7 @@ const fs = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os ===
|
|
|
1020
1021
|
];
|
|
1021
1022
|
for (const c in i) {
|
|
1022
1023
|
const a = i[c];
|
|
1023
|
-
if (a.r.test(
|
|
1024
|
+
if (a.r.test(s)) {
|
|
1024
1025
|
o = a.s;
|
|
1025
1026
|
break;
|
|
1026
1027
|
}
|
|
@@ -1030,11 +1031,11 @@ const fs = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os ===
|
|
|
1030
1031
|
case "Mac OS":
|
|
1031
1032
|
case "Mac OS X":
|
|
1032
1033
|
case "Android":
|
|
1033
|
-
r = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(
|
|
1034
|
+
r = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(s)[1];
|
|
1034
1035
|
break;
|
|
1035
1036
|
case "iOS": {
|
|
1036
1037
|
const c = /OS (\d+)_(\d+)_?(\d+)?/.exec(e);
|
|
1037
|
-
r = c[1] + "." + c[2] + "." + (parseInt(c[3]) | 0);
|
|
1038
|
+
c != null && c.length > 2 && (r = c[1] + "." + c[2] + "." + (parseInt(c[3]) | 0));
|
|
1038
1039
|
break;
|
|
1039
1040
|
}
|
|
1040
1041
|
}
|
|
@@ -1043,41 +1044,41 @@ const fs = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os ===
|
|
|
1043
1044
|
osVersion: r
|
|
1044
1045
|
};
|
|
1045
1046
|
};
|
|
1046
|
-
function
|
|
1047
|
-
const
|
|
1048
|
-
let e,
|
|
1049
|
-
if (/trident/i.test(
|
|
1050
|
-
return e = /\brv[ :]+(\d+)/g.exec(
|
|
1051
|
-
if (
|
|
1047
|
+
function yn() {
|
|
1048
|
+
const n = navigator.userAgent;
|
|
1049
|
+
let e, s = n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1050
|
+
if (/trident/i.test(s[1]))
|
|
1051
|
+
return e = /\brv[ :]+(\d+)/g.exec(n) || [], { name: "ie", version: e[1] || "" };
|
|
1052
|
+
if (s[1] === "Chrome" && (e = n.match(/\bOPR|Edge\/(\d+)/), e != null)) {
|
|
1052
1053
|
let t = e[1];
|
|
1053
1054
|
if (!t) {
|
|
1054
|
-
const o =
|
|
1055
|
+
const o = n.split(e[0] + "/");
|
|
1055
1056
|
o.length > 1 && (t = o[1]);
|
|
1056
1057
|
}
|
|
1057
1058
|
return { name: "opera", version: t };
|
|
1058
1059
|
}
|
|
1059
|
-
return
|
|
1060
|
-
name:
|
|
1061
|
-
version:
|
|
1060
|
+
return s = s[2] ? [s[1], s[2]] : [navigator.appName, navigator.appVersion, "-?"], (e = n.match(/version\/(\d+)/i)) != null && s.splice(1, 1, e[1]), {
|
|
1061
|
+
name: s[0].toLowerCase(),
|
|
1062
|
+
version: s[1]
|
|
1062
1063
|
};
|
|
1063
1064
|
}
|
|
1064
|
-
const
|
|
1065
|
-
const { name:
|
|
1066
|
-
if (
|
|
1065
|
+
const gn = () => {
|
|
1066
|
+
const { name: n, version: e } = yn();
|
|
1067
|
+
if (n === "chrome" && parseInt(e) <= 70 || n === "opera" && (!e || parseInt(e.split(".")[0]) < 80) || n === "ie")
|
|
1067
1068
|
return !1;
|
|
1068
|
-
const
|
|
1069
|
-
return !
|
|
1070
|
-
},
|
|
1071
|
-
class
|
|
1069
|
+
const s = _n(navigator);
|
|
1070
|
+
return !hn(s);
|
|
1071
|
+
}, kn = () => fetch;
|
|
1072
|
+
class ne {
|
|
1072
1073
|
constructor(e) {
|
|
1073
1074
|
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;
|
|
1074
1075
|
}
|
|
1075
1076
|
}
|
|
1076
|
-
const N = {},
|
|
1077
|
-
const { parsedTokens: e, callbackPath:
|
|
1078
|
-
return
|
|
1079
|
-
},
|
|
1080
|
-
constructor(e,
|
|
1077
|
+
const N = {}, mn = (n, e = new G()) => (s, t = "default") => (N[t] || (N[t] = new R(s, t, n, e)), N[t]), pn = async (n) => {
|
|
1078
|
+
const { parsedTokens: e, callbackPath: s } = await n.loginCallbackAsync();
|
|
1079
|
+
return n.timeoutId = K(n, e.refreshToken, e.expiresAt), { callbackPath: s };
|
|
1080
|
+
}, wn = (n) => Math.floor(Math.random() * n), re = class U {
|
|
1081
|
+
constructor(e, s = "default", t, o = new G()) {
|
|
1081
1082
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1082
1083
|
let i = e.silent_login_uri;
|
|
1083
1084
|
e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
@@ -1095,39 +1096,39 @@ const N = {}, ks = (s, e = new G()) => (n, t = "default") => (N[t] || (N[t] = ne
|
|
|
1095
1096
|
authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1096
1097
|
logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
1097
1098
|
service_worker_update_require_callback: c,
|
|
1098
|
-
service_worker_activate: e.service_worker_activate ??
|
|
1099
|
-
}, this.getFetch = t ??
|
|
1099
|
+
service_worker_activate: e.service_worker_activate ?? gn
|
|
1100
|
+
}, this.getFetch = t ?? kn, this.configurationName = s, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.synchroniseTokensAsync.bind(this), 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);
|
|
1100
1101
|
}
|
|
1101
1102
|
subscribeEvents(e) {
|
|
1102
|
-
const
|
|
1103
|
-
return this.events.push({ id:
|
|
1103
|
+
const s = wn(9999999999999).toString();
|
|
1104
|
+
return this.events.push({ id: s, func: e }), s;
|
|
1104
1105
|
}
|
|
1105
1106
|
removeEventSubscription(e) {
|
|
1106
|
-
const
|
|
1107
|
-
this.events =
|
|
1107
|
+
const s = this.events.filter((t) => t.id !== e);
|
|
1108
|
+
this.events = s;
|
|
1108
1109
|
}
|
|
1109
|
-
publishEvent(e,
|
|
1110
|
+
publishEvent(e, s) {
|
|
1110
1111
|
this.events.forEach((t) => {
|
|
1111
|
-
t.func(e,
|
|
1112
|
+
t.func(e, s);
|
|
1112
1113
|
});
|
|
1113
1114
|
}
|
|
1114
1115
|
static get(e = "default") {
|
|
1115
|
-
const
|
|
1116
|
-
if (!Object.prototype.hasOwnProperty.call(N, e) &&
|
|
1116
|
+
const s = typeof process > "u";
|
|
1117
|
+
if (!Object.prototype.hasOwnProperty.call(N, e) && s)
|
|
1117
1118
|
throw Error(`OIDC library does seem initialized.
|
|
1118
1119
|
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> compoment.`);
|
|
1119
1120
|
return N[e];
|
|
1120
1121
|
}
|
|
1121
1122
|
_silentLoginCallbackFromIFrame() {
|
|
1122
1123
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1123
|
-
const e = this.location,
|
|
1124
|
-
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState:
|
|
1124
|
+
const e = this.location, s = H(e.getCurrentHref());
|
|
1125
|
+
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: s.session_state })}`, e.getOrigin());
|
|
1125
1126
|
}
|
|
1126
1127
|
}
|
|
1127
1128
|
_silentLoginErrorCallbackFromIFrame() {
|
|
1128
1129
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1129
|
-
const e = this.location,
|
|
1130
|
-
window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error:
|
|
1130
|
+
const e = this.location, s = H(e.getCurrentHref());
|
|
1131
|
+
window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: s.error })}`, e.getOrigin());
|
|
1131
1132
|
}
|
|
1132
1133
|
}
|
|
1133
1134
|
async silentLoginCallbackAsync() {
|
|
@@ -1137,19 +1138,19 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1137
1138
|
console.error(e), this._silentLoginErrorCallbackFromIFrame();
|
|
1138
1139
|
}
|
|
1139
1140
|
}
|
|
1140
|
-
async initAsync(e,
|
|
1141
|
+
async initAsync(e, s) {
|
|
1141
1142
|
if (this.initPromise !== null)
|
|
1142
1143
|
return this.initPromise;
|
|
1143
1144
|
const t = async () => {
|
|
1144
|
-
if (
|
|
1145
|
-
return new
|
|
1146
|
-
authorization_endpoint:
|
|
1147
|
-
end_session_endpoint:
|
|
1148
|
-
revocation_endpoint:
|
|
1149
|
-
token_endpoint:
|
|
1150
|
-
userinfo_endpoint:
|
|
1151
|
-
check_session_iframe:
|
|
1152
|
-
issuer:
|
|
1145
|
+
if (s != null)
|
|
1146
|
+
return new ne({
|
|
1147
|
+
authorization_endpoint: s.authorization_endpoint,
|
|
1148
|
+
end_session_endpoint: s.end_session_endpoint,
|
|
1149
|
+
revocation_endpoint: s.revocation_endpoint,
|
|
1150
|
+
token_endpoint: s.token_endpoint,
|
|
1151
|
+
userinfo_endpoint: s.userinfo_endpoint,
|
|
1152
|
+
check_session_iframe: s.check_session_iframe,
|
|
1153
|
+
issuer: s.issuer
|
|
1153
1154
|
});
|
|
1154
1155
|
const i = await E(this.configuration, this.configurationName) ? window.localStorage : null;
|
|
1155
1156
|
return await Ze(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, i, this.configuration.authority_timeout_wellknowurl_in_millisecond);
|
|
@@ -1160,19 +1161,19 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1160
1161
|
if (this.tryKeepExistingSessionPromise !== null)
|
|
1161
1162
|
return this.tryKeepExistingSessionPromise;
|
|
1162
1163
|
const e = async () => {
|
|
1163
|
-
let
|
|
1164
|
+
let s;
|
|
1164
1165
|
if (this.tokens != null)
|
|
1165
1166
|
return !1;
|
|
1166
1167
|
this.publishEvent(m.tryKeepExistingSessionAsync_begin, {});
|
|
1167
1168
|
try {
|
|
1168
1169
|
const t = this.configuration, o = await this.initAsync(t.authority, t.authority_configuration);
|
|
1169
|
-
if (
|
|
1170
|
-
const { tokens: i } = await
|
|
1170
|
+
if (s = await E(t, this.configurationName), s) {
|
|
1171
|
+
const { tokens: i } = await s.initAsync(o, "tryKeepExistingSessionAsync", t);
|
|
1171
1172
|
if (i) {
|
|
1172
|
-
|
|
1173
|
-
const r =
|
|
1173
|
+
s.startKeepAliveServiceWorker(), this.tokens = i;
|
|
1174
|
+
const r = s.getLoginParams(this.configurationName);
|
|
1174
1175
|
this.timeoutId = K(this, this.tokens.refreshToken, this.tokens.expiresAt, r.extras);
|
|
1175
|
-
const c = await
|
|
1176
|
+
const c = await s.getSessionStateAsync();
|
|
1176
1177
|
return await this.startCheckSessionAsync(o.check_session_iframe, t.client_id, c), this.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1177
1178
|
success: !0,
|
|
1178
1179
|
message: "tokens inside ServiceWorker are valid"
|
|
@@ -1188,7 +1189,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1188
1189
|
});
|
|
1189
1190
|
const i = I(this.configurationName, t.storage ?? sessionStorage), { tokens: r } = await i.initAsync();
|
|
1190
1191
|
if (r) {
|
|
1191
|
-
this.tokens =
|
|
1192
|
+
this.tokens = se(r, null, t.token_renew_mode);
|
|
1192
1193
|
const c = i.getLoginParams();
|
|
1193
1194
|
this.timeoutId = K(this, r.refreshToken, this.tokens.expiresAt, c.extras);
|
|
1194
1195
|
const a = await i.getSessionStateAsync();
|
|
@@ -1200,38 +1201,38 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1200
1201
|
}
|
|
1201
1202
|
return this.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1202
1203
|
success: !1,
|
|
1203
|
-
message:
|
|
1204
|
+
message: s ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
|
|
1204
1205
|
}), !1;
|
|
1205
1206
|
} catch (t) {
|
|
1206
|
-
return console.error(t),
|
|
1207
|
+
return console.error(t), s && await s.clearAsync(), this.publishEvent(m.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
1207
1208
|
}
|
|
1208
1209
|
};
|
|
1209
|
-
return this.tryKeepExistingSessionPromise = e(), this.tryKeepExistingSessionPromise.then((
|
|
1210
|
+
return this.tryKeepExistingSessionPromise = e(), this.tryKeepExistingSessionPromise.then((s) => (this.tryKeepExistingSessionPromise = null, s));
|
|
1210
1211
|
}
|
|
1211
|
-
async startCheckSessionAsync(e,
|
|
1212
|
-
await Ve(this, N, this.configuration)(e,
|
|
1212
|
+
async startCheckSessionAsync(e, s, t, o = !1) {
|
|
1213
|
+
await Ve(this, N, this.configuration)(e, s, t, o);
|
|
1213
1214
|
}
|
|
1214
|
-
async loginAsync(e = void 0,
|
|
1215
|
-
return this.loginPromise !== null ? this.loginPromise : i ? Ue(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(
|
|
1215
|
+
async loginAsync(e = void 0, s = null, t = !1, o = void 0, i = !1) {
|
|
1216
|
+
return this.loginPromise !== null ? this.loginPromise : i ? Ue(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(s, o) : (this.loginPromise = cn(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(e, s, t, o), this.loginPromise.then((r) => (this.loginPromise = null, r)));
|
|
1216
1217
|
}
|
|
1217
1218
|
async loginCallbackAsync(e = !1) {
|
|
1218
1219
|
if (this.loginCallbackPromise !== null)
|
|
1219
1220
|
return this.loginCallbackPromise;
|
|
1220
|
-
const
|
|
1221
|
-
const t = await
|
|
1221
|
+
const s = async () => {
|
|
1222
|
+
const t = await ln(this)(e), o = t.tokens;
|
|
1222
1223
|
return this.tokens = o, await E(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(U.eventNames.token_aquired, o), { parsedTokens: o, state: t.state, callbackPath: t.callbackPath };
|
|
1223
1224
|
};
|
|
1224
|
-
return this.loginCallbackPromise =
|
|
1225
|
+
return this.loginCallbackPromise = s(), this.loginCallbackPromise.then((t) => (this.loginCallbackPromise = null, t));
|
|
1225
1226
|
}
|
|
1226
|
-
async synchroniseTokensAsync(e,
|
|
1227
|
+
async synchroniseTokensAsync(e, s = 0, t = !1, o = null, i) {
|
|
1227
1228
|
for (; !navigator.onLine && document.hidden; )
|
|
1228
1229
|
await $({ milliseconds: 1e3 }), this.publishEvent(m.refreshTokensAsync, { message: "wait because navigator is offline and hidden" });
|
|
1229
1230
|
let r = 6;
|
|
1230
1231
|
for (; !navigator.onLine && r > 0; )
|
|
1231
1232
|
await $({ milliseconds: 1e3 }), r--, this.publishEvent(m.refreshTokensAsync, { message: `wait because navigator is offline try ${r}` });
|
|
1232
|
-
const a = document.hidden ?
|
|
1233
|
+
const a = document.hidden ? s : s + 1;
|
|
1233
1234
|
o || (o = {});
|
|
1234
|
-
const u = this.configuration, f = (l, h, y = null) =>
|
|
1235
|
+
const u = this.configuration, f = (l, h, y = null) => oe(this.configurationName, this.configuration, this.publishEvent.bind(this))(l, h, y), d = async () => {
|
|
1235
1236
|
try {
|
|
1236
1237
|
let l;
|
|
1237
1238
|
const h = await E(u, this.configurationName);
|
|
@@ -1249,7 +1250,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1249
1250
|
}
|
|
1250
1251
|
return this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent return" }), await this.synchroniseTokensAsync(null, a, t, o, i);
|
|
1251
1252
|
};
|
|
1252
|
-
if (
|
|
1253
|
+
if (s > 4)
|
|
1253
1254
|
return i(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
|
|
1254
1255
|
try {
|
|
1255
1256
|
const { status: l, tokens: h, nonce: y } = await this.syncTokensInfoAsync(u, this.configurationName, this.tokens, t);
|
|
@@ -1265,9 +1266,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1265
1266
|
case "LOGOUT_FROM_ANOTHER_TAB":
|
|
1266
1267
|
return i(null), this.publishEvent(m.logout_from_another_tab, { status: "session syncTokensAsync" }), { tokens: null, status: "LOGGED_OUT" };
|
|
1267
1268
|
case "REQUIRE_SYNC_TOKENS":
|
|
1268
|
-
return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber:
|
|
1269
|
+
return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber: s }), await d();
|
|
1269
1270
|
default: {
|
|
1270
|
-
if (this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber:
|
|
1271
|
+
if (this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber: s }), !e)
|
|
1271
1272
|
return await d();
|
|
1272
1273
|
const _ = u.client_id, g = u.redirect_uri, w = u.authority, T = { ...u.token_request_extras ? u.token_request_extras : {} };
|
|
1273
1274
|
for (const [p, k] of Object.entries(o))
|
|
@@ -1280,7 +1281,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1280
1281
|
refresh_token: h.refreshToken
|
|
1281
1282
|
}, k = await this.initAsync(w, u.authority_configuration), A = document.hidden ? 1e4 : 3e4 * 10, O = k.tokenEndpoint, x = {};
|
|
1282
1283
|
u.demonstrating_proof_of_possession && (x.DPoP = await this.generateDemonstrationOfProofOfPossessionAsync(h.accessToken, O, "POST"));
|
|
1283
|
-
const P = await
|
|
1284
|
+
const P = await en(this.getFetch())(
|
|
1284
1285
|
O,
|
|
1285
1286
|
p,
|
|
1286
1287
|
T,
|
|
@@ -1294,8 +1295,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1294
1295
|
if (!S)
|
|
1295
1296
|
return i(null), this.publishEvent(m.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${W}` }), { tokens: null, status: "SESSION_LOST" };
|
|
1296
1297
|
if (i(P.data), P.demonstratingProofOfPossessionNonce) {
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1298
|
+
const ae = await E(u, this.configurationName);
|
|
1299
|
+
ae ? await ae.setDemonstratingProofOfPossessionNonce(P.demonstratingProofOfPossessionNonce) : await I(this.configurationName, u.storage).setDemonstratingProofOfPossessionNonce(P.demonstratingProofOfPossessionNonce);
|
|
1299
1300
|
}
|
|
1300
1301
|
return this.publishEvent(m.refreshTokensAsync_end, { success: P.success }), this.publishEvent(U.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: P.data, status: "LOGGED_IN" };
|
|
1301
1302
|
} else
|
|
@@ -1310,7 +1311,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1310
1311
|
return console.error(l), this.publishEvent(m.refreshTokensAsync_silent_error, { message: "exception", exception: l.message }), this.synchroniseTokensAsync(e, a, t, o, i);
|
|
1311
1312
|
}
|
|
1312
1313
|
}
|
|
1313
|
-
async generateDemonstrationOfProofOfPossessionAsync(e,
|
|
1314
|
+
async generateDemonstrationOfProofOfPossessionAsync(e, s, t) {
|
|
1314
1315
|
const o = this.configuration, i = { ath: await we(e) }, r = await E(o, this.configurationName);
|
|
1315
1316
|
let c = null, a;
|
|
1316
1317
|
if (r)
|
|
@@ -1319,14 +1320,14 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1319
1320
|
const u = I(this.configurationName, o.storage);
|
|
1320
1321
|
a = await u.getDemonstratingProofOfPossessionJwkAsync(), c = await u.getDemonstratingProofOfPossessionNonce();
|
|
1321
1322
|
}
|
|
1322
|
-
return c && (i.nonce = c), await Oe(a, t,
|
|
1323
|
+
return c && (i.nonce = c), await Oe(a, t, s, i);
|
|
1323
1324
|
}
|
|
1324
|
-
async syncTokensInfoAsync(e,
|
|
1325
|
+
async syncTokensInfoAsync(e, s, t, o = !1) {
|
|
1325
1326
|
const i = { nonce: null };
|
|
1326
1327
|
if (!t)
|
|
1327
1328
|
return { tokens: null, status: "NOT_CONNECTED", nonce: i };
|
|
1328
1329
|
let r = i;
|
|
1329
|
-
const c = await this.initAsync(e.authority, e.authority_configuration), a = await E(e,
|
|
1330
|
+
const c = await this.initAsync(e.authority, e.authority_configuration), a = await E(e, s);
|
|
1330
1331
|
if (a) {
|
|
1331
1332
|
const { status: d, tokens: l } = await a.initAsync(c, "syncTokensAsync", e);
|
|
1332
1333
|
if (d === "LOGGED_OUT")
|
|
@@ -1341,7 +1342,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1341
1342
|
}
|
|
1342
1343
|
r = await a.getNonceAsync();
|
|
1343
1344
|
} else {
|
|
1344
|
-
const d = I(
|
|
1345
|
+
const d = I(s, e.storage ?? sessionStorage), { tokens: l, status: h } = await d.initAsync();
|
|
1345
1346
|
if (l) {
|
|
1346
1347
|
if (h === "SESSIONS_LOST")
|
|
1347
1348
|
return { tokens: null, status: "SESSIONS_LOST", nonce: i };
|
|
@@ -1357,36 +1358,36 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1357
1358
|
return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: f, nonce: r };
|
|
1358
1359
|
}
|
|
1359
1360
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1360
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1361
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = pn(this), this.loginCallbackWithAutoTokensRenewPromise.then((e) => (this.loginCallbackWithAutoTokensRenewPromise = null, e)));
|
|
1361
1362
|
}
|
|
1362
1363
|
userInfoAsync(e = !1) {
|
|
1363
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1364
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = fn(this)(e), this.userInfoPromise.then((s) => (this.userInfoPromise = null, s)));
|
|
1364
1365
|
}
|
|
1365
1366
|
async renewTokensAsync(e = null) {
|
|
1366
1367
|
if (this.renewTokensPromise !== null)
|
|
1367
1368
|
return this.renewTokensPromise;
|
|
1368
1369
|
if (this.timeoutId)
|
|
1369
|
-
return M.clearTimeout(this.timeoutId), this.renewTokensPromise = me(this, this.tokens.refreshToken, !0, e), this.renewTokensPromise.then((
|
|
1370
|
+
return M.clearTimeout(this.timeoutId), this.renewTokensPromise = me(this, this.tokens.refreshToken, !0, e), this.renewTokensPromise.then((s) => (this.renewTokensPromise = null, s));
|
|
1370
1371
|
}
|
|
1371
1372
|
async destroyAsync(e) {
|
|
1372
|
-
return await
|
|
1373
|
+
return await un(this)(e);
|
|
1373
1374
|
}
|
|
1374
|
-
async logoutSameTabAsync(e,
|
|
1375
|
-
this.configuration.monitor_session && this.configuration.client_id === e &&
|
|
1375
|
+
async logoutSameTabAsync(e, s) {
|
|
1376
|
+
this.configuration.monitor_session && this.configuration.client_id === e && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (this.publishEvent(m.logout_from_same_tab, { message: s }), await this.destroyAsync("LOGGED_OUT"));
|
|
1376
1377
|
}
|
|
1377
|
-
async logoutOtherTabAsync(e,
|
|
1378
|
-
this.configuration.monitor_session && this.configuration.client_id === e &&
|
|
1378
|
+
async logoutOtherTabAsync(e, s) {
|
|
1379
|
+
this.configuration.monitor_session && this.configuration.client_id === e && s && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === s && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: s }));
|
|
1379
1380
|
}
|
|
1380
|
-
async logoutAsync(e = void 0,
|
|
1381
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1381
|
+
async logoutAsync(e = void 0, s = null) {
|
|
1382
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = dn(this, N, this.getFetch(), console, this.location)(e, s), this.logoutPromise.then((t) => (this.logoutPromise = null, t)));
|
|
1382
1383
|
}
|
|
1383
1384
|
};
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
let R =
|
|
1387
|
-
const
|
|
1385
|
+
re.getOrCreate = (n, e) => (s, t = "default") => mn(n, e)(s, t);
|
|
1386
|
+
re.eventNames = m;
|
|
1387
|
+
let R = re;
|
|
1388
|
+
const An = (n, e) => async (...s) => {
|
|
1388
1389
|
var l;
|
|
1389
|
-
const [t, o, ...i] =
|
|
1390
|
+
const [t, o, ...i] = s, r = o ? { ...o } : { method: "GET" };
|
|
1390
1391
|
let c = new Headers();
|
|
1391
1392
|
r.headers && (c = r.headers instanceof Headers ? r.headers : new Headers(r.headers));
|
|
1392
1393
|
const a = e, u = await a.getValidTokenAsync(), f = (l = u == null ? void 0 : u.tokens) == null ? void 0 : l.accessToken;
|
|
@@ -1399,7 +1400,7 @@ const ws = (s, e) => async (...n) => {
|
|
|
1399
1400
|
r.credentials || (r.credentials = "same-origin");
|
|
1400
1401
|
}
|
|
1401
1402
|
const d = { ...r, headers: c };
|
|
1402
|
-
return await
|
|
1403
|
+
return await n(t, d, ...i);
|
|
1403
1404
|
}, X = class Ee {
|
|
1404
1405
|
constructor(e) {
|
|
1405
1406
|
this._oidc = e;
|
|
@@ -1410,8 +1411,8 @@ const ws = (s, e) => async (...n) => {
|
|
|
1410
1411
|
removeEventSubscription(e) {
|
|
1411
1412
|
this._oidc.removeEventSubscription(e);
|
|
1412
1413
|
}
|
|
1413
|
-
publishEvent(e,
|
|
1414
|
-
this._oidc.publishEvent(e,
|
|
1414
|
+
publishEvent(e, s) {
|
|
1415
|
+
this._oidc.publishEvent(e, s);
|
|
1415
1416
|
}
|
|
1416
1417
|
static get(e = "default") {
|
|
1417
1418
|
return new Ee(R.get(e));
|
|
@@ -1419,11 +1420,11 @@ const ws = (s, e) => async (...n) => {
|
|
|
1419
1420
|
tryKeepExistingSessionAsync() {
|
|
1420
1421
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
1421
1422
|
}
|
|
1422
|
-
loginAsync(e = void 0,
|
|
1423
|
-
return this._oidc.loginAsync(e,
|
|
1423
|
+
loginAsync(e = void 0, s = null, t = !1, o = void 0, i = !1) {
|
|
1424
|
+
return this._oidc.loginAsync(e, s, t, o, i);
|
|
1424
1425
|
}
|
|
1425
|
-
logoutAsync(e = void 0,
|
|
1426
|
-
return this._oidc.logoutAsync(e,
|
|
1426
|
+
logoutAsync(e = void 0, s = null) {
|
|
1427
|
+
return this._oidc.logoutAsync(e, s);
|
|
1427
1428
|
}
|
|
1428
1429
|
silentLoginCallbackAsync() {
|
|
1429
1430
|
return this._oidc.silentLoginCallbackAsync();
|
|
@@ -1440,27 +1441,27 @@ const ws = (s, e) => async (...n) => {
|
|
|
1440
1441
|
get configuration() {
|
|
1441
1442
|
return this._oidc.configuration;
|
|
1442
1443
|
}
|
|
1443
|
-
async generateDemonstrationOfProofOfPossessionAsync(e,
|
|
1444
|
-
return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e,
|
|
1444
|
+
async generateDemonstrationOfProofOfPossessionAsync(e, s, t) {
|
|
1445
|
+
return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e, s, t);
|
|
1445
1446
|
}
|
|
1446
|
-
async getValidTokenAsync(e = 200,
|
|
1447
|
-
return Le(this._oidc, e,
|
|
1447
|
+
async getValidTokenAsync(e = 200, s = 50) {
|
|
1448
|
+
return Le(this._oidc, e, s);
|
|
1448
1449
|
}
|
|
1449
1450
|
fetchWithTokens(e) {
|
|
1450
|
-
return
|
|
1451
|
+
return An(e, this);
|
|
1451
1452
|
}
|
|
1452
1453
|
async userInfoAsync(e = !1) {
|
|
1453
1454
|
return this._oidc.userInfoAsync(e);
|
|
1454
1455
|
}
|
|
1455
1456
|
};
|
|
1456
|
-
X.getOrCreate = (
|
|
1457
|
+
X.getOrCreate = (n, e = new G()) => (s, t = "default") => new X(R.getOrCreate(n, e)(s, t));
|
|
1457
1458
|
X.eventNames = R.eventNames;
|
|
1458
|
-
let
|
|
1459
|
+
let Tn = X;
|
|
1459
1460
|
export {
|
|
1460
|
-
|
|
1461
|
+
Tn as OidcClient,
|
|
1461
1462
|
G as OidcLocation,
|
|
1462
1463
|
Y as TokenRenewMode,
|
|
1463
|
-
|
|
1464
|
+
kn as getFetchDefault,
|
|
1464
1465
|
H as getParseQueryStringFromLocation,
|
|
1465
|
-
|
|
1466
|
+
Sn as getPath
|
|
1466
1467
|
};
|