1.0.26 • Published 3 years ago

onz-auth v1.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm version Release

OnzAuth JavaScript SDK

OnzAuth's JS SDK for Passwordless Authentication using Email Magic Link and WebAuthN.

Implement Authentication in 5 mins or less, straightforward support for magic link or WebAuthN, no passwords to manage, no callbacks to implement.

Questions?

Join our Slack Community

Demo

View the Demo Application

Please refer to demo/index.htm for demo code

Note: WebAuthN registration is seemless, so login users will only need to confirm their emails the very first time only when they register with WebAuthN, but will have a more seamless experience the second time onwards.

Install

npm install onz-auth --save

or

<script src="https://unpkg.com/onz-auth@1.0.26/dist/onz-auth-js-sdk.min.js"></script>

Quickstart

You'll need a CLIENT_ID, which you can get by creating a free account at OnzAuth.

WebAuthN can be enabled in the settings options after project creation. It is disabled by default.

import onz from "onz-auth"; // If using npm or included in script import

// Initialisation
const auth = new onz.Auth({
    clientID: 'Your Client ID', // Options
    containerID: 'myDiv', // Optional, defaults to 'container'
    isIframe: true, // Optional, defaults to 'false'
});

Sign in

Tokens will automatically be saved in localstorage with the following keys access_token, id_token, expiry, refresh_token after successful signin

auth.showLogin(); // Shows the login popup

Sign out

Tokens will automatically be cleared from localstorage after signing out

auth.logout(); // Signs out the current user

Events examples

// Authenticated event, after log in successful, contains accessToken, idToken, refreshToken, expiry
auth.on("authenticated", (authResult) => {
    console.log('authentication result', authResult);
    console.log('authentication access token', authResult.accessToken);
});

// Error message
auth.on("error", (errorMessage) => {
    console.error('authentication error', errorMessage);
});

// On popup or iframe closed
auth.on("closed", () => {
    console.log('iframe or popup is closed');
});

Options

Methods

Events

1.0.22

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.21

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.20

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago