@assinafy/cli 1.0.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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 Assinafy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # @assinafy/cli
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.
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.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js 18+ (for the built-in `FormData` / `Blob` APIs used by uploads)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install -g @assinafy/cli
15
+ # then
16
+ assinafy --help
17
+ ```
18
+
19
+ Install from the latest GitHub release:
20
+
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
29
+ ```
30
+
31
+ Windows PowerShell:
32
+
33
+ ```powershell
34
+ iwr https://raw.githubusercontent.com/assinafy/assinafy-cli/main/install.ps1 -UseB | iex
35
+ ```
36
+
37
+ The installers place the CLI in `~/.assinafy/bin` by default. Set `ASSINAFY_INSTALL`
38
+ to choose another install directory.
39
+
40
+ Or run without installing:
41
+
42
+ ```bash
43
+ npx @assinafy/cli whoami
44
+ ```
45
+
46
+ ## Quick start
47
+
48
+ ```bash
49
+ # 1. Store your credentials (interactive)
50
+ assinafy login
51
+
52
+ # 2. Verify them
53
+ assinafy whoami
54
+
55
+ # 3. Upload a PDF and request signatures in one step
56
+ assinafy send contract.pdf \
57
+ --signer "Ana Lima <ana@example.com>" \
58
+ --signer "Bruno Souza <+5548999990000>" \
59
+ --message "Please sign this contract"
60
+ ```
61
+
62
+ ## Authentication & configuration
63
+
64
+ The CLI resolves every credential with this precedence: **CLI flag → environment variable → config file**.
65
+
66
+ ### Credentials
67
+
68
+ | What | Flag | Environment variable |
69
+ | --- | --- | --- |
70
+ | API key (preferred, sent as `X-Api-Key`) | `--api-key` | `ASSINAFY_API_KEY` |
71
+ | Legacy JWT token (sent as `Bearer`) | `--token` | `ASSINAFY_TOKEN` |
72
+ | Default account / workspace ID | `--account-id` | `ASSINAFY_ACCOUNT_ID` |
73
+ | API base URL | `--base-url` | `ASSINAFY_BASE_URL` |
74
+ | Webhook signing secret | _(config only)_ | `ASSINAFY_WEBHOOK_SECRET` |
75
+ | Config profile | `-p, --profile` | `ASSINAFY_PROFILE` |
76
+
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.
78
+
79
+ ### Config file & profiles
80
+
81
+ `assinafy login` / `assinafy config set` write to a JSON config file with owner-only (`0600`) permissions:
82
+
83
+ - Linux / macOS: `~/.config/assinafy/config.json` (honours `XDG_CONFIG_HOME`)
84
+ - Windows: `%APPDATA%\assinafy\config.json`
85
+ - Override anywhere with `ASSINAFY_CONFIG_DIR`
86
+
87
+ Profiles let you keep separate credentials (e.g. production vs. sandbox):
88
+
89
+ ```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"
94
+
95
+ assinafy config use sandbox # make it the default
96
+ assinafy config list # list profiles
97
+ assinafy config get # show the effective config (secrets masked)
98
+ ```
99
+
100
+ ### Sandbox
101
+
102
+ Assinafy runs a **separate sandbox** at `https://sandbox.assinafy.com.br/v1`. A sandbox key only works against that base URL. Target it per-command with `--base-url`, via `ASSINAFY_BASE_URL`, or by storing it in a profile.
103
+
104
+ ## Output
105
+
106
+ By default commands print friendly tables / key-value blocks to **stdout**, with spinners and status lines on **stderr**. For scripting:
107
+
108
+ - `--json` — emit structured JSON on stdout (errors become JSON on stderr). Always machine-readable.
109
+ - `-q, --quiet` — suppress spinners and status messages.
110
+
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'`).
112
+
113
+ ## Command reference
114
+
115
+ Run `assinafy <command> --help` for full flag details on any command. Detailed per-resource docs live in [`docs/`](./docs).
116
+
117
+ ### `send` — upload + request signatures (headline workflow)
118
+
119
+ ```bash
120
+ assinafy send contract.pdf \
121
+ --signer "Ana <ana@example.com>" \
122
+ --signer "Bruno <+5548999990000>" \
123
+ --message "Please sign" \
124
+ --expires-at 2026-12-31T23:59:59Z \
125
+ --copy-receivers cc@example.com
126
+ ```
127
+
128
+ Use `--signers '<json>'` for full control (verification methods, signing order/`step`), and `--no-wait` to skip waiting for processing.
129
+
130
+ ### `documents`
131
+
132
+ | Command | Description |
133
+ | --- | --- |
134
+ | `documents upload <file> [--name] [--metadata] [--wait]` | Upload a PDF |
135
+ | `documents list [--status] [--method] [--tags] [--page] [--per-page] [--search] [--sort]` | List documents |
136
+ | `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) |
140
+ | `documents activities <id>` | Activity log |
141
+ | `documents delete <id> [-y]` | Delete a document |
142
+ | `documents tags <id>` | List attached tags |
143
+ | `documents tags-set <id> [names...]` | Replace the tag set |
144
+ | `documents tags-add <id> <names...>` | Attach tags by name |
145
+ | `documents tags-remove <id> <tagId>` | Detach one tag |
146
+ | `documents create-from-template <templateId> --signers <json> [...]` | Create from a template |
147
+ | `documents estimate-template-cost <templateId> --signers <json>` | Estimate template cost |
148
+ | `documents verify <hash>` | Verify by signature hash |
149
+ | `documents statuses` | List all document statuses |
150
+ | `documents public <id>` | Public unauthenticated lookup |
151
+ | `documents send-token <id> --recipient <r> [--channel]` | Send a verification token |
152
+ | `documents progress <id>` | Signing progress |
153
+ | `documents wait <id> [--timeout] [--interval]` | Poll until ready |
154
+
155
+ ### `signers`
156
+
157
+ `create` · `list` · `get <id>` · `update <id>` · `delete <id>` · `find-by-email <email>`
158
+
159
+ ```bash
160
+ assinafy signers create --name "Ana Lima" --email ana@example.com --cpf 123.456.789-00
161
+ ```
162
+
163
+ ### `assignments`
164
+
165
+ `create <documentId>` · `estimate-cost <documentId>` · `reset-expiration <documentId> <assignmentId>` · `resend <documentId> <assignmentId> <signerId>` · `estimate-resend-cost ...` · `whatsapp-notifications <documentId> <assignmentId>`
166
+
167
+ ```bash
168
+ assinafy assignments create doc_123 --signer-ids sig_1,sig_2 --message "Please sign"
169
+ ```
170
+
171
+ ### `templates`
172
+
173
+ `list` · `get <id>` · `download-page <templateId> <pageId> [-o]`
174
+
175
+ ### `tags`
176
+
177
+ `list [--search]` · `create --name [--color]` · `update <id> [--name] [--color] [--clear-color]` · `delete <id> [--force] [-y]`
178
+
179
+ ### `fields`
180
+
181
+ `create --type --name [...]` · `list [--include-inactive] [--include-standard]` · `get <id>` · `update <id> [...]` · `delete <id> [-y]` · `validate <id> <value> [--signer-access-code]` · `validate-multiple --entries <json>` · `types`
182
+
183
+ ### `webhooks`
184
+
185
+ `register --url --email [--events] [--inactive]` · `get` · `delete [-y]` · `inactivate` · `event-types` · `dispatches [filters]` · `retry <dispatchId>`
186
+
187
+ ### `workspaces` (alias `accounts`)
188
+
189
+ `create --name [...]` · `list` · `get <id>` · `update <id> [...]` · `delete <id> [-y]`
190
+
191
+ ### `signer` — signer-side flows (authenticated by a signer access code)
192
+
193
+ `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
+
195
+ Every signer command takes `--access-code <code>` (the one-time link emailed/WhatsApped to the signer).
196
+
197
+ ### `auth`
198
+
199
+ `login <email>` · `social-login` · `change-password` · `request-password-reset <email>` · `reset-password` · `api-keys create|get|delete`
200
+
201
+ > 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.
203
+
204
+ ### Meta
205
+
206
+ `login` · `logout` · `whoami` · `config set|get|list|use|remove|path` · `docs [--open]`
207
+
208
+ ## Scripting examples
209
+
210
+ ```bash
211
+ # IDs of all pending documents
212
+ assinafy documents list --status pending_signature --json | jq -r '.[].id'
213
+
214
+ # Upload and capture the new document ID
215
+ DOC=$(assinafy documents upload contract.pdf --json | jq -r '.id')
216
+
217
+ # Bulk-tag every template-created document
218
+ assinafy documents tags-add "$DOC" legal q4-2026
219
+ ```
220
+
221
+ ## Development
222
+
223
+ ```bash
224
+ npm install # install dependencies
225
+ npm run dev -- --help # run from source with tsx
226
+ npm run dev:watch # run from source and restart on changes
227
+ npm run typecheck # tsc --noEmit
228
+ npm run lint # biome
229
+ npm test # vitest
230
+ npm run build # bundle to dist/cli.cjs (self-contained)
231
+ npm run verify:bundle # verify the bundled executable
232
+ npm run docs # regenerate docs/ from CLI help output
233
+ npm run pack:release # create release archives in dist/release/
234
+ ```
235
+
236
+ ## Release
237
+
238
+ 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.
242
+
243
+ ## License
244
+
245
+ MIT © Assinafy