@aoxborrow/registrar-client 0.7.0 → 0.8.0
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/README.md +6 -0
- package/dist/index.cjs +34 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/http.ts +26 -2
- package/src/registrars/dynadot.ts +3 -0
- package/src/registrars/namecheap.ts +11 -5
- package/src/registrars/namecom.ts +8 -12
- package/src/types.ts +3 -0
package/dist/index.d.cts
CHANGED
|
@@ -140,6 +140,7 @@ interface DomainAvailability {
|
|
|
140
140
|
available: boolean;
|
|
141
141
|
premium?: boolean;
|
|
142
142
|
price?: number;
|
|
143
|
+
renewalPrice?: number;
|
|
143
144
|
currency?: string;
|
|
144
145
|
period?: number;
|
|
145
146
|
}
|
|
@@ -354,6 +355,7 @@ interface HttpClientConfig {
|
|
|
354
355
|
headers?: Record<string, string>;
|
|
355
356
|
options: RegistrarClientOptions;
|
|
356
357
|
safeMethods?: readonly string[];
|
|
358
|
+
rateLimitFallbackSeconds?: number;
|
|
357
359
|
}
|
|
358
360
|
declare const REST_SAFE_METHODS: readonly string[];
|
|
359
361
|
interface RequestConfig {
|
package/dist/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ interface DomainAvailability {
|
|
|
140
140
|
available: boolean;
|
|
141
141
|
premium?: boolean;
|
|
142
142
|
price?: number;
|
|
143
|
+
renewalPrice?: number;
|
|
143
144
|
currency?: string;
|
|
144
145
|
period?: number;
|
|
145
146
|
}
|
|
@@ -354,6 +355,7 @@ interface HttpClientConfig {
|
|
|
354
355
|
headers?: Record<string, string>;
|
|
355
356
|
options: RegistrarClientOptions;
|
|
356
357
|
safeMethods?: readonly string[];
|
|
358
|
+
rateLimitFallbackSeconds?: number;
|
|
357
359
|
}
|
|
358
360
|
declare const REST_SAFE_METHODS: readonly string[];
|
|
359
361
|
interface RequestConfig {
|
package/dist/index.js
CHANGED
|
@@ -597,8 +597,8 @@ var HttpClient = class {
|
|
|
597
597
|
case 404:
|
|
598
598
|
return new NotFoundError(message);
|
|
599
599
|
case 429: {
|
|
600
|
-
const retryAfter =
|
|
601
|
-
return new RateLimitError(message,
|
|
600
|
+
const retryAfter = parseRetryAfter(response.headers.get("retry-after")) ?? this.config.rateLimitFallbackSeconds;
|
|
601
|
+
return new RateLimitError(message, retryAfter);
|
|
602
602
|
}
|
|
603
603
|
default: {
|
|
604
604
|
if (response.status >= 500) {
|
|
@@ -611,6 +611,19 @@ var HttpClient = class {
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
|
+
function parseRetryAfter(value) {
|
|
615
|
+
const text2 = value?.trim();
|
|
616
|
+
if (!text2) return void 0;
|
|
617
|
+
if (/^\d+$/.test(text2)) {
|
|
618
|
+
const seconds = Number(text2);
|
|
619
|
+
return Number.isSafeInteger(seconds) ? seconds : void 0;
|
|
620
|
+
}
|
|
621
|
+
const zonedDate = /^(?:[a-z]{3}, \d{2} [a-z]{3} \d{4}|[a-z]+, \d{2}-[a-z]{3}-\d{2}) \d{2}:\d{2}:\d{2} GMT$/i;
|
|
622
|
+
const asctimeDate = /^[a-z]{3} [a-z]{3} (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4}$/i;
|
|
623
|
+
if (!zonedDate.test(text2) && !asctimeDate.test(text2)) return void 0;
|
|
624
|
+
const date = Date.parse(asctimeDate.test(text2) ? `${text2} GMT` : text2);
|
|
625
|
+
return Number.isFinite(date) ? Math.max(0, Math.ceil((date - Date.now()) / 1e3)) : void 0;
|
|
626
|
+
}
|
|
614
627
|
function isOutcomeUnknown(error) {
|
|
615
628
|
if (error instanceof TimeoutError || error instanceof InvalidResponseError) return true;
|
|
616
629
|
return error instanceof ConnectionError && !error.notSent;
|
|
@@ -1798,7 +1811,10 @@ var DynadotRegistrar = class extends BaseRegistrar {
|
|
|
1798
1811
|
production: "https://api.dynadot.com",
|
|
1799
1812
|
sandbox: "https://api-sandbox.dynadot.com"
|
|
1800
1813
|
}),
|
|
1801
|
-
headers: { Authorization: `Bearer ${credentials.apiKey}` }
|
|
1814
|
+
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
|
1815
|
+
// HTTP 429 can omit Retry-After. Avoid exhausting all attempts inside
|
|
1816
|
+
// Dynadot's regular-tier minute window in that case.
|
|
1817
|
+
rateLimitFallbackSeconds: 60
|
|
1802
1818
|
},
|
|
1803
1819
|
options
|
|
1804
1820
|
);
|
|
@@ -4739,9 +4755,10 @@ var NamecheapRegistrar = class extends BaseRegistrar {
|
|
|
4739
4755
|
}
|
|
4740
4756
|
/**
|
|
4741
4757
|
* Availability via domains.check (batched at 50 per request, Namecheap's cap).
|
|
4742
|
-
* The check response only carries
|
|
4743
|
-
* (`PremiumRegistrationPrice`); regular
|
|
4744
|
-
* `getPricing`, so `price`
|
|
4758
|
+
* The check response only carries prices for *premium* names
|
|
4759
|
+
* (`PremiumRegistrationPrice`, `PremiumRenewalPrice`); regular pricing comes
|
|
4760
|
+
* from `getPricing`, so `price` and `renewalPrice` are set only for premium
|
|
4761
|
+
* results.
|
|
4745
4762
|
*/
|
|
4746
4763
|
async checkAvailability(domainNames, opts) {
|
|
4747
4764
|
const results = [];
|
|
@@ -4754,12 +4771,16 @@ var NamecheapRegistrar = class extends BaseRegistrar {
|
|
|
4754
4771
|
);
|
|
4755
4772
|
for (const el of ensureArray(cr.DomainCheckResult)) {
|
|
4756
4773
|
const premium = el["@_IsPremiumName"] === "true";
|
|
4757
|
-
const premiumPrice =
|
|
4774
|
+
const premiumPrice = (attr) => {
|
|
4775
|
+
const n = premium ? Number(attr) : NaN;
|
|
4776
|
+
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
4777
|
+
};
|
|
4758
4778
|
results.push({
|
|
4759
4779
|
domainName: el["@_Domain"] ?? "",
|
|
4760
4780
|
available: el["@_Available"] === "true",
|
|
4761
4781
|
premium,
|
|
4762
|
-
price:
|
|
4782
|
+
price: premiumPrice(el["@_PremiumRegistrationPrice"]),
|
|
4783
|
+
renewalPrice: premiumPrice(el["@_PremiumRenewalPrice"])
|
|
4763
4784
|
});
|
|
4764
4785
|
}
|
|
4765
4786
|
}
|
|
@@ -5167,12 +5188,11 @@ var NamecomHttpClient = class extends HttpClient {
|
|
|
5167
5188
|
}),
|
|
5168
5189
|
url
|
|
5169
5190
|
);
|
|
5170
|
-
if (error instanceof RateLimitError) {
|
|
5171
|
-
const
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
error.retryAfter = Number.isFinite(seconds) ? Math.max(0, seconds) : Number.isFinite(date) ? Math.max(0, (date - Date.now()) / 1e3) : reset != null && Number.isFinite(Number(reset)) ? Math.max(0, Number(reset) - Date.now() / 1e3) : void 0;
|
|
5191
|
+
if (error instanceof RateLimitError && error.retryAfter === void 0) {
|
|
5192
|
+
const reset = response.headers.get("x-ratelimit-reset")?.trim();
|
|
5193
|
+
if (reset && /^\d+(?:\.\d+)?$/.test(reset)) {
|
|
5194
|
+
error.retryAfter = Math.max(0, Math.ceil(Number(reset) - Date.now() / 1e3));
|
|
5195
|
+
}
|
|
5176
5196
|
}
|
|
5177
5197
|
return error;
|
|
5178
5198
|
}
|