@sphereon/ssi-sdk-ext.key-utils 0.36.1-feature.SSISDK.82.and.SSISDK.70.35 → 0.36.1-next.11

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.cjs CHANGED
@@ -38,7 +38,6 @@ __export(index_exports, {
38
38
  Key: () => Key,
39
39
  SIG_KEY_ALGS: () => SIG_KEY_ALGS,
40
40
  asn1DerToRawPublicKey: () => asn1DerToRawPublicKey,
41
- base64ToBase64Url: () => base64ToBase64Url,
42
41
  calculateJwkThumbprint: () => calculateJwkThumbprint,
43
42
  calculateJwkThumbprintForKey: () => calculateJwkThumbprintForKey,
44
43
  coseKeyToJwk: () => coseKeyToJwk,
@@ -53,12 +52,8 @@ __export(index_exports, {
53
52
  hexStringFromUint8Array: () => hexStringFromUint8Array,
54
53
  importProvidedOrGeneratedKey: () => importProvidedOrGeneratedKey,
55
54
  isAsn1Der: () => isAsn1Der,
56
- isHash: () => isHash,
57
- isHashString: () => isHashString,
58
55
  isRawCompressedPublicKey: () => isRawCompressedPublicKey,
59
- isSameHash: () => isSameHash,
60
56
  jcsCanonicalize: () => jcsCanonicalize,
61
- joseAlgorithmToDigest: () => joseAlgorithmToDigest,
62
57
  joseToCoseCurve: () => joseToCoseCurve,
63
58
  joseToCoseKeyOperation: () => joseToCoseKeyOperation,
64
59
  joseToCoseKty: () => joseToCoseKty,
@@ -71,7 +66,6 @@ __export(index_exports, {
71
66
  keyTypeFromCryptographicSuite: () => keyTypeFromCryptographicSuite,
72
67
  logger: () => logger,
73
68
  minimalJwk: () => minimalJwk,
74
- normalizeHashAlgorithm: () => normalizeHashAlgorithm,
75
69
  padLeft: () => padLeft,
76
70
  removeNulls: () => removeNulls,
77
71
  rsaJwkToRawHexKey: () => rsaJwkToRawHexKey,
@@ -114,25 +108,24 @@ var import_sha512 = require("@noble/hashes/sha512");
114
108
  var u8a = __toESM(require("uint8arrays"), 1);
115
109
  var { fromString, toString, SupportedEncodings } = u8a;
116
110
  var digestMethodParams = /* @__PURE__ */ __name((hashAlgorithm) => {
117
- switch (normalizeHashAlgorithm(hashAlgorithm)) {
118
- case "SHA-256":
119
- return {
120
- hashAlgorithm: "SHA-256",
121
- digestMethod: sha256DigestMethod,
122
- hash: import_sha256.sha256
123
- };
124
- case "SHA-384":
125
- return {
126
- hashAlgorithm: "SHA-384",
127
- digestMethod: sha384DigestMethod,
128
- hash: import_sha512.sha384
129
- };
130
- case "SHA-512":
131
- return {
132
- hashAlgorithm: "SHA-512",
133
- digestMethod: sha512DigestMethod,
134
- hash: import_sha512.sha512
135
- };
111
+ if (hashAlgorithm === "SHA-256") {
112
+ return {
113
+ hashAlgorithm: "SHA-256",
114
+ digestMethod: sha256DigestMethod,
115
+ hash: import_sha256.sha256
116
+ };
117
+ } else if (hashAlgorithm === "SHA-384") {
118
+ return {
119
+ hashAlgorithm: "SHA-384",
120
+ digestMethod: sha384DigestMethod,
121
+ hash: import_sha512.sha384
122
+ };
123
+ } else {
124
+ return {
125
+ hashAlgorithm: "SHA-512",
126
+ digestMethod: sha512DigestMethod,
127
+ hash: import_sha512.sha512
128
+ };
136
129
  }
137
130
  }, "digestMethodParams");
138
131
  var shaHasher = /* @__PURE__ */ __name((input, alg) => {
@@ -456,7 +449,7 @@ var assertJwkClaimPresent = /* @__PURE__ */ __name((value, description) => {
456
449
  }, "assertJwkClaimPresent");
457
450
  var toBase64url = /* @__PURE__ */ __name((input) => toString2(fromString2(input), "base64url"), "toBase64url");
458
451
  var calculateJwkThumbprint = /* @__PURE__ */ __name((args) => {
459
- const digestAlgorithm = normalizeHashAlgorithm(args.digestAlgorithm ?? "SHA-256");
452
+ const { digestAlgorithm = "sha256" } = args;
460
453
  const jwk = sanitizedJwk(args.jwk);
461
454
  let components;
462
455
  switch (jwk.kty) {
@@ -500,7 +493,7 @@ var calculateJwkThumbprint = /* @__PURE__ */ __name((args) => {
500
493
  throw new Error('"kty" (Key Type) Parameter missing or unsupported');
501
494
  }
502
495
  const data = JSON.stringify(components);
503
- return digestMethodParams(digestAlgorithm).digestMethod(data, "base64url");
496
+ return digestAlgorithm === "sha512" ? digestMethodParams("SHA-512").digestMethod(data, "base64url") : digestMethodParams("SHA-256").digestMethod(data, "base64url");
504
497
  }, "calculateJwkThumbprint");
505
498
  var toJwkFromKey = /* @__PURE__ */ __name((key, opts) => {
506
499
  const isPrivateKey = "privateKeyHex" in key;
@@ -1227,71 +1220,6 @@ function toPkcs1FromHex(publicKeyHex) {
1227
1220
  return toString2(pkcs1, "hex");
1228
1221
  }
1229
1222
  __name(toPkcs1FromHex, "toPkcs1FromHex");
1230
- function joseAlgorithmToDigest(alg) {
1231
- switch (alg.toUpperCase().replace("-", "")) {
1232
- case "RS256":
1233
- case "ES256":
1234
- case "ES256K":
1235
- case "PS256":
1236
- case "HS256":
1237
- return "SHA-256";
1238
- case "RS384":
1239
- case "ES384":
1240
- case "PS384":
1241
- case "HS384":
1242
- return "SHA-384";
1243
- case "RS512":
1244
- case "ES512":
1245
- case "PS512":
1246
- case "HS512":
1247
- return "SHA-512";
1248
- case "EdDSA":
1249
- return "SHA-512";
1250
- default:
1251
- return "SHA-256";
1252
- }
1253
- }
1254
- __name(joseAlgorithmToDigest, "joseAlgorithmToDigest");
1255
- function isHash(input) {
1256
- const length = input.length;
1257
- if (length !== 64 && length !== 96 && length !== 128) {
1258
- return false;
1259
- }
1260
- return input.match(/^([0-9A-Fa-f])+$/g) !== null;
1261
- }
1262
- __name(isHash, "isHash");
1263
- function isHashString(input) {
1264
- const length = input.length;
1265
- if (length !== 32 && length !== 48 && length !== 64) {
1266
- return false;
1267
- }
1268
- for (let i = 0; i < length; i++) {
1269
- const byte = input[i];
1270
- if (byte === void 0) {
1271
- return false;
1272
- }
1273
- if (!(byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102)) {
1274
- return false;
1275
- }
1276
- }
1277
- return true;
1278
- }
1279
- __name(isHashString, "isHashString");
1280
- function normalizeHashAlgorithm(alg) {
1281
- if (!alg) {
1282
- return "SHA-256";
1283
- }
1284
- const upper = alg.toUpperCase();
1285
- if (upper.includes("256")) return "SHA-256";
1286
- if (upper.includes("384")) return "SHA-384";
1287
- if (upper.includes("512")) return "SHA-512";
1288
- throw new Error(`Invalid hash algorithm: ${alg}`);
1289
- }
1290
- __name(normalizeHashAlgorithm, "normalizeHashAlgorithm");
1291
- function isSameHash(left, right) {
1292
- return normalizeHashAlgorithm(left) === normalizeHashAlgorithm(right);
1293
- }
1294
- __name(isSameHash, "isSameHash");
1295
1223
 
1296
1224
  // src/conversion.ts
1297
1225
  var import_ssi_types2 = require("@sphereon/ssi-types");