@assinafy/cli 2.5.0 → 2.5.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.
- package/README.en.md +7 -4
- package/README.md +5 -3
- package/dist/api.cjs +65 -38
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +65 -38
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +127 -70
- package/dist/types/api/errors.d.ts +9 -0
- package/dist/types/api/errors.d.ts.map +1 -1
- package/dist/types/api/resources/documents.d.ts +4 -3
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/oauth.d.ts +1 -1
- package/dist/types/api/resources/oauth.d.ts.map +1 -1
- package/dist/types/api/resources/signer-documents.d.ts +9 -4
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +23 -19
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/api/utils.d.ts.map +1 -1
- package/docs/api-operations.json +1 -1
- package/docs/api-reference.md +74 -39
- package/docs/documents.md +5 -6
- package/docs/migration-v2.md +1 -1
- package/docs/sdk-reference.md +12 -13
- package/docs/signer.md +4 -2
- package/docs/webhooks.md +34 -11
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -244,7 +244,7 @@ assinafy signer sign <documentId> <assignmentId> --entries '[
|
|
|
244
244
|
]'
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code. `documents send-token <documentId> --recipient <email
|
|
247
|
+
Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code. The code arrives in the invitation message itself. To email a fresh access token to a signer who has not signed a pending document yet, run `documents send-token <documentId> --recipient <email>` (email channel only; it sends `{ "channel": "email", "recipient": "signer@example.com" }` and returns `document`, `channel`, and `recipient`; `--email` is an alias). Both channels use `signer verify-code`; `verify-email` remains an alias. Set `ASSINAFY_VERIFICATION_CODE` to keep the OTP out of command arguments and preserve leading zeroes. `signer decline` (or `decline-multiple`) rejects with a reason, and `sign-multiple` completes several documents in one call.
|
|
248
248
|
|
|
249
249
|
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.
|
|
250
250
|
|
|
@@ -283,6 +283,8 @@ assinafy webhooks endpoints delete <endpointId>
|
|
|
283
283
|
|
|
284
284
|
assinafy webhooks dispatches --endpoint <endpointId> --delivered false
|
|
285
285
|
assinafy webhooks retry <dispatchId> # redeliver one event
|
|
286
|
+
# check a saved delivery with ASSINAFY_WEBHOOK_SECRET (exit code 1 when invalid)
|
|
287
|
+
assinafy webhooks verify body.json --id <webhook-id> --timestamp <webhook-timestamp> --signature <webhook-signature>
|
|
286
288
|
```
|
|
287
289
|
|
|
288
290
|
Omitting `--events` subscribes to `document_ready`, `document_prepared`, `signer_signed_document`, `signer_rejected_document`, and `document_processing_failed`. `endpoints update` changes only the flags given (`--active`/`--inactive`, `--signing`/`--no-signing`, `--url`, `--email`, `--name`, `--events`); disabling signing discards the secret. `rotate-secret` invalidates the previous secret immediately. A duplicate URL within the workspace returns `400`; creating past the plan limit returns `403`. Secret read and rotation are not available to OAuth applications. `retry` re-sends only to that delivery's endpoint, and only while it is active.
|
|
@@ -437,7 +439,7 @@ assinafy send contract.pdf \
|
|
|
437
439
|
| `documents verify <hash>` | Verify by signature hash (public) |
|
|
438
440
|
| `documents statuses` | List every document status and whether it is deletable |
|
|
439
441
|
| `documents public <id>` | Public unauthenticated lookup |
|
|
440
|
-
| `documents send-token <id> --recipient <email
|
|
442
|
+
| `documents send-token <id> --recipient <email>` | Email a one-time access token to a pending signer (email channel only) |
|
|
441
443
|
| `documents progress <id>` | Signing progress |
|
|
442
444
|
| `documents wait <id> [--timeout] [--interval]` | Poll until ready, failed, or timed out |
|
|
443
445
|
|
|
@@ -537,7 +539,7 @@ await client.documents.waitUntilReady(document.id);
|
|
|
537
539
|
|
|
538
540
|
CommonJS uses `require('@assinafy/cli/api')`. JSON `data` envelopes are unwrapped, paginated calls resolve to `{ data, meta }` built from the `X-Pagination-*` headers, downloads resolve to a `Buffer`, and status-only responses keep their documented object.
|
|
539
541
|
|
|
540
|
-
Errors are typed: `ValidationError` for local input, `ApiError` (with `statusCode`, `responseData`, `wwwAuthenticate`, and `
|
|
542
|
+
Errors are typed: `ValidationError` for local input, `ApiError` (with `statusCode`, `responseData`, `wwwAuthenticate`, `retryAfter`, and `rateLimit` from the `X-Rate-Limit-*` headers; on `429`, wait `Retry-After` seconds — the SDK never retries automatically) for HTTP failures, `NetworkError` for transport failures, and `PartialWorkflowError` when `uploadAndRequestSignatures` fails after creating resources — it exposes the `documentId` and `signerIds` that already exist so you can inspect and resume. Never automatically delete these signers: they may have been reused from other documents. For example:
|
|
541
543
|
|
|
542
544
|
```ts
|
|
543
545
|
try {
|
|
@@ -597,7 +599,8 @@ The [release runbook](./docs/releasing.md) covers tags, trusted publishing, and
|
|
|
597
599
|
- The production OpenAPI publishes 106 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.
|
|
598
600
|
- 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.
|
|
599
601
|
- 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 106 OpenAPI operations.
|
|
600
|
-
-
|
|
602
|
+
- `send-token` sends the email-only body `{ "channel": "email", "recipient": "..." }`; WhatsApp and the older `{ "email" }` body are rejected by the API with `400`.
|
|
603
|
+
- `signer documents` and `signer search` accept the workspace API key or token when `--access-code` is omitted.
|
|
601
604
|
- Webhook signatures follow Standard Webhooks; `WebhookVerifier.verifyDelivery` implements the published scheme. The older `verify(body, signature)` method is deprecated and does not match Assinafy deliveries.
|
|
602
605
|
|
|
603
606
|
## License
|
package/README.md
CHANGED
|
@@ -310,11 +310,11 @@ assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[
|
|
|
310
310
|
]' --json
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
-
Os IDs e valores de campos vêm do assignment apresentado ao signatário.
|
|
313
|
+
Os IDs e valores de campos vêm do assignment apresentado ao signatário. Na verificação por e-mail ou WhatsApp, o código chega na própria mensagem do convite. Para enviar um novo token de acesso por e-mail a um signatário que ainda não assinou um documento pendente, use `documents send-token <id> --recipient <email>` (somente o canal `email`; o corpo enviado é `{ "channel": "email", "recipient": "signer@example.com" }` e a resposta traz `document`, `channel` e `recipient`). Os dois métodos usam `signer verify-code`; `verify-email` continua disponível como alias. Configure `ASSINAFY_VERIFICATION_CODE` para manter o OTP fora dos argumentos e preservar zeros iniciais. `decline` e `decline-multiple` exigem motivo não vazio com até 2.000 caracteres. As operações em lote usam `sign-multiple` e `decline-multiple`.
|
|
314
314
|
|
|
315
315
|
Para certificados A1/A3, use a página de assinatura Assinafy ou integre o Web PKI com o SDK. Após apresentar o documento e aceitar os termos, `signer certificate-start --json` retorna `{ "token": "..." }`. O navegador assina essa operação no dispositivo do signatário. Defina `ASSINAFY_CERTIFICATE_TOKEN` com o mesmo token e execute `signer certificate-complete --json`, que retorna `{ "signerName": "..." }`. A chave privada e a senha/PIN permanecem no dispositivo. Aguarde o documento ficar `certificated` e baixe `--artifact pades` ou `bundle`; o comando comum `sign` não substitui esse fluxo.
|
|
316
316
|
|
|
317
|
-
O SDK remove credenciais do proprietário das chamadas públicas e do signatário. O download público de artefato do signatário aceita opcionalmente um código para uma verificação prévia de identidade.
|
|
317
|
+
O SDK remove credenciais do proprietário das chamadas públicas e do signatário. O download público de artefato do signatário aceita opcionalmente um código para uma verificação prévia de identidade. `--email` é um alias de `--recipient` em `send-token`. `signer documents <signerId>` e `signer search <signerId> <texto>` também funcionam sem `--access-code`, usando a chave de API ou o token do workspace ao qual o signatário pertence.
|
|
318
318
|
|
|
319
319
|
Verificação, confirmação de dados e envio da imagem de assinatura podem retornar `[]` em caso de sucesso. Consulte `signer self` para obter o perfil atualizado e confirme o progresso e os artefatos certificados após assinar. Os exemplos completos de requisição e resposta estão na [referência do SDK para signatários](docs/sdk-reference.md#signer-side-flows-clientsignerdocuments).
|
|
320
320
|
|
|
@@ -337,6 +337,8 @@ assinafy webhooks endpoints create --url https://example.com/hooks/assinafy
|
|
|
337
337
|
assinafy webhooks endpoints list
|
|
338
338
|
assinafy webhooks endpoints secret "$ENDPOINT_ID" # segredo whsec_ para o receptor
|
|
339
339
|
assinafy webhooks dispatches --endpoint "$ENDPOINT_ID" --delivered false --json
|
|
340
|
+
# confere uma entrega salva com ASSINAFY_WEBHOOK_SECRET (sai com código 1 se inválida)
|
|
341
|
+
assinafy webhooks verify corpo.json --id "$WEBHOOK_ID" --timestamp "$WEBHOOK_TIMESTAMP" --signature "$WEBHOOK_SIGNATURE"
|
|
340
342
|
```
|
|
341
343
|
|
|
342
344
|
Sem `--events`, o endpoint recebe `document_ready`, `document_prepared`, `signer_signed_document`, `signer_rejected_document` e `document_processing_failed`. `endpoints update <id>` altera apenas as opções informadas (`--active`/`--inactive`, `--signing`/`--no-signing`, `--url`, `--email`, `--name`, `--events`); desativar a assinatura descarta o segredo. `endpoints rotate-secret <id>` gera um novo segredo e invalida o anterior imediatamente. `endpoints delete <id>` remove o endpoint e libera a vaga. URLs repetidas no mesmo workspace retornam `400`; criar acima do limite do plano retorna `403`. A leitura e a rotação do segredo não estão disponíveis para aplicativos OAuth.
|
|
@@ -425,7 +427,7 @@ A listagem acima solicita uma página. Continue até `meta.last_page` quando pre
|
|
|
425
427
|
}
|
|
426
428
|
```
|
|
427
429
|
|
|
428
|
-
No SDK, `ValidationError` indica entrada inválida; `ApiError` carrega `statusCode`, `responseData`, `wwwAuthenticate` e `
|
|
430
|
+
No SDK, `ValidationError` indica entrada inválida; `ApiError` carrega `statusCode`, `responseData`, `wwwAuthenticate`, `retryAfter` e `rateLimit` (`X-Rate-Limit-Limit`, `-Remaining`, `-Reset`); em `429`, aguarde os segundos de `Retry-After` antes de repetir — o SDK não repete chamadas automaticamente; `NetworkError` indica falha de transporte; `PartialWorkflowError` preserva IDs existentes e a causa original. O SDK exige HTTPS, rejeita redirecionamentos e não inclui configurações Axios com credenciais nos erros. O uso de HTTP sem TLS é restrito a loopback com opt-in explícito no SDK.
|
|
429
431
|
|
|
430
432
|
## Referência de comandos
|
|
431
433
|
|
package/dist/api.cjs
CHANGED
|
@@ -76,6 +76,8 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
76
76
|
wwwAuthenticate;
|
|
77
77
|
/** Server retry delay (seconds or HTTP date), when provided. */
|
|
78
78
|
retryAfter;
|
|
79
|
+
/** Rate-limit window reported by the API, when the headers are present. */
|
|
80
|
+
rateLimit;
|
|
79
81
|
constructor(message, statusCode, responseData = null, options) {
|
|
80
82
|
super(message, { statusCode, responseData }, options);
|
|
81
83
|
this.name = "ApiError";
|
|
@@ -83,6 +85,7 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
83
85
|
this.responseData = responseData;
|
|
84
86
|
this.wwwAuthenticate = options?.wwwAuthenticate;
|
|
85
87
|
this.retryAfter = options?.retryAfter;
|
|
88
|
+
this.rateLimit = options?.rateLimit;
|
|
86
89
|
}
|
|
87
90
|
static fromResponse(statusCode, responseData, headers = {}) {
|
|
88
91
|
if (Buffer.isBuffer(responseData) || responseData instanceof ArrayBuffer) {
|
|
@@ -96,13 +99,23 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
96
99
|
const data = responseData ?? {};
|
|
97
100
|
const rawMessage = data.message;
|
|
98
101
|
const rawError = data.error;
|
|
99
|
-
const
|
|
102
|
+
const description = data.error_description;
|
|
103
|
+
const message = typeof rawMessage === "string" && rawMessage.length > 0 ? rawMessage : typeof rawError === "string" ? typeof description === "string" && description.length > 0 ? `${rawError}: ${description}` : rawError : "API request failed";
|
|
100
104
|
return new _ApiError(message, statusCode, responseData, {
|
|
101
105
|
wwwAuthenticate: typeof headers["www-authenticate"] === "string" ? headers["www-authenticate"] : void 0,
|
|
102
|
-
retryAfter: typeof headers["retry-after"] === "string" ? headers["retry-after"] : void 0
|
|
106
|
+
retryAfter: typeof headers["retry-after"] === "string" ? headers["retry-after"] : void 0,
|
|
107
|
+
rateLimit: parseRateLimit(headers)
|
|
103
108
|
});
|
|
104
109
|
}
|
|
105
110
|
};
|
|
111
|
+
function parseRateLimit(headers) {
|
|
112
|
+
const info = {};
|
|
113
|
+
for (const key of ["limit", "remaining", "reset"]) {
|
|
114
|
+
const value = Number.parseInt(String(headers[`x-rate-limit-${key}`]), 10);
|
|
115
|
+
if (Number.isFinite(value)) info[key] = value;
|
|
116
|
+
}
|
|
117
|
+
return Object.keys(info).length > 0 ? info : void 0;
|
|
118
|
+
}
|
|
106
119
|
var ValidationError = class extends AssinafyError {
|
|
107
120
|
errors;
|
|
108
121
|
constructor(message = "Validation failed", errors = {}) {
|
|
@@ -256,6 +269,16 @@ function validateSignerOptions(input) {
|
|
|
256
269
|
`notification_methods must contain only: ${NOTIFICATION_METHODS.join(", ")}`
|
|
257
270
|
);
|
|
258
271
|
}
|
|
272
|
+
const notifications = input.notification_methods ?? [];
|
|
273
|
+
if (notifications.length > 1) {
|
|
274
|
+
throw new ValidationError("notification_methods accepts exactly one method per signer");
|
|
275
|
+
}
|
|
276
|
+
const [notification] = notifications;
|
|
277
|
+
if (notification !== void 0 && (input.verification_method === "Email" || input.verification_method === "Whatsapp") && notification !== input.verification_method) {
|
|
278
|
+
throw new ValidationError(
|
|
279
|
+
`${input.verification_method} verification requires the ${input.verification_method} notification method`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
259
282
|
if (input.step !== void 0 && !Number.isInteger(input.step)) {
|
|
260
283
|
throw new ValidationError("step must be an integer");
|
|
261
284
|
}
|
|
@@ -992,7 +1015,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
992
1015
|
async createFromTemplate(templateId, signers, options = {}, accountId) {
|
|
993
1016
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
994
1017
|
const accId = this.accountId(accountId);
|
|
995
|
-
validateTemplateSigners(signers, { requireId: true
|
|
1018
|
+
validateTemplateSigners(signers, { requireId: true });
|
|
996
1019
|
if (options.expires_at !== void 0) requireIso8601(options.expires_at, "expires_at");
|
|
997
1020
|
if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
|
|
998
1021
|
throw new ValidationError("editor_fields must contain field_id and value");
|
|
@@ -1011,7 +1034,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1011
1034
|
async estimateCostFromTemplate(templateId, signers, accountId) {
|
|
1012
1035
|
const tmplId = this.requireId(templateId, "Template ID");
|
|
1013
1036
|
const accId = this.accountId(accountId);
|
|
1014
|
-
validateTemplateSigners(signers, { requireId: false
|
|
1037
|
+
validateTemplateSigners(signers, { requireId: false });
|
|
1015
1038
|
return this.call(
|
|
1016
1039
|
"Failed to estimate cost from template",
|
|
1017
1040
|
() => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents/estimate-cost`, { signers })
|
|
@@ -1051,33 +1074,21 @@ var DocumentResource = class extends BaseResource {
|
|
|
1051
1074
|
);
|
|
1052
1075
|
}
|
|
1053
1076
|
/**
|
|
1054
|
-
* `PUT /public/documents/{document_id}/send-token` —
|
|
1055
|
-
*
|
|
1056
|
-
*
|
|
1077
|
+
* `PUT /public/documents/{document_id}/send-token` — email a one-time access
|
|
1078
|
+
* token to a signer who has not signed a pending document yet. The API sends
|
|
1079
|
+
* `{ channel: 'email', recipient }`; only the `email` channel is accepted.
|
|
1080
|
+
* The `{ email }` form is kept for existing callers and sends the same body.
|
|
1057
1081
|
*/
|
|
1058
1082
|
async sendToken(documentId, recipient, channel = "email") {
|
|
1059
1083
|
const id = this.requireId(documentId, "Document ID");
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
"Failed to send signing token",
|
|
1064
|
-
() => this.http.put(
|
|
1065
|
-
`/public/documents/${id}/send-token`,
|
|
1066
|
-
{ email: recipient.email },
|
|
1067
|
-
publicRequestConfig()
|
|
1068
|
-
)
|
|
1069
|
-
);
|
|
1070
|
-
}
|
|
1071
|
-
if (!recipient) throw new ValidationError("recipient is required");
|
|
1072
|
-
if (channel !== "email" && channel !== "whatsapp") {
|
|
1073
|
-
throw new ValidationError("channel must be email or whatsapp");
|
|
1074
|
-
}
|
|
1075
|
-
if (channel === "email") requireEmail(recipient);
|
|
1084
|
+
const email = typeof recipient === "object" ? recipient?.email : recipient;
|
|
1085
|
+
if (channel !== "email") throw new ValidationError("channel must be email");
|
|
1086
|
+
requireEmail(email);
|
|
1076
1087
|
return this.call(
|
|
1077
1088
|
"Failed to send signing token",
|
|
1078
1089
|
() => this.http.put(
|
|
1079
1090
|
`/public/documents/${id}/send-token`,
|
|
1080
|
-
{
|
|
1091
|
+
{ channel, recipient: email },
|
|
1081
1092
|
publicRequestConfig()
|
|
1082
1093
|
)
|
|
1083
1094
|
);
|
|
@@ -1120,9 +1131,6 @@ function validateTemplateSigners(signers, options) {
|
|
|
1120
1131
|
if (options.requireId && signer.step !== void 0 && Number(signer.step) < 1) {
|
|
1121
1132
|
throw new ValidationError("template signer step must be a positive integer");
|
|
1122
1133
|
}
|
|
1123
|
-
if (options.singleNotification && Array.isArray(signer.notification_methods) && signer.notification_methods.length > 1) {
|
|
1124
|
-
throw new ValidationError("template signers accept at most one notification method");
|
|
1125
|
-
}
|
|
1126
1134
|
}
|
|
1127
1135
|
if (options.requireId) {
|
|
1128
1136
|
validateSigningSteps(signers);
|
|
@@ -1407,7 +1415,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
1407
1415
|
});
|
|
1408
1416
|
}
|
|
1409
1417
|
/**
|
|
1410
|
-
* `POST /oauth/token` — code exchange or
|
|
1418
|
+
* `POST /oauth/token` — code exchange, refresh, or RFC 8693 token exchange; returns the flat OAuth JSON body.
|
|
1411
1419
|
* A refresh must return a new `refresh_token`; otherwise this throws `ValidationError`.
|
|
1412
1420
|
*/
|
|
1413
1421
|
async token(payload) {
|
|
@@ -1424,8 +1432,20 @@ var OAuthResource = class extends BaseResource {
|
|
|
1424
1432
|
}
|
|
1425
1433
|
} else if (payload.grant_type === "refresh_token") {
|
|
1426
1434
|
required(payload.refresh_token, "refresh_token");
|
|
1435
|
+
} else if (payload.grant_type === TOKEN_EXCHANGE) {
|
|
1436
|
+
required(payload.client_secret, "client_secret");
|
|
1437
|
+
httpsUrl(required(payload.resource, "resource"), "resource");
|
|
1438
|
+
required(payload.subject_token, "subject_token");
|
|
1439
|
+
for (const field of ["subject_token_type", "requested_token_type"]) {
|
|
1440
|
+
const value = payload[field];
|
|
1441
|
+
if ((value !== void 0 || field === "subject_token_type") && value !== ACCESS_TOKEN_TYPE) {
|
|
1442
|
+
throw new ValidationError(`${field} must be ${ACCESS_TOKEN_TYPE}`);
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1427
1445
|
} else {
|
|
1428
|
-
throw new ValidationError(
|
|
1446
|
+
throw new ValidationError(
|
|
1447
|
+
`grant_type must be authorization_code, refresh_token or ${TOKEN_EXCHANGE}`
|
|
1448
|
+
);
|
|
1429
1449
|
}
|
|
1430
1450
|
const tokens = await this.call(
|
|
1431
1451
|
"OAuth token request failed",
|
|
@@ -1458,6 +1478,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
1458
1478
|
return this.call("Failed to fetch OAuth userinfo", () => this.http.get("/oauth/userinfo"));
|
|
1459
1479
|
}
|
|
1460
1480
|
};
|
|
1481
|
+
var TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
1482
|
+
var ACCESS_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token";
|
|
1461
1483
|
function required(value, name) {
|
|
1462
1484
|
if (typeof value !== "string" || !value.trim()) throw new ValidationError(`${name} is required`);
|
|
1463
1485
|
return value;
|
|
@@ -1486,27 +1508,32 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1486
1508
|
() => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
|
|
1487
1509
|
);
|
|
1488
1510
|
}
|
|
1489
|
-
/**
|
|
1511
|
+
/**
|
|
1512
|
+
* `GET /signers/{signer_id}/documents` — with a signer access code, or with
|
|
1513
|
+
* the client's owner credentials when the code is omitted (the signer must
|
|
1514
|
+
* belong to that workspace).
|
|
1515
|
+
*/
|
|
1490
1516
|
async list(signerId, signerAccessCode, params = {}) {
|
|
1491
1517
|
const sid = this.requireId(signerId, "Signer ID");
|
|
1492
|
-
const
|
|
1518
|
+
const config = this.signerOrOwnerConfig(signerAccessCode, { ...params });
|
|
1493
1519
|
return this.callList(
|
|
1494
1520
|
"Failed to list signer documents",
|
|
1495
|
-
() => this.http.get(
|
|
1496
|
-
`/signers/${sid}/documents`,
|
|
1497
|
-
signerAccessConfig(code, params)
|
|
1498
|
-
)
|
|
1521
|
+
() => this.http.get(`/signers/${sid}/documents`, config)
|
|
1499
1522
|
);
|
|
1500
1523
|
}
|
|
1501
|
-
/** `GET /signers/{signer_id}/documents/search?
|
|
1524
|
+
/** `GET /signers/{signer_id}/documents/search?search=…` — access code or owner credentials. */
|
|
1502
1525
|
async search(signerId, search, signerAccessCode) {
|
|
1503
1526
|
const sid = this.requireId(signerId, "Signer ID");
|
|
1504
|
-
const
|
|
1527
|
+
const config = this.signerOrOwnerConfig(signerAccessCode, { search });
|
|
1505
1528
|
return this.callList(
|
|
1506
1529
|
"Failed to search signer documents",
|
|
1507
|
-
() => this.http.get(`/signers/${sid}/documents/search`,
|
|
1530
|
+
() => this.http.get(`/signers/${sid}/documents/search`, config)
|
|
1508
1531
|
);
|
|
1509
1532
|
}
|
|
1533
|
+
signerOrOwnerConfig(signerAccessCode, params) {
|
|
1534
|
+
if (signerAccessCode === void 0) return { params: cleanParams(params) };
|
|
1535
|
+
return signerAccessConfig(this.requireId(signerAccessCode, "signer-access-code"), params);
|
|
1536
|
+
}
|
|
1510
1537
|
/**
|
|
1511
1538
|
* Public `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
|
|
1512
1539
|
* When an access code is supplied, the SDK first verifies that it belongs to
|