@versini/auth-provider 4.3.0 → 4.4.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/dist/index.js +577 -476
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as We } from "react/jsx-runtime";
|
|
2
2
|
import * as D from "react";
|
|
3
|
-
import { createContext as
|
|
3
|
+
import { createContext as Je, useState as xe, useCallback as je, useEffect as Me, useContext as Ve } from "react";
|
|
4
4
|
/*!
|
|
5
|
-
@versini/auth-provider v4.
|
|
5
|
+
@versini/auth-provider v4.4.0
|
|
6
6
|
© 2024 gizmette.com
|
|
7
7
|
*/
|
|
8
8
|
try {
|
|
9
9
|
window.__VERSINI_AUTH_CLIENT__ || (window.__VERSINI_AUTH_CLIENT__ = {
|
|
10
|
-
version: "4.
|
|
11
|
-
buildTime: "06/
|
|
10
|
+
version: "4.4.0",
|
|
11
|
+
buildTime: "06/29/2024 12:23 PM EDT",
|
|
12
12
|
homepage: "https://github.com/aversini/auth-client",
|
|
13
13
|
license: "MIT"
|
|
14
14
|
});
|
|
15
15
|
} catch {
|
|
16
16
|
}
|
|
17
17
|
/*!
|
|
18
|
-
@versini/auth-common v2.
|
|
18
|
+
@versini/auth-common v2.10.0
|
|
19
19
|
© 2024 gizmette.com
|
|
20
20
|
*/
|
|
21
21
|
try {
|
|
22
22
|
window.__VERSINI_AUTH_COMMON__ || (window.__VERSINI_AUTH_COMMON__ = {
|
|
23
|
-
version: "2.
|
|
24
|
-
buildTime: "06/
|
|
23
|
+
version: "2.10.0",
|
|
24
|
+
buildTime: "06/29/2024 12:23 PM EDT",
|
|
25
25
|
homepage: "https://github.com/aversini/auth-client",
|
|
26
26
|
license: "MIT"
|
|
27
27
|
});
|
|
28
28
|
} catch {
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const B = {
|
|
31
31
|
ID_TOKEN: "id_token",
|
|
32
32
|
ACCESS_TOKEN: "token",
|
|
33
33
|
ID_AND_ACCESS_TOKEN: "id_token token",
|
|
34
34
|
CODE: "code",
|
|
35
35
|
REFRESH_TOKEN: "refresh_token"
|
|
36
|
-
},
|
|
36
|
+
}, Ye = {
|
|
37
37
|
CLIENT_ID: "X-Auth-ClientId"
|
|
38
|
-
},
|
|
38
|
+
}, y = {
|
|
39
39
|
ALG: "RS256",
|
|
40
40
|
USER_ID_KEY: "sub",
|
|
41
41
|
TOKEN_ID_KEY: "__raw",
|
|
42
42
|
NONCE_KEY: "_nonce",
|
|
43
43
|
ISSUER: "gizmette.com"
|
|
44
|
-
},
|
|
44
|
+
}, Be = `-----BEGIN PUBLIC KEY-----
|
|
45
45
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsF6i3Jd9fY/3COqCw/m7
|
|
46
46
|
w5PKyTYLGAI2I6SIIdpe6i6DOCbEkmDz7LdVsBqwNtVi8gvWYIj+8ol6rU3qu1v5
|
|
47
47
|
i1Jd45GSK4kzkVdgCmQZbM5ak0KI99q5wsrAIzUd+LRJ2HRvWtr5IYdsIiXaQjle
|
|
@@ -49,28 +49,28 @@ aMwPFOIcJH+rKfFgNcHLcaS5syp7zU1ANwZ+trgR+DifBr8TLVkBynmNeTyhDm2+
|
|
|
49
49
|
l0haqjMk0UoNPPE8iYBWUHQJJE1Dqstj65d6Eh5g64Pao25y4cmYJbKjiblIGEkE
|
|
50
50
|
sjqybA9mARAqh9k/eiIopecWSiffNQTwVQVd2I9ZH3BalhEXHlqFgrjz51kFqg81
|
|
51
51
|
awIDAQAB
|
|
52
|
-
-----END PUBLIC KEY-----`,
|
|
52
|
+
-----END PUBLIC KEY-----`, F = {
|
|
53
53
|
AUTHENTICATE: "authenticate",
|
|
54
54
|
CODE: "code",
|
|
55
55
|
LOGOUT: "logout"
|
|
56
|
-
},
|
|
57
|
-
function
|
|
58
|
-
const t = e.reduce((
|
|
59
|
-
let
|
|
60
|
-
for (const
|
|
61
|
-
|
|
62
|
-
return
|
|
56
|
+
}, G = crypto, Ae = (e) => e instanceof CryptoKey, K = new TextEncoder(), q = new TextDecoder();
|
|
57
|
+
function Fe(...e) {
|
|
58
|
+
const t = e.reduce((n, { length: s }) => n + s, 0), r = new Uint8Array(t);
|
|
59
|
+
let a = 0;
|
|
60
|
+
for (const n of e)
|
|
61
|
+
r.set(n, a), a += n.length;
|
|
62
|
+
return r;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
const t = atob(e),
|
|
66
|
-
for (let
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
},
|
|
64
|
+
const Ge = (e) => {
|
|
65
|
+
const t = atob(e), r = new Uint8Array(t.length);
|
|
66
|
+
for (let a = 0; a < t.length; a++)
|
|
67
|
+
r[a] = t.charCodeAt(a);
|
|
68
|
+
return r;
|
|
69
|
+
}, M = (e) => {
|
|
70
70
|
let t = e;
|
|
71
|
-
t instanceof Uint8Array && (t =
|
|
71
|
+
t instanceof Uint8Array && (t = q.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
72
72
|
try {
|
|
73
|
-
return
|
|
73
|
+
return Ge(t);
|
|
74
74
|
} catch {
|
|
75
75
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
76
76
|
}
|
|
@@ -80,27 +80,27 @@ class C extends Error {
|
|
|
80
80
|
return "ERR_JOSE_GENERIC";
|
|
81
81
|
}
|
|
82
82
|
constructor(t) {
|
|
83
|
-
var
|
|
84
|
-
super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (
|
|
83
|
+
var r;
|
|
84
|
+
super(t), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (r = Error.captureStackTrace) == null || r.call(Error, this, this.constructor);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
class g extends C {
|
|
88
88
|
static get code() {
|
|
89
89
|
return "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
90
90
|
}
|
|
91
|
-
constructor(t,
|
|
92
|
-
super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim =
|
|
91
|
+
constructor(t, r, a = "unspecified", n = "unspecified") {
|
|
92
|
+
super(t), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = a, this.reason = n, this.payload = r;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
class
|
|
95
|
+
class ce extends C {
|
|
96
96
|
static get code() {
|
|
97
97
|
return "ERR_JWT_EXPIRED";
|
|
98
98
|
}
|
|
99
|
-
constructor(t,
|
|
100
|
-
super(t), this.code = "ERR_JWT_EXPIRED", this.claim =
|
|
99
|
+
constructor(t, r, a = "unspecified", n = "unspecified") {
|
|
100
|
+
super(t), this.code = "ERR_JWT_EXPIRED", this.claim = a, this.reason = n, this.payload = r;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class qe extends C {
|
|
104
104
|
constructor() {
|
|
105
105
|
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
106
106
|
}
|
|
@@ -108,15 +108,14 @@ class Me extends C {
|
|
|
108
108
|
return "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
-
class
|
|
111
|
+
let T = class extends C {
|
|
112
112
|
constructor() {
|
|
113
113
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
114
114
|
}
|
|
115
115
|
static get code() {
|
|
116
116
|
return "ERR_JOSE_NOT_SUPPORTED";
|
|
117
117
|
}
|
|
118
|
-
}
|
|
119
|
-
let h = class extends C {
|
|
118
|
+
}, h = class extends C {
|
|
120
119
|
constructor() {
|
|
121
120
|
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
122
121
|
}
|
|
@@ -124,7 +123,7 @@ let h = class extends C {
|
|
|
124
123
|
return "ERR_JWS_INVALID";
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
|
-
class
|
|
126
|
+
class be extends C {
|
|
128
127
|
constructor() {
|
|
129
128
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
130
129
|
}
|
|
@@ -132,7 +131,7 @@ class Se extends C {
|
|
|
132
131
|
return "ERR_JWT_INVALID";
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
class
|
|
134
|
+
class ze extends C {
|
|
136
135
|
constructor() {
|
|
137
136
|
super(...arguments), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED", this.message = "signature verification failed";
|
|
138
137
|
}
|
|
@@ -140,16 +139,16 @@ class Ve extends C {
|
|
|
140
139
|
return "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
function
|
|
142
|
+
function b(e, t = "algorithm.name") {
|
|
144
143
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
145
144
|
}
|
|
146
145
|
function $(e, t) {
|
|
147
146
|
return e.name === t;
|
|
148
147
|
}
|
|
149
|
-
function
|
|
148
|
+
function X(e) {
|
|
150
149
|
return parseInt(e.name.slice(4), 10);
|
|
151
150
|
}
|
|
152
|
-
function
|
|
151
|
+
function Xe(e) {
|
|
153
152
|
switch (e) {
|
|
154
153
|
case "ES256":
|
|
155
154
|
return "P-256";
|
|
@@ -161,106 +160,106 @@ function Ye(e) {
|
|
|
161
160
|
throw new Error("unreachable");
|
|
162
161
|
}
|
|
163
162
|
}
|
|
164
|
-
function
|
|
165
|
-
if (t.length && !t.some((
|
|
166
|
-
let
|
|
163
|
+
function Qe(e, t) {
|
|
164
|
+
if (t.length && !t.some((r) => e.usages.includes(r))) {
|
|
165
|
+
let r = "CryptoKey does not support this operation, its usages must include ";
|
|
167
166
|
if (t.length > 2) {
|
|
168
|
-
const
|
|
169
|
-
|
|
167
|
+
const a = t.pop();
|
|
168
|
+
r += `one of ${t.join(", ")}, or ${a}.`;
|
|
170
169
|
} else
|
|
171
|
-
t.length === 2 ?
|
|
172
|
-
throw new TypeError(
|
|
170
|
+
t.length === 2 ? r += `one of ${t[0]} or ${t[1]}.` : r += `${t[0]}.`;
|
|
171
|
+
throw new TypeError(r);
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
|
-
function
|
|
174
|
+
function Ze(e, t, ...r) {
|
|
176
175
|
switch (t) {
|
|
177
176
|
case "HS256":
|
|
178
177
|
case "HS384":
|
|
179
178
|
case "HS512": {
|
|
180
179
|
if (!$(e.algorithm, "HMAC"))
|
|
181
|
-
throw
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
throw
|
|
180
|
+
throw b("HMAC");
|
|
181
|
+
const a = parseInt(t.slice(2), 10);
|
|
182
|
+
if (X(e.algorithm.hash) !== a)
|
|
183
|
+
throw b(`SHA-${a}`, "algorithm.hash");
|
|
185
184
|
break;
|
|
186
185
|
}
|
|
187
186
|
case "RS256":
|
|
188
187
|
case "RS384":
|
|
189
188
|
case "RS512": {
|
|
190
189
|
if (!$(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
191
|
-
throw
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
-
throw
|
|
190
|
+
throw b("RSASSA-PKCS1-v1_5");
|
|
191
|
+
const a = parseInt(t.slice(2), 10);
|
|
192
|
+
if (X(e.algorithm.hash) !== a)
|
|
193
|
+
throw b(`SHA-${a}`, "algorithm.hash");
|
|
195
194
|
break;
|
|
196
195
|
}
|
|
197
196
|
case "PS256":
|
|
198
197
|
case "PS384":
|
|
199
198
|
case "PS512": {
|
|
200
199
|
if (!$(e.algorithm, "RSA-PSS"))
|
|
201
|
-
throw
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
throw
|
|
200
|
+
throw b("RSA-PSS");
|
|
201
|
+
const a = parseInt(t.slice(2), 10);
|
|
202
|
+
if (X(e.algorithm.hash) !== a)
|
|
203
|
+
throw b(`SHA-${a}`, "algorithm.hash");
|
|
205
204
|
break;
|
|
206
205
|
}
|
|
207
206
|
case "EdDSA": {
|
|
208
207
|
if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
|
|
209
|
-
throw
|
|
208
|
+
throw b("Ed25519 or Ed448");
|
|
210
209
|
break;
|
|
211
210
|
}
|
|
212
211
|
case "ES256":
|
|
213
212
|
case "ES384":
|
|
214
213
|
case "ES512": {
|
|
215
214
|
if (!$(e.algorithm, "ECDSA"))
|
|
216
|
-
throw
|
|
217
|
-
const
|
|
218
|
-
if (e.algorithm.namedCurve !==
|
|
219
|
-
throw
|
|
215
|
+
throw b("ECDSA");
|
|
216
|
+
const a = Xe(t);
|
|
217
|
+
if (e.algorithm.namedCurve !== a)
|
|
218
|
+
throw b(a, "algorithm.namedCurve");
|
|
220
219
|
break;
|
|
221
220
|
}
|
|
222
221
|
default:
|
|
223
222
|
throw new TypeError("CryptoKey does not support this operation");
|
|
224
223
|
}
|
|
225
|
-
|
|
224
|
+
Qe(e, r);
|
|
226
225
|
}
|
|
227
|
-
function
|
|
228
|
-
var
|
|
229
|
-
if (
|
|
230
|
-
const
|
|
231
|
-
e += `one of type ${
|
|
226
|
+
function _e(e, t, ...r) {
|
|
227
|
+
var a;
|
|
228
|
+
if (r.length > 2) {
|
|
229
|
+
const n = r.pop();
|
|
230
|
+
e += `one of type ${r.join(", ")}, or ${n}.`;
|
|
232
231
|
} else
|
|
233
|
-
|
|
234
|
-
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (
|
|
232
|
+
r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
233
|
+
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (a = t.constructor) != null && a.name && (e += ` Received an instance of ${t.constructor.name}`), e;
|
|
235
234
|
}
|
|
236
|
-
const
|
|
237
|
-
function
|
|
238
|
-
return
|
|
235
|
+
const ie = (e, ...t) => _e("Key must be ", e, ...t);
|
|
236
|
+
function ve(e, t, ...r) {
|
|
237
|
+
return _e(`Key for the ${e} algorithm must be `, t, ...r);
|
|
239
238
|
}
|
|
240
|
-
const
|
|
239
|
+
const Te = (e) => Ae(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", Y = ["CryptoKey"], et = (...e) => {
|
|
241
240
|
const t = e.filter(Boolean);
|
|
242
241
|
if (t.length === 0 || t.length === 1)
|
|
243
242
|
return !0;
|
|
244
|
-
let
|
|
245
|
-
for (const
|
|
246
|
-
const
|
|
247
|
-
if (!
|
|
248
|
-
|
|
243
|
+
let r;
|
|
244
|
+
for (const a of t) {
|
|
245
|
+
const n = Object.keys(a);
|
|
246
|
+
if (!r || r.size === 0) {
|
|
247
|
+
r = new Set(n);
|
|
249
248
|
continue;
|
|
250
249
|
}
|
|
251
|
-
for (const s of
|
|
252
|
-
if (
|
|
250
|
+
for (const s of n) {
|
|
251
|
+
if (r.has(s))
|
|
253
252
|
return !1;
|
|
254
|
-
|
|
253
|
+
r.add(s);
|
|
255
254
|
}
|
|
256
255
|
}
|
|
257
256
|
return !0;
|
|
258
257
|
};
|
|
259
|
-
function
|
|
258
|
+
function tt(e) {
|
|
260
259
|
return typeof e == "object" && e !== null;
|
|
261
260
|
}
|
|
262
|
-
function
|
|
263
|
-
if (!
|
|
261
|
+
function ne(e) {
|
|
262
|
+
if (!tt(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
264
263
|
return !1;
|
|
265
264
|
if (Object.getPrototypeOf(e) === null)
|
|
266
265
|
return !0;
|
|
@@ -269,51 +268,153 @@ function ee(e) {
|
|
|
269
268
|
t = Object.getPrototypeOf(t);
|
|
270
269
|
return Object.getPrototypeOf(e) === t;
|
|
271
270
|
}
|
|
272
|
-
const
|
|
271
|
+
const rt = (e, t) => {
|
|
273
272
|
if (e.startsWith("RS") || e.startsWith("PS")) {
|
|
274
|
-
const { modulusLength:
|
|
275
|
-
if (typeof
|
|
273
|
+
const { modulusLength: r } = t.algorithm;
|
|
274
|
+
if (typeof r != "number" || r < 2048)
|
|
276
275
|
throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
|
|
277
276
|
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
};
|
|
278
|
+
function at(e) {
|
|
279
|
+
let t, r;
|
|
280
|
+
switch (e.kty) {
|
|
281
|
+
case "RSA": {
|
|
282
|
+
switch (e.alg) {
|
|
283
|
+
case "PS256":
|
|
284
|
+
case "PS384":
|
|
285
|
+
case "PS512":
|
|
286
|
+
t = { name: "RSA-PSS", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
|
|
287
|
+
break;
|
|
288
|
+
case "RS256":
|
|
289
|
+
case "RS384":
|
|
290
|
+
case "RS512":
|
|
291
|
+
t = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${e.alg.slice(-3)}` }, r = e.d ? ["sign"] : ["verify"];
|
|
292
|
+
break;
|
|
293
|
+
case "RSA-OAEP":
|
|
294
|
+
case "RSA-OAEP-256":
|
|
295
|
+
case "RSA-OAEP-384":
|
|
296
|
+
case "RSA-OAEP-512":
|
|
297
|
+
t = {
|
|
298
|
+
name: "RSA-OAEP",
|
|
299
|
+
hash: `SHA-${parseInt(e.alg.slice(-3), 10) || 1}`
|
|
300
|
+
}, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
301
|
+
break;
|
|
302
|
+
default:
|
|
303
|
+
throw new T('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
case "EC": {
|
|
308
|
+
switch (e.alg) {
|
|
309
|
+
case "ES256":
|
|
310
|
+
t = { name: "ECDSA", namedCurve: "P-256" }, r = e.d ? ["sign"] : ["verify"];
|
|
311
|
+
break;
|
|
312
|
+
case "ES384":
|
|
313
|
+
t = { name: "ECDSA", namedCurve: "P-384" }, r = e.d ? ["sign"] : ["verify"];
|
|
314
|
+
break;
|
|
315
|
+
case "ES512":
|
|
316
|
+
t = { name: "ECDSA", namedCurve: "P-521" }, r = e.d ? ["sign"] : ["verify"];
|
|
317
|
+
break;
|
|
318
|
+
case "ECDH-ES":
|
|
319
|
+
case "ECDH-ES+A128KW":
|
|
320
|
+
case "ECDH-ES+A192KW":
|
|
321
|
+
case "ECDH-ES+A256KW":
|
|
322
|
+
t = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
323
|
+
break;
|
|
324
|
+
default:
|
|
325
|
+
throw new T('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case "OKP": {
|
|
330
|
+
switch (e.alg) {
|
|
331
|
+
case "EdDSA":
|
|
332
|
+
t = { name: e.crv }, r = e.d ? ["sign"] : ["verify"];
|
|
333
|
+
break;
|
|
334
|
+
case "ECDH-ES":
|
|
335
|
+
case "ECDH-ES+A128KW":
|
|
336
|
+
case "ECDH-ES+A192KW":
|
|
337
|
+
case "ECDH-ES+A256KW":
|
|
338
|
+
t = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
throw new T('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
default:
|
|
346
|
+
throw new T('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
347
|
+
}
|
|
348
|
+
return { algorithm: t, keyUsages: r };
|
|
349
|
+
}
|
|
350
|
+
const nt = async (e) => {
|
|
351
|
+
if (!e.alg)
|
|
352
|
+
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
353
|
+
const { algorithm: t, keyUsages: r } = at(e), a = [
|
|
354
|
+
t,
|
|
355
|
+
e.ext ?? !1,
|
|
356
|
+
e.key_ops ?? r
|
|
357
|
+
], n = { ...e };
|
|
358
|
+
return delete n.alg, delete n.use, G.subtle.importKey("jwk", n, ...a);
|
|
359
|
+
}, ke = (e) => M(e);
|
|
360
|
+
let Q, Z;
|
|
361
|
+
const Ie = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", Re = async (e, t, r, a) => {
|
|
362
|
+
let n = e.get(t);
|
|
363
|
+
if (n != null && n[a])
|
|
364
|
+
return n[a];
|
|
365
|
+
const s = await nt({ ...r, alg: a });
|
|
366
|
+
return n ? n[a] = s : e.set(t, { [a]: s }), s;
|
|
367
|
+
}, ot = (e, t) => {
|
|
368
|
+
if (Ie(e)) {
|
|
369
|
+
let r = e.export({ format: "jwk" });
|
|
370
|
+
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? ke(r.k) : (Z || (Z = /* @__PURE__ */ new WeakMap()), Re(Z, e, r, t));
|
|
371
|
+
}
|
|
372
|
+
return e;
|
|
373
|
+
}, st = (e, t) => {
|
|
374
|
+
if (Ie(e)) {
|
|
375
|
+
let r = e.export({ format: "jwk" });
|
|
376
|
+
return r.k ? ke(r.k) : (Q || (Q = /* @__PURE__ */ new WeakMap()), Re(Q, e, r, t));
|
|
377
|
+
}
|
|
378
|
+
return e;
|
|
379
|
+
}, ct = { normalizePublicKey: ot, normalizePrivateKey: st }, v = (e, t, r = 0) => {
|
|
380
|
+
r === 0 && (t.unshift(t.length), t.unshift(6));
|
|
381
|
+
const a = e.indexOf(t[0], r);
|
|
382
|
+
if (a === -1)
|
|
282
383
|
return !1;
|
|
283
|
-
const
|
|
284
|
-
return
|
|
285
|
-
},
|
|
384
|
+
const n = e.subarray(a, a + t.length);
|
|
385
|
+
return n.length !== t.length ? !1 : n.every((s, o) => s === t[o]) || v(e, t, a + 1);
|
|
386
|
+
}, ue = (e) => {
|
|
286
387
|
switch (!0) {
|
|
287
|
-
case
|
|
388
|
+
case v(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
288
389
|
return "P-256";
|
|
289
|
-
case
|
|
390
|
+
case v(e, [43, 129, 4, 0, 34]):
|
|
290
391
|
return "P-384";
|
|
291
|
-
case
|
|
392
|
+
case v(e, [43, 129, 4, 0, 35]):
|
|
292
393
|
return "P-521";
|
|
293
|
-
case
|
|
394
|
+
case v(e, [43, 101, 110]):
|
|
294
395
|
return "X25519";
|
|
295
|
-
case
|
|
396
|
+
case v(e, [43, 101, 111]):
|
|
296
397
|
return "X448";
|
|
297
|
-
case
|
|
398
|
+
case v(e, [43, 101, 112]):
|
|
298
399
|
return "Ed25519";
|
|
299
|
-
case
|
|
400
|
+
case v(e, [43, 101, 113]):
|
|
300
401
|
return "Ed448";
|
|
301
402
|
default:
|
|
302
|
-
throw new
|
|
403
|
+
throw new T("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
303
404
|
}
|
|
304
|
-
},
|
|
305
|
-
let s,
|
|
306
|
-
const i = new Uint8Array(atob(
|
|
307
|
-
switch (
|
|
405
|
+
}, it = async (e, t, r, a, n) => {
|
|
406
|
+
let s, o;
|
|
407
|
+
const i = new Uint8Array(atob(r.replace(e, "")).split("").map((c) => c.charCodeAt(0)));
|
|
408
|
+
switch (a) {
|
|
308
409
|
case "PS256":
|
|
309
410
|
case "PS384":
|
|
310
411
|
case "PS512":
|
|
311
|
-
s = { name: "RSA-PSS", hash: `SHA-${
|
|
412
|
+
s = { name: "RSA-PSS", hash: `SHA-${a.slice(-3)}` }, o = ["verify"];
|
|
312
413
|
break;
|
|
313
414
|
case "RS256":
|
|
314
415
|
case "RS384":
|
|
315
416
|
case "RS512":
|
|
316
|
-
s = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${
|
|
417
|
+
s = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${a.slice(-3)}` }, o = ["verify"];
|
|
317
418
|
break;
|
|
318
419
|
case "RSA-OAEP":
|
|
319
420
|
case "RSA-OAEP-256":
|
|
@@ -321,130 +422,130 @@ const ze = (e, t) => {
|
|
|
321
422
|
case "RSA-OAEP-512":
|
|
322
423
|
s = {
|
|
323
424
|
name: "RSA-OAEP",
|
|
324
|
-
hash: `SHA-${parseInt(
|
|
325
|
-
},
|
|
425
|
+
hash: `SHA-${parseInt(a.slice(-3), 10) || 1}`
|
|
426
|
+
}, o = ["encrypt", "wrapKey"];
|
|
326
427
|
break;
|
|
327
428
|
case "ES256":
|
|
328
|
-
s = { name: "ECDSA", namedCurve: "P-256" },
|
|
429
|
+
s = { name: "ECDSA", namedCurve: "P-256" }, o = ["verify"];
|
|
329
430
|
break;
|
|
330
431
|
case "ES384":
|
|
331
|
-
s = { name: "ECDSA", namedCurve: "P-384" },
|
|
432
|
+
s = { name: "ECDSA", namedCurve: "P-384" }, o = ["verify"];
|
|
332
433
|
break;
|
|
333
434
|
case "ES512":
|
|
334
|
-
s = { name: "ECDSA", namedCurve: "P-521" },
|
|
435
|
+
s = { name: "ECDSA", namedCurve: "P-521" }, o = ["verify"];
|
|
335
436
|
break;
|
|
336
437
|
case "ECDH-ES":
|
|
337
438
|
case "ECDH-ES+A128KW":
|
|
338
439
|
case "ECDH-ES+A192KW":
|
|
339
440
|
case "ECDH-ES+A256KW": {
|
|
340
|
-
const c =
|
|
341
|
-
s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c },
|
|
441
|
+
const c = ue(i);
|
|
442
|
+
s = c.startsWith("P-") ? { name: "ECDH", namedCurve: c } : { name: c }, o = [];
|
|
342
443
|
break;
|
|
343
444
|
}
|
|
344
445
|
case "EdDSA":
|
|
345
|
-
s = { name:
|
|
446
|
+
s = { name: ue(i) }, o = ["verify"];
|
|
346
447
|
break;
|
|
347
448
|
default:
|
|
348
|
-
throw new
|
|
449
|
+
throw new T('Invalid or unsupported "alg" (Algorithm) value');
|
|
349
450
|
}
|
|
350
|
-
return
|
|
351
|
-
},
|
|
352
|
-
async function
|
|
451
|
+
return G.subtle.importKey(t, i, s, !1, o);
|
|
452
|
+
}, ut = (e, t, r) => it(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
453
|
+
async function dt(e, t, r) {
|
|
353
454
|
if (e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
354
455
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
355
|
-
return
|
|
456
|
+
return ut(e, t);
|
|
356
457
|
}
|
|
357
|
-
const
|
|
458
|
+
const V = (e) => e == null ? void 0 : e[Symbol.toStringTag], lt = (e, t) => {
|
|
358
459
|
if (!(t instanceof Uint8Array)) {
|
|
359
|
-
if (!
|
|
360
|
-
throw new TypeError(
|
|
460
|
+
if (!Te(t))
|
|
461
|
+
throw new TypeError(ve(e, t, ...Y, "Uint8Array"));
|
|
361
462
|
if (t.type !== "secret")
|
|
362
|
-
throw new TypeError(`${
|
|
463
|
+
throw new TypeError(`${V(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
363
464
|
}
|
|
364
|
-
},
|
|
365
|
-
if (!
|
|
366
|
-
throw new TypeError(
|
|
465
|
+
}, ht = (e, t, r) => {
|
|
466
|
+
if (!Te(t))
|
|
467
|
+
throw new TypeError(ve(e, t, ...Y));
|
|
367
468
|
if (t.type === "secret")
|
|
368
|
-
throw new TypeError(`${
|
|
369
|
-
if (t.algorithm &&
|
|
370
|
-
throw new TypeError(`${
|
|
371
|
-
if (t.algorithm &&
|
|
372
|
-
throw new TypeError(`${
|
|
373
|
-
},
|
|
374
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ?
|
|
469
|
+
throw new TypeError(`${V(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
470
|
+
if (t.algorithm && r === "verify" && t.type === "private")
|
|
471
|
+
throw new TypeError(`${V(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
472
|
+
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
473
|
+
throw new TypeError(`${V(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
474
|
+
}, pt = (e, t, r) => {
|
|
475
|
+
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? lt(e, t) : ht(e, t, r);
|
|
375
476
|
};
|
|
376
|
-
function
|
|
377
|
-
if (
|
|
477
|
+
function yt(e, t, r, a, n) {
|
|
478
|
+
if (n.crit !== void 0 && (a == null ? void 0 : a.crit) === void 0)
|
|
378
479
|
throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
379
|
-
if (!
|
|
480
|
+
if (!a || a.crit === void 0)
|
|
380
481
|
return /* @__PURE__ */ new Set();
|
|
381
|
-
if (!Array.isArray(
|
|
482
|
+
if (!Array.isArray(a.crit) || a.crit.length === 0 || a.crit.some((o) => typeof o != "string" || o.length === 0))
|
|
382
483
|
throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
|
|
383
484
|
let s;
|
|
384
|
-
|
|
385
|
-
for (const
|
|
386
|
-
if (!s.has(
|
|
387
|
-
throw new
|
|
388
|
-
if (
|
|
389
|
-
throw new e(`Extension Header Parameter "${
|
|
390
|
-
if (s.get(
|
|
391
|
-
throw new e(`Extension Header Parameter "${
|
|
485
|
+
r !== void 0 ? s = new Map([...Object.entries(r), ...t.entries()]) : s = t;
|
|
486
|
+
for (const o of a.crit) {
|
|
487
|
+
if (!s.has(o))
|
|
488
|
+
throw new T(`Extension Header Parameter "${o}" is not recognized`);
|
|
489
|
+
if (n[o] === void 0)
|
|
490
|
+
throw new e(`Extension Header Parameter "${o}" is missing`);
|
|
491
|
+
if (s.get(o) && a[o] === void 0)
|
|
492
|
+
throw new e(`Extension Header Parameter "${o}" MUST be integrity protected`);
|
|
392
493
|
}
|
|
393
|
-
return new Set(
|
|
494
|
+
return new Set(a.crit);
|
|
394
495
|
}
|
|
395
|
-
const
|
|
396
|
-
if (t !== void 0 && (!Array.isArray(t) || t.some((
|
|
496
|
+
const ft = (e, t) => {
|
|
497
|
+
if (t !== void 0 && (!Array.isArray(t) || t.some((r) => typeof r != "string")))
|
|
397
498
|
throw new TypeError(`"${e}" option must be an array of strings`);
|
|
398
499
|
if (t)
|
|
399
500
|
return new Set(t);
|
|
400
501
|
};
|
|
401
|
-
function
|
|
402
|
-
const
|
|
502
|
+
function mt(e, t) {
|
|
503
|
+
const r = `SHA-${e.slice(-3)}`;
|
|
403
504
|
switch (e) {
|
|
404
505
|
case "HS256":
|
|
405
506
|
case "HS384":
|
|
406
507
|
case "HS512":
|
|
407
|
-
return { hash:
|
|
508
|
+
return { hash: r, name: "HMAC" };
|
|
408
509
|
case "PS256":
|
|
409
510
|
case "PS384":
|
|
410
511
|
case "PS512":
|
|
411
|
-
return { hash:
|
|
512
|
+
return { hash: r, name: "RSA-PSS", saltLength: e.slice(-3) >> 3 };
|
|
412
513
|
case "RS256":
|
|
413
514
|
case "RS384":
|
|
414
515
|
case "RS512":
|
|
415
|
-
return { hash:
|
|
516
|
+
return { hash: r, name: "RSASSA-PKCS1-v1_5" };
|
|
416
517
|
case "ES256":
|
|
417
518
|
case "ES384":
|
|
418
519
|
case "ES512":
|
|
419
|
-
return { hash:
|
|
520
|
+
return { hash: r, name: "ECDSA", namedCurve: t.namedCurve };
|
|
420
521
|
case "EdDSA":
|
|
421
522
|
return { name: t.name };
|
|
422
523
|
default:
|
|
423
|
-
throw new
|
|
524
|
+
throw new T(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
424
525
|
}
|
|
425
526
|
}
|
|
426
|
-
function
|
|
427
|
-
if (
|
|
428
|
-
return
|
|
527
|
+
async function wt(e, t, r) {
|
|
528
|
+
if (t = await ct.normalizePublicKey(t, e), Ae(t))
|
|
529
|
+
return Ze(t, e, r), t;
|
|
429
530
|
if (t instanceof Uint8Array) {
|
|
430
531
|
if (!e.startsWith("HS"))
|
|
431
|
-
throw new TypeError(
|
|
432
|
-
return
|
|
532
|
+
throw new TypeError(ie(t, ...Y));
|
|
533
|
+
return G.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
433
534
|
}
|
|
434
|
-
throw new TypeError(
|
|
535
|
+
throw new TypeError(ie(t, ...Y, "Uint8Array"));
|
|
435
536
|
}
|
|
436
|
-
const
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
const s =
|
|
537
|
+
const St = async (e, t, r, a) => {
|
|
538
|
+
const n = await wt(e, t, "verify");
|
|
539
|
+
rt(e, n);
|
|
540
|
+
const s = mt(e, n.algorithm);
|
|
440
541
|
try {
|
|
441
|
-
return await
|
|
542
|
+
return await G.subtle.verify(s, n, r, a);
|
|
442
543
|
} catch {
|
|
443
544
|
return !1;
|
|
444
545
|
}
|
|
445
546
|
};
|
|
446
|
-
async function
|
|
447
|
-
if (!
|
|
547
|
+
async function Et(e, t, r) {
|
|
548
|
+
if (!ne(e))
|
|
448
549
|
throw new h("Flattened JWS must be an object");
|
|
449
550
|
if (e.protected === void 0 && e.header === void 0)
|
|
450
551
|
throw new h('Flattened JWS must have either of the "protected" or "header" members');
|
|
@@ -454,140 +555,140 @@ async function it(e, t, o) {
|
|
|
454
555
|
throw new h("JWS Payload missing");
|
|
455
556
|
if (typeof e.signature != "string")
|
|
456
557
|
throw new h("JWS Signature missing or incorrect type");
|
|
457
|
-
if (e.header !== void 0 && !
|
|
558
|
+
if (e.header !== void 0 && !ne(e.header))
|
|
458
559
|
throw new h("JWS Unprotected Header incorrect type");
|
|
459
|
-
let
|
|
560
|
+
let a = {};
|
|
460
561
|
if (e.protected)
|
|
461
562
|
try {
|
|
462
|
-
const m =
|
|
463
|
-
|
|
563
|
+
const m = M(e.protected);
|
|
564
|
+
a = JSON.parse(q.decode(m));
|
|
464
565
|
} catch {
|
|
465
566
|
throw new h("JWS Protected Header is invalid");
|
|
466
567
|
}
|
|
467
|
-
if (!
|
|
568
|
+
if (!et(a, e.header))
|
|
468
569
|
throw new h("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
469
|
-
const
|
|
470
|
-
...
|
|
570
|
+
const n = {
|
|
571
|
+
...a,
|
|
471
572
|
...e.header
|
|
472
|
-
}, s =
|
|
473
|
-
let
|
|
474
|
-
if (s.has("b64") && (
|
|
573
|
+
}, s = yt(h, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, a, n);
|
|
574
|
+
let o = !0;
|
|
575
|
+
if (s.has("b64") && (o = a.b64, typeof o != "boolean"))
|
|
475
576
|
throw new h('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
476
|
-
const { alg: i } =
|
|
577
|
+
const { alg: i } = n;
|
|
477
578
|
if (typeof i != "string" || !i)
|
|
478
579
|
throw new h('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
479
|
-
const c =
|
|
580
|
+
const c = r && ft("algorithms", r.algorithms);
|
|
480
581
|
if (c && !c.has(i))
|
|
481
|
-
throw new
|
|
482
|
-
if (
|
|
582
|
+
throw new qe('"alg" (Algorithm) Header Parameter value not allowed');
|
|
583
|
+
if (o) {
|
|
483
584
|
if (typeof e.payload != "string")
|
|
484
585
|
throw new h("JWS Payload must be a string");
|
|
485
586
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
486
587
|
throw new h("JWS Payload must be a string or an Uint8Array instance");
|
|
487
588
|
let u = !1;
|
|
488
|
-
typeof t == "function" && (t = await t(
|
|
489
|
-
const
|
|
589
|
+
typeof t == "function" && (t = await t(a, e), u = !0), pt(i, t, "verify");
|
|
590
|
+
const f = Fe(K.encode(e.protected ?? ""), K.encode("."), typeof e.payload == "string" ? K.encode(e.payload) : e.payload);
|
|
490
591
|
let p;
|
|
491
592
|
try {
|
|
492
|
-
p =
|
|
593
|
+
p = M(e.signature);
|
|
493
594
|
} catch {
|
|
494
595
|
throw new h("Failed to base64url decode the signature");
|
|
495
596
|
}
|
|
496
|
-
if (!await
|
|
497
|
-
throw new
|
|
498
|
-
let
|
|
499
|
-
if (
|
|
597
|
+
if (!await St(i, t, p, f))
|
|
598
|
+
throw new ze();
|
|
599
|
+
let _;
|
|
600
|
+
if (o)
|
|
500
601
|
try {
|
|
501
|
-
|
|
602
|
+
_ = M(e.payload);
|
|
502
603
|
} catch {
|
|
503
604
|
throw new h("Failed to base64url decode the payload");
|
|
504
605
|
}
|
|
505
606
|
else
|
|
506
|
-
typeof e.payload == "string" ?
|
|
507
|
-
const
|
|
508
|
-
return e.protected !== void 0 && (
|
|
607
|
+
typeof e.payload == "string" ? _ = K.encode(e.payload) : _ = e.payload;
|
|
608
|
+
const S = { payload: _ };
|
|
609
|
+
return e.protected !== void 0 && (S.protectedHeader = a), e.header !== void 0 && (S.unprotectedHeader = e.header), u ? { ...S, key: t } : S;
|
|
509
610
|
}
|
|
510
|
-
async function
|
|
511
|
-
if (e instanceof Uint8Array && (e =
|
|
611
|
+
async function gt(e, t, r) {
|
|
612
|
+
if (e instanceof Uint8Array && (e = q.decode(e)), typeof e != "string")
|
|
512
613
|
throw new h("Compact JWS must be a string or Uint8Array");
|
|
513
|
-
const { 0:
|
|
514
|
-
if (
|
|
614
|
+
const { 0: a, 1: n, 2: s, length: o } = e.split(".");
|
|
615
|
+
if (o !== 3)
|
|
515
616
|
throw new h("Invalid Compact JWS");
|
|
516
|
-
const i = await
|
|
617
|
+
const i = await Et({ payload: n, protected: a, signature: s }, t, r), c = { payload: i.payload, protectedHeader: i.protectedHeader };
|
|
517
618
|
return typeof t == "function" ? { ...c, key: i.key } : c;
|
|
518
619
|
}
|
|
519
|
-
const
|
|
520
|
-
const t =
|
|
620
|
+
const At = (e) => Math.floor(e.getTime() / 1e3), Ce = 60, Pe = Ce * 60, oe = Pe * 24, bt = oe * 7, _t = oe * 365.25, vt = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i, de = (e) => {
|
|
621
|
+
const t = vt.exec(e);
|
|
521
622
|
if (!t || t[4] && t[1])
|
|
522
623
|
throw new TypeError("Invalid time period format");
|
|
523
|
-
const
|
|
524
|
-
let
|
|
525
|
-
switch (
|
|
624
|
+
const r = parseFloat(t[2]), a = t[3].toLowerCase();
|
|
625
|
+
let n;
|
|
626
|
+
switch (a) {
|
|
526
627
|
case "sec":
|
|
527
628
|
case "secs":
|
|
528
629
|
case "second":
|
|
529
630
|
case "seconds":
|
|
530
631
|
case "s":
|
|
531
|
-
|
|
632
|
+
n = Math.round(r);
|
|
532
633
|
break;
|
|
533
634
|
case "minute":
|
|
534
635
|
case "minutes":
|
|
535
636
|
case "min":
|
|
536
637
|
case "mins":
|
|
537
638
|
case "m":
|
|
538
|
-
|
|
639
|
+
n = Math.round(r * Ce);
|
|
539
640
|
break;
|
|
540
641
|
case "hour":
|
|
541
642
|
case "hours":
|
|
542
643
|
case "hr":
|
|
543
644
|
case "hrs":
|
|
544
645
|
case "h":
|
|
545
|
-
|
|
646
|
+
n = Math.round(r * Pe);
|
|
546
647
|
break;
|
|
547
648
|
case "day":
|
|
548
649
|
case "days":
|
|
549
650
|
case "d":
|
|
550
|
-
|
|
651
|
+
n = Math.round(r * oe);
|
|
551
652
|
break;
|
|
552
653
|
case "week":
|
|
553
654
|
case "weeks":
|
|
554
655
|
case "w":
|
|
555
|
-
|
|
656
|
+
n = Math.round(r * bt);
|
|
556
657
|
break;
|
|
557
658
|
default:
|
|
558
|
-
|
|
659
|
+
n = Math.round(r * _t);
|
|
559
660
|
break;
|
|
560
661
|
}
|
|
561
|
-
return t[1] === "-" || t[4] === "ago" ? -
|
|
562
|
-
},
|
|
563
|
-
let
|
|
662
|
+
return t[1] === "-" || t[4] === "ago" ? -n : n;
|
|
663
|
+
}, le = (e) => e.toLowerCase().replace(/^application\//, ""), Tt = (e, t) => typeof e == "string" ? t.includes(e) : Array.isArray(e) ? t.some(Set.prototype.has.bind(new Set(e))) : !1, kt = (e, t, r = {}) => {
|
|
664
|
+
let a;
|
|
564
665
|
try {
|
|
565
|
-
|
|
666
|
+
a = JSON.parse(q.decode(t));
|
|
566
667
|
} catch {
|
|
567
668
|
}
|
|
568
|
-
if (!
|
|
569
|
-
throw new
|
|
570
|
-
const { typ:
|
|
571
|
-
if (
|
|
572
|
-
throw new g('unexpected "typ" JWT header value',
|
|
573
|
-
const { requiredClaims: s = [], issuer:
|
|
574
|
-
u !== void 0 &&
|
|
575
|
-
for (const m of new Set(
|
|
576
|
-
if (!(m in
|
|
577
|
-
throw new g(`missing required "${m}" claim`,
|
|
578
|
-
if (
|
|
579
|
-
throw new g('unexpected "iss" claim value',
|
|
580
|
-
if (i &&
|
|
581
|
-
throw new g('unexpected "sub" claim value',
|
|
582
|
-
if (c && !
|
|
583
|
-
throw new g('unexpected "aud" claim value',
|
|
669
|
+
if (!ne(a))
|
|
670
|
+
throw new be("JWT Claims Set must be a top-level JSON object");
|
|
671
|
+
const { typ: n } = r;
|
|
672
|
+
if (n && (typeof e.typ != "string" || le(e.typ) !== le(n)))
|
|
673
|
+
throw new g('unexpected "typ" JWT header value', a, "typ", "check_failed");
|
|
674
|
+
const { requiredClaims: s = [], issuer: o, subject: i, audience: c, maxTokenAge: u } = r, f = [...s];
|
|
675
|
+
u !== void 0 && f.push("iat"), c !== void 0 && f.push("aud"), i !== void 0 && f.push("sub"), o !== void 0 && f.push("iss");
|
|
676
|
+
for (const m of new Set(f.reverse()))
|
|
677
|
+
if (!(m in a))
|
|
678
|
+
throw new g(`missing required "${m}" claim`, a, m, "missing");
|
|
679
|
+
if (o && !(Array.isArray(o) ? o : [o]).includes(a.iss))
|
|
680
|
+
throw new g('unexpected "iss" claim value', a, "iss", "check_failed");
|
|
681
|
+
if (i && a.sub !== i)
|
|
682
|
+
throw new g('unexpected "sub" claim value', a, "sub", "check_failed");
|
|
683
|
+
if (c && !Tt(a.aud, typeof c == "string" ? [c] : c))
|
|
684
|
+
throw new g('unexpected "aud" claim value', a, "aud", "check_failed");
|
|
584
685
|
let p;
|
|
585
|
-
switch (typeof
|
|
686
|
+
switch (typeof r.clockTolerance) {
|
|
586
687
|
case "string":
|
|
587
|
-
p =
|
|
688
|
+
p = de(r.clockTolerance);
|
|
588
689
|
break;
|
|
589
690
|
case "number":
|
|
590
|
-
p =
|
|
691
|
+
p = r.clockTolerance;
|
|
591
692
|
break;
|
|
592
693
|
case "undefined":
|
|
593
694
|
p = 0;
|
|
@@ -595,200 +696,200 @@ const dt = (e) => Math.floor(e.getTime() / 1e3), Te = 60, be = Te * 60, re = be
|
|
|
595
696
|
default:
|
|
596
697
|
throw new TypeError("Invalid clockTolerance option type");
|
|
597
698
|
}
|
|
598
|
-
const { currentDate:
|
|
599
|
-
if ((
|
|
600
|
-
throw new g('"iat" claim must be a number',
|
|
601
|
-
if (
|
|
602
|
-
if (typeof
|
|
603
|
-
throw new g('"nbf" claim must be a number',
|
|
604
|
-
if (
|
|
605
|
-
throw new g('"nbf" claim timestamp check failed',
|
|
699
|
+
const { currentDate: _ } = r, S = At(_ || /* @__PURE__ */ new Date());
|
|
700
|
+
if ((a.iat !== void 0 || u) && typeof a.iat != "number")
|
|
701
|
+
throw new g('"iat" claim must be a number', a, "iat", "invalid");
|
|
702
|
+
if (a.nbf !== void 0) {
|
|
703
|
+
if (typeof a.nbf != "number")
|
|
704
|
+
throw new g('"nbf" claim must be a number', a, "nbf", "invalid");
|
|
705
|
+
if (a.nbf > S + p)
|
|
706
|
+
throw new g('"nbf" claim timestamp check failed', a, "nbf", "check_failed");
|
|
606
707
|
}
|
|
607
|
-
if (
|
|
608
|
-
if (typeof
|
|
609
|
-
throw new g('"exp" claim must be a number',
|
|
610
|
-
if (
|
|
611
|
-
throw new
|
|
708
|
+
if (a.exp !== void 0) {
|
|
709
|
+
if (typeof a.exp != "number")
|
|
710
|
+
throw new g('"exp" claim must be a number', a, "exp", "invalid");
|
|
711
|
+
if (a.exp <= S - p)
|
|
712
|
+
throw new ce('"exp" claim timestamp check failed', a, "exp", "check_failed");
|
|
612
713
|
}
|
|
613
714
|
if (u) {
|
|
614
|
-
const m =
|
|
615
|
-
if (m - p >
|
|
616
|
-
throw new
|
|
715
|
+
const m = S - a.iat, k = typeof u == "number" ? u : de(u);
|
|
716
|
+
if (m - p > k)
|
|
717
|
+
throw new ce('"iat" claim timestamp check failed (too far in the past)', a, "iat", "check_failed");
|
|
617
718
|
if (m < 0 - p)
|
|
618
|
-
throw new g('"iat" claim timestamp check failed (it should be in the past)',
|
|
719
|
+
throw new g('"iat" claim timestamp check failed (it should be in the past)', a, "iat", "check_failed");
|
|
619
720
|
}
|
|
620
|
-
return
|
|
721
|
+
return a;
|
|
621
722
|
};
|
|
622
|
-
async function
|
|
623
|
-
var
|
|
624
|
-
const
|
|
625
|
-
if ((
|
|
626
|
-
throw new
|
|
627
|
-
const s = { payload:
|
|
628
|
-
return typeof t == "function" ? { ...s, key:
|
|
723
|
+
async function It(e, t, r) {
|
|
724
|
+
var a;
|
|
725
|
+
const n = await gt(e, t, r);
|
|
726
|
+
if ((a = n.protectedHeader.crit) != null && a.includes("b64") && n.protectedHeader.b64 === !1)
|
|
727
|
+
throw new be("JWTs MUST NOT use unencoded payload");
|
|
728
|
+
const s = { payload: kt(n.protectedHeader, n.payload, r), protectedHeader: n.protectedHeader };
|
|
729
|
+
return typeof t == "function" ? { ...s, key: n.key } : s;
|
|
629
730
|
}
|
|
630
|
-
const
|
|
731
|
+
const H = async (e) => {
|
|
631
732
|
try {
|
|
632
|
-
const t =
|
|
633
|
-
return await
|
|
634
|
-
issuer:
|
|
733
|
+
const t = y.ALG, r = await dt(Be, t);
|
|
734
|
+
return await It(e, r, {
|
|
735
|
+
issuer: y.ISSUER
|
|
635
736
|
});
|
|
636
737
|
} catch {
|
|
637
738
|
return;
|
|
638
739
|
}
|
|
639
740
|
};
|
|
640
741
|
var d = [];
|
|
641
|
-
for (var
|
|
642
|
-
d.push((
|
|
643
|
-
function
|
|
742
|
+
for (var ee = 0; ee < 256; ++ee)
|
|
743
|
+
d.push((ee + 256).toString(16).slice(1));
|
|
744
|
+
function Rt(e, t = 0) {
|
|
644
745
|
return (d[e[t + 0]] + d[e[t + 1]] + d[e[t + 2]] + d[e[t + 3]] + "-" + d[e[t + 4]] + d[e[t + 5]] + "-" + d[e[t + 6]] + d[e[t + 7]] + "-" + d[e[t + 8]] + d[e[t + 9]] + "-" + d[e[t + 10]] + d[e[t + 11]] + d[e[t + 12]] + d[e[t + 13]] + d[e[t + 14]] + d[e[t + 15]]).toLowerCase();
|
|
645
746
|
}
|
|
646
|
-
var
|
|
647
|
-
function
|
|
648
|
-
if (!
|
|
747
|
+
var L, Ct = new Uint8Array(16);
|
|
748
|
+
function Pt() {
|
|
749
|
+
if (!L && (L = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !L))
|
|
649
750
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
650
|
-
return
|
|
751
|
+
return L(Ct);
|
|
651
752
|
}
|
|
652
|
-
var
|
|
653
|
-
const
|
|
654
|
-
randomUUID:
|
|
753
|
+
var Ot = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
754
|
+
const he = {
|
|
755
|
+
randomUUID: Ot
|
|
655
756
|
};
|
|
656
|
-
function
|
|
657
|
-
if (
|
|
658
|
-
return
|
|
757
|
+
function pe(e, t, r) {
|
|
758
|
+
if (he.randomUUID && !t && !e)
|
|
759
|
+
return he.randomUUID();
|
|
659
760
|
e = e || {};
|
|
660
|
-
var
|
|
661
|
-
return
|
|
761
|
+
var a = e.random || (e.rng || Pt)();
|
|
762
|
+
return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Rt(a);
|
|
662
763
|
}
|
|
663
|
-
const
|
|
764
|
+
const ye = globalThis.crypto, Dt = (e) => `${pe()}${pe()}`.slice(0, e), Ut = (e) => btoa(
|
|
664
765
|
[...new Uint8Array(e)].map((t) => String.fromCharCode(t)).join("")
|
|
665
766
|
);
|
|
666
|
-
async function
|
|
667
|
-
if (!
|
|
767
|
+
async function Ht(e) {
|
|
768
|
+
if (!ye.subtle)
|
|
668
769
|
throw new Error(
|
|
669
770
|
"crypto.subtle is available only in secure contexts (HTTPS)."
|
|
670
771
|
);
|
|
671
|
-
const t = new TextEncoder().encode(e),
|
|
672
|
-
return
|
|
772
|
+
const t = new TextEncoder().encode(e), r = await ye.subtle.digest("SHA-256", t);
|
|
773
|
+
return Ut(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
673
774
|
}
|
|
674
|
-
async function
|
|
675
|
-
const
|
|
775
|
+
async function Nt(e) {
|
|
776
|
+
const r = Dt(43), a = await Ht(r);
|
|
676
777
|
return {
|
|
677
|
-
code_verifier:
|
|
678
|
-
code_challenge:
|
|
778
|
+
code_verifier: r,
|
|
779
|
+
code_challenge: a
|
|
679
780
|
};
|
|
680
781
|
}
|
|
681
|
-
function
|
|
782
|
+
function Oe(e, t) {
|
|
682
783
|
window.dispatchEvent(new StorageEvent("storage", { key: e, newValue: t }));
|
|
683
784
|
}
|
|
684
|
-
const
|
|
685
|
-
const
|
|
785
|
+
const fe = (e, t) => {
|
|
786
|
+
const r = JSON.stringify(
|
|
686
787
|
typeof t == "function" ? t() : t
|
|
687
788
|
);
|
|
688
|
-
window.localStorage.setItem(e,
|
|
689
|
-
},
|
|
690
|
-
window.localStorage.removeItem(e),
|
|
691
|
-
},
|
|
692
|
-
function
|
|
789
|
+
window.localStorage.setItem(e, r), Oe(e, r);
|
|
790
|
+
}, Kt = (e) => {
|
|
791
|
+
window.localStorage.removeItem(e), Oe(e, null);
|
|
792
|
+
}, me = (e) => window.localStorage.getItem(e), $t = (e) => (window.addEventListener("storage", e), () => window.removeEventListener("storage", e));
|
|
793
|
+
function W({
|
|
693
794
|
key: e,
|
|
694
795
|
initialValue: t
|
|
695
796
|
}) {
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
),
|
|
797
|
+
const r = () => me(e), a = D.useSyncExternalStore(
|
|
798
|
+
$t,
|
|
799
|
+
r
|
|
800
|
+
), n = D.useCallback(
|
|
700
801
|
(i) => {
|
|
701
802
|
try {
|
|
702
|
-
const c = typeof i == "function" ? i(JSON.parse(
|
|
703
|
-
c == null ?
|
|
803
|
+
const c = typeof i == "function" ? i(JSON.parse(a)) : i;
|
|
804
|
+
c == null ? Kt(e) : fe(e, c);
|
|
704
805
|
} catch (c) {
|
|
705
806
|
console.warn(c);
|
|
706
807
|
}
|
|
707
808
|
},
|
|
708
|
-
[e,
|
|
809
|
+
[e, a]
|
|
709
810
|
), s = D.useCallback(() => {
|
|
710
|
-
|
|
711
|
-
}, [t,
|
|
712
|
-
|
|
713
|
-
}, [
|
|
811
|
+
n(t);
|
|
812
|
+
}, [t, n]), o = D.useCallback(() => {
|
|
813
|
+
n(null);
|
|
814
|
+
}, [n]);
|
|
714
815
|
return D.useEffect(() => {
|
|
715
816
|
try {
|
|
716
|
-
|
|
817
|
+
me(e) === null && typeof t < "u" && fe(e, t);
|
|
717
818
|
} catch (i) {
|
|
718
819
|
console.warn(i);
|
|
719
820
|
}
|
|
720
|
-
}, [e, t]), [
|
|
821
|
+
}, [e, t]), [a ? JSON.parse(a) : null, n, s, o];
|
|
721
822
|
}
|
|
722
823
|
var l = [];
|
|
723
|
-
for (var
|
|
724
|
-
l.push((
|
|
725
|
-
function
|
|
824
|
+
for (var te = 0; te < 256; ++te)
|
|
825
|
+
l.push((te + 256).toString(16).slice(1));
|
|
826
|
+
function Lt(e, t = 0) {
|
|
726
827
|
return (l[e[t + 0]] + l[e[t + 1]] + l[e[t + 2]] + l[e[t + 3]] + "-" + l[e[t + 4]] + l[e[t + 5]] + "-" + l[e[t + 6]] + l[e[t + 7]] + "-" + l[e[t + 8]] + l[e[t + 9]] + "-" + l[e[t + 10]] + l[e[t + 11]] + l[e[t + 12]] + l[e[t + 13]] + l[e[t + 14]] + l[e[t + 15]]).toLowerCase();
|
|
727
828
|
}
|
|
728
|
-
var
|
|
729
|
-
function
|
|
730
|
-
if (!
|
|
829
|
+
var J, Wt = new Uint8Array(16);
|
|
830
|
+
function Jt() {
|
|
831
|
+
if (!J && (J = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !J))
|
|
731
832
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
732
|
-
return
|
|
833
|
+
return J(Wt);
|
|
733
834
|
}
|
|
734
|
-
var
|
|
735
|
-
const
|
|
736
|
-
randomUUID:
|
|
835
|
+
var xt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
836
|
+
const we = {
|
|
837
|
+
randomUUID: xt
|
|
737
838
|
};
|
|
738
|
-
function
|
|
739
|
-
if (
|
|
740
|
-
return
|
|
839
|
+
function jt(e, t, r) {
|
|
840
|
+
if (we.randomUUID && !t && !e)
|
|
841
|
+
return we.randomUUID();
|
|
741
842
|
e = e || {};
|
|
742
|
-
var
|
|
743
|
-
return
|
|
843
|
+
var a = e.random || (e.rng || Jt)();
|
|
844
|
+
return a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, Lt(a);
|
|
744
845
|
}
|
|
745
|
-
const
|
|
846
|
+
const re = "Oops! It looks like your session has expired. For your security, please log in again to continue.", Mt = "Your session has been successfully terminated.", Se = "Login failed. Please try again.", U = "Error getting access token, please re-authenticate.", Vt = "You forgot to wrap your component in <AuthProvider>.", Ee = {
|
|
746
847
|
dev: "https://auth.gizmette.local.com:3003",
|
|
747
848
|
prod: "https://mylogin.gizmette.com"
|
|
748
|
-
}, x = "@@auth@@",
|
|
849
|
+
}, x = "@@auth@@", Yt = process.env.NODE_ENV === "production", Bt = !Yt, z = async ({
|
|
749
850
|
type: e,
|
|
750
851
|
clientId: t,
|
|
751
|
-
params:
|
|
852
|
+
params: r = {}
|
|
752
853
|
}) => {
|
|
753
854
|
try {
|
|
754
|
-
const
|
|
755
|
-
|
|
855
|
+
const a = await fetch(
|
|
856
|
+
Bt ? `${Ee.dev}/${e}` : `${Ee.prod}/${e}`,
|
|
756
857
|
{
|
|
757
858
|
credentials: "include",
|
|
758
859
|
method: "POST",
|
|
759
860
|
headers: {
|
|
760
861
|
"Content-Type": "application/json",
|
|
761
|
-
[
|
|
862
|
+
[Ye.CLIENT_ID]: `${t}`
|
|
762
863
|
},
|
|
763
|
-
body: JSON.stringify(
|
|
864
|
+
body: JSON.stringify(r)
|
|
764
865
|
}
|
|
765
866
|
);
|
|
766
|
-
if (
|
|
767
|
-
return { status:
|
|
768
|
-
const { data:
|
|
867
|
+
if (a.status !== 200)
|
|
868
|
+
return { status: a.status, data: [] };
|
|
869
|
+
const { data: n, errors: s } = await a.json();
|
|
769
870
|
return {
|
|
770
|
-
status:
|
|
771
|
-
data:
|
|
871
|
+
status: a.status,
|
|
872
|
+
data: n,
|
|
772
873
|
errors: s
|
|
773
874
|
};
|
|
774
|
-
} catch (
|
|
775
|
-
return console.error(
|
|
875
|
+
} catch (a) {
|
|
876
|
+
return console.error(a), { status: 500, data: [] };
|
|
776
877
|
}
|
|
777
|
-
},
|
|
878
|
+
}, ae = async ({
|
|
778
879
|
idToken: e,
|
|
779
880
|
accessToken: t,
|
|
780
|
-
refreshToken:
|
|
781
|
-
clientId:
|
|
881
|
+
refreshToken: r,
|
|
882
|
+
clientId: a
|
|
782
883
|
}) => {
|
|
783
884
|
try {
|
|
784
885
|
return {
|
|
785
|
-
status: (await
|
|
786
|
-
type:
|
|
787
|
-
clientId:
|
|
886
|
+
status: (await z({
|
|
887
|
+
type: F.LOGOUT,
|
|
888
|
+
clientId: a,
|
|
788
889
|
params: {
|
|
789
890
|
idToken: e,
|
|
790
891
|
accessToken: t,
|
|
791
|
-
refreshToken:
|
|
892
|
+
refreshToken: r
|
|
792
893
|
}
|
|
793
894
|
})).status === 200
|
|
794
895
|
};
|
|
@@ -797,35 +898,35 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
797
898
|
status: !1
|
|
798
899
|
};
|
|
799
900
|
}
|
|
800
|
-
},
|
|
901
|
+
}, ge = async ({
|
|
801
902
|
username: e,
|
|
802
903
|
password: t,
|
|
803
|
-
clientId:
|
|
804
|
-
nonce:
|
|
805
|
-
type:
|
|
904
|
+
clientId: r,
|
|
905
|
+
nonce: a,
|
|
906
|
+
type: n,
|
|
806
907
|
sessionExpiration: s,
|
|
807
|
-
code:
|
|
908
|
+
code: o,
|
|
808
909
|
code_verifier: i
|
|
809
910
|
}) => {
|
|
810
911
|
try {
|
|
811
|
-
const c = await
|
|
812
|
-
type:
|
|
813
|
-
clientId:
|
|
912
|
+
const c = await z({
|
|
913
|
+
type: F.AUTHENTICATE,
|
|
914
|
+
clientId: r,
|
|
814
915
|
params: {
|
|
815
|
-
type:
|
|
916
|
+
type: n || B.ID_AND_ACCESS_TOKEN,
|
|
816
917
|
username: e,
|
|
817
918
|
password: t,
|
|
818
919
|
sessionExpiration: s,
|
|
819
|
-
nonce:
|
|
820
|
-
code:
|
|
920
|
+
nonce: a,
|
|
921
|
+
code: o,
|
|
821
922
|
code_verifier: i
|
|
822
923
|
}
|
|
823
|
-
}), u = await
|
|
824
|
-
return u && u.payload[
|
|
924
|
+
}), u = await H(c.data.idToken);
|
|
925
|
+
return u && u.payload[y.USER_ID_KEY] !== "" && u.payload[y.NONCE_KEY] === a ? {
|
|
825
926
|
idToken: c.data.idToken,
|
|
826
927
|
accessToken: c.data.accessToken,
|
|
827
928
|
refreshToken: c.data.refreshToken,
|
|
828
|
-
userId: u.payload[
|
|
929
|
+
userId: u.payload[y.USER_ID_KEY],
|
|
829
930
|
status: !0
|
|
830
931
|
} : {
|
|
831
932
|
status: !1
|
|
@@ -835,24 +936,24 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
835
936
|
status: !1
|
|
836
937
|
};
|
|
837
938
|
}
|
|
838
|
-
},
|
|
939
|
+
}, Ft = async ({
|
|
839
940
|
nonce: e,
|
|
840
941
|
clientId: t,
|
|
841
|
-
code_challenge:
|
|
942
|
+
code_challenge: r
|
|
842
943
|
}) => {
|
|
843
944
|
try {
|
|
844
|
-
const
|
|
845
|
-
type:
|
|
945
|
+
const a = await z({
|
|
946
|
+
type: F.CODE,
|
|
846
947
|
clientId: t,
|
|
847
948
|
params: {
|
|
848
|
-
type:
|
|
949
|
+
type: B.CODE,
|
|
849
950
|
nonce: e,
|
|
850
|
-
code_challenge:
|
|
951
|
+
code_challenge: r
|
|
851
952
|
}
|
|
852
953
|
});
|
|
853
|
-
return
|
|
954
|
+
return a.data.code ? {
|
|
854
955
|
status: !0,
|
|
855
|
-
code:
|
|
956
|
+
code: a.data.code
|
|
856
957
|
} : {
|
|
857
958
|
status: !1
|
|
858
959
|
};
|
|
@@ -861,29 +962,29 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
861
962
|
status: !1
|
|
862
963
|
};
|
|
863
964
|
}
|
|
864
|
-
},
|
|
965
|
+
}, Gt = async ({
|
|
865
966
|
clientId: e,
|
|
866
967
|
userId: t,
|
|
867
|
-
nonce:
|
|
868
|
-
refreshToken:
|
|
869
|
-
accessToken:
|
|
968
|
+
nonce: r,
|
|
969
|
+
refreshToken: a,
|
|
970
|
+
accessToken: n
|
|
870
971
|
}) => {
|
|
871
972
|
try {
|
|
872
|
-
const s = await
|
|
873
|
-
type:
|
|
973
|
+
const s = await z({
|
|
974
|
+
type: F.AUTHENTICATE,
|
|
874
975
|
clientId: e,
|
|
875
976
|
params: {
|
|
876
|
-
type:
|
|
977
|
+
type: B.REFRESH_TOKEN,
|
|
877
978
|
userId: t,
|
|
878
|
-
nonce:
|
|
879
|
-
refreshToken:
|
|
880
|
-
accessToken:
|
|
979
|
+
nonce: r,
|
|
980
|
+
refreshToken: a,
|
|
981
|
+
accessToken: n
|
|
881
982
|
}
|
|
882
|
-
}),
|
|
883
|
-
return
|
|
983
|
+
}), o = await H(s.data.accessToken);
|
|
984
|
+
return o && o.payload[y.USER_ID_KEY] !== "" && o.payload[y.NONCE_KEY] === r ? {
|
|
884
985
|
accessToken: s.data.accessToken,
|
|
885
986
|
refreshToken: s.data.refreshToken,
|
|
886
|
-
userId:
|
|
987
|
+
userId: o.payload[y.USER_ID_KEY],
|
|
887
988
|
status: !0
|
|
888
989
|
} : {
|
|
889
990
|
status: !1
|
|
@@ -894,8 +995,8 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
894
995
|
};
|
|
895
996
|
}
|
|
896
997
|
}, j = () => {
|
|
897
|
-
throw new Error(
|
|
898
|
-
},
|
|
998
|
+
throw new Error(Vt);
|
|
999
|
+
}, De = Je({
|
|
899
1000
|
isAuthenticated: !1,
|
|
900
1001
|
isLoading: !1,
|
|
901
1002
|
login: j,
|
|
@@ -903,135 +1004,135 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
903
1004
|
getAccessToken: j,
|
|
904
1005
|
getIdToken: j,
|
|
905
1006
|
logoutReason: ""
|
|
906
|
-
}),
|
|
1007
|
+
}), Zt = ({
|
|
907
1008
|
children: e,
|
|
908
1009
|
sessionExpiration: t,
|
|
909
|
-
clientId:
|
|
1010
|
+
clientId: r
|
|
910
1011
|
}) => {
|
|
911
|
-
const [
|
|
912
|
-
key: `${x}::${
|
|
913
|
-
}), [
|
|
914
|
-
key: `${x}::${
|
|
915
|
-
}), [u,
|
|
1012
|
+
const [a, n, , s] = W({
|
|
1013
|
+
key: `${x}::${r}::@@user@@`
|
|
1014
|
+
}), [o, i, , c] = W({
|
|
1015
|
+
key: `${x}::${r}::@@access@@`
|
|
1016
|
+
}), [u, f, , p] = W(
|
|
916
1017
|
{
|
|
917
|
-
key: `${x}::${
|
|
1018
|
+
key: `${x}::${r}::@@refresh@@`
|
|
918
1019
|
}
|
|
919
|
-
), [
|
|
920
|
-
key: `${x}::${
|
|
921
|
-
}), [
|
|
1020
|
+
), [_, S, , m] = W({
|
|
1021
|
+
key: `${x}::${r}::@@nonce@@`
|
|
1022
|
+
}), [k, N] = xe({
|
|
922
1023
|
isLoading: !0,
|
|
923
1024
|
isAuthenticated: !1,
|
|
924
1025
|
userId: "",
|
|
925
1026
|
logoutReason: ""
|
|
926
|
-
}), A =
|
|
1027
|
+
}), A = je(
|
|
927
1028
|
(w) => {
|
|
928
|
-
|
|
1029
|
+
N({
|
|
929
1030
|
isLoading: !1,
|
|
930
1031
|
isAuthenticated: !1,
|
|
931
1032
|
userId: "",
|
|
932
|
-
logoutReason: w ||
|
|
1033
|
+
logoutReason: w || re
|
|
933
1034
|
}), s(), c(), p(), m();
|
|
934
1035
|
},
|
|
935
1036
|
[s, c, m, p]
|
|
936
1037
|
);
|
|
937
|
-
|
|
938
|
-
|
|
1038
|
+
Me(() => {
|
|
1039
|
+
k.isLoading && a !== null && (async () => {
|
|
939
1040
|
try {
|
|
940
|
-
const w = await
|
|
941
|
-
w && w.payload[
|
|
1041
|
+
const w = await H(a);
|
|
1042
|
+
w && w.payload[y.USER_ID_KEY] !== "" ? N({
|
|
942
1043
|
isLoading: !1,
|
|
943
1044
|
isAuthenticated: !0,
|
|
944
|
-
userId: w.payload[
|
|
1045
|
+
userId: w.payload[y.USER_ID_KEY],
|
|
945
1046
|
logoutReason: ""
|
|
946
|
-
}) : (A(
|
|
947
|
-
idToken:
|
|
948
|
-
accessToken:
|
|
1047
|
+
}) : (A(re), await ae({
|
|
1048
|
+
idToken: a,
|
|
1049
|
+
accessToken: o,
|
|
949
1050
|
refreshToken: u,
|
|
950
|
-
clientId:
|
|
1051
|
+
clientId: r
|
|
951
1052
|
}));
|
|
952
1053
|
} catch {
|
|
953
|
-
A(
|
|
954
|
-
idToken:
|
|
955
|
-
accessToken:
|
|
1054
|
+
A(re), await ae({
|
|
1055
|
+
idToken: a,
|
|
1056
|
+
accessToken: o,
|
|
956
1057
|
refreshToken: u,
|
|
957
|
-
clientId:
|
|
1058
|
+
clientId: r
|
|
958
1059
|
});
|
|
959
1060
|
}
|
|
960
1061
|
})();
|
|
961
1062
|
}, [
|
|
962
|
-
|
|
963
|
-
n,
|
|
964
|
-
r,
|
|
965
|
-
u,
|
|
1063
|
+
k.isLoading,
|
|
966
1064
|
o,
|
|
1065
|
+
a,
|
|
1066
|
+
u,
|
|
1067
|
+
r,
|
|
967
1068
|
A
|
|
968
1069
|
]);
|
|
969
|
-
const
|
|
970
|
-
const
|
|
971
|
-
if (
|
|
972
|
-
const { code_verifier:
|
|
973
|
-
nonce:
|
|
974
|
-
clientId:
|
|
975
|
-
code_challenge:
|
|
1070
|
+
const Ue = async (w, P, I) => {
|
|
1071
|
+
const R = jt();
|
|
1072
|
+
if (S(R), I === B.CODE) {
|
|
1073
|
+
const { code_verifier: $e, code_challenge: Le } = await Nt(), se = await Ft({
|
|
1074
|
+
nonce: R,
|
|
1075
|
+
clientId: r,
|
|
1076
|
+
code_challenge: Le
|
|
976
1077
|
});
|
|
977
|
-
if (
|
|
978
|
-
const
|
|
1078
|
+
if (se.status) {
|
|
1079
|
+
const O = await ge({
|
|
979
1080
|
username: w,
|
|
980
|
-
password:
|
|
981
|
-
clientId:
|
|
1081
|
+
password: P,
|
|
1082
|
+
clientId: r,
|
|
982
1083
|
sessionExpiration: t,
|
|
983
|
-
nonce:
|
|
984
|
-
type:
|
|
985
|
-
code:
|
|
986
|
-
code_verifier:
|
|
1084
|
+
nonce: R,
|
|
1085
|
+
type: I,
|
|
1086
|
+
code: se.code,
|
|
1087
|
+
code_verifier: $e
|
|
987
1088
|
});
|
|
988
|
-
return
|
|
1089
|
+
return O.status ? (n(O.idToken), i(O.accessToken), f(O.refreshToken), N({
|
|
989
1090
|
isLoading: !1,
|
|
990
1091
|
isAuthenticated: !0,
|
|
991
|
-
userId:
|
|
1092
|
+
userId: O.userId,
|
|
992
1093
|
logoutReason: ""
|
|
993
|
-
}), !0) : (A(
|
|
1094
|
+
}), !0) : (A(Se), !1);
|
|
994
1095
|
}
|
|
995
1096
|
return !1;
|
|
996
1097
|
}
|
|
997
|
-
const
|
|
1098
|
+
const E = await ge({
|
|
998
1099
|
username: w,
|
|
999
|
-
password:
|
|
1000
|
-
clientId:
|
|
1100
|
+
password: P,
|
|
1101
|
+
clientId: r,
|
|
1001
1102
|
sessionExpiration: t,
|
|
1002
|
-
nonce:
|
|
1003
|
-
type:
|
|
1103
|
+
nonce: R,
|
|
1104
|
+
type: I
|
|
1004
1105
|
});
|
|
1005
|
-
return
|
|
1106
|
+
return E.status ? (n(E.idToken), i(E.accessToken), f(E.refreshToken), N({
|
|
1006
1107
|
isLoading: !1,
|
|
1007
1108
|
isAuthenticated: !0,
|
|
1008
|
-
userId:
|
|
1009
|
-
}), !0) : (A(
|
|
1010
|
-
},
|
|
1011
|
-
A(
|
|
1012
|
-
idToken:
|
|
1013
|
-
accessToken:
|
|
1109
|
+
userId: E.userId
|
|
1110
|
+
}), !0) : (A(Se), !1);
|
|
1111
|
+
}, He = async () => {
|
|
1112
|
+
A(Mt), await ae({
|
|
1113
|
+
idToken: a,
|
|
1114
|
+
accessToken: o,
|
|
1014
1115
|
refreshToken: u,
|
|
1015
|
-
clientId:
|
|
1116
|
+
clientId: r
|
|
1016
1117
|
});
|
|
1017
|
-
},
|
|
1018
|
-
const { isAuthenticated: w, userId:
|
|
1118
|
+
}, Ne = async () => {
|
|
1119
|
+
const { isAuthenticated: w, userId: P } = k;
|
|
1019
1120
|
try {
|
|
1020
|
-
if (w &&
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1023
|
-
return
|
|
1024
|
-
const
|
|
1025
|
-
if (
|
|
1026
|
-
const
|
|
1027
|
-
clientId:
|
|
1028
|
-
userId:
|
|
1029
|
-
nonce:
|
|
1121
|
+
if (w && P && o) {
|
|
1122
|
+
const I = await H(o);
|
|
1123
|
+
if (I && I.payload[y.USER_ID_KEY] !== "")
|
|
1124
|
+
return o;
|
|
1125
|
+
const R = await H(u);
|
|
1126
|
+
if (R && R.payload[y.USER_ID_KEY] !== "") {
|
|
1127
|
+
const E = await Gt({
|
|
1128
|
+
clientId: r,
|
|
1129
|
+
userId: P,
|
|
1130
|
+
nonce: _,
|
|
1030
1131
|
refreshToken: u,
|
|
1031
|
-
accessToken:
|
|
1132
|
+
accessToken: o
|
|
1032
1133
|
});
|
|
1033
|
-
if (
|
|
1034
|
-
return i(
|
|
1134
|
+
if (E.status)
|
|
1135
|
+
return i(E.accessToken), f(E.refreshToken), E.accessToken;
|
|
1035
1136
|
A(U);
|
|
1036
1137
|
}
|
|
1037
1138
|
return A(U), console.error(U), "";
|
|
@@ -1039,20 +1140,20 @@ const Q = "Oops! It looks like your session has expired. For your security, plea
|
|
|
1039
1140
|
} catch {
|
|
1040
1141
|
return A(U), console.error(U), "";
|
|
1041
1142
|
}
|
|
1042
|
-
},
|
|
1043
|
-
if (
|
|
1044
|
-
return
|
|
1143
|
+
}, Ke = () => {
|
|
1144
|
+
if (k.isAuthenticated && a)
|
|
1145
|
+
return a;
|
|
1045
1146
|
};
|
|
1046
|
-
return /* @__PURE__ */
|
|
1047
|
-
|
|
1147
|
+
return /* @__PURE__ */ We(
|
|
1148
|
+
De.Provider,
|
|
1048
1149
|
{
|
|
1049
|
-
value: { ...
|
|
1150
|
+
value: { ...k, login: Ue, logout: He, getAccessToken: Ne, getIdToken: Ke },
|
|
1050
1151
|
children: e
|
|
1051
1152
|
}
|
|
1052
1153
|
);
|
|
1053
|
-
},
|
|
1154
|
+
}, er = (e = De) => Ve(e);
|
|
1054
1155
|
export {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1156
|
+
B as AUTH_TYPES,
|
|
1157
|
+
Zt as AuthProvider,
|
|
1158
|
+
er as useAuth
|
|
1058
1159
|
};
|