unjwt 0.5.18 → 0.5.20
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 +5 -5
- package/dist/index.mjs +4 -4
- package/dist/jwe.d.mts +2 -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 +2 -2
- package/dist/jws.mjs +3 -3
- package/dist/shared/{unjwt.CcoSLC0q.d.mts → unjwt.BFtNZVqt.d.mts} +2 -2
- package/dist/shared/{unjwt.DNIO0cRI.d.mts → unjwt.BuQdWrN5.d.mts} +9 -3
- package/dist/shared/{unjwt.VeTDOWHW.mjs → unjwt.CaZJRuRa.mjs} +2 -2
- package/dist/shared/{unjwt.DMz8YzKh.d.mts → unjwt.ChCsF4q6.d.mts} +1 -1
- package/dist/shared/{unjwt.BEyYvaE4.mjs → unjwt.D7ya3PwS.mjs} +1 -1
- package/dist/shared/{unjwt.XLRRd_3f.d.mts → unjwt.DANsaNYC.d.mts} +2 -2
- package/dist/shared/{unjwt.DLpR-j1d.mjs → unjwt.Dc_YDjvO.mjs} +2 -2
- package/dist/shared/{unjwt.Ca4-7Myr.d.mts → unjwt.Dy68jE0N.d.mts} +6 -3
- package/dist/shared/{unjwt.tM5bsBSH.mjs → unjwt.K_6rgVTy.mjs} +54 -3
- package/dist/utils.d.mts +2 -2
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { 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, t as JWK,
|
|
2
|
-
export {
|
|
3
|
-
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.
|
|
4
|
-
export {
|
|
5
|
-
export { j as
|
|
1
|
+
export { C as CompositeKey, f as ContentEncryptionAlgorithm, D as DeriveKeyOptions, e as DeriveKeyReturn, E as ExpiresIn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, t as JWK, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, I as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, X as JWTClaimValidationOptions, T as JWTClaims, S as JoseHeaderParameters, K as KeyManagementAlgorithm, M as MaxTokenAge, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Dy68jE0N.mjs';
|
|
2
|
+
export { i as utils } from './shared/unjwt.BuQdWrN5.mjs';
|
|
3
|
+
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.BFtNZVqt.mjs';
|
|
4
|
+
export { j as jwk } from './shared/unjwt.ChCsF4q6.mjs';
|
|
5
|
+
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.DANsaNYC.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { i as utils } from './shared/unjwt.
|
|
2
|
-
export { j as jwe } from './shared/unjwt.
|
|
3
|
-
export { j as jwk } from './shared/unjwt.
|
|
4
|
-
export { j as jws } from './shared/unjwt.
|
|
1
|
+
export { i as utils } from './shared/unjwt.K_6rgVTy.mjs';
|
|
2
|
+
export { j as jwe } from './shared/unjwt.CaZJRuRa.mjs';
|
|
3
|
+
export { j as jwk } from './shared/unjwt.D7ya3PwS.mjs';
|
|
4
|
+
export { j as jws } from './shared/unjwt.Dc_YDjvO.mjs';
|
package/dist/jwe.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { 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, t as JWK,
|
|
2
|
-
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.
|
|
1
|
+
export { 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, t as JWK, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, I as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, X as JWTClaimValidationOptions, T as JWTClaims, S as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Dy68jE0N.mjs';
|
|
2
|
+
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.BFtNZVqt.mjs';
|
package/dist/jwe.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
import './shared/unjwt.
|
|
3
|
-
export { d as decrypt, e as encrypt } from './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.D7ya3PwS.mjs';
|
|
2
|
+
import './shared/unjwt.K_6rgVTy.mjs';
|
|
3
|
+
export { d as decrypt, e as encrypt } from './shared/unjwt.CaZJRuRa.mjs';
|
package/dist/jwk.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { 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, t as JWK,
|
|
2
|
-
export { b as deriveJWKFromPassword, d as deriveKeyFromPassword, f as exportJWKToPEM, e as exportKey, a as generateJWK, g as generateKey, h as getJWKFromSet, c as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
1
|
+
export { 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, t as JWK, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, I as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, X as JWTClaimValidationOptions, T as JWTClaims, S as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Dy68jE0N.mjs';
|
|
2
|
+
export { b as deriveJWKFromPassword, d as deriveKeyFromPassword, f as exportJWKToPEM, e as exportKey, a as generateJWK, g as generateKey, h as getJWKFromSet, c as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.ChCsF4q6.mjs';
|
package/dist/jwk.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export { k as deriveJWKFromPassword, h as deriveKeyFromPassword, n as exportJWKToPEM, l as exportKey, f as generateJWK, c as generateKey, b as getJWKFromSet, m as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.K_6rgVTy.mjs';
|
|
2
|
+
export { k as deriveJWKFromPassword, h as deriveKeyFromPassword, n as exportJWKToPEM, l as exportKey, f as generateJWK, c as generateKey, b as getJWKFromSet, m as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.D7ya3PwS.mjs';
|
package/dist/jws.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { 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, t as JWK,
|
|
2
|
-
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.
|
|
1
|
+
export { 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, t as JWK, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, I as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, X as JWTClaimValidationOptions, T as JWTClaims, S as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './shared/unjwt.Dy68jE0N.mjs';
|
|
2
|
+
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.DANsaNYC.mjs';
|
package/dist/jws.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
import './shared/unjwt.
|
|
3
|
-
export { s as sign, v as verify } from './shared/unjwt.
|
|
1
|
+
import './shared/unjwt.D7ya3PwS.mjs';
|
|
2
|
+
import './shared/unjwt.K_6rgVTy.mjs';
|
|
3
|
+
export { s as sign, v as verify } from './shared/unjwt.Dc_YDjvO.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm,
|
|
1
|
+
import { K as KeyManagementAlgorithm, f as ContentEncryptionAlgorithm, E as ExpiresIn, S as JoseHeaderParameters, h as JWK_EC_Public, i as JWK_EC_Private, t as JWK, X as JWTClaimValidationOptions, T as JWTClaims, C as CompositeKey, D as DeriveKeyOptions, e as DeriveKeyReturn, c as GenerateJWKOptions, d as GenerateJWKReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, u as JWKSet, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, I as JWK_PBES2, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.Dy68jE0N.mjs';
|
|
2
2
|
|
|
3
3
|
/** Recognized JWE Header Parameters, any other Header Members may also be present. */
|
|
4
4
|
interface JWEHeaderParameters extends JoseHeaderParameters {
|
|
@@ -77,7 +77,7 @@ interface JWEEncryptOptions {
|
|
|
77
77
|
/** Date to use when computing NumericDate claims, defaults to `new Date()`. */
|
|
78
78
|
currentDate?: Date;
|
|
79
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?:
|
|
80
|
+
expiresIn?: ExpiresIn;
|
|
81
81
|
/** Additional JWE Protected Header parameters. */
|
|
82
82
|
protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "epk" | "apu" | "apv">;
|
|
83
83
|
/** Initialization Vector for AES-GCMKW key wrapping. Generated if not provided. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as ExpiresIn, T as JWTClaims, X as JWTClaimValidationOptions, t as JWK, u as JWKSet, q as JWK_oct, s as JWK_Private, r as JWK_Public } from './unjwt.Dy68jE0N.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Apply default typ/cty semantics shared by JWS & JWE.
|
|
@@ -37,8 +37,10 @@ declare function decodePayloadFromB64UrlSegment<T = unknown>(payloadEncoded: str
|
|
|
37
37
|
} | undefined, forceUint8Array?: boolean): T | Uint8Array<ArrayBuffer> | string;
|
|
38
38
|
/** Convert plaintext input to bytes, shared by JWS & JWE when preparing payload. */
|
|
39
39
|
declare function getPlaintextBytes(payload: string | Uint8Array<ArrayBuffer> | Record<string, any>): Uint8Array<ArrayBuffer>;
|
|
40
|
+
declare function computeExpiresInSeconds(expiresIn: ExpiresIn): number;
|
|
41
|
+
declare const computeMaxTokenAgeSeconds: typeof computeExpiresInSeconds;
|
|
40
42
|
/** Optionally compute iat/exp when signing JWTs. */
|
|
41
|
-
declare function computeJwtTimeClaims(payload: unknown, headerTyp: string | undefined, expiresIn?:
|
|
43
|
+
declare function computeJwtTimeClaims(payload: unknown, headerTyp: string | undefined, expiresIn?: ExpiresIn, currentDate?: Date): JWTClaims | undefined;
|
|
42
44
|
/** Validate JWT claims under JWS verification rules (or custom JWE implementations). */
|
|
43
45
|
declare function validateJwtClaims(jwtClaims: JWTClaims, options?: JWTClaimValidationOptions): void;
|
|
44
46
|
/** Validate critical headers in JWS semantics. */
|
|
@@ -105,7 +107,9 @@ declare const index_base64Decode: typeof base64Decode;
|
|
|
105
107
|
declare const index_base64Encode: typeof base64Encode;
|
|
106
108
|
declare const index_base64UrlDecode: typeof base64UrlDecode;
|
|
107
109
|
declare const index_base64UrlEncode: typeof base64UrlEncode;
|
|
110
|
+
declare const index_computeExpiresInSeconds: typeof computeExpiresInSeconds;
|
|
108
111
|
declare const index_computeJwtTimeClaims: typeof computeJwtTimeClaims;
|
|
112
|
+
declare const index_computeMaxTokenAgeSeconds: typeof computeMaxTokenAgeSeconds;
|
|
109
113
|
declare const index_concatUint8Arrays: typeof concatUint8Arrays;
|
|
110
114
|
declare const index_decodeMaybeJWTString: typeof decodeMaybeJWTString;
|
|
111
115
|
declare const index_decodePayloadFromB64UrlSegment: typeof decodePayloadFromB64UrlSegment;
|
|
@@ -136,7 +140,9 @@ declare namespace index {
|
|
|
136
140
|
index_base64Encode as base64Encode,
|
|
137
141
|
index_base64UrlDecode as base64UrlDecode,
|
|
138
142
|
index_base64UrlEncode as base64UrlEncode,
|
|
143
|
+
index_computeExpiresInSeconds as computeExpiresInSeconds,
|
|
139
144
|
index_computeJwtTimeClaims as computeJwtTimeClaims,
|
|
145
|
+
index_computeMaxTokenAgeSeconds as computeMaxTokenAgeSeconds,
|
|
140
146
|
index_concatUint8Arrays as concatUint8Arrays,
|
|
141
147
|
index_decodeMaybeJWTString as decodeMaybeJWTString,
|
|
142
148
|
index_decodePayloadFromB64UrlSegment as decodePayloadFromB64UrlSegment,
|
|
@@ -162,4 +168,4 @@ declare namespace index {
|
|
|
162
168
|
};
|
|
163
169
|
}
|
|
164
170
|
|
|
165
|
-
export {
|
|
171
|
+
export { computeMaxTokenAgeSeconds as A, computeJwtTimeClaims as B, validateJwtClaims as C, validateCriticalHeadersJWS as D, validateCriticalHeadersJWE as E, sanitizeObject as F, textDecoder as a, base64Encode as b, base64UrlEncode as c, base64Decode as d, base64UrlDecode as e, concatUint8Arrays as f, isJWK as g, isJWKSet as h, index as i, assertCryptoKey as j, isCryptoKey as k, isCryptoKeyPair as l, maybeArray as m, isSymmetricJWK as n, isAsymmetricJWK as o, isPrivateJWK as p, isPublicJWK as q, randomBytes as r, applyTypCtyDefaults as s, textEncoder as t, isJWTContent as u, decodeMaybeJWTString as v, decodePayloadFromBytes as w, decodePayloadFromB64UrlSegment as x, getPlaintextBytes as y, computeExpiresInSeconds as z };
|
|
@@ -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.D7ya3PwS.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.K_6rgVTy.mjs';
|
|
3
3
|
|
|
4
4
|
async function encrypt(payload, key, options = {}) {
|
|
5
5
|
const {
|
|
@@ -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, I as JWK_PBES2, D as DeriveKeyOptions, e as DeriveKeyReturn, q as JWK_oct, t as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, g as WrapKeyResult, U as UnwrapKeyOptions, R as JWKPEMAlgorithm, u as JWKSet, S as JoseHeaderParameters, C as CompositeKey, f as ContentEncryptionAlgorithm, Q as JWKAlgorithm, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L as JWK_ECDH_ES, y as JWK_ECDSA, i as JWK_EC_Private, h as JWK_EC_Public, v as JWK_HMAC, p as JWK_OKP, o as JWK_OKP_Private, n as JWK_OKP_Public, N as JWK_OKP_SIGN, s as JWK_Private, r as JWK_Public, m as JWK_RSA, z as JWK_RSA_ENC, x as JWK_RSA_PSS, l as JWK_RSA_Private, k as JWK_RSA_Public, w as JWK_RSA_SIGN, O as JWK_Symmetric_Algorithm, V as JWT, X as JWTClaimValidationOptions, T as JWTClaims } from './unjwt.Dy68jE0N.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as isCryptoKey, p as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, u as base64Encode, t as textEncoder, s as sanitizeObject, w as assertCryptoKey, a as isJWK, e as base64UrlDecode, x as isAsymmetricJWK, r as randomBytes, m as isJWKSet } from './unjwt.
|
|
1
|
+
import { k as isCryptoKey, p as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, u as base64Encode, t as textEncoder, s as sanitizeObject, w as assertCryptoKey, a as isJWK, e as base64UrlDecode, x as isAsymmetricJWK, r as randomBytes, m as isJWKSet } from './unjwt.K_6rgVTy.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* This is a fork of Jose library's utility functions.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA,
|
|
1
|
+
import { v as JWK_HMAC, w as JWK_RSA_SIGN, x as JWK_RSA_PSS, y as JWK_ECDSA, S as JoseHeaderParameters, E as ExpiresIn, t as JWK, u as JWKSet, X as JWTClaimValidationOptions, T 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, Q as JWKAlgorithm, R as JWKPEMAlgorithm, J as JWKParameters, F as JWK_AES_CBC_HMAC, H as JWK_AES_GCM, B as JWK_AES_GCM_KW, A as JWK_AES_KW, P as JWK_Asymmetric_Algorithm, j as JWK_EC, L 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, N as JWK_OKP_SIGN, I 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, O as JWK_Symmetric_Algorithm, q as JWK_oct, V as JWT, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, g as WrapKeyResult } from './unjwt.Dy68jE0N.mjs';
|
|
2
2
|
|
|
3
3
|
type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
|
|
4
4
|
/** JWS Signing Algorithm Identifier. */
|
|
@@ -35,7 +35,7 @@ interface JWSSignOptions {
|
|
|
35
35
|
/**
|
|
36
36
|
* Time at which the JWS should expire, if no `exp` was already provided.
|
|
37
37
|
*/
|
|
38
|
-
expiresIn?:
|
|
38
|
+
expiresIn?: ExpiresIn;
|
|
39
39
|
}
|
|
40
40
|
/** Result of JWS verification */
|
|
41
41
|
interface JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> {
|
|
@@ -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.D7ya3PwS.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.K_6rgVTy.mjs';
|
|
3
3
|
|
|
4
4
|
async function sign(payload, key, options = {}) {
|
|
5
5
|
const { protectedHeader: additionalProtectedHeader } = options;
|
|
@@ -298,8 +298,8 @@ interface JWTClaimValidationOptions {
|
|
|
298
298
|
issuer?: string | string[];
|
|
299
299
|
/** Expected JWT "sub" (Subject) Claim value. Implies presence requirement. */
|
|
300
300
|
subject?: string;
|
|
301
|
-
/** Maximum token age
|
|
302
|
-
maxTokenAge?:
|
|
301
|
+
/** Maximum token age, from the JWT "iat" (Issued At) Claim value. Implies presence requirement. */
|
|
302
|
+
maxTokenAge?: MaxTokenAge;
|
|
303
303
|
/** Clock skew tolerance (in seconds) for validating time-based claims (nbf/exp/iat). */
|
|
304
304
|
clockTolerance?: number;
|
|
305
305
|
/** Expected JWT "typ" (Type) Header Parameter value. Implies presence requirement. */
|
|
@@ -318,4 +318,7 @@ interface JWTClaimValidationOptions {
|
|
|
318
318
|
critical?: string[];
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
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
|
+
type MaxTokenAge = ExpiresIn;
|
|
323
|
+
|
|
324
|
+
export type { JWK_AES_KW as A, JWK_AES_GCM_KW as B, CompositeKey as C, DeriveKeyOptions as D, ExpiresIn as E, JWK_AES_CBC_HMAC as F, GenerateKeyAlgorithm as G, JWK_AES_GCM as H, JWK_PBES2 as I, JWKParameters as J, KeyManagementAlgorithm as K, JWK_ECDH_ES as L, MaxTokenAge as M, JWK_OKP_SIGN as N, JWK_Symmetric_Algorithm as O, JWK_Asymmetric_Algorithm as P, JWKAlgorithm as Q, JWKPEMAlgorithm as R, JoseHeaderParameters as S, JWTClaims as T, UnwrapKeyOptions as U, JWT as V, WrapKeyOptions as W, JWTClaimValidationOptions as X, 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_Public as r, JWK_Private as s, JWK as t, JWKSet as u, JWK_HMAC as v, JWK_RSA_SIGN as w, JWK_RSA_PSS as x, JWK_ECDSA as y, JWK_RSA_ENC as z };
|
|
@@ -46,6 +46,55 @@ function getPlaintextBytes(payload) {
|
|
|
46
46
|
"Plaintext must be a string, Uint8Array, or a JSON-serializable object."
|
|
47
47
|
);
|
|
48
48
|
}
|
|
49
|
+
const TIME_CONSTANTS = Object.freeze({
|
|
50
|
+
s: 1,
|
|
51
|
+
second: 1,
|
|
52
|
+
seconds: 1,
|
|
53
|
+
m: 60,
|
|
54
|
+
minute: 60,
|
|
55
|
+
minutes: 60,
|
|
56
|
+
h: 3600,
|
|
57
|
+
hour: 3600,
|
|
58
|
+
hours: 3600,
|
|
59
|
+
D: 86400,
|
|
60
|
+
day: 86400,
|
|
61
|
+
days: 86400,
|
|
62
|
+
W: 604800,
|
|
63
|
+
week: 604800,
|
|
64
|
+
weeks: 604800,
|
|
65
|
+
M: 2592e3,
|
|
66
|
+
month: 2592e3,
|
|
67
|
+
months: 2592e3,
|
|
68
|
+
Y: 31536e3,
|
|
69
|
+
year: 31536e3,
|
|
70
|
+
years: 31536e3
|
|
71
|
+
});
|
|
72
|
+
const EXPIRES_IN_REGEX = /^(\d+)(s|second|seconds|m|minute|minutes|h|hour|hours|D|day|days|W|week|weeks|M|month|months|Y|year|years)?$/;
|
|
73
|
+
function computeExpiresInSeconds(expiresIn) {
|
|
74
|
+
if (typeof expiresIn === "number") {
|
|
75
|
+
if (!Number.isInteger(expiresIn) || expiresIn <= 0) {
|
|
76
|
+
throw new TypeError(
|
|
77
|
+
"If 'expiresIn' is a number, it must be a positive integer representing seconds."
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return expiresIn;
|
|
81
|
+
}
|
|
82
|
+
if (typeof expiresIn === "string") {
|
|
83
|
+
const match = expiresIn.match(EXPIRES_IN_REGEX);
|
|
84
|
+
if (!match || !match[1]) {
|
|
85
|
+
throw new TypeError(
|
|
86
|
+
"Invalid 'expiresIn' format. Must be a positive integer or a string like '10m', '2h', '7D', etc."
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const value = Number.parseInt(match[1], 10);
|
|
90
|
+
const unit = match[2] || "s";
|
|
91
|
+
return value * TIME_CONSTANTS[unit];
|
|
92
|
+
}
|
|
93
|
+
throw new TypeError(
|
|
94
|
+
"'expiresIn' must be a number or a string representing time duration."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const computeMaxTokenAgeSeconds = computeExpiresInSeconds;
|
|
49
98
|
function computeJwtTimeClaims(payload, headerTyp, expiresIn, currentDate = /* @__PURE__ */ new Date()) {
|
|
50
99
|
if (expiresIn === void 0 || !headerTyp?.toLowerCase().includes("jwt") || !(payload && typeof payload === "object") || payload instanceof Uint8Array || payload.exp) {
|
|
51
100
|
return void 0;
|
|
@@ -53,7 +102,7 @@ function computeJwtTimeClaims(payload, headerTyp, expiresIn, currentDate = /* @_
|
|
|
53
102
|
const now = Math.round(currentDate.getTime() / 1e3);
|
|
54
103
|
const claims = { ...payload };
|
|
55
104
|
claims.iat ||= now;
|
|
56
|
-
claims.exp = claims.iat + expiresIn;
|
|
105
|
+
claims.exp = claims.iat + computeExpiresInSeconds(expiresIn);
|
|
57
106
|
return claims;
|
|
58
107
|
}
|
|
59
108
|
function validateJwtClaims(jwtClaims, options = {}) {
|
|
@@ -118,7 +167,7 @@ function validateJwtClaims(jwtClaims, options = {}) {
|
|
|
118
167
|
`JWT "iat" (Issued At) Claim validation failed: Token was issued in the future (iat: ${new Date(jwtClaims.iat * 1e3).toISOString()})`
|
|
119
168
|
);
|
|
120
169
|
}
|
|
121
|
-
if (jwtClaims.iat < currentTime - options.maxTokenAge - clockTolerance) {
|
|
170
|
+
if (jwtClaims.iat < currentTime - computeMaxTokenAgeSeconds(options.maxTokenAge) - clockTolerance) {
|
|
122
171
|
throw new Error(
|
|
123
172
|
`JWT "iat" (Issued At) Claim validation failed: Token is too old (maxTokenAge: ${options.maxTokenAge}s, iat: ${new Date(jwtClaims.iat * 1e3).toISOString()})`
|
|
124
173
|
);
|
|
@@ -359,7 +408,9 @@ const index = {
|
|
|
359
408
|
base64Encode: base64Encode,
|
|
360
409
|
base64UrlDecode: base64UrlDecode,
|
|
361
410
|
base64UrlEncode: base64UrlEncode,
|
|
411
|
+
computeExpiresInSeconds: computeExpiresInSeconds,
|
|
362
412
|
computeJwtTimeClaims: computeJwtTimeClaims,
|
|
413
|
+
computeMaxTokenAgeSeconds: computeMaxTokenAgeSeconds,
|
|
363
414
|
concatUint8Arrays: concatUint8Arrays,
|
|
364
415
|
decodeMaybeJWTString: decodeMaybeJWTString,
|
|
365
416
|
decodePayloadFromB64UrlSegment: decodePayloadFromB64UrlSegment,
|
|
@@ -384,4 +435,4 @@ const index = {
|
|
|
384
435
|
validateJwtClaims: validateJwtClaims
|
|
385
436
|
};
|
|
386
437
|
|
|
387
|
-
export { isPrivateJWK as A, isPublicJWK as B, isJWTContent as C, decodeMaybeJWTString as D, 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, concatUint8Arrays as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWE as v, assertCryptoKey as w, isAsymmetricJWK as x, maybeArray as y, isSymmetricJWK as z };
|
|
438
|
+
export { isPrivateJWK 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, concatUint8Arrays as p, base64Decode as q, randomBytes as r, sanitizeObject as s, textEncoder as t, base64Encode as u, validateCriticalHeadersJWE as v, assertCryptoKey as w, isAsymmetricJWK as x, maybeArray as y, isSymmetricJWK as z };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './shared/unjwt.
|
|
2
|
-
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeJwtTimeClaims, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes,
|
|
1
|
+
import './shared/unjwt.Dy68jE0N.mjs';
|
|
2
|
+
export { s as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, z as computeExpiresInSeconds, B as computeJwtTimeClaims, A as computeMaxTokenAgeSeconds, f as concatUint8Arrays, v as decodeMaybeJWTString, x as decodePayloadFromB64UrlSegment, w as decodePayloadFromBytes, y as getPlaintextBytes, o as isAsymmetricJWK, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, u as isJWTContent, p as isPrivateJWK, q as isPublicJWK, n as isSymmetricJWK, m as maybeArray, r as randomBytes, F as sanitizeObject, a as textDecoder, t as textEncoder, E as validateCriticalHeadersJWE, D as validateCriticalHeadersJWS, C as validateJwtClaims } from './shared/unjwt.BuQdWrN5.mjs';
|
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { b as applyTypCtyDefaults, w as assertCryptoKey, q as base64Decode, u as base64Encode, e as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, p as concatUint8Arrays, D as decodeMaybeJWTString, n as decodePayloadFromB64UrlSegment, f as decodePayloadFromBytes, g as getPlaintextBytes, x as isAsymmetricJWK, k as isCryptoKey, j as isCryptoKeyPair, a as isJWK, m as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, z as isSymmetricJWK, y as maybeArray, r as randomBytes, s as sanitizeObject, l as textDecoder, t as textEncoder, v as validateCriticalHeadersJWE, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './shared/unjwt.
|
|
1
|
+
export { b as applyTypCtyDefaults, w as assertCryptoKey, q as base64Decode, u as base64Encode, e as base64UrlDecode, d as base64UrlEncode, E as computeExpiresInSeconds, c as computeJwtTimeClaims, F as computeMaxTokenAgeSeconds, p as concatUint8Arrays, D as decodeMaybeJWTString, n as decodePayloadFromB64UrlSegment, f as decodePayloadFromBytes, g as getPlaintextBytes, x as isAsymmetricJWK, k as isCryptoKey, j as isCryptoKeyPair, a as isJWK, m as isJWKSet, C as isJWTContent, A as isPrivateJWK, B as isPublicJWK, z as isSymmetricJWK, y as maybeArray, r as randomBytes, s as sanitizeObject, l as textDecoder, t as textEncoder, v as validateCriticalHeadersJWE, o as validateCriticalHeadersJWS, h as validateJwtClaims } from './shared/unjwt.K_6rgVTy.mjs';
|