@termix-ssh/cli 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -13440,7 +13440,7 @@ var require_form_data = __commonJS({
13440
13440
  var CombinedStream = require_combined_stream();
13441
13441
  var util5 = __require("util");
13442
13442
  var path3 = __require("path");
13443
- var http3 = __require("http");
13443
+ var http4 = __require("http");
13444
13444
  var https3 = __require("https");
13445
13445
  var parseUrl2 = __require("url").parse;
13446
13446
  var fs8 = __require("fs");
@@ -13715,7 +13715,7 @@ var require_form_data = __commonJS({
13715
13715
  if (options2.protocol === "https:") {
13716
13716
  request = https3.request(options2);
13717
13717
  } else {
13718
- request = http3.request(options2);
13718
+ request = http4.request(options2);
13719
13719
  }
13720
13720
  this.getLength(function(err, length) {
13721
13721
  if (err && err !== "Unknown stream") {
@@ -15000,7 +15000,7 @@ var require_follow_redirects = __commonJS({
15000
15000
  "use strict";
15001
15001
  var url2 = __require("url");
15002
15002
  var URL2 = url2.URL;
15003
- var http3 = __require("http");
15003
+ var http4 = __require("http");
15004
15004
  var https3 = __require("https");
15005
15005
  var Writable2 = __require("stream").Writable;
15006
15006
  var assert = __require("assert");
@@ -15501,7 +15501,7 @@ var require_follow_redirects = __commonJS({
15501
15501
  function escapeRegex(regex) {
15502
15502
  return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
15503
15503
  }
15504
- module.exports = wrap2({ http: http3, https: https3 });
15504
+ module.exports = wrap2({ http: http4, https: https3 });
15505
15505
  module.exports.wrap = wrap2;
15506
15506
  }
15507
15507
  });
@@ -17742,7 +17742,7 @@ var require_websocket = __commonJS({
17742
17742
  "use strict";
17743
17743
  var EventEmitter2 = __require("events");
17744
17744
  var https3 = __require("https");
17745
- var http3 = __require("http");
17745
+ var http4 = __require("http");
17746
17746
  var net = __require("net");
17747
17747
  var tls = __require("tls");
17748
17748
  var { randomBytes, createHash } = __require("crypto");
@@ -18284,7 +18284,7 @@ var require_websocket = __commonJS({
18284
18284
  }
18285
18285
  const defaultPort = isSecure ? 443 : 80;
18286
18286
  const key = randomBytes(16).toString("base64");
18287
- const request = isSecure ? https3.request : http3.request;
18287
+ const request = isSecure ? https3.request : http4.request;
18288
18288
  const protocolSet = /* @__PURE__ */ new Set();
18289
18289
  let perMessageDeflate;
18290
18290
  opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
@@ -18780,7 +18780,7 @@ var require_websocket_server = __commonJS({
18780
18780
  "node_modules/ws/lib/websocket-server.js"(exports, module) {
18781
18781
  "use strict";
18782
18782
  var EventEmitter2 = __require("events");
18783
- var http3 = __require("http");
18783
+ var http4 = __require("http");
18784
18784
  var { Duplex } = __require("stream");
18785
18785
  var { createHash } = __require("crypto");
18786
18786
  var extension2 = require_extension();
@@ -18861,8 +18861,8 @@ var require_websocket_server = __commonJS({
18861
18861
  );
18862
18862
  }
18863
18863
  if (options2.port != null) {
18864
- this._server = http3.createServer((req, res) => {
18865
- const body = http3.STATUS_CODES[426];
18864
+ this._server = http4.createServer((req, res) => {
18865
+ const body = http4.STATUS_CODES[426];
18866
18866
  res.writeHead(426, {
18867
18867
  "Content-Length": body.length,
18868
18868
  "Content-Type": "text/plain"
@@ -19151,7 +19151,7 @@ var require_websocket_server = __commonJS({
19151
19151
  this.destroy();
19152
19152
  }
19153
19153
  function abortHandshake(socket, code, message, headers) {
19154
- message = message || http3.STATUS_CODES[code];
19154
+ message = message || http4.STATUS_CODES[code];
19155
19155
  headers = {
19156
19156
  Connection: "close",
19157
19157
  "Content-Type": "text/html",
@@ -19160,7 +19160,7 @@ var require_websocket_server = __commonJS({
19160
19160
  };
19161
19161
  socket.once("finish", socket.destroy);
19162
19162
  socket.end(
19163
- `HTTP/1.1 ${code} ${http3.STATUS_CODES[code]}\r
19163
+ `HTTP/1.1 ${code} ${http4.STATUS_CODES[code]}\r
19164
19164
  ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
19165
19165
  );
19166
19166
  }
@@ -23444,22 +23444,82 @@ var { toString } = Object.prototype;
23444
23444
  var { getPrototypeOf } = Object;
23445
23445
  var { iterator, toStringTag } = Symbol;
23446
23446
  var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
23447
+ var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
23448
+ var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
23449
+ var isSafeAndFullyMutable = (obj) => {
23450
+ if (!Object.isExtensible(obj)) {
23451
+ return false;
23452
+ }
23453
+ const props = Object.getOwnPropertyNames(obj);
23454
+ if (Object.getOwnPropertySymbols) {
23455
+ props.push(...Object.getOwnPropertySymbols(obj));
23456
+ }
23457
+ return props.every((prop) => {
23458
+ if (isUnsafeObjectKey(prop)) {
23459
+ return false;
23460
+ }
23461
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
23462
+ return !!descriptor && descriptor.configurable && descriptor.writable === true;
23463
+ });
23464
+ };
23447
23465
  var hasOwnInPrototypeChain = (thing, prop) => {
23448
23466
  let obj = thing;
23449
23467
  const seen = [];
23450
- while (obj != null && obj !== Object.prototype) {
23468
+ while (obj != null) {
23451
23469
  if (seen.indexOf(obj) !== -1) {
23452
23470
  return false;
23453
23471
  }
23454
23472
  seen.push(obj);
23473
+ const prototype2 = getPrototypeOf(obj);
23474
+ if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
23475
+ return false;
23476
+ }
23455
23477
  if (hasOwnProperty(obj, prop)) {
23456
23478
  return true;
23457
23479
  }
23458
- obj = getPrototypeOf(obj);
23480
+ obj = prototype2;
23459
23481
  }
23460
23482
  return false;
23461
23483
  };
23462
23484
  var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
23485
+ var toSafeFlatObject = (thing) => {
23486
+ if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
23487
+ return thing;
23488
+ }
23489
+ const sourcePrototype = getPrototypeOf(thing);
23490
+ if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
23491
+ return thing;
23492
+ }
23493
+ const result = /* @__PURE__ */ Object.create(null);
23494
+ const merged = /* @__PURE__ */ Object.create(null);
23495
+ const seen = [];
23496
+ let current = thing;
23497
+ while (current != null) {
23498
+ if (seen.indexOf(current) !== -1) {
23499
+ break;
23500
+ }
23501
+ seen.push(current);
23502
+ const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
23503
+ if (isPrototypeBoundary(current, prototype2, current === thing)) {
23504
+ break;
23505
+ }
23506
+ const props = Object.getOwnPropertyNames(current);
23507
+ if (Object.getOwnPropertySymbols) {
23508
+ props.push(...Object.getOwnPropertySymbols(current));
23509
+ }
23510
+ for (const prop of props) {
23511
+ if (isUnsafeObjectKey(prop)) {
23512
+ continue;
23513
+ }
23514
+ if (!hasOwnProperty(merged, prop)) {
23515
+ result[prop] = thing[prop];
23516
+ merged[prop] = true;
23517
+ }
23518
+ }
23519
+ current = prototype2;
23520
+ }
23521
+ return result;
23522
+ };
23463
23523
  var kindOf = /* @__PURE__ */ ((cache2) => (thing) => {
23464
23524
  const str = toString.call(thing);
23465
23525
  return cache2[str] || (cache2[str] = str.slice(8, -1).toLowerCase());
@@ -23494,9 +23554,9 @@ var isPlainObject = (val) => {
23494
23554
  return false;
23495
23555
  }
23496
23556
  const prototype2 = getPrototypeOf(val);
23497
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
23498
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
23499
- // than a plain object, while ignoring keys injected onto Object.prototype.
23557
+ return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
23558
+ // evidence the value is tagged/iterable, while ignoring members reachable
23559
+ // only through shared or terminal prototype boundaries.
23500
23560
  !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
23501
23561
  };
23502
23562
  var isEmptyObject = (val) => {
@@ -23907,6 +23967,7 @@ var utils_default = {
23907
23967
  // an alias to avoid ESLint no-prototype-builtins detection
23908
23968
  hasOwnInPrototypeChain,
23909
23969
  getSafeProp,
23970
+ toSafeFlatObject,
23910
23971
  reduceDescriptors,
23911
23972
  freezeMethods,
23912
23973
  toObjectSet,
@@ -24545,24 +24606,16 @@ function toFormData(obj, formData, options2) {
24545
24606
  throw new TypeError("target must be an object");
24546
24607
  }
24547
24608
  formData = formData || new (FormData_default || FormData)();
24548
- options2 = utils_default.toFlatObject(
24549
- options2,
24550
- {
24551
- metaTokens: true,
24552
- dots: false,
24553
- indexes: false
24554
- },
24555
- false,
24556
- function defined(option, source) {
24557
- return !utils_default.isUndefined(source[option]);
24558
- }
24559
- );
24560
- const metaTokens = options2.metaTokens;
24561
- const visitor = options2.visitor || defaultVisitor;
24562
- const dots = options2.dots;
24563
- const indexes = options2.indexes;
24564
- const _Blob = options2.Blob || typeof Blob !== "undefined" && Blob;
24565
- const maxDepth = options2.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options2.maxDepth;
24609
+ const option = (name, fallback) => {
24610
+ const value = utils_default.getSafeProp(options2, name);
24611
+ return utils_default.isUndefined(value) ? fallback : value;
24612
+ };
24613
+ const metaTokens = option("metaTokens", true);
24614
+ const visitor = option("visitor") || defaultVisitor;
24615
+ const dots = option("dots", false);
24616
+ const indexes = option("indexes", false);
24617
+ const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
24618
+ const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
24566
24619
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
24567
24620
  const stack = [];
24568
24621
  if (!utils_default.isFunction(visitor)) {
@@ -24586,7 +24639,10 @@ function toFormData(obj, formData, options2) {
24586
24639
  if (Buffer_default && Buffer_default.isBufferAvailable()) {
24587
24640
  return Buffer_default.from(value);
24588
24641
  }
24589
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.", AxiosError_default.ERR_NOT_SUPPORT);
24642
+ throw new AxiosError_default(
24643
+ "Blob is not supported. Use a Buffer instead.",
24644
+ AxiosError_default.ERR_NOT_SUPPORT
24645
+ );
24590
24646
  }
24591
24647
  return value;
24592
24648
  }
@@ -24732,9 +24788,47 @@ function buildURL(url2, params, options2) {
24732
24788
  }
24733
24789
 
24734
24790
  // node_modules/axios/lib/core/InterceptorManager.js
24791
+ var $internals2 = /* @__PURE__ */ Symbol("internals");
24792
+ function countHandlers(handlers) {
24793
+ return handlers ? handlers.length : 0;
24794
+ }
24795
+ function trimHandlers(handlers) {
24796
+ if (!handlers) {
24797
+ return;
24798
+ }
24799
+ while (handlers.length && handlers[handlers.length - 1] === null) {
24800
+ handlers.pop();
24801
+ }
24802
+ }
24803
+ function syncHandlerEntries(manager, internals) {
24804
+ const handlers = manager.handlers;
24805
+ const length = countHandlers(handlers);
24806
+ if (handlers !== internals.handlersRef) {
24807
+ internals.handlersRef = handlers;
24808
+ internals.handlerEntries.clear();
24809
+ } else if (length !== internals.handlersLength) {
24810
+ if (!length) {
24811
+ internals.handlerEntries.clear();
24812
+ } else {
24813
+ internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
24814
+ if (handlers[entry.index] !== entry.handler) {
24815
+ internals.handlerEntries.delete(id);
24816
+ }
24817
+ });
24818
+ }
24819
+ }
24820
+ internals.handlersLength = length;
24821
+ }
24735
24822
  var InterceptorManager = class {
24736
24823
  constructor() {
24737
24824
  this.handlers = [];
24825
+ this[$internals2] = {
24826
+ handlersRef: this.handlers,
24827
+ handlersLength: this.handlers.length,
24828
+ handlerEntries: /* @__PURE__ */ new Map(),
24829
+ iterationDepth: 0,
24830
+ nextId: 0
24831
+ };
24738
24832
  }
24739
24833
  /**
24740
24834
  * Add a new interceptor to the stack
@@ -24746,13 +24840,25 @@ var InterceptorManager = class {
24746
24840
  * @return {Number} An ID used to remove interceptor later
24747
24841
  */
24748
24842
  use(fulfilled, rejected, options2) {
24749
- this.handlers.push({
24843
+ const handler = {
24750
24844
  fulfilled,
24751
24845
  rejected,
24752
24846
  synchronous: options2 ? options2.synchronous : false,
24753
24847
  runWhen: options2 ? options2.runWhen : null
24848
+ };
24849
+ const internals = this[$internals2];
24850
+ if (this.handlers == null) {
24851
+ this.handlers = [];
24852
+ }
24853
+ syncHandlerEntries(this, internals);
24854
+ const id = internals.nextId++;
24855
+ this.handlers.push(handler);
24856
+ internals.handlerEntries.set(id, {
24857
+ handler,
24858
+ index: this.handlers.length - 1
24754
24859
  });
24755
- return this.handlers.length - 1;
24860
+ internals.handlersLength = this.handlers.length;
24861
+ return id;
24756
24862
  }
24757
24863
  /**
24758
24864
  * Remove an interceptor from the stack
@@ -24762,8 +24868,19 @@ var InterceptorManager = class {
24762
24868
  * @returns {void}
24763
24869
  */
24764
24870
  eject(id) {
24765
- if (this.handlers[id]) {
24766
- this.handlers[id] = null;
24871
+ const internals = this[$internals2];
24872
+ syncHandlerEntries(this, internals);
24873
+ const entry = internals.handlerEntries.get(id);
24874
+ if (entry) {
24875
+ internals.handlerEntries.delete(id);
24876
+ if (this.handlers[entry.index] !== entry.handler) {
24877
+ return;
24878
+ }
24879
+ this.handlers[entry.index] = null;
24880
+ if (!internals.iterationDepth) {
24881
+ trimHandlers(this.handlers);
24882
+ internals.handlersLength = this.handlers.length;
24883
+ }
24767
24884
  }
24768
24885
  }
24769
24886
  /**
@@ -24774,6 +24891,7 @@ var InterceptorManager = class {
24774
24891
  clear() {
24775
24892
  if (this.handlers) {
24776
24893
  this.handlers = [];
24894
+ syncHandlerEntries(this, this[$internals2]);
24777
24895
  }
24778
24896
  }
24779
24897
  /**
@@ -24787,11 +24905,22 @@ var InterceptorManager = class {
24787
24905
  * @returns {void}
24788
24906
  */
24789
24907
  forEach(fn) {
24790
- utils_default.forEach(this.handlers, function forEachHandler(h) {
24791
- if (h !== null) {
24792
- fn(h);
24908
+ const internals = this[$internals2];
24909
+ syncHandlerEntries(this, internals);
24910
+ internals.iterationDepth++;
24911
+ try {
24912
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
24913
+ if (h !== null) {
24914
+ fn(h);
24915
+ }
24916
+ });
24917
+ } finally {
24918
+ if (!--internals.iterationDepth) {
24919
+ syncHandlerEntries(this, internals);
24920
+ trimHandlers(this.handlers);
24921
+ internals.handlersLength = countHandlers(this.handlers);
24793
24922
  }
24794
- });
24923
+ }
24795
24924
  }
24796
24925
  };
24797
24926
  var InterceptorManager_default = InterceptorManager;
@@ -24949,6 +25078,22 @@ function formDataToJSON(formData) {
24949
25078
  }
24950
25079
  var formDataToJSON_default = formDataToJSON;
24951
25080
 
25081
+ // node_modules/axios/lib/core/methodList.js
25082
+ var methodList = Object.freeze([
25083
+ "get",
25084
+ "delete",
25085
+ "head",
25086
+ "options",
25087
+ "post",
25088
+ "put",
25089
+ "patch",
25090
+ "purge",
25091
+ "link",
25092
+ "unlink",
25093
+ "query"
25094
+ ]);
25095
+ var methodList_default = methodList;
25096
+
24952
25097
  // node_modules/axios/lib/defaults/index.js
24953
25098
  var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
24954
25099
  function stringifySafely2(rawValue, parser, encoder) {
@@ -25061,7 +25206,7 @@ var defaults = {
25061
25206
  }
25062
25207
  }
25063
25208
  };
25064
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
25209
+ utils_default.forEach(methodList_default, (method) => {
25065
25210
  defaults.headers[method] = {};
25066
25211
  });
25067
25212
  var defaults_default = defaults;
@@ -25139,19 +25284,21 @@ function combineURLs(baseURL, relativeURL) {
25139
25284
  return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
25140
25285
  }
25141
25286
 
25142
- // node_modules/axios/lib/core/buildFullPath.js
25143
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
25144
- var httpProtocolControlCharacters = /[\t\n\r]/g;
25145
- function stripLeadingC0ControlOrSpace(url2) {
25146
- let i = 0;
25147
- while (i < url2.length && url2.charCodeAt(i) <= 32) {
25148
- i++;
25149
- }
25150
- return url2.slice(i);
25151
- }
25287
+ // node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
25288
+ var urlParserControlCharacters = /[\t\n\r]/g;
25152
25289
  function normalizeURLForProtocolCheck(url2) {
25153
- return stripLeadingC0ControlOrSpace(url2).replace(httpProtocolControlCharacters, "");
25290
+ if (typeof url2 !== "string") {
25291
+ return url2;
25292
+ }
25293
+ let start = 0;
25294
+ while (start < url2.length && url2.charCodeAt(start) <= 32) {
25295
+ start++;
25296
+ }
25297
+ return url2.slice(start).replace(urlParserControlCharacters, "");
25154
25298
  }
25299
+
25300
+ // node_modules/axios/lib/core/buildFullPath.js
25301
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
25155
25302
  function redactFragment(fragment) {
25156
25303
  if (!fragment) {
25157
25304
  return fragment;
@@ -25273,7 +25420,7 @@ import { resolve as resolvePath } from "path";
25273
25420
  import zlib from "zlib";
25274
25421
 
25275
25422
  // node_modules/axios/lib/env/data.js
25276
- var VERSION = "1.19.0";
25423
+ var VERSION = "1.20.0";
25277
25424
 
25278
25425
  // node_modules/axios/lib/helpers/parseProtocol.js
25279
25426
  function parseProtocol(url2) {
@@ -25282,7 +25429,7 @@ function parseProtocol(url2) {
25282
25429
  }
25283
25430
 
25284
25431
  // node_modules/axios/lib/helpers/fromDataURI.js
25285
- var DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
25432
+ var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
25286
25433
  function fromDataURI(uri, asBlob, options2) {
25287
25434
  const _Blob = options2 && options2.Blob || platform_default.classes.Blob;
25288
25435
  const protocol = parseProtocol(uri);
@@ -25595,6 +25742,7 @@ var Http2Sessions = class {
25595
25742
  }
25596
25743
  getSession(authority, options2) {
25597
25744
  options2 = Object.assign(
25745
+ /* @__PURE__ */ Object.create(null),
25598
25746
  {
25599
25747
  sessionTimeout: 1e3
25600
25748
  },
@@ -25660,6 +25808,7 @@ var Http2Sessions = class {
25660
25808
  };
25661
25809
  }
25662
25810
  session.once("close", removeSession);
25811
+ session.once("error", removeSession);
25663
25812
  let entry = [session, options2];
25664
25813
  authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
25665
25814
  return session;
@@ -25684,6 +25833,13 @@ var callbackify_default = callbackify;
25684
25833
 
25685
25834
  // node_modules/axios/lib/helpers/shouldBypassProxy.js
25686
25835
  var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
25836
+ var trimTrailingDots = (value) => {
25837
+ let end = value.length;
25838
+ while (end && value.charCodeAt(end - 1) === 46) {
25839
+ end--;
25840
+ }
25841
+ return end === value.length ? value : value.slice(0, end);
25842
+ };
25687
25843
  var isIPv4Loopback = (host) => {
25688
25844
  const parts = host.split(".");
25689
25845
  if (parts.length !== 4) return false;
@@ -25716,7 +25872,7 @@ var normalizeIPAddress = (host) => {
25716
25872
  if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
25717
25873
  h = h.slice(1, -1);
25718
25874
  }
25719
- h = h.replace(/\.+$/, "");
25875
+ h = trimTrailingDots(h);
25720
25876
  if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
25721
25877
  const parts = h.split(".");
25722
25878
  if (parts.some((p) => p === "")) return host;
@@ -25828,6 +25984,40 @@ var unmapIPv4MappedIPv6 = (host) => {
25828
25984
  }
25829
25985
  return host;
25830
25986
  };
25987
+ var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
25988
+ var ipv4ToBytes = (host) => {
25989
+ const parts = host.split(".");
25990
+ return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
25991
+ };
25992
+ var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
25993
+ var ipv6ToBytes = (host) => {
25994
+ const halves = host.split("::");
25995
+ if (halves.length > 2) {
25996
+ return null;
25997
+ }
25998
+ const groups = halves[0] ? halves[0].split(":") : [];
25999
+ if (halves.length === 2) {
26000
+ const rear = halves[1] ? halves[1].split(":") : [];
26001
+ const missing = 8 - groups.length - rear.length;
26002
+ if (missing < 1) {
26003
+ return null;
26004
+ }
26005
+ groups.push(...new Array(missing).fill("0"), ...rear);
26006
+ }
26007
+ if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
26008
+ return null;
26009
+ }
26010
+ return groups.flatMap((group) => {
26011
+ const value = Number.parseInt(group, 16);
26012
+ return [value >> 8 & 255, value & 255];
26013
+ });
26014
+ };
26015
+ var ipToBytes = (host) => {
26016
+ if (typeof host !== "string" || !host) {
26017
+ return null;
26018
+ }
26019
+ return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
26020
+ };
25831
26021
  var normalizeNoProxyHost = (hostname) => {
25832
26022
  if (!hostname) {
25833
26023
  return hostname;
@@ -25835,13 +26025,90 @@ var normalizeNoProxyHost = (hostname) => {
25835
26025
  if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
25836
26026
  hostname = hostname.slice(1, -1);
25837
26027
  }
25838
- const trimmed = hostname.replace(/\.+$/, "");
26028
+ const trimmed = trimTrailingDots(hostname);
25839
26029
  const ipv4 = normalizeIPAddress(trimmed);
25840
26030
  if (ipv4 !== trimmed) {
25841
26031
  return ipv4;
25842
26032
  }
25843
26033
  return unmapIPv4MappedIPv6(trimmed);
25844
26034
  };
26035
+ var normalizeCidrBase = (input) => {
26036
+ let base = input;
26037
+ const startsBracket = base.charAt(0) === "[";
26038
+ const endsBracket = base.charAt(base.length - 1) === "]";
26039
+ const hasBracket = base.includes("[") || base.includes("]");
26040
+ if (startsBracket || endsBracket) {
26041
+ if (!startsBracket || !endsBracket) {
26042
+ return null;
26043
+ }
26044
+ base = base.slice(1, -1);
26045
+ if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
26046
+ return null;
26047
+ }
26048
+ } else if (hasBracket) {
26049
+ return null;
26050
+ }
26051
+ if (!base || base.charAt(base.length - 1) === ".") {
26052
+ return null;
26053
+ }
26054
+ const wasIPv6 = base.indexOf(":") !== -1;
26055
+ if (wasIPv6) {
26056
+ try {
26057
+ base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
26058
+ } catch (_err) {
26059
+ return null;
26060
+ }
26061
+ } else {
26062
+ base = normalizeIPAddress(base);
26063
+ if (!ipv4ToBytes(base)) {
26064
+ return null;
26065
+ }
26066
+ }
26067
+ return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
26068
+ };
26069
+ var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
26070
+ var parseCidrEntry = (entry) => {
26071
+ if (entry.indexOf("/") === -1) {
26072
+ return void 0;
26073
+ }
26074
+ const match = CIDR_ENTRY_RE.exec(entry);
26075
+ if (!match) {
26076
+ return null;
26077
+ }
26078
+ let prefix = Number(match[2]);
26079
+ const parsedBase = normalizeCidrBase(match[1]);
26080
+ if (!parsedBase) {
26081
+ return null;
26082
+ }
26083
+ const { normalized, wasIPv6 } = parsedBase;
26084
+ if (wasIPv6 && normalized.indexOf(":") === -1) {
26085
+ if (prefix < 96) {
26086
+ return null;
26087
+ }
26088
+ prefix -= 96;
26089
+ }
26090
+ const bytes = ipToBytes(normalized);
26091
+ if (!bytes || prefix > bytes.length * 8) {
26092
+ return null;
26093
+ }
26094
+ return { bytes, prefix };
26095
+ };
26096
+ var isInSubnet = (addressBytes, networkBytes, prefix) => {
26097
+ const fullBytes = prefix >> 3;
26098
+ for (let i = 0; i < fullBytes; i++) {
26099
+ if (addressBytes[i] !== networkBytes[i]) {
26100
+ return false;
26101
+ }
26102
+ }
26103
+ const remainingBits = prefix & 7;
26104
+ if (remainingBits) {
26105
+ const mask = 255 << 8 - remainingBits & 255;
26106
+ if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
26107
+ return false;
26108
+ }
26109
+ }
26110
+ return true;
26111
+ };
25845
26112
  function shouldBypassProxy(location) {
25846
26113
  let parsed;
25847
26114
  try {
@@ -25858,6 +26125,7 @@ function shouldBypassProxy(location) {
25858
26125
  }
25859
26126
  const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
25860
26127
  const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
26128
+ const hostnameBytes = ipToBytes(hostname);
25861
26129
  return noProxy.split(/[\s,]+/).some((entry) => {
25862
26130
  if (!entry) {
25863
26131
  return false;
@@ -25865,6 +26133,10 @@ function shouldBypassProxy(location) {
25865
26133
  if (entry === "*") {
25866
26134
  return true;
25867
26135
  }
26136
+ const cidr = parseCidrEntry(entry);
26137
+ if (cidr !== void 0) {
26138
+ return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
26139
+ }
25868
26140
  let [entryHost, entryPort] = parseNoProxyEntry(entry);
25869
26141
  entryHost = normalizeNoProxyHost(entryHost);
25870
26142
  if (!entryHost) {
@@ -25950,7 +26222,8 @@ function throttle(fn, freq) {
25950
26222
  }
25951
26223
  };
25952
26224
  const flush = () => lastArgs && invoke(lastArgs);
25953
- return [throttled, flush];
26225
+ const flushWith = (...args) => invoke(args);
26226
+ return [throttled, flush, flushWith];
25954
26227
  }
25955
26228
  var throttle_default = throttle;
25956
26229
 
@@ -25959,7 +26232,7 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
25959
26232
  let bytesNotified = 0;
25960
26233
  const _speedometer = speedometer_default(50, 250);
25961
26234
  return throttle_default((e) => {
25962
- if (!e || typeof e.loaded !== "number") {
26235
+ if (!e || !utils_default.isNumber(e.loaded)) {
25963
26236
  return;
25964
26237
  }
25965
26238
  const rawLoaded = e.loaded;
@@ -26120,6 +26393,12 @@ var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
26120
26393
  var isHttps = /https:?/;
26121
26394
  var kAxiosSocketListener = /* @__PURE__ */ Symbol("axios.http.socketListener");
26122
26395
  var kAxiosCurrentReq = /* @__PURE__ */ Symbol("axios.http.currentReq");
26396
+ function handleSocketError(err) {
26397
+ const current = this[kAxiosCurrentReq];
26398
+ if (current && !current.destroyed) {
26399
+ current.destroy(err);
26400
+ }
26401
+ }
26123
26402
  var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
26124
26403
  var tunnelingAgentCache = /* @__PURE__ */ new Map();
26125
26404
  var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
@@ -26222,10 +26501,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
26222
26501
  return false;
26223
26502
  }
26224
26503
  }
26225
- function setProxy(options2, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
26504
+ function setProxy(options2, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
26226
26505
  let proxy = configProxy;
26227
26506
  const proxyEnvAgent = getProxyEnvAgent(options2, configHttpAgent, configHttpsAgent);
26228
- if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
26507
+ if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
26229
26508
  const proxyUrl = getProxyForUrl(location);
26230
26509
  if (proxyUrl) {
26231
26510
  if (!shouldBypassProxy(location)) {
@@ -26322,9 +26601,13 @@ function setProxy(options2, configProxy, location, isRedirect, configHttpsAgent,
26322
26601
  redirectOptions.href,
26323
26602
  true,
26324
26603
  configHttpsAgent,
26325
- configHttpAgent
26604
+ configHttpAgent,
26605
+ allowEnvProxy
26326
26606
  );
26327
26607
  };
26608
+ return Boolean(
26609
+ proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
26610
+ );
26328
26611
  }
26329
26612
  var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
26330
26613
  var wrapAsync = (asyncExecutor) => {
@@ -26349,7 +26632,7 @@ var wrapAsync = (asyncExecutor) => {
26349
26632
  };
26350
26633
  var resolveFamily = ({ address, family }) => {
26351
26634
  if (!utils_default.isString(address)) {
26352
- throw TypeError("address must be a string");
26635
+ throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
26353
26636
  }
26354
26637
  return {
26355
26638
  address,
@@ -26357,6 +26640,30 @@ var resolveFamily = ({ address, family }) => {
26357
26640
  };
26358
26641
  };
26359
26642
  var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
26643
+ var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
26644
+ var normalizeLookup = (lookup) => {
26645
+ let normalized = normalizedLookupCache.get(lookup);
26646
+ if (normalized) {
26647
+ return normalized;
26648
+ }
26649
+ const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
26650
+ normalized = (hostname, opt, cb) => {
26651
+ callbackLookup(hostname, opt, (err, arg0, arg1) => {
26652
+ if (err) {
26653
+ return cb(err);
26654
+ }
26655
+ let addresses;
26656
+ try {
26657
+ addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
26658
+ } catch (error) {
26659
+ return cb(error);
26660
+ }
26661
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
26662
+ });
26663
+ };
26664
+ normalizedLookupCache.set(lookup, normalized);
26665
+ return normalized;
26666
+ };
26360
26667
  var http2Transport = {
26361
26668
  request(options2, cb) {
26362
26669
  const authority = options2.protocol + "//" + options2.hostname + ":" + (options2.port || (options2.protocol === "https:" ? 443 : 80));
@@ -26393,6 +26700,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26393
26700
  let family = own2("family");
26394
26701
  let httpVersion = own2("httpVersion");
26395
26702
  if (httpVersion === void 0) httpVersion = 1;
26703
+ const rawHttpVersion = httpVersion;
26396
26704
  let http2Options = own2("http2Options");
26397
26705
  const httpAgent = own2("httpAgent");
26398
26706
  const httpsAgent = own2("httpsAgent");
@@ -26409,25 +26717,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26409
26717
  let rejected = false;
26410
26718
  let req;
26411
26719
  let connectPhaseTimer;
26412
- httpVersion = +httpVersion;
26720
+ try {
26721
+ httpVersion = +httpVersion;
26722
+ } catch (err) {
26723
+ throw new AxiosError_default(
26724
+ "Invalid protocol version: value is not a number",
26725
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
26726
+ config
26727
+ );
26728
+ }
26413
26729
  if (Number.isNaN(httpVersion)) {
26414
- throw TypeError(`Invalid protocol version: '${config.httpVersion}' is not a number`);
26730
+ throw new AxiosError_default(
26731
+ `Invalid protocol version: '${rawHttpVersion}' is not a number`,
26732
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
26733
+ config
26734
+ );
26415
26735
  }
26416
26736
  if (httpVersion !== 1 && httpVersion !== 2) {
26417
- throw TypeError(`Unsupported protocol version '${httpVersion}'`);
26737
+ throw new AxiosError_default(
26738
+ `Unsupported protocol version '${httpVersion}'`,
26739
+ AxiosError_default.ERR_BAD_OPTION_VALUE,
26740
+ config
26741
+ );
26418
26742
  }
26419
26743
  const isHttp2 = httpVersion === 2;
26420
26744
  if (lookup) {
26421
- const _lookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
26422
- lookup = (hostname, opt, cb) => {
26423
- _lookup(hostname, opt, (err, arg0, arg1) => {
26424
- if (err) {
26425
- return cb(err);
26426
- }
26427
- const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
26428
- opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
26429
- });
26430
- };
26745
+ lookup = normalizeLookup(lookup);
26431
26746
  }
26432
26747
  const abortEmitter = new EventEmitter();
26433
26748
  function abort(reason) {
@@ -26670,6 +26985,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26670
26985
  utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
26671
26986
  false
26672
26987
  );
26988
+ if (isHttp2 && lookup) {
26989
+ http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
26990
+ }
26673
26991
  const options2 = Object.assign(/* @__PURE__ */ Object.create(null), {
26674
26992
  path: path3,
26675
26993
  method,
@@ -26680,9 +26998,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26680
26998
  family,
26681
26999
  beforeRedirect: dispatchBeforeRedirect,
26682
27000
  beforeRedirects: /* @__PURE__ */ Object.create(null),
26683
- http2Options
27001
+ http2Options,
27002
+ createConnection: void 0
26684
27003
  });
26685
27004
  !utils_default.isUndefined(lookup) && (options2.lookup = lookup);
27005
+ let proxyApplied = false;
26686
27006
  if (socketPath) {
26687
27007
  if (typeof socketPath !== "string") {
26688
27008
  return reject(
@@ -26710,13 +27030,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26710
27030
  } else {
26711
27031
  options2.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
26712
27032
  options2.port = parsed.port;
26713
- setProxy(
27033
+ proxyApplied = setProxy(
26714
27034
  options2,
26715
27035
  configProxy,
26716
27036
  protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options2.path,
26717
27037
  false,
26718
27038
  httpsAgent,
26719
- httpAgent
27039
+ httpAgent,
27040
+ // The HTTP/2 transport connects independently of HTTP/1 agents, so it
27041
+ // cannot apply either axios-resolved or agent-local environment proxies.
27042
+ // Explicit proxy config is still processed and rejected below.
27043
+ !isHttp2
26720
27044
  );
26721
27045
  }
26722
27046
  let transport;
@@ -26727,6 +27051,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26727
27051
  options2.agent = isHttpsRequest ? httpsAgent : httpAgent;
26728
27052
  }
26729
27053
  if (isHttp2) {
27054
+ if (proxyApplied) {
27055
+ return reject(
27056
+ new AxiosError_default(
27057
+ "HTTP/2 requests with a proxy are not supported",
27058
+ AxiosError_default.ERR_NOT_SUPPORT,
27059
+ config
27060
+ )
27061
+ );
27062
+ }
26730
27063
  transport = http2Transport;
26731
27064
  } else {
26732
27065
  const configTransport = own2("transport");
@@ -26814,7 +27147,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26814
27147
  transformStream,
26815
27148
  progressEventDecorator(
26816
27149
  responseLength,
26817
- progressEventReducer(asyncDecorator(onDownloadProgress, scheduleProgress), true, 3)
27150
+ progressEventReducer(
27151
+ asyncDecorator(onDownloadProgress, scheduleProgress),
27152
+ true,
27153
+ 3
27154
+ )
26818
27155
  )
26819
27156
  )
26820
27157
  );
@@ -26963,12 +27300,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
26963
27300
  socket.setKeepAlive(true, 1e3 * 60);
26964
27301
  }
26965
27302
  if (!socket[kAxiosSocketListener]) {
26966
- socket.on("error", function handleSocketError(err) {
26967
- const current = socket[kAxiosCurrentReq];
26968
- if (current && !current.destroyed) {
26969
- current.destroy(err);
26970
- }
26971
- });
27303
+ socket.on("error", handleSocketError);
26972
27304
  socket[kAxiosSocketListener] = true;
26973
27305
  }
26974
27306
  socket[kAxiosCurrentReq] = req;
@@ -27213,7 +27545,7 @@ function mergeConfig(config1, config2) {
27213
27545
  transformResponse: defaultToConfig2,
27214
27546
  paramsSerializer: defaultToConfig2,
27215
27547
  timeout: defaultToConfig2,
27216
- timeoutMessage: defaultToConfig2,
27548
+ timeoutErrorMessage: defaultToConfig2,
27217
27549
  withCredentials: defaultToConfig2,
27218
27550
  withXSRFToken: defaultToConfig2,
27219
27551
  adapter: defaultToConfig2,
@@ -27290,10 +27622,11 @@ function resolveConfig2(config) {
27290
27622
  }
27291
27623
  }
27292
27624
  if (utils_default.isFormData(data)) {
27625
+ const getHeaders = utils_default.getSafeProp(data, "getHeaders");
27293
27626
  if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
27294
27627
  headers.setContentType(void 0);
27295
- } else if (utils_default.isFunction(data.getHeaders)) {
27296
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
27628
+ } else if (utils_default.isFunction(getHeaders)) {
27629
+ setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
27297
27630
  }
27298
27631
  }
27299
27632
  if (platform_default.hasStandardBrowserEnv) {
@@ -27322,7 +27655,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
27322
27655
  let { responseType, onUploadProgress, onDownloadProgress } = _config;
27323
27656
  let onCanceled;
27324
27657
  let uploadThrottled, downloadThrottled;
27325
- let flushUpload, flushDownload;
27658
+ let flushUpload, flushDownload, flushDownloadWithEvent;
27326
27659
  function done() {
27327
27660
  flushUpload && flushUpload();
27328
27661
  flushDownload && flushDownload();
@@ -27332,7 +27665,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
27332
27665
  let request = new XMLHttpRequest();
27333
27666
  request.open(_config.method.toUpperCase(), _config.url, true);
27334
27667
  request.timeout = _config.timeout;
27335
- function onloadend() {
27668
+ function onloadend(event) {
27669
+ if (!request) {
27670
+ return;
27671
+ }
27672
+ if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
27673
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
27674
+ done();
27675
+ request = null;
27676
+ return;
27677
+ }
27678
+ try {
27679
+ if (event) {
27680
+ flushDownloadWithEvent && flushDownloadWithEvent(event);
27681
+ } else {
27682
+ flushDownload && flushDownload();
27683
+ }
27684
+ } catch (err) {
27685
+ setTimeout(() => {
27686
+ throw err;
27687
+ });
27688
+ }
27336
27689
  if (!request) {
27337
27690
  return;
27338
27691
  }
@@ -27420,7 +27773,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
27420
27773
  request.responseType = _config.responseType;
27421
27774
  }
27422
27775
  if (onDownloadProgress) {
27423
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
27776
+ [downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
27777
+ onDownloadProgress,
27778
+ true
27779
+ );
27424
27780
  request.addEventListener("progress", downloadThrottled);
27425
27781
  }
27426
27782
  if (onUploadProgress && request.upload) {
@@ -27590,6 +27946,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
27590
27946
 
27591
27947
  // node_modules/axios/lib/adapters/fetch.js
27592
27948
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
27949
+ var DEFAULT_REQUEST_OPTIONS = {
27950
+ cache: "default",
27951
+ redirect: "follow",
27952
+ referrer: "about:client",
27953
+ referrerPolicy: "",
27954
+ mode: "cors",
27955
+ integrity: "",
27956
+ keepalive: false,
27957
+ priority: "auto",
27958
+ window: null
27959
+ };
27593
27960
  var { isFunction: isFunction2 } = utils_default;
27594
27961
  var encodeUTF82 = (str) => encodeURIComponent(str).replace(
27595
27962
  /%([0-9A-F]{2})/gi,
@@ -27720,7 +28087,8 @@ var factory = (env) => {
27720
28087
  withCredentials = "same-origin",
27721
28088
  fetchOptions,
27722
28089
  maxContentLength,
27723
- maxBodyLength
28090
+ maxBodyLength,
28091
+ maxRedirects
27724
28092
  } = resolveConfig_default(config);
27725
28093
  const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
27726
28094
  const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
@@ -27850,17 +28218,44 @@ var factory = (env) => {
27850
28218
  }
27851
28219
  }
27852
28220
  headers.set("User-Agent", "axios/" + VERSION, false);
27853
- const resolvedOptions = {
27854
- ...fetchOptions,
28221
+ const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
28222
+ if (safeFetchOptions) {
28223
+ delete safeFetchOptions.body;
28224
+ delete safeFetchOptions.headers;
28225
+ delete safeFetchOptions.method;
28226
+ delete safeFetchOptions.signal;
28227
+ delete safeFetchOptions.duplex;
28228
+ delete safeFetchOptions.credentials;
28229
+ }
28230
+ const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
27855
28231
  signal: composedSignal,
27856
28232
  method: method.toUpperCase(),
27857
28233
  headers: toByteStringHeaderObject(headers.normalize()),
27858
28234
  body: data,
27859
28235
  duplex: "half",
27860
28236
  credentials: isCredentialsSupported ? withCredentials : void 0
27861
- };
28237
+ });
28238
+ if (isRequestSupported) {
28239
+ utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
28240
+ if (resolvedOptions[key] === void 0) {
28241
+ resolvedOptions[key] = value;
28242
+ }
28243
+ });
28244
+ if (resolvedOptions.signal === void 0) {
28245
+ resolvedOptions.signal = null;
28246
+ }
28247
+ if (resolvedOptions.body === void 0) {
28248
+ resolvedOptions.body = null;
28249
+ }
28250
+ }
28251
+ if (maxRedirects === 0) {
28252
+ resolvedOptions.redirect = "manual";
28253
+ if (safeFetchOptions) {
28254
+ safeFetchOptions.redirect = "manual";
28255
+ }
28256
+ }
27862
28257
  request = isRequestSupported && new Request(url2, resolvedOptions);
27863
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
28258
+ let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
27864
28259
  const responseHeaders = AxiosHeaders_default.from(response.headers);
27865
28260
  if (hasMaxContentLength) {
27866
28261
  const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
@@ -28079,9 +28474,10 @@ function throwIfCancellationRequested(config) {
28079
28474
  throw new CanceledError_default(null, config);
28080
28475
  }
28081
28476
  }
28082
- function dispatchRequest(config) {
28477
+ function dispatchRequest(_config) {
28478
+ const config = utils_default.toSafeFlatObject(_config);
28083
28479
  throwIfCancellationRequested(config);
28084
- config.headers = AxiosHeaders_default.from(config.headers);
28480
+ config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
28085
28481
  config.data = transformData.call(config, config.transformRequest);
28086
28482
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
28087
28483
  config.headers.setContentType("application/x-www-form-urlencoded", false);
@@ -28211,16 +28607,15 @@ var Axios = class {
28211
28607
  return await this._request(configOrUrl, config);
28212
28608
  } catch (err) {
28213
28609
  if (err instanceof Error) {
28214
- let dummy = {};
28215
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
28216
- const stack = (() => {
28217
- if (!dummy.stack) {
28218
- return "";
28219
- }
28220
- const firstNewlineIndex = dummy.stack.indexOf("\n");
28221
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
28222
- })();
28223
28610
  try {
28611
+ let dummy = {};
28612
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
28613
+ const dummyStack = dummy.stack;
28614
+ let stack = "";
28615
+ if (typeof dummyStack === "string") {
28616
+ const firstNewlineIndex = dummyStack.indexOf("\n");
28617
+ stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
28618
+ }
28224
28619
  if (!err.stack) {
28225
28620
  err.stack = stack;
28226
28621
  } else if (stack) {
@@ -28290,9 +28685,9 @@ var Axios = class {
28290
28685
  },
28291
28686
  true
28292
28687
  );
28293
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
28688
+ config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
28294
28689
  let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
28295
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
28690
+ headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
28296
28691
  delete headers[method];
28297
28692
  });
28298
28693
  config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
@@ -28555,14 +28950,22 @@ var HttpStatusCode = {
28555
28950
  Gone: 410,
28556
28951
  LengthRequired: 411,
28557
28952
  PreconditionFailed: 412,
28953
+ /**
28954
+ * @deprecated Use `ContentTooLarge` instead.
28955
+ */
28558
28956
  PayloadTooLarge: 413,
28957
+ ContentTooLarge: 413,
28559
28958
  UriTooLong: 414,
28560
28959
  UnsupportedMediaType: 415,
28561
28960
  RangeNotSatisfiable: 416,
28562
28961
  ExpectationFailed: 417,
28563
28962
  ImATeapot: 418,
28564
28963
  MisdirectedRequest: 421,
28964
+ /**
28965
+ * @deprecated Use `UnprocessableContent` instead.
28966
+ */
28565
28967
  UnprocessableEntity: 422,
28968
+ UnprocessableContent: 422,
28566
28969
  Locked: 423,
28567
28970
  FailedDependency: 424,
28568
28971
  TooEarly: 425,
@@ -28591,7 +28994,9 @@ var HttpStatusCode = {
28591
28994
  InvalidSslCertificate: 526
28592
28995
  };
28593
28996
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
28594
- HttpStatusCode[value] = key;
28997
+ if (HttpStatusCode[value] === void 0) {
28998
+ HttpStatusCode[value] = key;
28999
+ }
28595
29000
  });
28596
29001
  var HttpStatusCode_default = HttpStatusCode;
28597
29002
 
@@ -28902,7 +29307,7 @@ function unavailableFor(pluginId, reason) {
28902
29307
  }
28903
29308
 
28904
29309
  // src/version.ts
28905
- var CLI_VERSION = true ? "1.1.0" : "0.0.0-dev";
29310
+ var CLI_VERSION = true ? "1.1.2" : "0.0.0-dev";
28906
29311
 
28907
29312
  // src/core/http.ts
28908
29313
  var MAX_ATTEMPTS = 3;
@@ -29277,6 +29682,113 @@ async function createContext(command) {
29277
29682
  };
29278
29683
  }
29279
29684
 
29685
+ // src/core/browser-login.ts
29686
+ import { spawn } from "child_process";
29687
+ import http3 from "http";
29688
+ function pickBrowserLogin(methods, wanted) {
29689
+ const targets = methods.filter((method) => method.kind === "redirect").flatMap(
29690
+ (method) => method.instances.map((instance) => ({
29691
+ methodId: method.id,
29692
+ instanceId: instance.id,
29693
+ label: instance.label
29694
+ }))
29695
+ );
29696
+ if (targets.length === 0) {
29697
+ throw new UsageError(
29698
+ "This Termix server has no single sign-on provider. Log in with a username and password, or an API key."
29699
+ );
29700
+ }
29701
+ const names = targets.map((target) => `"${target.label}"`).join(", ");
29702
+ if (!wanted) {
29703
+ const [only] = targets;
29704
+ if (targets.length === 1 && only) return only;
29705
+ throw new UsageError(
29706
+ `This server has more than one single sign-on provider. Pick one with --sso <name>: ${names}.`
29707
+ );
29708
+ }
29709
+ const needle = wanted.toLowerCase();
29710
+ const match = targets.find(
29711
+ (target) => target.label.toLowerCase() === needle || target.instanceId.toLowerCase() === needle
29712
+ );
29713
+ if (!match) {
29714
+ throw new UsageError(
29715
+ `No single sign-on provider named "${wanted}". Choose one of: ${names}.`
29716
+ );
29717
+ }
29718
+ return match;
29719
+ }
29720
+ var PAGE = (message) => `<!doctype html><html><body style="font-family:sans-serif;padding:2rem"><h2>${message}</h2><p>You can close this tab and go back to your terminal.</p></body></html>`;
29721
+ async function listenForBrowserLogin(timeoutMs = 5 * 60 * 1e3) {
29722
+ let settle2 = () => {
29723
+ };
29724
+ const outcome = new Promise((resolve) => {
29725
+ settle2 = resolve;
29726
+ });
29727
+ const server = http3.createServer((req, res) => {
29728
+ const url2 = new URL(req.url ?? "/", "http://localhost");
29729
+ if (url2.pathname !== "/oidc-callback") {
29730
+ res.writeHead(404, { "Content-Type": "text/plain" });
29731
+ res.end("Not found");
29732
+ return;
29733
+ }
29734
+ const token = url2.searchParams.get("token");
29735
+ const tempToken = url2.searchParams.get("temp_token");
29736
+ if (url2.searchParams.get("second_factor") === "1" && tempToken) {
29737
+ res.writeHead(200, { "Content-Type": "text/html" });
29738
+ res.end(PAGE("Almost done. Finish the second step in your terminal."));
29739
+ settle2({
29740
+ kind: "second-factor",
29741
+ tempToken,
29742
+ factors: (url2.searchParams.get("second_factors") ?? "").split(",").filter(Boolean)
29743
+ });
29744
+ return;
29745
+ }
29746
+ if (url2.searchParams.get("success") === "true" && token) {
29747
+ res.writeHead(200, { "Content-Type": "text/html" });
29748
+ res.end(PAGE("Signed in to the Termix CLI."));
29749
+ settle2({ kind: "token", token });
29750
+ return;
29751
+ }
29752
+ res.writeHead(200, { "Content-Type": "text/html" });
29753
+ res.end(PAGE("Sign in failed."));
29754
+ settle2(new Error(url2.searchParams.get("error") || "Sign in failed."));
29755
+ });
29756
+ await new Promise((resolve, reject) => {
29757
+ server.once("error", reject);
29758
+ server.listen(0, "localhost", () => resolve());
29759
+ });
29760
+ const { port } = server.address();
29761
+ const timer = setTimeout(
29762
+ () => settle2(new Error("Timed out waiting for the browser sign in.")),
29763
+ timeoutMs
29764
+ );
29765
+ const close = () => {
29766
+ clearTimeout(timer);
29767
+ server.close();
29768
+ };
29769
+ const result = outcome.then((value) => {
29770
+ close();
29771
+ if (value instanceof Error) throw value;
29772
+ return value;
29773
+ });
29774
+ result.catch(() => {
29775
+ });
29776
+ return { port, result, close };
29777
+ }
29778
+ function openInBrowser(url2) {
29779
+ const [command, args] = process.platform === "win32" ? (
29780
+ // cmd's start would split the URL at "&".
29781
+ ["rundll32", ["url.dll,FileProtocolHandler", url2]]
29782
+ ) : process.platform === "darwin" ? ["open", [url2]] : ["xdg-open", [url2]];
29783
+ try {
29784
+ const child = spawn(command, args, { stdio: "ignore", detached: true });
29785
+ child.on("error", () => {
29786
+ });
29787
+ child.unref();
29788
+ } catch {
29789
+ }
29790
+ }
29791
+
29280
29792
  // src/core/prompt.ts
29281
29793
  import readline from "readline/promises";
29282
29794
  import { Writable } from "stream";
@@ -29336,87 +29848,157 @@ function requireTty(question) {
29336
29848
  }
29337
29849
 
29338
29850
  // src/commands/login.ts
29339
- function bareClient(url2, insecure) {
29851
+ function bareClient(url2, insecure, token) {
29340
29852
  const config = {
29341
29853
  url: url2.replace(/\/+$/, ""),
29342
29854
  insecureTls: insecure || process.env.TERMIX_INSECURE_TLS === "true",
29343
- requestTimeoutMs: 6e4
29855
+ requestTimeoutMs: 6e4,
29856
+ ...token ? { token } : {}
29344
29857
  };
29345
29858
  return new TermixClient(config);
29346
29859
  }
29860
+ var NATIVE_HEADERS = { "X-Electron-App": "true" };
29861
+ async function completeTotp(client, tempToken, factorIds, totp) {
29862
+ const hasTotp = factorIds.length === 0 || factorIds.includes("totp");
29863
+ if (!hasTotp) {
29864
+ throw new UsageError(
29865
+ "This account signs in with a second factor the CLI cannot complete, such as a passkey. Create an API key in Termix and pass it with --api-key or TERMIX_API_KEY."
29866
+ );
29867
+ }
29868
+ const totpCode = totp || await promptHidden("Two-factor code: ");
29869
+ if (!totpCode) {
29870
+ throw new UsageError("A two-factor code is required.");
29871
+ }
29872
+ return client.request({
29873
+ method: "POST",
29874
+ path: "/users/totp/verify-login",
29875
+ data: {
29876
+ temp_token: tempToken,
29877
+ totp_code: totpCode,
29878
+ ...factorIds.length ? { factor: "totp" } : {},
29879
+ rememberMe: true
29880
+ },
29881
+ headers: NATIVE_HEADERS,
29882
+ noAuth: true
29883
+ });
29884
+ }
29885
+ async function browserLogin(client, wanted, totp) {
29886
+ const methods = await client.request({
29887
+ method: "GET",
29888
+ path: "/users/auth/methods",
29889
+ noAuth: true
29890
+ });
29891
+ const target = pickBrowserLogin(
29892
+ Array.isArray(methods) ? methods : [],
29893
+ wanted
29894
+ );
29895
+ const listener = await listenForBrowserLogin();
29896
+ try {
29897
+ const start = await client.request({
29898
+ method: "GET",
29899
+ path: `/users/auth/${encodeURIComponent(target.methodId)}/start`,
29900
+ params: {
29901
+ instance: target.instanceId,
29902
+ rememberMe: true,
29903
+ desktopCallbackPort: listener.port
29904
+ },
29905
+ noAuth: true
29906
+ });
29907
+ if (!start.redirectUrl) {
29908
+ throw new Error("The server did not return a sign in address.");
29909
+ }
29910
+ process.stderr.write(
29911
+ `Opening your browser to sign in with ${target.label}. If it does not open, visit:
29912
+ ${start.redirectUrl}
29913
+ `
29914
+ );
29915
+ openInBrowser(start.redirectUrl);
29916
+ const result = await listener.result;
29917
+ if (result.kind === "token") return result.token;
29918
+ const verified = await completeTotp(
29919
+ client,
29920
+ result.tempToken,
29921
+ result.factors,
29922
+ totp
29923
+ );
29924
+ if (!verified.token) throw new Error("Two-factor sign in failed.");
29925
+ return verified.token;
29926
+ } finally {
29927
+ listener.close();
29928
+ }
29929
+ }
29930
+ async function storeSession(url2, token, username, isAdmin) {
29931
+ const { file, usedKeychain } = await saveSession({ url: url2, token, username });
29932
+ const expMs = decodeJwtExpMs(token);
29933
+ printResult(`Logged in to ${url2} as ${username}.`, {
29934
+ username,
29935
+ url: url2,
29936
+ isAdmin: isAdmin ?? false,
29937
+ tokenExpiresAt: expMs ? new Date(expMs).toISOString() : null,
29938
+ configFile: file,
29939
+ storage: usedKeychain ? "keychain" : "file"
29940
+ });
29941
+ }
29347
29942
  function registerAuthCommands(program3) {
29348
29943
  program3.command("login").description(
29349
29944
  "Log in and store the session token. The password is never written to disk."
29350
29945
  ).option("--url <url>", "Termix base URL (e.g. https://termix.example.com)").option("--username <username>", "Termix username").option(
29351
29946
  "--password-stdin",
29352
29947
  "Read the password from stdin instead of prompting"
29353
- ).option("--totp <code>", "Two-factor code, for non-interactive login").action(async function(opts) {
29948
+ ).option("--totp <code>", "Two-factor code, for non-interactive login").option(
29949
+ "--sso [name]",
29950
+ "Sign in with single sign-on in your browser. Name the provider when the server has more than one"
29951
+ ).action(async function(opts) {
29354
29952
  await run(async () => {
29355
29953
  const flags = globalFlags(this);
29356
29954
  const stored = loadStoredConfig();
29357
29955
  const url2 = opts.url || flags.url || process.env.TERMIX_URL || stored?.url || await prompt("Termix URL: ");
29358
29956
  if (!url2) throw new UsageError("A Termix URL is required.");
29957
+ const normalisedUrl = url2.replace(/\/+$/, "");
29958
+ const insecure = flags.insecure === true;
29959
+ const client = bareClient(url2, insecure);
29960
+ if (opts.sso !== void 0 && opts.sso !== false) {
29961
+ const token = await browserLogin(
29962
+ client,
29963
+ typeof opts.sso === "string" ? opts.sso : void 0,
29964
+ opts.totp
29965
+ );
29966
+ const me = await bareClient(url2, insecure, token).request({ method: "GET", path: "/users/me" });
29967
+ await storeSession(
29968
+ normalisedUrl,
29969
+ token,
29970
+ String(me.username ?? ""),
29971
+ me.is_admin
29972
+ );
29973
+ return;
29974
+ }
29359
29975
  const username = opts.username || await prompt(
29360
29976
  stored?.username ? `Username [${stored.username}]: ` : "Username: "
29361
29977
  ) || stored?.username;
29362
29978
  if (!username) throw new UsageError("A username is required.");
29363
29979
  const password = opts.passwordStdin ? await readSecretFromStdin() : await promptHidden("Password: ");
29364
29980
  if (!password) throw new UsageError("A password is required.");
29365
- const client = bareClient(url2, flags.insecure === true);
29366
29981
  let res = await client.request({
29367
29982
  method: "POST",
29368
29983
  path: "/users/login",
29369
29984
  data: { username, password, rememberMe: true },
29370
- // Termix only returns the token in the body for native apps;
29371
- // otherwise it is set as an httpOnly cookie the CLI cannot read.
29372
- headers: { "X-Electron-App": "true" },
29985
+ headers: NATIVE_HEADERS,
29373
29986
  noAuth: true
29374
29987
  });
29375
29988
  if (res.requires_totp && res.temp_token) {
29376
- const factors = res.second_factors ?? [];
29377
- const hasTotp = factors.length === 0 || factors.some((f) => f.id === "totp");
29378
- if (!hasTotp) {
29379
- throw new UsageError(
29380
- "This account signs in with a second factor the CLI cannot complete, such as a passkey. Create an API key in Termix and pass it with --api-key or TERMIX_API_KEY."
29381
- );
29382
- }
29383
- const totpCode = opts.totp || await promptHidden("Two-factor code: ");
29384
- if (!totpCode) {
29385
- throw new UsageError("A two-factor code is required.");
29386
- }
29387
- res = await client.request({
29388
- method: "POST",
29389
- path: "/users/totp/verify-login",
29390
- data: {
29391
- temp_token: res.temp_token,
29392
- totp_code: totpCode,
29393
- ...factors.length ? { factor: "totp" } : {},
29394
- rememberMe: true
29395
- },
29396
- headers: { "X-Electron-App": "true" },
29397
- noAuth: true
29398
- });
29989
+ res = await completeTotp(
29990
+ client,
29991
+ res.temp_token,
29992
+ (res.second_factors ?? []).map((factor) => factor.id).filter((id) => !!id),
29993
+ opts.totp
29994
+ );
29399
29995
  }
29400
29996
  if (!res.token) {
29401
29997
  throw new Error(
29402
29998
  "Login succeeded but no token was returned. This Termix version may be too old for the CLI."
29403
29999
  );
29404
30000
  }
29405
- const normalisedUrl = url2.replace(/\/+$/, "");
29406
- const { file, usedKeychain } = await saveSession({
29407
- url: normalisedUrl,
29408
- token: res.token,
29409
- username
29410
- });
29411
- const expMs = decodeJwtExpMs(res.token);
29412
- printResult(`Logged in to ${normalisedUrl} as ${username}.`, {
29413
- username,
29414
- url: normalisedUrl,
29415
- isAdmin: res.is_admin ?? false,
29416
- tokenExpiresAt: expMs ? new Date(expMs).toISOString() : null,
29417
- configFile: file,
29418
- storage: usedKeychain ? "keychain" : "file"
29419
- });
30001
+ await storeSession(normalisedUrl, res.token, username, res.is_admin);
29420
30002
  });
29421
30003
  });
29422
30004
  program3.command("logout").description("Delete the stored session.").action(
@@ -29458,8 +30040,12 @@ import fs3 from "fs";
29458
30040
 
29459
30041
  // src/commands/host-fields.ts
29460
30042
  import fs2 from "fs";
30043
+ var AUTH_TYPES = ["password", "key", "credential", "agent", "none"];
29461
30044
  function addHostFieldOptions(cmd) {
29462
- return cmd.option("--name <name>", "Display name (defaults to user@ip)").option("--ip <ip>", "Hostname or IP address").option("--port <port>", "SSH port (default 22)").option("--username <username>", "SSH username").option("--auth-type <type>", "Authentication type: password | key").option("--key-file <path>", "Path to a private key file (authType=key)").option(
30045
+ return cmd.option("--name <name>", "Display name (defaults to user@ip)").option("--ip <ip>", "Hostname or IP address").option("--port <port>", "SSH port (default 22)").option("--username <username>", "SSH username").option(
30046
+ "--auth-type <type>",
30047
+ `Authentication type: ${AUTH_TYPES.join(" | ")}. --credential-id implies credential`
30048
+ ).option("--key-file <path>", "Path to a private key file (authType=key)").option(
29463
30049
  "--password <password>",
29464
30050
  "Password. Prefer TERMIX_HOST_PASSWORD: argv is visible to other processes"
29465
30051
  ).option(
@@ -29467,7 +30053,10 @@ function addHostFieldOptions(cmd) {
29467
30053
  "Key passphrase. Prefer TERMIX_HOST_KEY_PASSWORD"
29468
30054
  ).option(
29469
30055
  "--credential-id <id>",
29470
- "Use a saved shared credential instead of inline secrets"
30056
+ "Use a saved shared credential instead of inline secrets (authType=credential)"
30057
+ ).option(
30058
+ "--no-credential",
30059
+ "Unbind the saved credential. Pass --auth-type too, unless --password or --key-file implies it"
29471
30060
  ).option("--folder <folder>", "Folder to place the host in").option("--tags <tags>", "Comma-separated tags").option("--enable-terminal", "Enable the terminal for this host").option("--enable-file-manager", "Enable the file manager for this host").option("--enable-docker", "Enable Docker for this host").option("--enable-tunnel", "Enable tunneling for this host");
29472
30061
  }
29473
30062
  function resolveSecret(flagValue, envName, flagName) {
@@ -29487,8 +30076,6 @@ function buildHostPayload(opts) {
29487
30076
  if (opts.ip !== void 0) body.ip = opts.ip;
29488
30077
  if (opts.port !== void 0) body.port = parsePort(opts.port);
29489
30078
  if (opts.username !== void 0) body.username = opts.username;
29490
- if (opts.authType !== void 0)
29491
- body.authType = validateAuthType(opts.authType);
29492
30079
  const password = resolveSecret(
29493
30080
  opts.password,
29494
30081
  "TERMIX_HOST_PASSWORD",
@@ -29503,12 +30090,38 @@ function buildHostPayload(opts) {
29503
30090
  if (keyPassword !== void 0) body.keyPassword = keyPassword;
29504
30091
  if (opts.keyFile !== void 0) body.key = readKeyFile(opts.keyFile);
29505
30092
  if (opts.credentialId !== void 0) {
30093
+ if (opts.credential === false) {
30094
+ throw new UsageError(
30095
+ "Pass either --credential-id or --no-credential, not both."
30096
+ );
30097
+ }
29506
30098
  const id = Number(opts.credentialId);
29507
30099
  if (!Number.isInteger(id) || id <= 0) {
29508
- throw new UsageError(`Invalid --credential-id: "${opts.credentialId}".`);
30100
+ throw new UsageError(
30101
+ `Invalid --credential-id: "${opts.credentialId}" (use --no-credential to unbind one).`
30102
+ );
29509
30103
  }
29510
30104
  body.credentialId = id;
29511
30105
  }
30106
+ if (opts.credential === false) body.credentialId = null;
30107
+ if (opts.authType !== void 0) {
30108
+ body.authType = validateAuthType(opts.authType);
30109
+ if (body.authType !== "credential") {
30110
+ if (body.credentialId) {
30111
+ throw new UsageError(
30112
+ "--credential-id needs --auth-type credential (or leave --auth-type out)."
30113
+ );
30114
+ }
30115
+ body.credentialId = null;
30116
+ }
30117
+ if (body.authType === "password" && body.key !== void 0) {
30118
+ throw new UsageError(
30119
+ "--key-file would be dropped with --auth-type password. Use --auth-type key, which keeps the password too."
30120
+ );
30121
+ }
30122
+ } else if (body.credentialId) {
30123
+ body.authType = "credential";
30124
+ }
29512
30125
  if (opts.folder !== void 0) body.folder = opts.folder;
29513
30126
  if (opts.tags !== void 0) body.tags = splitTags(opts.tags);
29514
30127
  if (opts.enableTerminal !== void 0)
@@ -29559,10 +30172,22 @@ function parsePort(value) {
29559
30172
  }
29560
30173
  return port;
29561
30174
  }
30175
+ function inferAuthType(body) {
30176
+ if (body.key !== void 0) return "key";
30177
+ if (body.password !== void 0) return "password";
30178
+ return void 0;
30179
+ }
30180
+ function assertCredentialBound(body) {
30181
+ if (body.authType === "credential" && !body.credentialId) {
30182
+ throw new UsageError(
30183
+ "--auth-type credential needs a saved credential: pass --credential-id <id>."
30184
+ );
30185
+ }
30186
+ }
29562
30187
  function validateAuthType(value) {
29563
- if (value !== "password" && value !== "key") {
30188
+ if (!AUTH_TYPES.includes(value)) {
29564
30189
  throw new UsageError(
29565
- `Invalid --auth-type: "${value}" (expected password or key).`
30190
+ `Invalid --auth-type: "${value}" (expected ${AUTH_TYPES.join(", ")}).`
29566
30191
  );
29567
30192
  }
29568
30193
  return value;
@@ -29651,7 +30276,7 @@ function registerHostCommands(program3) {
29651
30276
  });
29652
30277
  addHostFieldOptions(
29653
30278
  hosts.command("create").description(
29654
- "Create an SSH host. --ip and --username are required, plus one of --password, --key-file or --credential-id."
30279
+ "Create an SSH host. --ip and --username are required, plus --auth-type or one of --password, --key-file or --credential-id to infer it from."
29655
30280
  )
29656
30281
  ).action(async function(opts) {
29657
30282
  await run(async () => {
@@ -29660,15 +30285,13 @@ function registerHostCommands(program3) {
29660
30285
  }
29661
30286
  if (opts.port === void 0) opts.port = "22";
29662
30287
  const payload = buildHostPayload(opts);
29663
- if (payload.password === void 0 && payload.key === void 0 && payload.credentialId === void 0) {
30288
+ payload.authType ??= inferAuthType(payload);
30289
+ if (payload.authType === void 0) {
29664
30290
  throw new UsageError(
29665
- "`hosts create` needs an auth method: pass --password, --key-file or --credential-id (or set TERMIX_HOST_PASSWORD)."
30291
+ "`hosts create` needs an auth method: pass --auth-type, --password, --key-file or --credential-id (or set TERMIX_HOST_PASSWORD)."
29666
30292
  );
29667
30293
  }
29668
- if (payload.authType === void 0) {
29669
- if (payload.password !== void 0) payload.authType = "password";
29670
- else if (payload.key !== void 0) payload.authType = "key";
29671
- }
30294
+ assertCredentialBound(payload);
29672
30295
  const { client } = await createContext(this);
29673
30296
  const created = await client.request({
29674
30297
  method: "POST",
@@ -29699,6 +30322,15 @@ function registerHostCommands(program3) {
29699
30322
  path: `/host/db/host/${id}`
29700
30323
  });
29701
30324
  const merged = { ...stripServerManaged(current), ...payload };
30325
+ if (opts.credential === false && payload.authType === void 0 && current.authType === "credential") {
30326
+ merged.authType = inferAuthType(payload);
30327
+ if (merged.authType === void 0) {
30328
+ throw new UsageError(
30329
+ `Host ${id} signs in with a credential. Pass --auth-type with --no-credential (or --password / --key-file).`
30330
+ );
30331
+ }
30332
+ }
30333
+ assertCredentialBound(merged);
29702
30334
  await client.request({
29703
30335
  method: "PUT",
29704
30336
  path: `/host/db/host/${id}`,
@@ -30236,6 +30868,7 @@ var AUTH_STEPS = [
30236
30868
  "totp_required",
30237
30869
  "totp_retry",
30238
30870
  "password_required",
30871
+ "auth_method_not_available",
30239
30872
  "*_auth_required"
30240
30873
  ];
30241
30874
  var MAX_AUTH_ROUNDS = 10;
@@ -30280,6 +30913,11 @@ async function completeAuth(socket, connect, trustHostKey) {
30280
30913
  );
30281
30914
  break;
30282
30915
  }
30916
+ case "auth_method_not_available": {
30917
+ const password = await promptHidden("Password: ");
30918
+ socket.send("reconnect_with_credentials", { ...connect, password });
30919
+ break;
30920
+ }
30283
30921
  case "passphrase_required": {
30284
30922
  const keyPassword = await promptHidden("Key passphrase: ");
30285
30923
  socket.send("reconnect_with_credentials", { ...connect, keyPassword });