openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
276 stars 202 forks source link

fix: resolve undefined credential_definition.type in credentialRequest #1989

Closed parametprame closed 3 months ago

parametprame commented 3 months ago

This fixes the issue reported in (#1963).

changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 1aa162319d8f458706ba7e0c843f43f9efaa98c9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Patrik-Stas commented 3 months ago

hi @parametprame @TimoGlastra

I run into same problem playing with the demo, however although this PR seem to fix the original problem, it seems I am still hitting some subsequent outstanding issue.

Didn't have time to investigate, so I am just reporting this finding.

ISSUER:

  Restart 2024-08-14T07:35:25.603Z-(sphereon:events) Emitting 'OID4VCI_CREDENTIAL_ISSUED' event [
  {
    eventName: 'OID4VCI_CREDENTIAL_ISSUED',
    id: 'c23eb450-abbf-4045-83bd-9a6a7cd17cd1',
    data: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa3RpUVFFcW0yeWFwWEJEdDFXRVZCM2RxZ3Z5emk5NkZ1RkFOWW1yZ1RyS1Y5I3o2TWt0aVFRRXFtMnlhcFhCRHQxV0VWQjNkcWd2eXppOTZGdUZBTlltcmdUcktWOSJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiY3JlZGVudGlhbFN1YmplY3QiOnt9fSwiaXNzIjoiZGlkOmtleTp6Nk1rdGlRUUVxbTJ5YXBYQkR0MVdFVkIzZHFndnl6aTk2RnVGQU5ZbXJnVHJLVjkiLCJzdWIiOiJkaWQ6a2V5Ono2TWtwR1I0Z3M0UmMzWnBoNHZqOHdSbmpuQXhnQVBTeGNSOE1BVkt1dFdzcFF6YyIsIm5iZiI6MTcyMzYyMDkyNX0.kF41ImYqM3Do8UZrV_AGBLurjPCu0tkI4Q7fE2FGoTD83oPRigx3bGqnV2urTDY5feD0m7OGLCUDylmSnu45DQ',
    initiator: 'did:key:z6MktiQQEqm2yapXBDt1WEVB3dqgvyzi96FuFANYmrgTrKV9',
    initiatorType: 'external',
    system: 'oid4vci',
    subsystem: 'vc_issuer'
  }
]

Error: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (node:_http_outgoing:659:11)
    at ServerResponse.header (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/response.js:795:10)
    at ServerResponse.header (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/response.js:798:12)
    at /Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-issuer/router/accessTokenEndpoint.ts:115:14
    at Layer.handle [as handle_request] (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/router/route.js:149:13)
    at /Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-issuer/router/accessTokenEndpoint.ts:222:5 {
  code: 'ERR_HTTP_HEADERS_SENT'
}

HOLDER:


Options: Accept the credential offer.

Options: UniversityDegreeCredential
Requesting the following credential 'UniversityDegreeCredential'
/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VciHolderService.ts:356
      throw new CredoError(
            ^
CredoError: could not acquire access token from 'http://localhost:2000/oid4vci/832ea2c6-ffcf-4b27-8432-9d6d72de74a2'. invalid_request: Access token has already been retrieved
    at OpenId4VciHolderService.requestAccessToken (/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VciHolderService.ts:356:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async OpenId4VcHolderApi.requestToken (/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VcHolderApi.ts:153:9)
    at async Holder.requestAndStoreCredentials (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/Holder.ts:42:27)
    at async HolderInquirer.requestCredential (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:115:25)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:61:9)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:76:5)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:76:5)
    at async runHolder (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:17:3) {
  [cause]: undefined
}
 ELIFECYCLE  Command failed with exit code 1.
 ```
parametprame commented 3 months ago

hi @parametprame @TimoGlastra

I run into same problem playing with the demo, however although this PR seem to fix the original problem, it seems I am still hitting some subsequent outstanding issue.

Didn't have time to investigate, so I am just reporting this finding.

ISSUER:

  Restart 2024-08-14T07:35:25.603Z-(sphereon:events) Emitting 'OID4VCI_CREDENTIAL_ISSUED' event [
  {
    eventName: 'OID4VCI_CREDENTIAL_ISSUED',
    id: 'c23eb450-abbf-4045-83bd-9a6a7cd17cd1',
    data: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSIsImtpZCI6ImRpZDprZXk6ejZNa3RpUVFFcW0yeWFwWEJEdDFXRVZCM2RxZ3Z5emk5NkZ1RkFOWW1yZ1RyS1Y5I3o2TWt0aVFRRXFtMnlhcFhCRHQxV0VWQjNkcWd2eXppOTZGdUZBTlltcmdUcktWOSJ9.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiVW5pdmVyc2l0eURlZ3JlZUNyZWRlbnRpYWwiXSwiY3JlZGVudGlhbFN1YmplY3QiOnt9fSwiaXNzIjoiZGlkOmtleTp6Nk1rdGlRUUVxbTJ5YXBYQkR0MVdFVkIzZHFndnl6aTk2RnVGQU5ZbXJnVHJLVjkiLCJzdWIiOiJkaWQ6a2V5Ono2TWtwR1I0Z3M0UmMzWnBoNHZqOHdSbmpuQXhnQVBTeGNSOE1BVkt1dFdzcFF6YyIsIm5iZiI6MTcyMzYyMDkyNX0.kF41ImYqM3Do8UZrV_AGBLurjPCu0tkI4Q7fE2FGoTD83oPRigx3bGqnV2urTDY5feD0m7OGLCUDylmSnu45DQ',
    initiator: 'did:key:z6MktiQQEqm2yapXBDt1WEVB3dqgvyzi96FuFANYmrgTrKV9',
    initiatorType: 'external',
    system: 'oid4vci',
    subsystem: 'vc_issuer'
  }
]

Error: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (node:_http_outgoing:659:11)
    at ServerResponse.header (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/response.js:795:10)
    at ServerResponse.header (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/response.js:798:12)
    at /Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-issuer/router/accessTokenEndpoint.ts:115:14
    at Layer.handle [as handle_request] (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/patrik/dev/project/experiment/credo-ts/node_modules/.pnpm/express@4.19.2/node_modules/express/lib/router/route.js:149:13)
    at /Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-issuer/router/accessTokenEndpoint.ts:222:5 {
  code: 'ERR_HTTP_HEADERS_SENT'
}

HOLDER:

Options: Accept the credential offer.

Options: UniversityDegreeCredential
Requesting the following credential 'UniversityDegreeCredential'
/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VciHolderService.ts:356
      throw new CredoError(
            ^
CredoError: could not acquire access token from 'http://localhost:2000/oid4vci/832ea2c6-ffcf-4b27-8432-9d6d72de74a2'. invalid_request: Access token has already been retrieved
    at OpenId4VciHolderService.requestAccessToken (/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VciHolderService.ts:356:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async OpenId4VcHolderApi.requestToken (/Users/patrik/dev/project/experiment/credo-ts/packages/openid4vc/src/openid4vc-holder/OpenId4VcHolderApi.ts:153:9)
    at async Holder.requestAndStoreCredentials (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/Holder.ts:42:27)
    at async HolderInquirer.requestCredential (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:115:25)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:61:9)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:76:5)
    at async HolderInquirer.processAnswer (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:76:5)
    at async runHolder (/Users/patrik/dev/project/experiment/credo-ts/demo-openid/src/HolderInquirer.ts:17:3) {
  [cause]: undefined
}
 ELIFECYCLE  Command failed with exit code 1.
 ```

@Patrik-Stas Did you selected Accept the credential offer. more than once?

TimoGlastra commented 3 months ago

Hey @parametprame it seems your commit hasn't been signed off.

Can you follow https://github.com/hyperledger/aries-rfcs/blob/main/contributing.md#signing-off-commits-dco?

parametprame commented 3 months ago

Hey @parametprame it seems your commit hasn't been signed off.

Can you follow https://github.com/hyperledger/aries-rfcs/blob/main/contributing.md#signing-off-commits-dco?

@TimoGlastra I've signed it. Thanks for letting me know.