credential

package
v0.0.0-...-0fc66b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchCreateCredentialsRequest

type BatchCreateCredentialsRequest struct {
	Requests []CreateCredentialRequest
}

type BatchCreateCredentialsResponse

type BatchCreateCredentialsResponse struct {
	Credentials []credential.Container
}

type BatchUpdateCredentialStatusRequest

type BatchUpdateCredentialStatusRequest struct {
	Requests []UpdateCredentialStatusRequest `json:"requests"`
}

type BatchUpdateCredentialStatusResponse

type BatchUpdateCredentialStatusResponse struct {
	CredentialStatuses []Status `json:"credentialStatuses"`
}

type CreateCredentialRequest

type CreateCredentialRequest struct {
	Issuer string `json:"issuer" validate:"required"`
	// Fully qualified verification method ID to determine the private key used for signing this credential. For example
	// `did:ion:EiDpQBo_nEfuLVeppgmPVQNEhtrnZLWFsB9ziZUuaKCJ3Q#83526c36-136c-423b-a57a-f190b83ae531`.
	FullyQualifiedVerificationMethodID string `json:"issuerVerificationMethodId" validate:"required"`
	Subject                            string `json:"subject" validate:"required"`
	// A context is optional. If not present, we'll apply default, required context values.
	Context string `json:"context,omitempty"`
	// A schema ID is optional. If present, we'll attempt to look it up and validate the data against it.
	SchemaID    string         `json:"schemaId,omitempty"`
	Data        map[string]any `json:"data,omitempty"`
	Expiry      string         `json:"expiry,omitempty"`
	Revocable   bool           `json:"revocable,omitempty"`
	Suspendable bool           `json:"suspendable,omitempty"`
	Evidence    []any          `json:"evidence,omitempty"`
}

func (CreateCredentialRequest) IsValid

func (csr CreateCredentialRequest) IsValid() error

type CreateCredentialResponse

type CreateCredentialResponse struct {
	credential.Container `json:"credential,omitempty"`
}

CreateCredentialResponse holds a resulting credential from credential creation, which is an XOR type: containing either a Data Integrity Proofed credential or a VC-JWT representation.

type DeleteCredentialRequest

type DeleteCredentialRequest struct {
	ID string `json:"id" validate:"required"`
}

type GetCredentialRequest

type GetCredentialRequest struct {
	ID string `json:"id" validate:"required"`
}

type GetCredentialResponse

type GetCredentialResponse struct {
	credential.Container `json:"credential,omitempty"`
}

type GetCredentialStatusListRequest

type GetCredentialStatusListRequest struct {
	ID string `json:"id" validate:"required"`
}

type GetCredentialStatusListResponse

type GetCredentialStatusListResponse struct {
	credential.Container `json:"credential,omitempty"`
}

type GetCredentialStatusRequest

type GetCredentialStatusRequest struct {
	ID string `json:"id" validate:"required"`
}

type GetCredentialStatusResponse

type GetCredentialStatusResponse struct {
	Revoked   bool `json:"revoked" validate:"required"`
	Suspended bool `json:"suspended" validate:"required"`
}

type ListCredentialByIssuerRequest

type ListCredentialByIssuerRequest struct {
	Issuer string `json:"issuer" validate:"required"`
}

type ListCredentialBySchemaRequest

type ListCredentialBySchemaRequest struct {
	Schema string `json:"schema" validate:"required"`
}

type ListCredentialBySubjectRequest

type ListCredentialBySubjectRequest struct {
	Subject string `json:"subject" validate:"required"`
}

type ListCredentialsResponse

type ListCredentialsResponse struct {
	Credentials   []credential.Container `json:"credentials,omitempty"`
	NextPageToken string                 `json:"nextPageToken,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewCredentialService

func NewCredentialService(config config.CredentialServiceConfig, s storage.ServiceStorage, keyStore *keystore.Service,
	didResolver resolution.Resolver, schema *schema.Service) (*Service, error)

func (Service) BatchCreateCredentials

func (s Service) BatchCreateCredentials(ctx context.Context, batchRequest BatchCreateCredentialsRequest) (*BatchCreateCredentialsResponse, error)

func (Service) BatchUpdateCredentialStatus

func (s Service) BatchUpdateCredentialStatus(ctx context.Context, batchRequest BatchUpdateCredentialStatusRequest) (*BatchUpdateCredentialStatusResponse, error)

func (Service) Config

func (Service) CreateCredential

func (s Service) CreateCredential(ctx context.Context, request CreateCredentialRequest) (*CreateCredentialResponse, error)

func (Service) DeleteCredential

func (s Service) DeleteCredential(ctx context.Context, request DeleteCredentialRequest) error

func (Service) GetCredential

func (s Service) GetCredential(ctx context.Context, request GetCredentialRequest) (*GetCredentialResponse, error)

func (Service) GetCredentialStatus

func (s Service) GetCredentialStatus(ctx context.Context, request GetCredentialStatusRequest) (*GetCredentialStatusResponse, error)

func (Service) GetCredentialStatusList

func (s Service) GetCredentialStatusList(ctx context.Context, request GetCredentialStatusListRequest) (*GetCredentialStatusListResponse, error)

func (Service) ListCredentials

func (s Service) ListCredentials(ctx context.Context, filter filtering.Filter, request pagination.PageRequest) (*ListCredentialsResponse, error)

func (Service) Status

func (s Service) Status() framework.Status

func (Service) Type

func (s Service) Type() framework.Type

func (Service) UpdateCredentialStatus

func (s Service) UpdateCredentialStatus(ctx context.Context, request UpdateCredentialStatusRequest) (*UpdateCredentialStatusResponse, error)

func (Service) VerifyCredential

func (s Service) VerifyCredential(ctx context.Context, request VerifyCredentialRequest) (*VerifyCredentialResponse, error)

VerifyCredential does three levels of verification on a credential: 1. Makes sure the credential has a valid signature 2. Makes sure the credential has is not expired 3. Makes sure the credential complies with the VC Data Model 4. If the credential has a schema, makes sure its data complies with the schema LATER: Makes sure the credential has not been revoked, other checks.

type Status

type Status struct {
	// ID of the credentials whose status this object represents.
	ID        string `json:"id,omitempty"`
	Revoked   bool   `json:"revoked" validate:"required"`
	Suspended bool   `json:"suspended" validate:"required"`
}

type StatusListCredentialMetadata

type StatusListCredentialMetadata struct {
	// contains filtered or unexported fields
}

type StatusListIndex

type StatusListIndex struct {
	Index int `json:"index"`
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

func NewCredentialStorage

func NewCredentialStorage(db storage.ServiceStorage) (*Storage, error)

func (*Storage) CreateStatusListCredentialTx

func (cs *Storage) CreateStatusListCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest, slcMetadata StatusListCredentialMetadata) (int, error)

CreateStatusListCredentialTx creates a new status list credential with the provided metadata and stores it in the database as a transaction. The function generates a unique random number and stores it along with the metadata in the database and then returns it

func (*Storage) DeleteCredential

func (cs *Storage) DeleteCredential(ctx context.Context, id string) error

func (*Storage) DeleteStatusListCredential

func (cs *Storage) DeleteStatusListCredential(ctx context.Context, id string) error

func (*Storage) GetCredential

func (cs *Storage) GetCredential(ctx context.Context, id string) (*StoredCredential, error)

func (*Storage) GetCredentialsByIssuerAndSchema

func (cs *Storage) GetCredentialsByIssuerAndSchema(ctx context.Context, issuer string, schema string) ([]StoredCredential, error)

GetCredentialsByIssuerAndSchema gets all credentials stored with a prefix key containing the issuer value The method is greedy, meaning if multiple values are found...and some fail during processing, we will return only the successful values and log an error for the failures.

func (*Storage) GetNextStatusListRandomIndex

func (cs *Storage) GetNextStatusListRandomIndex(ctx context.Context, slcMetadata StatusListCredentialMetadata) (int, error)

func (*Storage) GetStatusListCredential

func (cs *Storage) GetStatusListCredential(ctx context.Context, id string) (*StoredCredential, error)

func (*Storage) GetStatusListCredentialKeyData

func (cs *Storage) GetStatusListCredentialKeyData(ctx context.Context, issuer string, schema string, statusPurpose statussdk.StatusPurpose) (*StoredCredential, error)

func (*Storage) GetStatusListCredentialWatchKey

func (cs *Storage) GetStatusListCredentialWatchKey(issuer, schema, statusPurpose string) storage.WatchKey

func (*Storage) GetStatusListCredentialsByIssuerSchemaPurpose

func (cs *Storage) GetStatusListCredentialsByIssuerSchemaPurpose(ctx context.Context, issuer string, schema string, statusPurpose statussdk.StatusPurpose) ([]StoredCredential, error)

func (*Storage) GetStatusListCurrentIndexWatchKey

func (cs *Storage) GetStatusListCurrentIndexWatchKey(issuer, schema, statusPurpose string) storage.WatchKey

func (*Storage) GetStatusListIndexPoolWatchKey

func (cs *Storage) GetStatusListIndexPoolWatchKey(issuer, schema, statusPurpose string) storage.WatchKey

func (*Storage) IncrementStatusListIndexTx

func (cs *Storage) IncrementStatusListIndexTx(ctx context.Context, tx storage.Tx, slcMetadata StatusListCredentialMetadata) error

func (*Storage) ListCredentials

func (cs *Storage) ListCredentials(ctx context.Context, filter filtering.Filter, page *common.Page) (*StoredCredentials, error)

func (*Storage) StoreCredentialTx

func (cs *Storage) StoreCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest) error

func (*Storage) StoreStatusListCredentialTx

func (cs *Storage) StoreStatusListCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest, slcMetadata StatusListCredentialMetadata) error

func (*Storage) WriteMany

func (cs *Storage) WriteMany(ctx context.Context, writeContexts []WriteContext) error

type StoreCredentialRequest

type StoreCredentialRequest struct {
	credint.Container
}

type StoredCredential

type StoredCredential struct {
	// This Key is generated by the storage module upon first write.
	Key string `json:"key"`

	// ID of the credential that identifies it within ssi service.
	LocalCredentialID string `json:"LocalCredentialId"`

	// only one of these fields should be present
	Credential    *credential.VerifiableCredential `json:"credential,omitempty"`
	CredentialJWT *keyaccess.JWT                   `json:"token,omitempty"`

	Issuer                             string `json:"issuer"`
	FullyQualifiedVerificationMethodID string `json:"fullyQualifiedVerificationMethodId"`
	Subject                            string `json:"subject"`
	Schema                             string `json:"schema"`
	IssuanceDate                       string `json:"issuanceDate"`
	Revoked                            bool   `json:"revoked"`
	Suspended                          bool   `json:"suspended"`
}

func (*StoredCredential) FilterVariablesMap

func (sc *StoredCredential) FilterVariablesMap() map[string]any

func (*StoredCredential) GetStatusPurpose

func (sc *StoredCredential) GetStatusPurpose() string

func (*StoredCredential) HasCredentialStatus

func (sc *StoredCredential) HasCredentialStatus() bool

func (*StoredCredential) HasDataIntegrityCredential

func (sc *StoredCredential) HasDataIntegrityCredential() bool

func (*StoredCredential) HasJWTCredential

func (sc *StoredCredential) HasJWTCredential() bool

func (*StoredCredential) IsValid

func (sc *StoredCredential) IsValid() bool

type StoredCredentials

type StoredCredentials struct {
	StoredCredentials []StoredCredential
	NextPageToken     string
}

type UpdateCredentialStatusRequest

type UpdateCredentialStatusRequest struct {
	ID        string `json:"id" validate:"required"`
	Revoked   bool   `json:"revoked" validate:"required"`
	Suspended bool   `json:"suspended" validate:"required"`
}

type UpdateCredentialStatusResponse

type UpdateCredentialStatusResponse struct {
	Status
}

type VerifyCredentialRequest

type VerifyCredentialRequest struct {
	DataIntegrityCredential *credential.VerifiableCredential `json:"credential,omitempty"`
	CredentialJWT           *keyaccess.JWT                   `json:"credentialJwt,omitempty"`
}

func (VerifyCredentialRequest) IsValid

func (vcr VerifyCredentialRequest) IsValid() error

IsValid checks if the request is valid, meaning there is at least one data integrity (with proof) OR jwt credential, but not both

type VerifyCredentialResponse

type VerifyCredentialResponse struct {
	Verified bool   `json:"verified"`
	Reason   string `json:"reason,omitempty"`
}

type WriteContext

type WriteContext struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL