Help us shape the future of Go! Take the 2026 Go Developer Survey

zignsec

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 5 Imported by: 0

README

go-zignsec

Implements the ZignSec api

This is an interface to both http://docs.zignsec.com/api/web-based/ and http://docs.zignsec.com/api/s2s/. It has some simple functions and data structures.

EXAMPLE

s2s, signing:

s2s := zignsec.NewS2SClient(zignsec.S2SURLTest, "Your API key")
ic := zignsec.ZSInitConfig{Personalnumber: "1234567890",
	UserVisibleData:    "VGVzdGFy"}
ir, err := s2s.Init("Sign", ic)
cr, err := s2s.Collect(ir.OrderRef)
if cr.ProgressStatus == zignsec.CollectProgressStatusComplete {
	return cr.Signature
}

PACKAGE DOCUMENTATION

package zignsec
    import "github.com/qoorp/go-zignsec"

CONSTANTS

const (
    // APIHostBase is the production endpoint
    APIHostBase = "https://api.zignsec.com/v2/eid"
    // APIHostBaseTest is the test endpoint
    APIHostBaseTest = "https://test.zignsec.com/v2/eid"
)

const (
    // CollectProgressStatusComplete completed and validated
    CollectProgressStatusComplete = "COMPLETE"
    // CollectProgressStatusUserSign signed and validated
    CollectProgressStatusUserSign = "USER_SIGN"
    // CollectProgressStatusOutstanding waiting for user to complete login
    CollectProgressStatusOutstanding = "OUTSTANDING_TRANSACTION"
)

const (
    // S2SURL is the production endpoint
    S2SURL = "https://api.zignsec.com/v2/BankIDSE"
    // S2SURLTest is the test endpoint
    S2SURLTest = "https://test.zignsec.com/v2/BankIDSE"
)

TYPES

type Client struct {
    APIHostBase string
    APIKey      string
}
    Client is a zignsec client

func New(APIHostBase string, APIKey string) *Client
    New create a new client

func (c *Client) Initiate(method string, config ZSInitConfig) (*ZSInitRespBody, error)
    Initiate a login or sign request

func (c *Client) Verify(uuid string) (*ZSVerifyRespBody, error)
    Verify a login or signature

type ZSInitConfig struct {
    Personalnumber     string `json:"personalnumber,omitempty"`
    UserVisibleData    string `json:"userVisibleData,omitempty"`
    UserNonVisibleData string `json:"userNonVisibleData,omitempty"`
    Relaystate         string `json:"relaystate,omitempty"`
    Configid           string `json:"configid,omitempty"`
    Target             string `json:"target,omitempty"`
}
    ZSInitConfig defines the configuration which are sent along with both
    web-based Initiate() and s2s Init().
    UserNonVisibleData is signed, if present. UserVisibleData
    is then only for user guidance. Both must be base64 encoded. If decoded
    UserVisibleData contains certain bytes (integer value > 127?), Init()
    will fail with INVALID_PARAMETERS.

type ZSVerifyRespBody struct {
    ID     string   `json:"id"`
    Errors []string `json:"errors"`
    Result struct {
        Identity struct {
            State string `json:"state"`
        } `json:"identity"`
    }
    Identity struct {
        CountryCode    string `json:"CountryCode"`
        FirstName      string `json:"FirstName"`
        LastName       string `json:"LastName"`
        PersonalNumber string `json:"PersonalNumber"`
        DateOfBirth    string `json:"DateOfBirth"`
        Age            int    `json:"Age"`
    } `json:"identity"`
    Signature string `json:"signature"`
}
    ZSVerifyRespBody defines the response Body of Verify()

type S2SClient struct {
    // contains filtered or unexported fields
}
    S2SClient is a Zignsec server to server client

func NewS2SClient(baseURL string, key string) *S2SClient
    NewS2SClient create a new client. Key is the Zignsec Authorization.

func (c *S2SClient) Collect(order string) (*CollectResponse, error)
    Collect the state of an authenticate or sign request. Order is from the
    Init() response. The guidelines recommend polling for results every 2
    seconds. When the response Status is COMPLETE, then further use of
    Collect() will receive an error.

func (c *S2SClient) Init(method string, config ZSInitConfig) (*InitResponse, error)
    Init a authenticate or sign request. Use Collect() to get the answer
    afterwards.

type ZSInitRespBody struct {
    ID     string `json:"id"`
    Errors []struct {
        Code        string `json:"code"`
        Description string `json:"description"`
    } `json:"errors"`
    RedirectURL string `json:"redirect_url"`
}
    ZSInitRespBody defines the response Body of Initiate()

type CollectResponse struct {
    ID     string `json:"id"`
    Errors []struct {
        Code        string `json:"code"`
        Description string `json:"description"`
    } `json:"errors"`
    ProgressStatus string `json:"progressStatus"`
    UserInfo       struct {
        GivenName      string `json:"givenName"`
        Surname        string `json:"surname"`
        Name           string `json:"name"`
        PersonalNumber string `json:"personalNumber"`
        NotBefore      string `json:"notBefore"`
        NotAfter       string `json:"notAfter"`
        IPAddress      string `json:"ipAddress"`
    } `json:"userInfo"`
    Signature string `json:"signature"`
    OCSP      string `json:"ocspResponse"`
}
    CollectResponse defines the response Body of S2S Collect()

type InitResponse struct {
    ID     string `json:"id"`
    Errors []struct {
        Code        string `json:"code"`
        Description string `json:"description"`
    } `json:"errors"`
    OrderRef       string `json:"orderRef"`
    AutoStartToken string `json:"autoStartToken"`
}
    InitResponse defines the response Body of S2S Init()

Documentation

Index

Constants

View Source
const (
	// APIHostBase is the production endpoint
	APIHostBase = "https://api.zignsec.com/v2/eid"
	// APIHostBaseTest is the test endpoint
	APIHostBaseTest = "https://test.zignsec.com/v2/eid"
)
View Source
const (
	// CollectProgressStatusOutstanding ...
	CollectProgressStatusOutstanding = "OUTSTANDING_TRANSACTION"
	// CollectProgressStatusNoClient ...
	CollectProgressStatusNoClient = "NO_CLIENT"
	// CollectProgressStatusStarted ...
	CollectProgressStatusStarted = "STARTED"
	// CollectProgressStatusUserSign ...
	CollectProgressStatusUserSign = "USER_SIGN"
	// CollectProgressStatusComplete ...
	CollectProgressStatusComplete = "COMPLETE"
)
View Source
const (
	// CollectErrorInvalidParameters ...
	CollectErrorInvalidParameters = "INVALID_PARAMETERS"
	// CollectErrorReqPrecond ...
	CollectErrorReqPrecond = "REQ_PRECOND"
	// CollectErrorReqError ...
	CollectErrorReqError = "REQ_ERROR"
	// CollectErrorReqBlocked ...
	CollectErrorReqBlocked = "REQ_BLOCKED"
	// CollectErrorInternalError ...
	CollectErrorInternalError = "INTERNAL_ERROR"
	// CollectErrorRetry ...
	CollectErrorRetry = "RETRY"
	// CollectErrorAccessDeniedRP ...
	CollectErrorAccessDeniedRP = "ACCESS_DENIED_RP"
	// CollectErrorClientErr ...
	CollectErrorClientErr = "CLIENT_ERR"
	// CollectErrorExpiredTransaction ...
	CollectErrorExpiredTransaction = "EXPIRED_TRANSACTION"
	// CollectErrorCertificateErr ...
	CollectErrorCertificateErr = "CERTIFICATE_ERR"
	// CollectErrorUSerCancel ...
	CollectErrorUSerCancel = "USER_CANCEL"
	// CollectErrorCancelled ...
	CollectErrorCancelled = "CANCELLED"
	// CollectErrorStartFailed ...
	CollectErrorStartFailed = "START_FAILED"
	// CollectErrorAleadyCollected ...
	CollectErrorAleadyCollected = "ALREADY_COLLECTED"
)
View Source
const (
	// S2SURL is the production endpoint
	S2SURL = "https://api.zignsec.com/v2/BankIDSE"
	// S2SURLTest is the test endpoint
	S2SURLTest = "https://test.zignsec.com/v2/BankIDSE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIHostBase string
	APIKey      string
}

Client is a Zignsec web-based client.

func New

func New(APIHostBase string, APIKey string) *Client

New create a new Client

func (*Client) Initiate

func (c *Client) Initiate(method string, config ZWInitConfig) (*ZWInitRespBody, error)

Initiate a login or sign request

func (*Client) Verify

func (c *Client) Verify(uuid string) (*ZWVerifyRespBody, error)

Verify a login or signature

type S2SClient

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

S2SClient is a Zignsec server to server client

func NewS2SClient

func NewS2SClient(baseURL string, key string) *S2SClient

NewS2SClient create a new server to server client. Key is the Zignsec Authorization.

func (*S2SClient) Cancel

func (c *S2SClient) Cancel(orderRef string) (*ZSCancelResponse, error)

Cancel a login or signature

func (*S2SClient) Collect

func (c *S2SClient) Collect(orderRef string) (*ZSCollectResponse, error)

Collect the state of an authenticate or sign request. Order is from the Init() response. The guidelines recommend polling for results every 2 seconds. When the response Status is COMPLETE, then further use of Collect() will receive an error.

func (*S2SClient) Init

func (c *S2SClient) Init(method string, config ZSInitConfig) (*ZSInitResponse, error)

Init a authenticate or sign request. Use Collect() to get the answer afterwards.

type ZSCancelBody

type ZSCancelBody struct {
	OrderRef string `json:"orderRef"`
}

ZSCancelBody is used when canceling a pending auth/sign request

type ZSCancelResponse

type ZSCancelResponse struct {
	ID     string `json:"id"`
	Errors []struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"errors"`
}

ZSCancelResponse defines the response Body of S2S Cancel()

type ZSCollectResponse added in v0.2.0

type ZSCollectResponse struct {
	ID     string `json:"id"`
	Errors []struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"errors"`
	ProgressStatus string `json:"progressStatus"`
	Signature      string `json:"signature"`
	OCSPResponse   string `json:"ocspResponse"`
	UserInfo       struct {
		PersonalNumber string `json:"personalNumber"`
		GivenName      string `json:"givenName"`
		Surname        string `json:"surname"`
		Name           string `json:"name"`
		NotBefore      string `json:"notBefore"`
		NotAfter       string `json:"notAfter"`
		IPAddress      string `json:"ipAddress"`
	} `json:"userInfo"`
	RelayState string `json:"relayState"`
}

ZSCollectResponse defines the response Body of S2S Collect()

type ZSInitConfig

type ZSInitConfig struct {
	Personalnumber      *string `json:"personalnumber,omitempty"`
	EndUserInfo         *string `json:"endUserInfo,omitempty"`
	UserVisibleData     *string `json:"userVisibleData,omitempty"`
	UserNonVisibleData  *string `json:"userNonVisibleData,omitempty"`
	LookupPersonAddress *string `json:"lookupPersonAddress,omitempty"`
	Relaystate          *string `json:"relaystate,omitempty"`
	Webhook             *string `json:"webhook,omitempty"`
	Requirement         *struct {
		AutoStartTokenRequired string `json:"AutoStartTokenRequired"`
	} `json:"requirement,omitempty"`
	EndUserIp string `json:"endUserIp,omitempty"`
}

ZSInitConfig defines the configuration which are sent along with s2s Initiate(). UserNonVisibleData is signed, if present. UserVisibleData is then only for user guidance. Both must be base64 encoded. If decoded UserVisibleData contains certain bytes (integer value > 127?), Init() will fail with INVALID_PARAMETERS.

type ZSInitResponse added in v0.2.0

type ZSInitResponse struct {
	ID     string `json:"id"`
	Errors []struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"errors"`
	OrderRef       string  `json:"orderRef"`
	AutoStartToken string  `json:"autoStartToken"`
	QRCodeLink     *string `json:"qrCodeLink,omitempty"`
}

InitResponse defines the response Body of S2S Init()

type ZWInitConfig added in v0.2.0

type ZWInitConfig struct {
	Personalnumber     string `json:"personalnumber,omitempty"`
	UserVisibleData    string `json:"userVisibleData,omitempty"`
	UserNonVisibleData string `json:"userNonVisibleData,omitempty"`
	Relaystate         string `json:"relaystate,omitempty"`
	Configid           string `json:"configid,omitempty"`
	Target             string `json:"target,omitempty"`
}

ZWInitConfig defines the configuration which are sent along with web-based Initiate(). UserNonVisibleData is signed, if present. UserVisibleData is then only for user guidance. Both must be base64 encoded. If decoded UserVisibleData contains certain bytes (integer value > 127?), Init() will fail with INVALID_PARAMETERS.

type ZWInitRespBody added in v0.2.0

type ZWInitRespBody struct {
	ID     string `json:"id"`
	Errors []struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	} `json:"errors"`
	RedirectURL string `json:"redirect_url"`
}

ZWInitRespBody defines the response Body of Initiate()

type ZWVerifyRespBody added in v0.2.0

type ZWVerifyRespBody struct {
	ID     string   `json:"id"`
	Errors []string `json:"errors"`
	Result struct {
		Identity struct {
			State string `json:"state"`
		} `json:"identity"`
	}
	Identity struct {
		CountryCode    string `json:"CountryCode"`
		FirstName      string `json:"FirstName"`
		LastName       string `json:"LastName"`
		PersonalNumber string `json:"PersonalNumber"`
		DateOfBirth    string `json:"DateOfBirth"`
		Age            int    `json:"Age"`
	} `json:"identity"`
	Signature string `json:"signature"`
}

ZWVerifyRespBody defines the response Body of Verify()

Jump to

Keyboard shortcuts

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