Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #253 from skflorin/mobilevcwallet
Browse files Browse the repository at this point in the history
feat: WACI vcwallet mobile bindings
  • Loading branch information
fqutishat authored Sep 17, 2021
2 parents e86d01a + ba46b85 commit e3d9779
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 24 deletions.
1 change: 1 addition & 0 deletions cmd/agent-mobile/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPI
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
Expand Down
10 changes: 10 additions & 0 deletions cmd/agent-mobile/pkg/api/vcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@ type VCWalletController interface {

// creates a key pair from wallet.
CreateKeyPair(request *models.RequestEnvelope) *models.ResponseEnvelope

// accepts out-of-band invitations and performs DID exchange.
Connect(request *models.RequestEnvelope) *models.ResponseEnvelope

// accepts out-of-band invitation and sends message proposing presentation
// from wallet to relying party.
ProposePresentation(request *models.RequestEnvelope) *models.ResponseEnvelope

// sends message present proof message from wallet to relying party.
PresentProof(request *models.RequestEnvelope) *models.ResponseEnvelope
}
49 changes: 49 additions & 0 deletions cmd/agent-mobile/pkg/wrappers/command/vcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,52 @@ func (v *VCWallet) CreateKeyPair(request *models.RequestEnvelope) *models.Respon

return &models.ResponseEnvelope{Payload: response}
}

// Connect accepts out-of-band invitations and performs DID exchange.
func (v *VCWallet) Connect(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.ConnectRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.ConnectMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}

return &models.ResponseEnvelope{Payload: response}
}

// ProposePresentation accepts out-of-band invitation and sends message proposing presentation
// from wallet to relying party.
func (v *VCWallet) ProposePresentation(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.ProposePresentationRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.ProposePresentationMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}

return &models.ResponseEnvelope{Payload: response}
}

// PresentProof sends present proof message from wallet to relying party.
func (v *VCWallet) PresentProof(request *models.RequestEnvelope) *models.ResponseEnvelope {
args := cmdvcwallet.PresentProofRequest{}

if err := json.Unmarshal(request.Payload, &args); err != nil {
return &models.ResponseEnvelope{Error: &models.CommandError{Message: err.Error()}}
}

response, cmdErr := exec(v.handlers[cmdvcwallet.PresentProofMethod], args)
if cmdErr != nil {
return &models.ResponseEnvelope{Error: cmdErr}
}

return &models.ResponseEnvelope{Payload: response}
}
45 changes: 21 additions & 24 deletions cmd/agent-mobile/pkg/wrappers/rest/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,52 +500,49 @@ func getVCWalletEndpoints() map[string]*endpoint {
Path: opvcwallet.ProfileExistsPath, Method: http.MethodGet,
},
cmdvcwallet.OpenMethod: {
Path: opvcwallet.OpenPath,
Method: http.MethodPost,
Path: opvcwallet.OpenPath, Method: http.MethodPost,
},
cmdvcwallet.CloseMethod: {
Path: opvcwallet.ClosePath,
Method: http.MethodPost,
Path: opvcwallet.ClosePath, Method: http.MethodPost,
},
cmdvcwallet.AddMethod: {
Path: opvcwallet.AddPath,
Method: http.MethodPost,
Path: opvcwallet.AddPath, Method: http.MethodPost,
},
cmdvcwallet.RemoveMethod: {
Path: opvcwallet.RemovePath,
Method: http.MethodPost,
Path: opvcwallet.RemovePath, Method: http.MethodPost,
},
cmdvcwallet.GetMethod: {
Path: opvcwallet.GetPath,
Method: http.MethodPost,
Path: opvcwallet.GetPath, Method: http.MethodPost,
},
cmdvcwallet.GetAllMethod: {
Path: opvcwallet.GetAllPath,
Method: http.MethodPost,
Path: opvcwallet.GetAllPath, Method: http.MethodPost,
},
cmdvcwallet.QueryMethod: {
Path: opvcwallet.QueryPath,
Method: http.MethodPost,
Path: opvcwallet.QueryPath, Method: http.MethodPost,
},
cmdvcwallet.IssueMethod: {
Path: opvcwallet.IssuePath,
Method: http.MethodPost,
Path: opvcwallet.IssuePath, Method: http.MethodPost,
},
cmdvcwallet.ProveMethod: {
Path: opvcwallet.ProvePath,
Method: http.MethodPost,
Path: opvcwallet.ProvePath, Method: http.MethodPost,
},
cmdvcwallet.VerifyMethod: {
Path: opvcwallet.VerifyPath,
Method: http.MethodPost,
Path: opvcwallet.VerifyPath, Method: http.MethodPost,
},
cmdvcwallet.DeriveMethod: {
Path: opvcwallet.DerivePath,
Method: http.MethodPost,
Path: opvcwallet.DerivePath, Method: http.MethodPost,
},
cmdvcwallet.CreateKeyPairMethod: {
Path: opvcwallet.CreateKeyPairPath,
Method: http.MethodPost,
Path: opvcwallet.CreateKeyPairPath, Method: http.MethodPost,
},
cmdvcwallet.ConnectMethod: {
Path: opvcwallet.ConnectPath, Method: http.MethodPost,
},
cmdvcwallet.ProposePresentationMethod: {
Path: opvcwallet.ProposePresentationPath, Method: http.MethodPost,
},
cmdvcwallet.PresentProofMethod: {
Path: opvcwallet.PresentProofPath, Method: http.MethodPost,
},
}
}
16 changes: 16 additions & 0 deletions cmd/agent-mobile/pkg/wrappers/rest/vcwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@ func (wallet *VCWallet) CreateKeyPair(request *models.RequestEnvelope) *models.R
return wallet.createRespEnvelope(request, cmdvcwallet.CreateKeyPairMethod)
}

// Connect accepts out-of-band invitations and performs DID exchange.
func (wallet *VCWallet) Connect(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.ConnectMethod)
}

// ProposePresentation accepts out-of-band invitation and sends message proposing presentation
// from wallet to relying party.
func (wallet *VCWallet) ProposePresentation(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.ProposePresentationMethod)
}

// PresentProof sends message present proof message from wallet to relying party.
func (wallet *VCWallet) PresentProof(request *models.RequestEnvelope) *models.ResponseEnvelope {
return wallet.createRespEnvelope(request, cmdvcwallet.PresentProofMethod)
}

func (wallet *VCWallet) createRespEnvelope(request *models.RequestEnvelope, endpoint string) *models.ResponseEnvelope {
return exec(&restOperation{
url: wallet.URL,
Expand Down

0 comments on commit e3d9779

Please sign in to comment.