This is a demo for OTPless Backend SDK integration in Node TypeScript.
To integrate the same using JavaScript, check out nodeJS directory.
Pre-requisites: - Node installed
-
Open a new terminal in nodeTS directory.
-
Open src>constants file and
- Set the constants with your credentials.
-
Install and run
npm i && npm run dev
- 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.
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)