@sphereon/ssi-sdk-ext.key-utils 0.34.1-feature.SSISDK.26.RP.58 → 0.34.1-feature.SSISDK.45.189

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.js CHANGED
@@ -193,17 +193,17 @@ __name(jcsCanonicalize, "jcsCanonicalize");
193
193
  // src/types/key-util-types.ts
194
194
  var JWK_JCS_PUB_NAME = "jwk_jcs-pub";
195
195
  var JWK_JCS_PUB_PREFIX = 60241;
196
- var Key = /* @__PURE__ */ function(Key2) {
196
+ var Key = /* @__PURE__ */ (function(Key2) {
197
197
  Key2["Ed25519"] = "Ed25519";
198
198
  Key2["Secp256k1"] = "Secp256k1";
199
199
  Key2["Secp256r1"] = "Secp256r1";
200
200
  return Key2;
201
- }({});
202
- var JwkKeyUse = /* @__PURE__ */ function(JwkKeyUse2) {
201
+ })({});
202
+ var JwkKeyUse = /* @__PURE__ */ (function(JwkKeyUse2) {
203
203
  JwkKeyUse2["Encryption"] = "enc";
204
204
  JwkKeyUse2["Signature"] = "sig";
205
205
  return JwkKeyUse2;
206
- }({});
206
+ })({});
207
207
  var SIG_KEY_ALGS = [
208
208
  "ES256",
209
209
  "ES384",
@@ -586,8 +586,8 @@ var toSecp256k1Jwk = /* @__PURE__ */ __name((keyHex, opts) => {
586
586
  },
587
587
  kty: JwkKeyType.EC,
588
588
  crv: JoseCurve.secp256k1,
589
- x: hexToBase64(pubPoint.getX().toString("hex"), "base64url"),
590
- y: hexToBase64(pubPoint.getY().toString("hex"), "base64url"),
589
+ x: hexToBase64(pubPoint.getX().toString("hex").padStart(64, "0"), "base64url"),
590
+ y: hexToBase64(pubPoint.getY().toString("hex").padStart(64, "0"), "base64url"),
591
591
  ...opts?.isPrivateKey && {
592
592
  d: hexToBase64(keyPair.getPrivate("hex"), "base64url")
593
593
  }
@@ -618,8 +618,8 @@ var toSecp256r1Jwk = /* @__PURE__ */ __name((keyHex, opts) => {
618
618
  },
619
619
  kty: JwkKeyType.EC,
620
620
  crv: JoseCurve.P_256,
621
- x: hexToBase64(pubPoint.getX().toString("hex"), "base64url"),
622
- y: hexToBase64(pubPoint.getY().toString("hex"), "base64url"),
621
+ x: hexToBase64(pubPoint.getX().toString("hex").padStart(64, "0"), "base64url"),
622
+ y: hexToBase64(pubPoint.getY().toString("hex").padStart(64, "0"), "base64url"),
623
623
  ...opts?.isPrivateKey && {
624
624
  d: hexToBase64(keyPair.getPrivate("hex"), "base64url")
625
625
  }
@@ -1020,7 +1020,7 @@ async function verifyRawSignature({ data, signature, key: inputKey, opts }) {
1020
1020
  return bls12_381.verify(signature, data, fromString2(publicKeyHex, "hex"));
1021
1021
  case "RSA": {
1022
1022
  const signatureAlgorithm = opts?.signatureAlg ?? jwk.alg ?? JoseSignatureAlgorithm.PS256;
1023
- const hashAlg = signatureAlgorithm === (JoseSignatureAlgorithm.RS512 || JoseSignatureAlgorithm.PS512) ? sha5122 : signatureAlgorithm === (JoseSignatureAlgorithm.RS384 || JoseSignatureAlgorithm.PS384) ? sha3842 : sha2562;
1023
+ const hashAlg = signatureAlgorithm === JoseSignatureAlgorithm.RS512 || signatureAlgorithm === JoseSignatureAlgorithm.PS512 ? sha5122 : signatureAlgorithm === JoseSignatureAlgorithm.RS384 || signatureAlgorithm === JoseSignatureAlgorithm.PS384 ? sha3842 : sha2562;
1024
1024
  switch (signatureAlgorithm) {
1025
1025
  case JoseSignatureAlgorithm.RS256:
1026
1026
  return rsa.PKCS1_SHA256.verify({
@@ -1229,27 +1229,38 @@ function coseToJoseSignatureAlg(coseAlg) {
1229
1229
  __name(coseToJoseSignatureAlg, "coseToJoseSignatureAlg");
1230
1230
  function joseToCoseSignatureAlg(joseAlg) {
1231
1231
  switch (joseAlg) {
1232
- case (JoseSignatureAlgorithm2.ES256K, "ES256K"):
1232
+ case JoseSignatureAlgorithm2.ES256K:
1233
+ case "ES256K":
1233
1234
  return ICoseSignatureAlgorithm.ES256K;
1234
- case (JoseSignatureAlgorithm2.ES256, "ES256"):
1235
+ case JoseSignatureAlgorithm2.ES256:
1236
+ case "ES256":
1235
1237
  return ICoseSignatureAlgorithm.ES256;
1236
- case (JoseSignatureAlgorithm2.ES384, "ES384"):
1238
+ case JoseSignatureAlgorithm2.ES384:
1239
+ case "ES384":
1237
1240
  return ICoseSignatureAlgorithm.ES384;
1238
- case (JoseSignatureAlgorithm2.ES512, "ES512"):
1241
+ case JoseSignatureAlgorithm2.ES512:
1242
+ case "ES512":
1239
1243
  return ICoseSignatureAlgorithm.ES512;
1240
- case (JoseSignatureAlgorithm2.PS256, "PS256"):
1244
+ case JoseSignatureAlgorithm2.PS256:
1245
+ case "PS256":
1241
1246
  return ICoseSignatureAlgorithm.PS256;
1242
- case (JoseSignatureAlgorithm2.PS384, "PS384"):
1247
+ case JoseSignatureAlgorithm2.PS384:
1248
+ case "PS384":
1243
1249
  return ICoseSignatureAlgorithm.PS384;
1244
- case (JoseSignatureAlgorithm2.PS512, "PS512"):
1250
+ case JoseSignatureAlgorithm2.PS512:
1251
+ case "PS512":
1245
1252
  return ICoseSignatureAlgorithm.PS512;
1246
- case (JoseSignatureAlgorithm2.HS256, "HS256"):
1253
+ case JoseSignatureAlgorithm2.HS256:
1254
+ case "HS256":
1247
1255
  return ICoseSignatureAlgorithm.HS256;
1248
- case (JoseSignatureAlgorithm2.HS384, "HS384"):
1256
+ case JoseSignatureAlgorithm2.HS384:
1257
+ case "HS384":
1249
1258
  return ICoseSignatureAlgorithm.HS384;
1250
- case (JoseSignatureAlgorithm2.HS512, "HS512"):
1259
+ case JoseSignatureAlgorithm2.HS512:
1260
+ case "HS512":
1251
1261
  return ICoseSignatureAlgorithm.HS512;
1252
- case (JoseSignatureAlgorithm2.EdDSA, "EdDSA"):
1262
+ case JoseSignatureAlgorithm2.EdDSA:
1263
+ case "EdDSA":
1253
1264
  return ICoseSignatureAlgorithm.EdDSA;
1254
1265
  default:
1255
1266
  throw Error(`Signature algorithm ${joseAlg} not supported in Cose`);
@@ -1258,21 +1269,29 @@ function joseToCoseSignatureAlg(joseAlg) {
1258
1269
  __name(joseToCoseSignatureAlg, "joseToCoseSignatureAlg");
1259
1270
  function joseToCoseKeyOperation(keyOp) {
1260
1271
  switch (keyOp) {
1261
- case (JoseKeyOperation.SIGN, "sign"):
1272
+ case JoseKeyOperation.SIGN:
1273
+ case "sign":
1262
1274
  return ICoseKeyOperation.SIGN;
1263
- case (JoseKeyOperation.VERIFY, "verify"):
1275
+ case JoseKeyOperation.VERIFY:
1276
+ case "verify":
1264
1277
  return ICoseKeyOperation.VERIFY;
1265
- case (JoseKeyOperation.ENCRYPT, "encrypt"):
1278
+ case JoseKeyOperation.ENCRYPT:
1279
+ case "encrypt":
1266
1280
  return ICoseKeyOperation.ENCRYPT;
1267
- case (JoseKeyOperation.DECRYPT, "decrypt"):
1281
+ case JoseKeyOperation.DECRYPT:
1282
+ case "decrypt":
1268
1283
  return ICoseKeyOperation.DECRYPT;
1269
- case (JoseKeyOperation.WRAP_KEY, "wrapKey"):
1284
+ case JoseKeyOperation.WRAP_KEY:
1285
+ case "wrapKey":
1270
1286
  return ICoseKeyOperation.WRAP_KEY;
1271
- case (JoseKeyOperation.UNWRAP_KEY, "unwrapKey"):
1287
+ case JoseKeyOperation.UNWRAP_KEY:
1288
+ case "unwrapKey":
1272
1289
  return ICoseKeyOperation.UNWRAP_KEY;
1273
- case (JoseKeyOperation.DERIVE_KEY, "deriveKey"):
1290
+ case JoseKeyOperation.DERIVE_KEY:
1291
+ case "deriveKey":
1274
1292
  return ICoseKeyOperation.DERIVE_KEY;
1275
- case (JoseKeyOperation.DERIVE_BITS, "deriveBits"):
1293
+ case JoseKeyOperation.DERIVE_BITS:
1294
+ case "deriveBits":
1276
1295
  return ICoseKeyOperation.DERIVE_BITS;
1277
1296
  default:
1278
1297
  throw Error(`Key operation ${keyOp} not supported in Cose`);