@orangecheck/auth-client 2.18.0 → 2.19.0

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.d.mts CHANGED
@@ -125,6 +125,7 @@ interface OcSignInProps {
125
125
  resolveReturnTo?: (account: OcAccount) => string | Promise<string>;
126
126
  authOrigin?: string;
127
127
  initialPath?: 'wallet' | 'email';
128
+ providersFirst?: boolean;
128
129
  paths?: {
129
130
  wallet?: boolean;
130
131
  email?: boolean;
@@ -133,7 +134,7 @@ interface OcSignInProps {
133
134
  add?: boolean;
134
135
  className?: string;
135
136
  }
136
- declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
137
+ declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
137
138
 
138
139
  interface OcLinkedIdentity {
139
140
  id: string;
package/dist/index.d.ts CHANGED
@@ -125,6 +125,7 @@ interface OcSignInProps {
125
125
  resolveReturnTo?: (account: OcAccount) => string | Promise<string>;
126
126
  authOrigin?: string;
127
127
  initialPath?: 'wallet' | 'email';
128
+ providersFirst?: boolean;
128
129
  paths?: {
129
130
  wallet?: boolean;
130
131
  email?: boolean;
@@ -133,7 +134,7 @@ interface OcSignInProps {
133
134
  add?: boolean;
134
135
  className?: string;
135
136
  }
136
- declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
137
+ declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
137
138
 
138
139
  interface OcLinkedIdentity {
139
140
  id: string;
package/dist/index.js CHANGED
@@ -1953,7 +1953,8 @@ function OcSignIn({
1953
1953
  linkPrompt = true,
1954
1954
  add: addProp,
1955
1955
  authOrigin = "https://ochk.io",
1956
- initialPath = "wallet",
1956
+ initialPath,
1957
+ providersFirst = false,
1957
1958
  paths,
1958
1959
  className
1959
1960
  }) {
@@ -1982,7 +1983,9 @@ function OcSignIn({
1982
1983
  }
1983
1984
  setAddMode(new URLSearchParams(window.location.search).get("add") === "1");
1984
1985
  }, [addProp]);
1985
- const [path, setPath] = React3__namespace.useState(initialPath);
1986
+ const [path, setPath] = React3__namespace.useState(
1987
+ initialPath ?? (providersFirst ? "email" : "wallet")
1988
+ );
1986
1989
  const [signedIn, setSignedIn] = React3__namespace.useState(null);
1987
1990
  const [linkAlso, setLinkAlso] = React3__namespace.useState(false);
1988
1991
  const [oauthError, setOauthError] = React3__namespace.useState(false);
@@ -2130,7 +2133,16 @@ function OcSignIn({
2130
2133
  ]
2131
2134
  }
2132
2135
  ),
2133
- bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
2136
+ providersFirst && /* @__PURE__ */ jsxRuntime.jsx(
2137
+ ProviderSignIn,
2138
+ {
2139
+ authOrigin,
2140
+ returnTo: resolvedReturn,
2141
+ add: addMode,
2142
+ first: true
2143
+ }
2144
+ ),
2145
+ bothEnabled && /* @__PURE__ */ jsxRuntime.jsx(
2134
2146
  "div",
2135
2147
  {
2136
2148
  role: "tablist",
@@ -2142,7 +2154,24 @@ function OcSignIn({
2142
2154
  marginBottom: 16,
2143
2155
  borderBottom: "1px solid var(--border, #27272a)"
2144
2156
  },
2145
- children: [
2157
+ children: providersFirst ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2158
+ /* @__PURE__ */ jsxRuntime.jsx(
2159
+ SigninTab,
2160
+ {
2161
+ active: path === "email",
2162
+ onClick: () => setPath("email"),
2163
+ children: "email + otp"
2164
+ }
2165
+ ),
2166
+ /* @__PURE__ */ jsxRuntime.jsx(
2167
+ SigninTab,
2168
+ {
2169
+ active: path === "wallet",
2170
+ onClick: () => setPath("wallet"),
2171
+ children: "bitcoin \xB7 self-custody"
2172
+ }
2173
+ )
2174
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2146
2175
  /* @__PURE__ */ jsxRuntime.jsx(
2147
2176
  SigninTab,
2148
2177
  {
@@ -2151,8 +2180,15 @@ function OcSignIn({
2151
2180
  children: "bitcoin wallet"
2152
2181
  }
2153
2182
  ),
2154
- /* @__PURE__ */ jsxRuntime.jsx(SigninTab, { active: path === "email", onClick: () => setPath("email"), children: "email + otp" })
2155
- ]
2183
+ /* @__PURE__ */ jsxRuntime.jsx(
2184
+ SigninTab,
2185
+ {
2186
+ active: path === "email",
2187
+ onClick: () => setPath("email"),
2188
+ children: "email + otp"
2189
+ }
2190
+ )
2191
+ ] })
2156
2192
  }
2157
2193
  ),
2158
2194
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-signin-panel": "", role: "tabpanel", children: [
@@ -2174,7 +2210,7 @@ function OcSignIn({
2174
2210
  }
2175
2211
  )
2176
2212
  ] }),
2177
- /* @__PURE__ */ jsxRuntime.jsx(ProviderSignIn, { authOrigin, returnTo: resolvedReturn, add: addMode }),
2213
+ !providersFirst && /* @__PURE__ */ jsxRuntime.jsx(ProviderSignIn, { authOrigin, returnTo: resolvedReturn, add: addMode }),
2178
2214
  linkPrompt && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
2179
2215
  /* @__PURE__ */ jsxRuntime.jsx(
2180
2216
  "input",
@@ -2245,7 +2281,8 @@ function ProviderIcon({ id }) {
2245
2281
  function ProviderSignIn({
2246
2282
  authOrigin,
2247
2283
  returnTo,
2248
- add
2284
+ add,
2285
+ first = false
2249
2286
  }) {
2250
2287
  const [providers, setProviders] = React3__namespace.useState([]);
2251
2288
  const [origin, setOrigin] = React3__namespace.useState("");
@@ -2263,60 +2300,65 @@ function ProviderSignIn({
2263
2300
  if (providers.length === 0) return null;
2264
2301
  const providerReturnTo = returnTo.startsWith("/") ? origin ? `${origin}${returnTo}` : returnTo : returnTo;
2265
2302
  const line = { flex: 1, height: 1, background: "var(--border, #27272a)" };
2266
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-signin-providers": "", style: { marginTop: 20 }, children: [
2267
- /* @__PURE__ */ jsxRuntime.jsxs(
2268
- "div",
2269
- {
2270
- style: {
2271
- display: "flex",
2272
- alignItems: "center",
2273
- gap: 10,
2274
- margin: "4px 0 12px",
2275
- color: "var(--muted-foreground, #a1a1aa)",
2276
- fontFamily: "ui-monospace, SFMono-Regular, monospace",
2277
- fontSize: 10,
2278
- letterSpacing: "0.16em",
2279
- textTransform: "uppercase"
2280
- },
2281
- children: [
2282
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: line }),
2283
- "or",
2284
- /* @__PURE__ */ jsxRuntime.jsx("span", { style: line })
2285
- ]
2286
- }
2287
- ),
2288
- providers.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs(
2289
- "a",
2290
- {
2291
- href: `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
2292
- providerReturnTo
2293
- )}${add ? "&add=1" : ""}`,
2294
- "data-oc-signin-provider": p.id,
2295
- style: {
2296
- display: "flex",
2297
- alignItems: "center",
2298
- justifyContent: "center",
2299
- gap: 10,
2300
- boxSizing: "border-box",
2301
- width: "100%",
2302
- marginTop: i === 0 ? 0 : 8,
2303
- padding: "0.6rem 0.875rem",
2304
- border: "1px solid var(--border, #27272a)",
2305
- borderRadius: 6,
2306
- background: "transparent",
2307
- color: "var(--muted-foreground, #a1a1aa)",
2308
- fontFamily: "ui-monospace, SFMono-Regular, monospace",
2309
- fontSize: 12,
2310
- textDecoration: "none"
2311
- },
2312
- children: [
2313
- /* @__PURE__ */ jsxRuntime.jsx(ProviderIcon, { id: p.id }),
2314
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: p.label })
2315
- ]
2303
+ const divider = /* @__PURE__ */ jsxRuntime.jsxs(
2304
+ "div",
2305
+ {
2306
+ style: {
2307
+ display: "flex",
2308
+ alignItems: "center",
2309
+ gap: 10,
2310
+ margin: first ? "14px 0 4px" : "4px 0 12px",
2311
+ color: "var(--muted-foreground, #a1a1aa)",
2312
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
2313
+ fontSize: 10,
2314
+ letterSpacing: "0.16em",
2315
+ textTransform: "uppercase"
2316
2316
  },
2317
- p.id
2318
- ))
2319
- ] });
2317
+ children: [
2318
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: line }),
2319
+ "or",
2320
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: line })
2321
+ ]
2322
+ }
2323
+ );
2324
+ const buttons = providers.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs(
2325
+ "a",
2326
+ {
2327
+ href: `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
2328
+ providerReturnTo
2329
+ )}${add ? "&add=1" : ""}`,
2330
+ "data-oc-signin-provider": p.id,
2331
+ style: {
2332
+ display: "flex",
2333
+ alignItems: "center",
2334
+ justifyContent: "center",
2335
+ gap: 10,
2336
+ boxSizing: "border-box",
2337
+ width: "100%",
2338
+ marginTop: i === 0 ? 0 : 8,
2339
+ padding: "0.6rem 0.875rem",
2340
+ border: "1px solid var(--border, #27272a)",
2341
+ borderRadius: 6,
2342
+ background: "transparent",
2343
+ color: "var(--muted-foreground, #a1a1aa)",
2344
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
2345
+ fontSize: 12,
2346
+ textDecoration: "none"
2347
+ },
2348
+ children: [
2349
+ /* @__PURE__ */ jsxRuntime.jsx(ProviderIcon, { id: p.id }),
2350
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: p.label })
2351
+ ]
2352
+ },
2353
+ p.id
2354
+ ));
2355
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-oc-signin-providers": "", style: first ? { marginBottom: 4 } : { marginTop: 20 }, children: first ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2356
+ buttons,
2357
+ divider
2358
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2359
+ divider,
2360
+ buttons
2361
+ ] }) });
2320
2362
  }
2321
2363
  function WalletFlow({ authOrigin, audience, add, onSuccess }) {
2322
2364
  const [address, setAddress] = React3__namespace.useState("");