@assinafy/cli 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -208,6 +208,8 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
208
208
 
209
209
  Steps must form a contiguous sequence starting at `1`, and a `DigitalCertificate` signer must be alone in its step — both are validated locally before the request is sent. `--copy-receivers` takes **signer IDs** (people who only receive a copy of the finished document), not arbitrary email addresses.
210
210
 
211
+ In production, `notification_methods: []` defaults to `['Email']` and sends an invitation. Select the intended channel explicitly; an empty array does not disable notifications.
212
+
211
213
  To start from a saved template instead of a PDF:
212
214
 
213
215
  ```bash
@@ -223,10 +225,10 @@ Keep the certified PDF, the certificate page, the bundle, and the `documents act
223
225
 
224
226
  ## The signer side
225
227
 
226
- Signers do not use your API key. Each invitation carries a one-time **access code**, and the `assinafy signer` commands act as that signer:
228
+ Signers do not use your API key. The `assinafy signer` commands use a private **access code** from the signing verification link. For email verification, use the link and six-digit code from the same email; an invitation containing only a document ID and recipient does not contain this credential. Confirm the signer and document before submitting a decision:
227
229
 
228
230
  ```bash
229
- export ASSINAFY_SIGNER_ACCESS_CODE=<code-from-the-invitation>
231
+ export ASSINAFY_SIGNER_ACCESS_CODE=<code-from-the-verification-link>
230
232
 
231
233
  assinafy signer self # who the code belongs to
232
234
  assinafy signer assignment # the document as the signer sees it
@@ -237,7 +239,18 @@ assinafy signer sign <documentId> <assignmentId> --entries '[
237
239
  ]'
238
240
  ```
239
241
 
240
- Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code: `documents send-token <documentId> --email <email>` issues it and `signer verify-email --code <otp>` redeems it. `signer decline` (or `decline-multiple`) rejects with a reason, and `sign-multiple` completes several documents in one call.
242
+ Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code: `documents send-token <documentId> --recipient <email> --channel email` issues it and `signer verify-email --code <otp>` redeems it. `signer decline` (or `decline-multiple`) rejects with a reason, and `sign-multiple` completes several documents in one call.
243
+
244
+ Verification, data confirmation, and signature upload may return `[]` on success. Fetch `signer self` for the updated profile and check document progress and certified artifacts after signing. Full request and response examples are in the [signer SDK reference](docs/sdk-reference.md#signer-side-flows-clientsignerdocuments).
245
+
246
+ For a virtual assignment, confirm the signer's data and submit an empty entry array:
247
+
248
+ ```bash
249
+ assinafy signer confirm-data <documentId> --full-name 'Ana Lima' --email ana@example.com
250
+ assinafy signer sign <documentId> <assignmentId> --entries '[]'
251
+ ```
252
+
253
+ Single-document confirmation, signing, and decline commands verify that the access code matches the requested document and assignment before writing.
241
254
 
242
255
  Owner API credentials are stripped from every public and signer-side request, so an access-code flow can never leak your workspace key. The published signer artifact download is public; passing `--access-code` adds an identity preflight that confirms the code belongs to the signer being downloaded for.
243
256
 
@@ -385,15 +398,15 @@ assinafy send contract.pdf \
385
398
  | `documents activities <id>` | Activity log |
386
399
  | `documents delete <id> [-y]` | Delete a document |
387
400
  | `documents tags <id>` | List attached tags |
388
- | `documents tags-set <id> [tagIds...]` | Replace the tag set by ID (none detaches all) |
389
- | `documents tags-add <id> <tagIds...>` | Attach tags by ID |
401
+ | `documents tags-set <id> [tags...]` | Replace the tag set by name (none detaches all) |
402
+ | `documents tags-add <id> <tags...>` | Attach tags by name |
390
403
  | `documents tags-remove <id> <tagId>` | Detach one tag |
391
404
  | `documents create-from-template <templateId> --signers <json> [...]` | Create from a template |
392
405
  | `documents estimate-template-cost <templateId> --signers <json>` | Estimate template cost |
393
406
  | `documents verify <hash>` | Verify by signature hash (public) |
394
407
  | `documents statuses` | List every document status and whether it is deletable |
395
408
  | `documents public <id>` | Public unauthenticated lookup |
396
- | `documents send-token <id> --email <email>` | Send a verification token (`--recipient`/`--channel` remains for the live legacy form) |
409
+ | `documents send-token <id> --recipient <email> --channel email` | Send a verification token in production |
397
410
  | `documents progress <id>` | Signing progress |
398
411
  | `documents wait <id> [--timeout] [--interval]` | Poll until ready, failed, or timed out |
399
412
 
package/README.md CHANGED
@@ -263,6 +263,8 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
263
263
 
264
264
  Passos explícitos devem ser contíguos a partir de `1`. Um signatário `DigitalCertificate` deve estar sozinho no seu passo e ter os dados exigidos pela plataforma. O fluxo normal de `sign` não executa o handshake Web PKI. As rotas de certificado citadas na descrição da API não têm contratos OpenAPI publicados; o SDK não fornece chamadas especulativas para elas.
265
265
 
266
+ Em produção, `notification_methods: []` assume `['Email']` e envia o convite. Para escolher o canal, informe-o explicitamente; o array vazio não desativa notificações.
267
+
266
268
  `--copy-receivers` recebe IDs de signatários que receberão uma cópia final. Para coletar campos, use `assignments create --method collect --entries ...` com páginas, campos e signatários do documento; os formatos completos estão em [assignments](docs/assignments.md) e [SDK](docs/sdk-reference.md#assignments-clientassignments).
267
269
 
268
270
  Para iniciar a partir de um template:
@@ -279,9 +281,11 @@ assinafy documents create-from-template example_template --name 'Contrato' --sig
279
281
 
280
282
  Cada papel deve corresponder ao template escolhido. Campos de editor, tags, mensagem e vencimento são opcionais. Use IDs reais obtidos na sua conta ao executar os exemplos.
281
283
 
284
+ Para organizar documentos, `documents tags-set <id> Contratos` substitui as tags e `documents tags-add <id> Contratos` acrescenta nomes. Nomes inexistentes são criados. `documents tags-remove <id> <tagId>` e o filtro `documents list --tags <ids>` usam IDs obtidos em `documents tags <id>`.
285
+
282
286
  ## Fluxo do signatário
283
287
 
284
- Os comandos `signer` usam o código do convite, separado da credencial do proprietário. Configure `ASSINAFY_SIGNER_ACCESS_CODE` de forma privada. A aplicação deve apresentar termos, dados e documento à pessoa antes de enviar suas decisões:
288
+ Os comandos `signer` usam o código privado do link de verificação, separado da credencial do proprietário. Na verificação por e-mail, use o link e o código de seis dígitos da mesma mensagem; um convite que contém apenas o ID do documento e o destinatário não contém essa credencial. Configure `ASSINAFY_SIGNER_ACCESS_CODE` de forma privada e confirme o signatário e o documento. A aplicação deve apresentar termos, dados e documento à pessoa antes de enviar suas decisões:
285
289
 
286
290
  ```bash
287
291
  assinafy signer self --json
@@ -295,9 +299,20 @@ assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[
295
299
  ]' --json
296
300
  ```
297
301
 
298
- Os IDs e valores de campos vêm do assignment apresentado ao signatário. Quando for exigida verificação de e-mail, `documents send-token <id> --email <email>` envia o código e `signer verify-email --code <otp>` confirma; a variável `ASSINAFY_VERIFICATION_CODE` evita colocar o código nos argumentos. `decline` e `decline-multiple` exigem motivo não vazio com até 2.000 caracteres. As operações em lote usam `sign-multiple` e `decline-multiple`.
302
+ Os IDs e valores de campos vêm do assignment apresentado ao signatário. Quando for exigida verificação de e-mail, `documents send-token <id> --recipient <email> --channel email` envia o código e `signer verify-email --code <otp>` confirma; a variável `ASSINAFY_VERIFICATION_CODE` evita colocar o código nos argumentos. `decline` e `decline-multiple` exigem motivo não vazio com até 2.000 caracteres. As operações em lote usam `sign-multiple` e `decline-multiple`.
303
+
304
+ O SDK remove credenciais do proprietário das chamadas públicas e do signatário. O download público de artefato do signatário aceita opcionalmente um código para uma verificação prévia de identidade. Em produção, `send-token` usa `--recipient` e `--channel`; `--email` mantém o formato publicado para deployments que o aceitam.
305
+
306
+ Verificação, confirmação de dados e envio da imagem de assinatura podem retornar `[]` em caso de sucesso. Consulte `signer self` para obter o perfil atualizado e confirme o progresso e os artefatos certificados após assinar. Os exemplos completos de requisição e resposta estão na [referência do SDK para signatários](docs/sdk-reference.md#signer-side-flows-clientsignerdocuments).
307
+
308
+ Para um assignment virtual, confirme os dados do signatário e envie um array vazio:
309
+
310
+ ```bash
311
+ assinafy signer confirm-data "$DOCUMENT_ID" --full-name 'Ana Lima' --email ana@example.com
312
+ assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[]'
313
+ ```
299
314
 
300
- O SDK remove credenciais do proprietário das chamadas públicas e do signatário. O download público de artefato do signatário aceita opcionalmente um código para uma verificação prévia de identidade. A sobrecarga de `send-token` com `--recipient` e `--channel` permanece disponível para deployments que usam esse formato.
315
+ Os comandos de confirmação de dados, assinatura e recusa de um único documento verificam se o código de acesso corresponde ao documento e ao assignment antes de enviar a alteração.
301
316
 
302
317
  ## Eventos e webhooks
303
318
 
package/dist/api.cjs CHANGED
@@ -860,24 +860,24 @@ var DocumentResource = class extends BaseResource {
860
860
  );
861
861
  }
862
862
  /**
863
- * Replace the document's tag set with tag IDs. An empty array detaches all tags.
864
- * Values are forwarded unchanged for compatibility with deployments that also accept names.
863
+ * Replace the document's tag set. Production accepts tag names and creates missing tags.
864
+ * An empty array detaches all tags. Values are forwarded unchanged.
865
865
  */
866
866
  async replaceTags(documentId, tags, accountId) {
867
867
  const accId = this.accountId(accountId);
868
868
  const docId = this.requireId(documentId, "Document ID");
869
- if (!Array.isArray(tags)) throw new ValidationError("tags must be an array of tag IDs");
869
+ if (!Array.isArray(tags)) throw new ValidationError("tags must be an array");
870
870
  return this.call(
871
871
  "Failed to replace document tags",
872
872
  () => this.http.put(`/accounts/${accId}/documents/${docId}/tags`, { tags })
873
873
  );
874
874
  }
875
- /** Attach additional tag IDs without removing existing ones. */
875
+ /** Attach additional tag names without removing existing ones. Production creates missing tags. */
876
876
  async addTags(documentId, tags, accountId) {
877
877
  const accId = this.accountId(accountId);
878
878
  const docId = this.requireId(documentId, "Document ID");
879
879
  if (!Array.isArray(tags) || tags.length === 0) {
880
- throw new ValidationError("tags must be a non-empty array of tag IDs");
880
+ throw new ValidationError("tags must be a non-empty array");
881
881
  }
882
882
  return this.call(
883
883
  "Failed to add document tags",
@@ -1500,6 +1500,7 @@ var SignerDocumentsResource = class extends BaseResource {
1500
1500
  for (const [key, value] of Object.entries(payload)) {
1501
1501
  if (value !== void 0) body[key] = value;
1502
1502
  }
1503
+ await this.requireDocumentAccess(did, code);
1503
1504
  return this.call(
1504
1505
  "Failed to confirm signer data",
1505
1506
  () => this.http.put(`/documents/${did}/signers/confirm-data`, body, signerAccessConfig(code))
@@ -1552,13 +1553,20 @@ var SignerDocumentsResource = class extends BaseResource {
1552
1553
  () => this.http.get("/sign", signerAccessConfig(code, { has_accepted_terms: hasAcceptedTerms }))
1553
1554
  );
1554
1555
  }
1555
- /** `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign. */
1556
+ /**
1557
+ * `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign.
1558
+ * Virtual assignments accept `[]` after the signer confirms their data.
1559
+ */
1556
1560
  async sign(documentId, assignmentId, signerAccessCode, entries) {
1557
1561
  const did = this.requireId(documentId, "Document ID");
1558
1562
  const aid = this.requireId(assignmentId, "Assignment ID");
1559
1563
  const code = this.requireId(signerAccessCode, "signer-access-code");
1560
- if (!Array.isArray(entries) || entries.length === 0) {
1561
- throw new ValidationError("entries must be a non-empty array");
1564
+ if (!Array.isArray(entries)) {
1565
+ throw new ValidationError("entries must be an array");
1566
+ }
1567
+ const document = await this.requireDocumentAccess(did, code, aid);
1568
+ if (document.assignment?.method === "collect" && entries.length === 0) {
1569
+ throw new ValidationError("entries must be non-empty for collect assignments");
1562
1570
  }
1563
1571
  return this.call(
1564
1572
  "Failed to sign document",
@@ -1574,6 +1582,7 @@ var SignerDocumentsResource = class extends BaseResource {
1574
1582
  const aid = this.requireId(assignmentId, "Assignment ID");
1575
1583
  const code = this.requireId(signerAccessCode, "signer-access-code");
1576
1584
  validateDeclineReason(declineReason);
1585
+ await this.requireDocumentAccess(did, code, aid);
1577
1586
  return this.call(
1578
1587
  "Failed to decline assignment",
1579
1588
  () => this.http.put(
@@ -1583,6 +1592,13 @@ var SignerDocumentsResource = class extends BaseResource {
1583
1592
  )
1584
1593
  );
1585
1594
  }
1595
+ async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
1596
+ const document = await this.getAssignment(signerAccessCode);
1597
+ if (document.id !== documentId || assignmentId !== void 0 && document.assignment?.id !== assignmentId) {
1598
+ throw new ValidationError("Signer access code does not match the document or assignment");
1599
+ }
1600
+ return document;
1601
+ }
1586
1602
  };
1587
1603
  function validateDeclineReason(value) {
1588
1604
  if (typeof value !== "string" || !value.trim()) {