@orangecheck/auth-client 2.13.0 → 2.14.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/index.mjs CHANGED
@@ -1677,6 +1677,13 @@ function OcSignIn({
1677
1677
  const [path, setPath] = React3.useState(initialPath);
1678
1678
  const [signedIn, setSignedIn] = React3.useState(null);
1679
1679
  const [linkAlso, setLinkAlso] = React3.useState(false);
1680
+ const [oauthError, setOauthError] = React3.useState(false);
1681
+ React3.useEffect(() => {
1682
+ if (typeof window === "undefined") return;
1683
+ if (new URLSearchParams(window.location.search).has("oauth_error")) {
1684
+ setOauthError(true);
1685
+ }
1686
+ }, []);
1680
1687
  const navigate = React3.useCallback(
1681
1688
  async (account) => {
1682
1689
  if (resolveReturnTo) {
@@ -1762,6 +1769,22 @@ function OcSignIn({
1762
1769
  const bothEnabled = walletEnabled && emailEnabled;
1763
1770
  const activeMethod = !emailEnabled ? "wallet" : !walletEnabled ? "email" : path;
1764
1771
  return /* @__PURE__ */ jsxs("div", { className, "data-oc-signin": "", children: [
1772
+ oauthError && /* @__PURE__ */ jsx(
1773
+ "div",
1774
+ {
1775
+ "data-oc-signin-oauth-error": "",
1776
+ style: {
1777
+ marginBottom: 14,
1778
+ padding: "0.6rem 0.75rem",
1779
+ border: "1px solid var(--destructive, #ef4444)",
1780
+ borderRadius: 6,
1781
+ color: "var(--destructive, #ef4444)",
1782
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1783
+ fontSize: 11
1784
+ },
1785
+ children: "That sign-in didn't complete. Please try again."
1786
+ }
1787
+ ),
1765
1788
  bothEnabled && /* @__PURE__ */ jsxs(
1766
1789
  "div",
1767
1790
  {
@@ -1804,6 +1827,7 @@ function OcSignIn({
1804
1827
  }
1805
1828
  )
1806
1829
  ] }),
1830
+ /* @__PURE__ */ jsx(ProviderSignIn, { authOrigin, returnTo: safeReturn }),
1807
1831
  linkPrompt && /* @__PURE__ */ jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
1808
1832
  /* @__PURE__ */ jsx(
1809
1833
  "input",
@@ -1854,6 +1878,68 @@ function SigninTab({
1854
1878
  }
1855
1879
  );
1856
1880
  }
1881
+ var OAUTH_PROVIDERS = [
1882
+ { id: "google", label: "Continue with Google" }
1883
+ ];
1884
+ function ProviderSignIn({
1885
+ authOrigin,
1886
+ returnTo
1887
+ }) {
1888
+ const [origin, setOrigin] = React3.useState("");
1889
+ React3.useEffect(() => {
1890
+ setOrigin(window.location.origin);
1891
+ }, []);
1892
+ const providerReturnTo = origin ? `${origin}${returnTo}` : returnTo;
1893
+ const line = { flex: 1, height: 1, background: "var(--border, #27272a)" };
1894
+ return /* @__PURE__ */ jsxs("div", { "data-oc-signin-providers": "", style: { marginTop: 20 }, children: [
1895
+ /* @__PURE__ */ jsxs(
1896
+ "div",
1897
+ {
1898
+ style: {
1899
+ display: "flex",
1900
+ alignItems: "center",
1901
+ gap: 10,
1902
+ margin: "4px 0 12px",
1903
+ color: "var(--muted-foreground, #a1a1aa)",
1904
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1905
+ fontSize: 10,
1906
+ letterSpacing: "0.16em",
1907
+ textTransform: "uppercase"
1908
+ },
1909
+ children: [
1910
+ /* @__PURE__ */ jsx("span", { style: line }),
1911
+ "or",
1912
+ /* @__PURE__ */ jsx("span", { style: line })
1913
+ ]
1914
+ }
1915
+ ),
1916
+ OAUTH_PROVIDERS.map((p) => /* @__PURE__ */ jsx(
1917
+ "a",
1918
+ {
1919
+ href: `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
1920
+ providerReturnTo
1921
+ )}`,
1922
+ "data-oc-signin-provider": p.id,
1923
+ style: {
1924
+ display: "block",
1925
+ boxSizing: "border-box",
1926
+ width: "100%",
1927
+ padding: "0.6rem 0.875rem",
1928
+ textAlign: "center",
1929
+ border: "1px solid var(--border, #27272a)",
1930
+ borderRadius: 6,
1931
+ background: "transparent",
1932
+ color: "var(--muted-foreground, #a1a1aa)",
1933
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1934
+ fontSize: 12,
1935
+ textDecoration: "none"
1936
+ },
1937
+ children: p.label
1938
+ },
1939
+ p.id
1940
+ ))
1941
+ ] });
1942
+ }
1857
1943
  function WalletFlow({ authOrigin, audience, onSuccess }) {
1858
1944
  const [address, setAddress] = React3.useState("");
1859
1945
  const [error, setError] = React3.useState(null);