unjwt 0.7.3 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +4 -4
  2. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  3. package/dist/_chunks/_codec-jwe.d.mts +170 -0
  4. package/dist/_chunks/_codec-jws.mjs +878 -0
  5. package/dist/_chunks/_internal.d.mts +7 -0
  6. package/dist/_chunks/_jwt-internal.mjs +388 -0
  7. package/dist/_chunks/algorithms.mjs +186 -0
  8. package/dist/_chunks/index.d.mts +500 -808
  9. package/dist/_chunks/index2.d.mts +11 -0
  10. package/dist/_chunks/index3.d.mts +108 -0
  11. package/dist/_chunks/jwe.d.mts +43 -66
  12. package/dist/_chunks/jwe.mjs +384 -252
  13. package/dist/_chunks/jwk.mjs +1371 -607
  14. package/dist/_chunks/jws.d.mts +48 -103
  15. package/dist/_chunks/jws.mjs +372 -184
  16. package/dist/_chunks/jwt.d.mts +56 -0
  17. package/dist/_chunks/libs/unsecure.d.mts +164 -85
  18. package/dist/_chunks/libs/unsecure.mjs +390 -123
  19. package/dist/adapters/elysia/index.d.mts +33 -171
  20. package/dist/adapters/elysia/index.mjs +106 -575
  21. package/dist/adapters/h3v1/index.d.mts +59 -344
  22. package/dist/adapters/h3v1/index.mjs +114 -619
  23. package/dist/adapters/h3v2/index.d.mts +58 -326
  24. package/dist/adapters/h3v2/index.mjs +108 -611
  25. package/dist/core/internal.d.mts +2 -0
  26. package/dist/core/internal.mjs +1 -0
  27. package/dist/core/jwe.d.mts +4 -2
  28. package/dist/core/jwe.mjs +4 -2
  29. package/dist/core/jwk.d.mts +183 -371
  30. package/dist/core/jwk.mjs +4 -3
  31. package/dist/core/jws.d.mts +4 -2
  32. package/dist/core/jws.mjs +4 -2
  33. package/dist/core/utils/index.d.mts +5 -158
  34. package/dist/core/utils/index.mjs +12 -3
  35. package/dist/index.d.mts +8 -4
  36. package/dist/index.mjs +6 -3
  37. package/package.json +30 -30
  38. package/dist/_chunks/_internal.mjs +0 -88
  39. package/dist/_chunks/utils.mjs +0 -392
@@ -1,387 +1,199 @@
1
- import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWTError, JWTErrorCauseMap, JWTErrorCode, JoseHeaderParameters, KeyManagementAlgorithm, UnwrapKeyOptions, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor, isJWTError } from "../_chunks/index.mjs";
2
- /**
3
- * Generates a cryptographic key for the specified JWA algorithm.
4
- *
5
- * The return type is narrowed by `alg` and `options.toJWK`. When `toJWK` is not set
6
- * (or is `false`):
7
- *
8
- * - **Symmetric algorithms** (`HS*`, `A*KW`, `A*GCM`, `A*GCMKW`) → `CryptoKey`. The key
9
- * is imported with Web Crypto usages derived from the algorithm (e.g. `["sign", "verify"]`
10
- * for HMAC, `["wrapKey", "unwrapKey"]` for AES-KW, `["encrypt", "decrypt"]` for AES-GCM).
11
- * - **AES-CBC + HMAC composites** (`A128CBC-HS256`, `A192CBC-HS384`, `A256CBC-HS512`) →
12
- * `Uint8Array`. These keys are returned as raw bytes because the composite layout
13
- * (AES key ∥ HMAC key) is not directly importable via `crypto.subtle.importKey`. They
14
- * are split internally during encrypt/decrypt.
15
- * - **Asymmetric algorithms** (`RS*`, `PS*`, `ES*`, `RSA-OAEP*`, `Ed25519`, `EdDSA`,
16
- * `ECDH-ES*`) → `CryptoKeyPair`.
17
- *
18
- * When `options.toJWK` is `true`, the same call returns a JWK / JWK pair instead, with
19
- * a freshly generated `kid` attached (use {@link generateJWK} to customise `kid`,
20
- * `use`, etc.). Composite AES-CBC+HMAC keys are serialised to a single `JWK_oct` and
21
- * re-split internally on use.
22
- *
23
- * PBES2 is not a key-generation algorithm — use {@link deriveKeyFromPassword} or
24
- * {@link deriveJWKFromPassword} instead.
25
- *
26
- * @param alg The JWA algorithm identifier (e.g. `"HS256"`, `"RS256"`, `"A128GCM"`,
27
- * `"A256CBC-HS512"`). PBES2, `"dir"`, and `"none"` are not accepted.
28
- * @param options
29
- * - `toJWK?` — when `true`, return JWK / JWK pair instead of `CryptoKey` / `CryptoKeyPair`.
30
- * - `extractable?` — forwarded to `crypto.subtle.generateKey`. Defaults to `true`.
31
- * Ignored when `toJWK` is set — the JWK output requires exporting the intermediate key.
32
- * - `keyUsage?` — override the default usages derived from `alg`.
33
- * - `modulusLength?` — RSA only; defaults to `2048`.
34
- * - `publicExponent?` — RSA only; defaults to `0x010001`.
35
- * - `namedCurve?` — EC and OKP only; defaults to `"P-256"` for EC and `"Ed25519"` for OKP.
36
- *
37
- * @example
38
- * ```ts
39
- * // HS256 → CryptoKey
40
- * const hmac = await generateKey("HS256");
41
- *
42
- * // A256CBC-HS512 → Uint8Array (composite key)
43
- * const cek = await generateKey("A256CBC-HS512");
44
- *
45
- * // RS256 → CryptoKeyPair
46
- * const rsa = await generateKey("RS256", { modulusLength: 2048 });
47
- *
48
- * // As JWK pair
49
- * const { privateKey, publicKey } = await generateKey("ES256", { toJWK: true });
50
- * ```
51
- */
52
- declare function generateKey<TAlg extends GenerateKeyAlgorithm, TOptions extends GenerateKeyOptions>(alg: TAlg, options?: TOptions): Promise<GenerateKeyReturn<TAlg, TOptions>>;
53
- /**
54
- * Generates a ready-to-use JWK (or JWK pair) for the specified algorithm.
55
- *
56
- * Always returns JWK form with a `kid` attached — auto-generated via
57
- * `crypto.randomUUID()` when not supplied. For a `CryptoKey` / `CryptoKeyPair`
58
- * result instead, use {@link generateKey}. PBES2 is not a key-generation
59
- * algorithm — use {@link deriveJWKFromPassword}.
60
- *
61
- * Composite AES-CBC+HMAC keys (`A128CBC-HS256`, `A192CBC-HS384`, `A256CBC-HS512`)
62
- * are serialised to a single `JWK_oct` and re-split internally on use.
63
- *
64
- * @param alg The JWA algorithm identifier (e.g. `"HS256"`, `"RS256"`, `"ES256"`,
65
- * `"A128GCM"`, `"A256CBC-HS512"`). PBES2, `"dir"`, and `"none"` are
66
- * not accepted.
67
- * @param options
68
- * - `keyUsage?` — override the default usages derived from `alg`.
69
- * - `modulusLength?` — RSA only; defaults to `2048`.
70
- * - `publicExponent?` — RSA only; defaults to `0x010001`.
71
- * - `namedCurve?` — EC and OKP only; defaults to `"P-256"` for EC and `"Ed25519"` for OKP.
72
- * - JWK metadata (`kid`, `use`, `x5c`, `x5t`, `x5t#S256`, `x5u`) is merged onto the
73
- * result. `alg`, `kty`, `key_ops`, and `ext` are managed by the library and cannot
74
- * be overridden here.
75
- *
76
- * @example
77
- * ```ts
78
- * // HS256 → JWK_oct
79
- * const hmac = await generateJWK("HS256");
80
- *
81
- * // RS256 → { privateKey: JWK_RSA_Private; publicKey: JWK_RSA_Public }
82
- * const rsa = await generateJWK("RS256", { modulusLength: 2048, kid: "rsa-1" });
83
- *
84
- * // ES256 with explicit metadata
85
- * const { privateKey, publicKey } = await generateJWK("ES256", { kid: "ec-1", use: "sig" });
86
- * ```
87
- */
88
- declare function generateJWK<TAlg extends GenerateKeyAlgorithm>(alg: TAlg, options?: GenerateJWKOptions & Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">): Promise<GenerateJWKReturn<TAlg>>;
89
- /**
90
- * Derives a key from a password using PBKDF2 as specified by PBES2 algorithms.
91
- *
92
- * @param password The password to derive the key from (string or Uint8Array).
93
- * @param alg The PBES2 algorithm identifier (e.g., "PBES2-HS256+A128KW").
94
- * @param options Configuration options including salt and iterations.
95
- * @returns A Promise resolving to the derived key (CryptoKey) or its JWK_oct representation.
96
- */
97
- declare function deriveKeyFromPassword<TAlg extends JWK_PBES2, TOptions extends DeriveKeyOptions>(password: string | Uint8Array<ArrayBuffer>, alg: TAlg, options: TOptions): Promise<DeriveKeyReturn<TOptions>>;
98
- /**
99
- * Derives a `JWK_oct` from a password using PBKDF2 as specified by PBES2
100
- * (RFC 7518 §4.8). The resulting JWK's `alg` is the underlying AES-KW variant
101
- * (`A128KW` / `A192KW` / `A256KW`), ready to use with {@link wrapKey} /
102
- * {@link unwrapKey}.
103
- *
104
- * For a `CryptoKey` result without JWK metadata, use {@link deriveKeyFromPassword}.
105
- *
106
- * @param password The password to derive the key from (string or `Uint8Array`).
107
- * @param alg The PBES2 algorithm identifier (e.g. `"PBES2-HS256+A128KW"`).
108
- * @param options
109
- * - `salt` — PBKDF2 salt input (`p2s`). Must be at least 8 octets (RFC 7518 §4.8.1.1).
110
- * - `iterations` — PBKDF2 iteration count (`p2c`). Must be a positive integer.
111
- * - `keyUsage?` — defaults to `["wrapKey", "unwrapKey"]`.
112
- * - JWK metadata (`kid`, `use`, `x5c`, `x5t`, `x5t#S256`, `x5u`) is merged onto the
113
- * result. `alg`, `kty`, `key_ops`, and `ext` are managed by the library and cannot
114
- * be overridden here.
115
- */
116
- declare function deriveJWKFromPassword(password: string | Uint8Array<ArrayBuffer>, alg: JWK_PBES2, options: Omit<DeriveKeyOptions, "toJWK" | "extractable"> & Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">): Promise<JWK_oct>;
117
- /**
118
- * Default JWK import cache backed by a WeakMap.
119
- *
120
- * The outer WeakMap is keyed by the JWK object reference — a cache hit only
121
- * occurs when the exact same object variable is passed to {@link importKey}.
122
- * Reconstructing a structurally identical JWK (e.g. `{ ...jwk }`) will miss
123
- * the cache.
124
- *
125
- * The inner `Record<string, CryptoKey>` uses a plain object rather than `Map`
126
- * because typical entries have 1–2 algorithm strings per key. V8 applies
127
- * hidden-class optimisation to small plain objects, making property access
128
- * faster than `Map.get()` at this cardinality.
129
- */
130
- declare class WeakMapJWKCache implements JWKCacheAdapter {
1
+ import { UnsecureError, UnsecureErrorCode } from "../_chunks/libs/unsecure.mjs";
2
+ import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, ECDHEphemeralKeyInput, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWTError, JWTErrorCauseMap, JWTErrorCode, KeyManagementAlgorithm, KnownJWTErrorCode, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor, isJWTError, isUnsecureError } from "../_chunks/index.mjs";
3
+ import { ThumbprintHash, thumbprint } from "../_chunks/index2.mjs";
4
+ /**
5
+ * Generates a key for a JWA algorithm: a `CryptoKey` for symmetric algorithms, raw bytes for
6
+ * the `A*CBC-HS*` composites, a `CryptoKeyPair` for asymmetric ones; with `toJWK: true`, a JWK
7
+ * (or JWK pair) named by the `kid` option or its RFC 7638 thumbprint. PBES2, `"dir"` and `"none"` are refused.
8
+ *
9
+ * @param options
10
+ * - `extractable?` — defaults to `true`; ignored when `toJWK` is set.
11
+ * - `kid?` — with `toJWK`, a string set verbatim or `false` for no `kid`, either skipping the
12
+ * thumbprint digest; anything else throws `ERR_INVALID_OPTION`.
13
+ * - `keyUsage?` — narrows the usages derived from `alg`; leaving either half of a pair with
14
+ * no usage throws `ERR_INVALID_OPTION`.
15
+ * - `modulusLength?` — RSA only; defaults to `2048`.
16
+ * - `publicExponent?` — RSA only; big-endian bytes, defaults to `0x010001`.
17
+ * - `namedCurve?` — EC/OKP only; defaults to `"P-256"` / `"Ed25519"`. One that contradicts
18
+ * the curve `ES*` or `Ed25519` names throws `ERR_INVALID_OPTION`.
19
+ */
20
+ export declare function generateKey<TAlg extends GenerateKeyAlgorithm, ToJWK extends boolean = false, Kid extends string | false = string>(alg: TAlg, options?: GenerateKeyOptions<ToJWK, Kid>): Promise<GenerateKeyReturn<TAlg, GenerateKeyOptions<ToJWK, Kid>>>;
21
+ /**
22
+ * Generates a JWK (or JWK pair) for a JWA algorithm, its `kid` the caller's, none with
23
+ * `kid: false`, or else its RFC 7638 thumbprint. PBES2, `"dir"` and `"none"` are refused.
24
+ *
25
+ * @param options
26
+ * - `keyUsage?`, `modulusLength?` (default `2048`), `publicExponent?` (default `0x010001`),
27
+ * `namedCurve?` (default `"P-256"` / `"Ed25519"`); a narrowing that empties a pair half or
28
+ * a curve that contradicts `alg` throws `ERR_INVALID_OPTION`.
29
+ * - `kid?` — a string set verbatim or `false` for no `kid`, either skipping the thumbprint
30
+ * digest; anything else throws `ERR_INVALID_OPTION`.
31
+ * - JWK metadata (`use`, `x5c`, `x5t`, `x5t#S256`, `x5u`) is merged onto the result;
32
+ * `alg`, `kty`, `key_ops`, `ext` and key-material members are reserved (`ERR_INVALID_OPTION`).
33
+ */
34
+ export declare function generateJWK<TAlg extends GenerateKeyAlgorithm, Kid extends string | false = string>(alg: TAlg, options?: GenerateJWKOptions<Kid> & Omit<JWKMetadata, "kid">): Promise<GenerateJWKReturn<TAlg, Kid>>;
35
+ /**
36
+ * Derives an AES-KW key from a password with PBKDF2 per PBES2 (RFC 7518 §4.8).
37
+ *
38
+ * @param options
39
+ * - `alg` — a PBES2 algorithm; any other throws `ERR_JWK_UNSUPPORTED`.
40
+ * - `salt` — PBKDF2 salt (`p2s`), at least 8 octets (RFC 7518 §4.8.1.1).
41
+ * - `iterations` — PBKDF2 count (`p2c`), an integer of at least 1000 (RFC 7518 §4.8.1.2);
42
+ * anything else throws `ERR_INVALID_OPTION`.
43
+ * - `keyUsage?` — defaults to `["wrapKey", "unwrapKey"]`.
44
+ * - `extractable?` — defaults to `false`; ignored when `toJWK` is set.
45
+ * - `toJWK?` — return a `JWK_oct` carrying the inner AES-KW `alg` instead of a `CryptoKey`.
46
+ */
47
+ export declare function deriveKeyFromPassword<TOptions extends DeriveKeyOptions>(password: string | Uint8Array<ArrayBuffer>, options: TOptions): Promise<DeriveKeyReturn<TOptions, TOptions["alg"]>>;
48
+ /**
49
+ * Derives a `JWK_oct` from a password per PBES2 (RFC 7518 §4.8); its `alg` is the inner AES-KW
50
+ * variant and its `kid` the caller's, none with `kid: false`, or else its RFC 7638 thumbprint.
51
+ *
52
+ * @param options
53
+ * - `alg` (PBES2 only, else `ERR_JWK_UNSUPPORTED`), `salt` (at least 8 octets), `iterations`
54
+ * (integer of at least 1000, else `ERR_INVALID_OPTION`), `keyUsage?` (default
55
+ * `["wrapKey", "unwrapKey"]`).
56
+ * - `kid?` — a string set verbatim or `false` for no `kid`, either skipping the thumbprint
57
+ * digest; anything else throws `ERR_INVALID_OPTION`.
58
+ * - JWK metadata (`use`, `x5c`, `x5t`, `x5t#S256`, `x5u`) is merged onto the result;
59
+ * `alg`, `kty`, `key_ops`, `ext` and key-material members are reserved (`ERR_INVALID_OPTION`).
60
+ */
61
+ export declare function deriveJWKFromPassword(password: string | Uint8Array<ArrayBuffer>, options: Omit<DeriveKeyOptions, "toJWK" | "extractable"> & Omit<JWKMetadata, "kid"> & {
62
+ kid?: string | false;
63
+ }): Promise<JWK_oct>;
64
+ /**
65
+ * Default JWK import cache, keyed by JWK object identity: a copied JWK misses it, and a JWK
66
+ * mutated in place keeps serving the old `CryptoKey`. Rotate by replacing the object.
67
+ */
68
+ export declare class WeakMapJWKCache implements JWKCacheAdapter {
131
69
  private readonly _map;
132
70
  get(jwk: JWK, alg: string): CryptoKey | undefined;
133
71
  set(jwk: JWK, alg: string, key: CryptoKey): void;
134
72
  }
135
73
  /**
136
- * Replace or disable the JWK import cache used by {@link importKey}.
137
- *
138
- * Pass a custom {@link JWKCacheAdapter} to use your own cache strategy
139
- * (LRU, Redis-backed wrapper, test spy, etc.). Pass `false` to disable
140
- * caching entirely.
141
- *
142
- * @example Disable caching:
143
- * ```ts
144
- * configureJWKCache(false);
145
- * ```
146
- * @example Use a custom kid-keyed cache:
147
- * ```ts
148
- * const map = new Map<string, CryptoKey>();
149
- * configureJWKCache({
150
- * get: (jwk, alg) => map.get(`${jwk.kid}:${alg}`),
151
- * set: (jwk, alg, key) => map.set(`${jwk.kid}:${alg}`, key),
152
- * });
153
- * ```
154
- */
155
- declare function configureJWKCache(cache: JWKCacheAdapter | false): void;
156
- /**
157
- * Reset the JWK import cache to a fresh {@link WeakMapJWKCache}.
158
- * Useful in test environments to clear all cached CryptoKey references
159
- * between test runs without disabling the cache entirely.
160
- */
161
- declare function clearJWKCache(): void;
162
- /**
163
- * Imports a key from various formats (CryptoKey, JWK, Uint8Array).
164
- *
165
- * - If `key` is a `CryptoKey`, it's returned directly.
166
- * - If `key` is a `Uint8Array`, it's returned directly.
167
- * - If `key` is a `JWK_oct` (symmetric key with `k`), the raw key bytes are returned as `Uint8Array`.
168
- * - If `key` is any other JWK type (asymmetric), an algorithm hint is required (positional or via options)
169
- * and a `CryptoKey` is returned.
170
- *
171
- * ### `expect` option (asymmetric only)
172
- *
173
- * Pass `expect: "public"` or `expect: "private"` to validate the caller's intent against the key's
174
- * shape before the import. A private JWK passed with `expect: "public"` throws `ERR_JWK_INVALID`
175
- * instead of silently importing the private material. Callers who deliberately want to drop private
176
- * fields can do so themselves — no silent stripping.
177
- *
178
- * `expect` is a no-op for symmetric (`oct`) JWKs and for `CryptoKey` instances whose
179
- * `algorithm.type` is `"secret"`.
180
- */
181
- declare function importKey(key: string): Promise<Uint8Array<ArrayBuffer>>;
182
- declare function importKey(key: Uint8Array<ArrayBuffer>): Promise<Uint8Array<ArrayBuffer>>;
183
- declare function importKey(key: CryptoKey): Promise<CryptoKey>;
184
- declare function importKey(key: JWK_oct): Promise<Uint8Array<ArrayBuffer>>;
185
- declare function importKey(key: JWK_oct, options: {
186
- asCryptoKey: true; /** Algorithm to import the key as (e.g. `{ name: "AES-GCM", length: 256 }`). */
187
- algorithm: Parameters<typeof crypto.subtle.importKey>[2]; /** Key usages for the resulting CryptoKey. */
188
- usage: KeyUsage[]; /** Mark the key as extractable. Defaults to `false`. */
74
+ * Replaces the JWK import cache used by `importKey`, or disables it with `false`.
75
+ *
76
+ * A cache shared across JWK objects keys on the RFC 7638 thumbprint, the pair half (`d` present)
77
+ * and `alg`: the thumbprint covers public members only, and a `kid` may name different keys.
78
+ * `get` and `set` may return promises.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const cacheKey = async (jwk: JWK, alg: string) =>
83
+ * `${await thumbprint(jwk)}:${"d" in jwk ? "private" : "public"}:${alg}`;
84
+ * const map = new Map<string, CryptoKey>();
85
+ * configureJWKCache({
86
+ * get: async (jwk, alg) => map.get(await cacheKey(jwk, alg)),
87
+ * set: async (jwk, alg, key) => {
88
+ * map.set(await cacheKey(jwk, alg), key);
89
+ * },
90
+ * });
91
+ * ```
92
+ */
93
+ export declare function configureJWKCache(cache: JWKCacheAdapter | false): void;
94
+ /** Resets the JWK import cache to a fresh `WeakMapJWKCache`. */
95
+ export declare function clearJWKCache(): void;
96
+ /** Imports the secret of an `oct` JWK as a `CryptoKey` under `algorithm` and `usage`. */
97
+ export declare function importKey(key: JWK_oct, options: {
98
+ asCryptoKey: true;
99
+ /** Algorithm to import the key as (e.g. `{ name: "AES-GCM", length: 256 }`). */
100
+ algorithm: Parameters<typeof crypto.subtle.importKey>[2];
101
+ usage: KeyUsage[];
102
+ /** Mark the key as extractable. Defaults to `false`. */
189
103
  extractable?: boolean;
190
104
  }): Promise<CryptoKey>;
191
- declare function importKey(key: CryptoKey | JWK | Uint8Array<ArrayBuffer> | string, options: {
192
- /** Algorithm hint. Required when `key.alg` is absent on an asymmetric JWK. */alg?: string; /** Reject on shape mismatch instead of silently importing. */
193
- expect?: "public" | "private";
194
- }): Promise<CryptoKey | Uint8Array<ArrayBuffer>>;
195
- declare function importKey(key: CryptoKey | JWK | Uint8Array<ArrayBuffer> | string, alg?: string): Promise<CryptoKey | Uint8Array<ArrayBuffer>>;
196
- /**
197
- * Exports a CryptoKey to a JWK (JSON Web Key) format.
198
- *
199
- * @param key The CryptoKey to export.
200
- * @param jwk Optional partial JWK to merge with the exported key, allowing overrides.
201
- * @returns A Promise resolving to the exported JWK.
202
- */
203
- declare function exportKey<T extends JWK>(key: CryptoKey, jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">): Promise<T>;
204
105
  /**
205
- * Wraps a Content Encryption Key (CEK) using the specified algorithm and wrapping key.
206
- *
207
- * The return shape is narrowed by `alg` — see {@link WrapKeyResult}.
208
- *
209
- * @param alg The JWA key management algorithm (e.g., "A128KW", "RSA-OAEP", "PBES2-HS256+A128KW").
210
- * @param keyToWrap The key to be wrapped (CEK), typically a symmetric key as Uint8Array or CryptoKey.
211
- * @param wrappingKey The key used to wrap the CEK (CryptoKey, JWK, or password string/Uint8Array for PBES2).
212
- * @param options Additional options required by certain algorithms (e.g., p2s, p2c for PBES2).
213
- * @returns A Promise resolving to an alg-specific {@link WrapKeyResult}.
214
- */
215
- declare function wrapKey<TAlg extends KeyManagementAlgorithm>(alg: TAlg, keyToWrap: CryptoKey | Uint8Array<ArrayBuffer>, wrappingKey: WrappingKeyFor<TAlg>, options?: WrapKeyOptions): Promise<WrapKeyResult<TAlg>>;
216
- /**
217
- * Unwraps a Content Encryption Key (CEK) using the specified algorithm and unwrapping key.
218
- *
219
- * @param alg The JWA key management algorithm (e.g., "A128KW", "RSA-OAEP", "PBES2-HS256+A128KW").
220
- * @param wrappedKey The wrapped key (ciphertext) as Uint8Array.
221
- * @param unwrappingKey The key used to unwrap the CEK (CryptoKey, JWK, or password string/Uint8Array for PBES2).
222
- * @param options Additional options required by certain algorithms (e.g., iv, tag, p2s, p2c, epk).
223
- * @returns A Promise resolving to the unwrapped key (CEK) as a CryptoKey or Uint8Array.
224
- */
225
- declare function unwrapKey<TAlg extends KeyManagementAlgorithm>(alg: TAlg, wrappedKey: Uint8Array<ArrayBuffer>, unwrappingKey: UnwrappingKeyFor<TAlg>, options: UnwrapKeyOptions & {
226
- format: "raw";
227
- }): Promise<Uint8Array<ArrayBuffer>>;
228
- declare function unwrapKey<TAlg extends KeyManagementAlgorithm>(alg: TAlg, wrappedKey: Uint8Array<ArrayBuffer>, unwrappingKey: UnwrappingKeyFor<TAlg>, options?: UnwrapKeyOptions & {
229
- format?: "cryptokey";
230
- }): Promise<CryptoKey>;
231
- declare function unwrapKey<TAlg extends KeyManagementAlgorithm>(alg: TAlg, wrappedKey: Uint8Array<ArrayBuffer>, unwrappingKey: UnwrappingKeyFor<TAlg>, options: UnwrapKeyOptions): Promise<CryptoKey | Uint8Array<ArrayBuffer>>;
232
- /**
233
- * Imports a PEM-encoded key and returns it as a JWK.
234
- *
235
- * The PEM type is inferred from the `-----BEGIN <X>-----` label:
236
- * - `PRIVATE KEY` → PKCS#8 private key (RFC 5208)
237
- * - `PUBLIC KEY` → SubjectPublicKeyInfo public key (RFC 5280 §4.1.2.7)
238
- * - `CERTIFICATE` → X.509 certificate; its SPKI is extracted into the JWK and all cert metadata
239
- * (issuer, validity, extensions) is discarded — a JWK cannot represent it
240
- *
241
- * A caller can override the inference via `options.pemType`; the underlying label assertion
242
- * still runs, so a mismatched override (e.g. `pemType: "pkcs8"` on a SPKI body) throws
243
- * `ERR_JWK_INVALID` before any crypto work.
244
- *
245
- * @param pem The PEM-encoded string.
246
- * @param alg The JWA algorithm identifier. Required for `crypto.subtle.importKey` to understand
247
- * the key's intended algorithm and for setting the `alg` field on the resulting JWK.
248
- * @param options
249
- * - `pemType?` — explicit PEM type; inferred from the label when omitted.
250
- * - `jwkParams?` — additional JWK properties merged into the result (e.g. `kid`, `use`).
251
- *
252
- * The returned JWK always contains the key material in plain JavaScript — non-extractable
253
- * import is impossible for a PEM → JWK conversion (JWK export requires an extractable key).
254
- * To obtain a non-extractable `CryptoKey`, pass the result to
255
- * `importKey(jwk, { extractable: false })`.
256
- * `alg`, `kty`, `key_ops`, and `ext` are reserved and cannot be overridden here.
257
- * @throws `JWTError("ERR_JWK_INVALID")` if the PEM type cannot be inferred (no recognised label
258
- * and no `options.pemType`), or if the label does not match the requested/inferred type.
259
- * @throws `JWTError("ERR_JWK_UNSUPPORTED")` if `options.pemType` is a value outside the supported set.
260
- *
261
- * @example
262
- * ```ts
263
- * // Inferred — label on the PEM drives selection.
264
- * const jwk = await importPEM(pemString, "RS256", { jwkParams: { kid: "rsa-1" } });
265
- *
266
- * // Explicit override.
267
- * const jwk2 = await importPEM(pemString, "RS256", { pemType: "x509" });
268
- * ```
269
- */
270
- declare function importPEM<T extends JWK>(pem: string, alg: JWKPEMAlgorithm, options?: {
271
- /** PEM type. Inferred from the PEM label when omitted. */pemType?: "pkcs8" | "spki" | "x509"; /** Additional JWK properties merged into the exported key (e.g. `kid`). */
272
- jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
273
- }): Promise<T>;
274
- /**
275
- * @deprecated Use {@link importPEM} instead. `pemType` has moved into the options object and
276
- * is now inferred from the PEM label by default.
277
- */
278
- declare function importFromPEM<T extends JWK>(pem: string, pemType: "pkcs8" | "spki" | "x509", alg: JWKPEMAlgorithm, options?: {
279
- jwkParams?: Omit<JWKParameters, "alg" | "kty" | "key_ops" | "ext">;
106
+ * Imports key material: a `CryptoKey` or `Uint8Array` is returned as is, an `oct` JWK as its raw
107
+ * bytes, an asymmetric JWK as a `CryptoKey` under its own `alg` or the hint. A string throws
108
+ * `ERR_JWK_INVALID`.
109
+ *
110
+ * `expect` and `extractable` apply to asymmetric keys only; `expect` rejects the other pair half
111
+ * with `ERR_JWK_INVALID`. A JWK's `alg` is authoritative (RFC 7517 §4.4): a different requested
112
+ * `alg` throws `ERR_JWK_INVALID`, except an `oct` JWK declaring a content encryption `alg` under
113
+ * `"dir"`.
114
+ */
115
+ export declare function importKey<K extends CryptoKey | JWK | Uint8Array<ArrayBuffer>>(key: K, options?: string | {
116
+ /** Algorithm hint. Required when `key.alg` is absent on an asymmetric JWK. */
117
+ alg?: string;
118
+ /** Reject on shape mismatch instead of silently importing. */
119
+ expect?: "public" | "private";
120
+ /** Defaults to `false` for private, `true` for public material; JWK `ext: false` wins. */
121
+ extractable?: boolean;
122
+ }): Promise<ImportedKey<K>>;
123
+ /**
124
+ * Exports an extractable `CryptoKey` as a JWK, merging optional `jwkParams` metadata.
125
+ *
126
+ * The `alg` is WebCrypto's, which knows no JOSE roles: an AES-GCM key minted for `A128GCMKW`
127
+ * exports as `A128GCM`, so key-wrapping keys are minted with `generateJWK` instead.
128
+ *
129
+ * @throws `ERR_INVALID_OPTION` if `key` is not a `CryptoKey` or `jwkParams` sets a reserved member
130
+ * (`alg`, `kty`, `key_ops`, `ext`, key material); `ERR_JWK_INVALID` for a non-extractable key.
131
+ */
132
+ export declare function exportKey<T extends JWK = JWK>(key: CryptoKey, jwkParams?: JWKMetadata): Promise<T>;
133
+ /**
134
+ * Wraps a CEK under a JWA key management algorithm; the result shape follows `alg`.
135
+ *
136
+ * @param wrappingKey A `CryptoKey`, a JWK, or for PBES2 a password string or bytes.
137
+ * @param options `alg` plus its parameters (`p2s`/`p2c` for PBES2, `ecdh` for ECDH-ES, …).
138
+ */
139
+ export declare function wrapKey<TAlg extends KeyManagementAlgorithm>(keyToWrap: CryptoKey | Uint8Array<ArrayBuffer>, wrappingKey: WrappingKeyFor<TAlg>, options: WrapKeyOptions<TAlg>): Promise<WrapKeyResult<TAlg>>;
140
+ /**
141
+ * Unwraps a CEK under a JWA key management algorithm.
142
+ *
143
+ * @param unwrappingKey A `CryptoKey`, a JWK, or for PBES2 a password string or bytes.
144
+ * @param options `alg`, `format?` (`"cryptokey"` by default, or `"raw"`), plus the algorithm's
145
+ * parameters (`iv`/`tag`, `p2s`/`p2c`, `epk`, …).
146
+ * @throws `ERR_JWE_DECRYPTION_FAILED` for any failed unwrap, its cause undisclosed (RFC 7516
147
+ * §11.5); `ERR_INVALID_OPTION` for a malformed `wrappedKey` or `options`; `ERR_JWE_INVALID` for
148
+ * missing or malformed algorithm parameters.
149
+ */
150
+ export declare function unwrapKey<TOptions extends UnwrapKeyOptions>(wrappedKey: Uint8Array<ArrayBuffer>, unwrappingKey: UnwrappingKeyFor<TOptions["alg"]>, options: TOptions): Promise<UnwrapKeyResult<TOptions>>;
151
+ /**
152
+ * Imports a PEM key as a JWK carrying `alg`. The type follows the label — `PRIVATE KEY`
153
+ * (PKCS#8), `PUBLIC KEY` (SPKI), `CERTIFICATE` (X.509, only its SPKI kept) — unless
154
+ * `options.pemType` overrides it. The JWK holds the key material in plain JavaScript.
155
+ *
156
+ * @throws `ERR_JWK_INVALID` if the type cannot be inferred or does not match the label;
157
+ * `ERR_JWK_UNSUPPORTED` for an unknown `pemType`; `ERR_INVALID_OPTION` if `jwkParams` sets
158
+ * `alg`, `kty`, `key_ops`, `ext` or a key-material member.
159
+ */
160
+ export declare function importPEM<T extends JWK>(pem: string, alg: JWKPEMAlgorithm, options?: {
161
+ /** PEM type. Inferred from the PEM label when omitted. */
162
+ pemType?: "pkcs8" | "spki" | "x509";
163
+ /** Additional JWK properties merged into the exported key (e.g. `kid`). */
164
+ jwkParams?: JWKMetadata;
280
165
  }): Promise<T>;
281
166
  /**
282
- * Exports a JWK to a PEM-encoded string.
283
- *
284
- * The PEM format is inferred from the JWK shape:
285
- * - JWK with `d` (private component) → PKCS#8 (`-----BEGIN PRIVATE KEY-----`)
286
- * - JWK without `d` → SubjectPublicKeyInfo (`-----BEGIN PUBLIC KEY-----`)
287
- *
288
- * X.509 certificate export is intentionally not supported: a certificate carries metadata
289
- * (subject/issuer DNs, validity window, extensions) and a CA signature that a JWK cannot provide.
290
- * Producing a cert is a CA operation, not a key-format conversion.
291
- *
292
- * Symmetric `oct` JWKs cannot be exported to PEM — PKCS#8/SPKI are asymmetric-key formats.
293
- *
294
- * @param jwk The JWK to export. Must not be `kty: "oct"`.
295
- * @param options
296
- * - `pemFormat?` — force the output format. Inferred from the JWK shape when omitted.
297
- * - `alg?` — algorithm hint used only when `jwk.alg` is absent (both `kty: "RSA"` / `"EC"` /
298
- * `"OKP"` JWKs need an algorithm to be round-tripped through `crypto.subtle.importKey`).
299
- * @throws `JWTError("ERR_JWK_UNSUPPORTED")` for `oct` JWKs, or an unrecognised `pemFormat`.
300
- * @throws `JWTError("ERR_JWK_INVALID")` if the JWK requires an `alg` hint that was not supplied,
301
- * or if `pemFormat` is forced to a value incompatible with the JWK's public/private shape.
302
- *
303
- * @example
304
- * ```ts
305
- * // Inferred — private JWKs become PKCS#8, public JWKs become SPKI.
306
- * const pem = await exportPEM(jwk);
307
- *
308
- * // Override (will throw if incompatible with the JWK shape).
309
- * const spki = await exportPEM(jwk, { pemFormat: "spki" });
310
- *
311
- * // JWK without `alg` — provide a hint.
312
- * const pem2 = await exportPEM(rawJwk, { alg: "RS256" });
313
- * ```
314
- */
315
- declare function exportPEM(jwk: JWK, options?: {
316
- /** PEM format. Inferred from the JWK shape when omitted. */pemFormat?: "pkcs8" | "spki"; /** Algorithm hint used when `jwk.alg` is absent. */
167
+ * Exports an asymmetric JWK as PEM: PKCS#8 when it carries `d`, SPKI otherwise.
168
+ *
169
+ * @throws `ERR_JWK_UNSUPPORTED` for `oct` JWKs or an unknown format or algorithm;
170
+ * `ERR_JWK_INVALID` for a missing `alg` or a `pemFormat` that contradicts the JWK's half.
171
+ */
172
+ export declare function exportPEM(jwk: JWK, options?: {
173
+ /** PEM format. Inferred from the JWK shape when omitted. */
174
+ pemFormat?: "pkcs8" | "spki";
175
+ /** Algorithm hint used when `jwk.alg` is absent. */
317
176
  alg?: JWKPEMAlgorithm;
318
177
  }): Promise<string>;
319
178
  /**
320
- * @deprecated Use {@link exportPEM} instead. `pemFormat` has moved into the options object and
321
- * is now inferred from the JWK shape by default. The `algForCryptoKeyImport` parameter has
322
- * been renamed to `options.alg`.
323
- */
324
- declare function exportToPEM(jwk: JWK, pemFormat: "pkcs8" | "spki", algForCryptoKeyImport?: JWKPEMAlgorithm): Promise<string>;
325
- /**
326
- * Derives a shared secret using ECDH-ES key agreement (RFC 7518 §4.6).
327
- *
328
- * Performs an Elliptic Curve Diffie-Hellman Ephemeral-Static key derivation
329
- * followed by a Concat KDF (NIST SP 800-56A) to produce key material of the
330
- * requested length. The result can be used directly as a CEK (for `ECDH-ES`
331
- * direct key agreement) or as a KEK to wrap a separately generated CEK (for
332
- * `ECDH-ES+A*KW`).
333
- *
334
- * For multi-recipient JWE, call this once per recipient with their public key
335
- * and a fresh ephemeral private key, then wrap the shared CEK with the derived
336
- * material using {@link wrapKey}.
337
- *
338
- * @param publicKey The recipient's static public key (or the sender's
339
- * ephemeral public key on the decryption side).
340
- * @param privateKey The sender's ephemeral private key (or the recipient's
341
- * static private key on the decryption side).
342
- * @param alg The algorithm identifier used as the `AlgorithmID` in the
343
- * concat KDF info structure. Pass a {@link JWK_ECDH_ES} variant
344
- * (e.g. `"ECDH-ES+A128KW"`) or a {@link ContentEncryptionAlgorithm}
345
- * (e.g. `"A256GCM"`) for direct key agreement.
346
- * @param options Optional overrides for key length and party info.
347
- */
348
- declare function deriveSharedSecret(publicKey: CryptoKey | JWK_EC_Public, privateKey: CryptoKey | JWK_EC_Private, alg: JWK_ECDH_ES | ContentEncryptionAlgorithm, options?: {
349
- /** Override the derived key length in bits. Defaults to the standard length for `alg`. */keyLength?: number; /** Agreement PartyUInfo (apu). */
350
- partyUInfo?: Uint8Array<ArrayBuffer>; /** Agreement PartyVInfo (apv). */
179
+ * Derives ECDH-ES key material (RFC 7518 §4.6): ECDH followed by the Concat KDF.
180
+ *
181
+ * @param publicKey The recipient's static public key (the ephemeral one when decrypting).
182
+ * @param privateKey The ephemeral private key (the recipient's static one when decrypting).
183
+ */
184
+ export declare function deriveSharedSecret(publicKey: CryptoKey | JWK_EC_Public, privateKey: CryptoKey | JWK_EC_Private, options: {
185
+ /** Algorithm identifier fed to the concat KDF as `AlgorithmID`. */
186
+ enc: JWK_ECDH_ES | ContentEncryptionAlgorithm;
187
+ /** Derived length in bits. Defaults to `enc`'s length; required for `"ECDH-ES"`. */
188
+ keyLength?: number;
189
+ /** Agreement PartyUInfo (apu). */
190
+ partyUInfo?: Uint8Array<ArrayBuffer>;
191
+ /** Agreement PartyVInfo (apv). */
351
192
  partyVInfo?: Uint8Array<ArrayBuffer>;
352
193
  }): Promise<Uint8Array<ArrayBuffer>>;
353
194
  /**
354
- * @deprecated For set queries, use {@link getJWKsFromSet} which returns all
355
- * matching keys as an array. This function remains available for internal
356
- * single-key resolution by `kid` or JOSE header (used by `verify` and `decrypt`).
357
- *
358
- * Retrieves a JWK (JSON Web Key) from a JWKSet based on a key ID (kid) or
359
- * properties from a JOSE Header.
360
- *
361
- * @param jwkSet The JWKSet to search within.
362
- * @param kidOrProtectedHeader Either a string representing the 'kid' (Key ID)
363
- * or an object representing the JOSE Protected Header. If an object is
364
- * provided, it must contain a 'kid' property. It can optionally contain
365
- * 'alg' (Algorithm) and 'kty' (Key Type) to further refine the search.
366
- * @returns The matching JWK from the set.
367
- * @throws TypeError if `jwkSet` is invalid or `kidOrProtectedHeader` is not a
368
- * string or a valid header object.
369
- * @throws Error if no key is found matching the provided criteria, or if the
370
- * header object is missing the 'kid' property.
371
- */
372
- declare function getJWKFromSet(jwkSet: JWKSet, kidOrProtectedHeader: string | (JoseHeaderParameters & {
373
- alg?: string;
374
- kty?: string;
375
- })): JWK;
376
- /**
377
- * Returns all JWKs from a JWK Set, optionally narrowed by a predicate.
378
- *
379
- * Useful for multi-key verification retry, key rotation tooling, and
380
- * constructing multi-recipient JWE JSON Serialization structures.
381
- *
382
- * @param jwkSet The JWK Set to search.
383
- * @param filter Optional predicate `(jwk: JWK) => boolean`. Returns all keys when omitted.
384
- * @returns An array of matching JWKs.
385
- */
386
- declare function getJWKsFromSet(jwkSet: JWKSet, filter?: (jwk: JWK) => boolean): JWK[];
387
- export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveKeyOptions, type DeriveKeyReturn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type KeyManagementAlgorithm, type UnwrapKeyOptions, type UnwrappingKeyFor, WeakMapJWKCache, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, isJWTError, unwrapKey, wrapKey };
195
+ * Returns the JWKs of a JWK Set, dropping non-JWK entries, optionally narrowed by `filter`.
196
+ * An invalid set throws `ERR_JWK_INVALID`.
197
+ */
198
+ export declare function getJWKsFromSet(jwkSet: JWKSet, filter?: (jwk: JWK) => boolean): JWK[];
199
+ export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveKeyOptions, type DeriveKeyReturn, type ECDHEphemeralKeyInput, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type KeyManagementAlgorithm, type KnownJWTErrorCode, type ThumbprintHash, UnsecureError, type UnsecureErrorCode, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, isJWTError, isUnsecureError, thumbprint };
package/dist/core/jwk.mjs CHANGED
@@ -1,3 +1,4 @@
1
- import { JWTError, isJWTError } from "../_chunks/utils.mjs";
2
- import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, unwrapKey, wrapKey } from "../_chunks/jwk.mjs";
3
- export { JWTError, WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, isJWTError, unwrapKey, wrapKey };
1
+ import { UnsecureError } from "../_chunks/libs/unsecure.mjs";
2
+ import { JWTError, isJWTError, isUnsecureError } from "../_chunks/_jwt-internal.mjs";
3
+ import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, thumbprint, unwrapKey, wrapKey } from "../_chunks/jwk.mjs";
4
+ export { JWTError, UnsecureError, WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, isJWTError, isUnsecureError, thumbprint, unwrapKey, wrapKey };