{"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":["RedirectUrlsErrorMessage","niceName","variableName","React","Typography","variant","color","code","a","href","OneTapErrors","OriginNotAllowedForClient","InvalidOAuthClient","NoConfiguredOAuthClient","NoConfiguredLoginRedirectUrls","NoConfiguredSignupRedirectUrls","DefaultProviderNotAllowed","ErrorMessages","error","window","location","host"],"mappings":";;;AAOA,MAAMA,wBAAAA,GAA2B,CAAC,EAAEC,QAAQ,EAAEC,YAAY,EAA8C,iBACtGC,EAAA,CAAA,aAAA,CAACC,UAAAA,EAAAA;QAAWC,OAAAA,EAAQ,MAAA;QAAOC,KAAAA,EAAM;OAAc,6CAAA,EACDL,QAAAA,EAAS,wDAAqD,GAAA,g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