namecheap-ts 1.0.2 → 1.0.3
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 +51 -4
- package/dist/index.d.mts +79 -5
- package/dist/index.d.ts +95 -2
- package/dist/index.js +266 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/dist/api/api-client.d.ts +0 -8
- package/dist/api/api-client.js +0 -51
- package/dist/api/errors.d.ts +0 -7
- package/dist/api/errors.js +0 -18
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -8
- package/dist/commands.d.ts +0 -62
- package/dist/commands.js +0 -73
- package/dist/exceptions/InvalidDomainNameException.d.ts +0 -3
- package/dist/exceptions/InvalidDomainNameException.js +0 -10
- package/dist/exceptions/InvalidTLDException.d.ts +0 -3
- package/dist/exceptions/InvalidTLDException.js +0 -10
- package/dist/exceptions/index.d.ts +0 -1
- package/dist/exceptions/index.js +0 -17
- package/dist/namecheap.d.ts +0 -25
- package/dist/namecheap.js +0 -64
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -10
package/README.md
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
A TypeScript package that provides a simple and intuitive interface to interact with Namecheap API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You can install the package using npm. Run the following command in your terminal:
|
|
6
8
|
|
|
7
9
|
```shell
|
|
8
10
|
npm install namecheap-ts
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
You can use the package to perform various operations such as domain registration, DNS management, SSL certificate management, and more. Here's an example of how to use the package to check whether the domain name is available or not:
|
|
12
16
|
|
|
13
17
|
```typescript
|
|
14
18
|
import Namecheap, { INamecheapConfig } from "namecheap-ts";
|
|
@@ -28,10 +32,53 @@ const isAvailabe = data[0].DomainCheckResult[0].$.Available;
|
|
|
28
32
|
console.log(isAvailable);
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
The `Namecheap` class is the main entry point for interacting with the Namecheap API.
|
|
38
|
+
|
|
39
|
+
#### `constructor(config: INamecheapConfig, sandbox?: boolean)`
|
|
40
|
+
|
|
41
|
+
Create a new instance of the `Namecheap` class.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const namecheap = new Namecheap(config, true);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### `call(command: Command, payload: Record<string, string>): Promise<IReponse>`
|
|
48
|
+
|
|
49
|
+
Call a command on the Namecheap API.
|
|
32
50
|
|
|
33
51
|
```typescript
|
|
34
|
-
|
|
52
|
+
import { Commands } from "namecheap-ts";
|
|
53
|
+
const response = await namecheap.call(Commands.DOMAINS_CHECK, {
|
|
54
|
+
DomainList: "example.com",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
console.log(response);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### `checkDomain(domainName: string): Promise<ICheckDomainResponse>`
|
|
61
|
+
|
|
62
|
+
Check if a domain is available and if it'is premium.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const { availabe, premium } = await namecheap.checkDomain("example.com");
|
|
66
|
+
|
|
67
|
+
console.log({ availabe, premium });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### `getDomainPrice(domainName: string, action: DomainPriceAction): Promise<IReponse>`
|
|
71
|
+
|
|
72
|
+
Get the price of a domain.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { DomainPriceAction } from "namecheap-ts";
|
|
76
|
+
const response = await namecheap.getDomainPrice(
|
|
77
|
+
"example.com",
|
|
78
|
+
DomainPriceAction.REGISTER
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
console.log(response);
|
|
35
82
|
```
|
|
36
83
|
|
|
37
84
|
You can refer to the official Namecheap API documentation for more information on the available methods and parameters. [The documentation is available at ¹](https://www.namecheap.com/support/api/intro/).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
1
|
+
declare enum Commands {
|
|
2
|
+
DOMAINS_GETLIST = "namecheap.domains.getList",
|
|
3
|
+
DOMAINS_GETCONTACTS = "namecheap.domains.getContacts",
|
|
4
|
+
DOMAINS_CREATE = "namecheap.domains.create",
|
|
5
|
+
DOMAINS_GETTLDLIST = "namecheap.domains.getTldList",
|
|
6
|
+
DOMAINS_SETCONTACTS = "namecheap.domains.setContacts",
|
|
7
|
+
DOMAINS_CHECK = "namecheap.domains.check",
|
|
8
|
+
DOMAINS_REACTIVATE = "namecheap.domains.reactivate",
|
|
9
|
+
DOMAINS_RENEW = "namecheap.domains.renew",
|
|
10
|
+
DOMAINS_GETREGISTRARLOCK = "namecheap.domains.getRegistrarLock",
|
|
11
|
+
DOMAINS_SETREGISTRARLOCK = "namecheap.domains.setRegistrarLock",
|
|
12
|
+
DOMAINS_GETINFO = "namecheap.domains.getInfo",
|
|
13
|
+
DOMAINS_DNS_SETDEFAULT = "namecheap.domains.dns.setDefault",
|
|
14
|
+
DOMAINS_DNS_SETCUSTOM = "namecheap.domains.dns.setCustom",
|
|
15
|
+
DOMAINS_DNS_GETLIST = "namecheap.domains.dns.getList",
|
|
16
|
+
DOMAINS_DNS_GETHOSTS = "namecheap.domains.dns.getHosts",
|
|
17
|
+
DOMAINS_DNS_GETEMAILFORWARDING = "namecheap.domains.dns.getEmailForwarding",
|
|
18
|
+
DOMAINS_DNS_SETEMAILFORWARDING = "namecheap.domains.dns.setEmailForwarding",
|
|
19
|
+
DOMAINS_DNS_SETHOSTS = "namecheap.domains.dns.setHosts",
|
|
20
|
+
DOMAINS_NS_CREATE = "namecheap.domains.ns.create",
|
|
21
|
+
DOMAINS_NS_DELETE = "namecheap.domains.ns.delete",
|
|
22
|
+
DOMAINS_NS_GETINFO = "namecheap.domains.ns.getInfo",
|
|
23
|
+
DOMAINS_NS_UPDATE = "namecheap.domains.ns.update",
|
|
24
|
+
DOMAINS_TRANSFER_CREATE = "namecheap.domains.transfer.create",
|
|
25
|
+
DOMAINS_TRANSFER_GETSTATUS = "namecheap.domains.transfer.getStatus",
|
|
26
|
+
DOMAINS_TRANSFER_UPDATESTATUS = "namecheap.domains.transfer.updateStatus",
|
|
27
|
+
DOMAINS_TRANSFER_GETLIST = "namecheap.domains.transfer.getList",
|
|
28
|
+
SSL_CREATE = "namecheap.ssl.create",
|
|
29
|
+
SSL_GETLIST = "namecheap.ssl.getList",
|
|
30
|
+
SSL_PARSECSR = "namecheap.ssl.parseCSR",
|
|
31
|
+
SSL_GETAPPROVEREMAILLIST = "namecheap.ssl.getApproverEmailList",
|
|
32
|
+
SSL_ACTIVATE = "namecheap.ssl.activate",
|
|
33
|
+
SSL_RESENDAPPROVEREMAIL = "namecheap.ssl.resendApproverEmail",
|
|
34
|
+
SSL_GETINFO = "namecheap.ssl.getInfo",
|
|
35
|
+
SSL_RENEW = "namecheap.ssl.renew",
|
|
36
|
+
SSL_REISSUE = "namecheap.ssl.reissue",
|
|
37
|
+
SSL_RESENDFULFILLMENTEMAIL = "namecheap.ssl.resendfulfillmentemail",
|
|
38
|
+
SSL_PURCHASEMORESANS = "namecheap.ssl.purchasemoresans",
|
|
39
|
+
SSL_REVOKECERTIFICATE = "namecheap.ssl.revokecertificate",
|
|
40
|
+
SSL_EDITDCVMETHOD = "namecheap.ssl.editDCVMethod",
|
|
41
|
+
USERS_GETPRICING = "namecheap.users.getPricing",
|
|
42
|
+
USERS_GETBALANCES = "namecheap.users.getBalances",
|
|
43
|
+
USERS_CHANGEPASSWORD = "namecheap.users.changePassword",
|
|
44
|
+
USERS_UPDATE = "namecheap.users.update",
|
|
45
|
+
USERS_CREATEADDFUNDSREQUEST = "namecheap.users.createaddfundsrequest",
|
|
46
|
+
USERS_GETADDFUNDSSTATUS = "namecheap.users.getAddFundsStatus",
|
|
47
|
+
USERS_CREATE = "namecheap.users.create",
|
|
48
|
+
USERS_LOGIN = "namecheap.users.login",
|
|
49
|
+
USERS_RESETPASSWORD = "namecheap.users.resetPassword",
|
|
50
|
+
USERS_ADDRESS_CREATE = "namecheap.users.address.create",
|
|
51
|
+
USERS_ADDRESS_DELETE = "namecheap.users.address.delete",
|
|
52
|
+
USERS_ADDRESS_GETINFO = "namecheap.users.address.getInfo",
|
|
53
|
+
USERS_ADDRESS_GETLIST = "namecheap.users.address.getList",
|
|
54
|
+
USERS_ADDRESS_SETDEFAULT = "namecheap.users.address.setDefault",
|
|
55
|
+
USERS_ADDRESS_UPDATE = "namecheap.users.address.update",
|
|
56
|
+
WHOISGUARD_CHANGEEMAILADDRESS = "Namecheap.Whoisguard.changeemailaddress",
|
|
57
|
+
WHOISGUARD_ENABLE = "Namecheap.Whoisguard.enable",
|
|
58
|
+
WHOISGUARD_DISABLE = "Namecheap.Whoisguard.disable",
|
|
59
|
+
WHOISGUARD_GETLIST = "Namecheap.Whoisguard.getList",
|
|
60
|
+
WHOISGUARD_RENEW = "Namecheap.Whoisguard.renew"
|
|
61
|
+
}
|
|
62
|
+
type Command = `${Commands}`;
|
|
63
|
+
|
|
64
|
+
declare enum DomainPriceActions {
|
|
65
|
+
REGISTER = "REGISTER",
|
|
66
|
+
RENEW = "RENEW",
|
|
67
|
+
REACTIVATE = "REACTIVATE",
|
|
68
|
+
TRANSFER = "TRANSFER"
|
|
69
|
+
}
|
|
70
|
+
type DomainPriceAction = `${DomainPriceActions}`;
|
|
3
71
|
|
|
4
72
|
interface INamecheapConfig {
|
|
5
73
|
ApiUser: string;
|
|
@@ -7,15 +75,21 @@ interface INamecheapConfig {
|
|
|
7
75
|
UserName: string;
|
|
8
76
|
ClientIp: string;
|
|
9
77
|
}
|
|
10
|
-
interface
|
|
78
|
+
interface IReponse {
|
|
11
79
|
data: any;
|
|
12
80
|
status: number;
|
|
13
81
|
}
|
|
82
|
+
interface ICheckDomainResponse {
|
|
83
|
+
availabe: boolean;
|
|
84
|
+
premium: boolean;
|
|
85
|
+
}
|
|
14
86
|
declare class Namecheap {
|
|
15
87
|
private readonly config;
|
|
16
88
|
private readonly apiClient;
|
|
17
89
|
constructor(config: INamecheapConfig, sandbox?: boolean);
|
|
18
|
-
call(command:
|
|
90
|
+
call(command: Command, payload: Record<string, string>): Promise<IReponse>;
|
|
91
|
+
checkDomain(domainName: string): Promise<ICheckDomainResponse>;
|
|
92
|
+
getDomainPrice(domainName: string, action: DomainPriceAction): Promise<IReponse>;
|
|
19
93
|
}
|
|
20
94
|
|
|
21
|
-
export {
|
|
95
|
+
export { Command, Commands, DomainPriceAction, DomainPriceActions, ICheckDomainResponse, INamecheapConfig, IReponse, Namecheap as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare enum Commands {
|
|
2
|
+
DOMAINS_GETLIST = "namecheap.domains.getList",
|
|
3
|
+
DOMAINS_GETCONTACTS = "namecheap.domains.getContacts",
|
|
4
|
+
DOMAINS_CREATE = "namecheap.domains.create",
|
|
5
|
+
DOMAINS_GETTLDLIST = "namecheap.domains.getTldList",
|
|
6
|
+
DOMAINS_SETCONTACTS = "namecheap.domains.setContacts",
|
|
7
|
+
DOMAINS_CHECK = "namecheap.domains.check",
|
|
8
|
+
DOMAINS_REACTIVATE = "namecheap.domains.reactivate",
|
|
9
|
+
DOMAINS_RENEW = "namecheap.domains.renew",
|
|
10
|
+
DOMAINS_GETREGISTRARLOCK = "namecheap.domains.getRegistrarLock",
|
|
11
|
+
DOMAINS_SETREGISTRARLOCK = "namecheap.domains.setRegistrarLock",
|
|
12
|
+
DOMAINS_GETINFO = "namecheap.domains.getInfo",
|
|
13
|
+
DOMAINS_DNS_SETDEFAULT = "namecheap.domains.dns.setDefault",
|
|
14
|
+
DOMAINS_DNS_SETCUSTOM = "namecheap.domains.dns.setCustom",
|
|
15
|
+
DOMAINS_DNS_GETLIST = "namecheap.domains.dns.getList",
|
|
16
|
+
DOMAINS_DNS_GETHOSTS = "namecheap.domains.dns.getHosts",
|
|
17
|
+
DOMAINS_DNS_GETEMAILFORWARDING = "namecheap.domains.dns.getEmailForwarding",
|
|
18
|
+
DOMAINS_DNS_SETEMAILFORWARDING = "namecheap.domains.dns.setEmailForwarding",
|
|
19
|
+
DOMAINS_DNS_SETHOSTS = "namecheap.domains.dns.setHosts",
|
|
20
|
+
DOMAINS_NS_CREATE = "namecheap.domains.ns.create",
|
|
21
|
+
DOMAINS_NS_DELETE = "namecheap.domains.ns.delete",
|
|
22
|
+
DOMAINS_NS_GETINFO = "namecheap.domains.ns.getInfo",
|
|
23
|
+
DOMAINS_NS_UPDATE = "namecheap.domains.ns.update",
|
|
24
|
+
DOMAINS_TRANSFER_CREATE = "namecheap.domains.transfer.create",
|
|
25
|
+
DOMAINS_TRANSFER_GETSTATUS = "namecheap.domains.transfer.getStatus",
|
|
26
|
+
DOMAINS_TRANSFER_UPDATESTATUS = "namecheap.domains.transfer.updateStatus",
|
|
27
|
+
DOMAINS_TRANSFER_GETLIST = "namecheap.domains.transfer.getList",
|
|
28
|
+
SSL_CREATE = "namecheap.ssl.create",
|
|
29
|
+
SSL_GETLIST = "namecheap.ssl.getList",
|
|
30
|
+
SSL_PARSECSR = "namecheap.ssl.parseCSR",
|
|
31
|
+
SSL_GETAPPROVEREMAILLIST = "namecheap.ssl.getApproverEmailList",
|
|
32
|
+
SSL_ACTIVATE = "namecheap.ssl.activate",
|
|
33
|
+
SSL_RESENDAPPROVEREMAIL = "namecheap.ssl.resendApproverEmail",
|
|
34
|
+
SSL_GETINFO = "namecheap.ssl.getInfo",
|
|
35
|
+
SSL_RENEW = "namecheap.ssl.renew",
|
|
36
|
+
SSL_REISSUE = "namecheap.ssl.reissue",
|
|
37
|
+
SSL_RESENDFULFILLMENTEMAIL = "namecheap.ssl.resendfulfillmentemail",
|
|
38
|
+
SSL_PURCHASEMORESANS = "namecheap.ssl.purchasemoresans",
|
|
39
|
+
SSL_REVOKECERTIFICATE = "namecheap.ssl.revokecertificate",
|
|
40
|
+
SSL_EDITDCVMETHOD = "namecheap.ssl.editDCVMethod",
|
|
41
|
+
USERS_GETPRICING = "namecheap.users.getPricing",
|
|
42
|
+
USERS_GETBALANCES = "namecheap.users.getBalances",
|
|
43
|
+
USERS_CHANGEPASSWORD = "namecheap.users.changePassword",
|
|
44
|
+
USERS_UPDATE = "namecheap.users.update",
|
|
45
|
+
USERS_CREATEADDFUNDSREQUEST = "namecheap.users.createaddfundsrequest",
|
|
46
|
+
USERS_GETADDFUNDSSTATUS = "namecheap.users.getAddFundsStatus",
|
|
47
|
+
USERS_CREATE = "namecheap.users.create",
|
|
48
|
+
USERS_LOGIN = "namecheap.users.login",
|
|
49
|
+
USERS_RESETPASSWORD = "namecheap.users.resetPassword",
|
|
50
|
+
USERS_ADDRESS_CREATE = "namecheap.users.address.create",
|
|
51
|
+
USERS_ADDRESS_DELETE = "namecheap.users.address.delete",
|
|
52
|
+
USERS_ADDRESS_GETINFO = "namecheap.users.address.getInfo",
|
|
53
|
+
USERS_ADDRESS_GETLIST = "namecheap.users.address.getList",
|
|
54
|
+
USERS_ADDRESS_SETDEFAULT = "namecheap.users.address.setDefault",
|
|
55
|
+
USERS_ADDRESS_UPDATE = "namecheap.users.address.update",
|
|
56
|
+
WHOISGUARD_CHANGEEMAILADDRESS = "Namecheap.Whoisguard.changeemailaddress",
|
|
57
|
+
WHOISGUARD_ENABLE = "Namecheap.Whoisguard.enable",
|
|
58
|
+
WHOISGUARD_DISABLE = "Namecheap.Whoisguard.disable",
|
|
59
|
+
WHOISGUARD_GETLIST = "Namecheap.Whoisguard.getList",
|
|
60
|
+
WHOISGUARD_RENEW = "Namecheap.Whoisguard.renew"
|
|
61
|
+
}
|
|
62
|
+
type Command = `${Commands}`;
|
|
63
|
+
|
|
64
|
+
declare enum DomainPriceActions {
|
|
65
|
+
REGISTER = "REGISTER",
|
|
66
|
+
RENEW = "RENEW",
|
|
67
|
+
REACTIVATE = "REACTIVATE",
|
|
68
|
+
TRANSFER = "TRANSFER"
|
|
69
|
+
}
|
|
70
|
+
type DomainPriceAction = `${DomainPriceActions}`;
|
|
71
|
+
|
|
72
|
+
interface INamecheapConfig {
|
|
73
|
+
ApiUser: string;
|
|
74
|
+
ApiKey: string;
|
|
75
|
+
UserName: string;
|
|
76
|
+
ClientIp: string;
|
|
77
|
+
}
|
|
78
|
+
interface IReponse {
|
|
79
|
+
data: any;
|
|
80
|
+
status: number;
|
|
81
|
+
}
|
|
82
|
+
interface ICheckDomainResponse {
|
|
83
|
+
availabe: boolean;
|
|
84
|
+
premium: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare class Namecheap {
|
|
87
|
+
private readonly config;
|
|
88
|
+
private readonly apiClient;
|
|
89
|
+
constructor(config: INamecheapConfig, sandbox?: boolean);
|
|
90
|
+
call(command: Command, payload: Record<string, string>): Promise<IReponse>;
|
|
91
|
+
checkDomain(domainName: string): Promise<ICheckDomainResponse>;
|
|
92
|
+
getDomainPrice(domainName: string, action: DomainPriceAction): Promise<IReponse>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { Command, Commands, DomainPriceAction, DomainPriceActions, ICheckDomainResponse, INamecheapConfig, IReponse, Namecheap as default };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,268 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
7
21
|
}
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __copyProps = (to, from, except, desc) => {
|
|
30
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(from))
|
|
32
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
33
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
|
+
mod
|
|
44
|
+
));
|
|
45
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
|
+
var __async = (__this, __arguments, generator) => {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
var fulfilled = (value) => {
|
|
49
|
+
try {
|
|
50
|
+
step(generator.next(value));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
reject(e);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var rejected = (value) => {
|
|
56
|
+
try {
|
|
57
|
+
step(generator.throw(value));
|
|
58
|
+
} catch (e) {
|
|
59
|
+
reject(e);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
63
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/index.ts
|
|
68
|
+
var src_exports = {};
|
|
69
|
+
__export(src_exports, {
|
|
70
|
+
Commands: () => Commands,
|
|
71
|
+
DomainPriceActions: () => DomainPriceActions,
|
|
72
|
+
default: () => namecheap_default
|
|
73
|
+
});
|
|
74
|
+
module.exports = __toCommonJS(src_exports);
|
|
75
|
+
|
|
76
|
+
// src/commands.ts
|
|
77
|
+
var Commands = /* @__PURE__ */ ((Commands2) => {
|
|
78
|
+
Commands2["DOMAINS_GETLIST"] = "namecheap.domains.getList";
|
|
79
|
+
Commands2["DOMAINS_GETCONTACTS"] = "namecheap.domains.getContacts";
|
|
80
|
+
Commands2["DOMAINS_CREATE"] = "namecheap.domains.create";
|
|
81
|
+
Commands2["DOMAINS_GETTLDLIST"] = "namecheap.domains.getTldList";
|
|
82
|
+
Commands2["DOMAINS_SETCONTACTS"] = "namecheap.domains.setContacts";
|
|
83
|
+
Commands2["DOMAINS_CHECK"] = "namecheap.domains.check";
|
|
84
|
+
Commands2["DOMAINS_REACTIVATE"] = "namecheap.domains.reactivate";
|
|
85
|
+
Commands2["DOMAINS_RENEW"] = "namecheap.domains.renew";
|
|
86
|
+
Commands2["DOMAINS_GETREGISTRARLOCK"] = "namecheap.domains.getRegistrarLock";
|
|
87
|
+
Commands2["DOMAINS_SETREGISTRARLOCK"] = "namecheap.domains.setRegistrarLock";
|
|
88
|
+
Commands2["DOMAINS_GETINFO"] = "namecheap.domains.getInfo";
|
|
89
|
+
Commands2["DOMAINS_DNS_SETDEFAULT"] = "namecheap.domains.dns.setDefault";
|
|
90
|
+
Commands2["DOMAINS_DNS_SETCUSTOM"] = "namecheap.domains.dns.setCustom";
|
|
91
|
+
Commands2["DOMAINS_DNS_GETLIST"] = "namecheap.domains.dns.getList";
|
|
92
|
+
Commands2["DOMAINS_DNS_GETHOSTS"] = "namecheap.domains.dns.getHosts";
|
|
93
|
+
Commands2["DOMAINS_DNS_GETEMAILFORWARDING"] = "namecheap.domains.dns.getEmailForwarding";
|
|
94
|
+
Commands2["DOMAINS_DNS_SETEMAILFORWARDING"] = "namecheap.domains.dns.setEmailForwarding";
|
|
95
|
+
Commands2["DOMAINS_DNS_SETHOSTS"] = "namecheap.domains.dns.setHosts";
|
|
96
|
+
Commands2["DOMAINS_NS_CREATE"] = "namecheap.domains.ns.create";
|
|
97
|
+
Commands2["DOMAINS_NS_DELETE"] = "namecheap.domains.ns.delete";
|
|
98
|
+
Commands2["DOMAINS_NS_GETINFO"] = "namecheap.domains.ns.getInfo";
|
|
99
|
+
Commands2["DOMAINS_NS_UPDATE"] = "namecheap.domains.ns.update";
|
|
100
|
+
Commands2["DOMAINS_TRANSFER_CREATE"] = "namecheap.domains.transfer.create";
|
|
101
|
+
Commands2["DOMAINS_TRANSFER_GETSTATUS"] = "namecheap.domains.transfer.getStatus";
|
|
102
|
+
Commands2["DOMAINS_TRANSFER_UPDATESTATUS"] = "namecheap.domains.transfer.updateStatus";
|
|
103
|
+
Commands2["DOMAINS_TRANSFER_GETLIST"] = "namecheap.domains.transfer.getList";
|
|
104
|
+
Commands2["SSL_CREATE"] = "namecheap.ssl.create";
|
|
105
|
+
Commands2["SSL_GETLIST"] = "namecheap.ssl.getList";
|
|
106
|
+
Commands2["SSL_PARSECSR"] = "namecheap.ssl.parseCSR";
|
|
107
|
+
Commands2["SSL_GETAPPROVEREMAILLIST"] = "namecheap.ssl.getApproverEmailList";
|
|
108
|
+
Commands2["SSL_ACTIVATE"] = "namecheap.ssl.activate";
|
|
109
|
+
Commands2["SSL_RESENDAPPROVEREMAIL"] = "namecheap.ssl.resendApproverEmail";
|
|
110
|
+
Commands2["SSL_GETINFO"] = "namecheap.ssl.getInfo";
|
|
111
|
+
Commands2["SSL_RENEW"] = "namecheap.ssl.renew";
|
|
112
|
+
Commands2["SSL_REISSUE"] = "namecheap.ssl.reissue";
|
|
113
|
+
Commands2["SSL_RESENDFULFILLMENTEMAIL"] = "namecheap.ssl.resendfulfillmentemail";
|
|
114
|
+
Commands2["SSL_PURCHASEMORESANS"] = "namecheap.ssl.purchasemoresans";
|
|
115
|
+
Commands2["SSL_REVOKECERTIFICATE"] = "namecheap.ssl.revokecertificate";
|
|
116
|
+
Commands2["SSL_EDITDCVMETHOD"] = "namecheap.ssl.editDCVMethod";
|
|
117
|
+
Commands2["USERS_GETPRICING"] = "namecheap.users.getPricing";
|
|
118
|
+
Commands2["USERS_GETBALANCES"] = "namecheap.users.getBalances";
|
|
119
|
+
Commands2["USERS_CHANGEPASSWORD"] = "namecheap.users.changePassword";
|
|
120
|
+
Commands2["USERS_UPDATE"] = "namecheap.users.update";
|
|
121
|
+
Commands2["USERS_CREATEADDFUNDSREQUEST"] = "namecheap.users.createaddfundsrequest";
|
|
122
|
+
Commands2["USERS_GETADDFUNDSSTATUS"] = "namecheap.users.getAddFundsStatus";
|
|
123
|
+
Commands2["USERS_CREATE"] = "namecheap.users.create";
|
|
124
|
+
Commands2["USERS_LOGIN"] = "namecheap.users.login";
|
|
125
|
+
Commands2["USERS_RESETPASSWORD"] = "namecheap.users.resetPassword";
|
|
126
|
+
Commands2["USERS_ADDRESS_CREATE"] = "namecheap.users.address.create";
|
|
127
|
+
Commands2["USERS_ADDRESS_DELETE"] = "namecheap.users.address.delete";
|
|
128
|
+
Commands2["USERS_ADDRESS_GETINFO"] = "namecheap.users.address.getInfo";
|
|
129
|
+
Commands2["USERS_ADDRESS_GETLIST"] = "namecheap.users.address.getList";
|
|
130
|
+
Commands2["USERS_ADDRESS_SETDEFAULT"] = "namecheap.users.address.setDefault";
|
|
131
|
+
Commands2["USERS_ADDRESS_UPDATE"] = "namecheap.users.address.update";
|
|
132
|
+
Commands2["WHOISGUARD_CHANGEEMAILADDRESS"] = "Namecheap.Whoisguard.changeemailaddress";
|
|
133
|
+
Commands2["WHOISGUARD_ENABLE"] = "Namecheap.Whoisguard.enable";
|
|
134
|
+
Commands2["WHOISGUARD_DISABLE"] = "Namecheap.Whoisguard.disable";
|
|
135
|
+
Commands2["WHOISGUARD_GETLIST"] = "Namecheap.Whoisguard.getList";
|
|
136
|
+
Commands2["WHOISGUARD_RENEW"] = "Namecheap.Whoisguard.renew";
|
|
137
|
+
return Commands2;
|
|
138
|
+
})(Commands || {});
|
|
139
|
+
|
|
140
|
+
// src/types.ts
|
|
141
|
+
var DomainPriceActions = /* @__PURE__ */ ((DomainPriceActions2) => {
|
|
142
|
+
DomainPriceActions2["REGISTER"] = "REGISTER";
|
|
143
|
+
DomainPriceActions2["RENEW"] = "RENEW";
|
|
144
|
+
DomainPriceActions2["REACTIVATE"] = "REACTIVATE";
|
|
145
|
+
DomainPriceActions2["TRANSFER"] = "TRANSFER";
|
|
146
|
+
return DomainPriceActions2;
|
|
147
|
+
})(DomainPriceActions || {});
|
|
148
|
+
|
|
149
|
+
// src/api/api-client.ts
|
|
150
|
+
var import_axios = __toESM(require("axios"));
|
|
151
|
+
var import_xml2js = require("xml2js");
|
|
152
|
+
|
|
153
|
+
// src/api/errors.ts
|
|
154
|
+
var XMLParsingError = class extends Error {
|
|
155
|
+
constructor() {
|
|
156
|
+
super("Invalid XML response");
|
|
157
|
+
this.name = "XMLParsingError";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var ResponseError = class extends Error {
|
|
161
|
+
constructor(message, code) {
|
|
162
|
+
super((code ? `${code}: ` : "") + message);
|
|
163
|
+
this.code = code;
|
|
164
|
+
this.name = "ResponseError";
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/api/api-client.ts
|
|
169
|
+
var APIClient = class {
|
|
170
|
+
constructor(baseURL) {
|
|
171
|
+
this._client = import_axios.default.create({ baseURL });
|
|
172
|
+
this._client.interceptors.response.use(this.onResponse);
|
|
173
|
+
}
|
|
174
|
+
get(url) {
|
|
175
|
+
return __async(this, null, function* () {
|
|
176
|
+
return yield this._client.get(url);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
onResponse(response) {
|
|
180
|
+
return __async(this, null, function* () {
|
|
181
|
+
try {
|
|
182
|
+
const result = yield (0, import_xml2js.parseStringPromise)(response.data);
|
|
183
|
+
if (result.ApiResponse.$.Status === "ERROR") {
|
|
184
|
+
const responseErrors = result.ApiResponse.Errors;
|
|
185
|
+
const code = responseErrors[0].Error[0].$.Number;
|
|
186
|
+
const message = responseErrors[0].Error[0]._;
|
|
187
|
+
throw new ResponseError(message, code);
|
|
188
|
+
}
|
|
189
|
+
response.data = result.ApiResponse.CommandResponse;
|
|
190
|
+
} catch (err) {
|
|
191
|
+
response.status = 400;
|
|
192
|
+
if (err instanceof ResponseError) {
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
throw new XMLParsingError();
|
|
196
|
+
}
|
|
197
|
+
return response;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var api_client_default = APIClient;
|
|
202
|
+
|
|
203
|
+
// src/exceptions/InvalidDomainNameException.ts
|
|
204
|
+
var InvalidDomainNameException = class extends Error {
|
|
205
|
+
constructor(domainName) {
|
|
206
|
+
super(`The provided domain name [${domainName}] is not valid`);
|
|
207
|
+
this.name = "InvalidDomainNameException";
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/namecheap.ts
|
|
212
|
+
var Namecheap = class {
|
|
213
|
+
constructor(config, sandbox) {
|
|
214
|
+
this.config = config;
|
|
215
|
+
const baseURL = `https://api${sandbox ? ".sandbox" : ""}.namecheap.com/xml.response`;
|
|
216
|
+
this.apiClient = new api_client_default(baseURL);
|
|
217
|
+
}
|
|
218
|
+
call(command, payload) {
|
|
219
|
+
return __async(this, null, function* () {
|
|
220
|
+
const params = __spreadProps(__spreadValues(__spreadValues({}, payload), this.config), {
|
|
221
|
+
command
|
|
222
|
+
});
|
|
223
|
+
const url = "?" + new URLSearchParams(params).toString();
|
|
224
|
+
const { data, status } = yield this.apiClient.get(url);
|
|
225
|
+
return { data, status };
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
checkDomain(domainName) {
|
|
229
|
+
return __async(this, null, function* () {
|
|
230
|
+
const { data } = yield this.call("namecheap.domains.check" /* DOMAINS_CHECK */, {
|
|
231
|
+
DomainList: domainName
|
|
232
|
+
});
|
|
233
|
+
const isAvailabe = data[0].DomainCheckResult[0].$.Available;
|
|
234
|
+
const isPremium = data[0].DomainCheckResult[0].$.IsPremiumName;
|
|
235
|
+
const response = {
|
|
236
|
+
availabe: isAvailabe === "true",
|
|
237
|
+
premium: isPremium === "true"
|
|
238
|
+
};
|
|
239
|
+
return response;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
getDomainPrice(domainName, action) {
|
|
243
|
+
return __async(this, null, function* () {
|
|
244
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
245
|
+
const [_, tld] = domainName.split(".");
|
|
246
|
+
if (!tld) {
|
|
247
|
+
throw new InvalidDomainNameException(domainName);
|
|
248
|
+
}
|
|
249
|
+
const { data, status } = yield this.call("namecheap.users.getPricing" /* USERS_GETPRICING */, {
|
|
250
|
+
ProductType: "DOMAIN",
|
|
251
|
+
ProductCategory: "DOMAINS",
|
|
252
|
+
ActionName: action,
|
|
253
|
+
ProductName: tld
|
|
254
|
+
});
|
|
255
|
+
const pricing = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = data[0].UserGetPricingResult[0]) == null ? void 0 : _a.ProductType) == null ? void 0 : _b[0]) == null ? void 0 : _c.ProductCategory) == null ? void 0 : _d[0]) == null ? void 0 : _e.Product) == null ? void 0 : _f[0]) == null ? void 0 : _g.Price) == null ? void 0 : _h.map(
|
|
256
|
+
(price) => __spreadValues({}, price.$)
|
|
257
|
+
);
|
|
258
|
+
return { data: pricing, status };
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
var namecheap_default = Namecheap;
|
|
263
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
264
|
+
0 && (module.exports = {
|
|
265
|
+
Commands,
|
|
266
|
+
DomainPriceActions
|
|
267
|
+
});
|
|
268
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/api/api-client.ts","../src/api/errors.ts","../src/namecheap.ts"],"sourcesContent":["export { default, INamecheapConfig, ICallReponse } from \"./namecheap\";\r\n\r\n// import fs from \"fs\";\r\n\r\n// import NameCheap from \"./namecheap\";\r\n\r\n// const instance = new NameCheap(\r\n// {\r\n// ApiKey: \"d915adb9b0ac405398def53be001110e\",\r\n// ApiUser: \"Kanakri\",\r\n// UserName: \"Kanakri\",\r\n// ClientIp: \"5.155.10.166\",\r\n// },\r\n// true\r\n// );\r\n\r\n// instance\r\n// .call(\"namecheap.domains.check\", {\r\n// DomainList: \"mezoishere.net\",\r\n// })\r\n// .then(({data}) => {\r\n// fs.writeFile(\"data.json\", JSON.stringify(data, null, 2), \"utf8\", (err) => {\r\n// console.log(err);\r\n// });\r\n// console.log({ data });\r\n// })\r\n// .catch((err) => {\r\n// console.log({ err });\r\n// });\r\n","import axios, { AxiosInstance, AxiosResponse } from \"axios\";\r\nimport { parseStringPromise } from \"xml2js\";\r\nimport { ResponseError, XMLParsingError } from \"./errors\";\r\n\r\nclass APIClient {\r\n private readonly _client: AxiosInstance;\r\n constructor(baseURL: string) {\r\n this._client = axios.create({ baseURL });\r\n this._client.interceptors.response.use(this.onResponse);\r\n }\r\n\r\n async get(url: string) {\r\n return await this._client.get(url);\r\n }\r\n\r\n private async onResponse(response: AxiosResponse): Promise<AxiosResponse> {\r\n try {\r\n const result = await parseStringPromise(response.data);\r\n\r\n if (result.ApiResponse.$.Status === \"ERROR\") {\r\n const responseErrors = result.ApiResponse.Errors;\r\n const code = responseErrors[0].Error[0].$.Number;\r\n const message = responseErrors[0].Error[0]._;\r\n\r\n throw new ResponseError(message, code);\r\n }\r\n\r\n response.data = result.ApiResponse.CommandResponse;\r\n } catch (err) {\r\n response.status = 400;\r\n if (err instanceof ResponseError) {\r\n throw err;\r\n }\r\n\r\n throw new XMLParsingError();\r\n }\r\n\r\n return response;\r\n }\r\n}\r\n\r\nexport default APIClient;\r\n","export class XMLParsingError extends Error {\r\n constructor() {\r\n super(\"Invalid XML response\");\r\n\r\n this.name = \"XMLParsingError\";\r\n }\r\n}\r\n\r\nexport class ResponseError extends Error {\r\n constructor(message: string, readonly code?: number) {\r\n super((code ? `${code}: ` : \"\") + message);\r\n\r\n this.name = \"ResponseError\";\r\n }\r\n}\r\n","import APIClient from \"./api\";\r\nimport { ICommand } from \"./commands\";\r\n\r\nexport interface INamecheapConfig {\r\n ApiUser: string;\r\n ApiKey: string;\r\n UserName: string;\r\n ClientIp: string;\r\n}\r\n\r\nexport interface ICallReponse {\r\n data: any;\r\n status: number;\r\n}\r\n\r\nclass Namecheap {\r\n private readonly apiClient: APIClient;\r\n constructor(private readonly config: INamecheapConfig, sandbox?: boolean) {\r\n const baseURL = `https://api${\r\n sandbox ? \".sandbox\" : \"\"\r\n }.namecheap.com/xml.response`;\r\n this.apiClient = new APIClient(baseURL);\r\n }\r\n\r\n async call(\r\n command: ICommand,\r\n payload: Record<string, string>\r\n ): Promise<ICallReponse> {\r\n const params = {\r\n ...this.config,\r\n ...payload,\r\n command,\r\n };\r\n\r\n const url = \"?\" + new URLSearchParams(params).toString();\r\n\r\n const { data, status } = await this.apiClient.get(url);\r\n\r\n return { data, status };\r\n }\r\n}\r\n\r\nexport default Namecheap;\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAoD;AACpD,oBAAmC;;;ACD5B,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAA0B,MAAe;AACnD,WAAO,OAAO,GAAG,IAAI,OAAO,MAAM,OAAO;AADL;AAGpC,SAAK,OAAO;AAAA,EACd;AACF;;;ADVA,IAAM,YAAN,MAAgB;AAAA,EAEd,YAAY,SAAiB;AAC3B,SAAK,UAAU,aAAAA,QAAM,OAAO,EAAE,QAAQ,CAAC;AACvC,SAAK,QAAQ,aAAa,SAAS,IAAI,KAAK,UAAU;AAAA,EACxD;AAAA,EAEM,IAAI,KAAa;AAAA;AACrB,aAAO,MAAM,KAAK,QAAQ,IAAI,GAAG;AAAA,IACnC;AAAA;AAAA,EAEc,WAAW,UAAiD;AAAA;AACxE,UAAI;AACF,cAAM,SAAS,UAAM,kCAAmB,SAAS,IAAI;AAErD,YAAI,OAAO,YAAY,EAAE,WAAW,SAAS;AAC3C,gBAAM,iBAAiB,OAAO,YAAY;AAC1C,gBAAM,OAAO,eAAe,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE;AAC1C,gBAAM,UAAU,eAAe,CAAC,EAAE,MAAM,CAAC,EAAE;AAE3C,gBAAM,IAAI,cAAc,SAAS,IAAI;AAAA,QACvC;AAEA,iBAAS,OAAO,OAAO,YAAY;AAAA,MACrC,SAAS,KAAK;AACZ,iBAAS,SAAS;AAClB,YAAI,eAAe,eAAe;AAChC,gBAAM;AAAA,QACR;AAEA,cAAM,IAAI,gBAAgB;AAAA,MAC5B;AAEA,aAAO;AAAA,IACT;AAAA;AACF;AAEA,IAAO,qBAAQ;;;AE1Bf,IAAM,YAAN,MAAgB;AAAA,EAEd,YAA6B,QAA0B,SAAmB;AAA7C;AAC3B,UAAM,UAAU,cACd,UAAU,aAAa,EACzB;AACA,SAAK,YAAY,IAAI,mBAAU,OAAO;AAAA,EACxC;AAAA,EAEM,KACJ,SACA,SACuB;AAAA;AACvB,YAAM,SAAS,gDACV,KAAK,SACL,UAFU;AAAA,QAGb;AAAA,MACF;AAEA,YAAM,MAAM,MAAM,IAAI,gBAAgB,MAAM,EAAE,SAAS;AAEvD,YAAM,EAAE,MAAM,OAAO,IAAI,MAAM,KAAK,UAAU,IAAI,GAAG;AAErD,aAAO,EAAE,MAAM,OAAO;AAAA,IACxB;AAAA;AACF;AAEA,IAAO,oBAAQ;","names":["axios"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/commands.ts","../src/types.ts","../src/api/api-client.ts","../src/api/errors.ts","../src/exceptions/InvalidDomainNameException.ts","../src/namecheap.ts"],"sourcesContent":["export * from \"./commands\";\r\nexport * from \"./types\";\r\nexport * from \"./namecheap\";\r\nexport { default } from \"./namecheap\";\r\n","export enum Commands {\r\n // domains\r\n DOMAINS_GETLIST = \"namecheap.domains.getList\",\r\n DOMAINS_GETCONTACTS = \"namecheap.domains.getContacts\",\r\n DOMAINS_CREATE = \"namecheap.domains.create\",\r\n DOMAINS_GETTLDLIST = \"namecheap.domains.getTldList\",\r\n DOMAINS_SETCONTACTS = \"namecheap.domains.setContacts\",\r\n DOMAINS_CHECK = \"namecheap.domains.check\",\r\n DOMAINS_REACTIVATE = \"namecheap.domains.reactivate\",\r\n DOMAINS_RENEW = \"namecheap.domains.renew\",\r\n DOMAINS_GETREGISTRARLOCK = \"namecheap.domains.getRegistrarLock\",\r\n DOMAINS_SETREGISTRARLOCK = \"namecheap.domains.setRegistrarLock\",\r\n DOMAINS_GETINFO = \"namecheap.domains.getInfo\",\r\n\r\n // domains.dns\r\n DOMAINS_DNS_SETDEFAULT = \"namecheap.domains.dns.setDefault\",\r\n DOMAINS_DNS_SETCUSTOM = \"namecheap.domains.dns.setCustom\",\r\n DOMAINS_DNS_GETLIST = \"namecheap.domains.dns.getList\",\r\n DOMAINS_DNS_GETHOSTS = \"namecheap.domains.dns.getHosts\",\r\n DOMAINS_DNS_GETEMAILFORWARDING = \"namecheap.domains.dns.getEmailForwarding\",\r\n DOMAINS_DNS_SETEMAILFORWARDING = \"namecheap.domains.dns.setEmailForwarding\",\r\n DOMAINS_DNS_SETHOSTS = \"namecheap.domains.dns.setHosts\",\r\n\r\n // domains.ns\r\n DOMAINS_NS_CREATE = \"namecheap.domains.ns.create\",\r\n DOMAINS_NS_DELETE = \"namecheap.domains.ns.delete\",\r\n DOMAINS_NS_GETINFO = \"namecheap.domains.ns.getInfo\",\r\n DOMAINS_NS_UPDATE = \"namecheap.domains.ns.update\",\r\n\r\n // domains.transfer\r\n DOMAINS_TRANSFER_CREATE = \"namecheap.domains.transfer.create\",\r\n DOMAINS_TRANSFER_GETSTATUS = \"namecheap.domains.transfer.getStatus\",\r\n DOMAINS_TRANSFER_UPDATESTATUS = \"namecheap.domains.transfer.updateStatus\",\r\n DOMAINS_TRANSFER_GETLIST = \"namecheap.domains.transfer.getList\",\r\n\r\n // ssl\r\n SSL_CREATE = \"namecheap.ssl.create\",\r\n SSL_GETLIST = \"namecheap.ssl.getList\",\r\n SSL_PARSECSR = \"namecheap.ssl.parseCSR\",\r\n SSL_GETAPPROVEREMAILLIST = \"namecheap.ssl.getApproverEmailList\",\r\n SSL_ACTIVATE = \"namecheap.ssl.activate\",\r\n SSL_RESENDAPPROVEREMAIL = \"namecheap.ssl.resendApproverEmail\",\r\n SSL_GETINFO = \"namecheap.ssl.getInfo\",\r\n SSL_RENEW = \"namecheap.ssl.renew\",\r\n SSL_REISSUE = \"namecheap.ssl.reissue\",\r\n SSL_RESENDFULFILLMENTEMAIL = \"namecheap.ssl.resendfulfillmentemail\",\r\n SSL_PURCHASEMORESANS = \"namecheap.ssl.purchasemoresans\",\r\n SSL_REVOKECERTIFICATE = \"namecheap.ssl.revokecertificate\",\r\n SSL_EDITDCVMETHOD = \"namecheap.ssl.editDCVMethod\",\r\n\r\n // users\r\n USERS_GETPRICING = \"namecheap.users.getPricing\",\r\n USERS_GETBALANCES = \"namecheap.users.getBalances\",\r\n USERS_CHANGEPASSWORD = \"namecheap.users.changePassword\",\r\n USERS_UPDATE = \"namecheap.users.update\",\r\n USERS_CREATEADDFUNDSREQUEST = \"namecheap.users.createaddfundsrequest\",\r\n USERS_GETADDFUNDSSTATUS = \"namecheap.users.getAddFundsStatus\",\r\n USERS_CREATE = \"namecheap.users.create\",\r\n USERS_LOGIN = \"namecheap.users.login\",\r\n USERS_RESETPASSWORD = \"namecheap.users.resetPassword\",\r\n\r\n // users.address\r\n USERS_ADDRESS_CREATE = \"namecheap.users.address.create\",\r\n USERS_ADDRESS_DELETE = \"namecheap.users.address.delete\",\r\n USERS_ADDRESS_GETINFO = \"namecheap.users.address.getInfo\",\r\n USERS_ADDRESS_GETLIST = \"namecheap.users.address.getList\",\r\n USERS_ADDRESS_SETDEFAULT = \"namecheap.users.address.setDefault\",\r\n USERS_ADDRESS_UPDATE = \"namecheap.users.address.update\",\r\n\r\n // domainprivacy\r\n WHOISGUARD_CHANGEEMAILADDRESS = \"Namecheap.Whoisguard.changeemailaddress\",\r\n WHOISGUARD_ENABLE = \"Namecheap.Whoisguard.enable\",\r\n WHOISGUARD_DISABLE = \"Namecheap.Whoisguard.disable\",\r\n WHOISGUARD_GETLIST = \"Namecheap.Whoisguard.getList\",\r\n WHOISGUARD_RENEW = \"Namecheap.Whoisguard.renew\",\r\n}\r\n\r\nexport type Command = `${Commands}`;\r\n","export enum DomainPriceActions {\r\n REGISTER = \"REGISTER\",\r\n RENEW = \"RENEW\",\r\n REACTIVATE = \"REACTIVATE\",\r\n TRANSFER = \"TRANSFER\",\r\n}\r\n\r\nexport type DomainPriceAction = `${DomainPriceActions}`;\r\n","import axios, { AxiosInstance, AxiosResponse } from \"axios\";\r\nimport { parseStringPromise } from \"xml2js\";\r\nimport { ResponseError, XMLParsingError } from \"./errors\";\r\n\r\nclass APIClient {\r\n private readonly _client: AxiosInstance;\r\n constructor(baseURL: string) {\r\n this._client = axios.create({ baseURL });\r\n this._client.interceptors.response.use(this.onResponse);\r\n }\r\n\r\n async get(url: string) {\r\n return await this._client.get(url);\r\n }\r\n\r\n private async onResponse(response: AxiosResponse): Promise<AxiosResponse> {\r\n try {\r\n const result = await parseStringPromise(response.data);\r\n\r\n if (result.ApiResponse.$.Status === \"ERROR\") {\r\n const responseErrors = result.ApiResponse.Errors;\r\n const code = responseErrors[0].Error[0].$.Number;\r\n const message = responseErrors[0].Error[0]._;\r\n\r\n throw new ResponseError(message, code);\r\n }\r\n\r\n response.data = result.ApiResponse.CommandResponse;\r\n } catch (err) {\r\n response.status = 400;\r\n if (err instanceof ResponseError) {\r\n throw err;\r\n }\r\n\r\n throw new XMLParsingError();\r\n }\r\n\r\n return response;\r\n }\r\n}\r\n\r\nexport default APIClient;\r\n","export class XMLParsingError extends Error {\r\n constructor() {\r\n super(\"Invalid XML response\");\r\n\r\n this.name = \"XMLParsingError\";\r\n }\r\n}\r\n\r\nexport class ResponseError extends Error {\r\n constructor(message: string, readonly code?: number) {\r\n super((code ? `${code}: ` : \"\") + message);\r\n\r\n this.name = \"ResponseError\";\r\n }\r\n}\r\n","export class InvalidDomainNameException extends Error {\r\n constructor(domainName: string) {\r\n super(`The provided domain name [${domainName}] is not valid`);\r\n\r\n this.name = \"InvalidDomainNameException\";\r\n }\r\n}\r\n","import APIClient from \"./api\";\r\nimport { Commands, Command } from \"./commands\";\r\nimport { InvalidDomainNameException } from \"./exceptions\";\r\nimport { DomainPriceAction } from \"./types\";\r\n\r\nexport interface INamecheapConfig {\r\n ApiUser: string;\r\n ApiKey: string;\r\n UserName: string;\r\n ClientIp: string;\r\n}\r\n\r\nexport interface IReponse {\r\n data: any;\r\n status: number;\r\n}\r\n\r\nexport interface ICheckDomainResponse {\r\n availabe: boolean;\r\n premium: boolean;\r\n}\r\n\r\nclass Namecheap {\r\n private readonly apiClient: APIClient;\r\n constructor(private readonly config: INamecheapConfig, sandbox?: boolean) {\r\n const baseURL = `https://api${\r\n sandbox ? \".sandbox\" : \"\"\r\n }.namecheap.com/xml.response`;\r\n this.apiClient = new APIClient(baseURL);\r\n }\r\n\r\n async call(\r\n command: Command,\r\n payload: Record<string, string>\r\n ): Promise<IReponse> {\r\n const params = {\r\n ...payload,\r\n ...this.config,\r\n command,\r\n };\r\n\r\n const url = \"?\" + new URLSearchParams(params).toString();\r\n\r\n const { data, status } = await this.apiClient.get(url);\r\n\r\n return { data, status };\r\n }\r\n\r\n async checkDomain(domainName: string): Promise<ICheckDomainResponse> {\r\n const { data } = await this.call(Commands.DOMAINS_CHECK, {\r\n DomainList: domainName,\r\n });\r\n\r\n const isAvailabe: string = data[0].DomainCheckResult[0].$.Available;\r\n const isPremium: string = data[0].DomainCheckResult[0].$.IsPremiumName;\r\n\r\n const response: ICheckDomainResponse = {\r\n availabe: isAvailabe === \"true\",\r\n premium: isPremium === \"true\",\r\n };\r\n\r\n return response;\r\n }\r\n\r\n async getDomainPrice(\r\n domainName: string,\r\n action: DomainPriceAction\r\n ): Promise<IReponse> {\r\n const [_, tld] = domainName.split(\".\");\r\n if (!tld) {\r\n throw new InvalidDomainNameException(domainName);\r\n }\r\n\r\n const { data, status } = await this.call(Commands.USERS_GETPRICING, {\r\n ProductType: \"DOMAIN\",\r\n ProductCategory: \"DOMAINS\",\r\n ActionName: action,\r\n ProductName: tld,\r\n });\r\n\r\n const pricing =\r\n data[0].UserGetPricingResult[0]?.ProductType?.[0]?.ProductCategory?.[0]?.Product?.[0]?.Price?.map(\r\n (price: any) => ({ ...price.$ })\r\n );\r\n\r\n return { data: pricing, status };\r\n }\r\n}\r\n\r\nexport default Namecheap;\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAK,WAAL,kBAAKA,cAAL;AAEL,EAAAA,UAAA,qBAAkB;AAClB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,oBAAiB;AACjB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,mBAAgB;AAChB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,mBAAgB;AAChB,EAAAA,UAAA,8BAA2B;AAC3B,EAAAA,UAAA,8BAA2B;AAC3B,EAAAA,UAAA,qBAAkB;AAGlB,EAAAA,UAAA,4BAAyB;AACzB,EAAAA,UAAA,2BAAwB;AACxB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,0BAAuB;AACvB,EAAAA,UAAA,oCAAiC;AACjC,EAAAA,UAAA,oCAAiC;AACjC,EAAAA,UAAA,0BAAuB;AAGvB,EAAAA,UAAA,uBAAoB;AACpB,EAAAA,UAAA,uBAAoB;AACpB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,uBAAoB;AAGpB,EAAAA,UAAA,6BAA0B;AAC1B,EAAAA,UAAA,gCAA6B;AAC7B,EAAAA,U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GhC,aAAO,EAAE,MAAM,SAAS,OAAO;AAAA,IACjC;AAAA;AACF;AAEA,IAAO,oBAAQ;","names":["Commands","DomainPriceActions","axios"]}
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,79 @@ var __async = (__this, __arguments, generator) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
// src/commands.ts
|
|
42
|
+
var Commands = /* @__PURE__ */ ((Commands2) => {
|
|
43
|
+
Commands2["DOMAINS_GETLIST"] = "namecheap.domains.getList";
|
|
44
|
+
Commands2["DOMAINS_GETCONTACTS"] = "namecheap.domains.getContacts";
|
|
45
|
+
Commands2["DOMAINS_CREATE"] = "namecheap.domains.create";
|
|
46
|
+
Commands2["DOMAINS_GETTLDLIST"] = "namecheap.domains.getTldList";
|
|
47
|
+
Commands2["DOMAINS_SETCONTACTS"] = "namecheap.domains.setContacts";
|
|
48
|
+
Commands2["DOMAINS_CHECK"] = "namecheap.domains.check";
|
|
49
|
+
Commands2["DOMAINS_REACTIVATE"] = "namecheap.domains.reactivate";
|
|
50
|
+
Commands2["DOMAINS_RENEW"] = "namecheap.domains.renew";
|
|
51
|
+
Commands2["DOMAINS_GETREGISTRARLOCK"] = "namecheap.domains.getRegistrarLock";
|
|
52
|
+
Commands2["DOMAINS_SETREGISTRARLOCK"] = "namecheap.domains.setRegistrarLock";
|
|
53
|
+
Commands2["DOMAINS_GETINFO"] = "namecheap.domains.getInfo";
|
|
54
|
+
Commands2["DOMAINS_DNS_SETDEFAULT"] = "namecheap.domains.dns.setDefault";
|
|
55
|
+
Commands2["DOMAINS_DNS_SETCUSTOM"] = "namecheap.domains.dns.setCustom";
|
|
56
|
+
Commands2["DOMAINS_DNS_GETLIST"] = "namecheap.domains.dns.getList";
|
|
57
|
+
Commands2["DOMAINS_DNS_GETHOSTS"] = "namecheap.domains.dns.getHosts";
|
|
58
|
+
Commands2["DOMAINS_DNS_GETEMAILFORWARDING"] = "namecheap.domains.dns.getEmailForwarding";
|
|
59
|
+
Commands2["DOMAINS_DNS_SETEMAILFORWARDING"] = "namecheap.domains.dns.setEmailForwarding";
|
|
60
|
+
Commands2["DOMAINS_DNS_SETHOSTS"] = "namecheap.domains.dns.setHosts";
|
|
61
|
+
Commands2["DOMAINS_NS_CREATE"] = "namecheap.domains.ns.create";
|
|
62
|
+
Commands2["DOMAINS_NS_DELETE"] = "namecheap.domains.ns.delete";
|
|
63
|
+
Commands2["DOMAINS_NS_GETINFO"] = "namecheap.domains.ns.getInfo";
|
|
64
|
+
Commands2["DOMAINS_NS_UPDATE"] = "namecheap.domains.ns.update";
|
|
65
|
+
Commands2["DOMAINS_TRANSFER_CREATE"] = "namecheap.domains.transfer.create";
|
|
66
|
+
Commands2["DOMAINS_TRANSFER_GETSTATUS"] = "namecheap.domains.transfer.getStatus";
|
|
67
|
+
Commands2["DOMAINS_TRANSFER_UPDATESTATUS"] = "namecheap.domains.transfer.updateStatus";
|
|
68
|
+
Commands2["DOMAINS_TRANSFER_GETLIST"] = "namecheap.domains.transfer.getList";
|
|
69
|
+
Commands2["SSL_CREATE"] = "namecheap.ssl.create";
|
|
70
|
+
Commands2["SSL_GETLIST"] = "namecheap.ssl.getList";
|
|
71
|
+
Commands2["SSL_PARSECSR"] = "namecheap.ssl.parseCSR";
|
|
72
|
+
Commands2["SSL_GETAPPROVEREMAILLIST"] = "namecheap.ssl.getApproverEmailList";
|
|
73
|
+
Commands2["SSL_ACTIVATE"] = "namecheap.ssl.activate";
|
|
74
|
+
Commands2["SSL_RESENDAPPROVEREMAIL"] = "namecheap.ssl.resendApproverEmail";
|
|
75
|
+
Commands2["SSL_GETINFO"] = "namecheap.ssl.getInfo";
|
|
76
|
+
Commands2["SSL_RENEW"] = "namecheap.ssl.renew";
|
|
77
|
+
Commands2["SSL_REISSUE"] = "namecheap.ssl.reissue";
|
|
78
|
+
Commands2["SSL_RESENDFULFILLMENTEMAIL"] = "namecheap.ssl.resendfulfillmentemail";
|
|
79
|
+
Commands2["SSL_PURCHASEMORESANS"] = "namecheap.ssl.purchasemoresans";
|
|
80
|
+
Commands2["SSL_REVOKECERTIFICATE"] = "namecheap.ssl.revokecertificate";
|
|
81
|
+
Commands2["SSL_EDITDCVMETHOD"] = "namecheap.ssl.editDCVMethod";
|
|
82
|
+
Commands2["USERS_GETPRICING"] = "namecheap.users.getPricing";
|
|
83
|
+
Commands2["USERS_GETBALANCES"] = "namecheap.users.getBalances";
|
|
84
|
+
Commands2["USERS_CHANGEPASSWORD"] = "namecheap.users.changePassword";
|
|
85
|
+
Commands2["USERS_UPDATE"] = "namecheap.users.update";
|
|
86
|
+
Commands2["USERS_CREATEADDFUNDSREQUEST"] = "namecheap.users.createaddfundsrequest";
|
|
87
|
+
Commands2["USERS_GETADDFUNDSSTATUS"] = "namecheap.users.getAddFundsStatus";
|
|
88
|
+
Commands2["USERS_CREATE"] = "namecheap.users.create";
|
|
89
|
+
Commands2["USERS_LOGIN"] = "namecheap.users.login";
|
|
90
|
+
Commands2["USERS_RESETPASSWORD"] = "namecheap.users.resetPassword";
|
|
91
|
+
Commands2["USERS_ADDRESS_CREATE"] = "namecheap.users.address.create";
|
|
92
|
+
Commands2["USERS_ADDRESS_DELETE"] = "namecheap.users.address.delete";
|
|
93
|
+
Commands2["USERS_ADDRESS_GETINFO"] = "namecheap.users.address.getInfo";
|
|
94
|
+
Commands2["USERS_ADDRESS_GETLIST"] = "namecheap.users.address.getList";
|
|
95
|
+
Commands2["USERS_ADDRESS_SETDEFAULT"] = "namecheap.users.address.setDefault";
|
|
96
|
+
Commands2["USERS_ADDRESS_UPDATE"] = "namecheap.users.address.update";
|
|
97
|
+
Commands2["WHOISGUARD_CHANGEEMAILADDRESS"] = "Namecheap.Whoisguard.changeemailaddress";
|
|
98
|
+
Commands2["WHOISGUARD_ENABLE"] = "Namecheap.Whoisguard.enable";
|
|
99
|
+
Commands2["WHOISGUARD_DISABLE"] = "Namecheap.Whoisguard.disable";
|
|
100
|
+
Commands2["WHOISGUARD_GETLIST"] = "Namecheap.Whoisguard.getList";
|
|
101
|
+
Commands2["WHOISGUARD_RENEW"] = "Namecheap.Whoisguard.renew";
|
|
102
|
+
return Commands2;
|
|
103
|
+
})(Commands || {});
|
|
104
|
+
|
|
105
|
+
// src/types.ts
|
|
106
|
+
var DomainPriceActions = /* @__PURE__ */ ((DomainPriceActions2) => {
|
|
107
|
+
DomainPriceActions2["REGISTER"] = "REGISTER";
|
|
108
|
+
DomainPriceActions2["RENEW"] = "RENEW";
|
|
109
|
+
DomainPriceActions2["REACTIVATE"] = "REACTIVATE";
|
|
110
|
+
DomainPriceActions2["TRANSFER"] = "TRANSFER";
|
|
111
|
+
return DomainPriceActions2;
|
|
112
|
+
})(DomainPriceActions || {});
|
|
113
|
+
|
|
41
114
|
// src/api/api-client.ts
|
|
42
115
|
import axios from "axios";
|
|
43
116
|
import { parseStringPromise } from "xml2js";
|
|
@@ -92,6 +165,14 @@ var APIClient = class {
|
|
|
92
165
|
};
|
|
93
166
|
var api_client_default = APIClient;
|
|
94
167
|
|
|
168
|
+
// src/exceptions/InvalidDomainNameException.ts
|
|
169
|
+
var InvalidDomainNameException = class extends Error {
|
|
170
|
+
constructor(domainName) {
|
|
171
|
+
super(`The provided domain name [${domainName}] is not valid`);
|
|
172
|
+
this.name = "InvalidDomainNameException";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
95
176
|
// src/namecheap.ts
|
|
96
177
|
var Namecheap = class {
|
|
97
178
|
constructor(config, sandbox) {
|
|
@@ -101,7 +182,7 @@ var Namecheap = class {
|
|
|
101
182
|
}
|
|
102
183
|
call(command, payload) {
|
|
103
184
|
return __async(this, null, function* () {
|
|
104
|
-
const params = __spreadProps(__spreadValues(__spreadValues({}, this.config),
|
|
185
|
+
const params = __spreadProps(__spreadValues(__spreadValues({}, payload), this.config), {
|
|
105
186
|
command
|
|
106
187
|
});
|
|
107
188
|
const url = "?" + new URLSearchParams(params).toString();
|
|
@@ -109,9 +190,44 @@ var Namecheap = class {
|
|
|
109
190
|
return { data, status };
|
|
110
191
|
});
|
|
111
192
|
}
|
|
193
|
+
checkDomain(domainName) {
|
|
194
|
+
return __async(this, null, function* () {
|
|
195
|
+
const { data } = yield this.call("namecheap.domains.check" /* DOMAINS_CHECK */, {
|
|
196
|
+
DomainList: domainName
|
|
197
|
+
});
|
|
198
|
+
const isAvailabe = data[0].DomainCheckResult[0].$.Available;
|
|
199
|
+
const isPremium = data[0].DomainCheckResult[0].$.IsPremiumName;
|
|
200
|
+
const response = {
|
|
201
|
+
availabe: isAvailabe === "true",
|
|
202
|
+
premium: isPremium === "true"
|
|
203
|
+
};
|
|
204
|
+
return response;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
getDomainPrice(domainName, action) {
|
|
208
|
+
return __async(this, null, function* () {
|
|
209
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
210
|
+
const [_, tld] = domainName.split(".");
|
|
211
|
+
if (!tld) {
|
|
212
|
+
throw new InvalidDomainNameException(domainName);
|
|
213
|
+
}
|
|
214
|
+
const { data, status } = yield this.call("namecheap.users.getPricing" /* USERS_GETPRICING */, {
|
|
215
|
+
ProductType: "DOMAIN",
|
|
216
|
+
ProductCategory: "DOMAINS",
|
|
217
|
+
ActionName: action,
|
|
218
|
+
ProductName: tld
|
|
219
|
+
});
|
|
220
|
+
const pricing = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = data[0].UserGetPricingResult[0]) == null ? void 0 : _a.ProductType) == null ? void 0 : _b[0]) == null ? void 0 : _c.ProductCategory) == null ? void 0 : _d[0]) == null ? void 0 : _e.Product) == null ? void 0 : _f[0]) == null ? void 0 : _g.Price) == null ? void 0 : _h.map(
|
|
221
|
+
(price) => __spreadValues({}, price.$)
|
|
222
|
+
);
|
|
223
|
+
return { data: pricing, status };
|
|
224
|
+
});
|
|
225
|
+
}
|
|
112
226
|
};
|
|
113
227
|
var namecheap_default = Namecheap;
|
|
114
228
|
export {
|
|
229
|
+
Commands,
|
|
230
|
+
DomainPriceActions,
|
|
115
231
|
namecheap_default as default
|
|
116
232
|
};
|
|
117
233
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/api-client.ts","../src/api/errors.ts","../src/namecheap.ts"],"sourcesContent":["import axios, { AxiosInstance, AxiosResponse } from \"axios\";\r\nimport { parseStringPromise } from \"xml2js\";\r\nimport { ResponseError, XMLParsingError } from \"./errors\";\r\n\r\nclass APIClient {\r\n private readonly _client: AxiosInstance;\r\n constructor(baseURL: string) {\r\n this._client = axios.create({ baseURL });\r\n this._client.interceptors.response.use(this.onResponse);\r\n }\r\n\r\n async get(url: string) {\r\n return await this._client.get(url);\r\n }\r\n\r\n private async onResponse(response: AxiosResponse): Promise<AxiosResponse> {\r\n try {\r\n const result = await parseStringPromise(response.data);\r\n\r\n if (result.ApiResponse.$.Status === \"ERROR\") {\r\n const responseErrors = result.ApiResponse.Errors;\r\n const code = responseErrors[0].Error[0].$.Number;\r\n const message = responseErrors[0].Error[0]._;\r\n\r\n throw new ResponseError(message, code);\r\n }\r\n\r\n response.data = result.ApiResponse.CommandResponse;\r\n } catch (err) {\r\n response.status = 400;\r\n if (err instanceof ResponseError) {\r\n throw err;\r\n }\r\n\r\n throw new XMLParsingError();\r\n }\r\n\r\n return response;\r\n }\r\n}\r\n\r\nexport default APIClient;\r\n","export class XMLParsingError extends Error {\r\n constructor() {\r\n super(\"Invalid XML response\");\r\n\r\n this.name = \"XMLParsingError\";\r\n }\r\n}\r\n\r\nexport class ResponseError extends Error {\r\n constructor(message: string, readonly code?: number) {\r\n super((code ? `${code}: ` : \"\") + message);\r\n\r\n this.name = \"ResponseError\";\r\n }\r\n}\r\n","import APIClient from \"./api\";\r\nimport { ICommand } from \"./commands\";\r\n\r\nexport interface INamecheapConfig {\r\n ApiUser: string;\r\n ApiKey: string;\r\n UserName: string;\r\n ClientIp: string;\r\n}\r\n\r\nexport interface ICallReponse {\r\n data: any;\r\n status: number;\r\n}\r\n\r\nclass Namecheap {\r\n private readonly apiClient: APIClient;\r\n constructor(private readonly config: INamecheapConfig, sandbox?: boolean) {\r\n const baseURL = `https://api${\r\n sandbox ? \".sandbox\" : \"\"\r\n }.namecheap.com/xml.response`;\r\n this.apiClient = new APIClient(baseURL);\r\n }\r\n\r\n async call(\r\n command: ICommand,\r\n payload: Record<string, string>\r\n ): Promise<ICallReponse> {\r\n const params = {\r\n ...this.config,\r\n ...payload,\r\n command,\r\n };\r\n\r\n const url = \"?\" + new URLSearchParams(params).toString();\r\n\r\n const { data, status } = await this.apiClient.get(url);\r\n\r\n return { data, status };\r\n }\r\n}\r\n\r\nexport default Namecheap;\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAA6C;AACpD,SAAS,0BAA0B;;;ACD5B,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,cAAc;AACZ,UAAM,sBAAsB;AAE5B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACvC,YAAY,SAA0B,MAAe;AACnD,WAAO,OAAO,GAAG,IAAI,OAAO,MAAM,OAAO;AADL;AAGpC,SAAK,OAAO;AAAA,EACd;AACF;;;ADVA,IAAM,YAAN,MAAgB;AAAA,EAEd,YAAY,SAAiB;AAC3B,SAAK,UAAU,MAAM,OAAO,EAAE,QAAQ,CAAC;AACvC,SAAK,QAAQ,aAAa,SAAS,IAAI,KAAK,UAAU;AAAA,EACxD;AAAA,EAEM,IAAI,KAAa;AAAA;AACrB,aAAO,MAAM,KAAK,QAAQ,IAAI,GAAG;AAAA,IACnC;AAAA;AAAA,EAEc,WAAW,UAAiD;AAAA;AACxE,UAAI;AACF,cAAM,SAAS,MAAM,mBAAmB,SAAS,IAAI;AAErD,YAAI,OAAO,YAAY,EAAE,WAAW,SAAS;AAC3C,gBAAM,iBAAiB,OAAO,YAAY;AAC1C,gBAAM,OAAO,eAAe,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE;AAC1C,gBAAM,UAAU,eAAe,CAAC,EAAE,MAAM,CAAC,EAAE;AAE3C,gBAAM,IAAI,cAAc,SAAS,IAAI;AAAA,QACvC;AAEA,iBAAS,OAAO,OAAO,YAAY;AAAA,MACrC,SAAS,KAAK;AACZ,iBAAS,SAAS;AAClB,YAAI,eAAe,eAAe;AAChC,gBAAM;AAAA,QACR;AAEA,cAAM,IAAI,gBAAgB;AAAA,MAC5B;AAEA,aAAO;AAAA,IACT;AAAA;AACF;AAEA,IAAO,qBAAQ;;;AE1Bf,IAAM,YAAN,MAAgB;AAAA,EAEd,YAA6B,QAA0B,SAAmB;AAA7C;AAC3B,UAAM,UAAU,cACd,UAAU,aAAa,EACzB;AACA,SAAK,YAAY,IAAI,mBAAU,OAAO;AAAA,EACxC;AAAA,EAEM,KACJ,SACA,SACuB;AAAA;AACvB,YAAM,SAAS,gDACV,KAAK,SACL,UAFU;AAAA,QAGb;AAAA,MACF;AAEA,YAAM,MAAM,MAAM,IAAI,gBAAgB,MAAM,EAAE,SAAS;AAEvD,YAAM,EAAE,MAAM,OAAO,IAAI,MAAM,KAAK,UAAU,IAAI,GAAG;AAErD,aAAO,EAAE,MAAM,OAAO;AAAA,IACxB;AAAA;AACF;AAEA,IAAO,oBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/commands.ts","../src/types.ts","../src/api/api-client.ts","../src/api/errors.ts","../src/exceptions/InvalidDomainNameException.ts","../src/namecheap.ts"],"sourcesContent":["export enum Commands {\r\n // domains\r\n DOMAINS_GETLIST = \"namecheap.domains.getList\",\r\n DOMAINS_GETCONTACTS = \"namecheap.domains.getContacts\",\r\n DOMAINS_CREATE = \"namecheap.domains.create\",\r\n DOMAINS_GETTLDLIST = \"namecheap.domains.getTldList\",\r\n DOMAINS_SETCONTACTS = \"namecheap.domains.setContacts\",\r\n DOMAINS_CHECK = \"namecheap.domains.check\",\r\n DOMAINS_REACTIVATE = \"namecheap.domains.reactivate\",\r\n DOMAINS_RENEW = \"namecheap.domains.renew\",\r\n DOMAINS_GETREGISTRARLOCK = \"namecheap.domains.getRegistrarLock\",\r\n DOMAINS_SETREGISTRARLOCK = \"namecheap.domains.setRegistrarLock\",\r\n DOMAINS_GETINFO = \"namecheap.domains.getInfo\",\r\n\r\n // domains.dns\r\n DOMAINS_DNS_SETDEFAULT = \"namecheap.domains.dns.setDefault\",\r\n DOMAINS_DNS_SETCUSTOM = \"namecheap.domains.dns.setCustom\",\r\n DOMAINS_DNS_GETLIST = \"namecheap.domains.dns.getList\",\r\n DOMAINS_DNS_GETHOSTS = \"namecheap.domains.dns.getHosts\",\r\n DOMAINS_DNS_GETEMAILFORWARDING = \"namecheap.domains.dns.getEmailForwarding\",\r\n DOMAINS_DNS_SETEMAILFORWARDING = \"namecheap.domains.dns.setEmailForwarding\",\r\n DOMAINS_DNS_SETHOSTS = \"namecheap.domains.dns.setHosts\",\r\n\r\n // domains.ns\r\n DOMAINS_NS_CREATE = \"namecheap.domains.ns.create\",\r\n DOMAINS_NS_DELETE = \"namecheap.domains.ns.delete\",\r\n DOMAINS_NS_GETINFO = \"namecheap.domains.ns.getInfo\",\r\n DOMAINS_NS_UPDATE = \"namecheap.domains.ns.update\",\r\n\r\n // domains.transfer\r\n DOMAINS_TRANSFER_CREATE = \"namecheap.domains.transfer.create\",\r\n DOMAINS_TRANSFER_GETSTATUS = \"namecheap.domains.transfer.getStatus\",\r\n DOMAINS_TRANSFER_UPDATESTATUS = \"namecheap.domains.transfer.updateStatus\",\r\n DOMAINS_TRANSFER_GETLIST = \"namecheap.domains.transfer.getList\",\r\n\r\n // ssl\r\n SSL_CREATE = \"namecheap.ssl.create\",\r\n SSL_GETLIST = \"namecheap.ssl.getList\",\r\n SSL_PARSECSR = \"namecheap.ssl.parseCSR\",\r\n SSL_GETAPPROVEREMAILLIST = \"namecheap.ssl.getApproverEmailList\",\r\n SSL_ACTIVATE = \"namecheap.ssl.activate\",\r\n SSL_RESENDAPPROVEREMAIL = \"namecheap.ssl.resendApproverEmail\",\r\n SSL_GETINFO = \"namecheap.ssl.getInfo\",\r\n SSL_RENEW = \"namecheap.ssl.renew\",\r\n SSL_REISSUE = \"namecheap.ssl.reissue\",\r\n SSL_RESENDFULFILLMENTEMAIL = \"namecheap.ssl.resendfulfillmentemail\",\r\n SSL_PURCHASEMORESANS = \"namecheap.ssl.purchasemoresans\",\r\n SSL_REVOKECERTIFICATE = \"namecheap.ssl.revokecertificate\",\r\n SSL_EDITDCVMETHOD = \"namecheap.ssl.editDCVMethod\",\r\n\r\n // users\r\n USERS_GETPRICING = \"namecheap.users.getPricing\",\r\n USERS_GETBALANCES = \"namecheap.users.getBalances\",\r\n USERS_CHANGEPASSWORD = \"namecheap.users.changePassword\",\r\n USERS_UPDATE = \"namecheap.users.update\",\r\n USERS_CREATEADDFUNDSREQUEST = \"namecheap.users.createaddfundsrequest\",\r\n USERS_GETADDFUNDSSTATUS = \"namecheap.users.getAddFundsStatus\",\r\n USERS_CREATE = \"namecheap.users.create\",\r\n USERS_LOGIN = \"namecheap.users.login\",\r\n USERS_RESETPASSWORD = \"namecheap.users.resetPassword\",\r\n\r\n // users.address\r\n USERS_ADDRESS_CREATE = \"namecheap.users.address.create\",\r\n USERS_ADDRESS_DELETE = \"namecheap.users.address.delete\",\r\n USERS_ADDRESS_GETINFO = \"namecheap.users.address.getInfo\",\r\n USERS_ADDRESS_GETLIST = \"namecheap.users.address.getList\",\r\n USERS_ADDRESS_SETDEFAULT = \"namecheap.users.address.setDefault\",\r\n USERS_ADDRESS_UPDATE = \"namecheap.users.address.update\",\r\n\r\n // domainprivacy\r\n WHOISGUARD_CHANGEEMAILADDRESS = \"Namecheap.Whoisguard.changeemailaddress\",\r\n WHOISGUARD_ENABLE = \"Namecheap.Whoisguard.enable\",\r\n WHOISGUARD_DISABLE = \"Namecheap.Whoisguard.disable\",\r\n WHOISGUARD_GETLIST = \"Namecheap.Whoisguard.getList\",\r\n WHOISGUARD_RENEW = \"Namecheap.Whoisguard.renew\",\r\n}\r\n\r\nexport type Command = `${Commands}`;\r\n","export enum DomainPriceActions {\r\n REGISTER = \"REGISTER\",\r\n RENEW = \"RENEW\",\r\n REACTIVATE = \"REACTIVATE\",\r\n TRANSFER = \"TRANSFER\",\r\n}\r\n\r\nexport type DomainPriceAction = `${DomainPriceActions}`;\r\n","import axios, { AxiosInstance, AxiosResponse } from \"axios\";\r\nimport { parseStringPromise } from \"xml2js\";\r\nimport { ResponseError, XMLParsingError } from \"./errors\";\r\n\r\nclass APIClient {\r\n private readonly _client: AxiosInstance;\r\n constructor(baseURL: string) {\r\n this._client = axios.create({ baseURL });\r\n this._client.interceptors.response.use(this.onResponse);\r\n }\r\n\r\n async get(url: string) {\r\n return await this._client.get(url);\r\n }\r\n\r\n private async onResponse(response: AxiosResponse): Promise<AxiosResponse> {\r\n try {\r\n const result = await parseStringPromise(response.data);\r\n\r\n if (result.ApiResponse.$.Status === \"ERROR\") {\r\n const responseErrors = result.ApiResponse.Errors;\r\n const code = responseErrors[0].Error[0].$.Number;\r\n const message = responseErrors[0].Error[0]._;\r\n\r\n throw new ResponseError(message, code);\r\n }\r\n\r\n response.data = result.ApiResponse.CommandResponse;\r\n } catch (err) {\r\n response.status = 400;\r\n if (err instanceof ResponseError) {\r\n throw err;\r\n }\r\n\r\n throw new XMLParsingError();\r\n }\r\n\r\n return response;\r\n }\r\n}\r\n\r\nexport default APIClient;\r\n","export class XMLParsingError extends Error {\r\n constructor() {\r\n super(\"Invalid XML response\");\r\n\r\n this.name = \"XMLParsingError\";\r\n }\r\n}\r\n\r\nexport class ResponseError extends Error {\r\n constructor(message: string, readonly code?: number) {\r\n super((code ? `${code}: ` : \"\") + message);\r\n\r\n this.name = \"ResponseError\";\r\n }\r\n}\r\n","export class InvalidDomainNameException extends Error {\r\n constructor(domainName: string) {\r\n super(`The provided domain name [${domainName}] is not valid`);\r\n\r\n this.name = \"InvalidDomainNameException\";\r\n }\r\n}\r\n","import APIClient from \"./api\";\r\nimport { Commands, Command } from \"./commands\";\r\nimport { InvalidDomainNameException } from \"./exceptions\";\r\nimport { DomainPriceAction } from \"./types\";\r\n\r\nexport interface INamecheapConfig {\r\n ApiUser: string;\r\n ApiKey: string;\r\n UserName: string;\r\n ClientIp: string;\r\n}\r\n\r\nexport interface IReponse {\r\n data: any;\r\n status: number;\r\n}\r\n\r\nexport interface ICheckDomainResponse {\r\n availabe: boolean;\r\n premium: boolean;\r\n}\r\n\r\nclass Namecheap {\r\n private readonly apiClient: APIClient;\r\n constructor(private readonly config: INamecheapConfig, sandbox?: boolean) {\r\n const baseURL = `https://api${\r\n sandbox ? \".sandbox\" : \"\"\r\n }.namecheap.com/xml.response`;\r\n this.apiClient = new APIClient(baseURL);\r\n }\r\n\r\n async call(\r\n command: Command,\r\n payload: Record<string, string>\r\n ): Promise<IReponse> {\r\n const params = {\r\n ...payload,\r\n ...this.config,\r\n command,\r\n };\r\n\r\n const url = \"?\" + new URLSearchParams(params).toString();\r\n\r\n const { data, status } = await this.apiClient.get(url);\r\n\r\n return { data, status };\r\n }\r\n\r\n async checkDomain(domainName: string): Promise<ICheckDomainResponse> {\r\n const { data } = await this.call(Commands.DOMAINS_CHECK, {\r\n DomainList: domainName,\r\n });\r\n\r\n const isAvailabe: string = data[0].DomainCheckResult[0].$.Available;\r\n const isPremium: string = data[0].DomainCheckResult[0].$.IsPremiumName;\r\n\r\n const response: ICheckDomainResponse = {\r\n availabe: isAvailabe === \"true\",\r\n premium: isPremium === \"true\",\r\n };\r\n\r\n return response;\r\n }\r\n\r\n async getDomainPrice(\r\n domainName: string,\r\n action: DomainPriceAction\r\n ): Promise<IReponse> {\r\n const [_, tld] = domainName.split(\".\");\r\n if (!tld) {\r\n throw new InvalidDomainNameException(domainName);\r\n }\r\n\r\n const { data, status } = await this.call(Commands.USERS_GETPRICING, {\r\n ProductType: \"DOMAIN\",\r\n ProductCategory: \"DOMAINS\",\r\n ActionName: action,\r\n ProductName: tld,\r\n });\r\n\r\n const pricing =\r\n data[0].UserGetPricingResult[0]?.ProductType?.[0]?.ProductCategory?.[0]?.Product?.[0]?.Price?.map(\r\n (price: any) => ({ ...price.$ })\r\n );\r\n\r\n return { data: pricing, status };\r\n }\r\n}\r\n\r\nexport default Namecheap;\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAK,WAAL,kBAAKA,cAAL;AAEL,EAAAA,UAAA,qBAAkB;AAClB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,oBAAiB;AACjB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,mBAAgB;AAChB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,mBAAgB;AAChB,EAAAA,UAAA,8BAA2B;AAC3B,EAAAA,UAAA,8BAA2B;AAC3B,EAAAA,UAAA,qBAAkB;AAGlB,EAAAA,UAAA,4BAAyB;AACzB,EAAAA,UAAA,2BAAwB;AACxB,EAAAA,UAAA,yBAAsB;AACtB,EAAAA,UAAA,0BAAuB;AACvB,EAAAA,UAAA,oCAAiC;AACjC,EAAAA,UAAA,oCAAiC;AACjC,EAAAA,UAAA,0BAAuB;AAGvB,EAAAA,UAAA,uBAAoB;AACpB,EAAAA,UAAA,uBAAoB;AACpB,EAAAA,UAAA,wBAAqB;AACrB,EAAAA,UAAA,uBAAoB;AAGpB,EAAAA,UAAA,6BAA0B;AAC1B,EAAAA,UAAA,gCAA6B;AAC7B,EAAAA,UAAA,mCAAgC;AAChC,EAAAA,UAAA,8BAA2B;AAG3B,EAAAA,UAAA,gBAAa;AACb,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,kBAAe;AACf,EAAAA,UAAA,8BAA2B;AAC3B,EAAAA,UAAA,kBAAe;AACf,EAAAA,UAAA,6BAA0B;AAC1B,EAAAA,UAAA,iBAAc;AACd,EAAAA,UAAA,eAA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"description": "A simple wrapper for namecheap API",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"start": "tsc --build && node dist/index.js",
|
|
13
13
|
"build": "tsup",
|
|
14
|
+
"release": "rm -rf dist && tsup && npm publish",
|
|
14
15
|
"test": "jest"
|
|
15
16
|
},
|
|
16
17
|
"keywords": [
|
package/dist/api/api-client.d.ts
DELETED
package/dist/api/api-client.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
|
16
|
-
const xml2js_1 = require("xml2js");
|
|
17
|
-
const errors_1 = require("./errors");
|
|
18
|
-
class APIClient {
|
|
19
|
-
constructor(baseURL) {
|
|
20
|
-
this._client = axios_1.default.create({ baseURL });
|
|
21
|
-
this._client.interceptors.response.use(this.onResponse);
|
|
22
|
-
}
|
|
23
|
-
get(url) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return yield this._client.get(url);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
onResponse(response) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
try {
|
|
31
|
-
const result = yield (0, xml2js_1.parseStringPromise)(response.data);
|
|
32
|
-
if (result.ApiResponse.$.Status === "ERROR") {
|
|
33
|
-
const responseErrors = result.ApiResponse.Errors;
|
|
34
|
-
const code = responseErrors[0].Error[0].$.Number;
|
|
35
|
-
const message = responseErrors[0].Error[0]._;
|
|
36
|
-
throw new errors_1.ResponseError(message, code);
|
|
37
|
-
}
|
|
38
|
-
response.data = result.ApiResponse.CommandResponse;
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
response.status = 400;
|
|
42
|
-
if (err instanceof errors_1.ResponseError) {
|
|
43
|
-
throw err;
|
|
44
|
-
}
|
|
45
|
-
throw new errors_1.XMLParsingError();
|
|
46
|
-
}
|
|
47
|
-
return response;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.default = APIClient;
|
package/dist/api/errors.d.ts
DELETED
package/dist/api/errors.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResponseError = exports.XMLParsingError = void 0;
|
|
4
|
-
class XMLParsingError extends Error {
|
|
5
|
-
constructor() {
|
|
6
|
-
super("Invalid XML response");
|
|
7
|
-
this.name = "XMLParsingError";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.XMLParsingError = XMLParsingError;
|
|
11
|
-
class ResponseError extends Error {
|
|
12
|
-
constructor(message, code) {
|
|
13
|
-
super((code ? `${code}: ` : "") + message);
|
|
14
|
-
this.code = code;
|
|
15
|
-
this.name = "ResponseError";
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ResponseError = ResponseError;
|
package/dist/api/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./api-client";
|
package/dist/api/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var api_client_1 = require("./api-client");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(api_client_1).default; } });
|
package/dist/commands.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export declare enum Commands {
|
|
2
|
-
DOMAINS_GETLIST = "namecheap.domains.getList",
|
|
3
|
-
DOMAINS_GETCONTACTS = "namecheap.domains.getContacts",
|
|
4
|
-
DOMAINS_CREATE = "namecheap.domains.create",
|
|
5
|
-
DOMAINS_GETTLDLIST = "namecheap.domains.getTldList",
|
|
6
|
-
DOMAINS_SETCONTACTS = "namecheap.domains.setContacts",
|
|
7
|
-
DOMAINS_CHECK = "namecheap.domains.check",
|
|
8
|
-
DOMAINS_REACTIVATE = "namecheap.domains.reactivate",
|
|
9
|
-
DOMAINS_RENEW = "namecheap.domains.renew",
|
|
10
|
-
DOMAINS_GETREGISTRARLOCK = "namecheap.domains.getRegistrarLock",
|
|
11
|
-
DOMAINS_SETREGISTRARLOCK = "namecheap.domains.setRegistrarLock",
|
|
12
|
-
DOMAINS_GETINFO = "namecheap.domains.getInfo",
|
|
13
|
-
DOMAINS_DNS_SETDEFAULT = "namecheap.domains.dns.setDefault",
|
|
14
|
-
DOMAINS_DNS_SETCUSTOM = "namecheap.domains.dns.setCustom",
|
|
15
|
-
DOMAINS_DNS_GETLIST = "namecheap.domains.dns.getList",
|
|
16
|
-
DOMAINS_DNS_GETHOSTS = "namecheap.domains.dns.getHosts",
|
|
17
|
-
DOMAINS_DNS_GETEMAILFORWARDING = "namecheap.domains.dns.getEmailForwarding",
|
|
18
|
-
DOMAINS_DNS_SETEMAILFORWARDING = "namecheap.domains.dns.setEmailForwarding",
|
|
19
|
-
DOMAINS_DNS_SETHOSTS = "namecheap.domains.dns.setHosts",
|
|
20
|
-
DOMAINS_NS_CREATE = "namecheap.domains.ns.create",
|
|
21
|
-
DOMAINS_NS_DELETE = "namecheap.domains.ns.delete",
|
|
22
|
-
DOMAINS_NS_GETINFO = "namecheap.domains.ns.getInfo",
|
|
23
|
-
DOMAINS_NS_UPDATE = "namecheap.domains.ns.update",
|
|
24
|
-
DOMAINS_TRANSFER_CREATE = "namecheap.domains.transfer.create",
|
|
25
|
-
DOMAINS_TRANSFER_GETSTATUS = "namecheap.domains.transfer.getStatus",
|
|
26
|
-
DOMAINS_TRANSFER_UPDATESTATUS = "namecheap.domains.transfer.updateStatus",
|
|
27
|
-
DOMAINS_TRANSFER_GETLIST = "namecheap.domains.transfer.getList",
|
|
28
|
-
SSL_CREATE = "namecheap.ssl.create",
|
|
29
|
-
SSL_GETLIST = "namecheap.ssl.getList",
|
|
30
|
-
SSL_PARSECSR = "namecheap.ssl.parseCSR",
|
|
31
|
-
SSL_GETAPPROVEREMAILLIST = "namecheap.ssl.getApproverEmailList",
|
|
32
|
-
SSL_ACTIVATE = "namecheap.ssl.activate",
|
|
33
|
-
SSL_RESENDAPPROVEREMAIL = "namecheap.ssl.resendApproverEmail",
|
|
34
|
-
SSL_GETINFO = "namecheap.ssl.getInfo",
|
|
35
|
-
SSL_RENEW = "namecheap.ssl.renew",
|
|
36
|
-
SSL_REISSUE = "namecheap.ssl.reissue",
|
|
37
|
-
SSL_RESENDFULFILLMENTEMAIL = "namecheap.ssl.resendfulfillmentemail",
|
|
38
|
-
SSL_PURCHASEMORESANS = "namecheap.ssl.purchasemoresans",
|
|
39
|
-
SSL_REVOKECERTIFICATE = "namecheap.ssl.revokecertificate",
|
|
40
|
-
SSL_EDITDCVMETHOD = "namecheap.ssl.editDCVMethod",
|
|
41
|
-
USERS_GETPRICING = "namecheap.users.getPricing",
|
|
42
|
-
USERS_GETBALANCES = "namecheap.users.getBalances",
|
|
43
|
-
USERS_CHANGEPASSWORD = "namecheap.users.changePassword",
|
|
44
|
-
USERS_UPDATE = "namecheap.users.update",
|
|
45
|
-
USERS_CREATEADDFUNDSREQUEST = "namecheap.users.createaddfundsrequest",
|
|
46
|
-
USERS_GETADDFUNDSSTATUS = "namecheap.users.getAddFundsStatus",
|
|
47
|
-
USERS_CREATE = "namecheap.users.create",
|
|
48
|
-
USERS_LOGIN = "namecheap.users.login",
|
|
49
|
-
USERS_RESETPASSWORD = "namecheap.users.resetPassword",
|
|
50
|
-
USERS_ADDRESS_CREATE = "namecheap.users.address.create",
|
|
51
|
-
USERS_ADDRESS_DELETE = "namecheap.users.address.delete",
|
|
52
|
-
USERS_ADDRESS_GETINFO = "namecheap.users.address.getInfo",
|
|
53
|
-
USERS_ADDRESS_GETLIST = "namecheap.users.address.getList",
|
|
54
|
-
USERS_ADDRESS_SETDEFAULT = "namecheap.users.address.setDefault",
|
|
55
|
-
USERS_ADDRESS_UPDATE = "namecheap.users.address.update",
|
|
56
|
-
WHOISGUARD_CHANGEEMAILADDRESS = "Namecheap.Whoisguard.changeemailaddress",
|
|
57
|
-
WHOISGUARD_ENABLE = "Namecheap.Whoisguard.enable",
|
|
58
|
-
WHOISGUARD_DISABLE = "Namecheap.Whoisguard.disable",
|
|
59
|
-
WHOISGUARD_GETLIST = "Namecheap.Whoisguard.getList",
|
|
60
|
-
WHOISGUARD_RENEW = "Namecheap.Whoisguard.renew"
|
|
61
|
-
}
|
|
62
|
-
export type Command = `${Commands}`;
|
package/dist/commands.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Commands = void 0;
|
|
4
|
-
var Commands;
|
|
5
|
-
(function (Commands) {
|
|
6
|
-
// domains
|
|
7
|
-
Commands["DOMAINS_GETLIST"] = "namecheap.domains.getList";
|
|
8
|
-
Commands["DOMAINS_GETCONTACTS"] = "namecheap.domains.getContacts";
|
|
9
|
-
Commands["DOMAINS_CREATE"] = "namecheap.domains.create";
|
|
10
|
-
Commands["DOMAINS_GETTLDLIST"] = "namecheap.domains.getTldList";
|
|
11
|
-
Commands["DOMAINS_SETCONTACTS"] = "namecheap.domains.setContacts";
|
|
12
|
-
Commands["DOMAINS_CHECK"] = "namecheap.domains.check";
|
|
13
|
-
Commands["DOMAINS_REACTIVATE"] = "namecheap.domains.reactivate";
|
|
14
|
-
Commands["DOMAINS_RENEW"] = "namecheap.domains.renew";
|
|
15
|
-
Commands["DOMAINS_GETREGISTRARLOCK"] = "namecheap.domains.getRegistrarLock";
|
|
16
|
-
Commands["DOMAINS_SETREGISTRARLOCK"] = "namecheap.domains.setRegistrarLock";
|
|
17
|
-
Commands["DOMAINS_GETINFO"] = "namecheap.domains.getInfo";
|
|
18
|
-
// domains.dns
|
|
19
|
-
Commands["DOMAINS_DNS_SETDEFAULT"] = "namecheap.domains.dns.setDefault";
|
|
20
|
-
Commands["DOMAINS_DNS_SETCUSTOM"] = "namecheap.domains.dns.setCustom";
|
|
21
|
-
Commands["DOMAINS_DNS_GETLIST"] = "namecheap.domains.dns.getList";
|
|
22
|
-
Commands["DOMAINS_DNS_GETHOSTS"] = "namecheap.domains.dns.getHosts";
|
|
23
|
-
Commands["DOMAINS_DNS_GETEMAILFORWARDING"] = "namecheap.domains.dns.getEmailForwarding";
|
|
24
|
-
Commands["DOMAINS_DNS_SETEMAILFORWARDING"] = "namecheap.domains.dns.setEmailForwarding";
|
|
25
|
-
Commands["DOMAINS_DNS_SETHOSTS"] = "namecheap.domains.dns.setHosts";
|
|
26
|
-
// domains.ns
|
|
27
|
-
Commands["DOMAINS_NS_CREATE"] = "namecheap.domains.ns.create";
|
|
28
|
-
Commands["DOMAINS_NS_DELETE"] = "namecheap.domains.ns.delete";
|
|
29
|
-
Commands["DOMAINS_NS_GETINFO"] = "namecheap.domains.ns.getInfo";
|
|
30
|
-
Commands["DOMAINS_NS_UPDATE"] = "namecheap.domains.ns.update";
|
|
31
|
-
// domains.transfer
|
|
32
|
-
Commands["DOMAINS_TRANSFER_CREATE"] = "namecheap.domains.transfer.create";
|
|
33
|
-
Commands["DOMAINS_TRANSFER_GETSTATUS"] = "namecheap.domains.transfer.getStatus";
|
|
34
|
-
Commands["DOMAINS_TRANSFER_UPDATESTATUS"] = "namecheap.domains.transfer.updateStatus";
|
|
35
|
-
Commands["DOMAINS_TRANSFER_GETLIST"] = "namecheap.domains.transfer.getList";
|
|
36
|
-
// ssl
|
|
37
|
-
Commands["SSL_CREATE"] = "namecheap.ssl.create";
|
|
38
|
-
Commands["SSL_GETLIST"] = "namecheap.ssl.getList";
|
|
39
|
-
Commands["SSL_PARSECSR"] = "namecheap.ssl.parseCSR";
|
|
40
|
-
Commands["SSL_GETAPPROVEREMAILLIST"] = "namecheap.ssl.getApproverEmailList";
|
|
41
|
-
Commands["SSL_ACTIVATE"] = "namecheap.ssl.activate";
|
|
42
|
-
Commands["SSL_RESENDAPPROVEREMAIL"] = "namecheap.ssl.resendApproverEmail";
|
|
43
|
-
Commands["SSL_GETINFO"] = "namecheap.ssl.getInfo";
|
|
44
|
-
Commands["SSL_RENEW"] = "namecheap.ssl.renew";
|
|
45
|
-
Commands["SSL_REISSUE"] = "namecheap.ssl.reissue";
|
|
46
|
-
Commands["SSL_RESENDFULFILLMENTEMAIL"] = "namecheap.ssl.resendfulfillmentemail";
|
|
47
|
-
Commands["SSL_PURCHASEMORESANS"] = "namecheap.ssl.purchasemoresans";
|
|
48
|
-
Commands["SSL_REVOKECERTIFICATE"] = "namecheap.ssl.revokecertificate";
|
|
49
|
-
Commands["SSL_EDITDCVMETHOD"] = "namecheap.ssl.editDCVMethod";
|
|
50
|
-
// users
|
|
51
|
-
Commands["USERS_GETPRICING"] = "namecheap.users.getPricing";
|
|
52
|
-
Commands["USERS_GETBALANCES"] = "namecheap.users.getBalances";
|
|
53
|
-
Commands["USERS_CHANGEPASSWORD"] = "namecheap.users.changePassword";
|
|
54
|
-
Commands["USERS_UPDATE"] = "namecheap.users.update";
|
|
55
|
-
Commands["USERS_CREATEADDFUNDSREQUEST"] = "namecheap.users.createaddfundsrequest";
|
|
56
|
-
Commands["USERS_GETADDFUNDSSTATUS"] = "namecheap.users.getAddFundsStatus";
|
|
57
|
-
Commands["USERS_CREATE"] = "namecheap.users.create";
|
|
58
|
-
Commands["USERS_LOGIN"] = "namecheap.users.login";
|
|
59
|
-
Commands["USERS_RESETPASSWORD"] = "namecheap.users.resetPassword";
|
|
60
|
-
// users.address
|
|
61
|
-
Commands["USERS_ADDRESS_CREATE"] = "namecheap.users.address.create";
|
|
62
|
-
Commands["USERS_ADDRESS_DELETE"] = "namecheap.users.address.delete";
|
|
63
|
-
Commands["USERS_ADDRESS_GETINFO"] = "namecheap.users.address.getInfo";
|
|
64
|
-
Commands["USERS_ADDRESS_GETLIST"] = "namecheap.users.address.getList";
|
|
65
|
-
Commands["USERS_ADDRESS_SETDEFAULT"] = "namecheap.users.address.setDefault";
|
|
66
|
-
Commands["USERS_ADDRESS_UPDATE"] = "namecheap.users.address.update";
|
|
67
|
-
// domainprivacy
|
|
68
|
-
Commands["WHOISGUARD_CHANGEEMAILADDRESS"] = "Namecheap.Whoisguard.changeemailaddress";
|
|
69
|
-
Commands["WHOISGUARD_ENABLE"] = "Namecheap.Whoisguard.enable";
|
|
70
|
-
Commands["WHOISGUARD_DISABLE"] = "Namecheap.Whoisguard.disable";
|
|
71
|
-
Commands["WHOISGUARD_GETLIST"] = "Namecheap.Whoisguard.getList";
|
|
72
|
-
Commands["WHOISGUARD_RENEW"] = "Namecheap.Whoisguard.renew";
|
|
73
|
-
})(Commands || (exports.Commands = Commands = {}));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidDomainNameException = void 0;
|
|
4
|
-
class InvalidDomainNameException extends Error {
|
|
5
|
-
constructor(domainName) {
|
|
6
|
-
super(`The provided domain name [${domainName}] is not valid`);
|
|
7
|
-
this.name = "InvalidDomainNameException";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.InvalidDomainNameException = InvalidDomainNameException;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidTLDException = void 0;
|
|
4
|
-
class InvalidTLDException extends Error {
|
|
5
|
-
constructor(tld) {
|
|
6
|
-
super(`The provided tld [${tld}] is not valid`);
|
|
7
|
-
this.name = "InvalidTLDException";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.InvalidTLDException = InvalidTLDException;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./InvalidDomainNameException";
|
package/dist/exceptions/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./InvalidDomainNameException"), exports);
|
package/dist/namecheap.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Command } from "./commands";
|
|
2
|
-
import { DomainPriceAction } from "./types";
|
|
3
|
-
export interface INamecheapConfig {
|
|
4
|
-
ApiUser: string;
|
|
5
|
-
ApiKey: string;
|
|
6
|
-
UserName: string;
|
|
7
|
-
ClientIp: string;
|
|
8
|
-
}
|
|
9
|
-
export interface IReponse {
|
|
10
|
-
data: any;
|
|
11
|
-
status: number;
|
|
12
|
-
}
|
|
13
|
-
export interface ICheckDomainResponse {
|
|
14
|
-
availabe: boolean;
|
|
15
|
-
premium: boolean;
|
|
16
|
-
}
|
|
17
|
-
declare class Namecheap {
|
|
18
|
-
private readonly config;
|
|
19
|
-
private readonly apiClient;
|
|
20
|
-
constructor(config: INamecheapConfig, sandbox?: boolean);
|
|
21
|
-
call(command: Command, payload: Record<string, string>): Promise<IReponse>;
|
|
22
|
-
checkDomain(domainName: string): Promise<ICheckDomainResponse>;
|
|
23
|
-
getDomainPrice(domainName: string, action: DomainPriceAction): Promise<IReponse>;
|
|
24
|
-
}
|
|
25
|
-
export default Namecheap;
|
package/dist/namecheap.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const api_1 = __importDefault(require("./api"));
|
|
16
|
-
const commands_1 = require("./commands");
|
|
17
|
-
const exceptions_1 = require("./exceptions");
|
|
18
|
-
class Namecheap {
|
|
19
|
-
constructor(config, sandbox) {
|
|
20
|
-
this.config = config;
|
|
21
|
-
const baseURL = `https://api${sandbox ? ".sandbox" : ""}.namecheap.com/xml.response`;
|
|
22
|
-
this.apiClient = new api_1.default(baseURL);
|
|
23
|
-
}
|
|
24
|
-
call(command, payload) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const params = Object.assign(Object.assign(Object.assign({}, payload), this.config), { command });
|
|
27
|
-
const url = "?" + new URLSearchParams(params).toString();
|
|
28
|
-
const { data, status } = yield this.apiClient.get(url);
|
|
29
|
-
return { data, status };
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
checkDomain(domainName) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const { data } = yield this.call(commands_1.Commands.DOMAINS_CHECK, {
|
|
35
|
-
DomainList: domainName,
|
|
36
|
-
});
|
|
37
|
-
const isAvailabe = data[0].DomainCheckResult[0].$.Available;
|
|
38
|
-
const isPremium = data[0].DomainCheckResult[0].$.IsPremiumName;
|
|
39
|
-
const response = {
|
|
40
|
-
availabe: isAvailabe === "true",
|
|
41
|
-
premium: isPremium === "true",
|
|
42
|
-
};
|
|
43
|
-
return response;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
getDomainPrice(domainName, action) {
|
|
47
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const [_, tld] = domainName.split(".");
|
|
50
|
-
if (!tld) {
|
|
51
|
-
throw new exceptions_1.InvalidDomainNameException(domainName);
|
|
52
|
-
}
|
|
53
|
-
const { data, status } = yield this.call(commands_1.Commands.USERS_GETPRICING, {
|
|
54
|
-
ProductType: "DOMAIN",
|
|
55
|
-
ProductCategory: "DOMAINS",
|
|
56
|
-
ActionName: action,
|
|
57
|
-
ProductName: tld,
|
|
58
|
-
});
|
|
59
|
-
const pricing = (_h = (_g = (_f = (_e = (_d = (_c = (_b = (_a = data[0].UserGetPricingResult[0]) === null || _a === void 0 ? void 0 : _a.ProductType) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.ProductCategory) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.Product) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.Price) === null || _h === void 0 ? void 0 : _h.map((price) => (Object.assign({}, price.$)));
|
|
60
|
-
return { data: pricing, status };
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.default = Namecheap;
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DomainPriceActions = void 0;
|
|
4
|
-
var DomainPriceActions;
|
|
5
|
-
(function (DomainPriceActions) {
|
|
6
|
-
DomainPriceActions["REGISTER"] = "REGISTER";
|
|
7
|
-
DomainPriceActions["RENEW"] = "RENEW";
|
|
8
|
-
DomainPriceActions["REACTIVATE"] = "REACTIVATE";
|
|
9
|
-
DomainPriceActions["TRANSFER"] = "TRANSFER";
|
|
10
|
-
})(DomainPriceActions || (exports.DomainPriceActions = DomainPriceActions = {}));
|