zudoku 0.3.1-dev.20 → 0.3.1-dev.21
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/config/config.d.ts +0 -3
- package/dist/lib/authentication/providers/auth0.js +8 -22
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +1 -3
- package/dist/lib/authentication/providers/openid.js +4 -18
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/lib/zudoku.auth-auth0.js +19 -31
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-openid.js +321 -333
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/authentication/providers/auth0.tsx +10 -30
- package/src/lib/authentication/providers/openid.tsx +6 -21
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Le = (t, e,
|
|
3
|
-
var
|
|
4
|
-
import { j as
|
|
1
|
+
var Ue = Object.defineProperty;
|
|
2
|
+
var Le = (t, e, r) => e in t ? Ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var _ = (t, e, r) => Le(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { j as E } from "./jsx-runtime-B6kdoens.js";
|
|
5
5
|
import { c as Ce, a as Ie } from "./_commonjsHelpers-BVfed4GL.js";
|
|
6
6
|
import { A as je } from "./AuthenticationPlugin-owbEUimP.js";
|
|
7
|
-
import { useState as
|
|
8
|
-
import { D as
|
|
7
|
+
import { useState as Je, useRef as Oe, useEffect as Ne } from "react";
|
|
8
|
+
import { D as ze } from "./DeveloperHint-BQSFXH01.js";
|
|
9
9
|
import { E as De } from "./ErrorPage-PUg985n_.js";
|
|
10
10
|
import { S as Ke } from "./Spinner-CvXZ7QK4.js";
|
|
11
11
|
import { S as We } from "./Markdown-Chb9VIBv.js";
|
|
12
12
|
import { e as He } from "./index-Yjb2PyPF.js";
|
|
13
|
-
import { u as
|
|
13
|
+
import { u as z } from "./state-DsXXkBLH.js";
|
|
14
14
|
var fe = { exports: {} };
|
|
15
15
|
(function(t) {
|
|
16
|
-
(function(e,
|
|
17
|
-
t.exports ? t.exports =
|
|
16
|
+
(function(e, r) {
|
|
17
|
+
t.exports ? t.exports = r() : e.log = r();
|
|
18
18
|
})(Ce, function() {
|
|
19
19
|
var e = function() {
|
|
20
|
-
},
|
|
20
|
+
}, r = "undefined", o = typeof window !== r && typeof window.navigator !== r && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
21
21
|
"trace",
|
|
22
22
|
"debug",
|
|
23
23
|
"info",
|
|
24
24
|
"warn",
|
|
25
25
|
"error"
|
|
26
|
-
],
|
|
26
|
+
], n = {}, i = null;
|
|
27
27
|
function u(l, w) {
|
|
28
28
|
var c = l[w];
|
|
29
29
|
if (typeof c.bind == "function")
|
|
@@ -36,34 +36,34 @@ var fe = { exports: {} };
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function f() {
|
|
40
40
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
41
41
|
}
|
|
42
42
|
function m(l) {
|
|
43
|
-
return l === "debug" && (l = "log"), typeof console ===
|
|
43
|
+
return l === "debug" && (l = "log"), typeof console === r ? !1 : l === "trace" && o ? f : console[l] !== void 0 ? u(console, l) : console.log !== void 0 ? u(console, "log") : e;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function y() {
|
|
46
46
|
for (var l = this.getLevel(), w = 0; w < s.length; w++) {
|
|
47
47
|
var c = s[w];
|
|
48
48
|
this[c] = w < l ? e : this.methodFactory(c, l, this.name);
|
|
49
49
|
}
|
|
50
|
-
if (this.log = this.debug, typeof console ===
|
|
50
|
+
if (this.log = this.debug, typeof console === r && l < this.levels.SILENT)
|
|
51
51
|
return "No console available for logging";
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function b(l) {
|
|
54
54
|
return function() {
|
|
55
|
-
typeof console !==
|
|
55
|
+
typeof console !== r && (y.call(this), this[l].apply(this, arguments));
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return m(l) ||
|
|
58
|
+
function h(l, w, c) {
|
|
59
|
+
return m(l) || b.apply(this, arguments);
|
|
60
60
|
}
|
|
61
61
|
function R(l, w) {
|
|
62
|
-
var c = this,
|
|
62
|
+
var c = this, O, B, x, v = "loglevel";
|
|
63
63
|
typeof l == "string" ? v += ":" + l : typeof l == "symbol" && (v = void 0);
|
|
64
64
|
function Re(d) {
|
|
65
65
|
var g = (s[d] || "silent").toUpperCase();
|
|
66
|
-
if (!(typeof window ===
|
|
66
|
+
if (!(typeof window === r || !v)) {
|
|
67
67
|
try {
|
|
68
68
|
window.localStorage[v] = g;
|
|
69
69
|
return;
|
|
@@ -75,18 +75,18 @@ var fe = { exports: {} };
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function ne() {
|
|
79
79
|
var d;
|
|
80
|
-
if (!(typeof window ===
|
|
80
|
+
if (!(typeof window === r || !v)) {
|
|
81
81
|
try {
|
|
82
82
|
d = window.localStorage[v];
|
|
83
83
|
} catch {
|
|
84
84
|
}
|
|
85
|
-
if (typeof d ===
|
|
85
|
+
if (typeof d === r)
|
|
86
86
|
try {
|
|
87
|
-
var g = window.document.cookie,
|
|
87
|
+
var g = window.document.cookie, N = encodeURIComponent(v), ie = g.indexOf(N + "=");
|
|
88
88
|
ie !== -1 && (d = /^([^;]+)/.exec(
|
|
89
|
-
g.slice(ie +
|
|
89
|
+
g.slice(ie + N.length + 1)
|
|
90
90
|
)[1]);
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
@@ -94,7 +94,7 @@ var fe = { exports: {} };
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
function Pe() {
|
|
97
|
-
if (!(typeof window ===
|
|
97
|
+
if (!(typeof window === r || !v)) {
|
|
98
98
|
try {
|
|
99
99
|
window.localStorage.removeItem(v);
|
|
100
100
|
} catch {
|
|
@@ -118,42 +118,42 @@ var fe = { exports: {} };
|
|
|
118
118
|
WARN: 3,
|
|
119
119
|
ERROR: 4,
|
|
120
120
|
SILENT: 5
|
|
121
|
-
}, c.methodFactory = w ||
|
|
122
|
-
return
|
|
121
|
+
}, c.methodFactory = w || h, c.getLevel = function() {
|
|
122
|
+
return x ?? B ?? O;
|
|
123
123
|
}, c.setLevel = function(d, g) {
|
|
124
|
-
return
|
|
124
|
+
return x = L(d), g !== !1 && Re(x), y.call(c);
|
|
125
125
|
}, c.setDefaultLevel = function(d) {
|
|
126
|
-
B = L(d),
|
|
126
|
+
B = L(d), ne() || c.setLevel(d, !1);
|
|
127
127
|
}, c.resetLevel = function() {
|
|
128
|
-
|
|
128
|
+
x = null, Pe(), y.call(c);
|
|
129
129
|
}, c.enableAll = function(d) {
|
|
130
130
|
c.setLevel(c.levels.TRACE, d);
|
|
131
131
|
}, c.disableAll = function(d) {
|
|
132
132
|
c.setLevel(c.levels.SILENT, d);
|
|
133
133
|
}, c.rebuild = function() {
|
|
134
|
-
if (i !== c && (
|
|
135
|
-
for (var d in
|
|
136
|
-
|
|
137
|
-
},
|
|
134
|
+
if (i !== c && (O = L(i.getLevel())), y.call(c), i === c)
|
|
135
|
+
for (var d in n)
|
|
136
|
+
n[d].rebuild();
|
|
137
|
+
}, O = L(
|
|
138
138
|
i ? i.getLevel() : "WARN"
|
|
139
139
|
);
|
|
140
|
-
var oe =
|
|
141
|
-
oe != null && (
|
|
140
|
+
var oe = ne();
|
|
141
|
+
oe != null && (x = L(oe)), y.call(c);
|
|
142
142
|
}
|
|
143
143
|
i = new R(), i.getLogger = function(w) {
|
|
144
144
|
if (typeof w != "symbol" && typeof w != "string" || w === "")
|
|
145
145
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
146
|
-
var c =
|
|
147
|
-
return c || (c =
|
|
146
|
+
var c = n[w];
|
|
147
|
+
return c || (c = n[w] = new R(
|
|
148
148
|
w,
|
|
149
149
|
i.methodFactory
|
|
150
150
|
)), c;
|
|
151
151
|
};
|
|
152
|
-
var P = typeof window !==
|
|
152
|
+
var P = typeof window !== r ? window.log : void 0;
|
|
153
153
|
return i.noConflict = function() {
|
|
154
|
-
return typeof window !==
|
|
154
|
+
return typeof window !== r && window.log === i && (window.log = P), i;
|
|
155
155
|
}, i.getLoggers = function() {
|
|
156
|
-
return
|
|
156
|
+
return n;
|
|
157
157
|
}, i.default = i, i;
|
|
158
158
|
});
|
|
159
159
|
})(fe);
|
|
@@ -179,21 +179,21 @@ const se = 32768;
|
|
|
179
179
|
function qe(t) {
|
|
180
180
|
t instanceof ArrayBuffer && (t = new Uint8Array(t));
|
|
181
181
|
const e = [];
|
|
182
|
-
for (let
|
|
183
|
-
e.push(String.fromCharCode.apply(null, t.subarray(
|
|
182
|
+
for (let r = 0; r < t.byteLength; r += se)
|
|
183
|
+
e.push(String.fromCharCode.apply(null, t.subarray(r, r + se)));
|
|
184
184
|
return btoa(e.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
185
185
|
}
|
|
186
186
|
function Ge(t) {
|
|
187
187
|
try {
|
|
188
|
-
const e = atob(t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")),
|
|
188
|
+
const e = atob(t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), r = new Uint8Array(e.length);
|
|
189
189
|
for (let o = 0; o < e.length; o++)
|
|
190
|
-
|
|
191
|
-
return
|
|
190
|
+
r[o] = e.charCodeAt(o);
|
|
191
|
+
return r;
|
|
192
192
|
} catch (e) {
|
|
193
193
|
throw new a("The input to be decoded is not correctly encoded.", { cause: e });
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function k(t) {
|
|
197
197
|
return typeof t == "string" ? Ge(t) : qe(t);
|
|
198
198
|
}
|
|
199
199
|
class Ve {
|
|
@@ -201,35 +201,35 @@ class Ve {
|
|
|
201
201
|
this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize = e;
|
|
202
202
|
}
|
|
203
203
|
get(e) {
|
|
204
|
-
let
|
|
205
|
-
if (
|
|
206
|
-
return
|
|
207
|
-
if (
|
|
208
|
-
return this.update(e,
|
|
204
|
+
let r = this.cache.get(e);
|
|
205
|
+
if (r)
|
|
206
|
+
return r;
|
|
207
|
+
if (r = this._cache.get(e))
|
|
208
|
+
return this.update(e, r), r;
|
|
209
209
|
}
|
|
210
210
|
has(e) {
|
|
211
211
|
return this.cache.has(e) || this._cache.has(e);
|
|
212
212
|
}
|
|
213
|
-
set(e,
|
|
214
|
-
return this.cache.has(e) ? this.cache.set(e,
|
|
213
|
+
set(e, r) {
|
|
214
|
+
return this.cache.has(e) ? this.cache.set(e, r) : this.update(e, r), this;
|
|
215
215
|
}
|
|
216
216
|
delete(e) {
|
|
217
217
|
return this.cache.has(e) ? this.cache.delete(e) : this._cache.has(e) ? this._cache.delete(e) : !1;
|
|
218
218
|
}
|
|
219
|
-
update(e,
|
|
220
|
-
this.cache.set(e,
|
|
219
|
+
update(e, r) {
|
|
220
|
+
this.cache.set(e, r), this.cache.size >= this.maxSize && (this._cache = this.cache, this.cache = /* @__PURE__ */ new Map());
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
class S extends Error {
|
|
224
224
|
constructor(e) {
|
|
225
|
-
var
|
|
226
|
-
super(e ?? "operation not supported"), this.name = this.constructor.name, (
|
|
225
|
+
var r;
|
|
226
|
+
super(e ?? "operation not supported"), this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
class Ye extends Error {
|
|
230
|
-
constructor(e,
|
|
230
|
+
constructor(e, r) {
|
|
231
231
|
var o;
|
|
232
|
-
super(e,
|
|
232
|
+
super(e, r), this.name = this.constructor.name, (o = Error.captureStackTrace) == null || o.call(Error, this, this.constructor);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
const a = Ye, pe = new Ve(100);
|
|
@@ -272,20 +272,20 @@ async function Qe(t, e) {
|
|
|
272
272
|
throw new TypeError('"issuerIdentifier" must be an instance of URL');
|
|
273
273
|
if (t.protocol !== "https:" && t.protocol !== "http:")
|
|
274
274
|
throw new TypeError('"issuer.protocol" must be "https:" or "http:"');
|
|
275
|
-
const
|
|
275
|
+
const r = new URL(t.href);
|
|
276
276
|
switch (e == null ? void 0 : e.algorithm) {
|
|
277
277
|
case void 0:
|
|
278
278
|
case "oidc":
|
|
279
|
-
|
|
279
|
+
r.pathname = `${r.pathname}/.well-known/openid-configuration`.replace("//", "/");
|
|
280
280
|
break;
|
|
281
281
|
case "oauth2":
|
|
282
|
-
|
|
282
|
+
r.pathname === "/" ? r.pathname = ".well-known/oauth-authorization-server" : r.pathname = `.well-known/oauth-authorization-server/${r.pathname}`.replace("//", "/");
|
|
283
283
|
break;
|
|
284
284
|
default:
|
|
285
285
|
throw new TypeError('"options.algorithm" must be "oidc" (default), or "oauth2"');
|
|
286
286
|
}
|
|
287
287
|
const o = $(e == null ? void 0 : e.headers);
|
|
288
|
-
return o.set("accept", "application/json"), ((e == null ? void 0 : e[X]) || fetch)(
|
|
288
|
+
return o.set("accept", "application/json"), ((e == null ? void 0 : e[X]) || fetch)(r.href, {
|
|
289
289
|
headers: Object.fromEntries(o.entries()),
|
|
290
290
|
method: "GET",
|
|
291
291
|
redirect: "manual",
|
|
@@ -302,23 +302,23 @@ async function Xe(t, e) {
|
|
|
302
302
|
throw new TypeError('"response" must be an instance of Response');
|
|
303
303
|
if (e.status !== 200)
|
|
304
304
|
throw new a('"response" is not a conform Authorization Server Metadata response');
|
|
305
|
-
|
|
306
|
-
let
|
|
305
|
+
re(e);
|
|
306
|
+
let r;
|
|
307
307
|
try {
|
|
308
|
-
|
|
308
|
+
r = await e.json();
|
|
309
309
|
} catch (o) {
|
|
310
310
|
throw new a('failed to parse "response" body as JSON', { cause: o });
|
|
311
311
|
}
|
|
312
|
-
if (!C(
|
|
312
|
+
if (!C(r))
|
|
313
313
|
throw new a('"response" body must be a top level object');
|
|
314
|
-
if (!p(
|
|
314
|
+
if (!p(r.issuer))
|
|
315
315
|
throw new a('"response" body "issuer" property must be a non-empty string');
|
|
316
|
-
if (new URL(
|
|
316
|
+
if (new URL(r.issuer).href !== t.href)
|
|
317
317
|
throw new a('"response" body "issuer" does not match "expectedIssuer"');
|
|
318
|
-
return
|
|
318
|
+
return r;
|
|
319
319
|
}
|
|
320
320
|
function F() {
|
|
321
|
-
return
|
|
321
|
+
return k(crypto.getRandomValues(new Uint8Array(32)));
|
|
322
322
|
}
|
|
323
323
|
function et() {
|
|
324
324
|
return F();
|
|
@@ -326,12 +326,12 @@ function et() {
|
|
|
326
326
|
function tt() {
|
|
327
327
|
return F();
|
|
328
328
|
}
|
|
329
|
-
async function
|
|
329
|
+
async function rt(t) {
|
|
330
330
|
if (!p(t))
|
|
331
331
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
332
|
-
return
|
|
332
|
+
return k(await crypto.subtle.digest("SHA-256", A(t)));
|
|
333
333
|
}
|
|
334
|
-
function
|
|
334
|
+
function nt(t) {
|
|
335
335
|
if (t instanceof CryptoKey)
|
|
336
336
|
return { key: t };
|
|
337
337
|
if (!((t == null ? void 0 : t.key) instanceof CryptoKey))
|
|
@@ -344,8 +344,8 @@ function ae(t) {
|
|
|
344
344
|
return encodeURIComponent(t).replace(/%20/g, "+");
|
|
345
345
|
}
|
|
346
346
|
function ot(t, e) {
|
|
347
|
-
const
|
|
348
|
-
return `Basic ${btoa(`${
|
|
347
|
+
const r = ae(t), o = ae(e);
|
|
348
|
+
return `Basic ${btoa(`${r}:${o}`)}`;
|
|
349
349
|
}
|
|
350
350
|
function it(t) {
|
|
351
351
|
switch (t.algorithm.hash.name) {
|
|
@@ -410,22 +410,22 @@ function M() {
|
|
|
410
410
|
return Math.floor(Date.now() / 1e3);
|
|
411
411
|
}
|
|
412
412
|
function ct(t, e) {
|
|
413
|
-
const
|
|
413
|
+
const r = M() + I(e);
|
|
414
414
|
return {
|
|
415
415
|
jti: F(),
|
|
416
416
|
aud: [t.issuer, t.token_endpoint],
|
|
417
|
-
exp:
|
|
418
|
-
iat:
|
|
419
|
-
nbf:
|
|
417
|
+
exp: r + 60,
|
|
418
|
+
iat: r,
|
|
419
|
+
nbf: r,
|
|
420
420
|
iss: e.client_id,
|
|
421
421
|
sub: e.client_id
|
|
422
422
|
};
|
|
423
423
|
}
|
|
424
|
-
async function ut(t, e,
|
|
424
|
+
async function ut(t, e, r, o) {
|
|
425
425
|
return be({
|
|
426
|
-
alg: me(
|
|
426
|
+
alg: me(r),
|
|
427
427
|
kid: o
|
|
428
|
-
}, ct(t, e),
|
|
428
|
+
}, ct(t, e), r);
|
|
429
429
|
}
|
|
430
430
|
function j(t) {
|
|
431
431
|
if (typeof t != "object" || t === null)
|
|
@@ -434,7 +434,7 @@ function j(t) {
|
|
|
434
434
|
throw new TypeError('"as.issuer" property must be a non-empty string');
|
|
435
435
|
return !0;
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function J(t) {
|
|
438
438
|
if (typeof t != "object" || t === null)
|
|
439
439
|
throw new TypeError('"client" must be an object');
|
|
440
440
|
if (!p(t.client_id))
|
|
@@ -454,53 +454,53 @@ function ue(t, e) {
|
|
|
454
454
|
if (e !== void 0)
|
|
455
455
|
throw new TypeError(`"client.client_secret" property must not be provided when ${t} client authentication method is used.`);
|
|
456
456
|
}
|
|
457
|
-
async function lt(t, e,
|
|
458
|
-
switch (
|
|
457
|
+
async function lt(t, e, r, o, s) {
|
|
458
|
+
switch (r.delete("client_secret"), r.delete("client_assertion_type"), r.delete("client_assertion"), e.token_endpoint_auth_method) {
|
|
459
459
|
case void 0:
|
|
460
460
|
case "client_secret_basic": {
|
|
461
461
|
q("client_secret_basic", s), o.set("authorization", ot(e.client_id, ce(e.client_secret)));
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
464
|
case "client_secret_post": {
|
|
465
|
-
q("client_secret_post", s),
|
|
465
|
+
q("client_secret_post", s), r.set("client_id", e.client_id), r.set("client_secret", ce(e.client_secret));
|
|
466
466
|
break;
|
|
467
467
|
}
|
|
468
468
|
case "private_key_jwt": {
|
|
469
469
|
if (ue("private_key_jwt", e.client_secret), s === void 0)
|
|
470
470
|
throw new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"');
|
|
471
|
-
const { key:
|
|
472
|
-
if (!ge(
|
|
471
|
+
const { key: n, kid: i } = nt(s);
|
|
472
|
+
if (!ge(n))
|
|
473
473
|
throw new TypeError('"options.clientPrivateKey.key" must be a private CryptoKey');
|
|
474
|
-
|
|
474
|
+
r.set("client_id", e.client_id), r.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), r.set("client_assertion", await ut(t, e, n, i));
|
|
475
475
|
break;
|
|
476
476
|
}
|
|
477
477
|
case "tls_client_auth":
|
|
478
478
|
case "self_signed_tls_client_auth":
|
|
479
479
|
case "none": {
|
|
480
|
-
ue(e.token_endpoint_auth_method, e.client_secret), q(e.token_endpoint_auth_method, s),
|
|
480
|
+
ue(e.token_endpoint_auth_method, e.client_secret), q(e.token_endpoint_auth_method, s), r.set("client_id", e.client_id);
|
|
481
481
|
break;
|
|
482
482
|
}
|
|
483
483
|
default:
|
|
484
484
|
throw new S("unsupported client token_endpoint_auth_method");
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
async function be(t, e,
|
|
488
|
-
if (!
|
|
487
|
+
async function be(t, e, r) {
|
|
488
|
+
if (!r.usages.includes("sign"))
|
|
489
489
|
throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"');
|
|
490
|
-
const o = `${
|
|
490
|
+
const o = `${k(A(JSON.stringify(t)))}.${k(A(JSON.stringify(e)))}`, s = k(await crypto.subtle.sign(Ee(r), r, A(o)));
|
|
491
491
|
return `${o}.${s}`;
|
|
492
492
|
}
|
|
493
|
-
async function dt(t, e,
|
|
494
|
-
const { privateKey: i, publicKey: u, nonce:
|
|
493
|
+
async function dt(t, e, r, o, s, n) {
|
|
494
|
+
const { privateKey: i, publicKey: u, nonce: f = pe.get(r.origin) } = e;
|
|
495
495
|
if (!ge(i))
|
|
496
496
|
throw new TypeError('"DPoP.privateKey" must be a private CryptoKey');
|
|
497
497
|
if (!Ze(u))
|
|
498
498
|
throw new TypeError('"DPoP.publicKey" must be a public CryptoKey');
|
|
499
|
-
if (
|
|
499
|
+
if (f !== void 0 && !p(f))
|
|
500
500
|
throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined');
|
|
501
501
|
if (!u.extractable)
|
|
502
502
|
throw new TypeError('"DPoP.publicKey.extractable" must be true');
|
|
503
|
-
const m = M() + s,
|
|
503
|
+
const m = M() + s, y = await be({
|
|
504
504
|
alg: me(i),
|
|
505
505
|
typ: "dpop+jwt",
|
|
506
506
|
jwk: await ft(u)
|
|
@@ -508,73 +508,73 @@ async function dt(t, e, n, o, s, r) {
|
|
|
508
508
|
iat: m,
|
|
509
509
|
jti: F(),
|
|
510
510
|
htm: o,
|
|
511
|
-
nonce:
|
|
512
|
-
htu: `${
|
|
513
|
-
ath:
|
|
511
|
+
nonce: f,
|
|
512
|
+
htu: `${r.origin}${r.pathname}`,
|
|
513
|
+
ath: n ? k(await crypto.subtle.digest("SHA-256", A(n))) : void 0
|
|
514
514
|
}, i);
|
|
515
|
-
t.set("dpop",
|
|
515
|
+
t.set("dpop", y);
|
|
516
516
|
}
|
|
517
517
|
let W;
|
|
518
518
|
async function ht(t) {
|
|
519
|
-
const { kty: e, e:
|
|
519
|
+
const { kty: e, e: r, n: o, x: s, y: n, crv: i } = await crypto.subtle.exportKey("jwk", t), u = { kty: e, e: r, n: o, x: s, y: n, crv: i };
|
|
520
520
|
return W.set(t, u), u;
|
|
521
521
|
}
|
|
522
522
|
async function ft(t) {
|
|
523
523
|
return W || (W = /* @__PURE__ */ new WeakMap()), W.get(t) || ht(t);
|
|
524
524
|
}
|
|
525
|
-
function pt(t, e,
|
|
525
|
+
function pt(t, e, r) {
|
|
526
526
|
if (typeof t != "string")
|
|
527
527
|
throw new TypeError(`"as.${e}" must be a string`);
|
|
528
528
|
return new URL(t);
|
|
529
529
|
}
|
|
530
|
-
function _e(t, e,
|
|
530
|
+
function _e(t, e, r) {
|
|
531
531
|
return pt(t[e], e);
|
|
532
532
|
}
|
|
533
533
|
function Z(t) {
|
|
534
534
|
const e = t;
|
|
535
535
|
return typeof e != "object" || Array.isArray(e) || e === null ? !1 : e.error !== void 0;
|
|
536
536
|
}
|
|
537
|
-
async function wt(t, e,
|
|
537
|
+
async function wt(t, e, r, o, s, n) {
|
|
538
538
|
if (!p(t))
|
|
539
539
|
throw new TypeError('"accessToken" must be a non-empty string');
|
|
540
|
-
if (!(
|
|
540
|
+
if (!(r instanceof URL))
|
|
541
541
|
throw new TypeError('"url" must be an instance of URL');
|
|
542
|
-
return o = $(o), (
|
|
542
|
+
return o = $(o), (n == null ? void 0 : n.DPoP) === void 0 ? o.set("authorization", `Bearer ${t}`) : (await dt(o, n.DPoP, r, "GET", I({ [H]: n == null ? void 0 : n[H] }), t), o.set("authorization", `DPoP ${t}`)), ((n == null ? void 0 : n[X]) || fetch)(r.href, {
|
|
543
543
|
body: s,
|
|
544
544
|
headers: Object.fromEntries(o.entries()),
|
|
545
545
|
method: e,
|
|
546
546
|
redirect: "manual",
|
|
547
|
-
signal:
|
|
547
|
+
signal: n != null && n.signal ? te(n.signal) : null
|
|
548
548
|
}).then(ee);
|
|
549
549
|
}
|
|
550
|
-
async function gt(t, e,
|
|
551
|
-
j(t),
|
|
552
|
-
const s = _e(t, "userinfo_endpoint"),
|
|
553
|
-
return e.userinfo_signed_response_alg ?
|
|
550
|
+
async function gt(t, e, r, o) {
|
|
551
|
+
j(t), J(e);
|
|
552
|
+
const s = _e(t, "userinfo_endpoint"), n = $(o == null ? void 0 : o.headers);
|
|
553
|
+
return e.userinfo_signed_response_alg ? n.set("accept", "application/jwt") : (n.set("accept", "application/json"), n.append("accept", "application/jwt")), wt(r, "GET", s, n, null, {
|
|
554
554
|
...o,
|
|
555
555
|
[H]: I(e)
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
async function mt(t, e,
|
|
559
|
-
return await lt(t, e, s,
|
|
558
|
+
async function mt(t, e, r, o, s, n, i) {
|
|
559
|
+
return await lt(t, e, s, n, i == null ? void 0 : i.clientPrivateKey), n.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), ((i == null ? void 0 : i[X]) || fetch)(o.href, {
|
|
560
560
|
body: s,
|
|
561
|
-
headers: Object.fromEntries(
|
|
562
|
-
method:
|
|
561
|
+
headers: Object.fromEntries(n.entries()),
|
|
562
|
+
method: r,
|
|
563
563
|
redirect: "manual",
|
|
564
564
|
signal: i != null && i.signal ? te(i.signal) : null
|
|
565
565
|
}).then(ee);
|
|
566
566
|
}
|
|
567
|
-
async function ve(t, e,
|
|
568
|
-
const
|
|
569
|
-
o.set("grant_type",
|
|
567
|
+
async function ve(t, e, r, o, s) {
|
|
568
|
+
const n = _e(t, "token_endpoint");
|
|
569
|
+
o.set("grant_type", r);
|
|
570
570
|
const i = $(s == null ? void 0 : s.headers);
|
|
571
|
-
return i.set("accept", "application/json"), mt(t, e, "POST",
|
|
571
|
+
return i.set("accept", "application/json"), mt(t, e, "POST", n, o, i, s);
|
|
572
572
|
}
|
|
573
|
-
async function yt(t, e,
|
|
574
|
-
if (j(t),
|
|
573
|
+
async function yt(t, e, r, o) {
|
|
574
|
+
if (j(t), J(e), !p(r))
|
|
575
575
|
throw new TypeError('"refreshToken" must be a non-empty string');
|
|
576
576
|
const s = new URLSearchParams(o == null ? void 0 : o.additionalParameters);
|
|
577
|
-
return s.set("refresh_token",
|
|
577
|
+
return s.set("refresh_token", r), ve(t, e, "refresh_token", s, o);
|
|
578
578
|
}
|
|
579
579
|
const Se = /* @__PURE__ */ new WeakMap();
|
|
580
580
|
function bt(t) {
|
|
@@ -585,52 +585,52 @@ function bt(t) {
|
|
|
585
585
|
throw new TypeError('"ref" was already garbage collected or did not resolve from the proper sources');
|
|
586
586
|
return e;
|
|
587
587
|
}
|
|
588
|
-
async function Te(t, e,
|
|
589
|
-
if (j(t),
|
|
588
|
+
async function Te(t, e, r, o = !1, s = !1) {
|
|
589
|
+
if (j(t), J(e), !Q(r, Response))
|
|
590
590
|
throw new TypeError('"response" must be an instance of Response');
|
|
591
|
-
if (
|
|
591
|
+
if (r.status !== 200) {
|
|
592
592
|
let i;
|
|
593
|
-
if (i = await
|
|
593
|
+
if (i = await xt(r))
|
|
594
594
|
return i;
|
|
595
595
|
throw new a('"response" is not a conform Token Endpoint response');
|
|
596
596
|
}
|
|
597
|
-
|
|
598
|
-
let
|
|
597
|
+
re(r);
|
|
598
|
+
let n;
|
|
599
599
|
try {
|
|
600
|
-
|
|
600
|
+
n = await r.json();
|
|
601
601
|
} catch (i) {
|
|
602
602
|
throw new a('failed to parse "response" body as JSON', { cause: i });
|
|
603
603
|
}
|
|
604
|
-
if (!C(
|
|
604
|
+
if (!C(n))
|
|
605
605
|
throw new a('"response" body must be a top level object');
|
|
606
|
-
if (!p(
|
|
606
|
+
if (!p(n.access_token))
|
|
607
607
|
throw new a('"response" body "access_token" property must be a non-empty string');
|
|
608
|
-
if (!p(
|
|
608
|
+
if (!p(n.token_type))
|
|
609
609
|
throw new a('"response" body "token_type" property must be a non-empty string');
|
|
610
|
-
if (
|
|
610
|
+
if (n.token_type = n.token_type.toLowerCase(), n.token_type !== "dpop" && n.token_type !== "bearer")
|
|
611
611
|
throw new S("unsupported `token_type` value");
|
|
612
|
-
if (
|
|
612
|
+
if (n.expires_in !== void 0 && (typeof n.expires_in != "number" || n.expires_in <= 0))
|
|
613
613
|
throw new a('"response" body "expires_in" property must be a positive number');
|
|
614
|
-
if (!s &&
|
|
614
|
+
if (!s && n.refresh_token !== void 0 && !p(n.refresh_token))
|
|
615
615
|
throw new a('"response" body "refresh_token" property must be a non-empty string');
|
|
616
|
-
if (
|
|
616
|
+
if (n.scope !== void 0 && typeof n.scope != "string")
|
|
617
617
|
throw new a('"response" body "scope" property must be a string');
|
|
618
618
|
if (!o) {
|
|
619
|
-
if (
|
|
619
|
+
if (n.id_token !== void 0 && !p(n.id_token))
|
|
620
620
|
throw new a('"response" body "id_token" property must be a non-empty string');
|
|
621
|
-
if (
|
|
622
|
-
const { claims: i } = await Lt(
|
|
621
|
+
if (n.id_token) {
|
|
622
|
+
const { claims: i } = await Lt(n.id_token, Ct.bind(void 0, e.id_token_signed_response_alg, t.id_token_signing_alg_values_supported), Ae, I(e), ye(e)).then(At.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(St.bind(void 0, t.issuer)).then(vt.bind(void 0, e.client_id));
|
|
623
623
|
if (Array.isArray(i.aud) && i.aud.length !== 1 && i.azp !== e.client_id)
|
|
624
624
|
throw new a('unexpected ID Token "azp" (authorized party) claim value');
|
|
625
625
|
if (i.auth_time !== void 0 && (!Number.isFinite(i.auth_time) || Math.sign(i.auth_time) !== 1))
|
|
626
626
|
throw new a('ID Token "auth_time" (authentication time) must be a positive number');
|
|
627
|
-
Se.set(
|
|
627
|
+
Se.set(n, i);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
return
|
|
630
|
+
return n;
|
|
631
631
|
}
|
|
632
|
-
async function _t(t, e,
|
|
633
|
-
return Te(t, e,
|
|
632
|
+
async function _t(t, e, r) {
|
|
633
|
+
return Te(t, e, r);
|
|
634
634
|
}
|
|
635
635
|
function vt(t, e) {
|
|
636
636
|
if (Array.isArray(e.claims.aud)) {
|
|
@@ -645,24 +645,24 @@ function St(t, e) {
|
|
|
645
645
|
throw new a('unexpected JWT "iss" (issuer) claim value');
|
|
646
646
|
return e;
|
|
647
647
|
}
|
|
648
|
-
const
|
|
648
|
+
const ke = /* @__PURE__ */ new WeakSet();
|
|
649
649
|
function Tt(t) {
|
|
650
|
-
return
|
|
650
|
+
return ke.add(t), t;
|
|
651
651
|
}
|
|
652
|
-
async function
|
|
653
|
-
if (j(t),
|
|
652
|
+
async function kt(t, e, r, o, s, n) {
|
|
653
|
+
if (j(t), J(e), !ke.has(r))
|
|
654
654
|
throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()');
|
|
655
655
|
if (!p(o))
|
|
656
656
|
throw new TypeError('"redirectUri" must be a non-empty string');
|
|
657
657
|
if (!p(s))
|
|
658
658
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
659
|
-
const i = T(
|
|
659
|
+
const i = T(r, "code");
|
|
660
660
|
if (!i)
|
|
661
661
|
throw new a('no authorization code in "callbackParameters"');
|
|
662
|
-
const u = new URLSearchParams(
|
|
663
|
-
return u.set("redirect_uri", o), u.set("code_verifier", s), u.set("code", i), ve(t, e, "authorization_code", u,
|
|
662
|
+
const u = new URLSearchParams(n == null ? void 0 : n.additionalParameters);
|
|
663
|
+
return u.set("redirect_uri", o), u.set("code_verifier", s), u.set("code", i), ve(t, e, "authorization_code", u, n);
|
|
664
664
|
}
|
|
665
|
-
const
|
|
665
|
+
const Et = {
|
|
666
666
|
aud: "audience",
|
|
667
667
|
c_hash: "code hash",
|
|
668
668
|
client_id: "client id",
|
|
@@ -679,27 +679,27 @@ const kt = {
|
|
|
679
679
|
cnf: "confirmation"
|
|
680
680
|
};
|
|
681
681
|
function At(t, e) {
|
|
682
|
-
for (const
|
|
683
|
-
if (e.claims[
|
|
684
|
-
throw new a(`JWT "${
|
|
682
|
+
for (const r of t)
|
|
683
|
+
if (e.claims[r] === void 0)
|
|
684
|
+
throw new a(`JWT "${r}" (${Et[r]}) claim missing`);
|
|
685
685
|
return e;
|
|
686
686
|
}
|
|
687
687
|
const Rt = Symbol(), G = Symbol();
|
|
688
|
-
async function Pt(t, e,
|
|
689
|
-
const
|
|
690
|
-
if (Z(
|
|
691
|
-
return
|
|
692
|
-
if (!p(
|
|
688
|
+
async function Pt(t, e, r, o, s) {
|
|
689
|
+
const n = await Te(t, e, r);
|
|
690
|
+
if (Z(n))
|
|
691
|
+
return n;
|
|
692
|
+
if (!p(n.id_token))
|
|
693
693
|
throw new a('"response" body "id_token" property must be a non-empty string');
|
|
694
694
|
s ?? (s = e.default_max_age ?? G);
|
|
695
|
-
const i = bt(
|
|
695
|
+
const i = bt(n);
|
|
696
696
|
if ((e.require_auth_time || s !== G) && i.auth_time === void 0)
|
|
697
697
|
throw new a('ID Token "auth_time" (authentication time) claim missing');
|
|
698
698
|
if (s !== G) {
|
|
699
699
|
if (typeof s != "number" || s < 0)
|
|
700
700
|
throw new TypeError('"maxAge" must be a non-negative number');
|
|
701
|
-
const u = M() + I(e),
|
|
702
|
-
if (i.auth_time + s < u -
|
|
701
|
+
const u = M() + I(e), f = ye(e);
|
|
702
|
+
if (i.auth_time + s < u - f)
|
|
703
703
|
throw new a("too much time has elapsed since the last End-User authentication");
|
|
704
704
|
}
|
|
705
705
|
switch (o) {
|
|
@@ -716,15 +716,15 @@ async function Pt(t, e, n, o, s) {
|
|
|
716
716
|
if (i.nonce !== o)
|
|
717
717
|
throw new a('unexpected ID Token "nonce" claim value');
|
|
718
718
|
}
|
|
719
|
-
return
|
|
719
|
+
return n;
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function re(t) {
|
|
722
722
|
if (t.bodyUsed)
|
|
723
723
|
throw new TypeError('"response" body has been used already');
|
|
724
724
|
}
|
|
725
|
-
async function
|
|
725
|
+
async function xt(t) {
|
|
726
726
|
if (t.status > 399 && t.status < 500) {
|
|
727
|
-
|
|
727
|
+
re(t);
|
|
728
728
|
try {
|
|
729
729
|
const e = await t.json();
|
|
730
730
|
if (C(e) && typeof e.error == "string" && e.error.length)
|
|
@@ -737,7 +737,7 @@ function le(t) {
|
|
|
737
737
|
if (typeof t.modulusLength != "number" || t.modulusLength < 2048)
|
|
738
738
|
throw new a(`${t.name} modulusLength must be at least 2048 bits`);
|
|
739
739
|
}
|
|
740
|
-
function
|
|
740
|
+
function Ut(t) {
|
|
741
741
|
switch (t) {
|
|
742
742
|
case "P-256":
|
|
743
743
|
return "SHA-256";
|
|
@@ -749,12 +749,12 @@ function xt(t) {
|
|
|
749
749
|
throw new S();
|
|
750
750
|
}
|
|
751
751
|
}
|
|
752
|
-
function
|
|
752
|
+
function Ee(t) {
|
|
753
753
|
switch (t.algorithm.name) {
|
|
754
754
|
case "ECDSA":
|
|
755
755
|
return {
|
|
756
756
|
name: t.algorithm.name,
|
|
757
|
-
hash:
|
|
757
|
+
hash: Ut(t.algorithm.namedCurve)
|
|
758
758
|
};
|
|
759
759
|
case "RSA-PSS":
|
|
760
760
|
switch (le(t.algorithm), t.algorithm.hash.name) {
|
|
@@ -777,15 +777,15 @@ function ke(t) {
|
|
|
777
777
|
throw new S();
|
|
778
778
|
}
|
|
779
779
|
const Ae = Symbol();
|
|
780
|
-
async function Lt(t, e,
|
|
781
|
-
const { 0:
|
|
782
|
-
if (
|
|
780
|
+
async function Lt(t, e, r, o, s) {
|
|
781
|
+
const { 0: n, 1: i, 2: u, length: f } = t.split(".");
|
|
782
|
+
if (f === 5)
|
|
783
783
|
throw new S("JWE structure JWTs are not supported");
|
|
784
|
-
if (
|
|
784
|
+
if (f !== 3)
|
|
785
785
|
throw new a("Invalid JWT");
|
|
786
786
|
let m;
|
|
787
787
|
try {
|
|
788
|
-
m = JSON.parse(A(
|
|
788
|
+
m = JSON.parse(A(k(n)));
|
|
789
789
|
} catch (P) {
|
|
790
790
|
throw new a("failed to parse JWT Header body as base64url encoded JSON", { cause: P });
|
|
791
791
|
}
|
|
@@ -793,70 +793,70 @@ async function Lt(t, e, n, o, s) {
|
|
|
793
793
|
throw new a("JWT Header must be a top level object");
|
|
794
794
|
if (e(m), m.crit !== void 0)
|
|
795
795
|
throw new a('unexpected JWT "crit" header parameter');
|
|
796
|
-
const
|
|
797
|
-
let
|
|
798
|
-
if (
|
|
799
|
-
|
|
800
|
-
const P = `${
|
|
801
|
-
if (!await crypto.subtle.verify(
|
|
796
|
+
const y = k(u);
|
|
797
|
+
let b;
|
|
798
|
+
if (r !== Ae) {
|
|
799
|
+
b = await r(m);
|
|
800
|
+
const P = `${n}.${i}`;
|
|
801
|
+
if (!await crypto.subtle.verify(Ee(b), b, y, A(P)))
|
|
802
802
|
throw new a("JWT signature verification failed");
|
|
803
803
|
}
|
|
804
|
-
let
|
|
804
|
+
let h;
|
|
805
805
|
try {
|
|
806
|
-
|
|
806
|
+
h = JSON.parse(A(k(i)));
|
|
807
807
|
} catch (P) {
|
|
808
808
|
throw new a("failed to parse JWT Payload body as base64url encoded JSON", { cause: P });
|
|
809
809
|
}
|
|
810
|
-
if (!C(
|
|
810
|
+
if (!C(h))
|
|
811
811
|
throw new a("JWT Payload must be a top level object");
|
|
812
812
|
const R = M() + o;
|
|
813
|
-
if (
|
|
814
|
-
if (typeof
|
|
813
|
+
if (h.exp !== void 0) {
|
|
814
|
+
if (typeof h.exp != "number")
|
|
815
815
|
throw new a('unexpected JWT "exp" (expiration time) claim type');
|
|
816
|
-
if (
|
|
816
|
+
if (h.exp <= R - s)
|
|
817
817
|
throw new a('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
|
|
818
818
|
}
|
|
819
|
-
if (
|
|
819
|
+
if (h.iat !== void 0 && typeof h.iat != "number")
|
|
820
820
|
throw new a('unexpected JWT "iat" (issued at) claim type');
|
|
821
|
-
if (
|
|
821
|
+
if (h.iss !== void 0 && typeof h.iss != "string")
|
|
822
822
|
throw new a('unexpected JWT "iss" (issuer) claim type');
|
|
823
|
-
if (
|
|
824
|
-
if (typeof
|
|
823
|
+
if (h.nbf !== void 0) {
|
|
824
|
+
if (typeof h.nbf != "number")
|
|
825
825
|
throw new a('unexpected JWT "nbf" (not before) claim type');
|
|
826
|
-
if (
|
|
826
|
+
if (h.nbf > R + s)
|
|
827
827
|
throw new a('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
|
|
828
828
|
}
|
|
829
|
-
if (
|
|
829
|
+
if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
|
|
830
830
|
throw new a('unexpected JWT "aud" (audience) claim type');
|
|
831
|
-
return { header: m, claims:
|
|
831
|
+
return { header: m, claims: h, signature: y, key: b };
|
|
832
832
|
}
|
|
833
|
-
function Ct(t, e,
|
|
833
|
+
function Ct(t, e, r) {
|
|
834
834
|
if (t !== void 0) {
|
|
835
|
-
if (
|
|
835
|
+
if (r.alg !== t)
|
|
836
836
|
throw new a('unexpected JWT "alg" header parameter');
|
|
837
837
|
return;
|
|
838
838
|
}
|
|
839
839
|
if (Array.isArray(e)) {
|
|
840
|
-
if (!e.includes(
|
|
840
|
+
if (!e.includes(r.alg))
|
|
841
841
|
throw new a('unexpected JWT "alg" header parameter');
|
|
842
842
|
return;
|
|
843
843
|
}
|
|
844
|
-
if (
|
|
844
|
+
if (r.alg !== "RS256")
|
|
845
845
|
throw new a('unexpected JWT "alg" header parameter');
|
|
846
846
|
}
|
|
847
847
|
function T(t, e) {
|
|
848
|
-
const { 0:
|
|
848
|
+
const { 0: r, length: o } = t.getAll(e);
|
|
849
849
|
if (o > 1)
|
|
850
850
|
throw new a(`"${e}" parameter must be provided only once`);
|
|
851
|
-
return
|
|
851
|
+
return r;
|
|
852
852
|
}
|
|
853
853
|
const It = Symbol(), jt = Symbol();
|
|
854
|
-
function
|
|
855
|
-
if (j(t),
|
|
854
|
+
function Jt(t, e, r, o) {
|
|
855
|
+
if (j(t), J(e), r instanceof URL && (r = r.searchParams), !(r instanceof URLSearchParams))
|
|
856
856
|
throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
|
|
857
|
-
if (T(
|
|
857
|
+
if (T(r, "response"))
|
|
858
858
|
throw new a('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()');
|
|
859
|
-
const s = T(
|
|
859
|
+
const s = T(r, "iss"), n = T(r, "state");
|
|
860
860
|
if (!s && t.authorization_response_iss_parameter_supported)
|
|
861
861
|
throw new a('response parameter "iss" (issuer) missing');
|
|
862
862
|
if (s && s !== t.issuer)
|
|
@@ -864,7 +864,7 @@ function zt(t, e, n, o) {
|
|
|
864
864
|
switch (o) {
|
|
865
865
|
case void 0:
|
|
866
866
|
case jt:
|
|
867
|
-
if (
|
|
867
|
+
if (n !== void 0)
|
|
868
868
|
throw new a('unexpected "state" response parameter encountered');
|
|
869
869
|
break;
|
|
870
870
|
case It:
|
|
@@ -872,179 +872,167 @@ function zt(t, e, n, o) {
|
|
|
872
872
|
default:
|
|
873
873
|
if (!p(o))
|
|
874
874
|
throw new a('"expectedState" must be a non-empty string');
|
|
875
|
-
if (
|
|
875
|
+
if (n === void 0)
|
|
876
876
|
throw new a('response parameter "state" missing');
|
|
877
|
-
if (
|
|
877
|
+
if (n !== o)
|
|
878
878
|
throw new a('unexpected "state" response parameter value');
|
|
879
879
|
}
|
|
880
|
-
const i = T(
|
|
880
|
+
const i = T(r, "error");
|
|
881
881
|
if (i)
|
|
882
882
|
return {
|
|
883
883
|
error: i,
|
|
884
|
-
error_description: T(
|
|
885
|
-
error_uri: T(
|
|
884
|
+
error_description: T(r, "error_description"),
|
|
885
|
+
error_uri: T(r, "error_uri")
|
|
886
886
|
};
|
|
887
|
-
const u = T(
|
|
888
|
-
if (u !== void 0 ||
|
|
887
|
+
const u = T(r, "id_token"), f = T(r, "token");
|
|
888
|
+
if (u !== void 0 || f !== void 0)
|
|
889
889
|
throw new S("implicit and hybrid flows are not supported");
|
|
890
|
-
return Tt(new URLSearchParams(
|
|
890
|
+
return Tt(new URLSearchParams(r));
|
|
891
891
|
}
|
|
892
|
-
function
|
|
892
|
+
function Ot({
|
|
893
893
|
handleCallback: t
|
|
894
894
|
}) {
|
|
895
|
-
const [e,
|
|
896
|
-
return
|
|
897
|
-
s.current || (s.current = !0, t().then((
|
|
898
|
-
o(
|
|
899
|
-
}).catch((
|
|
900
|
-
K.error(
|
|
895
|
+
const [e, r] = Je(null), o = He(), s = Oe(!1);
|
|
896
|
+
return Ne(() => {
|
|
897
|
+
s.current || (s.current = !0, t().then((n) => {
|
|
898
|
+
o(n);
|
|
899
|
+
}).catch((n) => {
|
|
900
|
+
K.error(n), r(n);
|
|
901
901
|
}));
|
|
902
|
-
}, [o, t]), e ? /* @__PURE__ */
|
|
902
|
+
}, [o, t]), e ? /* @__PURE__ */ E.jsx(
|
|
903
903
|
De,
|
|
904
904
|
{
|
|
905
905
|
category: "Error",
|
|
906
906
|
title: "Authentication Error",
|
|
907
|
-
message: /* @__PURE__ */
|
|
908
|
-
/* @__PURE__ */
|
|
907
|
+
message: /* @__PURE__ */ E.jsxs(E.Fragment, { children: [
|
|
908
|
+
/* @__PURE__ */ E.jsx(ze, { className: "mb-4", children: "Check the configuration of your authorization provider and ensure all settings such as the callback URL are configured correctly." }),
|
|
909
909
|
"An error occurred while authorizing the user.",
|
|
910
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ E.jsx(We, { code: e.toString(), language: "plain" })
|
|
911
911
|
] })
|
|
912
912
|
}
|
|
913
|
-
) : /* @__PURE__ */
|
|
913
|
+
) : /* @__PURE__ */ E.jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ E.jsx(Ke, {}) });
|
|
914
914
|
}
|
|
915
|
-
class
|
|
915
|
+
class U extends Error {
|
|
916
916
|
}
|
|
917
|
-
class de extends
|
|
918
|
-
constructor(e,
|
|
919
|
-
super(e, o), this.error =
|
|
917
|
+
class de extends U {
|
|
918
|
+
constructor(e, r, o) {
|
|
919
|
+
super(e, o), this.error = r;
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
const V = "code-verifier";
|
|
923
|
-
class
|
|
924
|
-
constructor(e,
|
|
925
|
-
super(), this.callbackUrlPath = e, this.handleCallback =
|
|
923
|
+
class Nt extends je {
|
|
924
|
+
constructor(e, r) {
|
|
925
|
+
super(), this.callbackUrlPath = e, this.handleCallback = r;
|
|
926
926
|
}
|
|
927
927
|
getRoutes() {
|
|
928
928
|
return [
|
|
929
929
|
...super.getRoutes(),
|
|
930
930
|
{
|
|
931
931
|
path: this.callbackUrlPath,
|
|
932
|
-
element: /* @__PURE__ */
|
|
932
|
+
element: /* @__PURE__ */ E.jsx(Ot, { handleCallback: this.handleCallback })
|
|
933
933
|
}
|
|
934
934
|
];
|
|
935
935
|
}
|
|
936
936
|
}
|
|
937
|
-
class
|
|
937
|
+
class zt {
|
|
938
938
|
constructor({
|
|
939
939
|
issuer: e,
|
|
940
|
-
audience:
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
redirectToAfterSignIn: u,
|
|
946
|
-
redirectToAfterSignOut: h
|
|
940
|
+
audience: r,
|
|
941
|
+
clientId: o,
|
|
942
|
+
redirectToAfterSignUp: s,
|
|
943
|
+
redirectToAfterSignIn: n,
|
|
944
|
+
redirectToAfterSignOut: i
|
|
947
945
|
}) {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
y(this, "signOut", async () => {
|
|
961
|
-
N.setState({
|
|
946
|
+
_(this, "client");
|
|
947
|
+
_(this, "issuer");
|
|
948
|
+
_(this, "authorizationServer");
|
|
949
|
+
_(this, "callbackUrlPath", "/oauth/callback");
|
|
950
|
+
_(this, "logoutRedirectUrlPath", "/");
|
|
951
|
+
_(this, "onAuthorizationUrl");
|
|
952
|
+
_(this, "redirectToAfterSignUp");
|
|
953
|
+
_(this, "redirectToAfterSignIn");
|
|
954
|
+
_(this, "redirectToAfterSignOut");
|
|
955
|
+
_(this, "audience");
|
|
956
|
+
_(this, "signOut", async () => {
|
|
957
|
+
z.setState({
|
|
962
958
|
isAuthenticated: !1,
|
|
963
959
|
isPending: !1,
|
|
964
960
|
profile: void 0
|
|
965
961
|
}), sessionStorage.clear();
|
|
966
|
-
const e = await this.getAuthServer(),
|
|
962
|
+
const e = await this.getAuthServer(), r = new URL(
|
|
967
963
|
window.location.origin + this.redirectToAfterSignOut
|
|
968
964
|
);
|
|
969
|
-
|
|
965
|
+
r.pathname = this.logoutRedirectUrlPath;
|
|
970
966
|
let o;
|
|
971
967
|
e.end_session_endpoint ? (o = new URL(e.end_session_endpoint), o.searchParams.set(
|
|
972
968
|
"post_logout_redirect_uri",
|
|
973
|
-
|
|
974
|
-
)) : o =
|
|
969
|
+
r.toString()
|
|
970
|
+
)) : o = r;
|
|
975
971
|
});
|
|
976
|
-
|
|
977
|
-
const e = new URL(window.location.href),
|
|
972
|
+
_(this, "handleCallback", async () => {
|
|
973
|
+
const e = new URL(window.location.href), r = e.searchParams.get("state"), o = sessionStorage.getItem(V);
|
|
978
974
|
if (sessionStorage.removeItem(V), !o)
|
|
979
|
-
throw new
|
|
980
|
-
const s = await this.getAuthServer(),
|
|
975
|
+
throw new U("No code verifier found in state.");
|
|
976
|
+
const s = await this.getAuthServer(), n = Jt(
|
|
981
977
|
s,
|
|
982
978
|
this.client,
|
|
983
979
|
e.searchParams,
|
|
984
|
-
|
|
980
|
+
r ?? void 0
|
|
985
981
|
);
|
|
986
|
-
if (Z(
|
|
987
|
-
throw K.error("Error validating OAuth response",
|
|
982
|
+
if (Z(n))
|
|
983
|
+
throw K.error("Error validating OAuth response", n), new de(
|
|
988
984
|
"Error validating OAuth response",
|
|
989
|
-
|
|
985
|
+
n
|
|
990
986
|
);
|
|
991
987
|
const i = new URL(e);
|
|
992
988
|
i.pathname = this.redirectToAfterSignIn, i.search = "";
|
|
993
|
-
const u = await
|
|
989
|
+
const u = await kt(
|
|
994
990
|
s,
|
|
995
991
|
this.client,
|
|
996
|
-
|
|
992
|
+
n,
|
|
997
993
|
i.toString(),
|
|
998
994
|
o
|
|
999
|
-
),
|
|
995
|
+
), f = await Pt(
|
|
1000
996
|
s,
|
|
1001
997
|
this.client,
|
|
1002
998
|
u
|
|
1003
999
|
);
|
|
1004
|
-
this.setTokensFromResponse(
|
|
1005
|
-
const m = await this.getAccessToken(),
|
|
1000
|
+
this.setTokensFromResponse(f);
|
|
1001
|
+
const m = await this.getAccessToken(), b = await (await gt(
|
|
1006
1002
|
s,
|
|
1007
1003
|
this.client,
|
|
1008
1004
|
m
|
|
1009
|
-
)).json(),
|
|
1010
|
-
sub:
|
|
1011
|
-
email:
|
|
1012
|
-
name:
|
|
1013
|
-
emailVerified:
|
|
1014
|
-
pictureUrl:
|
|
1005
|
+
)).json(), h = {
|
|
1006
|
+
sub: b.sub,
|
|
1007
|
+
email: b.email,
|
|
1008
|
+
name: b.name,
|
|
1009
|
+
emailVerified: b.email_verified ?? !1,
|
|
1010
|
+
pictureUrl: b.picture
|
|
1015
1011
|
};
|
|
1016
|
-
|
|
1012
|
+
z.setState({
|
|
1017
1013
|
isAuthenticated: !0,
|
|
1018
1014
|
isPending: !1,
|
|
1019
|
-
profile:
|
|
1015
|
+
profile: h
|
|
1020
1016
|
}), sessionStorage.setItem(
|
|
1021
1017
|
"profile-state",
|
|
1022
|
-
JSON.stringify(
|
|
1018
|
+
JSON.stringify(z.getState().profile)
|
|
1023
1019
|
);
|
|
1024
1020
|
const R = sessionStorage.getItem("redirect-to") ?? "/";
|
|
1025
1021
|
return sessionStorage.removeItem("redirect-to"), R;
|
|
1026
1022
|
});
|
|
1027
1023
|
this.client = {
|
|
1028
|
-
client_id:
|
|
1024
|
+
client_id: o,
|
|
1029
1025
|
token_endpoint_auth_method: "none"
|
|
1030
|
-
}, this.audience =
|
|
1026
|
+
}, this.audience = r, this.issuer = e, this.redirectToAfterSignUp = s ?? "/", this.redirectToAfterSignIn = n ?? "/", this.redirectToAfterSignOut = i ?? "/";
|
|
1031
1027
|
}
|
|
1032
1028
|
async getAuthServer() {
|
|
1033
|
-
if (!this.authorizationServer)
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
};
|
|
1041
|
-
else {
|
|
1042
|
-
const e = new URL(this.issuer), n = await Qe(e);
|
|
1043
|
-
this.authorizationServer = await Xe(
|
|
1044
|
-
e,
|
|
1045
|
-
n
|
|
1046
|
-
);
|
|
1047
|
-
}
|
|
1029
|
+
if (!this.authorizationServer) {
|
|
1030
|
+
const e = new URL(this.issuer), r = await Qe(e);
|
|
1031
|
+
this.authorizationServer = await Xe(
|
|
1032
|
+
e,
|
|
1033
|
+
r
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1048
1036
|
return this.authorizationServer;
|
|
1049
1037
|
}
|
|
1050
1038
|
/**
|
|
@@ -1055,14 +1043,14 @@ class Nt {
|
|
|
1055
1043
|
if (Z(e))
|
|
1056
1044
|
throw K.error("Bad Token Response", e), new de("Bad Token Response", e);
|
|
1057
1045
|
if (!e.expires_in)
|
|
1058
|
-
throw new
|
|
1059
|
-
const
|
|
1046
|
+
throw new U("No expires_in in response");
|
|
1047
|
+
const r = {
|
|
1060
1048
|
accessToken: e.access_token,
|
|
1061
1049
|
refreshToken: e.refresh_token,
|
|
1062
1050
|
expiresOn: new Date(Date.now() + e.expires_in * 1e3),
|
|
1063
1051
|
tokenType: e.token_type
|
|
1064
1052
|
};
|
|
1065
|
-
sessionStorage.setItem("token-state", JSON.stringify(
|
|
1053
|
+
sessionStorage.setItem("token-state", JSON.stringify(r));
|
|
1066
1054
|
}
|
|
1067
1055
|
async signUp({ redirectTo: e } = {}) {
|
|
1068
1056
|
return this.authorize({
|
|
@@ -1077,36 +1065,36 @@ class Nt {
|
|
|
1077
1065
|
}
|
|
1078
1066
|
async authorize({
|
|
1079
1067
|
redirectTo: e,
|
|
1080
|
-
isSignUp:
|
|
1068
|
+
isSignUp: r = !1
|
|
1081
1069
|
}) {
|
|
1082
|
-
var m,
|
|
1070
|
+
var m, y;
|
|
1083
1071
|
const o = "S256", s = await this.getAuthServer();
|
|
1084
1072
|
if (!s.authorization_endpoint)
|
|
1085
|
-
throw new
|
|
1086
|
-
const
|
|
1087
|
-
sessionStorage.setItem(V,
|
|
1073
|
+
throw new U("No authorization endpoint");
|
|
1074
|
+
const n = et(), i = await rt(n);
|
|
1075
|
+
sessionStorage.setItem(V, n);
|
|
1088
1076
|
const u = new URL(
|
|
1089
1077
|
s.authorization_endpoint
|
|
1090
1078
|
);
|
|
1091
1079
|
sessionStorage.setItem("redirect-to", e);
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1080
|
+
const f = new URL(window.location.origin);
|
|
1081
|
+
if (f.pathname = this.callbackUrlPath, f.search = "", u.searchParams.set("client_id", this.client.client_id), u.searchParams.set("redirect_uri", f.toString()), u.searchParams.set("response_type", "code"), u.searchParams.set("scope", "openid profile email"), u.searchParams.set("code_challenge", i), u.searchParams.set(
|
|
1094
1082
|
"code_challenge_method",
|
|
1095
1083
|
o
|
|
1096
1084
|
), this.audience && u.searchParams.set("audience", this.audience), (m = this.onAuthorizationUrl) == null || m.call(this, u, {
|
|
1097
|
-
isSignIn: !
|
|
1098
|
-
isSignUp:
|
|
1099
|
-
}), ((
|
|
1100
|
-
const
|
|
1101
|
-
u.searchParams.set("state",
|
|
1085
|
+
isSignIn: !r,
|
|
1086
|
+
isSignUp: r
|
|
1087
|
+
}), ((y = s.code_challenge_methods_supported) == null ? void 0 : y.includes("S256")) !== !0) {
|
|
1088
|
+
const b = tt();
|
|
1089
|
+
u.searchParams.set("state", b);
|
|
1102
1090
|
}
|
|
1103
1091
|
location.href = u.href;
|
|
1104
1092
|
}
|
|
1105
1093
|
async getAccessToken() {
|
|
1106
|
-
const e = await this.getAuthServer(),
|
|
1107
|
-
if (!
|
|
1108
|
-
throw new
|
|
1109
|
-
const o = JSON.parse(
|
|
1094
|
+
const e = await this.getAuthServer(), r = sessionStorage.getItem("token-state");
|
|
1095
|
+
if (!r)
|
|
1096
|
+
throw new U("User is not authenticated");
|
|
1097
|
+
const o = JSON.parse(r);
|
|
1110
1098
|
if (o.expiresOn < /* @__PURE__ */ new Date()) {
|
|
1111
1099
|
if (!o.refreshToken)
|
|
1112
1100
|
return await this.signIn(), "";
|
|
@@ -1114,14 +1102,14 @@ class Nt {
|
|
|
1114
1102
|
e,
|
|
1115
1103
|
this.client,
|
|
1116
1104
|
o.refreshToken
|
|
1117
|
-
),
|
|
1105
|
+
), n = await _t(
|
|
1118
1106
|
e,
|
|
1119
1107
|
this.client,
|
|
1120
1108
|
s
|
|
1121
1109
|
);
|
|
1122
|
-
if (!
|
|
1123
|
-
throw new
|
|
1124
|
-
return this.setTokensFromResponse(
|
|
1110
|
+
if (!n.access_token)
|
|
1111
|
+
throw new U("No access token in response");
|
|
1112
|
+
return this.setTokensFromResponse(n), n.access_token.toString();
|
|
1125
1113
|
} else
|
|
1126
1114
|
return o.accessToken;
|
|
1127
1115
|
}
|
|
@@ -1129,23 +1117,23 @@ class Nt {
|
|
|
1129
1117
|
const e = sessionStorage.getItem("profile-state");
|
|
1130
1118
|
if (e)
|
|
1131
1119
|
try {
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1120
|
+
const r = JSON.parse(e);
|
|
1121
|
+
z.setState({
|
|
1134
1122
|
isAuthenticated: !0,
|
|
1135
1123
|
isPending: !1,
|
|
1136
|
-
profile:
|
|
1124
|
+
profile: r
|
|
1137
1125
|
});
|
|
1138
|
-
} catch (
|
|
1139
|
-
K.error("Error parsing auth state",
|
|
1126
|
+
} catch (r) {
|
|
1127
|
+
K.error("Error parsing auth state", r);
|
|
1140
1128
|
}
|
|
1141
1129
|
}
|
|
1142
1130
|
getAuthenticationPlugin() {
|
|
1143
|
-
return new
|
|
1131
|
+
return new Nt(this.callbackUrlPath, this.handleCallback);
|
|
1144
1132
|
}
|
|
1145
1133
|
}
|
|
1146
|
-
const Yt = (t) => new
|
|
1134
|
+
const Yt = (t) => new zt(t);
|
|
1147
1135
|
export {
|
|
1148
|
-
|
|
1136
|
+
zt as OpenIDAuthenticationProvider,
|
|
1149
1137
|
Yt as default
|
|
1150
1138
|
};
|
|
1151
1139
|
//# sourceMappingURL=zudoku.auth-openid.js.map
|