@tradejs/cli 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +700 -456
- package/dist/lib/marketContextPrepare.js +52 -37
- package/dist/lib/runEnvironment.js +52 -37
- package/dist/lib/runFormatting.js +52 -37
- package/dist/scripts/aiExport.js +52 -37
- package/dist/scripts/aiPocketSearch.js +52 -37
- package/dist/scripts/aiTrain.js +52 -37
- package/dist/scripts/backtest.js +52 -37
- package/dist/scripts/candlesMigrateProvider.js +648 -419
- package/dist/scripts/doctor.js +648 -419
- package/dist/scripts/mlExport.js +52 -37
- package/dist/scripts/replay.js +52 -37
- package/dist/scripts/replayRunner.js +52 -37
- package/dist/scripts/results.js +52 -37
- package/dist/scripts/runtimeParity.js +52 -37
- package/dist/scripts/signals.js +52 -37
- package/dist/scripts/signalsDaemon.js +52 -37
- package/package.json +14 -14
package/dist/cli.js
CHANGED
|
@@ -943,9 +943,9 @@ Return a corrected unified diff only. Keep the same allowed paths.`
|
|
|
943
943
|
}
|
|
944
944
|
});
|
|
945
945
|
|
|
946
|
-
// ../../node_modules/
|
|
946
|
+
// ../../node_modules/ms/index.js
|
|
947
947
|
var require_ms = __commonJS({
|
|
948
|
-
"../../node_modules/
|
|
948
|
+
"../../node_modules/ms/index.js"(exports2, module2) {
|
|
949
949
|
"use strict";
|
|
950
950
|
var s = 1e3;
|
|
951
951
|
var m = s * 60;
|
|
@@ -1060,9 +1060,9 @@ var require_ms = __commonJS({
|
|
|
1060
1060
|
}
|
|
1061
1061
|
});
|
|
1062
1062
|
|
|
1063
|
-
// ../../node_modules/debug/src/common.js
|
|
1063
|
+
// ../../node_modules/list-it/node_modules/debug/src/common.js
|
|
1064
1064
|
var require_common = __commonJS({
|
|
1065
|
-
"../../node_modules/debug/src/common.js"(exports2, module2) {
|
|
1065
|
+
"../../node_modules/list-it/node_modules/debug/src/common.js"(exports2, module2) {
|
|
1066
1066
|
"use strict";
|
|
1067
1067
|
function setup(env) {
|
|
1068
1068
|
createDebug.debug = createDebug;
|
|
@@ -1164,50 +1164,64 @@ var require_common = __commonJS({
|
|
|
1164
1164
|
createDebug.namespaces = namespaces;
|
|
1165
1165
|
createDebug.names = [];
|
|
1166
1166
|
createDebug.skips = [];
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1167
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
1168
|
+
for (const ns of split) {
|
|
1169
|
+
if (ns[0] === "-") {
|
|
1170
|
+
createDebug.skips.push(ns.slice(1));
|
|
1171
|
+
} else {
|
|
1172
|
+
createDebug.names.push(ns);
|
|
1173
1173
|
}
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
function matchesTemplate(search, template) {
|
|
1177
|
+
let searchIndex = 0;
|
|
1178
|
+
let templateIndex = 0;
|
|
1179
|
+
let starIndex = -1;
|
|
1180
|
+
let matchIndex = 0;
|
|
1181
|
+
while (searchIndex < search.length) {
|
|
1182
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
1183
|
+
if (template[templateIndex] === "*") {
|
|
1184
|
+
starIndex = templateIndex;
|
|
1185
|
+
matchIndex = searchIndex;
|
|
1186
|
+
templateIndex++;
|
|
1187
|
+
} else {
|
|
1188
|
+
searchIndex++;
|
|
1189
|
+
templateIndex++;
|
|
1190
|
+
}
|
|
1191
|
+
} else if (starIndex !== -1) {
|
|
1192
|
+
templateIndex = starIndex + 1;
|
|
1193
|
+
matchIndex++;
|
|
1194
|
+
searchIndex = matchIndex;
|
|
1177
1195
|
} else {
|
|
1178
|
-
|
|
1196
|
+
return false;
|
|
1179
1197
|
}
|
|
1180
1198
|
}
|
|
1199
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
1200
|
+
templateIndex++;
|
|
1201
|
+
}
|
|
1202
|
+
return templateIndex === template.length;
|
|
1181
1203
|
}
|
|
1182
1204
|
function disable() {
|
|
1183
1205
|
const namespaces = [
|
|
1184
|
-
...createDebug.names
|
|
1185
|
-
...createDebug.skips.map(
|
|
1206
|
+
...createDebug.names,
|
|
1207
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
1186
1208
|
].join(",");
|
|
1187
1209
|
createDebug.enable("");
|
|
1188
1210
|
return namespaces;
|
|
1189
1211
|
}
|
|
1190
1212
|
function enabled(name) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
}
|
|
1194
|
-
let i;
|
|
1195
|
-
let len;
|
|
1196
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
|
1197
|
-
if (createDebug.skips[i].test(name)) {
|
|
1213
|
+
for (const skip of createDebug.skips) {
|
|
1214
|
+
if (matchesTemplate(name, skip)) {
|
|
1198
1215
|
return false;
|
|
1199
1216
|
}
|
|
1200
1217
|
}
|
|
1201
|
-
for (
|
|
1202
|
-
if (
|
|
1218
|
+
for (const ns of createDebug.names) {
|
|
1219
|
+
if (matchesTemplate(name, ns)) {
|
|
1203
1220
|
return true;
|
|
1204
1221
|
}
|
|
1205
1222
|
}
|
|
1206
1223
|
return false;
|
|
1207
1224
|
}
|
|
1208
|
-
function toNamespace(regexp) {
|
|
1209
|
-
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
|
1210
|
-
}
|
|
1211
1225
|
function coerce(val) {
|
|
1212
1226
|
if (val instanceof Error) {
|
|
1213
1227
|
return val.stack || val.message;
|
|
@@ -1224,9 +1238,9 @@ var require_common = __commonJS({
|
|
|
1224
1238
|
}
|
|
1225
1239
|
});
|
|
1226
1240
|
|
|
1227
|
-
// ../../node_modules/debug/src/browser.js
|
|
1241
|
+
// ../../node_modules/list-it/node_modules/debug/src/browser.js
|
|
1228
1242
|
var require_browser = __commonJS({
|
|
1229
|
-
"../../node_modules/debug/src/browser.js"(exports2, module2) {
|
|
1243
|
+
"../../node_modules/list-it/node_modules/debug/src/browser.js"(exports2, module2) {
|
|
1230
1244
|
"use strict";
|
|
1231
1245
|
exports2.formatArgs = formatArgs;
|
|
1232
1246
|
exports2.save = save;
|
|
@@ -1327,10 +1341,11 @@ var require_browser = __commonJS({
|
|
|
1327
1341
|
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
1328
1342
|
return false;
|
|
1329
1343
|
}
|
|
1344
|
+
let m;
|
|
1330
1345
|
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
1331
1346
|
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
1332
1347
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
1333
|
-
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(
|
|
1348
|
+
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
1334
1349
|
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
1335
1350
|
}
|
|
1336
1351
|
function formatArgs(args30) {
|
|
@@ -1368,7 +1383,7 @@ var require_browser = __commonJS({
|
|
|
1368
1383
|
function load() {
|
|
1369
1384
|
let r;
|
|
1370
1385
|
try {
|
|
1371
|
-
r = exports2.storage.getItem("debug");
|
|
1386
|
+
r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
|
|
1372
1387
|
} catch (error) {
|
|
1373
1388
|
}
|
|
1374
1389
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
@@ -1509,9 +1524,9 @@ var require_supports_color = __commonJS({
|
|
|
1509
1524
|
}
|
|
1510
1525
|
});
|
|
1511
1526
|
|
|
1512
|
-
// ../../node_modules/debug/src/node.js
|
|
1527
|
+
// ../../node_modules/list-it/node_modules/debug/src/node.js
|
|
1513
1528
|
var require_node = __commonJS({
|
|
1514
|
-
"../../node_modules/debug/src/node.js"(exports2, module2) {
|
|
1529
|
+
"../../node_modules/list-it/node_modules/debug/src/node.js"(exports2, module2) {
|
|
1515
1530
|
"use strict";
|
|
1516
1531
|
var tty = require("tty");
|
|
1517
1532
|
var util = require("util");
|
|
@@ -1652,7 +1667,7 @@ var require_node = __commonJS({
|
|
|
1652
1667
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
1653
1668
|
}
|
|
1654
1669
|
function log(...args30) {
|
|
1655
|
-
return process.stderr.write(util.
|
|
1670
|
+
return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args30) + "\n");
|
|
1656
1671
|
}
|
|
1657
1672
|
function save(namespaces) {
|
|
1658
1673
|
if (namespaces) {
|
|
@@ -1684,9 +1699,9 @@ var require_node = __commonJS({
|
|
|
1684
1699
|
}
|
|
1685
1700
|
});
|
|
1686
1701
|
|
|
1687
|
-
// ../../node_modules/debug/src/index.js
|
|
1702
|
+
// ../../node_modules/list-it/node_modules/debug/src/index.js
|
|
1688
1703
|
var require_src = __commonJS({
|
|
1689
|
-
"../../node_modules/debug/src/index.js"(exports2, module2) {
|
|
1704
|
+
"../../node_modules/list-it/node_modules/debug/src/index.js"(exports2, module2) {
|
|
1690
1705
|
"use strict";
|
|
1691
1706
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
1692
1707
|
module2.exports = require_browser();
|
|
@@ -14391,11 +14406,16 @@ var require_pg_types = __commonJS({
|
|
|
14391
14406
|
var require_defaults = __commonJS({
|
|
14392
14407
|
"../../node_modules/pg/lib/defaults.js"(exports2, module2) {
|
|
14393
14408
|
"use strict";
|
|
14409
|
+
var user;
|
|
14410
|
+
try {
|
|
14411
|
+
user = process.platform === "win32" ? process.env.USERNAME : process.env.USER;
|
|
14412
|
+
} catch {
|
|
14413
|
+
}
|
|
14394
14414
|
module2.exports = {
|
|
14395
14415
|
// database host. defaults to localhost
|
|
14396
14416
|
host: "localhost",
|
|
14397
14417
|
// database user's name
|
|
14398
|
-
user
|
|
14418
|
+
user,
|
|
14399
14419
|
// name of database to connect
|
|
14400
14420
|
database: void 0,
|
|
14401
14421
|
// database user's password
|
|
@@ -14420,6 +14440,8 @@ var require_defaults = __commonJS({
|
|
|
14420
14440
|
idleTimeoutMillis: 3e4,
|
|
14421
14441
|
client_encoding: "",
|
|
14422
14442
|
ssl: false,
|
|
14443
|
+
// SSL negotiation style: 'postgres' (traditional SSLRequest) or 'direct'
|
|
14444
|
+
sslnegotiation: void 0,
|
|
14423
14445
|
application_name: void 0,
|
|
14424
14446
|
fallback_application_name: void 0,
|
|
14425
14447
|
options: void 0,
|
|
@@ -14454,8 +14476,7 @@ var require_utils = __commonJS({
|
|
|
14454
14476
|
"../../node_modules/pg/lib/utils.js"(exports2, module2) {
|
|
14455
14477
|
"use strict";
|
|
14456
14478
|
var defaults2 = require_defaults();
|
|
14457
|
-
var
|
|
14458
|
-
var { isDate } = util.types || util;
|
|
14479
|
+
var { isDate } = require("util/types");
|
|
14459
14480
|
function escapeElement(elementRepresentation) {
|
|
14460
14481
|
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
14461
14482
|
return '"' + escaped + '"';
|
|
@@ -14464,28 +14485,23 @@ var require_utils = __commonJS({
|
|
|
14464
14485
|
let result = "{";
|
|
14465
14486
|
for (let i = 0; i < val.length; i++) {
|
|
14466
14487
|
if (i > 0) {
|
|
14467
|
-
result
|
|
14468
|
-
}
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14488
|
+
result += ",";
|
|
14489
|
+
}
|
|
14490
|
+
let item = val[i];
|
|
14491
|
+
if (item == null) {
|
|
14492
|
+
result += "NULL";
|
|
14493
|
+
} else if (Array.isArray(item)) {
|
|
14494
|
+
result += arrayString(item);
|
|
14495
|
+
} else if (ArrayBuffer.isView(item)) {
|
|
14475
14496
|
if (!(item instanceof Buffer)) {
|
|
14476
|
-
|
|
14477
|
-
if (buf.length === item.byteLength) {
|
|
14478
|
-
item = buf;
|
|
14479
|
-
} else {
|
|
14480
|
-
item = buf.slice(item.byteOffset, item.byteOffset + item.byteLength);
|
|
14481
|
-
}
|
|
14497
|
+
item = Buffer.from(item.buffer, item.byteOffset, item.byteLength);
|
|
14482
14498
|
}
|
|
14483
14499
|
result += "\\\\x" + item.toString("hex");
|
|
14484
14500
|
} else {
|
|
14485
|
-
result += escapeElement(prepareValue(
|
|
14501
|
+
result += escapeElement(prepareValue(item));
|
|
14486
14502
|
}
|
|
14487
14503
|
}
|
|
14488
|
-
result
|
|
14504
|
+
result += "}";
|
|
14489
14505
|
return result;
|
|
14490
14506
|
}
|
|
14491
14507
|
var prepareValue = function(val, seen) {
|
|
@@ -14497,11 +14513,7 @@ var require_utils = __commonJS({
|
|
|
14497
14513
|
return val;
|
|
14498
14514
|
}
|
|
14499
14515
|
if (ArrayBuffer.isView(val)) {
|
|
14500
|
-
|
|
14501
|
-
if (buf.length === val.byteLength) {
|
|
14502
|
-
return buf;
|
|
14503
|
-
}
|
|
14504
|
-
return buf.slice(val.byteOffset, val.byteOffset + val.byteLength);
|
|
14516
|
+
return Buffer.from(val.buffer, val.byteOffset, val.byteLength);
|
|
14505
14517
|
}
|
|
14506
14518
|
if (isDate(val)) {
|
|
14507
14519
|
if (defaults2.parseInputDatesAsUTC) {
|
|
@@ -14607,47 +14619,9 @@ var require_utils = __commonJS({
|
|
|
14607
14619
|
}
|
|
14608
14620
|
});
|
|
14609
14621
|
|
|
14610
|
-
// ../../node_modules/pg/lib/crypto/utils
|
|
14611
|
-
var
|
|
14612
|
-
"../../node_modules/pg/lib/crypto/utils
|
|
14613
|
-
"use strict";
|
|
14614
|
-
var nodeCrypto = require("crypto");
|
|
14615
|
-
function md5(string) {
|
|
14616
|
-
return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
|
|
14617
|
-
}
|
|
14618
|
-
function postgresMd5PasswordHash(user, password, salt) {
|
|
14619
|
-
const inner = md5(password + user);
|
|
14620
|
-
const outer = md5(Buffer.concat([Buffer.from(inner), salt]));
|
|
14621
|
-
return "md5" + outer;
|
|
14622
|
-
}
|
|
14623
|
-
function sha256(text) {
|
|
14624
|
-
return nodeCrypto.createHash("sha256").update(text).digest();
|
|
14625
|
-
}
|
|
14626
|
-
function hashByName(hashName, text) {
|
|
14627
|
-
hashName = hashName.replace(/(\D)-/, "$1");
|
|
14628
|
-
return nodeCrypto.createHash(hashName).update(text).digest();
|
|
14629
|
-
}
|
|
14630
|
-
function hmacSha256(key, msg) {
|
|
14631
|
-
return nodeCrypto.createHmac("sha256", key).update(msg).digest();
|
|
14632
|
-
}
|
|
14633
|
-
async function deriveKey(password, salt, iterations) {
|
|
14634
|
-
return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, "sha256");
|
|
14635
|
-
}
|
|
14636
|
-
module2.exports = {
|
|
14637
|
-
postgresMd5PasswordHash,
|
|
14638
|
-
randomBytes: nodeCrypto.randomBytes,
|
|
14639
|
-
deriveKey,
|
|
14640
|
-
sha256,
|
|
14641
|
-
hashByName,
|
|
14642
|
-
hmacSha256,
|
|
14643
|
-
md5
|
|
14644
|
-
};
|
|
14645
|
-
}
|
|
14646
|
-
});
|
|
14647
|
-
|
|
14648
|
-
// ../../node_modules/pg/lib/crypto/utils-webcrypto.js
|
|
14649
|
-
var require_utils_webcrypto = __commonJS({
|
|
14650
|
-
"../../node_modules/pg/lib/crypto/utils-webcrypto.js"(exports2, module2) {
|
|
14622
|
+
// ../../node_modules/pg/lib/crypto/utils.js
|
|
14623
|
+
var require_utils2 = __commonJS({
|
|
14624
|
+
"../../node_modules/pg/lib/crypto/utils.js"(exports2, module2) {
|
|
14651
14625
|
"use strict";
|
|
14652
14626
|
var nodeCrypto = require("crypto");
|
|
14653
14627
|
module2.exports = {
|
|
@@ -14697,19 +14671,6 @@ var require_utils_webcrypto = __commonJS({
|
|
|
14697
14671
|
}
|
|
14698
14672
|
});
|
|
14699
14673
|
|
|
14700
|
-
// ../../node_modules/pg/lib/crypto/utils.js
|
|
14701
|
-
var require_utils2 = __commonJS({
|
|
14702
|
-
"../../node_modules/pg/lib/crypto/utils.js"(exports2, module2) {
|
|
14703
|
-
"use strict";
|
|
14704
|
-
var useLegacyCrypto = parseInt(process.versions && process.versions.node && process.versions.node.split(".")[0]) < 15;
|
|
14705
|
-
if (useLegacyCrypto) {
|
|
14706
|
-
module2.exports = require_utils_legacy();
|
|
14707
|
-
} else {
|
|
14708
|
-
module2.exports = require_utils_webcrypto();
|
|
14709
|
-
}
|
|
14710
|
-
}
|
|
14711
|
-
});
|
|
14712
|
-
|
|
14713
14674
|
// ../../node_modules/pg/lib/crypto/cert-signatures.js
|
|
14714
14675
|
var require_cert_signatures = __commonJS({
|
|
14715
14676
|
"../../node_modules/pg/lib/crypto/cert-signatures.js"(exports2, module2) {
|
|
@@ -14830,7 +14791,13 @@ var require_sasl = __commonJS({
|
|
|
14830
14791
|
"use strict";
|
|
14831
14792
|
var crypto = require_utils2();
|
|
14832
14793
|
var { signatureAlgorithmHashFromCertificate } = require_cert_signatures();
|
|
14833
|
-
function
|
|
14794
|
+
function saslprep(password) {
|
|
14795
|
+
const nonAsciiSpace = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
|
|
14796
|
+
const mappedToNothing = /[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;
|
|
14797
|
+
return password.replace(nonAsciiSpace, " ").replace(mappedToNothing, "").normalize("NFKC");
|
|
14798
|
+
}
|
|
14799
|
+
var DEFAULT_MAX_SCRAM_ITERATIONS = 1e5;
|
|
14800
|
+
function startSession(mechanisms, stream, scramMaxIterations = DEFAULT_MAX_SCRAM_ITERATIONS) {
|
|
14834
14801
|
const candidates = ["SCRAM-SHA-256"];
|
|
14835
14802
|
if (stream) candidates.unshift("SCRAM-SHA-256-PLUS");
|
|
14836
14803
|
const mechanism = candidates.find((candidate) => mechanisms.includes(candidate));
|
|
@@ -14846,7 +14813,8 @@ var require_sasl = __commonJS({
|
|
|
14846
14813
|
mechanism,
|
|
14847
14814
|
clientNonce,
|
|
14848
14815
|
response: gs2Header + ",,n=*,r=" + clientNonce,
|
|
14849
|
-
message: "SASLInitialResponse"
|
|
14816
|
+
message: "SASLInitialResponse",
|
|
14817
|
+
scramMaxIterations
|
|
14850
14818
|
};
|
|
14851
14819
|
}
|
|
14852
14820
|
async function continueSession(session, password, serverData, stream) {
|
|
@@ -14868,6 +14836,12 @@ var require_sasl = __commonJS({
|
|
|
14868
14836
|
} else if (sv.nonce.length === session.clientNonce.length) {
|
|
14869
14837
|
throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");
|
|
14870
14838
|
}
|
|
14839
|
+
const scramMaxIterations = typeof session.scramMaxIterations === "number" ? session.scramMaxIterations : DEFAULT_MAX_SCRAM_ITERATIONS;
|
|
14840
|
+
if (scramMaxIterations !== 0 && sv.iteration > scramMaxIterations) {
|
|
14841
|
+
throw new Error(
|
|
14842
|
+
"SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count " + sv.iteration + " exceeds scramMaxIterations of " + scramMaxIterations
|
|
14843
|
+
);
|
|
14844
|
+
}
|
|
14871
14845
|
const clientFirstMessageBare = "n=*,r=" + session.clientNonce;
|
|
14872
14846
|
const serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration;
|
|
14873
14847
|
let channelBinding = stream ? "eSws" : "biws";
|
|
@@ -14882,7 +14856,7 @@ var require_sasl = __commonJS({
|
|
|
14882
14856
|
const clientFinalMessageWithoutProof = "c=" + channelBinding + ",r=" + sv.nonce;
|
|
14883
14857
|
const authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
|
|
14884
14858
|
const saltBytes = Buffer.from(sv.salt, "base64");
|
|
14885
|
-
const saltedPassword = await crypto.deriveKey(password, saltBytes, sv.iteration);
|
|
14859
|
+
const saltedPassword = await crypto.deriveKey(saslprep(password), saltBytes, sv.iteration);
|
|
14886
14860
|
const clientKey = await crypto.hmacSha256(saltedPassword, "Client Key");
|
|
14887
14861
|
const storedKey = await crypto.sha256(clientKey);
|
|
14888
14862
|
const clientSignature = await crypto.hmacSha256(storedKey, authMessage);
|
|
@@ -14958,7 +14932,11 @@ var require_sasl = __commonJS({
|
|
|
14958
14932
|
}
|
|
14959
14933
|
function parseServerFinalMessage(serverData) {
|
|
14960
14934
|
const attrPairs = parseAttributePairs(serverData);
|
|
14935
|
+
const error = attrPairs.get("e");
|
|
14961
14936
|
const serverSignature = attrPairs.get("v");
|
|
14937
|
+
if (error) {
|
|
14938
|
+
throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${error}"`);
|
|
14939
|
+
}
|
|
14962
14940
|
if (!serverSignature) {
|
|
14963
14941
|
throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");
|
|
14964
14942
|
} else if (!isBase64(serverSignature)) {
|
|
@@ -14986,7 +14964,8 @@ var require_sasl = __commonJS({
|
|
|
14986
14964
|
module2.exports = {
|
|
14987
14965
|
startSession,
|
|
14988
14966
|
continueSession,
|
|
14989
|
-
finalizeSession
|
|
14967
|
+
finalizeSession,
|
|
14968
|
+
DEFAULT_MAX_SCRAM_ITERATIONS
|
|
14990
14969
|
};
|
|
14991
14970
|
}
|
|
14992
14971
|
});
|
|
@@ -15035,7 +15014,7 @@ var require_pg_connection_string = __commonJS({
|
|
|
15035
15014
|
const config2 = str.split(" ");
|
|
15036
15015
|
return { host: config2[0], database: config2[1] };
|
|
15037
15016
|
}
|
|
15038
|
-
const config =
|
|
15017
|
+
const config = /* @__PURE__ */ Object.create(null);
|
|
15039
15018
|
let result;
|
|
15040
15019
|
let dummyHost = false;
|
|
15041
15020
|
if (/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) {
|
|
@@ -15050,6 +15029,7 @@ var require_pg_connection_string = __commonJS({
|
|
|
15050
15029
|
}
|
|
15051
15030
|
} catch (err) {
|
|
15052
15031
|
err.input && (err.input = "*****REDACTED*****");
|
|
15032
|
+
throw err;
|
|
15053
15033
|
}
|
|
15054
15034
|
for (const entry of result.searchParams.entries()) {
|
|
15055
15035
|
config[entry[0]] = entry[1];
|
|
@@ -15082,6 +15062,9 @@ var require_pg_connection_string = __commonJS({
|
|
|
15082
15062
|
if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) {
|
|
15083
15063
|
config.ssl = {};
|
|
15084
15064
|
}
|
|
15065
|
+
if (config.sslnegotiation === "direct" && config.ssl === void 0) {
|
|
15066
|
+
config.ssl = true;
|
|
15067
|
+
}
|
|
15085
15068
|
const fs17 = config.sslcert || config.sslkey || config.sslrootcert ? require("fs") : null;
|
|
15086
15069
|
if (config.sslcert) {
|
|
15087
15070
|
config.ssl.cert = fs17.readFileSync(config.sslcert).toString();
|
|
@@ -15138,6 +15121,9 @@ var require_pg_connection_string = __commonJS({
|
|
|
15138
15121
|
case "require":
|
|
15139
15122
|
case "verify-ca":
|
|
15140
15123
|
case "verify-full": {
|
|
15124
|
+
if (config.sslmode !== "verify-full") {
|
|
15125
|
+
deprecatedSslModeWarning(config.sslmode);
|
|
15126
|
+
}
|
|
15141
15127
|
break;
|
|
15142
15128
|
}
|
|
15143
15129
|
case "no-verify": {
|
|
@@ -15154,7 +15140,7 @@ var require_pg_connection_string = __commonJS({
|
|
|
15154
15140
|
c[key] = value;
|
|
15155
15141
|
}
|
|
15156
15142
|
return c;
|
|
15157
|
-
},
|
|
15143
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
15158
15144
|
return connectionOptions;
|
|
15159
15145
|
}
|
|
15160
15146
|
function toClientConfig(config) {
|
|
@@ -15181,12 +15167,25 @@ var require_pg_connection_string = __commonJS({
|
|
|
15181
15167
|
}
|
|
15182
15168
|
}
|
|
15183
15169
|
return c;
|
|
15184
|
-
},
|
|
15170
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
15185
15171
|
return poolConfig;
|
|
15186
15172
|
}
|
|
15187
15173
|
function parseIntoClientConfig(str) {
|
|
15188
15174
|
return toClientConfig(parse(str));
|
|
15189
15175
|
}
|
|
15176
|
+
function deprecatedSslModeWarning(sslmode) {
|
|
15177
|
+
if (!deprecatedSslModeWarning.warned && typeof process !== "undefined" && process.emitWarning) {
|
|
15178
|
+
deprecatedSslModeWarning.warned = true;
|
|
15179
|
+
process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
|
|
15180
|
+
In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
|
|
15181
|
+
|
|
15182
|
+
To prepare for this change:
|
|
15183
|
+
- If you want the current behavior, explicitly use 'sslmode=verify-full'
|
|
15184
|
+
- If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${sslmode}'
|
|
15185
|
+
|
|
15186
|
+
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`);
|
|
15187
|
+
}
|
|
15188
|
+
}
|
|
15190
15189
|
module2.exports = parse;
|
|
15191
15190
|
parse.parse = parse;
|
|
15192
15191
|
parse.toClientConfig = toClientConfig;
|
|
@@ -15202,13 +15201,16 @@ var require_connection_parameters = __commonJS({
|
|
|
15202
15201
|
var defaults2 = require_defaults();
|
|
15203
15202
|
var parse = require_pg_connection_string().parse;
|
|
15204
15203
|
var val = function(key, config, envVar) {
|
|
15204
|
+
if (config[key]) {
|
|
15205
|
+
return config[key];
|
|
15206
|
+
}
|
|
15205
15207
|
if (envVar === void 0) {
|
|
15206
15208
|
envVar = process.env["PG" + key.toUpperCase()];
|
|
15207
15209
|
} else if (envVar === false) {
|
|
15208
15210
|
} else {
|
|
15209
15211
|
envVar = process.env[envVar];
|
|
15210
15212
|
}
|
|
15211
|
-
return
|
|
15213
|
+
return envVar || defaults2[key];
|
|
15212
15214
|
};
|
|
15213
15215
|
var readSSLConfigFromEnvironment = function() {
|
|
15214
15216
|
switch (process.env.PGSSLMODE) {
|
|
@@ -15268,6 +15270,15 @@ var require_connection_parameters = __commonJS({
|
|
|
15268
15270
|
enumerable: false
|
|
15269
15271
|
});
|
|
15270
15272
|
}
|
|
15273
|
+
this.sslnegotiation = val("sslnegotiation", config, "PGSSLNEGOTIATION");
|
|
15274
|
+
if (this.sslnegotiation !== void 0 && this.sslnegotiation !== "postgres" && this.sslnegotiation !== "direct") {
|
|
15275
|
+
throw new Error(
|
|
15276
|
+
`Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".`
|
|
15277
|
+
);
|
|
15278
|
+
}
|
|
15279
|
+
if (this.sslnegotiation === "direct" && !this.ssl) {
|
|
15280
|
+
throw new Error("sslnegotiation=direct requires SSL to be enabled");
|
|
15281
|
+
}
|
|
15271
15282
|
this.client_encoding = val("client_encoding", config);
|
|
15272
15283
|
this.replication = val("replication", config);
|
|
15273
15284
|
this.isDomainSocket = !(this.host || "").indexOf("/");
|
|
@@ -15306,6 +15317,7 @@ var require_connection_parameters = __commonJS({
|
|
|
15306
15317
|
add(params, ssl, "sslkey");
|
|
15307
15318
|
add(params, ssl, "sslcert");
|
|
15308
15319
|
add(params, ssl, "sslrootcert");
|
|
15320
|
+
add(params, this, "sslnegotiation");
|
|
15309
15321
|
if (this.database) {
|
|
15310
15322
|
params.push("dbname=" + quoteParamValue(this.database));
|
|
15311
15323
|
}
|
|
@@ -15406,7 +15418,7 @@ var require_result = __commonJS({
|
|
|
15406
15418
|
if (this.fields.length) {
|
|
15407
15419
|
this._parsers = new Array(fieldDescriptions.length);
|
|
15408
15420
|
}
|
|
15409
|
-
const row =
|
|
15421
|
+
const row = /* @__PURE__ */ Object.create(null);
|
|
15410
15422
|
for (let i = 0; i < fieldDescriptions.length; i++) {
|
|
15411
15423
|
const desc = fieldDescriptions[i];
|
|
15412
15424
|
row[desc.name] = null;
|
|
@@ -15601,6 +15613,8 @@ var require_query = __commonJS({
|
|
|
15601
15613
|
valueMapper: utils.prepareValue
|
|
15602
15614
|
});
|
|
15603
15615
|
} catch (err) {
|
|
15616
|
+
connection.close({ type: "S", name: this.name });
|
|
15617
|
+
connection.sync();
|
|
15604
15618
|
this.handleError(err, connection);
|
|
15605
15619
|
return;
|
|
15606
15620
|
}
|
|
@@ -15620,9 +15634,9 @@ var require_query = __commonJS({
|
|
|
15620
15634
|
}
|
|
15621
15635
|
});
|
|
15622
15636
|
|
|
15623
|
-
// ../../node_modules/pg-protocol/dist/messages.js
|
|
15637
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/messages.js
|
|
15624
15638
|
var require_messages = __commonJS({
|
|
15625
|
-
"../../node_modules/pg-protocol/dist/messages.js"(exports2) {
|
|
15639
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/messages.js"(exports2) {
|
|
15626
15640
|
"use strict";
|
|
15627
15641
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15628
15642
|
exports2.NoticeMessage = exports2.DataRowMessage = exports2.CommandCompleteMessage = exports2.ReadyForQueryMessage = exports2.NotificationResponseMessage = exports2.BackendKeyDataMessage = exports2.AuthenticationMD5Password = exports2.ParameterStatusMessage = exports2.ParameterDescriptionMessage = exports2.RowDescriptionMessage = exports2.Field = exports2.CopyResponse = exports2.CopyDataMessage = exports2.DatabaseError = exports2.copyDone = exports2.emptyQuery = exports2.replicationStart = exports2.portalSuspended = exports2.noData = exports2.closeComplete = exports2.bindComplete = exports2.parseComplete = void 0;
|
|
@@ -15785,9 +15799,9 @@ var require_messages = __commonJS({
|
|
|
15785
15799
|
}
|
|
15786
15800
|
});
|
|
15787
15801
|
|
|
15788
|
-
// ../../node_modules/pg-protocol/dist/buffer-writer.js
|
|
15802
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/buffer-writer.js
|
|
15789
15803
|
var require_buffer_writer = __commonJS({
|
|
15790
|
-
"../../node_modules/pg-protocol/dist/buffer-writer.js"(exports2) {
|
|
15804
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/buffer-writer.js"(exports2) {
|
|
15791
15805
|
"use strict";
|
|
15792
15806
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15793
15807
|
exports2.Writer = void 0;
|
|
@@ -15840,6 +15854,25 @@ var require_buffer_writer = __commonJS({
|
|
|
15840
15854
|
this.offset += len;
|
|
15841
15855
|
return this;
|
|
15842
15856
|
}
|
|
15857
|
+
// Write an Int32 byte-length prefix immediately followed by the string's UTF-8
|
|
15858
|
+
// bytes. Postgres' Bind wire format prefixes every parameter with its length,
|
|
15859
|
+
// and doing it in one method computes Buffer.byteLength ONCE — the previous
|
|
15860
|
+
// `addInt32(Buffer.byteLength(s)).addString(s)` pairing scanned the string
|
|
15861
|
+
// three times (byteLength for the prefix, byteLength again inside addString,
|
|
15862
|
+
// then the encode), which is costly for large text parameters.
|
|
15863
|
+
addInt32PrefixedString(string) {
|
|
15864
|
+
const len = Buffer.byteLength(string);
|
|
15865
|
+
this.ensure(4 + len);
|
|
15866
|
+
const buffer = this.buffer;
|
|
15867
|
+
let offset = this.offset;
|
|
15868
|
+
buffer[offset++] = len >>> 24 & 255;
|
|
15869
|
+
buffer[offset++] = len >>> 16 & 255;
|
|
15870
|
+
buffer[offset++] = len >>> 8 & 255;
|
|
15871
|
+
buffer[offset++] = len >>> 0 & 255;
|
|
15872
|
+
buffer.write(string, offset, "utf-8");
|
|
15873
|
+
this.offset = offset + len;
|
|
15874
|
+
return this;
|
|
15875
|
+
}
|
|
15843
15876
|
add(otherBuffer) {
|
|
15844
15877
|
this.ensure(otherBuffer.length);
|
|
15845
15878
|
otherBuffer.copy(this.buffer, this.offset);
|
|
@@ -15861,14 +15894,18 @@ var require_buffer_writer = __commonJS({
|
|
|
15861
15894
|
this.buffer = Buffer.allocUnsafe(this.size);
|
|
15862
15895
|
return result;
|
|
15863
15896
|
}
|
|
15897
|
+
clear() {
|
|
15898
|
+
this.offset = 5;
|
|
15899
|
+
this.headerPosition = 0;
|
|
15900
|
+
}
|
|
15864
15901
|
};
|
|
15865
15902
|
exports2.Writer = Writer;
|
|
15866
15903
|
}
|
|
15867
15904
|
});
|
|
15868
15905
|
|
|
15869
|
-
// ../../node_modules/pg-protocol/dist/serializer.js
|
|
15906
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/serializer.js
|
|
15870
15907
|
var require_serializer = __commonJS({
|
|
15871
|
-
"../../node_modules/pg-protocol/dist/serializer.js"(exports2) {
|
|
15908
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/serializer.js"(exports2) {
|
|
15872
15909
|
"use strict";
|
|
15873
15910
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
15874
15911
|
exports2.serialize = void 0;
|
|
@@ -15897,7 +15934,7 @@ var require_serializer = __commonJS({
|
|
|
15897
15934
|
);
|
|
15898
15935
|
};
|
|
15899
15936
|
var sendSASLInitialResponseMessage = function(mechanism, initialResponse) {
|
|
15900
|
-
writer.addCString(mechanism).
|
|
15937
|
+
writer.addCString(mechanism).addInt32PrefixedString(initialResponse);
|
|
15901
15938
|
return writer.flush(
|
|
15902
15939
|
112
|
|
15903
15940
|
/* code.startup */
|
|
@@ -15956,8 +15993,7 @@ var require_serializer = __commonJS({
|
|
|
15956
15993
|
0
|
|
15957
15994
|
/* ParamType.STRING */
|
|
15958
15995
|
);
|
|
15959
|
-
paramWriter.
|
|
15960
|
-
paramWriter.addString(mappedVal);
|
|
15996
|
+
paramWriter.addInt32PrefixedString(mappedVal);
|
|
15961
15997
|
}
|
|
15962
15998
|
}
|
|
15963
15999
|
};
|
|
@@ -15969,7 +16005,13 @@ var require_serializer = __commonJS({
|
|
|
15969
16005
|
const len = values.length;
|
|
15970
16006
|
writer.addCString(portal).addCString(statement);
|
|
15971
16007
|
writer.addInt16(len);
|
|
15972
|
-
|
|
16008
|
+
try {
|
|
16009
|
+
writeValues(values, config.valueMapper);
|
|
16010
|
+
} catch (err) {
|
|
16011
|
+
writer.clear();
|
|
16012
|
+
paramWriter.clear();
|
|
16013
|
+
throw err;
|
|
16014
|
+
}
|
|
15973
16015
|
writer.addInt16(len);
|
|
15974
16016
|
writer.add(paramWriter.flush());
|
|
15975
16017
|
writer.addInt16(1);
|
|
@@ -16083,17 +16125,16 @@ var require_serializer = __commonJS({
|
|
|
16083
16125
|
}
|
|
16084
16126
|
});
|
|
16085
16127
|
|
|
16086
|
-
// ../../node_modules/pg-protocol/dist/buffer-reader.js
|
|
16128
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/buffer-reader.js
|
|
16087
16129
|
var require_buffer_reader = __commonJS({
|
|
16088
|
-
"../../node_modules/pg-protocol/dist/buffer-reader.js"(exports2) {
|
|
16130
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/buffer-reader.js"(exports2) {
|
|
16089
16131
|
"use strict";
|
|
16090
16132
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16091
16133
|
exports2.BufferReader = void 0;
|
|
16092
|
-
var emptyBuffer = Buffer.allocUnsafe(0);
|
|
16093
16134
|
var BufferReader = class {
|
|
16094
16135
|
constructor(offset = 0) {
|
|
16095
16136
|
this.offset = offset;
|
|
16096
|
-
this.buffer =
|
|
16137
|
+
this.buffer = Buffer.allocUnsafe(0);
|
|
16097
16138
|
this.encoding = "utf-8";
|
|
16098
16139
|
}
|
|
16099
16140
|
setBuffer(offset, buffer) {
|
|
@@ -16128,7 +16169,7 @@ var require_buffer_reader = __commonJS({
|
|
|
16128
16169
|
cstring() {
|
|
16129
16170
|
const start = this.offset;
|
|
16130
16171
|
let end = start;
|
|
16131
|
-
while (this.buffer[end++]
|
|
16172
|
+
while (this.buffer[end++]) {
|
|
16132
16173
|
}
|
|
16133
16174
|
this.offset = end;
|
|
16134
16175
|
return this.buffer.toString(this.encoding, start, end - 1);
|
|
@@ -16143,9 +16184,9 @@ var require_buffer_reader = __commonJS({
|
|
|
16143
16184
|
}
|
|
16144
16185
|
});
|
|
16145
16186
|
|
|
16146
|
-
// ../../node_modules/pg-protocol/dist/parser.js
|
|
16187
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/parser.js
|
|
16147
16188
|
var require_parser = __commonJS({
|
|
16148
|
-
"../../node_modules/pg-protocol/dist/parser.js"(exports2) {
|
|
16189
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/parser.js"(exports2) {
|
|
16149
16190
|
"use strict";
|
|
16150
16191
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16151
16192
|
exports2.Parser = void 0;
|
|
@@ -16154,6 +16195,7 @@ var require_parser = __commonJS({
|
|
|
16154
16195
|
var CODE_LENGTH = 1;
|
|
16155
16196
|
var LEN_LENGTH = 4;
|
|
16156
16197
|
var HEADER_LENGTH = CODE_LENGTH + LEN_LENGTH;
|
|
16198
|
+
var LATEINIT_LENGTH = -1;
|
|
16157
16199
|
var emptyBuffer = Buffer.allocUnsafe(0);
|
|
16158
16200
|
var Parser = class {
|
|
16159
16201
|
constructor(opts) {
|
|
@@ -16219,229 +16261,243 @@ var require_parser = __commonJS({
|
|
|
16219
16261
|
}
|
|
16220
16262
|
}
|
|
16221
16263
|
handlePacket(offset, code, length, bytes) {
|
|
16264
|
+
const { reader } = this;
|
|
16265
|
+
reader.setBuffer(offset, bytes);
|
|
16266
|
+
let message;
|
|
16222
16267
|
switch (code) {
|
|
16223
16268
|
case 50:
|
|
16224
|
-
|
|
16269
|
+
message = messages_1.bindComplete;
|
|
16270
|
+
break;
|
|
16225
16271
|
case 49:
|
|
16226
|
-
|
|
16272
|
+
message = messages_1.parseComplete;
|
|
16273
|
+
break;
|
|
16227
16274
|
case 51:
|
|
16228
|
-
|
|
16275
|
+
message = messages_1.closeComplete;
|
|
16276
|
+
break;
|
|
16229
16277
|
case 110:
|
|
16230
|
-
|
|
16278
|
+
message = messages_1.noData;
|
|
16279
|
+
break;
|
|
16231
16280
|
case 115:
|
|
16232
|
-
|
|
16281
|
+
message = messages_1.portalSuspended;
|
|
16282
|
+
break;
|
|
16233
16283
|
case 99:
|
|
16234
|
-
|
|
16284
|
+
message = messages_1.copyDone;
|
|
16285
|
+
break;
|
|
16235
16286
|
case 87:
|
|
16236
|
-
|
|
16287
|
+
message = messages_1.replicationStart;
|
|
16288
|
+
break;
|
|
16237
16289
|
case 73:
|
|
16238
|
-
|
|
16290
|
+
message = messages_1.emptyQuery;
|
|
16291
|
+
break;
|
|
16239
16292
|
case 68:
|
|
16240
|
-
|
|
16293
|
+
message = parseDataRowMessage(reader);
|
|
16294
|
+
break;
|
|
16241
16295
|
case 67:
|
|
16242
|
-
|
|
16296
|
+
message = parseCommandCompleteMessage(reader);
|
|
16297
|
+
break;
|
|
16243
16298
|
case 90:
|
|
16244
|
-
|
|
16299
|
+
message = parseReadyForQueryMessage(reader);
|
|
16300
|
+
break;
|
|
16245
16301
|
case 65:
|
|
16246
|
-
|
|
16302
|
+
message = parseNotificationMessage(reader);
|
|
16303
|
+
break;
|
|
16247
16304
|
case 82:
|
|
16248
|
-
|
|
16305
|
+
message = parseAuthenticationResponse(reader, length);
|
|
16306
|
+
break;
|
|
16249
16307
|
case 83:
|
|
16250
|
-
|
|
16308
|
+
message = parseParameterStatusMessage(reader);
|
|
16309
|
+
break;
|
|
16251
16310
|
case 75:
|
|
16252
|
-
|
|
16311
|
+
message = parseBackendKeyData(reader);
|
|
16312
|
+
break;
|
|
16253
16313
|
case 69:
|
|
16254
|
-
|
|
16314
|
+
message = parseErrorMessage(reader, "error");
|
|
16315
|
+
break;
|
|
16255
16316
|
case 78:
|
|
16256
|
-
|
|
16257
|
-
case 84:
|
|
16258
|
-
return this.parseRowDescriptionMessage(offset, length, bytes);
|
|
16259
|
-
case 116:
|
|
16260
|
-
return this.parseParameterDescriptionMessage(offset, length, bytes);
|
|
16261
|
-
case 71:
|
|
16262
|
-
return this.parseCopyInMessage(offset, length, bytes);
|
|
16263
|
-
case 72:
|
|
16264
|
-
return this.parseCopyOutMessage(offset, length, bytes);
|
|
16265
|
-
case 100:
|
|
16266
|
-
return this.parseCopyData(offset, length, bytes);
|
|
16267
|
-
default:
|
|
16268
|
-
return new messages_1.DatabaseError("received invalid response: " + code.toString(16), length, "error");
|
|
16269
|
-
}
|
|
16270
|
-
}
|
|
16271
|
-
parseReadyForQueryMessage(offset, length, bytes) {
|
|
16272
|
-
this.reader.setBuffer(offset, bytes);
|
|
16273
|
-
const status = this.reader.string(1);
|
|
16274
|
-
return new messages_1.ReadyForQueryMessage(length, status);
|
|
16275
|
-
}
|
|
16276
|
-
parseCommandCompleteMessage(offset, length, bytes) {
|
|
16277
|
-
this.reader.setBuffer(offset, bytes);
|
|
16278
|
-
const text = this.reader.cstring();
|
|
16279
|
-
return new messages_1.CommandCompleteMessage(length, text);
|
|
16280
|
-
}
|
|
16281
|
-
parseCopyData(offset, length, bytes) {
|
|
16282
|
-
const chunk = bytes.slice(offset, offset + (length - 4));
|
|
16283
|
-
return new messages_1.CopyDataMessage(length, chunk);
|
|
16284
|
-
}
|
|
16285
|
-
parseCopyInMessage(offset, length, bytes) {
|
|
16286
|
-
return this.parseCopyMessage(offset, length, bytes, "copyInResponse");
|
|
16287
|
-
}
|
|
16288
|
-
parseCopyOutMessage(offset, length, bytes) {
|
|
16289
|
-
return this.parseCopyMessage(offset, length, bytes, "copyOutResponse");
|
|
16290
|
-
}
|
|
16291
|
-
parseCopyMessage(offset, length, bytes, messageName) {
|
|
16292
|
-
this.reader.setBuffer(offset, bytes);
|
|
16293
|
-
const isBinary = this.reader.byte() !== 0;
|
|
16294
|
-
const columnCount = this.reader.int16();
|
|
16295
|
-
const message = new messages_1.CopyResponse(length, messageName, isBinary, columnCount);
|
|
16296
|
-
for (let i = 0; i < columnCount; i++) {
|
|
16297
|
-
message.columnTypes[i] = this.reader.int16();
|
|
16298
|
-
}
|
|
16299
|
-
return message;
|
|
16300
|
-
}
|
|
16301
|
-
parseNotificationMessage(offset, length, bytes) {
|
|
16302
|
-
this.reader.setBuffer(offset, bytes);
|
|
16303
|
-
const processId = this.reader.int32();
|
|
16304
|
-
const channel = this.reader.cstring();
|
|
16305
|
-
const payload = this.reader.cstring();
|
|
16306
|
-
return new messages_1.NotificationResponseMessage(length, processId, channel, payload);
|
|
16307
|
-
}
|
|
16308
|
-
parseRowDescriptionMessage(offset, length, bytes) {
|
|
16309
|
-
this.reader.setBuffer(offset, bytes);
|
|
16310
|
-
const fieldCount = this.reader.int16();
|
|
16311
|
-
const message = new messages_1.RowDescriptionMessage(length, fieldCount);
|
|
16312
|
-
for (let i = 0; i < fieldCount; i++) {
|
|
16313
|
-
message.fields[i] = this.parseField();
|
|
16314
|
-
}
|
|
16315
|
-
return message;
|
|
16316
|
-
}
|
|
16317
|
-
parseField() {
|
|
16318
|
-
const name = this.reader.cstring();
|
|
16319
|
-
const tableID = this.reader.uint32();
|
|
16320
|
-
const columnID = this.reader.int16();
|
|
16321
|
-
const dataTypeID = this.reader.uint32();
|
|
16322
|
-
const dataTypeSize = this.reader.int16();
|
|
16323
|
-
const dataTypeModifier = this.reader.int32();
|
|
16324
|
-
const mode = this.reader.int16() === 0 ? "text" : "binary";
|
|
16325
|
-
return new messages_1.Field(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, mode);
|
|
16326
|
-
}
|
|
16327
|
-
parseParameterDescriptionMessage(offset, length, bytes) {
|
|
16328
|
-
this.reader.setBuffer(offset, bytes);
|
|
16329
|
-
const parameterCount = this.reader.int16();
|
|
16330
|
-
const message = new messages_1.ParameterDescriptionMessage(length, parameterCount);
|
|
16331
|
-
for (let i = 0; i < parameterCount; i++) {
|
|
16332
|
-
message.dataTypeIDs[i] = this.reader.int32();
|
|
16333
|
-
}
|
|
16334
|
-
return message;
|
|
16335
|
-
}
|
|
16336
|
-
parseDataRowMessage(offset, length, bytes) {
|
|
16337
|
-
this.reader.setBuffer(offset, bytes);
|
|
16338
|
-
const fieldCount = this.reader.int16();
|
|
16339
|
-
const fields = new Array(fieldCount);
|
|
16340
|
-
for (let i = 0; i < fieldCount; i++) {
|
|
16341
|
-
const len = this.reader.int32();
|
|
16342
|
-
fields[i] = len === -1 ? null : this.reader.string(len);
|
|
16343
|
-
}
|
|
16344
|
-
return new messages_1.DataRowMessage(length, fields);
|
|
16345
|
-
}
|
|
16346
|
-
parseParameterStatusMessage(offset, length, bytes) {
|
|
16347
|
-
this.reader.setBuffer(offset, bytes);
|
|
16348
|
-
const name = this.reader.cstring();
|
|
16349
|
-
const value = this.reader.cstring();
|
|
16350
|
-
return new messages_1.ParameterStatusMessage(length, name, value);
|
|
16351
|
-
}
|
|
16352
|
-
parseBackendKeyData(offset, length, bytes) {
|
|
16353
|
-
this.reader.setBuffer(offset, bytes);
|
|
16354
|
-
const processID = this.reader.int32();
|
|
16355
|
-
const secretKey = this.reader.int32();
|
|
16356
|
-
return new messages_1.BackendKeyDataMessage(length, processID, secretKey);
|
|
16357
|
-
}
|
|
16358
|
-
parseAuthenticationResponse(offset, length, bytes) {
|
|
16359
|
-
this.reader.setBuffer(offset, bytes);
|
|
16360
|
-
const code = this.reader.int32();
|
|
16361
|
-
const message = {
|
|
16362
|
-
name: "authenticationOk",
|
|
16363
|
-
length
|
|
16364
|
-
};
|
|
16365
|
-
switch (code) {
|
|
16366
|
-
case 0:
|
|
16317
|
+
message = parseErrorMessage(reader, "notice");
|
|
16367
16318
|
break;
|
|
16368
|
-
case
|
|
16369
|
-
|
|
16370
|
-
message.name = "authenticationCleartextPassword";
|
|
16371
|
-
}
|
|
16319
|
+
case 84:
|
|
16320
|
+
message = parseRowDescriptionMessage(reader);
|
|
16372
16321
|
break;
|
|
16373
|
-
case
|
|
16374
|
-
|
|
16375
|
-
message.name = "authenticationMD5Password";
|
|
16376
|
-
const salt = this.reader.bytes(4);
|
|
16377
|
-
return new messages_1.AuthenticationMD5Password(length, salt);
|
|
16378
|
-
}
|
|
16322
|
+
case 116:
|
|
16323
|
+
message = parseParameterDescriptionMessage(reader);
|
|
16379
16324
|
break;
|
|
16380
|
-
case
|
|
16381
|
-
|
|
16382
|
-
message.name = "authenticationSASL";
|
|
16383
|
-
message.mechanisms = [];
|
|
16384
|
-
let mechanism;
|
|
16385
|
-
do {
|
|
16386
|
-
mechanism = this.reader.cstring();
|
|
16387
|
-
if (mechanism) {
|
|
16388
|
-
message.mechanisms.push(mechanism);
|
|
16389
|
-
}
|
|
16390
|
-
} while (mechanism);
|
|
16391
|
-
}
|
|
16325
|
+
case 71:
|
|
16326
|
+
message = parseCopyInMessage(reader);
|
|
16392
16327
|
break;
|
|
16393
|
-
case
|
|
16394
|
-
message
|
|
16395
|
-
message.data = this.reader.string(length - 8);
|
|
16328
|
+
case 72:
|
|
16329
|
+
message = parseCopyOutMessage(reader);
|
|
16396
16330
|
break;
|
|
16397
|
-
case
|
|
16398
|
-
message
|
|
16399
|
-
message.data = this.reader.string(length - 8);
|
|
16331
|
+
case 100:
|
|
16332
|
+
message = parseCopyData(reader, length);
|
|
16400
16333
|
break;
|
|
16401
16334
|
default:
|
|
16402
|
-
|
|
16335
|
+
return new messages_1.DatabaseError("received invalid response: " + code.toString(16), length, "error");
|
|
16403
16336
|
}
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
parseErrorMessage(offset, length, bytes, name) {
|
|
16407
|
-
this.reader.setBuffer(offset, bytes);
|
|
16408
|
-
const fields = {};
|
|
16409
|
-
let fieldType = this.reader.string(1);
|
|
16410
|
-
while (fieldType !== "\0") {
|
|
16411
|
-
fields[fieldType] = this.reader.cstring();
|
|
16412
|
-
fieldType = this.reader.string(1);
|
|
16413
|
-
}
|
|
16414
|
-
const messageValue = fields.M;
|
|
16415
|
-
const message = name === "notice" ? new messages_1.NoticeMessage(length, messageValue) : new messages_1.DatabaseError(messageValue, length, name);
|
|
16416
|
-
message.severity = fields.S;
|
|
16417
|
-
message.code = fields.C;
|
|
16418
|
-
message.detail = fields.D;
|
|
16419
|
-
message.hint = fields.H;
|
|
16420
|
-
message.position = fields.P;
|
|
16421
|
-
message.internalPosition = fields.p;
|
|
16422
|
-
message.internalQuery = fields.q;
|
|
16423
|
-
message.where = fields.W;
|
|
16424
|
-
message.schema = fields.s;
|
|
16425
|
-
message.table = fields.t;
|
|
16426
|
-
message.column = fields.c;
|
|
16427
|
-
message.dataType = fields.d;
|
|
16428
|
-
message.constraint = fields.n;
|
|
16429
|
-
message.file = fields.F;
|
|
16430
|
-
message.line = fields.L;
|
|
16431
|
-
message.routine = fields.R;
|
|
16337
|
+
reader.setBuffer(0, emptyBuffer);
|
|
16338
|
+
message.length = length;
|
|
16432
16339
|
return message;
|
|
16433
16340
|
}
|
|
16434
16341
|
};
|
|
16435
16342
|
exports2.Parser = Parser;
|
|
16343
|
+
var parseReadyForQueryMessage = (reader) => {
|
|
16344
|
+
const status = reader.string(1);
|
|
16345
|
+
return new messages_1.ReadyForQueryMessage(LATEINIT_LENGTH, status);
|
|
16346
|
+
};
|
|
16347
|
+
var parseCommandCompleteMessage = (reader) => {
|
|
16348
|
+
const text = reader.cstring();
|
|
16349
|
+
return new messages_1.CommandCompleteMessage(LATEINIT_LENGTH, text);
|
|
16350
|
+
};
|
|
16351
|
+
var parseCopyData = (reader, length) => {
|
|
16352
|
+
const chunk = reader.bytes(length - 4);
|
|
16353
|
+
return new messages_1.CopyDataMessage(LATEINIT_LENGTH, chunk);
|
|
16354
|
+
};
|
|
16355
|
+
var parseCopyInMessage = (reader) => parseCopyMessage(reader, "copyInResponse");
|
|
16356
|
+
var parseCopyOutMessage = (reader) => parseCopyMessage(reader, "copyOutResponse");
|
|
16357
|
+
var parseCopyMessage = (reader, messageName) => {
|
|
16358
|
+
const isBinary = reader.byte() !== 0;
|
|
16359
|
+
const columnCount = reader.int16();
|
|
16360
|
+
const message = new messages_1.CopyResponse(LATEINIT_LENGTH, messageName, isBinary, columnCount);
|
|
16361
|
+
for (let i = 0; i < columnCount; i++) {
|
|
16362
|
+
message.columnTypes[i] = reader.int16();
|
|
16363
|
+
}
|
|
16364
|
+
return message;
|
|
16365
|
+
};
|
|
16366
|
+
var parseNotificationMessage = (reader) => {
|
|
16367
|
+
const processId = reader.int32();
|
|
16368
|
+
const channel = reader.cstring();
|
|
16369
|
+
const payload = reader.cstring();
|
|
16370
|
+
return new messages_1.NotificationResponseMessage(LATEINIT_LENGTH, processId, channel, payload);
|
|
16371
|
+
};
|
|
16372
|
+
var parseRowDescriptionMessage = (reader) => {
|
|
16373
|
+
const fieldCount = reader.int16();
|
|
16374
|
+
const message = new messages_1.RowDescriptionMessage(LATEINIT_LENGTH, fieldCount);
|
|
16375
|
+
for (let i = 0; i < fieldCount; i++) {
|
|
16376
|
+
message.fields[i] = parseField(reader);
|
|
16377
|
+
}
|
|
16378
|
+
return message;
|
|
16379
|
+
};
|
|
16380
|
+
var parseField = (reader) => {
|
|
16381
|
+
const name = reader.cstring();
|
|
16382
|
+
const tableID = reader.uint32();
|
|
16383
|
+
const columnID = reader.int16();
|
|
16384
|
+
const dataTypeID = reader.uint32();
|
|
16385
|
+
const dataTypeSize = reader.int16();
|
|
16386
|
+
const dataTypeModifier = reader.int32();
|
|
16387
|
+
const mode = reader.int16() === 0 ? "text" : "binary";
|
|
16388
|
+
return new messages_1.Field(name, tableID, columnID, dataTypeID, dataTypeSize, dataTypeModifier, mode);
|
|
16389
|
+
};
|
|
16390
|
+
var parseParameterDescriptionMessage = (reader) => {
|
|
16391
|
+
const parameterCount = reader.int16();
|
|
16392
|
+
const message = new messages_1.ParameterDescriptionMessage(LATEINIT_LENGTH, parameterCount);
|
|
16393
|
+
for (let i = 0; i < parameterCount; i++) {
|
|
16394
|
+
message.dataTypeIDs[i] = reader.int32();
|
|
16395
|
+
}
|
|
16396
|
+
return message;
|
|
16397
|
+
};
|
|
16398
|
+
var parseDataRowMessage = (reader) => {
|
|
16399
|
+
const fieldCount = reader.int16();
|
|
16400
|
+
const fields = new Array(fieldCount);
|
|
16401
|
+
for (let i = 0; i < fieldCount; i++) {
|
|
16402
|
+
const len = reader.int32();
|
|
16403
|
+
fields[i] = len === -1 ? null : reader.string(len);
|
|
16404
|
+
}
|
|
16405
|
+
return new messages_1.DataRowMessage(LATEINIT_LENGTH, fields);
|
|
16406
|
+
};
|
|
16407
|
+
var parseParameterStatusMessage = (reader) => {
|
|
16408
|
+
const name = reader.cstring();
|
|
16409
|
+
const value = reader.cstring();
|
|
16410
|
+
return new messages_1.ParameterStatusMessage(LATEINIT_LENGTH, name, value);
|
|
16411
|
+
};
|
|
16412
|
+
var parseBackendKeyData = (reader) => {
|
|
16413
|
+
const processID = reader.int32();
|
|
16414
|
+
const secretKey = reader.int32();
|
|
16415
|
+
return new messages_1.BackendKeyDataMessage(LATEINIT_LENGTH, processID, secretKey);
|
|
16416
|
+
};
|
|
16417
|
+
var parseAuthenticationResponse = (reader, length) => {
|
|
16418
|
+
const code = reader.int32();
|
|
16419
|
+
const message = {
|
|
16420
|
+
name: "authenticationOk",
|
|
16421
|
+
length
|
|
16422
|
+
};
|
|
16423
|
+
switch (code) {
|
|
16424
|
+
case 0:
|
|
16425
|
+
break;
|
|
16426
|
+
case 3:
|
|
16427
|
+
if (message.length === 8) {
|
|
16428
|
+
message.name = "authenticationCleartextPassword";
|
|
16429
|
+
}
|
|
16430
|
+
break;
|
|
16431
|
+
case 5:
|
|
16432
|
+
if (message.length === 12) {
|
|
16433
|
+
message.name = "authenticationMD5Password";
|
|
16434
|
+
const salt = reader.bytes(4);
|
|
16435
|
+
return new messages_1.AuthenticationMD5Password(LATEINIT_LENGTH, salt);
|
|
16436
|
+
}
|
|
16437
|
+
break;
|
|
16438
|
+
case 10:
|
|
16439
|
+
{
|
|
16440
|
+
message.name = "authenticationSASL";
|
|
16441
|
+
message.mechanisms = [];
|
|
16442
|
+
let mechanism;
|
|
16443
|
+
do {
|
|
16444
|
+
mechanism = reader.cstring();
|
|
16445
|
+
if (mechanism) {
|
|
16446
|
+
message.mechanisms.push(mechanism);
|
|
16447
|
+
}
|
|
16448
|
+
} while (mechanism);
|
|
16449
|
+
}
|
|
16450
|
+
break;
|
|
16451
|
+
case 11:
|
|
16452
|
+
message.name = "authenticationSASLContinue";
|
|
16453
|
+
message.data = reader.string(length - 8);
|
|
16454
|
+
break;
|
|
16455
|
+
case 12:
|
|
16456
|
+
message.name = "authenticationSASLFinal";
|
|
16457
|
+
message.data = reader.string(length - 8);
|
|
16458
|
+
break;
|
|
16459
|
+
default:
|
|
16460
|
+
throw new Error("Unknown authenticationOk message type " + code);
|
|
16461
|
+
}
|
|
16462
|
+
return message;
|
|
16463
|
+
};
|
|
16464
|
+
var parseErrorMessage = (reader, name) => {
|
|
16465
|
+
const fields = {};
|
|
16466
|
+
let fieldType = reader.string(1);
|
|
16467
|
+
while (fieldType !== "\0") {
|
|
16468
|
+
fields[fieldType] = reader.cstring();
|
|
16469
|
+
fieldType = reader.string(1);
|
|
16470
|
+
}
|
|
16471
|
+
const messageValue = fields.M;
|
|
16472
|
+
const message = name === "notice" ? new messages_1.NoticeMessage(LATEINIT_LENGTH, messageValue) : new messages_1.DatabaseError(messageValue, LATEINIT_LENGTH, name);
|
|
16473
|
+
message.severity = fields.S;
|
|
16474
|
+
message.code = fields.C;
|
|
16475
|
+
message.detail = fields.D;
|
|
16476
|
+
message.hint = fields.H;
|
|
16477
|
+
message.position = fields.P;
|
|
16478
|
+
message.internalPosition = fields.p;
|
|
16479
|
+
message.internalQuery = fields.q;
|
|
16480
|
+
message.where = fields.W;
|
|
16481
|
+
message.schema = fields.s;
|
|
16482
|
+
message.table = fields.t;
|
|
16483
|
+
message.column = fields.c;
|
|
16484
|
+
message.dataType = fields.d;
|
|
16485
|
+
message.constraint = fields.n;
|
|
16486
|
+
message.file = fields.F;
|
|
16487
|
+
message.line = fields.L;
|
|
16488
|
+
message.routine = fields.R;
|
|
16489
|
+
return message;
|
|
16490
|
+
};
|
|
16436
16491
|
}
|
|
16437
16492
|
});
|
|
16438
16493
|
|
|
16439
|
-
// ../../node_modules/pg-protocol/dist/index.js
|
|
16494
|
+
// ../../node_modules/pg/node_modules/pg-protocol/dist/index.js
|
|
16440
16495
|
var require_dist2 = __commonJS({
|
|
16441
|
-
"../../node_modules/pg-protocol/dist/index.js"(exports2) {
|
|
16496
|
+
"../../node_modules/pg/node_modules/pg-protocol/dist/index.js"(exports2) {
|
|
16442
16497
|
"use strict";
|
|
16443
16498
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
16444
|
-
exports2.DatabaseError = exports2.serialize =
|
|
16499
|
+
exports2.DatabaseError = exports2.serialize = void 0;
|
|
16500
|
+
exports2.parse = parse;
|
|
16445
16501
|
var messages_1 = require_messages();
|
|
16446
16502
|
Object.defineProperty(exports2, "DatabaseError", { enumerable: true, get: function() {
|
|
16447
16503
|
return messages_1.DatabaseError;
|
|
@@ -16456,7 +16512,6 @@ var require_dist2 = __commonJS({
|
|
|
16456
16512
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
16457
16513
|
return new Promise((resolve) => stream.on("end", () => resolve()));
|
|
16458
16514
|
}
|
|
16459
|
-
exports2.parse = parse;
|
|
16460
16515
|
}
|
|
16461
16516
|
});
|
|
16462
16517
|
|
|
@@ -16542,7 +16597,8 @@ var require_connection = __commonJS({
|
|
|
16542
16597
|
"use strict";
|
|
16543
16598
|
var EventEmitter = require("events").EventEmitter;
|
|
16544
16599
|
var { parse, serialize } = require_dist2();
|
|
16545
|
-
var
|
|
16600
|
+
var stream = require_stream();
|
|
16601
|
+
var { getStream } = stream;
|
|
16546
16602
|
var flushBuffer = serialize.flush();
|
|
16547
16603
|
var syncBuffer = serialize.sync();
|
|
16548
16604
|
var endBuffer = serialize.end();
|
|
@@ -16556,9 +16612,9 @@ var require_connection = __commonJS({
|
|
|
16556
16612
|
}
|
|
16557
16613
|
this._keepAlive = config.keepAlive;
|
|
16558
16614
|
this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis;
|
|
16559
|
-
this.lastBuffer = false;
|
|
16560
16615
|
this.parsedStatements = {};
|
|
16561
16616
|
this.ssl = config.ssl || false;
|
|
16617
|
+
this.sslNegotiation = config.sslNegotiation || "postgres";
|
|
16562
16618
|
this._ending = false;
|
|
16563
16619
|
this._emitMessage = false;
|
|
16564
16620
|
const self = this;
|
|
@@ -16592,6 +16648,11 @@ var require_connection = __commonJS({
|
|
|
16592
16648
|
if (!this.ssl) {
|
|
16593
16649
|
return this.attachListeners(this.stream);
|
|
16594
16650
|
}
|
|
16651
|
+
if (this.sslNegotiation === "direct") {
|
|
16652
|
+
return this.stream.once("connect", function() {
|
|
16653
|
+
self.upgradeToSSL(host, reportStreamError);
|
|
16654
|
+
});
|
|
16655
|
+
}
|
|
16595
16656
|
this.stream.once("data", function(buffer) {
|
|
16596
16657
|
const responseCode = buffer.toString("utf8");
|
|
16597
16658
|
switch (responseCode) {
|
|
@@ -16604,31 +16665,38 @@ var require_connection = __commonJS({
|
|
|
16604
16665
|
self.stream.end();
|
|
16605
16666
|
return self.emit("error", new Error("There was an error establishing an SSL connection"));
|
|
16606
16667
|
}
|
|
16607
|
-
|
|
16608
|
-
socket: self.stream
|
|
16609
|
-
};
|
|
16610
|
-
if (self.ssl !== true) {
|
|
16611
|
-
Object.assign(options, self.ssl);
|
|
16612
|
-
if ("key" in self.ssl) {
|
|
16613
|
-
options.key = self.ssl.key;
|
|
16614
|
-
}
|
|
16615
|
-
}
|
|
16616
|
-
const net2 = require("net");
|
|
16617
|
-
if (net2.isIP && net2.isIP(host) === 0) {
|
|
16618
|
-
options.servername = host;
|
|
16619
|
-
}
|
|
16620
|
-
try {
|
|
16621
|
-
self.stream = getSecureStream(options);
|
|
16622
|
-
} catch (err) {
|
|
16623
|
-
return self.emit("error", err);
|
|
16624
|
-
}
|
|
16625
|
-
self.attachListeners(self.stream);
|
|
16626
|
-
self.stream.on("error", reportStreamError);
|
|
16627
|
-
self.emit("sslconnect");
|
|
16668
|
+
self.upgradeToSSL(host, reportStreamError);
|
|
16628
16669
|
});
|
|
16629
16670
|
}
|
|
16630
|
-
|
|
16631
|
-
|
|
16671
|
+
upgradeToSSL(host, reportStreamError) {
|
|
16672
|
+
const self = this;
|
|
16673
|
+
const options = {
|
|
16674
|
+
socket: self.stream
|
|
16675
|
+
};
|
|
16676
|
+
if (self.ssl !== true) {
|
|
16677
|
+
Object.assign(options, self.ssl);
|
|
16678
|
+
if ("key" in self.ssl) {
|
|
16679
|
+
options.key = self.ssl.key;
|
|
16680
|
+
}
|
|
16681
|
+
}
|
|
16682
|
+
if (self.sslNegotiation === "direct") {
|
|
16683
|
+
options.ALPNProtocols = ["postgresql"];
|
|
16684
|
+
}
|
|
16685
|
+
const net2 = require("net");
|
|
16686
|
+
if (net2.isIP && net2.isIP(host) === 0) {
|
|
16687
|
+
options.servername = host;
|
|
16688
|
+
}
|
|
16689
|
+
try {
|
|
16690
|
+
self.stream = stream.getSecureStream(options);
|
|
16691
|
+
} catch (err) {
|
|
16692
|
+
return self.emit("error", err);
|
|
16693
|
+
}
|
|
16694
|
+
self.attachListeners(self.stream);
|
|
16695
|
+
self.stream.on("error", reportStreamError);
|
|
16696
|
+
self.emit("sslconnect");
|
|
16697
|
+
}
|
|
16698
|
+
attachListeners(stream2) {
|
|
16699
|
+
parse(stream2, (msg) => {
|
|
16632
16700
|
const eventName = msg.name === "error" ? "errorMessage" : msg.name;
|
|
16633
16701
|
if (this._emitMessage) {
|
|
16634
16702
|
this.emit("message", msg);
|
|
@@ -17019,6 +17087,7 @@ var require_client = __commonJS({
|
|
|
17019
17087
|
"use strict";
|
|
17020
17088
|
var EventEmitter = require("events").EventEmitter;
|
|
17021
17089
|
var utils = require_utils();
|
|
17090
|
+
var nodeUtils = require("util");
|
|
17022
17091
|
var sasl = require_sasl();
|
|
17023
17092
|
var TypeOverrides2 = require_type_overrides();
|
|
17024
17093
|
var ConnectionParameters = require_connection_parameters();
|
|
@@ -17026,6 +17095,41 @@ var require_client = __commonJS({
|
|
|
17026
17095
|
var defaults2 = require_defaults();
|
|
17027
17096
|
var Connection2 = require_connection();
|
|
17028
17097
|
var crypto = require_utils2();
|
|
17098
|
+
var activeQueryDeprecationNotice = nodeUtils.deprecate(
|
|
17099
|
+
() => {
|
|
17100
|
+
},
|
|
17101
|
+
"Client.activeQuery is deprecated and will be removed in pg@9.0"
|
|
17102
|
+
);
|
|
17103
|
+
var queryQueueDeprecationNotice = nodeUtils.deprecate(
|
|
17104
|
+
() => {
|
|
17105
|
+
},
|
|
17106
|
+
"Client.queryQueue is deprecated and will be removed in pg@9.0."
|
|
17107
|
+
);
|
|
17108
|
+
var pgPassDeprecationNotice = nodeUtils.deprecate(
|
|
17109
|
+
() => {
|
|
17110
|
+
},
|
|
17111
|
+
"pgpass support is deprecated and will be removed in pg@9.0. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code."
|
|
17112
|
+
);
|
|
17113
|
+
var byoPromiseDeprecationNotice = nodeUtils.deprecate(
|
|
17114
|
+
() => {
|
|
17115
|
+
},
|
|
17116
|
+
"Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0."
|
|
17117
|
+
);
|
|
17118
|
+
var queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
17119
|
+
() => {
|
|
17120
|
+
},
|
|
17121
|
+
"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."
|
|
17122
|
+
);
|
|
17123
|
+
function coerceNumberOrDefault(value, defaultValue) {
|
|
17124
|
+
if (typeof value === "number") {
|
|
17125
|
+
return Number.isFinite(value) ? value : defaultValue;
|
|
17126
|
+
}
|
|
17127
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
17128
|
+
const n = Number(value);
|
|
17129
|
+
return Number.isFinite(n) ? n : defaultValue;
|
|
17130
|
+
}
|
|
17131
|
+
return defaultValue;
|
|
17132
|
+
}
|
|
17029
17133
|
var Client2 = class extends EventEmitter {
|
|
17030
17134
|
constructor(config) {
|
|
17031
17135
|
super();
|
|
@@ -17042,6 +17146,9 @@ var require_client = __commonJS({
|
|
|
17042
17146
|
});
|
|
17043
17147
|
this.replication = this.connectionParameters.replication;
|
|
17044
17148
|
const c = config || {};
|
|
17149
|
+
if (c.Promise) {
|
|
17150
|
+
byoPromiseDeprecationNotice();
|
|
17151
|
+
}
|
|
17045
17152
|
this._Promise = c.Promise || global.Promise;
|
|
17046
17153
|
this._types = new TypeOverrides2(c.types);
|
|
17047
17154
|
this._ending = false;
|
|
@@ -17050,19 +17157,24 @@ var require_client = __commonJS({
|
|
|
17050
17157
|
this._connected = false;
|
|
17051
17158
|
this._connectionError = false;
|
|
17052
17159
|
this._queryable = true;
|
|
17160
|
+
this._activeQuery = null;
|
|
17161
|
+
this._txStatus = null;
|
|
17053
17162
|
this.enableChannelBinding = Boolean(c.enableChannelBinding);
|
|
17163
|
+
this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS);
|
|
17054
17164
|
this.connection = c.connection || new Connection2({
|
|
17055
17165
|
stream: c.stream,
|
|
17056
17166
|
ssl: this.connectionParameters.ssl,
|
|
17167
|
+
sslNegotiation: this.connectionParameters.sslnegotiation,
|
|
17057
17168
|
keepAlive: c.keepAlive || false,
|
|
17058
17169
|
keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0,
|
|
17059
17170
|
encoding: this.connectionParameters.client_encoding || "utf8"
|
|
17060
17171
|
});
|
|
17061
|
-
this.
|
|
17172
|
+
this._queryQueue = [];
|
|
17062
17173
|
this.binary = c.binary || defaults2.binary;
|
|
17063
17174
|
this.processID = null;
|
|
17064
17175
|
this.secretKey = null;
|
|
17065
17176
|
this.ssl = this.connectionParameters.ssl || false;
|
|
17177
|
+
this.sslNegotiation = this.connectionParameters.sslnegotiation || "postgres";
|
|
17066
17178
|
if (this.ssl && this.ssl.key) {
|
|
17067
17179
|
Object.defineProperty(this.ssl, "key", {
|
|
17068
17180
|
enumerable: false
|
|
@@ -17070,18 +17182,30 @@ var require_client = __commonJS({
|
|
|
17070
17182
|
}
|
|
17071
17183
|
this._connectionTimeoutMillis = c.connectionTimeoutMillis || 0;
|
|
17072
17184
|
}
|
|
17185
|
+
get activeQuery() {
|
|
17186
|
+
activeQueryDeprecationNotice();
|
|
17187
|
+
return this._activeQuery;
|
|
17188
|
+
}
|
|
17189
|
+
set activeQuery(val) {
|
|
17190
|
+
activeQueryDeprecationNotice();
|
|
17191
|
+
this._activeQuery = val;
|
|
17192
|
+
}
|
|
17193
|
+
_getActiveQuery() {
|
|
17194
|
+
return this._activeQuery;
|
|
17195
|
+
}
|
|
17073
17196
|
_errorAllQueries(err) {
|
|
17074
17197
|
const enqueueError = (query) => {
|
|
17075
17198
|
process.nextTick(() => {
|
|
17076
17199
|
query.handleError(err, this.connection);
|
|
17077
17200
|
});
|
|
17078
17201
|
};
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
|
|
17202
|
+
const activeQuery = this._getActiveQuery();
|
|
17203
|
+
if (activeQuery) {
|
|
17204
|
+
enqueueError(activeQuery);
|
|
17205
|
+
this._activeQuery = null;
|
|
17082
17206
|
}
|
|
17083
|
-
this.
|
|
17084
|
-
this.
|
|
17207
|
+
this._queryQueue.forEach(enqueueError);
|
|
17208
|
+
this._queryQueue.length = 0;
|
|
17085
17209
|
}
|
|
17086
17210
|
_connect(callback) {
|
|
17087
17211
|
const self = this;
|
|
@@ -17111,7 +17235,9 @@ var require_client = __commonJS({
|
|
|
17111
17235
|
}
|
|
17112
17236
|
con.on("connect", function() {
|
|
17113
17237
|
if (self.ssl) {
|
|
17114
|
-
|
|
17238
|
+
if (self.sslNegotiation !== "direct") {
|
|
17239
|
+
con.requestSsl();
|
|
17240
|
+
}
|
|
17115
17241
|
} else {
|
|
17116
17242
|
con.startup(self.getStartupConf());
|
|
17117
17243
|
}
|
|
@@ -17151,7 +17277,7 @@ var require_client = __commonJS({
|
|
|
17151
17277
|
if (error) {
|
|
17152
17278
|
reject(error);
|
|
17153
17279
|
} else {
|
|
17154
|
-
resolve();
|
|
17280
|
+
resolve(this);
|
|
17155
17281
|
}
|
|
17156
17282
|
});
|
|
17157
17283
|
});
|
|
@@ -17177,12 +17303,10 @@ var require_client = __commonJS({
|
|
|
17177
17303
|
con.on("copyData", this._handleCopyData.bind(this));
|
|
17178
17304
|
con.on("notification", this._handleNotification.bind(this));
|
|
17179
17305
|
}
|
|
17180
|
-
|
|
17181
|
-
// it can be supplied by the user if required - this is a breaking change!
|
|
17182
|
-
_checkPgPass(cb) {
|
|
17306
|
+
_getPassword(cb) {
|
|
17183
17307
|
const con = this.connection;
|
|
17184
17308
|
if (typeof this.password === "function") {
|
|
17185
|
-
this._Promise.resolve().then(() => this.password()).then((pass) => {
|
|
17309
|
+
this._Promise.resolve().then(() => this.password(this.connectionParameters)).then((pass) => {
|
|
17186
17310
|
if (pass !== void 0) {
|
|
17187
17311
|
if (typeof pass !== "string") {
|
|
17188
17312
|
con.emit("error", new TypeError("Password must be a string"));
|
|
@@ -17203,6 +17327,7 @@ var require_client = __commonJS({
|
|
|
17203
17327
|
const pgPass = require_lib();
|
|
17204
17328
|
pgPass(this.connectionParameters, (pass) => {
|
|
17205
17329
|
if (void 0 !== pass) {
|
|
17330
|
+
pgPassDeprecationNotice();
|
|
17206
17331
|
this.connectionParameters.password = this.password = pass;
|
|
17207
17332
|
}
|
|
17208
17333
|
cb();
|
|
@@ -17213,12 +17338,12 @@ var require_client = __commonJS({
|
|
|
17213
17338
|
}
|
|
17214
17339
|
}
|
|
17215
17340
|
_handleAuthCleartextPassword(msg) {
|
|
17216
|
-
this.
|
|
17341
|
+
this._getPassword(() => {
|
|
17217
17342
|
this.connection.password(this.password);
|
|
17218
17343
|
});
|
|
17219
17344
|
}
|
|
17220
17345
|
_handleAuthMD5Password(msg) {
|
|
17221
|
-
this.
|
|
17346
|
+
this._getPassword(async () => {
|
|
17222
17347
|
try {
|
|
17223
17348
|
const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt);
|
|
17224
17349
|
this.connection.password(hashedPassword);
|
|
@@ -17228,9 +17353,13 @@ var require_client = __commonJS({
|
|
|
17228
17353
|
});
|
|
17229
17354
|
}
|
|
17230
17355
|
_handleAuthSASL(msg) {
|
|
17231
|
-
this.
|
|
17356
|
+
this._getPassword(() => {
|
|
17232
17357
|
try {
|
|
17233
|
-
this.saslSession = sasl.startSession(
|
|
17358
|
+
this.saslSession = sasl.startSession(
|
|
17359
|
+
msg.mechanisms,
|
|
17360
|
+
this.enableChannelBinding && this.connection.stream,
|
|
17361
|
+
this.scramMaxIterations
|
|
17362
|
+
);
|
|
17234
17363
|
this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
|
|
17235
17364
|
} catch (err) {
|
|
17236
17365
|
this.connection.emit("error", err);
|
|
@@ -17273,8 +17402,9 @@ var require_client = __commonJS({
|
|
|
17273
17402
|
}
|
|
17274
17403
|
this.emit("connect");
|
|
17275
17404
|
}
|
|
17276
|
-
const
|
|
17277
|
-
this.
|
|
17405
|
+
const activeQuery = this._getActiveQuery();
|
|
17406
|
+
this._activeQuery = null;
|
|
17407
|
+
this._txStatus = msg?.status ?? null;
|
|
17278
17408
|
this.readyForQuery = true;
|
|
17279
17409
|
if (activeQuery) {
|
|
17280
17410
|
activeQuery.handleReadyForQuery(this.connection);
|
|
@@ -17310,49 +17440,87 @@ var require_client = __commonJS({
|
|
|
17310
17440
|
if (this._connecting) {
|
|
17311
17441
|
return this._handleErrorWhileConnecting(msg);
|
|
17312
17442
|
}
|
|
17313
|
-
const activeQuery = this.
|
|
17443
|
+
const activeQuery = this._getActiveQuery();
|
|
17314
17444
|
if (!activeQuery) {
|
|
17315
17445
|
this._handleErrorEvent(msg);
|
|
17316
17446
|
return;
|
|
17317
17447
|
}
|
|
17318
|
-
this.
|
|
17448
|
+
this._activeQuery = null;
|
|
17319
17449
|
activeQuery.handleError(msg, this.connection);
|
|
17320
17450
|
}
|
|
17321
17451
|
_handleRowDescription(msg) {
|
|
17322
|
-
this.
|
|
17452
|
+
const activeQuery = this._getActiveQuery();
|
|
17453
|
+
if (activeQuery == null) {
|
|
17454
|
+
const error = new Error("Received unexpected rowDescription message from backend.");
|
|
17455
|
+
this._handleErrorEvent(error);
|
|
17456
|
+
return;
|
|
17457
|
+
}
|
|
17458
|
+
activeQuery.handleRowDescription(msg);
|
|
17323
17459
|
}
|
|
17324
17460
|
_handleDataRow(msg) {
|
|
17325
|
-
this.
|
|
17461
|
+
const activeQuery = this._getActiveQuery();
|
|
17462
|
+
if (activeQuery == null) {
|
|
17463
|
+
const error = new Error("Received unexpected dataRow message from backend.");
|
|
17464
|
+
this._handleErrorEvent(error);
|
|
17465
|
+
return;
|
|
17466
|
+
}
|
|
17467
|
+
activeQuery.handleDataRow(msg);
|
|
17326
17468
|
}
|
|
17327
17469
|
_handlePortalSuspended(msg) {
|
|
17328
|
-
this.
|
|
17470
|
+
const activeQuery = this._getActiveQuery();
|
|
17471
|
+
if (activeQuery == null) {
|
|
17472
|
+
const error = new Error("Received unexpected portalSuspended message from backend.");
|
|
17473
|
+
this._handleErrorEvent(error);
|
|
17474
|
+
return;
|
|
17475
|
+
}
|
|
17476
|
+
activeQuery.handlePortalSuspended(this.connection);
|
|
17329
17477
|
}
|
|
17330
17478
|
_handleEmptyQuery(msg) {
|
|
17331
|
-
this.
|
|
17479
|
+
const activeQuery = this._getActiveQuery();
|
|
17480
|
+
if (activeQuery == null) {
|
|
17481
|
+
const error = new Error("Received unexpected emptyQuery message from backend.");
|
|
17482
|
+
this._handleErrorEvent(error);
|
|
17483
|
+
return;
|
|
17484
|
+
}
|
|
17485
|
+
activeQuery.handleEmptyQuery(this.connection);
|
|
17332
17486
|
}
|
|
17333
17487
|
_handleCommandComplete(msg) {
|
|
17334
|
-
|
|
17488
|
+
const activeQuery = this._getActiveQuery();
|
|
17489
|
+
if (activeQuery == null) {
|
|
17335
17490
|
const error = new Error("Received unexpected commandComplete message from backend.");
|
|
17336
17491
|
this._handleErrorEvent(error);
|
|
17337
17492
|
return;
|
|
17338
17493
|
}
|
|
17339
|
-
|
|
17494
|
+
activeQuery.handleCommandComplete(msg, this.connection);
|
|
17340
17495
|
}
|
|
17341
17496
|
_handleParseComplete() {
|
|
17342
|
-
|
|
17497
|
+
const activeQuery = this._getActiveQuery();
|
|
17498
|
+
if (activeQuery == null) {
|
|
17343
17499
|
const error = new Error("Received unexpected parseComplete message from backend.");
|
|
17344
17500
|
this._handleErrorEvent(error);
|
|
17345
17501
|
return;
|
|
17346
17502
|
}
|
|
17347
|
-
if (
|
|
17348
|
-
this.connection.parsedStatements[
|
|
17503
|
+
if (activeQuery.name) {
|
|
17504
|
+
this.connection.parsedStatements[activeQuery.name] = activeQuery.text;
|
|
17349
17505
|
}
|
|
17350
17506
|
}
|
|
17351
17507
|
_handleCopyInResponse(msg) {
|
|
17352
|
-
this.
|
|
17508
|
+
const activeQuery = this._getActiveQuery();
|
|
17509
|
+
if (activeQuery == null) {
|
|
17510
|
+
const error = new Error("Received unexpected copyInResponse message from backend.");
|
|
17511
|
+
this._handleErrorEvent(error);
|
|
17512
|
+
return;
|
|
17513
|
+
}
|
|
17514
|
+
activeQuery.handleCopyInResponse(this.connection);
|
|
17353
17515
|
}
|
|
17354
17516
|
_handleCopyData(msg) {
|
|
17355
|
-
|
|
17517
|
+
const activeQuery = this._getActiveQuery();
|
|
17518
|
+
if (activeQuery == null) {
|
|
17519
|
+
const error = new Error("Received unexpected copyData message from backend.");
|
|
17520
|
+
this._handleErrorEvent(error);
|
|
17521
|
+
return;
|
|
17522
|
+
}
|
|
17523
|
+
activeQuery.handleCopyData(msg, this.connection);
|
|
17356
17524
|
}
|
|
17357
17525
|
_handleNotification(msg) {
|
|
17358
17526
|
this.emit("notification", msg);
|
|
@@ -17398,8 +17566,8 @@ var require_client = __commonJS({
|
|
|
17398
17566
|
con.on("connect", function() {
|
|
17399
17567
|
con.cancel(client.processID, client.secretKey);
|
|
17400
17568
|
});
|
|
17401
|
-
} else if (client.
|
|
17402
|
-
client.
|
|
17569
|
+
} else if (client._queryQueue.indexOf(query) !== -1) {
|
|
17570
|
+
client._queryQueue.splice(client._queryQueue.indexOf(query), 1);
|
|
17403
17571
|
}
|
|
17404
17572
|
}
|
|
17405
17573
|
setTypeParser(oid, format2, parseFn) {
|
|
@@ -17419,20 +17587,21 @@ var require_client = __commonJS({
|
|
|
17419
17587
|
}
|
|
17420
17588
|
_pulseQueryQueue() {
|
|
17421
17589
|
if (this.readyForQuery === true) {
|
|
17422
|
-
this.
|
|
17423
|
-
|
|
17590
|
+
this._activeQuery = this._queryQueue.shift();
|
|
17591
|
+
const activeQuery = this._getActiveQuery();
|
|
17592
|
+
if (activeQuery) {
|
|
17424
17593
|
this.readyForQuery = false;
|
|
17425
17594
|
this.hasExecuted = true;
|
|
17426
|
-
const queryError =
|
|
17595
|
+
const queryError = activeQuery.submit(this.connection);
|
|
17427
17596
|
if (queryError) {
|
|
17428
17597
|
process.nextTick(() => {
|
|
17429
|
-
|
|
17598
|
+
activeQuery.handleError(queryError, this.connection);
|
|
17430
17599
|
this.readyForQuery = true;
|
|
17431
17600
|
this._pulseQueryQueue();
|
|
17432
17601
|
});
|
|
17433
17602
|
}
|
|
17434
17603
|
} else if (this.hasExecuted) {
|
|
17435
|
-
this.
|
|
17604
|
+
this._activeQuery = null;
|
|
17436
17605
|
this.emit("drain");
|
|
17437
17606
|
}
|
|
17438
17607
|
}
|
|
@@ -17440,19 +17609,19 @@ var require_client = __commonJS({
|
|
|
17440
17609
|
query(config, values, callback) {
|
|
17441
17610
|
let query;
|
|
17442
17611
|
let result;
|
|
17443
|
-
|
|
17444
|
-
let readTimeoutTimer;
|
|
17445
|
-
let queryCallback;
|
|
17446
|
-
if (config === null || config === void 0) {
|
|
17612
|
+
if (config == null) {
|
|
17447
17613
|
throw new TypeError("Client was passed a null or undefined query");
|
|
17448
|
-
}
|
|
17449
|
-
|
|
17614
|
+
}
|
|
17615
|
+
if (typeof config.submit === "function") {
|
|
17450
17616
|
result = query = config;
|
|
17451
|
-
if (
|
|
17452
|
-
|
|
17617
|
+
if (!query.callback) {
|
|
17618
|
+
if (typeof values === "function") {
|
|
17619
|
+
query.callback = values;
|
|
17620
|
+
} else if (callback) {
|
|
17621
|
+
query.callback = callback;
|
|
17622
|
+
}
|
|
17453
17623
|
}
|
|
17454
17624
|
} else {
|
|
17455
|
-
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
17456
17625
|
query = new Query2(config, values, callback);
|
|
17457
17626
|
if (!query.callback) {
|
|
17458
17627
|
result = new this._Promise((resolve, reject) => {
|
|
@@ -17461,11 +17630,15 @@ var require_client = __commonJS({
|
|
|
17461
17630
|
Error.captureStackTrace(err);
|
|
17462
17631
|
throw err;
|
|
17463
17632
|
});
|
|
17633
|
+
} else if (typeof query.callback !== "function") {
|
|
17634
|
+
throw new TypeError("callback is not a function");
|
|
17464
17635
|
}
|
|
17465
17636
|
}
|
|
17637
|
+
const readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
17466
17638
|
if (readTimeout) {
|
|
17467
|
-
queryCallback = query.callback
|
|
17468
|
-
|
|
17639
|
+
const queryCallback = query.callback || (() => {
|
|
17640
|
+
});
|
|
17641
|
+
const readTimeoutTimer = setTimeout(() => {
|
|
17469
17642
|
const error = new Error("Query read timeout");
|
|
17470
17643
|
process.nextTick(() => {
|
|
17471
17644
|
query.handleError(error, this.connection);
|
|
@@ -17473,9 +17646,9 @@ var require_client = __commonJS({
|
|
|
17473
17646
|
queryCallback(error);
|
|
17474
17647
|
query.callback = () => {
|
|
17475
17648
|
};
|
|
17476
|
-
const index = this.
|
|
17649
|
+
const index = this._queryQueue.indexOf(query);
|
|
17477
17650
|
if (index > -1) {
|
|
17478
|
-
this.
|
|
17651
|
+
this._queryQueue.splice(index, 1);
|
|
17479
17652
|
}
|
|
17480
17653
|
this._pulseQueryQueue();
|
|
17481
17654
|
}, readTimeout);
|
|
@@ -17502,7 +17675,10 @@ var require_client = __commonJS({
|
|
|
17502
17675
|
});
|
|
17503
17676
|
return result;
|
|
17504
17677
|
}
|
|
17505
|
-
this.
|
|
17678
|
+
if (this._queryQueue.length > 0) {
|
|
17679
|
+
queryQueueLengthDeprecationNotice();
|
|
17680
|
+
}
|
|
17681
|
+
this._queryQueue.push(query);
|
|
17506
17682
|
this._pulseQueryQueue();
|
|
17507
17683
|
return result;
|
|
17508
17684
|
}
|
|
@@ -17512,16 +17688,20 @@ var require_client = __commonJS({
|
|
|
17512
17688
|
unref() {
|
|
17513
17689
|
this.connection.unref();
|
|
17514
17690
|
}
|
|
17691
|
+
getTransactionStatus() {
|
|
17692
|
+
return this._txStatus;
|
|
17693
|
+
}
|
|
17515
17694
|
end(cb) {
|
|
17516
17695
|
this._ending = true;
|
|
17517
17696
|
if (!this.connection._connecting || this._ended) {
|
|
17518
17697
|
if (cb) {
|
|
17519
17698
|
cb();
|
|
17699
|
+
return;
|
|
17520
17700
|
} else {
|
|
17521
17701
|
return this._Promise.resolve();
|
|
17522
17702
|
}
|
|
17523
17703
|
}
|
|
17524
|
-
if (this.
|
|
17704
|
+
if (this._getActiveQuery() || !this._queryable) {
|
|
17525
17705
|
this.connection.stream.destroy();
|
|
17526
17706
|
} else {
|
|
17527
17707
|
this.connection.end();
|
|
@@ -17534,6 +17714,10 @@ var require_client = __commonJS({
|
|
|
17534
17714
|
});
|
|
17535
17715
|
}
|
|
17536
17716
|
}
|
|
17717
|
+
get queryQueue() {
|
|
17718
|
+
queryQueueDeprecationNotice();
|
|
17719
|
+
return this._queryQueue;
|
|
17720
|
+
}
|
|
17537
17721
|
};
|
|
17538
17722
|
Client2.Query = Query2;
|
|
17539
17723
|
module2.exports = Client2;
|
|
@@ -17632,6 +17816,13 @@ var require_pg_pool = __commonJS({
|
|
|
17632
17816
|
this.ending = false;
|
|
17633
17817
|
this.ended = false;
|
|
17634
17818
|
}
|
|
17819
|
+
_promiseTry(f) {
|
|
17820
|
+
const Promise2 = this.Promise;
|
|
17821
|
+
if (typeof Promise2.try === "function") {
|
|
17822
|
+
return Promise2.try(f);
|
|
17823
|
+
}
|
|
17824
|
+
return new Promise2((resolve) => resolve(f()));
|
|
17825
|
+
}
|
|
17635
17826
|
_isFull() {
|
|
17636
17827
|
return this._clients.length >= this.options.max;
|
|
17637
17828
|
}
|
|
@@ -17735,9 +17926,15 @@ var require_pg_pool = __commonJS({
|
|
|
17735
17926
|
let timeoutHit = false;
|
|
17736
17927
|
if (this.options.connectionTimeoutMillis) {
|
|
17737
17928
|
tid = setTimeout(() => {
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17929
|
+
if (client.connection) {
|
|
17930
|
+
this.log("ending client due to timeout");
|
|
17931
|
+
timeoutHit = true;
|
|
17932
|
+
client.connection.stream.destroy();
|
|
17933
|
+
} else if (!client.isConnected()) {
|
|
17934
|
+
this.log("ending client due to timeout");
|
|
17935
|
+
timeoutHit = true;
|
|
17936
|
+
client.end();
|
|
17937
|
+
}
|
|
17741
17938
|
}, this.options.connectionTimeoutMillis);
|
|
17742
17939
|
}
|
|
17743
17940
|
this.log("connecting new client");
|
|
@@ -17758,27 +17955,47 @@ var require_pg_pool = __commonJS({
|
|
|
17758
17955
|
}
|
|
17759
17956
|
} else {
|
|
17760
17957
|
this.log("new client connected");
|
|
17761
|
-
if (this.options.
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
this.
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17958
|
+
if (this.options.onConnect) {
|
|
17959
|
+
this._promiseTry(() => this.options.onConnect(client)).then(
|
|
17960
|
+
() => {
|
|
17961
|
+
this._afterConnect(client, pendingItem, idleListener);
|
|
17962
|
+
},
|
|
17963
|
+
(hookErr) => {
|
|
17964
|
+
this._clients = this._clients.filter((c) => c !== client);
|
|
17965
|
+
client.end(() => {
|
|
17966
|
+
this._pulseQueue();
|
|
17967
|
+
if (!pendingItem.timedOut) {
|
|
17968
|
+
pendingItem.callback(hookErr, void 0, NOOP);
|
|
17969
|
+
}
|
|
17970
|
+
});
|
|
17773
17971
|
}
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
client.once("end", () => clearTimeout(maxLifetimeTimeout));
|
|
17972
|
+
);
|
|
17973
|
+
return;
|
|
17777
17974
|
}
|
|
17778
|
-
return this.
|
|
17975
|
+
return this._afterConnect(client, pendingItem, idleListener);
|
|
17779
17976
|
}
|
|
17780
17977
|
});
|
|
17781
17978
|
}
|
|
17979
|
+
_afterConnect(client, pendingItem, idleListener) {
|
|
17980
|
+
if (this.options.maxLifetimeSeconds !== 0) {
|
|
17981
|
+
const maxLifetimeTimeout = setTimeout(() => {
|
|
17982
|
+
this.log("ending client due to expired lifetime");
|
|
17983
|
+
this._expired.add(client);
|
|
17984
|
+
const idleIndex = this._idle.findIndex((idleItem) => idleItem.client === client);
|
|
17985
|
+
if (idleIndex !== -1) {
|
|
17986
|
+
this._acquireClient(
|
|
17987
|
+
client,
|
|
17988
|
+
new PendingItem((err, client2, clientRelease) => clientRelease()),
|
|
17989
|
+
idleListener,
|
|
17990
|
+
false
|
|
17991
|
+
);
|
|
17992
|
+
}
|
|
17993
|
+
}, this.options.maxLifetimeSeconds * 1e3);
|
|
17994
|
+
maxLifetimeTimeout.unref();
|
|
17995
|
+
client.once("end", () => clearTimeout(maxLifetimeTimeout));
|
|
17996
|
+
}
|
|
17997
|
+
return this._acquireClient(client, pendingItem, idleListener, true);
|
|
17998
|
+
}
|
|
17782
17999
|
// acquire a client for a pending work item
|
|
17783
18000
|
_acquireClient(client, pendingItem, idleListener, isNew) {
|
|
17784
18001
|
if (isNew) {
|
|
@@ -17839,8 +18056,10 @@ var require_pg_pool = __commonJS({
|
|
|
17839
18056
|
let tid;
|
|
17840
18057
|
if (this.options.idleTimeoutMillis && this._isAboveMin()) {
|
|
17841
18058
|
tid = setTimeout(() => {
|
|
17842
|
-
this.
|
|
17843
|
-
|
|
18059
|
+
if (this._isAboveMin()) {
|
|
18060
|
+
this.log("remove idle client");
|
|
18061
|
+
this._remove(client, this._pulseQueue.bind(this));
|
|
18062
|
+
}
|
|
17844
18063
|
}, this.options.idleTimeoutMillis);
|
|
17845
18064
|
if (this.options.allowExitOnIdle) {
|
|
17846
18065
|
tid.unref();
|
|
@@ -18076,6 +18295,7 @@ var require_query2 = __commonJS({
|
|
|
18076
18295
|
var require_client2 = __commonJS({
|
|
18077
18296
|
"../../node_modules/pg/lib/native/client.js"(exports2, module2) {
|
|
18078
18297
|
"use strict";
|
|
18298
|
+
var nodeUtils = require("util");
|
|
18079
18299
|
var Native;
|
|
18080
18300
|
try {
|
|
18081
18301
|
Native = require("pg-native");
|
|
@@ -18087,6 +18307,11 @@ var require_client2 = __commonJS({
|
|
|
18087
18307
|
var util = require("util");
|
|
18088
18308
|
var ConnectionParameters = require_connection_parameters();
|
|
18089
18309
|
var NativeQuery = require_query2();
|
|
18310
|
+
var queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
18311
|
+
() => {
|
|
18312
|
+
},
|
|
18313
|
+
"Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead."
|
|
18314
|
+
);
|
|
18090
18315
|
var Client2 = module2.exports = function(config) {
|
|
18091
18316
|
EventEmitter.call(this);
|
|
18092
18317
|
config = config || {};
|
|
@@ -18159,7 +18384,7 @@ var require_client2 = __commonJS({
|
|
|
18159
18384
|
});
|
|
18160
18385
|
self.emit("connect");
|
|
18161
18386
|
self._pulseQueryQueue(true);
|
|
18162
|
-
cb();
|
|
18387
|
+
cb(null, this);
|
|
18163
18388
|
});
|
|
18164
18389
|
});
|
|
18165
18390
|
};
|
|
@@ -18173,7 +18398,7 @@ var require_client2 = __commonJS({
|
|
|
18173
18398
|
if (error) {
|
|
18174
18399
|
reject(error);
|
|
18175
18400
|
} else {
|
|
18176
|
-
resolve();
|
|
18401
|
+
resolve(this);
|
|
18177
18402
|
}
|
|
18178
18403
|
});
|
|
18179
18404
|
});
|
|
@@ -18208,7 +18433,8 @@ var require_client2 = __commonJS({
|
|
|
18208
18433
|
}
|
|
18209
18434
|
}
|
|
18210
18435
|
if (readTimeout) {
|
|
18211
|
-
queryCallback = query.callback
|
|
18436
|
+
queryCallback = query.callback || (() => {
|
|
18437
|
+
});
|
|
18212
18438
|
readTimeoutTimer = setTimeout(() => {
|
|
18213
18439
|
const error = new Error("Query read timeout");
|
|
18214
18440
|
process.nextTick(() => {
|
|
@@ -18242,6 +18468,9 @@ var require_client2 = __commonJS({
|
|
|
18242
18468
|
});
|
|
18243
18469
|
return result;
|
|
18244
18470
|
}
|
|
18471
|
+
if (this._queryQueue.length > 0) {
|
|
18472
|
+
queryQueueLengthDeprecationNotice();
|
|
18473
|
+
}
|
|
18245
18474
|
this._queryQueue.push(query);
|
|
18246
18475
|
this._pulseQueryQueue();
|
|
18247
18476
|
return result;
|
|
@@ -18249,8 +18478,11 @@ var require_client2 = __commonJS({
|
|
|
18249
18478
|
Client2.prototype.end = function(cb) {
|
|
18250
18479
|
const self = this;
|
|
18251
18480
|
this._ending = true;
|
|
18252
|
-
if (!this._connected) {
|
|
18253
|
-
this.once("connect",
|
|
18481
|
+
if (this._connecting && !this._connected) {
|
|
18482
|
+
this.once("connect", () => {
|
|
18483
|
+
this.end(() => {
|
|
18484
|
+
});
|
|
18485
|
+
});
|
|
18254
18486
|
}
|
|
18255
18487
|
let result;
|
|
18256
18488
|
if (!cb) {
|
|
@@ -18259,6 +18491,7 @@ var require_client2 = __commonJS({
|
|
|
18259
18491
|
});
|
|
18260
18492
|
}
|
|
18261
18493
|
this.native.end(function() {
|
|
18494
|
+
self._connected = false;
|
|
18262
18495
|
self._errorAllQueries(new Error("Connection terminated"));
|
|
18263
18496
|
process.nextTick(() => {
|
|
18264
18497
|
self.emit("end");
|
|
@@ -18309,6 +18542,12 @@ var require_client2 = __commonJS({
|
|
|
18309
18542
|
Client2.prototype.getTypeParser = function(oid, format2) {
|
|
18310
18543
|
return this._types.getTypeParser(oid, format2);
|
|
18311
18544
|
};
|
|
18545
|
+
Client2.prototype.isConnected = function() {
|
|
18546
|
+
return this._connected;
|
|
18547
|
+
};
|
|
18548
|
+
Client2.prototype.getTransactionStatus = function() {
|
|
18549
|
+
return this.native.getTransactionStatus();
|
|
18550
|
+
};
|
|
18312
18551
|
}
|
|
18313
18552
|
});
|
|
18314
18553
|
|
|
@@ -18340,9 +18579,9 @@ var require_lib2 = __commonJS({
|
|
|
18340
18579
|
}
|
|
18341
18580
|
};
|
|
18342
18581
|
};
|
|
18343
|
-
var PG = function(
|
|
18582
|
+
var PG = function(clientConstructor2) {
|
|
18344
18583
|
this.defaults = defaults2;
|
|
18345
|
-
this.Client =
|
|
18584
|
+
this.Client = clientConstructor2;
|
|
18346
18585
|
this.Query = this.Client.Query;
|
|
18347
18586
|
this.Pool = poolFactory(this.Client);
|
|
18348
18587
|
this._pools = [];
|
|
@@ -18355,29 +18594,34 @@ var require_lib2 = __commonJS({
|
|
|
18355
18594
|
this.Result = Result2;
|
|
18356
18595
|
this.utils = utils;
|
|
18357
18596
|
};
|
|
18358
|
-
|
|
18359
|
-
|
|
18360
|
-
|
|
18361
|
-
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18370
|
-
|
|
18371
|
-
|
|
18372
|
-
|
|
18597
|
+
var clientConstructor = Client2;
|
|
18598
|
+
var forceNative = false;
|
|
18599
|
+
try {
|
|
18600
|
+
forceNative = !!process.env.NODE_PG_FORCE_NATIVE;
|
|
18601
|
+
} catch {
|
|
18602
|
+
}
|
|
18603
|
+
if (forceNative) {
|
|
18604
|
+
clientConstructor = require_native();
|
|
18605
|
+
}
|
|
18606
|
+
module2.exports = new PG(clientConstructor);
|
|
18607
|
+
Object.defineProperty(module2.exports, "native", {
|
|
18608
|
+
configurable: true,
|
|
18609
|
+
enumerable: false,
|
|
18610
|
+
get() {
|
|
18611
|
+
let native = null;
|
|
18612
|
+
try {
|
|
18613
|
+
native = new PG(require_native());
|
|
18614
|
+
} catch (err) {
|
|
18615
|
+
if (err.code !== "MODULE_NOT_FOUND") {
|
|
18616
|
+
throw err;
|
|
18373
18617
|
}
|
|
18374
|
-
Object.defineProperty(module2.exports, "native", {
|
|
18375
|
-
value: native
|
|
18376
|
-
});
|
|
18377
|
-
return native;
|
|
18378
18618
|
}
|
|
18379
|
-
|
|
18380
|
-
|
|
18619
|
+
Object.defineProperty(module2.exports, "native", {
|
|
18620
|
+
value: native
|
|
18621
|
+
});
|
|
18622
|
+
return native;
|
|
18623
|
+
}
|
|
18624
|
+
});
|
|
18381
18625
|
}
|
|
18382
18626
|
});
|
|
18383
18627
|
|