-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: basic logic for refresh * feat: credential issuer * fix: compose tests * fix: test for prepare credentials * feat: basic endpoints * feat: compile * feat: check for update * feat: steps * feat: more logic * feat: more changes * feat: refactor wallet-cli * feat: split to refresh endpoint * feat: basic split to service * feat: migrate * feat: more refactor * fix: lint * feat: base tests * fix: more tests * feat: add basic tests * fix: compose plugin * fix: apt * feat: dind * feat: more tests * feat: more tests * fix: doc loader * feat: set default refresh service * feat: more refresh tests * feat: more tests * feat: more refresh logic * feat: more tests * fix: mocks * feat: update vc
- Loading branch information
Showing
103 changed files
with
5,572 additions
and
1,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/* | ||
Copyright Gen Digital Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/henvic/httpretty" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/trustbloc/vcs/component/wallet-cli/internal/formatter" | ||
"github.com/trustbloc/vcs/component/wallet-cli/pkg/refresh" | ||
) | ||
|
||
type refreshCommandFlags struct { | ||
serviceFlags *walletFlags | ||
proxyURL string | ||
enableTracing bool | ||
walletDIDIndex int | ||
} | ||
|
||
func NewRefreshCmd() *cobra.Command { | ||
flags := &refreshCommandFlags{ | ||
serviceFlags: &walletFlags{}, | ||
} | ||
|
||
return &cobra.Command{ | ||
Use: "refresh", | ||
Short: "Refresh credential", | ||
Long: "Refresh credential", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
w, svc, err := initWallet(flags.serviceFlags) | ||
if err != nil { | ||
return fmt.Errorf("init wallet: %w", err) | ||
} | ||
|
||
httpTransport := &http.Transport{ | ||
TLSClientConfig: svc.TLSConfig(), | ||
} | ||
|
||
if flags.proxyURL != "" { | ||
proxyURL, parseErr := url.Parse(flags.proxyURL) | ||
if parseErr != nil { | ||
return fmt.Errorf("parse proxy url: %w", parseErr) | ||
} | ||
|
||
httpTransport.Proxy = http.ProxyURL(proxyURL) | ||
} | ||
|
||
httpClient := &http.Client{ | ||
Transport: httpTransport, | ||
} | ||
|
||
if flags.enableTracing { | ||
httpLogger := &httpretty.Logger{ | ||
RequestHeader: true, | ||
RequestBody: true, | ||
ResponseHeader: true, | ||
ResponseBody: true, | ||
SkipSanitize: true, | ||
Colors: true, | ||
SkipRequestInfo: true, | ||
Formatters: []httpretty.Formatter{&httpretty.JSONFormatter{}, &formatter.JWTFormatter{}}, | ||
MaxResponseBody: 1e+7, | ||
} | ||
|
||
httpClient.Transport = httpLogger.RoundTripper(httpClient.Transport) | ||
} | ||
var walletDIDIndex int | ||
|
||
if flags.walletDIDIndex != -1 { | ||
walletDIDIndex = flags.walletDIDIndex | ||
} else { | ||
walletDIDIndex = len(w.DIDs()) - 1 | ||
} | ||
|
||
provider := &oidc4vpProvider{ | ||
storageProvider: svc.StorageProvider(), | ||
httpClient: httpClient, | ||
documentLoader: svc.DocumentLoader(), | ||
vdrRegistry: svc.VDR(), | ||
cryptoSuite: svc.CryptoSuite(), | ||
wallet: w, | ||
} | ||
|
||
var flow *refresh.Flow | ||
|
||
opts := []refresh.Opt{ | ||
refresh.WithWalletDIDIndex(walletDIDIndex), | ||
} | ||
|
||
if flow, err = refresh.NewFlow(provider, opts...); err != nil { | ||
return err | ||
} | ||
|
||
return flow.Run(context.Background()) | ||
}, | ||
} | ||
} |
Oops, something went wrong.