Documentation
¶
Overview ¶
Package issuer is a generated GoMock package.
Package issuer is a generated GoMock package.
Index ¶
- Constants
- Variables
- type CredentialOptions
- type CredentialSearcher
- type Flow
- type Grant
- type Issuer
- type MockCredentialSearcher
- type MockCredentialSearcherMockRecorder
- type MockIssuer
- func (m *MockIssuer) EXPECT() *MockIssuerMockRecorder
- func (m *MockIssuer) GetRevocation(id ssi.URI) (*credential.Revocation, error)
- func (m *MockIssuer) Issue(ctx context.Context, template vc.VerifiableCredential, ...) (*vc.VerifiableCredential, error)
- func (m *MockIssuer) Revoke(ctx context.Context, credentialID ssi.URI) (*credential.Revocation, error)
- func (m *MockIssuer) SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
- func (m *MockIssuer) StatusList(ctx context.Context, issuer did.DID, page int) (*vc.VerifiableCredential, error)
- type MockIssuerMockRecorder
- func (mr *MockIssuerMockRecorder) GetRevocation(id any) *gomock.Call
- func (mr *MockIssuerMockRecorder) Issue(ctx, template, options any) *gomock.Call
- func (mr *MockIssuerMockRecorder) Revoke(ctx, credentialID any) *gomock.Call
- func (mr *MockIssuerMockRecorder) SearchCredential(credentialType, issuer, subject any) *gomock.Call
- func (mr *MockIssuerMockRecorder) StatusList(ctx, issuer, page any) *gomock.Call
- type MockOpenIDHandler
- func (m *MockOpenIDHandler) EXPECT() *MockOpenIDHandlerMockRecorder
- func (m *MockOpenIDHandler) HandleAccessTokenRequest(ctx context.Context, preAuthorizedCode string) (string, string, error)
- func (m *MockOpenIDHandler) HandleCredentialRequest(ctx context.Context, request openid4vci.CredentialRequest, accessToken string) (*vc.VerifiableCredential, error)
- func (m *MockOpenIDHandler) Metadata() openid4vci.CredentialIssuerMetadata
- func (m *MockOpenIDHandler) OfferCredential(ctx context.Context, credential vc.VerifiableCredential, ...) error
- func (m *MockOpenIDHandler) ProviderMetadata() openid4vci.ProviderMetadata
- type MockOpenIDHandlerMockRecorder
- func (mr *MockOpenIDHandlerMockRecorder) HandleAccessTokenRequest(ctx, preAuthorizedCode any) *gomock.Call
- func (mr *MockOpenIDHandlerMockRecorder) HandleCredentialRequest(ctx, request, accessToken any) *gomock.Call
- func (mr *MockOpenIDHandlerMockRecorder) Metadata() *gomock.Call
- func (mr *MockOpenIDHandlerMockRecorder) OfferCredential(ctx, credential, walletIdentifier any) *gomock.Call
- func (mr *MockOpenIDHandlerMockRecorder) ProviderMetadata() *gomock.Call
- type MockPublisher
- type MockPublisherMockRecorder
- type MockStore
- func (m *MockStore) Close() error
- func (m *MockStore) Diagnostics() []core.DiagnosticResult
- func (m *MockStore) EXPECT() *MockStoreMockRecorder
- func (m *MockStore) GetCredential(id ssi.URI) (*vc.VerifiableCredential, error)
- func (m *MockStore) GetRevocation(id ssi.URI) ([]credential.Revocation, error)
- func (m *MockStore) SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
- func (m *MockStore) StoreCredential(arg0 vc.VerifiableCredential) error
- func (m *MockStore) StoreRevocation(r credential.Revocation) error
- type MockStoreMockRecorder
- func (mr *MockStoreMockRecorder) Close() *gomock.Call
- func (mr *MockStoreMockRecorder) Diagnostics() *gomock.Call
- func (mr *MockStoreMockRecorder) GetCredential(id any) *gomock.Call
- func (mr *MockStoreMockRecorder) GetRevocation(id any) *gomock.Call
- func (mr *MockStoreMockRecorder) SearchCredential(credentialType, issuer, subject any) *gomock.Call
- func (mr *MockStoreMockRecorder) StoreCredential(arg0 any) *gomock.Call
- func (mr *MockStoreMockRecorder) StoreRevocation(r any) *gomock.Call
- type OpenIDHandler
- type OpenIDStore
- type Publisher
- type Store
Constants ¶
const TokenTTL = 15 * time.Minute
TokenTTL is the time-to-live for issuance flows, access tokens and nonces.
Variables ¶
var TimeFunc = time.Now
TimeFunc is a function that returns the time used, for e.g. signing time. It can be set for testing purposes.
Functions ¶
This section is empty.
Types ¶
type CredentialOptions ¶
type CredentialOptions struct {
// Format specifies the proof format for the issued credential. If not set, it defaults to JSON-LD.
// Valid options are: ldp_vc or jwt_vc
Format string
// Publish param indicates if the credential should be published to the network.
Publish bool
// Public param instructs the Publisher to publish the param with a certain visibility.
Public bool
// WithStatusListRevocation adds a 'revocation' entry to the credential. Requires Publish to be False.
WithStatusListRevocation bool
}
CredentialOptions specifies options for issuing a credential.
type CredentialSearcher ¶
type CredentialSearcher interface {
// SearchCredential searches for issued credentials
// If the passed context is empty, it'll not be part of the search query on the DB.
SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
}
CredentialSearcher defines the functions to resolve or search for credentials. It is a separate interface from Store so when an object only needs resolving, it only needs the resolver.
type Flow ¶
type Flow struct {
ID string `json:"id"`
// IssuerID is the identifier of the credential issuer.
IssuerID string `json:"issuer_id"`
// WalletID is the identifier of the wallet.
WalletID string `json:"wallet_id"`
// Grants is a list of grants that can be used to acquire an access token.
Grants []Grant `json:"grants"`
// Credentials is the list of Verifiable Credentials that be issued to the wallet through this flow.
// It might be pre-determined (in the issuer-initiated flow) or determined during the flow execution (in the wallet-initiated flow).
Credentials []vc.VerifiableCredential `json:"credentials"`
}
Flow is an active OpenID4VCI credential issuance flow.
type Grant ¶
type Grant struct {
// Type is the type of grant, e.g. "urn:ietf:params:oauth:grant-type:pre-authorized_code".
Type string `json:"type"`
// Params is a map of parameters for the grant, e.g. "pre-authorized_code" for type "urn:ietf:params:oauth:grant-type:pre-authorized_code".
Params map[string]interface{} `json:"params"`
}
Grant is a grant that has been issued for an OAuth2 state.
type Issuer ¶
type Issuer interface {
// Issue issues a credential by signing an unsigned credential.
Issue(ctx context.Context, template vc.VerifiableCredential, options CredentialOptions) (*vc.VerifiableCredential, error)
// Revoke credential with credentialID.
// It returns types.ErrNotFound if the credential is not issued by this node, or types.ErrRevoked if already revoked.
// The revocation will be published to the network by the issuers Publisher if issuer by did:nuts.
Revoke(ctx context.Context, credentialID ssi.URI) (*credential.Revocation, error)
// StatusList returns the StatusList2021Credential tracking status list revocations for this issuer at /iam/issuerID/status/page.
// Returns types.ErrNotFound when no credential statuses have been published using the issuer and page combination.
StatusList(ctx context.Context, issuer did.DID, page int) (*vc.VerifiableCredential, error)
// GetRevocation returns a revocation for a credential ID.
// Returns nil when no revocation is found.
GetRevocation(id ssi.URI) (*credential.Revocation, error)
CredentialSearcher
}
Issuer is a role in the network for a party who issues credentials about a subject to a holder.
func NewIssuer ¶
func NewIssuer(store Store, vcrStore types.Writer, networkPublisher Publisher, openidHandlerFn func(ctx context.Context, id did.DID) (OpenIDHandler, error), didResolver resolver.DIDResolver, keyStore crypto.KeyStore, jsonldManager jsonld.JSONLD, trustConfig *trust.Config, statusList *revocation.StatusList2021) Issuer
NewIssuer creates a new issuer which implements the Issuer interface. If openidIssuerFn is nil, it won't try to issue over OpenID4VCI. It needs types.Writer since issued credentials need to be in the general VCR store, since that normally happens through receiving the just-issued credential over the network, but that doesn't happen when issuing over OpenID4VCI. Thus, it needs to explicitly save it to the VCR store when issuing over OpenID4VCI. See https://github.com/nuts-foundation/nuts-node/issues/2063
type MockCredentialSearcher ¶
type MockCredentialSearcher struct {
// contains filtered or unexported fields
}
MockCredentialSearcher is a mock of CredentialSearcher interface.
func NewMockCredentialSearcher ¶
func NewMockCredentialSearcher(ctrl *gomock.Controller) *MockCredentialSearcher
NewMockCredentialSearcher creates a new mock instance.
func (*MockCredentialSearcher) EXPECT ¶
func (m *MockCredentialSearcher) EXPECT() *MockCredentialSearcherMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockCredentialSearcher) SearchCredential ¶
func (m *MockCredentialSearcher) SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
SearchCredential mocks base method.
type MockCredentialSearcherMockRecorder ¶
type MockCredentialSearcherMockRecorder struct {
// contains filtered or unexported fields
}
MockCredentialSearcherMockRecorder is the mock recorder for MockCredentialSearcher.
func (*MockCredentialSearcherMockRecorder) SearchCredential ¶
func (mr *MockCredentialSearcherMockRecorder) SearchCredential(credentialType, issuer, subject any) *gomock.Call
SearchCredential indicates an expected call of SearchCredential.
type MockIssuer ¶
type MockIssuer struct {
// contains filtered or unexported fields
}
MockIssuer is a mock of Issuer interface.
func NewMockIssuer ¶
func NewMockIssuer(ctrl *gomock.Controller) *MockIssuer
NewMockIssuer creates a new mock instance.
func (*MockIssuer) EXPECT ¶
func (m *MockIssuer) EXPECT() *MockIssuerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockIssuer) GetRevocation ¶
func (m *MockIssuer) GetRevocation(id ssi.URI) (*credential.Revocation, error)
GetRevocation mocks base method.
func (*MockIssuer) Issue ¶
func (m *MockIssuer) Issue(ctx context.Context, template vc.VerifiableCredential, options CredentialOptions) (*vc.VerifiableCredential, error)
Issue mocks base method.
func (*MockIssuer) Revoke ¶
func (m *MockIssuer) Revoke(ctx context.Context, credentialID ssi.URI) (*credential.Revocation, error)
Revoke mocks base method.
func (*MockIssuer) SearchCredential ¶
func (m *MockIssuer) SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
SearchCredential mocks base method.
func (*MockIssuer) StatusList ¶
func (m *MockIssuer) StatusList(ctx context.Context, issuer did.DID, page int) (*vc.VerifiableCredential, error)
StatusList mocks base method.
type MockIssuerMockRecorder ¶
type MockIssuerMockRecorder struct {
// contains filtered or unexported fields
}
MockIssuerMockRecorder is the mock recorder for MockIssuer.
func (*MockIssuerMockRecorder) GetRevocation ¶
func (mr *MockIssuerMockRecorder) GetRevocation(id any) *gomock.Call
GetRevocation indicates an expected call of GetRevocation.
func (*MockIssuerMockRecorder) Issue ¶
func (mr *MockIssuerMockRecorder) Issue(ctx, template, options any) *gomock.Call
Issue indicates an expected call of Issue.
func (*MockIssuerMockRecorder) Revoke ¶
func (mr *MockIssuerMockRecorder) Revoke(ctx, credentialID any) *gomock.Call
Revoke indicates an expected call of Revoke.
func (*MockIssuerMockRecorder) SearchCredential ¶
func (mr *MockIssuerMockRecorder) SearchCredential(credentialType, issuer, subject any) *gomock.Call
SearchCredential indicates an expected call of SearchCredential.
func (*MockIssuerMockRecorder) StatusList ¶
func (mr *MockIssuerMockRecorder) StatusList(ctx, issuer, page any) *gomock.Call
StatusList indicates an expected call of StatusList.
type MockOpenIDHandler ¶
type MockOpenIDHandler struct {
// contains filtered or unexported fields
}
MockOpenIDHandler is a mock of OpenIDHandler interface.
func NewMockOpenIDHandler ¶
func NewMockOpenIDHandler(ctrl *gomock.Controller) *MockOpenIDHandler
NewMockOpenIDHandler creates a new mock instance.
func (*MockOpenIDHandler) EXPECT ¶
func (m *MockOpenIDHandler) EXPECT() *MockOpenIDHandlerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockOpenIDHandler) HandleAccessTokenRequest ¶
func (m *MockOpenIDHandler) HandleAccessTokenRequest(ctx context.Context, preAuthorizedCode string) (string, string, error)
HandleAccessTokenRequest mocks base method.
func (*MockOpenIDHandler) HandleCredentialRequest ¶
func (m *MockOpenIDHandler) HandleCredentialRequest(ctx context.Context, request openid4vci.CredentialRequest, accessToken string) (*vc.VerifiableCredential, error)
HandleCredentialRequest mocks base method.
func (*MockOpenIDHandler) Metadata ¶
func (m *MockOpenIDHandler) Metadata() openid4vci.CredentialIssuerMetadata
Metadata mocks base method.
func (*MockOpenIDHandler) OfferCredential ¶
func (m *MockOpenIDHandler) OfferCredential(ctx context.Context, credential vc.VerifiableCredential, walletIdentifier string) error
OfferCredential mocks base method.
func (*MockOpenIDHandler) ProviderMetadata ¶
func (m *MockOpenIDHandler) ProviderMetadata() openid4vci.ProviderMetadata
ProviderMetadata mocks base method.
type MockOpenIDHandlerMockRecorder ¶
type MockOpenIDHandlerMockRecorder struct {
// contains filtered or unexported fields
}
MockOpenIDHandlerMockRecorder is the mock recorder for MockOpenIDHandler.
func (*MockOpenIDHandlerMockRecorder) HandleAccessTokenRequest ¶
func (mr *MockOpenIDHandlerMockRecorder) HandleAccessTokenRequest(ctx, preAuthorizedCode any) *gomock.Call
HandleAccessTokenRequest indicates an expected call of HandleAccessTokenRequest.
func (*MockOpenIDHandlerMockRecorder) HandleCredentialRequest ¶
func (mr *MockOpenIDHandlerMockRecorder) HandleCredentialRequest(ctx, request, accessToken any) *gomock.Call
HandleCredentialRequest indicates an expected call of HandleCredentialRequest.
func (*MockOpenIDHandlerMockRecorder) Metadata ¶
func (mr *MockOpenIDHandlerMockRecorder) Metadata() *gomock.Call
Metadata indicates an expected call of Metadata.
func (*MockOpenIDHandlerMockRecorder) OfferCredential ¶
func (mr *MockOpenIDHandlerMockRecorder) OfferCredential(ctx, credential, walletIdentifier any) *gomock.Call
OfferCredential indicates an expected call of OfferCredential.
func (*MockOpenIDHandlerMockRecorder) ProviderMetadata ¶
func (mr *MockOpenIDHandlerMockRecorder) ProviderMetadata() *gomock.Call
ProviderMetadata indicates an expected call of ProviderMetadata.
type MockPublisher ¶
type MockPublisher struct {
// contains filtered or unexported fields
}
MockPublisher is a mock of Publisher interface.
func NewMockPublisher ¶
func NewMockPublisher(ctrl *gomock.Controller) *MockPublisher
NewMockPublisher creates a new mock instance.
func (*MockPublisher) EXPECT ¶
func (m *MockPublisher) EXPECT() *MockPublisherMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPublisher) PublishCredential ¶
func (m *MockPublisher) PublishCredential(ctx context.Context, verifiableCredential vc.VerifiableCredential, public bool) error
PublishCredential mocks base method.
func (*MockPublisher) PublishRevocation ¶
func (m *MockPublisher) PublishRevocation(ctx context.Context, revocation credential.Revocation) error
PublishRevocation mocks base method.
type MockPublisherMockRecorder ¶
type MockPublisherMockRecorder struct {
// contains filtered or unexported fields
}
MockPublisherMockRecorder is the mock recorder for MockPublisher.
func (*MockPublisherMockRecorder) PublishCredential ¶
func (mr *MockPublisherMockRecorder) PublishCredential(ctx, verifiableCredential, public any) *gomock.Call
PublishCredential indicates an expected call of PublishCredential.
func (*MockPublisherMockRecorder) PublishRevocation ¶
func (mr *MockPublisherMockRecorder) PublishRevocation(ctx, revocation any) *gomock.Call
PublishRevocation indicates an expected call of PublishRevocation.
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore is a mock of Store interface.
func NewMockStore ¶
func NewMockStore(ctrl *gomock.Controller) *MockStore
NewMockStore creates a new mock instance.
func (*MockStore) Diagnostics ¶
func (m *MockStore) Diagnostics() []core.DiagnosticResult
Diagnostics mocks base method.
func (*MockStore) EXPECT ¶
func (m *MockStore) EXPECT() *MockStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockStore) GetCredential ¶
GetCredential mocks base method.
func (*MockStore) GetRevocation ¶
func (m *MockStore) GetRevocation(id ssi.URI) ([]credential.Revocation, error)
GetRevocation mocks base method.
func (*MockStore) SearchCredential ¶
func (m *MockStore) SearchCredential(credentialType ssi.URI, issuer did.DID, subject *ssi.URI) ([]vc.VerifiableCredential, error)
SearchCredential mocks base method.
func (*MockStore) StoreCredential ¶
func (m *MockStore) StoreCredential(arg0 vc.VerifiableCredential) error
StoreCredential mocks base method.
func (*MockStore) StoreRevocation ¶
func (m *MockStore) StoreRevocation(r credential.Revocation) error
StoreRevocation mocks base method.
type MockStoreMockRecorder ¶
type MockStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockStoreMockRecorder is the mock recorder for MockStore.
func (*MockStoreMockRecorder) Close ¶
func (mr *MockStoreMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockStoreMockRecorder) Diagnostics ¶
func (mr *MockStoreMockRecorder) Diagnostics() *gomock.Call
Diagnostics indicates an expected call of Diagnostics.
func (*MockStoreMockRecorder) GetCredential ¶
func (mr *MockStoreMockRecorder) GetCredential(id any) *gomock.Call
GetCredential indicates an expected call of GetCredential.
func (*MockStoreMockRecorder) GetRevocation ¶
func (mr *MockStoreMockRecorder) GetRevocation(id any) *gomock.Call
GetRevocation indicates an expected call of GetRevocation.
func (*MockStoreMockRecorder) SearchCredential ¶
func (mr *MockStoreMockRecorder) SearchCredential(credentialType, issuer, subject any) *gomock.Call
SearchCredential indicates an expected call of SearchCredential.
func (*MockStoreMockRecorder) StoreCredential ¶
func (mr *MockStoreMockRecorder) StoreCredential(arg0 any) *gomock.Call
StoreCredential indicates an expected call of StoreCredential.
func (*MockStoreMockRecorder) StoreRevocation ¶
func (mr *MockStoreMockRecorder) StoreRevocation(r any) *gomock.Call
StoreRevocation indicates an expected call of StoreRevocation.
type OpenIDHandler ¶
type OpenIDHandler interface {
// ProviderMetadata returns the OpenID Connect provider metadata.
ProviderMetadata() openid4vci.ProviderMetadata
// HandleAccessTokenRequest handles an OAuth2 access token request for the given issuer and pre-authorized code.
// It returns the access token and a c_nonce.
HandleAccessTokenRequest(ctx context.Context, preAuthorizedCode string) (string, string, error)
// Metadata returns the OpenID4VCI credential issuer metadata for the given issuer.
Metadata() openid4vci.CredentialIssuerMetadata
// OfferCredential sends a credential offer to the specified wallet. It derives the issuer from the credential.
OfferCredential(ctx context.Context, credential vc.VerifiableCredential, walletIdentifier string) error
// HandleCredentialRequest requests a credential from the given issuer.
HandleCredentialRequest(ctx context.Context, request openid4vci.CredentialRequest, accessToken string) (*vc.VerifiableCredential, error)
}
OpenIDHandler defines the interface for handling OpenID4VCI issuer operations.
func NewOpenIDHandler ¶
func NewOpenIDHandler(issuerDID did.DID, issuerIdentifierURL string, definitionsDIR string, httpClient core.HTTPRequestDoer, keyResolver resolver.KeyResolver, sessionDatabase storage.SessionDatabase) (OpenIDHandler, error)
NewOpenIDHandler creates a new OpenIDHandler instance. The identifier is the Credential Issuer Identifier, e.g. https://example.com/issuer/
type OpenIDStore ¶
type OpenIDStore interface {
// Store saves a new Flow in the store.
Store(ctx context.Context, flow Flow) error
// StoreReference saves a reference to the given Flow, for looking it up later.
// This is used for finding a flow given a secret, e.g. pre-authorized code, authorization code or nonce.
// like a database index. The reference must be unique for all flows.
// The expiry is the time-to-live for the reference. After this time, the reference is automatically deleted.
// If the flow does not exist, or the reference does already exist, it returns an error.
StoreReference(ctx context.Context, flowID string, refType string, reference string) error
// FindByReference finds a Flow by its reference.
// If the flow does not exist, it returns nil.
FindByReference(ctx context.Context, refType string, reference string) (*Flow, error)
// DeleteReference deletes the reference from the store.
// It does not return an error if it doesn't exist anymore.
DeleteReference(ctx context.Context, refType string, reference string) error
}
OpenIDStore defines the storage API for OpenID Credential Issuance flows.
func NewOpenIDMemoryStore ¶
func NewOpenIDMemoryStore(sessionDatabase storage.SessionDatabase) OpenIDStore
NewOpenIDMemoryStore creates a new in-memory OpenIDStore.
type Publisher ¶
type Publisher interface {
// PublishCredential publishes the credential to the outside world.
// A public flag is used to indicate if everybody can see the credential, or just the involved parties.
PublishCredential(ctx context.Context, verifiableCredential vc.VerifiableCredential, public bool) error
// PublishRevocation publishes the revocation to the outside world.
// It indicates to the network a credential can no longer be used.
PublishRevocation(ctx context.Context, revocation credential.Revocation) error
}
Publisher publishes new credentials and revocations to a channel. Used by a credential issuer.
func NewNetworkPublisher ¶
func NewNetworkPublisher(networkTx network.Transactions, didResolver resolver.DIDResolver, keyResolver crypto.KeyResolver) Publisher
NewNetworkPublisher creates a new networkPublisher which implements the Publisher interface. It is the default implementation to use for issuers to publish credentials and revocations to the Nuts network.
type Store ¶
type Store interface {
core.Diagnosable
// GetCredential retrieves an issued credential by ID
// Returns a types.ErrNotFound when the credential is not in the store
// Returns a types.ErrMultipleFound when there are multiple credentials with this ID in the store
GetCredential(id ssi.URI) (*vc.VerifiableCredential, error)
// StoreCredential writes a VC to storage.
StoreCredential(vc vc.VerifiableCredential) error
// GetRevocation returns all revocations for a credential ID.
// Returns an empty slice when no revocations are found.
GetRevocation(id ssi.URI) ([]credential.Revocation, error)
// StoreRevocation writes a revocation to storage.
StoreRevocation(r credential.Revocation) error
CredentialSearcher
// Closer closes and frees the underlying resources the store uses.
io.Closer
}
Store defines the interface for an issuer store. An implementation stores all the issued credentials and the revocations.
func NewLeiaIssuerStore ¶
NewLeiaIssuerStore creates a new instance of leiaIssuerStore which implements the Store interface.