jose 6.0.7 → 6.0.9
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/types/index.d.ts +3 -4
- package/dist/types/jwe/compact/encrypt.d.ts +6 -2
- package/dist/types/jwe/flattened/encrypt.d.ts +6 -9
- package/dist/types/jwe/general/encrypt.d.ts +9 -9
- package/dist/types/jwks/remote.d.ts +10 -1
- package/dist/types/jws/compact/sign.d.ts +6 -2
- package/dist/types/jws/flattened/sign.d.ts +6 -4
- package/dist/types/jws/general/sign.d.ts +9 -6
- package/dist/types/jwt/encrypt.d.ts +15 -9
- package/dist/types/jwt/produce.d.ts +17 -101
- package/dist/types/jwt/sign.d.ts +15 -3
- package/dist/types/jwt/unsecured.d.ts +15 -2
- package/dist/types/types.d.ts +107 -0
- package/dist/types/util/errors.d.ts +15 -1
- package/dist/webapi/index.js +1 -1
- package/dist/webapi/jwe/compact/encrypt.js +7 -7
- package/dist/webapi/jwe/flattened/encrypt.js +44 -44
- package/dist/webapi/jwe/general/encrypt.js +40 -40
- package/dist/webapi/jwks/local.js +11 -14
- package/dist/webapi/jwks/remote.js +52 -46
- package/dist/webapi/jws/compact/sign.js +4 -4
- package/dist/webapi/jws/flattened/sign.js +20 -20
- package/dist/webapi/jws/general/sign.js +13 -13
- package/dist/webapi/jwt/encrypt.js +69 -36
- package/dist/webapi/jwt/produce.js +57 -42
- package/dist/webapi/jwt/sign.js +40 -9
- package/dist/webapi/jwt/unsecured.js +34 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Support from the community to continue maintaining and improving this module is
|
|
|
22
22
|
|
|
23
23
|
## Documentation
|
|
24
24
|
|
|
25
|
-
`jose` is distributed via [npmjs.com](https://www.npmjs.com/package/jose), [jsr.io](https://jsr.io/@panva/jose), [
|
|
25
|
+
`jose` is distributed via [npmjs.com](https://www.npmjs.com/package/jose), [jsr.io](https://jsr.io/@panva/jose), [jsdelivr.com](https://www.jsdelivr.com/package/npm/jose), and [github.com](https://github.com/panva/jose).
|
|
26
26
|
|
|
27
27
|
**`example`** ESM import[^cjs]
|
|
28
28
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export { jwtVerify } from './jwt/verify.js';
|
|
|
16
16
|
export type { JWTVerifyOptions, JWTVerifyGetKey } from './jwt/verify.js';
|
|
17
17
|
export { jwtDecrypt } from './jwt/decrypt.js';
|
|
18
18
|
export type { JWTDecryptOptions, JWTDecryptGetKey } from './jwt/decrypt.js';
|
|
19
|
-
export type { ProduceJWT } from './jwt/produce.js';
|
|
20
19
|
export { CompactEncrypt } from './jwe/compact/encrypt.js';
|
|
21
20
|
export { FlattenedEncrypt } from './jwe/flattened/encrypt.js';
|
|
22
21
|
export { CompactSign } from './jws/compact/sign.js';
|
|
@@ -28,8 +27,8 @@ export { EncryptJWT } from './jwt/encrypt.js';
|
|
|
28
27
|
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
29
28
|
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
30
29
|
export { createLocalJWKSet } from './jwks/local.js';
|
|
31
|
-
export { createRemoteJWKSet, jwksCache } from './jwks/remote.js';
|
|
32
|
-
export type { RemoteJWKSetOptions, JWKSCacheInput, ExportedJWKSCache,
|
|
30
|
+
export { createRemoteJWKSet, jwksCache, customFetch } from './jwks/remote.js';
|
|
31
|
+
export type { RemoteJWKSetOptions, JWKSCacheInput, ExportedJWKSCache, FetchImplementation, } from './jwks/remote.js';
|
|
33
32
|
export { UnsecuredJWT } from './jwt/unsecured.js';
|
|
34
33
|
export type { UnsecuredResult } from './jwt/unsecured.js';
|
|
35
34
|
export { exportPKCS8, exportSPKI, exportJWK } from './key/export.js';
|
|
@@ -44,7 +43,7 @@ export type { GenerateKeyPairResult, GenerateKeyPairOptions } from './key/genera
|
|
|
44
43
|
export { generateSecret } from './key/generate_secret.js';
|
|
45
44
|
export type { GenerateSecretOptions } from './key/generate_secret.js';
|
|
46
45
|
export * as base64url from './util/base64url.js';
|
|
47
|
-
export type { CompactDecryptResult, CompactJWEHeaderParameters, CompactJWSHeaderParameters, CompactVerifyResult, CritOption, CryptoKey, DecryptOptions, EncryptOptions, FlattenedDecryptResult, FlattenedJWE, FlattenedJWS, FlattenedJWSInput, FlattenedVerifyResult, GeneralDecryptResult, GeneralJWE, GeneralJWS, GeneralJWSInput, GeneralVerifyResult, GetKeyFunction, JoseHeaderParameters, JSONWebKeySet, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWK_EC_Private, JWK_EC_Public, JWK_oct, JWK_OKP_Private, JWK_OKP_Public, JWK_RSA_Private, JWK_RSA_Public, JWK, JWKParameters, JWSHeaderParameters, JWTClaimVerificationOptions, JWTDecryptResult, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject, ResolvedKey, SignOptions, VerifyOptions, } from './types.d.ts';
|
|
46
|
+
export type { CompactDecryptResult, CompactJWEHeaderParameters, CompactJWSHeaderParameters, CompactVerifyResult, CritOption, CryptoKey, DecryptOptions, EncryptOptions, FlattenedDecryptResult, FlattenedJWE, FlattenedJWS, FlattenedJWSInput, FlattenedVerifyResult, GeneralDecryptResult, GeneralJWE, GeneralJWS, GeneralJWSInput, GeneralVerifyResult, GetKeyFunction, JoseHeaderParameters, JSONWebKeySet, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWK_EC_Private, JWK_EC_Public, JWK_oct, JWK_OKP_Private, JWK_OKP_Public, JWK_RSA_Private, JWK_RSA_Public, JWK, JWKParameters, JWSHeaderParameters, JWTClaimVerificationOptions, JWTDecryptResult, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject, ProduceJWT, ResolvedKey, SignOptions, VerifyOptions, } from './types.d.ts';
|
|
48
47
|
/**
|
|
49
48
|
* In prior releases this indicated whether a Node.js-specific build was loaded, this is now fixed
|
|
50
49
|
* to `"WebCryptoAPI"`
|
|
@@ -12,8 +12,12 @@ import type * as types from '../../types.d.ts';
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export declare class CompactEncrypt {
|
|
15
|
-
private
|
|
16
|
-
/**
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link CompactEncrypt} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param plaintext Binary representation of the plaintext to encrypt.
|
|
20
|
+
*/
|
|
17
21
|
constructor(plaintext: Uint8Array);
|
|
18
22
|
/**
|
|
19
23
|
* Sets a content encryption key to use, by default a random suitable one is generated for the JWE
|
|
@@ -12,15 +12,12 @@ import type * as types from '../../types.d.ts';
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export declare class FlattenedEncrypt {
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
private _iv;
|
|
22
|
-
private _keyManagementParameters;
|
|
23
|
-
/** @param plaintext Binary representation of the plaintext to encrypt. */
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link FlattenedEncrypt} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param plaintext Binary representation of the plaintext to encrypt.
|
|
20
|
+
*/
|
|
24
21
|
constructor(plaintext: Uint8Array);
|
|
25
22
|
/**
|
|
26
23
|
* Sets the JWE Key Management parameters to be used when encrypting. Use of this is method is
|
|
@@ -12,11 +12,11 @@ export interface Recipient {
|
|
|
12
12
|
* @param unprotectedHeader JWE Per-Recipient Unprotected Header.
|
|
13
13
|
*/
|
|
14
14
|
setUnprotectedHeader(unprotectedHeader: types.JWEHeaderParameters): Recipient;
|
|
15
|
-
/** A shorthand for calling addRecipient() on the enclosing GeneralEncrypt instance */
|
|
15
|
+
/** A shorthand for calling addRecipient() on the enclosing {@link GeneralEncrypt} instance */
|
|
16
16
|
addRecipient(...args: Parameters<GeneralEncrypt['addRecipient']>): Recipient;
|
|
17
|
-
/** A shorthand for calling encrypt() on the enclosing GeneralEncrypt instance */
|
|
17
|
+
/** A shorthand for calling encrypt() on the enclosing {@link GeneralEncrypt} instance */
|
|
18
18
|
encrypt(...args: Parameters<GeneralEncrypt['encrypt']>): Promise<types.GeneralJWE>;
|
|
19
|
-
/** Returns the enclosing GeneralEncrypt */
|
|
19
|
+
/** Returns the enclosing {@link GeneralEncrypt} instance */
|
|
20
20
|
done(): GeneralEncrypt;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -27,12 +27,12 @@ export interface Recipient {
|
|
|
27
27
|
*
|
|
28
28
|
*/
|
|
29
29
|
export declare class GeneralEncrypt {
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* {@link GeneralEncrypt} constructor
|
|
33
|
+
*
|
|
34
|
+
* @param plaintext Binary representation of the plaintext to encrypt.
|
|
35
|
+
*/
|
|
36
36
|
constructor(plaintext: Uint8Array);
|
|
37
37
|
/**
|
|
38
38
|
* Adds an additional recipient for the General JWE object.
|
|
@@ -95,9 +95,16 @@ import type * as types from '../types.d.ts';
|
|
|
95
95
|
*/
|
|
96
96
|
export declare const customFetch: unique symbol;
|
|
97
97
|
/** See {@link customFetch}. */
|
|
98
|
-
export type FetchImplementation = (
|
|
98
|
+
export type FetchImplementation = (
|
|
99
|
+
/** URL the request is being made sent to {@link !fetch} as the `resource` argument */
|
|
100
|
+
url: string,
|
|
101
|
+
/** Options otherwise sent to {@link !fetch} as the `options` argument */
|
|
102
|
+
options: {
|
|
103
|
+
/** HTTP Headers */
|
|
99
104
|
headers: Headers;
|
|
105
|
+
/** The {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods request method} */
|
|
100
106
|
method: 'GET';
|
|
107
|
+
/** See {@link !Request.redirect} */
|
|
101
108
|
redirect: 'manual';
|
|
102
109
|
signal: AbortSignal;
|
|
103
110
|
}) => Promise<Response>;
|
|
@@ -178,7 +185,9 @@ export interface RemoteJWKSetOptions {
|
|
|
178
185
|
}
|
|
179
186
|
/** See {@link jwksCache}. */
|
|
180
187
|
export interface ExportedJWKSCache {
|
|
188
|
+
/** Current cached JSON Web Key Set */
|
|
181
189
|
jwks: types.JSONWebKeySet;
|
|
190
|
+
/** Last updated at timestamp (seconds since epoch) */
|
|
182
191
|
uat: number;
|
|
183
192
|
}
|
|
184
193
|
/** See {@link jwksCache}. */
|
|
@@ -12,8 +12,12 @@ import type * as types from '../../types.d.ts';
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export declare class CompactSign {
|
|
15
|
-
private
|
|
16
|
-
/**
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link CompactSign} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param payload Binary representation of the payload to sign.
|
|
20
|
+
*/
|
|
17
21
|
constructor(payload: Uint8Array);
|
|
18
22
|
/**
|
|
19
23
|
* Sets the JWS Protected Header on the CompactSign object.
|
|
@@ -12,10 +12,12 @@ import type * as types from '../../types.d.ts';
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export declare class FlattenedSign {
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link FlattenedSign} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param payload Binary representation of the payload to sign.
|
|
20
|
+
*/
|
|
19
21
|
constructor(payload: Uint8Array);
|
|
20
22
|
/**
|
|
21
23
|
* Sets the JWS Protected Header on the FlattenedSign object.
|
|
@@ -18,11 +18,11 @@ export interface Signature {
|
|
|
18
18
|
* @param unprotectedHeader JWS Unprotected Header.
|
|
19
19
|
*/
|
|
20
20
|
setUnprotectedHeader(unprotectedHeader: types.JWSHeaderParameters): Signature;
|
|
21
|
-
/** A shorthand for calling addSignature() on the enclosing GeneralSign instance */
|
|
21
|
+
/** A shorthand for calling addSignature() on the enclosing {@link GeneralSign} instance */
|
|
22
22
|
addSignature(...args: Parameters<GeneralSign['addSignature']>): Signature;
|
|
23
|
-
/** A shorthand for calling encrypt() on the enclosing GeneralSign instance */
|
|
23
|
+
/** A shorthand for calling encrypt() on the enclosing {@link GeneralSign} instance */
|
|
24
24
|
sign(...args: Parameters<GeneralSign['sign']>): Promise<types.GeneralJWS>;
|
|
25
|
-
/** Returns the enclosing GeneralSign */
|
|
25
|
+
/** Returns the enclosing {@link GeneralSign} instance */
|
|
26
26
|
done(): GeneralSign;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -33,9 +33,12 @@ export interface Signature {
|
|
|
33
33
|
*
|
|
34
34
|
*/
|
|
35
35
|
export declare class GeneralSign {
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
#private;
|
|
37
|
+
/**
|
|
38
|
+
* {@link GeneralSign} constructor
|
|
39
|
+
*
|
|
40
|
+
* @param payload Binary representation of the payload to sign.
|
|
41
|
+
*/
|
|
39
42
|
constructor(payload: Uint8Array);
|
|
40
43
|
/**
|
|
41
44
|
* Adds an additional signature for the General JWS object.
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type * as types from '../types.d.ts';
|
|
7
|
-
import { ProduceJWT } from './produce.js';
|
|
8
7
|
/**
|
|
9
8
|
* The EncryptJWT class is used to build and encrypt Compact JWE formatted JSON Web Tokens.
|
|
10
9
|
*
|
|
@@ -12,14 +11,21 @@ import { ProduceJWT } from './produce.js';
|
|
|
12
11
|
* from its subpath export `'jose/jwt/encrypt'`.
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
|
-
export declare class EncryptJWT
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
export declare class EncryptJWT implements types.ProduceJWT {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link EncryptJWT} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param payload The JWT Claims Set object. Defaults to an empty object.
|
|
20
|
+
*/
|
|
21
|
+
constructor(payload?: types.JWTPayload);
|
|
22
|
+
setIssuer(issuer: string): this;
|
|
23
|
+
setSubject(subject: string): this;
|
|
24
|
+
setAudience(audience: string | string[]): this;
|
|
25
|
+
setJti(jwtId: string): this;
|
|
26
|
+
setNotBefore(input: number | string | Date): this;
|
|
27
|
+
setExpirationTime(input: number | string | Date): this;
|
|
28
|
+
setIssuedAt(input?: number | string | Date): this;
|
|
23
29
|
/**
|
|
24
30
|
* Sets the JWE Protected Header on the EncryptJWT object.
|
|
25
31
|
*
|
|
@@ -1,104 +1,20 @@
|
|
|
1
1
|
import type * as types from '../types.d.ts';
|
|
2
|
-
/** Generic class for JWT producing. */
|
|
3
2
|
export declare class ProduceJWT {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @param audience "aud" (Audience) Claim value to set on the JWT Claims Set.
|
|
23
|
-
*/
|
|
24
|
-
setAudience(audience: string | string[]): this;
|
|
25
|
-
/**
|
|
26
|
-
* Set the "jti" (JWT ID) Claim.
|
|
27
|
-
*
|
|
28
|
-
* @param jwtId "jti" (JWT ID) Claim value to set on the JWT Claims Set.
|
|
29
|
-
*/
|
|
30
|
-
setJti(jwtId: string): this;
|
|
31
|
-
/**
|
|
32
|
-
* Set the "nbf" (Not Before) Claim.
|
|
33
|
-
*
|
|
34
|
-
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
35
|
-
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
36
|
-
* claim.
|
|
37
|
-
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
38
|
-
* current unix timestamp and used as the claim.
|
|
39
|
-
*
|
|
40
|
-
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
41
|
-
* day".
|
|
42
|
-
*
|
|
43
|
-
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
44
|
-
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
45
|
-
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
46
|
-
* alias for a year.
|
|
47
|
-
*
|
|
48
|
-
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
49
|
-
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
50
|
-
* readability when adding to the current unix timestamp.
|
|
51
|
-
*
|
|
52
|
-
* @param input "nbf" (Not Before) Claim value to set on the JWT Claims Set.
|
|
53
|
-
*/
|
|
54
|
-
setNotBefore(input: number | string | Date): this;
|
|
55
|
-
/**
|
|
56
|
-
* Set the "exp" (Expiration Time) Claim.
|
|
57
|
-
*
|
|
58
|
-
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
59
|
-
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
60
|
-
* claim.
|
|
61
|
-
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
62
|
-
* current unix timestamp and used as the claim.
|
|
63
|
-
*
|
|
64
|
-
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
65
|
-
* day".
|
|
66
|
-
*
|
|
67
|
-
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
68
|
-
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
69
|
-
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
70
|
-
* alias for a year.
|
|
71
|
-
*
|
|
72
|
-
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
73
|
-
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
74
|
-
* readability when adding to the current unix timestamp.
|
|
75
|
-
*
|
|
76
|
-
* @param input "exp" (Expiration Time) Claim value to set on the JWT Claims Set.
|
|
77
|
-
*/
|
|
78
|
-
setExpirationTime(input: number | string | Date): this;
|
|
79
|
-
/**
|
|
80
|
-
* Set the "iat" (Issued At) Claim.
|
|
81
|
-
*
|
|
82
|
-
* - If no argument is used the current unix timestamp is used as the claim.
|
|
83
|
-
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
84
|
-
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
85
|
-
* claim.
|
|
86
|
-
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
87
|
-
* current unix timestamp and used as the claim.
|
|
88
|
-
*
|
|
89
|
-
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
90
|
-
* day".
|
|
91
|
-
*
|
|
92
|
-
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
93
|
-
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
94
|
-
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
95
|
-
* alias for a year.
|
|
96
|
-
*
|
|
97
|
-
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
98
|
-
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
99
|
-
* readability when adding to the current unix timestamp.
|
|
100
|
-
*
|
|
101
|
-
* @param input "iat" (Expiration Time) Claim value to set on the JWT Claims Set.
|
|
102
|
-
*/
|
|
103
|
-
setIssuedAt(input?: number | string | Date): this;
|
|
3
|
+
#private;
|
|
4
|
+
constructor(payload: types.JWTPayload);
|
|
5
|
+
data(): Uint8Array;
|
|
6
|
+
get iss(): string | undefined;
|
|
7
|
+
set iss(value: string);
|
|
8
|
+
get sub(): string | undefined;
|
|
9
|
+
set sub(value: string);
|
|
10
|
+
get aud(): string | string[] | undefined;
|
|
11
|
+
set aud(value: string | string[]);
|
|
12
|
+
get jti(): string | undefined;
|
|
13
|
+
set jti(value: string);
|
|
14
|
+
get nbf(): number | undefined;
|
|
15
|
+
set nbf(value: number | string | Date);
|
|
16
|
+
get exp(): number | undefined;
|
|
17
|
+
set exp(value: number | string | Date);
|
|
18
|
+
get iat(): number | undefined;
|
|
19
|
+
set iat(value: number | string | Date | undefined);
|
|
104
20
|
}
|
package/dist/types/jwt/sign.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type * as types from '../types.d.ts';
|
|
7
|
-
import { ProduceJWT } from './produce.js';
|
|
8
7
|
/**
|
|
9
8
|
* The SignJWT class is used to build and sign Compact JWS formatted JSON Web Tokens.
|
|
10
9
|
*
|
|
@@ -12,8 +11,21 @@ import { ProduceJWT } from './produce.js';
|
|
|
12
11
|
* from its subpath export `'jose/jwt/sign'`.
|
|
13
12
|
*
|
|
14
13
|
*/
|
|
15
|
-
export declare class SignJWT
|
|
16
|
-
private
|
|
14
|
+
export declare class SignJWT implements types.ProduceJWT {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* {@link SignJWT} constructor
|
|
18
|
+
*
|
|
19
|
+
* @param payload The JWT Claims Set object. Defaults to an empty object.
|
|
20
|
+
*/
|
|
21
|
+
constructor(payload?: types.JWTPayload);
|
|
22
|
+
setIssuer(issuer: string): this;
|
|
23
|
+
setSubject(subject: string): this;
|
|
24
|
+
setAudience(audience: string | string[]): this;
|
|
25
|
+
setJti(jwtId: string): this;
|
|
26
|
+
setNotBefore(input: number | string | Date): this;
|
|
27
|
+
setExpirationTime(input: number | string | Date): this;
|
|
28
|
+
setIssuedAt(input?: number | string | Date): this;
|
|
17
29
|
/**
|
|
18
30
|
* Sets the JWS Protected Header on the SignJWT object.
|
|
19
31
|
*
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type * as types from '../types.d.ts';
|
|
7
|
-
import { ProduceJWT } from './produce.js';
|
|
8
7
|
/** Result of decoding an Unsecured JWT. */
|
|
9
8
|
export interface UnsecuredResult<PayloadType = types.JWTPayload> {
|
|
10
9
|
payload: PayloadType & types.JWTPayload;
|
|
@@ -17,9 +16,23 @@ export interface UnsecuredResult<PayloadType = types.JWTPayload> {
|
|
|
17
16
|
* from its subpath export `'jose/jwt/unsecured'`.
|
|
18
17
|
*
|
|
19
18
|
*/
|
|
20
|
-
export declare class UnsecuredJWT
|
|
19
|
+
export declare class UnsecuredJWT implements types.ProduceJWT {
|
|
20
|
+
#private;
|
|
21
|
+
/**
|
|
22
|
+
* {@link UnsecuredJWT} constructor
|
|
23
|
+
*
|
|
24
|
+
* @param payload The JWT Claims Set object. Defaults to an empty object.
|
|
25
|
+
*/
|
|
26
|
+
constructor(payload?: types.JWTPayload);
|
|
21
27
|
/** Encodes the Unsecured JWT. */
|
|
22
28
|
encode(): string;
|
|
29
|
+
setIssuer(issuer: string): this;
|
|
30
|
+
setSubject(subject: string): this;
|
|
31
|
+
setAudience(audience: string | string[]): this;
|
|
32
|
+
setJti(jwtId: string): this;
|
|
33
|
+
setNotBefore(input: number | string | Date): this;
|
|
34
|
+
setExpirationTime(input: number | string | Date): this;
|
|
35
|
+
setIssuedAt(input?: number | string | Date): this;
|
|
23
36
|
/**
|
|
24
37
|
* Decodes an unsecured JWT.
|
|
25
38
|
*
|
package/dist/types/types.d.ts
CHANGED
|
@@ -703,3 +703,110 @@ export type CryptoKey = Extract<
|
|
|
703
703
|
Awaited<ReturnType<typeof crypto.subtle.generateKey>>,
|
|
704
704
|
{ type: string }
|
|
705
705
|
>
|
|
706
|
+
|
|
707
|
+
/** Generic interface for JWT producing classes. */
|
|
708
|
+
export interface ProduceJWT {
|
|
709
|
+
/**
|
|
710
|
+
* Set the "iss" (Issuer) Claim.
|
|
711
|
+
*
|
|
712
|
+
* @param issuer "Issuer" Claim value to set on the JWT Claims Set.
|
|
713
|
+
*/
|
|
714
|
+
setIssuer(issuer: string): this
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Set the "sub" (Subject) Claim.
|
|
718
|
+
*
|
|
719
|
+
* @param subject "sub" (Subject) Claim value to set on the JWT Claims Set.
|
|
720
|
+
*/
|
|
721
|
+
setSubject(subject: string): this
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Set the "aud" (Audience) Claim.
|
|
725
|
+
*
|
|
726
|
+
* @param audience "aud" (Audience) Claim value to set on the JWT Claims Set.
|
|
727
|
+
*/
|
|
728
|
+
setAudience(audience: string | string[]): this
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* Set the "jti" (JWT ID) Claim.
|
|
732
|
+
*
|
|
733
|
+
* @param jwtId "jti" (JWT ID) Claim value to set on the JWT Claims Set.
|
|
734
|
+
*/
|
|
735
|
+
setJti(jwtId: string): this
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Set the "nbf" (Not Before) Claim.
|
|
739
|
+
*
|
|
740
|
+
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
741
|
+
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
742
|
+
* claim.
|
|
743
|
+
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
744
|
+
* current unix timestamp and used as the claim.
|
|
745
|
+
*
|
|
746
|
+
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
747
|
+
* day".
|
|
748
|
+
*
|
|
749
|
+
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
750
|
+
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
751
|
+
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
752
|
+
* alias for a year.
|
|
753
|
+
*
|
|
754
|
+
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
755
|
+
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
756
|
+
* readability when adding to the current unix timestamp.
|
|
757
|
+
*
|
|
758
|
+
* @param input "nbf" (Not Before) Claim value to set on the JWT Claims Set.
|
|
759
|
+
*/
|
|
760
|
+
setNotBefore(input: number | string | Date): this
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Set the "exp" (Expiration Time) Claim.
|
|
764
|
+
*
|
|
765
|
+
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
766
|
+
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
767
|
+
* claim.
|
|
768
|
+
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
769
|
+
* current unix timestamp and used as the claim.
|
|
770
|
+
*
|
|
771
|
+
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
772
|
+
* day".
|
|
773
|
+
*
|
|
774
|
+
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
775
|
+
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
776
|
+
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
777
|
+
* alias for a year.
|
|
778
|
+
*
|
|
779
|
+
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
780
|
+
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
781
|
+
* readability when adding to the current unix timestamp.
|
|
782
|
+
*
|
|
783
|
+
* @param input "exp" (Expiration Time) Claim value to set on the JWT Claims Set.
|
|
784
|
+
*/
|
|
785
|
+
setExpirationTime(input: number | string | Date): this
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Set the "iat" (Issued At) Claim.
|
|
789
|
+
*
|
|
790
|
+
* - If no argument is used the current unix timestamp is used as the claim.
|
|
791
|
+
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
792
|
+
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
793
|
+
* claim.
|
|
794
|
+
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
795
|
+
* current unix timestamp and used as the claim.
|
|
796
|
+
*
|
|
797
|
+
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
798
|
+
* day".
|
|
799
|
+
*
|
|
800
|
+
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
801
|
+
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
802
|
+
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
803
|
+
* alias for a year.
|
|
804
|
+
*
|
|
805
|
+
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
806
|
+
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
807
|
+
* readability when adding to the current unix timestamp.
|
|
808
|
+
*
|
|
809
|
+
* @param input "iat" (Expiration Time) Claim value to set on the JWT Claims Set.
|
|
810
|
+
*/
|
|
811
|
+
setIssuedAt(input?: number | string | Date): this
|
|
812
|
+
}
|
|
@@ -15,7 +15,7 @@ export declare class JOSEError extends Error {
|
|
|
15
15
|
* @ignore
|
|
16
16
|
*/
|
|
17
17
|
static code: string;
|
|
18
|
-
/** A unique error code for
|
|
18
|
+
/** A unique error code for {@link JOSEError}. */
|
|
19
19
|
code: string;
|
|
20
20
|
/** @ignore */
|
|
21
21
|
constructor(message?: string, options?: {
|
|
@@ -29,6 +29,7 @@ export declare class JOSEError extends Error {
|
|
|
29
29
|
export declare class JWTClaimValidationFailed extends JOSEError {
|
|
30
30
|
/** @ignore */
|
|
31
31
|
static code: string;
|
|
32
|
+
/** A unique error code for {@link JWTClaimValidationFailed}. */
|
|
32
33
|
code: string;
|
|
33
34
|
/** The Claim for which the validation failed. */
|
|
34
35
|
claim: string;
|
|
@@ -51,6 +52,7 @@ export declare class JWTClaimValidationFailed extends JOSEError {
|
|
|
51
52
|
export declare class JWTExpired extends JOSEError implements JWTClaimValidationFailed {
|
|
52
53
|
/** @ignore */
|
|
53
54
|
static code: string;
|
|
55
|
+
/** A unique error code for {@link JWTExpired}. */
|
|
54
56
|
code: string;
|
|
55
57
|
/** The Claim for which the validation failed. */
|
|
56
58
|
claim: string;
|
|
@@ -73,6 +75,7 @@ export declare class JWTExpired extends JOSEError implements JWTClaimValidationF
|
|
|
73
75
|
export declare class JOSEAlgNotAllowed extends JOSEError {
|
|
74
76
|
/** @ignore */
|
|
75
77
|
static code: string;
|
|
78
|
+
/** A unique error code for {@link JOSEAlgNotAllowed}. */
|
|
76
79
|
code: string;
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
@@ -83,6 +86,7 @@ export declare class JOSEAlgNotAllowed extends JOSEError {
|
|
|
83
86
|
export declare class JOSENotSupported extends JOSEError {
|
|
84
87
|
/** @ignore */
|
|
85
88
|
static code: string;
|
|
89
|
+
/** A unique error code for {@link JOSENotSupported}. */
|
|
86
90
|
code: string;
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
@@ -92,6 +96,7 @@ export declare class JOSENotSupported extends JOSEError {
|
|
|
92
96
|
export declare class JWEDecryptionFailed extends JOSEError {
|
|
93
97
|
/** @ignore */
|
|
94
98
|
static code: string;
|
|
99
|
+
/** A unique error code for {@link JWEDecryptionFailed}. */
|
|
95
100
|
code: string;
|
|
96
101
|
/** @ignore */
|
|
97
102
|
constructor(message?: string, options?: {
|
|
@@ -105,6 +110,7 @@ export declare class JWEDecryptionFailed extends JOSEError {
|
|
|
105
110
|
export declare class JWEInvalid extends JOSEError {
|
|
106
111
|
/** @ignore */
|
|
107
112
|
static code: string;
|
|
113
|
+
/** A unique error code for {@link JWEInvalid}. */
|
|
108
114
|
code: string;
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
@@ -114,6 +120,7 @@ export declare class JWEInvalid extends JOSEError {
|
|
|
114
120
|
export declare class JWSInvalid extends JOSEError {
|
|
115
121
|
/** @ignore */
|
|
116
122
|
static code: string;
|
|
123
|
+
/** A unique error code for {@link JWSInvalid}. */
|
|
117
124
|
code: string;
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
@@ -123,6 +130,7 @@ export declare class JWSInvalid extends JOSEError {
|
|
|
123
130
|
export declare class JWTInvalid extends JOSEError {
|
|
124
131
|
/** @ignore */
|
|
125
132
|
static code: string;
|
|
133
|
+
/** A unique error code for {@link JWTInvalid}. */
|
|
126
134
|
code: string;
|
|
127
135
|
}
|
|
128
136
|
/**
|
|
@@ -132,6 +140,7 @@ export declare class JWTInvalid extends JOSEError {
|
|
|
132
140
|
export declare class JWKInvalid extends JOSEError {
|
|
133
141
|
/** @ignore */
|
|
134
142
|
static code: string;
|
|
143
|
+
/** A unique error code for {@link JWKInvalid}. */
|
|
135
144
|
code: string;
|
|
136
145
|
}
|
|
137
146
|
/**
|
|
@@ -141,6 +150,7 @@ export declare class JWKInvalid extends JOSEError {
|
|
|
141
150
|
export declare class JWKSInvalid extends JOSEError {
|
|
142
151
|
/** @ignore */
|
|
143
152
|
static code: string;
|
|
153
|
+
/** A unique error code for {@link JWKSInvalid}. */
|
|
144
154
|
code: string;
|
|
145
155
|
}
|
|
146
156
|
/**
|
|
@@ -150,6 +160,7 @@ export declare class JWKSInvalid extends JOSEError {
|
|
|
150
160
|
export declare class JWKSNoMatchingKey extends JOSEError {
|
|
151
161
|
/** @ignore */
|
|
152
162
|
static code: string;
|
|
163
|
+
/** A unique error code for {@link JWKSNoMatchingKey}. */
|
|
153
164
|
code: string;
|
|
154
165
|
/** @ignore */
|
|
155
166
|
constructor(message?: string, options?: {
|
|
@@ -165,6 +176,7 @@ export declare class JWKSMultipleMatchingKeys extends JOSEError {
|
|
|
165
176
|
[Symbol.asyncIterator]: () => AsyncIterableIterator<types.CryptoKey>;
|
|
166
177
|
/** @ignore */
|
|
167
178
|
static code: string;
|
|
179
|
+
/** A unique error code for {@link JWKSMultipleMatchingKeys}. */
|
|
168
180
|
code: string;
|
|
169
181
|
/** @ignore */
|
|
170
182
|
constructor(message?: string, options?: {
|
|
@@ -178,6 +190,7 @@ export declare class JWKSMultipleMatchingKeys extends JOSEError {
|
|
|
178
190
|
export declare class JWKSTimeout extends JOSEError {
|
|
179
191
|
/** @ignore */
|
|
180
192
|
static code: string;
|
|
193
|
+
/** A unique error code for {@link JWKSTimeout}. */
|
|
181
194
|
code: string;
|
|
182
195
|
/** @ignore */
|
|
183
196
|
constructor(message?: string, options?: {
|
|
@@ -191,6 +204,7 @@ export declare class JWKSTimeout extends JOSEError {
|
|
|
191
204
|
export declare class JWSSignatureVerificationFailed extends JOSEError {
|
|
192
205
|
/** @ignore */
|
|
193
206
|
static code: string;
|
|
207
|
+
/** A unique error code for {@link JWSSignatureVerificationFailed}. */
|
|
194
208
|
code: string;
|
|
195
209
|
/** @ignore */
|
|
196
210
|
constructor(message?: string, options?: {
|