@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.cjs +47 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -28
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/conversion.ts +38 -19
- package/src/functions.ts +23 -23
package/dist/index.cjs
CHANGED
|
@@ -276,17 +276,17 @@ __name(jcsCanonicalize, "jcsCanonicalize");
|
|
|
276
276
|
// src/types/key-util-types.ts
|
|
277
277
|
var JWK_JCS_PUB_NAME = "jwk_jcs-pub";
|
|
278
278
|
var JWK_JCS_PUB_PREFIX = 60241;
|
|
279
|
-
var Key = /* @__PURE__ */ function(Key2) {
|
|
279
|
+
var Key = /* @__PURE__ */ (function(Key2) {
|
|
280
280
|
Key2["Ed25519"] = "Ed25519";
|
|
281
281
|
Key2["Secp256k1"] = "Secp256k1";
|
|
282
282
|
Key2["Secp256r1"] = "Secp256r1";
|
|
283
283
|
return Key2;
|
|
284
|
-
}({});
|
|
285
|
-
var JwkKeyUse = /* @__PURE__ */ function(JwkKeyUse2) {
|
|
284
|
+
})({});
|
|
285
|
+
var JwkKeyUse = /* @__PURE__ */ (function(JwkKeyUse2) {
|
|
286
286
|
JwkKeyUse2["Encryption"] = "enc";
|
|
287
287
|
JwkKeyUse2["Signature"] = "sig";
|
|
288
288
|
return JwkKeyUse2;
|
|
289
|
-
}({});
|
|
289
|
+
})({});
|
|
290
290
|
var SIG_KEY_ALGS = [
|
|
291
291
|
"ES256",
|
|
292
292
|
"ES384",
|
|
@@ -669,8 +669,8 @@ var toSecp256k1Jwk = /* @__PURE__ */ __name((keyHex, opts) => {
|
|
|
669
669
|
},
|
|
670
670
|
kty: import_ssi_types.JwkKeyType.EC,
|
|
671
671
|
crv: import_ssi_types.JoseCurve.secp256k1,
|
|
672
|
-
x: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getX().toString("hex"), "base64url"),
|
|
673
|
-
y: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getY().toString("hex"), "base64url"),
|
|
672
|
+
x: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getX().toString("hex").padStart(64, "0"), "base64url"),
|
|
673
|
+
y: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getY().toString("hex").padStart(64, "0"), "base64url"),
|
|
674
674
|
...opts?.isPrivateKey && {
|
|
675
675
|
d: (0, import_ssi_sdk_ext.hexToBase64)(keyPair.getPrivate("hex"), "base64url")
|
|
676
676
|
}
|
|
@@ -701,8 +701,8 @@ var toSecp256r1Jwk = /* @__PURE__ */ __name((keyHex, opts) => {
|
|
|
701
701
|
},
|
|
702
702
|
kty: import_ssi_types.JwkKeyType.EC,
|
|
703
703
|
crv: import_ssi_types.JoseCurve.P_256,
|
|
704
|
-
x: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getX().toString("hex"), "base64url"),
|
|
705
|
-
y: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getY().toString("hex"), "base64url"),
|
|
704
|
+
x: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getX().toString("hex").padStart(64, "0"), "base64url"),
|
|
705
|
+
y: (0, import_ssi_sdk_ext.hexToBase64)(pubPoint.getY().toString("hex").padStart(64, "0"), "base64url"),
|
|
706
706
|
...opts?.isPrivateKey && {
|
|
707
707
|
d: (0, import_ssi_sdk_ext.hexToBase64)(keyPair.getPrivate("hex"), "base64url")
|
|
708
708
|
}
|
|
@@ -1103,7 +1103,7 @@ async function verifyRawSignature({ data, signature, key: inputKey, opts }) {
|
|
|
1103
1103
|
return import_bls12_381.bls12_381.verify(signature, data, fromString2(publicKeyHex, "hex"));
|
|
1104
1104
|
case "RSA": {
|
|
1105
1105
|
const signatureAlgorithm = opts?.signatureAlg ?? jwk.alg ?? import_ssi_types.JoseSignatureAlgorithm.PS256;
|
|
1106
|
-
const hashAlg = signatureAlgorithm ===
|
|
1106
|
+
const hashAlg = signatureAlgorithm === import_ssi_types.JoseSignatureAlgorithm.RS512 || signatureAlgorithm === import_ssi_types.JoseSignatureAlgorithm.PS512 ? import_sha2.sha512 : signatureAlgorithm === import_ssi_types.JoseSignatureAlgorithm.RS384 || signatureAlgorithm === import_ssi_types.JoseSignatureAlgorithm.PS384 ? import_sha2.sha384 : import_sha2.sha256;
|
|
1107
1107
|
switch (signatureAlgorithm) {
|
|
1108
1108
|
case import_ssi_types.JoseSignatureAlgorithm.RS256:
|
|
1109
1109
|
return rsa.PKCS1_SHA256.verify({
|
|
@@ -1312,27 +1312,38 @@ function coseToJoseSignatureAlg(coseAlg) {
|
|
|
1312
1312
|
__name(coseToJoseSignatureAlg, "coseToJoseSignatureAlg");
|
|
1313
1313
|
function joseToCoseSignatureAlg(joseAlg) {
|
|
1314
1314
|
switch (joseAlg) {
|
|
1315
|
-
case
|
|
1315
|
+
case import_ssi_types2.JoseSignatureAlgorithm.ES256K:
|
|
1316
|
+
case "ES256K":
|
|
1316
1317
|
return import_ssi_types2.ICoseSignatureAlgorithm.ES256K;
|
|
1317
|
-
case
|
|
1318
|
+
case import_ssi_types2.JoseSignatureAlgorithm.ES256:
|
|
1319
|
+
case "ES256":
|
|
1318
1320
|
return import_ssi_types2.ICoseSignatureAlgorithm.ES256;
|
|
1319
|
-
case
|
|
1321
|
+
case import_ssi_types2.JoseSignatureAlgorithm.ES384:
|
|
1322
|
+
case "ES384":
|
|
1320
1323
|
return import_ssi_types2.ICoseSignatureAlgorithm.ES384;
|
|
1321
|
-
case
|
|
1324
|
+
case import_ssi_types2.JoseSignatureAlgorithm.ES512:
|
|
1325
|
+
case "ES512":
|
|
1322
1326
|
return import_ssi_types2.ICoseSignatureAlgorithm.ES512;
|
|
1323
|
-
case
|
|
1327
|
+
case import_ssi_types2.JoseSignatureAlgorithm.PS256:
|
|
1328
|
+
case "PS256":
|
|
1324
1329
|
return import_ssi_types2.ICoseSignatureAlgorithm.PS256;
|
|
1325
|
-
case
|
|
1330
|
+
case import_ssi_types2.JoseSignatureAlgorithm.PS384:
|
|
1331
|
+
case "PS384":
|
|
1326
1332
|
return import_ssi_types2.ICoseSignatureAlgorithm.PS384;
|
|
1327
|
-
case
|
|
1333
|
+
case import_ssi_types2.JoseSignatureAlgorithm.PS512:
|
|
1334
|
+
case "PS512":
|
|
1328
1335
|
return import_ssi_types2.ICoseSignatureAlgorithm.PS512;
|
|
1329
|
-
case
|
|
1336
|
+
case import_ssi_types2.JoseSignatureAlgorithm.HS256:
|
|
1337
|
+
case "HS256":
|
|
1330
1338
|
return import_ssi_types2.ICoseSignatureAlgorithm.HS256;
|
|
1331
|
-
case
|
|
1339
|
+
case import_ssi_types2.JoseSignatureAlgorithm.HS384:
|
|
1340
|
+
case "HS384":
|
|
1332
1341
|
return import_ssi_types2.ICoseSignatureAlgorithm.HS384;
|
|
1333
|
-
case
|
|
1342
|
+
case import_ssi_types2.JoseSignatureAlgorithm.HS512:
|
|
1343
|
+
case "HS512":
|
|
1334
1344
|
return import_ssi_types2.ICoseSignatureAlgorithm.HS512;
|
|
1335
|
-
case
|
|
1345
|
+
case import_ssi_types2.JoseSignatureAlgorithm.EdDSA:
|
|
1346
|
+
case "EdDSA":
|
|
1336
1347
|
return import_ssi_types2.ICoseSignatureAlgorithm.EdDSA;
|
|
1337
1348
|
default:
|
|
1338
1349
|
throw Error(`Signature algorithm ${joseAlg} not supported in Cose`);
|
|
@@ -1341,21 +1352,29 @@ function joseToCoseSignatureAlg(joseAlg) {
|
|
|
1341
1352
|
__name(joseToCoseSignatureAlg, "joseToCoseSignatureAlg");
|
|
1342
1353
|
function joseToCoseKeyOperation(keyOp) {
|
|
1343
1354
|
switch (keyOp) {
|
|
1344
|
-
case
|
|
1355
|
+
case import_ssi_types2.JoseKeyOperation.SIGN:
|
|
1356
|
+
case "sign":
|
|
1345
1357
|
return import_ssi_types2.ICoseKeyOperation.SIGN;
|
|
1346
|
-
case
|
|
1358
|
+
case import_ssi_types2.JoseKeyOperation.VERIFY:
|
|
1359
|
+
case "verify":
|
|
1347
1360
|
return import_ssi_types2.ICoseKeyOperation.VERIFY;
|
|
1348
|
-
case
|
|
1361
|
+
case import_ssi_types2.JoseKeyOperation.ENCRYPT:
|
|
1362
|
+
case "encrypt":
|
|
1349
1363
|
return import_ssi_types2.ICoseKeyOperation.ENCRYPT;
|
|
1350
|
-
case
|
|
1364
|
+
case import_ssi_types2.JoseKeyOperation.DECRYPT:
|
|
1365
|
+
case "decrypt":
|
|
1351
1366
|
return import_ssi_types2.ICoseKeyOperation.DECRYPT;
|
|
1352
|
-
case
|
|
1367
|
+
case import_ssi_types2.JoseKeyOperation.WRAP_KEY:
|
|
1368
|
+
case "wrapKey":
|
|
1353
1369
|
return import_ssi_types2.ICoseKeyOperation.WRAP_KEY;
|
|
1354
|
-
case
|
|
1370
|
+
case import_ssi_types2.JoseKeyOperation.UNWRAP_KEY:
|
|
1371
|
+
case "unwrapKey":
|
|
1355
1372
|
return import_ssi_types2.ICoseKeyOperation.UNWRAP_KEY;
|
|
1356
|
-
case
|
|
1373
|
+
case import_ssi_types2.JoseKeyOperation.DERIVE_KEY:
|
|
1374
|
+
case "deriveKey":
|
|
1357
1375
|
return import_ssi_types2.ICoseKeyOperation.DERIVE_KEY;
|
|
1358
|
-
case
|
|
1376
|
+
case import_ssi_types2.JoseKeyOperation.DERIVE_BITS:
|
|
1377
|
+
case "deriveBits":
|
|
1359
1378
|
return import_ssi_types2.ICoseKeyOperation.DERIVE_BITS;
|
|
1360
1379
|
default:
|
|
1361
1380
|
throw Error(`Key operation ${keyOp} not supported in Cose`);
|