microsoft / VerifiableCredentials-Verification-SDK-Typescript

An SDK to help Relying Parties manages their Decentralized Identities and Verifiable Credentials.
MIT License
53 stars 14 forks source link

TypeError: Key is not of type 'CryptoKey' at SubtleCryptoKeyVault.checkCryptoKey #111

Closed maakle closed 3 years ago

maakle commented 3 years ago

I opened already a ticket on the demo page, but I think the issue might be more related to the SDK here.

It seems like the SDK doesn't recognize the signing keys?

The error appears once I try to build a request with e.g.

req.session.issueRequest = await requestBuilder.build().create();

Error log:

(node:62578) UnhandledPromiseRejectionWarning: TypeError: Key is not of type 'CryptoKey'
    at SubtleCryptoKeyVault.checkCryptoKey (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/webcrypto-core/build/webcrypto-core.js:893:19)
    at SubtleCryptoKeyVault.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/webcrypto-core/build/webcrypto-core.js:762:14)
    at SubtleCryptoExtension.signByKeyStore (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript-plugin/dist/lib/SubtleCryptoExtension.js:53:40)
    at JwsToken.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript-protocol-jose/dist/lib/jws/JwsToken.js:382:40)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Jose.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript/dist/lib/Jose.js:52:23)
    at async Requestor.create (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-verification-sdk-typescript/dist/lib/api_oidc_request/Requestor.js:70:27)
    at async exports.issueRequest (/Users/mathiasklenk/passbase-dev/credential-issuer/src/controller/credentialIssuerController.js:76:30)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:62578) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:62578) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:62578) UnhandledPromiseRejectionWarning: TypeError: Key is not of type 'CryptoKey'
    at SubtleCryptoKeyVault.checkCryptoKey (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/webcrypto-core/build/webcrypto-core.js:893:19)
    at SubtleCryptoKeyVault.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/webcrypto-core/build/webcrypto-core.js:762:14)
    at SubtleCryptoExtension.signByKeyStore (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript-plugin/dist/lib/SubtleCryptoExtension.js:53:40)
    at JwsToken.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript-protocol-jose/dist/lib/jws/JwsToken.js:382:40)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Jose.sign (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-crypto-sdk-typescript/dist/lib/Jose.js:52:23)
    at async Requestor.create (/Users/mathiasklenk/passbase-dev/credential-issuer/node_modules/verifiablecredentials-verification-sdk-typescript/dist/lib/api_oidc_request/Requestor.js:70:27)
    at async exports.issueRequest (/Users/mathiasklenk/passbase-dev/credential-issuer/src/controller/credentialIssuerController.js:76:30)
@mathiasklenk
maakle commented 3 years ago

I think this issue was related to a breaking change you introduced.

Hence updating to the latest npm package should fix this.