Documentation ¶
Overview ¶
Package pkg provides utilities for interfacing with the BankID RP API.
Index ¶
- type APIError
- type Authenticator
- type BankID
- type BankIDClient
- func (b BankIDClient) Authenticate(context context.Context, payload *payload.AuthenticationPayload) (*response.AuthenticateResponse, error)
- func (b BankIDClient) Cancel(context context.Context, payload *payload.CancelPayload) (*response.CancelResponse, error)
- func (b BankIDClient) Collect(context context.Context, payload *payload.CollectPayload) (*response.CollectResponse, error)
- func (b BankIDClient) PhoneAuthenticate(context context.Context, payload *payload.PhoneAuthenticationPayload) (*response.PhoneAuthenticateResponse, error)
- func (b BankIDClient) PhoneSign(context context.Context, payload *payload.PhoneSignPayload) (*response.PhoneSignResponse, error)
- func (b BankIDClient) QRCodeContent(qrStartToken, qrStartSecret string, seconds int) (string, error)
- func (b BankIDClient) Sign(context context.Context, payload *payload.SignPayload) (*response.SignResponse, error)
- type Collector
- type OrderCanceller
- type QRCodeContentGenerator
- type Signer
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator interface { // Authenticate - Initiates an authentication order. // // Use the collect method to query the status of the order. // If the request is successful, the orderRef and autoStartToken is returned. // // Implements the Authenticator interface // It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or // std errors such as net.OpError on network errors. Authenticate(context context.Context, payload *payload.AuthenticationPayload) (*response.AuthenticateResponse, error) }
Authenticator is the interface implemented by types that can initiate an authenticate request via the BankID RP API.
type BankID ¶
type BankID interface { Authenticator Signer Collector OrderCanceller QRCodeContentGenerator }
BankID provides methods for interfacing with the BankID RP API.
type BankIDClient ¶
type BankIDClient struct {
// contains filtered or unexported fields
}
BankIDClient contains the validator and configuration context.
func NewBankIDClient ¶
func NewBankIDClient(configuration *configuration.Configuration) (*BankIDClient, error)
NewBankIDClient returns a new instance of 'BankIDClient'.
func (BankIDClient) Authenticate ¶
func (b BankIDClient) Authenticate( context context.Context, payload *payload.AuthenticationPayload, ) (*response.AuthenticateResponse, error)
Authenticate - Initiates an authentication order.
Use the collect method to query the status of the order. If the request is successful, the orderRef and autoStartToken is returned.
Implements the Authenticator interface It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
func (BankIDClient) Cancel ¶
func (b BankIDClient) Cancel( context context.Context, payload *payload.CancelPayload, ) (*response.CancelResponse, error)
Cancel - Cancels an ongoing sign or auth order.
This is typically used if the User cancels the order in your service or app.
It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
func (BankIDClient) Collect ¶
func (b BankIDClient) Collect( context context.Context, payload *payload.CollectPayload, ) (*response.CollectResponse, error)
Collect - Collects the result of a sign or auth order suing the orderRef as reference.
RP should keep calling collect every two seconds as long as status indicates pending. RP must abort if status indicates failed. The User identity is returned when complete.
It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
func (BankIDClient) PhoneAuthenticate ¶
func (b BankIDClient) PhoneAuthenticate( context context.Context, payload *payload.PhoneAuthenticationPayload, ) (*response.PhoneAuthenticateResponse, error)
PhoneAuthenticate - Initiates a phone authentication order.
Use the collect method to query the status of the order. If the request is successful, the orderRef and autoStartToken is returned.
Implements the Authenticator interface It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
func (BankIDClient) PhoneSign ¶
func (b BankIDClient) PhoneSign( context context.Context, payload *payload.PhoneSignPayload, ) (*response.PhoneSignResponse, error)
PhoneSign - Initiates a sign order.
Use the collect method to query the status of the order. If the request is successful, the orderRef and autoStartToken is returned.
It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
func (BankIDClient) QRCodeContent ¶
func (b BankIDClient) QRCodeContent(qrStartToken, qrStartSecret string, seconds int) (string, error)
QRCodeContent - Generates the QR code content based on qrStartToken, qrStartSecret and seconds elapsed since response.
The QR code is generated by the RP every second using the pattern "bankid.qrStartToken.time.qrAuthCode" as input.
func (BankIDClient) Sign ¶
func (b BankIDClient) Sign(context context.Context, payload *payload.SignPayload) (*response.SignResponse, error)
Sign - Initiates a sign order.
Use the collect method to query the status of the order. If the request is successful, the orderRef and autoStartToken is returned.
It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or std errors such as net.OpError on network errors.
type Collector ¶
type Collector interface { // Collect - Collects the result of a sign or auth order suing the orderRef as reference. // // RP should keep calling collect every two seconds as long as status indicates pending. // RP must abort if status indicates failed. The User identity is returned when complete. // // It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or // std errors such as net.OpError on network errors. Collect(context context.Context, payload *payload.CollectPayload) (*response.CollectResponse, error) }
Collector is the interface implemented by types that can collect an order via the BankID RP API.
type OrderCanceller ¶
type OrderCanceller interface { // Cancel - Cancels an ongoing sign or auth order. // // This is typically used if the User cancels the order in your service or app. // // It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or // std errors such as net.OpError on network errors. Cancel(context context.Context, payload *payload.CancelPayload) (*response.CancelResponse, error) }
OrderCanceller is the interface implemented by types that can cancel an order via the BankID RP API.
type QRCodeContentGenerator ¶
type QRCodeContentGenerator interface { // QRCodeContent - Generates the QR code content based on qrStartToken, qrStartSecret and seconds elapsed since // response. // // The QR code is generated by the RP every second using the pattern "bankid.qrStartToken.time.qrAuthCode" as input. QRCodeContent(qrStartToken, qrStartSecret string, seconds int) (string, error) }
QRCodeContentGenerator is the interface implemented by types that can generate the QR code content.
type Signer ¶
type Signer interface { // Sign - Initiates a sign order. // // Use the collect method to query the status of the order. // If the request is successful, the orderRef and autoStartToken is returned. // // It returns APIError for errors that originates from the BankID RP API, ValidationError if incorrect payload or // std errors such as net.OpError on network errors. Sign(context context.Context, payload *payload.SignPayload) (*response.SignResponse, error) }
Signer is the interface implemented by types that can initiate a sign request via the BankID RP API.
type ValidationError ¶
type ValidationError struct { Field string RejectedValue any // contains filtered or unexported fields }
A ValidationError is returned when the payload is found to be invalid.
func NewValidationError ¶
func NewValidationError(field string, rejectedValue any, wrapped error) *ValidationError
NewValidationError initialize a new ValidationError.
func (ValidationError) Error ¶
func (v ValidationError) Error() string
func (ValidationError) Unwrap ¶
func (v ValidationError) Unwrap() error
Unwrap unwraps the wrapped error.