diff --git a/app/index.js b/app/index.js index 8fdb0bd..a341f19 100644 --- a/app/index.js +++ b/app/index.js @@ -32,9 +32,25 @@ export const callApi = async ({ auth0, url, btnId }) => { history.pushState('', null, window.location.pathname); - const accessToken = ['scoped-api-btn', 'private-api-btn'].includes(btnId) - ? await auth0.refreshTokens(true) - : await auth0.getAccessToken(); + let accessToken = undefined; + + if (['step-up-api-btn'].includes(btnId)) { + const authOptions = { + cacheMode: "off", + authorizationParams: { + acr_values: `http://schemas.openid.net/pape/policies/2007/06/multi-factor`, + scope: "authRocks:admin", + redirect_uri: window.location.href, + audience: auth0.config?.audience, + }, + } + accessToken = await auth0.getTokenWithPopup(authOptions); + } + else { + accessToken = ['scoped-api-btn', 'private-api-btn'].includes(btnId) + ? await auth0.refreshTokens(true) + : await auth0.getAccessToken(); + } const fetchOptions = { method: 'GET', @@ -96,6 +112,7 @@ export default async () => { const publicAPIButton = document.querySelector('#public-api-btn'); const privateAPIButton = document.querySelector('#private-api-btn'); const scopedAPIButton = document.querySelector('#scoped-api-btn'); + const stepUpAPIButton = document.querySelector("#step-up-api-btn"); loginButton.addEventListener('click', () => auth0.login()); @@ -127,6 +144,14 @@ export default async () => { }) ); + stepUpAPIButton.addEventListener('click', () => + callApi({ + auth0, + url: window.location.origin + apiUrl + '/admin', + btnId: 'step-up-api-btn', + }) + ); + // If unable to parse the history hash, default to the root URL if (!showContentFromUrl(window.location.pathname)) { showContentFromUrl('/'); diff --git a/index.html b/index.html index 02e2cd6..451f9fd 100644 --- a/index.html +++ b/index.html @@ -1,242 +1,258 @@ -
- -