@assinafy/sdk 2.10.0 → 2.11.0

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/dist/index.mjs CHANGED
@@ -454,6 +454,17 @@ function assertDateTime(value, label) {
454
454
  throw new ValidationError(`${label} must be an ISO-8601 date-time`);
455
455
  }
456
456
  }
457
+ function assertExpirationDate(value, label) {
458
+ if (typeof value !== "string") {
459
+ throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
460
+ }
461
+ const normalized = /^\d{4}-\d{2}-\d{2}$/u.test(value) ? `${value}T00:00:00Z` : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?$/u.test(value) ? `${value}Z` : value;
462
+ try {
463
+ assertDateTime(normalized, label);
464
+ } catch {
465
+ throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
466
+ }
467
+ }
457
468
  function cleanParams(params) {
458
469
  assertRecord(params, "params");
459
470
  const out = {};
@@ -628,7 +639,7 @@ import axios2 from "axios";
628
639
  // package.json
629
640
  var package_default = {
630
641
  name: "@assinafy/sdk",
631
- version: "2.10.0",
642
+ version: "2.11.0",
632
643
  packageManager: "bun@1.4.4",
633
644
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
634
645
  type: "commonjs",
@@ -712,7 +723,8 @@ var package_default = {
712
723
  overrides: {
713
724
  esbuild: "0.28.2",
714
725
  "follow-redirects": "1.16.2",
715
- "brace-expansion": "5.0.12"
726
+ "brace-expansion": "5.0.12",
727
+ minimatch: "11.0.3"
716
728
  },
717
729
  files: [
718
730
  "dist",
@@ -1066,7 +1078,7 @@ function buildAssignmentPayload(payload) {
1066
1078
  if (payload.message !== void 0 && typeof payload.message !== "string") {
1067
1079
  throw new ValidationError("message must be a string");
1068
1080
  }
1069
- if (payload.expires_at !== void 0) assertDateTime(payload.expires_at, "expires_at");
1081
+ if (payload.expires_at !== void 0) assertExpirationDate(payload.expires_at, "expires_at");
1070
1082
  if (payload.copy_receivers !== void 0 && (!Array.isArray(payload.copy_receivers) || payload.copy_receivers.some(
1071
1083
  (id) => typeof id !== "string" || !id.trim()
1072
1084
  ))) {
@@ -1238,7 +1250,7 @@ var AssignmentResource = class extends BaseResource {
1238
1250
  * without it. Note the camelCase spelling: `account_id` and an
1239
1251
  * `X-Account-Id` header are both rejected.
1240
1252
  *
1241
- * @param params - `page`, `per-page`.
1253
+ * @param params - `page`, `per-page`, and `sort`.
1242
1254
  * @param accountId - Override the client's default account ID.
1243
1255
  * @returns Assignments, with pagination in `meta`. Each item is a full
1244
1256
  * {@link IAssignment} (same shape as {@link AssignmentResource.create}
@@ -1371,6 +1383,8 @@ var AssignmentResource = class extends BaseResource {
1371
1383
  * @param payload - Signers plus optional `method` (defaults to `virtual`),
1372
1384
  * `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
1373
1385
  * addresses), and `collect`-mode `entries` with page-image geometry.
1386
+ * `expires_at` accepts a date (ending at 23:59 UTC), a date-time without
1387
+ * an offset (UTC), or an offset-aware date-time.
1374
1388
  * @returns The created {@link IAssignment}: `signers` (rich, with `step` /
1375
1389
  * `notified` / `verification_method`), `items` (one row per signer × field),
1376
1390
  * a `summary` count block, and per-signer `signing_urls`. Response shape:
@@ -1558,9 +1572,10 @@ var AssignmentResource = class extends BaseResource {
1558
1572
  * (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
1559
1573
  *
1560
1574
  * Sends `{ expires_at }` verbatim; the key itself is required by the
1561
- * contract. Use an ISO-8601 date/time string, or `null` to remove the
1562
- * expiration — `null` is the documented clear mechanism and, unlike
1563
- * ordinary nullable inputs, is intentionally not stripped from the body.
1575
+ * contract. Use an ISO-8601 date, a date-time with or without an offset,
1576
+ * or `null` to remove the expiration. Date-only values end at 23:59 UTC;
1577
+ * date-times without offsets are UTC. `null` is intentionally not stripped
1578
+ * from the body.
1564
1579
  *
1565
1580
  * Request body (`application/json`):
1566
1581
  * ```jsonc
@@ -1571,8 +1586,8 @@ var AssignmentResource = class extends BaseResource {
1571
1586
  *
1572
1587
  * @param documentId - The document the assignment belongs to.
1573
1588
  * @param assignmentId - The assignment to update.
1574
- * @param expiresAt - New expiry as an ISO-8601 date/time string, or `null`
1575
- * to remove the expiration.
1589
+ * @param expiresAt - New expiry as an ISO-8601 date or date-time string,
1590
+ * or `null` to remove the expiration.
1576
1591
  * @returns The updated {@link IAssignment} — the same full shape
1577
1592
  * {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
1578
1593
  * `signing_urls`), with `expires_at` reflecting the new value:
@@ -1616,7 +1631,7 @@ var AssignmentResource = class extends BaseResource {
1616
1631
  async resetExpiration(documentId, assignmentId, expiresAt) {
1617
1632
  const docId = this.requireId(documentId, "Document ID");
1618
1633
  const asgId = this.requireId(assignmentId, "Assignment ID");
1619
- if (expiresAt !== null) assertDateTime(expiresAt, "expiresAt");
1634
+ if (expiresAt !== null) assertExpirationDate(expiresAt, "expiresAt");
1620
1635
  return this.call(
1621
1636
  "Failed to update assignment expiration",
1622
1637
  () => this.http.put(
@@ -2076,7 +2091,7 @@ var DocumentResource = class extends BaseResource {
2076
2091
  * a compact representation with no expanded `assignment` or `pages`, so
2077
2092
  * prefer it for name lookups and pickers.
2078
2093
  *
2079
- * @param params - `search`, `status`, `page`, `per-page`.
2094
+ * @param params - `search`, `status`, `page`, `per-page`, and `sort`.
2080
2095
  * @param accountId - Override the client's default account ID.
2081
2096
  * @returns Matching documents, with pagination in `meta`. Each item:
2082
2097
  * ```jsonc
@@ -2738,9 +2753,11 @@ var DocumentResource = class extends BaseResource {
2738
2753
  *
2739
2754
  * Instantiates the template, binding each role to a signer, and returns the
2740
2755
  * new document. The request body is `{ signers, ...options }` — `signers`
2741
- * maps every template `role_id` to an existing account signer `id`, and
2742
- * `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
2743
- * tag names in `tags` (unknown names are created automatically).
2756
+ * maps every template `role_id` to an existing signer `id` or an `email`.
2757
+ * An email reuses the matching account signer or creates one with `name`;
2758
+ * `id` wins when both are present. Options may add `name`, `message`,
2759
+ * `expires_at`, `editor_fields`, and tag names in `tags` (unknown names are
2760
+ * created automatically).
2744
2761
  *
2745
2762
  * Request body (`application/json`):
2746
2763
  * ```jsonc
@@ -2748,7 +2765,9 @@ var DocumentResource = class extends BaseResource {
2748
2765
  * "signers": [
2749
2766
  * {
2750
2767
  * "role_id": "signing_role_example",
2751
- * "id": "signer_example",
2768
+ * "email": "signer@example.com",
2769
+ * "name": "Example Signer",
2770
+ * "whatsapp_phone_number": "+15555550100",
2752
2771
  * "verification_method": "Email",
2753
2772
  * "notification_methods": [
2754
2773
  * "Email"
@@ -2772,27 +2791,33 @@ var DocumentResource = class extends BaseResource {
2772
2791
  * ```
2773
2792
  *
2774
2793
  * @param templateId - The template to instantiate.
2775
- * @param signers - Role-to-signer bindings (each with `role_id` and `id`,
2776
- * plus optional `verification_method`, `notification_methods`, `step`).
2794
+ * @param signers - Role-to-signer bindings (each with `role_id` and either
2795
+ * an existing `id` or an `email`; email creation also accepts `name` and
2796
+ * `whatsapp_phone_number`). `verification_method`, `notification_methods`,
2797
+ * and `step` are optional.
2777
2798
  * Only one notification method is allowed per signer; when only one of the
2778
2799
  * verification/notification fields is supplied, the API infers the other.
2779
2800
  * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
2780
2801
  * signer `government_id`, and that signer must be alone in its step. The
2781
- * server derives the assignment method from placed template fields but
2782
- * does not yet reject unusable certificate/`collect` combinations, so the
2783
- * SDK temporarily refuses certificate signers on this template route.
2802
+ * server derives the assignment method from placed template fields and
2803
+ * rejects certificate signers when those fields produce a `collect`
2804
+ * assignment. Use a template without placed signer fields for certificate
2805
+ * signing.
2784
2806
  * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
2785
2807
  * and a valid CPF in `government_id`; estimate the per-signer fee first.
2786
2808
  * @param options - Optional `name`, `message`, `expires_at`,
2787
2809
  * `editor_fields`, `tags`.
2788
2810
  * @param options.name - Generated document display name.
2789
2811
  * @param options.message - Signing invitation message.
2790
- * @param options.expires_at - ISO-8601 signature deadline.
2812
+ * @param options.expires_at - ISO-8601 deadline: date-only (ends at 23:59
2813
+ * UTC), date-time without an offset (treated as UTC), or an offset-aware
2814
+ * date-time.
2791
2815
  * @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
2792
2816
  * @param options.tags - Tag names attached to the generated document.
2793
2817
  * @param accountId - Override the client's default account ID.
2794
- * @returns The created document (an {@link IDocumentDetailsResponse} with
2795
- * `template_id` set and its `assignment` populated):
2818
+ * @returns The uploaded document. Assignment creation continues in the
2819
+ * background; follow `GET /documents/{documentId}` or webhooks until the
2820
+ * document becomes `pending_signature` or `failed`:
2796
2821
  * ```jsonc
2797
2822
  * {
2798
2823
  * "resource": "document",
@@ -2800,22 +2825,21 @@ var DocumentResource = class extends BaseResource {
2800
2825
  * "account_id": "acc_example",
2801
2826
  * "template_id": "103a0991a5cde83518e5672aa9aa",
2802
2827
  * "name": "Service agreement from template",
2803
- * "status": "pending_signature",
2804
- * "artifacts": { "original": "https://…/download/original", "thumbnail": "https://…/thumbnail" },
2828
+ * "status": "uploaded",
2829
+ * "artifacts": { "original": "https://…/download/original" },
2805
2830
  * "is_closed": false,
2806
2831
  * "signing_url": "https://app.assinafy.com.br/sign/19f675b7…",
2807
2832
  * "tags": [{ "id": "103a0992…", "name": "agreements", "color": null }],
2808
- * "assignment": { "id": "103a09a1…", "method": "virtual", "summary": { "signer_count": 1, "completed_count": 0 } },
2809
- * "pages": [{ "id": "103a0992…", "number": 1, "height": 1651, "width": 1275, "download_url": "https://…/download" }],
2833
+ * "assignment": null,
2834
+ * "pages": [],
2810
2835
  * "created_at": "2026-07-15T19:57:55Z",
2811
2836
  * "updated_at": "2026-07-15T19:59:33Z"
2812
2837
  * }
2813
2838
  * ```
2814
- * @throws {ValidationError} If `templateId` is missing, no account ID is
2815
- * available, or a signer uses `DigitalCertificate`. Certificate refusals
2816
- * have `errors.code === 'digital_certificate_requires_virtual_method'`.
2817
- * @throws {ApiError} `400` if the signers/roles are invalid or the template
2818
- * is not ready.
2839
+ * @throws {ValidationError} If `templateId`, an account ID, signer identity,
2840
+ * channel, order, deadline, editor field, or tag is invalid.
2841
+ * @throws {ApiError} `400` if the signers/roles are invalid, the template
2842
+ * is not ready, or placed signer fields conflict with `DigitalCertificate`.
2819
2843
  *
2820
2844
  * @example
2821
2845
  * ```ts
@@ -2832,7 +2856,7 @@ var DocumentResource = class extends BaseResource {
2832
2856
  if (options.message !== void 0 && typeof options.message !== "string") {
2833
2857
  throw new ValidationError("message must be a string");
2834
2858
  }
2835
- if (options.expires_at !== void 0) assertDateTime(options.expires_at, "expires_at");
2859
+ if (options.expires_at !== void 0) assertExpirationDate(options.expires_at, "expires_at");
2836
2860
  const editorFields = options.editor_fields === void 0 ? void 0 : normaliseTemplateEditorFields(options.editor_fields);
2837
2861
  if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag.trim()))) {
2838
2862
  throw new ValidationError("tags must be an array of non-empty tag names");
@@ -2862,10 +2886,8 @@ var DocumentResource = class extends BaseResource {
2862
2886
  *
2863
2887
  * A dry run: sends only `{ signers }` and consumes nothing. Use it to check
2864
2888
  * balances before calling {@link DocumentResource.createFromTemplate}.
2865
- * `DigitalCertificate` requires a provably `virtual` assignment. Because
2866
- * this route leaves method detection to the server, the SDK temporarily
2867
- * refuses certificate signers instead of returning a price for an
2868
- * assignment that may charge credits but cannot be completed.
2889
+ * `DigitalCertificate` adds 0.5 credits per signer plus notification cost;
2890
+ * the API returns `400` when the template has placed signer fields.
2869
2891
  *
2870
2892
  * Request body (`application/json`):
2871
2893
  * ```jsonc
@@ -2907,10 +2929,10 @@ var DocumentResource = class extends BaseResource {
2907
2929
  * "message": null
2908
2930
  * }
2909
2931
  * ```
2910
- * @throws {ValidationError} If `templateId` is missing, no account ID is
2911
- * available, or a signer uses `DigitalCertificate`. Certificate refusals
2912
- * have `errors.code === 'digital_certificate_requires_virtual_method'`.
2913
- * @throws {ApiError} If the API rejects the request.
2932
+ * @throws {ValidationError} If `templateId`, an account ID, role, or
2933
+ * channel is invalid.
2934
+ * @throws {ApiError} `400` if the role is invalid or placed signer fields
2935
+ * conflict with `DigitalCertificate`; `403` when a feature is unavailable.
2914
2936
  *
2915
2937
  * @example
2916
2938
  * ```ts
@@ -3190,11 +3212,33 @@ function normaliseTemplateSigners(signers) {
3190
3212
  if (typeof signer.role_id !== "string" || !signer.role_id.trim()) {
3191
3213
  throw new ValidationError(`Template signer ${index + 1} requires role_id`);
3192
3214
  }
3193
- if (typeof signer.id !== "string" || !signer.id.trim()) {
3194
- throw new ValidationError(`Template signer ${index + 1} requires id`);
3195
- }
3196
3215
  validateAssignmentSignerOptions(signer, `Template signer ${index + 1}`);
3197
- const projected = { role_id: signer.role_id, id: signer.id };
3216
+ const projected = { role_id: signer.role_id };
3217
+ if (signer.id !== void 0) {
3218
+ if (typeof signer.id !== "string" || !signer.id.trim()) {
3219
+ throw new ValidationError(`Template signer ${index + 1} id must be non-empty`);
3220
+ }
3221
+ projected.id = signer.id;
3222
+ } else {
3223
+ if (!isEmail(signer.email)) {
3224
+ throw new ValidationError(`Template signer ${index + 1} requires a valid id or email`);
3225
+ }
3226
+ projected.email = signer.email;
3227
+ if (signer.name !== void 0) {
3228
+ if (typeof signer.name !== "string" || !signer.name.trim()) {
3229
+ throw new ValidationError(`Template signer ${index + 1} name must be non-empty`);
3230
+ }
3231
+ projected.name = signer.name;
3232
+ }
3233
+ if (signer.whatsapp_phone_number !== void 0) {
3234
+ if (!isE164PhoneNumber(signer.whatsapp_phone_number)) {
3235
+ throw new ValidationError(
3236
+ `Template signer ${index + 1} whatsapp_phone_number must be E.164`
3237
+ );
3238
+ }
3239
+ projected.whatsapp_phone_number = signer.whatsapp_phone_number;
3240
+ }
3241
+ }
3198
3242
  if (signer.verification_method !== void 0) {
3199
3243
  projected.verification_method = signer.verification_method;
3200
3244
  }
@@ -3204,7 +3248,6 @@ function normaliseTemplateSigners(signers) {
3204
3248
  if (signer.step !== void 0) projected.step = signer.step;
3205
3249
  return projected;
3206
3250
  });
3207
- validateDigitalCertificateMethod(void 0, normalised);
3208
3251
  return normalised;
3209
3252
  }
3210
3253
  function normaliseTemplateEditorFields(fields) {
@@ -3245,7 +3288,6 @@ function normaliseTemplateCostSigners(signers) {
3245
3288
  }
3246
3289
  return descriptor;
3247
3290
  });
3248
- validateDigitalCertificateMethod(void 0, normalised);
3249
3291
  return normalised;
3250
3292
  }
3251
3293
  function validateWaitOption(value, name) {
@@ -4146,6 +4188,8 @@ var WebhookResource = class extends BaseResource {
4146
4188
  * "document_processing_failed"
4147
4189
  * ],
4148
4190
  * "is_active": true,
4191
+ * "is_held": false,
4192
+ * "held_since": null,
4149
4193
  * "updated_at": "2026-07-18T02:36:02Z" // no `id` / `created_at` are returned
4150
4194
  * }
4151
4195
  * ```
@@ -4315,11 +4359,12 @@ var WebhookResource = class extends BaseResource {
4315
4359
  * (`GET /accounts/{accountId}/webhooks`). Pagination info (if any) is
4316
4360
  * attached in `meta`.
4317
4361
  *
4318
- * Assinafy treats any `2xx` response as success. It makes at most two
4319
- * attempts per event with a three-second wait. After ten consecutive failed
4320
- * events, the circuit breaker pauses normal delivery and sends roughly 5%
4321
- * as recovery checks until one succeeds. The stored `response_body` is
4322
- * truncated to 2,000 characters.
4362
+ * Assinafy treats any `2xx` response as success. Retriable failures get up
4363
+ * to six attempts about ten minutes apart. After ten failed deliveries in
4364
+ * a row, the endpoint is paused and probed after 3, 15 and 60 minutes, then
4365
+ * every six hours. A successful delivery or probe resumes the endpoint and
4366
+ * replays missed events oldest first. Response bodies are truncated to
4367
+ * 2,000 characters and delivery entries are retained for seven days.
4323
4368
  *
4324
4369
  * @param params - Optional filters and pagination:
4325
4370
  * - `endpoint_id` — only deliveries to this webhook endpoint.
@@ -4346,6 +4391,10 @@ var WebhookResource = class extends BaseResource {
4346
4391
  * // subject: <User>, account_id, created_at }
4347
4392
  * },
4348
4393
  * "delivered": true,
4394
+ * "webhook_id": "9f86d081884c7d659a2feaa0c55ad015",
4395
+ * "attempt": 1,
4396
+ * "kind": "scheduled",
4397
+ * "will_retry": false,
4349
4398
  * "http_status": 200,
4350
4399
  * "response_body": "{ ... }", // receiving endpoint body, max 2,000 chars
4351
4400
  * "error": null,
@@ -4438,11 +4487,14 @@ var WebhookResource = class extends BaseResource {
4438
4487
  * [
4439
4488
  * {
4440
4489
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4490
+ * "resource": "activity_event_subscription",
4441
4491
  * "name": "ERP",
4442
4492
  * "url": "https://example.com/webhooks/assinafy",
4443
4493
  * "email": "ops@example.com",
4444
4494
  * "events": ["document_ready", "signer_signed_document"],
4445
4495
  * "is_active": true,
4496
+ * "is_held": false,
4497
+ * "held_since": null,
4446
4498
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4447
4499
  * "created_at": "2026-10-01T12:00:00Z",
4448
4500
  * "updated_at": "2026-10-01T12:00:00Z"
@@ -4460,7 +4512,7 @@ var WebhookResource = class extends BaseResource {
4460
4512
  */
4461
4513
  async listEndpoints(accountId, params = {}) {
4462
4514
  assertRecord(params, "webhook endpoint filters");
4463
- if (params.url !== void 0) validateWebhookUrl(params.url);
4515
+ if (params.url !== void 0) validateWebhookUrl(params.url, true);
4464
4516
  const path2 = this.endpointsPath(accountId);
4465
4517
  return this.call(
4466
4518
  "Failed to list webhook endpoints",
@@ -4474,8 +4526,8 @@ var WebhookResource = class extends BaseResource {
4474
4526
  * An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
4475
4527
  * of a workspace needs a different `url`. With `signing_enabled: true` the
4476
4528
  * API returns a signing `secret` in this creation response. Store it now:
4477
- * OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
4478
- * or rotate it later. When `events` is omitted or
4529
+ * OAuth applications cannot call {@link WebhookResource.getEndpointSecret},
4530
+ * but they can rotate a lost secret. When `events` is omitted or
4479
4531
  * empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
4480
4532
  * `webhooks:write` scope.
4481
4533
  *
@@ -4491,19 +4543,22 @@ var WebhookResource = class extends BaseResource {
4491
4543
  * }
4492
4544
  * ```
4493
4545
  *
4494
- * @param payload - Endpoint details. `url` (absolute HTTP(S)) and `email`
4546
+ * @param payload - Endpoint details. `url` (absolute HTTPS) and `email`
4495
4547
  * are required; `events`, `name`, `is_active` and `signing_enabled` are
4496
4548
  * optional.
4497
4549
  * @param accountId - Override the client's default account ID.
4498
4550
  * @returns The created endpoint:
4499
4551
  * ```jsonc
4500
4552
  * {
4553
+ * "resource": "activity_event_subscription",
4501
4554
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4502
4555
  * "name": "ERP",
4503
4556
  * "url": "https://example.com/webhooks/assinafy",
4504
4557
  * "email": "ops@example.com",
4505
4558
  * "events": ["document_ready", "signer_signed_document"],
4506
4559
  * "is_active": true,
4560
+ * "is_held": false,
4561
+ * "held_since": null,
4507
4562
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4508
4563
  * "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
4509
4564
  * "created_at": "2026-10-01T12:00:00Z",
@@ -4547,12 +4602,15 @@ var WebhookResource = class extends BaseResource {
4547
4602
  * @returns The endpoint:
4548
4603
  * ```jsonc
4549
4604
  * {
4605
+ * "resource": "activity_event_subscription",
4550
4606
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4551
4607
  * "name": "ERP",
4552
4608
  * "url": "https://example.com/webhooks/assinafy",
4553
4609
  * "email": "ops@example.com",
4554
4610
  * "events": ["document_ready", "signer_signed_document"],
4555
4611
  * "is_active": true,
4612
+ * "is_held": false,
4613
+ * "held_since": null,
4556
4614
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4557
4615
  * "created_at": "2026-10-01T12:00:00Z",
4558
4616
  * "updated_at": "2026-10-01T12:00:00Z"
@@ -4574,12 +4632,13 @@ var WebhookResource = class extends BaseResource {
4574
4632
  /**
4575
4633
  * Change a webhook endpoint
4576
4634
  * (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
4577
- * fields sent are updated; `url` cannot be one another endpoint of the
4578
- * workspace already uses.
4635
+ * fields sent are updated; a changed `url` must be HTTPS, publicly
4636
+ * routable, and different from every other endpoint in the workspace.
4579
4637
  *
4580
4638
  * `signing_enabled: true` generates a secret if the endpoint has none and
4581
- * keeps the current one otherwise; `false` discards the secret. OAuth
4582
- * tokens need the `webhooks:write` scope.
4639
+ * keeps the current one otherwise; `false` discards the secret. When this
4640
+ * request turns signing on, the response includes the new `secret` once.
4641
+ * OAuth tokens need the `webhooks:write` scope.
4583
4642
  *
4584
4643
  * Request body (`application/json`, every field optional):
4585
4644
  * ```jsonc
@@ -4599,13 +4658,17 @@ var WebhookResource = class extends BaseResource {
4599
4658
  * @returns The updated endpoint:
4600
4659
  * ```jsonc
4601
4660
  * {
4661
+ * "resource": "activity_event_subscription",
4602
4662
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4603
4663
  * "name": "ERP",
4604
4664
  * "url": "https://example.com/webhooks/assinafy",
4605
4665
  * "email": "ops@example.com",
4606
4666
  * "events": ["document_ready", "signer_signed_document"],
4607
4667
  * "is_active": true,
4668
+ * "is_held": false,
4669
+ * "held_since": null,
4608
4670
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4671
+ * "secret": "whsec_c2VjcmV0", // only when this request turned signing on
4609
4672
  * "created_at": "2026-10-01T12:00:00Z",
4610
4673
  * "updated_at": "2026-10-01T12:00:00Z"
4611
4674
  * }
@@ -4669,7 +4732,7 @@ var WebhookResource = class extends BaseResource {
4669
4732
  * ```
4670
4733
  */
4671
4734
  async deleteEndpointByUrl(url, accountId) {
4672
- validateWebhookUrl(url);
4735
+ validateWebhookUrl(url, true);
4673
4736
  const path2 = this.endpointsPath(accountId);
4674
4737
  return this.callVoid(
4675
4738
  "Failed to delete webhook endpoint",
@@ -4709,7 +4772,7 @@ var WebhookResource = class extends BaseResource {
4709
4772
  * (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
4710
4773
  * The old secret stops working immediately: deliveries sent after the
4711
4774
  * rotation are signed only with the new secret, so update the receiver at
4712
- * once. Not available to OAuth applications; use an API key.
4775
+ * once. OAuth tokens need the `webhooks:write` scope.
4713
4776
  *
4714
4777
  * @param endpointId - The endpoint ID.
4715
4778
  * @param accountId - Override the client's default account ID.
@@ -4770,15 +4833,15 @@ function validateWebhookFields(payload, required) {
4770
4833
  throw new ValidationError("Webhook name must be a string");
4771
4834
  }
4772
4835
  }
4773
- function validateWebhookUrl(value) {
4836
+ function validateWebhookUrl(value, allowStoredHttp = false) {
4774
4837
  let url;
4775
4838
  try {
4776
4839
  url = new URL(value ?? "");
4777
4840
  } catch {
4778
- throw new ValidationError("Webhook URL must be an absolute HTTP(S) URL", { url: value });
4841
+ throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
4779
4842
  }
4780
- if (url.protocol !== "https:" && url.protocol !== "http:" || !url.hostname) {
4781
- throw new ValidationError("Webhook URL must be an absolute HTTP(S) URL", { url: value });
4843
+ if (url.protocol !== "https:" && !(allowStoredHttp && url.protocol === "http:") || !url.hostname) {
4844
+ throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
4782
4845
  }
4783
4846
  }
4784
4847
 
@@ -7939,7 +8002,7 @@ function assertDeclineReason(declineReason) {
7939
8002
  if (typeof declineReason !== "string" || !declineReason.trim()) {
7940
8003
  throw new ValidationError("declineReason is required");
7941
8004
  }
7942
- if (declineReason.length > 2e3) {
8005
+ if ([...declineReason].length > 2e3) {
7943
8006
  throw new ValidationError("declineReason must be at most 2000 characters");
7944
8007
  }
7945
8008
  }
@@ -9370,8 +9433,9 @@ var AssinafyClient = class _AssinafyClient {
9370
9433
  * the API; only `collect` assignments require pre-rendered pages.
9371
9434
  * @param options.waitOptions - Optional `maxWaitMs` / `pollIntervalMs`
9372
9435
  * forwarded to {@link DocumentResource.waitUntilReady}.
9373
- * @param options.expiresAt - Optional ISO-8601 assignment expiry, e.g.
9374
- * `'2026-08-01T00:00:00Z'`.
9436
+ * @param options.expiresAt - Optional ISO-8601 assignment expiry. A date
9437
+ * ends at 23:59 UTC; a date-time without an offset is interpreted as UTC;
9438
+ * an explicit offset is honored.
9375
9439
  * @param options.copyReceivers - Optional existing signer IDs (not email
9376
9440
  * addresses) that receive a copy. See the caveat on
9377
9441
  * {@link ICreateAssignmentPayload.copy_receivers}; some plans silently drop
@@ -9457,7 +9521,7 @@ var AssinafyClient = class _AssinafyClient {
9457
9521
  if (options.metadata !== void 0) {
9458
9522
  assertRecord(options.metadata, "metadata");
9459
9523
  }
9460
- if (options.expiresAt !== void 0) assertDateTime(options.expiresAt, "expiresAt");
9524
+ if (options.expiresAt !== void 0) assertExpirationDate(options.expiresAt, "expiresAt");
9461
9525
  if (options.copyReceivers !== void 0 && (!Array.isArray(options.copyReceivers) || options.copyReceivers.some(
9462
9526
  (id) => typeof id !== "string" || id.trim().length === 0
9463
9527
  ))) {
@@ -43,9 +43,8 @@ They map to `auth.getSocialLoginUrl()` and
43
43
  The SDK also includes the production contract additions for:
44
44
 
45
45
  - the `pades` document artifact;
46
- - `DigitalCertificate` verification on virtual assignment creation and cost
47
- estimation (template calls remain typed but are temporarily rejected because
48
- the server derives their method);
46
+ - `DigitalCertificate` verification on direct and template assignment creation
47
+ and cost estimation (templates with placed signer fields return `400`);
49
48
  - typed `display_settings` for collect fields;
50
49
  - signer `government_id` updates;
51
50
  - signature-image `reuse`;
@@ -379,11 +378,11 @@ estimation with `ValidationError.errors.code` set to
379
378
 
380
379
  Template role IDs do not reveal which entries are signers, editors or copy
381
380
  receivers. The SDK validates each entry's channel and positive `step`, then
382
- lets the API enforce role-aware signing order. The server also derives the
383
- assignment method from placed template fields but does not yet reject an
384
- unusable certificate/`collect` result. Until it does, the SDK refuses
385
- `DigitalCertificate` on both template-document creation and cost estimation
386
- with the same stable code; use a direct virtual assignment instead.
381
+ lets the API enforce role-aware signing order. The server derives the method:
382
+ a fieldless template supports `DigitalCertificate`, while placed signer fields
383
+ produce `collect` and return `400`. A template signer can identify an existing
384
+ signer by `id`, or use `email` to reuse or create one; `id` wins when both are
385
+ sent.
387
386
 
388
387
  ## Identity document and face verification
389
388
 
@@ -468,9 +467,10 @@ Document upload accepts a PDF of at most 25 MB and 2,000 pages. The multipart
468
467
  schema documents the file; the SDK's optional `metadata` JSON part is retained
469
468
  for deployments that accept application-owned opaque metadata.
470
469
 
471
- The reset-expiration schema requires the `expires_at` key itself: send an
472
- ISO-8601 date-time string, or `null` to remove the expiration. The SDK's
473
- `resetExpiration` always sends the key and accepts `null` for clearing.
470
+ Assignment expiration accepts an ISO-8601 date (ending at 23:59 UTC), a
471
+ date-time without an offset (UTC), or an offset-aware date-time. The
472
+ reset-expiration schema requires the `expires_at` key itself; send `null` to
473
+ remove the expiration. The SDK always sends that key.
474
474
 
475
475
  ## Resend-cost response variants
476
476
 
@@ -530,12 +530,13 @@ signer access or verification value; treat it as a credential and never log it.
530
530
  Assinafy sends webhook events as HTTP `POST` JSON requests with
531
531
  `Connection: close`, `webhook-id` and `webhook-timestamp` headers, and a
532
532
  `webhook-signature` header on signing-enabled endpoints. Every active endpoint
533
- subscribed to an event receives it independently. Any `2xx` is successful. There are at most two automatic
534
- attempts per event with a three-second wait. After ten consecutive failed
535
- events, ordinary delivery pauses and about 5% of later events are attempted
536
- until one succeeds. `webhooks.retryDispatch()` requests immediate redelivery.
537
- Only the first 2,000 characters of the receiver response body are retained in
538
- dispatch history.
533
+ subscribed to an event receives it independently. Any `2xx` is successful.
534
+ Connection failures, timeouts, `408`, `429`, and `5xx` receive up to six
535
+ attempts about ten minutes apart. After ten failed deliveries in a row, the
536
+ endpoint is held and probed after 3, 15, and 60 minutes, then every six hours.
537
+ Success replays missed events oldest first. `webhooks.retryDispatch()` sends
538
+ once immediately, even while held. The first 2,000 response characters and the
539
+ delivery entry are retained for seven days.
539
540
 
540
541
  The common body contains `id`, `event`, nullable `message`, nullable `payload`,
541
542
  nullable `origin`, Unix-second `created_at`, polymorphic `subject` and `object`,
@@ -551,10 +552,13 @@ oldest endpoint; the endpoint routes address each one by ID. Exact registered
551
552
  URLs can also filter `listEndpoints(accountId?, { url })` and identify the
552
553
  target of `deleteEndpointByUrl(url, accountId?)`.
553
554
 
554
- `createEndpoint()` returns `IWebhookEndpointCreateResponse` with `secret` when
555
- signing is enabled. Store that value securely at creation, including for OAuth
556
- applications: they cannot read or rotate the secret afterward. If an OAuth
557
- application loses it, delete and recreate its endpoint.
555
+ New or changed endpoint URLs must use HTTPS. Endpoint responses expose
556
+ `is_held` and `held_since`; dispatch entries expose `webhook_id`, `attempt`,
557
+ `kind`, and `will_retry`. `createEndpoint()` returns
558
+ `IWebhookEndpointCreateResponse` with `secret` when signing is enabled.
559
+ `updateEndpoint()` returns the same shape and includes `secret` when that
560
+ request turns signing on. Store the value securely. OAuth applications cannot
561
+ read it afterward, but can rotate it with `webhooks:write`.
558
562
 
559
563
  Signing-enabled endpoints follow Standard Webhooks:
560
564
  `webhook-signature` holds space-separated `v1,<base64>` entries, each an
@@ -562,14 +566,14 @@ HMAC-SHA256 of `{webhook-id}.{webhook-timestamp}.{raw body}` keyed with the
562
566
  base64-decoded part of the `whsec_` secret.
563
567
  `webhookVerifier.verifySignature()` implements this, with a 300-second
564
568
  timestamp tolerance by default; non-finite or negative windows fail closed.
565
- The signing-secret routes are not available to
566
- OAuth applications. The earlier `webhookVerifier.verify()` (hex HMAC over the
569
+ The secret-read route is not available to OAuth applications. The earlier
570
+ `webhookVerifier.verify()` (hex HMAC over the
567
571
  body alone) is deprecated; it never matched an Assinafy signature.
568
572
 
569
- Older sandbox deployments can omit `secret` from the creation response and
570
- return `404` for deletion by URL. API-key integrations can still use the secret
571
- read/rotation and deletion-by-ID routes. OAuth integrations need a deployment
572
- that returns the creation secret to configure signed endpoints.
573
+ Older sandbox deployments can omit `secret` from creation/update responses and
574
+ return `404` for deletion by URL. API-key integrations can still read/rotate
575
+ the secret and delete by ID. OAuth integrations can rotate a lost secret where
576
+ the production route is available.
573
577
 
574
578
  ## Authentication isolation
575
579
 
package/docs/RELEASING.md CHANGED
@@ -13,7 +13,7 @@ accept the package.
13
13
  | Bun 1.4.4 | Locked install, tests, build, contract checks, and packaging |
14
14
  | Node.js 22 | Minimum supported consumer runtime |
15
15
  | Node.js 24 LTS | Packaging and registry publishing runtime |
16
- | Node.js 26 Current | Forward-compatibility consumer test |
16
+ | Node.js 26 LTS | Forward-compatibility consumer test |
17
17
 
18
18
  Keep this table, `package.json`, GitLab CI, and the GitHub workflows synchronized
19
19
  when changing runtime support.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assinafy/sdk",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "packageManager": "bun@1.4.4",
5
5
  "description": "TypeScript SDK for Assinafy API - Digital signature platform",
6
6
  "type": "commonjs",
@@ -84,7 +84,8 @@
84
84
  "overrides": {
85
85
  "esbuild": "0.28.2",
86
86
  "follow-redirects": "1.16.2",
87
- "brace-expansion": "5.0.12"
87
+ "brace-expansion": "5.0.12",
88
+ "minimatch": "11.0.3"
88
89
  },
89
90
  "files": [
90
91
  "dist",