onfido

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 18 Imported by: 5

README

go-onfido CircleCI Go Report Card

Client for the Onfido API

go-doc

This library was built for Utility Warehouse internal projects, so priority was given to supporting the features we needed. If the library is missing a feature from the API, raise an issue or ideally open a PR, however please understand that this library is not expected to receive any ongoing support unless required by Utility Warehouse.

Installation

To install go-onfido, use go get:

go get github.com/uw-labs/go-onfido

Usage

First you're going to need to instantiate a client (grab your sandbox API key)

client := onfido.NewClient("test_123")

Or you can instantiate usign the env variable ONFIDO_TOKEN

client, err := onfido.NewClientFromEnv()

Now checkout some of the examples

Documentation

Index

Constants

View Source
const (
	BreakdownClear        BreakdownResult = "clear"
	BreakdownConsider     BreakdownResult = "consider"
	BreakdownUnidentified BreakdownResult = "unidentified"

	SubBreakdownClear        BreakdownSubResult = "clear"
	SubBreakdownConsider     BreakdownSubResult = "consider"
	SubBreakdownUnidentified BreakdownSubResult = "unidentified"
)
View Source
const (
	CheckStatusInProgress        CheckStatus = "in_progress"
	CheckStatusAwaitingApplicant CheckStatus = "awaiting_applicant"
	CheckStatusComplete          CheckStatus = "complete"
	CheckStatusWithdrawn         CheckStatus = "withdrawn"
	CheckStatusPaused            CheckStatus = "paused"
	CheckStatusReopened          CheckStatus = "reopened"

	CheckResultClear    CheckResult = "clear"
	CheckResultConsider CheckResult = "consider"
)

Supported check types

View Source
const (
	DocumentTypeUnknown        DocumentType = "unknown"
	DocumentTypePassport       DocumentType = "passport"
	DocumentTypeIDCard         DocumentType = "national_identity_card"
	DocumentTypeDrivingLicence DocumentType = "driving_licence"
	DocumentTypeUKBRP          DocumentType = "uk_biometric_residence_permit"
	DocumentTypeTaxID          DocumentType = "tax_id"
	DocumentTypeVoterID        DocumentType = "voter_id"

	DocumentSideFront DocumentSide = "front"
	DocumentSideBack  DocumentSide = "back"
)

Supported document types and sides

View Source
const (
	ClientVersion   = "0.1.0"
	DefaultEndpoint = "https://api.eu.onfido.com/v3.6"
	TokenEnv        = "ONFIDO_TOKEN"
)

Constants

View Source
const (
	ReportNameDocument                              ReportName = "document"
	ReportNameDocumentVideo                         ReportName = "document_video"
	ReportNameDocumentWithAddressInformation        ReportName = "document_with_address_information"
	ReportNameDocumentVideoWithAddressInformation   ReportName = "document_video_with_address_information"
	ReportNameDocumentWithDrivingLicenceInformation ReportName = "document_with_driving_licence_information"
	ReportNameDocumentWithDriverVerification        ReportName = "document_with_driver_verification"
	ReportNameFacialSimilarityPhoto                 ReportName = "facial_similarity_photo"
	ReportNameFacialSimilarityPhotoFullyAuto        ReportName = "facial_similarity_photo_fully_auto"
	ReportNameFacialSimilarityVideo                 ReportName = "facial_similarity_video"
	ReportNameFacialSimilarityMotion                ReportName = "facial_similarity_motion"
	ReportNameKnownFaces                            ReportName = "known_faces"
	ReportNameIdentityEnhanced                      ReportName = "identity_enhanced"
	ReportNameWatchlistEnhanced                     ReportName = "watchlist_enhanced"
	ReportNameWatchlistAML                          ReportName = "watchlist_aml"
	ReportNameWatchlistStandard                     ReportName = "watchlist_standard"
	ReportNameWatchlistPepsOnly                     ReportName = "watchlist_peps_only"
	ReportNameWatchlistSanctionsOnly                ReportName = "watchlist_sanctions_only"
	ReportNameProofOfAddress                        ReportName = "proof_of_address"
	ReportNameUSDriversLicence                      ReportName = "us_driving_licence"
	ReportNameDeviceIntelligence                    ReportName = "device_intelligence"
	ReportNameIndiaPAN                              ReportName = "india_pan"

	ReportResultClear        ReportResult = "clear"
	ReportResultConsider     ReportResult = "consider"
	ReportResultUnidentified ReportResult = "unidentified"

	ReportSubResultClear     ReportSubResult = "clear"
	ReportSubResultRejected  ReportSubResult = "rejected"
	ReportSubResultSuspected ReportSubResult = "suspected"
	ReportSubResultCaution   ReportSubResult = "caution"
)

Supported report names, results, subresults

View Source
const (
	WebhookSignatureHeader = "X-Signature"
	WebhookTokenEnv        = "ONFIDO_WEBHOOK_TOKEN"
)

Constants

View Source
const (
	WebhookEnvironmentSandbox WebhookEnvironment = "sandbox"
	WebhookEnvironmentLive    WebhookEnvironment = "live"

	WebhookEventReportWithdrawn        WebhookEvent = "report.withdrawn"
	WebhookEventReportResumed          WebhookEvent = "report.resumed"
	WebhookEventReportCancelled        WebhookEvent = "report.cancelled"
	WebhookEventReportAwaitingApproval WebhookEvent = "report.awaiting_approval"
	WebhookEventReportInitiated        WebhookEvent = "report.initiated"
	WebhookEventReportCompleted        WebhookEvent = "report.completed"
	WebhookEventCheckStarted           WebhookEvent = "check.started"
	WebhookEventCheckReopened          WebhookEvent = "check.reopened"
	WebhookEventCheckWithdrawn         WebhookEvent = "check.withdrawn"
	WebhookEventCheckCompleted         WebhookEvent = "check.completed"
	WebhookEventCheckFormOpened        WebhookEvent = "check.form_opened"
	WebhookEventCheckFormCompleted     WebhookEvent = "check.form_completed"
)

Constants

Variables

View Source
var (
	ErrInvalidWebhookSignature = errors.New("invalid request, payload hash doesn't match signature")
	ErrMissingWebhookToken     = errors.New("webhook token not found in environmental variable")
)

Webhook errors

View Source
var (
	// ErrEmptyPostcode means that an empty postcode param was passed
	ErrEmptyPostcode = errors.New("empty postcode")
)

Functions

This section is empty.

Types

type Address

type Address struct {
	FlatNumber     string `json:"flat_number"`
	BuildingNumber string `json:"building_number"`
	BuildingName   string `json:"building_name"`
	Street         string `json:"street"`
	SubStreet      string `json:"sub_street"`
	Town           string `json:"town"`
	State          string `json:"state"`
	Postcode       string `json:"postcode"`
	Country        string `json:"country"`

	// Applicant specific
	StartDate string `json:"start_date,omitempty"`
	EndDate   string `json:"end_date,omitempty"`
}

Address represents an address from the Onfido API

type Addresses

type Addresses struct {
	Addresses []*Address `json:"addresses"`
}

Addresses represents a list of addresses from the Onfido API

type Applicant

type Applicant struct {
	ID         string     `json:"id,omitempty"`
	CreatedAt  *time.Time `json:"created_at,omitempty"`
	Sandbox    bool       `json:"sandbox,omitempty"`
	Title      string     `json:"title,omitempty"`
	FirstName  string     `json:"first_name,omitempty"`
	LastName   string     `json:"last_name,omitempty"`
	MiddleName string     `json:"middle_name,omitempty"`
	Email      string     `json:"email,omitempty"`
	DOB        string     `json:"dob,omitempty"`
	IDNumbers  []IDNumber `json:"id_numbers,omitempty"`
	Address    *Address   `json:"address,omitempty"`
	Location   Location   `json:"location,omitempty"`
	Consents   []Consent  `json:"consents,omitempty"`
}

Applicant represents an applicant from the Onfido API

type ApplicantIter

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

ApplicantIter represents an applicant iterator

func (*ApplicantIter) Applicant

func (i *ApplicantIter) Applicant() *Applicant

Applicant returns the current applicant on the iterator.

func (ApplicantIter) Current

func (it ApplicantIter) Current() interface{}

func (ApplicantIter) Err

func (it ApplicantIter) Err() error

func (ApplicantIter) Next

func (it ApplicantIter) Next(ctx context.Context) bool

type Applicants

type Applicants struct {
	Applicants []*Applicant `json:"applicants"`
}

Applicants represents a list of applicants from the Onfido API

type Breakdown

type Breakdown struct {
	Result        *BreakdownResult `json:"result"`
	SubBreakdowns SubBreakdowns    `json:"breakdown"`
}

type BreakdownResult

type BreakdownResult string

BreakdownResult represents a report's breakdown result

type BreakdownSubResult

type BreakdownSubResult string

BreakdownSubResult represents a report's sub-breakdown result

type Breakdowns

type Breakdowns map[string]Breakdown

type Check

type Check struct {
	ID                    string      `json:"id,omitempty"`
	CreatedAt             *time.Time  `json:"created_at,omitempty"`
	Href                  string      `json:"href,omitempty"`
	ApplicantID           string      `json:"applicant_id,omitempty"`
	ApplicantProvidesData bool        `json:"applicant_provides_data,omitempty"`
	Status                CheckStatus `json:"status,omitempty"`
	Result                CheckResult `json:"result,omitempty"`
	FormURI               string      `json:"form_uri,omitempty"`
	RedirectURI           string      `json:"redirect_uri,omitempty"`
	ResultsURI            string      `json:"results_uri,omitempty"`
	ReportIDs             []string    `json:"report_ids,omitempty"`
	Tags                  []string    `json:"tags,omitempty"`
	WebhookIDs            []string    `json:"webhook_ids,omitempty"`
	Paused                bool        `json:"paused,omitempty"`
	Sandbox               bool        `json:"sandbox,omitempty"`
}

Check represents a check in Onfido API

type CheckExpanded

type CheckExpanded struct {
	Check
	Reports []*Report `json:"reports,omitempty"`
}

CheckExpanded represents a check with expanded report objects

type CheckIter

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

CheckIter represents a check iterator

func (*CheckIter) Check

func (i *CheckIter) Check() *Check

Check returns the current item in the iterator as a Check.

func (CheckIter) Current

func (it CheckIter) Current() interface{}

func (CheckIter) Err

func (it CheckIter) Err() error

func (CheckIter) Next

func (it CheckIter) Next(ctx context.Context) bool

type CheckRequest

type CheckRequest struct {
	ApplicantID           string                 `json:"applicant_id"`
	ReportNames           []ReportName           `json:"report_names"`
	DocumentIDs           []string               `json:"document_ids,omitempty"`
	ApplicantProvidesData bool                   `json:"applicant_provides_data,omitempty"`
	Asynchronous          *bool                  `json:"asynchronous,omitempty"`
	RedirectURI           string                 `json:"redirect_uri,omitempty"`
	Tags                  []string               `json:"tags,omitempty"`
	SuppressFormEmails    *bool                  `json:"suppress_form_emails,omitempty"`
	WebhookIDs            []string               `json:"webhook_ids,omitempty"`
	USDriversLicence      map[string]interface{} `json:"us_driving_licence,omitempty"`
	ReportConfiguration   map[string]interface{} `json:"report_configuration,omitempty"`
	// Consider is used for Sandbox Testing of multiple report scenarios.
	// see https://documentation.onfido.com/#sandbox-responses
	Consider []string `json:"consider,omitempty"`
}

CheckRequest represents a check request to Onfido API

type CheckResult

type CheckResult string

CheckResult represents a result of a check (clear, consider)

type CheckStatus

type CheckStatus string

CheckStatus represents a status of a check

type Checks

type Checks struct {
	Checks []*Check `json:"checks"`
}

Checks represents a list of checks in Onfido API

type Client

type Client struct {
	Endpoint   string
	HTTPClient HTTPRequester
	Token      Token
}

Client represents an Onfido API client

func NewClient

func NewClient(token string) *Client

NewClient creates a new Onfido client.

func NewClientFromEnv

func NewClientFromEnv() (*Client, error)

NewClientFromEnv creates a new Onfido client using configuration from environment variables.

func (*Client) CancelReport

func (c *Client) CancelReport(ctx context.Context, id string) error

CancelReport cancels a report by its ID. see https://documentation.onfido.com/?shell#cancel-report

func (*Client) CreateApplicant

func (c *Client) CreateApplicant(ctx context.Context, a Applicant) (*Applicant, error)

CreateApplicant creates a new applicant. see https://documentation.onfido.com/?shell#create-applicant

func (*Client) CreateCheck

func (c *Client) CreateCheck(ctx context.Context, cr CheckRequest) (*Check, error)

CreateCheck creates a new check for the provided applicant. see https://documentation.onfido.com/?shell#create-check

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, wr WebhookRefRequest) (*WebhookRef, error)

CreateWebhook register a new webhook. see https://documentation.onfido.com/#register-webhook

func (*Client) DeleteApplicant

func (c *Client) DeleteApplicant(ctx context.Context, id string) error

DeleteApplicant deletes an applicant by its id. see https://documentation.onfido.com/?shell#delete-applicant

func (*Client) DownloadCheck

func (c *Client) DownloadCheck(ctx context.Context, id string) ([]byte, error)

DownloadCheck downloads a PDF summary of a check by its ID. see https://documentation.onfido.com/api/latest/#download-check

func (*Client) DownloadDocument

func (c *Client) DownloadDocument(ctx context.Context, id string) ([]byte, error)

DownloadDocument downloads the file data for a document by its ID. see https://documentation.onfido.com/?shell#download-document

func (*Client) GetApplicant

func (c *Client) GetApplicant(ctx context.Context, id string) (*Applicant, error)

GetApplicant retrieves an applicant by its id. see https://documentation.onfido.com/?shell#retrieve-applicant

func (*Client) GetCheck

func (c *Client) GetCheck(ctx context.Context, id string) (*Check, error)

GetCheck retrieves a check by its ID. see https://documentation.onfido.com/?shell#retrieve-check

func (*Client) GetCheckExpanded

func (c *Client) GetCheckExpanded(ctx context.Context, id string) (*CheckExpanded, error)

GetCheckExpanded retrieves a check by its ID, with the Check's Reports expanded within the returned CheckExpanded object. see https://documentation.onfido.com/?shell#retrieve-check (Shell) but refer to the JSON response object for https://documentation.onfido.com/?php#check-object (PHP) for the expanded contents.

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, id string) (*Document, error)

GetDocument retrieves a single document by its ID. see https://documentation.onfido.com/?shell#retrieve-document

func (*Client) GetReport

func (c *Client) GetReport(ctx context.Context, id string) (*Report, error)

GetReport retrieves a report by its ID. see https://documentation.onfido.com/?shell#retrieve-report

func (*Client) ListApplicants

func (c *Client) ListApplicants() *ApplicantIter

ListApplicants retrieves the list of applicants. see https://documentation.onfido.com/?shell#list-applicants

func (*Client) ListChecks

func (c *Client) ListChecks(applicantID string) *CheckIter

ListChecks retrieves the list of checks for the provided applicant. see https://documentation.onfido.com/?shell#list-checks

func (*Client) ListDocuments

func (c *Client) ListDocuments(applicantID string) *DocumentIter

ListDocuments retrieves the list of documents for the provided applicant. see https://documentation.onfido.com/?shell#list-documents

func (*Client) ListLivePhotos

func (c *Client) ListLivePhotos(applicantID string) *LivePhotoIter

ListPhotos retrieves the list of photos for the provided applicant. see https://documentation.onfido.com/?shell#live-photos

func (*Client) ListReports

func (c *Client) ListReports(checkID string) *ReportIter

ListReports retrieves the list of reports for the provided check. see https://documentation.onfido.com/?shell#list-reports

func (*Client) ListWebhooks

func (c *Client) ListWebhooks() *WebhookRefIter

ListWebhooks retrieves the list of webhooks. see https://documentation.onfido.com/#list-webhooks

func (*Client) NewSdkToken

func (c *Client) NewSdkToken(ctx context.Context, id, referrer string) (*SdkToken, error)

NewSdkToken returns a JWT token to used by the Javascript SDK

func (*Client) PickAddresses

func (c *Client) PickAddresses(postcode string) *PickerIter

PickAddresses retrieves the list of addresses matched against the provided postcode. see https://documentation.onfido.com/?shell#address-picker

func (*Client) ResumeCheck

func (c *Client) ResumeCheck(ctx context.Context, id string) (*Check, error)

ResumeCheck resumes a paused check by its ID. see https://documentation.onfido.com/?shell#resume-check

func (*Client) ResumeReport

func (c *Client) ResumeReport(ctx context.Context, id string) error

ResumeReport resumes a paused report by its ID. see https://documentation.onfido.com/?shell#resume-report

func (*Client) UpdateApplicant

func (c *Client) UpdateApplicant(ctx context.Context, a Applicant) (*Applicant, error)

UpdateApplicant updates an applicant by its id. see https://documentation.onfido.com/?shell#update-applicant

func (*Client) UploadDocument

func (c *Client) UploadDocument(ctx context.Context, dr DocumentRequest) (*Document, error)

UploadDocument uploads a document. see https://documentation.onfido.com/?shell#upload-document

type Consent struct {
	Name      string `json:"name"`
	Granted   bool   `json:"granted"`
	GrantedAt string `json:"granted_at,omitempty"`
}

Consent represents consent given by an applicant

type ConsentName

type ConsentName string

ConsentName represents the type of consent given by an applicant

const (
	ConsentPrivacyNoticesRead ConsentName = "privacy_notices_read"
	ConsentSSNVerification    ConsentName = "ssn_verification"
)

Supported consent types for US applicants

type Document

type Document struct {
	ID           string       `json:"id,omitempty"`
	CreatedAt    *time.Time   `json:"created_at,omitempty"`
	Href         string       `json:"href,omitempty"`
	DownloadHref string       `json:"download_href,omitempty"`
	FileName     string       `json:"file_name,omitempty"`
	FileType     string       `json:"file_type,omitempty"`
	FileSize     int          `json:"file_size,omitempty"`
	Type         DocumentType `json:"type,omitempty"`
	Side         DocumentSide `json:"side,omitempty"`
}

Document represents a document in Onfido API

type DocumentIter

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

DocumentIter represents a document iterator

func (DocumentIter) Current

func (it DocumentIter) Current() interface{}

func (*DocumentIter) Document

func (i *DocumentIter) Document() *Document

Document returns the current item in the iterator as a Document.

func (DocumentIter) Err

func (it DocumentIter) Err() error

func (DocumentIter) Next

func (it DocumentIter) Next(ctx context.Context) bool

type DocumentRequest

type DocumentRequest struct {
	File        io.ReadSeeker
	Type        DocumentType
	Side        DocumentSide
	ApplicantID string
}

DocumentRequest represents a document request to Onfido API

type DocumentSide

type DocumentSide string

DocumentSide represents a document side (front, back)

type DocumentType

type DocumentType string

DocumentType represents a document type (passport, ID, etc)

type Documents

type Documents struct {
	Documents []*Document `json:"documents"`
}

Documents represents a list of documents from the Onfido API

type Error

type Error struct {
	Resp *http.Response
	// see https://documentation.onfido.com/#error-object
	Err struct {
		ID     string      `json:"id"`
		Type   string      `json:"type"`
		Msg    string      `json:"message"`
		Fields ErrorFields `json:"fields"`
	} `json:"error"`
}

Error represents an Onfido API error response

func (*Error) Error

func (e *Error) Error() string

type ErrorFields

type ErrorFields map[string]interface{}

known shapes of the values are []string and map[string][]string for recursive field validation

type HTTPRequester

type HTTPRequester interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPRequester represents an HTTP requester

type IDNumber

type IDNumber struct {
	Type      IDNumberType `json:"type,omitempty"`
	Value     string       `json:"value,omitempty"`
	StateCode string       `json:"state_code,omitempty"`
}

IDNumber represents an ID number from the Onfido API

type IDNumberType

type IDNumberType string

IDNumberType represents an ID type (ssn, social insurance, etc)

const (
	IDNumberTypeSSN             IDNumberType = "ssn"
	IDNumberTypeSocialInsurance IDNumberType = "social_insurance"
	IDNumberTypeTaxID           IDNumberType = "tax_id"
	IDNumberTypeIdentityCard    IDNumberType = "identity_card"
	IDNumberTypeDrivingLicense  IDNumberType = "driving_license"
)

Supported ID number types

type LivePhoto

type LivePhoto struct {
	ID           string     `json:"id,omitempty"`
	CreatedAt    *time.Time `json:"created_at,omitempty"`
	Href         string     `json:"href,omitempty"`
	DownloadHref string     `json:"download_href,omitempty"`
	FileName     string     `json:"file_name,omitempty"`
	FileType     string     `json:"file_type,omitempty"`
	FileSize     int32      `json:"file_size,omitempty"`
}

LivePhoto represents a LivePhoto in Onfido API

type LivePhotoIter

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

LivePhotoIter represents a LivePhoto iterator

func (LivePhotoIter) Current

func (it LivePhotoIter) Current() interface{}

func (LivePhotoIter) Err

func (it LivePhotoIter) Err() error

func (*LivePhotoIter) LivePhoto

func (i *LivePhotoIter) LivePhoto() *LivePhoto

LivePhoto returns the current item in the iterator as a LivePhoto.

func (LivePhotoIter) Next

func (it LivePhotoIter) Next(ctx context.Context) bool

type Location

type Location struct {
	IPAddress          string `json:"ip_address,omitempty"`
	CountryOfResidence string `json:"country_of_residence,omitempty"`
}

Location struct represents location information for an applicant

type PickerIter

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

PickerIter represents an address picker iterator

func (*PickerIter) Address

func (i *PickerIter) Address() *Address

Address returns the current address on the iterator.

func (PickerIter) Current

func (it PickerIter) Current() interface{}

func (PickerIter) Err

func (it PickerIter) Err() error

func (PickerIter) Next

func (it PickerIter) Next(ctx context.Context) bool

type Properties

type Properties map[string]interface{}

type Report

type Report struct {
	ID         string                 `json:"id,omitempty"`
	Name       ReportName             `json:"name,omitempty"`
	CreatedAt  *time.Time             `json:"created_at,omitempty"`
	Status     string                 `json:"status,omitempty"`
	Result     ReportResult           `json:"result,omitempty"`
	SubResult  ReportSubResult        `json:"sub_result,omitempty"`
	Href       string                 `json:"href,omitempty"`
	Options    map[string]interface{} `json:"options,omitempty"`
	Breakdown  Breakdowns             `json:"breakdown,omitempty"`
	Properties Properties             `json:"properties,omitempty"`
}

Report represents a report from the Onfido API

type ReportIter

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

ReportIter represents a document iterator

func (ReportIter) Current

func (it ReportIter) Current() interface{}

func (ReportIter) Err

func (it ReportIter) Err() error

func (ReportIter) Next

func (it ReportIter) Next(ctx context.Context) bool

func (*ReportIter) Report

func (i *ReportIter) Report() *Report

Report returns the current item in the iterator as a Report.

type ReportName

type ReportName string

ReportName represents a report type name

type ReportResult

type ReportResult string

ReportResult represents a report result

type ReportSubResult

type ReportSubResult string

ReportSubResult represents a report sub result

type Reports

type Reports struct {
	Reports []*Report `json:"reports"`
}

Reports represents a list of reports from the Onfido API

type SdkToken

type SdkToken struct {
	ApplicantID string `json:"applicant_id,omitempty"`
	Referrer    string `json:"referrer,omitempty"`
	Token       string `json:"token,omitempty"`
}

SdkToken represents the response for a request for a JWT token

type SubBreakdown

type SubBreakdown struct {
	Result     *BreakdownSubResult `json:"result"`
	Properties Properties          `json:"properties"`
}

type SubBreakdowns

type SubBreakdowns map[string]SubBreakdown

type Token

type Token string

Token is an Onfido authentication token

func (Token) Prod

func (t Token) Prod() bool

Prod checks if this is a production token or not.

func (Token) String

func (t Token) String() string

String returns the token as a string.

type Webhook

type Webhook struct {
	Token                   string
	SkipSignatureValidation bool
}

Webhook represents a webhook handler

func NewWebhook

func NewWebhook(token string) *Webhook

NewWebhook creates a new webhook handler

func NewWebhookFromEnv

func NewWebhookFromEnv() (*Webhook, error)

NewWebhookFromEnv creates a new webhook handler using configuration from environment variables.

func (*Webhook) ParseFromRequest

func (wh *Webhook) ParseFromRequest(req *http.Request) (*WebhookRequest, error)

ParseFromRequest parses the webhook request body and returns it as WebhookRequest if the request signature is valid.

func (*Webhook) ValidateSignature

func (wh *Webhook) ValidateSignature(body []byte, signature string) error

ValidateSignature validates the request body against the signature header.

type WebhookEnvironment

type WebhookEnvironment string

WebhookEnvironment represents an environment type (see `WebhookEnvironment*` constants for possible values)

type WebhookEvent

type WebhookEvent string

WebhookEvent represents an event type (see `WebhookEvent*` constants for possible values)

type WebhookRef

type WebhookRef struct {
	ID           string               `json:"id,omitempty"`
	URL          string               `json:"url,omitempty"`
	Enabled      bool                 `json:"enabled"`
	Href         string               `json:"href,omitempty"`
	Token        string               `json:"token,omitempty"`
	Environments []WebhookEnvironment `json:"environments,omitempty"`
	Events       []WebhookEvent       `json:"events,omitempty"`
}

WebhookRef represents a webhook in Onfido API

type WebhookRefIter

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

WebhookRefIter represents a webhook iterator

func (WebhookRefIter) Current

func (it WebhookRefIter) Current() interface{}

func (WebhookRefIter) Err

func (it WebhookRefIter) Err() error

func (WebhookRefIter) Next

func (it WebhookRefIter) Next(ctx context.Context) bool

func (*WebhookRefIter) WebhookRef

func (i *WebhookRefIter) WebhookRef() *WebhookRef

WebhookRef returns the current item in the iterator as a WebhookRef.

type WebhookRefRequest

type WebhookRefRequest struct {
	URL          string               `json:"url"` // Onfido requires that this must be HTTPS
	Enabled      bool                 `json:"enabled"`
	Environments []WebhookEnvironment `json:"environments,omitempty"` // If omitted then Onfido will default to both
	Events       []WebhookEvent       `json:"events,omitempty"`       // If omitted then Onfido will default to all
}

WebhookRefRequest represents a webhook request to Onfido API

type WebhookRefs

type WebhookRefs struct {
	WebhookRefs []*WebhookRef `json:"webhooks"`
}

WebhookRefs represents a list of webhooks in Onfido API

type WebhookRequest

type WebhookRequest struct {
	Payload struct {
		ResourceType string `json:"resource_type"`
		Action       string `json:"action"`
		Object       struct {
			ID                 string `json:"id"`
			Status             string `json:"status"`
			CompletedAt        string `json:"completed_at"`         // Deprecated in v3, use CompletedAtISO8601
			CompletedAtISO8601 string `json:"completed_at_iso8601"` // New in v3
			Href               string `json:"href"`
		} `json:"object"`
	} `json:"payload"`
}

WebhookRequest represents an incoming webhook request from Onfido

Directories

Path Synopsis
examples
applicant command
check command
error command
jwt command
list-applicants command
upload-document command
webhook command

Jump to

Keyboard shortcuts

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