@assinafy/sdk 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -9
- package/dist/index.d.mts +368 -44
- package/dist/index.d.ts +368 -44
- package/dist/index.js +396 -102
- package/dist/index.mjs +395 -102
- package/package.json +18 -9
package/README.md
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the [Assinafy API](https://api.assinafy.com.br/v1/docs) — a Brazilian digital signature platform.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Covers the server-side surface of the API: documents, signers, assignments, templates, tags, workspaces, webhooks, field definitions, authentication, public/signer-side flows, and the high-level `uploadAndRequestSignatures` helper.
|
|
6
|
+
|
|
7
|
+
Deliberately not wrapped: the browser-redirect OAuth endpoints (`/auth/authenticate`, `/auth/link-social-login`, `/login-callback`), which a server-side SDK cannot meaningfully drive, and the account `theme`/`logo` branding routes.
|
|
6
8
|
|
|
7
9
|
## Requirements
|
|
8
10
|
|
|
9
|
-
- Node.js
|
|
11
|
+
- Node.js 22+ for the built-in `FormData` / `Blob` APIs used by uploads. Tested
|
|
12
|
+
on 22 (maintenance LTS) and 24 (active LTS); Node 20 reached end-of-life in
|
|
13
|
+
April 2026 and is no longer supported.
|
|
10
14
|
- or Bun 1.0+
|
|
11
15
|
|
|
12
16
|
## Installation
|
|
@@ -98,16 +102,16 @@ Every public endpoint documented in https://api.assinafy.com.br/v1/docs is cover
|
|
|
98
102
|
|
|
99
103
|
| Resource | Endpoints |
|
|
100
104
|
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
-
| `client.documents` | list, upload, details, activities, waitUntilReady, download, thumbnail, downloadPage, statuses, delete, verify, createFromTemplate, estimateCostFromTemplate,
|
|
105
|
+
| `client.documents` | list, **search**, upload, details, get, **rename**, activities, waitUntilReady, download, thumbnail, downloadPage, statuses, delete, verify, createFromTemplate, estimateCostFromTemplate, getPublic, sendToken, listTags, replaceTags, addTags, detachTag, isFullySigned, getSigningProgress |
|
|
102
106
|
| `client.signers` | create, get, list, update, delete, findByEmail |
|
|
103
|
-
| `client.assignments` | create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications
|
|
107
|
+
| `client.assignments` | **list**, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications |
|
|
104
108
|
| `client.templates` | **create**, list, get, **update**, **delete**, downloadPage |
|
|
105
109
|
| `client.tags` | list, create, update, delete |
|
|
106
110
|
| `client.workspaces` | create, list, get, update, delete |
|
|
107
|
-
| `client.webhooks` | register, get, inactivate,
|
|
111
|
+
| `client.webhooks` | register, get, inactivate, listEventTypes, listDispatches, retryDispatch |
|
|
108
112
|
| `client.fields` | create, list, get, update, delete, validate, validateMultiple, listTypes |
|
|
109
113
|
| `client.auth` | login, socialLogin, createApiKey, getApiKey, deleteApiKey, changePassword, requestPasswordReset, resetPassword |
|
|
110
|
-
| `client.signerDocuments` | getCurrent, list, download, signMultiple, declineMultiple, self, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline
|
|
114
|
+
| `client.signerDocuments` | getCurrent, list, **search**, download, signMultiple, declineMultiple, self, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline |
|
|
111
115
|
| `client.webhookVerifier` | verify, extractEvent, getEventType, getEventData |
|
|
112
116
|
|
|
113
117
|
## Resources
|
|
@@ -120,8 +124,12 @@ Most account-scoped methods accept an optional `accountId` that overrides the cl
|
|
|
120
124
|
// Upload from a file path (recommended)
|
|
121
125
|
const doc = await client.documents.upload(
|
|
122
126
|
{ filePath: './contract.pdf' },
|
|
123
|
-
{ metadata: { type: 'service' } },
|
|
127
|
+
{ name: 'Service agreement', metadata: { type: 'service' } },
|
|
124
128
|
);
|
|
129
|
+
// `name` is optional and defaults to the file's own name. The API derives the
|
|
130
|
+
// display name from the uploaded filename and appends `.pdf` when absent, so
|
|
131
|
+
// the document above is stored as 'Service agreement.pdf'. Accents are
|
|
132
|
+
// transliterated by the API ('Contrato de Serviço' → 'Contrato de Servico.pdf').
|
|
125
133
|
// → {
|
|
126
134
|
// resource: 'document', id: '1031…', account_id: '102d…', template_id: null,
|
|
127
135
|
// name: 'contract.pdf', status: 'uploaded',
|
|
@@ -136,10 +144,20 @@ await client.documents.upload({ buffer, fileName: 'contract.pdf' });
|
|
|
136
144
|
|
|
137
145
|
// List → { data: IDocumentListItem[], meta?: { current_page, per_page, total, last_page } }
|
|
138
146
|
const { data, meta } = await client.documents.list({ page: 1, per_page: 20, sort: '-created_at' });
|
|
147
|
+
|
|
148
|
+
// Search is the lightweight alternative to list: same item shape, but the API
|
|
149
|
+
// skips the expanded `assignment`/`pages`. Prefer it for name lookups.
|
|
150
|
+
const hits = await client.documents.search({ search: 'agreement', status: 'pending_signature', 'per-page': 20 });
|
|
151
|
+
|
|
139
152
|
await client.documents.details(doc.id);
|
|
140
153
|
await client.documents.activities(doc.id);
|
|
141
154
|
await client.documents.waitUntilReady(doc.id, { maxWaitMs: 30_000 });
|
|
142
155
|
|
|
156
|
+
// Rename. The API rejects this with 400 while the document is still in
|
|
157
|
+
// `metadata_processing`, so await waitUntilReady() first on a fresh upload.
|
|
158
|
+
// (Passing `name` to upload() avoids both the round-trip and the race.)
|
|
159
|
+
await client.documents.rename(doc.id, 'Signed service agreement.pdf');
|
|
160
|
+
|
|
143
161
|
await client.documents.download(doc.id, 'certificated'); // 'original' | 'certificated' | 'certificate-page' | 'bundle'
|
|
144
162
|
await client.documents.thumbnail(doc.id);
|
|
145
163
|
await client.documents.downloadPage(doc.id, pageId);
|
|
@@ -206,6 +224,10 @@ When an `email` is supplied, `signers.create()` is idempotent by email, matching
|
|
|
206
224
|
### Assignments
|
|
207
225
|
|
|
208
226
|
```ts
|
|
227
|
+
// List every assignment in the workspace.
|
|
228
|
+
// → { data: IAssignment[], meta?: { current_page, per_page, total, last_page } }
|
|
229
|
+
const { data, meta } = await client.assignments.list({ page: 1, 'per-page': 20 });
|
|
230
|
+
|
|
209
231
|
// Signers may be ids or objects — the SDK normalises to the API shape.
|
|
210
232
|
await client.assignments.create(documentId, {
|
|
211
233
|
method: 'virtual',
|
|
@@ -386,8 +408,7 @@ await client.webhooks.register({
|
|
|
386
408
|
});
|
|
387
409
|
|
|
388
410
|
await client.webhooks.get(); // current subscription or null
|
|
389
|
-
await client.webhooks.inactivate();
|
|
390
|
-
await client.webhooks.delete();
|
|
411
|
+
await client.webhooks.inactivate(); // stop deliveries (no delete route exists)
|
|
391
412
|
await client.webhooks.listEventTypes();
|
|
392
413
|
await client.webhooks.listDispatches({ delivered: false, page: 1, 'per-page': 20 });
|
|
393
414
|
await client.webhooks.retryDispatch(dispatchId);
|
|
@@ -433,6 +454,8 @@ await client.signerDocuments.verifyEmail({ signerAccessCode: accessCode, verific
|
|
|
433
454
|
|
|
434
455
|
await client.signerDocuments.getCurrent(signerId, accessCode);
|
|
435
456
|
const { data } = await client.signerDocuments.list(signerId, accessCode, { search: 'invoice' });
|
|
457
|
+
// Signer-side counterpart of documents.search(), authorised by the access code.
|
|
458
|
+
const found = await client.signerDocuments.search(signerId, accessCode, 'invoice');
|
|
436
459
|
await client.signerDocuments.download(signerId, documentId, 'original', accessCode);
|
|
437
460
|
|
|
438
461
|
await client.signerDocuments.confirmData(documentId, accessCode, {
|