@assinafy/cli 2.7.1 → 2.9.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.
Files changed (61) hide show
  1. package/.env.example +2 -0
  2. package/README.en.md +75 -67
  3. package/README.md +39 -25
  4. package/THIRD_PARTY_NOTICES.md +8 -8
  5. package/dist/api.cjs +701 -93
  6. package/dist/api.cjs.map +1 -1
  7. package/dist/api.js +696 -93
  8. package/dist/api.js.map +1 -1
  9. package/dist/cli.cjs +2390 -694
  10. package/dist/types/api/client.d.ts +7 -0
  11. package/dist/types/api/client.d.ts.map +1 -1
  12. package/dist/types/api/envelope-types.d.ts +73 -0
  13. package/dist/types/api/envelope-types.d.ts.map +1 -0
  14. package/dist/types/api/index.d.ts +4 -0
  15. package/dist/types/api/index.d.ts.map +1 -1
  16. package/dist/types/api/resources/assignments.d.ts +7 -1
  17. package/dist/types/api/resources/assignments.d.ts.map +1 -1
  18. package/dist/types/api/resources/contracts.d.ts +3 -1
  19. package/dist/types/api/resources/contracts.d.ts.map +1 -1
  20. package/dist/types/api/resources/documents.d.ts +25 -6
  21. package/dist/types/api/resources/documents.d.ts.map +1 -1
  22. package/dist/types/api/resources/embed.d.ts +14 -0
  23. package/dist/types/api/resources/embed.d.ts.map +1 -0
  24. package/dist/types/api/resources/envelopes.d.ts +37 -0
  25. package/dist/types/api/resources/envelopes.d.ts.map +1 -0
  26. package/dist/types/api/resources/scheduled-sends.d.ts +11 -0
  27. package/dist/types/api/resources/scheduled-sends.d.ts.map +1 -0
  28. package/dist/types/api/resources/signer-documents.d.ts +23 -11
  29. package/dist/types/api/resources/signer-documents.d.ts.map +1 -1
  30. package/dist/types/api/resources/signers.d.ts +1 -1
  31. package/dist/types/api/resources/signers.d.ts.map +1 -1
  32. package/dist/types/api/resources/users.d.ts +3 -1
  33. package/dist/types/api/resources/users.d.ts.map +1 -1
  34. package/dist/types/api/resources/webhooks.d.ts +6 -2
  35. package/dist/types/api/resources/webhooks.d.ts.map +1 -1
  36. package/dist/types/api/resources/workspaces.d.ts +9 -2
  37. package/dist/types/api/resources/workspaces.d.ts.map +1 -1
  38. package/dist/types/api/types.d.ts +138 -8
  39. package/dist/types/api/types.d.ts.map +1 -1
  40. package/dist/types/api/utils.d.ts +9 -0
  41. package/dist/types/api/utils.d.ts.map +1 -1
  42. package/docs/README.md +5 -1
  43. package/docs/api-operations-staging.json +1262 -0
  44. package/docs/api-operations.json +234 -2
  45. package/docs/api-reference-staging.md +18466 -0
  46. package/docs/api-reference.md +11562 -3718
  47. package/docs/assignments.md +62 -14
  48. package/docs/contracts.md +4 -3
  49. package/docs/documents.md +75 -27
  50. package/docs/embed.md +119 -0
  51. package/docs/envelopes.md +239 -0
  52. package/docs/scheduled-sends.md +63 -0
  53. package/docs/sdk-reference.md +278 -30
  54. package/docs/send.md +15 -11
  55. package/docs/signer.md +84 -3
  56. package/docs/users.md +41 -0
  57. package/docs/webhooks.md +22 -6
  58. package/docs/workspaces.md +66 -3
  59. package/install.ps1 +1 -1
  60. package/install.sh +1 -1
  61. package/package.json +4 -4
package/dist/cli.cjs CHANGED
@@ -47,13 +47,13 @@ var require_picocolors = __commonJS({
47
47
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
48
48
  };
49
49
  var replaceClose = (string, close, replace, index) => {
50
- let result = "", cursor3 = 0;
50
+ let result = "", cursor2 = 0;
51
51
  do {
52
- result += string.substring(cursor3, index) + replace;
53
- cursor3 = index + close.length;
54
- index = string.indexOf(close, cursor3);
52
+ result += string.substring(cursor2, index) + replace;
53
+ cursor2 = index + close.length;
54
+ index = string.indexOf(close, cursor2);
55
55
  } while (~index);
56
- return result + string.substring(cursor3);
56
+ return result + string.substring(cursor2);
57
57
  };
58
58
  var createColors = (enabled = isColorSupported) => {
59
59
  let f = enabled ? formatter : () => String;
@@ -10802,8 +10802,8 @@ var require_browser = __commonJS({
10802
10802
  if (!this.useColors) {
10803
10803
  return;
10804
10804
  }
10805
- const c = "color: " + this.color;
10806
- args.splice(1, 0, c, "color: inherit");
10805
+ const c2 = "color: " + this.color;
10806
+ args.splice(1, 0, c2, "color: inherit");
10807
10807
  let index = 0;
10808
10808
  let lastC = 0;
10809
10809
  args[0].replace(/%[a-zA-Z%]/g, (match) => {
@@ -10815,7 +10815,7 @@ var require_browser = __commonJS({
10815
10815
  lastC = index;
10816
10816
  }
10817
10817
  });
10818
- args.splice(lastC, 0, c);
10818
+ args.splice(lastC, 0, c2);
10819
10819
  }
10820
10820
  exports2.log = console.debug || console.log || (() => {
10821
10821
  });
@@ -10985,8 +10985,8 @@ var require_node = __commonJS({
10985
10985
  function formatArgs(args) {
10986
10986
  const { namespace: name, useColors: useColors2 } = this;
10987
10987
  if (useColors2) {
10988
- const c = this.color;
10989
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
10988
+ const c2 = this.color;
10989
+ const colorCode = "\x1B[3" + (c2 < 8 ? c2 : "8;5;" + c2);
10990
10990
  const prefix = ` ${colorCode};1m${name} \x1B[0m`;
10991
10991
  args[0] = prefix + args[0].split("\n").join("\n" + prefix);
10992
10992
  args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
@@ -11085,7 +11085,7 @@ var require_src2 = __commonJS({
11085
11085
  const { stack } = new Error();
11086
11086
  if (typeof stack !== "string")
11087
11087
  return false;
11088
- return stack.split("\n").some((l2) => l2.indexOf("(https.js:") !== -1 || l2.indexOf("node:https:") !== -1);
11088
+ return stack.split("\n").some((l) => l.indexOf("(https.js:") !== -1 || l.indexOf("node:https:") !== -1);
11089
11089
  }
11090
11090
  function createAgent(callback, opts) {
11091
11091
  return new createAgent.Agent(callback, opts);
@@ -12031,62 +12031,6 @@ var require_follow_redirects = __commonJS({
12031
12031
  }
12032
12032
  });
12033
12033
 
12034
- // node_modules/sisteransi/src/index.js
12035
- var require_src3 = __commonJS({
12036
- "node_modules/sisteransi/src/index.js"(exports2, module2) {
12037
- "use strict";
12038
- var ESC2 = "\x1B";
12039
- var CSI2 = `${ESC2}[`;
12040
- var beep = "\x07";
12041
- var cursor3 = {
12042
- to(x, y) {
12043
- if (!y) return `${CSI2}${x + 1}G`;
12044
- return `${CSI2}${y + 1};${x + 1}H`;
12045
- },
12046
- move(x, y) {
12047
- let ret = "";
12048
- if (x < 0) ret += `${CSI2}${-x}D`;
12049
- else if (x > 0) ret += `${CSI2}${x}C`;
12050
- if (y < 0) ret += `${CSI2}${-y}A`;
12051
- else if (y > 0) ret += `${CSI2}${y}B`;
12052
- return ret;
12053
- },
12054
- up: (count = 1) => `${CSI2}${count}A`,
12055
- down: (count = 1) => `${CSI2}${count}B`,
12056
- forward: (count = 1) => `${CSI2}${count}C`,
12057
- backward: (count = 1) => `${CSI2}${count}D`,
12058
- nextLine: (count = 1) => `${CSI2}E`.repeat(count),
12059
- prevLine: (count = 1) => `${CSI2}F`.repeat(count),
12060
- left: `${CSI2}G`,
12061
- hide: `${CSI2}?25l`,
12062
- show: `${CSI2}?25h`,
12063
- save: `${ESC2}7`,
12064
- restore: `${ESC2}8`
12065
- };
12066
- var scroll = {
12067
- up: (count = 1) => `${CSI2}S`.repeat(count),
12068
- down: (count = 1) => `${CSI2}T`.repeat(count)
12069
- };
12070
- var erase3 = {
12071
- screen: `${CSI2}2J`,
12072
- up: (count = 1) => `${CSI2}1J`.repeat(count),
12073
- down: (count = 1) => `${CSI2}J`.repeat(count),
12074
- line: `${CSI2}2K`,
12075
- lineEnd: `${CSI2}K`,
12076
- lineStart: `${CSI2}1K`,
12077
- lines(count) {
12078
- let clear = "";
12079
- for (let i2 = 0; i2 < count; i2++)
12080
- clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
12081
- if (count)
12082
- clear += cursor3.left;
12083
- return clear;
12084
- }
12085
- };
12086
- module2.exports = { cursor: cursor3, scroll, erase: erase3, beep };
12087
- }
12088
- });
12089
-
12090
12034
  // node_modules/commander/lib/error.js
12091
12035
  var CommanderError = class extends Error {
12092
12036
  /**
@@ -12314,11 +12258,11 @@ var Help = class {
12314
12258
  visibleOptions.push(helpOption);
12315
12259
  } else if (helpOption.long && !removeLong) {
12316
12260
  visibleOptions.push(
12317
- cmd.createOption(helpOption.long, helpOption.description)
12261
+ cmd.createOption(helpOption.long, helpOption.description).helpGroup(helpOption.helpGroupHeading)
12318
12262
  );
12319
12263
  } else if (helpOption.short && !removeShort) {
12320
12264
  visibleOptions.push(
12321
- cmd.createOption(helpOption.short, helpOption.description)
12265
+ cmd.createOption(helpOption.short, helpOption.description).helpGroup(helpOption.helpGroupHeading)
12322
12266
  );
12323
12267
  }
12324
12268
  }
@@ -12850,7 +12794,7 @@ var Option = class {
12850
12794
  this.description = description || "";
12851
12795
  this.required = flags.includes("<");
12852
12796
  this.optional = flags.includes("[");
12853
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
12797
+ this.variadic = new RegExp("\\p{ID_Continue}\\.\\.\\.[>\\]]$", "u").test(flags);
12854
12798
  this.mandatory = false;
12855
12799
  const optionFlags = splitOptionFlags(flags);
12856
12800
  this.short = optionFlags.shortFlag;
@@ -14033,7 +13977,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
14033
13977
  getOptionValueSourceWithGlobals(key) {
14034
13978
  let source;
14035
13979
  this._getCommandAndAncestors().forEach((cmd) => {
14036
- if (cmd.getOptionValueSource(key) !== void 0) {
13980
+ if (Object.hasOwn(cmd._optionValueSources, key)) {
14037
13981
  source = cmd.getOptionValueSource(key);
14038
13982
  }
14039
13983
  });
@@ -14676,7 +14620,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
14676
14620
  return arg.length > 1 && arg[0] === "-";
14677
14621
  }
14678
14622
  const negativeNumberArg = (arg) => {
14679
- if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
14623
+ if (!/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(arg)) return false;
14680
14624
  return !this._getCommandAndAncestors().some(
14681
14625
  (cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
14682
14626
  );
@@ -15124,7 +15068,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
15124
15068
  * (This does not override a group set directly on the subcommand using .helpGroup().)
15125
15069
  *
15126
15070
  * @example
15127
- * program.commandsGroup('Development Commands:);
15071
+ * program.commandsGroup('Development Commands:');
15128
15072
  * program.command('watch')...
15129
15073
  * program.command('lint')...
15130
15074
  * ...
@@ -15295,7 +15239,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
15295
15239
  * Pass in false to disable the built-in help option.
15296
15240
  *
15297
15241
  * @example
15298
- * program.helpOption('-?, --help' 'show help'); // customise
15242
+ * program.helpOption('-?, --help', 'show help'); // customise
15299
15243
  * program.helpOption(false); // disable
15300
15244
  *
15301
15245
  * @param {(string | boolean)} flags
@@ -15424,16 +15368,20 @@ function incrementNodeInspectorPort(args) {
15424
15368
  let debugHost = "127.0.0.1";
15425
15369
  let debugPort = "9229";
15426
15370
  let match;
15427
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
15371
+ if ((match = arg.match(/^(--inspect(-brk|-wait)?)$/)) !== null) {
15428
15372
  debugOption = match[1];
15429
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
15373
+ } else if ((match = arg.match(
15374
+ /^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/
15375
+ )) !== null) {
15430
15376
  debugOption = match[1];
15431
15377
  if (/^\d+$/.test(match[3])) {
15432
15378
  debugPort = match[3];
15433
15379
  } else {
15434
15380
  debugHost = match[3];
15435
15381
  }
15436
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
15382
+ } else if ((match = arg.match(
15383
+ /^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/
15384
+ )) !== null) {
15437
15385
  debugOption = match[1];
15438
15386
  debugHost = match[3];
15439
15387
  debugPort = match[4];
@@ -15580,10 +15528,16 @@ var isPlainObject = (val) => {
15580
15528
  return false;
15581
15529
  }
15582
15530
  const prototype2 = getPrototypeOf(val);
15583
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
15584
- // evidence the value is tagged/iterable, while ignoring members reachable
15585
- // only through shared or terminal prototype boundaries.
15586
- !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
15531
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat own Symbol.toStringTag or Symbol.iterator members as evidence the
15532
+ // value is tagged/iterable, ignoring members reachable only through shared
15533
+ // or terminal prototype boundaries. This is exactly what
15534
+ // hasOwnInPrototypeChain(val, prop) computes here: every prototype admitted
15535
+ // above (null, Object.prototype, or a terminal null-prototype template) is
15536
+ // a boundary, so the walk never inspects anything but `val`'s own members,
15537
+ // and stops before even those when `val` is itself the boundary
15538
+ // Object.prototype. Checking that inline avoids allocating the walker's
15539
+ // `seen` list twice per call on the mergeConfig / merge hot path.
15540
+ (isPrototypeBoundary(val, prototype2, true) || !hasOwnProperty(val, toStringTag) && !hasOwnProperty(val, iterator));
15587
15541
  };
15588
15542
  var isEmptyObject = (val) => {
15589
15543
  if (!isObject(val) || isBuffer(val)) {
@@ -15639,12 +15593,12 @@ function forEach(obj, fn, { allOwnKeys = false } = {}) {
15639
15593
  return;
15640
15594
  }
15641
15595
  let i2;
15642
- let l2;
15596
+ let l;
15643
15597
  if (typeof obj !== "object") {
15644
15598
  obj = [obj];
15645
15599
  }
15646
15600
  if (isArray(obj)) {
15647
- for (i2 = 0, l2 = obj.length; i2 < l2; i2++) {
15601
+ for (i2 = 0, l = obj.length; i2 < l; i2++) {
15648
15602
  fn.call(null, obj[i2], i2, obj);
15649
15603
  }
15650
15604
  } else {
@@ -15684,11 +15638,21 @@ var isContextDefined = (context) => !isUndefined(context) && context !== _global
15684
15638
  function merge(...objs) {
15685
15639
  const { caseless, skipUndefined } = isContextDefined(this) && this || {};
15686
15640
  const result = {};
15641
+ const lowerCaseKeys = caseless ? /* @__PURE__ */ Object.create(null) : null;
15687
15642
  const assignValue = (val, key) => {
15688
15643
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
15689
15644
  return;
15690
15645
  }
15691
- const targetKey = caseless && typeof key === "string" && findKey(result, key) || key;
15646
+ let targetKey = key;
15647
+ if (lowerCaseKeys && typeof key === "string") {
15648
+ const lowerKey = key.toLowerCase();
15649
+ const knownKey = lowerCaseKeys[lowerKey];
15650
+ if (knownKey !== void 0 && hasOwnProperty(result, knownKey)) {
15651
+ targetKey = knownKey;
15652
+ } else {
15653
+ lowerCaseKeys[lowerKey] = key;
15654
+ }
15655
+ }
15692
15656
  const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : void 0;
15693
15657
  if (isPlainObject(existing) && isPlainObject(val)) {
15694
15658
  result[targetKey] = merge(existing, val);
@@ -15700,13 +15664,13 @@ function merge(...objs) {
15700
15664
  result[targetKey] = val;
15701
15665
  }
15702
15666
  };
15703
- for (let i2 = 0, l2 = objs.length; i2 < l2; i2++) {
15667
+ for (let i2 = 0, l = objs.length; i2 < l; i2++) {
15704
15668
  const source = objs[i2];
15705
15669
  if (!source || isBuffer(source)) {
15706
15670
  continue;
15707
15671
  }
15708
15672
  forEach(source, assignValue);
15709
- if (typeof source !== "object" || isArray(source)) {
15673
+ if (typeof source !== "object" || isArray(source) || !Object.getOwnPropertySymbols) {
15710
15674
  continue;
15711
15675
  }
15712
15676
  const symbols = Object.getOwnPropertySymbols(source);
@@ -15802,7 +15766,24 @@ var toArray = (thing) => {
15802
15766
  if (!thing) return null;
15803
15767
  if (isArray(thing)) return thing;
15804
15768
  let i2 = thing.length;
15805
- if (!isNumber(i2)) return null;
15769
+ if (!Number.isSafeInteger(i2) || i2 < 0 || i2 > 4294967295) return null;
15770
+ const indexes = /* @__PURE__ */ new Set();
15771
+ const seen = /* @__PURE__ */ new Set();
15772
+ let source = thing;
15773
+ while (source != null && indexes.size < i2) {
15774
+ if (seen.has(source)) return null;
15775
+ seen.add(source);
15776
+ const prototype2 = getPrototypeOf(source);
15777
+ if (isPrototypeBoundary(source, prototype2, source === thing)) break;
15778
+ Object.getOwnPropertyNames(source).forEach((key) => {
15779
+ const index = +key;
15780
+ if (Number.isInteger(index) && index >= 0 && index < i2 && String(index) === key && hasOwnProperty(source, key)) {
15781
+ indexes.add(index);
15782
+ }
15783
+ });
15784
+ source = prototype2;
15785
+ }
15786
+ if (indexes.size !== i2) return null;
15806
15787
  const arr = new Array(i2);
15807
15788
  while (i2-- > 0) {
15808
15789
  arr[i2] = thing[i2];
@@ -16034,7 +16015,7 @@ var ignoreDuplicateOf = utils_default.toObjectSet([
16034
16015
  "user-agent"
16035
16016
  ]);
16036
16017
  var parseHeaders_default = (rawHeaders) => {
16037
- const parsed = {};
16018
+ const parsed = /* @__PURE__ */ Object.create(null);
16038
16019
  let key;
16039
16020
  let val;
16040
16021
  let i2;
@@ -16202,9 +16183,11 @@ function parseParameters(value) {
16202
16183
  return parameters;
16203
16184
  }
16204
16185
  var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
16186
+ var PROTO_HEADER_SLOT = "__Proto__";
16187
+ var headerSlot = (name) => name === "__proto__" ? PROTO_HEADER_SLOT : name;
16205
16188
  function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
16206
16189
  if (utils_default.isFunction(filter2)) {
16207
- return filter2.call(this, value, header);
16190
+ return filter2.call(context, value, header);
16208
16191
  }
16209
16192
  if (isHeaderNameFilter) {
16210
16193
  value = header;
@@ -16249,7 +16232,7 @@ var AxiosHeaders = class {
16249
16232
  }
16250
16233
  const key = utils_default.findKey(self2, lHeader);
16251
16234
  if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
16252
- self2[key || _header] = normalizeValue(_value);
16235
+ self2[headerSlot(key || _header)] = normalizeValue(_value);
16253
16236
  }
16254
16237
  }
16255
16238
  const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
@@ -16342,7 +16325,7 @@ var AxiosHeaders = class {
16342
16325
  }
16343
16326
  normalize(format) {
16344
16327
  const self2 = this;
16345
- const headers = {};
16328
+ const headers = /* @__PURE__ */ Object.create(null);
16346
16329
  utils_default.forEach(this, (value, header) => {
16347
16330
  const key = utils_default.findKey(headers, header);
16348
16331
  if (key) {
@@ -16350,7 +16333,7 @@ var AxiosHeaders = class {
16350
16333
  delete self2[header];
16351
16334
  return;
16352
16335
  }
16353
- const normalized = format ? formatHeader(header) : String(header).trim();
16336
+ const normalized = headerSlot(format ? formatHeader(header) : String(header).trim());
16354
16337
  if (normalized !== header) {
16355
16338
  delete self2[header];
16356
16339
  }
@@ -16500,6 +16483,28 @@ function aggregateErrorMessage(error) {
16500
16483
  }).filter(Boolean).join("; ");
16501
16484
  return message || error.name || "AggregateError";
16502
16485
  }
16486
+ var CAUSED_BY_SEPARATOR = "\nCaused by: ";
16487
+ var $causeStack = /* @__PURE__ */ Symbol("causeStack");
16488
+ function getCauseStackIndex(error, stack) {
16489
+ const causeStack = utils_default.hasOwnProp(error, $causeStack) && error[$causeStack];
16490
+ return causeStack && stack.endsWith(causeStack) ? stack.length - causeStack.length : -1;
16491
+ }
16492
+ function appendCauseStack(target, source) {
16493
+ try {
16494
+ const sourceStack = source && source.stack;
16495
+ if (typeof sourceStack !== "string" || !sourceStack) {
16496
+ return;
16497
+ }
16498
+ const targetStack = target.stack;
16499
+ if (typeof targetStack !== "string" || !targetStack) {
16500
+ return;
16501
+ }
16502
+ const causeStack = CAUSED_BY_SEPARATOR + sourceStack;
16503
+ target.stack = targetStack + causeStack;
16504
+ Object.defineProperty(target, $causeStack, { __proto__: null, value: causeStack });
16505
+ } catch (e) {
16506
+ }
16507
+ }
16503
16508
  var AxiosError = class _AxiosError extends Error {
16504
16509
  static from(error, code, config, request, response, customProps) {
16505
16510
  let message = error.message;
@@ -16515,6 +16520,7 @@ var AxiosError = class _AxiosError extends Error {
16515
16520
  configurable: true
16516
16521
  });
16517
16522
  axiosError.name = error.name;
16523
+ appendCauseStack(axiosError, error);
16518
16524
  if (error.status != null && axiosError.status == null) {
16519
16525
  axiosError.status = error.status;
16520
16526
  }
@@ -16826,6 +16832,12 @@ function trimHandlers(handlers) {
16826
16832
  handlers.pop();
16827
16833
  }
16828
16834
  }
16835
+ function normalizeHandlerId(id) {
16836
+ if (typeof id === "string" && id !== "" && String(Number(id)) === id) {
16837
+ return Number(id);
16838
+ }
16839
+ return id;
16840
+ }
16829
16841
  function syncHandlerEntries(manager, internals) {
16830
16842
  const handlers = manager.handlers;
16831
16843
  const length = countHandlers(handlers);
@@ -16896,9 +16908,10 @@ var InterceptorManager = class {
16896
16908
  eject(id) {
16897
16909
  const internals = this[$internals2];
16898
16910
  syncHandlerEntries(this, internals);
16899
- const entry = internals.handlerEntries.get(id);
16911
+ const handlerId = normalizeHandlerId(id);
16912
+ const entry = internals.handlerEntries.get(handlerId);
16900
16913
  if (entry) {
16901
- internals.handlerEntries.delete(id);
16914
+ internals.handlerEntries.delete(handlerId);
16902
16915
  if (this.handlers[entry.index] !== entry.handler) {
16903
16916
  return;
16904
16917
  }
@@ -16958,7 +16971,8 @@ var transitional_default = {
16958
16971
  clarifyTimeoutError: false,
16959
16972
  legacyInterceptorReqResOrdering: true,
16960
16973
  advertiseZstdAcceptEncoding: false,
16961
- validateStatusUndefinedResolves: true
16974
+ validateStatusUndefinedResolves: true,
16975
+ encodeBasicAuthUsername: false
16962
16976
  };
16963
16977
 
16964
16978
  // node_modules/axios/lib/platform/node/index.js
@@ -17068,6 +17082,24 @@ function arrayToObject(arr) {
17068
17082
  }
17069
17083
  return obj;
17070
17084
  }
17085
+ function normalizeArray(value) {
17086
+ if (!utils_default.isArray(value)) return value;
17087
+ const keys = Object.keys(value);
17088
+ return keys.length !== value.length || keys.some((key, index) => key !== String(index)) ? arrayToObject(value) : value;
17089
+ }
17090
+ function normalizeArrays(obj) {
17091
+ const pending = [obj];
17092
+ while (pending.length) {
17093
+ const target = pending.pop();
17094
+ Object.keys(target).forEach((key) => {
17095
+ const value = target[key] = normalizeArray(target[key]);
17096
+ if (utils_default.isArray(value) || utils_default.isPlainObject(value)) {
17097
+ pending.push(value);
17098
+ }
17099
+ });
17100
+ }
17101
+ return obj;
17102
+ }
17071
17103
  function formDataToJSON(formData) {
17072
17104
  function buildPath(path6, value, target, index) {
17073
17105
  throwIfDepthExceeded(index);
@@ -17078,6 +17110,7 @@ function formDataToJSON(formData) {
17078
17110
  name = !name && utils_default.isArray(target) ? target.length : name;
17079
17111
  if (isLast) {
17080
17112
  if (utils_default.hasOwnProp(target, name)) {
17113
+ target[name] = normalizeArray(target[name]);
17081
17114
  target[name] = utils_default.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
17082
17115
  } else {
17083
17116
  target[name] = value;
@@ -17098,7 +17131,7 @@ function formDataToJSON(formData) {
17098
17131
  utils_default.forEachEntry(formData, (name, value) => {
17099
17132
  buildPath(parsePropPath(name), value, obj, 0);
17100
17133
  });
17101
- return obj;
17134
+ return normalizeArrays(obj);
17102
17135
  }
17103
17136
  return null;
17104
17137
  }
@@ -17446,16 +17479,16 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
17446
17479
  var import_zlib = __toESM(require("zlib"), 1);
17447
17480
 
17448
17481
  // node_modules/axios/lib/env/data.js
17449
- var VERSION = "1.20.0";
17482
+ var VERSION = "1.21.0";
17450
17483
 
17451
17484
  // node_modules/axios/lib/helpers/parseProtocol.js
17452
17485
  function parseProtocol(url2) {
17453
17486
  const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url2);
17454
- return match && match[1] || "";
17487
+ return match && match[1].toLowerCase() || "";
17455
17488
  }
17456
17489
 
17457
17490
  // node_modules/axios/lib/helpers/fromDataURI.js
17458
- var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
17491
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/i;
17459
17492
  function fromDataURI(uri, asBlob, options) {
17460
17493
  const _Blob = options && options.Blob || platform_default.classes.Blob;
17461
17494
  const protocol = parseProtocol(uri);
@@ -17478,7 +17511,10 @@ function fromDataURI(uri, asBlob, options) {
17478
17511
  } else if (params) {
17479
17512
  mime = "text/plain" + params;
17480
17513
  }
17481
- const buffer = encoding === "base64" ? Buffer.from(body, "base64") : Buffer.from(decodeURIComponent(body), encoding);
17514
+ const buffer = encoding === "base64" ? Buffer.from(
17515
+ body.replace(/%([\da-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))),
17516
+ "base64"
17517
+ ) : Buffer.from(decodeURIComponent(body), encoding);
17482
17518
  if (asBlob) {
17483
17519
  if (!_Blob) {
17484
17520
  throw new AxiosError_default("Blob is not supported", AxiosError_default.ERR_NOT_SUPPORT);
@@ -17564,7 +17600,10 @@ var AxiosTransformStream = class extends import_stream.default.Transform {
17564
17600
  const timeWindow = internals.timeWindow;
17565
17601
  const divider = 1e3 / timeWindow;
17566
17602
  const bytesThreshold = maxRate / divider;
17567
- const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
17603
+ let minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
17604
+ if (maxRate) {
17605
+ minChunkSize = Math.min(bytesThreshold, minChunkSize);
17606
+ }
17568
17607
  const pushChunk = (_chunk, _callback) => {
17569
17608
  const bytes = Buffer.byteLength(_chunk);
17570
17609
  internals.bytesSeen += bytes;
@@ -17580,6 +17619,9 @@ var AxiosTransformStream = class extends import_stream.default.Transform {
17580
17619
  }
17581
17620
  };
17582
17621
  const transformChunk = (_chunk, _callback) => {
17622
+ if (this.destroyed) {
17623
+ return _callback();
17624
+ }
17583
17625
  const chunkSize = Buffer.byteLength(_chunk);
17584
17626
  let chunkRemainder = null;
17585
17627
  let maxChunkSize = readableHighWaterMark;
@@ -17602,7 +17644,7 @@ var AxiosTransformStream = class extends import_stream.default.Transform {
17602
17644
  }, timeWindow - passed);
17603
17645
  }
17604
17646
  if (bytesLeft < maxChunkSize) {
17605
- maxChunkSize = bytesLeft;
17647
+ maxChunkSize = Math.max(1, Math.floor(bytesLeft));
17606
17648
  }
17607
17649
  }
17608
17650
  if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
@@ -17660,9 +17702,9 @@ var CRLF_BYTES = textEncoder.encode(CRLF);
17660
17702
  var CRLF_BYTES_COUNT = 2;
17661
17703
  var FormDataPart = class {
17662
17704
  constructor(name, value) {
17663
- const { escapeName } = this.constructor;
17705
+ const { escapeName: escapeName2 } = this.constructor;
17664
17706
  const isStringValue = utils_default.isString(value);
17665
- let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ""}${CRLF}`;
17707
+ let headers = `Content-Disposition: form-data; name="${escapeName2(name)}"${!isStringValue && value.name ? `; filename="${escapeName2(value.name)}"` : ""}${CRLF}`;
17666
17708
  if (isStringValue) {
17667
17709
  value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
17668
17710
  } else {
@@ -17784,7 +17826,7 @@ var Http2Sessions = class {
17784
17826
  }
17785
17827
  }
17786
17828
  }
17787
- const session = import_http2.default.connect(authority, options);
17829
+ const session2 = import_http2.default.connect(authority, options);
17788
17830
  let removed;
17789
17831
  let timer;
17790
17832
  const removeSession = () => {
@@ -17798,24 +17840,24 @@ var Http2Sessions = class {
17798
17840
  }
17799
17841
  let entries = authoritySessions, len = entries.length, i2 = len;
17800
17842
  while (i2--) {
17801
- if (entries[i2][0] === session) {
17843
+ if (entries[i2][0] === session2) {
17802
17844
  if (len === 1) {
17803
17845
  delete this.sessions[authority];
17804
17846
  } else {
17805
17847
  entries.splice(i2, 1);
17806
17848
  }
17807
- if (!session.closed) {
17808
- session.close();
17849
+ if (!session2.closed) {
17850
+ session2.close();
17809
17851
  }
17810
17852
  return;
17811
17853
  }
17812
17854
  }
17813
17855
  };
17814
- const originalRequestFn = session.request;
17856
+ const originalRequestFn = session2.request;
17815
17857
  const { sessionTimeout } = options;
17816
17858
  if (sessionTimeout != null) {
17817
17859
  let streamsCount = 0;
17818
- session.request = function() {
17860
+ session2.request = function() {
17819
17861
  const stream4 = originalRequestFn.apply(this, arguments);
17820
17862
  streamsCount++;
17821
17863
  if (timer) {
@@ -17823,7 +17865,7 @@ var Http2Sessions = class {
17823
17865
  timer = null;
17824
17866
  }
17825
17867
  stream4.once("close", () => {
17826
- if (!--streamsCount) {
17868
+ if (!--streamsCount && !removed) {
17827
17869
  timer = setTimeout(() => {
17828
17870
  timer = null;
17829
17871
  removeSession();
@@ -17833,11 +17875,12 @@ var Http2Sessions = class {
17833
17875
  return stream4;
17834
17876
  };
17835
17877
  }
17836
- session.once("close", removeSession);
17837
- session.once("error", removeSession);
17838
- let entry = [session, options];
17878
+ session2.once("close", removeSession);
17879
+ session2.once("error", removeSession);
17880
+ session2.once("goaway", removeSession);
17881
+ let entry = [session2, options];
17839
17882
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
17840
- return session;
17883
+ return session2;
17841
17884
  }
17842
17885
  };
17843
17886
  var Http2Sessions_default = Http2Sessions;
@@ -17858,6 +17901,7 @@ var callbackify = (fn, reducer) => {
17858
17901
  var callbackify_default = callbackify;
17859
17902
 
17860
17903
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
17904
+ var import_url2 = require("url");
17861
17905
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
17862
17906
  var trimTrailingDots = (value) => {
17863
17907
  let end = value.length;
@@ -18051,7 +18095,20 @@ var normalizeNoProxyHost = (hostname) => {
18051
18095
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
18052
18096
  hostname = hostname.slice(1, -1);
18053
18097
  }
18054
- const trimmed = trimTrailingDots(hostname);
18098
+ let trimmed = trimTrailingDots(hostname);
18099
+ if (trimmed.indexOf(":") !== -1) {
18100
+ try {
18101
+ trimmed = new URL("http://[" + trimmed + "]/").hostname.slice(1, -1);
18102
+ } catch (_err) {
18103
+ return trimmed;
18104
+ }
18105
+ } else if (/[\u0080-\uffff]/.test(trimmed)) {
18106
+ const prefix = /^[*.]+/.exec(trimmed);
18107
+ const start = prefix ? prefix[0] : "";
18108
+ const ascii = (0, import_url2.domainToASCII)(trimmed.slice(start.length));
18109
+ if (!ascii) return "";
18110
+ trimmed = start + trimTrailingDots(ascii);
18111
+ }
18055
18112
  const ipv4 = normalizeIPAddress(trimmed);
18056
18113
  if (ipv4 !== trimmed) {
18057
18114
  return ipv4;
@@ -18322,6 +18379,26 @@ var estimateBase64BufferAllocation = (body) => {
18322
18379
  }
18323
18380
  return Math.floor((len - padding) * 3 / 4);
18324
18381
  };
18382
+ var estimatePercentDecodedBase64BufferAllocation = (body) => {
18383
+ if (body.indexOf("%") === -1) {
18384
+ return estimateBase64BufferAllocation(body);
18385
+ }
18386
+ let length = 0;
18387
+ let previous = 0;
18388
+ let last = 0;
18389
+ for (let i2 = 0, len = body.length; i2 < len; i2++) {
18390
+ let code = body.charCodeAt(i2);
18391
+ if (code === 37 && isPercentEncodedByte(body, i2, len)) {
18392
+ code = hexValue(body.charCodeAt(i2 + 1)) * 16 + hexValue(body.charCodeAt(i2 + 2));
18393
+ i2 += 2;
18394
+ }
18395
+ length++;
18396
+ previous = last;
18397
+ last = code;
18398
+ }
18399
+ const padding = last === 61 ? previous === 61 ? 2 : 1 : 0;
18400
+ return Math.floor((length - padding) * 3 / 4);
18401
+ };
18325
18402
  var estimatePercentDecodedBase64Bytes = (body) => {
18326
18403
  const len = body.length;
18327
18404
  let significant = 0;
@@ -18351,28 +18428,28 @@ var estimatePercentDecodedBase64Bytes = (body) => {
18351
18428
  }
18352
18429
  return base64Bytes(significant);
18353
18430
  };
18354
- var estimateDataURLBytes = (url2, estimateBase64) => {
18431
+ var estimateDataURLBytes = (url2, estimateBase64, base64Pattern) => {
18355
18432
  if (!url2 || typeof url2 !== "string") return 0;
18356
- if (!url2.startsWith("data:")) return 0;
18433
+ if (!/^data:/i.test(url2)) return 0;
18357
18434
  const comma = url2.indexOf(",");
18358
18435
  if (comma < 0) return 0;
18359
18436
  const meta = url2.slice(5, comma);
18360
18437
  const body = url2.slice(comma + 1);
18361
- const isBase64 = /;base64/i.test(meta);
18438
+ const isBase64 = base64Pattern.test(meta);
18362
18439
  if (isBase64) {
18363
18440
  return estimateBase64(body);
18364
18441
  }
18365
18442
  let bytes = 0;
18366
18443
  for (let i2 = 0, len = body.length; i2 < len; i2++) {
18367
- const c = body.charCodeAt(i2);
18368
- if (c === 37 && isPercentEncodedByte(body, i2, len)) {
18444
+ const c2 = body.charCodeAt(i2);
18445
+ if (c2 === 37 && isPercentEncodedByte(body, i2, len)) {
18369
18446
  bytes += 1;
18370
18447
  i2 += 2;
18371
- } else if (c < 128) {
18448
+ } else if (c2 < 128) {
18372
18449
  bytes += 1;
18373
- } else if (c < 2048) {
18450
+ } else if (c2 < 2048) {
18374
18451
  bytes += 2;
18375
- } else if (c >= 55296 && c <= 56319 && i2 + 1 < len) {
18452
+ } else if (c2 >= 55296 && c2 <= 56319 && i2 + 1 < len) {
18376
18453
  const next = body.charCodeAt(i2 + 1);
18377
18454
  if (next >= 56320 && next <= 57343) {
18378
18455
  bytes += 4;
@@ -18390,11 +18467,12 @@ function estimateDataURLDecodedBytes(url2) {
18390
18467
  const fragmentIndex = typeof url2 === "string" ? url2.indexOf("#") : -1;
18391
18468
  return estimateDataURLBytes(
18392
18469
  fragmentIndex === -1 ? url2 : url2.slice(0, fragmentIndex),
18393
- estimatePercentDecodedBase64Bytes
18470
+ estimatePercentDecodedBase64Bytes,
18471
+ /; *base64[\t\n\f\r ]*$/i
18394
18472
  );
18395
18473
  }
18396
18474
  function estimateDataURLBufferAllocation(url2) {
18397
- return estimateDataURLBytes(url2, estimateBase64BufferAllocation);
18475
+ return estimateDataURLBytes(url2, estimatePercentDecodedBase64BufferAllocation, /;base64$/i);
18398
18476
  }
18399
18477
 
18400
18478
  // node_modules/axios/lib/adapters/http.js
@@ -18428,6 +18506,18 @@ function handleSocketError(err) {
18428
18506
  var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
18429
18507
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
18430
18508
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
18509
+ var directAgents = /* @__PURE__ */ new WeakMap();
18510
+ var directAgentHooks = ["createConnection", "getName"];
18511
+ var nativeAgentPoolHooks = [
18512
+ "addRequest",
18513
+ "createSocket",
18514
+ "removeSocket",
18515
+ "keepSocketAlive",
18516
+ "reuseSocket",
18517
+ "_getSession",
18518
+ "_cacheSession",
18519
+ "_evictSession"
18520
+ ];
18431
18521
  var NODE_NATIVE_ENV_PROXY_SUPPORT = {
18432
18522
  22: 21,
18433
18523
  24: 5
@@ -18457,6 +18547,49 @@ function isNodeEnvProxyEnabled(agent, nodeVersion = process.versions && process.
18457
18547
  function getProxyEnvAgent(options, configHttpAgent, configHttpsAgent) {
18458
18548
  return isHttps.test(options.protocol) ? configHttpsAgent || import_https.default.globalAgent : configHttpAgent || import_http.default.globalAgent;
18459
18549
  }
18550
+ function getDirectAgent(configuredAgent, transport) {
18551
+ if (!process.allowedNodeEnvironmentFlags || !process.allowedNodeEnvironmentFlags.has("--use-env-proxy")) {
18552
+ return configuredAgent;
18553
+ }
18554
+ const agent = configuredAgent || transport.globalAgent;
18555
+ const options = agent && agent.options;
18556
+ if (!(agent instanceof transport.Agent) || agent.protocol !== transport.globalAgent.protocol || !options || !utils_default.hasOwnProp(options, "proxyEnv") || typeof options.proxyEnv !== "object" || options.proxyEnv === null) {
18557
+ return configuredAgent;
18558
+ }
18559
+ for (const hook of nativeAgentPoolHooks) {
18560
+ if (utils_default.isFunction(transport.Agent.prototype[hook]) && agent[hook] !== transport.Agent.prototype[hook]) {
18561
+ throw new AxiosError_default(
18562
+ "proxy: false cannot adapt an agent overriding " + hook + "; use an agent constructed without proxyEnv",
18563
+ AxiosError_default.ERR_BAD_OPTION_VALUE
18564
+ );
18565
+ }
18566
+ }
18567
+ let direct = directAgents.get(agent);
18568
+ if (!direct) {
18569
+ direct = new transport.Agent({ ...options, proxyEnv: void 0 });
18570
+ const destroy = agent.destroy;
18571
+ agent.destroy = function destroyWithDirectAgent() {
18572
+ try {
18573
+ return destroy.apply(this, arguments);
18574
+ } finally {
18575
+ direct.destroy();
18576
+ }
18577
+ };
18578
+ directAgents.set(agent, direct);
18579
+ }
18580
+ for (const hook of directAgentHooks) {
18581
+ direct[hook] = agent[hook] === transport.Agent.prototype[hook] ? transport.Agent.prototype[hook] : bind(agent[hook], agent);
18582
+ }
18583
+ return direct;
18584
+ }
18585
+ function setDirectAgent(options, configHttpAgent, configHttpsAgent) {
18586
+ const secure = isHttps.test(options.protocol);
18587
+ const agent = getDirectAgent(secure ? configHttpsAgent : configHttpAgent, secure ? import_https.default : import_http.default);
18588
+ options.agent = agent;
18589
+ if (options.agents) {
18590
+ options.agents[secure ? "https" : "http"] = agent;
18591
+ }
18592
+ }
18460
18593
  function getTunnelingAgent(agentOptions, userHttpsAgent) {
18461
18594
  const key = agentOptions.protocol + "//" + agentOptions.hostname + ":" + (agentOptions.port || "") + "#" + (agentOptions.auth || "");
18462
18595
  const cache = userHttpsAgent ? tunnelingAgentCacheUser.get(userHttpsAgent) || tunnelingAgentCacheUser.set(userHttpsAgent, /* @__PURE__ */ new Map()).get(userHttpsAgent) : tunnelingAgentCache;
@@ -18464,13 +18597,12 @@ function getTunnelingAgent(agentOptions, userHttpsAgent) {
18464
18597
  if (agent) return agent;
18465
18598
  const merged = userHttpsAgent && userHttpsAgent.options ? { ...userHttpsAgent.options, ...agentOptions } : agentOptions;
18466
18599
  agent = new import_https_proxy_agent.default(merged);
18467
- if (userHttpsAgent && userHttpsAgent.options) {
18468
- const originTLSOptions = { ...userHttpsAgent.options };
18469
- const callback = agent.callback;
18470
- agent.callback = function axiosTunnelingAgentCallback(req, opts) {
18471
- return callback.call(this, req, { ...originTLSOptions, ...opts });
18472
- };
18473
- }
18600
+ const callback = agent.callback;
18601
+ agent.callback = function axiosTunnelingAgentCallback(req, opts) {
18602
+ const originTLSAgent = userHttpsAgent || import_https.default.globalAgent;
18603
+ const originTLSOptions = originTLSAgent && originTLSAgent.options;
18604
+ return callback.call(this, req, { ...originTLSOptions, ...opts });
18605
+ };
18474
18606
  agent[kAxiosInstalledTunnel] = true;
18475
18607
  cache.set(key, agent);
18476
18608
  return agent;
@@ -18494,6 +18626,10 @@ var flushOnFinish = (stream4, [throttled, flush]) => {
18494
18626
  };
18495
18627
  var http2Sessions = new Http2Sessions_default();
18496
18628
  function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
18629
+ if (!isSameOriginRedirect(options, requestDetails)) {
18630
+ stripMatchingHeaders(options.headers, /* @__PURE__ */ new Set(["authorization", "cookie"]));
18631
+ delete options.auth;
18632
+ }
18497
18633
  if (options.beforeRedirects.proxy) {
18498
18634
  options.beforeRedirects.proxy(options);
18499
18635
  }
@@ -18503,6 +18639,9 @@ function dispatchBeforeRedirect(options, responseDetails, requestDetails) {
18503
18639
  if (options.beforeRedirects.sensitiveHeaders) {
18504
18640
  options.beforeRedirects.sensitiveHeaders(options, requestDetails);
18505
18641
  }
18642
+ if (options.beforeRedirects.direct) {
18643
+ options.beforeRedirects.direct(options);
18644
+ }
18506
18645
  if (options.beforeRedirects.config) {
18507
18646
  options.beforeRedirects.config(options, responseDetails, requestDetails);
18508
18647
  }
@@ -18548,6 +18687,9 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
18548
18687
  if (isRedirect && options.agent && options.agent[kAxiosInstalledTunnel]) {
18549
18688
  options.agent = void 0;
18550
18689
  }
18690
+ if (isRedirect && options.agents && options.agents.https && options.agents.https[kAxiosInstalledTunnel]) {
18691
+ options.agents.https = configHttpsAgent;
18692
+ }
18551
18693
  if (proxy) {
18552
18694
  const isProxyURL = proxy instanceof URL;
18553
18695
  const readProxyField = (key) => isProxyURL || utils_default.hasOwnProp(proxy, key) ? proxy[key] : void 0;
@@ -18694,7 +18836,7 @@ var http2Transport = {
18694
18836
  request(options, cb) {
18695
18837
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
18696
18838
  const { http2Options, headers } = options;
18697
- const session = http2Sessions.getSession(authority, http2Options);
18839
+ const session2 = http2Sessions.getSession(authority, http2Options);
18698
18840
  const { HTTP2_HEADER_SCHEME, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } = import_http22.default.constants;
18699
18841
  const http2Headers = {
18700
18842
  [HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
@@ -18704,7 +18846,7 @@ var http2Transport = {
18704
18846
  utils_default.forEach(headers, (header, name) => {
18705
18847
  name.charAt(0) !== ":" && (http2Headers[name] = header);
18706
18848
  });
18707
- const req = session.request(http2Headers);
18849
+ const req = session2.request(http2Headers);
18708
18850
  req.once("response", (responseHeaders) => {
18709
18851
  const response = req;
18710
18852
  responseHeaders = Object.assign({}, responseHeaders);
@@ -18728,9 +18870,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18728
18870
  if (httpVersion === void 0) httpVersion = 1;
18729
18871
  const rawHttpVersion = httpVersion;
18730
18872
  let http2Options = own2("http2Options");
18873
+ const configProxy = own2("proxy");
18731
18874
  const httpAgent = own2("httpAgent");
18732
18875
  const httpsAgent = own2("httpsAgent");
18733
- const configProxy = own2("proxy");
18734
18876
  const responseType = own2("responseType");
18735
18877
  const responseEncoding = own2("responseEncoding");
18736
18878
  const socketPath = own2("socketPath");
@@ -18869,6 +19011,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18869
19011
  } catch (err) {
18870
19012
  throw AxiosError_default.from(err, AxiosError_default.ERR_BAD_REQUEST, config);
18871
19013
  }
19014
+ if (maxContentLength > -1 && (responseType === "blob" ? convertedData.size : convertedData.length) > maxContentLength) {
19015
+ return reject(
19016
+ new AxiosError_default(
19017
+ "maxContentLength size of " + maxContentLength + " exceeded",
19018
+ AxiosError_default.ERR_BAD_RESPONSE,
19019
+ config
19020
+ )
19021
+ );
19022
+ }
18872
19023
  if (responseType === "text") {
18873
19024
  convertedData = convertedData.toString(responseEncoding);
18874
19025
  if (!responseEncoding || responseEncoding === "utf8") {
@@ -19071,9 +19222,13 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
19071
19222
  }
19072
19223
  let transport;
19073
19224
  let isNativeTransport = false;
19074
- let transportEnforcesMaxBodyLength = false;
19075
19225
  const isHttpsRequest = isHttps.test(options.protocol);
19076
- if (options.agent == null) {
19226
+ if (!isHttp2 && configProxy === false) {
19227
+ setDirectAgent(options, httpAgent, httpsAgent);
19228
+ options.beforeRedirects.direct = (redirectOptions) => {
19229
+ setDirectAgent(redirectOptions, httpAgent, httpsAgent);
19230
+ };
19231
+ } else if (options.agent == null) {
19077
19232
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
19078
19233
  }
19079
19234
  if (isHttp2) {
@@ -19095,7 +19250,6 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
19095
19250
  transport = isHttpsRequest ? import_https.default : import_http.default;
19096
19251
  isNativeTransport = true;
19097
19252
  } else {
19098
- transportEnforcesMaxBodyLength = true;
19099
19253
  options.sensitiveHeaders = [];
19100
19254
  if (maxRedirects) {
19101
19255
  options.maxRedirects = maxRedirects;
@@ -19381,7 +19535,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
19381
19535
  }
19382
19536
  });
19383
19537
  let uploadStream = data;
19384
- if (maxBodyLength > -1 && !transportEnforcesMaxBodyLength) {
19538
+ if (maxBodyLength > -1) {
19385
19539
  const limit = maxBodyLength;
19386
19540
  let bytesSent = 0;
19387
19541
  uploadStream = import_stream4.default.pipeline(
@@ -19418,16 +19572,14 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
19418
19572
  });
19419
19573
  };
19420
19574
 
19421
- // node_modules/axios/lib/helpers/isURLSameOrigin.js
19422
- var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url2) => {
19423
- url2 = new URL(url2, platform_default.origin);
19424
- return origin2.protocol === url2.protocol && origin2.host === url2.host && (isMSIE || origin2.port === url2.port);
19425
- })(
19426
- new URL(platform_default.origin),
19427
- platform_default.navigator && /(msie|trident)/i.test(platform_default.navigator.userAgent)
19428
- ) : () => true;
19429
-
19430
19575
  // node_modules/axios/lib/helpers/cookies.js
19576
+ var decodeCookieValue = (value) => {
19577
+ try {
19578
+ return decodeURIComponent(value);
19579
+ } catch (e) {
19580
+ return value;
19581
+ }
19582
+ };
19431
19583
  var cookies_default = platform_default.hasStandardBrowserEnv ? (
19432
19584
  // Standard browser envs support document.cookie
19433
19585
  {
@@ -19453,20 +19605,29 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
19453
19605
  },
19454
19606
  read(name) {
19455
19607
  if (typeof document === "undefined") return null;
19456
- const cookies = document.cookie.split(";");
19608
+ const cookieString = document.cookie;
19609
+ if (!cookieString) return null;
19610
+ const cookies = cookieString.split(";");
19457
19611
  for (let i2 = 0; i2 < cookies.length; i2++) {
19458
19612
  const cookie = cookies[i2].replace(/^\s+/, "");
19459
19613
  const eq = cookie.indexOf("=");
19460
19614
  if (eq !== -1 && cookie.slice(0, eq) === name) {
19461
- try {
19462
- return decodeURIComponent(cookie.slice(eq + 1));
19463
- } catch (e) {
19464
- return cookie.slice(eq + 1);
19465
- }
19615
+ return decodeCookieValue(cookie.slice(eq + 1));
19466
19616
  }
19467
19617
  }
19468
19618
  return null;
19469
19619
  },
19620
+ async readAsync(name) {
19621
+ try {
19622
+ const store = typeof window !== "undefined" && window.cookieStore;
19623
+ if (store && utils_default.isFunction(store.get)) {
19624
+ const cookie = await store.get(name);
19625
+ return cookie ? decodeCookieValue(cookie.value) : null;
19626
+ }
19627
+ } catch (e) {
19628
+ }
19629
+ return this.read(name);
19630
+ },
19470
19631
  remove(name) {
19471
19632
  this.write(name, "", Date.now() - 864e5, "/");
19472
19633
  }
@@ -19479,130 +19640,224 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
19479
19640
  read() {
19480
19641
  return null;
19481
19642
  },
19643
+ async readAsync() {
19644
+ return null;
19645
+ },
19482
19646
  remove() {
19483
19647
  }
19484
19648
  }
19485
19649
  );
19486
19650
 
19651
+ // node_modules/axios/lib/helpers/isURLSameOrigin.js
19652
+ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2) => (url2) => {
19653
+ url2 = new URL(url2, document.baseURI || platform_default.origin);
19654
+ return origin2.protocol === url2.protocol && origin2.host === url2.host && origin2.port === url2.port;
19655
+ })(new URL(platform_default.origin)) : () => true;
19656
+
19657
+ // node_modules/axios/lib/core/assertParamsAcyclic.js
19658
+ function assertParamsAcyclic(params) {
19659
+ const pending = [{ value: params }];
19660
+ const active = /* @__PURE__ */ new WeakSet();
19661
+ const visited = /* @__PURE__ */ new WeakSet();
19662
+ while (pending.length) {
19663
+ const { value, done } = pending.pop();
19664
+ if (!utils_default.isPlainObject(value) && !utils_default.isArray(value)) continue;
19665
+ if (done) {
19666
+ active.delete(value);
19667
+ continue;
19668
+ }
19669
+ if (active.has(value)) {
19670
+ throw new AxiosError_default(
19671
+ "Circular reference detected in params",
19672
+ AxiosError_default.ERR_BAD_OPTION_VALUE
19673
+ );
19674
+ }
19675
+ if (visited.has(value)) continue;
19676
+ visited.add(value);
19677
+ active.add(value);
19678
+ pending.push({ value, done: true });
19679
+ const keys = Object.keys(value);
19680
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
19681
+ Object.getOwnPropertySymbols(value).forEach((key) => {
19682
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
19683
+ if (descriptor && descriptor.enumerable) keys.push(key);
19684
+ });
19685
+ }
19686
+ keys.forEach((key) => {
19687
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
19688
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
19689
+ if (descriptor && utils_default.hasOwnProp(descriptor, "value")) {
19690
+ pending.push({ value: descriptor.value });
19691
+ }
19692
+ } else {
19693
+ pending.push({ value: value[key] });
19694
+ }
19695
+ });
19696
+ }
19697
+ }
19698
+
19487
19699
  // node_modules/axios/lib/core/mergeConfig.js
19488
19700
  var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
19489
19701
  var ownEnumerableKeys = (thing) => {
19490
19702
  if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
19491
19703
  return Object.keys(thing).concat(
19492
- Object.getOwnPropertySymbols(thing).filter(
19493
- (symbol2) => Object.getOwnPropertyDescriptor(thing, symbol2).enumerable
19494
- )
19704
+ Object.getOwnPropertySymbols(thing).filter((symbol2) => {
19705
+ const descriptor = Object.getOwnPropertyDescriptor(thing, symbol2);
19706
+ return descriptor && descriptor.enumerable;
19707
+ })
19495
19708
  );
19496
19709
  }
19497
19710
  return Object.keys(thing);
19498
19711
  };
19499
- function mergeConfig(config1, config2) {
19500
- config1 = config1 || {};
19501
- config2 = config2 || {};
19502
- const config = /* @__PURE__ */ Object.create(null);
19503
- Object.defineProperty(config, "hasOwnProperty", {
19504
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
19505
- // this data descriptor into an accessor descriptor on the way in.
19506
- __proto__: null,
19507
- value: Object.prototype.hasOwnProperty,
19508
- enumerable: false,
19509
- writable: true,
19510
- configurable: true
19511
- });
19512
- function getMergedValue(target, source, prop, caseless) {
19513
- if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
19514
- return utils_default.merge.call({ caseless }, target, source);
19515
- } else if (utils_default.isPlainObject(source)) {
19516
- return utils_default.merge({}, source);
19517
- } else if (utils_default.isArray(source)) {
19518
- return source.slice();
19519
- }
19520
- return source;
19712
+ function mergeParams(a2, b) {
19713
+ const pending = [];
19714
+ const copies = /* @__PURE__ */ new WeakMap();
19715
+ const empty = {};
19716
+ function copy(target, source) {
19717
+ if (!utils_default.isPlainObject(source)) {
19718
+ return utils_default.isArray(source) ? source.slice() : source;
19719
+ }
19720
+ const base = utils_default.isPlainObject(target) ? target : empty;
19721
+ let bases = copies.get(source);
19722
+ if (!bases) {
19723
+ bases = /* @__PURE__ */ new WeakMap();
19724
+ copies.set(source, bases);
19725
+ }
19726
+ if (bases.has(base)) return bases.get(base);
19727
+ const result2 = {};
19728
+ bases.set(base, result2);
19729
+ pending.push({ base, source, result: result2 });
19730
+ return result2;
19731
+ }
19732
+ const result = utils_default.isUndefined(b) ? copy(void 0, a2) : copy(a2, b);
19733
+ while (pending.length) {
19734
+ const { base, source, result: target } = pending.pop();
19735
+ const baseKeys = new Set(ownEnumerableKeys(base));
19736
+ const sourceKeys = new Set(ownEnumerableKeys(source));
19737
+ const keys = /* @__PURE__ */ new Set([...baseKeys, ...sourceKeys]);
19738
+ keys.forEach((key) => {
19739
+ if (key === "__proto__" || key === "constructor" || key === "prototype") return;
19740
+ const hasSource = sourceKeys.has(key);
19741
+ const value = hasSource ? source[key] : void 0;
19742
+ const previous = (!hasSource || utils_default.isPlainObject(value)) && baseKeys.has(key) ? base[key] : void 0;
19743
+ target[key] = hasSource ? copy(previous, value) : copy(void 0, previous);
19744
+ });
19521
19745
  }
19522
- function mergeDeepProperties(a2, b, prop, caseless) {
19523
- if (!utils_default.isUndefined(b)) {
19524
- return getMergedValue(a2, b, prop, caseless);
19525
- } else if (!utils_default.isUndefined(a2)) {
19526
- return getMergedValue(void 0, a2, prop, caseless);
19527
- }
19746
+ assertParamsAcyclic(result);
19747
+ return result;
19748
+ }
19749
+ function getMergedValue(target, source, prop, caseless) {
19750
+ if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
19751
+ return utils_default.merge.call({ caseless }, target, source);
19752
+ } else if (utils_default.isPlainObject(source)) {
19753
+ return utils_default.merge({}, source);
19754
+ } else if (utils_default.isArray(source)) {
19755
+ return source.slice();
19756
+ }
19757
+ return source;
19758
+ }
19759
+ function mergeDeepProperties(a2, b, prop, caseless) {
19760
+ if (!utils_default.isUndefined(b)) {
19761
+ return getMergedValue(a2, b, prop, caseless);
19762
+ } else if (!utils_default.isUndefined(a2)) {
19763
+ return getMergedValue(void 0, a2, prop, caseless);
19528
19764
  }
19529
- function valueFromConfig2(a2, b) {
19530
- if (!utils_default.isUndefined(b)) {
19531
- return getMergedValue(void 0, b);
19532
- }
19765
+ }
19766
+ function valueFromConfig2(a2, b) {
19767
+ if (!utils_default.isUndefined(b)) {
19768
+ return getMergedValue(void 0, b);
19533
19769
  }
19534
- function defaultToConfig2(a2, b) {
19535
- if (!utils_default.isUndefined(b)) {
19536
- return getMergedValue(void 0, b);
19537
- } else if (!utils_default.isUndefined(a2)) {
19538
- return getMergedValue(void 0, a2);
19539
- }
19770
+ }
19771
+ function defaultToConfig2(a2, b) {
19772
+ if (!utils_default.isUndefined(b)) {
19773
+ return getMergedValue(void 0, b);
19774
+ } else if (!utils_default.isUndefined(a2)) {
19775
+ return getMergedValue(void 0, a2);
19540
19776
  }
19541
- function getMergedTransitionalOption(prop) {
19542
- const transitional2 = utils_default.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
19543
- if (!utils_default.isUndefined(transitional2)) {
19544
- if (utils_default.isPlainObject(transitional2)) {
19545
- if (utils_default.hasOwnProp(transitional2, prop)) {
19546
- return transitional2[prop];
19547
- }
19548
- } else {
19549
- return void 0;
19777
+ }
19778
+ function getMergedTransitionalOption(config1, config2, prop) {
19779
+ const transitional2 = utils_default.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
19780
+ if (!utils_default.isUndefined(transitional2)) {
19781
+ if (utils_default.isPlainObject(transitional2)) {
19782
+ if (utils_default.hasOwnProp(transitional2, prop)) {
19783
+ return transitional2[prop];
19550
19784
  }
19785
+ } else {
19786
+ return void 0;
19551
19787
  }
19552
- const transitional1 = utils_default.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
19553
- if (utils_default.isPlainObject(transitional1) && utils_default.hasOwnProp(transitional1, prop)) {
19554
- return transitional1[prop];
19555
- }
19556
- return void 0;
19557
19788
  }
19558
- function mergeDirectKeys(a2, b, prop) {
19559
- if (utils_default.hasOwnProp(config2, prop)) {
19560
- return getMergedValue(a2, b);
19561
- } else if (utils_default.hasOwnProp(config1, prop)) {
19562
- return getMergedValue(void 0, a2);
19563
- }
19564
- }
19565
- const mergeMap = {
19566
- url: valueFromConfig2,
19567
- method: valueFromConfig2,
19568
- data: valueFromConfig2,
19569
- baseURL: defaultToConfig2,
19570
- transformRequest: defaultToConfig2,
19571
- transformResponse: defaultToConfig2,
19572
- paramsSerializer: defaultToConfig2,
19573
- timeout: defaultToConfig2,
19574
- timeoutErrorMessage: defaultToConfig2,
19575
- withCredentials: defaultToConfig2,
19576
- withXSRFToken: defaultToConfig2,
19577
- adapter: defaultToConfig2,
19578
- responseType: defaultToConfig2,
19579
- xsrfCookieName: defaultToConfig2,
19580
- xsrfHeaderName: defaultToConfig2,
19581
- onUploadProgress: defaultToConfig2,
19582
- onDownloadProgress: defaultToConfig2,
19583
- decompress: defaultToConfig2,
19584
- maxContentLength: defaultToConfig2,
19585
- maxBodyLength: defaultToConfig2,
19586
- beforeRedirect: defaultToConfig2,
19587
- transport: defaultToConfig2,
19588
- httpAgent: defaultToConfig2,
19589
- httpsAgent: defaultToConfig2,
19590
- cancelToken: defaultToConfig2,
19591
- socketPath: defaultToConfig2,
19592
- allowedSocketPaths: defaultToConfig2,
19593
- responseEncoding: defaultToConfig2,
19594
- validateStatus: mergeDirectKeys,
19595
- headers: (a2, b, prop) => mergeDeepProperties(headersToObject(a2), headersToObject(b), prop, true)
19596
- };
19597
- utils_default.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
19598
- if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
19789
+ const transitional1 = utils_default.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
19790
+ if (utils_default.isPlainObject(transitional1) && utils_default.hasOwnProp(transitional1, prop)) {
19791
+ return transitional1[prop];
19792
+ }
19793
+ return void 0;
19794
+ }
19795
+ function mergeDirectKeys(a2, b, prop, config1, config2) {
19796
+ if (utils_default.hasOwnProp(config2, prop)) {
19797
+ return getMergedValue(a2, b);
19798
+ } else if (utils_default.hasOwnProp(config1, prop)) {
19799
+ return getMergedValue(void 0, a2);
19800
+ }
19801
+ }
19802
+ function mergeHeaders(a2, b, prop) {
19803
+ return mergeDeepProperties(headersToObject(a2), headersToObject(b), prop, true);
19804
+ }
19805
+ var hasOwnPropertyDescriptor = Object.freeze({
19806
+ __proto__: null,
19807
+ value: Object.prototype.hasOwnProperty,
19808
+ enumerable: false,
19809
+ writable: true,
19810
+ configurable: true
19811
+ });
19812
+ var mergeMap = {
19813
+ url: valueFromConfig2,
19814
+ method: valueFromConfig2,
19815
+ data: valueFromConfig2,
19816
+ baseURL: defaultToConfig2,
19817
+ transformRequest: defaultToConfig2,
19818
+ transformResponse: defaultToConfig2,
19819
+ params: mergeParams,
19820
+ paramsSerializer: defaultToConfig2,
19821
+ timeout: defaultToConfig2,
19822
+ timeoutErrorMessage: defaultToConfig2,
19823
+ withCredentials: defaultToConfig2,
19824
+ withXSRFToken: defaultToConfig2,
19825
+ adapter: defaultToConfig2,
19826
+ responseType: defaultToConfig2,
19827
+ xsrfCookieName: defaultToConfig2,
19828
+ xsrfHeaderName: defaultToConfig2,
19829
+ onUploadProgress: defaultToConfig2,
19830
+ onDownloadProgress: defaultToConfig2,
19831
+ decompress: defaultToConfig2,
19832
+ maxContentLength: defaultToConfig2,
19833
+ maxBodyLength: defaultToConfig2,
19834
+ beforeRedirect: defaultToConfig2,
19835
+ transport: defaultToConfig2,
19836
+ httpAgent: defaultToConfig2,
19837
+ httpsAgent: defaultToConfig2,
19838
+ cancelToken: defaultToConfig2,
19839
+ socketPath: defaultToConfig2,
19840
+ allowedSocketPaths: defaultToConfig2,
19841
+ responseEncoding: defaultToConfig2,
19842
+ validateStatus: mergeDirectKeys,
19843
+ headers: mergeHeaders
19844
+ };
19845
+ function mergeConfig(config1, config2) {
19846
+ config1 = config1 || {};
19847
+ config2 = config2 || {};
19848
+ const config = /* @__PURE__ */ Object.create(null);
19849
+ Object.defineProperty(config, "hasOwnProperty", hasOwnPropertyDescriptor);
19850
+ const keys = ownEnumerableKeys({ ...config1, ...config2 });
19851
+ for (let i2 = 0, len = keys.length; i2 < len; i2++) {
19852
+ const prop = keys[i2];
19853
+ if (prop === "__proto__" || prop === "constructor" || prop === "prototype") continue;
19599
19854
  const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
19600
19855
  const a2 = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
19601
19856
  const b = utils_default.hasOwnProp(config2, prop) ? config2[prop] : void 0;
19602
- const configValue = merge2(a2, b, prop);
19857
+ const configValue = merge2 === mergeDirectKeys ? merge2(a2, b, prop, config1, config2) : merge2(a2, b, prop);
19603
19858
  utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
19604
- });
19605
- if (utils_default.hasOwnProp(config2, "validateStatus") && utils_default.isUndefined(config2.validateStatus) && getMergedTransitionalOption("validateStatusUndefinedResolves") === false) {
19859
+ }
19860
+ if (utils_default.hasOwnProp(config2, "validateStatus") && utils_default.isUndefined(config2.validateStatus) && getMergedTransitionalOption(config1, config2, "validateStatusUndefinedResolves") === false) {
19606
19861
  if (utils_default.hasOwnProp(config1, "validateStatus")) {
19607
19862
  config.validateStatus = getMergedValue(void 0, config1.validateStatus);
19608
19863
  } else {
@@ -19617,7 +19872,8 @@ var encodeUTF8 = (str) => encodeURIComponent(str).replace(
19617
19872
  /%([0-9A-F]{2})/gi,
19618
19873
  (_, hex) => String.fromCharCode(parseInt(hex, 16))
19619
19874
  );
19620
- function resolveConfig(config) {
19875
+ var readCookie = (name) => cookies_default.read(name);
19876
+ function resolveConfig(config, readXsrfCookie = readCookie) {
19621
19877
  const newConfig = mergeConfig({}, config);
19622
19878
  const own2 = (key) => utils_default.hasOwnProp(newConfig, key) ? newConfig[key] : void 0;
19623
19879
  const data = own2("data");
@@ -19638,10 +19894,15 @@ function resolveConfig(config) {
19638
19894
  if (auth) {
19639
19895
  const username = utils_default.getSafeProp(auth, "username") || "";
19640
19896
  const password2 = utils_default.getSafeProp(auth, "password") || "";
19897
+ const transitional2 = own2("transitional");
19898
+ const encodeUsername = transitional2 && utils_default.hasOwnProp(transitional2, "encodeBasicAuthUsername") && transitional2.encodeBasicAuthUsername === true;
19641
19899
  try {
19642
19900
  headers.set(
19643
19901
  "Authorization",
19644
- "Basic " + btoa(username + ":" + (password2 ? encodeUTF8(password2) : ""))
19902
+ // Preserve legacy username bytes unless the caller opts in to UTF-8.
19903
+ "Basic " + btoa(
19904
+ (encodeUsername ? encodeUTF8(username) : username) + ":" + (password2 ? encodeUTF8(password2) : "")
19905
+ )
19645
19906
  );
19646
19907
  } catch (e) {
19647
19908
  throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_OPTION_VALUE, config);
@@ -19661,7 +19922,7 @@ function resolveConfig(config) {
19661
19922
  }
19662
19923
  const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin_default(newConfig.url);
19663
19924
  if (shouldSendXSRF) {
19664
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
19925
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && readXsrfCookie(xsrfCookieName);
19665
19926
  if (xsrfValue) {
19666
19927
  headers.set(xsrfHeaderName, xsrfValue);
19667
19928
  }
@@ -19675,16 +19936,50 @@ var resolveConfig_default = resolveConfig;
19675
19936
  var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
19676
19937
  var xhr_default = isXHRAdapterSupported && function(config) {
19677
19938
  return new Promise(function dispatchXhrRequest(resolve, reject) {
19678
- const _config = resolveConfig_default(config);
19939
+ let useAsyncXsrf;
19940
+ try {
19941
+ const store = platform_default.hasStandardBrowserEnv && typeof window !== "undefined" && window.cookieStore;
19942
+ useAsyncXsrf = store && utils_default.isFunction(store.get);
19943
+ } catch (e) {
19944
+ }
19945
+ let xsrfCookieName;
19946
+ const _config = resolveConfig_default(
19947
+ config,
19948
+ useAsyncXsrf ? (name) => {
19949
+ xsrfCookieName = name;
19950
+ return null;
19951
+ } : void 0
19952
+ );
19679
19953
  let requestData = _config.data;
19680
19954
  const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
19681
19955
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
19682
19956
  let onCanceled;
19957
+ let timeoutId;
19683
19958
  let uploadThrottled, downloadThrottled;
19684
19959
  let flushUpload, flushDownload, flushDownloadWithEvent;
19685
19960
  function done() {
19686
- flushUpload && flushUpload();
19687
- flushDownload && flushDownload();
19961
+ clearTimeout(timeoutId);
19962
+ try {
19963
+ flushUpload && flushUpload();
19964
+ } catch (err) {
19965
+ setTimeout(() => {
19966
+ throw err;
19967
+ });
19968
+ }
19969
+ try {
19970
+ flushDownload && flushDownload();
19971
+ } catch (err) {
19972
+ setTimeout(() => {
19973
+ throw err;
19974
+ });
19975
+ }
19976
+ if (request) {
19977
+ downloadThrottled && request.removeEventListener("progress", downloadThrottled);
19978
+ if (request.upload) {
19979
+ uploadThrottled && request.upload.removeEventListener("progress", uploadThrottled);
19980
+ flushUpload && request.upload.removeEventListener("loadend", flushUpload);
19981
+ }
19982
+ }
19688
19983
  _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
19689
19984
  _config.signal && _config.signal.removeEventListener("abort", onCanceled);
19690
19985
  }
@@ -19770,6 +20065,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19770
20065
  request = null;
19771
20066
  };
19772
20067
  request.ontimeout = function handleTimeout() {
20068
+ if (!request) return;
19773
20069
  let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
19774
20070
  const transitional2 = _config.transitional || transitional_default;
19775
20071
  if (_config.timeoutErrorMessage) {
@@ -19787,11 +20083,6 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19787
20083
  request = null;
19788
20084
  };
19789
20085
  requestData === void 0 && requestHeaders.setContentType(null);
19790
- if ("setRequestHeader" in request) {
19791
- utils_default.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
19792
- request.setRequestHeader(key, val);
19793
- });
19794
- }
19795
20086
  if (!utils_default.isUndefined(_config.withCredentials)) {
19796
20087
  request.withCredentials = !!_config.withCredentials;
19797
20088
  }
@@ -19816,15 +20107,18 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19816
20107
  return;
19817
20108
  }
19818
20109
  reject(!cancel2 || cancel2.type ? new CanceledError_default(null, config, request) : cancel2);
19819
- request.abort();
20110
+ const xhr = request;
19820
20111
  done();
19821
20112
  request = null;
20113
+ xhr.abort();
19822
20114
  };
19823
20115
  _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
20116
+ if (!request) return;
19824
20117
  if (_config.signal) {
19825
20118
  _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
19826
20119
  }
19827
20120
  }
20121
+ if (!request) return;
19828
20122
  const protocol = parseProtocol(_config.url);
19829
20123
  if (protocol && !platform_default.protocols.includes(protocol)) {
19830
20124
  reject(
@@ -19837,7 +20131,58 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19837
20131
  done();
19838
20132
  return;
19839
20133
  }
19840
- request.send(requestData || null);
20134
+ const sendRequest = () => {
20135
+ if (!request) return;
20136
+ if ("setRequestHeader" in request) {
20137
+ utils_default.forEach(
20138
+ toByteStringHeaderObject(requestHeaders),
20139
+ function setRequestHeader(val, key) {
20140
+ request.setRequestHeader(key, val);
20141
+ }
20142
+ );
20143
+ }
20144
+ request.send(requestData || null);
20145
+ };
20146
+ if (xsrfCookieName) {
20147
+ const now = typeof performance !== "undefined" && utils_default.isFunction(performance.now) ? () => performance.now() : Date.now;
20148
+ const deadline = request.timeout > 0 ? now() + Number(request.timeout) : void 0;
20149
+ const abortOnTimeout = () => {
20150
+ if (!request) return;
20151
+ const xhr = request;
20152
+ xhr.ontimeout();
20153
+ xhr.abort();
20154
+ };
20155
+ if (deadline !== void 0) {
20156
+ const scheduleTimeout = () => {
20157
+ const remaining = deadline - now();
20158
+ if (remaining > 0) {
20159
+ timeoutId = setTimeout(scheduleTimeout, Math.min(remaining, 2147483647));
20160
+ } else {
20161
+ abortOnTimeout();
20162
+ }
20163
+ };
20164
+ scheduleTimeout();
20165
+ }
20166
+ cookies_default.readAsync(xsrfCookieName).then((value) => {
20167
+ if (!request) return;
20168
+ if (deadline !== void 0 && now() >= deadline) {
20169
+ abortOnTimeout();
20170
+ return;
20171
+ }
20172
+ if (value) {
20173
+ const headerName = utils_default.hasOwnProp(_config, "xsrfHeaderName") && _config.xsrfHeaderName;
20174
+ requestHeaders.set(headerName, value);
20175
+ }
20176
+ sendRequest();
20177
+ }).catch((error) => {
20178
+ if (!request) return;
20179
+ reject(AxiosError_default.from(error, null, config, request));
20180
+ done();
20181
+ request = null;
20182
+ });
20183
+ } else {
20184
+ sendRequest();
20185
+ }
19841
20186
  });
19842
20187
  };
19843
20188
 
@@ -19870,7 +20215,8 @@ var composeSignals = (signals, timeout) => {
19870
20215
  timer && clearTimeout(timer);
19871
20216
  timer = null;
19872
20217
  signals.forEach((signal2) => {
19873
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
20218
+ const unsubscribeSignal = utils_default.getSafeProp(signal2, "unsubscribe");
20219
+ utils_default.isFunction(unsubscribeSignal) ? unsubscribeSignal.call(signal2, onabort) : signal2.removeEventListener("abort", onabort);
19874
20220
  });
19875
20221
  signals = null;
19876
20222
  };
@@ -19970,6 +20316,110 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
19970
20316
  );
19971
20317
  };
19972
20318
 
20319
+ // node_modules/axios/lib/helpers/formDataToBlob.js
20320
+ var CRLF2 = "\r\n";
20321
+ var normalizeLines = (value) => String(value).replace(/\r\n|\r|\n/g, CRLF2);
20322
+ var escapeName = (value) => String(value).replace(
20323
+ /[\r\n"]/g,
20324
+ (char) => char === "\r" ? "%0D" : char === "\n" ? "%0A" : "%22"
20325
+ );
20326
+ var stringBytes = (value, normalize) => {
20327
+ let length = 0;
20328
+ for (let i2 = 0; i2 < value.length; i2++) {
20329
+ const code = value.charCodeAt(i2);
20330
+ if (normalize && (code === 13 || code === 10)) {
20331
+ if (code === 13 && value.charCodeAt(i2 + 1) === 10) i2++;
20332
+ length += 2;
20333
+ } else if (code < 128) {
20334
+ length++;
20335
+ } else if (code < 2048) {
20336
+ length += 2;
20337
+ } else if (code >= 55296 && code <= 56319 && value.charCodeAt(i2 + 1) >= 56320 && value.charCodeAt(i2 + 1) <= 57343) {
20338
+ length += 4;
20339
+ i2++;
20340
+ } else {
20341
+ length += 3;
20342
+ }
20343
+ }
20344
+ return length;
20345
+ };
20346
+ var FormDataError = class extends TypeError {
20347
+ constructor(message, reason) {
20348
+ super(message);
20349
+ this.name = "FormDataError";
20350
+ this.reason = reason;
20351
+ }
20352
+ };
20353
+ function formDataToBlob(form, Blob2, limit, limitError, boundary) {
20354
+ if (!utils_default.isFunction(Blob2)) {
20355
+ throw new FormDataError("Blob is not supported", "blob");
20356
+ }
20357
+ if (!utils_default.isString(boundary) || !/^[A-Za-z0-9'()+_,./:=? -]{1,70}$/.test(boundary) || / $/.test(boundary)) {
20358
+ throw new FormDataError("Invalid multipart boundary", "boundary");
20359
+ }
20360
+ const footer = "--" + boundary + "--" + CRLF2;
20361
+ let length = footer.length;
20362
+ const parts = [];
20363
+ const checkLength = (extra) => {
20364
+ if (length + extra > limit) throw limitError();
20365
+ };
20366
+ checkLength(0);
20367
+ for (const [name, value] of form) {
20368
+ const isString2 = utils_default.isString(value);
20369
+ const valueLength = isString2 ? stringBytes(value, true) : value.size;
20370
+ if (!Number.isFinite(valueLength) || valueLength < 0) {
20371
+ throw new FormDataError("Unsupported FormData part size", "part");
20372
+ }
20373
+ checkLength(
20374
+ valueLength + stringBytes(name, true) + (!isString2 && value.name ? stringBytes(value.name, false) : 0) + (!isString2 && value.type ? stringBytes(value.type, false) : 0)
20375
+ );
20376
+ let header = "--" + boundary + CRLF2 + 'Content-Disposition: form-data; name="' + escapeName(normalizeLines(name)) + '"';
20377
+ if (!isString2) {
20378
+ header += '; filename="' + escapeName(utils_default.isString(value.name) ? value.name : "blob") + '"' + CRLF2 + "Content-Type: " + String(value.type || "application/octet-stream").replace(/[\r\n]/g, "");
20379
+ }
20380
+ header += CRLF2 + CRLF2;
20381
+ const partLength = stringBytes(header, false) + valueLength + CRLF2.length;
20382
+ checkLength(partLength);
20383
+ length += partLength;
20384
+ parts.push({ header, value, isString: isString2 });
20385
+ }
20386
+ const blobParts = [];
20387
+ for (const part of parts) {
20388
+ blobParts.push(part.header, part.isString ? normalizeLines(part.value) : part.value, CRLF2);
20389
+ }
20390
+ blobParts.push(footer);
20391
+ return new Blob2(blobParts, { type: "multipart/form-data; boundary=" + boundary });
20392
+ }
20393
+
20394
+ // node_modules/axios/lib/core/createMultipartBody.js
20395
+ function createMultipartBody(form, Blob2, limit, limitError, boundary) {
20396
+ if (!utils_default.isFunction(Blob2)) {
20397
+ throw new AxiosError_default("Blob is not supported", AxiosError_default.ERR_NOT_SUPPORT);
20398
+ }
20399
+ if (boundary === void 0) {
20400
+ if (utils_default.isFunction(platform_default.generateString)) {
20401
+ boundary = "axios-" + platform_default.generateString(36, "0123456789abcdef");
20402
+ } else {
20403
+ const crypto2 = utils_default.global.crypto;
20404
+ if (!crypto2 || !utils_default.isFunction(crypto2.getRandomValues)) {
20405
+ throw new AxiosError_default("Random byte generation is not supported", AxiosError_default.ERR_NOT_SUPPORT);
20406
+ }
20407
+ const random = new Uint8Array(18);
20408
+ crypto2.getRandomValues(random);
20409
+ boundary = "axios-" + Array.from(random, (value) => ("0" + value.toString(16)).slice(-2)).join("");
20410
+ }
20411
+ }
20412
+ try {
20413
+ return formDataToBlob(form, Blob2, limit, limitError, boundary);
20414
+ } catch (error) {
20415
+ if (error instanceof FormDataError) {
20416
+ const code = error.reason === "boundary" ? AxiosError_default.ERR_BAD_OPTION_VALUE : AxiosError_default.ERR_BAD_REQUEST;
20417
+ throw new AxiosError_default(error.message, code);
20418
+ }
20419
+ throw error;
20420
+ }
20421
+ }
20422
+
19973
20423
  // node_modules/axios/lib/adapters/fetch.js
19974
20424
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
19975
20425
  var DEFAULT_REQUEST_OPTIONS = {
@@ -20022,11 +20472,13 @@ var factory = (env) => {
20022
20472
  },
20023
20473
  {
20024
20474
  Request: globalObject.Request,
20025
- Response: globalObject.Response
20475
+ Response: globalObject.Response,
20476
+ Blob: globalObject.Blob
20026
20477
  },
20027
20478
  env
20028
20479
  );
20029
- const { fetch: envFetch, Request, Response } = env;
20480
+ const envFetch = utils_default.hasOwnProp(env, "fetch") ? env.fetch : void 0;
20481
+ const { Request, Response, Blob: Blob2 } = env;
20030
20482
  const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
20031
20483
  const isRequestSupported = isFunction2(Request);
20032
20484
  const isResponseSupported = isFunction2(Response);
@@ -20052,6 +20504,13 @@ var factory = (env) => {
20052
20504
  return duplexAccessed && !hasContentType;
20053
20505
  });
20054
20506
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
20507
+ const requestDefaults = Object.assign(/* @__PURE__ */ Object.create(null), DEFAULT_REQUEST_OPTIONS);
20508
+ if (isRequestSupported && !test(() => new Request(platform_default.origin, requestDefaults))) {
20509
+ delete requestDefaults.cache;
20510
+ if (!test(() => new Request(platform_default.origin, requestDefaults))) {
20511
+ requestDefaults.cache = DEFAULT_REQUEST_OPTIONS.cache;
20512
+ }
20513
+ }
20055
20514
  const resolvers = {
20056
20515
  stream: supportsResponseStream && ((res) => res.body)
20057
20516
  };
@@ -20077,13 +20536,6 @@ var factory = (env) => {
20077
20536
  if (utils_default.isBlob(body)) {
20078
20537
  return body.size;
20079
20538
  }
20080
- if (utils_default.isSpecCompliantForm(body)) {
20081
- const _request = new Request(platform_default.origin, {
20082
- method: "POST",
20083
- body
20084
- });
20085
- return (await _request.arrayBuffer()).byteLength;
20086
- }
20087
20539
  if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
20088
20540
  return body.byteLength;
20089
20541
  }
@@ -20131,6 +20583,7 @@ var factory = (env) => {
20131
20583
  });
20132
20584
  let requestContentLength;
20133
20585
  let pendingBodyError = null;
20586
+ let pendingResponseError = null;
20134
20587
  const maxBodyLengthError = () => new AxiosError_default(
20135
20588
  "Request body larger than maxBodyLength limit",
20136
20589
  AxiosError_default.ERR_BAD_REQUEST,
@@ -20148,8 +20601,9 @@ var factory = (env) => {
20148
20601
  password: password2
20149
20602
  };
20150
20603
  }
20604
+ let parsedURL;
20151
20605
  if (maybeWithAuthCredentials(url2)) {
20152
- const parsedURL = new URL(url2, platform_default.origin);
20606
+ parsedURL = new URL(url2, platform_default.origin);
20153
20607
  if (!auth && (parsedURL.username || parsedURL.password)) {
20154
20608
  const urlUsername = decodeURIComponentSafe2(parsedURL.username);
20155
20609
  const urlPassword = decodeURIComponentSafe2(parsedURL.password);
@@ -20171,8 +20625,8 @@ var factory = (env) => {
20171
20625
  "Basic " + btoa(encodeUTF82((auth.username || "") + ":" + (auth.password || "")))
20172
20626
  );
20173
20627
  }
20174
- if (hasMaxContentLength && typeof url2 === "string" && url2.startsWith("data:")) {
20175
- const estimated = estimateDataURLDecodedBytes(url2);
20628
+ if (hasMaxContentLength && parsedURL && parsedURL.protocol === "data:") {
20629
+ const estimated = estimateDataURLDecodedBytes(parsedURL.href);
20176
20630
  if (estimated > maxContentLength) {
20177
20631
  throw new AxiosError_default(
20178
20632
  "maxContentLength size of " + maxContentLength + " exceeded",
@@ -20182,6 +20636,23 @@ var factory = (env) => {
20182
20636
  );
20183
20637
  }
20184
20638
  }
20639
+ const formContentType = utils_default.isSpecCompliantForm(data) && AxiosHeaders_default.from(own2("headers")).getContentType();
20640
+ let formBoundary;
20641
+ if (utils_default.isString(formContentType) && /^multipart\/form-data(?:\s*;|$)/i.test(formContentType.trim())) {
20642
+ const parameters = AxiosHeaders_default.parseParameters(formContentType);
20643
+ if (utils_default.hasOwnProp(parameters, "boundary")) formBoundary = parameters.boundary;
20644
+ }
20645
+ if (utils_default.isSpecCompliantForm(data) && method !== "get" && method !== "head" && (hasMaxBodyLength || onUploadProgress && supportsRequestStream || formBoundary !== void 0)) {
20646
+ data = createMultipartBody(
20647
+ data,
20648
+ Blob2,
20649
+ hasMaxBodyLength ? maxBodyLength : Infinity,
20650
+ maxBodyLengthError,
20651
+ formBoundary
20652
+ );
20653
+ headers.setContentType(formBoundary === void 0 ? data.type : formContentType);
20654
+ requestContentLength = data.size;
20655
+ }
20185
20656
  if (hasMaxBodyLength && method !== "get" && method !== "head") {
20186
20657
  const outboundLength = await getBodyLength(data);
20187
20658
  if (typeof outboundLength === "number" && isFinite(outboundLength)) {
@@ -20262,7 +20733,7 @@ var factory = (env) => {
20262
20733
  credentials: isCredentialsSupported ? withCredentials : void 0
20263
20734
  });
20264
20735
  if (isRequestSupported) {
20265
- utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
20736
+ utils_default.forEach(requestDefaults, (value, key) => {
20266
20737
  if (resolvedOptions[key] === void 0) {
20267
20738
  resolvedOptions[key] = value;
20268
20739
  }
@@ -20310,7 +20781,7 @@ var factory = (env) => {
20310
20781
  if (hasMaxContentLength) {
20311
20782
  bytesRead = loadedBytes;
20312
20783
  if (bytesRead > maxContentLength) {
20313
- throw new AxiosError_default(
20784
+ throw pendingResponseError = new AxiosError_default(
20314
20785
  "maxContentLength size of " + maxContentLength + " exceeded",
20315
20786
  AxiosError_default.ERR_BAD_RESPONSE,
20316
20787
  config,
@@ -20385,6 +20856,9 @@ var factory = (env) => {
20385
20856
  request && !pendingBodyError.request && (pendingBodyError.request = request);
20386
20857
  throw pendingBodyError;
20387
20858
  }
20859
+ if (pendingResponseError) {
20860
+ throw pendingResponseError;
20861
+ }
20388
20862
  if (err instanceof AxiosError_default) {
20389
20863
  request && !err.request && (err.request = request);
20390
20864
  throw err;
@@ -20412,9 +20886,15 @@ var factory = (env) => {
20412
20886
  };
20413
20887
  var seedCache = /* @__PURE__ */ new Map();
20414
20888
  var getFetch = (config) => {
20415
- let env = config && config.env || {};
20416
- const { fetch: fetch2, Request, Response } = env;
20417
- const seeds = [Request, Response, fetch2];
20889
+ const env = /* @__PURE__ */ Object.create(null);
20890
+ const configuredEnv = config && utils_default.hasOwnProp(config, "env") && config.env;
20891
+ ["fetch", "Request", "Response", "Blob"].forEach((key) => {
20892
+ if (configuredEnv && utils_default.hasOwnProp(configuredEnv, key)) {
20893
+ env[key] = configuredEnv[key];
20894
+ }
20895
+ });
20896
+ const { fetch: fetch2, Request, Response, Blob: Blob2 } = env;
20897
+ const seeds = [Request, Response, fetch2, Blob2];
20418
20898
  let len = seeds.length, i2 = len, seed, target, map = seedCache;
20419
20899
  while (i2--) {
20420
20900
  seed = seeds[i2];
@@ -20500,6 +20980,9 @@ function throwIfCancellationRequested(config) {
20500
20980
  throw new CanceledError_default(null, config);
20501
20981
  }
20502
20982
  }
20983
+ function elapsedSince(start) {
20984
+ return Math.max(0, Date.now() - start);
20985
+ }
20503
20986
  function dispatchRequest(_config) {
20504
20987
  const config = utils_default.toSafeFlatObject(_config);
20505
20988
  throwIfCancellationRequested(config);
@@ -20509,9 +20992,11 @@ function dispatchRequest(_config) {
20509
20992
  config.headers.setContentType("application/x-www-form-urlencoded", false);
20510
20993
  }
20511
20994
  const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
20995
+ const start = Date.now();
20512
20996
  return adapter2(config).then(
20513
20997
  function onAdapterResolution(response) {
20514
20998
  throwIfCancellationRequested(config);
20999
+ response.duration = elapsedSince(start);
20515
21000
  config.response = response;
20516
21001
  try {
20517
21002
  response.data = transformData.call(config, config.transformResponse, response);
@@ -20525,6 +21010,7 @@ function dispatchRequest(_config) {
20525
21010
  if (!isCancel(reason)) {
20526
21011
  throwIfCancellationRequested(config);
20527
21012
  if (reason && reason.response) {
21013
+ reason.response.duration = elapsedSince(start);
20528
21014
  config.response = reason.response;
20529
21015
  try {
20530
21016
  reason.response.data = transformData.call(
@@ -20612,6 +21098,27 @@ var validator_default = {
20612
21098
 
20613
21099
  // node_modules/axios/lib/core/Axios.js
20614
21100
  var validators2 = validator_default.validators;
21101
+ var isHeadersBucket = (value) => {
21102
+ if (value == null || utils_default.isPlainObject(value) || value instanceof AxiosHeaders_default) {
21103
+ return true;
21104
+ }
21105
+ try {
21106
+ return utils_default.isObject(value) && utils_default.getSafeProp(value, Symbol.toStringTag) === "AxiosHeaders" && [
21107
+ "toJSON",
21108
+ "set",
21109
+ "get",
21110
+ "has",
21111
+ "delete",
21112
+ "clear",
21113
+ "normalize",
21114
+ "concat",
21115
+ "toString",
21116
+ Symbol.iterator
21117
+ ].every((method) => utils_default.isFunction(utils_default.getSafeProp(value, method)));
21118
+ } catch (e) {
21119
+ return false;
21120
+ }
21121
+ };
20615
21122
  var Axios = class {
20616
21123
  constructor(instanceConfig) {
20617
21124
  this.defaults = instanceConfig || {};
@@ -20647,9 +21154,13 @@ var Axios = class {
20647
21154
  } else if (stack) {
20648
21155
  const firstNewlineIndex = stack.indexOf("\n");
20649
21156
  const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf("\n", firstNewlineIndex + 1);
20650
- const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? "" : stack.slice(secondNewlineIndex + 1);
20651
- if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
20652
- err.stack += "\n" + stack;
21157
+ const duplicateCheckSuffix = secondNewlineIndex === -1 ? stack : stack.slice(secondNewlineIndex + 1);
21158
+ const currentStack = String(err.stack);
21159
+ const causeIndex = getCauseStackIndex(err, currentStack);
21160
+ const stackHead = causeIndex === -1 ? currentStack : currentStack.slice(0, causeIndex);
21161
+ const causeSection = causeIndex === -1 ? "" : currentStack.slice(causeIndex);
21162
+ if (!stackHead.endsWith(duplicateCheckSuffix)) {
21163
+ err.stack = stackHead + "\n" + stack + causeSection;
20653
21164
  }
20654
21165
  }
20655
21166
  } catch (e) {
@@ -20676,7 +21187,8 @@ var Axios = class {
20676
21187
  clarifyTimeoutError: validators2.transitional(validators2.boolean),
20677
21188
  legacyInterceptorReqResOrdering: validators2.transitional(validators2.boolean),
20678
21189
  advertiseZstdAcceptEncoding: validators2.transitional(validators2.boolean),
20679
- validateStatusUndefinedResolves: validators2.transitional(validators2.boolean)
21190
+ validateStatusUndefinedResolves: validators2.transitional(validators2.boolean),
21191
+ encodeBasicAuthUsername: validators2.transitional(validators2.boolean)
20680
21192
  },
20681
21193
  false
20682
21194
  );
@@ -20698,7 +21210,7 @@ var Axios = class {
20698
21210
  }
20699
21211
  }
20700
21212
  if (config.allowAbsoluteUrls !== void 0) {
20701
- } else if (this.defaults.allowAbsoluteUrls !== void 0) {
21213
+ } else if (utils_default.hasOwnProp(this.defaults, "allowAbsoluteUrls") && this.defaults.allowAbsoluteUrls !== void 0) {
20702
21214
  config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
20703
21215
  } else {
20704
21216
  config.allowAbsoluteUrls = true;
@@ -20712,9 +21224,16 @@ var Axios = class {
20712
21224
  true
20713
21225
  );
20714
21226
  config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
20715
- let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
21227
+ const commonHeaders = utils_default.getSafeProp(headers, "common");
21228
+ const methodHeaders = utils_default.getSafeProp(headers, config.method);
21229
+ const contextHeaders = headers && utils_default.merge(
21230
+ isHeadersBucket(commonHeaders) ? commonHeaders : void 0,
21231
+ isHeadersBucket(methodHeaders) ? methodHeaders : void 0
21232
+ );
20716
21233
  headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
20717
- delete headers[method];
21234
+ if (isHeadersBucket(utils_default.getSafeProp(headers, method))) {
21235
+ delete headers[method];
21236
+ }
20718
21237
  });
20719
21238
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
20720
21239
  const requestInterceptorChain = [];
@@ -20796,7 +21315,7 @@ var Axios = class {
20796
21315
  }
20797
21316
  };
20798
21317
  utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
20799
- Axios.prototype[method] = function(url2, config) {
21318
+ Axios.prototype[method] = async function(url2, config) {
20800
21319
  return this.request(
20801
21320
  mergeConfig(config || {}, {
20802
21321
  method,
@@ -20808,7 +21327,7 @@ utils_default.forEach(["delete", "get", "head", "options"], function forEachMeth
20808
21327
  });
20809
21328
  utils_default.forEach(["post", "put", "patch", "query"], function forEachMethodWithData(method) {
20810
21329
  function generateHTTPMethod(isForm) {
20811
- return function httpMethod(url2, data, config) {
21330
+ return async function httpMethod(url2, data, config) {
20812
21331
  return this.request(
20813
21332
  mergeConfig(config || {}, {
20814
21333
  method,
@@ -20915,8 +21434,8 @@ var CancelToken = class _CancelToken {
20915
21434
  */
20916
21435
  static source() {
20917
21436
  let cancel2;
20918
- const token = new _CancelToken(function executor(c) {
20919
- cancel2 = c;
21437
+ const token = new _CancelToken(function executor(c2) {
21438
+ cancel2 = c2;
20920
21439
  });
20921
21440
  return {
20922
21441
  token,
@@ -21165,12 +21684,67 @@ var PartialWorkflowError = class extends AssinafyError {
21165
21684
  };
21166
21685
 
21167
21686
  // src/api/utils.ts
21168
- var DOCUMENT_ARTIFACT_NAMES = [
21169
- "original",
21170
- "certificated",
21171
- "certificate-page",
21172
- "pades",
21173
- "bundle"
21687
+ var import_node_http = require("http");
21688
+
21689
+ // src/api/types.ts
21690
+ var SIGNER_CAPACITIES = [
21691
+ "Sign",
21692
+ "Approve",
21693
+ "Acknowledge",
21694
+ "Party",
21695
+ "Witness",
21696
+ "Intervening",
21697
+ "Receipt",
21698
+ "IssuerEndorserGuarantor",
21699
+ "IssuerEndorserGuarantorSurety",
21700
+ "Surety",
21701
+ "PartySurety",
21702
+ "JointDebtor",
21703
+ "PartyJointDebtor",
21704
+ "ContractingParty",
21705
+ "ContractedParty",
21706
+ "Landlord",
21707
+ "Tenant",
21708
+ "Buyer",
21709
+ "Seller",
21710
+ "AttorneyInFact",
21711
+ "LegalRepresentative",
21712
+ "Employer",
21713
+ "Employee"
21714
+ ];
21715
+ var PUSH_PREFERENCE_CODES = [
21716
+ "SignerViewed",
21717
+ "SignerSigned",
21718
+ "DocumentCompleted",
21719
+ "SignerDeclined",
21720
+ "DocumentAboutToExpire",
21721
+ "DocumentExpired",
21722
+ "SignerIdentityReviewRequired",
21723
+ "SignerWhatsappFailed"
21724
+ ];
21725
+ var NOTIFICATION_PREFERENCE_CODES = [
21726
+ "DocumentCompleted",
21727
+ "SignerDeclined",
21728
+ "DocumentCancelled",
21729
+ "DocumentAboutToExpire",
21730
+ "DocumentExpired",
21731
+ "DocumentExpirationReset",
21732
+ "DocumentProcessingFailed",
21733
+ "TemplateProcessingFailed",
21734
+ "SignerWhatsappFailed",
21735
+ "ContractRenewalNotice",
21736
+ "ContractExpiring",
21737
+ "ContractExpired",
21738
+ "ContractRenewed"
21739
+ ];
21740
+
21741
+ // src/api/utils.ts
21742
+ var DOCUMENT_ARTIFACT_NAMES = [
21743
+ "original",
21744
+ "certificated",
21745
+ "certificate-page",
21746
+ "pades",
21747
+ "bundle"
21174
21748
  ];
21175
21749
  var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21176
21750
  var VERIFICATION_METHODS = [
@@ -21275,6 +21849,16 @@ function requireExpiration(value, name = "expires_at") {
21275
21849
  requireIso8601(timestamp, name);
21276
21850
  return value;
21277
21851
  }
21852
+ function requireScheduledTime(value, name = "send_at") {
21853
+ if (typeof value === "number") {
21854
+ if (!Number.isSafeInteger(value))
21855
+ throw new ValidationError(`${name} must be an integer Unix time`);
21856
+ } else if (typeof value === "string") {
21857
+ requireExpiration(value, name);
21858
+ } else {
21859
+ throw new ValidationError(`${name} must be an ISO 8601 time or integer Unix time`);
21860
+ }
21861
+ }
21278
21862
  function requireEmail(value) {
21279
21863
  if (!value || !EMAIL_RE.test(value)) {
21280
21864
  throw new ValidationError("Invalid email address", { email: value });
@@ -21282,6 +21866,15 @@ function requireEmail(value) {
21282
21866
  return value;
21283
21867
  }
21284
21868
  function validateSignerOptions(input) {
21869
+ if (input.sign_as != null && !SIGNER_CAPACITIES.includes(input.sign_as)) {
21870
+ throw new ValidationError("sign_as must be a published signer capacity or null");
21871
+ }
21872
+ if (input.embedded !== void 0 && typeof input.embedded !== "boolean") {
21873
+ throw new ValidationError("embedded must be a boolean");
21874
+ }
21875
+ if (input.embedded === true && input.verification_method !== void 0 && !["Email", "Whatsapp"].includes(input.verification_method)) {
21876
+ throw new ValidationError("Embedded signing requires Email or Whatsapp verification");
21877
+ }
21285
21878
  if (input.verification_method !== void 0 && !VERIFICATION_METHODS.includes(input.verification_method)) {
21286
21879
  throw new ValidationError(
21287
21880
  `verification_method must be one of: ${VERIFICATION_METHODS.join(", ")}`
@@ -21308,6 +21901,33 @@ function validateSignerOptions(input) {
21308
21901
  throw new ValidationError("step must be an integer");
21309
21902
  }
21310
21903
  }
21904
+ function validateCreditCeiling(value) {
21905
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || value < 0)) {
21906
+ throw new ValidationError("max_total_credits must be a finite non-negative number");
21907
+ }
21908
+ }
21909
+ function idempotencyHeaders(key) {
21910
+ if (key === void 0) return void 0;
21911
+ if (typeof key !== "string" || !key.trim()) {
21912
+ throw new ValidationError("idempotencyKey must be nonblank text");
21913
+ }
21914
+ try {
21915
+ (0, import_node_http.validateHeaderValue)("Idempotency-Key", key);
21916
+ } catch {
21917
+ throw new ValidationError("idempotencyKey must be a valid HTTP header value");
21918
+ }
21919
+ return { "Idempotency-Key": key };
21920
+ }
21921
+ function validateBooleanMap(payload, allowed) {
21922
+ if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length) {
21923
+ throw new ValidationError("At least one notification preference is required");
21924
+ }
21925
+ for (const [key, value] of Object.entries(payload)) {
21926
+ if (!allowed.includes(key))
21927
+ throw new ValidationError(`Unknown notification preference: ${key}`);
21928
+ if (typeof value !== "boolean") throw new ValidationError(`${key} must be a boolean`);
21929
+ }
21930
+ }
21311
21931
  function validateDigitalCertificateMethod(method, signers) {
21312
21932
  if (method !== "virtual" && signers.some((signer) => signer.verification_method === "DigitalCertificate")) {
21313
21933
  throw new ValidationError("DigitalCertificate signers require method: virtual", {
@@ -21447,7 +22067,7 @@ var BaseResource = class {
21447
22067
  }
21448
22068
  };
21449
22069
  function safeIdentifier(value, name) {
21450
- if (value === "." || value === ".." || /[\s/?#\\%]/.test(value)) {
22070
+ if (typeof value !== "string" || value === "." || value === ".." || /[\s/?#\\%]/.test(value)) {
21451
22071
  throw new ValidationError(`${name} contains invalid URL characters`);
21452
22072
  }
21453
22073
  return value;
@@ -21482,10 +22102,15 @@ function toInt(value) {
21482
22102
 
21483
22103
  // src/api/resources/assignments.ts
21484
22104
  function buildAssignmentPayload(payload, options = {}) {
22105
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
22106
+ throw new ValidationError("Assignment payload must be an object");
22107
+ }
21485
22108
  if (payload.method !== void 0 && payload.method !== "virtual" && payload.method !== "collect") {
21486
22109
  throw new ValidationError("method must be virtual or collect");
21487
22110
  }
21488
22111
  const signers = extractSignerRefs(payload);
22112
+ validateCreditCeiling(payload.max_total_credits);
22113
+ if (payload.expires_at != null) requireScheduledTime(payload.expires_at, "expires_at");
21489
22114
  if (signers.length === 0) {
21490
22115
  throw new ValidationError("At least one signer is required", {
21491
22116
  signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
@@ -21500,14 +22125,17 @@ function buildAssignmentPayload(payload, options = {}) {
21500
22125
  if (!options.skipDigitalCertificateStepValidation) {
21501
22126
  validateSigningSteps(normalisedSigners);
21502
22127
  }
21503
- return stripEmpty({
21504
- method,
21505
- signers: normalisedSigners,
21506
- message: payload.message,
21507
- expires_at: payload.expires_at === void 0 ? void 0 : requireExpiration(payload.expires_at),
21508
- copy_receivers: payload.copy_receivers,
21509
- entries: payload.entries
21510
- });
22128
+ return Object.fromEntries(
22129
+ Object.entries({
22130
+ method,
22131
+ signers: normalisedSigners,
22132
+ message: payload.message,
22133
+ expires_at: payload.expires_at,
22134
+ copy_receivers: payload.copy_receivers,
22135
+ entries: payload.entries,
22136
+ max_total_credits: payload.max_total_credits
22137
+ }).filter(([, value]) => value !== void 0)
22138
+ );
21511
22139
  }
21512
22140
  function extractSignerRefs(payload) {
21513
22141
  const populatedAliases = [payload.signers, payload.signer_ids, payload.signerIds].filter(
@@ -21524,20 +22152,24 @@ function extractSignerRefs(payload) {
21524
22152
  }
21525
22153
  function normaliseSignerRef(ref, options) {
21526
22154
  if (typeof ref === "string") {
21527
- if (!ref) throw new ValidationError("Signer ID cannot be empty");
22155
+ if (!ref.trim()) throw new ValidationError("Signer ID cannot be empty");
21528
22156
  return { id: ref };
21529
22157
  }
21530
22158
  if (ref && typeof ref === "object") {
21531
22159
  const input = ref;
21532
22160
  const id = input.id ?? input.signer_id;
21533
22161
  validateSignerOptions(input);
21534
- const normalised = stripEmpty({
21535
- id,
21536
- verification_method: input.verification_method,
21537
- notification_methods: input.notification_methods,
21538
- step: input.step
21539
- });
21540
- if (typeof id === "string" && id.length > 0) {
22162
+ const normalised = Object.fromEntries(
22163
+ Object.entries({
22164
+ id,
22165
+ sign_as: input.sign_as,
22166
+ verification_method: input.verification_method,
22167
+ notification_methods: input.notification_methods,
22168
+ step: input.step,
22169
+ embedded: input.embedded
22170
+ }).filter(([, value]) => value !== void 0)
22171
+ );
22172
+ if (typeof id === "string" && id.trim().length > 0) {
21541
22173
  return normalised;
21542
22174
  }
21543
22175
  if (options.allowSignersWithoutId && Object.keys(normalised).length > 0) {
@@ -21550,6 +22182,30 @@ function normaliseSignerRef(ref, options) {
21550
22182
  throw new ValidationError("Invalid signer reference", { ref });
21551
22183
  }
21552
22184
  var AssignmentResource = class extends BaseResource {
22185
+ /** Keep a request for later; no invitation or charge until the server sends it (staging). */
22186
+ async schedule(documentId, payload) {
22187
+ const id = this.requireId(documentId, "Document ID");
22188
+ requireScheduledTime(payload?.send_at);
22189
+ const body = { ...buildAssignmentPayload(payload), send_at: payload.send_at };
22190
+ return this.call(
22191
+ "Failed to schedule assignment",
22192
+ () => this.http.post(`/documents/${id}/scheduled-sends`, body)
22193
+ );
22194
+ }
22195
+ async signerCapacities(documentId) {
22196
+ const id = this.requireId(documentId, "Document ID");
22197
+ return this.call(
22198
+ "Failed to fetch signer capacities",
22199
+ () => this.http.get(`/documents/${id}/signer-capacities`)
22200
+ );
22201
+ }
22202
+ async notificationHistory(documentId) {
22203
+ const id = this.requireId(documentId, "Document ID");
22204
+ return this.call(
22205
+ "Failed to fetch notification history",
22206
+ () => this.http.get(`/documents/${id}/notification-history`)
22207
+ );
22208
+ }
21553
22209
  /** Fetch an account review and available evidence for a signer's identity verification. */
21554
22210
  async getIdentityVerification(documentId, assignmentId, signerId) {
21555
22211
  const docId = this.requireId(documentId, "Document ID");
@@ -21887,12 +22543,14 @@ var ContractResource = class extends BaseResource {
21887
22543
  );
21888
22544
  }
21889
22545
  /** Read the root contract and its amendments from any document in that family. */
21890
- async related(documentId, accountId) {
22546
+ async related(documentId, accountId, params = {}) {
21891
22547
  const id = this.accountId(accountId);
21892
22548
  const did = this.requireId(documentId, "Document ID");
21893
22549
  return this.call(
21894
22550
  "Failed to get related contracts",
21895
- () => this.http.get(`/accounts/${id}/documents/${did}/contract/related`)
22551
+ () => this.http.get(`/accounts/${id}/documents/${did}/contract/related`, {
22552
+ params: cleanParams(params)
22553
+ })
21896
22554
  );
21897
22555
  }
21898
22556
  /** Advance from the supplied current term or to a later end date. No automatic retry. */
@@ -22011,6 +22669,25 @@ var FAILED_STATUSES = /* @__PURE__ */ new Set([
22011
22669
  "expired"
22012
22670
  ]);
22013
22671
  var DocumentResource = class extends BaseResource {
22672
+ /** Read contacts who receive a completion email without document access (staging). */
22673
+ async listWatchers(documentId) {
22674
+ const id = this.requireId(documentId, "Document ID");
22675
+ return this.call(
22676
+ "Failed to list document watchers",
22677
+ () => this.http.get(`/documents/${id}/watchers`)
22678
+ );
22679
+ }
22680
+ /** Replace all watchers; an empty list clears them. Owner credentials required (staging). */
22681
+ async setWatchers(documentId, watcherIds) {
22682
+ const id = this.requireId(documentId, "Document ID");
22683
+ if (!Array.isArray(watcherIds) || new Set(watcherIds).size > 10 || watcherIds.some((value) => typeof value !== "string" || !value.trim())) {
22684
+ throw new ValidationError("watcher_ids must contain at most 10 nonblank contact IDs");
22685
+ }
22686
+ return this.call(
22687
+ "Failed to set document watchers",
22688
+ () => this.http.put(`/documents/${id}/watchers`, { watcher_ids: watcherIds })
22689
+ );
22690
+ }
22014
22691
  /**
22015
22692
  * Upload a PDF to the workspace.
22016
22693
  *
@@ -22073,9 +22750,9 @@ var DocumentResource = class extends BaseResource {
22073
22750
  );
22074
22751
  }
22075
22752
  /** Get document details. */
22076
- async details(documentId) {
22753
+ async details(documentId, params = {}) {
22077
22754
  const id = this.requireId(documentId, "Document ID");
22078
- return this.fetchDetails(id);
22755
+ return this.fetchDetails(id, void 0, params);
22079
22756
  }
22080
22757
  /**
22081
22758
  * Rename a document (`PATCH /documents/{id}`).
@@ -22092,8 +22769,17 @@ var DocumentResource = class extends BaseResource {
22092
22769
  );
22093
22770
  }
22094
22771
  /** Alias for {@link details}. */
22095
- async get(documentId) {
22096
- return this.details(documentId);
22772
+ async get(documentId, params = {}) {
22773
+ return this.details(documentId, params);
22774
+ }
22775
+ /** Read only the assignment items visible to this signer. */
22776
+ async getAsSigner(documentId, signerAccessCode) {
22777
+ const id = this.requireId(documentId, "Document ID");
22778
+ const code = this.requireId(signerAccessCode, "signer-access-code");
22779
+ return this.call(
22780
+ "Failed to fetch signer document",
22781
+ () => this.http.get(`/documents/${id}`, signerAccessConfig(code))
22782
+ );
22097
22783
  }
22098
22784
  /** Poll document status until ready (or a terminal status / timeout). */
22099
22785
  async waitUntilReady(documentId, options = {}) {
@@ -22140,42 +22826,57 @@ var DocumentResource = class extends BaseResource {
22140
22826
  attempts
22141
22827
  });
22142
22828
  }
22143
- fetchDetails(documentId, timeout) {
22829
+ fetchDetails(documentId, timeout, params) {
22144
22830
  return this.call(
22145
22831
  "Failed to fetch document details",
22146
- () => this.http.get(`/documents/${documentId}`, timeout === void 0 ? void 0 : { timeout })
22832
+ () => this.http.get(`/documents/${documentId}`, { timeout, ...params?.expand ? { params } : {} })
22147
22833
  );
22148
22834
  }
22149
22835
  /** Download a document artifact. Defaults to the certificated (signed) PDF. */
22150
- async download(documentId, artifactName = "certificated") {
22836
+ async download(documentId, artifactName = "certificated", options = {}) {
22151
22837
  const id = this.requireId(documentId, "Document ID");
22152
22838
  const artifact = requireDocumentArtifactName(artifactName);
22839
+ const config = this.artifactConfig(options);
22153
22840
  return this.callBinary(
22154
22841
  "Failed to download document",
22155
22842
  () => this.http.get(`/documents/${id}/download/${artifact}`, {
22843
+ ...config,
22156
22844
  responseType: "arraybuffer"
22157
22845
  })
22158
22846
  );
22159
22847
  }
22160
22848
  /** Download the document thumbnail. */
22161
- async thumbnail(documentId) {
22849
+ async thumbnail(documentId, options = {}) {
22850
+ const config = this.artifactConfig(options);
22162
22851
  const id = this.requireId(documentId, "Document ID");
22163
22852
  return this.callBinary(
22164
22853
  "Failed to download document thumbnail",
22165
- () => this.http.get(`/documents/${id}/thumbnail`, { responseType: "arraybuffer" })
22854
+ () => this.http.get(`/documents/${id}/thumbnail`, {
22855
+ ...config,
22856
+ responseType: "arraybuffer"
22857
+ })
22166
22858
  );
22167
22859
  }
22168
22860
  /** Download a single page as a JPEG. */
22169
- async downloadPage(documentId, pageId) {
22861
+ async downloadPage(documentId, pageId, options = {}) {
22862
+ const config = this.artifactConfig(options);
22170
22863
  const docId = this.requireId(documentId, "Document ID");
22171
22864
  const pid = this.requireId(pageId, "Page ID");
22172
22865
  return this.callBinary(
22173
22866
  "Failed to download page",
22174
22867
  () => this.http.get(`/documents/${docId}/pages/${pid}/download`, {
22868
+ ...config,
22175
22869
  responseType: "arraybuffer"
22176
22870
  })
22177
22871
  );
22178
22872
  }
22873
+ artifactConfig(options) {
22874
+ if (options.artifact !== void 0 && options.artifact !== "certificated") {
22875
+ throw new ValidationError("artifact must be certificated");
22876
+ }
22877
+ const params = options.artifact === void 0 ? {} : { artifact: options.artifact };
22878
+ return options.signerAccessCode === void 0 ? { params } : signerAccessConfig(this.requireId(options.signerAccessCode, "signer-access-code"), params);
22879
+ }
22179
22880
  /** Fetch one page of the document activity log (20 entries by default). */
22180
22881
  async activities(documentId, params = {}) {
22181
22882
  const id = this.requireId(documentId, "Document ID");
@@ -22249,6 +22950,9 @@ var DocumentResource = class extends BaseResource {
22249
22950
  const tmplId = this.requireId(templateId, "Template ID");
22250
22951
  const accId = this.accountId(accountId);
22251
22952
  validateTemplateSigners(signers, { requireIdentity: true });
22953
+ validateCreditCeiling(options.max_total_credits);
22954
+ const { idempotencyKey, ...bodyOptions } = options;
22955
+ const headers = idempotencyHeaders(idempotencyKey);
22252
22956
  if (options.expires_at !== void 0) requireExpiration(options.expires_at);
22253
22957
  if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
22254
22958
  throw new ValidationError("editor_fields must contain field_id and value");
@@ -22257,11 +22961,11 @@ var DocumentResource = class extends BaseResource {
22257
22961
  throw new ValidationError("tags must contain non-empty tag names");
22258
22962
  }
22259
22963
  await this.validateCertificateTemplateMethod(tmplId, accId, signers);
22260
- const body = { ...options, signers };
22964
+ const body = { ...bodyOptions, signers };
22261
22965
  this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
22262
22966
  return this.call(
22263
22967
  "Failed to create document from template",
22264
- () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body)
22968
+ () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents`, body, { headers })
22265
22969
  );
22266
22970
  }
22267
22971
  /** Estimate the credit cost of creating a document from a template. */
@@ -22440,6 +23144,285 @@ function sleep(ms) {
22440
23144
  return new Promise((resolve) => setTimeout(resolve, ms));
22441
23145
  }
22442
23146
 
23147
+ // src/api/resources/embed.ts
23148
+ var EmbedResource = class extends BaseResource {
23149
+ async listOrigins(accountId) {
23150
+ const id = this.accountId(accountId);
23151
+ return this.call(
23152
+ "Failed to list embed origins",
23153
+ () => this.http.get(`/accounts/${id}/embed-origins`)
23154
+ );
23155
+ }
23156
+ async createOrigin(origin2, accountId) {
23157
+ const id = this.accountId(accountId);
23158
+ validateOrigin(origin2);
23159
+ return this.call(
23160
+ "Failed to add embed origin",
23161
+ () => this.http.post(`/accounts/${id}/embed-origins`, { origin: origin2 })
23162
+ );
23163
+ }
23164
+ async updateOrigin(originId, origin2, accountId) {
23165
+ const id = this.accountId(accountId);
23166
+ const oid = this.requireId(originId, "Origin ID");
23167
+ validateOrigin(origin2);
23168
+ return this.call(
23169
+ "Failed to update embed origin",
23170
+ () => this.http.put(`/accounts/${id}/embed-origins/${oid}`, { origin: origin2 })
23171
+ );
23172
+ }
23173
+ async deleteOrigin(originId, accountId) {
23174
+ const id = this.accountId(accountId);
23175
+ const oid = this.requireId(originId, "Origin ID");
23176
+ return this.call(
23177
+ "Failed to delete embed origin",
23178
+ () => this.http.delete(`/accounts/${id}/embed-origins/${oid}`)
23179
+ );
23180
+ }
23181
+ /** Load the returned private URL in the iframe within five minutes. */
23182
+ async createSession(documentId, assignmentId, signerId) {
23183
+ const did = this.requireId(documentId, "Document ID");
23184
+ const aid = this.requireId(assignmentId, "Assignment ID");
23185
+ const sid = this.requireId(signerId, "Signer ID");
23186
+ return this.call(
23187
+ "Failed to create embed session",
23188
+ () => this.http.post(`/documents/${did}/assignments/${aid}/signers/${sid}/embed-sessions`)
23189
+ );
23190
+ }
23191
+ /** Used by Assinafy's embed page; consumes the token even on a 409. Never retry automatically. */
23192
+ async exchangeSession(token, parentOrigin) {
23193
+ const value = this.requireId(token, "Embed session token");
23194
+ if (parentOrigin !== void 0) validateOrigin(parentOrigin);
23195
+ return this.call(
23196
+ "Failed to exchange embed session",
23197
+ () => this.http.post(
23198
+ `/embed/sessions/${value}/exchange`,
23199
+ parentOrigin === void 0 ? void 0 : { parent_origin: parentOrigin },
23200
+ publicRequestConfig()
23201
+ )
23202
+ );
23203
+ }
23204
+ };
23205
+ function validateOrigin(value) {
23206
+ let url2;
23207
+ try {
23208
+ url2 = new URL(value);
23209
+ } catch {
23210
+ throw new ValidationError("origin must be an absolute origin");
23211
+ }
23212
+ if (typeof value !== "string" || /[\s\\?#*]/.test(value) || !/^[a-z][a-z\d+.-]*:\/\/[^/]+\/?$/i.test(value) || url2.username || url2.password || url2.pathname !== "/" || url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url2.hostname))) {
23213
+ throw new ValidationError(
23214
+ "origin must use HTTPS (HTTP only for localhost or 127.0.0.1) without path, credentials, query, fragment or wildcard"
23215
+ );
23216
+ }
23217
+ }
23218
+
23219
+ // src/api/resources/envelopes.ts
23220
+ var EnvelopeResource = class extends BaseResource {
23221
+ /** Schedule one envelope request; idempotency headers are not supported here (staging). */
23222
+ async schedule(payload, accountId) {
23223
+ const id = this.accountId(accountId);
23224
+ validateCreate(payload);
23225
+ requireScheduledTime(payload.send_at);
23226
+ return this.call(
23227
+ "Failed to schedule envelope",
23228
+ () => this.http.post(`/accounts/${id}/scheduled-sends`, payload)
23229
+ );
23230
+ }
23231
+ /** Estimate one reminder for the whole envelope without sending or charging (staging). */
23232
+ async estimateResendCost(envelopeId, signerId, accountId) {
23233
+ const id = this.accountId(accountId);
23234
+ const eid = this.requireId(envelopeId, "Envelope ID");
23235
+ const sid = this.requireId(signerId, "Signer ID");
23236
+ return this.call(
23237
+ "Failed to estimate envelope reminder cost",
23238
+ () => this.http.post(`/accounts/${id}/envelopes/${eid}/signers/${sid}/estimate-resend-cost`)
23239
+ );
23240
+ }
23241
+ async list(params = {}, accountId) {
23242
+ const id = this.accountId(accountId);
23243
+ if (params.status !== void 0 && !["open", "closed"].includes(params.status))
23244
+ throw new ValidationError("status must be open or closed");
23245
+ return this.callList(
23246
+ "Failed to list envelopes",
23247
+ () => this.http.get(`/accounts/${id}/envelopes`, { params: cleanParams({ ...params }) })
23248
+ );
23249
+ }
23250
+ /** Creates assignments and sends invitations; persist the result before checking delivery. */
23251
+ async create(payload, options = {}) {
23252
+ const id = this.accountId(options.accountId);
23253
+ validateCreate(payload);
23254
+ const headers = idempotencyHeaders(options.idempotencyKey);
23255
+ return this.call(
23256
+ "Failed to create envelope",
23257
+ () => this.http.post(`/accounts/${id}/envelopes`, payload, { headers })
23258
+ );
23259
+ }
23260
+ async estimateCost(payload, accountId) {
23261
+ const id = this.accountId(accountId);
23262
+ validateCreate(payload);
23263
+ return this.call(
23264
+ "Failed to estimate envelope cost",
23265
+ () => this.http.post(`/accounts/${id}/envelopes/estimate-cost`, payload)
23266
+ );
23267
+ }
23268
+ async get(envelopeId, accountId) {
23269
+ const id = this.accountId(accountId);
23270
+ const eid = this.requireId(envelopeId, "Envelope ID");
23271
+ return this.call(
23272
+ "Failed to fetch envelope",
23273
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}`)
23274
+ );
23275
+ }
23276
+ /** Renames, changes the message (null clears), or reorders every current document. */
23277
+ async update(envelopeId, payload, accountId) {
23278
+ const id = this.accountId(accountId);
23279
+ const eid = this.requireId(envelopeId, "Envelope ID");
23280
+ if (!payload || !["name", "message", "document_ids"].some(
23281
+ (key) => payload[key] !== void 0
23282
+ ))
23283
+ throw new ValidationError("At least one envelope field is required");
23284
+ if (payload.name !== void 0) validateName(payload.name);
23285
+ validateMessage(payload.message);
23286
+ if (payload.document_ids !== void 0) validateIds(payload.document_ids, "document_ids");
23287
+ return this.call(
23288
+ "Failed to update envelope",
23289
+ () => this.http.patch(`/accounts/${id}/envelopes/${eid}`, payload)
23290
+ );
23291
+ }
23292
+ /** Requires a closed envelope; its documents are retained by the server. */
23293
+ async delete(envelopeId, accountId) {
23294
+ const id = this.accountId(accountId);
23295
+ const eid = this.requireId(envelopeId, "Envelope ID");
23296
+ return this.call(
23297
+ "Failed to delete envelope",
23298
+ () => this.http.delete(`/accounts/${id}/envelopes/${eid}`)
23299
+ );
23300
+ }
23301
+ async activities(envelopeId, params = {}, accountId) {
23302
+ const id = this.accountId(accountId);
23303
+ const eid = this.requireId(envelopeId, "Envelope ID");
23304
+ requireSort(params.sort, ["id", "-id"]);
23305
+ return this.callList(
23306
+ "Failed to fetch envelope activities",
23307
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}/activities`, {
23308
+ params: cleanParams({ ...params })
23309
+ })
23310
+ );
23311
+ }
23312
+ /** ZIP containing the requested artifact of each eligible document. */
23313
+ async download(envelopeId, artifactName = "certificated", accountId) {
23314
+ const id = this.accountId(accountId);
23315
+ const eid = this.requireId(envelopeId, "Envelope ID");
23316
+ const artifact = requireDocumentArtifactName(artifactName);
23317
+ return this.callBinary(
23318
+ "Failed to download envelope",
23319
+ () => this.http.get(`/accounts/${id}/envelopes/${eid}/download/${artifact}`, {
23320
+ responseType: "arraybuffer"
23321
+ })
23322
+ );
23323
+ }
23324
+ /** Cancels only cancellable documents and notifies their recipients. */
23325
+ async cancel(envelopeId, accountId) {
23326
+ const id = this.accountId(accountId);
23327
+ const eid = this.requireId(envelopeId, "Envelope ID");
23328
+ return this.call(
23329
+ "Failed to cancel envelope",
23330
+ () => this.http.put(`/accounts/${id}/envelopes/${eid}/cancel`)
23331
+ );
23332
+ }
23333
+ async resendNotification(envelopeId, signerId, accountId) {
23334
+ const id = this.accountId(accountId);
23335
+ const eid = this.requireId(envelopeId, "Envelope ID");
23336
+ const sid = this.requireId(signerId, "Signer ID");
23337
+ return this.call(
23338
+ "Failed to resend envelope notification",
23339
+ () => this.http.put(`/accounts/${id}/envelopes/${eid}/signers/${sid}/resend`)
23340
+ );
23341
+ }
23342
+ /** Adds a processed document for existing envelope signers and sends updated invitations. */
23343
+ async addDocument(envelopeId, payload, accountId) {
23344
+ const id = this.accountId(accountId);
23345
+ const eid = this.requireId(envelopeId, "Envelope ID");
23346
+ validateDocument(payload);
23347
+ validateCreditCeiling(payload.max_total_credits);
23348
+ return this.call(
23349
+ "Failed to add envelope document",
23350
+ () => this.http.post(`/accounts/${id}/envelopes/${eid}/documents`, payload)
23351
+ );
23352
+ }
23353
+ /** Cancels an open document, notifies its recipients, and removes it from the envelope. */
23354
+ async removeDocument(envelopeId, documentId, accountId) {
23355
+ const id = this.accountId(accountId);
23356
+ const eid = this.requireId(envelopeId, "Envelope ID");
23357
+ const did = this.requireId(documentId, "Document ID");
23358
+ return this.call(
23359
+ "Failed to remove envelope document",
23360
+ () => this.http.delete(`/accounts/${id}/envelopes/${eid}/documents/${did}`)
23361
+ );
23362
+ }
23363
+ };
23364
+ function validateName(value) {
23365
+ if (typeof value !== "string" || !value.trim() || [...value].length > 255 || value.includes("<"))
23366
+ throw new ValidationError("name must contain 1\u2013255 characters without <");
23367
+ }
23368
+ function validateMessage(value) {
23369
+ if (value != null && typeof value !== "string")
23370
+ throw new ValidationError("message must be text or null");
23371
+ }
23372
+ function validateIds(values, name) {
23373
+ if (!Array.isArray(values) || !values.length || values.some((id) => typeof id !== "string" || !id.trim()) || new Set(values).size !== values.length)
23374
+ throw new ValidationError(`${name} must contain distinct nonblank IDs`);
23375
+ }
23376
+ function validateDocument(payload) {
23377
+ if (!payload || typeof payload.id !== "string" || !payload.id.trim())
23378
+ throw new ValidationError("Document ID is required");
23379
+ validateIds(payload.signer_ids, "signer_ids");
23380
+ if (payload.method !== void 0 && !["virtual", "collect"].includes(payload.method))
23381
+ throw new ValidationError("method must be virtual or collect");
23382
+ if (payload.method === "collect" && (!Array.isArray(payload.entries) || !payload.entries.length))
23383
+ throw new ValidationError("entries are required for collect documents");
23384
+ if (payload.expires_at != null && typeof payload.expires_at !== "string" && (typeof payload.expires_at !== "number" || !Number.isFinite(payload.expires_at)))
23385
+ throw new ValidationError("expires_at must be a date string, Unix time or null");
23386
+ if (payload.copy_receiver_ids !== void 0 && (!Array.isArray(payload.copy_receiver_ids) || payload.copy_receiver_ids.some((id) => typeof id !== "string" || !id.trim())))
23387
+ throw new ValidationError("copy_receiver_ids must contain nonblank IDs");
23388
+ }
23389
+ function validateCreate(payload) {
23390
+ if (!payload) throw new ValidationError("Envelope payload is required");
23391
+ validateName(payload.name);
23392
+ validateMessage(payload.message);
23393
+ validateCreditCeiling(payload.max_total_credits);
23394
+ if (!Array.isArray(payload.signers) || !payload.signers.length || payload.signers.length > 20 || payload.signers.some((s) => !s || typeof s !== "object"))
23395
+ throw new ValidationError("signers must contain 1\u201320 signers");
23396
+ validateIds(
23397
+ payload.signers.map((s) => s.id),
23398
+ "signers"
23399
+ );
23400
+ for (const signer of payload.signers) {
23401
+ if ("step" in signer) throw new ValidationError("Envelope signers do not accept step");
23402
+ validateSignerOptions(signer);
23403
+ }
23404
+ if (!Array.isArray(payload.documents) || !payload.documents.length || payload.documents.length > 20)
23405
+ throw new ValidationError("documents must contain 1\u201320 documents");
23406
+ for (const document2 of payload.documents) {
23407
+ validateDocument(document2);
23408
+ const signers = document2.signer_ids.map((id) => payload.signers.find((s) => s.id === id));
23409
+ if (signers.some((s) => !s))
23410
+ throw new ValidationError("Every document signer must be listed in signers");
23411
+ const assigned = signers.filter((s) => s !== void 0);
23412
+ validateDigitalCertificateMethod(document2.method ?? "virtual", assigned);
23413
+ if (assigned.length > 1 && assigned.some((s) => s.verification_method === "DigitalCertificate"))
23414
+ throw new ValidationError(
23415
+ "A DigitalCertificate signer must be alone on each envelope document"
23416
+ );
23417
+ }
23418
+ validateIds(
23419
+ payload.documents.map((d) => d.id),
23420
+ "documents"
23421
+ );
23422
+ if (payload.signers.some((s) => !payload.documents.some((d) => d.signer_ids.includes(s.id))))
23423
+ throw new ValidationError("Every signer must belong to at least one document");
23424
+ }
23425
+
22443
23426
  // src/api/resources/fields.ts
22444
23427
  var FieldsResource = class extends BaseResource {
22445
23428
  /** Create a field definition. */
@@ -22754,15 +23737,44 @@ function httpsUrl(value, name) {
22754
23737
  return url2;
22755
23738
  }
22756
23739
 
23740
+ // src/api/resources/scheduled-sends.ts
23741
+ var ScheduledSendResource = class extends BaseResource {
23742
+ async list(params = {}, accountId) {
23743
+ const id = this.accountId(accountId);
23744
+ return this.callList(
23745
+ "Failed to list scheduled sends",
23746
+ () => this.http.get(`/accounts/${id}/scheduled-sends`, { params: cleanParams({ ...params }) })
23747
+ );
23748
+ }
23749
+ /** Cancel only a pending request; nothing is sent or charged. */
23750
+ async cancel(scheduledSendId, accountId) {
23751
+ const id = this.accountId(accountId);
23752
+ const sid = this.requireId(scheduledSendId, "Scheduled send ID");
23753
+ return this.call(
23754
+ "Failed to cancel scheduled send",
23755
+ () => this.http.put(`/accounts/${id}/scheduled-sends/${sid}/cancel`)
23756
+ );
23757
+ }
23758
+ /** Execute a pending request now, sending invitations and charging its current cost. */
23759
+ async send(scheduledSendId, accountId) {
23760
+ const id = this.accountId(accountId);
23761
+ const sid = this.requireId(scheduledSendId, "Scheduled send ID");
23762
+ return this.call(
23763
+ "Failed to send scheduled request",
23764
+ () => this.http.put(`/accounts/${id}/scheduled-sends/${sid}/send`)
23765
+ );
23766
+ }
23767
+ };
23768
+
22757
23769
  // src/api/resources/signer-documents.ts
22758
23770
  var SignerDocumentsResource = class extends BaseResource {
22759
23771
  /** `GET /signers/{signer_id}/document?signer-access-code=…` */
22760
- async getCurrent(signerId, signerAccessCode) {
23772
+ async getCurrent(signerId, signerAccessCode, params = {}) {
22761
23773
  const sid = this.requireId(signerId, "Signer ID");
22762
23774
  const code = this.requireId(signerAccessCode, "signer-access-code");
22763
23775
  return this.call(
22764
23776
  "Failed to fetch current signer document",
22765
- () => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code))
23777
+ () => this.http.get(`/signers/${sid}/document`, signerAccessConfig(code, params))
22766
23778
  );
22767
23779
  }
22768
23780
  /** `GET /signers/{signer_id}/documents?signer-access-code=…` */
@@ -22779,17 +23791,17 @@ var SignerDocumentsResource = class extends BaseResource {
22779
23791
  return this.listDocuments(signerId, { params: cleanParams({ ...params }) });
22780
23792
  }
22781
23793
  /** `GET /signers/{signer_id}/documents/search?search=…&signer-access-code=…` */
22782
- async search(signerId, search, signerAccessCode) {
23794
+ async search(signerId, search, signerAccessCode, params = {}) {
22783
23795
  const code = this.requireId(signerAccessCode, "signer-access-code");
22784
- return this.searchDocuments(signerId, signerAccessConfig(code, { search }));
23796
+ return this.searchDocuments(signerId, signerAccessConfig(code, { ...params, search }));
22785
23797
  }
22786
23798
  /**
22787
23799
  * `GET /signers/{signer_id}/documents/search?search=…` with the client's owner
22788
23800
  * credentials instead of a signer access code. The signer must belong to that
22789
23801
  * workspace.
22790
23802
  */
22791
- async searchAsOwner(signerId, search) {
22792
- return this.searchDocuments(signerId, { params: cleanParams({ search }) });
23803
+ async searchAsOwner(signerId, search, params = {}) {
23804
+ return this.searchDocuments(signerId, { params: cleanParams({ ...params, search }) });
22793
23805
  }
22794
23806
  listDocuments(signerId, config) {
22795
23807
  const sid = this.requireId(signerId, "Signer ID");
@@ -22806,9 +23818,9 @@ var SignerDocumentsResource = class extends BaseResource {
22806
23818
  );
22807
23819
  }
22808
23820
  /**
22809
- * Public `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
22810
- * When an access code is supplied, the SDK first verifies that it belongs to
22811
- * the requested signer for callers that want that additional check.
23821
+ * `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
23822
+ * The current API permits only originals with a signer code. Other forms are
23823
+ * retained for compatibility; use downloadCertifiedCopy for completed PDFs.
22812
23824
  */
22813
23825
  async download(signerId, documentId, artifactName, signerAccessCode) {
22814
23826
  const sid = this.requireId(signerId, "Signer ID");
@@ -22922,13 +23934,16 @@ var SignerDocumentsResource = class extends BaseResource {
22922
23934
  * Returns `{ token }` for the signer's Web PKI client. This production route
22923
23935
  * is used by Assinafy's signing frontend but is absent from OpenAPI paths.
22924
23936
  */
22925
- async startCertificate(signerAccessCode) {
23937
+ async startCertificate(signerAccessCode, documentId) {
22926
23938
  const code = this.requireId(signerAccessCode, "signer-access-code");
22927
23939
  return this.call(
22928
23940
  "Failed to start certificate signature",
22929
23941
  () => this.http.post(
22930
23942
  "/signers/certificate/start",
22931
- { "signer-access-code": code },
23943
+ {
23944
+ "signer-access-code": code,
23945
+ ...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
23946
+ },
22932
23947
  signerAccessConfig(code)
22933
23948
  )
22934
23949
  );
@@ -22939,7 +23954,7 @@ var SignerDocumentsResource = class extends BaseResource {
22939
23954
  * successfully signs it. Returns `{ signerName }`; private keys stay local.
22940
23955
  * This production route is absent from OpenAPI paths.
22941
23956
  */
22942
- async completeCertificate(signerAccessCode, token) {
23957
+ async completeCertificate(signerAccessCode, token, documentId) {
22943
23958
  const code = this.requireId(signerAccessCode, "signer-access-code");
22944
23959
  if (typeof token !== "string" || !token.trim()) {
22945
23960
  throw new ValidationError("Certificate token is required");
@@ -22948,7 +23963,11 @@ var SignerDocumentsResource = class extends BaseResource {
22948
23963
  "Failed to complete certificate signature",
22949
23964
  () => this.http.post(
22950
23965
  "/signers/certificate/complete",
22951
- { "signer-access-code": code, token },
23966
+ {
23967
+ "signer-access-code": code,
23968
+ token,
23969
+ ...documentId === void 0 ? {} : { document_id: this.requireId(documentId, "Document ID") }
23970
+ },
22952
23971
  signerAccessConfig(code)
22953
23972
  )
22954
23973
  );
@@ -23013,11 +24032,15 @@ var SignerDocumentsResource = class extends BaseResource {
23013
24032
  );
23014
24033
  }
23015
24034
  /** `GET /sign?signer-access-code=…` — fetch the assignment as the signer sees it. */
23016
- async getAssignment(signerAccessCode, hasAcceptedTerms) {
24035
+ async getAssignment(signerAccessCode, hasAcceptedTerms, params = {}) {
23017
24036
  const code = this.requireId(signerAccessCode, "signer-access-code");
24037
+ if (params.document_id !== void 0) this.requireId(params.document_id, "Document ID");
23018
24038
  return this.call(
23019
24039
  "Failed to fetch signer assignment",
23020
- () => this.http.get("/sign", signerAccessConfig(code, { has_accepted_terms: hasAcceptedTerms }))
24040
+ () => this.http.get(
24041
+ "/sign",
24042
+ signerAccessConfig(code, { ...params, has_accepted_terms: hasAcceptedTerms })
24043
+ )
23021
24044
  );
23022
24045
  }
23023
24046
  /**
@@ -23060,12 +24083,59 @@ var SignerDocumentsResource = class extends BaseResource {
23060
24083
  );
23061
24084
  }
23062
24085
  async requireDocumentAccess(documentId, signerAccessCode, assignmentId) {
23063
- const document2 = await this.getAssignment(signerAccessCode);
24086
+ const document2 = assignmentId === void 0 ? await this.call(
24087
+ "Failed to fetch signer document",
24088
+ () => this.http.get(`/documents/${documentId}`, signerAccessConfig(signerAccessCode))
24089
+ ) : await this.getAssignment(signerAccessCode, void 0, { document_id: documentId });
23064
24090
  if (document2.id !== documentId || assignmentId !== void 0 && document2.assignment?.id !== assignmentId) {
23065
24091
  throw new ValidationError("Signer access code does not match the document or assignment");
23066
24092
  }
23067
24093
  return document2;
23068
24094
  }
24095
+ async getTheme(signerAccessCode) {
24096
+ const code = this.requireId(signerAccessCode, "signer-access-code");
24097
+ return this.call(
24098
+ "Failed to fetch signing theme",
24099
+ () => this.http.get("/sign/theme", signerAccessConfig(code))
24100
+ );
24101
+ }
24102
+ async downloadLogo(signerAccessCode) {
24103
+ const code = this.requireId(signerAccessCode, "signer-access-code");
24104
+ return this.callBinary(
24105
+ "Failed to download signing logo",
24106
+ () => this.http.get("/sign/logo", {
24107
+ ...signerAccessConfig(code),
24108
+ responseType: "arraybuffer"
24109
+ })
24110
+ );
24111
+ }
24112
+ /** Sends a time-limited download link to the original signing contact. */
24113
+ async resendCertifiedCopy(signerAccessCode, documentId) {
24114
+ const code = this.requireId(signerAccessCode, "signer-access-code");
24115
+ const body = documentId === void 0 ? void 0 : { document_id: this.requireId(documentId, "Document ID") };
24116
+ return this.call(
24117
+ "Failed to send certified copy",
24118
+ () => this.http.post("/sign/certified-copy", body, signerAccessConfig(code))
24119
+ );
24120
+ }
24121
+ /** Expired tokens return an ApiError (302); redirects remain disabled. */
24122
+ async downloadCertifiedCopy(token, artifact = "certificated") {
24123
+ const value = this.requireId(token, "Download token");
24124
+ if (!["certificated", "pades"].includes(artifact))
24125
+ throw new ValidationError("artifact must be certificated or pades");
24126
+ const config = { ...publicRequestConfig(), responseType: "arraybuffer" };
24127
+ return this.callBinary(
24128
+ "Failed to download certified copy",
24129
+ () => artifact === "pades" ? this.http.get(`/signers/downloads/${value}/pades`, config) : this.http.get(`/signers/downloads/${value}`, config)
24130
+ );
24131
+ }
24132
+ async resendDownloadLink(token) {
24133
+ const value = this.requireId(token, "Download token");
24134
+ return this.call(
24135
+ "Failed to resend download link",
24136
+ () => this.http.post(`/signers/downloads/${value}/resend`, void 0, publicRequestConfig())
24137
+ );
24138
+ }
23069
24139
  };
23070
24140
  function validateDeclineReason(value) {
23071
24141
  if (typeof value !== "string" || !value.trim()) {
@@ -23138,14 +24208,14 @@ var SignerResource = class extends BaseResource {
23138
24208
  })
23139
24209
  );
23140
24210
  }
23141
- /** Update a signer. Fails if the signer has active assignments. */
24211
+ /** Update supplied fields; verified channels on in-flight documents cannot change. */
23142
24212
  async update(signerId, payload, accountId) {
23143
24213
  const id = this.accountId(accountId);
23144
24214
  const sid = this.requireId(signerId, "Signer ID");
23145
24215
  if (payload.full_name !== void 0 && !payload.full_name.trim()) {
23146
24216
  throw new ValidationError("Signer full name cannot be blank");
23147
24217
  }
23148
- if (payload.email !== void 0) requireEmail(payload.email);
24218
+ if (payload.email != null && payload.email !== "") requireEmail(payload.email);
23149
24219
  return this.call(
23150
24220
  "Failed to update signer",
23151
24221
  () => this.http.put(`/accounts/${id}/signers/${sid}`, normaliseSignerPayload(payload, true))
@@ -23166,13 +24236,13 @@ var SignerResource = class extends BaseResource {
23166
24236
  try {
23167
24237
  const lower = email.toLowerCase();
23168
24238
  for (let page = 1; page <= MAX_SEARCH_PAGES; page++) {
23169
- const { data, meta } = await this.list({ search: email, per_page: 100, page }, accountId);
24239
+ const { data, meta } = await this.list({ search: email, per_page: 50, page }, accountId);
23170
24240
  const match = data.find((s) => (s.email ?? "").toLowerCase() === lower);
23171
24241
  if (match) return match;
23172
24242
  if (!data.length) return null;
23173
24243
  if (meta?.last_page !== void 0) {
23174
24244
  if (page >= meta.last_page) return null;
23175
- } else if (data.length < 100) {
24245
+ } else if (data.length < 50) {
23176
24246
  return null;
23177
24247
  }
23178
24248
  }
@@ -23190,7 +24260,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
23190
24260
  const normalised = {
23191
24261
  full_name: payload.full_name,
23192
24262
  email: payload.email,
23193
- whatsapp_phone_number: payload.whatsapp_phone_number ?? payload.phone
24263
+ whatsapp_phone_number: payload.whatsapp_phone_number !== void 0 ? payload.whatsapp_phone_number : payload.phone
23194
24264
  };
23195
24265
  if (payload.government_id !== void 0) {
23196
24266
  normalised.government_id = payload.government_id;
@@ -23201,7 +24271,7 @@ function normaliseSignerPayload(payload, useGovernmentId = false) {
23201
24271
  if ("metadata" in payload && payload.metadata !== void 0) {
23202
24272
  normalised.metadata = payload.metadata;
23203
24273
  }
23204
- return stripEmpty(normalised);
24274
+ return useGovernmentId ? Object.fromEntries(Object.entries(normalised).filter(([, value]) => value !== void 0)) : stripEmpty(normalised);
23205
24275
  }
23206
24276
 
23207
24277
  // src/api/resources/tags.ts
@@ -23302,25 +24372,7 @@ var TemplateResource = class extends BaseResource {
23302
24372
  }
23303
24373
  };
23304
24374
 
23305
- // src/api/types.ts
23306
- var NOTIFICATION_PREFERENCE_CODES = [
23307
- "DocumentCompleted",
23308
- "SignerDeclined",
23309
- "DocumentCancelled",
23310
- "DocumentAboutToExpire",
23311
- "DocumentExpired",
23312
- "DocumentExpirationReset",
23313
- "DocumentProcessingFailed",
23314
- "TemplateProcessingFailed",
23315
- "SignerWhatsappFailed",
23316
- "ContractRenewalNotice",
23317
- "ContractExpiring",
23318
- "ContractExpired",
23319
- "ContractRenewed"
23320
- ];
23321
-
23322
24375
  // src/api/resources/users.ts
23323
- var NOTIFICATION_PREFERENCES = new Set(NOTIFICATION_PREFERENCE_CODES);
23324
24376
  var UsersResource = class extends BaseResource {
23325
24377
  /** Fetch the authenticated user's profile. */
23326
24378
  async self() {
@@ -23342,26 +24394,25 @@ var UsersResource = class extends BaseResource {
23342
24394
  }
23343
24395
  /** Merge one or more owner-facing email notification preferences. */
23344
24396
  async updateNotificationPreferences(payload) {
23345
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
23346
- throw new ValidationError("Notification preferences must be an object");
23347
- }
23348
- const entries = Object.entries(payload);
23349
- if (entries.length === 0) {
23350
- throw new ValidationError("At least one notification preference is required");
23351
- }
23352
- for (const [key, value] of entries) {
23353
- if (!NOTIFICATION_PREFERENCES.has(key)) {
23354
- throw new ValidationError(`Unknown notification preference: ${key}`);
23355
- }
23356
- if (typeof value !== "boolean") {
23357
- throw new ValidationError(`${key} must be a boolean`);
23358
- }
23359
- }
24397
+ validateBooleanMap(payload, NOTIFICATION_PREFERENCE_CODES);
23360
24398
  return this.call(
23361
24399
  "Failed to update notification preferences",
23362
24400
  () => this.http.put("/users/self/notification-preferences", payload)
23363
24401
  );
23364
24402
  }
24403
+ async getPushPreferences() {
24404
+ return this.call(
24405
+ "Failed to fetch push preferences",
24406
+ () => this.http.get("/users/self/push-preferences")
24407
+ );
24408
+ }
24409
+ async updatePushPreferences(payload) {
24410
+ validateBooleanMap(payload, PUSH_PREFERENCE_CODES);
24411
+ return this.call(
24412
+ "Failed to update push preferences",
24413
+ () => this.http.put("/users/self/push-preferences", payload)
24414
+ );
24415
+ }
23365
24416
  };
23366
24417
 
23367
24418
  // src/api/resources/webhooks.ts
@@ -23401,6 +24452,15 @@ function validateWebhookFields(payload, requireHttps = false) {
23401
24452
  }
23402
24453
  }
23403
24454
  var WebhookResource = class extends BaseResource {
24455
+ /** Sends a webhook_test even to an inactive/held endpoint; does not change its state. */
24456
+ async testEndpoint(endpointId, accountId) {
24457
+ const id = this.accountId(accountId);
24458
+ const eid = this.requireId(endpointId, "Endpoint ID");
24459
+ return this.call(
24460
+ "Failed to send webhook test",
24461
+ () => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/test`)
24462
+ );
24463
+ }
23404
24464
  /**
23405
24465
  * `PUT /accounts/{accountId}/webhooks/subscriptions` — create or replace the
23406
24466
  * account's oldest webhook endpoint. Use the endpoint methods for accounts
@@ -23528,15 +24588,21 @@ var WebhookResource = class extends BaseResource {
23528
24588
  }
23529
24589
  /**
23530
24590
  * `POST …/endpoints/{endpointId}/secret/rotate` — replace the signing secret.
23531
- * The old secret stops working immediately. Requires `webhooks:write` for OAuth.
24591
+ * Set keep_previous to retain the replaced secret for 24 hours. Requires webhooks:write.
23532
24592
  */
23533
- async rotateEndpointSecret(endpointId, accountId) {
24593
+ async rotateEndpointSecret(endpointId, accountId, options = {}) {
23534
24594
  const id = this.accountId(accountId);
23535
24595
  const eid = this.requireId(endpointId, "Endpoint ID");
24596
+ if (options.keep_previous !== void 0 && typeof options.keep_previous !== "boolean") {
24597
+ throw new ValidationError("keep_previous must be a boolean");
24598
+ }
23536
24599
  this.logger.info("Rotating webhook endpoint secret");
23537
24600
  return this.call(
23538
24601
  "Failed to rotate webhook endpoint secret",
23539
- () => this.http.post(`/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`)
24602
+ () => this.http.post(
24603
+ `/accounts/${id}/webhooks/endpoints/${eid}/secret/rotate`,
24604
+ options.keep_previous === void 0 ? void 0 : { keep_previous: options.keep_previous }
24605
+ )
23540
24606
  );
23541
24607
  }
23542
24608
  /** List currently supported webhook event types. */
@@ -23587,9 +24653,46 @@ var WorkspaceResource = class extends BaseResource {
23587
24653
  );
23588
24654
  }
23589
24655
  /** Fetch a single workspace. */
23590
- async get(accountId) {
24656
+ async get(accountId, params = {}) {
24657
+ const id = this.requireId(accountId, "Account ID");
24658
+ return this.call(
24659
+ "Failed to fetch workspace",
24660
+ () => this.http.get(`/accounts/${id}`, { params })
24661
+ );
24662
+ }
24663
+ /** Plan allowance and balances; unavailable to third-party OAuth applications. */
24664
+ async usage(accountId) {
24665
+ const id = this.requireId(accountId, "Account ID");
24666
+ return this.call(
24667
+ "Failed to fetch workspace usage",
24668
+ () => this.http.get(`/accounts/${id}/usage`)
24669
+ );
24670
+ }
24671
+ async getNotificationPolicy(accountId) {
24672
+ const id = this.requireId(accountId, "Account ID");
24673
+ return this.call(
24674
+ "Failed to fetch notification policy",
24675
+ () => this.http.get(`/accounts/${id}/notification-policy`)
24676
+ );
24677
+ }
24678
+ /** Owner-only partial merge; false disables the alert workspace-wide. */
24679
+ async updateNotificationPolicy(accountId, payload) {
23591
24680
  const id = this.requireId(accountId, "Account ID");
23592
- return this.call("Failed to fetch workspace", () => this.http.get(`/accounts/${id}`));
24681
+ if (!payload || typeof payload !== "object" || Array.isArray(payload) || !Object.keys(payload).length || Object.keys(payload).some((key) => !["events", "owners_receive_all"].includes(key)))
24682
+ throw new ValidationError("Provide events and/or owners_receive_all");
24683
+ if (payload.owners_receive_all !== void 0 && typeof payload.owners_receive_all !== "boolean")
24684
+ throw new ValidationError("owners_receive_all must be a boolean");
24685
+ if (payload.events !== void 0)
24686
+ validateBooleanMap(payload.events, [
24687
+ ...NOTIFICATION_PREFERENCE_CODES,
24688
+ ...PUSH_PREFERENCE_CODES
24689
+ ]);
24690
+ if (payload.events === void 0 && payload.owners_receive_all === void 0)
24691
+ throw new ValidationError("At least one notification policy field is required");
24692
+ return this.call(
24693
+ "Failed to update notification policy",
24694
+ () => this.http.put(`/accounts/${id}/notification-policy`, payload)
24695
+ );
23593
24696
  }
23594
24697
  /** Fetch the workspace's public branding theme. */
23595
24698
  async getTheme(accountId) {
@@ -23783,6 +24886,7 @@ var AssinafyClient = class _AssinafyClient {
23783
24886
  contracts;
23784
24887
  signers;
23785
24888
  workspaces;
24889
+ scheduledSends;
23786
24890
  assignments;
23787
24891
  webhooks;
23788
24892
  templates;
@@ -23790,6 +24894,8 @@ var AssinafyClient = class _AssinafyClient {
23790
24894
  auth;
23791
24895
  oauth;
23792
24896
  fields;
24897
+ envelopes;
24898
+ embed;
23793
24899
  users;
23794
24900
  signerDocuments;
23795
24901
  webhookVerifier;
@@ -23855,12 +24961,19 @@ var AssinafyClient = class _AssinafyClient {
23855
24961
  this.defaultAccountId,
23856
24962
  this.logger
23857
24963
  );
24964
+ this.scheduledSends = new ScheduledSendResource(
24965
+ this.axiosInstance,
24966
+ this.defaultAccountId,
24967
+ this.logger
24968
+ );
23858
24969
  this.webhooks = new WebhookResource(this.axiosInstance, this.defaultAccountId, this.logger);
23859
24970
  this.templates = new TemplateResource(this.axiosInstance, this.defaultAccountId, this.logger);
23860
24971
  this.tags = new TagResource(this.axiosInstance, this.defaultAccountId, this.logger);
23861
24972
  this.auth = new AuthenticationResource(this.axiosInstance, void 0, this.logger);
23862
24973
  this.oauth = new OAuthResource(this.axiosInstance, void 0, this.logger);
23863
24974
  this.fields = new FieldsResource(this.axiosInstance, this.defaultAccountId, this.logger);
24975
+ this.envelopes = new EnvelopeResource(this.axiosInstance, this.defaultAccountId, this.logger);
24976
+ this.embed = new EmbedResource(this.axiosInstance, this.defaultAccountId, this.logger);
23864
24977
  this.users = new UsersResource(this.axiosInstance, void 0, this.logger);
23865
24978
  this.signerDocuments = new SignerDocumentsResource(
23866
24979
  this.axiosInstance,
@@ -23906,6 +25019,7 @@ var AssinafyClient = class _AssinafyClient {
23906
25019
  throw new ValidationError("At least one signer is required");
23907
25020
  }
23908
25021
  if (options.expiresAt !== void 0) requireExpiration(options.expiresAt, "expiresAt");
25022
+ validateCreditCeiling(options.maxTotalCredits);
23909
25023
  const preparedSigners = options.signers.map((signer) => {
23910
25024
  if (!signer || typeof signer !== "object") {
23911
25025
  throw new ValidationError("Each signer must be an object");
@@ -23922,7 +25036,9 @@ var AssinafyClient = class _AssinafyClient {
23922
25036
  const reference = {
23923
25037
  verification_method: signer.verification_method ?? (useWhatsapp ? "Whatsapp" : void 0),
23924
25038
  notification_methods: signer.notification_methods ?? (useWhatsapp ? ["Whatsapp"] : void 0),
23925
- step: signer.step
25039
+ step: signer.step,
25040
+ embedded: signer.embedded,
25041
+ sign_as: signer.sign_as
23926
25042
  };
23927
25043
  validateSignerOptions(reference);
23928
25044
  return { reference, payload };
@@ -23951,7 +25067,8 @@ var AssinafyClient = class _AssinafyClient {
23951
25067
  }
23952
25068
  const assignmentPayload = {
23953
25069
  method: "virtual",
23954
- signers: assignmentSigners
25070
+ signers: assignmentSigners,
25071
+ max_total_credits: options.maxTotalCredits
23955
25072
  };
23956
25073
  if (options.message !== void 0) assignmentPayload.message = options.message;
23957
25074
  if (options.expiresAt !== void 0) assignmentPayload.expires_at = options.expiresAt;
@@ -24158,7 +25275,7 @@ function printError(err, config) {
24158
25275
  // node_modules/@clack/core/dist/index.mjs
24159
25276
  var import_node_util4 = require("util");
24160
25277
  var import_node_process2 = require("process");
24161
- var l = __toESM(require("readline"), 1);
25278
+ var f$1 = __toESM(require("readline"), 1);
24162
25279
  var import_node_readline = __toESM(require("readline"), 1);
24163
25280
 
24164
25281
  // node_modules/fast-string-truncated-width/dist/utils.js
@@ -24247,7 +25364,7 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
24247
25364
  if (index >= length) {
24248
25365
  break outer;
24249
25366
  }
24250
- for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
25367
+ for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
24251
25368
  const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
24252
25369
  BLOCK_RE.lastIndex = index;
24253
25370
  if (BLOCK_RE.test(input)) {
@@ -24492,13 +25609,65 @@ var exec = (string, columns, options = {}) => {
24492
25609
  }
24493
25610
  return returnValue;
24494
25611
  };
24495
- var CRLF_OR_LF = /\r?\n/;
24496
- function wrapAnsi(string, columns, options) {
24497
- return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
24498
- }
25612
+ var CRLF_OR_LF = /\r?\n/;
25613
+ function wrapAnsi(string, columns, options) {
25614
+ return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
25615
+ }
25616
+
25617
+ // node_modules/sisteransi/dist/index.js
25618
+ var ESC2 = "\x1B";
25619
+ var CSI2 = `${ESC2}[`;
25620
+ var cursor = {
25621
+ to(x, y) {
25622
+ if (!y)
25623
+ return `${CSI2}${x + 1}G`;
25624
+ return `${CSI2}${y + 1};${x + 1}H`;
25625
+ },
25626
+ move(x, y) {
25627
+ let ret = "";
25628
+ if (x < 0)
25629
+ ret += `${CSI2}${-x}D`;
25630
+ else if (x > 0)
25631
+ ret += `${CSI2}${x}C`;
25632
+ if (y < 0)
25633
+ ret += `${CSI2}${-y}A`;
25634
+ else if (y > 0)
25635
+ ret += `${CSI2}${y}B`;
25636
+ return ret;
25637
+ },
25638
+ up: (count = 1) => `${CSI2}${count}A`,
25639
+ down: (count = 1) => `${CSI2}${count}B`,
25640
+ forward: (count = 1) => `${CSI2}${count}C`,
25641
+ backward: (count = 1) => `${CSI2}${count}D`,
25642
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
25643
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
25644
+ left: `${CSI2}G`,
25645
+ hide: `${CSI2}?25l`,
25646
+ show: `${CSI2}?25h`,
25647
+ save: `${ESC2}7`,
25648
+ restore: `${ESC2}8`
25649
+ };
25650
+ var erase = {
25651
+ screen: `${CSI2}2J`,
25652
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
25653
+ down: (count = 1) => `${CSI2}J`.repeat(count),
25654
+ line: `${CSI2}2K`,
25655
+ lineEnd: `${CSI2}K`,
25656
+ lineStart: `${CSI2}1K`,
25657
+ lines(count) {
25658
+ let clear2 = "";
25659
+ for (let i2 = 0; i2 < count; i2++)
25660
+ clear2 += this.line + (i2 < count - 1 ? cursor.up() : "");
25661
+ if (count)
25662
+ clear2 += cursor.left;
25663
+ return clear2;
25664
+ }
25665
+ };
25666
+ var clear = {
25667
+ screen: `${ESC2}c`
25668
+ };
24499
25669
 
24500
25670
  // node_modules/@clack/core/dist/index.mjs
24501
- var import_sisteransi = __toESM(require_src3(), 1);
24502
25671
  var import_node_tty = require("tty");
24503
25672
  var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
24504
25673
  var t = [
@@ -24532,6 +25701,7 @@ var settings = {
24532
25701
  error: "Something went wrong"
24533
25702
  },
24534
25703
  withGuide: true,
25704
+ accessible: void 0,
24535
25705
  date: {
24536
25706
  monthNames: [...t],
24537
25707
  messages: {
@@ -24543,6 +25713,12 @@ var settings = {
24543
25713
  }
24544
25714
  }
24545
25715
  };
25716
+ function isAccessible(n2) {
25717
+ if (n2 !== void 0) return n2;
25718
+ if (settings.accessible !== void 0) return settings.accessible;
25719
+ const e = process.env.ACCESSIBLE;
25720
+ return e !== void 0 && e !== "" && e !== "0" && e !== "false";
25721
+ }
24546
25722
  function isActionKey(n2, e) {
24547
25723
  if (typeof n2 == "string")
24548
25724
  return settings.aliases.get(n2) === e;
@@ -24575,59 +25751,55 @@ function block({
24575
25751
  input: e = import_node_process2.stdin,
24576
25752
  output: r2 = import_node_process2.stdout,
24577
25753
  overwrite: o = true,
24578
- hideCursor: t2 = true
25754
+ hideCursor: n2 = true
24579
25755
  } = {}) {
24580
- const s = l.createInterface({
25756
+ const s = f$1.createInterface({
24581
25757
  input: e,
24582
25758
  output: r2,
24583
25759
  prompt: "",
24584
25760
  tabSize: 1
24585
25761
  });
24586
- l.emitKeypressEvents(e, s), e instanceof import_node_tty.ReadStream && e.isTTY && e.setRawMode(true);
24587
- const n2 = (f, { name: a2, sequence: p }) => {
24588
- const c = String(f);
24589
- if (isActionKey([c, a2, p], "cancel")) {
24590
- t2 && r2.write(import_sisteransi.cursor.show), process.exit(0);
25762
+ f$1.emitKeypressEvents(e, s), e instanceof import_node_tty.ReadStream && e.isTTY && e.setRawMode(true);
25763
+ const t2 = (l, { name: i2, sequence: p }) => {
25764
+ const w = String(l);
25765
+ if (isActionKey([w, i2, p], "cancel")) {
25766
+ n2 && r2.write(cursor.show), process.exit(0);
24591
25767
  return;
24592
25768
  }
24593
25769
  if (!o) return;
24594
- const i2 = a2 === "return" ? 0 : -1, m = a2 === "return" ? -1 : 0;
24595
- l.moveCursor(r2, i2, m, () => {
24596
- l.clearLine(r2, 1, () => {
24597
- e.once("keypress", n2);
25770
+ const c2 = i2 === "return" ? 0 : -1, a2 = i2 === "return" ? -1 : 0;
25771
+ f$1.moveCursor(r2, c2, a2, () => {
25772
+ f$1.clearLine(r2, 1, () => {
25773
+ e.once("keypress", t2);
24598
25774
  });
24599
25775
  });
24600
25776
  };
24601
- return t2 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", n2), () => {
24602
- e.off("keypress", n2), t2 && r2.write(import_sisteransi.cursor.show), e instanceof import_node_tty.ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
25777
+ return n2 && r2.write(cursor.hide), e.once("keypress", t2), () => {
25778
+ e.off("keypress", t2), n2 && r2.write(cursor.show), e instanceof import_node_tty.ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
24603
25779
  };
24604
25780
  }
24605
25781
  var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
24606
25782
  var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
24607
- function wrapTextWithPrefix(e, r2, o, t2 = o, s = o, n2) {
24608
- const f = getColumns(e ?? import_node_process2.stdout);
24609
- return wrapAnsi(r2, f - o.length, {
25783
+ function wrapTextWithPrefix(e, r2, o, n2 = o, s = o, t2) {
25784
+ const l = getColumns(e ?? import_node_process2.stdout), i2 = dist_default2(o);
25785
+ return wrapAnsi(r2, l - i2, {
24610
25786
  hard: true,
24611
25787
  trim: false
24612
25788
  }).split(`
24613
- `).map((c, i2, m) => {
24614
- const d = n2 ? n2(c, i2) : c;
24615
- return i2 === 0 ? `${t2}${d}` : i2 === m.length - 1 ? `${s}${d}` : `${o}${d}`;
25789
+ `).map((c2, a2, g) => {
25790
+ const m = t2 ? t2(c2, a2) : c2;
25791
+ return a2 === 0 ? `${n2}${m}` : a2 === g.length - 1 ? `${s}${m}` : `${o}${m}`;
24616
25792
  }).join(`
24617
25793
  `);
24618
25794
  }
24619
- function runValidation(e, n2) {
25795
+ function runValidation(e, a2) {
24620
25796
  if ("~standard" in e) {
24621
- const a2 = e["~standard"].validate(n2);
24622
- if (a2 instanceof Promise)
24623
- throw new TypeError(
24624
- "Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
24625
- );
24626
- return a2.issues?.at(0)?.message;
25797
+ const n2 = e["~standard"].validate(a2);
25798
+ return n2 instanceof Promise ? n2.then((r2) => r2.issues?.at(0)?.message) : n2.issues?.at(0)?.message;
24627
25799
  }
24628
- return e(n2);
25800
+ return e(a2);
24629
25801
  }
24630
- var V = class {
25802
+ var C$1 = class C {
24631
25803
  input;
24632
25804
  output;
24633
25805
  _abortSignal;
@@ -24642,9 +25814,17 @@ var V = class {
24642
25814
  error = "";
24643
25815
  value;
24644
25816
  userInput = "";
25817
+ /**
25818
+ * Whether accessible (static, screen-reader friendly) output is enabled for
25819
+ * this prompt, resolved from the `accessible` option, the global setting,
25820
+ * and the `ACCESSIBLE` env var.
25821
+ */
25822
+ get accessible() {
25823
+ return isAccessible(this.opts.accessible);
25824
+ }
24645
25825
  constructor(t2, e = true) {
24646
- const { input: i2 = import_node_process2.stdin, output: n2 = import_node_process2.stdout, render: s, signal: r2, ...o } = t2;
24647
- this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r2, this.input = i2, this.output = n2;
25826
+ const { input: i2 = import_node_process2.stdin, output: s = import_node_process2.stdout, render: r2, signal: n2, ...o } = t2;
25827
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = r2.bind(this), this._track = e, this._abortSignal = n2, this.input = i2, this.output = s;
24648
25828
  }
24649
25829
  /**
24650
25830
  * Unsubscribe all listeners
@@ -24682,11 +25862,11 @@ var V = class {
24682
25862
  * @param data - The data to pass to the callback
24683
25863
  */
24684
25864
  emit(t2, ...e) {
24685
- const i2 = this._subscribers.get(t2) ?? [], n2 = [];
24686
- for (const s of i2)
24687
- s.cb(...e), s.once && n2.push(() => i2.splice(i2.indexOf(s), 1));
24688
- for (const s of n2)
24689
- s();
25865
+ const i2 = this._subscribers.get(t2) ?? [], s = [];
25866
+ for (const r2 of i2)
25867
+ r2.cb(...e), r2.once && s.push(() => i2.splice(i2.indexOf(r2), 1));
25868
+ for (const r2 of s)
25869
+ r2();
24690
25870
  }
24691
25871
  prompt() {
24692
25872
  return new Promise((t2) => {
@@ -24708,9 +25888,9 @@ var V = class {
24708
25888
  escapeCodeTimeout: 50,
24709
25889
  terminal: true
24710
25890
  }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
24711
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
25891
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
24712
25892
  }), this.once("cancel", () => {
24713
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
25893
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
24714
25894
  });
24715
25895
  });
24716
25896
  }
@@ -24729,70 +25909,73 @@ var V = class {
24729
25909
  _clearUserInput() {
24730
25910
  this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
24731
25911
  }
24732
- onKeypress(t2, e) {
24733
- if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
24734
- if (this.opts.validate) {
24735
- const i2 = runValidation(this.opts.validate, this.value);
24736
- i2 && (this.error = i2 instanceof Error ? i2.message : i2, this.state = "error", this.rl?.write(this.userInput));
25912
+ async onKeypress(t2, e) {
25913
+ if (this.state !== "validating") {
25914
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t2, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t2 && (t2.toLowerCase() === "y" || t2.toLowerCase() === "n") && this.emit("confirm", t2.toLowerCase() === "y"), this.emit("key", t2, e), e?.name === "return" && this._shouldSubmit(t2, e)) {
25915
+ if (this.opts.validate) {
25916
+ const i2 = runValidation(this.opts.validate, this.value);
25917
+ let s;
25918
+ i2 instanceof Promise ? (this.state = "validating", this.render(), s = await i2) : s = i2, s && (this.error = s instanceof Error ? s.message : s, this.state = "error", this.rl?.write(this.userInput));
25919
+ }
25920
+ this.state !== "error" && (this.state = "submit");
24737
25921
  }
24738
- this.state !== "error" && (this.state = "submit");
25922
+ isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
24739
25923
  }
24740
- isActionKey([t2, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
24741
25924
  }
24742
25925
  close() {
24743
25926
  this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
24744
25927
  `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
24745
25928
  }
24746
25929
  restoreCursor() {
24747
- const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
25930
+ const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
24748
25931
  `).length - 1;
24749
- this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
25932
+ this.output.write(cursor.move(-999, t2 * -1));
24750
25933
  }
24751
25934
  render() {
24752
- const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
25935
+ const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
24753
25936
  hard: true,
24754
25937
  trim: false
24755
25938
  });
24756
25939
  if (t2 !== this._prevFrame) {
24757
25940
  if (this.state === "initial")
24758
- this.output.write(import_sisteransi.cursor.hide);
25941
+ this.output.write(cursor.hide);
24759
25942
  else {
24760
25943
  const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
24761
25944
  if (this.restoreCursor(), e) {
24762
- const n2 = Math.max(0, e.numLinesAfter - i2), s = Math.max(0, e.numLinesBefore - i2);
24763
- let r2 = e.lines.find((o) => o >= n2);
24764
- if (r2 === void 0) {
25945
+ const s = Math.max(0, e.numLinesAfter - i2), r2 = Math.max(0, e.numLinesBefore - i2);
25946
+ let n2 = e.lines.find((o) => o >= s);
25947
+ if (n2 === void 0) {
24765
25948
  this._prevFrame = t2;
24766
25949
  return;
24767
25950
  }
24768
25951
  if (e.lines.length === 1) {
24769
- this.output.write(import_sisteransi.cursor.move(0, r2 - s)), this.output.write(import_sisteransi.erase.lines(1));
25952
+ this.output.write(cursor.move(0, n2 - r2)), this.output.write(erase.lines(1));
24770
25953
  const o = t2.split(`
24771
25954
  `);
24772
- this.output.write(o[r2]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - r2 - 1));
25955
+ this.output.write(o[n2]), this._prevFrame = t2, this.output.write(cursor.move(0, o.length - n2 - 1));
24773
25956
  return;
24774
25957
  } else if (e.lines.length > 1) {
24775
- if (n2 < s)
24776
- r2 = n2;
25958
+ if (s < r2)
25959
+ n2 = s;
24777
25960
  else {
24778
- const h2 = r2 - s;
24779
- h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
25961
+ const h2 = n2 - r2;
25962
+ h2 > 0 && this.output.write(cursor.move(0, h2));
24780
25963
  }
24781
- this.output.write(import_sisteransi.erase.down());
24782
- const f = t2.split(`
24783
- `).slice(r2);
24784
- this.output.write(f.join(`
25964
+ this.output.write(erase.down());
25965
+ const m = t2.split(`
25966
+ `).slice(n2);
25967
+ this.output.write(m.join(`
24785
25968
  `)), this._prevFrame = t2;
24786
25969
  return;
24787
25970
  }
24788
25971
  }
24789
- this.output.write(import_sisteransi.erase.down());
25972
+ this.output.write(erase.down());
24790
25973
  }
24791
25974
  this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
24792
25975
  }
24793
25976
  }
24794
25977
  };
24795
- var r = class extends V {
25978
+ var r = class extends C$1 {
24796
25979
  get cursor() {
24797
25980
  return this.value ? 0 : 1;
24798
25981
  }
@@ -24803,13 +25986,13 @@ var r = class extends V {
24803
25986
  super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
24804
25987
  this.value = this._value;
24805
25988
  }), this.on("confirm", (i2) => {
24806
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
25989
+ this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
24807
25990
  }), this.on("cursor", () => {
24808
25991
  this.value = !this.value;
24809
25992
  });
24810
25993
  }
24811
25994
  };
24812
- var u$1 = class u extends V {
25995
+ var u = class extends C$1 {
24813
25996
  _mask = "\u2022";
24814
25997
  get cursor() {
24815
25998
  return this._cursor;
@@ -24837,7 +26020,7 @@ var u$1 = class u extends V {
24837
26020
  });
24838
26021
  }
24839
26022
  };
24840
- var n = class extends V {
26023
+ var n = class extends C$1 {
24841
26024
  get userInputWithCursor() {
24842
26025
  if (this.state === "submit")
24843
26026
  return this.userInput;
@@ -24867,7 +26050,6 @@ var import_node_util5 = require("util");
24867
26050
  var import_node_process3 = __toESM(require("process"), 1);
24868
26051
  var import_node_fs3 = require("fs");
24869
26052
  var import_node_path3 = require("path");
24870
- var import_sisteransi2 = __toESM(require_src3(), 1);
24871
26053
  function isUnicodeSupported() {
24872
26054
  if (import_node_process3.default.platform !== "win32") {
24873
26055
  return import_node_process3.default.env.TERM !== "linux";
@@ -24876,7 +26058,7 @@ function isUnicodeSupported() {
24876
26058
  }
24877
26059
  var unicode = isUnicodeSupported();
24878
26060
  var isCI = () => process.env.CI === "true";
24879
- var unicodeOr = (o, e) => unicode ? o : e;
26061
+ var unicodeOr = (e, o) => unicode ? e : o;
24880
26062
  var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
24881
26063
  var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
24882
26064
  var S_STEP_ERROR = unicodeOr("\u25B2", "x");
@@ -24902,8 +26084,8 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
24902
26084
  var S_SUCCESS = unicodeOr("\u25C6", "*");
24903
26085
  var S_WARN = unicodeOr("\u25B2", "!");
24904
26086
  var S_ERROR = unicodeOr("\u25A0", "x");
24905
- var symbol = (o) => {
24906
- switch (o) {
26087
+ var symbol = (e) => {
26088
+ switch (e) {
24907
26089
  case "initial":
24908
26090
  case "active":
24909
26091
  return (0, import_node_util5.styleText)("cyan", S_STEP_ACTIVE);
@@ -24913,41 +26095,43 @@ var symbol = (o) => {
24913
26095
  return (0, import_node_util5.styleText)("yellow", S_STEP_ERROR);
24914
26096
  case "submit":
24915
26097
  return (0, import_node_util5.styleText)("green", S_STEP_SUBMIT);
26098
+ case "validating":
26099
+ return (0, import_node_util5.styleText)("dim", S_STEP_ACTIVE);
24916
26100
  }
24917
26101
  };
24918
- var confirm = (i2) => {
24919
- const a2 = i2.active ?? "Yes", s = i2.inactive ?? "No";
26102
+ var confirm = (e) => {
26103
+ const a2 = e.active ?? "Yes", o = e.inactive ?? "No";
24920
26104
  return new r({
24921
26105
  active: a2,
24922
- inactive: s,
24923
- signal: i2.signal,
24924
- input: i2.input,
24925
- output: i2.output,
24926
- initialValue: i2.initialValue ?? true,
26106
+ inactive: o,
26107
+ signal: e.signal,
26108
+ input: e.input,
26109
+ output: e.output,
26110
+ initialValue: e.initialValue ?? true,
24927
26111
  render() {
24928
- const e = i2.withGuide ?? settings.withGuide, u4 = `${symbol(this.state)} `, l2 = e ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
24929
- i2.output,
24930
- i2.message,
24931
- l2,
24932
- u4
24933
- ), o = `${e ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
26112
+ const i2 = e.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l = i2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
26113
+ e.output,
26114
+ e.message,
26115
+ l,
26116
+ u3
26117
+ ), s = `${i2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
24934
26118
  ` : ""}${f}
24935
- `, c = this.value ? a2 : s;
26119
+ `, c2 = this.value ? a2 : o;
24936
26120
  switch (this.state) {
24937
26121
  case "submit": {
24938
- const r2 = e ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "";
24939
- return `${o}${r2}${(0, import_node_util5.styleText)("dim", c)}`;
26122
+ const r2 = i2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "";
26123
+ return `${s}${r2}${(0, import_node_util5.styleText)("dim", c2)}`;
24940
26124
  }
24941
26125
  case "cancel": {
24942
- const r2 = e ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "";
24943
- return `${o}${r2}${(0, import_node_util5.styleText)(["strikethrough", "dim"], c)}${e ? `
26126
+ const r2 = i2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "";
26127
+ return `${s}${r2}${(0, import_node_util5.styleText)(["strikethrough", "dim"], c2)}${i2 ? `
24944
26128
  ${(0, import_node_util5.styleText)("gray", S_BAR)}` : ""}`;
24945
26129
  }
24946
26130
  default: {
24947
- const r2 = e ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", g = e ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
24948
- return `${o}${r2}${this.value ? `${(0, import_node_util5.styleText)("green", S_RADIO_ACTIVE)} ${a2}` : `${(0, import_node_util5.styleText)("dim", S_RADIO_INACTIVE)} ${(0, import_node_util5.styleText)("dim", a2)}`}${i2.vertical ? e ? `
26131
+ const r2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", g = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
26132
+ return `${s}${r2}${this.value ? `${(0, import_node_util5.styleText)("green", S_RADIO_ACTIVE)} ${a2}` : `${(0, import_node_util5.styleText)("dim", S_RADIO_INACTIVE)} ${(0, import_node_util5.styleText)("dim", a2)}`}${e.vertical ? i2 ? `
24949
26133
  ${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : `
24950
- ` : ` ${(0, import_node_util5.styleText)("dim", "/")} `}${this.value ? `${(0, import_node_util5.styleText)("dim", S_RADIO_INACTIVE)} ${(0, import_node_util5.styleText)("dim", s)}` : `${(0, import_node_util5.styleText)("green", S_RADIO_ACTIVE)} ${s}`}
26134
+ ` : ` ${(0, import_node_util5.styleText)("dim", "/")} `}${this.value ? `${(0, import_node_util5.styleText)("dim", S_RADIO_INACTIVE)} ${(0, import_node_util5.styleText)("dim", o)}` : `${(0, import_node_util5.styleText)("green", S_RADIO_ACTIVE)} ${o}`}
24951
26135
  ${g}
24952
26136
  `;
24953
26137
  }
@@ -24966,123 +26150,142 @@ var cancel = (o = "", t2) => {
24966
26150
 
24967
26151
  `);
24968
26152
  };
24969
- var password = (r2) => new u$1({
24970
- validate: r2.validate,
24971
- mask: r2.mask ?? S_PASSWORD_MASK,
24972
- signal: r2.signal,
24973
- input: r2.input,
24974
- output: r2.output,
26153
+ var password = (e) => new u({
26154
+ validate: e.validate,
26155
+ mask: e.mask ?? S_PASSWORD_MASK,
26156
+ signal: e.signal,
26157
+ input: e.input,
26158
+ output: e.output,
24975
26159
  render() {
24976
- const e = r2.withGuide ?? settings.withGuide, o = `${e ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
24977
- ` : ""}${symbol(this.state)} ${r2.message}
24978
- `, c = this.userInputWithCursor, i2 = this.masked;
26160
+ const r2 = e.withGuide ?? settings.withGuide, o = `${r2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
26161
+ ` : ""}${symbol(this.state)} ${e.message}
26162
+ `, m = this.userInputWithCursor, i2 = this.masked;
24979
26163
  switch (this.state) {
24980
26164
  case "error": {
24981
- const s = e ? `${(0, import_node_util5.styleText)("yellow", S_BAR)} ` : "", n2 = e ? `${(0, import_node_util5.styleText)("yellow", S_BAR_END)} ` : "", l2 = i2 ?? "";
24982
- return r2.clearOnError && this.clear(), `${o.trim()}
24983
- ${s}${l2}
26165
+ const s = r2 ? `${(0, import_node_util5.styleText)("yellow", S_BAR)} ` : "", n2 = r2 ? `${(0, import_node_util5.styleText)("yellow", S_BAR_END)} ` : "", d = i2 ?? "";
26166
+ return e.clearOnError && this.clear(), `${o.trim()}
26167
+ ${s}${d}
24984
26168
  ${n2}${(0, import_node_util5.styleText)("yellow", this.error)}
24985
26169
  `;
24986
26170
  }
24987
26171
  case "submit": {
24988
- const s = e ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", n2 = i2 ? (0, import_node_util5.styleText)("dim", i2) : "";
26172
+ const s = r2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", n2 = i2 ? (0, import_node_util5.styleText)("dim", i2) : "";
24989
26173
  return `${o}${s}${n2}`;
24990
26174
  }
24991
26175
  case "cancel": {
24992
- const s = e ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", n2 = i2 ? (0, import_node_util5.styleText)(["strikethrough", "dim"], i2) : "";
24993
- return `${o}${s}${n2}${i2 && e ? `
26176
+ const s = r2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)} ` : "", n2 = i2 ? (0, import_node_util5.styleText)(["strikethrough", "dim"], i2) : "";
26177
+ return `${o}${s}${n2}${i2 && r2 ? `
24994
26178
  ${(0, import_node_util5.styleText)("gray", S_BAR)}` : ""}`;
24995
26179
  }
24996
26180
  default: {
24997
- const s = e ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", n2 = e ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
24998
- return `${o}${s}${c}
26181
+ const s = r2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", n2 = r2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
26182
+ return `${o}${s}${m}
24999
26183
  ${n2}
25000
26184
  `;
25001
26185
  }
25002
26186
  }
25003
26187
  }
25004
26188
  }).prompt();
25005
- var W = (l2) => (0, import_node_util5.styleText)("magenta", l2);
26189
+ var Y = 3e4;
26190
+ var Z = (c2) => (0, import_node_util5.styleText)("magenta", c2);
25006
26191
  var spinner = ({
25007
- indicator: l2 = "dots",
25008
- onCancel: h2,
26192
+ indicator: c2 = "dots",
26193
+ onCancel: b,
25009
26194
  output: n2 = process.stdout,
25010
- cancelMessage: G2,
25011
- errorMessage: O,
25012
- frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
25013
- delay: F = unicode ? 80 : 120,
25014
- signal: m,
25015
- ...I
26195
+ cancelMessage: _,
26196
+ errorMessage: C2,
26197
+ frames: M = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
26198
+ delay: O = unicode ? 80 : 120,
26199
+ signal: g,
26200
+ ...E
25016
26201
  } = {}) => {
25017
- const u4 = isCI();
25018
- let M, T, d = false, S = false, s = "", p, w = performance.now();
25019
- const x = getColumns(n2), k = I?.styleFrame ?? W, g = (e) => {
25020
- const r2 = e > 1 ? O ?? settings.messages.error : G2 ?? settings.messages.cancel;
25021
- S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
25022
- }, f = () => g(2), i2 = () => g(1), A = () => {
25023
- process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g), m && m.addEventListener("abort", i2);
25024
- }, H = () => {
25025
- process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m && m.removeEventListener("abort", i2);
25026
- }, y = () => {
25027
- if (p === void 0) return;
25028
- u4 && n2.write(`
26202
+ const u3 = isCI(), h2 = isAccessible(E.accessible);
26203
+ let x, I, p = false, l = false, r2 = "", v, w = performance.now();
26204
+ const y = getColumns(n2), F = E?.styleFrame ?? Z, S = (e) => {
26205
+ const s = e > 1 ? C2 ?? settings.messages.error : _ ?? settings.messages.cancel;
26206
+ l = e === 1, p && (m(s, e), l && typeof b == "function" && b());
26207
+ }, $ = () => S(2), a2 = () => S(1), H = () => {
26208
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a2), process.on("SIGTERM", a2), process.on("exit", S), g && g.addEventListener("abort", a2);
26209
+ }, B = () => {
26210
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a2), process.removeListener("SIGTERM", a2), process.removeListener("exit", S), g && g.removeEventListener("abort", a2);
26211
+ }, R2 = () => {
26212
+ if (v === void 0) return;
26213
+ u3 && n2.write(`
25029
26214
  `);
25030
- const r2 = wrapAnsi(p, x, {
26215
+ const s = wrapAnsi(v, y, {
25031
26216
  hard: true,
25032
26217
  trim: false
25033
26218
  }).split(`
25034
26219
  `);
25035
- r2.length > 1 && n2.write(import_sisteransi2.cursor.up(r2.length - 1)), n2.write(import_sisteransi2.cursor.to(0)), n2.write(import_sisteransi2.erase.down());
25036
- }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
25037
- const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
25038
- return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
25039
- }, N = I.withGuide ?? settings.withGuide, P = (e = "") => {
25040
- d = true, M = block({ output: n2 }), s = C(e), w = performance.now(), N && n2.write(`${(0, import_node_util5.styleText)("gray", S_BAR)}
26220
+ s.length > 1 && n2.write(cursor.up(s.length - 1)), n2.write(cursor.to(0)), n2.write(erase.down());
26221
+ }, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
26222
+ const s = (performance.now() - e) / 1e3, i2 = Math.floor(s / 60), t2 = Math.floor(s % 60);
26223
+ return i2 > 0 ? `[${i2}m ${t2}s]` : `[${t2}s]`;
26224
+ }, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
26225
+ if (p = true, l = false, r2 = L(e), w = performance.now(), H(), h2) {
26226
+ r2 !== "" && n2.write(`${r2}
26227
+ `), I = setInterval(() => {
26228
+ n2.write(r2 === "" ? `still working
26229
+ ` : `still working: ${r2}
26230
+ `);
26231
+ }, Y);
26232
+ return;
26233
+ }
26234
+ x = block({ output: n2 }), N && n2.write(`${(0, import_node_util5.styleText)("gray", S_BAR)}
25041
26235
  `);
25042
- let r2 = 0, t2 = 0;
25043
- A(), T = setInterval(() => {
25044
- if (u4 && s === p)
26236
+ let s = 0, i2 = 0;
26237
+ I = setInterval(() => {
26238
+ if (u3 && r2 === v)
25045
26239
  return;
25046
- y(), p = s;
25047
- const o = k(E[r2]);
25048
- let v;
25049
- if (u4)
25050
- v = `${o} ${s}...`;
25051
- else if (l2 === "timer")
25052
- v = `${o} ${s} ${_(w)}`;
26240
+ R2(), v = r2;
26241
+ const t2 = F(M[s]);
26242
+ let o;
26243
+ if (u3)
26244
+ o = `${t2} ${r2}...`;
26245
+ else if (c2 === "timer")
26246
+ o = `${t2} ${r2} ${T(w)}`;
25053
26247
  else {
25054
- const B = ".".repeat(Math.floor(t2)).slice(0, 3);
25055
- v = `${o} ${s}${B}`;
26248
+ const j = ".".repeat(Math.floor(i2)).slice(0, 3);
26249
+ o = `${t2} ${r2}${j}`;
25056
26250
  }
25057
- const j = wrapAnsi(v, x, {
26251
+ const D = wrapAnsi(o, y, {
25058
26252
  hard: true,
25059
26253
  trim: false
25060
26254
  });
25061
- n2.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
25062
- }, F);
25063
- }, a2 = (e = "", r2 = 0, t2 = false) => {
25064
- if (!d) return;
25065
- d = false, clearInterval(T), y();
25066
- const o = r2 === 0 ? (0, import_node_util5.styleText)("green", S_STEP_SUBMIT) : r2 === 1 ? (0, import_node_util5.styleText)("red", S_STEP_CANCEL) : (0, import_node_util5.styleText)("red", S_STEP_ERROR);
25067
- s = e ?? s, t2 || (l2 === "timer" ? n2.write(`${o} ${s} ${_(w)}
25068
- `) : n2.write(`${o} ${s}
25069
- `)), H(), M();
26255
+ n2.write(D), s = s + 1 < M.length ? s + 1 : 0, i2 = i2 < 4 ? i2 + 0.125 : 0;
26256
+ }, O);
26257
+ }, m = (e = "", s = 0, i2 = false) => {
26258
+ if (p) {
26259
+ if (p = false, l = s === 1, clearInterval(I), h2 || R2(), r2 = e ?? r2, !i2)
26260
+ if (h2) {
26261
+ const t2 = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C2 ?? settings.messages.error : "Done", o = r2 || t2;
26262
+ c2 === "timer" ? n2.write(`${o} ${T(w)}
26263
+ `) : n2.write(`${o}
26264
+ `);
26265
+ } else {
26266
+ const t2 = s === 0 ? (0, import_node_util5.styleText)("green", S_STEP_SUBMIT) : s === 1 ? (0, import_node_util5.styleText)("red", S_STEP_CANCEL) : (0, import_node_util5.styleText)("red", S_STEP_ERROR);
26267
+ c2 === "timer" ? n2.write(`${t2} ${r2} ${T(w)}
26268
+ `) : n2.write(`${t2} ${r2}
26269
+ `);
26270
+ }
26271
+ B(), x?.();
26272
+ }
25070
26273
  };
25071
26274
  return {
25072
26275
  start: P,
25073
- stop: (e = "") => a2(e, 0),
26276
+ stop: (e = "") => m(e, 0),
25074
26277
  message: (e = "") => {
25075
- s = C(e ?? s);
26278
+ r2 = L(e ?? r2);
25076
26279
  },
25077
- cancel: (e = "") => a2(e, 1),
25078
- error: (e = "") => a2(e, 2),
25079
- clear: () => a2("", 0, true),
26280
+ cancel: (e = "") => m(e, 1),
26281
+ error: (e = "") => m(e, 2),
26282
+ clear: () => m("", 0, true),
25080
26283
  get isCancelled() {
25081
- return S;
26284
+ return l;
25082
26285
  }
25083
26286
  };
25084
26287
  };
25085
- var u3 = {
26288
+ var u2 = {
25086
26289
  light: unicodeOr("\u2500", "-"),
25087
26290
  heavy: unicodeOr("\u2501", "="),
25088
26291
  block: unicodeOr("\u2588", "#")
@@ -25092,42 +26295,48 @@ var SELECT_INSTRUCTIONS = [
25092
26295
  `${(0, import_node_util5.styleText)("dim", "Enter:")} confirm`
25093
26296
  ];
25094
26297
  var i = `${(0, import_node_util5.styleText)("gray", S_BAR)} `;
25095
- var text = (e) => new n({
25096
- validate: e.validate,
25097
- placeholder: e.placeholder,
25098
- defaultValue: e.defaultValue,
25099
- initialValue: e.initialValue,
25100
- output: e.output,
25101
- signal: e.signal,
25102
- input: e.input,
26298
+ var text = (t2) => new n({
26299
+ validate: t2.validate,
26300
+ placeholder: t2.placeholder,
26301
+ defaultValue: t2.defaultValue,
26302
+ initialValue: t2.initialValue,
26303
+ output: t2.output,
26304
+ signal: t2.signal,
26305
+ input: t2.input,
25103
26306
  render() {
25104
- const i2 = e?.withGuide ?? settings.withGuide, s = `${`${i2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
25105
- ` : ""}${symbol(this.state)} `}${e.message}
25106
- `, c = e.placeholder && e.placeholder.length > 0 ? (
26307
+ const r2 = t2?.withGuide ?? settings.withGuide, l = `${`${r2 ? `${(0, import_node_util5.styleText)("gray", S_BAR)}
26308
+ ` : ""}${symbol(this.state)} `}${t2.message}
26309
+ `, d = t2.placeholder && t2.placeholder.length > 0 ? (
25107
26310
  // biome-ignore lint/style/noNonNullAssertion: guarded by placeholder.length > 0
25108
- (0, import_node_util5.styleText)("inverse", e.placeholder[0]) + (0, import_node_util5.styleText)("dim", e.placeholder.slice(1))
25109
- ) : (0, import_node_util5.styleText)(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, l2 = this.value ?? "";
26311
+ (0, import_node_util5.styleText)("inverse", t2.placeholder[0]) + (0, import_node_util5.styleText)("dim", t2.placeholder.slice(1))
26312
+ ) : (0, import_node_util5.styleText)(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : d, s = this.value ?? "";
25110
26313
  switch (this.state) {
26314
+ case "validating": {
26315
+ const n2 = r2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", i2 = r2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "", c2 = (0, import_node_util5.styleText)("dim", o), $ = (0, import_node_util5.styleText)("dim", "Validating...");
26316
+ return `${l}${n2}${c2}
26317
+ ${i2} ${$}
26318
+ `;
26319
+ }
25111
26320
  case "error": {
25112
- const n2 = this.error ? ` ${(0, import_node_util5.styleText)("yellow", this.error)}` : "", r2 = i2 ? `${(0, import_node_util5.styleText)("yellow", S_BAR)} ` : "", d = i2 ? (0, import_node_util5.styleText)("yellow", S_BAR_END) : "";
25113
- return `${s.trim()}
25114
- ${r2}${o}
25115
- ${d}${n2}
26321
+ const n2 = this.error ? ` ${(0, import_node_util5.styleText)("yellow", this.error)}` : "", i2 = r2 ? `${(0, import_node_util5.styleText)("yellow", S_BAR)} ` : "", c2 = r2 ? (0, import_node_util5.styleText)("yellow", S_BAR_END) : "";
26322
+ return `${l.trim()}
26323
+ ${i2}${o}
26324
+ ${c2}${n2}
25116
26325
  `;
25117
26326
  }
25118
26327
  case "submit": {
25119
- const n2 = l2 ? ` ${(0, import_node_util5.styleText)("dim", l2)}` : "", r2 = i2 ? (0, import_node_util5.styleText)("gray", S_BAR) : "";
25120
- return `${s}${r2}${n2}`;
26328
+ const n2 = s ? `${r2 ? " " : ""}${(0, import_node_util5.styleText)("dim", s)}` : "", i2 = r2 ? (0, import_node_util5.styleText)("gray", S_BAR) : "";
26329
+ return `${l}${i2}${n2}`;
25121
26330
  }
25122
26331
  case "cancel": {
25123
- const n2 = l2 ? ` ${(0, import_node_util5.styleText)(["strikethrough", "dim"], l2)}` : "", r2 = i2 ? (0, import_node_util5.styleText)("gray", S_BAR) : "";
25124
- return `${s}${r2}${n2}${l2.trim() ? `
25125
- ${r2}` : ""}`;
26332
+ const n2 = s ? ` ${(0, import_node_util5.styleText)(["strikethrough", "dim"], s)}` : "", i2 = r2 ? (0, import_node_util5.styleText)("gray", S_BAR) : "";
26333
+ return `${l}${i2}${n2}${s.trim() ? `
26334
+ ${i2}` : ""}`;
25126
26335
  }
25127
26336
  default: {
25128
- const n2 = i2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", r2 = i2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
25129
- return `${s}${n2}${o}
25130
- ${r2}
26337
+ const n2 = r2 ? `${(0, import_node_util5.styleText)("cyan", S_BAR)} ` : "", i2 = r2 ? (0, import_node_util5.styleText)("cyan", S_BAR_END) : "";
26338
+ return `${l}${n2}${o}
26339
+ ${i2}
25131
26340
  `;
25132
26341
  }
25133
26342
  }
@@ -25203,6 +26412,13 @@ async function saveDownload(config, options) {
25203
26412
  }
25204
26413
 
25205
26414
  // src/lib/json.ts
26415
+ function parseCreditCeiling(raw) {
26416
+ if (raw === void 0) return void 0;
26417
+ if (!raw.trim()) throw new CliError("--max-total-credits must be a non-negative number.");
26418
+ const value = Number(raw);
26419
+ validateCreditCeiling(value);
26420
+ return value;
26421
+ }
25206
26422
  function parseJsonObject(raw, flag) {
25207
26423
  if (raw === void 0) return void 0;
25208
26424
  let parsed;
@@ -25513,8 +26729,8 @@ function renderTable(rows, columns) {
25513
26729
  if (rows.length === 0) {
25514
26730
  return import_picocolors4.default.dim("(no results)");
25515
26731
  }
25516
- const headers = columns.map((c) => sanitizeTerminalText(c.header));
25517
- const body = rows.map((row) => columns.map((c) => formatCell(c.value(row))));
26732
+ const headers = columns.map((c2) => sanitizeTerminalText(c2.header));
26733
+ const body = rows.map((row) => columns.map((c2) => formatCell(c2.value(row))));
25518
26734
  const widths = headers.map((header, i2) => {
25519
26735
  const cellMax = body.reduce((max, cells) => Math.max(max, displayWidth(cells[i2] ?? "")), 0);
25520
26736
  return Math.max(displayWidth(header), cellMax);
@@ -25522,7 +26738,7 @@ function renderTable(rows, columns) {
25522
26738
  const pad = (text2, width) => text2 + " ".repeat(Math.max(0, width - displayWidth(text2)));
25523
26739
  const headerLine = headers.map((h2, i2) => import_picocolors4.default.bold(pad(h2, widths[i2] ?? 0))).join(" ");
25524
26740
  const lines = body.map(
25525
- (cells) => cells.map((c, i2) => pad(c, widths[i2] ?? 0)).join(" ").trimEnd()
26741
+ (cells) => cells.map((c2, i2) => pad(c2, widths[i2] ?? 0)).join(" ").trimEnd()
25526
26742
  );
25527
26743
  return [headerLine, ...lines].join("\n");
25528
26744
  }
@@ -25609,14 +26825,15 @@ var createCommand = addSignerRefOptions(
25609
26825
  new Command("create").description("Create a signing assignment for a document").argument("<documentId>", "Document ID")
25610
26826
  ).addOption(
25611
26827
  new Option("--method <method>", "virtual or collect").choices(["virtual", "collect"]).default("virtual")
25612
- ).option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option(
26828
+ ).option("--message <message>", "Message shown to signers").option("--max-total-credits <amount>", "Reject the send if its credit cost exceeds this amount").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option(
25613
26829
  "--entries <json>",
25614
26830
  `JSON array of field placement entries, required for --method collect (e.g. '[{"page_id":"p1","fields":[{"signer_id":"s1","field_id":"f1"}]}]')`
25615
26831
  ).action(async (documentId, opts, command) => {
25616
26832
  await runWithClient(command, async ({ client, config }) => {
25617
26833
  const payload = {
25618
26834
  method: opts.method,
25619
- signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds)
26835
+ signers: resolveAssignmentSignerRefs(opts.signers, opts.signerIds),
26836
+ max_total_credits: parseCreditCeiling(opts.maxTotalCredits)
25620
26837
  };
25621
26838
  if (opts.message) payload.message = opts.message;
25622
26839
  if (opts.expiresAt) payload.expires_at = opts.expiresAt;
@@ -25776,6 +26993,31 @@ var reviewIdentityCommand = new Command("review-identity").description("Approve
25776
26993
  });
25777
26994
  });
25778
26995
  var assignmentsCommand = new Command("assignments").description("Create and manage signing assignments").addCommand(listCommand).addCommand(createCommand).addCommand(estimateCostCommand).addCommand(resetExpirationCommand).addCommand(resendCommand).addCommand(estimateResendCostCommand).addCommand(whatsappCommand).addCommand(identityVerificationCommand).addCommand(identityImageCommand).addCommand(reviewIdentityCommand);
26996
+ assignmentsCommand.addCommand(
26997
+ new Command("schedule").description("Schedule an assignment without sending or charging now (staging)").argument("<documentId>", "Document ID").requiredOption("--data <json>", "Assignment JSON with send_at (ISO 8601 or Unix seconds)").action(async (id, opts, command) => {
26998
+ await runWithClient(command, async ({ client, config }) => {
26999
+ const payload = parseJsonObject(
27000
+ opts.data,
27001
+ "--data"
27002
+ );
27003
+ printData(await client.assignments.schedule(id, payload), config);
27004
+ });
27005
+ })
27006
+ );
27007
+ for (const [name, method] of [
27008
+ ["signer-capacities", "signerCapacities"],
27009
+ ["notification-history", "notificationHistory"]
27010
+ ]) {
27011
+ assignmentsCommand.addCommand(
27012
+ new Command(name).description(
27013
+ name === "signer-capacities" ? "Read the capacities signers were assigned (staging)" : "Read notification delivery/open times (staging)"
27014
+ ).argument("<documentId>", "Document ID").action(async (id, _opts, command) => {
27015
+ await runWithClient(command, async ({ client, config }) => {
27016
+ printData(await client.assignments[method](id), config);
27017
+ });
27018
+ })
27019
+ );
27020
+ }
25779
27021
 
25780
27022
  // src/commands/auth.ts
25781
27023
  function resetPasswordPayload(email, resetToken, newPassword) {
@@ -26236,9 +27478,16 @@ var setCommand2 = new Command("set").description("Set terms or link an amendment
26236
27478
  printData(await client.contracts.set(documentId, payload, requireAccountId(config)), config);
26237
27479
  });
26238
27480
  });
26239
- var relatedCommand = new Command("related").description("Read the root contract and every linked instrument").argument("<documentId>", "Contract or amendment document ID").action(async (documentId, _opts, command) => {
27481
+ var relatedCommand = new Command("related").description("Read the root contract and every linked instrument").argument("<documentId>", "Contract or amendment document ID").addOption(
27482
+ new Option("--expand <relation>", "Include document details").choices(["document"])
27483
+ ).action(async (documentId, opts, command) => {
26240
27484
  await runWithClient(command, async ({ client, config }) => {
26241
- printData(await client.contracts.related(documentId, requireAccountId(config)), config);
27485
+ printData(
27486
+ await client.contracts.related(documentId, requireAccountId(config), {
27487
+ expand: opts.expand
27488
+ }),
27489
+ config
27490
+ );
26242
27491
  });
26243
27492
  });
26244
27493
  var renewCommand = new Command("renew").description("Start the next term using the current term or a later end_date").argument("<documentId>", "Document ID").requiredOption("--data <json>", "JSON with term or end_date, optional value and updated_at").option("-y, --yes", "Skip confirmation").action(async (documentId, opts, command) => {
@@ -26268,7 +27517,7 @@ var contractsCommand = new Command("contracts").description("Track contract term
26268
27517
  var import_node_child_process2 = require("child_process");
26269
27518
  var import_node_crypto4 = require("crypto");
26270
27519
  var import_node_events2 = require("events");
26271
- var import_node_http = require("http");
27520
+ var import_node_http2 = require("http");
26272
27521
  var CLI_OAUTH_REDIRECT_URI = "https://integrations.assinafy.com.br/assinafy-cli/oauth-callback";
26273
27522
  var clearHistory = "history.replaceState(null, '', '/');";
26274
27523
  var brandOrigin = "https://integrations.assinafy.com.br";
@@ -26371,7 +27620,7 @@ async function connectOAuth(oauth, options, onAuthorize, timeoutMs = 18e4) {
26371
27620
  if (new URL(request.redirect_uri).search) {
26372
27621
  throw new CliError("The browser relay redirect URI must not contain query parameters.");
26373
27622
  }
26374
- const server = (0, import_node_http.createServer)({ maxHeaderSize: 8192, requestTimeout: 5e3, headersTimeout: 5e3 });
27623
+ const server = (0, import_node_http2.createServer)({ maxHeaderSize: 8192, requestTimeout: 5e3, headersTimeout: 5e3 });
26375
27624
  server.maxConnections = 8;
26376
27625
  server.setTimeout(5e3, (socket) => socket.destroy());
26377
27626
  let timer;
@@ -26496,11 +27745,11 @@ var listCommand4 = addListOptions(
26496
27745
  "virtual",
26497
27746
  "collect"
26498
27747
  ])
26499
- ).option("--tags <ids>", "Comma-separated tag IDs (AND semantics)")
27748
+ ).option("--tags <ids>", "Comma-separated tag IDs (AND semantics)").option("--envelope <id>", "Filter by envelope ID")
26500
27749
  ).action(async (opts, command) => {
26501
27750
  await runWithClient(command, async ({ client, config }) => {
26502
27751
  const accountId = requireAccountId(config);
26503
- const params = { ...listParams(opts) };
27752
+ const params = { ...listParams(opts), envelope_id: opts.envelope };
26504
27753
  if (opts.status) params.status = opts.status;
26505
27754
  if (opts.method) params.method = opts.method;
26506
27755
  if (opts.tags) params.tags = opts.tags;
@@ -26513,11 +27762,11 @@ var listCommand4 = addListOptions(
26513
27762
  });
26514
27763
  });
26515
27764
  var searchCommand = addListOptions(
26516
- new Command("search").description("Lightweight document search (type-ahead)").argument("[query]", "Search text (alias for --search)").option("--status <status>", "Filter by document status")
27765
+ new Command("search").description("Lightweight document search (type-ahead)").argument("[query]", "Search text (alias for --search)").option("--status <status>", "Filter by document status").option("--envelope <id>", "Filter by envelope ID")
26517
27766
  ).action(async (query, opts, command) => {
26518
27767
  await runWithClient(command, async ({ client, config }) => {
26519
27768
  const accountId = requireAccountId(config);
26520
- const params = { ...listParams(opts) };
27769
+ const params = { ...listParams(opts), envelope_id: opts.envelope };
26521
27770
  if (query) params.search = query;
26522
27771
  if (opts.status) params.status = opts.status;
26523
27772
  const result = await withSpinner(
@@ -26528,27 +27777,40 @@ var searchCommand = addListOptions(
26528
27777
  printPaginatedData(result, config, () => renderDocumentListTable(result));
26529
27778
  });
26530
27779
  });
26531
- var getCommand3 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").action(async (id, _opts, command) => {
26532
- await runWithClient(command, async ({ client, config }) => {
26533
- const doc = await withSpinner(
26534
- "Fetching document",
26535
- config,
26536
- () => client.documents.details(id)
26537
- );
26538
- printData(
26539
- doc,
26540
- config,
26541
- (d) => renderKeyValue({
26542
- id: d.id,
26543
- name: d.name,
26544
- status: d.status,
26545
- account_id: d.account_id,
26546
- created_at: d.created_at,
26547
- updated_at: d.updated_at,
26548
- is_closed: d.is_closed
26549
- })
26550
- );
26551
- });
27780
+ var getCommand3 = new Command("get").description("Show details for a document").argument("<id>", "Document ID").addOption(
27781
+ new Option("--access-code <code>", "Read as a signer instead of the owner").env(
27782
+ "ASSINAFY_SIGNER_ACCESS_CODE"
27783
+ )
27784
+ ).addOption(
27785
+ new Option("--expand <relation>", "Include envelope details").choices([
27786
+ "envelope",
27787
+ "envelope_id",
27788
+ "envelope,envelope_id"
27789
+ ])
27790
+ ).action(async (id, opts, command) => {
27791
+ await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
27792
+ command,
27793
+ async ({ client, config }) => {
27794
+ const doc = await withSpinner(
27795
+ "Fetching document",
27796
+ config,
27797
+ () => opts.accessCode === void 0 ? client.documents.details(id, { expand: opts.expand }) : client.documents.getAsSigner(id, opts.accessCode)
27798
+ );
27799
+ printData(
27800
+ doc,
27801
+ config,
27802
+ (d) => renderKeyValue({
27803
+ id: d.id,
27804
+ name: d.name,
27805
+ status: d.status,
27806
+ account_id: d.account_id,
27807
+ created_at: d.created_at,
27808
+ updated_at: d.updated_at,
27809
+ is_closed: d.is_closed
27810
+ })
27811
+ );
27812
+ }
27813
+ );
26552
27814
  });
26553
27815
  var renameCommand = new Command("rename").description("Rename a document (only before the signature process starts)").argument("<id>", "Document ID").argument("<name>", "New document name").action(async (id, name, _opts, command) => {
26554
27816
  await runWithClient(command, async ({ client, config }) => {
@@ -26562,49 +27824,80 @@ var renameCommand = new Command("rename").description("Rename a document (only b
26562
27824
  });
26563
27825
  });
26564
27826
  var downloadCommand = addDownloadOptions(
26565
- new Command("download").description("Download a document artifact").argument("<id>", "Document ID").option(
27827
+ new Command("download").description("Download a document artifact").argument("<id>", "Document ID").addOption(
27828
+ new Option("--access-code <code>", "Read as a signer instead of the owner").env(
27829
+ "ASSINAFY_SIGNER_ACCESS_CODE"
27830
+ )
27831
+ ).option(
26566
27832
  "--artifact <name>",
26567
27833
  "original | certificated | certificate-page | pades | bundle",
26568
27834
  "certificated"
26569
27835
  )
26570
27836
  ).action(async (id, opts, command) => {
26571
- await runWithClient(command, async ({ client, config }) => {
26572
- const artifact = requireDocumentArtifactName(opts.artifact);
26573
- await saveDownload(config, {
26574
- message: "Downloading document",
26575
- download: () => client.documents.download(id, artifact),
26576
- output: opts.output,
26577
- defaultName: defaultArtifactFilename(id, artifact),
26578
- force: opts.force,
26579
- data: { artifact }
26580
- });
26581
- });
27837
+ await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
27838
+ command,
27839
+ async ({ client, config }) => {
27840
+ const artifact = requireDocumentArtifactName(opts.artifact);
27841
+ await saveDownload(config, {
27842
+ message: "Downloading document",
27843
+ download: () => client.documents.download(id, artifact, { signerAccessCode: opts.accessCode }),
27844
+ output: opts.output,
27845
+ defaultName: defaultArtifactFilename(id, artifact),
27846
+ force: opts.force,
27847
+ data: { artifact }
27848
+ });
27849
+ }
27850
+ );
26582
27851
  });
26583
27852
  var thumbnailCommand = addDownloadOptions(
26584
- new Command("thumbnail").description("Download the document thumbnail (JPEG)").argument("<id>", "Document ID")
27853
+ new Command("thumbnail").description("Download the document thumbnail (JPEG)").addOption(
27854
+ new Option("--artifact <name>", "Use the signed PDF").choices(["certificated"])
27855
+ ).argument("<id>", "Document ID").addOption(
27856
+ new Option("--access-code <code>", "Read as a signer instead of the owner").env(
27857
+ "ASSINAFY_SIGNER_ACCESS_CODE"
27858
+ )
27859
+ )
26585
27860
  ).action(async (id, opts, command) => {
26586
- await runWithClient(command, async ({ client, config }) => {
26587
- await saveDownload(config, {
26588
- message: "Downloading thumbnail",
26589
- download: () => client.documents.thumbnail(id),
26590
- output: opts.output,
26591
- defaultName: defaultArtifactFilename(id, "thumbnail"),
26592
- force: opts.force
26593
- });
26594
- });
27861
+ await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
27862
+ command,
27863
+ async ({ client, config }) => {
27864
+ await saveDownload(config, {
27865
+ message: "Downloading thumbnail",
27866
+ download: () => client.documents.thumbnail(id, {
27867
+ artifact: opts.artifact,
27868
+ signerAccessCode: opts.accessCode
27869
+ }),
27870
+ output: opts.output,
27871
+ defaultName: defaultArtifactFilename(id, "thumbnail"),
27872
+ force: opts.force
27873
+ });
27874
+ }
27875
+ );
26595
27876
  });
26596
27877
  var downloadPageCommand = addDownloadOptions(
26597
- new Command("download-page").description("Download a single document page (JPEG)").argument("<id>", "Document ID").argument("<pageId>", "Page ID")
27878
+ new Command("download-page").description("Download a single document page (JPEG)").addOption(
27879
+ new Option("--artifact <name>", "Use the signed PDF").choices(["certificated"])
27880
+ ).argument("<id>", "Document ID").addOption(
27881
+ new Option("--access-code <code>", "Read as a signer instead of the owner").env(
27882
+ "ASSINAFY_SIGNER_ACCESS_CODE"
27883
+ )
27884
+ ).argument("<pageId>", "Page ID")
26598
27885
  ).action(async (id, pageId, opts, command) => {
26599
- await runWithClient(command, async ({ client, config }) => {
26600
- await saveDownload(config, {
26601
- message: "Downloading page",
26602
- download: () => client.documents.downloadPage(id, pageId),
26603
- output: opts.output,
26604
- defaultName: `${id}-page-${pageId}.jpg`,
26605
- force: opts.force
26606
- });
26607
- });
27886
+ await (opts.accessCode === void 0 ? runWithClient : runWithPublicClient)(
27887
+ command,
27888
+ async ({ client, config }) => {
27889
+ await saveDownload(config, {
27890
+ message: "Downloading page",
27891
+ download: () => client.documents.downloadPage(id, pageId, {
27892
+ artifact: opts.artifact,
27893
+ signerAccessCode: opts.accessCode
27894
+ }),
27895
+ output: opts.output,
27896
+ defaultName: `${id}-page-${pageId}.jpg`,
27897
+ force: opts.force
27898
+ });
27899
+ }
27900
+ );
26608
27901
  });
26609
27902
  var activitiesCommand = addSortableListOptions(
26610
27903
  new Command("activities").description("Show one page of the activity log for a document").argument("<id>", "Document ID"),
@@ -26691,7 +27984,7 @@ var tagsRemoveCommand = new Command("tags-remove").description("Detach a single
26691
27984
  printData(result, config);
26692
27985
  });
26693
27986
  });
26694
- var createFromTemplateCommand = new Command("create-from-template").description("Create a document from a template").argument("<templateId>", "Template ID").requiredOption(
27987
+ var createFromTemplateCommand = new Command("create-from-template").option("--idempotency-key <key>", "Creation key for recovering a lost response").option("--max-total-credits <amount>", "Reject creation if its credit cost exceeds this amount").description("Create a document from a template").argument("<templateId>", "Template ID").requiredOption(
26695
27988
  "--signers <json>",
26696
27989
  `JSON array of signers, e.g. '[{"role_id":"r","id":"s","verification_method":"Email","notification_methods":["Email"]}]'`
26697
27990
  ).option("--name <name>", "Document name").option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--tags <names>", "Comma-separated tag names to attach").option("--editor-fields <json>", "JSON array of editor field placements").action(async (templateId, opts, command) => {
@@ -26700,6 +27993,8 @@ var createFromTemplateCommand = new Command("create-from-template").description(
26700
27993
  const signers = parseJsonArray(opts.signers, "--signers");
26701
27994
  const editorFields = parseJsonArray(opts.editorFields, "--editor-fields");
26702
27995
  const options = stripEmpty({
27996
+ idempotencyKey: opts.idempotencyKey,
27997
+ max_total_credits: parseCreditCeiling(opts.maxTotalCredits),
26703
27998
  name: opts.name,
26704
27999
  message: opts.message,
26705
28000
  expires_at: opts.expiresAt,
@@ -26820,6 +28115,249 @@ var waitCommand = new Command("wait").description("Poll a document until it is r
26820
28115
  });
26821
28116
  });
26822
28117
  var documentsCommand = new Command("documents").description("Upload, list, download, and manage documents").addCommand(uploadCommand).addCommand(listCommand4).addCommand(searchCommand).addCommand(getCommand3).addCommand(renameCommand).addCommand(downloadCommand).addCommand(thumbnailCommand).addCommand(downloadPageCommand).addCommand(activitiesCommand).addCommand(deleteCommand).addCommand(tagsCommand).addCommand(tagsSetCommand).addCommand(tagsAddCommand).addCommand(tagsRemoveCommand).addCommand(createFromTemplateCommand).addCommand(estimateTemplateCostCommand).addCommand(verifyCommand).addCommand(statusesCommand).addCommand(publicCommand).addCommand(sendTokenCommand).addCommand(progressCommand).addCommand(waitCommand);
28118
+ documentsCommand.addCommand(
28119
+ new Command("watchers").description("List document watchers (staging; owner credentials required)").argument("<documentId>", "Document ID").action(async (id, _opts, command) => {
28120
+ await runWithClient(command, async ({ client, config }) => {
28121
+ printData(await client.documents.listWatchers(id), config);
28122
+ });
28123
+ })
28124
+ );
28125
+ documentsCommand.addCommand(
28126
+ new Command("set-watchers").description("Replace contacts notified when the document ends (staging)").argument("<documentId>", "Document ID").requiredOption("--watcher-ids <json>", "JSON array of contact IDs; [] removes all watchers").action(async (id, opts, command) => {
28127
+ await runWithClient(command, async ({ client, config }) => {
28128
+ printData(
28129
+ await client.documents.setWatchers(
28130
+ id,
28131
+ parseJsonArray(opts.watcherIds, "--watcher-ids")
28132
+ ),
28133
+ config
28134
+ );
28135
+ });
28136
+ })
28137
+ );
28138
+
28139
+ // src/commands/embed.ts
28140
+ var origins = new Command("origins").description("Manage origins allowed to embed signing pages");
28141
+ origins.addCommand(
28142
+ new Command("list").description("List allowed origins").action(async (_opts, command) => {
28143
+ await runWithClient(command, async ({ client, config }) => {
28144
+ printData(await client.embed.listOrigins(requireAccountId(config)), config);
28145
+ });
28146
+ })
28147
+ );
28148
+ origins.addCommand(
28149
+ new Command("create").description("Allow an exact origin").requiredOption("--origin <url>", "HTTPS origin (HTTP allowed for localhost/127.0.0.1)").action(async (opts, command) => {
28150
+ await runWithClient(command, async ({ client, config }) => {
28151
+ printData(await client.embed.createOrigin(opts.origin, requireAccountId(config)), config);
28152
+ });
28153
+ })
28154
+ );
28155
+ origins.addCommand(
28156
+ new Command("update").description("Replace an allowed origin").argument("<originId>", "Origin ID").requiredOption("--origin <url>", "New exact origin").action(async (id, opts, command) => {
28157
+ await runWithClient(command, async ({ client, config }) => {
28158
+ printData(
28159
+ await client.embed.updateOrigin(id, opts.origin, requireAccountId(config)),
28160
+ config
28161
+ );
28162
+ });
28163
+ })
28164
+ );
28165
+ origins.addCommand(
28166
+ new Command("delete").description("Remove an allowed origin").argument("<originId>", "Origin ID").option("-y, --yes", "Skip confirmation").action(async (id, opts, command) => {
28167
+ await runWithClient(command, async ({ client, config }) => {
28168
+ if (!await confirmDestructive(`Remove embed origin ${id}?`, Boolean(opts.yes))) return;
28169
+ printData(await client.embed.deleteOrigin(id, requireAccountId(config)), config);
28170
+ });
28171
+ })
28172
+ );
28173
+ var session = new Command("session").description("Mint a private iframe URL valid for five minutes").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").argument("<signerId>", "Signer ID").action(async (did, aid, sid, _opts, command) => {
28174
+ await runWithClient(command, async ({ client, config }) => {
28175
+ printData(await client.embed.createSession(did, aid, sid), config);
28176
+ });
28177
+ });
28178
+ var exchange = new Command("exchange").description("Consume a session token (Assinafy embed page operation)").addOption(
28179
+ new Option("--session-token <token>", "Private session token").env("ASSINAFY_EMBED_SESSION_TOKEN").makeOptionMandatory()
28180
+ ).option("--parent-origin <url>", "Origin hosting the iframe").action(async (opts, command) => {
28181
+ await runWithPublicClient(command, async ({ client, config }) => {
28182
+ printData(await client.embed.exchangeSession(opts.sessionToken, opts.parentOrigin), config);
28183
+ });
28184
+ });
28185
+ var embedCommand = new Command("embed").description("Embedded signing origins and sessions").addCommand(origins).addCommand(session).addCommand(exchange);
28186
+
28187
+ // src/commands/envelopes.ts
28188
+ var envelopesCommand = new Command("envelopes").description(
28189
+ "Send and manage groups of documents"
28190
+ );
28191
+ envelopesCommand.addCommand(
28192
+ addPaginationOptions(new Command("list").description("List workspace envelopes")).option("--search <text>", "Part of the envelope name").addOption(
28193
+ new Option("--status <status>", "Document lifecycle group").choices([
28194
+ "open",
28195
+ "closed"
28196
+ ])
28197
+ ).action(async (opts, command) => {
28198
+ await runWithClient(command, async ({ client, config }) => {
28199
+ printData(
28200
+ await client.envelopes.list(
28201
+ { ...listParams(opts), status: opts.status },
28202
+ requireAccountId(config)
28203
+ ),
28204
+ config
28205
+ );
28206
+ });
28207
+ })
28208
+ );
28209
+ for (const action of ["create", "estimate-cost"]) {
28210
+ const cmd = new Command(action).description(
28211
+ action === "create" ? "Create an envelope and send invitations" : "Estimate without sending or charging"
28212
+ ).requiredOption(
28213
+ "--data <json>",
28214
+ "Envelope JSON: name, signers, documents, optional max_total_credits"
28215
+ );
28216
+ if (action === "create")
28217
+ cmd.option("--idempotency-key <key>", "Creation key for recovering a lost response");
28218
+ envelopesCommand.addCommand(
28219
+ cmd.action(async (opts, command) => {
28220
+ await runWithClient(command, async ({ client, config }) => {
28221
+ const payload = parseJsonObject(opts.data, "--data");
28222
+ const accountId = requireAccountId(config);
28223
+ const result = action === "create" ? await client.envelopes.create(payload, {
28224
+ accountId,
28225
+ idempotencyKey: opts.idempotencyKey
28226
+ }) : await client.envelopes.estimateCost(payload, accountId);
28227
+ printData(result, config);
28228
+ });
28229
+ })
28230
+ );
28231
+ }
28232
+ envelopesCommand.addCommand(
28233
+ new Command("get").description("Read an envelope and its documents").argument("<envelopeId>", "Envelope ID").action(async (id, _opts, command) => {
28234
+ await runWithClient(command, async ({ client, config }) => {
28235
+ printData(await client.envelopes.get(id, requireAccountId(config)), config);
28236
+ });
28237
+ })
28238
+ );
28239
+ envelopesCommand.addCommand(
28240
+ new Command("update").description("Rename, change message, or reorder documents").argument("<envelopeId>", "Envelope ID").requiredOption("--data <json>", "Partial JSON: name, message (null clears), document_ids").action(async (id, opts, command) => {
28241
+ await runWithClient(command, async ({ client, config }) => {
28242
+ printData(
28243
+ await client.envelopes.update(
28244
+ id,
28245
+ parseJsonObject(opts.data, "--data"),
28246
+ requireAccountId(config)
28247
+ ),
28248
+ config
28249
+ );
28250
+ });
28251
+ })
28252
+ );
28253
+ for (const action of ["cancel", "delete"]) {
28254
+ envelopesCommand.addCommand(
28255
+ new Command(action).description(
28256
+ action === "cancel" ? "Cancel open documents and notify recipients" : "Delete a closed envelope, keeping its documents"
28257
+ ).argument("<envelopeId>", "Envelope ID").option("-y, --yes", "Skip confirmation").action(async (id, opts, command) => {
28258
+ await runWithClient(command, async ({ client, config }) => {
28259
+ if (!await confirmDestructive(`${action} envelope ${id}?`, Boolean(opts.yes))) return;
28260
+ printData(await client.envelopes[action](id, requireAccountId(config)), config);
28261
+ });
28262
+ })
28263
+ );
28264
+ }
28265
+ envelopesCommand.addCommand(
28266
+ addSortableListOptions(
28267
+ new Command("activities").description("Read a page of document activities").argument("<envelopeId>", "Envelope ID"),
28268
+ "id or -id"
28269
+ ).action(async (id, opts, command) => {
28270
+ await runWithClient(command, async ({ client, config }) => {
28271
+ printData(
28272
+ await client.envelopes.activities(id, listParams(opts), requireAccountId(config)),
28273
+ config
28274
+ );
28275
+ });
28276
+ })
28277
+ );
28278
+ envelopesCommand.addCommand(
28279
+ addDownloadOptions(
28280
+ new Command("download").description("Download a ZIP of document artifacts").argument("<envelopeId>", "Envelope ID")
28281
+ ).option(
28282
+ "--artifact <name>",
28283
+ "original, certificated, certificate-page, pades, bundle",
28284
+ "certificated"
28285
+ ).action(async (id, opts, command) => {
28286
+ await runWithClient(command, async ({ client, config }) => {
28287
+ const artifact = requireDocumentArtifactName(opts.artifact);
28288
+ await saveDownload(config, {
28289
+ message: "Downloading envelope",
28290
+ download: () => client.envelopes.download(id, artifact, requireAccountId(config)),
28291
+ output: opts.output,
28292
+ defaultName: `envelope-${id}-${artifact}.zip`,
28293
+ force: opts.force
28294
+ });
28295
+ });
28296
+ })
28297
+ );
28298
+ envelopesCommand.addCommand(
28299
+ new Command("resend").description("Resend one signer\u2019s envelope invitation; paid channels cost credits").argument("<envelopeId>", "Envelope ID").argument("<signerId>", "Signer ID").action(async (id, signerId, _opts, command) => {
28300
+ await runWithClient(command, async ({ client, config }) => {
28301
+ printData(
28302
+ await client.envelopes.resendNotification(id, signerId, requireAccountId(config)),
28303
+ config
28304
+ );
28305
+ });
28306
+ })
28307
+ );
28308
+ envelopesCommand.addCommand(
28309
+ new Command("add-document").description("Add a processed document and notify its envelope signers").argument("<envelopeId>", "Envelope ID").requiredOption(
28310
+ "--data <json>",
28311
+ "JSON: id, signer_ids, optional method, entries, expires_at, copy_receiver_ids, max_total_credits"
28312
+ ).action(async (id, opts, command) => {
28313
+ await runWithClient(command, async ({ client, config }) => {
28314
+ printData(
28315
+ await client.envelopes.addDocument(
28316
+ id,
28317
+ parseJsonObject(opts.data, "--data"),
28318
+ requireAccountId(config)
28319
+ ),
28320
+ config
28321
+ );
28322
+ });
28323
+ })
28324
+ );
28325
+ envelopesCommand.addCommand(
28326
+ new Command("remove-document").description("Cancel and remove an open document, notifying its recipients").argument("<envelopeId>", "Envelope ID").argument("<documentId>", "Document ID").option("-y, --yes", "Skip confirmation").action(async (id, documentId, opts, command) => {
28327
+ await runWithClient(command, async ({ client, config }) => {
28328
+ if (!await confirmDestructive(
28329
+ `Cancel and remove document ${documentId} from envelope ${id}?`,
28330
+ Boolean(opts.yes)
28331
+ ))
28332
+ return;
28333
+ printData(
28334
+ await client.envelopes.removeDocument(id, documentId, requireAccountId(config)),
28335
+ config
28336
+ );
28337
+ });
28338
+ })
28339
+ );
28340
+ envelopesCommand.addCommand(
28341
+ new Command("schedule").description("Schedule an envelope without sending or charging now (staging)").requiredOption("--data <json>", "Envelope JSON with send_at (ISO 8601 or Unix seconds)").action(async (opts, command) => {
28342
+ await runWithClient(command, async ({ client, config }) => {
28343
+ const payload = parseJsonObject(
28344
+ opts.data,
28345
+ "--data"
28346
+ );
28347
+ printData(await client.envelopes.schedule(payload, requireAccountId(config)), config);
28348
+ });
28349
+ })
28350
+ );
28351
+ envelopesCommand.addCommand(
28352
+ new Command("estimate-resend-cost").description("Estimate one envelope reminder without sending or charging (staging)").argument("<envelopeId>", "Envelope ID").argument("<signerId>", "Signer ID").action(async (id, signerId, _opts, command) => {
28353
+ await runWithClient(command, async ({ client, config }) => {
28354
+ printData(
28355
+ await client.envelopes.estimateResendCost(id, signerId, requireAccountId(config)),
28356
+ config
28357
+ );
28358
+ });
28359
+ })
28360
+ );
26823
28361
 
26824
28362
  // src/commands/fields.ts
26825
28363
  var fieldColumns = [
@@ -27138,6 +28676,37 @@ var userinfoCommand = new Command("userinfo").description("Read OIDC claims usin
27138
28676
  });
27139
28677
  var oauthCommand = new Command("oauth").description("OAuth 2.1 authorization, PKCE, token rotation, and OpenID Connect").addCommand(connectCommand).addCommand(metadataCommand).addCommand(discoveryCommand).addCommand(authorizeCommand).addCommand(exchangeCommand).addCommand(refreshCommand).addCommand(revokeCommand).addCommand(userinfoCommand);
27140
28678
 
28679
+ // src/commands/scheduled-sends.ts
28680
+ var scheduledSendsCommand = new Command("scheduled-sends").description(
28681
+ "List, cancel or send queued requests (staging)"
28682
+ );
28683
+ scheduledSendsCommand.addCommand(
28684
+ addPaginationOptions(new Command("list").description("List queued assignments and envelopes")).option("--document <id>", "Filter by document ID").action(async (opts, command) => {
28685
+ await runWithClient(command, async ({ client, config }) => {
28686
+ printData(
28687
+ await client.scheduledSends.list(
28688
+ { ...listParams(opts), document_id: opts.document },
28689
+ requireAccountId(config)
28690
+ ),
28691
+ config
28692
+ );
28693
+ });
28694
+ })
28695
+ );
28696
+ for (const action of ["cancel", "send"]) {
28697
+ scheduledSendsCommand.addCommand(
28698
+ new Command(action).description(
28699
+ action === "send" ? "Send now, charging the current cost and notifying signers" : "Cancel a pending request without sending"
28700
+ ).argument("<scheduledSendId>", "Scheduled send ID").option("-y, --yes", "Skip confirmation").action(async (id, opts, command) => {
28701
+ await runWithClient(command, async ({ client, config }) => {
28702
+ if (!await confirmDestructive(`${action} scheduled request ${id}?`, Boolean(opts.yes)))
28703
+ return;
28704
+ printData(await client.scheduledSends[action](id, requireAccountId(config)), config);
28705
+ });
28706
+ })
28707
+ );
28708
+ }
28709
+
27141
28710
  // src/commands/send.ts
27142
28711
  var phonePattern = /^\+?[\d\s().-]*\d[\d\s().-]*$/;
27143
28712
  function parseSignerSpec(spec) {
@@ -27172,7 +28741,10 @@ function resolveSigners(signerSpecs, signersJson) {
27172
28741
  }
27173
28742
  var sendCommand = new Command("send").description("Upload a PDF, create signers, and request signatures in one step").argument("<file>", "Path to the PDF file").addOption(
27174
28743
  new Option("--signer <spec>", 'Signer as "Name <email-or-phone>" (repeatable)').argParser(collect).default([]).conflicts("signers")
27175
- ).addOption(new Option("--signers <json>", "JSON array of signer objects").conflicts("signer")).option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option("--metadata <json>", "JSON object of metadata to attach to the document").option("--no-wait", "Do not wait for the document to finish processing").action(async (file, opts, command) => {
28744
+ ).addOption(new Option("--signers <json>", "JSON array of signer objects").conflicts("signer")).option(
28745
+ "--max-total-credits <amount>",
28746
+ "Reject the assignment if its credit cost exceeds this amount"
28747
+ ).option("--message <message>", "Message shown to signers").option("--expires-at <iso8601>", "Expiration timestamp").option("--copy-receivers <csv>", "Comma-separated signer IDs to receive a copy of the document").option("--metadata <json>", "JSON object of metadata to attach to the document").option("--no-wait", "Do not wait for the document to finish processing").action(async (file, opts, command) => {
27176
28748
  await runWithClient(command, async ({ client, config }) => {
27177
28749
  const accountId = requireAccountId(config);
27178
28750
  const signers = resolveSigners(opts.signer, opts.signers);
@@ -27183,6 +28755,7 @@ var sendCommand = new Command("send").description("Upload a PDF, create signers,
27183
28755
  waitForReady: opts.wait
27184
28756
  };
27185
28757
  if (opts.message) params.message = opts.message;
28758
+ params.maxTotalCredits = parseCreditCeiling(opts.maxTotalCredits);
27186
28759
  if (opts.expiresAt) params.expiresAt = opts.expiresAt;
27187
28760
  const cc = splitList(opts.copyReceivers);
27188
28761
  if (cc) params.copyReceivers = cc;
@@ -27216,24 +28789,32 @@ var optionalAccessCodeOption = () => new Option("--access-code <code>", "Signer
27216
28789
  "ASSINAFY_SIGNER_ACCESS_CODE"
27217
28790
  );
27218
28791
  var runSignerOrOwner = (accessCode) => accessCode === void 0 ? runWithClient : runWithPublicClient;
27219
- var documentCommand = new Command("document").description("Fetch the signer's current document").argument("<signerId>", "Signer ID").addOption(accessCodeOption()).action(async (signerId, opts, command) => {
28792
+ var documentCommand = new Command("document").description("Fetch the signer's current document").argument("<signerId>", "Signer ID").addOption(accessCodeOption()).addOption(
28793
+ new Option("--expand <relation>", "Include the envelope").choices(["envelope"])
28794
+ ).action(async (signerId, opts, command) => {
27220
28795
  await runWithPublicClient(command, async ({ client, config }) => {
27221
28796
  const doc = await withSpinner(
27222
28797
  "Fetching document",
27223
28798
  config,
27224
- () => client.signerDocuments.getCurrent(signerId, opts.accessCode)
28799
+ () => client.signerDocuments.getCurrent(signerId, opts.accessCode, { expand: opts.expand })
27225
28800
  );
27226
28801
  printData(doc, config, (d) => renderKeyValue({ id: d.id, name: d.name, status: d.status }));
27227
28802
  });
27228
28803
  });
27229
28804
  var documentsCommand2 = addListOptions(
27230
- new Command("documents").description("List the signer's documents").argument("<signerId>", "Signer ID").addOption(optionalAccessCodeOption())
28805
+ new Command("documents").description("List the signer's documents").option("--envelope <id>", "Filter by envelope ID").argument("<signerId>", "Signer ID").addOption(optionalAccessCodeOption())
27231
28806
  ).action(async (signerId, opts, command) => {
27232
28807
  await runSignerOrOwner(opts.accessCode)(command, async ({ client, config }) => {
27233
28808
  const result = await withSpinner(
27234
28809
  "Fetching documents",
27235
28810
  config,
27236
- () => opts.accessCode === void 0 ? client.signerDocuments.listAsOwner(signerId, listParams(opts)) : client.signerDocuments.list(signerId, opts.accessCode, listParams(opts))
28811
+ () => opts.accessCode === void 0 ? client.signerDocuments.listAsOwner(signerId, {
28812
+ ...listParams(opts),
28813
+ envelope_id: opts.envelope
28814
+ }) : client.signerDocuments.list(signerId, opts.accessCode, {
28815
+ ...listParams(opts),
28816
+ envelope_id: opts.envelope
28817
+ })
27237
28818
  );
27238
28819
  printPaginatedData(
27239
28820
  result,
@@ -27246,12 +28827,14 @@ var documentsCommand2 = addListOptions(
27246
28827
  );
27247
28828
  });
27248
28829
  });
27249
- var searchCommand2 = new Command("search").description("Search the signer's documents").argument("<signerId>", "Signer ID").argument("<query>", "Search text").addOption(optionalAccessCodeOption()).action(async (signerId, query, opts, command) => {
28830
+ var searchCommand2 = new Command("search").description("Search the signer's documents").option("--envelope <id>", "Filter by envelope ID").argument("<signerId>", "Signer ID").argument("<query>", "Search text").addOption(optionalAccessCodeOption()).action(async (signerId, query, opts, command) => {
27250
28831
  await runSignerOrOwner(opts.accessCode)(command, async ({ client, config }) => {
27251
28832
  const result = await withSpinner(
27252
28833
  "Searching documents",
27253
28834
  config,
27254
- () => opts.accessCode === void 0 ? client.signerDocuments.searchAsOwner(signerId, query) : client.signerDocuments.search(signerId, query, opts.accessCode)
28835
+ () => opts.accessCode === void 0 ? client.signerDocuments.searchAsOwner(signerId, query, { envelope_id: opts.envelope }) : client.signerDocuments.search(signerId, query, opts.accessCode, {
28836
+ envelope_id: opts.envelope
28837
+ })
27255
28838
  );
27256
28839
  printPaginatedData(
27257
28840
  result,
@@ -27265,8 +28848,8 @@ var searchCommand2 = new Command("search").description("Search the signer's docu
27265
28848
  });
27266
28849
  });
27267
28850
  var downloadCommand2 = addDownloadOptions(
27268
- new Command("download").description("Download a signer document artifact").argument("<signerId>", "Signer ID").argument("<documentId>", "Document ID").argument("<artifact>", "original | certificated | certificate-page | pades | bundle").addOption(
27269
- new Option("--access-code <code>", "Optional signer identity preflight code").env(
28851
+ new Command("download").description("Download the original with a signer code; use download-copy for certified files").argument("<signerId>", "Signer ID").argument("<documentId>", "Document ID").argument("<artifact>", "original | certificated | certificate-page | pades | bundle").addOption(
28852
+ new Option("--access-code <code>", "Signer access code (required by the current API)").env(
27270
28853
  "ASSINAFY_SIGNER_ACCESS_CODE"
27271
28854
  )
27272
28855
  )
@@ -27340,24 +28923,28 @@ var verifyCodeCommand = new Command("verify-code").alias("verify-email").descrip
27340
28923
  printData(result, config);
27341
28924
  });
27342
28925
  });
27343
- var certificateStartCommand = new Command("certificate-start").description("Start an ICP-Brasil A1/A3 signature and return the Web PKI token").addOption(accessCodeOption()).action(async (opts, command) => {
28926
+ var certificateStartCommand = new Command("certificate-start").option("--document-id <id>", "Select a document of the same envelope").description("Start an ICP-Brasil A1/A3 signature and return the Web PKI token").addOption(accessCodeOption()).action(async (opts, command) => {
27344
28927
  await runWithPublicClient(command, async ({ client, config }) => {
27345
28928
  const result = await withSpinner(
27346
28929
  "Starting certificate signature",
27347
28930
  config,
27348
- () => client.signerDocuments.startCertificate(opts.accessCode)
28931
+ () => client.signerDocuments.startCertificate(opts.accessCode, opts.documentId)
27349
28932
  );
27350
28933
  printData(result, config);
27351
28934
  });
27352
28935
  });
27353
- var certificateCompleteCommand = new Command("certificate-complete").description("Complete an ICP-Brasil A1/A3 signature after Web PKI has signed the token").addOption(accessCodeOption()).addOption(
28936
+ var certificateCompleteCommand = new Command("certificate-complete").option("--document-id <id>", "Select a document of the same envelope").description("Complete an ICP-Brasil A1/A3 signature after Web PKI has signed the token").addOption(accessCodeOption()).addOption(
27354
28937
  new Option("--certificate-token <token>", "Operation token returned by certificate-start").env("ASSINAFY_CERTIFICATE_TOKEN").makeOptionMandatory()
27355
28938
  ).action(async (opts, command) => {
27356
28939
  await runWithPublicClient(command, async ({ client, config }) => {
27357
28940
  const result = await withSpinner(
27358
28941
  "Completing certificate signature",
27359
28942
  config,
27360
- () => client.signerDocuments.completeCertificate(opts.accessCode, opts.certificateToken)
28943
+ () => client.signerDocuments.completeCertificate(
28944
+ opts.accessCode,
28945
+ opts.certificateToken,
28946
+ opts.documentId
28947
+ )
27361
28948
  );
27362
28949
  printSuccess("Certificate signature completed", config);
27363
28950
  printData(result, config);
@@ -27411,12 +28998,17 @@ var downloadSignatureCommand = addDownloadOptions(
27411
28998
  });
27412
28999
  });
27413
29000
  });
27414
- var assignmentCommand = new Command("assignment").description("Fetch the assignment as the signer sees it").addOption(accessCodeOption()).option("--accept-terms", "Pass has_accepted_terms=true").action(async (opts, command) => {
29001
+ var assignmentCommand = new Command("assignment").description("Fetch the assignment as the signer sees it").option("--document-id <id>", "Select another document of the same envelope").addOption(accessCodeOption()).option("--accept-terms", "Pass has_accepted_terms=true").addOption(
29002
+ new Option("--expand <relation>", "Include the envelope").choices(["envelope"])
29003
+ ).action(async (opts, command) => {
27415
29004
  await runWithPublicClient(command, async ({ client, config }) => {
27416
29005
  const result = await withSpinner(
27417
29006
  "Fetching assignment",
27418
29007
  config,
27419
- () => client.signerDocuments.getAssignment(opts.accessCode, opts.acceptTerms ? true : void 0)
29008
+ () => client.signerDocuments.getAssignment(opts.accessCode, opts.acceptTerms ? true : void 0, {
29009
+ expand: opts.expand,
29010
+ document_id: opts.documentId
29011
+ })
27420
29012
  );
27421
29013
  printData(result, config);
27422
29014
  });
@@ -27471,7 +29063,54 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
27471
29063
  printData(result, config);
27472
29064
  });
27473
29065
  });
27474
- var signerCommand = new Command("signer").description("Signer-side flows and public artifact downloads").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(identityStatusCommand).addCommand(identityStartCommand).addCommand(acceptTermsCommand).addCommand(verifyCodeCommand).addCommand(certificateStartCommand).addCommand(certificateCompleteCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
29066
+ var themeCommand = new Command("theme").description("Read the signing workspace brand").addOption(accessCodeOption()).action(async (opts, command) => {
29067
+ await runWithPublicClient(command, async ({ client, config }) => {
29068
+ printData(await client.signerDocuments.getTheme(opts.accessCode), config);
29069
+ });
29070
+ });
29071
+ var logoCommand = addDownloadOptions(
29072
+ new Command("logo").description("Download the signing workspace logo").addOption(accessCodeOption())
29073
+ ).action(async (opts, command) => {
29074
+ await runWithPublicClient(command, async ({ client, config }) => {
29075
+ await saveDownload(config, {
29076
+ message: "Downloading logo",
29077
+ download: () => client.signerDocuments.downloadLogo(opts.accessCode),
29078
+ output: opts.output,
29079
+ defaultName: "signing-logo",
29080
+ force: opts.force
29081
+ });
29082
+ });
29083
+ });
29084
+ var certifiedCopyCommand = new Command("certified-copy").description("Send a new certified-copy link to the original signing contact").addOption(accessCodeOption()).option("--document-id <id>", "Another document in the same envelope").action(async (opts, command) => {
29085
+ await runWithPublicClient(command, async ({ client, config }) => {
29086
+ printData(
29087
+ await client.signerDocuments.resendCertifiedCopy(opts.accessCode, opts.documentId),
29088
+ config
29089
+ );
29090
+ });
29091
+ });
29092
+ var downloadTokenOption = () => new Option("--download-token <token>", "Private certified-copy link token").env("ASSINAFY_DOWNLOAD_TOKEN").makeOptionMandatory();
29093
+ var downloadCopyCommand = addDownloadOptions(
29094
+ new Command("download-copy").description("Download a PDF using a certified-copy link token").addOption(downloadTokenOption())
29095
+ ).addOption(
29096
+ new Option("--artifact <name>", "PDF artifact").choices(["certificated", "pades"]).default("certificated")
29097
+ ).action(async (opts, command) => {
29098
+ await runWithPublicClient(command, async ({ client, config }) => {
29099
+ await saveDownload(config, {
29100
+ message: "Downloading certified copy",
29101
+ download: () => client.signerDocuments.downloadCertifiedCopy(opts.downloadToken, opts.artifact),
29102
+ output: opts.output,
29103
+ defaultName: `${opts.artifact}.pdf`,
29104
+ force: opts.force
29105
+ });
29106
+ });
29107
+ });
29108
+ var resendCopyCommand = new Command("resend-download-link").description("Send a new link using an expired download token").addOption(downloadTokenOption()).action(async (opts, command) => {
29109
+ await runWithPublicClient(command, async ({ client, config }) => {
29110
+ printData(await client.signerDocuments.resendDownloadLink(opts.downloadToken), config);
29111
+ });
29112
+ });
29113
+ var signerCommand = new Command("signer").addCommand(themeCommand).addCommand(logoCommand).addCommand(certifiedCopyCommand).addCommand(downloadCopyCommand).addCommand(resendCopyCommand).description("Signer-side flows and public artifact downloads").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(identityStatusCommand).addCommand(identityStartCommand).addCommand(acceptTermsCommand).addCommand(verifyCodeCommand).addCommand(certificateStartCommand).addCommand(certificateCompleteCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
27475
29114
 
27476
29115
  // src/commands/signers.ts
27477
29116
  var signerColumns = [
@@ -27547,9 +29186,9 @@ var updateCommand2 = new Command("update").description("Update a signer").argume
27547
29186
  await runWithClient(command, async ({ client, config }) => {
27548
29187
  const accountId = requireAccountId(config);
27549
29188
  const payload = {};
27550
- if (opts.name) payload.full_name = opts.name;
27551
- if (opts.email) payload.email = opts.email;
27552
- if (opts.phone) payload.whatsapp_phone_number = opts.phone;
29189
+ if (opts.name !== void 0) payload.full_name = opts.name;
29190
+ if (opts.email !== void 0) payload.email = opts.email;
29191
+ if (opts.phone !== void 0) payload.whatsapp_phone_number = opts.phone;
27553
29192
  if (opts.cpf) payload.cpf = opts.cpf;
27554
29193
  if (opts.governmentId !== void 0) payload.government_id = opts.governmentId;
27555
29194
  const signer = await withSpinner(
@@ -27771,7 +29410,25 @@ var preferencesUpdateCommand = new Command("update").description("Merge one or m
27771
29410
  });
27772
29411
  });
27773
29412
  var preferencesCommand = new Command("notification-preferences").alias("preferences").description("Manage owner-facing email notification preferences").addCommand(preferencesGetCommand).addCommand(preferencesUpdateCommand);
27774
- var usersCommand = new Command("users").description("Show the authenticated user and personal preferences").addCommand(selfCommand2).addCommand(statsCommand).addCommand(preferencesCommand);
29413
+ var pushPreferences = new Command("push-preferences").description("Manage mobile push notification preferences").addCommand(
29414
+ new Command("get").description("Read push preferences").action(async (_opts, command) => {
29415
+ await runWithClient(command, async ({ client, config }) => {
29416
+ printData(await client.users.getPushPreferences(), config);
29417
+ });
29418
+ })
29419
+ ).addCommand(
29420
+ new Command("update").description("Merge push preference booleans").requiredOption("--set <json>", "Partial map of notification codes to booleans").action(async (opts, command) => {
29421
+ await runWithClient(command, async ({ client, config }) => {
29422
+ printData(
29423
+ await client.users.updatePushPreferences(
29424
+ parseJsonObject(opts.set, "--set")
29425
+ ),
29426
+ config
29427
+ );
29428
+ });
29429
+ })
29430
+ );
29431
+ var usersCommand = new Command("users").description("Show the authenticated user and personal preferences").addCommand(selfCommand2).addCommand(statsCommand).addCommand(preferencesCommand).addCommand(pushPreferences);
27775
29432
 
27776
29433
  // src/commands/webhooks.ts
27777
29434
  var registerCommand = new Command("register").description("Register (or replace) the account's oldest webhook endpoint").requiredOption("--url <url>", "Endpoint URL to receive events").requiredOption("--email <email>", "Contact email for delivery problems").option("--events <csv>", "Comma-separated event names (defaults to a sensible set)").option("--inactive", "Register the subscription as inactive").action(async (opts, command) => {
@@ -28029,21 +29686,23 @@ var endpointsSecretCommand = new Command("secret").description(
28029
29686
  printData(result, config, (r2) => r2.secret);
28030
29687
  });
28031
29688
  });
28032
- var endpointsRotateSecretCommand = new Command("rotate-secret").description("Replace the endpoint signing secret; the old one stops working immediately").argument("<endpointId>", "Endpoint ID").option("-y, --yes", "Skip the confirmation prompt").action(async (endpointId, opts, command) => {
29689
+ var endpointsRotateSecretCommand = new Command("rotate-secret").description("Replace the endpoint signing secret").option("--keep-previous", "Keep the replaced secret signing for 24 hours").argument("<endpointId>", "Endpoint ID").option("-y, --yes", "Skip the confirmation prompt").action(async (endpointId, opts, command) => {
28033
29690
  await runWithClient(command, async ({ client, config }) => {
28034
29691
  const accountId = requireAccountId(config);
28035
29692
  if (!await confirmDestructive(
28036
- `Rotate the signing secret of ${endpointId}? The current secret stops working immediately.`,
29693
+ `Rotate the signing secret of ${endpointId}? ${opts.keepPrevious ? "The current secret stays valid for 24 hours." : "The current secret stops working immediately."}`,
28037
29694
  Boolean(opts.yes)
28038
29695
  ))
28039
29696
  return;
28040
29697
  const result = await withSpinner(
28041
29698
  "Rotating secret",
28042
29699
  config,
28043
- () => client.webhooks.rotateEndpointSecret(endpointId, accountId)
29700
+ () => client.webhooks.rotateEndpointSecret(endpointId, accountId, {
29701
+ keep_previous: opts.keepPrevious
29702
+ })
28044
29703
  );
28045
29704
  printSuccess("Signing secret rotated", config);
28046
- printData(result, config, (r2) => r2.secret);
29705
+ printData(result, config);
28047
29706
  });
28048
29707
  });
28049
29708
  var verifyCommand2 = new Command("verify").description(
@@ -28071,7 +29730,13 @@ var verifyCommand2 = new Command("verify").description(
28071
29730
  printData({ valid, id: opts.id }, config, () => "valid");
28072
29731
  });
28073
29732
  });
28074
- var endpointsCommand = new Command("endpoints").description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsDeleteByUrlCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
29733
+ var endpointsCommand = new Command("endpoints").addCommand(
29734
+ new Command("test").description("Send one webhook_test, even if inactive or paused").argument("<endpointId>", "Webhook endpoint ID").action(async (id, _opts, command) => {
29735
+ await runWithClient(command, async ({ client, config }) => {
29736
+ printData(await client.webhooks.testEndpoint(id, requireAccountId(config)), config);
29737
+ });
29738
+ })
29739
+ ).description("Manage webhook endpoints and their signing secrets").addCommand(endpointsListCommand).addCommand(endpointsCreateCommand).addCommand(endpointsGetCommand).addCommand(endpointsUpdateCommand).addCommand(endpointsDeleteCommand).addCommand(endpointsDeleteByUrlCommand).addCommand(endpointsSecretCommand).addCommand(endpointsRotateSecretCommand);
28075
29740
  var webhooksCommand = new Command("webhooks").description("Manage webhook endpoints, the primary subscription, and delivery history").addCommand(endpointsCommand).addCommand(registerCommand).addCommand(getCommand7).addCommand(inactivateCommand).addCommand(eventTypesCommand).addCommand(dispatchesCommand).addCommand(retryCommand).addCommand(verifyCommand2);
28076
29741
 
28077
29742
  // src/commands/whoami.ts
@@ -28137,12 +29802,16 @@ var listCommand9 = new Command("list").description("List workspaces you can acce
28137
29802
  );
28138
29803
  });
28139
29804
  });
28140
- var getCommand8 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
29805
+ var getCommand8 = new Command("get").description("Show a workspace by ID").argument("<id>", "Account/workspace ID").addOption(
29806
+ new Option("--expand <relation>", "Include signing feature flags").choices([
29807
+ "signing_features"
29808
+ ])
29809
+ ).action(async (id, opts, command) => {
28141
29810
  await runWithClient(command, async ({ client, config }) => {
28142
29811
  const workspace = await withSpinner(
28143
29812
  "Fetching workspace",
28144
29813
  config,
28145
- () => client.workspaces.get(id)
29814
+ () => client.workspaces.get(id, { expand: opts.expand })
28146
29815
  );
28147
29816
  printData(workspace, config, (w) => renderKeyValue(w));
28148
29817
  });
@@ -28168,7 +29837,7 @@ var updateCommand4 = new Command("update").description("Update a workspace").arg
28168
29837
  printData(workspace, config, (w) => renderKeyValue({ id: w.id, name: w.name }));
28169
29838
  });
28170
29839
  });
28171
- var themeCommand = new Command("theme").description("Show public branding for a workspace").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
29840
+ var themeCommand2 = new Command("theme").description("Show public branding for a workspace").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
28172
29841
  await runWithClient(command, async ({ client, config }) => {
28173
29842
  const theme = await withSpinner(
28174
29843
  "Fetching workspace theme",
@@ -28235,7 +29904,7 @@ var logoDeleteCommand = new Command("delete").alias("rm").description("Delete th
28235
29904
  printData({ deleted: true, account_id: id }, config);
28236
29905
  });
28237
29906
  });
28238
- var logoCommand = new Command("logo").description("Manage a workspace logo").addCommand(logoDownloadCommand).addCommand(logoUploadCommand).addCommand(logoDeleteCommand);
29907
+ var logoCommand2 = new Command("logo").description("Manage a workspace logo").addCommand(logoDownloadCommand).addCommand(logoUploadCommand).addCommand(logoDeleteCommand);
28239
29908
  var deleteCommand5 = new Command("delete").alias("rm").description("Delete a workspace").argument("<id>", "Account/workspace ID").option("--force", "Cancel an active paid subscription automatically and delete anyway").option("-y, --yes", "Skip the confirmation prompt").action(async (id, opts, command) => {
28240
29909
  await runWithClient(command, async ({ client, config }) => {
28241
29910
  if (!await confirmDestructive(`Delete workspace ${id}?`, Boolean(opts.yes))) return;
@@ -28248,7 +29917,34 @@ var deleteCommand5 = new Command("delete").alias("rm").description("Delete a wor
28248
29917
  printData({ deleted: id }, config);
28249
29918
  });
28250
29919
  });
28251
- var workspacesCommand = new Command("workspaces").alias("accounts").description("Manage workspaces (accounts)").addCommand(createCommand5).addCommand(listCommand9).addCommand(getCommand8).addCommand(themeCommand).addCommand(statsCommand2).addCommand(logoCommand).addCommand(updateCommand4).addCommand(deleteCommand5);
29920
+ var usageCommand = new Command("usage").description("Read plan allowances and balances").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
29921
+ await runWithClient(command, async ({ client, config }) => {
29922
+ printData(await client.workspaces.usage(id), config);
29923
+ });
29924
+ });
29925
+ var policyCommand = new Command("notification-policy").description("Workspace-wide notification rules").addCommand(
29926
+ new Command("get").description("Read the policy").argument("<id>", "Account/workspace ID").action(async (id, _opts, command) => {
29927
+ await runWithClient(command, async ({ client, config }) => {
29928
+ printData(await client.workspaces.getNotificationPolicy(id), config);
29929
+ });
29930
+ })
29931
+ ).addCommand(
29932
+ new Command("update").description("Merge policy fields (workspace owners only)").argument("<id>", "Account/workspace ID").requiredOption("--data <json>", "Partial JSON: events and/or owners_receive_all").action(async (id, opts, command) => {
29933
+ await runWithClient(command, async ({ client, config }) => {
29934
+ printData(
29935
+ await client.workspaces.updateNotificationPolicy(
29936
+ id,
29937
+ parseJsonObject(
29938
+ opts.data,
29939
+ "--data"
29940
+ )
29941
+ ),
29942
+ config
29943
+ );
29944
+ });
29945
+ })
29946
+ );
29947
+ var workspacesCommand = new Command("workspaces").addCommand(usageCommand).addCommand(policyCommand).alias("accounts").description("Manage workspaces (accounts)").addCommand(createCommand5).addCommand(listCommand9).addCommand(getCommand8).addCommand(themeCommand2).addCommand(statsCommand2).addCommand(logoCommand2).addCommand(updateCommand4).addCommand(deleteCommand5);
28252
29948
  function logoContentType(file) {
28253
29949
  return {
28254
29950
  ".gif": "image/gif",
@@ -28295,7 +29991,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
28295
29991
  // package.json
28296
29992
  var package_default = {
28297
29993
  name: "@assinafy/cli",
28298
- version: "2.7.1",
29994
+ version: "2.9.1",
28299
29995
  description: "The official command-line interface for the Assinafy digital-signature API",
28300
29996
  license: "MIT",
28301
29997
  type: "module",
@@ -28369,7 +30065,7 @@ var package_default = {
28369
30065
  prepublishOnly: "npm run typecheck && npm run lint && npm run test && npm run build && npm run verify:bundle"
28370
30066
  },
28371
30067
  dependencies: {
28372
- "@types/node": "^22.20.1",
30068
+ "@types/node": "^26.6.6",
28373
30069
  axios: "^1.20.0"
28374
30070
  },
28375
30071
  devDependencies: {
@@ -28378,10 +30074,10 @@ var package_default = {
28378
30074
  "@commander-js/extra-typings": "^15.0.0",
28379
30075
  commander: "^15.0.0",
28380
30076
  picocolors: "^1.1.1",
28381
- tsup: "^8.3.5",
30077
+ tsup: "^9.0.0",
28382
30078
  tsx: "^4.23.12",
28383
30079
  typescript: "^7.0.2",
28384
- vitest: "^4.1.12"
30080
+ vitest: "^5.1.0"
28385
30081
  },
28386
30082
  overrides: {
28387
30083
  esbuild: "^0.28.2"
@@ -28411,7 +30107,7 @@ ${import_picocolors7.default.gray("Examples:")}
28411
30107
 
28412
30108
  ${import_picocolors7.default.gray("Sandbox:")} target it with ${import_picocolors7.default.blue("--base-url https://sandbox.assinafy.com.br/v1")}
28413
30109
  `
28414
- ).addCommand(sendCommand).addCommand(documentsCommand).addCommand(contractsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
30110
+ ).addCommand(sendCommand).addCommand(documentsCommand).addCommand(envelopesCommand).addCommand(embedCommand).addCommand(contractsCommand).addCommand(signersCommand).addCommand(assignmentsCommand).addCommand(scheduledSendsCommand).addCommand(templatesCommand).addCommand(tagsCommand2).addCommand(fieldsCommand).addCommand(webhooksCommand).addCommand(workspacesCommand).addCommand(usersCommand).addCommand(signerCommand).addCommand(authCommand).addCommand(oauthCommand).addCommand(loginCommand2).addCommand(logoutCommand).addCommand(whoamiCommand).addCommand(configCommand).addCommand(docsCommand);
28415
30111
  program2.parseAsync().catch((err) => {
28416
30112
  process.stderr.write(
28417
30113
  `${import_picocolors7.default.red("error:")} ${sanitizeTerminalText(err instanceof Error ? err.message : String(err))}