Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into anoncrypt-didcomm-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdulbois committed Jul 12, 2022
2 parents 33298c2 + 15a4bb4 commit 443493e
Show file tree
Hide file tree
Showing 6 changed files with 2,741 additions and 2,458 deletions.
22 changes: 14 additions & 8 deletions pkg/client/vcwallet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ var noAuth walletAuth = func() (string, error) { return "", ErrWalletLocked }

// Client enable access to verifiable credential wallet features.
type Client struct {
wallet *wallet.Wallet
auth walletAuth
wallet *wallet.Wallet
didComm *wallet.DidComm
auth walletAuth
}

// New returns new verifiable credential wallet client for given user.
Expand All @@ -83,7 +84,12 @@ func New(userID string, ctx provider, options ...wallet.UnlockOptions) (*Client,
return nil, err
}

client := &Client{wallet: w, auth: noAuth}
didComm, err := wallet.NewDidComm(w, ctx)
if err != nil {
return nil, err
}

client := &Client{wallet: w, didComm: didComm, auth: noAuth}

if len(options) > 0 {
if client.Close() {
Expand Down Expand Up @@ -370,7 +376,7 @@ func (c *Client) Connect(invitation *outofband.Invitation, options ...wallet.Con
return "", err
}

return c.wallet.Connect(auth, invitation, options...)
return c.didComm.Connect(auth, invitation, options...)
}

// ProposePresentation accepts out-of-band invitation and sends message proposing presentation
Expand All @@ -395,7 +401,7 @@ func (c *Client) ProposePresentation(invitation *wallet.GenericInvitation, optio
return nil, err
}

return c.wallet.ProposePresentation(auth, invitation, options...)
return c.didComm.ProposePresentation(auth, invitation, options...)
}

// PresentProof sends message present proof message from wallet to relying party.
Expand All @@ -418,7 +424,7 @@ func (c *Client) PresentProof(thID string, presentProofFrom ...wallet.ConcludeIn
return nil, err
}

return c.wallet.PresentProof(auth, thID, presentProofFrom...)
return c.didComm.PresentProof(auth, thID, presentProofFrom...)
}

// ProposeCredential sends propose credential message from wallet to issuer.
Expand All @@ -441,7 +447,7 @@ func (c *Client) ProposeCredential(invitation *wallet.GenericInvitation, options
return nil, err
}

return c.wallet.ProposeCredential(auth, invitation, options...)
return c.didComm.ProposeCredential(auth, invitation, options...)
}

// RequestCredential sends request credential message from wallet to issuer and
Expand All @@ -465,7 +471,7 @@ func (c *Client) RequestCredential(thID string, options ...wallet.ConcludeIntera
return nil, err
}

return c.wallet.RequestCredential(auth, thID, options...)
return c.didComm.RequestCredential(auth, thID, options...)
}

// ResolveCredentialManifest resolves given credential manifest by credential fulfillment or credential.
Expand Down
45 changes: 40 additions & 5 deletions pkg/controller/command/vcwallet/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,14 @@ func (o *Command) Connect(rw io.Writer, req io.Reader) command.Error {
return command.NewExecuteError(DIDConnectErrorCode, err)
}

connectionID, err := vcWallet.Connect(request.Auth, request.Invitation,
didComm, err := wallet.NewDidComm(vcWallet, o.ctx)
if err != nil {
logutil.LogInfo(logger, CommandName, ConnectMethod, err.Error())

return command.NewExecuteError(DIDConnectErrorCode, err)
}

connectionID, err := didComm.Connect(request.Auth, request.Invitation,
wallet.WithConnectTimeout(request.Timeout), wallet.WithReuseDID(request.ReuseConnection),
wallet.WithReuseAnyConnection(request.ReuseAnyConnection), wallet.WithMyLabel(request.MyLabel),
wallet.WithRouterConnections(request.RouterConnections...))
Expand Down Expand Up @@ -805,7 +812,14 @@ func (o *Command) ProposePresentation(rw io.Writer, req io.Reader) command.Error
return command.NewExecuteError(ProposePresentationErrorCode, err)
}

msg, err := vcWallet.ProposePresentation(request.Auth, request.Invitation,
didComm, err := wallet.NewDidComm(vcWallet, o.ctx)
if err != nil {
logutil.LogInfo(logger, CommandName, ProposePresentationMethod, err.Error())

return command.NewExecuteError(ProposePresentationErrorCode, err)
}

msg, err := didComm.ProposePresentation(request.Auth, request.Invitation,
wallet.WithFromDID(request.FromDID), wallet.WithInitiateTimeout(request.Timeout),
wallet.WithConnectOptions(wallet.WithConnectTimeout(request.ConnectionOpts.Timeout),
wallet.WithReuseDID(request.ConnectionOpts.ReuseConnection),
Expand Down Expand Up @@ -849,7 +863,14 @@ func (o *Command) PresentProof(rw io.Writer, req io.Reader) command.Error {
return command.NewExecuteError(PresentProofErrorCode, err)
}

status, err := vcWallet.PresentProof(request.Auth, request.ThreadID,
didComm, err := wallet.NewDidComm(vcWallet, o.ctx)
if err != nil {
logutil.LogInfo(logger, CommandName, PresentProofMethod, err.Error())

return command.NewExecuteError(PresentProofErrorCode, err)
}

status, err := didComm.PresentProof(request.Auth, request.ThreadID,
prepareConcludeInteractionOpts(request.WaitForDone, request.Timeout, request.Presentation)...)
if err != nil {
logutil.LogInfo(logger, CommandName, PresentProofMethod, err.Error())
Expand Down Expand Up @@ -888,7 +909,14 @@ func (o *Command) ProposeCredential(rw io.Writer, req io.Reader) command.Error {
return command.NewExecuteError(ProposeCredentialErrorCode, err)
}

msg, err := vcWallet.ProposeCredential(request.Auth, request.Invitation,
didComm, err := wallet.NewDidComm(vcWallet, o.ctx)
if err != nil {
logutil.LogInfo(logger, CommandName, ProposeCredentialMethod, err.Error())

return command.NewExecuteError(ProposeCredentialErrorCode, err)
}

msg, err := didComm.ProposeCredential(request.Auth, request.Invitation,
wallet.WithFromDID(request.FromDID), wallet.WithInitiateTimeout(request.Timeout),
wallet.WithConnectOptions(wallet.WithConnectTimeout(request.ConnectionOpts.Timeout),
wallet.WithReuseDID(request.ConnectionOpts.ReuseConnection),
Expand Down Expand Up @@ -933,7 +961,14 @@ func (o *Command) RequestCredential(rw io.Writer, req io.Reader) command.Error {
return command.NewExecuteError(RequestCredentialErrorCode, err)
}

status, err := vcWallet.RequestCredential(request.Auth, request.ThreadID,
didComm, err := wallet.NewDidComm(vcWallet, o.ctx)
if err != nil {
logutil.LogInfo(logger, CommandName, RequestCredentialMethod, err.Error())

return command.NewExecuteError(RequestCredentialErrorCode, err)
}

status, err := didComm.RequestCredential(request.Auth, request.ThreadID,
prepareConcludeInteractionOpts(request.WaitForDone, request.Timeout, request.Presentation)...)
if err != nil {
logutil.LogInfo(logger, CommandName, RequestCredentialMethod, err.Error())
Expand Down
Loading

0 comments on commit 443493e

Please sign in to comment.