Documentation
¶
Index ¶
- Constants
- Variables
- func AutoCorrectSelfAttestedCredential(credential vc.VerifiableCredential, requester did.DID) vc.VerifiableCredential
- func DiscoveryRegistrationCredentialTypeV1URI() ssi.URI
- func ExtractTypes(credential vc.VerifiableCredential) []string
- func FilterOnDIDMethod(credentials []vc.VerifiableCredential, didMethods []string) []vc.VerifiableCredential
- func ParseLDProof(presentation vc.VerifiablePresentation) (*proof.LDProof, error)
- func PresentationExpirationDate(presentation vc.VerifiablePresentation) *time.Time
- func PresentationIssuanceDate(presentation vc.VerifiablePresentation) *time.Time
- func PresentationSigner(presentation vc.VerifiablePresentation) (*did.DID, error)
- func PresenterIsCredentialSubject(vp vc.VerifiablePresentation) (*did.DID, error)
- func ResolveSubjectDID(credentials ...vc.VerifiableCredential) (*did.DID, error)
- func ValidateRevocation(r Revocation) error
- type BaseCredentialSubject
- type DiscoveryRegistrationCredentialSubject
- type Formats
- type NutsAuthorizationCredentialSubject
- type NutsOrganizationCredentialSubject
- type Resource
- type Revocation
- type Validator
Constants ¶
const ( // NutsOrganizationCredentialType is the VC type for a NutsOrganizationCredential NutsOrganizationCredentialType = "NutsOrganizationCredential" // NutsAuthorizationCredentialType is the VC type for a NutsAuthorizationCredential NutsAuthorizationCredentialType = "NutsAuthorizationCredential" // X509CredentialType is the VC type for a X509Credential X509CredentialType = "X509Credential" // NutsV1Context is the nuts V1 json-ld context NutsV1Context = "https://nuts.nl/credentials/v1" )
const ( // CredentialSubjectPath represents the JSON path to the holder of the VC CredentialSubjectPath = "credentialSubject.id" // RevocationSubjectPath represents the JSON path to the subject of a revocation, typically the VC id RevocationSubjectPath = "subject" )
const DiscoveryRegistrationCredentialType = "DiscoveryRegistrationCredential"
DiscoveryRegistrationCredentialType is the type for a Discovery Registration Credential
Variables ¶
var (
// NutsOrganizationCredentialTypeURI is the VC type for a NutsOrganizationCredentialType as URI
NutsOrganizationCredentialTypeURI, _ = ssi.ParseURI(NutsOrganizationCredentialType)
// NutsAuthorizationCredentialTypeURI is the VC type for a NutsAuthorizationCredentialType as URI
NutsAuthorizationCredentialTypeURI, _ = ssi.ParseURI(NutsAuthorizationCredentialType)
// NutsV1ContextURI is the nuts V1 json-ld context as URI
NutsV1ContextURI = ssi.MustParseURI(NutsV1Context)
)
var RevocationType = ssi.MustParseURI("CredentialRevocation")
RevocationType contains the JSON-LD type for a revocation
Functions ¶
func AutoCorrectSelfAttestedCredential ¶
func AutoCorrectSelfAttestedCredential(credential vc.VerifiableCredential, requester did.DID) vc.VerifiableCredential
AutoCorrectSelfAttestedCredential sets the required fields for a self-attested credential. These are provided through the API, and for convenience we set the required fields, if not already set. It only does this for unsigned JSON-LD credentials. DO NOT USE THIS WITH JWT_VC CREDENTIALS.
func ExtractTypes ¶
func ExtractTypes(credential vc.VerifiableCredential) []string
ExtractTypes extract additional VC types from the VC as strings It removes the default `VerifiableCredential` type from the types, returns the rest.
func FilterOnDIDMethod ¶
func FilterOnDIDMethod(credentials []vc.VerifiableCredential, didMethods []string) []vc.VerifiableCredential
FilterOnDIDMethod filters the credentials based on the DID method of the issuer and credentialSubject. credentials are only removed if there's a false match. Nil fields are ignored.
func ParseLDProof ¶
func ParseLDProof(presentation vc.VerifiablePresentation) (*proof.LDProof, error)
ParseLDProof parses the LinkedData proof from the presentation. It returns an error if the presentation does not have exactly 1 proof.
func PresentationExpirationDate ¶
func PresentationExpirationDate(presentation vc.VerifiablePresentation) *time.Time
PresentationExpirationDate returns the date at which the presentation was issued. For JSON-LD, it looks at the first LinkedData proof's 'expires' property. For JWT, it looks at the 'exp' claim. If it can't resolve the date, it returns nil.
func PresentationIssuanceDate ¶
func PresentationIssuanceDate(presentation vc.VerifiablePresentation) *time.Time
PresentationIssuanceDate returns the date at which the presentation was issued. For JSON-LD, it looks at the first LinkedData proof's 'created' property. For JWT, it looks at the 'nbf' claim, or if that is not present, the 'iat' claim. If it can't resolve the date, it returns nil.
func PresentationSigner ¶
func PresentationSigner(presentation vc.VerifiablePresentation) (*did.DID, error)
PresentationSigner returns the DID of the signer of the presentation. It does not do any signature validation. For JWTs it returns the did in the kid header of the JWT. For JSON-LD it returns the verification method of the proof.
func PresenterIsCredentialSubject ¶
func PresenterIsCredentialSubject(vp vc.VerifiablePresentation) (*did.DID, error)
PresenterIsCredentialSubject checks if the presenter of the VP is the same as the subject of the VCs being presented. If the presentation signer or credential subject can't be resolved, it returns an error. If parsing succeeds and the signer DID is the same as the credential subject DID, it returns the DID.
func ResolveSubjectDID ¶
func ResolveSubjectDID(credentials ...vc.VerifiableCredential) (*did.DID, error)
ResolveSubjectDID resolves the subject DID from the given credentials. It returns an error if: - the credentials do not have the same subject DID. - the credentials do not have a subject DID.
func ValidateRevocation ¶
func ValidateRevocation(r Revocation) error
ValidateRevocation checks if a revocation record contains the required fields and if fields have the correct value.
Types ¶
type BaseCredentialSubject ¶
type BaseCredentialSubject struct {
ID string `json:"id"`
}
BaseCredentialSubject defines the CredentialSubject struct for fields that are shared amongst all CredentialSubjects
type DiscoveryRegistrationCredentialSubject ¶
type DiscoveryRegistrationCredentialSubject map[string]interface{}
DiscoveryRegistrationCredentialSubject defines the CredentialSubject struct for the DiscoveryRegistrationCredential
type Formats ¶
type Formats struct {
Map map[string]map[string][]string
ParamAliases map[string]string
// FormatAliases allows aliasing the VP and VC formats. This feature can be removed when
// https://identity.foundation/claim-format-registry/ and the OpenID4VC specifications have
// agreed on the format designators.
FormatAliases map[string]string
}
Formats is a map of supported formats and their parameters according to https://identity.foundation/claim-format-registry/ E.g., ldp_vp: {proof_type: [Ed25519Signature2018, JsonWebSignature2020]}
func DIFClaimFormats ¶
DIFClaimFormats returns the given DIF claim formats as specified by https://identity.foundation/claim-format-registry/ as Formats.
func OpenIDSupportedFormats ¶
OpenIDSupportedFormats returns the given OpenID supported formats as specified by the OpenID4VC family of specs.
func (Formats) Match ¶
Match takes the other supports formats and returns the formats that are supported by both sets. If a format is supported by both sets, it returns the intersection of the parameters. If a format is supported by both sets, but parameters overlap (e.g. supported cryptographic algorithms), the format is not included in the result.
type NutsAuthorizationCredentialSubject ¶
type NutsAuthorizationCredentialSubject struct {
// ID contains the DID of the subject
ID string `json:"id"`
// PurposeOfUse refers to the Bolt access policy
PurposeOfUse string `json:"purposeOfUse"`
// Resources contains additional individual resources that can be accessed.
Resources []Resource `json:"resources,omitempty"`
// Subject contains a URN referring to the subject of care (not the credential subject)
Subject *string `json:"subject,omitempty"`
}
NutsAuthorizationCredentialSubject defines the CredentialSubject struct for the NutsAuthorizationCredential
type NutsOrganizationCredentialSubject ¶
type NutsOrganizationCredentialSubject struct {
ID string `json:"id"`
Organization map[string]string `json:"organization"`
}
NutsOrganizationCredentialSubject defines the CredentialSubject struct for the NutsOrganizationCredential
type Resource ¶
type Resource struct {
// Path defines the path of the resource relative to the service base URL.
// Which service acts as base URL is described by the Bolt.
Path string `json:"path"`
// Operations define which operations are allowed on the resource.
Operations []string `json:"operations"`
// UserContext defines if a user login contract is required for the resource.
UserContext bool `json:"userContext"`
// AssuranceLevel defines the assurance level required for the resource (low, substantial, high).
// Should be set if userContext = true, defaults to low
AssuranceLevel *string `json:"assuranceLevel"`
}
Resource defines a single accessbile resource
type Revocation ¶
type Revocation struct {
// Context contains the json-ld contexts
Context []ssi.URI `json:"@context,omitempty"`
// Type contains the json-ld type, usually this is CredentialRevocation
Type []ssi.URI `json:"type,omitempty"`
// Issuer refers to the party that issued the credential
Issuer ssi.URI `json:"issuer"`
// Subject refers to the VC that is revoked
Subject ssi.URI `json:"subject"`
// Reason describes why the VC has been revoked
Reason string `json:"reason,omitempty"`
// Date is a rfc3339 formatted datetime.
Date time.Time `json:"date"`
// Proof contains the cryptographic proof(s). It must be extracted using the Proofs method or UnmarshalProofValue method for non-generic proof fields.
Proof *vc.JSONWebSignature2020Proof `json:"proof,omitempty"`
}
Revocation defines a proof that a VC has been revoked by its issuer.
func BuildRevocation ¶
func BuildRevocation(issuer ssi.URI, subject ssi.URI) Revocation
BuildRevocation generates a revocation based on the credential
type Validator ¶
type Validator interface {
// Validate the given credential according to the rules of the VC type.
Validate(credential vc.VerifiableCredential) error
}
Validator is the interface specific VC verification. Every VC will have its own rules of verification.
func FindValidator ¶
func FindValidator(credential vc.VerifiableCredential, pkiValidator pki.Validator) Validator
FindValidator finds the Validator the provided credential based on its Type When no additional type is provided, it returns the default validator