w3c-ccg / universal-wallet-interop-spec

A data model and abstract interfaces for digital wallets
http://w3id.org/wallet
Other
56 stars 13 forks source link

wallet interfaces for WACI - share flow #99

Closed sudeshrshetty closed 2 years ago

sudeshrshetty commented 2 years ago

Based on recent progress in Wallet And Credential Interactions spec, I would like to propose few interfaces in universal wallet to support WACI.

Flow between prover(wallet) & verifier for share flow,

  1. verifier sends out-of-band invitation to wallet.
  2. wallet sends message proposing presentation to verifier.
  3. verifier replied with message requesting presentation from wallet.
  4. wallet performs query, prepares presentation and displays results in UI for user.
  5. wallet presents proof to verifier after taking user's consent in UI.
  6. verifier sends optional acknowledge message back to wallet for redirecting.

Interface Suggestion:

 // accept the invitation, send message proposing presentation, wait and return presentation request.
 let request = await wallet.proposePresentation(invitation, from, timeout)

 //  Args 
 //  invitation: out-of-band invitation 
//   from: optional in case of DIDComm V1 and a wallet can choose a specific DID to send the message in case of DIDComm V2 
// timeout: optional timeout duration to wait for presentation request from verifier.

Example of share flow:

// accept invitation, send propose presentation message and presentation request 
let request = await wallet.proposePresentation(invitation, "did:example:wallet:123", someTimeout)

// extract presentation definition(s) from request
let presentationDef = extractPresentationDef(request)

// perform query in wallet  (existing interface)
let presentation = await wallet.query([
           {
            type: "PresentationExchange",
            credentialQuery: presentationDef
            }
])

/* 
 show result to wallet user and get consent
*/

// add proof to presentation (existing interface)
let vp = await wallet.prove(presentation, proofOptions)

// send present proof message to verifier and get acknowledgement for next step
let ack = await wallet.presentProof(request.thid, presentation, someTimeout)
sudeshrshetty commented 2 years ago

@OR13 please have a look and let me know about your views.

OR13 commented 2 years ago

@sudeshrshetty yes, this looks good.

for the VC HTTP API side of this, we have this flow implemented, for example:

https://github.com/OR13/GNARLY/blob/main/src/__tests__/Exchange/Exchange.test.ts

and an older implementation of it that predates WACI:

https://github.com/transmute-industries/verifiable-data/blob/main/packages/universal-wallet-vp-exchange-plugin/src/__tests__/vp-exchange.spec.ts

I've very excited to add our first bits of DID Comm when we add support for WACI.