unjwt 0.7.3 → 0.8.1

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.
Files changed (39) hide show
  1. package/README.md +4 -4
  2. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  3. package/dist/_chunks/_codec-jwe.d.mts +170 -0
  4. package/dist/_chunks/_codec-jws.mjs +878 -0
  5. package/dist/_chunks/_internal.d.mts +7 -0
  6. package/dist/_chunks/_jwt-internal.mjs +388 -0
  7. package/dist/_chunks/algorithms.mjs +186 -0
  8. package/dist/_chunks/index.d.mts +500 -808
  9. package/dist/_chunks/index2.d.mts +11 -0
  10. package/dist/_chunks/index3.d.mts +108 -0
  11. package/dist/_chunks/jwe.d.mts +43 -66
  12. package/dist/_chunks/jwe.mjs +384 -252
  13. package/dist/_chunks/jwk.mjs +1371 -607
  14. package/dist/_chunks/jws.d.mts +48 -103
  15. package/dist/_chunks/jws.mjs +372 -184
  16. package/dist/_chunks/jwt.d.mts +56 -0
  17. package/dist/_chunks/libs/unsecure.d.mts +164 -85
  18. package/dist/_chunks/libs/unsecure.mjs +390 -123
  19. package/dist/adapters/elysia/index.d.mts +33 -171
  20. package/dist/adapters/elysia/index.mjs +106 -575
  21. package/dist/adapters/h3v1/index.d.mts +59 -344
  22. package/dist/adapters/h3v1/index.mjs +114 -619
  23. package/dist/adapters/h3v2/index.d.mts +58 -326
  24. package/dist/adapters/h3v2/index.mjs +108 -611
  25. package/dist/core/internal.d.mts +2 -0
  26. package/dist/core/internal.mjs +1 -0
  27. package/dist/core/jwe.d.mts +4 -2
  28. package/dist/core/jwe.mjs +4 -2
  29. package/dist/core/jwk.d.mts +183 -371
  30. package/dist/core/jwk.mjs +4 -3
  31. package/dist/core/jws.d.mts +4 -2
  32. package/dist/core/jws.mjs +4 -2
  33. package/dist/core/utils/index.d.mts +5 -158
  34. package/dist/core/utils/index.mjs +12 -3
  35. package/dist/index.d.mts +8 -4
  36. package/dist/index.mjs +6 -3
  37. package/package.json +30 -30
  38. package/dist/_chunks/_internal.mjs +0 -88
  39. package/dist/_chunks/utils.mjs +0 -392
@@ -1,3 +1,5 @@
1
- import { JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWTError, JWTErrorCauseMap, JWTErrorCode, isJWTError } from "../_chunks/index.mjs";
1
+ import { UnsecureError, UnsecureErrorCode } from "../_chunks/libs/unsecure.mjs";
2
+ import { JOSEPayloadMode, JOSEPayloadTypeMap, JWSAlgorithm, JWSAsymmetricPrivateJWK, JWSAsymmetricPublicJWK, JWSFlattenedSerialization, JWSGeneralSerialization, JWSGeneralSignature, JWSHeaderParameters, JWSMultiSignOptions, JWSMultiSigner, JWSMultiVerifyAllOptions, JWSMultiVerifyOptions, JWSMultiVerifyOutcome, JWSMultiVerifyResult, JWSProtectedHeader, JWSSignJWK, JWSSignOptions, JWSVerifyJWK, JWSVerifyOptions, JWSVerifyResult, JWTError, JWTErrorCauseMap, JWTErrorCode, KnownJWTErrorCode, PayloadOf, isJWTError, isUnsecureError } from "../_chunks/index.mjs";
3
+ import { DEFAULT_JOSE_LIMITS } from "../_chunks/_internal.mjs";
2
4
  import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "../_chunks/jws.mjs";
3
- export { 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, JWTError, type JWTErrorCauseMap, type JWTErrorCode, generalToFlattenedJWS, isJWTError, sign, signMulti, verify, verifyMulti, verifyMultiAll };
5
+ export { DEFAULT_JOSE_LIMITS, type JOSEPayloadMode, type JOSEPayloadTypeMap, 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, JWTError, type JWTErrorCauseMap, type JWTErrorCode, type KnownJWTErrorCode, type PayloadOf, UnsecureError, type UnsecureErrorCode, generalToFlattenedJWS, isJWTError, isUnsecureError, sign, signMulti, verify, verifyMulti, verifyMultiAll };
package/dist/core/jws.mjs CHANGED
@@ -1,3 +1,5 @@
1
- import { JWTError, isJWTError } from "../_chunks/utils.mjs";
1
+ import { UnsecureError } from "../_chunks/libs/unsecure.mjs";
2
+ import { JWTError, isJWTError, isUnsecureError } from "../_chunks/_jwt-internal.mjs";
3
+ import { DEFAULT_JOSE_LIMITS } from "../_chunks/jwk.mjs";
2
4
  import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "../_chunks/jws.mjs";
3
- export { JWTError, generalToFlattenedJWS, isJWTError, sign, signMulti, verify, verifyMulti, verifyMultiAll };
5
+ export { DEFAULT_JOSE_LIMITS, JWTError, UnsecureError, generalToFlattenedJWS, isJWTError, isUnsecureError, sign, signMulti, verify, verifyMulti, verifyMultiAll };
@@ -1,158 +1,5 @@
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
- /**
4
- * Infer the set of JWS signing algorithms a key unambiguously supports.
5
- * Returns `undefined` when inference is not possible — callers must pass
6
- * `options.algorithms` explicitly (raw bytes, ambiguous JWK, lookup functions, ...).
7
- */
8
- declare function inferJWSAllowedAlgorithms(key: unknown): JWSAlgorithm[] | undefined;
9
- /**
10
- * Infer the set of JWE key-management algorithms a key unambiguously supports.
11
- * Returns `undefined` when inference is not possible — callers must pass
12
- * `options.algorithms` explicitly.
13
- *
14
- * Passwords (`string` / `Uint8Array`) infer to the three PBES2 variants.
15
- */
16
- declare function inferJWEAllowedAlgorithms(key: unknown): KeyManagementAlgorithm[] | undefined;
17
- /**
18
- * Apply default typ/cty semantics shared by JWS & JWE.
19
- * - If typ is undefined and payload is a non-Uint8Array object, set typ="JWT".
20
- * - If typ is "JWT" and payload is a non-Uint8Array object, ensure cty defaults to "application/json".
21
- */
22
- declare function applyTypCtyDefaults<T extends {
23
- typ?: string;
24
- cty?: string;
25
- }>(header: T, payload: unknown): T;
26
- /** Returns true when headers indicate JSON content. */
27
- declare function isJWTContent(header: {
28
- typ?: string;
29
- cty?: string;
30
- } | undefined): boolean;
31
- /** Parse a decoded string as JSON when it looks like a JSON object or array, otherwise return the string verbatim. */
32
- declare function decodeMaybeJWTString<T = unknown>(decodedString: string): T | string;
33
- /** Decode raw payload bytes honoring `forceUint8Array`. */
34
- declare function decodePayloadFromBytes<T = unknown>(bytes: Uint8Array<ArrayBuffer>, forceUint8Array?: boolean): T | Uint8Array<ArrayBuffer> | string;
35
- /** Decode a Base64URL-encoded payload segment honoring `forceUint8Array`. */
36
- declare function decodePayloadFromB64UrlSegment<T = unknown>(payloadEncoded: string, forceUint8Array?: boolean): T | Uint8Array<ArrayBuffer> | string;
37
- /** Convert plaintext input to bytes, shared by JWS & JWE when preparing payload. */
38
- declare function getPlaintextBytes(payload: string | Uint8Array<ArrayBuffer> | Record<string, unknown>): Uint8Array<ArrayBuffer>;
39
- /**
40
- * Parse a {@link Duration} (integer seconds or shorthand string like `"10m"`)
41
- * into a positive integer number of seconds. Used for `expiresIn`-style inputs
42
- * where `0` / negatives are invalid.
43
- *
44
- * For inputs that legitimately permit `0` (e.g. `notBeforeIn: 0`), compute the
45
- * bounds at the call site instead.
46
- */
47
- declare function computeDurationInSeconds(duration: Duration): number;
48
- /** @deprecated Renamed to {@link computeDurationInSeconds} in v0.7.0. */
49
- declare const computeExpiresInSeconds: (expiresIn: ExpiresIn) => number;
50
- /** @deprecated Renamed to {@link computeDurationInSeconds} in v0.7.0. */
51
- declare const computeMaxTokenAgeSeconds: (expiresIn: ExpiresIn) => number;
52
- /** Options for {@link computeJwtTimeClaims}. */
53
- interface ComputeJwtTimeClaimsOptions {
54
- /** Reference moment for `iat` (and for `expiresIn` / `notBeforeIn` math). Defaults to `new Date()`. */
55
- currentDate?: Date;
56
- /** Duration until `exp`, relative to `currentDate`. Mutually exclusive with `expiresAt`. */
57
- expiresIn?: ExpiresIn;
58
- /** Absolute moment for `exp`. Mutually exclusive with `expiresIn`. */
59
- expiresAt?: Date;
60
- /**
61
- * Duration from `iat` before which the JWT must not be accepted.
62
- * `0` is allowed and means `nbf = iat` (explicit temporal floor at sign time).
63
- * Mutually exclusive with `notBeforeAt`.
64
- */
65
- notBeforeIn?: ExpiresIn;
66
- /** Absolute moment for `nbf` (RFC 7519 §4.1.5). Mutually exclusive with `notBeforeIn`. */
67
- notBeforeAt?: Date;
68
- }
69
- /**
70
- * Compute `iat` + optional `exp` / `nbf` for any JSON-object payload.
71
- *
72
- * Returns a shallow-cloned payload with the time claims added, or `undefined`
73
- * when no hint applies (no expiry/nbf provided, non-object payload, or the
74
- * payload already carries the corresponding claim).
75
- *
76
- * `expiresIn` / `expiresAt` and `notBeforeIn` / `notBeforeAt` are each mutually
77
- * exclusive pairs — passing both within a pair throws `ERR_JWT_CLAIM_INVALID`.
78
- * Invalid `Date` inputs (NaN `.getTime()`) and negative `notBeforeIn` durations
79
- * also throw.
80
- */
81
- declare function computeJwtTimeClaims(payload: unknown, options?: ComputeJwtTimeClaimsOptions): JWTClaims | undefined;
82
- /** Validate JWT claims under JWS verification rules (or custom JWE implementations). */
83
- declare function validateJwtClaims(jwtClaims: JWTClaims, options?: JWTClaimValidationOptions): void;
84
- /** Validate critical headers in JWS semantics. */
85
- declare function validateCriticalHeadersJWS(protectedHeader: {
86
- crit?: string[];
87
- } & Record<string, any>, recognizedHeaders?: string[]): void;
88
- /** Validate critical headers in JWE semantics. */
89
- declare function validateCriticalHeadersJWE(protectedHeader: {
90
- crit?: string[];
91
- } & Record<string, any>, recognizedHeaders?: string[]): void;
92
- /** Concatenate multiple `Uint8Array`s into a single contiguous buffer. */
93
- declare function concatUint8Arrays(...arrays: Readonly<Uint8Array<ArrayBuffer>[]>): Uint8Array<ArrayBuffer>;
94
- /** Wrap a value in an array; returns the array unchanged if already an array. */
95
- declare function maybeArray<T>(item: T | T[]): T[];
96
- /**
97
- * Type guard for {@link JWK} — an object whose `kty` this library models
98
- * (`"oct"`/`"RSA"`/`"EC"`/`"OKP"`).
99
- */
100
- declare function isJWK(key: any): key is JWK;
101
- /** Type guard for {@link JWKSet} — checks for an object with a `keys` array. */
102
- declare function isJWKSet(key: any): key is JWKSet;
103
- /** Asserts that `key` is a `CryptoKey`; throws `TypeError` otherwise. */
104
- declare function assertCryptoKey(key: unknown): asserts key is CryptoKey;
105
- /**
106
- * Type guard for `CryptoKey`. Uses `Symbol.toStringTag` instead of `instanceof`
107
- * so it works across worker / realm boundaries where `CryptoKey` identities differ.
108
- */
109
- declare function isCryptoKey(key: unknown): key is CryptoKey;
110
- /** Type guard for `CryptoKeyPair` — both `publicKey` and `privateKey` must be CryptoKeys. */
111
- declare const isCryptoKeyPair: (key: any) => key is CryptoKeyPair;
112
- /**
113
- * Returns true if the JWK is a symmetric (oct) key.
114
- *
115
- * NOTE: a symmetric JWK's `k` is always secret key material. {@link isPrivateJWK}
116
- * returns `false` for `oct` keys (it only detects asymmetric `d`), so use this
117
- * guard — not `!isPrivateJWK(key)` — when deciding whether a JWK is safe to
118
- * publish.
119
- *
120
- * The `T` inference preserves the caller's narrowed alg type — passing a
121
- * `JWK_oct<"HS256">` refines to `JWK_oct<"HS256">`, not `JWK_oct<string>`.
122
- */
123
- declare function isSymmetricJWK<T>(key: T): key is Extract<T, JWK_oct>;
124
- declare function isSymmetricJWK(key: unknown): key is JWK_oct;
125
- /**
126
- * Returns true if the JWK is an asymmetric (RSA, EC, OKP) key.
127
- *
128
- * The `T` inference preserves the caller's narrowed alg type — passing a
129
- * `JWK_EC<"ES256">` refines to `JWK_EC<"ES256">`, not `JWK_EC<string>`,
130
- * and so on for RSA and OKP.
131
- */
132
- declare function isAsymmetricJWK<T>(key: T): key is Exclude<T, JWK_oct>;
133
- declare function isAsymmetricJWK(key: unknown): key is Exclude<JWK, JWK_oct>;
134
- /**
135
- * Type guard that checks if the provided JWK contains *asymmetric* private key
136
- * material. It relies purely on the presence of private components (e.g. "d"),
137
- * not on the alg value.
138
- *
139
- * WARNING: this returns `false` for symmetric (`oct`) keys — their `k` is secret
140
- * material too, but it is not a `d` component. `!isPrivateJWK(key)` is therefore
141
- * NOT a "safe to share" check: it passes every `oct` key. To filter keys that
142
- * are safe to publish, use {@link isPublicJWK} (true only for asymmetric public
143
- * keys); to detect any secret material, combine with {@link isSymmetricJWK}.
144
- *
145
- * Preserves narrow alg types from the caller.
146
- */
147
- declare function isPrivateJWK<T>(key: T): key is Extract<T, JWK_EC_Private | JWK_OKP_Private | JWK_RSA_Private>;
148
- declare function isPrivateJWK(key: unknown): key is JWK_Private;
149
- /**
150
- * Type guard that checks if the provided JWK is a public (asymmetric) key:
151
- * public components present, no private `d`. Returns `false` for `oct` keys
152
- * (which are always secret), making it the correct "safe to publish" predicate.
153
- *
154
- * Preserves narrow alg types from the caller.
155
- */
156
- declare function isPublicJWK<T>(key: T): key is Exclude<Extract<T, JWK_EC_Public | JWK_OKP_Public | JWK_RSA_Public>, JWK_Private>;
157
- declare function isPublicJWK(key: unknown): key is JWK_Public;
158
- 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
+ import { BytesSource, DecodeOptions, DecodeReturnAs, UnsecureError, UnsecureErrorCode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "../../_chunks/libs/unsecure.mjs";
2
+ import { StrictOmit, isUnsecureError } from "../../_chunks/index.mjs";
3
+ import { computeDurationInSeconds, isJWTContent, validateJwtClaims } from "../../_chunks/jwt.mjs";
4
+ import { ComputeJwtTimeClaimsOptions, DecodePayloadOptions, InferAlgorithmsOptions, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeJwtTimeClaims, concatUint8Arrays, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, validateCriticalHeadersJWE, validateCriticalHeadersJWS } from "../../_chunks/index3.mjs";
5
+ export { type BytesSource, ComputeJwtTimeClaimsOptions, type DecodeOptions, DecodePayloadOptions, type DecodeReturnAs, type InferAlgorithmsOptions, type StrictOmit, UnsecureError, type UnsecureErrorCode, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeDurationInSeconds, computeJwtTimeClaims, concatUint8Arrays, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
@@ -1,3 +1,12 @@
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
- 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 };
1
+ import { UnsecureError, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "../../_chunks/libs/unsecure.mjs";
2
+ import { applyTypDefault, assertCritShape as assertCritShape$1, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeDurationInSeconds, computeJwtTimeClaims as computeJwtTimeClaims$1, concatUint8Arrays, getPlaintextBytes as getPlaintextBytes$1, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, parsePayloadBytes, parsePayloadSegment, validateCriticalHeadersJWE as validateCriticalHeadersJWE$1, validateCriticalHeadersJWS as validateCriticalHeadersJWS$1, validateJwtClaims } from "../../_chunks/_jwt-internal.mjs";
3
+ import { inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms } from "../../_chunks/algorithms.mjs";
4
+ const applyTypCtyDefaults = applyTypDefault;
5
+ const decodePayloadFromBytes = parsePayloadBytes;
6
+ const decodePayloadFromB64UrlSegment = parsePayloadSegment;
7
+ const getPlaintextBytes = getPlaintextBytes$1;
8
+ const computeJwtTimeClaims = computeJwtTimeClaims$1;
9
+ const validateCriticalHeadersJWS = validateCriticalHeadersJWS$1;
10
+ const validateCriticalHeadersJWE = validateCriticalHeadersJWE$1;
11
+ const assertCritShape = assertCritShape$1;
12
+ export { UnsecureError, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeDurationInSeconds, computeJwtTimeClaims, concatUint8Arrays, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,10 @@
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
- import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, exportToPEM, generateJWK, generateKey, getJWKFromSet, getJWKsFromSet, importFromPEM, importKey, importPEM, unwrapKey, wrapKey } from "./core/jwk.mjs";
1
+ import { BytesSource, DecodeOptions, DecodeReturnAs, UnsecureError, UnsecureErrorCode, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "./_chunks/libs/unsecure.mjs";
2
+ import { CompositeKey, ContentEncryptionAlgorithm, DeriveKeyOptions, DeriveKeyReturn, Duration, ECDHEphemeralKeyInput, ExpiresIn, GenerateJWKOptions, GenerateJWKReturn, GenerateKeyAlgorithm, GenerateKeyOptions, GenerateKeyReturn, GeneratedJWKMap, GeneratedKeyMap, ImportedKey, ImportedKeyMap, JOSEConsumerOptions, JOSELimits, JOSEPayload, JOSEPayloadMode, JOSEPayloadTypeMap, JWEAsymmetricPrivateJWK, JWEAsymmetricPublicJWK, JWEDecryptJWK, JWEDecryptOptions, JWEDecryptResult, JWEEncryptJWK, JWEEncryptOptions, JWEFlattenedSerialization, JWEGeneralRecipient, JWEGeneralSerialization, JWEHeaderParameters, JWEKeyManagementHeaderParameters, JWELibraryHeaderName, JWEMultiDecryptKey, JWEMultiDecryptOptions, JWEMultiDecryptResult, JWEMultiEncryptOptions, JWEMultiRecipient, JWEProtectedHeader, JWK, JWKAlgorithm, JWKCacheAdapter, JWKLookupFunction, JWKLookupFunctionHeader, JWKMetadata, 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, JWTTimeClaimOptions, JoseHeaderParameters, KeyManagementAlgorithm, KnownJWTErrorCode, MaxTokenAge, NotBeforeIn, PayloadOf, StrictOmit, UnwrapKeyOptions, UnwrapKeyResult, UnwrappingKeyFor, WrapKeyOptions, WrapKeyResult, WrappingKeyFor, isJWTError, isUnsecureError } from "./_chunks/index.mjs";
3
+ import { thumbprint } from "./_chunks/index2.mjs";
4
+ import { WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, unwrapKey, wrapKey } from "./core/jwk.mjs";
5
+ import { computeDurationInSeconds, isJWTContent, validateJwtClaims } from "./_chunks/jwt.mjs";
3
6
  import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/jwe.mjs";
7
+ import { DEFAULT_JOSE_LIMITS } from "./_chunks/_internal.mjs";
4
8
  import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/jws.mjs";
5
- import { assertCryptoKey, computeDurationInSeconds, computeExpiresInSeconds, computeMaxTokenAgeSeconds, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isPrivateJWK, isPublicJWK, isSymmetricJWK, validateJwtClaims } from "./core/utils/index.mjs";
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 };
9
+ import { ComputeJwtTimeClaimsOptions, DecodePayloadOptions, InferAlgorithmsOptions, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeJwtTimeClaims, concatUint8Arrays, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isPrivateJWK, isPublicJWK, isSymmetricJWK, maybeArray, validateCriticalHeadersJWE, validateCriticalHeadersJWS } from "./_chunks/index3.mjs";
10
+ export { type BytesSource, type CompositeKey, ComputeJwtTimeClaimsOptions, type ContentEncryptionAlgorithm, DEFAULT_JOSE_LIMITS, type DecodeOptions, DecodePayloadOptions, type DecodeReturnAs, type DeriveKeyOptions, type DeriveKeyReturn, type Duration, type ECDHEphemeralKeyInput, type ExpiresIn, type GenerateJWKOptions, type GenerateJWKReturn, type GenerateKeyAlgorithm, type GenerateKeyOptions, type GenerateKeyReturn, type GeneratedJWKMap, type GeneratedKeyMap, type ImportedKey, type ImportedKeyMap, type InferAlgorithmsOptions, type JOSEConsumerOptions, type JOSELimits, type JOSEPayload, type JOSEPayloadMode, type JOSEPayloadTypeMap, 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 JWELibraryHeaderName, type JWEMultiDecryptKey, type JWEMultiDecryptOptions, type JWEMultiDecryptResult, type JWEMultiEncryptOptions, type JWEMultiRecipient, type JWEProtectedHeader, type JWK, type JWKAlgorithm, type JWKCacheAdapter, type JWKLookupFunction, type JWKLookupFunctionHeader, type JWKMetadata, 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 JWTTimeClaimOptions, type JoseHeaderParameters, type KeyManagementAlgorithm, type KnownJWTErrorCode, type MaxTokenAge, type NotBeforeIn, type PayloadOf, type StrictOmit, UnsecureError, type UnsecureErrorCode, type UnwrapKeyOptions, type UnwrapKeyResult, type UnwrappingKeyFor, WeakMapJWKCache, type WrapKeyOptions, type WrapKeyResult, type WrappingKeyFor, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, clearJWKCache, computeDurationInSeconds, computeJwtTimeClaims, concatUint8Arrays, configureJWKCache, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptMulti, exportKey, exportPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKsFromSet, getPlaintextBytes, importKey, importPEM, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, sign, signMulti, textDecoder, textEncoder, thumbprint, unwrapKey, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
package/dist/index.mjs CHANGED
@@ -1,5 +1,8 @@
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";
1
+ import { UnsecureError, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, textDecoder, textEncoder } from "./_chunks/libs/unsecure.mjs";
2
+ import { JWTError, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, computeDurationInSeconds, concatUint8Arrays, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, validateJwtClaims } from "./_chunks/_jwt-internal.mjs";
3
+ import { inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms } from "./_chunks/algorithms.mjs";
4
+ import { DEFAULT_JOSE_LIMITS, WeakMapJWKCache, clearJWKCache, configureJWKCache, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, exportKey, exportPEM, generateJWK, generateKey, getJWKsFromSet, importKey, importPEM, thumbprint, unwrapKey, wrapKey } from "./_chunks/jwk.mjs";
3
5
  import { generalToFlattenedJWS, sign, signMulti, verify, verifyMulti, verifyMultiAll } from "./_chunks/jws.mjs";
4
6
  import { decrypt, decryptMulti, encrypt, encryptMulti, generalToFlattened } from "./_chunks/jwe.mjs";
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 };
7
+ import { applyTypCtyDefaults, assertCritShape, computeJwtTimeClaims, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, getPlaintextBytes, validateCriticalHeadersJWE, validateCriticalHeadersJWS } from "./core/utils/index.mjs";
8
+ export { DEFAULT_JOSE_LIMITS, JWTError, UnsecureError, WeakMapJWKCache, applyTypCtyDefaults, assertCritShape, assertCryptoKey, base64Decode, base64Encode, base64Parse, base64Stringify, base64UrlDecode, base64UrlEncode, base64UrlParse, base64UrlStringify, clearJWKCache, computeDurationInSeconds, computeJwtTimeClaims, concatUint8Arrays, configureJWKCache, decodePayloadFromB64UrlSegment, decodePayloadFromBytes, decrypt, decryptMulti, deriveJWKFromPassword, deriveKeyFromPassword, deriveSharedSecret, encrypt, encryptMulti, exportKey, exportPEM, generalToFlattened, generalToFlattenedJWS, generateJWK, generateKey, getJWKsFromSet, getPlaintextBytes, importKey, importPEM, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isAsymmetricJWK, isCryptoKey, isCryptoKeyPair, isJWK, isJWKSet, isJWTContent, isJWTError, isPrivateJWK, isPublicJWK, isSymmetricJWK, isUnsecureError, maybeArray, safeJsonParse, sanitizeObject, sanitizeObjectCopy, secureRandomBytes, sign, signMulti, textDecoder, textEncoder, thumbprint, unwrapKey, validateCriticalHeadersJWE, validateCriticalHeadersJWS, validateJwtClaims, verify, verifyMulti, verifyMultiAll, wrapKey };
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.7.3",
3
+ "version": "0.8.1",
4
4
  "description": "Low-level JWT utilities",
5
+ "homepage": "https://unjwt.s94.dev",
5
6
  "license": "MIT",
6
7
  "author": {
7
8
  "name": "Sandro Circi",
@@ -40,9 +41,13 @@
40
41
  "types": "./dist/core/utils/index.d.mts",
41
42
  "default": "./dist/core/utils/index.mjs"
42
43
  },
44
+ "./internal": {
45
+ "types": "./dist/core/internal.d.mts",
46
+ "default": "./dist/core/internal.mjs"
47
+ },
43
48
  "./adapters/h3": {
44
- "types": "./dist/adapters/h3v1/index.d.mts",
45
- "default": "./dist/adapters/h3v1/index.mjs"
49
+ "types": "./dist/adapters/h3v2/index.d.mts",
50
+ "default": "./dist/adapters/h3v2/index.mjs"
46
51
  },
47
52
  "./adapters/h3v1": {
48
53
  "types": "./dist/adapters/h3v1/index.d.mts",
@@ -58,33 +63,31 @@
58
63
  }
59
64
  },
60
65
  "devDependencies": {
61
- "@types/node": "^25",
62
- "@types/supertest": "^7.2.0",
63
- "@typescript/native-preview": "7.0.0-dev.20260611.2",
64
- "@vitest/coverage-v8": "^4.1.9",
66
+ "@types/node": "^24.19.2",
67
+ "@types/supertest": "^7.2.1",
68
+ "@vitest/coverage-v8": "^5.0.4",
65
69
  "automd": "^0.4.3",
66
70
  "cookie-esv1": "npm:cookie-es@^1.2.3",
67
71
  "cookie-esv3": "npm:cookie-es@^3.1.1",
68
- "elysia": "^1.4.29",
72
+ "elysia": "^1.4.30",
69
73
  "h3v1": "npm:h3@^1.15.11",
70
- "h3v2": "npm:h3@^2.0.1-rc.22",
71
- "jose": "^6.2.3",
72
- "obuild": "^0.4.37",
73
- "oxfmt": "^0.57.0",
74
- "oxlint": "^1.72.0",
75
- "oxlint-tsgolint": "^0.24.0",
76
- "rolldown": "1.1.4",
77
- "simple-git-hooks": "^2.13.1",
78
- "supertest": "^7.2.2",
79
- "typescript": "^6.0.3",
80
- "unsecure": "^0.2.2",
81
- "vitest": "^4.1.9"
74
+ "h3v2": "npm:h3@^2.0.2",
75
+ "jose": "^6.2.12",
76
+ "obuild": "^0.4.45",
77
+ "oxfmt": "^0.73.0",
78
+ "oxlint": "^1.88.0",
79
+ "oxlint-tsgolint": "^7.0.2004",
80
+ "rolldown": "1.2.14",
81
+ "simple-git-hooks": "^2.14.0",
82
+ "supertest": "^7.3.1",
83
+ "typescript": "^7.0.2",
84
+ "unsecure": "^0.3.2",
85
+ "vitest": "^5.0.4"
82
86
  },
83
87
  "peerDependencies": {
84
88
  "cookie-es": "^1.2.3 || ^3.1.1",
85
- "elysia": "^1.4.0",
86
- "h3": "^1.15.4 || >=2.0.1-rc.22 || ^2.0.1",
87
- "rou3": "^0.8.1"
89
+ "elysia": "^1.4.29",
90
+ "h3": "^1.15.4 || ^2.0.1"
88
91
  },
89
92
  "peerDependenciesMeta": {
90
93
  "cookie-es": {
@@ -95,9 +98,6 @@
95
98
  },
96
99
  "h3": {
97
100
  "optional": true
98
- },
99
- "rou3": {
100
- "optional": true
101
101
  }
102
102
  },
103
103
  "resolutions": {
@@ -109,12 +109,12 @@
109
109
  "devEngines": {
110
110
  "packageManager": {
111
111
  "name": "pnpm",
112
- "version": "11.9.0",
112
+ "version": "12.11.2",
113
113
  "onFail": "download"
114
114
  },
115
115
  "runtime": {
116
116
  "name": "node",
117
- "version": ">=24.17",
117
+ "version": ">=24.17.0",
118
118
  "onFail": "error"
119
119
  }
120
120
  },
@@ -122,11 +122,11 @@
122
122
  "build": "obuild",
123
123
  "dev": "bun --watch ./playground/main.ts",
124
124
  "dev:prepare": "obuild --stub && pnpm simple-git-hooks",
125
- "lint": "oxlint . && oxfmt --check .",
125
+ "lint": "oxlint --deny-warnings . && oxfmt --check .",
126
126
  "fmt": "automd && oxlint --fix . && oxfmt .",
127
127
  "test": "vitest run --slowTestThreshold=1000",
128
128
  "test:coverage": "vitest run --coverage --slowTestThreshold=1000",
129
- "typecheck": "tsgo --noEmit",
129
+ "typecheck": "tsc --noEmit",
130
130
  "bench": "vitest bench --run"
131
131
  }
132
132
  }
@@ -1,88 +0,0 @@
1
- import { JWTError, decodePayloadFromB64UrlSegment, inferJWEAllowedAlgorithms, inferJWSAllowedAlgorithms, isCryptoKey, isCryptoKeyPair, isJWK, validateJwtClaims } from "./utils.mjs";
2
- import { base64UrlDecode, safeJsonParse, textEncoder } from "./libs/unsecure.mjs";
3
- import { assertOctKeyLength } from "./jwk.mjs";
4
- function buildJWKSetFilter(header) {
5
- const kid = header?.kid;
6
- const alg = header?.alg;
7
- return (k) => (!kid || k.kid === kid) && (!k.alg || k.alg === alg);
8
- }
9
- function parseEphemeralKey(ephemeralKey) {
10
- if (isCryptoKeyPair(ephemeralKey)) return {
11
- epk: ephemeralKey.publicKey,
12
- epkPrivateKey: ephemeralKey.privateKey
13
- };
14
- if (typeof ephemeralKey === "object" && ephemeralKey !== null && "publicKey" in ephemeralKey && "privateKey" in ephemeralKey) {
15
- if (!ephemeralKey.publicKey || !ephemeralKey.privateKey) throw new JWTError("ECDH-ES custom ephemeral key must include both publicKey and privateKey.", "ERR_JWK_INVALID");
16
- return {
17
- epk: ephemeralKey.publicKey,
18
- epkPrivateKey: ephemeralKey.privateKey
19
- };
20
- }
21
- if (isCryptoKey(ephemeralKey)) {
22
- if (ephemeralKey.type !== "private") throw new JWTError("ECDH-ES custom ephemeral CryptoKey must include private key material.", "ERR_JWK_INVALID");
23
- return {
24
- epk: ephemeralKey,
25
- epkPrivateKey: ephemeralKey
26
- };
27
- }
28
- if (isJWK(ephemeralKey)) {
29
- if (!("d" in ephemeralKey) || typeof ephemeralKey.d !== "string") throw new JWTError("ECDH-ES custom ephemeral JWK must include private parameter \"d\".", "ERR_JWK_INVALID");
30
- return {
31
- epk: ephemeralKey,
32
- epkPrivateKey: ephemeralKey
33
- };
34
- }
35
- throw new JWTError("Unsupported ECDH-ES ephemeral key material provided.", "ERR_JWK_INVALID");
36
- }
37
- async function resolveSigningKey(alg, key, usage) {
38
- if (key instanceof Uint8Array) {
39
- assertOctKeyLength(key, alg);
40
- return crypto.subtle.importKey("raw", key, {
41
- name: "HMAC",
42
- hash: `SHA-${alg.slice(-3)}`
43
- }, false, [usage]);
44
- }
45
- if (alg.startsWith("RS") || alg.startsWith("PS")) {
46
- const { modulusLength } = key.algorithm;
47
- if (typeof modulusLength !== "number" || modulusLength < 2048) throw new JWTError(`${alg} requires a key modulusLength of at least 2048 bits`, "ERR_JWK_INVALID");
48
- }
49
- return key;
50
- }
51
- function validateJwtClaimsIfJsonPayload(payload, options) {
52
- if (payload && typeof payload === "object" && !(payload instanceof Uint8Array) && !options.forceUint8Array && options.validateClaims !== false) validateJwtClaims(payload, options);
53
- }
54
- const JWS_ALG_CTX = /* @__PURE__ */ Object.freeze({
55
- infer: inferJWSAllowedAlgorithms,
56
- octAliasing: false,
57
- errorCode: "ERR_JWS_ALG_NOT_ALLOWED",
58
- label: "Algorithm"
59
- });
60
- const JWE_ALG_CTX = /* @__PURE__ */ Object.freeze({
61
- infer: inferJWEAllowedAlgorithms,
62
- octAliasing: true,
63
- errorCode: "ERR_JWE_ALG_NOT_ALLOWED",
64
- label: "Key management algorithm"
65
- });
66
- function checkAlgAllowed(alg, key, explicit, ctx) {
67
- if (explicit) return explicit.includes(alg) ? void 0 : notAllowed(alg, ctx);
68
- if (isJWK(key) && typeof key.alg === "string" && (!ctx.octAliasing || key.kty !== "oct")) return key.alg === alg ? void 0 : notAllowed(alg, ctx);
69
- const inferred = ctx.infer(key);
70
- if (!inferred) return new JWTError(`Cannot infer allowed ${ctx.label.toLowerCase()}s from this key; pass "options.algorithms" explicitly.`, ctx.errorCode);
71
- return inferred.includes(alg) ? void 0 : notAllowed(alg, ctx);
72
- }
73
- function notAllowed(alg, ctx) {
74
- return new JWTError(`${ctx.label} not allowed: ${alg}`, ctx.errorCode);
75
- }
76
- function decodeProtectedHeader(encoded, family) {
77
- if (!encoded) return {};
78
- try {
79
- return safeJsonParse(base64UrlDecode(encoded));
80
- } catch {
81
- throw new JWTError(`Invalid ${family}: Protected header could not be decoded.`, `ERR_${family}_INVALID`);
82
- }
83
- }
84
- function decodeJWSPayload(payloadSegment, useB64, forceUint8Array) {
85
- if (useB64) return decodePayloadFromB64UrlSegment(payloadSegment, forceUint8Array);
86
- return forceUint8Array ? textEncoder.encode(payloadSegment) : payloadSegment;
87
- }
88
- export { JWE_ALG_CTX, JWS_ALG_CTX, buildJWKSetFilter, checkAlgAllowed, decodeJWSPayload, decodeProtectedHeader, parseEphemeralKey, resolveSigningKey, validateJwtClaimsIfJsonPayload };