github.com/hyperledger/aries-framework-go@v0.3.2/pkg/wallet/models.go (about)

     1  /*
     2  Copyright SecureKey Technologies Inc. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package wallet
     8  
     9  import (
    10  	"encoding/json"
    11  	"time"
    12  
    13  	"github.com/hyperledger/aries-framework-go/pkg/doc/verifiable"
    14  )
    15  
    16  // QueryParams contains credential queries for querying credential from wallet.
    17  // Refer https://w3c-ccg.github.io/vp-request-spec/#format for more details.
    18  type QueryParams struct {
    19  	// Type of the query.
    20  	// Allowed values  'QueryByExample', 'QueryByFrame', 'PresentationExchange', 'DIDAuth'
    21  	Type string `json:"type"`
    22  
    23  	// Query can contain one or more credential queries.
    24  	Query []json.RawMessage `json:"credentialQuery"`
    25  }
    26  
    27  // ProofFormat determines whether a credential or presentation should be signed with an external JWT proof
    28  // (wrapping the credential to form a JWT-VC) or with an embedded LD proof.
    29  type ProofFormat string
    30  
    31  const (
    32  	// ExternalJWTProofFormat indicates that a credential or presentation should be signed with an external JWT proof.
    33  	ExternalJWTProofFormat = "ExternalJWTProofFormat"
    34  	// EmbeddedLDProofFormat indicates that a credential or presentation should be signed with an embedded LD proof.
    35  	EmbeddedLDProofFormat = "EmbeddedLDProofFormat"
    36  )
    37  
    38  // ProofOptions model
    39  //
    40  // Options for adding JWT or linked data proofs to a verifiable credential or a verifiable presentation.
    41  // To be used as options for issue/prove wallet features.
    42  //
    43  type ProofOptions struct {
    44  	// Controller is a DID to be for signing. This option is required for issue/prove wallet features.
    45  	Controller string `json:"controller,omitempty"`
    46  	// VerificationMethod is the URI of the verificationMethod used for the proof.
    47  	// Optional, by default Controller public key matching 'assertion' for issue or 'authentication' for prove functions.
    48  	VerificationMethod string `json:"verificationMethod,omitempty"`
    49  	// Created date of the proof.
    50  	// Optional, current system time will be used.
    51  	Created *time.Time `json:"created,omitempty"`
    52  	// ProofFormat determines whether a credential or presentation should be signed with an external JWT proof
    53  	// (wrapping the credential to form a JWT-VC) or with an embedded LD proof.
    54  	//
    55  	// Optional: If empty, defaults to EmbeddedLDProofFormat.
    56  	ProofFormat ProofFormat `json:"proofFormat,omitempty"`
    57  	// Domain is operational domain of a digital proof.
    58  	// Optional, by default domain will not be part of proof.
    59  	Domain string `json:"domain,omitempty"`
    60  	// Challenge is a random or pseudo-random value option authentication.
    61  	// Optional, by default challenge will not be part of proof.
    62  	Challenge string `json:"challenge,omitempty"`
    63  	// ProofType is signature type used for signing.
    64  	// Optional, by default proof will be generated in Ed25519Signature2018 format.
    65  	ProofType string `json:"proofType,omitempty"`
    66  	// ProofRepresentation is type of proof data expected, (Refer verifiable.SignatureProofValue)
    67  	// Optional, by default proof will be represented as 'verifiable.SignatureProofValue'.
    68  	ProofRepresentation *verifiable.SignatureRepresentation `json:"proofRepresentation,omitempty"`
    69  }
    70  
    71  // DeriveOptions model containing options for deriving a credential.
    72  //
    73  type DeriveOptions struct {
    74  	// Frame is JSON-LD frame used for selective disclosure.
    75  	Frame map[string]interface{} `json:"frame,omitempty"`
    76  	// Nonce to prove uniqueness or freshness of the proof.
    77  	Nonce string `json:"nonce,omitempty"`
    78  }
    79  
    80  // QueryByExampleDefinition is model for QueryByExample query type.
    81  // https://w3c-ccg.github.io/vp-request-spec/#query-by-example
    82  type QueryByExampleDefinition struct {
    83  	Example *ExampleDefinition `json:"example"`
    84  }
    85  
    86  // QueryByFrameDefinition is model for QueryByExample query type.
    87  // https://w3c-ccg.github.io/vp-request-spec/
    88  // TODO QueryByExampleDefinition model is not yet finalized - https://github.com/w3c-ccg/vp-request-spec/issues/8
    89  type QueryByFrameDefinition struct {
    90  	Frame         map[string]interface{}    `json:"frame"`
    91  	TrustedIssuer []TrustedIssuerDefinition `json:"trustedIssuer"`
    92  }
    93  
    94  // ExampleDefinition frame for QueryByExample.
    95  // Refer - https://w3c-ccg.github.io/vp-request-spec/#example-2-a-query-by-example-query
    96  // TODO currently `IssuerQuery` is ignored.
    97  type ExampleDefinition struct {
    98  	Context           []string                  `json:"@context"`
    99  	Type              interface{}               `json:"type"`
   100  	CredentialSubject map[string]string         `json:"credentialSubject"`
   101  	CredentialSchema  map[string]string         `json:"credentialSchema"`
   102  	TrustedIssuer     []TrustedIssuerDefinition `json:"trustedIssuer"`
   103  	IssuerQuery       map[string]interface{}    `json:"issuerQuery"`
   104  }
   105  
   106  // TrustedIssuerDefinition is model for trusted issuer component in QueryByFrame & QueryByExample.
   107  type TrustedIssuerDefinition struct {
   108  	Issuer   string `json:"issuer"`
   109  	Required bool   `json:"required"`
   110  }
   111  
   112  // KeyPair is response of creating key pair inside wallet.
   113  type KeyPair struct {
   114  	// base64 encoded key ID of the key created.
   115  	KeyID string `json:"keyID,omitempty"`
   116  	// base64 encoded public key of the key pair created.
   117  	PublicKey string `json:"publicKey,omitempty"`
   118  }
   119  
   120  // CredentialInteractionStatus holds the status of credential share/issuance interaction from wallet.
   121  // Typically holds web redirect info of credential interaction conclusion or problem-report.
   122  type CredentialInteractionStatus struct {
   123  	// One of the status present proof or issue credential interaction
   124  	// Refer https://github.com/hyperledger/aries-rfcs/blob/main/features/0015-acks/README.md#ack-status.
   125  	Status string `json:"status"`
   126  	// Optional web redirect URL info sent by verifier.
   127  	RedirectURL string `json:"url,omitempty"`
   128  }