@sinch/functions-runtime 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/bin/sinch-runtime.js +81 -14
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/{chunk-W3R4GR3E.js → chunk-DLBCKZ6X.js} +1502 -571
- package/dist/chunk-DLBCKZ6X.js.map +1 -0
- package/dist/index.d.ts +75 -3
- package/dist/index.js +13 -1
- package/dist/voice/v2.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-W3R4GR3E.js.map +0 -1
|
@@ -15630,17 +15630,17 @@ var require_mime_types = __commonJS({
|
|
|
15630
15630
|
}
|
|
15631
15631
|
return exts[0];
|
|
15632
15632
|
}
|
|
15633
|
-
function lookup(
|
|
15634
|
-
if (!
|
|
15633
|
+
function lookup(path7) {
|
|
15634
|
+
if (!path7 || typeof path7 !== "string") {
|
|
15635
15635
|
return false;
|
|
15636
15636
|
}
|
|
15637
|
-
var extension2 = extname("x." +
|
|
15637
|
+
var extension2 = extname("x." + path7).toLowerCase().slice(1);
|
|
15638
15638
|
if (!extension2) {
|
|
15639
15639
|
return false;
|
|
15640
15640
|
}
|
|
15641
15641
|
return exports.types[extension2] || false;
|
|
15642
15642
|
}
|
|
15643
|
-
function populateMaps(extensions,
|
|
15643
|
+
function populateMaps(extensions, types2) {
|
|
15644
15644
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
15645
15645
|
var mime = db[type];
|
|
15646
15646
|
var exts = mime.extensions;
|
|
@@ -15650,14 +15650,14 @@ var require_mime_types = __commonJS({
|
|
|
15650
15650
|
extensions[type] = exts;
|
|
15651
15651
|
for (var i = 0; i < exts.length; i++) {
|
|
15652
15652
|
var extension2 = exts[i];
|
|
15653
|
-
|
|
15653
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
15654
15654
|
const legacyType = _preferredTypeLegacy(
|
|
15655
15655
|
extension2,
|
|
15656
|
-
|
|
15656
|
+
types2[extension2],
|
|
15657
15657
|
type
|
|
15658
15658
|
);
|
|
15659
|
-
if (legacyType !==
|
|
15660
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
15659
|
+
if (legacyType !== types2[extension2]) {
|
|
15660
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
15661
15661
|
}
|
|
15662
15662
|
}
|
|
15663
15663
|
});
|
|
@@ -15763,23 +15763,23 @@ var require_type_is = __commonJS({
|
|
|
15763
15763
|
module.exports.match = mimeMatch;
|
|
15764
15764
|
function typeis(value, types_) {
|
|
15765
15765
|
var i;
|
|
15766
|
-
var
|
|
15766
|
+
var types2 = types_;
|
|
15767
15767
|
var val = tryNormalizeType(value);
|
|
15768
15768
|
if (!val) {
|
|
15769
15769
|
return false;
|
|
15770
15770
|
}
|
|
15771
|
-
if (
|
|
15772
|
-
|
|
15773
|
-
for (i = 0; i <
|
|
15774
|
-
|
|
15771
|
+
if (types2 && !Array.isArray(types2)) {
|
|
15772
|
+
types2 = new Array(arguments.length - 1);
|
|
15773
|
+
for (i = 0; i < types2.length; i++) {
|
|
15774
|
+
types2[i] = arguments[i + 1];
|
|
15775
15775
|
}
|
|
15776
15776
|
}
|
|
15777
|
-
if (!
|
|
15777
|
+
if (!types2 || !types2.length) {
|
|
15778
15778
|
return val;
|
|
15779
15779
|
}
|
|
15780
15780
|
var type;
|
|
15781
|
-
for (i = 0; i <
|
|
15782
|
-
if (mimeMatch(normalize(type =
|
|
15781
|
+
for (i = 0; i < types2.length; i++) {
|
|
15782
|
+
if (mimeMatch(normalize(type = types2[i]), val)) {
|
|
15783
15783
|
return type[0] === "+" || type.indexOf("*") !== -1 ? val : type;
|
|
15784
15784
|
}
|
|
15785
15785
|
}
|
|
@@ -15790,9 +15790,9 @@ var require_type_is = __commonJS({
|
|
|
15790
15790
|
}
|
|
15791
15791
|
function typeofrequest(req, types_) {
|
|
15792
15792
|
if (!hasbody(req)) return null;
|
|
15793
|
-
var
|
|
15793
|
+
var types2 = arguments.length > 2 ? Array.prototype.slice.call(arguments, 1) : types_;
|
|
15794
15794
|
var value = req.headers["content-type"];
|
|
15795
|
-
return typeis(value,
|
|
15795
|
+
return typeis(value, types2);
|
|
15796
15796
|
}
|
|
15797
15797
|
function normalize(type) {
|
|
15798
15798
|
if (typeof type !== "string") {
|
|
@@ -16315,7 +16315,7 @@ var require_object_inspect = __commonJS({
|
|
|
16315
16315
|
} else if (indexOf(seen, obj) >= 0) {
|
|
16316
16316
|
return "[Circular]";
|
|
16317
16317
|
}
|
|
16318
|
-
function
|
|
16318
|
+
function inspect3(value, from, noIndent) {
|
|
16319
16319
|
if (from) {
|
|
16320
16320
|
seen = $arrSlice.call(seen);
|
|
16321
16321
|
seen.push(from);
|
|
@@ -16333,7 +16333,7 @@ var require_object_inspect = __commonJS({
|
|
|
16333
16333
|
}
|
|
16334
16334
|
if (typeof obj === "function" && !isRegExp2(obj)) {
|
|
16335
16335
|
var name = nameOf(obj);
|
|
16336
|
-
var keys = arrObjKeys(obj,
|
|
16336
|
+
var keys = arrObjKeys(obj, inspect3);
|
|
16337
16337
|
return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "");
|
|
16338
16338
|
}
|
|
16339
16339
|
if (isSymbol(obj)) {
|
|
@@ -16357,16 +16357,16 @@ var require_object_inspect = __commonJS({
|
|
|
16357
16357
|
if (obj.length === 0) {
|
|
16358
16358
|
return "[]";
|
|
16359
16359
|
}
|
|
16360
|
-
var xs = arrObjKeys(obj,
|
|
16360
|
+
var xs = arrObjKeys(obj, inspect3);
|
|
16361
16361
|
if (indent && !singleLineValues(xs)) {
|
|
16362
16362
|
return "[" + indentedJoin(xs, indent) + "]";
|
|
16363
16363
|
}
|
|
16364
16364
|
return "[ " + $join.call(xs, ", ") + " ]";
|
|
16365
16365
|
}
|
|
16366
16366
|
if (isError(obj)) {
|
|
16367
|
-
var parts = arrObjKeys(obj,
|
|
16367
|
+
var parts = arrObjKeys(obj, inspect3);
|
|
16368
16368
|
if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) {
|
|
16369
|
-
return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " +
|
|
16369
|
+
return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect3(obj.cause), parts), ", ") + " }";
|
|
16370
16370
|
}
|
|
16371
16371
|
if (parts.length === 0) {
|
|
16372
16372
|
return "[" + String(obj) + "]";
|
|
@@ -16384,7 +16384,7 @@ var require_object_inspect = __commonJS({
|
|
|
16384
16384
|
var mapParts = [];
|
|
16385
16385
|
if (mapForEach) {
|
|
16386
16386
|
mapForEach.call(obj, function(value, key) {
|
|
16387
|
-
mapParts.push(
|
|
16387
|
+
mapParts.push(inspect3(key, obj, true) + " => " + inspect3(value, obj));
|
|
16388
16388
|
});
|
|
16389
16389
|
}
|
|
16390
16390
|
return collectionOf("Map", mapSize.call(obj), mapParts, indent);
|
|
@@ -16393,7 +16393,7 @@ var require_object_inspect = __commonJS({
|
|
|
16393
16393
|
var setParts = [];
|
|
16394
16394
|
if (setForEach) {
|
|
16395
16395
|
setForEach.call(obj, function(value) {
|
|
16396
|
-
setParts.push(
|
|
16396
|
+
setParts.push(inspect3(value, obj));
|
|
16397
16397
|
});
|
|
16398
16398
|
}
|
|
16399
16399
|
return collectionOf("Set", setSize.call(obj), setParts, indent);
|
|
@@ -16408,16 +16408,16 @@ var require_object_inspect = __commonJS({
|
|
|
16408
16408
|
return weakCollectionOf("WeakRef");
|
|
16409
16409
|
}
|
|
16410
16410
|
if (isNumber2(obj)) {
|
|
16411
|
-
return markBoxed(
|
|
16411
|
+
return markBoxed(inspect3(Number(obj)));
|
|
16412
16412
|
}
|
|
16413
16413
|
if (isBigInt(obj)) {
|
|
16414
|
-
return markBoxed(
|
|
16414
|
+
return markBoxed(inspect3(bigIntValueOf.call(obj)));
|
|
16415
16415
|
}
|
|
16416
16416
|
if (isBoolean2(obj)) {
|
|
16417
16417
|
return markBoxed(booleanValueOf.call(obj));
|
|
16418
16418
|
}
|
|
16419
16419
|
if (isString2(obj)) {
|
|
16420
|
-
return markBoxed(
|
|
16420
|
+
return markBoxed(inspect3(String(obj)));
|
|
16421
16421
|
}
|
|
16422
16422
|
if (typeof window !== "undefined" && obj === window) {
|
|
16423
16423
|
return "{ [object Window] }";
|
|
@@ -16426,7 +16426,7 @@ var require_object_inspect = __commonJS({
|
|
|
16426
16426
|
return "{ [object globalThis] }";
|
|
16427
16427
|
}
|
|
16428
16428
|
if (!isDate2(obj) && !isRegExp2(obj)) {
|
|
16429
|
-
var ys = arrObjKeys(obj,
|
|
16429
|
+
var ys = arrObjKeys(obj, inspect3);
|
|
16430
16430
|
var isPlainObject3 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
16431
16431
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
16432
16432
|
var stringTag = !isPlainObject3 && toStringTag2 && Object(obj) === obj && toStringTag2 in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
|
|
@@ -16680,13 +16680,13 @@ var require_object_inspect = __commonJS({
|
|
|
16680
16680
|
var lineJoiner = "\n" + indent.prev + indent.base;
|
|
16681
16681
|
return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev;
|
|
16682
16682
|
}
|
|
16683
|
-
function arrObjKeys(obj,
|
|
16683
|
+
function arrObjKeys(obj, inspect3) {
|
|
16684
16684
|
var isArr = isArray2(obj);
|
|
16685
16685
|
var xs = [];
|
|
16686
16686
|
if (isArr) {
|
|
16687
16687
|
xs.length = obj.length;
|
|
16688
16688
|
for (var i = 0; i < obj.length; i++) {
|
|
16689
|
-
xs[i] = has(obj, i) ?
|
|
16689
|
+
xs[i] = has(obj, i) ? inspect3(obj[i], obj) : "";
|
|
16690
16690
|
}
|
|
16691
16691
|
}
|
|
16692
16692
|
var syms = typeof gOPS === "function" ? gOPS(obj) : [];
|
|
@@ -16707,15 +16707,15 @@ var require_object_inspect = __commonJS({
|
|
|
16707
16707
|
if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) {
|
|
16708
16708
|
continue;
|
|
16709
16709
|
} else if ($test.call(/[^\w$]/, key)) {
|
|
16710
|
-
xs.push(
|
|
16710
|
+
xs.push(inspect3(key, obj) + ": " + inspect3(obj[key], obj));
|
|
16711
16711
|
} else {
|
|
16712
|
-
xs.push(key + ": " +
|
|
16712
|
+
xs.push(key + ": " + inspect3(obj[key], obj));
|
|
16713
16713
|
}
|
|
16714
16714
|
}
|
|
16715
16715
|
if (typeof gOPS === "function") {
|
|
16716
16716
|
for (var j = 0; j < syms.length; j++) {
|
|
16717
16717
|
if (isEnumerable.call(obj, syms[j])) {
|
|
16718
|
-
xs.push("[" +
|
|
16718
|
+
xs.push("[" + inspect3(syms[j]) + "]: " + inspect3(obj[syms[j]], obj));
|
|
16719
16719
|
}
|
|
16720
16720
|
}
|
|
16721
16721
|
}
|
|
@@ -16728,7 +16728,7 @@ var require_object_inspect = __commonJS({
|
|
|
16728
16728
|
var require_side_channel_list = __commonJS({
|
|
16729
16729
|
"../../node_modules/side-channel-list/index.js"(exports, module) {
|
|
16730
16730
|
"use strict";
|
|
16731
|
-
var
|
|
16731
|
+
var inspect3 = require_object_inspect();
|
|
16732
16732
|
var $TypeError = require_type();
|
|
16733
16733
|
var listGetNode = function(list, key, isDelete) {
|
|
16734
16734
|
var prev = list;
|
|
@@ -16782,7 +16782,7 @@ var require_side_channel_list = __commonJS({
|
|
|
16782
16782
|
var channel = {
|
|
16783
16783
|
assert: function(key) {
|
|
16784
16784
|
if (!channel.has(key)) {
|
|
16785
|
-
throw new $TypeError("Side channel does not contain " +
|
|
16785
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
16786
16786
|
}
|
|
16787
16787
|
},
|
|
16788
16788
|
"delete": function(key) {
|
|
@@ -17642,7 +17642,7 @@ var require_side_channel_map = __commonJS({
|
|
|
17642
17642
|
"use strict";
|
|
17643
17643
|
var GetIntrinsic = require_get_intrinsic();
|
|
17644
17644
|
var callBound = require_call_bound();
|
|
17645
|
-
var
|
|
17645
|
+
var inspect3 = require_object_inspect();
|
|
17646
17646
|
var $TypeError = require_type();
|
|
17647
17647
|
var $Map = GetIntrinsic("%Map%", true);
|
|
17648
17648
|
var $mapGet = callBound("Map.prototype.get", true);
|
|
@@ -17656,7 +17656,7 @@ var require_side_channel_map = __commonJS({
|
|
|
17656
17656
|
var channel = {
|
|
17657
17657
|
assert: function(key) {
|
|
17658
17658
|
if (!channel.has(key)) {
|
|
17659
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17659
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17660
17660
|
}
|
|
17661
17661
|
},
|
|
17662
17662
|
"delete": function(key) {
|
|
@@ -17698,7 +17698,7 @@ var require_side_channel_weakmap = __commonJS({
|
|
|
17698
17698
|
"use strict";
|
|
17699
17699
|
var GetIntrinsic = require_get_intrinsic();
|
|
17700
17700
|
var callBound = require_call_bound();
|
|
17701
|
-
var
|
|
17701
|
+
var inspect3 = require_object_inspect();
|
|
17702
17702
|
var getSideChannelMap = require_side_channel_map();
|
|
17703
17703
|
var $TypeError = require_type();
|
|
17704
17704
|
var $WeakMap = GetIntrinsic("%WeakMap%", true);
|
|
@@ -17714,7 +17714,7 @@ var require_side_channel_weakmap = __commonJS({
|
|
|
17714
17714
|
var channel = {
|
|
17715
17715
|
assert: function(key) {
|
|
17716
17716
|
if (!channel.has(key)) {
|
|
17717
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17717
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17718
17718
|
}
|
|
17719
17719
|
},
|
|
17720
17720
|
"delete": function(key) {
|
|
@@ -17770,7 +17770,7 @@ var require_side_channel = __commonJS({
|
|
|
17770
17770
|
"../../node_modules/side-channel/index.js"(exports, module) {
|
|
17771
17771
|
"use strict";
|
|
17772
17772
|
var $TypeError = require_type();
|
|
17773
|
-
var
|
|
17773
|
+
var inspect3 = require_object_inspect();
|
|
17774
17774
|
var getSideChannelList = require_side_channel_list();
|
|
17775
17775
|
var getSideChannelMap = require_side_channel_map();
|
|
17776
17776
|
var getSideChannelWeakMap = require_side_channel_weakmap();
|
|
@@ -17780,7 +17780,7 @@ var require_side_channel = __commonJS({
|
|
|
17780
17780
|
var channel = {
|
|
17781
17781
|
assert: function(key) {
|
|
17782
17782
|
if (!channel.has(key)) {
|
|
17783
|
-
throw new $TypeError("Side channel does not contain " +
|
|
17783
|
+
throw new $TypeError("Side channel does not contain " + inspect3(key));
|
|
17784
17784
|
}
|
|
17785
17785
|
},
|
|
17786
17786
|
"delete": function(key) {
|
|
@@ -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
|
|
19081
|
-
var
|
|
19082
|
-
var dirname2 =
|
|
19083
|
-
var basename2 =
|
|
19084
|
-
var extname =
|
|
19085
|
-
var join3 =
|
|
19086
|
-
var 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
|
|
19115
|
+
var path8;
|
|
19116
19116
|
var roots = [].concat(this.root);
|
|
19117
19117
|
debug('lookup "%s"', name);
|
|
19118
|
-
for (var i = 0; i < roots.length && !
|
|
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
|
-
|
|
19123
|
+
path8 = this.resolve(dir, file);
|
|
19124
19124
|
}
|
|
19125
|
-
return
|
|
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
|
|
19148
|
-
var stat = tryStat(
|
|
19147
|
+
var path8 = join3(dir, file);
|
|
19148
|
+
var stat = tryStat(path8);
|
|
19149
19149
|
if (stat && stat.isFile()) {
|
|
19150
|
-
return
|
|
19150
|
+
return path8;
|
|
19151
19151
|
}
|
|
19152
|
-
|
|
19153
|
-
stat = tryStat(
|
|
19152
|
+
path8 = join3(dir, basename2(file, ext), "index" + ext);
|
|
19153
|
+
stat = tryStat(path8);
|
|
19154
19154
|
if (stat && stat.isFile()) {
|
|
19155
|
-
return
|
|
19155
|
+
return path8;
|
|
19156
19156
|
}
|
|
19157
19157
|
};
|
|
19158
|
-
function tryStat(
|
|
19159
|
-
debug('stat "%s"',
|
|
19158
|
+
function tryStat(path8) {
|
|
19159
|
+
debug('stat "%s"', path8);
|
|
19160
19160
|
try {
|
|
19161
|
-
return
|
|
19161
|
+
return fs6.statSync(path8);
|
|
19162
19162
|
} catch (e) {
|
|
19163
19163
|
return void 0;
|
|
19164
19164
|
}
|
|
@@ -19310,17 +19310,17 @@ var require_mime_types2 = __commonJS({
|
|
|
19310
19310
|
}
|
|
19311
19311
|
return exts[0];
|
|
19312
19312
|
}
|
|
19313
|
-
function lookup(
|
|
19314
|
-
if (!
|
|
19313
|
+
function lookup(path7) {
|
|
19314
|
+
if (!path7 || typeof path7 !== "string") {
|
|
19315
19315
|
return false;
|
|
19316
19316
|
}
|
|
19317
|
-
var extension2 = extname("x." +
|
|
19317
|
+
var extension2 = extname("x." + path7).toLowerCase().slice(1);
|
|
19318
19318
|
if (!extension2) {
|
|
19319
19319
|
return false;
|
|
19320
19320
|
}
|
|
19321
19321
|
return exports.types[extension2] || false;
|
|
19322
19322
|
}
|
|
19323
|
-
function populateMaps(extensions,
|
|
19323
|
+
function populateMaps(extensions, types2) {
|
|
19324
19324
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
19325
19325
|
var mime = db[type];
|
|
19326
19326
|
var exts = mime.extensions;
|
|
@@ -19330,14 +19330,14 @@ var require_mime_types2 = __commonJS({
|
|
|
19330
19330
|
extensions[type] = exts;
|
|
19331
19331
|
for (var i = 0; i < exts.length; i++) {
|
|
19332
19332
|
var extension2 = exts[i];
|
|
19333
|
-
|
|
19333
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
19334
19334
|
const legacyType = _preferredTypeLegacy(
|
|
19335
19335
|
extension2,
|
|
19336
|
-
|
|
19336
|
+
types2[extension2],
|
|
19337
19337
|
type
|
|
19338
19338
|
);
|
|
19339
|
-
if (legacyType !==
|
|
19340
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
19339
|
+
if (legacyType !== types2[extension2]) {
|
|
19340
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
19341
19341
|
}
|
|
19342
19342
|
}
|
|
19343
19343
|
});
|
|
@@ -20206,8 +20206,8 @@ var require_utils3 = __commonJS({
|
|
|
20206
20206
|
exports.normalizeType = function(type) {
|
|
20207
20207
|
return ~type.indexOf("/") ? acceptParams(type) : { value: mime.lookup(type) || "application/octet-stream", params: {} };
|
|
20208
20208
|
};
|
|
20209
|
-
exports.normalizeTypes = function(
|
|
20210
|
-
return
|
|
20209
|
+
exports.normalizeTypes = function(types2) {
|
|
20210
|
+
return types2.map(exports.normalizeType);
|
|
20211
20211
|
};
|
|
20212
20212
|
function acceptParams(str) {
|
|
20213
20213
|
var length = str.length;
|
|
@@ -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
|
|
20514
|
+
let path7 = token.value;
|
|
20515
20515
|
let cur = tokens[pos];
|
|
20516
20516
|
while (cur.type === "char" || cur.type === "escape") {
|
|
20517
|
-
|
|
20517
|
+
path7 += cur.value;
|
|
20518
20518
|
cur = tokens[++pos];
|
|
20519
20519
|
}
|
|
20520
20520
|
output.push({
|
|
20521
20521
|
type: "text",
|
|
20522
|
-
value: encodePath(
|
|
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(
|
|
20546
|
+
function compile(path7, options = {}) {
|
|
20547
20547
|
const { encode: encode3 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
20548
|
-
const data = typeof
|
|
20548
|
+
const data = typeof path7 === "object" ? path7 : parse2(path7, options);
|
|
20549
20549
|
const fn = tokensToFunction(data.tokens, delimiter, encode3);
|
|
20550
|
-
return function
|
|
20551
|
-
const [
|
|
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
|
|
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(
|
|
20611
|
+
function match(path7, options = {}) {
|
|
20612
20612
|
const { decode = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
|
|
20613
|
-
const { regexp, keys } = pathToRegexp(
|
|
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
|
|
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:
|
|
20634
|
+
return { path: path8, params };
|
|
20635
20635
|
};
|
|
20636
20636
|
}
|
|
20637
|
-
function pathToRegexp(
|
|
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(
|
|
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,19 +20769,19 @@ 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(
|
|
20772
|
+
function Layer(path7, options, fn) {
|
|
20773
20773
|
if (!(this instanceof Layer)) {
|
|
20774
|
-
return new Layer(
|
|
20774
|
+
return new Layer(path7, options, fn);
|
|
20775
20775
|
}
|
|
20776
|
-
debug("new %o",
|
|
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 =
|
|
20784
|
-
function
|
|
20783
|
+
this.slash = path7 === "/" && opts.end === false;
|
|
20784
|
+
function matcher2(_path) {
|
|
20785
20785
|
if (_path instanceof RegExp) {
|
|
20786
20786
|
const keys = [];
|
|
20787
20787
|
let name = 0;
|
|
@@ -20819,7 +20819,7 @@ var require_layer = __commonJS({
|
|
|
20819
20819
|
decode: decodeParam
|
|
20820
20820
|
});
|
|
20821
20821
|
}
|
|
20822
|
-
this.matchers = Array.isArray(
|
|
20822
|
+
this.matchers = Array.isArray(path7) ? path7.map(matcher2) : [matcher2(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(
|
|
20862
|
+
Layer.prototype.match = function match(path7) {
|
|
20863
20863
|
let match2;
|
|
20864
|
-
if (
|
|
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](
|
|
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(
|
|
20901
|
-
if (
|
|
20902
|
-
return
|
|
20900
|
+
function loosen(path7) {
|
|
20901
|
+
if (path7 instanceof RegExp || path7 === "/") {
|
|
20902
|
+
return path7;
|
|
20903
20903
|
}
|
|
20904
|
-
return Array.isArray(
|
|
20904
|
+
return Array.isArray(path7) ? path7.map(function(p) {
|
|
20905
20905
|
return loosen(p);
|
|
20906
|
-
}) : String(
|
|
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(
|
|
20923
|
-
debug("new %o",
|
|
20924
|
-
this.path =
|
|
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
|
|
21133
|
-
if (
|
|
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,
|
|
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,
|
|
21179
|
+
trimPrefix(layer, layerError, layerPath, path7);
|
|
21180
21180
|
}
|
|
21181
21181
|
sync = 0;
|
|
21182
21182
|
});
|
|
21183
21183
|
}
|
|
21184
|
-
function trimPrefix(layer, layerError, layerPath,
|
|
21184
|
+
function trimPrefix(layer, layerError, layerPath, path7) {
|
|
21185
21185
|
if (layerPath.length !== 0) {
|
|
21186
|
-
if (layerPath !==
|
|
21186
|
+
if (layerPath !== path7.substring(0, layerPath.length)) {
|
|
21187
21187
|
next(layerError);
|
|
21188
21188
|
return;
|
|
21189
21189
|
}
|
|
21190
|
-
const c =
|
|
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
|
|
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
|
-
|
|
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",
|
|
21235
|
-
const layer = new Layer(
|
|
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(
|
|
21246
|
-
const route2 = new Route(
|
|
21247
|
-
const layer = new Layer(
|
|
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(
|
|
21261
|
-
const route = this.route(
|
|
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,
|
|
21290
|
+
function matchLayer(layer, path7) {
|
|
21291
21291
|
try {
|
|
21292
|
-
return layer.match(
|
|
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
|
|
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
|
-
|
|
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(
|
|
21538
|
+
return router.use(path7, fn2);
|
|
21539
21539
|
}
|
|
21540
|
-
debug(".use app under %s",
|
|
21541
|
-
fn2.mountpath =
|
|
21540
|
+
debug(".use app under %s", path7);
|
|
21541
|
+
fn2.mountpath = path7;
|
|
21542
21542
|
fn2.parent = this;
|
|
21543
|
-
router.use(
|
|
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(
|
|
21556
|
-
return this.router.route(
|
|
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
|
|
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(
|
|
21615
|
+
app[method] = function(path7) {
|
|
21616
21616
|
if (method === "get" && arguments.length === 1) {
|
|
21617
|
-
return this.set(
|
|
21617
|
+
return this.set(path7);
|
|
21618
21618
|
}
|
|
21619
|
-
var route = this.route(
|
|
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(
|
|
21625
|
-
var route = this.route(
|
|
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,17 +22302,17 @@ var require_mime_types3 = __commonJS({
|
|
|
22302
22302
|
}
|
|
22303
22303
|
return exts[0];
|
|
22304
22304
|
}
|
|
22305
|
-
function lookup(
|
|
22306
|
-
if (!
|
|
22305
|
+
function lookup(path7) {
|
|
22306
|
+
if (!path7 || typeof path7 !== "string") {
|
|
22307
22307
|
return false;
|
|
22308
22308
|
}
|
|
22309
|
-
var extension2 = extname("x." +
|
|
22309
|
+
var extension2 = extname("x." + path7).toLowerCase().slice(1);
|
|
22310
22310
|
if (!extension2) {
|
|
22311
22311
|
return false;
|
|
22312
22312
|
}
|
|
22313
22313
|
return exports.types[extension2] || false;
|
|
22314
22314
|
}
|
|
22315
|
-
function populateMaps(extensions,
|
|
22315
|
+
function populateMaps(extensions, types2) {
|
|
22316
22316
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
22317
22317
|
var mime = db[type];
|
|
22318
22318
|
var exts = mime.extensions;
|
|
@@ -22322,14 +22322,14 @@ var require_mime_types3 = __commonJS({
|
|
|
22322
22322
|
extensions[type] = exts;
|
|
22323
22323
|
for (var i = 0; i < exts.length; i++) {
|
|
22324
22324
|
var extension2 = exts[i];
|
|
22325
|
-
|
|
22325
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
22326
22326
|
const legacyType = _preferredTypeLegacy(
|
|
22327
22327
|
extension2,
|
|
22328
|
-
|
|
22328
|
+
types2[extension2],
|
|
22329
22329
|
type
|
|
22330
22330
|
);
|
|
22331
|
-
if (legacyType !==
|
|
22332
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
22331
|
+
if (legacyType !== types2[extension2]) {
|
|
22332
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
22333
22333
|
}
|
|
22334
22334
|
}
|
|
22335
22335
|
});
|
|
@@ -22366,23 +22366,23 @@ var require_accepts = __commonJS({
|
|
|
22366
22366
|
this.negotiator = new Negotiator(req);
|
|
22367
22367
|
}
|
|
22368
22368
|
Accepts.prototype.type = Accepts.prototype.types = function(types_) {
|
|
22369
|
-
var
|
|
22370
|
-
if (
|
|
22371
|
-
|
|
22372
|
-
for (var i = 0; i <
|
|
22373
|
-
|
|
22369
|
+
var types2 = types_;
|
|
22370
|
+
if (types2 && !Array.isArray(types2)) {
|
|
22371
|
+
types2 = new Array(arguments.length);
|
|
22372
|
+
for (var i = 0; i < types2.length; i++) {
|
|
22373
|
+
types2[i] = arguments[i];
|
|
22374
22374
|
}
|
|
22375
22375
|
}
|
|
22376
|
-
if (!
|
|
22376
|
+
if (!types2 || types2.length === 0) {
|
|
22377
22377
|
return this.negotiator.mediaTypes();
|
|
22378
22378
|
}
|
|
22379
22379
|
if (!this.headers.accept) {
|
|
22380
|
-
return
|
|
22380
|
+
return types2[0];
|
|
22381
22381
|
}
|
|
22382
|
-
var mimes =
|
|
22382
|
+
var mimes = types2.map(extToMime);
|
|
22383
22383
|
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime));
|
|
22384
22384
|
var first = accepts[0];
|
|
22385
|
-
return first ?
|
|
22385
|
+
return first ? types2[mimes.indexOf(first)] : false;
|
|
22386
22386
|
};
|
|
22387
22387
|
Accepts.prototype.encoding = Accepts.prototype.encodings = function(encodings_) {
|
|
22388
22388
|
var encodings = encodings_;
|
|
@@ -22643,9 +22643,9 @@ var require_request = __commonJS({
|
|
|
22643
22643
|
var querystring = parse2(this).query;
|
|
22644
22644
|
return queryparse(querystring);
|
|
22645
22645
|
});
|
|
22646
|
-
req.is = function is(
|
|
22647
|
-
var arr =
|
|
22648
|
-
if (!Array.isArray(
|
|
22646
|
+
req.is = function is(types2) {
|
|
22647
|
+
var arr = types2;
|
|
22648
|
+
if (!Array.isArray(types2)) {
|
|
22649
22649
|
arr = new Array(arguments.length);
|
|
22650
22650
|
for (var i = 0; i < arr.length; i++) {
|
|
22651
22651
|
arr[i] = arguments[i];
|
|
@@ -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
|
|
22686
|
+
defineGetter(req, "path", function path7() {
|
|
22687
22687
|
return parse2(this).pathname;
|
|
22688
22688
|
});
|
|
22689
22689
|
defineGetter(req, "host", function host() {
|
|
@@ -23182,17 +23182,17 @@ var require_mime_types4 = __commonJS({
|
|
|
23182
23182
|
}
|
|
23183
23183
|
return exts[0];
|
|
23184
23184
|
}
|
|
23185
|
-
function lookup(
|
|
23186
|
-
if (!
|
|
23185
|
+
function lookup(path7) {
|
|
23186
|
+
if (!path7 || typeof path7 !== "string") {
|
|
23187
23187
|
return false;
|
|
23188
23188
|
}
|
|
23189
|
-
var extension2 = extname("x." +
|
|
23189
|
+
var extension2 = extname("x." + path7).toLowerCase().slice(1);
|
|
23190
23190
|
if (!extension2) {
|
|
23191
23191
|
return false;
|
|
23192
23192
|
}
|
|
23193
23193
|
return exports.types[extension2] || false;
|
|
23194
23194
|
}
|
|
23195
|
-
function populateMaps(extensions,
|
|
23195
|
+
function populateMaps(extensions, types2) {
|
|
23196
23196
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
23197
23197
|
var mime = db[type];
|
|
23198
23198
|
var exts = mime.extensions;
|
|
@@ -23202,14 +23202,14 @@ var require_mime_types4 = __commonJS({
|
|
|
23202
23202
|
extensions[type] = exts;
|
|
23203
23203
|
for (var i = 0; i < exts.length; i++) {
|
|
23204
23204
|
var extension2 = exts[i];
|
|
23205
|
-
|
|
23205
|
+
types2[extension2] = _preferredType(extension2, types2[extension2], type);
|
|
23206
23206
|
const legacyType = _preferredTypeLegacy(
|
|
23207
23207
|
extension2,
|
|
23208
|
-
|
|
23208
|
+
types2[extension2],
|
|
23209
23209
|
type
|
|
23210
23210
|
);
|
|
23211
|
-
if (legacyType !==
|
|
23212
|
-
exports._extensionConflicts.push([extension2, legacyType,
|
|
23211
|
+
if (legacyType !== types2[extension2]) {
|
|
23212
|
+
exports._extensionConflicts.push([extension2, legacyType, types2[extension2]]);
|
|
23213
23213
|
}
|
|
23214
23214
|
}
|
|
23215
23215
|
});
|
|
@@ -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
|
|
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
|
|
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 =
|
|
23254
|
-
var join3 =
|
|
23255
|
-
var normalize =
|
|
23256
|
-
var resolve =
|
|
23257
|
-
var 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,
|
|
23263
|
-
return new SendStream(req,
|
|
23262
|
+
function send(req, path8, options) {
|
|
23263
|
+
return new SendStream(req, path8, options);
|
|
23264
23264
|
}
|
|
23265
|
-
function SendStream(req,
|
|
23265
|
+
function SendStream(req, path8, options) {
|
|
23266
23266
|
Stream2.call(this);
|
|
23267
23267
|
var opts = options || {};
|
|
23268
23268
|
this.options = opts;
|
|
23269
|
-
this.path =
|
|
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(
|
|
23383
|
+
SendStream.prototype.redirect = function redirect(path8) {
|
|
23384
23384
|
var res = this.res;
|
|
23385
23385
|
if (hasListeners(this, "directory")) {
|
|
23386
|
-
this.emit("directory", res,
|
|
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
|
|
23407
|
-
if (
|
|
23406
|
+
var path8 = decode(this.path);
|
|
23407
|
+
if (path8 === -1) {
|
|
23408
23408
|
this.error(400);
|
|
23409
23409
|
return res;
|
|
23410
23410
|
}
|
|
23411
|
-
if (~
|
|
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 (
|
|
23418
|
-
|
|
23417
|
+
if (path8) {
|
|
23418
|
+
path8 = normalize("." + sep + path8);
|
|
23419
23419
|
}
|
|
23420
|
-
if (UP_PATH_REGEXP.test(
|
|
23421
|
-
debug('malicious path "%s"',
|
|
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 =
|
|
23426
|
-
|
|
23425
|
+
parts = path8.split(sep);
|
|
23426
|
+
path8 = normalize(join3(root, path8));
|
|
23427
23427
|
} else {
|
|
23428
|
-
if (UP_PATH_REGEXP.test(
|
|
23429
|
-
debug('malicious path "%s"',
|
|
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(
|
|
23434
|
-
|
|
23433
|
+
parts = normalize(path8).split(sep);
|
|
23434
|
+
path8 = resolve(path8);
|
|
23435
23435
|
}
|
|
23436
23436
|
if (containsDotFile(parts)) {
|
|
23437
|
-
debug('%s dotfile "%s"', this._dotfiles,
|
|
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(
|
|
23451
|
+
this.sendIndex(path8);
|
|
23452
23452
|
return res;
|
|
23453
23453
|
}
|
|
23454
|
-
this.sendFile(
|
|
23454
|
+
this.sendFile(path8);
|
|
23455
23455
|
return res;
|
|
23456
23456
|
};
|
|
23457
|
-
SendStream.prototype.send = function send2(
|
|
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"',
|
|
23470
|
-
this.setHeader(
|
|
23471
|
-
this.type(
|
|
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(
|
|
23520
|
+
this.stream(path8, opts);
|
|
23521
23521
|
};
|
|
23522
|
-
SendStream.prototype.sendFile = function sendFile(
|
|
23522
|
+
SendStream.prototype.sendFile = function sendFile(path8) {
|
|
23523
23523
|
var i = 0;
|
|
23524
23524
|
var self2 = this;
|
|
23525
|
-
debug('stat "%s"',
|
|
23526
|
-
|
|
23527
|
-
var pathEndsWithSep =
|
|
23528
|
-
if (err && err.code === "ENOENT" && !extname(
|
|
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(
|
|
23532
|
+
if (stat.isDirectory()) return self2.redirect(path8);
|
|
23533
23533
|
if (pathEndsWithSep) return self2.error(404);
|
|
23534
|
-
self2.emit("file",
|
|
23535
|
-
self2.send(
|
|
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 =
|
|
23541
|
+
var p = path8 + "." + self2._extensions[i++];
|
|
23542
23542
|
debug('stat "%s"', p);
|
|
23543
|
-
|
|
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(
|
|
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(
|
|
23559
|
+
var p = join3(path8, self2._index[i]);
|
|
23560
23560
|
debug('stat "%s"', p);
|
|
23561
|
-
|
|
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(
|
|
23570
|
+
SendStream.prototype.stream = function stream5(path8, options) {
|
|
23571
23571
|
var self2 = this;
|
|
23572
23572
|
var res = this.res;
|
|
23573
|
-
var stream6 =
|
|
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(
|
|
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(
|
|
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(
|
|
23596
|
+
SendStream.prototype.setHeader = function setHeader(path8, stat) {
|
|
23597
23597
|
var res = this.res;
|
|
23598
|
-
this.emit("headers", res,
|
|
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(
|
|
23656
|
+
function decode(path8) {
|
|
23657
23657
|
try {
|
|
23658
|
-
return decodeURIComponent(
|
|
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
|
|
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 =
|
|
23812
|
-
var 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(
|
|
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 (!
|
|
23964
|
+
if (!path8) {
|
|
23965
23965
|
throw new TypeError("path argument is required to res.sendFile");
|
|
23966
23966
|
}
|
|
23967
|
-
if (typeof
|
|
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(
|
|
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(
|
|
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(
|
|
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 ||
|
|
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(
|
|
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
|
|
24302
|
-
if (
|
|
24303
|
-
|
|
24301
|
+
var path7 = parseUrl2(req).pathname;
|
|
24302
|
+
if (path7 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
24303
|
+
path7 = "";
|
|
24304
24304
|
}
|
|
24305
|
-
var stream5 = send(req,
|
|
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
|
|
27953
|
-
if (
|
|
27952
|
+
const path7 = url2.path;
|
|
27953
|
+
if (path7.length === 0) {
|
|
27954
27954
|
return;
|
|
27955
27955
|
}
|
|
27956
|
-
if (url2.scheme === "file" &&
|
|
27956
|
+
if (url2.scheme === "file" && path7.length === 1 && isNormalizedWindowsDriveLetter(path7[0])) {
|
|
27957
27957
|
return;
|
|
27958
27958
|
}
|
|
27959
|
-
|
|
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,
|
|
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:
|
|
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,
|
|
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,
|
|
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,
|
|
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"]}`,
|
|
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,17 +44293,17 @@ var require_mime_types5 = __commonJS({
|
|
|
44293
44293
|
}
|
|
44294
44294
|
return exts[0];
|
|
44295
44295
|
}
|
|
44296
|
-
function lookup(
|
|
44297
|
-
if (!
|
|
44296
|
+
function lookup(path7) {
|
|
44297
|
+
if (!path7 || typeof path7 !== "string") {
|
|
44298
44298
|
return false;
|
|
44299
44299
|
}
|
|
44300
|
-
var extension2 = extname("x." +
|
|
44300
|
+
var extension2 = extname("x." + path7).toLowerCase().substr(1);
|
|
44301
44301
|
if (!extension2) {
|
|
44302
44302
|
return false;
|
|
44303
44303
|
}
|
|
44304
44304
|
return exports.types[extension2] || false;
|
|
44305
44305
|
}
|
|
44306
|
-
function populateMaps(extensions,
|
|
44306
|
+
function populateMaps(extensions, types2) {
|
|
44307
44307
|
var preference = ["nginx", "apache", void 0, "iana"];
|
|
44308
44308
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
44309
44309
|
var mime = db[type];
|
|
@@ -44314,14 +44314,14 @@ var require_mime_types5 = __commonJS({
|
|
|
44314
44314
|
extensions[type] = exts;
|
|
44315
44315
|
for (var i = 0; i < exts.length; i++) {
|
|
44316
44316
|
var extension2 = exts[i];
|
|
44317
|
-
if (
|
|
44318
|
-
var from = preference.indexOf(db[
|
|
44317
|
+
if (types2[extension2]) {
|
|
44318
|
+
var from = preference.indexOf(db[types2[extension2]].source);
|
|
44319
44319
|
var to = preference.indexOf(mime.source);
|
|
44320
|
-
if (
|
|
44320
|
+
if (types2[extension2] !== "application/octet-stream" && (from > to || from === to && types2[extension2].substr(0, 12) === "application/")) {
|
|
44321
44321
|
continue;
|
|
44322
44322
|
}
|
|
44323
44323
|
}
|
|
44324
|
-
|
|
44324
|
+
types2[extension2] = type;
|
|
44325
44325
|
}
|
|
44326
44326
|
});
|
|
44327
44327
|
}
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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 =
|
|
44740
|
+
filename = path7.normalize(options.filepath).replace(/\\/g, "/");
|
|
44741
44741
|
} else if (options.filename || value && (value.name || value.path)) {
|
|
44742
|
-
filename =
|
|
44742
|
+
filename = path7.basename(options.filename || value && (value.name || value.path));
|
|
44743
44743
|
} else if (value && value.readable && hasOwn(value, "httpVersion")) {
|
|
44744
|
-
filename =
|
|
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
|
|
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",
|
|
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,
|
|
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,
|
|
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
|
|
49552
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49553
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
49579
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49580
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
49602
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49603
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
49685
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49686
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49709
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49710
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49734
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49735
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49765
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49766
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49789
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49790
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49813
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49814
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49837
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49838
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49862
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49863
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49893
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49894
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49917
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49918
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PUT", getParams, headers, body || void 0,
|
|
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
|
|
49945
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49946
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
49986
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
49987
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
50011
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
50012
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
50043
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
50044
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
50067
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
50068
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
50092
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
50093
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
50117
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
50118
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
51316
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51317
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
51339
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51340
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
51362
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51363
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
51385
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51386
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body || void 0,
|
|
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
|
|
51408
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51409
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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
|
|
51431
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51432
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body || void 0,
|
|
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,
|
|
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,
|
|
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
|
|
51613
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51614
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body,
|
|
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
|
|
51636
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51637
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body,
|
|
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
|
|
51659
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51660
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "POST", getParams, headers, body,
|
|
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
|
|
51741
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51742
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
51764
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51765
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body,
|
|
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
|
|
51787
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51788
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body,
|
|
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
|
|
51879
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51880
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "GET", getParams, headers, body || void 0,
|
|
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
|
|
51902
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51903
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body,
|
|
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
|
|
51925
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51926
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "DELETE", getParams, headers, body,
|
|
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
|
|
51948
|
-
const basePathUrl = this.client.apiClientOptions.hostname +
|
|
51949
|
-
const requestOptions = await this.client.prepareOptions(basePathUrl, "PATCH", getParams, headers, body,
|
|
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,
|
|
@@ -59157,7 +59157,9 @@ function createConnectAgentAction(provider, agentId, options) {
|
|
|
59157
59157
|
transport,
|
|
59158
59158
|
...options?.cli && { cli: options.cli },
|
|
59159
59159
|
...options?.maxDuration !== void 0 && { maxDuration: options.maxDuration },
|
|
59160
|
-
...options?.suppressCallbacks !== void 0 && {
|
|
59160
|
+
...options?.suppressCallbacks !== void 0 && {
|
|
59161
|
+
suppressCallbacks: options.suppressCallbacks
|
|
59162
|
+
},
|
|
59161
59163
|
...callHeaders2 && { callHeaders: callHeaders2 }
|
|
59162
59164
|
};
|
|
59163
59165
|
}
|
|
@@ -59886,7 +59888,8 @@ var UniversalConfig = class {
|
|
|
59886
59888
|
secrets: {},
|
|
59887
59889
|
hasApplicationCredentials: !!this.getApplicationCredentials()
|
|
59888
59890
|
};
|
|
59889
|
-
for (const
|
|
59891
|
+
for (const key of Object.getOwnPropertyNames(this.env)) {
|
|
59892
|
+
const value = this.env[key];
|
|
59890
59893
|
if (secretKeys.some((secretKey) => key.includes(secretKey))) {
|
|
59891
59894
|
summary.secrets[key] = value ? "[REDACTED]" : "[NOT SET]";
|
|
59892
59895
|
} else if (["NODE_ENV", "PORT", "SINCH_REGION"].includes(key)) {
|
|
@@ -60039,23 +60042,23 @@ var HttpTransport = class {
|
|
|
60039
60042
|
return { transport: "HttpTransport", projectId: this.projectId, host: this.host };
|
|
60040
60043
|
}
|
|
60041
60044
|
async createCall(body) {
|
|
60042
|
-
const
|
|
60043
|
-
const response = await this.request("POST",
|
|
60045
|
+
const path7 = this.serviceId ? `calls?serviceId=${encodeURIComponent(this.serviceId)}` : "calls";
|
|
60046
|
+
const response = await this.request("POST", path7, body);
|
|
60044
60047
|
return response;
|
|
60045
60048
|
}
|
|
60046
60049
|
async patchCall(target, commands2) {
|
|
60047
|
-
const
|
|
60048
|
-
await this.request("PATCH",
|
|
60050
|
+
const path7 = "callId" in target ? `calls/${encodeURIComponent(target.callId)}` : `sessions/${encodeURIComponent(target.sessionId)}/calls/${encodeURIComponent(target.callName)}`;
|
|
60051
|
+
await this.request("PATCH", path7, { commands: commands2 });
|
|
60049
60052
|
}
|
|
60050
60053
|
get authHeaders() {
|
|
60051
60054
|
const token = Buffer.from(`${this.#keyId}:${this.#keySecret}`).toString("base64");
|
|
60052
60055
|
return { Authorization: `Basic ${token}`, "Content-Type": "application/json" };
|
|
60053
60056
|
}
|
|
60054
|
-
async request(method,
|
|
60057
|
+
async request(method, path7, body) {
|
|
60055
60058
|
if (!this.projectId || !this.#keyId || !this.#keySecret) {
|
|
60056
60059
|
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
60060
|
}
|
|
60058
|
-
const url2 = `${this.host}/v2/projects/${encodeURIComponent(this.projectId)}/${
|
|
60061
|
+
const url2 = `${this.host}/v2/projects/${encodeURIComponent(this.projectId)}/${path7}`;
|
|
60059
60062
|
const response = await this.fetchImpl(url2, {
|
|
60060
60063
|
method,
|
|
60061
60064
|
headers: this.authHeaders,
|
|
@@ -60794,7 +60797,12 @@ var CommandBuilder = class {
|
|
|
60794
60797
|
return this.push(bridgeStep(agentEndpoint(target), options2, STREAM_AGENT_LEG));
|
|
60795
60798
|
}
|
|
60796
60799
|
const { headers, transport, host, port, ...options } = sipOptions;
|
|
60797
|
-
const address = sipAgentAddress(target, numberOrOptions, {
|
|
60800
|
+
const address = sipAgentAddress(target, numberOrOptions, {
|
|
60801
|
+
headers,
|
|
60802
|
+
transport,
|
|
60803
|
+
host,
|
|
60804
|
+
port
|
|
60805
|
+
});
|
|
60798
60806
|
return this.push(bridgeStep((scope) => address(scope?.event), options, SIP_AGENT_LEG));
|
|
60799
60807
|
}
|
|
60800
60808
|
/**
|
|
@@ -61563,7 +61571,12 @@ var Client = class {
|
|
|
61563
61571
|
return this.transferTo(target, endpoint, numberOrOptions ?? {});
|
|
61564
61572
|
}
|
|
61565
61573
|
const { headers, transport, host, port, ...options } = sipOptions;
|
|
61566
|
-
const address = sipAgentAddress(agent, numberOrOptions, {
|
|
61574
|
+
const address = sipAgentAddress(agent, numberOrOptions, {
|
|
61575
|
+
headers,
|
|
61576
|
+
transport,
|
|
61577
|
+
host,
|
|
61578
|
+
port
|
|
61579
|
+
});
|
|
61567
61580
|
return this.transferTo(target, address, options, DEFAULT_AGENT_MAX_DURATION);
|
|
61568
61581
|
}
|
|
61569
61582
|
async transferTo(target, to, options, maxDuration) {
|
|
@@ -61755,8 +61768,261 @@ function connectAgent(provider, number, options = {}) {
|
|
|
61755
61768
|
};
|
|
61756
61769
|
}
|
|
61757
61770
|
|
|
61771
|
+
// ../runtime-shared/dist/security/context-secrets.js
|
|
61772
|
+
import { inspect } from "util";
|
|
61773
|
+
var HIDDEN_ENV_KEYS = [
|
|
61774
|
+
"PROJECT_ID_API_KEY",
|
|
61775
|
+
"PROJECT_ID_API_SECRET",
|
|
61776
|
+
"VOICE_APPLICATION_KEY",
|
|
61777
|
+
"VOICE_APPLICATION_SECRET",
|
|
61778
|
+
"VOICE_SERVICE_SECRET",
|
|
61779
|
+
"CONVERSATION_WEBHOOK_SECRET",
|
|
61780
|
+
"ADMIN_USER",
|
|
61781
|
+
"ADMIN_PASSWORD"
|
|
61782
|
+
];
|
|
61783
|
+
var HIDDEN_ENV_PATTERN = /SECRET|TOKEN|PASS|PRIVATE|CREDENTIAL|AUTH|APIKEY|ACCESS_KEY|DSN|CONNECTION_STRING|_URL|_URI|_KEY$|_KEY_ID$|^(?!(?:OLD)?PWD$).*PWD/i;
|
|
61784
|
+
var VISIBLE_ENV_KEYS = /* @__PURE__ */ new Set([
|
|
61785
|
+
"API_URL",
|
|
61786
|
+
"SINCH_API_URL",
|
|
61787
|
+
"FUNCTION_URL",
|
|
61788
|
+
"STREAM_URL",
|
|
61789
|
+
"TUNNEL_GATEWAY_URL"
|
|
61790
|
+
]);
|
|
61791
|
+
var hiddenKeys = new Set(HIDDEN_ENV_KEYS);
|
|
61792
|
+
var functionEnvs = /* @__PURE__ */ new WeakSet();
|
|
61793
|
+
var OPAQUE = /* @__PURE__ */ Symbol("sinch.opaque");
|
|
61794
|
+
function isHiddenEnvKey(key) {
|
|
61795
|
+
return hiddenKeys.has(key) || !VISIBLE_ENV_KEYS.has(key) && HIDDEN_ENV_PATTERN.test(key);
|
|
61796
|
+
}
|
|
61797
|
+
function createFunctionEnv(source) {
|
|
61798
|
+
const env = {};
|
|
61799
|
+
for (const key of Object.keys(source)) {
|
|
61800
|
+
Object.defineProperty(env, key, {
|
|
61801
|
+
value: source[key],
|
|
61802
|
+
enumerable: !isHiddenEnvKey(key),
|
|
61803
|
+
writable: true,
|
|
61804
|
+
configurable: true
|
|
61805
|
+
});
|
|
61806
|
+
}
|
|
61807
|
+
functionEnvs.add(env);
|
|
61808
|
+
return env;
|
|
61809
|
+
}
|
|
61810
|
+
function makeOpaque(target, label) {
|
|
61811
|
+
if (target === null || typeof target !== "object" && typeof target !== "function")
|
|
61812
|
+
return;
|
|
61813
|
+
if (Object.prototype.hasOwnProperty.call(target, OPAQUE) || !Object.isExtensible(target))
|
|
61814
|
+
return;
|
|
61815
|
+
const tag = `[${label}]`;
|
|
61816
|
+
Object.defineProperties(target, {
|
|
61817
|
+
[OPAQUE]: { value: true },
|
|
61818
|
+
toJSON: { value: () => tag, configurable: true, writable: true },
|
|
61819
|
+
[inspect.custom]: { value: () => tag, configurable: true, writable: true }
|
|
61820
|
+
});
|
|
61821
|
+
}
|
|
61822
|
+
var HOLDER_SEARCH_DEPTH = 4;
|
|
61823
|
+
var API_CLIENT_SEARCH_DEPTH = 8;
|
|
61824
|
+
var SDK_CREDENTIAL_FIELDS = /* @__PURE__ */ new Set([
|
|
61825
|
+
"keyId",
|
|
61826
|
+
"keySecret",
|
|
61827
|
+
"applicationKey",
|
|
61828
|
+
"applicationSecret",
|
|
61829
|
+
"applicationId",
|
|
61830
|
+
"apiToken",
|
|
61831
|
+
"mailgunApiKey",
|
|
61832
|
+
"userName",
|
|
61833
|
+
"password",
|
|
61834
|
+
"token"
|
|
61835
|
+
]);
|
|
61836
|
+
var searchedClients = /* @__PURE__ */ new WeakSet();
|
|
61837
|
+
var guardedLazyClients = /* @__PURE__ */ new WeakSet();
|
|
61838
|
+
var wrappedSetCredentials = /* @__PURE__ */ new WeakSet();
|
|
61839
|
+
function isObject(value) {
|
|
61840
|
+
return typeof value === "object" && value !== null;
|
|
61841
|
+
}
|
|
61842
|
+
function canDefine(obj, key) {
|
|
61843
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, key);
|
|
61844
|
+
return descriptor ? descriptor.configurable === true : Object.isExtensible(obj);
|
|
61845
|
+
}
|
|
61846
|
+
function dataValues(obj) {
|
|
61847
|
+
return Object.values(Object.getOwnPropertyDescriptors(obj)).filter((descriptor) => "value" in descriptor).map((descriptor) => descriptor.value);
|
|
61848
|
+
}
|
|
61849
|
+
function isCredentialField(key, value, secrets) {
|
|
61850
|
+
return SDK_CREDENTIAL_FIELDS.has(key) || typeof value === "string" && secrets.has(value);
|
|
61851
|
+
}
|
|
61852
|
+
function hideCredentialFields(obj, secrets) {
|
|
61853
|
+
let found = false;
|
|
61854
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(obj))) {
|
|
61855
|
+
if (!("value" in descriptor) || !isCredentialField(key, descriptor.value, secrets))
|
|
61856
|
+
continue;
|
|
61857
|
+
found = true;
|
|
61858
|
+
if (descriptor.enumerable && descriptor.configurable) {
|
|
61859
|
+
Object.defineProperty(obj, key, { enumerable: false });
|
|
61860
|
+
}
|
|
61861
|
+
}
|
|
61862
|
+
if (found)
|
|
61863
|
+
makeOpaque(obj, "Sinch credentials");
|
|
61864
|
+
return found;
|
|
61865
|
+
}
|
|
61866
|
+
function revealCredentialFields(obj, secrets) {
|
|
61867
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(obj))) {
|
|
61868
|
+
if (!("value" in descriptor) || descriptor.enumerable || !descriptor.configurable)
|
|
61869
|
+
continue;
|
|
61870
|
+
if (isCredentialField(key, descriptor.value, secrets)) {
|
|
61871
|
+
Object.defineProperty(obj, key, { enumerable: true });
|
|
61872
|
+
}
|
|
61873
|
+
}
|
|
61874
|
+
}
|
|
61875
|
+
function isLazyClient(obj) {
|
|
61876
|
+
const config = Object.getOwnPropertyDescriptor(obj, "sharedConfig");
|
|
61877
|
+
return typeof obj.getApiClient === "function" && (isObject(config?.value) || typeof config?.get === "function");
|
|
61878
|
+
}
|
|
61879
|
+
function isOAuth2Plugin(obj) {
|
|
61880
|
+
const plugin = obj;
|
|
61881
|
+
return typeof plugin.getOAuth2Token === "function" && typeof plugin.invalidateToken === "function";
|
|
61882
|
+
}
|
|
61883
|
+
function hideCredentialsBelow(obj, secrets, depth, maxDepth, seen) {
|
|
61884
|
+
if (depth > maxDepth || seen.has(obj))
|
|
61885
|
+
return;
|
|
61886
|
+
seen.add(obj);
|
|
61887
|
+
if (isOAuth2Plugin(obj) && !Object.prototype.hasOwnProperty.call(obj, "token") && canDefine(obj, "token")) {
|
|
61888
|
+
Object.defineProperty(obj, "token", {
|
|
61889
|
+
value: void 0,
|
|
61890
|
+
enumerable: false,
|
|
61891
|
+
writable: true,
|
|
61892
|
+
configurable: true
|
|
61893
|
+
});
|
|
61894
|
+
}
|
|
61895
|
+
hideCredentialFields(obj, secrets);
|
|
61896
|
+
for (const value of dataValues(obj)) {
|
|
61897
|
+
if (isObject(value))
|
|
61898
|
+
hideCredentialsBelow(value, secrets, depth + 1, maxDepth, seen);
|
|
61899
|
+
}
|
|
61900
|
+
}
|
|
61901
|
+
function protectApiClient(client, secrets) {
|
|
61902
|
+
if (!isObject(client))
|
|
61903
|
+
return;
|
|
61904
|
+
makeOpaque(client, "Sinch API client");
|
|
61905
|
+
hideCredentialsBelow(client, secrets, 0, API_CLIENT_SEARCH_DEPTH, /* @__PURE__ */ new Set());
|
|
61906
|
+
}
|
|
61907
|
+
function guardLazyClient(lazy, secrets) {
|
|
61908
|
+
if (guardedLazyClients.has(lazy))
|
|
61909
|
+
return;
|
|
61910
|
+
guardedLazyClients.add(lazy);
|
|
61911
|
+
let config = lazy.sharedConfig;
|
|
61912
|
+
let apiClient = lazy.apiFetchClient;
|
|
61913
|
+
if (isObject(config))
|
|
61914
|
+
hideCredentialFields(config, secrets);
|
|
61915
|
+
protectApiClient(apiClient, secrets);
|
|
61916
|
+
if (!canDefine(lazy, "sharedConfig") || !canDefine(lazy, "apiFetchClient"))
|
|
61917
|
+
return;
|
|
61918
|
+
Object.defineProperties(lazy, {
|
|
61919
|
+
sharedConfig: {
|
|
61920
|
+
get: () => config,
|
|
61921
|
+
set: (next) => {
|
|
61922
|
+
if (!isObject(next)) {
|
|
61923
|
+
config = next;
|
|
61924
|
+
return;
|
|
61925
|
+
}
|
|
61926
|
+
config = Object.create(Object.getPrototypeOf(next), Object.getOwnPropertyDescriptors(next));
|
|
61927
|
+
hideCredentialFields(config, secrets);
|
|
61928
|
+
},
|
|
61929
|
+
enumerable: true,
|
|
61930
|
+
configurable: true
|
|
61931
|
+
},
|
|
61932
|
+
apiFetchClient: {
|
|
61933
|
+
get: () => apiClient,
|
|
61934
|
+
set: (next) => {
|
|
61935
|
+
apiClient = next;
|
|
61936
|
+
protectApiClient(next, secrets);
|
|
61937
|
+
},
|
|
61938
|
+
enumerable: false,
|
|
61939
|
+
configurable: true
|
|
61940
|
+
}
|
|
61941
|
+
});
|
|
61942
|
+
}
|
|
61943
|
+
function keepCredentialsForSetCredentials(owner, lazies, secrets) {
|
|
61944
|
+
const original = owner.setCredentials;
|
|
61945
|
+
if (typeof original !== "function" || wrappedSetCredentials.has(owner))
|
|
61946
|
+
return;
|
|
61947
|
+
if (!canDefine(owner, "setCredentials"))
|
|
61948
|
+
return;
|
|
61949
|
+
wrappedSetCredentials.add(owner);
|
|
61950
|
+
Object.defineProperty(owner, "setCredentials", {
|
|
61951
|
+
value: function setCredentials(...args) {
|
|
61952
|
+
const configs = lazies.map((lazy) => lazy.sharedConfig).filter(isObject);
|
|
61953
|
+
for (const config of configs)
|
|
61954
|
+
revealCredentialFields(config, secrets);
|
|
61955
|
+
try {
|
|
61956
|
+
return original.apply(this, args);
|
|
61957
|
+
} finally {
|
|
61958
|
+
for (const config of configs)
|
|
61959
|
+
hideCredentialFields(config, secrets);
|
|
61960
|
+
}
|
|
61961
|
+
},
|
|
61962
|
+
enumerable: false,
|
|
61963
|
+
writable: true,
|
|
61964
|
+
configurable: true
|
|
61965
|
+
});
|
|
61966
|
+
}
|
|
61967
|
+
function guardSdkObjects(obj, secrets, lazies, depth, seen) {
|
|
61968
|
+
if (depth > HOLDER_SEARCH_DEPTH || seen.has(obj))
|
|
61969
|
+
return;
|
|
61970
|
+
seen.add(obj);
|
|
61971
|
+
if (isLazyClient(obj)) {
|
|
61972
|
+
lazies.push(obj);
|
|
61973
|
+
guardLazyClient(obj, secrets);
|
|
61974
|
+
return;
|
|
61975
|
+
}
|
|
61976
|
+
keepCredentialsForSetCredentials(obj, lazies, secrets);
|
|
61977
|
+
hideCredentialFields(obj, secrets);
|
|
61978
|
+
for (const value of dataValues(obj)) {
|
|
61979
|
+
if (isObject(value))
|
|
61980
|
+
guardSdkObjects(value, secrets, lazies, depth + 1, seen);
|
|
61981
|
+
}
|
|
61982
|
+
}
|
|
61983
|
+
function protectSdkClient(client, label, secrets) {
|
|
61984
|
+
if (!isObject(client) || searchedClients.has(client))
|
|
61985
|
+
return;
|
|
61986
|
+
searchedClients.add(client);
|
|
61987
|
+
makeOpaque(client, label);
|
|
61988
|
+
for (const member of dataValues(client)) {
|
|
61989
|
+
if (isObject(member))
|
|
61990
|
+
makeOpaque(member, label);
|
|
61991
|
+
}
|
|
61992
|
+
guardSdkObjects(client, secrets(), [], 0, /* @__PURE__ */ new Set());
|
|
61993
|
+
}
|
|
61994
|
+
function hiddenValues(env) {
|
|
61995
|
+
const values = /* @__PURE__ */ new Set();
|
|
61996
|
+
for (const key of env ? Object.getOwnPropertyNames(env) : []) {
|
|
61997
|
+
const value = env?.[key];
|
|
61998
|
+
if (value && isHiddenEnvKey(key))
|
|
61999
|
+
values.add(value);
|
|
62000
|
+
}
|
|
62001
|
+
return values;
|
|
62002
|
+
}
|
|
62003
|
+
function protectContext(context, v1) {
|
|
62004
|
+
const ctx = context;
|
|
62005
|
+
const original = ctx.env;
|
|
62006
|
+
if (original && !functionEnvs.has(original)) {
|
|
62007
|
+
const env = createFunctionEnv(original);
|
|
62008
|
+
ctx.env = env;
|
|
62009
|
+
if (ctx.config && ctx.config.variables === original) {
|
|
62010
|
+
ctx.config.variables = env;
|
|
62011
|
+
}
|
|
62012
|
+
}
|
|
62013
|
+
let secrets;
|
|
62014
|
+
const credentialValues = () => secrets ??= hiddenValues(ctx.env);
|
|
62015
|
+
protectSdkClient(ctx.conversation, "Sinch Conversation client", credentialValues);
|
|
62016
|
+
protectSdkClient(ctx.sms, "Sinch SMS client", credentialValues);
|
|
62017
|
+
protectSdkClient(ctx.numbers, "Sinch Numbers client", credentialValues);
|
|
62018
|
+
protectSdkClient(v1, "Sinch Voice v1 client", credentialValues);
|
|
62019
|
+
makeOpaque(ctx.cache, "Function cache");
|
|
62020
|
+
makeOpaque(ctx.storage, "Function storage");
|
|
62021
|
+
}
|
|
62022
|
+
|
|
61758
62023
|
// ../runtime-shared/dist/voice/client.js
|
|
61759
62024
|
function attachVoiceClient(context, v1) {
|
|
62025
|
+
protectContext(context, v1);
|
|
61760
62026
|
attachConfigAccessors(context);
|
|
61761
62027
|
let client;
|
|
61762
62028
|
Object.defineProperty(context, "voice", {
|
|
@@ -62278,6 +62544,238 @@ function createSecurityOptions(config) {
|
|
|
62278
62544
|
};
|
|
62279
62545
|
}
|
|
62280
62546
|
|
|
62547
|
+
// ../runtime-shared/dist/security/redact.js
|
|
62548
|
+
import { inspect as inspect2 } from "util";
|
|
62549
|
+
var REDACTED2 = "[REDACTED]";
|
|
62550
|
+
var MIN_SECRET_LENGTH = 8;
|
|
62551
|
+
var BASIC_AUTH_PAIRS = [
|
|
62552
|
+
["PROJECT_ID_API_KEY", "PROJECT_ID_API_SECRET"],
|
|
62553
|
+
["VOICE_APPLICATION_KEY", "VOICE_APPLICATION_SECRET"],
|
|
62554
|
+
["ADMIN_USER", "ADMIN_PASSWORD"]
|
|
62555
|
+
];
|
|
62556
|
+
var MAX_PATTERN_SOURCE = 16 * 1024;
|
|
62557
|
+
var MAX_PATTERN_NEEDLE = 1024;
|
|
62558
|
+
var matcher = null;
|
|
62559
|
+
function escapeRegExp(text) {
|
|
62560
|
+
return text.replace(/[\\^$.*+?()[\]{}|/-]/g, "\\$&");
|
|
62561
|
+
}
|
|
62562
|
+
function percentEncodedForms(value) {
|
|
62563
|
+
const component = encodeURIComponent(value);
|
|
62564
|
+
const strict = component.replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
62565
|
+
const form = new URLSearchParams([["", value]]).toString().slice(1);
|
|
62566
|
+
return [component, strict, form].flatMap((encoded) => [
|
|
62567
|
+
encoded,
|
|
62568
|
+
encoded.replace(/%[0-9A-F]{2}/g, (hex) => hex.toLowerCase())
|
|
62569
|
+
]);
|
|
62570
|
+
}
|
|
62571
|
+
function buildSecretNeedles(env) {
|
|
62572
|
+
const needles = /* @__PURE__ */ new Set();
|
|
62573
|
+
const add = (text) => {
|
|
62574
|
+
if (text.length >= MIN_SECRET_LENGTH)
|
|
62575
|
+
needles.add(text);
|
|
62576
|
+
};
|
|
62577
|
+
const addQuotedForms = (text) => {
|
|
62578
|
+
add(text);
|
|
62579
|
+
add(JSON.stringify(text).slice(1, -1));
|
|
62580
|
+
add(inspect2(text).slice(1, -1));
|
|
62581
|
+
};
|
|
62582
|
+
for (const key of Object.getOwnPropertyNames(env)) {
|
|
62583
|
+
const value = env[key];
|
|
62584
|
+
if (typeof value !== "string" || value.length < MIN_SECRET_LENGTH || !isHiddenEnvKey(key)) {
|
|
62585
|
+
continue;
|
|
62586
|
+
}
|
|
62587
|
+
addQuotedForms(value);
|
|
62588
|
+
for (const form of percentEncodedForms(value))
|
|
62589
|
+
add(form);
|
|
62590
|
+
for (const line of value.split(/\r?\n|(?:\\r)?\\n/))
|
|
62591
|
+
addQuotedForms(line.trim());
|
|
62592
|
+
}
|
|
62593
|
+
for (const [userKey, secretKey] of BASIC_AUTH_PAIRS) {
|
|
62594
|
+
const user = env[userKey];
|
|
62595
|
+
const secret = env[secretKey];
|
|
62596
|
+
if (user && secret)
|
|
62597
|
+
add(Buffer.from(`${user}:${secret}`).toString("base64"));
|
|
62598
|
+
}
|
|
62599
|
+
const sessions = collectCredentials2({
|
|
62600
|
+
authKey: env.PROJECT_ID_API_KEY,
|
|
62601
|
+
authSecret: env.PROJECT_ID_API_SECRET,
|
|
62602
|
+
adminUser: env.ADMIN_USER,
|
|
62603
|
+
adminPassword: env.ADMIN_PASSWORD
|
|
62604
|
+
});
|
|
62605
|
+
for (const { user, password } of sessions)
|
|
62606
|
+
add(sessionToken(user, password));
|
|
62607
|
+
return [...needles].sort((a, b) => b.length - a.length);
|
|
62608
|
+
}
|
|
62609
|
+
function configureSecretRedaction(env) {
|
|
62610
|
+
const needles = buildSecretNeedles(env);
|
|
62611
|
+
if (needles.length === 0) {
|
|
62612
|
+
matcher = null;
|
|
62613
|
+
return;
|
|
62614
|
+
}
|
|
62615
|
+
const patterns = [];
|
|
62616
|
+
const literals = [];
|
|
62617
|
+
let group = [];
|
|
62618
|
+
let groupSource = 0;
|
|
62619
|
+
const closeGroup = () => {
|
|
62620
|
+
if (group.length === 0)
|
|
62621
|
+
return;
|
|
62622
|
+
const alternation = group.join("|");
|
|
62623
|
+
patterns.push({
|
|
62624
|
+
any: new RegExp(alternation),
|
|
62625
|
+
starts: new RegExp(`(?=(${alternation}))`, "g")
|
|
62626
|
+
});
|
|
62627
|
+
group = [];
|
|
62628
|
+
groupSource = 0;
|
|
62629
|
+
};
|
|
62630
|
+
for (const needle of needles) {
|
|
62631
|
+
const source = escapeRegExp(needle);
|
|
62632
|
+
if (needle.length > MAX_PATTERN_NEEDLE) {
|
|
62633
|
+
literals.push(needle);
|
|
62634
|
+
continue;
|
|
62635
|
+
}
|
|
62636
|
+
if (groupSource + source.length + 1 > MAX_PATTERN_SOURCE)
|
|
62637
|
+
closeGroup();
|
|
62638
|
+
group.push(source);
|
|
62639
|
+
groupSource += source.length + 1;
|
|
62640
|
+
}
|
|
62641
|
+
closeGroup();
|
|
62642
|
+
matcher = {
|
|
62643
|
+
patterns,
|
|
62644
|
+
literals,
|
|
62645
|
+
shortest: needles[needles.length - 1].length,
|
|
62646
|
+
longest: needles[0].length,
|
|
62647
|
+
longestBytes: Math.max(...needles.map((needle) => Buffer.byteLength(needle)))
|
|
62648
|
+
};
|
|
62649
|
+
}
|
|
62650
|
+
function findSpans(m, text) {
|
|
62651
|
+
const found = [];
|
|
62652
|
+
for (const pattern of m.patterns) {
|
|
62653
|
+
if (!pattern.any.test(text))
|
|
62654
|
+
continue;
|
|
62655
|
+
for (const match of text.matchAll(pattern.starts)) {
|
|
62656
|
+
found.push([match.index, match.index + match[1].length]);
|
|
62657
|
+
}
|
|
62658
|
+
}
|
|
62659
|
+
for (const needle of m.literals) {
|
|
62660
|
+
for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + 1)) {
|
|
62661
|
+
found.push([at, at + needle.length]);
|
|
62662
|
+
}
|
|
62663
|
+
}
|
|
62664
|
+
if (found.length === 0)
|
|
62665
|
+
return found;
|
|
62666
|
+
found.sort((a, b) => a[0] - b[0]);
|
|
62667
|
+
const merged = [found[0]];
|
|
62668
|
+
for (const [start, end] of found) {
|
|
62669
|
+
const last = merged[merged.length - 1];
|
|
62670
|
+
if (start <= last[1])
|
|
62671
|
+
last[1] = Math.max(last[1], end);
|
|
62672
|
+
else
|
|
62673
|
+
merged.push([start, end]);
|
|
62674
|
+
}
|
|
62675
|
+
return merged;
|
|
62676
|
+
}
|
|
62677
|
+
function redactSecrets(text) {
|
|
62678
|
+
const m = matcher;
|
|
62679
|
+
if (!m || text.length < m.shortest)
|
|
62680
|
+
return text;
|
|
62681
|
+
let spans;
|
|
62682
|
+
try {
|
|
62683
|
+
spans = findSpans(m, text);
|
|
62684
|
+
} catch {
|
|
62685
|
+
return REDACTED2;
|
|
62686
|
+
}
|
|
62687
|
+
if (spans.length === 0)
|
|
62688
|
+
return text;
|
|
62689
|
+
let out = "";
|
|
62690
|
+
let copied = 0;
|
|
62691
|
+
for (const [start, end] of spans) {
|
|
62692
|
+
out += text.slice(copied, start) + REDACTED2;
|
|
62693
|
+
copied = end;
|
|
62694
|
+
}
|
|
62695
|
+
return out + text.slice(copied);
|
|
62696
|
+
}
|
|
62697
|
+
function redactAsText(value) {
|
|
62698
|
+
if (value === void 0 || value === null)
|
|
62699
|
+
return value;
|
|
62700
|
+
if (typeof value === "string")
|
|
62701
|
+
return redactSecrets(value);
|
|
62702
|
+
let text;
|
|
62703
|
+
try {
|
|
62704
|
+
text = JSON.stringify(value);
|
|
62705
|
+
} catch {
|
|
62706
|
+
}
|
|
62707
|
+
try {
|
|
62708
|
+
text ??= String(value);
|
|
62709
|
+
} catch {
|
|
62710
|
+
return REDACTED2;
|
|
62711
|
+
}
|
|
62712
|
+
return redactSecrets(text);
|
|
62713
|
+
}
|
|
62714
|
+
function secretLookaheadBytes() {
|
|
62715
|
+
return matcher ? matcher.longestBytes : 0;
|
|
62716
|
+
}
|
|
62717
|
+
function safeCut(prefix, continuation) {
|
|
62718
|
+
const m = matcher;
|
|
62719
|
+
if (!m || continuation.length === 0)
|
|
62720
|
+
return prefix;
|
|
62721
|
+
try {
|
|
62722
|
+
const cut = prefix.length;
|
|
62723
|
+
const after = continuation.slice(0, m.longest - 1);
|
|
62724
|
+
for (let reach = m.longest; ; reach *= 2) {
|
|
62725
|
+
const from = Math.max(0, cut - reach);
|
|
62726
|
+
const crossing = findSpans(m, prefix.slice(from) + after).find(([start, end]) => start < cut - from && end > cut - from);
|
|
62727
|
+
if (!crossing)
|
|
62728
|
+
return prefix;
|
|
62729
|
+
if (from === 0 || crossing[0] >= m.longest)
|
|
62730
|
+
return prefix.slice(0, from + crossing[0]);
|
|
62731
|
+
}
|
|
62732
|
+
} catch {
|
|
62733
|
+
return "";
|
|
62734
|
+
}
|
|
62735
|
+
}
|
|
62736
|
+
var wrappedStreams = /* @__PURE__ */ new WeakSet();
|
|
62737
|
+
function isTextEncoding(encoding) {
|
|
62738
|
+
return typeof encoding !== "string" || !/^(hex|base64|base64url)$/i.test(encoding);
|
|
62739
|
+
}
|
|
62740
|
+
function redactBytes(bytes) {
|
|
62741
|
+
const text = bytes.toString("utf8");
|
|
62742
|
+
const redacted = redactSecrets(text);
|
|
62743
|
+
return redacted === text ? void 0 : Buffer.from(redacted, "utf8");
|
|
62744
|
+
}
|
|
62745
|
+
function redactChunk(chunk, encoding) {
|
|
62746
|
+
if (!matcher)
|
|
62747
|
+
return chunk;
|
|
62748
|
+
if (typeof chunk === "string") {
|
|
62749
|
+
if (isTextEncoding(encoding))
|
|
62750
|
+
return redactSecrets(chunk);
|
|
62751
|
+
const notation = encoding;
|
|
62752
|
+
return redactBytes(Buffer.from(chunk, notation))?.toString(notation) ?? chunk;
|
|
62753
|
+
}
|
|
62754
|
+
if (ArrayBuffer.isView(chunk)) {
|
|
62755
|
+
return redactBytes(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength)) ?? chunk;
|
|
62756
|
+
}
|
|
62757
|
+
return chunk;
|
|
62758
|
+
}
|
|
62759
|
+
function wrapStreamWrite(stream5) {
|
|
62760
|
+
if (wrappedStreams.has(stream5))
|
|
62761
|
+
return;
|
|
62762
|
+
wrappedStreams.add(stream5);
|
|
62763
|
+
const write = stream5.write;
|
|
62764
|
+
stream5.write = function(chunk, ...rest) {
|
|
62765
|
+
let safe;
|
|
62766
|
+
try {
|
|
62767
|
+
safe = redactChunk(chunk, rest[0]);
|
|
62768
|
+
} catch {
|
|
62769
|
+
safe = typeof chunk === "string" ? REDACTED2 : Buffer.from(REDACTED2);
|
|
62770
|
+
}
|
|
62771
|
+
return write.call(this, safe, ...rest);
|
|
62772
|
+
};
|
|
62773
|
+
}
|
|
62774
|
+
function installStdioRedaction() {
|
|
62775
|
+
wrapStreamWrite(process.stdout);
|
|
62776
|
+
wrapStreamWrite(process.stderr);
|
|
62777
|
+
}
|
|
62778
|
+
|
|
62281
62779
|
// ../runtime-shared/dist/security/voice-signature.js
|
|
62282
62780
|
import { createHash, createHmac as createHmac2, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
62283
62781
|
var VOICE_TIMESTAMP_SKEW_MS = 5 * 60 * 1e3;
|
|
@@ -62475,6 +62973,52 @@ function safeToolOutput(value) {
|
|
|
62475
62973
|
}
|
|
62476
62974
|
}
|
|
62477
62975
|
|
|
62976
|
+
// ../runtime-shared/dist/host/exports.js
|
|
62977
|
+
import { types } from "util";
|
|
62978
|
+
var fnToString = Function.prototype.toString;
|
|
62979
|
+
var fnBind = Function.prototype.bind;
|
|
62980
|
+
var OBJECT_PROTOTYPE_NAMES = new Set(Object.getOwnPropertyNames(Object.prototype));
|
|
62981
|
+
function isAuthorClassPrototype(proto) {
|
|
62982
|
+
if (types.isProxy(proto))
|
|
62983
|
+
return false;
|
|
62984
|
+
const ctor = Object.getOwnPropertyDescriptor(proto, "constructor")?.value;
|
|
62985
|
+
if (typeof ctor !== "function" || types.isProxy(ctor))
|
|
62986
|
+
return false;
|
|
62987
|
+
if (Object.getOwnPropertyDescriptor(ctor, "prototype")?.value !== proto)
|
|
62988
|
+
return false;
|
|
62989
|
+
if (!/^class\b/.test(fnToString.call(ctor)))
|
|
62990
|
+
return false;
|
|
62991
|
+
const name = Object.getOwnPropertyDescriptor(ctor, "name")?.value;
|
|
62992
|
+
return !(typeof name === "string" && Object.getOwnPropertyDescriptor(globalThis, name)?.value === ctor);
|
|
62993
|
+
}
|
|
62994
|
+
function findExport(target, name) {
|
|
62995
|
+
if (OBJECT_PROTOTYPE_NAMES.has(name))
|
|
62996
|
+
return void 0;
|
|
62997
|
+
if (Object.hasOwn(target, name)) {
|
|
62998
|
+
const value = target[name];
|
|
62999
|
+
return typeof value === "function" ? fnBind.call(value, target) : void 0;
|
|
63000
|
+
}
|
|
63001
|
+
if (types.isProxy(target))
|
|
63002
|
+
return void 0;
|
|
63003
|
+
for (let proto = Object.getPrototypeOf(target); proto !== null && isAuthorClassPrototype(proto); proto = Object.getPrototypeOf(proto)) {
|
|
63004
|
+
const descriptor = Object.getOwnPropertyDescriptor(proto, name);
|
|
63005
|
+
if (descriptor) {
|
|
63006
|
+
return typeof descriptor.value === "function" ? fnBind.call(descriptor.value, target) : void 0;
|
|
63007
|
+
}
|
|
63008
|
+
}
|
|
63009
|
+
return void 0;
|
|
63010
|
+
}
|
|
63011
|
+
function listExports(target) {
|
|
63012
|
+
const candidates = new Set(Object.keys(target));
|
|
63013
|
+
if (!types.isProxy(target)) {
|
|
63014
|
+
for (let proto = Object.getPrototypeOf(target); proto !== null && isAuthorClassPrototype(proto); proto = Object.getPrototypeOf(proto)) {
|
|
63015
|
+
for (const name of Object.getOwnPropertyNames(proto))
|
|
63016
|
+
candidates.add(name);
|
|
63017
|
+
}
|
|
63018
|
+
}
|
|
63019
|
+
return [...candidates].filter((name) => findExport(target, name) !== void 0);
|
|
63020
|
+
}
|
|
63021
|
+
|
|
62478
63022
|
// ../runtime-shared/dist/host/app.js
|
|
62479
63023
|
import { createRequire } from "module";
|
|
62480
63024
|
import { pathToFileURL } from "url";
|
|
@@ -62583,8 +63127,8 @@ function buildVoiceSignedRequest(req) {
|
|
|
62583
63127
|
function isVoiceWebhookPath(pathname) {
|
|
62584
63128
|
return pathname === "/" || pathname === "/webhook/voice";
|
|
62585
63129
|
}
|
|
62586
|
-
function extractFunctionName(
|
|
62587
|
-
const pathname =
|
|
63130
|
+
function extractFunctionName(path7, body) {
|
|
63131
|
+
const pathname = path7.split("?")[0];
|
|
62588
63132
|
if (isVoiceWebhookPath(pathname)) {
|
|
62589
63133
|
if (body?.event && isVoiceV1Callback(body.event)) {
|
|
62590
63134
|
return body.event;
|
|
@@ -62609,10 +63153,10 @@ function generateRequestId() {
|
|
|
62609
63153
|
return `req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
62610
63154
|
}
|
|
62611
63155
|
function findFunctionPath() {
|
|
62612
|
-
const
|
|
63156
|
+
const fs6 = requireCjs("fs");
|
|
62613
63157
|
const distPath = nodePath.join(process.cwd(), "dist", "function.js");
|
|
62614
63158
|
const rootPath = nodePath.join(process.cwd(), "function.js");
|
|
62615
|
-
if (
|
|
63159
|
+
if (fs6.existsSync(distPath)) {
|
|
62616
63160
|
return distPath;
|
|
62617
63161
|
}
|
|
62618
63162
|
return rootPath;
|
|
@@ -62720,8 +63264,10 @@ function buildBaseContext(req, config = {}) {
|
|
|
62720
63264
|
}
|
|
62721
63265
|
};
|
|
62722
63266
|
}
|
|
63267
|
+
var ExportNotFoundError = class extends Error {
|
|
63268
|
+
};
|
|
62723
63269
|
async function handleVoiceV1Callback(functionName, userFunction, context, callbackData, logger) {
|
|
62724
|
-
const handler = userFunction
|
|
63270
|
+
const handler = findExport(userFunction, functionName);
|
|
62725
63271
|
if (!handler || typeof handler !== "function") {
|
|
62726
63272
|
if (functionName === "ice") {
|
|
62727
63273
|
throw new Error(`Voice callback 'ice' not found \u2014 export an ice() function in function.ts`);
|
|
@@ -62767,7 +63313,7 @@ async function handleVoiceV1Callback(functionName, userFunction, context, callba
|
|
|
62767
63313
|
return formatSvamlResponse(result2, functionName);
|
|
62768
63314
|
}
|
|
62769
63315
|
async function handleVoiceWebhook(userFunction, context, event, request, logger) {
|
|
62770
|
-
const handler = userFunction
|
|
63316
|
+
const handler = findExport(userFunction, VOICE_WEBHOOK_HANDLER);
|
|
62771
63317
|
if (!handler || typeof handler !== "function") {
|
|
62772
63318
|
throw new Error(`No export '${VOICE_WEBHOOK_HANDLER}' found for Voice v2 event '${event?.event}'. Export one built with onCall({ incoming: ... }), or drop VOICE_SERVICE_ID to stay on the v1 ice/ace/pie/dice callbacks.`);
|
|
62773
63319
|
}
|
|
@@ -62782,20 +63328,24 @@ async function handleVoiceWebhook(userFunction, context, event, request, logger)
|
|
|
62782
63328
|
return formatCustomResponse(result2);
|
|
62783
63329
|
}
|
|
62784
63330
|
const body = await context.voice.onCall({ fallback: () => result2 })(event);
|
|
62785
|
-
return body === void 0 ? { statusCode: 204 } : {
|
|
63331
|
+
return body === void 0 ? { statusCode: 204 } : {
|
|
63332
|
+
statusCode: 200,
|
|
63333
|
+
headers: { "Content-Type": "application/json" },
|
|
63334
|
+
body: stringify(body)
|
|
63335
|
+
};
|
|
62786
63336
|
}
|
|
62787
63337
|
function isVoiceResult(result2) {
|
|
62788
63338
|
return Array.isArray(result2) || result2 instanceof CommandBuilder || typeof result2 === "object" && Array.isArray(result2.commands);
|
|
62789
63339
|
}
|
|
62790
63340
|
async function handleCustomEndpoint(functionName, userFunction, context, request, logger) {
|
|
62791
|
-
let handler = userFunction
|
|
63341
|
+
let handler = findExport(userFunction, functionName);
|
|
62792
63342
|
if ((!handler || typeof handler !== "function") && functionName === "default") {
|
|
62793
|
-
handler = userFunction
|
|
63343
|
+
handler = findExport(userFunction, "home");
|
|
62794
63344
|
}
|
|
62795
63345
|
if (!handler || typeof handler !== "function") {
|
|
62796
|
-
const available =
|
|
63346
|
+
const available = listExports(userFunction);
|
|
62797
63347
|
const pathHint = functionName.endsWith("Webhook") ? `/webhook/${functionName.replace("Webhook", "")}` : `/${functionName}`;
|
|
62798
|
-
throw new
|
|
63348
|
+
throw new ExportNotFoundError(`No export '${functionName}' found for path ${pathHint}. Available exports: [${available.join(", ")}]. Custom endpoints require a named export matching the last path segment.`);
|
|
62799
63349
|
}
|
|
62800
63350
|
const result2 = await handler(context, request);
|
|
62801
63351
|
if (logger) {
|
|
@@ -62838,8 +63388,8 @@ function createSinchRuntime() {
|
|
|
62838
63388
|
onStartup(handler) {
|
|
62839
63389
|
result2.startupHandlers.push(handler);
|
|
62840
63390
|
},
|
|
62841
|
-
onWebSocket(
|
|
62842
|
-
const normalizedPath =
|
|
63391
|
+
onWebSocket(path7, handler) {
|
|
63392
|
+
const normalizedPath = path7.startsWith("/") ? path7 : `/${path7}`;
|
|
62843
63393
|
result2.wsHandlers.set(normalizedPath, handler);
|
|
62844
63394
|
}
|
|
62845
63395
|
};
|
|
@@ -62881,7 +63431,12 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62881
63431
|
}, buildContext = (req) => attachVoiceClient(buildBaseContext(req)), logger = console.log, landingPageEnabled = true, authConfig, authKey, authSecret, adminUser, adminPassword, onRequestStart = () => {
|
|
62882
63432
|
}, onRequestEnd = () => {
|
|
62883
63433
|
} } = options;
|
|
62884
|
-
const credentials = collectCredentials2({
|
|
63434
|
+
const credentials = collectCredentials2({
|
|
63435
|
+
authKey,
|
|
63436
|
+
authSecret,
|
|
63437
|
+
adminUser,
|
|
63438
|
+
adminPassword
|
|
63439
|
+
});
|
|
62885
63440
|
const functionDisplayName = process.env.FUNCTION_NAME || "Sinch Function";
|
|
62886
63441
|
app.use("/{*splat}", async (req, res) => {
|
|
62887
63442
|
const startTime = Date.now();
|
|
@@ -62894,7 +63449,7 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62894
63449
|
const functionName = extractFunctionName(req.originalUrl, req.body);
|
|
62895
63450
|
logger(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${req.method} ${req.path} -> ${functionName}`);
|
|
62896
63451
|
const userFunction = await Promise.resolve(loadUserFunction());
|
|
62897
|
-
const hasAuthorExport = (name) => typeof userFunction
|
|
63452
|
+
const hasAuthorExport = (name) => typeof findExport(userFunction, name) === "function";
|
|
62898
63453
|
if (functionName === "login" && !hasAuthorExport("login")) {
|
|
62899
63454
|
if (req.method === "GET") {
|
|
62900
63455
|
handleLoginPageRequest(req, res, { credentials, functionName: functionDisplayName });
|
|
@@ -62961,7 +63516,10 @@ function setupRequestHandler(app, options = {}) {
|
|
|
62961
63516
|
}
|
|
62962
63517
|
}
|
|
62963
63518
|
if (functionName === VOICE_WEBHOOK_HANDLER && isVoiceWebhook(req.body)) {
|
|
62964
|
-
const verdict = verifyVoiceWebhook(buildVoiceSignedRequest(req), {
|
|
63519
|
+
const verdict = verifyVoiceWebhook(buildVoiceSignedRequest(req), {
|
|
63520
|
+
mode: protectionMode,
|
|
63521
|
+
isDevelopment: isDev
|
|
63522
|
+
});
|
|
62965
63523
|
if (!verdict.valid) {
|
|
62966
63524
|
logger(`[SECURITY] Voice v2 webhook signature validation failed: ${verdict.reason}`);
|
|
62967
63525
|
res.status(401).json({ error: "Invalid webhook signature" });
|
|
@@ -63030,17 +63588,22 @@ function setupRequestHandler(app, options = {}) {
|
|
|
63030
63588
|
stack: error.stack,
|
|
63031
63589
|
function: extractFunctionName(req.originalUrl, req.body)
|
|
63032
63590
|
});
|
|
63033
|
-
|
|
63034
|
-
error: "
|
|
63035
|
-
|
|
63036
|
-
|
|
63037
|
-
|
|
63591
|
+
if (error instanceof ExportNotFoundError) {
|
|
63592
|
+
res.status(404).json({ error: "Not found", message: error.message });
|
|
63593
|
+
} else {
|
|
63594
|
+
const { message, stack } = error ?? {};
|
|
63595
|
+
res.status(500).json({
|
|
63596
|
+
error: "Internal server error",
|
|
63597
|
+
message: redactAsText(message),
|
|
63598
|
+
...process.env.NODE_ENV === "development" && { stack: redactAsText(stack) }
|
|
63599
|
+
});
|
|
63600
|
+
}
|
|
63038
63601
|
onRequestEnd({
|
|
63039
63602
|
functionName: extractFunctionName(req.originalUrl, req.body),
|
|
63040
63603
|
req,
|
|
63041
63604
|
error,
|
|
63042
63605
|
duration,
|
|
63043
|
-
statusCode: 500
|
|
63606
|
+
statusCode: error instanceof ExportNotFoundError ? 404 : 500
|
|
63044
63607
|
});
|
|
63045
63608
|
}
|
|
63046
63609
|
});
|
|
@@ -63519,7 +64082,7 @@ var ElevenLabsAutoConfigurator = class {
|
|
|
63519
64082
|
var AGENT_SAMPLE_RATE = 16e3;
|
|
63520
64083
|
var AGENT_STREAM_PATH = "/stream";
|
|
63521
64084
|
var AGENT_HEADER_TOKEN = "x-sinch-agent-token";
|
|
63522
|
-
function deriveSocketUrl(
|
|
64085
|
+
function deriveSocketUrl(path7) {
|
|
63523
64086
|
const fnName = process.env["FUNCTION_NAME"];
|
|
63524
64087
|
const apiUrl = process.env["API_URL"];
|
|
63525
64088
|
if (!fnName || !apiUrl)
|
|
@@ -63529,7 +64092,7 @@ function deriveSocketUrl(path6) {
|
|
|
63529
64092
|
const match = apiUrl.match(/api\.functions\.(\w+)\.sinchvoice\.org/);
|
|
63530
64093
|
if (!match)
|
|
63531
64094
|
return "";
|
|
63532
|
-
return `wss://${fnName}.fn-${match[1]}.sinch.com${
|
|
64095
|
+
return `wss://${fnName}.fn-${match[1]}.sinch.com${path7}`;
|
|
63533
64096
|
}
|
|
63534
64097
|
function isLocalDevUrl(url2) {
|
|
63535
64098
|
let hostname;
|
|
@@ -63550,10 +64113,10 @@ function isDeployed(context) {
|
|
|
63550
64113
|
function resolveAgentStreamUrl(context, override) {
|
|
63551
64114
|
return resolveSelfSocketUrl(AGENT_STREAM_PATH, "STREAM_URL", context, override);
|
|
63552
64115
|
}
|
|
63553
|
-
function resolveSelfSocketUrl(
|
|
63554
|
-
const url2 = override || (context?.host ? `wss://${context.host}${
|
|
64116
|
+
function resolveSelfSocketUrl(path7, envVar, context, override) {
|
|
64117
|
+
const url2 = override || (context?.host ? `wss://${context.host}${path7}` : "") || process.env[envVar] || deriveSocketUrl(path7);
|
|
63555
64118
|
if (!url2) {
|
|
63556
|
-
throw new Error(`WebSocket URL for ${
|
|
64119
|
+
throw new Error(`WebSocket URL for ${path7} cannot be determined \u2014 set ${envVar}, or ensure FUNCTION_NAME and API_URL are present.`);
|
|
63557
64120
|
}
|
|
63558
64121
|
if (isDeployed(context) && isLocalDevUrl(url2)) {
|
|
63559
64122
|
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 +64165,7 @@ var MAX_UNAUTHENTICATED_SOCKETS = 32;
|
|
|
63602
64165
|
var HANGUP_GRACE_MS = 1e3;
|
|
63603
64166
|
var RELAY_LEG2 = "relay";
|
|
63604
64167
|
function voiceRelay(options) {
|
|
63605
|
-
const
|
|
64168
|
+
const path7 = options.path ?? RELAY_PATH;
|
|
63606
64169
|
const pending = /* @__PURE__ */ new Map();
|
|
63607
64170
|
let unauthenticated = 0;
|
|
63608
64171
|
function takePending(token) {
|
|
@@ -63615,7 +64178,7 @@ function voiceRelay(options) {
|
|
|
63615
64178
|
}
|
|
63616
64179
|
function endpointFor(event, clientContext) {
|
|
63617
64180
|
const context = clientContext;
|
|
63618
|
-
const url2 = resolveSelfSocketUrl(
|
|
64181
|
+
const url2 = resolveSelfSocketUrl(path7, "RELAY_URL", context);
|
|
63619
64182
|
const voice = setting(options.voice, event.call, context, "voice");
|
|
63620
64183
|
const language = setting(options.language, event.call, context, "language");
|
|
63621
64184
|
const token = randomUUID();
|
|
@@ -63804,7 +64367,7 @@ function voiceRelay(options) {
|
|
|
63804
64367
|
}
|
|
63805
64368
|
return {
|
|
63806
64369
|
setup(runtime) {
|
|
63807
|
-
runtime.onWebSocket(
|
|
64370
|
+
runtime.onWebSocket(path7, ((ws, req) => handleRelay(ws, req)));
|
|
63808
64371
|
},
|
|
63809
64372
|
endpointFor
|
|
63810
64373
|
};
|
|
@@ -63855,9 +64418,9 @@ function closeAnyState(ws) {
|
|
|
63855
64418
|
function sanitizeVendorError(err) {
|
|
63856
64419
|
const message = err instanceof Error ? err.message : String(err);
|
|
63857
64420
|
const code = err?.code;
|
|
63858
|
-
return { message:
|
|
64421
|
+
return { message: redactSecrets2(message), ...code ? { code } : {} };
|
|
63859
64422
|
}
|
|
63860
|
-
function
|
|
64423
|
+
function redactSecrets2(message) {
|
|
63861
64424
|
return message.replace(/([?&](?:key|api_key|apikey|token)=)[^&\s"']+/gi, "$1[REDACTED]").replace(/(authorization:?\s*(?:bearer|token)\s+)\S+/gi, "$1[REDACTED]");
|
|
63862
64425
|
}
|
|
63863
64426
|
|
|
@@ -63873,7 +64436,12 @@ function providerOptionsFor(options) {
|
|
|
63873
64436
|
return options.providerOptions?.["deepgram"] ?? {};
|
|
63874
64437
|
}
|
|
63875
64438
|
function encodeTools(tools) {
|
|
63876
|
-
return tools.map((t) => ({
|
|
64439
|
+
return tools.map((t) => ({
|
|
64440
|
+
name: t.name,
|
|
64441
|
+
description: t.description,
|
|
64442
|
+
parameters: t.parameters,
|
|
64443
|
+
defer_until_eot: true
|
|
64444
|
+
}));
|
|
63877
64445
|
}
|
|
63878
64446
|
async function dispatchToolCall(fn, tools, ctx, dgWs, callbacks, session) {
|
|
63879
64447
|
const start = Date.now();
|
|
@@ -63957,7 +64525,10 @@ function buildSettingsFrame(options) {
|
|
|
63957
64525
|
}
|
|
63958
64526
|
},
|
|
63959
64527
|
think: {
|
|
63960
|
-
provider: {
|
|
64528
|
+
provider: {
|
|
64529
|
+
type: dg.llmProvider ?? DEFAULT_LLM_PROVIDER,
|
|
64530
|
+
model: dg.llmModel ?? DEFAULT_LLM_MODEL
|
|
64531
|
+
},
|
|
63961
64532
|
prompt: options.prompt,
|
|
63962
64533
|
functions: encodeTools(options.tools ?? [])
|
|
63963
64534
|
},
|
|
@@ -63979,7 +64550,9 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
63979
64550
|
throw new Error("realtimeAgent: provider 'deepgram' needs DEEPGRAM_API_KEY \u2014 set it as a function secret.");
|
|
63980
64551
|
}
|
|
63981
64552
|
const WebSocketClient = webSocketClient ?? loadWebSocketClient("deepgram");
|
|
63982
|
-
const dgWs = new WebSocketClient(DEEPGRAM_URL, {
|
|
64553
|
+
const dgWs = new WebSocketClient(DEEPGRAM_URL, {
|
|
64554
|
+
headers: { Authorization: `Token ${apiKey}` }
|
|
64555
|
+
});
|
|
63983
64556
|
const bytesPerMs = (options.audio === "wideband" ? 16e3 : 8e3) * 2 / 1e3;
|
|
63984
64557
|
const session = {
|
|
63985
64558
|
ws: dgWs,
|
|
@@ -64046,7 +64619,9 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
64046
64619
|
return;
|
|
64047
64620
|
}
|
|
64048
64621
|
if (isOversizedFrame(raw)) {
|
|
64049
|
-
callbacks.onError({
|
|
64622
|
+
callbacks.onError({
|
|
64623
|
+
message: "Received an oversized text frame from Deepgram \u2014 dropped"
|
|
64624
|
+
});
|
|
64050
64625
|
return;
|
|
64051
64626
|
}
|
|
64052
64627
|
const msg = parseVendorFrame(raw);
|
|
@@ -64074,7 +64649,11 @@ function createDeepgramAdapter(webSocketClient) {
|
|
|
64074
64649
|
for (const fn of functions) {
|
|
64075
64650
|
void dispatchToolCall(fn, tools, ctx, dgWs, callbacks, session).catch((err) => {
|
|
64076
64651
|
const sanitized = sanitizeVendorError(err);
|
|
64077
|
-
callbacks.onError({
|
|
64652
|
+
callbacks.onError({
|
|
64653
|
+
message: sanitized.message,
|
|
64654
|
+
code: sanitized.code,
|
|
64655
|
+
raw: sanitized
|
|
64656
|
+
});
|
|
64078
64657
|
});
|
|
64079
64658
|
}
|
|
64080
64659
|
break;
|
|
@@ -64362,7 +64941,10 @@ function builtInTools(hangupEnabled, transferNumber, ctx) {
|
|
|
64362
64941
|
type: "object",
|
|
64363
64942
|
properties: {
|
|
64364
64943
|
reason: { type: "string", description: "Why the call is being transferred." },
|
|
64365
|
-
summary: {
|
|
64944
|
+
summary: {
|
|
64945
|
+
type: "string",
|
|
64946
|
+
description: "A brief summary of the call so far, for the human."
|
|
64947
|
+
}
|
|
64366
64948
|
},
|
|
64367
64949
|
required: ["reason", "summary"]
|
|
64368
64950
|
},
|
|
@@ -64423,7 +65005,12 @@ function providerOptionsFor2(options) {
|
|
|
64423
65005
|
return options.providerOptions?.["openai"] ?? {};
|
|
64424
65006
|
}
|
|
64425
65007
|
function encodeResponsesTools(tools) {
|
|
64426
|
-
return tools.map((t) => ({
|
|
65008
|
+
return tools.map((t) => ({
|
|
65009
|
+
type: "function",
|
|
65010
|
+
name: t.name,
|
|
65011
|
+
description: t.description,
|
|
65012
|
+
parameters: t.parameters
|
|
65013
|
+
}));
|
|
64427
65014
|
}
|
|
64428
65015
|
function buildInstructions(options) {
|
|
64429
65016
|
if (!options.greeting)
|
|
@@ -64520,7 +65107,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64520
65107
|
throw new Error("realtimeAgent: provider 'openai' needs OPENAI_API_KEY \u2014 set it as a function secret.");
|
|
64521
65108
|
}
|
|
64522
65109
|
const WebSocketClient = webSocketClient ?? loadWebSocketClient("openai");
|
|
64523
|
-
const vendorWs = new WebSocketClient(GPT_LIVE_URL, {
|
|
65110
|
+
const vendorWs = new WebSocketClient(GPT_LIVE_URL, {
|
|
65111
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
65112
|
+
});
|
|
64524
65113
|
const session = {
|
|
64525
65114
|
ws: vendorWs,
|
|
64526
65115
|
ready: false,
|
|
@@ -64626,7 +65215,14 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64626
65215
|
session.lastDelegationId = void 0;
|
|
64627
65216
|
}
|
|
64628
65217
|
if (text)
|
|
64629
|
-
callbacks.onTurn({
|
|
65218
|
+
callbacks.onTurn({
|
|
65219
|
+
role: "agent",
|
|
65220
|
+
text,
|
|
65221
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65222
|
+
playbackStartAt,
|
|
65223
|
+
playbackEndAt,
|
|
65224
|
+
delegationMs
|
|
65225
|
+
});
|
|
64630
65226
|
};
|
|
64631
65227
|
const scheduleAgentTurnFlush = () => {
|
|
64632
65228
|
if (session.agentTurnTimer !== void 0)
|
|
@@ -64645,7 +65241,13 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64645
65241
|
const text = session.pendingUserTurnText;
|
|
64646
65242
|
session.pendingUserTurnText = "";
|
|
64647
65243
|
if (text)
|
|
64648
|
-
callbacks.onTurn({
|
|
65244
|
+
callbacks.onTurn({
|
|
65245
|
+
role: "user",
|
|
65246
|
+
text,
|
|
65247
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
65248
|
+
speechStartAt,
|
|
65249
|
+
speechEndAt
|
|
65250
|
+
});
|
|
64649
65251
|
};
|
|
64650
65252
|
const scheduleUserTurnFlush = () => {
|
|
64651
65253
|
if (session.userTurnTimer !== void 0)
|
|
@@ -64692,7 +65294,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64692
65294
|
};
|
|
64693
65295
|
vendorWs.on("message", (raw) => {
|
|
64694
65296
|
if (isOversizedFrame(raw)) {
|
|
64695
|
-
callbacks.onError({
|
|
65297
|
+
callbacks.onError({
|
|
65298
|
+
message: "Received an oversized frame from OpenAI GPT-Live \u2014 dropped"
|
|
65299
|
+
});
|
|
64696
65300
|
return;
|
|
64697
65301
|
}
|
|
64698
65302
|
const msg = parseVendorFrame(raw);
|
|
@@ -64719,7 +65323,9 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64719
65323
|
case "session.output_audio.delta": {
|
|
64720
65324
|
const mulaw = safeBase64ToBuffer(msg["delta"]);
|
|
64721
65325
|
if (!mulaw) {
|
|
64722
|
-
callbacks.onError({
|
|
65326
|
+
callbacks.onError({
|
|
65327
|
+
message: "Received a malformed audio delta from OpenAI GPT-Live"
|
|
65328
|
+
});
|
|
64723
65329
|
break;
|
|
64724
65330
|
}
|
|
64725
65331
|
const pcm8k = mulawToPcm16(mulaw);
|
|
@@ -64852,7 +65458,11 @@ function createOpenAiAdapter(webSocketClient) {
|
|
|
64852
65458
|
}
|
|
64853
65459
|
case "error": {
|
|
64854
65460
|
const err = msg["error"];
|
|
64855
|
-
callbacks.onError({
|
|
65461
|
+
callbacks.onError({
|
|
65462
|
+
message: err?.message ?? "OpenAI GPT-Live error",
|
|
65463
|
+
code: err?.code,
|
|
65464
|
+
raw: msg
|
|
65465
|
+
});
|
|
64856
65466
|
if (!settled) {
|
|
64857
65467
|
settle2(() => reject(new Error(err?.message ?? "realtimeAgent: OpenAI GPT-Live error before session.started")));
|
|
64858
65468
|
closeAnyState(vendorWs);
|
|
@@ -64914,7 +65524,12 @@ var VENDOR_RATE2 = 8e3;
|
|
|
64914
65524
|
var MULAW_BYTES_PER_MS = 8;
|
|
64915
65525
|
var HANDSHAKE_TIMEOUT_MS3 = 1e4;
|
|
64916
65526
|
function encodeTools2(tools) {
|
|
64917
|
-
return tools.map((t) => ({
|
|
65527
|
+
return tools.map((t) => ({
|
|
65528
|
+
type: "function",
|
|
65529
|
+
name: t.name,
|
|
65530
|
+
description: t.description,
|
|
65531
|
+
parameters: t.parameters
|
|
65532
|
+
}));
|
|
64918
65533
|
}
|
|
64919
65534
|
async function dispatchToolCall3(callId, name, rawArgs, tools, ctx, vendorWs, callbacks) {
|
|
64920
65535
|
const start = Date.now();
|
|
@@ -65073,7 +65688,9 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65073
65688
|
};
|
|
65074
65689
|
vendorWs.on("message", (raw) => {
|
|
65075
65690
|
if (isOversizedFrame(raw)) {
|
|
65076
|
-
callbacks.onError({
|
|
65691
|
+
callbacks.onError({
|
|
65692
|
+
message: `Received an oversized frame from ${config.provider} \u2014 dropped`
|
|
65693
|
+
});
|
|
65077
65694
|
return;
|
|
65078
65695
|
}
|
|
65079
65696
|
const msg = parseVendorFrame(raw);
|
|
@@ -65106,7 +65723,9 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65106
65723
|
}
|
|
65107
65724
|
const mulaw = safeBase64ToBuffer(msg["delta"]);
|
|
65108
65725
|
if (!mulaw) {
|
|
65109
|
-
callbacks.onError({
|
|
65726
|
+
callbacks.onError({
|
|
65727
|
+
message: `Received a malformed audio delta from ${config.provider}`
|
|
65728
|
+
});
|
|
65110
65729
|
break;
|
|
65111
65730
|
}
|
|
65112
65731
|
session.bytesSentForItem += mulaw.length;
|
|
@@ -65142,7 +65761,10 @@ function createOpenAiCompatibleAdapter(config, webSocketClient) {
|
|
|
65142
65761
|
if (usage) {
|
|
65143
65762
|
session.totalInputTokens += usage.input_tokens ?? 0;
|
|
65144
65763
|
session.totalOutputTokens += usage.output_tokens ?? 0;
|
|
65145
|
-
callbacks.onUsage?.({
|
|
65764
|
+
callbacks.onUsage?.({
|
|
65765
|
+
inputTokens: session.totalInputTokens,
|
|
65766
|
+
outputTokens: session.totalOutputTokens
|
|
65767
|
+
});
|
|
65146
65768
|
}
|
|
65147
65769
|
closeResponse();
|
|
65148
65770
|
break;
|
|
@@ -65268,7 +65890,10 @@ function buildGrokSession(options, tools) {
|
|
|
65268
65890
|
// that field.
|
|
65269
65891
|
input: {
|
|
65270
65892
|
format: { type: "audio/pcmu" },
|
|
65271
|
-
transcription: {
|
|
65893
|
+
transcription: {
|
|
65894
|
+
model: "grok-transcribe",
|
|
65895
|
+
language_hint: options.language ?? DEFAULT_LANGUAGE
|
|
65896
|
+
}
|
|
65272
65897
|
},
|
|
65273
65898
|
output: { format: { type: "audio/pcmu" } }
|
|
65274
65899
|
},
|
|
@@ -65312,7 +65937,11 @@ function flushPendingTurns(session, callbacks) {
|
|
|
65312
65937
|
}
|
|
65313
65938
|
function flushPendingAgentTurn(session, callbacks) {
|
|
65314
65939
|
if (session.pendingAgentText) {
|
|
65315
|
-
callbacks.onTurn({
|
|
65940
|
+
callbacks.onTurn({
|
|
65941
|
+
role: "agent",
|
|
65942
|
+
text: session.pendingAgentText,
|
|
65943
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
65944
|
+
});
|
|
65316
65945
|
session.pendingAgentText = "";
|
|
65317
65946
|
}
|
|
65318
65947
|
}
|
|
@@ -65332,7 +65961,10 @@ function toGeminiSchema(schema) {
|
|
|
65332
65961
|
if (schema["enum"])
|
|
65333
65962
|
out["enum"] = schema["enum"];
|
|
65334
65963
|
if (kind === "object" && schema["properties"] && typeof schema["properties"] === "object") {
|
|
65335
|
-
out["properties"] = Object.fromEntries(Object.entries(schema["properties"]).map(([k, v]) => [
|
|
65964
|
+
out["properties"] = Object.fromEntries(Object.entries(schema["properties"]).map(([k, v]) => [
|
|
65965
|
+
k,
|
|
65966
|
+
toGeminiSchema(v)
|
|
65967
|
+
]));
|
|
65336
65968
|
if (Array.isArray(schema["required"]))
|
|
65337
65969
|
out["required"] = schema["required"];
|
|
65338
65970
|
}
|
|
@@ -65367,7 +65999,9 @@ function buildSetupMessage(options, model, tools, resumptionHandle) {
|
|
|
65367
65999
|
// own default voice.
|
|
65368
66000
|
speechConfig: {
|
|
65369
66001
|
languageCode: options.language ?? DEFAULT_LANGUAGE,
|
|
65370
|
-
...options.voice && {
|
|
66002
|
+
...options.voice && {
|
|
66003
|
+
voiceConfig: { prebuiltVoiceConfig: { voiceName: options.voice } }
|
|
66004
|
+
}
|
|
65371
66005
|
}
|
|
65372
66006
|
},
|
|
65373
66007
|
systemInstruction: { parts: [{ text: options.prompt }] },
|
|
@@ -65375,7 +66009,11 @@ function buildSetupMessage(options, model, tools, resumptionHandle) {
|
|
|
65375
66009
|
inputAudioTranscription: {},
|
|
65376
66010
|
outputAudioTranscription: {},
|
|
65377
66011
|
realtimeInputConfig: {
|
|
65378
|
-
automaticActivityDetection: {
|
|
66012
|
+
automaticActivityDetection: {
|
|
66013
|
+
disabled: false,
|
|
66014
|
+
silenceDurationMs: 500,
|
|
66015
|
+
prefixPaddingMs: 20
|
|
66016
|
+
},
|
|
65379
66017
|
activityHandling: "START_OF_ACTIVITY_INTERRUPTS"
|
|
65380
66018
|
},
|
|
65381
66019
|
// A phone call routinely outlives the Live API's 15-minute audio-only session window (see
|
|
@@ -65403,7 +66041,13 @@ async function dispatchToolCall4(fc, tools, ctx, session, callbacks) {
|
|
|
65403
66041
|
error = err instanceof Error ? err.message : String(err);
|
|
65404
66042
|
}
|
|
65405
66043
|
}
|
|
65406
|
-
callbacks.onToolCall({
|
|
66044
|
+
callbacks.onToolCall({
|
|
66045
|
+
name: fc.name,
|
|
66046
|
+
args: fc.args,
|
|
66047
|
+
result: result2,
|
|
66048
|
+
error,
|
|
66049
|
+
latencyMs: Date.now() - start
|
|
66050
|
+
});
|
|
65407
66051
|
if (session.cancelledCallIds.delete(fc.id))
|
|
65408
66052
|
return;
|
|
65409
66053
|
if (session.ws.readyState !== session.ws.OPEN)
|
|
@@ -65412,14 +66056,20 @@ async function dispatchToolCall4(fc, tools, ctx, session, callbacks) {
|
|
|
65412
66056
|
session.ws.send(JSON.stringify({
|
|
65413
66057
|
toolResponse: {
|
|
65414
66058
|
// The structured result object itself, not a JSON-encoded string — see the file header.
|
|
65415
|
-
functionResponses: [
|
|
66059
|
+
functionResponses: [
|
|
66060
|
+
{ id: fc.id, name: fc.name, response: error ? { error } : result2 ?? {} }
|
|
66061
|
+
]
|
|
65416
66062
|
}
|
|
65417
66063
|
}));
|
|
65418
66064
|
} catch {
|
|
65419
66065
|
session.ws.send(JSON.stringify({
|
|
65420
66066
|
toolResponse: {
|
|
65421
66067
|
functionResponses: [
|
|
65422
|
-
{
|
|
66068
|
+
{
|
|
66069
|
+
id: fc.id,
|
|
66070
|
+
name: fc.name,
|
|
66071
|
+
response: { error: "realtimeAgent: tool result could not be serialized" }
|
|
66072
|
+
}
|
|
65423
66073
|
]
|
|
65424
66074
|
}
|
|
65425
66075
|
}));
|
|
@@ -65462,7 +66112,11 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65462
66112
|
let greeted = false;
|
|
65463
66113
|
const sendRealtimeAudio = (pcm) => {
|
|
65464
66114
|
const pcm16k = session.resamplerIn.push(pcm);
|
|
65465
|
-
session.ws.send(JSON.stringify({
|
|
66115
|
+
session.ws.send(JSON.stringify({
|
|
66116
|
+
realtimeInput: {
|
|
66117
|
+
audio: { data: pcm16k.toString("base64"), mimeType: "audio/pcm;rate=16000" }
|
|
66118
|
+
}
|
|
66119
|
+
}));
|
|
65466
66120
|
};
|
|
65467
66121
|
const flushBufferedAudio = () => {
|
|
65468
66122
|
const chunks = session.audioBuffer;
|
|
@@ -65520,7 +66174,9 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65520
66174
|
});
|
|
65521
66175
|
liveWs.on("message", (raw) => {
|
|
65522
66176
|
if (isOversizedFrame(raw)) {
|
|
65523
|
-
callbacks.onError({
|
|
66177
|
+
callbacks.onError({
|
|
66178
|
+
message: "Received an oversized frame from Gemini Live \u2014 dropped"
|
|
66179
|
+
});
|
|
65524
66180
|
return;
|
|
65525
66181
|
}
|
|
65526
66182
|
const msg = parseVendorFrame(raw);
|
|
@@ -65565,21 +66221,27 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65565
66221
|
if (Array.isArray(parts)) {
|
|
65566
66222
|
for (const part of parts) {
|
|
65567
66223
|
if (!isPlainObject(part)) {
|
|
65568
|
-
callbacks.onError({
|
|
66224
|
+
callbacks.onError({
|
|
66225
|
+
message: "Received a malformed audio part from Gemini Live"
|
|
66226
|
+
});
|
|
65569
66227
|
continue;
|
|
65570
66228
|
}
|
|
65571
66229
|
const inlineData = part["inlineData"];
|
|
65572
66230
|
const data = isPlainObject(inlineData) ? inlineData["data"] : void 0;
|
|
65573
66231
|
const pcm24k = safeBase64ToBuffer(data);
|
|
65574
66232
|
if (data && !pcm24k) {
|
|
65575
|
-
callbacks.onError({
|
|
66233
|
+
callbacks.onError({
|
|
66234
|
+
message: "Received a malformed audio part from Gemini Live"
|
|
66235
|
+
});
|
|
65576
66236
|
continue;
|
|
65577
66237
|
}
|
|
65578
66238
|
if (pcm24k)
|
|
65579
66239
|
callbacks.onAudioOut(session.resamplerOut.push(pcm24k));
|
|
65580
66240
|
}
|
|
65581
66241
|
} else if (parts !== void 0) {
|
|
65582
|
-
callbacks.onError({
|
|
66242
|
+
callbacks.onError({
|
|
66243
|
+
message: "Received a malformed modelTurn from Gemini Live \u2014 parts was not an array"
|
|
66244
|
+
});
|
|
65583
66245
|
}
|
|
65584
66246
|
if (content.interimInputTranscription?.text && !session.speechStartReported) {
|
|
65585
66247
|
session.speechStartReported = true;
|
|
@@ -65604,12 +66266,18 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65604
66266
|
if (Array.isArray(functionCalls)) {
|
|
65605
66267
|
for (const fc of functionCalls) {
|
|
65606
66268
|
if (!isPlainObject(fc) || typeof fc["id"] !== "string" || typeof fc["name"] !== "string") {
|
|
65607
|
-
callbacks.onError({
|
|
66269
|
+
callbacks.onError({
|
|
66270
|
+
message: "Received a malformed function call from Gemini Live"
|
|
66271
|
+
});
|
|
65608
66272
|
continue;
|
|
65609
66273
|
}
|
|
65610
66274
|
void dispatchToolCall4({ id: fc["id"], name: fc["name"], args: fc["args"] }, tools, ctx, session, callbacks).catch((err) => {
|
|
65611
66275
|
const sanitized = sanitizeVendorError(err);
|
|
65612
|
-
callbacks.onError({
|
|
66276
|
+
callbacks.onError({
|
|
66277
|
+
message: sanitized.message,
|
|
66278
|
+
code: sanitized.code,
|
|
66279
|
+
raw: sanitized
|
|
66280
|
+
});
|
|
65613
66281
|
});
|
|
65614
66282
|
}
|
|
65615
66283
|
} else if (functionCalls !== void 0) {
|
|
@@ -65630,7 +66298,10 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65630
66298
|
});
|
|
65631
66299
|
}
|
|
65632
66300
|
if (msg["goAway"] !== void 0) {
|
|
65633
|
-
callbacks.onError({
|
|
66301
|
+
callbacks.onError({
|
|
66302
|
+
message: "Gemini Live sent goAway \u2014 session will close soon",
|
|
66303
|
+
raw: msg["goAway"]
|
|
66304
|
+
});
|
|
65634
66305
|
}
|
|
65635
66306
|
});
|
|
65636
66307
|
liveWs.on("error", (err) => {
|
|
@@ -65688,7 +66359,11 @@ function createGeminiAdapter(webSocketClient) {
|
|
|
65688
66359
|
return;
|
|
65689
66360
|
}
|
|
65690
66361
|
const pcm16k = s.resamplerIn.push(pcm);
|
|
65691
|
-
s.ws.send(JSON.stringify({
|
|
66362
|
+
s.ws.send(JSON.stringify({
|
|
66363
|
+
realtimeInput: {
|
|
66364
|
+
audio: { data: pcm16k.toString("base64"), mimeType: "audio/pcm;rate=16000" }
|
|
66365
|
+
}
|
|
66366
|
+
}));
|
|
65692
66367
|
},
|
|
65693
66368
|
clear() {
|
|
65694
66369
|
},
|
|
@@ -65814,7 +66489,12 @@ function toResponsesInput(input) {
|
|
|
65814
66489
|
return { type: "function_call_output", call_id: turn.toolCallId, output: turn.output };
|
|
65815
66490
|
}
|
|
65816
66491
|
if (turn.role === "tool_call") {
|
|
65817
|
-
return {
|
|
66492
|
+
return {
|
|
66493
|
+
type: "function_call",
|
|
66494
|
+
call_id: turn.id,
|
|
66495
|
+
name: turn.name,
|
|
66496
|
+
arguments: JSON.stringify(turn.arguments ?? {})
|
|
66497
|
+
};
|
|
65818
66498
|
}
|
|
65819
66499
|
return { role: turn.role, content: turn.content };
|
|
65820
66500
|
});
|
|
@@ -65870,7 +66550,12 @@ function createResponsesEventState(callbacks) {
|
|
|
65870
66550
|
let functionCallDetected = false;
|
|
65871
66551
|
const dispatch = (entry, finalArgs) => {
|
|
65872
66552
|
const { value, error } = parseToolArgs(finalArgs);
|
|
65873
|
-
callbacks.onToolCall({
|
|
66553
|
+
callbacks.onToolCall({
|
|
66554
|
+
id: entry.callId,
|
|
66555
|
+
name: entry.name,
|
|
66556
|
+
arguments: value,
|
|
66557
|
+
...error && { argsError: error }
|
|
66558
|
+
});
|
|
65874
66559
|
};
|
|
65875
66560
|
return {
|
|
65876
66561
|
feedEvent(event) {
|
|
@@ -65891,7 +66576,12 @@ function createResponsesEventState(callbacks) {
|
|
|
65891
66576
|
case "response.output_item.added": {
|
|
65892
66577
|
const item = event["item"];
|
|
65893
66578
|
if (item?.type === "function_call" && item.id && item.name) {
|
|
65894
|
-
toolCalls.set(item.id, {
|
|
66579
|
+
toolCalls.set(item.id, {
|
|
66580
|
+
callId: item.call_id ?? item.id,
|
|
66581
|
+
name: item.name,
|
|
66582
|
+
args: "",
|
|
66583
|
+
dispatched: false
|
|
66584
|
+
});
|
|
65895
66585
|
if (!functionCallDetected) {
|
|
65896
66586
|
functionCallDetected = true;
|
|
65897
66587
|
callbacks.onFunctionCallDetected?.(item.name);
|
|
@@ -65928,7 +66618,10 @@ function createResponsesEventState(callbacks) {
|
|
|
65928
66618
|
const flushed = sentences.flush();
|
|
65929
66619
|
if (flushed)
|
|
65930
66620
|
callbacks.onSentence(flushed);
|
|
65931
|
-
const usage = response?.usage ? {
|
|
66621
|
+
const usage = response?.usage ? {
|
|
66622
|
+
inputTokens: response.usage.input_tokens,
|
|
66623
|
+
outputTokens: response.usage.output_tokens
|
|
66624
|
+
} : void 0;
|
|
65932
66625
|
return { text, responseId, usage };
|
|
65933
66626
|
}
|
|
65934
66627
|
case "response.failed": {
|
|
@@ -66001,8 +66694,8 @@ var FIRST_OUTPUT_TIMEOUT_MS = 3e3;
|
|
|
66001
66694
|
var RESPONSE_TIMEOUT_MS = 15e3;
|
|
66002
66695
|
function buildResponsesWsUrl(baseUrl) {
|
|
66003
66696
|
const base = resolveBaseUrl(baseUrl) ?? DEFAULT_RESPONSES_BASE_URL;
|
|
66004
|
-
const
|
|
66005
|
-
const url2 = new URL(base + (base.endsWith("/") ?
|
|
66697
|
+
const path7 = "/responses";
|
|
66698
|
+
const url2 = new URL(base + (base.endsWith("/") ? path7.slice(1) : path7));
|
|
66006
66699
|
url2.protocol = url2.protocol === "http:" ? "ws:" : "wss:";
|
|
66007
66700
|
return url2.toString();
|
|
66008
66701
|
}
|
|
@@ -66012,7 +66705,9 @@ var RawResponsesWs = class {
|
|
|
66012
66705
|
errorHandlers = [];
|
|
66013
66706
|
constructor(apiKey, baseUrl) {
|
|
66014
66707
|
const WebSocketClient = loadWebSocketClient("voice-relay");
|
|
66015
|
-
this.socket = new WebSocketClient(buildResponsesWsUrl(baseUrl), {
|
|
66708
|
+
this.socket = new WebSocketClient(buildResponsesWsUrl(baseUrl), {
|
|
66709
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
66710
|
+
});
|
|
66016
66711
|
this.socket.on("message", (data) => {
|
|
66017
66712
|
let event;
|
|
66018
66713
|
try {
|
|
@@ -66436,7 +67131,9 @@ function attach(options, pendingByCallId, transferredCallIds, call) {
|
|
|
66436
67131
|
usage.outputTokens = (usage.outputTokens ?? 0) + (result2.usage.outputTokens ?? 0);
|
|
66437
67132
|
}
|
|
66438
67133
|
call.send("", { last: true });
|
|
66439
|
-
const roundItems = [
|
|
67134
|
+
const roundItems = [
|
|
67135
|
+
...newInput
|
|
67136
|
+
];
|
|
66440
67137
|
let agentEntry;
|
|
66441
67138
|
if (result2.text) {
|
|
66442
67139
|
agentEntry = { role: "agent", text: result2.text, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -66462,7 +67159,12 @@ function attach(options, pendingByCallId, transferredCallIds, call) {
|
|
|
66462
67159
|
previousResponseId = result2.responseId ?? previousResponseId;
|
|
66463
67160
|
const nextInput = inFlight.map((f, i) => {
|
|
66464
67161
|
if (!chainingEnabled) {
|
|
66465
|
-
roundItems.push({
|
|
67162
|
+
roundItems.push({
|
|
67163
|
+
role: "tool_call",
|
|
67164
|
+
id: f.call.id,
|
|
67165
|
+
name: f.call.name,
|
|
67166
|
+
arguments: f.call.arguments
|
|
67167
|
+
});
|
|
66466
67168
|
}
|
|
66467
67169
|
const outcome = outcomes[i];
|
|
66468
67170
|
return {
|
|
@@ -66586,7 +67288,14 @@ async function resolvePerCallOptions(options, call, context, ctx) {
|
|
|
66586
67288
|
if (offersHangup(tools)) {
|
|
66587
67289
|
resolvedPrompt += options.provider === "openai" ? DELEGATED_CALL_TERMINATION_INSTRUCTIONS : CALL_TERMINATION_INSTRUCTIONS;
|
|
66588
67290
|
}
|
|
66589
|
-
return {
|
|
67291
|
+
return {
|
|
67292
|
+
...rest,
|
|
67293
|
+
prompt: resolvedPrompt,
|
|
67294
|
+
greeting,
|
|
67295
|
+
voice,
|
|
67296
|
+
tools,
|
|
67297
|
+
language: language ?? DEFAULT_LANGUAGE
|
|
67298
|
+
};
|
|
66590
67299
|
}
|
|
66591
67300
|
function realtimeAgent(options) {
|
|
66592
67301
|
if (!options.provider) {
|
|
@@ -66770,7 +67479,11 @@ function realtimeAgent(options) {
|
|
|
66770
67479
|
});
|
|
66771
67480
|
},
|
|
66772
67481
|
onTurn(turn) {
|
|
66773
|
-
const entry = {
|
|
67482
|
+
const entry = {
|
|
67483
|
+
role: turn.role,
|
|
67484
|
+
text: turn.text,
|
|
67485
|
+
timestamp: turn.timestamp
|
|
67486
|
+
};
|
|
66774
67487
|
if (turn.role === "user") {
|
|
66775
67488
|
flushPendingStreamLog();
|
|
66776
67489
|
lastUserTurnAt = Date.now();
|
|
@@ -67429,7 +68142,7 @@ function semver_compare_default(a, b) {
|
|
|
67429
68142
|
|
|
67430
68143
|
// ../../node_modules/libphonenumber-js/es6/helpers/isObject.js
|
|
67431
68144
|
var objectConstructor = {}.constructor;
|
|
67432
|
-
function
|
|
68145
|
+
function isObject2(object) {
|
|
67433
68146
|
return object !== void 0 && object !== null && object.constructor === objectConstructor;
|
|
67434
68147
|
}
|
|
67435
68148
|
|
|
@@ -67837,7 +68550,7 @@ var NumberingPlan = /* @__PURE__ */ (function() {
|
|
|
67837
68550
|
}
|
|
67838
68551
|
}, {
|
|
67839
68552
|
key: "types",
|
|
67840
|
-
value: function
|
|
68553
|
+
value: function types2() {
|
|
67841
68554
|
return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
|
|
67842
68555
|
}
|
|
67843
68556
|
}, {
|
|
@@ -67934,36 +68647,36 @@ var Type = /* @__PURE__ */ (function() {
|
|
|
67934
68647
|
}
|
|
67935
68648
|
}]);
|
|
67936
68649
|
})();
|
|
67937
|
-
function getType(
|
|
68650
|
+
function getType(types2, type) {
|
|
67938
68651
|
switch (type) {
|
|
67939
68652
|
case "FIXED_LINE":
|
|
67940
|
-
return
|
|
68653
|
+
return types2[0];
|
|
67941
68654
|
case "MOBILE":
|
|
67942
|
-
return
|
|
68655
|
+
return types2[1];
|
|
67943
68656
|
case "TOLL_FREE":
|
|
67944
|
-
return
|
|
68657
|
+
return types2[2];
|
|
67945
68658
|
case "PREMIUM_RATE":
|
|
67946
|
-
return
|
|
68659
|
+
return types2[3];
|
|
67947
68660
|
case "PERSONAL_NUMBER":
|
|
67948
|
-
return
|
|
68661
|
+
return types2[4];
|
|
67949
68662
|
case "VOICEMAIL":
|
|
67950
|
-
return
|
|
68663
|
+
return types2[5];
|
|
67951
68664
|
case "UAN":
|
|
67952
|
-
return
|
|
68665
|
+
return types2[6];
|
|
67953
68666
|
case "PAGER":
|
|
67954
|
-
return
|
|
68667
|
+
return types2[7];
|
|
67955
68668
|
case "VOIP":
|
|
67956
|
-
return
|
|
68669
|
+
return types2[8];
|
|
67957
68670
|
case "SHARED_COST":
|
|
67958
|
-
return
|
|
68671
|
+
return types2[9];
|
|
67959
68672
|
}
|
|
67960
68673
|
}
|
|
67961
68674
|
function validateMetadata(metadata) {
|
|
67962
68675
|
if (!metadata) {
|
|
67963
68676
|
throw new Error("[libphonenumber-js] `metadata` argument not passed. Check your arguments.");
|
|
67964
68677
|
}
|
|
67965
|
-
if (!
|
|
67966
|
-
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(
|
|
68678
|
+
if (!isObject2(metadata) || !isObject2(metadata.countries)) {
|
|
68679
|
+
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(isObject2(metadata) ? "an object of shape: { " + Object.keys(metadata).join(", ") + " }" : "a " + typeOf(metadata) + ": " + metadata, "."));
|
|
67967
68680
|
}
|
|
67968
68681
|
}
|
|
67969
68682
|
var typeOf = function typeOf2(_) {
|
|
@@ -68816,7 +69529,7 @@ var PhoneNumber = /* @__PURE__ */ (function() {
|
|
|
68816
69529
|
if (countryOrCountryCallingCode[0] === "+" && !nationalNumber) {
|
|
68817
69530
|
throw new TypeError("`metadata` argument not passed");
|
|
68818
69531
|
}
|
|
68819
|
-
if (
|
|
69532
|
+
if (isObject2(nationalNumber) && isObject2(nationalNumber.countries)) {
|
|
68820
69533
|
metadata = nationalNumber;
|
|
68821
69534
|
var e164Number = countryOrCountryCallingCode;
|
|
68822
69535
|
if (!E164_NUMBER_REGEXP.test(e164Number)) {
|
|
@@ -69629,7 +70342,7 @@ function normalizeArguments(args) {
|
|
|
69629
70342
|
defaultCountry: arg_2
|
|
69630
70343
|
}, options);
|
|
69631
70344
|
}
|
|
69632
|
-
} else if (
|
|
70345
|
+
} else if (isObject2(arg_2)) {
|
|
69633
70346
|
if (arg_3) {
|
|
69634
70347
|
options = arg_2;
|
|
69635
70348
|
metadata = arg_3;
|
|
@@ -70152,7 +70865,7 @@ function isArrayBufferView(val) {
|
|
|
70152
70865
|
var isString = typeOfTest("string");
|
|
70153
70866
|
var isFunction = typeOfTest("function");
|
|
70154
70867
|
var isNumber = typeOfTest("number");
|
|
70155
|
-
var
|
|
70868
|
+
var isObject3 = (thing) => thing !== null && typeof thing === "object";
|
|
70156
70869
|
var isBoolean = (thing) => thing === true || thing === false;
|
|
70157
70870
|
var isPlainObject2 = (val) => {
|
|
70158
70871
|
if (kindOf(val) !== "object") {
|
|
@@ -70162,7 +70875,7 @@ var isPlainObject2 = (val) => {
|
|
|
70162
70875
|
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(toStringTag in val) && !(iterator in val);
|
|
70163
70876
|
};
|
|
70164
70877
|
var isEmptyObject = (val) => {
|
|
70165
|
-
if (!
|
|
70878
|
+
if (!isObject3(val) || isBuffer(val)) {
|
|
70166
70879
|
return false;
|
|
70167
70880
|
}
|
|
70168
70881
|
try {
|
|
@@ -70179,7 +70892,7 @@ var isReactNativeBlob = (value) => {
|
|
|
70179
70892
|
var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
|
|
70180
70893
|
var isBlob2 = kindOfTest("Blob");
|
|
70181
70894
|
var isFileList = kindOfTest("FileList");
|
|
70182
|
-
var isStream = (val) =>
|
|
70895
|
+
var isStream = (val) => isObject3(val) && isFunction(val.pipe);
|
|
70183
70896
|
function getGlobal() {
|
|
70184
70897
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
70185
70898
|
if (typeof self !== "undefined") return self;
|
|
@@ -70451,7 +71164,7 @@ function isSpecCompliantForm(thing) {
|
|
|
70451
71164
|
var toJSONObject = (obj) => {
|
|
70452
71165
|
const stack = new Array(10);
|
|
70453
71166
|
const visit = (source, i) => {
|
|
70454
|
-
if (
|
|
71167
|
+
if (isObject3(source)) {
|
|
70455
71168
|
if (stack.indexOf(source) >= 0) {
|
|
70456
71169
|
return;
|
|
70457
71170
|
}
|
|
@@ -70474,7 +71187,7 @@ var toJSONObject = (obj) => {
|
|
|
70474
71187
|
return visit(obj, 0);
|
|
70475
71188
|
};
|
|
70476
71189
|
var isAsyncFn = kindOfTest("AsyncFunction");
|
|
70477
|
-
var isThenable = (thing) => thing && (
|
|
71190
|
+
var isThenable = (thing) => thing && (isObject3(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
70478
71191
|
var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
70479
71192
|
if (setImmediateSupported) {
|
|
70480
71193
|
return setImmediate;
|
|
@@ -70506,7 +71219,7 @@ var utils_default = {
|
|
|
70506
71219
|
isString,
|
|
70507
71220
|
isNumber,
|
|
70508
71221
|
isBoolean,
|
|
70509
|
-
isObject:
|
|
71222
|
+
isObject: isObject3,
|
|
70510
71223
|
isPlainObject: isPlainObject2,
|
|
70511
71224
|
isEmptyObject,
|
|
70512
71225
|
isReadableStream,
|
|
@@ -70740,22 +71453,22 @@ var AxiosHeaders = class {
|
|
|
70740
71453
|
}
|
|
70741
71454
|
}
|
|
70742
71455
|
}
|
|
70743
|
-
has(header,
|
|
71456
|
+
has(header, matcher2) {
|
|
70744
71457
|
header = normalizeHeader(header);
|
|
70745
71458
|
if (header) {
|
|
70746
71459
|
const key = utils_default.findKey(this, header);
|
|
70747
|
-
return !!(key && this[key] !== void 0 && (!
|
|
71460
|
+
return !!(key && this[key] !== void 0 && (!matcher2 || matchHeaderValue(this, this[key], key, matcher2)));
|
|
70748
71461
|
}
|
|
70749
71462
|
return false;
|
|
70750
71463
|
}
|
|
70751
|
-
delete(header,
|
|
71464
|
+
delete(header, matcher2) {
|
|
70752
71465
|
const self2 = this;
|
|
70753
71466
|
let deleted = false;
|
|
70754
71467
|
function deleteHeader(_header) {
|
|
70755
71468
|
_header = normalizeHeader(_header);
|
|
70756
71469
|
if (_header) {
|
|
70757
71470
|
const key = utils_default.findKey(self2, _header);
|
|
70758
|
-
if (key && (!
|
|
71471
|
+
if (key && (!matcher2 || matchHeaderValue(self2, self2[key], key, matcher2))) {
|
|
70759
71472
|
delete self2[key];
|
|
70760
71473
|
deleted = true;
|
|
70761
71474
|
}
|
|
@@ -70768,13 +71481,13 @@ var AxiosHeaders = class {
|
|
|
70768
71481
|
}
|
|
70769
71482
|
return deleted;
|
|
70770
71483
|
}
|
|
70771
|
-
clear(
|
|
71484
|
+
clear(matcher2) {
|
|
70772
71485
|
const keys = Object.keys(this);
|
|
70773
71486
|
let i = keys.length;
|
|
70774
71487
|
let deleted = false;
|
|
70775
71488
|
while (i--) {
|
|
70776
71489
|
const key = keys[i];
|
|
70777
|
-
if (!
|
|
71490
|
+
if (!matcher2 || matchHeaderValue(this, this[key], key, matcher2, true)) {
|
|
70778
71491
|
delete this[key];
|
|
70779
71492
|
deleted = true;
|
|
70780
71493
|
}
|
|
@@ -70868,7 +71581,7 @@ utils_default.freezeMethods(AxiosHeaders);
|
|
|
70868
71581
|
var AxiosHeaders_default = AxiosHeaders;
|
|
70869
71582
|
|
|
70870
71583
|
// ../../node_modules/axios/lib/core/AxiosError.js
|
|
70871
|
-
var
|
|
71584
|
+
var REDACTED3 = "[REDACTED ****]";
|
|
70872
71585
|
function hasOwnOrPrototypeToJSON(source) {
|
|
70873
71586
|
if (utils_default.hasOwnProp(source, "toJSON")) {
|
|
70874
71587
|
return true;
|
|
@@ -70909,7 +71622,7 @@ function redactConfig(config, redactKeys) {
|
|
|
70909
71622
|
}
|
|
70910
71623
|
result2 = /* @__PURE__ */ Object.create(null);
|
|
70911
71624
|
for (const [key, value] of Object.entries(source)) {
|
|
70912
|
-
const reducedValue = lowerKeys.has(key.toLowerCase()) ?
|
|
71625
|
+
const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED3 : visit(value);
|
|
70913
71626
|
if (!utils_default.isUndefined(reducedValue)) {
|
|
70914
71627
|
result2[key] = reducedValue;
|
|
70915
71628
|
}
|
|
@@ -71013,9 +71726,9 @@ function isVisitable(thing) {
|
|
|
71013
71726
|
function removeBrackets(key) {
|
|
71014
71727
|
return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
71015
71728
|
}
|
|
71016
|
-
function renderKey(
|
|
71017
|
-
if (!
|
|
71018
|
-
return
|
|
71729
|
+
function renderKey(path7, key, dots) {
|
|
71730
|
+
if (!path7) return key;
|
|
71731
|
+
return path7.concat(key).map(function each(token, i) {
|
|
71019
71732
|
token = removeBrackets(token);
|
|
71020
71733
|
return !dots && i ? "[" + token + "]" : token;
|
|
71021
71734
|
}).join(dots ? "." : "");
|
|
@@ -71069,13 +71782,13 @@ function toFormData(obj, formData, options) {
|
|
|
71069
71782
|
}
|
|
71070
71783
|
return value;
|
|
71071
71784
|
}
|
|
71072
|
-
function defaultVisitor(value, key,
|
|
71785
|
+
function defaultVisitor(value, key, path7) {
|
|
71073
71786
|
let arr = value;
|
|
71074
71787
|
if (utils_default.isReactNative(formData) && utils_default.isReactNativeBlob(value)) {
|
|
71075
|
-
formData.append(renderKey(
|
|
71788
|
+
formData.append(renderKey(path7, key, dots), convertValue(value));
|
|
71076
71789
|
return false;
|
|
71077
71790
|
}
|
|
71078
|
-
if (value && !
|
|
71791
|
+
if (value && !path7 && typeof value === "object") {
|
|
71079
71792
|
if (utils_default.endsWith(key, "{}")) {
|
|
71080
71793
|
key = metaTokens ? key : key.slice(0, -2);
|
|
71081
71794
|
value = JSON.stringify(value);
|
|
@@ -71094,7 +71807,7 @@ function toFormData(obj, formData, options) {
|
|
|
71094
71807
|
if (isVisitable(value)) {
|
|
71095
71808
|
return true;
|
|
71096
71809
|
}
|
|
71097
|
-
formData.append(renderKey(
|
|
71810
|
+
formData.append(renderKey(path7, key, dots), convertValue(value));
|
|
71098
71811
|
return false;
|
|
71099
71812
|
}
|
|
71100
71813
|
const stack = [];
|
|
@@ -71103,7 +71816,7 @@ function toFormData(obj, formData, options) {
|
|
|
71103
71816
|
convertValue,
|
|
71104
71817
|
isVisitable
|
|
71105
71818
|
});
|
|
71106
|
-
function build(value,
|
|
71819
|
+
function build(value, path7, depth = 0) {
|
|
71107
71820
|
if (utils_default.isUndefined(value)) return;
|
|
71108
71821
|
if (depth > maxDepth) {
|
|
71109
71822
|
throw new AxiosError_default(
|
|
@@ -71112,13 +71825,13 @@ function toFormData(obj, formData, options) {
|
|
|
71112
71825
|
);
|
|
71113
71826
|
}
|
|
71114
71827
|
if (stack.indexOf(value) !== -1) {
|
|
71115
|
-
throw Error("Circular reference detected in " +
|
|
71828
|
+
throw Error("Circular reference detected in " + path7.join("."));
|
|
71116
71829
|
}
|
|
71117
71830
|
stack.push(value);
|
|
71118
71831
|
utils_default.forEach(value, function each(el, key) {
|
|
71119
|
-
const result2 = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key,
|
|
71832
|
+
const result2 = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key, path7, exposedHelpers);
|
|
71120
71833
|
if (result2 === true) {
|
|
71121
|
-
build(el,
|
|
71834
|
+
build(el, path7 ? path7.concat(key) : [key], depth + 1);
|
|
71122
71835
|
}
|
|
71123
71836
|
});
|
|
71124
71837
|
stack.pop();
|
|
@@ -71329,7 +72042,7 @@ var platform_default = {
|
|
|
71329
72042
|
// ../../node_modules/axios/lib/helpers/toURLEncodedForm.js
|
|
71330
72043
|
function toURLEncodedForm(data, options) {
|
|
71331
72044
|
return toFormData_default(data, new platform_default.classes.URLSearchParams(), {
|
|
71332
|
-
visitor: function(value, key,
|
|
72045
|
+
visitor: function(value, key, path7, helpers) {
|
|
71333
72046
|
if (platform_default.isNode && utils_default.isBuffer(value)) {
|
|
71334
72047
|
this.append(key, value.toString("base64"));
|
|
71335
72048
|
return false;
|
|
@@ -71359,11 +72072,11 @@ function arrayToObject(arr) {
|
|
|
71359
72072
|
return obj;
|
|
71360
72073
|
}
|
|
71361
72074
|
function formDataToJSON(formData) {
|
|
71362
|
-
function buildPath(
|
|
71363
|
-
let name =
|
|
72075
|
+
function buildPath(path7, value, target, index) {
|
|
72076
|
+
let name = path7[index++];
|
|
71364
72077
|
if (name === "__proto__") return true;
|
|
71365
72078
|
const isNumericKey = Number.isFinite(+name);
|
|
71366
|
-
const isLast = index >=
|
|
72079
|
+
const isLast = index >= path7.length;
|
|
71367
72080
|
name = !name && utils_default.isArray(target) ? target.length : name;
|
|
71368
72081
|
if (isLast) {
|
|
71369
72082
|
if (utils_default.hasOwnProp(target, name)) {
|
|
@@ -71376,7 +72089,7 @@ function formDataToJSON(formData) {
|
|
|
71376
72089
|
if (!target[name] || !utils_default.isObject(target[name])) {
|
|
71377
72090
|
target[name] = [];
|
|
71378
72091
|
}
|
|
71379
|
-
const result2 = buildPath(
|
|
72092
|
+
const result2 = buildPath(path7, value, target[name], index);
|
|
71380
72093
|
if (result2 && utils_default.isArray(target[name])) {
|
|
71381
72094
|
target[name] = arrayToObject(target[name]);
|
|
71382
72095
|
}
|
|
@@ -72774,9 +73487,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
72774
73487
|
auth = urlUsername + ":" + urlPassword;
|
|
72775
73488
|
}
|
|
72776
73489
|
auth && headers.delete("authorization");
|
|
72777
|
-
let
|
|
73490
|
+
let path7;
|
|
72778
73491
|
try {
|
|
72779
|
-
|
|
73492
|
+
path7 = buildURL(
|
|
72780
73493
|
parsed.pathname + parsed.search,
|
|
72781
73494
|
config.params,
|
|
72782
73495
|
config.paramsSerializer
|
|
@@ -72794,7 +73507,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
72794
73507
|
false
|
|
72795
73508
|
);
|
|
72796
73509
|
const options = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
72797
|
-
path:
|
|
73510
|
+
path: path7,
|
|
72798
73511
|
method,
|
|
72799
73512
|
headers: headers.toJSON(),
|
|
72800
73513
|
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
@@ -73133,14 +73846,14 @@ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PUR
|
|
|
73133
73846
|
var cookies_default = platform_default.hasStandardBrowserEnv ? (
|
|
73134
73847
|
// Standard browser envs support document.cookie
|
|
73135
73848
|
{
|
|
73136
|
-
write(name, value, expires,
|
|
73849
|
+
write(name, value, expires, path7, domain, secure, sameSite) {
|
|
73137
73850
|
if (typeof document === "undefined") return;
|
|
73138
73851
|
const cookie = [`${name}=${encodeURIComponent(value)}`];
|
|
73139
73852
|
if (utils_default.isNumber(expires)) {
|
|
73140
73853
|
cookie.push(`expires=${new Date(expires).toUTCString()}`);
|
|
73141
73854
|
}
|
|
73142
|
-
if (utils_default.isString(
|
|
73143
|
-
cookie.push(`path=${
|
|
73855
|
+
if (utils_default.isString(path7)) {
|
|
73856
|
+
cookie.push(`path=${path7}`);
|
|
73144
73857
|
}
|
|
73145
73858
|
if (utils_default.isString(domain)) {
|
|
73146
73859
|
cookie.push(`domain=${domain}`);
|
|
@@ -74543,6 +75256,8 @@ var {
|
|
|
74543
75256
|
// src/tunnel/webhook-config.ts
|
|
74544
75257
|
var import_sdk_core2 = __toESM(require_dist11(), 1);
|
|
74545
75258
|
import { randomBytes } from "crypto";
|
|
75259
|
+
import fs4 from "fs";
|
|
75260
|
+
import path5 from "path";
|
|
74546
75261
|
var SINCH_FN_URL_PATTERN = /\.fn(-\w+)?\.sinch\.(?:com|io)/;
|
|
74547
75262
|
function isOurWebhook(target) {
|
|
74548
75263
|
return !!target && SINCH_FN_URL_PATTERN.test(target);
|
|
@@ -74554,8 +75269,24 @@ function deployedWebhookTarget(functionName) {
|
|
|
74554
75269
|
const domain = process.env.SINCH_FUNCTIONS_DOMAIN || FUNCTIONS_DOMAIN_DEFAULT;
|
|
74555
75270
|
return `https://${functionName}.${domain}/webhook/conversation`;
|
|
74556
75271
|
}
|
|
74557
|
-
|
|
74558
|
-
|
|
75272
|
+
var TUNNEL_GATEWAY_HOST_PATTERN = /^tunnel\.fn(-\w+)?\.sinch\.(com|io)$/;
|
|
75273
|
+
function isTunnelUrl(target, env = process.env) {
|
|
75274
|
+
if (!target) return false;
|
|
75275
|
+
let url2;
|
|
75276
|
+
try {
|
|
75277
|
+
url2 = new URL(target);
|
|
75278
|
+
} catch {
|
|
75279
|
+
return false;
|
|
75280
|
+
}
|
|
75281
|
+
if (TUNNEL_GATEWAY_HOST_PATTERN.test(url2.hostname)) return true;
|
|
75282
|
+
if (env.TUNNEL_GATEWAY_URL) {
|
|
75283
|
+
try {
|
|
75284
|
+
if (new URL(env.TUNNEL_GATEWAY_URL).host === url2.host) return true;
|
|
75285
|
+
} catch {
|
|
75286
|
+
}
|
|
75287
|
+
}
|
|
75288
|
+
const ingressPath = url2.pathname === "/ingress" || url2.pathname.startsWith("/ingress/");
|
|
75289
|
+
return ingressPath && url2.searchParams.has("tunnel");
|
|
74559
75290
|
}
|
|
74560
75291
|
async function configureConversationWebhooks(webhookUrl, config) {
|
|
74561
75292
|
try {
|
|
@@ -74584,11 +75315,14 @@ async function configureConversationWebhooks(webhookUrl, config) {
|
|
|
74584
75315
|
console.log("\u26A0\uFE0F No deployed webhook found \u2014 deploy first");
|
|
74585
75316
|
return;
|
|
74586
75317
|
}
|
|
74587
|
-
config.conversationWebhookId
|
|
74588
|
-
|
|
75318
|
+
if (config.conversationWebhookId !== deployedWebhook.id) {
|
|
75319
|
+
config.conversationWebhookId = deployedWebhook.id;
|
|
75320
|
+
config.originalTarget = deployedWebhook.target;
|
|
75321
|
+
}
|
|
74589
75322
|
const hmacSecret = randomBytes(32).toString("hex");
|
|
74590
75323
|
process.env.CONVERSATION_WEBHOOK_SECRET = hmacSecret;
|
|
74591
75324
|
resetSinchClients();
|
|
75325
|
+
configureSecretRedaction(process.env);
|
|
74592
75326
|
await sinchClient.conversation.webhooks.update({
|
|
74593
75327
|
webhook_id: deployedWebhook.id,
|
|
74594
75328
|
webhookUpdateRequestBody: {
|
|
@@ -74601,7 +75335,10 @@ async function configureConversationWebhooks(webhookUrl, config) {
|
|
|
74601
75335
|
console.log("\u{1F512} HMAC secret configured for webhook signature validation");
|
|
74602
75336
|
console.log("\u{1F4AC} Send a message to your Conversation app to test!");
|
|
74603
75337
|
} catch (error) {
|
|
74604
|
-
console.log(
|
|
75338
|
+
console.log(
|
|
75339
|
+
"\u26A0\uFE0F Could not configure Conversation webhooks:",
|
|
75340
|
+
error instanceof Error ? error.message : error
|
|
75341
|
+
);
|
|
74605
75342
|
}
|
|
74606
75343
|
}
|
|
74607
75344
|
async function cleanupConversationWebhook(config) {
|
|
@@ -74641,7 +75378,10 @@ async function cleanupConversationWebhook(config) {
|
|
|
74641
75378
|
delete process.env.CONVERSATION_WEBHOOK_SECRET;
|
|
74642
75379
|
resetSinchClients();
|
|
74643
75380
|
} catch (error) {
|
|
74644
|
-
console.log(
|
|
75381
|
+
console.log(
|
|
75382
|
+
"\u26A0\uFE0F Could not restore Conversation webhook:",
|
|
75383
|
+
error instanceof Error ? error.message : error
|
|
75384
|
+
);
|
|
74645
75385
|
}
|
|
74646
75386
|
}
|
|
74647
75387
|
async function configureElevenLabs() {
|
|
@@ -74656,30 +75396,88 @@ async function configureElevenLabs() {
|
|
|
74656
75396
|
console.log("\u{1F916} ElevenLabs auto-configuration enabled");
|
|
74657
75397
|
console.log(` Agent ID: ${agentId}`);
|
|
74658
75398
|
} catch (error) {
|
|
74659
|
-
console.log(
|
|
75399
|
+
console.log(
|
|
75400
|
+
"\u26A0\uFE0F Could not configure ElevenLabs:",
|
|
75401
|
+
error instanceof Error ? error.message : error
|
|
75402
|
+
);
|
|
74660
75403
|
}
|
|
74661
75404
|
}
|
|
74662
75405
|
var VOICE_V2_HOST = "https://voice.api.sinch.com";
|
|
74663
|
-
|
|
74664
|
-
const serviceId = env.VOICE_SERVICE_ID;
|
|
74665
|
-
if (!serviceId) return;
|
|
75406
|
+
function voiceServiceRequest(env) {
|
|
74666
75407
|
const projectId = env.PROJECT_ID;
|
|
74667
75408
|
const keyId = env.PROJECT_ID_API_KEY;
|
|
74668
75409
|
const keySecret = env.PROJECT_ID_API_SECRET;
|
|
74669
|
-
if (!projectId || !keyId || !keySecret)
|
|
75410
|
+
if (!projectId || !keyId || !keySecret) return null;
|
|
75411
|
+
return {
|
|
75412
|
+
baseUrl: `${VOICE_V2_HOST}/v2/projects/${encodeURIComponent(projectId)}/services`,
|
|
75413
|
+
headers: {
|
|
75414
|
+
Authorization: `Basic ${Buffer.from(`${keyId}:${keySecret}`).toString("base64")}`,
|
|
75415
|
+
"Content-Type": "application/json"
|
|
75416
|
+
}
|
|
75417
|
+
};
|
|
75418
|
+
}
|
|
75419
|
+
function staleVoiceWebhookAdvice(serviceId) {
|
|
75420
|
+
return ` Point it back at your deployed function with \`sinch functions deploy\` or \`sinch voice services update ${serviceId} --webhook-url <url>\`.`;
|
|
75421
|
+
}
|
|
75422
|
+
function defaultVoiceStatePath() {
|
|
75423
|
+
return path5.join(process.cwd(), ".sinch", "tunnel-voice-original.json");
|
|
75424
|
+
}
|
|
75425
|
+
function isTunnelBehavior(behavior, env) {
|
|
75426
|
+
return behavior?.type === "WEBHOOK" && isTunnelUrl(behavior.webhook?.url, env);
|
|
75427
|
+
}
|
|
75428
|
+
function writeVoiceState(stateFile, state) {
|
|
75429
|
+
try {
|
|
75430
|
+
fs4.mkdirSync(path5.dirname(stateFile), { recursive: true });
|
|
75431
|
+
fs4.writeFileSync(stateFile, JSON.stringify(state, null, 2));
|
|
75432
|
+
} catch (error) {
|
|
75433
|
+
console.log(
|
|
75434
|
+
`\u26A0\uFE0F Could not save Voice service state to ${stateFile}: ${error instanceof Error ? error.message : error}`
|
|
75435
|
+
);
|
|
75436
|
+
}
|
|
75437
|
+
}
|
|
75438
|
+
function readVoiceState(stateFile) {
|
|
75439
|
+
try {
|
|
75440
|
+
const parsed = JSON.parse(fs4.readFileSync(stateFile, "utf8"));
|
|
75441
|
+
if (typeof parsed?.serviceId === "string" && typeof parsed.callBehavior?.type === "string") {
|
|
75442
|
+
return parsed;
|
|
75443
|
+
}
|
|
75444
|
+
} catch {
|
|
75445
|
+
}
|
|
75446
|
+
return void 0;
|
|
75447
|
+
}
|
|
75448
|
+
function deleteVoiceState(stateFile) {
|
|
75449
|
+
try {
|
|
75450
|
+
fs4.rmSync(stateFile, { force: true });
|
|
75451
|
+
} catch {
|
|
75452
|
+
}
|
|
75453
|
+
}
|
|
75454
|
+
async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchImpl = globalThis.fetch, config = {}, stateFile = defaultVoiceStatePath()) {
|
|
75455
|
+
const serviceId = env.VOICE_SERVICE_ID;
|
|
75456
|
+
if (!serviceId) return;
|
|
75457
|
+
const request = voiceServiceRequest(env);
|
|
75458
|
+
if (!request) {
|
|
74670
75459
|
console.log(
|
|
74671
75460
|
"\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"
|
|
74672
75461
|
);
|
|
74673
75462
|
return;
|
|
74674
75463
|
}
|
|
74675
|
-
const url2 = `${
|
|
75464
|
+
const url2 = `${request.baseUrl}/${encodeURIComponent(serviceId)}`;
|
|
75465
|
+
const alreadySaved = config.voiceServiceId === serviceId;
|
|
75466
|
+
let original = config.voiceOriginalCallBehavior;
|
|
74676
75467
|
try {
|
|
75468
|
+
if (!alreadySaved) {
|
|
75469
|
+
original = await resolveVoiceOriginal(
|
|
75470
|
+
url2,
|
|
75471
|
+
request.headers,
|
|
75472
|
+
serviceId,
|
|
75473
|
+
env,
|
|
75474
|
+
fetchImpl,
|
|
75475
|
+
stateFile
|
|
75476
|
+
);
|
|
75477
|
+
}
|
|
74677
75478
|
const response = await fetchImpl(url2, {
|
|
74678
75479
|
method: "PATCH",
|
|
74679
|
-
headers:
|
|
74680
|
-
Authorization: `Basic ${Buffer.from(`${keyId}:${keySecret}`).toString("base64")}`,
|
|
74681
|
-
"Content-Type": "application/json"
|
|
74682
|
-
},
|
|
75480
|
+
headers: request.headers,
|
|
74683
75481
|
body: JSON.stringify({
|
|
74684
75482
|
callBehavior: { type: "WEBHOOK", webhook: { url: tunnelUrl } }
|
|
74685
75483
|
})
|
|
@@ -74690,6 +75488,8 @@ async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchI
|
|
|
74690
75488
|
);
|
|
74691
75489
|
return;
|
|
74692
75490
|
}
|
|
75491
|
+
config.voiceServiceId = serviceId;
|
|
75492
|
+
config.voiceOriginalCallBehavior = original;
|
|
74693
75493
|
console.log(`\u2705 Updated Voice service webhook (${serviceId}) to ${tunnelUrl}`);
|
|
74694
75494
|
console.log("\u{1F4A1} Call the number bound to this service in Build to test your voice function!");
|
|
74695
75495
|
} catch (error) {
|
|
@@ -74699,6 +75499,88 @@ async function configureVoiceServiceWebhook(tunnelUrl, env = process.env, fetchI
|
|
|
74699
75499
|
);
|
|
74700
75500
|
}
|
|
74701
75501
|
}
|
|
75502
|
+
async function resolveVoiceOriginal(url2, headers, serviceId, env, fetchImpl, stateFile) {
|
|
75503
|
+
let behavior;
|
|
75504
|
+
try {
|
|
75505
|
+
const response = await fetchImpl(url2, { method: "GET", headers });
|
|
75506
|
+
if (!response.ok) {
|
|
75507
|
+
console.log(
|
|
75508
|
+
`\u26A0\uFE0F Could not read Voice service ${serviceId} (${response.status} ${response.statusText}): its webhook will not be restored when dev stops`
|
|
75509
|
+
);
|
|
75510
|
+
return void 0;
|
|
75511
|
+
}
|
|
75512
|
+
const service = await response.json();
|
|
75513
|
+
behavior = service?.callBehavior;
|
|
75514
|
+
} catch (error) {
|
|
75515
|
+
console.log(
|
|
75516
|
+
`\u26A0\uFE0F Could not read Voice service ${serviceId}: ${error instanceof Error ? error.message : error}: its webhook will not be restored when dev stops`
|
|
75517
|
+
);
|
|
75518
|
+
return void 0;
|
|
75519
|
+
}
|
|
75520
|
+
if (!isTunnelBehavior(behavior, env)) {
|
|
75521
|
+
if (behavior) writeVoiceState(stateFile, { serviceId, callBehavior: behavior });
|
|
75522
|
+
return behavior;
|
|
75523
|
+
}
|
|
75524
|
+
const persisted = readVoiceState(stateFile);
|
|
75525
|
+
if (persisted?.serviceId === serviceId && !isTunnelBehavior(persisted.callBehavior, env)) {
|
|
75526
|
+
console.log(
|
|
75527
|
+
`\u{1F527} Voice service ${serviceId} still points at an earlier tunnel (hot reload?); will restore the webhook saved in ${stateFile}`
|
|
75528
|
+
);
|
|
75529
|
+
return persisted.callBehavior;
|
|
75530
|
+
}
|
|
75531
|
+
console.log(
|
|
75532
|
+
`\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.`
|
|
75533
|
+
);
|
|
75534
|
+
return behavior;
|
|
75535
|
+
}
|
|
75536
|
+
async function cleanupVoiceServiceWebhook(config, env = process.env, fetchImpl = globalThis.fetch, stateFile = defaultVoiceStatePath()) {
|
|
75537
|
+
const serviceId = config.voiceServiceId;
|
|
75538
|
+
if (!serviceId) return;
|
|
75539
|
+
const original = config.voiceOriginalCallBehavior;
|
|
75540
|
+
config.voiceServiceId = void 0;
|
|
75541
|
+
config.voiceOriginalCallBehavior = void 0;
|
|
75542
|
+
if (!original) {
|
|
75543
|
+
deleteVoiceState(stateFile);
|
|
75544
|
+
console.log(
|
|
75545
|
+
`\u26A0\uFE0F Voice service ${serviceId} still points at the tunnel: its previous webhook was not known, so it was not restored.`
|
|
75546
|
+
);
|
|
75547
|
+
console.log(staleVoiceWebhookAdvice(serviceId));
|
|
75548
|
+
return;
|
|
75549
|
+
}
|
|
75550
|
+
if (isTunnelBehavior(original, env)) {
|
|
75551
|
+
deleteVoiceState(stateFile);
|
|
75552
|
+
console.log(
|
|
75553
|
+
`\u26A0\uFE0F Voice service ${serviceId} was not restored: its previous webhook was a stale tunnel URL (${original.webhook?.url}).`
|
|
75554
|
+
);
|
|
75555
|
+
console.log(staleVoiceWebhookAdvice(serviceId));
|
|
75556
|
+
return;
|
|
75557
|
+
}
|
|
75558
|
+
const request = voiceServiceRequest(env);
|
|
75559
|
+
if (!request) return;
|
|
75560
|
+
try {
|
|
75561
|
+
const response = await fetchImpl(`${request.baseUrl}/${encodeURIComponent(serviceId)}`, {
|
|
75562
|
+
method: "PATCH",
|
|
75563
|
+
headers: request.headers,
|
|
75564
|
+
body: JSON.stringify({ callBehavior: original })
|
|
75565
|
+
});
|
|
75566
|
+
if (!response.ok) {
|
|
75567
|
+
console.log(
|
|
75568
|
+
`\u26A0\uFE0F Could not restore Voice service webhook (${serviceId}): ${response.status} ${response.statusText}`
|
|
75569
|
+
);
|
|
75570
|
+
console.log(staleVoiceWebhookAdvice(serviceId));
|
|
75571
|
+
return;
|
|
75572
|
+
}
|
|
75573
|
+
deleteVoiceState(stateFile);
|
|
75574
|
+
const restoredTo = original.type === "WEBHOOK" ? original.webhook?.url : original.type;
|
|
75575
|
+
console.log(`\u{1F504} Restored Voice service webhook (${serviceId}) to: ${restoredTo}`);
|
|
75576
|
+
} catch (error) {
|
|
75577
|
+
console.log(
|
|
75578
|
+
`\u26A0\uFE0F Could not restore Voice service webhook (${serviceId}):`,
|
|
75579
|
+
error instanceof Error ? error.message : error
|
|
75580
|
+
);
|
|
75581
|
+
console.log(staleVoiceWebhookAdvice(serviceId));
|
|
75582
|
+
}
|
|
75583
|
+
}
|
|
74702
75584
|
|
|
74703
75585
|
// src/tunnel/ws-stream.ts
|
|
74704
75586
|
var UPGRADE_TIMEOUT_MS = 1e4;
|
|
@@ -74734,8 +75616,8 @@ var TunnelStreamManager = class {
|
|
|
74734
75616
|
this.log(`[WS] Ignoring duplicate ws_open for stream ${id}`);
|
|
74735
75617
|
return;
|
|
74736
75618
|
}
|
|
74737
|
-
const
|
|
74738
|
-
const url2 = `ws://localhost:${this.localPort}${
|
|
75619
|
+
const path7 = message.path ?? "/";
|
|
75620
|
+
const url2 = `ws://localhost:${this.localPort}${path7}${message.query ?? ""}`;
|
|
74739
75621
|
const protocols = message.protocol ? message.protocol.split(",").map((p) => p.trim()).filter(Boolean) : [];
|
|
74740
75622
|
this.log(`[WS] Opening tunnelled WebSocket ${id} to ${url2}`);
|
|
74741
75623
|
let socket;
|
|
@@ -74891,6 +75773,12 @@ function describe(error) {
|
|
|
74891
75773
|
return String(error);
|
|
74892
75774
|
}
|
|
74893
75775
|
|
|
75776
|
+
// src/tunnel/url.ts
|
|
75777
|
+
function buildTunnelUrl(publicUrl, tunnelId, path7) {
|
|
75778
|
+
const base = publicUrl.split(/[?#]/, 1)[0].replace(/\/+$/, "");
|
|
75779
|
+
return `${base}${path7 || ""}?tunnel=${tunnelId}`;
|
|
75780
|
+
}
|
|
75781
|
+
|
|
74894
75782
|
// src/tunnel/index.ts
|
|
74895
75783
|
var TUNNEL_GATEWAY_DEFAULT = "https://tunnel.fn.sinch.io";
|
|
74896
75784
|
var TunnelClient = class {
|
|
@@ -74906,6 +75794,10 @@ var TunnelClient = class {
|
|
|
74906
75794
|
webhookConfig = {};
|
|
74907
75795
|
welcomeResolver = null;
|
|
74908
75796
|
streams;
|
|
75797
|
+
/** Set by disconnect(). A reconnect after it would repoint the webhooks cleanup restored. */
|
|
75798
|
+
shuttingDown = false;
|
|
75799
|
+
/** The in-flight configureWebhooks(), so disconnect() can wait for it before restoring. */
|
|
75800
|
+
configuring = null;
|
|
74909
75801
|
constructor(localPort = 3e3) {
|
|
74910
75802
|
this.localPort = localPort;
|
|
74911
75803
|
this.streams = new TunnelStreamManager({
|
|
@@ -74949,6 +75841,7 @@ var TunnelClient = class {
|
|
|
74949
75841
|
return timestampPart + randomPart;
|
|
74950
75842
|
}
|
|
74951
75843
|
async connect() {
|
|
75844
|
+
this.shuttingDown = false;
|
|
74952
75845
|
if (process.env.SINCH_TUNNEL !== "true") {
|
|
74953
75846
|
console.log("Tunnel is disabled (set SINCH_TUNNEL=true to enable)");
|
|
74954
75847
|
return;
|
|
@@ -74992,12 +75885,14 @@ var TunnelClient = class {
|
|
|
74992
75885
|
console.error("Tunnel connection error:", error.message);
|
|
74993
75886
|
});
|
|
74994
75887
|
await welcomePromise;
|
|
75888
|
+
if (this.shuttingDown) return;
|
|
74995
75889
|
if (!this.tunnelUrl) {
|
|
74996
75890
|
throw new Error("Did not receive tunnel URL from gateway");
|
|
74997
75891
|
}
|
|
74998
75892
|
console.log("Tunnel connected successfully!");
|
|
74999
75893
|
this.startHeartbeat();
|
|
75000
|
-
|
|
75894
|
+
this.configuring = this.configureWebhooks();
|
|
75895
|
+
await this.configuring;
|
|
75001
75896
|
} catch (error) {
|
|
75002
75897
|
console.error("Failed to establish tunnel connection:", error.message);
|
|
75003
75898
|
this.scheduleReconnect();
|
|
@@ -75033,11 +75928,11 @@ var TunnelClient = class {
|
|
|
75033
75928
|
/**
|
|
75034
75929
|
* Build a full tunnel URL with optional sub-path and tunnel query param.
|
|
75035
75930
|
* e.g. buildTunnelUrl('/webhook/conversation') →
|
|
75036
|
-
* https://tunnel.fn.sinch.
|
|
75931
|
+
* https://tunnel.fn.sinch.io/ingress/webhook/conversation?tunnel=01KKT...
|
|
75932
|
+
* See ./url.ts for why the welcome URL's own query string is dropped.
|
|
75037
75933
|
*/
|
|
75038
|
-
buildTunnelUrl(
|
|
75039
|
-
|
|
75040
|
-
return `${base}${path6 || ""}?tunnel=${this.tunnelId}`;
|
|
75934
|
+
buildTunnelUrl(path7) {
|
|
75935
|
+
return buildTunnelUrl(this.tunnelUrl, this.tunnelId, path7);
|
|
75041
75936
|
}
|
|
75042
75937
|
handleWelcomeMessage(message) {
|
|
75043
75938
|
this.tunnelId = message.tunnelId || null;
|
|
@@ -75091,9 +75986,16 @@ var TunnelClient = class {
|
|
|
75091
75986
|
}
|
|
75092
75987
|
this.ws?.send(JSON.stringify(responseMessage));
|
|
75093
75988
|
} catch (error) {
|
|
75094
|
-
console.error(
|
|
75989
|
+
console.error(
|
|
75990
|
+
`Error forwarding request: ${error.message} (${error.response?.status || "no response"})`
|
|
75991
|
+
);
|
|
75095
75992
|
if (verbose && error.response?.data) {
|
|
75096
|
-
console.error(
|
|
75993
|
+
console.error(
|
|
75994
|
+
` \u2192 Error body: ${typeof error.response.data === "string" ? error.response.data : JSON.stringify(error.response.data)}`.substring(
|
|
75995
|
+
0,
|
|
75996
|
+
2e3
|
|
75997
|
+
)
|
|
75998
|
+
);
|
|
75097
75999
|
}
|
|
75098
76000
|
const errorResponse = {
|
|
75099
76001
|
type: "response",
|
|
@@ -75138,20 +76040,33 @@ var TunnelClient = class {
|
|
|
75138
76040
|
await this.configureVoiceWebhooks();
|
|
75139
76041
|
}
|
|
75140
76042
|
if (autoConfigConversation && process.env.CONVERSATION_APP_ID) {
|
|
75141
|
-
await configureConversationWebhooks(
|
|
76043
|
+
await configureConversationWebhooks(
|
|
76044
|
+
this.buildTunnelUrl("/webhook/conversation"),
|
|
76045
|
+
this.webhookConfig
|
|
76046
|
+
);
|
|
75142
76047
|
}
|
|
75143
76048
|
if (process.env.ELEVENLABS_AUTO_CONFIGURE === "true") {
|
|
75144
76049
|
await configureElevenLabs();
|
|
75145
76050
|
}
|
|
75146
76051
|
}
|
|
75147
76052
|
/**
|
|
75148
|
-
*
|
|
76053
|
+
* Restore every webhook the tunnel repointed. Run in parallel: this happens during
|
|
76054
|
+
* shutdown, under a timeout, and the two restores are independent.
|
|
76055
|
+
* The v1 application callback is still not restored (it was never saved).
|
|
75149
76056
|
*/
|
|
75150
76057
|
async cleanupWebhooks() {
|
|
75151
|
-
await
|
|
76058
|
+
await Promise.all([
|
|
76059
|
+
cleanupConversationWebhook(this.webhookConfig),
|
|
76060
|
+
cleanupVoiceServiceWebhook(this.webhookConfig)
|
|
76061
|
+
]);
|
|
75152
76062
|
}
|
|
75153
76063
|
async configureVoiceWebhooks() {
|
|
75154
|
-
await configureVoiceServiceWebhook(
|
|
76064
|
+
await configureVoiceServiceWebhook(
|
|
76065
|
+
this.buildTunnelUrl(),
|
|
76066
|
+
process.env,
|
|
76067
|
+
globalThis.fetch,
|
|
76068
|
+
this.webhookConfig
|
|
76069
|
+
);
|
|
75155
76070
|
try {
|
|
75156
76071
|
const appKey = process.env.VOICE_APPLICATION_KEY;
|
|
75157
76072
|
const appSecret = process.env.VOICE_APPLICATION_SECRET;
|
|
@@ -75211,6 +76126,7 @@ var TunnelClient = class {
|
|
|
75211
76126
|
}
|
|
75212
76127
|
}
|
|
75213
76128
|
scheduleReconnect() {
|
|
76129
|
+
if (this.shuttingDown) return;
|
|
75214
76130
|
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
75215
76131
|
console.error("Max reconnection attempts reached. Giving up.");
|
|
75216
76132
|
return;
|
|
@@ -75218,17 +76134,30 @@ var TunnelClient = class {
|
|
|
75218
76134
|
this.reconnectAttempts++;
|
|
75219
76135
|
const delay = Math.min(this.reconnectDelay * Math.pow(2, this.reconnectAttempts - 1), 3e4);
|
|
75220
76136
|
console.log(`Attempting to reconnect in ${delay / 1e3} seconds...`);
|
|
75221
|
-
setTimeout(() =>
|
|
76137
|
+
setTimeout(() => {
|
|
76138
|
+
if (!this.shuttingDown) void this.connect();
|
|
76139
|
+
}, delay);
|
|
75222
76140
|
}
|
|
76141
|
+
/**
|
|
76142
|
+
* Stop the tunnel and restore every webhook it repointed.
|
|
76143
|
+
*
|
|
76144
|
+
* Order matters (#102 review): stop reconnects and close the socket first, so no new
|
|
76145
|
+
* welcome can start another configure; then wait for any configure already in flight, so
|
|
76146
|
+
* a PATCH that lands late (Ctrl+C between its GET and its PATCH) cannot overwrite the
|
|
76147
|
+
* restore; only then restore.
|
|
76148
|
+
*/
|
|
75223
76149
|
async disconnect() {
|
|
76150
|
+
this.shuttingDown = true;
|
|
75224
76151
|
this.stopHeartbeat();
|
|
75225
76152
|
this.streams.closeAll("Tunnel client shutting down");
|
|
75226
|
-
await this.cleanupWebhooks();
|
|
75227
76153
|
if (this.ws) {
|
|
75228
76154
|
this.ws.close();
|
|
75229
76155
|
this.ws = null;
|
|
75230
76156
|
}
|
|
75231
76157
|
this.isConnected = false;
|
|
76158
|
+
await this.configuring?.catch(() => {
|
|
76159
|
+
});
|
|
76160
|
+
await this.cleanupWebhooks();
|
|
75232
76161
|
}
|
|
75233
76162
|
getTunnelUrl() {
|
|
75234
76163
|
if (!this.tunnelUrl || !this.tunnelId) return null;
|
|
@@ -75247,8 +76176,8 @@ function getTunnelClient(localPort = 3e3) {
|
|
|
75247
76176
|
}
|
|
75248
76177
|
|
|
75249
76178
|
// src/secrets/index.ts
|
|
75250
|
-
import
|
|
75251
|
-
import
|
|
76179
|
+
import fs5 from "fs";
|
|
76180
|
+
import path6 from "path";
|
|
75252
76181
|
import os from "os";
|
|
75253
76182
|
import crypto3 from "crypto";
|
|
75254
76183
|
|
|
@@ -75414,11 +76343,9 @@ var macKeychain = {
|
|
|
75414
76343
|
},
|
|
75415
76344
|
async deletePassword(service, account) {
|
|
75416
76345
|
try {
|
|
75417
|
-
await execFileAsync(
|
|
75418
|
-
|
|
75419
|
-
|
|
75420
|
-
{ timeout: 15e3 }
|
|
75421
|
-
);
|
|
76346
|
+
await execFileAsync("security", ["delete-generic-password", "-s", service, "-a", account], {
|
|
76347
|
+
timeout: 15e3
|
|
76348
|
+
});
|
|
75422
76349
|
return true;
|
|
75423
76350
|
} catch {
|
|
75424
76351
|
return false;
|
|
@@ -75483,11 +76410,9 @@ var linuxKeychain = {
|
|
|
75483
76410
|
},
|
|
75484
76411
|
async deletePassword(service, account) {
|
|
75485
76412
|
try {
|
|
75486
|
-
await execFileAsync(
|
|
75487
|
-
|
|
75488
|
-
|
|
75489
|
-
{ timeout: 15e3 }
|
|
75490
|
-
);
|
|
76413
|
+
await execFileAsync("secret-tool", ["clear", "service", service, "account", account], {
|
|
76414
|
+
timeout: 15e3
|
|
76415
|
+
});
|
|
75491
76416
|
return true;
|
|
75492
76417
|
} catch (err) {
|
|
75493
76418
|
debugKeychain("clear", err);
|
|
@@ -75529,12 +76454,12 @@ var SecretsLoader = class {
|
|
|
75529
76454
|
return false;
|
|
75530
76455
|
}
|
|
75531
76456
|
try {
|
|
75532
|
-
const envPath =
|
|
75533
|
-
if (!
|
|
76457
|
+
const envPath = path6.join(process.cwd(), ".env");
|
|
76458
|
+
if (!fs5.existsSync(envPath)) {
|
|
75534
76459
|
console.debug("[Secrets] No .env file found, skipping keychain load");
|
|
75535
76460
|
return false;
|
|
75536
76461
|
}
|
|
75537
|
-
const envContent =
|
|
76462
|
+
const envContent = fs5.readFileSync(envPath, "utf8");
|
|
75538
76463
|
const envLines = envContent.replace(/\r\n/g, "\n").split("\n");
|
|
75539
76464
|
const secretsToLoad = [];
|
|
75540
76465
|
envLines.forEach((line) => {
|
|
@@ -75626,9 +76551,9 @@ var SecretsLoader = class {
|
|
|
75626
76551
|
*/
|
|
75627
76552
|
getApplicationKeyFromConfig() {
|
|
75628
76553
|
try {
|
|
75629
|
-
const sinchJsonPath =
|
|
75630
|
-
if (
|
|
75631
|
-
const sinchConfig = JSON.parse(
|
|
76554
|
+
const sinchJsonPath = path6.join(process.cwd(), "sinch.json");
|
|
76555
|
+
if (fs5.existsSync(sinchJsonPath)) {
|
|
76556
|
+
const sinchConfig = JSON.parse(fs5.readFileSync(sinchJsonPath, "utf8"));
|
|
75632
76557
|
return sinchConfig.voiceAppId || sinchConfig.applicationKey || null;
|
|
75633
76558
|
}
|
|
75634
76559
|
} catch (error) {
|
|
@@ -75641,9 +76566,9 @@ var SecretsLoader = class {
|
|
|
75641
76566
|
*/
|
|
75642
76567
|
getFunctionNameFromConfig() {
|
|
75643
76568
|
try {
|
|
75644
|
-
const sinchJsonPath =
|
|
75645
|
-
if (
|
|
75646
|
-
const sinchConfig = JSON.parse(
|
|
76569
|
+
const sinchJsonPath = path6.join(process.cwd(), "sinch.json");
|
|
76570
|
+
if (fs5.existsSync(sinchJsonPath)) {
|
|
76571
|
+
const sinchConfig = JSON.parse(fs5.readFileSync(sinchJsonPath, "utf8"));
|
|
75647
76572
|
return sinchConfig.name || null;
|
|
75648
76573
|
}
|
|
75649
76574
|
} catch (error) {
|
|
@@ -75660,10 +76585,10 @@ var SecretsLoader = class {
|
|
|
75660
76585
|
readProfilePlaintext(field) {
|
|
75661
76586
|
try {
|
|
75662
76587
|
const home = os.homedir();
|
|
75663
|
-
const metaPath =
|
|
76588
|
+
const metaPath = path6.join(home, ".sinch", "config.json");
|
|
75664
76589
|
let activeProfile = "default";
|
|
75665
|
-
if (
|
|
75666
|
-
const meta = JSON.parse(
|
|
76590
|
+
if (fs5.existsSync(metaPath)) {
|
|
76591
|
+
const meta = JSON.parse(fs5.readFileSync(metaPath, "utf8"));
|
|
75667
76592
|
if (typeof meta.activeProfile === "string" && meta.activeProfile) {
|
|
75668
76593
|
activeProfile = meta.activeProfile;
|
|
75669
76594
|
}
|
|
@@ -75671,9 +76596,9 @@ var SecretsLoader = class {
|
|
|
75671
76596
|
if (/[\\/]/.test(activeProfile) || activeProfile.includes("..")) {
|
|
75672
76597
|
return null;
|
|
75673
76598
|
}
|
|
75674
|
-
const profilePath =
|
|
75675
|
-
if (!
|
|
75676
|
-
const profile = JSON.parse(
|
|
76599
|
+
const profilePath = path6.join(home, ".sinch", "profiles", `${activeProfile}.json`);
|
|
76600
|
+
if (!fs5.existsSync(profilePath)) return null;
|
|
76601
|
+
const profile = JSON.parse(fs5.readFileSync(profilePath, "utf8"));
|
|
75677
76602
|
const value = profile[field];
|
|
75678
76603
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
75679
76604
|
} catch (err) {
|
|
@@ -75848,6 +76773,12 @@ export {
|
|
|
75848
76773
|
shouldValidateWebhook,
|
|
75849
76774
|
getProtectionMode,
|
|
75850
76775
|
createSecurityOptions,
|
|
76776
|
+
configureSecretRedaction,
|
|
76777
|
+
redactSecrets,
|
|
76778
|
+
redactAsText,
|
|
76779
|
+
secretLookaheadBytes,
|
|
76780
|
+
safeCut,
|
|
76781
|
+
installStdioRedaction,
|
|
75851
76782
|
VOICE_TIMESTAMP_SKEW_MS,
|
|
75852
76783
|
VOICE_MISSING_SECRET_WARNING,
|
|
75853
76784
|
validateVoiceSignature,
|
|
@@ -76223,4 +77154,4 @@ serve-static/index.js:
|
|
|
76223
77154
|
* MIT Licensed
|
|
76224
77155
|
*)
|
|
76225
77156
|
*/
|
|
76226
|
-
//# sourceMappingURL=chunk-
|
|
77157
|
+
//# sourceMappingURL=chunk-DLBCKZ6X.js.map
|