Socket
Socket
Sign inDemoInstall

@rqt/namecheap-web

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rqt/namecheap-web

An API To Namecheap.com Via The Web Interface, With An Ability To Log In Using 2-Factor Auth To Whitelist IPs And Check Whois And Coupons.


Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

namecheap

@rqt/namecheap-web

npm version

@rqt/namecheap-web is an API to namecheap.com via the web interface, with an ability to log in using 2-factor Auth, check Whois and retrieve a coupon code.

The web API is currently used in the Expensive package to authenticate and white-list IP addresses. This is useful for dynamic-IP holders. Because the API implemented with gzip compression, the amount of traffic is minimized as well, helping to save data on mobile networks.

yarn add @rqt/namecheap-web

Table Of Contents

API

The package is available by importing its default class:

import NamecheapWeb from '@rqt/namecheap-web'

constructor(
  options?: WebOptions,
): NamecheapWeb

Create a new instance of the NamecheapWeb class. The sandbox version can be specified in the options. To remember the session cookies on the local filesystem, the readSession parameter can be passed. On the production version, the session expires after 20 minutes, but can be renewed after 10 minutes of using an existing session.

WebOptions: Options for the web client.

NameType & DescriptionDefault
sandboxbooleanfalse
Whether to use the sandbox version.
readSessionbooleanfalse
Read and store the cookies for the session from the local file.
sessionFilestring.namecheap-web.json
If reading session, indicates the file where to store cookies.
/* yarn example/ */
import NamecheapWeb from '@rqt/namecheap-web'
import bosom from 'bosom'

(async () => {
  try {
    // 0. Read stored username and password from a local file.
    const { username, password } = await bosom('.auth-sandbox.json')
    const nw = new NamecheapWeb({
      sandbox: true,
      readSession: true, // save cookies in a file.
    })
    // 1. Authenticate and create a session.
    await nw.auth(username, password)

    // 2. Read white-listed IPs.
    const ips = await nw.getWhitelistedIPList()
    console.log(JSON.stringify(ips[0], null, 2))

    // 3. Whitelist a new IP.
    const ip = await NamecheapWeb.LOOKUP_IP()
    await nw.whitelistIP(ip, 'example')

    // 4. Remove white-listed IP.
    await nw.removeWhitelistedIP('example')
  } catch ({ message }) {
    console.error(message)
  }
})()

async auth(
  username: string,
  password: string,
  phone?: string,
): void

Authenticate the app and obtain the cookies. If 2-factor authentication is enabled, it will also be carried out. The phone argument can be passed which is the last 3 digits of the phone used to receive the confirmation text. If it is not passed, a question will be asked via the CLI. The code should be then entered in the CLI as well.

async static LOOKUP_IP(): string

Get the public IP address using https://api.ipify.org.

async static WHOIS(domain): string

Return WHOIS data for the domain.

import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.WHOIS('test.org')
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
Show whois data
Domain Name: TEST.ORG
Registry Domain ID: D380528-LROR
Registrar WHOIS Server: whois.psi-usa.info
Registrar URL: http://www.psi-usa.info
Updated Date: 2019-07-27T01:31:37Z
Creation Date: 1997-07-27T04:00:00Z
Registry Expiry Date: 2020-07-26T04:00:00Z
Registrar Registration Expiration Date:
Registrar: PSI-USA, Inc. dba Domain Robot
Registrar IANA ID: 151
Registrar Abuse Contact Email: domain-abuse@psi-usa.info
Registrar Abuse Contact Phone: +49.94159559482
Reseller:
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Domain Status: autoRenewPeriod https://icann.org/epp#autoRenewPeriod
Registrant Organization: TMT Teleservice GmbH & Co.KG
Registrant State/Province: Bayern
Registrant Country: DE
Name Server: NS0.TMT.DE
Name Server: NS4.TMT.DE
Name Server: NS3.TMT.DE
Name Server: NS2.TMT.DE
Name Server: NS1.TMT.DE
DNSSEC: unsigned
URL of the ICANN Whois Inaccuracy Complaint Form https://www.icann.org/wicf/)
>>> Last update of WHOIS database: 2019-08-01T01:55:55Z

async static COUPON(): string

Returns this month's coupon from the https://www.namecheap.com/promos/coupons/ page.

/* yarn example/whois.js */
import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.COUPON()
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
STEAMYDEALZ

async static SANDBOX_COUPON(): string

Returns this month's coupon from the https://www.sandbox.namecheap.com/promos/coupons/ page.

/* yarn example/whois.js */
import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.SANDBOX_COUPON()
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
STEAMYDEALZ

async getWhitelistedIPList(
  username: string,
  password: string,
  phone?: string,
): WhitelistedIP[]

Get a list of white-listed IP addresses which can make API calls. The maximum of 20 IP addresses is allowed.

WhitelistedIP: A white-listed IP which can be used for API calls.

NameType & Description
Name*string
The name of the IP.
IpAddress*string
The IP address.
ModifyDate*!Date
The modification date.

async whitelistIP(
  ip: string,
  name?: string,
): void

Add an IP address to the white-listed IPs. If name is not given, it is automatically generated as rqt {date}

async removeWhitelistedIP(
  name: string,
): void

Remove the IP from the white-listed IPs by its name.

Art Deco © Art Deco for Rqt 2019 Tech Nation Visa Tech Nation Visa Sucks

Keywords

FAQs

Package last updated on 01 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc