@assinafy/cli 2.4.1 → 2.4.2
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 +13 -10
- package/README.md +11 -2
- package/dist/api.cjs +8 -1
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +8 -1
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +50 -21
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/docs/api-operations.json +1 -1
- package/docs/api-reference.md +1 -5
- package/docs/migration-v2.md +4 -3
- package/docs/oauth-guide.md +4 -4
- package/docs/oauth.md +4 -4
- package/docs/sdk-reference.md +3 -3
- package/docs/signers.md +1 -1
- package/install.ps1 +10 -0
- package/install.sh +3 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
*[Leia em português](README.md) · English*
|
|
4
4
|
|
|
5
|
-
The official command-line interface and Node.js SDK for the [Assinafy API](https://api.assinafy.com.br/v1/docs), a Brazilian digital-signature platform. Upload PDFs, manage signers, request signatures, track
|
|
5
|
+
The official command-line interface and Node.js SDK for the [Assinafy API](https://api.assinafy.com.br/v1/docs), a Brazilian digital-signature platform. Upload PDFs, manage signers, request signatures, track activity history, and download certified documents — from a terminal, a shell script, or an application.
|
|
6
6
|
|
|
7
7
|
The CLI is a single self-contained executable. It prints human-readable tables by default and structured JSON with `--json`, so the same commands serve both interactive use and automation. The same package exposes a fully typed SDK at `@assinafy/cli/api` covering all 93 published API operations.
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ This document reads top to bottom: install, authenticate, send your first signat
|
|
|
32
32
|
|
|
33
33
|
- Node.js `>=22.12.0`. Node.js 24 LTS is recommended and is what CI publishes with; CI also tests 22 and 26.
|
|
34
34
|
- HTTPS with TLS 1.2 or higher to reach the Assinafy API; supported Node.js versions use that minimum by default.
|
|
35
|
-
- An Assinafy account and an API key (see [Authentication](#authentication)).
|
|
35
|
+
- An Assinafy account and an API key or consented OAuth connection (see [Authentication](#authentication)).
|
|
36
36
|
- Linux, macOS, or Windows. Release archives ship for `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`, `windows-x64`, and `windows-arm64`.
|
|
37
37
|
|
|
38
38
|
## Installation
|
|
@@ -111,7 +111,7 @@ The CLI includes the official application's public client ID and uses PKCE S256
|
|
|
111
111
|
https://integrations.assinafy.com.br/assinafy-cli/oauth-callback
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
The CLI requests
|
|
114
|
+
The CLI requests the seven scopes registered for its official application by default: `account:read documents:read documents:write templates:read templates:write webhooks:write offline_access`, including template read/write access and `webhooks:write` for webhook write commands. Existing connections need fresh consent to gain additional permissions. An explicit `--scope` selects another set. `openid`, `profile`, and `email` are excluded from the default; request them only with an application registered for those scopes to obtain OpenID Connect identity and UserInfo.
|
|
115
115
|
|
|
116
116
|
No `ASSINAFY_OAUTH_CLIENT_ID` configuration is needed for the official application. For your own application or another environment, use `--client-id` or that variable; the flag takes precedence. Register the callback URI and scopes for the selected application. In a private directory outside the repository:
|
|
117
117
|
|
|
@@ -228,14 +228,14 @@ Keep the certified PDF, the certificate page, the bundle, and the `documents act
|
|
|
228
228
|
|
|
229
229
|
## The signer side
|
|
230
230
|
|
|
231
|
-
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
|
|
231
|
+
Signers do not use your API key. The `assinafy signer` commands use a private **access code** from the signing verification link. For email or WhatsApp verification, use the link and six-digit code from the same message; an invitation containing only a document ID and recipient does not contain this credential. Set `ASSINAFY_SIGNER_ACCESS_CODE` and `ASSINAFY_VERIFICATION_CODE` privately. Confirm the signer and document before submitting a decision:
|
|
232
232
|
|
|
233
233
|
```bash
|
|
234
|
-
export ASSINAFY_SIGNER_ACCESS_CODE=<code-from-the-verification-link>
|
|
235
|
-
|
|
236
234
|
assinafy signer self # who the code belongs to
|
|
237
235
|
assinafy signer assignment # the document as the signer sees it
|
|
238
236
|
assinafy signer accept-terms
|
|
237
|
+
assinafy signer verify-code
|
|
238
|
+
assinafy signer confirm-data <documentId> --full-name 'Ana Lima' --email ana@example.com
|
|
239
239
|
assinafy signer upload-signature --file signature.png
|
|
240
240
|
assinafy signer sign <documentId> <assignmentId> --entries '[
|
|
241
241
|
{"itemId":"item_1","fieldId":"field_1","pageId":"page_1","value":"..."}
|
|
@@ -246,6 +246,8 @@ Where email or WhatsApp verification is configured, the signer also confirms a 6
|
|
|
246
246
|
|
|
247
247
|
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.
|
|
248
248
|
|
|
249
|
+
Before estimating or creating a certificate assignment, set the signer's CPF/CNPJ with `signers.update(signerId, { government_id })`, or `assinafy signers update <signerId> --cpf '<signer-CPF-or-CNPJ>'`. The update command sends `government_id`. Creating a signer by email may reuse an existing record without updating it. Each certificate signer needs a matching certificate and an individual signing step.
|
|
250
|
+
|
|
249
251
|
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).
|
|
250
252
|
|
|
251
253
|
For a virtual assignment, confirm the signer's data and submit an empty entry array:
|
|
@@ -299,9 +301,8 @@ assinafy documents list --page 2 --per-page 50 --json | jq '.meta'
|
|
|
299
301
|
# Upload and capture the new document ID
|
|
300
302
|
DOC=$(assinafy documents upload contract.pdf --json | jq -r '.id')
|
|
301
303
|
|
|
302
|
-
# Attach
|
|
303
|
-
|
|
304
|
-
assinafy documents tags-add "$DOC" "$TAG_ID"
|
|
304
|
+
# Attach a tag by name; production creates it if missing
|
|
305
|
+
assinafy documents tags-add "$DOC" legal
|
|
305
306
|
```
|
|
306
307
|
|
|
307
308
|
JSON errors carry a stable shape:
|
|
@@ -325,6 +326,8 @@ Destructive commands prompt for confirmation and refuse to run unattended unless
|
|
|
325
326
|
|
|
326
327
|
Every setting resolves as **CLI flag → environment variable → config-file profile → built-in default**. Credentials are selected together from the first level that supplies either type; an API key wins only when both types are supplied at that same level. Saving one credential type with `config set` clears the other from that profile. The CLI reads process environment variables; it does not automatically load `.env` files. The OAuth variables are listed in [.env.example](./.env.example).
|
|
327
328
|
|
|
329
|
+
Empty optional settings are ignored, including `.env.example` defaults. Configurations with invalid profile field types are ignored for reads and rejected by mutations.
|
|
330
|
+
|
|
328
331
|
| What | Flag | Environment variable |
|
|
329
332
|
| --- | --- | --- |
|
|
330
333
|
| API key (sent as `X-Api-Key`) | `--api-key` | `ASSINAFY_API_KEY` |
|
|
@@ -345,7 +348,7 @@ Public document verification and lookup, password reset, login and social login,
|
|
|
345
348
|
|
|
346
349
|
### Config file and profiles
|
|
347
350
|
|
|
348
|
-
`assinafy login` and `assinafy config set` write a JSON config file with owner-only (`0600`)
|
|
351
|
+
`assinafy login` and `assinafy config set` write a JSON config file with owner-only POSIX permissions (`0600` for the file and `0700` for its directory), including existing files and directories:
|
|
349
352
|
|
|
350
353
|
- Linux / macOS: `~/.config/assinafy/config.json` (honours `XDG_CONFIG_HOME`)
|
|
351
354
|
- Windows: `%APPDATA%\assinafy\config.json`
|
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ A CLI já inclui o ID público da aplicação oficial e usa PKCE S256, sem segre
|
|
|
94
94
|
https://integrations.assinafy.com.br/assinafy-cli/oauth-callback
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
A CLI solicita por padrão os
|
|
97
|
+
A CLI solicita por padrão os sete escopos cadastrados na aplicação oficial: `account:read documents:read documents:write templates:read templates:write webhooks:write offline_access`, incluindo leitura e alteração de templates e `webhooks:write` para os comandos que alteram webhooks. Uma conexão existente precisa de novo consentimento para obter permissões adicionais. `--scope` permite escolher outro conjunto. `openid`, `profile` e `email` não fazem parte do padrão; use-os apenas com uma aplicação cadastrada para esses escopos, para obter identidade OpenID Connect e UserInfo.
|
|
98
98
|
|
|
99
99
|
Não é necessário configurar `ASSINAFY_OAUTH_CLIENT_ID` para usar a aplicação oficial. Para uma aplicação própria ou outro ambiente, use `--client-id` ou essa variável; a flag tem precedência. A aplicação escolhida precisa ter a URI de retorno e os escopos cadastrados. Em um diretório privado fora do repositório:
|
|
100
100
|
|
|
@@ -120,6 +120,8 @@ Os comandos `oauth authorize` e `oauth exchange` continuam disponíveis para apl
|
|
|
120
120
|
|
|
121
121
|
A precedência é **flag → ambiente → perfil → padrão**. As credenciais são escolhidas juntas no primeiro nível que fornecer uma delas; nesse mesmo nível, a chave de API prevalece sobre o token. Assim, `--token` substitui uma chave existente no ambiente ou perfil. Salvar somente um tipo de credencial com `config set` remove o outro tipo daquele perfil.
|
|
122
122
|
|
|
123
|
+
Valores vazios de configurações opcionais são ignorados, inclusive os padrões de `.env.example`. Perfis com tipos de campos inválidos não são usados nem sobrescritos por comandos de configuração.
|
|
124
|
+
|
|
123
125
|
| Configuração | Flag | Variável |
|
|
124
126
|
| --- | --- | --- |
|
|
125
127
|
| Chave de API | `--api-key` | `ASSINAFY_API_KEY` |
|
|
@@ -263,6 +265,12 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
|
|
|
263
265
|
|
|
264
266
|
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
267
|
|
|
268
|
+
Antes de estimar ou criar um assignment com certificado, atualize o CPF/CNPJ do signatário. O cadastro por e-mail pode reutilizar um registro sem atualizar seus dados. A opção `--cpf` de atualização envia `government_id` e aceita CPF ou CNPJ:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
assinafy signers update "$SIGNER_ID" --cpf '<CPF-ou-CNPJ-do-signatário>' --json
|
|
272
|
+
```
|
|
273
|
+
|
|
266
274
|
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.
|
|
267
275
|
|
|
268
276
|
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.
|
|
@@ -287,12 +295,13 @@ Para organizar documentos, `documents tags-set <id> Contratos` substitui as tags
|
|
|
287
295
|
|
|
288
296
|
## Fluxo do signatário
|
|
289
297
|
|
|
290
|
-
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:
|
|
298
|
+
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 ou WhatsApp, 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` e `ASSINAFY_VERIFICATION_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:
|
|
291
299
|
|
|
292
300
|
```bash
|
|
293
301
|
assinafy signer self --json
|
|
294
302
|
assinafy signer document example_signer --json
|
|
295
303
|
assinafy signer accept-terms --json
|
|
304
|
+
assinafy signer verify-code --json
|
|
296
305
|
assinafy signer confirm-data "$DOCUMENT_ID" --full-name 'Ana Lima' --email ana@example.com --json
|
|
297
306
|
assinafy signer assignment --json
|
|
298
307
|
assinafy signer upload-signature --file assinatura.png --json
|
package/dist/api.cjs
CHANGED
|
@@ -1204,7 +1204,11 @@ var FieldsResource = class extends BaseResource {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
};
|
|
1206
1206
|
function validationConfig(signerAccessCode) {
|
|
1207
|
-
|
|
1207
|
+
if (signerAccessCode === void 0) return void 0;
|
|
1208
|
+
if (typeof signerAccessCode !== "string" || !signerAccessCode.trim()) {
|
|
1209
|
+
throw new ValidationError("signerAccessCode is required when supplied");
|
|
1210
|
+
}
|
|
1211
|
+
return signerAccessConfig(signerAccessCode);
|
|
1208
1212
|
}
|
|
1209
1213
|
|
|
1210
1214
|
// src/api/resources/oauth.ts
|
|
@@ -1312,6 +1316,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
1312
1316
|
if (callback.searchParams.get("iss") !== request.issuer) {
|
|
1313
1317
|
throw new ValidationError("OAuth issuer mismatch");
|
|
1314
1318
|
}
|
|
1319
|
+
if (callback.searchParams.has("code") === callback.searchParams.has("error")) {
|
|
1320
|
+
throw new ValidationError("OAuth callback must contain exactly one of code or error");
|
|
1321
|
+
}
|
|
1315
1322
|
if (callback.searchParams.has("error")) {
|
|
1316
1323
|
const error = callback.searchParams.get("error");
|
|
1317
1324
|
const oauthError = error.length > 0 && error.length <= 64 && !/[^a-z_]/.test(error) ? error : "unknown_error";
|