@assinafy/sdk 2.4.2 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -20
- package/README.en.md +72 -14
- package/README.md +15 -10
- package/SECURITY.md +6 -5
- package/dist/index.d.mts +160 -38
- package/dist/index.d.ts +160 -38
- package/dist/index.js +167 -62
- package/dist/index.mjs +167 -62
- package/docs/API_COVERAGE.md +11 -0
- package/docs/COMPATIBILITY.md +4 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -140,7 +140,9 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
140
140
|
* ones with no structured body to explain them. Anything else falls back to
|
|
141
141
|
* the stable message.
|
|
142
142
|
* @returns An `ApiError` retaining the original response body in
|
|
143
|
-
* {@link ApiError.responseData}
|
|
143
|
+
* {@link ApiError.responseData}. A JSON `message` is used verbatim; only an
|
|
144
|
+
* unstructured text body is whitespace-collapsed and truncated for
|
|
145
|
+
* legibility.
|
|
144
146
|
*
|
|
145
147
|
* @example
|
|
146
148
|
* ```ts
|
|
@@ -193,6 +195,16 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
193
195
|
* @param error - Any thrown value.
|
|
194
196
|
* @returns An `OAuthError` when the body carries a non-empty string
|
|
195
197
|
* `error`, else the original value.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const apiError = ApiError.fromResponse(400, {
|
|
202
|
+
* error: 'invalid_grant',
|
|
203
|
+
* error_description: 'The provided authorization grant is invalid.',
|
|
204
|
+
* });
|
|
205
|
+
* const upgraded = OAuthError.upgrade(apiError);
|
|
206
|
+
* // upgraded instanceof OAuthError → true, .error → 'invalid_grant'
|
|
207
|
+
* ```
|
|
196
208
|
*/
|
|
197
209
|
static upgrade(error) {
|
|
198
210
|
if (!(error instanceof ApiError) || error instanceof _OAuthError) return error;
|
|
@@ -634,7 +646,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
634
646
|
// package.json
|
|
635
647
|
var package_default = {
|
|
636
648
|
name: "@assinafy/sdk",
|
|
637
|
-
version: "2.
|
|
649
|
+
version: "2.5.1",
|
|
638
650
|
packageManager: "bun@1.4.0",
|
|
639
651
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
640
652
|
type: "commonjs",
|
|
@@ -1440,11 +1452,11 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1440
1452
|
* @param documentId - The document the assignment would be created on.
|
|
1441
1453
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
1442
1454
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
1443
|
-
* of this request schema.
|
|
1444
|
-
* `InsufficientDocuments`, or `InsufficientCredits`.
|
|
1455
|
+
* of this request schema.
|
|
1445
1456
|
* @returns an {@link ICostEstimate} with `total_credits`, balances, a
|
|
1446
|
-
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1447
|
-
*
|
|
1457
|
+
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1458
|
+
* `blocking_reason` may be `PendingPayment`, `InsufficientDocuments`, or
|
|
1459
|
+
* `InsufficientCredits`. Response shape:
|
|
1448
1460
|
* ```jsonc
|
|
1449
1461
|
* {
|
|
1450
1462
|
* "documents": 1,
|
|
@@ -1997,8 +2009,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1997
2009
|
* "updated_at": "2026-07-19T17:24:46Z"
|
|
1998
2010
|
* }
|
|
1999
2011
|
* ```
|
|
2000
|
-
* @throws {ValidationError} If `documentId` is missing
|
|
2001
|
-
* not one of the five documented artifact names.
|
|
2012
|
+
* @throws {ValidationError} If `documentId` is missing.
|
|
2002
2013
|
* @throws {ApiError} `404` if the document does not exist.
|
|
2003
2014
|
*
|
|
2004
2015
|
* @example
|
|
@@ -2582,6 +2593,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2582
2593
|
* {
|
|
2583
2594
|
* "hash": "FE32EDDADE7CBDDCBB934E7402047450B0E59C02",
|
|
2584
2595
|
* "id": "63ddb172402799bfc991d10d",
|
|
2596
|
+
* "agreement_code": "550E8400-E29B-41D4-A716-446655440000", // printed on the certificate
|
|
2585
2597
|
* "status": "certificated",
|
|
2586
2598
|
* "page_count": "1",
|
|
2587
2599
|
* "signer_count": "1",
|
|
@@ -2717,7 +2729,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2717
2729
|
}
|
|
2718
2730
|
}
|
|
2719
2731
|
/**
|
|
2720
|
-
* Quick boolean check: has every signer
|
|
2732
|
+
* Quick boolean check (`GET /documents/{documentId}`): has every signer
|
|
2733
|
+
* completed their assignment?
|
|
2721
2734
|
*
|
|
2722
2735
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2723
2736
|
* /documents/{documentId}`). Returns `true` when the document status is
|
|
@@ -2747,7 +2760,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2747
2760
|
return false;
|
|
2748
2761
|
}
|
|
2749
2762
|
/**
|
|
2750
|
-
* Summarise signing progress for UI display
|
|
2763
|
+
* Summarise signing progress for UI display
|
|
2764
|
+
* (`GET /documents/{documentId}`).
|
|
2751
2765
|
*
|
|
2752
2766
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2753
2767
|
* /documents/{documentId}`). `total` and `signed` come from the assignment
|
|
@@ -3731,7 +3745,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3731
3745
|
events: [...payload.events && payload.events.length > 0 ? payload.events : DEFAULT_WEBHOOK_EVENTS],
|
|
3732
3746
|
is_active: payload.is_active ?? true
|
|
3733
3747
|
};
|
|
3734
|
-
this.logger.info("Registering webhook"
|
|
3748
|
+
this.logger.info("Registering webhook");
|
|
3735
3749
|
return this.call(
|
|
3736
3750
|
"Failed to register webhook",
|
|
3737
3751
|
() => this.http.put(
|
|
@@ -4589,7 +4603,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4589
4603
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4590
4604
|
* "user": {
|
|
4591
4605
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4592
|
-
* "name": "
|
|
4606
|
+
* "name": "Empresa Exemplo",
|
|
4593
4607
|
* "email": "user@example.com",
|
|
4594
4608
|
* "telephone": null,
|
|
4595
4609
|
* "government_id": "",
|
|
@@ -4601,7 +4615,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4601
4615
|
* "accounts": [
|
|
4602
4616
|
* {
|
|
4603
4617
|
* "id": "acc_example",
|
|
4604
|
-
* "name": "
|
|
4618
|
+
* "name": "Empresa Exemplo",
|
|
4605
4619
|
* "roles": ["Owner"],
|
|
4606
4620
|
* "is_delete_allowed": true,
|
|
4607
4621
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4647,7 +4661,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4647
4661
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4648
4662
|
* "user": {
|
|
4649
4663
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4650
|
-
* "name": "
|
|
4664
|
+
* "name": "Empresa Exemplo",
|
|
4651
4665
|
* "email": "user@example.com",
|
|
4652
4666
|
* "telephone": null,
|
|
4653
4667
|
* "government_id": "",
|
|
@@ -4659,7 +4673,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4659
4673
|
* "accounts": [
|
|
4660
4674
|
* {
|
|
4661
4675
|
* "id": "acc_example",
|
|
4662
|
-
* "name": "
|
|
4676
|
+
* "name": "Empresa Exemplo",
|
|
4663
4677
|
* "roles": ["Owner"],
|
|
4664
4678
|
* "is_delete_allowed": true,
|
|
4665
4679
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4965,6 +4979,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4965
4979
|
var import_node_crypto = require("crypto");
|
|
4966
4980
|
var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
4967
4981
|
var AUTHORIZATION_SERVER_PATH = "/.well-known/oauth-authorization-server";
|
|
4982
|
+
var ASSINAFY_ISSUER = "https://auth.assinafy.com.br";
|
|
4968
4983
|
var CODE_VERIFIER_PATTERN = /^[A-Za-z0-9\-._~]{43,128}$/u;
|
|
4969
4984
|
var OAuthResource = class extends BaseResource {
|
|
4970
4985
|
publicHttp;
|
|
@@ -5197,8 +5212,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5197
5212
|
*
|
|
5198
5213
|
* The `iss` check is strict because the authorization server advertises
|
|
5199
5214
|
* RFC 9207 support and always sends the parameter: a missing `iss` is
|
|
5200
|
-
* treated exactly like a wrong one
|
|
5201
|
-
* something between the browser and your handler strips query parameters.
|
|
5215
|
+
* treated exactly like a wrong one, on success and error responses alike.
|
|
5202
5216
|
*
|
|
5203
5217
|
* This performs no network I/O.
|
|
5204
5218
|
*
|
|
@@ -5206,7 +5220,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5206
5220
|
* `req.query` record, a `URLSearchParams`, a `URL`, a full callback URL
|
|
5207
5221
|
* string, or a bare `a=b&c=d` query string.
|
|
5208
5222
|
* @param expected - The stored {@link IOAuthAuthorizationRequest} (or any
|
|
5209
|
-
* object carrying its `state` and `issuer`).
|
|
5223
|
+
* object carrying its `state` and `issuer`). Without `issuer`, `iss` must
|
|
5224
|
+
* equal `https://auth.assinafy.com.br`; pass the stored one for any other
|
|
5225
|
+
* authorization server, such as the sandbox's.
|
|
5210
5226
|
* @returns The validated response:
|
|
5211
5227
|
* ```jsonc
|
|
5212
5228
|
* {
|
|
@@ -5248,14 +5264,13 @@ var OAuthResource = class extends BaseResource {
|
|
|
5248
5264
|
"OAuth callback state does not match the stored authorization request"
|
|
5249
5265
|
);
|
|
5250
5266
|
}
|
|
5251
|
-
const issuer = query.get("iss")
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
}
|
|
5267
|
+
const issuer = query.get("iss");
|
|
5268
|
+
const expectedIssuer = expected.issuer ?? ASSINAFY_ISSUER;
|
|
5269
|
+
if (issuer === null || normaliseIssuer(issuer) !== normaliseIssuer(expectedIssuer)) {
|
|
5270
|
+
throw new ValidationError(
|
|
5271
|
+
"OAuth callback issuer is missing or does not match the expected issuer",
|
|
5272
|
+
{ expected: expectedIssuer, received: issuer }
|
|
5273
|
+
);
|
|
5259
5274
|
}
|
|
5260
5275
|
const error = query.get("error");
|
|
5261
5276
|
if (error !== null && error.length > 0) {
|
|
@@ -5268,9 +5283,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5268
5283
|
if (code === null || code.length === 0) {
|
|
5269
5284
|
throw new ValidationError("OAuth callback carries neither a code nor an error");
|
|
5270
5285
|
}
|
|
5271
|
-
|
|
5272
|
-
if (issuer !== void 0) result.issuer = issuer;
|
|
5273
|
-
return result;
|
|
5286
|
+
return { code, state, issuer };
|
|
5274
5287
|
}
|
|
5275
5288
|
/**
|
|
5276
5289
|
* Exchange an authorization code for tokens
|
|
@@ -5350,7 +5363,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5350
5363
|
* and re-read your stored token instead of retrying blindly, and never run
|
|
5351
5364
|
* two refreshes concurrently for one connection.
|
|
5352
5365
|
*
|
|
5353
|
-
*
|
|
5366
|
+
* Each returned refresh token is valid for a fresh 30 days, so a connection
|
|
5367
|
+
* only expires if it goes 30 days without a refresh; after that the user
|
|
5368
|
+
* has to reconnect.
|
|
5354
5369
|
*
|
|
5355
5370
|
* @param options - Refresh options.
|
|
5356
5371
|
* @param options.refreshToken - The current refresh token.
|
|
@@ -5358,7 +5373,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5358
5373
|
* @param options.clientSecret - The `client_secret`, for confidential
|
|
5359
5374
|
* applications only.
|
|
5360
5375
|
* @param options.resource - RFC 8707 resource indicator. Defaults to this
|
|
5361
|
-
* API's origin; pass `null` to omit it.
|
|
5376
|
+
* API's origin; pass `null` to omit it. A refresh may repeat the value the
|
|
5377
|
+
* connection was authorized with but never change it (`invalid_target`).
|
|
5362
5378
|
* @returns A fresh token set, identical in shape to
|
|
5363
5379
|
* {@link OAuthResource.exchangeCode}:
|
|
5364
5380
|
* ```jsonc
|
|
@@ -5389,12 +5405,19 @@ var OAuthResource = class extends BaseResource {
|
|
|
5389
5405
|
async refreshToken(options) {
|
|
5390
5406
|
assertRecord(options, "refresh options");
|
|
5391
5407
|
assertNonEmptyString(options.refreshToken, "refreshToken");
|
|
5392
|
-
|
|
5408
|
+
const tokens = await this.requestToken("Failed to refresh the OAuth access token", {
|
|
5393
5409
|
grant_type: "refresh_token",
|
|
5394
5410
|
refresh_token: options.refreshToken,
|
|
5395
5411
|
...this.clientAuth(options),
|
|
5396
5412
|
...this.resourceParam(options.resource)
|
|
5397
5413
|
});
|
|
5414
|
+
if (typeof tokens.refresh_token !== "string" || tokens.refresh_token.length === 0) {
|
|
5415
|
+
throw new ValidationError(
|
|
5416
|
+
"Failed to refresh the OAuth access token: the token endpoint returned no replacement refresh_token; the connection must be re-established",
|
|
5417
|
+
{ fields: Object.keys(tokens) }
|
|
5418
|
+
);
|
|
5419
|
+
}
|
|
5420
|
+
return tokens;
|
|
5398
5421
|
}
|
|
5399
5422
|
/**
|
|
5400
5423
|
* Revoke an access or refresh token (`POST /oauth/revoke`, RFC 7009).
|
|
@@ -5414,14 +5437,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5414
5437
|
* @param options.tokenTypeHint - Optional `access_token` or
|
|
5415
5438
|
* `refresh_token` hint that lets the server skip a lookup.
|
|
5416
5439
|
* @returns Nothing; resolves once the API acknowledges the request.
|
|
5417
|
-
* Request body:
|
|
5418
|
-
* ```
|
|
5419
|
-
*
|
|
5420
|
-
* "token": "def50200f1e2…",
|
|
5421
|
-
* "token_type_hint": "refresh_token",
|
|
5422
|
-
* "client_id": "cli_1a2b3c",
|
|
5423
|
-
* "client_secret": "…"
|
|
5424
|
-
* }
|
|
5440
|
+
* Request body (`application/x-www-form-urlencoded`):
|
|
5441
|
+
* ```text
|
|
5442
|
+
* token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
|
|
5425
5443
|
* ```
|
|
5426
5444
|
* @throws {ValidationError} If `token` or `clientId` is missing, or
|
|
5427
5445
|
* `tokenTypeHint` is not one of the two documented values.
|
|
@@ -5443,7 +5461,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5443
5461
|
if (options.tokenTypeHint !== void 0 && options.tokenTypeHint !== "access_token" && options.tokenTypeHint !== "refresh_token") {
|
|
5444
5462
|
throw new ValidationError("tokenTypeHint must be access_token or refresh_token");
|
|
5445
5463
|
}
|
|
5446
|
-
const body =
|
|
5464
|
+
const body = formBody({
|
|
5447
5465
|
token: options.token,
|
|
5448
5466
|
token_type_hint: options.tokenTypeHint,
|
|
5449
5467
|
...this.clientAuth(options)
|
|
@@ -5504,13 +5522,18 @@ var OAuthResource = class extends BaseResource {
|
|
|
5504
5522
|
})
|
|
5505
5523
|
);
|
|
5506
5524
|
}
|
|
5507
|
-
/**
|
|
5525
|
+
/**
|
|
5526
|
+
* POST the token endpoint once and assert the response carries a token.
|
|
5527
|
+
*
|
|
5528
|
+
* Never retried: the code is single-use, and replaying a refresh token the
|
|
5529
|
+
* server may already have rotated ends the whole connection.
|
|
5530
|
+
*/
|
|
5508
5531
|
async requestToken(label, body) {
|
|
5509
5532
|
let tokens;
|
|
5510
5533
|
try {
|
|
5511
5534
|
tokens = await this.call(
|
|
5512
5535
|
label,
|
|
5513
|
-
() => this.publicHttp.post("/oauth/token",
|
|
5536
|
+
() => this.publicHttp.post("/oauth/token", formBody(body))
|
|
5514
5537
|
);
|
|
5515
5538
|
} catch (error) {
|
|
5516
5539
|
throw OAuthError.upgrade(error);
|
|
@@ -5574,6 +5597,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5574
5597
|
return new URL(baseUrl).origin;
|
|
5575
5598
|
}
|
|
5576
5599
|
};
|
|
5600
|
+
function formBody(fields) {
|
|
5601
|
+
return new URLSearchParams(cleanParams(fields));
|
|
5602
|
+
}
|
|
5577
5603
|
function createCodeVerifier() {
|
|
5578
5604
|
return (0, import_node_crypto.randomBytes)(32).toString("base64url");
|
|
5579
5605
|
}
|
|
@@ -6062,8 +6088,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6062
6088
|
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6063
6089
|
* }
|
|
6064
6090
|
* ```
|
|
6065
|
-
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing
|
|
6066
|
-
* or a supplied `search` value is not a string.
|
|
6091
|
+
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6067
6092
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6068
6093
|
*
|
|
6069
6094
|
* @example
|
|
@@ -6151,7 +6176,29 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6151
6176
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6152
6177
|
* @param search - Free-text term matched against the document name.
|
|
6153
6178
|
* @returns Matching documents for that signer, in the compact
|
|
6154
|
-
* {@link IDocumentListItem} shape, with pagination in `meta
|
|
6179
|
+
* {@link IDocumentListItem} shape, with pagination in `meta`:
|
|
6180
|
+
* ```jsonc
|
|
6181
|
+
* {
|
|
6182
|
+
* "data": [
|
|
6183
|
+
* {
|
|
6184
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6185
|
+
* "account_id": "acc_example",
|
|
6186
|
+
* "template_id": null,
|
|
6187
|
+
* "name": "Service agreement.pdf",
|
|
6188
|
+
* "status": "pending_signature",
|
|
6189
|
+
* "artifacts": { "original": "https://...", "thumbnail": "https://..." },
|
|
6190
|
+
* "is_closed": false,
|
|
6191
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6192
|
+
* "decline_reason": null,
|
|
6193
|
+
* "declined_by": null,
|
|
6194
|
+
* "tags": [],
|
|
6195
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6196
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6197
|
+
* }
|
|
6198
|
+
* ],
|
|
6199
|
+
* "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
|
|
6200
|
+
* }
|
|
6201
|
+
* ```
|
|
6155
6202
|
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6156
6203
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6157
6204
|
*
|
|
@@ -6259,9 +6306,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6259
6306
|
* ```
|
|
6260
6307
|
*/
|
|
6261
6308
|
async signMultiple(documentIds, signerAccessCode) {
|
|
6262
|
-
|
|
6263
|
-
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
6264
|
-
}
|
|
6309
|
+
assertDocumentIds(documentIds);
|
|
6265
6310
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6266
6311
|
return this.callVoid(
|
|
6267
6312
|
"Failed to sign multiple documents",
|
|
@@ -6301,12 +6346,8 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6301
6346
|
* ```
|
|
6302
6347
|
*/
|
|
6303
6348
|
async declineMultiple(documentIds, declineReason, signerAccessCode) {
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
}
|
|
6307
|
-
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
6308
|
-
throw new ValidationError("declineReason is required");
|
|
6309
|
-
}
|
|
6349
|
+
assertDocumentIds(documentIds);
|
|
6350
|
+
assertDeclineReason(declineReason);
|
|
6310
6351
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6311
6352
|
return this.callVoid(
|
|
6312
6353
|
"Failed to decline multiple documents",
|
|
@@ -6537,7 +6578,48 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6537
6578
|
* @returns The document to sign, including its `assignment` (the
|
|
6538
6579
|
* {@link IAssignment} shape: `signers`, `items`, `summary`, `signing_urls`)
|
|
6539
6580
|
* from which the `itemId` / `fieldId` / `pageId` values for
|
|
6540
|
-
* {@link SignerDocumentsResource.sign} are read
|
|
6581
|
+
* {@link SignerDocumentsResource.sign} are read:
|
|
6582
|
+
* ```jsonc
|
|
6583
|
+
* {
|
|
6584
|
+
* "resource": "document",
|
|
6585
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6586
|
+
* "account_id": "acc_example",
|
|
6587
|
+
* "template_id": null,
|
|
6588
|
+
* "name": "Service agreement.pdf",
|
|
6589
|
+
* "status": "pending_signature",
|
|
6590
|
+
* "artifacts": {
|
|
6591
|
+
* "original": "https://api.assinafy.com.br/v1/documents/103acccd.../download/original",
|
|
6592
|
+
* "thumbnail": "https://api.assinafy.com.br/v1/documents/103acccd.../thumbnail"
|
|
6593
|
+
* },
|
|
6594
|
+
* "is_closed": false,
|
|
6595
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6596
|
+
* "decline_reason": null,
|
|
6597
|
+
* "declined_by": null,
|
|
6598
|
+
* "tags": [],
|
|
6599
|
+
* "assignment": {
|
|
6600
|
+
* "id": "1032c55c58bb00a8dc35db916751",
|
|
6601
|
+
* "method": "virtual",
|
|
6602
|
+
* "sender_email": "sender@example.com",
|
|
6603
|
+
* "expires_at": null,
|
|
6604
|
+
* "signers": [
|
|
6605
|
+
* { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
|
|
6606
|
+
* "full_name": "Example Signer", "notified": true, "completed": false }
|
|
6607
|
+
* ],
|
|
6608
|
+
* "items": [
|
|
6609
|
+
* { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
|
|
6610
|
+
* "download_url": "https://..." }, "signer": { "id": "19e6b92e..." },
|
|
6611
|
+
* "field": { "id": "field-1", "type": "signature" }, "value": null, "completed": false }
|
|
6612
|
+
* ],
|
|
6613
|
+
* "summary": { "signer_count": 1, "completed_count": 0, "signers": [] }
|
|
6614
|
+
* },
|
|
6615
|
+
* "pages": [
|
|
6616
|
+
* { "id": "103acccd5c73...", "number": 1, "height": 1651, "width": 1275,
|
|
6617
|
+
* "download_url": "https://api.assinafy.com.br/v1/documents/103acccd.../pages/103acccd5c73.../download" }
|
|
6618
|
+
* ],
|
|
6619
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6620
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6621
|
+
* }
|
|
6622
|
+
* ```
|
|
6541
6623
|
* @throws {ValidationError} If `signerAccessCode` is missing.
|
|
6542
6624
|
* @throws {ApiError} `400` when DigitalCertificate identity/terms are not
|
|
6543
6625
|
* confirmed; `401`/`403` if the access code is invalid or expired; `409`
|
|
@@ -6659,9 +6741,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6659
6741
|
const did = this.requireId(documentId, "Document ID");
|
|
6660
6742
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
6661
6743
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6662
|
-
|
|
6663
|
-
throw new ValidationError("declineReason is required");
|
|
6664
|
-
}
|
|
6744
|
+
assertDeclineReason(declineReason);
|
|
6665
6745
|
return this.callVoid(
|
|
6666
6746
|
"Failed to decline assignment",
|
|
6667
6747
|
() => this.http.put(
|
|
@@ -6672,6 +6752,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6672
6752
|
);
|
|
6673
6753
|
}
|
|
6674
6754
|
};
|
|
6755
|
+
function assertDocumentIds(documentIds) {
|
|
6756
|
+
if (!Array.isArray(documentIds) || documentIds.length === 0 || documentIds.some((id) => typeof id !== "string" || !id.trim())) {
|
|
6757
|
+
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
function assertDeclineReason(declineReason) {
|
|
6761
|
+
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
6762
|
+
throw new ValidationError("declineReason is required");
|
|
6763
|
+
}
|
|
6764
|
+
}
|
|
6675
6765
|
function validateConfirmDataPayload(payload) {
|
|
6676
6766
|
for (const key of ["full_name", "government_id"]) {
|
|
6677
6767
|
if (payload[key] !== void 0 && typeof payload[key] !== "string") {
|
|
@@ -6817,8 +6907,20 @@ var UserResource = class extends BaseResource {
|
|
|
6817
6907
|
* ```json
|
|
6818
6908
|
* { "DocumentCompleted": true, "SignerDeclined": false }
|
|
6819
6909
|
* ```
|
|
6820
|
-
* @returns The complete updated
|
|
6821
|
-
*
|
|
6910
|
+
* @returns The complete updated nine-key preference map:
|
|
6911
|
+
* ```json
|
|
6912
|
+
* {
|
|
6913
|
+
* "DocumentCompleted": true,
|
|
6914
|
+
* "SignerDeclined": false,
|
|
6915
|
+
* "DocumentCancelled": true,
|
|
6916
|
+
* "DocumentAboutToExpire": true,
|
|
6917
|
+
* "DocumentExpired": false,
|
|
6918
|
+
* "DocumentExpirationReset": true,
|
|
6919
|
+
* "DocumentProcessingFailed": true,
|
|
6920
|
+
* "TemplateProcessingFailed": true,
|
|
6921
|
+
* "SignerWhatsappFailed": true
|
|
6922
|
+
* }
|
|
6923
|
+
* ```
|
|
6822
6924
|
* @throws {ValidationError} Before requesting when the map is empty, has an
|
|
6823
6925
|
* unknown key, or contains a non-boolean value.
|
|
6824
6926
|
* @throws {ApiError} `400` if the API rejects the map, `401` for invalid
|
|
@@ -7270,7 +7372,10 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7270
7372
|
* the upload is empty / non-PDF / larger than 25 MB, or `waitForReady` is
|
|
7271
7373
|
* enabled and processing exceeds the {@link DocumentResource.waitUntilReady}
|
|
7272
7374
|
* timeout.
|
|
7273
|
-
* @throws {ApiError} If any underlying API call is rejected
|
|
7375
|
+
* @throws {ApiError} If any underlying API call is rejected — see the
|
|
7376
|
+
* `@throws` of {@link DocumentResource.upload}, {@link SignerResource.create},
|
|
7377
|
+
* {@link AssignmentResource.create}, and
|
|
7378
|
+
* {@link DocumentResource.waitUntilReady} for the per-step statuses.
|
|
7274
7379
|
*
|
|
7275
7380
|
* @example
|
|
7276
7381
|
* ```ts
|