@fwgapps/namecheap 1.0.0 → 1.1.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 +19 -3
- package/dist/index.cjs +72 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -12
- package/dist/index.d.ts +56 -12
- package/dist/index.js +72 -21
- package/dist/index.js.map +1 -1
- package/package.json +15 -1
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ console.log(status.status, transfers.length);
|
|
|
168
168
|
```ts
|
|
169
169
|
const csrInfo = await nc.ssl.parseCSR({ csr: "-----BEGIN CERTIFICATE REQUEST-----\n..." });
|
|
170
170
|
const { certificates } = await nc.ssl.getList({ listType: "Active" });
|
|
171
|
-
const emails = await nc.ssl.getApproverEmailList({ domainName: "example.com", certificateType: "
|
|
171
|
+
const emails = await nc.ssl.getApproverEmailList({ domainName: "example.com", certificateType: "Standard SSL SSLcom" });
|
|
172
172
|
const cert = await nc.ssl.getInfo({ certificateID: 12345 });
|
|
173
173
|
console.log(csrInfo.commonName, certificates.length, emails.genericEmails, cert.status);
|
|
174
174
|
```
|
|
@@ -309,11 +309,27 @@ const result = await nc.dns.setDefault({ sld: "example", tld: "com" });
|
|
|
309
309
|
console.log(result.updated, calls[0]?.url);
|
|
310
310
|
```
|
|
311
311
|
|
|
312
|
+
## End-to-end tests (sandbox)
|
|
313
|
+
|
|
314
|
+
The unit tests use recorded XML and a fake `fetch`. The E2E suites in `tests/e2e` call the real Namecheap **sandbox** and check that every command is read into its documented shape. They never reach production (`sandbox: true` is hardcoded) and are skipped when the credentials are missing, so CI is unaffected.
|
|
315
|
+
|
|
316
|
+
1. Create a sandbox account at [sandbox.namecheap.com](https://www.sandbox.namecheap.com), enable API access (Profile, Tools, Namecheap API Access) and whitelist your public IP.
|
|
317
|
+
2. Copy `.env.example` to `.env` (it is git-ignored) and fill in `NAMECHEAP_API_USER`, `NAMECHEAP_API_KEY` and `NAMECHEAP_CLIENT_IP`.
|
|
318
|
+
3. Optional, for the login and password tests: `NAMECHEAP_E2E_USER` (letters and digits only) and `NAMECHEAP_E2E_PASS` (a strong password) for a throw-away account. They are skipped without them.
|
|
319
|
+
4. Run `yarn test:e2e` (or `npm run test:e2e`).
|
|
320
|
+
|
|
321
|
+
Things to know:
|
|
322
|
+
|
|
323
|
+
- **Rate limit.** The API allows 20 calls per minute and 700 per hour, so the client waits 3.2 seconds between calls and a full run takes about 7 minutes. Over the limit the API answers HTTP 405.
|
|
324
|
+
- **Never use your main account for passwords.** Three failed logins in a row lock an ApiUser for 24 hours. The E2E client and `scripts/record-fixtures.mjs` refuse `users.login`, `users.changePassword` and `users.resetPassword` on the main account, so those tests run on the throw-away account only.
|
|
325
|
+
- **Leftovers.** The sandbox has no delete command: each run registers a throw-away domain and a few accounts. Sandbox money is fake.
|
|
326
|
+
- **Not covered.** The success path of `ssl.activate`, `ssl.reissue` and the commands that need an active certificate.
|
|
327
|
+
|
|
312
328
|
## Known gaps
|
|
313
329
|
|
|
314
|
-
1. `ssl.activate` and `ssl.reissue`
|
|
330
|
+
1. `ssl.activate` and `ssl.reissue` accept `approverEmail`, `httpDcValidation` and `dnsDcValidation` (verified against the sandbox) but do not expose the 0.6 OV/EV organisation option sets (organisation, department, admin address, company registration fields), because the API reference does not document them.
|
|
315
331
|
2. `users.create`, `users.login`, `users.resetPassword`, `whoisGuard.renew`, `ssl.create`, `ssl.renew` and `ssl.purchaseMoreSans` have undocumented response shapes. They return loosely typed results parsed tolerantly: they never throw on an unexpected shape, and fields that cannot be read are simply absent.
|
|
316
|
-
3. `dns.setEmailForwarding` sends `MailBox<n>` as spelled in the API reference; the
|
|
332
|
+
3. `dns.setEmailForwarding` sends `MailBox<n>` as spelled in the API reference; the sandbox accepted it (verified by the E2E suite).
|
|
317
333
|
4. CAA (`Flag`/`Tag`) records are not supported by `dns.setHosts`.
|
|
318
334
|
5. `ssl.getInfo` accepts `returnCertificate` and sends it, but 1.0 does not parse the certificate body (its response shape is undocumented), so the result never contains the certificate.
|
|
319
335
|
6. WhoisGuard `allot`, `unallot` and `discard` are not implemented.
|
package/dist/index.cjs
CHANGED
|
@@ -327,7 +327,7 @@ var getHosts = /* @__PURE__ */ defineCommand({
|
|
|
327
327
|
var getEmailForwarding = /* @__PURE__ */ defineCommand({
|
|
328
328
|
name: "namecheap.domains.dns.getEmailForwarding",
|
|
329
329
|
parse: (cr) => {
|
|
330
|
-
const result = cr.one("DomainEmailForwardingResult");
|
|
330
|
+
const result = cr.optional("DomainDNSGetEmailForwardingResult") ?? cr.one("DomainEmailForwardingResult");
|
|
331
331
|
return {
|
|
332
332
|
domain: result.string("Domain"),
|
|
333
333
|
forwards: result.all("Forward").map((forward) => ({
|
|
@@ -340,7 +340,7 @@ var getEmailForwarding = /* @__PURE__ */ defineCommand({
|
|
|
340
340
|
var setEmailForwarding = /* @__PURE__ */ defineCommand({
|
|
341
341
|
name: "namecheap.domains.dns.setEmailForwarding",
|
|
342
342
|
parse: (cr) => {
|
|
343
|
-
const result = cr.one("DomainEmailForwardingResult");
|
|
343
|
+
const result = cr.optional("DomainDNSSetEmailForwardingResult") ?? cr.one("DomainEmailForwardingResult");
|
|
344
344
|
return { domain: result.string("Domain"), isSuccess: result.boolean("IsSuccess") };
|
|
345
345
|
}
|
|
346
346
|
});
|
|
@@ -496,7 +496,8 @@ var getTldList = /* @__PURE__ */ defineCommand({
|
|
|
496
496
|
name: "namecheap.domains.getTldList",
|
|
497
497
|
parse: (cr) => (cr.optional("Tlds")?.all("Tld") ?? []).map((tld) => ({
|
|
498
498
|
name: tld.string("Name"),
|
|
499
|
-
|
|
499
|
+
// The live API sends NonRealTime; the reference (and older fixtures) say NonRealTimeDomain.
|
|
500
|
+
nonRealTimeDomain: tld.optionalBoolean("NonRealTime") ?? tld.boolean("NonRealTimeDomain"),
|
|
500
501
|
minRegisterYears: tld.number("MinRegisterYears"),
|
|
501
502
|
maxRegisterYears: tld.number("MaxRegisterYears"),
|
|
502
503
|
minRenewYears: tld.number("MinRenewYears"),
|
|
@@ -538,7 +539,10 @@ var getContacts = /* @__PURE__ */ defineCommand({
|
|
|
538
539
|
return {
|
|
539
540
|
domain: result.string("Domain"),
|
|
540
541
|
domainnameid: result.number("domainnameid"),
|
|
541
|
-
|
|
542
|
+
...optionalField(
|
|
543
|
+
"readonly",
|
|
544
|
+
result.optionalBoolean("ReadOnly") ?? result.optionalBoolean("Readonly")
|
|
545
|
+
),
|
|
542
546
|
...optionalField("registrant", contact("Registrant")),
|
|
543
547
|
...optionalField("tech", contact("Tech")),
|
|
544
548
|
...optionalField("admin", contact("Admin")),
|
|
@@ -739,12 +743,13 @@ var parseCSR = /* @__PURE__ */ defineCommand({
|
|
|
739
743
|
return {
|
|
740
744
|
commonName: details.one("CommonName").text(),
|
|
741
745
|
domainName: details.one("DomainName").text(),
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
746
|
+
// A CSR may omit any of these (e.g. no organisational unit), and the API then omits them too.
|
|
747
|
+
...optionalField("country", details.optional("Country")?.text()),
|
|
748
|
+
...optionalField("organisationUnit", details.optional("OrganisationUnit")?.text()),
|
|
749
|
+
...optionalField("organisation", details.optional("Organisation")?.text()),
|
|
750
|
+
...optionalField("state", details.optional("State")?.text()),
|
|
751
|
+
...optionalField("locality", details.optional("Locality")?.text()),
|
|
752
|
+
...optionalField("email", details.optional("Email")?.text())
|
|
748
753
|
};
|
|
749
754
|
}
|
|
750
755
|
});
|
|
@@ -765,21 +770,52 @@ var getApproverEmailList = /* @__PURE__ */ defineCommand({
|
|
|
765
770
|
function parseHttpDcValidation(result) {
|
|
766
771
|
const validation = result.optional("HttpDCValidation");
|
|
767
772
|
if (validation === void 0) return void 0;
|
|
773
|
+
const entries = validation.all("DNS").map((entry) => ({
|
|
774
|
+
...optionalField("domain", entry.optionalString("domain")),
|
|
775
|
+
...optionalField("fileName", entry.optionalText("FileName")),
|
|
776
|
+
...optionalField("fileContent", entry.optionalText("FileContent"))
|
|
777
|
+
}));
|
|
778
|
+
const fileName = validation.optionalText("FileName") ?? entries[0]?.fileName;
|
|
779
|
+
const fileContent = validation.optionalText("FileContent") ?? entries[0]?.fileContent;
|
|
780
|
+
return {
|
|
781
|
+
valueAvailable: validation.boolean("ValueAvailable"),
|
|
782
|
+
...optionalField("fileName", fileName),
|
|
783
|
+
...optionalField("fileContent", fileContent),
|
|
784
|
+
...entries.length > 0 ? { entries } : {}
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
function parseDnsDcValidation(result) {
|
|
788
|
+
const validation = result.optional("DNSDCValidation");
|
|
789
|
+
if (validation === void 0) return void 0;
|
|
790
|
+
const entries = validation.all("DNS").map((entry) => ({
|
|
791
|
+
...optionalField("domain", entry.optionalString("domain")),
|
|
792
|
+
...optionalField("hostName", entry.optionalText("HostName")),
|
|
793
|
+
...optionalField("target", entry.optionalText("Target"))
|
|
794
|
+
}));
|
|
795
|
+
const hostName = validation.optionalText("HostName") ?? entries[0]?.hostName;
|
|
796
|
+
const target = validation.optionalText("Target") ?? entries[0]?.target;
|
|
768
797
|
return {
|
|
769
798
|
valueAvailable: validation.boolean("ValueAvailable"),
|
|
770
|
-
...optionalField("
|
|
771
|
-
...optionalField("
|
|
799
|
+
...optionalField("hostName", hostName),
|
|
800
|
+
...optionalField("target", target),
|
|
801
|
+
...entries.length > 0 ? { entries } : {}
|
|
772
802
|
};
|
|
773
803
|
}
|
|
774
804
|
function parseActivation(result) {
|
|
775
805
|
return {
|
|
776
806
|
id: result.number("ID"),
|
|
777
807
|
isSuccess: result.boolean("IsSuccess"),
|
|
778
|
-
...optionalField("httpDCValidation", parseHttpDcValidation(result))
|
|
808
|
+
...optionalField("httpDCValidation", parseHttpDcValidation(result)),
|
|
809
|
+
...optionalField("dnsDCValidation", parseDnsDcValidation(result))
|
|
779
810
|
};
|
|
780
811
|
}
|
|
781
812
|
var activate = /* @__PURE__ */ defineCommand({
|
|
782
813
|
name: "namecheap.ssl.activate",
|
|
814
|
+
keys: {
|
|
815
|
+
approverEmail: "ApproverEmail",
|
|
816
|
+
httpDcValidation: "HTTPDCValidation",
|
|
817
|
+
dnsDcValidation: "DNSDCValidation"
|
|
818
|
+
},
|
|
783
819
|
parse: (cr) => parseActivation(cr.one("SSLActivateResult"))
|
|
784
820
|
});
|
|
785
821
|
function parseResend(result) {
|
|
@@ -791,6 +827,11 @@ var resendApproverEmail = /* @__PURE__ */ defineCommand({
|
|
|
791
827
|
});
|
|
792
828
|
var reissue = /* @__PURE__ */ defineCommand({
|
|
793
829
|
name: "namecheap.ssl.reissue",
|
|
830
|
+
keys: {
|
|
831
|
+
approverEmail: "ApproverEmail",
|
|
832
|
+
httpDcValidation: "HTTPDCValidation",
|
|
833
|
+
dnsDcValidation: "DNSDCValidation"
|
|
834
|
+
},
|
|
794
835
|
parse: (cr) => parseActivation(cr.one("SSLReissueResult"))
|
|
795
836
|
});
|
|
796
837
|
var resendFulfillmentEmail = /* @__PURE__ */ defineCommand({
|
|
@@ -809,11 +850,14 @@ var getInfo3 = /* @__PURE__ */ defineCommand({
|
|
|
809
850
|
parse: (cr) => {
|
|
810
851
|
const result = cr.one("SSLGetInfoResult");
|
|
811
852
|
return {
|
|
812
|
-
certificateID
|
|
853
|
+
...optionalField("certificateID", result.lenientNumber("CertificateID")),
|
|
813
854
|
status: result.string("Status"),
|
|
814
855
|
...optionalField("type", result.optionalString("Type")),
|
|
815
856
|
...optionalField("commonName", result.optionalString("CommonName")),
|
|
816
|
-
...optionalField(
|
|
857
|
+
...optionalField(
|
|
858
|
+
"provider",
|
|
859
|
+
result.optionalString("Provider") ?? result.optional("Provider")?.optionalText("Name")
|
|
860
|
+
),
|
|
817
861
|
...optionalField("issuedOn", result.optionalString("IssuedOn")),
|
|
818
862
|
...optionalField("expires", result.optionalString("Expires"))
|
|
819
863
|
};
|
|
@@ -921,11 +965,13 @@ var updateStatus = /* @__PURE__ */ defineCommand({
|
|
|
921
965
|
});
|
|
922
966
|
function parseListItem3(transfer) {
|
|
923
967
|
return {
|
|
924
|
-
|
|
968
|
+
// The live list sends ID; the reference says TransferID.
|
|
969
|
+
transferID: transfer.optionalNumber("ID") ?? transfer.number("TransferID"),
|
|
925
970
|
domainName: transfer.string("DomainName"),
|
|
926
971
|
user: transfer.string("User"),
|
|
927
972
|
transferDate: transfer.string("TransferDate"),
|
|
928
|
-
|
|
973
|
+
// OrderID is empty for a queued transfer.
|
|
974
|
+
...optionalField("orderID", transfer.lenientNumber("OrderID")),
|
|
929
975
|
statusID: transfer.number("StatusID"),
|
|
930
976
|
status: transfer.string("Status")
|
|
931
977
|
};
|
|
@@ -984,7 +1030,11 @@ var changePassword = /* @__PURE__ */ defineCommand({
|
|
|
984
1030
|
name: "namecheap.users.changePassword",
|
|
985
1031
|
parse: (cr) => {
|
|
986
1032
|
const result = cr.one("UserChangePasswordResult");
|
|
987
|
-
return {
|
|
1033
|
+
return {
|
|
1034
|
+
success: result.boolean("Success"),
|
|
1035
|
+
// The live API may spell it UserId, or leave it out.
|
|
1036
|
+
...optionalField("userID", result.lenientNumber("UserID") ?? result.lenientNumber("UserId"))
|
|
1037
|
+
};
|
|
988
1038
|
}
|
|
989
1039
|
});
|
|
990
1040
|
var update2 = /* @__PURE__ */ defineCommand({
|
|
@@ -994,7 +1044,7 @@ var update2 = /* @__PURE__ */ defineCommand({
|
|
|
994
1044
|
var createAddFundsRequest = /* @__PURE__ */ defineCommand({
|
|
995
1045
|
name: "namecheap.users.createaddfundsrequest",
|
|
996
1046
|
parse: (cr) => {
|
|
997
|
-
const result = cr.one("CreateAddFundsRequestResult");
|
|
1047
|
+
const result = cr.optional("Createaddfundsrequestresult") ?? cr.one("CreateAddFundsRequestResult");
|
|
998
1048
|
return {
|
|
999
1049
|
tokenID: result.string("TokenID"),
|
|
1000
1050
|
redirectURL: result.string("RedirectURL"),
|
|
@@ -1006,7 +1056,7 @@ var getAddFundsStatus = /* @__PURE__ */ defineCommand({
|
|
|
1006
1056
|
name: "namecheap.users.getAddFundsStatus",
|
|
1007
1057
|
keys: { tokenId: "TokenId" },
|
|
1008
1058
|
parse: (cr) => {
|
|
1009
|
-
const result = cr.one("GetAddFundsStatusResult");
|
|
1059
|
+
const result = cr.optional("Getaddfundsstatusresult") ?? cr.one("GetAddFundsStatusResult");
|
|
1010
1060
|
return {
|
|
1011
1061
|
transactionID: result.number("TransactionID"),
|
|
1012
1062
|
amount: result.string("Amount"),
|
|
@@ -1496,7 +1546,8 @@ function toErrorItem(error) {
|
|
|
1496
1546
|
};
|
|
1497
1547
|
}
|
|
1498
1548
|
function readEnvelope(xml) {
|
|
1499
|
-
const
|
|
1549
|
+
const start = xml.search(/<\?xml|<ApiResponse/);
|
|
1550
|
+
const root = new El(parseXml(start > 0 ? xml.slice(start) : xml));
|
|
1500
1551
|
if (root.name !== "ApiResponse") {
|
|
1501
1552
|
throw new NamecheapParseError(`Unexpected response root element "${root.name}"`);
|
|
1502
1553
|
}
|