Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions component/wallet-cli/cmd/create_wallet_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewCreateWalletCommand() *cobra.Command {
keyCreator: keyCreator,
}

slog.Info("creating wallet",
slog.Debug("creating wallet",
"did_key_type", flags.didKeyType,
"did_method", flags.didMethod,
)
Expand All @@ -83,7 +83,7 @@ func NewCreateWalletCommand() *cobra.Command {
dids = append(dids, fmt.Sprintf("%d", i), did.ID)
}

slog.Info("wallet created successfully",
slog.Debug("wallet created successfully",
"name", w.Name(),
"version", w.Version(),
"authentication_method", w.WalletType(),
Expand Down
2 changes: 1 addition & 1 deletion component/wallet-cli/cmd/init_wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func initServices(
return nil, fmt.Errorf("either --leveldb-path or --mongodb-connection-string must be specified")
}

slog.Info("initializing storage provider",
slog.Debug("initializing storage provider",
"storage_type", storageType,
)

Expand Down
22 changes: 11 additions & 11 deletions component/wallet-cli/pkg/oidc4vci/oidc4vci_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {
f.perfInfo.VcsCIFlowDuration = time.Since(totalFlowStart)
}()

slog.Info("Running OIDC4VCI flow",
slog.Debug("Running OIDC4VCI flow",
"flow_type", f.flowType,
"credential_offer_uri", f.credentialOffer,
"credential_filters", f.credentialFilters,
Expand All @@ -260,7 +260,7 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {

ctx = correlationCtx

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

var (
credentialIssuer string
Expand Down Expand Up @@ -329,7 +329,7 @@ func (f *Flow) Run(ctx context.Context) ([]*verifiable.Credential, error) {
return nil, err
}
} else if f.flowType == FlowTypePreAuthorizedCode {
slog.Info("Getting access token",
slog.Debug("Getting access token",
"grant_type", preAuthorizedCodeGrantType,
"client_id", f.clientID,
"pre-authorized_code", preAuthorizationGrant.PreAuthorizedCode,
Expand Down Expand Up @@ -464,7 +464,7 @@ func (f *Flow) Signer() jose.Signer {
}

func (f *Flow) parseCredentialOfferURI(uri string) (*oidc4ci.CredentialOfferResponse, error) {
slog.Info("Parsing credential offer URI",
slog.Debug("Parsing credential offer URI",
"uri", uri,
)

Expand All @@ -485,7 +485,7 @@ func (f *Flow) getAuthorizationCode(
oauthClient *oauth2.Config,
issuerState string,
) (string, error) {
slog.Info("Getting authorization code",
slog.Debug("Getting authorization code",
"client_id", oauthClient.ClientID,
"scopes", oauthClient.Scopes,
"filters", f.credentialFilters,
Expand Down Expand Up @@ -642,7 +642,7 @@ func (f *Flow) exchangeAuthorizationCodeForAccessToken(
oauthClient *oauth2.Config,
authCode string,
) (*oauth2.Token, error) {
slog.Info("Exchanging authorization code for access token",
slog.Debug("Exchanging authorization code for access token",
"grant_type", "authorization_code",
"client_id", oauthClient.ClientID,
"auth_code", authCode,
Expand Down Expand Up @@ -768,7 +768,7 @@ func (f *Flow) receiveVC(
return nil, errors.New("BatchCredentialEndpoint is not enalbed for given profile")
}

slog.Info("Getting batch credential",
slog.Debug("Getting batch credential",
"batch_credential_endpoint", batchCredentialEndpoint,
"credential_issuer", credentialIssuer,
)
Expand All @@ -785,7 +785,7 @@ func (f *Flow) receiveVC(
}
} else {
credentialEndpoint := lo.FromPtr(wellKnown.CredentialEndpoint)
slog.Info("Getting credential",
slog.Debug("Getting credential",
"credential_endpoint", credentialEndpoint,
"credential_issuer", credentialIssuer,
)
Expand Down Expand Up @@ -962,7 +962,7 @@ func (f *Flow) parseCredentialsResponse(
return !strings.EqualFold(item, "VerifiableCredential")
}

slog.Info("credential added to wallet",
slog.Debug("credential added to wallet",
"credential_id", parsedVC.Contents().ID,
"credential_type", strings.Join(lo.Filter(parsedVC.Contents().Types, predicate), ","),
"issuer_id", parsedVC.Contents().Issuer.ID,
Expand Down Expand Up @@ -1169,7 +1169,7 @@ func (f *Flow) handleIssuanceAck(
}()

for i := 0; i < credentialAmount; i++ {
slog.Info("Sending wallet notification", "notification_id", notificationID, "endpoint", notificationEndpoint)
slog.Debug("Sending wallet notification", "notification_id", notificationID, "endpoint", notificationEndpoint)

ackRequest := oidc4civ1.AckRequest{
Event: lo.ToPtr("credential_accepted"),
Expand Down Expand Up @@ -1199,7 +1199,7 @@ func (f *Flow) handleIssuanceAck(
return err
}

slog.Info(fmt.Sprintf("Wallet ACK sent with status code %v", resp.StatusCode))
slog.Debug(fmt.Sprintf("Wallet ACK sent with status code %v", resp.StatusCode))

b, _ = io.ReadAll(resp.Body) // nolint
if resp.StatusCode != http.StatusNoContent {
Expand Down
19 changes: 10 additions & 9 deletions component/wallet-cli/pkg/oidc4vp/oidc4vp_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"go.uber.org/zap"
"io"
"log/slog"
"net/http"
Expand All @@ -21,6 +20,8 @@ import (
"strings"
"time"

"go.uber.org/zap"

"github.com/google/uuid"
"github.com/piprate/json-gold/ld"
"github.com/trustbloc/did-go/doc/did"
Expand Down Expand Up @@ -163,7 +164,7 @@ func (f *Flow) Run(ctx context.Context) error {
f.perfInfo.VcsVPFlowDuration = time.Since(totalFlowStart)
}()

slog.Info("Running OIDC4VP flow",
slog.Debug("Running OIDC4VP flow",
"wallet_did", f.walletDID.String(),
"request_uri", f.requestURI,
"enable_linked_domain_verification", f.enableLinkedDomainVerification,
Expand All @@ -176,7 +177,7 @@ func (f *Flow) Run(ctx context.Context) error {
return fmt.Errorf("set correlation ID: %w", err)
}

logger.Infoc(ctx, "Running OIDC4VP flow", zap.String("correlation_id", correlationID))
logger.Debugc(ctx, "Running OIDC4VP flow", zap.String("correlation_id", correlationID))

ctx = correlationCtx

Expand Down Expand Up @@ -280,7 +281,7 @@ func (f *Flow) Run(ctx context.Context) error {
}

func (f *Flow) fetchRequestObject(ctx context.Context) (*RequestObject, error) {
slog.Info("Fetching request object",
slog.Debug("Fetching request object",
"uri", f.requestURI,
)

Expand Down Expand Up @@ -348,7 +349,7 @@ type serviceEndpoint struct {
}

func (f *Flow) runLinkedDomainVerification(clientDID string) error {
slog.Info("Running linked domain verification",
slog.Debug("Running linked domain verification",
"did", clientDID,
)

Expand Down Expand Up @@ -415,7 +416,7 @@ func (f *Flow) queryWallet(
pd *presexch.PresentationDefinition,
vpFormat *presexch.Format,
) ([]*verifiable.Presentation, *presexch.PresentationSubmission, error) {
slog.Info("Querying wallet")
slog.Debug("Querying wallet")

start := time.Now()
defer func() {
Expand Down Expand Up @@ -458,7 +459,7 @@ func (f *Flow) sendAuthorizationResponse(
presentationSubmission *presexch.PresentationSubmission,
attestationRequired bool,
) error {
slog.Info("Sending authorization response",
slog.Debug("Sending authorization response",
"response_uri", requestObject.ResponseURI,
)

Expand Down Expand Up @@ -614,7 +615,7 @@ func extractCustomScopeClaims(requestObjectScope string) (map[string]Claims, err
}

func (f *Flow) postAuthorizationResponse(ctx context.Context, responseURI string, body []byte) error {
slog.Info("Sending authorization response",
slog.Debug("Sending authorization response",
"response_uri", responseURI,
)

Expand Down Expand Up @@ -655,7 +656,7 @@ func (f *Flow) postAuthorizationResponse(ctx context.Context, responseURI string
)
}

slog.Info("Credential presented successfully")
slog.Debug("Credential presented successfully")

return nil
}
Expand Down
19 changes: 10 additions & 9 deletions component/wallet-cli/pkg/refresh/refresh_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (
"encoding/json"
"errors"
"fmt"
"go.uber.org/zap"
"io"
"log/slog"
"net/http"
"time"

"go.uber.org/zap"

"github.com/piprate/json-gold/ld"
"github.com/trustbloc/did-go/doc/did"
vdrapi "github.com/trustbloc/did-go/vdr/api"
Expand Down Expand Up @@ -140,7 +141,7 @@ func (f *Flow) Run(ctx context.Context) error {
return fmt.Errorf("set correlation ID: %w", err)
}

logger.Infoc(ctx, "Running Refresh flow", zap.String("correlation_id", correlationID))
logger.Debugc(ctx, "Running Refresh flow", zap.String("correlation_id", correlationID))

ctx = correlationCtx

Expand Down Expand Up @@ -187,7 +188,7 @@ func (f *Flow) Run(ctx context.Context) error {
NewCredential: updatedParsedCred,
}

slog.Info(fmt.Sprintf("credential with key %v updated", v))
slog.Debug(fmt.Sprintf("credential with key %v updated", v))
}

return finalErr
Expand All @@ -198,7 +199,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr
refreshService := parsedCred.Contents().RefreshService

if refreshService == nil {
slog.Info(fmt.Sprintf("no refresh service found for credential %s", credID))
slog.Debug(fmt.Sprintf("no refresh service found for credential %s", credID))
return nil, nil, nil
}

Expand All @@ -211,7 +212,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr
return nil, nil, fmt.Errorf("refresh service endpoint is not set")
}

slog.Info(fmt.Sprintf("fetching update for credential %s from %s", credID, refreshService.ID))
slog.Debug(fmt.Sprintf("fetching update for credential %s from %s", credID, refreshService.ID))

req, err := http.NewRequestWithContext(ctx, http.MethodGet, refreshService.ID, nil)
if err != nil {
Expand All @@ -224,7 +225,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr
}

if resp.StatusCode == http.StatusNoContent {
slog.Info(fmt.Sprintf("no update available for credential %s", credID))
slog.Debug(fmt.Sprintf("no update available for credential %s", credID))
return nil, nil, nil
}

Expand All @@ -248,7 +249,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr

interactEndpoint := parsed.VerifiablePresentationRequest.Interact.Service[0].ServiceEndpoint

slog.Info(fmt.Sprintf("update available for credential %s: %s", credID, credID))
slog.Debug(fmt.Sprintf("update available for credential %s: %s", credID, credID))

presDef, err := json.Marshal(parsed.VerifiablePresentationRequest.Query)
if err != nil {
Expand Down Expand Up @@ -286,7 +287,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr
return nil, nil, fmt.Errorf("failed to marshal request body: %w", err)
}

slog.Info(fmt.Sprintf("sending request to interact endpoint %s", interactEndpoint))
slog.Debug(fmt.Sprintf("sending request to interact endpoint %s", interactEndpoint))

req, err = http.NewRequestWithContext(ctx, http.MethodPost,
interactEndpoint,
Expand Down Expand Up @@ -336,7 +337,7 @@ func (f *Flow) fetchUpdateForCred(ctx context.Context, parsedCred *verifiable.Cr
return nil, nil, fmt.Errorf("failed to parse updated credential: %w", err)
}

slog.Info(fmt.Sprintf("received updated credential. old id : %v new id: %v", credID,
slog.Debug(fmt.Sprintf("received updated credential. old id : %v new id: %v", credID,
newParsedCred.Contents().ID))

return rawUpdatedCred, newParsedCred, nil
Expand Down
2 changes: 1 addition & 1 deletion component/wallet-cli/pkg/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (w *Wallet) Add(vc json.RawMessage, key string) error {
}
}

slog.Info("Add vc to store", "keyID", key)
slog.Debug("Add vc to store", "keyID", key)

w.mu.Lock()
defer w.mu.Unlock()
Expand Down
5 changes: 3 additions & 2 deletions component/wallet-cli/pkg/wellknown/wellknown.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/samber/lo"
"io"
"log/slog"
"net/http"

"github.com/samber/lo"

vdrapi "github.com/trustbloc/did-go/vdr/api"
"github.com/trustbloc/vc-go/jwt"
"github.com/trustbloc/vc-go/proof/defaults"
Expand All @@ -35,7 +36,7 @@ func (s *Service) GetWellKnownOpenIDConfiguration(
ctx context.Context,
issuerURL string,
) (*issuerv1.WellKnownOpenIDIssuerConfiguration, error) {
slog.Info("Getting OpenID credential issuer configuration",
slog.Debug("Getting OpenID credential issuer configuration",
"url", issuerURL+"/.well-known/openid-credential-issuer",
)

Expand Down