unjwt 0.5.20 → 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.
- package/README.md +55 -0
- package/dist/h3.d.mts +185 -0
- package/dist/h3.mjs +460 -0
- package/dist/index.d.mts +7 -5
- package/dist/index.mjs +4 -4
- package/dist/jwe.d.mts +3 -2
- package/dist/jwe.mjs +3 -3
- package/dist/jwk.d.mts +2 -2
- package/dist/jwk.mjs +2 -2
- package/dist/jws.d.mts +3 -2
- package/dist/jws.mjs +3 -3
- package/dist/shared/unjwt.9mL1vSFP.d.mts +154 -0
- package/dist/shared/{unjwt.ChCsF4q6.d.mts → unjwt.BjP_dGnX.d.mts} +6 -2
- package/dist/shared/{unjwt.BuQdWrN5.d.mts → unjwt.BrNGm4On.d.mts} +1 -1
- package/dist/shared/unjwt.BsLgL0DQ.d.mts +64 -0
- package/dist/shared/unjwt.C5jNR_1K.d.mts +166 -0
- package/dist/shared/{unjwt.CaZJRuRa.mjs → unjwt.CXl9FD-V.mjs} +2 -2
- package/dist/shared/{unjwt.Dy68jE0N.d.mts → unjwt.CtHrClHc.d.mts} +5 -1
- package/dist/shared/{unjwt.K_6rgVTy.mjs → unjwt.DCiTNyCM.mjs} +1 -1
- package/dist/shared/{unjwt.Dc_YDjvO.mjs → unjwt.DmRAjMp8.mjs} +3 -5
- package/dist/shared/unjwt.VUfJDcCJ.d.mts +161 -0
- package/dist/shared/{unjwt.D7ya3PwS.mjs → unjwt.Vg02PZWw.mjs} +10 -21
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +19 -1
- package/dist/shared/unjwt.BFtNZVqt.d.mts +0 -252
- package/dist/shared/unjwt.DANsaNYC.d.mts +0 -166
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, E as ExpiresIn, V as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, v as JWK, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.CtHrClHc.mjs';
|
|
2
|
+
|
|
3
|
+
/** Recognized JWE Header Parameters, any other Header Members may also be present. */
|
|
4
|
+
interface JWEHeaderParameters extends JoseHeaderParameters {
|
|
5
|
+
/**
|
|
6
|
+
* `alg` (Algorithm): Header Parameter - Key Management Algorithm
|
|
7
|
+
*/
|
|
8
|
+
alg?: string;
|
|
9
|
+
/**
|
|
10
|
+
* `enc` (Encryption Algorithm): Header Parameter - Content Encryption Algorithm
|
|
11
|
+
*/
|
|
12
|
+
enc?: string;
|
|
13
|
+
/**
|
|
14
|
+
* `p2c` (PBES2 Count): Header Parameter
|
|
15
|
+
*/
|
|
16
|
+
p2c?: number;
|
|
17
|
+
/**
|
|
18
|
+
* `p2s` (PBES2 Salt): Header Parameter. Base64URL encoded.
|
|
19
|
+
*/
|
|
20
|
+
p2s?: string;
|
|
21
|
+
/**
|
|
22
|
+
* "iv" (Initialization Vector) Header Parameter for AES GCM Key Wrapping. Base64URL encoded.
|
|
23
|
+
*/
|
|
24
|
+
iv?: string;
|
|
25
|
+
/**
|
|
26
|
+
* "tag" (Authentication Tag) Header Parameter for AES GCM Key Wrapping. Base64URL encoded.
|
|
27
|
+
*/
|
|
28
|
+
tag?: string;
|
|
29
|
+
/**
|
|
30
|
+
* "epk" (Ephemeral Public Key) Header Parameter for ECDH-ES.
|
|
31
|
+
*/
|
|
32
|
+
epk?: JWK_EC_Public;
|
|
33
|
+
/**
|
|
34
|
+
* "apu" (Agreement PartyUInfo) Header Parameter for ECDH-ES. Base64URL encoded.
|
|
35
|
+
*/
|
|
36
|
+
apu?: string;
|
|
37
|
+
/**
|
|
38
|
+
* "apv" (Agreement PartyVInfo) Header Parameter for ECDH-ES. Base64URL encoded.
|
|
39
|
+
*/
|
|
40
|
+
apv?: string;
|
|
41
|
+
/** Any other JWE Header member. */
|
|
42
|
+
[propName: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
/** Recognized JWE Key Management-related Header Parameters. */
|
|
45
|
+
interface JWEKeyManagementHeaderParameters {
|
|
46
|
+
apu?: Uint8Array<ArrayBuffer>;
|
|
47
|
+
apv?: Uint8Array<ArrayBuffer>;
|
|
48
|
+
/**
|
|
49
|
+
* For Internal use only
|
|
50
|
+
*/
|
|
51
|
+
p2c?: number;
|
|
52
|
+
/**
|
|
53
|
+
* For Internal use only
|
|
54
|
+
*/
|
|
55
|
+
p2s?: Uint8Array<ArrayBuffer>;
|
|
56
|
+
/**
|
|
57
|
+
* For Internal use only
|
|
58
|
+
*/
|
|
59
|
+
iv?: Uint8Array<ArrayBuffer>;
|
|
60
|
+
/**
|
|
61
|
+
* For Internal use only
|
|
62
|
+
*/
|
|
63
|
+
epk?: CryptoKey | JWK_EC_Public;
|
|
64
|
+
/**
|
|
65
|
+
* For Internal use only
|
|
66
|
+
*/
|
|
67
|
+
epkPrivateKey?: CryptoKey | JWK_EC_Private;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* JWE (JSON Web Encryption) encryption options
|
|
71
|
+
*/
|
|
72
|
+
interface JWEEncryptOptions {
|
|
73
|
+
/** JWE "alg" (Algorithm) Header Parameter. Key Management Algorithm. */
|
|
74
|
+
alg?: KeyManagementAlgorithm;
|
|
75
|
+
/** JWE "enc" (Encryption Algorithm) Header Parameter. Content Encryption Algorithm. */
|
|
76
|
+
enc?: ContentEncryptionAlgorithm;
|
|
77
|
+
/** Date to use when computing NumericDate claims, defaults to `new Date()`. */
|
|
78
|
+
currentDate?: Date;
|
|
79
|
+
/** Time at which the JWT should expire, if no `exp` was already provided (only when typ is "JWT" or explicitly parsing JWT). */
|
|
80
|
+
expiresIn?: ExpiresIn;
|
|
81
|
+
/** Additional JWE Protected Header parameters. */
|
|
82
|
+
protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "epk" | "apu" | "apv">;
|
|
83
|
+
/** Initialization Vector for AES-GCMKW key wrapping. Generated if not provided. */
|
|
84
|
+
keyManagementIV?: Uint8Array<ArrayBuffer>;
|
|
85
|
+
/** PBES2 Salt value (p2s). Required for PBES2 algorithms. */
|
|
86
|
+
p2s?: Uint8Array<ArrayBuffer>;
|
|
87
|
+
/** PBES2 Iteration count (p2c). Required for PBES2 algorithms. */
|
|
88
|
+
p2c?: number;
|
|
89
|
+
/** ECDH-ES specific options. */
|
|
90
|
+
ecdh?: {
|
|
91
|
+
/**
|
|
92
|
+
* ECDH-ES Ephemeral key material. Provide a private key (CryptoKey or JWK),
|
|
93
|
+
* a CryptoKeyPair, or an object exposing both public and private parts.
|
|
94
|
+
*/
|
|
95
|
+
ephemeralKey?: CryptoKey | JWK_EC_Private | CryptoKeyPair | {
|
|
96
|
+
publicKey: CryptoKey | JWK_EC_Public;
|
|
97
|
+
privateKey: CryptoKey | JWK_EC_Private;
|
|
98
|
+
};
|
|
99
|
+
/** ECDH-ES Agreement PartyUInfo. */
|
|
100
|
+
partyUInfo?: Uint8Array<ArrayBuffer>;
|
|
101
|
+
/** ECDH-ES Agreement PartyVInfo. */
|
|
102
|
+
partyVInfo?: Uint8Array<ArrayBuffer>;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Content Encryption Key (CEK) to use.
|
|
106
|
+
* If provided, it will be used directly. Otherwise, a CEK will be generated.
|
|
107
|
+
*/
|
|
108
|
+
cek?: Uint8Array<ArrayBuffer>;
|
|
109
|
+
/**
|
|
110
|
+
* Initialization Vector for content encryption.
|
|
111
|
+
* If provided, it will be used. Otherwise, one will be generated.
|
|
112
|
+
*/
|
|
113
|
+
contentEncryptionIV?: Uint8Array<ArrayBuffer>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Key lookup function for JWE decryption.
|
|
117
|
+
* @param header The JWE Protected Header.
|
|
118
|
+
* @returns The key material (CryptoKey, JWK, password string, or raw Uint8Array) or a Promise resolving to it.
|
|
119
|
+
*/
|
|
120
|
+
type JWEKeyLookupFunction = (header: JWEHeaderParameters, token: string) => CryptoKey | JWK | string | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | string | Uint8Array<ArrayBuffer>>;
|
|
121
|
+
/**
|
|
122
|
+
* JWE (JSON Web Encryption) decryption options
|
|
123
|
+
*/
|
|
124
|
+
interface JWEDecryptOptions extends JWTClaimValidationOptions {
|
|
125
|
+
/** A list of allowed JWE "alg" (Algorithm) Header Parameter values for key management. */
|
|
126
|
+
algorithms?: KeyManagementAlgorithm[];
|
|
127
|
+
/** A list of allowed JWE "enc" (Encryption Algorithm) Header Parameter values for content encryption. */
|
|
128
|
+
encryptionAlgorithms?: ContentEncryptionAlgorithm[];
|
|
129
|
+
/** Algorithm to import the unwrapped CEK as (e.g., { name: 'AES-GCM' }). Defaults based on 'enc'. */
|
|
130
|
+
unwrappedKeyAlgorithm?: Parameters<typeof crypto.subtle.importKey>[2];
|
|
131
|
+
/** Key usages for the unwrapped CEK. Defaults based on 'enc' (typically ['encrypt', 'decrypt']). */
|
|
132
|
+
keyUsage?: KeyUsage[];
|
|
133
|
+
/** Mark the unwrapped CEK as extractable. Defaults to true. */
|
|
134
|
+
extractable?: boolean;
|
|
135
|
+
/** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred based on JWE headers. */
|
|
136
|
+
forceUint8Array?: boolean;
|
|
137
|
+
/** Unless false, will parse payload as JWT and validate claims if applicable (typ "JWT"). */
|
|
138
|
+
validateJWT?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Result of a JWE decryption operation.
|
|
142
|
+
*/
|
|
143
|
+
interface JWEDecryptResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
|
|
144
|
+
/** The decrypted payload. */
|
|
145
|
+
payload: T;
|
|
146
|
+
/** The JWE Protected Header. */
|
|
147
|
+
protectedHeader: JWEHeaderParameters;
|
|
148
|
+
/** The Content Encryption Key (CEK) used for decryption, as Uint8Array. */
|
|
149
|
+
cek: Uint8Array<ArrayBuffer>;
|
|
150
|
+
/** The Additional Authenticated Data (AAD) used, as Uint8Array. */
|
|
151
|
+
aad: Uint8Array<ArrayBuffer>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export type { JWEHeaderParameters as J, JWEKeyManagementHeaderParameters as a, JWEEncryptOptions as b, JWEKeyLookupFunction as c, JWEDecryptOptions as d, JWEDecryptResult as e };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn,
|
|
1
|
+
import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, J as JWKParameters, c as GenerateJWKOptions, d as GenerateJWKReturn, N as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, v as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, T as JWKPEMAlgorithm, w as JWKSet, V as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, S as JWKAlgorithm, I as JWK_AES_CBC_HMAC, L as JWK_AES_GCM, H as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, u as JWK_Private, t as JWK_Public, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, r as JWK_Symmetric, Q as JWK_Symmetric_Algorithm, Y as JWT, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.CtHrClHc.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -157,6 +157,7 @@ declare const jwk_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
|
|
|
157
157
|
declare const jwk_JWK_AES_GCM: typeof JWK_AES_GCM;
|
|
158
158
|
declare const jwk_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
|
|
159
159
|
declare const jwk_JWK_AES_KW: typeof JWK_AES_KW;
|
|
160
|
+
declare const jwk_JWK_Asymmetric: typeof JWK_Asymmetric;
|
|
160
161
|
declare const jwk_JWK_Asymmetric_Algorithm: typeof JWK_Asymmetric_Algorithm;
|
|
161
162
|
declare const jwk_JWK_EC: typeof JWK_EC;
|
|
162
163
|
declare const jwk_JWK_ECDH_ES: typeof JWK_ECDH_ES;
|
|
@@ -177,6 +178,7 @@ declare const jwk_JWK_RSA_PSS: typeof JWK_RSA_PSS;
|
|
|
177
178
|
declare const jwk_JWK_RSA_Private: typeof JWK_RSA_Private;
|
|
178
179
|
declare const jwk_JWK_RSA_Public: typeof JWK_RSA_Public;
|
|
179
180
|
declare const jwk_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
|
|
181
|
+
declare const jwk_JWK_Symmetric: typeof JWK_Symmetric;
|
|
180
182
|
declare const jwk_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
|
|
181
183
|
declare const jwk_JWK_oct: typeof JWK_oct;
|
|
182
184
|
declare const jwk_JWT: typeof JWT;
|
|
@@ -218,6 +220,7 @@ declare namespace jwk {
|
|
|
218
220
|
jwk_JWK_AES_GCM as JWK_AES_GCM,
|
|
219
221
|
jwk_JWK_AES_GCM_KW as JWK_AES_GCM_KW,
|
|
220
222
|
jwk_JWK_AES_KW as JWK_AES_KW,
|
|
223
|
+
jwk_JWK_Asymmetric as JWK_Asymmetric,
|
|
221
224
|
jwk_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm,
|
|
222
225
|
jwk_JWK_EC as JWK_EC,
|
|
223
226
|
jwk_JWK_ECDH_ES as JWK_ECDH_ES,
|
|
@@ -238,6 +241,7 @@ declare namespace jwk {
|
|
|
238
241
|
jwk_JWK_RSA_Private as JWK_RSA_Private,
|
|
239
242
|
jwk_JWK_RSA_Public as JWK_RSA_Public,
|
|
240
243
|
jwk_JWK_RSA_SIGN as JWK_RSA_SIGN,
|
|
244
|
+
jwk_JWK_Symmetric as JWK_Symmetric,
|
|
241
245
|
jwk_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm,
|
|
242
246
|
jwk_JWK_oct as JWK_oct,
|
|
243
247
|
jwk_JWT as JWT,
|
|
@@ -262,4 +266,4 @@ declare namespace jwk {
|
|
|
262
266
|
};
|
|
263
267
|
}
|
|
264
268
|
|
|
265
|
-
export {
|
|
269
|
+
export { generateKey as a, deriveKeyFromPassword as b, importKey as c, deriveJWKFromPassword as d, exportJWKToPEM as e, exportKey as f, generateJWK as g, getJWKFromSet as h, importJWKFromPEM as i, jwk as j, unwrapKey as u, wrapKey as w };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as ExpiresIn,
|
|
1
|
+
import { E as ExpiresIn, X as JWTClaims, Z as JWTClaimValidationOptions, v as JWK, w as JWKSet, q as JWK_oct, u as JWK_Private, t as JWK_Public } from './unjwt.CtHrClHc.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Apply default typ/cty semantics shared by JWS & JWE.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { x as JWK_HMAC, y as JWK_RSA_SIGN, z as JWK_RSA_PSS, A as JWK_ECDSA, V as JoseHeaderParameters, E as ExpiresIn, v as JWK, w as JWKSet, Z as JWTClaimValidationOptions, X as JWTClaims } from './unjwt.CtHrClHc.mjs';
|
|
2
|
+
|
|
3
|
+
type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
|
|
4
|
+
/** JWS Signing Algorithm Identifier. */
|
|
5
|
+
type JWSAlgorithm = JWK_HMAC | JWK_RSA_SIGN | JWK_RSA_PSS | JWK_ECDSA | JWS_SIGN_EXTRA;
|
|
6
|
+
/** Recognized JWS Header Parameters, any other Header Members may also be present. */
|
|
7
|
+
interface JWSHeaderParameters extends JoseHeaderParameters {
|
|
8
|
+
/** JWS "alg" (Algorithm) Header Parameter */
|
|
9
|
+
alg?: JWSAlgorithm;
|
|
10
|
+
/**
|
|
11
|
+
* This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
|
|
12
|
+
* Input computation as per {@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}.
|
|
13
|
+
* If `false`, the payload is used directly without Base64URL encoding.
|
|
14
|
+
* Defaults to `true`.
|
|
15
|
+
*/
|
|
16
|
+
b64?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** JWS Protected Header */
|
|
19
|
+
interface JWSProtectedHeader extends JWSHeaderParameters {
|
|
20
|
+
alg: JWSAlgorithm;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* JWS (JSON Web Signature) options for signing
|
|
24
|
+
*/
|
|
25
|
+
interface JWSSignOptions {
|
|
26
|
+
/** The JWS Algorithm to use. Must be provided. */
|
|
27
|
+
alg?: JWSAlgorithm;
|
|
28
|
+
/**
|
|
29
|
+
* Additional protected header parameters. `alg` is automatically included.
|
|
30
|
+
* `typ` defaults to "JWT" if not provided and payload is an object.
|
|
31
|
+
*/
|
|
32
|
+
protectedHeader?: JWSHeaderParameters;
|
|
33
|
+
/** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
|
|
34
|
+
currentDate?: Date;
|
|
35
|
+
/**
|
|
36
|
+
* Time at which the JWS should expire, if no `exp` was already provided.
|
|
37
|
+
*/
|
|
38
|
+
expiresIn?: ExpiresIn;
|
|
39
|
+
}
|
|
40
|
+
/** Result of JWS verification */
|
|
41
|
+
interface JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
|
|
42
|
+
/** The decoded and verified payload. */
|
|
43
|
+
payload: T;
|
|
44
|
+
/** The JWS Protected Header. */
|
|
45
|
+
protectedHeader: JWSProtectedHeader;
|
|
46
|
+
}
|
|
47
|
+
/** Options for JWS verification */
|
|
48
|
+
interface JWSVerifyOptions extends JWTClaimValidationOptions {
|
|
49
|
+
/** List of allowed algorithms. If provided, the JWS `alg` must be in this list. */
|
|
50
|
+
algorithms?: JWSAlgorithm[];
|
|
51
|
+
/** If true, forces the payload to be returned as a Uint8Array, otherwise type is inferred. */
|
|
52
|
+
forceUint8Array?: boolean;
|
|
53
|
+
/** Unless false, will parse payload as JWT and validate claims if applicable (typ "JWT"). */
|
|
54
|
+
validateJWT?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Key lookup function for JWS verification.
|
|
58
|
+
* @param header The JWS Protected Header.
|
|
59
|
+
* @param token The JWS token.
|
|
60
|
+
* @returns The key material (CryptoKey, JWK, or raw Uint8Array) or a Promise resolving to it.
|
|
61
|
+
*/
|
|
62
|
+
type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer> | Promise<CryptoKey | JWK | JWKSet | Uint8Array<ArrayBuffer>>;
|
|
63
|
+
|
|
64
|
+
export type { JWSAlgorithm as J, JWSHeaderParameters as a, JWSProtectedHeader as b, JWSSignOptions as c, JWSVerifyResult as d, JWSVerifyOptions as e, JWSKeyLookupFunction as f };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { X as JWTClaims, r as JWK_Symmetric, u as JWK_Private, t as JWK_Public, w as JWKSet, 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, v as JWK, S as JWKAlgorithm, T as JWKPEMAlgorithm, J as JWKParameters, I as JWK_AES_CBC_HMAC, L as JWK_AES_GCM, H as JWK_AES_GCM_KW, F as JWK_AES_KW, s as JWK_Asymmetric, R as JWK_Asymmetric_Algorithm, j as JWK_EC, O as JWK_ECDH_ES, A as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, x as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, P as JWK_OKP_SIGN, N as JWK_PBES2, m as JWK_RSA, B as JWK_RSA_ENC, z as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, y as JWK_RSA_SIGN, Q as JWK_Symmetric_Algorithm, q as JWK_oct, Y as JWT, Z as JWTClaimValidationOptions, V as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.CtHrClHc.mjs';
|
|
2
|
+
import { c as JWSSignOptions, J as JWSAlgorithm, f as JWSKeyLookupFunction, e as JWSVerifyOptions, d as JWSVerifyResult, a as JWSHeaderParameters, b as JWSProtectedHeader } from './unjwt.BsLgL0DQ.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a JWS (JSON Web Signature) in Compact Serialization format.
|
|
6
|
+
*
|
|
7
|
+
* @param payload The payload to sign. Can be a string, Uint8Array, or an object (which will be JSON stringified).
|
|
8
|
+
* @param key The signing key (CryptoKey, JWK, or raw symmetric key as Uint8Array).
|
|
9
|
+
* @param options Signing options, including the algorithm (`alg`) and protected header parameters.
|
|
10
|
+
* @returns A Promise resolving to the JWS Compact Serialization string.
|
|
11
|
+
*/
|
|
12
|
+
declare function sign(payload: JWTClaims, key: JWK_Symmetric | JWK_Private, options?: JWSSignOptions): Promise<string>;
|
|
13
|
+
declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: JWK_Symmetric | JWK_Private, options?: JWSSignOptions): Promise<string>;
|
|
14
|
+
declare function sign(payload: JWTClaims, key: CryptoKey, options: JWSSignOptions & {
|
|
15
|
+
alg: JWSAlgorithm;
|
|
16
|
+
}): Promise<string>;
|
|
17
|
+
declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: CryptoKey, options: JWSSignOptions & {
|
|
18
|
+
alg: JWSAlgorithm;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
declare function sign(payload: JWTClaims, key: Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
|
|
21
|
+
alg: JWSAlgorithm;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
|
|
24
|
+
alg: JWSAlgorithm;
|
|
25
|
+
}): Promise<string>;
|
|
26
|
+
declare function sign(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>, key: CryptoKey | JWK_Symmetric | JWK_Private | Uint8Array<ArrayBuffer>, options: JWSSignOptions & {
|
|
27
|
+
alg: JWSAlgorithm;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Verifies a JWS (JSON Web Signature) in Compact Serialization format.
|
|
31
|
+
*
|
|
32
|
+
* @param jws The JWS Compact Serialization string.
|
|
33
|
+
* @param key The verification key (CryptoKey, JWK, JWKSet, raw symmetric key as Uint8Array, or a function resolving the key or set).
|
|
34
|
+
* @param options Verification options, such as allowed algorithms.
|
|
35
|
+
* @returns A Promise resolving to an object containing the verified payload and protected header.
|
|
36
|
+
* @throws If the JWS is invalid, signature verification fails, or options are not met.
|
|
37
|
+
*/
|
|
38
|
+
declare function verify<T extends JWTClaims | Uint8Array<ArrayBuffer> | string>(jws: string, key: CryptoKey | JWK_Symmetric | JWK_Public | JWKSet | Uint8Array<ArrayBuffer> | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
|
|
39
|
+
declare function verify(jws: string, key: CryptoKey | JWK_Symmetric | JWK_Public | JWKSet | Uint8Array<ArrayBuffer> | JWSKeyLookupFunction, options: JWSVerifyOptions & {
|
|
40
|
+
forceUint8Array: true;
|
|
41
|
+
}): Promise<JWSVerifyResult<Uint8Array<ArrayBuffer>>>;
|
|
42
|
+
|
|
43
|
+
declare const jws_CompositeKey: typeof CompositeKey;
|
|
44
|
+
declare const jws_ContentEncryptionAlgorithm: typeof ContentEncryptionAlgorithm;
|
|
45
|
+
declare const jws_DeriveKeyOptions: typeof DeriveKeyOptions;
|
|
46
|
+
declare const jws_DeriveKeyReturn: typeof DeriveKeyReturn;
|
|
47
|
+
declare const jws_GenerateJWKOptions: typeof GenerateJWKOptions;
|
|
48
|
+
declare const jws_GenerateJWKReturn: typeof GenerateJWKReturn;
|
|
49
|
+
declare const jws_GenerateKeyAlgorithm: typeof GenerateKeyAlgorithm;
|
|
50
|
+
declare const jws_GenerateKeyOptions: typeof GenerateKeyOptions;
|
|
51
|
+
declare const jws_GenerateKeyReturn: typeof GenerateKeyReturn;
|
|
52
|
+
declare const jws_JWK: typeof JWK;
|
|
53
|
+
declare const jws_JWKAlgorithm: typeof JWKAlgorithm;
|
|
54
|
+
declare const jws_JWKPEMAlgorithm: typeof JWKPEMAlgorithm;
|
|
55
|
+
declare const jws_JWKParameters: typeof JWKParameters;
|
|
56
|
+
declare const jws_JWKSet: typeof JWKSet;
|
|
57
|
+
declare const jws_JWK_AES_CBC_HMAC: typeof JWK_AES_CBC_HMAC;
|
|
58
|
+
declare const jws_JWK_AES_GCM: typeof JWK_AES_GCM;
|
|
59
|
+
declare const jws_JWK_AES_GCM_KW: typeof JWK_AES_GCM_KW;
|
|
60
|
+
declare const jws_JWK_AES_KW: typeof JWK_AES_KW;
|
|
61
|
+
declare const jws_JWK_Asymmetric: typeof JWK_Asymmetric;
|
|
62
|
+
declare const jws_JWK_Asymmetric_Algorithm: typeof JWK_Asymmetric_Algorithm;
|
|
63
|
+
declare const jws_JWK_EC: typeof JWK_EC;
|
|
64
|
+
declare const jws_JWK_ECDH_ES: typeof JWK_ECDH_ES;
|
|
65
|
+
declare const jws_JWK_ECDSA: typeof JWK_ECDSA;
|
|
66
|
+
declare const jws_JWK_EC_Private: typeof JWK_EC_Private;
|
|
67
|
+
declare const jws_JWK_EC_Public: typeof JWK_EC_Public;
|
|
68
|
+
declare const jws_JWK_HMAC: typeof JWK_HMAC;
|
|
69
|
+
declare const jws_JWK_OKP: typeof JWK_OKP;
|
|
70
|
+
declare const jws_JWK_OKP_Private: typeof JWK_OKP_Private;
|
|
71
|
+
declare const jws_JWK_OKP_Public: typeof JWK_OKP_Public;
|
|
72
|
+
declare const jws_JWK_OKP_SIGN: typeof JWK_OKP_SIGN;
|
|
73
|
+
declare const jws_JWK_PBES2: typeof JWK_PBES2;
|
|
74
|
+
declare const jws_JWK_Private: typeof JWK_Private;
|
|
75
|
+
declare const jws_JWK_Public: typeof JWK_Public;
|
|
76
|
+
declare const jws_JWK_RSA: typeof JWK_RSA;
|
|
77
|
+
declare const jws_JWK_RSA_ENC: typeof JWK_RSA_ENC;
|
|
78
|
+
declare const jws_JWK_RSA_PSS: typeof JWK_RSA_PSS;
|
|
79
|
+
declare const jws_JWK_RSA_Private: typeof JWK_RSA_Private;
|
|
80
|
+
declare const jws_JWK_RSA_Public: typeof JWK_RSA_Public;
|
|
81
|
+
declare const jws_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
|
|
82
|
+
declare const jws_JWK_Symmetric: typeof JWK_Symmetric;
|
|
83
|
+
declare const jws_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
|
|
84
|
+
declare const jws_JWK_oct: typeof JWK_oct;
|
|
85
|
+
declare const jws_JWSAlgorithm: typeof JWSAlgorithm;
|
|
86
|
+
declare const jws_JWSHeaderParameters: typeof JWSHeaderParameters;
|
|
87
|
+
declare const jws_JWSKeyLookupFunction: typeof JWSKeyLookupFunction;
|
|
88
|
+
declare const jws_JWSProtectedHeader: typeof JWSProtectedHeader;
|
|
89
|
+
declare const jws_JWSSignOptions: typeof JWSSignOptions;
|
|
90
|
+
declare const jws_JWSVerifyOptions: typeof JWSVerifyOptions;
|
|
91
|
+
declare const jws_JWSVerifyResult: typeof JWSVerifyResult;
|
|
92
|
+
declare const jws_JWT: typeof JWT;
|
|
93
|
+
declare const jws_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
|
|
94
|
+
declare const jws_JWTClaims: typeof JWTClaims;
|
|
95
|
+
declare const jws_JoseHeaderParameters: typeof JoseHeaderParameters;
|
|
96
|
+
declare const jws_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
|
|
97
|
+
declare const jws_UnwrapKeyOptions: typeof UnwrapKeyOptions;
|
|
98
|
+
declare const jws_WrapKeyOptions: typeof WrapKeyOptions;
|
|
99
|
+
declare const jws_WrapKeyResult: typeof WrapKeyResult;
|
|
100
|
+
declare const jws_sign: typeof sign;
|
|
101
|
+
declare const jws_verify: typeof verify;
|
|
102
|
+
declare namespace jws {
|
|
103
|
+
export {
|
|
104
|
+
jws_CompositeKey as CompositeKey,
|
|
105
|
+
jws_ContentEncryptionAlgorithm as ContentEncryptionAlgorithm,
|
|
106
|
+
jws_DeriveKeyOptions as DeriveKeyOptions,
|
|
107
|
+
jws_DeriveKeyReturn as DeriveKeyReturn,
|
|
108
|
+
jws_GenerateJWKOptions as GenerateJWKOptions,
|
|
109
|
+
jws_GenerateJWKReturn as GenerateJWKReturn,
|
|
110
|
+
jws_GenerateKeyAlgorithm as GenerateKeyAlgorithm,
|
|
111
|
+
jws_GenerateKeyOptions as GenerateKeyOptions,
|
|
112
|
+
jws_GenerateKeyReturn as GenerateKeyReturn,
|
|
113
|
+
jws_JWK as JWK,
|
|
114
|
+
jws_JWKAlgorithm as JWKAlgorithm,
|
|
115
|
+
jws_JWKPEMAlgorithm as JWKPEMAlgorithm,
|
|
116
|
+
jws_JWKParameters as JWKParameters,
|
|
117
|
+
jws_JWKSet as JWKSet,
|
|
118
|
+
jws_JWK_AES_CBC_HMAC as JWK_AES_CBC_HMAC,
|
|
119
|
+
jws_JWK_AES_GCM as JWK_AES_GCM,
|
|
120
|
+
jws_JWK_AES_GCM_KW as JWK_AES_GCM_KW,
|
|
121
|
+
jws_JWK_AES_KW as JWK_AES_KW,
|
|
122
|
+
jws_JWK_Asymmetric as JWK_Asymmetric,
|
|
123
|
+
jws_JWK_Asymmetric_Algorithm as JWK_Asymmetric_Algorithm,
|
|
124
|
+
jws_JWK_EC as JWK_EC,
|
|
125
|
+
jws_JWK_ECDH_ES as JWK_ECDH_ES,
|
|
126
|
+
jws_JWK_ECDSA as JWK_ECDSA,
|
|
127
|
+
jws_JWK_EC_Private as JWK_EC_Private,
|
|
128
|
+
jws_JWK_EC_Public as JWK_EC_Public,
|
|
129
|
+
jws_JWK_HMAC as JWK_HMAC,
|
|
130
|
+
jws_JWK_OKP as JWK_OKP,
|
|
131
|
+
jws_JWK_OKP_Private as JWK_OKP_Private,
|
|
132
|
+
jws_JWK_OKP_Public as JWK_OKP_Public,
|
|
133
|
+
jws_JWK_OKP_SIGN as JWK_OKP_SIGN,
|
|
134
|
+
jws_JWK_PBES2 as JWK_PBES2,
|
|
135
|
+
jws_JWK_Private as JWK_Private,
|
|
136
|
+
jws_JWK_Public as JWK_Public,
|
|
137
|
+
jws_JWK_RSA as JWK_RSA,
|
|
138
|
+
jws_JWK_RSA_ENC as JWK_RSA_ENC,
|
|
139
|
+
jws_JWK_RSA_PSS as JWK_RSA_PSS,
|
|
140
|
+
jws_JWK_RSA_Private as JWK_RSA_Private,
|
|
141
|
+
jws_JWK_RSA_Public as JWK_RSA_Public,
|
|
142
|
+
jws_JWK_RSA_SIGN as JWK_RSA_SIGN,
|
|
143
|
+
jws_JWK_Symmetric as JWK_Symmetric,
|
|
144
|
+
jws_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm,
|
|
145
|
+
jws_JWK_oct as JWK_oct,
|
|
146
|
+
jws_JWSAlgorithm as JWSAlgorithm,
|
|
147
|
+
jws_JWSHeaderParameters as JWSHeaderParameters,
|
|
148
|
+
jws_JWSKeyLookupFunction as JWSKeyLookupFunction,
|
|
149
|
+
jws_JWSProtectedHeader as JWSProtectedHeader,
|
|
150
|
+
jws_JWSSignOptions as JWSSignOptions,
|
|
151
|
+
jws_JWSVerifyOptions as JWSVerifyOptions,
|
|
152
|
+
jws_JWSVerifyResult as JWSVerifyResult,
|
|
153
|
+
jws_JWT as JWT,
|
|
154
|
+
jws_JWTClaimValidationOptions as JWTClaimValidationOptions,
|
|
155
|
+
jws_JWTClaims as JWTClaims,
|
|
156
|
+
jws_JoseHeaderParameters as JoseHeaderParameters,
|
|
157
|
+
jws_KeyManagementAlgorithm as KeyManagementAlgorithm,
|
|
158
|
+
jws_UnwrapKeyOptions as UnwrapKeyOptions,
|
|
159
|
+
jws_WrapKeyOptions as WrapKeyOptions,
|
|
160
|
+
jws_WrapKeyResult as WrapKeyResult,
|
|
161
|
+
jws_sign as sign,
|
|
162
|
+
jws_verify as verify,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { jws as j, sign as s, verify as v };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.
|
|
2
|
-
import { r as randomBytes, a as isJWK, s as sanitizeObject, b as applyTypCtyDefaults, c as computeJwtTimeClaims, g as getPlaintextBytes, d as base64UrlEncode, t as textEncoder, e as base64UrlDecode, f as decodePayloadFromBytes, v as validateCriticalHeadersJWE, h as validateJwtClaims, j as isCryptoKeyPair, k as isCryptoKey } from './unjwt.
|
|
1
|
+
import { i as importKey, e as encryptKey, g as generateIV, a as encrypt$1, u as unwrapKey, d as decrypt$1 } from './unjwt.Vg02PZWw.mjs';
|
|
2
|
+
import { r as randomBytes, a as isJWK, s as sanitizeObject, b as applyTypCtyDefaults, c as computeJwtTimeClaims, g as getPlaintextBytes, d as base64UrlEncode, t as textEncoder, e as base64UrlDecode, f as decodePayloadFromBytes, v as validateCriticalHeadersJWE, h as validateJwtClaims, j as isCryptoKeyPair, k as isCryptoKey } from './unjwt.DCiTNyCM.mjs';
|
|
3
3
|
|
|
4
4
|
async function encrypt(payload, key, options = {}) {
|
|
5
5
|
const {
|
|
@@ -209,6 +209,10 @@ interface JWK_oct extends JWKParameters {
|
|
|
209
209
|
/** Oct JWK "k" (Key Value) Parameter */
|
|
210
210
|
k: string;
|
|
211
211
|
}
|
|
212
|
+
/** Symmetric JSON Web Keys */
|
|
213
|
+
type JWK_Symmetric = JWK_oct;
|
|
214
|
+
/** Asymmetric JSON Web Keys */
|
|
215
|
+
type JWK_Asymmetric = JWK_RSA | JWK_EC | JWK_OKP;
|
|
212
216
|
/** Public JSON Web Keys */
|
|
213
217
|
type JWK_Public = JWK_RSA_Public | JWK_EC_Public | JWK_OKP_Public;
|
|
214
218
|
/** Private JSON Web Keys */
|
|
@@ -321,4 +325,4 @@ interface JWTClaimValidationOptions {
|
|
|
321
325
|
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"}`;
|
|
322
326
|
type MaxTokenAge = ExpiresIn;
|
|
323
327
|
|
|
324
|
-
export type {
|
|
328
|
+
export type { JWK_ECDSA as A, JWK_RSA_ENC as B, CompositeKey as C, DeriveKeyOptions as D, ExpiresIn as E, JWK_AES_KW as F, GenerateKeyAlgorithm as G, JWK_AES_GCM_KW as H, JWK_AES_CBC_HMAC as I, JWKParameters as J, KeyManagementAlgorithm as K, JWK_AES_GCM as L, MaxTokenAge as M, JWK_PBES2 as N, JWK_ECDH_ES as O, JWK_OKP_SIGN as P, JWK_Symmetric_Algorithm as Q, JWK_Asymmetric_Algorithm as R, JWKAlgorithm as S, JWKPEMAlgorithm as T, UnwrapKeyOptions as U, JoseHeaderParameters as V, WrapKeyOptions as W, JWTClaims as X, JWT as Y, JWTClaimValidationOptions as Z, GenerateKeyOptions as a, GenerateKeyReturn as b, GenerateJWKOptions as c, GenerateJWKReturn as d, DeriveKeyReturn as e, ContentEncryptionAlgorithm as f, WrapKeyResult as g, JWK_EC_Public as h, JWK_EC_Private as i, JWK_EC as j, JWK_RSA_Public as k, JWK_RSA_Private as l, JWK_RSA as m, JWK_OKP_Public as n, JWK_OKP_Private as o, JWK_OKP as p, JWK_oct as q, JWK_Symmetric as r, JWK_Asymmetric as s, JWK_Public as t, JWK_Private as u, JWK as v, JWKSet as w, JWK_HMAC as x, JWK_RSA_SIGN as y, JWK_RSA_PSS as z };
|
|
@@ -435,4 +435,4 @@ const index = {
|
|
|
435
435
|
validateJwtClaims: validateJwtClaims
|
|
436
436
|
};
|
|
437
437
|
|
|
438
|
-
export {
|
|
438
|
+
export { maybeArray as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, computeExpiresInSeconds as E, computeMaxTokenAgeSeconds as F, isJWK as a, applyTypCtyDefaults as b, computeJwtTimeClaims as c, base64UrlEncode as d, base64UrlDecode as e, decodePayloadFromBytes as f, getPlaintextBytes as g, validateJwtClaims as h, index as i, isCryptoKeyPair as j, isCryptoKey as k, textDecoder as l, isJWKSet as m, decodePayloadFromB64UrlSegment as n, validateCriticalHeadersJWS as o, isSymmetricJWK as p, isPrivateJWK as q, randomBytes as r, sanitizeObject as s, textEncoder as t, isAsymmetricJWK as u, validateCriticalHeadersJWE as v, concatUint8Arrays as w, base64Decode as x, base64Encode as y, assertCryptoKey as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.
|
|
2
|
-
import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, l as textDecoder, e as base64UrlDecode, m as isJWKSet, n as decodePayloadFromB64UrlSegment, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './unjwt.
|
|
1
|
+
import { i as importKey, s as sign$1, b as getJWKFromSet, v as verify$1 } from './unjwt.Vg02PZWw.mjs';
|
|
2
|
+
import { s as sanitizeObject, a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, l as textDecoder, e as base64UrlDecode, m as isJWKSet, n as decodePayloadFromB64UrlSegment, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './unjwt.DCiTNyCM.mjs';
|
|
3
3
|
|
|
4
4
|
async function sign(payload, key, options = {}) {
|
|
5
5
|
const { protectedHeader: additionalProtectedHeader } = options;
|
|
@@ -97,9 +97,7 @@ async function verify(jws, key, options = {}) {
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
const keyInput = typeof key === "function" ? await key(protectedHeader, jws) : key;
|
|
100
|
-
const resolvedKey = isJWKSet(
|
|
101
|
-
keyInput
|
|
102
|
-
) ? getJWKFromSet(keyInput, protectedHeader) : keyInput;
|
|
100
|
+
const resolvedKey = isJWKSet(keyInput) ? getJWKFromSet(keyInput, protectedHeader) : keyInput;
|
|
103
101
|
const verificationKey = await importKey(resolvedKey, alg);
|
|
104
102
|
const signingInputString = `${protectedHeaderEncoded}.${payloadEncoded}`;
|
|
105
103
|
const signingInputBytes = textEncoder.encode(signingInputString);
|