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

Unable to parse request for presentation openID4VP #2064

Closed MosCD3 closed 1 month ago

MosCD3 commented 1 month ago

Hi team I am trying to implement OpenID4VP in Bifold after we successfully implemented the credential issuance and acceptance flow. I am using such blockchain issuer now as means of testing issuance and verification and Paradym wallet as my resource for implementation. I am getting this error when trying to resolve presentation request

Invalid token specified: invalid base64 for part #1 (Property 'atob' doesn't exist) That seems coming from

agent.modules.openId4VcHolder.resolveSiopAuthorizationRequest(requestUri) => const verifiedAuthorizationRequest = await openidProvider.verifyAuthorizationRequest(requestJwtOrUri)

I tried both scenarios, passing the uri => failed with same error extracting certificate from auth request => adding to agent trusted certs => passing Jwt : also fails with same error

In paradym wallet, it works fine I made sure those sphereon libraries are installed though

    "@sphereon/did-auth-siop": "0.16.1-next.66",
    "@sphereon/oid4vc-common": "0.16.1-next.66",
    "@sphereon/oid4vci-client": "0.16.1-next.66",
    "@sphereon/oid4vci-common": "0.16.1-next.66",
    "@sphereon/oid4vci-issuer": "0.16.1-next.66",
    "@sphereon/ssi-types": "0.29.1-unstable.121",
TimoGlastra commented 1 month ago

Can you track down where atob is used? It's used for base64 encoding/decoding but not available in your environment it seems.

Which RN version are you on, and are you using hermes?

MosCD3 commented 1 month ago

It is used in @sphereon/did-auth-siop specifically to get the authorization from uri or JWT, the expectation comes from this function in credo-oidc const verifiedAuthorizationRequest = await openidProvider.verifyAuthorizationRequest(requestJwtOrUri)

I believe RN doesn't have a built in decoding for base64 but its working in paradigm with no issues Am I missing a polypfill or something

Bifold is at RN 0.72.5 And we are using latest credo 0.5.11

TimoGlastra commented 1 month ago

Okay and are you using hermes? Might be the react native version / hermes.

Is the sphereon lib using atob method directly? Or through a dependency?

MosCD3 commented 1 month ago

I can see that its using import { jwtDecode } from 'jwt-decode'; so through a dependency I believe And yes we are using hermes

MosCD3 commented 1 month ago

@TimoGlastra I solved it :D I added base64 polypill and defined it to be global in index.js and tested. The presentation request came in and was decoded successfully