@crossauth/common 1.0.1 → 1.1.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 +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +393 -280
- package/dist/interfaces.d.ts +7 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/oauth/tokenconsumer.d.ts +2 -2
- package/dist/oauth/tokenconsumer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var ye = Object.defineProperty;
|
|
2
|
+
var Y = (e) => {
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var a = (e, t, r) =>
|
|
7
|
-
var p = (e, t, r) => (
|
|
8
|
-
class
|
|
5
|
+
var me = (e, t, r) => t in e ? ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
6
|
+
var a = (e, t, r) => me(e, typeof t != "symbol" ? t + "" : t, r), X = (e, t, r) => t.has(e) || Y("Cannot " + r);
|
|
7
|
+
var p = (e, t, r) => (X(e, t, "read from private field"), r ? r.call(e) : t.get(e)), $ = (e, t, r) => t.has(e) ? Y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), D = (e, t, r, n) => (X(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
|
|
8
|
+
class E {
|
|
9
9
|
}
|
|
10
10
|
/** Ordinary, active user who can log in freely */
|
|
11
|
-
a(
|
|
12
|
-
a(
|
|
11
|
+
a(E, "active", "active"), /** Deactivated account. User cannot log in */
|
|
12
|
+
a(E, "disabled", "disabled"), /** Two factor authentication has been actived for this user
|
|
13
13
|
* but has not yet been configured. Once a user logs in,
|
|
14
14
|
* they will be directed to a page to configure 2FA and will
|
|
15
15
|
* not be able to do anything else (that requires login) until
|
|
16
16
|
* they have done so.
|
|
17
17
|
*/
|
|
18
|
-
a(
|
|
18
|
+
a(E, "awaitingTwoFactorSetup", "awaitingtwofactorsetup"), /** Two factor authentication has been actived for this user
|
|
19
|
+
* but has not yet been configured. Once a user logs in,
|
|
20
|
+
* they will be directed to a page to configure 2FA and will
|
|
21
|
+
* not be able to do anything else (that requires login) until
|
|
22
|
+
* they have done so. They will then have to verify their email
|
|
23
|
+
*/
|
|
24
|
+
a(E, "awaitingTwoFactorSetupAndEmailVerification", "awaitingtwofactorsetupandemailverification"), /** Email verification has been turned on but user has not
|
|
19
25
|
* verified his or her email address. Cannot log on until it has
|
|
20
26
|
* been verified.
|
|
21
27
|
*/
|
|
22
|
-
a(
|
|
28
|
+
a(E, "awaitingEmailVerification", "awaitingemailverification"), /**
|
|
23
29
|
* If the state is set to this, the user may not access any
|
|
24
30
|
* login-required functions unless he or she has changed their password.
|
|
25
31
|
*
|
|
26
32
|
* Upon login, the user is redirected to the change password page.
|
|
27
33
|
*/
|
|
28
|
-
a(
|
|
34
|
+
a(E, "passwordChangeNeeded", "passwordchangeneeded"), /**
|
|
29
35
|
* If the state is set to this, the user may not access any
|
|
30
36
|
* login-required functions unless he or she has reset their password.
|
|
31
37
|
*
|
|
32
38
|
* Upon login, the user is redirected to the reset password page.
|
|
33
39
|
*/
|
|
34
|
-
a(
|
|
40
|
+
a(E, "passwordResetNeeded", "passwordresetneeded"), /**
|
|
35
41
|
* If the state is set to this, the user may not access any
|
|
36
42
|
* login-required functions unless he or she has reset their second
|
|
37
43
|
* factor configuration.
|
|
@@ -42,27 +48,27 @@ a(P, "passwordResetNeeded", "passwordresetneeded"), /**
|
|
|
42
48
|
* this value and the user will then be prompted to configure 2FA
|
|
43
49
|
* upon login.
|
|
44
50
|
*/
|
|
45
|
-
a(
|
|
51
|
+
a(E, "factor2ResetNeeded", "factor2resetneeded"), /**
|
|
46
52
|
* If the state is set to this, the user may not access any
|
|
47
53
|
* login-required functions unless he or she has reset their password
|
|
48
54
|
* and then resets factor2.
|
|
49
55
|
*
|
|
50
56
|
* Upon login, the user is redirected to the reset password page.
|
|
51
57
|
*/
|
|
52
|
-
a(
|
|
53
|
-
class
|
|
58
|
+
a(E, "passwordAndFactor2ResetNeeded", "passwordandfactor2resetneeded");
|
|
59
|
+
class A {
|
|
54
60
|
}
|
|
55
61
|
/** Session ID */
|
|
56
|
-
a(
|
|
57
|
-
a(
|
|
58
|
-
a(
|
|
59
|
-
a(
|
|
60
|
-
a(
|
|
61
|
-
a(
|
|
62
|
-
a(
|
|
63
|
-
a(
|
|
64
|
-
a(
|
|
65
|
-
a(
|
|
62
|
+
a(A, "session", "s:"), /** Password Reset Token */
|
|
63
|
+
a(A, "passwordResetToken", "p:"), /** Email verification token */
|
|
64
|
+
a(A, "emailVerificationToken", "e:"), /** API key */
|
|
65
|
+
a(A, "apiKey", "api:"), /** OAuth authorization code */
|
|
66
|
+
a(A, "authorizationCode", "authz:"), /** OAuth access token */
|
|
67
|
+
a(A, "accessToken", "access:"), /** OAuth refresh token */
|
|
68
|
+
a(A, "refreshToken", "refresh:"), /** OAuth MFA key (used by the password MFA flow) */
|
|
69
|
+
a(A, "mfaToken", "omfa:"), /** Device code device code */
|
|
70
|
+
a(A, "deviceCode", "dc:"), /** Device code flow user code */
|
|
71
|
+
a(A, "userCode", "uc:");
|
|
66
72
|
var y = /* @__PURE__ */ ((e) => (e[e.UserNotExist = 0] = "UserNotExist", e[e.PasswordInvalid = 1] = "PasswordInvalid", e[e.EmailNotExist = 2] = "EmailNotExist", e[e.UsernameOrPasswordInvalid = 3] = "UsernameOrPasswordInvalid", e[e.InvalidClientId = 4] = "InvalidClientId", e[e.ClientExists = 5] = "ClientExists", e[e.InvalidClientSecret = 6] = "InvalidClientSecret", e[e.InvalidClientIdOrSecret = 7] = "InvalidClientIdOrSecret", e[e.InvalidRedirectUri = 8] = "InvalidRedirectUri", e[e.InvalidOAuthFlow = 9] = "InvalidOAuthFlow", e[e.UserNotActive = 10] = "UserNotActive", e[e.EmailNotVerified = 11] = "EmailNotVerified", e[e.TwoFactorIncomplete = 12] = "TwoFactorIncomplete", e[e.Unauthorized = 13] = "Unauthorized", e[e.UnauthorizedClient = 14] = "UnauthorizedClient", e[e.InvalidScope = 15] = "InvalidScope", e[e.InsufficientScope = 16] = "InsufficientScope", e[e.InsufficientPriviledges = 17] = "InsufficientPriviledges", e[e.Forbidden = 18] = "Forbidden", e[e.InvalidKey = 19] = "InvalidKey", e[e.InvalidCsrf = 20] = "InvalidCsrf", e[e.InvalidSession = 21] = "InvalidSession", e[e.Expired = 22] = "Expired", e[e.Connection = 23] = "Connection", e[e.InvalidHash = 24] = "InvalidHash", e[e.UnsupportedAlgorithm = 25] = "UnsupportedAlgorithm", e[e.KeyExists = 26] = "KeyExists", e[e.PasswordChangeNeeded = 27] = "PasswordChangeNeeded", e[e.PasswordResetNeeded = 28] = "PasswordResetNeeded", e[e.Factor2ResetNeeded = 29] = "Factor2ResetNeeded", e[e.Configuration = 30] = "Configuration", e[e.InvalidEmail = 31] = "InvalidEmail", e[e.InvalidPhoneNumber = 32] = "InvalidPhoneNumber", e[e.InvalidUsername = 33] = "InvalidUsername", e[e.PasswordMatch = 34] = "PasswordMatch", e[e.InvalidToken = 35] = "InvalidToken", e[e.MfaRequired = 36] = "MfaRequired", e[e.PasswordFormat = 37] = "PasswordFormat", e[e.DataFormat = 38] = "DataFormat", e[e.FetchError = 39] = "FetchError", e[e.UserExists = 40] = "UserExists", e[e.FormEntry = 41] = "FormEntry", e[e.BadRequest = 42] = "BadRequest", e[e.AuthorizationPending = 43] = "AuthorizationPending", e[e.SlowDown = 44] = "SlowDown", e[e.ExpiredToken = 45] = "ExpiredToken", e[e.ConstraintViolation = 46] = "ConstraintViolation", e[e.NotImplemented = 47] = "NotImplemented", e[e.UnknownError = 48] = "UnknownError", e))(y || {});
|
|
67
73
|
class g extends Error {
|
|
68
74
|
/**
|
|
@@ -205,10 +211,10 @@ class g extends Error {
|
|
|
205
211
|
return "message" in r && (i = r.message), new g(48, i);
|
|
206
212
|
}
|
|
207
213
|
}
|
|
208
|
-
function
|
|
209
|
-
return typeof e == "number" && (e = "" + e), e in
|
|
214
|
+
function it(e) {
|
|
215
|
+
return typeof e == "number" && (e = "" + e), e in B ? B[e] : B[500];
|
|
210
216
|
}
|
|
211
|
-
const
|
|
217
|
+
const B = {
|
|
212
218
|
200: "OK",
|
|
213
219
|
201: "Created",
|
|
214
220
|
202: "Accepted",
|
|
@@ -350,7 +356,7 @@ function u(e) {
|
|
|
350
356
|
}
|
|
351
357
|
globalThis.crossauthLogger = new l();
|
|
352
358
|
globalThis.crossauthLoggerAcceptsJson = !0;
|
|
353
|
-
const
|
|
359
|
+
const ie = {
|
|
354
360
|
issuer: "",
|
|
355
361
|
authorization_endpoint: "",
|
|
356
362
|
token_endpoint: "",
|
|
@@ -365,79 +371,129 @@ const Z = {
|
|
|
365
371
|
request_parameter_supported: !1,
|
|
366
372
|
request_uri_parameter_supported: !0,
|
|
367
373
|
require_request_uri_registration: !1
|
|
368
|
-
},
|
|
369
|
-
function
|
|
374
|
+
}, q = crypto, ne = (e) => e instanceof CryptoKey, M = new TextEncoder(), H = new TextDecoder();
|
|
375
|
+
function we(...e) {
|
|
370
376
|
const t = e.reduce((i, { length: o }) => i + o, 0), r = new Uint8Array(t);
|
|
371
377
|
let n = 0;
|
|
372
378
|
for (const i of e)
|
|
373
379
|
r.set(i, n), n += i.length;
|
|
374
380
|
return r;
|
|
375
381
|
}
|
|
376
|
-
const
|
|
382
|
+
const _e = (e) => {
|
|
377
383
|
const t = atob(e), r = new Uint8Array(t.length);
|
|
378
384
|
for (let n = 0; n < t.length; n++)
|
|
379
385
|
r[n] = t.charCodeAt(n);
|
|
380
386
|
return r;
|
|
381
|
-
},
|
|
387
|
+
}, K = (e) => {
|
|
382
388
|
let t = e;
|
|
383
|
-
t instanceof Uint8Array && (t =
|
|
389
|
+
t instanceof Uint8Array && (t = H.decode(t)), t = t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
|
|
384
390
|
try {
|
|
385
|
-
return
|
|
391
|
+
return _e(t);
|
|
386
392
|
} catch {
|
|
387
393
|
throw new TypeError("The input to be decoded is not correctly encoded.");
|
|
388
394
|
}
|
|
389
395
|
};
|
|
390
|
-
class
|
|
391
|
-
|
|
392
|
-
|
|
396
|
+
class S extends Error {
|
|
397
|
+
constructor(t, r) {
|
|
398
|
+
var n;
|
|
399
|
+
super(t, r), this.code = "ERR_JOSE_GENERIC", this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
|
|
393
400
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
401
|
+
}
|
|
402
|
+
S.code = "ERR_JOSE_GENERIC";
|
|
403
|
+
class ve extends S {
|
|
404
|
+
constructor(t, r, n = "unspecified", i = "unspecified") {
|
|
405
|
+
super(t, { cause: { claim: n, reason: i, payload: r } }), this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED", this.claim = n, this.reason = i, this.payload = r;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
ve.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
409
|
+
class Se extends S {
|
|
410
|
+
constructor(t, r, n = "unspecified", i = "unspecified") {
|
|
411
|
+
super(t, { cause: { claim: n, reason: i, payload: r } }), this.code = "ERR_JWT_EXPIRED", this.claim = n, this.reason = i, this.payload = r;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
Se.code = "ERR_JWT_EXPIRED";
|
|
415
|
+
class be extends S {
|
|
416
|
+
constructor() {
|
|
417
|
+
super(...arguments), this.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
397
418
|
}
|
|
398
419
|
}
|
|
399
|
-
|
|
420
|
+
be.code = "ERR_JOSE_ALG_NOT_ALLOWED";
|
|
421
|
+
class C extends S {
|
|
400
422
|
constructor() {
|
|
401
423
|
super(...arguments), this.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
402
424
|
}
|
|
403
|
-
|
|
404
|
-
|
|
425
|
+
}
|
|
426
|
+
C.code = "ERR_JOSE_NOT_SUPPORTED";
|
|
427
|
+
class Ce extends S {
|
|
428
|
+
constructor(t = "decryption operation failed", r) {
|
|
429
|
+
super(t, r), this.code = "ERR_JWE_DECRYPTION_FAILED";
|
|
405
430
|
}
|
|
406
431
|
}
|
|
407
|
-
|
|
432
|
+
Ce.code = "ERR_JWE_DECRYPTION_FAILED";
|
|
433
|
+
class Ae extends S {
|
|
408
434
|
constructor() {
|
|
409
|
-
super(...arguments), this.code = "
|
|
435
|
+
super(...arguments), this.code = "ERR_JWE_INVALID";
|
|
410
436
|
}
|
|
411
|
-
|
|
412
|
-
|
|
437
|
+
}
|
|
438
|
+
Ae.code = "ERR_JWE_INVALID";
|
|
439
|
+
class w extends S {
|
|
440
|
+
constructor() {
|
|
441
|
+
super(...arguments), this.code = "ERR_JWS_INVALID";
|
|
413
442
|
}
|
|
414
443
|
}
|
|
415
|
-
|
|
444
|
+
w.code = "ERR_JWS_INVALID";
|
|
445
|
+
class P extends S {
|
|
416
446
|
constructor() {
|
|
417
447
|
super(...arguments), this.code = "ERR_JWT_INVALID";
|
|
418
448
|
}
|
|
419
|
-
|
|
420
|
-
|
|
449
|
+
}
|
|
450
|
+
P.code = "ERR_JWT_INVALID";
|
|
451
|
+
class Ie extends S {
|
|
452
|
+
constructor() {
|
|
453
|
+
super(...arguments), this.code = "ERR_JWK_INVALID";
|
|
421
454
|
}
|
|
422
455
|
}
|
|
423
|
-
|
|
456
|
+
Ie.code = "ERR_JWK_INVALID";
|
|
457
|
+
class Ee extends S {
|
|
424
458
|
constructor() {
|
|
425
|
-
super(...arguments), this.code = "
|
|
459
|
+
super(...arguments), this.code = "ERR_JWKS_INVALID";
|
|
426
460
|
}
|
|
427
|
-
|
|
428
|
-
|
|
461
|
+
}
|
|
462
|
+
Ee.code = "ERR_JWKS_INVALID";
|
|
463
|
+
class Te extends S {
|
|
464
|
+
constructor(t = "no applicable key found in the JSON Web Key Set", r) {
|
|
465
|
+
super(t, r), this.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
429
466
|
}
|
|
430
467
|
}
|
|
431
|
-
|
|
468
|
+
Te.code = "ERR_JWKS_NO_MATCHING_KEY";
|
|
469
|
+
class Re extends S {
|
|
470
|
+
constructor(t = "multiple matching keys found in the JSON Web Key Set", r) {
|
|
471
|
+
super(t, r), this.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
Re.code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
|
|
475
|
+
class Pe extends S {
|
|
476
|
+
constructor(t = "request timed out", r) {
|
|
477
|
+
super(t, r), this.code = "ERR_JWKS_TIMEOUT";
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
Pe.code = "ERR_JWKS_TIMEOUT";
|
|
481
|
+
class oe extends S {
|
|
482
|
+
constructor(t = "signature verification failed", r) {
|
|
483
|
+
super(t, r), this.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
oe.code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
|
|
487
|
+
function I(e, t = "algorithm.name") {
|
|
432
488
|
return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`);
|
|
433
489
|
}
|
|
434
490
|
function z(e, t) {
|
|
435
491
|
return e.name === t;
|
|
436
492
|
}
|
|
437
|
-
function
|
|
493
|
+
function V(e) {
|
|
438
494
|
return parseInt(e.name.slice(4), 10);
|
|
439
495
|
}
|
|
440
|
-
function
|
|
496
|
+
function ke(e) {
|
|
441
497
|
switch (e) {
|
|
442
498
|
case "ES256":
|
|
443
499
|
return "P-256";
|
|
@@ -449,7 +505,7 @@ function ye(e) {
|
|
|
449
505
|
throw new Error("unreachable");
|
|
450
506
|
}
|
|
451
507
|
}
|
|
452
|
-
function
|
|
508
|
+
function Ke(e, t) {
|
|
453
509
|
if (t.length && !t.some((r) => e.usages.includes(r))) {
|
|
454
510
|
let r = "CryptoKey does not support this operation, its usages must include ";
|
|
455
511
|
if (t.length > 2) {
|
|
@@ -459,71 +515,76 @@ function me(e, t) {
|
|
|
459
515
|
throw new TypeError(r);
|
|
460
516
|
}
|
|
461
517
|
}
|
|
462
|
-
function
|
|
518
|
+
function Oe(e, t, ...r) {
|
|
463
519
|
switch (t) {
|
|
464
520
|
case "HS256":
|
|
465
521
|
case "HS384":
|
|
466
522
|
case "HS512": {
|
|
467
523
|
if (!z(e.algorithm, "HMAC"))
|
|
468
|
-
throw
|
|
524
|
+
throw I("HMAC");
|
|
469
525
|
const n = parseInt(t.slice(2), 10);
|
|
470
|
-
if (
|
|
471
|
-
throw
|
|
526
|
+
if (V(e.algorithm.hash) !== n)
|
|
527
|
+
throw I(`SHA-${n}`, "algorithm.hash");
|
|
472
528
|
break;
|
|
473
529
|
}
|
|
474
530
|
case "RS256":
|
|
475
531
|
case "RS384":
|
|
476
532
|
case "RS512": {
|
|
477
533
|
if (!z(e.algorithm, "RSASSA-PKCS1-v1_5"))
|
|
478
|
-
throw
|
|
534
|
+
throw I("RSASSA-PKCS1-v1_5");
|
|
479
535
|
const n = parseInt(t.slice(2), 10);
|
|
480
|
-
if (
|
|
481
|
-
throw
|
|
536
|
+
if (V(e.algorithm.hash) !== n)
|
|
537
|
+
throw I(`SHA-${n}`, "algorithm.hash");
|
|
482
538
|
break;
|
|
483
539
|
}
|
|
484
540
|
case "PS256":
|
|
485
541
|
case "PS384":
|
|
486
542
|
case "PS512": {
|
|
487
543
|
if (!z(e.algorithm, "RSA-PSS"))
|
|
488
|
-
throw
|
|
544
|
+
throw I("RSA-PSS");
|
|
489
545
|
const n = parseInt(t.slice(2), 10);
|
|
490
|
-
if (
|
|
491
|
-
throw
|
|
546
|
+
if (V(e.algorithm.hash) !== n)
|
|
547
|
+
throw I(`SHA-${n}`, "algorithm.hash");
|
|
492
548
|
break;
|
|
493
549
|
}
|
|
494
550
|
case "EdDSA": {
|
|
495
551
|
if (e.algorithm.name !== "Ed25519" && e.algorithm.name !== "Ed448")
|
|
496
|
-
throw
|
|
552
|
+
throw I("Ed25519 or Ed448");
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
case "Ed25519": {
|
|
556
|
+
if (!z(e.algorithm, "Ed25519"))
|
|
557
|
+
throw I("Ed25519");
|
|
497
558
|
break;
|
|
498
559
|
}
|
|
499
560
|
case "ES256":
|
|
500
561
|
case "ES384":
|
|
501
562
|
case "ES512": {
|
|
502
563
|
if (!z(e.algorithm, "ECDSA"))
|
|
503
|
-
throw
|
|
504
|
-
const n =
|
|
564
|
+
throw I("ECDSA");
|
|
565
|
+
const n = ke(t);
|
|
505
566
|
if (e.algorithm.namedCurve !== n)
|
|
506
|
-
throw
|
|
567
|
+
throw I(n, "algorithm.namedCurve");
|
|
507
568
|
break;
|
|
508
569
|
}
|
|
509
570
|
default:
|
|
510
571
|
throw new TypeError("CryptoKey does not support this operation");
|
|
511
572
|
}
|
|
512
|
-
|
|
573
|
+
Ke(e, r);
|
|
513
574
|
}
|
|
514
|
-
function
|
|
575
|
+
function se(e, t, ...r) {
|
|
515
576
|
var n;
|
|
516
|
-
if (r.length > 2) {
|
|
577
|
+
if (r = r.filter(Boolean), r.length > 2) {
|
|
517
578
|
const i = r.pop();
|
|
518
579
|
e += `one of type ${r.join(", ")}, or ${i}.`;
|
|
519
580
|
} else r.length === 2 ? e += `one of type ${r[0]} or ${r[1]}.` : e += `of type ${r[0]}.`;
|
|
520
581
|
return t == null ? e += ` Received ${t}` : typeof t == "function" && t.name ? e += ` Received function ${t.name}` : typeof t == "object" && t != null && (n = t.constructor) != null && n.name && (e += ` Received an instance of ${t.constructor.name}`), e;
|
|
521
582
|
}
|
|
522
|
-
const
|
|
523
|
-
function
|
|
524
|
-
return
|
|
583
|
+
const Q = (e, ...t) => se("Key must be ", e, ...t);
|
|
584
|
+
function ae(e, t, ...r) {
|
|
585
|
+
return se(`Key for the ${e} algorithm must be `, t, ...r);
|
|
525
586
|
}
|
|
526
|
-
const
|
|
587
|
+
const ce = (e) => ne(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", L = ["CryptoKey"], We = (...e) => {
|
|
527
588
|
const t = e.filter(Boolean);
|
|
528
589
|
if (t.length === 0 || t.length === 1)
|
|
529
590
|
return !0;
|
|
@@ -542,11 +603,11 @@ const ie = (e) => ee(e) ? !0 : (e == null ? void 0 : e[Symbol.toStringTag]) ===
|
|
|
542
603
|
}
|
|
543
604
|
return !0;
|
|
544
605
|
};
|
|
545
|
-
function
|
|
606
|
+
function Ne(e) {
|
|
546
607
|
return typeof e == "object" && e !== null;
|
|
547
608
|
}
|
|
548
|
-
function
|
|
549
|
-
if (!
|
|
609
|
+
function x(e) {
|
|
610
|
+
if (!Ne(e) || Object.prototype.toString.call(e) !== "[object Object]")
|
|
550
611
|
return !1;
|
|
551
612
|
if (Object.getPrototypeOf(e) === null)
|
|
552
613
|
return !0;
|
|
@@ -555,14 +616,26 @@ function U(e) {
|
|
|
555
616
|
t = Object.getPrototypeOf(t);
|
|
556
617
|
return Object.getPrototypeOf(e) === t;
|
|
557
618
|
}
|
|
558
|
-
const
|
|
619
|
+
const Je = (e, t) => {
|
|
559
620
|
if (e.startsWith("RS") || e.startsWith("PS")) {
|
|
560
621
|
const { modulusLength: r } = t.algorithm;
|
|
561
622
|
if (typeof r != "number" || r < 2048)
|
|
562
623
|
throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`);
|
|
563
624
|
}
|
|
564
625
|
};
|
|
565
|
-
function
|
|
626
|
+
function U(e) {
|
|
627
|
+
return x(e) && typeof e.kty == "string";
|
|
628
|
+
}
|
|
629
|
+
function xe(e) {
|
|
630
|
+
return e.kty !== "oct" && typeof e.d == "string";
|
|
631
|
+
}
|
|
632
|
+
function Ue(e) {
|
|
633
|
+
return e.kty !== "oct" && typeof e.d > "u";
|
|
634
|
+
}
|
|
635
|
+
function De(e) {
|
|
636
|
+
return U(e) && e.kty === "oct" && typeof e.k == "string";
|
|
637
|
+
}
|
|
638
|
+
function ze(e) {
|
|
566
639
|
let t, r;
|
|
567
640
|
switch (e.kty) {
|
|
568
641
|
case "RSA": {
|
|
@@ -587,7 +660,7 @@ function Ce(e) {
|
|
|
587
660
|
}, r = e.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
|
|
588
661
|
break;
|
|
589
662
|
default:
|
|
590
|
-
throw new
|
|
663
|
+
throw new C('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
591
664
|
}
|
|
592
665
|
break;
|
|
593
666
|
}
|
|
@@ -609,12 +682,15 @@ function Ce(e) {
|
|
|
609
682
|
t = { name: "ECDH", namedCurve: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
610
683
|
break;
|
|
611
684
|
default:
|
|
612
|
-
throw new
|
|
685
|
+
throw new C('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
613
686
|
}
|
|
614
687
|
break;
|
|
615
688
|
}
|
|
616
689
|
case "OKP": {
|
|
617
690
|
switch (e.alg) {
|
|
691
|
+
case "Ed25519":
|
|
692
|
+
t = { name: "Ed25519" }, r = e.d ? ["sign"] : ["verify"];
|
|
693
|
+
break;
|
|
618
694
|
case "EdDSA":
|
|
619
695
|
t = { name: e.crv }, r = e.d ? ["sign"] : ["verify"];
|
|
620
696
|
break;
|
|
@@ -625,71 +701,71 @@ function Ce(e) {
|
|
|
625
701
|
t = { name: e.crv }, r = e.d ? ["deriveBits"] : [];
|
|
626
702
|
break;
|
|
627
703
|
default:
|
|
628
|
-
throw new
|
|
704
|
+
throw new C('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
629
705
|
}
|
|
630
706
|
break;
|
|
631
707
|
}
|
|
632
708
|
default:
|
|
633
|
-
throw new
|
|
709
|
+
throw new C('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
634
710
|
}
|
|
635
711
|
return { algorithm: t, keyUsages: r };
|
|
636
712
|
}
|
|
637
|
-
const
|
|
713
|
+
const de = async (e) => {
|
|
638
714
|
if (!e.alg)
|
|
639
715
|
throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
|
|
640
|
-
const { algorithm: t, keyUsages: r } =
|
|
716
|
+
const { algorithm: t, keyUsages: r } = ze(e), n = [
|
|
641
717
|
t,
|
|
642
718
|
e.ext ?? !1,
|
|
643
719
|
e.key_ops ?? r
|
|
644
720
|
], i = { ...e };
|
|
645
|
-
return delete i.alg, delete i.use,
|
|
646
|
-
},
|
|
647
|
-
let
|
|
648
|
-
const
|
|
649
|
-
let
|
|
650
|
-
if (
|
|
651
|
-
return
|
|
652
|
-
const
|
|
653
|
-
return i ?
|
|
654
|
-
},
|
|
655
|
-
if (
|
|
721
|
+
return delete i.alg, delete i.use, q.subtle.importKey("jwk", i, ...n);
|
|
722
|
+
}, le = (e) => K(e);
|
|
723
|
+
let W, N;
|
|
724
|
+
const ue = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject", F = async (e, t, r, n, i = !1) => {
|
|
725
|
+
let o = e.get(t);
|
|
726
|
+
if (o != null && o[n])
|
|
727
|
+
return o[n];
|
|
728
|
+
const s = await de({ ...r, alg: n });
|
|
729
|
+
return i && Object.freeze(t), o ? o[n] = s : e.set(t, { [n]: s }), s;
|
|
730
|
+
}, He = (e, t) => {
|
|
731
|
+
if (ue(e)) {
|
|
656
732
|
let r = e.export({ format: "jwk" });
|
|
657
|
-
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ?
|
|
733
|
+
return delete r.d, delete r.dp, delete r.dq, delete r.p, delete r.q, delete r.qi, r.k ? le(r.k) : (N || (N = /* @__PURE__ */ new WeakMap()), F(N, e, r, t));
|
|
658
734
|
}
|
|
659
|
-
return e;
|
|
660
|
-
},
|
|
661
|
-
if (
|
|
735
|
+
return U(e) ? e.k ? K(e.k) : (N || (N = /* @__PURE__ */ new WeakMap()), F(N, e, e, t, !0)) : e;
|
|
736
|
+
}, Me = (e, t) => {
|
|
737
|
+
if (ue(e)) {
|
|
662
738
|
let r = e.export({ format: "jwk" });
|
|
663
|
-
return r.k ?
|
|
739
|
+
return r.k ? le(r.k) : (W || (W = /* @__PURE__ */ new WeakMap()), F(W, e, r, t));
|
|
664
740
|
}
|
|
665
|
-
return e;
|
|
666
|
-
},
|
|
741
|
+
return U(e) ? e.k ? K(e.k) : (W || (W = /* @__PURE__ */ new WeakMap()), F(W, e, e, t, !0)) : e;
|
|
742
|
+
}, Le = { normalizePublicKey: He, normalizePrivateKey: Me }, k = (e, t, r = 0) => {
|
|
667
743
|
r === 0 && (t.unshift(t.length), t.unshift(6));
|
|
668
744
|
const n = e.indexOf(t[0], r);
|
|
669
745
|
if (n === -1)
|
|
670
746
|
return !1;
|
|
671
747
|
const i = e.subarray(n, n + t.length);
|
|
672
|
-
return i.length !== t.length ? !1 : i.every((o, s) => o === t[s]) ||
|
|
673
|
-
},
|
|
748
|
+
return i.length !== t.length ? !1 : i.every((o, s) => o === t[s]) || k(e, t, n + 1);
|
|
749
|
+
}, Z = (e) => {
|
|
674
750
|
switch (!0) {
|
|
675
|
-
case
|
|
751
|
+
case k(e, [42, 134, 72, 206, 61, 3, 1, 7]):
|
|
676
752
|
return "P-256";
|
|
677
|
-
case
|
|
753
|
+
case k(e, [43, 129, 4, 0, 34]):
|
|
678
754
|
return "P-384";
|
|
679
|
-
case
|
|
755
|
+
case k(e, [43, 129, 4, 0, 35]):
|
|
680
756
|
return "P-521";
|
|
681
|
-
case
|
|
757
|
+
case k(e, [43, 101, 110]):
|
|
682
758
|
return "X25519";
|
|
683
|
-
case
|
|
759
|
+
case k(e, [43, 101, 111]):
|
|
684
760
|
return "X448";
|
|
685
|
-
case
|
|
761
|
+
case k(e, [43, 101, 112]):
|
|
686
762
|
return "Ed25519";
|
|
687
|
-
case
|
|
763
|
+
case k(e, [43, 101, 113]):
|
|
688
764
|
return "Ed448";
|
|
689
765
|
default:
|
|
690
|
-
throw new
|
|
766
|
+
throw new C("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
691
767
|
}
|
|
692
|
-
},
|
|
768
|
+
}, he = async (e, t, r, n, i) => {
|
|
693
769
|
let o, s;
|
|
694
770
|
const c = new Uint8Array(atob(r.replace(e, "")).split("").map((f) => f.charCodeAt(0))), d = t === "spki";
|
|
695
771
|
switch (n) {
|
|
@@ -725,66 +801,101 @@ const se = (e) => (e == null ? void 0 : e[Symbol.toStringTag]) === "KeyObject",
|
|
|
725
801
|
case "ECDH-ES+A128KW":
|
|
726
802
|
case "ECDH-ES+A192KW":
|
|
727
803
|
case "ECDH-ES+A256KW": {
|
|
728
|
-
const f =
|
|
804
|
+
const f = Z(c);
|
|
729
805
|
o = f.startsWith("P-") ? { name: "ECDH", namedCurve: f } : { name: f }, s = d ? [] : ["deriveBits"];
|
|
730
806
|
break;
|
|
731
807
|
}
|
|
808
|
+
case "Ed25519":
|
|
809
|
+
o = { name: "Ed25519" }, s = d ? ["verify"] : ["sign"];
|
|
810
|
+
break;
|
|
732
811
|
case "EdDSA":
|
|
733
|
-
o = { name:
|
|
812
|
+
o = { name: Z(c) }, s = d ? ["verify"] : ["sign"];
|
|
734
813
|
break;
|
|
735
814
|
default:
|
|
736
|
-
throw new
|
|
815
|
+
throw new C('Invalid or unsupported "alg" (Algorithm) value');
|
|
737
816
|
}
|
|
738
|
-
return
|
|
739
|
-
},
|
|
740
|
-
async function
|
|
817
|
+
return q.subtle.importKey(t, c, o, !1, s);
|
|
818
|
+
}, Fe = (e, t, r) => he(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, "pkcs8", e, t), qe = (e, t, r) => he(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g, "spki", e, t);
|
|
819
|
+
async function $e(e, t, r) {
|
|
741
820
|
if (typeof e != "string" || e.indexOf("-----BEGIN PUBLIC KEY-----") !== 0)
|
|
742
821
|
throw new TypeError('"spki" must be SPKI formatted string');
|
|
743
|
-
return
|
|
822
|
+
return qe(e, t);
|
|
744
823
|
}
|
|
745
|
-
async function
|
|
824
|
+
async function Be(e, t, r) {
|
|
746
825
|
if (typeof e != "string" || e.indexOf("-----BEGIN PRIVATE KEY-----") !== 0)
|
|
747
826
|
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
748
|
-
return
|
|
827
|
+
return Fe(e, t);
|
|
749
828
|
}
|
|
750
|
-
async function
|
|
751
|
-
if (!
|
|
829
|
+
async function j(e, t) {
|
|
830
|
+
if (!x(e))
|
|
752
831
|
throw new TypeError("JWK must be an object");
|
|
753
832
|
switch (t || (t = e.alg), e.kty) {
|
|
754
833
|
case "oct":
|
|
755
834
|
if (typeof e.k != "string" || !e.k)
|
|
756
835
|
throw new TypeError('missing "k" (Key Value) Parameter value');
|
|
757
|
-
return
|
|
836
|
+
return K(e.k);
|
|
758
837
|
case "RSA":
|
|
759
|
-
if (e.oth !== void 0)
|
|
760
|
-
throw new
|
|
838
|
+
if ("oth" in e && e.oth !== void 0)
|
|
839
|
+
throw new C('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
|
|
761
840
|
case "EC":
|
|
762
841
|
case "OKP":
|
|
763
|
-
return
|
|
842
|
+
return de({ ...e, alg: t });
|
|
764
843
|
default:
|
|
765
|
-
throw new
|
|
844
|
+
throw new C('Unsupported "kty" (Key Type) Parameter value');
|
|
766
845
|
}
|
|
767
846
|
}
|
|
768
|
-
const
|
|
847
|
+
const J = (e) => e == null ? void 0 : e[Symbol.toStringTag], G = (e, t, r) => {
|
|
848
|
+
var n, i;
|
|
849
|
+
if (t.use !== void 0 && t.use !== "sig")
|
|
850
|
+
throw new TypeError("Invalid key for this operation, when present its use must be sig");
|
|
851
|
+
if (t.key_ops !== void 0 && ((i = (n = t.key_ops).includes) == null ? void 0 : i.call(n, r)) !== !0)
|
|
852
|
+
throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);
|
|
853
|
+
if (t.alg !== void 0 && t.alg !== e)
|
|
854
|
+
throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`);
|
|
855
|
+
return !0;
|
|
856
|
+
}, Ve = (e, t, r, n) => {
|
|
769
857
|
if (!(t instanceof Uint8Array)) {
|
|
770
|
-
if (
|
|
771
|
-
|
|
858
|
+
if (n && U(t)) {
|
|
859
|
+
if (De(t) && G(e, t, r))
|
|
860
|
+
return;
|
|
861
|
+
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');
|
|
862
|
+
}
|
|
863
|
+
if (!ce(t))
|
|
864
|
+
throw new TypeError(ae(e, t, ...L, "Uint8Array", n ? "JSON Web Key" : null));
|
|
772
865
|
if (t.type !== "secret")
|
|
773
|
-
throw new TypeError(`${
|
|
866
|
+
throw new TypeError(`${J(t)} instances for symmetric algorithms must be of type "secret"`);
|
|
774
867
|
}
|
|
775
|
-
},
|
|
776
|
-
if (
|
|
777
|
-
|
|
868
|
+
}, je = (e, t, r, n) => {
|
|
869
|
+
if (n && U(t))
|
|
870
|
+
switch (r) {
|
|
871
|
+
case "sign":
|
|
872
|
+
if (xe(t) && G(e, t, r))
|
|
873
|
+
return;
|
|
874
|
+
throw new TypeError("JSON Web Key for this operation be a private JWK");
|
|
875
|
+
case "verify":
|
|
876
|
+
if (Ue(t) && G(e, t, r))
|
|
877
|
+
return;
|
|
878
|
+
throw new TypeError("JSON Web Key for this operation be a public JWK");
|
|
879
|
+
}
|
|
880
|
+
if (!ce(t))
|
|
881
|
+
throw new TypeError(ae(e, t, ...L, n ? "JSON Web Key" : null));
|
|
778
882
|
if (t.type === "secret")
|
|
779
|
-
throw new TypeError(`${
|
|
883
|
+
throw new TypeError(`${J(t)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
884
|
+
if (r === "sign" && t.type === "public")
|
|
885
|
+
throw new TypeError(`${J(t)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
886
|
+
if (r === "decrypt" && t.type === "public")
|
|
887
|
+
throw new TypeError(`${J(t)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
780
888
|
if (t.algorithm && r === "verify" && t.type === "private")
|
|
781
|
-
throw new TypeError(`${
|
|
889
|
+
throw new TypeError(`${J(t)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
782
890
|
if (t.algorithm && r === "encrypt" && t.type === "private")
|
|
783
|
-
throw new TypeError(`${
|
|
784
|
-
}, Ke = (e, t, r) => {
|
|
785
|
-
e.startsWith("HS") || e === "dir" || e.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(e) ? Ee(e, t) : Oe(e, t, r);
|
|
891
|
+
throw new TypeError(`${J(t)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
786
892
|
};
|
|
787
|
-
function
|
|
893
|
+
function fe(e, t, r, n) {
|
|
894
|
+
t.startsWith("HS") || t === "dir" || t.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(t) ? Ve(t, r, n, e) : je(t, r, n, e);
|
|
895
|
+
}
|
|
896
|
+
fe.bind(void 0, !1);
|
|
897
|
+
const ee = fe.bind(void 0, !0);
|
|
898
|
+
function Ge(e, t, r, n, i) {
|
|
788
899
|
if (i.crit !== void 0 && (n == null ? void 0 : n.crit) === void 0)
|
|
789
900
|
throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');
|
|
790
901
|
if (!n || n.crit === void 0)
|
|
@@ -795,7 +906,7 @@ function Ue(e, t, r, n, i) {
|
|
|
795
906
|
o = t;
|
|
796
907
|
for (const s of n.crit) {
|
|
797
908
|
if (!o.has(s))
|
|
798
|
-
throw new
|
|
909
|
+
throw new C(`Extension Header Parameter "${s}" is not recognized`);
|
|
799
910
|
if (i[s] === void 0)
|
|
800
911
|
throw new e(`Extension Header Parameter "${s}" is missing`);
|
|
801
912
|
if (o.get(s) && n[s] === void 0)
|
|
@@ -803,7 +914,7 @@ function Ue(e, t, r, n, i) {
|
|
|
803
914
|
}
|
|
804
915
|
return new Set(n.crit);
|
|
805
916
|
}
|
|
806
|
-
function
|
|
917
|
+
function Ye(e, t) {
|
|
807
918
|
const r = `SHA-${e.slice(-3)}`;
|
|
808
919
|
switch (e) {
|
|
809
920
|
case "HS256":
|
|
@@ -822,103 +933,105 @@ function Ne(e, t) {
|
|
|
822
933
|
case "ES384":
|
|
823
934
|
case "ES512":
|
|
824
935
|
return { hash: r, name: "ECDSA", namedCurve: t.namedCurve };
|
|
936
|
+
case "Ed25519":
|
|
937
|
+
return { name: "Ed25519" };
|
|
825
938
|
case "EdDSA":
|
|
826
939
|
return { name: t.name };
|
|
827
940
|
default:
|
|
828
|
-
throw new
|
|
941
|
+
throw new C(`alg ${e} is not supported either by JOSE or your javascript runtime`);
|
|
829
942
|
}
|
|
830
943
|
}
|
|
831
|
-
async function
|
|
832
|
-
if (t = await
|
|
833
|
-
return
|
|
944
|
+
async function Xe(e, t, r) {
|
|
945
|
+
if (t = await Le.normalizePublicKey(t, e), ne(t))
|
|
946
|
+
return Oe(t, e, r), t;
|
|
834
947
|
if (t instanceof Uint8Array) {
|
|
835
948
|
if (!e.startsWith("HS"))
|
|
836
|
-
throw new TypeError(
|
|
837
|
-
return
|
|
949
|
+
throw new TypeError(Q(t, ...L));
|
|
950
|
+
return q.subtle.importKey("raw", t, { hash: `SHA-${e.slice(-3)}`, name: "HMAC" }, !1, [r]);
|
|
838
951
|
}
|
|
839
|
-
throw new TypeError(
|
|
952
|
+
throw new TypeError(Q(t, ...L, "Uint8Array", "JSON Web Key"));
|
|
840
953
|
}
|
|
841
|
-
const
|
|
842
|
-
const i = await
|
|
843
|
-
|
|
844
|
-
const o =
|
|
954
|
+
const Qe = async (e, t, r, n) => {
|
|
955
|
+
const i = await Xe(e, t, "verify");
|
|
956
|
+
Je(e, i);
|
|
957
|
+
const o = Ye(e, i.algorithm);
|
|
845
958
|
try {
|
|
846
|
-
return await
|
|
959
|
+
return await q.subtle.verify(o, i, r, n);
|
|
847
960
|
} catch {
|
|
848
961
|
return !1;
|
|
849
962
|
}
|
|
850
963
|
};
|
|
851
|
-
async function
|
|
852
|
-
if (!
|
|
853
|
-
throw new
|
|
964
|
+
async function Ze(e, t, r) {
|
|
965
|
+
if (!x(e))
|
|
966
|
+
throw new w("Flattened JWS must be an object");
|
|
854
967
|
if (e.protected === void 0 && e.header === void 0)
|
|
855
|
-
throw new
|
|
968
|
+
throw new w('Flattened JWS must have either of the "protected" or "header" members');
|
|
856
969
|
if (e.protected !== void 0 && typeof e.protected != "string")
|
|
857
|
-
throw new
|
|
970
|
+
throw new w("JWS Protected Header incorrect type");
|
|
858
971
|
if (e.payload === void 0)
|
|
859
|
-
throw new
|
|
972
|
+
throw new w("JWS Payload missing");
|
|
860
973
|
if (typeof e.signature != "string")
|
|
861
|
-
throw new
|
|
862
|
-
if (e.header !== void 0 && !
|
|
863
|
-
throw new
|
|
974
|
+
throw new w("JWS Signature missing or incorrect type");
|
|
975
|
+
if (e.header !== void 0 && !x(e.header))
|
|
976
|
+
throw new w("JWS Unprotected Header incorrect type");
|
|
864
977
|
let n = {};
|
|
865
978
|
if (e.protected)
|
|
866
979
|
try {
|
|
867
|
-
const
|
|
868
|
-
n = JSON.parse(
|
|
980
|
+
const ge = K(e.protected);
|
|
981
|
+
n = JSON.parse(H.decode(ge));
|
|
869
982
|
} catch {
|
|
870
|
-
throw new
|
|
983
|
+
throw new w("JWS Protected Header is invalid");
|
|
871
984
|
}
|
|
872
|
-
if (!
|
|
873
|
-
throw new
|
|
985
|
+
if (!We(n, e.header))
|
|
986
|
+
throw new w("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
874
987
|
const i = {
|
|
875
988
|
...n,
|
|
876
989
|
...e.header
|
|
877
|
-
}, o =
|
|
990
|
+
}, o = Ge(w, /* @__PURE__ */ new Map([["b64", !0]]), r == null ? void 0 : r.crit, n, i);
|
|
878
991
|
let s = !0;
|
|
879
992
|
if (o.has("b64") && (s = n.b64, typeof s != "boolean"))
|
|
880
|
-
throw new
|
|
993
|
+
throw new w('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
|
|
881
994
|
const { alg: c } = i;
|
|
882
995
|
if (typeof c != "string" || !c)
|
|
883
|
-
throw new
|
|
996
|
+
throw new w('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
884
997
|
if (s) {
|
|
885
998
|
if (typeof e.payload != "string")
|
|
886
|
-
throw new
|
|
999
|
+
throw new w("JWS Payload must be a string");
|
|
887
1000
|
} else if (typeof e.payload != "string" && !(e.payload instanceof Uint8Array))
|
|
888
|
-
throw new
|
|
1001
|
+
throw new w("JWS Payload must be a string or an Uint8Array instance");
|
|
889
1002
|
let d = !1;
|
|
890
|
-
typeof t == "function"
|
|
891
|
-
const f =
|
|
892
|
-
let
|
|
1003
|
+
typeof t == "function" ? (t = await t(n, e), d = !0, ee(c, t, "verify"), U(t) && (t = await j(t, c))) : ee(c, t, "verify");
|
|
1004
|
+
const f = we(M.encode(e.protected ?? ""), M.encode("."), typeof e.payload == "string" ? M.encode(e.payload) : e.payload);
|
|
1005
|
+
let T;
|
|
893
1006
|
try {
|
|
894
|
-
|
|
1007
|
+
T = K(e.signature);
|
|
895
1008
|
} catch {
|
|
896
|
-
throw new
|
|
1009
|
+
throw new w("Failed to base64url decode the signature");
|
|
897
1010
|
}
|
|
898
|
-
if (!await
|
|
899
|
-
throw new
|
|
900
|
-
let
|
|
1011
|
+
if (!await Qe(c, t, T, f))
|
|
1012
|
+
throw new oe();
|
|
1013
|
+
let b;
|
|
901
1014
|
if (s)
|
|
902
1015
|
try {
|
|
903
|
-
|
|
1016
|
+
b = K(e.payload);
|
|
904
1017
|
} catch {
|
|
905
|
-
throw new
|
|
1018
|
+
throw new w("Failed to base64url decode the payload");
|
|
906
1019
|
}
|
|
907
|
-
else typeof e.payload == "string" ?
|
|
908
|
-
const
|
|
909
|
-
return e.protected !== void 0 && (
|
|
1020
|
+
else typeof e.payload == "string" ? b = M.encode(e.payload) : b = e.payload;
|
|
1021
|
+
const R = { payload: b };
|
|
1022
|
+
return e.protected !== void 0 && (R.protectedHeader = n), e.header !== void 0 && (R.unprotectedHeader = e.header), d ? { ...R, key: t } : R;
|
|
910
1023
|
}
|
|
911
|
-
async function
|
|
912
|
-
if (e instanceof Uint8Array && (e =
|
|
913
|
-
throw new
|
|
1024
|
+
async function et(e, t, r) {
|
|
1025
|
+
if (e instanceof Uint8Array && (e = H.decode(e)), typeof e != "string")
|
|
1026
|
+
throw new w("Compact JWS must be a string or Uint8Array");
|
|
914
1027
|
const { 0: n, 1: i, 2: o, length: s } = e.split(".");
|
|
915
1028
|
if (s !== 3)
|
|
916
|
-
throw new
|
|
917
|
-
const c = await
|
|
1029
|
+
throw new w("Invalid Compact JWS");
|
|
1030
|
+
const c = await Ze({ payload: i, protected: n, signature: o }, t, r), d = { payload: c.payload, protectedHeader: c.protectedHeader };
|
|
918
1031
|
return typeof t == "function" ? { ...d, key: c.key } : d;
|
|
919
1032
|
}
|
|
920
|
-
const
|
|
921
|
-
function
|
|
1033
|
+
const pe = K;
|
|
1034
|
+
function te(e) {
|
|
922
1035
|
let t;
|
|
923
1036
|
if (typeof e == "string") {
|
|
924
1037
|
const r = e.split(".");
|
|
@@ -931,38 +1044,38 @@ function X(e) {
|
|
|
931
1044
|
try {
|
|
932
1045
|
if (typeof t != "string" || !t)
|
|
933
1046
|
throw new Error();
|
|
934
|
-
const r = JSON.parse(
|
|
935
|
-
if (!
|
|
1047
|
+
const r = JSON.parse(H.decode(pe(t)));
|
|
1048
|
+
if (!x(r))
|
|
936
1049
|
throw new Error();
|
|
937
1050
|
return r;
|
|
938
1051
|
} catch {
|
|
939
1052
|
throw new TypeError("Invalid Token or Protected Header formatting");
|
|
940
1053
|
}
|
|
941
1054
|
}
|
|
942
|
-
function
|
|
1055
|
+
function tt(e) {
|
|
943
1056
|
if (typeof e != "string")
|
|
944
|
-
throw new
|
|
1057
|
+
throw new P("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
945
1058
|
const { 1: t, length: r } = e.split(".");
|
|
946
1059
|
if (r === 5)
|
|
947
|
-
throw new
|
|
1060
|
+
throw new P("Only JWTs using Compact JWS serialization can be decoded");
|
|
948
1061
|
if (r !== 3)
|
|
949
|
-
throw new
|
|
1062
|
+
throw new P("Invalid JWT");
|
|
950
1063
|
if (!t)
|
|
951
|
-
throw new
|
|
1064
|
+
throw new P("JWTs must contain a payload");
|
|
952
1065
|
let n;
|
|
953
1066
|
try {
|
|
954
|
-
n =
|
|
1067
|
+
n = pe(t);
|
|
955
1068
|
} catch {
|
|
956
|
-
throw new
|
|
1069
|
+
throw new P("Failed to base64url decode the payload");
|
|
957
1070
|
}
|
|
958
1071
|
let i;
|
|
959
1072
|
try {
|
|
960
|
-
i = JSON.parse(
|
|
1073
|
+
i = JSON.parse(H.decode(n));
|
|
961
1074
|
} catch {
|
|
962
|
-
throw new
|
|
1075
|
+
throw new P("Failed to parse the decoded payload as JSON");
|
|
963
1076
|
}
|
|
964
|
-
if (!
|
|
965
|
-
throw new
|
|
1077
|
+
if (!x(i))
|
|
1078
|
+
throw new P("Invalid JWT Claims Set");
|
|
966
1079
|
return i;
|
|
967
1080
|
}
|
|
968
1081
|
const h = class h {
|
|
@@ -1061,9 +1174,9 @@ a(h, "flowName", {
|
|
|
1061
1174
|
[h.PasswordMfa]: "Password MFA",
|
|
1062
1175
|
[h.OidcAuthorizationCode]: "OIDC Authorization Code"
|
|
1063
1176
|
});
|
|
1064
|
-
let
|
|
1065
|
-
var
|
|
1066
|
-
class
|
|
1177
|
+
let re = h;
|
|
1178
|
+
var _, v;
|
|
1179
|
+
class nt {
|
|
1067
1180
|
/**
|
|
1068
1181
|
* Constructor.
|
|
1069
1182
|
*
|
|
@@ -1101,12 +1214,12 @@ class qe {
|
|
|
1101
1214
|
verifierLength: c,
|
|
1102
1215
|
tokenConsumer: d,
|
|
1103
1216
|
authServerCredentials: f,
|
|
1104
|
-
authServerMode:
|
|
1105
|
-
authServerHeaders:
|
|
1217
|
+
authServerMode: T,
|
|
1218
|
+
authServerHeaders: O
|
|
1106
1219
|
}) {
|
|
1107
1220
|
a(this, "authServerBaseUrl", "");
|
|
1108
|
-
|
|
1109
|
-
|
|
1221
|
+
$(this, _);
|
|
1222
|
+
$(this, v);
|
|
1110
1223
|
a(this, "codeChallengeMethod", "S256");
|
|
1111
1224
|
a(this, "verifierLength", 32);
|
|
1112
1225
|
a(this, "redirect_uri");
|
|
@@ -1121,13 +1234,13 @@ class qe {
|
|
|
1121
1234
|
a(this, "oauthLogFetch", !1);
|
|
1122
1235
|
a(this, "oauthUseUserInfoEndpoint", !1);
|
|
1123
1236
|
a(this, "oauthAuthorizeRedirect");
|
|
1124
|
-
this.tokenConsumer = d, this.authServerBaseUrl = t, c && (this.verifierLength = c), s && (this.stateLength = s), r &&
|
|
1237
|
+
this.tokenConsumer = d, this.authServerBaseUrl = t, c && (this.verifierLength = c), s && (this.stateLength = s), r && D(this, _, r), n && D(this, v, n), i && (this.redirect_uri = i), o && (this.codeChallengeMethod = o), this.authServerBaseUrl = t, f && (this.authServerCredentials = f), T && (this.authServerMode = T), O && (this.authServerHeaders = O);
|
|
1125
1238
|
}
|
|
1126
1239
|
set client_id(t) {
|
|
1127
|
-
|
|
1240
|
+
D(this, _, t);
|
|
1128
1241
|
}
|
|
1129
1242
|
set client_secret(t) {
|
|
1130
|
-
|
|
1243
|
+
D(this, v, t);
|
|
1131
1244
|
}
|
|
1132
1245
|
/**
|
|
1133
1246
|
* Loads OpenID Connect configuration so that the client can determine
|
|
@@ -1161,7 +1274,7 @@ class qe {
|
|
|
1161
1274
|
y.Connection,
|
|
1162
1275
|
"Couldn't get OIDC configuration from URL" + this.authServerBaseUrl + "/.well-known/openid-configuration"
|
|
1163
1276
|
);
|
|
1164
|
-
this.oidcConfig = { ...
|
|
1277
|
+
this.oidcConfig = { ...ie };
|
|
1165
1278
|
try {
|
|
1166
1279
|
const n = await r.json();
|
|
1167
1280
|
for (const [i, o] of Object.entries(n))
|
|
@@ -1207,7 +1320,7 @@ class qe {
|
|
|
1207
1320
|
error: "server_error",
|
|
1208
1321
|
error_description: "Cannot get authorize endpoint"
|
|
1209
1322
|
};
|
|
1210
|
-
if (!p(this,
|
|
1323
|
+
if (!p(this, _)) return {
|
|
1211
1324
|
error: "invalid_request",
|
|
1212
1325
|
error_description: "Cannot make authorization code flow without client id"
|
|
1213
1326
|
};
|
|
@@ -1217,7 +1330,7 @@ class qe {
|
|
|
1217
1330
|
};
|
|
1218
1331
|
let o = this.oidcConfig.authorization_endpoint;
|
|
1219
1332
|
this.oauthAuthorizeRedirect && (o = this.oauthAuthorizeRedirect);
|
|
1220
|
-
let s = o + "?response_type=code&client_id=" + encodeURIComponent(p(this,
|
|
1333
|
+
let s = o + "?response_type=code&client_id=" + encodeURIComponent(p(this, _)) + "&state=" + encodeURIComponent(t) + "&redirect_uri=" + encodeURIComponent(this.redirect_uri);
|
|
1221
1334
|
return r && (s += "&scope=" + encodeURIComponent(r)), i && n && (s += "&code_challenge=" + n), { url: s };
|
|
1222
1335
|
}
|
|
1223
1336
|
async codeChallengeAndVerifier() {
|
|
@@ -1273,40 +1386,40 @@ class qe {
|
|
|
1273
1386
|
* request, or `error` and `error_description`.
|
|
1274
1387
|
*/
|
|
1275
1388
|
async redirectEndpoint(t, r, n, i, o) {
|
|
1276
|
-
var
|
|
1389
|
+
var T, O;
|
|
1277
1390
|
if (this.oidcConfig || await this.loadConfig(), i || !t)
|
|
1278
1391
|
return i || (i = "server_error"), o || (o = "Unknown error"), { error: i, error_description: o };
|
|
1279
|
-
if (this.authzCode = t, !((
|
|
1392
|
+
if (this.authzCode = t, !((T = this.oidcConfig) != null && T.grant_types_supported.includes("authorization_code")))
|
|
1280
1393
|
return {
|
|
1281
1394
|
error: "invalid_request",
|
|
1282
1395
|
error_description: "Server does not support authorization code grant"
|
|
1283
1396
|
};
|
|
1284
|
-
if (!((
|
|
1397
|
+
if (!((O = this.oidcConfig) != null && O.token_endpoint))
|
|
1285
1398
|
return {
|
|
1286
1399
|
error: "server_error",
|
|
1287
1400
|
error_description: "Cannot get token endpoint"
|
|
1288
1401
|
};
|
|
1289
1402
|
const s = this.oidcConfig.token_endpoint;
|
|
1290
1403
|
let c, d;
|
|
1291
|
-
c = "authorization_code", d = p(this,
|
|
1404
|
+
c = "authorization_code", d = p(this, v);
|
|
1292
1405
|
let f = {
|
|
1293
1406
|
grant_type: c,
|
|
1294
|
-
client_id: p(this,
|
|
1407
|
+
client_id: p(this, _),
|
|
1295
1408
|
code: this.authzCode,
|
|
1296
1409
|
redirect_uri: this.redirect_uri
|
|
1297
1410
|
};
|
|
1298
1411
|
r && (f.scope = r), d && (f.client_secret = d), n && (f.code_verifier = n);
|
|
1299
1412
|
try {
|
|
1300
|
-
let
|
|
1301
|
-
if (
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1304
|
-
return
|
|
1305
|
-
|
|
1413
|
+
let b = await this.post(s, f, this.authServerHeaders);
|
|
1414
|
+
if (b.id_token) {
|
|
1415
|
+
const R = await this.getIdPayload(b.id_token, b.access_token);
|
|
1416
|
+
if (R.error)
|
|
1417
|
+
return R;
|
|
1418
|
+
b.id_payload = R.payload;
|
|
1306
1419
|
}
|
|
1307
|
-
return
|
|
1308
|
-
} catch (
|
|
1309
|
-
return l.logger.error(u({ err:
|
|
1420
|
+
return b;
|
|
1421
|
+
} catch (b) {
|
|
1422
|
+
return l.logger.error(u({ err: b })), {
|
|
1310
1423
|
error: "server_error",
|
|
1311
1424
|
error_description: "Unable to get access token from server"
|
|
1312
1425
|
};
|
|
@@ -1335,15 +1448,15 @@ class qe {
|
|
|
1335
1448
|
};
|
|
1336
1449
|
if (!((o = this.oidcConfig) != null && o.token_endpoint))
|
|
1337
1450
|
return { error: "server_error", error_description: "Cannot get token endpoint" };
|
|
1338
|
-
if (!p(this,
|
|
1451
|
+
if (!p(this, _)) return {
|
|
1339
1452
|
error: "invalid_request",
|
|
1340
1453
|
error_description: "Cannot make client credentials flow without client id"
|
|
1341
1454
|
};
|
|
1342
1455
|
const r = this.oidcConfig.token_endpoint;
|
|
1343
1456
|
let n = {
|
|
1344
1457
|
grant_type: "client_credentials",
|
|
1345
|
-
client_id: p(this,
|
|
1346
|
-
client_secret: p(this,
|
|
1458
|
+
client_id: p(this, _),
|
|
1459
|
+
client_secret: p(this, v)
|
|
1347
1460
|
};
|
|
1348
1461
|
t && (n.scope = t);
|
|
1349
1462
|
try {
|
|
@@ -1392,8 +1505,8 @@ class qe {
|
|
|
1392
1505
|
const i = this.oidcConfig.token_endpoint;
|
|
1393
1506
|
let o = {
|
|
1394
1507
|
grant_type: "password",
|
|
1395
|
-
client_id: p(this,
|
|
1396
|
-
client_secret: p(this,
|
|
1508
|
+
client_id: p(this, _),
|
|
1509
|
+
client_secret: p(this, v),
|
|
1397
1510
|
username: t,
|
|
1398
1511
|
password: r
|
|
1399
1512
|
};
|
|
@@ -1482,8 +1595,8 @@ class qe {
|
|
|
1482
1595
|
if (!((s = this.oidcConfig) != null && s.issuer))
|
|
1483
1596
|
return { error: "server_error", error_description: "Cannot get issuer" };
|
|
1484
1597
|
const n = this.oidcConfig.issuer + (this.oidcConfig.issuer.endsWith("/") ? "" : "/") + "mfa/challenge", i = await this.post(n, {
|
|
1485
|
-
client_id: p(this,
|
|
1486
|
-
client_secret: p(this,
|
|
1598
|
+
client_id: p(this, _),
|
|
1599
|
+
client_secret: p(this, v),
|
|
1487
1600
|
challenge_type: "otp",
|
|
1488
1601
|
mfa_token: t,
|
|
1489
1602
|
authenticator_id: r
|
|
@@ -1521,8 +1634,8 @@ class qe {
|
|
|
1521
1634
|
return { error: "server_error", error_description: "Cannot get issuer" };
|
|
1522
1635
|
const i = this.oidcConfig.token_endpoint, o = await this.post(i, {
|
|
1523
1636
|
grant_type: "http://auth0.com/oauth/grant-type/mfa-otp",
|
|
1524
|
-
client_id: p(this,
|
|
1525
|
-
client_secret: p(this,
|
|
1637
|
+
client_id: p(this, _),
|
|
1638
|
+
client_secret: p(this, v),
|
|
1526
1639
|
challenge_type: "otp",
|
|
1527
1640
|
mfa_token: t,
|
|
1528
1641
|
otp: r,
|
|
@@ -1573,8 +1686,8 @@ class qe {
|
|
|
1573
1686
|
if (!((s = this.oidcConfig) != null && s.issuer))
|
|
1574
1687
|
return { error: "server_error", error_description: "Cannot get issuer" };
|
|
1575
1688
|
const n = this.oidcConfig.issuer + (this.oidcConfig.issuer.endsWith("/") ? "" : "/") + "mfa/challenge", i = await this.post(n, {
|
|
1576
|
-
client_id: p(this,
|
|
1577
|
-
client_secret: p(this,
|
|
1689
|
+
client_id: p(this, _),
|
|
1690
|
+
client_secret: p(this, v),
|
|
1578
1691
|
challenge_type: "oob",
|
|
1579
1692
|
mfa_token: t,
|
|
1580
1693
|
authenticator_id: r
|
|
@@ -1609,8 +1722,8 @@ class qe {
|
|
|
1609
1722
|
return { error: "server_error", error_description: "Cannot get issuer" };
|
|
1610
1723
|
const o = this.oidcConfig.token_endpoint, s = await this.post(o, {
|
|
1611
1724
|
grant_type: "http://auth0.com/oauth/grant-type/mfa-oob",
|
|
1612
|
-
client_id: p(this,
|
|
1613
|
-
client_secret: p(this,
|
|
1725
|
+
client_id: p(this, _),
|
|
1726
|
+
client_secret: p(this, v),
|
|
1614
1727
|
challenge_type: "otp",
|
|
1615
1728
|
mfa_token: t,
|
|
1616
1729
|
oob_code: r,
|
|
@@ -1653,11 +1766,11 @@ class qe {
|
|
|
1653
1766
|
};
|
|
1654
1767
|
const r = this.oidcConfig.token_endpoint;
|
|
1655
1768
|
let n;
|
|
1656
|
-
n = p(this,
|
|
1769
|
+
n = p(this, v);
|
|
1657
1770
|
let i = {
|
|
1658
1771
|
grant_type: "refresh_token",
|
|
1659
1772
|
refresh_token: t,
|
|
1660
|
-
client_id: p(this,
|
|
1773
|
+
client_id: p(this, _)
|
|
1661
1774
|
};
|
|
1662
1775
|
n && (i.client_secret = n);
|
|
1663
1776
|
try {
|
|
@@ -1693,8 +1806,8 @@ class qe {
|
|
|
1693
1806
|
};
|
|
1694
1807
|
let n = {
|
|
1695
1808
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
1696
|
-
client_id: p(this,
|
|
1697
|
-
client_secret: p(this,
|
|
1809
|
+
client_id: p(this, _),
|
|
1810
|
+
client_secret: p(this, v)
|
|
1698
1811
|
};
|
|
1699
1812
|
r && (n.scope = r);
|
|
1700
1813
|
try {
|
|
@@ -1728,8 +1841,8 @@ class qe {
|
|
|
1728
1841
|
};
|
|
1729
1842
|
let r = {
|
|
1730
1843
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
1731
|
-
client_id: p(this,
|
|
1732
|
-
client_secret: p(this,
|
|
1844
|
+
client_id: p(this, _),
|
|
1845
|
+
client_secret: p(this, v),
|
|
1733
1846
|
device_code: t
|
|
1734
1847
|
};
|
|
1735
1848
|
try {
|
|
@@ -1869,11 +1982,11 @@ class qe {
|
|
|
1869
1982
|
}
|
|
1870
1983
|
}
|
|
1871
1984
|
getTokenPayload(t) {
|
|
1872
|
-
return
|
|
1985
|
+
return tt(t);
|
|
1873
1986
|
}
|
|
1874
1987
|
}
|
|
1875
|
-
|
|
1876
|
-
class
|
|
1988
|
+
_ = new WeakMap(), v = new WeakMap();
|
|
1989
|
+
class ot {
|
|
1877
1990
|
/**
|
|
1878
1991
|
* Constrctor
|
|
1879
1992
|
*
|
|
@@ -1922,14 +2035,14 @@ class Me {
|
|
|
1922
2035
|
y.Configuration,
|
|
1923
2036
|
"Must specify jwtKeyType if setting jwtSecretKey"
|
|
1924
2037
|
);
|
|
1925
|
-
this.keys._default = await
|
|
2038
|
+
this.keys._default = await Be(this.jwtSecretKey, this.jwtKeyType);
|
|
1926
2039
|
} else if (this.jwtPublicKey) {
|
|
1927
2040
|
if (!this.jwtKeyType)
|
|
1928
2041
|
throw new g(
|
|
1929
2042
|
y.Configuration,
|
|
1930
2043
|
"Must specify jwtKeyType if setting jwtPublicKey"
|
|
1931
2044
|
);
|
|
1932
|
-
const r = await
|
|
2045
|
+
const r = await $e(this.jwtPublicKey, this.jwtKeyType);
|
|
1933
2046
|
this.keys._default = r;
|
|
1934
2047
|
} else {
|
|
1935
2048
|
if (this.oidcConfig || await this.loadConfig(), !this.oidcConfig)
|
|
@@ -1968,7 +2081,7 @@ class Me {
|
|
|
1968
2081
|
}
|
|
1969
2082
|
if (!r || !r.ok)
|
|
1970
2083
|
throw new g(y.Connection, "Couldn't get OIDC configuration");
|
|
1971
|
-
this.oidcConfig = { ...
|
|
2084
|
+
this.oidcConfig = { ...ie };
|
|
1972
2085
|
try {
|
|
1973
2086
|
const n = await r.json();
|
|
1974
2087
|
for (const [i, o] of Object.entries(n))
|
|
@@ -1990,8 +2103,8 @@ class Me {
|
|
|
1990
2103
|
if (t) {
|
|
1991
2104
|
this.keys = {};
|
|
1992
2105
|
for (let n = 0; n < t.keys.length; ++n) {
|
|
1993
|
-
const i = t.keys[n];
|
|
1994
|
-
this.keys[
|
|
2106
|
+
const i = t.keys[n], o = "kid" in i && i.kid ? i.kid : "_default";
|
|
2107
|
+
this.keys[o] = await j(t.keys[n]);
|
|
1995
2108
|
}
|
|
1996
2109
|
} else {
|
|
1997
2110
|
if (!this.oidcConfig)
|
|
@@ -2019,7 +2132,7 @@ class Me {
|
|
|
2019
2132
|
l.logger.debug(u({ msg: "Skipping key with " + c.kty }));
|
|
2020
2133
|
continue;
|
|
2021
2134
|
}
|
|
2022
|
-
const d = await
|
|
2135
|
+
const d = await j(c);
|
|
2023
2136
|
this.keys[s] = d;
|
|
2024
2137
|
} catch (s) {
|
|
2025
2138
|
throw l.logger.error(u({ err: s })), new g(y.Connection, "Couldn't load keys");
|
|
@@ -2042,7 +2155,7 @@ class Me {
|
|
|
2042
2155
|
*/
|
|
2043
2156
|
async tokenAuthorized(t, r, n) {
|
|
2044
2157
|
if (!this.keys || Object.keys(this.keys).length == 0) {
|
|
2045
|
-
const o =
|
|
2158
|
+
const o = te(t);
|
|
2046
2159
|
await this.loadKeys(o.alg);
|
|
2047
2160
|
}
|
|
2048
2161
|
const i = await this.validateToken(t);
|
|
@@ -2066,7 +2179,7 @@ class Me {
|
|
|
2066
2179
|
(!this.keys || Object.keys(this.keys).length == 0) && l.logger.warn("No keys loaded so cannot validate tokens");
|
|
2067
2180
|
let r;
|
|
2068
2181
|
try {
|
|
2069
|
-
r =
|
|
2182
|
+
r = te(t).kid;
|
|
2070
2183
|
} catch {
|
|
2071
2184
|
l.logger.warn(u({ msg: "Invalid access token format" }));
|
|
2072
2185
|
return;
|
|
@@ -2082,7 +2195,7 @@ class Me {
|
|
|
2082
2195
|
return;
|
|
2083
2196
|
}
|
|
2084
2197
|
try {
|
|
2085
|
-
const { payload: i } = await
|
|
2198
|
+
const { payload: i } = await et(t, n), o = JSON.parse(new TextDecoder().decode(i));
|
|
2086
2199
|
if (o.exp * 1e3 < Date.now() + this.clockTolerance) {
|
|
2087
2200
|
l.logger.warn(u({ msg: "Access token has expired" }));
|
|
2088
2201
|
return;
|
|
@@ -2098,13 +2211,13 @@ class Me {
|
|
|
2098
2211
|
export {
|
|
2099
2212
|
g as CrossauthError,
|
|
2100
2213
|
l as CrossauthLogger,
|
|
2101
|
-
|
|
2214
|
+
ie as DEFAULT_OIDCCONFIG,
|
|
2102
2215
|
y as ErrorCode,
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2216
|
+
A as KeyPrefix,
|
|
2217
|
+
nt as OAuthClientBase,
|
|
2218
|
+
re as OAuthFlows,
|
|
2219
|
+
ot as OAuthTokenConsumerBase,
|
|
2220
|
+
E as UserState,
|
|
2221
|
+
it as httpStatus,
|
|
2109
2222
|
u as j
|
|
2110
2223
|
};
|