1.0.1 • Published 4 months ago
@wral/studio.mods.auth v1.0.1
Vellum Auth Mod
This mod provides an Authentication mechanism via JWTs.
Usage
In a vellum project, add the following mod:
<vellum-app>
<vellum-mod name="auth" src="https://cdn.wral.studio/mods/auth/release/v1.0.0/auth.es.js"
api="https://api.wral.com/auth"
force-login>
</vellum-mod>
</vellum-app>
Attributes
api
: required auth api endpoint (without version or trailing slash)force-login
: optional force login on first page load- session-key: optional session key to use. Defaults to
token
Requesting an auth token
Consuming apps that would like an Auth token should dispatch an event:
const callback = (token) => {
// do something with the token
};
toolkit.dispatchAction({
type: 'auth:requestToken',
detail: { callback },
});
Alternatively, lib.es.js
contains a promise-based wrapper:
import { getToken } from 'https://cdn.wral.studio/mods/auth/release/v1.0.0/lib.es.js';
const elem = document.querySelector('vellum-app'); // any element within the app
getToken(elem).then((token) => {
// do something with the token
});