Documentation ¶
Overview ¶
Package model contains types representing the application's data layer.
Index ¶
- Variables
- type Credential
- type CredentialRequest
- type DateFormat
- type Digest
- type DocumentMode
- type Identifier
- func (el *Identifier) AuthenticationMethods() []string
- func (el *Identifier) Created(format DateFormat) string
- func (el *Identifier) Document(mode DocumentMode) string
- func (el *Identifier) ID() string
- func (el *Identifier) Keys() []*PublicKey
- func (el *Identifier) ProduceProof(req *ProofRequest) (*Proof, error)
- func (el *Identifier) Updated(format DateFormat) string
- type Proof
- type ProofRequest
- type PublicKey
- type PublishRequest
Constants ¶
This section is empty.
Variables ¶
var AllDateFormat = []DateFormat{ DateFormatRfc3339, DateFormatRfc822, DateFormatUnix, }
var AllDigest = []Digest{ DigestSha2, DigestSha3, }
var AllDocumentMode = []DocumentMode{ DocumentModeNormalized, DocumentModeExpanded, }
Functions ¶
This section is empty.
Types ¶
type Credential ¶
type Credential struct { // Compact representation of the generated credential. Usually to be used as // a 'bearer' token to access a digital service or other form of protected resource. Token string `json:"token"` }
Verifiable digital credential.
type CredentialRequest ¶
type CredentialRequest struct { // The principal that is the subject of the requested credential, required. Subject string `json:"subject"` // Recipients the credential is intended for, required. Audience []string `json:"audience"` // Set an expiration value for the credential. // A duration string is a signed sequence of decimal numbers, each with optional // fraction and a unit suffix, such as "300ms", "1.5h" or "2h45m". Valid time units // are: "ns", "us" (or "µs"), "ms", "s", "m", "h" // Optional when generating a new token, defaults to "720h". Expiration string `json:"expiration"` // The time before which the credential MUST NOT be accepted for processing. // A duration string is a signed sequence of decimal numbers, each with optional // fraction and a unit suffix, such as "300ms", "1.5h" or "2h45m". Valid time units // are: "ns", "us" (or "µs"), "ms", "s", "m", "h" // Optional when generating a new token, defaults to "0s". NotBefore string `json:"notBefore"` // JSON-encoded custom claims to include in the credential payload. Payload string `json:"payload"` }
Request a new credential.
type DateFormat ¶
type DateFormat string
The DateFormat enum list all the supported styles available when formatting Time values.
const ( // Example: "2006-01-02T15:04:05Z07:00" DateFormatRfc3339 DateFormat = "RFC3339" // Example: "02 Jan 06 15:04 MST" DateFormatRfc822 DateFormat = "RFC822" // Returns the date as its UNIX timestamp value (in seconds) DateFormatUnix DateFormat = "UNIX" )
func (DateFormat) IsValid ¶
func (e DateFormat) IsValid() bool
func (DateFormat) MarshalGQL ¶
func (e DateFormat) MarshalGQL(w io.Writer)
func (DateFormat) String ¶
func (e DateFormat) String() string
func (*DateFormat) UnmarshalGQL ¶
func (e *DateFormat) UnmarshalGQL(v interface{}) error
type Digest ¶
type Digest string
Supported standard for generating hash values. All hashes are displayed as hex encoded strings.
func (Digest) MarshalGQL ¶
func (*Digest) UnmarshalGQL ¶
type DocumentMode ¶
type DocumentMode string
Supported representation formats for linked data (LD) documents
const ( // RDF dataset on the JSON-LD document, the algorithm used is "URDNA2015" // and the format "application/n-quads. // // https://json-ld.github.io/normalization/spec DocumentModeNormalized DocumentMode = "NORMALIZED" // Expanded JSON-LD document. // // http://www.w3.org/TR/json-ld-api/#expansion-algorithm DocumentModeExpanded DocumentMode = "EXPANDED" )
func (DocumentMode) IsValid ¶
func (e DocumentMode) IsValid() bool
func (DocumentMode) MarshalGQL ¶
func (e DocumentMode) MarshalGQL(w io.Writer)
func (DocumentMode) String ¶
func (e DocumentMode) String() string
func (*DocumentMode) UnmarshalGQL ¶
func (e *DocumentMode) UnmarshalGQL(v interface{}) error
type Identifier ¶
type Identifier struct {
// contains filtered or unexported fields
}
Identifier provides a DID instance based on the specification v1.0
func LoadIdentifier ¶
func LoadIdentifier(doc *did.Document) (*Identifier, error)
LoadIdentifier prepares an identifier instance from a provided DID document.
func NewIdentifier ¶
func NewIdentifier() (*Identifier, error)
NewIdentifier properly initialize a new DID instance with a single "master" key.
func (*Identifier) AuthenticationMethods ¶
func (el *Identifier) AuthenticationMethods() []string
AuthenticationMethods enabled for the identifier.
func (*Identifier) Created ¶
func (el *Identifier) Created(format DateFormat) string
Created returns the date of the identifier's original creation.
func (*Identifier) Document ¶
func (el *Identifier) Document(mode DocumentMode) string
Document returns the DID document for the identifier instance. The returned document remove any private key material present, making the document safe to be published and shared.
func (*Identifier) ID ¶
func (el *Identifier) ID() string
ID returns a textual representation of the DID instance.
func (*Identifier) Keys ¶
func (el *Identifier) Keys() []*PublicKey
Keys returns the registered keys on the identifier.
func (*Identifier) ProduceProof ¶
func (el *Identifier) ProduceProof(req *ProofRequest) (*Proof, error)
ProduceProof will generate a valid linked data proof for the provided data. https://w3c-dvcg.github.io/ld-proofs
func (*Identifier) Updated ¶
func (el *Identifier) Updated(format DateFormat) string
Updated returns the date of the identifier's last update operation.
type Proof ¶
type Proof struct { // A URI that identifies the digital proof suite used. Kind string `json:"kind"` // A link to a machine-readable object, such as a DID Document, that contains // authorization relations that explicitly permit the use of certain verification // methods for specific purposes. For example, a controller object could contain // statements that restrict a public key to being used only for signing Verifiable // Credentials and no other kinds of documents. Controller string `json:"controller"` // A string value that specifies the operational domain of a digital proof. // This may be an Internet domain name like "example.com", a ad-hoc value such // as "corp-level3-access", or a very specific transaction value like "8zF6T$mqP". // A signer may include a domain in its digital proof to restrict its use to // particular target, identified by the specified domain. Domain string `json:"domain"` // A string value that is included in the digital proof and MUST only be used // once for a particular domain and window of time. This value is used to mitigate // replay attacks. Nonce string `json:"nonce"` // The specific intent for the proof, the reason why an entity created it. // Acts as a safeguard to prevent the proof from being misused for a purpose // other than the one it was intended for. For example, a proof can be used // for purposes of authentication, for asserting control of a Verifiable // Credential (assertionMethod), and several others. // // Common values include: authentication, assertionMethod, keyAgreement, // capabilityInvocation, capabilityDelegation. // // https://w3c-ccg.github.io/ld-proofs/#proof-purpose Purpose string `json:"purpose"` // A set of parameters required to independently verify the proof, such as // an identifier for a public/private key pair that would be used in the // proof. VerificationMethod string `json:"verificationMethod"` // A random or pseudo-random value used by some authentication protocols to // mitigate replay attacks. Optional. Challenge string `json:"challenge"` // contains filtered or unexported fields }
Proof add authentication and integrity protection to linked data documents through the use of mathematical algorithms. https://w3c-ccg.github.io/ld-proofs/
func (*Proof) Created ¶
func (el *Proof) Created(format DateFormat) string
Created returns the proof creation's date.
func (*Proof) Document ¶
Document produces an RDF dataset on the proof's JSON-LD document, the algorithm used is "URDNA2015" and the format "application/n-quads". https://json-ld.github.io/normalization/spec
type ProofRequest ¶
type ProofRequest struct { // ID segment of the identifier instance to be used to generate the proof. ID string `json:"id"` // Data to use as proof content. Usually some form of challenge or data structure. Data string `json:"data"` // A string value that specifies the operational domain of a digital proof. Domain string `json:"domain"` // The specific intent for the proof, the reason why an entity created it. // Acts as a safeguard to prevent the proof from being misused for a purpose // other than the one it was intended for. For example, a proof can be used // for purposes of authentication, for asserting control of a Verifiable // Credential (assertionMethod), and several others. // // Common values include: authentication, assertionMethod, keyAgreement, // capabilityInvocation, capabilityDelegation. // // https://w3c-ccg.github.io/ld-proofs/#proof-purpose Purpose string `json:"purpose"` }
Request a new proof document.
type PublicKey ¶
type PublicKey struct { // Unique identifier for the key reference. ID string `json:"id"` // Cryptographic suite identifier. Kind string `json:"kind"` // Subject controlling the corresponding private key. Controller string `json:"controller"` // Public key value. Encoded in base64 as defined in RFC 4648 Value string `json:"value"` }
PublicKey represents a cryptographic key according to the "Linked Data Cryptographic Suites".
type PublishRequest ¶
type PublishRequest struct { // JSON-encoded DID document. Document string `json:"document"` }
Publish a previously generated identifier.