@fwgapps/namecheap 0.6.0 → 1.0.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 +314 -60
- package/dist/index.cjs +1660 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1211 -954
- package/dist/index.d.ts +1211 -954
- package/dist/index.js +1561 -1
- package/dist/index.js.map +1 -1
- package/package.json +31 -26
- package/dist/index.global.js +0 -5
- package/dist/index.global.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,1562 @@
|
|
|
1
|
-
import{XMLParser as B}from"fast-xml-parser";import{camelCase as M,pascalCase as H}from"change-case-all";var g=r=>{if(Array.isArray(r))return r.map(g).filter(e=>e!=null&&e!=="");if(typeof r=="object"&&r!==null){let e=Object.keys(r);if(e.length===2&&e.includes("#text")&&e.some(s=>s!=="#text"&&r[s]===!0))return r["#text"];if(e.length===2&&e.some(s=>r[s]===!0)){let s=e.find(a=>r[a]!==!0);return g(r[s])}return Object.keys(r).reduce((s,a)=>{let o=a==="#text"?"value":a,n=g(r[a]);return n!=null&&n!==""&&(s[o]=n),s},{})}return r};var U=r=>`https://${r?"api.sandbox.namecheap.com":"api.namecheap.com"}/xml.response`,x=r=>r.status==="ERROR"||Object.hasOwnProperty.call(r,"errors")&&(!!r.errors.number||!!r.errors.value),h=(r,e="",s=!0)=>{let a=[];return Object.entries(r).forEach(([o,n])=>{let i=H(`${e} ${o}`);typeof n=="object"&&n!==null&&!Array.isArray(n)?a.push(...h(n,i)):typeof n=="object"&&n!==null&&Array.isArray(n)?n.forEach((m,p)=>{s?a.push([`${i}[${p+1}]`,String(m)]):a.push([`${i}${p+1}`,String(m)])}):n!=null&&a.push([i,String(n)])}),a},X=["apiResponse.commandResponse.tlds.tld","apiResponse.commandResponse.tlds.tld.categories","apiResponse.commandResponse.domainGetListResult.domain","apiResponse.commandResponse.domainCheckResult","apiResponse.commandResponse.userGetPricingResult.productType.productCategory","apiResponse.commandResponse.userGetPricingResult.productType.productCategory.product","apiResponse.commandResponse.userGetPricingResult.productType.productCategory.product.price","apiResponse.commandResponse.whoisguardGetListResult.whoisguardGetListResult.whoisguard","apiResponse.commandResponse.domainDnsGetEmailForwardingResult.forward","apiResponse.commandResponse.domainDnsSetHostsResult"],b=new B({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,processEntities:!0,parseTagValue:!0,parseAttributeValue:!0,trimValues:!0,isArray:(r,e)=>X.includes(e),transformTagName:r=>M(r),transformAttributeName:r=>M(r)});async function t(r,e,s={}){let{apiUser:a,apiKey:o,apiUrl:n,username:i,clientIp:m}=r,p=new URL(n);p.searchParams.append("ApiUser",a),p.searchParams.append("ApiKey",o),p.searchParams.append("UserName",i),p.searchParams.append("ClientIp",m),p.searchParams.append("Command",e),h(s).forEach(([l,N])=>{p.searchParams.append(l,N)});let c=await fetch(p.toString());if(!c.ok)throw new Error(`Error in API Namecheap: ${c.statusText}`);let d=await c.text(),f=b.parse(d),u=g(f.apiResponse);if(x(u)){let l=u.errors;throw{code:l.number||-1,message:l.value||"Unknown Error"}}return u}async function y(r,e,s={},a={}){let{apiUser:o,apiKey:n,apiUrl:i,username:m,clientIp:p}=r,c=new URL(i);c.searchParams.append("ApiUser",o),c.searchParams.append("ApiKey",n),c.searchParams.append("UserName",m),c.searchParams.append("ClientIp",p),c.searchParams.append("Command",e);let d=[];h(s).forEach(([R,G])=>{c.searchParams.append(R,G)}),h(a,"",!1).forEach(([R,G])=>{d.push({Key:R,Value:G})});let f={request:{RequestValues:d}},u=await fetch(c.toString(),{method:"POST",body:JSON.stringify(f)});if(!u.ok)throw new Error(`Error in API Namecheap: ${u.statusText}`);let l=await u.text(),N=b.parse(l),C=g(N.apiResponse);if(x(C)){let R=C.errors;throw{code:R.number,message:R.value}}return C}var z={A:"A",AAAA:"AAAA",ALIAS:"ALIAS",CAA:"CAA",CNAME:"CNAME",MX:"MX",MXE:"MXE",NS:"NS",TXT:"TXT",URL:"URL",URL301:"URL301",FRAME:"FRAME"},j={MXE:"MXE",MX:"MX",FWD:"FWD",OX:"OX"},k={Lock:"LOCK",Unlock:"UNLOCK"},v={All:"ALL",Expiring:"EXPIRING",Expired:"EXPIRED"},J={NameAsc:"NAME",NameDesc:"NAME_DESC",ExpireDateAsc:"EXPIREDATE",ExpireDateDesc:"EXPIREDATE_DESC",CreateDateAsc:"CREATEDATE",CreateDateDesc:"CREATEDATE_DESC"},Y={AFR:"afr",ALB:"alb",ARA:"ara",ARG:"arg",ARM:"arm",ASM:"asm",AST:"ast",AVE:"ave",AWA:"awa",AZE:"aze",BAK:"bak",BAL:"bal",BAN:"ban",BAQ:"baq",BAS:"bas",BEL:"bel",BEN:"ben",BHO:"bho",BOS:"bos",BUL:"bul",BUR:"bur",CAR:"car",CAT:"cat",CHE:"che",CHI:"chi",CHV:"chv",COP:"cop",COS:"cos",CZE:"cze",DAN:"dan",DIV:"div",DOI:"doi",DUT:"dut",ENG:"eng",EST:"est",FAO:"fao",FIJ:"fij",FIN:"fin",FRE:"fre",FRY:"fry",GEO:"geo",GER:"ger",GLA:"gla",GLE:"gle",GON:"gon",GRE:"gre",GUJ:"guj",HEB:"heb",HIN:"hin",HUN:"hun",INC:"inc",IND:"ind",INH:"inh",ISL:"isl",ITA:"ita",JAV:"jav",JPN:"jpn",KAS:"kas",KAZ:"kaz",KHM:"khm",KIR:"kir",KOR:"kor",KUR:"kur",LAO:"lao",LAV:"lav",LIT:"lit",LTZ:"ltz",MAL:"mal",MKD:"mkd",MLT:"mlt",MOL:"mol",MON:"mon",MRI:"mri",MSA:"msa",NEP:"nep",NOR:"nor",ORI:"ori",OSS:"oss",PAN:"pan",PER:"per",POL:"pol",POR:"por",PUS:"pus",RAJ:"raj",RUM:"rum",RUS:"rus",SAN:"san",SCR:"scr",SIN:"sin",SLO:"slo",SLV:"slv",SMO:"smo",SND:"snd",SOM:"som",SPA:"spa",SRD:"srd",SRP:"srp",SWA:"swa",SWE:"swe",SYR:"syr",TAM:"tam",TEL:"tel",TGK:"tgk",THA:"tha",TIB:"tib",TUR:"tur",UKR:"ukr",URD:"urd",UZB:"uzb",VIE:"vie",WEL:"wel",YID:"yid"},F={All:"ALL",InProgress:"INPROGRESS",Cancelled:"CANCELLED",Completed:"COMPLETED"},O={DomainName:"DOMAINNAME",DomainNameDesc:"DOMAINNAME_DESC",TransferDate:"TRANSFERDATE",TransferDateDesc:"TRANSFERDATE_DESC",StatusDate:"STATUSDATE",StatusDateDesc:"STATUSDATE_DESC"},Z={PositiveSSL:"PositiveSSL",EssentialSSL:"EssentialSSL",InstantSSL:"InstantSSL",InstantSSLPro:"InstantSSL Pro",PremiumSSL:"PremiumSSL",EVSSL:"EV SSL",PositiveSSLWildcard:"PositiveSSL Wildcard",EssentialSSLWildcard:"EssentialSSL Wildcard",PremiumSSLWildcard:"PremiumSSL Wildcard",PositiveSSLMultiDomain:"PositiveSSL Multi Domain",MultiDomainSSL:"Multi Domain SSL",UnifiedCommunications:"Unified Communications",EVMultiDomainSSL:"EV Multi Domain SSL"},Q={ALL:"ALL",Processing:"Processing",EmailSent:"EmailSent",TechnicalProblem:"TechnicalProblem",InProgress:"InProgress",Completed:"Completed",Deactivated:"Deactivated",Active:"Active",Cancelled:"Cancelled",NewPurchase:"NewPurchase",NewRenewal:"NewRenewal"},ee={PurchaseDate:"PURCHASEDATE",PurchaseDateDesc:"PURCHASEDATE_DESC",SSLType:"SSLTYPE",SSLTypeDesc:"SSLTYPE_DESC",ExpireDateTime:"EXPIREDATETIME",ExpireDateTimeDesc:"EXPIREDATETIME_DESC",Hostname:"Host_Name",HostnameDesc:"Host_Name_DESC"},se={Domain:"DOMAIN",SslCertificate:"SSLCERTIFICATE"},te={Domains:"DOMAINS",Comodo:"COMODO"},ae={Register:"REGISTER",Renew:"RENEW",Reactivate:"REACTIVATE",Transfer:"TRANSFER",Purchase:"PURCHASE"},re={COM:"COM",InstantSsl:"INSTANTSSL"},ne={CreditCard:"Creditcard"},oe={EmailAddress:"EMAILADDRESS",DomainName:"DOMAINNAME",Username:"USERNAME"},ie={All:"ALL",Alloted:"ALLOTED",Free:"FREE",Discard:"DISCARD"},pe={Created:"CREATED",Submitted:"SUBMITTED",Completed:"COMPLETED",Failed:"FAILED",Expired:"EXPIRED"},ce={Issue:"issue",IssueWild:"issuewild",IODEF:"iodef"};var P=class{constructor(e){this.config=e}async getList(e={listType:v.All,page:1,pageSize:20}){let s=await t(this.config,"namecheap.domains.getList",e);return{data:s.commandResponse.domainGetListResult,paging:s.commandResponse.paging}}async getContacts(e){return(await t(this.config,"namecheap.domains.getContacts",{domainName:e})).commandResponse.domainContactsResult}async create(e,s){return(await t(this.config,"namecheap.domains.create",{...s,domainName:e})).commandResponse.domainCreateResult}async getTldList(){return(await t(this.config,"namecheap.domains.getTldList")).commandResponse.tlds}async setContacts(e,s){return(await t(this.config,"namecheap.domains.setContacts",{...s,domainName:e})).commandResponse.domainSetContactResult}async check(e){return(await t(this.config,"namecheap.domains.check",{domainList:e.join()})).commandResponse.domainCheckResult}async reactivate(e,s={}){return(await t(this.config,"namecheap.domains.reactivate",{...s,domainName:e})).commandResponse.domainReactivateResult}async renew(e,s){return(await t(this.config,"namecheap.domains.renew",{...s,domainName:e})).commandResponse.domainRenewResult}async getRegistrarLock(e){return(await t(this.config,"namecheap.domains.getRegistrarLock",{domainName:e})).commandResponse.domainGetRegistrarLockResult}async setRegistrarLock(e,s=k.Lock){return(await t(this.config,"namecheap.domains.setRegistrarLock",{domainName:e,lockAction:s})).commandResponse.domainSetRegistrarLockResult}async getInfo(e,s){return(await t(this.config,"namecheap.domains.getInfo",{domainName:e,hostName:s})).commandResponse.domainGetInfoResult}};var S=class{constructor(e){this.config=e}async setDefault(e,s){return(await t(this.config,"namecheap.domains.dns.setDefault",{sld:e,tld:s})).commandResponse.domainDnsSetDefaultResult}async setCustom(e,s,a){return(await t(this.config,"namecheap.domains.dns.setCustom",{sld:e,tld:s,nameservers:a})).commandResponse.domainDNSSetCustomResult}async getList(e,s){return(await t(this.config,"namecheap.domains.dns.getList",{sld:e,tld:s})).commandResponse.domainDnsGetListResult}async getHosts(e,s){return(await t(this.config,"namecheap.domains.dns.getHosts",{sld:e,tld:s})).commandResponse.domainDnsGetHostsResult}async getEmailForwarding(e){return(await t(this.config,"namecheap.domains.dns.getEmailForwarding",{domainName:e})).commandResponse.domainDnsGetEmailForwardingResult}async setEmailForwarding(e,s){return(await t(this.config,"namecheap.domains.dns.setEmailForwarding",{...s,domainName:e})).commandResponse.domainDnsSetEmailForwardingResult}async setHosts(e,s,a){let{hosts:o}=a,n=o.reduce((m,p,c)=>(Object.entries(p).forEach(([d,f])=>{m[d][c]=f}),m),{hostname:[],ttl:[],address:[],mxpref:[],recordType:[]}),i;return o.length>10?i=await y(this.config,"namecheap.domains.dns.setHosts",{SLD:e,TLD:s},{...n,tag:a.tag,flag:a.flag,emailType:a.emailType}):i=await t(this.config,"namecheap.domains.dns.setHosts",{...n,sld:e,tld:s,tag:a.tag,flag:a.flag,emailType:a.emailType}),i.commandResponse.domainDnsSetHostsResult}};var L=class{constructor(e){this.config=e}async create(e,s,a,o){return(await t(this.config,"namecheap.domains.ns.create",{sld:e,tld:s,nameserver:a,ip:o})).commandResponse.domainNsCreateResult}async delete(e,s,a){return(await t(this.config,"namecheap.domains.ns.delete",{sld:e,tld:s,nameserver:a})).commandResponse.domainNsDeleteResult}async getInfo(e,s,a){return(await t(this.config,"namecheap.domains.ns.getInfo",{sld:e,tld:s,nameserver:a})).commandResponse.domainNsInfoResult}async update(e,s,a,o,n){return(await t(this.config,"namecheap.domains.ns.update",{sld:e,tld:s,nameserver:a,ip:o,oldIp:n})).commandResponse.domainNsUpdateResult}};var A=class{constructor(e){this.config=e}async create(e,s){return(await t(this.config,"namecheap.domains.transfer.create",{domainName:e,...s})).commandResponse.domainTransferCreateResult}async getStatus(e){return(await t(this.config,"namecheap.domains.transfer.getStatus",{transferID:e})).commandResponse.domainTransferGetStatusResult}async updateStatus(e,s){return(await t(this.config,"namecheap.domains.transfer.updateStatus",{transferID:e,resubmit:s})).commandResponse.domainTransferUpdateStatusResult}async getList(e={listType:F.All,page:1,pageSize:10,sortBy:O.DomainName}){let s=await t(this.config,"namecheap.domains.transfer.getList",e);return{data:s.commandResponse.transferGetListResult,paging:s.commandResponse.paging}}};var D=class{constructor(e){this.config=e}async create(e){return(await t(this.config,"namecheap.ssl.create",e)).commandResponse.sslCreateResult}async getList(e){return(await t(this.config,"namecheap.ssl.getList",e)).commandResponse.sslListResult}async parseCSR(e,s){return(await y(this.config,"namecheap.ssl.parseCSR",{csr:e,certificateType:s})).commandResponse.sslParseCsrResult}async getApproverEmailList(e,s){return(await t(this.config,"namecheap.ssl.getApproverEmailList",{domainName:e,certificateType:s})).commandResponse.getApproverEmailListResult}async activate(e,s){return(await t(this.config,"namecheap.ssl.activate",{certificateId:e,...s})).commandResponse.sslActivateResult}async resendApproverEmail(e){return(await t(this.config,"namecheap.ssl.resendApproverEmail",{certificateId:e})).commandResponse.sslResendApproverEmailResult}async getInfo(e){return(await t(this.config,"namecheap.ssl.getInfo",{certificateId:e})).commandResponse.sslGetInfoResult}async renew(e,s){return(await t(this.config,"namecheap.ssl.renew",{certificateId:e,...s})).commandResponse.sslRenewResult}async reissue(e,s){return(await t(this.config,"namecheap.ssl.reissue",{certificateId:e,...s})).commandResponse.sslActivateResult}async resendFulfillmentEmail(e){return(await t(this.config,"namecheap.ssl.resendfulfillmentemail",{certificateId:e})).commandResponse.sslResendFulfillmentEmailResult}async purchaseMoreSANS(e,s){return(await t(this.config,"namecheap.ssl.purchasemoresans",{certificateId:e,numberOfSANSToAdd:s})).commandResponse.sslPurchaseMoreSansResult}async revokeCertificate(e,s){return(await t(this.config,"namecheap.ssl.revokecertificate",{certificateId:e,certificateType:s})).commandResponse.revokeCertificateResult}async editDCVMethod(e,s){return(await t(this.config,"namecheap.ssl.editDCVMethod",{certificateId:e,...s})).commandResponse.sslEditDcvMethodResult}};var E=class{constructor(e){this.config=e}async getPricing(e){return(await t(this.config,"namecheap.users.getPricing",e)).commandResponse.userGetPricingResult}async getBalances(){return(await t(this.config,"namecheap.users.getBalances")).commandResponse.userGetBalancesResult}async changePassword(e,s){return(await t(this.config,"namecheap.users.changePassword",{oldPassword:e,newPassword:s})).commandResponse.userChangePasswordResult}async update(e){return(await t(this.config,"namecheap.users.update",e)).commandResponse.userUpdateResult}async createAddFundsRequest(e,s){return(await t(this.config,"namecheap.users.createaddfundsrequest",{...s,username:e})).commandResponse.createaddfundsrequestresult}async getAddFundsStatus(e){return(await t(this.config,"namecheap.users.getAddFundsStatus",{tokenId:e})).commandResponse.getAddFundsStatusResult}async create(e){return(await t(this.config,"namecheap.users.create",e)).commandResponse.userCreateResult}async login(e){return(await t(this.config,"namecheap.users.login",{password:e})).commandResponse.userLoginResult}async resetPassword(e){return(await t(this.config,"namecheap.users.resetPassword",e)).commandResponse.userResetPasswordResult}};var T=class{constructor(e){this.config=e}async create(e){return(await t(this.config,"namecheap.users.address.create",e)).commandResponse.addressCreateResult}async delete(e){return(await t(this.config,"namecheap.users.address.delete",{addressId:e})).commandResponse.addressDeleteResult}async getInfo(e){return(await t(this.config,"namecheap.users.address.getInfo",{addressId:e})).commandResponse.getAddressInfoResult}async getList(){return(await t(this.config,"namecheap.users.address.getList")).commandResponse.addressGetListResult}async setDefault(e){return(await t(this.config,"namecheap.users.address.setDefault",{addressId:e})).commandResponse.addressSetDefaultResult}async update(e,s){return(await t(this.config,"namecheap.users.address.update",{...s,addressId:e})).commandResponse.addressUpdateResult}};var w=class{constructor(e){this.config=e}async changeEmailAddress(e){return(await t(this.config,"namecheap.whoisguard.changeemailaddress",{whoIsGuardId:e})).commandResponse.whoisguardChangeEmailAddressResult}async enable(e,s){return(await t(this.config,"namecheap.whoisguard.enable",{whoIsGuardId:e,forwardedToEmail:s})).commandResponse.whoisguardEnableResult}async disable(e){return(await t(this.config,"namecheap.whoisguard.disable",{whoIsGuardId:e})).commandResponse.whoisguardDisableResult}async getList(e){let s=await t(this.config,"namecheap.whoisguard.getList",e);return{data:s.commandResponse.whoisguardGetListResult,paging:s.commandResponse.paging}}async renew(e,s,a){return(await t(this.config,"namecheap.whoisguard.renew",{whoIsGuardId:e,year:s,promotionCode:a})).commandResponse.whoisguardRenewResult}};var I=class{get domainPrivacy(){return this.whoIsGuard}constructor(e){let{apiUser:s,apiKey:a,username:o,clientIp:n,sandbox:i}=e;this.apiUser=s,this.apiKey=a,this.username=o||s,this.clientIp=n,this.apiUrl=U(i),this.domains=new P(this.getConfig()),this.domainsDns=new S(this.getConfig()),this.domainsNs=new L(this.getConfig()),this.domainsTransfer=new A(this.getConfig()),this.ssl=new D(this.getConfig()),this.users=new E(this.getConfig()),this.usersAddress=new T(this.getConfig()),this.whoIsGuard=new w(this.getConfig())}getConfig(){return{apiUser:this.apiUser,apiKey:this.apiKey,username:this.username,clientIp:this.clientIp,apiUrl:this.apiUrl}}};export{ce as DomainDnsTag,J as DomainListSortBy,v as DomainListType,F as DomainTransferListType,O as DomainTransferSortBy,j as EmailType,pe as GetAddFundsStatus,Y as IdnCode,k as LockAction,z as RecordType,ee as SSLListSortBy,Q as SSLListType,Z as SSLType,ae as UserActionName,oe as UserListFindBy,ne as UserPaymentType,te as UserProductCategory,re as UserProductName,se as UserProductType,ie as WhoIsListType,I as default};
|
|
1
|
+
// src/core/errors.ts
|
|
2
|
+
var NamecheapError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
errors;
|
|
5
|
+
constructor(errors) {
|
|
6
|
+
const first = errors[0];
|
|
7
|
+
super(
|
|
8
|
+
first === void 0 ? "Unknown Namecheap error" : first.message.trim() === "" ? `Namecheap error ${first.code}` : first.message
|
|
9
|
+
);
|
|
10
|
+
this.name = "NamecheapError";
|
|
11
|
+
this.code = first?.code ?? -1;
|
|
12
|
+
this.errors = errors;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var NamecheapHttpError = class extends Error {
|
|
16
|
+
status;
|
|
17
|
+
statusText;
|
|
18
|
+
constructor(message, init) {
|
|
19
|
+
super(message, init?.cause === void 0 ? void 0 : { cause: init.cause });
|
|
20
|
+
this.name = "NamecheapHttpError";
|
|
21
|
+
this.status = init?.status;
|
|
22
|
+
this.statusText = init?.statusText ?? "";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var NamecheapParseError = class extends Error {
|
|
26
|
+
constructor(message, init) {
|
|
27
|
+
super(message, init?.cause === void 0 ? void 0 : { cause: init.cause });
|
|
28
|
+
this.name = "NamecheapParseError";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/core/serialize.ts
|
|
33
|
+
var ACRONYMS = [
|
|
34
|
+
"SLD",
|
|
35
|
+
"TLD",
|
|
36
|
+
"IP",
|
|
37
|
+
"ID",
|
|
38
|
+
"DNS",
|
|
39
|
+
"WG",
|
|
40
|
+
"MX",
|
|
41
|
+
"TTL",
|
|
42
|
+
"EPP",
|
|
43
|
+
"CSR",
|
|
44
|
+
"DCV",
|
|
45
|
+
"SSL"
|
|
46
|
+
];
|
|
47
|
+
var hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
48
|
+
function splitWords(key) {
|
|
49
|
+
return key.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(/[\s_]+/).filter((word) => word.length > 0);
|
|
50
|
+
}
|
|
51
|
+
function toWord(word) {
|
|
52
|
+
const upper = word.toUpperCase();
|
|
53
|
+
if (ACRONYMS.includes(upper)) return upper;
|
|
54
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
55
|
+
}
|
|
56
|
+
function toParamName(key) {
|
|
57
|
+
return splitWords(key).map(toWord).join("");
|
|
58
|
+
}
|
|
59
|
+
function isPlainObject(value) {
|
|
60
|
+
if (typeof value !== "object" || value === null) return false;
|
|
61
|
+
const proto = Object.getPrototypeOf(value);
|
|
62
|
+
return proto === Object.prototype || proto === null;
|
|
63
|
+
}
|
|
64
|
+
function isObject(value) {
|
|
65
|
+
return typeof value === "object" && value !== null;
|
|
66
|
+
}
|
|
67
|
+
function serializeParams(params, opts = {}) {
|
|
68
|
+
const arrayStyle = opts.arrayStyle ?? "bracket";
|
|
69
|
+
const keys = opts.keys ?? {};
|
|
70
|
+
const out = [];
|
|
71
|
+
const walk = (obj, path, prefix) => {
|
|
72
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
73
|
+
if (value === void 0 || value === null) continue;
|
|
74
|
+
const keyPath = [...path, key];
|
|
75
|
+
const dotted = keyPath.join(".");
|
|
76
|
+
const name = (hasOwn(keys, dotted) ? keys[dotted] : void 0) ?? prefix + toParamName(key);
|
|
77
|
+
if (Array.isArray(value)) {
|
|
78
|
+
if (value.some((item) => isPlainObject(item))) {
|
|
79
|
+
value.forEach((item, position) => {
|
|
80
|
+
if (item === void 0 || item === null) {
|
|
81
|
+
throw new TypeError(
|
|
82
|
+
`Array parameter "${dotted}" cannot contain null or undefined records`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (!isPlainObject(item)) {
|
|
86
|
+
throw new TypeError(`Array parameter "${dotted}" cannot mix objects and scalars`);
|
|
87
|
+
}
|
|
88
|
+
for (const [field, fieldValue] of Object.entries(item)) {
|
|
89
|
+
if (fieldValue === void 0 || fieldValue === null) continue;
|
|
90
|
+
if (isObject(fieldValue)) {
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
`Array parameter "${dotted}" field "${field}" must be a scalar value`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
out.push([`${toParamName(field)}${position + 1}`, String(fieldValue)]);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let index = 0;
|
|
101
|
+
for (const item of value) {
|
|
102
|
+
if (item === void 0 || item === null) continue;
|
|
103
|
+
if (isObject(item)) {
|
|
104
|
+
throw new TypeError(
|
|
105
|
+
`Array parameter "${dotted}" cannot contain nested arrays or non-plain objects`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
index += 1;
|
|
109
|
+
out.push([
|
|
110
|
+
arrayStyle === "bracket" ? `${name}[${index}]` : `${name}${index}`,
|
|
111
|
+
String(item)
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
} else if (isObject(value)) {
|
|
115
|
+
walk(value, keyPath, name);
|
|
116
|
+
} else {
|
|
117
|
+
out.push([name, String(value)]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
walk(params, [], "");
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/core/define.ts
|
|
126
|
+
var RESERVED_NAMES = /* @__PURE__ */ new Set(["apiuser", "apikey", "username", "clientip", "command"]);
|
|
127
|
+
function defineCommand(def) {
|
|
128
|
+
return def;
|
|
129
|
+
}
|
|
130
|
+
async function run(command, send, ...args) {
|
|
131
|
+
const params = args[0] ?? {};
|
|
132
|
+
command.validate?.(params);
|
|
133
|
+
const options = {};
|
|
134
|
+
if (command.arrayStyle !== void 0) options.arrayStyle = command.arrayStyle;
|
|
135
|
+
if (command.keys !== void 0) options.keys = command.keys;
|
|
136
|
+
const serialized = serializeParams(params, options);
|
|
137
|
+
for (const [name] of serialized) {
|
|
138
|
+
if (RESERVED_NAMES.has(name.toLowerCase())) {
|
|
139
|
+
throw new TypeError(`Parameter "${name}" is reserved: the client sets it itself`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const el = await send({ command: command.name, params: serialized });
|
|
143
|
+
try {
|
|
144
|
+
return command.parse(el);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
if (error instanceof NamecheapParseError) {
|
|
147
|
+
throw new NamecheapParseError(
|
|
148
|
+
`${command.name}: Namecheap reported success but the response could not be read; the action may have been performed, verify before retrying`,
|
|
149
|
+
{ cause: error }
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function group(commands, send) {
|
|
156
|
+
const out = {};
|
|
157
|
+
for (const [key, command] of Object.entries(commands)) {
|
|
158
|
+
out[key] = (params) => run(command, send, params);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/core/fields.ts
|
|
164
|
+
function optionalField(key, value) {
|
|
165
|
+
return value === void 0 ? {} : { [key]: value };
|
|
166
|
+
}
|
|
167
|
+
function firstLenientNumber(el, ...names) {
|
|
168
|
+
for (const name of names) {
|
|
169
|
+
if (el.optionalString(name) !== void 0) return el.lenientNumber(name);
|
|
170
|
+
}
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/commands/dns.ts
|
|
175
|
+
var setDefault = /* @__PURE__ */ defineCommand({
|
|
176
|
+
name: "namecheap.domains.dns.setDefault",
|
|
177
|
+
parse: (cr) => {
|
|
178
|
+
const result = cr.one("DomainDNSSetDefaultResult");
|
|
179
|
+
return { domain: result.string("Domain"), updated: result.boolean("Updated") };
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
var setCustom = /* @__PURE__ */ defineCommand({
|
|
183
|
+
name: "namecheap.domains.dns.setCustom",
|
|
184
|
+
parse: (cr) => {
|
|
185
|
+
const result = cr.one("DomainDNSSetCustomResult");
|
|
186
|
+
return { domain: result.string("Domain"), updated: result.boolean("Updated") };
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
var getList = /* @__PURE__ */ defineCommand({
|
|
190
|
+
name: "namecheap.domains.dns.getList",
|
|
191
|
+
parse: (cr) => {
|
|
192
|
+
const result = cr.one("DomainDNSGetListResult");
|
|
193
|
+
return {
|
|
194
|
+
domain: result.string("Domain"),
|
|
195
|
+
isUsingOurDNS: result.boolean("IsUsingOurDNS"),
|
|
196
|
+
...optionalField("isPremiumDNS", result.optionalBoolean("IsPremiumDNS")),
|
|
197
|
+
...optionalField("isUsingFreeDNS", result.optionalBoolean("IsUsingFreeDNS")),
|
|
198
|
+
nameservers: result.all("Nameserver").map((ns) => ns.text())
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
function parseHost(host) {
|
|
203
|
+
return {
|
|
204
|
+
hostId: host.number("HostId"),
|
|
205
|
+
name: host.string("Name"),
|
|
206
|
+
type: host.string("Type"),
|
|
207
|
+
address: host.string("Address"),
|
|
208
|
+
mxPref: host.number("MXPref"),
|
|
209
|
+
ttl: host.number("TTL"),
|
|
210
|
+
...optionalField("associatedAppTitle", host.optionalString("AssociatedAppTitle")),
|
|
211
|
+
...optionalField("friendlyName", host.optionalString("FriendlyName")),
|
|
212
|
+
...optionalField("isActive", host.optionalBoolean("IsActive")),
|
|
213
|
+
...optionalField("isDDNSEnabled", host.optionalBoolean("IsDDNSEnabled"))
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
var getHosts = /* @__PURE__ */ defineCommand({
|
|
217
|
+
name: "namecheap.domains.dns.getHosts",
|
|
218
|
+
parse: (cr) => {
|
|
219
|
+
const result = cr.one("DomainDNSGetHostsResult");
|
|
220
|
+
return {
|
|
221
|
+
domain: result.string("Domain"),
|
|
222
|
+
...optionalField("emailType", result.optionalString("EmailType")),
|
|
223
|
+
isUsingOurDNS: result.boolean("IsUsingOurDNS"),
|
|
224
|
+
hosts: result.all("host").map(parseHost)
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
var getEmailForwarding = /* @__PURE__ */ defineCommand({
|
|
229
|
+
name: "namecheap.domains.dns.getEmailForwarding",
|
|
230
|
+
parse: (cr) => {
|
|
231
|
+
const result = cr.one("DomainEmailForwardingResult");
|
|
232
|
+
return {
|
|
233
|
+
domain: result.string("Domain"),
|
|
234
|
+
forwards: result.all("Forward").map((forward) => ({
|
|
235
|
+
mailbox: forward.string("mailbox"),
|
|
236
|
+
...optionalField("forwardTo", forward.optionalString("ForwardTo"))
|
|
237
|
+
}))
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
var setEmailForwarding = /* @__PURE__ */ defineCommand({
|
|
242
|
+
name: "namecheap.domains.dns.setEmailForwarding",
|
|
243
|
+
parse: (cr) => {
|
|
244
|
+
const result = cr.one("DomainEmailForwardingResult");
|
|
245
|
+
return { domain: result.string("Domain"), isSuccess: result.boolean("IsSuccess") };
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
var setHosts = /* @__PURE__ */ defineCommand({
|
|
249
|
+
name: "namecheap.domains.dns.setHosts",
|
|
250
|
+
validate: (params) => {
|
|
251
|
+
if (!params.hosts?.some((host) => host !== void 0 && host !== null)) {
|
|
252
|
+
throw new TypeError(
|
|
253
|
+
"dns.setHosts requires at least one host record: it replaces the whole zone, so an empty list would delete every record"
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
parse: (cr) => {
|
|
258
|
+
const result = cr.one("DomainDNSSetHostsResult");
|
|
259
|
+
return {
|
|
260
|
+
domain: result.string("Domain"),
|
|
261
|
+
...optionalField("emailType", result.optionalString("EmailType")),
|
|
262
|
+
isSuccess: result.boolean("IsSuccess")
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
var dnsCommands = {
|
|
267
|
+
setDefault,
|
|
268
|
+
setCustom,
|
|
269
|
+
getList,
|
|
270
|
+
getHosts,
|
|
271
|
+
getEmailForwarding,
|
|
272
|
+
setEmailForwarding,
|
|
273
|
+
setHosts
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// src/core/paging.ts
|
|
277
|
+
function parsePaging(el) {
|
|
278
|
+
return {
|
|
279
|
+
totalItems: el.one("TotalItems").numberText(),
|
|
280
|
+
currentPage: el.one("CurrentPage").numberText(),
|
|
281
|
+
pageSize: el.one("PageSize").numberText()
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// src/commands/domains.ts
|
|
286
|
+
function parseListItem(domain) {
|
|
287
|
+
return {
|
|
288
|
+
id: domain.number("ID"),
|
|
289
|
+
name: domain.string("Name"),
|
|
290
|
+
user: domain.string("User"),
|
|
291
|
+
created: domain.string("Created"),
|
|
292
|
+
expires: domain.string("Expires"),
|
|
293
|
+
isExpired: domain.boolean("IsExpired"),
|
|
294
|
+
isLocked: domain.boolean("IsLocked"),
|
|
295
|
+
autoRenew: domain.boolean("AutoRenew"),
|
|
296
|
+
whoisGuard: domain.string("WhoisGuard"),
|
|
297
|
+
isPremium: domain.boolean("IsPremium"),
|
|
298
|
+
isOurDNS: domain.boolean("IsOurDNS")
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
var getList2 = /* @__PURE__ */ defineCommand({
|
|
302
|
+
name: "namecheap.domains.getList",
|
|
303
|
+
parse: (cr) => ({
|
|
304
|
+
domains: (cr.optional("DomainGetListResult")?.all("Domain") ?? []).map(parseListItem),
|
|
305
|
+
paging: parsePaging(cr.one("Paging"))
|
|
306
|
+
})
|
|
307
|
+
});
|
|
308
|
+
var check = /* @__PURE__ */ defineCommand({
|
|
309
|
+
name: "namecheap.domains.check",
|
|
310
|
+
parse: (cr) => cr.all("DomainCheckResult").map((item) => ({
|
|
311
|
+
domain: item.string("Domain"),
|
|
312
|
+
available: item.boolean("Available"),
|
|
313
|
+
...optionalField("errorNo", item.optionalNumber("ErrorNo")),
|
|
314
|
+
...optionalField("description", item.optionalString("Description")),
|
|
315
|
+
isPremiumName: item.boolean("IsPremiumName"),
|
|
316
|
+
premiumRegistrationPrice: item.number("PremiumRegistrationPrice"),
|
|
317
|
+
premiumRenewalPrice: item.number("PremiumRenewalPrice"),
|
|
318
|
+
premiumRestorePrice: item.number("PremiumRestorePrice"),
|
|
319
|
+
premiumTransferPrice: item.number("PremiumTransferPrice"),
|
|
320
|
+
icannFee: item.number("IcannFee"),
|
|
321
|
+
eapFee: item.number("EapFee")
|
|
322
|
+
}))
|
|
323
|
+
});
|
|
324
|
+
var getRegistrarLock = /* @__PURE__ */ defineCommand({
|
|
325
|
+
name: "namecheap.domains.getRegistrarLock",
|
|
326
|
+
parse: (cr) => {
|
|
327
|
+
const result = cr.one("DomainGetRegistrarLockResult");
|
|
328
|
+
return {
|
|
329
|
+
domain: result.string("Domain"),
|
|
330
|
+
registrarLockStatus: result.boolean("RegistrarLockStatus")
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
var setRegistrarLock = /* @__PURE__ */ defineCommand({
|
|
335
|
+
name: "namecheap.domains.setRegistrarLock",
|
|
336
|
+
parse: (cr) => {
|
|
337
|
+
const result = cr.one("DomainSetRegistrarLockResult");
|
|
338
|
+
return { domain: result.string("Domain"), isSuccess: result.boolean("IsSuccess") };
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
var reactivate = /* @__PURE__ */ defineCommand({
|
|
342
|
+
name: "namecheap.domains.reactivate",
|
|
343
|
+
parse: (cr) => {
|
|
344
|
+
const result = cr.one("DomainReactivateResult");
|
|
345
|
+
return {
|
|
346
|
+
domain: result.string("Domain"),
|
|
347
|
+
isSuccess: result.boolean("IsSuccess"),
|
|
348
|
+
chargedAmount: result.number("ChargedAmount"),
|
|
349
|
+
orderID: result.number("OrderID"),
|
|
350
|
+
transactionID: result.number("TransactionID")
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
var renew = /* @__PURE__ */ defineCommand({
|
|
355
|
+
name: "namecheap.domains.renew",
|
|
356
|
+
parse: (cr) => {
|
|
357
|
+
const result = cr.one("DomainRenewResult");
|
|
358
|
+
const details = result.one("DomainDetails");
|
|
359
|
+
return {
|
|
360
|
+
domainName: result.string("DomainName"),
|
|
361
|
+
domainID: result.number("DomainID"),
|
|
362
|
+
renew: result.boolean("Renew"),
|
|
363
|
+
chargedAmount: result.number("ChargedAmount"),
|
|
364
|
+
orderID: result.number("OrderID"),
|
|
365
|
+
transactionID: result.number("TransactionID"),
|
|
366
|
+
domainDetails: {
|
|
367
|
+
expiredDate: details.one("ExpiredDate").text(),
|
|
368
|
+
numYears: details.one("NumYears").numberText()
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
var setContacts = /* @__PURE__ */ defineCommand({
|
|
374
|
+
name: "namecheap.domains.setContacts",
|
|
375
|
+
parse: (cr) => {
|
|
376
|
+
const result = cr.one("DomainSetContactResult");
|
|
377
|
+
return { domain: result.string("Domain"), isSuccess: result.boolean("IsSuccess") };
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
var create = /* @__PURE__ */ defineCommand({
|
|
381
|
+
name: "namecheap.domains.create",
|
|
382
|
+
parse: (cr) => {
|
|
383
|
+
const result = cr.one("DomainCreateResult");
|
|
384
|
+
return {
|
|
385
|
+
domain: result.string("Domain"),
|
|
386
|
+
registered: result.boolean("Registered"),
|
|
387
|
+
chargedAmount: result.number("ChargedAmount"),
|
|
388
|
+
domainID: result.number("DomainID"),
|
|
389
|
+
orderID: result.number("OrderID"),
|
|
390
|
+
transactionID: result.number("TransactionID"),
|
|
391
|
+
...optionalField("whoisguardEnable", result.lenientBoolean("WhoisguardEnable")),
|
|
392
|
+
...optionalField("nonRealTimeDomain", result.lenientBoolean("NonRealTimeDomain"))
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
var getTldList = /* @__PURE__ */ defineCommand({
|
|
397
|
+
name: "namecheap.domains.getTldList",
|
|
398
|
+
parse: (cr) => (cr.optional("Tlds")?.all("Tld") ?? []).map((tld) => ({
|
|
399
|
+
name: tld.string("Name"),
|
|
400
|
+
nonRealTimeDomain: tld.boolean("NonRealTimeDomain"),
|
|
401
|
+
minRegisterYears: tld.number("MinRegisterYears"),
|
|
402
|
+
maxRegisterYears: tld.number("MaxRegisterYears"),
|
|
403
|
+
minRenewYears: tld.number("MinRenewYears"),
|
|
404
|
+
maxRenewYears: tld.number("MaxRenewYears"),
|
|
405
|
+
minTransferYears: tld.number("MinTransferYears"),
|
|
406
|
+
maxTransferYears: tld.number("MaxTransferYears"),
|
|
407
|
+
isApiRegisterable: tld.boolean("IsApiRegisterable"),
|
|
408
|
+
isApiRenewable: tld.boolean("IsApiRenewable"),
|
|
409
|
+
isApiTransferable: tld.boolean("IsApiTransferable"),
|
|
410
|
+
isEppRequired: tld.boolean("IsEppRequired"),
|
|
411
|
+
description: tld.text()
|
|
412
|
+
}))
|
|
413
|
+
});
|
|
414
|
+
function parseContact(contact) {
|
|
415
|
+
const text = (name) => contact.optionalText(name);
|
|
416
|
+
return {
|
|
417
|
+
...optionalField("organizationName", text("OrganizationName")),
|
|
418
|
+
...optionalField("jobTitle", text("JobTitle")),
|
|
419
|
+
...optionalField("firstName", text("FirstName")),
|
|
420
|
+
...optionalField("lastName", text("LastName")),
|
|
421
|
+
...optionalField("address1", text("Address1")),
|
|
422
|
+
...optionalField("address2", text("Address2")),
|
|
423
|
+
...optionalField("city", text("City")),
|
|
424
|
+
...optionalField("stateProvince", text("StateProvince")),
|
|
425
|
+
...optionalField("postalCode", text("PostalCode")),
|
|
426
|
+
...optionalField("country", text("Country")),
|
|
427
|
+
...optionalField("phone", text("Phone")),
|
|
428
|
+
...optionalField("emailAddress", text("EmailAddress"))
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
var getContacts = /* @__PURE__ */ defineCommand({
|
|
432
|
+
name: "namecheap.domains.getContacts",
|
|
433
|
+
parse: (cr) => {
|
|
434
|
+
const result = cr.one("DomainContactsResult");
|
|
435
|
+
const contact = (name) => {
|
|
436
|
+
const found = result.optional(name);
|
|
437
|
+
return found === void 0 ? void 0 : parseContact(found);
|
|
438
|
+
};
|
|
439
|
+
return {
|
|
440
|
+
domain: result.string("Domain"),
|
|
441
|
+
domainnameid: result.number("domainnameid"),
|
|
442
|
+
readonly: result.boolean("Readonly"),
|
|
443
|
+
...optionalField("registrant", contact("Registrant")),
|
|
444
|
+
...optionalField("tech", contact("Tech")),
|
|
445
|
+
...optionalField("admin", contact("Admin")),
|
|
446
|
+
...optionalField("auxBilling", contact("AuxBilling"))
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
function parseWhoisguard(whoisguard) {
|
|
451
|
+
const emailDetails = whoisguard.optional("EmailDetails");
|
|
452
|
+
return {
|
|
453
|
+
enabled: whoisguard.string("Enabled"),
|
|
454
|
+
id: whoisguard.one("ID").numberText(),
|
|
455
|
+
...optionalField("expiredDate", whoisguard.optionalText("ExpiredDate")),
|
|
456
|
+
...optionalField(
|
|
457
|
+
"emailDetails",
|
|
458
|
+
emailDetails === void 0 ? void 0 : {
|
|
459
|
+
whoisGuardEmail: emailDetails.string("WhoisGuardEmail"),
|
|
460
|
+
forwardedTo: emailDetails.string("ForwardedTo"),
|
|
461
|
+
lastAutoEmailChangeDate: emailDetails.string("LastAutoEmailChangeDate"),
|
|
462
|
+
autoEmailChangeFrequencyDays: emailDetails.number("AutoEmailChangeFrequencyDays")
|
|
463
|
+
}
|
|
464
|
+
)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
var getInfo = /* @__PURE__ */ defineCommand({
|
|
468
|
+
name: "namecheap.domains.getInfo",
|
|
469
|
+
parse: (cr) => {
|
|
470
|
+
const result = cr.one("DomainGetInfoResult");
|
|
471
|
+
const details = result.one("DomainDetails");
|
|
472
|
+
const premiumDns = result.one("PremiumDnsSubscription");
|
|
473
|
+
const dns = result.one("DnsDetails");
|
|
474
|
+
const rights = result.one("Modificationrights");
|
|
475
|
+
return {
|
|
476
|
+
...optionalField("status", result.optionalString("Status")),
|
|
477
|
+
id: result.number("ID"),
|
|
478
|
+
domainName: result.string("DomainName"),
|
|
479
|
+
ownerName: result.string("OwnerName"),
|
|
480
|
+
isOwner: result.boolean("IsOwner"),
|
|
481
|
+
isPremium: result.boolean("IsPremium"),
|
|
482
|
+
domainDetails: {
|
|
483
|
+
...optionalField("createdDate", details.optionalText("CreatedDate")),
|
|
484
|
+
...optionalField("expiredDate", details.optionalText("ExpiredDate")),
|
|
485
|
+
numYears: details.one("NumYears").numberText()
|
|
486
|
+
},
|
|
487
|
+
whoisguard: parseWhoisguard(result.one("Whoisguard")),
|
|
488
|
+
premiumDnsSubscription: {
|
|
489
|
+
useAutoRenew: premiumDns.one("UseAutoRenew").booleanText(),
|
|
490
|
+
subscriptionId: premiumDns.one("SubscriptionId").numberText(),
|
|
491
|
+
createdDate: premiumDns.one("CreatedDate").text(),
|
|
492
|
+
expirationDate: premiumDns.one("ExpirationDate").text(),
|
|
493
|
+
isActive: premiumDns.one("IsActive").booleanText()
|
|
494
|
+
},
|
|
495
|
+
dnsDetails: {
|
|
496
|
+
providerType: dns.string("ProviderType"),
|
|
497
|
+
isUsingOurDNS: dns.boolean("IsUsingOurDNS"),
|
|
498
|
+
hostCount: dns.number("HostCount"),
|
|
499
|
+
emailType: dns.string("EmailType"),
|
|
500
|
+
dynamicDNSStatus: dns.boolean("DynamicDNSStatus"),
|
|
501
|
+
isFailover: dns.boolean("IsFailover"),
|
|
502
|
+
nameservers: dns.all("Nameserver").map((nameserver) => nameserver.text())
|
|
503
|
+
},
|
|
504
|
+
modificationrights: {
|
|
505
|
+
...optionalField("all", rights.optionalBoolean("All")),
|
|
506
|
+
rights: rights.all("Rights").map((right) => ({
|
|
507
|
+
type: right.string("Type"),
|
|
508
|
+
value: right.text()
|
|
509
|
+
}))
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
var domainsCommands = {
|
|
515
|
+
getList: getList2,
|
|
516
|
+
check,
|
|
517
|
+
getRegistrarLock,
|
|
518
|
+
setRegistrarLock,
|
|
519
|
+
reactivate,
|
|
520
|
+
renew,
|
|
521
|
+
setContacts,
|
|
522
|
+
create,
|
|
523
|
+
getTldList,
|
|
524
|
+
getContacts,
|
|
525
|
+
getInfo
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// src/commands/ns.ts
|
|
529
|
+
var create2 = /* @__PURE__ */ defineCommand({
|
|
530
|
+
name: "namecheap.domains.ns.create",
|
|
531
|
+
parse: (cr) => {
|
|
532
|
+
const result = cr.one("DomainNSCreateResult");
|
|
533
|
+
return {
|
|
534
|
+
domain: result.string("Domain"),
|
|
535
|
+
nameserver: result.string("Nameserver"),
|
|
536
|
+
ip: result.string("IP"),
|
|
537
|
+
isSuccess: result.boolean("IsSuccess")
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
var deleteNs = /* @__PURE__ */ defineCommand({
|
|
542
|
+
name: "namecheap.domains.ns.delete",
|
|
543
|
+
parse: (cr) => {
|
|
544
|
+
const result = cr.one("DomainNSDeleteResult");
|
|
545
|
+
return {
|
|
546
|
+
domain: result.string("Domain"),
|
|
547
|
+
nameserver: result.string("Nameserver"),
|
|
548
|
+
isSuccess: result.boolean("IsSuccess")
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
var getInfo2 = /* @__PURE__ */ defineCommand({
|
|
553
|
+
name: "namecheap.domains.ns.getInfo",
|
|
554
|
+
parse: (cr) => {
|
|
555
|
+
const result = cr.one("DomainNSInfoResult");
|
|
556
|
+
const statuses = result.optional("NameserverStatuses");
|
|
557
|
+
return {
|
|
558
|
+
domain: result.string("Domain"),
|
|
559
|
+
nameserver: result.string("Nameserver"),
|
|
560
|
+
ip: result.string("IP"),
|
|
561
|
+
...optionalField(
|
|
562
|
+
"nameserverStatuses",
|
|
563
|
+
statuses?.all("Status").map((status) => status.text())
|
|
564
|
+
)
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
var update = /* @__PURE__ */ defineCommand({
|
|
569
|
+
name: "namecheap.domains.ns.update",
|
|
570
|
+
parse: (cr) => {
|
|
571
|
+
const result = cr.one("DomainNSUpdateResult");
|
|
572
|
+
return {
|
|
573
|
+
domain: result.string("Domain"),
|
|
574
|
+
nameserver: result.string("Nameserver"),
|
|
575
|
+
isSuccess: result.boolean("IsSuccess")
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
var nsCommands = { create: create2, delete: deleteNs, getInfo: getInfo2, update };
|
|
580
|
+
|
|
581
|
+
// src/commands/ssl.ts
|
|
582
|
+
var create3 = /* @__PURE__ */ defineCommand({
|
|
583
|
+
name: "namecheap.ssl.create",
|
|
584
|
+
keys: { sansToAdd: "SANStoADD" },
|
|
585
|
+
parse: (cr) => {
|
|
586
|
+
const wrapper = cr.optional("SSLCreateResult") ?? cr.children()[0];
|
|
587
|
+
if (wrapper === void 0) return {};
|
|
588
|
+
const nested = wrapper.optional("SSLCertificate");
|
|
589
|
+
const sources = nested === void 0 ? [wrapper] : [wrapper, nested];
|
|
590
|
+
const pick = (read) => sources.map(read).find((value) => value !== void 0);
|
|
591
|
+
return {
|
|
592
|
+
...optionalField("isSuccess", wrapper.lenientBoolean("IsSuccess")),
|
|
593
|
+
...optionalField("orderID", firstLenientNumber(wrapper, "OrderID", "OrderId")),
|
|
594
|
+
...optionalField(
|
|
595
|
+
"transactionID",
|
|
596
|
+
firstLenientNumber(wrapper, "TransactionID", "TransactionId")
|
|
597
|
+
),
|
|
598
|
+
...optionalField("chargedAmount", wrapper.lenientNumber("ChargedAmount")),
|
|
599
|
+
...optionalField(
|
|
600
|
+
"certificateID",
|
|
601
|
+
pick((el) => el.lenientNumber("CertificateID"))
|
|
602
|
+
),
|
|
603
|
+
...optionalField(
|
|
604
|
+
"created",
|
|
605
|
+
pick((el) => el.optionalString("Created"))
|
|
606
|
+
),
|
|
607
|
+
...optionalField(
|
|
608
|
+
"sslType",
|
|
609
|
+
pick((el) => el.optionalString("SSLType"))
|
|
610
|
+
),
|
|
611
|
+
...optionalField(
|
|
612
|
+
"status",
|
|
613
|
+
pick((el) => el.optionalString("Status"))
|
|
614
|
+
)
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
function parseListItem2(ssl) {
|
|
619
|
+
return {
|
|
620
|
+
certificateID: ssl.number("CertificateID"),
|
|
621
|
+
hostName: ssl.string("HostName"),
|
|
622
|
+
sslType: ssl.string("SSLType"),
|
|
623
|
+
purchaseDate: ssl.string("PurchaseDate"),
|
|
624
|
+
expireDate: ssl.string("ExpireDate"),
|
|
625
|
+
...optionalField("status", ssl.optionalString("Status"))
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
var getList3 = /* @__PURE__ */ defineCommand({
|
|
629
|
+
name: "namecheap.ssl.getList",
|
|
630
|
+
parse: (cr) => ({
|
|
631
|
+
certificates: (cr.optional("SSLListResult")?.all("SSL") ?? []).map(parseListItem2),
|
|
632
|
+
paging: parsePaging(cr.one("Paging"))
|
|
633
|
+
})
|
|
634
|
+
});
|
|
635
|
+
var parseCSR = /* @__PURE__ */ defineCommand({
|
|
636
|
+
name: "namecheap.ssl.parseCSR",
|
|
637
|
+
keys: { csr: "csr" },
|
|
638
|
+
parse: (cr) => {
|
|
639
|
+
const details = cr.one("SSLParseCSRResult").one("CSRDetails");
|
|
640
|
+
return {
|
|
641
|
+
commonName: details.one("CommonName").text(),
|
|
642
|
+
domainName: details.one("DomainName").text(),
|
|
643
|
+
country: details.one("Country").text(),
|
|
644
|
+
organisationUnit: details.one("OrganisationUnit").text(),
|
|
645
|
+
organisation: details.one("Organisation").text(),
|
|
646
|
+
state: details.one("State").text(),
|
|
647
|
+
locality: details.one("Locality").text(),
|
|
648
|
+
email: details.one("Email").text()
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
function emails(result, group2) {
|
|
653
|
+
return (result.optional(group2)?.all("email") ?? []).map((email) => email.text());
|
|
654
|
+
}
|
|
655
|
+
var getApproverEmailList = /* @__PURE__ */ defineCommand({
|
|
656
|
+
name: "namecheap.ssl.getApproverEmailList",
|
|
657
|
+
parse: (cr) => {
|
|
658
|
+
const result = cr.one("GetApproverEmailListResult");
|
|
659
|
+
return {
|
|
660
|
+
domainEmails: emails(result, "Domainemails"),
|
|
661
|
+
genericEmails: emails(result, "Genericemails"),
|
|
662
|
+
manualEmails: emails(result, "Manualemails")
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
function parseHttpDcValidation(result) {
|
|
667
|
+
const validation = result.optional("HttpDCValidation");
|
|
668
|
+
if (validation === void 0) return void 0;
|
|
669
|
+
return {
|
|
670
|
+
valueAvailable: validation.boolean("ValueAvailable"),
|
|
671
|
+
...optionalField("fileName", validation.optionalText("FileName")),
|
|
672
|
+
...optionalField("fileContent", validation.optionalText("FileContent"))
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
function parseActivation(result) {
|
|
676
|
+
return {
|
|
677
|
+
id: result.number("ID"),
|
|
678
|
+
isSuccess: result.boolean("IsSuccess"),
|
|
679
|
+
...optionalField("httpDCValidation", parseHttpDcValidation(result))
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
var activate = /* @__PURE__ */ defineCommand({
|
|
683
|
+
name: "namecheap.ssl.activate",
|
|
684
|
+
parse: (cr) => parseActivation(cr.one("SSLActivateResult"))
|
|
685
|
+
});
|
|
686
|
+
function parseResend(result) {
|
|
687
|
+
return { id: result.number("ID"), isSuccess: result.boolean("IsSuccess") };
|
|
688
|
+
}
|
|
689
|
+
var resendApproverEmail = /* @__PURE__ */ defineCommand({
|
|
690
|
+
name: "namecheap.ssl.resendApproverEmail",
|
|
691
|
+
parse: (cr) => parseResend(cr.one("SSLResendApproverEmailResult"))
|
|
692
|
+
});
|
|
693
|
+
var reissue = /* @__PURE__ */ defineCommand({
|
|
694
|
+
name: "namecheap.ssl.reissue",
|
|
695
|
+
parse: (cr) => parseActivation(cr.one("SSLReissueResult"))
|
|
696
|
+
});
|
|
697
|
+
var resendFulfillmentEmail = /* @__PURE__ */ defineCommand({
|
|
698
|
+
name: "namecheap.ssl.resendfulfillmentemail",
|
|
699
|
+
parse: (cr) => parseResend(cr.one("SSLResendFulfillmentEmailResult"))
|
|
700
|
+
});
|
|
701
|
+
var editDCVMethod = /* @__PURE__ */ defineCommand(
|
|
702
|
+
{
|
|
703
|
+
name: "namecheap.ssl.editDCVMethod",
|
|
704
|
+
parse: (cr) => parseActivation(cr.one("SSLEditDCVMethodResult"))
|
|
705
|
+
}
|
|
706
|
+
);
|
|
707
|
+
var getInfo3 = /* @__PURE__ */ defineCommand({
|
|
708
|
+
name: "namecheap.ssl.getInfo",
|
|
709
|
+
keys: { returnCertificate: "Returncertificate", returnType: "Returntype" },
|
|
710
|
+
parse: (cr) => {
|
|
711
|
+
const result = cr.one("SSLGetInfoResult");
|
|
712
|
+
return {
|
|
713
|
+
certificateID: result.number("CertificateID"),
|
|
714
|
+
status: result.string("Status"),
|
|
715
|
+
...optionalField("type", result.optionalString("Type")),
|
|
716
|
+
...optionalField("commonName", result.optionalString("CommonName")),
|
|
717
|
+
...optionalField("provider", result.optionalString("Provider")),
|
|
718
|
+
...optionalField("issuedOn", result.optionalString("IssuedOn")),
|
|
719
|
+
...optionalField("expires", result.optionalString("Expires"))
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
var renew2 = /* @__PURE__ */ defineCommand({
|
|
724
|
+
name: "namecheap.ssl.renew",
|
|
725
|
+
parse: (cr) => {
|
|
726
|
+
const result = cr.optional("SSLRenewResult") ?? cr.children()[0];
|
|
727
|
+
if (result === void 0) return {};
|
|
728
|
+
return {
|
|
729
|
+
...optionalField("certificateID", result.lenientNumber("CertificateID")),
|
|
730
|
+
...optionalField("years", result.lenientNumber("Years")),
|
|
731
|
+
...optionalField("orderID", firstLenientNumber(result, "OrderID", "OrderId")),
|
|
732
|
+
...optionalField(
|
|
733
|
+
"transactionID",
|
|
734
|
+
firstLenientNumber(result, "TransactionID", "TransactionId")
|
|
735
|
+
),
|
|
736
|
+
...optionalField("chargedAmount", result.lenientNumber("ChargedAmount"))
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
var purchaseMoreSans = /* @__PURE__ */ defineCommand({
|
|
741
|
+
name: "namecheap.ssl.purchasemoresans",
|
|
742
|
+
keys: { numberOfSansToAdd: "NumberOfSANSToAdd" },
|
|
743
|
+
parse: (cr) => {
|
|
744
|
+
const result = cr.optional("SSLPurchaseMoreSansResult") ?? cr.children()[0];
|
|
745
|
+
if (result === void 0) return {};
|
|
746
|
+
return {
|
|
747
|
+
...optionalField("isSuccess", result.lenientBoolean("IsSuccess")),
|
|
748
|
+
...optionalField("orderID", firstLenientNumber(result, "OrderID", "OrderId")),
|
|
749
|
+
...optionalField(
|
|
750
|
+
"transactionID",
|
|
751
|
+
firstLenientNumber(result, "TransactionID", "TransactionId")
|
|
752
|
+
),
|
|
753
|
+
...optionalField("chargedAmount", result.lenientNumber("ChargedAmount")),
|
|
754
|
+
...optionalField("certificateID", result.lenientNumber("CertificateID")),
|
|
755
|
+
...optionalField("sslType", result.optionalString("SSLType")),
|
|
756
|
+
...optionalField("sansCount", result.lenientNumber("SANSCount"))
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
var revokeCertificate = /* @__PURE__ */ defineCommand({
|
|
761
|
+
name: "namecheap.ssl.revokecertificate",
|
|
762
|
+
parse: (cr) => {
|
|
763
|
+
const result = cr.one("SSLRevokeCertificateResult");
|
|
764
|
+
return {
|
|
765
|
+
isSuccess: result.boolean("IsSuccess"),
|
|
766
|
+
certificateID: result.number("CertificateID")
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
var sslCommands = {
|
|
771
|
+
create: create3,
|
|
772
|
+
getList: getList3,
|
|
773
|
+
parseCSR,
|
|
774
|
+
getApproverEmailList,
|
|
775
|
+
activate,
|
|
776
|
+
resendApproverEmail,
|
|
777
|
+
reissue,
|
|
778
|
+
resendFulfillmentEmail,
|
|
779
|
+
editDCVMethod,
|
|
780
|
+
getInfo: getInfo3,
|
|
781
|
+
renew: renew2,
|
|
782
|
+
purchaseMoreSans,
|
|
783
|
+
revokeCertificate
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
// src/commands/transfer.ts
|
|
787
|
+
var create4 = /* @__PURE__ */ defineCommand({
|
|
788
|
+
name: "namecheap.domains.transfer.create",
|
|
789
|
+
keys: { wgEnable: "WGenable" },
|
|
790
|
+
parse: (cr) => {
|
|
791
|
+
const result = cr.one("DomainTransferCreateResult");
|
|
792
|
+
return {
|
|
793
|
+
domainName: result.string("DomainName"),
|
|
794
|
+
transferID: result.number("TransferID"),
|
|
795
|
+
statusID: result.number("StatusID"),
|
|
796
|
+
orderID: result.number("OrderID"),
|
|
797
|
+
transactionID: result.number("TransactionID"),
|
|
798
|
+
chargedAmount: result.number("ChargedAmount")
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
var getStatus = /* @__PURE__ */ defineCommand({
|
|
803
|
+
name: "namecheap.domains.transfer.getStatus",
|
|
804
|
+
parse: (cr) => {
|
|
805
|
+
const result = cr.one("DomainTransferGetStatusResult");
|
|
806
|
+
return {
|
|
807
|
+
transferID: result.number("TransferID"),
|
|
808
|
+
statusID: result.number("StatusID"),
|
|
809
|
+
status: result.string("Status")
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
var updateStatus = /* @__PURE__ */ defineCommand({
|
|
814
|
+
name: "namecheap.domains.transfer.updateStatus",
|
|
815
|
+
parse: (cr) => {
|
|
816
|
+
const result = cr.one("DomainTransferUpdateStatusResult");
|
|
817
|
+
return {
|
|
818
|
+
transferID: result.number("TransferID"),
|
|
819
|
+
resubmit: result.boolean("Resubmit")
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
function parseListItem3(transfer) {
|
|
824
|
+
return {
|
|
825
|
+
transferID: transfer.number("TransferID"),
|
|
826
|
+
domainName: transfer.string("DomainName"),
|
|
827
|
+
user: transfer.string("User"),
|
|
828
|
+
transferDate: transfer.string("TransferDate"),
|
|
829
|
+
orderID: transfer.number("OrderID"),
|
|
830
|
+
statusID: transfer.number("StatusID"),
|
|
831
|
+
status: transfer.string("Status")
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
var getList4 = /* @__PURE__ */ defineCommand({
|
|
835
|
+
name: "namecheap.domains.transfer.getList",
|
|
836
|
+
parse: (cr) => ({
|
|
837
|
+
transfers: (cr.optional("TransferGetListResult")?.all("Transfer") ?? []).map(parseListItem3),
|
|
838
|
+
paging: parsePaging(cr.one("Paging"))
|
|
839
|
+
})
|
|
840
|
+
});
|
|
841
|
+
var transferCommands = { create: create4, getStatus, updateStatus, getList: getList4 };
|
|
842
|
+
|
|
843
|
+
// src/commands/users.ts
|
|
844
|
+
var getBalances = /* @__PURE__ */ defineCommand({
|
|
845
|
+
name: "namecheap.users.getBalances",
|
|
846
|
+
parse: (cr) => {
|
|
847
|
+
const result = cr.one("UserGetBalancesResult");
|
|
848
|
+
return {
|
|
849
|
+
currency: result.string("Currency"),
|
|
850
|
+
availableBalance: result.string("AvailableBalance"),
|
|
851
|
+
accountBalance: result.string("AccountBalance"),
|
|
852
|
+
earnedAmount: result.string("EarnedAmount"),
|
|
853
|
+
withdrawableAmount: result.string("WithdrawableAmount"),
|
|
854
|
+
fundsRequiredForAutoRenew: result.string("FundsRequiredForAutoRenew")
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
var getPricing = /* @__PURE__ */ defineCommand({
|
|
859
|
+
name: "namecheap.users.getPricing",
|
|
860
|
+
parse: (cr) => ({
|
|
861
|
+
productTypes: cr.one("UserGetPricingResult").all("ProductType").map((type) => ({
|
|
862
|
+
name: type.string("Name"),
|
|
863
|
+
productCategories: type.all("ProductCategory").map((category) => ({
|
|
864
|
+
name: category.string("Name"),
|
|
865
|
+
products: category.all("Product").map((product) => ({
|
|
866
|
+
name: product.string("Name"),
|
|
867
|
+
prices: product.all("Price").map((price) => ({
|
|
868
|
+
duration: price.number("Duration"),
|
|
869
|
+
durationType: price.string("DurationType"),
|
|
870
|
+
price: price.string("Price"),
|
|
871
|
+
regularPrice: price.string("RegularPrice"),
|
|
872
|
+
yourPrice: price.string("YourPrice"),
|
|
873
|
+
currency: price.string("Currency"),
|
|
874
|
+
...optionalField("pricingType", price.optionalString("PricingType")),
|
|
875
|
+
...optionalField("regularPriceType", price.optionalString("RegularPriceType")),
|
|
876
|
+
...optionalField("yourPriceType", price.optionalString("YourPriceType")),
|
|
877
|
+
...optionalField("promotionPrice", price.optionalString("PromotionPrice"))
|
|
878
|
+
}))
|
|
879
|
+
}))
|
|
880
|
+
}))
|
|
881
|
+
}))
|
|
882
|
+
})
|
|
883
|
+
});
|
|
884
|
+
var changePassword = /* @__PURE__ */ defineCommand({
|
|
885
|
+
name: "namecheap.users.changePassword",
|
|
886
|
+
parse: (cr) => {
|
|
887
|
+
const result = cr.one("UserChangePasswordResult");
|
|
888
|
+
return { success: result.boolean("Success"), userID: result.number("UserID") };
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
var update2 = /* @__PURE__ */ defineCommand({
|
|
892
|
+
name: "namecheap.users.update",
|
|
893
|
+
parse: (cr) => ({ success: cr.one("UserUpdateResult").boolean("Success") })
|
|
894
|
+
});
|
|
895
|
+
var createAddFundsRequest = /* @__PURE__ */ defineCommand({
|
|
896
|
+
name: "namecheap.users.createaddfundsrequest",
|
|
897
|
+
parse: (cr) => {
|
|
898
|
+
const result = cr.one("CreateAddFundsRequestResult");
|
|
899
|
+
return {
|
|
900
|
+
tokenID: result.string("TokenID"),
|
|
901
|
+
redirectURL: result.string("RedirectURL"),
|
|
902
|
+
returnURL: result.string("ReturnURL")
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
var getAddFundsStatus = /* @__PURE__ */ defineCommand({
|
|
907
|
+
name: "namecheap.users.getAddFundsStatus",
|
|
908
|
+
keys: { tokenId: "TokenId" },
|
|
909
|
+
parse: (cr) => {
|
|
910
|
+
const result = cr.one("GetAddFundsStatusResult");
|
|
911
|
+
return {
|
|
912
|
+
transactionID: result.number("TransactionID"),
|
|
913
|
+
amount: result.string("Amount"),
|
|
914
|
+
status: result.string("Status")
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
var create5 = /* @__PURE__ */ defineCommand({
|
|
919
|
+
name: "namecheap.users.create",
|
|
920
|
+
parse: (cr) => cr.children()[0]?.attributes() ?? {}
|
|
921
|
+
});
|
|
922
|
+
var login = /* @__PURE__ */ defineCommand({
|
|
923
|
+
name: "namecheap.users.login",
|
|
924
|
+
parse: (cr) => {
|
|
925
|
+
const result = cr.children()[0];
|
|
926
|
+
return {
|
|
927
|
+
...optionalField("username", result?.optionalString("Username")),
|
|
928
|
+
...optionalField("loginSuccess", result?.lenientBoolean("LoginSuccess"))
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
var resetPassword = /* @__PURE__ */ defineCommand({
|
|
933
|
+
name: "namecheap.users.resetPassword",
|
|
934
|
+
keys: { urlPattern: "URLPattern" },
|
|
935
|
+
parse: (cr) => ({
|
|
936
|
+
...optionalField("success", cr.children()[0]?.lenientBoolean("Success"))
|
|
937
|
+
})
|
|
938
|
+
});
|
|
939
|
+
var usersCommands = {
|
|
940
|
+
getBalances,
|
|
941
|
+
getPricing,
|
|
942
|
+
changePassword,
|
|
943
|
+
update: update2,
|
|
944
|
+
createAddFundsRequest,
|
|
945
|
+
getAddFundsStatus,
|
|
946
|
+
create: create5,
|
|
947
|
+
login,
|
|
948
|
+
resetPassword
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
// src/commands/users-address.ts
|
|
952
|
+
var create6 = /* @__PURE__ */ defineCommand({
|
|
953
|
+
name: "namecheap.users.address.create",
|
|
954
|
+
parse: (cr) => {
|
|
955
|
+
const result = cr.one("AddressCreateResult");
|
|
956
|
+
return {
|
|
957
|
+
success: result.boolean("Success"),
|
|
958
|
+
addressId: result.number("AddressId"),
|
|
959
|
+
addressName: result.string("AddressName")
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
var deleteAddress = /* @__PURE__ */ defineCommand({
|
|
964
|
+
name: "namecheap.users.address.delete",
|
|
965
|
+
keys: { addressId: "AddressId" },
|
|
966
|
+
parse: (cr) => {
|
|
967
|
+
const result = cr.one("AddressDeleteResult");
|
|
968
|
+
return {
|
|
969
|
+
success: result.boolean("Success"),
|
|
970
|
+
profileId: result.number("ProfileId"),
|
|
971
|
+
...optionalField("username", result.optionalString("Username"))
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
var getInfo4 = /* @__PURE__ */ defineCommand(
|
|
976
|
+
{
|
|
977
|
+
name: "namecheap.users.address.getInfo",
|
|
978
|
+
keys: { addressId: "AddressId" },
|
|
979
|
+
parse: (cr) => {
|
|
980
|
+
const result = cr.one("GetAddressInfoResult");
|
|
981
|
+
return {
|
|
982
|
+
addressId: result.one("AddressId").numberText(),
|
|
983
|
+
userName: result.one("UserName").text(),
|
|
984
|
+
addressName: result.one("AddressName").text(),
|
|
985
|
+
defaultYN: result.one("Default_YN").booleanText(),
|
|
986
|
+
firstName: result.one("FirstName").text(),
|
|
987
|
+
lastName: result.one("LastName").text(),
|
|
988
|
+
...optionalField("jobTitle", result.optionalText("JobTitle")),
|
|
989
|
+
...optionalField("organization", result.optionalText("Organization")),
|
|
990
|
+
address1: result.one("Address1").text(),
|
|
991
|
+
...optionalField("address2", result.optionalText("Address2")),
|
|
992
|
+
city: result.one("City").text(),
|
|
993
|
+
stateProvince: result.one("StateProvince").text(),
|
|
994
|
+
stateProvinceChoice: result.one("StateProvinceChoice").text(),
|
|
995
|
+
zip: result.one("Zip").text(),
|
|
996
|
+
country: result.one("Country").text(),
|
|
997
|
+
phone: result.one("Phone").text(),
|
|
998
|
+
...optionalField("phoneExt", result.optionalText("PhoneExt")),
|
|
999
|
+
...optionalField("fax", result.optionalText("Fax")),
|
|
1000
|
+
emailAddress: result.one("EmailAddress").text()
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
);
|
|
1005
|
+
var getList5 = /* @__PURE__ */ defineCommand({
|
|
1006
|
+
name: "namecheap.users.address.getList",
|
|
1007
|
+
parse: (cr) => (cr.optional("AddressGetListResult")?.all("List") ?? []).map((item) => ({
|
|
1008
|
+
addressId: item.number("AddressId"),
|
|
1009
|
+
addressName: item.string("AddressName"),
|
|
1010
|
+
isDefault: item.boolean("IsDefault")
|
|
1011
|
+
}))
|
|
1012
|
+
});
|
|
1013
|
+
var setDefault2 = /* @__PURE__ */ defineCommand({
|
|
1014
|
+
name: "namecheap.users.address.setDefault",
|
|
1015
|
+
keys: { addressId: "AddressId" },
|
|
1016
|
+
parse: (cr) => {
|
|
1017
|
+
const result = cr.one("AddressSetDefaultResult");
|
|
1018
|
+
return { success: result.boolean("Success"), addressId: result.number("AddressId") };
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
var update3 = /* @__PURE__ */ defineCommand({
|
|
1022
|
+
name: "namecheap.users.address.update",
|
|
1023
|
+
keys: { addressId: "AddressId" },
|
|
1024
|
+
parse: (cr) => {
|
|
1025
|
+
const result = cr.one("AddressUpdateResult");
|
|
1026
|
+
return {
|
|
1027
|
+
success: result.boolean("Success"),
|
|
1028
|
+
addressId: result.number("AddressId"),
|
|
1029
|
+
addressName: result.string("AddressName")
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
var usersAddressCommands = {
|
|
1034
|
+
create: create6,
|
|
1035
|
+
delete: deleteAddress,
|
|
1036
|
+
getInfo: getInfo4,
|
|
1037
|
+
getList: getList5,
|
|
1038
|
+
setDefault: setDefault2,
|
|
1039
|
+
update: update3
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
// src/commands/whoisguard.ts
|
|
1043
|
+
var changeEmailAddress = /* @__PURE__ */ defineCommand({
|
|
1044
|
+
name: "namecheap.whoisguard.changeemailaddress",
|
|
1045
|
+
parse: (cr) => {
|
|
1046
|
+
const result = cr.one("WhoisguardChangeEmailAddressResult");
|
|
1047
|
+
return {
|
|
1048
|
+
id: result.number("ID"),
|
|
1049
|
+
isSuccess: result.boolean("IsSuccess"),
|
|
1050
|
+
wgEmail: result.string("WGEmail"),
|
|
1051
|
+
wgOldEmail: result.string("WGOldEmail")
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
var enable = /* @__PURE__ */ defineCommand({
|
|
1056
|
+
name: "namecheap.whoisguard.enable",
|
|
1057
|
+
parse: (cr) => {
|
|
1058
|
+
const result = cr.one("WhoisguardEnableResult");
|
|
1059
|
+
return {
|
|
1060
|
+
domainName: result.string("DomainName"),
|
|
1061
|
+
isSuccess: result.boolean("IsSuccess")
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
var disable = /* @__PURE__ */ defineCommand({
|
|
1066
|
+
name: "namecheap.whoisguard.disable",
|
|
1067
|
+
parse: (cr) => {
|
|
1068
|
+
const result = cr.one("WhoisguardDisableResult");
|
|
1069
|
+
return {
|
|
1070
|
+
domainName: result.string("DomainName"),
|
|
1071
|
+
isSuccess: result.boolean("IsSuccess")
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
function parseListItem4(item) {
|
|
1076
|
+
return {
|
|
1077
|
+
id: item.number("ID"),
|
|
1078
|
+
domainName: item.string("DomainName"),
|
|
1079
|
+
created: item.string("Created"),
|
|
1080
|
+
expires: item.string("Expires"),
|
|
1081
|
+
status: item.string("Status")
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
var getList6 = /* @__PURE__ */ defineCommand({
|
|
1085
|
+
name: "namecheap.whoisguard.getlist",
|
|
1086
|
+
parse: (cr) => ({
|
|
1087
|
+
whoisguards: (cr.optional("WhoisguardGetListResult")?.all("Whoisguard") ?? []).map(
|
|
1088
|
+
parseListItem4
|
|
1089
|
+
),
|
|
1090
|
+
paging: parsePaging(cr.one("Paging"))
|
|
1091
|
+
})
|
|
1092
|
+
});
|
|
1093
|
+
var renew3 = /* @__PURE__ */ defineCommand({
|
|
1094
|
+
name: "namecheap.whoisguard.renew",
|
|
1095
|
+
parse: (cr) => {
|
|
1096
|
+
const result = cr.children()[0];
|
|
1097
|
+
return {
|
|
1098
|
+
...optionalField(
|
|
1099
|
+
"whoisguardID",
|
|
1100
|
+
result && firstLenientNumber(result, "WhoisguardID", "WhoisguardId")
|
|
1101
|
+
),
|
|
1102
|
+
...optionalField("years", result?.lenientNumber("Years")),
|
|
1103
|
+
...optionalField("renew", result?.lenientBoolean("Renew")),
|
|
1104
|
+
...optionalField("orderID", result && firstLenientNumber(result, "OrderID", "OrderId")),
|
|
1105
|
+
...optionalField(
|
|
1106
|
+
"transactionID",
|
|
1107
|
+
result && firstLenientNumber(result, "TransactionID", "TransactionId")
|
|
1108
|
+
),
|
|
1109
|
+
...optionalField("chargedAmount", result?.lenientNumber("ChargedAmount"))
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
var whoisGuardCommands = { changeEmailAddress, enable, disable, getList: getList6, renew: renew3 };
|
|
1114
|
+
|
|
1115
|
+
// src/core/element.ts
|
|
1116
|
+
var PLAIN_DECIMAL = /^[+-]?\d+(\.\d+)?$/;
|
|
1117
|
+
var El = class _El {
|
|
1118
|
+
constructor(node) {
|
|
1119
|
+
this.node = node;
|
|
1120
|
+
this.name = node.name;
|
|
1121
|
+
}
|
|
1122
|
+
node;
|
|
1123
|
+
name;
|
|
1124
|
+
text() {
|
|
1125
|
+
return this.node.text;
|
|
1126
|
+
}
|
|
1127
|
+
all(name) {
|
|
1128
|
+
return this.node.children.filter((child) => child.name === name).map((child) => new _El(child));
|
|
1129
|
+
}
|
|
1130
|
+
/** All direct child elements in document order, whatever their names. */
|
|
1131
|
+
children() {
|
|
1132
|
+
return this.node.children.map((child) => new _El(child));
|
|
1133
|
+
}
|
|
1134
|
+
/** Text of the first child element called `name`, or `undefined` when there is none. */
|
|
1135
|
+
optionalText(name) {
|
|
1136
|
+
return this.optional(name)?.text();
|
|
1137
|
+
}
|
|
1138
|
+
one(name) {
|
|
1139
|
+
const found = this.optional(name);
|
|
1140
|
+
if (found === void 0) {
|
|
1141
|
+
throw new NamecheapParseError(`${this.name}: missing element "${name}"`);
|
|
1142
|
+
}
|
|
1143
|
+
return found;
|
|
1144
|
+
}
|
|
1145
|
+
optional(name) {
|
|
1146
|
+
const child = this.node.children.find((candidate) => candidate.name === name);
|
|
1147
|
+
return child === void 0 ? void 0 : new _El(child);
|
|
1148
|
+
}
|
|
1149
|
+
string(attr) {
|
|
1150
|
+
const value = this.optionalString(attr);
|
|
1151
|
+
if (value === void 0) {
|
|
1152
|
+
throw new NamecheapParseError(`${this.name}: missing attribute "${attr}"`);
|
|
1153
|
+
}
|
|
1154
|
+
return value;
|
|
1155
|
+
}
|
|
1156
|
+
optionalString(attr) {
|
|
1157
|
+
return Object.hasOwn(this.node.attrs, attr) ? this.node.attrs[attr] : void 0;
|
|
1158
|
+
}
|
|
1159
|
+
number(attr) {
|
|
1160
|
+
return this.parseNumber(attr, this.string(attr));
|
|
1161
|
+
}
|
|
1162
|
+
optionalNumber(attr) {
|
|
1163
|
+
const value = this.optionalString(attr);
|
|
1164
|
+
return value === void 0 ? void 0 : this.parseNumber(attr, value);
|
|
1165
|
+
}
|
|
1166
|
+
boolean(attr) {
|
|
1167
|
+
return this.parseBoolean(attr, this.string(attr));
|
|
1168
|
+
}
|
|
1169
|
+
optionalBoolean(attr) {
|
|
1170
|
+
const value = this.optionalString(attr);
|
|
1171
|
+
return value === void 0 ? void 0 : this.parseBoolean(attr, value);
|
|
1172
|
+
}
|
|
1173
|
+
/**
|
|
1174
|
+
* Never throws: the plain decimal value of an attribute, or `undefined` when it is
|
|
1175
|
+
* absent or not acceptable. For undocumented responses of billed or account-changing
|
|
1176
|
+
* commands, where a parse failure after the action succeeded would invite a retry.
|
|
1177
|
+
*/
|
|
1178
|
+
lenientNumber(attr) {
|
|
1179
|
+
const value = this.optionalString(attr);
|
|
1180
|
+
if (value === void 0 || !PLAIN_DECIMAL.test(value)) return void 0;
|
|
1181
|
+
const parsed = Number(value);
|
|
1182
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1183
|
+
}
|
|
1184
|
+
/** Never throws: `true`/`false` (any case), or `undefined` when absent or anything else. */
|
|
1185
|
+
lenientBoolean(attr) {
|
|
1186
|
+
const lower = this.optionalString(attr)?.toLowerCase();
|
|
1187
|
+
if (lower === "true") return true;
|
|
1188
|
+
if (lower === "false") return false;
|
|
1189
|
+
return void 0;
|
|
1190
|
+
}
|
|
1191
|
+
/** Element text as a plain decimal number (for numeric child elements). */
|
|
1192
|
+
numberText() {
|
|
1193
|
+
return this.parseNumber(`text`, this.text(), `${this.name}: text is not a number`);
|
|
1194
|
+
}
|
|
1195
|
+
/** Element text as `true`/`false` (for boolean child elements). */
|
|
1196
|
+
booleanText() {
|
|
1197
|
+
return this.parseBoolean(`text`, this.text(), `${this.name}: text is not a boolean`);
|
|
1198
|
+
}
|
|
1199
|
+
attributes() {
|
|
1200
|
+
return { ...this.node.attrs };
|
|
1201
|
+
}
|
|
1202
|
+
parseNumber(attr, value, message) {
|
|
1203
|
+
const parsed = PLAIN_DECIMAL.test(value) ? Number(value) : Number.NaN;
|
|
1204
|
+
if (!Number.isFinite(parsed)) {
|
|
1205
|
+
throw new NamecheapParseError(message ?? `${this.name}: attribute "${attr}" is not a number`);
|
|
1206
|
+
}
|
|
1207
|
+
return parsed;
|
|
1208
|
+
}
|
|
1209
|
+
parseBoolean(attr, value, message) {
|
|
1210
|
+
const lower = value.toLowerCase();
|
|
1211
|
+
if (lower === "true") return true;
|
|
1212
|
+
if (lower === "false") return false;
|
|
1213
|
+
throw new NamecheapParseError(message ?? `${this.name}: attribute "${attr}" is not a boolean`);
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
// src/core/xml.ts
|
|
1218
|
+
var NAMED_ENTITIES = {
|
|
1219
|
+
amp: "&",
|
|
1220
|
+
lt: "<",
|
|
1221
|
+
gt: ">",
|
|
1222
|
+
quot: '"',
|
|
1223
|
+
apos: "'"
|
|
1224
|
+
};
|
|
1225
|
+
var NAME_START = /[A-Za-z_:]/;
|
|
1226
|
+
var NAME_CHAR = /[A-Za-z0-9_:.-]/;
|
|
1227
|
+
function fail(message, position) {
|
|
1228
|
+
throw new NamecheapParseError(`Invalid XML at position ${position}: ${message}`);
|
|
1229
|
+
}
|
|
1230
|
+
function isSpace(ch) {
|
|
1231
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r";
|
|
1232
|
+
}
|
|
1233
|
+
function decodeEntities(raw, position) {
|
|
1234
|
+
if (!raw.includes("&")) return raw;
|
|
1235
|
+
let out = "";
|
|
1236
|
+
let i = 0;
|
|
1237
|
+
while (i < raw.length) {
|
|
1238
|
+
const amp = raw.indexOf("&", i);
|
|
1239
|
+
if (amp === -1) {
|
|
1240
|
+
out += raw.slice(i);
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
out += raw.slice(i, amp);
|
|
1244
|
+
const semi = raw.indexOf(";", amp);
|
|
1245
|
+
if (semi === -1) fail("unterminated entity", position + amp);
|
|
1246
|
+
const body = raw.slice(amp + 1, semi);
|
|
1247
|
+
let decoded;
|
|
1248
|
+
if (body.startsWith("#x") || body.startsWith("#X")) {
|
|
1249
|
+
decoded = codePoint(body.slice(2), 16);
|
|
1250
|
+
} else if (body.startsWith("#")) {
|
|
1251
|
+
decoded = codePoint(body.slice(1), 10);
|
|
1252
|
+
} else {
|
|
1253
|
+
decoded = Object.hasOwn(NAMED_ENTITIES, body) ? NAMED_ENTITIES[body] : void 0;
|
|
1254
|
+
}
|
|
1255
|
+
if (decoded === void 0) {
|
|
1256
|
+
const shown = body.length > 32 ? `${body.slice(0, 32)}\u2026` : body;
|
|
1257
|
+
fail(`unknown entity &${shown};`, position + amp);
|
|
1258
|
+
}
|
|
1259
|
+
out += decoded;
|
|
1260
|
+
i = semi + 1;
|
|
1261
|
+
}
|
|
1262
|
+
return out;
|
|
1263
|
+
}
|
|
1264
|
+
function codePoint(digits, radix) {
|
|
1265
|
+
const pattern = radix === 10 ? /^[0-9]{1,7}$/ : /^[0-9A-Fa-f]{1,6}$/;
|
|
1266
|
+
if (!pattern.test(digits)) return void 0;
|
|
1267
|
+
const value = Number.parseInt(digits, radix);
|
|
1268
|
+
if (value > 1114111 || value >= 55296 && value <= 57343) return void 0;
|
|
1269
|
+
return String.fromCodePoint(value);
|
|
1270
|
+
}
|
|
1271
|
+
function parseXml(input) {
|
|
1272
|
+
const length = input.length;
|
|
1273
|
+
let pos = 0;
|
|
1274
|
+
let root;
|
|
1275
|
+
const stack = [];
|
|
1276
|
+
const skipSpace = () => {
|
|
1277
|
+
while (pos < length && isSpace(input[pos])) pos++;
|
|
1278
|
+
};
|
|
1279
|
+
const readName = () => {
|
|
1280
|
+
const start = pos;
|
|
1281
|
+
if (pos >= length || !NAME_START.test(input[pos])) fail("expected a name", pos);
|
|
1282
|
+
pos++;
|
|
1283
|
+
while (pos < length && NAME_CHAR.test(input[pos])) pos++;
|
|
1284
|
+
return input.slice(start, pos);
|
|
1285
|
+
};
|
|
1286
|
+
const skipUntil = (terminator, what) => {
|
|
1287
|
+
const end = input.indexOf(terminator, pos);
|
|
1288
|
+
if (end === -1) fail(`unterminated ${what}`, pos);
|
|
1289
|
+
pos = end + terminator.length;
|
|
1290
|
+
};
|
|
1291
|
+
const readAttributes = (attrs) => {
|
|
1292
|
+
for (; ; ) {
|
|
1293
|
+
const before = pos;
|
|
1294
|
+
skipSpace();
|
|
1295
|
+
const ch = input[pos];
|
|
1296
|
+
if (ch === void 0) fail("unterminated start tag", pos);
|
|
1297
|
+
if (ch === ">") {
|
|
1298
|
+
pos++;
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
if (ch === "/") {
|
|
1302
|
+
if (input[pos + 1] !== ">") fail("expected '>' after '/'", pos);
|
|
1303
|
+
pos += 2;
|
|
1304
|
+
return true;
|
|
1305
|
+
}
|
|
1306
|
+
if (pos === before) fail("expected whitespace before attribute", pos);
|
|
1307
|
+
const name = readName();
|
|
1308
|
+
skipSpace();
|
|
1309
|
+
if (input[pos] !== "=") fail(`attribute ${name} has no value`, pos);
|
|
1310
|
+
pos++;
|
|
1311
|
+
skipSpace();
|
|
1312
|
+
const quote = input[pos];
|
|
1313
|
+
if (quote !== '"' && quote !== "'") fail(`attribute ${name} value is not quoted`, pos);
|
|
1314
|
+
pos++;
|
|
1315
|
+
const end = input.indexOf(quote, pos);
|
|
1316
|
+
if (end === -1) fail("unterminated attribute value", pos);
|
|
1317
|
+
const raw = input.slice(pos, end);
|
|
1318
|
+
if (raw.includes("<")) fail("'<' in attribute value", pos);
|
|
1319
|
+
if (Object.hasOwn(attrs, name)) fail(`duplicate attribute ${name}`, pos);
|
|
1320
|
+
attrs[name] = decodeEntities(raw, pos);
|
|
1321
|
+
pos = end + 1;
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
const closeElement = (builder) => {
|
|
1325
|
+
const node = {
|
|
1326
|
+
name: builder.name,
|
|
1327
|
+
attrs: builder.attrs,
|
|
1328
|
+
text: builder.text.trim(),
|
|
1329
|
+
children: builder.children
|
|
1330
|
+
};
|
|
1331
|
+
const parent = stack[stack.length - 1];
|
|
1332
|
+
if (parent) parent.children.push(node);
|
|
1333
|
+
else root = node;
|
|
1334
|
+
};
|
|
1335
|
+
while (pos < length) {
|
|
1336
|
+
const current = stack[stack.length - 1];
|
|
1337
|
+
if (input[pos] !== "<") {
|
|
1338
|
+
const next = input.indexOf("<", pos);
|
|
1339
|
+
const end = next === -1 ? length : next;
|
|
1340
|
+
const raw = input.slice(pos, end);
|
|
1341
|
+
if (current) {
|
|
1342
|
+
current.text += decodeEntities(raw, pos);
|
|
1343
|
+
} else if (raw.trim() !== "") {
|
|
1344
|
+
fail("text outside the root element", pos);
|
|
1345
|
+
}
|
|
1346
|
+
pos = end;
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
if (input.startsWith("<!--", pos)) {
|
|
1350
|
+
pos += 4;
|
|
1351
|
+
skipUntil("-->", "comment");
|
|
1352
|
+
} else if (input.startsWith("<![CDATA[", pos)) {
|
|
1353
|
+
if (!current) fail("CDATA outside the root element", pos);
|
|
1354
|
+
pos += 9;
|
|
1355
|
+
const end = input.indexOf("]]>", pos);
|
|
1356
|
+
if (end === -1) fail("unterminated CDATA section", pos);
|
|
1357
|
+
current.text += input.slice(pos, end);
|
|
1358
|
+
pos = end + 3;
|
|
1359
|
+
} else if (input.startsWith("<?", pos)) {
|
|
1360
|
+
pos += 2;
|
|
1361
|
+
skipUntil("?>", "processing instruction");
|
|
1362
|
+
} else if (input.startsWith("<!", pos)) {
|
|
1363
|
+
fail("DTD and entity declarations are not supported", pos);
|
|
1364
|
+
} else if (input.startsWith("</", pos)) {
|
|
1365
|
+
pos += 2;
|
|
1366
|
+
const name = readName();
|
|
1367
|
+
skipSpace();
|
|
1368
|
+
if (input[pos] !== ">") fail("expected '>' in end tag", pos);
|
|
1369
|
+
pos++;
|
|
1370
|
+
if (!current) fail(`unexpected end tag </${name}>`, pos);
|
|
1371
|
+
if (current.name !== name) {
|
|
1372
|
+
fail(`end tag </${name}> does not match <${current.name}>`, pos);
|
|
1373
|
+
}
|
|
1374
|
+
stack.pop();
|
|
1375
|
+
closeElement(current);
|
|
1376
|
+
} else {
|
|
1377
|
+
if (!current && root) fail("more than one root element", pos);
|
|
1378
|
+
pos++;
|
|
1379
|
+
const builder = { name: readName(), attrs: {}, text: "", children: [] };
|
|
1380
|
+
const selfClosing = readAttributes(builder.attrs);
|
|
1381
|
+
if (selfClosing) closeElement(builder);
|
|
1382
|
+
else stack.push(builder);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
if (stack.length > 0) fail(`unclosed element <${stack[stack.length - 1]?.name}>`, pos);
|
|
1386
|
+
if (!root) fail("no root element", pos);
|
|
1387
|
+
return root;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// src/core/envelope.ts
|
|
1391
|
+
var INTEGER = /^-?\d+$/;
|
|
1392
|
+
function toErrorItem(error) {
|
|
1393
|
+
const number = error.optionalString("Number")?.trim();
|
|
1394
|
+
return {
|
|
1395
|
+
code: number !== void 0 && INTEGER.test(number) ? Number(number) : -1,
|
|
1396
|
+
message: error.text().trim()
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
function readEnvelope(xml) {
|
|
1400
|
+
const root = new El(parseXml(xml));
|
|
1401
|
+
if (root.name !== "ApiResponse") {
|
|
1402
|
+
throw new NamecheapParseError(`Unexpected response root element "${root.name}"`);
|
|
1403
|
+
}
|
|
1404
|
+
const errors = root.optional("Errors")?.all("Error") ?? [];
|
|
1405
|
+
if (root.optionalString("Status") === "ERROR" || errors.length > 0) {
|
|
1406
|
+
throw new NamecheapError(errors.map(toErrorItem));
|
|
1407
|
+
}
|
|
1408
|
+
const command = root.optional("CommandResponse");
|
|
1409
|
+
if (command === void 0) {
|
|
1410
|
+
throw new NamecheapParseError("Response has no CommandResponse element");
|
|
1411
|
+
}
|
|
1412
|
+
return command;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// src/core/transport.ts
|
|
1416
|
+
var PRODUCTION_URL = "https://api.namecheap.com/xml.response";
|
|
1417
|
+
var SANDBOX_URL = "https://api.sandbox.namecheap.com/xml.response";
|
|
1418
|
+
function createTransport(config) {
|
|
1419
|
+
if (config.sandbox !== void 0 && typeof config.sandbox !== "boolean") {
|
|
1420
|
+
throw new TypeError("NamecheapConfig.sandbox must be a boolean");
|
|
1421
|
+
}
|
|
1422
|
+
const url = config.sandbox === true ? SANDBOX_URL : PRODUCTION_URL;
|
|
1423
|
+
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1424
|
+
return async ({ command, params }) => {
|
|
1425
|
+
const body = new URLSearchParams();
|
|
1426
|
+
body.append("ApiUser", config.apiUser);
|
|
1427
|
+
body.append("ApiKey", config.apiKey);
|
|
1428
|
+
body.append("UserName", config.userName ?? config.apiUser);
|
|
1429
|
+
body.append("ClientIp", config.clientIp);
|
|
1430
|
+
body.append("Command", command);
|
|
1431
|
+
for (const [name, value] of params) body.append(name, value);
|
|
1432
|
+
const init = {
|
|
1433
|
+
method: "POST",
|
|
1434
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
1435
|
+
body: body.toString(),
|
|
1436
|
+
redirect: "error"
|
|
1437
|
+
};
|
|
1438
|
+
if (config.timeoutMs !== void 0) init.signal = AbortSignal.timeout(config.timeoutMs);
|
|
1439
|
+
let response;
|
|
1440
|
+
try {
|
|
1441
|
+
response = await fetchImpl(url, init);
|
|
1442
|
+
} catch (cause) {
|
|
1443
|
+
throw new NamecheapHttpError("Request to Namecheap failed", { cause });
|
|
1444
|
+
}
|
|
1445
|
+
if (!response.ok) {
|
|
1446
|
+
throw new NamecheapHttpError(`Namecheap responded with HTTP ${response.status}`, {
|
|
1447
|
+
status: response.status,
|
|
1448
|
+
statusText: response.statusText
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
let text;
|
|
1452
|
+
try {
|
|
1453
|
+
text = await response.text();
|
|
1454
|
+
} catch (cause) {
|
|
1455
|
+
throw new NamecheapHttpError("Request to Namecheap failed", { cause });
|
|
1456
|
+
}
|
|
1457
|
+
return readEnvelope(text);
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// src/client.ts
|
|
1462
|
+
var Namecheap = class {
|
|
1463
|
+
domains;
|
|
1464
|
+
dns;
|
|
1465
|
+
ns;
|
|
1466
|
+
transfer;
|
|
1467
|
+
ssl;
|
|
1468
|
+
users;
|
|
1469
|
+
usersAddress;
|
|
1470
|
+
whoisGuard;
|
|
1471
|
+
constructor(config) {
|
|
1472
|
+
const send = createTransport(config);
|
|
1473
|
+
this.domains = group(domainsCommands, send);
|
|
1474
|
+
this.dns = group(dnsCommands, send);
|
|
1475
|
+
this.ns = group(nsCommands, send);
|
|
1476
|
+
this.transfer = group(transferCommands, send);
|
|
1477
|
+
this.ssl = group(sslCommands, send);
|
|
1478
|
+
this.users = group(usersCommands, send);
|
|
1479
|
+
this.usersAddress = group(usersAddressCommands, send);
|
|
1480
|
+
this.whoisGuard = group(whoisGuardCommands, send);
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
// src/index.ts
|
|
1485
|
+
var index_default = Namecheap;
|
|
1486
|
+
export {
|
|
1487
|
+
Namecheap,
|
|
1488
|
+
NamecheapError,
|
|
1489
|
+
NamecheapHttpError,
|
|
1490
|
+
NamecheapParseError,
|
|
1491
|
+
createTransport,
|
|
1492
|
+
index_default as default,
|
|
1493
|
+
dnsCommands,
|
|
1494
|
+
getEmailForwarding as dnsGetEmailForwarding,
|
|
1495
|
+
getHosts as dnsGetHosts,
|
|
1496
|
+
getList as dnsGetList,
|
|
1497
|
+
setCustom as dnsSetCustom,
|
|
1498
|
+
setDefault as dnsSetDefault,
|
|
1499
|
+
setEmailForwarding as dnsSetEmailForwarding,
|
|
1500
|
+
setHosts as dnsSetHosts,
|
|
1501
|
+
check as domainsCheck,
|
|
1502
|
+
domainsCommands,
|
|
1503
|
+
create as domainsCreate,
|
|
1504
|
+
getContacts as domainsGetContacts,
|
|
1505
|
+
getInfo as domainsGetInfo,
|
|
1506
|
+
getList2 as domainsGetList,
|
|
1507
|
+
getRegistrarLock as domainsGetRegistrarLock,
|
|
1508
|
+
getTldList as domainsGetTldList,
|
|
1509
|
+
reactivate as domainsReactivate,
|
|
1510
|
+
renew as domainsRenew,
|
|
1511
|
+
setContacts as domainsSetContacts,
|
|
1512
|
+
setRegistrarLock as domainsSetRegistrarLock,
|
|
1513
|
+
nsCommands,
|
|
1514
|
+
create2 as nsCreate,
|
|
1515
|
+
deleteNs as nsDelete,
|
|
1516
|
+
getInfo2 as nsGetInfo,
|
|
1517
|
+
update as nsUpdate,
|
|
1518
|
+
run,
|
|
1519
|
+
activate as sslActivate,
|
|
1520
|
+
sslCommands,
|
|
1521
|
+
create3 as sslCreate,
|
|
1522
|
+
editDCVMethod as sslEditDCVMethod,
|
|
1523
|
+
getApproverEmailList as sslGetApproverEmailList,
|
|
1524
|
+
getInfo3 as sslGetInfo,
|
|
1525
|
+
getList3 as sslGetList,
|
|
1526
|
+
parseCSR as sslParseCSR,
|
|
1527
|
+
purchaseMoreSans as sslPurchaseMoreSans,
|
|
1528
|
+
reissue as sslReissue,
|
|
1529
|
+
renew2 as sslRenew,
|
|
1530
|
+
resendApproverEmail as sslResendApproverEmail,
|
|
1531
|
+
resendFulfillmentEmail as sslResendFulfillmentEmail,
|
|
1532
|
+
revokeCertificate as sslRevokeCertificate,
|
|
1533
|
+
transferCommands,
|
|
1534
|
+
create4 as transferCreate,
|
|
1535
|
+
getList4 as transferGetList,
|
|
1536
|
+
getStatus as transferGetStatus,
|
|
1537
|
+
updateStatus as transferUpdateStatus,
|
|
1538
|
+
usersAddressCommands,
|
|
1539
|
+
create6 as usersAddressCreate,
|
|
1540
|
+
deleteAddress as usersAddressDelete,
|
|
1541
|
+
getInfo4 as usersAddressGetInfo,
|
|
1542
|
+
getList5 as usersAddressGetList,
|
|
1543
|
+
setDefault2 as usersAddressSetDefault,
|
|
1544
|
+
update3 as usersAddressUpdate,
|
|
1545
|
+
changePassword as usersChangePassword,
|
|
1546
|
+
usersCommands,
|
|
1547
|
+
create5 as usersCreate,
|
|
1548
|
+
createAddFundsRequest as usersCreateAddFundsRequest,
|
|
1549
|
+
getAddFundsStatus as usersGetAddFundsStatus,
|
|
1550
|
+
getBalances as usersGetBalances,
|
|
1551
|
+
getPricing as usersGetPricing,
|
|
1552
|
+
login as usersLogin,
|
|
1553
|
+
resetPassword as usersResetPassword,
|
|
1554
|
+
update2 as usersUpdate,
|
|
1555
|
+
changeEmailAddress as whoisGuardChangeEmailAddress,
|
|
1556
|
+
whoisGuardCommands,
|
|
1557
|
+
disable as whoisGuardDisable,
|
|
1558
|
+
enable as whoisGuardEnable,
|
|
1559
|
+
getList6 as whoisGuardGetList,
|
|
1560
|
+
renew3 as whoisGuardRenew
|
|
1561
|
+
};
|
|
2
1562
|
//# sourceMappingURL=index.js.map
|