Socket
Socket
Sign inDemoInstall

ringcaptcha-es6

Package Overview
Dependencies
52
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.1.1

6

lib/RingCaptcha.js

@@ -92,5 +92,5 @@ "use strict";

generate(phone, type, token) {
generateSMS(phone, token) {
const options = {
type: type || 'sms',
type: 'sms',
app_key: this.app_key,

@@ -102,3 +102,3 @@ api_key: this.api_key,

return sendRequest(['code', '/', options.type].join(''), options);
return sendRequest('code/sms' , options);
}

@@ -105,0 +105,0 @@

{
"name": "ringcaptcha-es6",
"version": "0.1.0",
"description": "Node.js wrapper for the RingCaptcha API using es6 and promises",
"version": "0.1.1",
"description": "Node.js wrapper for the RingCaptcha API using ECMAScript 6 and Promises",
"repository": {

@@ -6,0 +6,0 @@ "type": "git",

@@ -5,7 +5,62 @@ # Node.js Library

`ringcaptcha/ringcaptcha-node` is a Node.js module for communicating with the RingCaptcha API, which simplifies the Onboarding and Verification of Users
`ringcaptcha/ringcaptcha-es6` is a Node.js module for communicating with the RingCaptcha API, which simplifies the Onboarding and Verification of Users. This project is forked from https://github.com/ringcaptcha/ringcaptcha-node which uses callbacks.
This version is redesigned for codes that requires promises and does not want to be forced to implement the original version's strict configuration style.
## Getting Started
Make sure you are runing at least NodeJS version 6.7
Run the following in the terminal
```
npm install ringcaptcha-es6
```
Add a reference to your code.
```
const RingCaptcha = require('ringcaptcha-es6');
```
Make sure you have registered in RingCaptcha (http://www.ringcaptcha.com/) and created an app. You should have an APP_KEY, API_KEY and SECRET_KEY generated. You will need these to creaet a new instance of the RingCaptchaClient.
```
const rc = RingCaptcha.init(APP_KEY, API_KEY, SECRET_KEY, OPTIONS);
```
*for now options is pretty useless, just leave it blank.
##Functions
* **getToken(locale)** - Creates a new ringcaptcha session token. This token is used to identify the current session so make sure to store it. The locale params is a string which contains a 2-character language code followed by underscore (_) and a 2-character country code (all lower cased). For American English for example, the value would be "en_us"
```
rc.getToken('en_us')
.then((data) => {
if (!data.token) {
throw new Error('NO_TOKEN_CREATED');
}
//store this token somewhere in yur session for later use
req.session.ringcaotcha.token = data.token;
});
```
* **normalize(phone)** - todo
* **generateSMS(phone, token)** - generates an SMS verification code that will be sent to the phone number provided in the parameter. Make sure that the token parameter is the one you retrieved from the getToken() function.
```
rc.generateSMS('+639171234567', req.session.ringcaptcha.token)
.then((data) => {
if (data.status === "ERROR") {
throw new Error("RINGCAPTCHA_ERROR");
}
//data will contain lots of information so check it
});
```
* **verify(code, token)** - validates the verification code sent to the user. This code is the code sent to the user device.
```
rc.verify('WXYZ', req.session.ringcaptcha.token)
.then((data) => {
if (data.status === "ERROR") {
throw new Error("RINGCAPTCHA_ERROR");
}
//data will contain lots of information so check it
});
```
## Learn More
- Read the [HTML & JS Guides](https://my.ringcaptcha.com/docs/web)
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