unjwt 0.7.2 → 0.8.0
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 +4 -4
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_chunks/_codec-jwe.d.mts +170 -0
- package/dist/_chunks/_codec-jws.mjs +878 -0
- package/dist/_chunks/_internal.d.mts +7 -0
- package/dist/_chunks/_jwt-internal.mjs +388 -0
- package/dist/_chunks/algorithms.mjs +186 -0
- package/dist/_chunks/index.d.mts +512 -818
- package/dist/_chunks/index2.d.mts +11 -0
- package/dist/_chunks/index3.d.mts +108 -0
- package/dist/_chunks/jwe.d.mts +43 -66
- package/dist/_chunks/jwe.mjs +384 -252
- package/dist/_chunks/jwk.mjs +1390 -622
- package/dist/_chunks/jws.d.mts +48 -103
- package/dist/_chunks/jws.mjs +372 -184
- package/dist/_chunks/jwt.d.mts +56 -0
- package/dist/_chunks/libs/unsecure.d.mts +164 -85
- package/dist/_chunks/libs/unsecure.mjs +390 -123
- package/dist/adapters/elysia/index.d.mts +33 -171
- package/dist/adapters/elysia/index.mjs +106 -575
- package/dist/adapters/h3v1/index.d.mts +59 -344
- package/dist/adapters/h3v1/index.mjs +114 -619
- package/dist/adapters/h3v2/index.d.mts +58 -326
- package/dist/adapters/h3v2/index.mjs +108 -611
- package/dist/core/internal.d.mts +2 -0
- package/dist/core/internal.mjs +1 -0
- package/dist/core/jwe.d.mts +4 -2
- package/dist/core/jwe.mjs +4 -2
- package/dist/core/jwk.d.mts +183 -371
- package/dist/core/jwk.mjs +4 -3
- package/dist/core/jws.d.mts +4 -2
- package/dist/core/jws.mjs +4 -2
- package/dist/core/utils/index.d.mts +5 -155
- package/dist/core/utils/index.mjs +12 -3
- package/dist/index.d.mts +8 -4
- package/dist/index.mjs +6 -3
- package/package.json +39 -36
- package/dist/_chunks/_internal.mjs +0 -88
- package/dist/_chunks/utils.mjs +0 -390
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JWK } from "./index.mjs";
|
|
2
|
+
/** Hash functions RFC 7638 §3.4 leaves open to the application. */
|
|
3
|
+
export type ThumbprintHash = "SHA-256" | "SHA-384" | "SHA-512";
|
|
4
|
+
/**
|
|
5
|
+
* The base64url JWK Thumbprint of a key (RFC 7638), over its required members only, so a
|
|
6
|
+
* public key and its private counterpart share one. `hash` defaults to `"SHA-256"`
|
|
7
|
+
* (RFC 7638 §3.4); a missing required member or unknown `kty` throws `ERR_JWK_INVALID`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function thumbprint(jwk: JWK, options?: {
|
|
10
|
+
hash?: ThumbprintHash;
|
|
11
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BytesSource, DecodeOptions, DecodeReturnAs } from "./libs/unsecure.mjs";
|
|
2
|
+
import { JWK, JWKSet, JWK_EC_Private, JWK_EC_Public, JWK_OKP_Private, JWK_OKP_Public, JWK_Private, JWK_Public, JWK_RSA_Private, JWK_RSA_Public, JWK_oct, JWSAlgorithm, KeyManagementAlgorithm } from "./index.mjs";
|
|
3
|
+
import { ComputeJwtTimeClaimsOptions as ComputeJwtTimeClaimsOptions$1, ParsePayloadOptions, applyTypDefault, assertCritShape as assertCritShape$1, computeJwtTimeClaims as computeJwtTimeClaims$1, getPlaintextBytes as getPlaintextBytes$1, parsePayloadBytes, parsePayloadSegment, validateCriticalHeadersJWE as validateCriticalHeadersJWE$1, validateCriticalHeadersJWS as validateCriticalHeadersJWS$1 } from "./jwt.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Encode bytes or a UTF-8 string as base64url the way JOSE defines it
|
|
6
|
+
* (RFC 7515 §2): URL-safe alphabet, no `=` padding, no line breaks.
|
|
7
|
+
*/
|
|
8
|
+
export declare function base64UrlStringify(data: string | BytesSource): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decode JOSE base64url (RFC 7515 §2). Strict: only the canonical, unpadded
|
|
11
|
+
* encoding of a byte string is accepted — `=`, whitespace, characters outside
|
|
12
|
+
* the URL-safe alphabet and set bits past the final byte are rejected, and a
|
|
13
|
+
* `string` result must be valid UTF-8. The return type mirrors the input unless
|
|
14
|
+
* `returnAs` is given. `{ loose: true }` drops what it cannot use instead of
|
|
15
|
+
* throwing: meant for application data, never for token material.
|
|
16
|
+
*
|
|
17
|
+
* @throws {UnsecureError} `MALFORMED` unless `loose`; `INVALID_TYPE` for input that is neither text nor bytes
|
|
18
|
+
*/
|
|
19
|
+
export declare function base64UrlParse<T extends DecodeReturnAs>(input: string | Uint8Array, options: DecodeOptions & {
|
|
20
|
+
returnAs: T;
|
|
21
|
+
}): T extends "string" ? string : Uint8Array<ArrayBuffer>;
|
|
22
|
+
export declare function base64UrlParse(input: string, options?: DecodeOptions): string;
|
|
23
|
+
export declare function base64UrlParse(input: Uint8Array, options?: DecodeOptions): Uint8Array<ArrayBuffer>;
|
|
24
|
+
/** Encode bytes or a UTF-8 string as standard base64 (RFC 4648 §4), with `=` padding. */
|
|
25
|
+
export declare function base64Stringify(data: string | BytesSource): string;
|
|
26
|
+
/**
|
|
27
|
+
* Decode standard base64 (RFC 4648 §4). Strict: the canonical encoding with its
|
|
28
|
+
* `=` padding present. Otherwise the same contract as {@link base64UrlParse}.
|
|
29
|
+
*
|
|
30
|
+
* @throws {UnsecureError} `MALFORMED` unless `loose`; `INVALID_TYPE` for input that is neither text nor bytes
|
|
31
|
+
*/
|
|
32
|
+
export declare function base64Parse<T extends DecodeReturnAs>(input: string | Uint8Array, options: DecodeOptions & {
|
|
33
|
+
returnAs: T;
|
|
34
|
+
}): T extends "string" ? string : Uint8Array<ArrayBuffer>;
|
|
35
|
+
export declare function base64Parse(input: string, options?: DecodeOptions): string;
|
|
36
|
+
export declare function base64Parse(input: Uint8Array, options?: DecodeOptions): Uint8Array<ArrayBuffer>;
|
|
37
|
+
/** @deprecated Renamed to {@link base64UrlStringify} in v0.8.0; removed in v0.9.0. */
|
|
38
|
+
export declare const base64UrlEncode: typeof base64UrlStringify;
|
|
39
|
+
/** @deprecated Renamed to {@link base64UrlParse} in v0.8.0; removed in v0.9.0. */
|
|
40
|
+
export declare const base64UrlDecode: typeof base64UrlParse;
|
|
41
|
+
/** @deprecated Renamed to {@link base64Stringify} in v0.8.0; removed in v0.9.0. */
|
|
42
|
+
export declare const base64Encode: typeof base64Stringify;
|
|
43
|
+
/** @deprecated Renamed to {@link base64Parse} in v0.8.0; removed in v0.9.0. */
|
|
44
|
+
export declare const base64Decode: typeof base64Parse;
|
|
45
|
+
/** Concatenate multiple `Uint8Array`s into a single contiguous buffer. */
|
|
46
|
+
export declare function concatUint8Arrays(...arrays: Readonly<Uint8Array<ArrayBuffer>[]>): Uint8Array<ArrayBuffer>;
|
|
47
|
+
/** Wrap a value in an array; returns the array unchanged if already an array. */
|
|
48
|
+
export declare function maybeArray<T>(item: T | T[]): T[];
|
|
49
|
+
/** Whether `key` is a JWK whose `kty` this library models (`oct`, `RSA`, `EC`, `OKP`). */
|
|
50
|
+
export declare function isJWK(key: unknown): key is JWK;
|
|
51
|
+
/** Whether `key` is an object with a `keys` array. */
|
|
52
|
+
export declare function isJWKSet(key: unknown): key is JWKSet;
|
|
53
|
+
/** Asserts that `key` is a `CryptoKey`; throws `ERR_JWK_INVALID` otherwise. */
|
|
54
|
+
export declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
|
|
55
|
+
/** Whether `key` is a `CryptoKey`, checked via `Symbol.toStringTag` to work across realms. */
|
|
56
|
+
export declare function isCryptoKey(key: unknown): key is CryptoKey;
|
|
57
|
+
/** Whether `key` is a `CryptoKeyPair` of two CryptoKeys. */
|
|
58
|
+
export declare const isCryptoKeyPair: (key: unknown) => key is CryptoKeyPair;
|
|
59
|
+
/** Whether the JWK is symmetric (`oct`); its `k` is always secret. */
|
|
60
|
+
export declare function isSymmetricJWK<T>(key: T): key is Extract<T, JWK_oct>;
|
|
61
|
+
export declare function isSymmetricJWK(key: unknown): key is JWK_oct;
|
|
62
|
+
/** Whether the JWK is asymmetric (RSA, EC, OKP). */
|
|
63
|
+
export declare function isAsymmetricJWK<T>(key: T): key is Exclude<T, JWK_oct>;
|
|
64
|
+
export declare function isAsymmetricJWK(key: unknown): key is Exclude<JWK, JWK_oct>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the JWK holds asymmetric private material (`d`). It is `false` for `oct` keys,
|
|
67
|
+
* so `!isPrivateJWK(key)` is not a "safe to publish" check; use `isPublicJWK`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isPrivateJWK<T>(key: T): key is Extract<T, JWK_EC_Private | JWK_OKP_Private | JWK_RSA_Private>;
|
|
70
|
+
export declare function isPrivateJWK(key: unknown): key is JWK_Private;
|
|
71
|
+
/** Whether the JWK is an asymmetric public key without `d`: the "safe to publish" check. */
|
|
72
|
+
export declare function isPublicJWK<T>(key: T): key is Exclude<Extract<T, JWK_EC_Public | JWK_OKP_Public | JWK_RSA_Public>, JWK_Private>;
|
|
73
|
+
export declare function isPublicJWK(key: unknown): key is JWK_Public;
|
|
74
|
+
/** How a JWK Set's entries are read during algorithm inference. */
|
|
75
|
+
export interface InferAlgorithmsOptions {
|
|
76
|
+
/** Admit `oct` entries of a JWK Set. Defaults to `false`. */
|
|
77
|
+
allowSymmetric?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Infer the JWS algorithms a key unambiguously supports, or `undefined` when it cannot
|
|
81
|
+
* (raw bytes, ambiguous JWK, lookup function) and `options.algorithms` must be passed.
|
|
82
|
+
*/
|
|
83
|
+
export declare function inferJWSAllowedAlgorithms(key: unknown, options?: InferAlgorithmsOptions): JWSAlgorithm[] | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Infer the JWE key management algorithms a key unambiguously supports, or `undefined`
|
|
86
|
+
* when it cannot; a password string infers the PBES2 variants, raw bytes nothing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function inferJWEAllowedAlgorithms(key: unknown, options?: InferAlgorithmsOptions): KeyManagementAlgorithm[] | undefined;
|
|
89
|
+
/** @deprecated Use `ParsePayloadOptions` from `unjwt/internal`; removed in v0.9.0. */
|
|
90
|
+
export type DecodePayloadOptions = ParsePayloadOptions;
|
|
91
|
+
/** @deprecated Use `ComputeJwtTimeClaimsOptions` from `unjwt/internal`; removed in v0.9.0. */
|
|
92
|
+
export type ComputeJwtTimeClaimsOptions = ComputeJwtTimeClaimsOptions$1;
|
|
93
|
+
/** @deprecated Use `applyTypDefault` from `unjwt/internal`; removed in v0.9.0. */
|
|
94
|
+
export declare const applyTypCtyDefaults: typeof applyTypDefault;
|
|
95
|
+
/** @deprecated Use `parsePayloadBytes` from `unjwt/internal`; removed in v0.9.0. */
|
|
96
|
+
export declare const decodePayloadFromBytes: typeof parsePayloadBytes;
|
|
97
|
+
/** @deprecated Use `parsePayloadSegment` from `unjwt/internal`; removed in v0.9.0. */
|
|
98
|
+
export declare const decodePayloadFromB64UrlSegment: typeof parsePayloadSegment;
|
|
99
|
+
/** @deprecated Use `getPlaintextBytes` from `unjwt/internal`; removed in v0.9.0. */
|
|
100
|
+
export declare const getPlaintextBytes: typeof getPlaintextBytes$1;
|
|
101
|
+
/** @deprecated Use `computeJwtTimeClaims` from `unjwt/internal`; removed in v0.9.0. */
|
|
102
|
+
export declare const computeJwtTimeClaims: typeof computeJwtTimeClaims$1;
|
|
103
|
+
/** @deprecated Use `validateCriticalHeadersJWS` from `unjwt/internal`; removed in v0.9.0. */
|
|
104
|
+
export declare const validateCriticalHeadersJWS: typeof validateCriticalHeadersJWS$1;
|
|
105
|
+
/** @deprecated Use `validateCriticalHeadersJWE` from `unjwt/internal`; removed in v0.9.0. */
|
|
106
|
+
export declare const validateCriticalHeadersJWE: typeof validateCriticalHeadersJWE$1;
|
|
107
|
+
/** @deprecated Use `assertCritShape` from `unjwt/internal`; removed in v0.9.0. */
|
|
108
|
+
export declare const assertCritShape: typeof assertCritShape$1;
|
package/dist/_chunks/jwe.d.mts
CHANGED
|
@@ -1,84 +1,61 @@
|
|
|
1
|
-
import { ContentEncryptionAlgorithm, JOSEPayload, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralSerialization, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWKLookupFunction, JWKSet, KeyManagementAlgorithm } from "./index.mjs";
|
|
1
|
+
import { ContentEncryptionAlgorithm, JOSEPayload, JOSEPayloadMode, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralSerialization, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWKLookupFunction, JWKSet, JWTClaims, KeyManagementAlgorithm, PayloadOf } from "./index.mjs";
|
|
2
|
+
import "./_internal.mjs";
|
|
2
3
|
/**
|
|
3
|
-
* Encrypt a payload to multiple recipients
|
|
4
|
-
* (
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Per-recipient `alg` is read from `key.alg` and throws `ERR_JWE_RECIPIENT_ALG_INFERENCE`
|
|
9
|
-
* when absent.
|
|
10
|
-
*
|
|
11
|
-
* Throws `ERR_JWE_ALG_FORBIDDEN_IN_MULTI` when any recipient resolves to `dir`
|
|
12
|
-
* or bare `ECDH-ES` — those algorithms require exactly one recipient; use
|
|
13
|
-
* {@link encrypt} instead.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const jwe = await encryptMulti({ sub: "u1" }, [
|
|
17
|
-
* { key: aliceRsaPublicJwk },
|
|
18
|
-
* { key: bobEcdhPublicJwk },
|
|
19
|
-
* ], { enc: "A256GCM", expiresIn: "1h" });
|
|
20
|
-
*/
|
|
21
|
-
declare function encryptMulti(payload: JOSEPayload, recipients: JWEMultiRecipient[], options?: JWEMultiEncryptOptions): Promise<JWEGeneralSerialization>;
|
|
4
|
+
* Encrypt a payload to multiple recipients as JWE General JSON Serialization (RFC 7516 §7.2.1).
|
|
5
|
+
* Each recipient's `alg` comes from `key.alg` (`ERR_JWE_RECIPIENT_ALG_INFERENCE` when absent);
|
|
6
|
+
* `dir` and bare `ECDH-ES` throw `ERR_JWE_ALG_FORBIDDEN_IN_MULTI`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function encryptMulti(payload: JOSEPayload, recipients: JWEMultiRecipient[], options?: JWEMultiEncryptOptions): Promise<JWEGeneralSerialization>;
|
|
22
9
|
/**
|
|
23
|
-
* Decrypt a JWE
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
* Decrypt a JWE General (RFC 7516 §7.2.1) or Flattened (§7.2.2) JSON Serialization.
|
|
11
|
+
* Recipients are tried in order; per-recipient failures surface only when none unwraps.
|
|
12
|
+
* `strictRecipientMatch` skips recipients the key cannot open and throws
|
|
13
|
+
* `ERR_JWE_NO_MATCHING_RECIPIENT` when none qualifies; a JWK Set with no `kid` candidate
|
|
14
|
+
* throws `ERR_JWK_KEY_NOT_FOUND`. The payload type follows `options.payload`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function decryptMulti<T extends Record<string, unknown> = JWTClaims>(jwe: JWEGeneralSerialization | JWEFlattenedSerialization, keyOrLookup: JWEMultiDecryptKey, options?: JWEMultiDecryptOptions<"json"> & {
|
|
17
|
+
forceUint8Array?: false;
|
|
18
|
+
}): Promise<JWEMultiDecryptResult<T>>;
|
|
19
|
+
/** @deprecated `forceUint8Array` is replaced by `payload: "bytes"`; removed in v0.9.0. */
|
|
20
|
+
export declare function decryptMulti(jwe: JWEGeneralSerialization | JWEFlattenedSerialization, keyOrLookup: JWEMultiDecryptKey, options: JWEMultiDecryptOptions & {
|
|
21
|
+
forceUint8Array: true;
|
|
22
|
+
}): Promise<JWEMultiDecryptResult<Uint8Array<ArrayBuffer>>>;
|
|
23
|
+
/** Decrypts a JWE JSON Serialization whose plaintext decodes under `options.payload`; see {@link PayloadOf}. */
|
|
24
|
+
export declare function decryptMulti<Mode extends JOSEPayloadMode = JOSEPayloadMode>(jwe: JWEGeneralSerialization | JWEFlattenedSerialization, keyOrLookup: JWEMultiDecryptKey, options?: JWEMultiDecryptOptions<Mode>): Promise<JWEMultiDecryptResult<PayloadOf<Mode>>>;
|
|
33
25
|
/**
|
|
34
|
-
* Convert a
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* `encryptMulti` never emits Flattened itself (stable return shape across
|
|
40
|
-
* recipient counts); this is the canonical post-processing step when
|
|
41
|
-
* interoperating with a strict Flattened-only consumer.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* const general = await encryptMulti(payload, [recipient], opts);
|
|
45
|
-
* const flattened = generalToFlattened(general);
|
|
46
|
-
*/
|
|
47
|
-
declare function generalToFlattened(jwe: JWEGeneralSerialization): JWEFlattenedSerialization;
|
|
26
|
+
* Convert a single-recipient General JWE to the Flattened form (RFC 7516 §7.2.2).
|
|
27
|
+
* Throws `ERR_JWE_INVALID_SERIALIZATION` for zero or multiple recipients.
|
|
28
|
+
*/
|
|
29
|
+
export declare function generalToFlattened(jwe: JWEGeneralSerialization): JWEFlattenedSerialization;
|
|
48
30
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @returns A Promise resolving to the JWE Compact Serialization string.
|
|
55
|
-
*/
|
|
56
|
-
declare function encrypt(payload: JOSEPayload, key: JWEEncryptJWK | string | Uint8Array<ArrayBuffer>, options?: JWEEncryptOptions): Promise<string>;
|
|
57
|
-
declare function encrypt(payload: JOSEPayload, key: CryptoKey | Extract<JWEEncryptJWK, {
|
|
31
|
+
* Encrypt a payload into a JWE Compact Serialization string. `key` is a CryptoKey, a JWK, or
|
|
32
|
+
* a PBES2 password; `alg` is inferred from it when omitted and `enc` defaults to `A256GCM`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function encrypt(payload: JOSEPayload, key: JWEEncryptJWK | string | Uint8Array<ArrayBuffer>, options?: JWEEncryptOptions): Promise<string>;
|
|
35
|
+
export declare function encrypt(payload: JOSEPayload, key: CryptoKey | Extract<JWEEncryptJWK, {
|
|
58
36
|
kty: "oct";
|
|
59
37
|
}> | Uint8Array<ArrayBuffer>, options: JWEEncryptOptions & {
|
|
60
38
|
alg: "dir";
|
|
61
39
|
enc: ContentEncryptionAlgorithm;
|
|
62
40
|
}): Promise<string>;
|
|
63
|
-
declare function encrypt(payload: JOSEPayload, key: CryptoKey, options: JWEEncryptOptions & {
|
|
41
|
+
export declare function encrypt(payload: JOSEPayload, key: CryptoKey, options: JWEEncryptOptions & {
|
|
64
42
|
alg: KeyManagementAlgorithm;
|
|
65
43
|
enc: ContentEncryptionAlgorithm;
|
|
66
44
|
}): Promise<string>;
|
|
67
|
-
declare function encrypt(payload: JOSEPayload, key: CryptoKey | JWEEncryptJWK | string | Uint8Array<ArrayBuffer>, options: JWEEncryptOptions & {
|
|
45
|
+
export declare function encrypt(payload: JOSEPayload, key: CryptoKey | JWEEncryptJWK | string | Uint8Array<ArrayBuffer>, options: JWEEncryptOptions & {
|
|
68
46
|
alg: KeyManagementAlgorithm;
|
|
69
47
|
enc: ContentEncryptionAlgorithm;
|
|
70
48
|
}): Promise<string>;
|
|
71
49
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
declare function decrypt<T extends JOSEPayload>(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options?: JWEDecryptOptions): Promise<JWEDecryptResult<T>>;
|
|
81
|
-
declare function decrypt(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options: JWEDecryptOptions & {
|
|
50
|
+
* Decrypt a JWE Compact Serialization string; `key` may be a lookup function.
|
|
51
|
+
* The payload type follows `options.payload` (claims `T` by default).
|
|
52
|
+
*/
|
|
53
|
+
export declare function decrypt<T extends Record<string, unknown> = JWTClaims>(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options?: JWEDecryptOptions<"json"> & {
|
|
54
|
+
forceUint8Array?: false;
|
|
55
|
+
}): Promise<JWEDecryptResult<T>>;
|
|
56
|
+
/** @deprecated `forceUint8Array` is replaced by `payload: "bytes"`; removed in v0.9.0. */
|
|
57
|
+
export declare function decrypt(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options: JWEDecryptOptions & {
|
|
82
58
|
forceUint8Array: true;
|
|
83
59
|
}): Promise<JWEDecryptResult<Uint8Array<ArrayBuffer>>>;
|
|
84
|
-
|
|
60
|
+
/** Decrypts a compact JWE whose plaintext decodes under `options.payload`; see {@link PayloadOf}. */
|
|
61
|
+
export declare function decrypt<Mode extends JOSEPayloadMode = JOSEPayloadMode>(jwe: string, key: CryptoKey | JWKSet | JWEDecryptJWK | string | Uint8Array<ArrayBuffer> | JWKLookupFunction, options?: JWEDecryptOptions<Mode>): Promise<JWEDecryptResult<PayloadOf<Mode>>>;
|