@assinafy/cli 2.4.0 → 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 +14 -11
- package/README.md +11 -2
- package/dist/api.cjs +61 -26
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +58 -25
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +438 -391
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/authentication.d.ts +1 -1
- package/dist/types/api/resources/authentication.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/dist/types/api/resources/signers.d.ts.map +1 -1
- package/dist/types/api/resources/workspaces.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts +4 -0
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/api-operations.json +1 -1
- package/docs/api-reference.md +1 -5
- package/docs/assignments.md +10 -7
- package/docs/auth.md +1 -1
- package/docs/documents.md +5 -3
- package/docs/fields.md +2 -2
- 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 +7 -7
- package/docs/signers.md +1 -1
- package/docs/users.md +2 -1
- package/docs/workspaces.md +6 -3
- 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`
|
|
@@ -571,7 +574,7 @@ The [release runbook](./docs/releasing.md) covers tags, trusted publishing, and
|
|
|
571
574
|
|
|
572
575
|
- The production OpenAPI publishes 93 operations and the SDK implements all of them. Sandbox deployments can lag individual routes — account/user statistics and user notification preferences may return route-level 404s there despite being documented in production.
|
|
573
576
|
- The SDK keeps two platform-compatible template routes (`GET /accounts/{id}/templates/{id}` and its page download) that are absent from the published OpenAPI paths.
|
|
574
|
-
-
|
|
577
|
+
- Certificate start/complete are deployed production extensions of the public signing frontend, exposed as `signerDocuments.startCertificate(accessCode)` and `signerDocuments.completeCertificate(accessCode, token)`. Start posts `{ "signer-access-code": code }` and returns `{ token }`; complete posts `{ "signer-access-code": code, token }` and returns `{ signerName }`. Both also carry the access code in the query string and strip owner credentials. They supplement, but are not part of, the 93 OpenAPI operations.
|
|
575
578
|
- Both the published and legacy `send-token` payloads are supported for compatible deployments.
|
|
576
579
|
- `WebhookVerifier` is **experimental**. Assinafy does not publish the signature header, algorithm, encoding, timestamp, or replay-protection scheme, so it is not a production trust boundary until the exact scheme is published or independently verified against real deliveries.
|
|
577
580
|
|
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
|
@@ -51,7 +51,9 @@ __export(api_exports, {
|
|
|
51
51
|
WebhookVerifier: () => WebhookVerifier,
|
|
52
52
|
WorkspaceResource: () => WorkspaceResource,
|
|
53
53
|
buildAssignmentPayload: () => buildAssignmentPayload,
|
|
54
|
-
normalizeBaseUrl: () => normalizeBaseUrl
|
|
54
|
+
normalizeBaseUrl: () => normalizeBaseUrl,
|
|
55
|
+
requireDocumentArtifactName: () => requireDocumentArtifactName,
|
|
56
|
+
requireSignerImageType: () => requireSignerImageType
|
|
55
57
|
});
|
|
56
58
|
module.exports = __toCommonJS(api_exports);
|
|
57
59
|
|
|
@@ -188,6 +190,19 @@ function cleanParams(params) {
|
|
|
188
190
|
}
|
|
189
191
|
return out;
|
|
190
192
|
}
|
|
193
|
+
function stripEmpty(body) {
|
|
194
|
+
const out = {};
|
|
195
|
+
for (const [key, value] of Object.entries(body)) {
|
|
196
|
+
if (value !== void 0 && value !== null) {
|
|
197
|
+
out[key] = value;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
function appendFilePart(form, data, contentType, fileName) {
|
|
203
|
+
const view = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
204
|
+
form.append("file", new Blob([view], { type: contentType }), fileName);
|
|
205
|
+
}
|
|
191
206
|
function publicRequestConfig(config = {}) {
|
|
192
207
|
return {
|
|
193
208
|
...config,
|
|
@@ -428,7 +443,7 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
428
443
|
if (!options.skipDigitalCertificateStepValidation) {
|
|
429
444
|
validateSigningSteps(normalisedSigners);
|
|
430
445
|
}
|
|
431
|
-
return
|
|
446
|
+
return stripEmpty({
|
|
432
447
|
method: payload.method ?? "virtual",
|
|
433
448
|
signers: normalisedSigners,
|
|
434
449
|
message: payload.message,
|
|
@@ -459,7 +474,7 @@ function normaliseSignerRef(ref, options) {
|
|
|
459
474
|
const input = ref;
|
|
460
475
|
const id = input.id ?? input.signer_id;
|
|
461
476
|
validateSignerOptions(input);
|
|
462
|
-
const normalised =
|
|
477
|
+
const normalised = stripEmpty({
|
|
463
478
|
id,
|
|
464
479
|
verification_method: input.verification_method,
|
|
465
480
|
notification_methods: input.notification_methods,
|
|
@@ -658,6 +673,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
658
673
|
var import_node_fs = require("fs");
|
|
659
674
|
var import_node_path = __toESM(require("path"), 1);
|
|
660
675
|
var MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
|
|
676
|
+
var DOCUMENT_SORTS = ["name", "-name", "updated_at", "-updated_at"];
|
|
661
677
|
var READY_STATUSES = /* @__PURE__ */ new Set([
|
|
662
678
|
"metadata_ready",
|
|
663
679
|
"pending_signature",
|
|
@@ -705,7 +721,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
705
721
|
*/
|
|
706
722
|
async list(params = {}, accountId) {
|
|
707
723
|
const id = this.accountId(accountId);
|
|
708
|
-
requireSort(params.sort,
|
|
724
|
+
requireSort(params.sort, DOCUMENT_SORTS);
|
|
709
725
|
return this.callList(
|
|
710
726
|
"Failed to list documents",
|
|
711
727
|
() => this.http.get(`/accounts/${id}/documents`, {
|
|
@@ -723,7 +739,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
723
739
|
*/
|
|
724
740
|
async search(params = {}, accountId) {
|
|
725
741
|
const id = this.accountId(accountId);
|
|
726
|
-
requireSort(params.sort,
|
|
742
|
+
requireSort(params.sort, DOCUMENT_SORTS);
|
|
727
743
|
return this.callList(
|
|
728
744
|
"Failed to search documents",
|
|
729
745
|
() => this.http.get(`/accounts/${id}/documents/search`, {
|
|
@@ -1078,8 +1094,7 @@ function validateUpload(buffer, fileName) {
|
|
|
1078
1094
|
}
|
|
1079
1095
|
function buildUploadForm(buffer, fileName, name, metadata) {
|
|
1080
1096
|
const form = new FormData();
|
|
1081
|
-
|
|
1082
|
-
form.append("file", new Blob([view], { type: "application/pdf" }), fileName);
|
|
1097
|
+
appendFilePart(form, buffer, "application/pdf", fileName);
|
|
1083
1098
|
form.append("name", name);
|
|
1084
1099
|
if (metadata) {
|
|
1085
1100
|
form.append("metadata", JSON.stringify(metadata));
|
|
@@ -1189,26 +1204,35 @@ var FieldsResource = class extends BaseResource {
|
|
|
1189
1204
|
}
|
|
1190
1205
|
};
|
|
1191
1206
|
function validationConfig(signerAccessCode) {
|
|
1192
|
-
|
|
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);
|
|
1193
1212
|
}
|
|
1194
1213
|
|
|
1195
1214
|
// src/api/resources/oauth.ts
|
|
1196
1215
|
var import_node_crypto = require("crypto");
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
}
|
|
1216
|
+
function formRequestConfig() {
|
|
1217
|
+
return publicRequestConfig({
|
|
1218
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1200
1221
|
var OAuthResource = class extends BaseResource {
|
|
1201
1222
|
/** `GET /.well-known/oauth-protected-resource` at the API origin, outside `/v1`. */
|
|
1202
1223
|
async metadata() {
|
|
1203
|
-
return this.call(
|
|
1204
|
-
|
|
1205
|
-
()
|
|
1224
|
+
return this.call("Failed to discover OAuth resource", () => {
|
|
1225
|
+
const baseURL = this.http.defaults.baseURL;
|
|
1226
|
+
if (!baseURL) {
|
|
1227
|
+
throw new ValidationError("A base URL is required to discover OAuth metadata");
|
|
1228
|
+
}
|
|
1229
|
+
return this.http.get(
|
|
1206
1230
|
"/.well-known/oauth-protected-resource",
|
|
1207
1231
|
publicRequestConfig({
|
|
1208
|
-
baseURL: new URL(
|
|
1232
|
+
baseURL: new URL(baseURL).origin
|
|
1209
1233
|
})
|
|
1210
|
-
)
|
|
1211
|
-
);
|
|
1234
|
+
);
|
|
1235
|
+
});
|
|
1212
1236
|
}
|
|
1213
1237
|
/** Read RFC 8414 metadata from an HTTPS issuer and verify its issuer identity. */
|
|
1214
1238
|
async discovery(issuer) {
|
|
@@ -1292,6 +1316,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
1292
1316
|
if (callback.searchParams.get("iss") !== request.issuer) {
|
|
1293
1317
|
throw new ValidationError("OAuth issuer mismatch");
|
|
1294
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
|
+
}
|
|
1295
1322
|
if (callback.searchParams.has("error")) {
|
|
1296
1323
|
const error = callback.searchParams.get("error");
|
|
1297
1324
|
const oauthError = error.length > 0 && error.length <= 64 && !/[^a-z_]/.test(error) ? error : "unknown_error";
|
|
@@ -1332,7 +1359,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
1332
1359
|
}
|
|
1333
1360
|
const tokens = await this.call(
|
|
1334
1361
|
"OAuth token request failed",
|
|
1335
|
-
() => this.http.post("/oauth/token", payload, formRequestConfig)
|
|
1362
|
+
() => this.http.post("/oauth/token", payload, formRequestConfig())
|
|
1336
1363
|
);
|
|
1337
1364
|
const next = tokens?.refresh_token;
|
|
1338
1365
|
if (payload.grant_type === "refresh_token" && (typeof next !== "string" || !next.trim() || next === payload.refresh_token)) {
|
|
@@ -1353,7 +1380,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
1353
1380
|
}
|
|
1354
1381
|
await this.call(
|
|
1355
1382
|
"OAuth revocation failed",
|
|
1356
|
-
() => this.http.post("/oauth/revoke", payload, formRequestConfig)
|
|
1383
|
+
() => this.http.post("/oauth/revoke", payload, formRequestConfig())
|
|
1357
1384
|
);
|
|
1358
1385
|
}
|
|
1359
1386
|
/** `GET /oauth/userinfo` — flat OIDC claims; requires a bearer token with `openid`. */
|
|
@@ -1751,12 +1778,18 @@ var SignerResource = class extends BaseResource {
|
|
|
1751
1778
|
requireEmail(email);
|
|
1752
1779
|
try {
|
|
1753
1780
|
const lower = email.toLowerCase();
|
|
1754
|
-
for (let page = 1; ; page++) {
|
|
1781
|
+
for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
|
|
1755
1782
|
const { data, meta } = await this.list({ search: email, per_page: 100, page }, accountId);
|
|
1756
1783
|
const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
|
|
1757
1784
|
if (match) return match;
|
|
1758
|
-
if (!data.length
|
|
1785
|
+
if (!data.length) return null;
|
|
1786
|
+
if (meta?.last_page !== void 0) {
|
|
1787
|
+
if (page >= meta.last_page) return null;
|
|
1788
|
+
} else if (data.length < 100) {
|
|
1789
|
+
return null;
|
|
1790
|
+
}
|
|
1759
1791
|
}
|
|
1792
|
+
throw new ValidationError("Signer email search exceeded the maximum page count");
|
|
1760
1793
|
} catch (err) {
|
|
1761
1794
|
if (err instanceof ApiError && err.statusCode === 404) {
|
|
1762
1795
|
return null;
|
|
@@ -1765,6 +1798,7 @@ var SignerResource = class extends BaseResource {
|
|
|
1765
1798
|
}
|
|
1766
1799
|
}
|
|
1767
1800
|
};
|
|
1801
|
+
var MAX_SEARCH_PAGES = 100;
|
|
1768
1802
|
function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
1769
1803
|
const normalised = {
|
|
1770
1804
|
full_name: payload.full_name,
|
|
@@ -1779,7 +1813,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
|
|
|
1779
1813
|
if ("metadata" in payload && payload.metadata !== void 0) {
|
|
1780
1814
|
normalised.metadata = payload.metadata;
|
|
1781
1815
|
}
|
|
1782
|
-
return
|
|
1816
|
+
return stripEmpty(normalised);
|
|
1783
1817
|
}
|
|
1784
1818
|
|
|
1785
1819
|
// src/api/resources/tags.ts
|
|
@@ -1800,7 +1834,7 @@ var TagResource = class extends BaseResource {
|
|
|
1800
1834
|
const id = this.accountId(accountId);
|
|
1801
1835
|
return this.call(
|
|
1802
1836
|
"Failed to create tag",
|
|
1803
|
-
() => this.http.post(`/accounts/${id}/tags`,
|
|
1837
|
+
() => this.http.post(`/accounts/${id}/tags`, stripEmpty({ ...payload }))
|
|
1804
1838
|
);
|
|
1805
1839
|
}
|
|
1806
1840
|
/**
|
|
@@ -2073,9 +2107,8 @@ var WorkspaceResource = class extends BaseResource {
|
|
|
2073
2107
|
throw new ValidationError("Logo buffer is required");
|
|
2074
2108
|
}
|
|
2075
2109
|
const contentType = options.contentType ?? "image/png";
|
|
2076
|
-
const view = new Uint8Array(logo.buffer, logo.byteOffset, logo.byteLength);
|
|
2077
2110
|
const form = new FormData();
|
|
2078
|
-
form
|
|
2111
|
+
appendFilePart(form, logo, contentType, options.fileName ?? "logo.png");
|
|
2079
2112
|
return this.call(
|
|
2080
2113
|
"Failed to upload workspace logo",
|
|
2081
2114
|
() => this.http.post(`/accounts/${id}/logo`, form, {
|
|
@@ -2412,6 +2445,8 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
2412
2445
|
WebhookVerifier,
|
|
2413
2446
|
WorkspaceResource,
|
|
2414
2447
|
buildAssignmentPayload,
|
|
2415
|
-
normalizeBaseUrl
|
|
2448
|
+
normalizeBaseUrl,
|
|
2449
|
+
requireDocumentArtifactName,
|
|
2450
|
+
requireSignerImageType
|
|
2416
2451
|
});
|
|
2417
2452
|
//# sourceMappingURL=api.cjs.map
|