@assinafy/sdk 2.3.0 → 2.4.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 +41 -1
- package/README.en.md +3 -0
- package/README.md +3 -0
- package/dist/index.d.mts +23 -10
- package/dist/index.d.ts +23 -10
- package/dist/index.js +19 -10
- package/dist/index.mjs +19 -10
- package/docs/API_COVERAGE.md +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.4.1] - 2026-09-23
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- OAuth's `webhooks:write` scope is available in `OAuthScope` and documented for
|
|
15
|
+
webhook subscription updates and inactivation.
|
|
16
|
+
|
|
17
|
+
## [2.4.0] - 2026-09-21
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- **`assignments.estimateCost` now sends `signers` for `collect` too.** The
|
|
22
|
+
published contract marks `signers` as required only for `virtual`, but the
|
|
23
|
+
API rejects *any* estimate without it — `collect` requests came back as
|
|
24
|
+
`400 Pelo menos um signatários precisa ser informado.` Pricing is per signer
|
|
25
|
+
in both modes (`Whatsapp` costs 0.45 credits per signer,
|
|
26
|
+
`DigitalCertificate` two), so a signer-less body could never be priced.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `IEstimateAssignmentCostPayload.signers` is now required. TypeScript callers
|
|
31
|
+
that omitted it for `collect` will stop compiling; those calls were already
|
|
32
|
+
failing at runtime, so no working code changes behaviour. Pass one descriptor
|
|
33
|
+
per signer —
|
|
34
|
+
`{}` prices the default Email channel:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
await client.assignments.estimateCost(documentId, {
|
|
38
|
+
method: 'collect',
|
|
39
|
+
signers: [{}, { verification_method: 'Whatsapp' }],
|
|
40
|
+
entries,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `buildAssignmentEstimatePayload` throws `ValidationError` for an empty
|
|
45
|
+
signer list in either mode, so JavaScript callers get a local error instead
|
|
46
|
+
of an opaque upstream rejection. The message is now method-neutral:
|
|
47
|
+
`At least one signer is required for a cost estimate`.
|
|
48
|
+
|
|
10
49
|
## [2.3.0] - 2026-09-20
|
|
11
50
|
|
|
12
51
|
### Added
|
|
@@ -621,7 +660,8 @@ fields (`cpf`, `whatsapp_phone_number`) with the PHP SDK and n8n node.
|
|
|
621
660
|
- High-level `uploadAndRequestSignatures` helper on `AssinafyClient`.
|
|
622
661
|
- `PaginatedResult<T>` with parsed `X-Pagination-*` header meta.
|
|
623
662
|
|
|
624
|
-
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.
|
|
663
|
+
[Unreleased]: https://github.com/assinafy/typescript-sdk/compare/v2.4.0...HEAD
|
|
664
|
+
[2.4.0]: https://github.com/assinafy/typescript-sdk/compare/v2.3.0...v2.4.0
|
|
625
665
|
[2.3.0]: https://github.com/assinafy/typescript-sdk/compare/v2.2.0...v2.3.0
|
|
626
666
|
[2.2.0]: https://github.com/assinafy/typescript-sdk/compare/v2.1.2...v2.2.0
|
|
627
667
|
[2.1.2]: https://github.com/assinafy/typescript-sdk/compare/v2.1.1...v2.1.2
|
package/README.en.md
CHANGED
|
@@ -228,6 +228,7 @@ await client.oauth.getUserInfo(tokens.access_token); // OIDC claims; needs `open
|
|
|
228
228
|
| `templates:read` | Read templates |
|
|
229
229
|
| `templates:write` | Create and change templates |
|
|
230
230
|
| `account:read` | Read the workspace's profile, theme and logo |
|
|
231
|
+
| `webhooks:write` | Update or inactivate the workspace's webhook subscription |
|
|
231
232
|
| `openid` | Receive an `id_token` identifying the user |
|
|
232
233
|
| `profile` | Read the user's name |
|
|
233
234
|
| `email` | Read the user's email and whether it is verified |
|
|
@@ -1095,6 +1096,8 @@ await client.users.updateNotificationPreferences({
|
|
|
1095
1096
|
|
|
1096
1097
|
### Webhooks
|
|
1097
1098
|
|
|
1099
|
+
OAuth tokens need `webhooks:write` for `register()` and `inactivate()`.
|
|
1100
|
+
|
|
1098
1101
|
```ts
|
|
1099
1102
|
await client.webhooks.register({
|
|
1100
1103
|
url: 'https://example.com/webhooks/assinafy',
|
package/README.md
CHANGED
|
@@ -222,6 +222,7 @@ await client.oauth.getUserInfo(tokens.access_token); // claims OIDC; exige `ope
|
|
|
222
222
|
| `templates:read` | Ler templates |
|
|
223
223
|
| `templates:write` | Criar e alterar templates |
|
|
224
224
|
| `account:read` | Ler perfil, tema e logotipo do workspace |
|
|
225
|
+
| `webhooks:write` | Atualizar ou inativar a assinatura de webhooks do workspace |
|
|
225
226
|
| `openid` | Receber um `id_token` identificando o usuário |
|
|
226
227
|
| `profile` | Ler o nome do usuário |
|
|
227
228
|
| `email` | Ler o e-mail do usuário e se está verificado |
|
|
@@ -1093,6 +1094,8 @@ await client.users.updateNotificationPreferences({
|
|
|
1093
1094
|
|
|
1094
1095
|
### Webhooks
|
|
1095
1096
|
|
|
1097
|
+
Tokens OAuth exigem `webhooks:write` para `register()` e `inactivate()`.
|
|
1098
|
+
|
|
1096
1099
|
```ts
|
|
1097
1100
|
await client.webhooks.register({
|
|
1098
1101
|
url: 'https://exemplo.com.br/webhooks/assinafy',
|
package/dist/index.d.mts
CHANGED
|
@@ -303,9 +303,13 @@ interface IAssignmentCostSigner {
|
|
|
303
303
|
*/
|
|
304
304
|
interface IEstimateAssignmentCostPayload {
|
|
305
305
|
method?: AssignmentMethod;
|
|
306
|
-
/**
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Required for both methods — the API rejects an estimate without it, and
|
|
308
|
+
* per-signer `verification_method` is what the estimate prices. `{}` prices
|
|
309
|
+
* the default Email channel.
|
|
310
|
+
*/
|
|
311
|
+
signers: IAssignmentCostSigner[];
|
|
312
|
+
/** Required for `collect`. */
|
|
309
313
|
entries?: IAssignmentEntry[];
|
|
310
314
|
}
|
|
311
315
|
/** A signer as embedded inside an assignment (richer than the bare {@link ISigner}). */
|
|
@@ -1150,7 +1154,7 @@ interface IUpdateTagPayload {
|
|
|
1150
1154
|
* `scopes_supported` in
|
|
1151
1155
|
* {@link IOAuthAuthorizationServerMetadata}.
|
|
1152
1156
|
*/
|
|
1153
|
-
type OAuthScope = 'documents:read' | 'documents:write' | 'templates:read' | 'templates:write' | 'account:read' | 'openid' | 'profile' | 'email' | 'offline_access' | AnyString;
|
|
1157
|
+
type OAuthScope = 'documents:read' | 'documents:write' | 'templates:read' | 'templates:write' | 'account:read' | 'webhooks:write' | 'openid' | 'profile' | 'email' | 'offline_access' | AnyString;
|
|
1154
1158
|
/**
|
|
1155
1159
|
* RFC 9728 protected-resource metadata served at
|
|
1156
1160
|
* `https://api.assinafy.com.br/.well-known/oauth-protected-resource`.
|
|
@@ -2933,7 +2937,8 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2933
2937
|
* }
|
|
2934
2938
|
* ```
|
|
2935
2939
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
2936
|
-
* has no signer entry, or a `collect` request has no
|
|
2940
|
+
* has no signer entry, or a `collect` request has no signer entry or no
|
|
2941
|
+
* field-placement entry.
|
|
2937
2942
|
* @throws {ApiError} If the API rejects the request.
|
|
2938
2943
|
*
|
|
2939
2944
|
* @example
|
|
@@ -3122,6 +3127,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3122
3127
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3123
3128
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
3124
3129
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3130
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3125
3131
|
*
|
|
3126
3132
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3127
3133
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
@@ -3145,7 +3151,8 @@ declare class WebhookResource extends BaseResource {
|
|
|
3145
3151
|
* ```
|
|
3146
3152
|
* @throws {ValidationError} If `url` / `email` is invalid, `events` /
|
|
3147
3153
|
* `is_active` has the wrong type, or no account ID is available.
|
|
3148
|
-
* @throws {ApiError} If the API rejects the subscription
|
|
3154
|
+
* @throws {ApiError} If the API rejects the subscription, including `403`
|
|
3155
|
+
* when an OAuth token lacks `webhooks:write`.
|
|
3149
3156
|
*
|
|
3150
3157
|
* @example
|
|
3151
3158
|
* ```ts
|
|
@@ -3204,6 +3211,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3204
3211
|
* subscription-delete route. The subscription is retained (with its `url`
|
|
3205
3212
|
* and `events`) and simply stops firing; re-enable it by calling
|
|
3206
3213
|
* {@link WebhookResource.register} again with `is_active: true`.
|
|
3214
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3207
3215
|
*
|
|
3208
3216
|
* @param accountId - Override the client's default account ID.
|
|
3209
3217
|
* @returns The subscription with `is_active` flipped to `false`. Response
|
|
@@ -3224,7 +3232,8 @@ declare class WebhookResource extends BaseResource {
|
|
|
3224
3232
|
* }
|
|
3225
3233
|
* ```
|
|
3226
3234
|
* @throws {ValidationError} If no account ID is available.
|
|
3227
|
-
* @throws {ApiError} If the API rejects the request
|
|
3235
|
+
* @throws {ApiError} If the API rejects the request, including `403` when
|
|
3236
|
+
* an OAuth token lacks `webhooks:write`.
|
|
3228
3237
|
*
|
|
3229
3238
|
* @example
|
|
3230
3239
|
* ```ts
|
|
@@ -4238,7 +4247,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4238
4247
|
* "scopes_supported": [
|
|
4239
4248
|
* "documents:read", "documents:write",
|
|
4240
4249
|
* "templates:read", "templates:write",
|
|
4241
|
-
* "account:read", "openid", "profile", "email"
|
|
4250
|
+
* "account:read", "webhooks:write", "openid", "profile", "email"
|
|
4242
4251
|
* ],
|
|
4243
4252
|
* "bearer_methods_supported": ["header"]
|
|
4244
4253
|
* }
|
|
@@ -4275,16 +4284,19 @@ declare class OAuthResource extends BaseResource {
|
|
|
4275
4284
|
* "userinfo_endpoint": "https://api.assinafy.com.br/v1/oauth/userinfo",
|
|
4276
4285
|
* "jwks_uri": "https://auth.assinafy.com.br/.well-known/jwks.json",
|
|
4277
4286
|
* "scopes_supported": ["documents:read", "documents:write", "templates:read",
|
|
4278
|
-
* "templates:write", "account:read", "openid",
|
|
4287
|
+
* "templates:write", "account:read", "webhooks:write", "openid",
|
|
4279
4288
|
* "profile", "email", "offline_access"],
|
|
4280
4289
|
* "response_types_supported": ["code"],
|
|
4281
|
-
* "grant_types_supported": ["authorization_code", "refresh_token"
|
|
4290
|
+
* "grant_types_supported": ["authorization_code", "refresh_token",
|
|
4291
|
+
* "urn:ietf:params:oauth:grant-type:token-exchange"],
|
|
4282
4292
|
* "code_challenge_methods_supported": ["S256"],
|
|
4283
4293
|
* "token_endpoint_auth_methods_supported": ["client_secret_post", "none"],
|
|
4284
4294
|
* "authorization_response_iss_parameter_supported": true,
|
|
4285
4295
|
* "client_id_metadata_document_supported": true
|
|
4286
4296
|
* }
|
|
4287
4297
|
* ```
|
|
4298
|
+
* The token-exchange grant is reserved for Assinafy's internal service
|
|
4299
|
+
* clients; integrations use `authorization_code` and `refresh_token`.
|
|
4288
4300
|
* @throws {ValidationError} If `issuer` is not an absolute `https://` URL,
|
|
4289
4301
|
* or the document's own `issuer` disagrees with where it was fetched from
|
|
4290
4302
|
* (RFC 8414 §3.3 — a mismatch means the document is not authoritative).
|
|
@@ -4318,6 +4330,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4318
4330
|
* `['documents:read', 'documents:write', 'offline_access']`. Ask for the
|
|
4319
4331
|
* minimum: the user approves all of them or none. Add `offline_access` to
|
|
4320
4332
|
* receive a refresh token and `openid` to receive an `id_token`.
|
|
4333
|
+
* `webhooks:write` permits subscription updates and inactivation.
|
|
4321
4334
|
* @param options.authorizationEndpoint - Skip discovery by supplying the
|
|
4322
4335
|
* endpoint yourself. Defaults to the discovered
|
|
4323
4336
|
* `authorization_endpoint`.
|
package/dist/index.d.ts
CHANGED
|
@@ -303,9 +303,13 @@ interface IAssignmentCostSigner {
|
|
|
303
303
|
*/
|
|
304
304
|
interface IEstimateAssignmentCostPayload {
|
|
305
305
|
method?: AssignmentMethod;
|
|
306
|
-
/**
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Required for both methods — the API rejects an estimate without it, and
|
|
308
|
+
* per-signer `verification_method` is what the estimate prices. `{}` prices
|
|
309
|
+
* the default Email channel.
|
|
310
|
+
*/
|
|
311
|
+
signers: IAssignmentCostSigner[];
|
|
312
|
+
/** Required for `collect`. */
|
|
309
313
|
entries?: IAssignmentEntry[];
|
|
310
314
|
}
|
|
311
315
|
/** A signer as embedded inside an assignment (richer than the bare {@link ISigner}). */
|
|
@@ -1150,7 +1154,7 @@ interface IUpdateTagPayload {
|
|
|
1150
1154
|
* `scopes_supported` in
|
|
1151
1155
|
* {@link IOAuthAuthorizationServerMetadata}.
|
|
1152
1156
|
*/
|
|
1153
|
-
type OAuthScope = 'documents:read' | 'documents:write' | 'templates:read' | 'templates:write' | 'account:read' | 'openid' | 'profile' | 'email' | 'offline_access' | AnyString;
|
|
1157
|
+
type OAuthScope = 'documents:read' | 'documents:write' | 'templates:read' | 'templates:write' | 'account:read' | 'webhooks:write' | 'openid' | 'profile' | 'email' | 'offline_access' | AnyString;
|
|
1154
1158
|
/**
|
|
1155
1159
|
* RFC 9728 protected-resource metadata served at
|
|
1156
1160
|
* `https://api.assinafy.com.br/.well-known/oauth-protected-resource`.
|
|
@@ -2933,7 +2937,8 @@ declare class AssignmentResource extends BaseResource {
|
|
|
2933
2937
|
* }
|
|
2934
2938
|
* ```
|
|
2935
2939
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
2936
|
-
* has no signer entry, or a `collect` request has no
|
|
2940
|
+
* has no signer entry, or a `collect` request has no signer entry or no
|
|
2941
|
+
* field-placement entry.
|
|
2937
2942
|
* @throws {ApiError} If the API rejects the request.
|
|
2938
2943
|
*
|
|
2939
2944
|
* @example
|
|
@@ -3122,6 +3127,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3122
3127
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3123
3128
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
3124
3129
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3130
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3125
3131
|
*
|
|
3126
3132
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3127
3133
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
@@ -3145,7 +3151,8 @@ declare class WebhookResource extends BaseResource {
|
|
|
3145
3151
|
* ```
|
|
3146
3152
|
* @throws {ValidationError} If `url` / `email` is invalid, `events` /
|
|
3147
3153
|
* `is_active` has the wrong type, or no account ID is available.
|
|
3148
|
-
* @throws {ApiError} If the API rejects the subscription
|
|
3154
|
+
* @throws {ApiError} If the API rejects the subscription, including `403`
|
|
3155
|
+
* when an OAuth token lacks `webhooks:write`.
|
|
3149
3156
|
*
|
|
3150
3157
|
* @example
|
|
3151
3158
|
* ```ts
|
|
@@ -3204,6 +3211,7 @@ declare class WebhookResource extends BaseResource {
|
|
|
3204
3211
|
* subscription-delete route. The subscription is retained (with its `url`
|
|
3205
3212
|
* and `events`) and simply stops firing; re-enable it by calling
|
|
3206
3213
|
* {@link WebhookResource.register} again with `is_active: true`.
|
|
3214
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3207
3215
|
*
|
|
3208
3216
|
* @param accountId - Override the client's default account ID.
|
|
3209
3217
|
* @returns The subscription with `is_active` flipped to `false`. Response
|
|
@@ -3224,7 +3232,8 @@ declare class WebhookResource extends BaseResource {
|
|
|
3224
3232
|
* }
|
|
3225
3233
|
* ```
|
|
3226
3234
|
* @throws {ValidationError} If no account ID is available.
|
|
3227
|
-
* @throws {ApiError} If the API rejects the request
|
|
3235
|
+
* @throws {ApiError} If the API rejects the request, including `403` when
|
|
3236
|
+
* an OAuth token lacks `webhooks:write`.
|
|
3228
3237
|
*
|
|
3229
3238
|
* @example
|
|
3230
3239
|
* ```ts
|
|
@@ -4238,7 +4247,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4238
4247
|
* "scopes_supported": [
|
|
4239
4248
|
* "documents:read", "documents:write",
|
|
4240
4249
|
* "templates:read", "templates:write",
|
|
4241
|
-
* "account:read", "openid", "profile", "email"
|
|
4250
|
+
* "account:read", "webhooks:write", "openid", "profile", "email"
|
|
4242
4251
|
* ],
|
|
4243
4252
|
* "bearer_methods_supported": ["header"]
|
|
4244
4253
|
* }
|
|
@@ -4275,16 +4284,19 @@ declare class OAuthResource extends BaseResource {
|
|
|
4275
4284
|
* "userinfo_endpoint": "https://api.assinafy.com.br/v1/oauth/userinfo",
|
|
4276
4285
|
* "jwks_uri": "https://auth.assinafy.com.br/.well-known/jwks.json",
|
|
4277
4286
|
* "scopes_supported": ["documents:read", "documents:write", "templates:read",
|
|
4278
|
-
* "templates:write", "account:read", "openid",
|
|
4287
|
+
* "templates:write", "account:read", "webhooks:write", "openid",
|
|
4279
4288
|
* "profile", "email", "offline_access"],
|
|
4280
4289
|
* "response_types_supported": ["code"],
|
|
4281
|
-
* "grant_types_supported": ["authorization_code", "refresh_token"
|
|
4290
|
+
* "grant_types_supported": ["authorization_code", "refresh_token",
|
|
4291
|
+
* "urn:ietf:params:oauth:grant-type:token-exchange"],
|
|
4282
4292
|
* "code_challenge_methods_supported": ["S256"],
|
|
4283
4293
|
* "token_endpoint_auth_methods_supported": ["client_secret_post", "none"],
|
|
4284
4294
|
* "authorization_response_iss_parameter_supported": true,
|
|
4285
4295
|
* "client_id_metadata_document_supported": true
|
|
4286
4296
|
* }
|
|
4287
4297
|
* ```
|
|
4298
|
+
* The token-exchange grant is reserved for Assinafy's internal service
|
|
4299
|
+
* clients; integrations use `authorization_code` and `refresh_token`.
|
|
4288
4300
|
* @throws {ValidationError} If `issuer` is not an absolute `https://` URL,
|
|
4289
4301
|
* or the document's own `issuer` disagrees with where it was fetched from
|
|
4290
4302
|
* (RFC 8414 §3.3 — a mismatch means the document is not authoritative).
|
|
@@ -4318,6 +4330,7 @@ declare class OAuthResource extends BaseResource {
|
|
|
4318
4330
|
* `['documents:read', 'documents:write', 'offline_access']`. Ask for the
|
|
4319
4331
|
* minimum: the user approves all of them or none. Add `offline_access` to
|
|
4320
4332
|
* receive a refresh token and `openid` to receive an `id_token`.
|
|
4333
|
+
* `webhooks:write` permits subscription updates and inactivation.
|
|
4321
4334
|
* @param options.authorizationEndpoint - Skip discovery by supplying the
|
|
4322
4335
|
* endpoint yourself. Defaults to the discovered
|
|
4323
4336
|
* `authorization_endpoint`.
|
package/dist/index.js
CHANGED
|
@@ -634,7 +634,7 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
634
634
|
// package.json
|
|
635
635
|
var package_default = {
|
|
636
636
|
name: "@assinafy/sdk",
|
|
637
|
-
version: "2.
|
|
637
|
+
version: "2.4.1",
|
|
638
638
|
packageManager: "bun@1.4.0",
|
|
639
639
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
640
640
|
type: "commonjs",
|
|
@@ -1071,8 +1071,8 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1071
1071
|
throw new ValidationError("method must be virtual or collect");
|
|
1072
1072
|
}
|
|
1073
1073
|
const signers = Array.isArray(payload.signers) ? payload.signers : [];
|
|
1074
|
-
if (
|
|
1075
|
-
throw new ValidationError("At least one signer is required for a
|
|
1074
|
+
if (signers.length === 0) {
|
|
1075
|
+
throw new ValidationError("At least one signer is required for a cost estimate");
|
|
1076
1076
|
}
|
|
1077
1077
|
const entries = payload.entries === void 0 ? void 0 : normaliseAssignmentEntries(payload.entries);
|
|
1078
1078
|
if (method === "collect" && (!entries || entries.length === 0)) {
|
|
@@ -1080,7 +1080,7 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
return cleanParams({
|
|
1082
1082
|
method,
|
|
1083
|
-
signers: signers.
|
|
1083
|
+
signers: signers.map((signer) => normaliseEstimateSigner(signer)),
|
|
1084
1084
|
entries
|
|
1085
1085
|
});
|
|
1086
1086
|
}
|
|
@@ -1461,7 +1461,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1461
1461
|
* }
|
|
1462
1462
|
* ```
|
|
1463
1463
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
1464
|
-
* has no signer entry, or a `collect` request has no
|
|
1464
|
+
* has no signer entry, or a `collect` request has no signer entry or no
|
|
1465
|
+
* field-placement entry.
|
|
1465
1466
|
* @throws {ApiError} If the API rejects the request.
|
|
1466
1467
|
*
|
|
1467
1468
|
* @example
|
|
@@ -3667,6 +3668,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3667
3668
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3668
3669
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
3669
3670
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3671
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3670
3672
|
*
|
|
3671
3673
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3672
3674
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
@@ -3690,7 +3692,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
3690
3692
|
* ```
|
|
3691
3693
|
* @throws {ValidationError} If `url` / `email` is invalid, `events` /
|
|
3692
3694
|
* `is_active` has the wrong type, or no account ID is available.
|
|
3693
|
-
* @throws {ApiError} If the API rejects the subscription
|
|
3695
|
+
* @throws {ApiError} If the API rejects the subscription, including `403`
|
|
3696
|
+
* when an OAuth token lacks `webhooks:write`.
|
|
3694
3697
|
*
|
|
3695
3698
|
* @example
|
|
3696
3699
|
* ```ts
|
|
@@ -3788,6 +3791,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3788
3791
|
* subscription-delete route. The subscription is retained (with its `url`
|
|
3789
3792
|
* and `events`) and simply stops firing; re-enable it by calling
|
|
3790
3793
|
* {@link WebhookResource.register} again with `is_active: true`.
|
|
3794
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3791
3795
|
*
|
|
3792
3796
|
* @param accountId - Override the client's default account ID.
|
|
3793
3797
|
* @returns The subscription with `is_active` flipped to `false`. Response
|
|
@@ -3808,7 +3812,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
3808
3812
|
* }
|
|
3809
3813
|
* ```
|
|
3810
3814
|
* @throws {ValidationError} If no account ID is available.
|
|
3811
|
-
* @throws {ApiError} If the API rejects the request
|
|
3815
|
+
* @throws {ApiError} If the API rejects the request, including `403` when
|
|
3816
|
+
* an OAuth token lacks `webhooks:write`.
|
|
3812
3817
|
*
|
|
3813
3818
|
* @example
|
|
3814
3819
|
* ```ts
|
|
@@ -4986,7 +4991,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
4986
4991
|
* "scopes_supported": [
|
|
4987
4992
|
* "documents:read", "documents:write",
|
|
4988
4993
|
* "templates:read", "templates:write",
|
|
4989
|
-
* "account:read", "openid", "profile", "email"
|
|
4994
|
+
* "account:read", "webhooks:write", "openid", "profile", "email"
|
|
4990
4995
|
* ],
|
|
4991
4996
|
* "bearer_methods_supported": ["header"]
|
|
4992
4997
|
* }
|
|
@@ -5028,16 +5033,19 @@ var OAuthResource = class extends BaseResource {
|
|
|
5028
5033
|
* "userinfo_endpoint": "https://api.assinafy.com.br/v1/oauth/userinfo",
|
|
5029
5034
|
* "jwks_uri": "https://auth.assinafy.com.br/.well-known/jwks.json",
|
|
5030
5035
|
* "scopes_supported": ["documents:read", "documents:write", "templates:read",
|
|
5031
|
-
* "templates:write", "account:read", "openid",
|
|
5036
|
+
* "templates:write", "account:read", "webhooks:write", "openid",
|
|
5032
5037
|
* "profile", "email", "offline_access"],
|
|
5033
5038
|
* "response_types_supported": ["code"],
|
|
5034
|
-
* "grant_types_supported": ["authorization_code", "refresh_token"
|
|
5039
|
+
* "grant_types_supported": ["authorization_code", "refresh_token",
|
|
5040
|
+
* "urn:ietf:params:oauth:grant-type:token-exchange"],
|
|
5035
5041
|
* "code_challenge_methods_supported": ["S256"],
|
|
5036
5042
|
* "token_endpoint_auth_methods_supported": ["client_secret_post", "none"],
|
|
5037
5043
|
* "authorization_response_iss_parameter_supported": true,
|
|
5038
5044
|
* "client_id_metadata_document_supported": true
|
|
5039
5045
|
* }
|
|
5040
5046
|
* ```
|
|
5047
|
+
* The token-exchange grant is reserved for Assinafy's internal service
|
|
5048
|
+
* clients; integrations use `authorization_code` and `refresh_token`.
|
|
5041
5049
|
* @throws {ValidationError} If `issuer` is not an absolute `https://` URL,
|
|
5042
5050
|
* or the document's own `issuer` disagrees with where it was fetched from
|
|
5043
5051
|
* (RFC 8414 §3.3 — a mismatch means the document is not authoritative).
|
|
@@ -5085,6 +5093,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5085
5093
|
* `['documents:read', 'documents:write', 'offline_access']`. Ask for the
|
|
5086
5094
|
* minimum: the user approves all of them or none. Add `offline_access` to
|
|
5087
5095
|
* receive a refresh token and `openid` to receive an `id_token`.
|
|
5096
|
+
* `webhooks:write` permits subscription updates and inactivation.
|
|
5088
5097
|
* @param options.authorizationEndpoint - Skip discovery by supplying the
|
|
5089
5098
|
* endpoint yourself. Defaults to the discovered
|
|
5090
5099
|
* `authorization_endpoint`.
|
package/dist/index.mjs
CHANGED
|
@@ -574,7 +574,7 @@ import axios2 from "axios";
|
|
|
574
574
|
// package.json
|
|
575
575
|
var package_default = {
|
|
576
576
|
name: "@assinafy/sdk",
|
|
577
|
-
version: "2.
|
|
577
|
+
version: "2.4.1",
|
|
578
578
|
packageManager: "bun@1.4.0",
|
|
579
579
|
description: "TypeScript SDK for Assinafy API - Digital signature platform",
|
|
580
580
|
type: "commonjs",
|
|
@@ -1011,8 +1011,8 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1011
1011
|
throw new ValidationError("method must be virtual or collect");
|
|
1012
1012
|
}
|
|
1013
1013
|
const signers = Array.isArray(payload.signers) ? payload.signers : [];
|
|
1014
|
-
if (
|
|
1015
|
-
throw new ValidationError("At least one signer is required for a
|
|
1014
|
+
if (signers.length === 0) {
|
|
1015
|
+
throw new ValidationError("At least one signer is required for a cost estimate");
|
|
1016
1016
|
}
|
|
1017
1017
|
const entries = payload.entries === void 0 ? void 0 : normaliseAssignmentEntries(payload.entries);
|
|
1018
1018
|
if (method === "collect" && (!entries || entries.length === 0)) {
|
|
@@ -1020,7 +1020,7 @@ function buildAssignmentEstimatePayload(payload) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
return cleanParams({
|
|
1022
1022
|
method,
|
|
1023
|
-
signers: signers.
|
|
1023
|
+
signers: signers.map((signer) => normaliseEstimateSigner(signer)),
|
|
1024
1024
|
entries
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
@@ -1401,7 +1401,8 @@ var AssignmentResource = class extends BaseResource {
|
|
|
1401
1401
|
* }
|
|
1402
1402
|
* ```
|
|
1403
1403
|
* @throws {ValidationError} If `documentId` is missing, a `virtual` request
|
|
1404
|
-
* has no signer entry, or a `collect` request has no
|
|
1404
|
+
* has no signer entry, or a `collect` request has no signer entry or no
|
|
1405
|
+
* field-placement entry.
|
|
1405
1406
|
* @throws {ApiError} If the API rejects the request.
|
|
1406
1407
|
*
|
|
1407
1408
|
* @example
|
|
@@ -3607,6 +3608,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3607
3608
|
* When `events` is omitted or empty, {@link DEFAULT_WEBHOOK_EVENTS} is used
|
|
3608
3609
|
* (`document_ready`, `document_prepared`, `signer_signed_document`,
|
|
3609
3610
|
* `signer_rejected_document`, `document_processing_failed`).
|
|
3611
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3610
3612
|
*
|
|
3611
3613
|
* @param payload - Subscription details. `url` and `email` are required;
|
|
3612
3614
|
* `events` defaults to {@link DEFAULT_WEBHOOK_EVENTS} and `is_active`
|
|
@@ -3630,7 +3632,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
3630
3632
|
* ```
|
|
3631
3633
|
* @throws {ValidationError} If `url` / `email` is invalid, `events` /
|
|
3632
3634
|
* `is_active` has the wrong type, or no account ID is available.
|
|
3633
|
-
* @throws {ApiError} If the API rejects the subscription
|
|
3635
|
+
* @throws {ApiError} If the API rejects the subscription, including `403`
|
|
3636
|
+
* when an OAuth token lacks `webhooks:write`.
|
|
3634
3637
|
*
|
|
3635
3638
|
* @example
|
|
3636
3639
|
* ```ts
|
|
@@ -3728,6 +3731,7 @@ var WebhookResource = class extends BaseResource {
|
|
|
3728
3731
|
* subscription-delete route. The subscription is retained (with its `url`
|
|
3729
3732
|
* and `events`) and simply stops firing; re-enable it by calling
|
|
3730
3733
|
* {@link WebhookResource.register} again with `is_active: true`.
|
|
3734
|
+
* OAuth tokens need the `webhooks:write` scope.
|
|
3731
3735
|
*
|
|
3732
3736
|
* @param accountId - Override the client's default account ID.
|
|
3733
3737
|
* @returns The subscription with `is_active` flipped to `false`. Response
|
|
@@ -3748,7 +3752,8 @@ var WebhookResource = class extends BaseResource {
|
|
|
3748
3752
|
* }
|
|
3749
3753
|
* ```
|
|
3750
3754
|
* @throws {ValidationError} If no account ID is available.
|
|
3751
|
-
* @throws {ApiError} If the API rejects the request
|
|
3755
|
+
* @throws {ApiError} If the API rejects the request, including `403` when
|
|
3756
|
+
* an OAuth token lacks `webhooks:write`.
|
|
3752
3757
|
*
|
|
3753
3758
|
* @example
|
|
3754
3759
|
* ```ts
|
|
@@ -4926,7 +4931,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
4926
4931
|
* "scopes_supported": [
|
|
4927
4932
|
* "documents:read", "documents:write",
|
|
4928
4933
|
* "templates:read", "templates:write",
|
|
4929
|
-
* "account:read", "openid", "profile", "email"
|
|
4934
|
+
* "account:read", "webhooks:write", "openid", "profile", "email"
|
|
4930
4935
|
* ],
|
|
4931
4936
|
* "bearer_methods_supported": ["header"]
|
|
4932
4937
|
* }
|
|
@@ -4968,16 +4973,19 @@ var OAuthResource = class extends BaseResource {
|
|
|
4968
4973
|
* "userinfo_endpoint": "https://api.assinafy.com.br/v1/oauth/userinfo",
|
|
4969
4974
|
* "jwks_uri": "https://auth.assinafy.com.br/.well-known/jwks.json",
|
|
4970
4975
|
* "scopes_supported": ["documents:read", "documents:write", "templates:read",
|
|
4971
|
-
* "templates:write", "account:read", "openid",
|
|
4976
|
+
* "templates:write", "account:read", "webhooks:write", "openid",
|
|
4972
4977
|
* "profile", "email", "offline_access"],
|
|
4973
4978
|
* "response_types_supported": ["code"],
|
|
4974
|
-
* "grant_types_supported": ["authorization_code", "refresh_token"
|
|
4979
|
+
* "grant_types_supported": ["authorization_code", "refresh_token",
|
|
4980
|
+
* "urn:ietf:params:oauth:grant-type:token-exchange"],
|
|
4975
4981
|
* "code_challenge_methods_supported": ["S256"],
|
|
4976
4982
|
* "token_endpoint_auth_methods_supported": ["client_secret_post", "none"],
|
|
4977
4983
|
* "authorization_response_iss_parameter_supported": true,
|
|
4978
4984
|
* "client_id_metadata_document_supported": true
|
|
4979
4985
|
* }
|
|
4980
4986
|
* ```
|
|
4987
|
+
* The token-exchange grant is reserved for Assinafy's internal service
|
|
4988
|
+
* clients; integrations use `authorization_code` and `refresh_token`.
|
|
4981
4989
|
* @throws {ValidationError} If `issuer` is not an absolute `https://` URL,
|
|
4982
4990
|
* or the document's own `issuer` disagrees with where it was fetched from
|
|
4983
4991
|
* (RFC 8414 §3.3 — a mismatch means the document is not authoritative).
|
|
@@ -5025,6 +5033,7 @@ var OAuthResource = class extends BaseResource {
|
|
|
5025
5033
|
* `['documents:read', 'documents:write', 'offline_access']`. Ask for the
|
|
5026
5034
|
* minimum: the user approves all of them or none. Add `offline_access` to
|
|
5027
5035
|
* receive a refresh token and `openid` to receive an `id_token`.
|
|
5036
|
+
* `webhooks:write` permits subscription updates and inactivation.
|
|
5028
5037
|
* @param options.authorizationEndpoint - Skip discovery by supplying the
|
|
5029
5038
|
* endpoint yourself. Defaults to the discovered
|
|
5030
5039
|
* `authorization_endpoint`.
|
package/docs/API_COVERAGE.md
CHANGED
|
@@ -101,6 +101,8 @@ operations answer with flat RFC 6749 / OIDC bodies rather than the
|
|
|
101
101
|
`{ status, message, data }` envelope used everywhere else, and the SDK returns
|
|
102
102
|
them unwrapped. The browser-facing `/oauth/authorize` page belongs to the
|
|
103
103
|
authorization server (`https://auth.assinafy.com.br`), not to this API.
|
|
104
|
+
The token endpoint also advertises an internal-service token-exchange grant;
|
|
105
|
+
ordinary OAuth applications use the two SDK methods listed below.
|
|
104
106
|
|
|
105
107
|
| Method | Path | SDK method | Status |
|
|
106
108
|
| --- | --- | --- | --- |
|