@assinafy/sdk 2.7.1 → 2.8.1
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 +50 -1
- package/README.en.md +89 -17
- package/README.md +86 -16
- package/dist/index.d.mts +399 -42
- package/dist/index.d.ts +399 -42
- package/dist/index.js +387 -44
- package/dist/index.mjs +386 -44
- package/docs/API_COVERAGE.md +14 -8
- package/docs/COMPATIBILITY.md +67 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.8.1] - 2026-10-19
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Reject `DigitalCertificate` signers unless an assignment is explicitly
|
|
15
|
+
`virtual`, before direct creation or cost estimation can invite or charge for
|
|
16
|
+
an unusable `collect` assignment. Template creation and estimation reject
|
|
17
|
+
certificate signers until the API enforces its server-derived method. All
|
|
18
|
+
paths expose the stable
|
|
19
|
+
`digital_certificate_requires_virtual_method` validation code.
|
|
20
|
+
|
|
21
|
+
## [2.8.0] - 2026-10-16
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Identity-document and face verification: `IdDocumentFaceMatchBasic` on
|
|
26
|
+
assignment and template creation and cost estimation,
|
|
27
|
+
`signerDocuments.getIdentityVerification()` and
|
|
28
|
+
`startIdentityVerification()`, and account-side
|
|
29
|
+
`assignments.getIdentityVerification()`,
|
|
30
|
+
`downloadIdentityVerificationImage()` and `reviewIdentityVerification()`.
|
|
31
|
+
Includes typed provider state, evidence, decisions, webhook events and the
|
|
32
|
+
`pending_identity_review` document status.
|
|
33
|
+
- `webhooks.deleteEndpointByUrl()` deletes an endpoint using its exact
|
|
34
|
+
registered URL. `listEndpoints()` accepts an optional second argument
|
|
35
|
+
`{ url }` to filter by that URL.
|
|
36
|
+
- `webhooks.createEndpoint()` returns `IWebhookEndpointCreateResponse`,
|
|
37
|
+
exposing the signing `secret` supplied at creation so OAuth applications can
|
|
38
|
+
store it without calling the API-key-only secret endpoint.
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- Reject dot-segment resource IDs before URL normalization can change the
|
|
43
|
+
requested route, and prevent redirect hooks from changing the destination
|
|
44
|
+
after credential checks.
|
|
45
|
+
- Reject invalid webhook timestamp tolerances instead of accepting stale
|
|
46
|
+
signed deliveries with a non-finite replay window.
|
|
47
|
+
- Search every matching signer page for an exact email so idempotent creation
|
|
48
|
+
reuses an existing signer beyond the first 50 substring matches.
|
|
49
|
+
- Let the API validate template signing order using its role definitions, so
|
|
50
|
+
copy receivers and editors are not counted as certificate signing peers.
|
|
51
|
+
- Return processed documents waiting for identity review from
|
|
52
|
+
`documents.waitUntilReady()`.
|
|
53
|
+
- Correct digital-certificate pricing to 0.5 credits plus notification in
|
|
54
|
+
method references and integration examples, and fix optional-page access in
|
|
55
|
+
TypeScript examples.
|
|
56
|
+
|
|
10
57
|
## [2.7.1] - 2026-10-12
|
|
11
58
|
|
|
12
59
|
### Added
|
|
@@ -798,7 +845,9 @@ signer fields with `cpf` and `whatsapp_phone_number`.
|
|
|
798
845
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
799
846
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
800
847
|
|
|
801
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.
|
|
848
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.8.1...HEAD
|
|
849
|
+
[2.8.1]: https://github.com/assinafy/typescript-sdk/compare/v2.8.0...v2.8.1
|
|
850
|
+
[2.8.0]: https://github.com/assinafy/typescript-sdk/releases/tag/v2.8.0
|
|
802
851
|
[2.7.1]: https://github.com/assinafy/typescript-sdk/compare/v2.7.0...v2.7.1
|
|
803
852
|
[2.7.0]: https://github.com/assinafy/typescript-sdk/compare/v2.6.0...v2.7.0
|
|
804
853
|
[2.6.0]: https://github.com/assinafy/typescript-sdk/compare/v2.5.2...v2.6.0
|
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
|
|
@@ -339,7 +339,7 @@ The configuration object accepted by `fromConfig` has the exported type
|
|
|
339
339
|
|
|
340
340
|
## Endpoint coverage
|
|
341
341
|
|
|
342
|
-
All
|
|
342
|
+
All 112 operations documented at https://api.assinafy.com.br/v1/docs are
|
|
343
343
|
covered. The table below is the resource-level summary; the detailed operation
|
|
344
344
|
ledger is in [docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
345
345
|
|
|
@@ -347,16 +347,16 @@ ledger is in [docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
|
347
347
|
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
348
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 |
|
|
349
349
|
| `client.signers` | create, get, list, update, delete, findByEmail |
|
|
350
|
-
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications |
|
|
350
|
+
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications, getIdentityVerification, downloadIdentityVerificationImage, reviewIdentityVerification |
|
|
351
351
|
| `client.templates` | create, list, get, update, delete, downloadPage |
|
|
352
352
|
| `client.tags` | list, create, update, delete |
|
|
353
353
|
| `client.workspaces` | create, list, get, update, delete, getTheme, downloadLogo, uploadLogo, deleteLogo, getStats |
|
|
354
|
-
| `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 |
|
|
355
355
|
| `client.fields` | create, list, get, update, delete, validate, validateMultiple, listTypes |
|
|
356
356
|
| `client.oauth` | **getProtectedResourceMetadata**, **getAuthorizationServerMetadata**, **createAuthorizationUrl**, **readAuthorizationCallback**, **exchangeCode**, **refreshToken**, **revokeToken**, **getUserInfo** |
|
|
357
357
|
| `client.auth` | getSocialLoginUrl, getSocialLoginCallbackUrl, login, verifyMfa, socialLogin, linkSocialLogin, createApiKey, getApiKey, deleteApiKey, changePassword, requestPasswordReset, resetPassword |
|
|
358
358
|
| `client.users` | getCurrent, getStats, getNotificationPreferences, updateNotificationPreferences, getMfa, startTotpEnrollment, confirmTotpEnrollment, regenerateRecoveryCodes, deleteMfaMethod |
|
|
359
|
-
| `client.signerDocuments` | getCurrent, list, search, listAsWorkspace, searchAsWorkspace, 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 |
|
|
360
360
|
| `client.webhookVerifier` | verifySignature, extractEvent, getEventType, getEventData |
|
|
361
361
|
|
|
362
362
|
Every HTTP wrapper has TypeScript-checked request/response shapes and
|
|
@@ -429,7 +429,7 @@ type DocumentUploadShape = {
|
|
|
429
429
|
```
|
|
430
430
|
|
|
431
431
|
`DocumentStatus` covers `uploading`, `uploaded`, `metadata_processing`,
|
|
432
|
-
`metadata_ready`, `pending_signature`, `expired`, `certificating`,
|
|
432
|
+
`metadata_ready`, `pending_signature`, `pending_identity_review`, `expired`, `certificating`,
|
|
433
433
|
`certificated`, `rejected_by_signer`, `rejected_by_user`, and `failed`.
|
|
434
434
|
|
|
435
435
|
Uploads must be PDFs, at most 25 MB and at most 2,000 pages (the byte limit is
|
|
@@ -603,6 +603,52 @@ before signing. A `DigitalCertificate` signer cannot call `sign`; that branch
|
|
|
603
603
|
uses Assinafy's certificate flow, described in
|
|
604
604
|
[ICP-Brasil digital certificate](#icp-brasil-digital-certificate).
|
|
605
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
|
+
|
|
606
652
|
### 6. Observe completion and download artifacts
|
|
607
653
|
|
|
608
654
|
Subscribe to `document_ready` for event-driven completion — on an endpoint with
|
|
@@ -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
|
|
911
|
+
| `DigitalCertificate` | The signer signs with their **own ICP-Brasil certificate — A1 or A3 —** through the Web PKI extension, producing a **qualified PAdES signature**; requires `method: 'virtual'` | `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`.
|
|
@@ -907,10 +954,19 @@ forward them outside the signing flow.
|
|
|
907
954
|
|
|
908
955
|
#### ICP-Brasil digital certificate
|
|
909
956
|
|
|
910
|
-
`DigitalCertificate` requires the account feature, a CPF
|
|
911
|
-
signer's `government_id`, and exactly one certificate signer in
|
|
912
|
-
step. It costs
|
|
913
|
-
notification cost.
|
|
957
|
+
`DigitalCertificate` requires `method: 'virtual'`, the account feature, a CPF
|
|
958
|
+
or CNPJ in the signer's `government_id`, and exactly one certificate signer in
|
|
959
|
+
that signing step. It costs 0.5 credits per certificate signer in addition to
|
|
960
|
+
the selected notification cost. A certificate flow completes the signer's
|
|
961
|
+
virtual item; it cannot submit placed fields through the ordinary `collect`
|
|
962
|
+
signing endpoint.
|
|
963
|
+
|
|
964
|
+
The SDK rejects certificate signers on a `collect` assignment in both
|
|
965
|
+
`create()` and `estimateCost()` before any request. Branch on
|
|
966
|
+
`ValidationError.errors.code ===
|
|
967
|
+
'digital_certificate_requires_virtual_method'`, or compare it with the
|
|
968
|
+
exported `DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD` constant; do not match
|
|
969
|
+
the human-readable message.
|
|
914
970
|
|
|
915
971
|
**A1 and A3 are certificate media**, chosen by the signer in their browser at
|
|
916
972
|
signing time: A1 lives in software (a file on the machine) and A3 in hardware
|
|
@@ -1000,9 +1056,12 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
1000
1056
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
1001
1057
|
```
|
|
1002
1058
|
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1059
|
+
The server derives a template assignment's method from its placed fields, and
|
|
1060
|
+
currently accepts certificate signers even when that produces an unusable
|
|
1061
|
+
`collect` assignment. Until the API enforces the virtual-only rule atomically,
|
|
1062
|
+
the SDK rejects `DigitalCertificate` in both `createFromTemplate()` and
|
|
1063
|
+
`estimateCostFromTemplate()` with the same stable validation code. Create a
|
|
1064
|
+
direct `virtual` assignment for certificate signers instead.
|
|
1006
1065
|
|
|
1007
1066
|
Template creation only uploads the PDF and provisions the default editor role —
|
|
1008
1067
|
configure roles/fields in the Assinafy editor (or the web UI) afterwards.
|
|
@@ -1024,6 +1083,10 @@ await client.tags.delete(tag.id, { force: true }); // detach everywhere,
|
|
|
1024
1083
|
|
|
1025
1084
|
Attach/detach tags on a specific document via `client.documents.listTags / replaceTags / addTags / detachTag` (see [Documents](#documents)).
|
|
1026
1085
|
|
|
1086
|
+
The published attachment contract takes tag IDs. Older sandbox deployments
|
|
1087
|
+
instead interpret strings as names and create ID-named tags for ID inputs;
|
|
1088
|
+
pass existing names intentionally there. See [document tag compatibility](docs/COMPATIBILITY.md#document-tags).
|
|
1089
|
+
|
|
1027
1090
|
### Workspaces
|
|
1028
1091
|
|
|
1029
1092
|
The official create/update request schemas define `name` and
|
|
@@ -1083,7 +1146,7 @@ await client.fields.get(fieldId);
|
|
|
1083
1146
|
await client.fields.update(fieldId, { name: 'Updated Name' });
|
|
1084
1147
|
await client.fields.delete(fieldId);
|
|
1085
1148
|
|
|
1086
|
-
//
|
|
1149
|
+
// Workspace credentials apply; signerAccessCode is an optional legacy query.
|
|
1087
1150
|
await client.fields.validate(fieldId, '400.676.228-36', { signerAccessCode });
|
|
1088
1151
|
|
|
1089
1152
|
// Validate multiple values at once
|
|
@@ -1182,7 +1245,8 @@ Replacing an already confirmed authenticator also needs `password` or
|
|
|
1182
1245
|
An account has 1 webhook endpoint, or up to 3 on paid plans. Every active
|
|
1183
1246
|
endpoint subscribed to an event receives it independently. OAuth tokens need
|
|
1184
1247
|
`account:read` to read endpoints and `webhooks:write` to change them; the
|
|
1185
|
-
|
|
1248
|
+
creation response includes `secret` when signing is enabled. Store it then,
|
|
1249
|
+
including for OAuth integrations; reading or rotating it later requires an API key.
|
|
1186
1250
|
|
|
1187
1251
|
```ts
|
|
1188
1252
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1194,12 +1258,15 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1194
1258
|
});
|
|
1195
1259
|
// → { id, name, url, email, events, is_active, signing_enabled, created_at, updated_at }
|
|
1196
1260
|
|
|
1197
|
-
const
|
|
1261
|
+
const secret = endpoint.secret; // 'whsec_…'; store securely at creation
|
|
1198
1262
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
1263
|
+
await client.webhooks.listEndpoints(undefined, { url: endpoint.url }); // exact URL filter
|
|
1199
1264
|
await client.webhooks.getEndpoint(endpoint.id);
|
|
1200
1265
|
await client.webhooks.updateEndpoint(endpoint.id, { is_active: false }); // only the fields sent
|
|
1201
1266
|
await client.webhooks.rotateEndpointSecret(endpoint.id); // the old secret stops at once
|
|
1202
1267
|
await client.webhooks.deleteEndpoint(endpoint.id); // frees the plan slot
|
|
1268
|
+
// Alternative when the integration kept only the registered URL:
|
|
1269
|
+
// await client.webhooks.deleteEndpointByUrl(endpoint.url);
|
|
1203
1270
|
|
|
1204
1271
|
await client.webhooks.listEventTypes();
|
|
1205
1272
|
const history = await client.webhooks.listDispatches({
|
|
@@ -1286,6 +1353,11 @@ Event-specific values are:
|
|
|
1286
1353
|
| `signer_whatsapp_verified` | `Signer` | `Document` | `signer_whatsapp_phone_number` |
|
|
1287
1354
|
| `signer_data_confirmed` | `Signer` | `Document` | `signer_email` |
|
|
1288
1355
|
| `signer_viewed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1356
|
+
| `signer_identity_verified` | `Signer` | `Document` | `signer_full_name`, `evidence` when available |
|
|
1357
|
+
| `signer_identity_verification_failed` | `Signer` | `Document` | `signer_full_name`, `reason` |
|
|
1358
|
+
| `signer_identity_review_required` | `Signer` | `Document` | `signer_full_name`, `reason_codes` |
|
|
1359
|
+
| `signer_identity_review_approved` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `reason_codes` |
|
|
1360
|
+
| `signer_identity_review_rejected` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `note` |
|
|
1289
1361
|
| `signer_signed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1290
1362
|
| `signer_rejected_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1291
1363
|
| `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
|
|
@@ -324,7 +324,7 @@ O objeto aceito por `fromConfig` tem o tipo exportado `ClientConfigInput`.
|
|
|
324
324
|
|
|
325
325
|
## Cobertura de endpoints
|
|
326
326
|
|
|
327
|
-
As
|
|
327
|
+
As 112 operações documentadas em https://api.assinafy.com.br/v1/docs estão cobertas. A tabela abaixo
|
|
328
328
|
é o resumo por recurso; o mapa detalhado por operação está em
|
|
329
329
|
[docs/API_COVERAGE.md](docs/API_COVERAGE.md).
|
|
330
330
|
|
|
@@ -332,16 +332,16 @@ As 106 operações documentadas em https://api.assinafy.com.br/v1/docs estão co
|
|
|
332
332
|
| --- | --- |
|
|
333
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 |
|
|
334
334
|
| `client.signers` | create, get, list, update, delete, findByEmail |
|
|
335
|
-
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications |
|
|
335
|
+
| `client.assignments` | list, create, estimateCost, resetExpiration, resendNotification, estimateResendCost, listWhatsAppNotifications, getIdentityVerification, downloadIdentityVerificationImage, reviewIdentityVerification |
|
|
336
336
|
| `client.templates` | create, list, get, update, delete, downloadPage |
|
|
337
337
|
| `client.tags` | list, create, update, delete |
|
|
338
338
|
| `client.workspaces` | create, list, get, update, delete, getTheme, downloadLogo, uploadLogo, deleteLogo, getStats |
|
|
339
|
-
| `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 |
|
|
340
340
|
| `client.fields` | create, list, get, update, delete, validate, validateMultiple, listTypes |
|
|
341
341
|
| `client.oauth` | **getProtectedResourceMetadata**, **getAuthorizationServerMetadata**, **createAuthorizationUrl**, **readAuthorizationCallback**, **exchangeCode**, **refreshToken**, **revokeToken**, **getUserInfo** |
|
|
342
342
|
| `client.auth` | getSocialLoginUrl, getSocialLoginCallbackUrl, login, verifyMfa, socialLogin, linkSocialLogin, createApiKey, getApiKey, deleteApiKey, changePassword, requestPasswordReset, resetPassword |
|
|
343
343
|
| `client.users` | getCurrent, getStats, getNotificationPreferences, updateNotificationPreferences, getMfa, startTotpEnrollment, confirmTotpEnrollment, regenerateRecoveryCodes, deleteMfaMethod |
|
|
344
|
-
| `client.signerDocuments` | getCurrent, list, search, listAsWorkspace, searchAsWorkspace, 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 |
|
|
345
345
|
| `client.webhookVerifier` | verifySignature, extractEvent, getEventType, getEventData |
|
|
346
346
|
|
|
347
347
|
Todo wrapper HTTP tem tipos de requisição e resposta verificados pelo TypeScript e JSDoc por método,
|
|
@@ -407,7 +407,7 @@ type DocumentUploadShape = {
|
|
|
407
407
|
```
|
|
408
408
|
|
|
409
409
|
`DocumentStatus` cobre `uploading`, `uploaded`, `metadata_processing`, `metadata_ready`,
|
|
410
|
-
`pending_signature`, `expired`, `certificating`, `certificated`, `rejected_by_signer`,
|
|
410
|
+
`pending_signature`, `pending_identity_review`, `expired`, `certificating`, `certificated`, `rejected_by_signer`,
|
|
411
411
|
`rejected_by_user` e `failed`.
|
|
412
412
|
|
|
413
413
|
O envio precisa ser um PDF de no máximo 25 MB e 2.000 páginas (o limite em bytes está exportado
|
|
@@ -573,6 +573,53 @@ assinar. Um signatário `DigitalCertificate` não pode usar `sign`; esse ramo pa
|
|
|
573
573
|
certificado da Assinafy, descrito em
|
|
574
574
|
[Certificado digital ICP-Brasil](#certificado-digital-icp-brasil).
|
|
575
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
|
+
|
|
576
623
|
### 6. Acompanhe a conclusão e baixe os artefatos
|
|
577
624
|
|
|
578
625
|
Assine o evento `document_ready` para saber da conclusão por evento — em um endpoint com
|
|
@@ -821,7 +868,8 @@ que faltar é inferido. Sem nenhum dos dois, ambos assumem `Email`.
|
|
|
821
868
|
| --- | --- | --- | --- |
|
|
822
869
|
| `Email` *(padrão)* | Código de uso único (OTP) por e-mail | `Email` | Gratuito |
|
|
823
870
|
| `Whatsapp` | Código de uso único (OTP) por WhatsApp | `Whatsapp` | 0,45 crédito (a notificação), só em planos pagos |
|
|
824
|
-
| `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
|
|
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**; exige `method: 'virtual'` | `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()` |
|
|
825
873
|
|
|
826
874
|
Apenas um método de notificação por signatário. O SDK recusa uma combinação inválida antes da
|
|
827
875
|
requisição; a API responderia `400`.
|
|
@@ -865,9 +913,16 @@ nem encaminhe fora do fluxo de assinatura.
|
|
|
865
913
|
|
|
866
914
|
#### Certificado digital ICP-Brasil
|
|
867
915
|
|
|
868
|
-
`DigitalCertificate` exige o recurso **Certificado Digital** na conta (planos
|
|
869
|
-
CNPJ em `government_id` do signatário, e exatamente **um signatário por
|
|
870
|
-
assinatura**. Custa
|
|
916
|
+
`DigitalCertificate` exige `method: 'virtual'`, o recurso **Certificado Digital** na conta (planos
|
|
917
|
+
Standard e Pro), CPF ou CNPJ em `government_id` do signatário, e exatamente **um signatário por
|
|
918
|
+
certificado naquele passo de assinatura**. Custa 0,5 crédito por signatário, além do custo da
|
|
919
|
+
notificação escolhida. O fluxo por certificado conclui o item virtual do signatário; ele não consegue
|
|
920
|
+
enviar campos posicionados pelo endpoint comum de assinatura `collect`.
|
|
921
|
+
|
|
922
|
+
O SDK rejeita signatários por certificado em assignments `collect`, tanto em `create()` quanto em
|
|
923
|
+
`estimateCost()`, antes de qualquer requisição. Ramifique por
|
|
924
|
+
`ValidationError.errors.code === 'digital_certificate_requires_virtual_method'`, ou compare com a
|
|
925
|
+
constante exportada `DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD`; não dependa da mensagem legível.
|
|
871
926
|
|
|
872
927
|
**A1 e A3 são mídias de certificado**, escolhidas pelo próprio signatário no navegador na hora de
|
|
873
928
|
assinar: A1 fica em software (um arquivo na máquina) e A3 em hardware (token ou cartão). A API
|
|
@@ -967,9 +1022,11 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
967
1022
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
968
1023
|
```
|
|
969
1024
|
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1025
|
+
O servidor deduz o método do assignment de template a partir dos campos posicionados e hoje aceita
|
|
1026
|
+
signatários por certificado mesmo quando isso cria um assignment `collect` impossível de concluir.
|
|
1027
|
+
Até a API impor atomicamente a regra de método virtual, o SDK rejeita `DigitalCertificate` tanto em
|
|
1028
|
+
`createFromTemplate()` quanto em `estimateCostFromTemplate()`, com o mesmo código estável. Para
|
|
1029
|
+
certificados, crie diretamente um assignment `virtual`.
|
|
973
1030
|
|
|
974
1031
|
Criar um template apenas envia o PDF e provisiona o papel de editor padrão — configure papéis e
|
|
975
1032
|
campos no editor da Assinafy depois. Os `download_url` dos objetos de página do template são URLs
|
|
@@ -992,6 +1049,10 @@ await client.tags.delete(tag.id, { force: true }); // desanexa de tudo e
|
|
|
992
1049
|
Anexe/desanexe tags em um documento específico com `client.documents.listTags / replaceTags /
|
|
993
1050
|
addTags / detachTag` (veja [Documentos](#documentos)).
|
|
994
1051
|
|
|
1052
|
+
O contrato publicado usa IDs para anexar tags. Sandboxes antigos interpretam
|
|
1053
|
+
essas strings como nomes e criam tags com o ID como nome; nesses ambientes,
|
|
1054
|
+
envie nomes existentes intencionalmente. Veja a [compatibilidade de tags](docs/COMPATIBILITY.md#document-tags).
|
|
1055
|
+
|
|
995
1056
|
### Workspaces
|
|
996
1057
|
|
|
997
1058
|
Os schemas oficiais de criação/atualização definem `name` e `notification_sender_type`. O sandbox
|
|
@@ -1051,7 +1112,7 @@ await client.fields.get(fieldId);
|
|
|
1051
1112
|
await client.fields.update(fieldId, { name: 'Nome atualizado' });
|
|
1052
1113
|
await client.fields.delete(fieldId);
|
|
1053
1114
|
|
|
1054
|
-
//
|
|
1115
|
+
// Usa credenciais do workspace; signerAccessCode é uma query legada opcional.
|
|
1055
1116
|
await client.fields.validate(fieldId, '400.676.228-36', { signerAccessCode });
|
|
1056
1117
|
|
|
1057
1118
|
// Valida vários valores de uma vez
|
|
@@ -1152,7 +1213,8 @@ Trocar um autenticador já confirmado exige também `password` ou `reauth_code`
|
|
|
1152
1213
|
|
|
1153
1214
|
Uma conta tem 1 endpoint de webhook, ou até 3 nos planos pagos. Cada endpoint ativo inscrito em um
|
|
1154
1215
|
evento o recebe, de forma independente. Tokens OAuth exigem `account:read` para ler endpoints e
|
|
1155
|
-
`webhooks:write` para alterá-los
|
|
1216
|
+
`webhooks:write` para alterá-los. Com assinatura ativa, a criação devolve `secret`: guarde-o também
|
|
1217
|
+
nas integrações OAuth. Ler ou rotacionar esse segredo depois exige chave de API.
|
|
1156
1218
|
|
|
1157
1219
|
```ts
|
|
1158
1220
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1164,12 +1226,15 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1164
1226
|
});
|
|
1165
1227
|
// → { id, name, url, email, events, is_active, signing_enabled, created_at, updated_at }
|
|
1166
1228
|
|
|
1167
|
-
const
|
|
1229
|
+
const secret = endpoint.secret; // 'whsec_…'; guarde em armazenamento seguro na criação
|
|
1168
1230
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
1231
|
+
await client.webhooks.listEndpoints(undefined, { url: endpoint.url }); // filtro exato por URL
|
|
1169
1232
|
await client.webhooks.getEndpoint(endpoint.id);
|
|
1170
1233
|
await client.webhooks.updateEndpoint(endpoint.id, { is_active: false }); // só os campos enviados
|
|
1171
1234
|
await client.webhooks.rotateEndpointSecret(endpoint.id); // o segredo antigo para na hora
|
|
1172
1235
|
await client.webhooks.deleteEndpoint(endpoint.id); // libera a vaga do plano
|
|
1236
|
+
// Alternativa quando a integração guardou somente a URL:
|
|
1237
|
+
// await client.webhooks.deleteEndpointByUrl(endpoint.url);
|
|
1173
1238
|
|
|
1174
1239
|
await client.webhooks.listEventTypes();
|
|
1175
1240
|
const historico = await client.webhooks.listDispatches({
|
|
@@ -1250,6 +1315,11 @@ Os valores por evento são:
|
|
|
1250
1315
|
| `signer_whatsapp_verified` | `Signer` | `Document` | `signer_whatsapp_phone_number` |
|
|
1251
1316
|
| `signer_data_confirmed` | `Signer` | `Document` | `signer_email` |
|
|
1252
1317
|
| `signer_viewed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1318
|
+
| `signer_identity_verified` | `Signer` | `Document` | `signer_full_name`, `evidence` quando disponível |
|
|
1319
|
+
| `signer_identity_verification_failed` | `Signer` | `Document` | `signer_full_name`, `reason` |
|
|
1320
|
+
| `signer_identity_review_required` | `Signer` | `Document` | `signer_full_name`, `reason_codes` |
|
|
1321
|
+
| `signer_identity_review_approved` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `reason_codes` |
|
|
1322
|
+
| `signer_identity_review_rejected` | `Signer` | `Document` | `signer_full_name`, `reviewer_id`, `reviewer_name`, `note` |
|
|
1253
1323
|
| `signer_signed_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1254
1324
|
| `signer_rejected_document` | `Signer` | `Document` | `signer_full_name` |
|
|
1255
1325
|
| `user_rejected_document` | `User` | `Document` | `user_name` |
|