jose 4.11.0 → 4.11.1
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/node/cjs/key/import.js +1 -1
- package/dist/node/esm/key/import.js +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/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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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/H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Ntbc4TEgybsP319UE4O41aKeNiBTAZKoYCxv/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
|
|
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ZCsvdkTVSOX76QQEXt7Y0nTNua69q3K3Jhf-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>;
|
package/package.json
CHANGED