Skip to content

Commit bbfd4bb

Browse files
authored
Merge pull request #64 from auth0-lab/optional_alg
fix: missing `issuerAuth.deviceKeyInfo.deviceKey.alg`
2 parents 50e51a0 + d2c55ef commit bbfd4bb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/mdoc/Verifier.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { compareVersions } from 'compare-versions';
22
import { X509Certificate } from '@peculiar/x509';
3-
import { importX509, JWK, KeyLike } from 'jose';
3+
import { importJWK, importX509, JWK, KeyLike } from 'jose';
44
import { Buffer } from 'buffer';
5-
import { COSEKeyToJWK, Sign1, importCOSEKey } from 'cose-kit';
5+
import { COSEKeyToJWK, Sign1 } from 'cose-kit';
66
import crypto from 'uncrypto';
77
import { MDoc } from './model/MDoc';
88

@@ -157,7 +157,9 @@ export class Verifier {
157157
}
158158

159159
if (deviceAuth.deviceSignature) {
160-
const deviceKey = await importCOSEKey(deviceKeyCoseKey);
160+
const deviceKeyJwk = COSEKeyToJWK(deviceKeyCoseKey);
161+
// When deviceKey (COSE Key) does not contain the `alg` parameter, use the one specified by the COSE_Sign1
162+
const deviceKey = await importJWK(deviceKeyJwk, deviceKeyJwk.alg ?? deviceAuth.deviceSignature.algName);
161163

162164
// ECDSA/EdDSA authentication
163165
try {

0 commit comments

Comments
 (0)