vishwajeet-auth-lib
v1.0.0-SNAPSHOT-54
Published
this is auth kit for generating token
Downloads
30
Readme
Leap Auth Kit
this is auth kit for generating token
Installation
yarn add @leapfinance/auth-kit
Getting Started
First, Keep this component in global level or where you want to access it
import { WithLogin } from "@leapfinance/auth-kit";//import
<WithLogin appName={application_name} apiPath={server_path} logo={componey_logo} /> // component
How to use
leapLogin
To initiate Login Form
// init login modal
leapLogin(loginOption)
loginOption
| Name | Type | Description | Default | |----------------------|---------------------------------------------------------|-------------------------------------------------------------|---------| | title | string | that need to show on login modal | null | | canClose | boolean | can login modal close | true | | phone | string | prefilled phone number | null | | callback | (token, options?: {phone, subscribedToWhatsapp}) =>void | when token generates successfully return token and options. | null | | canChangeCountryCode | boolean | enable multiple country selector | false | | logo | string | in case you want new logo on modal | null | | enableTrueCaller | boolean | enable truecaller login | true |
error
To show error message in modal
leapLogin.error("error message")
loader
To Show Loader in Login Form
leapLogin.error("error message")
login status
To check is Logged in
leapLogin.isLogin() // return boolean
logout
To logout or delete cookies
leapLogin.logout()
subscribe events
To subscribe events
leapLogin.subscribe(events,cb);
// where cb = (option?: LoginOptionDto) => void
subscribe events list
| Event Name | Description | |----------------------|-----------------------------------| | INIT_LOGIN | when Login form initiate | | GENERATE_OTP | when generate otp action initiate | | GENERATE_OTP_SUCCESS | when generate otp successfully | | RESEND_OTP | when resend otp action initiate | | RESEND_OTP_SUCCESS | when resent otp successfully | | LOGIN_WITH_TC | when login with truecaller | | SUBMIT_OTP_SUCCESS | when otp verify successfully | | LOGIN_SUCCESS | when login successfully |