jose 4.13.0 → 4.13.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 +94 -88
- package/dist/browser/jwks/remote.js +14 -26
- package/dist/browser/jws/general/sign.js +1 -1
- package/dist/node/cjs/jwks/remote.js +14 -26
- package/dist/node/cjs/jws/general/sign.js +1 -1
- package/dist/node/esm/jwks/remote.js +14 -26
- package/dist/node/esm/jws/general/sign.js +1 -1
- package/dist/types/jwe/compact/decrypt.d.ts +4 -14
- package/dist/types/jwe/compact/encrypt.d.ts +3 -13
- package/dist/types/jwe/flattened/decrypt.d.ts +4 -24
- package/dist/types/jwe/flattened/encrypt.d.ts +3 -14
- package/dist/types/jwe/general/decrypt.d.ts +4 -28
- package/dist/types/jwe/general/encrypt.d.ts +2 -16
- package/dist/types/jwk/embedded.d.ts +0 -14
- package/dist/types/jwk/thumbprint.d.ts +2 -30
- package/dist/types/jwks/local.d.ts +0 -59
- package/dist/types/jwks/remote.d.ts +5 -48
- package/dist/types/jws/compact/sign.d.ts +3 -13
- package/dist/types/jws/compact/verify.d.ts +5 -17
- package/dist/types/jws/flattened/sign.d.ts +3 -13
- package/dist/types/jws/flattened/verify.d.ts +5 -22
- package/dist/types/jws/general/sign.d.ts +3 -16
- package/dist/types/jws/general/verify.d.ts +5 -25
- package/dist/types/jwt/decrypt.d.ts +4 -18
- package/dist/types/jwt/encrypt.d.ts +12 -22
- package/dist/types/jwt/sign.d.ts +3 -93
- package/dist/types/jwt/unsecured.d.ts +0 -23
- package/dist/types/jwt/verify.d.ts +5 -84
- package/dist/types/key/export.d.ts +0 -26
- package/dist/types/key/generate_key_pair.d.ts +1 -9
- package/dist/types/key/generate_secret.d.ts +1 -8
- package/dist/types/key/import.d.ts +15 -80
- package/dist/types/types.d.ts +38 -94
- package/dist/types/util/decode_jwt.d.ts +0 -7
- package/dist/types/util/decode_protected_header.d.ts +0 -7
- package/dist/types/util/errors.d.ts +57 -14
- package/package.json +1 -1
|
@@ -2,46 +2,18 @@ import type { JWK } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Calculates a base64url-encoded JSON Web Key (JWK) Thumbprint
|
|
4
4
|
*
|
|
5
|
-
* @example Usage
|
|
6
|
-
*
|
|
7
|
-
* ```js
|
|
8
|
-
* const thumbprint = await jose.calculateJwkThumbprint({
|
|
9
|
-
* kty: 'EC',
|
|
10
|
-
* crv: 'P-256',
|
|
11
|
-
* x: 'jJ6Flys3zK9jUhnOHf6G49Dyp5hah6CNP84-gY-n9eo',
|
|
12
|
-
* y: 'nhI6iD5eFXgBTLt_1p3aip-5VbZeMhxeFSpjfEAf7Ww',
|
|
13
|
-
* })
|
|
14
|
-
*
|
|
15
|
-
* console.log(thumbprint)
|
|
16
|
-
* // 'w9eYdC6_s_tLQ8lH6PUpc0mddazaqtPgeC2IgWDiqY8'
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
5
|
* @param jwk JSON Web Key.
|
|
20
6
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
21
7
|
* "sha256".
|
|
22
|
-
* @see
|
|
8
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7638 RFC7638}
|
|
23
9
|
*/
|
|
24
10
|
export declare function calculateJwkThumbprint(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
25
11
|
/**
|
|
26
12
|
* Calculates a JSON Web Key (JWK) Thumbprint URI
|
|
27
13
|
*
|
|
28
|
-
* @example Usage
|
|
29
|
-
*
|
|
30
|
-
* ```js
|
|
31
|
-
* const thumbprintUri = await jose.calculateJwkThumbprintUri({
|
|
32
|
-
* kty: 'EC',
|
|
33
|
-
* crv: 'P-256',
|
|
34
|
-
* x: 'jJ6Flys3zK9jUhnOHf6G49Dyp5hah6CNP84-gY-n9eo',
|
|
35
|
-
* y: 'nhI6iD5eFXgBTLt_1p3aip-5VbZeMhxeFSpjfEAf7Ww',
|
|
36
|
-
* })
|
|
37
|
-
*
|
|
38
|
-
* console.log(thumbprint)
|
|
39
|
-
* // 'urn:ietf:params:oauth:jwk-thumbprint:sha-256:w9eYdC6_s_tLQ8lH6PUpc0mddazaqtPgeC2IgWDiqY8'
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
14
|
* @param jwk JSON Web Key.
|
|
43
15
|
* @param digestAlgorithm Digest Algorithm to use for calculating the thumbprint. Default is
|
|
44
16
|
* "sha256".
|
|
45
|
-
* @see
|
|
17
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc9278 RFC9278}
|
|
46
18
|
*/
|
|
47
19
|
export declare function calculateJwkThumbprintUri(jwk: JWK, digestAlgorithm?: 'sha256' | 'sha384' | 'sha512'): Promise<string>;
|
|
@@ -21,65 +21,6 @@ export declare class LocalJWKSet<T extends KeyLike = KeyLike> {
|
|
|
21
21
|
* multiple keys get matched it is possible to opt-in to iterate over the matched keys and attempt
|
|
22
22
|
* verification in an iterative manner.
|
|
23
23
|
*
|
|
24
|
-
* @example Usage
|
|
25
|
-
*
|
|
26
|
-
* ```js
|
|
27
|
-
* const JWKS = jose.createLocalJWKSet({
|
|
28
|
-
* keys: [
|
|
29
|
-
* {
|
|
30
|
-
* kty: 'RSA',
|
|
31
|
-
* e: 'AQAB',
|
|
32
|
-
* n: '12oBZRhCiZFJLcPg59LkZZ9mdhSMTKAQZYq32k_ti5SBB6jerkh-WzOMAO664r_qyLkqHUSp3u5SbXtseZEpN3XPWGKSxjsy-1JyEFTdLSYe6f9gfrmxkUF_7DTpq0gn6rntP05g2-wFW50YO7mosfdslfrTJYWHFhJALabAeYirYD7-9kqq9ebfFMF4sRRELbv9oi36As6Q9B3Qb5_C1rAzqfao_PCsf9EPsTZsVVVkA5qoIAr47lo1ipfiBPxUCCNSdvkmDTYgvvRm6ZoMjFbvOtgyts55fXKdMWv7I9HMD5HwE9uW839PWA514qhbcIsXEYSFMPMV6fnlsiZvQQ',
|
|
33
|
-
* alg: 'PS256',
|
|
34
|
-
* },
|
|
35
|
-
* {
|
|
36
|
-
* crv: 'P-256',
|
|
37
|
-
* kty: 'EC',
|
|
38
|
-
* x: 'ySK38C1jBdLwDsNWKzzBHqKYEE5Cgv-qjWvorUXk9fw',
|
|
39
|
-
* y: '_LeQBw07cf5t57Iavn4j-BqJsAD1dpoz8gokd3sBsOo',
|
|
40
|
-
* alg: 'ES256',
|
|
41
|
-
* },
|
|
42
|
-
* ],
|
|
43
|
-
* })
|
|
44
|
-
*
|
|
45
|
-
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
|
|
46
|
-
* issuer: 'urn:example:issuer',
|
|
47
|
-
* audience: 'urn:example:audience',
|
|
48
|
-
* })
|
|
49
|
-
* console.log(protectedHeader)
|
|
50
|
-
* console.log(payload)
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @example Opting-in to multiple JWKS matches using `createLocalJWKSet`
|
|
54
|
-
*
|
|
55
|
-
* ```js
|
|
56
|
-
* const options = {
|
|
57
|
-
* issuer: 'urn:example:issuer',
|
|
58
|
-
* audience: 'urn:example:audience',
|
|
59
|
-
* }
|
|
60
|
-
* const { payload, protectedHeader } = await jose
|
|
61
|
-
* .jwtVerify(jwt, JWKS, options)
|
|
62
|
-
* .catch(async (error) => {
|
|
63
|
-
* if (error?.code === 'ERR_JWKS_MULTIPLE_MATCHING_KEYS') {
|
|
64
|
-
* for await (const publicKey of error) {
|
|
65
|
-
* try {
|
|
66
|
-
* return await jose.jwtVerify(jwt, publicKey, options)
|
|
67
|
-
* } catch (innerError) {
|
|
68
|
-
* if (innerError?.code === 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED') {
|
|
69
|
-
* continue
|
|
70
|
-
* }
|
|
71
|
-
* throw innerError
|
|
72
|
-
* }
|
|
73
|
-
* }
|
|
74
|
-
* throw new jose.errors.JWSSignatureVerificationFailed()
|
|
75
|
-
* }
|
|
76
|
-
*
|
|
77
|
-
* throw error
|
|
78
|
-
* })
|
|
79
|
-
* console.log(protectedHeader)
|
|
80
|
-
* console.log(payload)
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
24
|
* @param jwks JSON Web Key Set formatted object.
|
|
84
25
|
*/
|
|
85
26
|
export declare function createLocalJWKSet<T extends KeyLike = KeyLike>(jwks: JSONWebKeySet): (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<T>;
|
|
@@ -17,11 +17,11 @@ export interface RemoteJWKSetOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
cacheMaxAge?: number | typeof Infinity;
|
|
19
19
|
/**
|
|
20
|
-
* An instance of
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when
|
|
20
|
+
* An instance of {@link https://nodejs.org/api/http.html#class-httpagent http.Agent} or
|
|
21
|
+
* {@link https://nodejs.org/api/https.html#class-httpsagent https.Agent} to pass to the
|
|
22
|
+
* {@link https://nodejs.org/api/http.html#httpgetoptions-callback http.get} or
|
|
23
|
+
* {@link https://nodejs.org/api/https.html#httpsgetoptions-callback https.get} method's options.
|
|
24
|
+
* Use when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when
|
|
25
25
|
* used outside of Node.js runtime.
|
|
26
26
|
*/
|
|
27
27
|
agent?: any;
|
|
@@ -43,49 +43,6 @@ export interface RemoteJWKSetOptions {
|
|
|
43
43
|
* multiple keys get matched it is possible to opt-in to iterate over the matched keys and attempt
|
|
44
44
|
* verification in an iterative manner.
|
|
45
45
|
*
|
|
46
|
-
* @example Usage
|
|
47
|
-
*
|
|
48
|
-
* ```js
|
|
49
|
-
* const JWKS = jose.createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))
|
|
50
|
-
*
|
|
51
|
-
* const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
|
|
52
|
-
* issuer: 'urn:example:issuer',
|
|
53
|
-
* audience: 'urn:example:audience',
|
|
54
|
-
* })
|
|
55
|
-
* console.log(protectedHeader)
|
|
56
|
-
* console.log(payload)
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example Opting-in to multiple JWKS matches using `createRemoteJWKSet`
|
|
60
|
-
*
|
|
61
|
-
* ```js
|
|
62
|
-
* const options = {
|
|
63
|
-
* issuer: 'urn:example:issuer',
|
|
64
|
-
* audience: 'urn:example:audience',
|
|
65
|
-
* }
|
|
66
|
-
* const { payload, protectedHeader } = await jose
|
|
67
|
-
* .jwtVerify(jwt, JWKS, options)
|
|
68
|
-
* .catch(async (error) => {
|
|
69
|
-
* if (error?.code === 'ERR_JWKS_MULTIPLE_MATCHING_KEYS') {
|
|
70
|
-
* for await (const publicKey of error) {
|
|
71
|
-
* try {
|
|
72
|
-
* return await jose.jwtVerify(jwt, publicKey, options)
|
|
73
|
-
* } catch (innerError) {
|
|
74
|
-
* if (innerError?.code === 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED') {
|
|
75
|
-
* continue
|
|
76
|
-
* }
|
|
77
|
-
* throw innerError
|
|
78
|
-
* }
|
|
79
|
-
* }
|
|
80
|
-
* throw new jose.errors.JWSSignatureVerificationFailed()
|
|
81
|
-
* }
|
|
82
|
-
*
|
|
83
|
-
* throw error
|
|
84
|
-
* })
|
|
85
|
-
* console.log(protectedHeader)
|
|
86
|
-
* console.log(payload)
|
|
87
|
-
* ```
|
|
88
|
-
*
|
|
89
46
|
* @param url URL to fetch the JSON Web Key Set from.
|
|
90
47
|
* @param options Options for the remote JSON Web Key Set.
|
|
91
48
|
*/
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import type { CompactJWSHeaderParameters, KeyLike, SignOptions } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* The CompactSign class is
|
|
3
|
+
* The CompactSign class is used to build and sign Compact JWS strings.
|
|
4
4
|
*
|
|
5
|
-
* @example Usage
|
|
6
|
-
*
|
|
7
|
-
* ```js
|
|
8
|
-
* const jws = await new jose.CompactSign(
|
|
9
|
-
* new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
|
|
10
|
-
* )
|
|
11
|
-
* .setProtectedHeader({ alg: 'ES256' })
|
|
12
|
-
* .sign(privateKey)
|
|
13
|
-
*
|
|
14
|
-
* console.log(jws)
|
|
15
|
-
* ```
|
|
16
5
|
*/
|
|
17
6
|
export declare class CompactSign {
|
|
18
7
|
private _flattened;
|
|
@@ -27,7 +16,8 @@ export declare class CompactSign {
|
|
|
27
16
|
/**
|
|
28
17
|
* Signs and resolves the value of the Compact JWS string.
|
|
29
18
|
*
|
|
30
|
-
* @param key Private Key or Secret to sign the JWS with.
|
|
19
|
+
* @param key Private Key or Secret to sign the JWS with. See
|
|
20
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
31
21
|
* @param options JWS Sign options.
|
|
32
22
|
*/
|
|
33
23
|
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<string>;
|
|
@@ -3,35 +3,23 @@ import type { CompactVerifyResult, FlattenedJWSInput, GetKeyFunction, CompactJWS
|
|
|
3
3
|
* Interface for Compact JWS Verification dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
|
|
8
|
-
* to verify using a remote JSON Web Key Set.
|
|
6
|
+
* @see [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset) to verify using a remote JSON Web Key Set.
|
|
9
7
|
*/
|
|
10
8
|
export interface CompactVerifyGetKey extends GetKeyFunction<CompactJWSHeaderParameters, FlattenedJWSInput> {
|
|
11
9
|
}
|
|
12
10
|
/**
|
|
13
11
|
* Verifies the signature and format of and afterwards decodes the Compact JWS.
|
|
14
12
|
*
|
|
15
|
-
* @example Usage
|
|
16
|
-
*
|
|
17
|
-
* ```js
|
|
18
|
-
* const jws =
|
|
19
|
-
* 'eyJhbGciOiJFUzI1NiJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4.kkAs_gPPxWMI3rHuVlxHaTPfDWDoqdI8jSvuSmqV-8IHIWXg9mcAeC9ggV-45ZHRbiRJ3obUIFo1rHphPA5URg'
|
|
20
|
-
*
|
|
21
|
-
* const { payload, protectedHeader } = await jose.compactVerify(jws, publicKey)
|
|
22
|
-
*
|
|
23
|
-
* console.log(protectedHeader)
|
|
24
|
-
* console.log(new TextDecoder().decode(payload))
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
13
|
* @param jws Compact JWS.
|
|
28
|
-
* @param key Key to verify the JWS with.
|
|
14
|
+
* @param key Key to verify the JWS with. See
|
|
15
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
29
16
|
* @param options JWS Verify options.
|
|
30
17
|
*/
|
|
31
18
|
export declare function compactVerify(jws: string | Uint8Array, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<CompactVerifyResult>;
|
|
32
19
|
/**
|
|
33
20
|
* @param jws Compact JWS.
|
|
34
|
-
* @param getKey Function resolving a key to verify the JWS with.
|
|
21
|
+
* @param getKey Function resolving a key to verify the JWS with. See
|
|
22
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
35
23
|
* @param options JWS Verify options.
|
|
36
24
|
*/
|
|
37
25
|
export declare function compactVerify<T extends KeyLike = KeyLike>(jws: string | Uint8Array, getKey: CompactVerifyGetKey, options?: VerifyOptions): Promise<CompactVerifyResult & ResolvedKey<T>>;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import type { KeyLike, FlattenedJWS, JWSHeaderParameters, SignOptions } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* The FlattenedSign class is
|
|
3
|
+
* The FlattenedSign class is used to build and sign Flattened JWS objects.
|
|
4
4
|
*
|
|
5
|
-
* @example Usage
|
|
6
|
-
*
|
|
7
|
-
* ```js
|
|
8
|
-
* const jws = await new jose.FlattenedSign(
|
|
9
|
-
* new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
|
|
10
|
-
* )
|
|
11
|
-
* .setProtectedHeader({ alg: 'ES256' })
|
|
12
|
-
* .sign(privateKey)
|
|
13
|
-
*
|
|
14
|
-
* console.log(jws)
|
|
15
|
-
* ```
|
|
16
5
|
*/
|
|
17
6
|
export declare class FlattenedSign {
|
|
18
7
|
private _payload;
|
|
@@ -35,7 +24,8 @@ export declare class FlattenedSign {
|
|
|
35
24
|
/**
|
|
36
25
|
* Signs and resolves the value of the Flattened JWS object.
|
|
37
26
|
*
|
|
38
|
-
* @param key Private Key or Secret to sign the JWS with.
|
|
27
|
+
* @param key Private Key or Secret to sign the JWS with. See
|
|
28
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
39
29
|
* @param options JWS Sign options.
|
|
40
30
|
*/
|
|
41
31
|
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<FlattenedJWS>;
|
|
@@ -3,40 +3,23 @@ import type { FlattenedVerifyResult, KeyLike, FlattenedJWSInput, JWSHeaderParame
|
|
|
3
3
|
* Interface for Flattened JWS Verification dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
|
|
8
|
-
* to verify using a remote JSON Web Key Set.
|
|
6
|
+
* @see [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset) to verify using a remote JSON Web Key Set.
|
|
9
7
|
*/
|
|
10
8
|
export interface FlattenedVerifyGetKey extends GetKeyFunction<JWSHeaderParameters | undefined, FlattenedJWSInput> {
|
|
11
9
|
}
|
|
12
10
|
/**
|
|
13
11
|
* Verifies the signature and format of and afterwards decodes the Flattened JWS.
|
|
14
12
|
*
|
|
15
|
-
* @example Usage
|
|
16
|
-
*
|
|
17
|
-
* ```js
|
|
18
|
-
* const decoder = new TextDecoder()
|
|
19
|
-
* const jws = {
|
|
20
|
-
* signature:
|
|
21
|
-
* 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
|
|
22
|
-
* payload: 'SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4',
|
|
23
|
-
* protected: 'eyJhbGciOiJFUzI1NiJ9',
|
|
24
|
-
* }
|
|
25
|
-
*
|
|
26
|
-
* const { payload, protectedHeader } = await jose.flattenedVerify(jws, publicKey)
|
|
27
|
-
*
|
|
28
|
-
* console.log(protectedHeader)
|
|
29
|
-
* console.log(decoder.decode(payload))
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
13
|
* @param jws Flattened JWS.
|
|
33
|
-
* @param key Key to verify the JWS with.
|
|
14
|
+
* @param key Key to verify the JWS with. See
|
|
15
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
34
16
|
* @param options JWS Verify options.
|
|
35
17
|
*/
|
|
36
18
|
export declare function flattenedVerify(jws: FlattenedJWSInput, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<FlattenedVerifyResult>;
|
|
37
19
|
/**
|
|
38
20
|
* @param jws Flattened JWS.
|
|
39
|
-
* @param getKey Function resolving a key to verify the JWS with.
|
|
21
|
+
* @param getKey Function resolving a key to verify the JWS with. See
|
|
22
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
40
23
|
* @param options JWS Verify options.
|
|
41
24
|
*/
|
|
42
25
|
export declare function flattenedVerify<T extends KeyLike = KeyLike>(jws: FlattenedJWSInput, getKey: FlattenedVerifyGetKey, options?: VerifyOptions): Promise<FlattenedVerifyResult & ResolvedKey<T>>;
|
|
@@ -20,22 +20,8 @@ export interface Signature {
|
|
|
20
20
|
done(): GeneralSign;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* The GeneralSign class is
|
|
23
|
+
* The GeneralSign class is used to build and sign General JWS objects.
|
|
24
24
|
*
|
|
25
|
-
* @example Usage
|
|
26
|
-
*
|
|
27
|
-
* ```js
|
|
28
|
-
* const jws = await new jose.GeneralSign(
|
|
29
|
-
* new TextEncoder().encode('It’s a dangerous business, Frodo, going out your door.'),
|
|
30
|
-
* )
|
|
31
|
-
* .addSignature(ecPrivateKey)
|
|
32
|
-
* .setProtectedHeader({ alg: 'ES256' })
|
|
33
|
-
* .addSignature(rsaPrivateKey)
|
|
34
|
-
* .setProtectedHeader({ alg: 'PS256' })
|
|
35
|
-
* .sign()
|
|
36
|
-
*
|
|
37
|
-
* console.log(jws)
|
|
38
|
-
* ```
|
|
39
25
|
*/
|
|
40
26
|
export declare class GeneralSign {
|
|
41
27
|
private _payload;
|
|
@@ -45,7 +31,8 @@ export declare class GeneralSign {
|
|
|
45
31
|
/**
|
|
46
32
|
* Adds an additional signature for the General JWS object.
|
|
47
33
|
*
|
|
48
|
-
* @param key Private Key or Secret to sign the individual JWS signature with.
|
|
34
|
+
* @param key Private Key or Secret to sign the individual JWS signature with. See
|
|
35
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
49
36
|
* @param options JWS Sign options.
|
|
50
37
|
*/
|
|
51
38
|
addSignature(key: KeyLike | Uint8Array, options?: SignOptions): Signature;
|
|
@@ -3,43 +3,23 @@ import type { GeneralJWSInput, GeneralVerifyResult, FlattenedJWSInput, GetKeyFun
|
|
|
3
3
|
* Interface for General JWS Verification dynamic key resolution. No token components have been
|
|
4
4
|
* verified at the time of this function call.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset)
|
|
8
|
-
* to verify using a remote JSON Web Key Set.
|
|
6
|
+
* @see [createRemoteJWKSet](../functions/jwks_remote.createRemoteJWKSet.md#function-createremotejwkset) to verify using a remote JSON Web Key Set.
|
|
9
7
|
*/
|
|
10
8
|
export interface GeneralVerifyGetKey extends GetKeyFunction<JWSHeaderParameters, FlattenedJWSInput> {
|
|
11
9
|
}
|
|
12
10
|
/**
|
|
13
11
|
* Verifies the signature and format of and afterwards decodes the General JWS.
|
|
14
12
|
*
|
|
15
|
-
* @example Usage
|
|
16
|
-
*
|
|
17
|
-
* ```js
|
|
18
|
-
* const jws = {
|
|
19
|
-
* payload: 'SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4',
|
|
20
|
-
* signatures: [
|
|
21
|
-
* {
|
|
22
|
-
* signature:
|
|
23
|
-
* 'FVVOXwj6kD3DqdfD9yYqfT2W9jv-Nop4kOehp_DeDGNB5dQNSPRvntBY6xH3uxlCxE8na9d_kyhYOcanpDJ0EA',
|
|
24
|
-
* protected: 'eyJhbGciOiJFUzI1NiJ9',
|
|
25
|
-
* },
|
|
26
|
-
* ],
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* const { payload, protectedHeader } = await jose.generalVerify(jws, publicKey)
|
|
30
|
-
*
|
|
31
|
-
* console.log(protectedHeader)
|
|
32
|
-
* console.log(new TextDecoder().decode(payload))
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
13
|
* @param jws General JWS.
|
|
36
|
-
* @param key Key to verify the JWS with.
|
|
14
|
+
* @param key Key to verify the JWS with. See
|
|
15
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
37
16
|
* @param options JWS Verify options.
|
|
38
17
|
*/
|
|
39
18
|
export declare function generalVerify(jws: GeneralJWSInput, key: KeyLike | Uint8Array, options?: VerifyOptions): Promise<GeneralVerifyResult>;
|
|
40
19
|
/**
|
|
41
20
|
* @param jws General JWS.
|
|
42
|
-
* @param getKey Function resolving a key to verify the JWS with.
|
|
21
|
+
* @param getKey Function resolving a key to verify the JWS with. See
|
|
22
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
43
23
|
* @param options JWS Verify options.
|
|
44
24
|
*/
|
|
45
25
|
export declare function generalVerify<T extends KeyLike = KeyLike>(jws: GeneralJWSInput, getKey: GeneralVerifyGetKey, options?: VerifyOptions): Promise<GeneralVerifyResult & ResolvedKey<T>>;
|
|
@@ -12,30 +12,16 @@ export interface JWTDecryptGetKey extends GetKeyFunction<CompactJWEHeaderParamet
|
|
|
12
12
|
* Verifies the JWT format (to be a JWE Compact format), decrypts the ciphertext, validates the JWT
|
|
13
13
|
* Claims Set.
|
|
14
14
|
*
|
|
15
|
-
* @example Usage
|
|
16
|
-
*
|
|
17
|
-
* ```js
|
|
18
|
-
* const secret = jose.base64url.decode('zH4NRP1HMALxxCFnRZABFA7GOJtzU_gIj02alfL1lvI')
|
|
19
|
-
* const jwt =
|
|
20
|
-
* 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..MB66qstZBPxAXKdsjet_lA.WHbtJTl4taHp7otOHLq3hBvv0yNPsPEKHYInmCPdDDeyV1kU-f-tGEiU4FxlSqkqAT2hVs8_wMNiQFAzPU1PUgIqWCPsBrPP3TtxYsrtwagpn4SvCsUsx0Mhw9ZhliAO8CLmCBQkqr_T9AcYsz5uZw.7nX9m7BGUu_u1p1qFHzyIg'
|
|
21
|
-
*
|
|
22
|
-
* const { payload, protectedHeader } = await jose.jwtDecrypt(jwt, secret, {
|
|
23
|
-
* issuer: 'urn:example:issuer',
|
|
24
|
-
* audience: 'urn:example:audience',
|
|
25
|
-
* })
|
|
26
|
-
*
|
|
27
|
-
* console.log(protectedHeader)
|
|
28
|
-
* console.log(payload)
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
15
|
* @param jwt JSON Web Token value (encoded as JWE).
|
|
32
|
-
* @param key Private Key or Secret to decrypt and verify the JWT with.
|
|
16
|
+
* @param key Private Key or Secret to decrypt and verify the JWT with. See
|
|
17
|
+
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
33
18
|
* @param options JWT Decryption and JWT Claims Set validation options.
|
|
34
19
|
*/
|
|
35
20
|
export declare function jwtDecrypt(jwt: string | Uint8Array, key: KeyLike | Uint8Array, options?: JWTDecryptOptions): Promise<JWTDecryptResult>;
|
|
36
21
|
/**
|
|
37
22
|
* @param jwt JSON Web Token value (encoded as JWE).
|
|
38
|
-
* @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with.
|
|
23
|
+
* @param getKey Function resolving Private Key or Secret to decrypt and verify the JWT with. See
|
|
24
|
+
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
39
25
|
* @param options JWT Decryption and JWT Claims Set validation options.
|
|
40
26
|
*/
|
|
41
27
|
export declare function jwtDecrypt<T extends KeyLike = KeyLike>(jwt: string | Uint8Array, getKey: JWTDecryptGetKey, options?: JWTDecryptOptions): Promise<JWTDecryptResult & ResolvedKey<T>>;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import type { EncryptOptions, CompactJWEHeaderParameters, JWEKeyManagementHeaderParameters, KeyLike } from '../types';
|
|
2
2
|
import { ProduceJWT } from './produce';
|
|
3
3
|
/**
|
|
4
|
-
* The EncryptJWT class is
|
|
4
|
+
* The EncryptJWT class is used to build and encrypt Compact JWE formatted JSON Web Tokens.
|
|
5
5
|
*
|
|
6
|
-
* @example Usage
|
|
7
|
-
*
|
|
8
|
-
* ```js
|
|
9
|
-
* const secret = jose.base64url.decode('zH4NRP1HMALxxCFnRZABFA7GOJtzU_gIj02alfL1lvI')
|
|
10
|
-
* const jwt = await new jose.EncryptJWT({ 'urn:example:claim': true })
|
|
11
|
-
* .setProtectedHeader({ alg: 'dir', enc: 'A128CBC-HS256' })
|
|
12
|
-
* .setIssuedAt()
|
|
13
|
-
* .setIssuer('urn:example:issuer')
|
|
14
|
-
* .setAudience('urn:example:audience')
|
|
15
|
-
* .setExpirationTime('2h')
|
|
16
|
-
* .encrypt(secret)
|
|
17
|
-
*
|
|
18
|
-
* console.log(jwt)
|
|
19
|
-
* ```
|
|
20
6
|
*/
|
|
21
7
|
export declare class EncryptJWT extends ProduceJWT {
|
|
22
8
|
private _cek;
|
|
@@ -61,24 +47,28 @@ export declare class EncryptJWT extends ProduceJWT {
|
|
|
61
47
|
*/
|
|
62
48
|
setInitializationVector(iv: Uint8Array): this;
|
|
63
49
|
/**
|
|
64
|
-
* Replicates the "iss" (Issuer) Claim as a JWE Protected Header Parameter
|
|
65
|
-
*
|
|
50
|
+
* Replicates the "iss" (Issuer) Claim as a JWE Protected Header Parameter.
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-5.3 RFC7519#section-5.3}
|
|
66
53
|
*/
|
|
67
54
|
replicateIssuerAsHeader(): this;
|
|
68
55
|
/**
|
|
69
|
-
* Replicates the "sub" (Subject) Claim as a JWE Protected Header Parameter
|
|
70
|
-
*
|
|
56
|
+
* Replicates the "sub" (Subject) Claim as a JWE Protected Header Parameter.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-5.3 RFC7519#section-5.3}
|
|
71
59
|
*/
|
|
72
60
|
replicateSubjectAsHeader(): this;
|
|
73
61
|
/**
|
|
74
|
-
* Replicates the "aud" (Audience) Claim as a JWE Protected Header Parameter
|
|
75
|
-
*
|
|
62
|
+
* Replicates the "aud" (Audience) Claim as a JWE Protected Header Parameter.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-5.3 RFC7519#section-5.3}
|
|
76
65
|
*/
|
|
77
66
|
replicateAudienceAsHeader(): this;
|
|
78
67
|
/**
|
|
79
68
|
* Encrypts and returns the JWT.
|
|
80
69
|
*
|
|
81
|
-
* @param key Public Key or Secret to encrypt the JWT with.
|
|
70
|
+
* @param key Public Key or Secret to encrypt the JWT with. See
|
|
71
|
+
* {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}.
|
|
82
72
|
* @param options JWE Encryption options.
|
|
83
73
|
*/
|
|
84
74
|
encrypt(key: KeyLike | Uint8Array, options?: EncryptOptions): Promise<string>;
|
package/dist/types/jwt/sign.d.ts
CHANGED
|
@@ -1,99 +1,8 @@
|
|
|
1
1
|
import type { JWTHeaderParameters, KeyLike, SignOptions } from '../types';
|
|
2
2
|
import { ProduceJWT } from './produce';
|
|
3
3
|
/**
|
|
4
|
-
* The SignJWT class is
|
|
4
|
+
* The SignJWT class is used to build and sign Compact JWS formatted JSON Web Tokens.
|
|
5
5
|
*
|
|
6
|
-
* @example Usage with a symmetric secret
|
|
7
|
-
*
|
|
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
|
-
*
|
|
87
|
-
* const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
|
|
88
|
-
* .setProtectedHeader({ alg })
|
|
89
|
-
* .setIssuedAt()
|
|
90
|
-
* .setIssuer('urn:example:issuer')
|
|
91
|
-
* .setAudience('urn:example:audience')
|
|
92
|
-
* .setExpirationTime('2h')
|
|
93
|
-
* .sign(privateKey)
|
|
94
|
-
*
|
|
95
|
-
* console.log(jwt)
|
|
96
|
-
* ```
|
|
97
6
|
*/
|
|
98
7
|
export declare class SignJWT extends ProduceJWT {
|
|
99
8
|
private _protectedHeader;
|
|
@@ -106,7 +15,8 @@ export declare class SignJWT extends ProduceJWT {
|
|
|
106
15
|
/**
|
|
107
16
|
* Signs and returns the JWT.
|
|
108
17
|
*
|
|
109
|
-
* @param key Private Key or Secret to sign the JWT with.
|
|
18
|
+
* @param key Private Key or Secret to sign the JWT with. See
|
|
19
|
+
* {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}.
|
|
110
20
|
* @param options JWT Sign options.
|
|
111
21
|
*/
|
|
112
22
|
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<string>;
|
|
@@ -7,29 +7,6 @@ export interface UnsecuredResult {
|
|
|
7
7
|
/**
|
|
8
8
|
* The UnsecuredJWT class is a utility for dealing with `{ "alg": "none" }` Unsecured JWTs.
|
|
9
9
|
*
|
|
10
|
-
* @example Encoding
|
|
11
|
-
*
|
|
12
|
-
* ```js
|
|
13
|
-
* const unsecuredJwt = new jose.UnsecuredJWT({ 'urn:example:claim': true })
|
|
14
|
-
* .setIssuedAt()
|
|
15
|
-
* .setIssuer('urn:example:issuer')
|
|
16
|
-
* .setAudience('urn:example:audience')
|
|
17
|
-
* .setExpirationTime('2h')
|
|
18
|
-
* .encode()
|
|
19
|
-
*
|
|
20
|
-
* console.log(unsecuredJwt)
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @example Decoding
|
|
24
|
-
*
|
|
25
|
-
* ```js
|
|
26
|
-
* const payload = jose.UnsecuredJWT.decode(jwt, {
|
|
27
|
-
* issuer: 'urn:example:issuer',
|
|
28
|
-
* audience: 'urn:example:audience',
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
|
-
* console.log(payload)
|
|
32
|
-
* ```
|
|
33
10
|
*/
|
|
34
11
|
export declare class UnsecuredJWT extends ProduceJWT {
|
|
35
12
|
/** Encodes the Unsecured JWT. */
|