jose 4.11.0 → 4.11.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 +1 -1
- package/dist/browser/key/import.js +1 -1
- package/dist/browser/util/errors.js +9 -9
- package/dist/node/cjs/key/import.js +1 -1
- package/dist/node/cjs/runtime/flags.js +8 -0
- package/dist/node/cjs/runtime/is_key_like.js +1 -1
- package/dist/node/cjs/runtime/jwk_to_key.js +2 -6
- package/dist/node/cjs/runtime/key_to_jwk.js +2 -6
- package/dist/node/cjs/runtime/node_key.js +7 -12
- package/dist/node/cjs/runtime/verify.js +2 -6
- package/dist/node/cjs/util/errors.js +9 -9
- package/dist/node/esm/key/import.js +1 -1
- package/dist/node/esm/runtime/flags.js +5 -0
- package/dist/node/esm/runtime/is_key_like.js +2 -2
- package/dist/node/esm/runtime/jwk_to_key.js +2 -6
- package/dist/node/esm/runtime/key_to_jwk.js +2 -6
- package/dist/node/esm/runtime/node_key.js +1 -6
- package/dist/node/esm/runtime/verify.js +2 -6
- package/dist/node/esm/util/errors.js +9 -9
- package/dist/types/jwk/embedded.d.ts +1 -1
- package/dist/types/jwt/decrypt.d.ts +3 -2
- package/dist/types/jwt/encrypt.d.ts +3 -2
- package/dist/types/jwt/sign.d.ts +80 -2
- package/dist/types/jwt/verify.d.ts +66 -2
- package/dist/types/key/import.d.ts +4 -4
- package/dist/types/util/decode_protected_header.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ export async function importX509(x509, alg, options) {
|
|
|
94
94
|
}
|
|
95
95
|
export async function importPKCS8(pkcs8, alg, options) {
|
|
96
96
|
if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {
|
|
97
|
-
throw new TypeError('"pkcs8" must be
|
|
97
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
98
98
|
}
|
|
99
99
|
return importPrivate(pkcs8, alg, options);
|
|
100
100
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export class JOSEError extends Error {
|
|
2
|
+
static get code() {
|
|
3
|
+
return 'ERR_JOSE_GENERIC';
|
|
4
|
+
}
|
|
2
5
|
constructor(message) {
|
|
3
6
|
var _a;
|
|
4
7
|
super(message);
|
|
@@ -6,31 +9,28 @@ export class JOSEError extends Error {
|
|
|
6
9
|
this.name = this.constructor.name;
|
|
7
10
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
8
11
|
}
|
|
9
|
-
static get code() {
|
|
10
|
-
return 'ERR_JOSE_GENERIC';
|
|
11
|
-
}
|
|
12
12
|
}
|
|
13
13
|
export class JWTClaimValidationFailed extends JOSEError {
|
|
14
|
+
static get code() {
|
|
15
|
+
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
16
|
+
}
|
|
14
17
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
15
18
|
super(message);
|
|
16
19
|
this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
17
20
|
this.claim = claim;
|
|
18
21
|
this.reason = reason;
|
|
19
22
|
}
|
|
20
|
-
static get code() {
|
|
21
|
-
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
22
|
-
}
|
|
23
23
|
}
|
|
24
24
|
export class JWTExpired extends JOSEError {
|
|
25
|
+
static get code() {
|
|
26
|
+
return 'ERR_JWT_EXPIRED';
|
|
27
|
+
}
|
|
25
28
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
26
29
|
super(message);
|
|
27
30
|
this.code = 'ERR_JWT_EXPIRED';
|
|
28
31
|
this.claim = claim;
|
|
29
32
|
this.reason = reason;
|
|
30
33
|
}
|
|
31
|
-
static get code() {
|
|
32
|
-
return 'ERR_JWT_EXPIRED';
|
|
33
|
-
}
|
|
34
34
|
}
|
|
35
35
|
export class JOSEAlgNotAllowed extends JOSEError {
|
|
36
36
|
constructor() {
|
|
@@ -99,7 +99,7 @@ async function importX509(x509, alg, options) {
|
|
|
99
99
|
exports.importX509 = importX509;
|
|
100
100
|
async function importPKCS8(pkcs8, alg, options) {
|
|
101
101
|
if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {
|
|
102
|
-
throw new TypeError('"pkcs8" must be
|
|
102
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
103
103
|
}
|
|
104
104
|
return (0, asn1_js_2.fromPKCS8)(pkcs8, alg, options);
|
|
105
105
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jwkImport = exports.jwkExport = exports.rsaPssParams = exports.oneShotCallback = void 0;
|
|
4
|
+
const [major, minor] = process.versions.node.split('.').map((str) => parseInt(str, 10));
|
|
5
|
+
exports.oneShotCallback = major >= 16 || (major === 15 && minor >= 13);
|
|
6
|
+
exports.rsaPssParams = !('electron' in process.versions) && (major >= 17 || (major === 16 && minor >= 9));
|
|
7
|
+
exports.jwkExport = major >= 16 || (major === 15 && minor >= 9);
|
|
8
|
+
exports.jwkImport = major >= 16 || (major === 15 && minor >= 12);
|
|
@@ -6,6 +6,6 @@ const is_key_object_js_1 = require("./is_key_object.js");
|
|
|
6
6
|
exports.default = (key) => (0, is_key_object_js_1.default)(key) || (0, webcrypto_js_1.isCryptoKey)(key);
|
|
7
7
|
const types = ['KeyObject'];
|
|
8
8
|
exports.types = types;
|
|
9
|
-
if (
|
|
9
|
+
if (globalThis.CryptoKey || (webcrypto_js_1.default === null || webcrypto_js_1.default === void 0 ? void 0 : webcrypto_js_1.default.CryptoKey)) {
|
|
10
10
|
types.push('CryptoKey');
|
|
11
11
|
}
|
|
@@ -7,13 +7,9 @@ const errors_js_1 = require("../util/errors.js");
|
|
|
7
7
|
const get_named_curve_js_1 = require("./get_named_curve.js");
|
|
8
8
|
const check_modulus_length_js_1 = require("./check_modulus_length.js");
|
|
9
9
|
const asn1_sequence_encoder_js_1 = require("./asn1_sequence_encoder.js");
|
|
10
|
-
const
|
|
11
|
-
.slice(1)
|
|
12
|
-
.split('.')
|
|
13
|
-
.map((str) => parseInt(str, 10));
|
|
14
|
-
const jwkImportSupported = major >= 16 || (major === 15 && minor >= 12);
|
|
10
|
+
const flags_js_1 = require("./flags.js");
|
|
15
11
|
const parse = (jwk) => {
|
|
16
|
-
if (
|
|
12
|
+
if (flags_js_1.jwkImport && jwk.kty !== 'oct') {
|
|
17
13
|
return jwk.d
|
|
18
14
|
? (0, crypto_1.createPrivateKey)({ format: 'jwk', key: jwk })
|
|
19
15
|
: (0, crypto_1.createPublicKey)({ format: 'jwk', key: jwk });
|
|
@@ -9,11 +9,7 @@ const webcrypto_js_1 = require("./webcrypto.js");
|
|
|
9
9
|
const is_key_object_js_1 = require("./is_key_object.js");
|
|
10
10
|
const invalid_key_input_js_1 = require("../lib/invalid_key_input.js");
|
|
11
11
|
const is_key_like_js_1 = require("./is_key_like.js");
|
|
12
|
-
const
|
|
13
|
-
.slice(1)
|
|
14
|
-
.split('.')
|
|
15
|
-
.map((str) => parseInt(str, 10));
|
|
16
|
-
const jwkExportSupported = major >= 16 || (major === 15 && minor >= 9);
|
|
12
|
+
const flags_js_1 = require("./flags.js");
|
|
17
13
|
const keyToJWK = (key) => {
|
|
18
14
|
let keyObject;
|
|
19
15
|
if ((0, webcrypto_js_1.isCryptoKey)(key)) {
|
|
@@ -34,7 +30,7 @@ const keyToJWK = (key) => {
|
|
|
34
30
|
else {
|
|
35
31
|
throw new TypeError((0, invalid_key_input_js_1.default)(key, ...is_key_like_js_1.types, 'Uint8Array'));
|
|
36
32
|
}
|
|
37
|
-
if (
|
|
33
|
+
if (flags_js_1.jwkExport) {
|
|
38
34
|
if (keyObject.type !== 'secret' &&
|
|
39
35
|
!['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {
|
|
40
36
|
throw new errors_js_1.JOSENotSupported('Unsupported key asymmetricKeyType');
|
|
@@ -4,12 +4,7 @@ const crypto_1 = require("crypto");
|
|
|
4
4
|
const get_named_curve_js_1 = require("./get_named_curve.js");
|
|
5
5
|
const errors_js_1 = require("../util/errors.js");
|
|
6
6
|
const check_modulus_length_js_1 = require("./check_modulus_length.js");
|
|
7
|
-
const
|
|
8
|
-
.slice(1)
|
|
9
|
-
.split('.')
|
|
10
|
-
.map((str) => parseInt(str, 10));
|
|
11
|
-
const electron = 'electron' in process.versions;
|
|
12
|
-
const rsaPssParams = !electron && (major >= 17 || (major === 16 && minor >= 9));
|
|
7
|
+
const flags_js_1 = require("./flags.js");
|
|
13
8
|
const PSS = {
|
|
14
9
|
padding: crypto_1.constants.RSA_PKCS1_PSS_PADDING,
|
|
15
10
|
saltLength: crypto_1.constants.RSA_PSS_SALTLEN_DIGEST,
|
|
@@ -35,9 +30,9 @@ function keyForCrypto(alg, key) {
|
|
|
35
30
|
}
|
|
36
31
|
(0, check_modulus_length_js_1.default)(key, alg);
|
|
37
32
|
return key;
|
|
38
|
-
case rsaPssParams && 'PS256':
|
|
39
|
-
case rsaPssParams && 'PS384':
|
|
40
|
-
case rsaPssParams && 'PS512':
|
|
33
|
+
case flags_js_1.rsaPssParams && 'PS256':
|
|
34
|
+
case flags_js_1.rsaPssParams && 'PS384':
|
|
35
|
+
case flags_js_1.rsaPssParams && 'PS512':
|
|
41
36
|
if (key.asymmetricKeyType === 'rsa-pss') {
|
|
42
37
|
const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;
|
|
43
38
|
const length = parseInt(alg.slice(-3), 10);
|
|
@@ -54,9 +49,9 @@ function keyForCrypto(alg, key) {
|
|
|
54
49
|
}
|
|
55
50
|
(0, check_modulus_length_js_1.default)(key, alg);
|
|
56
51
|
return { key, ...PSS };
|
|
57
|
-
case !rsaPssParams && 'PS256':
|
|
58
|
-
case !rsaPssParams && 'PS384':
|
|
59
|
-
case !rsaPssParams && 'PS512':
|
|
52
|
+
case !flags_js_1.rsaPssParams && 'PS256':
|
|
53
|
+
case !flags_js_1.rsaPssParams && 'PS384':
|
|
54
|
+
case !flags_js_1.rsaPssParams && 'PS512':
|
|
60
55
|
if (key.asymmetricKeyType !== 'rsa') {
|
|
61
56
|
throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');
|
|
62
57
|
}
|
|
@@ -6,13 +6,9 @@ const dsa_digest_js_1 = require("./dsa_digest.js");
|
|
|
6
6
|
const node_key_js_1 = require("./node_key.js");
|
|
7
7
|
const sign_js_1 = require("./sign.js");
|
|
8
8
|
const get_sign_verify_key_js_1 = require("./get_sign_verify_key.js");
|
|
9
|
-
const
|
|
10
|
-
.slice(1)
|
|
11
|
-
.split('.')
|
|
12
|
-
.map((str) => parseInt(str, 10));
|
|
13
|
-
const oneShotCallbackSupported = major >= 16 || (major === 15 && minor >= 13);
|
|
9
|
+
const flags_js_1 = require("./flags.js");
|
|
14
10
|
let oneShotVerify;
|
|
15
|
-
if (crypto.verify.length > 4 &&
|
|
11
|
+
if (crypto.verify.length > 4 && flags_js_1.oneShotCallback) {
|
|
16
12
|
oneShotVerify = (0, util_1.promisify)(crypto.verify);
|
|
17
13
|
}
|
|
18
14
|
else {
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JWSSignatureVerificationFailed = exports.JWKSTimeout = exports.JWKSMultipleMatchingKeys = exports.JWKSNoMatchingKey = exports.JWKSInvalid = exports.JWKInvalid = exports.JWTInvalid = exports.JWSInvalid = exports.JWEInvalid = exports.JWEDecryptionFailed = exports.JOSENotSupported = exports.JOSEAlgNotAllowed = exports.JWTExpired = exports.JWTClaimValidationFailed = exports.JOSEError = void 0;
|
|
4
4
|
class JOSEError extends Error {
|
|
5
|
+
static get code() {
|
|
6
|
+
return 'ERR_JOSE_GENERIC';
|
|
7
|
+
}
|
|
5
8
|
constructor(message) {
|
|
6
9
|
var _a;
|
|
7
10
|
super(message);
|
|
@@ -9,33 +12,30 @@ class JOSEError extends Error {
|
|
|
9
12
|
this.name = this.constructor.name;
|
|
10
13
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
11
14
|
}
|
|
12
|
-
static get code() {
|
|
13
|
-
return 'ERR_JOSE_GENERIC';
|
|
14
|
-
}
|
|
15
15
|
}
|
|
16
16
|
exports.JOSEError = JOSEError;
|
|
17
17
|
class JWTClaimValidationFailed extends JOSEError {
|
|
18
|
+
static get code() {
|
|
19
|
+
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
20
|
+
}
|
|
18
21
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
19
22
|
super(message);
|
|
20
23
|
this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
21
24
|
this.claim = claim;
|
|
22
25
|
this.reason = reason;
|
|
23
26
|
}
|
|
24
|
-
static get code() {
|
|
25
|
-
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
26
|
-
}
|
|
27
27
|
}
|
|
28
28
|
exports.JWTClaimValidationFailed = JWTClaimValidationFailed;
|
|
29
29
|
class JWTExpired extends JOSEError {
|
|
30
|
+
static get code() {
|
|
31
|
+
return 'ERR_JWT_EXPIRED';
|
|
32
|
+
}
|
|
30
33
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
31
34
|
super(message);
|
|
32
35
|
this.code = 'ERR_JWT_EXPIRED';
|
|
33
36
|
this.claim = claim;
|
|
34
37
|
this.reason = reason;
|
|
35
38
|
}
|
|
36
|
-
static get code() {
|
|
37
|
-
return 'ERR_JWT_EXPIRED';
|
|
38
|
-
}
|
|
39
39
|
}
|
|
40
40
|
exports.JWTExpired = JWTExpired;
|
|
41
41
|
class JOSEAlgNotAllowed extends JOSEError {
|
|
@@ -94,7 +94,7 @@ export async function importX509(x509, alg, options) {
|
|
|
94
94
|
}
|
|
95
95
|
export async function importPKCS8(pkcs8, alg, options) {
|
|
96
96
|
if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {
|
|
97
|
-
throw new TypeError('"pkcs8" must be
|
|
97
|
+
throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
|
|
98
98
|
}
|
|
99
99
|
return importPrivate(pkcs8, alg, options);
|
|
100
100
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const [major, minor] = process.versions.node.split('.').map((str) => parseInt(str, 10));
|
|
2
|
+
export const oneShotCallback = major >= 16 || (major === 15 && minor >= 13);
|
|
3
|
+
export const rsaPssParams = !('electron' in process.versions) && (major >= 17 || (major === 16 && minor >= 9));
|
|
4
|
+
export const jwkExport = major >= 16 || (major === 15 && minor >= 9);
|
|
5
|
+
export const jwkImport = major >= 16 || (major === 15 && minor >= 12);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isCryptoKey } from './webcrypto.js';
|
|
1
|
+
import webcrypto, { isCryptoKey } from './webcrypto.js';
|
|
2
2
|
import isKeyObject from './is_key_object.js';
|
|
3
3
|
export default (key) => isKeyObject(key) || isCryptoKey(key);
|
|
4
4
|
const types = ['KeyObject'];
|
|
5
|
-
if (
|
|
5
|
+
if (globalThis.CryptoKey || (webcrypto === null || webcrypto === void 0 ? void 0 : webcrypto.CryptoKey)) {
|
|
6
6
|
types.push('CryptoKey');
|
|
7
7
|
}
|
|
8
8
|
export { types };
|
|
@@ -5,13 +5,9 @@ import { JOSENotSupported } from '../util/errors.js';
|
|
|
5
5
|
import { setCurve } from './get_named_curve.js';
|
|
6
6
|
import { setModulusLength } from './check_modulus_length.js';
|
|
7
7
|
import Asn1SequenceEncoder from './asn1_sequence_encoder.js';
|
|
8
|
-
|
|
9
|
-
.slice(1)
|
|
10
|
-
.split('.')
|
|
11
|
-
.map((str) => parseInt(str, 10));
|
|
12
|
-
const jwkImportSupported = major >= 16 || (major === 15 && minor >= 12);
|
|
8
|
+
import { jwkImport } from './flags.js';
|
|
13
9
|
const parse = (jwk) => {
|
|
14
|
-
if (
|
|
10
|
+
if (jwkImport && jwk.kty !== 'oct') {
|
|
15
11
|
return jwk.d
|
|
16
12
|
? createPrivateKey({ format: 'jwk', key: jwk })
|
|
17
13
|
: createPublicKey({ format: 'jwk', key: jwk });
|
|
@@ -7,11 +7,7 @@ import { isCryptoKey } from './webcrypto.js';
|
|
|
7
7
|
import isKeyObject from './is_key_object.js';
|
|
8
8
|
import invalidKeyInput from '../lib/invalid_key_input.js';
|
|
9
9
|
import { types } from './is_key_like.js';
|
|
10
|
-
|
|
11
|
-
.slice(1)
|
|
12
|
-
.split('.')
|
|
13
|
-
.map((str) => parseInt(str, 10));
|
|
14
|
-
const jwkExportSupported = major >= 16 || (major === 15 && minor >= 9);
|
|
10
|
+
import { jwkExport } from './flags.js';
|
|
15
11
|
const keyToJWK = (key) => {
|
|
16
12
|
let keyObject;
|
|
17
13
|
if (isCryptoKey(key)) {
|
|
@@ -32,7 +28,7 @@ const keyToJWK = (key) => {
|
|
|
32
28
|
else {
|
|
33
29
|
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));
|
|
34
30
|
}
|
|
35
|
-
if (
|
|
31
|
+
if (jwkExport) {
|
|
36
32
|
if (keyObject.type !== 'secret' &&
|
|
37
33
|
!['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {
|
|
38
34
|
throw new JOSENotSupported('Unsupported key asymmetricKeyType');
|
|
@@ -2,12 +2,7 @@ import { constants } from 'crypto';
|
|
|
2
2
|
import getNamedCurve from './get_named_curve.js';
|
|
3
3
|
import { JOSENotSupported } from '../util/errors.js';
|
|
4
4
|
import checkModulusLength from './check_modulus_length.js';
|
|
5
|
-
|
|
6
|
-
.slice(1)
|
|
7
|
-
.split('.')
|
|
8
|
-
.map((str) => parseInt(str, 10));
|
|
9
|
-
const electron = 'electron' in process.versions;
|
|
10
|
-
const rsaPssParams = !electron && (major >= 17 || (major === 16 && minor >= 9));
|
|
5
|
+
import { rsaPssParams } from './flags.js';
|
|
11
6
|
const PSS = {
|
|
12
7
|
padding: constants.RSA_PKCS1_PSS_PADDING,
|
|
13
8
|
saltLength: constants.RSA_PSS_SALTLEN_DIGEST,
|
|
@@ -4,13 +4,9 @@ import nodeDigest from './dsa_digest.js';
|
|
|
4
4
|
import nodeKey from './node_key.js';
|
|
5
5
|
import sign from './sign.js';
|
|
6
6
|
import getVerifyKey from './get_sign_verify_key.js';
|
|
7
|
-
|
|
8
|
-
.slice(1)
|
|
9
|
-
.split('.')
|
|
10
|
-
.map((str) => parseInt(str, 10));
|
|
11
|
-
const oneShotCallbackSupported = major >= 16 || (major === 15 && minor >= 13);
|
|
7
|
+
import { oneShotCallback } from './flags.js';
|
|
12
8
|
let oneShotVerify;
|
|
13
|
-
if (crypto.verify.length > 4 &&
|
|
9
|
+
if (crypto.verify.length > 4 && oneShotCallback) {
|
|
14
10
|
oneShotVerify = promisify(crypto.verify);
|
|
15
11
|
}
|
|
16
12
|
else {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export class JOSEError extends Error {
|
|
2
|
+
static get code() {
|
|
3
|
+
return 'ERR_JOSE_GENERIC';
|
|
4
|
+
}
|
|
2
5
|
constructor(message) {
|
|
3
6
|
var _a;
|
|
4
7
|
super(message);
|
|
@@ -6,31 +9,28 @@ export class JOSEError extends Error {
|
|
|
6
9
|
this.name = this.constructor.name;
|
|
7
10
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
8
11
|
}
|
|
9
|
-
static get code() {
|
|
10
|
-
return 'ERR_JOSE_GENERIC';
|
|
11
|
-
}
|
|
12
12
|
}
|
|
13
13
|
export class JWTClaimValidationFailed extends JOSEError {
|
|
14
|
+
static get code() {
|
|
15
|
+
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
16
|
+
}
|
|
14
17
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
15
18
|
super(message);
|
|
16
19
|
this.code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
17
20
|
this.claim = claim;
|
|
18
21
|
this.reason = reason;
|
|
19
22
|
}
|
|
20
|
-
static get code() {
|
|
21
|
-
return 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
22
|
-
}
|
|
23
23
|
}
|
|
24
24
|
export class JWTExpired extends JOSEError {
|
|
25
|
+
static get code() {
|
|
26
|
+
return 'ERR_JWT_EXPIRED';
|
|
27
|
+
}
|
|
25
28
|
constructor(message, claim = 'unspecified', reason = 'unspecified') {
|
|
26
29
|
super(message);
|
|
27
30
|
this.code = 'ERR_JWT_EXPIRED';
|
|
28
31
|
this.claim = claim;
|
|
29
32
|
this.reason = reason;
|
|
30
33
|
}
|
|
31
|
-
static get code() {
|
|
32
|
-
return 'ERR_JWT_EXPIRED';
|
|
33
|
-
}
|
|
34
34
|
}
|
|
35
35
|
export class JOSEAlgNotAllowed extends JOSEError {
|
|
36
36
|
constructor() {
|
|
@@ -3,7 +3,7 @@ import type { FlattenedJWSInput, JWSHeaderParameters } from '../types';
|
|
|
3
3
|
* EmbeddedJWK is an implementation of a GetKeyFunction intended to be used with the JWS/JWT verify
|
|
4
4
|
* operations whenever you need to opt-in to verify signatures with a public key embedded in the
|
|
5
5
|
* token's "jwk" (JSON Web Key) Header Parameter. It is recommended to combine this with the verify
|
|
6
|
-
* algorithms option to
|
|
6
|
+
* function's `algorithms` option to define accepted JWS "alg" (Algorithm) Header Parameter values.
|
|
7
7
|
*
|
|
8
8
|
* @example Usage
|
|
9
9
|
*
|
|
@@ -15,10 +15,11 @@ export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParamet
|
|
|
15
15
|
* @example Usage
|
|
16
16
|
*
|
|
17
17
|
* ```js
|
|
18
|
+
* const secret = jose.base64url.decode('zH4NRP1HMALxxCFnRZABFA7GOJtzU_gIj02alfL1lvI')
|
|
18
19
|
* const jwt =
|
|
19
|
-
* '
|
|
20
|
+
* 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..MB66qstZBPxAXKdsjet_lA.WHbtJTl4taHp7otOHLq3hBvv0yNPsPEKHYInmCPdDDeyV1kU-f-tGEiU4FxlSqkqAT2hVs8_wMNiQFAzPU1PUgIqWCPsBrPP3TtxYsrtwagpn4SvCsUsx0Mhw9ZhliAO8CLmCBQkqr_T9AcYsz5uZw.7nX9m7BGUu_u1p1qFHzyIg'
|
|
20
21
|
*
|
|
21
|
-
* const { payload, protectedHeader } = await jose.jwtDecrypt(jwt,
|
|
22
|
+
* const { payload, protectedHeader } = await jose.jwtDecrypt(jwt, secret, {
|
|
22
23
|
* issuer: 'urn:example:issuer',
|
|
23
24
|
* audience: 'urn:example:audience',
|
|
24
25
|
* })
|
|
@@ -6,13 +6,14 @@ import { ProduceJWT } from './produce';
|
|
|
6
6
|
* @example Usage
|
|
7
7
|
*
|
|
8
8
|
* ```js
|
|
9
|
+
* const secret = jose.base64url.decode('zH4NRP1HMALxxCFnRZABFA7GOJtzU_gIj02alfL1lvI')
|
|
9
10
|
* const jwt = await new jose.EncryptJWT({ 'urn:example:claim': true })
|
|
10
|
-
* .setProtectedHeader({ alg: 'dir', enc: '
|
|
11
|
+
* .setProtectedHeader({ alg: 'dir', enc: 'A128CBC-HS256' })
|
|
11
12
|
* .setIssuedAt()
|
|
12
13
|
* .setIssuer('urn:example:issuer')
|
|
13
14
|
* .setAudience('urn:example:audience')
|
|
14
15
|
* .setExpirationTime('2h')
|
|
15
|
-
* .encrypt(
|
|
16
|
+
* .encrypt(secret)
|
|
16
17
|
*
|
|
17
18
|
* console.log(jwt)
|
|
18
19
|
* ```
|
package/dist/types/jwt/sign.d.ts
CHANGED
|
@@ -3,11 +3,89 @@ import { ProduceJWT } from './produce';
|
|
|
3
3
|
/**
|
|
4
4
|
* The SignJWT class is a utility for creating Compact JWS formatted JWT strings.
|
|
5
5
|
*
|
|
6
|
-
* @example Usage
|
|
6
|
+
* @example Usage with a symmetric secret
|
|
7
7
|
*
|
|
8
8
|
* ```js
|
|
9
|
+
* const secret = new TextEncoder().encode(
|
|
10
|
+
* 'cc7e0d44fd473002f1c42167459001140ec6389b7353f8088f4d9a95f2f596f2',
|
|
11
|
+
* )
|
|
12
|
+
* const alg = 'HS256'
|
|
13
|
+
*
|
|
14
|
+
* const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
|
|
15
|
+
* .setProtectedHeader({ alg })
|
|
16
|
+
* .setIssuedAt()
|
|
17
|
+
* .setIssuer('urn:example:issuer')
|
|
18
|
+
* .setAudience('urn:example:audience')
|
|
19
|
+
* .setExpirationTime('2h')
|
|
20
|
+
* .sign(secret)
|
|
21
|
+
*
|
|
22
|
+
* console.log(jwt)
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example Usage with a private PKCS#8 encoded RSA key
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* const alg = 'RS256'
|
|
29
|
+
* const pkcs8 = `-----BEGIN PRIVATE KEY-----
|
|
30
|
+
* MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDCFg4UrY5xtulv
|
|
31
|
+
* /NXKmL1J4qI1SopAfTNMo3X7p+kJO7plqUYjzaztcre1qfh0m33Sm1Q8oPbO/GpP
|
|
32
|
+
* MU1/HgcceytgJ/b4UwufVVMl9BrMDYG8moDBylbVupFQS3Ly1L9i/iFG9Z9A9xzY
|
|
33
|
+
* Zzf799A45bnvNXL6s2glzvjiRvfQ2NDF0anTcnZLcYtC7ugq1IMM+ihAcPfw8Qw2
|
|
34
|
+
* chN/SmP4qAM+PKaQwagmU7doqmmyN9u38AfoYZ1GCFhEs5TBBT6H6h9YdHeVtiIq
|
|
35
|
+
* 1c+fl03biSIfLrV7dUBD39gBmXBcL/30Ya3D82mCEUC4zg/UkOfQOmkmV3Lc8YUL
|
|
36
|
+
* QZ8EJkBLAgMBAAECggEAVuVE/KEP6323WjpbBdAIv7HGahGrgGANvbxZsIhm34ls
|
|
37
|
+
* VOPK0XDegZkhAybMZHjRhp+gwVxX5ChC+J3cUpOBH5FNxElgW6HizD2Jcq6t6LoL
|
|
38
|
+
* YgPSrfEHm71iHg8JsgrqfUnGYFzMJmv88C6WdCtpgG/qJV1K00/Ly1G1QKoBffEs
|
|
39
|
+
* +v4fAMJrCbUdCz1qWto+PU+HLMEo+krfEpGgcmtZeRlDADh8cETMQlgQfQX2VWq/
|
|
40
|
+
* aAP4a1SXmo+j0cvRU4W5Fj0RVwNesIpetX2ZFz4p/JmB5sWFEj/fC7h5z2lq+6Bm
|
|
41
|
+
* e2T3BHtXkIxoBW0/pYVnASC8P2puO5FnVxDmWuHDYQKBgQDTuuBd3+0tSFVEX+DU
|
|
42
|
+
* 5qpFmHm5nyGItZRJTS+71yg5pBxq1KqNCUjAtbxR0q//fwauakh+BwRVCPOrqsUG
|
|
43
|
+
* jBSb3NYE70Srp6elqxgkE54PwQx4Mr6exJPnseM9U4K+hULllf5yjM9edreJE1nV
|
|
44
|
+
* NVgFjeyafQhrHKwgr7PERJ/ikwKBgQDqqsT1M+EJLmI1HtCspOG6cu7q3gf/wKRh
|
|
45
|
+
* E8tu84i3YyBnI8uJkKy92RNVI5fvpBARe3tjSdM25rr2rcrcmF/5g6Q9ImxZPGCt
|
|
46
|
+
* 86eOgO9ErNtbc4TEgybsP319UE4O41aKeNiBTAZKoYCxv/dMqG0j4avmWzd+foHq
|
|
47
|
+
* gSNUvR2maQKBgQCYeqOsV2B6VPY7KIVFLd0AA9/dwvEmgAYLiA/RShDI+hwQ/5jX
|
|
48
|
+
* uxDu37KAhqeC65sHLrmIMUt4Zdr+DRyZK3aIDNEAesPMjw/X6lCXYp1ZISD2yyym
|
|
49
|
+
* MFGH8X8CIkstI9Faf9vf6PJKSFrC1/HA7wq17VCwrUzLvrljTMW8meM/CwKBgCpo
|
|
50
|
+
* 2leGHLFQFKeM/iF1WuYbR1pi7gcmhY6VyTowARFDdOOu8GXYI5/bz0afvCGvAMho
|
|
51
|
+
* DJCREv7lC/zww6zCTPYG+HOj+PjXlJFba3ixjIxYwPvyEJiDK1Ge18sB7Fl8dHNq
|
|
52
|
+
* C5ayaqCqN1voWYUdGzxU2IA1E/5kVo5O8FesJeOhAoGBAImJbZFf+D5kA32Xxhac
|
|
53
|
+
* 59lLWBCsocvvbd1cvDMNlRywAAyhsCb1SuX4nEAK9mrSBdfmoF2Nm3eilfsOds0f
|
|
54
|
+
* K5mX069IKG82CMqh3Mzptd7e7lyb9lsoGO0BAtjho3cWtha/UZ70vfaMzGuZ6JmQ
|
|
55
|
+
* ak6k+8+UFd93M4z0Qo74OhXB
|
|
56
|
+
* -----END PRIVATE KEY----`
|
|
57
|
+
* const privateKey = await jose.importPKCS8(pkcs8, alg)
|
|
58
|
+
*
|
|
59
|
+
* const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
|
|
60
|
+
* .setProtectedHeader({ alg })
|
|
61
|
+
* .setIssuedAt()
|
|
62
|
+
* .setIssuer('urn:example:issuer')
|
|
63
|
+
* .setAudience('urn:example:audience')
|
|
64
|
+
* .setExpirationTime('2h')
|
|
65
|
+
* .sign(privateKey)
|
|
66
|
+
*
|
|
67
|
+
* console.log(jwt)
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Usage with a private JWK encoded RSA key
|
|
71
|
+
*
|
|
72
|
+
* ```js
|
|
73
|
+
* const alg = 'RS256'
|
|
74
|
+
* const jwk = {
|
|
75
|
+
* kty: 'RSA',
|
|
76
|
+
* n: 'whYOFK2Ocbbpb_zVypi9SeKiNUqKQH0zTKN1-6fpCTu6ZalGI82s7XK3tan4dJt90ptUPKD2zvxqTzFNfx4HHHsrYCf2-FMLn1VTJfQazA2BvJqAwcpW1bqRUEty8tS_Yv4hRvWfQPcc2Gc3-_fQOOW57zVy-rNoJc744kb30NjQxdGp03J2S3GLQu7oKtSDDPooQHD38PEMNnITf0pj-KgDPjymkMGoJlO3aKppsjfbt_AH6GGdRghYRLOUwQU-h-ofWHR3lbYiKtXPn5dN24kiHy61e3VAQ9_YAZlwXC_99GGtw_NpghFAuM4P1JDn0DppJldy3PGFC0GfBCZASw',
|
|
77
|
+
* e: 'AQAB',
|
|
78
|
+
* d: 'VuVE_KEP6323WjpbBdAIv7HGahGrgGANvbxZsIhm34lsVOPK0XDegZkhAybMZHjRhp-gwVxX5ChC-J3cUpOBH5FNxElgW6HizD2Jcq6t6LoLYgPSrfEHm71iHg8JsgrqfUnGYFzMJmv88C6WdCtpgG_qJV1K00_Ly1G1QKoBffEs-v4fAMJrCbUdCz1qWto-PU-HLMEo-krfEpGgcmtZeRlDADh8cETMQlgQfQX2VWq_aAP4a1SXmo-j0cvRU4W5Fj0RVwNesIpetX2ZFz4p_JmB5sWFEj_fC7h5z2lq-6Bme2T3BHtXkIxoBW0_pYVnASC8P2puO5FnVxDmWuHDYQ',
|
|
79
|
+
* p: '07rgXd_tLUhVRF_g1OaqRZh5uZ8hiLWUSU0vu9coOaQcatSqjQlIwLW8UdKv_38GrmpIfgcEVQjzq6rFBowUm9zWBO9Eq6enpasYJBOeD8EMeDK-nsST57HjPVOCvoVC5ZX-cozPXna3iRNZ1TVYBY3smn0IaxysIK-zxESf4pM',
|
|
80
|
+
* q: '6qrE9TPhCS5iNR7QrKThunLu6t4H_8CkYRPLbvOIt2MgZyPLiZCsvdkTVSOX76QQEXt7Y0nTNua69q3K3Jhf-YOkPSJsWTxgrfOnjoDvRKzbW3OExIMm7D99fVBODuNWinjYgUwGSqGAsb_3TKhtI-Gr5ls3fn6B6oEjVL0dpmk',
|
|
81
|
+
* dp: 'mHqjrFdgelT2OyiFRS3dAAPf3cLxJoAGC4gP0UoQyPocEP-Y17sQ7t-ygIanguubBy65iDFLeGXa_g0cmSt2iAzRAHrDzI8P1-pQl2KdWSEg9ssspjBRh_F_AiJLLSPRWn_b3-jySkhawtfxwO8Kte1QsK1My765Y0zFvJnjPws',
|
|
82
|
+
* dq: 'KmjaV4YcsVAUp4z-IXVa5htHWmLuByaFjpXJOjABEUN0467wZdgjn9vPRp-8Ia8AyGgMkJES_uUL_PDDrMJM9gb4c6P4-NeUkVtreLGMjFjA-_IQmIMrUZ7XywHsWXx0c2oLlrJqoKo3W-hZhR0bPFTYgDUT_mRWjk7wV6wl46E',
|
|
83
|
+
* qi: 'iYltkV_4PmQDfZfGFpzn2UtYEKyhy-9t3Vy8Mw2VHLAADKGwJvVK5ficQAr2atIF1-agXY2bd6KV-w52zR8rmZfTr0gobzYIyqHczOm13t7uXJv2WygY7QEC2OGjdxa2Fr9RnvS99ozMa5nomZBqTqT7z5QV33czjPRCjvg6FcE',
|
|
84
|
+
* }
|
|
85
|
+
* const privateKey = await jose.importJWK(jwk, alg)
|
|
86
|
+
*
|
|
9
87
|
* const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
|
|
10
|
-
* .setProtectedHeader({ alg
|
|
88
|
+
* .setProtectedHeader({ alg })
|
|
11
89
|
* .setIssuedAt()
|
|
12
90
|
* .setIssuer('urn:example:issuer')
|
|
13
91
|
* .setAudience('urn:example:audience')
|
|
@@ -16,11 +16,62 @@ export interface JWTVerifyGetKey extends GetKeyFunction<JWTHeaderParameters, Fla
|
|
|
16
16
|
* Verifies the JWT format (to be a JWS Compact format), verifies the JWS signature, validates the
|
|
17
17
|
* JWT Claims Set.
|
|
18
18
|
*
|
|
19
|
-
* @example Usage
|
|
19
|
+
* @example Usage with a symmetric secret
|
|
20
20
|
*
|
|
21
21
|
* ```js
|
|
22
|
+
* const secret = new TextEncoder().encode(
|
|
23
|
+
* 'cc7e0d44fd473002f1c42167459001140ec6389b7353f8088f4d9a95f2f596f2',
|
|
24
|
+
* )
|
|
22
25
|
* const jwt =
|
|
23
|
-
* '
|
|
26
|
+
* 'eyJhbGciOiJIUzI1NiJ9.eyJ1cm46ZXhhbXBsZTpjbGFpbSI6dHJ1ZSwiaWF0IjoxNjY5MDU2MjMxLCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSJ9.C4iSlLfAUMBq--wnC6VqD9gEOhwpRZpoRarE0m7KEnI'
|
|
27
|
+
*
|
|
28
|
+
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, secret, {
|
|
29
|
+
* issuer: 'urn:example:issuer',
|
|
30
|
+
* audience: 'urn:example:audience',
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* console.log(protectedHeader)
|
|
34
|
+
* console.log(payload)
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Usage with a public SPKI encoded RSA key
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* const alg = 'RS256'
|
|
41
|
+
* const spki = `-----BEGIN PUBLIC KEY-----
|
|
42
|
+
* MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwhYOFK2Ocbbpb/zVypi9
|
|
43
|
+
* SeKiNUqKQH0zTKN1+6fpCTu6ZalGI82s7XK3tan4dJt90ptUPKD2zvxqTzFNfx4H
|
|
44
|
+
* HHsrYCf2+FMLn1VTJfQazA2BvJqAwcpW1bqRUEty8tS/Yv4hRvWfQPcc2Gc3+/fQ
|
|
45
|
+
* OOW57zVy+rNoJc744kb30NjQxdGp03J2S3GLQu7oKtSDDPooQHD38PEMNnITf0pj
|
|
46
|
+
* +KgDPjymkMGoJlO3aKppsjfbt/AH6GGdRghYRLOUwQU+h+ofWHR3lbYiKtXPn5dN
|
|
47
|
+
* 24kiHy61e3VAQ9/YAZlwXC/99GGtw/NpghFAuM4P1JDn0DppJldy3PGFC0GfBCZA
|
|
48
|
+
* SwIDAQAB
|
|
49
|
+
* -----END PUBLIC KEY-----`
|
|
50
|
+
* const publicKey = await jose.importSPKI(spki, alg)
|
|
51
|
+
* const jwt =
|
|
52
|
+
* 'eyJhbGciOiJSUzI1NiJ9.eyJ1cm46ZXhhbXBsZTpjbGFpbSI6dHJ1ZSwiaWF0IjoxNjY5MDU2NDg4LCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSJ9.gXrPZ3yM_60dMXGE69dusbpzYASNA-XIOwsb5D5xYnSxyj6_D6OR_uR_1vqhUm4AxZxcrH1_-XJAve9HCw8az_QzHcN-nETt-v6stCsYrn6Bv1YOc-mSJRZ8ll57KVqLbCIbjKwerNX5r2_Qg2TwmJzQdRs-AQDhy-s_DlJd8ql6wR4n-kDZpar-pwIvz4fFIN0Fj57SXpAbLrV6Eo4Byzl0xFD8qEYEpBwjrMMfxCZXTlAVhAq6KCoGlDTwWuExps342-0UErEtyIqDnDGcrfNWiUsoo8j-29IpKd-w9-C388u-ChCxoHz--H8WmMSZzx3zTXsZ5lXLZ9IKfanDKg'
|
|
53
|
+
*
|
|
54
|
+
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, publicKey, {
|
|
55
|
+
* issuer: 'urn:example:issuer',
|
|
56
|
+
* audience: 'urn:example:audience',
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* console.log(protectedHeader)
|
|
60
|
+
* console.log(payload)
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Usage with a public JWK encoded RSA key
|
|
64
|
+
*
|
|
65
|
+
* ```js
|
|
66
|
+
* const alg = 'RS256'
|
|
67
|
+
* const jwk = {
|
|
68
|
+
* kty: 'RSA',
|
|
69
|
+
* n: 'whYOFK2Ocbbpb_zVypi9SeKiNUqKQH0zTKN1-6fpCTu6ZalGI82s7XK3tan4dJt90ptUPKD2zvxqTzFNfx4HHHsrYCf2-FMLn1VTJfQazA2BvJqAwcpW1bqRUEty8tS_Yv4hRvWfQPcc2Gc3-_fQOOW57zVy-rNoJc744kb30NjQxdGp03J2S3GLQu7oKtSDDPooQHD38PEMNnITf0pj-KgDPjymkMGoJlO3aKppsjfbt_AH6GGdRghYRLOUwQU-h-ofWHR3lbYiKtXPn5dN24kiHy61e3VAQ9_YAZlwXC_99GGtw_NpghFAuM4P1JDn0DppJldy3PGFC0GfBCZASw',
|
|
70
|
+
* e: 'AQAB',
|
|
71
|
+
* }
|
|
72
|
+
* const publicKey = await jose.importJWK(jwk, alg)
|
|
73
|
+
* const jwt =
|
|
74
|
+
* 'eyJhbGciOiJSUzI1NiJ9.eyJ1cm46ZXhhbXBsZTpjbGFpbSI6dHJ1ZSwiaWF0IjoxNjY5MDU2NDg4LCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSJ9.gXrPZ3yM_60dMXGE69dusbpzYASNA-XIOwsb5D5xYnSxyj6_D6OR_uR_1vqhUm4AxZxcrH1_-XJAve9HCw8az_QzHcN-nETt-v6stCsYrn6Bv1YOc-mSJRZ8ll57KVqLbCIbjKwerNX5r2_Qg2TwmJzQdRs-AQDhy-s_DlJd8ql6wR4n-kDZpar-pwIvz4fFIN0Fj57SXpAbLrV6Eo4Byzl0xFD8qEYEpBwjrMMfxCZXTlAVhAq6KCoGlDTwWuExps342-0UErEtyIqDnDGcrfNWiUsoo8j-29IpKd-w9-C388u-ChCxoHz--H8WmMSZzx3zTXsZ5lXLZ9IKfanDKg'
|
|
24
75
|
*
|
|
25
76
|
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, publicKey, {
|
|
26
77
|
* issuer: 'urn:example:issuer',
|
|
@@ -37,6 +88,19 @@ export interface JWTVerifyGetKey extends GetKeyFunction<JWTHeaderParameters, Fla
|
|
|
37
88
|
*/
|
|
38
89
|
export declare function jwtVerify(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTVerifyOptions): Promise<JWTVerifyResult>;
|
|
39
90
|
/**
|
|
91
|
+
* @example Usage with a public JSON Web Key Set hosted on a remote URL
|
|
92
|
+
*
|
|
93
|
+
* ```js
|
|
94
|
+
* const JWKS = jose.createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))
|
|
95
|
+
*
|
|
96
|
+
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
|
|
97
|
+
* issuer: 'urn:example:issuer',
|
|
98
|
+
* audience: 'urn:example:audience',
|
|
99
|
+
* })
|
|
100
|
+
* console.log(protectedHeader)
|
|
101
|
+
* console.log(payload)
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
40
104
|
* @param jwt JSON Web Token value (encoded as JWS).
|
|
41
105
|
* @param getKey Function resolving a key to verify the JWT with.
|
|
42
106
|
* @param options JWT Decryption and JWT Claims Set validation options.
|
|
@@ -55,9 +55,9 @@ export declare function importSPKI(spki: string, alg: string, options?: PEMImpor
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function importX509(x509: string, alg: string, options?: PEMImportOptions): Promise<KeyLike>;
|
|
57
57
|
/**
|
|
58
|
-
* Imports a PEM-encoded
|
|
59
|
-
* CryptoKey). See [Algorithm Key Requirements](https://github.com/panva/jose/issues/210) to
|
|
60
|
-
* about key to algorithm requirements and mapping. Encrypted keys are not supported.
|
|
58
|
+
* Imports a PEM-encoded PKCS#8 string as a runtime-specific private key representation (KeyObject
|
|
59
|
+
* or CryptoKey). See [Algorithm Key Requirements](https://github.com/panva/jose/issues/210) to
|
|
60
|
+
* learn about key to algorithm requirements and mapping. Encrypted keys are not supported.
|
|
61
61
|
*
|
|
62
62
|
* @example Usage
|
|
63
63
|
*
|
|
@@ -71,7 +71,7 @@ export declare function importX509(x509: string, alg: string, options?: PEMImpor
|
|
|
71
71
|
* const ecPrivateKey = await jose.importPKCS8(pkcs8, algorithm)
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
|
-
* @param pem PEM-encoded
|
|
74
|
+
* @param pem PEM-encoded PKCS#8 string
|
|
75
75
|
* @param alg JSON Web Algorithm identifier to be used with the imported key.
|
|
76
76
|
*/
|
|
77
77
|
export declare function importPKCS8(pkcs8: string, alg: string, options?: PEMImportOptions): Promise<KeyLike>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { JWSHeaderParameters, JWEHeaderParameters } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export type ProtectedHeaderParameters = JWSHeaderParameters & JWEHeaderParameters;
|
|
3
3
|
/**
|
|
4
4
|
* Decodes the Protected Header of a JWE/JWS/JWT token utilizing any JOSE serialization.
|
|
5
5
|
*
|
package/package.json
CHANGED