{"version":3,"file":"OneTapError.mjs","sources":["../../../../../../../../../web/src/ui/components/organisms/OneTapError.tsx"],"sourcesContent":["/* eslint-disable lingui/no-unlocalized-strings -- messages are only shown in test environments */\n\nimport React from 'react';\n\nimport { Values } from '../../../utils/types';\nimport Typography from '../atoms/Typography';\n\nconst RedirectUrlsErrorMessage = ({ niceName, variableName }: { niceName: string; variableName: string }) => (\n  <Typography variant=\"body\" color=\"destructive\">\n    One Tap cannot render because there are no {niceName} set for this project so we are unable to verify the{' '}\n    <code>{variableName}</code>&nbsp; provided in the configuration. To set {niceName} for this project please\n    visit&nbsp;\n    <a href=\"https://stytch.com/dashboard/redirect-urls\">the Stytch dashboard.</a>&nbsp; For more information on why\n    this validation is necessary please visit&nbsp;\n    <a href=\"https://stytch.com/docs/api/url-validation\">https://stytch.com/docs/api/url-validation.</a>\n  </Typography>\n);\n\nexport const OneTapErrors = {\n  // These come from the Google GSI Client\n  OriginNotAllowedForClient: 'origin_not_allowed_for_client',\n  InvalidOAuthClient: 'invalid_client',\n  // These come from the API directly - err.error_type\n  NoConfiguredOAuthClient: 'oauth_config_not_found',\n  NoConfiguredLoginRedirectUrls: 'no_login_redirect_urls_set',\n  NoConfiguredSignupRedirectUrls: 'no_signup_redirect_urls_set',\n  DefaultProviderNotAllowed: 'default_provider_not_allowed',\n};\n\nexport type OneTapErrors = Values<typeof OneTapErrors>;\n\nexport const ErrorMessages = ({ error }: { error: OneTapErrors }) => {\n  switch (error) {\n    case OneTapErrors.OriginNotAllowedForClient:\n      return (\n        <Typography variant=\"body\" color=\"destructive\">\n          One Tap cannot render because the current host&nbsp;\n          <code>{window.location.host}</code> is not allowed for this project. Make sure to put your project&apos;s host\n          into the Google API console. When using localhost for development, you must add both&nbsp;\n          <code>http://localhost</code> and&nbsp;\n          <code>{`http://localhost:<port_number>`}</code>&nbsp; to the Authorized JavaScript origins box. You can learn\n          more&nbsp;\n          <a href=\"https://stytch.com/docs/sdks\">here.</a>\n        </Typography>\n      );\n    case OneTapErrors.InvalidOAuthClient:\n      return (\n        <Typography variant=\"body\" color=\"destructive\">\n          One Tap cannot render because the client ID configured for your project is not recognized by Google. &nbsp;\n          Please check that the client ID saved in{' '}\n          <a href=\"https://stytch.com/dashboard/oauth/google\">the Stytch Dashboard</a>&nbsp; matches the client ID in\n          your Google Cloud Console.\n        </Typography>\n      );\n    case OneTapErrors.NoConfiguredOAuthClient:\n      return (\n        <Typography variant=\"body\" color=\"destructive\">\n          One Tap cannot render because no Google OAuth client configuration could be found for this project. Please\n          make sure a client is configured in the&nbsp;\n          <a href=\"https://stytch.com/dashboard/oauth\">dashboard.</a>\n        </Typography>\n      );\n    case OneTapErrors.NoConfiguredLoginRedirectUrls:\n      return <RedirectUrlsErrorMessage niceName=\"login redirect URLs\" variableName=\"oauthOptions.loginRedirectURL\" />;\n    case OneTapErrors.NoConfiguredSignupRedirectUrls:\n      return <RedirectUrlsErrorMessage niceName=\"signup redirect URLs\" variableName=\"oauthOptions.signupRedirectURL\" />;\n    case OneTapErrors.DefaultProviderNotAllowed:\n      return (\n        <Typography variant=\"body\" color=\"destructive\">\n          One Tap cannot render because the Stytch Default OAuth Provider is not compatible with One Tap. Please\n          configure your own Google client in the&nbsp;\n          <a href=\"https://stytch.com/dashboard/oauth\">dashboard.</a>\n        </Typography>\n      );\n  }\n};\n"],"names":["OneTapErrors","OriginNotAllowedForClient","InvalidOAuthClient","NoConfiguredOAuthClient","NoConfiguredLoginRedirectUrls","NoConfiguredSignupRedirectUrls","DefaultProviderNotAllowed"],"mappings":";;;;MAkBaA,YAAAA,GAAe;;IAE1BC,yBAAAA,EAA2B,+BAAA;IAC3BC,kBAAAA,EAAoB,gBAAA;;IAEpBC,uBAAAA,EAAyB,wBAAA;IACzBC,6BAAAA,EAA+B,4BAAA;IAC/BC,8BAAAA,EAAgC,6BAAA;IAChCC,yBAAAA,EAA2B;AAC7B;;;;"}