unjwt 0.5.3 → 0.5.4
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/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/jwe.d.mts +1 -1
- package/dist/jwe.d.ts +1 -1
- package/dist/jwe.mjs +3 -3
- package/dist/jwk.d.mts +1 -1
- package/dist/jwk.d.ts +1 -1
- package/dist/jwk.mjs +1 -1
- package/dist/jws.d.mts +1 -1
- package/dist/jws.d.ts +1 -1
- package/dist/jws.mjs +3 -3
- package/dist/shared/{unjwt.CauxOPN5.mjs → unjwt.2RUlMdtr.mjs} +1 -1
- package/dist/shared/{unjwt.DLOO5Rmq.d.mts → unjwt.8w7jp2aw.d.mts} +3 -3
- package/dist/shared/{unjwt.BtEHeKmp.mjs → unjwt.BQI798Cm.mjs} +2 -2
- package/dist/shared/{unjwt.BvA-8hLQ.d.mts → unjwt.CGkRbYL2.d.mts} +11 -5
- package/dist/shared/{unjwt.BPpolBff.mjs → unjwt.CdYPxnzf.mjs} +2 -2
- package/dist/shared/{unjwt.BJPVLhUb.d.ts → unjwt.CoSilGqk.d.ts} +3 -3
- package/dist/shared/{unjwt.B4NFVxpx.d.ts → unjwt.CrcUJklb.d.ts} +0 -1
- package/dist/shared/{unjwt.Dsh9nxbB.mjs → unjwt.DGo0E5fc.mjs} +2 -2
- package/dist/shared/{unjwt.DZjogLQk.d.mts → unjwt.DH1p_WL8.d.mts} +0 -1
- package/dist/shared/{unjwt.C5blWtcA.d.ts → unjwt.RZpKLLLg.d.ts} +11 -5
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.mjs';
|
|
2
2
|
export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.BvIkEGGz.mjs';
|
|
3
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.
|
|
4
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.
|
|
3
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.CGkRbYL2.mjs';
|
|
4
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.8w7jp2aw.mjs';
|
|
5
5
|
export { i as utils } from './shared/unjwt.CbvzYE-m.mjs';
|
|
6
|
-
export { j as jwk } from './shared/unjwt.
|
|
6
|
+
export { j as jwk } from './shared/unjwt.DH1p_WL8.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.js';
|
|
2
2
|
export { b as JWT, a as JWTClaims, J as JoseHeaderParameters } from './shared/unjwt.c10n3uM8.js';
|
|
3
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.
|
|
4
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.
|
|
3
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, j as jws } from './shared/unjwt.RZpKLLLg.js';
|
|
4
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, j as jwe } from './shared/unjwt.CoSilGqk.js';
|
|
5
5
|
export { i as utils } from './shared/unjwt.D4DUiNeM.js';
|
|
6
|
-
export { j as jwk } from './shared/unjwt.
|
|
6
|
+
export { j as jwk } from './shared/unjwt.CrcUJklb.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { i as utils } from './shared/unjwt.X5vzu_l_.mjs';
|
|
2
|
-
export { j as jwe } from './shared/unjwt.
|
|
3
|
-
export { j as jwk } from './shared/unjwt.
|
|
4
|
-
export { j as jws } from './shared/unjwt.
|
|
5
|
-
import './shared/unjwt.
|
|
2
|
+
export { j as jwe } from './shared/unjwt.BQI798Cm.mjs';
|
|
3
|
+
export { j as jwk } from './shared/unjwt.CdYPxnzf.mjs';
|
|
4
|
+
export { j as jws } from './shared/unjwt.DGo0E5fc.mjs';
|
|
5
|
+
import './shared/unjwt.2RUlMdtr.mjs';
|
package/dist/jwe.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './shared/unjwt.D9da8HQF.mjs';
|
|
2
2
|
import './shared/unjwt.BvIkEGGz.mjs';
|
|
3
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.
|
|
3
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.8w7jp2aw.mjs';
|
package/dist/jwe.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './shared/unjwt.D9da8HQF.js';
|
|
2
2
|
import './shared/unjwt.c10n3uM8.js';
|
|
3
|
-
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.
|
|
3
|
+
export { d as JWEDecryptOptions, e as JWEDecryptResult, b as JWEEncryptOptions, J as JWEHeaderParameters, c as JWEKeyLookupFunction, a as JWEKeyManagementHeaderParameters, g as decrypt, f as encrypt } from './shared/unjwt.CoSilGqk.js';
|
package/dist/jwe.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.CdYPxnzf.mjs';
|
|
2
2
|
import './shared/unjwt.X5vzu_l_.mjs';
|
|
3
|
-
export { d as decrypt, e as encrypt } from './shared/unjwt.
|
|
4
|
-
import './shared/unjwt.
|
|
3
|
+
export { d as decrypt, e as encrypt } from './shared/unjwt.BQI798Cm.mjs';
|
|
4
|
+
import './shared/unjwt.2RUlMdtr.mjs';
|
package/dist/jwk.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.mjs';
|
|
2
2
|
import './shared/unjwt.BvIkEGGz.mjs';
|
|
3
|
-
export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
3
|
+
export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.DH1p_WL8.mjs';
|
package/dist/jwk.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.D9da8HQF.js';
|
|
2
2
|
import './shared/unjwt.c10n3uM8.js';
|
|
3
|
-
export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
3
|
+
export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.CrcUJklb.js';
|
package/dist/jwk.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './shared/unjwt.X5vzu_l_.mjs';
|
|
2
|
-
export { p as deriveKeyFromPassword, t as exportJWKToPEM, q as exportKey, o as generateKey, g as getJWKFromSet, s as importJWKFromPEM, i as importKey, m as unwrapKey, r as wrapKey } from './shared/unjwt.
|
|
2
|
+
export { p as deriveKeyFromPassword, t as exportJWKToPEM, q as exportKey, o as generateKey, g as getJWKFromSet, s as importJWKFromPEM, i as importKey, m as unwrapKey, r as wrapKey } from './shared/unjwt.CdYPxnzf.mjs';
|
package/dist/jws.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './shared/unjwt.D9da8HQF.mjs';
|
|
2
2
|
import './shared/unjwt.BvIkEGGz.mjs';
|
|
3
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.
|
|
3
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.CGkRbYL2.mjs';
|
package/dist/jws.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import './shared/unjwt.D9da8HQF.js';
|
|
2
2
|
import './shared/unjwt.c10n3uM8.js';
|
|
3
|
-
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.
|
|
3
|
+
export { J as JWSAlgorithm, a as JWSHeaderParameters, f as JWSKeyLookupFunction, b as JWSProtectedHeader, c as JWSSignOptions, e as JWSVerifyOptions, d as JWSVerifyResult, s as sign, v as verify } from './shared/unjwt.RZpKLLLg.js';
|
package/dist/jws.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.CdYPxnzf.mjs';
|
|
2
2
|
import './shared/unjwt.X5vzu_l_.mjs';
|
|
3
|
-
import './shared/unjwt.
|
|
4
|
-
export { s as sign, v as verify } from './shared/unjwt.
|
|
3
|
+
import './shared/unjwt.2RUlMdtr.mjs';
|
|
4
|
+
export { s as sign, v as verify } from './shared/unjwt.DGo0E5fc.mjs';
|
|
@@ -125,7 +125,7 @@ interface JWEDecryptOptions {
|
|
|
125
125
|
/**
|
|
126
126
|
* Result of a JWE decryption operation.
|
|
127
127
|
*/
|
|
128
|
-
interface JWEDecryptResult<T = JWTClaims | string> {
|
|
128
|
+
interface JWEDecryptResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> {
|
|
129
129
|
/** The decrypted payload. */
|
|
130
130
|
payload: T;
|
|
131
131
|
/** The JWE Protected Header. */
|
|
@@ -167,13 +167,13 @@ declare function encrypt(payload: string | Uint8Array | Record<string, any>, key
|
|
|
167
167
|
* @returns A Promise resolving to an object containing the decrypted plaintext, protected header, CEK, and AAD.
|
|
168
168
|
* @throws If JWE is invalid, decryption fails, or options are not met.
|
|
169
169
|
*/
|
|
170
|
-
declare function decrypt<T
|
|
170
|
+
declare function decrypt<T extends JWTClaims | Uint8Array | string>(jwe: string, key: CryptoKey | JWK | string | Uint8Array | JWEKeyLookupFunction, options?: JWEDecryptOptions): Promise<JWEDecryptResult<T>>;
|
|
171
171
|
declare function decrypt(jwe: string, key: CryptoKey | JWK | string | Uint8Array | JWEKeyLookupFunction, options: JWEDecryptOptions & {
|
|
172
172
|
forceUint8Array: true;
|
|
173
173
|
}): Promise<JWEDecryptResult<Uint8Array>>;
|
|
174
174
|
|
|
175
175
|
type jwe_JWEDecryptOptions = JWEDecryptOptions;
|
|
176
|
-
type jwe_JWEDecryptResult<T = JWTClaims | string> = JWEDecryptResult<T>;
|
|
176
|
+
type jwe_JWEDecryptResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> = JWEDecryptResult<T>;
|
|
177
177
|
type jwe_JWEEncryptOptions = JWEEncryptOptions;
|
|
178
178
|
type jwe_JWEHeaderParameters = JWEHeaderParameters;
|
|
179
179
|
type jwe_JWEKeyLookupFunction = JWEKeyLookupFunction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as checkEncCryptoKey, u as uint32be, b as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, d as bitLengthCEK, f as jwkTokey, i as importKey, h as generateIV, l as encrypt$1, m as unwrapKey, n as decrypt$1 } from './unjwt.
|
|
1
|
+
import { a as checkEncCryptoKey, u as uint32be, b as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, d as bitLengthCEK, f as jwkTokey, i as importKey, h as generateIV, l as encrypt$1, m as unwrapKey, n as decrypt$1 } from './unjwt.CdYPxnzf.mjs';
|
|
2
2
|
import { f as concatUint8Arrays, t as textEncoder, g as assertCryptoKey, b as base64UrlEncode, h as isCryptoKey, a as isJWK, d as base64UrlDecode, r as randomBytes, c as textDecoder } from './unjwt.X5vzu_l_.mjs';
|
|
3
|
-
import { c as checkKeyLength } from './unjwt.
|
|
3
|
+
import { c as checkKeyLength } from './unjwt.2RUlMdtr.mjs';
|
|
4
4
|
|
|
5
5
|
function lengthAndInput(input) {
|
|
6
6
|
return concatUint8Arrays(uint32be(input.length), input);
|
|
@@ -33,7 +33,7 @@ interface JWSSignOptions {
|
|
|
33
33
|
protectedHeader?: JWSHeaderParameters;
|
|
34
34
|
}
|
|
35
35
|
/** Result of JWS verification */
|
|
36
|
-
interface JWSVerifyResult<T = JWTClaims | Uint8Array | string> {
|
|
36
|
+
interface JWSVerifyResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> {
|
|
37
37
|
/** The decoded and verified payload. */
|
|
38
38
|
payload: T;
|
|
39
39
|
/** The JWS Protected Header. */
|
|
@@ -117,14 +117,20 @@ type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => Crypt
|
|
|
117
117
|
* @param options Signing options, including the algorithm (`alg`) and protected header parameters.
|
|
118
118
|
* @returns A Promise resolving to the JWS Compact Serialization string.
|
|
119
119
|
*/
|
|
120
|
-
declare function sign(payload: JWTClaims, key: JWK
|
|
121
|
-
declare function sign(payload: string | Uint8Array | Record<string, any>, key: JWK
|
|
120
|
+
declare function sign(payload: JWTClaims, key: JWK, options?: JWSSignOptions): Promise<string>;
|
|
121
|
+
declare function sign(payload: string | Uint8Array | Record<string, any>, key: JWK, options?: JWSSignOptions): Promise<string>;
|
|
122
122
|
declare function sign(payload: JWTClaims, key: CryptoKey, options: JWSSignOptions & {
|
|
123
123
|
alg: JWSAlgorithm;
|
|
124
124
|
}): Promise<string>;
|
|
125
125
|
declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey, options: JWSSignOptions & {
|
|
126
126
|
alg: JWSAlgorithm;
|
|
127
127
|
}): Promise<string>;
|
|
128
|
+
declare function sign(payload: JWTClaims, key: Uint8Array, options: JWSSignOptions & {
|
|
129
|
+
alg: JWSAlgorithm;
|
|
130
|
+
}): Promise<string>;
|
|
131
|
+
declare function sign(payload: string | Uint8Array | Record<string, any>, key: Uint8Array, options: JWSSignOptions & {
|
|
132
|
+
alg: JWSAlgorithm;
|
|
133
|
+
}): Promise<string>;
|
|
128
134
|
declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey | JWK | Uint8Array, options: JWSSignOptions & {
|
|
129
135
|
alg: JWSAlgorithm;
|
|
130
136
|
}): Promise<string>;
|
|
@@ -137,7 +143,7 @@ declare function sign(payload: string | Uint8Array | Record<string, any>, key: C
|
|
|
137
143
|
* @returns A Promise resolving to an object containing the verified payload and protected header.
|
|
138
144
|
* @throws If the JWS is invalid, signature verification fails, or options are not met.
|
|
139
145
|
*/
|
|
140
|
-
declare function verify<T
|
|
146
|
+
declare function verify<T extends JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
|
|
141
147
|
declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options: JWSVerifyOptions & {
|
|
142
148
|
forceUint8Array: true;
|
|
143
149
|
}): Promise<JWSVerifyResult<Uint8Array>>;
|
|
@@ -148,7 +154,7 @@ type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
|
|
|
148
154
|
type jws_JWSProtectedHeader = JWSProtectedHeader;
|
|
149
155
|
type jws_JWSSignOptions = JWSSignOptions;
|
|
150
156
|
type jws_JWSVerifyOptions = JWSVerifyOptions;
|
|
151
|
-
type jws_JWSVerifyResult<T = JWTClaims | Uint8Array | string> = JWSVerifyResult<T>;
|
|
157
|
+
type jws_JWSVerifyResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> = JWSVerifyResult<T>;
|
|
152
158
|
declare const jws_sign: typeof sign;
|
|
153
159
|
declare const jws_verify: typeof verify;
|
|
154
160
|
declare namespace jws {
|
|
@@ -1095,12 +1095,12 @@ async function importKey(key, alg) {
|
|
|
1095
1095
|
if ("k" in key && typeof key.k === "string") {
|
|
1096
1096
|
return base64UrlDecode(key.k, false);
|
|
1097
1097
|
} else {
|
|
1098
|
-
if (!alg) {
|
|
1098
|
+
if (!key.alg && !alg) {
|
|
1099
1099
|
throw new TypeError(
|
|
1100
1100
|
"Algorithm must be provided when importing non-oct JWK"
|
|
1101
1101
|
);
|
|
1102
1102
|
}
|
|
1103
|
-
return jwkTokey({ ...key, alg });
|
|
1103
|
+
return jwkTokey({ ...key, alg: key.alg || alg });
|
|
1104
1104
|
}
|
|
1105
1105
|
}
|
|
1106
1106
|
throw new Error("Invalid key type provided to importKey");
|
|
@@ -125,7 +125,7 @@ interface JWEDecryptOptions {
|
|
|
125
125
|
/**
|
|
126
126
|
* Result of a JWE decryption operation.
|
|
127
127
|
*/
|
|
128
|
-
interface JWEDecryptResult<T = JWTClaims | string> {
|
|
128
|
+
interface JWEDecryptResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> {
|
|
129
129
|
/** The decrypted payload. */
|
|
130
130
|
payload: T;
|
|
131
131
|
/** The JWE Protected Header. */
|
|
@@ -167,13 +167,13 @@ declare function encrypt(payload: string | Uint8Array | Record<string, any>, key
|
|
|
167
167
|
* @returns A Promise resolving to an object containing the decrypted plaintext, protected header, CEK, and AAD.
|
|
168
168
|
* @throws If JWE is invalid, decryption fails, or options are not met.
|
|
169
169
|
*/
|
|
170
|
-
declare function decrypt<T
|
|
170
|
+
declare function decrypt<T extends JWTClaims | Uint8Array | string>(jwe: string, key: CryptoKey | JWK | string | Uint8Array | JWEKeyLookupFunction, options?: JWEDecryptOptions): Promise<JWEDecryptResult<T>>;
|
|
171
171
|
declare function decrypt(jwe: string, key: CryptoKey | JWK | string | Uint8Array | JWEKeyLookupFunction, options: JWEDecryptOptions & {
|
|
172
172
|
forceUint8Array: true;
|
|
173
173
|
}): Promise<JWEDecryptResult<Uint8Array>>;
|
|
174
174
|
|
|
175
175
|
type jwe_JWEDecryptOptions = JWEDecryptOptions;
|
|
176
|
-
type jwe_JWEDecryptResult<T = JWTClaims | string> = JWEDecryptResult<T>;
|
|
176
|
+
type jwe_JWEDecryptResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> = JWEDecryptResult<T>;
|
|
177
177
|
type jwe_JWEEncryptOptions = JWEEncryptOptions;
|
|
178
178
|
type jwe_JWEHeaderParameters = JWEHeaderParameters;
|
|
179
179
|
type jwe_JWEKeyLookupFunction = JWEKeyLookupFunction;
|
|
@@ -48,7 +48,6 @@ declare function importKey(key: string): Promise<Uint8Array>;
|
|
|
48
48
|
declare function importKey(key: Uint8Array): Promise<Uint8Array>;
|
|
49
49
|
declare function importKey(key: CryptoKey): Promise<CryptoKey>;
|
|
50
50
|
declare function importKey(key: JWK_oct): Promise<Uint8Array>;
|
|
51
|
-
declare function importKey(key: Exclude<JWK, JWK_oct>, alg: string): Promise<CryptoKey>;
|
|
52
51
|
declare function importKey(key: CryptoKey | JWK | Uint8Array | string, alg?: string): Promise<CryptoKey | Uint8Array>;
|
|
53
52
|
/**
|
|
54
53
|
* Exports a CryptoKey to a JWK (JSON Web Key) format.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as importKey, g as getJWKFromSet } from './unjwt.
|
|
1
|
+
import { i as importKey, g as getJWKFromSet } from './unjwt.CdYPxnzf.mjs';
|
|
2
2
|
import { a as isJWK, b as base64UrlEncode, t as textEncoder, c as textDecoder, d as base64UrlDecode, e as isJWKSet, m as maybeArray } from './unjwt.X5vzu_l_.mjs';
|
|
3
|
-
import { s as sign$1, v as verify$1 } from './unjwt.
|
|
3
|
+
import { s as sign$1, v as verify$1 } from './unjwt.2RUlMdtr.mjs';
|
|
4
4
|
|
|
5
5
|
async function sign(payload, key, options = {}) {
|
|
6
6
|
const { protectedHeader: additionalProtectedHeader } = options;
|
|
@@ -48,7 +48,6 @@ declare function importKey(key: string): Promise<Uint8Array>;
|
|
|
48
48
|
declare function importKey(key: Uint8Array): Promise<Uint8Array>;
|
|
49
49
|
declare function importKey(key: CryptoKey): Promise<CryptoKey>;
|
|
50
50
|
declare function importKey(key: JWK_oct): Promise<Uint8Array>;
|
|
51
|
-
declare function importKey(key: Exclude<JWK, JWK_oct>, alg: string): Promise<CryptoKey>;
|
|
52
51
|
declare function importKey(key: CryptoKey | JWK | Uint8Array | string, alg?: string): Promise<CryptoKey | Uint8Array>;
|
|
53
52
|
/**
|
|
54
53
|
* Exports a CryptoKey to a JWK (JSON Web Key) format.
|
|
@@ -33,7 +33,7 @@ interface JWSSignOptions {
|
|
|
33
33
|
protectedHeader?: JWSHeaderParameters;
|
|
34
34
|
}
|
|
35
35
|
/** Result of JWS verification */
|
|
36
|
-
interface JWSVerifyResult<T = JWTClaims | Uint8Array | string> {
|
|
36
|
+
interface JWSVerifyResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> {
|
|
37
37
|
/** The decoded and verified payload. */
|
|
38
38
|
payload: T;
|
|
39
39
|
/** The JWS Protected Header. */
|
|
@@ -117,14 +117,20 @@ type JWSKeyLookupFunction = (header: JWSProtectedHeader, token: string) => Crypt
|
|
|
117
117
|
* @param options Signing options, including the algorithm (`alg`) and protected header parameters.
|
|
118
118
|
* @returns A Promise resolving to the JWS Compact Serialization string.
|
|
119
119
|
*/
|
|
120
|
-
declare function sign(payload: JWTClaims, key: JWK
|
|
121
|
-
declare function sign(payload: string | Uint8Array | Record<string, any>, key: JWK
|
|
120
|
+
declare function sign(payload: JWTClaims, key: JWK, options?: JWSSignOptions): Promise<string>;
|
|
121
|
+
declare function sign(payload: string | Uint8Array | Record<string, any>, key: JWK, options?: JWSSignOptions): Promise<string>;
|
|
122
122
|
declare function sign(payload: JWTClaims, key: CryptoKey, options: JWSSignOptions & {
|
|
123
123
|
alg: JWSAlgorithm;
|
|
124
124
|
}): Promise<string>;
|
|
125
125
|
declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey, options: JWSSignOptions & {
|
|
126
126
|
alg: JWSAlgorithm;
|
|
127
127
|
}): Promise<string>;
|
|
128
|
+
declare function sign(payload: JWTClaims, key: Uint8Array, options: JWSSignOptions & {
|
|
129
|
+
alg: JWSAlgorithm;
|
|
130
|
+
}): Promise<string>;
|
|
131
|
+
declare function sign(payload: string | Uint8Array | Record<string, any>, key: Uint8Array, options: JWSSignOptions & {
|
|
132
|
+
alg: JWSAlgorithm;
|
|
133
|
+
}): Promise<string>;
|
|
128
134
|
declare function sign(payload: string | Uint8Array | Record<string, any>, key: CryptoKey | JWK | Uint8Array, options: JWSSignOptions & {
|
|
129
135
|
alg: JWSAlgorithm;
|
|
130
136
|
}): Promise<string>;
|
|
@@ -137,7 +143,7 @@ declare function sign(payload: string | Uint8Array | Record<string, any>, key: C
|
|
|
137
143
|
* @returns A Promise resolving to an object containing the verified payload and protected header.
|
|
138
144
|
* @throws If the JWS is invalid, signature verification fails, or options are not met.
|
|
139
145
|
*/
|
|
140
|
-
declare function verify<T
|
|
146
|
+
declare function verify<T extends JWTClaims | Uint8Array | string>(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options?: JWSVerifyOptions): Promise<JWSVerifyResult<T>>;
|
|
141
147
|
declare function verify(jws: string, key: CryptoKey | JWK | JWKSet | Uint8Array | JWSKeyLookupFunction, options: JWSVerifyOptions & {
|
|
142
148
|
forceUint8Array: true;
|
|
143
149
|
}): Promise<JWSVerifyResult<Uint8Array>>;
|
|
@@ -148,7 +154,7 @@ type jws_JWSKeyLookupFunction = JWSKeyLookupFunction;
|
|
|
148
154
|
type jws_JWSProtectedHeader = JWSProtectedHeader;
|
|
149
155
|
type jws_JWSSignOptions = JWSSignOptions;
|
|
150
156
|
type jws_JWSVerifyOptions = JWSVerifyOptions;
|
|
151
|
-
type jws_JWSVerifyResult<T = JWTClaims | Uint8Array | string> = JWSVerifyResult<T>;
|
|
157
|
+
type jws_JWSVerifyResult<T extends JWTClaims | Uint8Array | string = JWTClaims | Uint8Array | string> = JWSVerifyResult<T>;
|
|
152
158
|
declare const jws_sign: typeof sign;
|
|
153
159
|
declare const jws_verify: typeof verify;
|
|
154
160
|
declare namespace jws {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unjwt",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Low-level JWT utilities",
|
|
5
5
|
"repository": "sandros94/unjwt",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"lint:fix": "automd && eslint . --fix && prettier -w .",
|
|
46
46
|
"prepack": "pnpm build",
|
|
47
47
|
"release": "pnpm test && pnpm prepack && changelogen --release --push --publish",
|
|
48
|
-
"test": "pnpm lint && pnpm test:types && vitest run --
|
|
48
|
+
"test": "pnpm lint && pnpm test:types && vitest run --slowTestThreshold=500",
|
|
49
|
+
"test:coverage": "pnpm lint && pnpm test:types && vitest run --coverage --slowTestThreshold=500",
|
|
49
50
|
"test:types": "tsc --noEmit --skipLibCheck"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|