2.1.1 • Published 1 year ago

otpless-js-sdk v2.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

otpless-js-sdk

Otpless-js-sdk is a vanilla javascript SDK used for authenticating users using OTPless in client side application. Demo video

Features

  • Fetch WhatsApp intent and redirect users to WhatsApp.
  • Get token from query params
  • Get state from local storage

Getting Started

  1. Install the otpless-js-sdk from the npm repository.
    npm i otpless-js-sdk
  1. Initialize the sdk. appId is required. enableErrorLogging is an optional parameter. On setting it to true, the error logs are consoled to the stderr.
    import otplessSdk from "otpless-js-sdk";
    const sdkIntance = new otplessSdk(
           {
               appId: "YOUR_APP_ID",
               enableErrorLogging: true
           }
        );
  1. create an Onclick function using createGetIntentOnClick. It takes redirectionURL object property as a parameter. This is the url to which the client is redirected to once it gets a response in WhatsApp.
   <button
     onClick={sdkIntance.createGetIntentOnClick({
       redirectionURL: "YOUR_REDIRECTION_URL",
     })}
   >
     Login with WhatsApp
   </button>
  1. After successfull redirection from WhatsApp, extract the token from query params using the static function getTokenFromQueryParams and the state from the local storage using the static function getState. The token along with the state needs to be passed to your server which in turn should make call to OTPless server for user details.
   const token=otplessSdk.getTokenFromQueryParams();
   const state=otplessSdk.getState()

License

MIT

Made with ❤️ by OTPless

2.1.1

1 year ago

2.0.2

2 years ago

2.1.0

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago