|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <title>cwc_auth_1.html</title> |
| 4 | + <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> |
| 5 | +</head> |
| 6 | +<body> |
| 7 | + |
| 8 | +<button type="button" onclick="clearSession()">clearSession</button> |
| 9 | + |
| 10 | +<script type='text/javascript'> |
| 11 | + async function fetchAndSetIdentityToken() { |
| 12 | + const identityTokenData = await fetchIdentityToken(); |
| 13 | + embeddedservice_bootstrap.userVerificationAPI.setIdentityToken({ |
| 14 | + identityTokenType: "JWT", |
| 15 | + identityToken: identityTokenData.accessToken |
| 16 | + }); |
| 17 | + } |
| 18 | + |
| 19 | + function fetchIdentityToken() { |
| 20 | + const porticoURL = "https://portico.sfproxy.controltelemetry-s.aws-esvc1-useast2.aws.sfdc.cl/api/v1/miaw/getJwtToken?issuer=testIssuer&subject=testSubject@cwc.com&jwtExpInSeconds=600&keyId=5f103f1b-ee38-404c-ac94-83c427764813"; |
| 21 | + return fetch(porticoURL).then(function(response) { |
| 22 | + return response.json(); |
| 23 | + }); |
| 24 | + } |
| 25 | + |
| 26 | + function clearSession() { |
| 27 | + embeddedservice_bootstrap.userVerificationAPI.clearSession(true); |
| 28 | + } |
| 29 | + |
| 30 | + window.addEventListener("onEmbeddedMessagingReady", () => { |
| 31 | + console.log("Received the onEmbeddedMessagingReady event…"); |
| 32 | + fetchAndSetIdentityToken(); |
| 33 | + }); |
| 34 | + |
| 35 | + |
| 36 | + window.addEventListener("onEmbeddedMessagingIdentityTokenExpired", () => { |
| 37 | + console.log("Received the onEmbeddedMessagingTokenExpired event…"); |
| 38 | + fetchAndSetIdentityToken(); |
| 39 | + }); |
| 40 | +</script> |
| 41 | + |
| 42 | + |
| 43 | +<script type='text/javascript'> |
| 44 | + function initEmbeddedMessaging() { |
| 45 | + try { |
| 46 | + embeddedservice_bootstrap.settings.language = 'en_US'; // For example, enter 'en' or 'en-US' |
| 47 | + embeddedservice_bootstrap.settings.devMode = true; |
| 48 | + |
| 49 | + embeddedservice_bootstrap.init( |
| 50 | + '00DSB00000aGFJL', |
| 51 | + 'CWC_Auth_1', |
| 52 | + 'https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWCAuth11765476941844', |
| 53 | + { |
| 54 | + scrt2URL: 'https://orgfarm-d585323017.test1.my.pc-rnd.salesforce-scrt.com' |
| 55 | + } |
| 56 | + ); |
| 57 | + } catch (err) { |
| 58 | + console.error('Error loading Embedded Messaging: ', err); |
| 59 | + } |
| 60 | + }; |
| 61 | +</script> |
| 62 | +<script type='text/javascript' src='https://orgfarm-d585323017.test1.my.pc-rnd.site.com/ESWCWCAuth11765476941844/assets/js/init.js' onload='initEmbeddedMessaging()'></script> |
| 63 | + |
| 64 | +</body> |
| 65 | +</html> |
0 commit comments