jose 6.0.8 → 6.0.10

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 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), [deno.land/x](https://deno.land/x/jose), [cdnjs.com](https://cdnjs.com/libraries/jose), [jsdelivr.com](https://www.jsdelivr.com/package/npm/jose), and [github.com](https://github.com/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
 
@@ -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';
@@ -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 _flattened;
16
- /** @param plaintext Binary representation of the plaintext to encrypt. */
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 _plaintext;
16
- private _protectedHeader;
17
- private _sharedUnprotectedHeader;
18
- private _unprotectedHeader;
19
- private _aad;
20
- private _cek;
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 _plaintext;
31
- private _recipients;
32
- private _protectedHeader;
33
- private _unprotectedHeader;
34
- private _aad;
35
- /** @param plaintext Binary representation of the plaintext to encrypt. */
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 = (url: string, options: {
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 _flattened;
16
- /** @param payload Binary representation of the payload to sign. */
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 _payload;
16
- private _protectedHeader;
17
- private _unprotectedHeader;
18
- /** @param payload Binary representation of the payload to sign. */
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 _payload;
37
- private _signatures;
38
- /** @param payload Binary representation of the payload to sign. */
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 extends ProduceJWT {
16
- private _cek;
17
- private _iv;
18
- private _keyManagementParameters;
19
- private _protectedHeader;
20
- private _replicateIssuerAsHeader;
21
- private _replicateSubjectAsHeader;
22
- private _replicateAudienceAsHeader;
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
  *
@@ -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 extends ProduceJWT {
16
- private _protectedHeader;
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 extends ProduceJWT {
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
  *
@@ -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 this particular error subclass. */
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?: {
@@ -1,27 +1,27 @@
1
1
  import { FlattenedEncrypt } from '../flattened/encrypt.js';
2
2
  export class CompactEncrypt {
3
- _flattened;
3
+ #flattened;
4
4
  constructor(plaintext) {
5
- this._flattened = new FlattenedEncrypt(plaintext);
5
+ this.#flattened = new FlattenedEncrypt(plaintext);
6
6
  }
7
7
  setContentEncryptionKey(cek) {
8
- this._flattened.setContentEncryptionKey(cek);
8
+ this.#flattened.setContentEncryptionKey(cek);
9
9
  return this;
10
10
  }
11
11
  setInitializationVector(iv) {
12
- this._flattened.setInitializationVector(iv);
12
+ this.#flattened.setInitializationVector(iv);
13
13
  return this;
14
14
  }
15
15
  setProtectedHeader(protectedHeader) {
16
- this._flattened.setProtectedHeader(protectedHeader);
16
+ this.#flattened.setProtectedHeader(protectedHeader);
17
17
  return this;
18
18
  }
19
19
  setKeyManagementParameters(parameters) {
20
- this._flattened.setKeyManagementParameters(parameters);
20
+ this.#flattened.setKeyManagementParameters(parameters);
21
21
  return this;
22
22
  }
23
23
  async encrypt(key, options) {
24
- const jwe = await this._flattened.encrypt(key, options);
24
+ const jwe = await this.#flattened.encrypt(key, options);
25
25
  return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
26
26
  }
27
27
  }