unjwt 0.5.19 → 0.5.21

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.
@@ -1,167 +0,0 @@
1
- import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA, Q as JoseHeaderParameters, t as JWK, u as JWKSet, T as JWTClaimValidationOptions, R as JWTClaims, C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, O as JWKAlgorithm, P as JWKPEMAlgorithm, J as JWKParameters, E as JWK_AES_CBC_HMAC, F as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, N as JWK_Asymmetric_Algorithm, j as JWK_EC, I as JWK_ECDH_ES, i as JWK_EC_Private, h as JWK_EC_Public, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, L as JWK_OKP_SIGN, H as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, l as JWK_RSA_Private, k as JWK_RSA_Public, M as JWK_Symmetric_Algorithm, q as JWK_oct, S as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.Ca4-7Myr.mjs';
2
- import { E as ExpiresIn } from './unjwt.b323eNLO.mjs';
3
-
4
- type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
5
- /** JWS Signing Algorithm Identifier. */
6
- type JWSAlgorithm = JWK_HMAC | JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWS_SIGN_EXTRA;
7
- /** Recognized JWS Header Parameters, any other Header Members may also be present. */
8
- interface JWSHeaderParameters extends JoseHeaderParameters {
9
- /** JWS "alg" (Algorithm) Header Parameter */
10
- alg?: JWSAlgorithm;
11
- /**
12
- * This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
13
- * Input computation as per {@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}.
14
- * If `false`, the payload is used directly without Base64URL encoding.
15
- * Defaults to `true`.
16
- */
17
- b64?: boolean;
18
- }
19
- /** JWS Protected Header */
20
- interface JWSProtectedHeader extends JWSHeaderParameters {
21
- alg: JWSAlgorithm;
22
- }
23
- /**
24
- * JWS (JSON Web Signature) options for signing
25
- */
26
- interface JWSSignOptions {
27
- /** The JWS Algorithm to use. Must be provided. */
28
- alg?: JWSAlgorithm;
29
- /**
30
- * Additional protected header parameters. `alg` is automatically included.
31
- * `typ` defaults to "JWT" if not provided and payload is an object.
32
- */
33
- protectedHeader?: JWSHeaderParameters;
34
- /** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
35
- currentDate?: Date;
36
- /**
37
- * Time at which the JWS should expire, if no `exp` was already provided.
38
- */
39
- expiresIn?: ExpiresIn;
40
- }
41
- /** Result of JWS verification */
42
- interface JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
43
- /** The decoded and verified payload. */
44
- payload: T;
45
- /** The JWS Protected Header. */
46
- protectedHeader: JWSProtectedHeader;
47
- }
48
- /** Options for JWS verification */
49
- interface JWSVerifyOptions extends JWTClaimValidationOptions {
50
- /** List of allowed algorithms. If provided, the JWS `alg` must be in this list. */
51
- algorithms?: JWSAlgorithm[];
52
- /** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred. */
53
- forceUint8Array?: boolean;
54
- /** Unless false, will parse payload as JWT and validate claims if applicable (typ "JWT"). */
55
- validateJWT?: boolean;
56
- }
57
- /**
58
- * Key lookup function for JWS verification.
59
- * @param header The JWS Protected Header.
60
- * @param token The JWS token.
61
- * @returns The key material (CryptoKey, JWK, or raw Uint8Array) or a Promise resolving to it.
62
- */
63
- type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer>>;
64
-
65
- /**
66
- * Creates a JWS (JSON Web Signature) in Compact Serialization format.
67
- *
68
- * @param payload The payload to sign. Can be a string, Uint8Array, or an object (which will be JSON stringified).
69
- * @param key The signing key (CryptoKey, JWK, or raw symmetric key as Uint8Array).
70
- * @param options Signing options, including the algorithm (`alg`) and protected header parameters.
71
- * @returns A Promise resolving to the JWS Compact Serialization string.
72
- */
73
- declare function sign(payload: JWTClaims, key: JWK, options?: JWSSignOptions): Promise<string>;
74
- declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: JWK, options?: JWSSignOptions): Promise<string>;
75
- declare function sign(payload: JWTClaims, key: CryptoKey, options: JWSSignOptions & {
76
- alg: JWSAlgorithm;
77
- }): Promise<string>;
78
- declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: CryptoKey, options: JWSSignOptions & {
79
- alg: JWSAlgorithm;
80
- }): Promise<string>;
81
- declare function sign(payload: JWTClaims, key: Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
82
- alg: JWSAlgorithm;
83
- }): Promise<string>;
84
- declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
85
- alg: JWSAlgorithm;
86
- }): Promise<string>;
87
- declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: CryptoKey | JWK | Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
88
- alg: JWSAlgorithm;
89
- }): Promise<string>;
90
- /**
91
- * Verifies a JWS (JSON Web Signature) in Compact Serialization format.
92
- *
93
- * @param jws The JWS Compact Serialization string.
94
- * @param key The verification key (CryptoKey, JWK, JWKSet, raw symmetric key as Uint8Array, or a function resolving the key or set).
95
- * @param options Verification options, such as allowed algorithms.
96
- * @returns A Promise resolving to an object containing the verified payload and protected header.
97
- * @throws If the JWS is invalid, signature verification fails, or options are not met.
98
- */
99
- declare function verify<T extends JWTClaims | Uint8Array<ArrayBuffer> | string>(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer> | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
100
- declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer> | JWSKeyLookupFunction, options: JWSVerifyOptions & {
101
- forceUint8Array: true;
102
- }): Promise<JWSVerifyResult<Uint8Array<ArrayBuffer>>>;
103
-
104
- declare const jws_CompositeKey: typeof CompositeKey;
105
- declare const jws_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
106
- declare const jws_DeriveKeyOptions: typeof DeriveKeyOptions;
107
- declare const jws_DeriveKeyReturn: typeof DeriveKeyReturn;
108
- declare const jws_GenerateJWKOptions: typeof GenerateJWKOptions;
109
- declare const jws_GenerateJWKReturn: typeof GenerateJWKReturn;
110
- declare const jws_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
111
- declare const jws_GenerateKeyOptions: typeof GenerateKeyOptions;
112
- declare const jws_GenerateKeyReturn: typeof GenerateKeyReturn;
113
- declare const jws_JWK: typeof JWK;
114
- declare const jws_JWKAlgorithm: typeof JWKAlgorithm;
115
- declare const jws_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
116
- declare const jws_JWKParameters: typeof JWKParameters;
117
- declare const jws_JWKSet: typeof JWKSet;
118
- declare const jws_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
119
- declare const jws_JWK_AES_GCM: typeof JWK_AES_GCM;
120
- declare const jws_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
121
- declare const jws_JWK_AES_KW: typeof JWK_AES_KW;
122
- declare const jws_JWK_Asymmetric_Algorithm: typeof JWK_Asymmetric_Algorithm;
123
- declare const jws_JWK_EC: typeof JWK_EC;
124
- declare const jws_JWK_ECDH_ES: typeof JWK_ECDH_ES;
125
- declare const jws_JWK_ECDSA: typeof JWK_ECDSA;
126
- declare const jws_JWK_EC_Private: typeof JWK_EC_Private;
127
- declare const jws_JWK_EC_Public: typeof JWK_EC_Public;
128
- declare const jws_JWK_HMAC: typeof JWK_HMAC;
129
- declare const jws_JWK_OKP: typeof JWK_OKP;
130
- declare const jws_JWK_OKP_Private: typeof JWK_OKP_Private;
131
- declare const jws_JWK_OKP_Public: typeof JWK_OKP_Public;
132
- declare const jws_JWK_OKP_SIGN: typeof JWK_OKP_SIGN;
133
- declare const jws_JWK_PBES2: typeof JWK_PBES2;
134
- declare const jws_JWK_Private: typeof JWK_Private;
135
- declare const jws_JWK_Public: typeof JWK_Public;
136
- declare const jws_JWK_RSA: typeof JWK_RSA;
137
- declare const jws_JWK_RSA_ENC: typeof JWK_RSA_ENC;
138
- declare const jws_JWK_RSA_PSS: typeof JWK_RSA_PSS;
139
- declare const jws_JWK_RSA_Private: typeof JWK_RSA_Private;
140
- declare const jws_JWK_RSA_Public: typeof JWK_RSA_Public;
141
- declare const jws_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
142
- declare const jws_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
143
- declare const jws_JWK_oct: typeof JWK_oct;
144
- type jws_JWSAlgorithm = JWSAlgorithm;
145
- type jws_JWSHeaderParameters = JWSHeaderParameters;
146
- type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
147
- type jws_JWSProtectedHeader = JWSProtectedHeader;
148
- type jws_JWSSignOptions = JWSSignOptions;
149
- type jws_JWSVerifyOptions = JWSVerifyOptions;
150
- type jws_JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> = JWSVerifyResult<T>;
151
- declare const jws_JWT: typeof JWT;
152
- declare const jws_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
153
- declare const jws_JWTClaims: typeof JWTClaims;
154
- declare const jws_JoseHeaderParameters: typeof JoseHeaderParameters;
155
- declare const jws_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
156
- declare const jws_UnwrapKeyOptions: typeof UnwrapKeyOptions;
157
- declare const jws_WrapKeyOptions: typeof WrapKeyOptions;
158
- declare const jws_WrapKeyResult: typeof WrapKeyResult;
159
- declare const jws_sign: typeof sign;
160
- declare const jws_verify: typeof verify;
161
- declare namespace jws {
162
- export { jws_CompositeKey as CompositeKey, jws_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm, jws_DeriveKeyOptions as DeriveKeyOptions, jws_DeriveKeyReturn as DeriveKeyReturn, jws_GenerateJWKOptions as GenerateJWKOptions, jws_GenerateJWKReturn as GenerateJWKReturn, jws_GenerateKeyAlgorithm as GenerateKeyAlgorithm, jws_GenerateKeyOptions as GenerateKeyOptions, jws_GenerateKeyReturn as GenerateKeyReturn, jws_JWK as JWK, jws_JWKAlgorithm as JWKAlgorithm, jws_JWKPEMAlgorithm as JWKPEMAlgorithm, jws_JWKParameters as JWKParameters, jws_JWKSet as JWKSet, jws_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC, jws_JWK_AES_GCM as JWK_AES_GCM, jws_JWK_AES_GCM_KW as JWK_AES_GCM_KW, jws_JWK_AES_KW as JWK_AES_KW, jws_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm, jws_JWK_EC as JWK_EC, jws_JWK_ECDH_ES as JWK_ECDH_ES, jws_JWK_ECDSA as JWK_ECDSA, jws_JWK_EC_Private as JWK_EC_Private, jws_JWK_EC_Public as JWK_EC_Public, jws_JWK_HMAC as JWK_HMAC, jws_JWK_OKP as JWK_OKP, jws_JWK_OKP_Private as JWK_OKP_Private, jws_JWK_OKP_Public as JWK_OKP_Public, jws_JWK_OKP_SIGN as JWK_OKP_SIGN, jws_JWK_PBES2 as JWK_PBES2, jws_JWK_Private as JWK_Private, jws_JWK_Public as JWK_Public, jws_JWK_RSA as JWK_RSA, jws_JWK_RSA_ENC as JWK_RSA_ENC, jws_JWK_RSA_PSS as JWK_RSA_PSS, jws_JWK_RSA_Private as JWK_RSA_Private, jws_JWK_RSA_Public as JWK_RSA_Public, jws_JWK_RSA_SIGN as JWK_RSA_SIGN, jws_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm, jws_JWK_oct as JWK_oct, jws_JWT as JWT, jws_JWTClaimValidationOptions as JWTClaimValidationOptions, jws_JWTClaims as JWTClaims, jws_JoseHeaderParameters as JoseHeaderParameters, jws_KeyManagementAlgorithm as KeyManagementAlgorithm, jws_UnwrapKeyOptions as UnwrapKeyOptions, jws_WrapKeyOptions as WrapKeyOptions, jws_WrapKeyResult as WrapKeyResult, jws_sign as sign, jws_verify as verify };
163
- export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSKeyLookupFunction as JWSKeyLookupFunction, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
164
- }
165
-
166
- export { jws as j, sign as s, verify as v };
167
- export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e, JWSKeyLookupFunction as f };
@@ -1,3 +0,0 @@
1
- type ExpiresIn = number | `${number}` | `${number}${"s" | "second" | "seconds" | "m" | "minute" | "minutes" | "h" | "hour" | "hours" | "D" | "day" | "days" | "W" | "week" | "weeks" | "M" | "month" | "months" | "Y" | "year" | "years"}`;
2
-
3
- export type { ExpiresIn as E };