@wandelbots/wandelbots-js-react-components 4.7.2-pr.v4.554.f8a153d → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -32
- package/dist/3d.cjs.js +1 -1
- package/dist/3d.es.js +1 -1
- package/dist/MotionGroupVisualizer-C6MgXjCN.cjs +2 -0
- package/dist/MotionGroupVisualizer-C6MgXjCN.cjs.map +1 -0
- package/dist/MotionGroupVisualizer-Cm-XYEZe.js +1328 -0
- package/dist/{MotionGroupVisualizer-DP4K1dVw.cjs.map → MotionGroupVisualizer-Cm-XYEZe.js.map} +1 -1
- package/dist/auth0-spa-js.production.esm-CVEdrQ4-.cjs +5 -0
- package/dist/auth0-spa-js.production.esm-CVEdrQ4-.cjs.map +1 -0
- package/dist/auth0-spa-js.production.esm-Cr9w0sUa.js +4217 -0
- package/dist/auth0-spa-js.production.esm-Cr9w0sUa.js.map +1 -0
- package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts +1 -1
- package/dist/components/3d-viewport/CoordinateSystemTransform.d.ts.map +1 -1
- package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts +1 -2
- package/dist/components/3d-viewport/SafetyZonesRenderer.d.ts.map +1 -1
- package/dist/components/3d-viewport/TrajectoryRenderer.d.ts +2 -2
- package/dist/components/3d-viewport/TrajectoryRenderer.d.ts.map +1 -1
- package/dist/components/3d-viewport/collider/ColliderCollection.d.ts +1 -1
- package/dist/components/3d-viewport/collider/ColliderElement.d.ts +1 -1
- package/dist/components/3d-viewport/collider/CollisionSceneRenderer.d.ts +2 -2
- package/dist/components/3d-viewport/collider/colliderShapeToBufferGeometry.d.ts +1 -1
- package/dist/core.cjs.js +1 -1
- package/dist/core.es.js +37 -39
- package/dist/core.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +51 -55
- package/dist/index.es.js.map +1 -1
- package/dist/interpolation-GwZidExa.cjs +42 -0
- package/dist/interpolation-GwZidExa.cjs.map +1 -0
- package/dist/{interpolation-B8AcxfdD.js → interpolation-JdOMWH6y.js} +3635 -3115
- package/dist/interpolation-JdOMWH6y.js.map +1 -0
- package/dist/lib/ConnectedMotionGroup.d.ts +2 -3
- package/dist/lib/ConnectedMotionGroup.d.ts.map +1 -1
- package/dist/lib/MotionStreamConnection.d.ts +0 -1
- package/dist/lib/MotionStreamConnection.d.ts.map +1 -1
- package/dist/themes/createDarkTheme.d.ts.map +1 -1
- package/dist/themes/themeTypes.d.ts +0 -4
- package/dist/themes/themeTypes.d.ts.map +1 -1
- package/dist/{theming-BKpqgTRM.js → theming-B1iO9Lkl.js} +3104 -3062
- package/dist/theming-B1iO9Lkl.js.map +1 -0
- package/dist/theming-BKsKrdpU.cjs +115 -0
- package/dist/theming-BKsKrdpU.cjs.map +1 -0
- package/package.json +15 -29
- package/src/components/3d-viewport/CoordinateSystemTransform.tsx +29 -18
- package/src/components/3d-viewport/SafetyZonesRenderer.tsx +24 -151
- package/src/components/3d-viewport/TrajectoryRenderer.tsx +9 -10
- package/src/components/3d-viewport/collider/ColliderCollection.tsx +1 -1
- package/src/components/3d-viewport/collider/ColliderElement.tsx +1 -1
- package/src/components/3d-viewport/collider/CollisionSceneRenderer.tsx +2 -2
- package/src/components/3d-viewport/collider/colliderShapeToBufferGeometry.ts +1 -1
- package/src/index.ts +0 -1
- package/src/lib/ConnectedMotionGroup.ts +0 -5
- package/src/lib/MotionStreamConnection.ts +0 -5
- package/src/themes/createDarkTheme.ts +1 -22
- package/src/themes/themeTypes.ts +0 -5
- package/dist/LoadingCover-B3UN1lnU.js +0 -81
- package/dist/LoadingCover-B3UN1lnU.js.map +0 -1
- package/dist/LoadingCover-DXcsXWDy.cjs +0 -2
- package/dist/LoadingCover-DXcsXWDy.cjs.map +0 -1
- package/dist/MotionGroupVisualizer-CPEIGXUC.js +0 -1407
- package/dist/MotionGroupVisualizer-CPEIGXUC.js.map +0 -1
- package/dist/MotionGroupVisualizer-DP4K1dVw.cjs +0 -2
- package/dist/WandelscriptEditor-6sAoniLC.cjs +0 -2
- package/dist/WandelscriptEditor-6sAoniLC.cjs.map +0 -1
- package/dist/WandelscriptEditor-kWC2VyG_.js +0 -140
- package/dist/WandelscriptEditor-kWC2VyG_.js.map +0 -1
- package/dist/auth0-spa-js.production.esm-DNao6_S5.js +0 -4064
- package/dist/auth0-spa-js.production.esm-DNao6_S5.js.map +0 -1
- package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs +0 -5
- package/dist/auth0-spa-js.production.esm-DaBMfOV8.cjs.map +0 -1
- package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts +0 -16
- package/dist/components/wandelscript-editor/WandelscriptEditor.d.ts.map +0 -1
- package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts +0 -45
- package/dist/components/wandelscript-editor/wandelscript.tmLanguage.d.ts.map +0 -1
- package/dist/externalizeComponent-B98tgTPP.cjs +0 -24
- package/dist/externalizeComponent-B98tgTPP.cjs.map +0 -1
- package/dist/externalizeComponent-BOqKMZMc.js +0 -526
- package/dist/externalizeComponent-BOqKMZMc.js.map +0 -1
- package/dist/interpolation-B8AcxfdD.js.map +0 -1
- package/dist/interpolation-SWzo5zr4.cjs +0 -20
- package/dist/interpolation-SWzo5zr4.cjs.map +0 -1
- package/dist/theming-BKpqgTRM.js.map +0 -1
- package/dist/theming-CatQaIl_.cjs +0 -115
- package/dist/theming-CatQaIl_.cjs.map +0 -1
- package/dist/wandelscript.cjs.js +0 -2
- package/dist/wandelscript.cjs.js.map +0 -1
- package/dist/wandelscript.d.ts +0 -2
- package/dist/wandelscript.d.ts.map +0 -1
- package/dist/wandelscript.es.js +0 -5
- package/dist/wandelscript.es.js.map +0 -1
- package/src/components/wandelscript-editor/WandelscriptEditor.tsx +0 -142
- package/src/components/wandelscript-editor/wandelscript.tmLanguage.ts +0 -62
- package/src/wandelscript.ts +0 -2
|
@@ -1,4064 +0,0 @@
|
|
|
1
|
-
function X(n, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && e.indexOf(o) < 0 && (t[o] = n[o]);
|
|
4
|
-
if (n != null && typeof Object.getOwnPropertySymbols == "function") {
|
|
5
|
-
var r = 0;
|
|
6
|
-
for (o = Object.getOwnPropertySymbols(n); r < o.length; r++) e.indexOf(o[r]) < 0 && Object.prototype.propertyIsEnumerable.call(n, o[r]) && (t[o[r]] = n[o[r]]);
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
}
|
|
10
|
-
const Tr = { timeoutInSeconds: 60 }, xo = { name: "auth0-spa-js", version: "2.17.0" }, Co = () => Date.now();
|
|
11
|
-
class O extends Error {
|
|
12
|
-
constructor(e, t) {
|
|
13
|
-
super(t), this.error = e, this.error_description = t, Object.setPrototypeOf(this, O.prototype);
|
|
14
|
-
}
|
|
15
|
-
static fromPayload(e) {
|
|
16
|
-
let { error: t, error_description: o } = e;
|
|
17
|
-
return new O(t, o);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
class Cn extends O {
|
|
21
|
-
constructor(e, t, o) {
|
|
22
|
-
let r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
23
|
-
super(e, t), this.state = o, this.appState = r, Object.setPrototypeOf(this, Cn.prototype);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class jn extends O {
|
|
27
|
-
constructor(e, t, o, r) {
|
|
28
|
-
let i = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : null;
|
|
29
|
-
super(e, t), this.connection = o, this.state = r, this.appState = i, Object.setPrototypeOf(this, jn.prototype);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
class Fe extends O {
|
|
33
|
-
constructor() {
|
|
34
|
-
super("timeout", "Timeout"), Object.setPrototypeOf(this, Fe.prototype);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
class Dn extends Fe {
|
|
38
|
-
constructor(e) {
|
|
39
|
-
super(), this.popup = e, Object.setPrototypeOf(this, Dn.prototype);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class Ln extends O {
|
|
43
|
-
constructor(e) {
|
|
44
|
-
super("cancelled", "Popup closed"), this.popup = e, Object.setPrototypeOf(this, Ln.prototype);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
class Kn extends O {
|
|
48
|
-
constructor() {
|
|
49
|
-
super("popup_open", "Unable to open a popup for loginWithPopup - window.open returned `null`"), Object.setPrototypeOf(this, Kn.prototype);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class Je extends O {
|
|
53
|
-
constructor(e, t, o, r) {
|
|
54
|
-
super(e, t), this.mfa_token = o, this.mfa_requirements = r, Object.setPrototypeOf(this, Je.prototype);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
class Ut extends O {
|
|
58
|
-
constructor(e, t) {
|
|
59
|
-
super("missing_refresh_token", "Missing Refresh Token (audience: '".concat(Pt(e, ["default"]), "', scope: '").concat(Pt(t), "')")), this.audience = e, this.scope = t, Object.setPrototypeOf(this, Ut.prototype);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
class Un extends O {
|
|
63
|
-
constructor(e, t) {
|
|
64
|
-
super("missing_scopes", "Missing requested scopes after refresh (audience: '".concat(Pt(e, ["default"]), "', missing scope: '").concat(Pt(t), "')")), this.audience = e, this.scope = t, Object.setPrototypeOf(this, Un.prototype);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
class Nt extends O {
|
|
68
|
-
constructor(e) {
|
|
69
|
-
super("use_dpop_nonce", "Server rejected DPoP proof: wrong nonce"), this.newDpopNonce = e, Object.setPrototypeOf(this, Nt.prototype);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function Pt(n) {
|
|
73
|
-
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
74
|
-
return n && !e.includes(n) ? n : "";
|
|
75
|
-
}
|
|
76
|
-
const Rt = () => window.crypto, Ze = () => {
|
|
77
|
-
const n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_~.";
|
|
78
|
-
let e = "";
|
|
79
|
-
return Array.from(Rt().getRandomValues(new Uint8Array(43))).forEach(((t) => e += n[t % n.length])), e;
|
|
80
|
-
}, Jt = (n) => btoa(n), Pr = [{ key: "name", type: ["string"] }, { key: "version", type: ["string", "number"] }, { key: "env", type: ["object"] }], jo = function(n) {
|
|
81
|
-
let e = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
|
|
82
|
-
return Object.keys(n).reduce(((t, o) => {
|
|
83
|
-
if (e && o === "env") return t;
|
|
84
|
-
const r = Pr.find(((i) => i.key === o));
|
|
85
|
-
return r && r.type.includes(typeof n[o]) && (t[o] = n[o]), t;
|
|
86
|
-
}), {});
|
|
87
|
-
}, mn = (n) => {
|
|
88
|
-
var { clientId: e } = n, t = X(n, ["clientId"]);
|
|
89
|
-
return new URLSearchParams(((o) => Object.keys(o).filter(((r) => o[r] !== void 0)).reduce(((r, i) => Object.assign(Object.assign({}, r), { [i]: o[i] })), {}))(Object.assign({ client_id: e }, t))).toString();
|
|
90
|
-
}, $n = async (n) => await Rt().subtle.digest({ name: "SHA-256" }, new TextEncoder().encode(n)), eo = (n) => ((e) => decodeURIComponent(atob(e).split("").map(((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2))).join("")))(n.replace(/_/g, "/").replace(/-/g, "+")), to = (n) => {
|
|
91
|
-
const e = new Uint8Array(n);
|
|
92
|
-
return ((t) => {
|
|
93
|
-
const o = { "+": "-", "/": "_", "=": "" };
|
|
94
|
-
return t.replace(/[+/=]/g, ((r) => o[r]));
|
|
95
|
-
})(window.btoa(String.fromCharCode(...Array.from(e))));
|
|
96
|
-
};
|
|
97
|
-
var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Do = {}, Nn = {};
|
|
98
|
-
Object.defineProperty(Nn, "__esModule", { value: !0 });
|
|
99
|
-
var Rr = (function() {
|
|
100
|
-
function n() {
|
|
101
|
-
var e = this;
|
|
102
|
-
this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(t, o) {
|
|
103
|
-
var r = e.locked.get(t);
|
|
104
|
-
r === void 0 ? o === void 0 ? e.locked.set(t, []) : e.locked.set(t, [o]) : o !== void 0 && (r.unshift(o), e.locked.set(t, r));
|
|
105
|
-
}, this.isLocked = function(t) {
|
|
106
|
-
return e.locked.has(t);
|
|
107
|
-
}, this.lock = function(t) {
|
|
108
|
-
return new Promise((function(o, r) {
|
|
109
|
-
e.isLocked(t) ? e.addToLocked(t, o) : (e.addToLocked(t), o());
|
|
110
|
-
}));
|
|
111
|
-
}, this.unlock = function(t) {
|
|
112
|
-
var o = e.locked.get(t);
|
|
113
|
-
if (o !== void 0 && o.length !== 0) {
|
|
114
|
-
var r = o.pop();
|
|
115
|
-
e.locked.set(t, o), r !== void 0 && setTimeout(r, 0);
|
|
116
|
-
} else e.locked.delete(t);
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return n.getInstance = function() {
|
|
120
|
-
return n.instance === void 0 && (n.instance = new n()), n.instance;
|
|
121
|
-
}, n;
|
|
122
|
-
})();
|
|
123
|
-
Nn.default = function() {
|
|
124
|
-
return Rr.getInstance();
|
|
125
|
-
};
|
|
126
|
-
var Y = Ce && Ce.__awaiter || function(n, e, t, o) {
|
|
127
|
-
return new (t || (t = Promise))((function(r, i) {
|
|
128
|
-
function a(u) {
|
|
129
|
-
try {
|
|
130
|
-
c(o.next(u));
|
|
131
|
-
} catch (l) {
|
|
132
|
-
i(l);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function s(u) {
|
|
136
|
-
try {
|
|
137
|
-
c(o.throw(u));
|
|
138
|
-
} catch (l) {
|
|
139
|
-
i(l);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function c(u) {
|
|
143
|
-
u.done ? r(u.value) : new t((function(l) {
|
|
144
|
-
l(u.value);
|
|
145
|
-
})).then(a, s);
|
|
146
|
-
}
|
|
147
|
-
c((o = o.apply(n, e || [])).next());
|
|
148
|
-
}));
|
|
149
|
-
}, Q = Ce && Ce.__generator || function(n, e) {
|
|
150
|
-
var t, o, r, i, a = { label: 0, sent: function() {
|
|
151
|
-
if (1 & r[0]) throw r[1];
|
|
152
|
-
return r[1];
|
|
153
|
-
}, trys: [], ops: [] };
|
|
154
|
-
return i = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
|
|
155
|
-
return this;
|
|
156
|
-
}), i;
|
|
157
|
-
function s(c) {
|
|
158
|
-
return function(u) {
|
|
159
|
-
return (function(l) {
|
|
160
|
-
if (t) throw new TypeError("Generator is already executing.");
|
|
161
|
-
for (; a; ) try {
|
|
162
|
-
if (t = 1, o && (r = 2 & l[0] ? o.return : l[0] ? o.throw || ((r = o.return) && r.call(o), 0) : o.next) && !(r = r.call(o, l[1])).done) return r;
|
|
163
|
-
switch (o = 0, r && (l = [2 & l[0], r.value]), l[0]) {
|
|
164
|
-
case 0:
|
|
165
|
-
case 1:
|
|
166
|
-
r = l;
|
|
167
|
-
break;
|
|
168
|
-
case 4:
|
|
169
|
-
return a.label++, { value: l[1], done: !1 };
|
|
170
|
-
case 5:
|
|
171
|
-
a.label++, o = l[1], l = [0];
|
|
172
|
-
continue;
|
|
173
|
-
case 7:
|
|
174
|
-
l = a.ops.pop(), a.trys.pop();
|
|
175
|
-
continue;
|
|
176
|
-
default:
|
|
177
|
-
if (r = a.trys, !((r = r.length > 0 && r[r.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
|
|
178
|
-
a = 0;
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
if (l[0] === 3 && (!r || l[1] > r[0] && l[1] < r[3])) {
|
|
182
|
-
a.label = l[1];
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (l[0] === 6 && a.label < r[1]) {
|
|
186
|
-
a.label = r[1], r = l;
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
if (r && a.label < r[2]) {
|
|
190
|
-
a.label = r[2], a.ops.push(l);
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
r[2] && a.ops.pop(), a.trys.pop();
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
l = e.call(n, a);
|
|
197
|
-
} catch (f) {
|
|
198
|
-
l = [6, f], o = 0;
|
|
199
|
-
} finally {
|
|
200
|
-
t = r = 0;
|
|
201
|
-
}
|
|
202
|
-
if (5 & l[0]) throw l[1];
|
|
203
|
-
return { value: l[0] ? l[1] : void 0, done: !0 };
|
|
204
|
-
})([c, u]);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}, qe = Ce;
|
|
208
|
-
Object.defineProperty(Do, "__esModule", { value: !0 });
|
|
209
|
-
var Le = Nn, mt = { key: function(n) {
|
|
210
|
-
return Y(qe, void 0, void 0, (function() {
|
|
211
|
-
return Q(this, (function(e) {
|
|
212
|
-
throw new Error("Unsupported");
|
|
213
|
-
}));
|
|
214
|
-
}));
|
|
215
|
-
}, getItem: function(n) {
|
|
216
|
-
return Y(qe, void 0, void 0, (function() {
|
|
217
|
-
return Q(this, (function(e) {
|
|
218
|
-
throw new Error("Unsupported");
|
|
219
|
-
}));
|
|
220
|
-
}));
|
|
221
|
-
}, clear: function() {
|
|
222
|
-
return Y(qe, void 0, void 0, (function() {
|
|
223
|
-
return Q(this, (function(n) {
|
|
224
|
-
return [2, window.localStorage.clear()];
|
|
225
|
-
}));
|
|
226
|
-
}));
|
|
227
|
-
}, removeItem: function(n) {
|
|
228
|
-
return Y(qe, void 0, void 0, (function() {
|
|
229
|
-
return Q(this, (function(e) {
|
|
230
|
-
throw new Error("Unsupported");
|
|
231
|
-
}));
|
|
232
|
-
}));
|
|
233
|
-
}, setItem: function(n, e) {
|
|
234
|
-
return Y(qe, void 0, void 0, (function() {
|
|
235
|
-
return Q(this, (function(t) {
|
|
236
|
-
throw new Error("Unsupported");
|
|
237
|
-
}));
|
|
238
|
-
}));
|
|
239
|
-
}, keySync: function(n) {
|
|
240
|
-
return window.localStorage.key(n);
|
|
241
|
-
}, getItemSync: function(n) {
|
|
242
|
-
return window.localStorage.getItem(n);
|
|
243
|
-
}, clearSync: function() {
|
|
244
|
-
return window.localStorage.clear();
|
|
245
|
-
}, removeItemSync: function(n) {
|
|
246
|
-
return window.localStorage.removeItem(n);
|
|
247
|
-
}, setItemSync: function(n, e) {
|
|
248
|
-
return window.localStorage.setItem(n, e);
|
|
249
|
-
} };
|
|
250
|
-
function Vt(n) {
|
|
251
|
-
return new Promise((function(e) {
|
|
252
|
-
return setTimeout(e, n);
|
|
253
|
-
}));
|
|
254
|
-
}
|
|
255
|
-
function Ft(n) {
|
|
256
|
-
for (var e = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", t = "", o = 0; o < n; o++)
|
|
257
|
-
t += e[Math.floor(Math.random() * e.length)];
|
|
258
|
-
return t;
|
|
259
|
-
}
|
|
260
|
-
var Ir = (function() {
|
|
261
|
-
function n(e) {
|
|
262
|
-
this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + Ft(15), this.acquireLock = this.acquireLock.bind(this), this.releaseLock = this.releaseLock.bind(this), this.releaseLock__private__ = this.releaseLock__private__.bind(this), this.waitForSomethingToChange = this.waitForSomethingToChange.bind(this), this.refreshLockWhileAcquired = this.refreshLockWhileAcquired.bind(this), this.storageHandler = e, n.waiters === void 0 && (n.waiters = []);
|
|
263
|
-
}
|
|
264
|
-
return n.prototype.acquireLock = function(e, t) {
|
|
265
|
-
return t === void 0 && (t = 5e3), Y(this, void 0, void 0, (function() {
|
|
266
|
-
var o, r, i, a, s, c, u;
|
|
267
|
-
return Q(this, (function(l) {
|
|
268
|
-
switch (l.label) {
|
|
269
|
-
case 0:
|
|
270
|
-
o = Date.now() + Ft(4), r = Date.now() + t, i = "browser-tabs-lock-key-" + e, a = this.storageHandler === void 0 ? mt : this.storageHandler, l.label = 1;
|
|
271
|
-
case 1:
|
|
272
|
-
return Date.now() < r ? [4, Vt(30)] : [3, 8];
|
|
273
|
-
case 2:
|
|
274
|
-
return l.sent(), a.getItemSync(i) !== null ? [3, 5] : (s = this.id + "-" + e + "-" + o, [4, Vt(Math.floor(25 * Math.random()))]);
|
|
275
|
-
case 3:
|
|
276
|
-
return l.sent(), a.setItemSync(i, JSON.stringify({ id: this.id, iat: o, timeoutKey: s, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, Vt(30)];
|
|
277
|
-
case 4:
|
|
278
|
-
return l.sent(), (c = a.getItemSync(i)) !== null && (u = JSON.parse(c)).id === this.id && u.iat === o ? (this.acquiredIatSet.add(o), this.refreshLockWhileAcquired(i, o), [2, !0]) : [3, 7];
|
|
279
|
-
case 5:
|
|
280
|
-
return n.lockCorrector(this.storageHandler === void 0 ? mt : this.storageHandler), [4, this.waitForSomethingToChange(r)];
|
|
281
|
-
case 6:
|
|
282
|
-
l.sent(), l.label = 7;
|
|
283
|
-
case 7:
|
|
284
|
-
return o = Date.now() + Ft(4), [3, 1];
|
|
285
|
-
case 8:
|
|
286
|
-
return [2, !1];
|
|
287
|
-
}
|
|
288
|
-
}));
|
|
289
|
-
}));
|
|
290
|
-
}, n.prototype.refreshLockWhileAcquired = function(e, t) {
|
|
291
|
-
return Y(this, void 0, void 0, (function() {
|
|
292
|
-
var o = this;
|
|
293
|
-
return Q(this, (function(r) {
|
|
294
|
-
return setTimeout((function() {
|
|
295
|
-
return Y(o, void 0, void 0, (function() {
|
|
296
|
-
var i, a, s;
|
|
297
|
-
return Q(this, (function(c) {
|
|
298
|
-
switch (c.label) {
|
|
299
|
-
case 0:
|
|
300
|
-
return [4, Le.default().lock(t)];
|
|
301
|
-
case 1:
|
|
302
|
-
return c.sent(), this.acquiredIatSet.has(t) ? (i = this.storageHandler === void 0 ? mt : this.storageHandler, (a = i.getItemSync(e)) === null ? (Le.default().unlock(t), [2]) : ((s = JSON.parse(a)).timeRefreshed = Date.now(), i.setItemSync(e, JSON.stringify(s)), Le.default().unlock(t), this.refreshLockWhileAcquired(e, t), [2])) : (Le.default().unlock(t), [2]);
|
|
303
|
-
}
|
|
304
|
-
}));
|
|
305
|
-
}));
|
|
306
|
-
}), 1e3), [2];
|
|
307
|
-
}));
|
|
308
|
-
}));
|
|
309
|
-
}, n.prototype.waitForSomethingToChange = function(e) {
|
|
310
|
-
return Y(this, void 0, void 0, (function() {
|
|
311
|
-
return Q(this, (function(t) {
|
|
312
|
-
switch (t.label) {
|
|
313
|
-
case 0:
|
|
314
|
-
return [4, new Promise((function(o) {
|
|
315
|
-
var r = !1, i = Date.now(), a = !1;
|
|
316
|
-
function s() {
|
|
317
|
-
if (a || (window.removeEventListener("storage", s), n.removeFromWaiting(s), clearTimeout(c), a = !0), !r) {
|
|
318
|
-
r = !0;
|
|
319
|
-
var u = 50 - (Date.now() - i);
|
|
320
|
-
u > 0 ? setTimeout(o, u) : o(null);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
window.addEventListener("storage", s), n.addToWaiting(s);
|
|
324
|
-
var c = setTimeout(s, Math.max(0, e - Date.now()));
|
|
325
|
-
}))];
|
|
326
|
-
case 1:
|
|
327
|
-
return t.sent(), [2];
|
|
328
|
-
}
|
|
329
|
-
}));
|
|
330
|
-
}));
|
|
331
|
-
}, n.addToWaiting = function(e) {
|
|
332
|
-
this.removeFromWaiting(e), n.waiters !== void 0 && n.waiters.push(e);
|
|
333
|
-
}, n.removeFromWaiting = function(e) {
|
|
334
|
-
n.waiters !== void 0 && (n.waiters = n.waiters.filter((function(t) {
|
|
335
|
-
return t !== e;
|
|
336
|
-
})));
|
|
337
|
-
}, n.notifyWaiters = function() {
|
|
338
|
-
n.waiters !== void 0 && n.waiters.slice().forEach((function(e) {
|
|
339
|
-
return e();
|
|
340
|
-
}));
|
|
341
|
-
}, n.prototype.releaseLock = function(e) {
|
|
342
|
-
return Y(this, void 0, void 0, (function() {
|
|
343
|
-
return Q(this, (function(t) {
|
|
344
|
-
switch (t.label) {
|
|
345
|
-
case 0:
|
|
346
|
-
return [4, this.releaseLock__private__(e)];
|
|
347
|
-
case 1:
|
|
348
|
-
return [2, t.sent()];
|
|
349
|
-
}
|
|
350
|
-
}));
|
|
351
|
-
}));
|
|
352
|
-
}, n.prototype.releaseLock__private__ = function(e) {
|
|
353
|
-
return Y(this, void 0, void 0, (function() {
|
|
354
|
-
var t, o, r, i;
|
|
355
|
-
return Q(this, (function(a) {
|
|
356
|
-
switch (a.label) {
|
|
357
|
-
case 0:
|
|
358
|
-
return t = this.storageHandler === void 0 ? mt : this.storageHandler, o = "browser-tabs-lock-key-" + e, (r = t.getItemSync(o)) === null ? [2] : (i = JSON.parse(r)).id !== this.id ? [3, 2] : [4, Le.default().lock(i.iat)];
|
|
359
|
-
case 1:
|
|
360
|
-
a.sent(), this.acquiredIatSet.delete(i.iat), t.removeItemSync(o), Le.default().unlock(i.iat), n.notifyWaiters(), a.label = 2;
|
|
361
|
-
case 2:
|
|
362
|
-
return [2];
|
|
363
|
-
}
|
|
364
|
-
}));
|
|
365
|
-
}));
|
|
366
|
-
}, n.lockCorrector = function(e) {
|
|
367
|
-
for (var t = Date.now() - 5e3, o = e, r = [], i = 0; ; ) {
|
|
368
|
-
var a = o.keySync(i);
|
|
369
|
-
if (a === null) break;
|
|
370
|
-
r.push(a), i++;
|
|
371
|
-
}
|
|
372
|
-
for (var s = !1, c = 0; c < r.length; c++) {
|
|
373
|
-
var u = r[c];
|
|
374
|
-
if (u.includes("browser-tabs-lock-key")) {
|
|
375
|
-
var l = o.getItemSync(u);
|
|
376
|
-
if (l !== null) {
|
|
377
|
-
var f = JSON.parse(l);
|
|
378
|
-
(f.timeRefreshed === void 0 && f.timeAcquired < t || f.timeRefreshed !== void 0 && f.timeRefreshed < t) && (o.removeItemSync(u), s = !0);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
s && n.notifyWaiters();
|
|
383
|
-
}, n.waiters = void 0, n;
|
|
384
|
-
})(), Or = Do.default = Ir;
|
|
385
|
-
class xr {
|
|
386
|
-
async runWithLock(e, t, o) {
|
|
387
|
-
const r = new AbortController(), i = setTimeout((() => r.abort()), t);
|
|
388
|
-
try {
|
|
389
|
-
return await navigator.locks.request(e, { mode: "exclusive", signal: r.signal }, (async (a) => {
|
|
390
|
-
if (clearTimeout(i), !a) throw new Error("Lock not available");
|
|
391
|
-
return await o();
|
|
392
|
-
}));
|
|
393
|
-
} catch (a) {
|
|
394
|
-
throw clearTimeout(i), (a == null ? void 0 : a.name) === "AbortError" ? new Fe() : a;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
class Cr {
|
|
399
|
-
constructor() {
|
|
400
|
-
this.activeLocks = /* @__PURE__ */ new Set(), this.lock = new Or(), this.pagehideHandler = () => {
|
|
401
|
-
this.activeLocks.forEach(((e) => this.lock.releaseLock(e))), this.activeLocks.clear();
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
async runWithLock(e, t, o) {
|
|
405
|
-
let r = !1;
|
|
406
|
-
for (let i = 0; i < 10 && !r; i++) r = await this.lock.acquireLock(e, t);
|
|
407
|
-
if (!r) throw new Fe();
|
|
408
|
-
this.activeLocks.add(e), this.activeLocks.size === 1 && typeof window < "u" && window.addEventListener("pagehide", this.pagehideHandler);
|
|
409
|
-
try {
|
|
410
|
-
return await o();
|
|
411
|
-
} finally {
|
|
412
|
-
this.activeLocks.delete(e), await this.lock.releaseLock(e), this.activeLocks.size === 0 && typeof window < "u" && window.removeEventListener("pagehide", this.pagehideHandler);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
function jr() {
|
|
417
|
-
return typeof navigator < "u" && typeof ((n = navigator.locks) === null || n === void 0 ? void 0 : n.request) == "function" ? new xr() : new Cr();
|
|
418
|
-
var n;
|
|
419
|
-
}
|
|
420
|
-
let Gt = null;
|
|
421
|
-
const Dr = new TextEncoder(), Lr = new TextDecoder();
|
|
422
|
-
function $e(n) {
|
|
423
|
-
return typeof n == "string" ? Dr.encode(n) : Lr.decode(n);
|
|
424
|
-
}
|
|
425
|
-
function no(n) {
|
|
426
|
-
if (typeof n.modulusLength != "number" || n.modulusLength < 2048) throw new Ur(`${n.name} modulusLength must be at least 2048 bits`);
|
|
427
|
-
}
|
|
428
|
-
async function Kr(n, e, t) {
|
|
429
|
-
if (t.usages.includes("sign") === !1) throw new TypeError('private CryptoKey instances used for signing assertions must include "sign" in their "usages"');
|
|
430
|
-
const o = `${et($e(JSON.stringify(n)))}.${et($e(JSON.stringify(e)))}`;
|
|
431
|
-
return `${o}.${et(await crypto.subtle.sign((function(r) {
|
|
432
|
-
switch (r.algorithm.name) {
|
|
433
|
-
case "ECDSA":
|
|
434
|
-
return { name: r.algorithm.name, hash: "SHA-256" };
|
|
435
|
-
case "RSA-PSS":
|
|
436
|
-
return no(r.algorithm), { name: r.algorithm.name, saltLength: 32 };
|
|
437
|
-
case "RSASSA-PKCS1-v1_5":
|
|
438
|
-
return no(r.algorithm), { name: r.algorithm.name };
|
|
439
|
-
case "Ed25519":
|
|
440
|
-
return { name: r.algorithm.name };
|
|
441
|
-
}
|
|
442
|
-
throw new Oe();
|
|
443
|
-
})(t), t, $e(o)))}`;
|
|
444
|
-
}
|
|
445
|
-
let yn;
|
|
446
|
-
Uint8Array.prototype.toBase64 ? yn = (n) => (n instanceof ArrayBuffer && (n = new Uint8Array(n)), n.toBase64({ alphabet: "base64url", omitPadding: !0 })) : yn = (e) => {
|
|
447
|
-
e instanceof ArrayBuffer && (e = new Uint8Array(e));
|
|
448
|
-
const t = [];
|
|
449
|
-
for (let o = 0; o < e.byteLength; o += 32768) t.push(String.fromCharCode.apply(null, e.subarray(o, o + 32768)));
|
|
450
|
-
return btoa(t.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
451
|
-
};
|
|
452
|
-
function et(n) {
|
|
453
|
-
return yn(n);
|
|
454
|
-
}
|
|
455
|
-
class Oe extends Error {
|
|
456
|
-
constructor(e) {
|
|
457
|
-
var t;
|
|
458
|
-
super(e ?? "operation not supported"), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
class Ur extends Error {
|
|
462
|
-
constructor(e) {
|
|
463
|
-
var t;
|
|
464
|
-
super(e), this.name = this.constructor.name, (t = Error.captureStackTrace) === null || t === void 0 || t.call(Error, this, this.constructor);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
function Nr(n) {
|
|
468
|
-
switch (n.algorithm.name) {
|
|
469
|
-
case "RSA-PSS":
|
|
470
|
-
return (function(e) {
|
|
471
|
-
if (e.algorithm.hash.name === "SHA-256") return "PS256";
|
|
472
|
-
throw new Oe("unsupported RsaHashedKeyAlgorithm hash name");
|
|
473
|
-
})(n);
|
|
474
|
-
case "RSASSA-PKCS1-v1_5":
|
|
475
|
-
return (function(e) {
|
|
476
|
-
if (e.algorithm.hash.name === "SHA-256") return "RS256";
|
|
477
|
-
throw new Oe("unsupported RsaHashedKeyAlgorithm hash name");
|
|
478
|
-
})(n);
|
|
479
|
-
case "ECDSA":
|
|
480
|
-
return (function(e) {
|
|
481
|
-
if (e.algorithm.namedCurve === "P-256") return "ES256";
|
|
482
|
-
throw new Oe("unsupported EcKeyAlgorithm namedCurve");
|
|
483
|
-
})(n);
|
|
484
|
-
case "Ed25519":
|
|
485
|
-
return "Ed25519";
|
|
486
|
-
default:
|
|
487
|
-
throw new Oe("unsupported CryptoKey algorithm name");
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
function Lo(n) {
|
|
491
|
-
return n instanceof CryptoKey;
|
|
492
|
-
}
|
|
493
|
-
function Ko(n) {
|
|
494
|
-
return Lo(n) && n.type === "public";
|
|
495
|
-
}
|
|
496
|
-
async function Wr(n, e, t, o, r, i) {
|
|
497
|
-
const a = n == null ? void 0 : n.privateKey, s = n == null ? void 0 : n.publicKey;
|
|
498
|
-
if (!Lo(c = a) || c.type !== "private") throw new TypeError('"keypair.privateKey" must be a private CryptoKey');
|
|
499
|
-
var c;
|
|
500
|
-
if (!Ko(s)) throw new TypeError('"keypair.publicKey" must be a public CryptoKey');
|
|
501
|
-
if (s.extractable !== !0) throw new TypeError('"keypair.publicKey.extractable" must be true');
|
|
502
|
-
if (typeof e != "string") throw new TypeError('"htu" must be a string');
|
|
503
|
-
if (typeof t != "string") throw new TypeError('"htm" must be a string');
|
|
504
|
-
if (o !== void 0 && typeof o != "string") throw new TypeError('"nonce" must be a string or undefined');
|
|
505
|
-
if (r !== void 0 && typeof r != "string") throw new TypeError('"accessToken" must be a string or undefined');
|
|
506
|
-
return Kr({ alg: Nr(a), typ: "dpop+jwt", jwk: await Uo(s) }, Object.assign(Object.assign({}, i), { iat: Math.floor(Date.now() / 1e3), jti: crypto.randomUUID(), htm: t, nonce: o, htu: e, ath: r ? et(await crypto.subtle.digest("SHA-256", $e(r))) : void 0 }), a);
|
|
507
|
-
}
|
|
508
|
-
async function Uo(n) {
|
|
509
|
-
const { kty: e, e: t, n: o, x: r, y: i, crv: a } = await crypto.subtle.exportKey("jwk", n);
|
|
510
|
-
return { kty: e, crv: a, e: t, n: o, x: r, y: i };
|
|
511
|
-
}
|
|
512
|
-
const zr = ["authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:token-exchange", "http://auth0.com/oauth/grant-type/mfa-oob", "http://auth0.com/oauth/grant-type/mfa-otp", "http://auth0.com/oauth/grant-type/mfa-recovery-code"];
|
|
513
|
-
function Hr() {
|
|
514
|
-
return (async function(n, e) {
|
|
515
|
-
var t;
|
|
516
|
-
let o;
|
|
517
|
-
if (n.length === 0) throw new TypeError('"alg" must be a non-empty string');
|
|
518
|
-
switch (n) {
|
|
519
|
-
case "PS256":
|
|
520
|
-
o = { name: "RSA-PSS", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
|
|
521
|
-
break;
|
|
522
|
-
case "RS256":
|
|
523
|
-
o = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]) };
|
|
524
|
-
break;
|
|
525
|
-
case "ES256":
|
|
526
|
-
o = { name: "ECDSA", namedCurve: "P-256" };
|
|
527
|
-
break;
|
|
528
|
-
case "Ed25519":
|
|
529
|
-
o = { name: "Ed25519" };
|
|
530
|
-
break;
|
|
531
|
-
default:
|
|
532
|
-
throw new Oe();
|
|
533
|
-
}
|
|
534
|
-
return crypto.subtle.generateKey(o, (t = e == null ? void 0 : e.extractable) !== null && t !== void 0 && t, ["sign", "verify"]);
|
|
535
|
-
})("ES256", { extractable: !1 });
|
|
536
|
-
}
|
|
537
|
-
function Mr(n) {
|
|
538
|
-
return (async function(e) {
|
|
539
|
-
if (!Ko(e)) throw new TypeError('"publicKey" must be a public CryptoKey');
|
|
540
|
-
if (e.extractable !== !0) throw new TypeError('"publicKey.extractable" must be true');
|
|
541
|
-
const t = await Uo(e);
|
|
542
|
-
let o;
|
|
543
|
-
switch (t.kty) {
|
|
544
|
-
case "EC":
|
|
545
|
-
o = { crv: t.crv, kty: t.kty, x: t.x, y: t.y };
|
|
546
|
-
break;
|
|
547
|
-
case "OKP":
|
|
548
|
-
o = { crv: t.crv, kty: t.kty, x: t.x };
|
|
549
|
-
break;
|
|
550
|
-
case "RSA":
|
|
551
|
-
o = { e: t.e, kty: t.kty, n: t.n };
|
|
552
|
-
break;
|
|
553
|
-
default:
|
|
554
|
-
throw new Oe("unsupported JWK kty");
|
|
555
|
-
}
|
|
556
|
-
return et(await crypto.subtle.digest({ name: "SHA-256" }, $e(JSON.stringify(o))));
|
|
557
|
-
})(n.publicKey);
|
|
558
|
-
}
|
|
559
|
-
function Jr(n) {
|
|
560
|
-
let { keyPair: e, url: t, method: o, nonce: r, accessToken: i } = n;
|
|
561
|
-
const a = (function(s) {
|
|
562
|
-
const c = new URL(s);
|
|
563
|
-
return c.search = "", c.hash = "", c.href;
|
|
564
|
-
})(t);
|
|
565
|
-
return Wr(e, a, o, r, i);
|
|
566
|
-
}
|
|
567
|
-
const Vr = async (n, e) => {
|
|
568
|
-
const t = await fetch(n, e);
|
|
569
|
-
return { ok: t.ok, json: await t.json(), headers: (o = t.headers, [...o].reduce(((r, i) => {
|
|
570
|
-
let [a, s] = i;
|
|
571
|
-
return r[a] = s, r;
|
|
572
|
-
}), {})) };
|
|
573
|
-
var o;
|
|
574
|
-
}, Fr = async (n, e, t) => {
|
|
575
|
-
const o = new AbortController();
|
|
576
|
-
let r;
|
|
577
|
-
return e.signal = o.signal, Promise.race([Vr(n, e), new Promise(((i, a) => {
|
|
578
|
-
r = setTimeout((() => {
|
|
579
|
-
o.abort(), a(new Error("Timeout when executing 'fetch'"));
|
|
580
|
-
}), t);
|
|
581
|
-
}))]).finally((() => {
|
|
582
|
-
clearTimeout(r);
|
|
583
|
-
}));
|
|
584
|
-
}, Gr = async (n, e, t, o, r, i, a, s) => ((c, u) => new Promise((function(l, f) {
|
|
585
|
-
const h = new MessageChannel();
|
|
586
|
-
h.port1.onmessage = function(d) {
|
|
587
|
-
d.data.error ? f(new Error(d.data.error)) : l(d.data), h.port1.close();
|
|
588
|
-
}, u.postMessage(c, [h.port2]);
|
|
589
|
-
})))({ auth: { audience: e, scope: t }, timeout: r, fetchUrl: n, fetchOptions: o, useFormData: a, useMrrt: s }, i), Zr = async function(n, e, t, o, r, i) {
|
|
590
|
-
let a = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : 1e4, s = arguments.length > 7 ? arguments[7] : void 0;
|
|
591
|
-
return r ? Gr(n, e, t, o, a, r, i, s) : Fr(n, o, a);
|
|
592
|
-
};
|
|
593
|
-
async function No(n, e, t, o, r, i, a, s, c, u) {
|
|
594
|
-
if (c) {
|
|
595
|
-
const k = await c.generateProof({ url: n, method: r.method || "GET", nonce: await c.getNonce() });
|
|
596
|
-
r.headers = Object.assign(Object.assign({}, r.headers), { dpop: k });
|
|
597
|
-
}
|
|
598
|
-
let l, f = null;
|
|
599
|
-
for (let k = 0; k < 3; k++) try {
|
|
600
|
-
l = await Zr(n, t, o, r, i, a, e, s), f = null;
|
|
601
|
-
break;
|
|
602
|
-
} catch (E) {
|
|
603
|
-
f = E;
|
|
604
|
-
}
|
|
605
|
-
if (f) throw f;
|
|
606
|
-
const h = l.json, { error: d, error_description: w } = h, m = X(h, ["error", "error_description"]), { headers: p, ok: g } = l;
|
|
607
|
-
let b;
|
|
608
|
-
if (c && (b = p["dpop-nonce"], b && await c.setNonce(b)), !g) {
|
|
609
|
-
const k = w || "HTTP error. Unable to fetch ".concat(n);
|
|
610
|
-
if (d === "mfa_required") throw new Je(d, k, m.mfa_token, m.mfa_requirements);
|
|
611
|
-
if (d === "missing_refresh_token") throw new Ut(t, o);
|
|
612
|
-
if (d === "use_dpop_nonce") {
|
|
613
|
-
if (!c || !b || u) throw new Nt(b);
|
|
614
|
-
return No(n, e, t, o, r, i, a, s, c, !0);
|
|
615
|
-
}
|
|
616
|
-
throw new O(d || "request_error", k);
|
|
617
|
-
}
|
|
618
|
-
return m;
|
|
619
|
-
}
|
|
620
|
-
async function qr(n, e) {
|
|
621
|
-
var { baseUrl: t, timeout: o, audience: r, scope: i, auth0Client: a, useFormData: s, useMrrt: c, dpop: u } = n, l = X(n, ["baseUrl", "timeout", "audience", "scope", "auth0Client", "useFormData", "useMrrt", "dpop"]);
|
|
622
|
-
const f = l.grant_type === "urn:ietf:params:oauth:grant-type:token-exchange", h = l.grant_type === "refresh_token" && c, d = Object.assign(Object.assign(Object.assign(Object.assign({}, l), f && r && { audience: r }), f && i && { scope: i }), h && { audience: r, scope: i }), w = s ? mn(d) : JSON.stringify(d), m = (p = l.grant_type, zr.includes(p));
|
|
623
|
-
var p;
|
|
624
|
-
return await No("".concat(t, "/oauth/token"), o, r || "default", i, { method: "POST", body: w, headers: { "Content-Type": s ? "application/x-www-form-urlencoded" : "application/json", "Auth0-Client": btoa(JSON.stringify(jo(a || xo))) } }, e, s, c, m ? u : void 0);
|
|
625
|
-
}
|
|
626
|
-
const Br = (n) => Array.from(new Set(n)), Et = function() {
|
|
627
|
-
for (var n = arguments.length, e = new Array(n), t = 0; t < n; t++) e[t] = arguments[t];
|
|
628
|
-
return Br(e.filter(Boolean).join(" ").trim().split(/\s+/)).join(" ");
|
|
629
|
-
}, yt = (n, e, t) => {
|
|
630
|
-
let o;
|
|
631
|
-
return t && (o = n[t]), o || (o = n.default), Et(o, e);
|
|
632
|
-
};
|
|
633
|
-
class Z {
|
|
634
|
-
constructor(e) {
|
|
635
|
-
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "@@auth0spajs@@", o = arguments.length > 2 ? arguments[2] : void 0;
|
|
636
|
-
this.prefix = t, this.suffix = o, this.clientId = e.clientId, this.scope = e.scope, this.audience = e.audience;
|
|
637
|
-
}
|
|
638
|
-
toKey() {
|
|
639
|
-
return [this.prefix, this.clientId, this.audience, this.scope, this.suffix].filter(Boolean).join("::");
|
|
640
|
-
}
|
|
641
|
-
static fromKey(e) {
|
|
642
|
-
const [t, o, r, i] = e.split("::");
|
|
643
|
-
return new Z({ clientId: o, scope: i, audience: r }, t);
|
|
644
|
-
}
|
|
645
|
-
static fromCacheEntry(e) {
|
|
646
|
-
const { scope: t, audience: o, client_id: r } = e;
|
|
647
|
-
return new Z({ scope: t, audience: o, clientId: r });
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
class Xr {
|
|
651
|
-
set(e, t) {
|
|
652
|
-
localStorage.setItem(e, JSON.stringify(t));
|
|
653
|
-
}
|
|
654
|
-
get(e) {
|
|
655
|
-
const t = window.localStorage.getItem(e);
|
|
656
|
-
if (t) try {
|
|
657
|
-
return JSON.parse(t);
|
|
658
|
-
} catch {
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
remove(e) {
|
|
663
|
-
localStorage.removeItem(e);
|
|
664
|
-
}
|
|
665
|
-
allKeys() {
|
|
666
|
-
return Object.keys(window.localStorage).filter(((e) => e.startsWith("@@auth0spajs@@")));
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
class Wo {
|
|
670
|
-
constructor() {
|
|
671
|
-
this.enclosedCache = /* @__PURE__ */ (function() {
|
|
672
|
-
let e = {};
|
|
673
|
-
return { set(t, o) {
|
|
674
|
-
e[t] = o;
|
|
675
|
-
}, get(t) {
|
|
676
|
-
const o = e[t];
|
|
677
|
-
if (o) return o;
|
|
678
|
-
}, remove(t) {
|
|
679
|
-
delete e[t];
|
|
680
|
-
}, allKeys: () => Object.keys(e) };
|
|
681
|
-
})();
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
class Yr {
|
|
685
|
-
constructor(e, t, o) {
|
|
686
|
-
this.cache = e, this.keyManifest = t, this.nowProvider = o || Co;
|
|
687
|
-
}
|
|
688
|
-
async setIdToken(e, t, o) {
|
|
689
|
-
var r;
|
|
690
|
-
const i = this.getIdTokenCacheKey(e);
|
|
691
|
-
await this.cache.set(i, { id_token: t, decodedToken: o }), await ((r = this.keyManifest) === null || r === void 0 ? void 0 : r.add(i));
|
|
692
|
-
}
|
|
693
|
-
async getIdToken(e) {
|
|
694
|
-
const t = await this.cache.get(this.getIdTokenCacheKey(e.clientId));
|
|
695
|
-
if (!t && e.scope && e.audience) {
|
|
696
|
-
const o = await this.get(e);
|
|
697
|
-
return !o || !o.id_token || !o.decodedToken ? void 0 : { id_token: o.id_token, decodedToken: o.decodedToken };
|
|
698
|
-
}
|
|
699
|
-
if (t) return { id_token: t.id_token, decodedToken: t.decodedToken };
|
|
700
|
-
}
|
|
701
|
-
async get(e) {
|
|
702
|
-
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, o = arguments.length > 2 && arguments[2] !== void 0 && arguments[2], r = arguments.length > 3 ? arguments[3] : void 0;
|
|
703
|
-
var i;
|
|
704
|
-
let a = await this.cache.get(e.toKey());
|
|
705
|
-
if (!a) {
|
|
706
|
-
const u = await this.getCacheKeys();
|
|
707
|
-
if (!u) return;
|
|
708
|
-
const l = this.matchExistingCacheKey(e, u);
|
|
709
|
-
if (l && (a = await this.cache.get(l)), !a && o && r !== "cache-only") return this.getEntryWithRefreshToken(e, u);
|
|
710
|
-
}
|
|
711
|
-
if (!a) return;
|
|
712
|
-
const s = await this.nowProvider(), c = Math.floor(s / 1e3);
|
|
713
|
-
return a.expiresAt - t < c ? a.body.refresh_token ? this.modifiedCachedEntry(a, e) : (await this.cache.remove(e.toKey()), void await ((i = this.keyManifest) === null || i === void 0 ? void 0 : i.remove(e.toKey()))) : a.body;
|
|
714
|
-
}
|
|
715
|
-
async modifiedCachedEntry(e, t) {
|
|
716
|
-
return e.body = { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope }, await this.cache.set(t.toKey(), e), { refresh_token: e.body.refresh_token, audience: e.body.audience, scope: e.body.scope };
|
|
717
|
-
}
|
|
718
|
-
async set(e) {
|
|
719
|
-
var t;
|
|
720
|
-
const o = new Z({ clientId: e.client_id, scope: e.scope, audience: e.audience }), r = await this.wrapCacheEntry(e);
|
|
721
|
-
await this.cache.set(o.toKey(), r), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.add(o.toKey()));
|
|
722
|
-
}
|
|
723
|
-
async remove(e, t, o) {
|
|
724
|
-
const r = new Z({ clientId: e, scope: o, audience: t });
|
|
725
|
-
await this.cache.remove(r.toKey());
|
|
726
|
-
}
|
|
727
|
-
async clear(e) {
|
|
728
|
-
var t;
|
|
729
|
-
const o = await this.getCacheKeys();
|
|
730
|
-
o && (await o.filter(((r) => !e || r.includes(e))).reduce((async (r, i) => {
|
|
731
|
-
await r, await this.cache.remove(i);
|
|
732
|
-
}), Promise.resolve()), await ((t = this.keyManifest) === null || t === void 0 ? void 0 : t.clear()));
|
|
733
|
-
}
|
|
734
|
-
async wrapCacheEntry(e) {
|
|
735
|
-
const t = await this.nowProvider();
|
|
736
|
-
return { body: e, expiresAt: Math.floor(t / 1e3) + e.expires_in };
|
|
737
|
-
}
|
|
738
|
-
async getCacheKeys() {
|
|
739
|
-
var e;
|
|
740
|
-
return this.keyManifest ? (e = await this.keyManifest.get()) === null || e === void 0 ? void 0 : e.keys : this.cache.allKeys ? this.cache.allKeys() : void 0;
|
|
741
|
-
}
|
|
742
|
-
getIdTokenCacheKey(e) {
|
|
743
|
-
return new Z({ clientId: e }, "@@auth0spajs@@", "@@user@@").toKey();
|
|
744
|
-
}
|
|
745
|
-
matchExistingCacheKey(e, t) {
|
|
746
|
-
return t.filter(((o) => {
|
|
747
|
-
var r;
|
|
748
|
-
const i = Z.fromKey(o), a = new Set(i.scope && i.scope.split(" ")), s = ((r = e.scope) === null || r === void 0 ? void 0 : r.split(" ")) || [], c = i.scope && s.reduce(((u, l) => u && a.has(l)), !0);
|
|
749
|
-
return i.prefix === "@@auth0spajs@@" && i.clientId === e.clientId && i.audience === e.audience && c;
|
|
750
|
-
}))[0];
|
|
751
|
-
}
|
|
752
|
-
async getEntryWithRefreshToken(e, t) {
|
|
753
|
-
var o;
|
|
754
|
-
for (const r of t) {
|
|
755
|
-
const i = Z.fromKey(r);
|
|
756
|
-
if (i.prefix === "@@auth0spajs@@" && i.clientId === e.clientId) {
|
|
757
|
-
const a = await this.cache.get(r);
|
|
758
|
-
if (!((o = a == null ? void 0 : a.body) === null || o === void 0) && o.refresh_token) return this.modifiedCachedEntry(a, e);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
async updateEntry(e, t) {
|
|
763
|
-
var o;
|
|
764
|
-
const r = await this.getCacheKeys();
|
|
765
|
-
if (r) for (const i of r) {
|
|
766
|
-
const a = await this.cache.get(i);
|
|
767
|
-
((o = a == null ? void 0 : a.body) === null || o === void 0 ? void 0 : o.refresh_token) === e && (a.body.refresh_token = t, await this.cache.set(i, a));
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
class Qr {
|
|
772
|
-
constructor(e, t, o) {
|
|
773
|
-
this.storage = e, this.clientId = t, this.cookieDomain = o, this.storageKey = "".concat("a0.spajs.txs", ".").concat(this.clientId);
|
|
774
|
-
}
|
|
775
|
-
create(e) {
|
|
776
|
-
this.storage.save(this.storageKey, e, { daysUntilExpire: 1, cookieDomain: this.cookieDomain });
|
|
777
|
-
}
|
|
778
|
-
get() {
|
|
779
|
-
return this.storage.get(this.storageKey);
|
|
780
|
-
}
|
|
781
|
-
remove() {
|
|
782
|
-
this.storage.remove(this.storageKey, { cookieDomain: this.cookieDomain });
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
const Be = (n) => typeof n == "number", $r = ["iss", "aud", "exp", "nbf", "iat", "jti", "azp", "nonce", "auth_time", "at_hash", "c_hash", "acr", "amr", "sub_jwk", "cnf", "sip_from_tag", "sip_date", "sip_callid", "sip_cseq_num", "sip_via_branch", "orig", "dest", "mky", "events", "toe", "txn", "rph", "sid", "vot", "vtm"], ei = (n) => {
|
|
786
|
-
if (!n.id_token) throw new Error("ID token is required but missing");
|
|
787
|
-
const e = ((i) => {
|
|
788
|
-
const a = i.split("."), [s, c, u] = a;
|
|
789
|
-
if (a.length !== 3 || !s || !c || !u) throw new Error("ID token could not be decoded");
|
|
790
|
-
const l = JSON.parse(eo(c)), f = { __raw: i }, h = {};
|
|
791
|
-
return Object.keys(l).forEach(((d) => {
|
|
792
|
-
f[d] = l[d], $r.includes(d) || (h[d] = l[d]);
|
|
793
|
-
})), { encoded: { header: s, payload: c, signature: u }, header: JSON.parse(eo(s)), claims: f, user: h };
|
|
794
|
-
})(n.id_token);
|
|
795
|
-
if (!e.claims.iss) throw new Error("Issuer (iss) claim must be a string present in the ID token");
|
|
796
|
-
if (e.claims.iss !== n.iss) throw new Error('Issuer (iss) claim mismatch in the ID token; expected "'.concat(n.iss, '", found "').concat(e.claims.iss, '"'));
|
|
797
|
-
if (!e.user.sub) throw new Error("Subject (sub) claim must be a string present in the ID token");
|
|
798
|
-
if (e.header.alg !== "RS256") throw new Error('Signature algorithm of "'.concat(e.header.alg, '" is not supported. Expected the ID token to be signed with "RS256".'));
|
|
799
|
-
if (!e.claims.aud || typeof e.claims.aud != "string" && !Array.isArray(e.claims.aud)) throw new Error("Audience (aud) claim must be a string or array of strings present in the ID token");
|
|
800
|
-
if (Array.isArray(e.claims.aud)) {
|
|
801
|
-
if (!e.claims.aud.includes(n.aud)) throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(n.aud, '" but was not one of "').concat(e.claims.aud.join(", "), '"'));
|
|
802
|
-
if (e.claims.aud.length > 1) {
|
|
803
|
-
if (!e.claims.azp) throw new Error("Authorized Party (azp) claim must be a string present in the ID token when Audience (aud) claim has multiple values");
|
|
804
|
-
if (e.claims.azp !== n.aud) throw new Error('Authorized Party (azp) claim mismatch in the ID token; expected "'.concat(n.aud, '", found "').concat(e.claims.azp, '"'));
|
|
805
|
-
}
|
|
806
|
-
} else if (e.claims.aud !== n.aud) throw new Error('Audience (aud) claim mismatch in the ID token; expected "'.concat(n.aud, '" but found "').concat(e.claims.aud, '"'));
|
|
807
|
-
if (n.nonce) {
|
|
808
|
-
if (!e.claims.nonce) throw new Error("Nonce (nonce) claim must be a string present in the ID token");
|
|
809
|
-
if (e.claims.nonce !== n.nonce) throw new Error('Nonce (nonce) claim mismatch in the ID token; expected "'.concat(n.nonce, '", found "').concat(e.claims.nonce, '"'));
|
|
810
|
-
}
|
|
811
|
-
if (n.max_age && !Be(e.claims.auth_time)) throw new Error("Authentication Time (auth_time) claim must be a number present in the ID token when Max Age (max_age) is specified");
|
|
812
|
-
if (e.claims.exp == null || !Be(e.claims.exp)) throw new Error("Expiration Time (exp) claim must be a number present in the ID token");
|
|
813
|
-
if (!Be(e.claims.iat)) throw new Error("Issued At (iat) claim must be a number present in the ID token");
|
|
814
|
-
const t = n.leeway || 60, o = new Date(n.now || Date.now()), r = /* @__PURE__ */ new Date(0);
|
|
815
|
-
if (r.setUTCSeconds(e.claims.exp + t), o > r) throw new Error("Expiration Time (exp) claim error in the ID token; current time (".concat(o, ") is after expiration time (").concat(r, ")"));
|
|
816
|
-
if (e.claims.nbf != null && Be(e.claims.nbf)) {
|
|
817
|
-
const i = /* @__PURE__ */ new Date(0);
|
|
818
|
-
if (i.setUTCSeconds(e.claims.nbf - t), o < i) throw new Error("Not Before time (nbf) claim in the ID token indicates that this token can't be used just yet. Current time (".concat(o, ") is before ").concat(i));
|
|
819
|
-
}
|
|
820
|
-
if (e.claims.auth_time != null && Be(e.claims.auth_time)) {
|
|
821
|
-
const i = /* @__PURE__ */ new Date(0);
|
|
822
|
-
if (i.setUTCSeconds(parseInt(e.claims.auth_time) + n.max_age + t), o > i) throw new Error("Authentication Time (auth_time) claim in the ID token indicates that too much time has passed since the last end-user authentication. Current time (".concat(o, ") is after last auth at ").concat(i));
|
|
823
|
-
}
|
|
824
|
-
if (n.organization) {
|
|
825
|
-
const i = n.organization.trim();
|
|
826
|
-
if (i.startsWith("org_")) {
|
|
827
|
-
const a = i;
|
|
828
|
-
if (!e.claims.org_id) throw new Error("Organization ID (org_id) claim must be a string present in the ID token");
|
|
829
|
-
if (a !== e.claims.org_id) throw new Error('Organization ID (org_id) claim mismatch in the ID token; expected "'.concat(a, '", found "').concat(e.claims.org_id, '"'));
|
|
830
|
-
} else {
|
|
831
|
-
const a = i.toLowerCase();
|
|
832
|
-
if (!e.claims.org_name) throw new Error("Organization Name (org_name) claim must be a string present in the ID token");
|
|
833
|
-
if (a !== e.claims.org_name) throw new Error('Organization Name (org_name) claim mismatch in the ID token; expected "'.concat(a, '", found "').concat(e.claims.org_name, '"'));
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
return e;
|
|
837
|
-
};
|
|
838
|
-
var rt = Ce && Ce.__assign || function() {
|
|
839
|
-
return rt = Object.assign || function(n) {
|
|
840
|
-
for (var e, t = 1, o = arguments.length; t < o; t++) for (var r in e = arguments[t]) Object.prototype.hasOwnProperty.call(e, r) && (n[r] = e[r]);
|
|
841
|
-
return n;
|
|
842
|
-
}, rt.apply(this, arguments);
|
|
843
|
-
};
|
|
844
|
-
function Xe(n, e) {
|
|
845
|
-
if (!e) return "";
|
|
846
|
-
var t = "; " + n;
|
|
847
|
-
return e === !0 ? t : t + "=" + e;
|
|
848
|
-
}
|
|
849
|
-
function ti(n, e, t) {
|
|
850
|
-
return encodeURIComponent(n).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/\(/g, "%28").replace(/\)/g, "%29") + "=" + encodeURIComponent(e).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) + (function(o) {
|
|
851
|
-
if (typeof o.expires == "number") {
|
|
852
|
-
var r = /* @__PURE__ */ new Date();
|
|
853
|
-
r.setMilliseconds(r.getMilliseconds() + 864e5 * o.expires), o.expires = r;
|
|
854
|
-
}
|
|
855
|
-
return Xe("Expires", o.expires ? o.expires.toUTCString() : "") + Xe("Domain", o.domain) + Xe("Path", o.path) + Xe("Secure", o.secure) + Xe("SameSite", o.sameSite);
|
|
856
|
-
})(t);
|
|
857
|
-
}
|
|
858
|
-
function ni() {
|
|
859
|
-
return (function(n) {
|
|
860
|
-
for (var e = {}, t = n ? n.split("; ") : [], o = /(%[\dA-F]{2})+/gi, r = 0; r < t.length; r++) {
|
|
861
|
-
var i = t[r].split("="), a = i.slice(1).join("=");
|
|
862
|
-
a.charAt(0) === '"' && (a = a.slice(1, -1));
|
|
863
|
-
try {
|
|
864
|
-
e[i[0].replace(o, decodeURIComponent)] = a.replace(o, decodeURIComponent);
|
|
865
|
-
} catch {
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
return e;
|
|
869
|
-
})(document.cookie);
|
|
870
|
-
}
|
|
871
|
-
var oi = function(n) {
|
|
872
|
-
return ni()[n];
|
|
873
|
-
};
|
|
874
|
-
function zo(n, e, t) {
|
|
875
|
-
document.cookie = ti(n, e, rt({ path: "/" }, t));
|
|
876
|
-
}
|
|
877
|
-
var Ho = zo, Mo = function(n, e) {
|
|
878
|
-
zo(n, "", rt(rt({}, e), { expires: -1 }));
|
|
879
|
-
};
|
|
880
|
-
const Ne = { get(n) {
|
|
881
|
-
const e = oi(n);
|
|
882
|
-
if (e !== void 0) return JSON.parse(e);
|
|
883
|
-
}, save(n, e, t) {
|
|
884
|
-
let o = {};
|
|
885
|
-
window.location.protocol === "https:" && (o = { secure: !0, sameSite: "none" }), t != null && t.daysUntilExpire && (o.expires = t.daysUntilExpire), t != null && t.cookieDomain && (o.domain = t.cookieDomain), Ho(n, JSON.stringify(e), o);
|
|
886
|
-
}, remove(n, e) {
|
|
887
|
-
let t = {};
|
|
888
|
-
e != null && e.cookieDomain && (t.domain = e.cookieDomain), Mo(n, t);
|
|
889
|
-
} }, ri = { get(n) {
|
|
890
|
-
return Ne.get(n) || Ne.get("".concat("_legacy_").concat(n));
|
|
891
|
-
}, save(n, e, t) {
|
|
892
|
-
let o = {};
|
|
893
|
-
window.location.protocol === "https:" && (o = { secure: !0 }), t != null && t.daysUntilExpire && (o.expires = t.daysUntilExpire), t != null && t.cookieDomain && (o.domain = t.cookieDomain), Ho("".concat("_legacy_").concat(n), JSON.stringify(e), o), Ne.save(n, e, t);
|
|
894
|
-
}, remove(n, e) {
|
|
895
|
-
let t = {};
|
|
896
|
-
e != null && e.cookieDomain && (t.domain = e.cookieDomain), Mo(n, t), Ne.remove(n, e), Ne.remove("".concat("_legacy_").concat(n), e);
|
|
897
|
-
} }, ii = { get(n) {
|
|
898
|
-
if (typeof sessionStorage > "u") return;
|
|
899
|
-
const e = sessionStorage.getItem(n);
|
|
900
|
-
return e != null ? JSON.parse(e) : void 0;
|
|
901
|
-
}, save(n, e) {
|
|
902
|
-
sessionStorage.setItem(n, JSON.stringify(e));
|
|
903
|
-
}, remove(n) {
|
|
904
|
-
sessionStorage.removeItem(n);
|
|
905
|
-
} };
|
|
906
|
-
var Re;
|
|
907
|
-
(function(n) {
|
|
908
|
-
n.Code = "code", n.ConnectCode = "connect_code";
|
|
909
|
-
})(Re || (Re = {}));
|
|
910
|
-
function ai(n, e, t) {
|
|
911
|
-
var o = e === void 0 ? null : e, r = (function(c, u) {
|
|
912
|
-
var l = atob(c);
|
|
913
|
-
if (u) {
|
|
914
|
-
for (var f = new Uint8Array(l.length), h = 0, d = l.length; h < d; ++h) f[h] = l.charCodeAt(h);
|
|
915
|
-
return String.fromCharCode.apply(null, new Uint16Array(f.buffer));
|
|
916
|
-
}
|
|
917
|
-
return l;
|
|
918
|
-
})(n, t !== void 0 && t), i = r.indexOf(`
|
|
919
|
-
`, 10) + 1, a = r.substring(i) + (o ? "//# sourceMappingURL=" + o : ""), s = new Blob([a], { type: "application/javascript" });
|
|
920
|
-
return URL.createObjectURL(s);
|
|
921
|
-
}
|
|
922
|
-
var oo, ro, io, Zt, si = (oo = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHQpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnN9PXQ7cmV0dXJuIG5ldyBlKHIscyl9fWNsYXNzIHQgZXh0ZW5kcyBle2NvbnN0cnVjdG9yKGUscyl7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChyKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChyKHMpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1zLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLHQucHJvdG90eXBlKX19ZnVuY3Rpb24gcihlKXtsZXQgdD1hcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W107cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQodCk7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jIGU9PntsZXQgcixjLHtkYXRhOnt0aW1lb3V0OmksYXV0aDphLGZldGNoVXJsOmYsZmV0Y2hPcHRpb25zOmwsdXNlRm9ybURhdGE6cCx1c2VNcnJ0Omh9LHBvcnRzOlt1XX09ZSxkPXt9O2NvbnN0e2F1ZGllbmNlOmcsc2NvcGU6eX09YXx8e307dHJ5e2NvbnN0IGU9cD8oZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKChlLHQpPT57clt0XT1lfSkpLHJ9KShsLmJvZHkpOkpTT04ucGFyc2UobC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKGM9KChlLHQpPT5vW24oZSx0KV0pKGcseSksIWMmJmgpe2NvbnN0IGU9by5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+e2NvbnN0IHI9T2JqZWN0LmtleXMobykuZmluZCgocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBzPSgoZSx0KT0+dC5zdGFydHNXaXRoKCIiLmNvbmNhdChlLCJ8IikpKSh0LHIpLG89ci5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIiksbj1lLnNwbGl0KCIgIikuZXZlcnkoKGU9Pm8uaW5jbHVkZXMoZSkpKTtyZXR1cm4gcyYmbn19KSk7cmV0dXJuISFyfSkoeSxnKTtlJiYhdCYmKGM9ZSl9aWYoIWMpdGhyb3cgbmV3IHQoZyx5KTtsLmJvZHk9cD9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpjfSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpjfSkpfWxldCBhLGs7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixsLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2s9YXdhaXQgUHJvbWlzZS5yYWNlKFsoaj1pLG5ldyBQcm9taXNlKChlPT5zZXRUaW1lb3V0KGUsaikpKSksZmV0Y2goZixPYmplY3QuYXNzaWduKHt9LGwpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIHUucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFrKXJldHVybiBhJiZhLmFib3J0KCksdm9pZCB1LnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO189ay5oZWFkZXJzLGQ9Wy4uLl9dLnJlZHVjZSgoKGUsdCk9PntsZXRbcixzXT10O3JldHVybiBlW3JdPXMsZX0pLHt9KSxyPWF3YWl0IGsuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKG8ubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLE89YyxiPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhvKS5mb3JFYWNoKChlPT57bGV0W3Qscl09ZTtyPT09TyYmKG9bdF09Yil9KSkpLCgoZSx0LHIpPT57b1tuKHQscildPWV9KShyLnJlZnJlc2hfdG9rZW4sZyx5KSxkZWxldGUgci5yZWZyZXNoX3Rva2VuKTooKGUsdCk9PntkZWxldGUgb1tuKGUsdCldfSkoZyx5KSx1LnBvc3RNZXNzYWdlKHtvazprLm9rLGpzb246cixoZWFkZXJzOmR9KX1jYXRjaChlKXt1LnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjplLmVycm9yLGVycm9yX2Rlc2NyaXB0aW9uOmUubWVzc2FnZX0saGVhZGVyczpkfSl9dmFyIE8sYixfLGp9KSl9KCk7Cgo=", ro = null, io = !1, function(n) {
|
|
923
|
-
return Zt = Zt || ai(oo, ro, io), new Worker(Zt, n);
|
|
924
|
-
});
|
|
925
|
-
const qt = {};
|
|
926
|
-
class ci {
|
|
927
|
-
constructor(e, t) {
|
|
928
|
-
this.cache = e, this.clientId = t, this.manifestKey = this.createManifestKeyFrom(this.clientId);
|
|
929
|
-
}
|
|
930
|
-
async add(e) {
|
|
931
|
-
var t;
|
|
932
|
-
const o = new Set(((t = await this.cache.get(this.manifestKey)) === null || t === void 0 ? void 0 : t.keys) || []);
|
|
933
|
-
o.add(e), await this.cache.set(this.manifestKey, { keys: [...o] });
|
|
934
|
-
}
|
|
935
|
-
async remove(e) {
|
|
936
|
-
const t = await this.cache.get(this.manifestKey);
|
|
937
|
-
if (t) {
|
|
938
|
-
const o = new Set(t.keys);
|
|
939
|
-
return o.delete(e), o.size > 0 ? await this.cache.set(this.manifestKey, { keys: [...o] }) : await this.cache.remove(this.manifestKey);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
get() {
|
|
943
|
-
return this.cache.get(this.manifestKey);
|
|
944
|
-
}
|
|
945
|
-
clear() {
|
|
946
|
-
return this.cache.remove(this.manifestKey);
|
|
947
|
-
}
|
|
948
|
-
createManifestKeyFrom(e) {
|
|
949
|
-
return "".concat("@@auth0spajs@@", "::").concat(e);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
const ui = { memory: () => new Wo().enclosedCache, localstorage: () => new Xr() }, ao = (n) => ui[n], so = (n) => {
|
|
953
|
-
const { openUrl: e, onRedirect: t } = n, o = X(n, ["openUrl", "onRedirect"]);
|
|
954
|
-
return Object.assign(Object.assign({}, o), { openUrl: e === !1 || e ? e : t });
|
|
955
|
-
}, co = (n, e) => {
|
|
956
|
-
const t = (e == null ? void 0 : e.split(" ")) || [];
|
|
957
|
-
return ((n == null ? void 0 : n.split(" ")) || []).every(((o) => t.includes(o)));
|
|
958
|
-
}, _e = { NONCE: "nonce", KEYPAIR: "keypair" };
|
|
959
|
-
class li {
|
|
960
|
-
constructor(e) {
|
|
961
|
-
this.clientId = e;
|
|
962
|
-
}
|
|
963
|
-
getVersion() {
|
|
964
|
-
return 1;
|
|
965
|
-
}
|
|
966
|
-
createDbHandle() {
|
|
967
|
-
const e = window.indexedDB.open("auth0-spa-js", this.getVersion());
|
|
968
|
-
return new Promise(((t, o) => {
|
|
969
|
-
e.onupgradeneeded = () => Object.values(_e).forEach(((r) => e.result.createObjectStore(r))), e.onerror = () => o(e.error), e.onsuccess = () => t(e.result);
|
|
970
|
-
}));
|
|
971
|
-
}
|
|
972
|
-
async getDbHandle() {
|
|
973
|
-
return this.dbHandle || (this.dbHandle = await this.createDbHandle()), this.dbHandle;
|
|
974
|
-
}
|
|
975
|
-
async executeDbRequest(e, t, o) {
|
|
976
|
-
const r = o((await this.getDbHandle()).transaction(e, t).objectStore(e));
|
|
977
|
-
return new Promise(((i, a) => {
|
|
978
|
-
r.onsuccess = () => i(r.result), r.onerror = () => a(r.error);
|
|
979
|
-
}));
|
|
980
|
-
}
|
|
981
|
-
buildKey(e) {
|
|
982
|
-
const t = e ? "_".concat(e) : "auth0";
|
|
983
|
-
return "".concat(this.clientId, "::").concat(t);
|
|
984
|
-
}
|
|
985
|
-
setNonce(e, t) {
|
|
986
|
-
return this.save(_e.NONCE, this.buildKey(t), e);
|
|
987
|
-
}
|
|
988
|
-
setKeyPair(e) {
|
|
989
|
-
return this.save(_e.KEYPAIR, this.buildKey(), e);
|
|
990
|
-
}
|
|
991
|
-
async save(e, t, o) {
|
|
992
|
-
await this.executeDbRequest(e, "readwrite", ((r) => r.put(o, t)));
|
|
993
|
-
}
|
|
994
|
-
findNonce(e) {
|
|
995
|
-
return this.find(_e.NONCE, this.buildKey(e));
|
|
996
|
-
}
|
|
997
|
-
findKeyPair() {
|
|
998
|
-
return this.find(_e.KEYPAIR, this.buildKey());
|
|
999
|
-
}
|
|
1000
|
-
find(e, t) {
|
|
1001
|
-
return this.executeDbRequest(e, "readonly", ((o) => o.get(t)));
|
|
1002
|
-
}
|
|
1003
|
-
async deleteBy(e, t) {
|
|
1004
|
-
const o = await this.executeDbRequest(e, "readonly", ((r) => r.getAllKeys()));
|
|
1005
|
-
o == null || o.filter(t).map(((r) => this.executeDbRequest(e, "readwrite", ((i) => i.delete(r)))));
|
|
1006
|
-
}
|
|
1007
|
-
deleteByClientId(e, t) {
|
|
1008
|
-
return this.deleteBy(e, ((o) => typeof o == "string" && o.startsWith("".concat(t, "::"))));
|
|
1009
|
-
}
|
|
1010
|
-
clearNonces() {
|
|
1011
|
-
return this.deleteByClientId(_e.NONCE, this.clientId);
|
|
1012
|
-
}
|
|
1013
|
-
clearKeyPairs() {
|
|
1014
|
-
return this.deleteByClientId(_e.KEYPAIR, this.clientId);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
class hi {
|
|
1018
|
-
constructor(e) {
|
|
1019
|
-
this.storage = new li(e);
|
|
1020
|
-
}
|
|
1021
|
-
getNonce(e) {
|
|
1022
|
-
return this.storage.findNonce(e);
|
|
1023
|
-
}
|
|
1024
|
-
setNonce(e, t) {
|
|
1025
|
-
return this.storage.setNonce(e, t);
|
|
1026
|
-
}
|
|
1027
|
-
async getOrGenerateKeyPair() {
|
|
1028
|
-
let e = await this.storage.findKeyPair();
|
|
1029
|
-
return e || (e = await Hr(), await this.storage.setKeyPair(e)), e;
|
|
1030
|
-
}
|
|
1031
|
-
async generateProof(e) {
|
|
1032
|
-
const t = await this.getOrGenerateKeyPair();
|
|
1033
|
-
return Jr(Object.assign({ keyPair: t }, e));
|
|
1034
|
-
}
|
|
1035
|
-
async calculateThumbprint() {
|
|
1036
|
-
return Mr(await this.getOrGenerateKeyPair());
|
|
1037
|
-
}
|
|
1038
|
-
async clear() {
|
|
1039
|
-
await Promise.all([this.storage.clearNonces(), this.storage.clearKeyPairs()]);
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
var We;
|
|
1043
|
-
(function(n) {
|
|
1044
|
-
n.Bearer = "Bearer", n.DPoP = "DPoP";
|
|
1045
|
-
})(We || (We = {}));
|
|
1046
|
-
class di {
|
|
1047
|
-
constructor(e, t) {
|
|
1048
|
-
this.hooks = t, this.config = Object.assign(Object.assign({}, e), { fetch: e.fetch || (typeof window > "u" ? fetch : window.fetch.bind(window)) });
|
|
1049
|
-
}
|
|
1050
|
-
isAbsoluteUrl(e) {
|
|
1051
|
-
return /^(https?:)?\/\//i.test(e);
|
|
1052
|
-
}
|
|
1053
|
-
buildUrl(e, t) {
|
|
1054
|
-
if (t) {
|
|
1055
|
-
if (this.isAbsoluteUrl(t)) return t;
|
|
1056
|
-
if (e) return "".concat(e.replace(/\/?\/$/, ""), "/").concat(t.replace(/^\/+/, ""));
|
|
1057
|
-
}
|
|
1058
|
-
throw new TypeError("`url` must be absolute or `baseUrl` non-empty.");
|
|
1059
|
-
}
|
|
1060
|
-
getAccessToken(e) {
|
|
1061
|
-
return this.config.getAccessToken ? this.config.getAccessToken(e) : this.hooks.getAccessToken(e);
|
|
1062
|
-
}
|
|
1063
|
-
extractUrl(e) {
|
|
1064
|
-
return typeof e == "string" ? e : e instanceof URL ? e.href : e.url;
|
|
1065
|
-
}
|
|
1066
|
-
buildBaseRequest(e, t) {
|
|
1067
|
-
if (!this.config.baseUrl) return new Request(e, t);
|
|
1068
|
-
const o = this.buildUrl(this.config.baseUrl, this.extractUrl(e)), r = e instanceof Request ? new Request(o, e) : o;
|
|
1069
|
-
return new Request(r, t);
|
|
1070
|
-
}
|
|
1071
|
-
setAuthorizationHeader(e, t) {
|
|
1072
|
-
let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : We.Bearer;
|
|
1073
|
-
e.headers.set("authorization", "".concat(o, " ").concat(t));
|
|
1074
|
-
}
|
|
1075
|
-
async setDpopProofHeader(e, t) {
|
|
1076
|
-
if (!this.config.dpopNonceId) return;
|
|
1077
|
-
const o = await this.hooks.getDpopNonce(), r = await this.hooks.generateDpopProof({ accessToken: t, method: e.method, nonce: o, url: e.url });
|
|
1078
|
-
e.headers.set("dpop", r);
|
|
1079
|
-
}
|
|
1080
|
-
async prepareRequest(e, t) {
|
|
1081
|
-
const o = await this.getAccessToken(t);
|
|
1082
|
-
let r, i;
|
|
1083
|
-
typeof o == "string" ? (r = this.config.dpopNonceId ? We.DPoP : We.Bearer, i = o) : (r = o.token_type, i = o.access_token), this.setAuthorizationHeader(e, i, r), r === We.DPoP && await this.setDpopProofHeader(e, i);
|
|
1084
|
-
}
|
|
1085
|
-
getHeader(e, t) {
|
|
1086
|
-
return Array.isArray(e) ? new Headers(e).get(t) || "" : typeof e.get == "function" ? e.get(t) || "" : e[t] || "";
|
|
1087
|
-
}
|
|
1088
|
-
hasUseDpopNonceError(e) {
|
|
1089
|
-
if (e.status !== 401) return !1;
|
|
1090
|
-
const t = this.getHeader(e.headers, "www-authenticate");
|
|
1091
|
-
return t.includes("invalid_dpop_nonce") || t.includes("use_dpop_nonce");
|
|
1092
|
-
}
|
|
1093
|
-
async handleResponse(e, t) {
|
|
1094
|
-
const o = this.getHeader(e.headers, "dpop-nonce");
|
|
1095
|
-
if (o && await this.hooks.setDpopNonce(o), !this.hasUseDpopNonceError(e)) return e;
|
|
1096
|
-
if (!o || !t.onUseDpopNonceError) throw new Nt(o);
|
|
1097
|
-
return t.onUseDpopNonceError();
|
|
1098
|
-
}
|
|
1099
|
-
async internalFetchWithAuth(e, t, o, r) {
|
|
1100
|
-
const i = this.buildBaseRequest(e, t);
|
|
1101
|
-
await this.prepareRequest(i, r);
|
|
1102
|
-
const a = await this.config.fetch(i);
|
|
1103
|
-
return this.handleResponse(a, o);
|
|
1104
|
-
}
|
|
1105
|
-
fetchWithAuth(e, t, o) {
|
|
1106
|
-
const r = { onUseDpopNonceError: () => this.internalFetchWithAuth(e, t, Object.assign(Object.assign({}, r), { onUseDpopNonceError: void 0 }), o) };
|
|
1107
|
-
return this.internalFetchWithAuth(e, t, r, o);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
class pi {
|
|
1111
|
-
constructor(e, t) {
|
|
1112
|
-
this.myAccountFetcher = e, this.apiBase = t;
|
|
1113
|
-
}
|
|
1114
|
-
async connectAccount(e) {
|
|
1115
|
-
const t = await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase, "v1/connected-accounts/connect"), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
|
|
1116
|
-
return this._handleResponse(t);
|
|
1117
|
-
}
|
|
1118
|
-
async completeAccount(e) {
|
|
1119
|
-
const t = await this.myAccountFetcher.fetchWithAuth("".concat(this.apiBase, "v1/connected-accounts/complete"), { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) });
|
|
1120
|
-
return this._handleResponse(t);
|
|
1121
|
-
}
|
|
1122
|
-
async _handleResponse(e) {
|
|
1123
|
-
let t;
|
|
1124
|
-
try {
|
|
1125
|
-
t = await e.text(), t = JSON.parse(t);
|
|
1126
|
-
} catch (o) {
|
|
1127
|
-
throw new It({ type: "invalid_json", status: e.status, title: "Invalid JSON response", detail: t || String(o) });
|
|
1128
|
-
}
|
|
1129
|
-
if (e.ok) return t;
|
|
1130
|
-
throw new It(t);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
class It extends Error {
|
|
1134
|
-
constructor(e) {
|
|
1135
|
-
let { type: t, status: o, title: r, detail: i, validation_errors: a } = e;
|
|
1136
|
-
super(i), this.name = "MyAccountApiError", this.type = t, this.status = o, this.title = r, this.detail = i, this.validation_errors = a, Object.setPrototypeOf(this, It.prototype);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
const fi = { otp: { authenticatorTypes: ["otp"] }, sms: { authenticatorTypes: ["oob"], oobChannels: ["sms"] }, email: { authenticatorTypes: ["oob"], oobChannels: ["email"] }, push: { authenticatorTypes: ["oob"], oobChannels: ["auth0"] }, voice: { authenticatorTypes: ["oob"], oobChannels: ["voice"] } }, mi = "http://auth0.com/oauth/grant-type/mfa-otp", yi = "http://auth0.com/oauth/grant-type/mfa-oob", gi = "http://auth0.com/oauth/grant-type/mfa-recovery-code";
|
|
1140
|
-
function Jo(n, e) {
|
|
1141
|
-
this.v = n, this.k = e;
|
|
1142
|
-
}
|
|
1143
|
-
function j(n, e, t) {
|
|
1144
|
-
if (typeof n == "function" ? n === e : n.has(e)) return arguments.length < 3 ? e : t;
|
|
1145
|
-
throw new TypeError("Private element is not present on this object");
|
|
1146
|
-
}
|
|
1147
|
-
function wi(n) {
|
|
1148
|
-
return new Jo(n, 0);
|
|
1149
|
-
}
|
|
1150
|
-
function Vo(n, e) {
|
|
1151
|
-
if (e.has(n)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
1152
|
-
}
|
|
1153
|
-
function v(n, e) {
|
|
1154
|
-
return n.get(j(n, e));
|
|
1155
|
-
}
|
|
1156
|
-
function L(n, e, t) {
|
|
1157
|
-
Vo(n, e), e.set(n, t);
|
|
1158
|
-
}
|
|
1159
|
-
function x(n, e, t) {
|
|
1160
|
-
return n.set(j(n, e), t), t;
|
|
1161
|
-
}
|
|
1162
|
-
function _(n, e, t) {
|
|
1163
|
-
return (e = (function(o) {
|
|
1164
|
-
var r = (function(i, a) {
|
|
1165
|
-
if (typeof i != "object" || !i) return i;
|
|
1166
|
-
var s = i[Symbol.toPrimitive];
|
|
1167
|
-
if (s !== void 0) {
|
|
1168
|
-
var c = s.call(i, a);
|
|
1169
|
-
if (typeof c != "object") return c;
|
|
1170
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1171
|
-
}
|
|
1172
|
-
return (a === "string" ? String : Number)(i);
|
|
1173
|
-
})(o, "string");
|
|
1174
|
-
return typeof r == "symbol" ? r : r + "";
|
|
1175
|
-
})(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
|
|
1176
|
-
}
|
|
1177
|
-
function uo(n, e) {
|
|
1178
|
-
var t = Object.keys(n);
|
|
1179
|
-
if (Object.getOwnPropertySymbols) {
|
|
1180
|
-
var o = Object.getOwnPropertySymbols(n);
|
|
1181
|
-
e && (o = o.filter((function(r) {
|
|
1182
|
-
return Object.getOwnPropertyDescriptor(n, r).enumerable;
|
|
1183
|
-
}))), t.push.apply(t, o);
|
|
1184
|
-
}
|
|
1185
|
-
return t;
|
|
1186
|
-
}
|
|
1187
|
-
function S(n) {
|
|
1188
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
1189
|
-
var t = arguments[e] != null ? arguments[e] : {};
|
|
1190
|
-
e % 2 ? uo(Object(t), !0).forEach((function(o) {
|
|
1191
|
-
_(n, o, t[o]);
|
|
1192
|
-
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(t)) : uo(Object(t)).forEach((function(o) {
|
|
1193
|
-
Object.defineProperty(n, o, Object.getOwnPropertyDescriptor(t, o));
|
|
1194
|
-
}));
|
|
1195
|
-
}
|
|
1196
|
-
return n;
|
|
1197
|
-
}
|
|
1198
|
-
function lo(n, e) {
|
|
1199
|
-
if (n == null) return {};
|
|
1200
|
-
var t, o, r = (function(a, s) {
|
|
1201
|
-
if (a == null) return {};
|
|
1202
|
-
var c = {};
|
|
1203
|
-
for (var u in a) if ({}.hasOwnProperty.call(a, u)) {
|
|
1204
|
-
if (s.indexOf(u) !== -1) continue;
|
|
1205
|
-
c[u] = a[u];
|
|
1206
|
-
}
|
|
1207
|
-
return c;
|
|
1208
|
-
})(n, e);
|
|
1209
|
-
if (Object.getOwnPropertySymbols) {
|
|
1210
|
-
var i = Object.getOwnPropertySymbols(n);
|
|
1211
|
-
for (o = 0; o < i.length; o++) t = i[o], e.indexOf(t) === -1 && {}.propertyIsEnumerable.call(n, t) && (r[t] = n[t]);
|
|
1212
|
-
}
|
|
1213
|
-
return r;
|
|
1214
|
-
}
|
|
1215
|
-
function vi(n) {
|
|
1216
|
-
return function() {
|
|
1217
|
-
return new Qe(n.apply(this, arguments));
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
function Qe(n) {
|
|
1221
|
-
var e, t;
|
|
1222
|
-
function o(i, a) {
|
|
1223
|
-
try {
|
|
1224
|
-
var s = n[i](a), c = s.value, u = c instanceof Jo;
|
|
1225
|
-
Promise.resolve(u ? c.v : c).then((function(l) {
|
|
1226
|
-
if (u) {
|
|
1227
|
-
var f = i === "return" ? "return" : "next";
|
|
1228
|
-
if (!c.k || l.done) return o(f, l);
|
|
1229
|
-
l = n[f](l).value;
|
|
1230
|
-
}
|
|
1231
|
-
r(s.done ? "return" : "normal", l);
|
|
1232
|
-
}), (function(l) {
|
|
1233
|
-
o("throw", l);
|
|
1234
|
-
}));
|
|
1235
|
-
} catch (l) {
|
|
1236
|
-
r("throw", l);
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
function r(i, a) {
|
|
1240
|
-
switch (i) {
|
|
1241
|
-
case "return":
|
|
1242
|
-
e.resolve({ value: a, done: !0 });
|
|
1243
|
-
break;
|
|
1244
|
-
case "throw":
|
|
1245
|
-
e.reject(a);
|
|
1246
|
-
break;
|
|
1247
|
-
default:
|
|
1248
|
-
e.resolve({ value: a, done: !1 });
|
|
1249
|
-
}
|
|
1250
|
-
(e = e.next) ? o(e.key, e.arg) : t = null;
|
|
1251
|
-
}
|
|
1252
|
-
this._invoke = function(i, a) {
|
|
1253
|
-
return new Promise((function(s, c) {
|
|
1254
|
-
var u = { key: i, arg: a, resolve: s, reject: c, next: null };
|
|
1255
|
-
t ? t = t.next = u : (e = t = u, o(i, a));
|
|
1256
|
-
}));
|
|
1257
|
-
}, typeof n.return != "function" && (this.return = void 0);
|
|
1258
|
-
}
|
|
1259
|
-
var gt, Bt;
|
|
1260
|
-
let gn;
|
|
1261
|
-
Qe.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
1262
|
-
return this;
|
|
1263
|
-
}, Qe.prototype.next = function(n) {
|
|
1264
|
-
return this._invoke("next", n);
|
|
1265
|
-
}, Qe.prototype.throw = function(n) {
|
|
1266
|
-
return this._invoke("throw", n);
|
|
1267
|
-
}, Qe.prototype.return = function(n) {
|
|
1268
|
-
return this._invoke("return", n);
|
|
1269
|
-
}, (typeof navigator > "u" || (gt = navigator.userAgent) === null || gt === void 0 || (Bt = gt.startsWith) === null || Bt === void 0 || !Bt.call(gt, "Mozilla/5.0 ")) && (gn = "".concat("oauth4webapi", "/").concat("v3.8.3"));
|
|
1270
|
-
function Ge(n, e) {
|
|
1271
|
-
if (n == null) return !1;
|
|
1272
|
-
try {
|
|
1273
|
-
return n instanceof e || Object.getPrototypeOf(n)[Symbol.toStringTag] === e.prototype[Symbol.toStringTag];
|
|
1274
|
-
} catch {
|
|
1275
|
-
return !1;
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
function R(n, e, t) {
|
|
1279
|
-
const o = new TypeError(n, { cause: t });
|
|
1280
|
-
return Object.assign(o, { code: e }), o;
|
|
1281
|
-
}
|
|
1282
|
-
const q = Symbol(), wn = Symbol(), vn = Symbol(), te = Symbol(), ce = Symbol(), bi = new TextEncoder(), _i = new TextDecoder();
|
|
1283
|
-
function Me(n) {
|
|
1284
|
-
return typeof n == "string" ? bi.encode(n) : _i.decode(n);
|
|
1285
|
-
}
|
|
1286
|
-
let bn, Fo;
|
|
1287
|
-
Uint8Array.prototype.toBase64 ? bn = (n) => (n instanceof ArrayBuffer && (n = new Uint8Array(n)), n.toBase64({ alphabet: "base64url", omitPadding: !0 })) : bn = (e) => {
|
|
1288
|
-
e instanceof ArrayBuffer && (e = new Uint8Array(e));
|
|
1289
|
-
const t = [];
|
|
1290
|
-
for (let o = 0; o < e.byteLength; o += 32768) t.push(String.fromCharCode.apply(null, e.subarray(o, o + 32768)));
|
|
1291
|
-
return btoa(t.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1292
|
-
};
|
|
1293
|
-
function xe(n) {
|
|
1294
|
-
return typeof n == "string" ? Fo(n) : bn(n);
|
|
1295
|
-
}
|
|
1296
|
-
Fo = Uint8Array.fromBase64 ? (n) => {
|
|
1297
|
-
try {
|
|
1298
|
-
return Uint8Array.fromBase64(n, { alphabet: "base64url" });
|
|
1299
|
-
} catch (e) {
|
|
1300
|
-
throw R("The input to be decoded is not correctly encoded.", "ERR_INVALID_ARG_VALUE", e);
|
|
1301
|
-
}
|
|
1302
|
-
} : (n) => {
|
|
1303
|
-
try {
|
|
1304
|
-
const e = atob(n.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), t = new Uint8Array(e.length);
|
|
1305
|
-
for (let o = 0; o < e.length; o++) t[o] = e.charCodeAt(o);
|
|
1306
|
-
return t;
|
|
1307
|
-
} catch (e) {
|
|
1308
|
-
throw R("The input to be decoded is not correctly encoded.", "ERR_INVALID_ARG_VALUE", e);
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
class F extends Error {
|
|
1312
|
-
constructor(e, t) {
|
|
1313
|
-
var o;
|
|
1314
|
-
super(e, t), _(this, "code", void 0), this.name = this.constructor.name, this.code = Sn, (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
class Wn extends Error {
|
|
1318
|
-
constructor(e, t) {
|
|
1319
|
-
var o;
|
|
1320
|
-
super(e, t), _(this, "code", void 0), this.name = this.constructor.name, t != null && t.code && (this.code = t == null ? void 0 : t.code), (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
function A(n, e, t) {
|
|
1324
|
-
return new Wn(n, { code: e, cause: t });
|
|
1325
|
-
}
|
|
1326
|
-
function ki(n, e) {
|
|
1327
|
-
if ((function(t, o) {
|
|
1328
|
-
if (!(t instanceof CryptoKey)) throw R("".concat(o, " must be a CryptoKey"), "ERR_INVALID_ARG_TYPE");
|
|
1329
|
-
})(n, e), n.type !== "private") throw R("".concat(e, " must be a private CryptoKey"), "ERR_INVALID_ARG_VALUE");
|
|
1330
|
-
}
|
|
1331
|
-
function Ot(n) {
|
|
1332
|
-
return n !== null && typeof n == "object" && !Array.isArray(n);
|
|
1333
|
-
}
|
|
1334
|
-
function Wt(n) {
|
|
1335
|
-
Ge(n, Headers) && (n = Object.fromEntries(n.entries()));
|
|
1336
|
-
const e = new Headers(n ?? {});
|
|
1337
|
-
if (gn && !e.has("user-agent") && e.set("user-agent", gn), e.has("authorization")) throw R('"options.headers" must not include the "authorization" header name', "ERR_INVALID_ARG_VALUE");
|
|
1338
|
-
return e;
|
|
1339
|
-
}
|
|
1340
|
-
function Go(n, e) {
|
|
1341
|
-
if (e !== void 0) {
|
|
1342
|
-
if (typeof e == "function" && (e = e(n.href)), !(e instanceof AbortSignal)) throw R('"options.signal" must return or be an instance of AbortSignal', "ERR_INVALID_ARG_TYPE");
|
|
1343
|
-
return e;
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
function ho(n) {
|
|
1347
|
-
return n.includes("//") ? n.replace("//", "/") : n;
|
|
1348
|
-
}
|
|
1349
|
-
async function Si(n, e) {
|
|
1350
|
-
return (async function(t, o, r, i) {
|
|
1351
|
-
if (!(t instanceof URL)) throw R('"'.concat(o, '" must be an instance of URL'), "ERR_INVALID_ARG_TYPE");
|
|
1352
|
-
zn(t, (i == null ? void 0 : i[q]) !== !0);
|
|
1353
|
-
const a = r(new URL(t.href)), s = Wt(i == null ? void 0 : i.headers);
|
|
1354
|
-
return s.set("accept", "application/json"), ((i == null ? void 0 : i[te]) || fetch)(a.href, { body: void 0, headers: Object.fromEntries(s.entries()), method: "GET", redirect: "manual", signal: Go(a, i == null ? void 0 : i.signal) });
|
|
1355
|
-
})(n, "issuerIdentifier", ((t) => {
|
|
1356
|
-
switch (e == null ? void 0 : e.algorithm) {
|
|
1357
|
-
case void 0:
|
|
1358
|
-
case "oidc":
|
|
1359
|
-
(function(o, r) {
|
|
1360
|
-
o.pathname = ho("".concat(o.pathname, "/").concat(r));
|
|
1361
|
-
})(t, ".well-known/openid-configuration");
|
|
1362
|
-
break;
|
|
1363
|
-
case "oauth2":
|
|
1364
|
-
(function(o, r) {
|
|
1365
|
-
let i = arguments.length > 2 && arguments[2] !== void 0 && arguments[2];
|
|
1366
|
-
o.pathname === "/" ? o.pathname = r : o.pathname = ho("".concat(r, "/").concat(i ? o.pathname : o.pathname.replace(/(\/)$/, "")));
|
|
1367
|
-
})(t, ".well-known/oauth-authorization-server");
|
|
1368
|
-
break;
|
|
1369
|
-
default:
|
|
1370
|
-
throw R('"options.algorithm" must be "oidc" (default), or "oauth2"', "ERR_INVALID_ARG_VALUE");
|
|
1371
|
-
}
|
|
1372
|
-
return t;
|
|
1373
|
-
}), e);
|
|
1374
|
-
}
|
|
1375
|
-
function ge(n, e, t, o, r) {
|
|
1376
|
-
try {
|
|
1377
|
-
if (typeof n != "number" || !Number.isFinite(n)) throw R("".concat(t, " must be a number"), "ERR_INVALID_ARG_TYPE", r);
|
|
1378
|
-
if (n > 0) return;
|
|
1379
|
-
if (e) {
|
|
1380
|
-
if (n !== 0) throw R("".concat(t, " must be a non-negative number"), "ERR_INVALID_ARG_VALUE", r);
|
|
1381
|
-
return;
|
|
1382
|
-
}
|
|
1383
|
-
throw R("".concat(t, " must be a positive number"), "ERR_INVALID_ARG_VALUE", r);
|
|
1384
|
-
} catch (i) {
|
|
1385
|
-
throw o ? A(i.message, o, r) : i;
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
function D(n, e, t, o) {
|
|
1389
|
-
try {
|
|
1390
|
-
if (typeof n != "string") throw R("".concat(e, " must be a string"), "ERR_INVALID_ARG_TYPE", o);
|
|
1391
|
-
if (n.length === 0) throw R("".concat(e, " must not be empty"), "ERR_INVALID_ARG_VALUE", o);
|
|
1392
|
-
} catch (r) {
|
|
1393
|
-
throw t ? A(r.message, t, o) : r;
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
function Zo(n) {
|
|
1397
|
-
(function(e, t) {
|
|
1398
|
-
if (Yo(e) !== t) throw (function(o) {
|
|
1399
|
-
let r = '"response" content-type must be ';
|
|
1400
|
-
for (var i = arguments.length, a = new Array(i > 1 ? i - 1 : 0), s = 1; s < i; s++) a[s - 1] = arguments[s];
|
|
1401
|
-
if (a.length > 2) {
|
|
1402
|
-
const c = a.pop();
|
|
1403
|
-
r += "".concat(a.join(", "), ", or ").concat(c);
|
|
1404
|
-
} else a.length === 2 ? r += "".concat(a[0], " or ").concat(a[1]) : r += a[0];
|
|
1405
|
-
return A(r, $o, o);
|
|
1406
|
-
})(e, t);
|
|
1407
|
-
})(n, "application/json");
|
|
1408
|
-
}
|
|
1409
|
-
function qo() {
|
|
1410
|
-
return xe(crypto.getRandomValues(new Uint8Array(32)));
|
|
1411
|
-
}
|
|
1412
|
-
function Ei(n) {
|
|
1413
|
-
switch (n.algorithm.name) {
|
|
1414
|
-
case "RSA-PSS":
|
|
1415
|
-
return (function(e) {
|
|
1416
|
-
switch (e.algorithm.hash.name) {
|
|
1417
|
-
case "SHA-256":
|
|
1418
|
-
return "PS256";
|
|
1419
|
-
case "SHA-384":
|
|
1420
|
-
return "PS384";
|
|
1421
|
-
case "SHA-512":
|
|
1422
|
-
return "PS512";
|
|
1423
|
-
default:
|
|
1424
|
-
throw new F("unsupported RsaHashedKeyAlgorithm hash name", { cause: e });
|
|
1425
|
-
}
|
|
1426
|
-
})(n);
|
|
1427
|
-
case "RSASSA-PKCS1-v1_5":
|
|
1428
|
-
return (function(e) {
|
|
1429
|
-
switch (e.algorithm.hash.name) {
|
|
1430
|
-
case "SHA-256":
|
|
1431
|
-
return "RS256";
|
|
1432
|
-
case "SHA-384":
|
|
1433
|
-
return "RS384";
|
|
1434
|
-
case "SHA-512":
|
|
1435
|
-
return "RS512";
|
|
1436
|
-
default:
|
|
1437
|
-
throw new F("unsupported RsaHashedKeyAlgorithm hash name", { cause: e });
|
|
1438
|
-
}
|
|
1439
|
-
})(n);
|
|
1440
|
-
case "ECDSA":
|
|
1441
|
-
return (function(e) {
|
|
1442
|
-
switch (e.algorithm.namedCurve) {
|
|
1443
|
-
case "P-256":
|
|
1444
|
-
return "ES256";
|
|
1445
|
-
case "P-384":
|
|
1446
|
-
return "ES384";
|
|
1447
|
-
case "P-521":
|
|
1448
|
-
return "ES512";
|
|
1449
|
-
default:
|
|
1450
|
-
throw new F("unsupported EcKeyAlgorithm namedCurve", { cause: e });
|
|
1451
|
-
}
|
|
1452
|
-
})(n);
|
|
1453
|
-
case "Ed25519":
|
|
1454
|
-
case "ML-DSA-44":
|
|
1455
|
-
case "ML-DSA-65":
|
|
1456
|
-
case "ML-DSA-87":
|
|
1457
|
-
return n.algorithm.name;
|
|
1458
|
-
case "EdDSA":
|
|
1459
|
-
return "Ed25519";
|
|
1460
|
-
default:
|
|
1461
|
-
throw new F("unsupported CryptoKey algorithm name", { cause: n });
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
function xt(n) {
|
|
1465
|
-
const e = n == null ? void 0 : n[wn];
|
|
1466
|
-
return typeof e == "number" && Number.isFinite(e) ? e : 0;
|
|
1467
|
-
}
|
|
1468
|
-
function _n(n) {
|
|
1469
|
-
const e = n == null ? void 0 : n[vn];
|
|
1470
|
-
return typeof e == "number" && Number.isFinite(e) && Math.sign(e) !== -1 ? e : 30;
|
|
1471
|
-
}
|
|
1472
|
-
function Ct() {
|
|
1473
|
-
return Math.floor(Date.now() / 1e3);
|
|
1474
|
-
}
|
|
1475
|
-
function $(n) {
|
|
1476
|
-
if (typeof n != "object" || n === null) throw R('"as" must be an object', "ERR_INVALID_ARG_TYPE");
|
|
1477
|
-
D(n.issuer, '"as.issuer"');
|
|
1478
|
-
}
|
|
1479
|
-
function ee(n) {
|
|
1480
|
-
if (typeof n != "object" || n === null) throw R('"client" must be an object', "ERR_INVALID_ARG_TYPE");
|
|
1481
|
-
D(n.client_id, '"client.client_id"');
|
|
1482
|
-
}
|
|
1483
|
-
function po(n) {
|
|
1484
|
-
return D(n, '"clientSecret"'), (e, t, o, r) => {
|
|
1485
|
-
o.set("client_id", t.client_id), o.set("client_secret", n);
|
|
1486
|
-
};
|
|
1487
|
-
}
|
|
1488
|
-
function Ai(n, e) {
|
|
1489
|
-
const { key: t, kid: o } = (r = n) instanceof CryptoKey ? { key: r } : (r == null ? void 0 : r.key) instanceof CryptoKey ? (r.kid !== void 0 && D(r.kid, '"kid"'), { key: r.key, kid: r.kid }) : {};
|
|
1490
|
-
var r;
|
|
1491
|
-
return ki(t, '"clientPrivateKey.key"'), async (i, a, s, c) => {
|
|
1492
|
-
const u = { alg: Ei(t), kid: o }, l = (function(f, h) {
|
|
1493
|
-
const d = Ct() + xt(h);
|
|
1494
|
-
return { jti: qo(), aud: f.issuer, exp: d + 60, iat: d, nbf: d, iss: h.client_id, sub: h.client_id };
|
|
1495
|
-
})(i, a);
|
|
1496
|
-
s.set("client_id", a.client_id), s.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), s.set("client_assertion", await (async function(f, h, d) {
|
|
1497
|
-
if (!d.usages.includes("sign")) throw R('CryptoKey instances used for signing assertions must include "sign" in their "usages"', "ERR_INVALID_ARG_VALUE");
|
|
1498
|
-
const w = "".concat(xe(Me(JSON.stringify(f))), ".").concat(xe(Me(JSON.stringify(h)))), m = xe(await crypto.subtle.sign((function(p) {
|
|
1499
|
-
switch (p.algorithm.name) {
|
|
1500
|
-
case "ECDSA":
|
|
1501
|
-
return { name: p.algorithm.name, hash: Ji(p) };
|
|
1502
|
-
case "RSA-PSS":
|
|
1503
|
-
switch (yo(p), p.algorithm.hash.name) {
|
|
1504
|
-
case "SHA-256":
|
|
1505
|
-
case "SHA-384":
|
|
1506
|
-
case "SHA-512":
|
|
1507
|
-
return { name: p.algorithm.name, saltLength: parseInt(p.algorithm.hash.name.slice(-3), 10) >> 3 };
|
|
1508
|
-
default:
|
|
1509
|
-
throw new F("unsupported RSA-PSS hash name", { cause: p });
|
|
1510
|
-
}
|
|
1511
|
-
case "RSASSA-PKCS1-v1_5":
|
|
1512
|
-
return yo(p), p.algorithm.name;
|
|
1513
|
-
case "ML-DSA-44":
|
|
1514
|
-
case "ML-DSA-65":
|
|
1515
|
-
case "ML-DSA-87":
|
|
1516
|
-
case "Ed25519":
|
|
1517
|
-
return p.algorithm.name;
|
|
1518
|
-
}
|
|
1519
|
-
throw new F("unsupported CryptoKey algorithm name", { cause: p });
|
|
1520
|
-
})(d), d, Me(w)));
|
|
1521
|
-
return "".concat(w, ".").concat(m);
|
|
1522
|
-
})(u, l, t));
|
|
1523
|
-
};
|
|
1524
|
-
}
|
|
1525
|
-
const Ti = URL.parse ? (n, e) => URL.parse(n, e) : (n, e) => {
|
|
1526
|
-
try {
|
|
1527
|
-
return new URL(n, e);
|
|
1528
|
-
} catch {
|
|
1529
|
-
return null;
|
|
1530
|
-
}
|
|
1531
|
-
};
|
|
1532
|
-
function zn(n, e) {
|
|
1533
|
-
if (e && n.protocol !== "https:") throw A("only requests to HTTPS are allowed", er, n);
|
|
1534
|
-
if (n.protocol !== "https:" && n.protocol !== "http:") throw A("only HTTP and HTTPS requests are allowed", tr, n);
|
|
1535
|
-
}
|
|
1536
|
-
function fo(n, e, t, o) {
|
|
1537
|
-
let r;
|
|
1538
|
-
if (typeof n != "string" || !(r = Ti(n))) throw A("authorization server metadata does not contain a valid ".concat(t ? '"as.mtls_endpoint_aliases.'.concat(e, '"') : '"as.'.concat(e, '"')), n === void 0 ? Hi : Mi, { attribute: t ? "mtls_endpoint_aliases.".concat(e) : e });
|
|
1539
|
-
return zn(r, o), r;
|
|
1540
|
-
}
|
|
1541
|
-
function st(n, e, t, o) {
|
|
1542
|
-
return t && n.mtls_endpoint_aliases && e in n.mtls_endpoint_aliases ? fo(n.mtls_endpoint_aliases[e], e, t, o) : fo(n[e], e, t, o);
|
|
1543
|
-
}
|
|
1544
|
-
class zt extends Error {
|
|
1545
|
-
constructor(e, t) {
|
|
1546
|
-
var o;
|
|
1547
|
-
super(e, t), _(this, "cause", void 0), _(this, "code", void 0), _(this, "error", void 0), _(this, "status", void 0), _(this, "error_description", void 0), _(this, "response", void 0), this.name = this.constructor.name, this.code = Wi, this.cause = t.cause, this.error = t.cause.error, this.status = t.response.status, this.error_description = t.cause.error_description, Object.defineProperty(this, "response", { enumerable: !1, value: t.response }), (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
class Bo extends Error {
|
|
1551
|
-
constructor(e, t) {
|
|
1552
|
-
var o, r;
|
|
1553
|
-
super(e, t), _(this, "cause", void 0), _(this, "code", void 0), _(this, "error", void 0), _(this, "error_description", void 0), this.name = this.constructor.name, this.code = zi, this.cause = t.cause, this.error = t.cause.get("error"), this.error_description = (o = t.cause.get("error_description")) !== null && o !== void 0 ? o : void 0, (r = Error.captureStackTrace) === null || r === void 0 || r.call(Error, this, this.constructor);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
class Hn extends Error {
|
|
1557
|
-
constructor(e, t) {
|
|
1558
|
-
var o;
|
|
1559
|
-
super(e, t), _(this, "cause", void 0), _(this, "code", void 0), _(this, "response", void 0), _(this, "status", void 0), this.name = this.constructor.name, this.code = Ni, this.cause = t.cause, this.status = t.response.status, this.response = t.response, Object.defineProperty(this, "response", { enumerable: !1 }), (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
const Pi = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+", Ri = new RegExp("^[,\\s]*(" + Pi + ")"), Ii = new RegExp('^[,\\s]*([a-zA-Z0-9!#$%&\\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"[,\\s]*(.*)'), Oi = new RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)[,\\s]*(.*)"), xi = new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");
|
|
1563
|
-
async function Mn(n, e, t) {
|
|
1564
|
-
if (n.status !== e) {
|
|
1565
|
-
let r;
|
|
1566
|
-
var o;
|
|
1567
|
-
throw (function(i) {
|
|
1568
|
-
let a;
|
|
1569
|
-
if (a = (function(s) {
|
|
1570
|
-
if (!Ge(s, Response)) throw R('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
|
|
1571
|
-
const c = s.headers.get("www-authenticate");
|
|
1572
|
-
if (c === null) return;
|
|
1573
|
-
const u = [];
|
|
1574
|
-
let l = c;
|
|
1575
|
-
for (; l; ) {
|
|
1576
|
-
var f;
|
|
1577
|
-
let h = l.match(Ri);
|
|
1578
|
-
const d = (f = h) === null || f === void 0 ? void 0 : f[1].toLowerCase();
|
|
1579
|
-
if (!d) return;
|
|
1580
|
-
const w = l.substring(h[0].length);
|
|
1581
|
-
if (w && !w.match(/^[\s,]/)) return;
|
|
1582
|
-
const m = w.match(/^\s+(.*)$/), p = !!m;
|
|
1583
|
-
l = m ? m[1] : void 0;
|
|
1584
|
-
const g = {};
|
|
1585
|
-
let b;
|
|
1586
|
-
if (p) for (; l; ) {
|
|
1587
|
-
let E, y;
|
|
1588
|
-
if (h = l.match(Ii)) {
|
|
1589
|
-
if ([, E, y, l] = h, y.includes("\\")) try {
|
|
1590
|
-
y = JSON.parse('"'.concat(y, '"'));
|
|
1591
|
-
} catch {
|
|
1592
|
-
}
|
|
1593
|
-
g[E.toLowerCase()] = y;
|
|
1594
|
-
} else {
|
|
1595
|
-
if (!(h = l.match(Oi))) {
|
|
1596
|
-
if (h = l.match(xi)) {
|
|
1597
|
-
if (Object.keys(g).length) break;
|
|
1598
|
-
[, b, l] = h;
|
|
1599
|
-
break;
|
|
1600
|
-
}
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
[, E, y, l] = h, g[E.toLowerCase()] = y;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
else l = w || void 0;
|
|
1607
|
-
const k = { scheme: d, parameters: g };
|
|
1608
|
-
b && (k.token68 = b), u.push(k);
|
|
1609
|
-
}
|
|
1610
|
-
return u.length ? u : void 0;
|
|
1611
|
-
})(i)) throw new Hn("server responded with a challenge in the WWW-Authenticate HTTP Header", { cause: a, response: i });
|
|
1612
|
-
})(n), (r = await (async function(i) {
|
|
1613
|
-
if (i.status > 399 && i.status < 500) {
|
|
1614
|
-
ut(i), Zo(i);
|
|
1615
|
-
try {
|
|
1616
|
-
const a = await i.clone().json();
|
|
1617
|
-
if (Ot(a) && typeof a.error == "string" && a.error.length) return a;
|
|
1618
|
-
} catch {
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
})(n)) ? (await ((o = n.body) === null || o === void 0 ? void 0 : o.cancel()), new zt("server responded with an error in the response body", { cause: r, response: n })) : A('"response" is not a conform '.concat(t, " response (unexpected HTTP status code)"), Fn, n);
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
function Xo(n) {
|
|
1625
|
-
if (!Vn.has(n)) throw R('"options.DPoP" is not a valid DPoPHandle', "ERR_INVALID_ARG_VALUE");
|
|
1626
|
-
}
|
|
1627
|
-
function Yo(n) {
|
|
1628
|
-
var e;
|
|
1629
|
-
return (e = n.headers.get("content-type")) === null || e === void 0 ? void 0 : e.split(";")[0];
|
|
1630
|
-
}
|
|
1631
|
-
async function Jn(n, e, t, o, r, i, a) {
|
|
1632
|
-
return await t(n, e, r, i), i.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), ((a == null ? void 0 : a[te]) || fetch)(o.href, { body: r, headers: Object.fromEntries(i.entries()), method: "POST", redirect: "manual", signal: Go(o, a == null ? void 0 : a.signal) });
|
|
1633
|
-
}
|
|
1634
|
-
async function ct(n, e, t, o, r, i) {
|
|
1635
|
-
var a;
|
|
1636
|
-
const s = st(n, "token_endpoint", e.use_mtls_endpoint_aliases, (i == null ? void 0 : i[q]) !== !0);
|
|
1637
|
-
r.set("grant_type", o);
|
|
1638
|
-
const c = Wt(i == null ? void 0 : i.headers);
|
|
1639
|
-
c.set("accept", "application/json"), (i == null ? void 0 : i.DPoP) !== void 0 && (Xo(i.DPoP), await i.DPoP.addProof(s, c, "POST"));
|
|
1640
|
-
const u = await Jn(n, e, t, s, r, c, i);
|
|
1641
|
-
return i == null || (a = i.DPoP) === null || a === void 0 || a.cacheNonce(u, s), u;
|
|
1642
|
-
}
|
|
1643
|
-
const Qo = /* @__PURE__ */ new WeakMap(), Ci = /* @__PURE__ */ new WeakMap();
|
|
1644
|
-
function kn(n) {
|
|
1645
|
-
if (!n.id_token) return;
|
|
1646
|
-
const e = Qo.get(n);
|
|
1647
|
-
if (!e) throw R('"ref" was already garbage collected or did not resolve from the proper sources', "ERR_INVALID_ARG_VALUE");
|
|
1648
|
-
return e;
|
|
1649
|
-
}
|
|
1650
|
-
async function Ve(n, e, t, o, r, i) {
|
|
1651
|
-
if ($(n), ee(e), !Ge(t, Response)) throw R('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
|
|
1652
|
-
await Mn(t, 200, "Token Endpoint"), ut(t);
|
|
1653
|
-
const a = await Ht(t);
|
|
1654
|
-
if (D(a.access_token, '"response" body "access_token" property', T, { body: a }), D(a.token_type, '"response" body "token_type" property', T, { body: a }), a.token_type = a.token_type.toLowerCase(), a.expires_in !== void 0) {
|
|
1655
|
-
let s = typeof a.expires_in != "number" ? parseFloat(a.expires_in) : a.expires_in;
|
|
1656
|
-
ge(s, !0, '"response" body "expires_in" property', T, { body: a }), a.expires_in = s;
|
|
1657
|
-
}
|
|
1658
|
-
if (a.refresh_token !== void 0 && D(a.refresh_token, '"response" body "refresh_token" property', T, { body: a }), a.scope !== void 0 && typeof a.scope != "string") throw A('"response" body "scope" property must be a string', T, { body: a });
|
|
1659
|
-
if (a.id_token !== void 0) {
|
|
1660
|
-
D(a.id_token, '"response" body "id_token" property', T, { body: a });
|
|
1661
|
-
const s = ["aud", "exp", "iat", "iss", "sub"];
|
|
1662
|
-
e.require_auth_time === !0 && s.push("auth_time"), e.default_max_age !== void 0 && (ge(e.default_max_age, !0, '"client.default_max_age"'), s.push("auth_time")), o != null && o.length && s.push(...o);
|
|
1663
|
-
const { claims: c, jwt: u } = await (async function(l, f, h, d, w) {
|
|
1664
|
-
let m, p, { 0: g, 1: b, length: k } = l.split(".");
|
|
1665
|
-
if (k === 5) {
|
|
1666
|
-
if (w === void 0) throw new F("JWE decryption is not configured", { cause: l });
|
|
1667
|
-
l = await w(l), { 0: g, 1: b, length: k } = l.split(".");
|
|
1668
|
-
}
|
|
1669
|
-
if (k !== 3) throw A("Invalid JWT", T, l);
|
|
1670
|
-
try {
|
|
1671
|
-
m = JSON.parse(Me(xe(g)));
|
|
1672
|
-
} catch (y) {
|
|
1673
|
-
throw A("failed to parse JWT Header body as base64url encoded JSON", jt, y);
|
|
1674
|
-
}
|
|
1675
|
-
if (!Ot(m)) throw A("JWT Header must be a top level object", T, l);
|
|
1676
|
-
if (f(m), m.crit !== void 0) throw new F('no JWT "crit" header parameter extensions are supported', { cause: { header: m } });
|
|
1677
|
-
try {
|
|
1678
|
-
p = JSON.parse(Me(xe(b)));
|
|
1679
|
-
} catch (y) {
|
|
1680
|
-
throw A("failed to parse JWT Payload body as base64url encoded JSON", jt, y);
|
|
1681
|
-
}
|
|
1682
|
-
if (!Ot(p)) throw A("JWT Payload must be a top level object", T, l);
|
|
1683
|
-
const E = Ct() + h;
|
|
1684
|
-
if (p.exp !== void 0) {
|
|
1685
|
-
if (typeof p.exp != "number") throw A('unexpected JWT "exp" (expiration time) claim type', T, { claims: p });
|
|
1686
|
-
if (p.exp <= E - d) throw A('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', it, { claims: p, now: E, tolerance: d, claim: "exp" });
|
|
1687
|
-
}
|
|
1688
|
-
if (p.iat !== void 0 && typeof p.iat != "number") throw A('unexpected JWT "iat" (issued at) claim type', T, { claims: p });
|
|
1689
|
-
if (p.iss !== void 0 && typeof p.iss != "string") throw A('unexpected JWT "iss" (issuer) claim type', T, { claims: p });
|
|
1690
|
-
if (p.nbf !== void 0) {
|
|
1691
|
-
if (typeof p.nbf != "number") throw A('unexpected JWT "nbf" (not before) claim type', T, { claims: p });
|
|
1692
|
-
if (p.nbf > E + d) throw A('unexpected JWT "nbf" (not before) claim value', it, { claims: p, now: E, tolerance: d, claim: "nbf" });
|
|
1693
|
-
}
|
|
1694
|
-
if (p.aud !== void 0 && typeof p.aud != "string" && !Array.isArray(p.aud)) throw A('unexpected JWT "aud" (audience) claim type', T, { claims: p });
|
|
1695
|
-
return { header: m, claims: p, jwt: l };
|
|
1696
|
-
})(a.id_token, Fi.bind(void 0, e.id_token_signed_response_alg, n.id_token_signing_alg_values_supported, "RS256"), xt(e), _n(e), r).then(Ki.bind(void 0, s)).then(Di.bind(void 0, n)).then(ji.bind(void 0, e.client_id));
|
|
1697
|
-
if (Array.isArray(c.aud) && c.aud.length !== 1) {
|
|
1698
|
-
if (c.azp === void 0) throw A('ID Token "aud" (audience) claim includes additional untrusted audiences', se, { claims: c, claim: "aud" });
|
|
1699
|
-
if (c.azp !== e.client_id) throw A('unexpected ID Token "azp" (authorized party) claim value', se, { expected: e.client_id, claims: c, claim: "azp" });
|
|
1700
|
-
}
|
|
1701
|
-
c.auth_time !== void 0 && ge(c.auth_time, !0, 'ID Token "auth_time" (authentication time)', T, { claims: c }), Ci.set(t, u), Qo.set(a, c);
|
|
1702
|
-
}
|
|
1703
|
-
if ((i == null ? void 0 : i[a.token_type]) !== void 0) i[a.token_type](t, a);
|
|
1704
|
-
else if (a.token_type !== "dpop" && a.token_type !== "bearer") throw new F("unsupported `token_type` value", { cause: { body: a } });
|
|
1705
|
-
return a;
|
|
1706
|
-
}
|
|
1707
|
-
function ji(n, e) {
|
|
1708
|
-
if (Array.isArray(e.claims.aud)) {
|
|
1709
|
-
if (!e.claims.aud.includes(n)) throw A('unexpected JWT "aud" (audience) claim value', se, { expected: n, claims: e.claims, claim: "aud" });
|
|
1710
|
-
} else if (e.claims.aud !== n) throw A('unexpected JWT "aud" (audience) claim value', se, { expected: n, claims: e.claims, claim: "aud" });
|
|
1711
|
-
return e;
|
|
1712
|
-
}
|
|
1713
|
-
function Di(n, e) {
|
|
1714
|
-
var t, o;
|
|
1715
|
-
const r = (t = (o = n[nr]) === null || o === void 0 ? void 0 : o.call(n, e)) !== null && t !== void 0 ? t : n.issuer;
|
|
1716
|
-
if (e.claims.iss !== r) throw A('unexpected JWT "iss" (issuer) claim value', se, { expected: r, claims: e.claims, claim: "iss" });
|
|
1717
|
-
return e;
|
|
1718
|
-
}
|
|
1719
|
-
const Vn = /* @__PURE__ */ new WeakSet(), mo = Symbol(), Li = { aud: "audience", c_hash: "code hash", client_id: "client id", exp: "expiration time", iat: "issued at", iss: "issuer", jti: "jwt id", nonce: "nonce", s_hash: "state hash", sub: "subject", ath: "access token hash", htm: "http method", htu: "http uri", cnf: "confirmation", auth_time: "authentication time" };
|
|
1720
|
-
function Ki(n, e) {
|
|
1721
|
-
for (const t of n) if (e.claims[t] === void 0) throw A('JWT "'.concat(t, '" (').concat(Li[t], ") claim missing"), T, { claims: e.claims });
|
|
1722
|
-
return e;
|
|
1723
|
-
}
|
|
1724
|
-
const Xt = Symbol(), Yt = Symbol();
|
|
1725
|
-
async function Ui(n, e, t, o) {
|
|
1726
|
-
return typeof (o == null ? void 0 : o.expectedNonce) == "string" || typeof (o == null ? void 0 : o.maxAge) == "number" || o != null && o.requireIdToken ? (async function(r, i, a, s, c, u, l) {
|
|
1727
|
-
const f = [];
|
|
1728
|
-
switch (s) {
|
|
1729
|
-
case void 0:
|
|
1730
|
-
s = Xt;
|
|
1731
|
-
break;
|
|
1732
|
-
case Xt:
|
|
1733
|
-
break;
|
|
1734
|
-
default:
|
|
1735
|
-
D(s, '"expectedNonce" argument'), f.push("nonce");
|
|
1736
|
-
}
|
|
1737
|
-
switch (c != null || (c = i.default_max_age), c) {
|
|
1738
|
-
case void 0:
|
|
1739
|
-
c = Yt;
|
|
1740
|
-
break;
|
|
1741
|
-
case Yt:
|
|
1742
|
-
break;
|
|
1743
|
-
default:
|
|
1744
|
-
ge(c, !0, '"maxAge" argument'), f.push("auth_time");
|
|
1745
|
-
}
|
|
1746
|
-
const h = await Ve(r, i, a, f, u, l);
|
|
1747
|
-
D(h.id_token, '"response" body "id_token" property', T, { body: h });
|
|
1748
|
-
const d = kn(h);
|
|
1749
|
-
if (c !== Yt) {
|
|
1750
|
-
const w = Ct() + xt(i), m = _n(i);
|
|
1751
|
-
if (d.auth_time + c < w - m) throw A("too much time has elapsed since the last End-User authentication", it, { claims: d, now: w, tolerance: m, claim: "auth_time" });
|
|
1752
|
-
}
|
|
1753
|
-
if (s === Xt) {
|
|
1754
|
-
if (d.nonce !== void 0) throw A('unexpected ID Token "nonce" claim value', se, { expected: void 0, claims: d, claim: "nonce" });
|
|
1755
|
-
} else if (d.nonce !== s) throw A('unexpected ID Token "nonce" claim value', se, { expected: s, claims: d, claim: "nonce" });
|
|
1756
|
-
return h;
|
|
1757
|
-
})(n, e, t, o.expectedNonce, o.maxAge, o[ce], o.recognizedTokenTypes) : (async function(r, i, a, s, c) {
|
|
1758
|
-
const u = await Ve(r, i, a, void 0, s, c), l = kn(u);
|
|
1759
|
-
if (l) {
|
|
1760
|
-
if (i.default_max_age !== void 0) {
|
|
1761
|
-
ge(i.default_max_age, !0, '"client.default_max_age"');
|
|
1762
|
-
const f = Ct() + xt(i), h = _n(i);
|
|
1763
|
-
if (l.auth_time + i.default_max_age < f - h) throw A("too much time has elapsed since the last End-User authentication", it, { claims: l, now: f, tolerance: h, claim: "auth_time" });
|
|
1764
|
-
}
|
|
1765
|
-
if (l.nonce !== void 0) throw A('unexpected ID Token "nonce" claim value', se, { expected: void 0, claims: l, claim: "nonce" });
|
|
1766
|
-
}
|
|
1767
|
-
return u;
|
|
1768
|
-
})(n, e, t, o == null ? void 0 : o[ce], o == null ? void 0 : o.recognizedTokenTypes);
|
|
1769
|
-
}
|
|
1770
|
-
const Ni = "OAUTH_WWW_AUTHENTICATE_CHALLENGE", Wi = "OAUTH_RESPONSE_BODY_ERROR", Sn = "OAUTH_UNSUPPORTED_OPERATION", zi = "OAUTH_AUTHORIZATION_RESPONSE_ERROR", jt = "OAUTH_PARSE_ERROR", T = "OAUTH_INVALID_RESPONSE", $o = "OAUTH_RESPONSE_IS_NOT_JSON", Fn = "OAUTH_RESPONSE_IS_NOT_CONFORM", er = "OAUTH_HTTP_REQUEST_FORBIDDEN", tr = "OAUTH_REQUEST_PROTOCOL_FORBIDDEN", it = "OAUTH_JWT_TIMESTAMP_CHECK_FAILED", se = "OAUTH_JWT_CLAIM_COMPARISON_FAILED", En = "OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED", Hi = "OAUTH_MISSING_SERVER_METADATA", Mi = "OAUTH_INVALID_SERVER_METADATA";
|
|
1771
|
-
function ut(n) {
|
|
1772
|
-
if (n.bodyUsed) throw R('"response" body has been used already', "ERR_INVALID_ARG_VALUE");
|
|
1773
|
-
}
|
|
1774
|
-
function yo(n) {
|
|
1775
|
-
const { algorithm: e } = n;
|
|
1776
|
-
if (typeof e.modulusLength != "number" || e.modulusLength < 2048) throw new F("unsupported ".concat(e.name, " modulusLength"), { cause: n });
|
|
1777
|
-
}
|
|
1778
|
-
function Ji(n) {
|
|
1779
|
-
const { algorithm: e } = n;
|
|
1780
|
-
switch (e.namedCurve) {
|
|
1781
|
-
case "P-256":
|
|
1782
|
-
return "SHA-256";
|
|
1783
|
-
case "P-384":
|
|
1784
|
-
return "SHA-384";
|
|
1785
|
-
case "P-521":
|
|
1786
|
-
return "SHA-512";
|
|
1787
|
-
default:
|
|
1788
|
-
throw new F("unsupported ECDSA namedCurve", { cause: n });
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
async function Vi(n) {
|
|
1792
|
-
if (n.method !== "POST") throw R("form_post responses are expected to use the POST method", "ERR_INVALID_ARG_VALUE", { cause: n });
|
|
1793
|
-
if (Yo(n) !== "application/x-www-form-urlencoded") throw R("form_post responses are expected to use the application/x-www-form-urlencoded content-type", "ERR_INVALID_ARG_VALUE", { cause: n });
|
|
1794
|
-
return (async function(e) {
|
|
1795
|
-
if (e.bodyUsed) throw R("form_post Request instances must contain a readable body", "ERR_INVALID_ARG_VALUE", { cause: e });
|
|
1796
|
-
return e.text();
|
|
1797
|
-
})(n);
|
|
1798
|
-
}
|
|
1799
|
-
function Fi(n, e, t, o) {
|
|
1800
|
-
if (n === void 0) if (Array.isArray(e)) {
|
|
1801
|
-
if (!e.includes(o.alg)) throw A('unexpected JWT "alg" header parameter', T, { header: o, expected: e, reason: "authorization server metadata" });
|
|
1802
|
-
} else {
|
|
1803
|
-
if (t === void 0) throw A('missing client or server configuration to verify used JWT "alg" header parameter', void 0, { client: n, issuer: e, fallback: t });
|
|
1804
|
-
if (typeof t == "string" ? o.alg !== t : typeof t == "function" ? !t(o.alg) : !t.includes(o.alg)) throw A('unexpected JWT "alg" header parameter', T, { header: o, expected: t, reason: "default value" });
|
|
1805
|
-
}
|
|
1806
|
-
else if (typeof n == "string" ? o.alg !== n : !n.includes(o.alg)) throw A('unexpected JWT "alg" header parameter', T, { header: o, expected: n, reason: "client configuration" });
|
|
1807
|
-
}
|
|
1808
|
-
function Pe(n, e) {
|
|
1809
|
-
const { 0: t, length: o } = n.getAll(e);
|
|
1810
|
-
if (o > 1) throw A('"'.concat(e, '" parameter must be provided only once'), T);
|
|
1811
|
-
return t;
|
|
1812
|
-
}
|
|
1813
|
-
const Gi = Symbol(), Zi = Symbol();
|
|
1814
|
-
function qi(n, e, t, o) {
|
|
1815
|
-
if ($(n), ee(e), t instanceof URL && (t = t.searchParams), !(t instanceof URLSearchParams)) throw R('"parameters" must be an instance of URLSearchParams, or URL', "ERR_INVALID_ARG_TYPE");
|
|
1816
|
-
if (Pe(t, "response")) throw A('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()', T, { parameters: t });
|
|
1817
|
-
const r = Pe(t, "iss"), i = Pe(t, "state");
|
|
1818
|
-
if (!r && n.authorization_response_iss_parameter_supported) throw A('response parameter "iss" (issuer) missing', T, { parameters: t });
|
|
1819
|
-
if (r && r !== n.issuer) throw A('unexpected "iss" (issuer) response parameter value', T, { expected: n.issuer, parameters: t });
|
|
1820
|
-
switch (o) {
|
|
1821
|
-
case void 0:
|
|
1822
|
-
case Zi:
|
|
1823
|
-
if (i !== void 0) throw A('unexpected "state" response parameter encountered', T, { expected: void 0, parameters: t });
|
|
1824
|
-
break;
|
|
1825
|
-
case Gi:
|
|
1826
|
-
break;
|
|
1827
|
-
default:
|
|
1828
|
-
if (D(o, '"expectedState" argument'), i !== o) throw A(i === void 0 ? 'response parameter "state" missing' : 'unexpected "state" response parameter value', T, { expected: o, parameters: t });
|
|
1829
|
-
}
|
|
1830
|
-
if (Pe(t, "error")) throw new Bo("authorization response from the server is an error", { cause: t });
|
|
1831
|
-
const a = Pe(t, "id_token"), s = Pe(t, "token");
|
|
1832
|
-
if (a !== void 0 || s !== void 0) throw new F("implicit and hybrid flows are not supported");
|
|
1833
|
-
return c = new URLSearchParams(t), Vn.add(c), c;
|
|
1834
|
-
var c;
|
|
1835
|
-
}
|
|
1836
|
-
async function Ht(n) {
|
|
1837
|
-
let e, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Zo;
|
|
1838
|
-
try {
|
|
1839
|
-
e = await n.json();
|
|
1840
|
-
} catch (o) {
|
|
1841
|
-
throw t(n), A('failed to parse "response" body as JSON', jt, o);
|
|
1842
|
-
}
|
|
1843
|
-
if (!Ot(e)) throw A('"response" body must be a top level object', T, { body: e });
|
|
1844
|
-
return e;
|
|
1845
|
-
}
|
|
1846
|
-
const Qt = Symbol(), nr = Symbol(), go = new TextEncoder(), at = new TextDecoder();
|
|
1847
|
-
function $t(n) {
|
|
1848
|
-
const e = new Uint8Array(n.length);
|
|
1849
|
-
for (let t = 0; t < n.length; t++) {
|
|
1850
|
-
const o = n.charCodeAt(t);
|
|
1851
|
-
if (o > 127) throw new TypeError("non-ASCII string encountered in encode()");
|
|
1852
|
-
e[t] = o;
|
|
1853
|
-
}
|
|
1854
|
-
return e;
|
|
1855
|
-
}
|
|
1856
|
-
function or(n) {
|
|
1857
|
-
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(n);
|
|
1858
|
-
const e = atob(n), t = new Uint8Array(e.length);
|
|
1859
|
-
for (let o = 0; o < e.length; o++) t[o] = e.charCodeAt(o);
|
|
1860
|
-
return t;
|
|
1861
|
-
}
|
|
1862
|
-
function tt(n) {
|
|
1863
|
-
if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof n == "string" ? n : at.decode(n), { alphabet: "base64url" });
|
|
1864
|
-
let e = n;
|
|
1865
|
-
e instanceof Uint8Array && (e = at.decode(e)), e = e.replace(/-/g, "+").replace(/_/g, "/");
|
|
1866
|
-
try {
|
|
1867
|
-
return or(e);
|
|
1868
|
-
} catch {
|
|
1869
|
-
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
class W extends Error {
|
|
1873
|
-
constructor(e, t) {
|
|
1874
|
-
var o;
|
|
1875
|
-
super(e, t), _(this, "code", "ERR_JOSE_GENERIC"), this.name = this.constructor.name, (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
_(W, "code", "ERR_JOSE_GENERIC");
|
|
1879
|
-
class B extends W {
|
|
1880
|
-
constructor(e, t) {
|
|
1881
|
-
let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "unspecified", r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "unspecified";
|
|
1882
|
-
super(e, { cause: { claim: o, reason: r, payload: t } }), _(this, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED"), _(this, "claim", void 0), _(this, "reason", void 0), _(this, "payload", void 0), this.claim = o, this.reason = r, this.payload = t;
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
_(B, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
|
|
1886
|
-
class An extends W {
|
|
1887
|
-
constructor(e, t) {
|
|
1888
|
-
let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "unspecified", r = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "unspecified";
|
|
1889
|
-
super(e, { cause: { claim: o, reason: r, payload: t } }), _(this, "code", "ERR_JWT_EXPIRED"), _(this, "claim", void 0), _(this, "reason", void 0), _(this, "payload", void 0), this.claim = o, this.reason = r, this.payload = t;
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
_(An, "code", "ERR_JWT_EXPIRED");
|
|
1893
|
-
class rr extends W {
|
|
1894
|
-
constructor() {
|
|
1895
|
-
super(...arguments), _(this, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
_(rr, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
|
|
1899
|
-
class V extends W {
|
|
1900
|
-
constructor() {
|
|
1901
|
-
super(...arguments), _(this, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
_(V, "code", "ERR_JOSE_NOT_SUPPORTED");
|
|
1905
|
-
_(class extends W {
|
|
1906
|
-
constructor() {
|
|
1907
|
-
super(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "decryption operation failed", arguments.length > 1 ? arguments[1] : void 0), _(this, "code", "ERR_JWE_DECRYPTION_FAILED");
|
|
1908
|
-
}
|
|
1909
|
-
}, "code", "ERR_JWE_DECRYPTION_FAILED");
|
|
1910
|
-
_(class extends W {
|
|
1911
|
-
constructor() {
|
|
1912
|
-
super(...arguments), _(this, "code", "ERR_JWE_INVALID");
|
|
1913
|
-
}
|
|
1914
|
-
}, "code", "ERR_JWE_INVALID");
|
|
1915
|
-
class K extends W {
|
|
1916
|
-
constructor() {
|
|
1917
|
-
super(...arguments), _(this, "code", "ERR_JWS_INVALID");
|
|
1918
|
-
}
|
|
1919
|
-
}
|
|
1920
|
-
_(K, "code", "ERR_JWS_INVALID");
|
|
1921
|
-
class Tn extends W {
|
|
1922
|
-
constructor() {
|
|
1923
|
-
super(...arguments), _(this, "code", "ERR_JWT_INVALID");
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
_(Tn, "code", "ERR_JWT_INVALID");
|
|
1927
|
-
_(class extends W {
|
|
1928
|
-
constructor() {
|
|
1929
|
-
super(...arguments), _(this, "code", "ERR_JWK_INVALID");
|
|
1930
|
-
}
|
|
1931
|
-
}, "code", "ERR_JWK_INVALID");
|
|
1932
|
-
class Gn extends W {
|
|
1933
|
-
constructor() {
|
|
1934
|
-
super(...arguments), _(this, "code", "ERR_JWKS_INVALID");
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
_(Gn, "code", "ERR_JWKS_INVALID");
|
|
1938
|
-
class Zn extends W {
|
|
1939
|
-
constructor() {
|
|
1940
|
-
super(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "no applicable key found in the JSON Web Key Set", arguments.length > 1 ? arguments[1] : void 0), _(this, "code", "ERR_JWKS_NO_MATCHING_KEY");
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
_(Zn, "code", "ERR_JWKS_NO_MATCHING_KEY");
|
|
1944
|
-
class ir extends W {
|
|
1945
|
-
constructor() {
|
|
1946
|
-
super(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "multiple matching keys found in the JSON Web Key Set", arguments.length > 1 ? arguments[1] : void 0), _(this, Symbol.asyncIterator, void 0), _(this, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
_(ir, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
|
|
1950
|
-
class ar extends W {
|
|
1951
|
-
constructor() {
|
|
1952
|
-
super(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "request timed out", arguments.length > 1 ? arguments[1] : void 0), _(this, "code", "ERR_JWKS_TIMEOUT");
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
_(ar, "code", "ERR_JWKS_TIMEOUT");
|
|
1956
|
-
class sr extends W {
|
|
1957
|
-
constructor() {
|
|
1958
|
-
super(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "signature verification failed", arguments.length > 1 ? arguments[1] : void 0), _(this, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
_(sr, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
|
|
1962
|
-
const ne = function(n) {
|
|
1963
|
-
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "algorithm.name";
|
|
1964
|
-
return new TypeError("CryptoKey does not support this operation, its ".concat(e, " must be ").concat(n));
|
|
1965
|
-
}, Ke = (n, e) => n.name === e;
|
|
1966
|
-
function en(n) {
|
|
1967
|
-
return parseInt(n.name.slice(4), 10);
|
|
1968
|
-
}
|
|
1969
|
-
function Bi(n, e, t) {
|
|
1970
|
-
switch (e) {
|
|
1971
|
-
case "HS256":
|
|
1972
|
-
case "HS384":
|
|
1973
|
-
case "HS512": {
|
|
1974
|
-
if (!Ke(n.algorithm, "HMAC")) throw ne("HMAC");
|
|
1975
|
-
const o = parseInt(e.slice(2), 10);
|
|
1976
|
-
if (en(n.algorithm.hash) !== o) throw ne("SHA-".concat(o), "algorithm.hash");
|
|
1977
|
-
break;
|
|
1978
|
-
}
|
|
1979
|
-
case "RS256":
|
|
1980
|
-
case "RS384":
|
|
1981
|
-
case "RS512": {
|
|
1982
|
-
if (!Ke(n.algorithm, "RSASSA-PKCS1-v1_5")) throw ne("RSASSA-PKCS1-v1_5");
|
|
1983
|
-
const o = parseInt(e.slice(2), 10);
|
|
1984
|
-
if (en(n.algorithm.hash) !== o) throw ne("SHA-".concat(o), "algorithm.hash");
|
|
1985
|
-
break;
|
|
1986
|
-
}
|
|
1987
|
-
case "PS256":
|
|
1988
|
-
case "PS384":
|
|
1989
|
-
case "PS512": {
|
|
1990
|
-
if (!Ke(n.algorithm, "RSA-PSS")) throw ne("RSA-PSS");
|
|
1991
|
-
const o = parseInt(e.slice(2), 10);
|
|
1992
|
-
if (en(n.algorithm.hash) !== o) throw ne("SHA-".concat(o), "algorithm.hash");
|
|
1993
|
-
break;
|
|
1994
|
-
}
|
|
1995
|
-
case "Ed25519":
|
|
1996
|
-
case "EdDSA":
|
|
1997
|
-
if (!Ke(n.algorithm, "Ed25519")) throw ne("Ed25519");
|
|
1998
|
-
break;
|
|
1999
|
-
case "ML-DSA-44":
|
|
2000
|
-
case "ML-DSA-65":
|
|
2001
|
-
case "ML-DSA-87":
|
|
2002
|
-
if (!Ke(n.algorithm, e)) throw ne(e);
|
|
2003
|
-
break;
|
|
2004
|
-
case "ES256":
|
|
2005
|
-
case "ES384":
|
|
2006
|
-
case "ES512": {
|
|
2007
|
-
if (!Ke(n.algorithm, "ECDSA")) throw ne("ECDSA");
|
|
2008
|
-
const o = (function(r) {
|
|
2009
|
-
switch (r) {
|
|
2010
|
-
case "ES256":
|
|
2011
|
-
return "P-256";
|
|
2012
|
-
case "ES384":
|
|
2013
|
-
return "P-384";
|
|
2014
|
-
case "ES512":
|
|
2015
|
-
return "P-521";
|
|
2016
|
-
default:
|
|
2017
|
-
throw new Error("unreachable");
|
|
2018
|
-
}
|
|
2019
|
-
})(e);
|
|
2020
|
-
if (n.algorithm.namedCurve !== o) throw ne(o, "algorithm.namedCurve");
|
|
2021
|
-
break;
|
|
2022
|
-
}
|
|
2023
|
-
default:
|
|
2024
|
-
throw new TypeError("CryptoKey does not support this operation");
|
|
2025
|
-
}
|
|
2026
|
-
(function(o, r) {
|
|
2027
|
-
if (!o.usages.includes(r)) throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(r, "."));
|
|
2028
|
-
})(n, t);
|
|
2029
|
-
}
|
|
2030
|
-
function cr(n, e) {
|
|
2031
|
-
for (var t = arguments.length, o = new Array(t > 2 ? t - 2 : 0), r = 2; r < t; r++) o[r - 2] = arguments[r];
|
|
2032
|
-
if ((o = o.filter(Boolean)).length > 2) {
|
|
2033
|
-
const a = o.pop();
|
|
2034
|
-
n += "one of type ".concat(o.join(", "), ", or ").concat(a, ".");
|
|
2035
|
-
} else o.length === 2 ? n += "one of type ".concat(o[0], " or ").concat(o[1], ".") : n += "of type ".concat(o[0], ".");
|
|
2036
|
-
if (e == null) n += " Received ".concat(e);
|
|
2037
|
-
else if (typeof e == "function" && e.name) n += " Received function ".concat(e.name);
|
|
2038
|
-
else if (typeof e == "object" && e != null) {
|
|
2039
|
-
var i;
|
|
2040
|
-
(i = e.constructor) !== null && i !== void 0 && i.name && (n += " Received an instance of ".concat(e.constructor.name));
|
|
2041
|
-
}
|
|
2042
|
-
return n;
|
|
2043
|
-
}
|
|
2044
|
-
const wo = function(n, e) {
|
|
2045
|
-
for (var t = arguments.length, o = new Array(t > 2 ? t - 2 : 0), r = 2; r < t; r++) o[r - 2] = arguments[r];
|
|
2046
|
-
return cr("Key for the ".concat(n, " algorithm must be "), e, ...o);
|
|
2047
|
-
}, ur = (n) => {
|
|
2048
|
-
if ((n == null ? void 0 : n[Symbol.toStringTag]) === "CryptoKey") return !0;
|
|
2049
|
-
try {
|
|
2050
|
-
return n instanceof CryptoKey;
|
|
2051
|
-
} catch {
|
|
2052
|
-
return !1;
|
|
2053
|
-
}
|
|
2054
|
-
}, lr = (n) => (n == null ? void 0 : n[Symbol.toStringTag]) === "KeyObject", vo = (n) => ur(n) || lr(n);
|
|
2055
|
-
function ve(n) {
|
|
2056
|
-
if (typeof (e = n) != "object" || e === null || Object.prototype.toString.call(n) !== "[object Object]") return !1;
|
|
2057
|
-
var e;
|
|
2058
|
-
if (Object.getPrototypeOf(n) === null) return !0;
|
|
2059
|
-
let t = n;
|
|
2060
|
-
for (; Object.getPrototypeOf(t) !== null; ) t = Object.getPrototypeOf(t);
|
|
2061
|
-
return Object.getPrototypeOf(n) === t;
|
|
2062
|
-
}
|
|
2063
|
-
const tn = (n, e) => {
|
|
2064
|
-
if (n.byteLength !== e.length) return !1;
|
|
2065
|
-
for (let t = 0; t < n.byteLength; t++) if (n[t] !== e[t]) return !1;
|
|
2066
|
-
return !0;
|
|
2067
|
-
}, nt = (n) => {
|
|
2068
|
-
const e = n.data[n.pos++];
|
|
2069
|
-
if (128 & e) {
|
|
2070
|
-
const t = 127 & e;
|
|
2071
|
-
let o = 0;
|
|
2072
|
-
for (let r = 0; r < t; r++) o = o << 8 | n.data[n.pos++];
|
|
2073
|
-
return o;
|
|
2074
|
-
}
|
|
2075
|
-
return e;
|
|
2076
|
-
}, ot = (n, e, t) => {
|
|
2077
|
-
if (n.data[n.pos++] !== e) throw new Error(t);
|
|
2078
|
-
}, bo = (n, e) => {
|
|
2079
|
-
const t = n.data.subarray(n.pos, n.pos + e);
|
|
2080
|
-
return n.pos += e, t;
|
|
2081
|
-
}, Xi = (n) => {
|
|
2082
|
-
const e = ((r) => {
|
|
2083
|
-
ot(r, 6, "Expected algorithm OID");
|
|
2084
|
-
const i = nt(r);
|
|
2085
|
-
return bo(r, i);
|
|
2086
|
-
})(n);
|
|
2087
|
-
if (tn(e, [43, 101, 110])) return "X25519";
|
|
2088
|
-
if (!tn(e, [42, 134, 72, 206, 61, 2, 1])) throw new Error("Unsupported key algorithm");
|
|
2089
|
-
ot(n, 6, "Expected curve OID");
|
|
2090
|
-
const t = nt(n), o = bo(n, t);
|
|
2091
|
-
for (const { name: r, oid: i } of [{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] }, { name: "P-384", oid: [43, 129, 4, 0, 34] }, { name: "P-521", oid: [43, 129, 4, 0, 35] }]) if (tn(o, i)) return r;
|
|
2092
|
-
throw new Error("Unsupported named curve");
|
|
2093
|
-
}, Yi = async (n, e, t, o) => {
|
|
2094
|
-
var r;
|
|
2095
|
-
let i, a;
|
|
2096
|
-
const s = () => ["sign"];
|
|
2097
|
-
switch (t) {
|
|
2098
|
-
case "PS256":
|
|
2099
|
-
case "PS384":
|
|
2100
|
-
case "PS512":
|
|
2101
|
-
i = { name: "RSA-PSS", hash: "SHA-".concat(t.slice(-3)) }, a = s();
|
|
2102
|
-
break;
|
|
2103
|
-
case "RS256":
|
|
2104
|
-
case "RS384":
|
|
2105
|
-
case "RS512":
|
|
2106
|
-
i = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-".concat(t.slice(-3)) }, a = s();
|
|
2107
|
-
break;
|
|
2108
|
-
case "RSA-OAEP":
|
|
2109
|
-
case "RSA-OAEP-256":
|
|
2110
|
-
case "RSA-OAEP-384":
|
|
2111
|
-
case "RSA-OAEP-512":
|
|
2112
|
-
i = { name: "RSA-OAEP", hash: "SHA-".concat(parseInt(t.slice(-3), 10) || 1) }, a = ["decrypt", "unwrapKey"];
|
|
2113
|
-
break;
|
|
2114
|
-
case "ES256":
|
|
2115
|
-
case "ES384":
|
|
2116
|
-
case "ES512":
|
|
2117
|
-
i = { name: "ECDSA", namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[t] }, a = s();
|
|
2118
|
-
break;
|
|
2119
|
-
case "ECDH-ES":
|
|
2120
|
-
case "ECDH-ES+A128KW":
|
|
2121
|
-
case "ECDH-ES+A192KW":
|
|
2122
|
-
case "ECDH-ES+A256KW":
|
|
2123
|
-
try {
|
|
2124
|
-
const c = o.getNamedCurve(e);
|
|
2125
|
-
i = c === "X25519" ? { name: "X25519" } : { name: "ECDH", namedCurve: c };
|
|
2126
|
-
} catch {
|
|
2127
|
-
throw new V("Invalid or unsupported key format");
|
|
2128
|
-
}
|
|
2129
|
-
a = ["deriveBits"];
|
|
2130
|
-
break;
|
|
2131
|
-
case "Ed25519":
|
|
2132
|
-
case "EdDSA":
|
|
2133
|
-
i = { name: "Ed25519" }, a = s();
|
|
2134
|
-
break;
|
|
2135
|
-
case "ML-DSA-44":
|
|
2136
|
-
case "ML-DSA-65":
|
|
2137
|
-
case "ML-DSA-87":
|
|
2138
|
-
i = { name: t }, a = s();
|
|
2139
|
-
break;
|
|
2140
|
-
default:
|
|
2141
|
-
throw new V('Invalid or unsupported "alg" (Algorithm) value');
|
|
2142
|
-
}
|
|
2143
|
-
return crypto.subtle.importKey(n, e, i, (r = o == null ? void 0 : o.extractable) !== null && r !== void 0 ? r : !1, a);
|
|
2144
|
-
}, Qi = (n, e, t) => {
|
|
2145
|
-
var o;
|
|
2146
|
-
const r = ((a, s) => or(a.replace(s, "")))(n, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
|
|
2147
|
-
let i = t;
|
|
2148
|
-
return e != null && (o = e.startsWith) !== null && o !== void 0 && o.call(e, "ECDH-ES") && (i || (i = {}), i.getNamedCurve = (a) => {
|
|
2149
|
-
const s = { data: a, pos: 0 };
|
|
2150
|
-
return (function(c) {
|
|
2151
|
-
ot(c, 48, "Invalid PKCS#8 structure"), nt(c), ot(c, 2, "Expected version field");
|
|
2152
|
-
const u = nt(c);
|
|
2153
|
-
c.pos += u, ot(c, 48, "Expected algorithm identifier"), nt(c);
|
|
2154
|
-
})(s), Xi(s);
|
|
2155
|
-
}), Yi("pkcs8", r, e, i);
|
|
2156
|
-
};
|
|
2157
|
-
async function At(n) {
|
|
2158
|
-
var e, t;
|
|
2159
|
-
if (!n.alg) throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
2160
|
-
const { algorithm: o, keyUsages: r } = (function(a) {
|
|
2161
|
-
let s, c;
|
|
2162
|
-
switch (a.kty) {
|
|
2163
|
-
case "AKP":
|
|
2164
|
-
switch (a.alg) {
|
|
2165
|
-
case "ML-DSA-44":
|
|
2166
|
-
case "ML-DSA-65":
|
|
2167
|
-
case "ML-DSA-87":
|
|
2168
|
-
s = { name: a.alg }, c = a.priv ? ["sign"] : ["verify"];
|
|
2169
|
-
break;
|
|
2170
|
-
default:
|
|
2171
|
-
throw new V('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2172
|
-
}
|
|
2173
|
-
break;
|
|
2174
|
-
case "RSA":
|
|
2175
|
-
switch (a.alg) {
|
|
2176
|
-
case "PS256":
|
|
2177
|
-
case "PS384":
|
|
2178
|
-
case "PS512":
|
|
2179
|
-
s = { name: "RSA-PSS", hash: "SHA-".concat(a.alg.slice(-3)) }, c = a.d ? ["sign"] : ["verify"];
|
|
2180
|
-
break;
|
|
2181
|
-
case "RS256":
|
|
2182
|
-
case "RS384":
|
|
2183
|
-
case "RS512":
|
|
2184
|
-
s = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-".concat(a.alg.slice(-3)) }, c = a.d ? ["sign"] : ["verify"];
|
|
2185
|
-
break;
|
|
2186
|
-
case "RSA-OAEP":
|
|
2187
|
-
case "RSA-OAEP-256":
|
|
2188
|
-
case "RSA-OAEP-384":
|
|
2189
|
-
case "RSA-OAEP-512":
|
|
2190
|
-
s = { name: "RSA-OAEP", hash: "SHA-".concat(parseInt(a.alg.slice(-3), 10) || 1) }, c = a.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
2191
|
-
break;
|
|
2192
|
-
default:
|
|
2193
|
-
throw new V('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2194
|
-
}
|
|
2195
|
-
break;
|
|
2196
|
-
case "EC":
|
|
2197
|
-
switch (a.alg) {
|
|
2198
|
-
case "ES256":
|
|
2199
|
-
s = { name: "ECDSA", namedCurve: "P-256" }, c = a.d ? ["sign"] : ["verify"];
|
|
2200
|
-
break;
|
|
2201
|
-
case "ES384":
|
|
2202
|
-
s = { name: "ECDSA", namedCurve: "P-384" }, c = a.d ? ["sign"] : ["verify"];
|
|
2203
|
-
break;
|
|
2204
|
-
case "ES512":
|
|
2205
|
-
s = { name: "ECDSA", namedCurve: "P-521" }, c = a.d ? ["sign"] : ["verify"];
|
|
2206
|
-
break;
|
|
2207
|
-
case "ECDH-ES":
|
|
2208
|
-
case "ECDH-ES+A128KW":
|
|
2209
|
-
case "ECDH-ES+A192KW":
|
|
2210
|
-
case "ECDH-ES+A256KW":
|
|
2211
|
-
s = { name: "ECDH", namedCurve: a.crv }, c = a.d ? ["deriveBits"] : [];
|
|
2212
|
-
break;
|
|
2213
|
-
default:
|
|
2214
|
-
throw new V('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2215
|
-
}
|
|
2216
|
-
break;
|
|
2217
|
-
case "OKP":
|
|
2218
|
-
switch (a.alg) {
|
|
2219
|
-
case "Ed25519":
|
|
2220
|
-
case "EdDSA":
|
|
2221
|
-
s = { name: "Ed25519" }, c = a.d ? ["sign"] : ["verify"];
|
|
2222
|
-
break;
|
|
2223
|
-
case "ECDH-ES":
|
|
2224
|
-
case "ECDH-ES+A128KW":
|
|
2225
|
-
case "ECDH-ES+A192KW":
|
|
2226
|
-
case "ECDH-ES+A256KW":
|
|
2227
|
-
s = { name: a.crv }, c = a.d ? ["deriveBits"] : [];
|
|
2228
|
-
break;
|
|
2229
|
-
default:
|
|
2230
|
-
throw new V('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2231
|
-
}
|
|
2232
|
-
break;
|
|
2233
|
-
default:
|
|
2234
|
-
throw new V('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
2235
|
-
}
|
|
2236
|
-
return { algorithm: s, keyUsages: c };
|
|
2237
|
-
})(n), i = S({}, n);
|
|
2238
|
-
return i.kty !== "AKP" && delete i.alg, delete i.use, crypto.subtle.importKey("jwk", i, o, (e = n.ext) !== null && e !== void 0 ? e : !n.d && !n.priv, (t = n.key_ops) !== null && t !== void 0 ? t : r);
|
|
2239
|
-
}
|
|
2240
|
-
const Pn = (n) => ve(n) && typeof n.kty == "string";
|
|
2241
|
-
let me;
|
|
2242
|
-
const _o = async function(n, e, t) {
|
|
2243
|
-
let o = arguments.length > 3 && arguments[3] !== void 0 && arguments[3];
|
|
2244
|
-
me || (me = /* @__PURE__ */ new WeakMap());
|
|
2245
|
-
let r = me.get(n);
|
|
2246
|
-
if (r != null && r[t]) return r[t];
|
|
2247
|
-
const i = await At(S(S({}, e), {}, { alg: t }));
|
|
2248
|
-
return o && Object.freeze(n), r ? r[t] = i : me.set(n, { [t]: i }), i;
|
|
2249
|
-
};
|
|
2250
|
-
async function $i(n, e) {
|
|
2251
|
-
if (n instanceof Uint8Array || ur(n)) return n;
|
|
2252
|
-
if (lr(n)) {
|
|
2253
|
-
if (n.type === "secret") return n.export();
|
|
2254
|
-
if ("toCryptoKey" in n && typeof n.toCryptoKey == "function") try {
|
|
2255
|
-
return ((o, r) => {
|
|
2256
|
-
me || (me = /* @__PURE__ */ new WeakMap());
|
|
2257
|
-
let i = me.get(o);
|
|
2258
|
-
if (i != null && i[r]) return i[r];
|
|
2259
|
-
const a = o.type === "public", s = !!a;
|
|
2260
|
-
let c;
|
|
2261
|
-
if (o.asymmetricKeyType === "x25519") {
|
|
2262
|
-
switch (r) {
|
|
2263
|
-
case "ECDH-ES":
|
|
2264
|
-
case "ECDH-ES+A128KW":
|
|
2265
|
-
case "ECDH-ES+A192KW":
|
|
2266
|
-
case "ECDH-ES+A256KW":
|
|
2267
|
-
break;
|
|
2268
|
-
default:
|
|
2269
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2270
|
-
}
|
|
2271
|
-
c = o.toCryptoKey(o.asymmetricKeyType, s, a ? [] : ["deriveBits"]);
|
|
2272
|
-
}
|
|
2273
|
-
if (o.asymmetricKeyType === "ed25519") {
|
|
2274
|
-
if (r !== "EdDSA" && r !== "Ed25519") throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2275
|
-
c = o.toCryptoKey(o.asymmetricKeyType, s, [a ? "verify" : "sign"]);
|
|
2276
|
-
}
|
|
2277
|
-
switch (o.asymmetricKeyType) {
|
|
2278
|
-
case "ml-dsa-44":
|
|
2279
|
-
case "ml-dsa-65":
|
|
2280
|
-
case "ml-dsa-87":
|
|
2281
|
-
if (r !== o.asymmetricKeyType.toUpperCase()) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2282
|
-
c = o.toCryptoKey(o.asymmetricKeyType, s, [a ? "verify" : "sign"]);
|
|
2283
|
-
}
|
|
2284
|
-
if (o.asymmetricKeyType === "rsa") {
|
|
2285
|
-
let l;
|
|
2286
|
-
switch (r) {
|
|
2287
|
-
case "RSA-OAEP":
|
|
2288
|
-
l = "SHA-1";
|
|
2289
|
-
break;
|
|
2290
|
-
case "RS256":
|
|
2291
|
-
case "PS256":
|
|
2292
|
-
case "RSA-OAEP-256":
|
|
2293
|
-
l = "SHA-256";
|
|
2294
|
-
break;
|
|
2295
|
-
case "RS384":
|
|
2296
|
-
case "PS384":
|
|
2297
|
-
case "RSA-OAEP-384":
|
|
2298
|
-
l = "SHA-384";
|
|
2299
|
-
break;
|
|
2300
|
-
case "RS512":
|
|
2301
|
-
case "PS512":
|
|
2302
|
-
case "RSA-OAEP-512":
|
|
2303
|
-
l = "SHA-512";
|
|
2304
|
-
break;
|
|
2305
|
-
default:
|
|
2306
|
-
throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2307
|
-
}
|
|
2308
|
-
if (r.startsWith("RSA-OAEP")) return o.toCryptoKey({ name: "RSA-OAEP", hash: l }, s, a ? ["encrypt"] : ["decrypt"]);
|
|
2309
|
-
c = o.toCryptoKey({ name: r.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5", hash: l }, s, [a ? "verify" : "sign"]);
|
|
2310
|
-
}
|
|
2311
|
-
if (o.asymmetricKeyType === "ec") {
|
|
2312
|
-
var u;
|
|
2313
|
-
const l = (/* @__PURE__ */ new Map([["prime256v1", "P-256"], ["secp384r1", "P-384"], ["secp521r1", "P-521"]])).get((u = o.asymmetricKeyDetails) === null || u === void 0 ? void 0 : u.namedCurve);
|
|
2314
|
-
if (!l) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2315
|
-
r === "ES256" && l === "P-256" && (c = o.toCryptoKey({ name: "ECDSA", namedCurve: l }, s, [a ? "verify" : "sign"])), r === "ES384" && l === "P-384" && (c = o.toCryptoKey({ name: "ECDSA", namedCurve: l }, s, [a ? "verify" : "sign"])), r === "ES512" && l === "P-521" && (c = o.toCryptoKey({ name: "ECDSA", namedCurve: l }, s, [a ? "verify" : "sign"])), r.startsWith("ECDH-ES") && (c = o.toCryptoKey({ name: "ECDH", namedCurve: l }, s, a ? [] : ["deriveBits"]));
|
|
2316
|
-
}
|
|
2317
|
-
if (!c) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
|
|
2318
|
-
return i ? i[r] = c : me.set(o, { [r]: c }), c;
|
|
2319
|
-
})(n, e);
|
|
2320
|
-
} catch (o) {
|
|
2321
|
-
if (o instanceof TypeError) throw o;
|
|
2322
|
-
}
|
|
2323
|
-
let t = n.export({ format: "jwk" });
|
|
2324
|
-
return _o(n, t, e);
|
|
2325
|
-
}
|
|
2326
|
-
if (Pn(n)) return n.k ? tt(n.k) : _o(n, n, e, !0);
|
|
2327
|
-
throw new Error("unreachable");
|
|
2328
|
-
}
|
|
2329
|
-
const Ue = (n) => n == null ? void 0 : n[Symbol.toStringTag], nn = (n, e, t) => {
|
|
2330
|
-
if (e.use !== void 0) {
|
|
2331
|
-
let i;
|
|
2332
|
-
switch (t) {
|
|
2333
|
-
case "sign":
|
|
2334
|
-
case "verify":
|
|
2335
|
-
i = "sig";
|
|
2336
|
-
break;
|
|
2337
|
-
case "encrypt":
|
|
2338
|
-
case "decrypt":
|
|
2339
|
-
i = "enc";
|
|
2340
|
-
}
|
|
2341
|
-
if (e.use !== i) throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(i, '" when present'));
|
|
2342
|
-
}
|
|
2343
|
-
if (e.alg !== void 0 && e.alg !== n) throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(n, '" when present'));
|
|
2344
|
-
if (Array.isArray(e.key_ops)) {
|
|
2345
|
-
var o, r;
|
|
2346
|
-
let i;
|
|
2347
|
-
switch (!0) {
|
|
2348
|
-
case t === "verify":
|
|
2349
|
-
case n === "dir":
|
|
2350
|
-
case n.includes("CBC-HS"):
|
|
2351
|
-
i = t;
|
|
2352
|
-
break;
|
|
2353
|
-
case n.startsWith("PBES2"):
|
|
2354
|
-
i = "deriveBits";
|
|
2355
|
-
break;
|
|
2356
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(n):
|
|
2357
|
-
i = !n.includes("GCM") && n.endsWith("KW") ? "unwrapKey" : t;
|
|
2358
|
-
break;
|
|
2359
|
-
case t === "encrypt":
|
|
2360
|
-
i = "wrapKey";
|
|
2361
|
-
break;
|
|
2362
|
-
case t === "decrypt":
|
|
2363
|
-
i = n.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
2364
|
-
}
|
|
2365
|
-
if (i && ((o = e.key_ops) === null || o === void 0 || (r = o.includes) === null || r === void 0 ? void 0 : r.call(o, i)) === !1) throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i, '" when present'));
|
|
2366
|
-
}
|
|
2367
|
-
return !0;
|
|
2368
|
-
};
|
|
2369
|
-
function ea(n, e, t) {
|
|
2370
|
-
switch (n.substring(0, 2)) {
|
|
2371
|
-
case "A1":
|
|
2372
|
-
case "A2":
|
|
2373
|
-
case "di":
|
|
2374
|
-
case "HS":
|
|
2375
|
-
case "PB":
|
|
2376
|
-
((o, r, i) => {
|
|
2377
|
-
if (!(r instanceof Uint8Array)) {
|
|
2378
|
-
if (Pn(r)) {
|
|
2379
|
-
if (((a) => a.kty === "oct" && typeof a.k == "string")(r) && nn(o, r, i)) return;
|
|
2380
|
-
throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
|
|
2381
|
-
}
|
|
2382
|
-
if (!vo(r)) throw new TypeError(wo(o, r, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
2383
|
-
if (r.type !== "secret") throw new TypeError("".concat(Ue(r), ' instances for symmetric algorithms must be of type "secret"'));
|
|
2384
|
-
}
|
|
2385
|
-
})(n, e, t);
|
|
2386
|
-
break;
|
|
2387
|
-
default:
|
|
2388
|
-
((o, r, i) => {
|
|
2389
|
-
if (Pn(r)) switch (i) {
|
|
2390
|
-
case "decrypt":
|
|
2391
|
-
case "sign":
|
|
2392
|
-
if (((a) => a.kty !== "oct" && (a.kty === "AKP" && typeof a.priv == "string" || typeof a.d == "string"))(r) && nn(o, r, i)) return;
|
|
2393
|
-
throw new TypeError("JSON Web Key for this operation must be a private JWK");
|
|
2394
|
-
case "encrypt":
|
|
2395
|
-
case "verify":
|
|
2396
|
-
if (((a) => a.kty !== "oct" && a.d === void 0 && a.priv === void 0)(r) && nn(o, r, i)) return;
|
|
2397
|
-
throw new TypeError("JSON Web Key for this operation must be a public JWK");
|
|
2398
|
-
}
|
|
2399
|
-
if (!vo(r)) throw new TypeError(wo(o, r, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
2400
|
-
if (r.type === "secret") throw new TypeError("".concat(Ue(r), ' instances for asymmetric algorithms must not be of type "secret"'));
|
|
2401
|
-
if (r.type === "public") switch (i) {
|
|
2402
|
-
case "sign":
|
|
2403
|
-
throw new TypeError("".concat(Ue(r), ' instances for asymmetric algorithm signing must be of type "private"'));
|
|
2404
|
-
case "decrypt":
|
|
2405
|
-
throw new TypeError("".concat(Ue(r), ' instances for asymmetric algorithm decryption must be of type "private"'));
|
|
2406
|
-
}
|
|
2407
|
-
if (r.type === "private") switch (i) {
|
|
2408
|
-
case "verify":
|
|
2409
|
-
throw new TypeError("".concat(Ue(r), ' instances for asymmetric algorithm verifying must be of type "public"'));
|
|
2410
|
-
case "encrypt":
|
|
2411
|
-
throw new TypeError("".concat(Ue(r), ' instances for asymmetric algorithm encryption must be of type "public"'));
|
|
2412
|
-
}
|
|
2413
|
-
})(n, e, t);
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
var wt, on;
|
|
2417
|
-
let re, ko;
|
|
2418
|
-
(typeof navigator > "u" || (wt = navigator.userAgent) === null || wt === void 0 || (on = wt.startsWith) === null || on === void 0 || !on.call(wt, "Mozilla/5.0 ")) && (ko = "".concat("openid-client", "/").concat("v6.8.1"), re = { "user-agent": ko });
|
|
2419
|
-
const N = (n) => Tt.get(n);
|
|
2420
|
-
let Tt, vt;
|
|
2421
|
-
function hr(n) {
|
|
2422
|
-
return n !== void 0 ? po(n) : (vt || (vt = /* @__PURE__ */ new WeakMap()), (e, t, o, r) => {
|
|
2423
|
-
let i;
|
|
2424
|
-
return (i = vt.get(t)) || ((function(a, s) {
|
|
2425
|
-
if (typeof a != "string") throw ie("".concat(s, " must be a string"), ht);
|
|
2426
|
-
if (a.length === 0) throw ie("".concat(s, " must not be empty"), lt);
|
|
2427
|
-
})(t.client_secret, '"metadata.client_secret"'), i = po(t.client_secret), vt.set(t, i)), i(e, t, o, r);
|
|
2428
|
-
});
|
|
2429
|
-
}
|
|
2430
|
-
const ye = te, lt = "ERR_INVALID_ARG_VALUE", ht = "ERR_INVALID_ARG_TYPE";
|
|
2431
|
-
function ie(n, e, t) {
|
|
2432
|
-
const o = new TypeError(n, { cause: t });
|
|
2433
|
-
return Object.assign(o, { code: e }), o;
|
|
2434
|
-
}
|
|
2435
|
-
function ta(n) {
|
|
2436
|
-
return (async function(e) {
|
|
2437
|
-
return D(e, "codeVerifier"), xe(await crypto.subtle.digest("SHA-256", Me(e)));
|
|
2438
|
-
})(n);
|
|
2439
|
-
}
|
|
2440
|
-
function na() {
|
|
2441
|
-
return qo();
|
|
2442
|
-
}
|
|
2443
|
-
class Dt extends Error {
|
|
2444
|
-
constructor(e, t) {
|
|
2445
|
-
var o;
|
|
2446
|
-
super(e, t), _(this, "code", void 0), this.name = this.constructor.name, this.code = t == null ? void 0 : t.code, (o = Error.captureStackTrace) === null || o === void 0 || o.call(Error, this, this.constructor);
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
function z(n, e, t) {
|
|
2450
|
-
return new Dt(n, { cause: e, code: t });
|
|
2451
|
-
}
|
|
2452
|
-
function H(n) {
|
|
2453
|
-
if (n instanceof TypeError || n instanceof Dt || n instanceof zt || n instanceof Bo || n instanceof Hn) throw n;
|
|
2454
|
-
if (n instanceof Wn) switch (n.code) {
|
|
2455
|
-
case er:
|
|
2456
|
-
throw z("only requests to HTTPS are allowed", n, n.code);
|
|
2457
|
-
case tr:
|
|
2458
|
-
throw z("only requests to HTTP or HTTPS are allowed", n, n.code);
|
|
2459
|
-
case Fn:
|
|
2460
|
-
throw z("unexpected HTTP response status code", n.cause, n.code);
|
|
2461
|
-
case $o:
|
|
2462
|
-
throw z("unexpected response content-type", n.cause, n.code);
|
|
2463
|
-
case jt:
|
|
2464
|
-
throw z("parsing error occured", n, n.code);
|
|
2465
|
-
case T:
|
|
2466
|
-
throw z("invalid response encountered", n, n.code);
|
|
2467
|
-
case se:
|
|
2468
|
-
throw z("unexpected JWT claim value encountered", n, n.code);
|
|
2469
|
-
case En:
|
|
2470
|
-
throw z("unexpected JSON attribute value encountered", n, n.code);
|
|
2471
|
-
case it:
|
|
2472
|
-
throw z("JWT timestamp claim value failed validation", n, n.code);
|
|
2473
|
-
default:
|
|
2474
|
-
throw z(n.message, n, n.code);
|
|
2475
|
-
}
|
|
2476
|
-
if (n instanceof F) throw z("unsupported operation", n, n.code);
|
|
2477
|
-
if (n instanceof DOMException) switch (n.name) {
|
|
2478
|
-
case "OperationError":
|
|
2479
|
-
throw z("runtime operation error", n, Sn);
|
|
2480
|
-
case "NotSupportedError":
|
|
2481
|
-
throw z("runtime unsupported operation", n, Sn);
|
|
2482
|
-
case "TimeoutError":
|
|
2483
|
-
throw z("operation timed out", n, "OAUTH_TIMEOUT");
|
|
2484
|
-
case "AbortError":
|
|
2485
|
-
throw z("operation aborted", n, "OAUTH_ABORT");
|
|
2486
|
-
}
|
|
2487
|
-
throw new Dt("something went wrong", { cause: n });
|
|
2488
|
-
}
|
|
2489
|
-
async function oa(n, e, t, o, r) {
|
|
2490
|
-
const i = await (async function(c, u) {
|
|
2491
|
-
var l, f;
|
|
2492
|
-
if (!(c instanceof URL)) throw ie('"server" must be an instance of URL', ht);
|
|
2493
|
-
const h = !c.href.includes("/.well-known/"), d = (l = u == null ? void 0 : u.timeout) !== null && l !== void 0 ? l : 30, w = AbortSignal.timeout(1e3 * d), m = await (h ? Si(c, { algorithm: u == null ? void 0 : u.algorithm, [te]: u == null ? void 0 : u[ye], [q]: u == null || (f = u.execute) === null || f === void 0 ? void 0 : f.includes(Ao), signal: w, headers: new Headers(re) }) : ((u == null ? void 0 : u[ye]) || fetch)((zn(c, u == null || (p = u.execute) === null || p === void 0 || !p.includes(Ao)), c.href), { headers: Object.fromEntries(new Headers(S({ accept: "application/json" }, re)).entries()), body: void 0, method: "GET", redirect: "manual", signal: w })).then(((g) => (async function(b, k) {
|
|
2494
|
-
const E = b;
|
|
2495
|
-
if (!(E instanceof URL) && E !== Qt) throw R('"expectedIssuerIdentifier" must be an instance of URL', "ERR_INVALID_ARG_TYPE");
|
|
2496
|
-
if (!Ge(k, Response)) throw R('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
|
|
2497
|
-
if (k.status !== 200) throw A('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)', Fn, k);
|
|
2498
|
-
ut(k);
|
|
2499
|
-
const y = await Ht(k);
|
|
2500
|
-
if (D(y.issuer, '"response" body "issuer" property', T, { body: y }), E !== Qt && new URL(y.issuer).href !== E.href) throw A('"response" body "issuer" property does not match the expected value', En, { expected: E.href, body: y, attribute: "issuer" });
|
|
2501
|
-
return y;
|
|
2502
|
-
})(Qt, g))).catch(H);
|
|
2503
|
-
var p;
|
|
2504
|
-
return h && new URL(m.issuer).href !== c.href && ((function(g, b, k) {
|
|
2505
|
-
return !(g.origin !== "https://login.microsoftonline.com" || k != null && k.algorithm && k.algorithm !== "oidc" || (b[dr] = !0, 0));
|
|
2506
|
-
})(c, m, u) || (function(g, b) {
|
|
2507
|
-
return !(!g.hostname.endsWith(".b2clogin.com") || b != null && b.algorithm && b.algorithm !== "oidc");
|
|
2508
|
-
})(c, u) || (() => {
|
|
2509
|
-
throw new Dt("discovered metadata issuer does not match the expected issuer", { code: En, cause: { expected: c.href, body: m, attribute: "issuer" } });
|
|
2510
|
-
})()), m;
|
|
2511
|
-
})(n, r), a = new Lt(i, e, t, o);
|
|
2512
|
-
let s = N(a);
|
|
2513
|
-
if (r != null && r[ye] && (s.fetch = r[ye]), r != null && r.timeout && (s.timeout = r.timeout), r != null && r.execute) for (const c of r.execute) c(a);
|
|
2514
|
-
return a;
|
|
2515
|
-
}
|
|
2516
|
-
new TextDecoder();
|
|
2517
|
-
const dr = Symbol();
|
|
2518
|
-
class Lt {
|
|
2519
|
-
constructor(e, t, o, r) {
|
|
2520
|
-
var i, a, s, c, u;
|
|
2521
|
-
if (typeof t != "string" || !t.length) throw ie('"clientId" must be a non-empty string', ht);
|
|
2522
|
-
if (typeof o == "string" && (o = { client_secret: o }), ((i = o) === null || i === void 0 ? void 0 : i.client_id) !== void 0 && t !== o.client_id) throw ie('"clientId" and "metadata.client_id" must be the same', lt);
|
|
2523
|
-
const l = S(S({}, structuredClone(o)), {}, { client_id: t });
|
|
2524
|
-
let f;
|
|
2525
|
-
l[wn] = (a = (s = o) === null || s === void 0 ? void 0 : s[wn]) !== null && a !== void 0 ? a : 0, l[vn] = (c = (u = o) === null || u === void 0 ? void 0 : u[vn]) !== null && c !== void 0 ? c : 30, f = r || (typeof l.client_secret == "string" && l.client_secret.length ? hr(l.client_secret) : (m, p, g, b) => {
|
|
2526
|
-
g.set("client_id", p.client_id);
|
|
2527
|
-
});
|
|
2528
|
-
let h = Object.freeze(l);
|
|
2529
|
-
const d = structuredClone(e);
|
|
2530
|
-
dr in e && (d[nr] = (m) => {
|
|
2531
|
-
let { claims: { tid: p } } = m;
|
|
2532
|
-
return e.issuer.replace("{tenantid}", p);
|
|
2533
|
-
});
|
|
2534
|
-
let w = Object.freeze(d);
|
|
2535
|
-
Tt || (Tt = /* @__PURE__ */ new WeakMap()), Tt.set(this, { __proto__: null, as: w, c: h, auth: f, tlsOnly: !0, jwksCache: {} });
|
|
2536
|
-
}
|
|
2537
|
-
serverMetadata() {
|
|
2538
|
-
const e = structuredClone(N(this).as);
|
|
2539
|
-
return (function(t) {
|
|
2540
|
-
Object.defineProperties(t, /* @__PURE__ */ (function(o) {
|
|
2541
|
-
return { supportsPKCE: { __proto__: null, value() {
|
|
2542
|
-
var r;
|
|
2543
|
-
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "S256";
|
|
2544
|
-
return ((r = o.code_challenge_methods_supported) === null || r === void 0 ? void 0 : r.includes(i)) === !0;
|
|
2545
|
-
} } };
|
|
2546
|
-
})(t));
|
|
2547
|
-
})(e), e;
|
|
2548
|
-
}
|
|
2549
|
-
clientMetadata() {
|
|
2550
|
-
return structuredClone(N(this).c);
|
|
2551
|
-
}
|
|
2552
|
-
get timeout() {
|
|
2553
|
-
return N(this).timeout;
|
|
2554
|
-
}
|
|
2555
|
-
set timeout(e) {
|
|
2556
|
-
N(this).timeout = e;
|
|
2557
|
-
}
|
|
2558
|
-
get [ye]() {
|
|
2559
|
-
return N(this).fetch;
|
|
2560
|
-
}
|
|
2561
|
-
set [ye](e) {
|
|
2562
|
-
N(this).fetch = e;
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
function dt(n) {
|
|
2566
|
-
Object.defineProperties(n, (function(e) {
|
|
2567
|
-
let t;
|
|
2568
|
-
if (e.expires_in !== void 0) {
|
|
2569
|
-
const o = /* @__PURE__ */ new Date();
|
|
2570
|
-
o.setSeconds(o.getSeconds() + e.expires_in), t = o.getTime();
|
|
2571
|
-
}
|
|
2572
|
-
return { expiresIn: { __proto__: null, value() {
|
|
2573
|
-
if (t) {
|
|
2574
|
-
const o = Date.now();
|
|
2575
|
-
return t > o ? Math.floor((t - o) / 1e3) : 0;
|
|
2576
|
-
}
|
|
2577
|
-
} }, claims: { __proto__: null, value() {
|
|
2578
|
-
try {
|
|
2579
|
-
return kn(this);
|
|
2580
|
-
} catch {
|
|
2581
|
-
return;
|
|
2582
|
-
}
|
|
2583
|
-
} } };
|
|
2584
|
-
})(n));
|
|
2585
|
-
}
|
|
2586
|
-
async function So(n, e, t) {
|
|
2587
|
-
var o;
|
|
2588
|
-
let r = arguments.length > 3 && arguments[3] !== void 0 && arguments[3];
|
|
2589
|
-
const i = (o = n.headers.get("retry-after")) === null || o === void 0 ? void 0 : o.trim();
|
|
2590
|
-
if (i === void 0) return;
|
|
2591
|
-
let a;
|
|
2592
|
-
if (/^\d+$/.test(i)) a = parseInt(i, 10);
|
|
2593
|
-
else {
|
|
2594
|
-
const s = new Date(i);
|
|
2595
|
-
if (Number.isFinite(s.getTime())) {
|
|
2596
|
-
const c = /* @__PURE__ */ new Date(), u = s.getTime() - c.getTime();
|
|
2597
|
-
u > 0 && (a = Math.ceil(u / 1e3));
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
if (r && !Number.isFinite(a)) throw new Wn("invalid Retry-After header value", { cause: n });
|
|
2601
|
-
a > e && await pr(a - e, t);
|
|
2602
|
-
}
|
|
2603
|
-
function pr(n, e) {
|
|
2604
|
-
return new Promise(((t, o) => {
|
|
2605
|
-
const r = (i) => {
|
|
2606
|
-
try {
|
|
2607
|
-
e.throwIfAborted();
|
|
2608
|
-
} catch (s) {
|
|
2609
|
-
return void o(s);
|
|
2610
|
-
}
|
|
2611
|
-
if (i <= 0) return void t();
|
|
2612
|
-
const a = Math.min(i, 5);
|
|
2613
|
-
setTimeout((() => r(i - a)), 1e3 * a);
|
|
2614
|
-
};
|
|
2615
|
-
r(n);
|
|
2616
|
-
}));
|
|
2617
|
-
}
|
|
2618
|
-
async function Eo(n, e) {
|
|
2619
|
-
ue(n);
|
|
2620
|
-
const { as: t, c: o, auth: r, fetch: i, tlsOnly: a, timeout: s } = N(n);
|
|
2621
|
-
return (async function(c, u, l, f, h) {
|
|
2622
|
-
$(c), ee(u);
|
|
2623
|
-
const d = st(c, "backchannel_authentication_endpoint", u.use_mtls_endpoint_aliases, (h == null ? void 0 : h[q]) !== !0), w = new URLSearchParams(f);
|
|
2624
|
-
w.set("client_id", u.client_id);
|
|
2625
|
-
const m = Wt(h == null ? void 0 : h.headers);
|
|
2626
|
-
return m.set("accept", "application/json"), Jn(c, u, l, d, w, m, h);
|
|
2627
|
-
})(t, o, r, e, { [te]: i, [q]: !a, headers: new Headers(re), signal: je(s) }).then(((c) => (async function(u, l, f) {
|
|
2628
|
-
if ($(u), ee(l), !Ge(f, Response)) throw R('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
|
|
2629
|
-
await Mn(f, 200, "Backchannel Authentication Endpoint"), ut(f);
|
|
2630
|
-
const h = await Ht(f);
|
|
2631
|
-
D(h.auth_req_id, '"response" body "auth_req_id" property', T, { body: h });
|
|
2632
|
-
let d = typeof h.expires_in != "number" ? parseFloat(h.expires_in) : h.expires_in;
|
|
2633
|
-
return ge(d, !0, '"response" body "expires_in" property', T, { body: h }), h.expires_in = d, h.interval !== void 0 && ge(h.interval, !1, '"response" body "interval" property', T, { body: h }), h;
|
|
2634
|
-
})(t, o, c))).catch(H);
|
|
2635
|
-
}
|
|
2636
|
-
async function fr(n, e, t, o) {
|
|
2637
|
-
var r, i;
|
|
2638
|
-
ue(n), t = new URLSearchParams(t);
|
|
2639
|
-
let a = (r = e.interval) !== null && r !== void 0 ? r : 5;
|
|
2640
|
-
const s = (i = o == null ? void 0 : o.signal) !== null && i !== void 0 ? i : AbortSignal.timeout(1e3 * e.expires_in);
|
|
2641
|
-
try {
|
|
2642
|
-
await pr(a, s);
|
|
2643
|
-
} catch (y) {
|
|
2644
|
-
H(y);
|
|
2645
|
-
}
|
|
2646
|
-
const { as: c, c: u, auth: l, fetch: f, tlsOnly: h, nonRepudiation: d, timeout: w, decrypt: m } = N(n), p = (y, P) => fr(n, S(S({}, e), {}, { interval: y }), t, S(S({}, o), {}, { signal: s, flag: P })), g = await (async function(y, P, J, U, he) {
|
|
2647
|
-
$(y), ee(P), D(U, '"authReqId"');
|
|
2648
|
-
const M = new URLSearchParams(he == null ? void 0 : he.additionalParameters);
|
|
2649
|
-
return M.set("auth_req_id", U), ct(y, P, J, "urn:openid:params:grant-type:ciba", M, he);
|
|
2650
|
-
})(c, u, l, e.auth_req_id, { [te]: f, [q]: !h, additionalParameters: t, DPoP: o == null ? void 0 : o.DPoP, headers: new Headers(re), signal: s.aborted ? s : je(w) }).catch(H);
|
|
2651
|
-
var b;
|
|
2652
|
-
if (g.status === 503 && g.headers.has("retry-after")) return await So(g, a, s, !0), await ((b = g.body) === null || b === void 0 ? void 0 : b.cancel()), p(a);
|
|
2653
|
-
const k = (async function(y, P, J, U) {
|
|
2654
|
-
return Ve(y, P, J, void 0, U == null ? void 0 : U[ce], U == null ? void 0 : U.recognizedTokenTypes);
|
|
2655
|
-
})(c, u, g, { [ce]: m });
|
|
2656
|
-
let E;
|
|
2657
|
-
try {
|
|
2658
|
-
E = await k;
|
|
2659
|
-
} catch (y) {
|
|
2660
|
-
if (pt(y, o)) return p(a, we);
|
|
2661
|
-
if (y instanceof zt) switch (y.error) {
|
|
2662
|
-
case "slow_down":
|
|
2663
|
-
a += 5;
|
|
2664
|
-
case "authorization_pending":
|
|
2665
|
-
return await So(y.response, a, s), p(a);
|
|
2666
|
-
}
|
|
2667
|
-
H(y);
|
|
2668
|
-
}
|
|
2669
|
-
return E.id_token && await (d == null ? void 0 : d(g)), dt(E), E;
|
|
2670
|
-
}
|
|
2671
|
-
function Ao(n) {
|
|
2672
|
-
N(n).tlsOnly = !1;
|
|
2673
|
-
}
|
|
2674
|
-
async function mr(n, e, t, o, r) {
|
|
2675
|
-
if (ue(n), !((r == null ? void 0 : r.flag) === we || e instanceof URL || (function(y, P) {
|
|
2676
|
-
try {
|
|
2677
|
-
return Object.getPrototypeOf(y)[Symbol.toStringTag] === P;
|
|
2678
|
-
} catch {
|
|
2679
|
-
return !1;
|
|
2680
|
-
}
|
|
2681
|
-
})(e, "Request"))) throw ie('"currentUrl" must be an instance of URL, or Request', ht);
|
|
2682
|
-
let i, a;
|
|
2683
|
-
const { as: s, c, auth: u, fetch: l, tlsOnly: f, jarm: h, hybrid: d, nonRepudiation: w, timeout: m, decrypt: p, implicit: g } = N(n);
|
|
2684
|
-
if ((r == null ? void 0 : r.flag) === we) i = r.authResponse, a = r.redirectUri;
|
|
2685
|
-
else {
|
|
2686
|
-
if (!(e instanceof URL)) {
|
|
2687
|
-
const y = e;
|
|
2688
|
-
switch (e = new URL(e.url), y.method) {
|
|
2689
|
-
case "GET":
|
|
2690
|
-
break;
|
|
2691
|
-
case "POST":
|
|
2692
|
-
const P = new URLSearchParams(await Vi(y));
|
|
2693
|
-
if (d) e.hash = P.toString();
|
|
2694
|
-
else for (const [J, U] of P.entries()) e.searchParams.append(J, U);
|
|
2695
|
-
break;
|
|
2696
|
-
default:
|
|
2697
|
-
throw ie("unexpected Request HTTP method", lt);
|
|
2698
|
-
}
|
|
2699
|
-
}
|
|
2700
|
-
switch (a = (function(y) {
|
|
2701
|
-
return (y = new URL(y)).search = "", y.hash = "", y.href;
|
|
2702
|
-
})(e), !0) {
|
|
2703
|
-
case !!h:
|
|
2704
|
-
i = await h(e, t == null ? void 0 : t.expectedState);
|
|
2705
|
-
break;
|
|
2706
|
-
case !!d:
|
|
2707
|
-
i = await d(e, t == null ? void 0 : t.expectedNonce, t == null ? void 0 : t.expectedState, t == null ? void 0 : t.maxAge);
|
|
2708
|
-
break;
|
|
2709
|
-
case !!g:
|
|
2710
|
-
throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");
|
|
2711
|
-
default:
|
|
2712
|
-
try {
|
|
2713
|
-
i = qi(s, c, e.searchParams, t == null ? void 0 : t.expectedState);
|
|
2714
|
-
} catch (y) {
|
|
2715
|
-
H(y);
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
}
|
|
2719
|
-
const b = await (async function(y, P, J, U, he, M, De) {
|
|
2720
|
-
if ($(y), ee(P), !Vn.has(U)) throw R('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()', "ERR_INVALID_ARG_VALUE");
|
|
2721
|
-
D(he, '"redirectUri"');
|
|
2722
|
-
const Qn = Pe(U, "code");
|
|
2723
|
-
if (!Qn) throw A('no authorization code in "callbackParameters"', T);
|
|
2724
|
-
const ft = new URLSearchParams(De == null ? void 0 : De.additionalParameters);
|
|
2725
|
-
return ft.set("redirect_uri", he), ft.set("code", Qn), M !== mo && (D(M, '"codeVerifier"'), ft.set("code_verifier", M)), ct(y, P, J, "authorization_code", ft, De);
|
|
2726
|
-
})(s, c, u, i, a, (t == null ? void 0 : t.pkceCodeVerifier) || mo, { additionalParameters: o, [te]: l, [q]: !f, DPoP: r == null ? void 0 : r.DPoP, headers: new Headers(re), signal: je(m) }).catch(H);
|
|
2727
|
-
typeof (t == null ? void 0 : t.expectedNonce) != "string" && typeof (t == null ? void 0 : t.maxAge) != "number" || (t.idTokenExpected = !0);
|
|
2728
|
-
const k = Ui(s, c, b, { expectedNonce: t == null ? void 0 : t.expectedNonce, maxAge: t == null ? void 0 : t.maxAge, requireIdToken: t == null ? void 0 : t.idTokenExpected, [ce]: p });
|
|
2729
|
-
let E;
|
|
2730
|
-
try {
|
|
2731
|
-
E = await k;
|
|
2732
|
-
} catch (y) {
|
|
2733
|
-
if (pt(y, r)) return mr(n, void 0, t, o, S(S({}, r), {}, { flag: we, authResponse: i, redirectUri: a }));
|
|
2734
|
-
H(y);
|
|
2735
|
-
}
|
|
2736
|
-
return E.id_token && await (w == null ? void 0 : w(b)), dt(E), E;
|
|
2737
|
-
}
|
|
2738
|
-
async function yr(n, e, t, o) {
|
|
2739
|
-
ue(n), t = new URLSearchParams(t);
|
|
2740
|
-
const { as: r, c: i, auth: a, fetch: s, tlsOnly: c, nonRepudiation: u, timeout: l, decrypt: f } = N(n), h = await (async function(m, p, g, b, k) {
|
|
2741
|
-
$(m), ee(p), D(b, '"refreshToken"');
|
|
2742
|
-
const E = new URLSearchParams(k == null ? void 0 : k.additionalParameters);
|
|
2743
|
-
return E.set("refresh_token", b), ct(m, p, g, "refresh_token", E, k);
|
|
2744
|
-
})(r, i, a, e, { [te]: s, [q]: !c, additionalParameters: t, DPoP: o == null ? void 0 : o.DPoP, headers: new Headers(re), signal: je(l) }).catch(H), d = (async function(m, p, g, b) {
|
|
2745
|
-
return Ve(m, p, g, void 0, b == null ? void 0 : b[ce], b == null ? void 0 : b.recognizedTokenTypes);
|
|
2746
|
-
})(r, i, h, { [ce]: f });
|
|
2747
|
-
let w;
|
|
2748
|
-
try {
|
|
2749
|
-
w = await d;
|
|
2750
|
-
} catch (m) {
|
|
2751
|
-
if (pt(m, o)) return yr(n, e, t, S(S({}, o), {}, { flag: we }));
|
|
2752
|
-
H(m);
|
|
2753
|
-
}
|
|
2754
|
-
return w.id_token && await (u == null ? void 0 : u(h)), dt(w), w;
|
|
2755
|
-
}
|
|
2756
|
-
async function gr(n, e, t) {
|
|
2757
|
-
ue(n), e = new URLSearchParams(e);
|
|
2758
|
-
const { as: o, c: r, auth: i, fetch: a, tlsOnly: s, timeout: c } = N(n), u = await (async function(h, d, w, m, p) {
|
|
2759
|
-
return $(h), ee(d), ct(h, d, w, "client_credentials", new URLSearchParams(m), p);
|
|
2760
|
-
})(o, r, i, e, { [te]: a, [q]: !s, DPoP: t == null ? void 0 : t.DPoP, headers: new Headers(re), signal: je(c) }).catch(H), l = (async function(h, d, w, m) {
|
|
2761
|
-
return Ve(h, d, w, void 0, void 0, void 0);
|
|
2762
|
-
})(o, r, u);
|
|
2763
|
-
let f;
|
|
2764
|
-
try {
|
|
2765
|
-
f = await l;
|
|
2766
|
-
} catch (h) {
|
|
2767
|
-
if (pt(h, t)) return gr(n, e, S(S({}, t), {}, { flag: we }));
|
|
2768
|
-
H(h);
|
|
2769
|
-
}
|
|
2770
|
-
return dt(f), f;
|
|
2771
|
-
}
|
|
2772
|
-
function Rn(n, e) {
|
|
2773
|
-
ue(n);
|
|
2774
|
-
const { as: t, c: o, tlsOnly: r, hybrid: i, jarm: a, implicit: s } = N(n), c = st(t, "authorization_endpoint", !1, r);
|
|
2775
|
-
if ((e = new URLSearchParams(e)).has("client_id") || e.set("client_id", o.client_id), !e.has("request_uri") && !e.has("request")) {
|
|
2776
|
-
if (e.has("response_type") || e.set("response_type", i ? "code id_token" : s ? "id_token" : "code"), s && !e.has("nonce")) throw ie("response_type=id_token clients must provide a nonce parameter in their authorization request parameters", lt);
|
|
2777
|
-
a && e.set("response_mode", "jwt");
|
|
2778
|
-
}
|
|
2779
|
-
for (const [u, l] of e.entries()) c.searchParams.append(u, l);
|
|
2780
|
-
return c;
|
|
2781
|
-
}
|
|
2782
|
-
async function wr(n, e, t) {
|
|
2783
|
-
ue(n);
|
|
2784
|
-
const o = Rn(n, e), { as: r, c: i, auth: a, fetch: s, tlsOnly: c, timeout: u } = N(n), l = await (async function(d, w, m, p, g) {
|
|
2785
|
-
var b;
|
|
2786
|
-
$(d), ee(w);
|
|
2787
|
-
const k = st(d, "pushed_authorization_request_endpoint", w.use_mtls_endpoint_aliases, (g == null ? void 0 : g[q]) !== !0), E = new URLSearchParams(p);
|
|
2788
|
-
E.set("client_id", w.client_id);
|
|
2789
|
-
const y = Wt(g == null ? void 0 : g.headers);
|
|
2790
|
-
y.set("accept", "application/json"), (g == null ? void 0 : g.DPoP) !== void 0 && (Xo(g.DPoP), await g.DPoP.addProof(k, y, "POST"));
|
|
2791
|
-
const P = await Jn(d, w, m, k, E, y, g);
|
|
2792
|
-
return g == null || (b = g.DPoP) === null || b === void 0 || b.cacheNonce(P, k), P;
|
|
2793
|
-
})(r, i, a, o.searchParams, { [te]: s, [q]: !c, DPoP: t == null ? void 0 : t.DPoP, headers: new Headers(re), signal: je(u) }).catch(H), f = (async function(d, w, m) {
|
|
2794
|
-
if ($(d), ee(w), !Ge(m, Response)) throw R('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
|
|
2795
|
-
await Mn(m, 201, "Pushed Authorization Request Endpoint"), ut(m);
|
|
2796
|
-
const p = await Ht(m);
|
|
2797
|
-
D(p.request_uri, '"response" body "request_uri" property', T, { body: p });
|
|
2798
|
-
let g = typeof p.expires_in != "number" ? parseFloat(p.expires_in) : p.expires_in;
|
|
2799
|
-
return ge(g, !0, '"response" body "expires_in" property', T, { body: p }), p.expires_in = g, p;
|
|
2800
|
-
})(r, i, l);
|
|
2801
|
-
let h;
|
|
2802
|
-
try {
|
|
2803
|
-
h = await f;
|
|
2804
|
-
} catch (d) {
|
|
2805
|
-
if (pt(d, t)) return wr(n, e, S(S({}, t), {}, { flag: we }));
|
|
2806
|
-
H(d);
|
|
2807
|
-
}
|
|
2808
|
-
return Rn(n, { request_uri: h.request_uri });
|
|
2809
|
-
}
|
|
2810
|
-
function ue(n) {
|
|
2811
|
-
if (!(n instanceof Lt)) throw ie('"config" must be an instance of Configuration', ht);
|
|
2812
|
-
if (Object.getPrototypeOf(n) !== Lt.prototype) throw ie("subclassing Configuration is not allowed", lt);
|
|
2813
|
-
}
|
|
2814
|
-
function je(n) {
|
|
2815
|
-
return n ? AbortSignal.timeout(1e3 * n) : void 0;
|
|
2816
|
-
}
|
|
2817
|
-
function pt(n, e) {
|
|
2818
|
-
return !(e == null || !e.DPoP || e.flag === we) && (function(t) {
|
|
2819
|
-
if (t instanceof Hn) {
|
|
2820
|
-
const { 0: o, length: r } = t.cause;
|
|
2821
|
-
return r === 1 && o.scheme === "dpop" && o.parameters.error === "use_dpop_nonce";
|
|
2822
|
-
}
|
|
2823
|
-
return t instanceof zt && t.error === "use_dpop_nonce";
|
|
2824
|
-
})(n);
|
|
2825
|
-
}
|
|
2826
|
-
Object.freeze(Lt.prototype);
|
|
2827
|
-
const we = Symbol();
|
|
2828
|
-
async function qn(n, e, t, o) {
|
|
2829
|
-
ue(n);
|
|
2830
|
-
const { as: r, c: i, auth: a, fetch: s, tlsOnly: c, timeout: u, decrypt: l } = N(n), f = await (async function(h, d, w, m, p, g) {
|
|
2831
|
-
return $(h), ee(d), D(m, '"grantType"'), ct(h, d, w, m, new URLSearchParams(p), g);
|
|
2832
|
-
})(r, i, a, e, new URLSearchParams(t), { [te]: s, [q]: !c, DPoP: void 0, headers: new Headers(re), signal: je(u) }).then(((h) => {
|
|
2833
|
-
let d;
|
|
2834
|
-
return e === "urn:ietf:params:oauth:grant-type:token-exchange" && (d = { n_a: () => {
|
|
2835
|
-
} }), (async function(w, m, p, g) {
|
|
2836
|
-
return Ve(w, m, p, void 0, g == null ? void 0 : g[ce], g == null ? void 0 : g.recognizedTokenTypes);
|
|
2837
|
-
})(r, i, h, { [ce]: l, recognizedTokenTypes: d });
|
|
2838
|
-
})).catch(H);
|
|
2839
|
-
return dt(f), f;
|
|
2840
|
-
}
|
|
2841
|
-
async function ra(n, e, t) {
|
|
2842
|
-
if (e instanceof Uint8Array) {
|
|
2843
|
-
if (!n.startsWith("HS")) throw new TypeError((function(o) {
|
|
2844
|
-
for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++) i[a - 1] = arguments[a];
|
|
2845
|
-
return cr("Key must be ", o, ...i);
|
|
2846
|
-
})(e, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
2847
|
-
return crypto.subtle.importKey("raw", e, { hash: "SHA-".concat(n.slice(-3)), name: "HMAC" }, !1, [t]);
|
|
2848
|
-
}
|
|
2849
|
-
return Bi(e, n, t), e;
|
|
2850
|
-
}
|
|
2851
|
-
async function ia(n, e, t, o) {
|
|
2852
|
-
const r = await ra(n, e, "verify");
|
|
2853
|
-
(function(a, s) {
|
|
2854
|
-
if (a.startsWith("RS") || a.startsWith("PS")) {
|
|
2855
|
-
const { modulusLength: c } = s.algorithm;
|
|
2856
|
-
if (typeof c != "number" || c < 2048) throw new TypeError("".concat(a, " requires key modulusLength to be 2048 bits or larger"));
|
|
2857
|
-
}
|
|
2858
|
-
})(n, r);
|
|
2859
|
-
const i = (function(a, s) {
|
|
2860
|
-
const c = "SHA-".concat(a.slice(-3));
|
|
2861
|
-
switch (a) {
|
|
2862
|
-
case "HS256":
|
|
2863
|
-
case "HS384":
|
|
2864
|
-
case "HS512":
|
|
2865
|
-
return { hash: c, name: "HMAC" };
|
|
2866
|
-
case "PS256":
|
|
2867
|
-
case "PS384":
|
|
2868
|
-
case "PS512":
|
|
2869
|
-
return { hash: c, name: "RSA-PSS", saltLength: parseInt(a.slice(-3), 10) >> 3 };
|
|
2870
|
-
case "RS256":
|
|
2871
|
-
case "RS384":
|
|
2872
|
-
case "RS512":
|
|
2873
|
-
return { hash: c, name: "RSASSA-PKCS1-v1_5" };
|
|
2874
|
-
case "ES256":
|
|
2875
|
-
case "ES384":
|
|
2876
|
-
case "ES512":
|
|
2877
|
-
return { hash: c, name: "ECDSA", namedCurve: s.namedCurve };
|
|
2878
|
-
case "Ed25519":
|
|
2879
|
-
case "EdDSA":
|
|
2880
|
-
return { name: "Ed25519" };
|
|
2881
|
-
case "ML-DSA-44":
|
|
2882
|
-
case "ML-DSA-65":
|
|
2883
|
-
case "ML-DSA-87":
|
|
2884
|
-
return { name: a };
|
|
2885
|
-
default:
|
|
2886
|
-
throw new V("alg ".concat(a, " is not supported either by JOSE or your javascript runtime"));
|
|
2887
|
-
}
|
|
2888
|
-
})(n, r.algorithm);
|
|
2889
|
-
try {
|
|
2890
|
-
return await crypto.subtle.verify(i, r, t, o);
|
|
2891
|
-
} catch {
|
|
2892
|
-
return !1;
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
async function aa(n, e, t) {
|
|
2896
|
-
if (!ve(n)) throw new K("Flattened JWS must be an object");
|
|
2897
|
-
if (n.protected === void 0 && n.header === void 0) throw new K('Flattened JWS must have either of the "protected" or "header" members');
|
|
2898
|
-
if (n.protected !== void 0 && typeof n.protected != "string") throw new K("JWS Protected Header incorrect type");
|
|
2899
|
-
if (n.payload === void 0) throw new K("JWS Payload missing");
|
|
2900
|
-
if (typeof n.signature != "string") throw new K("JWS Signature missing or incorrect type");
|
|
2901
|
-
if (n.header !== void 0 && !ve(n.header)) throw new K("JWS Unprotected Header incorrect type");
|
|
2902
|
-
let o = {};
|
|
2903
|
-
if (n.protected) try {
|
|
2904
|
-
const m = tt(n.protected);
|
|
2905
|
-
o = JSON.parse(at.decode(m));
|
|
2906
|
-
} catch {
|
|
2907
|
-
throw new K("JWS Protected Header is invalid");
|
|
2908
|
-
}
|
|
2909
|
-
if (!(function() {
|
|
2910
|
-
for (var m = arguments.length, p = new Array(m), g = 0; g < m; g++) p[g] = arguments[g];
|
|
2911
|
-
const b = p.filter(Boolean);
|
|
2912
|
-
if (b.length === 0 || b.length === 1) return !0;
|
|
2913
|
-
let k;
|
|
2914
|
-
for (const E of b) {
|
|
2915
|
-
const y = Object.keys(E);
|
|
2916
|
-
if (k && k.size !== 0) for (const P of y) {
|
|
2917
|
-
if (k.has(P)) return !1;
|
|
2918
|
-
k.add(P);
|
|
2919
|
-
}
|
|
2920
|
-
else k = new Set(y);
|
|
2921
|
-
}
|
|
2922
|
-
return !0;
|
|
2923
|
-
})(o, n.header)) throw new K("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
2924
|
-
const r = S(S({}, o), n.header), i = (function(m, p, g, b, k) {
|
|
2925
|
-
if (k.crit !== void 0 && (b == null ? void 0 : b.crit) === void 0) throw new m('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
2926
|
-
if (!b || b.crit === void 0) return /* @__PURE__ */ new Set();
|
|
2927
|
-
if (!Array.isArray(b.crit) || b.crit.length === 0 || b.crit.some(((y) => typeof y != "string" || y.length === 0))) throw new m('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
2928
|
-
let E;
|
|
2929
|
-
E = g !== void 0 ? new Map([...Object.entries(g), ...p.entries()]) : p;
|
|
2930
|
-
for (const y of b.crit) {
|
|
2931
|
-
if (!E.has(y)) throw new V('Extension Header Parameter "'.concat(y, '" is not recognized'));
|
|
2932
|
-
if (k[y] === void 0) throw new m('Extension Header Parameter "'.concat(y, '" is missing'));
|
|
2933
|
-
if (E.get(y) && b[y] === void 0) throw new m('Extension Header Parameter "'.concat(y, '" MUST be integrity protected'));
|
|
2934
|
-
}
|
|
2935
|
-
return new Set(b.crit);
|
|
2936
|
-
})(K, /* @__PURE__ */ new Map([["b64", !0]]), t == null ? void 0 : t.crit, o, r);
|
|
2937
|
-
let a = !0;
|
|
2938
|
-
if (i.has("b64") && (a = o.b64, typeof a != "boolean")) throw new K('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
2939
|
-
const { alg: s } = r;
|
|
2940
|
-
if (typeof s != "string" || !s) throw new K('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
2941
|
-
const c = t && (function(m, p) {
|
|
2942
|
-
if (p !== void 0 && (!Array.isArray(p) || p.some(((g) => typeof g != "string")))) throw new TypeError('"'.concat(m, '" option must be an array of strings'));
|
|
2943
|
-
if (p) return new Set(p);
|
|
2944
|
-
})("algorithms", t.algorithms);
|
|
2945
|
-
if (c && !c.has(s)) throw new rr('"alg" (Algorithm) Header Parameter value not allowed');
|
|
2946
|
-
if (a) {
|
|
2947
|
-
if (typeof n.payload != "string") throw new K("JWS Payload must be a string");
|
|
2948
|
-
} else if (typeof n.payload != "string" && !(n.payload instanceof Uint8Array)) throw new K("JWS Payload must be a string or an Uint8Array instance");
|
|
2949
|
-
let u = !1;
|
|
2950
|
-
typeof e == "function" && (e = await e(o, n), u = !0), ea(s, e, "verify");
|
|
2951
|
-
const l = (function() {
|
|
2952
|
-
for (var m = arguments.length, p = new Array(m), g = 0; g < m; g++) p[g] = arguments[g];
|
|
2953
|
-
const b = p.reduce(((y, P) => {
|
|
2954
|
-
let { length: J } = P;
|
|
2955
|
-
return y + J;
|
|
2956
|
-
}), 0), k = new Uint8Array(b);
|
|
2957
|
-
let E = 0;
|
|
2958
|
-
for (const y of p) k.set(y, E), E += y.length;
|
|
2959
|
-
return k;
|
|
2960
|
-
})(n.protected !== void 0 ? $t(n.protected) : new Uint8Array(), $t("."), typeof n.payload == "string" ? a ? $t(n.payload) : go.encode(n.payload) : n.payload);
|
|
2961
|
-
let f;
|
|
2962
|
-
try {
|
|
2963
|
-
f = tt(n.signature);
|
|
2964
|
-
} catch {
|
|
2965
|
-
throw new K("Failed to base64url decode the signature");
|
|
2966
|
-
}
|
|
2967
|
-
const h = await $i(e, s);
|
|
2968
|
-
if (!await ia(s, h, f, l)) throw new sr();
|
|
2969
|
-
let d;
|
|
2970
|
-
if (a) try {
|
|
2971
|
-
d = tt(n.payload);
|
|
2972
|
-
} catch {
|
|
2973
|
-
throw new K("Failed to base64url decode the payload");
|
|
2974
|
-
}
|
|
2975
|
-
else d = typeof n.payload == "string" ? go.encode(n.payload) : n.payload;
|
|
2976
|
-
const w = { payload: d };
|
|
2977
|
-
return n.protected !== void 0 && (w.protectedHeader = o), n.header !== void 0 && (w.unprotectedHeader = n.header), u ? S(S({}, w), {}, { key: h }) : w;
|
|
2978
|
-
}
|
|
2979
|
-
const sa = (n) => Math.floor(n.getTime() / 1e3), ca = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
|
|
2980
|
-
function To(n) {
|
|
2981
|
-
const e = ca.exec(n);
|
|
2982
|
-
if (!e || e[4] && e[1]) throw new TypeError("Invalid time period format");
|
|
2983
|
-
const t = parseFloat(e[2]);
|
|
2984
|
-
let o;
|
|
2985
|
-
switch (e[3].toLowerCase()) {
|
|
2986
|
-
case "sec":
|
|
2987
|
-
case "secs":
|
|
2988
|
-
case "second":
|
|
2989
|
-
case "seconds":
|
|
2990
|
-
case "s":
|
|
2991
|
-
o = Math.round(t);
|
|
2992
|
-
break;
|
|
2993
|
-
case "minute":
|
|
2994
|
-
case "minutes":
|
|
2995
|
-
case "min":
|
|
2996
|
-
case "mins":
|
|
2997
|
-
case "m":
|
|
2998
|
-
o = Math.round(60 * t);
|
|
2999
|
-
break;
|
|
3000
|
-
case "hour":
|
|
3001
|
-
case "hours":
|
|
3002
|
-
case "hr":
|
|
3003
|
-
case "hrs":
|
|
3004
|
-
case "h":
|
|
3005
|
-
o = Math.round(3600 * t);
|
|
3006
|
-
break;
|
|
3007
|
-
case "day":
|
|
3008
|
-
case "days":
|
|
3009
|
-
case "d":
|
|
3010
|
-
o = Math.round(86400 * t);
|
|
3011
|
-
break;
|
|
3012
|
-
case "week":
|
|
3013
|
-
case "weeks":
|
|
3014
|
-
case "w":
|
|
3015
|
-
o = Math.round(604800 * t);
|
|
3016
|
-
break;
|
|
3017
|
-
default:
|
|
3018
|
-
o = Math.round(31557600 * t);
|
|
3019
|
-
}
|
|
3020
|
-
return e[1] === "-" || e[4] === "ago" ? -o : o;
|
|
3021
|
-
}
|
|
3022
|
-
const Po = (n) => n.includes("/") ? n.toLowerCase() : "application/".concat(n.toLowerCase()), ua = (n, e) => typeof n == "string" ? e.includes(n) : !!Array.isArray(n) && e.some(Set.prototype.has.bind(new Set(n)));
|
|
3023
|
-
async function la(n, e, t) {
|
|
3024
|
-
var o;
|
|
3025
|
-
const r = await (async function(s, c, u) {
|
|
3026
|
-
if (s instanceof Uint8Array && (s = at.decode(s)), typeof s != "string") throw new K("Compact JWS must be a string or Uint8Array");
|
|
3027
|
-
const { 0: l, 1: f, 2: h, length: d } = s.split(".");
|
|
3028
|
-
if (d !== 3) throw new K("Invalid Compact JWS");
|
|
3029
|
-
const w = await aa({ payload: f, protected: l, signature: h }, c, u), m = { payload: w.payload, protectedHeader: w.protectedHeader };
|
|
3030
|
-
return typeof c == "function" ? S(S({}, m), {}, { key: w.key }) : m;
|
|
3031
|
-
})(n, e, t);
|
|
3032
|
-
if ((o = r.protectedHeader.crit) !== null && o !== void 0 && o.includes("b64") && r.protectedHeader.b64 === !1) throw new Tn("JWTs MUST NOT use unencoded payload");
|
|
3033
|
-
const i = (function(s, c) {
|
|
3034
|
-
let u, l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
3035
|
-
try {
|
|
3036
|
-
u = JSON.parse(at.decode(c));
|
|
3037
|
-
} catch {
|
|
3038
|
-
}
|
|
3039
|
-
if (!ve(u)) throw new Tn("JWT Claims Set must be a top-level JSON object");
|
|
3040
|
-
const { typ: f } = l;
|
|
3041
|
-
if (f && (typeof s.typ != "string" || Po(s.typ) !== Po(f))) throw new B('unexpected "typ" JWT header value', u, "typ", "check_failed");
|
|
3042
|
-
const { requiredClaims: h = [], issuer: d, subject: w, audience: m, maxTokenAge: p } = l, g = [...h];
|
|
3043
|
-
p !== void 0 && g.push("iat"), m !== void 0 && g.push("aud"), w !== void 0 && g.push("sub"), d !== void 0 && g.push("iss");
|
|
3044
|
-
for (const y of new Set(g.reverse())) if (!(y in u)) throw new B('missing required "'.concat(y, '" claim'), u, y, "missing");
|
|
3045
|
-
if (d && !(Array.isArray(d) ? d : [d]).includes(u.iss)) throw new B('unexpected "iss" claim value', u, "iss", "check_failed");
|
|
3046
|
-
if (w && u.sub !== w) throw new B('unexpected "sub" claim value', u, "sub", "check_failed");
|
|
3047
|
-
if (m && !ua(u.aud, typeof m == "string" ? [m] : m)) throw new B('unexpected "aud" claim value', u, "aud", "check_failed");
|
|
3048
|
-
let b;
|
|
3049
|
-
switch (typeof l.clockTolerance) {
|
|
3050
|
-
case "string":
|
|
3051
|
-
b = To(l.clockTolerance);
|
|
3052
|
-
break;
|
|
3053
|
-
case "number":
|
|
3054
|
-
b = l.clockTolerance;
|
|
3055
|
-
break;
|
|
3056
|
-
case "undefined":
|
|
3057
|
-
b = 0;
|
|
3058
|
-
break;
|
|
3059
|
-
default:
|
|
3060
|
-
throw new TypeError("Invalid clockTolerance option type");
|
|
3061
|
-
}
|
|
3062
|
-
const { currentDate: k } = l, E = sa(k || /* @__PURE__ */ new Date());
|
|
3063
|
-
if ((u.iat !== void 0 || p) && typeof u.iat != "number") throw new B('"iat" claim must be a number', u, "iat", "invalid");
|
|
3064
|
-
if (u.nbf !== void 0) {
|
|
3065
|
-
if (typeof u.nbf != "number") throw new B('"nbf" claim must be a number', u, "nbf", "invalid");
|
|
3066
|
-
if (u.nbf > E + b) throw new B('"nbf" claim timestamp check failed', u, "nbf", "check_failed");
|
|
3067
|
-
}
|
|
3068
|
-
if (u.exp !== void 0) {
|
|
3069
|
-
if (typeof u.exp != "number") throw new B('"exp" claim must be a number', u, "exp", "invalid");
|
|
3070
|
-
if (u.exp <= E - b) throw new An('"exp" claim timestamp check failed', u, "exp", "check_failed");
|
|
3071
|
-
}
|
|
3072
|
-
if (p) {
|
|
3073
|
-
const y = E - u.iat;
|
|
3074
|
-
if (y - b > (typeof p == "number" ? p : To(p))) throw new An('"iat" claim timestamp check failed (too far in the past)', u, "iat", "check_failed");
|
|
3075
|
-
if (y < 0 - b) throw new B('"iat" claim timestamp check failed (it should be in the past)', u, "iat", "check_failed");
|
|
3076
|
-
}
|
|
3077
|
-
return u;
|
|
3078
|
-
})(r.protectedHeader, r.payload, t), a = { payload: i, protectedHeader: r.protectedHeader };
|
|
3079
|
-
return typeof e == "function" ? S(S({}, a), {}, { key: r.key }) : a;
|
|
3080
|
-
}
|
|
3081
|
-
function ha(n) {
|
|
3082
|
-
return ve(n);
|
|
3083
|
-
}
|
|
3084
|
-
var bt, rn, _t = /* @__PURE__ */ new WeakMap(), an = /* @__PURE__ */ new WeakMap();
|
|
3085
|
-
class da {
|
|
3086
|
-
constructor(e) {
|
|
3087
|
-
if (L(this, _t, void 0), L(this, an, /* @__PURE__ */ new WeakMap()), !(function(t) {
|
|
3088
|
-
return t && typeof t == "object" && Array.isArray(t.keys) && t.keys.every(ha);
|
|
3089
|
-
})(e)) throw new Gn("JSON Web Key Set malformed");
|
|
3090
|
-
x(_t, this, structuredClone(e));
|
|
3091
|
-
}
|
|
3092
|
-
jwks() {
|
|
3093
|
-
return v(_t, this);
|
|
3094
|
-
}
|
|
3095
|
-
async getKey(e, t) {
|
|
3096
|
-
const { alg: o, kid: r } = S(S({}, e), t == null ? void 0 : t.header), i = (function(u) {
|
|
3097
|
-
switch (typeof u == "string" && u.slice(0, 2)) {
|
|
3098
|
-
case "RS":
|
|
3099
|
-
case "PS":
|
|
3100
|
-
return "RSA";
|
|
3101
|
-
case "ES":
|
|
3102
|
-
return "EC";
|
|
3103
|
-
case "Ed":
|
|
3104
|
-
return "OKP";
|
|
3105
|
-
case "ML":
|
|
3106
|
-
return "AKP";
|
|
3107
|
-
default:
|
|
3108
|
-
throw new V('Unsupported "alg" value for a JSON Web Key Set');
|
|
3109
|
-
}
|
|
3110
|
-
})(o), a = v(_t, this).keys.filter(((u) => {
|
|
3111
|
-
let l = i === u.kty;
|
|
3112
|
-
if (l && typeof r == "string" && (l = r === u.kid), !l || typeof u.alg != "string" && i !== "AKP" || (l = o === u.alg), l && typeof u.use == "string" && (l = u.use === "sig"), l && Array.isArray(u.key_ops) && (l = u.key_ops.includes("verify")), l) switch (o) {
|
|
3113
|
-
case "ES256":
|
|
3114
|
-
l = u.crv === "P-256";
|
|
3115
|
-
break;
|
|
3116
|
-
case "ES384":
|
|
3117
|
-
l = u.crv === "P-384";
|
|
3118
|
-
break;
|
|
3119
|
-
case "ES512":
|
|
3120
|
-
l = u.crv === "P-521";
|
|
3121
|
-
break;
|
|
3122
|
-
case "Ed25519":
|
|
3123
|
-
case "EdDSA":
|
|
3124
|
-
l = u.crv === "Ed25519";
|
|
3125
|
-
}
|
|
3126
|
-
return l;
|
|
3127
|
-
})), { 0: s, length: c } = a;
|
|
3128
|
-
if (c === 0) throw new Zn();
|
|
3129
|
-
if (c !== 1) {
|
|
3130
|
-
const u = new ir(), l = v(an, this);
|
|
3131
|
-
throw u[Symbol.asyncIterator] = vi((function* () {
|
|
3132
|
-
for (const f of a) try {
|
|
3133
|
-
yield yield wi(Ro(l, f, o));
|
|
3134
|
-
} catch {
|
|
3135
|
-
}
|
|
3136
|
-
})), u;
|
|
3137
|
-
}
|
|
3138
|
-
return Ro(v(an, this), s, o);
|
|
3139
|
-
}
|
|
3140
|
-
}
|
|
3141
|
-
async function Ro(n, e, t) {
|
|
3142
|
-
const o = n.get(e) || n.set(e, {}).get(e);
|
|
3143
|
-
if (o[t] === void 0) {
|
|
3144
|
-
const r = await (async function(i, a, s) {
|
|
3145
|
-
var c;
|
|
3146
|
-
if (!ve(i)) throw new TypeError("JWK must be an object");
|
|
3147
|
-
let u;
|
|
3148
|
-
switch (a != null || (a = i.alg), u != null || (u = (c = void 0) !== null && c !== void 0 ? c : i.ext), i.kty) {
|
|
3149
|
-
case "oct":
|
|
3150
|
-
if (typeof i.k != "string" || !i.k) throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
3151
|
-
return tt(i.k);
|
|
3152
|
-
case "RSA":
|
|
3153
|
-
if ("oth" in i && i.oth !== void 0) throw new V('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
3154
|
-
return At(S(S({}, i), {}, { alg: a, ext: u }));
|
|
3155
|
-
case "AKP":
|
|
3156
|
-
if (typeof i.alg != "string" || !i.alg) throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
3157
|
-
if (a !== void 0 && a !== i.alg) throw new TypeError("JWK alg and alg option value mismatch");
|
|
3158
|
-
return At(S(S({}, i), {}, { ext: u }));
|
|
3159
|
-
case "EC":
|
|
3160
|
-
case "OKP":
|
|
3161
|
-
return At(S(S({}, i), {}, { alg: a, ext: u }));
|
|
3162
|
-
default:
|
|
3163
|
-
throw new V('Unsupported "kty" (Key Type) Parameter value');
|
|
3164
|
-
}
|
|
3165
|
-
})(S(S({}, e), {}, { ext: !0 }), t);
|
|
3166
|
-
if (r instanceof Uint8Array || r.type !== "public") throw new Gn("JSON Web Key Set members must be public keys");
|
|
3167
|
-
o[t] = r;
|
|
3168
|
-
}
|
|
3169
|
-
return o[t];
|
|
3170
|
-
}
|
|
3171
|
-
function Io(n) {
|
|
3172
|
-
const e = new da(n), t = async (o, r) => e.getKey(o, r);
|
|
3173
|
-
return Object.defineProperties(t, { jwks: { value: () => structuredClone(e.jwks()), enumerable: !1, configurable: !1, writable: !1 } }), t;
|
|
3174
|
-
}
|
|
3175
|
-
let In;
|
|
3176
|
-
(typeof navigator > "u" || (bt = navigator.userAgent) === null || bt === void 0 || (rn = bt.startsWith) === null || rn === void 0 || !rn.call(bt, "Mozilla/5.0 ")) && (In = "".concat("jose", "/").concat("v6.1.3"));
|
|
3177
|
-
const vr = Symbol(), sn = Symbol();
|
|
3178
|
-
var cn = /* @__PURE__ */ new WeakMap(), un = /* @__PURE__ */ new WeakMap(), ln = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), hn = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakMap();
|
|
3179
|
-
class pa {
|
|
3180
|
-
constructor(e, t) {
|
|
3181
|
-
if (L(this, cn, void 0), L(this, un, void 0), L(this, ln, void 0), L(this, kt, void 0), L(this, ke, void 0), L(this, ae, void 0), L(this, de, void 0), L(this, hn, void 0), L(this, Se, void 0), L(this, Ee, void 0), !(e instanceof URL)) throw new TypeError("url must be an instance of URL");
|
|
3182
|
-
var o, r;
|
|
3183
|
-
x(cn, this, new URL(e.href)), x(un, this, typeof (t == null ? void 0 : t.timeoutDuration) == "number" ? t == null ? void 0 : t.timeoutDuration : 5e3), x(ln, this, typeof (t == null ? void 0 : t.cooldownDuration) == "number" ? t == null ? void 0 : t.cooldownDuration : 3e4), x(kt, this, typeof (t == null ? void 0 : t.cacheMaxAge) == "number" ? t == null ? void 0 : t.cacheMaxAge : 6e5), x(de, this, new Headers(t == null ? void 0 : t.headers)), In && !v(de, this).has("User-Agent") && v(de, this).set("User-Agent", In), v(de, this).has("accept") || (v(de, this).set("accept", "application/json"), v(de, this).append("accept", "application/jwk-set+json")), x(hn, this, t == null ? void 0 : t[vr]), (t == null ? void 0 : t[sn]) !== void 0 && (x(Ee, this, t == null ? void 0 : t[sn]), o = t == null ? void 0 : t[sn], r = v(kt, this), typeof o == "object" && o !== null && "uat" in o && typeof o.uat == "number" && !(Date.now() - o.uat >= r) && "jwks" in o && ve(o.jwks) && Array.isArray(o.jwks.keys) && Array.prototype.every.call(o.jwks.keys, ve) && (x(ke, this, v(Ee, this).uat), x(Se, this, Io(v(Ee, this).jwks))));
|
|
3184
|
-
}
|
|
3185
|
-
pendingFetch() {
|
|
3186
|
-
return !!v(ae, this);
|
|
3187
|
-
}
|
|
3188
|
-
coolingDown() {
|
|
3189
|
-
return typeof v(ke, this) == "number" && Date.now() < v(ke, this) + v(ln, this);
|
|
3190
|
-
}
|
|
3191
|
-
fresh() {
|
|
3192
|
-
return typeof v(ke, this) == "number" && Date.now() < v(ke, this) + v(kt, this);
|
|
3193
|
-
}
|
|
3194
|
-
jwks() {
|
|
3195
|
-
var e;
|
|
3196
|
-
return (e = v(Se, this)) === null || e === void 0 ? void 0 : e.jwks();
|
|
3197
|
-
}
|
|
3198
|
-
async getKey(e, t) {
|
|
3199
|
-
v(Se, this) && this.fresh() || await this.reload();
|
|
3200
|
-
try {
|
|
3201
|
-
return await v(Se, this).call(this, e, t);
|
|
3202
|
-
} catch (o) {
|
|
3203
|
-
if (o instanceof Zn && this.coolingDown() === !1) return await this.reload(), v(Se, this).call(this, e, t);
|
|
3204
|
-
throw o;
|
|
3205
|
-
}
|
|
3206
|
-
}
|
|
3207
|
-
async reload() {
|
|
3208
|
-
v(ae, this) && (typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel") && x(ae, this, void 0), v(ae, this) || x(ae, this, (async function(e, t, o) {
|
|
3209
|
-
const i = await (arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : fetch)(e, { method: "GET", signal: o, redirect: "manual", headers: t }).catch(((a) => {
|
|
3210
|
-
throw a.name === "TimeoutError" ? new ar() : a;
|
|
3211
|
-
}));
|
|
3212
|
-
if (i.status !== 200) throw new W("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
3213
|
-
try {
|
|
3214
|
-
return await i.json();
|
|
3215
|
-
} catch {
|
|
3216
|
-
throw new W("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
3217
|
-
}
|
|
3218
|
-
})(v(cn, this).href, v(de, this), AbortSignal.timeout(v(un, this)), v(hn, this)).then(((e) => {
|
|
3219
|
-
x(Se, this, Io(e)), v(Ee, this) && (v(Ee, this).uat = Date.now(), v(Ee, this).jwks = e), x(ke, this, Date.now()), x(ae, this, void 0);
|
|
3220
|
-
})).catch(((e) => {
|
|
3221
|
-
throw x(ae, this, void 0), e;
|
|
3222
|
-
}))), await v(ae, this);
|
|
3223
|
-
}
|
|
3224
|
-
}
|
|
3225
|
-
const fa = ["mfaToken"], ma = ["mfaToken"];
|
|
3226
|
-
var Ae, St, Te, fe, ze, I, Ye, C, Oo = class extends Error {
|
|
3227
|
-
constructor(n, e) {
|
|
3228
|
-
super(e), _(this, "code", void 0), this.name = "NotSupportedError", this.code = n;
|
|
3229
|
-
}
|
|
3230
|
-
}, le = class extends Error {
|
|
3231
|
-
constructor(n, e, t) {
|
|
3232
|
-
super(e), _(this, "cause", void 0), _(this, "code", void 0), this.code = n, this.cause = t && { error: t.error, error_description: t.error_description, message: t.message };
|
|
3233
|
-
}
|
|
3234
|
-
}, ya = class extends le {
|
|
3235
|
-
constructor(n, e) {
|
|
3236
|
-
super("token_by_code_error", n, e), this.name = "TokenByCodeError";
|
|
3237
|
-
}
|
|
3238
|
-
}, ga = class extends le {
|
|
3239
|
-
constructor(n, e) {
|
|
3240
|
-
super("token_by_client_credentials_error", n, e), this.name = "TokenByClientCredentialsError";
|
|
3241
|
-
}
|
|
3242
|
-
}, wa = class extends le {
|
|
3243
|
-
constructor(n, e) {
|
|
3244
|
-
super("token_by_refresh_token_error", n, e), this.name = "TokenByRefreshTokenError";
|
|
3245
|
-
}
|
|
3246
|
-
}, dn = class extends le {
|
|
3247
|
-
constructor(n, e) {
|
|
3248
|
-
super("token_for_connection_error", n, e), this.name = "TokenForConnectionErrorCode";
|
|
3249
|
-
}
|
|
3250
|
-
}, oe = class extends le {
|
|
3251
|
-
constructor(n, e) {
|
|
3252
|
-
super("token_exchange_error", n, e), this.name = "TokenExchangeError";
|
|
3253
|
-
}
|
|
3254
|
-
}, pe = class extends Error {
|
|
3255
|
-
constructor(n) {
|
|
3256
|
-
super(n), _(this, "code", "verify_logout_token_error"), this.name = "VerifyLogoutTokenError";
|
|
3257
|
-
}
|
|
3258
|
-
}, pn = class extends le {
|
|
3259
|
-
constructor(n) {
|
|
3260
|
-
super("backchannel_authentication_error", "There was an error when trying to use Client-Initiated Backchannel Authentication.", n), _(this, "code", "backchannel_authentication_error"), this.name = "BackchannelAuthenticationError";
|
|
3261
|
-
}
|
|
3262
|
-
}, va = class extends le {
|
|
3263
|
-
constructor(n) {
|
|
3264
|
-
super("build_authorization_url_error", "There was an error when trying to build the authorization URL.", n), this.name = "BuildAuthorizationUrlError";
|
|
3265
|
-
}
|
|
3266
|
-
}, ba = class extends le {
|
|
3267
|
-
constructor(n) {
|
|
3268
|
-
super("build_link_user_url_error", "There was an error when trying to build the Link User URL.", n), this.name = "BuildLinkUserUrlError";
|
|
3269
|
-
}
|
|
3270
|
-
}, _a = class extends le {
|
|
3271
|
-
constructor(n) {
|
|
3272
|
-
super("build_unlink_user_url_error", "There was an error when trying to build the Unlink User URL.", n), this.name = "BuildUnlinkUserUrlError";
|
|
3273
|
-
}
|
|
3274
|
-
}, ka = class extends Error {
|
|
3275
|
-
constructor() {
|
|
3276
|
-
super("The client secret or client assertion signing key must be provided."), _(this, "code", "missing_client_auth_error"), this.name = "MissingClientAuthError";
|
|
3277
|
-
}
|
|
3278
|
-
};
|
|
3279
|
-
function On(n) {
|
|
3280
|
-
return Object.entries(n).filter(((e) => {
|
|
3281
|
-
let [, t] = e;
|
|
3282
|
-
return t !== void 0;
|
|
3283
|
-
})).reduce(((e, t) => S(S({}, e), {}, { [t[0]]: t[1] })), {});
|
|
3284
|
-
}
|
|
3285
|
-
var Mt = class extends Error {
|
|
3286
|
-
constructor(n, e, t) {
|
|
3287
|
-
super(e), _(this, "cause", void 0), _(this, "code", void 0), this.code = n, this.cause = t && { error: t.error, error_description: t.error_description, message: t.message };
|
|
3288
|
-
}
|
|
3289
|
-
}, br = class extends Mt {
|
|
3290
|
-
constructor(n, e) {
|
|
3291
|
-
super("mfa_list_authenticators_error", n, e), this.name = "MfaListAuthenticatorsError";
|
|
3292
|
-
}
|
|
3293
|
-
}, _r = class extends Mt {
|
|
3294
|
-
constructor(n, e) {
|
|
3295
|
-
super("mfa_enrollment_error", n, e), this.name = "MfaEnrollmentError";
|
|
3296
|
-
}
|
|
3297
|
-
}, Sa = class extends Mt {
|
|
3298
|
-
constructor(n, e) {
|
|
3299
|
-
super("mfa_delete_authenticator_error", n, e), this.name = "MfaDeleteAuthenticatorError";
|
|
3300
|
-
}
|
|
3301
|
-
}, kr = class extends Mt {
|
|
3302
|
-
constructor(n, e) {
|
|
3303
|
-
super("mfa_challenge_error", n, e), this.name = "MfaChallengeError";
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
|
-
function Ea(n) {
|
|
3307
|
-
return { id: n.id, authenticatorType: n.authenticator_type, active: n.active, name: n.name, oobChannels: n.oob_channels, type: n.type };
|
|
3308
|
-
}
|
|
3309
|
-
var Aa = (Ae = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), class {
|
|
3310
|
-
constructor(n) {
|
|
3311
|
-
var e;
|
|
3312
|
-
L(this, Ae, void 0), L(this, St, void 0), L(this, Te, void 0), x(Ae, this, "https://".concat(n.domain)), x(St, this, n.clientId), x(Te, this, (e = n.customFetch) !== null && e !== void 0 ? e : function() {
|
|
3313
|
-
return fetch(...arguments);
|
|
3314
|
-
});
|
|
3315
|
-
}
|
|
3316
|
-
async listAuthenticators(n) {
|
|
3317
|
-
const e = "".concat(v(Ae, this), "/mfa/authenticators"), { mfaToken: t } = n, o = await v(Te, this).call(this, e, { method: "GET", headers: { Authorization: "Bearer ".concat(t), "Content-Type": "application/json" } });
|
|
3318
|
-
if (!o.ok) {
|
|
3319
|
-
const r = await o.json();
|
|
3320
|
-
throw new br(r.error_description || "Failed to list authenticators", r);
|
|
3321
|
-
}
|
|
3322
|
-
return (await o.json()).map(Ea);
|
|
3323
|
-
}
|
|
3324
|
-
async enrollAuthenticator(n) {
|
|
3325
|
-
const e = "".concat(v(Ae, this), "/mfa/associate"), { mfaToken: t } = n, o = lo(n, fa), r = { authenticator_types: o.authenticatorTypes };
|
|
3326
|
-
"oobChannels" in o && (r.oob_channels = o.oobChannels), "phoneNumber" in o && o.phoneNumber && (r.phone_number = o.phoneNumber), "email" in o && o.email && (r.email = o.email);
|
|
3327
|
-
const i = await v(Te, this).call(this, e, { method: "POST", headers: { Authorization: "Bearer ".concat(t), "Content-Type": "application/json" }, body: JSON.stringify(r) });
|
|
3328
|
-
if (!i.ok) {
|
|
3329
|
-
const a = await i.json();
|
|
3330
|
-
throw new _r(a.error_description || "Failed to enroll authenticator", a);
|
|
3331
|
-
}
|
|
3332
|
-
return (function(a) {
|
|
3333
|
-
if (a.authenticator_type === "otp") return { authenticatorType: "otp", secret: a.secret, barcodeUri: a.barcode_uri, recoveryCodes: a.recovery_codes, id: a.id };
|
|
3334
|
-
if (a.authenticator_type === "oob") return { authenticatorType: "oob", oobChannel: a.oob_channel, oobCode: a.oob_code, bindingMethod: a.binding_method, id: a.id };
|
|
3335
|
-
throw new Error("Unexpected authenticator type: ".concat(a.authenticator_type));
|
|
3336
|
-
})(await i.json());
|
|
3337
|
-
}
|
|
3338
|
-
async deleteAuthenticator(n) {
|
|
3339
|
-
const { authenticatorId: e, mfaToken: t } = n, o = "".concat(v(Ae, this), "/mfa/authenticators/").concat(encodeURIComponent(e)), r = await v(Te, this).call(this, o, { method: "DELETE", headers: { Authorization: "Bearer ".concat(t), "Content-Type": "application/json" } });
|
|
3340
|
-
if (!r.ok) {
|
|
3341
|
-
const i = await r.json();
|
|
3342
|
-
throw new Sa(i.error_description || "Failed to delete authenticator", i);
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
async challengeAuthenticator(n) {
|
|
3346
|
-
const e = "".concat(v(Ae, this), "/mfa/challenge"), { mfaToken: t } = n, o = lo(n, ma), r = { mfa_token: t, client_id: v(St, this), challenge_type: o.challengeType };
|
|
3347
|
-
o.authenticatorId && (r.authenticator_id = o.authenticatorId);
|
|
3348
|
-
const i = await v(Te, this).call(this, e, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(r) });
|
|
3349
|
-
if (!i.ok) {
|
|
3350
|
-
const a = await i.json();
|
|
3351
|
-
throw new kr(a.error_description || "Failed to challenge authenticator", a);
|
|
3352
|
-
}
|
|
3353
|
-
return (function(a) {
|
|
3354
|
-
const s = { challengeType: a.challenge_type };
|
|
3355
|
-
return a.oob_code !== void 0 && (s.oobCode = a.oob_code), a.binding_method !== void 0 && (s.bindingMethod = a.binding_method), s;
|
|
3356
|
-
})(await i.json());
|
|
3357
|
-
}
|
|
3358
|
-
}), Ie = class Sr {
|
|
3359
|
-
constructor(e, t, o, r, i, a, s) {
|
|
3360
|
-
_(this, "accessToken", void 0), _(this, "idToken", void 0), _(this, "refreshToken", void 0), _(this, "expiresAt", void 0), _(this, "scope", void 0), _(this, "claims", void 0), _(this, "authorizationDetails", void 0), _(this, "tokenType", void 0), _(this, "issuedTokenType", void 0), this.accessToken = e, this.idToken = o, this.refreshToken = r, this.expiresAt = t, this.scope = i, this.claims = a, this.authorizationDetails = s;
|
|
3361
|
-
}
|
|
3362
|
-
static fromTokenEndpointResponse(e) {
|
|
3363
|
-
const t = e.id_token ? e.claims() : void 0, o = new Sr(e.access_token, Math.floor(Date.now() / 1e3) + Number(e.expires_in), e.id_token, e.refresh_token, e.scope, t, e.authorization_details);
|
|
3364
|
-
return o.tokenType = e.token_type, o.issuedTokenType = e.issued_token_type, o;
|
|
3365
|
-
}
|
|
3366
|
-
}, xn = "openid profile email offline_access", Ta = Object.freeze(/* @__PURE__ */ new Set(["grant_type", "client_id", "client_secret", "client_assertion", "client_assertion_type", "subject_token", "subject_token_type", "requested_token_type", "actor_token", "actor_token_type", "audience", "aud", "resource", "resources", "resource_indicator", "scope", "connection", "login_hint", "organization", "assertion"]));
|
|
3367
|
-
function Er(n) {
|
|
3368
|
-
if (n == null) throw new oe("subject_token is required");
|
|
3369
|
-
if (typeof n != "string") throw new oe("subject_token must be a string");
|
|
3370
|
-
if (n.trim().length === 0) throw new oe("subject_token cannot be blank or whitespace");
|
|
3371
|
-
if (n !== n.trim()) throw new oe("subject_token must not include leading or trailing whitespace");
|
|
3372
|
-
if (/^bearer\s+/i.test(n)) throw new oe("subject_token must not include the 'Bearer ' prefix");
|
|
3373
|
-
}
|
|
3374
|
-
function Ar(n, e) {
|
|
3375
|
-
if (e) {
|
|
3376
|
-
for (const [t, o] of Object.entries(e)) if (!Ta.has(t)) if (Array.isArray(o)) {
|
|
3377
|
-
if (o.length > 20) throw new oe("Parameter '".concat(t, "' exceeds maximum array size of ").concat(20));
|
|
3378
|
-
o.forEach(((r) => {
|
|
3379
|
-
n.append(t, r);
|
|
3380
|
-
}));
|
|
3381
|
-
} else n.append(t, o);
|
|
3382
|
-
}
|
|
3383
|
-
}
|
|
3384
|
-
var Pa = (fe = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakSet(), class {
|
|
3385
|
-
constructor(n) {
|
|
3386
|
-
if ((function(e, t) {
|
|
3387
|
-
Vo(e, t), t.add(e);
|
|
3388
|
-
})(this, C), L(this, fe, void 0), L(this, ze, void 0), L(this, I, void 0), L(this, Ye, void 0), _(this, "mfa", void 0), x(I, this, n), n.useMtls && !n.customFetch) throw new Oo("mtls_without_custom_fetch_not_supported", "Using mTLS without a custom fetch implementation is not supported");
|
|
3389
|
-
this.mfa = new Aa({ domain: v(I, this).domain, clientId: v(I, this).clientId, customFetch: v(I, this).customFetch });
|
|
3390
|
-
}
|
|
3391
|
-
async buildAuthorizationUrl(n) {
|
|
3392
|
-
const { serverMetadata: e } = await j(C, this, G).call(this);
|
|
3393
|
-
if (n != null && n.pushedAuthorizationRequests && !e.pushed_authorization_request_endpoint) throw new Oo("par_not_supported_error", "The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");
|
|
3394
|
-
try {
|
|
3395
|
-
return await j(C, this, fn).call(this, n);
|
|
3396
|
-
} catch (t) {
|
|
3397
|
-
throw new va(t);
|
|
3398
|
-
}
|
|
3399
|
-
}
|
|
3400
|
-
async buildLinkUserUrl(n) {
|
|
3401
|
-
try {
|
|
3402
|
-
const e = await j(C, this, fn).call(this, { authorizationParams: S(S({}, n.authorizationParams), {}, { requested_connection: n.connection, requested_connection_scope: n.connectionScope, scope: "openid link_account offline_access", id_token_hint: n.idToken }) });
|
|
3403
|
-
return { linkUserUrl: e.authorizationUrl, codeVerifier: e.codeVerifier };
|
|
3404
|
-
} catch (e) {
|
|
3405
|
-
throw new ba(e);
|
|
3406
|
-
}
|
|
3407
|
-
}
|
|
3408
|
-
async buildUnlinkUserUrl(n) {
|
|
3409
|
-
try {
|
|
3410
|
-
const e = await j(C, this, fn).call(this, { authorizationParams: S(S({}, n.authorizationParams), {}, { requested_connection: n.connection, scope: "openid unlink_account", id_token_hint: n.idToken }) });
|
|
3411
|
-
return { unlinkUserUrl: e.authorizationUrl, codeVerifier: e.codeVerifier };
|
|
3412
|
-
} catch (e) {
|
|
3413
|
-
throw new _a(e);
|
|
3414
|
-
}
|
|
3415
|
-
}
|
|
3416
|
-
async backchannelAuthentication(n) {
|
|
3417
|
-
const { configuration: e, serverMetadata: t } = await j(C, this, G).call(this), o = On(S(S({}, v(I, this).authorizationParams), n == null ? void 0 : n.authorizationParams)), r = new URLSearchParams(S(S({ scope: xn }, o), {}, { client_id: v(I, this).clientId, binding_message: n.bindingMessage, login_hint: JSON.stringify({ format: "iss_sub", iss: t.issuer, sub: n.loginHint.sub }) }));
|
|
3418
|
-
n.requestedExpiry && r.append("requested_expiry", n.requestedExpiry.toString()), n.authorizationDetails && r.append("authorization_details", JSON.stringify(n.authorizationDetails));
|
|
3419
|
-
try {
|
|
3420
|
-
const i = await Eo(e, r), a = await fr(e, i);
|
|
3421
|
-
return Ie.fromTokenEndpointResponse(a);
|
|
3422
|
-
} catch (i) {
|
|
3423
|
-
throw new pn(i);
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
async initiateBackchannelAuthentication(n) {
|
|
3427
|
-
const { configuration: e, serverMetadata: t } = await j(C, this, G).call(this), o = On(S(S({}, v(I, this).authorizationParams), n == null ? void 0 : n.authorizationParams)), r = new URLSearchParams(S(S({ scope: xn }, o), {}, { client_id: v(I, this).clientId, binding_message: n.bindingMessage, login_hint: JSON.stringify({ format: "iss_sub", iss: t.issuer, sub: n.loginHint.sub }) }));
|
|
3428
|
-
n.requestedExpiry && r.append("requested_expiry", n.requestedExpiry.toString()), n.authorizationDetails && r.append("authorization_details", JSON.stringify(n.authorizationDetails));
|
|
3429
|
-
try {
|
|
3430
|
-
const i = await Eo(e, r);
|
|
3431
|
-
return { authReqId: i.auth_req_id, expiresIn: i.expires_in, interval: i.interval };
|
|
3432
|
-
} catch (i) {
|
|
3433
|
-
throw new pn(i);
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
async backchannelAuthenticationGrant(n) {
|
|
3437
|
-
let { authReqId: e } = n;
|
|
3438
|
-
const { configuration: t } = await j(C, this, G).call(this), o = new URLSearchParams({ auth_req_id: e });
|
|
3439
|
-
try {
|
|
3440
|
-
const r = await qn(t, "urn:openid:params:grant-type:ciba", o);
|
|
3441
|
-
return Ie.fromTokenEndpointResponse(r);
|
|
3442
|
-
} catch (r) {
|
|
3443
|
-
throw new pn(r);
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
async getTokenForConnection(n) {
|
|
3447
|
-
var e;
|
|
3448
|
-
if (n.refreshToken && n.accessToken) throw new dn("Either a refresh or access token should be specified, but not both.");
|
|
3449
|
-
const t = (e = n.accessToken) !== null && e !== void 0 ? e : n.refreshToken;
|
|
3450
|
-
if (!t) throw new dn("Either a refresh or access token must be specified.");
|
|
3451
|
-
try {
|
|
3452
|
-
return await this.exchangeToken({ connection: n.connection, subjectToken: t, subjectTokenType: n.accessToken ? "urn:ietf:params:oauth:token-type:access_token" : "urn:ietf:params:oauth:token-type:refresh_token", loginHint: n.loginHint });
|
|
3453
|
-
} catch (o) {
|
|
3454
|
-
throw o instanceof oe ? new dn(o.message, o.cause) : o;
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3457
|
-
async exchangeToken(n) {
|
|
3458
|
-
return "connection" in n ? j(C, this, Ra).call(this, n) : j(C, this, Ia).call(this, n);
|
|
3459
|
-
}
|
|
3460
|
-
async getTokenByCode(n, e) {
|
|
3461
|
-
const { configuration: t } = await j(C, this, G).call(this);
|
|
3462
|
-
try {
|
|
3463
|
-
const o = await mr(t, n, { pkceCodeVerifier: e.codeVerifier });
|
|
3464
|
-
return Ie.fromTokenEndpointResponse(o);
|
|
3465
|
-
} catch (o) {
|
|
3466
|
-
throw new ya("There was an error while trying to request a token.", o);
|
|
3467
|
-
}
|
|
3468
|
-
}
|
|
3469
|
-
async getTokenByRefreshToken(n) {
|
|
3470
|
-
const { configuration: e } = await j(C, this, G).call(this);
|
|
3471
|
-
try {
|
|
3472
|
-
const t = await yr(e, n.refreshToken);
|
|
3473
|
-
return Ie.fromTokenEndpointResponse(t);
|
|
3474
|
-
} catch (t) {
|
|
3475
|
-
throw new wa("The access token has expired and there was an error while trying to refresh it.", t);
|
|
3476
|
-
}
|
|
3477
|
-
}
|
|
3478
|
-
async getTokenByClientCredentials(n) {
|
|
3479
|
-
const { configuration: e } = await j(C, this, G).call(this);
|
|
3480
|
-
try {
|
|
3481
|
-
const t = new URLSearchParams({ audience: n.audience });
|
|
3482
|
-
n.organization && t.append("organization", n.organization);
|
|
3483
|
-
const o = await gr(e, t);
|
|
3484
|
-
return Ie.fromTokenEndpointResponse(o);
|
|
3485
|
-
} catch (t) {
|
|
3486
|
-
throw new ga("There was an error while trying to request a token.", t);
|
|
3487
|
-
}
|
|
3488
|
-
}
|
|
3489
|
-
async buildLogoutUrl(n) {
|
|
3490
|
-
const { configuration: e, serverMetadata: t } = await j(C, this, G).call(this);
|
|
3491
|
-
if (!t.end_session_endpoint) {
|
|
3492
|
-
const o = new URL("https://".concat(v(I, this).domain, "/v2/logout"));
|
|
3493
|
-
return o.searchParams.set("returnTo", n.returnTo), o.searchParams.set("client_id", v(I, this).clientId), o;
|
|
3494
|
-
}
|
|
3495
|
-
return (function(o, r) {
|
|
3496
|
-
ue(o);
|
|
3497
|
-
const { as: i, c: a, tlsOnly: s } = N(o), c = st(i, "end_session_endpoint", !1, s);
|
|
3498
|
-
(r = new URLSearchParams(r)).has("client_id") || r.set("client_id", a.client_id);
|
|
3499
|
-
for (const [u, l] of r.entries()) c.searchParams.append(u, l);
|
|
3500
|
-
return c;
|
|
3501
|
-
})(e, { post_logout_redirect_uri: n.returnTo });
|
|
3502
|
-
}
|
|
3503
|
-
async verifyLogoutToken(n) {
|
|
3504
|
-
const { serverMetadata: e } = await j(C, this, G).call(this);
|
|
3505
|
-
v(Ye, this) || x(Ye, this, (function(o, r) {
|
|
3506
|
-
const i = new pa(o, r), a = async (s, c) => i.getKey(s, c);
|
|
3507
|
-
return Object.defineProperties(a, { coolingDown: { get: () => i.coolingDown(), enumerable: !0, configurable: !1 }, fresh: { get: () => i.fresh(), enumerable: !0, configurable: !1 }, reload: { value: () => i.reload(), enumerable: !0, configurable: !1, writable: !1 }, reloading: { get: () => i.pendingFetch(), enumerable: !0, configurable: !1 }, jwks: { value: () => i.jwks(), enumerable: !0, configurable: !1, writable: !1 } }), a;
|
|
3508
|
-
})(new URL(e.jwks_uri), { [vr]: v(I, this).customFetch }));
|
|
3509
|
-
const { payload: t } = await la(n.logoutToken, v(Ye, this), { issuer: e.issuer, audience: v(I, this).clientId, algorithms: ["RS256"], requiredClaims: ["iat"] });
|
|
3510
|
-
if (!("sid" in t) && !("sub" in t)) throw new pe('either "sid" or "sub" (or both) claims must be present');
|
|
3511
|
-
if ("sid" in t && typeof t.sid != "string") throw new pe('"sid" claim must be a string');
|
|
3512
|
-
if ("sub" in t && typeof t.sub != "string") throw new pe('"sub" claim must be a string');
|
|
3513
|
-
if ("nonce" in t) throw new pe('"nonce" claim is prohibited');
|
|
3514
|
-
if (!("events" in t)) throw new pe('"events" claim is missing');
|
|
3515
|
-
if (typeof t.events != "object" || t.events === null) throw new pe('"events" claim must be an object');
|
|
3516
|
-
if (!("http://schemas.openid.net/event/backchannel-logout" in t.events)) throw new pe('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');
|
|
3517
|
-
if (typeof t.events["http://schemas.openid.net/event/backchannel-logout"] != "object") throw new pe('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');
|
|
3518
|
-
return { sid: t.sid, sub: t.sub };
|
|
3519
|
-
}
|
|
3520
|
-
});
|
|
3521
|
-
async function G() {
|
|
3522
|
-
if (v(fe, this) && v(ze, this)) return { configuration: v(fe, this), serverMetadata: v(ze, this) };
|
|
3523
|
-
const n = await j(C, this, Oa).call(this);
|
|
3524
|
-
return x(fe, this, await oa(new URL("https://".concat(v(I, this).domain)), v(I, this).clientId, { use_mtls_endpoint_aliases: v(I, this).useMtls }, n, { [ye]: v(I, this).customFetch })), x(ze, this, v(fe, this).serverMetadata()), v(fe, this)[ye] = v(I, this).customFetch || fetch, { configuration: v(fe, this), serverMetadata: v(ze, this) };
|
|
3525
|
-
}
|
|
3526
|
-
async function Ra(n) {
|
|
3527
|
-
var e, t;
|
|
3528
|
-
const { configuration: o } = await j(C, this, G).call(this);
|
|
3529
|
-
if ("audience" in n || "resource" in n) throw new oe("audience and resource parameters are not supported for Token Vault exchanges");
|
|
3530
|
-
Er(n.subjectToken);
|
|
3531
|
-
const r = new URLSearchParams({ connection: n.connection, subject_token: n.subjectToken, subject_token_type: (e = n.subjectTokenType) !== null && e !== void 0 ? e : "urn:ietf:params:oauth:token-type:access_token", requested_token_type: (t = n.requestedTokenType) !== null && t !== void 0 ? t : "http://auth0.com/oauth/token-type/federated-connection-access-token" });
|
|
3532
|
-
n.loginHint && r.append("login_hint", n.loginHint), n.scope && r.append("scope", n.scope), Ar(r, n.extra);
|
|
3533
|
-
try {
|
|
3534
|
-
const i = await qn(o, "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token", r);
|
|
3535
|
-
return Ie.fromTokenEndpointResponse(i);
|
|
3536
|
-
} catch (i) {
|
|
3537
|
-
throw new oe("Failed to exchange token for connection '".concat(n.connection, "'."), i);
|
|
3538
|
-
}
|
|
3539
|
-
}
|
|
3540
|
-
async function Ia(n) {
|
|
3541
|
-
const { configuration: e } = await j(C, this, G).call(this);
|
|
3542
|
-
Er(n.subjectToken);
|
|
3543
|
-
const t = new URLSearchParams({ subject_token_type: n.subjectTokenType, subject_token: n.subjectToken });
|
|
3544
|
-
n.audience && t.append("audience", n.audience), n.scope && t.append("scope", n.scope), n.requestedTokenType && t.append("requested_token_type", n.requestedTokenType), n.organization && t.append("organization", n.organization), Ar(t, n.extra);
|
|
3545
|
-
try {
|
|
3546
|
-
const o = await qn(e, "urn:ietf:params:oauth:grant-type:token-exchange", t);
|
|
3547
|
-
return Ie.fromTokenEndpointResponse(o);
|
|
3548
|
-
} catch (o) {
|
|
3549
|
-
throw new oe("Failed to exchange token of type '".concat(n.subjectTokenType, "'").concat(n.audience ? " for audience '".concat(n.audience, "'") : "", "."), o);
|
|
3550
|
-
}
|
|
3551
|
-
}
|
|
3552
|
-
async function Oa() {
|
|
3553
|
-
if (!v(I, this).clientSecret && !v(I, this).clientAssertionSigningKey && !v(I, this).useMtls) throw new ka();
|
|
3554
|
-
if (v(I, this).useMtls) return (e, t, o, r) => {
|
|
3555
|
-
o.set("client_id", t.client_id);
|
|
3556
|
-
};
|
|
3557
|
-
let n = v(I, this).clientAssertionSigningKey;
|
|
3558
|
-
return !n || n instanceof CryptoKey || (n = await (async function(e, t, o) {
|
|
3559
|
-
if (typeof e != "string" || e.indexOf("-----BEGIN PRIVATE KEY-----") !== 0) throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
3560
|
-
return Qi(e, t, o);
|
|
3561
|
-
})(n, v(I, this).clientAssertionSigningAlg || "RS256")), n ? (function(e, t) {
|
|
3562
|
-
return Ai(e);
|
|
3563
|
-
})(n) : hr(v(I, this).clientSecret);
|
|
3564
|
-
}
|
|
3565
|
-
async function fn(n) {
|
|
3566
|
-
const { configuration: e } = await j(C, this, G).call(this), t = na(), o = await ta(t), r = On(S(S({}, v(I, this).authorizationParams), n == null ? void 0 : n.authorizationParams)), i = new URLSearchParams(S(S({ scope: xn }, r), {}, { client_id: v(I, this).clientId, code_challenge: o, code_challenge_method: "S256" }));
|
|
3567
|
-
return { authorizationUrl: n != null && n.pushedAuthorizationRequests ? await wr(e, i) : await Rn(e, i), codeVerifier: t };
|
|
3568
|
-
}
|
|
3569
|
-
class be extends O {
|
|
3570
|
-
constructor(e, t) {
|
|
3571
|
-
super(e, t), Object.setPrototypeOf(this, be.prototype);
|
|
3572
|
-
}
|
|
3573
|
-
static fromPayload(e) {
|
|
3574
|
-
let { error: t, error_description: o } = e;
|
|
3575
|
-
return new be(t, o);
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
class Kt extends be {
|
|
3579
|
-
constructor(e, t) {
|
|
3580
|
-
super(e, t), Object.setPrototypeOf(this, Kt.prototype);
|
|
3581
|
-
}
|
|
3582
|
-
}
|
|
3583
|
-
class Bn extends be {
|
|
3584
|
-
constructor(e, t) {
|
|
3585
|
-
super(e, t), Object.setPrototypeOf(this, Bn.prototype);
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
class Xn extends be {
|
|
3589
|
-
constructor(e, t) {
|
|
3590
|
-
super(e, t), Object.setPrototypeOf(this, Xn.prototype);
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
class He extends be {
|
|
3594
|
-
constructor(e, t) {
|
|
3595
|
-
super(e, t), Object.setPrototypeOf(this, He.prototype);
|
|
3596
|
-
}
|
|
3597
|
-
}
|
|
3598
|
-
class Yn extends be {
|
|
3599
|
-
constructor(e, t) {
|
|
3600
|
-
super(e, t), Object.setPrototypeOf(this, Yn.prototype);
|
|
3601
|
-
}
|
|
3602
|
-
}
|
|
3603
|
-
class xa {
|
|
3604
|
-
constructor() {
|
|
3605
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 6e5;
|
|
3606
|
-
this.contexts = /* @__PURE__ */ new Map(), this.ttlMs = e;
|
|
3607
|
-
}
|
|
3608
|
-
set(e, t) {
|
|
3609
|
-
this.cleanup(), this.contexts.set(e, Object.assign(Object.assign({}, t), { createdAt: Date.now() }));
|
|
3610
|
-
}
|
|
3611
|
-
get(e) {
|
|
3612
|
-
const t = this.contexts.get(e);
|
|
3613
|
-
if (t) {
|
|
3614
|
-
if (!(Date.now() - t.createdAt > this.ttlMs)) return t;
|
|
3615
|
-
this.contexts.delete(e);
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
remove(e) {
|
|
3619
|
-
this.contexts.delete(e);
|
|
3620
|
-
}
|
|
3621
|
-
cleanup() {
|
|
3622
|
-
const e = Date.now();
|
|
3623
|
-
for (const [t, o] of this.contexts) e - o.createdAt > this.ttlMs && this.contexts.delete(t);
|
|
3624
|
-
}
|
|
3625
|
-
get size() {
|
|
3626
|
-
return this.contexts.size;
|
|
3627
|
-
}
|
|
3628
|
-
}
|
|
3629
|
-
class Ca {
|
|
3630
|
-
constructor(e, t) {
|
|
3631
|
-
this.authJsMfaClient = e, this.auth0Client = t, this.contextManager = new xa();
|
|
3632
|
-
}
|
|
3633
|
-
setMFAAuthDetails(e, t, o, r) {
|
|
3634
|
-
this.contextManager.set(e, { scope: t, audience: o, mfaRequirements: r });
|
|
3635
|
-
}
|
|
3636
|
-
async getAuthenticators(e) {
|
|
3637
|
-
var t, o;
|
|
3638
|
-
const r = this.contextManager.get(e);
|
|
3639
|
-
if (!(!((t = r == null ? void 0 : r.mfaRequirements) === null || t === void 0) && t.challenge) || r.mfaRequirements.challenge.length === 0) throw new Kt("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
3640
|
-
const i = r.mfaRequirements.challenge.map(((a) => a.type));
|
|
3641
|
-
try {
|
|
3642
|
-
return (await this.authJsMfaClient.listAuthenticators({ mfaToken: e })).filter(((a) => !!a.type && i.includes(a.type)));
|
|
3643
|
-
} catch (a) {
|
|
3644
|
-
throw a instanceof br ? new Kt((o = a.cause) === null || o === void 0 ? void 0 : o.error, a.message) : a;
|
|
3645
|
-
}
|
|
3646
|
-
}
|
|
3647
|
-
async enroll(e) {
|
|
3648
|
-
var t;
|
|
3649
|
-
const o = (function(r) {
|
|
3650
|
-
const i = fi[r.factorType];
|
|
3651
|
-
return Object.assign(Object.assign(Object.assign({ mfaToken: r.mfaToken, authenticatorTypes: i.authenticatorTypes }, i.oobChannels && { oobChannels: i.oobChannels }), "phoneNumber" in r && { phoneNumber: r.phoneNumber }), "email" in r && { email: r.email });
|
|
3652
|
-
})(e);
|
|
3653
|
-
try {
|
|
3654
|
-
return await this.authJsMfaClient.enrollAuthenticator(o);
|
|
3655
|
-
} catch (r) {
|
|
3656
|
-
throw r instanceof _r ? new Bn((t = r.cause) === null || t === void 0 ? void 0 : t.error, r.message) : r;
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
|
-
async challenge(e) {
|
|
3660
|
-
var t;
|
|
3661
|
-
try {
|
|
3662
|
-
const o = { challengeType: e.challengeType, mfaToken: e.mfaToken };
|
|
3663
|
-
return e.authenticatorId && (o.authenticatorId = e.authenticatorId), await this.authJsMfaClient.challengeAuthenticator(o);
|
|
3664
|
-
} catch (o) {
|
|
3665
|
-
throw o instanceof kr ? new Xn((t = o.cause) === null || t === void 0 ? void 0 : t.error, o.message) : o;
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
async getEnrollmentFactors(e) {
|
|
3669
|
-
const t = this.contextManager.get(e);
|
|
3670
|
-
if (!t || !t.mfaRequirements) throw new Yn("mfa_context_not_found", "MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");
|
|
3671
|
-
return t.mfaRequirements.enroll && t.mfaRequirements.enroll.length !== 0 ? t.mfaRequirements.enroll : [];
|
|
3672
|
-
}
|
|
3673
|
-
async verify(e) {
|
|
3674
|
-
const t = this.contextManager.get(e.mfaToken);
|
|
3675
|
-
if (!t) throw new He("mfa_context_not_found", "MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");
|
|
3676
|
-
const o = (function(a) {
|
|
3677
|
-
return "otp" in a && a.otp ? mi : "oobCode" in a && a.oobCode ? yi : "recoveryCode" in a && a.recoveryCode ? gi : void 0;
|
|
3678
|
-
})(e);
|
|
3679
|
-
if (!o) throw new He("invalid_request", "Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");
|
|
3680
|
-
const r = t.scope, i = t.audience;
|
|
3681
|
-
try {
|
|
3682
|
-
const a = await this.auth0Client._requestTokenForMfa({ grant_type: o, mfaToken: e.mfaToken, scope: r, audience: i, otp: e.otp, oob_code: e.oobCode, binding_code: e.bindingCode, recovery_code: e.recoveryCode });
|
|
3683
|
-
return this.contextManager.remove(e.mfaToken), a;
|
|
3684
|
-
} catch (a) {
|
|
3685
|
-
if (a instanceof Je) this.setMFAAuthDetails(a.mfa_token, r, i, a.mfa_requirements);
|
|
3686
|
-
else if (a instanceof He) throw new He(a.error, a.error_description);
|
|
3687
|
-
throw a;
|
|
3688
|
-
}
|
|
3689
|
-
}
|
|
3690
|
-
}
|
|
3691
|
-
class ja {
|
|
3692
|
-
constructor(e) {
|
|
3693
|
-
let t, o;
|
|
3694
|
-
if (this.userCache = new Wo().enclosedCache, this.defaultOptions = { authorizationParams: { scope: "openid profile email" }, useRefreshTokensFallback: !1, useFormData: !0 }, this.options = Object.assign(Object.assign(Object.assign({}, this.defaultOptions), e), { authorizationParams: Object.assign(Object.assign({}, this.defaultOptions.authorizationParams), e.authorizationParams) }), typeof window < "u" && (() => {
|
|
3695
|
-
if (!Rt()) throw new Error("For security reasons, `window.crypto` is required to run `auth0-spa-js`.");
|
|
3696
|
-
if (Rt().subtle === void 0) throw new Error(`
|
|
3697
|
-
auth0-spa-js must run on a secure origin. See https://github.com/auth0/auth0-spa-js/blob/main/FAQ.md#why-do-i-get-auth0-spa-js-must-run-on-a-secure-origin for more information.
|
|
3698
|
-
`);
|
|
3699
|
-
})(), this.lockManager = (Gt || (Gt = jr()), Gt), e.cache && e.cacheLocation && console.warn("Both `cache` and `cacheLocation` options have been specified in the Auth0Client configuration; ignoring `cacheLocation` and using `cache`."), e.cache) o = e.cache;
|
|
3700
|
-
else {
|
|
3701
|
-
if (t = e.cacheLocation || "memory", !ao(t)) throw new Error('Invalid cache location "'.concat(t, '"'));
|
|
3702
|
-
o = ao(t)();
|
|
3703
|
-
}
|
|
3704
|
-
var r;
|
|
3705
|
-
this.httpTimeoutMs = e.httpTimeoutInSeconds ? 1e3 * e.httpTimeoutInSeconds : 1e4, this.cookieStorage = e.legacySameSiteCookie === !1 ? Ne : ri, this.orgHintCookieName = (r = this.options.clientId, "auth0.".concat(r, ".organization_hint")), this.isAuthenticatedCookieName = ((u) => "auth0.".concat(u, ".is.authenticated"))(this.options.clientId), this.sessionCheckExpiryDays = e.sessionCheckExpiryDays || 1;
|
|
3706
|
-
const i = e.useCookiesForTransactions ? this.cookieStorage : ii;
|
|
3707
|
-
var a;
|
|
3708
|
-
this.scope = (function(u, l) {
|
|
3709
|
-
for (var f = arguments.length, h = new Array(f > 2 ? f - 2 : 0), d = 2; d < f; d++) h[d - 2] = arguments[d];
|
|
3710
|
-
if (typeof u != "object") return { default: Et(l, u, ...h) };
|
|
3711
|
-
let w = { default: Et(l, ...h) };
|
|
3712
|
-
return Object.keys(u).forEach(((m) => {
|
|
3713
|
-
const p = u[m];
|
|
3714
|
-
w[m] = Et(l, p, ...h);
|
|
3715
|
-
})), w;
|
|
3716
|
-
})(this.options.authorizationParams.scope, "openid", this.options.useRefreshTokens ? "offline_access" : ""), this.transactionManager = new Qr(i, this.options.clientId, this.options.cookieDomain), this.nowProvider = this.options.nowProvider || Co, this.cacheManager = new Yr(o, o.allKeys ? void 0 : new ci(o, this.options.clientId), this.nowProvider), this.dpop = this.options.useDpop ? new hi(this.options.clientId) : void 0, this.domainUrl = (a = this.options.domain, /^https?:\/\//.test(a) ? a : "https://".concat(a)), this.tokenIssuer = ((u, l) => u ? u.startsWith("https://") ? u : "https://".concat(u, "/") : "".concat(l, "/"))(this.options.issuer, this.domainUrl);
|
|
3717
|
-
const s = "".concat(this.domainUrl, "/me/"), c = this.createFetcher(Object.assign(Object.assign({}, this.options.useDpop && { dpopNonceId: "__auth0_my_account_api__" }), { getAccessToken: () => this.getTokenSilently({ authorizationParams: { scope: "create:me:connected_accounts", audience: s }, detailedResponse: !0 }) }));
|
|
3718
|
-
this.myAccountApi = new pi(c, s), this.authJsClient = new Pa({ domain: this.options.domain, clientId: this.options.clientId }), this.mfa = new Ca(this.authJsClient.mfa, this), typeof window < "u" && window.Worker && this.options.useRefreshTokens && t === "memory" && (this.options.workerUrl ? this.worker = new Worker(this.options.workerUrl) : this.worker = new si());
|
|
3719
|
-
}
|
|
3720
|
-
getConfiguration() {
|
|
3721
|
-
return Object.freeze({ domain: this.options.domain, clientId: this.options.clientId });
|
|
3722
|
-
}
|
|
3723
|
-
_url(e) {
|
|
3724
|
-
const t = this.options.auth0Client || xo, o = jo(t, !0), r = encodeURIComponent(btoa(JSON.stringify(o)));
|
|
3725
|
-
return "".concat(this.domainUrl).concat(e, "&auth0Client=").concat(r);
|
|
3726
|
-
}
|
|
3727
|
-
_authorizeUrl(e) {
|
|
3728
|
-
return this._url("/authorize?".concat(mn(e)));
|
|
3729
|
-
}
|
|
3730
|
-
async _verifyIdToken(e, t, o) {
|
|
3731
|
-
const r = await this.nowProvider();
|
|
3732
|
-
return ei({ iss: this.tokenIssuer, aud: this.options.clientId, id_token: e, nonce: t, organization: o, leeway: this.options.leeway, max_age: (i = this.options.authorizationParams.max_age, typeof i != "string" ? i : parseInt(i, 10) || void 0), now: r });
|
|
3733
|
-
var i;
|
|
3734
|
-
}
|
|
3735
|
-
_processOrgHint(e) {
|
|
3736
|
-
e ? this.cookieStorage.save(this.orgHintCookieName, e, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }) : this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain });
|
|
3737
|
-
}
|
|
3738
|
-
async _prepareAuthorizeUrl(e, t, o) {
|
|
3739
|
-
var r;
|
|
3740
|
-
const i = Jt(Ze()), a = Jt(Ze()), s = Ze(), c = await $n(s), u = to(c), l = await ((r = this.dpop) === null || r === void 0 ? void 0 : r.calculateThumbprint()), f = ((d, w, m, p, g, b, k, E, y) => Object.assign(Object.assign(Object.assign({ client_id: d.clientId }, d.authorizationParams), m), { scope: yt(w, m.scope, m.audience), response_type: "code", response_mode: E || "query", state: p, nonce: g, redirect_uri: k || d.authorizationParams.redirect_uri, code_challenge: b, code_challenge_method: "S256", dpop_jkt: y }))(this.options, this.scope, e, i, a, u, e.redirect_uri || this.options.authorizationParams.redirect_uri || o, t == null ? void 0 : t.response_mode, l), h = this._authorizeUrl(f);
|
|
3741
|
-
return { nonce: a, code_verifier: s, scope: f.scope, audience: f.audience || "default", redirect_uri: f.redirect_uri, state: i, url: h };
|
|
3742
|
-
}
|
|
3743
|
-
async loginWithPopup(e, t) {
|
|
3744
|
-
var o;
|
|
3745
|
-
if (e = e || {}, !(t = t || {}).popup && (t.popup = ((s) => {
|
|
3746
|
-
const c = window.screenX + (window.innerWidth - 400) / 2, u = window.screenY + (window.innerHeight - 600) / 2;
|
|
3747
|
-
return window.open(s, "auth0:authorize:popup", "left=".concat(c, ",top=").concat(u, ",width=").concat(400, ",height=").concat(600, ",resizable,scrollbars=yes,status=1"));
|
|
3748
|
-
})(""), !t.popup)) throw new Kn();
|
|
3749
|
-
const r = await this._prepareAuthorizeUrl(e.authorizationParams || {}, { response_mode: "web_message" }, window.location.origin);
|
|
3750
|
-
t.popup.location.href = r.url;
|
|
3751
|
-
const i = await ((s) => new Promise(((c, u) => {
|
|
3752
|
-
let l;
|
|
3753
|
-
const f = setInterval((() => {
|
|
3754
|
-
s.popup && s.popup.closed && (clearInterval(f), clearTimeout(h), window.removeEventListener("message", l, !1), u(new Ln(s.popup)));
|
|
3755
|
-
}), 1e3), h = setTimeout((() => {
|
|
3756
|
-
clearInterval(f), u(new Dn(s.popup)), window.removeEventListener("message", l, !1);
|
|
3757
|
-
}), 1e3 * (s.timeoutInSeconds || 60));
|
|
3758
|
-
l = function(d) {
|
|
3759
|
-
if (d.data && d.data.type === "authorization_response") {
|
|
3760
|
-
if (clearTimeout(h), clearInterval(f), window.removeEventListener("message", l, !1), s.closePopup !== !1 && s.popup.close(), d.data.response.error) return u(O.fromPayload(d.data.response));
|
|
3761
|
-
c(d.data.response);
|
|
3762
|
-
}
|
|
3763
|
-
}, window.addEventListener("message", l);
|
|
3764
|
-
})))(Object.assign(Object.assign({}, t), { timeoutInSeconds: t.timeoutInSeconds || this.options.authorizeTimeoutInSeconds || 60 }));
|
|
3765
|
-
if (r.state !== i.state) throw new O("state_mismatch", "Invalid state");
|
|
3766
|
-
const a = ((o = e.authorizationParams) === null || o === void 0 ? void 0 : o.organization) || this.options.authorizationParams.organization;
|
|
3767
|
-
await this._requestToken({ audience: r.audience, scope: r.scope, code_verifier: r.code_verifier, grant_type: "authorization_code", code: i.code, redirect_uri: r.redirect_uri }, { nonceIn: r.nonce, organization: a });
|
|
3768
|
-
}
|
|
3769
|
-
async getUser() {
|
|
3770
|
-
var e;
|
|
3771
|
-
const t = await this._getIdTokenFromCache();
|
|
3772
|
-
return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.user;
|
|
3773
|
-
}
|
|
3774
|
-
async getIdTokenClaims() {
|
|
3775
|
-
var e;
|
|
3776
|
-
const t = await this._getIdTokenFromCache();
|
|
3777
|
-
return (e = t == null ? void 0 : t.decodedToken) === null || e === void 0 ? void 0 : e.claims;
|
|
3778
|
-
}
|
|
3779
|
-
async loginWithRedirect() {
|
|
3780
|
-
var e;
|
|
3781
|
-
const t = so(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), { openUrl: o, fragment: r, appState: i } = t, a = X(t, ["openUrl", "fragment", "appState"]), s = ((e = a.authorizationParams) === null || e === void 0 ? void 0 : e.organization) || this.options.authorizationParams.organization, c = await this._prepareAuthorizeUrl(a.authorizationParams || {}), { url: u } = c, l = X(c, ["url"]);
|
|
3782
|
-
this.transactionManager.create(Object.assign(Object.assign(Object.assign({}, l), { appState: i, response_type: Re.Code }), s && { organization: s }));
|
|
3783
|
-
const f = r ? "".concat(u, "#").concat(r) : u;
|
|
3784
|
-
o ? await o(f) : window.location.assign(f);
|
|
3785
|
-
}
|
|
3786
|
-
async handleRedirectCallback() {
|
|
3787
|
-
const e = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.location.href).split("?").slice(1);
|
|
3788
|
-
if (e.length === 0) throw new Error("There are no query params available for parsing.");
|
|
3789
|
-
const t = this.transactionManager.get();
|
|
3790
|
-
if (!t) throw new O("missing_transaction", "Invalid state");
|
|
3791
|
-
this.transactionManager.remove();
|
|
3792
|
-
const o = ((r) => {
|
|
3793
|
-
r.indexOf("#") > -1 && (r = r.substring(0, r.indexOf("#")));
|
|
3794
|
-
const i = new URLSearchParams(r);
|
|
3795
|
-
return { state: i.get("state"), code: i.get("code") || void 0, connect_code: i.get("connect_code") || void 0, error: i.get("error") || void 0, error_description: i.get("error_description") || void 0 };
|
|
3796
|
-
})(e.join(""));
|
|
3797
|
-
return t.response_type === Re.ConnectCode ? this._handleConnectAccountRedirectCallback(o, t) : this._handleLoginRedirectCallback(o, t);
|
|
3798
|
-
}
|
|
3799
|
-
async _handleLoginRedirectCallback(e, t) {
|
|
3800
|
-
const { code: o, state: r, error: i, error_description: a } = e;
|
|
3801
|
-
if (i) throw new Cn(i, a || i, r, t.appState);
|
|
3802
|
-
if (!t.code_verifier || t.state && t.state !== r) throw new O("state_mismatch", "Invalid state");
|
|
3803
|
-
const s = t.organization, c = t.nonce, u = t.redirect_uri;
|
|
3804
|
-
return await this._requestToken(Object.assign({ audience: t.audience, scope: t.scope, code_verifier: t.code_verifier, grant_type: "authorization_code", code: o }, u ? { redirect_uri: u } : {}), { nonceIn: c, organization: s }), { appState: t.appState, response_type: Re.Code };
|
|
3805
|
-
}
|
|
3806
|
-
async _handleConnectAccountRedirectCallback(e, t) {
|
|
3807
|
-
const { connect_code: o, state: r, error: i, error_description: a } = e;
|
|
3808
|
-
if (i) throw new jn(i, a || i, t.connection, r, t.appState);
|
|
3809
|
-
if (!o) throw new O("missing_connect_code", "Missing connect code");
|
|
3810
|
-
if (!(t.code_verifier && t.state && t.auth_session && t.redirect_uri && t.state === r)) throw new O("state_mismatch", "Invalid state");
|
|
3811
|
-
const s = await this.myAccountApi.completeAccount({ auth_session: t.auth_session, connect_code: o, redirect_uri: t.redirect_uri, code_verifier: t.code_verifier });
|
|
3812
|
-
return Object.assign(Object.assign({}, s), { appState: t.appState, response_type: Re.ConnectCode });
|
|
3813
|
-
}
|
|
3814
|
-
async checkSession(e) {
|
|
3815
|
-
if (!this.cookieStorage.get(this.isAuthenticatedCookieName)) {
|
|
3816
|
-
if (!this.cookieStorage.get("auth0.is.authenticated")) return;
|
|
3817
|
-
this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove("auth0.is.authenticated");
|
|
3818
|
-
}
|
|
3819
|
-
try {
|
|
3820
|
-
await this.getTokenSilently(e);
|
|
3821
|
-
} catch {
|
|
3822
|
-
}
|
|
3823
|
-
}
|
|
3824
|
-
async getTokenSilently() {
|
|
3825
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3826
|
-
var t, o;
|
|
3827
|
-
const r = Object.assign(Object.assign({ cacheMode: "on" }, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: yt(this.scope, (t = e.authorizationParams) === null || t === void 0 ? void 0 : t.scope, ((o = e.authorizationParams) === null || o === void 0 ? void 0 : o.audience) || this.options.authorizationParams.audience) }) }), i = await ((a, s) => {
|
|
3828
|
-
let c = qt[s];
|
|
3829
|
-
return c || (c = a().finally((() => {
|
|
3830
|
-
delete qt[s], c = null;
|
|
3831
|
-
})), qt[s] = c), c;
|
|
3832
|
-
})((() => this._getTokenSilently(r)), "".concat(this.options.clientId, "::").concat(r.authorizationParams.audience, "::").concat(r.authorizationParams.scope));
|
|
3833
|
-
return e.detailedResponse ? i : i == null ? void 0 : i.access_token;
|
|
3834
|
-
}
|
|
3835
|
-
async _getTokenSilently(e) {
|
|
3836
|
-
const { cacheMode: t } = e, o = X(e, ["cacheMode"]);
|
|
3837
|
-
if (t !== "off") {
|
|
3838
|
-
const s = await this._getEntryFromCache({ scope: o.authorizationParams.scope, audience: o.authorizationParams.audience || "default", clientId: this.options.clientId, cacheMode: t });
|
|
3839
|
-
if (s) return s;
|
|
3840
|
-
}
|
|
3841
|
-
if (t === "cache-only") return;
|
|
3842
|
-
const r = (i = this.options.clientId, a = o.authorizationParams.audience || "default", "".concat("auth0.lock.getTokenSilently", ".").concat(i, ".").concat(a));
|
|
3843
|
-
var i, a;
|
|
3844
|
-
try {
|
|
3845
|
-
return await this.lockManager.runWithLock(r, 5e3, (async () => {
|
|
3846
|
-
if (t !== "off") {
|
|
3847
|
-
const d = await this._getEntryFromCache({ scope: o.authorizationParams.scope, audience: o.authorizationParams.audience || "default", clientId: this.options.clientId });
|
|
3848
|
-
if (d) return d;
|
|
3849
|
-
}
|
|
3850
|
-
const s = this.options.useRefreshTokens ? await this._getTokenUsingRefreshToken(o) : await this._getTokenFromIFrame(o), { id_token: c, token_type: u, access_token: l, oauthTokenScope: f, expires_in: h } = s;
|
|
3851
|
-
return Object.assign(Object.assign({ id_token: c, token_type: u, access_token: l }, f ? { scope: f } : null), { expires_in: h });
|
|
3852
|
-
}));
|
|
3853
|
-
} catch (s) {
|
|
3854
|
-
if (this._isInteractiveError(s) && this.options.interactiveErrorHandler === "popup") return await this._handleInteractiveErrorWithPopup(o);
|
|
3855
|
-
throw s;
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
_isInteractiveError(e) {
|
|
3859
|
-
return e instanceof Je || e instanceof O && this._isIframeMfaError(e);
|
|
3860
|
-
}
|
|
3861
|
-
_isIframeMfaError(e) {
|
|
3862
|
-
return e.error === "login_required" && e.error_description === "Multifactor authentication required";
|
|
3863
|
-
}
|
|
3864
|
-
async _handleInteractiveErrorWithPopup(e) {
|
|
3865
|
-
try {
|
|
3866
|
-
await this.loginWithPopup({ authorizationParams: e.authorizationParams });
|
|
3867
|
-
const t = await this._getEntryFromCache({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId });
|
|
3868
|
-
if (!t) throw new O("interactive_handler_cache_miss", "Token not found in cache after interactive authentication");
|
|
3869
|
-
return t;
|
|
3870
|
-
} catch (t) {
|
|
3871
|
-
throw t;
|
|
3872
|
-
}
|
|
3873
|
-
}
|
|
3874
|
-
async getTokenWithPopup() {
|
|
3875
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
3876
|
-
var o, r;
|
|
3877
|
-
const i = Object.assign(Object.assign({}, e), { authorizationParams: Object.assign(Object.assign(Object.assign({}, this.options.authorizationParams), e.authorizationParams), { scope: yt(this.scope, (o = e.authorizationParams) === null || o === void 0 ? void 0 : o.scope, ((r = e.authorizationParams) === null || r === void 0 ? void 0 : r.audience) || this.options.authorizationParams.audience) }) });
|
|
3878
|
-
return t = Object.assign(Object.assign({}, Tr), t), await this.loginWithPopup(i, t), (await this.cacheManager.get(new Z({ scope: i.authorizationParams.scope, audience: i.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt)).access_token;
|
|
3879
|
-
}
|
|
3880
|
-
async isAuthenticated() {
|
|
3881
|
-
return !!await this.getUser();
|
|
3882
|
-
}
|
|
3883
|
-
_buildLogoutUrl(e) {
|
|
3884
|
-
e.clientId !== null ? e.clientId = e.clientId || this.options.clientId : delete e.clientId;
|
|
3885
|
-
const t = e.logoutParams || {}, { federated: o } = t, r = X(t, ["federated"]), i = o ? "&federated" : "";
|
|
3886
|
-
return this._url("/v2/logout?".concat(mn(Object.assign({ clientId: e.clientId }, r)))) + i;
|
|
3887
|
-
}
|
|
3888
|
-
async logout() {
|
|
3889
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3890
|
-
var t;
|
|
3891
|
-
const o = so(e), { openUrl: r } = o, i = X(o, ["openUrl"]);
|
|
3892
|
-
e.clientId === null ? await this.cacheManager.clear() : await this.cacheManager.clear(e.clientId || this.options.clientId), this.cookieStorage.remove(this.orgHintCookieName, { cookieDomain: this.options.cookieDomain }), this.cookieStorage.remove(this.isAuthenticatedCookieName, { cookieDomain: this.options.cookieDomain }), this.userCache.remove("@@user@@"), await ((t = this.dpop) === null || t === void 0 ? void 0 : t.clear());
|
|
3893
|
-
const a = this._buildLogoutUrl(i);
|
|
3894
|
-
r ? await r(a) : r !== !1 && window.location.assign(a);
|
|
3895
|
-
}
|
|
3896
|
-
async _getTokenFromIFrame(e) {
|
|
3897
|
-
const t = (o = this.options.clientId, "".concat("auth0.lock.getTokenFromIFrame", ".").concat(o));
|
|
3898
|
-
var o;
|
|
3899
|
-
try {
|
|
3900
|
-
return await this.lockManager.runWithLock(t, 5e3, (async () => {
|
|
3901
|
-
const r = Object.assign(Object.assign({}, e.authorizationParams), { prompt: "none" }), i = this.cookieStorage.get(this.orgHintCookieName);
|
|
3902
|
-
i && !r.organization && (r.organization = i);
|
|
3903
|
-
const { url: a, state: s, nonce: c, code_verifier: u, redirect_uri: l, scope: f, audience: h } = await this._prepareAuthorizeUrl(r, { response_mode: "web_message" }, window.location.origin);
|
|
3904
|
-
if (window.crossOriginIsolated) throw new O("login_required", "The application is running in a Cross-Origin Isolated context, silently retrieving a token without refresh token is not possible.");
|
|
3905
|
-
const d = e.timeoutInSeconds || this.options.authorizeTimeoutInSeconds;
|
|
3906
|
-
let w;
|
|
3907
|
-
try {
|
|
3908
|
-
w = new URL(this.domainUrl).origin;
|
|
3909
|
-
} catch {
|
|
3910
|
-
w = this.domainUrl;
|
|
3911
|
-
}
|
|
3912
|
-
const m = await (function(g, b) {
|
|
3913
|
-
let k = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 60;
|
|
3914
|
-
return new Promise(((E, y) => {
|
|
3915
|
-
const P = window.document.createElement("iframe");
|
|
3916
|
-
P.setAttribute("width", "0"), P.setAttribute("height", "0"), P.style.display = "none";
|
|
3917
|
-
const J = () => {
|
|
3918
|
-
window.document.body.contains(P) && (window.document.body.removeChild(P), window.removeEventListener("message", U, !1));
|
|
3919
|
-
};
|
|
3920
|
-
let U;
|
|
3921
|
-
const he = setTimeout((() => {
|
|
3922
|
-
y(new Fe()), J();
|
|
3923
|
-
}), 1e3 * k);
|
|
3924
|
-
U = function(M) {
|
|
3925
|
-
if (M.origin != b || !M.data || M.data.type !== "authorization_response") return;
|
|
3926
|
-
const De = M.source;
|
|
3927
|
-
De && De.close(), M.data.response.error ? y(O.fromPayload(M.data.response)) : E(M.data.response), clearTimeout(he), window.removeEventListener("message", U, !1), setTimeout(J, 2e3);
|
|
3928
|
-
}, window.addEventListener("message", U, !1), window.document.body.appendChild(P), P.setAttribute("src", g);
|
|
3929
|
-
}));
|
|
3930
|
-
})(a, w, d);
|
|
3931
|
-
if (s !== m.state) throw new O("state_mismatch", "Invalid state");
|
|
3932
|
-
const p = await this._requestToken(Object.assign(Object.assign({}, e.authorizationParams), { code_verifier: u, code: m.code, grant_type: "authorization_code", redirect_uri: l, timeout: e.authorizationParams.timeout || this.httpTimeoutMs }), { nonceIn: c, organization: r.organization });
|
|
3933
|
-
return Object.assign(Object.assign({}, p), { scope: f, oauthTokenScope: p.scope, audience: h });
|
|
3934
|
-
}));
|
|
3935
|
-
} catch (r) {
|
|
3936
|
-
throw r.error === "login_required" && (r instanceof O && this._isIframeMfaError(r) && this.options.interactiveErrorHandler === "popup" || this.logout({ openUrl: !1 })), r;
|
|
3937
|
-
}
|
|
3938
|
-
}
|
|
3939
|
-
async _getTokenUsingRefreshToken(e) {
|
|
3940
|
-
var t, o;
|
|
3941
|
-
const r = await this.cacheManager.get(new Z({ scope: e.authorizationParams.scope, audience: e.authorizationParams.audience || "default", clientId: this.options.clientId }), void 0, this.options.useMrrt);
|
|
3942
|
-
if (!(r && r.refresh_token || this.worker)) {
|
|
3943
|
-
if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
|
|
3944
|
-
throw new Ut(e.authorizationParams.audience || "default", e.authorizationParams.scope);
|
|
3945
|
-
}
|
|
3946
|
-
const i = e.authorizationParams.redirect_uri || this.options.authorizationParams.redirect_uri || window.location.origin, a = typeof e.timeoutInSeconds == "number" ? 1e3 * e.timeoutInSeconds : null, s = ((h, d, w, m) => {
|
|
3947
|
-
var p;
|
|
3948
|
-
if (h && w && m) {
|
|
3949
|
-
if (d.audience !== w) return d.scope;
|
|
3950
|
-
const g = m.split(" "), b = ((p = d.scope) === null || p === void 0 ? void 0 : p.split(" ")) || [], k = b.every(((E) => g.includes(E)));
|
|
3951
|
-
return g.length >= b.length && k ? m : d.scope;
|
|
3952
|
-
}
|
|
3953
|
-
return d.scope;
|
|
3954
|
-
})(this.options.useMrrt, e.authorizationParams, r == null ? void 0 : r.audience, r == null ? void 0 : r.scope);
|
|
3955
|
-
try {
|
|
3956
|
-
const h = await this._requestToken(Object.assign(Object.assign(Object.assign({}, e.authorizationParams), { grant_type: "refresh_token", refresh_token: r && r.refresh_token, redirect_uri: i }), a && { timeout: a }), { scopesToRequest: s });
|
|
3957
|
-
if (h.refresh_token && (r != null && r.refresh_token) && await this.cacheManager.updateEntry(r.refresh_token, h.refresh_token), this.options.useMrrt && (c = r == null ? void 0 : r.audience, u = r == null ? void 0 : r.scope, l = e.authorizationParams.audience, f = e.authorizationParams.scope, (c !== l || !co(f, u)) && !co(s, h.scope))) {
|
|
3958
|
-
if (this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
|
|
3959
|
-
await this.cacheManager.remove(this.options.clientId, e.authorizationParams.audience, e.authorizationParams.scope);
|
|
3960
|
-
const d = ((w, m) => {
|
|
3961
|
-
const p = (w == null ? void 0 : w.split(" ")) || [], g = (m == null ? void 0 : m.split(" ")) || [];
|
|
3962
|
-
return p.filter(((b) => g.indexOf(b) == -1)).join(",");
|
|
3963
|
-
})(s, h.scope);
|
|
3964
|
-
throw new Un(e.authorizationParams.audience || "default", d);
|
|
3965
|
-
}
|
|
3966
|
-
return Object.assign(Object.assign({}, h), { scope: e.authorizationParams.scope, oauthTokenScope: h.scope, audience: e.authorizationParams.audience || "default" });
|
|
3967
|
-
} catch (h) {
|
|
3968
|
-
if (h.message) {
|
|
3969
|
-
if (h.message.includes("user is blocked")) throw await this.logout({ openUrl: !1 }), h;
|
|
3970
|
-
if ((h.message.includes("Missing Refresh Token") || h.message.includes("invalid refresh token")) && this.options.useRefreshTokensFallback) return await this._getTokenFromIFrame(e);
|
|
3971
|
-
}
|
|
3972
|
-
throw h instanceof Je && this.mfa.setMFAAuthDetails(h.mfa_token, (t = e.authorizationParams) === null || t === void 0 ? void 0 : t.scope, (o = e.authorizationParams) === null || o === void 0 ? void 0 : o.audience, h.mfa_requirements), h;
|
|
3973
|
-
}
|
|
3974
|
-
var c, u, l, f;
|
|
3975
|
-
}
|
|
3976
|
-
async _saveEntryInCache(e) {
|
|
3977
|
-
const { id_token: t, decodedToken: o } = e, r = X(e, ["id_token", "decodedToken"]);
|
|
3978
|
-
this.userCache.set("@@user@@", { id_token: t, decodedToken: o }), await this.cacheManager.setIdToken(this.options.clientId, e.id_token, e.decodedToken), await this.cacheManager.set(r);
|
|
3979
|
-
}
|
|
3980
|
-
async _getIdTokenFromCache() {
|
|
3981
|
-
const e = this.options.authorizationParams.audience || "default", t = this.scope[e], o = await this.cacheManager.getIdToken(new Z({ clientId: this.options.clientId, audience: e, scope: t })), r = this.userCache.get("@@user@@");
|
|
3982
|
-
return o && o.id_token === (r == null ? void 0 : r.id_token) ? r : (this.userCache.set("@@user@@", o), o);
|
|
3983
|
-
}
|
|
3984
|
-
async _getEntryFromCache(e) {
|
|
3985
|
-
let { scope: t, audience: o, clientId: r, cacheMode: i } = e;
|
|
3986
|
-
const a = await this.cacheManager.get(new Z({ scope: t, audience: o, clientId: r }), 60, this.options.useMrrt, i);
|
|
3987
|
-
if (a && a.access_token) {
|
|
3988
|
-
const { token_type: s, access_token: c, oauthTokenScope: u, expires_in: l } = a, f = await this._getIdTokenFromCache();
|
|
3989
|
-
return f && Object.assign(Object.assign({ id_token: f.id_token, token_type: s || "Bearer", access_token: c }, u ? { scope: u } : null), { expires_in: l });
|
|
3990
|
-
}
|
|
3991
|
-
}
|
|
3992
|
-
async _requestToken(e, t) {
|
|
3993
|
-
var o, r;
|
|
3994
|
-
const { nonceIn: i, organization: a, scopesToRequest: s } = t || {}, c = await qr(Object.assign(Object.assign({ baseUrl: this.domainUrl, client_id: this.options.clientId, auth0Client: this.options.auth0Client, useFormData: this.options.useFormData, timeout: this.httpTimeoutMs, useMrrt: this.options.useMrrt, dpop: this.dpop }, e), { scope: s || e.scope }), this.worker), u = await this._verifyIdToken(c.id_token, i, a);
|
|
3995
|
-
if (e.grant_type === "authorization_code") {
|
|
3996
|
-
const l = await this._getIdTokenFromCache();
|
|
3997
|
-
!((r = (o = l == null ? void 0 : l.decodedToken) === null || o === void 0 ? void 0 : o.claims) === null || r === void 0) && r.sub && l.decodedToken.claims.sub !== u.claims.sub && (await this.cacheManager.clear(this.options.clientId), this.userCache.remove("@@user@@"));
|
|
3998
|
-
}
|
|
3999
|
-
return await this._saveEntryInCache(Object.assign(Object.assign(Object.assign(Object.assign({}, c), { decodedToken: u, scope: e.scope, audience: e.audience || "default" }), c.scope ? { oauthTokenScope: c.scope } : null), { client_id: this.options.clientId })), this.cookieStorage.save(this.isAuthenticatedCookieName, !0, { daysUntilExpire: this.sessionCheckExpiryDays, cookieDomain: this.options.cookieDomain }), this._processOrgHint(a || u.claims.org_id), Object.assign(Object.assign({}, c), { decodedToken: u });
|
|
4000
|
-
}
|
|
4001
|
-
async loginWithCustomTokenExchange(e) {
|
|
4002
|
-
return this._requestToken(Object.assign(Object.assign({}, e), { grant_type: "urn:ietf:params:oauth:grant-type:token-exchange", subject_token: e.subject_token, subject_token_type: e.subject_token_type, scope: yt(this.scope, e.scope, e.audience || this.options.authorizationParams.audience), audience: e.audience || this.options.authorizationParams.audience, organization: e.organization || this.options.authorizationParams.organization }));
|
|
4003
|
-
}
|
|
4004
|
-
async exchangeToken(e) {
|
|
4005
|
-
return this.loginWithCustomTokenExchange(e);
|
|
4006
|
-
}
|
|
4007
|
-
_assertDpop(e) {
|
|
4008
|
-
if (!e) throw new Error("`useDpop` option must be enabled before using DPoP.");
|
|
4009
|
-
}
|
|
4010
|
-
getDpopNonce(e) {
|
|
4011
|
-
return this._assertDpop(this.dpop), this.dpop.getNonce(e);
|
|
4012
|
-
}
|
|
4013
|
-
setDpopNonce(e, t) {
|
|
4014
|
-
return this._assertDpop(this.dpop), this.dpop.setNonce(e, t);
|
|
4015
|
-
}
|
|
4016
|
-
generateDpopProof(e) {
|
|
4017
|
-
return this._assertDpop(this.dpop), this.dpop.generateProof(e);
|
|
4018
|
-
}
|
|
4019
|
-
createFetcher() {
|
|
4020
|
-
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
4021
|
-
return new di(e, { isDpopEnabled: () => !!this.options.useDpop, getAccessToken: (t) => {
|
|
4022
|
-
var o;
|
|
4023
|
-
return this.getTokenSilently({ authorizationParams: { scope: (o = t == null ? void 0 : t.scope) === null || o === void 0 ? void 0 : o.join(" "), audience: t == null ? void 0 : t.audience }, detailedResponse: !0 });
|
|
4024
|
-
}, getDpopNonce: () => this.getDpopNonce(e.dpopNonceId), setDpopNonce: (t) => this.setDpopNonce(t, e.dpopNonceId), generateDpopProof: (t) => this.generateDpopProof(t) });
|
|
4025
|
-
}
|
|
4026
|
-
async connectAccountWithRedirect(e) {
|
|
4027
|
-
const { openUrl: t, appState: o, connection: r, scopes: i, authorization_params: a, redirectUri: s = this.options.authorizationParams.redirect_uri || window.location.origin } = e;
|
|
4028
|
-
if (!r) throw new Error("connection is required");
|
|
4029
|
-
const c = Jt(Ze()), u = Ze(), l = await $n(u), f = to(l), { connect_uri: h, connect_params: d, auth_session: w } = await this.myAccountApi.connectAccount({ connection: r, scopes: i, redirect_uri: s, state: c, code_challenge: f, code_challenge_method: "S256", authorization_params: a });
|
|
4030
|
-
this.transactionManager.create({ state: c, code_verifier: u, auth_session: w, redirect_uri: s, appState: o, connection: r, response_type: Re.ConnectCode });
|
|
4031
|
-
const m = new URL(h);
|
|
4032
|
-
m.searchParams.set("ticket", d.ticket), t ? await t(m.toString()) : window.location.assign(m);
|
|
4033
|
-
}
|
|
4034
|
-
async _requestTokenForMfa(e, t) {
|
|
4035
|
-
const { mfaToken: o } = e, r = X(e, ["mfaToken"]);
|
|
4036
|
-
return this._requestToken(Object.assign(Object.assign({}, r), { mfa_token: o }), t);
|
|
4037
|
-
}
|
|
4038
|
-
}
|
|
4039
|
-
export {
|
|
4040
|
-
ja as Auth0Client,
|
|
4041
|
-
Cn as AuthenticationError,
|
|
4042
|
-
Z as CacheKey,
|
|
4043
|
-
jn as ConnectError,
|
|
4044
|
-
O as GenericError,
|
|
4045
|
-
Wo as InMemoryCache,
|
|
4046
|
-
Xr as LocalStorageCache,
|
|
4047
|
-
Ca as MfaApiClient,
|
|
4048
|
-
Xn as MfaChallengeError,
|
|
4049
|
-
Bn as MfaEnrollmentError,
|
|
4050
|
-
Yn as MfaEnrollmentFactorsError,
|
|
4051
|
-
be as MfaError,
|
|
4052
|
-
Kt as MfaListAuthenticatorsError,
|
|
4053
|
-
Je as MfaRequiredError,
|
|
4054
|
-
He as MfaVerifyError,
|
|
4055
|
-
Ut as MissingRefreshTokenError,
|
|
4056
|
-
It as MyAccountApiError,
|
|
4057
|
-
Ln as PopupCancelledError,
|
|
4058
|
-
Kn as PopupOpenError,
|
|
4059
|
-
Dn as PopupTimeoutError,
|
|
4060
|
-
Re as ResponseType,
|
|
4061
|
-
Fe as TimeoutError,
|
|
4062
|
-
Nt as UseDpopNonceError
|
|
4063
|
-
};
|
|
4064
|
-
//# sourceMappingURL=auth0-spa-js.production.esm-DNao6_S5.js.map
|