@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.js CHANGED
@@ -516,6 +516,17 @@ function assertDateTime(value, label) {
516
516
  throw new ValidationError(`${label} must be an ISO-8601 date-time`);
517
517
  }
518
518
  }
519
+ function assertExpirationDate(value, label) {
520
+ if (typeof value !== "string") {
521
+ throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
522
+ }
523
+ 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;
524
+ try {
525
+ assertDateTime(normalized, label);
526
+ } catch {
527
+ throw new ValidationError(`${label} must be an ISO-8601 date or date-time`);
528
+ }
529
+ }
519
530
  function cleanParams(params) {
520
531
  assertRecord(params, "params");
521
532
  const out = {};
@@ -690,7 +701,7 @@ var import_axios2 = __toESM(require("axios"));
690
701
  // package.json
691
702
  var package_default = {
692
703
  name: "@assinafy/sdk",
693
- version: "2.10.0",
704
+ version: "2.11.0",
694
705
  packageManager: "bun@1.4.4",
695
706
  description: "TypeScript SDK for Assinafy API - Digital signature platform",
696
707
  type: "commonjs",
@@ -774,7 +785,8 @@ var package_default = {
774
785
  overrides: {
775
786
  esbuild: "0.28.2",
776
787
  "follow-redirects": "1.16.2",
777
- "brace-expansion": "5.0.12"
788
+ "brace-expansion": "5.0.12",
789
+ minimatch: "11.0.3"
778
790
  },
779
791
  files: [
780
792
  "dist",
@@ -1128,7 +1140,7 @@ function buildAssignmentPayload(payload) {
1128
1140
  if (payload.message !== void 0 && typeof payload.message !== "string") {
1129
1141
  throw new ValidationError("message must be a string");
1130
1142
  }
1131
- if (payload.expires_at !== void 0) assertDateTime(payload.expires_at, "expires_at");
1143
+ if (payload.expires_at !== void 0) assertExpirationDate(payload.expires_at, "expires_at");
1132
1144
  if (payload.copy_receivers !== void 0 && (!Array.isArray(payload.copy_receivers) || payload.copy_receivers.some(
1133
1145
  (id) => typeof id !== "string" || !id.trim()
1134
1146
  ))) {
@@ -1300,7 +1312,7 @@ var AssignmentResource = class extends BaseResource {
1300
1312
  * without it. Note the camelCase spelling: `account_id` and an
1301
1313
  * `X-Account-Id` header are both rejected.
1302
1314
  *
1303
- * @param params - `page`, `per-page`.
1315
+ * @param params - `page`, `per-page`, and `sort`.
1304
1316
  * @param accountId - Override the client's default account ID.
1305
1317
  * @returns Assignments, with pagination in `meta`. Each item is a full
1306
1318
  * {@link IAssignment} (same shape as {@link AssignmentResource.create}
@@ -1433,6 +1445,8 @@ var AssignmentResource = class extends BaseResource {
1433
1445
  * @param payload - Signers plus optional `method` (defaults to `virtual`),
1434
1446
  * `message`, `expires_at`, `copy_receivers` (existing signer IDs, not
1435
1447
  * addresses), and `collect`-mode `entries` with page-image geometry.
1448
+ * `expires_at` accepts a date (ending at 23:59 UTC), a date-time without
1449
+ * an offset (UTC), or an offset-aware date-time.
1436
1450
  * @returns The created {@link IAssignment}: `signers` (rich, with `step` /
1437
1451
  * `notified` / `verification_method`), `items` (one row per signer × field),
1438
1452
  * a `summary` count block, and per-signer `signing_urls`. Response shape:
@@ -1620,9 +1634,10 @@ var AssignmentResource = class extends BaseResource {
1620
1634
  * (`PUT /documents/{documentId}/assignments/{assignmentId}/reset-expiration`).
1621
1635
  *
1622
1636
  * Sends `{ expires_at }` verbatim; the key itself is required by the
1623
- * contract. Use an ISO-8601 date/time string, or `null` to remove the
1624
- * expiration — `null` is the documented clear mechanism and, unlike
1625
- * ordinary nullable inputs, is intentionally not stripped from the body.
1637
+ * contract. Use an ISO-8601 date, a date-time with or without an offset,
1638
+ * or `null` to remove the expiration. Date-only values end at 23:59 UTC;
1639
+ * date-times without offsets are UTC. `null` is intentionally not stripped
1640
+ * from the body.
1626
1641
  *
1627
1642
  * Request body (`application/json`):
1628
1643
  * ```jsonc
@@ -1633,8 +1648,8 @@ var AssignmentResource = class extends BaseResource {
1633
1648
  *
1634
1649
  * @param documentId - The document the assignment belongs to.
1635
1650
  * @param assignmentId - The assignment to update.
1636
- * @param expiresAt - New expiry as an ISO-8601 date/time string, or `null`
1637
- * to remove the expiration.
1651
+ * @param expiresAt - New expiry as an ISO-8601 date or date-time string,
1652
+ * or `null` to remove the expiration.
1638
1653
  * @returns The updated {@link IAssignment} — the same full shape
1639
1654
  * {@link AssignmentResource.create} returns (`signers`, `items`, `summary`,
1640
1655
  * `signing_urls`), with `expires_at` reflecting the new value:
@@ -1678,7 +1693,7 @@ var AssignmentResource = class extends BaseResource {
1678
1693
  async resetExpiration(documentId, assignmentId, expiresAt) {
1679
1694
  const docId = this.requireId(documentId, "Document ID");
1680
1695
  const asgId = this.requireId(assignmentId, "Assignment ID");
1681
- if (expiresAt !== null) assertDateTime(expiresAt, "expiresAt");
1696
+ if (expiresAt !== null) assertExpirationDate(expiresAt, "expiresAt");
1682
1697
  return this.call(
1683
1698
  "Failed to update assignment expiration",
1684
1699
  () => this.http.put(
@@ -2138,7 +2153,7 @@ var DocumentResource = class extends BaseResource {
2138
2153
  * a compact representation with no expanded `assignment` or `pages`, so
2139
2154
  * prefer it for name lookups and pickers.
2140
2155
  *
2141
- * @param params - `search`, `status`, `page`, `per-page`.
2156
+ * @param params - `search`, `status`, `page`, `per-page`, and `sort`.
2142
2157
  * @param accountId - Override the client's default account ID.
2143
2158
  * @returns Matching documents, with pagination in `meta`. Each item:
2144
2159
  * ```jsonc
@@ -2800,9 +2815,11 @@ var DocumentResource = class extends BaseResource {
2800
2815
  *
2801
2816
  * Instantiates the template, binding each role to a signer, and returns the
2802
2817
  * new document. The request body is `{ signers, ...options }` — `signers`
2803
- * maps every template `role_id` to an existing account signer `id`, and
2804
- * `options` may add `name`, `message`, `expires_at`, `editor_fields`, and
2805
- * tag names in `tags` (unknown names are created automatically).
2818
+ * maps every template `role_id` to an existing signer `id` or an `email`.
2819
+ * An email reuses the matching account signer or creates one with `name`;
2820
+ * `id` wins when both are present. Options may add `name`, `message`,
2821
+ * `expires_at`, `editor_fields`, and tag names in `tags` (unknown names are
2822
+ * created automatically).
2806
2823
  *
2807
2824
  * Request body (`application/json`):
2808
2825
  * ```jsonc
@@ -2810,7 +2827,9 @@ var DocumentResource = class extends BaseResource {
2810
2827
  * "signers": [
2811
2828
  * {
2812
2829
  * "role_id": "signing_role_example",
2813
- * "id": "signer_example",
2830
+ * "email": "signer@example.com",
2831
+ * "name": "Example Signer",
2832
+ * "whatsapp_phone_number": "+15555550100",
2814
2833
  * "verification_method": "Email",
2815
2834
  * "notification_methods": [
2816
2835
  * "Email"
@@ -2834,27 +2853,33 @@ var DocumentResource = class extends BaseResource {
2834
2853
  * ```
2835
2854
  *
2836
2855
  * @param templateId - The template to instantiate.
2837
- * @param signers - Role-to-signer bindings (each with `role_id` and `id`,
2838
- * plus optional `verification_method`, `notification_methods`, `step`).
2856
+ * @param signers - Role-to-signer bindings (each with `role_id` and either
2857
+ * an existing `id` or an `email`; email creation also accepts `name` and
2858
+ * `whatsapp_phone_number`). `verification_method`, `notification_methods`,
2859
+ * and `step` are optional.
2839
2860
  * Only one notification method is allowed per signer; when only one of the
2840
2861
  * verification/notification fields is supplied, the API infers the other.
2841
2862
  * `DigitalCertificate` costs 0.5 credits, requires the feature plus a
2842
2863
  * signer `government_id`, and that signer must be alone in its step. The
2843
- * server derives the assignment method from placed template fields but
2844
- * does not yet reject unusable certificate/`collect` combinations, so the
2845
- * SDK temporarily refuses certificate signers on this template route.
2864
+ * server derives the assignment method from placed template fields and
2865
+ * rejects certificate signers when those fields produce a `collect`
2866
+ * assignment. Use a template without placed signer fields for certificate
2867
+ * signing.
2846
2868
  * `IdDocumentFaceMatchBasic` needs the ID Document + Face Match feature
2847
2869
  * and a valid CPF in `government_id`; estimate the per-signer fee first.
2848
2870
  * @param options - Optional `name`, `message`, `expires_at`,
2849
2871
  * `editor_fields`, `tags`.
2850
2872
  * @param options.name - Generated document display name.
2851
2873
  * @param options.message - Signing invitation message.
2852
- * @param options.expires_at - ISO-8601 signature deadline.
2874
+ * @param options.expires_at - ISO-8601 deadline: date-only (ends at 23:59
2875
+ * UTC), date-time without an offset (treated as UTC), or an offset-aware
2876
+ * date-time.
2853
2877
  * @param options.editor_fields - Template editor values as `{ field_id, value }` entries.
2854
2878
  * @param options.tags - Tag names attached to the generated document.
2855
2879
  * @param accountId - Override the client's default account ID.
2856
- * @returns The created document (an {@link IDocumentDetailsResponse} with
2857
- * `template_id` set and its `assignment` populated):
2880
+ * @returns The uploaded document. Assignment creation continues in the
2881
+ * background; follow `GET /documents/{documentId}` or webhooks until the
2882
+ * document becomes `pending_signature` or `failed`:
2858
2883
  * ```jsonc
2859
2884
  * {
2860
2885
  * "resource": "document",
@@ -2862,22 +2887,21 @@ var DocumentResource = class extends BaseResource {
2862
2887
  * "account_id": "acc_example",
2863
2888
  * "template_id": "103a0991a5cde83518e5672aa9aa",
2864
2889
  * "name": "Service agreement from template",
2865
- * "status": "pending_signature",
2866
- * "artifacts": { "original": "https://…/download/original", "thumbnail": "https://…/thumbnail" },
2890
+ * "status": "uploaded",
2891
+ * "artifacts": { "original": "https://…/download/original" },
2867
2892
  * "is_closed": false,
2868
2893
  * "signing_url": "https://app.assinafy.com.br/sign/19f675b7…",
2869
2894
  * "tags": [{ "id": "103a0992…", "name": "agreements", "color": null }],
2870
- * "assignment": { "id": "103a09a1…", "method": "virtual", "summary": { "signer_count": 1, "completed_count": 0 } },
2871
- * "pages": [{ "id": "103a0992…", "number": 1, "height": 1651, "width": 1275, "download_url": "https://…/download" }],
2895
+ * "assignment": null,
2896
+ * "pages": [],
2872
2897
  * "created_at": "2026-07-15T19:57:55Z",
2873
2898
  * "updated_at": "2026-07-15T19:59:33Z"
2874
2899
  * }
2875
2900
  * ```
2876
- * @throws {ValidationError} If `templateId` is missing, no account ID is
2877
- * available, or a signer uses `DigitalCertificate`. Certificate refusals
2878
- * have `errors.code === 'digital_certificate_requires_virtual_method'`.
2879
- * @throws {ApiError} `400` if the signers/roles are invalid or the template
2880
- * is not ready.
2901
+ * @throws {ValidationError} If `templateId`, an account ID, signer identity,
2902
+ * channel, order, deadline, editor field, or tag is invalid.
2903
+ * @throws {ApiError} `400` if the signers/roles are invalid, the template
2904
+ * is not ready, or placed signer fields conflict with `DigitalCertificate`.
2881
2905
  *
2882
2906
  * @example
2883
2907
  * ```ts
@@ -2894,7 +2918,7 @@ var DocumentResource = class extends BaseResource {
2894
2918
  if (options.message !== void 0 && typeof options.message !== "string") {
2895
2919
  throw new ValidationError("message must be a string");
2896
2920
  }
2897
- if (options.expires_at !== void 0) assertDateTime(options.expires_at, "expires_at");
2921
+ if (options.expires_at !== void 0) assertExpirationDate(options.expires_at, "expires_at");
2898
2922
  const editorFields = options.editor_fields === void 0 ? void 0 : normaliseTemplateEditorFields(options.editor_fields);
2899
2923
  if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag.trim()))) {
2900
2924
  throw new ValidationError("tags must be an array of non-empty tag names");
@@ -2924,10 +2948,8 @@ var DocumentResource = class extends BaseResource {
2924
2948
  *
2925
2949
  * A dry run: sends only `{ signers }` and consumes nothing. Use it to check
2926
2950
  * balances before calling {@link DocumentResource.createFromTemplate}.
2927
- * `DigitalCertificate` requires a provably `virtual` assignment. Because
2928
- * this route leaves method detection to the server, the SDK temporarily
2929
- * refuses certificate signers instead of returning a price for an
2930
- * assignment that may charge credits but cannot be completed.
2951
+ * `DigitalCertificate` adds 0.5 credits per signer plus notification cost;
2952
+ * the API returns `400` when the template has placed signer fields.
2931
2953
  *
2932
2954
  * Request body (`application/json`):
2933
2955
  * ```jsonc
@@ -2969,10 +2991,10 @@ var DocumentResource = class extends BaseResource {
2969
2991
  * "message": null
2970
2992
  * }
2971
2993
  * ```
2972
- * @throws {ValidationError} If `templateId` is missing, no account ID is
2973
- * available, or a signer uses `DigitalCertificate`. Certificate refusals
2974
- * have `errors.code === 'digital_certificate_requires_virtual_method'`.
2975
- * @throws {ApiError} If the API rejects the request.
2994
+ * @throws {ValidationError} If `templateId`, an account ID, role, or
2995
+ * channel is invalid.
2996
+ * @throws {ApiError} `400` if the role is invalid or placed signer fields
2997
+ * conflict with `DigitalCertificate`; `403` when a feature is unavailable.
2976
2998
  *
2977
2999
  * @example
2978
3000
  * ```ts
@@ -3252,11 +3274,33 @@ function normaliseTemplateSigners(signers) {
3252
3274
  if (typeof signer.role_id !== "string" || !signer.role_id.trim()) {
3253
3275
  throw new ValidationError(`Template signer ${index + 1} requires role_id`);
3254
3276
  }
3255
- if (typeof signer.id !== "string" || !signer.id.trim()) {
3256
- throw new ValidationError(`Template signer ${index + 1} requires id`);
3257
- }
3258
3277
  validateAssignmentSignerOptions(signer, `Template signer ${index + 1}`);
3259
- const projected = { role_id: signer.role_id, id: signer.id };
3278
+ const projected = { role_id: signer.role_id };
3279
+ if (signer.id !== void 0) {
3280
+ if (typeof signer.id !== "string" || !signer.id.trim()) {
3281
+ throw new ValidationError(`Template signer ${index + 1} id must be non-empty`);
3282
+ }
3283
+ projected.id = signer.id;
3284
+ } else {
3285
+ if (!isEmail(signer.email)) {
3286
+ throw new ValidationError(`Template signer ${index + 1} requires a valid id or email`);
3287
+ }
3288
+ projected.email = signer.email;
3289
+ if (signer.name !== void 0) {
3290
+ if (typeof signer.name !== "string" || !signer.name.trim()) {
3291
+ throw new ValidationError(`Template signer ${index + 1} name must be non-empty`);
3292
+ }
3293
+ projected.name = signer.name;
3294
+ }
3295
+ if (signer.whatsapp_phone_number !== void 0) {
3296
+ if (!isE164PhoneNumber(signer.whatsapp_phone_number)) {
3297
+ throw new ValidationError(
3298
+ `Template signer ${index + 1} whatsapp_phone_number must be E.164`
3299
+ );
3300
+ }
3301
+ projected.whatsapp_phone_number = signer.whatsapp_phone_number;
3302
+ }
3303
+ }
3260
3304
  if (signer.verification_method !== void 0) {
3261
3305
  projected.verification_method = signer.verification_method;
3262
3306
  }
@@ -3266,7 +3310,6 @@ function normaliseTemplateSigners(signers) {
3266
3310
  if (signer.step !== void 0) projected.step = signer.step;
3267
3311
  return projected;
3268
3312
  });
3269
- validateDigitalCertificateMethod(void 0, normalised);
3270
3313
  return normalised;
3271
3314
  }
3272
3315
  function normaliseTemplateEditorFields(fields) {
@@ -3307,7 +3350,6 @@ function normaliseTemplateCostSigners(signers) {
3307
3350
  }
3308
3351
  return descriptor;
3309
3352
  });
3310
- validateDigitalCertificateMethod(void 0, normalised);
3311
3353
  return normalised;
3312
3354
  }
3313
3355
  function validateWaitOption(value, name) {
@@ -4208,6 +4250,8 @@ var WebhookResource = class extends BaseResource {
4208
4250
  * "document_processing_failed"
4209
4251
  * ],
4210
4252
  * "is_active": true,
4253
+ * "is_held": false,
4254
+ * "held_since": null,
4211
4255
  * "updated_at": "2026-07-18T02:36:02Z" // no `id` / `created_at` are returned
4212
4256
  * }
4213
4257
  * ```
@@ -4377,11 +4421,12 @@ var WebhookResource = class extends BaseResource {
4377
4421
  * (`GET /accounts/{accountId}/webhooks`). Pagination info (if any) is
4378
4422
  * attached in `meta`.
4379
4423
  *
4380
- * Assinafy treats any `2xx` response as success. It makes at most two
4381
- * attempts per event with a three-second wait. After ten consecutive failed
4382
- * events, the circuit breaker pauses normal delivery and sends roughly 5%
4383
- * as recovery checks until one succeeds. The stored `response_body` is
4384
- * truncated to 2,000 characters.
4424
+ * Assinafy treats any `2xx` response as success. Retriable failures get up
4425
+ * to six attempts about ten minutes apart. After ten failed deliveries in
4426
+ * a row, the endpoint is paused and probed after 3, 15 and 60 minutes, then
4427
+ * every six hours. A successful delivery or probe resumes the endpoint and
4428
+ * replays missed events oldest first. Response bodies are truncated to
4429
+ * 2,000 characters and delivery entries are retained for seven days.
4385
4430
  *
4386
4431
  * @param params - Optional filters and pagination:
4387
4432
  * - `endpoint_id` — only deliveries to this webhook endpoint.
@@ -4408,6 +4453,10 @@ var WebhookResource = class extends BaseResource {
4408
4453
  * // subject: <User>, account_id, created_at }
4409
4454
  * },
4410
4455
  * "delivered": true,
4456
+ * "webhook_id": "9f86d081884c7d659a2feaa0c55ad015",
4457
+ * "attempt": 1,
4458
+ * "kind": "scheduled",
4459
+ * "will_retry": false,
4411
4460
  * "http_status": 200,
4412
4461
  * "response_body": "{ ... }", // receiving endpoint body, max 2,000 chars
4413
4462
  * "error": null,
@@ -4500,11 +4549,14 @@ var WebhookResource = class extends BaseResource {
4500
4549
  * [
4501
4550
  * {
4502
4551
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4552
+ * "resource": "activity_event_subscription",
4503
4553
  * "name": "ERP",
4504
4554
  * "url": "https://example.com/webhooks/assinafy",
4505
4555
  * "email": "ops@example.com",
4506
4556
  * "events": ["document_ready", "signer_signed_document"],
4507
4557
  * "is_active": true,
4558
+ * "is_held": false,
4559
+ * "held_since": null,
4508
4560
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4509
4561
  * "created_at": "2026-10-01T12:00:00Z",
4510
4562
  * "updated_at": "2026-10-01T12:00:00Z"
@@ -4522,7 +4574,7 @@ var WebhookResource = class extends BaseResource {
4522
4574
  */
4523
4575
  async listEndpoints(accountId, params = {}) {
4524
4576
  assertRecord(params, "webhook endpoint filters");
4525
- if (params.url !== void 0) validateWebhookUrl(params.url);
4577
+ if (params.url !== void 0) validateWebhookUrl(params.url, true);
4526
4578
  const path2 = this.endpointsPath(accountId);
4527
4579
  return this.call(
4528
4580
  "Failed to list webhook endpoints",
@@ -4536,8 +4588,8 @@ var WebhookResource = class extends BaseResource {
4536
4588
  * An account can have 1 endpoint, or up to 3 on paid plans. Each endpoint
4537
4589
  * of a workspace needs a different `url`. With `signing_enabled: true` the
4538
4590
  * API returns a signing `secret` in this creation response. Store it now:
4539
- * OAuth applications cannot call {@link WebhookResource.getEndpointSecret}
4540
- * or rotate it later. When `events` is omitted or
4591
+ * OAuth applications cannot call {@link WebhookResource.getEndpointSecret},
4592
+ * but they can rotate a lost secret. When `events` is omitted or
4541
4593
  * empty, {@link DEFAULT_WEBHOOK_EVENTS} is sent. OAuth tokens need the
4542
4594
  * `webhooks:write` scope.
4543
4595
  *
@@ -4553,19 +4605,22 @@ var WebhookResource = class extends BaseResource {
4553
4605
  * }
4554
4606
  * ```
4555
4607
  *
4556
- * @param payload - Endpoint details. `url` (absolute HTTP(S)) and `email`
4608
+ * @param payload - Endpoint details. `url` (absolute HTTPS) and `email`
4557
4609
  * are required; `events`, `name`, `is_active` and `signing_enabled` are
4558
4610
  * optional.
4559
4611
  * @param accountId - Override the client's default account ID.
4560
4612
  * @returns The created endpoint:
4561
4613
  * ```jsonc
4562
4614
  * {
4615
+ * "resource": "activity_event_subscription",
4563
4616
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4564
4617
  * "name": "ERP",
4565
4618
  * "url": "https://example.com/webhooks/assinafy",
4566
4619
  * "email": "ops@example.com",
4567
4620
  * "events": ["document_ready", "signer_signed_document"],
4568
4621
  * "is_active": true,
4622
+ * "is_held": false,
4623
+ * "held_since": null,
4569
4624
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4570
4625
  * "secret": "whsec_c2VjcmV0", // only in this response when signing is enabled
4571
4626
  * "created_at": "2026-10-01T12:00:00Z",
@@ -4609,12 +4664,15 @@ var WebhookResource = class extends BaseResource {
4609
4664
  * @returns The endpoint:
4610
4665
  * ```jsonc
4611
4666
  * {
4667
+ * "resource": "activity_event_subscription",
4612
4668
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4613
4669
  * "name": "ERP",
4614
4670
  * "url": "https://example.com/webhooks/assinafy",
4615
4671
  * "email": "ops@example.com",
4616
4672
  * "events": ["document_ready", "signer_signed_document"],
4617
4673
  * "is_active": true,
4674
+ * "is_held": false,
4675
+ * "held_since": null,
4618
4676
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4619
4677
  * "created_at": "2026-10-01T12:00:00Z",
4620
4678
  * "updated_at": "2026-10-01T12:00:00Z"
@@ -4636,12 +4694,13 @@ var WebhookResource = class extends BaseResource {
4636
4694
  /**
4637
4695
  * Change a webhook endpoint
4638
4696
  * (`PUT /accounts/{accountId}/webhooks/endpoints/{endpointId}`). Only the
4639
- * fields sent are updated; `url` cannot be one another endpoint of the
4640
- * workspace already uses.
4697
+ * fields sent are updated; a changed `url` must be HTTPS, publicly
4698
+ * routable, and different from every other endpoint in the workspace.
4641
4699
  *
4642
4700
  * `signing_enabled: true` generates a secret if the endpoint has none and
4643
- * keeps the current one otherwise; `false` discards the secret. OAuth
4644
- * tokens need the `webhooks:write` scope.
4701
+ * keeps the current one otherwise; `false` discards the secret. When this
4702
+ * request turns signing on, the response includes the new `secret` once.
4703
+ * OAuth tokens need the `webhooks:write` scope.
4645
4704
  *
4646
4705
  * Request body (`application/json`, every field optional):
4647
4706
  * ```jsonc
@@ -4661,13 +4720,17 @@ var WebhookResource = class extends BaseResource {
4661
4720
  * @returns The updated endpoint:
4662
4721
  * ```jsonc
4663
4722
  * {
4723
+ * "resource": "activity_event_subscription",
4664
4724
  * "id": "65f1c2a9b3e4d5f60718293a4b5c6d7e",
4665
4725
  * "name": "ERP",
4666
4726
  * "url": "https://example.com/webhooks/assinafy",
4667
4727
  * "email": "ops@example.com",
4668
4728
  * "events": ["document_ready", "signer_signed_document"],
4669
4729
  * "is_active": true,
4730
+ * "is_held": false,
4731
+ * "held_since": null,
4670
4732
  * "signing_enabled": true, // deliveries carry a `webhook-signature` header
4733
+ * "secret": "whsec_c2VjcmV0", // only when this request turned signing on
4671
4734
  * "created_at": "2026-10-01T12:00:00Z",
4672
4735
  * "updated_at": "2026-10-01T12:00:00Z"
4673
4736
  * }
@@ -4731,7 +4794,7 @@ var WebhookResource = class extends BaseResource {
4731
4794
  * ```
4732
4795
  */
4733
4796
  async deleteEndpointByUrl(url, accountId) {
4734
- validateWebhookUrl(url);
4797
+ validateWebhookUrl(url, true);
4735
4798
  const path2 = this.endpointsPath(accountId);
4736
4799
  return this.callVoid(
4737
4800
  "Failed to delete webhook endpoint",
@@ -4771,7 +4834,7 @@ var WebhookResource = class extends BaseResource {
4771
4834
  * (`POST /accounts/{accountId}/webhooks/endpoints/{endpointId}/secret/rotate`).
4772
4835
  * The old secret stops working immediately: deliveries sent after the
4773
4836
  * rotation are signed only with the new secret, so update the receiver at
4774
- * once. Not available to OAuth applications; use an API key.
4837
+ * once. OAuth tokens need the `webhooks:write` scope.
4775
4838
  *
4776
4839
  * @param endpointId - The endpoint ID.
4777
4840
  * @param accountId - Override the client's default account ID.
@@ -4832,15 +4895,15 @@ function validateWebhookFields(payload, required) {
4832
4895
  throw new ValidationError("Webhook name must be a string");
4833
4896
  }
4834
4897
  }
4835
- function validateWebhookUrl(value) {
4898
+ function validateWebhookUrl(value, allowStoredHttp = false) {
4836
4899
  let url;
4837
4900
  try {
4838
4901
  url = new URL(value ?? "");
4839
4902
  } catch {
4840
- throw new ValidationError("Webhook URL must be an absolute HTTP(S) URL", { url: value });
4903
+ throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
4841
4904
  }
4842
- if (url.protocol !== "https:" && url.protocol !== "http:" || !url.hostname) {
4843
- throw new ValidationError("Webhook URL must be an absolute HTTP(S) URL", { url: value });
4905
+ if (url.protocol !== "https:" && !(allowStoredHttp && url.protocol === "http:") || !url.hostname) {
4906
+ throw new ValidationError("Webhook URL must be an absolute HTTPS URL", { url: value });
4844
4907
  }
4845
4908
  }
4846
4909
 
@@ -8001,7 +8064,7 @@ function assertDeclineReason(declineReason) {
8001
8064
  if (typeof declineReason !== "string" || !declineReason.trim()) {
8002
8065
  throw new ValidationError("declineReason is required");
8003
8066
  }
8004
- if (declineReason.length > 2e3) {
8067
+ if ([...declineReason].length > 2e3) {
8005
8068
  throw new ValidationError("declineReason must be at most 2000 characters");
8006
8069
  }
8007
8070
  }
@@ -9432,8 +9495,9 @@ var AssinafyClient = class _AssinafyClient {
9432
9495
  * the API; only `collect` assignments require pre-rendered pages.
9433
9496
  * @param options.waitOptions - Optional `maxWaitMs` / `pollIntervalMs`
9434
9497
  * forwarded to {@link DocumentResource.waitUntilReady}.
9435
- * @param options.expiresAt - Optional ISO-8601 assignment expiry, e.g.
9436
- * `'2026-08-01T00:00:00Z'`.
9498
+ * @param options.expiresAt - Optional ISO-8601 assignment expiry. A date
9499
+ * ends at 23:59 UTC; a date-time without an offset is interpreted as UTC;
9500
+ * an explicit offset is honored.
9437
9501
  * @param options.copyReceivers - Optional existing signer IDs (not email
9438
9502
  * addresses) that receive a copy. See the caveat on
9439
9503
  * {@link ICreateAssignmentPayload.copy_receivers}; some plans silently drop
@@ -9519,7 +9583,7 @@ var AssinafyClient = class _AssinafyClient {
9519
9583
  if (options.metadata !== void 0) {
9520
9584
  assertRecord(options.metadata, "metadata");
9521
9585
  }
9522
- if (options.expiresAt !== void 0) assertDateTime(options.expiresAt, "expiresAt");
9586
+ if (options.expiresAt !== void 0) assertExpirationDate(options.expiresAt, "expiresAt");
9523
9587
  if (options.copyReceivers !== void 0 && (!Array.isArray(options.copyReceivers) || options.copyReceivers.some(
9524
9588
  (id) => typeof id !== "string" || id.trim().length === 0
9525
9589
  ))) {