@kadoa/mcp 0.5.3-rc.1 → 0.5.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +1262 -240
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -28938,8 +28938,17 @@ var toString, getPrototypeOf, iterator, toStringTag, kindOf, kindOfTest = (type)
28938
28938
  }, isDate, isFile, isReactNativeBlob = (value) => {
28939
28939
  return !!(value && typeof value.uri !== "undefined");
28940
28940
  }, isReactNative = (formData) => formData && typeof formData.getParts !== "undefined", isBlob, isFileList, isStream = (val) => isObject2(val) && isFunction(val.pipe), G, FormDataCtor, isFormData = (thing) => {
28941
- let kind;
28942
- return thing && (FormDataCtor && thing instanceof FormDataCtor || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
28941
+ if (!thing)
28942
+ return false;
28943
+ if (FormDataCtor && thing instanceof FormDataCtor)
28944
+ return true;
28945
+ const proto = getPrototypeOf(thing);
28946
+ if (!proto || proto === Object.prototype)
28947
+ return false;
28948
+ if (!isFunction(thing.append))
28949
+ return false;
28950
+ const kind = kindOf(thing);
28951
+ return kind === "formdata" || kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]";
28943
28952
  }, isURLSearchParams, isReadableStream, isRequest, isResponse, isHeaders, trim = (str) => {
28944
28953
  return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
28945
28954
  }, _global, isContextDefined = (context) => !isUndefined(context) && context !== _global, extend2 = (a, b, thisArg, { allOwnKeys } = {}) => {
@@ -29286,6 +29295,7 @@ var init_AxiosError = __esm(() => {
29286
29295
  AxiosError.ERR_CANCELED = "ERR_CANCELED";
29287
29296
  AxiosError.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
29288
29297
  AxiosError.ERR_INVALID_URL = "ERR_INVALID_URL";
29298
+ AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = "ERR_FORM_DATA_DEPTH_EXCEEDED";
29289
29299
  AxiosError_default = AxiosError;
29290
29300
  });
29291
29301
 
@@ -39437,6 +39447,7 @@ function toFormData(obj, formData, options) {
39437
39447
  const dots = options.dots;
39438
39448
  const indexes = options.indexes;
39439
39449
  const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
39450
+ const maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
39440
39451
  const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
39441
39452
  if (!utils_default.isFunction(visitor)) {
39442
39453
  throw new TypeError("visitor must be a function");
@@ -39488,9 +39499,12 @@ function toFormData(obj, formData, options) {
39488
39499
  convertValue,
39489
39500
  isVisitable
39490
39501
  });
39491
- function build(value, path) {
39502
+ function build(value, path, depth = 0) {
39492
39503
  if (utils_default.isUndefined(value))
39493
39504
  return;
39505
+ if (depth > maxDepth) {
39506
+ throw new AxiosError_default("Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth, AxiosError_default.ERR_FORM_DATA_DEPTH_EXCEEDED);
39507
+ }
39494
39508
  if (stack.indexOf(value) !== -1) {
39495
39509
  throw Error("Circular reference detected in " + path.join("."));
39496
39510
  }
@@ -39498,7 +39512,7 @@ function toFormData(obj, formData, options) {
39498
39512
  utils_default.forEach(value, function each(el, key) {
39499
39513
  const result = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key, path, exposedHelpers);
39500
39514
  if (result === true) {
39501
- build(el, path ? path.concat(key) : [key]);
39515
+ build(el, path ? path.concat(key) : [key], depth + 1);
39502
39516
  }
39503
39517
  });
39504
39518
  stack.pop();
@@ -39528,10 +39542,9 @@ function encode3(str) {
39528
39542
  "(": "%28",
39529
39543
  ")": "%29",
39530
39544
  "~": "%7E",
39531
- "%20": "+",
39532
- "%00": "\x00"
39545
+ "%20": "+"
39533
39546
  };
39534
- return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
39547
+ return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
39535
39548
  return charMap[match];
39536
39549
  });
39537
39550
  }
@@ -39757,7 +39770,7 @@ function formDataToJSON(formData) {
39757
39770
  name = !name && utils_default.isArray(target) ? target.length : name;
39758
39771
  if (isLast) {
39759
39772
  if (utils_default.hasOwnProp(target, name)) {
39760
- target[name] = [target[name], value];
39773
+ target[name] = utils_default.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
39761
39774
  } else {
39762
39775
  target[name] = value;
39763
39776
  }
@@ -39801,7 +39814,7 @@ function stringifySafely(rawValue, parser, encoder) {
39801
39814
  }
39802
39815
  return (encoder || JSON.stringify)(rawValue);
39803
39816
  }
39804
- var defaults, defaults_default;
39817
+ var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : undefined, defaults, defaults_default;
39805
39818
  var init_defaults = __esm(() => {
39806
39819
  init_utils();
39807
39820
  init_AxiosError();
@@ -39837,12 +39850,14 @@ var init_defaults = __esm(() => {
39837
39850
  }
39838
39851
  let isFileList2;
39839
39852
  if (isObjectPayload) {
39853
+ const formSerializer = own(this, "formSerializer");
39840
39854
  if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
39841
- return toURLEncodedForm(data, this.formSerializer).toString();
39855
+ return toURLEncodedForm(data, formSerializer).toString();
39842
39856
  }
39843
39857
  if ((isFileList2 = utils_default.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
39844
- const _FormData = this.env && this.env.FormData;
39845
- return toFormData_default(isFileList2 ? { "files[]": data } : data, _FormData && new _FormData, this.formSerializer);
39858
+ const env = own(this, "env");
39859
+ const _FormData = env && env.FormData;
39860
+ return toFormData_default(isFileList2 ? { "files[]": data } : data, _FormData && new _FormData, formSerializer);
39846
39861
  }
39847
39862
  }
39848
39863
  if (isObjectPayload || hasJSONContentType) {
@@ -39854,21 +39869,22 @@ var init_defaults = __esm(() => {
39854
39869
  ],
39855
39870
  transformResponse: [
39856
39871
  function transformResponse(data) {
39857
- const transitional = this.transitional || defaults.transitional;
39872
+ const transitional = own(this, "transitional") || defaults.transitional;
39858
39873
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
39859
- const JSONRequested = this.responseType === "json";
39874
+ const responseType = own(this, "responseType");
39875
+ const JSONRequested = responseType === "json";
39860
39876
  if (utils_default.isResponse(data) || utils_default.isReadableStream(data)) {
39861
39877
  return data;
39862
39878
  }
39863
- if (data && utils_default.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
39879
+ if (data && utils_default.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
39864
39880
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
39865
39881
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
39866
39882
  try {
39867
- return JSON.parse(data, this.parseReviver);
39883
+ return JSON.parse(data, own(this, "parseReviver"));
39868
39884
  } catch (e) {
39869
39885
  if (strictJSONParsing) {
39870
39886
  if (e.name === "SyntaxError") {
39871
- throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, this.response);
39887
+ throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, own(this, "response"));
39872
39888
  }
39873
39889
  throw e;
39874
39890
  }
@@ -39952,14 +39968,36 @@ var init_parseHeaders = __esm(() => {
39952
39968
  });
39953
39969
 
39954
39970
  // node_modules/axios/lib/core/AxiosHeaders.js
39971
+ function trimSPorHTAB(str) {
39972
+ let start = 0;
39973
+ let end = str.length;
39974
+ while (start < end) {
39975
+ const code = str.charCodeAt(start);
39976
+ if (code !== 9 && code !== 32) {
39977
+ break;
39978
+ }
39979
+ start += 1;
39980
+ }
39981
+ while (end > start) {
39982
+ const code = str.charCodeAt(end - 1);
39983
+ if (code !== 9 && code !== 32) {
39984
+ break;
39985
+ }
39986
+ end -= 1;
39987
+ }
39988
+ return start === 0 && end === str.length ? str : str.slice(start, end);
39989
+ }
39955
39990
  function normalizeHeader(header) {
39956
39991
  return header && String(header).trim().toLowerCase();
39957
39992
  }
39993
+ function sanitizeHeaderValue(str) {
39994
+ return trimSPorHTAB(str.replace(INVALID_HEADER_VALUE_CHARS_RE, ""));
39995
+ }
39958
39996
  function normalizeValue(value) {
39959
39997
  if (value === false || value == null) {
39960
39998
  return value;
39961
39999
  }
39962
- return utils_default.isArray(value) ? value.map(normalizeValue) : String(value);
40000
+ return utils_default.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
39963
40001
  }
39964
40002
  function parseTokens(str) {
39965
40003
  const tokens = Object.create(null);
@@ -40002,11 +40040,12 @@ function buildAccessors(obj, header) {
40002
40040
  });
40003
40041
  });
40004
40042
  }
40005
- var $internals, isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim()), AxiosHeaders, AxiosHeaders_default;
40043
+ var $internals, INVALID_HEADER_VALUE_CHARS_RE, isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim()), AxiosHeaders, AxiosHeaders_default;
40006
40044
  var init_AxiosHeaders = __esm(() => {
40007
40045
  init_utils();
40008
40046
  init_parseHeaders();
40009
40047
  $internals = Symbol("internals");
40048
+ INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
40010
40049
  AxiosHeaders = class AxiosHeaders {
40011
40050
  constructor(headers) {
40012
40051
  headers && this.set(headers);
@@ -40259,7 +40298,7 @@ function combineURLs(baseURL, relativeURL) {
40259
40298
  // node_modules/axios/lib/core/buildFullPath.js
40260
40299
  function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
40261
40300
  let isRelativeUrl = !isAbsoluteURL(requestedURL);
40262
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
40301
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
40263
40302
  return combineURLs(baseURL, requestedURL);
40264
40303
  }
40265
40304
  return requestedURL;
@@ -40267,9 +40306,66 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
40267
40306
  var init_buildFullPath = () => {};
40268
40307
 
40269
40308
  // node_modules/proxy-from-env/index.js
40270
- var require_proxy_from_env = __commonJS((exports) => {
40271
- var parseUrl = __require("url").parse;
40272
- var DEFAULT_PORTS = {
40309
+ function parseUrl(urlString) {
40310
+ try {
40311
+ return new URL(urlString);
40312
+ } catch {
40313
+ return null;
40314
+ }
40315
+ }
40316
+ function getProxyForUrl(url3) {
40317
+ var parsedUrl = (typeof url3 === "string" ? parseUrl(url3) : url3) || {};
40318
+ var proto = parsedUrl.protocol;
40319
+ var hostname3 = parsedUrl.host;
40320
+ var port = parsedUrl.port;
40321
+ if (typeof hostname3 !== "string" || !hostname3 || typeof proto !== "string") {
40322
+ return "";
40323
+ }
40324
+ proto = proto.split(":", 1)[0];
40325
+ hostname3 = hostname3.replace(/:\d*$/, "");
40326
+ port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
40327
+ if (!shouldProxy(hostname3, port)) {
40328
+ return "";
40329
+ }
40330
+ var proxy = getEnv(proto + "_proxy") || getEnv("all_proxy");
40331
+ if (proxy && proxy.indexOf("://") === -1) {
40332
+ proxy = proto + "://" + proxy;
40333
+ }
40334
+ return proxy;
40335
+ }
40336
+ function shouldProxy(hostname3, port) {
40337
+ var NO_PROXY = getEnv("no_proxy").toLowerCase();
40338
+ if (!NO_PROXY) {
40339
+ return true;
40340
+ }
40341
+ if (NO_PROXY === "*") {
40342
+ return false;
40343
+ }
40344
+ return NO_PROXY.split(/[,\s]/).every(function(proxy) {
40345
+ if (!proxy) {
40346
+ return true;
40347
+ }
40348
+ var parsedProxy = proxy.match(/^(.+):(\d+)$/);
40349
+ var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
40350
+ var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
40351
+ if (parsedProxyPort && parsedProxyPort !== port) {
40352
+ return true;
40353
+ }
40354
+ if (!/^[.*]/.test(parsedProxyHostname)) {
40355
+ return hostname3 !== parsedProxyHostname;
40356
+ }
40357
+ if (parsedProxyHostname.charAt(0) === "*") {
40358
+ parsedProxyHostname = parsedProxyHostname.slice(1);
40359
+ }
40360
+ return !hostname3.endsWith(parsedProxyHostname);
40361
+ });
40362
+ }
40363
+ function getEnv(key) {
40364
+ return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
40365
+ }
40366
+ var DEFAULT_PORTS;
40367
+ var init_proxy_from_env = __esm(() => {
40368
+ DEFAULT_PORTS = {
40273
40369
  ftp: 21,
40274
40370
  gopher: 70,
40275
40371
  http: 80,
@@ -40277,60 +40373,6 @@ var require_proxy_from_env = __commonJS((exports) => {
40277
40373
  ws: 80,
40278
40374
  wss: 443
40279
40375
  };
40280
- var stringEndsWith = String.prototype.endsWith || function(s) {
40281
- return s.length <= this.length && this.indexOf(s, this.length - s.length) !== -1;
40282
- };
40283
- function getProxyForUrl(url3) {
40284
- var parsedUrl = typeof url3 === "string" ? parseUrl(url3) : url3 || {};
40285
- var proto = parsedUrl.protocol;
40286
- var hostname3 = parsedUrl.host;
40287
- var port = parsedUrl.port;
40288
- if (typeof hostname3 !== "string" || !hostname3 || typeof proto !== "string") {
40289
- return "";
40290
- }
40291
- proto = proto.split(":", 1)[0];
40292
- hostname3 = hostname3.replace(/:\d*$/, "");
40293
- port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
40294
- if (!shouldProxy(hostname3, port)) {
40295
- return "";
40296
- }
40297
- var proxy = getEnv("npm_config_" + proto + "_proxy") || getEnv(proto + "_proxy") || getEnv("npm_config_proxy") || getEnv("all_proxy");
40298
- if (proxy && proxy.indexOf("://") === -1) {
40299
- proxy = proto + "://" + proxy;
40300
- }
40301
- return proxy;
40302
- }
40303
- function shouldProxy(hostname3, port) {
40304
- var NO_PROXY = (getEnv("npm_config_no_proxy") || getEnv("no_proxy")).toLowerCase();
40305
- if (!NO_PROXY) {
40306
- return true;
40307
- }
40308
- if (NO_PROXY === "*") {
40309
- return false;
40310
- }
40311
- return NO_PROXY.split(/[,\s]/).every(function(proxy) {
40312
- if (!proxy) {
40313
- return true;
40314
- }
40315
- var parsedProxy = proxy.match(/^(.+):(\d+)$/);
40316
- var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
40317
- var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
40318
- if (parsedProxyPort && parsedProxyPort !== port) {
40319
- return true;
40320
- }
40321
- if (!/^[.*]/.test(parsedProxyHostname)) {
40322
- return hostname3 !== parsedProxyHostname;
40323
- }
40324
- if (parsedProxyHostname.charAt(0) === "*") {
40325
- parsedProxyHostname = parsedProxyHostname.slice(1);
40326
- }
40327
- return !stringEndsWith.call(hostname3, parsedProxyHostname);
40328
- });
40329
- }
40330
- function getEnv(key) {
40331
- return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || "";
40332
- }
40333
- exports.getProxyForUrl = getProxyForUrl;
40334
40376
  });
40335
40377
 
40336
40378
  // node_modules/ms/index.js
@@ -41269,7 +41311,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
41269
41311
  removeMatchingHeaders(/^content-/i, this._options.headers);
41270
41312
  }
41271
41313
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
41272
- var currentUrlParts = parseUrl(this._currentUrl);
41314
+ var currentUrlParts = parseUrl2(this._currentUrl);
41273
41315
  var currentHost = currentHostHeader || currentUrlParts.host;
41274
41316
  var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url3.format(Object.assign(currentUrlParts, { host: currentHost }));
41275
41317
  var redirectUrl = resolveUrl(location, currentUrl);
@@ -41308,7 +41350,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
41308
41350
  if (isURL(input)) {
41309
41351
  input = spreadUrlObject(input);
41310
41352
  } else if (isString2(input)) {
41311
- input = spreadUrlObject(parseUrl(input));
41353
+ input = spreadUrlObject(parseUrl2(input));
41312
41354
  } else {
41313
41355
  callback = options;
41314
41356
  options = validateUrl(input);
@@ -41343,7 +41385,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
41343
41385
  return exports2;
41344
41386
  }
41345
41387
  function noop2() {}
41346
- function parseUrl(input) {
41388
+ function parseUrl2(input) {
41347
41389
  var parsed;
41348
41390
  if (useNativeURL) {
41349
41391
  parsed = new URL2(input);
@@ -41356,7 +41398,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
41356
41398
  return parsed;
41357
41399
  }
41358
41400
  function resolveUrl(relative, base) {
41359
- return useNativeURL ? new URL2(relative, base) : parseUrl(url3.resolve(base, relative));
41401
+ return useNativeURL ? new URL2(relative, base) : parseUrl2(url3.resolve(base, relative));
41360
41402
  }
41361
41403
  function validateUrl(input) {
41362
41404
  if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
@@ -41442,7 +41484,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
41442
41484
  });
41443
41485
 
41444
41486
  // node_modules/axios/lib/env/data.js
41445
- var VERSION = "1.13.6";
41487
+ var VERSION = "1.15.2";
41446
41488
 
41447
41489
  // node_modules/axios/lib/helpers/parseProtocol.js
41448
41490
  function parseProtocol(url3) {
@@ -41632,7 +41674,8 @@ class FormDataPart {
41632
41674
  if (isStringValue) {
41633
41675
  value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
41634
41676
  } else {
41635
- headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
41677
+ const safeType = String(value.type || "application/octet-stream").replace(/[\r\n]/g, "");
41678
+ headers += `Content-Type: ${safeType}${CRLF}`;
41636
41679
  }
41637
41680
  this.headers = textEncoder.encode(headers + CRLF);
41638
41681
  this.contentLength = isStringValue ? value.byteLength : value.size;
@@ -41749,6 +41792,120 @@ var init_callbackify = __esm(() => {
41749
41792
  callbackify_default = callbackify;
41750
41793
  });
41751
41794
 
41795
+ // node_modules/axios/lib/helpers/shouldBypassProxy.js
41796
+ function shouldBypassProxy(location) {
41797
+ let parsed;
41798
+ try {
41799
+ parsed = new URL(location);
41800
+ } catch (_err) {
41801
+ return false;
41802
+ }
41803
+ const noProxy = (process.env.no_proxy || process.env.NO_PROXY || "").toLowerCase();
41804
+ if (!noProxy) {
41805
+ return false;
41806
+ }
41807
+ if (noProxy === "*") {
41808
+ return true;
41809
+ }
41810
+ const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
41811
+ const hostname3 = normalizeNoProxyHost(parsed.hostname.toLowerCase());
41812
+ return noProxy.split(/[\s,]+/).some((entry) => {
41813
+ if (!entry) {
41814
+ return false;
41815
+ }
41816
+ let [entryHost, entryPort] = parseNoProxyEntry(entry);
41817
+ entryHost = normalizeNoProxyHost(entryHost);
41818
+ if (!entryHost) {
41819
+ return false;
41820
+ }
41821
+ if (entryPort && entryPort !== port) {
41822
+ return false;
41823
+ }
41824
+ if (entryHost.charAt(0) === "*") {
41825
+ entryHost = entryHost.slice(1);
41826
+ }
41827
+ if (entryHost.charAt(0) === ".") {
41828
+ return hostname3.endsWith(entryHost);
41829
+ }
41830
+ return hostname3 === entryHost || isLoopback(hostname3) && isLoopback(entryHost);
41831
+ });
41832
+ }
41833
+ var LOOPBACK_HOSTNAMES, isIPv4Loopback = (host) => {
41834
+ const parts = host.split(".");
41835
+ if (parts.length !== 4)
41836
+ return false;
41837
+ if (parts[0] !== "127")
41838
+ return false;
41839
+ return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
41840
+ }, isIPv6Loopback = (host) => {
41841
+ if (host === "::1")
41842
+ return true;
41843
+ const v4MappedDotted = host.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);
41844
+ if (v4MappedDotted)
41845
+ return isIPv4Loopback(v4MappedDotted[1]);
41846
+ const v4MappedHex = host.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);
41847
+ if (v4MappedHex) {
41848
+ const high = parseInt(v4MappedHex[1], 16);
41849
+ return high >= 32512 && high <= 32767;
41850
+ }
41851
+ const groups = host.split(":");
41852
+ if (groups.length === 8) {
41853
+ for (let i = 0;i < 7; i++) {
41854
+ if (!/^0+$/.test(groups[i]))
41855
+ return false;
41856
+ }
41857
+ return /^0*1$/.test(groups[7]);
41858
+ }
41859
+ return false;
41860
+ }, isLoopback = (host) => {
41861
+ if (!host)
41862
+ return false;
41863
+ if (LOOPBACK_HOSTNAMES.has(host))
41864
+ return true;
41865
+ if (isIPv4Loopback(host))
41866
+ return true;
41867
+ return isIPv6Loopback(host);
41868
+ }, DEFAULT_PORTS2, parseNoProxyEntry = (entry) => {
41869
+ let entryHost = entry;
41870
+ let entryPort = 0;
41871
+ if (entryHost.charAt(0) === "[") {
41872
+ const bracketIndex = entryHost.indexOf("]");
41873
+ if (bracketIndex !== -1) {
41874
+ const host = entryHost.slice(1, bracketIndex);
41875
+ const rest = entryHost.slice(bracketIndex + 1);
41876
+ if (rest.charAt(0) === ":" && /^\d+$/.test(rest.slice(1))) {
41877
+ entryPort = Number.parseInt(rest.slice(1), 10);
41878
+ }
41879
+ return [host, entryPort];
41880
+ }
41881
+ }
41882
+ const firstColon = entryHost.indexOf(":");
41883
+ const lastColon = entryHost.lastIndexOf(":");
41884
+ if (firstColon !== -1 && firstColon === lastColon && /^\d+$/.test(entryHost.slice(lastColon + 1))) {
41885
+ entryPort = Number.parseInt(entryHost.slice(lastColon + 1), 10);
41886
+ entryHost = entryHost.slice(0, lastColon);
41887
+ }
41888
+ return [entryHost, entryPort];
41889
+ }, normalizeNoProxyHost = (hostname3) => {
41890
+ if (!hostname3) {
41891
+ return hostname3;
41892
+ }
41893
+ if (hostname3.charAt(0) === "[" && hostname3.charAt(hostname3.length - 1) === "]") {
41894
+ hostname3 = hostname3.slice(1, -1);
41895
+ }
41896
+ return hostname3.replace(/\.+$/, "");
41897
+ };
41898
+ var init_shouldBypassProxy = __esm(() => {
41899
+ LOOPBACK_HOSTNAMES = new Set(["localhost"]);
41900
+ DEFAULT_PORTS2 = {
41901
+ http: 80,
41902
+ https: 443,
41903
+ ws: 80,
41904
+ wss: 443,
41905
+ ftp: 21
41906
+ };
41907
+ });
41908
+
41752
41909
  // node_modules/axios/lib/helpers/speedometer.js
41753
41910
  function speedometer(samplesCount, min) {
41754
41911
  samplesCount = samplesCount || 10;
@@ -41831,19 +41988,19 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
41831
41988
  let bytesNotified = 0;
41832
41989
  const _speedometer = speedometer_default(50, 250);
41833
41990
  return throttle_default((e) => {
41834
- const loaded = e.loaded;
41991
+ const rawLoaded = e.loaded;
41835
41992
  const total = e.lengthComputable ? e.total : undefined;
41836
- const progressBytes = loaded - bytesNotified;
41993
+ const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
41994
+ const progressBytes = Math.max(0, loaded - bytesNotified);
41837
41995
  const rate = _speedometer(progressBytes);
41838
- const inRange = loaded <= total;
41839
- bytesNotified = loaded;
41996
+ bytesNotified = Math.max(bytesNotified, loaded);
41840
41997
  const data = {
41841
41998
  loaded,
41842
41999
  total,
41843
42000
  progress: total ? loaded / total : undefined,
41844
42001
  bytes: progressBytes,
41845
42002
  rate: rate ? rate : undefined,
41846
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
42003
+ estimated: rate && total ? (total - loaded) / rate : undefined,
41847
42004
  event: e,
41848
42005
  lengthComputable: total != null,
41849
42006
  [isDownloadStream ? "download" : "upload"]: true
@@ -41924,6 +42081,7 @@ import http from "http";
41924
42081
  import https from "https";
41925
42082
  import http2 from "http2";
41926
42083
  import util4 from "util";
42084
+ import { resolve as resolvePath } from "path";
41927
42085
  import zlib from "zlib";
41928
42086
  import stream3 from "stream";
41929
42087
  import { EventEmitter } from "events";
@@ -41961,6 +42119,9 @@ class Http2Sessions {
41961
42119
  } else {
41962
42120
  entries.splice(i, 1);
41963
42121
  }
42122
+ if (!session.closed) {
42123
+ session.close();
42124
+ }
41964
42125
  return;
41965
42126
  }
41966
42127
  }
@@ -42005,9 +42166,11 @@ function dispatchBeforeRedirect(options, responseDetails) {
42005
42166
  function setProxy(options, configProxy, location) {
42006
42167
  let proxy = configProxy;
42007
42168
  if (!proxy && proxy !== false) {
42008
- const proxyUrl = import_proxy_from_env.default.getProxyForUrl(location);
42169
+ const proxyUrl = getProxyForUrl(location);
42009
42170
  if (proxyUrl) {
42010
- proxy = new URL(proxyUrl);
42171
+ if (!shouldBypassProxy(location)) {
42172
+ proxy = new URL(proxyUrl);
42173
+ }
42011
42174
  }
42012
42175
  }
42013
42176
  if (proxy) {
@@ -42038,7 +42201,7 @@ function setProxy(options, configProxy, location) {
42038
42201
  setProxy(redirectOptions, configProxy, redirectOptions.href);
42039
42202
  };
42040
42203
  }
42041
- var import_proxy_from_env, import_follow_redirects, zlibOptions, brotliOptions, isBrotliSupported, httpFollow, httpsFollow, isHttps, supportedProtocols, flushOnFinish = (stream4, [throttled, flush]) => {
42204
+ var import_follow_redirects, zlibOptions, brotliOptions, isBrotliSupported, httpFollow, httpsFollow, isHttps, kAxiosSocketListener, kAxiosCurrentReq, supportedProtocols, flushOnFinish = (stream4, [throttled, flush]) => {
42042
42205
  stream4.on("end", flush).on("error", flush);
42043
42206
  return throttled;
42044
42207
  }, http2Sessions, isHttpAdapterSupported, wrapAsync = (asyncExecutor) => {
@@ -42075,6 +42238,7 @@ var init_http = __esm(() => {
42075
42238
  init_settle();
42076
42239
  init_buildFullPath();
42077
42240
  init_buildURL();
42241
+ init_proxy_from_env();
42078
42242
  init_transitional();
42079
42243
  init_AxiosError();
42080
42244
  init_CanceledError();
@@ -42086,8 +42250,8 @@ var init_http = __esm(() => {
42086
42250
  init_readBlob();
42087
42251
  init_ZlibHeaderTransformStream();
42088
42252
  init_callbackify();
42253
+ init_shouldBypassProxy();
42089
42254
  init_progressEventReducer();
42090
- import_proxy_from_env = __toESM(require_proxy_from_env(), 1);
42091
42255
  import_follow_redirects = __toESM(require_follow_redirects(), 1);
42092
42256
  zlibOptions = {
42093
42257
  flush: zlib.constants.Z_SYNC_FLUSH,
@@ -42100,6 +42264,8 @@ var init_http = __esm(() => {
42100
42264
  isBrotliSupported = utils_default.isFunction(zlib.createBrotliDecompress);
42101
42265
  ({ http: httpFollow, https: httpsFollow } = import_follow_redirects.default);
42102
42266
  isHttps = /https:?/;
42267
+ kAxiosSocketListener = Symbol("axios.http.socketListener");
42268
+ kAxiosCurrentReq = Symbol("axios.http.currentReq");
42103
42269
  supportedProtocols = platform_default.protocols.map((protocol) => {
42104
42270
  return protocol + ":";
42105
42271
  });
@@ -42134,8 +42300,16 @@ var init_http = __esm(() => {
42134
42300
  };
42135
42301
  http_default = isHttpAdapterSupported && function httpAdapter(config2) {
42136
42302
  return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
42137
- let { data, lookup, family, httpVersion = 1, http2Options } = config2;
42138
- const { responseType, responseEncoding } = config2;
42303
+ const own2 = (key) => utils_default.hasOwnProp(config2, key) ? config2[key] : undefined;
42304
+ let data = own2("data");
42305
+ let lookup = own2("lookup");
42306
+ let family = own2("family");
42307
+ let httpVersion = own2("httpVersion");
42308
+ if (httpVersion === undefined)
42309
+ httpVersion = 1;
42310
+ let http2Options = own2("http2Options");
42311
+ const responseType = own2("responseType");
42312
+ const responseEncoding = own2("responseEncoding");
42139
42313
  const method = config2.method.toUpperCase();
42140
42314
  let isDone;
42141
42315
  let rejected = false;
@@ -42261,7 +42435,7 @@ var init_http = __esm(() => {
42261
42435
  tag: `axios-${VERSION}-boundary`,
42262
42436
  boundary: userBoundary && userBoundary[1] || undefined
42263
42437
  });
42264
- } else if (utils_default.isFormData(data) && utils_default.isFunction(data.getHeaders)) {
42438
+ } else if (utils_default.isFormData(data) && utils_default.isFunction(data.getHeaders) && data.getHeaders !== Object.prototype.getHeaders) {
42265
42439
  headers.set(data.getHeaders());
42266
42440
  if (!headers.hasContentLength()) {
42267
42441
  try {
@@ -42306,9 +42480,10 @@ var init_http = __esm(() => {
42306
42480
  onUploadProgress && data.on("progress", flushOnFinish(data, progressEventDecorator(contentLength, progressEventReducer(asyncDecorator(onUploadProgress), false, 3))));
42307
42481
  }
42308
42482
  let auth = undefined;
42309
- if (config2.auth) {
42310
- const username = config2.auth.username || "";
42311
- const password = config2.auth.password || "";
42483
+ const configAuth = own2("auth");
42484
+ if (configAuth) {
42485
+ const username = configAuth.username || "";
42486
+ const password = configAuth.password || "";
42312
42487
  auth = username + ":" + password;
42313
42488
  }
42314
42489
  if (!auth && parsed.username) {
@@ -42328,7 +42503,7 @@ var init_http = __esm(() => {
42328
42503
  return reject(customErr);
42329
42504
  }
42330
42505
  headers.set("Accept-Encoding", "gzip, compress, deflate" + (isBrotliSupported ? ", br" : ""), false);
42331
- const options = {
42506
+ const options = Object.assign(Object.create(null), {
42332
42507
  path,
42333
42508
  method,
42334
42509
  headers: headers.toJSON(),
@@ -42337,11 +42512,22 @@ var init_http = __esm(() => {
42337
42512
  protocol,
42338
42513
  family,
42339
42514
  beforeRedirect: dispatchBeforeRedirect,
42340
- beforeRedirects: {},
42515
+ beforeRedirects: Object.create(null),
42341
42516
  http2Options
42342
- };
42517
+ });
42343
42518
  !utils_default.isUndefined(lookup) && (options.lookup = lookup);
42344
42519
  if (config2.socketPath) {
42520
+ if (typeof config2.socketPath !== "string") {
42521
+ return reject(new AxiosError_default("socketPath must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE, config2));
42522
+ }
42523
+ if (config2.allowedSocketPaths != null) {
42524
+ const allowed = Array.isArray(config2.allowedSocketPaths) ? config2.allowedSocketPaths : [config2.allowedSocketPaths];
42525
+ const resolvedSocket = resolvePath(config2.socketPath);
42526
+ const isAllowed = allowed.some((entry) => typeof entry === "string" && resolvePath(entry) === resolvedSocket);
42527
+ if (!isAllowed) {
42528
+ return reject(new AxiosError_default(`socketPath "${config2.socketPath}" is not permitted by allowedSocketPaths`, AxiosError_default.ERR_BAD_OPTION_VALUE, config2));
42529
+ }
42530
+ }
42345
42531
  options.socketPath = config2.socketPath;
42346
42532
  } else {
42347
42533
  options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
@@ -42354,16 +42540,18 @@ var init_http = __esm(() => {
42354
42540
  if (isHttp2) {
42355
42541
  transport = http2Transport;
42356
42542
  } else {
42357
- if (config2.transport) {
42358
- transport = config2.transport;
42543
+ const configTransport = own2("transport");
42544
+ if (configTransport) {
42545
+ transport = configTransport;
42359
42546
  } else if (config2.maxRedirects === 0) {
42360
42547
  transport = isHttpsRequest ? https : http;
42361
42548
  } else {
42362
42549
  if (config2.maxRedirects) {
42363
42550
  options.maxRedirects = config2.maxRedirects;
42364
42551
  }
42365
- if (config2.beforeRedirect) {
42366
- options.beforeRedirects.config = config2.beforeRedirect;
42552
+ const configBeforeRedirect = own2("beforeRedirect");
42553
+ if (configBeforeRedirect) {
42554
+ options.beforeRedirects.config = configBeforeRedirect;
42367
42555
  }
42368
42556
  transport = isHttpsRequest ? httpsFollow : httpFollow;
42369
42557
  }
@@ -42373,9 +42561,7 @@ var init_http = __esm(() => {
42373
42561
  } else {
42374
42562
  options.maxBodyLength = Infinity;
42375
42563
  }
42376
- if (config2.insecureHTTPParser) {
42377
- options.insecureHTTPParser = config2.insecureHTTPParser;
42378
- }
42564
+ options.insecureHTTPParser = Boolean(own2("insecureHTTPParser"));
42379
42565
  req = transport.request(options, function handleResponse(res) {
42380
42566
  if (req.destroyed)
42381
42567
  return;
@@ -42423,6 +42609,23 @@ var init_http = __esm(() => {
42423
42609
  request: lastRequest
42424
42610
  };
42425
42611
  if (responseType === "stream") {
42612
+ if (config2.maxContentLength > -1) {
42613
+ const limit = config2.maxContentLength;
42614
+ const source = responseStream;
42615
+ async function* enforceMaxContentLength() {
42616
+ let totalResponseBytes = 0;
42617
+ for await (const chunk of source) {
42618
+ totalResponseBytes += chunk.length;
42619
+ if (totalResponseBytes > limit) {
42620
+ throw new AxiosError_default("maxContentLength size of " + limit + " exceeded", AxiosError_default.ERR_BAD_RESPONSE, config2, lastRequest);
42621
+ }
42622
+ yield chunk;
42623
+ }
42624
+ }
42625
+ responseStream = stream3.Readable.from(enforceMaxContentLength(), {
42626
+ objectMode: false
42627
+ });
42628
+ }
42426
42629
  response.data = responseStream;
42427
42630
  settle(resolve, reject, response);
42428
42631
  } else {
@@ -42485,6 +42688,21 @@ var init_http = __esm(() => {
42485
42688
  });
42486
42689
  req.on("socket", function handleRequestSocket(socket) {
42487
42690
  socket.setKeepAlive(true, 1000 * 60);
42691
+ if (!socket[kAxiosSocketListener]) {
42692
+ socket.on("error", function handleSocketError(err) {
42693
+ const current = socket[kAxiosCurrentReq];
42694
+ if (current && !current.destroyed) {
42695
+ current.destroy(err);
42696
+ }
42697
+ });
42698
+ socket[kAxiosSocketListener] = true;
42699
+ }
42700
+ socket[kAxiosCurrentReq] = req;
42701
+ req.once("close", function clearCurrentReq() {
42702
+ if (socket[kAxiosCurrentReq] === req) {
42703
+ socket[kAxiosCurrentReq] = null;
42704
+ }
42705
+ });
42488
42706
  });
42489
42707
  if (config2.timeout) {
42490
42708
  const timeout = parseInt(config2.timeout, 10);
@@ -42520,7 +42738,28 @@ var init_http = __esm(() => {
42520
42738
  abort(new CanceledError_default("Request stream has been aborted", config2, req));
42521
42739
  }
42522
42740
  });
42523
- data.pipe(req);
42741
+ let uploadStream = data;
42742
+ if (config2.maxBodyLength > -1 && config2.maxRedirects === 0) {
42743
+ const limit = config2.maxBodyLength;
42744
+ let bytesSent = 0;
42745
+ uploadStream = stream3.pipeline([
42746
+ data,
42747
+ new stream3.Transform({
42748
+ transform(chunk, _enc, cb) {
42749
+ bytesSent += chunk.length;
42750
+ if (bytesSent > limit) {
42751
+ return cb(new AxiosError_default("Request body larger than maxBodyLength limit", AxiosError_default.ERR_BAD_REQUEST, config2, req));
42752
+ }
42753
+ cb(null, chunk);
42754
+ }
42755
+ })
42756
+ ], utils_default.noop);
42757
+ uploadStream.on("error", (err) => {
42758
+ if (!req.destroyed)
42759
+ req.destroy(err);
42760
+ });
42761
+ }
42762
+ uploadStream.pipe(req);
42524
42763
  } else {
42525
42764
  data && req.write(data);
42526
42765
  req.end();
@@ -42587,7 +42826,13 @@ var init_cookies = __esm(() => {
42587
42826
  // node_modules/axios/lib/core/mergeConfig.js
42588
42827
  function mergeConfig(config1, config2) {
42589
42828
  config2 = config2 || {};
42590
- const config3 = {};
42829
+ const config3 = Object.create(null);
42830
+ Object.defineProperty(config3, "hasOwnProperty", {
42831
+ value: Object.prototype.hasOwnProperty,
42832
+ enumerable: false,
42833
+ writable: true,
42834
+ configurable: true
42835
+ });
42591
42836
  function getMergedValue(target, source, prop, caseless) {
42592
42837
  if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
42593
42838
  return utils_default.merge.call({ caseless }, target, source);
@@ -42618,9 +42863,9 @@ function mergeConfig(config1, config2) {
42618
42863
  }
42619
42864
  }
42620
42865
  function mergeDirectKeys(a, b, prop) {
42621
- if (prop in config2) {
42866
+ if (utils_default.hasOwnProp(config2, prop)) {
42622
42867
  return getMergedValue(a, b);
42623
- } else if (prop in config1) {
42868
+ } else if (utils_default.hasOwnProp(config1, prop)) {
42624
42869
  return getMergedValue(undefined, a);
42625
42870
  }
42626
42871
  }
@@ -42651,6 +42896,7 @@ function mergeConfig(config1, config2) {
42651
42896
  httpsAgent: defaultToConfig2,
42652
42897
  cancelToken: defaultToConfig2,
42653
42898
  socketPath: defaultToConfig2,
42899
+ allowedSocketPaths: defaultToConfig2,
42654
42900
  responseEncoding: defaultToConfig2,
42655
42901
  validateStatus: mergeDirectKeys,
42656
42902
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
@@ -42659,7 +42905,9 @@ function mergeConfig(config1, config2) {
42659
42905
  if (prop === "__proto__" || prop === "constructor" || prop === "prototype")
42660
42906
  return;
42661
42907
  const merge3 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
42662
- const configValue = merge3(config1[prop], config2[prop], prop);
42908
+ const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : undefined;
42909
+ const b = utils_default.hasOwnProp(config2, prop) ? config2[prop] : undefined;
42910
+ const configValue = merge3(a, b, prop);
42663
42911
  utils_default.isUndefined(configValue) && merge3 !== mergeDirectKeys || (config3[prop] = configValue);
42664
42912
  });
42665
42913
  return config3;
@@ -42673,9 +42921,18 @@ var init_mergeConfig = __esm(() => {
42673
42921
  // node_modules/axios/lib/helpers/resolveConfig.js
42674
42922
  var resolveConfig_default = (config2) => {
42675
42923
  const newConfig = mergeConfig({}, config2);
42676
- let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
42924
+ const own2 = (key) => utils_default.hasOwnProp(newConfig, key) ? newConfig[key] : undefined;
42925
+ const data = own2("data");
42926
+ let withXSRFToken = own2("withXSRFToken");
42927
+ const xsrfHeaderName = own2("xsrfHeaderName");
42928
+ const xsrfCookieName = own2("xsrfCookieName");
42929
+ let headers = own2("headers");
42930
+ const auth = own2("auth");
42931
+ const baseURL = own2("baseURL");
42932
+ const allowAbsoluteUrls = own2("allowAbsoluteUrls");
42933
+ const url3 = own2("url");
42677
42934
  newConfig.headers = headers = AxiosHeaders_default.from(headers);
42678
- newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config2.params, config2.paramsSerializer);
42935
+ newConfig.url = buildURL(buildFullPath(baseURL, url3, allowAbsoluteUrls), config2.params, config2.paramsSerializer);
42679
42936
  if (auth) {
42680
42937
  headers.set("Authorization", "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : "")));
42681
42938
  }
@@ -42693,8 +42950,11 @@ var resolveConfig_default = (config2) => {
42693
42950
  }
42694
42951
  }
42695
42952
  if (platform_default.hasStandardBrowserEnv) {
42696
- withXSRFToken && utils_default.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
42697
- if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin_default(newConfig.url)) {
42953
+ if (utils_default.isFunction(withXSRFToken)) {
42954
+ withXSRFToken = withXSRFToken(newConfig);
42955
+ }
42956
+ const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin_default(newConfig.url);
42957
+ if (shouldSendXSRF) {
42698
42958
  const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
42699
42959
  if (xsrfValue) {
42700
42960
  headers.set(xsrfHeaderName, xsrfValue);
@@ -42986,14 +43246,18 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
42986
43246
  const encodeText = isFetchSupported && (typeof TextEncoder2 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder2) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
42987
43247
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
42988
43248
  let duplexAccessed = false;
42989
- const hasContentType = new Request(platform_default.origin, {
43249
+ const request = new Request(platform_default.origin, {
42990
43250
  body: new ReadableStream2,
42991
43251
  method: "POST",
42992
43252
  get duplex() {
42993
43253
  duplexAccessed = true;
42994
43254
  return "half";
42995
43255
  }
42996
- }).headers.has("Content-Type");
43256
+ });
43257
+ const hasContentType = request.headers.has("Content-Type");
43258
+ if (request.body != null) {
43259
+ request.body.cancel();
43260
+ }
42997
43261
  return duplexAccessed && !hasContentType;
42998
43262
  });
42999
43263
  const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response2("").body));
@@ -43082,6 +43346,12 @@ var DEFAULT_CHUNK_SIZE, isFunction2, globalFetchAPI, ReadableStream2, TextEncode
43082
43346
  withCredentials = withCredentials ? "include" : "omit";
43083
43347
  }
43084
43348
  const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
43349
+ if (utils_default.isFormData(data)) {
43350
+ const contentType = headers.getContentType();
43351
+ if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
43352
+ headers.delete("content-type");
43353
+ }
43354
+ }
43085
43355
  const resolvedOptions = {
43086
43356
  ...fetchOptions,
43087
43357
  signal: composedSignal,
@@ -43271,7 +43541,7 @@ function assertOptions(options, schema, allowUnknown) {
43271
43541
  let i = keys.length;
43272
43542
  while (i-- > 0) {
43273
43543
  const opt = keys[i];
43274
- const validator = schema[opt];
43544
+ const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : undefined;
43275
43545
  if (validator) {
43276
43546
  const value = options[opt];
43277
43547
  const result = value === undefined || validator(value, opt, options);
@@ -43338,13 +43608,27 @@ class Axios {
43338
43608
  if (err instanceof Error) {
43339
43609
  let dummy = {};
43340
43610
  Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error;
43341
- const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
43611
+ const stack = (() => {
43612
+ if (!dummy.stack) {
43613
+ return "";
43614
+ }
43615
+ const firstNewlineIndex = dummy.stack.indexOf(`
43616
+ `);
43617
+ return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
43618
+ })();
43342
43619
  try {
43343
43620
  if (!err.stack) {
43344
43621
  err.stack = stack;
43345
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
43346
- err.stack += `
43622
+ } else if (stack) {
43623
+ const firstNewlineIndex = stack.indexOf(`
43624
+ `);
43625
+ const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf(`
43626
+ `, firstNewlineIndex + 1);
43627
+ const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? "" : stack.slice(secondNewlineIndex + 1);
43628
+ if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
43629
+ err.stack += `
43347
43630
  ` + stack;
43631
+ }
43348
43632
  }
43349
43633
  } catch (e) {}
43350
43634
  }
@@ -43848,26 +44132,13 @@ var init_dist = __esm(() => {
43848
44132
  init_upperFirst();
43849
44133
  });
43850
44134
 
43851
- // node_modules/uuid/dist-node/native.js
43852
- import { randomUUID } from "node:crypto";
43853
- var native_default;
43854
- var init_native = __esm(() => {
43855
- native_default = { randomUUID };
43856
- });
43857
-
43858
44135
  // node_modules/uuid/dist-node/rng.js
43859
- import { randomFillSync } from "node:crypto";
43860
44136
  function rng() {
43861
- if (poolPtr > rnds8Pool.length - 16) {
43862
- randomFillSync(rnds8Pool);
43863
- poolPtr = 0;
43864
- }
43865
- return rnds8Pool.slice(poolPtr, poolPtr += 16);
44137
+ return crypto.getRandomValues(rnds8);
43866
44138
  }
43867
- var rnds8Pool, poolPtr;
44139
+ var rnds8;
43868
44140
  var init_rng = __esm(() => {
43869
- rnds8Pool = new Uint8Array(256);
43870
- poolPtr = rnds8Pool.length;
44141
+ rnds8 = new Uint8Array(16);
43871
44142
  });
43872
44143
 
43873
44144
  // node_modules/uuid/dist-node/stringify.js
@@ -43883,6 +44154,12 @@ var init_stringify = __esm(() => {
43883
44154
  });
43884
44155
 
43885
44156
  // node_modules/uuid/dist-node/v4.js
44157
+ function v4(options, buf, offset) {
44158
+ if (!buf && !options && crypto.randomUUID) {
44159
+ return crypto.randomUUID();
44160
+ }
44161
+ return _v4(options, buf, offset);
44162
+ }
43886
44163
  function _v4(options, buf, offset) {
43887
44164
  options = options || {};
43888
44165
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -43903,15 +44180,8 @@ function _v4(options, buf, offset) {
43903
44180
  }
43904
44181
  return unsafeStringify(rnds);
43905
44182
  }
43906
- function v4(options, buf, offset) {
43907
- if (native_default.randomUUID && !buf && !options) {
43908
- return native_default.randomUUID();
43909
- }
43910
- return _v4(options, buf, offset);
43911
- }
43912
44183
  var v4_default;
43913
44184
  var init_v42 = __esm(() => {
43914
- init_native();
43915
44185
  init_rng();
43916
44186
  init_stringify();
43917
44187
  v4_default = v4;
@@ -46617,8 +46887,8 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
46617
46887
  options: localVarRequestOptions
46618
46888
  };
46619
46889
  },
46620
- v4WorkflowsPost: async (createWorkflowBody, options = {}) => {
46621
- const localVarPath = `/v4/workflows/`;
46890
+ v4WorkflowsPost: async (publicWorkflowCreateRequest, options = {}) => {
46891
+ const localVarPath = `/v4/workflows`;
46622
46892
  const localVarUrlObj = new URL$1(localVarPath, DUMMY_BASE_URL);
46623
46893
  let baseOptions;
46624
46894
  if (configuration) {
@@ -46633,7 +46903,7 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
46633
46903
  setSearchParams(localVarUrlObj, localVarQueryParameter);
46634
46904
  let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
46635
46905
  localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
46636
- localVarRequestOptions.data = serializeDataIfNeeded(createWorkflowBody, localVarRequestOptions, configuration);
46906
+ localVarRequestOptions.data = serializeDataIfNeeded(publicWorkflowCreateRequest, localVarRequestOptions, configuration);
46637
46907
  return {
46638
46908
  url: toPathString(localVarUrlObj),
46639
46909
  options: localVarRequestOptions
@@ -46730,7 +47000,30 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
46730
47000
  options: localVarRequestOptions
46731
47001
  };
46732
47002
  },
46733
- v4WorkflowsWorkflowIdDataGet: async (workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, options = {}) => {
47003
+ v4WorkflowsWorkflowIdDataExportsExportIdGet: async (workflowId, exportId, options = {}) => {
47004
+ assertParamExists("v4WorkflowsWorkflowIdDataExportsExportIdGet", "workflowId", workflowId);
47005
+ assertParamExists("v4WorkflowsWorkflowIdDataExportsExportIdGet", "exportId", exportId);
47006
+ const localVarPath = `/v4/workflows/{workflowId}/data/exports/{exportId}`.replace(`{${"workflowId"}}`, encodeURIComponent(String(workflowId))).replace(`{${"exportId"}}`, encodeURIComponent(String(exportId)));
47007
+ const localVarUrlObj = new URL$1(localVarPath, DUMMY_BASE_URL);
47008
+ let baseOptions;
47009
+ if (configuration) {
47010
+ baseOptions = configuration.baseOptions;
47011
+ }
47012
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
47013
+ const localVarHeaderParameter = {};
47014
+ const localVarQueryParameter = {};
47015
+ await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration);
47016
+ await setBearerAuthToObject(localVarHeaderParameter, configuration);
47017
+ localVarHeaderParameter["Accept"] = "text/csv";
47018
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
47019
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
47020
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
47021
+ return {
47022
+ url: toPathString(localVarUrlObj),
47023
+ options: localVarRequestOptions
47024
+ };
47025
+ },
47026
+ v4WorkflowsWorkflowIdDataGet: async (workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, download, options = {}) => {
46734
47027
  assertParamExists("v4WorkflowsWorkflowIdDataGet", "workflowId", workflowId);
46735
47028
  const localVarPath = `/v4/workflows/{workflowId}/data`.replace(`{${"workflowId"}}`, encodeURIComponent(String(workflowId)));
46736
47029
  const localVarUrlObj = new URL$1(localVarPath, DUMMY_BASE_URL);
@@ -46773,6 +47066,9 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
46773
47066
  if (includeAnomalies !== undefined) {
46774
47067
  localVarQueryParameter["includeAnomalies"] = includeAnomalies;
46775
47068
  }
47069
+ if (download !== undefined) {
47070
+ localVarQueryParameter["download"] = download;
47071
+ }
46776
47072
  localVarHeaderParameter["Accept"] = "application/json,text/csv";
46777
47073
  if (xApiKey != null) {
46778
47074
  localVarHeaderParameter["x-api-key"] = String(xApiKey);
@@ -46986,6 +47282,27 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
46986
47282
  options: localVarRequestOptions
46987
47283
  };
46988
47284
  },
47285
+ v4WorkflowsWorkflowIdStopPut: async (workflowId, options = {}) => {
47286
+ assertParamExists("v4WorkflowsWorkflowIdStopPut", "workflowId", workflowId);
47287
+ const localVarPath = `/v4/workflows/{workflowId}/stop`.replace(`{${"workflowId"}}`, encodeURIComponent(String(workflowId)));
47288
+ const localVarUrlObj = new URL$1(localVarPath, DUMMY_BASE_URL);
47289
+ let baseOptions;
47290
+ if (configuration) {
47291
+ baseOptions = configuration.baseOptions;
47292
+ }
47293
+ const localVarRequestOptions = { method: "PUT", ...baseOptions, ...options };
47294
+ const localVarHeaderParameter = {};
47295
+ const localVarQueryParameter = {};
47296
+ await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration);
47297
+ localVarHeaderParameter["Accept"] = "application/json";
47298
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
47299
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
47300
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
47301
+ return {
47302
+ url: toPathString(localVarUrlObj),
47303
+ options: localVarRequestOptions
47304
+ };
47305
+ },
46989
47306
  v5ChangesChangeIdGet: async (changeId, xApiKey, authorization, options = {}) => {
46990
47307
  assertParamExists("v5ChangesChangeIdGet", "changeId", changeId);
46991
47308
  const localVarPath = `/v5/changes/{changeId}`.replace(`{${"changeId"}}`, encodeURIComponent(String(changeId)));
@@ -47124,8 +47441,8 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
47124
47441
  const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsGet"]?.[localVarOperationServerIndex]?.url;
47125
47442
  return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
47126
47443
  },
47127
- async v4WorkflowsPost(createWorkflowBody, options) {
47128
- const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsPost(createWorkflowBody, options);
47444
+ async v4WorkflowsPost(publicWorkflowCreateRequest, options) {
47445
+ const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsPost(publicWorkflowCreateRequest, options);
47129
47446
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
47130
47447
  const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsPost"]?.[localVarOperationServerIndex]?.url;
47131
47448
  return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
@@ -47148,8 +47465,14 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
47148
47465
  const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsWorkflowIdComplianceRejectPut"]?.[localVarOperationServerIndex]?.url;
47149
47466
  return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
47150
47467
  },
47151
- async v4WorkflowsWorkflowIdDataGet(workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, options) {
47152
- const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsWorkflowIdDataGet(workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, options);
47468
+ async v4WorkflowsWorkflowIdDataExportsExportIdGet(workflowId, exportId, options) {
47469
+ const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsWorkflowIdDataExportsExportIdGet(workflowId, exportId, options);
47470
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
47471
+ const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsWorkflowIdDataExportsExportIdGet"]?.[localVarOperationServerIndex]?.url;
47472
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
47473
+ },
47474
+ async v4WorkflowsWorkflowIdDataGet(workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, download, options) {
47475
+ const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsWorkflowIdDataGet(workflowId, xApiKey, authorization, runId, format, sortBy2, order, filters, page, limit, gzip, rowIds, includeAnomalies, download, options);
47153
47476
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
47154
47477
  const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsWorkflowIdDataGet"]?.[localVarOperationServerIndex]?.url;
47155
47478
  return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
@@ -47208,6 +47531,12 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
47208
47531
  const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsWorkflowIdSchedulePut"]?.[localVarOperationServerIndex]?.url;
47209
47532
  return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
47210
47533
  },
47534
+ async v4WorkflowsWorkflowIdStopPut(workflowId, options) {
47535
+ const localVarAxiosArgs = await localVarAxiosParamCreator.v4WorkflowsWorkflowIdStopPut(workflowId, options);
47536
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
47537
+ const localVarOperationServerBasePath = operationServerMap["WorkflowsApi.v4WorkflowsWorkflowIdStopPut"]?.[localVarOperationServerIndex]?.url;
47538
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
47539
+ },
47211
47540
  async v5ChangesChangeIdGet(changeId, xApiKey, authorization, options) {
47212
47541
  const localVarAxiosArgs = await localVarAxiosParamCreator.v5ChangesChangeIdGet(changeId, xApiKey, authorization, options);
47213
47542
  const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
@@ -47389,8 +47718,7 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
47389
47718
  page: options.page ?? 1,
47390
47719
  limit: options.limit ?? this.defaultLimit
47391
47720
  });
47392
- const result = response.data;
47393
- return result;
47721
+ return response.data;
47394
47722
  }
47395
47723
  async fetchAllData(options) {
47396
47724
  const iterator2 = new PagedIterator((pageOptions) => this.fetchData({ ...options, ...pageOptions }));
@@ -48325,7 +48653,7 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
48325
48653
  }));
48326
48654
  return channels;
48327
48655
  }
48328
- }, PUBLIC_API_URI, WSS_API_URI, REALTIME_API_URI, SDK_VERSION = "0.29.1", SDK_NAME = "kadoa-node-sdk", SDK_LANGUAGE = "node", debug6, isDrainControlMessage = (message) => message.type === "control.draining", isRealtimeEvent = (message) => message.type !== "heartbeat" && message.type !== "control.draining", _Realtime = class _Realtime2 {
48656
+ }, PUBLIC_API_URI, WSS_API_URI, REALTIME_API_URI, SDK_VERSION = "0.31.1", SDK_NAME = "kadoa-node-sdk", SDK_LANGUAGE = "node", debug6, isDrainControlMessage = (message) => message.type === "control.draining", isRealtimeEvent = (message) => message.type !== "heartbeat" && message.type !== "control.draining", _Realtime = class _Realtime2 {
48329
48657
  constructor(config2) {
48330
48658
  this.drainingSockets = /* @__PURE__ */ new Set;
48331
48659
  this.lastHeartbeat = Date.now();
@@ -49059,53 +49387,20 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
49059
49387
  }
49060
49388
  async create(input) {
49061
49389
  validateAdditionalData(input.additionalData);
49062
- const domainName = new URL(input.urls[0]).hostname;
49063
- if (input.navigationMode === "agentic-navigation") {
49064
- if (!input.userPrompt) {
49065
- throw new KadoaSdkException("userPrompt is required when navigationMode is 'agentic-navigation'", {
49066
- code: "VALIDATION_ERROR",
49067
- details: { navigationMode: input.navigationMode }
49068
- });
49069
- }
49070
- const agenticRequest = {
49071
- urls: input.urls,
49072
- navigationMode: "agentic-navigation",
49073
- name: input.name ?? domainName,
49074
- description: input.description,
49075
- userPrompt: input.userPrompt,
49076
- schemaId: input.schemaId,
49077
- entity: input.entity,
49078
- fields: input.fields,
49079
- bypassPreview: input.bypassPreview ?? true,
49080
- tags: input.tags,
49081
- interval: input.interval,
49082
- monitoring: input.monitoring,
49083
- location: input.location,
49084
- autoStart: input.autoStart,
49085
- schedules: input.schedules,
49086
- additionalData: input.additionalData,
49087
- limit: input.limit
49088
- };
49089
- const response2 = await this.workflowsApi.v4WorkflowsPost({
49090
- createWorkflowBody: agenticRequest
49390
+ if (!input.userPrompt) {
49391
+ throw new KadoaSdkException("userPrompt is required to create a workflow", {
49392
+ code: "VALIDATION_ERROR",
49393
+ details: { urls: input.urls }
49091
49394
  });
49092
- const workflowId2 = response2.data?.workflowId;
49093
- if (!workflowId2) {
49094
- throw new KadoaSdkException(ERROR_MESSAGES.NO_WORKFLOW_ID, {
49095
- code: "INTERNAL_ERROR",
49096
- details: {
49097
- response: response2.data
49098
- }
49099
- });
49100
- }
49101
- return { id: workflowId2 };
49102
49395
  }
49396
+ const domainName = new URL(input.urls[0]).hostname;
49103
49397
  const request = {
49104
49398
  urls: input.urls,
49105
49399
  name: input.name ?? domainName,
49106
- schemaId: input.schemaId,
49107
49400
  description: input.description,
49108
- navigationMode: input.navigationMode,
49401
+ userPrompt: input.userPrompt,
49402
+ navigationMode: "agentic-navigation",
49403
+ schemaId: input.schemaId,
49109
49404
  ...input.entity != null && { entity: input.entity },
49110
49405
  fields: input.fields,
49111
49406
  bypassPreview: input.bypassPreview ?? true,
@@ -49113,13 +49408,12 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
49113
49408
  interval: input.interval,
49114
49409
  monitoring: input.monitoring,
49115
49410
  location: input.location,
49116
- autoStart: input.autoStart,
49117
49411
  schedules: input.schedules,
49118
49412
  additionalData: input.additionalData,
49119
49413
  limit: input.limit
49120
49414
  };
49121
49415
  const response = await this.workflowsApi.v4WorkflowsPost({
49122
- createWorkflowBody: request
49416
+ publicWorkflowCreateRequest: request
49123
49417
  });
49124
49418
  const workflowId = response.data?.workflowId;
49125
49419
  if (!workflowId) {
@@ -49148,6 +49442,14 @@ var import_debug, __require2, ChangeDifferenceType, KadoaErrorCode, _KadoaSdkExc
49148
49442
  });
49149
49443
  return response.data?.workflows?.[0];
49150
49444
  }
49445
+ async getAuditLog(id, options) {
49446
+ const response = await this.workflowsApi.v5WorkflowsWorkflowIdAuditlogGet({
49447
+ workflowId: id,
49448
+ page: options?.page,
49449
+ limit: options?.limit
49450
+ });
49451
+ return response.data;
49452
+ }
49151
49453
  async delete(id) {
49152
49454
  await this.workflowsApi.v4WorkflowsWorkflowIdDelete({
49153
49455
  workflowId: id
@@ -49855,7 +50157,7 @@ var init_dist2 = __esm(() => {
49855
50157
  return WorkflowsApiFp(this.configuration).v4WorkflowsGet(requestParameters.search, requestParameters.skip, requestParameters.limit, requestParameters.state, requestParameters.runState, requestParameters.displayState, requestParameters.inSupport, requestParameters.tags, requestParameters.userId, requestParameters.monitoring, requestParameters.updateInterval, requestParameters.includeDeleted, requestParameters.format, options).then((request) => request(this.axios, this.basePath));
49856
50158
  }
49857
50159
  v4WorkflowsPost(requestParameters = {}, options) {
49858
- return WorkflowsApiFp(this.configuration).v4WorkflowsPost(requestParameters.createWorkflowBody, options).then((request) => request(this.axios, this.basePath));
50160
+ return WorkflowsApiFp(this.configuration).v4WorkflowsPost(requestParameters.publicWorkflowCreateRequest, options).then((request) => request(this.axios, this.basePath));
49859
50161
  }
49860
50162
  v4WorkflowsWorkflowIdAuditlogGet(requestParameters, options) {
49861
50163
  return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdAuditlogGet(requestParameters.workflowId, requestParameters.xApiKey, requestParameters.authorization, requestParameters.page, requestParameters.limit, options).then((request) => request(this.axios, this.basePath));
@@ -49866,8 +50168,11 @@ var init_dist2 = __esm(() => {
49866
50168
  v4WorkflowsWorkflowIdComplianceRejectPut(requestParameters, options) {
49867
50169
  return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdComplianceRejectPut(requestParameters.workflowId, requestParameters.v4WorkflowsWorkflowIdComplianceRejectPutRequest, requestParameters.xApiKey, requestParameters.authorization, options).then((request) => request(this.axios, this.basePath));
49868
50170
  }
50171
+ v4WorkflowsWorkflowIdDataExportsExportIdGet(requestParameters, options) {
50172
+ return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdDataExportsExportIdGet(requestParameters.workflowId, requestParameters.exportId, options).then((request) => request(this.axios, this.basePath));
50173
+ }
49869
50174
  v4WorkflowsWorkflowIdDataGet(requestParameters, options) {
49870
- return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdDataGet(requestParameters.workflowId, requestParameters.xApiKey, requestParameters.authorization, requestParameters.runId, requestParameters.format, requestParameters.sortBy, requestParameters.order, requestParameters.filters, requestParameters.page, requestParameters.limit, requestParameters.gzip, requestParameters.rowIds, requestParameters.includeAnomalies, options).then((request) => request(this.axios, this.basePath));
50175
+ return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdDataGet(requestParameters.workflowId, requestParameters.xApiKey, requestParameters.authorization, requestParameters.runId, requestParameters.format, requestParameters.sortBy, requestParameters.order, requestParameters.filters, requestParameters.page, requestParameters.limit, requestParameters.gzip, requestParameters.rowIds, requestParameters.includeAnomalies, requestParameters.download, options).then((request) => request(this.axios, this.basePath));
49871
50176
  }
49872
50177
  v4WorkflowsWorkflowIdDelete(requestParameters, options) {
49873
50178
  return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdDelete(requestParameters.workflowId, options).then((request) => request(this.axios, this.basePath));
@@ -49896,6 +50201,9 @@ var init_dist2 = __esm(() => {
49896
50201
  v4WorkflowsWorkflowIdSchedulePut(requestParameters, options) {
49897
50202
  return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdSchedulePut(requestParameters.workflowId, requestParameters.v4WorkflowsWorkflowIdSchedulePutRequest, options).then((request) => request(this.axios, this.basePath));
49898
50203
  }
50204
+ v4WorkflowsWorkflowIdStopPut(requestParameters, options) {
50205
+ return WorkflowsApiFp(this.configuration).v4WorkflowsWorkflowIdStopPut(requestParameters.workflowId, options).then((request) => request(this.axios, this.basePath));
50206
+ }
49899
50207
  v5ChangesChangeIdGet(requestParameters, options) {
49900
50208
  return WorkflowsApiFp(this.configuration).v5ChangesChangeIdGet(requestParameters.changeId, requestParameters.xApiKey, requestParameters.authorization, options).then((request) => request(this.axios, this.basePath));
49901
50209
  }
@@ -50391,6 +50699,25 @@ function classifyError(error48, toolName) {
50391
50699
  }
50392
50700
  return "Unknown error";
50393
50701
  }
50702
+ function jsonEq(a, b) {
50703
+ return JSON.stringify(a) === JSON.stringify(b);
50704
+ }
50705
+ function diffWorkflowAuditEntry(entry) {
50706
+ const prev = entry.previousValue;
50707
+ const next = entry.newValue;
50708
+ if (!prev || !next)
50709
+ return [];
50710
+ const changed = [];
50711
+ for (const key of WORKFLOW_AUDIT_WATCHED_KEYS) {
50712
+ if (!jsonEq(prev[key], next[key]))
50713
+ changed.push(key);
50714
+ }
50715
+ const prevPrompt = prev["additionalData"]?.["userPrompt"];
50716
+ const nextPrompt = next["additionalData"]?.["userPrompt"];
50717
+ if (!jsonEq(prevPrompt, nextPrompt))
50718
+ changed.push("additionalData.userPrompt");
50719
+ return changed;
50720
+ }
50394
50721
  function registerTools(server, ctx) {
50395
50722
  function withErrorHandling(name, handler) {
50396
50723
  return async (...args) => {
@@ -50751,6 +51078,42 @@ function registerTools(server, ctx) {
50751
51078
  notificationConfig: workflow.notificationConfig
50752
51079
  });
50753
51080
  }));
51081
+ server.registerTool("get_workflow_history", {
51082
+ description: "Get the configuration revision history (audit log) for a workflow. Each entry captures who changed the workflow, when, from which channel (UI/API/SDK/MCP/CLI/SYSTEM), and a `changedFields` list summarizing what changed between revisions. Use this to answer questions like 'did this workflow's prompt or schema change, when, and from what to what?'. Note: CREATE entries return null `previousValue`/`newValue` and an empty `changedFields` (no initial-state snapshot is captured).",
51083
+ inputSchema: {
51084
+ workflowId: exports_external.string().describe("The workflow ID"),
51085
+ page: exports_external.preprocess(coerceNumber(), exports_external.number()).optional().describe("Page number, 1-based (default: 1)"),
51086
+ limit: exports_external.preprocess(coerceNumber(), exports_external.number()).optional().describe("Entries per page (default: 25)")
51087
+ },
51088
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true }
51089
+ }, withErrorHandling("get_workflow_history", async (args) => {
51090
+ const response = await ctx.client.workflow.getAuditLog(args.workflowId, {
51091
+ page: args.page,
51092
+ limit: args.limit
51093
+ });
51094
+ const entries = (response.logEntries ?? []).map((e) => ({
51095
+ id: e.id,
51096
+ operationType: e.operationType,
51097
+ createdAt: e.createdAt,
51098
+ userEmail: e.userEmail,
51099
+ userId: e.userId,
51100
+ requestSource: e.requestSource,
51101
+ authMethod: e.authMethod,
51102
+ changedFields: diffWorkflowAuditEntry({
51103
+ previousValue: e.previousValue,
51104
+ newValue: e.newValue
51105
+ }),
51106
+ previousValue: e.previousValue,
51107
+ newValue: e.newValue
51108
+ }));
51109
+ return jsonResult({
51110
+ workflowId: response.id,
51111
+ totalCount: response.pagination?.totalCount ?? response.logEntriesCount ?? entries.length,
51112
+ page: response.pagination?.page ?? 1,
51113
+ totalPages: response.pagination?.totalPages ?? 1,
51114
+ entries
51115
+ });
51116
+ }));
50754
51117
  server.registerTool("run_workflow", {
50755
51118
  description: "Run a workflow to extract fresh data. The run is asynchronous and may take several minutes. Do NOT poll or sleep-wait for completion. Return the workflow ID to the user and let them check status with get_workflow or fetch results later with fetch_data.",
50756
51119
  inputSchema: {
@@ -51479,7 +51842,7 @@ function registerTools(server, ctx) {
51479
51842
  return jsonResult({ schemas: schemas4, count: schemas4.length });
51480
51843
  }));
51481
51844
  }
51482
- var SchemaFieldShape, DASHBOARD_BASE_URL = "https://www.kadoa.com";
51845
+ var SchemaFieldShape, DASHBOARD_BASE_URL = "https://www.kadoa.com", WORKFLOW_AUDIT_WATCHED_KEYS;
51483
51846
  var init_tools = __esm(() => {
51484
51847
  init_zod();
51485
51848
  init_dist2();
@@ -51493,6 +51856,17 @@ var init_tools = __esm(() => {
51493
51856
  isRequired: exports_external.boolean().optional(),
51494
51857
  isUnique: exports_external.boolean().optional()
51495
51858
  };
51859
+ WORKFLOW_AUDIT_WATCHED_KEYS = [
51860
+ "name",
51861
+ "tags",
51862
+ "urls",
51863
+ "schedules",
51864
+ "entity",
51865
+ "schema",
51866
+ "monitoringConfig",
51867
+ "location",
51868
+ "navigationMode"
51869
+ ];
51496
51870
  });
51497
51871
 
51498
51872
  // package.json
@@ -51500,7 +51874,7 @@ var package_default;
51500
51874
  var init_package = __esm(() => {
51501
51875
  package_default = {
51502
51876
  name: "@kadoa/mcp",
51503
- version: "0.5.3-rc.1",
51877
+ version: "0.5.3",
51504
51878
  description: "Kadoa MCP Server — manage workflows from Claude Desktop, Cursor, and other MCP clients",
51505
51879
  type: "module",
51506
51880
  main: "dist/index.js",
@@ -51524,7 +51898,7 @@ var init_package = __esm(() => {
51524
51898
  prepublishOnly: "bun run check-types && bun run test:unit && bun run build"
51525
51899
  },
51526
51900
  dependencies: {
51527
- "@kadoa/node-sdk": "^0.29.1",
51901
+ "@kadoa/node-sdk": "^0.31.1",
51528
51902
  "@modelcontextprotocol/sdk": "^1.26.0",
51529
51903
  express: "^5.2.1",
51530
51904
  ioredis: "^5.6.1",
@@ -55542,10 +55916,6 @@ function generatePKCE() {
55542
55916
  const challenge = createHash2("sha256").update(verifier).digest("base64url");
55543
55917
  return { verifier, challenge };
55544
55918
  }
55545
- function kadoaAuthUrl() {
55546
- const raw = process.env.KADOA_AUTH_URL || "https://auth.kadoa.com";
55547
- return raw.replace(/\/+$/, "");
55548
- }
55549
55919
  function jwtClaims(jwt2) {
55550
55920
  try {
55551
55921
  const payload = JSON.parse(Buffer.from(jwt2.split(".")[1], "base64url").toString());
@@ -55558,6 +55928,76 @@ function jwtClaims(jwt2) {
55558
55928
  return {};
55559
55929
  }
55560
55930
  }
55931
+ async function exchangeSupabaseCode(code, codeVerifier) {
55932
+ const supabaseUrl = process.env.SUPABASE_URL;
55933
+ if (!supabaseUrl)
55934
+ throw new Error("SUPABASE_URL is not configured");
55935
+ const res = await fetch(`${supabaseUrl}/auth/v1/token?grant_type=pkce`, {
55936
+ method: "POST",
55937
+ headers: {
55938
+ "Content-Type": "application/json",
55939
+ apikey: process.env.SUPABASE_ANON_KEY
55940
+ },
55941
+ body: JSON.stringify({ auth_code: code, code_verifier: codeVerifier })
55942
+ });
55943
+ if (!res.ok) {
55944
+ const body = await res.text();
55945
+ throw new Error(`Supabase token exchange failed (${res.status}): ${body}`);
55946
+ }
55947
+ const data = await res.json();
55948
+ return { accessToken: data.access_token, refreshToken: data.refresh_token };
55949
+ }
55950
+ async function fetchUserTeams(supabaseJwt) {
55951
+ const kadoaApiUrl = process.env.KADOA_PUBLIC_API_URI || "https://api.kadoa.com";
55952
+ const userRes = await fetch(`${kadoaApiUrl}/v4/user`, {
55953
+ headers: { Authorization: `Bearer ${supabaseJwt}` }
55954
+ });
55955
+ if (!userRes.ok) {
55956
+ const body = await userRes.text();
55957
+ throw new Error(`Kadoa /v4/user failed (${userRes.status}): ${body}`);
55958
+ }
55959
+ const userData = await userRes.json();
55960
+ if (!userData.teams?.length) {
55961
+ throw new Error("User has no teams");
55962
+ }
55963
+ return userData.teams.map((t) => ({
55964
+ id: t.id,
55965
+ name: t.name,
55966
+ memberRole: t.memberRole
55967
+ }));
55968
+ }
55969
+ async function setActiveTeamAndRefresh(jwt2, refreshToken, teamId) {
55970
+ const kadoaApiUrl = process.env.KADOA_PUBLIC_API_URI || "https://api.kadoa.com";
55971
+ const supabaseUrl = process.env.SUPABASE_URL;
55972
+ if (!supabaseUrl)
55973
+ throw new Error("SUPABASE_URL is not configured");
55974
+ const setRes = await fetch(`${kadoaApiUrl}/v5/auth/active-team`, {
55975
+ method: "POST",
55976
+ headers: {
55977
+ "Content-Type": "application/json",
55978
+ Authorization: `Bearer ${jwt2}`
55979
+ },
55980
+ body: JSON.stringify({ teamId })
55981
+ });
55982
+ if (!setRes.ok) {
55983
+ const body = await setRes.text();
55984
+ throw new Error(`POST /v5/auth/active-team failed (${setRes.status}): ${body}`);
55985
+ }
55986
+ const refreshRes = await fetch(`${supabaseUrl}/auth/v1/token?grant_type=refresh_token`, {
55987
+ method: "POST",
55988
+ headers: {
55989
+ "Content-Type": "application/json",
55990
+ apikey: process.env.SUPABASE_ANON_KEY
55991
+ },
55992
+ body: JSON.stringify({ refresh_token: refreshToken })
55993
+ });
55994
+ if (!refreshRes.ok) {
55995
+ const body = await refreshRes.text();
55996
+ throw new Error(`Supabase token refresh failed (${refreshRes.status}): ${body}`);
55997
+ }
55998
+ const data = await refreshRes.json();
55999
+ return { jwt: data.access_token, refreshToken: data.refresh_token };
56000
+ }
55561
56001
 
55562
56002
  class KadoaOAuthProvider {
55563
56003
  store;
@@ -55583,23 +56023,151 @@ class KadoaOAuthProvider {
55583
56023
  };
55584
56024
  }
55585
56025
  async authorize(client, params, res) {
56026
+ const supabaseUrl = process.env.SUPABASE_URL;
55586
56027
  const serverUrl = process.env.MCP_SERVER_URL;
55587
- if (!serverUrl)
55588
- throw new Error("MCP_SERVER_URL must be configured");
56028
+ if (!supabaseUrl || !serverUrl) {
56029
+ throw new Error("SUPABASE_URL and MCP_SERVER_URL must be configured");
56030
+ }
55589
56031
  const state = randomToken();
55590
56032
  const { verifier, challenge } = generatePKCE();
55591
56033
  await this.store.set("pending_auths", state, {
55592
56034
  client,
55593
56035
  params,
55594
- mcpVerifier: verifier
56036
+ supabaseCodeVerifier: verifier
55595
56037
  }, 600);
55596
- const authUrl = new URL(`${kadoaAuthUrl()}/login`);
55597
- authUrl.searchParams.set("callback_url", `${serverUrl}/auth/callback`);
55598
- authUrl.searchParams.set("state", state);
55599
- authUrl.searchParams.set("code_challenge", challenge);
56038
+ res.type("html").send(renderLoginPage(state));
56039
+ }
56040
+ async handleGoogleLogin(req, res) {
56041
+ const { state } = req.body;
56042
+ const pending = await this.store.get("pending_auths", state);
56043
+ if (!pending) {
56044
+ res.status(400).send("Unknown or expired state parameter");
56045
+ return;
56046
+ }
56047
+ const supabaseUrl = process.env.SUPABASE_URL;
56048
+ const serverUrl = process.env.MCP_SERVER_URL;
56049
+ if (!supabaseUrl || !serverUrl) {
56050
+ res.status(500).send("Server misconfigured");
56051
+ return;
56052
+ }
56053
+ const redirectTo = `${serverUrl}/auth/callback?mcp_state=${state}`;
56054
+ const authUrl = new URL(`${supabaseUrl}/auth/v1/authorize`);
56055
+ authUrl.searchParams.set("provider", "google");
56056
+ authUrl.searchParams.set("redirect_to", redirectTo);
56057
+ authUrl.searchParams.set("code_challenge", pending.supabaseCodeVerifier ? createHash2("sha256").update(pending.supabaseCodeVerifier).digest("base64url") : "");
55600
56058
  authUrl.searchParams.set("code_challenge_method", "S256");
55601
56059
  res.redirect(authUrl.toString());
55602
56060
  }
56061
+ async handleEmailPasswordLogin(req, res) {
56062
+ const { state, email: email3, password } = req.body;
56063
+ if (!state || !email3 || !password) {
56064
+ res.status(400).send("Missing required fields");
56065
+ return;
56066
+ }
56067
+ const pending = await this.store.get("pending_auths", state);
56068
+ if (!pending) {
56069
+ res.status(400).type("html").send(renderLoginPage(state, "Session expired — please try again"));
56070
+ return;
56071
+ }
56072
+ const supabaseUrl = process.env.SUPABASE_URL;
56073
+ if (!supabaseUrl) {
56074
+ res.status(500).send("Server misconfigured");
56075
+ return;
56076
+ }
56077
+ try {
56078
+ const tokenRes = await fetch(`${supabaseUrl}/auth/v1/token?grant_type=password`, {
56079
+ method: "POST",
56080
+ headers: {
56081
+ "Content-Type": "application/json",
56082
+ apikey: process.env.SUPABASE_ANON_KEY
56083
+ },
56084
+ body: JSON.stringify({ email: email3, password })
56085
+ });
56086
+ if (!tokenRes.ok) {
56087
+ const body = await tokenRes.json().catch(() => ({ error_description: "Authentication failed" }));
56088
+ const message = body.error_description || body.msg || "Invalid email or password";
56089
+ res.type("html").send(renderLoginPage(state, message));
56090
+ return;
56091
+ }
56092
+ const data = await tokenRes.json();
56093
+ await this.store.del("pending_auths", state);
56094
+ await this.completeAuthWithTokens(pending, res, data.access_token, data.refresh_token);
56095
+ } catch (error48) {
56096
+ console.error("Email/password login error:", error48);
56097
+ res.type("html").send(renderLoginPage(state, "An unexpected error occurred"));
56098
+ }
56099
+ }
56100
+ async handleSSOLogin(req, res) {
56101
+ const { state, email: email3 } = req.body;
56102
+ if (!state || !email3) {
56103
+ res.status(400).send("Missing required fields");
56104
+ return;
56105
+ }
56106
+ const pending = await this.store.get("pending_auths", state);
56107
+ if (!pending) {
56108
+ res.status(400).type("html").send(renderLoginPage(state, "Session expired — please try again"));
56109
+ return;
56110
+ }
56111
+ const supabaseUrl = process.env.SUPABASE_URL;
56112
+ const serverUrl = process.env.MCP_SERVER_URL;
56113
+ if (!supabaseUrl || !serverUrl) {
56114
+ res.status(500).send("Server misconfigured");
56115
+ return;
56116
+ }
56117
+ const domain2 = email3.includes("@") ? email3.split("@").pop() : email3;
56118
+ try {
56119
+ const ssoRes = await fetch(`${supabaseUrl}/auth/v1/sso`, {
56120
+ method: "POST",
56121
+ headers: {
56122
+ "Content-Type": "application/json",
56123
+ apikey: process.env.SUPABASE_ANON_KEY
56124
+ },
56125
+ body: JSON.stringify({
56126
+ domain: domain2,
56127
+ redirect_to: `${serverUrl}/auth/callback?mcp_state=${state}`,
56128
+ skip_http_redirect: true,
56129
+ code_challenge: createHash2("sha256").update(pending.supabaseCodeVerifier).digest("base64url"),
56130
+ code_challenge_method: "s256"
56131
+ })
56132
+ });
56133
+ if (!ssoRes.ok) {
56134
+ const body = await ssoRes.json().catch(() => ({}));
56135
+ const message = body.error_description || body.msg || body.message || "No SSO provider configured for this domain";
56136
+ res.type("html").send(renderLoginPage(state, message));
56137
+ return;
56138
+ }
56139
+ const data = await ssoRes.json();
56140
+ if (!data.url) {
56141
+ res.type("html").send(renderLoginPage(state, "No SSO provider configured for this domain"));
56142
+ return;
56143
+ }
56144
+ res.redirect(data.url);
56145
+ } catch (error48) {
56146
+ console.error("SSO login error:", error48);
56147
+ res.type("html").send(renderLoginPage(state, "An unexpected error occurred"));
56148
+ }
56149
+ }
56150
+ async completeAuthWithTokens(pending, res, supabaseJwt, supabaseRefreshToken) {
56151
+ const teams = await fetchUserTeams(supabaseJwt);
56152
+ if (teams.length === 1) {
56153
+ const refreshed = await setActiveTeamAndRefresh(supabaseJwt, supabaseRefreshToken, teams[0].id);
56154
+ await this.completeAuthFlow(pending, res, {
56155
+ jwt: refreshed.jwt,
56156
+ refreshToken: refreshed.refreshToken,
56157
+ teamId: teams[0].id
56158
+ });
56159
+ return;
56160
+ }
56161
+ const selectionToken = randomToken();
56162
+ await this.store.set("pending_team_selections", selectionToken, {
56163
+ supabaseJwt,
56164
+ supabaseRefreshToken,
56165
+ teams,
56166
+ pending,
56167
+ expiresAt: Date.now() + TEAM_SELECTION_TTL
56168
+ }, 600);
56169
+ res.type("html").send(renderTeamSelectionPage(teams, selectionToken));
56170
+ }
55603
56171
  async challengeForAuthorizationCode(_client, authorizationCode) {
55604
56172
  const entry = await this.store.get("auth_codes", authorizationCode);
55605
56173
  if (!entry)
@@ -55724,9 +56292,9 @@ class KadoaOAuthProvider {
55724
56292
  };
55725
56293
  }
55726
56294
  async handleAuthCallback(req, res) {
55727
- const { code, state } = req.query;
56295
+ const { code, mcp_state: state } = req.query;
55728
56296
  if (!code || !state) {
55729
- res.status(400).send("Missing code or state parameter");
56297
+ res.status(400).send("Missing code or mcp_state parameter");
55730
56298
  return;
55731
56299
  }
55732
56300
  const pending = await this.store.get("pending_auths", state);
@@ -55736,28 +56304,10 @@ class KadoaOAuthProvider {
55736
56304
  }
55737
56305
  await this.store.del("pending_auths", state);
55738
56306
  try {
55739
- const tokenRes = await fetch(`${kadoaAuthUrl()}/api/token`, {
55740
- method: "POST",
55741
- headers: { "Content-Type": "application/json" },
55742
- body: JSON.stringify({ code, code_verifier: pending.mcpVerifier })
55743
- });
55744
- if (!tokenRes.ok) {
55745
- const body = await tokenRes.text().catch(() => "");
55746
- throw new Error(`auth.kadoa.com /api/token failed (${tokenRes.status}): ${body}`);
55747
- }
55748
- const data = await tokenRes.json();
55749
- if (typeof data?.access_token !== "string" || typeof data?.refresh_token !== "string" || typeof data?.team_id !== "string") {
55750
- throw new Error("auth.kadoa.com /api/token returned malformed response");
55751
- }
55752
- const claims = jwtClaims(data.access_token);
55753
- console.error(`[AUTH] CALLBACK_OK: tokens received (email=${claims.email}, team=${data.team_id})`);
55754
- await this.completeAuthFlow(pending, res, {
55755
- jwt: data.access_token,
55756
- refreshToken: data.refresh_token,
55757
- teamId: data.team_id
55758
- });
56307
+ const supabaseTokens = await exchangeSupabaseCode(code, pending.supabaseCodeVerifier);
56308
+ await this.completeAuthWithTokens(pending, res, supabaseTokens.accessToken, supabaseTokens.refreshToken);
55759
56309
  } catch (error48) {
55760
- console.error("[AUTH] CALLBACK_FAIL:", error48);
56310
+ console.error("Auth callback error:", error48);
55761
56311
  const redirectUrl = new URL(pending.params.redirectUri);
55762
56312
  redirectUrl.searchParams.set("error", "server_error");
55763
56313
  redirectUrl.searchParams.set("error_description", error48 instanceof Error ? error48.message : "Authentication failed");
@@ -55767,6 +56317,45 @@ class KadoaOAuthProvider {
55767
56317
  res.redirect(redirectUrl.toString());
55768
56318
  }
55769
56319
  }
56320
+ async handleTeamSelection(req, res) {
56321
+ const { token, teamId } = req.body;
56322
+ if (!token || !teamId) {
56323
+ res.status(400).send("Missing token or teamId");
56324
+ return;
56325
+ }
56326
+ const entry = await this.store.get("pending_team_selections", token);
56327
+ if (!entry) {
56328
+ res.status(400).send("Unknown or expired team selection token");
56329
+ return;
56330
+ }
56331
+ if (entry.expiresAt < Date.now()) {
56332
+ await this.store.del("pending_team_selections", token);
56333
+ res.status(400).send("Team selection expired — please log in again");
56334
+ return;
56335
+ }
56336
+ if (!entry.teams.some((t) => t.id === teamId)) {
56337
+ res.status(403).send("Invalid team selection");
56338
+ return;
56339
+ }
56340
+ await this.store.del("pending_team_selections", token);
56341
+ try {
56342
+ const refreshed = await setActiveTeamAndRefresh(entry.supabaseJwt, entry.supabaseRefreshToken, teamId);
56343
+ await this.completeAuthFlow(entry.pending, res, {
56344
+ jwt: refreshed.jwt,
56345
+ refreshToken: refreshed.refreshToken,
56346
+ teamId
56347
+ });
56348
+ } catch (error48) {
56349
+ console.error("Team selection error:", error48);
56350
+ const redirectUrl = new URL(entry.pending.params.redirectUri);
56351
+ redirectUrl.searchParams.set("error", "server_error");
56352
+ redirectUrl.searchParams.set("error_description", error48 instanceof Error ? error48.message : "Failed to set active team");
56353
+ if (entry.pending.params.state) {
56354
+ redirectUrl.searchParams.set("state", entry.pending.params.state);
56355
+ }
56356
+ res.redirect(redirectUrl.toString());
56357
+ }
56358
+ }
55770
56359
  async completeAuthFlow(pending, res, credentials) {
55771
56360
  const mcpCode = randomToken();
55772
56361
  await this.store.set("auth_codes", mcpCode, {
@@ -55786,9 +56375,429 @@ class KadoaOAuthProvider {
55786
56375
  res.redirect(redirectUrl.toString());
55787
56376
  }
55788
56377
  }
55789
- var ACCESS_TOKEN_TTL;
56378
+ function renderTeamSelectionPage(teams, selectionToken) {
56379
+ const teamButtons = teams.map((t) => `
56380
+ <button type="submit" name="teamId" value="${t.id}" class="team-btn">
56381
+ <span class="team-name">${escapeHtml(t.name)}</span>
56382
+ ${t.memberRole ? `<span class="team-role">${escapeHtml(t.memberRole.toLowerCase())}</span>` : ""}
56383
+ </button>`).join(`
56384
+ `);
56385
+ return `<!DOCTYPE html>
56386
+ <html lang="en">
56387
+ <head>
56388
+ <meta charset="utf-8" />
56389
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
56390
+ <title>Select Team - Kadoa</title>
56391
+ <style>
56392
+ * { margin: 0; padding: 0; box-sizing: border-box; }
56393
+
56394
+ body {
56395
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
56396
+ background: oklch(1 0 0);
56397
+ color: oklch(0.17 0.02 228);
56398
+ min-height: 100vh;
56399
+ display: flex;
56400
+ align-items: center;
56401
+ justify-content: center;
56402
+ }
56403
+
56404
+ .container {
56405
+ width: 100%;
56406
+ max-width: 420px;
56407
+ padding: 2rem;
56408
+ }
56409
+
56410
+ .logo {
56411
+ text-align: center;
56412
+ margin-bottom: 2rem;
56413
+ }
56414
+
56415
+ h1 {
56416
+ font-size: 1.25rem;
56417
+ font-weight: 600;
56418
+ text-align: center;
56419
+ margin-bottom: 0.5rem;
56420
+ color: oklch(0.17 0.02 228);
56421
+ }
56422
+
56423
+ .subtitle {
56424
+ text-align: center;
56425
+ color: oklch(0.56 0.02 228);
56426
+ font-size: 0.875rem;
56427
+ margin-bottom: 1.5rem;
56428
+ }
56429
+
56430
+ .team-btn {
56431
+ width: 100%;
56432
+ display: flex;
56433
+ align-items: center;
56434
+ justify-content: space-between;
56435
+ padding: 0.875rem 1rem;
56436
+ margin-bottom: 0.5rem;
56437
+ background: oklch(1 0 0);
56438
+ border: 1px solid oklch(0.5 0.02 228 / 0.4);
56439
+ border-radius: 0.3rem;
56440
+ color: oklch(0.17 0.02 228);
56441
+ font-size: 15px;
56442
+ cursor: pointer;
56443
+ transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
56444
+ box-shadow: 0px 1px 1px 0px oklch(0.68 0.01 60.13 / 0.11);
56445
+ }
56446
+
56447
+ .team-btn:hover {
56448
+ background: oklch(0.96 0 286);
56449
+ border-color: oklch(0.7 0.18 42);
56450
+ }
56451
+
56452
+ .team-btn:active {
56453
+ background: oklch(0.72 0.23 54 / 0.13);
56454
+ }
56455
+
56456
+ .team-name { font-weight: 500; }
56457
+
56458
+ .team-role {
56459
+ font-size: 13px;
56460
+ color: oklch(0.56 0.02 228 / 0.67);
56461
+ text-transform: capitalize;
56462
+ }
56463
+ </style>
56464
+ </head>
56465
+ <body>
56466
+ <div class="container">
56467
+ <div class="logo">
56468
+ <svg width="108" height="32" viewBox="0 0 108 32" fill="none" xmlns="http://www.w3.org/2000/svg">
56469
+ <g clip-path="url(#clip0)">
56470
+ <path d="M4.5 27V20.0059C4.49955 18.6288 3.38499 17.5105 2.00781 17.5059L-0.00585938 17.5V14.5L2.00781 14.4941C3.38499 14.4895 4.49955 13.3712 4.5 11.9941V5C4.5 2.51472 6.51472 0.5 9 0.5H12V3.5H9C8.17157 3.5 7.5 4.17157 7.5 5V11.9941C7.49977 13.5757 6.82719 14.9966 5.75781 16C6.82719 17.0034 7.49977 18.4243 7.5 20.0059V27C7.5 27.8284 8.17157 28.5 9 28.5H12V31.5H9C6.51472 31.5 4.5 29.4853 4.5 27Z" fill="#FD7412"/>
56471
+ <path d="M103.5 27V20.0059C103.5 18.6288 104.615 17.5105 105.992 17.5059L108.006 17.5V14.5L105.992 14.4941C104.615 14.4895 103.5 13.3712 103.5 11.9941V5C103.5 2.51472 101.485 0.5 99 0.5H96V3.5H99C99.8284 3.5 100.5 4.17157 100.5 5V11.9941C100.5 13.5757 101.173 14.9966 102.242 16C101.173 17.0034 100.5 18.4243 100.5 20.0059V27C100.5 27.8284 99.8284 28.5 99 28.5H96V31.5H99C101.485 31.5 103.5 29.4853 103.5 27Z" fill="#FD7412"/>
56472
+ <path d="M85.2346 26.308C84.0026 26.308 82.92 26.0093 81.9866 25.412C81.0533 24.8147 80.3253 23.9653 79.8026 22.864C79.28 21.7627 79.0186 20.4373 79.0186 18.888C79.0186 17.3573 79.28 16.0413 79.8026 14.94C80.3253 13.8387 81.0533 12.9987 81.9866 12.42C82.92 11.8227 84.0026 11.524 85.2346 11.524C86.3733 11.524 87.3906 11.804 88.2866 12.364C89.2013 12.9053 89.7986 13.6427 90.0786 14.576H89.7706L90.1066 11.804H94.1666C94.1106 12.42 94.0546 13.0453 93.9986 13.68C93.9613 14.296 93.9426 14.9027 93.9426 15.5V26H89.7426L89.7146 23.34H90.0506C89.752 24.236 89.1546 24.9547 88.2586 25.496C87.3626 26.0373 86.3546 26.308 85.2346 26.308ZM86.5226 23.116C87.4933 23.116 88.2773 22.7707 88.8746 22.08C89.472 21.3893 89.7706 20.3253 89.7706 18.888C89.7706 17.4507 89.472 16.396 88.8746 15.724C88.2773 15.052 87.4933 14.716 86.5226 14.716C85.552 14.716 84.768 15.052 84.1706 15.724C83.5733 16.396 83.2746 17.4507 83.2746 18.888C83.2746 20.3253 83.564 21.3893 84.1426 22.08C84.74 22.7707 85.5333 23.116 86.5226 23.116Z" fill="#18181B"/>
56473
+ <path d="M70.1002 26.308C68.5882 26.308 67.2722 26.0093 66.1522 25.412C65.0509 24.796 64.1922 23.9373 63.5762 22.836C62.9789 21.7347 62.6802 20.4187 62.6802 18.888C62.6802 17.376 62.9789 16.0693 63.5762 14.968C64.1922 13.8667 65.0509 13.0173 66.1522 12.42C67.2722 11.8227 68.5882 11.524 70.1002 11.524C71.6122 11.524 72.9282 11.8227 74.0482 12.42C75.1682 13.0173 76.0269 13.8667 76.6242 14.968C77.2402 16.0693 77.5482 17.376 77.5482 18.888C77.5482 20.4187 77.2402 21.7347 76.6242 22.836C76.0269 23.9373 75.1682 24.796 74.0482 25.412C72.9282 26.0093 71.6122 26.308 70.1002 26.308ZM70.1002 23.116C71.0709 23.116 71.8362 22.7707 72.3962 22.08C72.9749 21.3893 73.2642 20.3253 73.2642 18.888C73.2642 17.4507 72.9749 16.396 72.3962 15.724C71.8362 15.052 71.0709 14.716 70.1002 14.716C69.1295 14.716 68.3549 15.052 67.7762 15.724C67.2162 16.396 66.9362 17.4507 66.9362 18.888C66.9362 20.3253 67.2162 21.3893 67.7762 22.08C68.3549 22.7707 69.1295 23.116 70.1002 23.116Z" fill="#18181B"/>
56474
+ <path d="M51.8208 26.308C50.5888 26.308 49.4968 26.0093 48.5448 25.412C47.6115 24.8147 46.8741 23.9653 46.3328 22.864C45.8101 21.7627 45.5488 20.4373 45.5488 18.888C45.5488 17.3573 45.8101 16.0413 46.3328 14.94C46.8555 13.8387 47.5928 12.9987 48.5448 12.42C49.4968 11.8227 50.5888 11.524 51.8208 11.524C52.9408 11.524 53.9395 11.7947 54.8168 12.336C55.7128 12.8587 56.3101 13.568 56.6088 14.464H56.2448V5.392H60.4728V26H56.3008V23.228H56.6648C56.3661 24.1613 55.7688 24.908 54.8728 25.468C53.9768 26.028 52.9595 26.308 51.8208 26.308ZM53.0808 23.116C54.0515 23.116 54.8355 22.7707 55.4328 22.08C56.0301 21.3893 56.3288 20.3253 56.3288 18.888C56.3288 17.4507 56.0301 16.396 55.4328 15.724C54.8355 15.052 54.0515 14.716 53.0808 14.716C52.1101 14.716 51.3168 15.052 50.7008 15.724C50.1035 16.396 49.8048 17.4507 49.8048 18.888C49.8048 20.3253 50.1035 21.3893 50.7008 22.08C51.3168 22.7707 52.1101 23.116 53.0808 23.116Z" fill="#18181B"/>
56475
+ <path d="M34.6334 26.308C33.4014 26.308 32.3187 26.0093 31.3854 25.412C30.4521 24.8147 29.7241 23.9653 29.2014 22.864C28.6787 21.7627 28.4174 20.4373 28.4174 18.888C28.4174 17.3573 28.6787 16.0413 29.2014 14.94C29.7241 13.8387 30.4521 12.9987 31.3854 12.42C32.3187 11.8227 33.4014 11.524 34.6334 11.524C35.7721 11.524 36.7894 11.804 37.6854 12.364C38.6001 12.9053 39.1974 13.6427 39.4774 14.576H39.1694L39.5054 11.804H43.5654C43.5094 12.42 43.4534 13.0453 43.3974 13.68C43.3601 14.296 43.3414 14.9027 43.3414 15.5V26H39.1414L39.1134 23.34H39.4494C39.1507 24.236 38.5534 24.9547 37.6574 25.496C36.7614 26.0373 35.7534 26.308 34.6334 26.308ZM35.9214 23.116C36.8921 23.116 37.6761 22.7707 38.2734 22.08C38.8707 21.3893 39.1694 20.3253 39.1694 18.888C39.1694 17.4507 38.8707 16.396 38.2734 15.724C37.6761 15.052 36.8921 14.716 35.9214 14.716C34.9507 14.716 34.1667 15.052 33.5694 15.724C32.9721 16.396 32.6734 17.4507 32.6734 18.888C32.6734 20.3253 32.9627 21.3893 33.5414 22.08C34.1387 22.7707 34.9321 23.116 35.9214 23.116Z" fill="#18181B"/>
56476
+ <path d="M13.736 26V5.392H17.964V17.712H18.02L23.284 11.804H28.324L21.52 19.364V17.824L28.688 26H23.508L18.02 19.84H17.964V26H13.736Z" fill="#18181B"/>
56477
+ </g>
56478
+ <defs><clipPath id="clip0"><rect width="108" height="32" fill="white"/></clipPath></defs>
56479
+ </svg>
56480
+ </div>
56481
+ <h1>Select a team</h1>
56482
+ <p class="subtitle">Choose which team to connect with this MCP session</p>
56483
+ <form method="POST" action="/team-select">
56484
+ <input type="hidden" name="token" value="${selectionToken}" />
56485
+ ${teamButtons}
56486
+ </form>
56487
+ </div>
56488
+ </body>
56489
+ </html>`;
56490
+ }
56491
+ function renderLoginPage(state, error48) {
56492
+ const errorHtml = error48 ? `<div class="error">${escapeHtml(error48)}</div>` : "";
56493
+ return `<!DOCTYPE html>
56494
+ <html lang="en">
56495
+ <head>
56496
+ <meta charset="utf-8" />
56497
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
56498
+ <title>Sign In - Kadoa</title>
56499
+ <style>
56500
+ * { margin: 0; padding: 0; box-sizing: border-box; }
56501
+
56502
+ body {
56503
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
56504
+ background: hsl(0 0% 98%);
56505
+ color: #18181b;
56506
+ min-height: 100dvh;
56507
+ display: flex;
56508
+ align-items: center;
56509
+ justify-content: center;
56510
+ background-image: radial-gradient(circle, #d4d4d8 1px, transparent 1px);
56511
+ background-size: 24px 24px;
56512
+ background-position: center top;
56513
+ }
56514
+
56515
+ .card {
56516
+ width: 100%;
56517
+ max-width: 460px;
56518
+ background: #fff;
56519
+ padding: 1rem;
56520
+ display: flex;
56521
+ flex-direction: column;
56522
+ gap: 1rem;
56523
+ min-height: 100dvh;
56524
+ }
56525
+
56526
+ @media (min-width: 768px) {
56527
+ .card { padding: 3rem; min-height: auto; border-left: 1px solid #e0e1e5; border-right: 1px solid #e0e1e5; }
56528
+ }
56529
+
56530
+ .logo { display: grid; place-content: center; }
56531
+
56532
+ h1 {
56533
+ font-size: 20px;
56534
+ font-weight: 600;
56535
+ text-align: center;
56536
+ color: #18181b;
56537
+ }
56538
+
56539
+ .spacer { height: 0; }
56540
+ @media (min-width: 768px) { .spacer { height: 3rem; } }
56541
+
56542
+ .error {
56543
+ background: #fef2f2;
56544
+ color: #991b1b;
56545
+ border: 1px solid #fecaca;
56546
+ border-radius: 4px;
56547
+ padding: 0.6rem 0.875rem;
56548
+ font-size: 15px;
56549
+ }
56550
+
56551
+ /* Buttons — matching KUI default + primary looks */
56552
+ .btn {
56553
+ width: 100%;
56554
+ padding: 0.6em 1em;
56555
+ border-radius: 4px;
56556
+ font-size: 16px;
56557
+ font-weight: 500;
56558
+ cursor: pointer;
56559
+ display: flex;
56560
+ align-items: center;
56561
+ justify-content: center;
56562
+ gap: 0.5rem;
56563
+ transition: background 0.15s, border-color 0.15s;
56564
+ text-decoration: none;
56565
+ }
56566
+
56567
+ .btn-default {
56568
+ background: #fff;
56569
+ color: #18181b;
56570
+ border: 1px solid #d4d4d8;
56571
+ box-shadow: inset 0 -3px 0 0 rgba(0,0,0,0.03), 0 1px 0px 1px rgba(255,255,255,0.5), 0 -1px 0px 1px rgba(0,0,0,0.02);
56572
+ }
56573
+
56574
+ .btn-default:hover {
56575
+ background: rgba(113,113,122,0.1);
56576
+ }
56577
+
56578
+ .btn-primary {
56579
+ background: hsl(212 70% 27%);
56580
+ color: #fff;
56581
+ border: 1px solid hsl(214 70% 23%);
56582
+ box-shadow: inset 0 2px 0 0 rgba(56,189,248,0.2), 0 -1px 0px 1px rgba(0,0,0,0.02);
56583
+ }
56584
+
56585
+ .btn-primary:hover {
56586
+ background: hsl(212 70% 33%);
56587
+ }
56588
+
56589
+ /* OR divider */
56590
+ .line-or {
56591
+ display: flex;
56592
+ align-items: center;
56593
+ gap: 0.5rem;
56594
+ font-weight: 500;
56595
+ color: rgba(24,24,27,0.6);
56596
+ font-size: 14px;
56597
+ margin: 0.5rem 0;
56598
+ }
56599
+
56600
+ .line-or hr {
56601
+ flex: 1;
56602
+ border: none;
56603
+ border-top: 1px solid rgba(113,113,122,0.15);
56604
+ }
56605
+
56606
+ /* Form inputs — matching KUI input style */
56607
+ label {
56608
+ display: block;
56609
+ font-size: 16px;
56610
+ font-weight: 500;
56611
+ margin-bottom: 0.25rem;
56612
+ color: #18181b;
56613
+ }
56614
+
56615
+ input[type="email"], input[type="password"] {
56616
+ width: 100%;
56617
+ padding: 0.35em 0.5em;
56618
+ border: 1px solid #d4d4d8;
56619
+ border-radius: 4px;
56620
+ font-size: 18px;
56621
+ font-family: inherit;
56622
+ color: #18181b;
56623
+ background: #fff;
56624
+ outline: none;
56625
+ box-shadow: inset 0 3px 0 0 rgba(0,0,0,0.025);
56626
+ transition: border-color 0.15s;
56627
+ caret-color: hsl(25 98% 53%);
56628
+ }
56629
+
56630
+ input[type="email"]:hover, input[type="password"]:hover {
56631
+ border-color: hsl(31 99% 72%);
56632
+ }
56633
+
56634
+ input[type="email"]:focus, input[type="password"]:focus {
56635
+ border-color: hsl(25 98% 53%);
56636
+ box-shadow: inset 0 3px 0 0 rgba(0,0,0,0.025), 0 0 0 2px rgba(249,115,22,0.2);
56637
+ }
56638
+
56639
+ .field { margin-bottom: 0.75rem; }
56640
+
56641
+ hr.separator {
56642
+ border: none;
56643
+ border-top: 1px solid rgba(113,113,122,0.15);
56644
+ margin: 0.5rem 0;
56645
+ }
56646
+
56647
+ .google-icon { width: 18px; height: 18px; }
56648
+ .key-icon { width: 16px; height: 16px; }
56649
+
56650
+ /* Tabs for email/SSO — keep simple, same visual weight */
56651
+ .tabs {
56652
+ display: none;
56653
+ }
56654
+
56655
+ .tab-content { display: none; }
56656
+ .tab-content.active { display: block; }
56657
+
56658
+ .tab-switch {
56659
+ text-align: center;
56660
+ margin-top: 0.25rem;
56661
+ }
56662
+
56663
+ .tab-switch a {
56664
+ font-size: 15px;
56665
+ color: #18181b;
56666
+ text-decoration: underline;
56667
+ text-decoration-color: rgba(251,146,60,0.5);
56668
+ text-underline-offset: 2px;
56669
+ cursor: pointer;
56670
+ }
56671
+
56672
+ .tab-switch a:hover {
56673
+ background: rgba(251,146,60,0.1);
56674
+ border-radius: 2px;
56675
+ }
56676
+ </style>
56677
+ </head>
56678
+ <body>
56679
+ <div class="card">
56680
+ <!-- Logo {k} -->
56681
+ <div class="logo">
56682
+ <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
56683
+ <path opacity="0.15" d="M25.3196 6.25H14.6804C14.6804 7.49264 13.6596 8.5 12.4005 8.5C11.3808 8.5 10.8312 8.67478 10.5466 8.82497C10.3001 8.95506 10.147 9.11941 10.0189 9.38005C9.85482 9.7141 9.74438 10.1712 9.68281 10.8152C9.62136 11.458 9.61405 12.2133 9.61405 13.125L9.61416 13.3731C9.61532 14.9118 9.61694 17.0733 8.75235 18.8332C8.55109 19.2428 8.30266 19.6357 8 20C8.30266 20.3643 8.55109 20.7572 8.75235 21.1668C9.61694 22.9267 9.61532 25.0882 9.61416 26.6269L9.61405 26.875C9.61405 27.7867 9.62136 28.542 9.68281 29.1848C9.74438 29.8288 9.85482 30.2859 10.0189 30.6199C10.147 30.8806 10.3001 31.0449 10.5466 31.175C10.8312 31.3252 11.3808 31.5 12.4005 31.5C13.6596 31.5 14.6804 32.5074 14.6804 33.75H25.3196C25.3196 32.5074 26.3404 31.5 27.5995 31.5C28.6192 31.5 29.1688 31.3252 29.4534 31.175C29.6999 31.0449 29.853 30.8806 29.9811 30.6199C30.1452 30.2859 30.2556 29.8288 30.3172 29.1848C30.3786 28.542 30.386 27.7867 30.386 26.875L30.3858 26.6269C30.3847 25.0882 30.3831 22.9267 31.2477 21.1668C31.4489 20.7572 31.6973 20.3643 32 20C31.6973 19.6357 31.4489 19.2428 31.2477 18.8332C30.3831 17.0733 30.3847 14.9118 30.3858 13.3731L30.386 13.125C30.386 12.2133 30.3786 11.458 30.3172 10.8152C30.2556 10.1712 30.1452 9.7141 29.9811 9.38005C29.853 9.11941 29.6999 8.95506 29.4534 8.82497C29.1688 8.67478 28.6192 8.5 27.5995 8.5C26.3404 8.5 25.3196 7.49264 25.3196 6.25Z" fill="#fd7412"/>
56684
+ <path d="M12.5 6.25C2.5 6.25 12.5 20 2.5 20C12.5 20 2.5 33.75 12.5 33.75" stroke="#fd7412" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/>
56685
+ <path d="M16 10V29" stroke="#18181B" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/>
56686
+ <path d="M27.5 6.25C37.5 6.25 27.5 20 37.5 20C27.5 20 37.5 33.75 27.5 33.75" stroke="#fd7412" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/>
56687
+ <path d="M16 23L25 18" stroke="#18181B" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/>
56688
+ <path d="M25 29L16 23" stroke="#18181B" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8"/>
56689
+ </svg>
56690
+ </div>
56691
+
56692
+ <!-- Heading -->
56693
+ <h1>Sign in to Kadoa</h1>
56694
+
56695
+ <div class="spacer"></div>
56696
+
56697
+ ${errorHtml}
56698
+
56699
+ <!-- Continue with Google -->
56700
+ <form method="POST" action="/auth/google">
56701
+ <input type="hidden" name="state" value="${escapeHtml(state)}" />
56702
+ <button type="submit" class="btn btn-default">
56703
+ <svg class="google-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
56704
+ <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/>
56705
+ <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
56706
+ <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/>
56707
+ <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
56708
+ </svg>
56709
+ Continue with Google
56710
+ </button>
56711
+ </form>
56712
+
56713
+ <!-- Continue with SSO -->
56714
+ <div id="sso-button-wrapper">
56715
+ <form method="POST" action="/auth/sso" id="sso-direct-form" style="display:none">
56716
+ <input type="hidden" name="state" value="${escapeHtml(state)}" />
56717
+ <input type="hidden" name="email" id="sso-email-hidden" />
56718
+ </form>
56719
+ <button type="button" class="btn btn-default" id="sso-toggle-btn">
56720
+ <svg class="key-icon" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
56721
+ <path d="M10 1a5 5 0 0 0-4.546 7.066l-4.161 4.16a.5.5 0 0 0-.146.354V14.5a.5.5 0 0 0 .5.5h2a.5.5 0 0 0 .5-.5V14h1a.5.5 0 0 0 .5-.5v-1h1a.5.5 0 0 0 .354-.146l.94-.94A5 5 0 1 0 10 1zm1.5 4a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3z" fill="currentColor"/>
56722
+ </svg>
56723
+ Continue with SSO
56724
+ </button>
56725
+ </div>
56726
+
56727
+ <!-- OR divider -->
56728
+ <div class="line-or">
56729
+ <hr />
56730
+ OR
56731
+ <hr />
56732
+ </div>
56733
+
56734
+ <!-- Email + Password form -->
56735
+ <div class="tab-content active" id="tab-email">
56736
+ <form method="POST" action="/auth/login">
56737
+ <input type="hidden" name="state" value="${escapeHtml(state)}" />
56738
+ <div class="field">
56739
+ <label for="email">Sign in with email:</label>
56740
+ <input type="email" id="email" name="email" required autocomplete="email" />
56741
+ </div>
56742
+ <div class="field">
56743
+ <label for="password">Your password:</label>
56744
+ <input type="password" id="password" name="password" required autocomplete="current-password" />
56745
+ </div>
56746
+ <button type="submit" class="btn btn-primary">Continue</button>
56747
+ </form>
56748
+ </div>
56749
+
56750
+ <!-- SSO form (shown when "Continue with SSO" is clicked) -->
56751
+ <div class="tab-content" id="tab-sso">
56752
+ <form method="POST" action="/auth/sso">
56753
+ <input type="hidden" name="state" value="${escapeHtml(state)}" />
56754
+ <div class="field">
56755
+ <label for="sso-email">Work email:</label>
56756
+ <input type="email" id="sso-email" name="email" required autocomplete="email" />
56757
+ </div>
56758
+ <button type="submit" class="btn btn-primary">Continue with SSO</button>
56759
+ </form>
56760
+ <div class="tab-switch">
56761
+ <a id="back-to-email">Sign in with email instead</a>
56762
+ </div>
56763
+ </div>
56764
+
56765
+ <div style="flex:1"></div>
56766
+
56767
+ <script>
56768
+ var ssoBtn = document.getElementById('sso-toggle-btn');
56769
+ var tabEmail = document.getElementById('tab-email');
56770
+ var tabSso = document.getElementById('tab-sso');
56771
+ var ssoWrapper = document.getElementById('sso-button-wrapper');
56772
+ var lineOr = document.querySelector('.line-or');
56773
+ var backLink = document.getElementById('back-to-email');
56774
+
56775
+ ssoBtn.addEventListener('click', function() {
56776
+ tabEmail.classList.remove('active');
56777
+ tabSso.classList.add('active');
56778
+ ssoWrapper.style.display = 'none';
56779
+ lineOr.style.display = 'none';
56780
+ document.getElementById('sso-email').focus();
56781
+ });
56782
+
56783
+ backLink.addEventListener('click', function() {
56784
+ tabSso.classList.remove('active');
56785
+ tabEmail.classList.add('active');
56786
+ ssoWrapper.style.display = '';
56787
+ lineOr.style.display = '';
56788
+ });
56789
+ </script>
56790
+ </div>
56791
+ </body>
56792
+ </html>`;
56793
+ }
56794
+ function escapeHtml(str) {
56795
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
56796
+ }
56797
+ var TEAM_SELECTION_TTL, ACCESS_TOKEN_TTL;
55790
56798
  var init_auth2 = __esm(() => {
55791
56799
  init_errors4();
56800
+ TEAM_SELECTION_TTL = 10 * 60 * 1000;
55792
56801
  ACCESS_TOKEN_TTL = 7 * 24 * 3600;
55793
56802
  });
55794
56803
 
@@ -55893,6 +56902,7 @@ var exports_http = {};
55893
56902
  __export(exports_http, {
55894
56903
  startHttpServer: () => startHttpServer
55895
56904
  });
56905
+ import express8 from "express";
55896
56906
  function jwtClaims2(jwt2) {
55897
56907
  try {
55898
56908
  return JSON.parse(Buffer.from(jwt2.split(".")[1], "base64url").toString());
@@ -55949,6 +56959,18 @@ async function startHttpServer(options) {
55949
56959
  app.get("/auth/callback", (req, res) => {
55950
56960
  provider.handleAuthCallback(req, res);
55951
56961
  });
56962
+ app.post("/auth/google", express8.urlencoded({ extended: false }), (req, res) => {
56963
+ provider.handleGoogleLogin(req, res);
56964
+ });
56965
+ app.post("/auth/login", express8.urlencoded({ extended: false }), (req, res) => {
56966
+ provider.handleEmailPasswordLogin(req, res);
56967
+ });
56968
+ app.post("/auth/sso", express8.urlencoded({ extended: false }), (req, res) => {
56969
+ provider.handleSSOLogin(req, res);
56970
+ });
56971
+ app.post("/team-select", express8.urlencoded({ extended: false }), (req, res) => {
56972
+ provider.handleTeamSelection(req, res);
56973
+ });
55952
56974
  app.get("/health", (_req, res) => {
55953
56975
  res.json({
55954
56976
  status: "ok",