unjwt 0.5.0 → 0.5.2
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 +89 -4
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +5 -5
- package/dist/jwe.d.mts +3 -3
- package/dist/jwe.d.ts +3 -3
- package/dist/jwe.mjs +4 -4
- package/dist/jwk.d.mts +2 -2
- package/dist/jwk.d.ts +2 -2
- package/dist/jwk.mjs +2 -2
- package/dist/jws.d.mts +3 -3
- package/dist/jws.d.ts +3 -3
- package/dist/jws.mjs +4 -4
- package/dist/shared/{unjwt.BKG_8Y9G.d.ts → unjwt.B0XDPf8a.d.ts} +2 -2
- package/dist/shared/{unjwt.CJ_ohCFC.d.mts → unjwt.B5N3dPN9.d.ts} +13 -4
- package/dist/shared/{unjwt.DoVzOnty.d.ts → unjwt.BISJ5yt1.d.ts} +1 -1
- package/dist/shared/{unjwt.mc4AEAT7.d.ts → unjwt.BJEchXrM.d.mts} +13 -4
- package/dist/shared/{unjwt.B4e_rwol.mjs → unjwt.ByclPbtq.mjs} +3 -3
- package/dist/shared/{unjwt.Bzcov22m.mjs → unjwt.COPr8ebc.mjs} +98 -20
- package/dist/shared/{unjwt.D90BbcE1.d.mts → unjwt.Cd9nTEWg.d.mts} +1 -1
- package/dist/shared/{unjwt.C0bBN0AC.d.mts → unjwt.CxhGjEAX.d.mts} +3 -1
- package/dist/shared/{unjwt.C0bBN0AC.d.ts → unjwt.CxhGjEAX.d.ts} +3 -1
- package/dist/shared/{unjwt.BOEZHxi_.d.ts → unjwt.D1J1DelP.d.mts} +46 -2
- package/dist/shared/{unjwt.CjHZv3F3.mjs → unjwt.DOI5UE8K.mjs} +32 -2
- package/dist/shared/{unjwt.Dz5Oe9BG.d.mts → unjwt.DQIYSlHj.d.mts} +2 -2
- package/dist/shared/{unjwt.ppm5Y0k7.d.ts → unjwt.TbszLNOP.d.ts} +57 -4
- package/dist/shared/{unjwt.B9uGngq-.d.mts → unjwt.WvWb2zNM.d.ts} +46 -2
- package/dist/shared/{unjwt.DKq5VF7t.mjs → unjwt.ZsOShfhX.mjs} +325 -4
- package/dist/shared/{unjwt.DYFIh1YE.d.mts → unjwt.kiNPBQh0.d.mts} +57 -4
- package/dist/shared/{unjwt.sux3_Z19.mjs → unjwt.z_U3fRJ-.mjs} +1 -1
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as isCryptoKey, e as concatUint8Arrays, b as base64UrlEncode, t as textEncoder, r as randomBytes, a as isJWK, d as base64UrlDecode } from './unjwt.
|
|
1
|
+
import { g as isCryptoKey, e as concatUint8Arrays, b as base64UrlEncode, h as base64Decode, j as base64Encode, t as textEncoder, r as randomBytes, a as isJWK, d as base64UrlDecode } from './unjwt.DOI5UE8K.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -113,7 +113,7 @@ function isAlgorithm(algorithm, name) {
|
|
|
113
113
|
function getHashLength(hash) {
|
|
114
114
|
return Number.parseInt(hash.name.slice(4), 10);
|
|
115
115
|
}
|
|
116
|
-
function getNamedCurve(alg) {
|
|
116
|
+
function getNamedCurve$1(alg) {
|
|
117
117
|
switch (alg) {
|
|
118
118
|
case "ES256": {
|
|
119
119
|
return "P-256";
|
|
@@ -182,7 +182,7 @@ function checkSigCryptoKey(key, alg, usage) {
|
|
|
182
182
|
case "ES512": {
|
|
183
183
|
if (!isAlgorithm(key.algorithm, "ECDSA"))
|
|
184
184
|
throw unusable("ECDSA");
|
|
185
|
-
const expected = getNamedCurve(alg);
|
|
185
|
+
const expected = getNamedCurve$1(alg);
|
|
186
186
|
const actual = key.algorithm.namedCurve;
|
|
187
187
|
if (actual !== expected) throw unusable(expected, "algorithm.namedCurve");
|
|
188
188
|
break;
|
|
@@ -511,6 +511,251 @@ async function decryptIV(alg, key, encryptedKey, iv, tag) {
|
|
|
511
511
|
return decrypt(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
+
/**
|
|
515
|
+
* This is a fork of Jose library's utility functions.
|
|
516
|
+
* @source https://github.com/panva/jose/tree/69b7960c67e05be55fa2ec31c74b987696c20c60/src/lib/asn1.ts
|
|
517
|
+
* @license MIT https://github.com/panva/jose/blob/69b7960c67e05be55fa2ec31c74b987696c20c60/LICENSE.md
|
|
518
|
+
*/
|
|
519
|
+
const formatPEM = (b64, descriptor) => {
|
|
520
|
+
const newlined = (b64.match(/.{1,64}/g) || []).join("\n");
|
|
521
|
+
return `-----BEGIN ${descriptor}-----
|
|
522
|
+
${newlined}
|
|
523
|
+
-----END ${descriptor}-----`;
|
|
524
|
+
};
|
|
525
|
+
const genericExport = async (keyType, keyFormat, key) => {
|
|
526
|
+
if (!isCryptoKey(key)) {
|
|
527
|
+
throw new TypeError(`Key must be ${key} of type CryptoKey`);
|
|
528
|
+
}
|
|
529
|
+
if (!key.extractable) {
|
|
530
|
+
throw new TypeError("CryptoKey is not extractable");
|
|
531
|
+
}
|
|
532
|
+
if (key.type !== keyType) {
|
|
533
|
+
throw new TypeError(`key is not a ${keyType} key`);
|
|
534
|
+
}
|
|
535
|
+
return formatPEM(
|
|
536
|
+
base64Encode(new Uint8Array(await crypto.subtle.exportKey(keyFormat, key))),
|
|
537
|
+
`${keyType.toUpperCase()} KEY`
|
|
538
|
+
);
|
|
539
|
+
};
|
|
540
|
+
const toSPKI = (key) => {
|
|
541
|
+
return genericExport("public", "spki", key);
|
|
542
|
+
};
|
|
543
|
+
const toPKCS8 = (key) => {
|
|
544
|
+
return genericExport("private", "pkcs8", key);
|
|
545
|
+
};
|
|
546
|
+
const findOid = (keyData, oid, from = 0) => {
|
|
547
|
+
if (from === 0) {
|
|
548
|
+
oid.unshift(oid.length);
|
|
549
|
+
oid.unshift(6);
|
|
550
|
+
}
|
|
551
|
+
const i = keyData.indexOf(oid[0], from);
|
|
552
|
+
if (i === -1) return false;
|
|
553
|
+
const sub = keyData.subarray(i, i + oid.length);
|
|
554
|
+
if (sub.length !== oid.length) return false;
|
|
555
|
+
return sub.every((value, index) => value === oid[index]) || findOid(keyData, oid, i + 1);
|
|
556
|
+
};
|
|
557
|
+
const getNamedCurve = (keyData) => {
|
|
558
|
+
switch (true) {
|
|
559
|
+
case findOid(keyData, [42, 134, 72, 206, 61, 3, 1, 7]): {
|
|
560
|
+
return "P-256";
|
|
561
|
+
}
|
|
562
|
+
case findOid(keyData, [43, 129, 4, 0, 34]): {
|
|
563
|
+
return "P-384";
|
|
564
|
+
}
|
|
565
|
+
case findOid(keyData, [43, 129, 4, 0, 35]): {
|
|
566
|
+
return "P-521";
|
|
567
|
+
}
|
|
568
|
+
default: {
|
|
569
|
+
return void 0;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
const genericImport = async (replace, keyFormat, pem, alg, options) => {
|
|
574
|
+
let algorithm;
|
|
575
|
+
let keyUsages;
|
|
576
|
+
const cleanedPem = pem.replace(replace, "");
|
|
577
|
+
const keyData = base64Decode(cleanedPem, false);
|
|
578
|
+
const isPublic = keyFormat === "spki";
|
|
579
|
+
switch (alg) {
|
|
580
|
+
case "PS256":
|
|
581
|
+
case "PS384":
|
|
582
|
+
case "PS512": {
|
|
583
|
+
algorithm = { name: "RSA-PSS", hash: `SHA-${alg.slice(-3)}` };
|
|
584
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
case "RS256":
|
|
588
|
+
case "RS384":
|
|
589
|
+
case "RS512": {
|
|
590
|
+
algorithm = { name: "RSASSA-PKCS1-v1_5", hash: `SHA-${alg.slice(-3)}` };
|
|
591
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
592
|
+
break;
|
|
593
|
+
}
|
|
594
|
+
case "RSA-OAEP":
|
|
595
|
+
case "RSA-OAEP-256":
|
|
596
|
+
case "RSA-OAEP-384":
|
|
597
|
+
case "RSA-OAEP-512": {
|
|
598
|
+
algorithm = {
|
|
599
|
+
name: "RSA-OAEP",
|
|
600
|
+
hash: `SHA-${Number.parseInt(alg.slice(-3), 10) || 1}`
|
|
601
|
+
};
|
|
602
|
+
keyUsages = isPublic ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
case "ES256": {
|
|
606
|
+
algorithm = { name: "ECDSA", namedCurve: "P-256" };
|
|
607
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
case "ES384": {
|
|
611
|
+
algorithm = { name: "ECDSA", namedCurve: "P-384" };
|
|
612
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
case "ES512": {
|
|
616
|
+
algorithm = { name: "ECDSA", namedCurve: "P-521" };
|
|
617
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
case "ECDH-ES":
|
|
621
|
+
case "ECDH-ES+A128KW":
|
|
622
|
+
case "ECDH-ES+A192KW":
|
|
623
|
+
case "ECDH-ES+A256KW": {
|
|
624
|
+
const namedCurve = getNamedCurve(keyData);
|
|
625
|
+
algorithm = namedCurve?.startsWith("P-") ? { name: "ECDH", namedCurve } : { name: "X25519" };
|
|
626
|
+
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
case "Ed25519":
|
|
630
|
+
case "EdDSA": {
|
|
631
|
+
algorithm = { name: "Ed25519" };
|
|
632
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
633
|
+
break;
|
|
634
|
+
}
|
|
635
|
+
default: {
|
|
636
|
+
throw new Error('Invalid or unsupported "alg" (Algorithm) value');
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return crypto.subtle.importKey(
|
|
640
|
+
keyFormat,
|
|
641
|
+
keyData,
|
|
642
|
+
algorithm,
|
|
643
|
+
options?.extractable ?? (isPublic ? true : false),
|
|
644
|
+
keyUsages
|
|
645
|
+
);
|
|
646
|
+
};
|
|
647
|
+
const fromPKCS8 = (pem, alg, options) => {
|
|
648
|
+
return genericImport(
|
|
649
|
+
/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,
|
|
650
|
+
"pkcs8",
|
|
651
|
+
pem,
|
|
652
|
+
alg,
|
|
653
|
+
options
|
|
654
|
+
);
|
|
655
|
+
};
|
|
656
|
+
const fromSPKI = (pem, alg, options) => {
|
|
657
|
+
return genericImport(
|
|
658
|
+
/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,
|
|
659
|
+
"spki",
|
|
660
|
+
pem,
|
|
661
|
+
alg,
|
|
662
|
+
options
|
|
663
|
+
);
|
|
664
|
+
};
|
|
665
|
+
function getElement(seq) {
|
|
666
|
+
const result = [];
|
|
667
|
+
let next = 0;
|
|
668
|
+
while (next < seq.length) {
|
|
669
|
+
const nextPart = parseElement(seq.subarray(next));
|
|
670
|
+
result.push(nextPart);
|
|
671
|
+
next += nextPart.byteLength;
|
|
672
|
+
}
|
|
673
|
+
return result;
|
|
674
|
+
}
|
|
675
|
+
function parseElement(bytes) {
|
|
676
|
+
let position = 0;
|
|
677
|
+
let tag = bytes[0] & 31;
|
|
678
|
+
position++;
|
|
679
|
+
if (tag === 31) {
|
|
680
|
+
tag = 0;
|
|
681
|
+
while (bytes[position] >= 128) {
|
|
682
|
+
tag = tag * 128 + bytes[position] - 128;
|
|
683
|
+
position++;
|
|
684
|
+
}
|
|
685
|
+
tag = tag * 128 + bytes[position] - 128;
|
|
686
|
+
position++;
|
|
687
|
+
}
|
|
688
|
+
let length = 0;
|
|
689
|
+
if (bytes[position] < 128) {
|
|
690
|
+
length = bytes[position];
|
|
691
|
+
position++;
|
|
692
|
+
} else if (length === 128) {
|
|
693
|
+
length = 0;
|
|
694
|
+
while (bytes[position + length] !== 0 || bytes[position + length + 1] !== 0) {
|
|
695
|
+
if (length > bytes.byteLength) {
|
|
696
|
+
throw new TypeError("invalid indefinite form length");
|
|
697
|
+
}
|
|
698
|
+
length++;
|
|
699
|
+
}
|
|
700
|
+
const byteLength2 = position + length + 2;
|
|
701
|
+
return {
|
|
702
|
+
byteLength: byteLength2,
|
|
703
|
+
contents: bytes.subarray(position, position + length),
|
|
704
|
+
raw: bytes.subarray(0, byteLength2)
|
|
705
|
+
};
|
|
706
|
+
} else {
|
|
707
|
+
const numberOfDigits = bytes[position] & 127;
|
|
708
|
+
position++;
|
|
709
|
+
length = 0;
|
|
710
|
+
for (let i = 0; i < numberOfDigits; i++) {
|
|
711
|
+
length = length * 256 + bytes[position];
|
|
712
|
+
position++;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const byteLength = position + length;
|
|
716
|
+
return {
|
|
717
|
+
byteLength,
|
|
718
|
+
contents: bytes.subarray(position, byteLength),
|
|
719
|
+
raw: bytes.subarray(0, byteLength)
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function spkiFromX509(buf) {
|
|
723
|
+
const tbsCertificate = getElement(
|
|
724
|
+
getElement(parseElement(buf).contents)[0].contents
|
|
725
|
+
);
|
|
726
|
+
return base64Encode(
|
|
727
|
+
tbsCertificate[tbsCertificate[0].raw[0] === 160 ? 6 : 5].raw
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
let createPublicKey;
|
|
731
|
+
function getSPKI(x509) {
|
|
732
|
+
try {
|
|
733
|
+
createPublicKey ??= globalThis.process?.getBuiltinModule?.("node:crypto")?.createPublicKey;
|
|
734
|
+
} catch {
|
|
735
|
+
createPublicKey = 0;
|
|
736
|
+
}
|
|
737
|
+
if (createPublicKey) {
|
|
738
|
+
try {
|
|
739
|
+
return new createPublicKey(x509).export({ format: "pem", type: "spki" });
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
const pem = x509.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g, "");
|
|
744
|
+
const raw = base64Decode(pem, false);
|
|
745
|
+
return formatPEM(spkiFromX509(raw), "PUBLIC KEY");
|
|
746
|
+
}
|
|
747
|
+
const fromX509 = (pem, alg, options) => {
|
|
748
|
+
let spki;
|
|
749
|
+
try {
|
|
750
|
+
spki = getSPKI(pem);
|
|
751
|
+
} catch (error_) {
|
|
752
|
+
throw new TypeError("Failed to parse the X.509 certificate", {
|
|
753
|
+
cause: error_
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
return fromSPKI(spki, alg, options);
|
|
757
|
+
};
|
|
758
|
+
|
|
514
759
|
/**
|
|
515
760
|
* This is a fork of Jose library's utility functions.
|
|
516
761
|
* @source https://github.com/panva/jose/tree/69b7960c67e05be55fa2ec31c74b987696c20c60/src/lib/jwt_to_key.ts
|
|
@@ -1064,6 +1309,80 @@ async function unwrapKey(alg, wrappedKey, unwrappingKey, options = {}) {
|
|
|
1064
1309
|
);
|
|
1065
1310
|
return finalKey;
|
|
1066
1311
|
}
|
|
1312
|
+
async function importJWKFromPEM(pem, pemType, alg, importOptions, jwkExtras) {
|
|
1313
|
+
let cryptoKey;
|
|
1314
|
+
const defaultExtractable = importOptions?.extractable !== false;
|
|
1315
|
+
switch (pemType) {
|
|
1316
|
+
case "pkcs8": {
|
|
1317
|
+
cryptoKey = await fromPKCS8(pem, alg, {
|
|
1318
|
+
...importOptions,
|
|
1319
|
+
extractable: defaultExtractable
|
|
1320
|
+
});
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
case "spki": {
|
|
1324
|
+
cryptoKey = await fromSPKI(pem, alg, {
|
|
1325
|
+
...importOptions,
|
|
1326
|
+
extractable: defaultExtractable
|
|
1327
|
+
});
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
case "x509": {
|
|
1331
|
+
cryptoKey = await fromX509(pem, alg, {
|
|
1332
|
+
...importOptions,
|
|
1333
|
+
extractable: defaultExtractable
|
|
1334
|
+
});
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
default: {
|
|
1338
|
+
throw new TypeError(`Unsupported PEM type: ${pemType}`);
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
const finalJWKExtras = { alg, ...jwkExtras };
|
|
1342
|
+
return exportKey(cryptoKey, finalJWKExtras);
|
|
1343
|
+
}
|
|
1344
|
+
async function exportJWKToPEM(jwk, pemFormat, algForCryptoKeyImport) {
|
|
1345
|
+
if (jwk.kty === "oct") {
|
|
1346
|
+
throw new TypeError(
|
|
1347
|
+
"Octet (symmetric) JWKs (kty: 'oct') cannot be exported to PKCS8 or SPKI PEM formats."
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
const effectiveAlg = jwk.alg || algForCryptoKeyImport;
|
|
1351
|
+
if (!effectiveAlg && (jwk.kty === "RSA" || jwk.kty === "EC" || jwk.kty === "OKP")) {
|
|
1352
|
+
throw new TypeError(
|
|
1353
|
+
"Algorithm (alg) must be provided in the JWK or as a parameter for converting this JWK type to a CryptoKey."
|
|
1354
|
+
);
|
|
1355
|
+
}
|
|
1356
|
+
const jwkForImport = { ...jwk, ext: true };
|
|
1357
|
+
const cryptoKeyCandidate = await importKey(jwkForImport, effectiveAlg);
|
|
1358
|
+
if (!isCryptoKey(cryptoKeyCandidate)) {
|
|
1359
|
+
throw new Error(
|
|
1360
|
+
"Failed to convert JWK to a CryptoKey instance suitable for PEM export."
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
const cryptoKey = cryptoKeyCandidate;
|
|
1364
|
+
switch (pemFormat) {
|
|
1365
|
+
case "pkcs8": {
|
|
1366
|
+
if (cryptoKey.type !== "private") {
|
|
1367
|
+
throw new TypeError(
|
|
1368
|
+
`Only 'private' type CryptoKeys can be exported to PKCS8 PEM format. Key type is '${cryptoKey.type}'.`
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
return toPKCS8(cryptoKey);
|
|
1372
|
+
}
|
|
1373
|
+
case "spki": {
|
|
1374
|
+
if (cryptoKey.type !== "public") {
|
|
1375
|
+
throw new TypeError(
|
|
1376
|
+
`Only 'public' type CryptoKeys can be exported to SPKI PEM format. Key type is '${cryptoKey.type}'.`
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1379
|
+
return toSPKI(cryptoKey);
|
|
1380
|
+
}
|
|
1381
|
+
default: {
|
|
1382
|
+
throw new TypeError(`Unsupported PEM format: ${pemFormat}`);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1067
1386
|
function getGenerateKeyParams(alg, options) {
|
|
1068
1387
|
let algorithm;
|
|
1069
1388
|
let keyUsages;
|
|
@@ -1176,11 +1495,13 @@ function getGenerateKeyParams(alg, options) {
|
|
|
1176
1495
|
const jwk = {
|
|
1177
1496
|
__proto__: null,
|
|
1178
1497
|
deriveKeyFromPassword: deriveKeyFromPassword,
|
|
1498
|
+
exportJWKToPEM: exportJWKToPEM,
|
|
1179
1499
|
exportKey: exportKey,
|
|
1180
1500
|
generateKey: generateKey,
|
|
1501
|
+
importJWKFromPEM: importJWKFromPEM,
|
|
1181
1502
|
importKey: importKey,
|
|
1182
1503
|
unwrapKey: unwrapKey,
|
|
1183
1504
|
wrapKey: wrapKey
|
|
1184
1505
|
};
|
|
1185
1506
|
|
|
1186
|
-
export { checkEncCryptoKey as a, bitLengthCEK as b, checkSigCryptoKey as c, jwkTokey as d, encryptIV as e, generateIV as f, generateCEK as g, encrypt as h, importKey as i, jwk as j, keyToJWK as k, unwrapKey as l, decrypt as m, generateKey as n, deriveKeyFromPassword as o, exportKey as p, wrapKey as q, uint32be as u, wrap as w };
|
|
1507
|
+
export { checkEncCryptoKey as a, bitLengthCEK as b, checkSigCryptoKey as c, jwkTokey as d, encryptIV as e, generateIV as f, generateCEK as g, encrypt as h, importKey as i, jwk as j, keyToJWK as k, unwrapKey as l, decrypt as m, generateKey as n, deriveKeyFromPassword as o, exportKey as p, wrapKey as q, importJWKFromPEM as r, exportJWKToPEM as s, uint32be as u, wrap as w };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as JWK_HMAC, o as JWK_RSA_SIGN, p as JWK_RSA_PSS, q as JWK_ECDSA, m as JWK } from './unjwt.
|
|
2
|
-
import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.
|
|
1
|
+
import { n as JWK_HMAC, o as JWK_RSA_SIGN, p as JWK_RSA_PSS, q as JWK_ECDSA, m as JWK } from './unjwt.CxhGjEAX.mjs';
|
|
2
|
+
import { J as JoseHeaderParameters, a as JWTClaims } from './unjwt.Cd9nTEWg.mjs';
|
|
3
3
|
|
|
4
4
|
type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
|
|
5
5
|
/** JWS Signing Algorithm Identifier. */
|
|
@@ -43,10 +43,63 @@ interface JWSVerifyResult<T = JWTClaims | Uint8Array | string> {
|
|
|
43
43
|
interface JWSVerifyOptions {
|
|
44
44
|
/** List of allowed algorithms. If provided, the JWS `alg` must be in this list. */
|
|
45
45
|
algorithms?: JWSAlgorithm[];
|
|
46
|
-
/** List of critical header parameters that must be understood and processed. */
|
|
47
|
-
critical?: string[];
|
|
48
46
|
/** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred. */
|
|
49
47
|
forceUint8Array?: boolean;
|
|
48
|
+
/** List of critical header parameters that must be understood and processed. */
|
|
49
|
+
requiredHeaders?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Expected JWT "aud" (Audience) Claim value(s).
|
|
52
|
+
*
|
|
53
|
+
* This option makes the JWT "aud" (Audience) Claim presence required.
|
|
54
|
+
*/
|
|
55
|
+
audience?: string | string[];
|
|
56
|
+
/**
|
|
57
|
+
* Clock skew tolerance (in seconds) for validating JWT claims.
|
|
58
|
+
*
|
|
59
|
+
* Used when validating the JWT "nbf" (Not Before) and "exp" (Expiration Time) claims, and when
|
|
60
|
+
* validating the "iat" (Issued At) claim if the {@link maxTokenAge `maxTokenAge` option} is set.
|
|
61
|
+
*/
|
|
62
|
+
clockTolerance?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Expected JWT "iss" (Issuer) Claim value(s).
|
|
65
|
+
*
|
|
66
|
+
* This option makes the JWT "iss" (Issuer) Claim presence required.
|
|
67
|
+
*/
|
|
68
|
+
issuer?: string | string[];
|
|
69
|
+
/**
|
|
70
|
+
* Maximum time elapsed (in seconds) from the JWT "iat" (Issued At) Claim value.
|
|
71
|
+
*
|
|
72
|
+
* This option makes the JWT "iat" (Issued At) Claim presence required.
|
|
73
|
+
*/
|
|
74
|
+
maxTokenAge?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Expected JWT "sub" (Subject) Claim value.
|
|
77
|
+
*
|
|
78
|
+
* This option makes the JWT "sub" (Subject) Claim presence required.
|
|
79
|
+
*/
|
|
80
|
+
subject?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Expected JWT "typ" (Type) Header Parameter value.
|
|
83
|
+
*
|
|
84
|
+
* This option makes the JWT "typ" (Type) Header Parameter presence required.
|
|
85
|
+
*/
|
|
86
|
+
typ?: string;
|
|
87
|
+
/** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
|
|
88
|
+
currentDate?: Date;
|
|
89
|
+
/**
|
|
90
|
+
* Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if
|
|
91
|
+
* the {@link issuer `issuer` option} is set, then JWT "iss" (Issuer) Claim must be present; if the
|
|
92
|
+
* {@link audience `audience` option} is set, then JWT "aud" (Audience) Claim must be present; if
|
|
93
|
+
* the {@link subject `subject` option} is set, then JWT "sub" (Subject) Claim must be present; if
|
|
94
|
+
* the {@link maxTokenAge `maxTokenAge` option} is set, then JWT "iat" (Issued At) Claim must be
|
|
95
|
+
* present.
|
|
96
|
+
*/
|
|
97
|
+
requiredClaims?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* List of critical header parameters that must be understood and processed.
|
|
100
|
+
* @deprecated use {@link requiredHeaders `recognizedHeaders` option} instead.
|
|
101
|
+
*/
|
|
102
|
+
critical?: string[];
|
|
50
103
|
}
|
|
51
104
|
|
|
52
105
|
/**
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export {
|
|
1
|
+
import './shared/unjwt.CxhGjEAX.mjs';
|
|
2
|
+
export { h as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, j as isCryptoKey, k as isCryptoKeyPair, g as isJWK, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.BJEchXrM.mjs';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export {
|
|
1
|
+
import './shared/unjwt.CxhGjEAX.js';
|
|
2
|
+
export { h as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, f as concatUint8Arrays, j as isCryptoKey, k as isCryptoKeyPair, g as isJWK, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder } from './shared/unjwt.B5N3dPN9.js';
|
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as assertCryptoKey, d as base64UrlDecode, b as base64UrlEncode, e as concatUint8Arrays, g as isCryptoKey,
|
|
1
|
+
export { f as assertCryptoKey, h as base64Decode, j as base64Encode, d as base64UrlDecode, b as base64UrlEncode, e as concatUint8Arrays, g as isCryptoKey, k as isCryptoKeyPair, a as isJWK, m as maybeArray, r as randomBytes, c as textDecoder, t as textEncoder } from './shared/unjwt.DOI5UE8K.mjs';
|