jose 3.19.0 → 3.20.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/jwe/flattened/decrypt.js +5 -9
- package/dist/browser/jwe/flattened/encrypt.js +2 -5
- package/dist/browser/jwk/embedded.js +2 -2
- package/dist/browser/jwks/remote.js +7 -10
- package/dist/browser/jws/flattened/sign.js +1 -2
- package/dist/browser/jws/flattened/verify.js +2 -4
- package/dist/browser/jwt/encrypt.js +1 -1
- package/dist/browser/{lib/jwt_producer.js → jwt/produce.js} +4 -4
- package/dist/browser/jwt/sign.js +1 -1
- package/dist/browser/jwt/unsecured.js +1 -1
- package/dist/browser/lib/cek.js +3 -2
- package/dist/browser/lib/check_key_type.js +33 -16
- package/dist/browser/lib/decrypt_key_management.js +35 -35
- package/dist/browser/lib/encrypt_key_management.js +3 -5
- package/dist/browser/lib/iv.js +3 -2
- package/dist/browser/runtime/aesgcmkw.js +1 -3
- package/dist/browser/runtime/fetch_jwks.js +16 -3
- package/dist/browser/runtime/is_key_like.js +5 -0
- package/dist/browser/runtime/random.js +1 -2
- package/dist/browser/util/errors.js +73 -34
- package/dist/node/cjs/jwe/flattened/decrypt.js +5 -9
- package/dist/node/cjs/jwe/flattened/encrypt.js +2 -5
- package/dist/node/cjs/jwk/embedded.js +2 -2
- package/dist/node/cjs/jwks/remote.js +7 -10
- package/dist/node/cjs/jws/flattened/sign.js +1 -2
- package/dist/node/cjs/jws/flattened/verify.js +2 -4
- package/dist/node/cjs/jwt/encrypt.js +2 -2
- package/dist/node/cjs/{lib/jwt_producer.js → jwt/produce.js} +5 -4
- package/dist/node/cjs/jwt/sign.js +2 -2
- package/dist/node/cjs/jwt/unsecured.js +2 -2
- package/dist/node/cjs/lib/cek.js +4 -3
- package/dist/node/cjs/lib/check_key_type.js +33 -16
- package/dist/node/cjs/lib/decrypt_key_management.js +35 -35
- package/dist/node/cjs/lib/encrypt_key_management.js +7 -9
- package/dist/node/cjs/lib/iv.js +4 -3
- package/dist/node/cjs/runtime/aesgcmkw.js +1 -3
- package/dist/node/cjs/runtime/fetch_jwks.js +5 -1
- package/dist/node/cjs/runtime/is_key_like.js +11 -0
- package/dist/node/cjs/runtime/random.js +3 -2
- package/dist/node/cjs/util/errors.js +77 -37
- package/dist/node/esm/jwe/flattened/decrypt.js +5 -9
- package/dist/node/esm/jwe/flattened/encrypt.js +2 -5
- package/dist/node/esm/jwk/embedded.js +2 -2
- package/dist/node/esm/jwks/remote.js +7 -10
- package/dist/node/esm/jws/flattened/sign.js +1 -2
- package/dist/node/esm/jws/flattened/verify.js +2 -4
- package/dist/node/esm/jwt/encrypt.js +1 -1
- package/dist/node/esm/{lib/jwt_producer.js → jwt/produce.js} +4 -4
- package/dist/node/esm/jwt/sign.js +1 -1
- package/dist/node/esm/jwt/unsecured.js +1 -1
- package/dist/node/esm/lib/cek.js +3 -2
- package/dist/node/esm/lib/check_key_type.js +33 -16
- package/dist/node/esm/lib/decrypt_key_management.js +35 -35
- package/dist/node/esm/lib/encrypt_key_management.js +3 -5
- package/dist/node/esm/lib/iv.js +3 -2
- package/dist/node/esm/runtime/aesgcmkw.js +1 -3
- package/dist/node/esm/runtime/fetch_jwks.js +6 -2
- package/dist/node/esm/runtime/is_key_like.js +8 -0
- package/dist/node/esm/runtime/random.js +1 -2
- package/dist/node/esm/util/errors.js +73 -34
- package/dist/types/jwe/compact/decrypt.d.ts +1 -1
- package/dist/types/jwe/compact/encrypt.d.ts +1 -1
- package/dist/types/jwe/flattened/decrypt.d.ts +1 -1
- package/dist/types/jwe/flattened/encrypt.d.ts +1 -1
- package/dist/types/jwe/general/decrypt.d.ts +1 -1
- package/dist/types/jwk/embedded.d.ts +2 -3
- package/dist/types/jwk/from_key_like.d.ts +1 -1
- package/dist/types/jwk/parse.d.ts +1 -1
- package/dist/types/jws/compact/sign.d.ts +1 -1
- package/dist/types/jws/compact/verify.d.ts +1 -1
- package/dist/types/jws/flattened/sign.d.ts +1 -1
- package/dist/types/jws/flattened/verify.d.ts +1 -1
- package/dist/types/jws/general/sign.d.ts +1 -1
- package/dist/types/jws/general/verify.d.ts +1 -1
- package/dist/types/jwt/decrypt.d.ts +1 -1
- package/dist/types/jwt/encrypt.d.ts +2 -2
- package/dist/types/{lib/jwt_producer.d.ts → jwt/produce.d.ts} +1 -1
- package/dist/types/jwt/sign.d.ts +2 -2
- package/dist/types/jwt/unsecured.d.ts +1 -1
- package/dist/types/jwt/verify.d.ts +1 -1
- package/dist/types/key/export.d.ts +3 -3
- package/dist/types/key/import.d.ts +4 -4
- package/dist/types/types.d.ts +99 -6
- package/dist/types/util/errors.d.ts +24 -16
- package/dist/types/util/generate_key_pair.d.ts +2 -2
- package/dist/types/util/generate_secret.d.ts +1 -1
- package/package.json +3 -4
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* KeyLike are runtime-specific classes representing asymmetric keys or symmetric secrets.
|
|
3
|
+
* These are instances of
|
|
4
|
+
* [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) and additionally
|
|
5
|
+
* [KeyObject](https://nodejs.org/api/crypto.html#crypto_class_keyobject)
|
|
6
|
+
* in Node.js runtime.
|
|
7
|
+
* [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)
|
|
8
|
+
* instances are also accepted as symmetric secret representation only.
|
|
9
|
+
*
|
|
10
|
+
* [jose/key/import](../modules/key_import.md#readme) functions can be used to import PEM,
|
|
11
|
+
* or JWK formatted asymmetric keys and certificates to these runtime-specific representations.
|
|
12
|
+
*
|
|
13
|
+
* In Node.js the
|
|
14
|
+
* [Buffer](https://nodejs.org/api/buffer.html#buffer_buffer) class is a subclass of Uint8Array
|
|
15
|
+
* and so Buffer can be provided for symmetric secrets as well.
|
|
16
|
+
*
|
|
17
|
+
* ---
|
|
18
|
+
*
|
|
19
|
+
* [KeyObject](https://nodejs.org/api/crypto.html#crypto_class_keyobject) is a representation of a
|
|
20
|
+
* key/secret available in the Node.js runtime.
|
|
21
|
+
* In addition to the import functions of this library you may use the
|
|
22
|
+
* runtime APIs
|
|
23
|
+
* [crypto.createPublicKey](https://nodejs.org/api/crypto.html#crypto_crypto_createpublickey_key),
|
|
24
|
+
* [crypto.createPrivateKey](https://nodejs.org/api/crypto.html#crypto_crypto_createprivatekey_key), and
|
|
25
|
+
* [crypto.createSecretKey](https://nodejs.org/api/crypto.html#crypto_crypto_createsecretkey_key_encoding)
|
|
26
|
+
* to obtain a KeyObject from your existing key material.
|
|
27
|
+
*
|
|
28
|
+
* [CryptoKey](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) is a representation of a
|
|
29
|
+
* key/secret available in the Browser and Deno runtimes.
|
|
30
|
+
* In addition to the import functions of this library you may use the
|
|
31
|
+
* [SubtleCrypto.importKey](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey) API
|
|
32
|
+
* to obtain a CryptoKey from your existing key material.
|
|
33
|
+
*
|
|
34
|
+
* ---
|
|
35
|
+
*
|
|
36
|
+
* @example Import a PEM-encoded SPKI Public Key
|
|
37
|
+
* ```js
|
|
38
|
+
* import { importSPKI } from 'jose/key/import'
|
|
39
|
+
*
|
|
40
|
+
* const algorithm = 'ES256'
|
|
41
|
+
* const spki = `-----BEGIN PUBLIC KEY-----
|
|
42
|
+
* MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEFlHHWfLk0gLBbsLTcuCrbCqoHqmM
|
|
43
|
+
* YJepMC+Q+Dd6RBmBiA41evUsNMwLeN+PNFqib+xwi9JkJ8qhZkq8Y/IzGg==
|
|
44
|
+
* -----END PUBLIC KEY-----`
|
|
45
|
+
* const ecPublicKey = await importSPKI(spki, algorithm)
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Import a X.509 Certificate
|
|
49
|
+
* ```js
|
|
50
|
+
* import { importX509 } from 'jose/key/import'
|
|
51
|
+
*
|
|
52
|
+
* const algorithm = 'ES256'
|
|
53
|
+
* const x509 = `-----BEGIN CERTIFICATE-----
|
|
54
|
+
* MIIBXjCCAQSgAwIBAgIGAXvykuMKMAoGCCqGSM49BAMCMDYxNDAyBgNVBAMMK3Np
|
|
55
|
+
* QXBNOXpBdk1VaXhXVWVGaGtjZXg1NjJRRzFyQUhXaV96UlFQTVpQaG8wHhcNMjEw
|
|
56
|
+
* OTE3MDcwNTE3WhcNMjIwNzE0MDcwNTE3WjA2MTQwMgYDVQQDDCtzaUFwTTl6QXZN
|
|
57
|
+
* VWl4V1VlRmhrY2V4NTYyUUcxckFIV2lfelJRUE1aUGhvMFkwEwYHKoZIzj0CAQYI
|
|
58
|
+
* KoZIzj0DAQcDQgAE8PbPvCv5D5xBFHEZlBp/q5OEUymq7RIgWIi7tkl9aGSpYE35
|
|
59
|
+
* UH+kBKDnphJO3odpPZ5gvgKs2nwRWcrDnUjYLDAKBggqhkjOPQQDAgNIADBFAiEA
|
|
60
|
+
* 1yyMTRe66MhEXID9+uVub7woMkNYd0LhSHwKSPMUUTkCIFQGsfm1ecXOpeGOufAh
|
|
61
|
+
* v+A1QWZMuTWqYt+uh/YSRNDn
|
|
62
|
+
* -----END CERTIFICATE-----`
|
|
63
|
+
* const ecPublicKey = await importX509(x509, algorithm)
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example Import a PEM-encoded PKCS8 Private Key
|
|
67
|
+
* ```js
|
|
68
|
+
* import { importPKCS8 } from 'jose/key/import'
|
|
69
|
+
*
|
|
70
|
+
* const algorithm = 'ES256'
|
|
71
|
+
* const pkcs8 = `-----BEGIN PRIVATE KEY-----
|
|
72
|
+
* MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiyvo0X+VQ0yIrOaN
|
|
73
|
+
* nlrnUclopnvuuMfoc8HHly3505OhRANCAAQWUcdZ8uTSAsFuwtNy4KtsKqgeqYxg
|
|
74
|
+
* l6kwL5D4N3pEGYGIDjV69Sw0zAt43480WqJv7HCL0mQnyqFmSrxj8jMa
|
|
75
|
+
* -----END PRIVATE KEY-----`
|
|
76
|
+
* const ecPrivateKey = await importPKCS8(pkcs8, algorithm)
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example Import a JSON Web Key (JWK)
|
|
80
|
+
* ```js
|
|
81
|
+
* import { importJWK } from 'jose/key/import'
|
|
82
|
+
*
|
|
83
|
+
* const ecPublicKey = await importJWK({
|
|
84
|
+
* crv: 'P-256',
|
|
85
|
+
* kty: 'EC',
|
|
86
|
+
* x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
|
|
87
|
+
* y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo'
|
|
88
|
+
* }, 'ES256')
|
|
89
|
+
*
|
|
90
|
+
* const rsaPublicKey = await importJWK({
|
|
91
|
+
* kty: 'RSA',
|
|
92
|
+
* e: 'AQAB',
|
|
93
|
+
* n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ'
|
|
94
|
+
* }, 'PS256')
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export type KeyLike = { type: string }
|
|
5
98
|
export interface JWK {
|
|
6
99
|
alg?: string
|
|
7
100
|
crv?: string
|
|
@@ -33,7 +126,7 @@ export interface JWK {
|
|
|
33
126
|
[propName: string]: unknown
|
|
34
127
|
}
|
|
35
128
|
export interface GetKeyFunction<T, T2> {
|
|
36
|
-
(protectedHeader: T, token: T2): Promise<KeyLike>
|
|
129
|
+
(protectedHeader: T, token: T2): Promise<KeyLike | Uint8Array>
|
|
37
130
|
}
|
|
38
131
|
export interface FlattenedJWSInput {
|
|
39
132
|
header?: JWSHeaderParameters
|
|
@@ -170,5 +263,5 @@ export interface JWTDecryptResult {
|
|
|
170
263
|
protectedHeader: JWEHeaderParameters
|
|
171
264
|
}
|
|
172
265
|
export interface ResolvedKey {
|
|
173
|
-
key: KeyLike
|
|
266
|
+
key: KeyLike | Uint8Array
|
|
174
267
|
}
|
|
@@ -1,64 +1,72 @@
|
|
|
1
1
|
export declare class JOSEError extends Error {
|
|
2
|
-
static code: string;
|
|
2
|
+
static get code(): string;
|
|
3
3
|
code: string;
|
|
4
4
|
constructor(message?: string);
|
|
5
5
|
}
|
|
6
6
|
export declare class JWTClaimValidationFailed extends JOSEError {
|
|
7
|
-
static code:
|
|
7
|
+
static get code(): 'ERR_JWT_CLAIM_VALIDATION_FAILED';
|
|
8
|
+
code: string;
|
|
9
|
+
claim: string;
|
|
10
|
+
reason: string;
|
|
11
|
+
constructor(message: string, claim?: string, reason?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailed {
|
|
14
|
+
static get code(): 'ERR_JWT_EXPIRED';
|
|
8
15
|
code: string;
|
|
9
16
|
claim: string;
|
|
10
17
|
reason: string;
|
|
11
18
|
constructor(message: string, claim?: string, reason?: string);
|
|
12
19
|
}
|
|
13
20
|
export declare class JOSEAlgNotAllowed extends JOSEError {
|
|
14
|
-
static code:
|
|
21
|
+
static get code(): 'ERR_JOSE_ALG_NOT_ALLOWED';
|
|
15
22
|
code: string;
|
|
16
23
|
}
|
|
17
24
|
export declare class JOSENotSupported extends JOSEError {
|
|
18
|
-
static code:
|
|
25
|
+
static get code(): 'ERR_JOSE_NOT_SUPPORTED';
|
|
19
26
|
code: string;
|
|
20
27
|
}
|
|
21
28
|
export declare class JWEDecryptionFailed extends JOSEError {
|
|
22
|
-
static code:
|
|
29
|
+
static get code(): 'ERR_JWE_DECRYPTION_FAILED';
|
|
23
30
|
code: string;
|
|
24
31
|
message: string;
|
|
25
32
|
}
|
|
26
33
|
export declare class JWEInvalid extends JOSEError {
|
|
27
|
-
static code:
|
|
34
|
+
static get code(): 'ERR_JWE_INVALID';
|
|
28
35
|
code: string;
|
|
29
36
|
}
|
|
30
37
|
export declare class JWSInvalid extends JOSEError {
|
|
31
|
-
static code:
|
|
38
|
+
static get code(): 'ERR_JWS_INVALID';
|
|
32
39
|
code: string;
|
|
33
40
|
}
|
|
34
41
|
export declare class JWTInvalid extends JOSEError {
|
|
35
|
-
static code:
|
|
42
|
+
static get code(): 'ERR_JWT_INVALID';
|
|
36
43
|
code: string;
|
|
37
44
|
}
|
|
38
45
|
export declare class JWKInvalid extends JOSEError {
|
|
39
|
-
static code:
|
|
46
|
+
static get code(): 'ERR_JWK_INVALID';
|
|
40
47
|
code: string;
|
|
41
48
|
}
|
|
42
49
|
export declare class JWKSInvalid extends JOSEError {
|
|
43
|
-
static code:
|
|
50
|
+
static get code(): 'ERR_JWKS_INVALID';
|
|
44
51
|
code: string;
|
|
45
52
|
}
|
|
46
53
|
export declare class JWKSNoMatchingKey extends JOSEError {
|
|
47
|
-
static code:
|
|
54
|
+
static get code(): 'ERR_JWKS_NO_MATCHING_KEY';
|
|
48
55
|
code: string;
|
|
49
56
|
message: string;
|
|
50
57
|
}
|
|
51
58
|
export declare class JWKSMultipleMatchingKeys extends JOSEError {
|
|
52
|
-
static code:
|
|
59
|
+
static get code(): 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';
|
|
53
60
|
code: string;
|
|
54
61
|
message: string;
|
|
55
62
|
}
|
|
56
|
-
export declare class
|
|
57
|
-
static code:
|
|
63
|
+
export declare class JWKSTimeout extends JOSEError {
|
|
64
|
+
static get code(): 'ERR_JWKS_TIMEOUT';
|
|
58
65
|
code: string;
|
|
59
66
|
message: string;
|
|
60
67
|
}
|
|
61
|
-
export declare class
|
|
62
|
-
static code:
|
|
68
|
+
export declare class JWSSignatureVerificationFailed extends JOSEError {
|
|
69
|
+
static get code(): 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';
|
|
63
70
|
code: string;
|
|
71
|
+
message: string;
|
|
64
72
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { KeyLike } from '../types';
|
|
2
2
|
export interface GenerateKeyPairResult {
|
|
3
|
-
privateKey:
|
|
4
|
-
publicKey:
|
|
3
|
+
privateKey: KeyLike;
|
|
4
|
+
publicKey: KeyLike;
|
|
5
5
|
}
|
|
6
6
|
export interface GenerateKeyPairOptions {
|
|
7
7
|
crv?: string;
|
|
@@ -2,6 +2,6 @@ import type { KeyLike } from '../types';
|
|
|
2
2
|
export interface GenerateSecretOptions {
|
|
3
3
|
extractable?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<KeyLike>;
|
|
5
|
+
declare function generateSecret(alg: string, options?: GenerateSecretOptions): Promise<KeyLike | Uint8Array>;
|
|
6
6
|
export { generateSecret };
|
|
7
7
|
export default generateSecret;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jose",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.3",
|
|
4
4
|
"description": "Universal 'JSON Web Almost Everything' - JWA, JWS, JWE, JWT, JWK with no dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"author": "Filip Skokan <panva.ip@gmail.com>",
|
|
55
|
+
"sideEffects": false,
|
|
55
56
|
"exports": {
|
|
56
57
|
"./package.json": "./package.json",
|
|
57
58
|
"./jwe/compact/decrypt": {
|
|
@@ -212,9 +213,7 @@
|
|
|
212
213
|
"dist/**/*.js",
|
|
213
214
|
"dist/types/**/*.d.ts",
|
|
214
215
|
"!dist/node/webcrypto/**/*",
|
|
215
|
-
"!dist/types/**/*.i.d.ts",
|
|
216
216
|
"!dist/types/runtime/*",
|
|
217
|
-
"!dist/types/lib/*"
|
|
218
|
-
"dist/types/lib/jwt_producer.d.ts"
|
|
217
|
+
"!dist/types/lib/*"
|
|
219
218
|
]
|
|
220
219
|
}
|