@squiz/db-lib 1.11.0-alpha.1 → 1.12.0-alpha.1

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/lib/index.js CHANGED
@@ -1019,6 +1019,9 @@ var require_defaults = __commonJS({
1019
1019
  // max milliseconds any query using this connection will execute for before timing out in error.
1020
1020
  // false=unlimited
1021
1021
  statement_timeout: false,
1022
+ // Abort any statement that waits longer than the specified duration in milliseconds while attempting to acquire a lock.
1023
+ // false=unlimited
1024
+ lock_timeout: false,
1022
1025
  // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds
1023
1026
  // false=unlimited
1024
1027
  idle_in_transaction_session_timeout: false,
@@ -1200,6 +1203,9 @@ var require_sasl = __commonJS({
1200
1203
  if (typeof password !== "string") {
1201
1204
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string");
1202
1205
  }
1206
+ if (password === "") {
1207
+ throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string");
1208
+ }
1203
1209
  if (typeof serverData !== "string") {
1204
1210
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string");
1205
1211
  }
@@ -1210,7 +1216,7 @@ var require_sasl = __commonJS({
1210
1216
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");
1211
1217
  }
1212
1218
  var saltBytes = Buffer.from(sv.salt, "base64");
1213
- var saltedPassword = Hi(password, saltBytes, sv.iteration);
1219
+ var saltedPassword = crypto4.pbkdf2Sync(password, saltBytes, sv.iteration, 32, "sha256");
1214
1220
  var clientKey = hmacSha256(saltedPassword, "Client Key");
1215
1221
  var storedKey = sha256(clientKey);
1216
1222
  var clientFirstMessageBare = "n=*,r=" + session.clientNonce;
@@ -1322,15 +1328,6 @@ var require_sasl = __commonJS({
1322
1328
  function hmacSha256(key, msg) {
1323
1329
  return crypto4.createHmac("sha256", key).update(msg).digest();
1324
1330
  }
1325
- function Hi(password, saltBytes, iterations) {
1326
- var ui1 = hmacSha256(password, Buffer.concat([saltBytes, Buffer.from([0, 0, 0, 1])]));
1327
- var ui = ui1;
1328
- for (var i = 0; i < iterations - 1; i++) {
1329
- ui1 = hmacSha256(password, ui1);
1330
- ui = xorBuffers(ui, ui1);
1331
- }
1332
- return ui;
1333
- }
1334
1331
  module2.exports = {
1335
1332
  startSession,
1336
1333
  continueSession,
@@ -1833,6 +1830,7 @@ var require_connection_parameters = __commonJS({
1833
1830
  this.application_name = val("application_name", config, "PGAPPNAME");
1834
1831
  this.fallback_application_name = val("fallback_application_name", config, false);
1835
1832
  this.statement_timeout = val("statement_timeout", config, false);
1833
+ this.lock_timeout = val("lock_timeout", config, false);
1836
1834
  this.idle_in_transaction_session_timeout = val("idle_in_transaction_session_timeout", config, false);
1837
1835
  this.query_timeout = val("query_timeout", config, false);
1838
1836
  if (config.connectionTimeoutMillis === void 0) {
@@ -2085,7 +2083,13 @@ var require_query = __commonJS({
2085
2083
  return this.handleError(this._canceledDueToError, con);
2086
2084
  }
2087
2085
  if (this.callback) {
2088
- this.callback(null, this._results);
2086
+ try {
2087
+ this.callback(null, this._results);
2088
+ } catch (err) {
2089
+ process.nextTick(() => {
2090
+ throw err;
2091
+ });
2092
+ }
2089
2093
  }
2090
2094
  this.emit("end", this._results);
2091
2095
  }
@@ -3014,6 +3018,9 @@ var require_connection = __commonJS({
3014
3018
  super();
3015
3019
  config = config || {};
3016
3020
  this.stream = config.stream || new net.Socket();
3021
+ if (typeof this.stream === "function") {
3022
+ this.stream = this.stream(config);
3023
+ }
3017
3024
  this._keepAlive = config.keepAlive;
3018
3025
  this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis;
3019
3026
  this.lastBuffer = false;
@@ -3145,7 +3152,6 @@ var require_connection = __commonJS({
3145
3152
  }
3146
3153
  sync() {
3147
3154
  this._ending = true;
3148
- this._send(flushBuffer);
3149
3155
  this._send(syncBuffer);
3150
3156
  }
3151
3157
  ref() {
@@ -3189,7 +3195,6 @@ var require_client = __commonJS({
3189
3195
  "../../node_modules/pg/lib/client.js"(exports, module2) {
3190
3196
  "use strict";
3191
3197
  var EventEmitter = require("events").EventEmitter;
3192
- var util = require("util");
3193
3198
  var utils = require_utils();
3194
3199
  var sasl = require_sasl();
3195
3200
  var pgPass = require_lib();
@@ -3387,17 +3392,29 @@ var require_client = __commonJS({
3387
3392
  }
3388
3393
  _handleAuthSASL(msg) {
3389
3394
  this._checkPgPass(() => {
3390
- this.saslSession = sasl.startSession(msg.mechanisms);
3391
- this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
3395
+ try {
3396
+ this.saslSession = sasl.startSession(msg.mechanisms);
3397
+ this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
3398
+ } catch (err) {
3399
+ this.connection.emit("error", err);
3400
+ }
3392
3401
  });
3393
3402
  }
3394
3403
  _handleAuthSASLContinue(msg) {
3395
- sasl.continueSession(this.saslSession, this.password, msg.data);
3396
- this.connection.sendSCRAMClientFinalMessage(this.saslSession.response);
3404
+ try {
3405
+ sasl.continueSession(this.saslSession, this.password, msg.data);
3406
+ this.connection.sendSCRAMClientFinalMessage(this.saslSession.response);
3407
+ } catch (err) {
3408
+ this.connection.emit("error", err);
3409
+ }
3397
3410
  }
3398
3411
  _handleAuthSASLFinal(msg) {
3399
- sasl.finalizeSession(this.saslSession, msg.data);
3400
- this.saslSession = null;
3412
+ try {
3413
+ sasl.finalizeSession(this.saslSession, msg.data);
3414
+ this.saslSession = null;
3415
+ } catch (err) {
3416
+ this.connection.emit("error", err);
3417
+ }
3401
3418
  }
3402
3419
  _handleBackendKeyData(msg) {
3403
3420
  this.processID = msg.processID;
@@ -3507,6 +3524,9 @@ var require_client = __commonJS({
3507
3524
  if (params.statement_timeout) {
3508
3525
  data.statement_timeout = String(parseInt(params.statement_timeout, 10));
3509
3526
  }
3527
+ if (params.lock_timeout) {
3528
+ data.lock_timeout = String(parseInt(params.lock_timeout, 10));
3529
+ }
3510
3530
  if (params.idle_in_transaction_session_timeout) {
3511
3531
  data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10));
3512
3532
  }
@@ -4060,69 +4080,6 @@ var require_pg_pool = __commonJS({
4060
4080
  }
4061
4081
  });
4062
4082
 
4063
- // ../../node_modules/pg/package.json
4064
- var require_package = __commonJS({
4065
- "../../node_modules/pg/package.json"(exports, module2) {
4066
- module2.exports = {
4067
- name: "pg",
4068
- version: "8.7.3",
4069
- description: "PostgreSQL client - pure javascript & libpq with the same API",
4070
- keywords: [
4071
- "database",
4072
- "libpq",
4073
- "pg",
4074
- "postgre",
4075
- "postgres",
4076
- "postgresql",
4077
- "rdbms"
4078
- ],
4079
- homepage: "https://github.com/brianc/node-postgres",
4080
- repository: {
4081
- type: "git",
4082
- url: "git://github.com/brianc/node-postgres.git",
4083
- directory: "packages/pg"
4084
- },
4085
- author: "Brian Carlson <brian.m.carlson@gmail.com>",
4086
- main: "./lib",
4087
- dependencies: {
4088
- "buffer-writer": "2.0.0",
4089
- "packet-reader": "1.0.0",
4090
- "pg-connection-string": "^2.5.0",
4091
- "pg-pool": "^3.5.1",
4092
- "pg-protocol": "^1.5.0",
4093
- "pg-types": "^2.1.0",
4094
- pgpass: "1.x"
4095
- },
4096
- devDependencies: {
4097
- async: "0.9.0",
4098
- bluebird: "3.5.2",
4099
- co: "4.6.0",
4100
- "pg-copy-streams": "0.3.0"
4101
- },
4102
- peerDependencies: {
4103
- "pg-native": ">=2.0.0"
4104
- },
4105
- peerDependenciesMeta: {
4106
- "pg-native": {
4107
- optional: true
4108
- }
4109
- },
4110
- scripts: {
4111
- test: "make test-all"
4112
- },
4113
- files: [
4114
- "lib",
4115
- "SPONSORS.md"
4116
- ],
4117
- license: "MIT",
4118
- engines: {
4119
- node: ">= 8.0.0"
4120
- },
4121
- gitHead: "4fa7ee891a456168a75695ac026792136f16577f"
4122
- };
4123
- }
4124
- });
4125
-
4126
4083
  // ../../node_modules/pg/lib/native/query.js
4127
4084
  var require_query2 = __commonJS({
4128
4085
  "../../node_modules/pg/lib/native/query.js"(exports, module2) {
@@ -4271,7 +4228,6 @@ var require_client2 = __commonJS({
4271
4228
  "use strict";
4272
4229
  var Native = require("pg-native");
4273
4230
  var TypeOverrides = require_type_overrides();
4274
- var pkg = require_package();
4275
4231
  var EventEmitter = require("events").EventEmitter;
4276
4232
  var util = require("util");
4277
4233
  var ConnectionParameters = require_connection_parameters();
@@ -6597,7 +6553,7 @@ var require_ms2 = __commonJS({
6597
6553
  var format = require_format();
6598
6554
  var ms = require_ms();
6599
6555
  module2.exports = format((info) => {
6600
- const curr = +new Date();
6556
+ const curr = +/* @__PURE__ */ new Date();
6601
6557
  exports.diff = curr - (exports.prevTime || curr);
6602
6558
  exports.prevTime = curr;
6603
6559
  info.ms = `+${ms(exports.diff)}`;
@@ -6969,7 +6925,7 @@ var require_fecha_umd = __commonJS({
6969
6925
  "year",
6970
6926
  twoDigits,
6971
6927
  function(v) {
6972
- var now = new Date();
6928
+ var now = /* @__PURE__ */ new Date();
6973
6929
  var cent = +("" + now.getFullYear()).substr(0, 2);
6974
6930
  return +("" + (+v > 68 ? cent - 1 : cent) + v);
6975
6931
  }
@@ -7054,7 +7010,7 @@ var require_fecha_umd = __commonJS({
7054
7010
  if (dateStr.length > 1e3) {
7055
7011
  return null;
7056
7012
  }
7057
- var today = new Date();
7013
+ var today = /* @__PURE__ */ new Date();
7058
7014
  var dateInfo = {
7059
7015
  year: today.getFullYear(),
7060
7016
  month: 0,
@@ -7163,10 +7119,10 @@ var require_timestamp = __commonJS({
7163
7119
  var format = require_format();
7164
7120
  module2.exports = format((info, opts = {}) => {
7165
7121
  if (opts.format) {
7166
- info.timestamp = typeof opts.format === "function" ? opts.format() : fecha.format(new Date(), opts.format);
7122
+ info.timestamp = typeof opts.format === "function" ? opts.format() : fecha.format(/* @__PURE__ */ new Date(), opts.format);
7167
7123
  }
7168
7124
  if (!info.timestamp) {
7169
- info.timestamp = new Date().toISOString();
7125
+ info.timestamp = (/* @__PURE__ */ new Date()).toISOString();
7170
7126
  }
7171
7127
  if (opts.alias) {
7172
7128
  info[opts.alias] = info.timestamp;
@@ -7318,7 +7274,7 @@ var require_common = __commonJS({
7318
7274
  });
7319
7275
 
7320
7276
  // ../../node_modules/winston/package.json
7321
- var require_package2 = __commonJS({
7277
+ var require_package = __commonJS({
7322
7278
  "../../node_modules/winston/package.json"(exports, module2) {
7323
7279
  module2.exports = {
7324
7280
  name: "winston",
@@ -13509,7 +13465,7 @@ var require_file = __commonJS({
13509
13465
  options2 = options2 || {};
13510
13466
  options2.rows = options2.rows || options2.limit || 10;
13511
13467
  options2.start = options2.start || 0;
13512
- options2.until = options2.until || new Date();
13468
+ options2.until = options2.until || /* @__PURE__ */ new Date();
13513
13469
  if (typeof options2.until !== "object") {
13514
13470
  options2.until = new Date(options2.until);
13515
13471
  }
@@ -14513,7 +14469,7 @@ var require_exception_handler = __commonJS({
14513
14469
  ].join("\n"),
14514
14470
  stack: err.stack,
14515
14471
  exception: true,
14516
- date: new Date().toString(),
14472
+ date: (/* @__PURE__ */ new Date()).toString(),
14517
14473
  process: this.getProcessInfo(),
14518
14474
  os: this.getOsInfo(),
14519
14475
  trace: this.getTrace(err)
@@ -14713,7 +14669,7 @@ var require_rejection_handler = __commonJS({
14713
14669
  ].join("\n"),
14714
14670
  stack: err && err.stack,
14715
14671
  exception: true,
14716
- date: new Date().toString(),
14672
+ date: (/* @__PURE__ */ new Date()).toString(),
14717
14673
  process: this.getProcessInfo(),
14718
14674
  os: this.getOsInfo(),
14719
14675
  trace: this.getTrace(err)
@@ -15560,7 +15516,7 @@ var require_winston = __commonJS({
15560
15516
  "use strict";
15561
15517
  var logform = require_logform();
15562
15518
  var { warn } = require_common();
15563
- exports.version = require_package2().version;
15519
+ exports.version = require_package().version;
15564
15520
  exports.transports = require_transports();
15565
15521
  exports.config = require_config2();
15566
15522
  exports.addColors = logform.levels;
@@ -16813,7 +16769,7 @@ var require_date_utils = __commonJS({
16813
16769
  return new Date(Date.UTC(year, adjustedMonth, day, parseDateValue(time.hours, "hour", 0, 23), parseDateValue(time.minutes, "minute", 0, 59), parseDateValue(time.seconds, "seconds", 0, 60), parseMilliseconds(time.fractionalMilliseconds)));
16814
16770
  };
16815
16771
  var parseTwoDigitYear = (value) => {
16816
- const thisYear = new Date().getUTCFullYear();
16772
+ const thisYear = (/* @__PURE__ */ new Date()).getUTCFullYear();
16817
16773
  const valueInThisCentury = Math.floor(thisYear / 100) * 100 + (0, parse_utils_1.strictParseShort)(stripLeadingZeroes(value));
16818
16774
  if (valueInThisCentury < thisYear) {
16819
16775
  return valueInThisCentury + 100;
@@ -16822,7 +16778,7 @@ var require_date_utils = __commonJS({
16822
16778
  };
16823
16779
  var FIFTY_YEARS_IN_MILLIS = 50 * 365 * 24 * 60 * 60 * 1e3;
16824
16780
  var adjustRfc850Year = (input) => {
16825
- if (input.getTime() - new Date().getTime() > FIFTY_YEARS_IN_MILLIS) {
16781
+ if (input.getTime() - (/* @__PURE__ */ new Date()).getTime() > FIFTY_YEARS_IN_MILLIS) {
16826
16782
  return new Date(Date.UTC(input.getUTCFullYear() - 100, input.getUTCMonth(), input.getUTCDate(), input.getUTCHours(), input.getUTCMinutes(), input.getUTCSeconds(), input.getUTCMilliseconds()));
16827
16783
  }
16828
16784
  return input;
@@ -22770,7 +22726,7 @@ var require_SignatureV4 = __commonJS({
22770
22726
  this.credentialProvider = (0, util_middleware_1.normalizeProvider)(credentials);
22771
22727
  }
22772
22728
  async presign(originalRequest, options = {}) {
22773
- const { signingDate = new Date(), expiresIn = 3600, unsignableHeaders, unhoistableHeaders, signableHeaders, signingRegion, signingService } = options;
22729
+ const { signingDate = /* @__PURE__ */ new Date(), expiresIn = 3600, unsignableHeaders, unhoistableHeaders, signableHeaders, signingRegion, signingService } = options;
22774
22730
  const credentials = await this.credentialProvider();
22775
22731
  this.validateResolvedCredentials(credentials);
22776
22732
  const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : await this.regionProvider();
@@ -22801,7 +22757,7 @@ var require_SignatureV4 = __commonJS({
22801
22757
  return this.signRequest(toSign, options);
22802
22758
  }
22803
22759
  }
22804
- async signEvent({ headers, payload }, { signingDate = new Date(), priorSignature, signingRegion, signingService }) {
22760
+ async signEvent({ headers, payload }, { signingDate = /* @__PURE__ */ new Date(), priorSignature, signingRegion, signingService }) {
22805
22761
  const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : await this.regionProvider();
22806
22762
  const { shortDate, longDate } = formatDate(signingDate);
22807
22763
  const scope = (0, credentialDerivation_1.createScope)(shortDate, region, signingService !== null && signingService !== void 0 ? signingService : this.service);
@@ -22819,7 +22775,7 @@ var require_SignatureV4 = __commonJS({
22819
22775
  ].join("\n");
22820
22776
  return this.signString(stringToSign, { signingDate, signingRegion: region, signingService });
22821
22777
  }
22822
- async signString(stringToSign, { signingDate = new Date(), signingRegion, signingService } = {}) {
22778
+ async signString(stringToSign, { signingDate = /* @__PURE__ */ new Date(), signingRegion, signingService } = {}) {
22823
22779
  const credentials = await this.credentialProvider();
22824
22780
  this.validateResolvedCredentials(credentials);
22825
22781
  const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : await this.regionProvider();
@@ -22828,7 +22784,7 @@ var require_SignatureV4 = __commonJS({
22828
22784
  hash.update(stringToSign);
22829
22785
  return (0, util_hex_encoding_1.toHex)(await hash.digest());
22830
22786
  }
22831
- async signRequest(requestToSign, { signingDate = new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService } = {}) {
22787
+ async signRequest(requestToSign, { signingDate = /* @__PURE__ */ new Date(), signableHeaders, unsignableHeaders, signingRegion, signingService } = {}) {
22832
22788
  const credentials = await this.credentialProvider();
22833
22789
  this.validateResolvedCredentials(credentials);
22834
22790
  const region = signingRegion !== null && signingRegion !== void 0 ? signingRegion : await this.regionProvider();
@@ -23243,7 +23199,7 @@ var require_dist_cjs20 = __commonJS({
23243
23199
  });
23244
23200
 
23245
23201
  // ../../node_modules/@aws-sdk/client-secrets-manager/package.json
23246
- var require_package3 = __commonJS({
23202
+ var require_package2 = __commonJS({
23247
23203
  "../../node_modules/@aws-sdk/client-secrets-manager/package.json"(exports, module2) {
23248
23204
  module2.exports = {
23249
23205
  name: "@aws-sdk/client-secrets-manager",
@@ -26426,7 +26382,7 @@ var require_dist_cjs21 = __commonJS({
26426
26382
  });
26427
26383
 
26428
26384
  // ../../node_modules/@aws-sdk/client-sts/package.json
26429
- var require_package4 = __commonJS({
26385
+ var require_package3 = __commonJS({
26430
26386
  "../../node_modules/@aws-sdk/client-sts/package.json"(exports, module2) {
26431
26387
  module2.exports = {
26432
26388
  name: "@aws-sdk/client-sts",
@@ -28310,7 +28266,7 @@ var require_LogoutCommand = __commonJS({
28310
28266
  });
28311
28267
 
28312
28268
  // ../../node_modules/@aws-sdk/client-sso/package.json
28313
- var require_package5 = __commonJS({
28269
+ var require_package4 = __commonJS({
28314
28270
  "../../node_modules/@aws-sdk/client-sso/package.json"(exports, module2) {
28315
28271
  module2.exports = {
28316
28272
  name: "@aws-sdk/client-sso",
@@ -29526,7 +29482,7 @@ var require_runtimeConfig = __commonJS({
29526
29482
  Object.defineProperty(exports, "__esModule", { value: true });
29527
29483
  exports.getRuntimeConfig = void 0;
29528
29484
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
29529
- var package_json_1 = tslib_1.__importDefault(require_package5());
29485
+ var package_json_1 = tslib_1.__importDefault(require_package4());
29530
29486
  var config_resolver_1 = require_dist_cjs7();
29531
29487
  var hash_node_1 = require_dist_cjs29();
29532
29488
  var middleware_retry_1 = require_dist_cjs13();
@@ -30148,7 +30104,7 @@ var require_getValidatedProcessCredentials = __commonJS({
30148
30104
  throw Error(`Profile ${profileName} credential_process returned invalid credentials.`);
30149
30105
  }
30150
30106
  if (data.Expiration) {
30151
- const currentTime = new Date();
30107
+ const currentTime = /* @__PURE__ */ new Date();
30152
30108
  const expireTime = new Date(data.Expiration);
30153
30109
  if (expireTime < currentTime) {
30154
30110
  throw Error(`Profile ${profileName} credential_process returned expired credentials.`);
@@ -30516,7 +30472,7 @@ var require_runtimeConfig2 = __commonJS({
30516
30472
  Object.defineProperty(exports, "__esModule", { value: true });
30517
30473
  exports.getRuntimeConfig = void 0;
30518
30474
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
30519
- var package_json_1 = tslib_1.__importDefault(require_package4());
30475
+ var package_json_1 = tslib_1.__importDefault(require_package3());
30520
30476
  var defaultStsRoleAssumers_1 = require_defaultStsRoleAssumers();
30521
30477
  var config_resolver_1 = require_dist_cjs7();
30522
30478
  var credential_provider_node_1 = require_dist_cjs42();
@@ -31036,7 +30992,7 @@ var require_runtimeConfig3 = __commonJS({
31036
30992
  Object.defineProperty(exports, "__esModule", { value: true });
31037
30993
  exports.getRuntimeConfig = void 0;
31038
30994
  var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
31039
- var package_json_1 = tslib_1.__importDefault(require_package3());
30995
+ var package_json_1 = tslib_1.__importDefault(require_package2());
31040
30996
  var client_sts_1 = require_dist_cjs43();
31041
30997
  var config_resolver_1 = require_dist_cjs7();
31042
30998
  var credential_provider_node_1 = require_dist_cjs42();