@assinafy/cli 2.1.3 → 2.3.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 +1 -0
- package/README.en.md +8 -3
- package/README.md +6 -2
- package/dist/api.cjs +44 -5
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +44 -5
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +72 -10
- package/dist/types/api/resources/assignments.d.ts +0 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/signer-documents.d.ts +18 -6
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +13 -0
- package/dist/types/api/types.d.ts.map +1 -1
- package/docs/sdk-reference.md +89 -2
- package/docs/signer.md +33 -4
- package/package.json +1 -1
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
|
|
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-
|
|
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
|
|
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.
|
|
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
|
@@ -416,7 +416,7 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
416
416
|
throw new ValidationError("method must be virtual or collect");
|
|
417
417
|
}
|
|
418
418
|
const signers = extractSignerRefs(payload);
|
|
419
|
-
if (signers.length === 0
|
|
419
|
+
if (signers.length === 0) {
|
|
420
420
|
throw new ValidationError("At least one signer is required", {
|
|
421
421
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
422
422
|
});
|
|
@@ -516,7 +516,6 @@ var AssignmentResource = class extends BaseResource {
|
|
|
516
516
|
`/documents/${docId}/assignments/estimate-cost`,
|
|
517
517
|
buildAssignmentPayload(payload, {
|
|
518
518
|
allowSignersWithoutId: true,
|
|
519
|
-
allowEmptySigners: true,
|
|
520
519
|
skipDigitalCertificateStepValidation: true
|
|
521
520
|
})
|
|
522
521
|
)
|
|
@@ -1477,15 +1476,55 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1477
1476
|
() => this.http.put("/signers/accept-terms", void 0, signerAccessConfig(code))
|
|
1478
1477
|
);
|
|
1479
1478
|
}
|
|
1480
|
-
/** `POST /verify` — verify
|
|
1481
|
-
async
|
|
1479
|
+
/** `POST /verify` — verify an email or WhatsApp OTP for a signer. */
|
|
1480
|
+
async verifyCode(payload) {
|
|
1482
1481
|
const code = this.requireId(payload.signerAccessCode, "signer-access-code");
|
|
1483
1482
|
const otp = this.requireId(payload.verificationCode, "verification-code");
|
|
1484
1483
|
return this.call(
|
|
1485
|
-
"Failed to verify signer
|
|
1484
|
+
"Failed to verify signer code",
|
|
1486
1485
|
() => this.http.post("/verify", { "verification-code": otp }, signerAccessConfig(code))
|
|
1487
1486
|
);
|
|
1488
1487
|
}
|
|
1488
|
+
/** Compatibility alias for {@link verifyCode}; accepts email and WhatsApp OTPs. */
|
|
1489
|
+
async verifyEmail(payload) {
|
|
1490
|
+
return this.verifyCode(payload);
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* `POST /signers/certificate/start` — start an ICP-Brasil A1/A3 signature.
|
|
1494
|
+
* Returns `{ token }` for the signer's Web PKI client. This production route
|
|
1495
|
+
* is used by Assinafy's signing frontend but is absent from OpenAPI paths.
|
|
1496
|
+
*/
|
|
1497
|
+
async startCertificate(signerAccessCode) {
|
|
1498
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1499
|
+
return this.call(
|
|
1500
|
+
"Failed to start certificate signature",
|
|
1501
|
+
() => this.http.post(
|
|
1502
|
+
"/signers/certificate/start",
|
|
1503
|
+
{ "signer-access-code": code },
|
|
1504
|
+
signerAccessConfig(code)
|
|
1505
|
+
)
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* `POST /signers/certificate/complete` — finish an ICP-Brasil A1/A3 signature.
|
|
1510
|
+
* Pass the same token returned by {@link startCertificate}, after Web PKI
|
|
1511
|
+
* successfully signs it. Returns `{ signerName }`; private keys stay local.
|
|
1512
|
+
* This production route is absent from OpenAPI paths.
|
|
1513
|
+
*/
|
|
1514
|
+
async completeCertificate(signerAccessCode, token) {
|
|
1515
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1516
|
+
if (typeof token !== "string" || !token.trim()) {
|
|
1517
|
+
throw new ValidationError("Certificate token is required");
|
|
1518
|
+
}
|
|
1519
|
+
return this.call(
|
|
1520
|
+
"Failed to complete certificate signature",
|
|
1521
|
+
() => this.http.post(
|
|
1522
|
+
"/signers/certificate/complete",
|
|
1523
|
+
{ "signer-access-code": code, token },
|
|
1524
|
+
signerAccessConfig(code)
|
|
1525
|
+
)
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1489
1528
|
/**
|
|
1490
1529
|
* `PUT /documents/{documentId}/signers/confirm-data?signer-access-code=…`
|
|
1491
1530
|
*
|