@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.mjs
CHANGED
|
@@ -80,7 +80,9 @@ var ApiError = class _ApiError extends AssinafyError {
|
|
|
80
80
|
* ones with no structured body to explain them. Anything else falls back to
|
|
81
81
|
* the stable message.
|
|
82
82
|
* @returns An `ApiError` retaining the original response body in
|
|
83
|
-
* {@link ApiError.responseData}
|
|
83
|
+
* {@link ApiError.responseData}. A JSON `message` is used verbatim; only an
|
|
84
|
+
* unstructured text body is whitespace-collapsed and truncated for
|
|
85
|
+
* legibility.
|
|
84
86
|
*
|
|
85
87
|
* @example
|
|
86
88
|
* ```ts
|
|
@@ -133,6 +135,16 @@ var OAuthError = class _OAuthError extends ApiError {
|
|
|
133
135
|
* @param error - Any thrown value.
|
|
134
136
|
* @returns An `OAuthError` when the body carries a non-empty string
|
|
135
137
|
* `error`, else the original value.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const apiError = ApiError.fromResponse(400, {
|
|
142
|
+
* error: 'invalid_grant',
|
|
143
|
+
* error_description: 'The provided authorization grant is invalid.',
|
|
144
|
+
* });
|
|
145
|
+
* const upgraded = OAuthError.upgrade(apiError);
|
|
146
|
+
* // upgraded instanceof OAuthError → true, .error → 'invalid_grant'
|
|
147
|
+
* ```
|
|
136
148
|
*/
|
|
137
149
|
static upgrade(error) {
|
|
138
150
|
if (!(error instanceof ApiError) || error instanceof _OAuthError) return error;
|
|
@@ -574,7 +586,7 @@ import axios2 from "axios";
|
|
|
574
586
|
// package.json
|
|
575
587
|
var package_default = {
|
|
576
588
|
name: "@assinafy/sdk",
|
|
577
|
-
version: "2.
|
|
589
|
+
version: "2.5.1",
|
|
578
590
|
packageManager: "bun@1.4.0",
|
|
579
591
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
580
592
|
type: "commonjs",
|
|
@@ -1380,11 +1392,11 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1380
1392
|
* @param documentId - The document the assignment would be created on.
|
|
1381
1393
|
* @param payload - `method` plus channel-only signer descriptors and/or
|
|
1382
1394
|
* `collect`-mode `entries`. Create-only fields and signer IDs are not part
|
|
1383
|
-
* of this request schema.
|
|
1384
|
-
* `InsufficientDocuments`, or `InsufficientCredits`.
|
|
1395
|
+
* of this request schema.
|
|
1385
1396
|
* @returns an {@link ICostEstimate} with `total_credits`, balances, a
|
|
1386
|
-
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1387
|
-
*
|
|
1397
|
+
* line-item `breakdown`, and a `has_sufficient_resources` gate.
|
|
1398
|
+
* `blocking_reason` may be `PendingPayment`, `InsufficientDocuments`, or
|
|
1399
|
+
* `InsufficientCredits`. Response shape:
|
|
1388
1400
|
* ```jsonc
|
|
1389
1401
|
* {
|
|
1390
1402
|
* "documents": 1,
|
|
@@ -1937,8 +1949,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
1937
1949
|
* "updated_at": "2026-07-19T17:24:46Z"
|
|
1938
1950
|
* }
|
|
1939
1951
|
* ```
|
|
1940
|
-
* @throws {ValidationError} If `documentId` is missing
|
|
1941
|
-
* not one of the five documented artifact names.
|
|
1952
|
+
* @throws {ValidationError} If `documentId` is missing.
|
|
1942
1953
|
* @throws {ApiError} `404` if the document does not exist.
|
|
1943
1954
|
*
|
|
1944
1955
|
* @example
|
|
@@ -2522,6 +2533,7 @@ var DocumentResource = class extends BaseResource {
|
|
|
2522
2533
|
* {
|
|
2523
2534
|
* "hash": "FE32EDDADE7CBDDCBB934E7402047450B0E59C02",
|
|
2524
2535
|
* "id": "63ddb172402799bfc991d10d",
|
|
2536
|
+
* "agreement_code": "550E8400-E29B-41D4-A716-446655440000", // printed on the certificate
|
|
2525
2537
|
* "status": "certificated",
|
|
2526
2538
|
* "page_count": "1",
|
|
2527
2539
|
* "signer_count": "1",
|
|
@@ -2657,7 +2669,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2657
2669
|
}
|
|
2658
2670
|
}
|
|
2659
2671
|
/**
|
|
2660
|
-
* Quick boolean check: has every signer
|
|
2672
|
+
* Quick boolean check (`GET /documents/{documentId}`): has every signer
|
|
2673
|
+
* completed their assignment?
|
|
2661
2674
|
*
|
|
2662
2675
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2663
2676
|
* /documents/{documentId}`). Returns `true` when the document status is
|
|
@@ -2687,7 +2700,8 @@ var DocumentResource = class extends BaseResource {
|
|
|
2687
2700
|
return false;
|
|
2688
2701
|
}
|
|
2689
2702
|
/**
|
|
2690
|
-
* Summarise signing progress for UI display
|
|
2703
|
+
* Summarise signing progress for UI display
|
|
2704
|
+
* (`GET /documents/{documentId}`).
|
|
2691
2705
|
*
|
|
2692
2706
|
* A computed convenience over {@link DocumentResource.details} (one `GET
|
|
2693
2707
|
* /documents/{documentId}`). `total` and `signed` come from the assignment
|
|
@@ -3671,7 +3685,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3671
3685
|
events: [...payload.events && payload.events.length > 0 ? payload.events : DEFAULT_WEBHOOK_EVENTS],
|
|
3672
3686
|
is_active: payload.is_active ?? true
|
|
3673
3687
|
};
|
|
3674
|
-
this.logger.info("Registering webhook"
|
|
3688
|
+
this.logger.info("Registering webhook");
|
|
3675
3689
|
return this.call(
|
|
3676
3690
|
"Failed to register webhook",
|
|
3677
3691
|
() => this.http.put(
|
|
@@ -4529,7 +4543,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4529
4543
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4530
4544
|
* "user": {
|
|
4531
4545
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4532
|
-
* "name": "
|
|
4546
|
+
* "name": "Empresa Exemplo",
|
|
4533
4547
|
* "email": "user@example.com",
|
|
4534
4548
|
* "telephone": null,
|
|
4535
4549
|
* "government_id": "",
|
|
@@ -4541,7 +4555,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4541
4555
|
* "accounts": [
|
|
4542
4556
|
* {
|
|
4543
4557
|
* "id": "acc_example",
|
|
4544
|
-
* "name": "
|
|
4558
|
+
* "name": "Empresa Exemplo",
|
|
4545
4559
|
* "roles": ["Owner"],
|
|
4546
4560
|
* "is_delete_allowed": true,
|
|
4547
4561
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4587,7 +4601,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4587
4601
|
* "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…",
|
|
4588
4602
|
* "user": {
|
|
4589
4603
|
* "id": "md3j6p9w8b7y6qvqaoy5er42",
|
|
4590
|
-
* "name": "
|
|
4604
|
+
* "name": "Empresa Exemplo",
|
|
4591
4605
|
* "email": "user@example.com",
|
|
4592
4606
|
* "telephone": null,
|
|
4593
4607
|
* "government_id": "",
|
|
@@ -4599,7 +4613,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4599
4613
|
* "accounts": [
|
|
4600
4614
|
* {
|
|
4601
4615
|
* "id": "acc_example",
|
|
4602
|
-
* "name": "
|
|
4616
|
+
* "name": "Empresa Exemplo",
|
|
4603
4617
|
* "roles": ["Owner"],
|
|
4604
4618
|
* "is_delete_allowed": true,
|
|
4605
4619
|
* "created_at": "2026-05-12T13:45:11Z"
|
|
@@ -4905,6 +4919,7 @@ var AuthenticationResource = class extends BaseResource {
|
|
|
4905
4919
|
import { createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
4906
4920
|
var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
4907
4921
|
var AUTHORIZATION_SERVER_PATH = "/.well-known/oauth-authorization-server";
|
|
4922
|
+
var ASSINAFY_ISSUER = "https://auth.assinafy.com.br";
|
|
4908
4923
|
var CODE_VERIFIER_PATTERN = /^[A-Za-z0-9\-._~]{43,128}$/u;
|
|
4909
4924
|
var OAuthResource = class extends BaseResource {
|
|
4910
4925
|
publicHttp;
|
|
@@ -5137,8 +5152,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5137
5152
|
*
|
|
5138
5153
|
* The `iss` check is strict because the authorization server advertises
|
|
5139
5154
|
* RFC 9207 support and always sends the parameter: a missing `iss` is
|
|
5140
|
-
* treated exactly like a wrong one
|
|
5141
|
-
* something between the browser and your handler strips query parameters.
|
|
5155
|
+
* treated exactly like a wrong one, on success and error responses alike.
|
|
5142
5156
|
*
|
|
5143
5157
|
* This performs no network I/O.
|
|
5144
5158
|
*
|
|
@@ -5146,7 +5160,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5146
5160
|
* `req.query` record, a `URLSearchParams`, a `URL`, a full callback URL
|
|
5147
5161
|
* string, or a bare `a=b&c=d` query string.
|
|
5148
5162
|
* @param expected - The stored {@link IOAuthAuthorizationRequest} (or any
|
|
5149
|
-
* object carrying its `state` and `issuer`).
|
|
5163
|
+
* object carrying its `state` and `issuer`). Without `issuer`, `iss` must
|
|
5164
|
+
* equal `https://auth.assinafy.com.br`; pass the stored one for any other
|
|
5165
|
+
* authorization server, such as the sandbox's.
|
|
5150
5166
|
* @returns The validated response:
|
|
5151
5167
|
* ```jsonc
|
|
5152
5168
|
* {
|
|
@@ -5188,14 +5204,13 @@ var OAuthResource = class extends BaseResource {
|
|
|
5188
5204
|
"OAuth callback state does not match the stored authorization request"
|
|
5189
5205
|
);
|
|
5190
5206
|
}
|
|
5191
|
-
const issuer = query.get("iss")
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
}
|
|
5207
|
+
const issuer = query.get("iss");
|
|
5208
|
+
const expectedIssuer = expected.issuer ?? ASSINAFY_ISSUER;
|
|
5209
|
+
if (issuer === null || normaliseIssuer(issuer) !== normaliseIssuer(expectedIssuer)) {
|
|
5210
|
+
throw new ValidationError(
|
|
5211
|
+
"OAuth callback issuer is missing or does not match the expected issuer",
|
|
5212
|
+
{ expected: expectedIssuer, received: issuer }
|
|
5213
|
+
);
|
|
5199
5214
|
}
|
|
5200
5215
|
const error = query.get("error");
|
|
5201
5216
|
if (error !== null && error.length > 0) {
|
|
@@ -5208,9 +5223,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5208
5223
|
if (code === null || code.length === 0) {
|
|
5209
5224
|
throw new ValidationError("OAuth callback carries neither a code nor an error");
|
|
5210
5225
|
}
|
|
5211
|
-
|
|
5212
|
-
if (issuer !== void 0) result.issuer = issuer;
|
|
5213
|
-
return result;
|
|
5226
|
+
return { code, state, issuer };
|
|
5214
5227
|
}
|
|
5215
5228
|
/**
|
|
5216
5229
|
* Exchange an authorization code for tokens
|
|
@@ -5290,7 +5303,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5290
5303
|
* and re-read your stored token instead of retrying blindly, and never run
|
|
5291
5304
|
* two refreshes concurrently for one connection.
|
|
5292
5305
|
*
|
|
5293
|
-
*
|
|
5306
|
+
* Each returned refresh token is valid for a fresh 30 days, so a connection
|
|
5307
|
+
* only expires if it goes 30 days without a refresh; after that the user
|
|
5308
|
+
* has to reconnect.
|
|
5294
5309
|
*
|
|
5295
5310
|
* @param options - Refresh options.
|
|
5296
5311
|
* @param options.refreshToken - The current refresh token.
|
|
@@ -5298,7 +5313,8 @@ var OAuthResource = class extends BaseResource {
|
|
|
5298
5313
|
* @param options.clientSecret - The `client_secret`, for confidential
|
|
5299
5314
|
* applications only.
|
|
5300
5315
|
* @param options.resource - RFC 8707 resource indicator. Defaults to this
|
|
5301
|
-
* API's origin; pass `null` to omit it.
|
|
5316
|
+
* API's origin; pass `null` to omit it. A refresh may repeat the value the
|
|
5317
|
+
* connection was authorized with but never change it (`invalid_target`).
|
|
5302
5318
|
* @returns A fresh token set, identical in shape to
|
|
5303
5319
|
* {@link OAuthResource.exchangeCode}:
|
|
5304
5320
|
* ```jsonc
|
|
@@ -5329,12 +5345,19 @@ var OAuthResource = class extends BaseResource {
|
|
|
5329
5345
|
async refreshToken(options) {
|
|
5330
5346
|
assertRecord(options, "refresh options");
|
|
5331
5347
|
assertNonEmptyString(options.refreshToken, "refreshToken");
|
|
5332
|
-
|
|
5348
|
+
const tokens = await this.requestToken("Failed to refresh the OAuth access token", {
|
|
5333
5349
|
grant_type: "refresh_token",
|
|
5334
5350
|
refresh_token: options.refreshToken,
|
|
5335
5351
|
...this.clientAuth(options),
|
|
5336
5352
|
...this.resourceParam(options.resource)
|
|
5337
5353
|
});
|
|
5354
|
+
if (typeof tokens.refresh_token !== "string" || tokens.refresh_token.length === 0) {
|
|
5355
|
+
throw new ValidationError(
|
|
5356
|
+
"Failed to refresh the OAuth access token: the token endpoint returned no replacement refresh_token; the connection must be re-established",
|
|
5357
|
+
{ fields: Object.keys(tokens) }
|
|
5358
|
+
);
|
|
5359
|
+
}
|
|
5360
|
+
return tokens;
|
|
5338
5361
|
}
|
|
5339
5362
|
/**
|
|
5340
5363
|
* Revoke an access or refresh token (`POST /oauth/revoke`, RFC 7009).
|
|
@@ -5354,14 +5377,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5354
5377
|
* @param options.tokenTypeHint - Optional `access_token` or
|
|
5355
5378
|
* `refresh_token` hint that lets the server skip a lookup.
|
|
5356
5379
|
* @returns Nothing; resolves once the API acknowledges the request.
|
|
5357
|
-
* Request body:
|
|
5358
|
-
* ```
|
|
5359
|
-
*
|
|
5360
|
-
* "token": "def50200f1e2…",
|
|
5361
|
-
* "token_type_hint": "refresh_token",
|
|
5362
|
-
* "client_id": "cli_1a2b3c",
|
|
5363
|
-
* "client_secret": "…"
|
|
5364
|
-
* }
|
|
5380
|
+
* Request body (`application/x-www-form-urlencoded`):
|
|
5381
|
+
* ```text
|
|
5382
|
+
* token=def50200f1e2…&token_type_hint=refresh_token&client_id=cli_1a2b3c&client_secret=…
|
|
5365
5383
|
* ```
|
|
5366
5384
|
* @throws {ValidationError} If `token` or `clientId` is missing, or
|
|
5367
5385
|
* `tokenTypeHint` is not one of the two documented values.
|
|
@@ -5383,7 +5401,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5383
5401
|
if (options.tokenTypeHint !== void 0 && options.tokenTypeHint !== "access_token" && options.tokenTypeHint !== "refresh_token") {
|
|
5384
5402
|
throw new ValidationError("tokenTypeHint must be access_token or refresh_token");
|
|
5385
5403
|
}
|
|
5386
|
-
const body =
|
|
5404
|
+
const body = formBody({
|
|
5387
5405
|
token: options.token,
|
|
5388
5406
|
token_type_hint: options.tokenTypeHint,
|
|
5389
5407
|
...this.clientAuth(options)
|
|
@@ -5444,13 +5462,18 @@ var OAuthResource = class extends BaseResource {
|
|
|
5444
5462
|
})
|
|
5445
5463
|
);
|
|
5446
5464
|
}
|
|
5447
|
-
/**
|
|
5465
|
+
/**
|
|
5466
|
+
* POST the token endpoint once and assert the response carries a token.
|
|
5467
|
+
*
|
|
5468
|
+
* Never retried: the code is single-use, and replaying a refresh token the
|
|
5469
|
+
* server may already have rotated ends the whole connection.
|
|
5470
|
+
*/
|
|
5448
5471
|
async requestToken(label, body) {
|
|
5449
5472
|
let tokens;
|
|
5450
5473
|
try {
|
|
5451
5474
|
tokens = await this.call(
|
|
5452
5475
|
label,
|
|
5453
|
-
() => this.publicHttp.post("/oauth/token",
|
|
5476
|
+
() => this.publicHttp.post("/oauth/token", formBody(body))
|
|
5454
5477
|
);
|
|
5455
5478
|
} catch (error) {
|
|
5456
5479
|
throw OAuthError.upgrade(error);
|
|
@@ -5514,6 +5537,9 @@ var OAuthResource = class extends BaseResource {
|
|
|
5514
5537
|
return new URL(baseUrl).origin;
|
|
5515
5538
|
}
|
|
5516
5539
|
};
|
|
5540
|
+
function formBody(fields) {
|
|
5541
|
+
return new URLSearchParams(cleanParams(fields));
|
|
5542
|
+
}
|
|
5517
5543
|
function createCodeVerifier() {
|
|
5518
5544
|
return randomBytes(32).toString("base64url");
|
|
5519
5545
|
}
|
|
@@ -6002,8 +6028,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6002
6028
|
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6003
6029
|
* }
|
|
6004
6030
|
* ```
|
|
6005
|
-
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing
|
|
6006
|
-
* or a supplied `search` value is not a string.
|
|
6031
|
+
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6007
6032
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6008
6033
|
*
|
|
6009
6034
|
* @example
|
|
@@ -6091,7 +6116,29 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6091
6116
|
* @param signerAccessCode - The signer's access code, from their signing link.
|
|
6092
6117
|
* @param search - Free-text term matched against the document name.
|
|
6093
6118
|
* @returns Matching documents for that signer, in the compact
|
|
6094
|
-
* {@link IDocumentListItem} shape, with pagination in `meta
|
|
6119
|
+
* {@link IDocumentListItem} shape, with pagination in `meta`:
|
|
6120
|
+
* ```jsonc
|
|
6121
|
+
* {
|
|
6122
|
+
* "data": [
|
|
6123
|
+
* {
|
|
6124
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6125
|
+
* "account_id": "acc_example",
|
|
6126
|
+
* "template_id": null,
|
|
6127
|
+
* "name": "Service agreement.pdf",
|
|
6128
|
+
* "status": "pending_signature",
|
|
6129
|
+
* "artifacts": { "original": "https://...", "thumbnail": "https://..." },
|
|
6130
|
+
* "is_closed": false,
|
|
6131
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6132
|
+
* "decline_reason": null,
|
|
6133
|
+
* "declined_by": null,
|
|
6134
|
+
* "tags": [],
|
|
6135
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6136
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6137
|
+
* }
|
|
6138
|
+
* ],
|
|
6139
|
+
* "meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
|
|
6140
|
+
* }
|
|
6141
|
+
* ```
|
|
6095
6142
|
* @throws {ValidationError} If `signerId` or `signerAccessCode` is missing.
|
|
6096
6143
|
* @throws {ApiError} If the access code is invalid or expired.
|
|
6097
6144
|
*
|
|
@@ -6199,9 +6246,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6199
6246
|
* ```
|
|
6200
6247
|
*/
|
|
6201
6248
|
async signMultiple(documentIds, signerAccessCode) {
|
|
6202
|
-
|
|
6203
|
-
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
6204
|
-
}
|
|
6249
|
+
assertDocumentIds(documentIds);
|
|
6205
6250
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6206
6251
|
return this.callVoid(
|
|
6207
6252
|
"Failed to sign multiple documents",
|
|
@@ -6241,12 +6286,8 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6241
6286
|
* ```
|
|
6242
6287
|
*/
|
|
6243
6288
|
async declineMultiple(documentIds, declineReason, signerAccessCode) {
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
}
|
|
6247
|
-
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
6248
|
-
throw new ValidationError("declineReason is required");
|
|
6249
|
-
}
|
|
6289
|
+
assertDocumentIds(documentIds);
|
|
6290
|
+
assertDeclineReason(declineReason);
|
|
6250
6291
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6251
6292
|
return this.callVoid(
|
|
6252
6293
|
"Failed to decline multiple documents",
|
|
@@ -6477,7 +6518,48 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6477
6518
|
* @returns The document to sign, including its `assignment` (the
|
|
6478
6519
|
* {@link IAssignment} shape: `signers`, `items`, `summary`, `signing_urls`)
|
|
6479
6520
|
* from which the `itemId` / `fieldId` / `pageId` values for
|
|
6480
|
-
* {@link SignerDocumentsResource.sign} are read
|
|
6521
|
+
* {@link SignerDocumentsResource.sign} are read:
|
|
6522
|
+
* ```jsonc
|
|
6523
|
+
* {
|
|
6524
|
+
* "resource": "document",
|
|
6525
|
+
* "id": "103acccd24234c07858ffddf6d84",
|
|
6526
|
+
* "account_id": "acc_example",
|
|
6527
|
+
* "template_id": null,
|
|
6528
|
+
* "name": "Service agreement.pdf",
|
|
6529
|
+
* "status": "pending_signature",
|
|
6530
|
+
* "artifacts": {
|
|
6531
|
+
* "original": "https://api.assinafy.com.br/v1/documents/103acccd.../download/original",
|
|
6532
|
+
* "thumbnail": "https://api.assinafy.com.br/v1/documents/103acccd.../thumbnail"
|
|
6533
|
+
* },
|
|
6534
|
+
* "is_closed": false,
|
|
6535
|
+
* "signing_url": "https://app.assinafy.com.br/sign/103acccd...",
|
|
6536
|
+
* "decline_reason": null,
|
|
6537
|
+
* "declined_by": null,
|
|
6538
|
+
* "tags": [],
|
|
6539
|
+
* "assignment": {
|
|
6540
|
+
* "id": "1032c55c58bb00a8dc35db916751",
|
|
6541
|
+
* "method": "virtual",
|
|
6542
|
+
* "sender_email": "sender@example.com",
|
|
6543
|
+
* "expires_at": null,
|
|
6544
|
+
* "signers": [
|
|
6545
|
+
* { "id": "19e6b92e7895332ed9708535d8c", "step": 1, "email": "signer@example.com",
|
|
6546
|
+
* "full_name": "Example Signer", "notified": true, "completed": false }
|
|
6547
|
+
* ],
|
|
6548
|
+
* "items": [
|
|
6549
|
+
* { "id": "item-1", "page": { "id": "page-1", "number": 1, "height": 1651, "width": 1275,
|
|
6550
|
+
* "download_url": "https://..." }, "signer": { "id": "19e6b92e..." },
|
|
6551
|
+
* "field": { "id": "field-1", "type": "signature" }, "value": null, "completed": false }
|
|
6552
|
+
* ],
|
|
6553
|
+
* "summary": { "signer_count": 1, "completed_count": 0, "signers": [] }
|
|
6554
|
+
* },
|
|
6555
|
+
* "pages": [
|
|
6556
|
+
* { "id": "103acccd5c73...", "number": 1, "height": 1651, "width": 1275,
|
|
6557
|
+
* "download_url": "https://api.assinafy.com.br/v1/documents/103acccd.../pages/103acccd5c73.../download" }
|
|
6558
|
+
* ],
|
|
6559
|
+
* "created_at": "2026-07-19T14:56:54Z",
|
|
6560
|
+
* "updated_at": "2026-07-19T14:56:56Z"
|
|
6561
|
+
* }
|
|
6562
|
+
* ```
|
|
6481
6563
|
* @throws {ValidationError} If `signerAccessCode` is missing.
|
|
6482
6564
|
* @throws {ApiError} `400` when DigitalCertificate identity/terms are not
|
|
6483
6565
|
* confirmed; `401`/`403` if the access code is invalid or expired; `409`
|
|
@@ -6599,9 +6681,7 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6599
6681
|
const did = this.requireId(documentId, "Document ID");
|
|
6600
6682
|
const aid = this.requireId(assignmentId, "Assignment ID");
|
|
6601
6683
|
const code = this.requireId(signerAccessCode, "signer-access-code");
|
|
6602
|
-
|
|
6603
|
-
throw new ValidationError("declineReason is required");
|
|
6604
|
-
}
|
|
6684
|
+
assertDeclineReason(declineReason);
|
|
6605
6685
|
return this.callVoid(
|
|
6606
6686
|
"Failed to decline assignment",
|
|
6607
6687
|
() => this.http.put(
|
|
@@ -6612,6 +6692,16 @@ var SignerDocumentsResource = class extends BaseResource {
|
|
|
6612
6692
|
);
|
|
6613
6693
|
}
|
|
6614
6694
|
};
|
|
6695
|
+
function assertDocumentIds(documentIds) {
|
|
6696
|
+
if (!Array.isArray(documentIds) || documentIds.length === 0 || documentIds.some((id) => typeof id !== "string" || !id.trim())) {
|
|
6697
|
+
throw new ValidationError("documentIds must be a non-empty array of non-empty IDs");
|
|
6698
|
+
}
|
|
6699
|
+
}
|
|
6700
|
+
function assertDeclineReason(declineReason) {
|
|
6701
|
+
if (typeof declineReason !== "string" || !declineReason.trim()) {
|
|
6702
|
+
throw new ValidationError("declineReason is required");
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6615
6705
|
function validateConfirmDataPayload(payload) {
|
|
6616
6706
|
for (const key of ["full_name", "government_id"]) {
|
|
6617
6707
|
if (payload[key] !== void 0 && typeof payload[key] !== "string") {
|
|
@@ -6757,8 +6847,20 @@ var UserResource = class extends BaseResource {
|
|
|
6757
6847
|
* ```json
|
|
6758
6848
|
* { "DocumentCompleted": true, "SignerDeclined": false }
|
|
6759
6849
|
* ```
|
|
6760
|
-
* @returns The complete updated
|
|
6761
|
-
*
|
|
6850
|
+
* @returns The complete updated nine-key preference map:
|
|
6851
|
+
* ```json
|
|
6852
|
+
* {
|
|
6853
|
+
* "DocumentCompleted": true,
|
|
6854
|
+
* "SignerDeclined": false,
|
|
6855
|
+
* "DocumentCancelled": true,
|
|
6856
|
+
* "DocumentAboutToExpire": true,
|
|
6857
|
+
* "DocumentExpired": false,
|
|
6858
|
+
* "DocumentExpirationReset": true,
|
|
6859
|
+
* "DocumentProcessingFailed": true,
|
|
6860
|
+
* "TemplateProcessingFailed": true,
|
|
6861
|
+
* "SignerWhatsappFailed": true
|
|
6862
|
+
* }
|
|
6863
|
+
* ```
|
|
6762
6864
|
* @throws {ValidationError} Before requesting when the map is empty, has an
|
|
6763
6865
|
* unknown key, or contains a non-boolean value.
|
|
6764
6866
|
* @throws {ApiError} `400` if the API rejects the map, `401` for invalid
|
|
@@ -7210,7 +7312,10 @@ var AssinafyClient = class _AssinafyClient {
|
|
|
7210
7312
|
* the upload is empty / non-PDF / larger than 25 MB, or `waitForReady` is
|
|
7211
7313
|
* enabled and processing exceeds the {@link DocumentResource.waitUntilReady}
|
|
7212
7314
|
* timeout.
|
|
7213
|
-
* @throws {ApiError} If any underlying API call is rejected
|
|
7315
|
+
* @throws {ApiError} If any underlying API call is rejected — see the
|
|
7316
|
+
* `@throws` of {@link DocumentResource.upload}, {@link SignerResource.create},
|
|
7317
|
+
* {@link AssignmentResource.create}, and
|
|
7318
|
+
* {@link DocumentResource.waitUntilReady} for the per-step statuses.
|
|
7214
7319
|
*
|
|
7215
7320
|
* @example
|
|
7216
7321
|
* ```ts
|
package/docs/API_COVERAGE.md
CHANGED
|
@@ -200,6 +200,17 @@ coverage count.
|
|
|
200
200
|
| `DELETE` | `/v1/accounts/{accountId}/templates/{templateId}` | `client.templates.delete(templateId, accountId?)` | Compatibility extension |
|
|
201
201
|
| `GET` | `/v1/accounts/{accountId}/templates/{templateId}/pages/{pageId}/download` | `client.templates.downloadPage(templateId, pageId, accountId?)` | Compatibility extension |
|
|
202
202
|
|
|
203
|
+
## Browser URL helpers
|
|
204
|
+
|
|
205
|
+
Two browser URL helpers used by older deployments are live but absent from the
|
|
206
|
+
current OpenAPI path set, so they are likewise excluded from the official
|
|
207
|
+
93-operation coverage count.
|
|
208
|
+
|
|
209
|
+
| Method | Path | SDK method | Status |
|
|
210
|
+
| --- | --- | --- | --- |
|
|
211
|
+
| `GET` | `/v1/auth/authenticate` | `client.auth.getSocialLoginUrl()` | Compatibility extension |
|
|
212
|
+
| `GET` | `/v1/login-callback` | `client.auth.getSocialLoginCallbackUrl()` | Compatibility extension |
|
|
213
|
+
|
|
203
214
|
## SDK conveniences
|
|
204
215
|
|
|
205
216
|
These helpers compose or derive official operations and therefore do not add to
|
package/docs/COMPATIBILITY.md
CHANGED
|
@@ -35,7 +35,7 @@ GET /v1/login-callback
|
|
|
35
35
|
|
|
36
36
|
They map to `auth.getSocialLoginUrl()` and
|
|
37
37
|
`auth.getSocialLoginCallbackUrl()` and are not part of the official
|
|
38
|
-
|
|
38
|
+
93-operation total.
|
|
39
39
|
|
|
40
40
|
The SDK also includes the production contract additions for:
|
|
41
41
|
|
|
@@ -113,8 +113,9 @@ Response shapes diverge from the rest of the API on purpose:
|
|
|
113
113
|
| `GET /oauth/userinfo` | flat claims object (OIDC Core §5.3.2) | the usual `{ status, message, data }` envelope |
|
|
114
114
|
|
|
115
115
|
Both JSON and `application/x-www-form-urlencoded` bodies are accepted by the
|
|
116
|
-
token and revocation endpoints
|
|
117
|
-
|
|
116
|
+
token and revocation endpoints. The published `requestBody` lists only JSON,
|
|
117
|
+
but the SDK sends `application/x-www-form-urlencoded`: the encoding RFC 6749
|
|
118
|
+
and RFC 7009 define and the OAuth Integration Guide uses.
|
|
118
119
|
|
|
119
120
|
The RFC 8707 `resource` indicator defaults to the configured API origin, and is
|
|
120
121
|
omitted when that origin is a loopback `http://` host — the shape used by mock
|