@openid4vc/oauth2 0.3.0-alpha-20250304095426 → 0.3.0-alpha-20250315153009

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -2146,9 +2146,13 @@ type JwtHeader = z__default.infer<typeof zJwtHeader>;
2146
2146
 
2147
2147
  /**
2148
2148
  * Supported hashing algorithms
2149
+ *
2150
+ * Based on https://www.iana.org/assignments/named-information/named-information.xhtml
2149
2151
  */
2150
2152
  declare enum HashAlgorithm {
2151
- Sha256 = "SHA-256"
2153
+ Sha256 = "sha-256",
2154
+ Sha384 = "sha-384",
2155
+ Sha512 = "sha-512"
2152
2156
  }
2153
2157
  /**
2154
2158
  * Callback used for operations that require hashing
@@ -2174,7 +2178,7 @@ type VerifyJwtCallback = (jwtSigner: JwtSigner, jwt: {
2174
2178
  signerJwk?: Jwk;
2175
2179
  }>;
2176
2180
  interface DecryptJweCallbackOptions {
2177
- jwk: Jwk;
2181
+ jwk?: Jwk;
2178
2182
  }
2179
2183
  type DecryptJweCallback = (jwe: string, options?: DecryptJweCallbackOptions) => OrPromise<{
2180
2184
  decrypted: true;
package/dist/index.d.ts CHANGED
@@ -2146,9 +2146,13 @@ type JwtHeader = z__default.infer<typeof zJwtHeader>;
2146
2146
 
2147
2147
  /**
2148
2148
  * Supported hashing algorithms
2149
+ *
2150
+ * Based on https://www.iana.org/assignments/named-information/named-information.xhtml
2149
2151
  */
2150
2152
  declare enum HashAlgorithm {
2151
- Sha256 = "SHA-256"
2153
+ Sha256 = "sha-256",
2154
+ Sha384 = "sha-384",
2155
+ Sha512 = "sha-512"
2152
2156
  }
2153
2157
  /**
2154
2158
  * Callback used for operations that require hashing
@@ -2174,7 +2178,7 @@ type VerifyJwtCallback = (jwtSigner: JwtSigner, jwt: {
2174
2178
  signerJwk?: Jwk;
2175
2179
  }>;
2176
2180
  interface DecryptJweCallbackOptions {
2177
- jwk: Jwk;
2181
+ jwk?: Jwk;
2178
2182
  }
2179
2183
  type DecryptJweCallback = (jwe: string, options?: DecryptJweCallbackOptions) => OrPromise<{
2180
2184
  decrypted: true;
package/dist/index.js CHANGED
@@ -180,7 +180,9 @@ async function calculateJwkThumbprint(options) {
180
180
 
181
181
  // src/callbacks.ts
182
182
  var HashAlgorithm = /* @__PURE__ */ ((HashAlgorithm2) => {
183
- HashAlgorithm2["Sha256"] = "SHA-256";
183
+ HashAlgorithm2["Sha256"] = "sha-256";
184
+ HashAlgorithm2["Sha384"] = "sha-384";
185
+ HashAlgorithm2["Sha512"] = "sha-512";
184
186
  return HashAlgorithm2;
185
187
  })(HashAlgorithm || {});
186
188
 
@@ -214,13 +216,13 @@ async function isJwkInSet({
214
216
  callbacks
215
217
  }) {
216
218
  const jwkThumbprint = await calculateJwkThumbprint({
217
- hashAlgorithm: "SHA-256" /* Sha256 */,
219
+ hashAlgorithm: "sha-256" /* Sha256 */,
218
220
  hashCallback: callbacks.hash,
219
221
  jwk
220
222
  });
221
223
  for (const jwkFromSet of jwks) {
222
224
  const jwkFromSetThumbprint = await calculateJwkThumbprint({
223
- hashAlgorithm: "SHA-256" /* Sha256 */,
225
+ hashAlgorithm: "sha-256" /* Sha256 */,
224
226
  hashCallback: callbacks.hash,
225
227
  jwk: jwkFromSet
226
228
  });
@@ -895,7 +897,7 @@ async function createDpopHeadersForRequest(options) {
895
897
  async function createDpopJwt(options) {
896
898
  let ath = void 0;
897
899
  if (options.accessToken) {
898
- ath = (0, import_utils15.encodeToBase64Url)(await options.callbacks.hash((0, import_utils15.decodeUtf8String)(options.accessToken), "SHA-256" /* Sha256 */));
900
+ ath = (0, import_utils15.encodeToBase64Url)(await options.callbacks.hash((0, import_utils15.decodeUtf8String)(options.accessToken), "sha-256" /* Sha256 */));
899
901
  }
900
902
  const header = (0, import_utils15.parseWithErrorHandling)(zDpopJwtHeader, {
901
903
  typ: "dpop+jwt",
@@ -949,7 +951,7 @@ async function verifyDpopJwt(options) {
949
951
  }
950
952
  if (options.accessToken) {
951
953
  const expectedAth = (0, import_utils15.encodeToBase64Url)(
952
- await options.callbacks.hash((0, import_utils15.decodeUtf8String)(options.accessToken), "SHA-256" /* Sha256 */)
954
+ await options.callbacks.hash((0, import_utils15.decodeUtf8String)(options.accessToken), "sha-256" /* Sha256 */)
953
955
  );
954
956
  if (!payload.ath) {
955
957
  throw new Oauth2Error(`Dpop jwt does not have a ath value, but expected ath value '${expectedAth}'.`);
@@ -960,7 +962,7 @@ async function verifyDpopJwt(options) {
960
962
  }
961
963
  if (options.expectedJwkThumbprint) {
962
964
  const jwkThumprint = await calculateJwkThumbprint({
963
- hashAlgorithm: "SHA-256" /* Sha256 */,
965
+ hashAlgorithm: "sha-256" /* Sha256 */,
964
966
  hashCallback: options.callbacks.hash,
965
967
  jwk: header.jwk
966
968
  });
@@ -1424,7 +1426,7 @@ async function createAccessTokenJwt(options) {
1424
1426
  scope: options.scope,
1425
1427
  cnf: options.dpopJwk ? {
1426
1428
  jkt: await calculateJwkThumbprint({
1427
- hashAlgorithm: "SHA-256" /* Sha256 */,
1429
+ hashAlgorithm: "sha-256" /* Sha256 */,
1428
1430
  hashCallback: options.callbacks.hash,
1429
1431
  jwk: options.dpopJwk
1430
1432
  })
@@ -1623,7 +1625,7 @@ async function calculateCodeChallenge(options) {
1623
1625
  return options.codeVerifier;
1624
1626
  }
1625
1627
  if (options.codeChallengeMethod === "S256" /* S256 */) {
1626
- return (0, import_utils26.encodeToBase64Url)(await options.hashCallback((0, import_utils26.decodeUtf8String)(options.codeVerifier), "SHA-256" /* Sha256 */));
1628
+ return (0, import_utils26.encodeToBase64Url)(await options.hashCallback((0, import_utils26.decodeUtf8String)(options.codeVerifier), "sha-256" /* Sha256 */));
1627
1629
  }
1628
1630
  throw new Oauth2Error(`Unsupported code challenge method ${options.codeChallengeMethod}`);
1629
1631
  }
@@ -2452,7 +2454,7 @@ async function createAuthorizationRequestUrl(options) {
2452
2454
  } else {
2453
2455
  if (options.dpop) {
2454
2456
  authorizationRequest.dpop_jkt = await calculateJwkThumbprint({
2455
- hashAlgorithm: "SHA-256" /* Sha256 */,
2457
+ hashAlgorithm: "sha-256" /* Sha256 */,
2456
2458
  hashCallback: options.callbacks.hash,
2457
2459
  jwk: options.dpop.signer.publicJwk
2458
2460
  });