credential

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainersToInterface

func ContainersToInterface(cs []Container) []any

func CopyCredential

CopyCredential copies a credential into a new credential

Types

type Container

type Container struct {
	// Credential ID. This is the same value as the id within the secured credential. It is typically a URL that can be
	// dereferenced. For example, `https://ssi-service.com/v1/credentials/48958871-6a6d-4a25-889f-88c9c6835780`.
	ID string `json:"id,omitempty"`

	// The KID of the private key used to sign `credentialJwt`.
	IssuerKID string `json:"issuerKid,omitempty"`

	// Verifiable Credential in the `application/vc+ld+json` format. The credential is secured with an external proof
	// using JWS. In other words, the `proof` field is not present. See `credentialJwt` for the secured Verifiable
	// Credential.
	Credential *credential.VerifiableCredential `json:"credential,omitempty"`

	// JWT representation of `credential`, secured with an external proof signed by `issuerKid`.
	CredentialJWT *keyaccess.JWT `json:"credentialJwt,omitempty"`

	// Whether this credential is currently revoked.
	Revoked bool `json:"revoked,omitempty"`

	// Whether this credential is currently suspended.
	Suspended bool `json:"suspended,omitempty"`
}

Container acts as an abstraction over both possible credential representations JWT representations are parsed upon container creation, while the original JWT is maintained

func NewCredentialContainerFromArray

func NewCredentialContainerFromArray(creds []any) ([]Container, error)

NewCredentialContainerFromArray attempts to parse arrays of credentials of any type (either data integrity or JWT) into an array of CredentialContainers. The method will return an error if any of the credentials are invalid.

func NewCredentialContainerFromJWT

func NewCredentialContainerFromJWT(credentialJWT string) (*Container, error)

NewCredentialContainerFromJWT attempts to parse a VC-JWT credential from a string into a Container

func NewCredentialContainerFromMap

func NewCredentialContainerFromMap(credMap map[string]any) (*Container, error)

NewCredentialContainerFromMap attempts to parse a data integrity credential from a piece of JSON, which is represented as a map in go, into a Container

func (Container) HasDataIntegrityCredential

func (c Container) HasDataIntegrityCredential() bool

func (Container) HasJWTCredential

func (c Container) HasJWTCredential() bool

func (Container) HasSignedCredential

func (c Container) HasSignedCredential() bool

func (Container) IsValid

func (c Container) IsValid() bool

func (Container) JWTString

func (c Container) JWTString() string

type Verifier

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

func NewCredentialVerifier

func NewCredentialVerifier(didResolver resolution.Resolver, schemaResolver schema.Resolution) (*Verifier, error)

NewCredentialVerifier creates a new credential verifier which executes both signature and static verification checks. In the future the set of verification checks will be configurable.

func (Verifier) VerifyDataIntegrityCredential

func (v Verifier) VerifyDataIntegrityCredential(ctx context.Context, credential credsdk.VerifiableCredential) error

VerifyDataIntegrityCredential first checks the signature on the given data integrity credential. Next, it runs a set of static verification checks on the credential as per the credential service's configuration.

func (Verifier) VerifyJWT

func (v Verifier) VerifyJWT(ctx context.Context, did string, token keyaccess.JWT) error

func (Verifier) VerifyJWTCredential

func (v Verifier) VerifyJWTCredential(ctx context.Context, token keyaccess.JWT) error

VerifyJWTCredential first parses and checks the signature on the given JWT credential. Next, it runs a set of static verification checks on the credential as per the credential service's configuration.

Jump to

Keyboard shortcuts

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