cauthy-auth 0.35.2 → 0.36.1

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.
package/dist/react.mjs CHANGED
@@ -767,6 +767,9 @@ var TEXTS = {
767
767
  checkEmail: "Almost there: open the link we sent to confirm your address \u2014 it signs you in.",
768
768
  backToSignIn: "Back to sign in",
769
769
  emailMeALink: "Email me a sign-in link",
770
+ linkHelp: "We will email you a link that signs you in, no password needed.",
771
+ sendMeTheLink: "Send me the link",
772
+ back: "Back",
770
773
  usePasskey: "Sign in with a passkey",
771
774
  codeFromMail: "Reading it on another device? Enter the code from the email.",
772
775
  signInLinkSent: "If that address has an account, a link to sign in is on its way.",
@@ -948,6 +951,9 @@ var TEXTS = {
948
951
  checkEmail: "Casi listo: abre el enlace que te enviamos para confirmar tu correo; te deja adentro.",
949
952
  backToSignIn: "Volver a entrar",
950
953
  emailMeALink: "Env\xEDame un enlace para entrar",
954
+ linkHelp: "Te enviamos un enlace al correo que te deja entrar, sin contrase\xF1a.",
955
+ sendMeTheLink: "Env\xEDame el enlace",
956
+ back: "Volver",
951
957
  usePasskey: "Entrar con una llave de acceso",
952
958
  codeFromMail: "\xBFLo est\xE1s leyendo en otro dispositivo? Escribe el c\xF3digo que trae el correo.",
953
959
  signInLinkSent: "Si ese correo tiene una cuenta, ya va en camino un enlace para entrar.",
@@ -1643,9 +1649,14 @@ function SignIn(props) {
1643
1649
  f.setError(null);
1644
1650
  return toCompany();
1645
1651
  }
1652
+ if (step === "link") {
1653
+ if (company?.enforced) return toCompany();
1654
+ if (f.check(checkEmail(email))) return sendLink();
1655
+ return;
1656
+ }
1646
1657
  if (step === "password" && !passwordOn) {
1647
1658
  if (company) return toCompany();
1648
- if (methods?.magicLink) return sendLink();
1659
+ if (methods?.magicLink && f.check(checkEmail(email))) return sendLink();
1649
1660
  return;
1650
1661
  }
1651
1662
  if (step === "password" && !f.check(checkEmail(email), checkPassword(password))) return;
@@ -1686,6 +1697,11 @@ function SignIn(props) {
1686
1697
  if (!r.ok) return f.setError(r.error);
1687
1698
  setStep("sent");
1688
1699
  };
1700
+ const openLink = () => {
1701
+ autofill.current?.abort();
1702
+ f.setError(null);
1703
+ setStep("link");
1704
+ };
1689
1705
  const general = f.error && !f.error.field ? f.error : null;
1690
1706
  const asksEmail = offers.email;
1691
1707
  if (step === "opening") return /* @__PURE__ */ jsx(Wrap, { f, as: "div", slot: "form", root: f.root, busy: true });
@@ -1699,11 +1715,27 @@ function SignIn(props) {
1699
1715
  ] });
1700
1716
  }
1701
1717
  if (step === "code") return /* @__PURE__ */ jsx(SecondStepForm, { f, auth });
1718
+ if (step === "link") {
1719
+ return /* @__PURE__ */ jsxs(Wrap, { f, as: "form", slot: "form", root: f.root, onSubmit: submit, noValidate: true, children: [
1720
+ general && /* @__PURE__ */ jsx(Say, { f, tone: "danger", children: f.say(general) }),
1721
+ /* @__PURE__ */ jsx(Note, { f, children: f.t.linkHelp }),
1722
+ /* @__PURE__ */ jsx(Field, { f, name: "email", type: "email", label: f.t.email, value: email, autoComplete: "username", required: true, onChange: setEmail }),
1723
+ challenge.node,
1724
+ /* @__PURE__ */ jsx(f.Button, { type: "submit", variant: "primary", loading: f.loading("link"), disabled: f.busy, className: f.cx("button"), children: f.t.sendMeTheLink }),
1725
+ /* @__PURE__ */ jsx(f.Button, { type: "button", variant: "secondary", disabled: f.busy, className: f.cx("providerButton"), onClick: () => {
1726
+ f.setError(null);
1727
+ setStep("password");
1728
+ }, children: f.t.back })
1729
+ ] });
1730
+ }
1731
+ const quickLink = methods?.magicLink === true && passwordOn;
1732
+ const quick = offers.passkey || (methods?.providers.length ?? 0) > 0 || quickLink;
1702
1733
  return /* @__PURE__ */ jsxs(Wrap, { f, as: "form", slot: "form", root: f.root, onSubmit: submit, noValidate: true, children: [
1703
1734
  general && /* @__PURE__ */ jsx(Say, { f, tone: "danger", children: f.say(general) }),
1704
- /* @__PURE__ */ jsx(ProviderButtons, { f, providers: methods?.providers ?? [], onPick: (id) => auth.signIn.social(id, { returnTo: props.returnTo }) }),
1705
1735
  offers.passkey && /* @__PURE__ */ jsx(f.Button, { type: "button", variant: "secondary", loading: f.loading("passkey"), disabled: f.busy, className: f.cx("providerButton"), onClick: () => void usePasskey(), children: f.t.usePasskey }),
1706
- asksEmail && ((methods?.providers.length ?? 0) > 0 || offers.passkey) && /* @__PURE__ */ jsx(Or, { f, children: f.t.orWithEmail }),
1736
+ /* @__PURE__ */ jsx(ProviderButtons, { f, providers: methods?.providers ?? [], onPick: (id) => auth.signIn.social(id, { returnTo: props.returnTo }) }),
1737
+ quickLink && /* @__PURE__ */ jsx(f.Button, { type: "button", variant: "secondary", disabled: f.busy, className: f.cx("providerButton"), onClick: openLink, children: f.t.emailMeALink }),
1738
+ asksEmail && quick && /* @__PURE__ */ jsx(Or, { f, children: f.t.orWithEmail }),
1707
1739
  asksEmail && /* @__PURE__ */ jsx(Field, { f, name: "email", type: "email", label: f.t.email, value: email, autoComplete: methods?.passkeyHere ? "username webauthn" : "username", required: true, onChange: setEmail }),
1708
1740
  company && /* @__PURE__ */ jsxs(f.Button, { type: "button", variant: company.enforced ? "primary" : "secondary", loading: f.loading("sso"), disabled: f.busy, className: f.cx(company.enforced ? "button" : "providerButton"), onClick: toCompany, children: [
1709
1741
  f.t.continueWith,
@@ -1729,8 +1761,10 @@ function SignIn(props) {
1729
1761
  challenge.node,
1730
1762
  /* @__PURE__ */ jsx(f.Button, { type: "submit", variant: "primary", loading: f.loading(), disabled: f.busy, className: f.cx("button"), children: f.t.signIn })
1731
1763
  ] }),
1732
- !company?.enforced && !passwordOn && methods?.magicLink && challenge.node,
1733
- methods?.magicLink && !company?.enforced && /* @__PURE__ */ jsx(f.Button, { type: "button", variant: "secondary", loading: f.loading("link"), disabled: f.busy, className: f.cx("providerButton"), onClick: () => void sendLink(), children: f.t.emailMeALink }),
1764
+ !company?.enforced && !passwordOn && methods?.magicLink && /* @__PURE__ */ jsxs(Fragment2, { children: [
1765
+ challenge.node,
1766
+ /* @__PURE__ */ jsx(f.Button, { type: "submit", variant: "primary", loading: f.loading("link"), disabled: f.busy, className: f.cx("button"), children: f.t.sendMeTheLink })
1767
+ ] }),
1734
1768
  methods?.signUp !== false && props.links?.signUp && /* @__PURE__ */ jsxs(Note, { f, footer: true, children: [
1735
1769
  f.t.noAccount,
1736
1770
  " ",