This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f40dc2c
commit f890817
Showing
4 changed files
with
298 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package vcwallet | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
// provider contains dependencies for the verifiable credential wallet client | ||
// and is typically created by using aries.Context(). | ||
type provider interface { | ||
// TODO to be added #2433 | ||
} | ||
|
||
// Client enable access to verifiable credential wallet features. | ||
type Client struct { | ||
// ID of wallet content owner | ||
userID string | ||
} | ||
|
||
// New returns new verifiable credential wallet client for given user. | ||
func New(userID string, ctx provider) *Client { | ||
// TODO initialize providers for stores, VDR, KMS #2433 | ||
// TODO create user profile if not already created #2433 | ||
return &Client{userID: userID} | ||
} | ||
|
||
// Export produces a serialized exported wallet representation. | ||
// Only ciphertext wallet contents can be exported. | ||
// | ||
// Args: | ||
// - auth: token to be used to lock the wallet before exporting. | ||
// | ||
// Returns exported locked wallet. | ||
// | ||
// Supported data models: | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Profile | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential | ||
// | ||
func (c *Client) Export(auth string) (json.RawMessage, error) { | ||
// TODO to be added #2433 | ||
return nil, fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Import Takes a serialized exported wallet representation as input | ||
// and imports all contents into wallet. | ||
// | ||
// Args: | ||
// - contents: wallet content to be imported. | ||
// - auth: token used while exporting the wallet. | ||
// | ||
// Supported data models: | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Profile | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential | ||
// | ||
func (c *Client) Import(auth string, contents json.RawMessage) error { | ||
// TODO to be added #2433 | ||
return fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Add adds given data model to wallet contents store. | ||
// | ||
// Supported data models: | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Profile | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential | ||
// | ||
func (c *Client) Add(model json.RawMessage) error { | ||
// TODO to be added #2433 | ||
return fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Remove removes wallet content by content ID. | ||
// | ||
// Supported data models: | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Profile | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential | ||
// | ||
func (c *Client) Remove(contentID string) error { | ||
// TODO to be added #2433 | ||
return fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Get fetches a wallet content by content ID. | ||
// | ||
// Supported data models: | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Profile | ||
// - https://w3c-ccg.github.io/universal-wallet-interop-spec/#Credential | ||
// | ||
func (c *Client) Get(contentID string) (json.RawMessage, error) { | ||
// TODO to be added #2433 | ||
return nil, fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Query returns a collection of results based on current wallet contents. | ||
// | ||
// Supported Query Types: | ||
// - https://www.w3.org/TR/json-ld11-framing | ||
// - https://identity.foundation/presentation-exchange | ||
// | ||
func (c *Client) Query(query *QueryParams) ([]json.RawMessage, error) { | ||
// TODO to be added #2433 | ||
return nil, fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Issue adds proof to a Verifiable Credential. | ||
// | ||
// Args: | ||
// - A verifiable credential with or without proof | ||
// - Proof options | ||
// | ||
func (c *Client) Issue(credential json.RawMessage, options *ProofOptions) (json.RawMessage, error) { | ||
// TODO to be added #2433 | ||
return nil, fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Prove produces a Verifiable Presentation. | ||
// | ||
// Args: | ||
// - List of verifiable credentials IDs. | ||
// - Proof options | ||
// | ||
func (c *Client) Prove(credentialIDs []string, options *ProofOptions) (json.RawMessage, error) { | ||
// TODO to be added #2433 | ||
return nil, fmt.Errorf("to be implemented") | ||
} | ||
|
||
// Verify takes Takes a Verifiable Credential or Verifiable Presentation as input,. | ||
// | ||
// Args: | ||
// - a Verifiable Credential or Verifiable Presentation | ||
// | ||
// Returns: a boolean verified, and an error if verified is false. | ||
func (c *Client) Verify(raw json.RawMessage) (bool, error) { | ||
// TODO to be added #2433 | ||
return false, fmt.Errorf("to be implemented") | ||
} |
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,110 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package vcwallet | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
sampleUserID = "sample-user01" | ||
toBeImplementedErr = "to be implemented" | ||
) | ||
|
||
func TestNew(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
} | ||
|
||
func TestClient_Export(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
result, err := vcWalletClient.Export("") | ||
require.Empty(t, result) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Import(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
err := vcWalletClient.Import("", nil) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Add(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
err := vcWalletClient.Add(nil) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Remove(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
err := vcWalletClient.Remove("") | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Get(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
result, err := vcWalletClient.Get("") | ||
require.Empty(t, result) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Query(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
results, err := vcWalletClient.Query(&QueryParams{}) | ||
require.Empty(t, results) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Issue(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
result, err := vcWalletClient.Issue(nil, &ProofOptions{}) | ||
require.Empty(t, result) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Prove(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
result, err := vcWalletClient.Prove(nil, &ProofOptions{}) | ||
require.Empty(t, result) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} | ||
|
||
func TestClient_Verify(t *testing.T) { | ||
vcWalletClient := New(sampleUserID, nil) | ||
require.NotEmpty(t, vcWalletClient) | ||
|
||
result, err := vcWalletClient.Verify(nil) | ||
require.Empty(t, result) | ||
require.Error(t, err) | ||
require.EqualError(t, err, toBeImplementedErr) | ||
} |
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,46 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package vcwallet | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
) | ||
|
||
// QueryParams model | ||
// | ||
// Parameters for querying vc wallet contents. | ||
// | ||
type QueryParams struct { | ||
// Type of the query. | ||
// Allowed values 'QueryByFrame', 'PresentationExchange' | ||
Type string | ||
|
||
// Wallet content query. | ||
Query json.RawMessage | ||
} | ||
|
||
// ProofOptions model | ||
// | ||
// Options for adding linked data proofs to a verifiable credential or a verifiable presentation. | ||
// | ||
type ProofOptions struct { | ||
// VerificationMethod is the URI of the verificationMethod used for the proof. | ||
VerificationMethod string `json:"verificationMethod,omitempty"` | ||
// ProofPurpose is purpose of the proof. | ||
ProofPurpose string `json:"proofPurpose,omitempty"` | ||
// Controller is a DID to be for signing. | ||
Controller string `json:"controller,omitempty"` | ||
// Created date of the proof. If omitted current system time will be used. | ||
Created *time.Time `json:"created,omitempty"` | ||
// Domain is operational domain of a digital proof. | ||
Domain string `json:"domain,omitempty"` | ||
// Challenge is a random or pseudo-random value option authentication | ||
Challenge string `json:"challenge,omitempty"` | ||
// ProofType is signature type used for signing | ||
ProofType string `json:"proofType,omitempty"` | ||
} |