pkg

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pkg provides utilities for interfacing with the BankID RP API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	ErrorCode string `json:"errorCode"`
	Details   string `json:"details"`
}

A APIError is returned when the BankID RP API returns an error.

func (APIError) Error

func (e APIError) Error() string

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

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

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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