@assinafy/cli 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -15467,22 +15467,82 @@ var { toString } = Object.prototype;
15467
15467
  var { getPrototypeOf } = Object;
15468
15468
  var { iterator, toStringTag } = Symbol;
15469
15469
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
15470
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
15471
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
15472
+ var isSafeAndFullyMutable = (obj) => {
15473
+ if (!Object.isExtensible(obj)) {
15474
+ return false;
15475
+ }
15476
+ const props = Object.getOwnPropertyNames(obj);
15477
+ if (Object.getOwnPropertySymbols) {
15478
+ props.push(...Object.getOwnPropertySymbols(obj));
15479
+ }
15480
+ return props.every((prop) => {
15481
+ if (isUnsafeObjectKey(prop)) {
15482
+ return false;
15483
+ }
15484
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
15485
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
15486
+ });
15487
+ };
15470
15488
  var hasOwnInPrototypeChain = (thing, prop) => {
15471
15489
  let obj = thing;
15472
15490
  const seen = [];
15473
- while (obj != null && obj !== Object.prototype) {
15491
+ while (obj != null) {
15474
15492
  if (seen.indexOf(obj) !== -1) {
15475
15493
  return false;
15476
15494
  }
15477
15495
  seen.push(obj);
15496
+ const prototype2 = getPrototypeOf(obj);
15497
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
15498
+ return false;
15499
+ }
15478
15500
  if (hasOwnProperty(obj, prop)) {
15479
15501
  return true;
15480
15502
  }
15481
- obj = getPrototypeOf(obj);
15503
+ obj = prototype2;
15482
15504
  }
15483
15505
  return false;
15484
15506
  };
15485
15507
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
15508
+ var toSafeFlatObject = (thing) => {
15509
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
15510
+ return thing;
15511
+ }
15512
+ const sourcePrototype = getPrototypeOf(thing);
15513
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
15514
+ return thing;
15515
+ }
15516
+ const result = /* @__PURE__ */ Object.create(null);
15517
+ const merged = /* @__PURE__ */ Object.create(null);
15518
+ const seen = [];
15519
+ let current = thing;
15520
+ while (current != null) {
15521
+ if (seen.indexOf(current) !== -1) {
15522
+ break;
15523
+ }
15524
+ seen.push(current);
15525
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
15526
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
15527
+ break;
15528
+ }
15529
+ const props = Object.getOwnPropertyNames(current);
15530
+ if (Object.getOwnPropertySymbols) {
15531
+ props.push(...Object.getOwnPropertySymbols(current));
15532
+ }
15533
+ for (const prop of props) {
15534
+ if (isUnsafeObjectKey(prop)) {
15535
+ continue;
15536
+ }
15537
+ if (!hasOwnProperty(merged, prop)) {
15538
+ result[prop] = thing[prop];
15539
+ merged[prop] = true;
15540
+ }
15541
+ }
15542
+ current = prototype2;
15543
+ }
15544
+ return result;
15545
+ };
15486
15546
  var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
15487
15547
  const str = toString.call(thing);
15488
15548
  return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
@@ -15517,9 +15577,9 @@ var isPlainObject = (val) => {
15517
15577
  return false;
15518
15578
  }
15519
15579
  const prototype2 = getPrototypeOf(val);
15520
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
15521
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
15522
- // than a plain object, while ignoring keys injected onto Object.prototype.
15580
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
15581
+ // evidence the value is tagged/iterable, while ignoring members reachable
15582
+ // only through shared or terminal prototype boundaries.
15523
15583
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
15524
15584
  };
15525
15585
  var isEmptyObject = (val) => {
@@ -15930,6 +15990,7 @@ var utils_default = {
15930
15990
  // an alias to avoid ESLint no-prototype-builtins detection
15931
15991
  hasOwnInPrototypeChain,
15932
15992
  getSafeProp,
15993
+ toSafeFlatObject,
15933
15994
  reduceDescriptors,
15934
15995
  freezeMethods,
15935
15996
  toObjectSet,
@@ -16568,24 +16629,16 @@ function toFormData(obj, formData, options) {
16568
16629
  throw new TypeError("target must be an object");
16569
16630
  }
16570
16631
  formData = formData || new (FormData_default || FormData)();
16571
- options = utils_default.toFlatObject(
16572
- options,
16573
- {
16574
- metaTokens: true,
16575
- dots: false,
16576
- indexes: false
16577
- },
16578
- false,
16579
- function defined(option, source) {
16580
- return !utils_default.isUndefined(source[option]);
16581
- }
16582
- );
16583
- const metaTokens = options.metaTokens;
16584
- const visitor = options.visitor || defaultVisitor;
16585
- const dots = options.dots;
16586
- const indexes = options.indexes;
16587
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
16588
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
16632
+ const option = (name, fallback) => {
16633
+ const value = utils_default.getSafeProp(options, name);
16634
+ return utils_default.isUndefined(value) ? fallback : value;
16635
+ };
16636
+ const metaTokens = option("metaTokens", true);
16637
+ const visitor = option("visitor") || defaultVisitor;
16638
+ const dots = option("dots", false);
16639
+ const indexes = option("indexes", false);
16640
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
16641
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
16589
16642
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
16590
16643
  const stack = [];
16591
16644
  if (!utils_default.isFunction(visitor)) {
@@ -16609,7 +16662,10 @@ function toFormData(obj, formData, options) {
16609
16662
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
16610
16663
  return Buffer_default.from(value);
16611
16664
  }
16612
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
16665
+ throw new AxiosError_default(
16666
+ "Blob is not supported. Use a Buffer instead.",
16667
+ AxiosError_default.ERR_NOT_SUPPORT
16668
+ );
16613
16669
  }
16614
16670
  return value;
16615
16671
  }
@@ -16755,9 +16811,47 @@ function buildURL(url2, params, options) {
16755
16811
  }
16756
16812
 
16757
16813
  // node_modules/axios/lib/core/InterceptorManager.js
16814
+ var $internals2 = /* @__PURE__ */ Symbol("internals");
16815
+ function countHandlers(handlers) {
16816
+ return handlers ? handlers.length : 0;
16817
+ }
16818
+ function trimHandlers(handlers) {
16819
+ if (!handlers) {
16820
+ return;
16821
+ }
16822
+ while (handlers.length && handlers[handlers.length - 1] === null) {
16823
+ handlers.pop();
16824
+ }
16825
+ }
16826
+ function syncHandlerEntries(manager, internals) {
16827
+ const handlers = manager.handlers;
16828
+ const length = countHandlers(handlers);
16829
+ if (handlers !== internals.handlersRef) {
16830
+ internals.handlersRef = handlers;
16831
+ internals.handlerEntries.clear();
16832
+ } else if (length !== internals.handlersLength) {
16833
+ if (!length) {
16834
+ internals.handlerEntries.clear();
16835
+ } else {
16836
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
16837
+ if (handlers[entry.index] !== entry.handler) {
16838
+ internals.handlerEntries.delete(id);
16839
+ }
16840
+ });
16841
+ }
16842
+ }
16843
+ internals.handlersLength = length;
16844
+ }
16758
16845
  var InterceptorManager = class {
16759
16846
  constructor() {
16760
16847
  this.handlers = [];
16848
+ this[$internals2] = {
16849
+ handlersRef: this.handlers,
16850
+ handlersLength: this.handlers.length,
16851
+ handlerEntries: /* @__PURE__ */ new Map(),
16852
+ iterationDepth: 0,
16853
+ nextId: 0
16854
+ };
16761
16855
  }
16762
16856
  /**
16763
16857
  * Add a new interceptor to the stack
@@ -16769,13 +16863,25 @@ var InterceptorManager = class {
16769
16863
  * @return {Number} An ID used to remove interceptor later
16770
16864
  */
16771
16865
  use(fulfilled, rejected, options) {
16772
- this.handlers.push({
16866
+ const handler = {
16773
16867
  fulfilled,
16774
16868
  rejected,
16775
16869
  synchronous: options ? options.synchronous : false,
16776
16870
  runWhen: options ? options.runWhen : null
16871
+ };
16872
+ const internals = this[$internals2];
16873
+ if (this.handlers == null) {
16874
+ this.handlers = [];
16875
+ }
16876
+ syncHandlerEntries(this, internals);
16877
+ const id = internals.nextId++;
16878
+ this.handlers.push(handler);
16879
+ internals.handlerEntries.set(id, {
16880
+ handler,
16881
+ index: this.handlers.length - 1
16777
16882
  });
16778
- return this.handlers.length - 1;
16883
+ internals.handlersLength = this.handlers.length;
16884
+ return id;
16779
16885
  }
16780
16886
  /**
16781
16887
  * Remove an interceptor from the stack
@@ -16785,8 +16891,19 @@ var InterceptorManager = class {
16785
16891
  * @returns {void}
16786
16892
  */
16787
16893
  eject(id) {
16788
- if (this.handlers[id]) {
16789
- this.handlers[id] = null;
16894
+ const internals = this[$internals2];
16895
+ syncHandlerEntries(this, internals);
16896
+ const entry = internals.handlerEntries.get(id);
16897
+ if (entry) {
16898
+ internals.handlerEntries.delete(id);
16899
+ if (this.handlers[entry.index] !== entry.handler) {
16900
+ return;
16901
+ }
16902
+ this.handlers[entry.index] = null;
16903
+ if (!internals.iterationDepth) {
16904
+ trimHandlers(this.handlers);
16905
+ internals.handlersLength = this.handlers.length;
16906
+ }
16790
16907
  }
16791
16908
  }
16792
16909
  /**
@@ -16797,6 +16914,7 @@ var InterceptorManager = class {
16797
16914
  clear() {
16798
16915
  if (this.handlers) {
16799
16916
  this.handlers = [];
16917
+ syncHandlerEntries(this, this[$internals2]);
16800
16918
  }
16801
16919
  }
16802
16920
  /**
@@ -16810,11 +16928,22 @@ var InterceptorManager = class {
16810
16928
  * @returns {void}
16811
16929
  */
16812
16930
  forEach(fn) {
16813
- utils_default.forEach(this.handlers, function forEachHandler(h2) {
16814
- if (h2 !== null) {
16815
- fn(h2);
16931
+ const internals = this[$internals2];
16932
+ syncHandlerEntries(this, internals);
16933
+ internals.iterationDepth++;
16934
+ try {
16935
+ utils_default.forEach(this.handlers, function forEachHandler(h2) {
16936
+ if (h2 !== null) {
16937
+ fn(h2);
16938
+ }
16939
+ });
16940
+ } finally {
16941
+ if (!--internals.iterationDepth) {
16942
+ syncHandlerEntries(this, internals);
16943
+ trimHandlers(this.handlers);
16944
+ internals.handlersLength = countHandlers(this.handlers);
16816
16945
  }
16817
- });
16946
+ }
16818
16947
  }
16819
16948
  };
16820
16949
  var InterceptorManager_default = InterceptorManager;
@@ -16972,6 +17101,22 @@ function formDataToJSON(formData) {
16972
17101
  }
16973
17102
  var formDataToJSON_default = formDataToJSON;
16974
17103
 
17104
+ // node_modules/axios/lib/core/methodList.js
17105
+ var methodList = Object.freeze([
17106
+ "get",
17107
+ "delete",
17108
+ "head",
17109
+ "options",
17110
+ "post",
17111
+ "put",
17112
+ "patch",
17113
+ "purge",
17114
+ "link",
17115
+ "unlink",
17116
+ "query"
17117
+ ]);
17118
+ var methodList_default = methodList;
17119
+
16975
17120
  // node_modules/axios/lib/defaults/index.js
16976
17121
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
16977
17122
  function stringifySafely2(rawValue, parser, encoder) {
@@ -17084,7 +17229,7 @@ var defaults = {
17084
17229
  }
17085
17230
  }
17086
17231
  };
17087
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
17232
+ utils_default.forEach(methodList_default, (method) => {
17088
17233
  defaults.headers[method] = {};
17089
17234
  });
17090
17235
  var defaults_default = defaults;
@@ -17162,19 +17307,21 @@ function combineURLs(baseURL, relativeURL) {
17162
17307
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
17163
17308
  }
17164
17309
 
17165
- // node_modules/axios/lib/core/buildFullPath.js
17166
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
17167
- var httpProtocolControlCharacters = /[\t\n\r]/g;
17168
- function stripLeadingC0ControlOrSpace(url2) {
17169
- let i2 = 0;
17170
- while (i2 < url2.length && url2.charCodeAt(i2) <= 32) {
17171
- i2++;
17172
- }
17173
- return url2.slice(i2);
17174
- }
17310
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
17311
+ var urlParserControlCharacters = /[\t\n\r]/g;
17175
17312
  function normalizeURLForProtocolCheck(url2) {
17176
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
17313
+ if (typeof url2 !== "string") {
17314
+ return url2;
17315
+ }
17316
+ let start = 0;
17317
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
17318
+ start++;
17319
+ }
17320
+ return url2.slice(start).replace(urlParserControlCharacters, "");
17177
17321
  }
17322
+
17323
+ // node_modules/axios/lib/core/buildFullPath.js
17324
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
17178
17325
  function redactFragment(fragment) {
17179
17326
  if (!fragment) {
17180
17327
  return fragment;
@@ -17296,7 +17443,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
17296
17443
  var import_zlib = __toESM(require("zlib"), 1);
17297
17444
 
17298
17445
  // node_modules/axios/lib/env/data.js
17299
- var VERSION = "1.19.0";
17446
+ var VERSION = "1.20.0";
17300
17447
 
17301
17448
  // node_modules/axios/lib/helpers/parseProtocol.js
17302
17449
  function parseProtocol(url2) {
@@ -17305,7 +17452,7 @@ function parseProtocol(url2) {
17305
17452
  }
17306
17453
 
17307
17454
  // node_modules/axios/lib/helpers/fromDataURI.js
17308
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
17455
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
17309
17456
  function fromDataURI(uri, asBlob, options) {
17310
17457
  const _Blob = options && options.Blob || platform_default.classes.Blob;
17311
17458
  const protocol = parseProtocol(uri);
@@ -17618,6 +17765,7 @@ var Http2Sessions = class {
17618
17765
  }
17619
17766
  getSession(authority, options) {
17620
17767
  options = Object.assign(
17768
+ /* @__PURE__ */ Object.create(null),
17621
17769
  {
17622
17770
  sessionTimeout: 1e3
17623
17771
  },
@@ -17683,6 +17831,7 @@ var Http2Sessions = class {
17683
17831
  };
17684
17832
  }
17685
17833
  session.once("close", removeSession);
17834
+ session.once("error", removeSession);
17686
17835
  let entry = [session, options];
17687
17836
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
17688
17837
  return session;
@@ -17707,6 +17856,13 @@ var callbackify_default = callbackify;
17707
17856
 
17708
17857
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
17709
17858
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
17859
+ var trimTrailingDots = (value) => {
17860
+ let end = value.length;
17861
+ while (end && value.charCodeAt(end - 1) === 46) {
17862
+ end--;
17863
+ }
17864
+ return end === value.length ? value : value.slice(0, end);
17865
+ };
17710
17866
  var isIPv4Loopback = (host) => {
17711
17867
  const parts = host.split(".");
17712
17868
  if (parts.length !== 4) return false;
@@ -17739,7 +17895,7 @@ var normalizeIPAddress = (host) => {
17739
17895
  if (h2.charAt(0) === "[" && h2.charAt(h2.length - 1) === "]") {
17740
17896
  h2 = h2.slice(1, -1);
17741
17897
  }
17742
- h2 = h2.replace(/\.+$/, "");
17898
+ h2 = trimTrailingDots(h2);
17743
17899
  if (!/^[0-9.xXa-fA-F]+$/.test(h2)) return host;
17744
17900
  const parts = h2.split(".");
17745
17901
  if (parts.some((p) => p === "")) return host;
@@ -17851,6 +18007,40 @@ var unmapIPv4MappedIPv6 = (host) => {
17851
18007
  }
17852
18008
  return host;
17853
18009
  };
18010
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
18011
+ var ipv4ToBytes = (host) => {
18012
+ const parts = host.split(".");
18013
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
18014
+ };
18015
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
18016
+ var ipv6ToBytes = (host) => {
18017
+ const halves = host.split("::");
18018
+ if (halves.length > 2) {
18019
+ return null;
18020
+ }
18021
+ const groups = halves[0] ? halves[0].split(":") : [];
18022
+ if (halves.length === 2) {
18023
+ const rear = halves[1] ? halves[1].split(":") : [];
18024
+ const missing = 8 - groups.length - rear.length;
18025
+ if (missing < 1) {
18026
+ return null;
18027
+ }
18028
+ groups.push(...new Array(missing).fill("0"), ...rear);
18029
+ }
18030
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
18031
+ return null;
18032
+ }
18033
+ return groups.flatMap((group) => {
18034
+ const value = Number.parseInt(group, 16);
18035
+ return [value >> 8 & 255, value & 255];
18036
+ });
18037
+ };
18038
+ var ipToBytes = (host) => {
18039
+ if (typeof host !== "string" || !host) {
18040
+ return null;
18041
+ }
18042
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
18043
+ };
17854
18044
  var normalizeNoProxyHost = (hostname) => {
17855
18045
  if (!hostname) {
17856
18046
  return hostname;
@@ -17858,13 +18048,90 @@ var normalizeNoProxyHost = (hostname) => {
17858
18048
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
17859
18049
  hostname = hostname.slice(1, -1);
17860
18050
  }
17861
- const trimmed = hostname.replace(/\.+$/, "");
18051
+ const trimmed = trimTrailingDots(hostname);
17862
18052
  const ipv4 = normalizeIPAddress(trimmed);
17863
18053
  if (ipv4 !== trimmed) {
17864
18054
  return ipv4;
17865
18055
  }
17866
18056
  return unmapIPv4MappedIPv6(trimmed);
17867
18057
  };
18058
+ var normalizeCidrBase = (input) => {
18059
+ let base = input;
18060
+ const startsBracket = base.charAt(0) === "[";
18061
+ const endsBracket = base.charAt(base.length - 1) === "]";
18062
+ const hasBracket = base.includes("[") || base.includes("]");
18063
+ if (startsBracket || endsBracket) {
18064
+ if (!startsBracket || !endsBracket) {
18065
+ return null;
18066
+ }
18067
+ base = base.slice(1, -1);
18068
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
18069
+ return null;
18070
+ }
18071
+ } else if (hasBracket) {
18072
+ return null;
18073
+ }
18074
+ if (!base || base.charAt(base.length - 1) === ".") {
18075
+ return null;
18076
+ }
18077
+ const wasIPv6 = base.indexOf(":") !== -1;
18078
+ if (wasIPv6) {
18079
+ try {
18080
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
18081
+ } catch (_err) {
18082
+ return null;
18083
+ }
18084
+ } else {
18085
+ base = normalizeIPAddress(base);
18086
+ if (!ipv4ToBytes(base)) {
18087
+ return null;
18088
+ }
18089
+ }
18090
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
18091
+ };
18092
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
18093
+ var parseCidrEntry = (entry) => {
18094
+ if (entry.indexOf("/") === -1) {
18095
+ return void 0;
18096
+ }
18097
+ const match = CIDR_ENTRY_RE.exec(entry);
18098
+ if (!match) {
18099
+ return null;
18100
+ }
18101
+ let prefix = Number(match[2]);
18102
+ const parsedBase = normalizeCidrBase(match[1]);
18103
+ if (!parsedBase) {
18104
+ return null;
18105
+ }
18106
+ const { normalized, wasIPv6 } = parsedBase;
18107
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
18108
+ if (prefix < 96) {
18109
+ return null;
18110
+ }
18111
+ prefix -= 96;
18112
+ }
18113
+ const bytes = ipToBytes(normalized);
18114
+ if (!bytes || prefix > bytes.length * 8) {
18115
+ return null;
18116
+ }
18117
+ return { bytes, prefix };
18118
+ };
18119
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
18120
+ const fullBytes = prefix >> 3;
18121
+ for (let i2 = 0; i2 < fullBytes; i2++) {
18122
+ if (addressBytes[i2] !== networkBytes[i2]) {
18123
+ return false;
18124
+ }
18125
+ }
18126
+ const remainingBits = prefix & 7;
18127
+ if (remainingBits) {
18128
+ const mask2 = 255 << 8 - remainingBits & 255;
18129
+ if ((addressBytes[fullBytes] & mask2) !== (networkBytes[fullBytes] & mask2)) {
18130
+ return false;
18131
+ }
18132
+ }
18133
+ return true;
18134
+ };
17868
18135
  function shouldBypassProxy(location) {
17869
18136
  let parsed;
17870
18137
  try {
@@ -17881,6 +18148,7 @@ function shouldBypassProxy(location) {
17881
18148
  }
17882
18149
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
17883
18150
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
18151
+ const hostnameBytes = ipToBytes(hostname);
17884
18152
  return noProxy.split(/[\s,]+/).some((entry) => {
17885
18153
  if (!entry) {
17886
18154
  return false;
@@ -17888,6 +18156,10 @@ function shouldBypassProxy(location) {
17888
18156
  if (entry === "*") {
17889
18157
  return true;
17890
18158
  }
18159
+ const cidr = parseCidrEntry(entry);
18160
+ if (cidr !== void 0) {
18161
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
18162
+ }
17891
18163
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
17892
18164
  entryHost = normalizeNoProxyHost(entryHost);
17893
18165
  if (!entryHost) {
@@ -17973,7 +18245,8 @@ function throttle(fn, freq) {
17973
18245
  }
17974
18246
  };
17975
18247
  const flush = () => lastArgs && invoke(lastArgs);
17976
- return [throttled, flush];
18248
+ const flushWith = (...args) => invoke(args);
18249
+ return [throttled, flush, flushWith];
17977
18250
  }
17978
18251
  var throttle_default = throttle;
17979
18252
 
@@ -17982,7 +18255,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
17982
18255
  let bytesNotified = 0;
17983
18256
  const _speedometer = speedometer_default(50, 250);
17984
18257
  return throttle_default((e) => {
17985
- if (!e || typeof e.loaded !== "number") {
18258
+ if (!e || !utils_default.isNumber(e.loaded)) {
17986
18259
  return;
17987
18260
  }
17988
18261
  const rawLoaded = e.loaded;
@@ -18143,6 +18416,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
18143
18416
  var isHttps = /https:?/;
18144
18417
  var kAxiosSocketListener = /* @__PURE__ */ Symbol("axios.http.socketListener");
18145
18418
  var kAxiosCurrentReq = /* @__PURE__ */ Symbol("axios.http.currentReq");
18419
+ function handleSocketError(err) {
18420
+ const current = this[kAxiosCurrentReq];
18421
+ if (current && !current.destroyed) {
18422
+ current.destroy(err);
18423
+ }
18424
+ }
18146
18425
  var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
18147
18426
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
18148
18427
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -18245,10 +18524,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
18245
18524
  return false;
18246
18525
  }
18247
18526
  }
18248
- function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
18527
+ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
18249
18528
  let proxy = configProxy;
18250
18529
  const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
18251
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
18530
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
18252
18531
  const proxyUrl = getProxyForUrl(location);
18253
18532
  if (proxyUrl) {
18254
18533
  if (!shouldBypassProxy(location)) {
@@ -18345,9 +18624,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
18345
18624
  redirectOptions.href,
18346
18625
  true,
18347
18626
  configHttpsAgent,
18348
- configHttpAgent
18627
+ configHttpAgent,
18628
+ allowEnvProxy
18349
18629
  );
18350
18630
  };
18631
+ return Boolean(
18632
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
18633
+ );
18351
18634
  }
18352
18635
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
18353
18636
  var wrapAsync = (asyncExecutor) => {
@@ -18372,7 +18655,7 @@ var wrapAsync = (asyncExecutor) => {
18372
18655
  };
18373
18656
  var resolveFamily = ({ address, family }) => {
18374
18657
  if (!utils_default.isString(address)) {
18375
- throw TypeError("address must be a string");
18658
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
18376
18659
  }
18377
18660
  return {
18378
18661
  address,
@@ -18380,6 +18663,30 @@ var resolveFamily = ({ address, family }) => {
18380
18663
  };
18381
18664
  };
18382
18665
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
18666
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
18667
+ var normalizeLookup = (lookup) => {
18668
+ let normalized = normalizedLookupCache.get(lookup);
18669
+ if (normalized) {
18670
+ return normalized;
18671
+ }
18672
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
18673
+ normalized = (hostname, opt, cb) => {
18674
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
18675
+ if (err) {
18676
+ return cb(err);
18677
+ }
18678
+ let addresses;
18679
+ try {
18680
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
18681
+ } catch (error) {
18682
+ return cb(error);
18683
+ }
18684
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
18685
+ });
18686
+ };
18687
+ normalizedLookupCache.set(lookup, normalized);
18688
+ return normalized;
18689
+ };
18383
18690
  var http2Transport = {
18384
18691
  request(options, cb) {
18385
18692
  const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
@@ -18416,6 +18723,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18416
18723
  let family = own2("family");
18417
18724
  let httpVersion = own2("httpVersion");
18418
18725
  if (httpVersion === void 0) httpVersion = 1;
18726
+ const rawHttpVersion = httpVersion;
18419
18727
  let http2Options = own2("http2Options");
18420
18728
  const httpAgent = own2("httpAgent");
18421
18729
  const httpsAgent = own2("httpsAgent");
@@ -18432,25 +18740,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18432
18740
  let rejected = false;
18433
18741
  let req;
18434
18742
  let connectPhaseTimer;
18435
- httpVersion = +httpVersion;
18743
+ try {
18744
+ httpVersion = +httpVersion;
18745
+ } catch (err) {
18746
+ throw new AxiosError_default(
18747
+ "Invalid protocol version: value is not a number",
18748
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
18749
+ config
18750
+ );
18751
+ }
18436
18752
  if (Number.isNaN(httpVersion)) {
18437
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
18753
+ throw new AxiosError_default(
18754
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
18755
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
18756
+ config
18757
+ );
18438
18758
  }
18439
18759
  if (httpVersion !== 1 && httpVersion !== 2) {
18440
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
18760
+ throw new AxiosError_default(
18761
+ `Unsupported protocol version '${httpVersion}'`,
18762
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
18763
+ config
18764
+ );
18441
18765
  }
18442
18766
  const isHttp2 = httpVersion === 2;
18443
18767
  if (lookup) {
18444
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
18445
- lookup = (hostname, opt, cb) => {
18446
- _lookup(hostname, opt, (err, arg0, arg1) => {
18447
- if (err) {
18448
- return cb(err);
18449
- }
18450
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
18451
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
18452
- });
18453
- };
18768
+ lookup = normalizeLookup(lookup);
18454
18769
  }
18455
18770
  const abortEmitter = new import_events.EventEmitter();
18456
18771
  function abort(reason) {
@@ -18693,6 +19008,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18693
19008
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
18694
19009
  false
18695
19010
  );
19011
+ if (isHttp2 && lookup) {
19012
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
19013
+ }
18696
19014
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
18697
19015
  path: path6,
18698
19016
  method,
@@ -18703,9 +19021,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18703
19021
  family,
18704
19022
  beforeRedirect: dispatchBeforeRedirect,
18705
19023
  beforeRedirects: /* @__PURE__ */ Object.create(null),
18706
- http2Options
19024
+ http2Options,
19025
+ createConnection: void 0
18707
19026
  });
18708
19027
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
19028
+ let proxyApplied = false;
18709
19029
  if (socketPath) {
18710
19030
  if (typeof socketPath !== "string") {
18711
19031
  return reject(
@@ -18733,13 +19053,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18733
19053
  } else {
18734
19054
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
18735
19055
  options.port = parsed.port;
18736
- setProxy(
19056
+ proxyApplied = setProxy(
18737
19057
  options,
18738
19058
  configProxy,
18739
19059
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
18740
19060
  false,
18741
19061
  httpsAgent,
18742
- httpAgent
19062
+ httpAgent,
19063
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
19064
+ // cannot apply either axios-resolved or agent-local environment proxies.
19065
+ // Explicit proxy config is still processed and rejected below.
19066
+ !isHttp2
18743
19067
  );
18744
19068
  }
18745
19069
  let transport;
@@ -18750,6 +19074,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18750
19074
  options.agent = isHttpsRequest ? httpsAgent : httpAgent;
18751
19075
  }
18752
19076
  if (isHttp2) {
19077
+ if (proxyApplied) {
19078
+ return reject(
19079
+ new AxiosError_default(
19080
+ "HTTP/2 requests with a proxy are not supported",
19081
+ AxiosError_default.ERR_NOT_SUPPORT,
19082
+ config
19083
+ )
19084
+ );
19085
+ }
18753
19086
  transport = http2Transport;
18754
19087
  } else {
18755
19088
  const configTransport = own2("transport");
@@ -18837,7 +19170,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18837
19170
  transformStream,
18838
19171
  progressEventDecorator(
18839
19172
  responseLength,
18840
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
19173
+ progressEventReducer(
19174
+ asyncDecorator(onDownloadProgress, scheduleProgress),
19175
+ true,
19176
+ 3
19177
+ )
18841
19178
  )
18842
19179
  )
18843
19180
  );
@@ -18986,12 +19323,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
18986
19323
  socket.setKeepAlive(true, 1e3 * 60);
18987
19324
  }
18988
19325
  if (!socket[kAxiosSocketListener]) {
18989
- socket.on("error", function handleSocketError(err) {
18990
- const current = socket[kAxiosCurrentReq];
18991
- if (current && !current.destroyed) {
18992
- current.destroy(err);
18993
- }
18994
- });
19326
+ socket.on("error", handleSocketError);
18995
19327
  socket[kAxiosSocketListener] = true;
18996
19328
  }
18997
19329
  socket[kAxiosCurrentReq] = req;
@@ -19236,7 +19568,7 @@ function mergeConfig(config1, config2) {
19236
19568
  transformResponse: defaultToConfig2,
19237
19569
  paramsSerializer: defaultToConfig2,
19238
19570
  timeout: defaultToConfig2,
19239
- timeoutMessage: defaultToConfig2,
19571
+ timeoutErrorMessage: defaultToConfig2,
19240
19572
  withCredentials: defaultToConfig2,
19241
19573
  withXSRFToken: defaultToConfig2,
19242
19574
  adapter: defaultToConfig2,
@@ -19313,10 +19645,11 @@ function resolveConfig(config) {
19313
19645
  }
19314
19646
  }
19315
19647
  if (utils_default.isFormData(data)) {
19648
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
19316
19649
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
19317
19650
  headers.setContentType(void 0);
19318
- } else if (utils_default.isFunction(data.getHeaders)) {
19319
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
19651
+ } else if (utils_default.isFunction(getHeaders)) {
19652
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
19320
19653
  }
19321
19654
  }
19322
19655
  if (platform_default.hasStandardBrowserEnv) {
@@ -19345,7 +19678,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19345
19678
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
19346
19679
  let onCanceled;
19347
19680
  let uploadThrottled, downloadThrottled;
19348
- let flushUpload, flushDownload;
19681
+ let flushUpload, flushDownload, flushDownloadWithEvent;
19349
19682
  function done() {
19350
19683
  flushUpload && flushUpload();
19351
19684
  flushDownload && flushDownload();
@@ -19355,7 +19688,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19355
19688
  let request = new XMLHttpRequest();
19356
19689
  request.open(_config.method.toUpperCase(), _config.url, true);
19357
19690
  request.timeout = _config.timeout;
19358
- function onloadend() {
19691
+ function onloadend(event) {
19692
+ if (!request) {
19693
+ return;
19694
+ }
19695
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
19696
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
19697
+ done();
19698
+ request = null;
19699
+ return;
19700
+ }
19701
+ try {
19702
+ if (event) {
19703
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
19704
+ } else {
19705
+ flushDownload && flushDownload();
19706
+ }
19707
+ } catch (err) {
19708
+ setTimeout(() => {
19709
+ throw err;
19710
+ });
19711
+ }
19359
19712
  if (!request) {
19360
19713
  return;
19361
19714
  }
@@ -19443,7 +19796,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
19443
19796
  request.responseType = _config.responseType;
19444
19797
  }
19445
19798
  if (onDownloadProgress) {
19446
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
19799
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
19800
+ onDownloadProgress,
19801
+ true
19802
+ );
19447
19803
  request.addEventListener("progress", downloadThrottled);
19448
19804
  }
19449
19805
  if (onUploadProgress && request.upload) {
@@ -19613,6 +19969,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
19613
19969
 
19614
19970
  // node_modules/axios/lib/adapters/fetch.js
19615
19971
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
19972
+ var DEFAULT_REQUEST_OPTIONS = {
19973
+ cache: "default",
19974
+ redirect: "follow",
19975
+ referrer: "about:client",
19976
+ referrerPolicy: "",
19977
+ mode: "cors",
19978
+ integrity: "",
19979
+ keepalive: false,
19980
+ priority: "auto",
19981
+ window: null
19982
+ };
19616
19983
  var { isFunction: isFunction2 } = utils_default;
19617
19984
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
19618
19985
  /%([0-9A-F]{2})/gi,
@@ -19743,7 +20110,8 @@ var factory = (env) => {
19743
20110
  withCredentials = "same-origin",
19744
20111
  fetchOptions,
19745
20112
  maxContentLength,
19746
- maxBodyLength
20113
+ maxBodyLength,
20114
+ maxRedirects
19747
20115
  } = resolveConfig_default(config);
19748
20116
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
19749
20117
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -19873,17 +20241,44 @@ var factory = (env) => {
19873
20241
  }
19874
20242
  }
19875
20243
  headers.set("User-Agent", "axios/" + VERSION, false);
19876
- const resolvedOptions = {
19877
- ...fetchOptions,
20244
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
20245
+ if (safeFetchOptions) {
20246
+ delete safeFetchOptions.body;
20247
+ delete safeFetchOptions.headers;
20248
+ delete safeFetchOptions.method;
20249
+ delete safeFetchOptions.signal;
20250
+ delete safeFetchOptions.duplex;
20251
+ delete safeFetchOptions.credentials;
20252
+ }
20253
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
19878
20254
  signal: composedSignal,
19879
20255
  method: method.toUpperCase(),
19880
20256
  headers: toByteStringHeaderObject(headers.normalize()),
19881
20257
  body: data,
19882
20258
  duplex: "half",
19883
20259
  credentials: isCredentialsSupported ? withCredentials : void 0
19884
- };
20260
+ });
20261
+ if (isRequestSupported) {
20262
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
20263
+ if (resolvedOptions[key] === void 0) {
20264
+ resolvedOptions[key] = value;
20265
+ }
20266
+ });
20267
+ if (resolvedOptions.signal === void 0) {
20268
+ resolvedOptions.signal = null;
20269
+ }
20270
+ if (resolvedOptions.body === void 0) {
20271
+ resolvedOptions.body = null;
20272
+ }
20273
+ }
20274
+ if (maxRedirects === 0) {
20275
+ resolvedOptions.redirect = "manual";
20276
+ if (safeFetchOptions) {
20277
+ safeFetchOptions.redirect = "manual";
20278
+ }
20279
+ }
19885
20280
  request = isRequestSupported && new Request(url2, resolvedOptions);
19886
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
20281
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
19887
20282
  const responseHeaders = AxiosHeaders_default.from(response.headers);
19888
20283
  if (hasMaxContentLength) {
19889
20284
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -20102,9 +20497,10 @@ function throwIfCancellationRequested(config) {
20102
20497
  throw new CanceledError_default(null, config);
20103
20498
  }
20104
20499
  }
20105
- function dispatchRequest(config) {
20500
+ function dispatchRequest(_config) {
20501
+ const config = utils_default.toSafeFlatObject(_config);
20106
20502
  throwIfCancellationRequested(config);
20107
- config.headers = AxiosHeaders_default.from(config.headers);
20503
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
20108
20504
  config.data = transformData.call(config, config.transformRequest);
20109
20505
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
20110
20506
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -20234,16 +20630,15 @@ var Axios = class {
20234
20630
  return await this._request(configOrUrl, config);
20235
20631
  } catch (err) {
20236
20632
  if (err instanceof Error) {
20237
- let dummy = {};
20238
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
20239
- const stack = (() => {
20240
- if (!dummy.stack) {
20241
- return "";
20242
- }
20243
- const firstNewlineIndex = dummy.stack.indexOf("\n");
20244
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
20245
- })();
20246
20633
  try {
20634
+ let dummy = {};
20635
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
20636
+ const dummyStack = dummy.stack;
20637
+ let stack = "";
20638
+ if (typeof dummyStack === "string") {
20639
+ const firstNewlineIndex = dummyStack.indexOf("\n");
20640
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
20641
+ }
20247
20642
  if (!err.stack) {
20248
20643
  err.stack = stack;
20249
20644
  } else if (stack) {
@@ -20313,9 +20708,9 @@ var Axios = class {
20313
20708
  },
20314
20709
  true
20315
20710
  );
20316
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
20711
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
20317
20712
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
20318
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
20713
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
20319
20714
  delete headers[method];
20320
20715
  });
20321
20716
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -20578,14 +20973,22 @@ var HttpStatusCode = {
20578
20973
  Gone: 410,
20579
20974
  LengthRequired: 411,
20580
20975
  PreconditionFailed: 412,
20976
+ /**
20977
+ * @deprecated Use `ContentTooLarge` instead.
20978
+ */
20581
20979
  PayloadTooLarge: 413,
20980
+ ContentTooLarge: 413,
20582
20981
  UriTooLong: 414,
20583
20982
  UnsupportedMediaType: 415,
20584
20983
  RangeNotSatisfiable: 416,
20585
20984
  ExpectationFailed: 417,
20586
20985
  ImATeapot: 418,
20587
20986
  MisdirectedRequest: 421,
20987
+ /**
20988
+ * @deprecated Use `UnprocessableContent` instead.
20989
+ */
20588
20990
  UnprocessableEntity: 422,
20991
+ UnprocessableContent: 422,
20589
20992
  Locked: 423,
20590
20993
  FailedDependency: 424,
20591
20994
  TooEarly: 425,
@@ -20614,7 +21017,9 @@ var HttpStatusCode = {
20614
21017
  InvalidSslCertificate: 526
20615
21018
  };
20616
21019
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
20617
- HttpStatusCode[value] = key;
21020
+ if (HttpStatusCode[value] === void 0) {
21021
+ HttpStatusCode[value] = key;
21022
+ }
20618
21023
  });
20619
21024
  var HttpStatusCode_default = HttpStatusCode;
20620
21025
 
@@ -20721,6 +21126,13 @@ var DOCUMENT_ARTIFACT_NAMES = [
20721
21126
  "pades",
20722
21127
  "bundle"
20723
21128
  ];
21129
+ var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21130
+ var VERIFICATION_METHODS = [
21131
+ "Email",
21132
+ "Whatsapp",
21133
+ "DigitalCertificate"
21134
+ ];
21135
+ var NOTIFICATION_METHODS = ["Email", "Whatsapp"];
20724
21136
  function handleAssinafyResponse(response) {
20725
21137
  const resp = response;
20726
21138
  if (resp && typeof resp === "object" && resp.status !== void 0 && "data" in resp) {
@@ -20798,6 +21210,51 @@ function requireIso8601(value, name = "timestamp") {
20798
21210
  }
20799
21211
  return value;
20800
21212
  }
21213
+ function requireEmail(value) {
21214
+ if (!value || !EMAIL_RE.test(value)) {
21215
+ throw new ValidationError("Invalid email address", { email: value });
21216
+ }
21217
+ return value;
21218
+ }
21219
+ function validateSignerOptions(input) {
21220
+ if (input.verification_method !== void 0 && !VERIFICATION_METHODS.includes(input.verification_method)) {
21221
+ throw new ValidationError(
21222
+ `verification_method must be one of: ${VERIFICATION_METHODS.join(", ")}`
21223
+ );
21224
+ }
21225
+ if (input.notification_methods !== void 0 && (!Array.isArray(input.notification_methods) || input.notification_methods.some(
21226
+ (method) => !NOTIFICATION_METHODS.includes(method)
21227
+ ))) {
21228
+ throw new ValidationError(
21229
+ `notification_methods must contain only: ${NOTIFICATION_METHODS.join(", ")}`
21230
+ );
21231
+ }
21232
+ if (input.step !== void 0 && !Number.isInteger(input.step)) {
21233
+ throw new ValidationError("step must be an integer");
21234
+ }
21235
+ }
21236
+ function validateSigningSteps(signers) {
21237
+ const withSteps = signers.filter((signer) => signer.step !== void 0);
21238
+ if (withSteps.length > 0) {
21239
+ if (withSteps.length !== signers.length) {
21240
+ throw new ValidationError("step must be supplied for every signer when used");
21241
+ }
21242
+ const steps = [...new Set(withSteps.map((signer) => signer.step))].sort(
21243
+ (a2, b) => a2 - b
21244
+ );
21245
+ if (steps.some((step, index) => step !== index + 1)) {
21246
+ throw new ValidationError("steps must form a contiguous sequence starting at 1");
21247
+ }
21248
+ }
21249
+ validateDigitalCertificateSteps(signers);
21250
+ }
21251
+ function validateDigitalCertificateSteps(signers) {
21252
+ for (const signer of signers) {
21253
+ if (signer.verification_method === "DigitalCertificate" && signers.some((other) => other !== signer && (other.step ?? 1) === (signer.step ?? 1))) {
21254
+ throw new ValidationError("a DigitalCertificate signer must be alone in its signing step");
21255
+ }
21256
+ }
21257
+ }
20801
21258
  function documentStatsParams(params = {}) {
20802
21259
  if (params.granularity !== void 0 && !["monthly", "daily"].includes(params.granularity)) {
20803
21260
  throw new ValidationError("granularity must be monthly or daily");
@@ -20943,15 +21400,25 @@ function toInt(value) {
20943
21400
 
20944
21401
  // src/api/resources/assignments.ts
20945
21402
  function buildAssignmentPayload(payload, options = {}) {
21403
+ if (payload.method !== void 0 && payload.method !== "virtual" && payload.method !== "collect") {
21404
+ throw new ValidationError("method must be virtual or collect");
21405
+ }
20946
21406
  const signers = extractSignerRefs(payload);
20947
- if (signers.length === 0 && !options.allowEmptySigners) {
21407
+ if (signers.length === 0 && (!options.allowEmptySigners || (payload.method ?? "virtual") !== "collect")) {
20948
21408
  throw new ValidationError("At least one signer is required", {
20949
21409
  signers: payload.signers ?? payload.signer_ids ?? payload.signerIds
20950
21410
  });
20951
21411
  }
21412
+ if (payload.method === "collect" && !Array.isArray(payload.entries)) {
21413
+ throw new ValidationError("entries are required for collect assignments");
21414
+ }
21415
+ const normalisedSigners = signers.map((ref) => normaliseSignerRef(ref, options));
21416
+ if (!options.skipDigitalCertificateStepValidation) {
21417
+ validateDigitalCertificateSteps(normalisedSigners);
21418
+ }
20952
21419
  return cleanParams({
20953
21420
  method: payload.method ?? "virtual",
20954
- signers: signers.map((ref) => normaliseSignerRef(ref, options)),
21421
+ signers: normalisedSigners,
20955
21422
  message: payload.message,
20956
21423
  expires_at: payload.expires_at === void 0 ? void 0 : requireIso8601(payload.expires_at, "expires_at"),
20957
21424
  copy_receivers: payload.copy_receivers,
@@ -20979,6 +21446,7 @@ function normaliseSignerRef(ref, options) {
20979
21446
  if (ref && typeof ref === "object") {
20980
21447
  const input = ref;
20981
21448
  const id = input.id ?? input.signer_id;
21449
+ validateSignerOptions(input);
20982
21450
  const normalised = cleanParams({
20983
21451
  id,
20984
21452
  verification_method: input.verification_method,
@@ -21036,14 +21504,16 @@ var AssignmentResource = class extends BaseResource {
21036
21504
  `/documents/${docId}/assignments/estimate-cost`,
21037
21505
  buildAssignmentPayload(payload, {
21038
21506
  allowSignersWithoutId: true,
21039
- allowEmptySigners: true
21507
+ allowEmptySigners: true,
21508
+ skipDigitalCertificateStepValidation: true
21040
21509
  })
21041
21510
  )
21042
21511
  );
21043
21512
  }
21044
21513
  /**
21045
21514
  * Update the expiration date of an existing assignment.
21046
- * Pass `null` to remove the expiration entirely.
21515
+ * The published API accepts an ISO 8601 timestamp. Deployments that support
21516
+ * clearing an expiration also accept `null`.
21047
21517
  */
21048
21518
  async resetExpiration(documentId, assignmentId, expiresAt) {
21049
21519
  const docId = this.requireId(documentId, "Document ID");
@@ -21378,24 +21848,24 @@ var DocumentResource = class extends BaseResource {
21378
21848
  );
21379
21849
  }
21380
21850
  /**
21381
- * Replace the document's tag set with `tags` (an array of tag names).
21382
- * Unknown names are auto-created; an empty array detaches all tags.
21851
+ * Replace the document's tag set with tag IDs. An empty array detaches all tags.
21852
+ * Values are forwarded unchanged for compatibility with deployments that also accept names.
21383
21853
  */
21384
21854
  async replaceTags(documentId, tags, accountId) {
21385
21855
  const accId = this.accountId(accountId);
21386
21856
  const docId = this.requireId(documentId, "Document ID");
21387
- if (!Array.isArray(tags)) throw new ValidationError("tags must be an array of tag names");
21857
+ if (!Array.isArray(tags)) throw new ValidationError("tags must be an array of tag IDs");
21388
21858
  return this.call(
21389
21859
  "Failed to replace document tags",
21390
21860
  () => this.http.put(`/accounts/${accId}/documents/${docId}/tags`, { tags })
21391
21861
  );
21392
21862
  }
21393
- /** Attach additional tags (by name) without removing existing ones. Idempotent. */
21863
+ /** Attach additional tag IDs without removing existing ones. */
21394
21864
  async addTags(documentId, tags, accountId) {
21395
21865
  const accId = this.accountId(accountId);
21396
21866
  const docId = this.requireId(documentId, "Document ID");
21397
21867
  if (!Array.isArray(tags) || tags.length === 0) {
21398
- throw new ValidationError("tags must be a non-empty array of tag names");
21868
+ throw new ValidationError("tags must be a non-empty array of tag IDs");
21399
21869
  }
21400
21870
  return this.call(
21401
21871
  "Failed to add document tags",
@@ -21425,7 +21895,14 @@ var DocumentResource = class extends BaseResource {
21425
21895
  async createFromTemplate(templateId, signers, options = {}, accountId) {
21426
21896
  const tmplId = this.requireId(templateId, "Template ID");
21427
21897
  const accId = this.accountId(accountId);
21898
+ validateTemplateSigners(signers, { requireId: true, singleNotification: true });
21428
21899
  if (options.expires_at !== void 0) requireIso8601(options.expires_at, "expires_at");
21900
+ if (options.editor_fields !== void 0 && (!Array.isArray(options.editor_fields) || options.editor_fields.some((field) => !field?.field_id || typeof field.value !== "string"))) {
21901
+ throw new ValidationError("editor_fields must contain field_id and value");
21902
+ }
21903
+ if (options.tags !== void 0 && (!Array.isArray(options.tags) || options.tags.some((tag) => typeof tag !== "string" || !tag))) {
21904
+ throw new ValidationError("tags must contain non-empty tag names");
21905
+ }
21429
21906
  const body = { ...options, signers };
21430
21907
  this.logger.info("Creating document from template", { templateId: tmplId, accountId: accId });
21431
21908
  return this.call(
@@ -21437,6 +21914,7 @@ var DocumentResource = class extends BaseResource {
21437
21914
  async estimateCostFromTemplate(templateId, signers, accountId) {
21438
21915
  const tmplId = this.requireId(templateId, "Template ID");
21439
21916
  const accId = this.accountId(accountId);
21917
+ validateTemplateSigners(signers, { requireId: false, singleNotification: false });
21440
21918
  return this.call(
21441
21919
  "Failed to estimate cost from template",
21442
21920
  () => this.http.post(`/accounts/${accId}/templates/${tmplId}/documents/estimate-cost`, { signers })
@@ -21483,7 +21961,7 @@ var DocumentResource = class extends BaseResource {
21483
21961
  async sendToken(documentId, recipient, channel = "email") {
21484
21962
  const id = this.requireId(documentId, "Document ID");
21485
21963
  if (typeof recipient === "object") {
21486
- if (!recipient?.email) throw new ValidationError("email is required");
21964
+ requireEmail(recipient?.email);
21487
21965
  return this.call(
21488
21966
  "Failed to send signing token",
21489
21967
  () => this.http.put(
@@ -21494,6 +21972,10 @@ var DocumentResource = class extends BaseResource {
21494
21972
  );
21495
21973
  }
21496
21974
  if (!recipient) throw new ValidationError("recipient is required");
21975
+ if (channel !== "email" && channel !== "whatsapp") {
21976
+ throw new ValidationError("channel must be email or whatsapp");
21977
+ }
21978
+ if (channel === "email") requireEmail(recipient);
21497
21979
  return this.call(
21498
21980
  "Failed to send signing token",
21499
21981
  () => this.http.put(
@@ -21524,6 +22006,31 @@ var DocumentResource = class extends BaseResource {
21524
22006
  return { signed, total, pending, percentage };
21525
22007
  }
21526
22008
  };
22009
+ function validateTemplateSigners(signers, options) {
22010
+ if (!Array.isArray(signers)) throw new ValidationError("signers must be an array");
22011
+ for (const value of signers) {
22012
+ if (!value || typeof value !== "object") {
22013
+ throw new ValidationError("each template signer must be an object");
22014
+ }
22015
+ const signer = value;
22016
+ if (typeof signer.role_id !== "string" || !signer.role_id) {
22017
+ throw new ValidationError("each template signer requires role_id");
22018
+ }
22019
+ if ((options.requireId || signer.id !== void 0) && (typeof signer.id !== "string" || !signer.id)) {
22020
+ throw new ValidationError("each template signer requires a valid id");
22021
+ }
22022
+ validateSignerOptions(signer);
22023
+ if (options.requireId && signer.step !== void 0 && Number(signer.step) < 1) {
22024
+ throw new ValidationError("template signer step must be a positive integer");
22025
+ }
22026
+ if (options.singleNotification && Array.isArray(signer.notification_methods) && signer.notification_methods.length > 1) {
22027
+ throw new ValidationError("template signers accept at most one notification method");
22028
+ }
22029
+ }
22030
+ if (options.requireId) {
22031
+ validateSigningSteps(signers);
22032
+ }
22033
+ }
21527
22034
  async function loadSource(source) {
21528
22035
  if ("buffer" in source) {
21529
22036
  if (!source.fileName) {
@@ -21635,6 +22142,7 @@ var FieldsResource = class extends BaseResource {
21635
22142
  async validate(fieldId, value, options = {}) {
21636
22143
  const id = this.accountId(options.accountId);
21637
22144
  const fid = this.requireId(fieldId, "Field ID");
22145
+ if (value === void 0) throw new ValidationError("value is required");
21638
22146
  return this.call(
21639
22147
  "Failed to validate field value",
21640
22148
  () => this.http.post(
@@ -21649,6 +22157,11 @@ var FieldsResource = class extends BaseResource {
21649
22157
  if (!Array.isArray(entries) || entries.length === 0) {
21650
22158
  throw new ValidationError("entries must be a non-empty array");
21651
22159
  }
22160
+ if (entries.some(
22161
+ (entry) => !entry || typeof entry !== "object" || typeof entry.field_id !== "string" || !entry.field_id || entry.value === void 0
22162
+ )) {
22163
+ throw new ValidationError("each entry must contain field_id and value");
22164
+ }
21652
22165
  const id = this.accountId(options.accountId);
21653
22166
  return this.call(
21654
22167
  "Failed to validate field values",
@@ -21700,20 +22213,28 @@ var SignerDocumentsResource = class extends BaseResource {
21700
22213
  () => this.http.get(`/signers/${sid}/documents/search`, signerAccessConfig(code, { search }))
21701
22214
  );
21702
22215
  }
21703
- /** `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}?signer-access-code=…` */
22216
+ /**
22217
+ * Public `GET /signers/{signer_id}/documents/{document_id}/download/{artifact}`.
22218
+ * When an access code is supplied, the SDK first verifies that it belongs to
22219
+ * the requested signer for callers that want that additional check.
22220
+ */
21704
22221
  async download(signerId, documentId, artifactName, signerAccessCode) {
21705
22222
  const sid = this.requireId(signerId, "Signer ID");
21706
22223
  const did = this.requireId(documentId, "Document ID");
21707
22224
  const artifact = requireDocumentArtifactName(artifactName);
21708
- const code = this.requireId(signerAccessCode, "signer-access-code");
21709
- const signer = await this.self(code);
21710
- if (signer.id !== sid) {
21711
- throw new ValidationError("Signer access code does not match the signer ID");
22225
+ let config = publicRequestConfig();
22226
+ if (signerAccessCode !== void 0) {
22227
+ const code = this.requireId(signerAccessCode, "signer-access-code");
22228
+ const signer = await this.self(code);
22229
+ if (signer.id !== sid) {
22230
+ throw new ValidationError("Signer access code does not match the signer ID");
22231
+ }
22232
+ config = signerAccessConfig(code);
21712
22233
  }
21713
22234
  return this.callBinary(
21714
22235
  "Failed to download signer document",
21715
22236
  () => this.http.get(`/signers/${sid}/documents/${did}/download/${artifact}`, {
21716
- ...signerAccessConfig(code),
22237
+ ...config,
21717
22238
  responseType: "arraybuffer"
21718
22239
  })
21719
22240
  );
@@ -21881,15 +22402,9 @@ var SignerDocumentsResource = class extends BaseResource {
21881
22402
  };
21882
22403
 
21883
22404
  // src/api/resources/signers.ts
21884
- var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21885
22405
  function validateCreateSignerPayload(payload) {
21886
22406
  if (!payload.full_name?.trim()) throw new ValidationError("Signer full name is required");
21887
- if (payload.email) assertEmail(payload.email);
21888
- }
21889
- function assertEmail(email) {
21890
- if (!email || !EMAIL_RE.test(email)) {
21891
- throw new ValidationError("Invalid email address", { email });
21892
- }
22407
+ if (payload.email !== void 0) requireEmail(payload.email);
21893
22408
  }
21894
22409
  var SignerResource = class extends BaseResource {
21895
22410
  /**
@@ -21952,6 +22467,10 @@ var SignerResource = class extends BaseResource {
21952
22467
  async update(signerId, payload, accountId) {
21953
22468
  const id = this.accountId(accountId);
21954
22469
  const sid = this.requireId(signerId, "Signer ID");
22470
+ if (payload.full_name !== void 0 && !payload.full_name.trim()) {
22471
+ throw new ValidationError("Signer full name cannot be blank");
22472
+ }
22473
+ if (payload.email !== void 0) requireEmail(payload.email);
21955
22474
  return this.call(
21956
22475
  "Failed to update signer",
21957
22476
  () => this.http.put(`/accounts/${id}/signers/${sid}`, normaliseSignerPayload(payload, true))
@@ -21968,7 +22487,7 @@ var SignerResource = class extends BaseResource {
21968
22487
  }
21969
22488
  /** Find a signer by email via the API's `search` parameter. Returns `null` if none match. */
21970
22489
  async findByEmail(email, accountId) {
21971
- assertEmail(email);
22490
+ requireEmail(email);
21972
22491
  try {
21973
22492
  const { data } = await this.list({ search: email, per_page: 100 }, accountId);
21974
22493
  const lower = email.toLowerCase();
@@ -22166,7 +22685,22 @@ var WebhookResource = class extends BaseResource {
22166
22685
  /** Register (or replace) the webhook subscription for the workspace. */
22167
22686
  async register(payload, accountId) {
22168
22687
  if (!payload.url) throw new ValidationError("Webhook URL is required");
22169
- if (!payload.email) throw new ValidationError("Webhook email is required");
22688
+ let webhookUrl;
22689
+ try {
22690
+ webhookUrl = new URL(payload.url);
22691
+ } catch {
22692
+ throw new ValidationError("Webhook URL must be a valid HTTP(S) URL");
22693
+ }
22694
+ if (webhookUrl.protocol !== "http:" && webhookUrl.protocol !== "https:") {
22695
+ throw new ValidationError("Webhook URL must be a valid HTTP(S) URL");
22696
+ }
22697
+ requireEmail(payload.email);
22698
+ if (payload.events !== void 0 && (!Array.isArray(payload.events) || payload.events.some((event) => typeof event !== "string" || !event))) {
22699
+ throw new ValidationError("Webhook events must contain non-empty strings");
22700
+ }
22701
+ if (payload.is_active !== void 0 && typeof payload.is_active !== "boolean") {
22702
+ throw new ValidationError("Webhook is_active must be a boolean");
22703
+ }
22170
22704
  const id = this.accountId(accountId);
22171
22705
  const body = {
22172
22706
  url: payload.url,
@@ -22340,13 +22874,13 @@ var WebhookVerifier = class {
22340
22874
  /** Returns `true` if `signature` is a valid HMAC of `payload` under the configured scheme. */
22341
22875
  verify(payload, signature) {
22342
22876
  if (!this.webhookSecret || !signature) return false;
22343
- const buf = typeof payload === "string" ? Buffer.from(payload, "utf8") : payload;
22344
- const expected = (0, import_node_crypto.createHmac)(this.algorithm, this.webhookSecret).update(buf).digest(this.encoding);
22345
- const provided = signature.trim();
22346
- const a2 = Buffer.from(expected, "utf8");
22347
- const b = Buffer.from(provided, "utf8");
22348
- if (a2.length !== b.length) return false;
22349
22877
  try {
22878
+ const buf = typeof payload === "string" ? Buffer.from(payload, "utf8") : payload;
22879
+ const expected = (0, import_node_crypto.createHmac)(this.algorithm, this.webhookSecret).update(buf).digest(this.encoding);
22880
+ const provided = signature.trim();
22881
+ const a2 = Buffer.from(expected, "utf8");
22882
+ const b = Buffer.from(provided, "utf8");
22883
+ if (a2.length !== b.length) return false;
22350
22884
  return (0, import_node_crypto.timingSafeEqual)(a2, b);
22351
22885
  } catch {
22352
22886
  return false;
@@ -22366,7 +22900,8 @@ var WebhookVerifier = class {
22366
22900
  getEventType(event) {
22367
22901
  if (!event || typeof event !== "object") return null;
22368
22902
  const e = event;
22369
- return e.event ?? e.type ?? null;
22903
+ if (typeof e.event === "string") return e.event;
22904
+ return typeof e.type === "string" ? e.type : null;
22370
22905
  }
22371
22906
  /**
22372
22907
  * Extract the event data from an event envelope.
@@ -22411,6 +22946,9 @@ var AssinafyClient = class _AssinafyClient {
22411
22946
  "An API key (options.apiKey) or legacy access token (options.token) is required."
22412
22947
  );
22413
22948
  }
22949
+ if (options.timeout !== void 0 && (!Number.isFinite(options.timeout) || options.timeout <= 0)) {
22950
+ throw new ValidationError("timeout must be a finite positive number");
22951
+ }
22414
22952
  this.defaultAccountId = options.accountId;
22415
22953
  this.logger = options.logger ?? createNoopLogger();
22416
22954
  this.webhookSecret = options.webhookSecret;
@@ -23936,6 +24474,27 @@ function renderTable(rows, columns) {
23936
24474
  );
23937
24475
  return [headerLine, ...lines].join("\n");
23938
24476
  }
24477
+ function renderDocumentStats(rows) {
24478
+ return renderTable(rows, [
24479
+ { header: "PERIOD", value: (row) => row.period },
24480
+ { header: "UPLOADED", value: (row) => row.documents_uploaded },
24481
+ { header: "SENT", value: (row) => row.documents_sent },
24482
+ { header: "REQUESTS", value: (row) => row.signature_requests },
24483
+ { header: "NOTIFY EMAIL", value: (row) => row.signature_requests_notification_email },
24484
+ { header: "NOTIFY WA", value: (row) => row.signature_requests_notification_whatsapp },
24485
+ { header: "NOTIFY BYPASS", value: (row) => row.signature_requests_notification_bypass },
24486
+ { header: "VERIFY EMAIL", value: (row) => row.signature_requests_verification_email },
24487
+ { header: "VERIFY WA", value: (row) => row.signature_requests_verification_whatsapp },
24488
+ { header: "VERIFY BYPASS", value: (row) => row.signature_requests_verification_bypass },
24489
+ {
24490
+ header: "VERIFY CERT",
24491
+ value: (row) => row.signature_requests_verification_digital_certificate
24492
+ },
24493
+ { header: "VIEWED", value: (row) => row.signature_requests_viewed },
24494
+ { header: "COMPLETED", value: (row) => row.signature_requests_completed },
24495
+ { header: "CERTIFIED", value: (row) => row.documents_certified }
24496
+ ]);
24497
+ }
23939
24498
  function renderKeyValue(obj, order) {
23940
24499
  const keys = order ?? Object.keys(obj);
23941
24500
  const present = keys.filter((k) => k in obj && obj[k] !== void 0);
@@ -24056,7 +24615,11 @@ var estimateCostCommand = new Command("estimate-cost").description("Estimate the
24056
24615
  printData(result, config);
24057
24616
  });
24058
24617
  });
24059
- var resetExpirationCommand = new Command("reset-expiration").description("Update or clear an assignment expiration date").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").addOption(new Option("--expires-at <iso8601>", "New expiration timestamp").conflicts("clear")).addOption(new Option("--clear", "Remove the expiration entirely").conflicts("expiresAt")).action(async (documentId, assignmentId, opts, command) => {
24618
+ var resetExpirationCommand = new Command("reset-expiration").description("Update an assignment expiration date").argument("<documentId>", "Document ID").argument("<assignmentId>", "Assignment ID").addOption(new Option("--expires-at <iso8601>", "New expiration timestamp").conflicts("clear")).addOption(
24619
+ new Option("--clear", "Remove the expiration when supported by the deployment").conflicts(
24620
+ "expiresAt"
24621
+ )
24622
+ ).action(async (documentId, assignmentId, opts, command) => {
24060
24623
  await runWithClient(command, async ({ client, config }) => {
24061
24624
  if (!opts.clear && !opts.expiresAt) {
24062
24625
  throw new CliError("Pass --expires-at <iso8601> or --clear.");
@@ -24677,25 +25240,25 @@ var tagsCommand = new Command("tags").description("List the tags attached to a d
24677
25240
  );
24678
25241
  });
24679
25242
  });
24680
- var tagsSetCommand = new Command("tags-set").description("Replace a document tag set (names; unknown names are auto-created)").argument("<id>", "Document ID").argument("[names...]", "Tag names (pass none to detach all)").action(async (id, names, _opts, command) => {
25243
+ var tagsSetCommand = new Command("tags-set").description("Replace a document tag set by tag ID").argument("<id>", "Document ID").argument("[tagIds...]", "Tag IDs (pass none to detach all)").action(async (id, tagIds, _opts, command) => {
24681
25244
  await runWithClient(command, async ({ client, config }) => {
24682
25245
  const accountId = requireAccountId(config);
24683
25246
  const tags = await withSpinner(
24684
25247
  "Replacing tags",
24685
25248
  config,
24686
- () => client.documents.replaceTags(id, names ?? [], accountId)
25249
+ () => client.documents.replaceTags(id, tagIds ?? [], accountId)
24687
25250
  );
24688
25251
  printSuccess(`Document now has ${tags.length} tag(s)`, config);
24689
25252
  printData(tags, config);
24690
25253
  });
24691
25254
  });
24692
- var tagsAddCommand = new Command("tags-add").description("Attach additional tags by name without removing existing ones").argument("<id>", "Document ID").argument("<names...>", "Tag names to attach").action(async (id, names, _opts, command) => {
25255
+ var tagsAddCommand = new Command("tags-add").description("Attach additional tag IDs without removing existing ones").argument("<id>", "Document ID").argument("<tagIds...>", "Tag IDs to attach").action(async (id, tagIds, _opts, command) => {
24693
25256
  await runWithClient(command, async ({ client, config }) => {
24694
25257
  const accountId = requireAccountId(config);
24695
25258
  const tags = await withSpinner(
24696
25259
  "Adding tags",
24697
25260
  config,
24698
- () => client.documents.addTags(id, names, accountId)
25261
+ () => client.documents.addTags(id, tagIds, accountId)
24699
25262
  );
24700
25263
  printSuccess(`Document now has ${tags.length} tag(s)`, config);
24701
25264
  printData(tags, config);
@@ -24867,7 +25430,7 @@ var fieldColumns = [
24867
25430
  { header: "REQUIRED", value: (r2) => r2.is_required },
24868
25431
  { header: "ACTIVE", value: (r2) => r2.is_active }
24869
25432
  ];
24870
- var createCommand2 = new Command("create").description("Create a custom field definition").requiredOption("--type <type>", "Field type (see `fields types`)").requiredOption("--name <name>", "Field name").option("--regex <regex>", "Validation regex").option("--required", "Mark the field as required").option("--inactive", "Create the field inactive").action(async (opts, command) => {
25433
+ var createCommand2 = new Command("create").description("Create a custom field definition").requiredOption("--type <type>", "Field type (see `fields types`)").requiredOption("--name <name>", "Field name").option("--regex <regex>", "Validation regex").option("--required", "Mark the field as required").option("--inactive", "Compatibility: create the field inactive").action(async (opts, command) => {
24871
25434
  await runWithClient(command, async ({ client, config }) => {
24872
25435
  const accountId = requireAccountId(config);
24873
25436
  const payload = { type: opts.type, name: opts.name };
@@ -24908,7 +25471,7 @@ var getCommand3 = new Command("get").description("Show a field definition by ID"
24908
25471
  printData(field, config, (f) => renderKeyValue(f));
24909
25472
  });
24910
25473
  });
24911
- var updateCommand = new Command("update").description("Update a field definition").argument("<id>", "Field ID").option("--type <type>", "Field type").option("--name <name>", "Field name").addOption(new Option("--regex <regex>", "Validation regex").conflicts("clearRegex")).addOption(new Option("--clear-regex", "Remove the existing validation regex").conflicts("regex")).addOption(new Option("--required", "Mark as required").conflicts("optional")).addOption(new Option("--optional", "Mark as not required").conflicts("required")).addOption(new Option("--active", "Activate the field").conflicts("inactive")).addOption(new Option("--inactive", "Deactivate the field").conflicts("active")).action(async (id, opts, command) => {
25474
+ var updateCommand = new Command("update").description("Update a field definition").argument("<id>", "Field ID").option("--type <type>", "Compatibility: change the field type").option("--name <name>", "Field name").addOption(new Option("--regex <regex>", "Validation regex").conflicts("clearRegex")).addOption(new Option("--clear-regex", "Remove the existing validation regex").conflicts("regex")).addOption(new Option("--required", "Compatibility: mark as required").conflicts("optional")).addOption(new Option("--optional", "Compatibility: mark as not required").conflicts("required")).addOption(new Option("--active", "Activate the field").conflicts("inactive")).addOption(new Option("--inactive", "Deactivate the field").conflicts("active")).action(async (id, opts, command) => {
24912
25475
  await runWithClient(command, async ({ client, config }) => {
24913
25476
  const accountId = requireAccountId(config);
24914
25477
  const payload = {};
@@ -25162,7 +25725,11 @@ var searchCommand2 = new Command("search").description("Search the signer's docu
25162
25725
  );
25163
25726
  });
25164
25727
  });
25165
- var downloadCommand2 = 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(accessCodeOption()).option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists").action(async (signerId, documentId, artifact, opts, command) => {
25728
+ var downloadCommand2 = 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(
25729
+ new Option("--access-code <code>", "Optional signer identity preflight code").env(
25730
+ "ASSINAFY_SIGNER_ACCESS_CODE"
25731
+ )
25732
+ ).option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists").action(async (signerId, documentId, artifact, opts, command) => {
25166
25733
  await runWithPublicClient(command, async ({ client, config }) => {
25167
25734
  const artifactName = requireDocumentArtifactName(artifact);
25168
25735
  const buffer = await withSpinner(
@@ -25330,7 +25897,7 @@ var declineMultipleCommand = new Command("decline-multiple").description("Declin
25330
25897
  printData(result, config);
25331
25898
  });
25332
25899
  });
25333
- var signerCommand = new Command("signer").description("Signer-side flows authenticated by a signer access code").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(acceptTermsCommand).addCommand(verifyEmailCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
25900
+ var signerCommand = new Command("signer").description("Signer-side flows and public artifact downloads").addCommand(documentCommand).addCommand(documentsCommand2).addCommand(searchCommand2).addCommand(downloadCommand2).addCommand(selfCommand).addCommand(acceptTermsCommand).addCommand(verifyEmailCommand).addCommand(confirmDataCommand).addCommand(uploadSignatureCommand).addCommand(downloadSignatureCommand).addCommand(assignmentCommand).addCommand(signCommand).addCommand(declineCommand).addCommand(signMultipleCommand).addCommand(declineMultipleCommand);
25334
25901
 
25335
25902
  // src/commands/signers.ts
25336
25903
  var signerColumns = [
@@ -25595,7 +26162,7 @@ var statsCommand = new Command("stats").description("Show document KPIs across t
25595
26162
  config,
25596
26163
  () => client.users.stats(params)
25597
26164
  );
25598
- printData(rows, config, renderStats);
26165
+ printData(rows, config, renderDocumentStats);
25599
26166
  });
25600
26167
  });
25601
26168
  var preferencesGetCommand = new Command("get").description("Show all owner-facing email notification preferences").action(async (_opts, command) => {
@@ -25632,16 +26199,6 @@ var preferencesUpdateCommand = new Command("update").description("Merge one or m
25632
26199
  });
25633
26200
  var preferencesCommand = new Command("notification-preferences").alias("preferences").description("Manage owner-facing email notification preferences").addCommand(preferencesGetCommand).addCommand(preferencesUpdateCommand);
25634
26201
  var usersCommand = new Command("users").description("Show the authenticated user and personal preferences").addCommand(selfCommand2).addCommand(statsCommand).addCommand(preferencesCommand);
25635
- function renderStats(rows) {
25636
- return renderTable(rows, [
25637
- { header: "PERIOD", value: (row) => row.period },
25638
- { header: "UPLOADED", value: (row) => row.documents_uploaded },
25639
- { header: "SENT", value: (row) => row.documents_sent },
25640
- { header: "REQUESTS", value: (row) => row.signature_requests },
25641
- { header: "COMPLETED", value: (row) => row.signature_requests_completed },
25642
- { header: "CERTIFIED", value: (row) => row.documents_certified }
25643
- ]);
25644
- }
25645
26202
 
25646
26203
  // src/commands/webhooks.ts
25647
26204
  var registerCommand = new Command("register").description("Register (or replace) the workspace webhook subscription").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) => {
@@ -25878,7 +26435,7 @@ var statsCommand2 = new Command("stats").description("Show document KPIs for a w
25878
26435
  config,
25879
26436
  () => client.workspaces.stats(id, params)
25880
26437
  );
25881
- printData(rows, config, renderStats2);
26438
+ printData(rows, config, renderDocumentStats);
25882
26439
  });
25883
26440
  });
25884
26441
  var logoDownloadCommand = new Command("download").description("Download the workspace logo").argument("<id>", "Account/workspace ID").option("-o, --output <path>", "Output file path").option("--force", "Overwrite the output file if it already exists").action(async (id, opts, command) => {
@@ -25943,16 +26500,6 @@ function logoContentType(file) {
25943
26500
  ".webp": "image/webp"
25944
26501
  }[import_node_path6.default.extname(file).toLowerCase()] ?? "image/png";
25945
26502
  }
25946
- function renderStats2(rows) {
25947
- return renderTable(rows, [
25948
- { header: "PERIOD", value: (row) => row.period },
25949
- { header: "UPLOADED", value: (row) => row.documents_uploaded },
25950
- { header: "SENT", value: (row) => row.documents_sent },
25951
- { header: "REQUESTS", value: (row) => row.signature_requests },
25952
- { header: "COMPLETED", value: (row) => row.signature_requests_completed },
25953
- { header: "CERTIFIED", value: (row) => row.documents_certified }
25954
- ]);
25955
- }
25956
26503
 
25957
26504
  // src/lib/cli-exit.ts
25958
26505
  var import_picocolors6 = __toESM(require_picocolors(), 1);
@@ -25991,7 +26538,7 @@ function handleStreamError(err, fallback, exit = process.exit) {
25991
26538
  // package.json
25992
26539
  var package_default = {
25993
26540
  name: "@assinafy/cli",
25994
- version: "2.0.2",
26541
+ version: "2.0.3",
25995
26542
  description: "The official command-line interface for the Assinafy digital-signature API",
25996
26543
  license: "MIT",
25997
26544
  type: "module",
@@ -26062,11 +26609,11 @@ var package_default = {
26062
26609
  prepublishOnly: "npm run typecheck && npm run lint && npm run test && npm run build && npm run verify:bundle"
26063
26610
  },
26064
26611
  dependencies: {
26065
- "@types/node": "^26.2.0",
26066
- axios: "^1.7.9"
26612
+ "@types/node": "^22.20.1",
26613
+ axios: "^1.20.0"
26067
26614
  },
26068
26615
  devDependencies: {
26069
- "@biomejs/biome": "^2.5.9",
26616
+ "@biomejs/biome": "^2.5.10",
26070
26617
  "@clack/prompts": "^1.7.0",
26071
26618
  "@commander-js/extra-typings": "^15.0.0",
26072
26619
  commander: "^15.0.0",
@@ -26100,7 +26647,7 @@ ${import_picocolors7.default.gray("Examples:")}
26100
26647
  ${import_picocolors7.default.blue("$ assinafy login")} Store an API key
26101
26648
  ${import_picocolors7.default.blue("$ assinafy whoami")} Verify credentials
26102
26649
  ${import_picocolors7.default.blue("$ assinafy documents upload contract.pdf")} Upload a PDF
26103
- ${import_picocolors7.default.blue('$ assinafy send contract.pdf --signer "Ana <ana@x.com>"')}
26650
+ ${import_picocolors7.default.blue('$ assinafy send contract.pdf --signer "Ana <ana@example.com>"')}
26104
26651
 
26105
26652
  ${import_picocolors7.default.gray("Sandbox:")} target it with ${import_picocolors7.default.blue("--base-url https://sandbox.assinafy.com.br/v1")}
26106
26653
  `