zudoku 0.3.0-dev.60 → 0.3.0-dev.62
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 +6 -0
- package/dist/config/validators/validate.d.ts +30 -0
- package/dist/config/validators/validate.js +6 -0
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/lib/authentication/AuthenticationPlugin.d.ts +2 -5
- package/dist/lib/authentication/AuthenticationPlugin.js +12 -12
- package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +3 -5
- package/dist/lib/authentication/components/SignIn.d.ts +1 -0
- package/dist/lib/authentication/components/{Logout.js → SignIn.js} +3 -3
- package/dist/lib/authentication/components/{Logout.js.map → SignIn.js.map} +1 -1
- package/dist/lib/authentication/components/SignOut.d.ts +1 -0
- package/dist/lib/authentication/components/SignOut.js +10 -0
- package/dist/lib/authentication/components/SignOut.js.map +1 -0
- package/dist/lib/authentication/components/SignUp.d.ts +1 -0
- package/dist/lib/authentication/components/{Login.js → SignUp.js} +3 -3
- package/dist/lib/authentication/components/SignUp.js.map +1 -0
- package/dist/lib/authentication/hook.js +2 -2
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +2 -2
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +17 -6
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +10 -5
- package/dist/lib/authentication/providers/openid.js +24 -6
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/components/Header.js +1 -1
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/navigation/SideNavigationItem.d.ts +0 -4
- package/dist/lib/components/navigation/SideNavigationItem.js +2 -2
- package/dist/lib/components/navigation/SideNavigationItem.js.map +1 -1
- package/dist/lib/core/DevPortalContext.js.map +1 -1
- package/lib/AuthenticationPlugin-RvXALgvS.js +52 -0
- package/lib/AuthenticationPlugin-RvXALgvS.js.map +1 -0
- package/lib/{hook-Q_gAL2NZ.js → hook-BY1NP0kj.js} +9 -9
- package/lib/{hook-Q_gAL2NZ.js.map → hook-BY1NP0kj.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +9 -7
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +48 -35
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +472 -456
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +64 -64
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +1 -1
- package/package.json +1 -1
- package/src/lib/authentication/AuthenticationPlugin.tsx +12 -10
- package/src/lib/authentication/authentication.ts +3 -5
- package/src/lib/authentication/components/{Login.tsx → SignIn.tsx} +2 -2
- package/src/lib/authentication/components/SignOut.tsx +11 -0
- package/src/lib/authentication/components/{Logout.tsx → SignUp.tsx} +2 -2
- package/src/lib/authentication/hook.ts +2 -2
- package/src/lib/authentication/providers/auth0.tsx +4 -2
- package/src/lib/authentication/providers/clerk.tsx +22 -7
- package/src/lib/authentication/providers/openid.tsx +33 -5
- package/src/lib/components/Header.tsx +27 -23
- package/src/lib/components/navigation/SideNavigationItem.tsx +2 -2
- package/src/lib/core/DevPortalContext.ts +2 -0
- package/dist/lib/authentication/components/Login.d.ts +0 -1
- package/dist/lib/authentication/components/Login.js.map +0 -1
- package/dist/lib/authentication/components/Logout.d.ts +0 -1
- package/dist/lib/authentication/routes.d.ts +0 -5
- package/dist/lib/authentication/routes.js +0 -12
- package/dist/lib/authentication/routes.js.map +0 -1
- package/lib/AuthenticationPlugin-CG6Bw32B.js +0 -46
- package/lib/AuthenticationPlugin-CG6Bw32B.js.map +0 -1
- package/src/lib/authentication/routes.tsx +0 -10
|
@@ -1,112 +1,112 @@
|
|
|
1
1
|
var Re = Object.defineProperty;
|
|
2
|
-
var Pe = (
|
|
3
|
-
var
|
|
2
|
+
var Pe = (t, e, n) => e in t ? Re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var y = (t, e, n) => Pe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
4
|
import { b as xe, j as T } from "./jsx-runtime-BIr0WBt_.js";
|
|
5
|
-
import { c as
|
|
6
|
-
import { A as Ce } from "./AuthenticationPlugin-
|
|
7
|
-
import { useRef as je, useState as
|
|
5
|
+
import { c as Ue, a as Le } from "./_commonjsHelpers-BVfed4GL.js";
|
|
6
|
+
import { A as Ce } from "./AuthenticationPlugin-RvXALgvS.js";
|
|
7
|
+
import { useRef as je, useState as ze, useEffect as Je } from "react";
|
|
8
8
|
import { u as re } from "./state-DKdaQzvh.js";
|
|
9
9
|
var he = { exports: {} };
|
|
10
|
-
(function(
|
|
11
|
-
(function(
|
|
12
|
-
|
|
13
|
-
})(
|
|
14
|
-
var
|
|
15
|
-
}, n = "undefined",
|
|
10
|
+
(function(t) {
|
|
11
|
+
(function(e, n) {
|
|
12
|
+
t.exports ? t.exports = n() : e.log = n();
|
|
13
|
+
})(Ue, function() {
|
|
14
|
+
var e = function() {
|
|
15
|
+
}, n = "undefined", r = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
|
|
16
16
|
"trace",
|
|
17
17
|
"debug",
|
|
18
18
|
"info",
|
|
19
19
|
"warn",
|
|
20
20
|
"error"
|
|
21
|
-
],
|
|
22
|
-
function
|
|
23
|
-
var c =
|
|
21
|
+
], o = {}, i = null;
|
|
22
|
+
function u(l, f) {
|
|
23
|
+
var c = l[f];
|
|
24
24
|
if (typeof c.bind == "function")
|
|
25
|
-
return c.bind(
|
|
25
|
+
return c.bind(l);
|
|
26
26
|
try {
|
|
27
|
-
return Function.prototype.bind.call(c,
|
|
27
|
+
return Function.prototype.bind.call(c, l);
|
|
28
28
|
} catch {
|
|
29
29
|
return function() {
|
|
30
|
-
return Function.prototype.apply.apply(c, [
|
|
30
|
+
return Function.prototype.apply.apply(c, [l, arguments]);
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
function g() {
|
|
35
35
|
console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
|
|
36
36
|
}
|
|
37
|
-
function m(
|
|
38
|
-
return
|
|
37
|
+
function m(l) {
|
|
38
|
+
return l === "debug" && (l = "log"), typeof console === n ? !1 : l === "trace" && r ? g : console[l] !== void 0 ? u(console, l) : console.log !== void 0 ? u(console, "log") : e;
|
|
39
39
|
}
|
|
40
40
|
function b() {
|
|
41
|
-
for (var
|
|
41
|
+
for (var l = this.getLevel(), f = 0; f < s.length; f++) {
|
|
42
42
|
var c = s[f];
|
|
43
|
-
this[c] = f <
|
|
43
|
+
this[c] = f < l ? e : this.methodFactory(c, l, this.name);
|
|
44
44
|
}
|
|
45
|
-
if (this.log = this.debug, typeof console === n &&
|
|
45
|
+
if (this.log = this.debug, typeof console === n && l < this.levels.SILENT)
|
|
46
46
|
return "No console available for logging";
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function _(l) {
|
|
49
49
|
return function() {
|
|
50
|
-
typeof console !== n && (b.call(this), this[
|
|
50
|
+
typeof console !== n && (b.call(this), this[l].apply(this, arguments));
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function h(
|
|
54
|
-
return m(
|
|
53
|
+
function h(l, f, c) {
|
|
54
|
+
return m(l) || _.apply(this, arguments);
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
var c = this,
|
|
58
|
-
typeof
|
|
59
|
-
function Ee(
|
|
60
|
-
var p = (s[
|
|
61
|
-
if (!(typeof window === n || !
|
|
56
|
+
function U(l, f) {
|
|
57
|
+
var c = this, J, $, P, v = "loglevel";
|
|
58
|
+
typeof l == "string" ? v += ":" + l : typeof l == "symbol" && (v = void 0);
|
|
59
|
+
function Ee(d) {
|
|
60
|
+
var p = (s[d] || "silent").toUpperCase();
|
|
61
|
+
if (!(typeof window === n || !v)) {
|
|
62
62
|
try {
|
|
63
|
-
window.localStorage[
|
|
63
|
+
window.localStorage[v] = p;
|
|
64
64
|
return;
|
|
65
65
|
} catch {
|
|
66
66
|
}
|
|
67
67
|
try {
|
|
68
|
-
window.document.cookie = encodeURIComponent(
|
|
68
|
+
window.document.cookie = encodeURIComponent(v) + "=" + p + ";";
|
|
69
69
|
} catch {
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
function ee() {
|
|
74
|
-
var
|
|
75
|
-
if (!(typeof window === n || !
|
|
74
|
+
var d;
|
|
75
|
+
if (!(typeof window === n || !v)) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
77
|
+
d = window.localStorage[v];
|
|
78
78
|
} catch {
|
|
79
79
|
}
|
|
80
|
-
if (typeof
|
|
80
|
+
if (typeof d === n)
|
|
81
81
|
try {
|
|
82
|
-
var p = window.document.cookie, O = encodeURIComponent(
|
|
83
|
-
ne !== -1 && (
|
|
82
|
+
var p = window.document.cookie, O = encodeURIComponent(v), ne = p.indexOf(O + "=");
|
|
83
|
+
ne !== -1 && (d = /^([^;]+)/.exec(
|
|
84
84
|
p.slice(ne + O.length + 1)
|
|
85
85
|
)[1]);
|
|
86
86
|
} catch {
|
|
87
87
|
}
|
|
88
|
-
return c.levels[
|
|
88
|
+
return c.levels[d] === void 0 && (d = void 0), d;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
function Te() {
|
|
92
|
-
if (!(typeof window === n || !
|
|
92
|
+
if (!(typeof window === n || !v)) {
|
|
93
93
|
try {
|
|
94
|
-
window.localStorage.removeItem(
|
|
94
|
+
window.localStorage.removeItem(v);
|
|
95
95
|
} catch {
|
|
96
96
|
}
|
|
97
97
|
try {
|
|
98
|
-
window.document.cookie = encodeURIComponent(
|
|
98
|
+
window.document.cookie = encodeURIComponent(v) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
|
|
99
99
|
} catch {
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
var p =
|
|
103
|
+
function L(d) {
|
|
104
|
+
var p = d;
|
|
105
105
|
if (typeof p == "string" && c.levels[p.toUpperCase()] !== void 0 && (p = c.levels[p.toUpperCase()]), typeof p == "number" && p >= 0 && p <= c.levels.SILENT)
|
|
106
106
|
return p;
|
|
107
|
-
throw new TypeError("log.setLevel() called with invalid level: " +
|
|
107
|
+
throw new TypeError("log.setLevel() called with invalid level: " + d);
|
|
108
108
|
}
|
|
109
|
-
c.name =
|
|
109
|
+
c.name = l, c.levels = {
|
|
110
110
|
TRACE: 0,
|
|
111
111
|
DEBUG: 1,
|
|
112
112
|
INFO: 2,
|
|
@@ -114,32 +114,32 @@ var he = { exports: {} };
|
|
|
114
114
|
ERROR: 4,
|
|
115
115
|
SILENT: 5
|
|
116
116
|
}, c.methodFactory = f || h, c.getLevel = function() {
|
|
117
|
-
return P ?? $ ??
|
|
118
|
-
}, c.setLevel = function(
|
|
119
|
-
return P =
|
|
120
|
-
}, c.setDefaultLevel = function(
|
|
121
|
-
$ =
|
|
117
|
+
return P ?? $ ?? J;
|
|
118
|
+
}, c.setLevel = function(d, p) {
|
|
119
|
+
return P = L(d), p !== !1 && Ee(P), b.call(c);
|
|
120
|
+
}, c.setDefaultLevel = function(d) {
|
|
121
|
+
$ = L(d), ee() || c.setLevel(d, !1);
|
|
122
122
|
}, c.resetLevel = function() {
|
|
123
123
|
P = null, Te(), b.call(c);
|
|
124
|
-
}, c.enableAll = function(
|
|
125
|
-
c.setLevel(c.levels.TRACE,
|
|
126
|
-
}, c.disableAll = function(
|
|
127
|
-
c.setLevel(c.levels.SILENT,
|
|
124
|
+
}, c.enableAll = function(d) {
|
|
125
|
+
c.setLevel(c.levels.TRACE, d);
|
|
126
|
+
}, c.disableAll = function(d) {
|
|
127
|
+
c.setLevel(c.levels.SILENT, d);
|
|
128
128
|
}, c.rebuild = function() {
|
|
129
|
-
if (i !== c && (
|
|
130
|
-
for (var
|
|
131
|
-
|
|
132
|
-
},
|
|
129
|
+
if (i !== c && (J = L(i.getLevel())), b.call(c), i === c)
|
|
130
|
+
for (var d in o)
|
|
131
|
+
o[d].rebuild();
|
|
132
|
+
}, J = L(
|
|
133
133
|
i ? i.getLevel() : "WARN"
|
|
134
134
|
);
|
|
135
135
|
var te = ee();
|
|
136
|
-
te != null && (P =
|
|
136
|
+
te != null && (P = L(te)), b.call(c);
|
|
137
137
|
}
|
|
138
|
-
i = new
|
|
138
|
+
i = new U(), i.getLogger = function(f) {
|
|
139
139
|
if (typeof f != "symbol" && typeof f != "string" || f === "")
|
|
140
140
|
throw new TypeError("You must supply a name when creating a logger.");
|
|
141
|
-
var c =
|
|
142
|
-
return c || (c =
|
|
141
|
+
var c = o[f];
|
|
142
|
+
return c || (c = o[f] = new U(
|
|
143
143
|
f,
|
|
144
144
|
i.methodFactory
|
|
145
145
|
)), c;
|
|
@@ -148,127 +148,127 @@ var he = { exports: {} };
|
|
|
148
148
|
return i.noConflict = function() {
|
|
149
149
|
return typeof window !== n && window.log === i && (window.log = R), i;
|
|
150
150
|
}, i.getLoggers = function() {
|
|
151
|
-
return
|
|
151
|
+
return o;
|
|
152
152
|
}, i.default = i, i;
|
|
153
153
|
});
|
|
154
154
|
})(he);
|
|
155
155
|
var Oe = he.exports;
|
|
156
|
-
const oe = /* @__PURE__ */
|
|
156
|
+
const oe = /* @__PURE__ */ Le(Oe);
|
|
157
157
|
let M;
|
|
158
158
|
var I, de;
|
|
159
159
|
(typeof navigator > "u" || !((de = (I = navigator.userAgent) == null ? void 0 : I.startsWith) != null && de.call(I, "Mozilla/5.0 "))) && (M = "oauth4webapi/v2.11.1");
|
|
160
|
-
function q(
|
|
161
|
-
if (
|
|
160
|
+
function q(t, e) {
|
|
161
|
+
if (t == null)
|
|
162
162
|
return !1;
|
|
163
163
|
try {
|
|
164
|
-
return
|
|
164
|
+
return t instanceof e || Object.getPrototypeOf(t)[Symbol.toStringTag] === e.prototype[Symbol.toStringTag];
|
|
165
165
|
} catch {
|
|
166
166
|
return !1;
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
const K = Symbol(), Ie = Symbol(), V = Symbol(), Ne = new TextEncoder(), Ke = new TextDecoder();
|
|
170
|
-
function A(
|
|
171
|
-
return typeof
|
|
170
|
+
function A(t) {
|
|
171
|
+
return typeof t == "string" ? Ne.encode(t) : Ke.decode(t);
|
|
172
172
|
}
|
|
173
173
|
const ie = 32768;
|
|
174
|
-
function We(
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
for (let n = 0; n <
|
|
178
|
-
|
|
179
|
-
return btoa(
|
|
180
|
-
}
|
|
181
|
-
function De(
|
|
174
|
+
function We(t) {
|
|
175
|
+
t instanceof ArrayBuffer && (t = new Uint8Array(t));
|
|
176
|
+
const e = [];
|
|
177
|
+
for (let n = 0; n < t.byteLength; n += ie)
|
|
178
|
+
e.push(String.fromCharCode.apply(null, t.subarray(n, n + ie)));
|
|
179
|
+
return btoa(e.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
180
|
+
}
|
|
181
|
+
function De(t) {
|
|
182
182
|
try {
|
|
183
|
-
const
|
|
184
|
-
for (let
|
|
185
|
-
n[
|
|
183
|
+
const e = atob(t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), n = new Uint8Array(e.length);
|
|
184
|
+
for (let r = 0; r < e.length; r++)
|
|
185
|
+
n[r] = e.charCodeAt(r);
|
|
186
186
|
return n;
|
|
187
|
-
} catch (
|
|
188
|
-
throw new a("The input to be decoded is not correctly encoded.", { cause:
|
|
187
|
+
} catch (e) {
|
|
188
|
+
throw new a("The input to be decoded is not correctly encoded.", { cause: e });
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
function E(
|
|
192
|
-
return typeof
|
|
191
|
+
function E(t) {
|
|
192
|
+
return typeof t == "string" ? De(t) : We(t);
|
|
193
193
|
}
|
|
194
194
|
class He {
|
|
195
|
-
constructor(
|
|
196
|
-
this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize =
|
|
195
|
+
constructor(e) {
|
|
196
|
+
this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize = e;
|
|
197
197
|
}
|
|
198
|
-
get(
|
|
199
|
-
let n = this.cache.get(
|
|
198
|
+
get(e) {
|
|
199
|
+
let n = this.cache.get(e);
|
|
200
200
|
if (n)
|
|
201
201
|
return n;
|
|
202
|
-
if (n = this._cache.get(
|
|
203
|
-
return this.update(
|
|
202
|
+
if (n = this._cache.get(e))
|
|
203
|
+
return this.update(e, n), n;
|
|
204
204
|
}
|
|
205
|
-
has(
|
|
206
|
-
return this.cache.has(
|
|
205
|
+
has(e) {
|
|
206
|
+
return this.cache.has(e) || this._cache.has(e);
|
|
207
207
|
}
|
|
208
|
-
set(
|
|
209
|
-
return this.cache.has(
|
|
208
|
+
set(e, n) {
|
|
209
|
+
return this.cache.has(e) ? this.cache.set(e, n) : this.update(e, n), this;
|
|
210
210
|
}
|
|
211
|
-
delete(
|
|
212
|
-
return this.cache.has(
|
|
211
|
+
delete(e) {
|
|
212
|
+
return this.cache.has(e) ? this.cache.delete(e) : this._cache.has(e) ? this._cache.delete(e) : !1;
|
|
213
213
|
}
|
|
214
|
-
update(
|
|
215
|
-
this.cache.set(
|
|
214
|
+
update(e, n) {
|
|
215
|
+
this.cache.set(e, n), this.cache.size >= this.maxSize && (this._cache = this.cache, this.cache = /* @__PURE__ */ new Map());
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
class
|
|
219
|
-
constructor(
|
|
218
|
+
class S extends Error {
|
|
219
|
+
constructor(e) {
|
|
220
220
|
var n;
|
|
221
|
-
super(
|
|
221
|
+
super(e ?? "operation not supported"), this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
class $e extends Error {
|
|
225
|
-
constructor(
|
|
226
|
-
var
|
|
227
|
-
super(
|
|
225
|
+
constructor(e, n) {
|
|
226
|
+
var r;
|
|
227
|
+
super(e, n), this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
const a = $e, fe = new He(100);
|
|
231
|
-
function pe(
|
|
232
|
-
return
|
|
231
|
+
function pe(t) {
|
|
232
|
+
return t instanceof CryptoKey;
|
|
233
233
|
}
|
|
234
|
-
function we(
|
|
235
|
-
return pe(
|
|
234
|
+
function we(t) {
|
|
235
|
+
return pe(t) && t.type === "private";
|
|
236
236
|
}
|
|
237
|
-
function Fe(
|
|
238
|
-
return pe(
|
|
237
|
+
function Fe(t) {
|
|
238
|
+
return pe(t) && t.type === "public";
|
|
239
239
|
}
|
|
240
|
-
function Y(
|
|
240
|
+
function Y(t) {
|
|
241
241
|
try {
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const e = t.headers.get("dpop-nonce");
|
|
243
|
+
e && fe.set(new URL(t.url).origin, e);
|
|
244
244
|
} catch {
|
|
245
245
|
}
|
|
246
|
-
return
|
|
246
|
+
return t;
|
|
247
247
|
}
|
|
248
|
-
function C(
|
|
249
|
-
return !(
|
|
248
|
+
function C(t) {
|
|
249
|
+
return !(t === null || typeof t != "object" || Array.isArray(t));
|
|
250
250
|
}
|
|
251
|
-
function W(
|
|
252
|
-
q(
|
|
253
|
-
const
|
|
254
|
-
if (M && !
|
|
251
|
+
function W(t) {
|
|
252
|
+
q(t, Headers) && (t = Object.fromEntries(t.entries()));
|
|
253
|
+
const e = new Headers(t);
|
|
254
|
+
if (M && !e.has("user-agent") && e.set("user-agent", M), e.has("authorization"))
|
|
255
255
|
throw new TypeError('"options.headers" must not include the "authorization" header name');
|
|
256
|
-
if (
|
|
256
|
+
if (e.has("dpop"))
|
|
257
257
|
throw new TypeError('"options.headers" must not include the "dpop" header name');
|
|
258
|
-
return
|
|
258
|
+
return e;
|
|
259
259
|
}
|
|
260
|
-
function Z(
|
|
261
|
-
if (typeof
|
|
260
|
+
function Z(t) {
|
|
261
|
+
if (typeof t == "function" && (t = t()), !(t instanceof AbortSignal))
|
|
262
262
|
throw new TypeError('"options.signal" must return or be an instance of AbortSignal');
|
|
263
|
-
return
|
|
263
|
+
return t;
|
|
264
264
|
}
|
|
265
|
-
async function Me(
|
|
266
|
-
if (!(
|
|
265
|
+
async function Me(t, e) {
|
|
266
|
+
if (!(t instanceof URL))
|
|
267
267
|
throw new TypeError('"issuerIdentifier" must be an instance of URL');
|
|
268
|
-
if (
|
|
268
|
+
if (t.protocol !== "https:" && t.protocol !== "http:")
|
|
269
269
|
throw new TypeError('"issuer.protocol" must be "https:" or "http:"');
|
|
270
|
-
const n = new URL(
|
|
271
|
-
switch (
|
|
270
|
+
const n = new URL(t.href);
|
|
271
|
+
switch (e == null ? void 0 : e.algorithm) {
|
|
272
272
|
case void 0:
|
|
273
273
|
case "oidc":
|
|
274
274
|
n.pathname = `${n.pathname}/.well-known/openid-configuration`.replace("//", "/");
|
|
@@ -279,36 +279,36 @@ async function Me(e, t) {
|
|
|
279
279
|
default:
|
|
280
280
|
throw new TypeError('"options.algorithm" must be "oidc" (default), or "oauth2"');
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
headers: Object.fromEntries(
|
|
282
|
+
const r = W(e == null ? void 0 : e.headers);
|
|
283
|
+
return r.set("accept", "application/json"), ((e == null ? void 0 : e[V]) || fetch)(n.href, {
|
|
284
|
+
headers: Object.fromEntries(r.entries()),
|
|
285
285
|
method: "GET",
|
|
286
286
|
redirect: "manual",
|
|
287
|
-
signal:
|
|
287
|
+
signal: e != null && e.signal ? Z(e.signal) : null
|
|
288
288
|
}).then(Y);
|
|
289
289
|
}
|
|
290
|
-
function w(
|
|
291
|
-
return typeof
|
|
290
|
+
function w(t) {
|
|
291
|
+
return typeof t == "string" && t.length !== 0;
|
|
292
292
|
}
|
|
293
|
-
async function Be(
|
|
294
|
-
if (!(
|
|
293
|
+
async function Be(t, e) {
|
|
294
|
+
if (!(t instanceof URL))
|
|
295
295
|
throw new TypeError('"expectedIssuer" must be an instance of URL');
|
|
296
|
-
if (!q(
|
|
296
|
+
if (!q(e, Response))
|
|
297
297
|
throw new TypeError('"response" must be an instance of Response');
|
|
298
|
-
if (
|
|
298
|
+
if (e.status !== 200)
|
|
299
299
|
throw new a('"response" is not a conform Authorization Server Metadata response');
|
|
300
|
-
X(
|
|
300
|
+
X(e);
|
|
301
301
|
let n;
|
|
302
302
|
try {
|
|
303
|
-
n = await
|
|
304
|
-
} catch (
|
|
305
|
-
throw new a('failed to parse "response" body as JSON', { cause:
|
|
303
|
+
n = await e.json();
|
|
304
|
+
} catch (r) {
|
|
305
|
+
throw new a('failed to parse "response" body as JSON', { cause: r });
|
|
306
306
|
}
|
|
307
307
|
if (!C(n))
|
|
308
308
|
throw new a('"response" body must be a top level object');
|
|
309
309
|
if (!w(n.issuer))
|
|
310
310
|
throw new a('"response" body "issuer" property must be a non-empty string');
|
|
311
|
-
if (new URL(n.issuer).href !==
|
|
311
|
+
if (new URL(n.issuer).href !== t.href)
|
|
312
312
|
throw new a('"response" body "issuer" does not match "expectedIssuer"');
|
|
313
313
|
return n;
|
|
314
314
|
}
|
|
@@ -321,29 +321,29 @@ function Ge() {
|
|
|
321
321
|
function qe() {
|
|
322
322
|
return D();
|
|
323
323
|
}
|
|
324
|
-
async function Ve(
|
|
325
|
-
if (!w(
|
|
324
|
+
async function Ve(t) {
|
|
325
|
+
if (!w(t))
|
|
326
326
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
327
|
-
return E(await crypto.subtle.digest("SHA-256", A(
|
|
327
|
+
return E(await crypto.subtle.digest("SHA-256", A(t)));
|
|
328
328
|
}
|
|
329
|
-
function Ye(
|
|
330
|
-
if (
|
|
331
|
-
return { key:
|
|
332
|
-
if (!((
|
|
329
|
+
function Ye(t) {
|
|
330
|
+
if (t instanceof CryptoKey)
|
|
331
|
+
return { key: t };
|
|
332
|
+
if (!((t == null ? void 0 : t.key) instanceof CryptoKey))
|
|
333
333
|
return {};
|
|
334
|
-
if (
|
|
334
|
+
if (t.kid !== void 0 && !w(t.kid))
|
|
335
335
|
throw new TypeError('"kid" must be a non-empty string');
|
|
336
|
-
return { key:
|
|
336
|
+
return { key: t.key, kid: t.kid };
|
|
337
337
|
}
|
|
338
|
-
function se(
|
|
339
|
-
return encodeURIComponent(
|
|
338
|
+
function se(t) {
|
|
339
|
+
return encodeURIComponent(t).replace(/%20/g, "+");
|
|
340
340
|
}
|
|
341
|
-
function Ze(
|
|
342
|
-
const n = se(
|
|
343
|
-
return `Basic ${btoa(`${n}:${
|
|
341
|
+
function Ze(t, e) {
|
|
342
|
+
const n = se(t), r = se(e);
|
|
343
|
+
return `Basic ${btoa(`${n}:${r}`)}`;
|
|
344
344
|
}
|
|
345
|
-
function Qe(
|
|
346
|
-
switch (
|
|
345
|
+
function Qe(t) {
|
|
346
|
+
switch (t.algorithm.hash.name) {
|
|
347
347
|
case "SHA-256":
|
|
348
348
|
return "PS256";
|
|
349
349
|
case "SHA-384":
|
|
@@ -351,11 +351,11 @@ function Qe(e) {
|
|
|
351
351
|
case "SHA-512":
|
|
352
352
|
return "PS512";
|
|
353
353
|
default:
|
|
354
|
-
throw new
|
|
354
|
+
throw new S("unsupported RsaHashedKeyAlgorithm hash name");
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
function Xe(
|
|
358
|
-
switch (
|
|
357
|
+
function Xe(t) {
|
|
358
|
+
switch (t.algorithm.hash.name) {
|
|
359
359
|
case "SHA-256":
|
|
360
360
|
return "RS256";
|
|
361
361
|
case "SHA-384":
|
|
@@ -363,11 +363,11 @@ function Xe(e) {
|
|
|
363
363
|
case "SHA-512":
|
|
364
364
|
return "RS512";
|
|
365
365
|
default:
|
|
366
|
-
throw new
|
|
366
|
+
throw new S("unsupported RsaHashedKeyAlgorithm hash name");
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
function et(
|
|
370
|
-
switch (
|
|
369
|
+
function et(t) {
|
|
370
|
+
switch (t.algorithm.namedCurve) {
|
|
371
371
|
case "P-256":
|
|
372
372
|
return "ES256";
|
|
373
373
|
case "P-384":
|
|
@@ -375,205 +375,205 @@ function et(e) {
|
|
|
375
375
|
case "P-521":
|
|
376
376
|
return "ES512";
|
|
377
377
|
default:
|
|
378
|
-
throw new
|
|
378
|
+
throw new S("unsupported EcKeyAlgorithm namedCurve");
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
function ge(
|
|
382
|
-
switch (
|
|
381
|
+
function ge(t) {
|
|
382
|
+
switch (t.algorithm.name) {
|
|
383
383
|
case "RSA-PSS":
|
|
384
|
-
return Qe(
|
|
384
|
+
return Qe(t);
|
|
385
385
|
case "RSASSA-PKCS1-v1_5":
|
|
386
|
-
return Xe(
|
|
386
|
+
return Xe(t);
|
|
387
387
|
case "ECDSA":
|
|
388
|
-
return et(
|
|
388
|
+
return et(t);
|
|
389
389
|
case "Ed25519":
|
|
390
390
|
case "Ed448":
|
|
391
391
|
return "EdDSA";
|
|
392
392
|
default:
|
|
393
|
-
throw new
|
|
393
|
+
throw new S("unsupported CryptoKey algorithm name");
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
-
function H(
|
|
397
|
-
const
|
|
398
|
-
return typeof
|
|
396
|
+
function H(t) {
|
|
397
|
+
const e = t == null ? void 0 : t[K];
|
|
398
|
+
return typeof e == "number" && Number.isFinite(e) ? e : 0;
|
|
399
399
|
}
|
|
400
|
-
function tt(
|
|
401
|
-
const
|
|
402
|
-
return typeof
|
|
400
|
+
function tt(t) {
|
|
401
|
+
const e = t == null ? void 0 : t[Ie];
|
|
402
|
+
return typeof e == "number" && Number.isFinite(e) && Math.sign(e) !== -1 ? e : 30;
|
|
403
403
|
}
|
|
404
404
|
function Q() {
|
|
405
405
|
return Math.floor(Date.now() / 1e3);
|
|
406
406
|
}
|
|
407
|
-
function nt(
|
|
408
|
-
const n = Q() + H(
|
|
407
|
+
function nt(t, e) {
|
|
408
|
+
const n = Q() + H(e);
|
|
409
409
|
return {
|
|
410
410
|
jti: D(),
|
|
411
|
-
aud: [
|
|
411
|
+
aud: [t.issuer, t.token_endpoint],
|
|
412
412
|
exp: n + 60,
|
|
413
413
|
iat: n,
|
|
414
414
|
nbf: n,
|
|
415
|
-
iss:
|
|
416
|
-
sub:
|
|
415
|
+
iss: e.client_id,
|
|
416
|
+
sub: e.client_id
|
|
417
417
|
};
|
|
418
418
|
}
|
|
419
|
-
async function rt(
|
|
419
|
+
async function rt(t, e, n, r) {
|
|
420
420
|
return me({
|
|
421
421
|
alg: ge(n),
|
|
422
|
-
kid:
|
|
423
|
-
}, nt(
|
|
422
|
+
kid: r
|
|
423
|
+
}, nt(t, e), n);
|
|
424
424
|
}
|
|
425
|
-
function j(
|
|
426
|
-
if (typeof
|
|
425
|
+
function j(t) {
|
|
426
|
+
if (typeof t != "object" || t === null)
|
|
427
427
|
throw new TypeError('"as" must be an object');
|
|
428
|
-
if (!w(
|
|
428
|
+
if (!w(t.issuer))
|
|
429
429
|
throw new TypeError('"as.issuer" property must be a non-empty string');
|
|
430
430
|
return !0;
|
|
431
431
|
}
|
|
432
|
-
function
|
|
433
|
-
if (typeof
|
|
432
|
+
function z(t) {
|
|
433
|
+
if (typeof t != "object" || t === null)
|
|
434
434
|
throw new TypeError('"client" must be an object');
|
|
435
|
-
if (!w(
|
|
435
|
+
if (!w(t.client_id))
|
|
436
436
|
throw new TypeError('"client.client_id" property must be a non-empty string');
|
|
437
437
|
return !0;
|
|
438
438
|
}
|
|
439
|
-
function ae(
|
|
440
|
-
if (!w(
|
|
439
|
+
function ae(t) {
|
|
440
|
+
if (!w(t))
|
|
441
441
|
throw new TypeError('"client.client_secret" property must be a non-empty string');
|
|
442
|
-
return
|
|
442
|
+
return t;
|
|
443
443
|
}
|
|
444
|
-
function F(
|
|
445
|
-
if (
|
|
446
|
-
throw new TypeError(`"options.clientPrivateKey" property must not be provided when ${
|
|
444
|
+
function F(t, e) {
|
|
445
|
+
if (e !== void 0)
|
|
446
|
+
throw new TypeError(`"options.clientPrivateKey" property must not be provided when ${t} client authentication method is used.`);
|
|
447
447
|
}
|
|
448
|
-
function ce(
|
|
449
|
-
if (
|
|
450
|
-
throw new TypeError(`"client.client_secret" property must not be provided when ${
|
|
448
|
+
function ce(t, e) {
|
|
449
|
+
if (e !== void 0)
|
|
450
|
+
throw new TypeError(`"client.client_secret" property must not be provided when ${t} client authentication method is used.`);
|
|
451
451
|
}
|
|
452
|
-
async function ot(
|
|
453
|
-
switch (n.delete("client_secret"), n.delete("client_assertion_type"), n.delete("client_assertion"),
|
|
452
|
+
async function ot(t, e, n, r, s) {
|
|
453
|
+
switch (n.delete("client_secret"), n.delete("client_assertion_type"), n.delete("client_assertion"), e.token_endpoint_auth_method) {
|
|
454
454
|
case void 0:
|
|
455
455
|
case "client_secret_basic": {
|
|
456
|
-
F("client_secret_basic", s),
|
|
456
|
+
F("client_secret_basic", s), r.set("authorization", Ze(e.client_id, ae(e.client_secret)));
|
|
457
457
|
break;
|
|
458
458
|
}
|
|
459
459
|
case "client_secret_post": {
|
|
460
|
-
F("client_secret_post", s), n.set("client_id",
|
|
460
|
+
F("client_secret_post", s), n.set("client_id", e.client_id), n.set("client_secret", ae(e.client_secret));
|
|
461
461
|
break;
|
|
462
462
|
}
|
|
463
463
|
case "private_key_jwt": {
|
|
464
|
-
if (ce("private_key_jwt",
|
|
464
|
+
if (ce("private_key_jwt", e.client_secret), s === void 0)
|
|
465
465
|
throw new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"');
|
|
466
|
-
const { key:
|
|
467
|
-
if (!we(
|
|
466
|
+
const { key: o, kid: i } = Ye(s);
|
|
467
|
+
if (!we(o))
|
|
468
468
|
throw new TypeError('"options.clientPrivateKey.key" must be a private CryptoKey');
|
|
469
|
-
n.set("client_id",
|
|
469
|
+
n.set("client_id", e.client_id), n.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.set("client_assertion", await rt(t, e, o, i));
|
|
470
470
|
break;
|
|
471
471
|
}
|
|
472
472
|
case "tls_client_auth":
|
|
473
473
|
case "self_signed_tls_client_auth":
|
|
474
474
|
case "none": {
|
|
475
|
-
ce(
|
|
475
|
+
ce(e.token_endpoint_auth_method, e.client_secret), F(e.token_endpoint_auth_method, s), n.set("client_id", e.client_id);
|
|
476
476
|
break;
|
|
477
477
|
}
|
|
478
478
|
default:
|
|
479
|
-
throw new
|
|
479
|
+
throw new S("unsupported client token_endpoint_auth_method");
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
async function me(
|
|
482
|
+
async function me(t, e, n) {
|
|
483
483
|
if (!n.usages.includes("sign"))
|
|
484
484
|
throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"');
|
|
485
|
-
const
|
|
486
|
-
return `${
|
|
485
|
+
const r = `${E(A(JSON.stringify(t)))}.${E(A(JSON.stringify(e)))}`, s = E(await crypto.subtle.sign(Se(n), n, A(r)));
|
|
486
|
+
return `${r}.${s}`;
|
|
487
487
|
}
|
|
488
|
-
async function it(
|
|
489
|
-
const { privateKey: i, publicKey:
|
|
488
|
+
async function it(t, e, n, r, s, o) {
|
|
489
|
+
const { privateKey: i, publicKey: u, nonce: g = fe.get(n.origin) } = e;
|
|
490
490
|
if (!we(i))
|
|
491
491
|
throw new TypeError('"DPoP.privateKey" must be a private CryptoKey');
|
|
492
|
-
if (!Fe(
|
|
492
|
+
if (!Fe(u))
|
|
493
493
|
throw new TypeError('"DPoP.publicKey" must be a public CryptoKey');
|
|
494
494
|
if (g !== void 0 && !w(g))
|
|
495
495
|
throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined');
|
|
496
|
-
if (!
|
|
496
|
+
if (!u.extractable)
|
|
497
497
|
throw new TypeError('"DPoP.publicKey.extractable" must be true');
|
|
498
498
|
const m = Q() + s, b = await me({
|
|
499
499
|
alg: ge(i),
|
|
500
500
|
typ: "dpop+jwt",
|
|
501
|
-
jwk: await at(
|
|
501
|
+
jwk: await at(u)
|
|
502
502
|
}, {
|
|
503
503
|
iat: m,
|
|
504
504
|
jti: D(),
|
|
505
|
-
htm:
|
|
505
|
+
htm: r,
|
|
506
506
|
nonce: g,
|
|
507
507
|
htu: `${n.origin}${n.pathname}`,
|
|
508
|
-
ath:
|
|
508
|
+
ath: o ? E(await crypto.subtle.digest("SHA-256", A(o))) : void 0
|
|
509
509
|
}, i);
|
|
510
|
-
|
|
510
|
+
t.set("dpop", b);
|
|
511
511
|
}
|
|
512
512
|
let N;
|
|
513
|
-
async function st(
|
|
514
|
-
const { kty:
|
|
515
|
-
return N.set(
|
|
513
|
+
async function st(t) {
|
|
514
|
+
const { kty: e, e: n, n: r, x: s, y: o, crv: i } = await crypto.subtle.exportKey("jwk", t), u = { kty: e, e: n, n: r, x: s, y: o, crv: i };
|
|
515
|
+
return N.set(t, u), u;
|
|
516
516
|
}
|
|
517
|
-
async function at(
|
|
518
|
-
return N || (N = /* @__PURE__ */ new WeakMap()), N.get(
|
|
517
|
+
async function at(t) {
|
|
518
|
+
return N || (N = /* @__PURE__ */ new WeakMap()), N.get(t) || st(t);
|
|
519
519
|
}
|
|
520
|
-
function ct(
|
|
521
|
-
if (typeof
|
|
522
|
-
throw new TypeError(`"as.${
|
|
523
|
-
return new URL(
|
|
520
|
+
function ct(t, e, n) {
|
|
521
|
+
if (typeof t != "string")
|
|
522
|
+
throw new TypeError(`"as.${e}" must be a string`);
|
|
523
|
+
return new URL(t);
|
|
524
524
|
}
|
|
525
|
-
function ye(
|
|
526
|
-
return ct(e
|
|
525
|
+
function ye(t, e, n) {
|
|
526
|
+
return ct(t[e], e);
|
|
527
527
|
}
|
|
528
|
-
function B(
|
|
529
|
-
const
|
|
530
|
-
return typeof
|
|
528
|
+
function B(t) {
|
|
529
|
+
const e = t;
|
|
530
|
+
return typeof e != "object" || Array.isArray(e) || e === null ? !1 : e.error !== void 0;
|
|
531
531
|
}
|
|
532
|
-
async function ut(
|
|
533
|
-
if (!w(
|
|
532
|
+
async function ut(t, e, n, r, s, o) {
|
|
533
|
+
if (!w(t))
|
|
534
534
|
throw new TypeError('"accessToken" must be a non-empty string');
|
|
535
535
|
if (!(n instanceof URL))
|
|
536
536
|
throw new TypeError('"url" must be an instance of URL');
|
|
537
|
-
return
|
|
537
|
+
return r = W(r), (o == null ? void 0 : o.DPoP) === void 0 ? r.set("authorization", `Bearer ${t}`) : (await it(r, o.DPoP, n, "GET", H({ [K]: o == null ? void 0 : o[K] }), t), r.set("authorization", `DPoP ${t}`)), ((o == null ? void 0 : o[V]) || fetch)(n.href, {
|
|
538
538
|
body: s,
|
|
539
|
-
headers: Object.fromEntries(
|
|
540
|
-
method:
|
|
539
|
+
headers: Object.fromEntries(r.entries()),
|
|
540
|
+
method: e,
|
|
541
541
|
redirect: "manual",
|
|
542
|
-
signal:
|
|
542
|
+
signal: o != null && o.signal ? Z(o.signal) : null
|
|
543
543
|
}).then(Y);
|
|
544
544
|
}
|
|
545
|
-
async function lt(
|
|
546
|
-
j(
|
|
547
|
-
const s = ye(
|
|
548
|
-
return
|
|
549
|
-
...
|
|
550
|
-
[K]: H(
|
|
545
|
+
async function lt(t, e, n, r) {
|
|
546
|
+
j(t), z(e);
|
|
547
|
+
const s = ye(t, "userinfo_endpoint"), o = W(r == null ? void 0 : r.headers);
|
|
548
|
+
return e.userinfo_signed_response_alg ? o.set("accept", "application/jwt") : (o.set("accept", "application/json"), o.append("accept", "application/jwt")), ut(n, "GET", s, o, null, {
|
|
549
|
+
...r,
|
|
550
|
+
[K]: H(e)
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
|
-
async function dt(
|
|
554
|
-
return await ot(
|
|
553
|
+
async function dt(t, e, n, r, s, o, i) {
|
|
554
|
+
return await ot(t, e, s, o, i == null ? void 0 : i.clientPrivateKey), o.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), ((i == null ? void 0 : i[V]) || fetch)(r.href, {
|
|
555
555
|
body: s,
|
|
556
|
-
headers: Object.fromEntries(
|
|
556
|
+
headers: Object.fromEntries(o.entries()),
|
|
557
557
|
method: n,
|
|
558
558
|
redirect: "manual",
|
|
559
559
|
signal: i != null && i.signal ? Z(i.signal) : null
|
|
560
560
|
}).then(Y);
|
|
561
561
|
}
|
|
562
|
-
async function
|
|
563
|
-
const
|
|
564
|
-
|
|
562
|
+
async function _e(t, e, n, r, s) {
|
|
563
|
+
const o = ye(t, "token_endpoint");
|
|
564
|
+
r.set("grant_type", n);
|
|
565
565
|
const i = W(s == null ? void 0 : s.headers);
|
|
566
|
-
return i.set("accept", "application/json"), dt(
|
|
566
|
+
return i.set("accept", "application/json"), dt(t, e, "POST", o, r, i, s);
|
|
567
567
|
}
|
|
568
|
-
async function ht(
|
|
569
|
-
if (j(
|
|
568
|
+
async function ht(t, e, n, r) {
|
|
569
|
+
if (j(t), z(e), !w(n))
|
|
570
570
|
throw new TypeError('"refreshToken" must be a non-empty string');
|
|
571
|
-
const s = new URLSearchParams(
|
|
572
|
-
return s.set("refresh_token", n),
|
|
571
|
+
const s = new URLSearchParams(r == null ? void 0 : r.additionalParameters);
|
|
572
|
+
return s.set("refresh_token", n), _e(t, e, "refresh_token", s, r);
|
|
573
573
|
}
|
|
574
574
|
const ft = /* @__PURE__ */ new WeakMap();
|
|
575
|
-
async function
|
|
576
|
-
if (j(
|
|
575
|
+
async function be(t, e, n, r = !1, s = !1) {
|
|
576
|
+
if (j(t), z(e), !q(n, Response))
|
|
577
577
|
throw new TypeError('"response" must be an instance of Response');
|
|
578
578
|
if (n.status !== 200) {
|
|
579
579
|
let i;
|
|
@@ -582,74 +582,74 @@ async function _e(e, t, n, o = !1, s = !1) {
|
|
|
582
582
|
throw new a('"response" is not a conform Token Endpoint response');
|
|
583
583
|
}
|
|
584
584
|
X(n);
|
|
585
|
-
let
|
|
585
|
+
let o;
|
|
586
586
|
try {
|
|
587
|
-
|
|
587
|
+
o = await n.json();
|
|
588
588
|
} catch (i) {
|
|
589
589
|
throw new a('failed to parse "response" body as JSON', { cause: i });
|
|
590
590
|
}
|
|
591
|
-
if (!C(
|
|
591
|
+
if (!C(o))
|
|
592
592
|
throw new a('"response" body must be a top level object');
|
|
593
|
-
if (!w(
|
|
593
|
+
if (!w(o.access_token))
|
|
594
594
|
throw new a('"response" body "access_token" property must be a non-empty string');
|
|
595
|
-
if (!w(
|
|
595
|
+
if (!w(o.token_type))
|
|
596
596
|
throw new a('"response" body "token_type" property must be a non-empty string');
|
|
597
|
-
if (
|
|
598
|
-
throw new
|
|
599
|
-
if (
|
|
597
|
+
if (o.token_type = o.token_type.toLowerCase(), o.token_type !== "dpop" && o.token_type !== "bearer")
|
|
598
|
+
throw new S("unsupported `token_type` value");
|
|
599
|
+
if (o.expires_in !== void 0 && (typeof o.expires_in != "number" || o.expires_in <= 0))
|
|
600
600
|
throw new a('"response" body "expires_in" property must be a positive number');
|
|
601
|
-
if (!s &&
|
|
601
|
+
if (!s && o.refresh_token !== void 0 && !w(o.refresh_token))
|
|
602
602
|
throw new a('"response" body "refresh_token" property must be a non-empty string');
|
|
603
|
-
if (
|
|
603
|
+
if (o.scope !== void 0 && typeof o.scope != "string")
|
|
604
604
|
throw new a('"response" body "scope" property must be a string');
|
|
605
|
-
if (!
|
|
606
|
-
if (
|
|
605
|
+
if (!r) {
|
|
606
|
+
if (o.id_token !== void 0 && !w(o.id_token))
|
|
607
607
|
throw new a('"response" body "id_token" property must be a non-empty string');
|
|
608
|
-
if (
|
|
609
|
-
const { claims: i } = await Et(
|
|
610
|
-
if (Array.isArray(i.aud) && i.aud.length !== 1 && i.azp !==
|
|
608
|
+
if (o.id_token) {
|
|
609
|
+
const { claims: i } = await Et(o.id_token, Tt.bind(void 0, e.id_token_signed_response_alg, t.id_token_signing_alg_values_supported), ke, H(e), tt(e)).then(bt.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(gt.bind(void 0, t.issuer)).then(wt.bind(void 0, e.client_id));
|
|
610
|
+
if (Array.isArray(i.aud) && i.aud.length !== 1 && i.azp !== e.client_id)
|
|
611
611
|
throw new a('unexpected ID Token "azp" (authorized party) claim value');
|
|
612
612
|
if (i.auth_time !== void 0 && (!Number.isFinite(i.auth_time) || Math.sign(i.auth_time) !== 1))
|
|
613
613
|
throw new a('ID Token "auth_time" (authentication time) must be a positive number');
|
|
614
|
-
ft.set(
|
|
614
|
+
ft.set(o, i);
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
return
|
|
617
|
+
return o;
|
|
618
618
|
}
|
|
619
|
-
async function pt(
|
|
620
|
-
return
|
|
619
|
+
async function pt(t, e, n) {
|
|
620
|
+
return be(t, e, n);
|
|
621
621
|
}
|
|
622
|
-
function wt(
|
|
623
|
-
if (Array.isArray(
|
|
624
|
-
if (!
|
|
622
|
+
function wt(t, e) {
|
|
623
|
+
if (Array.isArray(e.claims.aud)) {
|
|
624
|
+
if (!e.claims.aud.includes(t))
|
|
625
625
|
throw new a('unexpected JWT "aud" (audience) claim value');
|
|
626
|
-
} else if (
|
|
626
|
+
} else if (e.claims.aud !== t)
|
|
627
627
|
throw new a('unexpected JWT "aud" (audience) claim value');
|
|
628
|
-
return
|
|
628
|
+
return e;
|
|
629
629
|
}
|
|
630
|
-
function gt(
|
|
631
|
-
if (
|
|
630
|
+
function gt(t, e) {
|
|
631
|
+
if (e.claims.iss !== t)
|
|
632
632
|
throw new a('unexpected JWT "iss" (issuer) claim value');
|
|
633
|
-
return
|
|
633
|
+
return e;
|
|
634
634
|
}
|
|
635
635
|
const ve = /* @__PURE__ */ new WeakSet();
|
|
636
|
-
function mt(
|
|
637
|
-
return ve.add(
|
|
636
|
+
function mt(t) {
|
|
637
|
+
return ve.add(t), t;
|
|
638
638
|
}
|
|
639
|
-
async function yt(
|
|
640
|
-
if (j(
|
|
639
|
+
async function yt(t, e, n, r, s, o) {
|
|
640
|
+
if (j(t), z(e), !ve.has(n))
|
|
641
641
|
throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()');
|
|
642
|
-
if (!w(
|
|
642
|
+
if (!w(r))
|
|
643
643
|
throw new TypeError('"redirectUri" must be a non-empty string');
|
|
644
644
|
if (!w(s))
|
|
645
645
|
throw new TypeError('"codeVerifier" must be a non-empty string');
|
|
646
646
|
const i = k(n, "code");
|
|
647
647
|
if (!i)
|
|
648
648
|
throw new a('no authorization code in "callbackParameters"');
|
|
649
|
-
const
|
|
650
|
-
return
|
|
649
|
+
const u = new URLSearchParams(o == null ? void 0 : o.additionalParameters);
|
|
650
|
+
return u.set("redirect_uri", r), u.set("code_verifier", s), u.set("code", i), _e(t, e, "authorization_code", u, o);
|
|
651
651
|
}
|
|
652
|
-
const
|
|
652
|
+
const _t = {
|
|
653
653
|
aud: "audience",
|
|
654
654
|
c_hash: "code hash",
|
|
655
655
|
client_id: "client id",
|
|
@@ -665,44 +665,44 @@ const bt = {
|
|
|
665
665
|
htu: "http uri",
|
|
666
666
|
cnf: "confirmation"
|
|
667
667
|
};
|
|
668
|
-
function
|
|
669
|
-
for (const n of
|
|
670
|
-
if (
|
|
671
|
-
throw new a(`JWT "${n}" (${
|
|
672
|
-
return
|
|
668
|
+
function bt(t, e) {
|
|
669
|
+
for (const n of t)
|
|
670
|
+
if (e.claims[n] === void 0)
|
|
671
|
+
throw new a(`JWT "${n}" (${_t[n]}) claim missing`);
|
|
672
|
+
return e;
|
|
673
673
|
}
|
|
674
|
-
async function vt(
|
|
675
|
-
const
|
|
676
|
-
if (B(
|
|
677
|
-
return
|
|
678
|
-
if (
|
|
679
|
-
if (typeof
|
|
674
|
+
async function vt(t, e, n) {
|
|
675
|
+
const r = await be(t, e, n, !0);
|
|
676
|
+
if (B(r))
|
|
677
|
+
return r;
|
|
678
|
+
if (r.id_token !== void 0) {
|
|
679
|
+
if (typeof r.id_token == "string" && r.id_token.length)
|
|
680
680
|
throw new a("Unexpected ID Token returned, use processAuthorizationCodeOpenIDResponse() for OpenID Connect callback processing");
|
|
681
|
-
delete
|
|
681
|
+
delete r.id_token;
|
|
682
682
|
}
|
|
683
|
-
return
|
|
683
|
+
return r;
|
|
684
684
|
}
|
|
685
|
-
function X(
|
|
686
|
-
if (
|
|
685
|
+
function X(t) {
|
|
686
|
+
if (t.bodyUsed)
|
|
687
687
|
throw new TypeError('"response" body has been used already');
|
|
688
688
|
}
|
|
689
|
-
async function St(
|
|
690
|
-
if (
|
|
691
|
-
X(
|
|
689
|
+
async function St(t) {
|
|
690
|
+
if (t.status > 399 && t.status < 500) {
|
|
691
|
+
X(t);
|
|
692
692
|
try {
|
|
693
|
-
const
|
|
694
|
-
if (C(
|
|
695
|
-
return
|
|
693
|
+
const e = await t.json();
|
|
694
|
+
if (C(e) && typeof e.error == "string" && e.error.length)
|
|
695
|
+
return e.error_description !== void 0 && typeof e.error_description != "string" && delete e.error_description, e.error_uri !== void 0 && typeof e.error_uri != "string" && delete e.error_uri, e.algs !== void 0 && typeof e.algs != "string" && delete e.algs, e.scope !== void 0 && typeof e.scope != "string" && delete e.scope, e;
|
|
696
696
|
} catch {
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function ue(
|
|
701
|
-
if (typeof
|
|
702
|
-
throw new a(`${
|
|
700
|
+
function ue(t) {
|
|
701
|
+
if (typeof t.modulusLength != "number" || t.modulusLength < 2048)
|
|
702
|
+
throw new a(`${t.name} modulusLength must be at least 2048 bits`);
|
|
703
703
|
}
|
|
704
|
-
function kt(
|
|
705
|
-
switch (
|
|
704
|
+
function kt(t) {
|
|
705
|
+
switch (t) {
|
|
706
706
|
case "P-256":
|
|
707
707
|
return "SHA-256";
|
|
708
708
|
case "P-384":
|
|
@@ -710,59 +710,59 @@ function kt(e) {
|
|
|
710
710
|
case "P-521":
|
|
711
711
|
return "SHA-512";
|
|
712
712
|
default:
|
|
713
|
-
throw new
|
|
713
|
+
throw new S();
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
function Se(
|
|
717
|
-
switch (
|
|
716
|
+
function Se(t) {
|
|
717
|
+
switch (t.algorithm.name) {
|
|
718
718
|
case "ECDSA":
|
|
719
719
|
return {
|
|
720
|
-
name:
|
|
721
|
-
hash: kt(
|
|
720
|
+
name: t.algorithm.name,
|
|
721
|
+
hash: kt(t.algorithm.namedCurve)
|
|
722
722
|
};
|
|
723
723
|
case "RSA-PSS":
|
|
724
|
-
switch (ue(
|
|
724
|
+
switch (ue(t.algorithm), t.algorithm.hash.name) {
|
|
725
725
|
case "SHA-256":
|
|
726
726
|
case "SHA-384":
|
|
727
727
|
case "SHA-512":
|
|
728
728
|
return {
|
|
729
|
-
name:
|
|
730
|
-
saltLength: parseInt(
|
|
729
|
+
name: t.algorithm.name,
|
|
730
|
+
saltLength: parseInt(t.algorithm.hash.name.slice(-3), 10) >> 3
|
|
731
731
|
};
|
|
732
732
|
default:
|
|
733
|
-
throw new
|
|
733
|
+
throw new S();
|
|
734
734
|
}
|
|
735
735
|
case "RSASSA-PKCS1-v1_5":
|
|
736
|
-
return ue(
|
|
736
|
+
return ue(t.algorithm), t.algorithm.name;
|
|
737
737
|
case "Ed448":
|
|
738
738
|
case "Ed25519":
|
|
739
|
-
return
|
|
739
|
+
return t.algorithm.name;
|
|
740
740
|
}
|
|
741
|
-
throw new
|
|
741
|
+
throw new S();
|
|
742
742
|
}
|
|
743
743
|
const ke = Symbol();
|
|
744
|
-
async function Et(
|
|
745
|
-
const { 0:
|
|
744
|
+
async function Et(t, e, n, r, s) {
|
|
745
|
+
const { 0: o, 1: i, 2: u, length: g } = t.split(".");
|
|
746
746
|
if (g === 5)
|
|
747
|
-
throw new
|
|
747
|
+
throw new S("JWE structure JWTs are not supported");
|
|
748
748
|
if (g !== 3)
|
|
749
749
|
throw new a("Invalid JWT");
|
|
750
750
|
let m;
|
|
751
751
|
try {
|
|
752
|
-
m = JSON.parse(A(E(
|
|
752
|
+
m = JSON.parse(A(E(o)));
|
|
753
753
|
} catch (R) {
|
|
754
754
|
throw new a("failed to parse JWT Header body as base64url encoded JSON", { cause: R });
|
|
755
755
|
}
|
|
756
756
|
if (!C(m))
|
|
757
757
|
throw new a("JWT Header must be a top level object");
|
|
758
|
-
if (
|
|
758
|
+
if (e(m), m.crit !== void 0)
|
|
759
759
|
throw new a('unexpected JWT "crit" header parameter');
|
|
760
|
-
const b = E(
|
|
761
|
-
let
|
|
760
|
+
const b = E(u);
|
|
761
|
+
let _;
|
|
762
762
|
if (n !== ke) {
|
|
763
|
-
|
|
764
|
-
const R = `${
|
|
765
|
-
if (!await crypto.subtle.verify(Se(
|
|
763
|
+
_ = await n(m);
|
|
764
|
+
const R = `${o}.${i}`;
|
|
765
|
+
if (!await crypto.subtle.verify(Se(_), _, b, A(R)))
|
|
766
766
|
throw new a("JWT signature verification failed");
|
|
767
767
|
}
|
|
768
768
|
let h;
|
|
@@ -773,11 +773,11 @@ async function Et(e, t, n, o, s) {
|
|
|
773
773
|
}
|
|
774
774
|
if (!C(h))
|
|
775
775
|
throw new a("JWT Payload must be a top level object");
|
|
776
|
-
const
|
|
776
|
+
const U = Q() + r;
|
|
777
777
|
if (h.exp !== void 0) {
|
|
778
778
|
if (typeof h.exp != "number")
|
|
779
779
|
throw new a('unexpected JWT "exp" (expiration time) claim type');
|
|
780
|
-
if (h.exp <=
|
|
780
|
+
if (h.exp <= U - s)
|
|
781
781
|
throw new a('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
|
|
782
782
|
}
|
|
783
783
|
if (h.iat !== void 0 && typeof h.iat != "number")
|
|
@@ -787,58 +787,58 @@ async function Et(e, t, n, o, s) {
|
|
|
787
787
|
if (h.nbf !== void 0) {
|
|
788
788
|
if (typeof h.nbf != "number")
|
|
789
789
|
throw new a('unexpected JWT "nbf" (not before) claim type');
|
|
790
|
-
if (h.nbf >
|
|
790
|
+
if (h.nbf > U + s)
|
|
791
791
|
throw new a('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
|
|
792
792
|
}
|
|
793
793
|
if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
|
|
794
794
|
throw new a('unexpected JWT "aud" (audience) claim type');
|
|
795
|
-
return { header: m, claims: h, signature: b, key:
|
|
795
|
+
return { header: m, claims: h, signature: b, key: _ };
|
|
796
796
|
}
|
|
797
|
-
function Tt(
|
|
798
|
-
if (
|
|
799
|
-
if (n.alg !==
|
|
797
|
+
function Tt(t, e, n) {
|
|
798
|
+
if (t !== void 0) {
|
|
799
|
+
if (n.alg !== t)
|
|
800
800
|
throw new a('unexpected JWT "alg" header parameter');
|
|
801
801
|
return;
|
|
802
802
|
}
|
|
803
|
-
if (Array.isArray(
|
|
804
|
-
if (!
|
|
803
|
+
if (Array.isArray(e)) {
|
|
804
|
+
if (!e.includes(n.alg))
|
|
805
805
|
throw new a('unexpected JWT "alg" header parameter');
|
|
806
806
|
return;
|
|
807
807
|
}
|
|
808
808
|
if (n.alg !== "RS256")
|
|
809
809
|
throw new a('unexpected JWT "alg" header parameter');
|
|
810
810
|
}
|
|
811
|
-
function k(
|
|
812
|
-
const { 0: n, length:
|
|
813
|
-
if (
|
|
814
|
-
throw new a(`"${
|
|
811
|
+
function k(t, e) {
|
|
812
|
+
const { 0: n, length: r } = t.getAll(e);
|
|
813
|
+
if (r > 1)
|
|
814
|
+
throw new a(`"${e}" parameter must be provided only once`);
|
|
815
815
|
return n;
|
|
816
816
|
}
|
|
817
817
|
const At = Symbol(), Rt = Symbol();
|
|
818
|
-
function Pt(
|
|
819
|
-
if (j(
|
|
818
|
+
function Pt(t, e, n, r) {
|
|
819
|
+
if (j(t), z(e), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
|
|
820
820
|
throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
|
|
821
821
|
if (k(n, "response"))
|
|
822
822
|
throw new a('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()');
|
|
823
|
-
const s = k(n, "iss"),
|
|
824
|
-
if (!s &&
|
|
823
|
+
const s = k(n, "iss"), o = k(n, "state");
|
|
824
|
+
if (!s && t.authorization_response_iss_parameter_supported)
|
|
825
825
|
throw new a('response parameter "iss" (issuer) missing');
|
|
826
|
-
if (s && s !==
|
|
826
|
+
if (s && s !== t.issuer)
|
|
827
827
|
throw new a('unexpected "iss" (issuer) response parameter value');
|
|
828
|
-
switch (
|
|
828
|
+
switch (r) {
|
|
829
829
|
case void 0:
|
|
830
830
|
case Rt:
|
|
831
|
-
if (
|
|
831
|
+
if (o !== void 0)
|
|
832
832
|
throw new a('unexpected "state" response parameter encountered');
|
|
833
833
|
break;
|
|
834
834
|
case At:
|
|
835
835
|
break;
|
|
836
836
|
default:
|
|
837
|
-
if (!w(
|
|
837
|
+
if (!w(r))
|
|
838
838
|
throw new a('"expectedState" must be a non-empty string');
|
|
839
|
-
if (
|
|
839
|
+
if (o === void 0)
|
|
840
840
|
throw new a('response parameter "state" missing');
|
|
841
|
-
if (
|
|
841
|
+
if (o !== r)
|
|
842
842
|
throw new a('unexpected "state" response parameter value');
|
|
843
843
|
}
|
|
844
844
|
const i = k(n, "error");
|
|
@@ -848,27 +848,27 @@ function Pt(e, t, n, o) {
|
|
|
848
848
|
error_description: k(n, "error_description"),
|
|
849
849
|
error_uri: k(n, "error_uri")
|
|
850
850
|
};
|
|
851
|
-
const
|
|
852
|
-
if (
|
|
853
|
-
throw new
|
|
851
|
+
const u = k(n, "id_token"), g = k(n, "token");
|
|
852
|
+
if (u !== void 0 || g !== void 0)
|
|
853
|
+
throw new S("implicit and hybrid flows are not supported");
|
|
854
854
|
return mt(new URLSearchParams(n));
|
|
855
855
|
}
|
|
856
856
|
class x extends Error {
|
|
857
857
|
}
|
|
858
858
|
class G extends x {
|
|
859
|
-
constructor(
|
|
860
|
-
super(
|
|
859
|
+
constructor(e, n, r) {
|
|
860
|
+
super(e, r), this.error = n;
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
863
|
function xt({
|
|
864
|
-
handleCallback:
|
|
864
|
+
handleCallback: t
|
|
865
865
|
}) {
|
|
866
|
-
const
|
|
867
|
-
return
|
|
868
|
-
|
|
866
|
+
const e = je(!1), [n, r] = ze(void 0), s = xe();
|
|
867
|
+
return Je(() => {
|
|
868
|
+
e.current || (e.current = !0, t().then(() => {
|
|
869
869
|
s("/");
|
|
870
|
-
}).catch((
|
|
871
|
-
o
|
|
870
|
+
}).catch((o) => {
|
|
871
|
+
r(o);
|
|
872
872
|
}));
|
|
873
873
|
}, []), n ? n instanceof G ? /* @__PURE__ */ T.jsxs("div", { children: [
|
|
874
874
|
/* @__PURE__ */ T.jsx("h2", { children: "Error" }),
|
|
@@ -886,9 +886,9 @@ function xt({
|
|
|
886
886
|
] }) : /* @__PURE__ */ T.jsx("div", { children: "Loading..." });
|
|
887
887
|
}
|
|
888
888
|
const le = "code-verifier";
|
|
889
|
-
class
|
|
890
|
-
constructor(
|
|
891
|
-
super(), this.callbackUrlPath =
|
|
889
|
+
class Ut extends Ce {
|
|
890
|
+
constructor(e, n) {
|
|
891
|
+
super(), this.callbackUrlPath = e, this.handleCallback = n;
|
|
892
892
|
}
|
|
893
893
|
getRoutes() {
|
|
894
894
|
return [
|
|
@@ -900,62 +900,68 @@ class Lt extends Ce {
|
|
|
900
900
|
];
|
|
901
901
|
}
|
|
902
902
|
}
|
|
903
|
-
class
|
|
903
|
+
class Lt {
|
|
904
904
|
constructor({
|
|
905
|
-
issuer:
|
|
905
|
+
issuer: e,
|
|
906
906
|
authorizationEndpoint: n,
|
|
907
|
-
tokenEndpoint:
|
|
908
|
-
clientId: s
|
|
907
|
+
tokenEndpoint: r,
|
|
908
|
+
clientId: s,
|
|
909
|
+
redirectToAfterSignUp: o,
|
|
910
|
+
redirectToAfterSignIn: i,
|
|
911
|
+
redirectToAfterSignOut: u
|
|
909
912
|
}) {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
913
|
+
y(this, "client");
|
|
914
|
+
y(this, "issuer");
|
|
915
|
+
y(this, "authorizationEndpoint");
|
|
916
|
+
y(this, "tokenEndpoint");
|
|
917
|
+
y(this, "authorizationServer");
|
|
918
|
+
y(this, "tokens");
|
|
919
|
+
y(this, "callbackUrlPath", "/oauth/callback");
|
|
920
|
+
y(this, "logoutRedirectUrlPath", "/");
|
|
921
|
+
y(this, "redirectToAfterSignUp");
|
|
922
|
+
y(this, "redirectToAfterSignIn");
|
|
923
|
+
y(this, "redirectToAfterSignOut");
|
|
924
|
+
y(this, "handleCallback", async () => {
|
|
925
|
+
const e = new URL(window.location.href), n = e.searchParams.get("state"), r = localStorage.getItem(le);
|
|
926
|
+
if (!r)
|
|
921
927
|
throw new x(
|
|
922
928
|
"Code verifier not found. Invalid auth state."
|
|
923
929
|
);
|
|
924
|
-
const s = await this.getAuthServer(),
|
|
930
|
+
const s = await this.getAuthServer(), o = Pt(
|
|
925
931
|
s,
|
|
926
932
|
this.client,
|
|
927
|
-
|
|
933
|
+
e.searchParams,
|
|
928
934
|
n ?? void 0
|
|
929
935
|
);
|
|
930
|
-
if (B(
|
|
931
|
-
throw oe.error("Error validating OAuth response",
|
|
936
|
+
if (B(o))
|
|
937
|
+
throw oe.error("Error validating OAuth response", o), new G(
|
|
932
938
|
"Error validating OAuth response",
|
|
933
|
-
|
|
939
|
+
o
|
|
934
940
|
);
|
|
935
|
-
const i = new URL(
|
|
941
|
+
const i = new URL(e);
|
|
936
942
|
i.pathname = this.callbackUrlPath, i.search = "";
|
|
937
|
-
const
|
|
943
|
+
const u = await yt(
|
|
938
944
|
s,
|
|
939
945
|
this.client,
|
|
940
|
-
|
|
946
|
+
o,
|
|
941
947
|
i.toString(),
|
|
942
|
-
|
|
948
|
+
r
|
|
943
949
|
), g = await vt(
|
|
944
950
|
s,
|
|
945
951
|
this.client,
|
|
946
|
-
|
|
952
|
+
u
|
|
947
953
|
);
|
|
948
954
|
this.setTokensFromResponse(g);
|
|
949
|
-
const m = await this.getAccessToken(),
|
|
955
|
+
const m = await this.getAccessToken(), _ = await (await lt(
|
|
950
956
|
s,
|
|
951
957
|
this.client,
|
|
952
958
|
m
|
|
953
959
|
)).json(), h = {
|
|
954
|
-
sub:
|
|
955
|
-
email:
|
|
956
|
-
name:
|
|
957
|
-
emailVerified:
|
|
958
|
-
pictureUrl:
|
|
960
|
+
sub: _.sub,
|
|
961
|
+
email: _.email,
|
|
962
|
+
name: _.name,
|
|
963
|
+
emailVerified: _.email_verified ?? !1,
|
|
964
|
+
pictureUrl: _.picture
|
|
959
965
|
};
|
|
960
966
|
re.setState({
|
|
961
967
|
isAuthenticated: !0,
|
|
@@ -966,7 +972,7 @@ class Ut {
|
|
|
966
972
|
this.client = {
|
|
967
973
|
client_id: s,
|
|
968
974
|
token_endpoint_auth_method: "none"
|
|
969
|
-
}, this.issuer =
|
|
975
|
+
}, this.issuer = e, this.authorizationEndpoint = n, this.tokenEndpoint = r, this.redirectToAfterSignUp = o ?? "/", this.redirectToAfterSignIn = i ?? "/", this.redirectToAfterSignOut = u ?? "/";
|
|
970
976
|
}
|
|
971
977
|
async getAuthServer() {
|
|
972
978
|
if (!this.authorizationServer)
|
|
@@ -978,9 +984,9 @@ class Ut {
|
|
|
978
984
|
code_challenge_methods_supported: []
|
|
979
985
|
};
|
|
980
986
|
else {
|
|
981
|
-
const
|
|
987
|
+
const e = new URL(this.issuer), n = await Me(e);
|
|
982
988
|
this.authorizationServer = await Be(
|
|
983
|
-
|
|
989
|
+
e,
|
|
984
990
|
n
|
|
985
991
|
);
|
|
986
992
|
}
|
|
@@ -990,39 +996,47 @@ class Ut {
|
|
|
990
996
|
* Sets the tokens from various OAuth responses
|
|
991
997
|
* @param response
|
|
992
998
|
*/
|
|
993
|
-
setTokensFromResponse(
|
|
994
|
-
if (B(
|
|
995
|
-
throw oe.error("Bad Token Response",
|
|
996
|
-
if (!
|
|
999
|
+
setTokensFromResponse(e) {
|
|
1000
|
+
if (B(e))
|
|
1001
|
+
throw oe.error("Bad Token Response", e), new G("Bad Token Response", e);
|
|
1002
|
+
if (!e.expires_in)
|
|
997
1003
|
throw new x("No expires_in in response");
|
|
998
1004
|
this.tokens = {
|
|
999
|
-
accessToken:
|
|
1000
|
-
refreshToken:
|
|
1001
|
-
expiresOn: new Date(Date.now() +
|
|
1002
|
-
tokenType:
|
|
1005
|
+
accessToken: e.access_token,
|
|
1006
|
+
refreshToken: e.refresh_token,
|
|
1007
|
+
expiresOn: new Date(Date.now() + e.expires_in * 1e3),
|
|
1008
|
+
tokenType: e.token_type
|
|
1003
1009
|
};
|
|
1004
1010
|
}
|
|
1005
|
-
async
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1011
|
+
async signUp() {
|
|
1012
|
+
return this.authorize(!0);
|
|
1013
|
+
}
|
|
1014
|
+
async signIn() {
|
|
1015
|
+
return this.authorize();
|
|
1016
|
+
}
|
|
1017
|
+
async authorize(e = !1) {
|
|
1018
|
+
var g;
|
|
1019
|
+
const n = "S256", r = await this.getAuthServer();
|
|
1020
|
+
if (!r.authorization_endpoint)
|
|
1009
1021
|
throw new x("No authorization endpoint");
|
|
1010
|
-
const
|
|
1011
|
-
localStorage.setItem(le,
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
),
|
|
1015
|
-
|
|
1022
|
+
const s = Ge(), o = await Ve(s);
|
|
1023
|
+
localStorage.setItem(le, s);
|
|
1024
|
+
const i = new URL(
|
|
1025
|
+
e ? r.registration_endpoint ?? r.authorization_endpoint : r.authorization_endpoint
|
|
1026
|
+
), u = new URL(
|
|
1027
|
+
(e ? window.location.origin + this.redirectToAfterSignUp : window.location.origin + this.redirectToAfterSignIn) ?? window.location.href
|
|
1028
|
+
);
|
|
1029
|
+
if (u.pathname = this.callbackUrlPath, u.search = "", i.searchParams.set("client_id", this.client.client_id), i.searchParams.set("redirect_uri", u.toString()), i.searchParams.set("response_type", "code"), i.searchParams.set("scope", "openid+profile+email"), i.searchParams.set("code_challenge", o), i.searchParams.set(
|
|
1016
1030
|
"code_challenge_method",
|
|
1017
|
-
|
|
1018
|
-
), ((
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1031
|
+
n
|
|
1032
|
+
), ((g = r.code_challenge_methods_supported) == null ? void 0 : g.includes("S256")) !== !0) {
|
|
1033
|
+
const m = qe();
|
|
1034
|
+
i.searchParams.set("state", m);
|
|
1021
1035
|
}
|
|
1022
|
-
location.href =
|
|
1036
|
+
location.href = i.href;
|
|
1023
1037
|
}
|
|
1024
1038
|
async getAccessToken() {
|
|
1025
|
-
const
|
|
1039
|
+
const e = await this.getAuthServer();
|
|
1026
1040
|
if (!this.tokens)
|
|
1027
1041
|
throw new x("User is not authenticated");
|
|
1028
1042
|
if (this.tokens.expiresOn < /* @__PURE__ */ new Date()) {
|
|
@@ -1031,42 +1045,44 @@ class Ut {
|
|
|
1031
1045
|
"Token expired and no refresh token available"
|
|
1032
1046
|
);
|
|
1033
1047
|
const n = await ht(
|
|
1034
|
-
|
|
1048
|
+
e,
|
|
1035
1049
|
this.client,
|
|
1036
1050
|
this.tokens.refreshToken
|
|
1037
|
-
),
|
|
1038
|
-
|
|
1051
|
+
), r = await pt(
|
|
1052
|
+
e,
|
|
1039
1053
|
this.client,
|
|
1040
1054
|
n
|
|
1041
1055
|
);
|
|
1042
|
-
this.setTokensFromResponse(
|
|
1056
|
+
this.setTokensFromResponse(r);
|
|
1043
1057
|
}
|
|
1044
1058
|
return this.tokens.accessToken;
|
|
1045
1059
|
}
|
|
1046
|
-
async
|
|
1060
|
+
async signOut() {
|
|
1047
1061
|
re.setState({
|
|
1048
1062
|
isAuthenticated: !1,
|
|
1049
1063
|
isPending: !1,
|
|
1050
1064
|
profile: void 0
|
|
1051
1065
|
});
|
|
1052
|
-
const
|
|
1066
|
+
const e = await this.getAuthServer(), n = new URL(
|
|
1067
|
+
window.location.origin + this.redirectToAfterSignOut
|
|
1068
|
+
);
|
|
1053
1069
|
n.pathname = this.logoutRedirectUrlPath;
|
|
1054
|
-
let
|
|
1055
|
-
|
|
1070
|
+
let r;
|
|
1071
|
+
e.end_session_endpoint ? (r = new URL(e.end_session_endpoint), r.searchParams.set(
|
|
1056
1072
|
"post_logout_redirect_uri",
|
|
1057
1073
|
n.toString()
|
|
1058
|
-
)) :
|
|
1074
|
+
)) : r = n;
|
|
1059
1075
|
}
|
|
1060
1076
|
getAuthenticationPlugin() {
|
|
1061
|
-
return new
|
|
1077
|
+
return new Ut(
|
|
1062
1078
|
this.callbackUrlPath,
|
|
1063
1079
|
() => this.handleCallback()
|
|
1064
1080
|
);
|
|
1065
1081
|
}
|
|
1066
1082
|
}
|
|
1067
|
-
const Nt = (
|
|
1083
|
+
const Nt = (t) => new Lt(t);
|
|
1068
1084
|
export {
|
|
1069
|
-
|
|
1085
|
+
Lt as OpenIDAuthenticationProvider,
|
|
1070
1086
|
Nt as default
|
|
1071
1087
|
};
|
|
1072
1088
|
//# sourceMappingURL=zudoku.auth-openid.js.map
|