Documentation ¶
Index ¶
- func ExtractID(input string) string
- type BatchCreateCredentialsRequest
- type BatchCreateCredentialsResponse
- type CreateCredentialRequest
- type CreateCredentialResponse
- type DeleteCredentialRequest
- type GetCredentialRequest
- type GetCredentialResponse
- type GetCredentialStatusListRequest
- type GetCredentialStatusListResponse
- type GetCredentialStatusRequest
- type GetCredentialStatusResponse
- type ListCredentialByIssuerRequest
- type ListCredentialBySchemaRequest
- type ListCredentialBySubjectRequest
- type ListCredentialsResponse
- type Service
- func (s Service) BatchCreateCredentials(ctx context.Context, batchRequest BatchCreateCredentialsRequest) (*BatchCreateCredentialsResponse, error)
- func (s Service) Config() config.CredentialServiceConfig
- func (s Service) CreateCredential(ctx context.Context, request CreateCredentialRequest) (*CreateCredentialResponse, error)
- func (s Service) DeleteCredential(ctx context.Context, request DeleteCredentialRequest) error
- func (s Service) GetCredential(ctx context.Context, request GetCredentialRequest) (*GetCredentialResponse, error)
- func (s Service) GetCredentialStatus(ctx context.Context, request GetCredentialStatusRequest) (*GetCredentialStatusResponse, error)
- func (s Service) GetCredentialStatusList(ctx context.Context, request GetCredentialStatusListRequest) (*GetCredentialStatusListResponse, error)
- func (s Service) GetCredentialsByIssuerAndSchemaWithStatus(ctx context.Context, issuer string, schema string) ([]credential.VerifiableCredential, error)
- func (s Service) ListCredentials(ctx context.Context) (*ListCredentialsResponse, error)
- func (s Service) ListCredentialsByIssuer(ctx context.Context, request ListCredentialByIssuerRequest) (*ListCredentialsResponse, error)
- func (s Service) ListCredentialsBySchema(ctx context.Context, request ListCredentialBySchemaRequest) (*ListCredentialsResponse, error)
- func (s Service) ListCredentialsBySubject(ctx context.Context, request ListCredentialBySubjectRequest) (*ListCredentialsResponse, error)
- func (s Service) Status() framework.Status
- func (s Service) Type() framework.Type
- func (s Service) UpdateCredentialStatus(ctx context.Context, request UpdateCredentialStatusRequest) (*UpdateCredentialStatusResponse, error)
- func (s Service) VerifyCredential(ctx context.Context, request VerifyCredentialRequest) (*VerifyCredentialResponse, error)
- type StatusListCredentialMetadata
- type StatusListIndex
- type Storage
- func (cs *Storage) CreateStatusListCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest, ...) (int, error)
- func (cs *Storage) DeleteCredential(ctx context.Context, id string) error
- func (cs *Storage) DeleteStatusListCredential(ctx context.Context, id string) error
- func (cs *Storage) GetCredential(ctx context.Context, id string) (*StoredCredential, error)
- func (cs *Storage) GetCredentialsByIssuerAndSchema(ctx context.Context, issuer string, schema string) ([]StoredCredential, error)
- func (cs *Storage) GetCredentialsBySchema(ctx context.Context, schema string) ([]StoredCredential, error)
- func (cs *Storage) GetNextStatusListRandomIndex(ctx context.Context, slcMetadata StatusListCredentialMetadata) (int, error)
- func (cs *Storage) GetStatusListCredential(ctx context.Context, id string) (*StoredCredential, error)
- func (cs *Storage) GetStatusListCredentialKeyData(ctx context.Context, issuer string, schema string, ...) (*StoredCredential, error)
- func (cs *Storage) GetStatusListCredentialWatchKey(issuer, schema, statusPurpose string) storage.WatchKey
- func (cs *Storage) GetStatusListCredentialsByIssuerSchemaPurpose(ctx context.Context, issuer string, schema string, ...) ([]StoredCredential, error)
- func (cs *Storage) GetStatusListCurrentIndexWatchKey(issuer, schema, statusPurpose string) storage.WatchKey
- func (cs *Storage) GetStatusListIndexPoolWatchKey(issuer, schema, statusPurpose string) storage.WatchKey
- func (cs *Storage) IncrementStatusListIndexTx(ctx context.Context, tx storage.Tx, slcMetadata StatusListCredentialMetadata) error
- func (cs *Storage) ListCredentials(ctx context.Context) ([]StoredCredential, error)
- func (cs *Storage) ListCredentialsByIssuer(ctx context.Context, issuer string) ([]StoredCredential, error)
- func (cs *Storage) ListCredentialsBySubject(ctx context.Context, subject string) ([]StoredCredential, error)
- func (cs *Storage) StoreCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest) error
- func (cs *Storage) StoreStatusListCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest, ...) error
- func (cs *Storage) WriteMany(ctx context.Context, writeContexts []WriteContext) error
- type StoreCredentialRequest
- type StoredCredential
- type UpdateCredentialStatusRequest
- type UpdateCredentialStatusResponse
- type VerifyCredentialRequest
- type VerifyCredentialResponse
- type WriteContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractID ¶
ExtractID is a function that takes a string input and returns a string that contains an ID extracted from the input string. The ID is extracted by searching for a string that matches the regular expression, which matches a forward slash followed by one or more characters that are either letters (upper or lower case), digits (0-9), or hyphens (-), at the end of the input string. If a match is found, the function returns the matched string with the forward slash removed (i.e., everything after the forward slash). If no match is found, an empty string is returned.
Types ¶
type BatchCreateCredentialsRequest ¶
type BatchCreateCredentialsRequest struct {
Requests []CreateCredentialRequest
}
type BatchCreateCredentialsResponse ¶
type BatchCreateCredentialsResponse struct {
Credentials []credential.Container
}
type CreateCredentialRequest ¶
type CreateCredentialRequest struct { Issuer string `json:"issuer" validate:"required"` IssuerKID string `json:"issuerKid" 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"` }
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 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"`
}
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) Config ¶
func (s Service) Config() config.CredentialServiceConfig
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) GetCredentialsByIssuerAndSchemaWithStatus ¶
func (s Service) GetCredentialsByIssuerAndSchemaWithStatus(ctx context.Context, issuer string, schema string) ([]credential.VerifiableCredential, error)
func (Service) ListCredentials ¶
func (s Service) ListCredentials(ctx context.Context) (*ListCredentialsResponse, error)
func (Service) ListCredentialsByIssuer ¶
func (s Service) ListCredentialsByIssuer(ctx context.Context, request ListCredentialByIssuerRequest) (*ListCredentialsResponse, error)
func (Service) ListCredentialsBySchema ¶
func (s Service) ListCredentialsBySchema(ctx context.Context, request ListCredentialBySchemaRequest) (*ListCredentialsResponse, error)
func (Service) ListCredentialsBySubject ¶
func (s Service) ListCredentialsBySubject(ctx context.Context, request ListCredentialBySubjectRequest) (*ListCredentialsResponse, error)
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. Note: https://github.com/TBD54566975/ssi-sdk/issues/213
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 (*Storage) DeleteStatusListCredential ¶
func (*Storage) GetCredential ¶
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) GetCredentialsBySchema ¶
func (cs *Storage) GetCredentialsBySchema(ctx context.Context, schema string) ([]StoredCredential, error)
GetCredentialsBySchema gets all credentials stored with a prefix key containing the schema 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 (*Storage) GetStatusListCredential ¶
func (*Storage) GetStatusListCredentialKeyData ¶
func (cs *Storage) GetStatusListCredentialKeyData(ctx context.Context, issuer string, schema string, statusPurpose statussdk.StatusPurpose) (*StoredCredential, error)
func (*Storage) GetStatusListCredentialWatchKey ¶
func (*Storage) GetStatusListCredentialsByIssuerSchemaPurpose ¶
func (cs *Storage) GetStatusListCredentialsByIssuerSchemaPurpose(ctx context.Context, issuer string, schema string, statusPurpose statussdk.StatusPurpose) ([]StoredCredential, error)
func (*Storage) GetStatusListCurrentIndexWatchKey ¶
func (*Storage) GetStatusListIndexPoolWatchKey ¶
func (*Storage) IncrementStatusListIndexTx ¶
func (*Storage) ListCredentials ¶
func (cs *Storage) ListCredentials(ctx context.Context) ([]StoredCredential, error)
ListCredentials gets all credentials stored with a prefix key 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) ListCredentialsByIssuer ¶
func (cs *Storage) ListCredentialsByIssuer(ctx context.Context, issuer string) ([]StoredCredential, error)
ListCredentialsByIssuer 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) ListCredentialsBySubject ¶
func (cs *Storage) ListCredentialsBySubject(ctx context.Context, subject string) ([]StoredCredential, error)
ListCredentialsBySubject gets all credentials stored with a prefix key containing the subject 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) StoreCredentialTx ¶
func (*Storage) StoreStatusListCredentialTx ¶
func (cs *Storage) StoreStatusListCredentialTx(ctx context.Context, tx storage.Tx, request StoreCredentialRequest, slcMetadata StatusListCredentialMetadata) error
type StoreCredentialRequest ¶
type StoredCredential ¶
type StoredCredential struct { // This Key is generated by the storage module upon first write. Key string `json:"key"` // This is the same as `credential.id`. Typically, a URL that can be dereferenced. CredentialID string `json:"credentialId"` // only one of these fields should be present Credential *credential.VerifiableCredential `json:"credential,omitempty"` CredentialJWT *keyaccess.JWT `json:"token,omitempty"` Issuer string `json:"issuer"` IssuerKID string `json:"issuerKid"` Subject string `json:"subject"` Schema string `json:"schema"` IssuanceDate string `json:"issuanceDate"` Revoked bool `json:"revoked"` Suspended bool `json:"suspended"` }
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 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 WriteContext ¶
type WriteContext struct {
// contains filtered or unexported fields
}