@assinafy/cli 2.2.0 → 2.4.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/README.en.md +2 -1
- package/README.md +2 -2
- package/dist/api.cjs +19 -6
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +19 -6
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +55 -20
- package/dist/types/api/resources/assignments.d.ts +0 -1
- package/dist/types/api/resources/assignments.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts +4 -1
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +9 -3
- package/dist/types/api/types.d.ts.map +1 -1
- package/docs/api-operations.json +2 -2
- package/docs/api-reference.md +40 -18
- package/docs/oauth-guide.md +23 -14
- package/docs/oauth.md +4 -4
- package/docs/sdk-reference.md +2 -2
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -31,6 +31,7 @@ This document reads top to bottom: install, authenticate, send your first signat
|
|
|
31
31
|
## Requirements
|
|
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
|
+
- HTTPS with TLS 1.2 or higher to reach the Assinafy API; supported Node.js versions use that minimum by default.
|
|
34
35
|
- An Assinafy account and an API key (see [Authentication](#authentication)).
|
|
35
36
|
- Linux, macOS, or Windows. Release archives ship for `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`, `windows-x64`, and `windows-arm64`.
|
|
36
37
|
|
|
@@ -110,7 +111,7 @@ The CLI includes the official application's public client ID and uses PKCE S256
|
|
|
110
111
|
https://integrations.assinafy.com.br/assinafy-cli/oauth-callback
|
|
111
112
|
```
|
|
112
113
|
|
|
113
|
-
The CLI requests all
|
|
114
|
+
The CLI requests all ten published scopes by default: `account:read documents:read documents:write templates:read templates:write webhooks:write openid profile email offline_access`, including template read/write access and `webhooks:write` for the webhook write commands. The application registration must permit all ten; existing connections need fresh consent to gain additional permissions. An explicit `--scope` requests a smaller set.
|
|
114
115
|
|
|
115
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:
|
|
116
117
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Este guia segue o fluxo de uma integração: instalação, autenticação, envio
|
|
|
23
23
|
|
|
24
24
|
## Requisitos e instalação
|
|
25
25
|
|
|
26
|
-
Use [Node.js 24 LTS](https://nodejs.org/en/about/previous-releases) atualizado. O mínimo suportado é `22.12.0`; a CI também verifica as linhas 22 e 26. A CLI funciona em Linux, macOS e Windows, em x64 e ARM64. Os arquivos de release incluem o executável JavaScript e exigem Node.js instalado.
|
|
26
|
+
Use [Node.js 24 LTS](https://nodejs.org/en/about/previous-releases) atualizado. O mínimo suportado é `22.12.0`; a CI também verifica as linhas 22 e 26. A CLI funciona em Linux, macOS e Windows, em x64 e ARM64. Os arquivos de release incluem o executável JavaScript e exigem Node.js instalado. A API Assinafy exige HTTPS com TLS 1.2 ou superior, o mínimo padrão das versões suportadas do Node.js.
|
|
27
27
|
|
|
28
28
|
Instale uma versão publicada e fixe essa versão nas automações:
|
|
29
29
|
|
|
@@ -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 os
|
|
97
|
+
A CLI solicita por padrão os dez escopos publicados: `account:read documents:read documents:write templates:read templates:write webhooks:write openid profile email offline_access`, incluindo leitura e alteração de templates e `webhooks:write` para os comandos que alteram webhooks. O cadastro da aplicação deve permitir os dez; uma conexão existente precisa de novo consentimento para obter permissões adicionais. `--scope` permite solicitar um conjunto menor explicitamente.
|
|
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
|
|
package/dist/api.cjs
CHANGED
|
@@ -416,7 +416,7 @@ function buildAssignmentPayload(payload, options = {}) {
|
|
|
416
416
|
throw new ValidationError("method must be virtual or collect");
|
|
417
417
|
}
|
|
418
418
|
const signers = extractSignerRefs(payload);
|
|
419
|
-
if (signers.length === 0
|
|
419
|
+
if (signers.length === 0) {
|
|
420
420
|
throw new ValidationError("At least one signer is required", {
|
|
421
421
|
signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
|
|
422
422
|
});
|
|
@@ -516,7 +516,6 @@ var AssignmentResource = class extends BaseResource {
|
|
|
516
516
|
`/documents/${docId}/assignments/estimate-cost`,
|
|
517
517
|
buildAssignmentPayload(payload, {
|
|
518
518
|
allowSignersWithoutId: true,
|
|
519
|
-
allowEmptySigners: true,
|
|
520
519
|
skipDigitalCertificateStepValidation: true
|
|
521
520
|
})
|
|
522
521
|
)
|
|
@@ -1195,6 +1194,9 @@ function validationConfig(signerAccessCode) {
|
|
|
1195
1194
|
|
|
1196
1195
|
// src/api/resources/oauth.ts
|
|
1197
1196
|
var import_node_crypto = require("crypto");
|
|
1197
|
+
var formRequestConfig = publicRequestConfig({
|
|
1198
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
1199
|
+
});
|
|
1198
1200
|
var OAuthResource = class extends BaseResource {
|
|
1199
1201
|
/** `GET /.well-known/oauth-protected-resource` at the API origin, outside `/v1`. */
|
|
1200
1202
|
async metadata() {
|
|
@@ -1307,7 +1309,10 @@ var OAuthResource = class extends BaseResource {
|
|
|
1307
1309
|
resource: request.resource
|
|
1308
1310
|
});
|
|
1309
1311
|
}
|
|
1310
|
-
/**
|
|
1312
|
+
/**
|
|
1313
|
+
* `POST /oauth/token` — code exchange or refresh; returns the flat OAuth JSON body.
|
|
1314
|
+
* A refresh must return a new `refresh_token`; otherwise this throws `ValidationError`.
|
|
1315
|
+
*/
|
|
1311
1316
|
async token(payload) {
|
|
1312
1317
|
required(payload.client_id, "client_id");
|
|
1313
1318
|
if (payload.client_secret !== void 0) required(payload.client_secret, "client_secret");
|
|
@@ -1325,10 +1330,18 @@ var OAuthResource = class extends BaseResource {
|
|
|
1325
1330
|
} else {
|
|
1326
1331
|
throw new ValidationError("grant_type must be authorization_code or refresh_token");
|
|
1327
1332
|
}
|
|
1328
|
-
|
|
1333
|
+
const tokens = await this.call(
|
|
1329
1334
|
"OAuth token request failed",
|
|
1330
|
-
() => this.http.post("/oauth/token", payload,
|
|
1335
|
+
() => this.http.post("/oauth/token", payload, formRequestConfig)
|
|
1331
1336
|
);
|
|
1337
|
+
const next = tokens?.refresh_token;
|
|
1338
|
+
if (payload.grant_type === "refresh_token" && (typeof next !== "string" || !next.trim() || next === payload.refresh_token)) {
|
|
1339
|
+
throw new ValidationError(
|
|
1340
|
+
"OAuth refresh response has no new refresh_token; the submitted refresh token may already be retired, so do not reuse it: reconnect instead",
|
|
1341
|
+
{ field: "refresh_token" }
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
return tokens;
|
|
1332
1345
|
}
|
|
1333
1346
|
/** `POST /oauth/revoke` — revoke an access/refresh token; success has no required body. */
|
|
1334
1347
|
async revoke(payload) {
|
|
@@ -1340,7 +1353,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
1340
1353
|
}
|
|
1341
1354
|
await this.call(
|
|
1342
1355
|
"OAuth revocation failed",
|
|
1343
|
-
() => this.http.post("/oauth/revoke", payload,
|
|
1356
|
+
() => this.http.post("/oauth/revoke", payload, formRequestConfig)
|
|
1344
1357
|
);
|
|
1345
1358
|
}
|
|
1346
1359
|
/** `GET /oauth/userinfo` — flat OIDC claims; requires a bearer token with `openid`. */
|