@axa-fr/oidc-client 7.22.14 → 7.22.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +452 -443
- package/dist/index.umd.cjs +2 -2
- package/dist/oidc.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/oidc.ts +5 -2
- package/src/renewTokens.ts +14 -2
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
const D = console;
|
|
2
2
|
class Pe {
|
|
3
|
-
constructor(
|
|
4
|
-
this._callback =
|
|
3
|
+
constructor(s, n, t, o = 2e3, i = !0) {
|
|
4
|
+
this._callback = s, this._client_id = n, this._url = t, this._interval = o || 2e3, this._stopOnError = i;
|
|
5
5
|
const r = t.indexOf("/", t.indexOf("//") + 2);
|
|
6
6
|
this._frame_origin = t.substr(0, r), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = t;
|
|
7
7
|
}
|
|
8
8
|
load() {
|
|
9
|
-
return new Promise((
|
|
9
|
+
return new Promise((s) => {
|
|
10
10
|
this._frame.onload = () => {
|
|
11
|
-
|
|
11
|
+
s();
|
|
12
12
|
}, window.document.body.appendChild(this._frame), this._boundMessageEvent = this._message.bind(this), window.addEventListener("message", this._boundMessageEvent, !1);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
_message(
|
|
16
|
-
|
|
15
|
+
_message(s) {
|
|
16
|
+
s.origin === this._frame_origin && s.source === this._frame.contentWindow && (s.data === "error" ? (D.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : s.data === "changed" ? (D.debug(s), D.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : D.debug("CheckSessionIFrame: " + s.data + " message from check session op iframe"));
|
|
17
17
|
}
|
|
18
|
-
start(
|
|
19
|
-
D.debug("CheckSessionIFrame.start :" +
|
|
20
|
-
const
|
|
21
|
-
this._frame.contentWindow.postMessage(this._client_id + " " +
|
|
18
|
+
start(s) {
|
|
19
|
+
D.debug("CheckSessionIFrame.start :" + s), this.stop();
|
|
20
|
+
const n = () => {
|
|
21
|
+
this._frame.contentWindow.postMessage(this._client_id + " " + s, this._frame_origin);
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
n(), this._timer = window.setInterval(n, this._interval);
|
|
24
24
|
}
|
|
25
25
|
stop() {
|
|
26
26
|
this._timer && (D.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
|
|
@@ -55,26 +55,26 @@ const m = {
|
|
|
55
55
|
syncTokensAsync_end: "syncTokensAsync_end",
|
|
56
56
|
syncTokensAsync_error: "syncTokensAsync_error",
|
|
57
57
|
tokensInvalidAndWaitingActionsToRefresh: "tokensInvalidAndWaitingActionsToRefresh"
|
|
58
|
-
}, O = (e,
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
61
|
-
return
|
|
62
|
-
const h = JSON.parse(
|
|
58
|
+
}, O = (e, s = sessionStorage) => {
|
|
59
|
+
const n = (h) => (s[`oidc.${e}`] = JSON.stringify({ tokens: null, status: h }), Promise.resolve()), t = async () => {
|
|
60
|
+
if (!s[`oidc.${e}`])
|
|
61
|
+
return s[`oidc.${e}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
|
|
62
|
+
const h = JSON.parse(s[`oidc.${e}`]);
|
|
63
63
|
return Promise.resolve({ tokens: h.tokens, status: h.status });
|
|
64
64
|
}, o = (h) => {
|
|
65
|
-
|
|
65
|
+
s[`oidc.${e}`] = JSON.stringify({ tokens: h });
|
|
66
66
|
}, i = async (h) => {
|
|
67
|
-
|
|
68
|
-
}, r = async () =>
|
|
69
|
-
|
|
67
|
+
s[`oidc.session_state.${e}`] = h;
|
|
68
|
+
}, r = async () => s[`oidc.session_state.${e}`], a = (h) => {
|
|
69
|
+
s[`oidc.nonce.${e}`] = h.nonce;
|
|
70
70
|
}, l = (h) => {
|
|
71
|
-
|
|
72
|
-
}, f = () => JSON.parse(
|
|
73
|
-
|
|
74
|
-
}, _ = () =>
|
|
71
|
+
s[`oidc.jwk.${e}`] = JSON.stringify(h);
|
|
72
|
+
}, f = () => JSON.parse(s[`oidc.jwk.${e}`]), u = async () => ({ nonce: s[`oidc.nonce.${e}`] }), c = async (h) => {
|
|
73
|
+
s[`oidc.dpop_nonce.${e}`] = h;
|
|
74
|
+
}, _ = () => s[`oidc.dpop_nonce.${e}`], y = () => s[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(s[`oidc.${e}`]).tokens }) : null;
|
|
75
75
|
let g = {};
|
|
76
76
|
return {
|
|
77
|
-
clearAsync:
|
|
77
|
+
clearAsync: n,
|
|
78
78
|
initAsync: t,
|
|
79
79
|
setTokens: o,
|
|
80
80
|
getTokens: y,
|
|
@@ -83,19 +83,19 @@ const m = {
|
|
|
83
83
|
setNonceAsync: a,
|
|
84
84
|
getNonceAsync: u,
|
|
85
85
|
setLoginParams: (h) => {
|
|
86
|
-
g[e] = h,
|
|
86
|
+
g[e] = h, s[`oidc.login.${e}`] = JSON.stringify(h);
|
|
87
87
|
},
|
|
88
88
|
getLoginParams: () => {
|
|
89
|
-
const h =
|
|
89
|
+
const h = s[`oidc.login.${e}`];
|
|
90
90
|
return h ? (g[e] || (g[e] = JSON.parse(h)), g[e]) : (console.warn(`storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`), null);
|
|
91
91
|
},
|
|
92
|
-
getStateAsync: async () =>
|
|
92
|
+
getStateAsync: async () => s[`oidc.state.${e}`],
|
|
93
93
|
setStateAsync: async (h) => {
|
|
94
|
-
|
|
94
|
+
s[`oidc.state.${e}`] = h;
|
|
95
95
|
},
|
|
96
|
-
getCodeVerifierAsync: async () =>
|
|
96
|
+
getCodeVerifierAsync: async () => s[`oidc.code_verifier.${e}`],
|
|
97
97
|
setCodeVerifierAsync: async (h) => {
|
|
98
|
-
|
|
98
|
+
s[`oidc.code_verifier.${e}`] = h;
|
|
99
99
|
},
|
|
100
100
|
setDemonstratingProofOfPossessionNonce: c,
|
|
101
101
|
getDemonstratingProofOfPossessionNonce: _,
|
|
@@ -104,45 +104,45 @@ const m = {
|
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
var V = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(V || {});
|
|
107
|
-
const Oe = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (
|
|
107
|
+
const Oe = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (s) => "%" + ("00" + s.charCodeAt(0).toString(16)).slice(-2)).join("")), Ie = (e) => JSON.parse(Oe(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), ae = (e) => {
|
|
108
108
|
try {
|
|
109
109
|
return e && Ce(e, ".") === 2 ? Ie(e.split(".")[1]) : null;
|
|
110
|
-
} catch (
|
|
111
|
-
console.warn(
|
|
110
|
+
} catch (s) {
|
|
111
|
+
console.warn(s);
|
|
112
112
|
}
|
|
113
113
|
return null;
|
|
114
|
-
}, Ce = (e,
|
|
114
|
+
}, Ce = (e, s) => e.split(s).length - 1, Z = {
|
|
115
115
|
access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
|
|
116
116
|
access_token_invalid: "access_token_invalid",
|
|
117
117
|
id_token_invalid: "id_token_invalid"
|
|
118
118
|
};
|
|
119
|
-
function Ne(e,
|
|
119
|
+
function Ne(e, s, n) {
|
|
120
120
|
if (e.issuedAt) {
|
|
121
121
|
if (typeof e.issuedAt == "string")
|
|
122
122
|
return parseInt(e.issuedAt, 10);
|
|
123
123
|
} else
|
|
124
|
-
return
|
|
124
|
+
return s && s.iat ? s.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
125
125
|
return e.issuedAt;
|
|
126
126
|
}
|
|
127
|
-
const X = (e,
|
|
127
|
+
const X = (e, s = null, n) => {
|
|
128
128
|
if (!e)
|
|
129
129
|
return null;
|
|
130
130
|
let t;
|
|
131
131
|
const o = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
|
|
132
132
|
e.accessTokenPayload !== void 0 ? t = e.accessTokenPayload : t = ae(e.accessToken);
|
|
133
133
|
let i;
|
|
134
|
-
|
|
134
|
+
s != null && "idToken" in s && !("idToken" in e) ? i = s.idToken : i = e.idToken;
|
|
135
135
|
const r = e.idTokenPayload ? e.idTokenPayload : ae(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, l = t && t.exp ? t.exp : e.issuedAt + o;
|
|
136
136
|
e.issuedAt = Ne(e, t, r);
|
|
137
137
|
let f;
|
|
138
|
-
e.expiresAt ? f = e.expiresAt :
|
|
138
|
+
e.expiresAt ? f = e.expiresAt : n === Z.access_token_invalid ? f = l : n === Z.id_token_invalid ? f = a : f = a < l ? a : l;
|
|
139
139
|
const u = { ...e, idTokenPayload: r, accessTokenPayload: t, expiresAt: f, idToken: i };
|
|
140
|
-
if (
|
|
141
|
-
const c =
|
|
140
|
+
if (s != null && "refreshToken" in s && !("refreshToken" in e)) {
|
|
141
|
+
const c = s.refreshToken;
|
|
142
142
|
return { ...u, refreshToken: c };
|
|
143
143
|
}
|
|
144
144
|
return u;
|
|
145
|
-
}, oe = (e,
|
|
145
|
+
}, oe = (e, s, n) => {
|
|
146
146
|
if (!e)
|
|
147
147
|
return null;
|
|
148
148
|
if (!e.issued_at) {
|
|
@@ -157,12 +157,12 @@ const X = (e, n = null, s) => {
|
|
|
157
157
|
tokenType: e.token_type,
|
|
158
158
|
issuedAt: e.issued_at
|
|
159
159
|
};
|
|
160
|
-
return "refresh_token" in e && (t.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (t.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (t.idTokenPayload = e.idTokenPayload), X(t,
|
|
161
|
-
}, U = (e,
|
|
162
|
-
const
|
|
160
|
+
return "refresh_token" in e && (t.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (t.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (t.idTokenPayload = e.idTokenPayload), X(t, s, n);
|
|
161
|
+
}, U = (e, s) => {
|
|
162
|
+
const n = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = s - n;
|
|
163
163
|
return Math.round(t - e);
|
|
164
|
-
}, ce = (e) => e ? U(0, e.expiresAt) > 0 : !1, ge = async (e,
|
|
165
|
-
let t =
|
|
164
|
+
}, ce = (e) => e ? U(0, e.expiresAt) > 0 : !1, ge = async (e, s = 200, n = 50) => {
|
|
165
|
+
let t = n;
|
|
166
166
|
if (!e.tokens)
|
|
167
167
|
return null;
|
|
168
168
|
for (; !ce(e.tokens) && t > 0; ) {
|
|
@@ -170,27 +170,27 @@ const X = (e, n = null, s) => {
|
|
|
170
170
|
await e.renewTokensAsync({});
|
|
171
171
|
break;
|
|
172
172
|
} else
|
|
173
|
-
await z({ milliseconds:
|
|
173
|
+
await z({ milliseconds: s });
|
|
174
174
|
t = t - 1;
|
|
175
175
|
}
|
|
176
176
|
return {
|
|
177
177
|
isTokensValid: ce(e.tokens),
|
|
178
178
|
tokens: e.tokens,
|
|
179
|
-
numberWaited: t -
|
|
179
|
+
numberWaited: t - n
|
|
180
180
|
};
|
|
181
|
-
}, ke = (e,
|
|
181
|
+
}, ke = (e, s, n) => {
|
|
182
182
|
if (e.idTokenPayload) {
|
|
183
183
|
const t = e.idTokenPayload;
|
|
184
|
-
if (
|
|
185
|
-
return { isValid: !1, reason: `Issuer does not match (oidcServerConfiguration issuer) ${
|
|
184
|
+
if (n.issuer !== t.iss)
|
|
185
|
+
return { isValid: !1, reason: `Issuer does not match (oidcServerConfiguration issuer) ${n.issuer} !== (idTokenPayload issuer) ${t.iss}` };
|
|
186
186
|
const o = (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
187
187
|
if (t.exp && t.exp < o)
|
|
188
188
|
return { isValid: !1, reason: `Token expired (idTokenPayload exp) ${t.exp} < (currentTimeUnixSecond) ${o}` };
|
|
189
189
|
const i = 60 * 60 * 24 * 7;
|
|
190
190
|
if (t.iat && t.iat + i < o)
|
|
191
191
|
return { isValid: !1, reason: `Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${t.iat + i} < (currentTimeUnixSecond) ${o}` };
|
|
192
|
-
if (t.nonce && t.nonce !==
|
|
193
|
-
return { isValid: !1, reason: `Nonce does not match (idTokenPayload nonce) ${t.nonce} !== (nonce) ${
|
|
192
|
+
if (t.nonce && t.nonce !== s)
|
|
193
|
+
return { isValid: !1, reason: `Nonce does not match (idTokenPayload nonce) ${t.nonce} !== (nonce) ${s}` };
|
|
194
194
|
}
|
|
195
195
|
return { isValid: !0, reason: "" };
|
|
196
196
|
}, M = function() {
|
|
@@ -201,15 +201,15 @@ const X = (e, n = null, s) => {
|
|
|
201
201
|
setInterval: setInterval.bind(e),
|
|
202
202
|
clearInterval: clearInterval.bind(e)
|
|
203
203
|
};
|
|
204
|
-
}(), le = "7.22.
|
|
204
|
+
}(), le = "7.22.16";
|
|
205
205
|
let ue = null, q;
|
|
206
|
-
const z = ({ milliseconds: e }) => new Promise((
|
|
206
|
+
const z = ({ milliseconds: e }) => new Promise((s) => M.setTimeout(s, e)), me = (e = "/") => {
|
|
207
207
|
try {
|
|
208
208
|
q = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((t) => {
|
|
209
209
|
console.log(t);
|
|
210
210
|
}), z({ milliseconds: 150 * 1e3 }).then(me);
|
|
211
|
-
} catch (
|
|
212
|
-
console.log(
|
|
211
|
+
} catch (s) {
|
|
212
|
+
console.log(s);
|
|
213
213
|
}
|
|
214
214
|
}, xe = () => {
|
|
215
215
|
q && q.abort();
|
|
@@ -217,29 +217,29 @@ const z = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), me =
|
|
|
217
217
|
headers: {
|
|
218
218
|
"oidc-vanilla": "true"
|
|
219
219
|
}
|
|
220
|
-
}).then((
|
|
221
|
-
console.log(
|
|
222
|
-
}), Le = (e) => async (
|
|
223
|
-
|
|
224
|
-
const t = await
|
|
220
|
+
}).then((s) => s.statusText === "oidc-service-worker").catch((s) => {
|
|
221
|
+
console.log(s);
|
|
222
|
+
}), Le = (e) => async (s, n) => {
|
|
223
|
+
n(), await s.update();
|
|
224
|
+
const t = await s.unregister();
|
|
225
225
|
console.log(`Service worker unregistering ${t}`), await z({ milliseconds: 2e3 }), e.reload();
|
|
226
|
-
}, P = (e) => (
|
|
226
|
+
}, P = (e) => (s) => new Promise(function(n, t) {
|
|
227
227
|
const o = new MessageChannel();
|
|
228
228
|
o.port1.onmessage = function(i) {
|
|
229
|
-
i.data && i.data.error ? t(i.data.error) :
|
|
230
|
-
}, e.active.postMessage(
|
|
231
|
-
}), I = async (e,
|
|
232
|
-
const
|
|
233
|
-
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !
|
|
229
|
+
i.data && i.data.error ? t(i.data.error) : n(i.data), o.port1.close(), o.port2.close();
|
|
230
|
+
}, e.active.postMessage(s, [o.port2]);
|
|
231
|
+
}), I = async (e, s) => {
|
|
232
|
+
const n = e.service_worker_relative_url;
|
|
233
|
+
if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1)
|
|
234
234
|
return null;
|
|
235
235
|
let t = null;
|
|
236
|
-
e.register ? t = await e.service_worker_register(
|
|
236
|
+
e.register ? t = await e.service_worker_register(n) : t = await navigator.serviceWorker.register(n);
|
|
237
237
|
try {
|
|
238
238
|
await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await P(t)({ type: "claim" });
|
|
239
239
|
} catch {
|
|
240
240
|
return null;
|
|
241
241
|
}
|
|
242
|
-
const o = async (d) => P(t)({ type: "clear", data: { status: d }, configurationName:
|
|
242
|
+
const o = async (d) => P(t)({ type: "clear", data: { status: d }, configurationName: s }), i = async (d, A, v) => {
|
|
243
243
|
const W = await P(t)({
|
|
244
244
|
type: "init",
|
|
245
245
|
data: {
|
|
@@ -250,14 +250,14 @@ const z = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), me =
|
|
|
250
250
|
service_worker_convert_all_requests_to_cors: v.service_worker_convert_all_requests_to_cors
|
|
251
251
|
}
|
|
252
252
|
},
|
|
253
|
-
configurationName:
|
|
253
|
+
configurationName: s
|
|
254
254
|
}), L = W.version;
|
|
255
255
|
return L !== le && (console.warn(`Service worker ${L} version mismatch with js client version ${le}, unregistering and reloading`), await v.service_worker_update_require_callback(t, xe)), { tokens: oe(W.tokens, null, v.token_renew_mode), status: W.status };
|
|
256
256
|
}, r = (d = "/") => {
|
|
257
257
|
ue == null && (ue = "not_null", me(d));
|
|
258
|
-
}, a = (d) => P(t)({ type: "setSessionState", data: { sessionState: d }, configurationName:
|
|
259
|
-
let A = (await P(t)({ type: "getNonce", data: null, configurationName:
|
|
260
|
-
return A || (A = sessionStorage[`oidc.nonce.${
|
|
258
|
+
}, a = (d) => P(t)({ type: "setSessionState", data: { sessionState: d }, configurationName: s }), l = async () => (await P(t)({ type: "getSessionState", data: null, configurationName: s })).sessionState, f = (d) => (sessionStorage[`oidc.nonce.${s}`] = d.nonce, P(t)({ type: "setNonce", data: { nonce: d }, configurationName: s })), u = async () => {
|
|
259
|
+
let A = (await P(t)({ type: "getNonce", data: null, configurationName: s })).nonce;
|
|
260
|
+
return A || (A = sessionStorage[`oidc.nonce.${s}`], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: A };
|
|
261
261
|
};
|
|
262
262
|
let c = {};
|
|
263
263
|
return {
|
|
@@ -270,45 +270,45 @@ const z = ({ milliseconds: e }) => new Promise((n) => M.setTimeout(n, e)), me =
|
|
|
270
270
|
setNonceAsync: f,
|
|
271
271
|
getNonceAsync: u,
|
|
272
272
|
setLoginParams: (d) => {
|
|
273
|
-
c[
|
|
273
|
+
c[s] = d, localStorage[`oidc.login.${s}`] = JSON.stringify(d);
|
|
274
274
|
},
|
|
275
275
|
getLoginParams: () => {
|
|
276
|
-
const d = localStorage[`oidc.login.${
|
|
277
|
-
return c[
|
|
276
|
+
const d = localStorage[`oidc.login.${s}`];
|
|
277
|
+
return c[s] || (c[s] = JSON.parse(d)), c[s];
|
|
278
278
|
},
|
|
279
279
|
getStateAsync: async () => {
|
|
280
|
-
let A = (await P(t)({ type: "getState", data: null, configurationName:
|
|
281
|
-
return A || (A = sessionStorage[`oidc.state.${
|
|
280
|
+
let A = (await P(t)({ type: "getState", data: null, configurationName: s })).state;
|
|
281
|
+
return A || (A = sessionStorage[`oidc.state.${s}`], console.warn("state not found in service worker, using sessionStorage")), A;
|
|
282
282
|
},
|
|
283
|
-
setStateAsync: async (d) => (sessionStorage[`oidc.state.${
|
|
283
|
+
setStateAsync: async (d) => (sessionStorage[`oidc.state.${s}`] = d, P(t)({ type: "setState", data: { state: d }, configurationName: s })),
|
|
284
284
|
getCodeVerifierAsync: async () => {
|
|
285
|
-
let A = (await P(t)({ type: "getCodeVerifier", data: null, configurationName:
|
|
286
|
-
return A || (A = sessionStorage[`oidc.code_verifier.${
|
|
285
|
+
let A = (await P(t)({ type: "getCodeVerifier", data: null, configurationName: s })).codeVerifier;
|
|
286
|
+
return A || (A = sessionStorage[`oidc.code_verifier.${s}`], console.warn("codeVerifier not found in service worker, using sessionStorage")), A;
|
|
287
287
|
},
|
|
288
|
-
setCodeVerifierAsync: async (d) => (sessionStorage[`oidc.code_verifier.${
|
|
288
|
+
setCodeVerifierAsync: async (d) => (sessionStorage[`oidc.code_verifier.${s}`] = d, P(t)({ type: "setCodeVerifier", data: { codeVerifier: d }, configurationName: s })),
|
|
289
289
|
setDemonstratingProofOfPossessionNonce: async (d) => {
|
|
290
|
-
await P(t)({ type: "setDemonstratingProofOfPossessionNonce", data: { demonstratingProofOfPossessionNonce: d }, configurationName:
|
|
290
|
+
await P(t)({ type: "setDemonstratingProofOfPossessionNonce", data: { demonstratingProofOfPossessionNonce: d }, configurationName: s });
|
|
291
291
|
},
|
|
292
|
-
getDemonstratingProofOfPossessionNonce: async () => (await P(t)({ type: "getDemonstratingProofOfPossessionNonce", data: null, configurationName:
|
|
292
|
+
getDemonstratingProofOfPossessionNonce: async () => (await P(t)({ type: "getDemonstratingProofOfPossessionNonce", data: null, configurationName: s })).demonstratingProofOfPossessionNonce,
|
|
293
293
|
setDemonstratingProofOfPossessionJwkAsync: async (d) => {
|
|
294
294
|
const A = JSON.stringify(d);
|
|
295
|
-
await P(t)({ type: "setDemonstratingProofOfPossessionJwk", data: { demonstratingProofOfPossessionJwkJson: A }, configurationName:
|
|
295
|
+
await P(t)({ type: "setDemonstratingProofOfPossessionJwk", data: { demonstratingProofOfPossessionJwkJson: A }, configurationName: s });
|
|
296
296
|
},
|
|
297
297
|
getDemonstratingProofOfPossessionJwkAsync: async () => {
|
|
298
|
-
const d = await P(t)({ type: "getDemonstratingProofOfPossessionJwk", data: null, configurationName:
|
|
298
|
+
const d = await P(t)({ type: "getDemonstratingProofOfPossessionJwk", data: null, configurationName: s });
|
|
299
299
|
return d.demonstratingProofOfPossessionJwkJson ? JSON.parse(d.demonstratingProofOfPossessionJwkJson) : null;
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
|
-
}, R = {}, De = (e,
|
|
303
|
-
if (!R[e] &&
|
|
304
|
-
const o =
|
|
302
|
+
}, R = {}, De = (e, s = window.sessionStorage, n) => {
|
|
303
|
+
if (!R[e] && s) {
|
|
304
|
+
const o = s.getItem(e);
|
|
305
305
|
o && (R[e] = JSON.parse(o));
|
|
306
306
|
}
|
|
307
|
-
const t = 1e3 *
|
|
307
|
+
const t = 1e3 * n;
|
|
308
308
|
return R[e] && R[e].timestamp + t > Date.now() ? R[e].result : null;
|
|
309
|
-
}, Re = (e,
|
|
309
|
+
}, Re = (e, s, n = window.sessionStorage) => {
|
|
310
310
|
const t = Date.now();
|
|
311
|
-
R[e] = { result:
|
|
311
|
+
R[e] = { result: s, timestamp: t }, n && n.setItem(e, JSON.stringify({ result: s, timestamp: t }));
|
|
312
312
|
};
|
|
313
313
|
function pe(e) {
|
|
314
314
|
return new TextEncoder().encode(e);
|
|
@@ -317,15 +317,15 @@ function we(e) {
|
|
|
317
317
|
return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
318
318
|
}
|
|
319
319
|
function $e(e) {
|
|
320
|
-
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(
|
|
320
|
+
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(n, t) {
|
|
321
321
|
return String.fromCharCode(parseInt(t, 16));
|
|
322
322
|
});
|
|
323
323
|
}
|
|
324
324
|
const ie = (e) => {
|
|
325
|
-
let
|
|
326
|
-
return e.forEach(function(
|
|
327
|
-
|
|
328
|
-
}), we(
|
|
325
|
+
let s = "";
|
|
326
|
+
return e.forEach(function(n) {
|
|
327
|
+
s += String.fromCharCode(n);
|
|
328
|
+
}), we(s);
|
|
329
329
|
};
|
|
330
330
|
function _e(e) {
|
|
331
331
|
return we($e(e));
|
|
@@ -343,13 +343,13 @@ const Ke = {
|
|
|
343
343
|
},
|
|
344
344
|
digestAlgorithm: { name: "SHA-256" },
|
|
345
345
|
jwtHeaderAlgorithm: "ES256"
|
|
346
|
-
}, Ue = (e) => async (
|
|
347
|
-
switch (
|
|
346
|
+
}, Ue = (e) => async (s, n, t, o, i = "dpop+jwt") => {
|
|
347
|
+
switch (s = Object.assign({}, s), n.typ = i, n.alg = o.jwtHeaderAlgorithm, n.alg) {
|
|
348
348
|
case "ES256":
|
|
349
|
-
|
|
349
|
+
n.jwk = { kty: s.kty, crv: s.crv, x: s.x, y: s.y };
|
|
350
350
|
break;
|
|
351
351
|
case "RS256":
|
|
352
|
-
|
|
352
|
+
n.jwk = { kty: s.kty, n: s.n, e: s.e, kid: n.kid };
|
|
353
353
|
break;
|
|
354
354
|
default:
|
|
355
355
|
throw new Error("Unknown or not implemented JWS algorithm");
|
|
@@ -357,40 +357,40 @@ const Ke = {
|
|
|
357
357
|
const r = {
|
|
358
358
|
// @ts-ignore
|
|
359
359
|
// JWT "headers" really means JWS "protected headers"
|
|
360
|
-
protected: _e(JSON.stringify(
|
|
360
|
+
protected: _e(JSON.stringify(n)),
|
|
361
361
|
// @ts-ignore
|
|
362
362
|
// JWT "claims" are really a JSON-defined JWS "payload"
|
|
363
363
|
payload: _e(JSON.stringify(t))
|
|
364
|
-
}, a = o.importKeyAlgorithm, l = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk",
|
|
364
|
+
}, a = o.importKeyAlgorithm, l = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", s, a, l, f), c = pe(`${r.protected}.${r.payload}`), _ = o.signAlgorithm, y = await e.crypto.subtle.sign(_, u, c);
|
|
365
365
|
return r.signature = ie(new Uint8Array(y)), `${r.protected}.${r.payload}.${r.signature}`;
|
|
366
366
|
};
|
|
367
367
|
var Fe = { sign: Ue };
|
|
368
|
-
const Ve = (e) => async (
|
|
369
|
-
const
|
|
368
|
+
const Ve = (e) => async (s) => {
|
|
369
|
+
const n = s, t = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(n, t, o);
|
|
370
370
|
return await e.crypto.subtle.exportKey("jwk", i.privateKey);
|
|
371
371
|
}, Je = (e) => {
|
|
372
|
-
const
|
|
373
|
-
return delete
|
|
372
|
+
const s = Object.assign({}, e);
|
|
373
|
+
return delete s.d, s.key_ops = ["verify"], s;
|
|
374
374
|
}, Me = {
|
|
375
375
|
generate: Ve,
|
|
376
376
|
neuter: Je
|
|
377
|
-
}, Be = (e) => async (
|
|
377
|
+
}, Be = (e) => async (s, n) => {
|
|
378
378
|
let t;
|
|
379
|
-
switch (
|
|
379
|
+
switch (s.kty) {
|
|
380
380
|
case "EC":
|
|
381
|
-
t = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",
|
|
381
|
+
t = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV", s.crv).replace("X", s.x).replace("Y", s.y);
|
|
382
382
|
break;
|
|
383
383
|
case "RSA":
|
|
384
|
-
t = '{"e":"E","kty":"RSA","n":"N"}'.replace("E",
|
|
384
|
+
t = '{"e":"E","kty":"RSA","n":"N"}'.replace("E", s.e).replace("N", s.n);
|
|
385
385
|
break;
|
|
386
386
|
default:
|
|
387
387
|
throw new Error("Unknown or not implemented JWK type");
|
|
388
388
|
}
|
|
389
|
-
const o = await e.crypto.subtle.digest(
|
|
389
|
+
const o = await e.crypto.subtle.digest(n, pe(t));
|
|
390
390
|
return ie(new Uint8Array(o));
|
|
391
391
|
};
|
|
392
392
|
var He = { thumbprint: Be };
|
|
393
|
-
const qe = (e) => async (
|
|
393
|
+
const qe = (e) => async (s) => await Me.generate(e)(s), Ae = (e) => (s) => async (n, t = "POST", o, i = {}) => {
|
|
394
394
|
const r = {
|
|
395
395
|
// https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
|
|
396
396
|
jti: btoa(je()),
|
|
@@ -398,51 +398,51 @@ const qe = (e) => async (n) => await Me.generate(e)(n), Ae = (e) => (n) => async
|
|
|
398
398
|
htu: o,
|
|
399
399
|
iat: Math.round(Date.now() / 1e3),
|
|
400
400
|
...i
|
|
401
|
-
}, a = await He.thumbprint(e)(
|
|
402
|
-
return await Fe.sign(e)(
|
|
401
|
+
}, a = await He.thumbprint(e)(n, s.digestAlgorithm);
|
|
402
|
+
return await Fe.sign(e)(n, { kid: a }, r, s);
|
|
403
403
|
}, je = () => {
|
|
404
|
-
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
|
405
|
-
let
|
|
404
|
+
const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", s = "0123456789abcdef";
|
|
405
|
+
let n = 0, t = "";
|
|
406
406
|
for (let o = 0; o < 36; o++)
|
|
407
|
-
e[o] !== "-" && e[o] !== "4" && (
|
|
407
|
+
e[o] !== "-" && e[o] !== "4" && (n = Math.random() * 16 | 0), e[o] === "x" ? t += s[n] : e[o] === "y" ? (n &= 3, n |= 8, t += s[n]) : t += e[o];
|
|
408
408
|
return t;
|
|
409
409
|
}, Se = () => {
|
|
410
|
-
const e = typeof window < "u" && !!window.crypto,
|
|
411
|
-
return { hasCrypto: e, hasSubtleCrypto:
|
|
410
|
+
const e = typeof window < "u" && !!window.crypto, s = e && !!window.crypto.subtle;
|
|
411
|
+
return { hasCrypto: e, hasSubtleCrypto: s };
|
|
412
412
|
}, ee = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", Ge = (e) => {
|
|
413
|
-
const
|
|
414
|
-
for (let
|
|
415
|
-
const t = e[
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
return
|
|
419
|
-
},
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
window.crypto.getRandomValues(
|
|
413
|
+
const s = [];
|
|
414
|
+
for (let n = 0; n < e.byteLength; n += 1) {
|
|
415
|
+
const t = e[n] % ee.length;
|
|
416
|
+
s.push(ee[t]);
|
|
417
|
+
}
|
|
418
|
+
return s.join("");
|
|
419
|
+
}, se = (e) => {
|
|
420
|
+
const s = new Uint8Array(e), { hasCrypto: n } = Se();
|
|
421
|
+
if (n)
|
|
422
|
+
window.crypto.getRandomValues(s);
|
|
423
423
|
else
|
|
424
424
|
for (let t = 0; t < e; t += 1)
|
|
425
|
-
|
|
426
|
-
return Ge(
|
|
425
|
+
s[t] = Math.random() * ee.length | 0;
|
|
426
|
+
return Ge(s);
|
|
427
427
|
};
|
|
428
428
|
function Ye(e) {
|
|
429
|
-
const
|
|
429
|
+
const s = new ArrayBuffer(e.length), n = new Uint8Array(s);
|
|
430
430
|
for (let t = 0; t < e.length; t++)
|
|
431
|
-
|
|
432
|
-
return
|
|
431
|
+
n[t] = e.charCodeAt(t);
|
|
432
|
+
return n;
|
|
433
433
|
}
|
|
434
434
|
function ve(e) {
|
|
435
|
-
return new Promise((
|
|
436
|
-
crypto.subtle.digest("SHA-256", Ye(e)).then((t) =>
|
|
435
|
+
return new Promise((s, n) => {
|
|
436
|
+
crypto.subtle.digest("SHA-256", Ye(e)).then((t) => s(ie(new Uint8Array(t))), (t) => n(t));
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
439
|
const Xe = (e) => {
|
|
440
440
|
if (e.length < 43 || e.length > 128)
|
|
441
441
|
return Promise.reject(new Error("Invalid code length."));
|
|
442
|
-
const { hasSubtleCrypto:
|
|
443
|
-
return
|
|
444
|
-
}, ze = 60 * 60, Qe = (e) => async (
|
|
445
|
-
const i = `${
|
|
442
|
+
const { hasSubtleCrypto: s } = Se();
|
|
443
|
+
return s ? ve(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
|
|
444
|
+
}, ze = 60 * 60, Qe = (e) => async (s, n = ze, t = window.sessionStorage, o = 1e4) => {
|
|
445
|
+
const i = `${s}/.well-known/openid-configuration`, r = `oidc.server:${s}`, a = De(r, t, n);
|
|
446
446
|
if (a)
|
|
447
447
|
return new te(a);
|
|
448
448
|
const l = await B(e)(i, {}, o);
|
|
@@ -450,26 +450,26 @@ const Xe = (e) => {
|
|
|
450
450
|
return null;
|
|
451
451
|
const f = await l.json();
|
|
452
452
|
return Re(r, f, t), new te(f);
|
|
453
|
-
}, B = (e) => async (
|
|
453
|
+
}, B = (e) => async (s, n = {}, t = 1e4, o = 0) => {
|
|
454
454
|
let i;
|
|
455
455
|
try {
|
|
456
456
|
const r = new AbortController();
|
|
457
|
-
setTimeout(() => r.abort(), t), i = await e(
|
|
457
|
+
setTimeout(() => r.abort(), t), i = await e(s, { ...n, signal: r.signal });
|
|
458
458
|
} catch (r) {
|
|
459
459
|
if (r.name === "AbortError" || r.message === "Network request failed") {
|
|
460
460
|
if (o <= 1)
|
|
461
|
-
return await B(e)(
|
|
461
|
+
return await B(e)(s, n, t, o + 1);
|
|
462
462
|
throw r;
|
|
463
463
|
} else
|
|
464
464
|
throw console.error(r.message), r;
|
|
465
465
|
}
|
|
466
466
|
return i;
|
|
467
|
-
},
|
|
467
|
+
}, ne = {
|
|
468
468
|
refresh_token: "refresh_token",
|
|
469
469
|
access_token: "access_token"
|
|
470
|
-
}, fe = (e) => async (
|
|
470
|
+
}, fe = (e) => async (s, n, t = ne.refresh_token, o, i = {}, r = 1e4) => {
|
|
471
471
|
const a = {
|
|
472
|
-
token:
|
|
472
|
+
token: n,
|
|
473
473
|
token_type_hint: t,
|
|
474
474
|
client_id: o
|
|
475
475
|
};
|
|
@@ -481,7 +481,7 @@ const Xe = (e) => {
|
|
|
481
481
|
l.push(`${_}=${y}`);
|
|
482
482
|
}
|
|
483
483
|
const f = l.join("&");
|
|
484
|
-
return (await B(e)(
|
|
484
|
+
return (await B(e)(s, {
|
|
485
485
|
method: "POST",
|
|
486
486
|
headers: {
|
|
487
487
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
|
|
@@ -490,15 +490,15 @@ const Xe = (e) => {
|
|
|
490
490
|
}, r)).status !== 200 ? { success: !1 } : {
|
|
491
491
|
success: !0
|
|
492
492
|
};
|
|
493
|
-
}, Ze = (e) => async (
|
|
493
|
+
}, Ze = (e) => async (s, n, t, o, i = {}, r, a = 1e4) => {
|
|
494
494
|
for (const [y, g] of Object.entries(t))
|
|
495
|
-
|
|
495
|
+
n[y] === void 0 && (n[y] = g);
|
|
496
496
|
const l = [];
|
|
497
|
-
for (const y in
|
|
498
|
-
const g = encodeURIComponent(y), p = encodeURIComponent(
|
|
497
|
+
for (const y in n) {
|
|
498
|
+
const g = encodeURIComponent(y), p = encodeURIComponent(n[y]);
|
|
499
499
|
l.push(`${g}=${p}`);
|
|
500
500
|
}
|
|
501
|
-
const f = l.join("&"), u = await B(e)(
|
|
501
|
+
const f = l.join("&"), u = await B(e)(s, {
|
|
502
502
|
method: "POST",
|
|
503
503
|
headers: {
|
|
504
504
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -520,23 +520,23 @@ const Xe = (e) => {
|
|
|
520
520
|
data: oe(c, o, r),
|
|
521
521
|
demonstratingProofOfPossessionNonce: _
|
|
522
522
|
};
|
|
523
|
-
},
|
|
523
|
+
}, es = (e, s) => async (n, t) => {
|
|
524
524
|
t = t ? { ...t } : {};
|
|
525
|
-
const o =
|
|
525
|
+
const o = se(128), i = await Xe(o);
|
|
526
526
|
await e.setCodeVerifierAsync(o), await e.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
|
|
527
527
|
let r = "";
|
|
528
528
|
if (t)
|
|
529
529
|
for (const [a, l] of Object.entries(t))
|
|
530
530
|
r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(l)}`;
|
|
531
|
-
|
|
532
|
-
}, j = "DPoP-Nonce",
|
|
533
|
-
|
|
531
|
+
s.open(`${n}${r}`);
|
|
532
|
+
}, j = "DPoP-Nonce", ss = (e) => async (s, n, t, o, i = 1e4) => {
|
|
533
|
+
n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
|
|
534
534
|
const r = [];
|
|
535
|
-
for (const c in
|
|
536
|
-
const _ = encodeURIComponent(c), y = encodeURIComponent(
|
|
535
|
+
for (const c in n) {
|
|
536
|
+
const _ = encodeURIComponent(c), y = encodeURIComponent(n[c]);
|
|
537
537
|
r.push(`${_}=${y}`);
|
|
538
538
|
}
|
|
539
|
-
const a = r.join("&"), l = await B(fetch)(
|
|
539
|
+
const a = r.join("&"), l = await B(fetch)(s, {
|
|
540
540
|
method: "POST",
|
|
541
541
|
headers: {
|
|
542
542
|
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
|
@@ -552,40 +552,40 @@ const Xe = (e) => {
|
|
|
552
552
|
return {
|
|
553
553
|
success: !0,
|
|
554
554
|
data: {
|
|
555
|
-
state:
|
|
555
|
+
state: n.state,
|
|
556
556
|
tokens: oe(u, null, o),
|
|
557
557
|
demonstratingProofOfPossessionNonce: f
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
560
|
};
|
|
561
|
-
async function de(e,
|
|
561
|
+
async function de(e, s, n) {
|
|
562
562
|
const t = (a) => {
|
|
563
563
|
e.tokens = a;
|
|
564
|
-
}, { tokens: o, status: i } = await H(e)(0,
|
|
564
|
+
}, { tokens: o, status: i } = await H(e)(0, s, n, t);
|
|
565
565
|
return await I(e.configuration, e.configurationName) || await O(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? o : (await e.destroyAsync(i), null);
|
|
566
566
|
}
|
|
567
|
-
const
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
570
|
-
const t = await e.initAsync(
|
|
567
|
+
const ns = async (e, s) => {
|
|
568
|
+
const n = await I(s, e.configurationName);
|
|
569
|
+
if (n) {
|
|
570
|
+
const t = await e.initAsync(s.authority, s.authority_configuration), { tokens: o } = await n.initAsync(t, "tryKeepExistingSessionAsync", s);
|
|
571
571
|
return o;
|
|
572
572
|
} else {
|
|
573
|
-
const t = O(e.configurationName,
|
|
573
|
+
const t = O(e.configurationName, s.storage ?? sessionStorage);
|
|
574
574
|
let { tokens: o } = await t.initAsync();
|
|
575
|
-
return o = X(o, e.tokens,
|
|
575
|
+
return o = X(o, e.tokens, s.token_renew_mode), o;
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
|
-
async function Te(e,
|
|
578
|
+
async function Te(e, s = !1, n = null) {
|
|
579
579
|
const t = e.configuration, o = `${t.client_id}_${e.configurationName}_${t.authority}`;
|
|
580
580
|
let i;
|
|
581
581
|
const r = await I(e.configuration, e.configurationName);
|
|
582
|
-
return (t == null ? void 0 : t.storage) === (window == null ? void 0 : window.sessionStorage) && !r ? i = await de(e,
|
|
582
|
+
return (t == null ? void 0 : t.storage) === (window == null ? void 0 : window.sessionStorage) && !r ? i = await de(e, s, n) : i = await navigator.locks.request(o, { ifAvailable: !0 }, async (a) => a ? await de(e, s, n) : (e.publishEvent(C.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), await ns(e, t))), i ? (e.timeoutId && (e.timeoutId = J(e, e.tokens.expiresAt, n)), e.tokens) : null;
|
|
583
583
|
}
|
|
584
|
-
const J = (e,
|
|
584
|
+
const J = (e, s, n = null) => {
|
|
585
585
|
const t = e.configuration.refresh_time_before_tokens_expiration_in_second;
|
|
586
586
|
return M.setTimeout(async () => {
|
|
587
|
-
const i = { timeLeft: U(t,
|
|
588
|
-
e.publishEvent(C.eventNames.token_timer, i), await Te(e, !1,
|
|
587
|
+
const i = { timeLeft: U(t, s) };
|
|
588
|
+
e.publishEvent(C.eventNames.token_timer, i), await Te(e, !1, n);
|
|
589
589
|
}, 1e3);
|
|
590
590
|
}, N = {
|
|
591
591
|
FORCE_REFRESH: "FORCE_REFRESH",
|
|
@@ -595,14 +595,14 @@ const J = (e, n, s = null) => {
|
|
|
595
595
|
TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",
|
|
596
596
|
LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
|
|
597
597
|
REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS"
|
|
598
|
-
},
|
|
598
|
+
}, ts = (e) => async (s, n, t, o = !1) => {
|
|
599
599
|
const i = { nonce: null };
|
|
600
600
|
if (!t)
|
|
601
601
|
return { tokens: null, status: "NOT_CONNECTED", nonce: i };
|
|
602
602
|
let r = i;
|
|
603
|
-
const a = await e.initAsync(
|
|
603
|
+
const a = await e.initAsync(s.authority, s.authority_configuration), l = await I(s, n);
|
|
604
604
|
if (l) {
|
|
605
|
-
const { status: c, tokens: _ } = await l.initAsync(a, "syncTokensAsync",
|
|
605
|
+
const { status: c, tokens: _ } = await l.initAsync(a, "syncTokensAsync", s);
|
|
606
606
|
if (c === "LOGGED_OUT")
|
|
607
607
|
return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
|
|
608
608
|
if (c === "SESSIONS_LOST")
|
|
@@ -610,33 +610,33 @@ const J = (e, n, s = null) => {
|
|
|
610
610
|
if (!c || !_)
|
|
611
611
|
return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: i };
|
|
612
612
|
if (_.issuedAt !== t.issuedAt) {
|
|
613
|
-
const g = U(
|
|
613
|
+
const g = U(s.refresh_time_before_tokens_expiration_in_second, _.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", p = await l.getNonceAsync();
|
|
614
614
|
return { tokens: _, status: g, nonce: p };
|
|
615
615
|
}
|
|
616
616
|
r = await l.getNonceAsync();
|
|
617
617
|
} else {
|
|
618
|
-
const c = O(
|
|
618
|
+
const c = O(n, s.storage ?? sessionStorage);
|
|
619
619
|
let { tokens: _, status: y } = await c.initAsync();
|
|
620
|
-
if (_ && (_ = X(_, e.tokens,
|
|
620
|
+
if (_ && (_ = X(_, e.tokens, s.token_renew_mode)), _) {
|
|
621
621
|
if (y === "SESSIONS_LOST")
|
|
622
622
|
return { tokens: null, status: "SESSIONS_LOST", nonce: i };
|
|
623
623
|
if (_.issuedAt !== t.issuedAt) {
|
|
624
|
-
const p = U(
|
|
624
|
+
const p = U(s.refresh_time_before_tokens_expiration_in_second, _.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", k = await c.getNonceAsync();
|
|
625
625
|
return { tokens: _, status: p, nonce: k };
|
|
626
626
|
}
|
|
627
627
|
} else
|
|
628
628
|
return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
|
|
629
629
|
r = await c.getNonceAsync();
|
|
630
630
|
}
|
|
631
|
-
const u = U(
|
|
631
|
+
const u = U(s.refresh_time_before_tokens_expiration_in_second, t.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
|
|
632
632
|
return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: u, nonce: r };
|
|
633
|
-
}, H = (e) => async (
|
|
633
|
+
}, H = (e) => async (s = 0, n = !1, t = null, o) => {
|
|
634
634
|
if (!navigator.onLine && document.hidden)
|
|
635
635
|
return { tokens: e.tokens, status: "GIVE_UP" };
|
|
636
636
|
let i = 6;
|
|
637
637
|
for (; !navigator.onLine && i > 0; )
|
|
638
638
|
await z({ milliseconds: 1e3 }), i--, e.publishEvent(m.refreshTokensAsync, { message: `wait because navigator is offline try ${i}` });
|
|
639
|
-
const r =
|
|
639
|
+
const r = s + 1;
|
|
640
640
|
t || (t = {});
|
|
641
641
|
const a = e.configuration, l = (u, c = null, _ = null) => re(e.configurationName, e.configuration, e.publishEvent.bind(e))(u, c, _), f = async () => {
|
|
642
642
|
try {
|
|
@@ -650,11 +650,11 @@ const J = (e, n, s = null) => {
|
|
|
650
650
|
});
|
|
651
651
|
return _ ? _.error ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent" }), { tokens: null, status: "SESSION_LOST" }) : (o(_.tokens), e.publishEvent(C.eventNames.token_renewed, {}), { tokens: _.tokens, status: "LOGGED" }) : (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token silent not active" }), { tokens: null, status: "SESSION_LOST" });
|
|
652
652
|
} catch (u) {
|
|
653
|
-
return console.error(u), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exceptionSilent", exception: u.message }), await H(e)(r,
|
|
653
|
+
return console.error(u), e.publishEvent(m.refreshTokensAsync_silent_error, { message: "exceptionSilent", exception: u.message }), await H(e)(r, n, t, o);
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
656
|
try {
|
|
657
|
-
const { status: u, tokens: c, nonce: _ } = await
|
|
657
|
+
const { status: u, tokens: c, nonce: _ } = await ts(e)(a, e.configurationName, e.tokens, n);
|
|
658
658
|
switch (u) {
|
|
659
659
|
case N.SESSION_LOST:
|
|
660
660
|
return o(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token session lost" }), { tokens: null, status: "SESSION_LOST" };
|
|
@@ -667,11 +667,11 @@ const J = (e, n, s = null) => {
|
|
|
667
667
|
case N.LOGOUT_FROM_ANOTHER_TAB:
|
|
668
668
|
return o(null), e.publishEvent(m.logout_from_another_tab, { status: "session syncTokensAsync" }), { tokens: null, status: "LOGGED_OUT" };
|
|
669
669
|
case N.REQUIRE_SYNC_TOKENS:
|
|
670
|
-
return a.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted && N.FORCE_REFRESH !== u ? (e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(m.refreshTokensAsync_begin, { tryNumber:
|
|
670
|
+
return a.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted && N.FORCE_REFRESH !== u ? (e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(m.refreshTokensAsync_begin, { tryNumber: s }), await f());
|
|
671
671
|
default: {
|
|
672
672
|
if (a.token_automatic_renew_mode == V.AutomaticOnlyWhenFetchExecuted && N.FORCE_REFRESH !== u)
|
|
673
673
|
return e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
|
|
674
|
-
if (e.publishEvent(m.refreshTokensAsync_begin, { refreshToken: c.refreshToken, status: u, tryNumber:
|
|
674
|
+
if (e.publishEvent(m.refreshTokensAsync_begin, { refreshToken: c.refreshToken, status: u, tryNumber: s }), !c.refreshToken)
|
|
675
675
|
return await f();
|
|
676
676
|
const y = a.client_id, g = a.redirect_uri, p = a.authority, w = { ...a.token_request_extras ? a.token_request_extras : {} };
|
|
677
677
|
for (const [S, E] of Object.entries(t))
|
|
@@ -706,23 +706,30 @@ const J = (e, n, s = null) => {
|
|
|
706
706
|
return e.publishEvent(m.refreshTokensAsync_silent_error, {
|
|
707
707
|
message: "bad request",
|
|
708
708
|
tokenResponse: v
|
|
709
|
-
}), v.status >= 400 && v.status < 500 ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: `session lost: ${v.status}` }), { tokens: null, status: "SESSION_LOST" }) : await H(e)(r,
|
|
709
|
+
}), v.status >= 400 && v.status < 500 ? (o(null), e.publishEvent(m.refreshTokensAsync_error, { message: `session lost: ${v.status}` }), { tokens: null, status: "SESSION_LOST" }) : await H(e)(r, n, t, o);
|
|
710
710
|
})();
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
} catch (u) {
|
|
714
|
-
return console.error(u), e.publishEvent(m.refreshTokensAsync_silent_error, {
|
|
714
|
+
return console.error(u), e.publishEvent(m.refreshTokensAsync_silent_error, {
|
|
715
|
+
message: "exception",
|
|
716
|
+
exception: u.message
|
|
717
|
+
}), new Promise((c, _) => {
|
|
718
|
+
setTimeout(() => {
|
|
719
|
+
H(e)(r, n, t, o).then(c).catch(_);
|
|
720
|
+
}, 1e3);
|
|
721
|
+
});
|
|
715
722
|
}
|
|
716
|
-
}, re = (e,
|
|
717
|
-
if (!
|
|
723
|
+
}, re = (e, s, n) => (t = null, o = null, i = null) => {
|
|
724
|
+
if (!s.silent_redirect_uri || !s.silent_login_uri)
|
|
718
725
|
return Promise.resolve(null);
|
|
719
726
|
try {
|
|
720
|
-
|
|
727
|
+
n(m.silentLoginAsync_begin, {});
|
|
721
728
|
let r = "";
|
|
722
729
|
if (o && (t == null && (t = {}), t.state = o), i && (t == null && (t = {}), t.scope = i), t != null)
|
|
723
730
|
for (const [c, _] of Object.entries(t))
|
|
724
731
|
r === "" ? r = `?${encodeURIComponent(c)}=${encodeURIComponent(_)}` : r += `&${encodeURIComponent(c)}=${encodeURIComponent(_)}`;
|
|
725
|
-
const a =
|
|
732
|
+
const a = s.silent_login_uri + r, l = a.indexOf("/", a.indexOf("//") + 2), f = a.substring(0, l), u = document.createElement("iframe");
|
|
726
733
|
return u.width = "0px", u.height = "0px", u.id = `${e}_oidc_iframe`, u.setAttribute("src", a), document.body.appendChild(u), new Promise((c, _) => {
|
|
727
734
|
let y = !1;
|
|
728
735
|
const g = () => {
|
|
@@ -733,39 +740,39 @@ const J = (e, n, s = null) => {
|
|
|
733
740
|
if (E && typeof E == "string" && !y) {
|
|
734
741
|
if (E.startsWith(w)) {
|
|
735
742
|
const h = JSON.parse(k.data.replace(w, ""));
|
|
736
|
-
|
|
743
|
+
n(m.silentLoginAsync_end, {}), c(h), g();
|
|
737
744
|
} else if (E.startsWith(T)) {
|
|
738
745
|
const h = JSON.parse(k.data.replace(T, ""));
|
|
739
|
-
|
|
746
|
+
n(m.silentLoginAsync_error, h), c({ error: "oidc_" + h.error, tokens: null, sessionState: null }), g();
|
|
740
747
|
} else if (E.startsWith(S)) {
|
|
741
748
|
const h = JSON.parse(k.data.replace(S, ""));
|
|
742
|
-
|
|
749
|
+
n(m.silentLoginAsync_error, h), _(new Error(h.error)), g();
|
|
743
750
|
}
|
|
744
751
|
}
|
|
745
752
|
}
|
|
746
753
|
};
|
|
747
754
|
try {
|
|
748
755
|
window.addEventListener("message", p);
|
|
749
|
-
const k =
|
|
756
|
+
const k = s.silent_login_timeout;
|
|
750
757
|
setTimeout(() => {
|
|
751
|
-
y || (g(),
|
|
758
|
+
y || (g(), n(m.silentLoginAsync_error, { reason: "timeout" }), _(new Error("timeout")));
|
|
752
759
|
}, k);
|
|
753
760
|
} catch (k) {
|
|
754
|
-
g(),
|
|
761
|
+
g(), n(m.silentLoginAsync_error, k), _(k);
|
|
755
762
|
}
|
|
756
763
|
});
|
|
757
764
|
} catch (r) {
|
|
758
|
-
throw
|
|
765
|
+
throw n(m.silentLoginAsync_error, r), r;
|
|
759
766
|
}
|
|
760
|
-
},
|
|
767
|
+
}, os = (e, s, n, t, o) => (i = null, r = void 0) => {
|
|
761
768
|
i = { ...i };
|
|
762
|
-
const a = (f, u, c) => re(
|
|
769
|
+
const a = (f, u, c) => re(s, n, t.bind(o))(f, u, c);
|
|
763
770
|
return (async () => {
|
|
764
771
|
o.timeoutId && M.clearTimeout(o.timeoutId);
|
|
765
772
|
let f;
|
|
766
773
|
i && "state" in i && (f = i.state, delete i.state);
|
|
767
774
|
try {
|
|
768
|
-
const u =
|
|
775
|
+
const u = n.extras ? { ...n.extras, ...i } : i, c = await a({
|
|
769
776
|
...u,
|
|
770
777
|
prompt: "none"
|
|
771
778
|
}, f, r);
|
|
@@ -775,10 +782,10 @@ const J = (e, n, s = null) => {
|
|
|
775
782
|
return u;
|
|
776
783
|
}
|
|
777
784
|
})();
|
|
778
|
-
},
|
|
779
|
-
const a = (l, f = void 0, u = void 0) => re(e.configurationName,
|
|
785
|
+
}, is = (e, s, n) => (t, o, i, r = !1) => {
|
|
786
|
+
const a = (l, f = void 0, u = void 0) => re(e.configurationName, n, e.publishEvent.bind(e))(l, f, u);
|
|
780
787
|
return new Promise((l, f) => {
|
|
781
|
-
if (
|
|
788
|
+
if (n.silent_login_uri && n.silent_redirect_uri && n.monitor_session && t && i && !r) {
|
|
782
789
|
const u = () => {
|
|
783
790
|
e.checkSessionIFrame.stop();
|
|
784
791
|
const c = e.tokens;
|
|
@@ -788,7 +795,7 @@ const J = (e, n, s = null) => {
|
|
|
788
795
|
return a({
|
|
789
796
|
prompt: "none",
|
|
790
797
|
id_token_hint: _,
|
|
791
|
-
scope:
|
|
798
|
+
scope: n.scope || "openid"
|
|
792
799
|
}).then((g) => {
|
|
793
800
|
if (g.error)
|
|
794
801
|
throw new Error(g.error);
|
|
@@ -800,8 +807,8 @@ const J = (e, n, s = null) => {
|
|
|
800
807
|
console.debug("SessionMonitor._callback: Different subject signed into OP:", p.sub);
|
|
801
808
|
}).catch(async (g) => {
|
|
802
809
|
console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:", g);
|
|
803
|
-
for (const [p, k] of Object.entries(
|
|
804
|
-
await k.logoutOtherTabAsync(
|
|
810
|
+
for (const [p, k] of Object.entries(s))
|
|
811
|
+
await k.logoutOtherTabAsync(n.client_id, y.sub);
|
|
805
812
|
});
|
|
806
813
|
};
|
|
807
814
|
e.checkSessionIFrame = new Pe(u, o, t), e.checkSessionIFrame.load().then(() => {
|
|
@@ -813,84 +820,84 @@ const J = (e, n, s = null) => {
|
|
|
813
820
|
l(null);
|
|
814
821
|
});
|
|
815
822
|
}, Ee = (e) => {
|
|
816
|
-
const
|
|
823
|
+
const s = e.match(
|
|
817
824
|
// eslint-disable-next-line no-useless-escape
|
|
818
825
|
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
|
|
819
826
|
);
|
|
820
|
-
if (!
|
|
827
|
+
if (!s)
|
|
821
828
|
throw new Error("Invalid URL");
|
|
822
|
-
let
|
|
829
|
+
let n = s[6], t = s[7];
|
|
823
830
|
if (t) {
|
|
824
831
|
const o = t.split("?");
|
|
825
|
-
o.length === 2 && (t = o[0],
|
|
832
|
+
o.length === 2 && (t = o[0], n = o[1]);
|
|
826
833
|
}
|
|
827
|
-
return
|
|
834
|
+
return n.startsWith("?") && (n = n.slice(1)), s && {
|
|
828
835
|
href: e,
|
|
829
|
-
protocol:
|
|
830
|
-
host:
|
|
831
|
-
hostname:
|
|
832
|
-
port:
|
|
833
|
-
path:
|
|
834
|
-
search:
|
|
836
|
+
protocol: s[1],
|
|
837
|
+
host: s[2],
|
|
838
|
+
hostname: s[3],
|
|
839
|
+
port: s[4],
|
|
840
|
+
path: s[5],
|
|
841
|
+
search: n,
|
|
835
842
|
hash: t
|
|
836
843
|
};
|
|
837
|
-
},
|
|
838
|
-
const
|
|
839
|
-
let { path:
|
|
840
|
-
|
|
841
|
-
let { hash: t } =
|
|
842
|
-
return t === "#_=_" && (t = ""), t && (
|
|
844
|
+
}, Ss = (e) => {
|
|
845
|
+
const s = Ee(e);
|
|
846
|
+
let { path: n } = s;
|
|
847
|
+
n.endsWith("/") && (n = n.slice(0, -1));
|
|
848
|
+
let { hash: t } = s;
|
|
849
|
+
return t === "#_=_" && (t = ""), t && (n += t), n;
|
|
843
850
|
}, G = (e) => {
|
|
844
|
-
const
|
|
845
|
-
return
|
|
846
|
-
},
|
|
847
|
-
const
|
|
848
|
-
let
|
|
851
|
+
const s = Ee(e), { search: n } = s;
|
|
852
|
+
return rs(n);
|
|
853
|
+
}, rs = (e) => {
|
|
854
|
+
const s = {};
|
|
855
|
+
let n, t, o;
|
|
849
856
|
const i = e.split("&");
|
|
850
857
|
for (t = 0, o = i.length; t < o; t++)
|
|
851
|
-
|
|
852
|
-
return
|
|
853
|
-
},
|
|
858
|
+
n = i[t].split("="), s[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
|
|
859
|
+
return s;
|
|
860
|
+
}, as = (e, s, n, t, o) => (i = void 0, r = null, a = !1, l = void 0) => {
|
|
854
861
|
const f = r;
|
|
855
862
|
return r = { ...r }, (async () => {
|
|
856
863
|
const c = i || o.getPath();
|
|
857
|
-
if ("state" in r || (r.state =
|
|
864
|
+
if ("state" in r || (r.state = se(16)), n(m.loginAsync_begin, {}), r)
|
|
858
865
|
for (const _ of Object.keys(r))
|
|
859
866
|
_.endsWith(":token_request") && delete r[_];
|
|
860
867
|
try {
|
|
861
|
-
const _ = a ?
|
|
862
|
-
l || (l =
|
|
863
|
-
const y =
|
|
864
|
-
y.nonce || (y.nonce =
|
|
865
|
-
const g = { nonce: y.nonce }, p = await I(
|
|
868
|
+
const _ = a ? s.silent_redirect_uri : s.redirect_uri;
|
|
869
|
+
l || (l = s.scope);
|
|
870
|
+
const y = s.extras ? { ...s.extras, ...r } : r;
|
|
871
|
+
y.nonce || (y.nonce = se(12));
|
|
872
|
+
const g = { nonce: y.nonce }, p = await I(s, e), k = await t(s.authority, s.authority_configuration);
|
|
866
873
|
let w;
|
|
867
874
|
if (p)
|
|
868
|
-
p.setLoginParams({ callbackPath: c, extras: f }), await p.initAsync(k, "loginAsync",
|
|
875
|
+
p.setLoginParams({ callbackPath: c, extras: f }), await p.initAsync(k, "loginAsync", s), await p.setNonceAsync(g), p.startKeepAliveServiceWorker(), w = p;
|
|
869
876
|
else {
|
|
870
|
-
const S = O(e,
|
|
877
|
+
const S = O(e, s.storage ?? sessionStorage);
|
|
871
878
|
S.setLoginParams({ callbackPath: c, extras: f }), await S.setNonceAsync(g), w = S;
|
|
872
879
|
}
|
|
873
880
|
const T = {
|
|
874
|
-
client_id:
|
|
881
|
+
client_id: s.client_id,
|
|
875
882
|
redirect_uri: _,
|
|
876
883
|
scope: l,
|
|
877
884
|
response_type: "code",
|
|
878
885
|
...y
|
|
879
886
|
};
|
|
880
|
-
await
|
|
887
|
+
await es(w, o)(k.authorizationEndpoint, T);
|
|
881
888
|
} catch (_) {
|
|
882
|
-
throw
|
|
889
|
+
throw n(m.loginAsync_error, _), _;
|
|
883
890
|
}
|
|
884
891
|
})();
|
|
885
|
-
},
|
|
892
|
+
}, cs = (e) => async (s = !1) => {
|
|
886
893
|
try {
|
|
887
894
|
e.publishEvent(m.loginCallbackAsync_begin, {});
|
|
888
|
-
const
|
|
895
|
+
const n = e.configuration, t = n.client_id, o = s ? n.silent_redirect_uri : n.redirect_uri, i = n.authority, r = n.token_request_timeout, a = await e.initAsync(i, n.authority_configuration), l = e.location.getCurrentHref(), u = G(l).session_state, c = await I(n, e.configurationName);
|
|
889
896
|
let _, y, g, p;
|
|
890
897
|
if (c)
|
|
891
|
-
await c.initAsync(a, "loginCallbackAsync",
|
|
898
|
+
await c.initAsync(a, "loginCallbackAsync", n), await c.setSessionStateAsync(u), y = await c.getNonceAsync(), g = c.getLoginParams(), p = await c.getStateAsync(), c.startKeepAliveServiceWorker(), _ = c;
|
|
892
899
|
else {
|
|
893
|
-
const b = O(e.configurationName,
|
|
900
|
+
const b = O(e.configurationName, n.storage ?? sessionStorage);
|
|
894
901
|
await b.setSessionStateAsync(u), y = await b.getNonceAsync(), g = b.getLoginParams(), p = await b.getStateAsync(), _ = b;
|
|
895
902
|
}
|
|
896
903
|
const k = G(l);
|
|
@@ -903,24 +910,24 @@ const J = (e, n, s = null) => {
|
|
|
903
910
|
const w = {
|
|
904
911
|
code: k.code,
|
|
905
912
|
grant_type: "authorization_code",
|
|
906
|
-
client_id:
|
|
913
|
+
client_id: n.client_id,
|
|
907
914
|
redirect_uri: o
|
|
908
915
|
}, T = {};
|
|
909
|
-
if (
|
|
910
|
-
for (const [b, K] of Object.entries(
|
|
916
|
+
if (n.token_request_extras)
|
|
917
|
+
for (const [b, K] of Object.entries(n.token_request_extras))
|
|
911
918
|
T[b] = K;
|
|
912
919
|
if (g && g.extras)
|
|
913
920
|
for (const [b, K] of Object.entries(g.extras))
|
|
914
921
|
b.endsWith(":token_request") && (T[b.replace(":token_request", "")] = K);
|
|
915
922
|
const S = a.tokenEndpoint, E = {};
|
|
916
|
-
if (
|
|
923
|
+
if (n.demonstrating_proof_of_possession)
|
|
917
924
|
if (c)
|
|
918
925
|
E.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
|
|
919
926
|
else {
|
|
920
|
-
const b = await qe(window)(
|
|
921
|
-
await O(e.configurationName,
|
|
927
|
+
const b = await qe(window)(n.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
|
|
928
|
+
await O(e.configurationName, n.storage).setDemonstratingProofOfPossessionJwkAsync(b), E.DPoP = await Ae(window)(n.demonstrating_proof_of_possession_configuration)(b, "POST", S);
|
|
922
929
|
}
|
|
923
|
-
const h = await
|
|
930
|
+
const h = await ss(_)(
|
|
924
931
|
S,
|
|
925
932
|
{ ...w, ...T },
|
|
926
933
|
E,
|
|
@@ -943,46 +950,46 @@ const J = (e, n, s = null) => {
|
|
|
943
950
|
throw new Error("Demonstration of proof of possession require Access token not hidden by service worker");
|
|
944
951
|
}
|
|
945
952
|
if (c)
|
|
946
|
-
await c.initAsync(a, "syncTokensAsync",
|
|
953
|
+
await c.initAsync(a, "syncTokensAsync", n), d = c.getLoginParams(), v && await c.setDemonstratingProofOfPossessionNonce(v);
|
|
947
954
|
else {
|
|
948
|
-
const b = O(e.configurationName,
|
|
955
|
+
const b = O(e.configurationName, n.storage);
|
|
949
956
|
d = b.getLoginParams(), v && await b.setDemonstratingProofOfPossessionNonce(v);
|
|
950
957
|
}
|
|
951
|
-
return await e.startCheckSessionAsync(a.checkSessionIframe, t, u,
|
|
958
|
+
return await e.startCheckSessionAsync(a.checkSessionIframe, t, u, s), e.publishEvent(m.loginCallbackAsync_end, {}), {
|
|
952
959
|
tokens: A,
|
|
953
960
|
state: "request.state",
|
|
954
961
|
callbackPath: d.callbackPath
|
|
955
962
|
};
|
|
956
|
-
} catch (
|
|
957
|
-
throw console.error(
|
|
963
|
+
} catch (n) {
|
|
964
|
+
throw console.error(n), e.publishEvent(m.loginCallbackAsync_error, n), n;
|
|
958
965
|
}
|
|
959
966
|
}, he = {
|
|
960
967
|
access_token: "access_token",
|
|
961
968
|
refresh_token: "refresh_token"
|
|
962
|
-
}, Q = (e,
|
|
963
|
-
const
|
|
969
|
+
}, Q = (e, s) => {
|
|
970
|
+
const n = {};
|
|
964
971
|
if (e) {
|
|
965
972
|
for (const [t, o] of Object.entries(e))
|
|
966
|
-
if (t.endsWith(
|
|
967
|
-
const i = t.replace(
|
|
968
|
-
|
|
973
|
+
if (t.endsWith(s)) {
|
|
974
|
+
const i = t.replace(s, "");
|
|
975
|
+
n[i] = o;
|
|
969
976
|
}
|
|
970
|
-
return s;
|
|
971
|
-
}
|
|
972
|
-
return s;
|
|
973
|
-
}, un = (e) => {
|
|
974
|
-
const n = {};
|
|
975
|
-
if (e) {
|
|
976
|
-
for (const [s, t] of Object.entries(e))
|
|
977
|
-
s.includes(":") || (n[s] = t);
|
|
978
977
|
return n;
|
|
979
978
|
}
|
|
980
979
|
return n;
|
|
981
|
-
},
|
|
980
|
+
}, ls = (e) => {
|
|
981
|
+
const s = {};
|
|
982
|
+
if (e) {
|
|
983
|
+
for (const [n, t] of Object.entries(e))
|
|
984
|
+
n.includes(":") || (s[n] = t);
|
|
985
|
+
return s;
|
|
986
|
+
}
|
|
987
|
+
return s;
|
|
988
|
+
}, us = (e) => async (s) => {
|
|
982
989
|
M.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
|
|
983
|
-
const
|
|
984
|
-
|
|
985
|
-
},
|
|
990
|
+
const n = await I(e.configuration, e.configurationName);
|
|
991
|
+
n ? await n.clearAsync(s) : await O(e.configurationName, e.configuration.storage).clearAsync(s), e.tokens = null, e.userInfo = null;
|
|
992
|
+
}, _s = (e, s, n, t, o) => async (i = void 0, r = null) => {
|
|
986
993
|
const a = e.configuration, l = await e.initAsync(a.authority, a.authority_configuration);
|
|
987
994
|
i && typeof i != "string" && (i = void 0, t.warn("callbackPathOrUrl path is not a string"));
|
|
988
995
|
const f = i ?? o.getPath();
|
|
@@ -994,10 +1001,10 @@ const J = (e, n, s = null) => {
|
|
|
994
1001
|
if (w) {
|
|
995
1002
|
const T = [], S = e.tokens ? e.tokens.accessToken : null;
|
|
996
1003
|
if (S && a.logout_tokens_to_invalidate.includes(he.access_token)) {
|
|
997
|
-
const h = Q(r, ":revoke_access_token"), d = fe(
|
|
1004
|
+
const h = Q(r, ":revoke_access_token"), d = fe(n)(
|
|
998
1005
|
w,
|
|
999
1006
|
S,
|
|
1000
|
-
|
|
1007
|
+
ne.access_token,
|
|
1001
1008
|
a.client_id,
|
|
1002
1009
|
h
|
|
1003
1010
|
);
|
|
@@ -1005,10 +1012,10 @@ const J = (e, n, s = null) => {
|
|
|
1005
1012
|
}
|
|
1006
1013
|
const E = e.tokens ? e.tokens.refreshToken : null;
|
|
1007
1014
|
if (E && a.logout_tokens_to_invalidate.includes(he.refresh_token)) {
|
|
1008
|
-
const h = Q(r, ":revoke_refresh_token"), d = fe(
|
|
1015
|
+
const h = Q(r, ":revoke_refresh_token"), d = fe(n)(
|
|
1009
1016
|
w,
|
|
1010
1017
|
E,
|
|
1011
|
-
|
|
1018
|
+
ne.refresh_token,
|
|
1012
1019
|
a.client_id,
|
|
1013
1020
|
h
|
|
1014
1021
|
);
|
|
@@ -1021,12 +1028,12 @@ const J = (e, n, s = null) => {
|
|
|
1021
1028
|
}
|
|
1022
1029
|
const y = e.tokens && e.tokens.idTokenPayload ? e.tokens.idTokenPayload.sub : null;
|
|
1023
1030
|
await e.destroyAsync("LOGGED_OUT");
|
|
1024
|
-
for (const [w, T] of Object.entries(
|
|
1031
|
+
for (const [w, T] of Object.entries(s))
|
|
1025
1032
|
T !== e ? await e.logoutSameTabAsync(e.configuration.client_id, y) : e.publishEvent(m.logout_from_same_tab, {});
|
|
1026
1033
|
const g = Q(r, ":oidc");
|
|
1027
1034
|
if (g && g.no_reload === "true")
|
|
1028
1035
|
return;
|
|
1029
|
-
const k =
|
|
1036
|
+
const k = ls(r);
|
|
1030
1037
|
if (l.endSessionEndpoint) {
|
|
1031
1038
|
"id_token_hint" in k || (k.id_token_hint = _), !("post_logout_redirect_uri" in k) && i !== null && (k.post_logout_redirect_uri = c);
|
|
1032
1039
|
let w = "";
|
|
@@ -1035,14 +1042,14 @@ const J = (e, n, s = null) => {
|
|
|
1035
1042
|
o.open(`${l.endSessionEndpoint}${w}`);
|
|
1036
1043
|
} else
|
|
1037
1044
|
o.reload();
|
|
1038
|
-
}, be = (e,
|
|
1045
|
+
}, be = (e, s, n = !1) => async (...t) => {
|
|
1039
1046
|
var y;
|
|
1040
1047
|
const [o, i, ...r] = t, a = i ? { ...i } : { method: "GET" };
|
|
1041
1048
|
let l = new Headers();
|
|
1042
1049
|
a.headers && (l = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
|
|
1043
|
-
const f =
|
|
1050
|
+
const f = s, u = await ge(f), c = (y = u == null ? void 0 : u.tokens) == null ? void 0 : y.accessToken;
|
|
1044
1051
|
if (l.has("Accept") || l.set("Accept", "application/json"), c) {
|
|
1045
|
-
if (f.configuration.demonstrating_proof_of_possession &&
|
|
1052
|
+
if (f.configuration.demonstrating_proof_of_possession && n) {
|
|
1046
1053
|
const g = await f.generateDemonstrationOfProofOfPossessionAsync(c, o.toString(), a.method);
|
|
1047
1054
|
l.set("Authorization", `PoP ${c}`), l.set("DPoP", g);
|
|
1048
1055
|
} else
|
|
@@ -1051,18 +1058,18 @@ const J = (e, n, s = null) => {
|
|
|
1051
1058
|
}
|
|
1052
1059
|
const _ = { ...a, headers: l };
|
|
1053
1060
|
return await e(o, _, ...r);
|
|
1054
|
-
},
|
|
1055
|
-
if (e.userInfo != null && !
|
|
1061
|
+
}, fs = (e) => async (s = !1, n = !1) => {
|
|
1062
|
+
if (e.userInfo != null && !s)
|
|
1056
1063
|
return e.userInfo;
|
|
1057
1064
|
const t = e.configuration, i = (await e.initAsync(t.authority, t.authority_configuration)).userInfoEndpoint, a = await (async () => {
|
|
1058
|
-
const f = await be(fetch, e,
|
|
1065
|
+
const f = await be(fetch, e, n)(i);
|
|
1059
1066
|
return f.status !== 200 ? null : f.json();
|
|
1060
1067
|
})();
|
|
1061
1068
|
return e.userInfo = a, a;
|
|
1062
1069
|
};
|
|
1063
1070
|
class Y {
|
|
1064
|
-
open(
|
|
1065
|
-
window.location.href =
|
|
1071
|
+
open(s) {
|
|
1072
|
+
window.location.href = s;
|
|
1066
1073
|
}
|
|
1067
1074
|
reload() {
|
|
1068
1075
|
window.location.reload();
|
|
@@ -1071,15 +1078,15 @@ class Y {
|
|
|
1071
1078
|
return window.location.href;
|
|
1072
1079
|
}
|
|
1073
1080
|
getPath() {
|
|
1074
|
-
const
|
|
1075
|
-
return
|
|
1081
|
+
const s = window.location;
|
|
1082
|
+
return s.pathname + (s.search || "") + (s.hash || "");
|
|
1076
1083
|
}
|
|
1077
1084
|
getOrigin() {
|
|
1078
1085
|
return window.origin;
|
|
1079
1086
|
}
|
|
1080
1087
|
}
|
|
1081
|
-
const
|
|
1082
|
-
const
|
|
1088
|
+
const ds = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), hs = (e) => {
|
|
1089
|
+
const s = e.appVersion, n = e.userAgent, t = "-";
|
|
1083
1090
|
let o = t;
|
|
1084
1091
|
const i = [
|
|
1085
1092
|
{ s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
|
|
@@ -1112,7 +1119,7 @@ const hn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os ===
|
|
|
1112
1119
|
];
|
|
1113
1120
|
for (const a in i) {
|
|
1114
1121
|
const l = i[a];
|
|
1115
|
-
if (l.r.test(
|
|
1122
|
+
if (l.r.test(n)) {
|
|
1116
1123
|
o = l.s;
|
|
1117
1124
|
break;
|
|
1118
1125
|
}
|
|
@@ -1122,10 +1129,10 @@ const hn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os ===
|
|
|
1122
1129
|
case "Mac OS":
|
|
1123
1130
|
case "Mac OS X":
|
|
1124
1131
|
case "Android":
|
|
1125
|
-
r = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(
|
|
1132
|
+
r = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(n)[1];
|
|
1126
1133
|
break;
|
|
1127
1134
|
case "iOS": {
|
|
1128
|
-
const a = /OS (\d+)_(\d+)_?(\d+)?/.exec(
|
|
1135
|
+
const a = /OS (\d+)_(\d+)_?(\d+)?/.exec(s);
|
|
1129
1136
|
a != null && a.length > 2 && (r = a[1] + "." + a[2] + "." + (parseInt(a[3]) | 0));
|
|
1130
1137
|
break;
|
|
1131
1138
|
}
|
|
@@ -1135,45 +1142,45 @@ const hn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os ===
|
|
|
1135
1142
|
osVersion: r
|
|
1136
1143
|
};
|
|
1137
1144
|
};
|
|
1138
|
-
function
|
|
1145
|
+
function ys() {
|
|
1139
1146
|
const e = navigator.userAgent;
|
|
1140
|
-
let
|
|
1141
|
-
if (/trident/i.test(
|
|
1142
|
-
return
|
|
1143
|
-
if (
|
|
1144
|
-
let t =
|
|
1147
|
+
let s, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
|
|
1148
|
+
if (/trident/i.test(n[1]))
|
|
1149
|
+
return s = /\brv[ :]+(\d+)/g.exec(e) || [], { name: "ie", version: s[1] || "" };
|
|
1150
|
+
if (n[1] === "Chrome" && (s = e.match(/\bOPR|Edge\/(\d+)/), s != null)) {
|
|
1151
|
+
let t = s[1];
|
|
1145
1152
|
if (!t) {
|
|
1146
|
-
const o = e.split(
|
|
1153
|
+
const o = e.split(s[0] + "/");
|
|
1147
1154
|
o.length > 1 && (t = o[1]);
|
|
1148
1155
|
}
|
|
1149
1156
|
return { name: "opera", version: t };
|
|
1150
1157
|
}
|
|
1151
|
-
return
|
|
1152
|
-
name:
|
|
1153
|
-
version:
|
|
1158
|
+
return n = n[2] ? [n[1], n[2]] : [navigator.appName, navigator.appVersion, "-?"], (s = e.match(/version\/(\d+)/i)) != null && n.splice(1, 1, s[1]), {
|
|
1159
|
+
name: n[0].toLowerCase(),
|
|
1160
|
+
version: n[1]
|
|
1154
1161
|
};
|
|
1155
1162
|
}
|
|
1156
|
-
const
|
|
1157
|
-
const { name: e, version:
|
|
1158
|
-
if (e === "chrome" && parseInt(
|
|
1163
|
+
const gs = () => {
|
|
1164
|
+
const { name: e, version: s } = ys();
|
|
1165
|
+
if (e === "chrome" && parseInt(s) <= 70 || e === "opera" && (!s || parseInt(s.split(".")[0]) < 80) || e === "ie")
|
|
1159
1166
|
return !1;
|
|
1160
|
-
const
|
|
1161
|
-
return !
|
|
1162
|
-
},
|
|
1163
|
-
let
|
|
1167
|
+
const n = hs(navigator);
|
|
1168
|
+
return !ds(n);
|
|
1169
|
+
}, ks = async (e) => {
|
|
1170
|
+
let s;
|
|
1164
1171
|
if (e.tokens != null)
|
|
1165
1172
|
return !1;
|
|
1166
1173
|
e.publishEvent(m.tryKeepExistingSessionAsync_begin, {});
|
|
1167
1174
|
try {
|
|
1168
|
-
const
|
|
1169
|
-
if (
|
|
1170
|
-
const { tokens: o } = await
|
|
1175
|
+
const n = e.configuration, t = await e.initAsync(n.authority, n.authority_configuration);
|
|
1176
|
+
if (s = await I(n, e.configurationName), s) {
|
|
1177
|
+
const { tokens: o } = await s.initAsync(t, "tryKeepExistingSessionAsync", n);
|
|
1171
1178
|
if (o) {
|
|
1172
|
-
|
|
1173
|
-
const i =
|
|
1179
|
+
s.startKeepAliveServiceWorker(), e.tokens = o;
|
|
1180
|
+
const i = s.getLoginParams(e.configurationName);
|
|
1174
1181
|
e.timeoutId = J(e, e.tokens.expiresAt, i.extras);
|
|
1175
|
-
const r = await
|
|
1176
|
-
return await e.startCheckSessionAsync(t.check_session_iframe,
|
|
1182
|
+
const r = await s.getSessionStateAsync();
|
|
1183
|
+
return await e.startCheckSessionAsync(t.check_session_iframe, n.client_id, r), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1177
1184
|
success: !0,
|
|
1178
1185
|
message: "tokens inside ServiceWorker are valid"
|
|
1179
1186
|
}), !0;
|
|
@@ -1183,16 +1190,16 @@ const kn = () => {
|
|
|
1183
1190
|
message: "no exiting session found"
|
|
1184
1191
|
});
|
|
1185
1192
|
} else {
|
|
1186
|
-
|
|
1193
|
+
n.service_worker_relative_url && e.publishEvent(m.service_worker_not_supported_by_browser, {
|
|
1187
1194
|
message: "service worker is not supported by this browser"
|
|
1188
1195
|
});
|
|
1189
|
-
const o = O(e.configurationName,
|
|
1196
|
+
const o = O(e.configurationName, n.storage ?? sessionStorage), { tokens: i } = await o.initAsync();
|
|
1190
1197
|
if (i) {
|
|
1191
|
-
e.tokens = X(i, null,
|
|
1198
|
+
e.tokens = X(i, null, n.token_renew_mode);
|
|
1192
1199
|
const r = o.getLoginParams();
|
|
1193
1200
|
e.timeoutId = J(e, e.tokens.expiresAt, r.extras);
|
|
1194
1201
|
const a = await o.getSessionStateAsync();
|
|
1195
|
-
return await e.startCheckSessionAsync(t.check_session_iframe,
|
|
1202
|
+
return await e.startCheckSessionAsync(t.check_session_iframe, n.client_id, a), n.preload_user_info && await e.userInfoAsync(), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1196
1203
|
success: !0,
|
|
1197
1204
|
message: "tokens inside storage are valid"
|
|
1198
1205
|
}), !0;
|
|
@@ -1200,124 +1207,126 @@ const kn = () => {
|
|
|
1200
1207
|
}
|
|
1201
1208
|
return e.publishEvent(m.tryKeepExistingSessionAsync_end, {
|
|
1202
1209
|
success: !1,
|
|
1203
|
-
message:
|
|
1210
|
+
message: s ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
|
|
1204
1211
|
}), !1;
|
|
1205
|
-
} catch (
|
|
1206
|
-
return console.error(
|
|
1212
|
+
} catch (n) {
|
|
1213
|
+
return console.error(n), s && await s.clearAsync(), e.publishEvent(m.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
|
|
1207
1214
|
}
|
|
1208
|
-
},
|
|
1215
|
+
}, ms = () => fetch;
|
|
1209
1216
|
class te {
|
|
1210
|
-
constructor(
|
|
1211
|
-
this.authorizationEndpoint =
|
|
1217
|
+
constructor(s) {
|
|
1218
|
+
this.authorizationEndpoint = s.authorization_endpoint, this.tokenEndpoint = s.token_endpoint, this.revocationEndpoint = s.revocation_endpoint, this.userInfoEndpoint = s.userinfo_endpoint, this.checkSessionIframe = s.check_session_iframe, this.issuer = s.issuer, this.endSessionEndpoint = s.end_session_endpoint;
|
|
1212
1219
|
}
|
|
1213
1220
|
}
|
|
1214
|
-
const x = {},
|
|
1215
|
-
const { parsedTokens:
|
|
1216
|
-
return e.timeoutId = J(e,
|
|
1217
|
-
},
|
|
1218
|
-
constructor(
|
|
1221
|
+
const x = {}, ps = (e, s = new Y()) => (n, t = "default") => (x[t] || (x[t] = new C(n, t, e, s)), x[t]), ws = async (e) => {
|
|
1222
|
+
const { parsedTokens: s, callbackPath: n } = await e.loginCallbackAsync();
|
|
1223
|
+
return e.timeoutId = J(e, s.expiresAt), { callbackPath: n };
|
|
1224
|
+
}, As = (e) => Math.floor(Math.random() * e), F = class F {
|
|
1225
|
+
constructor(s, n = "default", t, o = new Y()) {
|
|
1219
1226
|
this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
|
|
1220
|
-
let i =
|
|
1221
|
-
|
|
1222
|
-
let r =
|
|
1227
|
+
let i = s.silent_login_uri;
|
|
1228
|
+
s.silent_redirect_uri && !s.silent_login_uri && (i = `${s.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
|
|
1229
|
+
let r = s.refresh_time_before_tokens_expiration_in_second ?? 120;
|
|
1223
1230
|
r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new Y();
|
|
1224
|
-
const a =
|
|
1231
|
+
const a = s.service_worker_update_require_callback ?? Le(this.location);
|
|
1225
1232
|
this.configuration = {
|
|
1226
|
-
...
|
|
1233
|
+
...s,
|
|
1227
1234
|
silent_login_uri: i,
|
|
1228
|
-
token_automatic_renew_mode:
|
|
1229
|
-
monitor_session:
|
|
1235
|
+
token_automatic_renew_mode: s.token_automatic_renew_mode ?? V.AutomaticBeforeTokenExpiration,
|
|
1236
|
+
monitor_session: s.monitor_session ?? !1,
|
|
1230
1237
|
refresh_time_before_tokens_expiration_in_second: r,
|
|
1231
|
-
silent_login_timeout:
|
|
1232
|
-
token_renew_mode:
|
|
1233
|
-
demonstrating_proof_of_possession:
|
|
1234
|
-
authority_timeout_wellknowurl_in_millisecond:
|
|
1235
|
-
logout_tokens_to_invalidate:
|
|
1238
|
+
silent_login_timeout: s.silent_login_timeout ?? 12e3,
|
|
1239
|
+
token_renew_mode: s.token_renew_mode ?? Z.access_token_or_id_token_invalid,
|
|
1240
|
+
demonstrating_proof_of_possession: s.demonstrating_proof_of_possession ?? !1,
|
|
1241
|
+
authority_timeout_wellknowurl_in_millisecond: s.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
|
|
1242
|
+
logout_tokens_to_invalidate: s.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
|
|
1236
1243
|
service_worker_update_require_callback: a,
|
|
1237
|
-
service_worker_activate:
|
|
1238
|
-
demonstrating_proof_of_possession_configuration:
|
|
1239
|
-
preload_user_info:
|
|
1240
|
-
}, this.getFetch = t ??
|
|
1244
|
+
service_worker_activate: s.service_worker_activate ?? gs,
|
|
1245
|
+
demonstrating_proof_of_possession_configuration: s.demonstrating_proof_of_possession_configuration ?? Ke,
|
|
1246
|
+
preload_user_info: s.preload_user_info ?? !1
|
|
1247
|
+
}, this.getFetch = t ?? ms, this.configurationName = n, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
|
|
1241
1248
|
}
|
|
1242
|
-
subscribeEvents(
|
|
1243
|
-
const
|
|
1244
|
-
return this.events.push({ id:
|
|
1249
|
+
subscribeEvents(s) {
|
|
1250
|
+
const n = As(9999999999999).toString();
|
|
1251
|
+
return this.events.push({ id: n, func: s }), n;
|
|
1245
1252
|
}
|
|
1246
|
-
removeEventSubscription(
|
|
1247
|
-
const
|
|
1248
|
-
this.events =
|
|
1253
|
+
removeEventSubscription(s) {
|
|
1254
|
+
const n = this.events.filter((t) => t.id !== s);
|
|
1255
|
+
this.events = n;
|
|
1249
1256
|
}
|
|
1250
|
-
publishEvent(
|
|
1257
|
+
publishEvent(s, n) {
|
|
1251
1258
|
this.events.forEach((t) => {
|
|
1252
|
-
t.func(
|
|
1259
|
+
t.func(s, n);
|
|
1253
1260
|
});
|
|
1254
1261
|
}
|
|
1255
|
-
static get(
|
|
1256
|
-
const
|
|
1257
|
-
if (!Object.prototype.hasOwnProperty.call(x,
|
|
1262
|
+
static get(s = "default") {
|
|
1263
|
+
const n = typeof process > "u";
|
|
1264
|
+
if (!Object.prototype.hasOwnProperty.call(x, s) && n)
|
|
1258
1265
|
throw Error(`OIDC library does seem initialized.
|
|
1259
|
-
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${
|
|
1260
|
-
return x[
|
|
1266
|
+
Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${s}"></OidcProvider> component.`);
|
|
1267
|
+
return x[s];
|
|
1261
1268
|
}
|
|
1262
1269
|
_silentLoginCallbackFromIFrame() {
|
|
1263
1270
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1264
|
-
const
|
|
1265
|
-
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState:
|
|
1271
|
+
const s = this.location, n = G(s.getCurrentHref());
|
|
1272
|
+
window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: n.session_state })}`, s.getOrigin());
|
|
1266
1273
|
}
|
|
1267
1274
|
}
|
|
1268
|
-
_silentLoginErrorCallbackFromIFrame(
|
|
1275
|
+
_silentLoginErrorCallbackFromIFrame(s = null) {
|
|
1269
1276
|
if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
|
|
1270
|
-
const
|
|
1271
|
-
t.error ? window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: t.error })}`,
|
|
1277
|
+
const n = this.location, t = G(n.getCurrentHref());
|
|
1278
|
+
t.error ? window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: t.error })}`, n.getOrigin()) : window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({ error: s == null ? "" : s.toString() })}`, n.getOrigin());
|
|
1272
1279
|
}
|
|
1273
1280
|
}
|
|
1274
1281
|
async silentLoginCallbackAsync() {
|
|
1275
1282
|
try {
|
|
1276
1283
|
await this.loginCallbackAsync(!0), this._silentLoginCallbackFromIFrame();
|
|
1277
|
-
} catch (
|
|
1278
|
-
console.error(
|
|
1284
|
+
} catch (s) {
|
|
1285
|
+
console.error(s), this._silentLoginErrorCallbackFromIFrame(s);
|
|
1279
1286
|
}
|
|
1280
1287
|
}
|
|
1281
|
-
async initAsync(
|
|
1288
|
+
async initAsync(s, n) {
|
|
1282
1289
|
if (this.initPromise !== null)
|
|
1283
1290
|
return this.initPromise;
|
|
1284
1291
|
const t = async () => {
|
|
1285
|
-
if (
|
|
1292
|
+
if (n != null)
|
|
1286
1293
|
return new te({
|
|
1287
|
-
authorization_endpoint:
|
|
1288
|
-
end_session_endpoint:
|
|
1289
|
-
revocation_endpoint:
|
|
1290
|
-
token_endpoint:
|
|
1291
|
-
userinfo_endpoint:
|
|
1292
|
-
check_session_iframe:
|
|
1293
|
-
issuer:
|
|
1294
|
+
authorization_endpoint: n.authorization_endpoint,
|
|
1295
|
+
end_session_endpoint: n.end_session_endpoint,
|
|
1296
|
+
revocation_endpoint: n.revocation_endpoint,
|
|
1297
|
+
token_endpoint: n.token_endpoint,
|
|
1298
|
+
userinfo_endpoint: n.userinfo_endpoint,
|
|
1299
|
+
check_session_iframe: n.check_session_iframe,
|
|
1300
|
+
issuer: n.issuer
|
|
1294
1301
|
});
|
|
1295
1302
|
const i = await I(this.configuration, this.configurationName) ? window.localStorage : null;
|
|
1296
|
-
return await Qe(this.getFetch())(
|
|
1303
|
+
return await Qe(this.getFetch())(s, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, i, this.configuration.authority_timeout_wellknowurl_in_millisecond);
|
|
1297
1304
|
};
|
|
1298
|
-
return this.initPromise = t(), this.initPromise.
|
|
1305
|
+
return this.initPromise = t(), this.initPromise.finally(() => {
|
|
1306
|
+
this.initPromise = null;
|
|
1307
|
+
});
|
|
1299
1308
|
}
|
|
1300
1309
|
async tryKeepExistingSessionAsync() {
|
|
1301
|
-
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise =
|
|
1310
|
+
return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = ks(this), this.tryKeepExistingSessionPromise.then((s) => (this.tryKeepExistingSessionPromise = null, s)));
|
|
1302
1311
|
}
|
|
1303
|
-
async startCheckSessionAsync(
|
|
1304
|
-
await
|
|
1312
|
+
async startCheckSessionAsync(s, n, t, o = !1) {
|
|
1313
|
+
await is(this, x, this.configuration)(s, n, t, o);
|
|
1305
1314
|
}
|
|
1306
|
-
async loginAsync(
|
|
1307
|
-
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : i ?
|
|
1315
|
+
async loginAsync(s = void 0, n = null, t = !1, o = void 0, i = !1) {
|
|
1316
|
+
return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : i ? os(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(n, o) : (this.loginPromise = as(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(s, n, t, o), this.loginPromise.then((r) => (this.loginPromise = null, r)));
|
|
1308
1317
|
}
|
|
1309
|
-
async loginCallbackAsync(
|
|
1318
|
+
async loginCallbackAsync(s = !1) {
|
|
1310
1319
|
if (this.loginCallbackPromise !== null)
|
|
1311
1320
|
return this.loginCallbackPromise;
|
|
1312
|
-
const
|
|
1313
|
-
const t = await
|
|
1321
|
+
const n = async () => {
|
|
1322
|
+
const t = await cs(this)(s), o = t.tokens;
|
|
1314
1323
|
return this.tokens = o, await I(this.configuration, this.configurationName) || O(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(F.eventNames.token_aquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), { parsedTokens: o, state: t.state, callbackPath: t.callbackPath };
|
|
1315
1324
|
};
|
|
1316
|
-
return this.loginCallbackPromise =
|
|
1325
|
+
return this.loginCallbackPromise = n(), this.loginCallbackPromise.then((t) => (this.loginCallbackPromise = null, t));
|
|
1317
1326
|
}
|
|
1318
|
-
async generateDemonstrationOfProofOfPossessionAsync(
|
|
1327
|
+
async generateDemonstrationOfProofOfPossessionAsync(s, n, t, o = {}) {
|
|
1319
1328
|
const i = this.configuration, r = {
|
|
1320
|
-
ath: await ve(
|
|
1329
|
+
ath: await ve(s),
|
|
1321
1330
|
...o
|
|
1322
1331
|
}, a = await I(i, this.configurationName);
|
|
1323
1332
|
let l;
|
|
@@ -1325,65 +1334,65 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
|
|
|
1325
1334
|
return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}`;
|
|
1326
1335
|
const f = O(this.configurationName, i.storage);
|
|
1327
1336
|
let u = await f.getDemonstratingProofOfPossessionJwkAsync();
|
|
1328
|
-
return l = await f.getDemonstratingProofOfPossessionNonce(), l && (r.nonce = l), await Ae(window)(i.demonstrating_proof_of_possession_configuration)(u, t,
|
|
1337
|
+
return l = await f.getDemonstratingProofOfPossessionNonce(), l && (r.nonce = l), await Ae(window)(i.demonstrating_proof_of_possession_configuration)(u, t, n, r);
|
|
1329
1338
|
}
|
|
1330
1339
|
loginCallbackWithAutoTokensRenewAsync() {
|
|
1331
|
-
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise =
|
|
1340
|
+
return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = ws(this), this.loginCallbackWithAutoTokensRenewPromise.then((s) => (this.loginCallbackWithAutoTokensRenewPromise = null, s)));
|
|
1332
1341
|
}
|
|
1333
|
-
userInfoAsync(
|
|
1334
|
-
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise =
|
|
1342
|
+
userInfoAsync(s = !1, n = !1) {
|
|
1343
|
+
return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = fs(this)(s, n), this.userInfoPromise.then((t) => (this.userInfoPromise = null, t)));
|
|
1335
1344
|
}
|
|
1336
|
-
async renewTokensAsync(
|
|
1345
|
+
async renewTokensAsync(s = null) {
|
|
1337
1346
|
if (this.renewTokensPromise !== null)
|
|
1338
1347
|
return this.renewTokensPromise;
|
|
1339
1348
|
if (this.timeoutId)
|
|
1340
|
-
return M.clearTimeout(this.timeoutId), this.renewTokensPromise = Te(this, !0,
|
|
1349
|
+
return M.clearTimeout(this.timeoutId), this.renewTokensPromise = Te(this, !0, s), this.renewTokensPromise.then((n) => (this.renewTokensPromise = null, n));
|
|
1341
1350
|
}
|
|
1342
|
-
async destroyAsync(
|
|
1343
|
-
return await
|
|
1351
|
+
async destroyAsync(s) {
|
|
1352
|
+
return await us(this)(s);
|
|
1344
1353
|
}
|
|
1345
|
-
async logoutSameTabAsync(
|
|
1346
|
-
this.configuration.monitor_session && this.configuration.client_id ===
|
|
1354
|
+
async logoutSameTabAsync(s, n) {
|
|
1355
|
+
this.configuration.monitor_session && this.configuration.client_id === s && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_same_tab, { mmessage: "SessionMonitor", sub: n }));
|
|
1347
1356
|
}
|
|
1348
|
-
async logoutOtherTabAsync(
|
|
1349
|
-
this.configuration.monitor_session && this.configuration.client_id ===
|
|
1357
|
+
async logoutOtherTabAsync(s, n) {
|
|
1358
|
+
this.configuration.monitor_session && this.configuration.client_id === s && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: n }));
|
|
1350
1359
|
}
|
|
1351
|
-
async logoutAsync(
|
|
1352
|
-
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise =
|
|
1360
|
+
async logoutAsync(s = void 0, n = null) {
|
|
1361
|
+
return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = _s(this, x, this.getFetch(), console, this.location)(s, n), this.logoutPromise.then((t) => (this.logoutPromise = null, t)));
|
|
1353
1362
|
}
|
|
1354
1363
|
};
|
|
1355
|
-
F.getOrCreate = (
|
|
1364
|
+
F.getOrCreate = (s, n) => (t, o = "default") => ps(s, n)(t, o), F.eventNames = m;
|
|
1356
1365
|
let C = F;
|
|
1357
1366
|
const $ = class $ {
|
|
1358
|
-
constructor(
|
|
1359
|
-
this._oidc =
|
|
1367
|
+
constructor(s) {
|
|
1368
|
+
this._oidc = s;
|
|
1360
1369
|
}
|
|
1361
|
-
subscribeEvents(
|
|
1362
|
-
return this._oidc.subscribeEvents(
|
|
1370
|
+
subscribeEvents(s) {
|
|
1371
|
+
return this._oidc.subscribeEvents(s);
|
|
1363
1372
|
}
|
|
1364
|
-
removeEventSubscription(
|
|
1365
|
-
this._oidc.removeEventSubscription(
|
|
1373
|
+
removeEventSubscription(s) {
|
|
1374
|
+
this._oidc.removeEventSubscription(s);
|
|
1366
1375
|
}
|
|
1367
|
-
publishEvent(
|
|
1368
|
-
this._oidc.publishEvent(
|
|
1376
|
+
publishEvent(s, n) {
|
|
1377
|
+
this._oidc.publishEvent(s, n);
|
|
1369
1378
|
}
|
|
1370
|
-
static get(
|
|
1371
|
-
return new $(C.get(
|
|
1379
|
+
static get(s = "default") {
|
|
1380
|
+
return new $(C.get(s));
|
|
1372
1381
|
}
|
|
1373
1382
|
tryKeepExistingSessionAsync() {
|
|
1374
1383
|
return this._oidc.tryKeepExistingSessionAsync();
|
|
1375
1384
|
}
|
|
1376
|
-
loginAsync(
|
|
1377
|
-
return this._oidc.loginAsync(
|
|
1385
|
+
loginAsync(s = void 0, n = null, t = !1, o = void 0, i = !1) {
|
|
1386
|
+
return this._oidc.loginAsync(s, n, t, o, i);
|
|
1378
1387
|
}
|
|
1379
|
-
logoutAsync(
|
|
1380
|
-
return this._oidc.logoutAsync(
|
|
1388
|
+
logoutAsync(s = void 0, n = null) {
|
|
1389
|
+
return this._oidc.logoutAsync(s, n);
|
|
1381
1390
|
}
|
|
1382
1391
|
silentLoginCallbackAsync() {
|
|
1383
1392
|
return this._oidc.silentLoginCallbackAsync();
|
|
1384
1393
|
}
|
|
1385
|
-
renewTokensAsync(
|
|
1386
|
-
return this._oidc.renewTokensAsync(
|
|
1394
|
+
renewTokensAsync(s = null) {
|
|
1395
|
+
return this._oidc.renewTokensAsync(s);
|
|
1387
1396
|
}
|
|
1388
1397
|
loginCallbackAsync() {
|
|
1389
1398
|
return this._oidc.loginCallbackWithAutoTokensRenewAsync();
|
|
@@ -1394,30 +1403,30 @@ const $ = class $ {
|
|
|
1394
1403
|
get configuration() {
|
|
1395
1404
|
return this._oidc.configuration;
|
|
1396
1405
|
}
|
|
1397
|
-
async generateDemonstrationOfProofOfPossessionAsync(
|
|
1398
|
-
return this._oidc.generateDemonstrationOfProofOfPossessionAsync(
|
|
1406
|
+
async generateDemonstrationOfProofOfPossessionAsync(s, n, t, o = {}) {
|
|
1407
|
+
return this._oidc.generateDemonstrationOfProofOfPossessionAsync(s, n, t, o);
|
|
1399
1408
|
}
|
|
1400
|
-
async getValidTokenAsync(
|
|
1401
|
-
return ge(this._oidc,
|
|
1409
|
+
async getValidTokenAsync(s = 200, n = 50) {
|
|
1410
|
+
return ge(this._oidc, s, n);
|
|
1402
1411
|
}
|
|
1403
|
-
fetchWithTokens(
|
|
1404
|
-
return be(
|
|
1412
|
+
fetchWithTokens(s, n) {
|
|
1413
|
+
return be(s, this, n);
|
|
1405
1414
|
}
|
|
1406
|
-
async userInfoAsync(
|
|
1407
|
-
return this._oidc.userInfoAsync(
|
|
1415
|
+
async userInfoAsync(s = !1, n = !1) {
|
|
1416
|
+
return this._oidc.userInfoAsync(s, n);
|
|
1408
1417
|
}
|
|
1409
1418
|
userInfo() {
|
|
1410
1419
|
return this._oidc.userInfo;
|
|
1411
1420
|
}
|
|
1412
1421
|
};
|
|
1413
|
-
$.getOrCreate = (
|
|
1422
|
+
$.getOrCreate = (s, n = new Y()) => (t, o = "default") => new $(C.getOrCreate(s, n)(t, o)), $.eventNames = C.eventNames;
|
|
1414
1423
|
let ye = $;
|
|
1415
1424
|
export {
|
|
1416
1425
|
ye as OidcClient,
|
|
1417
1426
|
Y as OidcLocation,
|
|
1418
1427
|
V as TokenAutomaticRenewMode,
|
|
1419
1428
|
Z as TokenRenewMode,
|
|
1420
|
-
|
|
1429
|
+
ms as getFetchDefault,
|
|
1421
1430
|
G as getParseQueryStringFromLocation,
|
|
1422
|
-
|
|
1431
|
+
Ss as getPath
|
|
1423
1432
|
};
|