@vvedantb/native-ui 0.31.0 → 0.33.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/src/auth/totp.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useState } from "react";
2
- import { useSignIn } from "@clerk/clerk-expo";
2
+ import { useSignIn } from "@clerk/expo";
3
3
  import {
4
4
  authErrorMessage,
5
5
  DEFAULT_STAGE_TIMEOUT_MS,
@@ -7,6 +7,7 @@ import {
7
7
  logAuthFailure,
8
8
  withAuthTimeout,
9
9
  } from "./authErrors";
10
+ import { signInCalls } from "./clerkCore3";
10
11
 
11
12
  /** Logs a timed-out stage. Other failures are not logged here. */
12
13
  const logTimeout = (stage: string, error: unknown) => {
@@ -329,7 +330,8 @@ export type UseSecondFactorResult = {
329
330
  * `{ ok: true }` the session is active: navigate in the caller.
330
331
  */
331
332
  export function useSecondFactor(options: UseSecondFactorOptions = {}): UseSecondFactorResult {
332
- const { isLoaded, signIn, setActive } = useSignIn();
333
+ // Always defined: before Clerk loads, a call waits for it, inside the stage timeout.
334
+ const signIn = signInCalls(useSignIn().signIn);
333
335
  const [chosen, setChosen] = useState<SecondFactorStrategy | null>(null);
334
336
  const strategy = chosen ?? options.strategy ?? "totp";
335
337
  const [loading, setLoading] = useState(false);
@@ -338,13 +340,9 @@ export function useSecondFactor(options: UseSecondFactorOptions = {}): UseSecond
338
340
 
339
341
  const submit = async (code: string): Promise<TotpResult> => {
340
342
  if (loading) return { ok: false, error };
341
- if (!isLoaded || !signIn || !setActive) {
342
- setError(TOTP_MESSAGES.notReady);
343
- return { ok: false, error: TOTP_MESSAGES.notReady };
344
- }
345
343
  setLoading(true);
346
344
  setError("");
347
- const result = await submitSecondFactor({ signIn, setActive, code, strategy, timeoutMs });
345
+ const result = await submitSecondFactor({ signIn, setActive: signIn.setActive, code, strategy, timeoutMs });
348
346
  if (!result.ok) setError(result.error);
349
347
  setLoading(false);
350
348
  return result;
@@ -354,10 +352,6 @@ export function useSecondFactor(options: UseSecondFactorOptions = {}): UseSecond
354
352
  prepareStrategy: SecondFactorStrategy = strategy,
355
353
  factor?: SecondFactor,
356
354
  ): Promise<TotpResult> => {
357
- if (!isLoaded || !signIn) {
358
- setError(TOTP_MESSAGES.notReady);
359
- return { ok: false, error: TOTP_MESSAGES.notReady };
360
- }
361
355
  setLoading(true);
362
356
  setError("");
363
357
  const result = await prepareSecondFactorIfNeeded({ signIn, strategy: prepareStrategy, factor, timeoutMs });
@@ -1,5 +1,5 @@
1
1
  // `@vvedantb/native-ui/auth`: `AuthProviders`, `SignInScreen`, `SignUpScreen`,
2
2
  // `GoogleSignInButton` and the auth frame. Not on the root entry: it imports
3
- // `@clerk/clerk-expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
3
+ // `@clerk/expo`, `convex`, `expo-auth-session`, `expo-web-browser` and
4
4
  // `expo-router`, and Metro does not tree-shake.
5
5
  export * from "../auth";