diff --git a/packages/auth/demo/public/index.html b/packages/auth/demo/public/index.html index f69918d43d0..fde656a9d48 100644 --- a/packages/auth/demo/public/index.html +++ b/packages/auth/demo/public/index.html @@ -854,6 +854,7 @@

Sign in with your CIAM token

No CIAM token found. User not logged in.
+ + +
+ + + + + + `; + + $('body').append(modalHtml); + const $modal = $(`#${modalId}`); + + $modal.find('#token-submit-btn').on('click', () => { + isSubmitted = true; + + const configId = $modal.find('#idp-config-id-input-field').val(); + const token = $modal.find('#id-token-input-field').val(); + + $modal.modal('hide'); // Hide the modal + + const result = new RefreshIdpTokenResult(); + result.idpConfigId = configId; + result.idToken = token; + + resolve(result); + }); + + $modal.on('hidden.bs.modal', () => { + $modal.remove(); + + if (!isSubmitted) { + reject(new Error('User cancelled token input.')); + } + }); + + $modal.modal('show'); + }); + } +} + /** * Refreshes the current user data in the UI, displaying a user info box if * a user is signed in, or removing it. @@ -1509,23 +1589,20 @@ function onFinalizeSignInWithTotpMultiFactor(event) { }, onAuthError); } -async function exchangeCIAMToken(token) { - const firebaseToken = await exchangeToken( - regionalAuth, - (idpConfigId = 'Bar-e2e-idpconfig-002'), - token - ); +async function exchangeCIAMToken(idpConfigId, token) { + const firebaseToken = await exchangeToken(regionalAuth, idpConfigId, token); return firebaseToken; } function onExchangeToken(event) { event.preventDefault(); const byoCiamInput = document.getElementById('byo-ciam-token'); + const idpConfigId = document.getElementById('idp-config-id'); const firebaseTokenStatus = document.getElementById('firebase-token-status'); firebaseTokenStatus.textContent = 'Exchanging token...'; - exchangeCIAMToken(byoCiamInput.value) + exchangeCIAMToken(idpConfigId.value, byoCiamInput.value) .then(response => { firebaseTokenStatus.textContent = '✅ Firebase token is set: ' + response; console.log('Token:', response); @@ -2092,6 +2169,8 @@ function initApp() { popupRedirectResolver: browserPopupRedirectResolver, tenantConfig: tenantConfig }); + const tokenRefreshHandler = new TokenRefreshHandlerImpl(); + regionalAuth.setTokenRefreshHandler(tokenRefreshHandler); const firebaseTokenStatus = document.getElementById('firebase-token-status'); setTimeout(async () => {