@assinafy/cli 2.1.3 → 2.2.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/.env.example CHANGED
@@ -31,6 +31,7 @@ ASSINAFY_PROVIDER_TOKEN=
31
31
  ASSINAFY_RESET_TOKEN=
32
32
  ASSINAFY_SIGNER_ACCESS_CODE=
33
33
  ASSINAFY_VERIFICATION_CODE=
34
+ ASSINAFY_CERTIFICATE_TOKEN=
34
35
 
35
36
  # Experimental verifier only: Assinafy does not publish its webhook signing scheme.
36
37
  # Do not treat WebhookVerifier as a production trust boundary without independent validation.
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
+ Email verification uses `["Email"]` notifications; WhatsApp uses `["Whatsapp"]`. ICP-Brasil A1 and A3 both use `DigitalCertificate`, with either delivery channel, a matching CPF/CNPJ in `government_id`, an eligible workspace, and sufficient credits. Select one notification channel per signer. These same options work for template roles. A1/A3 signing uses `startCertificate`, the signer's local Web PKI operation, and `completeCertificate`; [complete payloads and the signing sequence](docs/sdk-reference.md#icp-brasil-a1a3-certificates) are in the SDK reference.
212
+
211
213
  In production, `notification_methods: []` defaults to `['Email']` and sends an invitation. Select the intended channel explicitly; an empty array does not disable notifications.
212
214
 
213
215
  To start from a saved template instead of a PDF:
@@ -239,7 +241,9 @@ assinafy signer sign <documentId> <assignmentId> --entries '[
239
241
  ]'
240
242
  ```
241
243
 
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.
244
+ Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code. `documents send-token <documentId> --recipient <email> --channel email` sends it by email; use `--recipient <phone> --channel whatsapp` for WhatsApp. Both use `signer verify-code`; `verify-email` remains an alias. Set `ASSINAFY_VERIFICATION_CODE` to keep the OTP out of command arguments and preserve leading zeroes. `signer decline` (or `decline-multiple`) rejects with a reason, and `sign-multiple` completes several documents in one call.
245
+
246
+ For A1/A3 certificates, use Assinafy's hosted signing page or integrate Web PKI with the SDK. After document review and terms acceptance, `signer certificate-start --json` returns `{ "token": "..." }`. Have the browser sign that operation on the signer's device, then set `ASSINAFY_CERTIFICATE_TOKEN` to the same token and run `signer certificate-complete --json`; it returns `{ "signerName": "..." }`. Private keys and passwords/PINs stay on the device. Wait for `certificated` status and download `--artifact pades` or `bundle`. The ordinary `sign` command does not perform this handshake. These two production routes use the signing application's payloads and are not yet OpenAPI paths.
243
247
 
244
248
  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
249
 
@@ -331,7 +335,8 @@ Every setting resolves as **CLI flag → environment variable → config-file pr
331
335
  | Experimental webhook-verifier secret | _(config only)_ | `ASSINAFY_WEBHOOK_SECRET` |
332
336
  | Password / new password | `--password` / `--new-password` | `ASSINAFY_PASSWORD` / `ASSINAFY_NEW_PASSWORD` |
333
337
  | Social provider / reset token | `--provider-token` / `--reset-token` | `ASSINAFY_PROVIDER_TOKEN` / `ASSINAFY_RESET_TOKEN` |
334
- | Signer access code / email OTP | `--access-code` / `--code` | `ASSINAFY_SIGNER_ACCESS_CODE` / `ASSINAFY_VERIFICATION_CODE` |
338
+ | Signer access code / email or WhatsApp OTP | `--access-code` / `--code` | `ASSINAFY_SIGNER_ACCESS_CODE` / `ASSINAFY_VERIFICATION_CODE` |
339
+ | Web PKI operation token | `--certificate-token` | `ASSINAFY_CERTIFICATE_TOKEN` |
335
340
 
336
341
  `.env.example` documents every CLI and installer environment variable.
337
342
 
@@ -463,7 +468,7 @@ Field definitions are what `--method collect` assignments gather. Run `fields ty
463
468
 
464
469
  ### `signer` — signer-side flows
465
470
 
466
- `document <signerId>` · `documents <signerId>` · `search <signerId> <query>` · `download <signerId> <documentId> <artifact>` · `self` · `accept-terms` · `verify-email --code` · `confirm-data <documentId>` · `upload-signature --file` · `download-signature` · `assignment` · `sign <documentId> <assignmentId> --entries` · `decline <documentId> <assignmentId> --reason` · `sign-multiple --document-ids` · `decline-multiple --document-ids --reason`
471
+ `document <signerId>` · `documents <signerId>` · `search <signerId> <query>` · `download <signerId> <documentId> <artifact>` · `self` · `accept-terms` · `verify-code --code` (alias `verify-email`) · `certificate-start` · `certificate-complete --certificate-token` · `confirm-data <documentId>` · `upload-signature --file` · `download-signature` · `assignment` · `sign <documentId> <assignmentId> --entries` · `decline <documentId> <assignmentId> --reason` · `sign-multiple --document-ids` · `decline-multiple --document-ids --reason`
467
472
 
468
473
  Every signer command except the public artifact `download` requires `--access-code <code>`; `download` accepts it optionally for an identity preflight. Use `ASSINAFY_SIGNER_ACCESS_CODE` to keep the code out of process arguments.
469
474
 
package/README.md CHANGED
@@ -261,7 +261,9 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
261
261
  ]' --json
262
262
  ```
263
263
 
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.
264
+ Passos explícitos devem ser contíguos a partir de `1`. Um signatário `DigitalCertificate` deve estar sozinho no seu passo, ter CPF/CNPJ em `government_id` e usar um certificado correspondente. A conta precisa do recurso Digital Certificate e dos créditos indicados pela estimativa. A1 e A3 usam o mesmo fluxo: `startCertificate`, assinatura local pelo Web PKI e `completeCertificate`. As chamadas seguem os payloads da aplicação Assinafy em produção; essas duas rotas ainda não constam como paths no OpenAPI. Veja [requisições, respostas e sequência completa](docs/sdk-reference.md#icp-brasil-a1a3-certificates).
265
+
266
+ Verificação `Email` usa notificação `["Email"]`; `Whatsapp` usa `["Whatsapp"]`. `DigitalCertificate` permite um desses dois canais. Escolha apenas um canal por signatário; os mesmos campos são aceitos em documentos gerados de templates.
265
267
 
266
268
  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
269
 
@@ -299,7 +301,9 @@ assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[
299
301
  ]' --json
300
302
  ```
301
303
 
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`.
304
+ Os IDs e valores de campos vêm do assignment apresentado ao signatário. Para verificação por e-mail, `documents send-token <id> --recipient <email> --channel email` envia o código; para WhatsApp, use `--recipient <telefone> --channel whatsapp`. Ambos usam `signer verify-code`; `verify-email` continua disponível como alias. Configure `ASSINAFY_VERIFICATION_CODE` para manter o OTP fora dos argumentos e preservar zeros iniciais. `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`.
305
+
306
+ Para certificados A1/A3, use a página de assinatura Assinafy ou integre o Web PKI com o SDK. Após apresentar o documento e aceitar os termos, `signer certificate-start --json` retorna `{ "token": "..." }`. O navegador assina essa operação no dispositivo do signatário. Defina `ASSINAFY_CERTIFICATE_TOKEN` com o mesmo token e execute `signer certificate-complete --json`, que retorna `{ "signerName": "..." }`. A chave privada e a senha/PIN permanecem no dispositivo. Aguarde o documento ficar `certificated` e baixe `--artifact pades` ou `bundle`; o comando comum `sign` não substitui esse fluxo.
303
307
 
304
308
  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
309
 
package/dist/api.cjs CHANGED
@@ -1477,15 +1477,55 @@ var SignerDocumentsResource = class extends BaseResource {
1477
1477
  () => this.http.put("/signers/accept-terms", void 0, signerAccessConfig(code))
1478
1478
  );
1479
1479
  }
1480
- /** `POST /verify` — verify the email OTP for a signer. */
1481
- async verifyEmail(payload) {
1480
+ /** `POST /verify` — verify an email or WhatsApp OTP for a signer. */
1481
+ async verifyCode(payload) {
1482
1482
  const code = this.requireId(payload.signerAccessCode, "signer-access-code");
1483
1483
  const otp = this.requireId(payload.verificationCode, "verification-code");
1484
1484
  return this.call(
1485
- "Failed to verify signer email",
1485
+ "Failed to verify signer code",
1486
1486
  () => this.http.post("/verify", { "verification-code": otp }, signerAccessConfig(code))
1487
1487
  );
1488
1488
  }
1489
+ /** Compatibility alias for {@link verifyCode}; accepts email and WhatsApp OTPs. */
1490
+ async verifyEmail(payload) {
1491
+ return this.verifyCode(payload);
1492
+ }
1493
+ /**
1494
+ * `POST /signers/certificate/start` — start an ICP-Brasil A1/A3 signature.
1495
+ * Returns `{ token }` for the signer's Web PKI client. This production route
1496
+ * is used by Assinafy's signing frontend but is absent from OpenAPI paths.
1497
+ */
1498
+ async startCertificate(signerAccessCode) {
1499
+ const code = this.requireId(signerAccessCode, "signer-access-code");
1500
+ return this.call(
1501
+ "Failed to start certificate signature",
1502
+ () => this.http.post(
1503
+ "/signers/certificate/start",
1504
+ { "signer-access-code": code },
1505
+ signerAccessConfig(code)
1506
+ )
1507
+ );
1508
+ }
1509
+ /**
1510
+ * `POST /signers/certificate/complete` — finish an ICP-Brasil A1/A3 signature.
1511
+ * Pass the same token returned by {@link startCertificate}, after Web PKI
1512
+ * successfully signs it. Returns `{ signerName }`; private keys stay local.
1513
+ * This production route is absent from OpenAPI paths.
1514
+ */
1515
+ async completeCertificate(signerAccessCode, token) {
1516
+ const code = this.requireId(signerAccessCode, "signer-access-code");
1517
+ if (typeof token !== "string" || !token.trim()) {
1518
+ throw new ValidationError("Certificate token is required");
1519
+ }
1520
+ return this.call(
1521
+ "Failed to complete certificate signature",
1522
+ () => this.http.post(
1523
+ "/signers/certificate/complete",
1524
+ { "signer-access-code": code, token },
1525
+ signerAccessConfig(code)
1526
+ )
1527
+ );
1528
+ }
1489
1529
  /**
1490
1530
  * `PUT /documents/{documentId}/signers/confirm-data?signer-access-code=…`
1491
1531
  *