Skip to content

Commit

Permalink
feat: pass wallet-cli context
Browse files Browse the repository at this point in the history
  • Loading branch information
skynet2 committed Feb 29, 2024
1 parent 4212e96 commit 5dd548e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion component/wallet-cli/pkg/oidc4vci/oidc4vci_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ const (
)

type trustRegistry interface {
ValidateIssuer(issuerDID string, issuerDomain string, credentialOffers []trustregistry.CredentialOffer) error
ValidateIssuer(
ctx context.Context,
issuerDID string,
issuerDomain string,
credentialOffers []trustregistry.CredentialOffer,
) error
}

type Flow struct {
Expand Down Expand Up @@ -292,6 +297,7 @@ func (f *Flow) Run(ctx context.Context) (*verifiable.Credential, error) {

if err = f.trustRegistryClient.
ValidateIssuer(
ctx,
issuerDID,
"",
[]trustregistry.CredentialOffer{
Expand Down
8 changes: 7 additions & 1 deletion component/wallet-cli/pkg/oidc4vp/oidc4vp_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ const (
)

type trustRegistry interface {
ValidateVerifier(verifierDID, verifierDomain string, credentials []*verifiable.Credential) error
ValidateVerifier(
ctx context.Context,
verifierDID,
verifierDomain string,
credentials []*verifiable.Credential,
) error
}

type Flow struct {
Expand Down Expand Up @@ -195,6 +200,7 @@ func (f *Flow) Run(ctx context.Context) error {

if err = f.trustRegistryClient.
ValidateVerifier(
ctx,
requestObject.ClientID,
"",
vp.Credentials(),
Expand Down
14 changes: 8 additions & 6 deletions component/wallet-cli/pkg/trustregistry/trustregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ func NewClient(httpClient *http.Client, policyURL string) *Client {
}

func (c *Client) ValidateIssuer(
ctx context.Context,
issuerDID string,
issuerDomain string,
credentialOffers []CredentialOffer,
) error {
logger.Debug("issuer validation begin")
logger.Debug("issuer validation begin", log.WithURL(c.policyURL))

req := &WalletIssuanceRequest{
IssuerDID: issuerDID,
Expand All @@ -53,7 +54,7 @@ func (c *Client) ValidateIssuer(
return fmt.Errorf("marshal wallet issuance request: %w", err)
}

resp, err := c.doRequest(context.Background(), c.policyURL, body)
resp, err := c.doRequest(ctx, c.policyURL, body)
if err != nil {
return err
}
Expand All @@ -62,17 +63,18 @@ func (c *Client) ValidateIssuer(
return ErrInteractionRestricted
}

logger.Debug("issuer validation succeed")
logger.Debug("issuer validation succeed", log.WithURL(c.policyURL))

return nil
}

func (c *Client) ValidateVerifier(
ctx context.Context,
verifierDID,
verifierDomain string,
credentials []*verifiable.Credential,
) error {
logger.Debug("verifier validation begin")
logger.Debug("verifier validation begin", log.WithURL(c.policyURL))

req := &WalletPresentationRequest{
VerifierDID: verifierDID,
Expand All @@ -91,7 +93,7 @@ func (c *Client) ValidateVerifier(
return fmt.Errorf("marshal wallet presentation request: %w", err)
}

resp, err := c.doRequest(context.Background(), c.policyURL, body)
resp, err := c.doRequest(ctx, c.policyURL, body)
if err != nil {
return err
}
Expand All @@ -100,7 +102,7 @@ func (c *Client) ValidateVerifier(
return ErrInteractionRestricted
}

logger.Debug("verifier validation succeed")
logger.Debug("verifier validation succeed", log.WithURL(c.policyURL))

return nil
}
Expand Down

0 comments on commit 5dd548e

Please sign in to comment.