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