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 1.0.3 to 1.1.0

55

lib/RingCaptcha.js
"use strict";
//See https://my.ringcaptcha.com/docs/api
const rp = require('request-promise');

@@ -8,2 +9,42 @@ const util = require("util");

/**
* Gets the locale to use when a user performs ringcaptcha
* @param language_code
* @param country_code
* @returns {*|string}
*/
function getLocale(language_code , country_code) {
if (!language_code || language_code.length !== 2) {
throw new Error('LANGUAGE_CODE_INVALID')
};
const available_locales = [ //always update this list when ringcaptcha makes it available
'ar', //Arabic
'de', //German
'en', //US English
'en_gb', //UK English
'es', //Spanish
'fi', //Finnish
'fr', //French
'gr', //Greek
'it', //Italian
'ja', //Japanese
'nl', //Dutch
'pt', //Portuguese
'ru', //Russian
'sv', //Swedish
'tr', //Turkish
'zh' //Chinese
]
let use, i;
i = available_locales.indexOf(language_code.toLowerCase());
if (i < 0 && country_code && available_locales.indexOf(language_code + _ + country_code) >= 0) {
i = available_locales.indexOf(language_code + _ + country_code);
}
use = i >= 0 ? available_locales[i] : 'en';
return use;
}
function sendRequest(method, uri, payload) {

@@ -63,4 +104,6 @@ const options = {

*/
getToken(locale = 'en') {
let uri = API_HOSTNAME + '/' + this.app_key + '/captcha';
getToken(language_code = 'en', country_code) {
const uri = API_HOSTNAME + '/' + this.app_key + '/captcha';
const locale = getLocale(language_code , country_code);
return sendRequest('POST', uri, {

@@ -79,4 +122,5 @@ app_key: this.app_key,

*/
sendVerificationCodeSMS(token, phone, locale = 'en') {
let uri = API_HOSTNAME + '/' + this.app_key + '/code/sms';
sendVerificationCodeSMS(token, phone, language_code = 'en' , country_code) {
const uri = API_HOSTNAME + '/' + this.app_key + '/code/sms';
const locale = getLocale(language_code , country_code);

@@ -99,4 +143,5 @@ return sendRequest('POST', uri , {

*/
sendVerificationCodeVoice(token, phone, locale = 'en') {
sendVerificationCodeVoice(token, phone, language_code = 'en' , country_code) {
let uri = API_HOSTNAME + '/' + this.app_key + '/code/voice';
const locale = getLocale(language_code , country_code);

@@ -103,0 +148,0 @@ return sendRequest('POST', uri , {

2

package.json
{
"name": "ringcaptcha-es6",
"version": "1.0.3",
"version": "1.1.0",
"description": "Node.js wrapper for the RingCaptcha API using ECMAScript 6 and Promises",

@@ -5,0 +5,0 @@ "repository": {

@@ -1,2 +0,2 @@

# Node.js Library
# RingCaptcha (ES6 and Promise version)

@@ -28,4 +28,5 @@ ## Overview

##Functions
* **getToken(locale)** - Gets a RingCaptcha session token
* @param locale - The locale/language to send the Voice call in (optional, defaults to 'en')
* **getToken(language_code, country_code)** - Gets a RingCaptcha session token
* @param language_code - The locale/language to send the Voice call in (optional, defaults to 'en')
* @param country_code - The country code to send the Voice call in (optional)
```

@@ -42,6 +43,7 @@ rc.getToken('en_gb')

* **sendVerificationCodeSMS(token, phone, locale)** - generate a new SMS verification code. Verification will be provided to the mobile number
* **sendVerificationCodeSMS(token, phone, language_code, country_code)** - generate a new SMS verification code. Verification will be provided to the mobile number
* @param token - Should you have a token already created and valid, send it thru this parameter
* @param phone - Phone number in international format as described in E.123.
* @param locale - The locale/language to send the Voice call in (optional, defaults to 'en')
* @param language_code - The locale/language to send the Voice call in (optional, defaults to 'en')
* @param country_code - The country code to send the Voice call in (optional)
```

@@ -57,6 +59,7 @@ rc.sendVerificationCodeSMS("mytoken-qwertyuiop", '+639171234567')

* **sendVerificationCodeVoice(token, phone, locale)** - generate a new Voice verification. Verification will be provided to the mobile number
* **sendVerificationCodeVoice(token, phone, language_code, country_code)** - generate a new Voice verification. Verification will be provided to the mobile number
* @param token - Should you have a token already created and valid, send it thru this parameter
* @param phone - Phone number in international format as described in E.123.
* @param locale - The locale/language to send the Voice call in (optional, defaults to 'en')
* @param language_code - The locale/language to send the Voice call in (optional, defaults to 'en')
* @param country_code - The country code to send the Voice call in (optional)
```

@@ -63,0 +66,0 @@ rc.sendVerificationCodeVoice("mytoken-qwertyuiop", '+639171234567')

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