@hasna/domains 0.0.18 → 0.0.19

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.
@@ -1 +1 @@
1
- {"version":3,"file":"route53.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/route53.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAogB9D"}
1
+ {"version":3,"file":"route53.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/route53.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyBzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmhB9D"}
package/dist/cli/index.js CHANGED
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __returnValue = (v) => v;
35
+ function __exportSetter(name, newValue) {
36
+ this[name] = __returnValue.bind(null, newValue);
37
+ }
20
38
  var __export = (target, all) => {
21
39
  for (var name in all)
22
40
  __defProp(target, name, {
23
41
  get: all[name],
24
42
  enumerable: true,
25
43
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
44
+ set: __exportSetter.bind(all, name)
27
45
  });
28
46
  };
29
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -19531,7 +19549,7 @@ var require_package = __commonJS((exports, module) => {
19531
19549
 
19532
19550
  // node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
19533
19551
  var require_dist_cjs41 = __commonJS((exports) => {
19534
- var __dirname = "/Users/hasna/Workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
19552
+ var __dirname = "/home/hasna/workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
19535
19553
  var node_os = __require("os");
19536
19554
  var node_process = __require("process");
19537
19555
  var utilConfigProvider = require_dist_cjs33();
@@ -38061,9 +38079,47 @@ function registerServeCommand(program2) {
38061
38079
 
38062
38080
  // src/cli/commands/route53.ts
38063
38081
  init_route53();
38082
+ import { readFileSync as readFileSync6 } from "fs";
38083
+
38084
+ // src/lib/zone-setup.ts
38085
+ function nameserversMatch(a3, b3) {
38086
+ const norm = (ns) => new Set(ns.map((n3) => n3.trim().toLowerCase().replace(/\.$/, "")));
38087
+ const sa = norm(a3);
38088
+ const sb = norm(b3);
38089
+ if (sa.size !== sb.size)
38090
+ return false;
38091
+ for (const n3 of sa)
38092
+ if (!sb.has(n3))
38093
+ return false;
38094
+ return true;
38095
+ }
38096
+ async function setupDomainZone(domain, deps) {
38097
+ const log = deps.log ?? (() => {});
38098
+ const existing = await deps.findExistingZone(domain);
38099
+ let zone;
38100
+ let created;
38101
+ if (existing) {
38102
+ zone = existing;
38103
+ created = false;
38104
+ log("zone_reused", { domain, zoneId: zone.id });
38105
+ } else {
38106
+ zone = await deps.createZone(domain);
38107
+ created = true;
38108
+ log("zone_created", { domain, zoneId: zone.id });
38109
+ }
38110
+ let nsUpdated = false;
38111
+ const registrarNs = await deps.getRegistrarNs(domain);
38112
+ if (!nameserversMatch(registrarNs, zone.name_servers)) {
38113
+ await deps.setRegistrarNs(domain, zone.name_servers);
38114
+ nsUpdated = true;
38115
+ log("ns_aligned", { domain, zoneId: zone.id, nameservers: zone.name_servers });
38116
+ }
38117
+ return { zoneId: zone.id, nameServers: zone.name_servers, created, nsUpdated };
38118
+ }
38119
+
38120
+ // src/cli/commands/route53.ts
38064
38121
  init_domains();
38065
38122
  init_config();
38066
- import { readFileSync as readFileSync6 } from "fs";
38067
38123
  function registerRoute53Commands(program2) {
38068
38124
  const r53 = program2.command("r53").description("AWS Route 53 \u2014 domain purchase, hosted zones & DNS");
38069
38125
  r53.command("check <domains...>").description("Check if one or more domains are available for purchase").action(async (domains) => {
@@ -38411,46 +38467,55 @@ DNS Records for ${domain}:`);
38411
38467
  }
38412
38468
  const reg = await registerDomain(domain, contact, parseInt(opts.years));
38413
38469
  console.log(` \u2713 Submitted (operation: ${reg.operationId})`);
38414
- if (opts.wait) {
38415
- console.log(` Waiting for registration to complete...`);
38416
- let status = "IN_PROGRESS";
38417
- while (status === "IN_PROGRESS" || status === "SUBMITTED") {
38418
- await new Promise((r3) => setTimeout(r3, 1e4));
38419
- const s3 = await getRegistrationStatus(reg.operationId);
38420
- status = s3.status;
38421
- process.stdout.write(` Status: ${status}\r`);
38422
- }
38423
- console.log();
38424
- if (status !== "SUCCESSFUL") {
38425
- console.error(`\u2717 Registration ${status}`);
38426
- process.exit(1);
38427
- }
38428
- console.log(` \u2713 Registration complete`);
38470
+ console.log(` Waiting for registration to complete...`);
38471
+ let status = "IN_PROGRESS";
38472
+ while (status === "IN_PROGRESS" || status === "SUBMITTED") {
38473
+ await new Promise((r3) => setTimeout(r3, 1e4));
38474
+ const s3 = await getRegistrationStatus(reg.operationId);
38475
+ status = s3.status;
38476
+ process.stdout.write(` Status: ${status}\r`);
38477
+ }
38478
+ console.log();
38479
+ if (status !== "SUCCESSFUL") {
38480
+ console.error(`\u2717 Registration ${status}`);
38481
+ process.exit(1);
38429
38482
  }
38430
- console.log(`[3/4] Creating hosted zone...`);
38431
- const zone = await createHostedZone(domain, `Managed by @hasna/domains`);
38432
- console.log(` \u2713 Zone created (${zone.id})`);
38483
+ console.log(` \u2713 Registration complete`);
38484
+ console.log(`[3/4] Configuring hosted zone...`);
38485
+ const setup = await setupDomainZone(domain, {
38486
+ findExistingZone: async (d3) => {
38487
+ const z2 = await findHostedZoneByDomain(d3);
38488
+ if (!z2)
38489
+ return null;
38490
+ const full = await getHostedZone(z2.id);
38491
+ return { id: full.id, name_servers: full.name_servers };
38492
+ },
38493
+ createZone: async (d3) => {
38494
+ const z2 = await createHostedZone(d3, `Managed by @hasna/domains`);
38495
+ return { id: z2.id, name_servers: z2.name_servers ?? [] };
38496
+ },
38497
+ getRegistrarNs: async (d3) => (await getDomainDetail(d3)).nameservers,
38498
+ setRegistrarNs: async (d3, ns) => {
38499
+ await updateNameservers(d3, ns);
38500
+ }
38501
+ });
38502
+ console.log(` \u2713 Zone ${setup.created ? "created" : "reused"} (${setup.zoneId})` + (setup.nsUpdated ? ` \u2014 registry NS repointed to this zone` : ``));
38433
38503
  console.log(`[4/4] Adding to local database...`);
38434
38504
  createDomain({
38435
38505
  name: domain,
38436
38506
  registrar: "AWS Route 53",
38437
38507
  status: "active",
38438
38508
  auto_renew: true,
38439
- nameservers: zone.name_servers
38509
+ nameservers: setup.nameServers
38440
38510
  });
38441
38511
  console.log(` \u2713 Added to portfolio`);
38442
38512
  console.log(`
38443
38513
  \u2713 Full setup complete for ${domain}`);
38444
- if (!opts.wait) {
38445
- console.log(` Registration may take a few minutes.`);
38446
- console.log(` \u26A0 Hosted zone created before registration confirmed.`);
38447
- console.log(` If registration fails, clean up: domains r53 zone-delete ${zone.id} --force`);
38448
- }
38449
38514
  console.log(` Check: domains r53 status ${reg.operationId}`);
38450
- if (zone.name_servers && zone.name_servers.length > 0) {
38515
+ if (setup.nameServers && setup.nameServers.length > 0) {
38451
38516
  console.log(`
38452
38517
  Name servers:`);
38453
- for (const ns of zone.name_servers) {
38518
+ for (const ns of setup.nameServers) {
38454
38519
  console.log(` ${ns}`);
38455
38520
  }
38456
38521
  }
package/dist/index.js CHANGED
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
7
12
  var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
8
20
  target = mod != null ? __create(__getProtoOf(mod)) : {};
9
21
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
22
  for (let key of __getOwnPropNames(mod))
11
23
  if (!__hasOwnProp.call(to, key))
12
24
  __defProp(to, key, {
13
- get: () => mod[key],
25
+ get: __accessProp.bind(mod, key),
14
26
  enumerable: true
15
27
  });
28
+ if (canCache)
29
+ cache.set(mod, to);
16
30
  return to;
17
31
  };
18
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __returnValue = (v) => v;
34
+ function __exportSetter(name, newValue) {
35
+ this[name] = __returnValue.bind(null, newValue);
36
+ }
19
37
  var __export = (target, all) => {
20
38
  for (var name in all)
21
39
  __defProp(target, name, {
22
40
  get: all[name],
23
41
  enumerable: true,
24
42
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
43
+ set: __exportSetter.bind(all, name)
26
44
  });
27
45
  };
28
46
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -15805,7 +15823,7 @@ var require_package = __commonJS((exports, module) => {
15805
15823
 
15806
15824
  // node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
15807
15825
  var require_dist_cjs41 = __commonJS((exports) => {
15808
- var __dirname = "/Users/hasna/Workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
15826
+ var __dirname = "/home/hasna/workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
15809
15827
  var node_os = __require("os");
15810
15828
  var node_process = __require("process");
15811
15829
  var utilConfigProvider = require_dist_cjs33();
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Hosted-zone setup for a freshly registered domain.
3
+ *
4
+ * Route 53 AUTO-CREATES a hosted zone when a domain is registered, and the
5
+ * registry delegation already points at it. Blindly calling CreateHostedZone
6
+ * afterwards produces a SECOND zone with a different delegation set, leaving the
7
+ * domain delegated to the (now orphaned) auto zone — DNS records added to the
8
+ * new zone never resolve. This module reuses the existing zone when present and
9
+ * only ever creates one if none exists, then reconciles the registry NS to the
10
+ * managed zone so delegation is always correct.
11
+ *
12
+ * Dependency-injected (mirrors reconcileNsDrift) so the decision logic is unit
13
+ * testable without hitting AWS.
14
+ */
15
+ /** Order/case/trailing-dot-insensitive set comparison of two NS lists. */
16
+ export declare function nameserversMatch(a: string[], b: string[]): boolean;
17
+ export interface ZoneSetupDeps {
18
+ /** Find an existing hosted zone for the domain (including its NS), or null. */
19
+ findExistingZone: (domain: string) => Promise<{
20
+ id: string;
21
+ name_servers: string[];
22
+ } | null>;
23
+ /** Create a new hosted zone for the domain and return it (with NS). */
24
+ createZone: (domain: string) => Promise<{
25
+ id: string;
26
+ name_servers: string[];
27
+ }>;
28
+ /** Current registry/registrar nameservers for the domain. */
29
+ getRegistrarNs: (domain: string) => Promise<string[]>;
30
+ /** Point the registry/registrar delegation at the given nameservers. */
31
+ setRegistrarNs: (domain: string, ns: string[]) => Promise<void>;
32
+ log?: (event: string, detail: Record<string, unknown>) => void;
33
+ }
34
+ export interface ZoneSetupResult {
35
+ zoneId: string;
36
+ nameServers: string[];
37
+ /** true if a new zone was created, false if an existing one was reused. */
38
+ created: boolean;
39
+ /** true if the registry delegation had to be repointed at the managed zone. */
40
+ nsUpdated: boolean;
41
+ }
42
+ export declare function setupDomainZone(domain: string, deps: ZoneSetupDeps): Promise<ZoneSetupResult>;
43
+ //# sourceMappingURL=zone-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zone-setup.d.ts","sourceRoot":"","sources":["../../src/lib/zone-setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAQlE;AAED,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IAC7F,uEAAuE;IACvE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAChF,6DAA6D;IAC7D,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACtD,wEAAwE;IACxE,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAChE;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,2EAA2E;IAC3E,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,eAAe,CAAC,CA0B1B"}
package/dist/mcp/index.js CHANGED
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __returnValue = (v) => v;
35
+ function __exportSetter(name, newValue) {
36
+ this[name] = __returnValue.bind(null, newValue);
37
+ }
20
38
  var __export = (target, all) => {
21
39
  for (var name in all)
22
40
  __defProp(target, name, {
23
41
  get: all[name],
24
42
  enumerable: true,
25
43
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
44
+ set: __exportSetter.bind(all, name)
27
45
  });
28
46
  };
29
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -16055,7 +16073,7 @@ var require_package = __commonJS((exports, module) => {
16055
16073
 
16056
16074
  // node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
16057
16075
  var require_dist_cjs41 = __commonJS((exports) => {
16058
- var __dirname = "/Users/hasna/Workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
16076
+ var __dirname = "/home/hasna/workspace/hasna/opensource/open-domains/node_modules/@aws-sdk/util-user-agent-node/dist-cjs";
16059
16077
  var node_os = __require("os");
16060
16078
  var node_process = __require("process");
16061
16079
  var utilConfigProvider = require_dist_cjs33();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/domains",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Domain portfolio and DNS management for AI agents — CLI + MCP server with SQLite",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",