unjwt 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { B as JWTClaimValidationOptions, Ft as KeyManagementAlgorithm, N as StrictOmit, Pt as JWK_oct, Q as JWK, Tt as JWK_Public, V as JWTClaims, at as JWKSet, n as ExpiresIn, t as Duration, v as JWSAlgorithm, wt as JWK_Private } from "../../_chunks/index.mjs";
2
- import { a as textDecoder, c as sanitizeObject, i as base64UrlEncode, l as sanitizeObjectCopy, n as base64Encode, o as textEncoder, r as base64UrlDecode, s as safeJsonParse, t as base64Decode, u as secureRandomBytes } from "../../_chunks/libs/unsecure.mjs";
1
+ import { Duration, ExpiresIn, JWK, JWKSet, JWK_EC_Private, JWK_EC_Public, JWK_OKP_Private, JWK_OKP_Public, JWK_Private, JWK_Public, JWK_RSA_Private, JWK_RSA_Public, JWK_oct, JWSAlgorithm, JWTClaimValidationOptions, JWTClaims, KeyManagementAlgorithm, StrictOmit } from "../../_chunks/index.mjs";
2
+ import { base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "../../_chunks/libs/unsecure.mjs";
3
3
  /**
4
4
  * Infer the set of JWS signing algorithms a key unambiguously supports.
5
5
  * Returns `undefined` when inference is not possible — callers must pass
@@ -106,18 +106,50 @@ declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
106
106
  declare function isCryptoKey(key: unknown): key is CryptoKey;
107
107
  /** Type guard for `CryptoKeyPair` — both `publicKey` and `privateKey` must be CryptoKeys. */
108
108
  declare const isCryptoKeyPair: (key: any) => key is CryptoKeyPair;
109
- /** Returns true if the JWK is a symmetric (oct) key. */
110
- declare function isSymmetricJWK(key: unknown): key is Extract<JWK, JWK_oct>;
111
- /** Returns true if the JWK is an asymmetric (RSA, EC, OKP) key. */
109
+ /**
110
+ * Returns true if the JWK is a symmetric (oct) key.
111
+ *
112
+ * NOTE: a symmetric JWK's `k` is always secret key material. {@link isPrivateJWK}
113
+ * returns `false` for `oct` keys (it only detects asymmetric `d`), so use this
114
+ * guard — not `!isPrivateJWK(key)` — when deciding whether a JWK is safe to
115
+ * publish.
116
+ *
117
+ * The `T` inference preserves the caller's narrowed alg type — passing a
118
+ * `JWK_oct<"HS256">` refines to `JWK_oct<"HS256">`, not `JWK_oct<string>`.
119
+ */
120
+ declare function isSymmetricJWK<T>(key: T): key is Extract<T, JWK_oct>;
121
+ declare function isSymmetricJWK(key: unknown): key is JWK_oct;
122
+ /**
123
+ * Returns true if the JWK is an asymmetric (RSA, EC, OKP) key.
124
+ *
125
+ * The `T` inference preserves the caller's narrowed alg type — passing a
126
+ * `JWK_EC<"ES256">` refines to `JWK_EC<"ES256">`, not `JWK_EC<string>`,
127
+ * and so on for RSA and OKP.
128
+ */
129
+ declare function isAsymmetricJWK<T>(key: T): key is Exclude<T, JWK_oct>;
112
130
  declare function isAsymmetricJWK(key: unknown): key is Exclude<JWK, JWK_oct>;
113
131
  /**
114
- * Type guard that checks if the provided JWK contains private key material.
115
- * It relies purely on the presence of private components (e.g. "d"), not on the alg value.
132
+ * Type guard that checks if the provided JWK contains *asymmetric* private key
133
+ * material. It relies purely on the presence of private components (e.g. "d"),
134
+ * not on the alg value.
135
+ *
136
+ * WARNING: this returns `false` for symmetric (`oct`) keys — their `k` is secret
137
+ * material too, but it is not a `d` component. `!isPrivateJWK(key)` is therefore
138
+ * NOT a "safe to share" check: it passes every `oct` key. To filter keys that
139
+ * are safe to publish, use {@link isPublicJWK} (true only for asymmetric public
140
+ * keys); to detect any secret material, combine with {@link isSymmetricJWK}.
141
+ *
142
+ * Preserves narrow alg types from the caller.
116
143
  */
144
+ declare function isPrivateJWK<T>(key: T): key is Extract<T, JWK_EC_Private | JWK_OKP_Private | JWK_RSA_Private>;
117
145
  declare function isPrivateJWK(key: unknown): key is JWK_Private;
118
146
  /**
119
- * Type guard that checks if the provided JWK is a public (asymmetric) key.
120
- * This checks for the presence of public components and absence of private material.
147
+ * Type guard that checks if the provided JWK is a public (asymmetric) key:
148
+ * public components present, no private `d`. Returns `false` for `oct` keys
149
+ * (which are always secret), making it the correct "safe to publish" predicate.
150
+ *
151
+ * Preserves narrow alg types from the caller.
121
152
  */
153
+ declare function isPublicJWK<T>(key: T): key is Exclude<Extract<T, JWK_EC_Public | JWK_OKP_Public | JWK_RSA_Public>, JWK_Private>;
122
154
  declare function isPublicJWK(key: unknown): key is JWK_Public;
123
- export { ComputeJwtTimeClaimsOptions, StrictOmit, applyTypCtyDefaults, assertCryptoKey, base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, computeDurationInSeconds, computeExpiresInSeconds, computeJwtTimeClaims, computeMaxTokenAgeSeconds, concatUint8Arrays, decodeMaybeJWTString, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
155
+ export { ComputeJwtTimeClaimsOptions, type StrictOmit, applyTypCtyDefaults, assertCryptoKey, base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, computeDurationInSeconds, computeExpiresInSeconds, computeJwtTimeClaims, computeMaxTokenAgeSeconds, concatUint8Arrays, decodeMaybeJWTString, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
@@ -1,3 +1,3 @@
1
- import { C as validateCriticalHeadersJWS, E as inferJWSAllowedAlgorithms, S as validateCriticalHeadersJWE, T as inferJWEAllowedAlgorithms, _ as decodeMaybeJWTString, a as isCryptoKeyPair, b as getPlaintextBytes, c as isPrivateJWK, d as maybeArray, f as applyTypCtyDefaults, g as computeMaxTokenAgeSeconds, h as computeJwtTimeClaims, i as isCryptoKey, l as isPublicJWK, m as computeExpiresInSeconds, n as concatUint8Arrays, o as isJWK, p as computeDurationInSeconds, r as isAsymmetricJWK, s as isJWKSet, t as assertCryptoKey, u as isSymmetricJWK, v as decodePayloadFromB64UrlSegment, w as validateJwtClaims, x as isJWTContent, y as decodePayloadFromBytes } from "../../_chunks/utils.mjs";
2
- import { a as base64UrlEncode, c as safeJsonParse, i as base64UrlDecode, l as sanitizeObject, n as base64Decode, o as textDecoder, r as base64Encode, s as textEncoder, t as secureRandomBytes, u as sanitizeObjectCopy } from "../../_chunks/libs/unsecure.mjs";
1
+ import { applyTypCtyDefaults, assertCryptoKey, computeDurationInSeconds, computeExpiresInSeconds, computeJwtTimeClaims, computeMaxTokenAgeSeconds, concatUint8Arrays, decodeMaybeJWTString, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims } from "../../_chunks/utils.mjs";
2
+ import { base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "../../_chunks/libs/unsecure.mjs";
3
3
  export { applyTypCtyDefaults, assertCryptoKey, base64Decode, base64Encode, base64UrlDecode, base64UrlEncode, computeDurationInSeconds, computeExpiresInSeconds, computeJwtTimeClaims, computeMaxTokenAgeSeconds, concatUint8Arrays, decodeMaybeJWTString, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as JWKAlgorithm, A as JWSSignOptions, At as JWK_RSA_Public, B as JWTClaimValidationOptions, C as JWSMultiSignOptions, Ct as JWK_Pair, D as JWSMultiVerifyOutcome, Dt as JWK_RSA_ENC, E as JWSMultiVerifyOptions, Et as JWK_RSA, F as JWTErrorCauseMap, Ft as KeyManagementAlgorithm, G as DeriveKeyOptions, H as JoseHeaderParameters, I as JWTErrorCode, It as UnwrapKeyOptions, J as GenerateJWKReturn, K as DeriveKeyReturn, L as isJWTError, Lt as WrapKeyOptions, M as JWSVerifyResult, Mt as JWK_Symmetric, Nt as JWK_Symmetric_Algorithm, O as JWSMultiVerifyResult, Ot as JWK_RSA_PSS, P as JWTError, Pt as JWK_oct, Q as JWK, R as JOSEPayload, Rt as WrapKeyResult, S as JWSHeaderParameters, St as JWK_PBES2, T as JWSMultiVerifyAllOptions, Tt as JWK_Public, U as CompositeKey, V as JWTClaims, W as ContentEncryptionAlgorithm, X as GenerateKeyOptions, Y as GenerateKeyAlgorithm, Z as GenerateKeyReturn, _ as JWEProtectedHeader, _t as JWK_HMAC, a as JWEDecryptOptions, at as JWKSet, b as JWSGeneralSerialization, bt as JWK_OKP_Public, c as JWEFlattenedSerialization, ct as JWK_AES_GCM_KW, d as JWEHeaderParameters, dt as JWK_Asymmetric_Algorithm, et as JWKCacheAdapter, f as JWEKeyManagementHeaderParameters, ft as JWK_EC, g as JWEMultiRecipient, gt as JWK_EC_Public, h as JWEMultiEncryptOptions, ht as JWK_EC_Private, i as NotBeforeIn, it as JWKParameters, j as JWSVerifyOptions, jt as JWK_RSA_SIGN, k as JWSProtectedHeader, kt as JWK_RSA_Private, l as JWEGeneralRecipient, lt as JWK_AES_KW, m as JWEMultiDecryptResult, mt as JWK_ECDSA, n as ExpiresIn, nt as JWKLookupFunctionHeader, o as JWEDecryptResult, ot as JWK_AES_CBC_HMAC, p as JWEMultiDecryptOptions, pt as JWK_ECDH_ES, q as GenerateJWKOptions, r as MaxTokenAge, rt as JWKPEMAlgorithm, s as JWEEncryptOptions, st as JWK_AES_GCM, t as Duration, tt as JWKLookupFunction, u as JWEGeneralSerialization, ut as JWK_Asymmetric, v as JWSAlgorithm, vt as JWK_OKP, w as JWSMultiSigner, wt as JWK_Private, x as JWSGeneralSignature, xt as JWK_OKP_SIGN, y as JWSFlattenedSerialization, yt as JWK_OKP_Private, z as JWT } from "./_chunks/index.mjs";
1
+ import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JOSEPayload, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTError, JWTErrorCauseMap, JWTErrorCode, JoseHeaderParameters, KeyManagementAlgorithm, MaxTokenAge, NotBeforeIn, UnwrapKeyOptions, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor, isJWTError } from "./_chunks/index.mjs";
2
2
  import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, unwrapKey, wrapKey } from "./core/jwk.mjs";
3
- import { a as generalToFlattened, i as encryptMulti, n as encrypt, r as decryptMulti, t as decrypt } from "./_chunks/jwe.mjs";
4
- import { a as verifyMulti, i as signMulti, n as verify, o as verifyMultiAll, r as generalToFlattenedJWS, t as sign } from "./_chunks/jws.mjs";
3
+ import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/jwe.mjs";
4
+ import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/jws.mjs";
5
5
  import { assertCryptoKey, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isPrivateJWK, isPublicJWK, isSymmetricJWK, validateJwtClaims } from "./core/utils/index.mjs";
6
- export { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, JOSEPayload, JWEDecryptOptions, JWEDecryptResult, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKPEMAlgorithm, JWKParameters, JWKSet, JWK_AES_CBC_HMAC, JWK_AES_GCM, JWK_AES_GCM_KW, JWK_AES_KW, JWK_Asymmetric, JWK_Asymmetric_Algorithm, JWK_EC, JWK_ECDH_ES, JWK_ECDSA, JWK_EC_Private, JWK_EC_Public, JWK_HMAC, JWK_OKP, JWK_OKP_Private, JWK_OKP_Public, JWK_OKP_SIGN, JWK_PBES2, JWK_Pair, JWK_Private, JWK_Public, JWK_RSA, JWK_RSA_ENC, JWK_RSA_PSS, JWK_RSA_Private, JWK_RSA_Public, JWK_RSA_SIGN, JWK_Symmetric, JWK_Symmetric_Algorithm, JWK_oct, JWSAlgorithm, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignOptions, JWSVerifyOptions, JWSVerifyResult, JWT, JWTClaimValidationOptions, JWTClaims, JWTError, type JWTErrorCauseMap, type JWTErrorCode, JoseHeaderParameters, KeyManagementAlgorithm, MaxTokenAge, NotBeforeIn, UnwrapKeyOptions, WeakMapJWKCache, WrapKeyOptions, WrapKeyResult, assertCryptoKey, clearJWKCache, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, configureJWKCache, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptMulti, exportKey, exportPEM, exportToPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, sign, signMulti, unwrapKey, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
6
+ export { type CompositeKey, type ContentEncryptionAlgorithm, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type JOSEPayload, type JWEAsymmetricPrivateJWK, type JWEAsymmetricPublicJWK, type JWEDecryptJWK, type JWEDecryptOptions, type JWEDecryptResult, type JWEEncryptJWK, type JWEEncryptOptions, type JWEFlattenedSerialization, type JWEGeneralRecipient, type JWEGeneralSerialization, type JWEHeaderParameters, type JWEKeyManagementHeaderParameters, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKPEMAlgorithm, type JWKParameters, type JWKSet, type JWK_AES_CBC_HMAC, type JWK_AES_GCM, type JWK_AES_GCM_KW, type JWK_AES_KW, type JWK_Asymmetric, type JWK_Asymmetric_Algorithm, type JWK_EC, type JWK_ECDH_ES, type JWK_ECDSA, type JWK_EC_Private, type JWK_EC_Public, type JWK_HMAC, type JWK_OKP, type JWK_OKP_Private, type JWK_OKP_Public, type JWK_OKP_SIGN, type JWK_PBES2, type JWK_Pair, type JWK_Private, type JWK_Public, type JWK_RSA, type JWK_RSA_ENC, type JWK_RSA_PSS, type JWK_RSA_Private, type JWK_RSA_Public, type JWK_RSA_SIGN, type JWK_Symmetric, type JWK_Symmetric_Algorithm, type JWK_oct, type JWSAlgorithm, type JWSAsymmetricPrivateJWK, type JWSAsymmetricPublicJWK, type JWSFlattenedSerialization, type JWSGeneralSerialization, type JWSGeneralSignature, type JWSHeaderParameters, type JWSMultiSignOptions, type JWSMultiSigner, type JWSMultiVerifyAllOptions, type JWSMultiVerifyOptions, type JWSMultiVerifyOutcome, type JWSMultiVerifyResult, type JWSProtectedHeader, type JWSSignJWK, type JWSSignOptions, type JWSVerifyJWK, type JWSVerifyOptions, type JWSVerifyResult, type JWT, type JWTClaimValidationOptions, type JWTClaims, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type JoseHeaderParameters, type KeyManagementAlgorithm, type MaxTokenAge, type NotBeforeIn, type UnwrapKeyOptions, type UnwrappingKeyFor, WeakMapJWKCache, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, assertCryptoKey, clearJWKCache, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, configureJWKCache, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptMulti, exportKey, exportPEM, exportToPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, sign, signMulti, unwrapKey, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { D as JWTError, O as isJWTError, a as isCryptoKeyPair, c as isPrivateJWK, g as computeMaxTokenAgeSeconds, i as isCryptoKey, l as isPublicJWK, m as computeExpiresInSeconds, o as isJWK, p as computeDurationInSeconds, r as isAsymmetricJWK, s as isJWKSet, t as assertCryptoKey, u as isSymmetricJWK, w as validateJwtClaims } from "./_chunks/utils.mjs";
2
- import { _ as unwrapKey, a as deriveKeyFromPassword, c as exportPEM, d as generateKey, f as getJWKFromSet, g as importPEM, h as importKey, i as deriveJWKFromPassword, l as exportToPEM, m as importFromPEM, n as clearJWKCache, o as deriveSharedSecret, p as getJWKsFromSet, r as configureJWKCache, s as exportKey, t as WeakMapJWKCache, u as generateJWK, v as wrapKey } from "./_chunks/jwk.mjs";
3
- import { a as verifyMulti, i as signMulti, n as verify, o as verifyMultiAll, r as generalToFlattenedJWS, t as sign } from "./_chunks/jws.mjs";
4
- import { a as generalToFlattened, i as encryptMulti, n as encrypt, r as decryptMulti, t as decrypt } from "./_chunks/jwe.mjs";
1
+ import { JWTError, assertCryptoKey, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, validateJwtClaims } from "./_chunks/utils.mjs";
2
+ import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, unwrapKey, wrapKey } from "./_chunks/jwk.mjs";
3
+ import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/jws.mjs";
4
+ import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/jwe.mjs";
5
5
  export { JWTError, WeakMapJWKCache, assertCryptoKey, clearJWKCache, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, configureJWKCache, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptMulti, exportKey, exportPEM, exportToPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, sign, signMulti, unwrapKey, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Low-level JWT utilities",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -51,42 +51,54 @@
51
51
  "./adapters/h3v2": {
52
52
  "types": "./dist/adapters/h3v2/index.d.mts",
53
53
  "default": "./dist/adapters/h3v2/index.mjs"
54
+ },
55
+ "./adapters/elysia": {
56
+ "types": "./dist/adapters/elysia/index.d.mts",
57
+ "default": "./dist/adapters/elysia/index.mjs"
54
58
  }
55
59
  },
56
60
  "devDependencies": {
57
- "@types/node": "^24",
61
+ "@types/node": "^25",
58
62
  "@types/supertest": "^7.2.0",
59
- "@typescript/native-preview": "7.0.0-dev.20260419.1",
60
- "@vitest/coverage-v8": "^4.1.4",
63
+ "@typescript/native-preview": "7.0.0-dev.20260611.2",
64
+ "@vitest/coverage-v8": "^4.1.8",
61
65
  "automd": "^0.4.3",
62
66
  "changelogen": "^0.6.2",
63
67
  "cookie-esv1": "npm:cookie-es@^1.2.3",
64
68
  "cookie-esv3": "npm:cookie-es@^3.1.1",
69
+ "elysia": "^1.4.9",
65
70
  "h3v1": "npm:h3@^1.15.11",
66
- "h3v2": "npm:h3@^2.0.1-rc.20",
67
- "jose": "^6.2.2",
71
+ "h3v2": "npm:h3@^2.0.1-rc.22",
72
+ "jose": "^6.2.3",
68
73
  "nano-staged": "^1.0.2",
69
- "obuild": "^0.4.33",
70
- "oxfmt": "^0.45.0",
71
- "oxlint": "^1.60.0",
72
- "rolldown": "1.0.0-rc.16",
73
- "rou3": "^0.8.1",
74
+ "obuild": "^0.4.36",
75
+ "oxfmt": "^0.54.0",
76
+ "oxlint": "^1.69.0",
77
+ "rolldown": "1.1.1",
74
78
  "simple-git-hooks": "^2.13.1",
75
79
  "supertest": "^7.2.2",
76
80
  "typescript": "^6.0.3",
77
- "unsecure": "^0.2.1",
78
- "vitest": "^4.1.4"
81
+ "unsecure": "^0.2.2",
82
+ "vitest": "^4.1.8"
79
83
  },
80
84
  "peerDependencies": {
81
85
  "cookie-es": "^1.2.3 || ^3.1.1",
82
- "h3": "^1.15.4 || >=2.0.1-rc.20 || ^2.0.1"
86
+ "elysia": "^1.4.0",
87
+ "h3": "^1.15.4 || >=2.0.1-rc.22 || ^2.0.1",
88
+ "rou3": "^0.8.1"
83
89
  },
84
90
  "peerDependenciesMeta": {
85
91
  "cookie-es": {
86
92
  "optional": true
87
93
  },
94
+ "elysia": {
95
+ "optional": true
96
+ },
88
97
  "h3": {
89
98
  "optional": true
99
+ },
100
+ "rou3": {
101
+ "optional": true
90
102
  }
91
103
  },
92
104
  "resolutions": {
@@ -1,63 +0,0 @@
1
- # Licenses of Bundled Dependencies
2
-
3
- The published artifact additionally contains code with the following licenses:
4
- MIT
5
-
6
- # Bundled Dependencies
7
-
8
- ## rou3
9
-
10
- License: MIT
11
- Repository: https://github.com/h3js/rou3
12
-
13
- > MIT License
14
- >
15
- > Copyright (c) Pooya Parsa <pooya@pi0.io>
16
- >
17
- > Permission is hereby granted, free of charge, to any person obtaining a copy
18
- > of this software and associated documentation files (the "Software"), to deal
19
- > in the Software without restriction, including without limitation the rights
20
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- > copies of the Software, and to permit persons to whom the Software is
22
- > furnished to do so, subject to the following conditions:
23
- >
24
- > The above copyright notice and this permission notice shall be included in all
25
- > copies or substantial portions of the Software.
26
- >
27
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
- > SOFTWARE.
34
-
35
- ---------------------------------------
36
-
37
- ## unsecure
38
-
39
- License: MIT
40
- By: Sandro Circi
41
- Repository: https://github.com/sandros94/unsecure
42
-
43
- > MIT License
44
- >
45
- > Copyright (c) 2025 Sandro Circi
46
- >
47
- > Permission is hereby granted, free of charge, to any person obtaining a copy
48
- > of this software and associated documentation files (the "Software"), to deal
49
- > in the Software without restriction, including without limitation the rights
50
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
- > copies of the Software, and to permit persons to whom the Software is
52
- > furnished to do so, subject to the following conditions:
53
- >
54
- > The above copyright notice and this permission notice shall be included in all
55
- > copies or substantial portions of the Software.
56
- >
57
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
- > SOFTWARE.
@@ -1,5 +0,0 @@
1
- const NullProtoObj = /* @__PURE__ */ (() => {
2
- const e = function() {};
3
- return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
4
- })();
5
- export { NullProtoObj as t };