@sinch/functions-runtime 0.6.1 → 0.6.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.
@@ -15630,11 +15630,11 @@ var require_mime_types = __commonJS({
15630
15630
  }
15631
15631
  return exts[0];
15632
15632
  }
15633
- function lookup(path6) {
15634
- if (!path6 || typeof path6 !== "string") {
15633
+ function lookup(path7) {
15634
+ if (!path7 || typeof path7 !== "string") {
15635
15635
  return false;
15636
15636
  }
15637
- var extension2 = extname("x." + path6).toLowerCase().slice(1);
15637
+ var extension2 = extname("x." + path7).toLowerCase().slice(1);
15638
15638
  if (!extension2) {
15639
15639
  return false;
15640
15640
  }
@@ -19077,13 +19077,13 @@ var require_view = __commonJS({
19077
19077
  "../../node_modules/express/lib/view.js"(exports, module) {
19078
19078
  "use strict";
19079
19079
  var debug = require_src()("express:view");
19080
- var path6 = __require("path");
19081
- var fs5 = __require("fs");
19082
- var dirname2 = path6.dirname;
19083
- var basename2 = path6.basename;
19084
- var extname = path6.extname;
19085
- var join3 = path6.join;
19086
- var resolve = path6.resolve;
19080
+ var path7 = __require("path");
19081
+ var fs6 = __require("fs");
19082
+ var dirname2 = path7.dirname;
19083
+ var basename2 = path7.basename;
19084
+ var extname = path7.extname;
19085
+ var join3 = path7.join;
19086
+ var resolve = path7.resolve;
19087
19087
  module.exports = View;
19088
19088
  function View(name, options) {
19089
19089
  var opts = options || {};
@@ -19112,17 +19112,17 @@ var require_view = __commonJS({
19112
19112
  this.path = this.lookup(fileName);
19113
19113
  }
19114
19114
  View.prototype.lookup = function lookup(name) {
19115
- var path7;
19115
+ var path8;
19116
19116
  var roots = [].concat(this.root);
19117
19117
  debug('lookup "%s"', name);
19118
- for (var i = 0; i < roots.length && !path7; i++) {
19118
+ for (var i = 0; i < roots.length && !path8; i++) {
19119
19119
  var root = roots[i];
19120
19120
  var loc = resolve(root, name);
19121
19121
  var dir = dirname2(loc);
19122
19122
  var file = basename2(loc);
19123
- path7 = this.resolve(dir, file);
19123
+ path8 = this.resolve(dir, file);
19124
19124
  }
19125
- return path7;
19125
+ return path8;
19126
19126
  };
19127
19127
  View.prototype.render = function render(options, callback) {
19128
19128
  var sync = true;
@@ -19144,21 +19144,21 @@ var require_view = __commonJS({
19144
19144
  };
19145
19145
  View.prototype.resolve = function resolve2(dir, file) {
19146
19146
  var ext = this.ext;
19147
- var path7 = join3(dir, file);
19148
- var stat = tryStat(path7);
19147
+ var path8 = join3(dir, file);
19148
+ var stat = tryStat(path8);
19149
19149
  if (stat && stat.isFile()) {
19150
- return path7;
19150
+ return path8;
19151
19151
  }
19152
- path7 = join3(dir, basename2(file, ext), "index" + ext);
19153
- stat = tryStat(path7);
19152
+ path8 = join3(dir, basename2(file, ext), "index" + ext);
19153
+ stat = tryStat(path8);
19154
19154
  if (stat && stat.isFile()) {
19155
- return path7;
19155
+ return path8;
19156
19156
  }
19157
19157
  };
19158
- function tryStat(path7) {
19159
- debug('stat "%s"', path7);
19158
+ function tryStat(path8) {
19159
+ debug('stat "%s"', path8);
19160
19160
  try {
19161
- return fs5.statSync(path7);
19161
+ return fs6.statSync(path8);
19162
19162
  } catch (e) {
19163
19163
  return void 0;
19164
19164
  }
@@ -19310,11 +19310,11 @@ var require_mime_types2 = __commonJS({
19310
19310
  }
19311
19311
  return exts[0];
19312
19312
  }
19313
- function lookup(path6) {
19314
- if (!path6 || typeof path6 !== "string") {
19313
+ function lookup(path7) {
19314
+ if (!path7 || typeof path7 !== "string") {
19315
19315
  return false;
19316
19316
  }
19317
- var extension2 = extname("x." + path6).toLowerCase().slice(1);
19317
+ var extension2 = extname("x." + path7).toLowerCase().slice(1);
19318
19318
  if (!extension2) {
19319
19319
  return false;
19320
19320
  }
@@ -20511,15 +20511,15 @@ var require_dist = __commonJS({
20511
20511
  if (token.type === endType)
20512
20512
  break;
20513
20513
  if (token.type === "char" || token.type === "escape") {
20514
- let path6 = token.value;
20514
+ let path7 = token.value;
20515
20515
  let cur = tokens[pos];
20516
20516
  while (cur.type === "char" || cur.type === "escape") {
20517
- path6 += cur.value;
20517
+ path7 += cur.value;
20518
20518
  cur = tokens[++pos];
20519
20519
  }
20520
20520
  output.push({
20521
20521
  type: "text",
20522
- value: encodePath(path6)
20522
+ value: encodePath(path7)
20523
20523
  });
20524
20524
  continue;
20525
20525
  }
@@ -20543,16 +20543,16 @@ var require_dist = __commonJS({
20543
20543
  }
20544
20544
  return new TokenData(consumeUntil("end"), str);
20545
20545
  }
20546
- function compile(path6, options = {}) {
20546
+ function compile(path7, options = {}) {
20547
20547
  const { encode: encode3 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
20548
- const data = typeof path6 === "object" ? path6 : parse2(path6, options);
20548
+ const data = typeof path7 === "object" ? path7 : parse2(path7, options);
20549
20549
  const fn = tokensToFunction(data.tokens, delimiter, encode3);
20550
- return function path7(params = {}) {
20551
- const [path8, ...missing] = fn(params);
20550
+ return function path8(params = {}) {
20551
+ const [path9, ...missing] = fn(params);
20552
20552
  if (missing.length) {
20553
20553
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
20554
20554
  }
20555
- return path8;
20555
+ return path9;
20556
20556
  };
20557
20557
  }
20558
20558
  function tokensToFunction(tokens, delimiter, encode3) {
@@ -20608,9 +20608,9 @@ var require_dist = __commonJS({
20608
20608
  return [encodeValue(value)];
20609
20609
  };
20610
20610
  }
20611
- function match(path6, options = {}) {
20611
+ function match(path7, options = {}) {
20612
20612
  const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
20613
- const { regexp, keys } = pathToRegexp(path6, options);
20613
+ const { regexp, keys } = pathToRegexp(path7, options);
20614
20614
  const decoders = keys.map((key) => {
20615
20615
  if (decode === false)
20616
20616
  return NOOP_VALUE;
@@ -20622,7 +20622,7 @@ var require_dist = __commonJS({
20622
20622
  const m = regexp.exec(input);
20623
20623
  if (!m)
20624
20624
  return false;
20625
- const path7 = m[0];
20625
+ const path8 = m[0];
20626
20626
  const params = /* @__PURE__ */ Object.create(null);
20627
20627
  for (let i = 1; i < m.length; i++) {
20628
20628
  if (m[i] === void 0)
@@ -20631,15 +20631,15 @@ var require_dist = __commonJS({
20631
20631
  const decoder = decoders[i - 1];
20632
20632
  params[key.name] = decoder(m[i]);
20633
20633
  }
20634
- return { path: path7, params };
20634
+ return { path: path8, params };
20635
20635
  };
20636
20636
  }
20637
- function pathToRegexp(path6, options = {}) {
20637
+ function pathToRegexp(path7, options = {}) {
20638
20638
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
20639
20639
  const keys = [];
20640
20640
  const flags = sensitive ? "" : "i";
20641
20641
  const sources = [];
20642
- for (const input of pathsToArray(path6, [])) {
20642
+ for (const input of pathsToArray(path7, [])) {
20643
20643
  const data = typeof input === "object" ? input : parse2(input, options);
20644
20644
  for (const tokens of flatten(data.tokens, 0, [])) {
20645
20645
  sources.push(toRegExpSource(tokens, delimiter, keys, data.originalPath));
@@ -20769,18 +20769,18 @@ var require_layer = __commonJS({
20769
20769
  var TRAILING_SLASH_REGEXP = /\/+$/;
20770
20770
  var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
20771
20771
  module.exports = Layer;
20772
- function Layer(path6, options, fn) {
20772
+ function Layer(path7, options, fn) {
20773
20773
  if (!(this instanceof Layer)) {
20774
- return new Layer(path6, options, fn);
20774
+ return new Layer(path7, options, fn);
20775
20775
  }
20776
- debug("new %o", path6);
20776
+ debug("new %o", path7);
20777
20777
  const opts = options || {};
20778
20778
  this.handle = fn;
20779
20779
  this.keys = [];
20780
20780
  this.name = fn.name || "<anonymous>";
20781
20781
  this.params = void 0;
20782
20782
  this.path = void 0;
20783
- this.slash = path6 === "/" && opts.end === false;
20783
+ this.slash = path7 === "/" && opts.end === false;
20784
20784
  function matcher(_path) {
20785
20785
  if (_path instanceof RegExp) {
20786
20786
  const keys = [];
@@ -20819,7 +20819,7 @@ var require_layer = __commonJS({
20819
20819
  decode: decodeParam
20820
20820
  });
20821
20821
  }
20822
- this.matchers = Array.isArray(path6) ? path6.map(matcher) : [matcher(path6)];
20822
+ this.matchers = Array.isArray(path7) ? path7.map(matcher) : [matcher(path7)];
20823
20823
  }
20824
20824
  Layer.prototype.handleError = function handleError(error, req, res, next) {
20825
20825
  const fn = this.handle;
@@ -20859,9 +20859,9 @@ var require_layer = __commonJS({
20859
20859
  next(err);
20860
20860
  }
20861
20861
  };
20862
- Layer.prototype.match = function match(path6) {
20862
+ Layer.prototype.match = function match(path7) {
20863
20863
  let match2;
20864
- if (path6 != null) {
20864
+ if (path7 != null) {
20865
20865
  if (this.slash) {
20866
20866
  this.params = {};
20867
20867
  this.path = "";
@@ -20869,7 +20869,7 @@ var require_layer = __commonJS({
20869
20869
  }
20870
20870
  let i = 0;
20871
20871
  while (!match2 && i < this.matchers.length) {
20872
- match2 = this.matchers[i](path6);
20872
+ match2 = this.matchers[i](path7);
20873
20873
  i++;
20874
20874
  }
20875
20875
  }
@@ -20897,13 +20897,13 @@ var require_layer = __commonJS({
20897
20897
  throw err;
20898
20898
  }
20899
20899
  }
20900
- function loosen(path6) {
20901
- if (path6 instanceof RegExp || path6 === "/") {
20902
- return path6;
20900
+ function loosen(path7) {
20901
+ if (path7 instanceof RegExp || path7 === "/") {
20902
+ return path7;
20903
20903
  }
20904
- return Array.isArray(path6) ? path6.map(function(p) {
20904
+ return Array.isArray(path7) ? path7.map(function(p) {
20905
20905
  return loosen(p);
20906
- }) : String(path6).replace(TRAILING_SLASH_REGEXP, "");
20906
+ }) : String(path7).replace(TRAILING_SLASH_REGEXP, "");
20907
20907
  }
20908
20908
  }
20909
20909
  });
@@ -20919,9 +20919,9 @@ var require_route = __commonJS({
20919
20919
  var flatten = Array.prototype.flat;
20920
20920
  var methods = METHODS.map((method) => method.toLowerCase());
20921
20921
  module.exports = Route;
20922
- function Route(path6) {
20923
- debug("new %o", path6);
20924
- this.path = path6;
20922
+ function Route(path7) {
20923
+ debug("new %o", path7);
20924
+ this.path = path7;
20925
20925
  this.stack = [];
20926
20926
  this.methods = /* @__PURE__ */ Object.create(null);
20927
20927
  }
@@ -21129,8 +21129,8 @@ var require_router = __commonJS({
21129
21129
  if (++sync > 100) {
21130
21130
  return setImmediate(next, err);
21131
21131
  }
21132
- const path6 = getPathname(req);
21133
- if (path6 == null) {
21132
+ const path7 = getPathname(req);
21133
+ if (path7 == null) {
21134
21134
  return done(layerError);
21135
21135
  }
21136
21136
  let layer;
@@ -21138,7 +21138,7 @@ var require_router = __commonJS({
21138
21138
  let route;
21139
21139
  while (match !== true && idx < stack.length) {
21140
21140
  layer = stack[idx++];
21141
- match = matchLayer(layer, path6);
21141
+ match = matchLayer(layer, path7);
21142
21142
  route = layer.route;
21143
21143
  if (typeof match !== "boolean") {
21144
21144
  layerError = layerError || match;
@@ -21176,18 +21176,18 @@ var require_router = __commonJS({
21176
21176
  } else if (route) {
21177
21177
  layer.handleRequest(req, res, next);
21178
21178
  } else {
21179
- trimPrefix(layer, layerError, layerPath, path6);
21179
+ trimPrefix(layer, layerError, layerPath, path7);
21180
21180
  }
21181
21181
  sync = 0;
21182
21182
  });
21183
21183
  }
21184
- function trimPrefix(layer, layerError, layerPath, path6) {
21184
+ function trimPrefix(layer, layerError, layerPath, path7) {
21185
21185
  if (layerPath.length !== 0) {
21186
- if (layerPath !== path6.substring(0, layerPath.length)) {
21186
+ if (layerPath !== path7.substring(0, layerPath.length)) {
21187
21187
  next(layerError);
21188
21188
  return;
21189
21189
  }
21190
- const c = path6[layerPath.length];
21190
+ const c = path7[layerPath.length];
21191
21191
  if (c && c !== "/") {
21192
21192
  next(layerError);
21193
21193
  return;
@@ -21211,7 +21211,7 @@ var require_router = __commonJS({
21211
21211
  };
21212
21212
  Router.prototype.use = function use(handler) {
21213
21213
  let offset = 0;
21214
- let path6 = "/";
21214
+ let path7 = "/";
21215
21215
  if (typeof handler !== "function") {
21216
21216
  let arg = handler;
21217
21217
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -21219,7 +21219,7 @@ var require_router = __commonJS({
21219
21219
  }
21220
21220
  if (typeof arg !== "function") {
21221
21221
  offset = 1;
21222
- path6 = handler;
21222
+ path7 = handler;
21223
21223
  }
21224
21224
  }
21225
21225
  const callbacks = flatten.call(slice.call(arguments, offset), Infinity);
@@ -21231,8 +21231,8 @@ var require_router = __commonJS({
21231
21231
  if (typeof fn !== "function") {
21232
21232
  throw new TypeError("argument handler must be a function");
21233
21233
  }
21234
- debug("use %o %s", path6, fn.name || "<anonymous>");
21235
- const layer = new Layer(path6, {
21234
+ debug("use %o %s", path7, fn.name || "<anonymous>");
21235
+ const layer = new Layer(path7, {
21236
21236
  sensitive: this.caseSensitive,
21237
21237
  strict: false,
21238
21238
  end: false
@@ -21242,9 +21242,9 @@ var require_router = __commonJS({
21242
21242
  }
21243
21243
  return this;
21244
21244
  };
21245
- Router.prototype.route = function route(path6) {
21246
- const route2 = new Route(path6);
21247
- const layer = new Layer(path6, {
21245
+ Router.prototype.route = function route(path7) {
21246
+ const route2 = new Route(path7);
21247
+ const layer = new Layer(path7, {
21248
21248
  sensitive: this.caseSensitive,
21249
21249
  strict: this.strict,
21250
21250
  end: true
@@ -21257,8 +21257,8 @@ var require_router = __commonJS({
21257
21257
  return route2;
21258
21258
  };
21259
21259
  methods.concat("all").forEach(function(method) {
21260
- Router.prototype[method] = function(path6) {
21261
- const route = this.route(path6);
21260
+ Router.prototype[method] = function(path7) {
21261
+ const route = this.route(path7);
21262
21262
  route[method].apply(route, slice.call(arguments, 1));
21263
21263
  return this;
21264
21264
  };
@@ -21287,9 +21287,9 @@ var require_router = __commonJS({
21287
21287
  const fqdnIndex = url2.substring(0, pathLength).indexOf("://");
21288
21288
  return fqdnIndex !== -1 ? url2.substring(0, url2.indexOf("/", 3 + fqdnIndex)) : void 0;
21289
21289
  }
21290
- function matchLayer(layer, path6) {
21290
+ function matchLayer(layer, path7) {
21291
21291
  try {
21292
- return layer.match(path6);
21292
+ return layer.match(path7);
21293
21293
  } catch (err) {
21294
21294
  return err;
21295
21295
  }
@@ -21517,7 +21517,7 @@ var require_application = __commonJS({
21517
21517
  };
21518
21518
  app.use = function use(fn) {
21519
21519
  var offset = 0;
21520
- var path6 = "/";
21520
+ var path7 = "/";
21521
21521
  if (typeof fn !== "function") {
21522
21522
  var arg = fn;
21523
21523
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -21525,7 +21525,7 @@ var require_application = __commonJS({
21525
21525
  }
21526
21526
  if (typeof arg !== "function") {
21527
21527
  offset = 1;
21528
- path6 = fn;
21528
+ path7 = fn;
21529
21529
  }
21530
21530
  }
21531
21531
  var fns = flatten.call(slice.call(arguments, offset), Infinity);
@@ -21535,12 +21535,12 @@ var require_application = __commonJS({
21535
21535
  var router = this.router;
21536
21536
  fns.forEach(function(fn2) {
21537
21537
  if (!fn2 || !fn2.handle || !fn2.set) {
21538
- return router.use(path6, fn2);
21538
+ return router.use(path7, fn2);
21539
21539
  }
21540
- debug(".use app under %s", path6);
21541
- fn2.mountpath = path6;
21540
+ debug(".use app under %s", path7);
21541
+ fn2.mountpath = path7;
21542
21542
  fn2.parent = this;
21543
- router.use(path6, function mounted_app(req, res, next) {
21543
+ router.use(path7, function mounted_app(req, res, next) {
21544
21544
  var orig = req.app;
21545
21545
  fn2.handle(req, res, function(err) {
21546
21546
  Object.setPrototypeOf(req, orig.request);
@@ -21552,8 +21552,8 @@ var require_application = __commonJS({
21552
21552
  }, this);
21553
21553
  return this;
21554
21554
  };
21555
- app.route = function route(path6) {
21556
- return this.router.route(path6);
21555
+ app.route = function route(path7) {
21556
+ return this.router.route(path7);
21557
21557
  };
21558
21558
  app.engine = function engine(ext, fn) {
21559
21559
  if (typeof fn !== "function") {
@@ -21596,7 +21596,7 @@ var require_application = __commonJS({
21596
21596
  }
21597
21597
  return this;
21598
21598
  };
21599
- app.path = function path6() {
21599
+ app.path = function path7() {
21600
21600
  return this.parent ? this.parent.path() + this.mountpath : "";
21601
21601
  };
21602
21602
  app.enabled = function enabled(setting2) {
@@ -21612,17 +21612,17 @@ var require_application = __commonJS({
21612
21612
  return this.set(setting2, false);
21613
21613
  };
21614
21614
  methods.forEach(function(method) {
21615
- app[method] = function(path6) {
21615
+ app[method] = function(path7) {
21616
21616
  if (method === "get" && arguments.length === 1) {
21617
- return this.set(path6);
21617
+ return this.set(path7);
21618
21618
  }
21619
- var route = this.route(path6);
21619
+ var route = this.route(path7);
21620
21620
  route[method].apply(route, slice.call(arguments, 1));
21621
21621
  return this;
21622
21622
  };
21623
21623
  });
21624
- app.all = function all3(path6) {
21625
- var route = this.route(path6);
21624
+ app.all = function all3(path7) {
21625
+ var route = this.route(path7);
21626
21626
  var args = slice.call(arguments, 1);
21627
21627
  for (var i = 0; i < methods.length; i++) {
21628
21628
  route[methods[i]].apply(route, args);
@@ -22302,11 +22302,11 @@ var require_mime_types3 = __commonJS({
22302
22302
  }
22303
22303
  return exts[0];
22304
22304
  }
22305
- function lookup(path6) {
22306
- if (!path6 || typeof path6 !== "string") {
22305
+ function lookup(path7) {
22306
+ if (!path7 || typeof path7 !== "string") {
22307
22307
  return false;
22308
22308
  }
22309
- var extension2 = extname("x." + path6).toLowerCase().slice(1);
22309
+ var extension2 = extname("x." + path7).toLowerCase().slice(1);
22310
22310
  if (!extension2) {
22311
22311
  return false;
22312
22312
  }
@@ -22683,7 +22683,7 @@ var require_request = __commonJS({
22683
22683
  var subdomains2 = !isIP(hostname) ? hostname.split(".").reverse() : [hostname];
22684
22684
  return subdomains2.slice(offset);
22685
22685
  });
22686
- defineGetter(req, "path", function path6() {
22686
+ defineGetter(req, "path", function path7() {
22687
22687
  return parse2(this).pathname;
22688
22688
  });
22689
22689
  defineGetter(req, "host", function host() {
@@ -23182,11 +23182,11 @@ var require_mime_types4 = __commonJS({
23182
23182
  }
23183
23183
  return exts[0];
23184
23184
  }
23185
- function lookup(path6) {
23186
- if (!path6 || typeof path6 !== "string") {
23185
+ function lookup(path7) {
23186
+ if (!path7 || typeof path7 !== "string") {
23187
23187
  return false;
23188
23188
  }
23189
- var extension2 = extname("x." + path6).toLowerCase().slice(1);
23189
+ var extension2 = extname("x." + path7).toLowerCase().slice(1);
23190
23190
  if (!extension2) {
23191
23191
  return false;
23192
23192
  }
@@ -23241,32 +23241,32 @@ var require_send = __commonJS({
23241
23241
  var escapeHtml = require_escape_html();
23242
23242
  var etag = require_etag();
23243
23243
  var fresh = require_fresh();
23244
- var fs5 = __require("fs");
23244
+ var fs6 = __require("fs");
23245
23245
  var mime = require_mime_types4();
23246
23246
  var ms = require_ms();
23247
23247
  var onFinished = require_on_finished();
23248
23248
  var parseRange = require_range_parser();
23249
- var path6 = __require("path");
23249
+ var path7 = __require("path");
23250
23250
  var statuses = require_statuses();
23251
23251
  var Stream2 = __require("stream");
23252
23252
  var util3 = __require("util");
23253
- var extname = path6.extname;
23254
- var join3 = path6.join;
23255
- var normalize = path6.normalize;
23256
- var resolve = path6.resolve;
23257
- var sep = path6.sep;
23253
+ var extname = path7.extname;
23254
+ var join3 = path7.join;
23255
+ var normalize = path7.normalize;
23256
+ var resolve = path7.resolve;
23257
+ var sep = path7.sep;
23258
23258
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
23259
23259
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
23260
23260
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
23261
23261
  module.exports = send;
23262
- function send(req, path7, options) {
23263
- return new SendStream(req, path7, options);
23262
+ function send(req, path8, options) {
23263
+ return new SendStream(req, path8, options);
23264
23264
  }
23265
- function SendStream(req, path7, options) {
23265
+ function SendStream(req, path8, options) {
23266
23266
  Stream2.call(this);
23267
23267
  var opts = options || {};
23268
23268
  this.options = opts;
23269
- this.path = path7;
23269
+ this.path = path8;
23270
23270
  this.req = req;
23271
23271
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
23272
23272
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -23380,10 +23380,10 @@ var require_send = __commonJS({
23380
23380
  var lastModified = this.res.getHeader("Last-Modified");
23381
23381
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
23382
23382
  };
23383
- SendStream.prototype.redirect = function redirect(path7) {
23383
+ SendStream.prototype.redirect = function redirect(path8) {
23384
23384
  var res = this.res;
23385
23385
  if (hasListeners(this, "directory")) {
23386
- this.emit("directory", res, path7);
23386
+ this.emit("directory", res, path8);
23387
23387
  return;
23388
23388
  }
23389
23389
  if (this.hasTrailingSlash()) {
@@ -23403,38 +23403,38 @@ var require_send = __commonJS({
23403
23403
  SendStream.prototype.pipe = function pipe(res) {
23404
23404
  var root = this._root;
23405
23405
  this.res = res;
23406
- var path7 = decode(this.path);
23407
- if (path7 === -1) {
23406
+ var path8 = decode(this.path);
23407
+ if (path8 === -1) {
23408
23408
  this.error(400);
23409
23409
  return res;
23410
23410
  }
23411
- if (~path7.indexOf("\0")) {
23411
+ if (~path8.indexOf("\0")) {
23412
23412
  this.error(400);
23413
23413
  return res;
23414
23414
  }
23415
23415
  var parts;
23416
23416
  if (root !== null) {
23417
- if (path7) {
23418
- path7 = normalize("." + sep + path7);
23417
+ if (path8) {
23418
+ path8 = normalize("." + sep + path8);
23419
23419
  }
23420
- if (UP_PATH_REGEXP.test(path7)) {
23421
- debug('malicious path "%s"', path7);
23420
+ if (UP_PATH_REGEXP.test(path8)) {
23421
+ debug('malicious path "%s"', path8);
23422
23422
  this.error(403);
23423
23423
  return res;
23424
23424
  }
23425
- parts = path7.split(sep);
23426
- path7 = normalize(join3(root, path7));
23425
+ parts = path8.split(sep);
23426
+ path8 = normalize(join3(root, path8));
23427
23427
  } else {
23428
- if (UP_PATH_REGEXP.test(path7)) {
23429
- debug('malicious path "%s"', path7);
23428
+ if (UP_PATH_REGEXP.test(path8)) {
23429
+ debug('malicious path "%s"', path8);
23430
23430
  this.error(403);
23431
23431
  return res;
23432
23432
  }
23433
- parts = normalize(path7).split(sep);
23434
- path7 = resolve(path7);
23433
+ parts = normalize(path8).split(sep);
23434
+ path8 = resolve(path8);
23435
23435
  }
23436
23436
  if (containsDotFile(parts)) {
23437
- debug('%s dotfile "%s"', this._dotfiles, path7);
23437
+ debug('%s dotfile "%s"', this._dotfiles, path8);
23438
23438
  switch (this._dotfiles) {
23439
23439
  case "allow":
23440
23440
  break;
@@ -23448,13 +23448,13 @@ var require_send = __commonJS({
23448
23448
  }
23449
23449
  }
23450
23450
  if (this._index.length && this.hasTrailingSlash()) {
23451
- this.sendIndex(path7);
23451
+ this.sendIndex(path8);
23452
23452
  return res;
23453
23453
  }
23454
- this.sendFile(path7);
23454
+ this.sendFile(path8);
23455
23455
  return res;
23456
23456
  };
23457
- SendStream.prototype.send = function send2(path7, stat) {
23457
+ SendStream.prototype.send = function send2(path8, stat) {
23458
23458
  var len = stat.size;
23459
23459
  var options = this.options;
23460
23460
  var opts = {};
@@ -23466,9 +23466,9 @@ var require_send = __commonJS({
23466
23466
  this.headersAlreadySent();
23467
23467
  return;
23468
23468
  }
23469
- debug('pipe "%s"', path7);
23470
- this.setHeader(path7, stat);
23471
- this.type(path7);
23469
+ debug('pipe "%s"', path8);
23470
+ this.setHeader(path8, stat);
23471
+ this.type(path8);
23472
23472
  if (this.isConditionalGET()) {
23473
23473
  if (this.isPreconditionFailure()) {
23474
23474
  this.error(412);
@@ -23517,30 +23517,30 @@ var require_send = __commonJS({
23517
23517
  res.end();
23518
23518
  return;
23519
23519
  }
23520
- this.stream(path7, opts);
23520
+ this.stream(path8, opts);
23521
23521
  };
23522
- SendStream.prototype.sendFile = function sendFile(path7) {
23522
+ SendStream.prototype.sendFile = function sendFile(path8) {
23523
23523
  var i = 0;
23524
23524
  var self2 = this;
23525
- debug('stat "%s"', path7);
23526
- fs5.stat(path7, function onstat(err, stat) {
23527
- var pathEndsWithSep = path7[path7.length - 1] === sep;
23528
- if (err && err.code === "ENOENT" && !extname(path7) && !pathEndsWithSep) {
23525
+ debug('stat "%s"', path8);
23526
+ fs6.stat(path8, function onstat(err, stat) {
23527
+ var pathEndsWithSep = path8[path8.length - 1] === sep;
23528
+ if (err && err.code === "ENOENT" && !extname(path8) && !pathEndsWithSep) {
23529
23529
  return next(err);
23530
23530
  }
23531
23531
  if (err) return self2.onStatError(err);
23532
- if (stat.isDirectory()) return self2.redirect(path7);
23532
+ if (stat.isDirectory()) return self2.redirect(path8);
23533
23533
  if (pathEndsWithSep) return self2.error(404);
23534
- self2.emit("file", path7, stat);
23535
- self2.send(path7, stat);
23534
+ self2.emit("file", path8, stat);
23535
+ self2.send(path8, stat);
23536
23536
  });
23537
23537
  function next(err) {
23538
23538
  if (self2._extensions.length <= i) {
23539
23539
  return err ? self2.onStatError(err) : self2.error(404);
23540
23540
  }
23541
- var p = path7 + "." + self2._extensions[i++];
23541
+ var p = path8 + "." + self2._extensions[i++];
23542
23542
  debug('stat "%s"', p);
23543
- fs5.stat(p, function(err2, stat) {
23543
+ fs6.stat(p, function(err2, stat) {
23544
23544
  if (err2) return next(err2);
23545
23545
  if (stat.isDirectory()) return next();
23546
23546
  self2.emit("file", p, stat);
@@ -23548,7 +23548,7 @@ var require_send = __commonJS({
23548
23548
  });
23549
23549
  }
23550
23550
  };
23551
- SendStream.prototype.sendIndex = function sendIndex(path7) {
23551
+ SendStream.prototype.sendIndex = function sendIndex(path8) {
23552
23552
  var i = -1;
23553
23553
  var self2 = this;
23554
23554
  function next(err) {
@@ -23556,9 +23556,9 @@ var require_send = __commonJS({
23556
23556
  if (err) return self2.onStatError(err);
23557
23557
  return self2.error(404);
23558
23558
  }
23559
- var p = join3(path7, self2._index[i]);
23559
+ var p = join3(path8, self2._index[i]);
23560
23560
  debug('stat "%s"', p);
23561
- fs5.stat(p, function(err2, stat) {
23561
+ fs6.stat(p, function(err2, stat) {
23562
23562
  if (err2) return next(err2);
23563
23563
  if (stat.isDirectory()) return next();
23564
23564
  self2.emit("file", p, stat);
@@ -23567,10 +23567,10 @@ var require_send = __commonJS({
23567
23567
  }
23568
23568
  next();
23569
23569
  };
23570
- SendStream.prototype.stream = function stream5(path7, options) {
23570
+ SendStream.prototype.stream = function stream5(path8, options) {
23571
23571
  var self2 = this;
23572
23572
  var res = this.res;
23573
- var stream6 = fs5.createReadStream(path7, options);
23573
+ var stream6 = fs6.createReadStream(path8, options);
23574
23574
  this.emit("stream", stream6);
23575
23575
  stream6.pipe(res);
23576
23576
  function cleanup() {
@@ -23585,17 +23585,17 @@ var require_send = __commonJS({
23585
23585
  self2.emit("end");
23586
23586
  });
23587
23587
  };
23588
- SendStream.prototype.type = function type(path7) {
23588
+ SendStream.prototype.type = function type(path8) {
23589
23589
  var res = this.res;
23590
23590
  if (res.getHeader("Content-Type")) return;
23591
- var ext = extname(path7);
23591
+ var ext = extname(path8);
23592
23592
  var type2 = mime.contentType(ext) || "application/octet-stream";
23593
23593
  debug("content-type %s", type2);
23594
23594
  res.setHeader("Content-Type", type2);
23595
23595
  };
23596
- SendStream.prototype.setHeader = function setHeader(path7, stat) {
23596
+ SendStream.prototype.setHeader = function setHeader(path8, stat) {
23597
23597
  var res = this.res;
23598
- this.emit("headers", res, path7, stat);
23598
+ this.emit("headers", res, path8, stat);
23599
23599
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
23600
23600
  debug("accept ranges");
23601
23601
  res.setHeader("Accept-Ranges", "bytes");
@@ -23653,9 +23653,9 @@ var require_send = __commonJS({
23653
23653
  }
23654
23654
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
23655
23655
  }
23656
- function decode(path7) {
23656
+ function decode(path8) {
23657
23657
  try {
23658
- return decodeURIComponent(path7);
23658
+ return decodeURIComponent(path8);
23659
23659
  } catch (err) {
23660
23660
  return -1;
23661
23661
  }
@@ -23799,7 +23799,7 @@ var require_response = __commonJS({
23799
23799
  var http3 = __require("http");
23800
23800
  var onFinished = require_on_finished();
23801
23801
  var mime = require_mime_types2();
23802
- var path6 = __require("path");
23802
+ var path7 = __require("path");
23803
23803
  var pathIsAbsolute = __require("path").isAbsolute;
23804
23804
  var statuses = require_statuses();
23805
23805
  var sign = require_cookie_signature().sign;
@@ -23808,8 +23808,8 @@ var require_response = __commonJS({
23808
23808
  var setCharset = require_utils3().setCharset;
23809
23809
  var cookie = require_cookie();
23810
23810
  var send = require_send();
23811
- var extname = path6.extname;
23812
- var resolve = path6.resolve;
23811
+ var extname = path7.extname;
23812
+ var resolve = path7.resolve;
23813
23813
  var vary = require_vary();
23814
23814
  var { Buffer: Buffer2 } = __require("buffer");
23815
23815
  var res = Object.create(http3.ServerResponse.prototype);
@@ -23955,26 +23955,26 @@ var require_response = __commonJS({
23955
23955
  this.type("txt");
23956
23956
  return this.send(body);
23957
23957
  };
23958
- res.sendFile = function sendFile(path7, options, callback) {
23958
+ res.sendFile = function sendFile(path8, options, callback) {
23959
23959
  var done = callback;
23960
23960
  var req = this.req;
23961
23961
  var res2 = this;
23962
23962
  var next = req.next;
23963
23963
  var opts = options || {};
23964
- if (!path7) {
23964
+ if (!path8) {
23965
23965
  throw new TypeError("path argument is required to res.sendFile");
23966
23966
  }
23967
- if (typeof path7 !== "string") {
23967
+ if (typeof path8 !== "string") {
23968
23968
  throw new TypeError("path must be a string to res.sendFile");
23969
23969
  }
23970
23970
  if (typeof options === "function") {
23971
23971
  done = options;
23972
23972
  opts = {};
23973
23973
  }
23974
- if (!opts.root && !pathIsAbsolute(path7)) {
23974
+ if (!opts.root && !pathIsAbsolute(path8)) {
23975
23975
  throw new TypeError("path must be absolute or specify root to res.sendFile");
23976
23976
  }
23977
- var pathname = encodeURI(path7);
23977
+ var pathname = encodeURI(path8);
23978
23978
  opts.etag = this.app.enabled("etag");
23979
23979
  var file = send(req, pathname, opts);
23980
23980
  sendfile(res2, file, opts, function(err) {
@@ -23985,7 +23985,7 @@ var require_response = __commonJS({
23985
23985
  }
23986
23986
  });
23987
23987
  };
23988
- res.download = function download(path7, filename, options, callback) {
23988
+ res.download = function download(path8, filename, options, callback) {
23989
23989
  var done = callback;
23990
23990
  var name = filename;
23991
23991
  var opts = options || null;
@@ -24002,7 +24002,7 @@ var require_response = __commonJS({
24002
24002
  opts = filename;
24003
24003
  }
24004
24004
  var headers = {
24005
- "Content-Disposition": contentDisposition(name || path7)
24005
+ "Content-Disposition": contentDisposition(name || path8)
24006
24006
  };
24007
24007
  if (opts && opts.headers) {
24008
24008
  var keys = Object.keys(opts.headers);
@@ -24015,7 +24015,7 @@ var require_response = __commonJS({
24015
24015
  }
24016
24016
  opts = Object.create(opts);
24017
24017
  opts.headers = headers;
24018
- var fullPath = !opts.root ? resolve(path7) : path7;
24018
+ var fullPath = !opts.root ? resolve(path8) : path8;
24019
24019
  return this.sendFile(fullPath, opts, done);
24020
24020
  };
24021
24021
  res.contentType = res.type = function contentType(type) {
@@ -24298,11 +24298,11 @@ var require_serve_static = __commonJS({
24298
24298
  }
24299
24299
  var forwardError = !fallthrough;
24300
24300
  var originalUrl = parseUrl2.original(req);
24301
- var path6 = parseUrl2(req).pathname;
24302
- if (path6 === "/" && originalUrl.pathname.substr(-1) !== "/") {
24303
- path6 = "";
24301
+ var path7 = parseUrl2(req).pathname;
24302
+ if (path7 === "/" && originalUrl.pathname.substr(-1) !== "/") {
24303
+ path7 = "";
24304
24304
  }
24305
- var stream5 = send(req, path6, opts);
24305
+ var stream5 = send(req, path7, opts);
24306
24306
  stream5.on("directory", onDirectory);
24307
24307
  if (setHeaders) {
24308
24308
  stream5.on("headers", setHeaders);
@@ -27949,14 +27949,14 @@ var require_url_state_machine = __commonJS({
27949
27949
  return url2.replace(/\u0009|\u000A|\u000D/g, "");
27950
27950
  }
27951
27951
  function shortenPath(url2) {
27952
- const path6 = url2.path;
27953
- if (path6.length === 0) {
27952
+ const path7 = url2.path;
27953
+ if (path7.length === 0) {
27954
27954
  return;
27955
27955
  }
27956
- if (url2.scheme === "file" && path6.length === 1 && isNormalizedWindowsDriveLetter(path6[0])) {
27956
+ if (url2.scheme === "file" && path7.length === 1 && isNormalizedWindowsDriveLetter(path7[0])) {
27957
27957
  return;
27958
27958
  }
27959
- path6.pop();
27959
+ path7.pop();
27960
27960
  }
27961
27961
  function includesCredentials(url2) {
27962
27962
  return url2.username !== "" || url2.password !== "";
@@ -30280,14 +30280,14 @@ var require_api_client = __commonJS({
30280
30280
  * @param {string} [path] - An optional path for the request.
30281
30281
  * @return {Promise<RequestOptions>} A promise that resolves to the prepared options for the HTTP request.
30282
30282
  */
30283
- async prepareOptions(url2, method, queryParams, headers, body, path6) {
30283
+ async prepareOptions(url2, method, queryParams, headers, body, path7) {
30284
30284
  const options = {
30285
30285
  method,
30286
30286
  headers: new node_fetch_1.Headers(filterUndefinedValues(headers)),
30287
30287
  body,
30288
30288
  queryParams: filterUndefinedValues(queryParams),
30289
30289
  hostname: url2,
30290
- path: path6
30290
+ path: path7
30291
30291
  };
30292
30292
  let opts = options;
30293
30293
  if (this.apiClientOptions.requestPlugins) {
@@ -31159,7 +31159,7 @@ var require_authorization_helper = __commonJS({
31159
31159
  return headerSignature === signature;
31160
31160
  };
31161
31161
  exports.validateWebhookSignature = validateWebhookSignature;
31162
- var validateAuthenticationHeader2 = (applicationKey, applicationSecret, headers, body, path6, method) => {
31162
+ var validateAuthenticationHeader2 = (applicationKey, applicationSecret, headers, body, path7, method) => {
31163
31163
  const normalizedHeaders = normalizeHeaders(headers);
31164
31164
  const authorization = getHeader(normalizedHeaders.authorization);
31165
31165
  if (typeof authorization === "undefined") {
@@ -31175,7 +31175,7 @@ var require_authorization_helper = __commonJS({
31175
31175
  return validateBasicAuth2(authorizationValue, applicationKey, applicationSecret);
31176
31176
  }
31177
31177
  if (authorizationScheme === "application") {
31178
- return validateApplicationAuth(authorizationValue, normalizedHeaders, applicationKey, applicationSecret, path6, body, method);
31178
+ return validateApplicationAuth(authorizationValue, normalizedHeaders, applicationKey, applicationSecret, path7, body, method);
31179
31179
  }
31180
31180
  console.error(`Scheme is not valid: ${authParts[0]}`);
31181
31181
  return false;
@@ -31205,7 +31205,7 @@ var require_authorization_helper = __commonJS({
31205
31205
  return crypto_1.default.createHmac("sha256", secret).update(signedData).digest("base64");
31206
31206
  };
31207
31207
  exports.calculateWebhookSignature = calculateWebhookSignature;
31208
- var validateApplicationAuth = (authorizationValue, normalizedHeaders, applicationKey, applicationSecret, path6, body, method) => {
31208
+ var validateApplicationAuth = (authorizationValue, normalizedHeaders, applicationKey, applicationSecret, path7, body, method) => {
31209
31209
  const authKeyAndSecret = authorizationValue.split(":");
31210
31210
  if (authKeyAndSecret.length !== 2) {
31211
31211
  console.error("Invalid authorization value format provided");
@@ -31218,7 +31218,7 @@ var require_authorization_helper = __commonJS({
31218
31218
  const contentType = getHeader(normalizedHeaders["content-type"]);
31219
31219
  const hasBody = !!body;
31220
31220
  const contentMD5 = hasBody ? (0, exports.calculateMD5)(body) : "";
31221
- const stringToSign = buildStringToSign2(method.toUpperCase(), contentMD5, contentType, `x-timestamp:${normalizedHeaders["x-timestamp"]}`, path6);
31221
+ const stringToSign = buildStringToSign2(method.toUpperCase(), contentMD5, contentType, `x-timestamp:${normalizedHeaders["x-timestamp"]}`, path7);
31222
31222
  const signature = (0, exports.calculateSignature)(applicationSecret, stringToSign);
31223
31223
  if (authKeyAndSecret[1] !== signature) {
31224
31224
  console.error("Invalid signature");
@@ -44293,11 +44293,11 @@ var require_mime_types5 = __commonJS({
44293
44293
  }
44294
44294
  return exts[0];
44295
44295
  }
44296
- function lookup(path6) {
44297
- if (!path6 || typeof path6 !== "string") {
44296
+ function lookup(path7) {
44297
+ if (!path7 || typeof path7 !== "string") {
44298
44298
  return false;
44299
44299
  }
44300
- var extension2 = extname("x." + path6).toLowerCase().substr(1);
44300
+ var extension2 = extname("x." + path7).toLowerCase().substr(1);
44301
44301
  if (!extension2) {
44302
44302
  return false;
44303
44303
  }
@@ -44609,11 +44609,11 @@ var require_form_data = __commonJS({
44609
44609
  "use strict";
44610
44610
  var CombinedStream = require_combined_stream();
44611
44611
  var util3 = __require("util");
44612
- var path6 = __require("path");
44612
+ var path7 = __require("path");
44613
44613
  var http3 = __require("http");
44614
44614
  var https3 = __require("https");
44615
44615
  var parseUrl2 = __require("url").parse;
44616
- var fs5 = __require("fs");
44616
+ var fs6 = __require("fs");
44617
44617
  var Stream2 = __require("stream").Stream;
44618
44618
  var crypto4 = __require("crypto");
44619
44619
  var mime = require_mime_types5();
@@ -44680,7 +44680,7 @@ var require_form_data = __commonJS({
44680
44680
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
44681
44681
  callback(null, value.end + 1 - (value.start ? value.start : 0));
44682
44682
  } else {
44683
- fs5.stat(value.path, function(err, stat) {
44683
+ fs6.stat(value.path, function(err, stat) {
44684
44684
  if (err) {
44685
44685
  callback(err);
44686
44686
  return;
@@ -44737,11 +44737,11 @@ var require_form_data = __commonJS({
44737
44737
  FormData3.prototype._getContentDisposition = function(value, options) {
44738
44738
  var filename;
44739
44739
  if (typeof options.filepath === "string") {
44740
- filename = path6.normalize(options.filepath).replace(/\\/g, "/");
44740
+ filename = path7.normalize(options.filepath).replace(/\\/g, "/");
44741
44741
  } else if (options.filename || value && (value.name || value.path)) {
44742
- filename = path6.basename(options.filename || value && (value.name || value.path));
44742
+ filename = path7.basename(options.filename || value && (value.name || value.path));
44743
44743
  } else if (value && value.readable && hasOwn(value, "httpVersion")) {
44744
- filename = path6.basename(value.client._httpMessage.path || "");
44744
+ filename = path7.basename(value.client._httpMessage.path || "");
44745
44745
  }
44746
44746
  if (filename) {
44747
44747
  return 'filename="' + filename + '"';
@@ -44968,7 +44968,7 @@ var require_faxes_api = __commonJS({
44968
44968
  var sdk_client_1 = require_dist2();
44969
44969
  var fax_domain_api_1 = require_fax_domain_api();
44970
44970
  var FormData3 = require_form_data();
44971
- var fs5 = __importStar(__require("fs"));
44971
+ var fs6 = __importStar(__require("fs"));
44972
44972
  var FaxesApi = class extends fax_domain_api_1.FaxDomainApi {
44973
44973
  constructor(lazyClient) {
44974
44974
  super(lazyClient, "FaxesApi");
@@ -45124,7 +45124,7 @@ var require_faxes_api = __commonJS({
45124
45124
  attachmentPaths = [String(requestData.filePaths)];
45125
45125
  }
45126
45126
  attachmentPaths.forEach((filePath) => {
45127
- formData.append("file", fs5.readFileSync(filePath), filePath.split("/").pop());
45127
+ formData.append("file", fs6.readFileSync(filePath), filePath.split("/").pop());
45128
45128
  });
45129
45129
  }
45130
45130
  if (requestData.from) {
@@ -49393,11 +49393,11 @@ var require_callbacks_webhook6 = __commonJS({
49393
49393
  * @param {string} method - Incoming request's HTTP method
49394
49394
  * @return {boolean} - true if the authorization header is valid
49395
49395
  */
49396
- validateAuthenticationHeader(headers, body, path6, method) {
49396
+ validateAuthenticationHeader(headers, body, path7, method) {
49397
49397
  if (!this.sinchClientParameters.applicationKey || !this.sinchClientParameters.applicationSecret) {
49398
49398
  throw new Error("The application key and secret must be defined");
49399
49399
  }
49400
- return (0, sdk_client_1.validateAuthenticationHeader)(this.sinchClientParameters.applicationKey, this.sinchClientParameters.applicationSecret, headers, body, path6, method);
49400
+ return (0, sdk_client_1.validateAuthenticationHeader)(this.sinchClientParameters.applicationKey, this.sinchClientParameters.applicationSecret, headers, body, path7, method);
49401
49401
  }
49402
49402
  /**
49403
49403
  * Reviver for a Verification Event.
@@ -49548,9 +49548,9 @@ var require_verification_status_api = __commonJS({
49548
49548
  "Accept": "application/json"
49549
49549
  };
49550
49550
  const body = "";
49551
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49552
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49553
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
49551
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49552
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49553
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
49554
49554
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49555
49555
  return this.client.processCall({
49556
49556
  url: url2,
@@ -49575,9 +49575,9 @@ var require_verification_status_api = __commonJS({
49575
49575
  verificationMethod = "callout";
49576
49576
  }
49577
49577
  const body = "";
49578
- const path6 = `/verification/v1/verifications/${verificationMethod}/number/${data["endpoint"]}`;
49579
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49580
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
49578
+ const path7 = `/verification/v1/verifications/${verificationMethod}/number/${data["endpoint"]}`;
49579
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49580
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
49581
49581
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49582
49582
  return this.client.processCall({
49583
49583
  url: url2,
@@ -49598,9 +49598,9 @@ var require_verification_status_api = __commonJS({
49598
49598
  "Accept": "application/json"
49599
49599
  };
49600
49600
  const body = "";
49601
- const path6 = `/verification/v1/verifications/reference/${data["reference"]}`;
49602
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49603
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
49601
+ const path7 = `/verification/v1/verifications/reference/${data["reference"]}`;
49602
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49603
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
49604
49604
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49605
49605
  return this.client.processCall({
49606
49606
  url: url2,
@@ -49681,9 +49681,9 @@ var require_verifications_api = __commonJS({
49681
49681
  "Accept": "application/json"
49682
49682
  };
49683
49683
  const body = data["reportSmsVerificationByIdRequestBody"] ? JSON.stringify(data["reportSmsVerificationByIdRequestBody"]) : "{}";
49684
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49685
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49686
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49684
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49685
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49686
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49687
49687
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49688
49688
  return this.client.processCall({
49689
49689
  url: url2,
@@ -49705,9 +49705,9 @@ var require_verifications_api = __commonJS({
49705
49705
  "Accept": "application/json"
49706
49706
  };
49707
49707
  const body = data["reportFlashCallVerificationByIdRequestBody"] ? JSON.stringify(data["reportFlashCallVerificationByIdRequestBody"]) : "{}";
49708
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49709
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49710
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49708
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49709
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49710
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49711
49711
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49712
49712
  return this.client.processCall({
49713
49713
  url: url2,
@@ -49730,9 +49730,9 @@ var require_verifications_api = __commonJS({
49730
49730
  };
49731
49731
  const requestDataBody = this.performReportPhoneCallByIdRequestBodyTransformation(data.reportPhoneCallVerificationByIdRequestBody);
49732
49732
  const body = requestDataBody ? JSON.stringify(requestDataBody) : "{}";
49733
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49734
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49735
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49733
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49734
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49735
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49736
49736
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49737
49737
  return this.client.processCall({
49738
49738
  url: url2,
@@ -49761,9 +49761,9 @@ var require_verifications_api = __commonJS({
49761
49761
  "Accept": "application/json"
49762
49762
  };
49763
49763
  const body = data["reportCalloutVerificationByIdRequestBody"] ? JSON.stringify(data["reportCalloutVerificationByIdRequestBody"]) : "{}";
49764
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49765
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49766
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49764
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49765
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49766
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49767
49767
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49768
49768
  return this.client.processCall({
49769
49769
  url: url2,
@@ -49785,9 +49785,9 @@ var require_verifications_api = __commonJS({
49785
49785
  "Accept": "application/json"
49786
49786
  };
49787
49787
  const body = data["reportWhatsAppVerificationByIdRequestBody"] ? JSON.stringify(data["reportWhatsAppVerificationByIdRequestBody"]) : "{}";
49788
- const path6 = `/verification/v1/verifications/id/${data["id"]}`;
49789
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49790
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49788
+ const path7 = `/verification/v1/verifications/id/${data["id"]}`;
49789
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49790
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49791
49791
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49792
49792
  return this.client.processCall({
49793
49793
  url: url2,
@@ -49809,9 +49809,9 @@ var require_verifications_api = __commonJS({
49809
49809
  "Accept": "application/json"
49810
49810
  };
49811
49811
  const body = data["reportSmsVerificationByIdentityRequestBody"] ? JSON.stringify(data["reportSmsVerificationByIdentityRequestBody"]) : "{}";
49812
- const path6 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49813
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49814
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49812
+ const path7 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49813
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49814
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49815
49815
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49816
49816
  return this.client.processCall({
49817
49817
  url: url2,
@@ -49833,9 +49833,9 @@ var require_verifications_api = __commonJS({
49833
49833
  "Accept": "application/json"
49834
49834
  };
49835
49835
  const body = data["reportFlashCallVerificationByIdentityRequestBody"] ? JSON.stringify(data["reportFlashCallVerificationByIdentityRequestBody"]) : "{}";
49836
- const path6 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49837
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49838
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49836
+ const path7 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49837
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49838
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49839
49839
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49840
49840
  return this.client.processCall({
49841
49841
  url: url2,
@@ -49858,9 +49858,9 @@ var require_verifications_api = __commonJS({
49858
49858
  };
49859
49859
  const requestDataBody = this.performReportPhoneCallByIdentityRequestBodyTransformation(data.reportPhoneCallVerificationByIdentityRequestBody);
49860
49860
  const body = requestDataBody ? JSON.stringify(requestDataBody) : "{}";
49861
- const path6 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49862
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49863
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49861
+ const path7 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49862
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49863
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49864
49864
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49865
49865
  return this.client.processCall({
49866
49866
  url: url2,
@@ -49889,9 +49889,9 @@ var require_verifications_api = __commonJS({
49889
49889
  "Accept": "application/json"
49890
49890
  };
49891
49891
  const body = data["reportCalloutVerificationByIdentityRequestBody"] ? JSON.stringify(data["reportCalloutVerificationByIdentityRequestBody"]) : "{}";
49892
- const path6 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49893
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49894
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49892
+ const path7 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49893
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49894
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49895
49895
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49896
49896
  return this.client.processCall({
49897
49897
  url: url2,
@@ -49913,9 +49913,9 @@ var require_verifications_api = __commonJS({
49913
49913
  "Accept": "application/json"
49914
49914
  };
49915
49915
  const body = data["reportWhatsAppVerificationByIdentityRequestBody"] ? JSON.stringify(data["reportWhatsAppVerificationByIdentityRequestBody"]) : "{}";
49916
- const path6 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49917
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49918
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path6);
49916
+ const path7 = `/verification/v1/verifications/number/${data["endpoint"]}`;
49917
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49918
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0, path7);
49919
49919
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49920
49920
  return this.client.processCall({
49921
49921
  url: url2,
@@ -49941,9 +49941,9 @@ var require_verifications_api = __commonJS({
49941
49941
  }
49942
49942
  const requestDataBody = this.performStartSmsRequestBodyTransformation(data.startVerificationWithSmsRequestBody);
49943
49943
  const body = requestDataBody ? JSON.stringify(requestDataBody) : "{}";
49944
- const path6 = "/verification/v1/verifications";
49945
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49946
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
49944
+ const path7 = "/verification/v1/verifications";
49945
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49946
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
49947
49947
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49948
49948
  return this.client.processCall({
49949
49949
  url: url2,
@@ -49982,9 +49982,9 @@ var require_verifications_api = __commonJS({
49982
49982
  "Accept": "application/json"
49983
49983
  };
49984
49984
  const body = data["startVerificationWithFlashCallRequestBody"] ? JSON.stringify(data["startVerificationWithFlashCallRequestBody"]) : "{}";
49985
- const path6 = "/verification/v1/verifications";
49986
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
49987
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
49985
+ const path7 = "/verification/v1/verifications";
49986
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
49987
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
49988
49988
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
49989
49989
  return this.client.processCall({
49990
49990
  url: url2,
@@ -50007,9 +50007,9 @@ var require_verifications_api = __commonJS({
50007
50007
  };
50008
50008
  const requestDataBody = this.performStartPhoneCallRequestBodyTransformation(data.startVerificationWithPhoneCallRequestBody);
50009
50009
  const body = requestDataBody ? JSON.stringify(requestDataBody) : "{}";
50010
- const path6 = "/verification/v1/verifications";
50011
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
50012
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
50010
+ const path7 = "/verification/v1/verifications";
50011
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
50012
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
50013
50013
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
50014
50014
  return this.client.processCall({
50015
50015
  url: url2,
@@ -50039,9 +50039,9 @@ var require_verifications_api = __commonJS({
50039
50039
  "Accept": "application/json"
50040
50040
  };
50041
50041
  const body = data["startDataVerificationRequestBody"] ? JSON.stringify(data["startDataVerificationRequestBody"]) : "{}";
50042
- const path6 = "/verification/v1/verifications";
50043
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
50044
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
50042
+ const path7 = "/verification/v1/verifications";
50043
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
50044
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
50045
50045
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
50046
50046
  return this.client.processCall({
50047
50047
  url: url2,
@@ -50063,9 +50063,9 @@ var require_verifications_api = __commonJS({
50063
50063
  "Accept": "application/json"
50064
50064
  };
50065
50065
  const body = data["startVerificationWithWhatsAppRequestBody"] ? JSON.stringify(data["startVerificationWithWhatsAppRequestBody"]) : "{}";
50066
- const path6 = "/verification/v1/verifications";
50067
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
50068
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
50066
+ const path7 = "/verification/v1/verifications";
50067
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
50068
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
50069
50069
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
50070
50070
  return this.client.processCall({
50071
50071
  url: url2,
@@ -50088,9 +50088,9 @@ var require_verifications_api = __commonJS({
50088
50088
  "Accept": "application/json"
50089
50089
  };
50090
50090
  const body = data["startVerificationWithCalloutRequestBody"] ? JSON.stringify(data["startVerificationWithCalloutRequestBody"]) : "{}";
50091
- const path6 = "/verification/v1/verifications";
50092
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
50093
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
50091
+ const path7 = "/verification/v1/verifications";
50092
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
50093
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
50094
50094
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
50095
50095
  return this.client.processCall({
50096
50096
  url: url2,
@@ -50113,9 +50113,9 @@ var require_verifications_api = __commonJS({
50113
50113
  "Accept": "application/json"
50114
50114
  };
50115
50115
  const body = data["startSeamlessVerificationRequestBody"] ? JSON.stringify(data["startSeamlessVerificationRequestBody"]) : "{}";
50116
- const path6 = "/verification/v1/verifications";
50117
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
50118
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
50116
+ const path7 = "/verification/v1/verifications";
50117
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
50118
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
50119
50119
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
50120
50120
  return this.client.processCall({
50121
50121
  url: url2,
@@ -51312,9 +51312,9 @@ var require_applications_api = __commonJS({
51312
51312
  "Accept": "application/json"
51313
51313
  };
51314
51314
  const body = "";
51315
- const path6 = `/v1/calling/query/number/${data["number"].split(" ").join("")}`;
51316
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51317
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
51315
+ const path7 = `/v1/calling/query/number/${data["number"].split(" ").join("")}`;
51316
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51317
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
51318
51318
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51319
51319
  return this.client.processCall({
51320
51320
  url: url2,
@@ -51335,9 +51335,9 @@ var require_applications_api = __commonJS({
51335
51335
  "Accept": "application/json"
51336
51336
  };
51337
51337
  const body = "";
51338
- const path6 = `/v1/configuration/callbacks/applications/${data["applicationkey"]}`;
51339
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51340
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
51338
+ const path7 = `/v1/configuration/callbacks/applications/${data["applicationkey"]}`;
51339
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51340
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
51341
51341
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51342
51342
  return this.client.processCall({
51343
51343
  url: url2,
@@ -51358,9 +51358,9 @@ var require_applications_api = __commonJS({
51358
51358
  "Accept": "application/json"
51359
51359
  };
51360
51360
  const body = "";
51361
- const path6 = "/v1/configuration/numbers";
51362
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51363
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
51361
+ const path7 = "/v1/configuration/numbers";
51362
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51363
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
51364
51364
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51365
51365
  return this.client.processCall({
51366
51366
  url: url2,
@@ -51381,9 +51381,9 @@ var require_applications_api = __commonJS({
51381
51381
  "Accept": "application/json"
51382
51382
  };
51383
51383
  const body = data["unassignNumbersRequestBody"] ? JSON.stringify(data["unassignNumbersRequestBody"]) : "{}";
51384
- const path6 = "/v1/configuration/numbers";
51385
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51386
- const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body || void 0, path6);
51384
+ const path7 = "/v1/configuration/numbers";
51385
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51386
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body || void 0, path7);
51387
51387
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51388
51388
  return this.client.processCall({
51389
51389
  url: url2,
@@ -51404,9 +51404,9 @@ var require_applications_api = __commonJS({
51404
51404
  "Accept": "application/json"
51405
51405
  };
51406
51406
  const body = data["updateCallbacksRequestBody"] ? JSON.stringify(data["updateCallbacksRequestBody"]) : "{}";
51407
- const path6 = `/v1/configuration/callbacks/applications/${data["applicationkey"]}`;
51408
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51409
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
51407
+ const path7 = `/v1/configuration/callbacks/applications/${data["applicationkey"]}`;
51408
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51409
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
51410
51410
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51411
51411
  return this.client.processCall({
51412
51412
  url: url2,
@@ -51427,9 +51427,9 @@ var require_applications_api = __commonJS({
51427
51427
  "Accept": "application/json"
51428
51428
  };
51429
51429
  const body = data["assignNumbersRequestBody"] ? JSON.stringify(data["assignNumbersRequestBody"]) : "{}";
51430
- const path6 = "/v1/configuration/numbers";
51431
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51432
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path6);
51430
+ const path7 = "/v1/configuration/numbers";
51431
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51432
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0, path7);
51433
51433
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51434
51434
  return this.client.processCall({
51435
51435
  url: url2,
@@ -51508,11 +51508,11 @@ var require_callbacks_webhook7 = __commonJS({
51508
51508
  * @param {string} method - Incoming request's HTTP method
51509
51509
  * @return {boolean} - true if the authorization header is valid
51510
51510
  */
51511
- validateAuthenticationHeader(headers, body, path6, method) {
51511
+ validateAuthenticationHeader(headers, body, path7, method) {
51512
51512
  if (!this.sinchClientParameters.applicationKey || !this.sinchClientParameters.applicationSecret) {
51513
51513
  throw new Error("The application key and secret must be defined");
51514
51514
  }
51515
- return (0, sdk_client_1.validateAuthenticationHeader)(this.sinchClientParameters.applicationKey, this.sinchClientParameters.applicationSecret, headers, body, path6, method);
51515
+ return (0, sdk_client_1.validateAuthenticationHeader)(this.sinchClientParameters.applicationKey, this.sinchClientParameters.applicationSecret, headers, body, path7, method);
51516
51516
  }
51517
51517
  /**
51518
51518
  * Reviver for a Voice Event.
@@ -51609,9 +51609,9 @@ var require_callouts_api = __commonJS({
51609
51609
  "Accept": "application/json"
51610
51610
  };
51611
51611
  const body = data["ttsCalloutRequestBody"] ? JSON.stringify(data["ttsCalloutRequestBody"]) : "{}";
51612
- const path6 = "/calling/v1/callouts";
51613
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51614
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path6);
51612
+ const path7 = "/calling/v1/callouts";
51613
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51614
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path7);
51615
51615
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51616
51616
  return this.client.processCall({
51617
51617
  url: url2,
@@ -51632,9 +51632,9 @@ var require_callouts_api = __commonJS({
51632
51632
  "Accept": "application/json"
51633
51633
  };
51634
51634
  const body = data["conferenceCalloutRequestBody"] ? JSON.stringify(data["conferenceCalloutRequestBody"]) : "{}";
51635
- const path6 = "/calling/v1/callouts";
51636
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51637
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path6);
51635
+ const path7 = "/calling/v1/callouts";
51636
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51637
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path7);
51638
51638
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51639
51639
  return this.client.processCall({
51640
51640
  url: url2,
@@ -51655,9 +51655,9 @@ var require_callouts_api = __commonJS({
51655
51655
  "Accept": "application/json"
51656
51656
  };
51657
51657
  const body = data["customCalloutRequestBody"] ? JSON.stringify(data["customCalloutRequestBody"]) : "{}";
51658
- const path6 = "/calling/v1/callouts";
51659
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51660
- const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path6);
51658
+ const path7 = "/calling/v1/callouts";
51659
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51660
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body, path7);
51661
51661
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51662
51662
  return this.client.processCall({
51663
51663
  url: url2,
@@ -51737,9 +51737,9 @@ var require_calls_api = __commonJS({
51737
51737
  "Accept": "application/json"
51738
51738
  };
51739
51739
  const body = "";
51740
- const path6 = `/calling/v1/calls/id/${data["callId"]}`;
51741
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51742
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
51740
+ const path7 = `/calling/v1/calls/id/${data["callId"]}`;
51741
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51742
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
51743
51743
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51744
51744
  return this.client.processCall({
51745
51745
  url: url2,
@@ -51760,9 +51760,9 @@ var require_calls_api = __commonJS({
51760
51760
  "Accept": "application/json"
51761
51761
  };
51762
51762
  const body = data["manageWithCallLegRequestBody"] ? JSON.stringify(data["manageWithCallLegRequestBody"]) : "{}";
51763
- const path6 = `/calling/v1/calls/id/${data["callId"]}/leg/${data["callLeg"]}`;
51764
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51765
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path6);
51763
+ const path7 = `/calling/v1/calls/id/${data["callId"]}/leg/${data["callLeg"]}`;
51764
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51765
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path7);
51766
51766
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51767
51767
  return this.client.processCall({
51768
51768
  url: url2,
@@ -51783,9 +51783,9 @@ var require_calls_api = __commonJS({
51783
51783
  "Accept": "application/json"
51784
51784
  };
51785
51785
  const body = data["updateCallRequestBody"] ? JSON.stringify(data["updateCallRequestBody"]) : "{}";
51786
- const path6 = `/calling/v1/calls/id/${data["callId"]}`;
51787
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51788
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path6);
51786
+ const path7 = `/calling/v1/calls/id/${data["callId"]}`;
51787
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51788
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path7);
51789
51789
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51790
51790
  return this.client.processCall({
51791
51791
  url: url2,
@@ -51875,9 +51875,9 @@ var require_conferences_api = __commonJS({
51875
51875
  "Accept": "application/json"
51876
51876
  };
51877
51877
  const body = "";
51878
- const path6 = `/calling/v1/conferences/id/${data["conferenceId"]}`;
51879
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51880
- const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path6);
51878
+ const path7 = `/calling/v1/conferences/id/${data["conferenceId"]}`;
51879
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51880
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0, path7);
51881
51881
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51882
51882
  return this.client.processCall({
51883
51883
  url: url2,
@@ -51898,9 +51898,9 @@ var require_conferences_api = __commonJS({
51898
51898
  "Accept": "application/json"
51899
51899
  };
51900
51900
  const body = "";
51901
- const path6 = `/calling/v1/conferences/id/${data["conferenceId"]}`;
51902
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51903
- const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body, path6);
51901
+ const path7 = `/calling/v1/conferences/id/${data["conferenceId"]}`;
51902
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51903
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body, path7);
51904
51904
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51905
51905
  return this.client.processCall({
51906
51906
  url: url2,
@@ -51921,9 +51921,9 @@ var require_conferences_api = __commonJS({
51921
51921
  "Accept": "application/json"
51922
51922
  };
51923
51923
  const body = "";
51924
- const path6 = `/calling/v1/conferences/id/${data["conferenceId"]}/${data["callId"]}`;
51925
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51926
- const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body, path6);
51924
+ const path7 = `/calling/v1/conferences/id/${data["conferenceId"]}/${data["callId"]}`;
51925
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51926
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body, path7);
51927
51927
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51928
51928
  return this.client.processCall({
51929
51929
  url: url2,
@@ -51944,9 +51944,9 @@ var require_conferences_api = __commonJS({
51944
51944
  "Accept": "application/json"
51945
51945
  };
51946
51946
  const body = data["manageParticipantRequestBody"] ? JSON.stringify(data["manageParticipantRequestBody"]) : "{}";
51947
- const path6 = `/calling/v1/conferences/id/${data["conferenceId"]}/${data["callId"]}`;
51948
- const basePathUrl = this.client.apiClientOptions.hostname + path6;
51949
- const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path6);
51947
+ const path7 = `/calling/v1/conferences/id/${data["conferenceId"]}/${data["callId"]}`;
51948
+ const basePathUrl = this.client.apiClientOptions.hostname + path7;
51949
+ const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body, path7);
51950
51950
  const url2 = this.client.prepareUrl(requestOptions.hostname, requestOptions.queryParams);
51951
51951
  return this.client.processCall({
51952
51952
  url: url2,
@@ -60039,23 +60039,23 @@ var HttpTransport = class {
60039
60039
  return { transport: "HttpTransport", projectId: this.projectId, host: this.host };
60040
60040
  }
60041
60041
  async createCall(body) {
60042
- const path6 = this.serviceId ? `calls?serviceId=${encodeURIComponent(this.serviceId)}` : "calls";
60043
- const response = await this.request("POST", path6, body);
60042
+ const path7 = this.serviceId ? `calls?serviceId=${encodeURIComponent(this.serviceId)}` : "calls";
60043
+ const response = await this.request("POST", path7, body);
60044
60044
  return response;
60045
60045
  }
60046
60046
  async patchCall(target, commands2) {
60047
- const path6 = "callId" in target ? `calls/${encodeURIComponent(target.callId)}` : `sessions/${encodeURIComponent(target.sessionId)}/calls/${encodeURIComponent(target.callName)}`;
60048
- await this.request("PATCH", path6, { commands: commands2 });
60047
+ const path7 = "callId" in target ? `calls/${encodeURIComponent(target.callId)}` : `sessions/${encodeURIComponent(target.sessionId)}/calls/${encodeURIComponent(target.callName)}`;
60048
+ await this.request("PATCH", path7, { commands: commands2 });
60049
60049
  }
60050
60050
  get authHeaders() {
60051
60051
  const token = Buffer.from(`${this.#keyId}:${this.#keySecret}`).toString("base64");
60052
60052
  return { Authorization: `Basic ${token}`, "Content-Type": "application/json" };
60053
60053
  }
60054
- async request(method, path6, body) {
60054
+ async request(method, path7, body) {
60055
60055
  if (!this.projectId || !this.#keyId || !this.#keySecret) {
60056
60056
  throw new Error("Voice API v2 needs PROJECT_ID, PROJECT_ID_API_KEY and PROJECT_ID_API_SECRET (the project Access Key pair, not the v1 application key).");
60057
60057
  }
60058
- const url2 = `${this.host}/v2/projects/${encodeURIComponent(this.projectId)}/${path6}`;
60058
+ const url2 = `${this.host}/v2/projects/${encodeURIComponent(this.projectId)}/${path7}`;
60059
60059
  const response = await this.fetchImpl(url2, {
60060
60060
  method,
60061
60061
  headers: this.authHeaders,
@@ -62583,8 +62583,8 @@ function buildVoiceSignedRequest(req) {
62583
62583
  function isVoiceWebhookPath(pathname) {
62584
62584
  return pathname === "/" || pathname === "/webhook/voice";
62585
62585
  }
62586
- function extractFunctionName(path6, body) {
62587
- const pathname = path6.split("?")[0];
62586
+ function extractFunctionName(path7, body) {
62587
+ const pathname = path7.split("?")[0];
62588
62588
  if (isVoiceWebhookPath(pathname)) {
62589
62589
  if (body?.event && isVoiceV1Callback(body.event)) {
62590
62590
  return body.event;
@@ -62609,10 +62609,10 @@ function generateRequestId() {
62609
62609
  return `req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
62610
62610
  }
62611
62611
  function findFunctionPath() {
62612
- const fs5 = requireCjs("fs");
62612
+ const fs6 = requireCjs("fs");
62613
62613
  const distPath = nodePath.join(process.cwd(), "dist", "function.js");
62614
62614
  const rootPath = nodePath.join(process.cwd(), "function.js");
62615
- if (fs5.existsSync(distPath)) {
62615
+ if (fs6.existsSync(distPath)) {
62616
62616
  return distPath;
62617
62617
  }
62618
62618
  return rootPath;
@@ -62838,8 +62838,8 @@ function createSinchRuntime() {
62838
62838
  onStartup(handler) {
62839
62839
  result2.startupHandlers.push(handler);
62840
62840
  },
62841
- onWebSocket(path6, handler) {
62842
- const normalizedPath = path6.startsWith("/") ? path6 : `/${path6}`;
62841
+ onWebSocket(path7, handler) {
62842
+ const normalizedPath = path7.startsWith("/") ? path7 : `/${path7}`;
62843
62843
  result2.wsHandlers.set(normalizedPath, handler);
62844
62844
  }
62845
62845
  };
@@ -63519,7 +63519,7 @@ var ElevenLabsAutoConfigurator = class {
63519
63519
  var AGENT_SAMPLE_RATE = 16e3;
63520
63520
  var AGENT_STREAM_PATH = "/stream";
63521
63521
  var AGENT_HEADER_TOKEN = "x-sinch-agent-token";
63522
- function deriveSocketUrl(path6) {
63522
+ function deriveSocketUrl(path7) {
63523
63523
  const fnName = process.env["FUNCTION_NAME"];
63524
63524
  const apiUrl = process.env["API_URL"];
63525
63525
  if (!fnName || !apiUrl)
@@ -63529,7 +63529,7 @@ function deriveSocketUrl(path6) {
63529
63529
  const match = apiUrl.match(/api\.functions\.(\w+)\.sinchvoice\.org/);
63530
63530
  if (!match)
63531
63531
  return "";
63532
- return `wss://${fnName}.fn-${match[1]}.sinch.com${path6}`;
63532
+ return `wss://${fnName}.fn-${match[1]}.sinch.com${path7}`;
63533
63533
  }
63534
63534
  function isLocalDevUrl(url2) {
63535
63535
  let hostname;
@@ -63550,10 +63550,10 @@ function isDeployed(context) {
63550
63550
  function resolveAgentStreamUrl(context, override) {
63551
63551
  return resolveSelfSocketUrl(AGENT_STREAM_PATH, "STREAM_URL", context, override);
63552
63552
  }
63553
- function resolveSelfSocketUrl(path6, envVar, context, override) {
63554
- const url2 = override || (context?.host ? `wss://${context.host}${path6}` : "") || process.env[envVar] || deriveSocketUrl(path6);
63553
+ function resolveSelfSocketUrl(path7, envVar, context, override) {
63554
+ const url2 = override || (context?.host ? `wss://${context.host}${path7}` : "") || process.env[envVar] || deriveSocketUrl(path7);
63555
63555
  if (!url2) {
63556
- throw new Error(`WebSocket URL for ${path6} cannot be determined \u2014 set ${envVar}, or ensure FUNCTION_NAME and API_URL are present.`);
63556
+ throw new Error(`WebSocket URL for ${path7} cannot be determined \u2014 set ${envVar}, or ensure FUNCTION_NAME and API_URL are present.`);
63557
63557
  }
63558
63558
  if (isDeployed(context) && isLocalDevUrl(url2)) {
63559
63559
  throw new Error(`Refusing ${url2} as this deployed function's media endpoint \u2014 it is a local development host the platform cannot reach, so the leg would fail instantly. This is almost always a ${envVar} left over from a 'sinch functions dev' tunnel. Unset it in the deployed environment, or pass the request-scoped context or an explicit URL.`);
@@ -63602,7 +63602,7 @@ var MAX_UNAUTHENTICATED_SOCKETS = 32;
63602
63602
  var HANGUP_GRACE_MS = 1e3;
63603
63603
  var RELAY_LEG2 = "relay";
63604
63604
  function voiceRelay(options) {
63605
- const path6 = options.path ?? RELAY_PATH;
63605
+ const path7 = options.path ?? RELAY_PATH;
63606
63606
  const pending = /* @__PURE__ */ new Map();
63607
63607
  let unauthenticated = 0;
63608
63608
  function takePending(token) {
@@ -63615,7 +63615,7 @@ function voiceRelay(options) {
63615
63615
  }
63616
63616
  function endpointFor(event, clientContext) {
63617
63617
  const context = clientContext;
63618
- const url2 = resolveSelfSocketUrl(path6, "RELAY_URL", context);
63618
+ const url2 = resolveSelfSocketUrl(path7, "RELAY_URL", context);
63619
63619
  const voice = setting(options.voice, event.call, context, "voice");
63620
63620
  const language = setting(options.language, event.call, context, "language");
63621
63621
  const token = randomUUID();
@@ -63804,7 +63804,7 @@ function voiceRelay(options) {
63804
63804
  }
63805
63805
  return {
63806
63806
  setup(runtime) {
63807
- runtime.onWebSocket(path6, ((ws, req) => handleRelay(ws, req)));
63807
+ runtime.onWebSocket(path7, ((ws, req) => handleRelay(ws, req)));
63808
63808
  },
63809
63809
  endpointFor
63810
63810
  };
@@ -63933,19 +63933,27 @@ function buildSettingsFrame(options) {
63933
63933
  output: { encoding: "linear16", sample_rate: sampleRate, container: "none" }
63934
63934
  },
63935
63935
  agent: {
63936
+ // Deepgram's `agent.language` — pins recognition to `options.language` (defaults to
63937
+ // `'en-US'`, see `resolvePerCallOptions`) rather than letting the model auto-detect and
63938
+ // drift onto a misheard phrase, the way it did on a live Gemini call (see `gemini.ts`'s own
63939
+ // `speechConfig.languageCode` comment for that incident). This must live at `agent.language`,
63940
+ // never inside `listen.provider`: a live probe against the current Deepgram API on
63941
+ // 2026-09-26 confirmed a Flux listen model plus `listen.provider.language` is rejected as
63942
+ // `UNPARSABLE_CLIENT_MESSAGE` ("Check the agent.listen.provider field against the API
63943
+ // spec"), while Flux plus `agent.language`, Flux with no language at all, and nova-3 with
63944
+ // `language` at either location are all accepted — matching the shape the C# runtime
63945
+ // already sends. `language_hints` (for `flux-general-multi`) is a separate,
63946
+ // `listen.provider`-only concern this adapter does not yet support.
63947
+ language: options.language ?? DEFAULT_LANGUAGE,
63936
63948
  listen: {
63937
63949
  // Deepgram's Voice Agent API: Flux models take `version: 'v2'`, every other listen
63938
63950
  // model takes `'v1'` — https://developers.deepgram.com/docs/configure-voice-agent.
63939
63951
  provider: {
63940
63952
  type: "deepgram",
63941
63953
  model: sttModel,
63942
- version: sttModel.startsWith("flux") ? "v2" : "v1",
63943
- // Deepgram's `listen.provider.language` — pins recognition to `options.language`
63944
- // (defaults to `'en-US'`, see `resolvePerCallOptions`) rather than letting the model
63945
- // auto-detect and drift onto a misheard phrase, the way it did on a live Gemini call
63946
- // (see `gemini.ts`'s own `speechConfig.languageCode` comment for that incident; not yet
63947
- // reproduced against Deepgram specifically, wired here for the same reason).
63948
- language: options.language ?? DEFAULT_LANGUAGE
63954
+ // Flux listen models (`flux-general-en`, `flux-general-multi`) take `version: 'v2'`;
63955
+ // every other model (Nova, etc.) takes `'v1'`.
63956
+ version: sttModel.startsWith("flux") ? "v2" : "v1"
63949
63957
  }
63950
63958
  },
63951
63959
  think: {
@@ -64424,15 +64432,16 @@ function buildInstructions(options) {
64424
64432
 
64425
64433
  Open the call by greeting the caller before waiting for any caller input.`;
64426
64434
  }
64427
- function buildBackendInstructions(po, tools) {
64435
+ function buildBackendInstructions(options, po, tools) {
64436
+ const preamble = currentDateTimePreamble(options.timezone);
64428
64437
  if (!offersHangup(tools))
64429
- return po.backendInstructions;
64438
+ return preamble + (po.backendInstructions ?? "");
64430
64439
  const terminationBlock = CALL_TERMINATION_INSTRUCTIONS + GPT_LIVE_BACKEND_CALL_TERMINATION_RULE;
64431
- return po.backendInstructions ? po.backendInstructions + terminationBlock : terminationBlock.trimStart();
64440
+ return preamble + (po.backendInstructions ? po.backendInstructions + terminationBlock : terminationBlock.trimStart());
64432
64441
  }
64433
64442
  function buildSessionStart(options, tools) {
64434
64443
  const po = providerOptionsFor2(options);
64435
- const backendInstructions = buildBackendInstructions(po, tools);
64444
+ const backendInstructions = buildBackendInstructions(options, po, tools);
64436
64445
  return {
64437
64446
  type: "session.start",
64438
64447
  session: {
@@ -65992,8 +66001,8 @@ var FIRST_OUTPUT_TIMEOUT_MS = 3e3;
65992
66001
  var RESPONSE_TIMEOUT_MS = 15e3;
65993
66002
  function buildResponsesWsUrl(baseUrl) {
65994
66003
  const base = resolveBaseUrl(baseUrl) ?? DEFAULT_RESPONSES_BASE_URL;
65995
- const path6 = "/responses";
65996
- const url2 = new URL(base + (base.endsWith("/") ? path6.slice(1) : path6));
66004
+ const path7 = "/responses";
66005
+ const url2 = new URL(base + (base.endsWith("/") ? path7.slice(1) : path7));
65997
66006
  url2.protocol = url2.protocol === "http:" ? "ws:" : "wss:";
65998
66007
  return url2.toString();
65999
66008
  }
@@ -71004,9 +71013,9 @@ function isVisitable(thing) {
71004
71013
  function removeBrackets(key) {
71005
71014
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
71006
71015
  }
71007
- function renderKey(path6, key, dots) {
71008
- if (!path6) return key;
71009
- return path6.concat(key).map(function each(token, i) {
71016
+ function renderKey(path7, key, dots) {
71017
+ if (!path7) return key;
71018
+ return path7.concat(key).map(function each(token, i) {
71010
71019
  token = removeBrackets(token);
71011
71020
  return !dots && i ? "[" + token + "]" : token;
71012
71021
  }).join(dots ? "." : "");
@@ -71060,13 +71069,13 @@ function toFormData(obj, formData, options) {
71060
71069
  }
71061
71070
  return value;
71062
71071
  }
71063
- function defaultVisitor(value, key, path6) {
71072
+ function defaultVisitor(value, key, path7) {
71064
71073
  let arr = value;
71065
71074
  if (utils_default.isReactNative(formData) && utils_default.isReactNativeBlob(value)) {
71066
- formData.append(renderKey(path6, key, dots), convertValue(value));
71075
+ formData.append(renderKey(path7, key, dots), convertValue(value));
71067
71076
  return false;
71068
71077
  }
71069
- if (value && !path6 && typeof value === "object") {
71078
+ if (value && !path7 && typeof value === "object") {
71070
71079
  if (utils_default.endsWith(key, "{}")) {
71071
71080
  key = metaTokens ? key : key.slice(0, -2);
71072
71081
  value = JSON.stringify(value);
@@ -71085,7 +71094,7 @@ function toFormData(obj, formData, options) {
71085
71094
  if (isVisitable(value)) {
71086
71095
  return true;
71087
71096
  }
71088
- formData.append(renderKey(path6, key, dots), convertValue(value));
71097
+ formData.append(renderKey(path7, key, dots), convertValue(value));
71089
71098
  return false;
71090
71099
  }
71091
71100
  const stack = [];
@@ -71094,7 +71103,7 @@ function toFormData(obj, formData, options) {
71094
71103
  convertValue,
71095
71104
  isVisitable
71096
71105
  });
71097
- function build(value, path6, depth = 0) {
71106
+ function build(value, path7, depth = 0) {
71098
71107
  if (utils_default.isUndefined(value)) return;
71099
71108
  if (depth > maxDepth) {
71100
71109
  throw new AxiosError_default(
@@ -71103,13 +71112,13 @@ function toFormData(obj, formData, options) {
71103
71112
  );
71104
71113
  }
71105
71114
  if (stack.indexOf(value) !== -1) {
71106
- throw Error("Circular reference detected in " + path6.join("."));
71115
+ throw Error("Circular reference detected in " + path7.join("."));
71107
71116
  }
71108
71117
  stack.push(value);
71109
71118
  utils_default.forEach(value, function each(el, key) {
71110
- const result2 = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key, path6, exposedHelpers);
71119
+ const result2 = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key, path7, exposedHelpers);
71111
71120
  if (result2 === true) {
71112
- build(el, path6 ? path6.concat(key) : [key], depth + 1);
71121
+ build(el, path7 ? path7.concat(key) : [key], depth + 1);
71113
71122
  }
71114
71123
  });
71115
71124
  stack.pop();
@@ -71320,7 +71329,7 @@ var platform_default = {
71320
71329
  // ../../node_modules/axios/lib/helpers/toURLEncodedForm.js
71321
71330
  function toURLEncodedForm(data, options) {
71322
71331
  return toFormData_default(data, new platform_default.classes.URLSearchParams(), {
71323
- visitor: function(value, key, path6, helpers) {
71332
+ visitor: function(value, key, path7, helpers) {
71324
71333
  if (platform_default.isNode && utils_default.isBuffer(value)) {
71325
71334
  this.append(key, value.toString("base64"));
71326
71335
  return false;
@@ -71350,11 +71359,11 @@ function arrayToObject(arr) {
71350
71359
  return obj;
71351
71360
  }
71352
71361
  function formDataToJSON(formData) {
71353
- function buildPath(path6, value, target, index) {
71354
- let name = path6[index++];
71362
+ function buildPath(path7, value, target, index) {
71363
+ let name = path7[index++];
71355
71364
  if (name === "__proto__") return true;
71356
71365
  const isNumericKey = Number.isFinite(+name);
71357
- const isLast = index >= path6.length;
71366
+ const isLast = index >= path7.length;
71358
71367
  name = !name && utils_default.isArray(target) ? target.length : name;
71359
71368
  if (isLast) {
71360
71369
  if (utils_default.hasOwnProp(target, name)) {
@@ -71367,7 +71376,7 @@ function formDataToJSON(formData) {
71367
71376
  if (!target[name] || !utils_default.isObject(target[name])) {
71368
71377
  target[name] = [];
71369
71378
  }
71370
- const result2 = buildPath(path6, value, target[name], index);
71379
+ const result2 = buildPath(path7, value, target[name], index);
71371
71380
  if (result2 && utils_default.isArray(target[name])) {
71372
71381
  target[name] = arrayToObject(target[name]);
71373
71382
  }
@@ -72765,9 +72774,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
72765
72774
  auth = urlUsername + ":" + urlPassword;
72766
72775
  }
72767
72776
  auth && headers.delete("authorization");
72768
- let path6;
72777
+ let path7;
72769
72778
  try {
72770
- path6 = buildURL(
72779
+ path7 = buildURL(
72771
72780
  parsed.pathname + parsed.search,
72772
72781
  config.params,
72773
72782
  config.paramsSerializer
@@ -72785,7 +72794,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
72785
72794
  false
72786
72795
  );
72787
72796
  const options = Object.assign(/* @__PURE__ */ Object.create(null), {
72788
- path: path6,
72797
+ path: path7,
72789
72798
  method,
72790
72799
  headers: headers.toJSON(),
72791
72800
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -73124,14 +73133,14 @@ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PUR
73124
73133
  var cookies_default = platform_default.hasStandardBrowserEnv ? (
73125
73134
  // Standard browser envs support document.cookie
73126
73135
  {
73127
- write(name, value, expires, path6, domain, secure, sameSite) {
73136
+ write(name, value, expires, path7, domain, secure, sameSite) {
73128
73137
  if (typeof document === "undefined") return;
73129
73138
  const cookie = [`${name}=${encodeURIComponent(value)}`];
73130
73139
  if (utils_default.isNumber(expires)) {
73131
73140
  cookie.push(`expires=${new Date(expires).toUTCString()}`);
73132
73141
  }
73133
- if (utils_default.isString(path6)) {
73134
- cookie.push(`path=${path6}`);
73142
+ if (utils_default.isString(path7)) {
73143
+ cookie.push(`path=${path7}`);
73135
73144
  }
73136
73145
  if (utils_default.isString(domain)) {
73137
73146
  cookie.push(`domain=${domain}`);
@@ -74534,6 +74543,8 @@ var {
74534
74543
  // src/tunnel/webhook-config.ts
74535
74544
  var import_sdk_core2 = __toESM(require_dist11(), 1);
74536
74545
  import { randomBytes } from "crypto";
74546
+ import fs4 from "fs";
74547
+ import path5 from "path";
74537
74548
  var SINCH_FN_URL_PATTERN = /\.fn(-\w+)?\.sinch\.(?:com|io)/;
74538
74549
  function isOurWebhook(target) {
74539
74550
  return !!target && SINCH_FN_URL_PATTERN.test(target);
@@ -74545,8 +74556,24 @@ function deployedWebhookTarget(functionName) {
74545
74556
  const domain = process.env.SINCH_FUNCTIONS_DOMAIN || FUNCTIONS_DOMAIN_DEFAULT;
74546
74557
  return `https://${functionName}.${domain}/webhook/conversation`;
74547
74558
  }
74548
- function isTunnelUrl(target) {
74549
- return !!target && target.includes("tunnel.fn");
74559
+ var TUNNEL_GATEWAY_HOST_PATTERN = /^tunnel\.fn(-\w+)?\.sinch\.(com|io)$/;
74560
+ function isTunnelUrl(target, env = process.env) {
74561
+ if (!target) return false;
74562
+ let url2;
74563
+ try {
74564
+ url2 = new URL(target);
74565
+ } catch {
74566
+ return false;
74567
+ }
74568
+ if (TUNNEL_GATEWAY_HOST_PATTERN.test(url2.hostname)) return true;
74569
+ if (env.TUNNEL_GATEWAY_URL) {
74570
+ try {
74571
+ if (new URL(env.TUNNEL_GATEWAY_URL).host === url2.host) return true;
74572
+ } catch {
74573
+ }
74574
+ }
74575
+ const ingressPath = url2.pathname === "/ingress" || url2.pathname.startsWith("/ingress/");
74576
+ return ingressPath && url2.searchParams.has("tunnel");
74550
74577
  }
74551
74578
  async function configureConversationWebhooks(webhookUrl, config) {
74552
74579
  try {
@@ -74575,8 +74602,10 @@ async function configureConversationWebhooks(webhookUrl, config) {
74575
74602
  console.log("\u26A0\uFE0F No deployed webhook found \u2014 deploy first");
74576
74603
  return;
74577
74604
  }
74578
- config.conversationWebhookId = deployedWebhook.id;
74579
- config.originalTarget = deployedWebhook.target;
74605
+ if (config.conversationWebhookId !== deployedWebhook.id) {
74606
+ config.conversationWebhookId = deployedWebhook.id;
74607
+ config.originalTarget = deployedWebhook.target;
74608
+ }
74580
74609
  const hmacSecret = randomBytes(32).toString("hex");
74581
74610
  process.env.CONVERSATION_WEBHOOK_SECRET = hmacSecret;
74582
74611
  resetSinchClients();
@@ -74651,26 +74680,81 @@ async function configureElevenLabs() {
74651
74680
  }
74652
74681
  }
74653
74682
  var VOICE_V2_HOST = "https://voice.api.sinch.com";
74654
- async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchImpl = globalThis.fetch) {
74655
- const serviceId = env.VOICE_SERVICE_ID;
74656
- if (!serviceId) return;
74683
+ function voiceServiceRequest(env) {
74657
74684
  const projectId = env.PROJECT_ID;
74658
74685
  const keyId = env.PROJECT_ID_API_KEY;
74659
74686
  const keySecret = env.PROJECT_ID_API_SECRET;
74660
- if (!projectId || !keyId || !keySecret) {
74687
+ if (!projectId || !keyId || !keySecret) return null;
74688
+ return {
74689
+ baseUrl: `${VOICE_V2_HOST}/v2/projects/${encodeURIComponent(projectId)}/services`,
74690
+ headers: {
74691
+ Authorization: `Basic ${Buffer.from(`${keyId}:${keySecret}`).toString("base64")}`,
74692
+ "Content-Type": "application/json"
74693
+ }
74694
+ };
74695
+ }
74696
+ function staleVoiceWebhookAdvice(serviceId) {
74697
+ return ` Point it back at your deployed function with \`sinch functions deploy\` or \`sinch voice services update ${serviceId} --webhook-url <url>\`.`;
74698
+ }
74699
+ function defaultVoiceStatePath() {
74700
+ return path5.join(process.cwd(), ".sinch", "tunnel-voice-original.json");
74701
+ }
74702
+ function isTunnelBehavior(behavior, env) {
74703
+ return behavior?.type === "WEBHOOK" && isTunnelUrl(behavior.webhook?.url, env);
74704
+ }
74705
+ function writeVoiceState(stateFile, state) {
74706
+ try {
74707
+ fs4.mkdirSync(path5.dirname(stateFile), { recursive: true });
74708
+ fs4.writeFileSync(stateFile, JSON.stringify(state, null, 2));
74709
+ } catch (error) {
74710
+ console.log(
74711
+ `\u26A0\uFE0F Could not save Voice service state to ${stateFile}: ${error instanceof Error ? error.message : error}`
74712
+ );
74713
+ }
74714
+ }
74715
+ function readVoiceState(stateFile) {
74716
+ try {
74717
+ const parsed = JSON.parse(fs4.readFileSync(stateFile, "utf8"));
74718
+ if (typeof parsed?.serviceId === "string" && typeof parsed.callBehavior?.type === "string") {
74719
+ return parsed;
74720
+ }
74721
+ } catch {
74722
+ }
74723
+ return void 0;
74724
+ }
74725
+ function deleteVoiceState(stateFile) {
74726
+ try {
74727
+ fs4.rmSync(stateFile, { force: true });
74728
+ } catch {
74729
+ }
74730
+ }
74731
+ async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchImpl = globalThis.fetch, config = {}, stateFile = defaultVoiceStatePath()) {
74732
+ const serviceId = env.VOICE_SERVICE_ID;
74733
+ if (!serviceId) return;
74734
+ const request = voiceServiceRequest(env);
74735
+ if (!request) {
74661
74736
  console.log(
74662
74737
  "\u26A0\uFE0F VOICE_SERVICE_ID is set but PROJECT_ID, PROJECT_ID_API_KEY or PROJECT_ID_API_SECRET is missing - skipping Voice service webhook update"
74663
74738
  );
74664
74739
  return;
74665
74740
  }
74666
- const url2 = `${VOICE_V2_HOST}/v2/projects/${encodeURIComponent(projectId)}/services/${encodeURIComponent(serviceId)}`;
74741
+ const url2 = `${request.baseUrl}/${encodeURIComponent(serviceId)}`;
74742
+ const alreadySaved = config.voiceServiceId === serviceId;
74743
+ let original = config.voiceOriginalCallBehavior;
74667
74744
  try {
74745
+ if (!alreadySaved) {
74746
+ original = await resolveVoiceOriginal(
74747
+ url2,
74748
+ request.headers,
74749
+ serviceId,
74750
+ env,
74751
+ fetchImpl,
74752
+ stateFile
74753
+ );
74754
+ }
74668
74755
  const response = await fetchImpl(url2, {
74669
74756
  method: "PATCH",
74670
- headers: {
74671
- Authorization: `Basic ${Buffer.from(`${keyId}:${keySecret}`).toString("base64")}`,
74672
- "Content-Type": "application/json"
74673
- },
74757
+ headers: request.headers,
74674
74758
  body: JSON.stringify({
74675
74759
  callBehavior: { type: "WEBHOOK", webhook: { url: tunnelUrl } }
74676
74760
  })
@@ -74681,6 +74765,8 @@ async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchI
74681
74765
  );
74682
74766
  return;
74683
74767
  }
74768
+ config.voiceServiceId = serviceId;
74769
+ config.voiceOriginalCallBehavior = original;
74684
74770
  console.log(`\u2705 Updated Voice service webhook (${serviceId}) to ${tunnelUrl}`);
74685
74771
  console.log("\u{1F4A1} Call the number bound to this service in Build to test your voice function!");
74686
74772
  } catch (error) {
@@ -74690,6 +74776,88 @@ async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchI
74690
74776
  );
74691
74777
  }
74692
74778
  }
74779
+ async function resolveVoiceOriginal(url2, headers, serviceId, env, fetchImpl, stateFile) {
74780
+ let behavior;
74781
+ try {
74782
+ const response = await fetchImpl(url2, { method: "GET", headers });
74783
+ if (!response.ok) {
74784
+ console.log(
74785
+ `\u26A0\uFE0F Could not read Voice service ${serviceId} (${response.status} ${response.statusText}): its webhook will not be restored when dev stops`
74786
+ );
74787
+ return void 0;
74788
+ }
74789
+ const service = await response.json();
74790
+ behavior = service?.callBehavior;
74791
+ } catch (error) {
74792
+ console.log(
74793
+ `\u26A0\uFE0F Could not read Voice service ${serviceId}: ${error instanceof Error ? error.message : error}: its webhook will not be restored when dev stops`
74794
+ );
74795
+ return void 0;
74796
+ }
74797
+ if (!isTunnelBehavior(behavior, env)) {
74798
+ if (behavior) writeVoiceState(stateFile, { serviceId, callBehavior: behavior });
74799
+ return behavior;
74800
+ }
74801
+ const persisted = readVoiceState(stateFile);
74802
+ if (persisted?.serviceId === serviceId && !isTunnelBehavior(persisted.callBehavior, env)) {
74803
+ console.log(
74804
+ `\u{1F527} Voice service ${serviceId} still points at an earlier tunnel (hot reload?); will restore the webhook saved in ${stateFile}`
74805
+ );
74806
+ return persisted.callBehavior;
74807
+ }
74808
+ console.log(
74809
+ `\u26A0\uFE0F Voice service ${serviceId} already points at a tunnel URL from an earlier dev session (${behavior?.webhook?.url}); it will not be restored to that when dev stops.`
74810
+ );
74811
+ return behavior;
74812
+ }
74813
+ async function cleanupVoiceServiceWebhook(config, env = process.env, fetchImpl = globalThis.fetch, stateFile = defaultVoiceStatePath()) {
74814
+ const serviceId = config.voiceServiceId;
74815
+ if (!serviceId) return;
74816
+ const original = config.voiceOriginalCallBehavior;
74817
+ config.voiceServiceId = void 0;
74818
+ config.voiceOriginalCallBehavior = void 0;
74819
+ if (!original) {
74820
+ deleteVoiceState(stateFile);
74821
+ console.log(
74822
+ `\u26A0\uFE0F Voice service ${serviceId} still points at the tunnel: its previous webhook was not known, so it was not restored.`
74823
+ );
74824
+ console.log(staleVoiceWebhookAdvice(serviceId));
74825
+ return;
74826
+ }
74827
+ if (isTunnelBehavior(original, env)) {
74828
+ deleteVoiceState(stateFile);
74829
+ console.log(
74830
+ `\u26A0\uFE0F Voice service ${serviceId} was not restored: its previous webhook was a stale tunnel URL (${original.webhook?.url}).`
74831
+ );
74832
+ console.log(staleVoiceWebhookAdvice(serviceId));
74833
+ return;
74834
+ }
74835
+ const request = voiceServiceRequest(env);
74836
+ if (!request) return;
74837
+ try {
74838
+ const response = await fetchImpl(`${request.baseUrl}/${encodeURIComponent(serviceId)}`, {
74839
+ method: "PATCH",
74840
+ headers: request.headers,
74841
+ body: JSON.stringify({ callBehavior: original })
74842
+ });
74843
+ if (!response.ok) {
74844
+ console.log(
74845
+ `\u26A0\uFE0F Could not restore Voice service webhook (${serviceId}): ${response.status} ${response.statusText}`
74846
+ );
74847
+ console.log(staleVoiceWebhookAdvice(serviceId));
74848
+ return;
74849
+ }
74850
+ deleteVoiceState(stateFile);
74851
+ const restoredTo = original.type === "WEBHOOK" ? original.webhook?.url : original.type;
74852
+ console.log(`\u{1F504} Restored Voice service webhook (${serviceId}) to: ${restoredTo}`);
74853
+ } catch (error) {
74854
+ console.log(
74855
+ `\u26A0\uFE0F Could not restore Voice service webhook (${serviceId}):`,
74856
+ error instanceof Error ? error.message : error
74857
+ );
74858
+ console.log(staleVoiceWebhookAdvice(serviceId));
74859
+ }
74860
+ }
74693
74861
 
74694
74862
  // src/tunnel/ws-stream.ts
74695
74863
  var UPGRADE_TIMEOUT_MS = 1e4;
@@ -74725,8 +74893,8 @@ var TunnelStreamManager = class {
74725
74893
  this.log(`[WS] Ignoring duplicate ws_open for stream ${id}`);
74726
74894
  return;
74727
74895
  }
74728
- const path6 = message.path ?? "/";
74729
- const url2 = `ws://localhost:${this.localPort}${path6}${message.query ?? ""}`;
74896
+ const path7 = message.path ?? "/";
74897
+ const url2 = `ws://localhost:${this.localPort}${path7}${message.query ?? ""}`;
74730
74898
  const protocols = message.protocol ? message.protocol.split(",").map((p) => p.trim()).filter(Boolean) : [];
74731
74899
  this.log(`[WS] Opening tunnelled WebSocket ${id} to ${url2}`);
74732
74900
  let socket;
@@ -74882,6 +75050,12 @@ function describe(error) {
74882
75050
  return String(error);
74883
75051
  }
74884
75052
 
75053
+ // src/tunnel/url.ts
75054
+ function buildTunnelUrl(publicUrl, tunnelId, path7) {
75055
+ const base = publicUrl.split(/[?#]/, 1)[0].replace(/\/+$/, "");
75056
+ return `${base}${path7 || ""}?tunnel=${tunnelId}`;
75057
+ }
75058
+
74885
75059
  // src/tunnel/index.ts
74886
75060
  var TUNNEL_GATEWAY_DEFAULT = "https://tunnel.fn.sinch.io";
74887
75061
  var TunnelClient = class {
@@ -74897,6 +75071,10 @@ var TunnelClient = class {
74897
75071
  webhookConfig = {};
74898
75072
  welcomeResolver = null;
74899
75073
  streams;
75074
+ /** Set by disconnect(). A reconnect after it would repoint the webhooks cleanup restored. */
75075
+ shuttingDown = false;
75076
+ /** The in-flight configureWebhooks(), so disconnect() can wait for it before restoring. */
75077
+ configuring = null;
74900
75078
  constructor(localPort = 3e3) {
74901
75079
  this.localPort = localPort;
74902
75080
  this.streams = new TunnelStreamManager({
@@ -74940,6 +75118,7 @@ var TunnelClient = class {
74940
75118
  return timestampPart + randomPart;
74941
75119
  }
74942
75120
  async connect() {
75121
+ this.shuttingDown = false;
74943
75122
  if (process.env.SINCH_TUNNEL !== "true") {
74944
75123
  console.log("Tunnel is disabled (set SINCH_TUNNEL=true to enable)");
74945
75124
  return;
@@ -74983,12 +75162,14 @@ var TunnelClient = class {
74983
75162
  console.error("Tunnel connection error:", error.message);
74984
75163
  });
74985
75164
  await welcomePromise;
75165
+ if (this.shuttingDown) return;
74986
75166
  if (!this.tunnelUrl) {
74987
75167
  throw new Error("Did not receive tunnel URL from gateway");
74988
75168
  }
74989
75169
  console.log("Tunnel connected successfully!");
74990
75170
  this.startHeartbeat();
74991
- await this.configureWebhooks();
75171
+ this.configuring = this.configureWebhooks();
75172
+ await this.configuring;
74992
75173
  } catch (error) {
74993
75174
  console.error("Failed to establish tunnel connection:", error.message);
74994
75175
  this.scheduleReconnect();
@@ -75024,11 +75205,11 @@ var TunnelClient = class {
75024
75205
  /**
75025
75206
  * Build a full tunnel URL with optional sub-path and tunnel query param.
75026
75207
  * e.g. buildTunnelUrl('/webhook/conversation') →
75027
- * https://tunnel.fn.sinch.com/ingress/webhook/conversation?tunnel=01KKT...
75208
+ * https://tunnel.fn.sinch.io/ingress/webhook/conversation?tunnel=01KKT...
75209
+ * See ./url.ts for why the welcome URL's own query string is dropped.
75028
75210
  */
75029
- buildTunnelUrl(path6) {
75030
- const base = this.tunnelUrl.replace(/\/$/, "");
75031
- return `${base}${path6 || ""}?tunnel=${this.tunnelId}`;
75211
+ buildTunnelUrl(path7) {
75212
+ return buildTunnelUrl(this.tunnelUrl, this.tunnelId, path7);
75032
75213
  }
75033
75214
  handleWelcomeMessage(message) {
75034
75215
  this.tunnelId = message.tunnelId || null;
@@ -75136,13 +75317,23 @@ var TunnelClient = class {
75136
75317
  }
75137
75318
  }
75138
75319
  /**
75139
- * Cleanup webhooks on disconnect
75320
+ * Restore every webhook the tunnel repointed. Run in parallel: this happens during
75321
+ * shutdown, under a timeout, and the two restores are independent.
75322
+ * The v1 application callback is still not restored (it was never saved).
75140
75323
  */
75141
75324
  async cleanupWebhooks() {
75142
- await cleanupConversationWebhook(this.webhookConfig);
75325
+ await Promise.all([
75326
+ cleanupConversationWebhook(this.webhookConfig),
75327
+ cleanupVoiceServiceWebhook(this.webhookConfig)
75328
+ ]);
75143
75329
  }
75144
75330
  async configureVoiceWebhooks() {
75145
- await configureVoiceServiceWebhook(this.buildTunnelUrl());
75331
+ await configureVoiceServiceWebhook(
75332
+ this.buildTunnelUrl(),
75333
+ process.env,
75334
+ globalThis.fetch,
75335
+ this.webhookConfig
75336
+ );
75146
75337
  try {
75147
75338
  const appKey = process.env.VOICE_APPLICATION_KEY;
75148
75339
  const appSecret = process.env.VOICE_APPLICATION_SECRET;
@@ -75202,6 +75393,7 @@ var TunnelClient = class {
75202
75393
  }
75203
75394
  }
75204
75395
  scheduleReconnect() {
75396
+ if (this.shuttingDown) return;
75205
75397
  if (this.reconnectAttempts >= this.maxReconnectAttempts) {
75206
75398
  console.error("Max reconnection attempts reached. Giving up.");
75207
75399
  return;
@@ -75209,17 +75401,30 @@ var TunnelClient = class {
75209
75401
  this.reconnectAttempts++;
75210
75402
  const delay = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), 3e4);
75211
75403
  console.log(`Attempting to reconnect in ${delay / 1e3} seconds...`);
75212
- setTimeout(() => this.connect(), delay);
75404
+ setTimeout(() => {
75405
+ if (!this.shuttingDown) void this.connect();
75406
+ }, delay);
75213
75407
  }
75408
+ /**
75409
+ * Stop the tunnel and restore every webhook it repointed.
75410
+ *
75411
+ * Order matters (#102 review): stop reconnects and close the socket first, so no new
75412
+ * welcome can start another configure; then wait for any configure already in flight, so
75413
+ * a PATCH that lands late (Ctrl+C between its GET and its PATCH) cannot overwrite the
75414
+ * restore; only then restore.
75415
+ */
75214
75416
  async disconnect() {
75417
+ this.shuttingDown = true;
75215
75418
  this.stopHeartbeat();
75216
75419
  this.streams.closeAll("Tunnel client shutting down");
75217
- await this.cleanupWebhooks();
75218
75420
  if (this.ws) {
75219
75421
  this.ws.close();
75220
75422
  this.ws = null;
75221
75423
  }
75222
75424
  this.isConnected = false;
75425
+ await this.configuring?.catch(() => {
75426
+ });
75427
+ await this.cleanupWebhooks();
75223
75428
  }
75224
75429
  getTunnelUrl() {
75225
75430
  if (!this.tunnelUrl || !this.tunnelId) return null;
@@ -75238,8 +75443,8 @@ function getTunnelClient(localPort = 3e3) {
75238
75443
  }
75239
75444
 
75240
75445
  // src/secrets/index.ts
75241
- import fs4 from "fs";
75242
- import path5 from "path";
75446
+ import fs5 from "fs";
75447
+ import path6 from "path";
75243
75448
  import os from "os";
75244
75449
  import crypto3 from "crypto";
75245
75450
 
@@ -75520,12 +75725,12 @@ var SecretsLoader = class {
75520
75725
  return false;
75521
75726
  }
75522
75727
  try {
75523
- const envPath = path5.join(process.cwd(), ".env");
75524
- if (!fs4.existsSync(envPath)) {
75728
+ const envPath = path6.join(process.cwd(), ".env");
75729
+ if (!fs5.existsSync(envPath)) {
75525
75730
  console.debug("[Secrets] No .env file found, skipping keychain load");
75526
75731
  return false;
75527
75732
  }
75528
- const envContent = fs4.readFileSync(envPath, "utf8");
75733
+ const envContent = fs5.readFileSync(envPath, "utf8");
75529
75734
  const envLines = envContent.replace(/\r\n/g, "\n").split("\n");
75530
75735
  const secretsToLoad = [];
75531
75736
  envLines.forEach((line) => {
@@ -75617,9 +75822,9 @@ var SecretsLoader = class {
75617
75822
  */
75618
75823
  getApplicationKeyFromConfig() {
75619
75824
  try {
75620
- const sinchJsonPath = path5.join(process.cwd(), "sinch.json");
75621
- if (fs4.existsSync(sinchJsonPath)) {
75622
- const sinchConfig = JSON.parse(fs4.readFileSync(sinchJsonPath, "utf8"));
75825
+ const sinchJsonPath = path6.join(process.cwd(), "sinch.json");
75826
+ if (fs5.existsSync(sinchJsonPath)) {
75827
+ const sinchConfig = JSON.parse(fs5.readFileSync(sinchJsonPath, "utf8"));
75623
75828
  return sinchConfig.voiceAppId || sinchConfig.applicationKey || null;
75624
75829
  }
75625
75830
  } catch (error) {
@@ -75632,9 +75837,9 @@ var SecretsLoader = class {
75632
75837
  */
75633
75838
  getFunctionNameFromConfig() {
75634
75839
  try {
75635
- const sinchJsonPath = path5.join(process.cwd(), "sinch.json");
75636
- if (fs4.existsSync(sinchJsonPath)) {
75637
- const sinchConfig = JSON.parse(fs4.readFileSync(sinchJsonPath, "utf8"));
75840
+ const sinchJsonPath = path6.join(process.cwd(), "sinch.json");
75841
+ if (fs5.existsSync(sinchJsonPath)) {
75842
+ const sinchConfig = JSON.parse(fs5.readFileSync(sinchJsonPath, "utf8"));
75638
75843
  return sinchConfig.name || null;
75639
75844
  }
75640
75845
  } catch (error) {
@@ -75651,10 +75856,10 @@ var SecretsLoader = class {
75651
75856
  readProfilePlaintext(field) {
75652
75857
  try {
75653
75858
  const home = os.homedir();
75654
- const metaPath = path5.join(home, ".sinch", "config.json");
75859
+ const metaPath = path6.join(home, ".sinch", "config.json");
75655
75860
  let activeProfile = "default";
75656
- if (fs4.existsSync(metaPath)) {
75657
- const meta = JSON.parse(fs4.readFileSync(metaPath, "utf8"));
75861
+ if (fs5.existsSync(metaPath)) {
75862
+ const meta = JSON.parse(fs5.readFileSync(metaPath, "utf8"));
75658
75863
  if (typeof meta.activeProfile === "string" && meta.activeProfile) {
75659
75864
  activeProfile = meta.activeProfile;
75660
75865
  }
@@ -75662,9 +75867,9 @@ var SecretsLoader = class {
75662
75867
  if (/[\\/]/.test(activeProfile) || activeProfile.includes("..")) {
75663
75868
  return null;
75664
75869
  }
75665
- const profilePath = path5.join(home, ".sinch", "profiles", `${activeProfile}.json`);
75666
- if (!fs4.existsSync(profilePath)) return null;
75667
- const profile = JSON.parse(fs4.readFileSync(profilePath, "utf8"));
75870
+ const profilePath = path6.join(home, ".sinch", "profiles", `${activeProfile}.json`);
75871
+ if (!fs5.existsSync(profilePath)) return null;
75872
+ const profile = JSON.parse(fs5.readFileSync(profilePath, "utf8"));
75668
75873
  const value = profile[field];
75669
75874
  return typeof value === "string" && value.length > 0 ? value : null;
75670
75875
  } catch (err) {
@@ -76214,4 +76419,4 @@ serve-static/index.js:
76214
76419
  * MIT Licensed
76215
76420
  *)
76216
76421
  */
76217
- //# sourceMappingURL=chunk-DHM4MH2A.js.map
76422
+ //# sourceMappingURL=chunk-H2JZGXXT.js.map