From fed942d98728c1382f487eec9475fd2d4390f8a7 Mon Sep 17 00:00:00 2001 From: Michael Avoyan <64565419+michaelavoyan@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:11:29 +0200 Subject: [PATCH 1/2] Update 0.4-to-0.5.md Signed-off-by: Michael Avoyan <64565419+michaelavoyan@users.noreply.github.com> --- guides/updating/versions/0.4-to-0.5.md | 64 +++----------------------- 1 file changed, 7 insertions(+), 57 deletions(-) diff --git a/guides/updating/versions/0.4-to-0.5.md b/guides/updating/versions/0.4-to-0.5.md index 62cb4604..69c21cf7 100644 --- a/guides/updating/versions/0.4-to-0.5.md +++ b/guides/updating/versions/0.4-to-0.5.md @@ -294,65 +294,15 @@ const data = 'openid-credential-offer://?credential_offer_uri=...' const resolvedCredentialOffer = await agent.modules.openId4VcHolder.resolveCredentialOffer(data) -await agent.modules.openId4VcHolder.acceptCredentialOfferUsingPreAuthorizedCode( - // First parameter is now the resolved credential offer +const token = await holder.modules.openId4VcHolderModule.requestToken({ resolvedCredentialOffer, - { - // has been renamed from proofOfPossessionVerificationMethodResolver to credentialBindingResolver - credentialBindingResolver: async ({ - supportedDidMethods, - keyType, - supportsAllDidMethods, - // supportsJwk now also passed - supportsJwk, - credentialFormat, - }) => { - // NOTE: example implementation. Adjust based on your needs - // Return the binding to the credential that should be used. Either did or jwk is supported - - if (supportsAllDidMethods || supportedDidMethods?.includes('did:key')) { - const didResult = await agent.dids.create({ - method: 'key', - options: { - keyType, - }, - }) - - if (didResult.didState.state !== 'finished') { - throw new Error('DID creation failed.') - } - - const didKey = DidKey.fromDid(didResult.didState.did) - - // you now need to return an object instead of VerificationMethod instance - // and method 'did' or 'jwk' - return { - method: 'did', - didUrl: `${didKey.did}#${didKey.key.fingerprint}`, - } - } - - // we also support plain jwk for sd-jwt only - if (supportsJwk && credentialFormat === OpenId4VciCredentialFormatProfile.SdJwtVc) { - const key = await agent.wallet.createKey({ - keyType, - }) - - // you now need to return an object instead of VerificationMethod instance - // and method 'did' or 'jwk' - return { - method: 'jwk', - jwk: getJwkFromKey(key), - } - } + userPin: '1234', +}); - throw new Error('Unable to create a key binding') - }, - - verifyCredentialStatus: false, - allowedProofOfPossessionSignatureAlgorithms: [JwaSignatureAlgorithm.EdDSA, JwaSignatureAlgorithm.ES256], - } -) +const credentials = await holder.modules.openId4VcHolderModule.requestCredentials({ + resolvedCredentialOffer, + token, +}); ``` From d27ea650844aba946cc8a9cfe6ecf80c5ebb031d Mon Sep 17 00:00:00 2001 From: Michael Avoyan <64565419+michaelavoyan@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:09:30 +0200 Subject: [PATCH 2/2] Update .gitignore Signed-off-by: Michael Avoyan <64565419+michaelavoyan@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 58e70810..e835d2c4 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ yarn-debug.log* yarn-error.log* .vscode +/.idea