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