🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

otpless-next-js-auth-sdk

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

otpless-next-js-auth-sdk

---

1.0.2
npm
Version published
Weekly downloads
4
300%
Maintainers
1
Weekly downloads
 
Created
Source

Merchant Integration Documentation(Backend Next JS Auth SDK)

A. OTPLessAuth Dependency

You can install the OTPLessAuth SDK using npm:

npm install otpless-next-js-auth-sdk

B. OTPLessAuth class

The OTPLessAuth Next.js SDK is a powerful library that enables you to perform authentication using the OTPLess service. This SDK simplifies the integration of OTPLess authentication into your Next.js applications.

Methods:

1. Verify Auth Token

This method help to resolve token which is issued by OTPLess which return user detail from that token also this method verify that token is valid, token should not expired and issued by only otpless.com

Method Signature:
const userDetail = await OTPLessAuth.verifyToken(token, clientId, clientSecret);

Method Params:

ParamsData typeMandatoryConstraintsRemarks
tokenStringtruetoken which you get from OTPLess
clientIdStringtrueYour OTPLess Client Id
clientSecretStringtrueYour OTPLess Client Secret

Return

Return: Object Name: UserDetail

2. Decode IdToken

This method help to resolve idToken(JWT token) which is issued by OTPLess which return user detail from that token also this method verify that token is valid, token should not expired and issued by only otpless.com

Method Signature:
const userDetail = await OTPLessAuth.decodeIdToken(
  idToken,
  clientId,
  clientSecret
);

Method Params:

ParamsData typeMandatoryConstraintsRemarks
idTokenStringtrueidToken which is JWT token which you get from OTPLess by exchange code API
clientIdStringtrueYour OTPLess Client Id
clientSecretStringtrueYour OTPLess Client Secret

Return

Return: Object Name: UserDetail

3. Verify Code

This method help to resolve code which is return from OTPLess which will return user detail from that code also this method verify that code is valid, code should not expired and issued by only otpless.com

Method Signature:
const userDetail = await OTPLessAuth.verifyCode(code, clientId, clientSecret);

Method Params:

ParamsData typeMandatoryConstraintsRemarks
codeStringtruecode which you get from OTPLess
clientIdStringtrueYour OTPLess Client Id
clientSecretStringtrueYour OTPLess Client Secret

Return

Return: Object Name: UserDetail

This method help to get magic link which is return from OTPLess which will return token and request id from that mobile number or email id. Issued by only otpless.com

Method Signature:
const magicLinkTokens = await OTPLessAuth.magicLink(mobile, email, redirectURI, clientId, clientSecret);

Method Params:

ParamsData typeMandatoryConstraintsRemarks
mobileStringfalseInput by your user.
emailStringfalseInput by your user.
redirectURIStringtrueYour redirectURI. .
clientIdStringtrueYour OTPLess Client Id
clientSecretStringtrueYour OTPLess Client Secret

Return

Return: Object Name: magicLinkTokens

UserDetail Object Fields:

success (boolean): This will be true in case of method successfully performed operation.
authTime (Long, required): The time when authentication was completed.
phoneNumber (String, required): The user's phone number.
countryCode (String, required): The country code of user's phone number.
nationalPhoneNumber (String, required): The user's phone number without country code.
email (String, required): The user's email address.
name (String, required): The user's full name.

MagicLinkTokens Object Fields:

success (boolean): This will be true in case of method successfully performed operation.
requestIds (List, required): List of Token and Type of AUth.
type (String, required): Auth type.
value (String, required): Token value.

Error case:

success (boolean): This will be false. The method is failed to perform.
errorMessage (String): The message contains error information.

Example of usage

const OTPLessAuth = require("otpless-next-js-auth-sdk");

const idToken = "..."; // Replace with your ID token
const clientId = "..."; // Replace with your client ID
const clientSecret = "..."; // Replace with your client secret

const userDetail = await OTPLessAuth.decodeIdToken(
  idToken,
  clientId,
  clientSecret
);
console.log("User Details:", userDetail);

This method allows you to decode and verify OTPLess tokens and retrieve user information for integration into your next js application.

FAQs

Package last updated on 06 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts