🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

api-key-validator

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

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

0.1.6
latest
Source
npm
Version published
Weekly downloads
3
-81.25%
Maintainers
1
Weekly downloads
 
Created
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

  • Write Failing Tests
  • If new service type, create a new test file of the form test/service_type.js.
  • Copy test/test_template.js into the newly created file or the file corresponding to the service type of the new provider.
  • Follow instructions in the template file to create tests for the new service
  • Create the New Service Provider
  • Install the service provider's npm package as a dependency, or hit their rest API through npm request package
  • Create a new file of the form lib/models/services/service_type /provider_name.js
  • 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.
  • 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.
  • Edit lib/index.js
  • Require the newly created service provider
var ServiceName = require('./providers/service_type/service_name');
  • Add the newly created service provider to apiKeyValidator
  if (service == "service_name") Service_name.validate(keys);

Keywords

api

FAQs

Package last updated on 11 Aug 2015

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