@assinafy/sdk 2.5.1 → 2.5.2
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 +26 -45
- package/README.en.md +28 -27
- package/README.md +25 -25
- package/dist/index.d.mts +447 -18
- package/dist/index.d.ts +447 -18
- package/dist/index.js +402 -22
- package/dist/index.mjs +398 -18
- package/docs/API_COVERAGE.md +1 -1
- package/docs/COMPATIBILITY.md +15 -21
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.5.2] - 2026-10-05
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- OAuth callbacks reject repeated protocol parameters before exchanging a code.
|
|
15
|
+
- API errors preserve authentication challenges and decoded binary error bodies
|
|
16
|
+
when a custom transport resolves a non-success response. OAuth errors retain
|
|
17
|
+
the authentication challenge when converted to `OAuthError`.
|
|
18
|
+
- Sandbox OAuth setup uses discovery and keeps client registration, issuer and
|
|
19
|
+
API requests in the same environment.
|
|
20
|
+
- Resource reference documentation includes JSON request payloads alongside
|
|
21
|
+
response examples; upload examples describe filename handling accurately.
|
|
22
|
+
|
|
23
|
+
### Security
|
|
24
|
+
|
|
25
|
+
- Update the development dependency override for `brace-expansion` to 5.0.12.
|
|
26
|
+
|
|
10
27
|
## [2.5.1] - 2026-09-28
|
|
11
28
|
|
|
12
29
|
### Fixed
|
|
@@ -166,10 +183,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
166
183
|
**A3** are recorded explicitly as certificate media — a file in software or a
|
|
167
184
|
token/smartcard, chosen by the signer in the browser — both modelled by the
|
|
168
185
|
single `DigitalCertificate` value, with no separate field to send.
|
|
169
|
-
- `bun run audit:api` additionally fetches the two OAuth discovery documents
|
|
170
|
-
and checks the issuer, the authorization and token endpoints, PKCE `S256` and
|
|
171
|
-
the RFC 9207 `iss` parameter against the published contract. They are the
|
|
172
|
-
only part of the OAuth surface that does not live in the OpenAPI document.
|
|
173
186
|
- `docs/API_COVERAGE.md` maps the four new OAuth operations, bringing the
|
|
174
187
|
ledger to 93 of 93.
|
|
175
188
|
- The Portuguese README is now the complete reference rather than a summary
|
|
@@ -295,7 +308,7 @@ type, or API surface changed.
|
|
|
295
308
|
operations across 68 paths**, including account theme/logo/statistics, OAuth
|
|
296
309
|
URL helpers/linking, authenticated-user profile/statistics, and all signer
|
|
297
310
|
response/acknowledgement shapes.
|
|
298
|
-
-
|
|
311
|
+
- A complete endpoint ledger (`docs/API_COVERAGE.md`),
|
|
299
312
|
compatibility record, and a scheduled OpenAPI operation-drift gate.
|
|
300
313
|
- Strict test-source typechecking and enforced Bun coverage floors. The suite
|
|
301
314
|
now executes every public HTTP wrapper and covers the production source at
|
|
@@ -343,12 +356,6 @@ type, or API surface changed.
|
|
|
343
356
|
|
|
344
357
|
### Additional fixes (completed 2026-07-19)
|
|
345
358
|
|
|
346
|
-
Validated against the live sandbox API (`https://sandbox.assinafy.com.br/v1`)
|
|
347
|
-
and the OpenAPI reference: every safely runnable operation was exercised live,
|
|
348
|
-
operations that depend on fixtures or legal consent were recorded as explicit
|
|
349
|
-
skips, and the SDK was brought in line with the observed request/response
|
|
350
|
-
shapes.
|
|
351
|
-
|
|
352
359
|
#### Fixed
|
|
353
360
|
|
|
354
361
|
- **`signerDocuments.acceptTerms()` and `signerDocuments.verifyEmail()` were
|
|
@@ -364,7 +371,7 @@ shapes.
|
|
|
364
371
|
`pages`, and the embedded `assignment` are current.
|
|
365
372
|
- **README workspace example used an invalid colour.** `primary_color:
|
|
366
373
|
'#ff0066'` is rejected by the account endpoints, which require exactly 6 hex
|
|
367
|
-
characters with **no** leading
|
|
374
|
+
characters with **no** leading `#`. Fixed the example and
|
|
368
375
|
documented the format on the payload types.
|
|
369
376
|
|
|
370
377
|
#### Added
|
|
@@ -419,7 +426,7 @@ shapes.
|
|
|
419
426
|
|
|
420
427
|
- **`per_page` was silently ignored on every list call.** The API reads only
|
|
421
428
|
`per-page`; `per_page` is accepted and discarded, so the response fell back to
|
|
422
|
-
20 items
|
|
429
|
+
20 items. Every list
|
|
423
430
|
method's documentation advertised `per_page`, so paging appeared to work while
|
|
424
431
|
quietly returning the wrong page size. Both spellings are now honoured —
|
|
425
432
|
`per_page` is normalised to `per-page`, and an explicit `per-page` wins.
|
|
@@ -522,23 +529,19 @@ shapes.
|
|
|
522
529
|
not return either field, so the old type promised a required `pages` array
|
|
523
530
|
that was `undefined` at runtime.
|
|
524
531
|
- **`ICreateAssignmentPayload.copy_receivers` is documented as unreliable.** On
|
|
525
|
-
the sandbox plan the API accepts it and persists nothing —
|
|
532
|
+
the sandbox plan the API accepts it and persists nothing — `[]` from
|
|
526
533
|
`create`, `list` and `details().assignment`, for both emails and signer IDs.
|
|
527
534
|
Kept (it may be plan-gated) but do not assume a CC was delivered.
|
|
528
535
|
|
|
529
536
|
## [1.5.0] - 2026-06-05
|
|
530
537
|
|
|
531
|
-
|
|
532
|
-
re-validated end-to-end against the live **sandbox**
|
|
533
|
-
(`https://sandbox.assinafy.com.br/v1`). Closes the last coverage gap (Template
|
|
534
|
-
create/update/delete), removes a dead endpoint, tightens types to the real
|
|
535
|
-
wire shapes, and modernises the toolchain.
|
|
538
|
+
Adds template management, aligns types with response payloads, and updates the toolchain.
|
|
536
539
|
|
|
537
540
|
### Removed
|
|
538
541
|
|
|
539
542
|
- **`assignments.cancel`** — it called
|
|
540
543
|
`POST /accounts/{id}/signature-requests/{id}/cancel`, which is undocumented and
|
|
541
|
-
returns `404` on the live API
|
|
544
|
+
returns `404` on the live API. There is no workspace-side cancel
|
|
542
545
|
endpoint — cancel by deleting the document (`documents.delete`, when its status
|
|
543
546
|
is deletable) or via the signer-side decline
|
|
544
547
|
(`signerDocuments.decline(documentId, assignmentId, accessCode, reason)`).
|
|
@@ -597,19 +600,10 @@ wire shapes, and modernises the toolchain.
|
|
|
597
600
|
for publishing, and npm provenance (`--provenance` + `id-token: write`).
|
|
598
601
|
- esbuild pinned via `overrides` to keep the bun + npm lockfiles reproducible.
|
|
599
602
|
|
|
600
|
-
### Tests
|
|
601
|
-
|
|
602
|
-
113 unit tests pass (`bun test`). New suites cover `TemplateResource` (incl. the
|
|
603
|
-
new CRUD), the `BaseResource` helpers (`callOptional` 404→null, `callVoid`,
|
|
604
|
-
`callBinary`, `callList`), the rate-limit retry helpers, and assignment/document
|
|
605
|
-
response shapes. All read and write paths re-verified against the live sandbox,
|
|
606
|
-
including template create/get/update/downloadPage/delete.
|
|
607
603
|
|
|
608
604
|
## [1.4.0] - 2026-05-27
|
|
609
605
|
|
|
610
|
-
|
|
611
|
-
re-validated end-to-end against the live API. Closes the last coverage gap
|
|
612
|
-
(Tags) and fixes signer-creation and type accuracy.
|
|
606
|
+
Adds tags and fixes signer creation and response types.
|
|
613
607
|
|
|
614
608
|
### Added
|
|
615
609
|
|
|
@@ -642,18 +636,9 @@ re-validated end-to-end against the live API. Closes the last coverage gap
|
|
|
642
636
|
is typed as the `{ ip, user-agent }` object the API actually returns, with the
|
|
643
637
|
event `payload` snapshot added.
|
|
644
638
|
|
|
645
|
-
### Tests
|
|
646
|
-
|
|
647
|
-
86 unit tests pass (`bun test`). New `tags` and `documents` suites cover Tag CRUD
|
|
648
|
-
and document-tag attach/detach; new signer tests cover WhatsApp-only creation and
|
|
649
|
-
CPF normalisation. All read and write paths re-verified against the live API
|
|
650
|
-
(`scripts/live-smoke.ts --write`).
|
|
651
639
|
|
|
652
640
|
## [1.3.0] - 2026-05-12
|
|
653
641
|
|
|
654
|
-
100% endpoint coverage of [the live API docs](https://api.assinafy.com.br/v1/docs),
|
|
655
|
-
validated end-to-end against the live API.
|
|
656
|
-
|
|
657
642
|
### Added
|
|
658
643
|
|
|
659
644
|
- **`AuthenticationResource`** (new — `client.auth`): `login`, `socialLogin`,
|
|
@@ -684,11 +669,6 @@ validated end-to-end against the live API.
|
|
|
684
669
|
- Live smoke-test script (`scripts/live-smoke.ts`) covering every read-only
|
|
685
670
|
endpoint plus optional `--write` and `--upload` modes.
|
|
686
671
|
|
|
687
|
-
### Tests
|
|
688
|
-
|
|
689
|
-
70 unit tests pass (`bun test`). New suites cover the authentication, fields,
|
|
690
|
-
and signer-documents resources. Build + ESM/CJS bundles validated against the
|
|
691
|
-
live API.
|
|
692
672
|
|
|
693
673
|
## [1.2.0] - 2026-05-06
|
|
694
674
|
|
|
@@ -725,7 +705,8 @@ signer fields with `cpf` and `whatsapp_phone_number`.
|
|
|
725
705
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
726
706
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
727
707
|
|
|
728
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.5.
|
|
708
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.5.2...HEAD
|
|
709
|
+
[2.5.2]: https://github.com/assinafy/typescript-sdk/compare/v2.5.1...v2.5.2
|
|
729
710
|
[2.5.1]: https://github.com/assinafy/typescript-sdk/compare/v2.5.0...v2.5.1
|
|
730
711
|
[2.5.0]: https://github.com/assinafy/typescript-sdk/compare/v2.4.2...v2.5.0
|
|
731
712
|
[2.4.2]: https://github.com/assinafy/typescript-sdk/compare/v2.4.1...v2.4.2
|
package/README.en.md
CHANGED
|
@@ -186,7 +186,7 @@ const tokens = await client.oauth.exchangeCode({
|
|
|
186
186
|
codeVerifier: session.oauth.codeVerifier,
|
|
187
187
|
redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
188
188
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
189
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
189
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!, // confidential apps only
|
|
190
190
|
});
|
|
191
191
|
// → { access_token, token_type: 'Bearer', expires_in: 3600,
|
|
192
192
|
// scope: 'documents:read documents:write',
|
|
@@ -201,7 +201,7 @@ const accountId = data[0]?.id; // store it with the tokens
|
|
|
201
201
|
const renewed = await client.oauth.refreshToken({
|
|
202
202
|
refreshToken: connection.refreshToken,
|
|
203
203
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
204
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
204
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
205
205
|
});
|
|
206
206
|
await connection.save({ refreshToken: renewed.refresh_token }); // BEFORE using it
|
|
207
207
|
|
|
@@ -211,7 +211,7 @@ await client.oauth.revokeToken({
|
|
|
211
211
|
token: current.refreshToken,
|
|
212
212
|
tokenTypeHint: 'refresh_token',
|
|
213
213
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
214
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
214
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
215
215
|
});
|
|
216
216
|
```
|
|
217
217
|
|
|
@@ -378,7 +378,7 @@ display-name override (used as that file part's filename) and an optional JSON
|
|
|
378
378
|
`IDocumentUploadResponse`:
|
|
379
379
|
|
|
380
380
|
```ts
|
|
381
|
-
{
|
|
381
|
+
type DocumentUploadShape = {
|
|
382
382
|
resource?: string;
|
|
383
383
|
id: string;
|
|
384
384
|
account_id: string;
|
|
@@ -402,7 +402,7 @@ display-name override (used as that file part's filename) and an optional JSON
|
|
|
402
402
|
is_closed: boolean;
|
|
403
403
|
decline_reason: string | null;
|
|
404
404
|
declined_by: ISigner | null;
|
|
405
|
-
}
|
|
405
|
+
};
|
|
406
406
|
```
|
|
407
407
|
|
|
408
408
|
`DocumentStatus` covers `uploading`, `uploaded`, `metadata_processing`,
|
|
@@ -438,7 +438,7 @@ const signerB = await client.signers.create({
|
|
|
438
438
|
The wire body is `{ full_name, email }`. Each response is an `ISigner`:
|
|
439
439
|
|
|
440
440
|
```ts
|
|
441
|
-
{
|
|
441
|
+
type SignerShape = {
|
|
442
442
|
resource?: string;
|
|
443
443
|
id: string;
|
|
444
444
|
full_name: string;
|
|
@@ -450,7 +450,7 @@ The wire body is `{ full_name, email }`. Each response is an `ISigner`:
|
|
|
450
450
|
has_initial?: boolean; // signer-self response only
|
|
451
451
|
is_signature_reusable?: boolean; // signer-self response only
|
|
452
452
|
metadata?: Record<string, unknown>;
|
|
453
|
-
}
|
|
453
|
+
};
|
|
454
454
|
```
|
|
455
455
|
|
|
456
456
|
When an email is present, `signers.create()` first looks up that email in the
|
|
@@ -507,7 +507,7 @@ const assignment = await client.assignments.create(uploaded.id, {
|
|
|
507
507
|
The request returns an `IAssignment`:
|
|
508
508
|
|
|
509
509
|
```ts
|
|
510
|
-
{
|
|
510
|
+
type AssignmentShape = {
|
|
511
511
|
resource?: string;
|
|
512
512
|
id: string;
|
|
513
513
|
sender_email?: string;
|
|
@@ -524,7 +524,7 @@ The request returns an `IAssignment`:
|
|
|
524
524
|
signers: Array<ISigner & { completed?: boolean }>;
|
|
525
525
|
};
|
|
526
526
|
signing_urls?: Array<{ signer_id: string; url: string }>;
|
|
527
|
-
}
|
|
527
|
+
};
|
|
528
528
|
```
|
|
529
529
|
|
|
530
530
|
The URLs and delivered messages contain signer credentials; treat them as
|
|
@@ -556,7 +556,7 @@ await signerClient.signerDocuments.verifyEmail({
|
|
|
556
556
|
const confirmed = await signerClient.signerDocuments.confirmData(
|
|
557
557
|
uploaded.id,
|
|
558
558
|
accessCode,
|
|
559
|
-
{ full_name: self.full_name, email: self.email
|
|
559
|
+
{ full_name: self.full_name, ...(self.email === null ? {} : { email: self.email }) },
|
|
560
560
|
); // ISigner
|
|
561
561
|
|
|
562
562
|
const signable = await signerClient.signerDocuments.getAssignment(accessCode, true);
|
|
@@ -617,10 +617,10 @@ const doc = await client.documents.upload(
|
|
|
617
617
|
{ filePath: './contract.pdf' },
|
|
618
618
|
{ name: 'Service agreement', metadata: { type: 'service' } },
|
|
619
619
|
);
|
|
620
|
-
// `
|
|
621
|
-
// file
|
|
622
|
-
//
|
|
623
|
-
//
|
|
620
|
+
// `metadata` is a compatibility multipart part outside the published schema.
|
|
621
|
+
// `name` sets the filename of the file part; it is not sent as a separate field.
|
|
622
|
+
// When omitted, it defaults to the original filename. The API appends `.pdf`
|
|
623
|
+
// when absent, so
|
|
624
624
|
// the document above is stored as 'Service agreement.pdf'. Accents are
|
|
625
625
|
// transliterated by the API ('Contrato de Serviço' → 'Contrato de Servico.pdf').
|
|
626
626
|
// → {
|
|
@@ -1165,7 +1165,7 @@ retains only the first 2,000 characters of the receiver's response body.
|
|
|
1165
1165
|
Each history or retry result is an `IWebhookDispatch`:
|
|
1166
1166
|
|
|
1167
1167
|
```ts
|
|
1168
|
-
{
|
|
1168
|
+
type WebhookDispatchShape = {
|
|
1169
1169
|
resource?: string;
|
|
1170
1170
|
id: string;
|
|
1171
1171
|
event: string;
|
|
@@ -1178,13 +1178,13 @@ Each history or retry result is an `IWebhookDispatch`:
|
|
|
1178
1178
|
error: string | null;
|
|
1179
1179
|
created_at: string;
|
|
1180
1180
|
updated_at?: string;
|
|
1181
|
-
}
|
|
1181
|
+
};
|
|
1182
1182
|
```
|
|
1183
1183
|
|
|
1184
1184
|
Every delivery body uses this envelope:
|
|
1185
1185
|
|
|
1186
1186
|
```ts
|
|
1187
|
-
{
|
|
1187
|
+
type WebhookPayloadShape = {
|
|
1188
1188
|
id: number; // use for idempotent processing
|
|
1189
1189
|
event: string;
|
|
1190
1190
|
message: string | null;
|
|
@@ -1194,7 +1194,7 @@ Every delivery body uses this envelope:
|
|
|
1194
1194
|
subject: { type: 'User' | 'Signer' | 'Account' | 'Document' | 'Template'; [key: string]: unknown };
|
|
1195
1195
|
object: { type: 'User' | 'Signer' | 'Account' | 'Document' | 'Template'; [key: string]: unknown };
|
|
1196
1196
|
account_id: string;
|
|
1197
|
-
}
|
|
1197
|
+
};
|
|
1198
1198
|
```
|
|
1199
1199
|
|
|
1200
1200
|
Event-specific values are:
|
|
@@ -1397,24 +1397,25 @@ try {
|
|
|
1397
1397
|
|
|
1398
1398
|
The sandbox runs its own authorization server at
|
|
1399
1399
|
`https://auth-sandbox.assinafy.com.br`, with the consent screen at
|
|
1400
|
-
`/oauth/authorize`.
|
|
1401
|
-
|
|
1400
|
+
`/oauth/authorize`. Discovery is available and selects that server from the
|
|
1401
|
+
configured `baseUrl`:
|
|
1402
1402
|
|
|
1403
1403
|
```ts
|
|
1404
1404
|
const client = new AssinafyClient({ baseUrl: 'https://sandbox.assinafy.com.br/v1' });
|
|
1405
|
-
|
|
1405
|
+
const metadata = await client.oauth.getAuthorizationServerMetadata();
|
|
1406
1406
|
const request = await client.oauth.createAuthorizationUrl({
|
|
1407
1407
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
1408
1408
|
redirectUri: 'https://myapp.example.com/oauth/callback',
|
|
1409
|
-
scopes: ['documents:read'],
|
|
1410
|
-
issuer: 'https://auth-sandbox.assinafy.com.br',
|
|
1411
|
-
authorizationEndpoint: 'https://auth-sandbox.assinafy.com.br/oauth/authorize',
|
|
1409
|
+
scopes: ['documents:read', 'account:read', 'offline_access'],
|
|
1412
1410
|
});
|
|
1413
1411
|
```
|
|
1414
1412
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1413
|
+
Register the application in the matching environment. Production and sandbox
|
|
1414
|
+
have separate issuers, client IDs, credentials and workspaces; keep each
|
|
1415
|
+
connection entirely in one environment. Token, revocation and userinfo requests
|
|
1416
|
+
use the configured `baseUrl`. For local testing, expose only the callback
|
|
1417
|
+
through an HTTPS tunnel, register its exact URL and revoke tokens afterward.
|
|
1418
|
+
See [docs/COMPATIBILITY.md](docs/COMPATIBILITY.md).
|
|
1418
1419
|
|
|
1419
1420
|
## Development
|
|
1420
1421
|
|
package/README.md
CHANGED
|
@@ -178,7 +178,7 @@ const tokens = await client.oauth.exchangeCode({
|
|
|
178
178
|
codeVerifier: sessao.oauth.codeVerifier,
|
|
179
179
|
redirectUri: 'https://meuapp.exemplo.com.br/oauth/callback',
|
|
180
180
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
181
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
181
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!, // só aplicações confidenciais
|
|
182
182
|
});
|
|
183
183
|
// → { access_token, token_type: 'Bearer', expires_in: 3600,
|
|
184
184
|
// scope: 'documents:read documents:write',
|
|
@@ -193,7 +193,7 @@ const accountId = data[0]?.id; // guarde junto com os tok
|
|
|
193
193
|
const renovado = await client.oauth.refreshToken({
|
|
194
194
|
refreshToken: conexao.refreshToken,
|
|
195
195
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
196
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
196
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
197
197
|
});
|
|
198
198
|
await conexao.save({ refreshToken: renovado.refresh_token }); // ANTES de usar
|
|
199
199
|
|
|
@@ -203,7 +203,7 @@ await client.oauth.revokeToken({
|
|
|
203
203
|
token: atual.refreshToken,
|
|
204
204
|
tokenTypeHint: 'refresh_token',
|
|
205
205
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
206
|
-
clientSecret: process.env.ASSINAFY_CLIENT_SECRET
|
|
206
|
+
clientSecret: process.env.ASSINAFY_CLIENT_SECRET!,
|
|
207
207
|
});
|
|
208
208
|
```
|
|
209
209
|
|
|
@@ -359,7 +359,7 @@ nome de arquivo dessa parte) e uma parte JSON `metadata` opcional, para deploys
|
|
|
359
359
|
resposta de sucesso é `IDocumentUploadResponse`:
|
|
360
360
|
|
|
361
361
|
```ts
|
|
362
|
-
{
|
|
362
|
+
type DocumentUploadShape = {
|
|
363
363
|
resource?: string;
|
|
364
364
|
id: string;
|
|
365
365
|
account_id: string;
|
|
@@ -383,7 +383,7 @@ resposta de sucesso é `IDocumentUploadResponse`:
|
|
|
383
383
|
is_closed: boolean;
|
|
384
384
|
decline_reason: string | null;
|
|
385
385
|
declined_by: ISigner | null;
|
|
386
|
-
}
|
|
386
|
+
};
|
|
387
387
|
```
|
|
388
388
|
|
|
389
389
|
`DocumentStatus` cobre `uploading`, `uploaded`, `metadata_processing`, `metadata_ready`,
|
|
@@ -418,7 +418,7 @@ const signatarioB = await client.signers.create({
|
|
|
418
418
|
O corpo de rede é `{ full_name, email }`. Cada resposta é um `ISigner`:
|
|
419
419
|
|
|
420
420
|
```ts
|
|
421
|
-
{
|
|
421
|
+
type SignerShape = {
|
|
422
422
|
resource?: string;
|
|
423
423
|
id: string;
|
|
424
424
|
full_name: string;
|
|
@@ -430,7 +430,7 @@ O corpo de rede é `{ full_name, email }`. Cada resposta é um `ISigner`:
|
|
|
430
430
|
has_initial?: boolean; // só na resposta de signers/self
|
|
431
431
|
is_signature_reusable?: boolean; // só na resposta de signers/self
|
|
432
432
|
metadata?: Record<string, unknown>;
|
|
433
|
-
}
|
|
433
|
+
};
|
|
434
434
|
```
|
|
435
435
|
|
|
436
436
|
Quando há e-mail, `signers.create()` primeiro procura esse endereço no workspace e reaproveita o
|
|
@@ -486,7 +486,7 @@ const assignment = await client.assignments.create(enviado.id, {
|
|
|
486
486
|
A requisição devolve um `IAssignment`:
|
|
487
487
|
|
|
488
488
|
```ts
|
|
489
|
-
{
|
|
489
|
+
type AssignmentShape = {
|
|
490
490
|
resource?: string;
|
|
491
491
|
id: string;
|
|
492
492
|
sender_email?: string;
|
|
@@ -503,7 +503,7 @@ A requisição devolve um `IAssignment`:
|
|
|
503
503
|
signers: Array<ISigner & { completed?: boolean }>;
|
|
504
504
|
};
|
|
505
505
|
signing_urls?: Array<{ signer_id: string; url: string }>;
|
|
506
|
-
}
|
|
506
|
+
};
|
|
507
507
|
```
|
|
508
508
|
|
|
509
509
|
As URLs e as mensagens entregues contêm credenciais do signatário; trate-as como segredo.
|
|
@@ -531,7 +531,7 @@ await clienteSignatario.signerDocuments.verifyEmail({
|
|
|
531
531
|
const confirmado = await clienteSignatario.signerDocuments.confirmData(
|
|
532
532
|
enviado.id,
|
|
533
533
|
accessCode,
|
|
534
|
-
{ full_name: self.full_name, email: self.email
|
|
534
|
+
{ full_name: self.full_name, ...(self.email === null ? {} : { email: self.email }) },
|
|
535
535
|
); // ISigner
|
|
536
536
|
|
|
537
537
|
const assinavel = await clienteSignatario.signerDocuments.getAssignment(accessCode, true);
|
|
@@ -588,9 +588,9 @@ const doc = await client.documents.upload(
|
|
|
588
588
|
{ filePath: './contrato.pdf' },
|
|
589
589
|
{ name: 'Contrato de prestação', metadata: { tipo: 'servico' } },
|
|
590
590
|
);
|
|
591
|
-
// `
|
|
592
|
-
//
|
|
593
|
-
//
|
|
591
|
+
// `metadata` é uma parte multipart de compatibilidade fora do schema oficial.
|
|
592
|
+
// `name` define o nome do arquivo na parte multipart; não é enviado como campo
|
|
593
|
+
// separado. Se omitido, usa o nome do arquivo original. A API acrescenta
|
|
594
594
|
// `.pdf` quando falta, então o documento acima é salvo como
|
|
595
595
|
// 'Contrato de prestação.pdf'. A API translitera acentos
|
|
596
596
|
// ('Contrato de Serviço' → 'Contrato de Servico.pdf').
|
|
@@ -1138,7 +1138,7 @@ primeiros 2.000 caracteres do corpo de resposta do receptor.
|
|
|
1138
1138
|
Cada item do histórico (ou resultado de reenvio) é um `IWebhookDispatch`:
|
|
1139
1139
|
|
|
1140
1140
|
```ts
|
|
1141
|
-
{
|
|
1141
|
+
type WebhookDispatchShape = {
|
|
1142
1142
|
resource?: string;
|
|
1143
1143
|
id: string;
|
|
1144
1144
|
event: string;
|
|
@@ -1151,13 +1151,13 @@ Cada item do histórico (ou resultado de reenvio) é um `IWebhookDispatch`:
|
|
|
1151
1151
|
error: string | null;
|
|
1152
1152
|
created_at: string;
|
|
1153
1153
|
updated_at?: string;
|
|
1154
|
-
}
|
|
1154
|
+
};
|
|
1155
1155
|
```
|
|
1156
1156
|
|
|
1157
1157
|
Todo corpo de entrega usa este envelope:
|
|
1158
1158
|
|
|
1159
1159
|
```ts
|
|
1160
|
-
{
|
|
1160
|
+
type WebhookPayloadShape = {
|
|
1161
1161
|
id: number; // use para processamento idempotente
|
|
1162
1162
|
event: string;
|
|
1163
1163
|
message: string | null;
|
|
@@ -1167,7 +1167,7 @@ Todo corpo de entrega usa este envelope:
|
|
|
1167
1167
|
subject: { type: 'User' | 'Signer' | 'Account' | 'Document' | 'Template'; [key: string]: unknown };
|
|
1168
1168
|
object: { type: 'User' | 'Signer' | 'Account' | 'Document' | 'Template'; [key: string]: unknown };
|
|
1169
1169
|
account_id: string;
|
|
1170
|
-
}
|
|
1170
|
+
};
|
|
1171
1171
|
```
|
|
1172
1172
|
|
|
1173
1173
|
Os valores por evento são:
|
|
@@ -1371,23 +1371,23 @@ try {
|
|
|
1371
1371
|
| Sandbox | `https://sandbox.assinafy.com.br/v1` |
|
|
1372
1372
|
|
|
1373
1373
|
O sandbox tem servidor de autorização próprio em `https://auth-sandbox.assinafy.com.br`, com a tela
|
|
1374
|
-
de consentimento em `/oauth/authorize`.
|
|
1375
|
-
|
|
1374
|
+
de consentimento em `/oauth/authorize`. A descoberta está disponível e seleciona esse servidor
|
|
1375
|
+
automaticamente a partir do `baseUrl`:
|
|
1376
1376
|
|
|
1377
1377
|
```ts
|
|
1378
1378
|
const client = new AssinafyClient({ baseUrl: 'https://sandbox.assinafy.com.br/v1' });
|
|
1379
|
-
|
|
1379
|
+
const metadados = await client.oauth.getAuthorizationServerMetadata();
|
|
1380
1380
|
const requisicao = await client.oauth.createAuthorizationUrl({
|
|
1381
1381
|
clientId: process.env.ASSINAFY_CLIENT_ID!,
|
|
1382
1382
|
redirectUri: 'https://meuapp.exemplo.com.br/oauth/callback',
|
|
1383
|
-
scopes: ['documents:read'],
|
|
1384
|
-
issuer: 'https://auth-sandbox.assinafy.com.br',
|
|
1385
|
-
authorizationEndpoint: 'https://auth-sandbox.assinafy.com.br/oauth/authorize',
|
|
1383
|
+
scopes: ['documents:read', 'account:read', 'offline_access'],
|
|
1386
1384
|
});
|
|
1387
1385
|
```
|
|
1388
1386
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1387
|
+
Cadastre o aplicativo no ambiente correspondente. Produção e sandbox têm emissores, client IDs,
|
|
1388
|
+
credenciais e workspaces próprios: mantenha cada conexão inteira no mesmo ambiente. Token,
|
|
1389
|
+
revogação e userinfo usam o `baseUrl` configurado. Para testar localmente, exponha somente o
|
|
1390
|
+
callback por um túnel HTTPS, registre a URL exata e revogue os tokens ao terminar. Veja
|
|
1391
1391
|
[docs/COMPATIBILITY.md](docs/COMPATIBILITY.md).
|
|
1392
1392
|
|
|
1393
1393
|
## Desenvolvimento
|