@assinafy/cli 2.0.2 → 2.1.1

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 (48) hide show
  1. package/.env.example +54 -0
  2. package/CONTRIBUTING.md +29 -0
  3. package/README.en.md +559 -0
  4. package/README.md +314 -180
  5. package/SECURITY.md +10 -0
  6. package/THIRD_PARTY_NOTICES.md +3 -3
  7. package/dist/api.cjs +453 -74
  8. package/dist/api.cjs.map +1 -1
  9. package/dist/api.js +451 -74
  10. package/dist/api.js.map +1 -1
  11. package/dist/cli.cjs +1278 -228
  12. package/dist/types/api/client.d.ts +7 -0
  13. package/dist/types/api/client.d.ts.map +1 -1
  14. package/dist/types/api/errors.d.ts +42 -1
  15. package/dist/types/api/errors.d.ts.map +1 -1
  16. package/dist/types/api/index.d.ts +1 -0
  17. package/dist/types/api/index.d.ts.map +1 -1
  18. package/dist/types/api/resources/assignments.d.ts +3 -1
  19. package/dist/types/api/resources/assignments.d.ts.map +1 -1
  20. package/dist/types/api/resources/documents.d.ts +3 -3
  21. package/dist/types/api/resources/documents.d.ts.map +1 -1
  22. package/dist/types/api/resources/fields.d.ts.map +1 -1
  23. package/dist/types/api/resources/oauth.d.ts +20 -0
  24. package/dist/types/api/resources/oauth.d.ts.map +1 -0
  25. package/dist/types/api/resources/signer-documents.d.ts +9 -5
  26. package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
  27. package/dist/types/api/resources/signers.d.ts.map +1 -1
  28. package/dist/types/api/resources/webhooks.d.ts.map +1 -1
  29. package/dist/types/api/support/webhook-verifier.d.ts.map +1 -1
  30. package/dist/types/api/types.d.ts +146 -56
  31. package/dist/types/api/types.d.ts.map +1 -1
  32. package/dist/types/api/utils.d.ts +18 -0
  33. package/dist/types/api/utils.d.ts.map +1 -1
  34. package/docs/README.md +4 -2
  35. package/docs/api-operations.json +33 -1
  36. package/docs/api-reference.md +323 -79
  37. package/docs/assignments.md +3 -3
  38. package/docs/documents.md +8 -8
  39. package/docs/fields.md +4 -4
  40. package/docs/migration-v2.md +6 -2
  41. package/docs/oauth-guide.md +343 -0
  42. package/docs/oauth.md +162 -0
  43. package/docs/releasing.md +16 -6
  44. package/docs/sdk-reference.md +121 -24
  45. package/docs/signer.md +3 -2
  46. package/install.ps1 +9 -2
  47. package/install.sh +5 -5
  48. package/package.json +8 -5
package/docs/releasing.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Release runbook
2
2
 
3
- Releases originate from the source GitLab repository. Its push mirror must send
4
- branches and `v*` tags to GitHub; GitHub Release objects are created by
5
- `.github/workflows/release.yml`, not by the mirror.
3
+ This repository is hosted directly on GitHub. Push `main` and the matching
4
+ annotated `v*` tag to `assinafy/assinafy-cli`. GitHub Release objects are created
5
+ by `.github/workflows/release.yml` after the verification job succeeds.
6
6
 
7
7
  ## One-time repository setup
8
8
 
@@ -20,13 +20,23 @@ branches and `v*` tags to GitHub; GitHub Release objects are created by
20
20
 
21
21
  ## Publish
22
22
 
23
- 1. Run `npm ci`, `npm run typecheck`, `npm run lint`, `npm test`, and
24
- `npm run pack:release` on the release commit.
23
+ 1. Run `npm ci`, `npm run typecheck`, `npm run lint`, `npm test`,
24
+ `npm run docs:api`, `npm run verify:api-docs`, and `npm run pack:release` on
25
+ the release commit. Commit the generated API reference when the official
26
+ contract changes.
25
27
  2. Set `package.json` to the exact SemVer version and push the matching signed or
26
- annotated `vX.Y.Z` tag from GitLab.
28
+ annotated `vX.Y.Z` tag to GitHub.
27
29
  3. Confirm the GitHub workflow verifies that exact tag/commit, uploads its checked
28
30
  artifact, publishes both registries, and only then publishes the draft release.
29
31
 
32
+ The `publish` job depends on `verify`, which runs the automated SDK and CLI tests,
33
+ type and lint checks, current public production API contract check, generated-file
34
+ checks, packaged consumer checks, installer checks, and reproducible archive and
35
+ checksum validation. It then uploads one verified payload for publication. Tests
36
+ use controlled transports and local servers; verification requires no Assinafy
37
+ account credentials. Publishing retains its protected `release` environment and
38
+ registry authentication.
39
+
30
40
  Prerelease versions advance the `next` registry tag and are not marked as the
31
41
  latest GitHub release. Stable versions advance `latest`. The workflow compares
32
42
  SemVer precedence before moving either registry/GitHub pointer; an older backfill
@@ -32,7 +32,7 @@ const client = AssinafyClient.create(
32
32
  );
33
33
  ```
34
34
 
35
- For the sandbox, add `baseUrl: 'https://sandbox.assinafy.com.br/v1'`. Create an unauthenticated client only for public or signer-access-code endpoints:
35
+ For the sandbox, add `baseUrl: 'https://sandbox.assinafy.com.br/v1'`. Create an unauthenticated client for public, OAuth bootstrap, or signer-access-code endpoints:
36
36
 
37
37
  ```ts
38
38
  const publicClient = new AssinafyClient({ allowUnauthenticated: true });
@@ -44,19 +44,19 @@ const publicClient = new AssinafyClient({ allowUnauthenticated: true });
44
44
 
45
45
  | Field | Type | Behavior |
46
46
  | --- | --- | --- |
47
- | `apiKey` | `string` | Preferred credential; sent as `X-Api-Key`. |
48
- | `token` | `string` | JWT fallback; sent as `Authorization: Bearer`. `apiKey` wins when both are set. |
47
+ | `apiKey` | `string` | Direct owner credential; sent as `X-Api-Key`. |
48
+ | `token` | `string` | OAuth access token or user JWT; sent as `Authorization: Bearer`. `apiKey` wins when both are set. |
49
49
  | `accountId` | `string` | Default for account-scoped methods; most methods also accept an override. |
50
50
  | `baseUrl` | `string` | HTTPS URL; defaults to `https://api.assinafy.com.br/v1`. Redirects are rejected. |
51
- | `allowInsecureHttp` | `boolean` | Explicit opt-in for isolated local development only. |
51
+ | `allowInsecureHttp` | `boolean` | Opt-in for a plaintext `http://` base URL. Restricted to loopback hosts (`localhost`, `127.0.0.0/8`, `[::1]`); any other host is rejected even with this enabled, so the API key can never travel in cleartext. |
52
52
  | `timeout` | `number` | Request timeout in milliseconds; default `30_000`. |
53
53
  | `logger` | `Logger` | Optional `debug`/`info`/`warn`/`error` functions; otherwise no-op. |
54
- | `allowUnauthenticated` | `boolean` | Permit construction without `apiKey`/`token`; use only for public and signer-code flows. |
54
+ | `allowUnauthenticated` | `boolean` | Permit construction without `apiKey`/`token`; use only for public, OAuth bootstrap, and signer-code flows. |
55
55
  | `webhookSecret` | `string` | Used only by the experimental `webhookVerifier`; see [Webhook verification](#webhook-verification-experimental). |
56
56
 
57
57
  | API | Result |
58
58
  | --- | --- |
59
- | `new AssinafyClient(options: AssinafyClientOptions)` | Client with `documents`, `signers`, `workspaces`, `assignments`, `webhooks`, `templates`, `tags`, `auth`, `fields`, `users`, `signerDocuments`, and `webhookVerifier`. |
59
+ | `new AssinafyClient(options: AssinafyClientOptions)` | Client with `documents`, `signers`, `workspaces`, `assignments`, `webhooks`, `templates`, `tags`, `auth`, `oauth`, `fields`, `users`, `signerDocuments`, and `webhookVerifier`. |
60
60
  | `AssinafyClient.create(apiKey, accountId, options?)` | Convenience constructor. |
61
61
  | `AssinafyClient.fromConfig(config: ClientConfigInput)` | Accepts snake-case or camel-case configuration keys. |
62
62
  | `client.uploadAndRequestSignatures(options)` | Uploads a PDF, optionally waits for processing, creates/reuses signers, and creates a virtual assignment; returns `IUploadAndRequestSignaturesResult`. |
@@ -87,7 +87,24 @@ const publicClient = new AssinafyClient({ allowUnauthenticated: true });
87
87
  }
88
88
  ```
89
89
 
90
- It resolves to `{ document: IDocumentUploadResponse; assignment: IAssignment; signer_ids: string[] }`. A phone-only signer defaults to WhatsApp verification and notification unless those controls are supplied explicitly. The workflow is not transactional: if a later step fails, previously created documents/signers remain available for caller-directed cleanup.
90
+ It resolves to `{ document: IDocumentUploadResponse; assignment: IAssignment; signer_ids: string[] }`. A phone-only signer defaults to WhatsApp verification and notification unless those controls are supplied explicitly.
91
+
92
+ The workflow is not transactional. Once the upload succeeds, any later failure rejects with a `PartialWorkflowError` naming everything that already exists, so cleanup or a resume never needs to search the workspace for orphans. Nothing is deleted automatically. Signer IDs include reused records; never delete them as an automatic rollback. Validate local signer options before uploading, then inspect the document state before resuming a partially completed workflow.
93
+
94
+ ```ts
95
+ import { PartialWorkflowError } from '@assinafy/cli/api';
96
+
97
+ try {
98
+ await client.uploadAndRequestSignatures({ source, signers });
99
+ } catch (error) {
100
+ if (error instanceof PartialWorkflowError) {
101
+ console.error(error.message, error.cause); // original API/validation failure
102
+ console.error({ documentId: error.documentId, signerIds: error.signerIds });
103
+ // Inspect before resuming: these signers may be shared with existing documents.
104
+ }
105
+ throw error;
106
+ }
107
+ ```
91
108
 
92
109
  ## Documents (`client.documents`)
93
110
 
@@ -132,10 +149,14 @@ interface IDocumentUploadOptions {
132
149
  }
133
150
  ```
134
151
 
135
- Uploads must be non-empty PDFs up to 25 MiB. `DocumentArtifactName` is `original | certificated | certificate-page | pades | bundle`; `bundle` is ZIP and the other document artifacts are PDF. Prefer the published `sendToken(documentId, { email })` form. The string overload sends the live-compatible legacy `{ recipient, channel }` body for email or WhatsApp integrations that still require it.
152
+ Uploads must be non-empty PDFs up to 25 MiB. `DocumentArtifactName` is `original | certificated | certificate-page | pades | bundle`; `bundle` is ZIP and the other document artifacts are PDF. Prefer the published `sendToken(documentId, { email })` form. The current sandbox rejects that form with HTTP 400, so use the string overload there; it sends the live-compatible legacy `{ recipient, channel }` body for email or WhatsApp integrations that still require it.
153
+
154
+ Template document creation sends `{ signers, name?, message?, expires_at?, editor_fields?, tags? }`. Each signer is `{ role_id, id, verification_method?, notification_methods?, step? }`; each editor field is `{ field_id, value: string }`. Template cost estimation publishes `{ signers: Array<{ role_id, verification_method?, notification_methods? }> }`. The optional cost-signer `id` and `step` properties remain compatibility extensions for existing integrations.
136
155
 
137
156
  Document list params are `{ page?, per_page?, status?, method?, tags?, search?, sort? }`; search params omit `method`/`tags`. Supported sort values are `name`, `-name`, `updated_at`, and `-updated_at`.
138
157
 
158
+ `replaceTags` and `addTags` take tag IDs, as required by the published request bodies. Values are still forwarded unchanged for compatibility with deployments that accept tag names; new integrations should use IDs from `client.tags.list()`.
159
+
139
160
  Document responses expose typed `IDocumentArtifacts`, `IDocumentPage`, inline tags, assignment/signing state, decline state, and creation/update timestamps. `IPublicDocumentInfo` models the complete published public-document payload while retaining the older optional `page_count` and `created_by` fields.
140
161
 
141
162
  ## Assignments (`client.assignments`)
@@ -145,7 +166,7 @@ Document responses expose typed `IDocumentArtifacts`, `IDocumentPage`, inline ta
145
166
  | `list(params?, accountId?)` | [`GET /assignments?accountId=…`](./api-reference.md#list-assignments) | `PaginatedResult<IAssignment>` |
146
167
  | `create(documentId, payload)` | [`POST /documents/{documentId}/assignments`](./api-reference.md#create-assignment-request-signatures) | `IAssignment` |
147
168
  | `estimateCost(documentId, payload)` | [`POST /documents/{documentId}/assignments/estimate-cost`](./api-reference.md#estimate-assignment-cost) | `IEstimateCostResponse` |
148
- | `resetExpiration(documentId, assignmentId, expiresAt)` | [`PUT …/reset-expiration`](./api-reference.md#reset-assignment-expiration) | `IAssignment`; pass `null` to remove expiration |
169
+ | `resetExpiration(documentId, assignmentId, expiresAt)` | [`PUT …/reset-expiration`](./api-reference.md#reset-assignment-expiration) | `IAssignment`; the published API accepts an ISO 8601 timestamp, and deployments that support clearing also accept `null` |
149
170
  | `resendNotification(documentId, assignmentId, signerId)` | [`PUT …/signers/{signerId}/resend`](./api-reference.md#resend-signature-request) | `IResendEmailResponse` |
150
171
  | `estimateResendCost(documentId, assignmentId, signerId)` | [`POST …/estimate-resend-cost`](./api-reference.md#estimate-resend-cost) | `IResendCostEstimate` |
151
172
  | `listWhatsAppNotifications(documentId, assignmentId)` | [`GET …/whatsapp-notifications`](./api-reference.md#list-whatsapp-notifications) | `IWhatsAppNotification[]` |
@@ -171,7 +192,7 @@ Assignment payload:
171
192
  }
172
193
  ```
173
194
 
174
- `buildAssignmentPayload(payload, options?)` is exported for callers that need the same normalization. `create` requires at least one signer; `estimateCost` permits zero signers for `collect`. Assignment list params are pagination plus the live-verified `sort?: 'created_at' | '-created_at'`; the runtime endpoint requires the SDK's `accountId` query even though the published parameter table omits it. The sandbox ignored an assignment `search` query, so the SDK does not expose it.
195
+ `buildAssignmentPayload(payload, options?)` is exported for callers that need the same normalization. It resolves synchronously to the JSON assignment body above; no HTTP call occurs. Options are `{ allowSignersWithoutId?: boolean; allowEmptySigners?: boolean; skipDigitalCertificateStepValidation?: boolean }`, all false by default. The first two support cost estimation; the third bypasses signing-order and certificate-step checks for estimates. `allowEmptySigners` applies only to `collect`. `create` requires at least one signer, enforces complete contiguous signing steps from 1 when supplied, and requires each digital-certificate signer to be alone in its step. The estimate schema has no `step`, so `estimateCost` does not apply that create-only rule and permits zero signers for `collect`. Assignment list params are pagination plus the compatible `sort?: 'created_at' | '-created_at'`; the runtime endpoint requires the SDK's `accountId` query even though the published parameter table omits it. Assignment `search` is unsupported and rejected locally.
175
196
 
176
197
  ## Signers (`client.signers`)
177
198
 
@@ -184,18 +205,18 @@ Assignment payload:
184
205
  | `delete(signerId, accountId?)` | [`DELETE /accounts/{accountId}/signers/{signerId}`](./api-reference.md#delete-signer) | `IEmptyResult` (`unknown[]`) |
185
206
  | `findByEmail(email, accountId?)` | SDK helper over `list({ search: email })` | `ISigner | null` |
186
207
 
187
- Create payload: `{ full_name: string; email?; whatsapp_phone_number?; phone?; cpf?; metadata? }`. Update payload: `{ full_name?; email?; whatsapp_phone_number?; phone?; government_id?; cpf? }`. `phone` and update-time `cpf` are compatibility aliases. Creation is idempotent by exact case-insensitive email when email is supplied; full-name-only signers are valid. List params support published `search` and live-verified `sort?: 'full_name' | '-full_name'`; ignored sort fields are rejected locally.
208
+ Create payload: `{ full_name: string; email?; whatsapp_phone_number?; phone?; cpf?; metadata? }`. Update payload: `{ full_name?; email?; whatsapp_phone_number?; phone?; government_id?; cpf? }`. `phone`, create-time `cpf`/`metadata`, and update-time `cpf` are compatibility extensions; new integrations should use the published fields. Creation is idempotent by exact case-insensitive email when email is supplied; full-name-only signers are valid. List params support published `search` and compatible `sort?: 'full_name' | '-full_name'`; ignored sort fields are rejected locally.
188
209
 
189
210
  ## Signer-side flows (`client.signerDocuments`)
190
211
 
191
- These methods use the one-time `signer-access-code`, not the workspace API key.
212
+ These methods use the one-time `signer-access-code`, not the workspace API key, except for the artifact download that the API publishes as a public route.
192
213
 
193
214
  | SDK method | HTTP operation | Resolves to |
194
215
  | --- | --- | --- |
195
216
  | `getCurrent(signerId, accessCode)` | [`GET /signers/{signerId}/document`](./api-reference.md#get-signers-document) | `IDocumentDetailsResponse` |
196
217
  | `list(signerId, accessCode, params?)` | [`GET /signers/{signerId}/documents`](./api-reference.md#list-signers-documents) | `IDocumentListResponse` |
197
218
  | `search(signerId, search, accessCode)` | [`GET /signers/{signerId}/documents/search`](./api-reference.md#search-signers-documents) | `IDocumentListResponse` |
198
- | `download(signerId, documentId, artifact, accessCode)` | [`GET /signers/{signerId}/documents/{documentId}/download/{artifact}`](./api-reference.md#download-signers-document-artifact) | `Buffer` |
219
+ | `download(signerId, documentId, artifact, accessCode?)` | [`GET /signers/{signerId}/documents/{documentId}/download/{artifact}`](./api-reference.md#download-signers-document-artifact) | `Buffer` |
199
220
  | `signMultiple(documentIds, accessCode)` | [`PUT /signers/documents/sign-multiple`](./api-reference.md#sign-multiple-documents) | `unknown[]` |
200
221
  | `declineMultiple(documentIds, reason, accessCode)` | [`PUT /signers/documents/decline-multiple`](./api-reference.md#decline-multiple-documents) | `unknown[]` |
201
222
  | `self(accessCode)` | [`GET /signers/self`](./api-reference.md#get-current-signer) | `ISignerSelf` |
@@ -210,7 +231,7 @@ These methods use the one-time `signer-access-code`, not the workspace API key.
210
231
 
211
232
  `confirmData` accepts `{ full_name?, email?, government_id?, whatsapp_phone_number?, has_accepted_terms? }`. `uploadSignature` accepts a non-empty image `Buffer` plus `{ imageType?: 'signature' | 'initial'; contentType?: string; reuse?: boolean }`. Each signing entry is `{ itemId, fieldId, pageId, value }`.
212
233
 
213
- `download` first verifies the access code through `/signers/self` and confirms that it belongs to the requested signer. This SDK-side check mitigates a sandbox defect where the raw artifact route returned a document for an invalid access code; the upstream route must still be fixed before it can be treated as a secure trust boundary.
234
+ The artifact `download` route is public in the published API. If `accessCode` is supplied, the SDK first verifies it through `/signers/self` and confirms that it belongs to the requested signer before downloading.
214
235
 
215
236
  ## Workspaces (`client.workspaces`)
216
237
 
@@ -229,6 +250,29 @@ These methods use the one-time `signer-access-code`, not the workspace API key.
229
250
 
230
251
  Create/update payloads use `name` and `notification_sender_type?: 'User' | 'Account'`; legacy color fields remain accepted for compatibility. List/detail responses include `resource`, `id`, `name`, nullable colors, `notification_sender_type`, roles, delete permission, and `created_at`. `IAccountTheme` is `{ account_name; primary_color; secondary_color: string | null; logo: string | null }`. Logo options are `{ fileName?, contentType? }`. Statistics params are `{ granularity?: 'monthly' | 'daily'; month?: 'YYYY-MM' }`; `month` is required for daily data.
231
252
 
253
+ Both account and user statistics resolve to the complete published row:
254
+
255
+ ```ts
256
+ interface IDocumentStatsRow {
257
+ period: string; // YYYY-MM or YYYY-MM-DD
258
+ documents_uploaded: number;
259
+ documents_sent: number;
260
+ signature_requests: number;
261
+ signature_requests_notification_email: number;
262
+ signature_requests_notification_whatsapp: number;
263
+ signature_requests_notification_bypass: number;
264
+ signature_requests_verification_email: number;
265
+ signature_requests_verification_whatsapp: number;
266
+ signature_requests_verification_bypass: number;
267
+ signature_requests_verification_digital_certificate: number;
268
+ signature_requests_viewed: number;
269
+ signature_requests_completed: number;
270
+ documents_certified: number;
271
+ }
272
+ ```
273
+
274
+ Notification counters can overlap when a request uses multiple delivery channels. The four verification counters are mutually exclusive and add up to `signature_requests`.
275
+
232
276
  ## Users (`client.users`)
233
277
 
234
278
  | SDK method | HTTP operation | Resolves to |
@@ -238,7 +282,7 @@ Create/update payloads use `name` and `notification_sender_type?: 'User' | 'Acco
238
282
  | `getNotificationPreferences()` | [`GET /users/self/notification-preferences`](./api-reference.md#get-my-notification-preferences) | `INotificationPreferences` |
239
283
  | `updateNotificationPreferences(payload)` | [`PUT /users/self/notification-preferences`](./api-reference.md#update-my-notification-preferences) | `INotificationPreferences` |
240
284
 
241
- `IUserSelfResponse` accepts the published user object and the sandbox-observed `{ user, accounts }` envelope. Preference payloads are a non-empty partial mapping of the exported `NOTIFICATION_PREFERENCE_CODES` to booleans. The production OpenAPI publishes these routes; a lagging sandbox deployment may return route-level 404s for statistics/preferences.
285
+ `IUserSelfResponse` accepts the published user object and the compatible `{ user, accounts }` envelope. Preference payloads are a non-empty partial mapping of the exported `NOTIFICATION_PREFERENCE_CODES` to booleans. The production OpenAPI publishes these routes; a lagging sandbox deployment may return route-level 404s for statistics/preferences.
242
286
 
243
287
  ## Authentication (`client.auth`)
244
288
 
@@ -256,6 +300,22 @@ Create/update payloads use `name` and `notification_sender_type?: 'User' | 'Acco
256
300
 
257
301
  Login/social/reset bootstrap calls can use an unauthenticated client. The published authenticated user endpoints permit either a bearer JWT or `X-Api-Key`; use the credential type appropriate to the account and endpoint policy.
258
302
 
303
+ ## OAuth (`client.oauth`)
304
+
305
+ | SDK method | HTTP operation / behavior | Resolves to |
306
+ | --- | --- | --- |
307
+ | `metadata()` | [`GET /.well-known/oauth-protected-resource`](./api-reference.md#oauth-20-protected-resource-metadata), at the API origin outside `/v1` | `IOAuthProtectedResource` |
308
+ | `discovery(issuer)` | `GET {issuer}/.well-known/oauth-authorization-server`; requires HTTPS and matching issuer | `IOAuthAuthorizationServer` |
309
+ | `authorize({ clientId, redirectUri, scopes })` | Discover resource/server and generate a fresh S256 verifier, state, and optional OIDC nonce | `IOAuthAuthorizationRequest` |
310
+ | `exchangeCode(callbackUrl, request, clientSecret?)` | Validate callback URI/state/issuer and submit the authorization code | `IOAuthTokenResponse` |
311
+ | `token(payload)` | [`POST /oauth/token`](./api-reference.md#exchange-a-code-or-refresh-token-for-an-access-token), with code or refresh grant | `IOAuthTokenResponse` |
312
+ | `revoke(payload)` | [`POST /oauth/revoke`](./api-reference.md#revoke-a-token) | `void` |
313
+ | `userinfo()` | `GET /oauth/userinfo`, using the current OAuth bearer token with `openid` | `IOAuthUserInfo` |
314
+
315
+ All request types, full payload examples and response shapes are in the [OAuth guide](./oauth-guide.md). `IOAuthTokenPayload` is a discriminated union: code exchange requires `code`, `redirect_uri`, and `code_verifier`; refresh requires `refresh_token`; both require `client_id` and optionally accept `client_secret` and `resource`. `IOAuthRevokePayload` requires `token` and `client_id`, with optional `client_secret` and `token_type_hint`.
316
+
317
+ Metadata, discovery, token, and revoke calls remove owner headers. UserInfo uses the configured credential; construct the client with `token` for OAuth. OAuth bodies have no Assinafy envelope. The SDK returns credentials to the caller and does not persist, retry, or automatically refresh them. Store authorization requests in a single-use session; serialize refreshes across workers and atomically save the rotated result. Use an OIDC library to validate ID tokens before relying on identity claims.
318
+
259
319
  ## Fields (`client.fields`)
260
320
 
261
321
  | SDK method | HTTP operation | Resolves to |
@@ -269,7 +329,7 @@ Login/social/reset bootstrap calls can use an unauthenticated client. The publis
269
329
  | `validateMultiple(entries, options?)` | [`POST …/fields/validate-multiple`](./api-reference.md#validate-multiple-field-values) | `IFieldValidationResult[]` |
270
330
  | `listTypes()` | [`GET /field-types`](./api-reference.md#list-field-types) | `IFieldType[]` |
271
331
 
272
- Create payload: `{ type: string; name: string; regex?; is_required?; is_active? }`. Update makes each field optional and allows `regex: null`. List params are `{ include_inactive?, include_standard? }`. Validation options are `{ signerAccessCode?, accountId? }`; multiple entries are `{ field_id, value }[]`. When a signer code is supplied, the SDK removes any configured owner API-key/bearer headers from that request.
332
+ Published create payload: `{ type: string; name: string; regex?; is_required? }`. Published update payload: `{ name?; regex?: string | null; is_active? }`. The SDK retains create-time `is_active` and update-time `type`/`is_required` as compatibility extensions. List params are `{ include_inactive?, include_standard? }`. Validation options are `{ signerAccessCode?, accountId? }`; multiple entries are `{ field_id, value }[]`. When a signer code is supplied, the SDK removes any configured owner API-key/bearer headers from that request.
273
333
 
274
334
  ## Tags (`client.tags`)
275
335
 
@@ -288,9 +348,44 @@ Create payload: `{ type: string; name: string; regex?; is_required?; is_active?
288
348
  | `get(templateId, accountId?)` | `GET /accounts/{accountId}/templates/{templateId}` | `ITemplateDetailsResponse` |
289
349
  | `downloadPage(templateId, pageId, accountId?)` | `GET /accounts/{accountId}/templates/{templateId}/pages/{pageId}/download` | JPEG `Buffer` |
290
350
 
291
- The last two compatibility routes are supported by the platform/official PHP SDK but are absent from the published OpenAPI document, so they have no generated payload section.
351
+ The last two routes are retained for platform compatibility although they are not in the published OpenAPI. Neither sends a request body. `get` unwraps the normal Assinafy envelope and returns:
292
352
 
293
- Template list params support pagination, published `search`, and live-verified `sort?: 'name' | '-name'`; ignored sort fields are rejected locally. `ITemplatePage` contains document page dimensions/URL plus typed `ITemplateField[]` entries (`id`, `field_id`, `role_id`, `label`, `display_settings`, and timestamps). Template document creation accepts `editor_fields?: Array<{ field_id: string; value: unknown }>`.
353
+ ```ts
354
+ interface ITemplateDetailsResponse {
355
+ resource?: string;
356
+ id: string;
357
+ name: string;
358
+ document_name?: string | null;
359
+ message?: string | null;
360
+ status: string;
361
+ account_id?: string;
362
+ pages?: Array<{
363
+ id: string;
364
+ number: number;
365
+ height: number;
366
+ width: number;
367
+ download_url: string;
368
+ fields: Array<{
369
+ id: string;
370
+ field_id: string;
371
+ role_id: string;
372
+ label: string;
373
+ display_settings: IDisplaySettings | unknown[] | null;
374
+ created_at: string;
375
+ updated_at: string;
376
+ }>;
377
+ }>;
378
+ roles?: ITemplateRole[];
379
+ tags?: IInlineTag[];
380
+ default_document_tags?: IInlineTag[];
381
+ created_at: string;
382
+ updated_at?: string;
383
+ }
384
+ ```
385
+
386
+ `downloadPage` returns the raw JPEG response as a Node.js `Buffer`; it does not unwrap JSON.
387
+
388
+ Template list params support pagination, published `search`, and compatible `sort?: 'name' | '-name'`; ignored sort fields are rejected locally. `ITemplatePage` contains document page dimensions/URL plus typed `ITemplateField[]` entries (`id`, `field_id`, `role_id`, `label`, `display_settings`, and timestamps). Template document creation accepts `editor_fields?: Array<{ field_id: string; value: string }>`.
294
389
 
295
390
  ## Webhooks (`client.webhooks`)
296
391
 
@@ -303,16 +398,18 @@ Template list params support pagination, published `search`, and live-verified `
303
398
  | `listDispatches(params?, accountId?)` | [`GET /accounts/{accountId}/webhooks`](./api-reference.md#list-webhook-deliveries) | `PaginatedResult<IWebhookDispatch>` |
304
399
  | `retryDispatch(dispatchId, accountId?)` | [`POST /accounts/{accountId}/webhooks/{dispatchId}/retry`](./api-reference.md#retry-webhook-delivery) | `IWebhookDispatch` |
305
400
 
306
- Registration payload: `{ url: string; email: string; events?: string[]; is_active?: boolean }`. When `events` is omitted the SDK uses `document_ready`, `document_prepared`, `signer_signed_document`, `signer_rejected_document`, and `document_processing_failed`; pass `[]` deliberately for none. Dispatch filters extend pagination with `{ event?, delivered?, from?, to?, sort?: 'created_at' | '-created_at' }`; sort is a live-verified extension. The sandbox ignored dispatch `search`, so it is rejected locally. The API does not expose a delete-subscription operation; use `inactivate`.
401
+ Registration payload: `{ url: string; email: string; events?: string[]; is_active?: boolean }`. When `events` is omitted the SDK uses `document_ready`, `document_prepared`, `signer_signed_document`, `signer_rejected_document`, and `document_processing_failed`; pass `[]` deliberately for none. Dispatch filters extend pagination with `{ event?, delivered?, from?, to?, sort?: 'created_at' | '-created_at' }`; sort is a compatibility extension. Dispatch `search` is unsupported and rejected locally. The API does not expose a delete-subscription operation; use `inactivate`.
402
+
403
+ Decline operations require a non-empty reason of at most 2,000 Unicode characters. `signers.findByEmail` follows pagination metadata until an exact case-insensitive email match is found or the search is exhausted.
307
404
 
308
405
  ## Responses, pagination, errors, and binary data
309
406
 
310
407
  - JSON responses with `data` are unwrapped from the API envelope; direct status bodies remain `IStatusResponse`. Paginated calls resolve to `{ data: T[]; meta?: { current_page?, last_page?, per_page?, total? } }`; metadata comes from `X-Pagination-*` headers.
311
408
  - Binary methods resolve to Node.js `Buffer`; the SDK is not a browser package. It never writes downloaded data to disk.
312
- - `ValidationError` means local input validation failed before a request. `ApiError` exposes `statusCode` and `responseData`. `NetworkError` covers timeout/DNS/transport failures. All extend `AssinafyError`, which exposes `context` and preserves `cause` where available.
409
+ - `ValidationError` means local input validation failed before a request. `ApiError` exposes `statusCode`, `responseData`, `wwwAuthenticate` and `retryAfter`; binary JSON error bodies are decoded before normalization. OAuth responses are flat JSON, and OAuth revocation resolves to `undefined`. `NetworkError` covers timeout/DNS/transport failures. `PartialWorkflowError` reports `documents upload --wait` or a multi-step helper that failed after creating resources and exposes `documentId` and `signerIds`. All extend `AssinafyError`, which exposes `context` and preserves `cause` where available.
313
410
  - `normalizeBaseUrl(url)` is exported and removes one trailing slash.
314
411
 
315
- Exported error constructors/helpers are `new AssinafyError(message, context?, { cause? }?)`, `new ApiError(message, statusCode, responseData?, { cause? }?)`, `ApiError.fromResponse(statusCode, responseData)`, `new ValidationError(message?, errors?)`, and `new NetworkError(message, { cause? }?)`. Resource classes and all named request/response types are also exported for dependency injection and type annotations; normal applications should obtain resource instances from `AssinafyClient`.
412
+ Exported error constructors/helpers are `new AssinafyError(message, context?, { cause? }?)`, `new ApiError(message, statusCode, responseData?, { cause?, wwwAuthenticate?, retryAfter? }?)`, `ApiError.fromResponse(statusCode, responseData, headers?)`, `new ValidationError(message?, errors?)`, `new NetworkError(message, { cause? }?)`, and `new PartialWorkflowError(message, { documentId?, signerIds? }, { cause? }?)`. Resource classes and all named request/response types are also exported for dependency injection and type annotations; normal applications should obtain resource instances from `AssinafyClient`.
316
413
 
317
414
  ```ts
318
415
  try {
@@ -338,7 +435,7 @@ Assinafy's published API does **not** define a signature header, algorithm, dige
338
435
 
339
436
  ## Contract boundaries
340
437
 
341
- - Production OpenAPI currently publishes 89 operations. Some sandbox deployments lag it; account/user statistics and user notification-preference routes may return route-level 404s even though production documentation includes them.
438
+ - Production OpenAPI currently publishes 93 operations. Some sandbox deployments lag it; account/user statistics and user notification-preference routes may return route-level 404s even though production documentation includes them.
342
439
  - The API's digital-certificate description mentions certificate start/complete routes that are not defined as OpenAPI paths. The SDK does not invent undocumented request/response contracts for them.
343
- - The SDK retains the two template compatibility routes above and both published/legacy public `sendToken` payloads until the upstream contract converges.
344
- - The sandbox raw signer-artifact route ignored an invalid access code during sandbox verification. The SDK adds the identity preflight described above, but direct HTTP consumers remain exposed until Assinafy fixes the route.
440
+ - The SDK retains the two template compatibility routes above and both published/legacy public `sendToken` payloads for compatible deployments.
441
+ - Signer artifact downloads are public in the published contract. Supplying a signer access code opts into an SDK identity preflight; it does not change the server route into a private endpoint.
package/docs/signer.md CHANGED
@@ -5,7 +5,7 @@
5
5
  ```text
6
6
  Usage: assinafy signer [options] [command]
7
7
 
8
- Signer-side flows authenticated by a signer access code
8
+ Signer-side flows and public artifact downloads
9
9
 
10
10
  Options:
11
11
  -h, --help display help for command
@@ -93,7 +93,8 @@ Arguments:
93
93
  bundle
94
94
 
95
95
  Options:
96
- --access-code <code> Signer access code (env: ASSINAFY_SIGNER_ACCESS_CODE)
96
+ --access-code <code> Optional signer identity preflight code (env:
97
+ ASSINAFY_SIGNER_ACCESS_CODE)
97
98
  -o, --output <path> Output file path
98
99
  --force Overwrite the output file if it already exists
99
100
  -h, --help display help for command
package/install.ps1 CHANGED
@@ -58,7 +58,7 @@ function Test-ArchiveLayout([string]$Archive, [string]$Target) {
58
58
  Fail "Release archive contained an unsafe path"
59
59
  }
60
60
  $allowed = $expectedExecutables -ccontains $entry -or
61
- $entry -cin @("VERSION", "README.md", "LICENSE", "THIRD_PARTY_NOTICES.md") -or
61
+ $entry -cin @("VERSION", "README.md", "README.en.md", "CONTRIBUTING.md", "SECURITY.md", ".env.example", "LICENSE", "THIRD_PARTY_NOTICES.md") -or
62
62
  $entry -cmatch '^docs/[^/]+\.md$' -or $entry -ceq "docs/api-operations.json"
63
63
  if (-not $allowed) {
64
64
  Fail "Release archive contained an unexpected path: $entry"
@@ -205,13 +205,20 @@ try {
205
205
  Move-Item $cmdReplacement $exe -Force
206
206
  $cmdReplacement = $null
207
207
 
208
- foreach ($file in @("README.md", "LICENSE", "THIRD_PARTY_NOTICES.md", "VERSION")) {
208
+ foreach ($file in @("README.md", "README.en.md", "CONTRIBUTING.md", "SECURITY.md", ".env.example", "LICENSE", "THIRD_PARTY_NOTICES.md", "VERSION")) {
209
209
  $source = Join-Path $extractDir $file
210
210
  if (Test-Path $source) {
211
211
  Copy-Item $source (Join-Path $installDir $file) -Force
212
212
  }
213
213
  }
214
214
 
215
+ $docsSource = Join-Path $extractDir "docs"
216
+ if (Test-Path $docsSource) {
217
+ $docsDestination = Join-Path $installDir "docs"
218
+ New-Item -ItemType Directory -Path $docsDestination -Force | Out-Null
219
+ Copy-Item (Join-Path $docsSource "*") $docsDestination -Recurse -Force
220
+ }
221
+
215
222
  if ($env:ASSINAFY_NO_PATH_UPDATE -ne "1") {
216
223
  Add-UserPath $binDir
217
224
  }
package/install.sh CHANGED
@@ -83,10 +83,10 @@ main() {
83
83
  mv -f "$assinafy_replacement" "$executable"
84
84
  assinafy_replacement=""
85
85
 
86
- if [ -f "$extract_dir/README.md" ]; then cp "$extract_dir/README.md" "$install_dir/README.md"; fi
87
- if [ -f "$extract_dir/LICENSE" ]; then cp "$extract_dir/LICENSE" "$install_dir/LICENSE"; fi
88
- if [ -f "$extract_dir/THIRD_PARTY_NOTICES.md" ]; then cp "$extract_dir/THIRD_PARTY_NOTICES.md" "$install_dir/THIRD_PARTY_NOTICES.md"; fi
89
- if [ -f "$extract_dir/VERSION" ]; then cp "$extract_dir/VERSION" "$install_dir/VERSION"; fi
86
+ for file in README.md README.en.md CONTRIBUTING.md SECURITY.md .env.example LICENSE THIRD_PARTY_NOTICES.md VERSION; do
87
+ if [ -f "$extract_dir/$file" ]; then cp "$extract_dir/$file" "$install_dir/$file"; fi
88
+ done
89
+ if [ -d "$extract_dir/docs" ]; then cp -R "$extract_dir/docs/." "$install_dir/docs"; fi
90
90
 
91
91
  ensure_path "$bin_dir"
92
92
  success "Installed $installed_version to $executable"
@@ -265,7 +265,7 @@ validate_archive() {
265
265
  fi
266
266
  ;;
267
267
  VERSION) version_count=$((version_count + 1)) ;;
268
- README.md | LICENSE | THIRD_PARTY_NOTICES.md | docs/*.md | docs/api-operations.json) ;;
268
+ README.md | README.en.md | CONTRIBUTING.md | SECURITY.md | .env.example | LICENSE | THIRD_PARTY_NOTICES.md | docs/*.md | docs/api-operations.json) ;;
269
269
  *) fail "Release archive contained an unexpected path: $entry" ;;
270
270
  esac
271
271
  done < <(tar -tzf "$archive")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/cli",
3
- "version": "2.0.2",
3
+ "version": "2.1.1",
4
4
  "description": "The official command-line interface for the Assinafy digital-signature API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,6 +29,10 @@
29
29
  "install.sh",
30
30
  "install.ps1",
31
31
  "README.md",
32
+ "README.en.md",
33
+ "CONTRIBUTING.md",
34
+ "SECURITY.md",
35
+ ".env.example",
32
36
  "LICENSE",
33
37
  "THIRD_PARTY_NOTICES.md"
34
38
  ],
@@ -59,7 +63,6 @@
59
63
  "lint": "biome check .",
60
64
  "lint:fix": "biome check --write .",
61
65
  "test": "vitest run",
62
- "test:sandbox": "npm run build && node scripts/sandbox-smoke.mjs",
63
66
  "test:watch": "vitest",
64
67
  "docs": "npm run build && node scripts/gen-docs.mjs",
65
68
  "docs:api": "node scripts/gen-api-reference.mjs",
@@ -71,11 +74,11 @@
71
74
  "prepublishOnly": "npm run typecheck && npm run lint && npm run test && npm run build && npm run verify:bundle"
72
75
  },
73
76
  "dependencies": {
74
- "@types/node": "^26.2.0",
75
- "axios": "^1.7.9"
77
+ "@types/node": "^22.20.1",
78
+ "axios": "^1.20.0"
76
79
  },
77
80
  "devDependencies": {
78
- "@biomejs/biome": "^2.5.9",
81
+ "@biomejs/biome": "^2.5.10",
79
82
  "@clack/prompts": "^1.7.0",
80
83
  "@commander-js/extra-typings": "^15.0.0",
81
84
  "commander": "^15.0.0",