A lightweight JavaScript library that provides a custom web component <esign-component>
for embedding ESIGN workflows into your web applications.
Check out the live demo
<esign-component>
web component to the HTML with api-key
and document-id
attributes.<script src="https://cdn.jsdelivr.net/gh/joinworth/esign-SDK@1.0.0/esign-sdk.js"></script>
First, get a session token from the ESIGN API using your API key:
curl -X POST https://localhost:3000/api/v1/sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"templateId": "irs_8821",
"signer": {
"id": "user_123",
"email": "john@example.com",
"fullName": "John Smith",
"title": "CEO"
},
"documentFields": {
"legalName": "Acme Corp LLC",
"addressLine1": "123 Main St",
"addressLine2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"zip": "94105",
"taxId": "12-3456789"
}
}'
Response:
{
"status": "success",
"message": "Session created successfully",
"data": {
"sessionToken": "mock_wmi508",
"expiresAt": "2025-01-24T22:59:59.492Z",
"documentId": "doc_9m3dr9",
"templateId": "template_123",
"signer": {
"id": "user_123",
"email": "john@example.com",
"fullName": "John Smith",
"title": "CEO"
},
"documentFields": {
"legalName": "Acme Corp LLC",
"addressLine1": "123 Main St",
"addressLine2": "Suite 100",
"city": "San Francisco",
"state": "CA",
"zip": "94105",
"taxId": "12-3456789"
},
"signatureBlocks": [
{
"id": "sig_block_1",
"type": "signature",
"page": 1,
"position": {
"x": 25.5, // Percentage from left
"y": 75.2 // Percentage from top
},
"required": true,
"label": "Taxpayer Signature"
}
]
}
}
The response includes:
page
: The page number where the signature block appearsposition
: X,Y coordinates as percentages of page width/heighttype
: Type of signature block (signature, date, initial, etc.)required
: Whether this signature is requiredlabel
: Description of the signature block<!-- Basic Usage - All signer and document data is encoded in the session token -->
<esign-component
session-token="your-jwt-token"
service-url="https://your-domain.com/api/esign"
dev-mode
></esign-component>
Attribute | Required | Default | Description |
---|---|---|---|
session-token | Yes | - | JWT token from the session API |
service-url | No | https://api.esign.com/v1 | Base URL for the signing API |
dev-mode | No | false | Enable development mode |
When the dev-mode
attribute is present, the SDK will:
This is useful for:
The component emits the following custom events:
Event Name | Detail | Description |
---|---|---|
signing-complete | { status, documentId, timestamp, ... } |
Fired when signing is completed successfully |
signing-error | { error } |
Fired when an error occurs during signing |
Example usage:
document
.querySelector("esign-component")
.addEventListener("signing-complete", (event) => {
console.log("Signing completed:", event.detail);
// Handle successful signing...
});
document
.querySelector("esign-component")
.addEventListener("signing-error", (event) => {
console.error("Signing error:", event.detail.error);
// Handle error...
});
sequenceDiagram
participant Client as Client App
participant ClientBackend as Client Backend
participant SDK as ESIGN Component
participant Backend as ESIGN Service
participant Storage as Document Storage
Note over Client: User loads signature page
Client ->> ClientBackend: Request session token
ClientBackend ->> Backend: POST /v1/sessions (with template_id and api secret)
Backend -->> ClientBackend: Return session token
ClientBackend -->> Client: Return session token
Client ->> SDK: Initialize component with session token
SDK ->> Backend: Retrieve template document
Backend -->> SDK: Return template document
SDK ->> SDK: Render signing interface with template
Note over SDK: User clicks "Sign"
SDK ->> Backend: POST /v1/sign (session token)
Backend ->> Backend: Generate document from template
Backend ->> Storage: Store signed document
Storage -->> Backend: Document URL
Backend -->> SDK: Success response
SDK ->> Client: Dispatch signing-complete event
Client -->> Client: Handle signing completion
Backend -->> ClientBackend: Upload document to Tax OCR (business_id)
This diagram shows: