@assinafy/cli 1.0.2 → 2.0.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.
Files changed (69) hide show
  1. package/README.md +86 -38
  2. package/THIRD_PARTY_NOTICES.md +972 -0
  3. package/dist/api.cjs +1965 -0
  4. package/dist/api.cjs.map +1 -0
  5. package/dist/api.js +1909 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/cli.cjs +3018 -1560
  8. package/dist/types/api/client.d.ts +88 -0
  9. package/dist/types/api/client.d.ts.map +1 -0
  10. package/dist/types/api/errors.d.ts +28 -0
  11. package/dist/types/api/errors.d.ts.map +1 -0
  12. package/dist/types/api/index.d.ts +21 -0
  13. package/dist/types/api/index.d.ts.map +1 -0
  14. package/dist/types/api/resources/assignments.d.ts +39 -0
  15. package/dist/types/api/resources/assignments.d.ts.map +1 -0
  16. package/dist/types/api/resources/authentication.d.ts +55 -0
  17. package/dist/types/api/resources/authentication.d.ts.map +1 -0
  18. package/dist/types/api/resources/base.d.ts +35 -0
  19. package/dist/types/api/resources/base.d.ts.map +1 -0
  20. package/dist/types/api/resources/documents.d.ts +124 -0
  21. package/dist/types/api/resources/documents.d.ts.map +1 -0
  22. package/dist/types/api/resources/fields.d.ts +57 -0
  23. package/dist/types/api/resources/fields.d.ts.map +1 -0
  24. package/dist/types/api/resources/signer-documents.d.ts +72 -0
  25. package/dist/types/api/resources/signer-documents.d.ts.map +1 -0
  26. package/dist/types/api/resources/signers.d.ts +25 -0
  27. package/dist/types/api/resources/signers.d.ts.map +1 -0
  28. package/dist/types/api/resources/tags.d.ts +37 -0
  29. package/dist/types/api/resources/tags.d.ts.map +1 -0
  30. package/dist/types/api/resources/templates.d.ts +21 -0
  31. package/dist/types/api/resources/templates.d.ts.map +1 -0
  32. package/dist/types/api/resources/users.d.ts +14 -0
  33. package/dist/types/api/resources/users.d.ts.map +1 -0
  34. package/dist/types/api/resources/webhooks.d.ts +17 -0
  35. package/dist/types/api/resources/webhooks.d.ts.map +1 -0
  36. package/dist/types/api/resources/workspaces.d.ts +32 -0
  37. package/dist/types/api/resources/workspaces.d.ts.map +1 -0
  38. package/dist/types/api/support/webhook-verifier.d.ts +43 -0
  39. package/dist/types/api/support/webhook-verifier.d.ts.map +1 -0
  40. package/dist/types/api/types.d.ts +926 -0
  41. package/dist/types/api/types.d.ts.map +1 -0
  42. package/dist/types/api/utils.d.ts +34 -0
  43. package/dist/types/api/utils.d.ts.map +1 -0
  44. package/docs/README.md +9 -1
  45. package/docs/api-operations.json +718 -0
  46. package/docs/api-reference.md +7228 -0
  47. package/docs/assignments.md +21 -1
  48. package/docs/auth.md +28 -12
  49. package/docs/config.md +0 -1
  50. package/docs/docs.md +0 -1
  51. package/docs/documents.md +45 -6
  52. package/docs/fields.md +4 -2
  53. package/docs/login.md +0 -1
  54. package/docs/logout.md +0 -1
  55. package/docs/migration-v2.md +20 -0
  56. package/docs/releasing.md +42 -0
  57. package/docs/sdk-reference.md +344 -0
  58. package/docs/send.md +1 -2
  59. package/docs/signer.md +44 -19
  60. package/docs/signers.md +2 -3
  61. package/docs/tags.md +0 -1
  62. package/docs/templates.md +3 -3
  63. package/docs/users.md +85 -0
  64. package/docs/webhooks.md +1 -16
  65. package/docs/whoami.md +0 -1
  66. package/docs/workspaces.md +109 -10
  67. package/install.ps1 +117 -13
  68. package/install.sh +165 -30
  69. package/package.json +37 -16
package/README.md CHANGED
@@ -1,41 +1,41 @@
1
1
  # @assinafy/cli
2
2
 
3
- The official command-line interface for the [Assinafy API](https://api.assinafy.com.br/v1/docs) — a Brazilian digital-signature platform. Upload PDFs, manage signers, request signatures, and drive every documented endpoint straight from your terminal or scripts.
3
+ The 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, and automate documented API workflows from a terminal or application.
4
4
 
5
- A self-contained CLI with full coverage of the public API: `commander`-based, human-readable tables by default, and `--json` everywhere for scripting.
5
+ The self-contained CLI prints human-readable tables by default and supports `--json` for scripting. The package also exposes a typed SDK at `@assinafy/cli/api`; see the [SDK reference](./docs/sdk-reference.md).
6
6
 
7
7
  ## Requirements
8
8
 
9
- - Node.js 18+ (for the built-in `FormData` / `Blob` APIs used by uploads)
9
+ - Node.js `>=22.12.0`; Node.js 24 LTS is recommended
10
10
 
11
11
  ## Installation
12
12
 
13
13
  ```bash
14
- npm install -g @assinafy/cli
14
+ npm install -g @assinafy/cli@<version>
15
15
  # then
16
16
  assinafy --help
17
17
  ```
18
18
 
19
- Install from the latest GitHub release:
19
+ Omit `@<version>` only when you deliberately want the newest published release. For a GitHub release install, download and inspect the installer from the same immutable version tag you are installing:
20
20
 
21
21
  ```bash
22
- curl -fsSL https://raw.githubusercontent.com/assinafy/assinafy-cli/main/install.sh | bash
23
- ```
24
-
25
- Install a specific release:
26
-
27
- ```bash
28
- curl -fsSL https://raw.githubusercontent.com/assinafy/assinafy-cli/main/install.sh | bash -s -- v1.0.0
22
+ ASSINAFY_VERSION=vX.Y.Z # replace with a published release tag
23
+ curl -fsSLo assinafy-install.sh \
24
+ "https://raw.githubusercontent.com/assinafy/assinafy-cli/${ASSINAFY_VERSION}/install.sh"
25
+ less assinafy-install.sh
26
+ bash assinafy-install.sh "$ASSINAFY_VERSION"
29
27
  ```
30
28
 
31
29
  Windows PowerShell:
32
30
 
33
31
  ```powershell
34
- iwr https://raw.githubusercontent.com/assinafy/assinafy-cli/main/install.ps1 -UseB | iex
32
+ $Version = 'vX.Y.Z' # replace with a published release tag
33
+ Invoke-WebRequest "https://raw.githubusercontent.com/assinafy/assinafy-cli/$Version/install.ps1" -OutFile .\assinafy-install.ps1
34
+ Get-Content .\assinafy-install.ps1
35
+ & .\assinafy-install.ps1 -Version $Version
35
36
  ```
36
37
 
37
- The installers place the CLI in `~/.assinafy/bin` by default. Set `ASSINAFY_INSTALL`
38
- to choose another install directory.
38
+ The installers fetch the matching release archive and verify it against that release's `SHA256SUMS` before replacing the executable. They place the CLI in `~/.assinafy/bin` by default; set `ASSINAFY_INSTALL` to choose another directory or `ASSINAFY_NO_PATH_UPDATE=1` to leave `PATH` unchanged.
39
39
 
40
40
  Or run without installing:
41
41
 
@@ -71,10 +71,15 @@ The CLI resolves every credential with this precedence: **CLI flag → environme
71
71
  | Legacy JWT token (sent as `Bearer`) | `--token` | `ASSINAFY_TOKEN` |
72
72
  | Default account / workspace ID | `--account-id` | `ASSINAFY_ACCOUNT_ID` |
73
73
  | API base URL | `--base-url` | `ASSINAFY_BASE_URL` |
74
- | Webhook signing secret | _(config only)_ | `ASSINAFY_WEBHOOK_SECRET` |
74
+ | Experimental webhook-verifier secret | _(config only)_ | `ASSINAFY_WEBHOOK_SECRET` |
75
75
  | Config profile | `-p, --profile` | `ASSINAFY_PROFILE` |
76
+ | Password / new password | `--password` / `--new-password` | `ASSINAFY_PASSWORD` / `ASSINAFY_NEW_PASSWORD` |
77
+ | Social provider / reset token | `--provider-token` / `--reset-token` | `ASSINAFY_PROVIDER_TOKEN` / `ASSINAFY_RESET_TOKEN` |
78
+ | Signer access code / email OTP | `--access-code` / `--code` | `ASSINAFY_SIGNER_ACCESS_CODE` / `ASSINAFY_VERIFICATION_CODE` |
79
+
80
+ Public document verification/lookup, password reset, login/social-login, and signer access-code flows do not require stored credentials. Authenticated operations accept the API key or bearer token documented for their endpoint.
76
81
 
77
- Public document verification/lookup, password reset, login/social-login, and signer access-code flows do not require a stored API key. User-account operations such as `auth change-password` and `auth api-keys` require a JWT access token (`--token` or `ASSINAFY_TOKEN`) because the API documents those endpoints as bearer-token flows.
82
+ Secret-bearing flags can be visible in shell history and process listings. Prefer the hidden `login` prompt, the owner-only config file, or environment variables; do not put API keys, tokens, passwords, reset/provider tokens, or signer access codes in shared scripts or logs.
78
83
 
79
84
  ### Config file & profiles
80
85
 
@@ -84,13 +89,16 @@ Public document verification/lookup, password reset, login/social-login, and sig
84
89
  - Windows: `%APPDATA%\assinafy\config.json`
85
90
  - Override anywhere with `ASSINAFY_CONFIG_DIR`
86
91
 
92
+ Writes are atomic. Read-only commands warn and ignore a malformed config, while
93
+ login/logout and profile mutations refuse to overwrite it so its contents remain
94
+ available for recovery.
95
+
87
96
  Profiles let you keep separate credentials (e.g. production vs. sandbox):
88
97
 
89
98
  ```bash
90
- assinafy --profile sandbox config set \
91
- --api-key "k_sandbox..." \
92
- --account-id "acc_..." \
93
- --base-url "https://sandbox.assinafy.com.br/v1"
99
+ assinafy --profile sandbox \
100
+ --base-url "https://sandbox.assinafy.com.br/v1" \
101
+ login # prompts for the API key and account ID
94
102
 
95
103
  assinafy config use sandbox # make it the default
96
104
  assinafy config list # list profiles
@@ -108,11 +116,11 @@ By default commands print friendly tables / key-value blocks to **stdout**, with
108
116
  - `--json` — emit structured JSON on stdout (errors become JSON on stderr). Always machine-readable.
109
117
  - `-q, --quiet` — suppress spinners and status messages.
110
118
 
111
- Commands exit `0` on success and `1` on error (`130` on Ctrl-C). This makes the CLI safe to pipe (`assinafy documents list --json | jq '.[].id'`).
119
+ Commands exit `0` on success and `1` on error (`130` on Ctrl-C). Paginated JSON preserves both records and metadata: `assinafy documents list --json | jq -r '.data[].id'`.
112
120
 
113
121
  ## Command reference
114
122
 
115
- Run `assinafy <command> --help` for full flag details on any command. Detailed per-resource docs live in [`docs/`](./docs).
123
+ Run `assinafy <command> --help` for full flag details on any command. Per-command help is mirrored under [`docs/`](./docs), the [API reference](./docs/api-reference.md) contains the official request/response payloads for all 89 published operations, and the [SDK reference](./docs/sdk-reference.md) maps every public SDK method to those operations.
116
124
 
117
125
  ### `send` — upload + request signatures (headline workflow)
118
126
 
@@ -133,10 +141,12 @@ Use `--signers '<json>'` for full control (verification methods, signing order/`
133
141
  | --- | --- |
134
142
  | `documents upload <file> [--name] [--metadata] [--wait]` | Upload a PDF |
135
143
  | `documents list [--status] [--method] [--tags] [--page] [--per-page] [--search] [--sort]` | List documents |
144
+ | `documents search [query] [--status] [--page] [--per-page]` | Lightweight type-ahead search |
136
145
  | `documents get <id>` | Show document details |
137
- | `documents download <id> [--artifact] [-o]` | Download an artifact (`original`/`certificated`/`certificate-page`/`bundle`) |
138
- | `documents thumbnail <id> [-o]` | Download the thumbnail (JPEG) |
139
- | `documents download-page <id> <pageId> [-o]` | Download one page (JPEG) |
146
+ | `documents rename <id> <name>` | Rename a document (before signing starts) |
147
+ | `documents download <id> [--artifact] [-o] [--force]` | Download an artifact (`original`/`certificated`/`certificate-page`/`pades` PDFs or `bundle` ZIP) |
148
+ | `documents thumbnail <id> [-o] [--force]` | Download the thumbnail (JPEG) |
149
+ | `documents download-page <id> <pageId> [-o] [--force]` | Download one page (JPEG) |
140
150
  | `documents activities <id>` | Activity log |
141
151
  | `documents delete <id> [-y]` | Delete a document |
142
152
  | `documents tags <id>` | List attached tags |
@@ -148,7 +158,7 @@ Use `--signers '<json>'` for full control (verification methods, signing order/`
148
158
  | `documents verify <hash>` | Verify by signature hash |
149
159
  | `documents statuses` | List all document statuses |
150
160
  | `documents public <id>` | Public unauthenticated lookup |
151
- | `documents send-token <id> --recipient <r> [--channel]` | Send a verification token |
161
+ | `documents send-token <id> --email <email>` | Send a verification token with the published payload (`--recipient`/`--channel` remains for the live legacy form) |
152
162
  | `documents progress <id>` | Signing progress |
153
163
  | `documents wait <id> [--timeout] [--interval]` | Poll until ready |
154
164
 
@@ -162,7 +172,7 @@ assinafy signers create --name "Ana Lima" --email ana@example.com --cpf 123.456.
162
172
 
163
173
  ### `assignments`
164
174
 
165
- `create <documentId>` · `estimate-cost <documentId>` · `reset-expiration <documentId> <assignmentId>` · `resend <documentId> <assignmentId> <signerId>` · `estimate-resend-cost ...` · `whatsapp-notifications <documentId> <assignmentId>`
175
+ `list` · `create <documentId>` · `estimate-cost <documentId>` · `reset-expiration <documentId> <assignmentId>` · `resend <documentId> <assignmentId> <signerId>` · `estimate-resend-cost ...` · `whatsapp-notifications <documentId> <assignmentId>`
166
176
 
167
177
  ```bash
168
178
  assinafy assignments create doc_123 --signer-ids sig_1,sig_2 --message "Please sign"
@@ -170,7 +180,7 @@ assinafy assignments create doc_123 --signer-ids sig_1,sig_2 --message "Please s
170
180
 
171
181
  ### `templates`
172
182
 
173
- `list` · `get <id>` · `download-page <templateId> <pageId> [-o]`
183
+ `list` · `get <id>` · `download-page <templateId> <pageId> [-o] [--force]`
174
184
 
175
185
  ### `tags`
176
186
 
@@ -182,34 +192,59 @@ assinafy assignments create doc_123 --signer-ids sig_1,sig_2 --message "Please s
182
192
 
183
193
  ### `webhooks`
184
194
 
185
- `register --url --email [--events] [--inactive]` · `get` · `delete [-y]` · `inactivate` · `event-types` · `dispatches [filters]` · `retry <dispatchId>`
195
+ `register --url --email [--events] [--inactive]` · `get` · `inactivate` · `event-types` · `dispatches [filters]` · `retry <dispatchId>`
196
+
197
+ > The API has no delete-subscription endpoint — use `inactivate` to stop deliveries.
186
198
 
187
199
  ### `workspaces` (alias `accounts`)
188
200
 
189
- `create --name [...]` · `list` · `get <id>` · `update <id> [...]` · `delete <id> [-y]`
201
+ `create --name [...]` · `list` · `get <id>` · `theme <id>` · `stats <id>` · `logo download|upload|delete` · `update <id> [...]` · `delete <id> [-y]`
202
+
203
+ ### `users`
204
+
205
+ `self` · `stats [--granularity] [--month]` · `notification-preferences get|update`
190
206
 
191
207
  ### `signer` — signer-side flows (authenticated by a signer access code)
192
208
 
193
209
  `document <signerId>` · `documents <signerId>` · `download <signerId> <documentId> <artifact>` · `self` · `accept-terms` · `verify-email` · `confirm-data <documentId>` · `upload-signature` · `download-signature` · `assignment` · `sign <documentId> <assignmentId>` · `decline <documentId> <assignmentId>` · `sign-multiple` · `decline-multiple`
194
210
 
195
- Every signer command takes `--access-code <code>` (the one-time link emailed/WhatsApped to the signer).
211
+ Every signer command takes `--access-code <code>` (the one-time link emailed/WhatsApped to the signer); use `ASSINAFY_SIGNER_ACCESS_CODE` to keep it out of process arguments.
196
212
 
197
213
  ### `auth`
198
214
 
199
- `login <email>` · `social-login` · `change-password` · `request-password-reset <email>` · `reset-password` · `api-keys create|get|delete`
215
+ `login <email>` · `social-login` · `link-social-login` · `change-password` · `request-password-reset <email>` · `reset-password --reset-token` · `api-keys create|get|delete`
200
216
 
201
217
  > For server-to-server use, prefer an `X-Api-Key` (`assinafy login` / `--api-key`) and skip these.
202
- > `auth login`, `auth social-login`, `auth request-password-reset`, and `auth reset-password` can run without stored credentials. `auth change-password` and `auth api-keys ...` require a JWT token.
218
+ > `auth login`, `auth social-login`, `auth request-password-reset`, and `auth reset-password` can run without stored credentials. The other auth commands accept the API key or JWT documented by the API.
203
219
 
204
220
  ### Meta
205
221
 
206
222
  `login` · `logout` · `whoami` · `config set|get|list|use|remove|path` · `docs [--open]`
207
223
 
224
+ ## Node.js SDK
225
+
226
+ ```ts
227
+ import { AssinafyClient } from '@assinafy/cli/api';
228
+
229
+ const client = AssinafyClient.create(
230
+ process.env.ASSINAFY_API_KEY!,
231
+ process.env.ASSINAFY_ACCOUNT_ID!,
232
+ );
233
+
234
+ const { data, meta } = await client.documents.list({ status: 'pending_signature' });
235
+ const document = await client.documents.upload(
236
+ { filePath: './contract.pdf' },
237
+ { name: 'Service agreement', metadata: { external_id: 'order-123' } },
238
+ );
239
+ ```
240
+
241
+ CommonJS uses `require('@assinafy/cli/api')`. JSON `data` envelopes are unwrapped, paginated results are `{ data, meta }`, and downloads return `Buffer`; status-only responses retain their documented object. Full method signatures, payload types, error handling, binary formats, and contract caveats are in the [SDK reference](./docs/sdk-reference.md).
242
+
208
243
  ## Scripting examples
209
244
 
210
245
  ```bash
211
246
  # IDs of all pending documents
212
- assinafy documents list --status pending_signature --json | jq -r '.[].id'
247
+ assinafy documents list --status pending_signature --json | jq -r '.data[].id'
213
248
 
214
249
  # Upload and capture the new document ID
215
250
  DOC=$(assinafy documents upload contract.pdf --json | jq -r '.id')
@@ -230,15 +265,28 @@ npm test # vitest
230
265
  npm run build # bundle to dist/cli.cjs (self-contained)
231
266
  npm run verify:bundle # verify the bundled executable
232
267
  npm run docs # regenerate docs/ from CLI help output
268
+ npm run docs:api # regenerate the official HTTP payload reference
269
+ npm run verify:api-docs # verify all published API operations are documented
233
270
  npm run pack:release # create release archives in dist/release/
234
271
  ```
235
272
 
273
+ The opt-in `npm run test:sandbox` matrix requires the sandbox variables shown in
274
+ `.env.example`. It creates and cleans up disposable API resources and sends one
275
+ signing-token email to `ASSINAFY_TEST_EMAIL`; do not run it against production.
276
+
236
277
  ## Release
237
278
 
238
279
  GitHub CI runs typecheck, lint, tests, bundle verification, and package-content
239
- checks on Node 18, 20, and 22. Publishing a GitHub release packages the CLI into
240
- platform archives, uploads the assets, and publishes to npm when `NPM_TOKEN` is
241
- configured.
280
+ checks on Node 22, 24, and 26. Publishing a GitHub release packages the CLI into
281
+ platform archives, uploads the assets, and publishes the configured package registries.
282
+ See the [release runbook](./docs/releasing.md) for tag, mirror, trusted-publishing,
283
+ and recovery requirements.
284
+
285
+ ## Contract notes
286
+
287
+ The production OpenAPI currently publishes 89 operations, while sandbox deployments can lag individual routes. The SDK keeps two platform-compatible template routes that are not present in the OpenAPI paths and does not invent the certificate start/complete contracts mentioned only in prose. See [SDK contract boundaries](./docs/sdk-reference.md#contract-boundaries).
288
+
289
+ `WebhookVerifier` is experimental: Assinafy does not publish the signature header, algorithm, encoding, timestamp, or replay-protection scheme. Do not use it as a production trust boundary until the exact scheme is published or independently verified against real deliveries.
242
290
 
243
291
  ## License
244
292