@saasquatch/mint-components 1.8.5-11 → 1.8.5-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cjs/{sqm-portal-verify-email-view-ce552bbc.js → sqm-portal-verify-email-view-81ef761a.js} +2 -0
  2. package/dist/cjs/sqm-portal-verify-email.cjs.entry.js +31 -26
  3. package/dist/cjs/sqm-stencilbook.cjs.entry.js +2 -2
  4. package/dist/collection/components/sqm-portal-verify-email/sqm-portal-verify-email-view.js +2 -0
  5. package/dist/collection/components/sqm-portal-verify-email/usePortalVerifyEmail.js +30 -25
  6. package/dist/esm/{sqm-portal-verify-email-view-283bf637.js → sqm-portal-verify-email-view-857a46e3.js} +2 -0
  7. package/dist/esm/sqm-portal-verify-email.entry.js +31 -26
  8. package/dist/esm/sqm-stencilbook.entry.js +2 -2
  9. package/dist/esm-es5/sqm-portal-verify-email-view-857a46e3.js +1 -0
  10. package/dist/esm-es5/sqm-portal-verify-email.entry.js +1 -1
  11. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  12. package/dist/mint-components/mint-components.esm.js +1 -1
  13. package/dist/mint-components/p-1db8fde3.entry.js +9 -0
  14. package/dist/mint-components/p-335ec624.system.entry.js +1 -0
  15. package/dist/mint-components/p-3aa885c1.entry.js +1 -0
  16. package/dist/mint-components/p-44b12b2e.system.js +1 -1
  17. package/dist/mint-components/p-5d1700a3.system.entry.js +1 -0
  18. package/dist/mint-components/p-65200af1.system.js +1 -0
  19. package/dist/mint-components/p-d8e56725.js +1 -0
  20. package/docs/docs.docx +0 -0
  21. package/package.json +1 -1
  22. package/dist/esm-es5/sqm-portal-verify-email-view-283bf637.js +0 -1
  23. package/dist/mint-components/p-4d9744bf.js +0 -1
  24. package/dist/mint-components/p-5cd6d4ed.system.entry.js +0 -1
  25. package/dist/mint-components/p-a69c8b27.system.entry.js +0 -1
  26. package/dist/mint-components/p-b2b22a2a.entry.js +0 -9
  27. package/dist/mint-components/p-d4b174e1.system.js +0 -1
  28. package/dist/mint-components/p-f24dadbe.entry.js +0 -1
@@ -24,6 +24,8 @@ const sheet = JSS.createStyleSheet(style);
24
24
  const styleString = sheet.toString();
25
25
  function PortalVerifyEmailView(props) {
26
26
  const { states, data, callbacks, content } = props;
27
+ if (states.loading)
28
+ return;
27
29
  if (states.verified) {
28
30
  return (index.h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
29
31
  index.h("style", { type: "text/css" },
@@ -10,7 +10,7 @@ require('./mixins-fe9d4112.js');
10
10
  require('./JSS-8503a151.js');
11
11
  const utils = require('./utils-6847bc06.js');
12
12
  require('./sqm-text-span-view-e1cd9bd3.js');
13
- const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-ce552bbc.js');
13
+ const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-81ef761a.js');
14
14
 
15
15
  const SUBMITTED_CONTEXT = "sq:verify-submitted";
16
16
  function setSubmitted(submitted) {
@@ -30,6 +30,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
30
30
  // derived from useMutation in component boilerplate initialState
31
31
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
32
32
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
33
+ const hasContext = localStorage.getItem("sq:user-identity");
33
34
  const verified = !!(((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified) || (data === null || data === void 0 ? void 0 : data.verifyManagedIdentityEmail.success));
34
35
  const failed = () => {
35
36
  return index_module.$n.push({
@@ -42,39 +43,43 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
42
43
  const url = utils.sanitizeUrlPath(nextPageOverride || nextPage);
43
44
  index_module.$n.push(url.href);
44
45
  };
46
+ const logout = () => {
47
+ console.debug("LOGOUT");
48
+ setTimeout(() => {
49
+ gotoNextPage();
50
+ index_module.setUserIdentity(undefined);
51
+ setSubmitted(false);
52
+ }, 3000);
53
+ };
45
54
  const submit = async () => {
46
55
  setSubmitted(true);
56
+ console.debug("SUBMITTED");
47
57
  await request({ oobCode });
48
58
  };
59
+ console.log({ hasContext, userIdent, data, submitted, verified });
49
60
  stencilHooks_module.useEffect(() => {
50
- const logout = async () => {
51
- var _a;
52
- if (!((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.emailVerified) && !submitted) {
53
- await submit();
54
- }
55
- setTimeout(() => {
56
- gotoNextPage();
57
- index_module.setUserIdentity(undefined);
58
- setSubmitted(false);
59
- }, 3000);
60
- };
61
+ if (!data && !submitted && oobCode)
62
+ submit();
61
63
  // verification successful but user in context is not verified
62
64
  // or mismatch between logged in user and user associated with oobCode
63
- if (email && email !== oobEmail) {
64
- logout();
65
- return;
66
- // Already verified, begin redirect
67
- }
68
- else if (verified) {
69
- setTimeout(() => {
70
- gotoNextPage();
71
- setSubmitted(false);
72
- }, 3000);
73
- return;
65
+ if (submitted) {
66
+ console.debug("in submit condition");
67
+ if (email && email !== oobEmail) {
68
+ console.debug("email mismatch");
69
+ logout();
70
+ return;
71
+ // Already verified, begin redirect
72
+ }
73
+ if (verified) {
74
+ console.debug("verified");
75
+ setTimeout(() => {
76
+ gotoNextPage();
77
+ setSubmitted(false);
78
+ }, 3000);
79
+ return;
80
+ }
74
81
  }
75
- if (!data && !submitted && oobCode)
76
- submit();
77
- }, [verified, submitted, data, userIdent]);
82
+ }, [submitted, data, email, oobCode, oobEmail, submit]);
78
83
  return {
79
84
  states: {
80
85
  loading: loading || disableContinue,
@@ -27,7 +27,7 @@ const sqmPortalForgotPasswordView = require('./sqm-portal-forgot-password-view-c
27
27
  const sqmPortalProfileView = require('./sqm-portal-profile-view-d8697f23.js');
28
28
  require('./utilities-73df97e1.js');
29
29
  const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-07a13210.js');
30
- const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-ce552bbc.js');
30
+ const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-81ef761a.js');
31
31
  const ShadowViewAddon = require('./ShadowViewAddon-89ba2ab0.js');
32
32
  const sqmPortalContainerView = require('./sqm-portal-container-view-5fb2ad49.js');
33
33
  const sqmInvoiceTableView = require('./sqm-invoice-table-view-501f8985.js');
@@ -7605,7 +7605,7 @@ const PortalResetPassword = /*#__PURE__*/Object.freeze({
7605
7605
  CodeValidating: CodeValidating
7606
7606
  });
7607
7607
 
7608
- const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n Background: A user is on the email verification page\n Given a user who has been redirected to the email verification page\n\n @motivating\n Scenario: Verifying your email takes you to the portal login page\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they click \"Continue\"\n Then they are redirected to login\n\n @motivating\n Scenario: Users are automatically redirected if they dont click \"Continue\"\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they wait 5 seconds\n Then they are redirected to login\n\n @motivating\n Scenario: Users are notified if verifying their email has failed\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email fails to be validated\n Then an banner is shown stating that an error occured\n\n @motivating\n Scenario Outline: Users cannot verify their email with an invalid or missing oob code\n Given a user has a <oobCode> as a url query parameter\n And the component <mayHave> \"failed-page\" with <value>\n Then they see an error message saying that their verification code is invalid/expired\n When they click \"Continue\"\n Then they are redirected to <redirectPath>\n Examples:\n | oobCode | mayHave | value | redirectPath |\n | invalid oob code | doesn't have | N/A | / |\n | non existant oob code | doesn't have | N/A | / |\n | invalid oob code | has | /login | /login |\n | non existant oob code | has | /login | /login |\n\n @motivating\n Scenario: Users are redirected to \"/\" by default\n Given the component does not have prop \"nextPage\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/\"\n\n @motivating\n Scenario: Custom redirection can be configured\n Given the component has prop \"nextPage\" with value \"/activity\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/activity\"\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter if it exists\n Given the component <mayHave> prop \"nextPage\" with <nextPageValue>\n And the users url contains a \"nextPage\" query paramater with <nextPageParamValue>\n And the user has verified their email\n When they click \"Continue\"\n Then they are redirected to <nextPageParamValue>\n Examples:\n | mayHave | nextPageValue | nextPageParamValue |\n | has | /dashboard | /activity |\n | does not have | N/A | /activity |\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter as if it were a relative path\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://www.example.com?nextPage=./activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=/activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=www.google.com | https://www.example.com/www.google.com |\n | https://www.example.com?nextPage=//foo.com | https://www.example.com/ |\n | https://www.example.com?nextPage=https://malicious.example.com | https://www.example.com/ |\n | http://www.example.com/nest/page?oob=123&other&nextPage=activity#heading-1 | http://www.example.com/activity |\n | https://www.example.com?nextPage=activity?foo=bar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar#hash | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar%23hash | https://www.example.com/activity?foo=bar#hash |\n | https://www.example.com:1337?nextPage=activity | https://www.example.com:1337/activity |\n | http://1.1.1.1:1111?nextPage=activity | http://1.1.1.1:1111/activity |\n\n @landmine\n Scenario Outline: Username and password are not persisted on redirects\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://user:pass@www.example.com:444?nextPage=activity | https://www.example.com:444/activity |";
7608
+ const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n Background: A user is on the email verification page\n Given a user who has been redirected to the email verification page\n\n @motivating\n Scenario: Verifying your email takes you to the portal login page\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they click \"Continue\"\n Then they are redirected to login\n\n @motivating\n Scenario: Users are automatically redirected if they dont click \"Continue\"\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they wait 5 seconds\n Then they are redirected to login\n\n @motivating\n Scenario: Users are notified if verifying their email has failed\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email fails to be validated\n Then an banner is shown stating that an error occured\n\n @motivating\n Scenario Outline: Users cannot verify their email with an invalid or missing oob code\n Given a user has a <oobCode> as a url query parameter\n And the component <mayHave> \"failed-page\" with <value>\n Then they see an error message saying that their verification code is invalid/expired\n When they click \"Continue\"\n Then they are redirected to <redirectPath>\n Examples:\n | oobCode | mayHave | value | redirectPath |\n | invalid oob code | doesn't have | N/A | / |\n | non existant oob code | doesn't have | N/A | / |\n | invalid oob code | has | /login | /login |\n | non existant oob code | has | /login | /login |\n\n @motivating\n Scenario: Users are redirected to \"/\" by default\n Given the component does not have prop \"nextPage\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/\"\n\n @motivating\n Scenario: Custom redirection can be configured\n Given the component has prop \"nextPage\" with value \"/activity\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/activity\"\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter if it exists\n Given the component <mayHave> prop \"nextPage\" with <nextPageValue>\n And the users url contains a \"nextPage\" query paramater with <nextPageParamValue>\n And the user has verified their email\n When they click \"Continue\"\n Then they are redirected to <nextPageParamValue>\n Examples:\n | mayHave | nextPageValue | nextPageParamValue |\n | has | /dashboard | /activity |\n | does not have | N/A | /activity |\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter as if it were a relative path\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://www.example.com?nextPage=./activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=/activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=www.google.com | https://www.example.com/www.google.com |\n | https://www.example.com?nextPage=//foo.com | https://www.example.com/ |\n | https://www.example.com?nextPage=https://malicious.example.com | https://www.example.com/ |\n | http://www.example.com/nest/page?oob=123&other&nextPage=activity#heading-1 | http://www.example.com/activity |\n | https://www.example.com?nextPage=activity?foo=bar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar#hash | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar%23hash | https://www.example.com/activity?foo=bar#hash |\n | https://www.example.com:1337?nextPage=activity | https://www.example.com:1337/activity |\n | http://1.1.1.1:1111?nextPage=activity | http://1.1.1.1:1111/activity |\n\n @landmine\n Scenario Outline: Username and password are not persisted on redirects\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://user:pass@www.example.com:444?nextPage=activity | https://www.example.com:444/activity |\n\n\n @minutia\n Scenario Outline: Users may be logged in or logged out depending on the verified status and logged in email\n Given an oobCode with email <oobCodeEmail> as a url query parameter\n And the user is logged in as <loggedInEmail>\n And the logged in user <isVerified>\n When the oobCode is submitted\n And the oobCode <isValid>\n Then the <submitState> screen is shown\n And after 3 seconds pass\n Then the user is redirected to <redirect>\n Examples:\n | oobCodeEmail | loggedInEmail | isVerified | isValid | submitState | redirect |\n | user1@example.com | N/A | false | is valid | success | /login |\n | user1@example.com | N/A | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | false | is valid | success | /activity |\n | user1@example.com | user1@example.com | false | is not valid | error | N/A |\n | user1@example.com | user2@example.com | false | is valid | success | /login |\n | user1@example.com | user2@example.com | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | true | is valid | success | /activity |\n | user1@example.com | user1@example.com | true | is not valid | success | /activity |\n | user1@example.com | user2@example.com | true | is not valid | error | /login |\n";
7609
7609
 
7610
7610
  const PortalVerifyEmail_stories = {
7611
7611
  title: "Components/Microsite Verify Email",
@@ -21,6 +21,8 @@ const sheet = createStyleSheet(style);
21
21
  const styleString = sheet.toString();
22
22
  export function PortalVerifyEmailView(props) {
23
23
  const { states, data, callbacks, content } = props;
24
+ if (states.loading)
25
+ return;
24
26
  if (states.verified) {
25
27
  return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
26
28
  h("style", { type: "text/css" },
@@ -19,6 +19,7 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
19
19
  // derived from useMutation in component boilerplate initialState
20
20
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
21
21
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
22
+ const hasContext = localStorage.getItem("sq:user-identity");
22
23
  const verified = !!(((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified) || (data === null || data === void 0 ? void 0 : data.verifyManagedIdentityEmail.success));
23
24
  const failed = () => {
24
25
  return navigation.push({
@@ -31,39 +32,43 @@ export function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText,
31
32
  const url = sanitizeUrlPath(nextPageOverride || nextPage);
32
33
  navigation.push(url.href);
33
34
  };
35
+ const logout = () => {
36
+ console.debug("LOGOUT");
37
+ setTimeout(() => {
38
+ gotoNextPage();
39
+ setUserIdentity(undefined);
40
+ setSubmitted(false);
41
+ }, 3000);
42
+ };
34
43
  const submit = async () => {
35
44
  setSubmitted(true);
45
+ console.debug("SUBMITTED");
36
46
  await request({ oobCode });
37
47
  };
48
+ console.log({ hasContext, userIdent, data, submitted, verified });
38
49
  useEffect(() => {
39
- const logout = async () => {
40
- var _a;
41
- if (!((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.emailVerified) && !submitted) {
42
- await submit();
43
- }
44
- setTimeout(() => {
45
- gotoNextPage();
46
- setUserIdentity(undefined);
47
- setSubmitted(false);
48
- }, 3000);
49
- };
50
+ if (!data && !submitted && oobCode)
51
+ submit();
50
52
  // verification successful but user in context is not verified
51
53
  // or mismatch between logged in user and user associated with oobCode
52
- if (email && email !== oobEmail) {
53
- logout();
54
- return;
55
- // Already verified, begin redirect
56
- }
57
- else if (verified) {
58
- setTimeout(() => {
59
- gotoNextPage();
60
- setSubmitted(false);
61
- }, 3000);
62
- return;
54
+ if (submitted) {
55
+ console.debug("in submit condition");
56
+ if (email && email !== oobEmail) {
57
+ console.debug("email mismatch");
58
+ logout();
59
+ return;
60
+ // Already verified, begin redirect
61
+ }
62
+ if (verified) {
63
+ console.debug("verified");
64
+ setTimeout(() => {
65
+ gotoNextPage();
66
+ setSubmitted(false);
67
+ }, 3000);
68
+ return;
69
+ }
63
70
  }
64
- if (!data && !submitted && oobCode)
65
- submit();
66
- }, [verified, submitted, data, userIdent]);
71
+ }, [submitted, data, email, oobCode, oobEmail, submit]);
67
72
  return {
68
73
  states: {
69
74
  loading: loading || disableContinue,
@@ -22,6 +22,8 @@ const sheet = createStyleSheet(style);
22
22
  const styleString = sheet.toString();
23
23
  function PortalVerifyEmailView(props) {
24
24
  const { states, data, callbacks, content } = props;
25
+ if (states.loading)
26
+ return;
25
27
  if (states.verified) {
26
28
  return (h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
27
29
  h("style", { type: "text/css" },
@@ -6,7 +6,7 @@ import './mixins-f60a614c.js';
6
6
  import './JSS-67b5cff8.js';
7
7
  import { s as sanitizeUrlPath, g as getProps } from './utils-334c1e34.js';
8
8
  import './sqm-text-span-view-8d140661.js';
9
- import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-283bf637.js';
9
+ import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-857a46e3.js';
10
10
 
11
11
  const SUBMITTED_CONTEXT = "sq:verify-submitted";
12
12
  function setSubmitted(submitted) {
@@ -26,6 +26,7 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
26
26
  // derived from useMutation in component boilerplate initialState
27
27
  const disableContinue = data === undefined && errors === undefined && !!oobCode;
28
28
  // if logged out, userIdent?.managedIdentity?.emailVerified will be falsey, even if verification was successful
29
+ const hasContext = localStorage.getItem("sq:user-identity");
29
30
  const verified = !!(((_b = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _b === void 0 ? void 0 : _b.emailVerified) || (data === null || data === void 0 ? void 0 : data.verifyManagedIdentityEmail.success));
30
31
  const failed = () => {
31
32
  return $n.push({
@@ -38,39 +39,43 @@ function usePortalVerifyEmail({ nextPage, failedPage, verifySuccessText, verifyE
38
39
  const url = sanitizeUrlPath(nextPageOverride || nextPage);
39
40
  $n.push(url.href);
40
41
  };
42
+ const logout = () => {
43
+ console.debug("LOGOUT");
44
+ setTimeout(() => {
45
+ gotoNextPage();
46
+ setUserIdentity(undefined);
47
+ setSubmitted(false);
48
+ }, 3000);
49
+ };
41
50
  const submit = async () => {
42
51
  setSubmitted(true);
52
+ console.debug("SUBMITTED");
43
53
  await request({ oobCode });
44
54
  };
55
+ console.log({ hasContext, userIdent, data, submitted, verified });
45
56
  useEffect(() => {
46
- const logout = async () => {
47
- var _a;
48
- if (!((_a = userIdent === null || userIdent === void 0 ? void 0 : userIdent.managedIdentity) === null || _a === void 0 ? void 0 : _a.emailVerified) && !submitted) {
49
- await submit();
50
- }
51
- setTimeout(() => {
52
- gotoNextPage();
53
- setUserIdentity(undefined);
54
- setSubmitted(false);
55
- }, 3000);
56
- };
57
+ if (!data && !submitted && oobCode)
58
+ submit();
57
59
  // verification successful but user in context is not verified
58
60
  // or mismatch between logged in user and user associated with oobCode
59
- if (email && email !== oobEmail) {
60
- logout();
61
- return;
62
- // Already verified, begin redirect
63
- }
64
- else if (verified) {
65
- setTimeout(() => {
66
- gotoNextPage();
67
- setSubmitted(false);
68
- }, 3000);
69
- return;
61
+ if (submitted) {
62
+ console.debug("in submit condition");
63
+ if (email && email !== oobEmail) {
64
+ console.debug("email mismatch");
65
+ logout();
66
+ return;
67
+ // Already verified, begin redirect
68
+ }
69
+ if (verified) {
70
+ console.debug("verified");
71
+ setTimeout(() => {
72
+ gotoNextPage();
73
+ setSubmitted(false);
74
+ }, 3000);
75
+ return;
76
+ }
70
77
  }
71
- if (!data && !submitted && oobCode)
72
- submit();
73
- }, [verified, submitted, data, userIdent]);
78
+ }, [submitted, data, email, oobCode, oobEmail, submit]);
74
79
  return {
75
80
  states: {
76
81
  loading: loading || disableContinue,
@@ -23,7 +23,7 @@ import { P as PortalForgotPasswordView } from './sqm-portal-forgot-password-view
23
23
  import { P as PortalProfileView } from './sqm-portal-profile-view-13f0ef79.js';
24
24
  import './utilities-21d8a4df.js';
25
25
  import { P as PortalResetPasswordView } from './sqm-portal-reset-password-view-d3e726a9.js';
26
- import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-283bf637.js';
26
+ import { P as PortalVerifyEmailView } from './sqm-portal-verify-email-view-857a46e3.js';
27
27
  import { S as ShareButtonView, L as LeaderboardView, C as CopyTextView, B as BigStatView, P as PortalFrameView, E as EditProfileView, u as useShareLink, a as useShareButton, b as useDemoBigStat, c as StatContainerView, d as PortalChangePasswordView, e as PortalLoginView, f as PortalRegisterView, T as TaskCardView, g as ProgressBarView, h as PoweredByImg$1, i as PortalFooterView, H as HeroView, R as ReferralIframeView, N as NameFieldsView, j as CheckboxFieldView, D as DropdownFieldView, I as InputFieldView, k as RewardExchangeView, r as rewardExchangeCustomErrorMsg, l as rewardExchangeLongText, m as rewardExchangeSelected, n as chooseAmountFixed, o as chooseAmountFixedNoDescription, p as chooseAmountVariable, q as chooseAmountVariableNoDescription, s as chooseAmountVariableDisabled, t as chooseAmountVariableUnavailable, v as confirmFixed, w as confirmVariable, x as redemptionError, y as queryError, z as success, A as successVariable, F as loading, G as empty$1, J as rewardExchange, K as CardFeedView, M as CouponCodeView, O as ProgressBar$2, Q as autoColorScaleCss, U as ShadowViewAddon } from './ShadowViewAddon-c22043d9.js';
28
28
  import { P as PortalContainerView, a as PortalSectionView } from './sqm-portal-container-view-ab89c6cc.js';
29
29
  import { O as OtherRegionSlotView, I as InvoiceTableView, T as TaxForm } from './sqm-invoice-table-view-d00894ce.js';
@@ -7601,7 +7601,7 @@ const PortalResetPassword = /*#__PURE__*/Object.freeze({
7601
7601
  CodeValidating: CodeValidating
7602
7602
  });
7603
7603
 
7604
- const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n Background: A user is on the email verification page\n Given a user who has been redirected to the email verification page\n\n @motivating\n Scenario: Verifying your email takes you to the portal login page\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they click \"Continue\"\n Then they are redirected to login\n\n @motivating\n Scenario: Users are automatically redirected if they dont click \"Continue\"\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they wait 5 seconds\n Then they are redirected to login\n\n @motivating\n Scenario: Users are notified if verifying their email has failed\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email fails to be validated\n Then an banner is shown stating that an error occured\n\n @motivating\n Scenario Outline: Users cannot verify their email with an invalid or missing oob code\n Given a user has a <oobCode> as a url query parameter\n And the component <mayHave> \"failed-page\" with <value>\n Then they see an error message saying that their verification code is invalid/expired\n When they click \"Continue\"\n Then they are redirected to <redirectPath>\n Examples:\n | oobCode | mayHave | value | redirectPath |\n | invalid oob code | doesn't have | N/A | / |\n | non existant oob code | doesn't have | N/A | / |\n | invalid oob code | has | /login | /login |\n | non existant oob code | has | /login | /login |\n\n @motivating\n Scenario: Users are redirected to \"/\" by default\n Given the component does not have prop \"nextPage\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/\"\n\n @motivating\n Scenario: Custom redirection can be configured\n Given the component has prop \"nextPage\" with value \"/activity\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/activity\"\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter if it exists\n Given the component <mayHave> prop \"nextPage\" with <nextPageValue>\n And the users url contains a \"nextPage\" query paramater with <nextPageParamValue>\n And the user has verified their email\n When they click \"Continue\"\n Then they are redirected to <nextPageParamValue>\n Examples:\n | mayHave | nextPageValue | nextPageParamValue |\n | has | /dashboard | /activity |\n | does not have | N/A | /activity |\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter as if it were a relative path\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://www.example.com?nextPage=./activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=/activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=www.google.com | https://www.example.com/www.google.com |\n | https://www.example.com?nextPage=//foo.com | https://www.example.com/ |\n | https://www.example.com?nextPage=https://malicious.example.com | https://www.example.com/ |\n | http://www.example.com/nest/page?oob=123&other&nextPage=activity#heading-1 | http://www.example.com/activity |\n | https://www.example.com?nextPage=activity?foo=bar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar#hash | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar%23hash | https://www.example.com/activity?foo=bar#hash |\n | https://www.example.com:1337?nextPage=activity | https://www.example.com:1337/activity |\n | http://1.1.1.1:1111?nextPage=activity | http://1.1.1.1:1111/activity |\n\n @landmine\n Scenario Outline: Username and password are not persisted on redirects\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://user:pass@www.example.com:444?nextPage=activity | https://www.example.com:444/activity |";
7604
+ const scenario$9 = "@author:derek\n@owner:ian\nFeature: Verify Email\n\n Background: A user is on the email verification page\n Given a user who has been redirected to the email verification page\n\n @motivating\n Scenario: Verifying your email takes you to the portal login page\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they click \"Continue\"\n Then they are redirected to login\n\n @motivating\n Scenario: Users are automatically redirected if they dont click \"Continue\"\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email is validated\n Then a button that says \"Continue\" appears\n When they wait 5 seconds\n Then they are redirected to login\n\n @motivating\n Scenario: Users are notified if verifying their email has failed\n Given a user has a valid oob code as a url query parameter\n When they click \"Verify Email\"\n Then the button enters a loading state\n When their email fails to be validated\n Then an banner is shown stating that an error occured\n\n @motivating\n Scenario Outline: Users cannot verify their email with an invalid or missing oob code\n Given a user has a <oobCode> as a url query parameter\n And the component <mayHave> \"failed-page\" with <value>\n Then they see an error message saying that their verification code is invalid/expired\n When they click \"Continue\"\n Then they are redirected to <redirectPath>\n Examples:\n | oobCode | mayHave | value | redirectPath |\n | invalid oob code | doesn't have | N/A | / |\n | non existant oob code | doesn't have | N/A | / |\n | invalid oob code | has | /login | /login |\n | non existant oob code | has | /login | /login |\n\n @motivating\n Scenario: Users are redirected to \"/\" by default\n Given the component does not have prop \"nextPage\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/\"\n\n @motivating\n Scenario: Custom redirection can be configured\n Given the component has prop \"nextPage\" with value \"/activity\"\n And the users url does not contain a \"nextPage\" query parameter\n And a user has verified their email\n When they click \"Continue\"\n Then they are redirected to \"/activity\"\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter if it exists\n Given the component <mayHave> prop \"nextPage\" with <nextPageValue>\n And the users url contains a \"nextPage\" query paramater with <nextPageParamValue>\n And the user has verified their email\n When they click \"Continue\"\n Then they are redirected to <nextPageParamValue>\n Examples:\n | mayHave | nextPageValue | nextPageParamValue |\n | has | /dashboard | /activity |\n | does not have | N/A | /activity |\n\n @motivating\n Scenario Outline: Users are redirected to the value of the nextPage url parameter as if it were a relative path\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://www.example.com?nextPage=./activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=/activity | https://www.example.com/activity |\n | https://www.example.com?nextPage=www.google.com | https://www.example.com/www.google.com |\n | https://www.example.com?nextPage=//foo.com | https://www.example.com/ |\n | https://www.example.com?nextPage=https://malicious.example.com | https://www.example.com/ |\n | http://www.example.com/nest/page?oob=123&other&nextPage=activity#heading-1 | http://www.example.com/activity |\n | https://www.example.com?nextPage=activity?foo=bar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar#hash | https://www.example.com/activity?foo=bar |\n | https://www.example.com?nextPage=%2Factivity%3Ffoo%3Dbar%23hash | https://www.example.com/activity?foo=bar#hash |\n | https://www.example.com:1337?nextPage=activity | https://www.example.com:1337/activity |\n | http://1.1.1.1:1111?nextPage=activity | http://1.1.1.1:1111/activity |\n\n @landmine\n Scenario Outline: Username and password are not persisted on redirects\n Given the component is loaded at <currentUrl>\n And the user has verified their email\n When they click \"Continue\"\n And they are redirected to <url>\n Examples:\n | currentUrl | url |\n | https://user:pass@www.example.com:444?nextPage=activity | https://www.example.com:444/activity |\n\n\n @minutia\n Scenario Outline: Users may be logged in or logged out depending on the verified status and logged in email\n Given an oobCode with email <oobCodeEmail> as a url query parameter\n And the user is logged in as <loggedInEmail>\n And the logged in user <isVerified>\n When the oobCode is submitted\n And the oobCode <isValid>\n Then the <submitState> screen is shown\n And after 3 seconds pass\n Then the user is redirected to <redirect>\n Examples:\n | oobCodeEmail | loggedInEmail | isVerified | isValid | submitState | redirect |\n | user1@example.com | N/A | false | is valid | success | /login |\n | user1@example.com | N/A | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | false | is valid | success | /activity |\n | user1@example.com | user1@example.com | false | is not valid | error | N/A |\n | user1@example.com | user2@example.com | false | is valid | success | /login |\n | user1@example.com | user2@example.com | false | is not valid | error | /login |\n | user1@example.com | user1@example.com | true | is valid | success | /activity |\n | user1@example.com | user1@example.com | true | is not valid | success | /activity |\n | user1@example.com | user2@example.com | true | is not valid | error | /login |\n";
7605
7605
 
7606
7606
  const PortalVerifyEmail_stories = {
7607
7607
  title: "Components/Microsite Verify Email",
@@ -0,0 +1 @@
1
+ import{h}from"./index-17b4da69.js";import{A as AuthWrapper,a as AuthColumn}from"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var style={Wrapper:AuthWrapper,Column:AuthColumn,ContinueButton:{width:"100%"}};var vanillaStyle="\n:host {\n display: block;\n}\n:host([hidden]): {\n display: none;\n}\n";var sheet=createStyleSheet(style);var styleString=sheet.toString();function PortalVerifyEmailView(e){var t=e.states,s=e.data,r=e.callbacks,a=e.content;if(t.loading)return;if(t.verified){return h("div",{class:sheet.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},vanillaStyle,styleString),h(TextSpanView,{type:"h3"},a.verifyEmailText),h("sqm-form-message",{exportparts:"success-icon"},h("div",{part:"successalert-text"},a.verifySuccessText)),h("sl-button",{class:sheet.classes.ContinueButton,onClick:r.gotoNextPage,loading:t.loading,exportparts:"base: primarybutton-base",type:"primary"},a.continueText))}if(t.error||!s.oobCode){return h("div",{class:sheet.classes.Wrapper,part:"sqm-base"},h("style",{type:"text/css"},styleString),h(TextSpanView,{type:"h3"},a.verifyEmailText),h("sqm-form-message",{type:"error",exportparts:"erroralert-icon"},h("div",{part:"erroralert-text"},a.verifyInvalidText)),h("sl-button",{class:sheet.classes.ContinueButton,onClick:r.failed,loading:t.loading,exportparts:"base: primarybutton-base",type:"primary"},a.continueText))}}export{PortalVerifyEmailView as P};
@@ -1 +1 @@
1
- var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r["throw"](e))}catch(e){a(e)}}function l(e){e.done?i(e.value):n(e.value).then(o,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return l([e,t])}}function l(o){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,n&&(a=o[0]&2?n["return"]:o[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;if(n=0,a)o=[o[0]&2,a.value];switch(o[0]){case 0:case 1:a=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;n=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(o[0]===6&&i.label<a[1]){i.label=a[1];a=o;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(o);break}if(a[2])i.ops.pop();i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e];n=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{r as registerInstance,h as h$1}from"./index-17b4da69.js";import{f as useEffect,n as h}from"./stencil-hooks.module-8032b139.js";import{Q,j as an,$ as $n,b as setUserIdentity,i as isDemo}from"./index.module-ba0ed7a8.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import"./JSS-67b5cff8.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import"./sqm-text-span-view-8d140661.js";import{P as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-283bf637.js";var SUBMITTED_CONTEXT="sq:verify-submitted";function setSubmitted(e){window[SUBMITTED_CONTEXT]=e}function usePortalVerifyEmail(e){var t=this;var i=e.nextPage,r=e.failedPage,n=e.verifySuccessText,a=e.verifyEmailText,o=e.verifyInvalidText,s=e.networkErrorMessage,l=e.continueText;var u,c,d,f,v,m,h,y,g;var p=window[SUBMITTED_CONTEXT];var b=Q();var x=(u=b===null||b===void 0?void 0:b.managedIdentity)===null||u===void 0?void 0:u.email;var T=an(),w=T[0],E=T[1],P=E.loading,_=E.data,S=E.errors;var I=new URLSearchParams($n.location.search);var j=I.get("oobCode");var k=I.get("email");var V=I.get("nextPage");var C=_===undefined&&S===undefined&&!!j;var D=!!(((c=b===null||b===void 0?void 0:b.managedIdentity)===null||c===void 0?void 0:c.emailVerified)||(_===null||_===void 0?void 0:_.verifyManagedIdentityEmail.success));var U=function(){return $n.push({pathname:r,search:I.toString()&&"?"+I.toString()})};var M=function(){I.delete("nextPage");var e=sanitizeUrlPath(V||i);$n.push(e.href)};var $=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:setSubmitted(true);return[4,w({oobCode:j})];case 1:e.sent();return[2]}}))}))};useEffect((function(){var e=function(){return __awaiter(t,void 0,void 0,(function(){var e;return __generator(this,(function(t){switch(t.label){case 0:if(!(!((e=b===null||b===void 0?void 0:b.managedIdentity)===null||e===void 0?void 0:e.emailVerified)&&!p))return[3,2];return[4,$()];case 1:t.sent();t.label=2;case 2:setTimeout((function(){M();setUserIdentity(undefined);setSubmitted(false)}),3e3);return[2]}}))}))};if(x&&x!==k){e();return}else if(D){setTimeout((function(){M();setSubmitted(false)}),3e3);return}if(!_&&!p&&j)$()}),[D,p,_,b]);return{states:{loading:P||C,error:((m=(v=(f=(d=S===null||S===void 0?void 0:S.response)===null||d===void 0?void 0:d.errors)===null||f===void 0?void 0:f[0])===null||v===void 0?void 0:v.extensions)===null||m===void 0?void 0:m.message)||((g=(y=(h=S===null||S===void 0?void 0:S.response)===null||h===void 0?void 0:h.errors)===null||y===void 0?void 0:y[0])===null||g===void 0?void 0:g.message)||(S===null||S===void 0?void 0:S.message)&&s,verified:D},data:{oobCode:j},callbacks:{failed:U,gotoNextPage:M},content:{verifySuccessText:n,verifyEmailText:a,verifyInvalidText:o,continueText:l}}}var PortalVerifyEmail=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.failedPage="/";this.verifyEmailText="Verify your email";this.verifySuccessText="Your email has been verified and you are being redirected. If you are not redirected, please click Continue.";this.verifyInvalidText="The email verification code is invalid or has expired, please try again.";this.continueText="Continue";this.networkErrorMessage="An error occurred while verifying your email. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalVerifyEmailDemo(getProps(this)):usePortalVerifyEmail(getProps(this)),t=e.states,i=e.data,r=e.callbacks,n=e.content;return h$1(PortalVerifyEmailView,{states:t,data:i,callbacks:r,content:n})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,verified:true},data:{oobCode:"code"},callbacks:{failed:function(){console.log("failed")},gotoNextPage:function(){}},content:{verifySuccessText:e.verifySuccessText,verifyEmailText:e.verifyEmailText,verifyInvalidText:e.verifyInvalidText,continueText:e.continueText}},e.demoData||{},{arrayMerge:function(e,t){return t}})}export{PortalVerifyEmail as sqm_portal_verify_email};
1
+ var __awaiter=this&&this.__awaiter||function(e,t,i,r){function n(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r["throw"](e))}catch(e){a(e)}}function l(e){e.done?i(e.value):n(e.value).then(o,s)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return l([e,t])}}function l(o){if(r)throw new TypeError("Generator is already executing.");while(i)try{if(r=1,n&&(a=o[0]&2?n["return"]:o[0]?n["throw"]||((a=n["return"])&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;if(n=0,a)o=[o[0]&2,a.value];switch(o[0]){case 0:case 1:a=o;break;case 4:i.label++;return{value:o[1],done:false};case 5:i.label++;n=o[1];o=[0];continue;case 7:o=i.ops.pop();i.trys.pop();continue;default:if(!(a=i.trys,a=a.length>0&&a[a.length-1])&&(o[0]===6||o[0]===2)){i=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(o[0]===6&&i.label<a[1]){i.label=a[1];a=o;break}if(a&&i.label<a[2]){i.label=a[2];i.ops.push(o);break}if(a[2])i.ops.pop();i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e];n=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};import{r as registerInstance,h as h$1}from"./index-17b4da69.js";import{f as useEffect,n as h}from"./stencil-hooks.module-8032b139.js";import{Q,j as an,$ as $n,b as setUserIdentity,i as isDemo}from"./index.module-ba0ed7a8.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import"./JSS-67b5cff8.js";import{s as sanitizeUrlPath,g as getProps}from"./utils-334c1e34.js";import"./sqm-text-span-view-8d140661.js";import{P as PortalVerifyEmailView}from"./sqm-portal-verify-email-view-857a46e3.js";var SUBMITTED_CONTEXT="sq:verify-submitted";function setSubmitted(e){window[SUBMITTED_CONTEXT]=e}function usePortalVerifyEmail(e){var t=this;var i=e.nextPage,r=e.failedPage,n=e.verifySuccessText,a=e.verifyEmailText,o=e.verifyInvalidText,s=e.networkErrorMessage,l=e.continueText;var u,c,d,f,v,m,h,y,g;var p=window[SUBMITTED_CONTEXT];var b=Q();var x=(u=b===null||b===void 0?void 0:b.managedIdentity)===null||u===void 0?void 0:u.email;var T=an(),w=T[0],E=T[1],P=E.loading,S=E.data,I=E.errors;var _=new URLSearchParams($n.location.search);var j=_.get("oobCode");var k=_.get("email");var V=_.get("nextPage");var C=S===undefined&&I===undefined&&!!j;var U=localStorage.getItem("sq:user-identity");var D=!!(((c=b===null||b===void 0?void 0:b.managedIdentity)===null||c===void 0?void 0:c.emailVerified)||(S===null||S===void 0?void 0:S.verifyManagedIdentityEmail.success));var M=function(){return $n.push({pathname:r,search:_.toString()&&"?"+_.toString()})};var $=function(){_.delete("nextPage");var e=sanitizeUrlPath(V||i);$n.push(e.href)};var q=function(){console.debug("LOGOUT");setTimeout((function(){$();setUserIdentity(undefined);setSubmitted(false)}),3e3)};var N=function(){return __awaiter(t,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:setSubmitted(true);console.debug("SUBMITTED");return[4,w({oobCode:j})];case 1:e.sent();return[2]}}))}))};console.log({hasContext:U,userIdent:b,data:S,submitted:p,verified:D});useEffect((function(){if(!S&&!p&&j)N();if(p){console.debug("in submit condition");if(x&&x!==k){console.debug("email mismatch");q();return}if(D){console.debug("verified");setTimeout((function(){$();setSubmitted(false)}),3e3);return}}}),[p,S,x,j,k,N]);return{states:{loading:P||C,error:((m=(v=(f=(d=I===null||I===void 0?void 0:I.response)===null||d===void 0?void 0:d.errors)===null||f===void 0?void 0:f[0])===null||v===void 0?void 0:v.extensions)===null||m===void 0?void 0:m.message)||((g=(y=(h=I===null||I===void 0?void 0:I.response)===null||h===void 0?void 0:h.errors)===null||y===void 0?void 0:y[0])===null||g===void 0?void 0:g.message)||(I===null||I===void 0?void 0:I.message)&&s,verified:D},data:{oobCode:j},callbacks:{failed:M,gotoNextPage:$},content:{verifySuccessText:n,verifyEmailText:a,verifyInvalidText:o,continueText:l}}}var PortalVerifyEmail=function(){function e(e){registerInstance(this,e);this.ignored=true;this.nextPage="/";this.failedPage="/";this.verifyEmailText="Verify your email";this.verifySuccessText="Your email has been verified and you are being redirected. If you are not redirected, please click Continue.";this.verifyInvalidText="The email verification code is invalid or has expired, please try again.";this.continueText="Continue";this.networkErrorMessage="An error occurred while verifying your email. Please refresh the page and try again.";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=isDemo()?usePortalVerifyEmailDemo(getProps(this)):usePortalVerifyEmail(getProps(this)),t=e.states,i=e.data,r=e.callbacks,n=e.content;return h$1(PortalVerifyEmailView,{states:t,data:i,callbacks:r,content:n})};return e}();function usePortalVerifyEmailDemo(e){return cjs({states:{error:"",loading:false,verified:true},data:{oobCode:"code"},callbacks:{failed:function(){console.log("failed")},gotoNextPage:function(){}},content:{verifySuccessText:e.verifySuccessText,verifyEmailText:e.verifyEmailText,verifyInvalidText:e.verifyInvalidText,continueText:e.continueText}},e.demoData||{},{arrayMerge:function(e,t){return t}})}export{PortalVerifyEmail as sqm_portal_verify_email};