Skip to content

Commit

Permalink
feat: Propagate tracing info from wallet-cli (#1788)
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Stasyszyn <[email protected]>
  • Loading branch information
bstasyszyn authored Nov 1, 2024
1 parent 4e96c46 commit 926f929
Show file tree
Hide file tree
Showing 34 changed files with 292 additions and 80 deletions.
2 changes: 1 addition & 1 deletion cmd/vc-rest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/trustbloc/cmdutil-go v1.0.0
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd
github.com/trustbloc/logutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1
github.com/trustbloc/vcs v0.0.0
Expand Down
4 changes: 2 additions & 2 deletions cmd/vc-rest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd h1:prVBQvvk4mzh
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88 h1:k3KNf9tE4TBVdpEtImmZIbUWFZRoL/96GPR7FSqCr9k=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/trustbloc/logutil-go v1.0.0 h1:KzNs9TRbnmn+M3oYw9UkrtOjNd3ZGO8aLgfYttMypcE=
github.com/trustbloc/logutil-go v1.0.0/go.mod h1:JlxT0oZfNKgIlSNtgc001WEeDMxlnAvOM43gNm8DQVc=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9 h1:j4SHVhRQyPvXJV3LpzR8lMBpo8BxkE5CSbMUabkr+Ww=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9/go.mod h1:AuHbwVcx1Rl6KNG2oFvlUR79egmDM8urblUaJ24p85A=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104 h1:0IW4muaGvhjJ4OkG6/PQG3DGf5POWxlA1wwEYsxWQ+4=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104/go.mod h1:3yChjB5KOT7B9eZe0W1XaIx3MNUuC1Oe9nR/GCtI1W0=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1 h1:z1YCowgkcRz/Gbf04/QArqYjQNspB5QGOhawmWswPsc=
Expand Down
2 changes: 1 addition & 1 deletion cmd/vc-rest/startcmd/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ func getTracingParams(cmd *cobra.Command) (*tracingParams, error) {
serviceName: serviceName,
}

if !tracing.IsExportedSupported(params.exporter) {
if !tracing.IsExporterSupported(params.exporter) {
return nil, fmt.Errorf("unsupported otel span exporter: %s", params.exporter)
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/vc-rest/startcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/trustbloc/did-go/doc/ld/context/remote"
"github.com/trustbloc/did-go/doc/ld/documentloader"
"github.com/trustbloc/logutil-go/pkg/log"
"github.com/trustbloc/logutil-go/pkg/otel/correlationidecho"
"github.com/trustbloc/vc-go/proof/defaults"
"github.com/trustbloc/vc-go/vermethod"
"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -446,6 +447,7 @@ func buildEchoHandler(

if conf.IsTraceEnabled {
e.Use(otelecho.Middleware(""))
e.Use(correlationidecho.Middleware())
}

tlsConfig := &tls.Config{RootCAs: conf.RootCAs, MinVersion: tls.VersionTLS12}
Expand Down
2 changes: 1 addition & 1 deletion component/credentialstatus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88
github.com/trustbloc/logutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1
github.com/trustbloc/vcs v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions component/credentialstatus/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd h1:prVBQvvk4mzh
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88 h1:k3KNf9tE4TBVdpEtImmZIbUWFZRoL/96GPR7FSqCr9k=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/trustbloc/logutil-go v1.0.0 h1:KzNs9TRbnmn+M3oYw9UkrtOjNd3ZGO8aLgfYttMypcE=
github.com/trustbloc/logutil-go v1.0.0/go.mod h1:JlxT0oZfNKgIlSNtgc001WEeDMxlnAvOM43gNm8DQVc=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9 h1:j4SHVhRQyPvXJV3LpzR8lMBpo8BxkE5CSbMUabkr+Ww=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9/go.mod h1:AuHbwVcx1Rl6KNG2oFvlUR79egmDM8urblUaJ24p85A=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104 h1:0IW4muaGvhjJ4OkG6/PQG3DGf5POWxlA1wwEYsxWQ+4=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104/go.mod h1:3yChjB5KOT7B9eZe0W1XaIx3MNUuC1Oe9nR/GCtI1W0=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1 h1:z1YCowgkcRz/Gbf04/QArqYjQNspB5QGOhawmWswPsc=
Expand Down
2 changes: 1 addition & 1 deletion component/event/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
github.com/trustbloc/cmdutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1
github.com/trustbloc/vcs v0.0.0-00010101000000-000000000000
go.opentelemetry.io/otel/trace v1.29.0
Expand Down
4 changes: 2 additions & 2 deletions component/event/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd h1:prVBQvvk4mzh
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88 h1:k3KNf9tE4TBVdpEtImmZIbUWFZRoL/96GPR7FSqCr9k=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/trustbloc/logutil-go v1.0.0 h1:KzNs9TRbnmn+M3oYw9UkrtOjNd3ZGO8aLgfYttMypcE=
github.com/trustbloc/logutil-go v1.0.0/go.mod h1:JlxT0oZfNKgIlSNtgc001WEeDMxlnAvOM43gNm8DQVc=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9 h1:j4SHVhRQyPvXJV3LpzR8lMBpo8BxkE5CSbMUabkr+Ww=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9/go.mod h1:AuHbwVcx1Rl6KNG2oFvlUR79egmDM8urblUaJ24p85A=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1 h1:z1YCowgkcRz/Gbf04/QArqYjQNspB5QGOhawmWswPsc=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1/go.mod h1:LJTZ+GIYr/HeklpmhzlNfz9zAd/t4mj4Kylr9+ubHnc=
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
Expand Down
2 changes: 1 addition & 1 deletion component/profile/reader/file/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/trustbloc/cmdutil-go v1.0.0
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88
github.com/trustbloc/logutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104
github.com/trustbloc/vcs v0.0.0-00010101000000-000000000000
)
Expand Down
4 changes: 2 additions & 2 deletions component/profile/reader/file/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd h1:prVBQvvk4mzh
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88 h1:k3KNf9tE4TBVdpEtImmZIbUWFZRoL/96GPR7FSqCr9k=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/trustbloc/logutil-go v1.0.0 h1:KzNs9TRbnmn+M3oYw9UkrtOjNd3ZGO8aLgfYttMypcE=
github.com/trustbloc/logutil-go v1.0.0/go.mod h1:JlxT0oZfNKgIlSNtgc001WEeDMxlnAvOM43gNm8DQVc=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9 h1:j4SHVhRQyPvXJV3LpzR8lMBpo8BxkE5CSbMUabkr+Ww=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9/go.mod h1:AuHbwVcx1Rl6KNG2oFvlUR79egmDM8urblUaJ24p85A=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104 h1:0IW4muaGvhjJ4OkG6/PQG3DGf5POWxlA1wwEYsxWQ+4=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104/go.mod h1:3yChjB5KOT7B9eZe0W1XaIx3MNUuC1Oe9nR/GCtI1W0=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1 h1:z1YCowgkcRz/Gbf04/QArqYjQNspB5QGOhawmWswPsc=
Expand Down
8 changes: 4 additions & 4 deletions component/wallet-cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ require (
github.com/syndtr/goleveldb v1.0.0
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88
github.com/trustbloc/logutil-go v1.0.0
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1
github.com/trustbloc/vcs v0.0.0-00010101000000-000000000000
github.com/valyala/fastjson v1.6.4
github.com/veraison/go-cose v1.3.0-rc.1
go.mongodb.org/mongo-driver v1.16.1
go.opentelemetry.io/otel v1.29.0
go.opentelemetry.io/otel/sdk v1.29.0
go.opentelemetry.io/otel/trace v1.29.0
go.uber.org/zap v1.27.0
golang.org/x/oauth2 v0.23.0
)
Expand Down Expand Up @@ -220,14 +223,11 @@ require (
go.opentelemetry.io/contrib/propagators/b3 v1.29.0 // indirect
go.opentelemetry.io/contrib/propagators/jaeger v1.29.0 // indirect
go.opentelemetry.io/contrib/samplers/jaegerremote v0.23.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.10.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions component/wallet-cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd h1:prVBQvvk4mzh
github.com/trustbloc/did-go v1.3.1-0.20241015091350-bb3317ba5bdd/go.mod h1:packTRoBoo8DrwOE7QKsI98xXS3Vf6ovUXYD4FUAcB4=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88 h1:k3KNf9tE4TBVdpEtImmZIbUWFZRoL/96GPR7FSqCr9k=
github.com/trustbloc/kms-go v1.1.3-0.20241001141623-8d9510c6bb88/go.mod h1:OKOtsLbE6W5s4mpjWkvk8XEqcmt9vTgVmDNkHELpWO0=
github.com/trustbloc/logutil-go v1.0.0 h1:KzNs9TRbnmn+M3oYw9UkrtOjNd3ZGO8aLgfYttMypcE=
github.com/trustbloc/logutil-go v1.0.0/go.mod h1:JlxT0oZfNKgIlSNtgc001WEeDMxlnAvOM43gNm8DQVc=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9 h1:j4SHVhRQyPvXJV3LpzR8lMBpo8BxkE5CSbMUabkr+Ww=
github.com/trustbloc/logutil-go v1.0.1-0.20241101181049-1d51079631d9/go.mod h1:AuHbwVcx1Rl6KNG2oFvlUR79egmDM8urblUaJ24p85A=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104 h1:0IW4muaGvhjJ4OkG6/PQG3DGf5POWxlA1wwEYsxWQ+4=
github.com/trustbloc/sidetree-go v1.0.1-0.20240219121130-f4260aff7104/go.mod h1:3yChjB5KOT7B9eZe0W1XaIx3MNUuC1Oe9nR/GCtI1W0=
github.com/trustbloc/vc-go v1.2.1-0.20241024133843-c0dd16d854d1 h1:z1YCowgkcRz/Gbf04/QArqYjQNspB5QGOhawmWswPsc=
Expand Down
53 changes: 45 additions & 8 deletions component/wallet-cli/pkg/oidc4vci/oidc4vci_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"encoding/json"
"errors"
"fmt"
"go.uber.org/zap"
"io"
"log/slog"
"net"
Expand All @@ -32,9 +33,12 @@ import (
"github.com/trustbloc/kms-go/doc/jose"
"github.com/trustbloc/kms-go/spi/kms"
"github.com/trustbloc/kms-go/wrapper/api"
"github.com/trustbloc/logutil-go/pkg/log"
"github.com/trustbloc/logutil-go/pkg/otel/correlationid"
"github.com/trustbloc/vc-go/jwt"
"github.com/trustbloc/vc-go/presexch"
"github.com/trustbloc/vc-go/verifiable"
"go.opentelemetry.io/otel/trace"
"golang.org/x/oauth2"

"github.com/trustbloc/vcs/component/wallet-cli/pkg/attestation"
Expand All @@ -52,6 +56,8 @@ import (
"github.com/trustbloc/vcs/pkg/service/oidc4ci"
)

var logger = log.New("oidc4vci-flow")

const (
preAuthorizedCodeGrantType = "urn:ietf:params:oauth:grant-type:pre-authorized_code"
discoverableClientIDScheme = "urn:ietf:params:oauth:client-id-scheme:oauth-discoverable-client"
Expand Down Expand Up @@ -110,6 +116,7 @@ type Flow struct {
walletKeyType kms.KeyType
perfInfo *PerfInfo
verificationMethod did.VerificationMethod
tracer trace.Tracer
}

type credentialFilter struct {
Expand Down Expand Up @@ -231,6 +238,7 @@ func NewFlow(p provider, opts ...Opt) (*Flow, error) {
pin: o.pin,
perfInfo: &PerfInfo{},
verificationMethod: targetVerMethod,
tracer: o.tracer,
}, nil
}

Expand All @@ -247,6 +255,20 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {
"scope", f.scopes,
)

if f.tracer != nil {
spanCtx, span := f.tracer.Start(ctx, "OIDC4VCIFlow")
defer span.End()

correlationCtx, correlationID, err := correlationid.Set(spanCtx)
if err != nil {
return nil, fmt.Errorf("set correlation ID: %w", err)
}

ctx = correlationCtx

logger.Infoc(ctx, "Running OIDC4VCI flow", zap.String("correlation_id", correlationID))
}

var (
credentialIssuer string
issuerState string
Expand Down Expand Up @@ -278,7 +300,7 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {

start := time.Now()

openIDConfig, err := f.wellKnownService.GetWellKnownOpenIDConfiguration(credentialIssuer)
openIDConfig, err := f.wellKnownService.GetWellKnownOpenIDConfiguration(ctx, credentialIssuer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -441,7 +463,7 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {

f.perfInfo.GetAccessToken = time.Since(start)

return f.receiveVC(token, openIDConfig, credentialOfferResponse, credentialIssuer)
return f.receiveVC(ctx, token, openIDConfig, credentialOfferResponse, credentialIssuer)
}

func (f *Flow) Signer() jose.Signer {
Expand Down Expand Up @@ -720,6 +742,7 @@ func (f *Flow) getAttestationVP() (string, error) {
}

func (f *Flow) receiveVC(
ctx context.Context,
token *oauth2.Token,
wellKnown *issuerv1.WellKnownOpenIDIssuerConfiguration,
credentialOfferResponse *oidc4ci.CredentialOfferResponse,
Expand Down Expand Up @@ -756,6 +779,7 @@ func (f *Flow) receiveVC(
)

credentialResp, err := f.batchCredentialRequest(
ctx,
batchCredentialEndpoint,
token,
credentialFilters,
Expand Down Expand Up @@ -785,6 +809,7 @@ func (f *Flow) receiveVC(
}

credentialResp, err := f.credentialRequest(
ctx,
credentialEndpoint,
token,
credentialFilters[0].oidcCredentialFormat,
Expand All @@ -802,7 +827,7 @@ func (f *Flow) receiveVC(
})
}

credentials, err := f.parseCredentialsResponse(parseCredentialResponseDataList, token, wellKnown)
credentials, err := f.parseCredentialsResponse(ctx, parseCredentialResponseDataList, token, wellKnown)
if err != nil {
return nil, fmt.Errorf("parseCredentialsResponse: %w", err)
}
Expand All @@ -811,6 +836,7 @@ func (f *Flow) receiveVC(
}

func (f *Flow) credentialRequest(
ctx context.Context,
credentialEndpoint string,
token *oauth2.Token,
credentialFormat vcsverifiable.OIDCFormat,
Expand All @@ -830,7 +856,7 @@ func (f *Flow) credentialRequest(
return nil, fmt.Errorf("marshal credential request: %w", err)
}

responseBody, err := f.doCredentialRequest(credentialEndpoint, b, token)
responseBody, err := f.doCredentialRequest(ctx, credentialEndpoint, b, token)
if err != nil {
return nil, fmt.Errorf("doCredentialRequest: %w", err)
}
Expand All @@ -845,6 +871,7 @@ func (f *Flow) credentialRequest(
}

func (f *Flow) batchCredentialRequest(
ctx context.Context,
credentialEndpoint string,
token *oauth2.Token,
credentialFilters []*credentialFilter,
Expand Down Expand Up @@ -872,7 +899,7 @@ func (f *Flow) batchCredentialRequest(
return nil, fmt.Errorf("marshal batch credential request: %w", err)
}

responseBody, err := f.doCredentialRequest(credentialEndpoint, b, token)
responseBody, err := f.doCredentialRequest(ctx, credentialEndpoint, b, token)
if err != nil {
return nil, fmt.Errorf("doCredentialRequest: %w", err)
}
Expand All @@ -887,6 +914,7 @@ func (f *Flow) batchCredentialRequest(
}

func (f *Flow) parseCredentialsResponse(
ctx context.Context,
parseCredentialResponseDataList []*parseCredentialResponseData,
token *oauth2.Token,
wellKnown *issuerv1.WellKnownOpenIDIssuerConfiguration,
Expand Down Expand Up @@ -953,7 +981,7 @@ func (f *Flow) parseCredentialsResponse(
notificationIDs = append(notificationIDs, lo.FromPtr(parseCredentialData.notificationID))
}

if err := f.handleIssuanceAck(wellKnown, notificationIDs, token); err != nil {
if err := f.handleIssuanceAck(ctx, wellKnown, notificationIDs, token); err != nil {
return nil, fmt.Errorf("handleIssuanceAck: %w", err)
}

Expand Down Expand Up @@ -985,11 +1013,12 @@ func (f *Flow) buildProof(
}

func (f *Flow) doCredentialRequest(
ctx context.Context,
credentialEndpoint string,
requestPayload []byte,
token *oauth2.Token,
) ([]byte, error) {
req, err := http.NewRequest(http.MethodPost, credentialEndpoint, bytes.NewBuffer(requestPayload))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, credentialEndpoint, bytes.NewBuffer(requestPayload))
if err != nil {
return nil, fmt.Errorf("new credential request: %w", err)
}
Expand Down Expand Up @@ -1126,6 +1155,7 @@ func (f *Flow) getCredentialFiltersFromCredentialConfigurationIDs(
}

func (f *Flow) handleIssuanceAck(
ctx context.Context,
wellKnown *issuerv1.WellKnownOpenIDIssuerConfiguration,
notificationIDs []string,
token *oauth2.Token,
Expand Down Expand Up @@ -1174,7 +1204,7 @@ func (f *Flow) handleIssuanceAck(
return err
}

req, err := http.NewRequest(http.MethodPost, notificationEndpoint, bytes.NewBuffer(b))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, notificationEndpoint, bytes.NewBuffer(b))
if err != nil {
return fmt.Errorf("ack credential request: %w", err)
}
Expand Down Expand Up @@ -1303,6 +1333,7 @@ type options struct {
pin string
walletDIDIndex int
credentialFilters []*credentialFilter
tracer trace.Tracer
}

type Opt func(opts *options)
Expand Down Expand Up @@ -1399,3 +1430,9 @@ func WithCredentialConfigurationIDs(credentialConfigurationIDs []string) Opt {
opts.credentialConfigurationIDs = credentialConfigurationIDs
}
}

func WithTracer(tracer trace.Tracer) Opt {
return func(opts *options) {
opts.tracer = tracer
}
}
Loading

0 comments on commit 926f929

Please sign in to comment.