Skip to content

Commit

Permalink
Released Version 11.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
giriraj12000 committed Apr 8, 2021
1 parent ca0c133 commit e504e50
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 11 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@

> **LoginRadius Node JS SDK Change Log** provides information regarding what has changed, more specifically what changes, improvements and bug fix has been made to the SDK. For more details please refer to the [LoginRadius API Documention](https://docs.loginradius.com/api/v2/deployment/sdk-libraries/node-js-library)
# Version 11.1.0
Release on April 7, 2021

## Enhancements

- Added X-Origin-IP header support.
- Added 429 error code handling for "Too Many Request in a particular time frame".


## Added new multiple APIs for better user experience

- Get Profile By Ping.
- Passwordless Login Verification By Email And OTP.
- Passwordless Login Verification By User Name And OTP.



# Version 11.0.0
Release on Aug 04, 2020

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019 LoginRadius Inc.
Copyright (c) 2021 LoginRadius Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
108 changes: 105 additions & 3 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LoginRadius Combined Node SDK features a combined SDK set to encompass Social Lo
This document contains information and examples regarding the LoginRadius Node.js SDK. It provides guidance for working with social authentication, user profile data, and sending messages with a variety of social networks such as Facebook, Google, Twitter, Yahoo, LinkedIn, and more.
You can get the SDK from [here](http://github.com/LoginRadius/node-js-sdk)

Note: The latest version(11.0.0) of Node js SDK works with LoginRadius V2 APIs.
Note: The latest version(11.1.0) of Node js SDK works with LoginRadius V2 APIs.

Installation <br/>
run `npm install loginradius-sdk` <br/>
Expand All @@ -47,6 +47,7 @@ Create `var config` in project
apiSecret: '{{ Your API Secret }}',
siteName: '{{ Your Sitename }}',
apiRequestSigning: false,
originIp:"{{ Client Ip }}",
proxy:{
host:'',
port:'',
Expand All @@ -59,6 +60,16 @@ Replace the placeholders in the config object with your LoginRadius credentials

Pass the proxy configurations if you want to set Http Server Proxy Configuration through your NodeJs SDK. Host and port are required to set Http Server Proxy configuration (username and password are optional).

### X-Origin-IP

LoginRadius allows you to add X-Origin-IP in your headers and it determines the IP address of the client's request,this can also be useful to overcome analytics discrepancies where the analytics depend on header data.

```
originIp:"{{ Client Ip }}"
```
The originIp will be added in `var config`

Require the loginradius-sdk package and pass the config object
```
var lrv2 = require('loginradius-sdk')(config);
Expand Down Expand Up @@ -100,6 +111,7 @@ List of APIs in this Section:<br>
* GET : [Auth Read all Profiles by Token](#GetProfileByAccessToken-get-)<br>
* GET : [Auth Send Welcome Email](#SendWelcomeEmail-get-)<br>
* GET : [Auth Delete Account](#DeleteAccountByDeleteToken-get-)<br>
* GET : [Get Profile By Ping](#GetProfileByPing-get-)<br>
* GET : [Auth Check Email Availability](#CheckEmailAvailability-get-)<br>
* GET : [Auth Verify Email](#VerifyEmail-get-)<br>
* GET : [Auth Check UserName Availability](#CheckUserNameAvailability-get-)<br>
Expand Down Expand Up @@ -851,7 +863,26 @@ lrv2.authenticationApi.deleteAccountByDeleteToken(deletetoken).then((response) =
```


<h6 id="GetProfileByPing-get-">Get Profile By Ping (GET)</h6>
This API is used to get a user's profile using the clientGuid parameter if no callback feature enabled. [More Info](https://www.loginradius.com/docs/api/v2/customer-identity-api/social-login/social-login-by-ping/)



```
var clientGuid = "<clientGuid>"; //Required
var emailTemplate = "<emailTemplate>"; //Optional
var fields = null; //Optional
var verificationUrl = "<verificationUrl>"; //Optional
var welcomeEmailTemplate = "<welcomeEmailTemplate>"; //Optional
lrv2.authenticationApi.getProfileByPing(clientGuid, emailTemplate, fields, verificationUrl, welcomeEmailTemplate).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
```


<h6 id="CheckEmailAvailability-get-"> Auth Check Email Availability (GET)</h6>
Expand Down Expand Up @@ -1044,6 +1075,7 @@ List of APIs in this Section:<br>
* PUT : [Account Invalidate Verification Email](#InvalidateAccountEmailVerification-put-)<br>
* PUT : [Reset phone ID verification](#ResetPhoneIDVerificationByUid-put-)<br>
* PUT : [Upsert Email](#UpsertEmail-put-)<br>
* PUT : [Update UID](#AccountUpdateUid-put-)<br>
* POST : [Account Create](#CreateAccount-post-)<br>
* POST : [Forgot Password token](#GetForgotPasswordToken-post-)<br>
* POST : [Email Verification token](#GetEmailVerificationToken-post-)<br>
Expand Down Expand Up @@ -1207,7 +1239,27 @@ lrv2.accountApi.upsertEmail(upsertEmailModel, uid, fields).then((response) => {
```


<h6 id="AccountUpdateUid-put-"> Update UID (PUT)</h6>
This API is used to update a user's Uid. It will update all profiles, custom objects and consent management logs associated with the Uid. [More Info](https://www.loginradius.com/docs/api/v2/customer-identity-api/account/account-update/)




```
var updateUidModel ={
"newUid" : "<newUid>"
}; //Required
var uid = "<uid>"; //Required
lrv2.accountApi.accountUpdateUid(updateUidModel, uid).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
```


<h6 id="CreateAccount-post-"> Account Create (POST)</h6>
Expand Down Expand Up @@ -4462,6 +4514,8 @@ lrv2.oneTouchLoginApi.oneTouchLoginPing(clientGuid, fields).then((response) => {
List of APIs in this Section:<br>

* PUT : [Passwordless Login Phone Verification](#PasswordlessLoginPhoneVerification-put-)<br>
* POST : [Passwordless Login Verification By Email And OTP](#PasswordlessLoginVerificationByEmailAndOTP-post-)<br>
* POST : [Passwordless Login Verification By User Name And OTP](#PasswordlessLoginVerificationByUserNameAndOTP-post-)<br>
* GET : [Passwordless Login by Phone](#PasswordlessLoginByPhone-get-)<br>
* GET : [Passwordless Login By Email](#PasswordlessLoginByEmail-get-)<br>
* GET : [Passwordless Login By UserName](#PasswordlessLoginByUserName-get-)<br>
Expand Down Expand Up @@ -4493,7 +4547,55 @@ lrv2.passwordLessLoginApi.passwordlessLoginPhoneVerification(passwordLessLoginOt
```



<h6 id="PasswordlessLoginVerificationByEmailAndOTP-post-">Passwordless Login Verification By Email And OTP (POST)</h6>
This API is used to verify the otp sent to the email when doing a passwordless login. [More Info](https://www.loginradius.com/docs/api/v2/customer-identity-api/passwordless-login/passwordless-login-verify-by-email-and-otp/)




```
var passwordLessLoginByEmailAndOtpModel ={
"email": "<email>",
"otp": "<otp>",
"welcomeemailtemplate": "<welcome_email_template>"
}; //Required
var fields = null; //Optional
lrv2.passwordLessLoginApi.passwordlessLoginVerificationByEmailAndOTP(passwordLessLoginByEmailAndOtpModel, fields).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
```

<h6 id="PasswordlessLoginVerificationByUserNameAndOTP-post-">Passwordless Login Verification By User Name And OTP (POST)</h6>
This API is used to verify the otp sent to the email when doing a passwordless login. [More Info](https://www.loginradius.com/docs/api/v2/customer-identity-api/passwordless-login/passwordless-login-verify-by-username-and-otp/)




```
var passwordLessLoginByUserNameAndOtpModel ={
"username": "<User name>",
"otp": "<otp>",
"welcomeemailtemplate": "<welcome_email_template>"
}; //Required
var fields = null; //Optional
lrv2.passwordLessLoginApi.passwordlessLoginVerificationByUserNameAndOTP(passwordLessLoginByUserNameAndOtpModel, fields).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
```


<h6 id="PasswordlessLoginByPhone-get-"> Passwordless Login by Phone (GET)</h6>
Expand Down
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodeJsDemo",
"version": "11.0.0-demo",
"version": "11.1.0-demo",
"keywords": [
"util",
"functional",
Expand All @@ -13,6 +13,6 @@
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3",
"loginradius-sdk": "11.0.0"
"loginradius-sdk": "11.1.0"
}
}
6 changes: 3 additions & 3 deletions demo/server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Config variable */
var config = {
apiDomain: 'api.loginradius.com',
apiKey: '',
apiSecret: '',
siteName: '',
apiKey: '{{ Your API KEY }}',
apiSecret: '{{ Your API Secret }}',
siteName: '{{ Your Sitename }}',
serverRegion: '',
apiRequestSigning: false,
proxy: {
Expand Down
Empty file modified loginradius-sdk/README.md
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion loginradius-sdk/package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "loginradius-sdk",
"readme": "",
"scripts": {},
"version": "11.0.0",
"version": "11.1.0",
"description": "A LoginRadius SDK for node.js",
"homepage": "https://www.loginradius.com",
"main": "./sdk/util/lr.js",
Expand Down
38 changes: 38 additions & 0 deletions loginradius-sdk/sdk/api/authentication/authenticationApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,44 @@ module.exports = function (config) {
return config.request('PUT', resourcePath, queryParameters, unlockProfileModel);
};

/**
*
* @param {clientGuid}
* @param {emailTemplate}
* @param {fields}
* @param {verificationUrl}
* @param {welcomeEmailTemplate}
* @return Response containing User Profile Data and access token
*5.16
*/

module.getProfileByPing = function (clientGuid, emailTemplate,
fields, verificationUrl, welcomeEmailTemplate) {
if (helper.isNullOrWhiteSpace(clientGuid)) {
return Promise.reject(helper.getValidationMessage('clientGuid'));
}
var queryParameters = {};

queryParameters.apiKey = config.apiKey;
queryParameters.clientGuid = clientGuid;
if (!helper.isNullOrWhiteSpace(emailTemplate)) {
queryParameters.emailTemplate = emailTemplate;
}
if (!helper.isNullOrWhiteSpace(fields)) {
queryParameters.fields = fields;
}
if (!helper.isNullOrWhiteSpace(verificationUrl)) {
queryParameters.verificationUrl = verificationUrl;
}
if (!helper.isNullOrWhiteSpace(welcomeEmailTemplate)) {
queryParameters.welcomeEmailTemplate = welcomeEmailTemplate;
}

var resourcePath = 'identity/v2/auth/account/ping';

return config.request('GET', resourcePath, queryParameters, null);
};

/**
* This API is used to check the email exists or not on your site.
* @param {email} Email of the user
Expand Down
48 changes: 48 additions & 0 deletions loginradius-sdk/sdk/api/authentication/passwordLessLoginApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,53 @@ module.exports = function (config) {

return config.request('GET', resourcePath, queryParameters, null);
};

/**
*
* @param {passwordLessLoginByEmailAndOtpModel}
* @param {fields}
* @return Response containing User Profile Data and access token
*9.23
*/

module.passwordlessLoginVerificationByEmailAndOTP = function (passwordLessLoginByEmailAndOtpModel, fields) {
if (helper.checkJson(passwordLessLoginByEmailAndOtpModel)) {
return Promise.reject(helper.getValidationMessage('passwordLessLoginByEmailAndOtpModel'));
}
var queryParameters = {};

queryParameters.apiKey = config.apiKey;
if (!helper.isNullOrWhiteSpace(fields)) {
queryParameters.fields = fields;
}

var resourcePath = 'identity/v2/auth/login/passwordlesslogin/email/verifyotp';

return config.request('POST', resourcePath, queryParameters, passwordLessLoginByEmailAndOtpModel);
};

/**
*
* @param {passwordLessLoginByUserNameAndOtpModel}
* @param {fields}
* @return Response containing User Profile Data and access token
*9.24
*/

module.passwordlessLoginVerificationByUserNameAndOTP = function (passwordLessLoginByUserNameAndOtpModel, fields) {
if (helper.checkJson(passwordLessLoginByUserNameAndOtpModel)) {
return Promise.reject(helper.getValidationMessage('passwordLessLoginByUserNameAndOtpModel'));
}
var queryParameters = {};

queryParameters.apiKey = config.apiKey;
if (!helper.isNullOrWhiteSpace(fields)) {
queryParameters.fields = fields;
}

var resourcePath = 'identity/v2/auth/login/passwordlesslogin/username/verifyotp';

return config.request('POST', resourcePath, queryParameters, passwordLessLoginByUserNameAndOtpModel);
};
return module;
};
5 changes: 4 additions & 1 deletion loginradius-sdk/sdk/util/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ var getValidationMessage = function (type) {
*/
var manageRequestResponse = function (status, data, resolve, reject) {
if (checkError(status, data)) {
reject(data);
if(!data){
data=checkError(status, data)
}
reject(data);
} else {
resolve(data);
}
Expand Down
14 changes: 14 additions & 0 deletions loginradius-sdk/sdk/util/lr.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module.exports = function (config = {}) {
Object.assign(headers, { 'X-LoginRadius-Sott': queryParameters.sott });
delete queryParameters.sott;
}
if (!helper.isNullOrWhiteSpace(config.originIp)) {
Object.assign(headers, { 'X-Origin-IP':config.originIp});
}
var queryString = helper.getQueryString(queryParameters);

if (queryParameters.access_token) {
Expand Down Expand Up @@ -90,6 +93,16 @@ module.exports = function (config = {}) {

const req = https.request(options, (resp) => {
var data = '';
if(resp.hasOwnProperty("statusCode") && resp.statusCode==429){
var jsondata = {
'Description': 'Too many request in particular time frame',
'ErrorCode': 429,
'Message': 'Too many request in particular time frame',
'IsProviderError': false,
'ProviderErrorResponse': null
};
helper.manageRequestResponse('serverError', jsondata, resolve, reject);
}else{
resp.on('data', (chunk) => {
data += chunk;
});
Expand All @@ -102,6 +115,7 @@ module.exports = function (config = {}) {
helper.manageRequestResponse('serverError', '', resolve, reject);
}
});
}
}).on('error', (error) => {
helper.manageRequestResponse('serverError', error, resolve, reject);
});
Expand Down

0 comments on commit e504e50

Please sign in to comment.