Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dnsimple

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnsimple

Wrapper for DNSimple API

  • 1.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by14.45%
Maintainers
1
Weekly downloads
 
Created
Source

dnsimple

This is an unofficial DNSimple API module for node.js. You need a DNSimple account to use this.

Build Status Dependency Status

Installation

npm install dnsimple

Example

See Configuration below for details.

var dnsimple = new require ('dnsimple') ({ email: 'you@web.tld', token: 'abc123' });

// Add a domain name
var input = {
  domain: { name: 'example.tld' }
};

dnsimple ('POST', '/domains', input, function (err, data) {
  if (err) {
    return console.log (err);
  }

  console.log (data.domain.name + ' created with ID ' + data.domain.id);
});

More examples: https://github.com/fvdm/nodejs-dnsimple/wiki

Authentication

This module supports multiple authentication methods. None of them is totally secure, but some are easier to reset.

Account token

Most secure, easy to reset at dnsimple.com/account.

var dnsimple = require ('dnsimple') ({
  email: 'your@email.tld',
  token: '12345abcde'
});

Email & password

var dnsimple = require ('dnsimple') ({
  email: 'your@email.tld',
  password: 'secret'
});

Domain token

Access to only one domain name, easy to reset.

var dnsimple = require ('dnsimple') ({
  domainToken: 'abc123'
});

Two-factor authentication (2FA / OTP)

When you have set up two-factor authentication for your account the module returns error twoFactorOTP missing when you did not provide your one-time password.

First your need to tell the API once your one-time code from Authy or SMS, by defining it during setup along with your email and password and calling a random method. Then the API returns a token which you can use instead of your email and password.

// Set the OTP code on load
var dnsimple = require ('dnsimple') ({
  email: 'my@mail.tld',
  password: 'my-secret',
  twoFactorOTP: '0123456'
});

// Now call a random method to trade the OTP for a longterm token
dnsimple ('GET', '/subscription', function (err, data, meta) {
  if (err) { return console.log (err); }

  console.log ('Two-factor token: '+ meta.twoFactorToken);
});

// From now on only use this token - no email/password
var dnsimple = require ('dnsimple') ({
  twoFactorToken: '22596363b3de40b06f981fb85d82312e'
});

Configuration

When loading the module into your code you need to provide an Object for authentication as described above. This object can have a few more settings.

namedescriptiondefault
emailAccount email address
tokenAccount access token
passwordAccount password
domainTokenDomain specific API access token
twoFactorOTPOne-time code, i.e. Authy
twoFactorTokenLogin token, from twoFactorOTP
timeoutEnd API call after this amount of ms30000
hostnameAPI endpointapi.dnsimple.com

To use the sandbox environment set hostname to api.sandbox.dnsimple.com.

dnsimple

( method, path, [params], callback )

The module is only one method which takes care of all the error handling and basic post-processing.

See the API documentation for details on each method.

Module Arguments
nametyperequireddescription
methodstringyesGET, POST, PUT, DELETE
pathstringyesi.e. /domains/two.com
paramsobjectnoi.e. {domain: { name: 'one.com' } }
callbackfunctionyesFunction to receive response
Callback Arguments

The last argument callback receives three arguments: err, data and meta. When an error occurs err is an instance of Error and data is null. err can have additional properties. When everything is good err will be null and data will be the parsed result.

The meta parameter is always available and contains extra information from the API, such as statusCode, request_id, runtime and twoFactorToken.

  • DELETE result data is boolean true on success, false otherwise.
Errors

The err.message can be any of these:

messagedescriptionadditional
credentials missingNo authentication details set
request failedThe request cannot be madeerr.error
invalid reponseInvalid API responseerr.code, err.error, err.data
API errorThe API returned an errorerr.code, err.error, err.data

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Author

Franklin van de Meent

Keywords

FAQs

Package last updated on 11 May 2016

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