@transmute/cose
Advanced tools
Comparing version 0.2.5 to 0.2.6
{ | ||
"name": "@transmute/cose", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "COSE and related work.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -53,3 +53,3 @@ # cose | ||
remote: cose.crypto.signer({ | ||
secretKeyJwk: issuerSecretKeyJwk, | ||
privateKeyJwk: issuerSecretKeyJwk, | ||
}), | ||
@@ -59,3 +59,3 @@ }); | ||
remote: cose.crypto.signer({ | ||
secretKeyJwk: notarySecretKeyJwk, | ||
privateKeyJwk: notarySecretKeyJwk, | ||
}), | ||
@@ -62,0 +62,0 @@ }); |
@@ -32,12 +32,12 @@ | ||
const cryptoKeyPair = await generateKeyPair(knownAlgorithm.Name, { extractable: true }); | ||
const secretKeyJwk = await exportJWK(cryptoKeyPair.privateKey) | ||
const jwkThumbprint = await calculateJwkThumbprint(secretKeyJwk) | ||
secretKeyJwk.kid = jwkThumbprint | ||
secretKeyJwk.alg = alg | ||
const privateKeyJwk = await exportJWK(cryptoKeyPair.privateKey) | ||
const jwkThumbprint = await calculateJwkThumbprint(privateKeyJwk) | ||
privateKeyJwk.kid = jwkThumbprint | ||
privateKeyJwk.alg = alg | ||
if (contentType === 'application/jwk+json') { | ||
return formatJwk(secretKeyJwk) as T | ||
return formatJwk(privateKeyJwk) as T | ||
} | ||
if (contentType === 'application/cose-key') { | ||
delete secretKeyJwk.kid; | ||
const secretKeyCoseKey = await convertJsonWebKeyToCoseKey<CoseKey>(secretKeyJwk) | ||
delete privateKeyJwk.kid; | ||
const secretKeyCoseKey = await convertJsonWebKeyToCoseKey<CoseKey>(privateKeyJwk) | ||
const coseKeyThumbprint = await thumbprint.calculateCoseKeyThumbprint(secretKeyCoseKey) | ||
@@ -44,0 +44,0 @@ secretKeyCoseKey.set(2, coseKeyThumbprint) |
@@ -5,8 +5,8 @@ import { CoseKey } from "."; | ||
export const extracePublicKeyJwk = (secretKeyJwk: SecretKeyJwk) => { | ||
if (secretKeyJwk.kty !== 'EC') { | ||
export const extracePublicKeyJwk = (privateKeyJwk: SecretKeyJwk) => { | ||
if (privateKeyJwk.kty !== 'EC') { | ||
throw new Error('Only EC keys are supported') | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { d, p, q, dp, dq, qi, key_ops, ...publicKeyJwk } = secretKeyJwk | ||
const { d, p, q, dp, dq, qi, key_ops, ...publicKeyJwk } = privateKeyJwk | ||
return publicKeyJwk | ||
@@ -13,0 +13,0 @@ } |
@@ -9,4 +9,4 @@ | ||
const signer = ({ secretKeyJwk }: { secretKeyJwk: SecretKeyJwk }) => { | ||
const digest = getDigestFromVerificationKey(`${secretKeyJwk.alg}`) | ||
const signer = ({ privateKeyJwk }: { privateKeyJwk: SecretKeyJwk }) => { | ||
const digest = getDigestFromVerificationKey(`${privateKeyJwk.alg}`) | ||
return { | ||
@@ -17,6 +17,6 @@ sign: async (toBeSigned: ArrayBuffer): Promise<ArrayBuffer> => { | ||
"jwk", | ||
secretKeyJwk, | ||
privateKeyJwk, | ||
{ | ||
name: "ECDSA", | ||
namedCurve: secretKeyJwk.crv, | ||
namedCurve: privateKeyJwk.crv, | ||
}, | ||
@@ -23,0 +23,0 @@ true, |
@@ -102,7 +102,7 @@ import { exportJWK, exportPKCS8, importPKCS8 } from 'jose'; | ||
} | ||
const secretKeyJwk = await exportJWK(await importPKCS8(privateKeyPKCS8, `${foundAlgorithm.Name}`)) as SecretKeyJwk | ||
secretKeyJwk.alg = foundAlgorithm.Name; | ||
const privateKeyJwk = await exportJWK(await importPKCS8(privateKeyPKCS8, `${foundAlgorithm.Name}`)) as SecretKeyJwk | ||
privateKeyJwk.alg = foundAlgorithm.Name; | ||
return detached.signer({ | ||
remote: crypto.signer({ | ||
secretKeyJwk | ||
privateKeyJwk | ||
}) | ||
@@ -109,0 +109,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318213