@hasna/shortlinks 0.2.0 → 0.2.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.
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => {
33
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
34
  var __require = import.meta.require;
35
35
 
36
- // node_modules/postgres-array/index.js
36
+ // node_modules/.pnpm/postgres-array@2.0.0/node_modules/postgres-array/index.js
37
37
  var require_postgres_array = __commonJS((exports) => {
38
38
  exports.parse = function(source, transform) {
39
39
  return new ArrayParser(source, transform).parse();
@@ -129,7 +129,7 @@ var require_postgres_array = __commonJS((exports) => {
129
129
  }
130
130
  });
131
131
 
132
- // node_modules/pg-types/lib/arrayParser.js
132
+ // node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/arrayParser.js
133
133
  var require_arrayParser = __commonJS((exports, module) => {
134
134
  var array = require_postgres_array();
135
135
  module.exports = {
@@ -143,7 +143,7 @@ var require_arrayParser = __commonJS((exports, module) => {
143
143
  };
144
144
  });
145
145
 
146
- // node_modules/postgres-date/index.js
146
+ // node_modules/.pnpm/postgres-date@1.0.7/node_modules/postgres-date/index.js
147
147
  var require_postgres_date = __commonJS((exports, module) => {
148
148
  var DATE_TIME = /(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/;
149
149
  var DATE = /^(\d{1,})-(\d{2})-(\d{2})( BC)?$/;
@@ -228,7 +228,7 @@ var require_postgres_date = __commonJS((exports, module) => {
228
228
  }
229
229
  });
230
230
 
231
- // node_modules/xtend/mutable.js
231
+ // node_modules/.pnpm/xtend@4.0.2/node_modules/xtend/mutable.js
232
232
  var require_mutable = __commonJS((exports, module) => {
233
233
  module.exports = extend;
234
234
  var hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -245,7 +245,7 @@ var require_mutable = __commonJS((exports, module) => {
245
245
  }
246
246
  });
247
247
 
248
- // node_modules/postgres-interval/index.js
248
+ // node_modules/.pnpm/postgres-interval@1.2.0/node_modules/postgres-interval/index.js
249
249
  var require_postgres_interval = __commonJS((exports, module) => {
250
250
  var extend = require_mutable();
251
251
  module.exports = PostgresInterval;
@@ -337,7 +337,7 @@ var require_postgres_interval = __commonJS((exports, module) => {
337
337
  }
338
338
  });
339
339
 
340
- // node_modules/postgres-bytea/index.js
340
+ // node_modules/.pnpm/postgres-bytea@1.0.1/node_modules/postgres-bytea/index.js
341
341
  var require_postgres_bytea = __commonJS((exports, module) => {
342
342
  var bufferFrom = Buffer.from || Buffer;
343
343
  module.exports = function parseBytea(input) {
@@ -370,7 +370,7 @@ var require_postgres_bytea = __commonJS((exports, module) => {
370
370
  };
371
371
  });
372
372
 
373
- // node_modules/pg-types/lib/textParsers.js
373
+ // node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/textParsers.js
374
374
  var require_textParsers = __commonJS((exports, module) => {
375
375
  var array = require_postgres_array();
376
376
  var arrayParser = require_arrayParser();
@@ -573,7 +573,7 @@ var require_textParsers = __commonJS((exports, module) => {
573
573
  };
574
574
  });
575
575
 
576
- // node_modules/pg-int8/index.js
576
+ // node_modules/.pnpm/pg-int8@1.0.1/node_modules/pg-int8/index.js
577
577
  var require_pg_int8 = __commonJS((exports, module) => {
578
578
  var BASE = 1e6;
579
579
  function readInt8(buffer) {
@@ -650,7 +650,7 @@ var require_pg_int8 = __commonJS((exports, module) => {
650
650
  module.exports = readInt8;
651
651
  });
652
652
 
653
- // node_modules/pg-types/lib/binaryParsers.js
653
+ // node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/binaryParsers.js
654
654
  var require_binaryParsers = __commonJS((exports, module) => {
655
655
  var parseInt64 = require_pg_int8();
656
656
  var parseBits = function(data, bits, offset, invert, callback) {
@@ -849,7 +849,7 @@ var require_binaryParsers = __commonJS((exports, module) => {
849
849
  };
850
850
  });
851
851
 
852
- // node_modules/pg-types/lib/builtins.js
852
+ // node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/lib/builtins.js
853
853
  var require_builtins = __commonJS((exports, module) => {
854
854
  module.exports = {
855
855
  BOOL: 16,
@@ -915,7 +915,7 @@ var require_builtins = __commonJS((exports, module) => {
915
915
  };
916
916
  });
917
917
 
918
- // node_modules/pg-types/index.js
918
+ // node_modules/.pnpm/pg-types@2.2.0/node_modules/pg-types/index.js
919
919
  var require_pg_types = __commonJS((exports) => {
920
920
  var textParsers = require_textParsers();
921
921
  var binaryParsers = require_binaryParsers();
@@ -954,7 +954,7 @@ var require_pg_types = __commonJS((exports) => {
954
954
  });
955
955
  });
956
956
 
957
- // node_modules/pg/lib/defaults.js
957
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/defaults.js
958
958
  var require_defaults = __commonJS((exports, module) => {
959
959
  var user;
960
960
  try {
@@ -973,6 +973,7 @@ var require_defaults = __commonJS((exports, module) => {
973
973
  idleTimeoutMillis: 30000,
974
974
  client_encoding: "",
975
975
  ssl: false,
976
+ sslnegotiation: undefined,
976
977
  application_name: undefined,
977
978
  fallback_application_name: undefined,
978
979
  options: undefined,
@@ -994,11 +995,10 @@ var require_defaults = __commonJS((exports, module) => {
994
995
  });
995
996
  });
996
997
 
997
- // node_modules/pg/lib/utils.js
998
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/utils.js
998
999
  var require_utils = __commonJS((exports, module) => {
999
1000
  var defaults = require_defaults();
1000
- var util = __require("util");
1001
- var { isDate } = util.types || util;
1001
+ var { isDate } = __require("util/types");
1002
1002
  function escapeElement(elementRepresentation) {
1003
1003
  const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
1004
1004
  return '"' + escaped + '"';
@@ -1007,28 +1007,23 @@ var require_utils = __commonJS((exports, module) => {
1007
1007
  let result = "{";
1008
1008
  for (let i = 0;i < val.length; i++) {
1009
1009
  if (i > 0) {
1010
- result = result + ",";
1011
- }
1012
- if (val[i] === null || typeof val[i] === "undefined") {
1013
- result = result + "NULL";
1014
- } else if (Array.isArray(val[i])) {
1015
- result = result + arrayString(val[i]);
1016
- } else if (ArrayBuffer.isView(val[i])) {
1017
- let item = val[i];
1010
+ result += ",";
1011
+ }
1012
+ let item = val[i];
1013
+ if (item == null) {
1014
+ result += "NULL";
1015
+ } else if (Array.isArray(item)) {
1016
+ result += arrayString(item);
1017
+ } else if (ArrayBuffer.isView(item)) {
1018
1018
  if (!(item instanceof Buffer)) {
1019
- const buf = Buffer.from(item.buffer, item.byteOffset, item.byteLength);
1020
- if (buf.length === item.byteLength) {
1021
- item = buf;
1022
- } else {
1023
- item = buf.slice(item.byteOffset, item.byteOffset + item.byteLength);
1024
- }
1019
+ item = Buffer.from(item.buffer, item.byteOffset, item.byteLength);
1025
1020
  }
1026
1021
  result += "\\\\x" + item.toString("hex");
1027
1022
  } else {
1028
- result += escapeElement(prepareValue(val[i]));
1023
+ result += escapeElement(prepareValue(item));
1029
1024
  }
1030
1025
  }
1031
- result = result + "}";
1026
+ result += "}";
1032
1027
  return result;
1033
1028
  }
1034
1029
  var prepareValue = function(val, seen) {
@@ -1040,11 +1035,7 @@ var require_utils = __commonJS((exports, module) => {
1040
1035
  return val;
1041
1036
  }
1042
1037
  if (ArrayBuffer.isView(val)) {
1043
- const buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength);
1044
- if (buf.length === val.byteLength) {
1045
- return buf;
1046
- }
1047
- return buf.slice(val.byteOffset, val.byteOffset + val.byteLength);
1038
+ return Buffer.from(val.buffer, val.byteOffset, val.byteLength);
1048
1039
  }
1049
1040
  if (isDate(val)) {
1050
1041
  if (defaults.parseInputDatesAsUTC) {
@@ -1153,43 +1144,8 @@ var require_utils = __commonJS((exports, module) => {
1153
1144
  };
1154
1145
  });
1155
1146
 
1156
- // node_modules/pg/lib/crypto/utils-legacy.js
1157
- var require_utils_legacy = __commonJS((exports, module) => {
1158
- var nodeCrypto = __require("crypto");
1159
- function md5(string) {
1160
- return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
1161
- }
1162
- function postgresMd5PasswordHash(user, password, salt) {
1163
- const inner = md5(password + user);
1164
- const outer = md5(Buffer.concat([Buffer.from(inner), salt]));
1165
- return "md5" + outer;
1166
- }
1167
- function sha256(text) {
1168
- return nodeCrypto.createHash("sha256").update(text).digest();
1169
- }
1170
- function hashByName(hashName, text) {
1171
- hashName = hashName.replace(/(\D)-/, "$1");
1172
- return nodeCrypto.createHash(hashName).update(text).digest();
1173
- }
1174
- function hmacSha256(key, msg) {
1175
- return nodeCrypto.createHmac("sha256", key).update(msg).digest();
1176
- }
1177
- async function deriveKey(password, salt, iterations) {
1178
- return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, "sha256");
1179
- }
1180
- module.exports = {
1181
- postgresMd5PasswordHash,
1182
- randomBytes: nodeCrypto.randomBytes,
1183
- deriveKey,
1184
- sha256,
1185
- hashByName,
1186
- hmacSha256,
1187
- md5
1188
- };
1189
- });
1190
-
1191
- // node_modules/pg/lib/crypto/utils-webcrypto.js
1192
- var require_utils_webcrypto = __commonJS((exports, module) => {
1147
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/crypto/utils.js
1148
+ var require_utils2 = __commonJS((exports, module) => {
1193
1149
  var nodeCrypto = __require("crypto");
1194
1150
  module.exports = {
1195
1151
  postgresMd5PasswordHash,
@@ -1237,17 +1193,7 @@ var require_utils_webcrypto = __commonJS((exports, module) => {
1237
1193
  }
1238
1194
  });
1239
1195
 
1240
- // node_modules/pg/lib/crypto/utils.js
1241
- var require_utils2 = __commonJS((exports, module) => {
1242
- var useLegacyCrypto = parseInt(process.versions && process.versions.node && process.versions.node.split(".")[0]) < 15;
1243
- if (useLegacyCrypto) {
1244
- module.exports = require_utils_legacy();
1245
- } else {
1246
- module.exports = require_utils_webcrypto();
1247
- }
1248
- });
1249
-
1250
- // node_modules/pg/lib/crypto/cert-signatures.js
1196
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/crypto/cert-signatures.js
1251
1197
  var require_cert_signatures = __commonJS((exports, module) => {
1252
1198
  function x509Error(msg, cert) {
1253
1199
  return new Error("SASL channel binding: " + msg + " when parsing public certificate " + cert.toString("base64"));
@@ -1359,11 +1305,17 @@ var require_cert_signatures = __commonJS((exports, module) => {
1359
1305
  module.exports = { signatureAlgorithmHashFromCertificate };
1360
1306
  });
1361
1307
 
1362
- // node_modules/pg/lib/crypto/sasl.js
1308
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/crypto/sasl.js
1363
1309
  var require_sasl = __commonJS((exports, module) => {
1364
1310
  var crypto2 = require_utils2();
1365
1311
  var { signatureAlgorithmHashFromCertificate } = require_cert_signatures();
1366
- function startSession(mechanisms, stream) {
1312
+ function saslprep(password) {
1313
+ const nonAsciiSpace = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
1314
+ const mappedToNothing = /[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;
1315
+ return password.replace(nonAsciiSpace, " ").replace(mappedToNothing, "").normalize("NFKC");
1316
+ }
1317
+ var DEFAULT_MAX_SCRAM_ITERATIONS = 1e5;
1318
+ function startSession(mechanisms, stream, scramMaxIterations = DEFAULT_MAX_SCRAM_ITERATIONS) {
1367
1319
  const candidates = ["SCRAM-SHA-256"];
1368
1320
  if (stream)
1369
1321
  candidates.unshift("SCRAM-SHA-256-PLUS");
@@ -1380,7 +1332,8 @@ var require_sasl = __commonJS((exports, module) => {
1380
1332
  mechanism,
1381
1333
  clientNonce,
1382
1334
  response: gs2Header + ",,n=*,r=" + clientNonce,
1383
- message: "SASLInitialResponse"
1335
+ message: "SASLInitialResponse",
1336
+ scramMaxIterations
1384
1337
  };
1385
1338
  }
1386
1339
  async function continueSession(session, password, serverData, stream) {
@@ -1402,6 +1355,10 @@ var require_sasl = __commonJS((exports, module) => {
1402
1355
  } else if (sv.nonce.length === session.clientNonce.length) {
1403
1356
  throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");
1404
1357
  }
1358
+ const scramMaxIterations = typeof session.scramMaxIterations === "number" ? session.scramMaxIterations : DEFAULT_MAX_SCRAM_ITERATIONS;
1359
+ if (scramMaxIterations !== 0 && sv.iteration > scramMaxIterations) {
1360
+ throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count " + sv.iteration + " exceeds scramMaxIterations of " + scramMaxIterations);
1361
+ }
1405
1362
  const clientFirstMessageBare = "n=*,r=" + session.clientNonce;
1406
1363
  const serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration;
1407
1364
  let channelBinding = stream ? "eSws" : "biws";
@@ -1417,7 +1374,7 @@ var require_sasl = __commonJS((exports, module) => {
1417
1374
  const clientFinalMessageWithoutProof = "c=" + channelBinding + ",r=" + sv.nonce;
1418
1375
  const authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
1419
1376
  const saltBytes = Buffer.from(sv.salt, "base64");
1420
- const saltedPassword = await crypto2.deriveKey(password, saltBytes, sv.iteration);
1377
+ const saltedPassword = await crypto2.deriveKey(saslprep(password), saltBytes, sv.iteration);
1421
1378
  const clientKey = await crypto2.hmacSha256(saltedPassword, "Client Key");
1422
1379
  const storedKey = await crypto2.sha256(clientKey);
1423
1380
  const clientSignature = await crypto2.hmacSha256(storedKey, authMessage);
@@ -1491,7 +1448,11 @@ var require_sasl = __commonJS((exports, module) => {
1491
1448
  }
1492
1449
  function parseServerFinalMessage(serverData) {
1493
1450
  const attrPairs = parseAttributePairs(serverData);
1451
+ const error = attrPairs.get("e");
1494
1452
  const serverSignature = attrPairs.get("v");
1453
+ if (error) {
1454
+ throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${error}"`);
1455
+ }
1495
1456
  if (!serverSignature) {
1496
1457
  throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");
1497
1458
  } else if (!isBase64(serverSignature)) {
@@ -1519,11 +1480,12 @@ var require_sasl = __commonJS((exports, module) => {
1519
1480
  module.exports = {
1520
1481
  startSession,
1521
1482
  continueSession,
1522
- finalizeSession
1483
+ finalizeSession,
1484
+ DEFAULT_MAX_SCRAM_ITERATIONS
1523
1485
  };
1524
1486
  });
1525
1487
 
1526
- // node_modules/pg/lib/type-overrides.js
1488
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/type-overrides.js
1527
1489
  var require_type_overrides = __commonJS((exports, module) => {
1528
1490
  var types = require_pg_types();
1529
1491
  function TypeOverrides(userTypes) {
@@ -1555,14 +1517,14 @@ var require_type_overrides = __commonJS((exports, module) => {
1555
1517
  module.exports = TypeOverrides;
1556
1518
  });
1557
1519
 
1558
- // node_modules/pg-connection-string/index.js
1520
+ // node_modules/.pnpm/pg-connection-string@2.14.0/node_modules/pg-connection-string/index.js
1559
1521
  var require_pg_connection_string = __commonJS((exports, module) => {
1560
1522
  function parse(str, options = {}) {
1561
1523
  if (str.charAt(0) === "/") {
1562
1524
  const config2 = str.split(" ");
1563
1525
  return { host: config2[0], database: config2[1] };
1564
1526
  }
1565
- const config = {};
1527
+ const config = Object.create(null);
1566
1528
  let result;
1567
1529
  let dummyHost = false;
1568
1530
  if (/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) {
@@ -1610,6 +1572,9 @@ var require_pg_connection_string = __commonJS((exports, module) => {
1610
1572
  if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) {
1611
1573
  config.ssl = {};
1612
1574
  }
1575
+ if (config.sslnegotiation === "direct" && config.ssl === undefined) {
1576
+ config.ssl = true;
1577
+ }
1613
1578
  const fs = config.sslcert || config.sslkey || config.sslrootcert ? __require("fs") : null;
1614
1579
  if (config.sslcert) {
1615
1580
  config.ssl.cert = fs.readFileSync(config.sslcert).toString();
@@ -1681,7 +1646,7 @@ var require_pg_connection_string = __commonJS((exports, module) => {
1681
1646
  c[key] = value;
1682
1647
  }
1683
1648
  return c;
1684
- }, {});
1649
+ }, Object.create(null));
1685
1650
  return connectionOptions;
1686
1651
  }
1687
1652
  function toClientConfig(config) {
@@ -1708,7 +1673,7 @@ var require_pg_connection_string = __commonJS((exports, module) => {
1708
1673
  }
1709
1674
  }
1710
1675
  return c;
1711
- }, {});
1676
+ }, Object.create(null));
1712
1677
  return poolConfig;
1713
1678
  }
1714
1679
  function parseIntoClientConfig(str) {
@@ -1733,7 +1698,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
1733
1698
  parse.parseIntoClientConfig = parseIntoClientConfig;
1734
1699
  });
1735
1700
 
1736
- // node_modules/pg/lib/connection-parameters.js
1701
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/connection-parameters.js
1737
1702
  var require_connection_parameters = __commonJS((exports, module) => {
1738
1703
  var dns = __require("dns");
1739
1704
  var defaults = require_defaults();
@@ -1808,6 +1773,13 @@ var require_connection_parameters = __commonJS((exports, module) => {
1808
1773
  enumerable: false
1809
1774
  });
1810
1775
  }
1776
+ this.sslnegotiation = val("sslnegotiation", config, "PGSSLNEGOTIATION");
1777
+ if (this.sslnegotiation !== undefined && this.sslnegotiation !== "postgres" && this.sslnegotiation !== "direct") {
1778
+ throw new Error(`Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".`);
1779
+ }
1780
+ if (this.sslnegotiation === "direct" && !this.ssl) {
1781
+ throw new Error("sslnegotiation=direct requires SSL to be enabled");
1782
+ }
1811
1783
  this.client_encoding = val("client_encoding", config);
1812
1784
  this.replication = val("replication", config);
1813
1785
  this.isDomainSocket = !(this.host || "").indexOf("/");
@@ -1846,6 +1818,7 @@ var require_connection_parameters = __commonJS((exports, module) => {
1846
1818
  add(params, ssl, "sslkey");
1847
1819
  add(params, ssl, "sslcert");
1848
1820
  add(params, ssl, "sslrootcert");
1821
+ add(params, this, "sslnegotiation");
1849
1822
  if (this.database) {
1850
1823
  params.push("dbname=" + quoteParamValue(this.database));
1851
1824
  }
@@ -1872,7 +1845,7 @@ var require_connection_parameters = __commonJS((exports, module) => {
1872
1845
  module.exports = ConnectionParameters;
1873
1846
  });
1874
1847
 
1875
- // node_modules/pg/lib/result.js
1848
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/result.js
1876
1849
  var require_result = __commonJS((exports, module) => {
1877
1850
  var types = require_pg_types();
1878
1851
  var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;
@@ -1944,7 +1917,7 @@ var require_result = __commonJS((exports, module) => {
1944
1917
  if (this.fields.length) {
1945
1918
  this._parsers = new Array(fieldDescriptions.length);
1946
1919
  }
1947
- const row = {};
1920
+ const row = Object.create(null);
1948
1921
  for (let i = 0;i < fieldDescriptions.length; i++) {
1949
1922
  const desc = fieldDescriptions[i];
1950
1923
  row[desc.name] = null;
@@ -1960,7 +1933,7 @@ var require_result = __commonJS((exports, module) => {
1960
1933
  module.exports = Result;
1961
1934
  });
1962
1935
 
1963
- // node_modules/pg/lib/query.js
1936
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/query.js
1964
1937
  var require_query = __commonJS((exports, module) => {
1965
1938
  var { EventEmitter } = __require("events");
1966
1939
  var Result = require_result();
@@ -2129,6 +2102,8 @@ var require_query = __commonJS((exports, module) => {
2129
2102
  valueMapper: utils.prepareValue
2130
2103
  });
2131
2104
  } catch (err) {
2105
+ connection.close({ type: "S", name: this.name });
2106
+ connection.sync();
2132
2107
  this.handleError(err, connection);
2133
2108
  return;
2134
2109
  }
@@ -2146,7 +2121,7 @@ var require_query = __commonJS((exports, module) => {
2146
2121
  module.exports = Query;
2147
2122
  });
2148
2123
 
2149
- // node_modules/pg-protocol/dist/messages.js
2124
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/messages.js
2150
2125
  var require_messages = __commonJS((exports) => {
2151
2126
  Object.defineProperty(exports, "__esModule", { value: true });
2152
2127
  exports.NoticeMessage = exports.DataRowMessage = exports.CommandCompleteMessage = exports.ReadyForQueryMessage = exports.NotificationResponseMessage = exports.BackendKeyDataMessage = exports.AuthenticationMD5Password = exports.ParameterStatusMessage = exports.ParameterDescriptionMessage = exports.RowDescriptionMessage = exports.Field = exports.CopyResponse = exports.CopyDataMessage = exports.DatabaseError = exports.copyDone = exports.emptyQuery = exports.replicationStart = exports.portalSuspended = exports.noData = exports.closeComplete = exports.bindComplete = exports.parseComplete = undefined;
@@ -2322,7 +2297,7 @@ var require_messages = __commonJS((exports) => {
2322
2297
  exports.NoticeMessage = NoticeMessage;
2323
2298
  });
2324
2299
 
2325
- // node_modules/pg-protocol/dist/buffer-writer.js
2300
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/buffer-writer.js
2326
2301
  var require_buffer_writer = __commonJS((exports) => {
2327
2302
  Object.defineProperty(exports, "__esModule", { value: true });
2328
2303
  exports.Writer = undefined;
@@ -2376,6 +2351,19 @@ var require_buffer_writer = __commonJS((exports) => {
2376
2351
  this.offset += len;
2377
2352
  return this;
2378
2353
  }
2354
+ addInt32PrefixedString(string) {
2355
+ const len = Buffer.byteLength(string);
2356
+ this.ensure(4 + len);
2357
+ const buffer = this.buffer;
2358
+ let offset = this.offset;
2359
+ buffer[offset++] = len >>> 24 & 255;
2360
+ buffer[offset++] = len >>> 16 & 255;
2361
+ buffer[offset++] = len >>> 8 & 255;
2362
+ buffer[offset++] = len >>> 0 & 255;
2363
+ buffer.write(string, offset, "utf-8");
2364
+ this.offset = offset + len;
2365
+ return this;
2366
+ }
2379
2367
  add(otherBuffer) {
2380
2368
  this.ensure(otherBuffer.length);
2381
2369
  otherBuffer.copy(this.buffer, this.offset);
@@ -2397,11 +2385,15 @@ var require_buffer_writer = __commonJS((exports) => {
2397
2385
  this.buffer = Buffer.allocUnsafe(this.size);
2398
2386
  return result;
2399
2387
  }
2388
+ clear() {
2389
+ this.offset = 5;
2390
+ this.headerPosition = 0;
2391
+ }
2400
2392
  }
2401
2393
  exports.Writer = Writer;
2402
2394
  });
2403
2395
 
2404
- // node_modules/pg-protocol/dist/serializer.js
2396
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/serializer.js
2405
2397
  var require_serializer = __commonJS((exports) => {
2406
2398
  Object.defineProperty(exports, "__esModule", { value: true });
2407
2399
  exports.serialize = undefined;
@@ -2427,7 +2419,7 @@ var require_serializer = __commonJS((exports) => {
2427
2419
  return writer.addCString(password2).flush(112);
2428
2420
  };
2429
2421
  var sendSASLInitialResponseMessage = function(mechanism, initialResponse) {
2430
- writer.addCString(mechanism).addInt32(Buffer.byteLength(initialResponse)).addString(initialResponse);
2422
+ writer.addCString(mechanism).addInt32PrefixedString(initialResponse);
2431
2423
  return writer.flush(112);
2432
2424
  };
2433
2425
  var sendSCRAMClientFinalMessage = function(additionalData) {
@@ -2465,8 +2457,7 @@ var require_serializer = __commonJS((exports) => {
2465
2457
  paramWriter.add(mappedVal);
2466
2458
  } else {
2467
2459
  writer.addInt16(0);
2468
- paramWriter.addInt32(Buffer.byteLength(mappedVal));
2469
- paramWriter.addString(mappedVal);
2460
+ paramWriter.addInt32PrefixedString(mappedVal);
2470
2461
  }
2471
2462
  }
2472
2463
  };
@@ -2478,7 +2469,13 @@ var require_serializer = __commonJS((exports) => {
2478
2469
  const len = values.length;
2479
2470
  writer.addCString(portal).addCString(statement);
2480
2471
  writer.addInt16(len);
2481
- writeValues(values, config.valueMapper);
2472
+ try {
2473
+ writeValues(values, config.valueMapper);
2474
+ } catch (err) {
2475
+ writer.clear();
2476
+ paramWriter.clear();
2477
+ throw err;
2478
+ }
2482
2479
  writer.addInt16(len);
2483
2480
  writer.add(paramWriter.flush());
2484
2481
  writer.addInt16(1);
@@ -2564,7 +2561,7 @@ var require_serializer = __commonJS((exports) => {
2564
2561
  exports.serialize = serialize;
2565
2562
  });
2566
2563
 
2567
- // node_modules/pg-protocol/dist/buffer-reader.js
2564
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/buffer-reader.js
2568
2565
  var require_buffer_reader = __commonJS((exports) => {
2569
2566
  Object.defineProperty(exports, "__esModule", { value: true });
2570
2567
  exports.BufferReader = undefined;
@@ -2607,7 +2604,7 @@ var require_buffer_reader = __commonJS((exports) => {
2607
2604
  cstring() {
2608
2605
  const start = this.offset;
2609
2606
  let end = start;
2610
- while (this.buffer[end++] !== 0) {}
2607
+ while (this.buffer[end++]) {}
2611
2608
  this.offset = end;
2612
2609
  return this.buffer.toString(this.encoding, start, end - 1);
2613
2610
  }
@@ -2620,7 +2617,7 @@ var require_buffer_reader = __commonJS((exports) => {
2620
2617
  exports.BufferReader = BufferReader;
2621
2618
  });
2622
2619
 
2623
- // node_modules/pg-protocol/dist/parser.js
2620
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/parser.js
2624
2621
  var require_parser = __commonJS((exports) => {
2625
2622
  Object.defineProperty(exports, "__esModule", { value: true });
2626
2623
  exports.Parser = undefined;
@@ -2925,10 +2922,11 @@ var require_parser = __commonJS((exports) => {
2925
2922
  };
2926
2923
  });
2927
2924
 
2928
- // node_modules/pg-protocol/dist/index.js
2925
+ // node_modules/.pnpm/pg-protocol@1.15.0/node_modules/pg-protocol/dist/index.js
2929
2926
  var require_dist = __commonJS((exports) => {
2930
2927
  Object.defineProperty(exports, "__esModule", { value: true });
2931
- exports.DatabaseError = exports.serialize = exports.parse = undefined;
2928
+ exports.DatabaseError = exports.serialize = undefined;
2929
+ exports.parse = parse;
2932
2930
  var messages_1 = require_messages();
2933
2931
  Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function() {
2934
2932
  return messages_1.DatabaseError;
@@ -2943,16 +2941,15 @@ var require_dist = __commonJS((exports) => {
2943
2941
  stream.on("data", (buffer) => parser.parse(buffer, callback));
2944
2942
  return new Promise((resolve2) => stream.on("end", () => resolve2()));
2945
2943
  }
2946
- exports.parse = parse;
2947
2944
  });
2948
2945
 
2949
- // node_modules/pg-cloudflare/dist/empty.js
2946
+ // node_modules/.pnpm/pg-cloudflare@1.4.0/node_modules/pg-cloudflare/dist/empty.js
2950
2947
  var require_empty = __commonJS((exports) => {
2951
2948
  Object.defineProperty(exports, "__esModule", { value: true });
2952
2949
  exports.default = {};
2953
2950
  });
2954
2951
 
2955
- // node_modules/pg/lib/stream.js
2952
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/stream.js
2956
2953
  var require_stream = __commonJS((exports, module) => {
2957
2954
  var { getStream, getSecureStream } = getStreamFuncs();
2958
2955
  module.exports = {
@@ -3007,11 +3004,12 @@ var require_stream = __commonJS((exports, module) => {
3007
3004
  }
3008
3005
  });
3009
3006
 
3010
- // node_modules/pg/lib/connection.js
3007
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/connection.js
3011
3008
  var require_connection = __commonJS((exports, module) => {
3012
3009
  var EventEmitter = __require("events").EventEmitter;
3013
3010
  var { parse, serialize } = require_dist();
3014
- var { getStream, getSecureStream } = require_stream();
3011
+ var stream = require_stream();
3012
+ var { getStream } = stream;
3015
3013
  var flushBuffer = serialize.flush();
3016
3014
  var syncBuffer = serialize.sync();
3017
3015
  var endBuffer = serialize.end();
@@ -3028,6 +3026,7 @@ var require_connection = __commonJS((exports, module) => {
3028
3026
  this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis;
3029
3027
  this.parsedStatements = {};
3030
3028
  this.ssl = config.ssl || false;
3029
+ this.sslNegotiation = config.sslNegotiation || "postgres";
3031
3030
  this._ending = false;
3032
3031
  this._emitMessage = false;
3033
3032
  const self = this;
@@ -3061,6 +3060,11 @@ var require_connection = __commonJS((exports, module) => {
3061
3060
  if (!this.ssl) {
3062
3061
  return this.attachListeners(this.stream);
3063
3062
  }
3063
+ if (this.sslNegotiation === "direct") {
3064
+ return this.stream.once("connect", function() {
3065
+ self.upgradeToSSL(host, reportStreamError);
3066
+ });
3067
+ }
3064
3068
  this.stream.once("data", function(buffer) {
3065
3069
  const responseCode = buffer.toString("utf8");
3066
3070
  switch (responseCode) {
@@ -3073,31 +3077,38 @@ var require_connection = __commonJS((exports, module) => {
3073
3077
  self.stream.end();
3074
3078
  return self.emit("error", new Error("There was an error establishing an SSL connection"));
3075
3079
  }
3076
- const options = {
3077
- socket: self.stream
3078
- };
3079
- if (self.ssl !== true) {
3080
- Object.assign(options, self.ssl);
3081
- if ("key" in self.ssl) {
3082
- options.key = self.ssl.key;
3083
- }
3084
- }
3085
- const net = __require("net");
3086
- if (net.isIP && net.isIP(host) === 0) {
3087
- options.servername = host;
3088
- }
3089
- try {
3090
- self.stream = getSecureStream(options);
3091
- } catch (err) {
3092
- return self.emit("error", err);
3093
- }
3094
- self.attachListeners(self.stream);
3095
- self.stream.on("error", reportStreamError);
3096
- self.emit("sslconnect");
3080
+ self.upgradeToSSL(host, reportStreamError);
3097
3081
  });
3098
3082
  }
3099
- attachListeners(stream) {
3100
- parse(stream, (msg) => {
3083
+ upgradeToSSL(host, reportStreamError) {
3084
+ const self = this;
3085
+ const options = {
3086
+ socket: self.stream
3087
+ };
3088
+ if (self.ssl !== true) {
3089
+ Object.assign(options, self.ssl);
3090
+ if ("key" in self.ssl) {
3091
+ options.key = self.ssl.key;
3092
+ }
3093
+ }
3094
+ if (self.sslNegotiation === "direct") {
3095
+ options.ALPNProtocols = ["postgresql"];
3096
+ }
3097
+ const net = __require("net");
3098
+ if (net.isIP && net.isIP(host) === 0) {
3099
+ options.servername = host;
3100
+ }
3101
+ try {
3102
+ self.stream = stream.getSecureStream(options);
3103
+ } catch (err) {
3104
+ return self.emit("error", err);
3105
+ }
3106
+ self.attachListeners(self.stream);
3107
+ self.stream.on("error", reportStreamError);
3108
+ self.emit("sslconnect");
3109
+ }
3110
+ attachListeners(stream2) {
3111
+ parse(stream2, (msg) => {
3101
3112
  const eventName = msg.name === "error" ? "errorMessage" : msg.name;
3102
3113
  if (this._emitMessage) {
3103
3114
  this.emit("message", msg);
@@ -3185,7 +3196,7 @@ var require_connection = __commonJS((exports, module) => {
3185
3196
  module.exports = Connection;
3186
3197
  });
3187
3198
 
3188
- // node_modules/split2/index.js
3199
+ // node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js
3189
3200
  var require_split2 = __commonJS((exports, module) => {
3190
3201
  var { Transform } = __require("stream");
3191
3202
  var { StringDecoder } = __require("string_decoder");
@@ -3284,7 +3295,7 @@ var require_split2 = __commonJS((exports, module) => {
3284
3295
  module.exports = split;
3285
3296
  });
3286
3297
 
3287
- // node_modules/pgpass/lib/helper.js
3298
+ // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/helper.js
3288
3299
  var require_helper = __commonJS((exports, module) => {
3289
3300
  var path = __require("path");
3290
3301
  var Stream = __require("stream").Stream;
@@ -3448,7 +3459,7 @@ var require_helper = __commonJS((exports, module) => {
3448
3459
  };
3449
3460
  });
3450
3461
 
3451
- // node_modules/pgpass/lib/index.js
3462
+ // node_modules/.pnpm/pgpass@1.0.5/node_modules/pgpass/lib/index.js
3452
3463
  var require_lib = __commonJS((exports, module) => {
3453
3464
  var path = __require("path");
3454
3465
  var fs = __require("fs");
@@ -3466,7 +3477,7 @@ var require_lib = __commonJS((exports, module) => {
3466
3477
  module.exports.warnTo = helper.warnTo;
3467
3478
  });
3468
3479
 
3469
- // node_modules/pg/lib/client.js
3480
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/client.js
3470
3481
  var require_client = __commonJS((exports, module) => {
3471
3482
  var EventEmitter = __require("events").EventEmitter;
3472
3483
  var utils = require_utils();
@@ -3483,6 +3494,16 @@ var require_client = __commonJS((exports, module) => {
3483
3494
  var pgPassDeprecationNotice = nodeUtils.deprecate(() => {}, "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.");
3484
3495
  var byoPromiseDeprecationNotice = nodeUtils.deprecate(() => {}, "Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0.");
3485
3496
  var queryQueueLengthDeprecationNotice = nodeUtils.deprecate(() => {}, "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.");
3497
+ function coerceNumberOrDefault(value, defaultValue) {
3498
+ if (typeof value === "number") {
3499
+ return Number.isFinite(value) ? value : defaultValue;
3500
+ }
3501
+ if (typeof value === "string" && value.trim() !== "") {
3502
+ const n = Number(value);
3503
+ return Number.isFinite(n) ? n : defaultValue;
3504
+ }
3505
+ return defaultValue;
3506
+ }
3486
3507
 
3487
3508
  class Client extends EventEmitter {
3488
3509
  constructor(config) {
@@ -3512,10 +3533,13 @@ var require_client = __commonJS((exports, module) => {
3512
3533
  this._connectionError = false;
3513
3534
  this._queryable = true;
3514
3535
  this._activeQuery = null;
3536
+ this._txStatus = null;
3515
3537
  this.enableChannelBinding = Boolean(c.enableChannelBinding);
3538
+ this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS);
3516
3539
  this.connection = c.connection || new Connection({
3517
3540
  stream: c.stream,
3518
3541
  ssl: this.connectionParameters.ssl,
3542
+ sslNegotiation: this.connectionParameters.sslnegotiation,
3519
3543
  keepAlive: c.keepAlive || false,
3520
3544
  keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0,
3521
3545
  encoding: this.connectionParameters.client_encoding || "utf8"
@@ -3525,6 +3549,7 @@ var require_client = __commonJS((exports, module) => {
3525
3549
  this.processID = null;
3526
3550
  this.secretKey = null;
3527
3551
  this.ssl = this.connectionParameters.ssl || false;
3552
+ this.sslNegotiation = this.connectionParameters.sslnegotiation || "postgres";
3528
3553
  if (this.ssl && this.ssl.key) {
3529
3554
  Object.defineProperty(this.ssl, "key", {
3530
3555
  enumerable: false
@@ -3585,7 +3610,9 @@ var require_client = __commonJS((exports, module) => {
3585
3610
  }
3586
3611
  con.on("connect", function() {
3587
3612
  if (self.ssl) {
3588
- con.requestSsl();
3613
+ if (self.sslNegotiation !== "direct") {
3614
+ con.requestSsl();
3615
+ }
3589
3616
  } else {
3590
3617
  con.startup(self.getStartupConf());
3591
3618
  }
@@ -3703,7 +3730,7 @@ var require_client = __commonJS((exports, module) => {
3703
3730
  _handleAuthSASL(msg) {
3704
3731
  this._getPassword(() => {
3705
3732
  try {
3706
- this.saslSession = sasl.startSession(msg.mechanisms, this.enableChannelBinding && this.connection.stream);
3733
+ this.saslSession = sasl.startSession(msg.mechanisms, this.enableChannelBinding && this.connection.stream, this.scramMaxIterations);
3707
3734
  this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
3708
3735
  } catch (err) {
3709
3736
  this.connection.emit("error", err);
@@ -3743,6 +3770,7 @@ var require_client = __commonJS((exports, module) => {
3743
3770
  }
3744
3771
  const activeQuery = this._getActiveQuery();
3745
3772
  this._activeQuery = null;
3773
+ this._txStatus = msg?.status ?? null;
3746
3774
  this.readyForQuery = true;
3747
3775
  if (activeQuery) {
3748
3776
  activeQuery.handleReadyForQuery(this.connection);
@@ -3938,13 +3966,10 @@ var require_client = __commonJS((exports, module) => {
3938
3966
  query(config, values, callback) {
3939
3967
  let query;
3940
3968
  let result;
3941
- let readTimeout;
3942
- let readTimeoutTimer;
3943
- let queryCallback;
3944
- if (config === null || config === undefined) {
3969
+ if (config == null) {
3945
3970
  throw new TypeError("Client was passed a null or undefined query");
3946
- } else if (typeof config.submit === "function") {
3947
- readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
3971
+ }
3972
+ if (typeof config.submit === "function") {
3948
3973
  result = query = config;
3949
3974
  if (!query.callback) {
3950
3975
  if (typeof values === "function") {
@@ -3954,7 +3979,6 @@ var require_client = __commonJS((exports, module) => {
3954
3979
  }
3955
3980
  }
3956
3981
  } else {
3957
- readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
3958
3982
  query = new Query(config, values, callback);
3959
3983
  if (!query.callback) {
3960
3984
  result = new this._Promise((resolve2, reject) => {
@@ -3963,11 +3987,14 @@ var require_client = __commonJS((exports, module) => {
3963
3987
  Error.captureStackTrace(err);
3964
3988
  throw err;
3965
3989
  });
3990
+ } else if (typeof query.callback !== "function") {
3991
+ throw new TypeError("callback is not a function");
3966
3992
  }
3967
3993
  }
3994
+ const readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
3968
3995
  if (readTimeout) {
3969
- queryCallback = query.callback || (() => {});
3970
- readTimeoutTimer = setTimeout(() => {
3996
+ const queryCallback = query.callback || (() => {});
3997
+ const readTimeoutTimer = setTimeout(() => {
3971
3998
  const error = new Error("Query read timeout");
3972
3999
  process.nextTick(() => {
3973
4000
  query.handleError(error, this.connection);
@@ -4016,11 +4043,15 @@ var require_client = __commonJS((exports, module) => {
4016
4043
  unref() {
4017
4044
  this.connection.unref();
4018
4045
  }
4046
+ getTransactionStatus() {
4047
+ return this._txStatus;
4048
+ }
4019
4049
  end(cb) {
4020
4050
  this._ending = true;
4021
4051
  if (!this.connection._connecting || this._ended) {
4022
4052
  if (cb) {
4023
4053
  cb();
4054
+ return;
4024
4055
  } else {
4025
4056
  return this._Promise.resolve();
4026
4057
  }
@@ -4047,7 +4078,7 @@ var require_client = __commonJS((exports, module) => {
4047
4078
  module.exports = Client;
4048
4079
  });
4049
4080
 
4050
- // node_modules/pg-pool/index.js
4081
+ // node_modules/.pnpm/pg-pool@3.14.0_pg@8.22.0/node_modules/pg-pool/index.js
4051
4082
  var require_pg_pool = __commonJS((exports, module) => {
4052
4083
  var EventEmitter = __require("events").EventEmitter;
4053
4084
  var NOOP = function() {};
@@ -4459,7 +4490,7 @@ var require_pg_pool = __commonJS((exports, module) => {
4459
4490
  module.exports = Pool;
4460
4491
  });
4461
4492
 
4462
- // node_modules/pg/lib/native/query.js
4493
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/native/query.js
4463
4494
  var require_query2 = __commonJS((exports, module) => {
4464
4495
  var EventEmitter = __require("events").EventEmitter;
4465
4496
  var util = __require("util");
@@ -4595,7 +4626,7 @@ var require_query2 = __commonJS((exports, module) => {
4595
4626
  };
4596
4627
  });
4597
4628
 
4598
- // node_modules/pg/lib/native/client.js
4629
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/native/client.js
4599
4630
  var require_client2 = __commonJS((exports, module) => {
4600
4631
  var nodeUtils = __require("util");
4601
4632
  var Native;
@@ -4777,8 +4808,10 @@ var require_client2 = __commonJS((exports, module) => {
4777
4808
  Client.prototype.end = function(cb) {
4778
4809
  const self = this;
4779
4810
  this._ending = true;
4780
- if (!this._connected) {
4781
- this.once("connect", this.end.bind(this, cb));
4811
+ if (this._connecting && !this._connected) {
4812
+ this.once("connect", () => {
4813
+ this.end(() => {});
4814
+ });
4782
4815
  }
4783
4816
  let result;
4784
4817
  if (!cb) {
@@ -4839,9 +4872,12 @@ var require_client2 = __commonJS((exports, module) => {
4839
4872
  Client.prototype.isConnected = function() {
4840
4873
  return this._connected;
4841
4874
  };
4875
+ Client.prototype.getTransactionStatus = function() {
4876
+ return this.native.getTransactionStatus();
4877
+ };
4842
4878
  });
4843
4879
 
4844
- // node_modules/pg/lib/index.js
4880
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/lib/index.js
4845
4881
  var require_lib2 = __commonJS((exports, module) => {
4846
4882
  var Client = require_client();
4847
4883
  var defaults = require_defaults();
@@ -4907,7 +4943,7 @@ var require_lib2 = __commonJS((exports, module) => {
4907
4943
  var require_package = __commonJS((exports, module) => {
4908
4944
  module.exports = {
4909
4945
  name: "@hasna/shortlinks",
4910
- version: "0.2.0",
4946
+ version: "0.2.1",
4911
4947
  description: "Shortlink manager for custom domains and click tracking, with local SQLite or self-hosted cloud (/v1 API + bearer key) storage and Cloudflare setup helpers",
4912
4948
  type: "module",
4913
4949
  main: "dist/index.js",
@@ -4948,7 +4984,7 @@ var require_package = __commonJS((exports, module) => {
4948
4984
  "SECURITY.md"
4949
4985
  ],
4950
4986
  scripts: {
4951
- build: "rm -rf dist && bun build src/cli/index.ts src/mcp/index.ts src/serve/index.ts src/sdk/index.ts src/index.ts src/server.ts src/cloudflare.ts src/pg-store.ts --root src --outdir dist --target bun --external @modelcontextprotocol/sdk --external @hasna/mcp-harness --external @hasna/mcp-harness/node && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
4987
+ build: "rm -rf dist && bun build src/cli/index.ts src/mcp/index.ts src/serve/index.ts src/sdk/index.ts src/index.ts src/server.ts src/cloudflare.ts src/pg-store.ts --root src --outdir dist --target bun --external @modelcontextprotocol/sdk && tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
4952
4988
  "sdk:generate": "bun run scripts/generate-sdk.ts",
4953
4989
  typecheck: "tsc --noEmit",
4954
4990
  test: "bun test",
@@ -4988,7 +5024,6 @@ var require_package = __commonJS((exports, module) => {
4988
5024
  license: "Apache-2.0",
4989
5025
  dependencies: {
4990
5026
  "@hasna/events": "^0.1.6",
4991
- "@hasna/mcp-harness": "file:../open-mcp",
4992
5027
  "@modelcontextprotocol/sdk": "^1.27.1",
4993
5028
  chalk: "^5.4.1",
4994
5029
  commander: "^13.1.0",
@@ -4996,7 +5031,7 @@ var require_package = __commonJS((exports, module) => {
4996
5031
  pg: "^8.13.3"
4997
5032
  },
4998
5033
  devDependencies: {
4999
- "@hasna/contracts": "file:../open-contracts",
5034
+ "@hasna/contracts": "^0.5.2",
5000
5035
  "@types/pg": "^8.11.11",
5001
5036
  "@types/bun": "^1.2.4",
5002
5037
  typescript: "^5.7.3"
@@ -5446,6 +5481,13 @@ class PgShortlinksStore {
5446
5481
  `);
5447
5482
  return row ? domainFromRow(row) : null;
5448
5483
  }
5484
+ async deleteDomain(hostnameOrId) {
5485
+ const domain = await this.getDomain(hostnameOrId);
5486
+ if (!domain)
5487
+ throw new Error("Domain not found.");
5488
+ await this.pg.run("DELETE FROM domains WHERE id = ?", domain.id);
5489
+ return domain;
5490
+ }
5449
5491
  async createLink(input) {
5450
5492
  const domain = input.domain ? await this.getDomain(input.domain) : await this.getDefaultDomain();
5451
5493
  if (!domain) {
@@ -5622,7 +5664,7 @@ class PgShortlinksStore {
5622
5664
  }
5623
5665
  }
5624
5666
 
5625
- // node_modules/pg/esm/index.mjs
5667
+ // node_modules/.pnpm/pg@8.22.0/node_modules/pg/esm/index.mjs
5626
5668
  var import_lib = __toESM(require_lib2(), 1);
5627
5669
  var Client = import_lib.default.Client;
5628
5670
  var Pool = import_lib.default.Pool;
@@ -5945,7 +5987,7 @@ class MigrationLedger {
5945
5987
  }
5946
5988
  }
5947
5989
 
5948
- // ../open-contracts/dist/auth/index.js
5990
+ // node_modules/.pnpm/@hasna+contracts@0.5.2/node_modules/@hasna/contracts/dist/auth/index.js
5949
5991
  import { createHash as createHash3, createHmac, randomBytes as randomBytes3, timingSafeEqual } from "crypto";
5950
5992
  var API_KEY_TOKEN_VERSION = 1;
5951
5993
  var API_KEY_NAMESPACE = "hasna";
@@ -8066,6 +8108,11 @@ function buildOpenApiDocument(version) {
8066
8108
  properties: { deleted: { type: "boolean" }, slug: { type: "string" } },
8067
8109
  required: ["deleted"]
8068
8110
  },
8111
+ DomainDeleteResponse: {
8112
+ type: "object",
8113
+ properties: { deleted: { type: "boolean" }, hostname: { type: "string" } },
8114
+ required: ["deleted"]
8115
+ },
8069
8116
  HealthStatus: probe({ db_latency_ms: { type: "integer" } }),
8070
8117
  ReadyStatus: probe({ pending_migrations: { type: "array", items: { type: "string" } } }),
8071
8118
  VersionInfo: probe({ name: { type: "string" } }),
@@ -8136,6 +8183,19 @@ function buildOpenApiDocument(version) {
8136
8183
  }
8137
8184
  }
8138
8185
  },
8186
+ "/v1/domains/{hostname}": {
8187
+ delete: {
8188
+ operationId: "deleteDomain",
8189
+ summary: "Delete a domain and all of its links and clicks.",
8190
+ security: [{ apiKey: [] }],
8191
+ parameters: [
8192
+ { name: "hostname", in: "path", required: true, schema: { type: "string" } }
8193
+ ],
8194
+ responses: {
8195
+ "200": { content: { "application/json": { schema: { $ref: "#/components/schemas/DomainDeleteResponse" } } } }
8196
+ }
8197
+ }
8198
+ },
8139
8199
  "/v1/links": {
8140
8200
  get: {
8141
8201
  operationId: "listLinks",
@@ -8337,6 +8397,18 @@ function createServeApp(deps) {
8337
8397
  return handleError(c, error);
8338
8398
  }
8339
8399
  });
8400
+ app.delete("/v1/domains/:hostname", async (c) => {
8401
+ const denied = await requireScopes(c, [`${APP_SLUG}:write`]);
8402
+ if (denied)
8403
+ return denied;
8404
+ const hostname2 = c.req.param("hostname");
8405
+ try {
8406
+ const domain = await store.deleteDomain(hostname2);
8407
+ return c.json({ deleted: true, hostname: domain.hostname });
8408
+ } catch (error) {
8409
+ return handleError(c, error);
8410
+ }
8411
+ });
8340
8412
  app.get("/v1/links", async (c) => {
8341
8413
  const denied = await requireScopes(c, [`${APP_SLUG}:read`]);
8342
8414
  if (denied)