Web JS SDK
Install web-js 
Install web-js to your web app.
npm i @axioms/web-js
Basic Uusage
Create Axioms auth object,
import { Auth } from '@axioms/web-js';
const $auth = new Auth({
axioms_domain: '<Your-Axioms-Domain>',
response_type: '<Your-Response-Type>',
redirect_uri: 'https://<Your-App-Host>/callback',
post_logout_uri: 'https://<Your-App-Host>/login',
client_id: '<Your-Client-ID>',
scope: '<Your-Scope>',
post_login_navigate: '<Your-Post-Login-Navigate>'
});
| Parameter | Allowed value/s | Required |
|---|---|---|
axioms_domain | your tenant's primary or custom domain without protocol i.e. your-slug.us.axioms.io or auth.my-domain.com | Yes |
response_type | Supported values code (authorization code flow)or id_token token (implicit code flow) | |
redirect_uri | redirect_uri registered in your Client's settings area in your tenant's control plane | Yes |
post_logout_uri | post_logout_uri registered in your Client's settings area in your tenant's control plane | Yes |
scope | Space separated scopes values . Bare-minimum you need openid. If you need user profile and email to be included in issued id_token then your scope should look like openid profile email. See list of all supported scopes here | Yes |
post_login_navigate | Application path where user should be navigated after successful login. For example, /home or /dashboard | Yes |
Web-js API
| Function/Object | Description |
|---|---|
$auth.login_with_redirect() | Login user with redirect to Axioms hosted login page |
$auth.login_with_email_link(email) | Passwordless login using magic link sent to email address of the user |
$auth.logout_with_redirect() | Logout user with redirect to Axioms logout endpoint |
$auth.session.is_authenticated() | Check if user session is authenticated or not |
$auth.get_user_settings_url() | Get user settings URL where user can update profile, password, multi-factor preferences, sessions and apps. |
$auth.session.id_payload | Get payload of id token and access individual attributes by name |
$auth.session.id_token | Get id token for the session |
$auth.session.access_token | Get access token for the session (if included in response type) |
$auth.session.hasRole(required_roles) | Check any of the required roles included in roles claim of the id token. required_roles must be an array of strings with each string representing a role. |
$auth.session.hasScope(required_scopes) | Check any of the required scopes included in scope claim of the id token. required_scopes must be an array of strings with each string representing a scope. |
$auth.session.hasPermission(required_permissions) | Check any of the required permissions included in permissions claim of the id token. required_permissions must be an array of strings with each string representing a permission. |