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
- Variables
- func IdempotencyKey() string
- func SignWebhook(secrets []string, id string, ts time.Time, body []byte) (string, error)
- type Assertion
- type Client
- func (c *Client) Artifact(ctx context.Context, id, name string) ([]byte, error)
- func (c *Client) CreateSession(ctx context.Context, id, signerRef string, in CreateSession, idemKey string) (*Session, error)
- func (c *Client) CreateSigningRequest(ctx context.Context, in CreateSigningRequest, idemKey string) (*SigningRequest, error)
- func (c *Client) FailedWebhookDeliveries(ctx context.Context) (*WebhookDeliveryList, error)
- func (c *Client) GetSigningRequest(ctx context.Context, id string) (*SigningRequest, error)
- func (c *Client) Issue(ctx context.Context, id, idemKey string) (*SigningRequest, error)
- func (c *Client) ListSigningRequests(ctx context.Context, since time.Time, cursor string) (*SigningRequestList, error)
- func (c *Client) Revoke(ctx context.Context, id, reason, idemKey string) (*SigningRequest, error)
- func (c *Client) UploadDocument(ctx context.Context, pdf []byte, idemKey string) (*Document, error)
- type CreateSession
- type CreateSigningRequest
- type Document
- type Error
- type Event
- type Revoke
- type Session
- type Signer
- type SignerInput
- type SigningRequest
- type SigningRequestList
- type WebhookDelivery
- type WebhookDeliveryList
Constants ¶
const ( StateDraft = "draft" StateIssued = "issued" StatePartiallySigned = "partially_signed" StateCompleted = "completed" StateDeclined = "declined" StateExpired = "expired" StateRevoked = "revoked" )
Request states.
const ( SignerWaiting = "waiting" SignerReady = "ready" SignerViewed = "viewed" SignerSigned = "signed" SignerDeclined = "declined" SignerVoided = "voided" )
Signer states.
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.
const WebhookTolerance = 5 * time.Minute
WebhookTolerance is the accepted clock skew for webhook-timestamp.
Variables ¶
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.
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 ¶
func (*Client) CreateSession ¶
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 (*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.
type CreateSession ¶
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 Error ¶
type Error struct {
Status int `json:"-"`
Code string `json:"code"`
Message string `json:"message"`
}
Error is the API error body's "error" member.
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 ¶
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 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 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 WebhookDeliveryList ¶
type WebhookDeliveryList struct {
Data []WebhookDelivery `json:"data"`
}