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