@assinafy/sdk 2.7.0 → 2.8.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/CHANGELOG.md +67 -1
- package/README.en.md +77 -17
- package/README.md +77 -17
- package/dist/index.d.mts +508 -63
- package/dist/index.d.ts +508 -63
- package/dist/index.js +513 -78
- package/dist/index.mjs +513 -78
- package/docs/API_COVERAGE.md +22 -14
- package/docs/COMPATIBILITY.md +58 -20
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,69 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.8.0] - 2026-10-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Identity-document and face verification: `IdDocumentFaceMatchBasic` on
|
|
15
|
+
assignment and template creation and cost estimation,
|
|
16
|
+
`signerDocuments.getIdentityVerification()` and
|
|
17
|
+
`startIdentityVerification()`, and account-side
|
|
18
|
+
`assignments.getIdentityVerification()`,
|
|
19
|
+
`downloadIdentityVerificationImage()` and `reviewIdentityVerification()`.
|
|
20
|
+
Includes typed provider state, evidence, decisions, webhook events and the
|
|
21
|
+
`pending_identity_review` document status.
|
|
22
|
+
- `webhooks.deleteEndpointByUrl()` deletes an endpoint using its exact
|
|
23
|
+
registered URL. `listEndpoints()` accepts an optional second argument
|
|
24
|
+
`{ url }` to filter by that URL.
|
|
25
|
+
- `webhooks.createEndpoint()` returns `IWebhookEndpointCreateResponse`,
|
|
26
|
+
exposing the signing `secret` supplied at creation so OAuth applications can
|
|
27
|
+
store it without calling the API-key-only secret endpoint.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- Reject dot-segment resource IDs before URL normalization can change the
|
|
32
|
+
requested route, and prevent redirect hooks from changing the destination
|
|
33
|
+
after credential checks.
|
|
34
|
+
- Reject invalid webhook timestamp tolerances instead of accepting stale
|
|
35
|
+
signed deliveries with a non-finite replay window.
|
|
36
|
+
- Search every matching signer page for an exact email so idempotent creation
|
|
37
|
+
reuses an existing signer beyond the first 50 substring matches.
|
|
38
|
+
- Let the API validate template signing order using its role definitions, so
|
|
39
|
+
copy receivers and editors are not counted as certificate signing peers.
|
|
40
|
+
- Return processed documents waiting for identity review from
|
|
41
|
+
`documents.waitUntilReady()`.
|
|
42
|
+
- Correct digital-certificate pricing to 0.5 credits plus notification in
|
|
43
|
+
method references and integration examples, and fix optional-page access in
|
|
44
|
+
TypeScript examples.
|
|
45
|
+
|
|
46
|
+
## [2.7.1] - 2026-10-12
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
|
|
50
|
+
- `signerDocuments.listAsWorkspace()` and `searchAsWorkspace()` list and
|
|
51
|
+
search a signer's documents with the client's API key or OAuth token. They
|
|
52
|
+
never send a signer access code.
|
|
53
|
+
- `ApiError.rateLimit` exposes the `X-Rate-Limit-Limit`,
|
|
54
|
+
`X-Rate-Limit-Remaining`, `X-Rate-Limit-Reset` and `Retry-After` headers of
|
|
55
|
+
the failed response (new exported type `IRateLimitInfo`).
|
|
56
|
+
- `IOAuthTokenResponse.issued_token_type` and `ITemplateListItem.resource`,
|
|
57
|
+
as published in the API contract.
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- **`documents.sendToken()` follows the published contract**: it always sends
|
|
62
|
+
`{ "channel": "email", "recipient": "…" }` and resolves with the response
|
|
63
|
+
`data` (`{ document, channel, recipient }`, new type `ISendTokenResult`)
|
|
64
|
+
instead of `void`. The legacy `{ email }` body and its automatic retry are
|
|
65
|
+
gone. `SendTokenChannel` is now `'email'`; passing `'whatsapp'` or a
|
|
66
|
+
non-email recipient is rejected with a `ValidationError` before any request,
|
|
67
|
+
because the endpoint accepts only the email channel.
|
|
68
|
+
- `signerDocuments.decline()` and `declineMultiple()` reject a decline reason
|
|
69
|
+
longer than 2000 characters, the documented limit.
|
|
70
|
+
- `WebhookVerifier.verifySignature()` reads `webhook-*` headers from a plain
|
|
71
|
+
object regardless of letter case.
|
|
72
|
+
|
|
10
73
|
## [2.7.0] - 2026-10-10
|
|
11
74
|
|
|
12
75
|
### Changed
|
|
@@ -771,7 +834,10 @@ signer fields with `cpf` and `whatsapp_phone_number`.
|
|
|
771
834
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
772
835
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
773
836
|
|
|
774
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.
|
|
837
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.8.0...HEAD
|
|
838
|
+
[2.8.0]: https://github.com/assinafy/typescript-sdk/releases/tag/v2.8.0
|
|
839
|
+
[2.7.1]: https://github.com/assinafy/typescript-sdk/compare/v2.7.0...v2.7.1
|
|
840
|
+
[2.7.0]: https://github.com/assinafy/typescript-sdk/compare/v2.6.0...v2.7.0
|
|
775
841
|
[2.6.0]: https://github.com/assinafy/typescript-sdk/compare/v2.5.2...v2.6.0
|
|
776
842
|
[2.5.2]: https://github.com/assinafy/typescript-sdk/compare/v2.5.1...v2.5.2
|
|
777
843
|
[2.5.1]: https://github.com/assinafy/typescript-sdk/compare/v2.5.0...v2.5.1
|
package/README.en.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
TypeScript SDK for the [Assinafy API](https://api.assinafy.com.br/v1/docs) — a Brazilian digital signature platform.
|
|
6
6
|
|
|
7
|
-
Covers all
|
|
7
|
+
Covers all 112 operations in the current official OpenAPI document: accounts,
|
|
8
8
|
authentication, OAuth 2.1 applications, users, documents, assignments, signers,
|
|
9
9
|
signer-side flows, templates, tags, fields, webhooks, branding, statistics, and
|
|
10
10
|
the high-level `uploadAndRequestSignatures` workflow. Five additional
|
|
@@ -308,6 +308,10 @@ anything for them.
|
|
|
308
308
|
|
|
309
309
|
### Rate limiting
|
|
310
310
|
|
|
311
|
+
Once retries are spent, the `ApiError` carries `err.rateLimit` with `limit`,
|
|
312
|
+
`remaining`, `reset` (from `X-Rate-Limit-*`) and `retryAfter` (`Retry-After`,
|
|
313
|
+
in seconds).
|
|
314
|
+
|
|
311
315
|
On an HTTP `429`, the client automatically retries up to `maxRetries` times,
|
|
312
316
|
waiting for the server-provided `Retry-After` (or `X-Rate-Limit-Reset`) delay
|
|
313
317
|
before each attempt. Automatic replay is limited to read-safe `GET`, `HEAD`,
|
|
@@ -335,7 +339,7 @@ The configuration object accepted by `fromConfig` has the exported type
|
|
|
335
339
|
|
|
336
340
|
## Endpoint coverage
|
|
337
341
|
|
|
338
|
-
All
|
|
342
|
+
All 112 operations documented at https://api.assinafy.com.br/v1/docs are
|
|
339
343
|
covered. The table below is the resource-level summary; the detailed operation
|
|
340
344
|
ledger is in [docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
341
345
|
|
|
@@ -343,16 +347,16 @@ ledger is in [docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
|
343
347
|
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
344
348
|
| `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 |
|
|
345
349
|
| `client.signers` | create, get, list, update, delete, findByEmail |
|
|
346
|
-
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications |
|
|
350
|
+
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications, getIdentityVerification, downloadIdentityVerificationImage, reviewIdentityVerification |
|
|
347
351
|
| `client.templates` | create, list, get, update, delete, downloadPage |
|
|
348
352
|
| `client.tags` | list, create, update, delete |
|
|
349
353
|
| `client.workspaces` | create, list, get, update, delete, getTheme, downloadLogo, uploadLogo, deleteLogo, getStats |
|
|
350
|
-
| `client.webhooks` | listEndpoints, createEndpoint, getEndpoint, updateEndpoint, deleteEndpoint, getEndpointSecret, rotateEndpointSecret, register, get, inactivate, listEventTypes, listDispatches, retryDispatch |
|
|
354
|
+
| `client.webhooks` | listEndpoints, createEndpoint, getEndpoint, updateEndpoint, deleteEndpoint, deleteEndpointByUrl, getEndpointSecret, rotateEndpointSecret, register, get, inactivate, listEventTypes, listDispatches, retryDispatch |
|
|
351
355
|
| `client.fields` | create, list, get, update, delete, validate, validateMultiple, listTypes |
|
|
352
356
|
| `client.oauth` | **getProtectedResourceMetadata**, **getAuthorizationServerMetadata**, **createAuthorizationUrl**, **readAuthorizationCallback**, **exchangeCode**, **refreshToken**, **revokeToken**, **getUserInfo** |
|
|
353
357
|
| `client.auth` | getSocialLoginUrl, getSocialLoginCallbackUrl, login, verifyMfa, socialLogin, linkSocialLogin, createApiKey, getApiKey, deleteApiKey, changePassword, requestPasswordReset, resetPassword |
|
|
354
358
|
| `client.users` | getCurrent, getStats, getNotificationPreferences, updateNotificationPreferences, getMfa, startTotpEnrollment, confirmTotpEnrollment, regenerateRecoveryCodes, deleteMfaMethod |
|
|
355
|
-
| `client.signerDocuments` | getCurrent, list, search, download, signMultiple, declineMultiple, self, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline |
|
|
359
|
+
| `client.signerDocuments` | getCurrent, list, search, listAsWorkspace, searchAsWorkspace, download, signMultiple, declineMultiple, self, getIdentityVerification, startIdentityVerification, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline |
|
|
356
360
|
| `client.webhookVerifier` | verifySignature, extractEvent, getEventType, getEventData |
|
|
357
361
|
|
|
358
362
|
Every HTTP wrapper has TypeScript-checked request/response shapes and
|
|
@@ -425,7 +429,7 @@ type DocumentUploadShape = {
|
|
|
425
429
|
```
|
|
426
430
|
|
|
427
431
|
`DocumentStatus` covers `uploading`, `uploaded`, `metadata_processing`,
|
|
428
|
-
`metadata_ready`, `pending_signature`, `expired`, `certificating`,
|
|
432
|
+
`metadata_ready`, `pending_signature`, `pending_identity_review`, `expired`, `certificating`,
|
|
429
433
|
`certificated`, `rejected_by_signer`, `rejected_by_user`, and `failed`.
|
|
430
434
|
|
|
431
435
|
Uploads must be PDFs, at most 25 MB and at most 2,000 pages (the byte limit is
|
|
@@ -599,6 +603,52 @@ before signing. A `DigitalCertificate` signer cannot call `sign`; that branch
|
|
|
599
603
|
uses Assinafy's certificate flow, described in
|
|
600
604
|
[ICP-Brasil digital certificate](#icp-brasil-digital-certificate).
|
|
601
605
|
|
|
606
|
+
#### Identity-document verification branch
|
|
607
|
+
|
|
608
|
+
For a separate assignment configured with `verification_method:
|
|
609
|
+
'IdDocumentFaceMatchBasic'`, enable the **ID Document + Face Match** feature
|
|
610
|
+
and register a valid CPF in the signer's `government_id`. Either notification
|
|
611
|
+
channel is supported; estimate the fee before creating the assignment.
|
|
612
|
+
`self.verification_method` tells a custom signing portal to use this branch
|
|
613
|
+
instead of the email/WhatsApp OTP step.
|
|
614
|
+
|
|
615
|
+
```ts
|
|
616
|
+
const state = await signerClient.signerDocuments.getIdentityVerification(accessCode);
|
|
617
|
+
// Only after the signer's explicit biometric-processing consent:
|
|
618
|
+
if (state.can_start && signerConsented) {
|
|
619
|
+
const capture = await signerClient.signerDocuments.startIdentityVerification(
|
|
620
|
+
accessCode, { consent: true },
|
|
621
|
+
);
|
|
622
|
+
response.redirect(capture.url); // preserve the fragment; never log or store this bearer URL
|
|
623
|
+
}
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
An existing `Pending` session exposes its capture link in `state.url`.
|
|
627
|
+
Only no session or `Expired` allows a new start; `Declined` and `Abandoned`
|
|
628
|
+
require a new document/assignment. An elapsed `expires_at` alone does not
|
|
629
|
+
authorize a restart. Once `Approved` or `InReview`, continue with data/terms
|
|
630
|
+
confirmation and signing. `InReview` holds certification; after everyone
|
|
631
|
+
signs the document becomes `pending_identity_review`.
|
|
632
|
+
|
|
633
|
+
```ts
|
|
634
|
+
// Account-side review, using workspace credentials:
|
|
635
|
+
const review = await client.assignments.getIdentityVerification(documentId, assignmentId, signerId);
|
|
636
|
+
const image = review.images[0];
|
|
637
|
+
if (image) {
|
|
638
|
+
const bytes = await client.assignments.downloadIdentityVerificationImage(documentId, assignmentId, signerId, image);
|
|
639
|
+
// Show to the authorized reviewer without caching or logging the evidence.
|
|
640
|
+
}
|
|
641
|
+
// Send only the account reviewer's explicit decision:
|
|
642
|
+
await client.assignments.reviewIdentityVerification(documentId, assignmentId, signerId, {
|
|
643
|
+
decision: 'Approved', note: 'Verified independently.',
|
|
644
|
+
});
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
Approval permits certification after all signatures and reviews are complete.
|
|
648
|
+
`Rejected` cancels the document and notifies signers and copy receivers; the
|
|
649
|
+
optional note (up to 2000 characters, or null) stays hidden from them.
|
|
650
|
+
Images are available only while `InReview`.
|
|
651
|
+
|
|
602
652
|
### 6. Observe completion and download artifacts
|
|
603
653
|
|
|
604
654
|
Subscribe to `document_ready` for event-driven completion — on an endpoint with
|
|
@@ -691,12 +741,8 @@ await client.documents.verify('FE32EDDADE7CBDDCBB934E7402047450B0E59C02');
|
|
|
691
741
|
|
|
692
742
|
// Public endpoints (no auth)
|
|
693
743
|
await client.documents.getPublic(doc.id);
|
|
694
|
-
//
|
|
695
|
-
await client.documents.sendToken(doc.id, '
|
|
696
|
-
|
|
697
|
-
// Explicit compatibility overload for older deployments:
|
|
698
|
-
// { recipient: '+5548999990000', channel: 'whatsapp' }
|
|
699
|
-
await client.documents.sendToken(doc.id, '+5548999990000', 'whatsapp');
|
|
744
|
+
// Body: { channel: 'email', recipient: 'signer@example.com' } (email only)
|
|
745
|
+
await client.documents.sendToken(doc.id, 'signer@example.com');
|
|
700
746
|
|
|
701
747
|
// The current OpenAPI contract requires existing tag IDs.
|
|
702
748
|
const contractsTag = await client.tags.create({ name: 'Contracts' });
|
|
@@ -862,7 +908,8 @@ to `Email`.
|
|
|
862
908
|
| --- | --- | --- | --- |
|
|
863
909
|
| `Email` *(default)* | One-time code (OTP) by email | `Email` | Free |
|
|
864
910
|
| `Whatsapp` | One-time code (OTP) by WhatsApp | `Whatsapp` | 0.45 credit (the notification), paid plans only |
|
|
865
|
-
| `DigitalCertificate` | The signer signs with their **own ICP-Brasil certificate — A1 or A3 —** through the Web PKI extension, producing a **qualified PAdES signature** | `Email` **or** `Whatsapp` |
|
|
911
|
+
| `DigitalCertificate` | The signer signs with their **own ICP-Brasil certificate — A1 or A3 —** through the Web PKI extension, producing a **qualified PAdES signature** | `Email` **or** `Whatsapp` | 0.5 credits + the notification |
|
|
912
|
+
| `IdDocumentFaceMatchBasic` | Hosted identity-document, face and liveness verification | `Email` **or** `Whatsapp` | Use `estimateCost()` |
|
|
866
913
|
|
|
867
914
|
Exactly one notification method per signer. The SDK rejects an invalid
|
|
868
915
|
combination before the request; the API would answer `400`.
|
|
@@ -909,7 +956,7 @@ forward them outside the signing flow.
|
|
|
909
956
|
|
|
910
957
|
`DigitalCertificate` requires the account feature, a CPF or CNPJ in the
|
|
911
958
|
signer's `government_id`, and exactly one certificate signer in that signing
|
|
912
|
-
step. It costs
|
|
959
|
+
step. It costs 0.5 credits per certificate signer in addition to the selected
|
|
913
960
|
notification cost.
|
|
914
961
|
|
|
915
962
|
**A1 and A3 are certificate media**, chosen by the signer in their browser at
|
|
@@ -1024,6 +1071,10 @@ await client.tags.delete(tag.id, { force: true }); // detach everywhere,
|
|
|
1024
1071
|
|
|
1025
1072
|
Attach/detach tags on a specific document via `client.documents.listTags / replaceTags / addTags / detachTag` (see [Documents](#documents)).
|
|
1026
1073
|
|
|
1074
|
+
The published attachment contract takes tag IDs. Older sandbox deployments
|
|
1075
|
+
instead interpret strings as names and create ID-named tags for ID inputs;
|
|
1076
|
+
pass existing names intentionally there. See [document tag compatibility](docs/COMPATIBILITY.md#document-tags).
|
|
1077
|
+
|
|
1027
1078
|
### Workspaces
|
|
1028
1079
|
|
|
1029
1080
|
The official create/update request schemas define `name` and
|
|
@@ -1083,7 +1134,7 @@ await client.fields.get(fieldId);
|
|
|
1083
1134
|
await client.fields.update(fieldId, { name: 'Updated Name' });
|
|
1084
1135
|
await client.fields.delete(fieldId);
|
|
1085
1136
|
|
|
1086
|
-
//
|
|
1137
|
+
// Workspace credentials apply; signerAccessCode is an optional legacy query.
|
|
1087
1138
|
await client.fields.validate(fieldId, '400.676.228-36', { signerAccessCode });
|
|
1088
1139
|
|
|
1089
1140
|
// Validate multiple values at once
|
|
@@ -1182,7 +1233,8 @@ Replacing an already confirmed authenticator also needs `password` or
|
|
|
1182
1233
|
An account has 1 webhook endpoint, or up to 3 on paid plans. Every active
|
|
1183
1234
|
endpoint subscribed to an event receives it independently. OAuth tokens need
|
|
1184
1235
|
`account:read` to read endpoints and `webhooks:write` to change them; the
|
|
1185
|
-
|
|
1236
|
+
creation response includes `secret` when signing is enabled. Store it then,
|
|
1237
|
+
including for OAuth integrations; reading or rotating it later requires an API key.
|
|
1186
1238
|
|
|
1187
1239
|
```ts
|
|
1188
1240
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1194,12 +1246,15 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1194
1246
|
});
|
|
1195
1247
|
// → { id, name, url, email, events, is_active, signing_enabled, created_at, updated_at }
|
|
1196
1248
|
|
|
1197
|
-
const
|
|
1249
|
+
const secret = endpoint.secret; // 'whsec_…'; store securely at creation
|
|
1198
1250
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
1251
|
+
await client.webhooks.listEndpoints(undefined, { url: endpoint.url }); // exact URL filter
|
|
1199
1252
|
await client.webhooks.getEndpoint(endpoint.id);
|
|
1200
1253
|
await client.webhooks.updateEndpoint(endpoint.id, { is_active: false }); // only the fields sent
|
|
1201
1254
|
await client.webhooks.rotateEndpointSecret(endpoint.id); // the old secret stops at once
|
|
1202
1255
|
await client.webhooks.deleteEndpoint(endpoint.id); // frees the plan slot
|
|
1256
|
+
// Alternative when the integration kept only the registered URL:
|
|
1257
|
+
// await client.webhooks.deleteEndpointByUrl(endpoint.url);
|
|
1203
1258
|
|
|
1204
1259
|
await client.webhooks.listEventTypes();
|
|
1205
1260
|
const history = await client.webhooks.listDispatches({
|
|
@@ -1286,6 +1341,11 @@ Event-specific values are:
|
|
|
1286
1341
|
| `signer_whatsapp_verified` | `Signer` | `Document` | `signer_whatsapp_phone_number` |
|
|
1287
1342
|
| `signer_data_confirmed` | `Signer` | `Document` | `signer_email` |
|
|
1288
1343
|
| `signer_viewed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1344
|
+
| `signer_identity_verified` | `Signer` | `Document` | `signer_full_name`, `evidence` when available |
|
|
1345
|
+
| `signer_identity_verification_failed` | `Signer` | `Document` | `signer_full_name`, `reason` |
|
|
1346
|
+
| `signer_identity_review_required` | `Signer` | `Document` | `signer_full_name`, `reason_codes` |
|
|
1347
|
+
| `signer_identity_review_approved` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `reason_codes` |
|
|
1348
|
+
| `signer_identity_review_rejected` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `note` |
|
|
1289
1349
|
| `signer_signed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1290
1350
|
| `signer_rejected_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1291
1351
|
| `user_rejected_document` | `User` | `Document` | `user_name` |
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
SDK oficial em TypeScript para a [API Assinafy](https://api.assinafy.com.br/v1/docs) — plataforma
|
|
6
6
|
brasileira de assinatura eletrônica de documentos.
|
|
7
7
|
|
|
8
|
-
Cobre as
|
|
8
|
+
Cobre as 112 operações do documento OpenAPI oficial: contas, autenticação, aplicações OAuth 2.1,
|
|
9
9
|
usuários, documentos, assignments, signatários, fluxos do lado do signatário, templates, tags,
|
|
10
10
|
campos, webhooks, identidade visual, estatísticas e o fluxo de alto nível
|
|
11
11
|
`uploadAndRequestSignatures`. Cinco rotas adicionais de gestão de templates usadas por integrações
|
|
@@ -296,6 +296,9 @@ configurações de conector; seus usuários não precisam que você registre nad
|
|
|
296
296
|
|
|
297
297
|
### Limite de requisições
|
|
298
298
|
|
|
299
|
+
Quando as tentativas se esgotam, o `ApiError` traz `err.rateLimit` com `limit`, `remaining`,
|
|
300
|
+
`reset` (de `X-Rate-Limit-*`) e `retryAfter` (`Retry-After`, em segundos).
|
|
301
|
+
|
|
299
302
|
Em um HTTP `429` o cliente retenta até `maxRetries` vezes, aguardando o `Retry-After` (ou
|
|
300
303
|
`X-Rate-Limit-Reset`) devolvido pelo servidor antes de cada tentativa. A repetição automática vale
|
|
301
304
|
apenas para `GET`, `HEAD`, `OPTIONS` e `DELETE`, que são seguros de repetir. `GET /sign` fica de
|
|
@@ -321,7 +324,7 @@ O objeto aceito por `fromConfig` tem o tipo exportado `ClientConfigInput`.
|
|
|
321
324
|
|
|
322
325
|
## Cobertura de endpoints
|
|
323
326
|
|
|
324
|
-
As
|
|
327
|
+
As 112 operações documentadas em https://api.assinafy.com.br/v1/docs estão cobertas. A tabela abaixo
|
|
325
328
|
é o resumo por recurso; o mapa detalhado por operação está em
|
|
326
329
|
[docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
327
330
|
|
|
@@ -329,16 +332,16 @@ As 106 operações documentadas em https://api.assinafy.com.br/v1/docs estão co
|
|
|
329
332
|
| --- | --- |
|
|
330
333
|
| `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 |
|
|
331
334
|
| `client.signers` | create, get, list, update, delete, findByEmail |
|
|
332
|
-
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications |
|
|
335
|
+
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications, getIdentityVerification, downloadIdentityVerificationImage, reviewIdentityVerification |
|
|
333
336
|
| `client.templates` | create, list, get, update, delete, downloadPage |
|
|
334
337
|
| `client.tags` | list, create, update, delete |
|
|
335
338
|
| `client.workspaces` | create, list, get, update, delete, getTheme, downloadLogo, uploadLogo, deleteLogo, getStats |
|
|
336
|
-
| `client.webhooks` | listEndpoints, createEndpoint, getEndpoint, updateEndpoint, deleteEndpoint, getEndpointSecret, rotateEndpointSecret, register, get, inactivate, listEventTypes, listDispatches, retryDispatch |
|
|
339
|
+
| `client.webhooks` | listEndpoints, createEndpoint, getEndpoint, updateEndpoint, deleteEndpoint, deleteEndpointByUrl, getEndpointSecret, rotateEndpointSecret, register, get, inactivate, listEventTypes, listDispatches, retryDispatch |
|
|
337
340
|
| `client.fields` | create, list, get, update, delete, validate, validateMultiple, listTypes |
|
|
338
341
|
| `client.oauth` | **getProtectedResourceMetadata**, **getAuthorizationServerMetadata**, **createAuthorizationUrl**, **readAuthorizationCallback**, **exchangeCode**, **refreshToken**, **revokeToken**, **getUserInfo** |
|
|
339
342
|
| `client.auth` | getSocialLoginUrl, getSocialLoginCallbackUrl, login, verifyMfa, socialLogin, linkSocialLogin, createApiKey, getApiKey, deleteApiKey, changePassword, requestPasswordReset, resetPassword |
|
|
340
343
|
| `client.users` | getCurrent, getStats, getNotificationPreferences, updateNotificationPreferences, getMfa, startTotpEnrollment, confirmTotpEnrollment, regenerateRecoveryCodes, deleteMfaMethod |
|
|
341
|
-
| `client.signerDocuments` | getCurrent, list, search, download, signMultiple, declineMultiple, self, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline |
|
|
344
|
+
| `client.signerDocuments` | getCurrent, list, search, listAsWorkspace, searchAsWorkspace, download, signMultiple, declineMultiple, self, getIdentityVerification, startIdentityVerification, acceptTerms, verifyEmail, confirmData, uploadSignature, downloadSignature, getAssignment, sign, decline |
|
|
342
345
|
| `client.webhookVerifier` | verifySignature, extractEvent, getEventType, getEventData |
|
|
343
346
|
|
|
344
347
|
Todo wrapper HTTP tem tipos de requisição e resposta verificados pelo TypeScript e JSDoc por método,
|
|
@@ -404,7 +407,7 @@ type DocumentUploadShape = {
|
|
|
404
407
|
```
|
|
405
408
|
|
|
406
409
|
`DocumentStatus` cobre `uploading`, `uploaded`, `metadata_processing`, `metadata_ready`,
|
|
407
|
-
`pending_signature`, `expired`, `certificating`, `certificated`, `rejected_by_signer`,
|
|
410
|
+
`pending_signature`, `pending_identity_review`, `expired`, `certificating`, `certificated`, `rejected_by_signer`,
|
|
408
411
|
`rejected_by_user` e `failed`.
|
|
409
412
|
|
|
410
413
|
O envio precisa ser um PDF de no máximo 25 MB e 2.000 páginas (o limite em bytes está exportado
|
|
@@ -570,6 +573,53 @@ assinar. Um signatário `DigitalCertificate` não pode usar `sign`; esse ramo pa
|
|
|
570
573
|
certificado da Assinafy, descrito em
|
|
571
574
|
[Certificado digital ICP-Brasil](#certificado-digital-icp-brasil).
|
|
572
575
|
|
|
576
|
+
#### Ramo de verificação do documento de identidade
|
|
577
|
+
|
|
578
|
+
Para um assignment separado com `verification_method:
|
|
579
|
+
'IdDocumentFaceMatchBasic'`, habilite **ID Document + Face Match** e cadastre
|
|
580
|
+
um CPF válido no `government_id` do signatário. Os dois canais de notificação
|
|
581
|
+
são aceitos; estime o custo antes de criar o assignment.
|
|
582
|
+
`self.verification_method` informa ao portal que deve usar este ramo em vez
|
|
583
|
+
da etapa de código de uso único por e-mail/WhatsApp.
|
|
584
|
+
|
|
585
|
+
```ts
|
|
586
|
+
const estado = await clienteSignatario.signerDocuments.getIdentityVerification(accessCode);
|
|
587
|
+
// Somente após consentimento explícito do signatário para o tratamento biométrico:
|
|
588
|
+
if (estado.can_start && signatarioConsentiu) {
|
|
589
|
+
const captura = await clienteSignatario.signerDocuments.startIdentityVerification(
|
|
590
|
+
accessCode, { consent: true },
|
|
591
|
+
);
|
|
592
|
+
response.redirect(captura.url); // preserve o fragmento; não registre nem armazene esta URL credencial
|
|
593
|
+
}
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
Uma sessão `Pending` existente expõe o link de captura em `estado.url`.
|
|
597
|
+
Só a ausência de sessão ou `Expired` permite iniciar outra; `Declined` e
|
|
598
|
+
`Abandoned` exigem novo documento/assignment. O simples vencimento de
|
|
599
|
+
`expires_at` não autoriza reinício. Em `Approved` ou `InReview`, continue
|
|
600
|
+
com confirmação dos dados/termos e assinatura. `InReview` segura a
|
|
601
|
+
certificação; depois que todos assinam, o documento fica
|
|
602
|
+
`pending_identity_review`.
|
|
603
|
+
|
|
604
|
+
```ts
|
|
605
|
+
// Lado da conta, com credenciais do workspace:
|
|
606
|
+
const revisao = await client.assignments.getIdentityVerification(documentId, assignmentId, signerId);
|
|
607
|
+
const imagem = revisao.images[0];
|
|
608
|
+
if (imagem) {
|
|
609
|
+
const bytes = await client.assignments.downloadIdentityVerificationImage(documentId, assignmentId, signerId, imagem);
|
|
610
|
+
// Exiba ao revisor autorizado sem cache nem log das evidências.
|
|
611
|
+
}
|
|
612
|
+
// Envie somente a decisão explícita do revisor da conta:
|
|
613
|
+
await client.assignments.reviewIdentityVerification(documentId, assignmentId, signerId, {
|
|
614
|
+
decision: 'Approved', note: 'Identidade conferida independentemente.',
|
|
615
|
+
});
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
A aprovação permite certificar depois de todas as assinaturas e aprovações.
|
|
619
|
+
`Rejected` cancela o documento e notifica signatários e destinatários de cópia;
|
|
620
|
+
a nota opcional (até 2000 caracteres, ou null) não é mostrada a eles.
|
|
621
|
+
As imagens só ficam disponíveis em `InReview`.
|
|
622
|
+
|
|
573
623
|
### 6. Acompanhe a conclusão e baixe os artefatos
|
|
574
624
|
|
|
575
625
|
Assine o evento `document_ready` para saber da conclusão por evento — em um endpoint com
|
|
@@ -660,12 +710,8 @@ await client.documents.verify('FE32EDDADE7CBDDCBB934E7402047450B0E59C02');
|
|
|
660
710
|
|
|
661
711
|
// Endpoints públicos (sem autenticação)
|
|
662
712
|
await client.documents.getPublic(doc.id);
|
|
663
|
-
// Corpo
|
|
664
|
-
await client.documents.sendToken(doc.id, '
|
|
665
|
-
|
|
666
|
-
// Sobrecarga explícita de compatibilidade para deploys mais antigos:
|
|
667
|
-
// { recipient: '+5548999990000', channel: 'whatsapp' }
|
|
668
|
-
await client.documents.sendToken(doc.id, '+5548999990000', 'whatsapp');
|
|
713
|
+
// Corpo: { channel: 'email', recipient: 'signer@example.com' } (só e-mail)
|
|
714
|
+
await client.documents.sendToken(doc.id, 'signer@example.com');
|
|
669
715
|
|
|
670
716
|
// O contrato OpenAPI atual exige IDs de tags já existentes.
|
|
671
717
|
const tagContratos = await client.tags.create({ name: 'Contratos' });
|
|
@@ -822,7 +868,8 @@ que faltar é inferido. Sem nenhum dos dois, ambos assumem `Email`.
|
|
|
822
868
|
| --- | --- | --- | --- |
|
|
823
869
|
| `Email` *(padrão)* | Código de uso único (OTP) por e-mail | `Email` | Gratuito |
|
|
824
870
|
| `Whatsapp` | Código de uso único (OTP) por WhatsApp | `Whatsapp` | 0,45 crédito (a notificação), só em planos pagos |
|
|
825
|
-
| `DigitalCertificate` | O signatário assina com o **próprio certificado ICP-Brasil — A1 ou A3 —** pela extensão Web PKI, gerando uma assinatura **PAdES qualificada** | `Email` **ou** `Whatsapp` |
|
|
871
|
+
| `DigitalCertificate` | O signatário assina com o **próprio certificado ICP-Brasil — A1 ou A3 —** pela extensão Web PKI, gerando uma assinatura **PAdES qualificada** | `Email` **ou** `Whatsapp` | 0,5 crédito + a notificação |
|
|
872
|
+
| `IdDocumentFaceMatchBasic` | Documento de identidade, foto e prova de vida em sessão hospedada | `Email` **ou** `Whatsapp` | Consulte `estimateCost()` |
|
|
826
873
|
|
|
827
874
|
Apenas um método de notificação por signatário. O SDK recusa uma combinação inválida antes da
|
|
828
875
|
requisição; a API responderia `400`.
|
|
@@ -868,7 +915,7 @@ nem encaminhe fora do fluxo de assinatura.
|
|
|
868
915
|
|
|
869
916
|
`DigitalCertificate` exige o recurso **Certificado Digital** na conta (planos Standard e Pro), CPF ou
|
|
870
917
|
CNPJ em `government_id` do signatário, e exatamente **um signatário por certificado naquele passo de
|
|
871
|
-
assinatura**. Custa
|
|
918
|
+
assinatura**. Custa 0,5 crédito por signatário, além do custo da notificação escolhida.
|
|
872
919
|
|
|
873
920
|
**A1 e A3 são mídias de certificado**, escolhidas pelo próprio signatário no navegador na hora de
|
|
874
921
|
assinar: A1 fica em software (um arquivo na máquina) e A3 em hardware (token ou cartão). A API
|
|
@@ -993,6 +1040,10 @@ await client.tags.delete(tag.id, { force: true }); // desanexa de tudo e
|
|
|
993
1040
|
Anexe/desanexe tags em um documento específico com `client.documents.listTags / replaceTags /
|
|
994
1041
|
addTags / detachTag` (veja [Documentos](#documentos)).
|
|
995
1042
|
|
|
1043
|
+
O contrato publicado usa IDs para anexar tags. Sandboxes antigos interpretam
|
|
1044
|
+
essas strings como nomes e criam tags com o ID como nome; nesses ambientes,
|
|
1045
|
+
envie nomes existentes intencionalmente. Veja a [compatibilidade de tags](docs/COMPATIBILITY.md#document-tags).
|
|
1046
|
+
|
|
996
1047
|
### Workspaces
|
|
997
1048
|
|
|
998
1049
|
Os schemas oficiais de criação/atualização definem `name` e `notification_sender_type`. O sandbox
|
|
@@ -1052,7 +1103,7 @@ await client.fields.get(fieldId);
|
|
|
1052
1103
|
await client.fields.update(fieldId, { name: 'Nome atualizado' });
|
|
1053
1104
|
await client.fields.delete(fieldId);
|
|
1054
1105
|
|
|
1055
|
-
//
|
|
1106
|
+
// Usa credenciais do workspace; signerAccessCode é uma query legada opcional.
|
|
1056
1107
|
await client.fields.validate(fieldId, '400.676.228-36', { signerAccessCode });
|
|
1057
1108
|
|
|
1058
1109
|
// Valida vários valores de uma vez
|
|
@@ -1153,7 +1204,8 @@ Trocar um autenticador já confirmado exige também `password` ou `reauth_code`
|
|
|
1153
1204
|
|
|
1154
1205
|
Uma conta tem 1 endpoint de webhook, ou até 3 nos planos pagos. Cada endpoint ativo inscrito em um
|
|
1155
1206
|
evento o recebe, de forma independente. Tokens OAuth exigem `account:read` para ler endpoints e
|
|
1156
|
-
`webhooks:write` para alterá-los
|
|
1207
|
+
`webhooks:write` para alterá-los. Com assinatura ativa, a criação devolve `secret`: guarde-o também
|
|
1208
|
+
nas integrações OAuth. Ler ou rotacionar esse segredo depois exige chave de API.
|
|
1157
1209
|
|
|
1158
1210
|
```ts
|
|
1159
1211
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1165,12 +1217,15 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1165
1217
|
});
|
|
1166
1218
|
// → { id, name, url, email, events, is_active, signing_enabled, created_at, updated_at }
|
|
1167
1219
|
|
|
1168
|
-
const
|
|
1220
|
+
const secret = endpoint.secret; // 'whsec_…'; guarde em armazenamento seguro na criação
|
|
1169
1221
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
1222
|
+
await client.webhooks.listEndpoints(undefined, { url: endpoint.url }); // filtro exato por URL
|
|
1170
1223
|
await client.webhooks.getEndpoint(endpoint.id);
|
|
1171
1224
|
await client.webhooks.updateEndpoint(endpoint.id, { is_active: false }); // só os campos enviados
|
|
1172
1225
|
await client.webhooks.rotateEndpointSecret(endpoint.id); // o segredo antigo para na hora
|
|
1173
1226
|
await client.webhooks.deleteEndpoint(endpoint.id); // libera a vaga do plano
|
|
1227
|
+
// Alternativa quando a integração guardou somente a URL:
|
|
1228
|
+
// await client.webhooks.deleteEndpointByUrl(endpoint.url);
|
|
1174
1229
|
|
|
1175
1230
|
await client.webhooks.listEventTypes();
|
|
1176
1231
|
const historico = await client.webhooks.listDispatches({
|
|
@@ -1251,6 +1306,11 @@ Os valores por evento são:
|
|
|
1251
1306
|
| `signer_whatsapp_verified` | `Signer` | `Document` | `signer_whatsapp_phone_number` |
|
|
1252
1307
|
| `signer_data_confirmed` | `Signer` | `Document` | `signer_email` |
|
|
1253
1308
|
| `signer_viewed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1309
|
+
| `signer_identity_verified` | `Signer` | `Document` | `signer_full_name`, `evidence` quando disponível |
|
|
1310
|
+
| `signer_identity_verification_failed` | `Signer` | `Document` | `signer_full_name`, `reason` |
|
|
1311
|
+
| `signer_identity_review_required` | `Signer` | `Document` | `signer_full_name`, `reason_codes` |
|
|
1312
|
+
| `signer_identity_review_approved` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `reason_codes` |
|
|
1313
|
+
| `signer_identity_review_rejected` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `note` |
|
|
1254
1314
|
| `signer_signed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1255
1315
|
| `signer_rejected_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1256
1316
|
| `user_rejected_document` | `User` | `Document` | `user_name` |
|