Skip to content

Commit e504e50

Browse files
committed
Released Version 11.1.0
1 parent ca0c133 commit e504e50

File tree

11 files changed

+233
-11
lines changed

11 files changed

+233
-11
lines changed

CHANGELOG.md

100755100644
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11

22
> **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)
33
4+
# Version 11.1.0
5+
Release on April 7, 2021
6+
7+
## Enhancements
8+
9+
- Added X-Origin-IP header support.
10+
- Added 429 error code handling for "Too Many Request in a particular time frame".
11+
12+
13+
## Added new multiple APIs for better user experience
14+
15+
- Get Profile By Ping.
16+
- Passwordless Login Verification By Email And OTP.
17+
- Passwordless Login Verification By User Name And OTP.
18+
19+
20+
421
# Version 11.0.0
522
Release on Aug 04, 2020
623

LICENSE

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 LoginRadius Inc.
1+
Copyright (c) 2021 LoginRadius Inc.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

README.md

100755100644
Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LoginRadius Combined Node SDK features a combined SDK set to encompass Social Lo
3434
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.
3535
You can get the SDK from [here](http://github.com/LoginRadius/node-js-sdk)
3636

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

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

6061
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).
6162

63+
### X-Origin-IP
64+
65+
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.
66+
67+
```
68+
originIp:"{{ Client Ip }}"
69+
70+
```
71+
The originIp will be added in `var config`
72+
6273
Require the loginradius-sdk package and pass the config object
6374
```
6475
var lrv2 = require('loginradius-sdk')(config);
@@ -100,6 +111,7 @@ List of APIs in this Section:<br>
100111
* GET : [Auth Read all Profiles by Token](#GetProfileByAccessToken-get-)<br>
101112
* GET : [Auth Send Welcome Email](#SendWelcomeEmail-get-)<br>
102113
* GET : [Auth Delete Account](#DeleteAccountByDeleteToken-get-)<br>
114+
* GET : [Get Profile By Ping](#GetProfileByPing-get-)<br>
103115
* GET : [Auth Check Email Availability](#CheckEmailAvailability-get-)<br>
104116
* GET : [Auth Verify Email](#VerifyEmail-get-)<br>
105117
* GET : [Auth Check UserName Availability](#CheckUserNameAvailability-get-)<br>
@@ -851,7 +863,26 @@ lrv2.authenticationApi.deleteAccountByDeleteToken(deletetoken).then((response) =
851863
852864
```
853865

854-
866+
<h6 id="GetProfileByPing-get-">Get Profile By Ping (GET)</h6>
867+
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/)
868+
869+
870+
871+
```
872+
873+
var clientGuid = "<clientGuid>"; //Required
874+
var emailTemplate = "<emailTemplate>"; //Optional
875+
var fields = null; //Optional
876+
var verificationUrl = "<verificationUrl>"; //Optional
877+
var welcomeEmailTemplate = "<welcomeEmailTemplate>"; //Optional
878+
879+
lrv2.authenticationApi.getProfileByPing(clientGuid, emailTemplate, fields, verificationUrl, welcomeEmailTemplate).then((response) => {
880+
console.log(response);
881+
}).catch((error) => {
882+
console.log(error);
883+
});
884+
885+
```
855886

856887

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

1210-
1242+
<h6 id="AccountUpdateUid-put-"> Update UID (PUT)</h6>
1243+
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/)
1244+
1245+
1246+
1247+
1248+
```
1249+
1250+
1251+
var updateUidModel ={
1252+
"newUid" : "<newUid>"
1253+
}; //Required
1254+
var uid = "<uid>"; //Required
1255+
1256+
lrv2.accountApi.accountUpdateUid(updateUidModel, uid).then((response) => {
1257+
console.log(response);
1258+
}).catch((error) => {
1259+
console.log(error);
1260+
});
1261+
1262+
```
12111263

12121264

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

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

4550+
4551+
4552+
<h6 id="PasswordlessLoginVerificationByEmailAndOTP-post-">Passwordless Login Verification By Email And OTP (POST)</h6>
4553+
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/)
4554+
4555+
4556+
4557+
4558+
```
4559+
4560+
4561+
var passwordLessLoginByEmailAndOtpModel ={
4562+
"email": "<email>",
4563+
"otp": "<otp>",
4564+
"welcomeemailtemplate": "<welcome_email_template>"
4565+
}; //Required
4566+
var fields = null; //Optional
4567+
4568+
lrv2.passwordLessLoginApi.passwordlessLoginVerificationByEmailAndOTP(passwordLessLoginByEmailAndOtpModel, fields).then((response) => {
4569+
console.log(response);
4570+
}).catch((error) => {
4571+
console.log(error);
4572+
});
4573+
4574+
```
44964575

4576+
<h6 id="PasswordlessLoginVerificationByUserNameAndOTP-post-">Passwordless Login Verification By User Name And OTP (POST)</h6>
4577+
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/)
4578+
4579+
4580+
4581+
4582+
```
4583+
4584+
4585+
var passwordLessLoginByUserNameAndOtpModel ={
4586+
"username": "<User name>",
4587+
"otp": "<otp>",
4588+
"welcomeemailtemplate": "<welcome_email_template>"
4589+
}; //Required
4590+
var fields = null; //Optional
4591+
4592+
lrv2.passwordLessLoginApi.passwordlessLoginVerificationByUserNameAndOTP(passwordLessLoginByUserNameAndOtpModel, fields).then((response) => {
4593+
console.log(response);
4594+
}).catch((error) => {
4595+
console.log(error);
4596+
});
4597+
4598+
```
44974599

44984600

44994601
<h6 id="PasswordlessLoginByPhone-get-"> Passwordless Login by Phone (GET)</h6>

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodeJsDemo",
3-
"version": "11.0.0-demo",
3+
"version": "11.1.0-demo",
44
"keywords": [
55
"util",
66
"functional",
@@ -13,6 +13,6 @@
1313
"dependencies": {
1414
"body-parser": "^1.18.3",
1515
"express": "^4.16.3",
16-
"loginradius-sdk": "11.0.0"
16+
"loginradius-sdk": "11.1.0"
1717
}
1818
}

demo/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Config variable */
22
var config = {
33
apiDomain: 'api.loginradius.com',
4-
apiKey: '',
5-
apiSecret: '',
6-
siteName: '',
4+
apiKey: '{{ Your API KEY }}',
5+
apiSecret: '{{ Your API Secret }}',
6+
siteName: '{{ Your Sitename }}',
77
serverRegion: '',
88
apiRequestSigning: false,
99
proxy: {

loginradius-sdk/README.md

100755100644
File mode changed.

loginradius-sdk/package.json

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "loginradius-sdk",
33
"readme": "",
44
"scripts": {},
5-
"version": "11.0.0",
5+
"version": "11.1.0",
66
"description": "A LoginRadius SDK for node.js",
77
"homepage": "https://www.loginradius.com",
88
"main": "./sdk/util/lr.js",

loginradius-sdk/sdk/api/authentication/authenticationApi.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,44 @@ module.exports = function (config) {
329329
return config.request('PUT', resourcePath, queryParameters, unlockProfileModel);
330330
};
331331

332+
/**
333+
*
334+
* @param {clientGuid}
335+
* @param {emailTemplate}
336+
* @param {fields}
337+
* @param {verificationUrl}
338+
* @param {welcomeEmailTemplate}
339+
* @return Response containing User Profile Data and access token
340+
*5.16
341+
*/
342+
343+
module.getProfileByPing = function (clientGuid, emailTemplate,
344+
fields, verificationUrl, welcomeEmailTemplate) {
345+
if (helper.isNullOrWhiteSpace(clientGuid)) {
346+
return Promise.reject(helper.getValidationMessage('clientGuid'));
347+
}
348+
var queryParameters = {};
349+
350+
queryParameters.apiKey = config.apiKey;
351+
queryParameters.clientGuid = clientGuid;
352+
if (!helper.isNullOrWhiteSpace(emailTemplate)) {
353+
queryParameters.emailTemplate = emailTemplate;
354+
}
355+
if (!helper.isNullOrWhiteSpace(fields)) {
356+
queryParameters.fields = fields;
357+
}
358+
if (!helper.isNullOrWhiteSpace(verificationUrl)) {
359+
queryParameters.verificationUrl = verificationUrl;
360+
}
361+
if (!helper.isNullOrWhiteSpace(welcomeEmailTemplate)) {
362+
queryParameters.welcomeEmailTemplate = welcomeEmailTemplate;
363+
}
364+
365+
var resourcePath = 'identity/v2/auth/account/ping';
366+
367+
return config.request('GET', resourcePath, queryParameters, null);
368+
};
369+
332370
/**
333371
* This API is used to check the email exists or not on your site.
334372
* @param {email} Email of the user

loginradius-sdk/sdk/api/authentication/passwordLessLoginApi.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,53 @@ module.exports = function (config) {
149149

150150
return config.request('GET', resourcePath, queryParameters, null);
151151
};
152+
153+
/**
154+
*
155+
* @param {passwordLessLoginByEmailAndOtpModel}
156+
* @param {fields}
157+
* @return Response containing User Profile Data and access token
158+
*9.23
159+
*/
160+
161+
module.passwordlessLoginVerificationByEmailAndOTP = function (passwordLessLoginByEmailAndOtpModel, fields) {
162+
if (helper.checkJson(passwordLessLoginByEmailAndOtpModel)) {
163+
return Promise.reject(helper.getValidationMessage('passwordLessLoginByEmailAndOtpModel'));
164+
}
165+
var queryParameters = {};
166+
167+
queryParameters.apiKey = config.apiKey;
168+
if (!helper.isNullOrWhiteSpace(fields)) {
169+
queryParameters.fields = fields;
170+
}
171+
172+
var resourcePath = 'identity/v2/auth/login/passwordlesslogin/email/verifyotp';
173+
174+
return config.request('POST', resourcePath, queryParameters, passwordLessLoginByEmailAndOtpModel);
175+
};
176+
177+
/**
178+
*
179+
* @param {passwordLessLoginByUserNameAndOtpModel}
180+
* @param {fields}
181+
* @return Response containing User Profile Data and access token
182+
*9.24
183+
*/
184+
185+
module.passwordlessLoginVerificationByUserNameAndOTP = function (passwordLessLoginByUserNameAndOtpModel, fields) {
186+
if (helper.checkJson(passwordLessLoginByUserNameAndOtpModel)) {
187+
return Promise.reject(helper.getValidationMessage('passwordLessLoginByUserNameAndOtpModel'));
188+
}
189+
var queryParameters = {};
190+
191+
queryParameters.apiKey = config.apiKey;
192+
if (!helper.isNullOrWhiteSpace(fields)) {
193+
queryParameters.fields = fields;
194+
}
195+
196+
var resourcePath = 'identity/v2/auth/login/passwordlesslogin/username/verifyotp';
197+
198+
return config.request('POST', resourcePath, queryParameters, passwordLessLoginByUserNameAndOtpModel);
199+
};
152200
return module;
153201
};

loginradius-sdk/sdk/util/helper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ var getValidationMessage = function (type) {
8686
*/
8787
var manageRequestResponse = function (status, data, resolve, reject) {
8888
if (checkError(status, data)) {
89-
reject(data);
89+
if(!data){
90+
data=checkError(status, data)
91+
}
92+
reject(data);
9093
} else {
9194
resolve(data);
9295
}

0 commit comments

Comments
 (0)