@assinafy/sdk 2.10.0 → 2.11.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 +33 -1
- package/README.en.md +39 -19
- package/README.md +39 -18
- package/dist/index.d.mts +114 -66
- package/dist/index.d.ts +114 -66
- package/dist/index.js +134 -70
- package/dist/index.mjs +134 -70
- package/docs/COMPATIBILITY.md +31 -27
- package/docs/RELEASING.md +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.11.0] - 2026-11-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Template document creation accepts either an existing signer `id` or an
|
|
15
|
+
`email` that reuses or creates the signer, with optional `name` and E.164
|
|
16
|
+
`whatsapp_phone_number`.
|
|
17
|
+
- Template creation and cost estimation support `DigitalCertificate` for
|
|
18
|
+
templates without placed signer fields; templates that produce `collect`
|
|
19
|
+
assignments remain rejected by the API.
|
|
20
|
+
- Webhook endpoint and delivery types expose hold state, attempt identity,
|
|
21
|
+
attempt kind, and whether another retry will follow. Endpoint updates expose
|
|
22
|
+
a newly generated signing secret when they turn signing on.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Assignment deadlines accept date-only values, date-times interpreted as UTC
|
|
27
|
+
when no offset is present, and offset-aware date-times.
|
|
28
|
+
- New or changed webhook endpoint URLs require HTTPS. OAuth applications with
|
|
29
|
+
`webhooks:write` can rotate a signing secret, while reading it remains
|
|
30
|
+
API-key-only.
|
|
31
|
+
- Webhook delivery guidance covers the six-attempt retry policy, endpoint hold
|
|
32
|
+
probes, oldest-first recovery, and seven-day history retention.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- Signer decline reasons count Unicode characters rather than UTF-16 code
|
|
37
|
+
units, allowing the documented 2,000-character limit for astral characters.
|
|
38
|
+
- Development tooling resolves `minimatch` 11.0.3, which prevents unbounded
|
|
39
|
+
glob-part amplification on attacker-controlled patterns.
|
|
40
|
+
|
|
10
41
|
## [2.10.0] - 2026-10-29
|
|
11
42
|
|
|
12
43
|
### Added
|
|
@@ -895,7 +926,8 @@ signer fields with `cpf` and `whatsapp_phone_number`.
|
|
|
895
926
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
896
927
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
897
928
|
|
|
898
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.
|
|
929
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.11.0...HEAD
|
|
930
|
+
[2.11.0]: https://github.com/assinafy/typescript-sdk/compare/v2.10.0...v2.11.0
|
|
899
931
|
[2.10.0]: https://github.com/assinafy/typescript-sdk/compare/v2.9.1...v2.10.0
|
|
900
932
|
[2.9.1]: https://github.com/assinafy/typescript-sdk/compare/v2.9.0...v2.9.1
|
|
901
933
|
[2.9.0]: https://github.com/assinafy/typescript-sdk/compare/v2.8.1...v2.9.0
|
package/README.en.md
CHANGED
|
@@ -990,6 +990,7 @@ await client.assignments.estimateCost(documentId, { signers: [{}] }); // default
|
|
|
990
990
|
|
|
991
991
|
await client.assignments.resetExpiration(documentId, assignmentId, '2027-06-30T00:00:00Z');
|
|
992
992
|
// The `expires_at` key is required by the contract; send `null` to remove the expiration.
|
|
993
|
+
// Date-only values end at 23:59 UTC; date-times without an offset are UTC.
|
|
993
994
|
await client.assignments.resetExpiration(documentId, assignmentId, null);
|
|
994
995
|
|
|
995
996
|
await client.assignments.resendNotification(documentId, assignmentId, signerId);
|
|
@@ -1161,11 +1162,19 @@ const signerRole = configured.roles?.find(
|
|
|
1161
1162
|
&& role.assignment_type.toLowerCase() !== 'editor',
|
|
1162
1163
|
);
|
|
1163
1164
|
if (!signerRole) throw new Error('Template has no signer role');
|
|
1164
|
-
await client.documents.createFromTemplate(
|
|
1165
|
+
const generated = await client.documents.createFromTemplate(
|
|
1165
1166
|
templateId,
|
|
1166
|
-
[{
|
|
1167
|
-
|
|
1167
|
+
[{
|
|
1168
|
+
role_id: signerRole.id,
|
|
1169
|
+
email: 'signer@example.com',
|
|
1170
|
+
name: 'Example Signer',
|
|
1171
|
+
verification_method: 'Email',
|
|
1172
|
+
notification_methods: ['Email'],
|
|
1173
|
+
}],
|
|
1174
|
+
{ name: 'NDA - Example', message: 'Please sign at your earliest convenience.' },
|
|
1168
1175
|
);
|
|
1176
|
+
// The response starts at status: 'uploaded' with assignment: null. Follow
|
|
1177
|
+
// documents.get(generated.id) or webhooks for pending_signature / failed.
|
|
1169
1178
|
|
|
1170
1179
|
// Estimate the cost before creating → ICostEstimate
|
|
1171
1180
|
await client.documents.estimateCostFromTemplate(templateId, [
|
|
@@ -1175,12 +1184,14 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
1175
1184
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
1176
1185
|
```
|
|
1177
1186
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
`
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1187
|
+
Each template signer uses an existing `id` or an `email`; `id` wins when both
|
|
1188
|
+
are sent. An email reuses the matching account signer or creates one with the
|
|
1189
|
+
supplied `name` and optional E.164 `whatsapp_phone_number`.
|
|
1190
|
+
|
|
1191
|
+
The server derives the assignment method from the template. A template without
|
|
1192
|
+
placed signer fields supports `DigitalCertificate`; a template with placed
|
|
1193
|
+
fields returns `400` because it produces a `collect` assignment. The same rule
|
|
1194
|
+
is applied by `estimateCostFromTemplate()`.
|
|
1184
1195
|
|
|
1185
1196
|
Template creation only uploads the PDF and provisions the default editor role —
|
|
1186
1197
|
configure roles/fields in the Assinafy editor (or the web UI) afterwards.
|
|
@@ -1366,7 +1377,8 @@ An account has 1 webhook endpoint, or up to 3 on paid plans. Every active
|
|
|
1366
1377
|
endpoint subscribed to an event receives it independently. OAuth tokens need
|
|
1367
1378
|
`account:read` to read endpoints and `webhooks:write` to change them; the
|
|
1368
1379
|
creation response includes `secret` when signing is enabled. Store it then,
|
|
1369
|
-
including for OAuth integrations
|
|
1380
|
+
including for OAuth integrations. Reading it later requires an API key; OAuth
|
|
1381
|
+
apps with `webhooks:write` can rotate a lost secret.
|
|
1370
1382
|
|
|
1371
1383
|
```ts
|
|
1372
1384
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1376,7 +1388,8 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1376
1388
|
events: ['document_ready', 'signer_signed_document', 'signer_rejected_document'],
|
|
1377
1389
|
signing_enabled: true, // sign deliveries with Standard Webhooks
|
|
1378
1390
|
});
|
|
1379
|
-
// → { id, name, url, email, events, is_active,
|
|
1391
|
+
// → { id, name, url, email, events, is_active, is_held, held_since,
|
|
1392
|
+
// signing_enabled, secret, created_at, updated_at }
|
|
1380
1393
|
|
|
1381
1394
|
const secret = endpoint.secret; // 'whsec_…'; store securely at creation
|
|
1382
1395
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
@@ -1398,14 +1411,15 @@ const history = await client.webhooks.listDispatches({
|
|
|
1398
1411
|
const retried = await client.webhooks.retryDispatch(dispatchId); // IWebhookDispatch
|
|
1399
1412
|
```
|
|
1400
1413
|
|
|
1401
|
-
|
|
1414
|
+
New or changed webhook URLs must use HTTPS. `createEndpoint()` returns `403`
|
|
1415
|
+
once the plan's limit is reached and `400`
|
|
1402
1416
|
when another endpoint of the workspace already uses the same `url`. When
|
|
1403
1417
|
`events` is omitted or empty, the SDK sends the exported
|
|
1404
1418
|
`DEFAULT_WEBHOOK_EVENTS`: `document_ready`, `document_prepared`,
|
|
1405
1419
|
`signer_signed_document`, `signer_rejected_document`, and
|
|
1406
1420
|
`document_processing_failed`. In
|
|
1407
1421
|
`updateEndpoint()`, `signing_enabled: true` generates a secret if there is none
|
|
1408
|
-
and `false` discards it.
|
|
1422
|
+
and returns that new secret once; `false` discards it.
|
|
1409
1423
|
|
|
1410
1424
|
The earlier routes remain and act on the account's oldest endpoint:
|
|
1411
1425
|
`register()` (create or update), `get()` (`IWebhookSubscription | null`) and
|
|
@@ -1415,11 +1429,13 @@ Assinafy delivers each event as an HTTP `POST` with
|
|
|
1415
1429
|
`Content-Type: application/json`, `Connection: close` and the headers
|
|
1416
1430
|
`webhook-id` (identical on every attempt of the same event to the same
|
|
1417
1431
|
endpoint — deduplicate on it), `webhook-timestamp` and, with signing on,
|
|
1418
|
-
`webhook-signature`. Any `2xx` is success.
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1432
|
+
`webhook-signature`. Any `2xx` is success. Connection errors, timeouts, `408`,
|
|
1433
|
+
`429`, and `5xx` responses receive up to six attempts about ten minutes apart;
|
|
1434
|
+
other statuses are final. After ten failed deliveries in a row, `is_held`
|
|
1435
|
+
becomes true and the oldest missed event is probed after 3, 15, and 60 minutes,
|
|
1436
|
+
then every six hours. Success resumes delivery and replays missed events oldest
|
|
1437
|
+
first. `retryDispatch()` sends once immediately, even while held. Dispatch
|
|
1438
|
+
history keeps the first 2,000 response characters for seven days.
|
|
1423
1439
|
|
|
1424
1440
|
Each history or retry result is an `IWebhookDispatch`:
|
|
1425
1441
|
|
|
@@ -1433,6 +1449,10 @@ type WebhookDispatchShape = {
|
|
|
1433
1449
|
endpoint: string | null;
|
|
1434
1450
|
payload: IWebhookPayload | Record<string, unknown> | null;
|
|
1435
1451
|
delivered: boolean;
|
|
1452
|
+
webhook_id?: string | null;
|
|
1453
|
+
attempt?: number | null;
|
|
1454
|
+
kind?: 'scheduled' | 'probe' | 'manual' | string;
|
|
1455
|
+
will_retry?: boolean;
|
|
1436
1456
|
http_status: number | null;
|
|
1437
1457
|
response_body: string | null;
|
|
1438
1458
|
error: string | null;
|
|
@@ -1445,7 +1465,7 @@ Every delivery body uses this envelope:
|
|
|
1445
1465
|
|
|
1446
1466
|
```ts
|
|
1447
1467
|
type WebhookPayloadShape = {
|
|
1448
|
-
id: number; //
|
|
1468
|
+
id: number; // internal activity ID; deduplicate on webhook-id
|
|
1449
1469
|
event: string;
|
|
1450
1470
|
message: string | null;
|
|
1451
1471
|
payload: Record<string, unknown> | null;
|
package/README.md
CHANGED
|
@@ -946,6 +946,7 @@ await client.assignments.estimateCost(documentId, { signers: [{}] }); // Email p
|
|
|
946
946
|
|
|
947
947
|
await client.assignments.resetExpiration(documentId, assignmentId, '2027-06-30T00:00:00Z');
|
|
948
948
|
// A chave `expires_at` é exigida pelo contrato; envie `null` para remover a expiração.
|
|
949
|
+
// Valores só com data terminam às 23:59 UTC; data/hora sem offset é UTC.
|
|
949
950
|
await client.assignments.resetExpiration(documentId, assignmentId, null);
|
|
950
951
|
|
|
951
952
|
await client.assignments.resendNotification(documentId, assignmentId, signerId);
|
|
@@ -1124,11 +1125,19 @@ const papelSignatario = configurado.roles?.find(
|
|
|
1124
1125
|
&& papel.assignment_type.toLowerCase() !== 'editor',
|
|
1125
1126
|
);
|
|
1126
1127
|
if (!papelSignatario) throw new Error('O template não tem papel de signatário');
|
|
1127
|
-
await client.documents.createFromTemplate(
|
|
1128
|
+
const gerado = await client.documents.createFromTemplate(
|
|
1128
1129
|
templateId,
|
|
1129
|
-
[{
|
|
1130
|
-
|
|
1130
|
+
[{
|
|
1131
|
+
role_id: papelSignatario.id,
|
|
1132
|
+
email: 'signatario@exemplo.com.br',
|
|
1133
|
+
name: 'Signatário Exemplo',
|
|
1134
|
+
verification_method: 'Email',
|
|
1135
|
+
notification_methods: ['Email'],
|
|
1136
|
+
}],
|
|
1137
|
+
{ name: 'NDA - Exemplo', message: 'Por favor, assine assim que puder.' },
|
|
1131
1138
|
);
|
|
1139
|
+
// A resposta começa com status: 'uploaded' e assignment: null. Acompanhe
|
|
1140
|
+
// documents.get(gerado.id) ou os webhooks até pending_signature / failed.
|
|
1132
1141
|
|
|
1133
1142
|
// Estime o custo antes de criar → ICostEstimate
|
|
1134
1143
|
await client.documents.estimateCostFromTemplate(templateId, [
|
|
@@ -1138,11 +1147,13 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
1138
1147
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
1139
1148
|
```
|
|
1140
1149
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1150
|
+
Cada signatário do template usa um `id` existente ou um `email`; `id` prevalece quando ambos são
|
|
1151
|
+
enviados. O email reutiliza o signatário correspondente da conta ou cria um com `name` e o
|
|
1152
|
+
`whatsapp_phone_number` E.164 opcional.
|
|
1153
|
+
|
|
1154
|
+
O servidor deduz o método do assignment a partir do template. Um template sem campos posicionados
|
|
1155
|
+
para o signatário aceita `DigitalCertificate`; com campos posicionados, a API devolve `400` porque
|
|
1156
|
+
o assignment seria `collect`. `estimateCostFromTemplate()` aplica a mesma regra.
|
|
1146
1157
|
|
|
1147
1158
|
Criar um template apenas envia o PDF e provisiona o papel de editor padrão — configure papéis e
|
|
1148
1159
|
campos no editor da Assinafy depois. Os `download_url` dos objetos de página do template são URLs
|
|
@@ -1331,7 +1342,8 @@ Trocar um autenticador já confirmado exige também `password` ou `reauth_code`
|
|
|
1331
1342
|
Uma conta tem 1 endpoint de webhook, ou até 3 nos planos pagos. Cada endpoint ativo inscrito em um
|
|
1332
1343
|
evento o recebe, de forma independente. Tokens OAuth exigem `account:read` para ler endpoints e
|
|
1333
1344
|
`webhooks:write` para alterá-los. Com assinatura ativa, a criação devolve `secret`: guarde-o também
|
|
1334
|
-
nas integrações OAuth. Ler
|
|
1345
|
+
nas integrações OAuth. Ler o segredo depois exige chave de API; uma aplicação OAuth com
|
|
1346
|
+
`webhooks:write` pode rotacionar um segredo perdido.
|
|
1335
1347
|
|
|
1336
1348
|
```ts
|
|
1337
1349
|
const endpoint = await client.webhooks.createEndpoint({
|
|
@@ -1341,7 +1353,8 @@ const endpoint = await client.webhooks.createEndpoint({
|
|
|
1341
1353
|
events: ['document_ready', 'signer_signed_document', 'signer_rejected_document'],
|
|
1342
1354
|
signing_enabled: true, // assina as entregas no padrão Standard Webhooks
|
|
1343
1355
|
});
|
|
1344
|
-
// → { id, name, url, email, events, is_active,
|
|
1356
|
+
// → { id, name, url, email, events, is_active, is_held, held_since,
|
|
1357
|
+
// signing_enabled, secret, created_at, updated_at }
|
|
1345
1358
|
|
|
1346
1359
|
const secret = endpoint.secret; // 'whsec_…'; guarde em armazenamento seguro na criação
|
|
1347
1360
|
await client.webhooks.listEndpoints(); // IWebhookEndpoint[]
|
|
@@ -1363,11 +1376,13 @@ const historico = await client.webhooks.listDispatches({
|
|
|
1363
1376
|
const reenviado = await client.webhooks.retryDispatch(dispatchId); // IWebhookDispatch
|
|
1364
1377
|
```
|
|
1365
1378
|
|
|
1366
|
-
|
|
1379
|
+
URLs novas ou alteradas de webhook devem usar HTTPS. `createEndpoint()` devolve `403` quando o
|
|
1380
|
+
limite do plano foi atingido e `400` quando outro endpoint
|
|
1367
1381
|
do workspace já usa a mesma `url`. Quando `events` é omitido ou vazio, o SDK envia
|
|
1368
1382
|
`DEFAULT_WEBHOOK_EVENTS` (exportado): `document_ready`, `document_prepared`,
|
|
1369
|
-
`signer_signed_document`, `signer_rejected_document` e `document_processing_failed`. Em
|
|
1370
|
-
ainda não houver e
|
|
1383
|
+
`signer_signed_document`, `signer_rejected_document` e `document_processing_failed`. Em
|
|
1384
|
+
`updateEndpoint()`, `signing_enabled: true` gera um segredo se ainda não houver e devolve esse novo
|
|
1385
|
+
segredo uma vez; `false` o descarta.
|
|
1371
1386
|
|
|
1372
1387
|
As rotas anteriores continuam disponíveis e operam sobre o endpoint mais antigo da conta:
|
|
1373
1388
|
`register()` (cria ou atualiza), `get()` (`IWebhookSubscription | null`) e `inactivate()`.
|
|
@@ -1375,10 +1390,12 @@ As rotas anteriores continuam disponíveis e operam sobre o endpoint mais antigo
|
|
|
1375
1390
|
A Assinafy entrega cada evento como um `POST` HTTP com `Content-Type: application/json`,
|
|
1376
1391
|
`Connection: close` e os headers `webhook-id` (igual em todas as tentativas do mesmo evento para o
|
|
1377
1392
|
mesmo endpoint — use-o para deduplicar), `webhook-timestamp` e, com assinatura ativa,
|
|
1378
|
-
`webhook-signature`. Qualquer `2xx` é sucesso.
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1393
|
+
`webhook-signature`. Qualquer `2xx` é sucesso. Erros de conexão, timeouts, `408`, `429` e `5xx`
|
|
1394
|
+
recebem até seis tentativas, separadas por cerca de dez minutos; outros status são finais. Depois
|
|
1395
|
+
de dez entregas falhas seguidas, `is_held` fica verdadeiro e o evento perdido mais antigo é testado
|
|
1396
|
+
após 3, 15 e 60 minutos, e depois a cada seis horas. O sucesso retoma as entregas e envia os eventos
|
|
1397
|
+
perdidos do mais antigo para o mais novo. `retryDispatch()` envia uma vez imediatamente, mesmo
|
|
1398
|
+
durante a pausa. O histórico guarda os primeiros 2.000 caracteres da resposta por sete dias.
|
|
1382
1399
|
|
|
1383
1400
|
Cada item do histórico (ou resultado de reenvio) é um `IWebhookDispatch`:
|
|
1384
1401
|
|
|
@@ -1392,6 +1409,10 @@ type WebhookDispatchShape = {
|
|
|
1392
1409
|
endpoint: string | null;
|
|
1393
1410
|
payload: IWebhookPayload | Record<string, unknown> | null;
|
|
1394
1411
|
delivered: boolean;
|
|
1412
|
+
webhook_id?: string | null;
|
|
1413
|
+
attempt?: number | null;
|
|
1414
|
+
kind?: 'scheduled' | 'probe' | 'manual' | string;
|
|
1415
|
+
will_retry?: boolean;
|
|
1395
1416
|
http_status: number | null;
|
|
1396
1417
|
response_body: string | null;
|
|
1397
1418
|
error: string | null;
|
|
@@ -1404,7 +1425,7 @@ Todo corpo de entrega usa este envelope:
|
|
|
1404
1425
|
|
|
1405
1426
|
```ts
|
|
1406
1427
|
type WebhookPayloadShape = {
|
|
1407
|
-
id: number; //
|
|
1428
|
+
id: number; // atividade interna; deduplique pelo webhook-id
|
|
1408
1429
|
event: string;
|
|
1409
1430
|
message: string | null;
|
|
1410
1431
|
payload: Record<string, unknown> | null;
|