@assinafy/cli 2.1.2 → 2.2.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/.env.example +1 -0
- package/README.en.md +26 -8
- package/README.md +23 -4
- package/dist/api.cjs +67 -11
- package/dist/api.cjs.map +1 -1
- package/dist/api.js +67 -11
- package/dist/api.js.map +1 -1
- package/dist/cli.cjs +109 -27
- package/dist/types/api/resources/documents.d.ts +3 -3
- package/dist/types/api/resources/documents.d.ts.map +1 -1
- package/dist/types/api/resources/signer-documents.d.ts +26 -10
- package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +27 -2
- package/dist/types/api/types.d.ts.map +1 -1
- package/docs/documents.md +8 -8
- package/docs/oauth-guide.md +2 -0
- package/docs/sdk-reference.md +124 -9
- package/docs/signer.md +35 -5
- package/package.json +1 -1
package/.env.example
CHANGED
|
@@ -31,6 +31,7 @@ ASSINAFY_PROVIDER_TOKEN=
|
|
|
31
31
|
ASSINAFY_RESET_TOKEN=
|
|
32
32
|
ASSINAFY_SIGNER_ACCESS_CODE=
|
|
33
33
|
ASSINAFY_VERIFICATION_CODE=
|
|
34
|
+
ASSINAFY_CERTIFICATE_TOKEN=
|
|
34
35
|
|
|
35
36
|
# Experimental verifier only: Assinafy does not publish its webhook signing scheme.
|
|
36
37
|
# Do not treat WebhookVerifier as a production trust boundary without independent validation.
|
package/README.en.md
CHANGED
|
@@ -208,6 +208,10 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
|
|
|
208
208
|
|
|
209
209
|
Steps must form a contiguous sequence starting at `1`, and a `DigitalCertificate` signer must be alone in its step — both are validated locally before the request is sent. `--copy-receivers` takes **signer IDs** (people who only receive a copy of the finished document), not arbitrary email addresses.
|
|
210
210
|
|
|
211
|
+
Email verification uses `["Email"]` notifications; WhatsApp uses `["Whatsapp"]`. ICP-Brasil A1 and A3 both use `DigitalCertificate`, with either delivery channel, a matching CPF/CNPJ in `government_id`, an eligible workspace, and sufficient credits. Select one notification channel per signer. These same options work for template roles. A1/A3 signing uses `startCertificate`, the signer's local Web PKI operation, and `completeCertificate`; [complete payloads and the signing sequence](docs/sdk-reference.md#icp-brasil-a1a3-certificates) are in the SDK reference.
|
|
212
|
+
|
|
213
|
+
In production, `notification_methods: []` defaults to `['Email']` and sends an invitation. Select the intended channel explicitly; an empty array does not disable notifications.
|
|
214
|
+
|
|
211
215
|
To start from a saved template instead of a PDF:
|
|
212
216
|
|
|
213
217
|
```bash
|
|
@@ -223,10 +227,10 @@ Keep the certified PDF, the certificate page, the bundle, and the `documents act
|
|
|
223
227
|
|
|
224
228
|
## The signer side
|
|
225
229
|
|
|
226
|
-
Signers do not use your API key.
|
|
230
|
+
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 email; an invitation containing only a document ID and recipient does not contain this credential. Confirm the signer and document before submitting a decision:
|
|
227
231
|
|
|
228
232
|
```bash
|
|
229
|
-
export ASSINAFY_SIGNER_ACCESS_CODE=<code-from-the-
|
|
233
|
+
export ASSINAFY_SIGNER_ACCESS_CODE=<code-from-the-verification-link>
|
|
230
234
|
|
|
231
235
|
assinafy signer self # who the code belongs to
|
|
232
236
|
assinafy signer assignment # the document as the signer sees it
|
|
@@ -237,7 +241,20 @@ assinafy signer sign <documentId> <assignmentId> --entries '[
|
|
|
237
241
|
]'
|
|
238
242
|
```
|
|
239
243
|
|
|
240
|
-
Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code
|
|
244
|
+
Where email or WhatsApp verification is configured, the signer also confirms a 6-digit code. `documents send-token <documentId> --recipient <email> --channel email` sends it by email; use `--recipient <phone> --channel whatsapp` for WhatsApp. Both 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.
|
|
245
|
+
|
|
246
|
+
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.
|
|
247
|
+
|
|
248
|
+
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).
|
|
249
|
+
|
|
250
|
+
For a virtual assignment, confirm the signer's data and submit an empty entry array:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
assinafy signer confirm-data <documentId> --full-name 'Ana Lima' --email ana@example.com
|
|
254
|
+
assinafy signer sign <documentId> <assignmentId> --entries '[]'
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Single-document confirmation, signing, and decline commands verify that the access code matches the requested document and assignment before writing.
|
|
241
258
|
|
|
242
259
|
Owner API credentials are stripped from every public and signer-side request, so an access-code flow can never leak your workspace key. The published signer artifact download is public; passing `--access-code` adds an identity preflight that confirms the code belongs to the signer being downloaded for.
|
|
243
260
|
|
|
@@ -318,7 +335,8 @@ Every setting resolves as **CLI flag → environment variable → config-file pr
|
|
|
318
335
|
| Experimental webhook-verifier secret | _(config only)_ | `ASSINAFY_WEBHOOK_SECRET` |
|
|
319
336
|
| Password / new password | `--password` / `--new-password` | `ASSINAFY_PASSWORD` / `ASSINAFY_NEW_PASSWORD` |
|
|
320
337
|
| Social provider / reset token | `--provider-token` / `--reset-token` | `ASSINAFY_PROVIDER_TOKEN` / `ASSINAFY_RESET_TOKEN` |
|
|
321
|
-
| Signer access code / email OTP | `--access-code` / `--code` | `ASSINAFY_SIGNER_ACCESS_CODE` / `ASSINAFY_VERIFICATION_CODE` |
|
|
338
|
+
| Signer access code / email or WhatsApp OTP | `--access-code` / `--code` | `ASSINAFY_SIGNER_ACCESS_CODE` / `ASSINAFY_VERIFICATION_CODE` |
|
|
339
|
+
| Web PKI operation token | `--certificate-token` | `ASSINAFY_CERTIFICATE_TOKEN` |
|
|
322
340
|
|
|
323
341
|
`.env.example` documents every CLI and installer environment variable.
|
|
324
342
|
|
|
@@ -385,15 +403,15 @@ assinafy send contract.pdf \
|
|
|
385
403
|
| `documents activities <id>` | Activity log |
|
|
386
404
|
| `documents delete <id> [-y]` | Delete a document |
|
|
387
405
|
| `documents tags <id>` | List attached tags |
|
|
388
|
-
| `documents tags-set <id> [
|
|
389
|
-
| `documents tags-add <id> <
|
|
406
|
+
| `documents tags-set <id> [tags...]` | Replace the tag set by name (none detaches all) |
|
|
407
|
+
| `documents tags-add <id> <tags...>` | Attach tags by name |
|
|
390
408
|
| `documents tags-remove <id> <tagId>` | Detach one tag |
|
|
391
409
|
| `documents create-from-template <templateId> --signers <json> [...]` | Create from a template |
|
|
392
410
|
| `documents estimate-template-cost <templateId> --signers <json>` | Estimate template cost |
|
|
393
411
|
| `documents verify <hash>` | Verify by signature hash (public) |
|
|
394
412
|
| `documents statuses` | List every document status and whether it is deletable |
|
|
395
413
|
| `documents public <id>` | Public unauthenticated lookup |
|
|
396
|
-
| `documents send-token <id> --
|
|
414
|
+
| `documents send-token <id> --recipient <email> --channel email` | Send a verification token in production |
|
|
397
415
|
| `documents progress <id>` | Signing progress |
|
|
398
416
|
| `documents wait <id> [--timeout] [--interval]` | Poll until ready, failed, or timed out |
|
|
399
417
|
|
|
@@ -450,7 +468,7 @@ Field definitions are what `--method collect` assignments gather. Run `fields ty
|
|
|
450
468
|
|
|
451
469
|
### `signer` — signer-side flows
|
|
452
470
|
|
|
453
|
-
`document <signerId>` · `documents <signerId>` · `search <signerId> <query>` · `download <signerId> <documentId> <artifact>` · `self` · `accept-terms` · `verify-
|
|
471
|
+
`document <signerId>` · `documents <signerId>` · `search <signerId> <query>` · `download <signerId> <documentId> <artifact>` · `self` · `accept-terms` · `verify-code --code` (alias `verify-email`) · `certificate-start` · `certificate-complete --certificate-token` · `confirm-data <documentId>` · `upload-signature --file` · `download-signature` · `assignment` · `sign <documentId> <assignmentId> --entries` · `decline <documentId> <assignmentId> --reason` · `sign-multiple --document-ids` · `decline-multiple --document-ids --reason`
|
|
454
472
|
|
|
455
473
|
Every signer command except the public artifact `download` requires `--access-code <code>`; `download` accepts it optionally for an identity preflight. Use `ASSINAFY_SIGNER_ACCESS_CODE` to keep the code out of process arguments.
|
|
456
474
|
|
package/README.md
CHANGED
|
@@ -261,7 +261,11 @@ assinafy assignments create "$DOCUMENT_ID" --signers '[
|
|
|
261
261
|
]' --json
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
-
Passos explícitos devem ser contíguos a partir de `1`. Um signatário `DigitalCertificate` deve estar sozinho no seu passo e
|
|
264
|
+
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
|
+
|
|
266
|
+
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
|
+
|
|
268
|
+
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.
|
|
265
269
|
|
|
266
270
|
`--copy-receivers` recebe IDs de signatários que receberão uma cópia final. Para coletar campos, use `assignments create --method collect --entries ...` com páginas, campos e signatários do documento; os formatos completos estão em [assignments](docs/assignments.md) e [SDK](docs/sdk-reference.md#assignments-clientassignments).
|
|
267
271
|
|
|
@@ -279,9 +283,11 @@ assinafy documents create-from-template example_template --name 'Contrato' --sig
|
|
|
279
283
|
|
|
280
284
|
Cada papel deve corresponder ao template escolhido. Campos de editor, tags, mensagem e vencimento são opcionais. Use IDs reais obtidos na sua conta ao executar os exemplos.
|
|
281
285
|
|
|
286
|
+
Para organizar documentos, `documents tags-set <id> Contratos` substitui as tags e `documents tags-add <id> Contratos` acrescenta nomes. Nomes inexistentes são criados. `documents tags-remove <id> <tagId>` e o filtro `documents list --tags <ids>` usam IDs obtidos em `documents tags <id>`.
|
|
287
|
+
|
|
282
288
|
## Fluxo do signatário
|
|
283
289
|
|
|
284
|
-
Os comandos `signer` usam o código do
|
|
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:
|
|
285
291
|
|
|
286
292
|
```bash
|
|
287
293
|
assinafy signer self --json
|
|
@@ -295,9 +301,22 @@ assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[
|
|
|
295
301
|
]' --json
|
|
296
302
|
```
|
|
297
303
|
|
|
298
|
-
Os IDs e valores de campos vêm do assignment apresentado ao signatário.
|
|
304
|
+
Os IDs e valores de campos vêm do assignment apresentado ao signatário. Para verificação por e-mail, `documents send-token <id> --recipient <email> --channel email` envia o código; para WhatsApp, use `--recipient <telefone> --channel whatsapp`. Ambos 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`.
|
|
305
|
+
|
|
306
|
+
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.
|
|
307
|
+
|
|
308
|
+
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. Em produção, `send-token` usa `--recipient` e `--channel`; `--email` mantém o formato publicado para deployments que o aceitam.
|
|
309
|
+
|
|
310
|
+
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).
|
|
311
|
+
|
|
312
|
+
Para um assignment virtual, confirme os dados do signatário e envie um array vazio:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
assinafy signer confirm-data "$DOCUMENT_ID" --full-name 'Ana Lima' --email ana@example.com
|
|
316
|
+
assinafy signer sign "$DOCUMENT_ID" example_assignment --entries '[]'
|
|
317
|
+
```
|
|
299
318
|
|
|
300
|
-
|
|
319
|
+
Os comandos de confirmação de dados, assinatura e recusa de um único documento verificam se o código de acesso corresponde ao documento e ao assignment antes de enviar a alteração.
|
|
301
320
|
|
|
302
321
|
## Eventos e webhooks
|
|
303
322
|
|
package/dist/api.cjs
CHANGED
|
@@ -860,24 +860,24 @@ var DocumentResource = class extends BaseResource {
|
|
|
860
860
|
);
|
|
861
861
|
}
|
|
862
862
|
/**
|
|
863
|
-
* Replace the document's tag set
|
|
864
|
-
*
|
|
863
|
+
* Replace the document's tag set. Production accepts tag names and creates missing tags.
|
|
864
|
+
* An empty array detaches all tags. Values are forwarded unchanged.
|
|
865
865
|
*/
|
|
866
866
|
async replaceTags(documentId, tags, accountId) {
|
|
867
867
|
const accId = this.accountId(accountId);
|
|
868
868
|
const docId = this.requireId(documentId, "Document ID");
|
|
869
|
-
if (!Array.isArray(tags)) throw new ValidationError("tags must be an array
|
|
869
|
+
if (!Array.isArray(tags)) throw new ValidationError("tags must be an array");
|
|
870
870
|
return this.call(
|
|
871
871
|
"Failed to replace document tags",
|
|
872
872
|
() => this.http.put(`/accounts/${accId}/documents/${docId}/tags`, { tags })
|
|
873
873
|
);
|
|
874
874
|
}
|
|
875
|
-
/** Attach additional tag
|
|
875
|
+
/** Attach additional tag names without removing existing ones. Production creates missing tags. */
|
|
876
876
|
async addTags(documentId, tags, accountId) {
|
|
877
877
|
const accId = this.accountId(accountId);
|
|
878
878
|
const docId = this.requireId(documentId, "Document ID");
|
|
879
879
|
if (!Array.isArray(tags) || tags.length === 0) {
|
|
880
|
-
throw new ValidationError("tags must be a non-empty array
|
|
880
|
+
throw new ValidationError("tags must be a non-empty array");
|
|
881
881
|
}
|
|
882
882
|
return this.call(
|
|
883
883
|
"Failed to add document tags",
|
|
@@ -1477,15 +1477,55 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1477
1477
|
() => this.http.put("/signers/accept-terms", void 0, signerAccessConfig(code))
|
|
1478
1478
|
);
|
|
1479
1479
|
}
|
|
1480
|
-
/** `POST /verify` — verify
|
|
1481
|
-
async
|
|
1480
|
+
/** `POST /verify` — verify an email or WhatsApp OTP for a signer. */
|
|
1481
|
+
async verifyCode(payload) {
|
|
1482
1482
|
const code = this.requireId(payload.signerAccessCode, "signer-access-code");
|
|
1483
1483
|
const otp = this.requireId(payload.verificationCode, "verification-code");
|
|
1484
1484
|
return this.call(
|
|
1485
|
-
"Failed to verify signer
|
|
1485
|
+
"Failed to verify signer code",
|
|
1486
1486
|
() => this.http.post("/verify", { "verification-code": otp }, signerAccessConfig(code))
|
|
1487
1487
|
);
|
|
1488
1488
|
}
|
|
1489
|
+
/** Compatibility alias for {@link verifyCode}; accepts email and WhatsApp OTPs. */
|
|
1490
|
+
async verifyEmail(payload) {
|
|
1491
|
+
return this.verifyCode(payload);
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* `POST /signers/certificate/start` — start an ICP-Brasil A1/A3 signature.
|
|
1495
|
+
* Returns `{ token }` for the signer's Web PKI client. This production route
|
|
1496
|
+
* is used by Assinafy's signing frontend but is absent from OpenAPI paths.
|
|
1497
|
+
*/
|
|
1498
|
+
async startCertificate(signerAccessCode) {
|
|
1499
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1500
|
+
return this.call(
|
|
1501
|
+
"Failed to start certificate signature",
|
|
1502
|
+
() => this.http.post(
|
|
1503
|
+
"/signers/certificate/start",
|
|
1504
|
+
{ "signer-access-code": code },
|
|
1505
|
+
signerAccessConfig(code)
|
|
1506
|
+
)
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* `POST /signers/certificate/complete` — finish an ICP-Brasil A1/A3 signature.
|
|
1511
|
+
* Pass the same token returned by {@link startCertificate}, after Web PKI
|
|
1512
|
+
* successfully signs it. Returns `{ signerName }`; private keys stay local.
|
|
1513
|
+
* This production route is absent from OpenAPI paths.
|
|
1514
|
+
*/
|
|
1515
|
+
async completeCertificate(signerAccessCode, token) {
|
|
1516
|
+
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1517
|
+
if (typeof token !== "string" || !token.trim()) {
|
|
1518
|
+
throw new ValidationError("Certificate token is required");
|
|
1519
|
+
}
|
|
1520
|
+
return this.call(
|
|
1521
|
+
"Failed to complete certificate signature",
|
|
1522
|
+
() => this.http.post(
|
|
1523
|
+
"/signers/certificate/complete",
|
|
1524
|
+
{ "signer-access-code": code, token },
|
|
1525
|
+
signerAccessConfig(code)
|
|
1526
|
+
)
|
|
1527
|
+
);
|
|
1528
|
+
}
|
|
1489
1529
|
/**
|
|
1490
1530
|
* `PUT /documents/{documentId}/signers/confirm-data?signer-access-code=…`
|
|
1491
1531
|
*
|
|
@@ -1500,6 +1540,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1500
1540
|
for (const [key, value] of Object.entries(payload)) {
|
|
1501
1541
|
if (value !== void 0) body[key] = value;
|
|
1502
1542
|
}
|
|
1543
|
+
await this.requireDocumentAccess(did, code);
|
|
1503
1544
|
return this.call(
|
|
1504
1545
|
"Failed to confirm signer data",
|
|
1505
1546
|
() => this.http.put(`/documents/${did}/signers/confirm-data`, body, signerAccessConfig(code))
|
|
@@ -1552,13 +1593,20 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1552
1593
|
() => this.http.get("/sign", signerAccessConfig(code, { has_accepted_terms: hasAcceptedTerms }))
|
|
1553
1594
|
);
|
|
1554
1595
|
}
|
|
1555
|
-
/**
|
|
1596
|
+
/**
|
|
1597
|
+
* `POST /documents/{documentId}/assignments/{assignmentId}?signer-access-code=…` — sign.
|
|
1598
|
+
* Virtual assignments accept `[]` after the signer confirms their data.
|
|
1599
|
+
*/
|
|
1556
1600
|
async sign(documentId, assignmentId, signerAccessCode, entries) {
|
|
1557
1601
|
const did = this.requireId(documentId, "Document ID");
|
|
1558
1602
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
1559
1603
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1560
|
-
if (!Array.isArray(entries)
|
|
1561
|
-
throw new ValidationError("entries must be
|
|
1604
|
+
if (!Array.isArray(entries)) {
|
|
1605
|
+
throw new ValidationError("entries must be an array");
|
|
1606
|
+
}
|
|
1607
|
+
const document = await this.requireDocumentAccess(did, code, aid);
|
|
1608
|
+
if (document.assignment?.method === "collect" && entries.length === 0) {
|
|
1609
|
+
throw new ValidationError("entries must be non-empty for collect assignments");
|
|
1562
1610
|
}
|
|
1563
1611
|
return this.call(
|
|
1564
1612
|
"Failed to sign document",
|
|
@@ -1574,6 +1622,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1574
1622
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
1575
1623
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
1576
1624
|
validateDeclineReason(declineReason);
|
|
1625
|
+
await this.requireDocumentAccess(did, code, aid);
|
|
1577
1626
|
return this.call(
|
|
1578
1627
|
"Failed to decline assignment",
|
|
1579
1628
|
() => this.http.put(
|
|
@@ -1583,6 +1632,13 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
1583
1632
|
)
|
|
1584
1633
|
);
|
|
1585
1634
|
}
|
|
1635
|
+
async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
|
|
1636
|
+
const document = await this.getAssignment(signerAccessCode);
|
|
1637
|
+
if (document.id !== documentId || assignmentId !== void 0 && document.assignment?.id !== assignmentId) {
|
|
1638
|
+
throw new ValidationError("Signer access code does not match the document or assignment");
|
|
1639
|
+
}
|
|
1640
|
+
return document;
|
|
1641
|
+
}
|
|
1586
1642
|
};
|
|
1587
1643
|
function validateDeclineReason(value) {
|
|
1588
1644
|
if (typeof value !== "string" || !value.trim()) {
|