@kernel-js/auth
Install
npm install @kernel-js/auth
Enums
StorageMethods
Exposes the possible ways of storing the data received through native browser drives.
import { StorageMethods } from '@kernel-js/auth';
StorageMethods.LocalStorage
StorageMethods.CookieStorage
StorageMethods.SessionStorageClasses
OAuthAuthentication
Used for OAuth type password authentication. By default, it uses the model established by Laravel Passport.
Arguments
config - Object with the authentication settings.
request- It waits for an Axios instance and will be used to make the requests.storage - method- Expect a StorageMethods enum that will tell you how to persist the data.client - id- OAuth client id.client - scope- Scope says you want to get (optional).client - secret- Secret of the client OAuth.
Methods
All classes use by default the interface Authentication that defines some common methods, being them.
Login
Method that authenticates the user and returns their access tokens, in addition to the expiration date of the user.
Arguments
data- Object that holds the user data as the username and password.url (Optional)- path in which the authentication request will be sent. By default/oauth/tokenis used.
Logout
Clears user authentication data.
isGuest
Check if an authenticated user exist.
isAuthenticated
Opposite the isGuest method.
Last updated
Was this helpful?