client

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client is the Go client for the Inkless API v1 and a helper for receiving its Standard Webhooks events. Types mirror api/openapi.yaml.

Index

Constants

View Source
const (
	StateDraft           = "draft"
	StateIssued          = "issued"
	StatePartiallySigned = "partially_signed"
	StateCompleted       = "completed"
	StateDeclined        = "declined"
	StateExpired         = "expired"
	StateRevoked         = "revoked"
)

Request states.

View Source
const (
	SignerWaiting  = "waiting"
	SignerReady    = "ready"
	SignerViewed   = "viewed"
	SignerSigned   = "signed"
	SignerDeclined = "declined"
	SignerVoided   = "voided"
)

Signer states.

View Source
const (
	EventRequestIssued    = "request.issued"
	EventSignerReady      = "signer.ready"
	EventSignerViewed     = "signer.viewed"
	EventSignerSigned     = "signer.signed"
	EventSignerDeclined   = "signer.declined"
	EventRequestCompleted = "request.completed"
	EventRequestDeclined  = "request.declined"
	EventRequestExpired   = "request.expired"
	EventRequestRevoked   = "request.revoked"
)

Event types.

View Source
const WebhookTolerance = 5 * time.Minute

WebhookTolerance is the accepted clock skew for webhook-timestamp.

Variables

View Source
var ErrWebhookSignature = errors.New("inkless: invalid webhook signature")

Functions

func IdempotencyKey

func IdempotencyKey() string

IdempotencyKey returns a random key. Pass the same key when retrying a POST so the retry returns the first result.

func SignWebhook

func SignWebhook(secrets []string, id string, ts time.Time, body []byte) (string, error)

SignWebhook returns the webhook-signature header value: one "v1,<base64>" entry per secret ("whsec_<base64>"), separated by spaces.

Types

type Assertion

type Assertion struct {
	Subject         string    `json:"subject"`
	Email           string    `json:"email"`
	Method          string    `json:"method"`
	AuthenticatedAt time.Time `json:"authenticated_at"`
	Assurance       string    `json:"assurance"`
}

Assertion is the application's statement about the authenticated signer.

type Client

type Client struct {
	BaseURL string
	APIKey  string
	HTTP    *http.Client
}

func (*Client) Artifact

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

Artifact downloads "final.pdf" or "evidence.zip" of a completed request.

func (*Client) CreateSession

func (c *Client) CreateSession(ctx context.Context, id, signerRef string, in CreateSession, idemKey string) (*Session, error)

func (*Client) CreateSigningRequest

func (c *Client) CreateSigningRequest(ctx context.Context, in CreateSigningRequest, idemKey string) (*SigningRequest, error)

func (*Client) FailedWebhookDeliveries

func (c *Client) FailedWebhookDeliveries(ctx context.Context) (*WebhookDeliveryList, error)

func (*Client) GetSigningRequest

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

func (*Client) Issue

func (c *Client) Issue(ctx context.Context, id, idemKey string) (*SigningRequest, error)

func (*Client) ListSigningRequests

func (c *Client) ListSigningRequests(ctx context.Context, since time.Time, cursor string) (*SigningRequestList, error)

ListSigningRequests returns requests updated at or after since, oldest first. Pass the returned NextCursor to continue.

func (*Client) Revoke

func (c *Client) Revoke(ctx context.Context, id, reason, idemKey string) (*SigningRequest, error)

func (*Client) UploadDocument

func (c *Client) UploadDocument(ctx context.Context, pdf []byte, idemKey string) (*Document, error)

UploadDocument stores a PDF. Inkless rejects it unless its SHA-256 matches.

type CreateSession

type CreateSession struct {
	Assertion Assertion `json:"assertion"`
	ReturnURL string    `json:"return_url"`
}

type CreateSigningRequest

type CreateSigningRequest struct {
	DocumentID     string          `json:"document_id"`
	Signers        []SignerInput   `json:"signers"`
	Routing        string          `json:"routing"`
	Assurance      string          `json:"assurance,omitempty"`
	ConsentVersion string          `json:"consent_version,omitempty"`
	Locale         string          `json:"locale,omitempty"`
	ExpiresAt      time.Time       `json:"expires_at"`
	ExternalRef    string          `json:"external_ref,omitempty"`
	Metadata       json.RawMessage `json:"metadata,omitempty"`
}

type Document

type Document struct {
	ID     string `json:"id"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
	Pages  int    `json:"pages"`
}

type Error

type Error struct {
	Status  int    `json:"-"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

Error is the API error body's "error" member.

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	ID          string         `json:"id"`
	Type        string         `json:"type"`
	CreatedAt   time.Time      `json:"created_at"`
	RequestID   string         `json:"request_id"`
	ExternalRef string         `json:"external_ref"`
	Sequence    int64          `json:"sequence"`
	Request     SigningRequest `json:"request"`
}

Event is the webhook envelope.

func VerifyWebhook

func VerifyWebhook(secrets []string, h http.Header, body []byte, now time.Time) (*Event, error)

VerifyWebhook checks the Standard Webhooks headers against any of the secrets and returns the event. Receivers must still dedupe by Event.ID, ignore events whose Sequence is not above the last one seen for the request, and reconcile with GET /v1/signing-requests/{id} on gaps.

type Revoke

type Revoke struct {
	Reason string `json:"reason"`
}

type Session

type Session struct {
	URL       string    `json:"url"`
	ExpiresAt time.Time `json:"expires_at"`
}

type Signer

type Signer struct {
	Ref           string     `json:"ref"`
	Name          string     `json:"name"`
	Email         string     `json:"email"`
	Order         int        `json:"order"`
	State         string     `json:"state"`
	SignedAt      *time.Time `json:"signed_at,omitempty"`
	DeclinedAt    *time.Time `json:"declined_at,omitempty"`
	DeclineReason string     `json:"decline_reason,omitempty"`
}

type SignerInput

type SignerInput struct {
	Ref   string `json:"ref"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Order int    `json:"order"`
}

type SigningRequest

type SigningRequest struct {
	ID             string          `json:"id"`
	State          string          `json:"state"`
	Sequence       int64           `json:"sequence"`
	ExternalRef    string          `json:"external_ref"`
	Metadata       json.RawMessage `json:"metadata"`
	Routing        string          `json:"routing"`
	Assurance      string          `json:"assurance"`
	ConsentVersion string          `json:"consent_version"`
	Locale         string          `json:"locale"`
	ExpiresAt      time.Time       `json:"expires_at"`
	Document       Document        `json:"document"`
	Signers        []Signer        `json:"signers"`
	RevokeReason   string          `json:"revoke_reason,omitempty"`
	ArtifactsReady bool            `json:"artifacts_ready"`
	CreatedAt      time.Time       `json:"created_at"`
	UpdatedAt      time.Time       `json:"updated_at"`
	IssuedAt       *time.Time      `json:"issued_at,omitempty"`
	EndedAt        *time.Time      `json:"ended_at,omitempty"`
}

type SigningRequestList

type SigningRequestList struct {
	Data       []SigningRequest `json:"data"`
	NextCursor string           `json:"next_cursor,omitempty"`
}

type WebhookDelivery

type WebhookDelivery struct {
	EventID   string     `json:"event_id"`
	Type      string     `json:"type"`
	RequestID string     `json:"request_id"`
	Attempts  int        `json:"attempts"`
	LastError string     `json:"last_error,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
	FailedAt  *time.Time `json:"failed_at,omitempty"`
}

type WebhookDeliveryList

type WebhookDeliveryList struct {
	Data []WebhookDelivery `json:"data"`
}

Jump to

Keyboard shortcuts

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