@aoxborrow/registrar-client 0.9.1 → 0.9.2

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/index.cjs CHANGED
@@ -4639,6 +4639,80 @@ function dnsFieldsDiffer(a, b) {
4639
4639
 
4640
4640
  // src/registrars/namebright.ts
4641
4641
  var TOKEN_URL = "https://api.namebright.com/auth/token";
4642
+ var NB_KEYS = new Map(
4643
+ [
4644
+ // domains
4645
+ "DomainName",
4646
+ "Status",
4647
+ "ExpirationDate",
4648
+ "RegistrationDate",
4649
+ "AutoRenew",
4650
+ "Locked",
4651
+ "WhoIsPrivacy",
4652
+ "AuthCode",
4653
+ "Category",
4654
+ "UpgradedDomain",
4655
+ "ResultsTotal",
4656
+ "CurrentPage",
4657
+ "Domains",
4658
+ "NameServers",
4659
+ // contacts
4660
+ "RegistrantContact",
4661
+ "AdministrativeContact",
4662
+ "TechnicalContact",
4663
+ "FirstName",
4664
+ "LastName",
4665
+ "Organization",
4666
+ "Department",
4667
+ "Email",
4668
+ "Address1",
4669
+ "Address2",
4670
+ "City",
4671
+ "Region",
4672
+ "Country",
4673
+ "PostalCode",
4674
+ "PhoneCountry",
4675
+ "Phone",
4676
+ "FaxCountry",
4677
+ "Fax",
4678
+ // host records
4679
+ "ARecords",
4680
+ "AAAARecords",
4681
+ "CNAMERecords",
4682
+ "MXRecords",
4683
+ "TXTRecords",
4684
+ "SRVRecords",
4685
+ "RecordId",
4686
+ "Subdomain",
4687
+ "IPV4Address",
4688
+ "IPV6Address",
4689
+ "RedirectDomain",
4690
+ "MailServer",
4691
+ "Priority",
4692
+ "TextRecord",
4693
+ "Service",
4694
+ "Protocol",
4695
+ "Weight",
4696
+ "Port",
4697
+ "Target",
4698
+ // availability + orders
4699
+ "ProductTypeName",
4700
+ "UnitPrice",
4701
+ "Promotion",
4702
+ "PromotionPrice",
4703
+ "Discount",
4704
+ "Description",
4705
+ "OrderId",
4706
+ "TotalPrice"
4707
+ ].map((k) => [k.toLowerCase(), k])
4708
+ );
4709
+ function canonicalKeys(value) {
4710
+ if (Array.isArray(value)) return value.map(canonicalKeys);
4711
+ if (value === null || typeof value !== "object") return value;
4712
+ return Object.fromEntries(
4713
+ Object.entries(value).map(([k, v]) => [NB_KEYS.get(k.toLowerCase()) ?? k, canonicalKeys(v)])
4714
+ );
4715
+ }
4642
4716
  var NameBrightRegistrar = class extends BaseRegistrar {
4643
4717
  name = "namebright";
4644
4718
  // a REST API: GET and HEAD never change state
@@ -4692,14 +4766,16 @@ var NameBrightRegistrar = class extends BaseRegistrar {
4692
4766
  this.tokenExpiresAt = now + ttlMs - 6e4;
4693
4767
  return this.token;
4694
4768
  }
4695
- // issue an authenticated REST request, attaching a fresh bearer token
4769
+ // issue an authenticated REST request, attaching a fresh bearer token. The
4770
+ // response's keys are normalized to PascalCase (see NB_KEYS).
4696
4771
  async authed(config, opts) {
4697
4772
  const token = await this.getToken(opts);
4698
- return this.http.request({
4773
+ const res = await this.http.request({
4699
4774
  ...config,
4700
4775
  headers: { Authorization: `Bearer ${token}` },
4701
4776
  ...opts
4702
4777
  });
4778
+ return canonicalKeys(res);
4703
4779
  }
4704
4780
  async testConnection(opts) {
4705
4781
  try {
@@ -4720,8 +4796,8 @@ var NameBrightRegistrar = class extends BaseRegistrar {
4720
4796
  { path: "account/domains", query: { page, domainsPerPage: perPage } },
4721
4797
  reqOpts
4722
4798
  );
4723
- const list = Array.isArray(data) ? data : data?.Domains ?? data?.domains ?? [];
4724
- for (const d of list) domains.push(this.toDomain(d));
4799
+ const list = Array.isArray(data) ? data : data?.Domains ?? [];
4800
+ for (const d of list) if (d.DomainName) domains.push(this.toDomain(d));
4725
4801
  hasMore = list.length === perPage;
4726
4802
  page++;
4727
4803
  }
@@ -4758,7 +4834,7 @@ var NameBrightRegistrar = class extends BaseRegistrar {
4758
4834
  opts
4759
4835
  );
4760
4836
  if (Array.isArray(res)) return res.map(String);
4761
- return (res.NameServers ?? res.Nameservers ?? res.nameservers ?? []).map(String);
4837
+ return (res.NameServers ?? []).map(String);
4762
4838
  }
4763
4839
  /**
4764
4840
  * Read the registrant/admin/tech contacts via GET
@@ -4895,10 +4971,10 @@ var NameBrightRegistrar = class extends BaseRegistrar {
4895
4971
  async setDomainFlag(domainName, change, successMessage, opts) {
4896
4972
  try {
4897
4973
  const path = `account/domains/${encodeURIComponent(domainName)}`;
4898
- const current = await this.authed(
4899
- { path },
4900
- opts
4901
- );
4974
+ const current = await this.authed({ path }, opts);
4975
+ if (!current.DomainName) {
4976
+ return { success: false, message: `NameBright: could not read ${domainName} to update it` };
4977
+ }
4902
4978
  const body = {
4903
4979
  DomainName: current.DomainName,
4904
4980
  Status: current.Status,
@@ -4975,7 +5051,7 @@ var NameBrightRegistrar = class extends BaseRegistrar {
4975
5051
  // normalized Domain shape. Neither endpoint returns nameservers.
4976
5052
  toDomain(d) {
4977
5053
  return createDomain({
4978
- domainName: d.DomainName ?? d.domain,
5054
+ domainName: d.DomainName,
4979
5055
  registrar: this.name,
4980
5056
  status: d.Status ?? "ok",
4981
5057
  createdDate: d.RegistrationDate,