Skip to content

Latest commit

 

History

History

nodeTS

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

OTPless SDK integration in Node TS

This is a demo for OTPless Backend SDK integration in Node TypeScript.

To integrate the same using JavaScript, check out nodeJS directory.

Follow the steps below to get started

Pre-requisites: - Node installed

Step 1: Run the server

  1. Open a new terminal in nodeTS directory.

  2. Open src>constants file and

    • Set the constants with your credentials.
  3. Install and run

    npm i && npm run dev

Step 2: Send requests to the server

  • Thats it. Open src>auth file and use the functions from auth class.
  • Uncomment the function you want to test in index.ts file.
  • Pass the values for the required parameters if any and hit save to send requests.
  • You will get a successful or error logs on your console.

OTPless Package usage

npm i -S otpless-node-js-auth-sdk
//Ignore types for this file
//@ts-ignore
import { UserDetails } from 'otpless-node-js-auth-sdk'

// Send a magic link
await UserDetails.magicLink(mobile, email, redirectURI, channel, clientId, clientSecret)

// Verify code from magic link's approved redirected URI's params
await UserDetails.verifyCode(code, clientId, clientSecret)

// Verify token from frontend (OTPless)
await UserDetails.verifyToken(token, clientId, clientSecret)

// Send OTP
await UserDetails.sendOTP(sendTo, orderId, hash, clientId, clientSecret, channel, otpLength)

// Resend OTP
await UserDetails.resendOTP(orderId, clientId, clientSecret)

// Verify OTP
await UserDetails.verifyOTP(sendTo, orderId, otp, clientId, clientSecret)

Check out Official Documentation for more details

Thank you