UNPKG

@auth0/auth0-spa-js

Version:

Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE

25 lines (21 loc) 595 B
import 'fast-text-encoding'; import Auth0Client from './Auth0Client'; import * as ClientStorage from './storage'; //this is necessary to export the type definitions used in this file import './global'; export default async function createAuth0Client(options: Auth0ClientOptions) { const auth0 = new Auth0Client(options); if (!ClientStorage.get('auth0.is.authenticated')) { return auth0; } try { await auth0.getTokenSilently({ audience: options.audience, scope: options.scope, ignoreCache: true }); } catch (error) { // ignore } return auth0; }