unjwt 0.5.10 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -111,7 +111,7 @@ Creates a JWS token.
111
111
  - `key`: The signing key (`CryptoKey`, `JWK`, or `Uint8Array` for symmetric keys).
112
112
  - `options`:
113
113
  - `alg`: (Required) The JWS algorithm (e.g., `"HS256"`, `"RS256"`, `"ES256"`, `"PS256"`).
114
- - `protectedHeader`: An object for additional JWS Protected Header parameters (e.g., `kid`, `typ`, `cty`, `crit`, `b64`). If `payload` is an object and `typ` is not set, it defaults to `"JWT"`. The `b64` parameter ([RFC7797 section-3](https://datatracker.ietf.org/doc/html/rfc7797#section-3)) controls payload encoding (defaults to `true`, meaning Base64URL encoded).
114
+ - `protectedHeader`: An object for additional JWS Protected Header parameters (e.g., `kid`, `typ`, `cty`, `crit`, `b64`). If `payload` is an object and `typ` is not set, it defaults to `"at+jwt"`. The `b64` parameter ([RFC7797 section-3](https://datatracker.ietf.org/doc/html/rfc7797#section-3)) controls payload encoding (defaults to `true`, meaning Base64URL encoded).
115
115
  - `expiresIn`: Sets an expiration time in seconds (e.g., `3600` for 1 hour). If `iat` is missing it will be set to the current time. If `exp` is missing it will be set to `iat + expiresIn`. This is only applied if `payload` is a JWT.
116
116
  - `currentDate`: The current date for computing `expiresIn` option. Defaults to `new Date()`.
117
117
 
@@ -170,7 +170,7 @@ const secret = "supersecretkey";
170
170
 
171
171
  const { payload, protectedHeader } = await verify(token, secret);
172
172
  console.log(payload); // { message: "My important data" }
173
- console.log(protectedHeader); // { alg: "HS256", typ: "JWT" }
173
+ console.log(protectedHeader); // { alg: "HS256", typ: "at+jwt" }
174
174
  ```
175
175
 
176
176
  **Example (RS256 with key lookup):**
@@ -210,7 +210,7 @@ Encrypts data to produce a JWE token.
210
210
  - `options`:
211
211
  - `alg`: (Required) The JWE Key Management algorithm (e.g., `"A128KW"`, `"RSA-OAEP-256"`, `"PBES2-HS256+A128KW"`, `"ECDH-ES+A128KW"`), defaults depends on the key provided.
212
212
  - `enc`: (Required) The JWE Content Encryption algorithm (e.g., `"A128GCM"`, `"A256CBC-HS512"`), defaults depends on the key provided.
213
- - `protectedHeader`: An object for JWE Protected Header parameters (e.g., `kid`, `typ`, `cty`, `crit`, `apu`, `apv`, `p2s`, `p2c`). If `payload` is an object and `typ` is not set, it defaults to `"JWT"`.
213
+ - `protectedHeader`: An object for JWE Protected Header parameters (e.g., `kid`, `typ`, `cty`, `crit`, `apu`, `apv`, `p2s`, `p2c`). If `payload` is an object and `typ` is not set, it defaults to `"at+jwt"`.
214
214
  - `cek`: (Optional) Provide your own Content Encryption Key (`CryptoKey` or `Uint8Array`).
215
215
  - `contentEncryptionIV`: (Optional) Provide your own Initialization Vector for content encryption (`Uint8Array`).
216
216
  - Other algorithm-specific options like `p2s`, `p2c` (for PBES2), `keyManagementIV`, `ecdhPartyUInfo`, `ecdhPartyVInfo`.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, L as JWT, M as JWTClaimValidationOptions, I as JWTClaims, H as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CN1C8TlR.mjs';
2
- 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.igKyF5q2.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.Dof5OLMV.mjs';
4
- export { i as utils } from './shared/unjwt.CUUg6g3N.mjs';
5
- export { j as jwk } from './shared/unjwt.Cz90HQhy.mjs';
2
+ 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.BRtnm5sB.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.B9sSOKE3.mjs';
4
+ export { i as utils } from './shared/unjwt.df8yQ5_5.mjs';
5
+ export { j as jwk } from './shared/unjwt.DtVML6Qp.mjs';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { i as utils } from './shared/unjwt.odifuYKu.mjs';
2
- export { j as jwe } from './shared/unjwt.D0WA_yog.mjs';
3
- export { j as jwk } from './shared/unjwt.BrOta13J.mjs';
4
- export { j as jws } from './shared/unjwt.B1dfkZSt.mjs';
5
- import './shared/unjwt.CEjyBwhK.mjs';
1
+ export { i as utils } from './shared/unjwt.Ce8yMcp_.mjs';
2
+ export { j as jwe } from './shared/unjwt.DVMpKj8x.mjs';
3
+ export { j as jwk } from './shared/unjwt.DuBBF25X.mjs';
4
+ export { j as jws } from './shared/unjwt.D_JFPtpW.mjs';
5
+ import './shared/unjwt.C_D0RMCp.mjs';
package/dist/jwe.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.CN1C8TlR.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.Dof5OLMV.mjs';
1
+ export { L as JWT, M as JWTClaimValidationOptions, I as JWTClaims, H as JoseHeaderParameters } from './shared/unjwt.CN1C8TlR.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.B9sSOKE3.mjs';
package/dist/jwe.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import './shared/unjwt.BrOta13J.mjs';
2
- import './shared/unjwt.odifuYKu.mjs';
3
- export { d as decrypt, e as encrypt } from './shared/unjwt.D0WA_yog.mjs';
4
- import './shared/unjwt.CEjyBwhK.mjs';
1
+ import './shared/unjwt.DuBBF25X.mjs';
2
+ import './shared/unjwt.Ce8yMcp_.mjs';
3
+ export { d as decrypt, e as encrypt } from './shared/unjwt.DVMpKj8x.mjs';
4
+ import './shared/unjwt.C_D0RMCp.mjs';
package/dist/jwk.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CN1C8TlR.mjs';
2
- export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.Cz90HQhy.mjs';
1
+ export { C as CompositeKey, d as ContentEncryptionAlgorithm, D as DeriveKeyOptions, c as DeriveKeyReturn, G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, m as JWK, E as JWKAlgorithm, F as JWKPEMAlgorithm, J as JWKParameters, n as JWKSet, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, x as JWK_PBES2, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, l as JWK_oct, L as JWT, M as JWTClaimValidationOptions, I as JWTClaims, H as JoseHeaderParameters, K as KeyManagementAlgorithm, U as UnwrapKeyOptions, W as WrapKeyOptions, e as WrapKeyResult } from './shared/unjwt.CN1C8TlR.mjs';
2
+ export { d as deriveKeyFromPassword, b as exportJWKToPEM, e as exportKey, g as generateKey, c as getJWKFromSet, a as importJWKFromPEM, i as importKey, u as unwrapKey, w as wrapKey } from './shared/unjwt.DtVML6Qp.mjs';
package/dist/jwk.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.odifuYKu.mjs';
2
- export { p as deriveKeyFromPassword, t as exportJWKToPEM, q as exportKey, o as generateKey, g as getJWKFromSet, s as importJWKFromPEM, i as importKey, m as unwrapKey, r as wrapKey } from './shared/unjwt.BrOta13J.mjs';
1
+ import './shared/unjwt.Ce8yMcp_.mjs';
2
+ export { p as deriveKeyFromPassword, t as exportJWKToPEM, q as exportKey, o as generateKey, g as getJWKFromSet, s as importJWKFromPEM, i as importKey, m as unwrapKey, r as wrapKey } from './shared/unjwt.DuBBF25X.mjs';
package/dist/jws.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import './shared/unjwt.CN1C8TlR.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.igKyF5q2.mjs';
1
+ export { L as JWT, M as JWTClaimValidationOptions, I as JWTClaims, H as JoseHeaderParameters } from './shared/unjwt.CN1C8TlR.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.BRtnm5sB.mjs';
package/dist/jws.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import './shared/unjwt.BrOta13J.mjs';
2
- import './shared/unjwt.odifuYKu.mjs';
3
- import './shared/unjwt.CEjyBwhK.mjs';
4
- export { s as sign, v as verify } from './shared/unjwt.B1dfkZSt.mjs';
1
+ import './shared/unjwt.DuBBF25X.mjs';
2
+ import './shared/unjwt.Ce8yMcp_.mjs';
3
+ import './shared/unjwt.C_D0RMCp.mjs';
4
+ export { s as sign, v as verify } from './shared/unjwt.D_JFPtpW.mjs';
@@ -1,4 +1,4 @@
1
- import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, H as JoseHeaderParameters, f as JWK_EC_Public, m as JWK, M as JWTClaimValidationOptions, I as JWTClaims } from './unjwt.CN1C8TlR.mjs';
1
+ import { K as KeyManagementAlgorithm, d as ContentEncryptionAlgorithm, H as JoseHeaderParameters, f as JWK_EC_Public, m as JWK, M as JWTClaimValidationOptions, I as JWTClaims, L as JWT } from './unjwt.CN1C8TlR.mjs';
2
2
 
3
3
  /** Recognized JWE Header Parameters, any other Header Members may also be present. */
4
4
  interface JWEHeaderParameters extends JoseHeaderParameters {
@@ -72,7 +72,7 @@ interface JWEEncryptOptions {
72
72
  enc?: ContentEncryptionAlgorithm;
73
73
  /** Date to use when computing NumericDate claims, defaults to `new Date()`. */
74
74
  currentDate?: Date;
75
- /** Time at which the JWT should expire, if no `exp` was already provided (only when typ is JWT). */
75
+ /** Time at which the JWT should expire, if no `exp` was already provided (only when typ is "at+jwt"). */
76
76
  expiresIn?: number;
77
77
  /** Additional JWE Protected Header parameters. */
78
78
  protectedHeader?: Omit<JWEHeaderParameters, "alg" | "enc" | "iv" | "tag" | "p2s" | "p2c" | "apu" | "apv">;
@@ -176,10 +176,14 @@ type jwe_JWEEncryptOptions = JWEEncryptOptions;
176
176
  type jwe_JWEHeaderParameters = JWEHeaderParameters;
177
177
  type jwe_JWEKeyLookupFunction = JWEKeyLookupFunction;
178
178
  type jwe_JWEKeyManagementHeaderParameters = JWEKeyManagementHeaderParameters;
179
+ declare const jwe_JWT: typeof JWT;
180
+ declare const jwe_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
181
+ declare const jwe_JWTClaims: typeof JWTClaims;
182
+ declare const jwe_JoseHeaderParameters: typeof JoseHeaderParameters;
179
183
  declare const jwe_decrypt: typeof decrypt;
180
184
  declare const jwe_encrypt: typeof encrypt;
181
185
  declare namespace jwe {
182
- export { jwe_decrypt as decrypt, jwe_encrypt as encrypt };
186
+ export { jwe_JWT as JWT, jwe_JWTClaimValidationOptions as JWTClaimValidationOptions, jwe_JWTClaims as JWTClaims, jwe_JoseHeaderParameters as JoseHeaderParameters, jwe_decrypt as decrypt, jwe_encrypt as encrypt };
183
187
  export type { jwe_JWEDecryptOptions as JWEDecryptOptions, jwe_JWEDecryptResult as JWEDecryptResult, jwe_JWEEncryptOptions as JWEEncryptOptions, jwe_JWEHeaderParameters as JWEHeaderParameters, jwe_JWEKeyLookupFunction as JWEKeyLookupFunction, jwe_JWEKeyManagementHeaderParameters as JWEKeyManagementHeaderParameters };
184
188
  }
185
189
 
@@ -1,4 +1,4 @@
1
- import { o as JWK_HMAC, p as JWK_RSA_SIGN, q as JWK_RSA_PSS, r as JWK_ECDSA, H as JoseHeaderParameters, m as JWK, n as JWKSet, M as JWTClaimValidationOptions, I as JWTClaims } from './unjwt.CN1C8TlR.mjs';
1
+ import { o as JWK_HMAC, p as JWK_RSA_SIGN, q as JWK_RSA_PSS, r as JWK_ECDSA, H as JoseHeaderParameters, m as JWK, n as JWKSet, M as JWTClaimValidationOptions, I as JWTClaims, L as JWT } from './unjwt.CN1C8TlR.mjs';
2
2
 
3
3
  type JWS_SIGN_EXTRA = "Ed25519" | "EdDSA";
4
4
  /** JWS Signing Algorithm Identifier. */
@@ -27,7 +27,7 @@ interface JWSSignOptions {
27
27
  alg?: JWSAlgorithm;
28
28
  /**
29
29
  * Additional protected header parameters. `alg` is automatically included.
30
- * `typ` defaults to "JWT" if not provided.
30
+ * `typ` defaults to "at+jwt" if not provided.
31
31
  */
32
32
  protectedHeader?: JWSHeaderParameters;
33
33
  /** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
@@ -105,10 +105,14 @@ type jws_JWSProtectedHeader = JWSProtectedHeader;
105
105
  type jws_JWSSignOptions = JWSSignOptions;
106
106
  type jws_JWSVerifyOptions = JWSVerifyOptions;
107
107
  type jws_JWSVerifyResult<T extends JWTClaims | Uint8Array<ArrayBuffer> | string = JWTClaims | Uint8Array<ArrayBuffer> | string> = JWSVerifyResult<T>;
108
+ declare const jws_JWT: typeof JWT;
109
+ declare const jws_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
110
+ declare const jws_JWTClaims: typeof JWTClaims;
111
+ declare const jws_JoseHeaderParameters: typeof JoseHeaderParameters;
108
112
  declare const jws_sign: typeof sign;
109
113
  declare const jws_verify: typeof verify;
110
114
  declare namespace jws {
111
- export { jws_sign as sign, jws_verify as verify };
115
+ export { jws_JWT as JWT, jws_JWTClaimValidationOptions as JWTClaimValidationOptions, jws_JWTClaims as JWTClaims, jws_JoseHeaderParameters as JoseHeaderParameters, jws_sign as sign, jws_verify as verify };
112
116
  export type { jws_JWSAlgorithm as JWSAlgorithm, jws_JWSHeaderParameters as JWSHeaderParameters, jws_JWSKeyLookupFunction as JWSKeyLookupFunction, jws_JWSProtectedHeader as JWSProtectedHeader, jws_JWSSignOptions as JWSSignOptions, jws_JWSVerifyOptions as JWSVerifyOptions, jws_JWSVerifyResult as JWSVerifyResult };
113
117
  }
114
118
 
@@ -1,4 +1,4 @@
1
- import { c as checkSigCryptoKey } from './unjwt.BrOta13J.mjs';
1
+ import { c as checkSigCryptoKey } from './unjwt.DuBBF25X.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -1,15 +1,16 @@
1
1
  function applyTypCtyDefaults(header, payload) {
2
2
  const isObjectPayload = typeof payload === "object" && payload !== null && !(payload instanceof Uint8Array);
3
3
  if (header.typ === void 0 && isObjectPayload) {
4
- header.typ = "JWT";
4
+ header.typ = "at+jwt";
5
5
  }
6
- if (header.typ === "JWT" && isObjectPayload) {
7
- header.cty ||= "json";
6
+ if ((header.typ === "at+jwt" || header.typ === "JWT") && isObjectPayload) {
7
+ header.cty ||= "application/json";
8
8
  }
9
9
  return header;
10
10
  }
11
11
  function isJsonContent(header) {
12
12
  if (!header) return false;
13
+ if (header.typ === "at+jwt") return true;
13
14
  if (header.typ === "JWT") return true;
14
15
  const cty = header.cty?.toLowerCase();
15
16
  return cty === "json" || cty === "application/json" || !!cty && cty.endsWith("+json");
@@ -46,7 +47,7 @@ function getPlaintextBytes(payload) {
46
47
  );
47
48
  }
48
49
  function computeJwtTimeClaims(payload, headerTyp, expiresIn, currentDate = /* @__PURE__ */ new Date()) {
49
- if (expiresIn === void 0 || headerTyp !== "JWT" || !(payload && typeof payload === "object") || payload instanceof Uint8Array || payload.exp) {
50
+ if (expiresIn === void 0 || headerTyp !== "at+jwt" && headerTyp !== "JWT" || !(payload && typeof payload === "object") || payload instanceof Uint8Array || payload.exp) {
50
51
  return void 0;
51
52
  }
52
53
  const now = Math.round(currentDate.getTime() / 1e3);
@@ -1,6 +1,6 @@
1
- import { a as checkEncCryptoKey, u as uint32be, b as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, d as bitLengthCEK, f as jwkTokey, i as importKey, h as generateIV, l as encrypt$1, m as unwrapKey, n as decrypt$1 } from './unjwt.BrOta13J.mjs';
2
- import { k as concatUint8Arrays, t as textEncoder, l as assertCryptoKey, d as base64UrlEncode, m as isCryptoKey, a as isJWK, f as base64UrlDecode, r as randomBytes, b as applyTypCtyDefaults, c as computeJwtTimeClaims, n as getPlaintextBytes, o as decodePayloadFromBytes, p as validateCriticalHeadersJWE } from './unjwt.odifuYKu.mjs';
3
- import { c as checkKeyLength } from './unjwt.CEjyBwhK.mjs';
1
+ import { a as checkEncCryptoKey, u as uint32be, b as generateCEK, e as encryptIV, w as wrap, k as keyToJWK, d as bitLengthCEK, f as jwkTokey, i as importKey, h as generateIV, l as encrypt$1, m as unwrapKey, n as decrypt$1 } from './unjwt.DuBBF25X.mjs';
2
+ import { k as concatUint8Arrays, t as textEncoder, l as assertCryptoKey, d as base64UrlEncode, m as isCryptoKey, a as isJWK, f as base64UrlDecode, r as randomBytes, b as applyTypCtyDefaults, c as computeJwtTimeClaims, n as getPlaintextBytes, o as decodePayloadFromBytes, p as validateCriticalHeadersJWE } from './unjwt.Ce8yMcp_.mjs';
3
+ import { c as checkKeyLength } from './unjwt.C_D0RMCp.mjs';
4
4
 
5
5
  function lengthAndInput(input) {
6
6
  return concatUint8Arrays(uint32be(input.length), input);
@@ -1,6 +1,6 @@
1
- import { i as importKey, g as getJWKFromSet } from './unjwt.BrOta13J.mjs';
2
- import { a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, e as textDecoder, f as base64UrlDecode, g as isJWKSet, h as decodePayloadFromB64UrlSegment, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './unjwt.odifuYKu.mjs';
3
- import { s as sign$1, v as verify$1 } from './unjwt.CEjyBwhK.mjs';
1
+ import { i as importKey, g as getJWKFromSet } from './unjwt.DuBBF25X.mjs';
2
+ import { a as isJWK, b as applyTypCtyDefaults, c as computeJwtTimeClaims, d as base64UrlEncode, t as textEncoder, e as textDecoder, f as base64UrlDecode, g as isJWKSet, h as decodePayloadFromB64UrlSegment, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './unjwt.Ce8yMcp_.mjs';
3
+ import { s as sign$1, v as verify$1 } from './unjwt.C_D0RMCp.mjs';
4
4
 
5
5
  async function sign(payload, key, options = {}) {
6
6
  const { protectedHeader: additionalProtectedHeader } = options;
@@ -125,7 +125,7 @@ async function verify(jws, key, options = {}) {
125
125
  ...options.critical || [],
126
126
  ...options.requiredHeaders || []
127
127
  ]);
128
- if (payload && typeof payload === "object" && protectedHeader.typ === "JWT" && !options.forceUint8Array) {
128
+ if (payload && typeof payload === "object" && (protectedHeader.typ === "at+jwt" || protectedHeader.typ === "JWT") && !options.forceUint8Array) {
129
129
  validateJwtClaims(payload, options);
130
130
  }
131
131
  return {
@@ -1,4 +1,4 @@
1
- import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, x as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, F as JWKPEMAlgorithm, n as JWKSet, H as JoseHeaderParameters, C as CompositeKey, d as ContentEncryptionAlgorithm, E as JWKAlgorithm, J as JWKParameters, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm } from './unjwt.CN1C8TlR.mjs';
1
+ import { G as GenerateKeyAlgorithm, a as GenerateKeyOptions, b as GenerateKeyReturn, x as JWK_PBES2, D as DeriveKeyOptions, c as DeriveKeyReturn, l as JWK_oct, m as JWK, K as KeyManagementAlgorithm, W as WrapKeyOptions, e as WrapKeyResult, U as UnwrapKeyOptions, F as JWKPEMAlgorithm, n as JWKSet, H as JoseHeaderParameters, C as CompositeKey, d as ContentEncryptionAlgorithm, E as JWKAlgorithm, J as JWKParameters, v as JWK_AES_CBC_HMAC, w as JWK_AES_GCM, u as JWK_AES_GCM_KW, t as JWK_AES_KW, B as JWK_Asymmetric_Algorithm, h as JWK_EC, y as JWK_ECDH_ES, r as JWK_ECDSA, g as JWK_EC_Private, f as JWK_EC_Public, z as JWK_ED, o as JWK_HMAC, k as JWK_RSA, s as JWK_RSA_ENC, q as JWK_RSA_PSS, j as JWK_RSA_Private, i as JWK_RSA_Public, p as JWK_RSA_SIGN, A as JWK_Symmetric_Algorithm, L as JWT, M as JWTClaimValidationOptions, I as JWTClaims } from './unjwt.CN1C8TlR.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -153,6 +153,10 @@ declare const jwk_JWK_RSA_Public: typeof JWK_RSA_Public;
153
153
  declare const jwk_JWK_RSA_SIGN: typeof JWK_RSA_SIGN;
154
154
  declare const jwk_JWK_Symmetric_Algorithm: typeof JWK_Symmetric_Algorithm;
155
155
  declare const jwk_JWK_oct: typeof JWK_oct;
156
+ declare const jwk_JWT: typeof JWT;
157
+ declare const jwk_JWTClaimValidationOptions: typeof JWTClaimValidationOptions;
158
+ declare const jwk_JWTClaims: typeof JWTClaims;
159
+ declare const jwk_JoseHeaderParameters: typeof JoseHeaderParameters;
156
160
  declare const jwk_KeyManagementAlgorithm: typeof KeyManagementAlgorithm;
157
161
  declare const jwk_UnwrapKeyOptions: typeof UnwrapKeyOptions;
158
162
  declare const jwk_WrapKeyOptions: typeof WrapKeyOptions;
@@ -201,6 +205,10 @@ declare namespace jwk {
201
205
  jwk_JWK_RSA_SIGN as JWK_RSA_SIGN,
202
206
  jwk_JWK_Symmetric_Algorithm as JWK_Symmetric_Algorithm,
203
207
  jwk_JWK_oct as JWK_oct,
208
+ jwk_JWT as JWT,
209
+ jwk_JWTClaimValidationOptions as JWTClaimValidationOptions,
210
+ jwk_JWTClaims as JWTClaims,
211
+ jwk_JoseHeaderParameters as JoseHeaderParameters,
204
212
  jwk_KeyManagementAlgorithm as KeyManagementAlgorithm,
205
213
  jwk_UnwrapKeyOptions as UnwrapKeyOptions,
206
214
  jwk_WrapKeyOptions as WrapKeyOptions,
@@ -1,4 +1,4 @@
1
- import { m as isCryptoKey, k as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, s as base64Encode, t as textEncoder, r as randomBytes, a as isJWK, f as base64UrlDecode, g as isJWKSet } from './unjwt.odifuYKu.mjs';
1
+ import { m as isCryptoKey, k as concatUint8Arrays, d as base64UrlEncode, q as base64Decode, s as base64Encode, t as textEncoder, r as randomBytes, a as isJWK, f as base64UrlDecode, g as isJWKSet } from './unjwt.Ce8yMcp_.mjs';
2
2
 
3
3
  /**
4
4
  * This is a fork of Jose library's utility functions.
@@ -2,8 +2,8 @@ import { I as JWTClaims, M as JWTClaimValidationOptions, m as JWK, n as JWKSet }
2
2
 
3
3
  /**
4
4
  * Apply default typ/cty semantics shared by JWS & JWE.
5
- * - If typ is undefined and payload is a non-Uint8Array object, set typ="JWT".
6
- * - If typ is "JWT" and payload is a non-Uint8Array object, ensure cty defaults to "json".
5
+ * - If typ is undefined and payload is a non-Uint8Array object, set typ="at+jwt".
6
+ * - If typ is "at+jwt" and payload is a non-Uint8Array object, ensure cty defaults to "application/json".
7
7
  */
8
8
  declare function applyTypCtyDefaults<T extends {
9
9
  typ?: string;
package/dist/utils.d.mts CHANGED
@@ -1,2 +1,2 @@
1
1
  import './shared/unjwt.CN1C8TlR.mjs';
2
- export { n as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, v as computeJwtTimeClaims, f as concatUint8Arrays, p as decodeMaybeJsonString, s as decodePayloadFromB64UrlSegment, q as decodePayloadFromBytes, u as getPlaintextBytes, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, o as isJsonContent, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder, y as validateCriticalHeadersJWE, x as validateCriticalHeadersJWS, w as validateJwtClaims } from './shared/unjwt.CUUg6g3N.mjs';
2
+ export { n as applyTypCtyDefaults, j as assertCryptoKey, d as base64Decode, b as base64Encode, e as base64UrlDecode, c as base64UrlEncode, v as computeJwtTimeClaims, f as concatUint8Arrays, p as decodeMaybeJsonString, s as decodePayloadFromB64UrlSegment, q as decodePayloadFromBytes, u as getPlaintextBytes, k as isCryptoKey, l as isCryptoKeyPair, g as isJWK, h as isJWKSet, o as isJsonContent, m as maybeArray, r as randomBytes, a as textDecoder, t as textEncoder, y as validateCriticalHeadersJWE, x as validateCriticalHeadersJWS, w as validateJwtClaims } from './shared/unjwt.df8yQ5_5.mjs';
package/dist/utils.mjs CHANGED
@@ -1 +1 @@
1
- export { b as applyTypCtyDefaults, l as assertCryptoKey, q as base64Decode, s as base64Encode, f as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, k as concatUint8Arrays, y as decodeMaybeJsonString, h as decodePayloadFromB64UrlSegment, o as decodePayloadFromBytes, n as getPlaintextBytes, m as isCryptoKey, w as isCryptoKeyPair, a as isJWK, g as isJWKSet, x as isJsonContent, u as maybeArray, r as randomBytes, e as textDecoder, t as textEncoder, p as validateCriticalHeadersJWE, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './shared/unjwt.odifuYKu.mjs';
1
+ export { b as applyTypCtyDefaults, l as assertCryptoKey, q as base64Decode, s as base64Encode, f as base64UrlDecode, d as base64UrlEncode, c as computeJwtTimeClaims, k as concatUint8Arrays, y as decodeMaybeJsonString, h as decodePayloadFromB64UrlSegment, o as decodePayloadFromBytes, n as getPlaintextBytes, m as isCryptoKey, w as isCryptoKeyPair, a as isJWK, g as isJWKSet, x as isJsonContent, u as maybeArray, r as randomBytes, e as textDecoder, t as textEncoder, p as validateCriticalHeadersJWE, v as validateCriticalHeadersJWS, j as validateJwtClaims } from './shared/unjwt.Ce8yMcp_.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unjwt",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "description": "Low-level JWT utilities",
5
5
  "repository": "sandros94/unjwt",
6
6
  "license": "MIT",