A client-side library for the MikroAuth magic link authentication service. You will have to point the client to the endpoint of your MikroAuth server.
The minified version is ~4KB, substantially smaller than clients for common authentication services like Firebase (~118KB).
In your HTML:
<script src="path/to/mikroauth-client.min.js"></script>
<script>
const auth = new MikroAuthClient({ authUrl: 'https://auth.example.com' });
const isAuthenticated = await auth.isAuthenticated();
console.log('Is authenticated?', isAuthenticated);
const userInfo = await auth.getUserInfo();
console.log('User info:', userInfo);
</script>
await auth.requestMagicLink(email);
Request a new magic link email to the specified email address.
await auth.handleMagicLink();
Handle magic link from URL. Used when verifying the URL params (token and email).
await auth.isAuthenticated();
Checks if the user is authenticated.
await auth.getUserInfo();
Retrieves user data.
await auth.refreshToken();
Get a new refresh token.
await auth.logout();
Log out (sign out) the user.
Run npm run build
. Files are created in the lib
directory.
Run npm test
.
MIT. See the LICENSE
file.