@stackframe/react 2.8.75 → 2.8.78

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 (83) hide show
  1. package/dist/components/credential-sign-up.js +2 -2
  2. package/dist/components/credential-sign-up.js.map +1 -1
  3. package/dist/components/magic-link-sign-in.js +3 -3
  4. package/dist/components/magic-link-sign-in.js.map +1 -1
  5. package/dist/components/oauth-button.d.ts +3 -1
  6. package/dist/components/oauth-button.d.ts.map +1 -1
  7. package/dist/components/oauth-button.js +4 -4
  8. package/dist/components/oauth-button.js.map +1 -1
  9. package/dist/components-page/stack-handler-client.js +1 -1
  10. package/dist/esm/components/credential-sign-up.js +1 -1
  11. package/dist/esm/components/credential-sign-up.js.map +1 -1
  12. package/dist/esm/components/magic-link-sign-in.js +1 -1
  13. package/dist/esm/components/magic-link-sign-in.js.map +1 -1
  14. package/dist/esm/components/oauth-button.d.ts +3 -1
  15. package/dist/esm/components/oauth-button.d.ts.map +1 -1
  16. package/dist/esm/components/oauth-button.js +3 -3
  17. package/dist/esm/components/oauth-button.js.map +1 -1
  18. package/dist/esm/components-page/stack-handler-client.js +1 -1
  19. package/dist/esm/generated/quetzal-translations.d.ts +2 -2
  20. package/dist/esm/lib/auth.d.ts +1 -7
  21. package/dist/esm/lib/auth.d.ts.map +1 -1
  22. package/dist/esm/lib/auth.js +2 -17
  23. package/dist/esm/lib/auth.js.map +1 -1
  24. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts +5 -22
  25. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  26. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +1 -6
  27. package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  28. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +12 -2
  29. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  30. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +131 -17
  31. package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  32. package/dist/esm/lib/stack-app/apps/implementations/common.js +2 -2
  33. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.d.ts +1 -1
  34. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.d.ts.map +1 -1
  35. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +5 -0
  36. package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  37. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts +0 -22
  38. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -1
  39. package/dist/esm/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  40. package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts +2 -2
  41. package/dist/esm/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
  42. package/dist/esm/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  43. package/dist/esm/lib/stack-app/projects/index.d.ts +3 -0
  44. package/dist/esm/lib/stack-app/projects/index.d.ts.map +1 -1
  45. package/dist/esm/lib/stack-app/projects/index.js +1 -0
  46. package/dist/esm/lib/stack-app/projects/index.js.map +1 -1
  47. package/dist/esm/lib/stack-app/users/index.d.ts +22 -1
  48. package/dist/esm/lib/stack-app/users/index.d.ts.map +1 -1
  49. package/dist/esm/lib/stack-app/users/index.js +12 -2
  50. package/dist/esm/lib/stack-app/users/index.js.map +1 -1
  51. package/dist/generated/quetzal-translations.d.ts +2 -2
  52. package/dist/lib/auth.d.ts +1 -7
  53. package/dist/lib/auth.d.ts.map +1 -1
  54. package/dist/lib/auth.js +1 -17
  55. package/dist/lib/auth.js.map +1 -1
  56. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts +5 -22
  57. package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
  58. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +1 -6
  59. package/dist/lib/stack-app/apps/implementations/admin-app-impl.js.map +1 -1
  60. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +12 -2
  61. package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
  62. package/dist/lib/stack-app/apps/implementations/client-app-impl.js +129 -15
  63. package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
  64. package/dist/lib/stack-app/apps/implementations/common.js +2 -2
  65. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts +1 -1
  66. package/dist/lib/stack-app/apps/implementations/server-app-impl.d.ts.map +1 -1
  67. package/dist/lib/stack-app/apps/implementations/server-app-impl.js +5 -0
  68. package/dist/lib/stack-app/apps/implementations/server-app-impl.js.map +1 -1
  69. package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts +0 -22
  70. package/dist/lib/stack-app/apps/interfaces/admin-app.d.ts.map +1 -1
  71. package/dist/lib/stack-app/apps/interfaces/admin-app.js.map +1 -1
  72. package/dist/lib/stack-app/apps/interfaces/client-app.d.ts +2 -2
  73. package/dist/lib/stack-app/apps/interfaces/client-app.d.ts.map +1 -1
  74. package/dist/lib/stack-app/apps/interfaces/client-app.js.map +1 -1
  75. package/dist/lib/stack-app/projects/index.d.ts +3 -0
  76. package/dist/lib/stack-app/projects/index.d.ts.map +1 -1
  77. package/dist/lib/stack-app/projects/index.js +1 -0
  78. package/dist/lib/stack-app/projects/index.js.map +1 -1
  79. package/dist/lib/stack-app/users/index.d.ts +22 -1
  80. package/dist/lib/stack-app/users/index.d.ts.map +1 -1
  81. package/dist/lib/stack-app/users/index.js +12 -2
  82. package/dist/lib/stack-app/users/index.js.map +1 -1
  83. package/package.json +4 -3
@@ -9,13 +9,13 @@ let _stackframe_stack_ui = require("@stackframe/stack-ui");
9
9
  let react = require("react");
10
10
  react = require_chunk.__toESM(react);
11
11
  let react_hook_form = require("react-hook-form");
12
- let ___index_js = require("../index.js");
13
12
  let ___lib_translations_js = require("../lib/translations.js");
14
13
  let react_jsx_runtime = require("react/jsx-runtime");
15
14
  let __elements_form_warning_js = require("./elements/form-warning.js");
16
15
  let _stackframe_stack_shared_dist_helpers_password = require("@stackframe/stack-shared/dist/helpers/password");
17
16
  let yup = require("yup");
18
17
  yup = require_chunk.__toESM(yup);
18
+ let ___lib_hooks_js = require("../lib/hooks.js");
19
19
 
20
20
  //#region src/components/credential-sign-up.tsx
21
21
  function CredentialSignUp(props) {
@@ -36,7 +36,7 @@ function CredentialSignUp(props) {
36
36
  null
37
37
  ], t("Passwords do not match")).nonEmpty(t("Please repeat your password")) }
38
38
  })) });
39
- const app = (0, ___index_js.useStackApp)();
39
+ const app = (0, ___lib_hooks_js.useStackApp)();
40
40
  const [loading, setLoading] = (0, react.useState)(false);
41
41
  const onSubmit = async (data) => {
42
42
  setLoading(true);
@@ -1 +1 @@
1
- {"version":3,"file":"credential-sign-up.js","names":["passwordSchema","Label","Input","FormWarningText","PasswordInput","Button"],"sources":["../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { getPasswordError } from \"@stackframe/stack-shared/dist/helpers/password\";\nimport { passwordSchema, strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronously, runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput } from \"@stackframe/stack-ui\";\nimport React, { useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"..\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nexport function CredentialSignUp(props: { noPasswordRepeat?: boolean }) {\n const { t } = useTranslation();\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email')),\n password: passwordSchema.defined().nonEmpty(t('Please enter your password')).test({\n name: 'is-valid-password',\n test: (value, ctx) => {\n const error = getPasswordError(value);\n if (error) {\n return ctx.createError({ message: error.message });\n } else {\n return true;\n }\n }\n }),\n ...(!props.noPasswordRepeat && {\n passwordRepeat: passwordSchema.nullable().oneOf([yup.ref('password'), \"\", null], t('Passwords do not match')).nonEmpty(t('Please repeat your password'))\n })\n });\n\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email, password } = data;\n const result = await app.signUpWithCredential({ email, password });\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n }\n } finally {\n setLoading(false);\n }\n };\n\n const registerPassword = register('password');\n const registerPasswordRepeat = register('passwordRepeat');\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input id=\"email\" type=\"email\" autoComplete=\"email\" {...register('email')}/>\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">{t('Password')}</Label>\n <PasswordInput\n id=\"password\"\n autoComplete=\"new-password\"\n {...registerPassword}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPassword.onChange(e));\n }}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n {\n !props.noPasswordRepeat && (\n <>\n <Label htmlFor=\"repeat-password\" className=\"mt-4 mb-1\">{t('Repeat Password')}</Label>\n <PasswordInput\n id=\"repeat-password\"\n {...registerPasswordRepeat}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPasswordRepeat.onChange(e));\n }}\n />\n <FormWarningText text={errors.passwordRepeat?.message?.toString()} />\n </>\n )\n }\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Sign Up')}\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAAuC;CACtE,MAAM,EAAE,kDAAsB;CAoB9B,MAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,UAAU,6CAAwB,EACvF,8GAnBuB;EACvB,0EAAyB,EAAE,6BAA6B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC;EAC1G,UAAUA,2DAAe,SAAS,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,KAAK;GAChF,MAAM;GACN,OAAO,OAAO,QAAQ;IACpB,MAAM,6EAAyB,MAAM;AACrC,QAAI,MACF,QAAO,IAAI,YAAY,EAAE,SAAS,MAAM,SAAS,CAAC;QAElD,QAAO;;GAGZ,CAAC;EACF,GAAI,CAAC,MAAM,oBAAoB,EAC7B,gBAAgBA,2DAAe,UAAU,CAAC,MAAM;GAAC,IAAI,IAAI,WAAW;GAAE;GAAI;GAAK,EAAE,EAAE,yBAAyB,CAAC,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACzJ;EACF,CAAC,CAG6B,EAC9B,CAAC;CACF,MAAM,oCAAmB;CACzB,MAAM,CAAC,SAAS,kCAAuB,MAAM;CAE7C,MAAM,WAAW,OAAO,SAAuC;AAC7D,aAAW,KAAK;AAChB,MAAI;GACF,MAAM,EAAE,OAAO,aAAa;GAC5B,MAAM,SAAS,MAAM,IAAI,qBAAqB;IAAE;IAAO;IAAU,CAAC;AAClE,OAAI,OAAO,WAAW,QACpB,UAAS,SAAS;IAAE,MAAM;IAAU,SAAS,OAAO,MAAM;IAAS,CAAC;YAE9D;AACR,cAAW,MAAM;;;CAIrB,MAAM,mBAAmB,SAAS,WAAW;CAC7C,MAAM,yBAAyB,SAAS,iBAAiB;AAEzD,QACE,4CAAC;EACC,WAAU;EACV,WAAU,mFAAgC,aAAa,SAAS,CAAC,EAAE,CAAC;EACpE;;GAEA,2CAACC;IAAM,SAAQ;IAAQ,WAAU;cAAQ,EAAE,QAAQ;KAAS;GAC5D,2CAACC;IAAM,IAAG;IAAQ,MAAK;IAAQ,cAAa;IAAQ,GAAI,SAAS,QAAQ;KAAG;GAC5E,2CAACC,8CAAgB,MAAM,OAAO,OAAO,SAAS,UAAU,GAAI;GAE5D,2CAACF;IAAM,SAAQ;IAAW,WAAU;cAAa,EAAE,WAAW;KAAS;GACvE,2CAACG;IACC,IAAG;IACH,cAAa;IACb,GAAI;IACJ,WAAW,MAA2C;AACpD,iBAAY,WAAW;AACvB,iBAAY,iBAAiB;AAC7B,yEAAkB,iBAAiB,SAAS,EAAE,CAAC;;KAEjD;GACF,2CAACD,8CAAgB,MAAM,OAAO,UAAU,SAAS,UAAU,GAAI;GAE7D,CAAC,MAAM,oBACL;IACE,2CAACF;KAAM,SAAQ;KAAkB,WAAU;eAAa,EAAE,kBAAkB;MAAS;IACrF,2CAACG;KACC,IAAG;KACH,GAAI;KACJ,WAAW,MAA2C;AACtD,kBAAY,WAAW;AACvB,kBAAY,iBAAiB;AAC7B,0EAAkB,uBAAuB,SAAS,EAAE,CAAC;;MAErD;IACF,2CAACD,8CAAgB,MAAM,OAAO,gBAAgB,SAAS,UAAU,GAAI;OACpE;GAIP,2CAACE;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,UAAU;KACN;;GACJ"}
1
+ {"version":3,"file":"credential-sign-up.js","names":["passwordSchema","Label","Input","FormWarningText","PasswordInput","Button"],"sources":["../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { getPasswordError } from \"@stackframe/stack-shared/dist/helpers/password\";\nimport { passwordSchema, strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronously, runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput } from \"@stackframe/stack-ui\";\nimport React, { useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nexport function CredentialSignUp(props: { noPasswordRepeat?: boolean }) {\n const { t } = useTranslation();\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email')),\n password: passwordSchema.defined().nonEmpty(t('Please enter your password')).test({\n name: 'is-valid-password',\n test: (value, ctx) => {\n const error = getPasswordError(value);\n if (error) {\n return ctx.createError({ message: error.message });\n } else {\n return true;\n }\n }\n }),\n ...(!props.noPasswordRepeat && {\n passwordRepeat: passwordSchema.nullable().oneOf([yup.ref('password'), \"\", null], t('Passwords do not match')).nonEmpty(t('Please repeat your password'))\n })\n });\n\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email, password } = data;\n const result = await app.signUpWithCredential({ email, password });\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n }\n } finally {\n setLoading(false);\n }\n };\n\n const registerPassword = register('password');\n const registerPasswordRepeat = register('passwordRepeat');\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input id=\"email\" type=\"email\" autoComplete=\"email\" {...register('email')}/>\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">{t('Password')}</Label>\n <PasswordInput\n id=\"password\"\n autoComplete=\"new-password\"\n {...registerPassword}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPassword.onChange(e));\n }}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n {\n !props.noPasswordRepeat && (\n <>\n <Label htmlFor=\"repeat-password\" className=\"mt-4 mb-1\">{t('Repeat Password')}</Label>\n <PasswordInput\n id=\"repeat-password\"\n {...registerPasswordRepeat}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPasswordRepeat.onChange(e));\n }}\n />\n <FormWarningText text={errors.passwordRepeat?.message?.toString()} />\n </>\n )\n }\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Sign Up')}\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAAuC;CACtE,MAAM,EAAE,kDAAsB;CAoB9B,MAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,UAAU,6CAAwB,EACvF,8GAnBuB;EACvB,0EAAyB,EAAE,6BAA6B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC;EAC1G,UAAUA,2DAAe,SAAS,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,KAAK;GAChF,MAAM;GACN,OAAO,OAAO,QAAQ;IACpB,MAAM,6EAAyB,MAAM;AACrC,QAAI,MACF,QAAO,IAAI,YAAY,EAAE,SAAS,MAAM,SAAS,CAAC;QAElD,QAAO;;GAGZ,CAAC;EACF,GAAI,CAAC,MAAM,oBAAoB,EAC7B,gBAAgBA,2DAAe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AACG;KACC,IAAG;KACH,GAAI;KACJ,WAAW,MAA2C;AACtD,kBAAY,WAAW;AACvB,kBAAY,iBAAiB;AAC7B,0EAAkB,uBAAuB,SAAS,EAAE,CAAC;;MAErD;IACF,2CAACD,8CAAgB,MAAM,OAAO,gBAAgB,SAAS,UAAU,GAAI;OACpE;GAIP,2CAACE;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,UAAU;KACN;;GACJ"}
@@ -8,10 +8,10 @@ let _stackframe_stack_shared_dist_utils_promises = require("@stackframe/stack-sh
8
8
  let _stackframe_stack_ui = require("@stackframe/stack-ui");
9
9
  let react = require("react");
10
10
  let react_hook_form = require("react-hook-form");
11
- let ___index_js = require("../index.js");
12
11
  let ___lib_translations_js = require("../lib/translations.js");
13
12
  let react_jsx_runtime = require("react/jsx-runtime");
14
13
  let __elements_form_warning_js = require("./elements/form-warning.js");
14
+ let ___lib_hooks_js = require("../lib/hooks.js");
15
15
  let _stackframe_stack_shared = require("@stackframe/stack-shared");
16
16
 
17
17
  //#region src/components/magic-link-sign-in.tsx
@@ -19,7 +19,7 @@ function OTP(props) {
19
19
  const { t } = (0, ___lib_translations_js.useTranslation)();
20
20
  const [otp, setOtp] = (0, react.useState)("");
21
21
  const [submitting, setSubmitting] = (0, react.useState)(false);
22
- const stackApp = (0, ___index_js.useStackApp)();
22
+ const stackApp = (0, ___lib_hooks_js.useStackApp)();
23
23
  const [error, setError] = (0, react.useState)(null);
24
24
  (0, react.useEffect)(() => {
25
25
  if (otp.length === 6 && !submitting) {
@@ -76,7 +76,7 @@ function OTP(props) {
76
76
  }
77
77
  function MagicLinkSignIn() {
78
78
  const { t } = (0, ___lib_translations_js.useTranslation)();
79
- const app = (0, ___index_js.useStackApp)();
79
+ const app = (0, ___lib_hooks_js.useStackApp)();
80
80
  const [loading, setLoading] = (0, react.useState)(false);
81
81
  const [nonce, setNonce] = (0, react.useState)(null);
82
82
  const { register, handleSubmit, setError, formState: { errors } } = (0, react_hook_form.useForm)({ resolver: (0, _hookform_resolvers_yup.yupResolver)((0, _stackframe_stack_shared_dist_schema_fields.yupObject)({ email: (0, _stackframe_stack_shared_dist_schema_fields.strictEmailSchema)(t("Please enter a valid email")).defined().nonEmpty(t("Please enter your email")) })) });
@@ -1 +1 @@
1
- {"version":3,"file":"magic-link-sign-in.js","names":["KnownErrors","Typography","InputOTP","InputOTPGroup","InputOTPSlot","FormWarningText","Button","Label","Input"],"sources":["../../src/components/magic-link-sign-in.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, InputOTP, InputOTPGroup, InputOTPSlot, Label, Typography } from \"@stackframe/stack-ui\";\nimport { useEffect, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"..\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nfunction OTP(props: {\n onBack: () => void,\n nonce: string,\n}) {\n const { t } = useTranslation();\n const [otp, setOtp] = useState<string>('');\n const [submitting, setSubmitting] = useState<boolean>(false);\n const stackApp = useStackApp();\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (otp.length === 6 && !submitting) {\n setSubmitting(true);\n // eslint-disable-next-line no-restricted-syntax\n stackApp.signInWithMagicLink(otp + props.nonce)\n .then(result => {\n if (result.status === 'error') {\n if (KnownErrors.VerificationCodeError.isInstance(result.error)) {\n setError(t(\"Invalid code\"));\n } else if (KnownErrors.InvalidTotpCode.isInstance(result.error)) {\n setError(t(\"Invalid TOTP code\"));\n } else {\n throw result.error;\n }\n }\n })\n .catch(e => console.error(e))\n .finally(() => {\n setSubmitting(false);\n setOtp('');\n });\n }\n if (otp.length !== 0 && otp.length !== 6) {\n setError(null);\n }\n }, [otp, submitting]);\n\n return (\n <div className=\"flex flex-col items-stretch stack-scope\">\n <form className='w-full flex flex-col items-center mb-2'>\n <Typography className='mb-2' >{t('Enter the code from your email')}</Typography>\n <InputOTP\n maxLength={6}\n type=\"text\"\n inputMode=\"text\"\n pattern={\"^[a-zA-Z0-9]+$\"}\n value={otp}\n onChange={value => setOtp(value.toUpperCase())}\n disabled={submitting}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} size='lg' />\n ))}\n </InputOTPGroup>\n </InputOTP>\n {error && <FormWarningText text={error} />}\n </form>\n <Button variant='link' onClick={props.onBack} className='underline'>{t('Cancel')}</Button>\n </div>\n );\n}\n\nexport function MagicLinkSignIn() {\n const { t } = useTranslation();\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n const [nonce, setNonce] = useState<string | null>(null);\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email'))\n });\n\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email } = data;\n const result = await app.sendMagicLinkEmail(email);\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n return;\n } else {\n setNonce(result.data.nonce);\n }\n } catch (e) {\n if (KnownErrors.SignUpNotEnabled.isInstance(e)) {\n setError('email', { type: 'manual', message: t('New account registration is not allowed') });\n } else {\n throw e;\n }\n } finally {\n setLoading(false);\n }\n };\n\n if (nonce) {\n return <OTP nonce={nonce} onBack={() => setNonce(null)} />;\n } else {\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input\n id=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Send email')}\n </Button>\n </form>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAS,IAAI,OAGV;CACD,MAAM,EAAE,kDAAsB;CAC9B,MAAM,CAAC,KAAK,8BAA2B,GAAG;CAC1C,MAAM,CAAC,YAAY,qCAAmC,MAAM;CAC5D,MAAM,yCAAwB;CAC9B,MAAM,CAAC,OAAO,gCAAoC,KAAK;AAEvD,4BAAgB;AACd,MAAI,IAAI,WAAW,KAAK,CAAC,YAAY;AACnC,iBAAc,KAAK;AAEnB,YAAS,oBAAoB,MAAM,MAAM,MAAM,CAC5C,MAAK,WAAU;AACd,QAAI,OAAO,WAAW,QACpB,KAAIA,qCAAY,sBAAsB,WAAW,OAAO,MAAM,CAC5D,UAAS,EAAE,eAAe,CAAC;aAClBA,qCAAY,gBAAgB,WAAW,OAAO,MAAM,CAC7D,UAAS,EAAE,oBAAoB,CAAC;QAEhC,OAAM,OAAO;KAGjB,CACD,OAAM,MAAK,QAAQ,MAAM,EAAE,CAAC,CAC5B,cAAc;AACb,kBAAc,MAAM;AACpB,WAAO,GAAG;KACV;;AAEN,MAAI,IAAI,WAAW,KAAK,IAAI,WAAW,EACrC,UAAS,KAAK;IAEf,CAAC,KAAK,WAAW,CAAC;AAErB,QACE,4CAAC;EAAI,WAAU;aACb,4CAAC;GAAK,WAAU;;IACd,2CAACC;KAAW,WAAU;eAAS,EAAE,iCAAiC;MAAc;IAChF,2CAACC;KACC,WAAW;KACX,MAAK;KACL,WAAU;KACV,SAAS;KACT,OAAO;KACP,WAAU,UAAS,OAAO,MAAM,aAAa,CAAC;KAC9C,UAAU;eAEV,2CAACC,gDACE;MA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,2CAACC;IACC,IAAG;IACH,MAAK;IACL,cAAa;IACb,GAAI,SAAS,QAAQ;KACrB;GACF,2CAACH,8CAAgB,MAAM,OAAO,OAAO,SAAS,UAAU,GAAI;GAE5D,2CAACC;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,aAAa;KACT;;GACJ"}
1
+ {"version":3,"file":"magic-link-sign-in.js","names":["KnownErrors","Typography","InputOTP","InputOTPGroup","InputOTPSlot","FormWarningText","Button","Label","Input"],"sources":["../../src/components/magic-link-sign-in.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, InputOTP, InputOTPGroup, InputOTPSlot, Label, Typography } from \"@stackframe/stack-ui\";\nimport { useEffect, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nfunction OTP(props: {\n onBack: () => void,\n nonce: string,\n}) {\n const { t } = useTranslation();\n const [otp, setOtp] = useState<string>('');\n const [submitting, setSubmitting] = useState<boolean>(false);\n const stackApp = useStackApp();\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (otp.length === 6 && !submitting) {\n setSubmitting(true);\n // eslint-disable-next-line no-restricted-syntax\n stackApp.signInWithMagicLink(otp + props.nonce)\n .then(result => {\n if (result.status === 'error') {\n if (KnownErrors.VerificationCodeError.isInstance(result.error)) {\n setError(t(\"Invalid code\"));\n } else if (KnownErrors.InvalidTotpCode.isInstance(result.error)) {\n setError(t(\"Invalid TOTP code\"));\n } else {\n throw result.error;\n }\n }\n })\n .catch(e => console.error(e))\n .finally(() => {\n setSubmitting(false);\n setOtp('');\n });\n }\n if (otp.length !== 0 && otp.length !== 6) {\n setError(null);\n }\n }, [otp, submitting]);\n\n return (\n <div className=\"flex flex-col items-stretch stack-scope\">\n <form className='w-full flex flex-col items-center mb-2'>\n <Typography className='mb-2' >{t('Enter the code from your email')}</Typography>\n <InputOTP\n maxLength={6}\n type=\"text\"\n inputMode=\"text\"\n pattern={\"^[a-zA-Z0-9]+$\"}\n value={otp}\n onChange={value => setOtp(value.toUpperCase())}\n disabled={submitting}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} size='lg' />\n ))}\n </InputOTPGroup>\n </InputOTP>\n {error && <FormWarningText text={error} />}\n </form>\n <Button variant='link' onClick={props.onBack} className='underline'>{t('Cancel')}</Button>\n </div>\n );\n}\n\nexport function MagicLinkSignIn() {\n const { t } = useTranslation();\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n const [nonce, setNonce] = useState<string | null>(null);\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email'))\n });\n\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email } = data;\n const result = await app.sendMagicLinkEmail(email);\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n return;\n } else {\n setNonce(result.data.nonce);\n }\n } catch (e) {\n if (KnownErrors.SignUpNotEnabled.isInstance(e)) {\n setError('email', { type: 'manual', message: t('New account registration is not allowed') });\n } else {\n throw e;\n }\n } finally {\n setLoading(false);\n }\n };\n\n if (nonce) {\n return <OTP nonce={nonce} onBack={() => setNonce(null)} />;\n } else {\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input\n id=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Send email')}\n </Button>\n </form>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAS,IAAI,OAGV;CACD,MAAM,EAAE,kDAAsB;CAC9B,MAAM,CAAC,KAAK,8BAA2B,GAAG;CAC1C,MAAM,CAAC,YAAY,qCAAmC,MAAM;CAC5D,MAAM,6CAAwB;CAC9B,MAAM,CAAC,OAAO,gCAAoC,KAAK;AAEvD,4BAAgB;AACd,MAAI,IAAI,WAAW,KAAK,CAAC,YAAY;AACnC,iBAAc,KAAK;AAEnB,YAAS,oBAAoB,MAAM,MAAM,MAAM,CAC5C,MAAK,WAAU;AACd,QAAI,OAAO,WAAW,QACpB,KAAIA,qCAAY,sBAAsB,WAAW,OAAO,MAAM,CAC5D,UAAS,EAAE,eAAe,CAAC;aAClBA,qCAAY,gBAAgB,WAAW,OAAO,MAAM,CAC7D,UAAS,EAAE,oBAAoB,CAAC;QAEhC,OAAM,OAAO;KAGjB,CACD,OAAM,MAAK,QAAQ,MAAM,EAAE,CAAC,CAC5B,cAAc;AACb,kBAAc,MAAM;AACpB,WAAO,GAAG;KACV;;AAEN,MAAI,IAAI,WAAW,KAAK,IAAI,WAAW,EACrC,UAAS,KAAK;IAEf,CAAC,KAAK,WAAW,CAAC;AAErB,QACE,4CAAC;EAAI,WAAU;aACb,4CAAC;GAAK,WAAU;;IACd,2CAACC;KAAW,WAAU;eAAS,EAAE,iCAAiC;MAAc;IAChF,2CAACC;KACC,WAAW;KACX,MAAK;KACL,WAAU;KACV,SAAS;KACT,OAAO;KACP,WAAU,UAAS,OAAO,MAAM,aAAa,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,WAAU;cAAQ,EAAE,QAAQ;KAAS;GAC5D,2CAACC;IACC,IAAG;IACH,MAAK;IACL,cAAa;IACb,GAAI,SAAS,QAAQ;KACrB;GACF,2CAACH,8CAAgB,MAAM,OAAO,OAAO,SAAS,UAAU,GAAI;GAE5D,2CAACC;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,aAAa;KACT;;GACJ"}
@@ -4,11 +4,13 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  declare function OAuthButton({
5
5
  provider,
6
6
  type,
7
- isMock
7
+ isMock,
8
+ onAuthenticate
8
9
  }: {
9
10
  provider: string;
10
11
  type: 'sign-in' | 'sign-up';
11
12
  isMock?: boolean;
13
+ onAuthenticate?: () => Promise<void>;
12
14
  }): react_jsx_runtime0.JSX.Element;
13
15
  //#endregion
14
16
  export { OAuthButton };
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-button.d.ts","names":[],"sources":["../../src/components/oauth-button.tsx"],"mappings":";;;iBAuBgB,WAAA,CAAA;EACd,QAAA;EACA,IAAA;EACA;AAAA;EAEA,QAAA;EACA,IAAA;EACA,MAAA;AAAA,IACD,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"oauth-button.d.ts","names":[],"sources":["../../src/components/oauth-button.tsx"],"mappings":";;;iBAuBgB,WAAA,CAAA;EACd,QAAA;EACA,IAAA;EACA,MAAA;EACA;AAAA;EAEA,QAAA;EACA,IAAA;EACA,MAAA;EACA,cAAA,SAAuB,OAAA;AAAA,IACxB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -4,9 +4,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_chunk = require('../chunk-BE-pF4vm.js');
5
5
  let _stackframe_stack_ui = require("@stackframe/stack-ui");
6
6
  let react = require("react");
7
- let ___index_js = require("../index.js");
8
7
  let ___lib_translations_js = require("../lib/translations.js");
9
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
+ let ___lib_hooks_js = require("../lib/hooks.js");
10
10
  let color = require("color");
11
11
  color = require_chunk.__toESM(color);
12
12
  let __use_in_iframe_js = require("./use-in-iframe.js");
@@ -17,9 +17,9 @@ const changeColor = (c, value) => {
17
17
  if (c.isLight()) value = -value;
18
18
  return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();
19
19
  };
20
- function OAuthButton({ provider, type, isMock = false }) {
20
+ function OAuthButton({ provider, type, isMock = false, onAuthenticate }) {
21
21
  const { t } = (0, ___lib_translations_js.useTranslation)();
22
- const stackApp = (0, ___index_js.useStackApp)();
22
+ const stackApp = (0, ___lib_hooks_js.useStackApp)();
23
23
  const styleId = (0, react.useId)().replaceAll(":", "-");
24
24
  const isIframe = (0, __use_in_iframe_js.useInIframe)();
25
25
  const [lastUsed, setLastUsed] = (0, react.useState)(null);
@@ -150,7 +150,7 @@ function OAuthButton({ provider, type, isMock = false }) {
150
150
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_stackframe_stack_ui.Button, {
151
151
  onClick: async () => {
152
152
  localStorage.setItem("_STACK_AUTH.lastUsed", provider);
153
- await stackApp.signInWithOAuth(provider);
153
+ await (onAuthenticate ? onAuthenticate() : stackApp.signInWithOAuth(provider));
154
154
  },
155
155
  className: `stack-oauth-button-${styleId} stack-scope relative w-full`,
156
156
  disabled: isIframe,
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-button.js","names":["BrandIcons","SimpleTooltip","Button"],"sources":["../../src/components/oauth-button.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { BrandIcons, Button, SimpleTooltip } from '@stackframe/stack-ui';\nimport Color, { ColorInstance } from 'color';\nimport { useEffect, useId, useState } from 'react';\nimport { useStackApp } from '..';\nimport { useTranslation } from '../lib/translations';\nimport { useInIframe } from './use-in-iframe';\n\nconst iconSize = 22;\n\nconst changeColor = (c: ColorInstance, value: number) => {\n if (c.isLight()) {\n value = -value;\n }\n return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();\n};\n\nexport function OAuthButton({\n provider,\n type,\n isMock = false,\n}: {\n provider: string,\n type: 'sign-in' | 'sign-up',\n isMock?: boolean,\n}) {\n const { t } = useTranslation();\n const stackApp = useStackApp();\n const styleId = useId().replaceAll(':', '-');\n const isIframe = useInIframe();\n\n const [lastUsed, setLastUsed] = useState<string | null>(null);\n useEffect(() => {\n setLastUsed(localStorage.getItem('_STACK_AUTH.lastUsed'));\n }, []);\n\n let style : {\n backgroundColor?: string,\n textColor?: string,\n name: string,\n icon: JSX.Element | null,\n border?: string,\n };\n switch (provider) {\n case 'google': {\n style = {\n backgroundColor: '#fff',\n textColor: '#000',\n name: 'Google',\n border: '1px solid #ddd',\n icon: <BrandIcons.Google iconSize={iconSize} />,\n };\n break;\n }\n case 'github': {\n style = {\n backgroundColor: '#111',\n textColor: '#fff',\n border: '1px solid #333',\n name: 'GitHub',\n icon: <BrandIcons.GitHub iconSize={iconSize} />,\n };\n break;\n }\n case 'facebook': {\n style = {\n backgroundColor: '#1877F2',\n textColor: '#fff',\n name: 'Facebook',\n icon: <BrandIcons.Facebook iconSize={iconSize} />,\n };\n break;\n }\n case 'microsoft': {\n style = {\n backgroundColor: '#2f2f2f',\n textColor: '#fff',\n name: 'Microsoft',\n icon: <BrandIcons.Microsoft iconSize={iconSize} />,\n };\n break;\n }\n case 'spotify': {\n style = {\n backgroundColor: '#1DB954',\n textColor: '#fff',\n name: 'Spotify',\n icon: <BrandIcons.Spotify iconSize={iconSize} />,\n };\n break;\n }\n case 'discord': {\n style = {\n backgroundColor: '#5865F2',\n textColor: '#fff',\n name: 'Discord',\n icon: <BrandIcons.Discord iconSize={iconSize} />,\n };\n break;\n }\n case 'gitlab': {\n style = {\n backgroundColor: \"#111\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Gitlab\",\n icon: <BrandIcons.Gitlab iconSize={iconSize} />,\n };\n break;\n }\n case 'apple': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Apple\",\n icon: <BrandIcons.Apple iconSize={iconSize} />,\n };\n break;\n }\n case \"bitbucket\": {\n style = {\n backgroundColor: \"#fff\",\n textColor: \"#000\",\n border: \"1px solid #ddd\",\n name: \"Bitbucket\",\n icon: <BrandIcons.Bitbucket iconSize={iconSize} />,\n };\n break;\n }\n case 'linkedin': {\n style = {\n backgroundColor: \"#0073b1\",\n textColor: \"#fff\",\n name: \"LinkedIn\",\n icon: <BrandIcons.LinkedIn iconSize={iconSize} />,\n };\n break;\n }\n case 'x': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n name: \"X\",\n icon: <BrandIcons.X iconSize={iconSize} />,\n };\n break;\n }\n case 'twitch': {\n style = {\n backgroundColor: \"#6441a5\",\n textColor: \"#fff\",\n name: \"Twitch\",\n icon: <BrandIcons.Twitch iconSize={iconSize} />,\n };\n break;\n }\n default: {\n style = {\n name: provider,\n icon: null,\n };\n }\n }\n\n const styleSheet = `\n .stack-oauth-button-${styleId} {\n background-color: ${style.backgroundColor} !important;\n color: ${style.textColor} !important;\n border: ${style.border} !important;\n }\n .stack-oauth-button-${styleId}:hover {\n background-color: ${changeColor(Color(style.backgroundColor), 10)} !important;\n }\n `;\n\n return (\n <>\n <style>{styleSheet}</style>\n <SimpleTooltip\n disabled={!isIframe}\n tooltip={isIframe ? \"This auth provider is not supported in an iframe for security reasons.\" : undefined}\n className='stack-scope w-full inline-flex'\n >\n <Button\n onClick={async () => {\n localStorage.setItem('_STACK_AUTH.lastUsed', provider);\n await stackApp.signInWithOAuth(provider);\n }}\n className={`stack-oauth-button-${styleId} stack-scope relative w-full`}\n disabled={isIframe}\n >\n {!isMock && lastUsed === provider && (\n <span className=\"absolute -top-2 -right-2 bg-blue-500 text-white text-xs px-2 py-1 rounded-md\">\n last\n </span>\n )}\n <div className='flex items-center w-full gap-4'>\n {style.icon}\n <span className='flex-1'>\n {type === 'sign-up' ?\n t('Sign up with {provider}', { provider: style.name }) :\n t('Sign in with {provider}', { provider: style.name })\n }\n </span>\n </div>\n </Button>\n </SimpleTooltip>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,WAAW;AAEjB,MAAM,eAAe,GAAkB,UAAkB;AACvD,KAAI,EAAE,SAAS,CACb,SAAQ,CAAC;AAEX,QAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,UAAU;;AAG1E,SAAgB,YAAY,EAC1B,UACA,MACA,SAAS,SAKR;CACD,MAAM,EAAE,kDAAsB;CAC9B,MAAM,yCAAwB;CAC9B,MAAM,4BAAiB,CAAC,WAAW,KAAK,IAAI;CAC5C,MAAM,gDAAwB;CAE9B,MAAM,CAAC,UAAU,mCAAuC,KAAK;AAC7D,4BAAgB;AACd,cAAY,aAAa,QAAQ,uBAAuB,CAAC;IACxD,EAAE,CAAC;CAEN,IAAI;AAOJ,SAAQ,UAAR;EACE,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,QAAQ;IACR,MAAM,2CAACA,gCAAW,UAAiB,WAAY;IAChD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,QAAQ;IACR,MAAM;IACN,MAAM,2CAACA,gCAAW,UAAiB,WAAY;IAChD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,2CAACA,gCAAW,YAAmB,WAAY;IAClD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,2CAACA,gCAAW,aAAoB,WAAY;IACnD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MA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GAE1C,WAAW,sBAAsB,QAAQ;GACzC,UAAU;cAET,CAAC,UAAU,aAAa,YACvB,2CAAC;IAAK,WAAU;cAA+E;KAExF,EAET,4CAAC;IAAI,WAAU;eACZ,MAAM,MACP,2CAAC;KAAK,WAAU;eACb,SAAS,YACV,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC,GACtD,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC;MAEjD;KACH;IACC;GACK,IACf"}
1
+ {"version":3,"file":"oauth-button.js","names":["BrandIcons","SimpleTooltip","Button"],"sources":["../../src/components/oauth-button.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { BrandIcons, Button, SimpleTooltip } from '@stackframe/stack-ui';\nimport Color, { ColorInstance } from 'color';\nimport { useEffect, useId, useState } from 'react';\nimport { useStackApp } from '../lib/hooks';\nimport { useTranslation } from '../lib/translations';\nimport { useInIframe } from './use-in-iframe';\n\nconst iconSize = 22;\n\nconst changeColor = (c: ColorInstance, value: number) => {\n if (c.isLight()) {\n value = -value;\n }\n return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();\n};\n\nexport function OAuthButton({\n provider,\n type,\n isMock = false,\n onAuthenticate,\n}: {\n provider: string,\n type: 'sign-in' | 'sign-up',\n isMock?: boolean,\n onAuthenticate?: () => Promise<void>,\n}) {\n const { t } = useTranslation();\n const stackApp = useStackApp();\n const styleId = useId().replaceAll(':', '-');\n const isIframe = useInIframe();\n\n const [lastUsed, setLastUsed] = useState<string | null>(null);\n useEffect(() => {\n setLastUsed(localStorage.getItem('_STACK_AUTH.lastUsed'));\n }, []);\n\n let style : {\n backgroundColor?: string,\n textColor?: string,\n name: string,\n icon: JSX.Element | null,\n border?: string,\n };\n switch (provider) {\n case 'google': {\n style = {\n backgroundColor: '#fff',\n textColor: '#000',\n name: 'Google',\n border: '1px solid #ddd',\n icon: <BrandIcons.Google iconSize={iconSize} />,\n };\n break;\n }\n case 'github': {\n style = {\n backgroundColor: '#111',\n textColor: '#fff',\n border: '1px solid #333',\n name: 'GitHub',\n icon: <BrandIcons.GitHub iconSize={iconSize} />,\n };\n break;\n }\n case 'facebook': {\n style = {\n backgroundColor: '#1877F2',\n textColor: '#fff',\n name: 'Facebook',\n icon: <BrandIcons.Facebook iconSize={iconSize} />,\n };\n break;\n }\n case 'microsoft': {\n style = {\n backgroundColor: '#2f2f2f',\n textColor: '#fff',\n name: 'Microsoft',\n icon: <BrandIcons.Microsoft iconSize={iconSize} />,\n };\n break;\n }\n case 'spotify': {\n style = {\n backgroundColor: '#1DB954',\n textColor: '#fff',\n name: 'Spotify',\n icon: <BrandIcons.Spotify iconSize={iconSize} />,\n };\n break;\n }\n case 'discord': {\n style = {\n backgroundColor: '#5865F2',\n textColor: '#fff',\n name: 'Discord',\n icon: <BrandIcons.Discord iconSize={iconSize} />,\n };\n break;\n }\n case 'gitlab': {\n style = {\n backgroundColor: \"#111\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Gitlab\",\n icon: <BrandIcons.Gitlab iconSize={iconSize} />,\n };\n break;\n }\n case 'apple': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Apple\",\n icon: <BrandIcons.Apple iconSize={iconSize} />,\n };\n break;\n }\n case \"bitbucket\": {\n style = {\n backgroundColor: \"#fff\",\n textColor: \"#000\",\n border: \"1px solid #ddd\",\n name: \"Bitbucket\",\n icon: <BrandIcons.Bitbucket iconSize={iconSize} />,\n };\n break;\n }\n case 'linkedin': {\n style = {\n backgroundColor: \"#0073b1\",\n textColor: \"#fff\",\n name: \"LinkedIn\",\n icon: <BrandIcons.LinkedIn iconSize={iconSize} />,\n };\n break;\n }\n case 'x': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n name: \"X\",\n icon: <BrandIcons.X iconSize={iconSize} />,\n };\n break;\n }\n case 'twitch': {\n style = {\n backgroundColor: \"#6441a5\",\n textColor: \"#fff\",\n name: \"Twitch\",\n icon: <BrandIcons.Twitch iconSize={iconSize} />,\n };\n break;\n }\n default: {\n style = {\n name: provider,\n icon: null,\n };\n }\n }\n\n const styleSheet = `\n .stack-oauth-button-${styleId} {\n background-color: ${style.backgroundColor} !important;\n color: ${style.textColor} !important;\n border: ${style.border} !important;\n }\n .stack-oauth-button-${styleId}:hover {\n background-color: ${changeColor(Color(style.backgroundColor), 10)} !important;\n }\n `;\n\n return (\n <>\n <style>{styleSheet}</style>\n <SimpleTooltip\n disabled={!isIframe}\n tooltip={isIframe ? \"This auth provider is not supported in an iframe for security reasons.\" : undefined}\n className='stack-scope w-full inline-flex'\n >\n <Button\n onClick={async () => {\n localStorage.setItem('_STACK_AUTH.lastUsed', provider);\n await (onAuthenticate ? onAuthenticate() : stackApp.signInWithOAuth(provider));\n }}\n className={`stack-oauth-button-${styleId} stack-scope relative w-full`}\n disabled={isIframe}\n >\n {!isMock && lastUsed === provider && (\n <span className=\"absolute -top-2 -right-2 bg-blue-500 text-white text-xs px-2 py-1 rounded-md\">\n last\n </span>\n )}\n <div className='flex items-center w-full gap-4'>\n {style.icon}\n <span className='flex-1'>\n {type === 'sign-up' ?\n t('Sign up with {provider}', { provider: style.name }) :\n t('Sign in with {provider}', { provider: style.name })\n }\n </span>\n </div>\n </Button>\n </SimpleTooltip>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,WAAW;AAEjB,MAAM,eAAe,GAAkB,UAAkB;AACvD,KAAI,EAAE,SAAS,CACb,SAAQ,CAAC;AAEX,QAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,UAAU;;AAG1E,SAAgB,YAAY,EAC1B,UACA,MACA,SAAS,OACT,kBAMC;CACD,MAAM,EAAE,kDAAsB;CAC9B,M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2CAACA,gCAAW,aAAoB,WAAY;IACnD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,2CAACA,gCAAW,YAAmB,WAAY;IAClD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,2CAACA,gCAAW,KAAY,WAAY;IAC3C;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,2CAACA,gCAAW,UAAiB,WAAY;IAChD;AACD;EAEF,QACE,SAAQ;GACN,MAAM;GACN,MAAM;GACP;;AAeL,QACE,qFACE,2CAAC,qBAbc;0BACK,QAAQ;0BACR,MAAM,gBAAgB;eACjC,MAAM,UAAU;gBACf,MAAM,OAAO;;0BAEH,QAAQ;0BACR,+BAAkB,MAAM,gBAAgB,EAAE,GAAG,CAAC;;MAMvC,EAC3B,2CAACC;EACC,UAAU,CAAC;EACX,SAAS,WAAW,2EAA2E;EAC/F,WAAU;YAEV,4CAACC;GACC,SAAS,YAAY;AACnB,iBAAa,QAAQ,wBAAwB,SAAS;AACtD,WAAO,iBAAiB,gBAAgB,GAAG,SAAS,gBAAgB,SAAS;;GAE/E,WAAW,sBAAsB,QAAQ;GACzC,UAAU;cAET,CAAC,UAAU,aAAa,YACvB,2CAAC;IAAK,WAAU;cAA+E;KAExF,EAET,4CAAC;IAAI,WAAU;eACZ,MAAM,MACP,2CAAC;KAAK,WAAU;eACb,SAAS,YACV,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC,GACtD,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC;MAEjD;KACH;IACC;GACK,IACf"}
@@ -7,8 +7,8 @@ let react = require("react");
7
7
  let ___index_js = require("../index.js");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
9
  let ___lib_hooks_js = require("../lib/hooks.js");
10
- let _stackframe_stack_shared_dist_utils_objects = require("@stackframe/stack-shared/dist/utils/objects");
11
10
  let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
11
+ let _stackframe_stack_shared_dist_utils_objects = require("@stackframe/stack-shared/dist/utils/objects");
12
12
  let _stackframe_stack_shared_dist_utils_urls = require("@stackframe/stack-shared/dist/utils/urls");
13
13
  let __account_settings_js = require("./account-settings.js");
14
14
  let __cli_auth_confirm_js = require("./cli-auth-confirm.js");
@@ -6,12 +6,12 @@ import { runAsynchronously, runAsynchronouslyWithAlert } from "@stackframe/stack
6
6
  import { Button, Input, Label, PasswordInput } from "@stackframe/stack-ui";
7
7
  import React, { useState } from "react";
8
8
  import { useForm } from "react-hook-form";
9
- import { useStackApp } from "../index.js";
10
9
  import { useTranslation } from "../lib/translations.js";
11
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
11
  import { FormWarningText } from "./elements/form-warning.js";
13
12
  import { getPasswordError } from "@stackframe/stack-shared/dist/helpers/password";
14
13
  import * as yup from "yup";
14
+ import { useStackApp } from "../lib/hooks.js";
15
15
 
16
16
  //#region src/components/credential-sign-up.tsx
17
17
  function CredentialSignUp(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"credential-sign-up.js","names":[],"sources":["../../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { getPasswordError } from \"@stackframe/stack-shared/dist/helpers/password\";\nimport { passwordSchema, strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronously, runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput } from \"@stackframe/stack-ui\";\nimport React, { useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"..\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nexport function CredentialSignUp(props: { noPasswordRepeat?: boolean }) {\n const { t } = useTranslation();\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email')),\n password: passwordSchema.defined().nonEmpty(t('Please enter your password')).test({\n name: 'is-valid-password',\n test: (value, ctx) => {\n const error = getPasswordError(value);\n if (error) {\n return ctx.createError({ message: error.message });\n } else {\n return true;\n }\n }\n }),\n ...(!props.noPasswordRepeat && {\n passwordRepeat: passwordSchema.nullable().oneOf([yup.ref('password'), \"\", null], t('Passwords do not match')).nonEmpty(t('Please repeat your password'))\n })\n });\n\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email, password } = data;\n const result = await app.signUpWithCredential({ email, password });\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n }\n } finally {\n setLoading(false);\n }\n };\n\n const registerPassword = register('password');\n const registerPasswordRepeat = register('passwordRepeat');\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input id=\"email\" type=\"email\" autoComplete=\"email\" {...register('email')}/>\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">{t('Password')}</Label>\n <PasswordInput\n id=\"password\"\n autoComplete=\"new-password\"\n {...registerPassword}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPassword.onChange(e));\n }}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n {\n !props.noPasswordRepeat && (\n <>\n <Label htmlFor=\"repeat-password\" className=\"mt-4 mb-1\">{t('Repeat Password')}</Label>\n <PasswordInput\n id=\"repeat-password\"\n {...registerPasswordRepeat}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPasswordRepeat.onChange(e));\n }}\n />\n <FormWarningText text={errors.passwordRepeat?.message?.toString()} />\n </>\n )\n }\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Sign Up')}\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAAuC;CACtE,MAAM,EAAE,MAAM,gBAAgB;CAoB9B,MAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,UAAU,gBAAgB,QAAQ,EACvF,UAAU,YAnBG,UAAU;EACvB,OAAO,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC;EAC1G,UAAU,eAAe,SAAS,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,KAAK;GAChF,MAAM;GACN,OAAO,OAAO,QAAQ;IACpB,MAAM,QAAQ,iBAAiB,MAAM;AACrC,QAAI,MACF,QAAO,IAAI,YAAY,EAAE,SAAS,MAAM,SAAS,CAAC;QAElD,QAAO;;GAGZ,CAAC;EACF,GAAI,CAAC,MAAM,oBAAoB,EAC7B,gBAAgB,eAAe,UAAU,CAAC,MAAM;GAAC,IAAI,IAAI,WAAW;GAAE;GAAI;GAAK,EAAE,EAAE,yBAAyB,CAAC,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACzJ;EACF,CAAC,CAG6B,EAC9B,CAAC;CACF,MAAM,MAAM,aAAa;CACzB,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAE7C,MAAM,WAAW,OAAO,SAAuC;AAC7D,aAAW,KAAK;AAChB,MAAI;GACF,MAAM,EAAE,OAAO,a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-sign-up.js","names":[],"sources":["../../../src/components/credential-sign-up.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { getPasswordError } from \"@stackframe/stack-shared/dist/helpers/password\";\nimport { passwordSchema, strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronously, runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, Label, PasswordInput } from \"@stackframe/stack-ui\";\nimport React, { useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nexport function CredentialSignUp(props: { noPasswordRepeat?: boolean }) {\n const { t } = useTranslation();\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email')),\n password: passwordSchema.defined().nonEmpty(t('Please enter your password')).test({\n name: 'is-valid-password',\n test: (value, ctx) => {\n const error = getPasswordError(value);\n if (error) {\n return ctx.createError({ message: error.message });\n } else {\n return true;\n }\n }\n }),\n ...(!props.noPasswordRepeat && {\n passwordRepeat: passwordSchema.nullable().oneOf([yup.ref('password'), \"\", null], t('Passwords do not match')).nonEmpty(t('Please repeat your password'))\n })\n });\n\n const { register, handleSubmit, setError, formState: { errors }, clearErrors } = useForm({\n resolver: yupResolver(schema)\n });\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email, password } = data;\n const result = await app.signUpWithCredential({ email, password });\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n }\n } finally {\n setLoading(false);\n }\n };\n\n const registerPassword = register('password');\n const registerPasswordRepeat = register('passwordRepeat');\n\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input id=\"email\" type=\"email\" autoComplete=\"email\" {...register('email')}/>\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Label htmlFor=\"password\" className=\"mt-4 mb-1\">{t('Password')}</Label>\n <PasswordInput\n id=\"password\"\n autoComplete=\"new-password\"\n {...registerPassword}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPassword.onChange(e));\n }}\n />\n <FormWarningText text={errors.password?.message?.toString()} />\n {\n !props.noPasswordRepeat && (\n <>\n <Label htmlFor=\"repeat-password\" className=\"mt-4 mb-1\">{t('Repeat Password')}</Label>\n <PasswordInput\n id=\"repeat-password\"\n {...registerPasswordRepeat}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) => {\n clearErrors('password');\n clearErrors('passwordRepeat');\n runAsynchronously(registerPasswordRepeat.onChange(e));\n }}\n />\n <FormWarningText text={errors.passwordRepeat?.message?.toString()} />\n </>\n )\n }\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Sign Up')}\n </Button>\n </form>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,OAAuC;CACtE,MAAM,EAAE,MAAM,gBAAgB;CAoB9B,MAAM,EAAE,UAAU,cAAc,UAAU,WAAW,EAAE,UAAU,gBAAgB,QAAQ,EACvF,UAAU,YAnBG,UAAU;EACvB,OAAO,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC;EAC1G,UAAU,eAAe,SAAS,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,KAAK;GAChF,MAAM;GACN,OAAO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AC7B,uBAAkB,iBAAiB,SAAS,EAAE,CAAC;;KAEjD;GACF,oBAAC,mBAAgB,MAAM,OAAO,UAAU,SAAS,UAAU,GAAI;GAE7D,CAAC,MAAM,oBACL;IACE,oBAAC;KAAM,SAAQ;KAAkB,WAAU;eAAa,EAAE,kBAAkB;MAAS;IACrF,oBAAC;KACC,IAAG;KACH,GAAI;KACJ,WAAW,MAA2C;AACtD,kBAAY,WAAW;AACvB,kBAAY,iBAAiB;AAC7B,wBAAkB,uBAAuB,SAAS,EAAE,CAAC;;MAErD;IACF,oBAAC,mBAAgB,MAAM,OAAO,gBAAgB,SAAS,UAAU,GAAI;OACpE;GAIP,oBAAC;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,UAAU;KACN;;GACJ"}
@@ -6,10 +6,10 @@ import { runAsynchronouslyWithAlert } from "@stackframe/stack-shared/dist/utils/
6
6
  import { Button, Input, InputOTP, InputOTPGroup, InputOTPSlot, Label, Typography } from "@stackframe/stack-ui";
7
7
  import { useEffect, useState } from "react";
8
8
  import { useForm } from "react-hook-form";
9
- import { useStackApp } from "../index.js";
10
9
  import { useTranslation } from "../lib/translations.js";
11
10
  import { jsx, jsxs } from "react/jsx-runtime";
12
11
  import { FormWarningText } from "./elements/form-warning.js";
12
+ import { useStackApp } from "../lib/hooks.js";
13
13
  import { KnownErrors } from "@stackframe/stack-shared";
14
14
 
15
15
  //#region src/components/magic-link-sign-in.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"magic-link-sign-in.js","names":[],"sources":["../../../src/components/magic-link-sign-in.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, InputOTP, InputOTPGroup, InputOTPSlot, Label, Typography } from \"@stackframe/stack-ui\";\nimport { useEffect, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"..\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nfunction OTP(props: {\n onBack: () => void,\n nonce: string,\n}) {\n const { t } = useTranslation();\n const [otp, setOtp] = useState<string>('');\n const [submitting, setSubmitting] = useState<boolean>(false);\n const stackApp = useStackApp();\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (otp.length === 6 && !submitting) {\n setSubmitting(true);\n // eslint-disable-next-line no-restricted-syntax\n stackApp.signInWithMagicLink(otp + props.nonce)\n .then(result => {\n if (result.status === 'error') {\n if (KnownErrors.VerificationCodeError.isInstance(result.error)) {\n setError(t(\"Invalid code\"));\n } else if (KnownErrors.InvalidTotpCode.isInstance(result.error)) {\n setError(t(\"Invalid TOTP code\"));\n } else {\n throw result.error;\n }\n }\n })\n .catch(e => console.error(e))\n .finally(() => {\n setSubmitting(false);\n setOtp('');\n });\n }\n if (otp.length !== 0 && otp.length !== 6) {\n setError(null);\n }\n }, [otp, submitting]);\n\n return (\n <div className=\"flex flex-col items-stretch stack-scope\">\n <form className='w-full flex flex-col items-center mb-2'>\n <Typography className='mb-2' >{t('Enter the code from your email')}</Typography>\n <InputOTP\n maxLength={6}\n type=\"text\"\n inputMode=\"text\"\n pattern={\"^[a-zA-Z0-9]+$\"}\n value={otp}\n onChange={value => setOtp(value.toUpperCase())}\n disabled={submitting}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} size='lg' />\n ))}\n </InputOTPGroup>\n </InputOTP>\n {error && <FormWarningText text={error} />}\n </form>\n <Button variant='link' onClick={props.onBack} className='underline'>{t('Cancel')}</Button>\n </div>\n );\n}\n\nexport function MagicLinkSignIn() {\n const { t } = useTranslation();\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n const [nonce, setNonce] = useState<string | null>(null);\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email'))\n });\n\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email } = data;\n const result = await app.sendMagicLinkEmail(email);\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n return;\n } else {\n setNonce(result.data.nonce);\n }\n } catch (e) {\n if (KnownErrors.SignUpNotEnabled.isInstance(e)) {\n setError('email', { type: 'manual', message: t('New account registration is not allowed') });\n } else {\n throw e;\n }\n } finally {\n setLoading(false);\n }\n };\n\n if (nonce) {\n return <OTP nonce={nonce} onBack={() => setNonce(null)} />;\n } else {\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input\n id=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Send email')}\n </Button>\n </form>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAS,IAAI,OAGV;CACD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,CAAC,KAAK,UAAU,SAAiB,GAAG;CAC1C,MAAM,CAAC,YAAY,iBAAiB,SAAkB,MAAM;CAC5D,MAAM,WAAW,aAAa;CAC9B,MAAM,CAAC,OAAO,YAAY,SAAwB,KAAK;AAEvD,iBAAgB;AACd,MAAI,IAAI,WAAW,KAAK,CAAC,YAAY;AACnC,iBAAc,KAAK;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C,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC,EAC3G,CAAC,CAG6B,EAC9B,CAAC;CAEF,MAAM,WAAW,OAAO,SAAuC;AAC7D,aAAW,KAAK;AAChB,MAAI;GACF,MAAM,EAAE,UAAU;GAClB,MAAM,SAAS,MAAM,IAAI,mBAAmB,MAAM;AAClD,OAAI,OAAO,WAAW,SAAS;AAC7B,aAAS,SAAS;KAAE,MAAM;KAAU,SAAS,OAAO,MAAM;KAAS,CAAC;AACpE;SAEA,UAAS,OAAO,KAAK,MAAM;WAEtB,GAAG;AACV,OAAI,YAAY,iBAAiB,WAAW,EAAE,CAC5C,UAAS,SAAS;IAAE,MAAM;IAAU,SAAS,EAAE,0CAA0C;IAAE,CAAC;OAE5F,OAAM;YAEA;AACR,cAAW,MAAM;;;AAIrB,KAAI,MACF,QAAO,oBAAC;EAAW;EAAO,cAAc,SAAS,KAAK;GAAI;KAE1D,QACE,qBAAC;EACC,WAAU;EACV,WAAU,MAAK,2BAA2B,aAAa,SAAS,CAAC,EAAE,CAAC;EACpE;;GAEA,oBAAC;IAAM,SAAQ;IAAQ,WAAU;cAAQ,EAAE,QAAQ;KAAS;GAC5D,oBAAC;IACC,IAAG;IACH,MAAK;IACL,cAAa;IACb,GAAI,SAAS,QAAQ;KACrB;GACF,oBAAC,mBAAgB,MAAM,OAAO,OAAO,SAAS,UAAU,GAAI;GAE5D,oBAAC;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,aAAa;KACT;;GACJ"}
1
+ {"version":3,"file":"magic-link-sign-in.js","names":[],"sources":["../../../src/components/magic-link-sign-in.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { yupResolver } from \"@hookform/resolvers/yup\";\nimport { KnownErrors } from \"@stackframe/stack-shared\";\nimport { strictEmailSchema, yupObject } from \"@stackframe/stack-shared/dist/schema-fields\";\nimport { runAsynchronouslyWithAlert } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport { Button, Input, InputOTP, InputOTPGroup, InputOTPSlot, Label, Typography } from \"@stackframe/stack-ui\";\nimport { useEffect, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as yup from \"yup\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { useTranslation } from \"../lib/translations\";\nimport { FormWarningText } from \"./elements/form-warning\";\n\nfunction OTP(props: {\n onBack: () => void,\n nonce: string,\n}) {\n const { t } = useTranslation();\n const [otp, setOtp] = useState<string>('');\n const [submitting, setSubmitting] = useState<boolean>(false);\n const stackApp = useStackApp();\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (otp.length === 6 && !submitting) {\n setSubmitting(true);\n // eslint-disable-next-line no-restricted-syntax\n stackApp.signInWithMagicLink(otp + props.nonce)\n .then(result => {\n if (result.status === 'error') {\n if (KnownErrors.VerificationCodeError.isInstance(result.error)) {\n setError(t(\"Invalid code\"));\n } else if (KnownErrors.InvalidTotpCode.isInstance(result.error)) {\n setError(t(\"Invalid TOTP code\"));\n } else {\n throw result.error;\n }\n }\n })\n .catch(e => console.error(e))\n .finally(() => {\n setSubmitting(false);\n setOtp('');\n });\n }\n if (otp.length !== 0 && otp.length !== 6) {\n setError(null);\n }\n }, [otp, submitting]);\n\n return (\n <div className=\"flex flex-col items-stretch stack-scope\">\n <form className='w-full flex flex-col items-center mb-2'>\n <Typography className='mb-2' >{t('Enter the code from your email')}</Typography>\n <InputOTP\n maxLength={6}\n type=\"text\"\n inputMode=\"text\"\n pattern={\"^[a-zA-Z0-9]+$\"}\n value={otp}\n onChange={value => setOtp(value.toUpperCase())}\n disabled={submitting}\n >\n <InputOTPGroup>\n {[0, 1, 2, 3, 4, 5].map((index) => (\n <InputOTPSlot key={index} index={index} size='lg' />\n ))}\n </InputOTPGroup>\n </InputOTP>\n {error && <FormWarningText text={error} />}\n </form>\n <Button variant='link' onClick={props.onBack} className='underline'>{t('Cancel')}</Button>\n </div>\n );\n}\n\nexport function MagicLinkSignIn() {\n const { t } = useTranslation();\n const app = useStackApp();\n const [loading, setLoading] = useState(false);\n const [nonce, setNonce] = useState<string | null>(null);\n\n const schema = yupObject({\n email: strictEmailSchema(t('Please enter a valid email')).defined().nonEmpty(t('Please enter your email'))\n });\n\n const { register, handleSubmit, setError, formState: { errors } } = useForm({\n resolver: yupResolver(schema)\n });\n\n const onSubmit = async (data: yup.InferType<typeof schema>) => {\n setLoading(true);\n try {\n const { email } = data;\n const result = await app.sendMagicLinkEmail(email);\n if (result.status === 'error') {\n setError('email', { type: 'manual', message: result.error.message });\n return;\n } else {\n setNonce(result.data.nonce);\n }\n } catch (e) {\n if (KnownErrors.SignUpNotEnabled.isInstance(e)) {\n setError('email', { type: 'manual', message: t('New account registration is not allowed') });\n } else {\n throw e;\n }\n } finally {\n setLoading(false);\n }\n };\n\n if (nonce) {\n return <OTP nonce={nonce} onBack={() => setNonce(null)} />;\n } else {\n return (\n <form\n className=\"flex flex-col items-stretch stack-scope\"\n onSubmit={e => runAsynchronouslyWithAlert(handleSubmit(onSubmit)(e))}\n noValidate\n >\n <Label htmlFor=\"email\" className=\"mb-1\">{t('Email')}</Label>\n <Input\n id=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n {...register('email')}\n />\n <FormWarningText text={errors.email?.message?.toString()} />\n\n <Button type=\"submit\" className=\"mt-6\" loading={loading}>\n {t('Send email')}\n </Button>\n </form>\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,SAAS,IAAI,OAGV;CACD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,CAAC,KAAK,UAAU,SAAiB,GAAG;CAC1C,MAAM,CAAC,YAAY,iBAAiB,SAAkB,MAAM;CAC5D,MAAM,WAAW,aAAa;CAC9B,MAAM,CAAC,OAAO,YAAY,SAAwB,KAAK;AAEvD,iBAAgB;AACd,MAAI,IAAI,W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AU,EACvB,OAAO,kBAAkB,EAAE,6BAA6B,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE,0BAA0B,CAAC,EAC3G,CAAC,CAG6B,EAC9B,CAAC;CAEF,MAAM,WAAW,OAAO,SAAuC;AAC7D,aAAW,KAAK;AAChB,MAAI;GACF,MAAM,EAAE,UAAU;GAClB,MAAM,SAAS,MAAM,IAAI,mBAAmB,MAAM;AAClD,OAAI,OAAO,WAAW,SAAS;AAC7B,aAAS,SAAS;KAAE,MAAM;KAAU,SAAS,OAAO,MAAM;KAAS,CAAC;AACpE;SAEA,UAAS,OAAO,KAAK,MAAM;WAEtB,GAAG;AACV,OAAI,YAAY,iBAAiB,WAAW,EAAE,CAC5C,UAAS,SAAS;IAAE,MAAM;IAAU,SAAS,EAAE,0CAA0C;IAAE,CAAC;OAE5F,OAAM;YAEA;AACR,cAAW,MAAM;;;AAIrB,KAAI,MACF,QAAO,oBAAC;EAAW;EAAO,cAAc,SAAS,KAAK;GAAI;KAE1D,QACE,qBAAC;EACC,WAAU;EACV,WAAU,MAAK,2BAA2B,aAAa,SAAS,CAAC,EAAE,CAAC;EACpE;;GAEA,oBAAC;IAAM,SAAQ;IAAQ,WAAU;cAAQ,EAAE,QAAQ;KAAS;GAC5D,oBAAC;IACC,IAAG;IACH,MAAK;IACL,cAAa;IACb,GAAI,SAAS,QAAQ;KACrB;GACF,oBAAC,mBAAgB,MAAM,OAAO,OAAO,SAAS,UAAU,GAAI;GAE5D,oBAAC;IAAO,MAAK;IAAS,WAAU;IAAgB;cAC7C,EAAE,aAAa;KACT;;GACJ"}
@@ -4,11 +4,13 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
4
  declare function OAuthButton({
5
5
  provider,
6
6
  type,
7
- isMock
7
+ isMock,
8
+ onAuthenticate
8
9
  }: {
9
10
  provider: string;
10
11
  type: 'sign-in' | 'sign-up';
11
12
  isMock?: boolean;
13
+ onAuthenticate?: () => Promise<void>;
12
14
  }): react_jsx_runtime0.JSX.Element;
13
15
  //#endregion
14
16
  export { OAuthButton };
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-button.d.ts","names":[],"sources":["../../../src/components/oauth-button.tsx"],"mappings":";;;iBAuBgB,WAAA,CAAA;EACd,QAAA;EACA,IAAA;EACA;AAAA;EAEA,QAAA;EACA,IAAA;EACA,MAAA;AAAA,IACD,kBAAA,CAAA,GAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"oauth-button.d.ts","names":[],"sources":["../../../src/components/oauth-button.tsx"],"mappings":";;;iBAuBgB,WAAA,CAAA;EACd,QAAA;EACA,IAAA;EACA,MAAA;EACA;AAAA;EAEA,QAAA;EACA,IAAA;EACA,MAAA;EACA,cAAA,SAAuB,OAAA;AAAA,IACxB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -2,9 +2,9 @@
2
2
 
3
3
  import { BrandIcons, Button, SimpleTooltip } from "@stackframe/stack-ui";
4
4
  import { useEffect, useId, useState } from "react";
5
- import { useStackApp } from "../index.js";
6
5
  import { useTranslation } from "../lib/translations.js";
7
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { useStackApp } from "../lib/hooks.js";
8
8
  import Color from "color";
9
9
  import { useInIframe } from "./use-in-iframe.js";
10
10
 
@@ -14,7 +14,7 @@ const changeColor = (c, value) => {
14
14
  if (c.isLight()) value = -value;
15
15
  return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();
16
16
  };
17
- function OAuthButton({ provider, type, isMock = false }) {
17
+ function OAuthButton({ provider, type, isMock = false, onAuthenticate }) {
18
18
  const { t } = useTranslation();
19
19
  const stackApp = useStackApp();
20
20
  const styleId = useId().replaceAll(":", "-");
@@ -147,7 +147,7 @@ function OAuthButton({ provider, type, isMock = false }) {
147
147
  children: /* @__PURE__ */ jsxs(Button, {
148
148
  onClick: async () => {
149
149
  localStorage.setItem("_STACK_AUTH.lastUsed", provider);
150
- await stackApp.signInWithOAuth(provider);
150
+ await (onAuthenticate ? onAuthenticate() : stackApp.signInWithOAuth(provider));
151
151
  },
152
152
  className: `stack-oauth-button-${styleId} stack-scope relative w-full`,
153
153
  disabled: isIframe,
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-button.js","names":[],"sources":["../../../src/components/oauth-button.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { BrandIcons, Button, SimpleTooltip } from '@stackframe/stack-ui';\nimport Color, { ColorInstance } from 'color';\nimport { useEffect, useId, useState } from 'react';\nimport { useStackApp } from '..';\nimport { useTranslation } from '../lib/translations';\nimport { useInIframe } from './use-in-iframe';\n\nconst iconSize = 22;\n\nconst changeColor = (c: ColorInstance, value: number) => {\n if (c.isLight()) {\n value = -value;\n }\n return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();\n};\n\nexport function OAuthButton({\n provider,\n type,\n isMock = false,\n}: {\n provider: string,\n type: 'sign-in' | 'sign-up',\n isMock?: boolean,\n}) {\n const { t } = useTranslation();\n const stackApp = useStackApp();\n const styleId = useId().replaceAll(':', '-');\n const isIframe = useInIframe();\n\n const [lastUsed, setLastUsed] = useState<string | null>(null);\n useEffect(() => {\n setLastUsed(localStorage.getItem('_STACK_AUTH.lastUsed'));\n }, []);\n\n let style : {\n backgroundColor?: string,\n textColor?: string,\n name: string,\n icon: JSX.Element | null,\n border?: string,\n };\n switch (provider) {\n case 'google': {\n style = {\n backgroundColor: '#fff',\n textColor: '#000',\n name: 'Google',\n border: '1px solid #ddd',\n icon: <BrandIcons.Google iconSize={iconSize} />,\n };\n break;\n }\n case 'github': {\n style = {\n backgroundColor: '#111',\n textColor: '#fff',\n border: '1px solid #333',\n name: 'GitHub',\n icon: <BrandIcons.GitHub iconSize={iconSize} />,\n };\n break;\n }\n case 'facebook': {\n style = {\n backgroundColor: '#1877F2',\n textColor: '#fff',\n name: 'Facebook',\n icon: <BrandIcons.Facebook iconSize={iconSize} />,\n };\n break;\n }\n case 'microsoft': {\n style = {\n backgroundColor: '#2f2f2f',\n textColor: '#fff',\n name: 'Microsoft',\n icon: <BrandIcons.Microsoft iconSize={iconSize} />,\n };\n break;\n }\n case 'spotify': {\n style = {\n backgroundColor: '#1DB954',\n textColor: '#fff',\n name: 'Spotify',\n icon: <BrandIcons.Spotify iconSize={iconSize} />,\n };\n break;\n }\n case 'discord': {\n style = {\n backgroundColor: '#5865F2',\n textColor: '#fff',\n name: 'Discord',\n icon: <BrandIcons.Discord iconSize={iconSize} />,\n };\n break;\n }\n case 'gitlab': {\n style = {\n backgroundColor: \"#111\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Gitlab\",\n icon: <BrandIcons.Gitlab iconSize={iconSize} />,\n };\n break;\n }\n case 'apple': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Apple\",\n icon: <BrandIcons.Apple iconSize={iconSize} />,\n };\n break;\n }\n case \"bitbucket\": {\n style = {\n backgroundColor: \"#fff\",\n textColor: \"#000\",\n border: \"1px solid #ddd\",\n name: \"Bitbucket\",\n icon: <BrandIcons.Bitbucket iconSize={iconSize} />,\n };\n break;\n }\n case 'linkedin': {\n style = {\n backgroundColor: \"#0073b1\",\n textColor: \"#fff\",\n name: \"LinkedIn\",\n icon: <BrandIcons.LinkedIn iconSize={iconSize} />,\n };\n break;\n }\n case 'x': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n name: \"X\",\n icon: <BrandIcons.X iconSize={iconSize} />,\n };\n break;\n }\n case 'twitch': {\n style = {\n backgroundColor: \"#6441a5\",\n textColor: \"#fff\",\n name: \"Twitch\",\n icon: <BrandIcons.Twitch iconSize={iconSize} />,\n };\n break;\n }\n default: {\n style = {\n name: provider,\n icon: null,\n };\n }\n }\n\n const styleSheet = `\n .stack-oauth-button-${styleId} {\n background-color: ${style.backgroundColor} !important;\n color: ${style.textColor} !important;\n border: ${style.border} !important;\n }\n .stack-oauth-button-${styleId}:hover {\n background-color: ${changeColor(Color(style.backgroundColor), 10)} !important;\n }\n `;\n\n return (\n <>\n <style>{styleSheet}</style>\n <SimpleTooltip\n disabled={!isIframe}\n tooltip={isIframe ? \"This auth provider is not supported in an iframe for security reasons.\" : undefined}\n className='stack-scope w-full inline-flex'\n >\n <Button\n onClick={async () => {\n localStorage.setItem('_STACK_AUTH.lastUsed', provider);\n await stackApp.signInWithOAuth(provider);\n }}\n className={`stack-oauth-button-${styleId} stack-scope relative w-full`}\n disabled={isIframe}\n >\n {!isMock && lastUsed === provider && (\n <span className=\"absolute -top-2 -right-2 bg-blue-500 text-white text-xs px-2 py-1 rounded-md\">\n last\n </span>\n )}\n <div className='flex items-center w-full gap-4'>\n {style.icon}\n <span className='flex-1'>\n {type === 'sign-up' ?\n t('Sign up with {provider}', { provider: style.name }) :\n t('Sign in with {provider}', { provider: style.name })\n }\n </span>\n </div>\n </Button>\n </SimpleTooltip>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,WAAW;AAEjB,MAAM,eAAe,GAAkB,UAAkB;AACvD,KAAI,EAAE,SAAS,CACb,SAAQ,CAAC;AAEX,QAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,UAAU;;AAG1E,SAAgB,YAAY,EAC1B,UACA,MACA,SAAS,SAKR;CACD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,WAAW,aAAa;CAC9B,MAAM,UAAU,OAAO,CAAC,WAAW,KAAK,IAAI;CAC5C,MAAM,WAAW,aAAa;CAE9B,MAAM,CAAC,UAAU,eAAe,SAAwB,KAAK;AAC7D,iBAAgB;AACd,cAAY,aAAa,QAAQ,uBAAuB,CAAC;IACxD,EAAE,CAAC;CAEN,IAAI;AAOJ,SAAQ,UAAR;EACE,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;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iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,oBAAC,WAAW,UAAiB,WAAY;IAChD;AACD;EAEF,QACE,SAAQ;GACN,MAAM;GACN,MAAM;GACP;;AAeL,QACE,4CACE,oBAAC,qBAbc;0BACK,QAAQ;0BACR,MAAM,gBAAgB;eACjC,MAAM,UAAU;gBACf,MAAM,OAAO;;0BAEH,QAAQ;0BACR,YAAY,MAAM,MAAM,gBAAgB,EAAE,GAAG,CAAC;;MAMvC,EAC3B,oBAAC;EACC,UAAU,CAAC;EACX,SAAS,WAAW,2EAA2E;EAC/F,WAAU;YAEV,qBAAC;GACC,SAAS,YAAY;AACnB,iBAAa,QAAQ,wBAAwB,SAAS;AACtD,UAAM,SAAS,gBAAgB,SAAS;;GAE1C,WAAW,sBAAsB,QAAQ;GACzC,UAAU;cAET,CAAC,UAAU,aAAa,YACvB,oBAAC;IAAK,WAAU;cAA+E;KAExF,EAET,qBAAC;IAAI,WAAU;eACZ,MAAM,MACP,oBAAC;KAAK,WAAU;eACb,SAAS,YACV,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC,GACtD,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC;MAEjD;KACH;IACC;GACK,IACf"}
1
+ {"version":3,"file":"oauth-button.js","names":[],"sources":["../../../src/components/oauth-button.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { BrandIcons, Button, SimpleTooltip } from '@stackframe/stack-ui';\nimport Color, { ColorInstance } from 'color';\nimport { useEffect, useId, useState } from 'react';\nimport { useStackApp } from '../lib/hooks';\nimport { useTranslation } from '../lib/translations';\nimport { useInIframe } from './use-in-iframe';\n\nconst iconSize = 22;\n\nconst changeColor = (c: ColorInstance, value: number) => {\n if (c.isLight()) {\n value = -value;\n }\n return c.hsl(c.hue(), c.saturationl(), c.lightness() + value).toString();\n};\n\nexport function OAuthButton({\n provider,\n type,\n isMock = false,\n onAuthenticate,\n}: {\n provider: string,\n type: 'sign-in' | 'sign-up',\n isMock?: boolean,\n onAuthenticate?: () => Promise<void>,\n}) {\n const { t } = useTranslation();\n const stackApp = useStackApp();\n const styleId = useId().replaceAll(':', '-');\n const isIframe = useInIframe();\n\n const [lastUsed, setLastUsed] = useState<string | null>(null);\n useEffect(() => {\n setLastUsed(localStorage.getItem('_STACK_AUTH.lastUsed'));\n }, []);\n\n let style : {\n backgroundColor?: string,\n textColor?: string,\n name: string,\n icon: JSX.Element | null,\n border?: string,\n };\n switch (provider) {\n case 'google': {\n style = {\n backgroundColor: '#fff',\n textColor: '#000',\n name: 'Google',\n border: '1px solid #ddd',\n icon: <BrandIcons.Google iconSize={iconSize} />,\n };\n break;\n }\n case 'github': {\n style = {\n backgroundColor: '#111',\n textColor: '#fff',\n border: '1px solid #333',\n name: 'GitHub',\n icon: <BrandIcons.GitHub iconSize={iconSize} />,\n };\n break;\n }\n case 'facebook': {\n style = {\n backgroundColor: '#1877F2',\n textColor: '#fff',\n name: 'Facebook',\n icon: <BrandIcons.Facebook iconSize={iconSize} />,\n };\n break;\n }\n case 'microsoft': {\n style = {\n backgroundColor: '#2f2f2f',\n textColor: '#fff',\n name: 'Microsoft',\n icon: <BrandIcons.Microsoft iconSize={iconSize} />,\n };\n break;\n }\n case 'spotify': {\n style = {\n backgroundColor: '#1DB954',\n textColor: '#fff',\n name: 'Spotify',\n icon: <BrandIcons.Spotify iconSize={iconSize} />,\n };\n break;\n }\n case 'discord': {\n style = {\n backgroundColor: '#5865F2',\n textColor: '#fff',\n name: 'Discord',\n icon: <BrandIcons.Discord iconSize={iconSize} />,\n };\n break;\n }\n case 'gitlab': {\n style = {\n backgroundColor: \"#111\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Gitlab\",\n icon: <BrandIcons.Gitlab iconSize={iconSize} />,\n };\n break;\n }\n case 'apple': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n border: \"1px solid #333\",\n name: \"Apple\",\n icon: <BrandIcons.Apple iconSize={iconSize} />,\n };\n break;\n }\n case \"bitbucket\": {\n style = {\n backgroundColor: \"#fff\",\n textColor: \"#000\",\n border: \"1px solid #ddd\",\n name: \"Bitbucket\",\n icon: <BrandIcons.Bitbucket iconSize={iconSize} />,\n };\n break;\n }\n case 'linkedin': {\n style = {\n backgroundColor: \"#0073b1\",\n textColor: \"#fff\",\n name: \"LinkedIn\",\n icon: <BrandIcons.LinkedIn iconSize={iconSize} />,\n };\n break;\n }\n case 'x': {\n style = {\n backgroundColor: \"#000\",\n textColor: \"#fff\",\n name: \"X\",\n icon: <BrandIcons.X iconSize={iconSize} />,\n };\n break;\n }\n case 'twitch': {\n style = {\n backgroundColor: \"#6441a5\",\n textColor: \"#fff\",\n name: \"Twitch\",\n icon: <BrandIcons.Twitch iconSize={iconSize} />,\n };\n break;\n }\n default: {\n style = {\n name: provider,\n icon: null,\n };\n }\n }\n\n const styleSheet = `\n .stack-oauth-button-${styleId} {\n background-color: ${style.backgroundColor} !important;\n color: ${style.textColor} !important;\n border: ${style.border} !important;\n }\n .stack-oauth-button-${styleId}:hover {\n background-color: ${changeColor(Color(style.backgroundColor), 10)} !important;\n }\n `;\n\n return (\n <>\n <style>{styleSheet}</style>\n <SimpleTooltip\n disabled={!isIframe}\n tooltip={isIframe ? \"This auth provider is not supported in an iframe for security reasons.\" : undefined}\n className='stack-scope w-full inline-flex'\n >\n <Button\n onClick={async () => {\n localStorage.setItem('_STACK_AUTH.lastUsed', provider);\n await (onAuthenticate ? onAuthenticate() : stackApp.signInWithOAuth(provider));\n }}\n className={`stack-oauth-button-${styleId} stack-scope relative w-full`}\n disabled={isIframe}\n >\n {!isMock && lastUsed === provider && (\n <span className=\"absolute -top-2 -right-2 bg-blue-500 text-white text-xs px-2 py-1 rounded-md\">\n last\n </span>\n )}\n <div className='flex items-center w-full gap-4'>\n {style.icon}\n <span className='flex-1'>\n {type === 'sign-up' ?\n t('Sign up with {provider}', { provider: style.name }) :\n t('Sign in with {provider}', { provider: style.name })\n }\n </span>\n </div>\n </Button>\n </SimpleTooltip>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAcA,MAAM,WAAW;AAEjB,MAAM,eAAe,GAAkB,UAAkB;AACvD,KAAI,EAAE,SAAS,CACb,SAAQ,CAAC;AAEX,QAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,WAAW,GAAG,MAAM,CAAC,UAAU;;AAG1E,SAAgB,YAAY,EAC1B,UACA,MACA,SAAS,OACT,kBAMC;CACD,MAAM,EAAE,MAAM,gBAAgB;CAC9B,MAAM,WAAW,aAAa;CAC9B,MAAM,UAAU,OAAO,CAAC,WAAW,KAAK,IAAI;CAC5C,MAAM,WAAW,aAAa;CAE9B,MAAM,CAAC,UAAU,eAAe,SAAwB,KAAK;AAC7D,iBAAgB;AACd,cAAY,aAAa,QAAQ,uBAAuB,CAAC;IACxD,EAAE,CAAC;CAEN,IAAI;AAOJ,SAAQ,UAAR;EACE,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,QAAQ;IACR,MAAM,oBAAC,WAAW,UAAiB,WAAY;IAChD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,QAAQ;IACR,MAAM;IACN,MAAM,oBAAC,WAAW,UAAiB,WAAY;IAChD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,oBAAC,WAAW,YAAmB,WAAY;IAClD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,oBAAC,WAAW,aAAoB,WAAY;IACnD;AACD;EAEF,KAAK;AACH,WAAQ;IACN,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,MAAM,oBAAC,WAAW,W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AE/E,WAAW,sBAAsB,QAAQ;GACzC,UAAU;cAET,CAAC,UAAU,aAAa,YACvB,oBAAC;IAAK,WAAU;cAA+E;KAExF,EAET,qBAAC;IAAI,WAAU;eACZ,MAAM,MACP,oBAAC;KAAK,WAAU;eACb,SAAS,YACV,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC,GACtD,EAAE,2BAA2B,EAAE,UAAU,MAAM,MAAM,CAAC;MAEjD;KACH;IACC;GACK,IACf"}
@@ -5,8 +5,8 @@ import { useMemo } from "react";
5
5
  import { SignIn, SignUp } from "../index.js";
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { useStackApp as useStackApp$1 } from "../lib/hooks.js";
8
- import { filterUndefined } from "@stackframe/stack-shared/dist/utils/objects";
9
8
  import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
9
+ import { filterUndefined } from "@stackframe/stack-shared/dist/utils/objects";
10
10
  import { getRelativePart } from "@stackframe/stack-shared/dist/utils/urls";
11
11
  import { AccountSettings } from "./account-settings.js";
12
12
  import { CliAuthConfirmation } from "./cli-auth-confirm.js";