npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serify

v1.1.1

Published

Lightweight SMS code validation library for Twilio Verify – Node.js

Downloads

40

Readme

Serify

Dependency Status Dependency Size Open Issues Version

Note: This package is still under heavy development and methods can change at any point in time. Use with caution. Contributors welcome.

Serify is a wrapper around the Twilio Verify REST API. This lightweight and straightforward wrapper allows you to send and verify SMS codes with two easy to use methods – and it only has two dependencies. Both methods use of async/await, making it easy to integrate into your existing codebase.

Example

Note: The phone number is automatically converted when passing an ISO-3166 country code. For example, when passing USA as the country, the library will automatically validate and construct a valid phone number such as +15554443333.

To send a verification code using, use the start method as shown below:

import Serify from 'serify';

const auth = new Serify({
	twilioServiceSid: 'YOUR_TWILIO_SERVICE_SID', // required (found in the twilio console)
	twilioAccountSid: 'YOUR_TWILIO_ACCOUNT_SID', // required (found in the twilio console)
	twilioAuthToken: 'YOUR_TWILIO_AUTH_TOKEN', // required (found in the twilio console)
});

const start = async () => {
	try {
		const start = await auth.start({
			phone: 'USER_PHONE_NUMBER', // users phone number in E.164 format
			country: 'USA', // ISO-3166 alpha 3 format (e.g. USA, CAN, etc.)
		});

		console.log(start);
	} catch (error) {
		console.log(error);
	}
};

start();

To verify a code, use the verify method as shown below:

import Serify from 'serify';

const auth = new Serify({
	twilioServiceSid: 'YOUR_TWILIO_SERVICE_SID', // required (found in the twilio console)
	twilioAccountSid: 'YOUR_TWILIO_ACCOUNT_SID', // required (found in the twilio console)
	twilioAuthToken: 'YOUR_TWILIO_AUTH_TOKEN', // required (found in the twilio console)
});

const verify = async () => {
	try {
		const verify = await auth.verify({
			phone: 'USER_PHONE_NUMBER', // users phone number in E.164 format
			country: 'USA', // ISO-3166 alpha 3 format (e.g. USA, CAN, etc.)
			code: '1990', // length is configurable via the twilio console
		});

		console.log(verify);
	} catch (error) {
		console.log(error);
	}
};

verify();

Obtaining Tokens

Twilio can be confusing at times as the API requires an Account Level SID, an Account Auth Token, in addition to a Service SID. All tokens can be found within your Twilio console.

  1. The account level SID and Account Auth Token are provided at the top level of your account.
  2. The service specific SID can be found when creating your application for the Twilio Verify product.

Beerpay