Socket
Socket
Sign inDemoInstall

api-key-validator

Package Overview
Dependencies
190
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-key-validator

A package to easily validate api keys email, sms, push and web push service providers


Version published
Maintainers
1
Weekly downloads
7
increased by250%
Install size
30.3 MB

Weekly downloads

Readme

Source

API Key Validator   image of lock

Codeship Status for VennHQ/api-key-validator

Validate api keys for major email, sms, or push notification providers quickly and easily. Catch the problem early.

Installation

npm install api-key-validator

Validate (serviceName, keys, callback)

serviceNamekeys
"mailgun"{api_key, domain}
"mandrill"{api_key}
"postmark"{server_key}
"sendgrid"{api_user, api_key}
"nexmo"{api_key, api_secret}
"plivo"{auth_id, auth_token}
"sinch"{application_key, application_secret}
"twilio"{account_sid, auth_token}
"onesignal"{app_id, api_key}
"parse"{app_id, api_key}
"pushbots"{app_id}
"zeropush"{server_token}
Example
var apiKeyValidator = require('api-key-validator');

var keys = {
    api_user: "cx34554cvd234sdfsd34fsdf123123",
    api_key: "2342334534fbdf29sdfsbfbdfsd4"
}

apiKeyValidator.validate("sendgrid", keys, function(err, result){
    console.log(err, result);
});

Development

Want to add a service not currently supported? Feel free to add it yourself and send a pull request!

Install Dependencies
npm install
Run Examples
node example.js
Run Tests
mocha
Adding a New Service Provider
  1. Write Failing Tests
  2. If new service type, create a new test file of the form test/service_type.js.
  3. Copy test/test_template.js into the newly created file or the file corresponding to the service type of the new provider.
  4. Follow instructions in the template file to create tests for the new service
  5. Create the New Service Provider
  6. Install the service provider's npm package as a dependency, or hit their rest API through npm request package
  7. Create a new file of the form lib/models/services/service_type /provider_name.js
  8. Decide how you want to test if the provided keys are valid. Refer to the service's api documentation to call a function or hit an end point that will authenticate or result in an error.
  9. Return a callback making sure that error is null and result is populated if the keys are verified and error is populated and result is null if they are not.
  10. Edit lib/index.js
  11. Require the newly created service provider
var ServiceName = require('./providers/service_type/service_name');
  1. Add the newly created service provider to apiKeyValidator
  if (service == "service_name") Service_name.validate(keys);

Keywords

FAQs

Last updated on 11 Aug 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc