@assinafy/sdk 2.8.0 → 2.8.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/CHANGELOG.md +13 -1
- package/README.en.md +20 -8
- package/README.md +16 -7
- package/dist/index.d.mts +47 -19
- package/dist/index.d.ts +47 -19
- package/dist/index.js +49 -16
- package/dist/index.mjs +48 -16
- package/docs/COMPATIBILITY.md +14 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.8.1] - 2026-10-19
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Reject `DigitalCertificate` signers unless an assignment is explicitly
|
|
15
|
+
`virtual`, before direct creation or cost estimation can invite or charge for
|
|
16
|
+
an unusable `collect` assignment. Template creation and estimation reject
|
|
17
|
+
certificate signers until the API enforces its server-derived method. All
|
|
18
|
+
paths expose the stable
|
|
19
|
+
`digital_certificate_requires_virtual_method` validation code.
|
|
20
|
+
|
|
10
21
|
## [2.8.0] - 2026-10-16
|
|
11
22
|
|
|
12
23
|
### Added
|
|
@@ -834,7 +845,8 @@ signer fields with `cpf` and `whatsapp_phone_number`.
|
|
|
834
845
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
835
846
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
836
847
|
|
|
837
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.8.
|
|
848
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.8.1...HEAD
|
|
849
|
+
[2.8.1]: https://github.com/assinafy/typescript-sdk/compare/v2.8.0...v2.8.1
|
|
838
850
|
[2.8.0]: https://github.com/assinafy/typescript-sdk/releases/tag/v2.8.0
|
|
839
851
|
[2.7.1]: https://github.com/assinafy/typescript-sdk/compare/v2.7.0...v2.7.1
|
|
840
852
|
[2.7.0]: https://github.com/assinafy/typescript-sdk/compare/v2.6.0...v2.7.0
|
package/README.en.md
CHANGED
|
@@ -908,7 +908,7 @@ to `Email`.
|
|
|
908
908
|
| --- | --- | --- | --- |
|
|
909
909
|
| `Email` *(default)* | One-time code (OTP) by email | `Email` | Free |
|
|
910
910
|
| `Whatsapp` | One-time code (OTP) by WhatsApp | `Whatsapp` | 0.45 credit (the notification), paid plans only |
|
|
911
|
-
| `DigitalCertificate` | The signer signs with their **own ICP-Brasil certificate — A1 or A3 —** through the Web PKI extension, producing a **qualified PAdES signature
|
|
911
|
+
| `DigitalCertificate` | The signer signs with their **own ICP-Brasil certificate — A1 or A3 —** through the Web PKI extension, producing a **qualified PAdES signature**; requires `method: 'virtual'` | `Email` **or** `Whatsapp` | 0.5 credits + the notification |
|
|
912
912
|
| `IdDocumentFaceMatchBasic` | Hosted identity-document, face and liveness verification | `Email` **or** `Whatsapp` | Use `estimateCost()` |
|
|
913
913
|
|
|
914
914
|
Exactly one notification method per signer. The SDK rejects an invalid
|
|
@@ -954,10 +954,19 @@ forward them outside the signing flow.
|
|
|
954
954
|
|
|
955
955
|
#### ICP-Brasil digital certificate
|
|
956
956
|
|
|
957
|
-
`DigitalCertificate` requires the account feature, a CPF
|
|
958
|
-
signer's `government_id`, and exactly one certificate signer in
|
|
959
|
-
step. It costs 0.5 credits per certificate signer in addition to
|
|
960
|
-
notification cost.
|
|
957
|
+
`DigitalCertificate` requires `method: 'virtual'`, the account feature, a CPF
|
|
958
|
+
or CNPJ in the signer's `government_id`, and exactly one certificate signer in
|
|
959
|
+
that signing step. It costs 0.5 credits per certificate signer in addition to
|
|
960
|
+
the selected notification cost. A certificate flow completes the signer's
|
|
961
|
+
virtual item; it cannot submit placed fields through the ordinary `collect`
|
|
962
|
+
signing endpoint.
|
|
963
|
+
|
|
964
|
+
The SDK rejects certificate signers on a `collect` assignment in both
|
|
965
|
+
`create()` and `estimateCost()` before any request. Branch on
|
|
966
|
+
`ValidationError.errors.code ===
|
|
967
|
+
'digital_certificate_requires_virtual_method'`, or compare it with the
|
|
968
|
+
exported `DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD` constant; do not match
|
|
969
|
+
the human-readable message.
|
|
961
970
|
|
|
962
971
|
**A1 and A3 are certificate media**, chosen by the signer in their browser at
|
|
963
972
|
signing time: A1 lives in software (a file on the machine) and A3 in hardware
|
|
@@ -1047,9 +1056,12 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
1047
1056
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
1048
1057
|
```
|
|
1049
1058
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1059
|
+
The server derives a template assignment's method from its placed fields, and
|
|
1060
|
+
currently accepts certificate signers even when that produces an unusable
|
|
1061
|
+
`collect` assignment. Until the API enforces the virtual-only rule atomically,
|
|
1062
|
+
the SDK rejects `DigitalCertificate` in both `createFromTemplate()` and
|
|
1063
|
+
`estimateCostFromTemplate()` with the same stable validation code. Create a
|
|
1064
|
+
direct `virtual` assignment for certificate signers instead.
|
|
1053
1065
|
|
|
1054
1066
|
Template creation only uploads the PDF and provisions the default editor role —
|
|
1055
1067
|
configure roles/fields in the Assinafy editor (or the web UI) afterwards.
|
package/README.md
CHANGED
|
@@ -868,7 +868,7 @@ que faltar é inferido. Sem nenhum dos dois, ambos assumem `Email`.
|
|
|
868
868
|
| --- | --- | --- | --- |
|
|
869
869
|
| `Email` *(padrão)* | Código de uso único (OTP) por e-mail | `Email` | Gratuito |
|
|
870
870
|
| `Whatsapp` | Código de uso único (OTP) por WhatsApp | `Whatsapp` | 0,45 crédito (a notificação), só em planos pagos |
|
|
871
|
-
| `DigitalCertificate` | O signatário assina com o **próprio certificado ICP-Brasil — A1 ou A3 —** pela extensão Web PKI, gerando uma assinatura **PAdES qualificada
|
|
871
|
+
| `DigitalCertificate` | O signatário assina com o **próprio certificado ICP-Brasil — A1 ou A3 —** pela extensão Web PKI, gerando uma assinatura **PAdES qualificada**; exige `method: 'virtual'` | `Email` **ou** `Whatsapp` | 0,5 crédito + a notificação |
|
|
872
872
|
| `IdDocumentFaceMatchBasic` | Documento de identidade, foto e prova de vida em sessão hospedada | `Email` **ou** `Whatsapp` | Consulte `estimateCost()` |
|
|
873
873
|
|
|
874
874
|
Apenas um método de notificação por signatário. O SDK recusa uma combinação inválida antes da
|
|
@@ -913,9 +913,16 @@ nem encaminhe fora do fluxo de assinatura.
|
|
|
913
913
|
|
|
914
914
|
#### Certificado digital ICP-Brasil
|
|
915
915
|
|
|
916
|
-
`DigitalCertificate` exige o recurso **Certificado Digital** na conta (planos
|
|
917
|
-
CNPJ em `government_id` do signatário, e exatamente **um signatário por
|
|
918
|
-
assinatura**. Custa 0,5 crédito por signatário, além do custo da
|
|
916
|
+
`DigitalCertificate` exige `method: 'virtual'`, o recurso **Certificado Digital** na conta (planos
|
|
917
|
+
Standard e Pro), CPF ou CNPJ em `government_id` do signatário, e exatamente **um signatário por
|
|
918
|
+
certificado naquele passo de assinatura**. Custa 0,5 crédito por signatário, além do custo da
|
|
919
|
+
notificação escolhida. O fluxo por certificado conclui o item virtual do signatário; ele não consegue
|
|
920
|
+
enviar campos posicionados pelo endpoint comum de assinatura `collect`.
|
|
921
|
+
|
|
922
|
+
O SDK rejeita signatários por certificado em assignments `collect`, tanto em `create()` quanto em
|
|
923
|
+
`estimateCost()`, antes de qualquer requisição. Ramifique por
|
|
924
|
+
`ValidationError.errors.code === 'digital_certificate_requires_virtual_method'`, ou compare com a
|
|
925
|
+
constante exportada `DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD`; não dependa da mensagem legível.
|
|
919
926
|
|
|
920
927
|
**A1 e A3 são mídias de certificado**, escolhidas pelo próprio signatário no navegador na hora de
|
|
921
928
|
assinar: A1 fica em software (um arquivo na máquina) e A3 em hardware (token ou cartão). A API
|
|
@@ -1015,9 +1022,11 @@ await client.documents.estimateCostFromTemplate(templateId, [
|
|
|
1015
1022
|
// has_sufficient_resources: true, blocking_reason: null, breakdown: [], … }
|
|
1016
1023
|
```
|
|
1017
1024
|
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1025
|
+
O servidor deduz o método do assignment de template a partir dos campos posicionados e hoje aceita
|
|
1026
|
+
signatários por certificado mesmo quando isso cria um assignment `collect` impossível de concluir.
|
|
1027
|
+
Até a API impor atomicamente a regra de método virtual, o SDK rejeita `DigitalCertificate` tanto em
|
|
1028
|
+
`createFromTemplate()` quanto em `estimateCostFromTemplate()`, com o mesmo código estável. Para
|
|
1029
|
+
certificados, crie diretamente um assignment `virtual`.
|
|
1021
1030
|
|
|
1022
1031
|
Criar um template apenas envia o PDF e provisiona o papel de editor padrão — configure papéis e
|
|
1023
1032
|
campos no editor da Assinafy depois. Os `download_url` dos objetos de página do template são URLs
|
package/dist/index.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ type AssignmentMethod = 'virtual' | 'collect';
|
|
|
29
29
|
* | --- | --- | --- | --- |
|
|
30
30
|
* | `Email` | One-time code sent by e-mail (the default). | An `email`. | 0 credits |
|
|
31
31
|
* | `Whatsapp` | One-time code sent over WhatsApp. | A `whatsapp_phone_number`; paid plan. | 0.45 credits |
|
|
32
|
-
* | `DigitalCertificate` | The signer signs with their own ICP-Brasil certificate — **A1** (software, a file on the machine) or **A3** (hardware, a token or smartcard) — through the Web PKI browser extension, producing a qualified PAdES signature. | Digital Certificate feature (Standard/Pro); `government_id`; the signer must be alone in their signing step. | 0.5 credits + notification |
|
|
32
|
+
* | `DigitalCertificate` | The signer signs with their own ICP-Brasil certificate — **A1** (software, a file on the machine) or **A3** (hardware, a token or smartcard) — through the Web PKI browser extension, producing a qualified PAdES signature. | `method: 'virtual'`; Digital Certificate feature (Standard/Pro); `government_id`; the signer must be alone in their signing step. | 0.5 credits + notification |
|
|
33
33
|
* | `IdDocumentFaceMatchBasic` | Hosted identity-document and face verification, with explicit biometric consent. | ID Document + Face Match feature; valid CPF in `government_id`; account approval for any `InReview` result before certification. | Use cost estimation for current pricing. |
|
|
34
34
|
*
|
|
35
35
|
* A1 and A3 are certificate *media*, chosen by the signer in their browser at
|
|
@@ -310,6 +310,7 @@ type ISignerListResponse = PaginatedResult<ISigner>;
|
|
|
310
310
|
type SignerReference = string | {
|
|
311
311
|
id?: string;
|
|
312
312
|
signer_id?: string;
|
|
313
|
+
/** `DigitalCertificate` is valid only when the assignment method is `virtual`. */
|
|
313
314
|
verification_method?: AssignmentVerificationMethod;
|
|
314
315
|
notification_methods?: AssignmentNotificationMethod[];
|
|
315
316
|
/**
|
|
@@ -381,7 +382,7 @@ interface IAssignmentEntry {
|
|
|
381
382
|
display_settings?: IDisplaySettings;
|
|
382
383
|
}>;
|
|
383
384
|
}
|
|
384
|
-
/** Channel descriptor accepted by assignment cost estimation. */
|
|
385
|
+
/** Channel descriptor accepted by assignment cost estimation. `DigitalCertificate` requires `method: 'virtual'`. */
|
|
385
386
|
interface IAssignmentCostSigner {
|
|
386
387
|
verification_method?: AssignmentVerificationMethod;
|
|
387
388
|
notification_methods?: AssignmentNotificationMethod[];
|
|
@@ -1039,7 +1040,13 @@ interface ITemplateDetailsResponse {
|
|
|
1039
1040
|
updated_at?: string;
|
|
1040
1041
|
[key: string]: unknown;
|
|
1041
1042
|
}
|
|
1042
|
-
/**
|
|
1043
|
+
/**
|
|
1044
|
+
* Signer assignment for creating a document from a template.
|
|
1045
|
+
*
|
|
1046
|
+
* The SDK temporarily rejects `DigitalCertificate` because the server derives
|
|
1047
|
+
* the method from template fields and can create an unusable `collect`
|
|
1048
|
+
* assignment. Use a direct `virtual` assignment for certificate signers.
|
|
1049
|
+
*/
|
|
1043
1050
|
interface ITemplateSigner {
|
|
1044
1051
|
role_id: string;
|
|
1045
1052
|
id: string;
|
|
@@ -1050,7 +1057,9 @@ interface ITemplateSigner {
|
|
|
1050
1057
|
}
|
|
1051
1058
|
/**
|
|
1052
1059
|
* Role/channel descriptor used only for template cost estimation. The official
|
|
1053
|
-
* schema intentionally omits signer `id` and sequential-signing `step`.
|
|
1060
|
+
* schema intentionally omits signer `id` and sequential-signing `step`. The SDK
|
|
1061
|
+
* temporarily rejects `DigitalCertificate`; use direct virtual-assignment cost
|
|
1062
|
+
* estimation instead.
|
|
1054
1063
|
*/
|
|
1055
1064
|
interface ITemplateCostSigner {
|
|
1056
1065
|
role_id: string;
|
|
@@ -2198,7 +2207,10 @@ declare class DocumentResource extends BaseResource {
|
|
|
2198
2207
|
* Only one notification method is allowed per signer; when only one of the
|
|
2199
2208
|
* verification/notification fields is supplied, the API infers the other.
|
|
2200
2209
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2201
|
-
* signer `government_id`, and that signer must be alone in its step.
|
|
2210
|
+
* signer `government_id`, and that signer must be alone in its step. The
|
|
2211
|
+
* server derives the assignment method from placed template fields but
|
|
2212
|
+
* does not yet reject unusable certificate/`collect` combinations, so the
|
|
2213
|
+
* SDK temporarily refuses certificate signers on this template route.
|
|
2202
2214
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2203
2215
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2204
2216
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
@@ -2229,15 +2241,16 @@ declare class DocumentResource extends BaseResource {
|
|
|
2229
2241
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2230
2242
|
* }
|
|
2231
2243
|
* ```
|
|
2232
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2233
|
-
* available
|
|
2244
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2245
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2246
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2234
2247
|
* @throws {ApiError} `400` if the signers/roles are invalid or the template
|
|
2235
2248
|
* is not ready.
|
|
2236
2249
|
*
|
|
2237
2250
|
* @example
|
|
2238
2251
|
* ```ts
|
|
2239
2252
|
* await client.documents.createFromTemplate('tmpl_id', [
|
|
2240
|
-
* { role_id: 'role_id', id: 'signer_id', verification_method: '
|
|
2253
|
+
* { role_id: 'role_id', id: 'signer_id', verification_method: 'Email' },
|
|
2241
2254
|
* ], { name: 'My Contract' });
|
|
2242
2255
|
* ```
|
|
2243
2256
|
*/
|
|
@@ -2248,8 +2261,10 @@ declare class DocumentResource extends BaseResource {
|
|
|
2248
2261
|
*
|
|
2249
2262
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2250
2263
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2251
|
-
* `DigitalCertificate`
|
|
2252
|
-
*
|
|
2264
|
+
* `DigitalCertificate` requires a provably `virtual` assignment. Because
|
|
2265
|
+
* this route leaves method detection to the server, the SDK temporarily
|
|
2266
|
+
* refuses certificate signers instead of returning a price for an
|
|
2267
|
+
* assignment that may charge credits but cannot be completed.
|
|
2253
2268
|
*
|
|
2254
2269
|
* Request body (`application/json`):
|
|
2255
2270
|
* ```jsonc
|
|
@@ -2291,14 +2306,15 @@ declare class DocumentResource extends BaseResource {
|
|
|
2291
2306
|
* "message": null
|
|
2292
2307
|
* }
|
|
2293
2308
|
* ```
|
|
2294
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2295
|
-
* available
|
|
2309
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2310
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2311
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2296
2312
|
* @throws {ApiError} If the API rejects the request.
|
|
2297
2313
|
*
|
|
2298
2314
|
* @example
|
|
2299
2315
|
* ```ts
|
|
2300
2316
|
* const estimate = await client.documents.estimateCostFromTemplate('tmpl_id', [
|
|
2301
|
-
* { role_id: 'role_id', verification_method: '
|
|
2317
|
+
* { role_id: 'role_id', verification_method: 'Email' },
|
|
2302
2318
|
* ]);
|
|
2303
2319
|
* if (!estimate.has_sufficient_resources) throw new Error(estimate.blocking_reason ?? 'insufficient');
|
|
2304
2320
|
* ```
|
|
@@ -3069,6 +3085,8 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
3069
3085
|
}): Promise<void>;
|
|
3070
3086
|
}
|
|
3071
3087
|
|
|
3088
|
+
/** Stable {@link ValidationError.errors} code for an unusable certificate assignment. */
|
|
3089
|
+
declare const DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
|
|
3072
3090
|
/**
|
|
3073
3091
|
* Normalize a public assignment input into the exact create-request body.
|
|
3074
3092
|
* String IDs and legacy `signer_id` aliases become signer objects, omitted
|
|
@@ -3079,7 +3097,9 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
3079
3097
|
* @returns A JSON-ready body shaped as
|
|
3080
3098
|
* `{ method, signers: [{ id, verification_method?, notification_methods?, step? }], message?, expires_at?, copy_receivers?, entries? }`.
|
|
3081
3099
|
* @throws {ValidationError} If no signer is present, a signer reference is
|
|
3082
|
-
* malformed,
|
|
3100
|
+
* malformed, a collect assignment has no field-placement entries, or a
|
|
3101
|
+
* `DigitalCertificate` signer is combined with `method: 'collect'`. The last
|
|
3102
|
+
* case has `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
3083
3103
|
*
|
|
3084
3104
|
* @example
|
|
3085
3105
|
* ```ts
|
|
@@ -3194,7 +3214,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3194
3214
|
* `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
|
|
3195
3215
|
* automatically; `collect` requires rendered pages at `metadata_ready`.
|
|
3196
3216
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
3197
|
-
* signer `government_id`,
|
|
3217
|
+
* signer `government_id`, that signer must be alone in its step, and the
|
|
3218
|
+
* assignment must use `method: 'virtual'`. Certificate completion marks a
|
|
3219
|
+
* virtual item complete; it cannot submit placed `collect` fields.
|
|
3198
3220
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
3199
3221
|
* and a valid CPF in the signer's `government_id`; estimate its fee first.
|
|
3200
3222
|
*
|
|
@@ -3294,7 +3316,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3294
3316
|
* }
|
|
3295
3317
|
* ```
|
|
3296
3318
|
* @throws {ValidationError} If `documentId` is missing, no signer is
|
|
3297
|
-
* supplied,
|
|
3319
|
+
* supplied, a signer reference is invalid, or `DigitalCertificate` is
|
|
3320
|
+
* combined with `collect`. The last case has `errors.code ===
|
|
3321
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
3298
3322
|
* @throws {ApiError} `400` for an invalid assignment or unmet verification
|
|
3299
3323
|
* precondition; otherwise if the API rejects the request.
|
|
3300
3324
|
*
|
|
@@ -3318,7 +3342,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3318
3342
|
* default Email channel). {@link buildAssignmentEstimatePayload} projects
|
|
3319
3343
|
* exactly the fields permitted by the estimate schema.
|
|
3320
3344
|
* `DigitalCertificate` is priced at 0.5 credits per signer and remains
|
|
3321
|
-
* subject to the feature
|
|
3345
|
+
* subject to the feature and identity requirements. It is valid only with
|
|
3346
|
+
* `method: 'virtual'`; the SDK refuses to quote a certificate/`collect`
|
|
3347
|
+
* request because that assignment cannot be completed.
|
|
3322
3348
|
* Current documented unit prices are 1 credit for an extra document, 0 for
|
|
3323
3349
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
3324
3350
|
* certificate charge is added on top of its notification cost.
|
|
@@ -3363,7 +3389,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3363
3389
|
* ```
|
|
3364
3390
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
3365
3391
|
* has no signer entry, or a `collect` request has no signer entry or no
|
|
3366
|
-
* field-placement entry
|
|
3392
|
+
* field-placement entry, or combines `DigitalCertificate` with `collect`.
|
|
3393
|
+
* The last case has `errors.code ===
|
|
3394
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
3367
3395
|
* @throws {ApiError} If the API rejects the request.
|
|
3368
3396
|
*
|
|
3369
3397
|
* @example
|
|
@@ -7692,4 +7720,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
|
|
|
7692
7720
|
|
|
7693
7721
|
declare const SDK_USER_AGENT: string;
|
|
7694
7722
|
|
|
7695
|
-
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|
|
7723
|
+
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ type AssignmentMethod = 'virtual' | 'collect';
|
|
|
29
29
|
* | --- | --- | --- | --- |
|
|
30
30
|
* | `Email` | One-time code sent by e-mail (the default). | An `email`. | 0 credits |
|
|
31
31
|
* | `Whatsapp` | One-time code sent over WhatsApp. | A `whatsapp_phone_number`; paid plan. | 0.45 credits |
|
|
32
|
-
* | `DigitalCertificate` | The signer signs with their own ICP-Brasil certificate — **A1** (software, a file on the machine) or **A3** (hardware, a token or smartcard) — through the Web PKI browser extension, producing a qualified PAdES signature. | Digital Certificate feature (Standard/Pro); `government_id`; the signer must be alone in their signing step. | 0.5 credits + notification |
|
|
32
|
+
* | `DigitalCertificate` | The signer signs with their own ICP-Brasil certificate — **A1** (software, a file on the machine) or **A3** (hardware, a token or smartcard) — through the Web PKI browser extension, producing a qualified PAdES signature. | `method: 'virtual'`; Digital Certificate feature (Standard/Pro); `government_id`; the signer must be alone in their signing step. | 0.5 credits + notification |
|
|
33
33
|
* | `IdDocumentFaceMatchBasic` | Hosted identity-document and face verification, with explicit biometric consent. | ID Document + Face Match feature; valid CPF in `government_id`; account approval for any `InReview` result before certification. | Use cost estimation for current pricing. |
|
|
34
34
|
*
|
|
35
35
|
* A1 and A3 are certificate *media*, chosen by the signer in their browser at
|
|
@@ -310,6 +310,7 @@ type ISignerListResponse = PaginatedResult<ISigner>;
|
|
|
310
310
|
type SignerReference = string | {
|
|
311
311
|
id?: string;
|
|
312
312
|
signer_id?: string;
|
|
313
|
+
/** `DigitalCertificate` is valid only when the assignment method is `virtual`. */
|
|
313
314
|
verification_method?: AssignmentVerificationMethod;
|
|
314
315
|
notification_methods?: AssignmentNotificationMethod[];
|
|
315
316
|
/**
|
|
@@ -381,7 +382,7 @@ interface IAssignmentEntry {
|
|
|
381
382
|
display_settings?: IDisplaySettings;
|
|
382
383
|
}>;
|
|
383
384
|
}
|
|
384
|
-
/** Channel descriptor accepted by assignment cost estimation. */
|
|
385
|
+
/** Channel descriptor accepted by assignment cost estimation. `DigitalCertificate` requires `method: 'virtual'`. */
|
|
385
386
|
interface IAssignmentCostSigner {
|
|
386
387
|
verification_method?: AssignmentVerificationMethod;
|
|
387
388
|
notification_methods?: AssignmentNotificationMethod[];
|
|
@@ -1039,7 +1040,13 @@ interface ITemplateDetailsResponse {
|
|
|
1039
1040
|
updated_at?: string;
|
|
1040
1041
|
[key: string]: unknown;
|
|
1041
1042
|
}
|
|
1042
|
-
/**
|
|
1043
|
+
/**
|
|
1044
|
+
* Signer assignment for creating a document from a template.
|
|
1045
|
+
*
|
|
1046
|
+
* The SDK temporarily rejects `DigitalCertificate` because the server derives
|
|
1047
|
+
* the method from template fields and can create an unusable `collect`
|
|
1048
|
+
* assignment. Use a direct `virtual` assignment for certificate signers.
|
|
1049
|
+
*/
|
|
1043
1050
|
interface ITemplateSigner {
|
|
1044
1051
|
role_id: string;
|
|
1045
1052
|
id: string;
|
|
@@ -1050,7 +1057,9 @@ interface ITemplateSigner {
|
|
|
1050
1057
|
}
|
|
1051
1058
|
/**
|
|
1052
1059
|
* Role/channel descriptor used only for template cost estimation. The official
|
|
1053
|
-
* schema intentionally omits signer `id` and sequential-signing `step`.
|
|
1060
|
+
* schema intentionally omits signer `id` and sequential-signing `step`. The SDK
|
|
1061
|
+
* temporarily rejects `DigitalCertificate`; use direct virtual-assignment cost
|
|
1062
|
+
* estimation instead.
|
|
1054
1063
|
*/
|
|
1055
1064
|
interface ITemplateCostSigner {
|
|
1056
1065
|
role_id: string;
|
|
@@ -2198,7 +2207,10 @@ declare class DocumentResource extends BaseResource {
|
|
|
2198
2207
|
* Only one notification method is allowed per signer; when only one of the
|
|
2199
2208
|
* verification/notification fields is supplied, the API infers the other.
|
|
2200
2209
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2201
|
-
* signer `government_id`, and that signer must be alone in its step.
|
|
2210
|
+
* signer `government_id`, and that signer must be alone in its step. The
|
|
2211
|
+
* server derives the assignment method from placed template fields but
|
|
2212
|
+
* does not yet reject unusable certificate/`collect` combinations, so the
|
|
2213
|
+
* SDK temporarily refuses certificate signers on this template route.
|
|
2202
2214
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2203
2215
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2204
2216
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
@@ -2229,15 +2241,16 @@ declare class DocumentResource extends BaseResource {
|
|
|
2229
2241
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2230
2242
|
* }
|
|
2231
2243
|
* ```
|
|
2232
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2233
|
-
* available
|
|
2244
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2245
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2246
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2234
2247
|
* @throws {ApiError} `400` if the signers/roles are invalid or the template
|
|
2235
2248
|
* is not ready.
|
|
2236
2249
|
*
|
|
2237
2250
|
* @example
|
|
2238
2251
|
* ```ts
|
|
2239
2252
|
* await client.documents.createFromTemplate('tmpl_id', [
|
|
2240
|
-
* { role_id: 'role_id', id: 'signer_id', verification_method: '
|
|
2253
|
+
* { role_id: 'role_id', id: 'signer_id', verification_method: 'Email' },
|
|
2241
2254
|
* ], { name: 'My Contract' });
|
|
2242
2255
|
* ```
|
|
2243
2256
|
*/
|
|
@@ -2248,8 +2261,10 @@ declare class DocumentResource extends BaseResource {
|
|
|
2248
2261
|
*
|
|
2249
2262
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2250
2263
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2251
|
-
* `DigitalCertificate`
|
|
2252
|
-
*
|
|
2264
|
+
* `DigitalCertificate` requires a provably `virtual` assignment. Because
|
|
2265
|
+
* this route leaves method detection to the server, the SDK temporarily
|
|
2266
|
+
* refuses certificate signers instead of returning a price for an
|
|
2267
|
+
* assignment that may charge credits but cannot be completed.
|
|
2253
2268
|
*
|
|
2254
2269
|
* Request body (`application/json`):
|
|
2255
2270
|
* ```jsonc
|
|
@@ -2291,14 +2306,15 @@ declare class DocumentResource extends BaseResource {
|
|
|
2291
2306
|
* "message": null
|
|
2292
2307
|
* }
|
|
2293
2308
|
* ```
|
|
2294
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2295
|
-
* available
|
|
2309
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2310
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2311
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2296
2312
|
* @throws {ApiError} If the API rejects the request.
|
|
2297
2313
|
*
|
|
2298
2314
|
* @example
|
|
2299
2315
|
* ```ts
|
|
2300
2316
|
* const estimate = await client.documents.estimateCostFromTemplate('tmpl_id', [
|
|
2301
|
-
* { role_id: 'role_id', verification_method: '
|
|
2317
|
+
* { role_id: 'role_id', verification_method: 'Email' },
|
|
2302
2318
|
* ]);
|
|
2303
2319
|
* if (!estimate.has_sufficient_resources) throw new Error(estimate.blocking_reason ?? 'insufficient');
|
|
2304
2320
|
* ```
|
|
@@ -3069,6 +3085,8 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
3069
3085
|
}): Promise<void>;
|
|
3070
3086
|
}
|
|
3071
3087
|
|
|
3088
|
+
/** Stable {@link ValidationError.errors} code for an unusable certificate assignment. */
|
|
3089
|
+
declare const DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
|
|
3072
3090
|
/**
|
|
3073
3091
|
* Normalize a public assignment input into the exact create-request body.
|
|
3074
3092
|
* String IDs and legacy `signer_id` aliases become signer objects, omitted
|
|
@@ -3079,7 +3097,9 @@ declare class WorkspaceResource extends BaseResource {
|
|
|
3079
3097
|
* @returns A JSON-ready body shaped as
|
|
3080
3098
|
* `{ method, signers: [{ id, verification_method?, notification_methods?, step? }], message?, expires_at?, copy_receivers?, entries? }`.
|
|
3081
3099
|
* @throws {ValidationError} If no signer is present, a signer reference is
|
|
3082
|
-
* malformed,
|
|
3100
|
+
* malformed, a collect assignment has no field-placement entries, or a
|
|
3101
|
+
* `DigitalCertificate` signer is combined with `method: 'collect'`. The last
|
|
3102
|
+
* case has `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
3083
3103
|
*
|
|
3084
3104
|
* @example
|
|
3085
3105
|
* ```ts
|
|
@@ -3194,7 +3214,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3194
3214
|
* `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
|
|
3195
3215
|
* automatically; `collect` requires rendered pages at `metadata_ready`.
|
|
3196
3216
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
3197
|
-
* signer `government_id`,
|
|
3217
|
+
* signer `government_id`, that signer must be alone in its step, and the
|
|
3218
|
+
* assignment must use `method: 'virtual'`. Certificate completion marks a
|
|
3219
|
+
* virtual item complete; it cannot submit placed `collect` fields.
|
|
3198
3220
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
3199
3221
|
* and a valid CPF in the signer's `government_id`; estimate its fee first.
|
|
3200
3222
|
*
|
|
@@ -3294,7 +3316,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3294
3316
|
* }
|
|
3295
3317
|
* ```
|
|
3296
3318
|
* @throws {ValidationError} If `documentId` is missing, no signer is
|
|
3297
|
-
* supplied,
|
|
3319
|
+
* supplied, a signer reference is invalid, or `DigitalCertificate` is
|
|
3320
|
+
* combined with `collect`. The last case has `errors.code ===
|
|
3321
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
3298
3322
|
* @throws {ApiError} `400` for an invalid assignment or unmet verification
|
|
3299
3323
|
* precondition; otherwise if the API rejects the request.
|
|
3300
3324
|
*
|
|
@@ -3318,7 +3342,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3318
3342
|
* default Email channel). {@link buildAssignmentEstimatePayload} projects
|
|
3319
3343
|
* exactly the fields permitted by the estimate schema.
|
|
3320
3344
|
* `DigitalCertificate` is priced at 0.5 credits per signer and remains
|
|
3321
|
-
* subject to the feature
|
|
3345
|
+
* subject to the feature and identity requirements. It is valid only with
|
|
3346
|
+
* `method: 'virtual'`; the SDK refuses to quote a certificate/`collect`
|
|
3347
|
+
* request because that assignment cannot be completed.
|
|
3322
3348
|
* Current documented unit prices are 1 credit for an extra document, 0 for
|
|
3323
3349
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
3324
3350
|
* certificate charge is added on top of its notification cost.
|
|
@@ -3363,7 +3389,9 @@ declare class AssignmentResource extends BaseResource {
|
|
|
3363
3389
|
* ```
|
|
3364
3390
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
3365
3391
|
* has no signer entry, or a `collect` request has no signer entry or no
|
|
3366
|
-
* field-placement entry
|
|
3392
|
+
* field-placement entry, or combines `DigitalCertificate` with `collect`.
|
|
3393
|
+
* The last case has `errors.code ===
|
|
3394
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
3367
3395
|
* @throws {ApiError} If the API rejects the request.
|
|
3368
3396
|
*
|
|
3369
3397
|
* @example
|
|
@@ -7692,4 +7720,4 @@ declare const MAX_LIST_PAGE_SIZE = 50;
|
|
|
7692
7720
|
|
|
7693
7721
|
declare const SDK_USER_AGENT: string;
|
|
7694
7722
|
|
|
7695
|
-
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|
|
7723
|
+
export { type AccountLogoUploadSource, type AnyString, ApiError, type AssignmentDisplaySettings, type AssignmentMethod, type AssignmentNotificationMethod, AssignmentResource, type AssignmentVerificationMethod, AssinafyClient, type AssinafyClientOptions, AssinafyError, AuthenticationResource, type ClientConfigInput, DEFAULT_WEBHOOK_EVENTS, DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD, type DocumentArtifactName, DocumentResource, type DocumentStatsGranularity, type DocumentStatus, type DocumentUploadSource, FieldsResource, type IAccountTheme, type IApiKeyResponse, type IAssignment, type IAssignmentCostSigner, type IAssignmentEntry, type IAssignmentItem, type IAssignmentListParams, type IAssignmentListResponse, type IAssignmentSigner, type IAuthenticateChallenge, type IAuthenticatedUser, type IConfirmSignerDataPayload, type IConfirmTotpPayload, type ICostEstimate, type ICreateAssignmentPayload, type ICreateAssignmentResponse, type ICreateDocumentFromTemplateOptions, type ICreateFieldPayload, type ICreateSignerPayload, type ICreateSignerResponse, type ICreateTagPayload, type ICreateWorkspacePayload, type IDeleteTagResponse, type IDetachDocumentTagResponse, type IDisplaySettings, type IDocumentActivity, type IDocumentDetailsResponse, type IDocumentListItem, type IDocumentListParams, type IDocumentListResponse, type IDocumentSearchParams, type IDocumentStatsParams, type IDocumentStatsRow, type IDocumentStatusInfo, type IDocumentUploadOptions, type IDocumentUploadResponse, type IDocumentVerification, type IEstimateAssignmentCostPayload, type IFieldDefinition, type IFieldType, type IFieldValidateMultipleEntry, type IFieldValidationMultipleResult, type IFieldValidationResponse, type IFieldValidationResult, type IInlineTag, type ILegacyConfirmSignerDataPayload, type ILegacyResendCostEstimate, type ILegacyUploadSignatureOptions, type IListParams, type ILoginResponse, type IMaskedApiKeyResponse, type IMfaMethod, type IMfaReauth, type IMfaRecoveryCodes, type IMfaStatus, type INotificationHistoryEntry, type INotificationPreferences, type IOAuthAuthorizationCallback, type IOAuthAuthorizationRequest, type IOAuthAuthorizationServerMetadata, type IOAuthProtectedResourceMetadata, type IOAuthTokenResponse, type IOAuthUserInfo, type IPage, type IPaginatedResponse, type IPublicDocumentInfo, type IRateLimitInfo, type IRenameDocumentResponse, type IResendCostEstimate, type IResendEmailResponse, type IReviewIdentityVerificationPayload, type ISendTokenResult, type ISignFieldEntry, type ISigner, type ISignerIdentityReview, type ISignerIdentityVerification, type ISignerIdentityVerificationSession, type ISignerListParams, type ISignerListResponse, type ISignerSelf, type ISigningProgress, type IStartIdentityVerificationPayload, type ITag, type ITemplateCostSigner, type ITemplateDetailsResponse, type ITemplateFieldPlacement, type ITemplateListItem, type ITemplateListParams, type ITemplateListResponse, type ITemplateRole, type ITemplateSigner, type ITotpEnrollment, type IUpdateFieldPayload, type IUpdateNotificationPreferences, type IUpdateSignerPayload, type IUpdateTagPayload, type IUpdateTemplatePayload, type IUpdateWorkspacePayload, type IUploadAndRequestSignaturesResult, type IUploadAndRequestSignaturesSigner, type IUploadSignatureOptions, type IWebhookDispatch, type IWebhookDispatchListParams, type IWebhookEndpoint, type IWebhookEndpointCreatePayload, type IWebhookEndpointCreateResponse, type IWebhookEndpointSecret, type IWebhookEndpointUpdatePayload, type IWebhookEventTypeInfo, type IWebhookPayload, type IWebhookRegisterPayload, type IWebhookSubscription, type IWhatsAppNotification, type IWorkspaceListItem, type IWorkspaceListResponse, type IWorkspaceResponse, type IdentityVerificationImageName, type IdentityVerificationStatus, type Logger, MAX_LIST_PAGE_SIZE, MAX_UPLOAD_BYTES, NetworkError, type NotificationSenderType, OAuthError, OAuthResource, type OAuthScope, type PaginatedResult, type PaginationMeta, SDK_USER_AGENT, type SendTokenChannel, type SignatureImageType, SignerDocumentsResource, type SignerReference, SignerResource, TagResource, TemplateResource, UserResource, ValidationError, type WebhookEventType, type WebhookHeaders, WebhookResource, WebhookVerifier, WorkspaceResource, buildAssignmentPayload, parseWwwAuthenticate };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
AssinafyError: () => AssinafyError,
|
|
37
37
|
AuthenticationResource: () => AuthenticationResource,
|
|
38
38
|
DEFAULT_WEBHOOK_EVENTS: () => DEFAULT_WEBHOOK_EVENTS,
|
|
39
|
+
DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD: () => DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
39
40
|
DocumentResource: () => DocumentResource,
|
|
40
41
|
FieldsResource: () => FieldsResource,
|
|
41
42
|
MAX_LIST_PAGE_SIZE: () => MAX_LIST_PAGE_SIZE,
|
|
@@ -688,7 +689,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
688
689
|
// package.json
|
|
689
690
|
var package_default = {
|
|
690
691
|
name: "@assinafy/sdk",
|
|
691
|
-
version: "2.8.
|
|
692
|
+
version: "2.8.1",
|
|
692
693
|
packageManager: "bun@1.4.0",
|
|
693
694
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
694
695
|
type: "commonjs",
|
|
@@ -1036,6 +1037,7 @@ function toInt(value) {
|
|
|
1036
1037
|
var ASSIGNMENT_METHODS = /* @__PURE__ */ new Set(["virtual", "collect"]);
|
|
1037
1038
|
var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate", "IdDocumentFaceMatchBasic"]);
|
|
1038
1039
|
var NOTIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp"]);
|
|
1040
|
+
var DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
|
|
1039
1041
|
var ALLOWED_NOTIFICATION_METHODS = {
|
|
1040
1042
|
Email: /* @__PURE__ */ new Set(["Email"]),
|
|
1041
1043
|
Whatsapp: /* @__PURE__ */ new Set(["Whatsapp"]),
|
|
@@ -1090,6 +1092,15 @@ function validateSigningOrder(signers, label = "signers") {
|
|
|
1090
1092
|
}
|
|
1091
1093
|
}
|
|
1092
1094
|
}
|
|
1095
|
+
function validateDigitalCertificateMethod(method, signers) {
|
|
1096
|
+
if (method === "virtual" || !signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
1100
|
+
code: DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
1101
|
+
method: method ?? null
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1093
1104
|
function buildAssignmentPayload(payload) {
|
|
1094
1105
|
assertRecord(payload, "assignment payload");
|
|
1095
1106
|
const method = payload.method ?? "virtual";
|
|
@@ -1118,6 +1129,7 @@ function buildAssignmentPayload(payload) {
|
|
|
1118
1129
|
throw new ValidationError("copy_receivers must be an array of non-empty signer IDs");
|
|
1119
1130
|
}
|
|
1120
1131
|
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref));
|
|
1132
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1121
1133
|
validateSigningOrder(normalisedSigners, "assignment signers");
|
|
1122
1134
|
return cleanParams({
|
|
1123
1135
|
method,
|
|
@@ -1142,9 +1154,11 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1142
1154
|
if (method === "collect" && (!entries || entries.length === 0)) {
|
|
1143
1155
|
throw new ValidationError("At least one field-placement entry is required for a collect cost estimate");
|
|
1144
1156
|
}
|
|
1157
|
+
const normalisedSigners = signers.map((signer) => normaliseEstimateSigner(signer));
|
|
1158
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1145
1159
|
return cleanParams({
|
|
1146
1160
|
method,
|
|
1147
|
-
signers:
|
|
1161
|
+
signers: normalisedSigners,
|
|
1148
1162
|
entries
|
|
1149
1163
|
});
|
|
1150
1164
|
}
|
|
@@ -1381,7 +1395,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1381
1395
|
* `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
|
|
1382
1396
|
* automatically; `collect` requires rendered pages at `metadata_ready`.
|
|
1383
1397
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
1384
|
-
* signer `government_id`,
|
|
1398
|
+
* signer `government_id`, that signer must be alone in its step, and the
|
|
1399
|
+
* assignment must use `method: 'virtual'`. Certificate completion marks a
|
|
1400
|
+
* virtual item complete; it cannot submit placed `collect` fields.
|
|
1385
1401
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
1386
1402
|
* and a valid CPF in the signer's `government_id`; estimate its fee first.
|
|
1387
1403
|
*
|
|
@@ -1481,7 +1497,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1481
1497
|
* }
|
|
1482
1498
|
* ```
|
|
1483
1499
|
* @throws {ValidationError} If `documentId` is missing, no signer is
|
|
1484
|
-
* supplied,
|
|
1500
|
+
* supplied, a signer reference is invalid, or `DigitalCertificate` is
|
|
1501
|
+
* combined with `collect`. The last case has `errors.code ===
|
|
1502
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1485
1503
|
* @throws {ApiError} `400` for an invalid assignment or unmet verification
|
|
1486
1504
|
* precondition; otherwise if the API rejects the request.
|
|
1487
1505
|
*
|
|
@@ -1520,7 +1538,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1520
1538
|
* default Email channel). {@link buildAssignmentEstimatePayload} projects
|
|
1521
1539
|
* exactly the fields permitted by the estimate schema.
|
|
1522
1540
|
* `DigitalCertificate` is priced at 0.5 credits per signer and remains
|
|
1523
|
-
* subject to the feature
|
|
1541
|
+
* subject to the feature and identity requirements. It is valid only with
|
|
1542
|
+
* `method: 'virtual'`; the SDK refuses to quote a certificate/`collect`
|
|
1543
|
+
* request because that assignment cannot be completed.
|
|
1524
1544
|
* Current documented unit prices are 1 credit for an extra document, 0 for
|
|
1525
1545
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1526
1546
|
* certificate charge is added on top of its notification cost.
|
|
@@ -1565,7 +1585,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1565
1585
|
* ```
|
|
1566
1586
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
1567
1587
|
* has no signer entry, or a `collect` request has no signer entry or no
|
|
1568
|
-
* field-placement entry
|
|
1588
|
+
* field-placement entry, or combines `DigitalCertificate` with `collect`.
|
|
1589
|
+
* The last case has `errors.code ===
|
|
1590
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1569
1591
|
* @throws {ApiError} If the API rejects the request.
|
|
1570
1592
|
*
|
|
1571
1593
|
* @example
|
|
@@ -2759,7 +2781,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2759
2781
|
* Only one notification method is allowed per signer; when only one of the
|
|
2760
2782
|
* verification/notification fields is supplied, the API infers the other.
|
|
2761
2783
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2762
|
-
* signer `government_id`, and that signer must be alone in its step.
|
|
2784
|
+
* signer `government_id`, and that signer must be alone in its step. The
|
|
2785
|
+
* server derives the assignment method from placed template fields but
|
|
2786
|
+
* does not yet reject unusable certificate/`collect` combinations, so the
|
|
2787
|
+
* SDK temporarily refuses certificate signers on this template route.
|
|
2763
2788
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2764
2789
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2765
2790
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
@@ -2790,15 +2815,16 @@ var DocumentResource = class extends BaseResource {
|
|
|
2790
2815
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2791
2816
|
* }
|
|
2792
2817
|
* ```
|
|
2793
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2794
|
-
* available
|
|
2818
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2819
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2820
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2795
2821
|
* @throws {ApiError} `400` if the signers/roles are invalid or the template
|
|
2796
2822
|
* is not ready.
|
|
2797
2823
|
*
|
|
2798
2824
|
* @example
|
|
2799
2825
|
* ```ts
|
|
2800
2826
|
* await client.documents.createFromTemplate('tmpl_id', [
|
|
2801
|
-
* { role_id: 'role_id', id: 'signer_id', verification_method: '
|
|
2827
|
+
* { role_id: 'role_id', id: 'signer_id', verification_method: 'Email' },
|
|
2802
2828
|
* ], { name: 'My Contract' });
|
|
2803
2829
|
* ```
|
|
2804
2830
|
*/
|
|
@@ -2840,8 +2866,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2840
2866
|
*
|
|
2841
2867
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2842
2868
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2843
|
-
* `DigitalCertificate`
|
|
2844
|
-
*
|
|
2869
|
+
* `DigitalCertificate` requires a provably `virtual` assignment. Because
|
|
2870
|
+
* this route leaves method detection to the server, the SDK temporarily
|
|
2871
|
+
* refuses certificate signers instead of returning a price for an
|
|
2872
|
+
* assignment that may charge credits but cannot be completed.
|
|
2845
2873
|
*
|
|
2846
2874
|
* Request body (`application/json`):
|
|
2847
2875
|
* ```jsonc
|
|
@@ -2883,14 +2911,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2883
2911
|
* "message": null
|
|
2884
2912
|
* }
|
|
2885
2913
|
* ```
|
|
2886
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2887
|
-
* available
|
|
2914
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2915
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2916
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2888
2917
|
* @throws {ApiError} If the API rejects the request.
|
|
2889
2918
|
*
|
|
2890
2919
|
* @example
|
|
2891
2920
|
* ```ts
|
|
2892
2921
|
* const estimate = await client.documents.estimateCostFromTemplate('tmpl_id', [
|
|
2893
|
-
* { role_id: 'role_id', verification_method: '
|
|
2922
|
+
* { role_id: 'role_id', verification_method: 'Email' },
|
|
2894
2923
|
* ]);
|
|
2895
2924
|
* if (!estimate.has_sufficient_resources) throw new Error(estimate.blocking_reason ?? 'insufficient');
|
|
2896
2925
|
* ```
|
|
@@ -3179,6 +3208,7 @@ function normaliseTemplateSigners(signers) {
|
|
|
3179
3208
|
if (signer.step !== void 0) projected.step = signer.step;
|
|
3180
3209
|
return projected;
|
|
3181
3210
|
});
|
|
3211
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
3182
3212
|
return normalised;
|
|
3183
3213
|
}
|
|
3184
3214
|
function normaliseTemplateEditorFields(fields) {
|
|
@@ -3202,7 +3232,7 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3202
3232
|
if (!Array.isArray(signers) || signers.length === 0) {
|
|
3203
3233
|
throw new ValidationError("At least one template role is required for cost estimation");
|
|
3204
3234
|
}
|
|
3205
|
-
|
|
3235
|
+
const normalised = signers.map((signer, index) => {
|
|
3206
3236
|
if (!signer || typeof signer !== "object") {
|
|
3207
3237
|
throw new ValidationError(`Template cost signer ${index + 1} is invalid`);
|
|
3208
3238
|
}
|
|
@@ -3219,6 +3249,8 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3219
3249
|
}
|
|
3220
3250
|
return descriptor;
|
|
3221
3251
|
});
|
|
3252
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
3253
|
+
return normalised;
|
|
3222
3254
|
}
|
|
3223
3255
|
function validateWaitOption(value, name) {
|
|
3224
3256
|
if (!Number.isFinite(value) || value < 0 || name === "pollIntervalMs" && value === 0) {
|
|
@@ -9051,6 +9083,7 @@ function hasIdempotencyKey(headers) {
|
|
|
9051
9083
|
AssinafyError,
|
|
9052
9084
|
AuthenticationResource,
|
|
9053
9085
|
DEFAULT_WEBHOOK_EVENTS,
|
|
9086
|
+
DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
9054
9087
|
DocumentResource,
|
|
9055
9088
|
FieldsResource,
|
|
9056
9089
|
MAX_LIST_PAGE_SIZE,
|
package/dist/index.mjs
CHANGED
|
@@ -628,7 +628,7 @@ import axios2 from "axios";
|
|
|
628
628
|
// package.json
|
|
629
629
|
var package_default = {
|
|
630
630
|
name: "@assinafy/sdk",
|
|
631
|
-
version: "2.8.
|
|
631
|
+
version: "2.8.1",
|
|
632
632
|
packageManager: "bun@1.4.0",
|
|
633
633
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
634
634
|
type: "commonjs",
|
|
@@ -976,6 +976,7 @@ function toInt(value) {
|
|
|
976
976
|
var ASSIGNMENT_METHODS = /* @__PURE__ */ new Set(["virtual", "collect"]);
|
|
977
977
|
var VERIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp", "DigitalCertificate", "IdDocumentFaceMatchBasic"]);
|
|
978
978
|
var NOTIFICATION_METHODS = /* @__PURE__ */ new Set(["Email", "Whatsapp"]);
|
|
979
|
+
var DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD = "digital_certificate_requires_virtual_method";
|
|
979
980
|
var ALLOWED_NOTIFICATION_METHODS = {
|
|
980
981
|
Email: /* @__PURE__ */ new Set(["Email"]),
|
|
981
982
|
Whatsapp: /* @__PURE__ */ new Set(["Whatsapp"]),
|
|
@@ -1030,6 +1031,15 @@ function validateSigningOrder(signers, label = "signers") {
|
|
|
1030
1031
|
}
|
|
1031
1032
|
}
|
|
1032
1033
|
}
|
|
1034
|
+
function validateDigitalCertificateMethod(method, signers) {
|
|
1035
|
+
if (method === "virtual" || !signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
throw new ValidationError("DigitalCertificate signers require method: virtual", {
|
|
1039
|
+
code: DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
1040
|
+
method: method ?? null
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1033
1043
|
function buildAssignmentPayload(payload) {
|
|
1034
1044
|
assertRecord(payload, "assignment payload");
|
|
1035
1045
|
const method = payload.method ?? "virtual";
|
|
@@ -1058,6 +1068,7 @@ function buildAssignmentPayload(payload) {
|
|
|
1058
1068
|
throw new ValidationError("copy_receivers must be an array of non-empty signer IDs");
|
|
1059
1069
|
}
|
|
1060
1070
|
const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref));
|
|
1071
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1061
1072
|
validateSigningOrder(normalisedSigners, "assignment signers");
|
|
1062
1073
|
return cleanParams({
|
|
1063
1074
|
method,
|
|
@@ -1082,9 +1093,11 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1082
1093
|
if (method === "collect" && (!entries || entries.length === 0)) {
|
|
1083
1094
|
throw new ValidationError("At least one field-placement entry is required for a collect cost estimate");
|
|
1084
1095
|
}
|
|
1096
|
+
const normalisedSigners = signers.map((signer) => normaliseEstimateSigner(signer));
|
|
1097
|
+
validateDigitalCertificateMethod(method, normalisedSigners);
|
|
1085
1098
|
return cleanParams({
|
|
1086
1099
|
method,
|
|
1087
|
-
signers:
|
|
1100
|
+
signers: normalisedSigners,
|
|
1088
1101
|
entries
|
|
1089
1102
|
});
|
|
1090
1103
|
}
|
|
@@ -1321,7 +1334,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1321
1334
|
* `uploaded`, `metadata_processing`, or `metadata_ready` and is promoted
|
|
1322
1335
|
* automatically; `collect` requires rendered pages at `metadata_ready`.
|
|
1323
1336
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
1324
|
-
* signer `government_id`,
|
|
1337
|
+
* signer `government_id`, that signer must be alone in its step, and the
|
|
1338
|
+
* assignment must use `method: 'virtual'`. Certificate completion marks a
|
|
1339
|
+
* virtual item complete; it cannot submit placed `collect` fields.
|
|
1325
1340
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
1326
1341
|
* and a valid CPF in the signer's `government_id`; estimate its fee first.
|
|
1327
1342
|
*
|
|
@@ -1421,7 +1436,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1421
1436
|
* }
|
|
1422
1437
|
* ```
|
|
1423
1438
|
* @throws {ValidationError} If `documentId` is missing, no signer is
|
|
1424
|
-
* supplied,
|
|
1439
|
+
* supplied, a signer reference is invalid, or `DigitalCertificate` is
|
|
1440
|
+
* combined with `collect`. The last case has `errors.code ===
|
|
1441
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1425
1442
|
* @throws {ApiError} `400` for an invalid assignment or unmet verification
|
|
1426
1443
|
* precondition; otherwise if the API rejects the request.
|
|
1427
1444
|
*
|
|
@@ -1460,7 +1477,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1460
1477
|
* default Email channel). {@link buildAssignmentEstimatePayload} projects
|
|
1461
1478
|
* exactly the fields permitted by the estimate schema.
|
|
1462
1479
|
* `DigitalCertificate` is priced at 0.5 credits per signer and remains
|
|
1463
|
-
* subject to the feature
|
|
1480
|
+
* subject to the feature and identity requirements. It is valid only with
|
|
1481
|
+
* `method: 'virtual'`; the SDK refuses to quote a certificate/`collect`
|
|
1482
|
+
* request because that assignment cannot be completed.
|
|
1464
1483
|
* Current documented unit prices are 1 credit for an extra document, 0 for
|
|
1465
1484
|
* email notification, and 0.45 for WhatsApp notification; a digital
|
|
1466
1485
|
* certificate charge is added on top of its notification cost.
|
|
@@ -1505,7 +1524,9 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1505
1524
|
* ```
|
|
1506
1525
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
1507
1526
|
* has no signer entry, or a `collect` request has no signer entry or no
|
|
1508
|
-
* field-placement entry
|
|
1527
|
+
* field-placement entry, or combines `DigitalCertificate` with `collect`.
|
|
1528
|
+
* The last case has `errors.code ===
|
|
1529
|
+
* 'digital_certificate_requires_virtual_method'`.
|
|
1509
1530
|
* @throws {ApiError} If the API rejects the request.
|
|
1510
1531
|
*
|
|
1511
1532
|
* @example
|
|
@@ -2699,7 +2720,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2699
2720
|
* Only one notification method is allowed per signer; when only one of the
|
|
2700
2721
|
* verification/notification fields is supplied, the API infers the other.
|
|
2701
2722
|
* `DigitalCertificate` costs 0.5 credits, requires the feature plus a
|
|
2702
|
-
* signer `government_id`, and that signer must be alone in its step.
|
|
2723
|
+
* signer `government_id`, and that signer must be alone in its step. The
|
|
2724
|
+
* server derives the assignment method from placed template fields but
|
|
2725
|
+
* does not yet reject unusable certificate/`collect` combinations, so the
|
|
2726
|
+
* SDK temporarily refuses certificate signers on this template route.
|
|
2703
2727
|
* `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
|
|
2704
2728
|
* and a valid CPF in `government_id`; estimate the per-signer fee first.
|
|
2705
2729
|
* @param options - Optional `name`, `message`, `expires_at`,
|
|
@@ -2730,15 +2754,16 @@ var DocumentResource = class extends BaseResource {
|
|
|
2730
2754
|
* "updated_at": "2026-07-15T19:59:33Z"
|
|
2731
2755
|
* }
|
|
2732
2756
|
* ```
|
|
2733
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2734
|
-
* available
|
|
2757
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2758
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2759
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2735
2760
|
* @throws {ApiError} `400` if the signers/roles are invalid or the template
|
|
2736
2761
|
* is not ready.
|
|
2737
2762
|
*
|
|
2738
2763
|
* @example
|
|
2739
2764
|
* ```ts
|
|
2740
2765
|
* await client.documents.createFromTemplate('tmpl_id', [
|
|
2741
|
-
* { role_id: 'role_id', id: 'signer_id', verification_method: '
|
|
2766
|
+
* { role_id: 'role_id', id: 'signer_id', verification_method: 'Email' },
|
|
2742
2767
|
* ], { name: 'My Contract' });
|
|
2743
2768
|
* ```
|
|
2744
2769
|
*/
|
|
@@ -2780,8 +2805,10 @@ var DocumentResource = class extends BaseResource {
|
|
|
2780
2805
|
*
|
|
2781
2806
|
* A dry run: sends only `{ signers }` and consumes nothing. Use it to check
|
|
2782
2807
|
* balances before calling {@link DocumentResource.createFromTemplate}.
|
|
2783
|
-
* `DigitalCertificate`
|
|
2784
|
-
*
|
|
2808
|
+
* `DigitalCertificate` requires a provably `virtual` assignment. Because
|
|
2809
|
+
* this route leaves method detection to the server, the SDK temporarily
|
|
2810
|
+
* refuses certificate signers instead of returning a price for an
|
|
2811
|
+
* assignment that may charge credits but cannot be completed.
|
|
2785
2812
|
*
|
|
2786
2813
|
* Request body (`application/json`):
|
|
2787
2814
|
* ```jsonc
|
|
@@ -2823,14 +2850,15 @@ var DocumentResource = class extends BaseResource {
|
|
|
2823
2850
|
* "message": null
|
|
2824
2851
|
* }
|
|
2825
2852
|
* ```
|
|
2826
|
-
* @throws {ValidationError} If `templateId` is missing
|
|
2827
|
-
* available
|
|
2853
|
+
* @throws {ValidationError} If `templateId` is missing, no account ID is
|
|
2854
|
+
* available, or a signer uses `DigitalCertificate`. Certificate refusals
|
|
2855
|
+
* have `errors.code === 'digital_certificate_requires_virtual_method'`.
|
|
2828
2856
|
* @throws {ApiError} If the API rejects the request.
|
|
2829
2857
|
*
|
|
2830
2858
|
* @example
|
|
2831
2859
|
* ```ts
|
|
2832
2860
|
* const estimate = await client.documents.estimateCostFromTemplate('tmpl_id', [
|
|
2833
|
-
* { role_id: 'role_id', verification_method: '
|
|
2861
|
+
* { role_id: 'role_id', verification_method: 'Email' },
|
|
2834
2862
|
* ]);
|
|
2835
2863
|
* if (!estimate.has_sufficient_resources) throw new Error(estimate.blocking_reason ?? 'insufficient');
|
|
2836
2864
|
* ```
|
|
@@ -3119,6 +3147,7 @@ function normaliseTemplateSigners(signers) {
|
|
|
3119
3147
|
if (signer.step !== void 0) projected.step = signer.step;
|
|
3120
3148
|
return projected;
|
|
3121
3149
|
});
|
|
3150
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
3122
3151
|
return normalised;
|
|
3123
3152
|
}
|
|
3124
3153
|
function normaliseTemplateEditorFields(fields) {
|
|
@@ -3142,7 +3171,7 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3142
3171
|
if (!Array.isArray(signers) || signers.length === 0) {
|
|
3143
3172
|
throw new ValidationError("At least one template role is required for cost estimation");
|
|
3144
3173
|
}
|
|
3145
|
-
|
|
3174
|
+
const normalised = signers.map((signer, index) => {
|
|
3146
3175
|
if (!signer || typeof signer !== "object") {
|
|
3147
3176
|
throw new ValidationError(`Template cost signer ${index + 1} is invalid`);
|
|
3148
3177
|
}
|
|
@@ -3159,6 +3188,8 @@ function normaliseTemplateCostSigners(signers) {
|
|
|
3159
3188
|
}
|
|
3160
3189
|
return descriptor;
|
|
3161
3190
|
});
|
|
3191
|
+
validateDigitalCertificateMethod(void 0, normalised);
|
|
3192
|
+
return normalised;
|
|
3162
3193
|
}
|
|
3163
3194
|
function validateWaitOption(value, name) {
|
|
3164
3195
|
if (!Number.isFinite(value) || value < 0 || name === "pollIntervalMs" && value === 0) {
|
|
@@ -8990,6 +9021,7 @@ export {
|
|
|
8990
9021
|
AssinafyError,
|
|
8991
9022
|
AuthenticationResource,
|
|
8992
9023
|
DEFAULT_WEBHOOK_EVENTS,
|
|
9024
|
+
DIGITAL_CERTIFICATE_REQUIRES_VIRTUAL_METHOD,
|
|
8993
9025
|
DocumentResource,
|
|
8994
9026
|
FieldsResource,
|
|
8995
9027
|
MAX_LIST_PAGE_SIZE,
|
package/docs/COMPATIBILITY.md
CHANGED
|
@@ -43,8 +43,9 @@ They map to `auth.getSocialLoginUrl()` and
|
|
|
43
43
|
The SDK also includes the production contract additions for:
|
|
44
44
|
|
|
45
45
|
- the `pades` document artifact;
|
|
46
|
-
- `DigitalCertificate` verification on assignment and
|
|
47
|
-
|
|
46
|
+
- `DigitalCertificate` verification on virtual assignment creation and cost
|
|
47
|
+
estimation (template calls remain typed but are temporarily rejected because
|
|
48
|
+
the server derives their method);
|
|
48
49
|
- typed `display_settings` for collect fields;
|
|
49
50
|
- signer `government_id` updates;
|
|
50
51
|
- signature-image `reuse`;
|
|
@@ -281,11 +282,20 @@ responses do not return it.
|
|
|
281
282
|
`DigitalCertificate` requires the account feature, a CPF or CNPJ stored in the
|
|
282
283
|
signer's `government_id`, and exactly one certificate signer in that signing
|
|
283
284
|
step. It costs 0.5 credits per signer in addition to the selected notification
|
|
284
|
-
cost. Notification methods remain `Email` and `Whatsapp`.
|
|
285
|
+
cost. Notification methods remain `Email` and `Whatsapp`. It also requires
|
|
286
|
+
`method: virtual`: certificate completion completes a virtual item, while the
|
|
287
|
+
ordinary field-signing endpoint refuses certificate signers. The SDK rejects a
|
|
288
|
+
certificate/`collect` combination before assignment creation or cost
|
|
289
|
+
estimation with `ValidationError.errors.code` set to
|
|
290
|
+
`digital_certificate_requires_virtual_method`.
|
|
285
291
|
|
|
286
292
|
Template role IDs do not reveal which entries are signers, editors or copy
|
|
287
293
|
receivers. The SDK validates each entry's channel and positive `step`, then
|
|
288
|
-
lets the API enforce role-aware signing order
|
|
294
|
+
lets the API enforce role-aware signing order. The server also derives the
|
|
295
|
+
assignment method from placed template fields but does not yet reject an
|
|
296
|
+
unusable certificate/`collect` result. Until it does, the SDK refuses
|
|
297
|
+
`DigitalCertificate` on both template-document creation and cost estimation
|
|
298
|
+
with the same stable code; use a direct virtual assignment instead.
|
|
289
299
|
|
|
290
300
|
## Identity document and face verification
|
|
291
301
|
|