@hasna/domains 0.0.4 → 0.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/index.js CHANGED
@@ -3196,7 +3196,7 @@ var require_headStream = __commonJS((exports) => {
3196
3196
  if ((0, stream_type_check_1.isReadableStream)(stream)) {
3197
3197
  return (0, headStream_browser_1.headStream)(stream, bytes);
3198
3198
  }
3199
- return new Promise((resolve2, reject) => {
3199
+ return new Promise((resolve3, reject) => {
3200
3200
  const collector = new Collector;
3201
3201
  collector.limit = bytes;
3202
3202
  stream.pipe(collector);
@@ -3207,7 +3207,7 @@ var require_headStream = __commonJS((exports) => {
3207
3207
  collector.on("error", reject);
3208
3208
  collector.on("finish", function() {
3209
3209
  const bytes2 = new Uint8Array(Buffer.concat(this.buffers));
3210
- resolve2(bytes2);
3210
+ resolve3(bytes2);
3211
3211
  });
3212
3212
  });
3213
3213
  };
@@ -3403,21 +3403,21 @@ var require_dist_cjs13 = __commonJS((exports) => {
3403
3403
  let sendBody = true;
3404
3404
  if (!externalAgent && expect === "100-continue") {
3405
3405
  sendBody = await Promise.race([
3406
- new Promise((resolve2) => {
3407
- timeoutId = Number(timing.setTimeout(() => resolve2(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
3406
+ new Promise((resolve3) => {
3407
+ timeoutId = Number(timing.setTimeout(() => resolve3(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
3408
3408
  }),
3409
- new Promise((resolve2) => {
3409
+ new Promise((resolve3) => {
3410
3410
  httpRequest.on("continue", () => {
3411
3411
  timing.clearTimeout(timeoutId);
3412
- resolve2(true);
3412
+ resolve3(true);
3413
3413
  });
3414
3414
  httpRequest.on("response", () => {
3415
3415
  timing.clearTimeout(timeoutId);
3416
- resolve2(false);
3416
+ resolve3(false);
3417
3417
  });
3418
3418
  httpRequest.on("error", () => {
3419
3419
  timing.clearTimeout(timeoutId);
3420
- resolve2(false);
3420
+ resolve3(false);
3421
3421
  });
3422
3422
  })
3423
3423
  ]);
@@ -3492,13 +3492,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3492
3492
  return socketWarningTimestamp;
3493
3493
  }
3494
3494
  constructor(options) {
3495
- this.configProvider = new Promise((resolve2, reject) => {
3495
+ this.configProvider = new Promise((resolve3, reject) => {
3496
3496
  if (typeof options === "function") {
3497
3497
  options().then((_options) => {
3498
- resolve2(this.resolveDefaultConfig(_options));
3498
+ resolve3(this.resolveDefaultConfig(_options));
3499
3499
  }).catch(reject);
3500
3500
  } else {
3501
- resolve2(this.resolveDefaultConfig(options));
3501
+ resolve3(this.resolveDefaultConfig(options));
3502
3502
  }
3503
3503
  });
3504
3504
  }
@@ -3518,7 +3518,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3518
3518
  return new Promise((_resolve, _reject) => {
3519
3519
  let writeRequestBodyPromise = undefined;
3520
3520
  const timeouts = [];
3521
- const resolve2 = async (arg) => {
3521
+ const resolve3 = async (arg) => {
3522
3522
  await writeRequestBodyPromise;
3523
3523
  timeouts.forEach(timing.clearTimeout);
3524
3524
  _resolve(arg);
@@ -3582,7 +3582,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3582
3582
  headers: getTransformedHeaders(res.headers),
3583
3583
  body: res
3584
3584
  });
3585
- resolve2({ response: httpResponse });
3585
+ resolve3({ response: httpResponse });
3586
3586
  });
3587
3587
  req.on("error", (err) => {
3588
3588
  if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
@@ -3794,13 +3794,13 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3794
3794
  return new NodeHttp2Handler(instanceOrOptions);
3795
3795
  }
3796
3796
  constructor(options) {
3797
- this.configProvider = new Promise((resolve2, reject) => {
3797
+ this.configProvider = new Promise((resolve3, reject) => {
3798
3798
  if (typeof options === "function") {
3799
3799
  options().then((opts) => {
3800
- resolve2(opts || {});
3800
+ resolve3(opts || {});
3801
3801
  }).catch(reject);
3802
3802
  } else {
3803
- resolve2(options || {});
3803
+ resolve3(options || {});
3804
3804
  }
3805
3805
  });
3806
3806
  }
@@ -3820,7 +3820,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3820
3820
  return new Promise((_resolve, _reject) => {
3821
3821
  let fulfilled = false;
3822
3822
  let writeRequestBodyPromise = undefined;
3823
- const resolve2 = async (arg) => {
3823
+ const resolve3 = async (arg) => {
3824
3824
  await writeRequestBodyPromise;
3825
3825
  _resolve(arg);
3826
3826
  };
@@ -3875,7 +3875,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3875
3875
  body: req
3876
3876
  });
3877
3877
  fulfilled = true;
3878
- resolve2({ response: httpResponse });
3878
+ resolve3({ response: httpResponse });
3879
3879
  if (disableConcurrentStreams) {
3880
3880
  session.close();
3881
3881
  this.connectionManager.deleteSession(authority, session);
@@ -3952,7 +3952,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3952
3952
  if (isReadableStreamInstance(stream)) {
3953
3953
  return collectReadableStream(stream);
3954
3954
  }
3955
- return new Promise((resolve2, reject) => {
3955
+ return new Promise((resolve3, reject) => {
3956
3956
  const collector = new Collector;
3957
3957
  stream.pipe(collector);
3958
3958
  stream.on("error", (err) => {
@@ -3962,7 +3962,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
3962
3962
  collector.on("error", reject);
3963
3963
  collector.on("finish", function() {
3964
3964
  const bytes = new Uint8Array(Buffer.concat(this.bufferedBytes));
3965
- resolve2(bytes);
3965
+ resolve3(bytes);
3966
3966
  });
3967
3967
  });
3968
3968
  };
@@ -4003,7 +4003,7 @@ var require_dist_cjs14 = __commonJS((exports) => {
4003
4003
  return new Request(url, requestOptions);
4004
4004
  }
4005
4005
  function requestTimeout(timeoutInMs = 0) {
4006
- return new Promise((resolve2, reject) => {
4006
+ return new Promise((resolve3, reject) => {
4007
4007
  if (timeoutInMs) {
4008
4008
  setTimeout(() => {
4009
4009
  const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
@@ -4119,7 +4119,7 @@ var require_dist_cjs14 = __commonJS((exports) => {
4119
4119
  requestTimeout(requestTimeoutInMs)
4120
4120
  ];
4121
4121
  if (abortSignal) {
4122
- raceOfPromises.push(new Promise((resolve2, reject) => {
4122
+ raceOfPromises.push(new Promise((resolve3, reject) => {
4123
4123
  const onAbort = () => {
4124
4124
  const abortError = buildAbortError(abortSignal);
4125
4125
  reject(abortError);
@@ -4199,7 +4199,7 @@ var require_dist_cjs14 = __commonJS((exports) => {
4199
4199
  return collected;
4200
4200
  }
4201
4201
  function readToBase64(blob) {
4202
- return new Promise((resolve2, reject) => {
4202
+ return new Promise((resolve3, reject) => {
4203
4203
  const reader = new FileReader;
4204
4204
  reader.onloadend = () => {
4205
4205
  if (reader.readyState !== 2) {
@@ -4208,7 +4208,7 @@ var require_dist_cjs14 = __commonJS((exports) => {
4208
4208
  const result = reader.result ?? "";
4209
4209
  const commaIndex = result.indexOf(",");
4210
4210
  const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
4211
- resolve2(result.substring(dataOffset));
4211
+ resolve3(result.substring(dataOffset));
4212
4212
  };
4213
4213
  reader.onabort = () => reject(new Error("Read aborted"));
4214
4214
  reader.onerror = () => reject(reader.error);
@@ -5415,11 +5415,11 @@ var require_tslib = __commonJS((exports, module) => {
5415
5415
  };
5416
5416
  __awaiter = function(thisArg, _arguments, P, generator) {
5417
5417
  function adopt(value) {
5418
- return value instanceof P ? value : new P(function(resolve2) {
5419
- resolve2(value);
5418
+ return value instanceof P ? value : new P(function(resolve3) {
5419
+ resolve3(value);
5420
5420
  });
5421
5421
  }
5422
- return new (P || (P = Promise))(function(resolve2, reject) {
5422
+ return new (P || (P = Promise))(function(resolve3, reject) {
5423
5423
  function fulfilled(value) {
5424
5424
  try {
5425
5425
  step(generator.next(value));
@@ -5435,7 +5435,7 @@ var require_tslib = __commonJS((exports, module) => {
5435
5435
  }
5436
5436
  }
5437
5437
  function step(result) {
5438
- result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
5438
+ result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
5439
5439
  }
5440
5440
  step((generator = generator.apply(thisArg, _arguments || [])).next());
5441
5441
  });
@@ -5664,14 +5664,14 @@ var require_tslib = __commonJS((exports, module) => {
5664
5664
  }, i);
5665
5665
  function verb(n) {
5666
5666
  i[n] = o[n] && function(v) {
5667
- return new Promise(function(resolve2, reject) {
5668
- v = o[n](v), settle(resolve2, reject, v.done, v.value);
5667
+ return new Promise(function(resolve3, reject) {
5668
+ v = o[n](v), settle(resolve3, reject, v.done, v.value);
5669
5669
  });
5670
5670
  };
5671
5671
  }
5672
- function settle(resolve2, reject, d, v) {
5672
+ function settle(resolve3, reject, d, v) {
5673
5673
  Promise.resolve(v).then(function(v2) {
5674
- resolve2({ value: v2, done: d });
5674
+ resolve3({ value: v2, done: d });
5675
5675
  }, reject);
5676
5676
  }
5677
5677
  };
@@ -15357,7 +15357,7 @@ var require_dist_cjs31 = __commonJS((exports) => {
15357
15357
  this.refillTokenBucket();
15358
15358
  if (amount > this.currentCapacity) {
15359
15359
  const delay = (amount - this.currentCapacity) / this.fillRate * 1000;
15360
- await new Promise((resolve2) => DefaultRateLimiter.setTimeoutFn(resolve2, delay));
15360
+ await new Promise((resolve3) => DefaultRateLimiter.setTimeoutFn(resolve3, delay));
15361
15361
  }
15362
15362
  this.currentCapacity = this.currentCapacity - amount;
15363
15363
  }
@@ -15651,7 +15651,7 @@ var require_dist_cjs32 = __commonJS((exports) => {
15651
15651
  }
15652
15652
  }
15653
15653
  }
15654
- var USER_AGENT = "user-agent";
15654
+ var USER_AGENT2 = "user-agent";
15655
15655
  var X_AMZ_USER_AGENT = "x-amz-user-agent";
15656
15656
  var SPACE = " ";
15657
15657
  var UA_NAME_SEPARATOR = "/";
@@ -15699,9 +15699,9 @@ var require_dist_cjs32 = __commonJS((exports) => {
15699
15699
  ].join(SPACE);
15700
15700
  if (options.runtime !== "browser") {
15701
15701
  if (normalUAValue) {
15702
- headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT]} ${normalUAValue}` : normalUAValue;
15702
+ headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT2]} ${normalUAValue}` : normalUAValue;
15703
15703
  }
15704
- headers[USER_AGENT] = sdkUserAgentValue;
15704
+ headers[USER_AGENT2] = sdkUserAgentValue;
15705
15705
  } else {
15706
15706
  headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
15707
15707
  }
@@ -16803,7 +16803,7 @@ var require_dist_cjs40 = __commonJS((exports) => {
16803
16803
  const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
16804
16804
  const delay = Math.max(delayFromResponse || 0, delayFromDecider);
16805
16805
  totalDelay += delay;
16806
- await new Promise((resolve2) => setTimeout(resolve2, delay));
16806
+ await new Promise((resolve3) => setTimeout(resolve3, delay));
16807
16807
  continue;
16808
16808
  }
16809
16809
  if (!err.$metadata) {
@@ -16955,7 +16955,7 @@ var require_dist_cjs40 = __commonJS((exports) => {
16955
16955
  attempts = retryToken.getRetryCount();
16956
16956
  const delay = retryToken.getRetryDelay();
16957
16957
  totalRetryDelay += delay;
16958
- await new Promise((resolve2) => setTimeout(resolve2, delay));
16958
+ await new Promise((resolve3) => setTimeout(resolve3, delay));
16959
16959
  }
16960
16960
  }
16961
16961
  } else {
@@ -17078,7 +17078,7 @@ var init_dist_es = __esm(() => {
17078
17078
  import { Buffer as Buffer2 } from "buffer";
17079
17079
  import { request } from "http";
17080
17080
  function httpRequest(options) {
17081
- return new Promise((resolve2, reject) => {
17081
+ return new Promise((resolve3, reject) => {
17082
17082
  const req = request({
17083
17083
  method: "GET",
17084
17084
  ...options,
@@ -17103,7 +17103,7 @@ function httpRequest(options) {
17103
17103
  chunks.push(chunk);
17104
17104
  });
17105
17105
  res.on("end", () => {
17106
- resolve2(Buffer2.concat(chunks));
17106
+ resolve3(Buffer2.concat(chunks));
17107
17107
  req.destroy();
17108
17108
  });
17109
17109
  });
@@ -17564,7 +17564,7 @@ var retryWrapper = (toRetry, maxRetries, delayMs) => {
17564
17564
  try {
17565
17565
  return await toRetry();
17566
17566
  } catch (e) {
17567
- await new Promise((resolve2) => setTimeout(resolve2, delayMs));
17567
+ await new Promise((resolve3) => setTimeout(resolve3, delayMs));
17568
17568
  }
17569
17569
  }
17570
17570
  return await toRetry();
@@ -17874,12 +17874,12 @@ var require_dist_cjs41 = __commonJS((exports) => {
17874
17874
  }
17875
17875
  return ["md/nodejs", node_process.versions.node];
17876
17876
  };
17877
- var getNodeModulesParentDirs = (dirname3) => {
17877
+ var getNodeModulesParentDirs = (dirname4) => {
17878
17878
  const cwd = process.cwd();
17879
- if (!dirname3) {
17879
+ if (!dirname4) {
17880
17880
  return [cwd];
17881
17881
  }
17882
- const normalizedPath = node_path.normalize(dirname3);
17882
+ const normalizedPath = node_path.normalize(dirname4);
17883
17883
  const parts = normalizedPath.split(node_path.sep);
17884
17884
  const nodeModulesIndex = parts.indexOf("node_modules");
17885
17885
  const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : normalizedPath;
@@ -17926,8 +17926,8 @@ var require_dist_cjs41 = __commonJS((exports) => {
17926
17926
  tscVersion = null;
17927
17927
  return;
17928
17928
  }
17929
- const dirname3 = typeof __dirname !== "undefined" ? __dirname : undefined;
17930
- const nodeModulesParentDirs = getNodeModulesParentDirs(dirname3);
17929
+ const dirname4 = typeof __dirname !== "undefined" ? __dirname : undefined;
17930
+ const nodeModulesParentDirs = getNodeModulesParentDirs(dirname4);
17931
17931
  let versionFromApp;
17932
17932
  for (const nodeModulesParentDir of nodeModulesParentDirs) {
17933
17933
  try {
@@ -23670,7 +23670,7 @@ var require_signin = __commonJS((exports) => {
23670
23670
  import { createHash, createPrivateKey, createPublicKey, sign } from "crypto";
23671
23671
  import { promises as fs2 } from "fs";
23672
23672
  import { homedir as homedir6 } from "os";
23673
- import { dirname as dirname3, join as join7 } from "path";
23673
+ import { dirname as dirname4, join as join7 } from "path";
23674
23674
  var import_property_provider18, import_protocol_http2, import_shared_ini_file_loader6, LoginCredentialsFetcher;
23675
23675
  var init_LoginCredentialsFetcher = __esm(() => {
23676
23676
  import_property_provider18 = __toESM(require_dist_cjs23(), 1);
@@ -23823,7 +23823,7 @@ var init_LoginCredentialsFetcher = __esm(() => {
23823
23823
  }
23824
23824
  async saveToken(token) {
23825
23825
  const tokenFilePath = this.getTokenFilePath();
23826
- const directory = dirname3(tokenFilePath);
23826
+ const directory = dirname4(tokenFilePath);
23827
23827
  try {
23828
23828
  await fs2.mkdir(directory, { recursive: true });
23829
23829
  } catch (error) {}
@@ -24139,7 +24139,7 @@ var fromWebToken = (init) => async (awsIdentityProperties) => {
24139
24139
  };
24140
24140
 
24141
24141
  // node_modules/@aws-sdk/credential-provider-web-identity/dist-es/fromTokenFile.js
24142
- import { readFileSync as readFileSync2 } from "fs";
24142
+ import { readFileSync as readFileSync3 } from "fs";
24143
24143
  var import_client12, import_property_provider21, import_shared_ini_file_loader10, ENV_TOKEN_FILE = "AWS_WEB_IDENTITY_TOKEN_FILE", ENV_ROLE_ARN = "AWS_ROLE_ARN", ENV_ROLE_SESSION_NAME = "AWS_ROLE_SESSION_NAME", fromTokenFile = (init = {}) => async (awsIdentityProperties) => {
24144
24144
  init.logger?.debug("@aws-sdk/credential-provider-web-identity - fromTokenFile");
24145
24145
  const webIdentityTokenFile = init?.webIdentityTokenFile ?? process.env[ENV_TOKEN_FILE];
@@ -24152,7 +24152,7 @@ var import_client12, import_property_provider21, import_shared_ini_file_loader10
24152
24152
  }
24153
24153
  const credentials = await fromWebToken({
24154
24154
  ...init,
24155
- webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync2(webIdentityTokenFile, { encoding: "ascii" }),
24155
+ webIdentityToken: import_shared_ini_file_loader10.externalDataInterceptor?.getTokenRecord?.()[webIdentityTokenFile] ?? readFileSync3(webIdentityTokenFile, { encoding: "ascii" }),
24156
24156
  roleArn,
24157
24157
  roleSessionName
24158
24158
  })(awsIdentityProperties);
@@ -33944,11 +33944,14 @@ function listDomains(options = {}) {
33944
33944
  sql += " WHERE " + conditions.join(" AND ");
33945
33945
  }
33946
33946
  sql += " ORDER BY name";
33947
- if (options.limit) {
33947
+ if (options.limit !== undefined) {
33948
33948
  sql += " LIMIT ?";
33949
33949
  params.push(options.limit);
33950
33950
  }
33951
- if (options.offset) {
33951
+ if (options.offset !== undefined && options.offset > 0) {
33952
+ if (options.limit === undefined) {
33953
+ sql += " LIMIT -1";
33954
+ }
33952
33955
  sql += " OFFSET ?";
33953
33956
  params.push(options.offset);
33954
33957
  }
@@ -34175,6 +34178,28 @@ function deleteAlert(id) {
34175
34178
  }
34176
34179
  // src/db/dns-tools.ts
34177
34180
  import { execSync } from "child_process";
34181
+
34182
+ // src/lib/version.ts
34183
+ import { readFileSync as readFileSync2 } from "fs";
34184
+ import { dirname as dirname3, resolve as resolve2 } from "path";
34185
+ import { fileURLToPath } from "url";
34186
+ var cachedVersion = null;
34187
+ function getPackageVersion() {
34188
+ if (cachedVersion)
34189
+ return cachedVersion;
34190
+ try {
34191
+ const moduleDir = dirname3(fileURLToPath(import.meta.url));
34192
+ const packageJsonPath = resolve2(moduleDir, "../../package.json");
34193
+ const pkg = JSON.parse(readFileSync2(packageJsonPath, "utf8"));
34194
+ cachedVersion = pkg.version ?? "0.0.0";
34195
+ } catch {
34196
+ cachedVersion = "0.0.0";
34197
+ }
34198
+ return cachedVersion;
34199
+ }
34200
+ var USER_AGENT = `open-domains/${getPackageVersion()}`;
34201
+
34202
+ // src/db/dns-tools.ts
34178
34203
  function whoisLookup(domainName) {
34179
34204
  let raw;
34180
34205
  try {
@@ -34388,7 +34413,7 @@ async function discoverSubdomains(domain) {
34388
34413
  const url = `https://crt.sh/?q=%25.${encodeURIComponent(domain)}&output=json`;
34389
34414
  const response = await fetch(url, {
34390
34415
  signal: AbortSignal.timeout(15000),
34391
- headers: { "User-Agent": "open-domains/0.0.1" }
34416
+ headers: { "User-Agent": USER_AGENT }
34392
34417
  });
34393
34418
  if (!response.ok) {
34394
34419
  return {
@@ -41824,7 +41849,7 @@ async function apiRequest3(method, path, apiKey, body, baseUrl = BRANDSIGHT_BASE
41824
41849
  Authorization: `Bearer ${apiKey}`,
41825
41850
  "Content-Type": "application/json",
41826
41851
  Accept: "application/json",
41827
- "User-Agent": "open-domains/0.0.3"
41852
+ "User-Agent": USER_AGENT
41828
41853
  };
41829
41854
  try {
41830
41855
  const response = await fetchFn(url, {
@@ -41851,7 +41876,7 @@ async function apiGet(path, apiKey, baseUrl = BRANDSIGHT_BASE) {
41851
41876
  Authorization: `Bearer ${apiKey}`,
41852
41877
  "Content-Type": "application/json",
41853
41878
  Accept: "application/json",
41854
- "User-Agent": "open-domains/0.0.3"
41879
+ "User-Agent": USER_AGENT
41855
41880
  };
41856
41881
  try {
41857
41882
  const response = await fetchFn(url, {
@@ -42269,7 +42294,7 @@ function autoDetectRegistrar(domain, getDomainByName2) {
42269
42294
  }
42270
42295
 
42271
42296
  // src/lib/config.ts
42272
- import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
42297
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
42273
42298
  import { homedir as homedir8 } from "os";
42274
42299
  import { join as join8 } from "path";
42275
42300
  function configPath() {
@@ -42280,7 +42305,7 @@ function loadConfig3() {
42280
42305
  if (!existsSync6(path))
42281
42306
  return {};
42282
42307
  try {
42283
- return JSON.parse(readFileSync3(path, "utf-8"));
42308
+ return JSON.parse(readFileSync4(path, "utf-8"));
42284
42309
  } catch {
42285
42310
  return {};
42286
42311
  }
@@ -42331,10 +42356,25 @@ function resolveContact(opts) {
42331
42356
  // src/cli/commands/domain.ts
42332
42357
  function registerDomainCommand(program2) {
42333
42358
  const domain = program2.command("domain").description("Domain portfolio management");
42334
- domain.command("list").description("List all domains in the portfolio").option("--status <status>", "Filter by status (active/expired/transferring/redemption)").option("--registrar <name>", "Filter by registrar").option("--json", "Output JSON").action((opts) => {
42335
- const domains = listDomains({ status: opts.status, registrar: opts.registrar });
42359
+ domain.command("list").description("List all domains in the portfolio").option("--status <status>", "Filter by status (active/expired/transferring/redemption)").option("--registrar <name>", "Filter by registrar").option("--limit <n>", "Limit number of returned domains").option("--offset <n>", "Skip first N domains", "0").option("-j, --json", "Output JSON").action((opts) => {
42360
+ const limit = opts.limit ? parseInt(opts.limit, 10) : undefined;
42361
+ const offset = opts.offset ? parseInt(opts.offset, 10) : 0;
42362
+ if (limit !== undefined && (!Number.isInteger(limit) || limit < 0)) {
42363
+ console.error("--limit must be a non-negative integer");
42364
+ process.exit(1);
42365
+ }
42366
+ if (!Number.isInteger(offset) || offset < 0) {
42367
+ console.error("--offset must be a non-negative integer");
42368
+ process.exit(1);
42369
+ }
42370
+ const domains = listDomains({
42371
+ status: opts.status,
42372
+ registrar: opts.registrar,
42373
+ limit,
42374
+ offset
42375
+ });
42336
42376
  if (opts.json) {
42337
- console.log(JSON.stringify({ domains, count: domains.length }, null, 2));
42377
+ console.log(JSON.stringify({ domains, count: domains.length, limit: limit ?? null, offset }, null, 2));
42338
42378
  return;
42339
42379
  }
42340
42380
  if (domains.length === 0) {
@@ -42347,8 +42387,11 @@ function registerDomainCommand(program2) {
42347
42387
  }
42348
42388
  console.log(`
42349
42389
  ${domains.length} domain(s)`);
42390
+ if (limit !== undefined || offset > 0) {
42391
+ console.log(`Page: limit=${limit ?? "all"}, offset=${offset}`);
42392
+ }
42350
42393
  });
42351
- domain.command("get <id>").description("Get a domain by ID").option("--json", "Output JSON").action((id, opts) => {
42394
+ domain.command("get <id>").description("Get a domain by ID").option("-j, --json", "Output JSON").action((id, opts) => {
42352
42395
  const d3 = getDomain(id);
42353
42396
  if (!d3) {
42354
42397
  console.error(`Domain '${id}' not found.`);
@@ -42369,7 +42412,7 @@ ${d3.name} [${d3.status}]`);
42369
42412
  console.log(` Notes: ${d3.notes}`);
42370
42413
  console.log();
42371
42414
  });
42372
- domain.command("add").description("Add a domain to the portfolio").requiredOption("--name <name>", "Domain name").option("--registrar <name>", "Registrar name").option("--status <s>", "Status (active/expired/transferring/redemption)", "active").option("--expires <date>", "Expiry date (YYYY-MM-DD)").option("--notes <text>", "Notes").option("--json", "Output JSON").action((opts) => {
42415
+ domain.command("add").description("Add a domain to the portfolio").requiredOption("--name <name>", "Domain name").option("--registrar <name>", "Registrar name").option("--status <s>", "Status (active/expired/transferring/redemption)", "active").option("--expires <date>", "Expiry date (YYYY-MM-DD)").option("--notes <text>", "Notes").option("-j, --json", "Output JSON").action((opts) => {
42373
42416
  const d3 = createDomain({
42374
42417
  name: opts.name,
42375
42418
  registrar: opts.registrar,
@@ -42383,7 +42426,7 @@ ${d3.name} [${d3.status}]`);
42383
42426
  }
42384
42427
  console.log(`Created domain: ${d3.name} (${d3.id})`);
42385
42428
  });
42386
- domain.command("update <id>").description("Update a domain").option("--registrar <name>", "Registrar").option("--status <s>", "Status").option("--expires <date>", "Expiry date").option("--notes <text>", "Notes").option("--json", "Output JSON").action((id, opts) => {
42429
+ domain.command("update <id>").description("Update a domain").option("--registrar <name>", "Registrar").option("--status <s>", "Status").option("--expires <date>", "Expiry date").option("--notes <text>", "Notes").option("-j, --json", "Output JSON").action((id, opts) => {
42387
42430
  const d3 = updateDomain(id, {
42388
42431
  registrar: opts.registrar,
42389
42432
  status: opts.status,
@@ -42400,16 +42443,34 @@ ${d3.name} [${d3.status}]`);
42400
42443
  }
42401
42444
  console.log(`Updated: ${d3.name}`);
42402
42445
  });
42403
- domain.command("delete <id>").description("Delete a domain from the portfolio").action((id) => {
42446
+ domain.command("delete <id>").description("Delete a domain from the portfolio").option("-f, --force", "Required confirmation for destructive delete").option("-j, --json", "Output JSON").action((id, opts) => {
42447
+ if (!opts.force) {
42448
+ const message = `Refusing to delete domain '${id}' without --force.`;
42449
+ if (opts.json) {
42450
+ console.log(JSON.stringify({ deleted: false, id, error: message }, null, 2));
42451
+ } else {
42452
+ console.error(message);
42453
+ console.error("Re-run with --force to confirm deletion.");
42454
+ }
42455
+ process.exit(1);
42456
+ }
42404
42457
  const deleted = deleteDomain(id);
42405
- if (deleted)
42406
- console.log(`Deleted domain ${id}`);
42407
- else {
42408
- console.error(`Domain '${id}' not found.`);
42458
+ if (!deleted) {
42459
+ const message = `Domain '${id}' not found.`;
42460
+ if (opts.json) {
42461
+ console.log(JSON.stringify({ deleted: false, id, error: message }, null, 2));
42462
+ } else {
42463
+ console.error(message);
42464
+ }
42409
42465
  process.exit(1);
42410
42466
  }
42467
+ if (opts.json) {
42468
+ console.log(JSON.stringify({ deleted: true, id }, null, 2));
42469
+ return;
42470
+ }
42471
+ console.log(`Deleted domain ${id}`);
42411
42472
  });
42412
- domain.command("search <query>").description("Search domains by name, registrar, or notes").option("--json", "Output JSON").action((query, opts) => {
42473
+ domain.command("search <query>").description("Search domains by name, registrar, or notes").option("-j, --json", "Output JSON").action((query, opts) => {
42413
42474
  const results = searchDomains(query);
42414
42475
  if (opts.json) {
42415
42476
  console.log(JSON.stringify({ results, count: results.length }, null, 2));
@@ -42420,7 +42481,7 @@ ${d3.name} [${d3.status}]`);
42420
42481
  if (results.length === 0)
42421
42482
  console.log("No results.");
42422
42483
  });
42423
- domain.command("expiring").description("List domains expiring soon").option("--days <n>", "Days threshold", "30").option("--json", "Output JSON").action((opts) => {
42484
+ domain.command("expiring").description("List domains expiring soon").option("--days <n>", "Days threshold", "30").option("-j, --json", "Output JSON").action((opts) => {
42424
42485
  const domains = listExpiring(parseInt(opts.days));
42425
42486
  if (opts.json) {
42426
42487
  console.log(JSON.stringify(domains, null, 2));
@@ -42436,7 +42497,7 @@ Expiring within ${opts.days} days:`);
42436
42497
  console.log(` ${d3.name.padEnd(40)} expires ${(d3.expires_at ?? "").split("T")[0]}`);
42437
42498
  console.log();
42438
42499
  });
42439
- domain.command("stats").description("Show portfolio statistics").option("--json", "Output JSON").action((opts) => {
42500
+ domain.command("stats").description("Show portfolio statistics").option("-j, --json", "Output JSON").action((opts) => {
42440
42501
  const stats = getDomainStats();
42441
42502
  if (opts.json) {
42442
42503
  console.log(JSON.stringify(stats, null, 2));
@@ -42447,7 +42508,7 @@ Expiring within ${opts.days} days:`);
42447
42508
  console.log(` ${k3.replace(/_/g, " ")}: ${v3}`);
42448
42509
  }
42449
42510
  });
42450
- domain.command("whois <name>").description("Run WHOIS lookup and update local DB record").option("--json", "Output JSON").action((name, opts) => {
42511
+ domain.command("whois <name>").description("Run WHOIS lookup and update local DB record").option("-j, --json", "Output JSON").action((name, opts) => {
42451
42512
  const result = whoisLookup(name);
42452
42513
  if (opts.json) {
42453
42514
  console.log(JSON.stringify(result, null, 2));
@@ -42650,7 +42711,7 @@ Setting up ${name}`);
42650
42711
  }
42651
42712
 
42652
42713
  // src/cli/commands/dns.ts
42653
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
42714
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync3 } from "fs";
42654
42715
  function registerDnsCommands(program2) {
42655
42716
  const dnsCmd = program2.command("dns").description("DNS record management");
42656
42717
  dnsCmd.command("list").description("List DNS records for a domain").argument("<domain-id>", "Domain ID").option("--type <type>", "Filter by record type (A/AAAA/CNAME/MX/TXT/NS/SRV)").option("--json", "Output as JSON", false).action((domainId, opts) => {
@@ -42745,7 +42806,7 @@ function registerDnsCommands(program2) {
42745
42806
  dnsCmd.command("import").description("Import DNS records from a BIND zone file").argument("<domain-id>", "Domain ID").requiredOption("--file <path>", "Path to zone file").option("--json", "Output as JSON", false).action((domainId, opts) => {
42746
42807
  let content;
42747
42808
  try {
42748
- content = readFileSync4(opts.file, "utf-8");
42809
+ content = readFileSync5(opts.file, "utf-8");
42749
42810
  } catch {
42750
42811
  console.error(`Could not read file: ${opts.file}`);
42751
42812
  process.exit(1);
@@ -43234,29 +43295,41 @@ Configuration (~/.hasna/domains/config.json):`);
43234
43295
  // src/cli/commands/doctor.ts
43235
43296
  import { execSync as execSync2 } from "child_process";
43236
43297
  function registerDoctorCommand(program2) {
43237
- program2.command("doctor").description("Run diagnostics \u2014 check credentials, DB, and provider connectivity").action(async () => {
43298
+ program2.command("doctor").description("Run diagnostics \u2014 check credentials, DB, and provider connectivity").option("--json", "Output structured JSON").action(async (opts) => {
43238
43299
  let passed = 0;
43239
43300
  let failed = 0;
43301
+ const checks = [];
43302
+ let currentSection = "general";
43303
+ function section(name) {
43304
+ currentSection = name;
43305
+ if (!opts.json) {
43306
+ console.log(`
43307
+ \u2500\u2500 ${name} \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
43308
+ }
43309
+ }
43240
43310
  function ok(msg) {
43241
- console.log(` \u2713 ${msg}`);
43311
+ checks.push({ section: currentSection, status: "pass", message: msg });
43312
+ if (!opts.json)
43313
+ console.log(` \u2713 ${msg}`);
43242
43314
  passed++;
43243
43315
  }
43244
43316
  function fail(msg, fix) {
43245
- console.log(` \u2717 ${msg}`);
43246
- if (fix)
43247
- console.log(` \u2192 ${fix}`);
43317
+ checks.push({ section: currentSection, status: "fail", message: msg, fix });
43318
+ if (!opts.json) {
43319
+ console.log(` \u2717 ${msg}`);
43320
+ if (fix)
43321
+ console.log(` \u2192 ${fix}`);
43322
+ }
43248
43323
  failed++;
43249
43324
  }
43250
- console.log(`
43251
- \u2500\u2500 Database \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
43325
+ section("Database");
43252
43326
  try {
43253
43327
  const count = countDomains();
43254
43328
  ok(`Local DB accessible (${count} domain${count !== 1 ? "s" : ""})`);
43255
- } catch (e3) {
43256
- fail("Local DB not accessible", `Check ~/.hasna/domains/domains.db`);
43329
+ } catch {
43330
+ fail("Local DB not accessible", "Check ~/.hasna/domains/domains.db");
43257
43331
  }
43258
- console.log(`
43259
- \u2500\u2500 Config \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
43332
+ section("Config");
43260
43333
  const cfg = loadConfig3();
43261
43334
  if (cfg.default_registrar)
43262
43335
  ok(`default-registrar: ${cfg.default_registrar}`);
@@ -43272,8 +43345,7 @@ function registerDoctorCommand(program2) {
43272
43345
  ok("Registrant contact info complete");
43273
43346
  else
43274
43347
  fail(`Missing contact fields: ${missingContact.join(", ")}`, "domains config set contact.<field> <value>");
43275
- console.log(`
43276
- \u2500\u2500 Providers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
43348
+ section("Providers");
43277
43349
  const providers = getAvailableProviders().filter((p3) => p3.name !== "brandsight");
43278
43350
  for (const p3 of providers) {
43279
43351
  if (!p3.configured) {
@@ -43298,25 +43370,33 @@ function registerDoctorCommand(program2) {
43298
43370
  }
43299
43371
  }
43300
43372
  }
43301
- console.log(`
43302
- \u2500\u2500 Tools \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
43373
+ section("Tools");
43303
43374
  try {
43304
43375
  execSync2("whois --version 2>/dev/null || whois example.com 2>/dev/null", { timeout: 3000 });
43305
43376
  ok("whois binary found");
43306
43377
  } catch {
43307
43378
  fail("whois not installed", "apt install whois / brew install whois");
43308
43379
  }
43309
- console.log(`
43380
+ if (opts.json) {
43381
+ console.log(JSON.stringify({
43382
+ passed,
43383
+ failed,
43384
+ healthy: failed === 0,
43385
+ checks
43386
+ }, null, 2));
43387
+ } else {
43388
+ console.log(`
43310
43389
  ${"\u2500".repeat(45)}`);
43311
- console.log(` ${passed} passed / ${failed} failed
43390
+ console.log(` ${passed} passed / ${failed} failed
43312
43391
  `);
43392
+ }
43313
43393
  if (failed > 0)
43314
43394
  process.exit(1);
43315
43395
  });
43316
43396
  }
43317
43397
 
43318
43398
  // src/cli/commands/mcp-install.ts
43319
- import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
43399
+ import { existsSync as existsSync7, readFileSync as readFileSync6, writeFileSync as writeFileSync4 } from "fs";
43320
43400
  import { homedir as homedir9 } from "os";
43321
43401
  import { join as join9 } from "path";
43322
43402
  import { execSync as execSync3 } from "child_process";
@@ -43343,7 +43423,7 @@ function registerMcpCommand(program2) {
43343
43423
  let config = {};
43344
43424
  if (existsSync7(configPath2)) {
43345
43425
  try {
43346
- config = JSON.parse(readFileSync5(configPath2, "utf-8"));
43426
+ config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43347
43427
  } catch {
43348
43428
  config = {};
43349
43429
  }
@@ -43365,7 +43445,7 @@ function registerMcpCommand(program2) {
43365
43445
  console.log("Config file not found \u2014 nothing to remove.");
43366
43446
  return;
43367
43447
  }
43368
- const config = JSON.parse(readFileSync5(configPath2, "utf-8"));
43448
+ const config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43369
43449
  const mcpServers = config.mcpServers;
43370
43450
  if (!mcpServers?.[MCP_SERVER_NAME]) {
43371
43451
  console.log(`MCP server '${MCP_SERVER_NAME}' is not registered.`);
@@ -43383,7 +43463,7 @@ function registerMcpCommand(program2) {
43383
43463
  continue;
43384
43464
  }
43385
43465
  try {
43386
- const config = JSON.parse(readFileSync5(configPath2, "utf-8"));
43466
+ const config = JSON.parse(readFileSync6(configPath2, "utf-8"));
43387
43467
  const mcpServers = config.mcpServers;
43388
43468
  if (mcpServers?.[MCP_SERVER_NAME]) {
43389
43469
  console.log(` ${label}: \u2713 registered`);
@@ -43399,6 +43479,7 @@ function registerMcpCommand(program2) {
43399
43479
 
43400
43480
  // src/cli/commands/serve.ts
43401
43481
  function registerServeCommand(program2) {
43482
+ const packageVersion = getPackageVersion();
43402
43483
  program2.command("serve").description("Start HTTP API server").option("--port <n>", "Port to listen on", "3000").option("--host <h>", "Host to bind to", "127.0.0.1").action(async (opts) => {
43403
43484
  const port = parseInt(opts.port);
43404
43485
  const server = Bun.serve({
@@ -43415,7 +43496,7 @@ function registerServeCommand(program2) {
43415
43496
  const notFound = () => json({ error: "Not found" }, 404);
43416
43497
  try {
43417
43498
  if (method === "GET" && path === "/health") {
43418
- return json({ status: "ok", version: "0.0.3" });
43499
+ return json({ status: "ok", version: packageVersion });
43419
43500
  }
43420
43501
  if (method === "GET" && path === "/domains") {
43421
43502
  const search = url.searchParams.get("search") ?? undefined;
@@ -43483,7 +43564,7 @@ function registerServeCommand(program2) {
43483
43564
  }
43484
43565
 
43485
43566
  // src/cli/commands/route53.ts
43486
- import { readFileSync as readFileSync6 } from "fs";
43567
+ import { readFileSync as readFileSync7 } from "fs";
43487
43568
  function registerRoute53Commands(program2) {
43488
43569
  const r53 = program2.command("r53").description("AWS Route 53 \u2014 domain purchase, hosted zones & DNS");
43489
43570
  r53.command("check <domains...>").description("Check if one or more domains are available for purchase").action(async (domains) => {
@@ -43772,7 +43853,7 @@ DNS Records for ${domain}:`);
43772
43853
  try {
43773
43854
  let raw;
43774
43855
  try {
43775
- raw = readFileSync6(opts.file, "utf-8");
43856
+ raw = readFileSync7(opts.file, "utf-8");
43776
43857
  } catch {
43777
43858
  console.error(`Could not read file: ${opts.file}`);
43778
43859
  process.exit(1);
@@ -43884,7 +43965,7 @@ DNS Records for ${domain}:`);
43884
43965
 
43885
43966
  // src/cli/index.ts
43886
43967
  var program2 = new Command;
43887
- program2.name("domains").description("Domain portfolio and DNS management for AI agents").version("0.0.4");
43968
+ program2.name("domains").description("Domain portfolio and DNS management for AI agents").version(getPackageVersion());
43888
43969
  registerDomainCommand(program2);
43889
43970
  registerDnsCommands(program2);
43890
43971
  registerZoneCommand(program2);