@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.js CHANGED
@@ -1699,6 +1699,13 @@ function OcSignIn({
1699
1699
  const [path, setPath] = React3__namespace.useState(initialPath);
1700
1700
  const [signedIn, setSignedIn] = React3__namespace.useState(null);
1701
1701
  const [linkAlso, setLinkAlso] = React3__namespace.useState(false);
1702
+ const [oauthError, setOauthError] = React3__namespace.useState(false);
1703
+ React3__namespace.useEffect(() => {
1704
+ if (typeof window === "undefined") return;
1705
+ if (new URLSearchParams(window.location.search).has("oauth_error")) {
1706
+ setOauthError(true);
1707
+ }
1708
+ }, []);
1702
1709
  const navigate = React3__namespace.useCallback(
1703
1710
  async (account) => {
1704
1711
  if (resolveReturnTo) {
@@ -1784,6 +1791,22 @@ function OcSignIn({
1784
1791
  const bothEnabled = walletEnabled && emailEnabled;
1785
1792
  const activeMethod = !emailEnabled ? "wallet" : !walletEnabled ? "email" : path;
1786
1793
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-oc-signin": "", children: [
1794
+ oauthError && /* @__PURE__ */ jsxRuntime.jsx(
1795
+ "div",
1796
+ {
1797
+ "data-oc-signin-oauth-error": "",
1798
+ style: {
1799
+ marginBottom: 14,
1800
+ padding: "0.6rem 0.75rem",
1801
+ border: "1px solid var(--destructive, #ef4444)",
1802
+ borderRadius: 6,
1803
+ color: "var(--destructive, #ef4444)",
1804
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1805
+ fontSize: 11
1806
+ },
1807
+ children: "That sign-in didn't complete. Please try again."
1808
+ }
1809
+ ),
1787
1810
  bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
1788
1811
  "div",
1789
1812
  {
@@ -1826,6 +1849,7 @@ function OcSignIn({
1826
1849
  }
1827
1850
  )
1828
1851
  ] }),
1852
+ /* @__PURE__ */ jsxRuntime.jsx(ProviderSignIn, { authOrigin, returnTo: safeReturn }),
1829
1853
  linkPrompt && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
1830
1854
  /* @__PURE__ */ jsxRuntime.jsx(
1831
1855
  "input",
@@ -1876,6 +1900,68 @@ function SigninTab({
1876
1900
  }
1877
1901
  );
1878
1902
  }
1903
+ var OAUTH_PROVIDERS = [
1904
+ { id: "google", label: "Continue with Google" }
1905
+ ];
1906
+ function ProviderSignIn({
1907
+ authOrigin,
1908
+ returnTo
1909
+ }) {
1910
+ const [origin, setOrigin] = React3__namespace.useState("");
1911
+ React3__namespace.useEffect(() => {
1912
+ setOrigin(window.location.origin);
1913
+ }, []);
1914
+ const providerReturnTo = origin ? `${origin}${returnTo}` : returnTo;
1915
+ const line = { flex: 1, height: 1, background: "var(--border, #27272a)" };
1916
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-signin-providers": "", style: { marginTop: 20 }, children: [
1917
+ /* @__PURE__ */ jsxRuntime.jsxs(
1918
+ "div",
1919
+ {
1920
+ style: {
1921
+ display: "flex",
1922
+ alignItems: "center",
1923
+ gap: 10,
1924
+ margin: "4px 0 12px",
1925
+ color: "var(--muted-foreground, #a1a1aa)",
1926
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1927
+ fontSize: 10,
1928
+ letterSpacing: "0.16em",
1929
+ textTransform: "uppercase"
1930
+ },
1931
+ children: [
1932
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: line }),
1933
+ "or",
1934
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: line })
1935
+ ]
1936
+ }
1937
+ ),
1938
+ OAUTH_PROVIDERS.map((p) => /* @__PURE__ */ jsxRuntime.jsx(
1939
+ "a",
1940
+ {
1941
+ href: `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
1942
+ providerReturnTo
1943
+ )}`,
1944
+ "data-oc-signin-provider": p.id,
1945
+ style: {
1946
+ display: "block",
1947
+ boxSizing: "border-box",
1948
+ width: "100%",
1949
+ padding: "0.6rem 0.875rem",
1950
+ textAlign: "center",
1951
+ border: "1px solid var(--border, #27272a)",
1952
+ borderRadius: 6,
1953
+ background: "transparent",
1954
+ color: "var(--muted-foreground, #a1a1aa)",
1955
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
1956
+ fontSize: 12,
1957
+ textDecoration: "none"
1958
+ },
1959
+ children: p.label
1960
+ },
1961
+ p.id
1962
+ ))
1963
+ ] });
1964
+ }
1879
1965
  function WalletFlow({ authOrigin, audience, onSuccess }) {
1880
1966
  const [address, setAddress] = React3__namespace.useState("");
1881
1967
  const [error, setError] = React3__namespace.useState(null);