@vvedantb/native-ui 0.37.2 → 0.39.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/README.md +8 -7
- package/dist/Avatar.jsx +22 -19
- package/dist/BottomSheetContainer.jsx +0 -6
- package/dist/BulkActionBar.jsx +0 -24
- package/dist/Button.jsx +92 -116
- package/dist/Card.jsx +56 -50
- package/dist/ColorSwatches.jsx +0 -6
- package/dist/Dialog.jsx +0 -12
- package/dist/DropdownMenu.jsx +0 -10
- package/dist/EmptyState.jsx +0 -3
- package/dist/ExpoWebRoot.jsx +0 -6
- package/dist/Field.jsx +0 -17
- package/dist/FloatingSurface.jsx +95 -80
- package/dist/FloatingTabBar.jsx +0 -23
- package/dist/IconButton.jsx +0 -1
- package/dist/LoadingState.jsx +0 -6
- package/dist/PasswordInput.jsx +0 -15
- package/dist/PillTabs.jsx +39 -36
- package/dist/SearchInput.jsx +0 -13
- package/dist/SectionLabel.jsx +0 -1
- package/dist/SharedTransition.jsx +0 -3
- package/dist/Skeleton.jsx +0 -2
- package/dist/Spinner.jsx +0 -2
- package/dist/StatusDot.jsx +0 -5
- package/dist/Switch.jsx +32 -22
- package/dist/Tabs.jsx +27 -26
- package/dist/Textarea.jsx +0 -1
- package/dist/ThemeToggle.jsx +0 -1
- package/dist/Toast.jsx +80 -91
- package/dist/UpdateChecker.jsx +0 -1
- package/dist/ai/activity-question.jsx +0 -6
- package/dist/ai/activity-step-label.js +0 -6
- package/dist/ai/activity-step-types.js +0 -4
- package/dist/ai/activity-tasks-utils.js +0 -17
- package/dist/ai/activity-timeline.js +0 -8
- package/dist/ai/attachments.jsx +0 -2
- package/dist/ai/chain-of-thought.jsx +0 -3
- package/dist/ai/chat-text.js +0 -1
- package/dist/ai/chat-thread.jsx +0 -1
- package/dist/ai/choice-question.jsx +0 -10
- package/dist/ai/code-block.jsx +0 -31
- package/dist/ai/collapsible.jsx +0 -14
- package/dist/ai/conversation-context.js +0 -3
- package/dist/ai/conversation.jsx +2 -48
- package/dist/ai/file-chip.jsx +0 -2
- package/dist/ai/icon-button.jsx +0 -8
- package/dist/ai/index.js +0 -5
- package/dist/ai/message-context-menu.jsx +0 -7
- package/dist/ai/message.jsx +0 -21
- package/dist/ai/prompt-input-menu.jsx +0 -3
- package/dist/ai/prompt-input.jsx +0 -27
- package/dist/ai/response-text.jsx +0 -6
- package/dist/ai/sources.jsx +0 -1
- package/dist/ai/suggestion.jsx +0 -1
- package/dist/ai/trace.jsx +0 -11
- package/dist/ai/unified-diff.jsx +0 -4
- package/dist/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +250 -77
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +18 -14
- package/dist/auth/SignInScreen.jsx +40 -34
- package/dist/auth/authErrors.js +0 -4
- package/dist/auth/clerkCore3.js +0 -7
- package/dist/auth/index.js +0 -4
- package/dist/auth/totp.js +0 -2
- package/dist/brand/GoogleMark.jsx +0 -1
- package/dist/brand/ProviderIcon.jsx +0 -2
- package/dist/brand/index.js +0 -3
- package/dist/brand/svg.js +0 -6
- package/dist/configureTheme.js +0 -9
- package/dist/controlStyles.js +0 -14
- package/dist/crash/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +192 -0
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +1 -0
- package/dist/entries/auth.js +0 -4
- package/dist/entries/bottom-sheet.js +0 -2
- package/dist/entries/brand.js +0 -1
- package/dist/entries/button.js +0 -1
- package/dist/entries/crash.js +2 -0
- package/dist/entries/date-time.js +0 -2
- package/dist/entries/expo-router.js +0 -3
- package/dist/entries/expo-web-root.js +0 -2
- package/dist/entries/floating.js +0 -2
- package/dist/entries/generative-ui.js +0 -4
- package/dist/entries/gesture-handler.js +0 -3
- package/dist/entries/keyboard-controller.js +0 -3
- package/dist/entries/layout.js +0 -2
- package/dist/entries/markdown.js +0 -3
- package/dist/entries/marketing.js +0 -1
- package/dist/entries/page-title.js +0 -5
- package/dist/entries/password-input.js +0 -2
- package/dist/entries/paste-input.js +0 -3
- package/dist/entries/primitives.js +0 -6
- package/dist/entries/search-input.js +0 -2
- package/dist/entries/tab-bar.js +0 -2
- package/dist/entries/theme.js +4 -2
- package/dist/entries/toast.js +0 -3
- package/dist/entries/video.js +0 -2
- package/dist/entries/webview.js +0 -2
- package/dist/examples/AiChatGallery.jsx +0 -11
- package/dist/examples/ParityGallery.jsx +0 -12
- package/dist/floating.js +0 -8
- package/dist/generative-ui/GenerativeUiPanel.jsx +0 -2
- package/dist/generative-ui/components.jsx +0 -8
- package/dist/glass.js +55 -0
- package/dist/glassBlur.jsx +0 -12
- package/dist/highlight.js +0 -26
- package/dist/index.js +4 -2
- package/dist/loadingGrid.js +0 -13
- package/dist/markdown/Markdown.jsx +0 -59
- package/dist/markdown/MarkdownTable.jsx +0 -18
- package/dist/markdown/tableText.js +0 -5
- package/dist/marketing/UpgradeToProCard.jsx +0 -5
- package/dist/marketing/pricing.js +0 -3
- package/dist/media/ImageGallery.jsx +0 -16
- package/dist/media/imageZoom.js +0 -4
- package/dist/media/zoom-image-gesture.jsx +0 -8
- package/dist/media/zoomImage.js +0 -3
- package/dist/motion.js +0 -3
- package/dist/neutralTheme.js +158 -0
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/icon.jsx +0 -4
- package/dist/primitives/keyboard-controller.jsx +0 -27
- package/dist/primitives/native-only-animated-view.jsx +0 -5
- package/dist/primitives/overlay.jsx +0 -2
- package/dist/primitives/pager-gesture.jsx +3 -29
- package/dist/primitives/paste-input.jsx +0 -5
- package/dist/primitives/select.jsx +0 -10
- package/dist/primitives/sheet-drag.jsx +0 -3
- package/dist/primitives/sheet-gesture.jsx +0 -8
- package/dist/primitives/swipe-row-gesture.jsx +3 -45
- package/dist/primitives/text.jsx +0 -5
- package/dist/primitives/toast-drag-gesture.jsx +4 -24
- package/dist/primitives/web-click-guard.js +0 -3
- package/dist/primitives/window-layer.jsx +0 -14
- package/dist/push.js +0 -6
- package/dist/relativeTime.js +0 -13
- package/dist/settings/MoreFromProjectV.jsx +0 -5
- package/dist/settings/ThemeModePicker.jsx +2 -9
- package/dist/settings/projectVMobileApps.js +1 -6
- package/dist/sheetDrag.js +0 -10
- package/dist/swipeRow.js +0 -15
- package/dist/tabBarRoutes.js +0 -4
- package/dist/tabIndicator.js +0 -4
- package/dist/tailwind-preset.cjs +0 -54
- package/dist/tailwind-preset.d.cts +0 -8
- package/dist/theme.jsx +29 -21
- package/dist/themeModeStore.js +62 -0
- package/dist/themeModes.js +9 -0
- package/dist/toastChrome.js +0 -6
- package/dist/toastDrag.js +0 -14
- package/dist/toastStore.js +0 -4
- package/dist/updateCheck.js +0 -7
- package/dist/video/InlineVideo.jsx +0 -2
- package/dist/webview/htmlView.js +0 -5
- package/package.json +47 -19
- package/src/ArtifactList.tsx +0 -2
- package/src/Avatar.tsx +3 -3
- package/src/Badge.tsx +0 -1
- package/src/BottomSheetContainer.tsx +0 -11
- package/src/BulkActionBar.tsx +0 -66
- package/src/Button.tsx +4 -40
- package/src/CaptureButton.tsx +0 -1
- package/src/Card.tsx +3 -15
- package/src/Checkbox.tsx +0 -2
- package/src/ColorSwatches.tsx +0 -9
- package/src/ConfirmDialog.tsx +0 -7
- package/src/DateTimeField.tsx +0 -5
- package/src/Dialog.tsx +0 -27
- package/src/DividedList.tsx +0 -1
- package/src/DropdownMenu.tsx +0 -51
- package/src/EmptyState.tsx +0 -5
- package/src/ExpoWebRoot.tsx +0 -10
- package/src/Field.tsx +0 -14
- package/src/FloatingFAB.tsx +0 -3
- package/src/FloatingSurface.tsx +11 -8
- package/src/FloatingTabBar.tsx +0 -25
- package/src/IconButton.tsx +0 -5
- package/src/Input.tsx +0 -1
- package/src/Label.tsx +0 -1
- package/src/LabeledSwitchRow.tsx +0 -2
- package/src/ListRow.tsx +0 -12
- package/src/LoadingState.tsx +0 -12
- package/src/MenuSheet.tsx +0 -2
- package/src/PageIndicator.tsx +0 -2
- package/src/PageTitle.tsx +0 -15
- package/src/Pager.tsx +0 -9
- package/src/PasswordInput.tsx +0 -24
- package/src/PillTabs.tsx +3 -11
- package/src/PinnedBotTile.tsx +0 -6
- package/src/Progress.tsx +0 -3
- package/src/ReactionRow.tsx +0 -8
- package/src/ScreenContainer.tsx +0 -4
- package/src/SearchInput.tsx +0 -25
- package/src/SectionLabel.tsx +0 -2
- package/src/Select.tsx +0 -6
- package/src/Separator.tsx +0 -2
- package/src/SharedTransition.tsx +0 -7
- package/src/Sheet.tsx +0 -3
- package/src/SheetRow.tsx +0 -12
- package/src/Skeleton.tsx +0 -10
- package/src/Spinner.tsx +0 -6
- package/src/StackPageHeader.tsx +0 -16
- package/src/StatGrid.tsx +0 -1
- package/src/StatusDot.tsx +0 -6
- package/src/SurfaceRow.tsx +0 -12
- package/src/SwipeableRow.tsx +0 -4
- package/src/Switch.tsx +3 -4
- package/src/Tabs.tsx +3 -27
- package/src/Textarea.tsx +0 -2
- package/src/ThemeToggle.tsx +0 -1
- package/src/Toast.tsx +3 -19
- package/src/UpdateChecker.tsx +0 -46
- package/src/ai/activity-question.tsx +0 -8
- package/src/ai/activity-step-detail.tsx +0 -5
- package/src/ai/activity-step-label.ts +0 -5
- package/src/ai/activity-step-types.ts +0 -24
- package/src/ai/activity-step.tsx +0 -4
- package/src/ai/activity-tasks-utils.ts +0 -13
- package/src/ai/activity-timeline.ts +0 -6
- package/src/ai/attachments.tsx +0 -13
- package/src/ai/chain-of-thought.tsx +0 -5
- package/src/ai/chat-jump-rail.tsx +0 -2
- package/src/ai/chat-text.ts +0 -1
- package/src/ai/chat-thread.tsx +0 -9
- package/src/ai/choice-question.tsx +0 -36
- package/src/ai/code-block.tsx +0 -52
- package/src/ai/collapsible.tsx +0 -12
- package/src/ai/conversation-context.ts +0 -14
- package/src/ai/conversation.tsx +0 -58
- package/src/ai/file-chip.tsx +0 -1
- package/src/ai/icon-button.tsx +0 -17
- package/src/ai/index.ts +0 -5
- package/src/ai/message-action-sheet.tsx +0 -8
- package/src/ai/message-context-menu.tsx +0 -22
- package/src/ai/message-quote.tsx +0 -4
- package/src/ai/message.tsx +0 -66
- package/src/ai/prompt-input-menu.tsx +0 -19
- package/src/ai/prompt-input.tsx +0 -97
- package/src/ai/reasoning.tsx +0 -6
- package/src/ai/reply-quote-chip.tsx +0 -5
- package/src/ai/response-text.tsx +0 -8
- package/src/ai/shimmer.tsx +0 -2
- package/src/ai/sources.tsx +0 -3
- package/src/ai/subagent-cards.tsx +0 -13
- package/src/ai/suggestion.tsx +0 -4
- package/src/ai/tool-approval-card.tsx +0 -14
- package/src/ai/trace.tsx +0 -23
- package/src/ai/unified-diff.tsx +0 -16
- package/src/ai/use-streaming-disclosure.ts +0 -4
- package/src/app-root/AuthGroupGate.tsx +38 -0
- package/src/app-root/SsoCallbackScreen.tsx +52 -0
- package/src/app-root/fonts.ts +53 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +95 -6
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +17 -15
- package/src/auth/SignInScreen.tsx +103 -105
- package/src/auth/authErrors.ts +0 -6
- package/src/auth/clerkCore3.ts +0 -6
- package/src/auth/index.ts +0 -4
- package/src/auth/totp.ts +0 -13
- package/src/brand/AppIcons.tsx +0 -6
- package/src/brand/AppMark.tsx +0 -5
- package/src/brand/AppWordmark.tsx +0 -7
- package/src/brand/GoogleMark.tsx +0 -4
- package/src/brand/ProviderIcon.tsx +0 -6
- package/src/brand/familyApps.ts +0 -2
- package/src/brand/index.ts +0 -3
- package/src/brand/svg.ts +0 -9
- package/src/configureTheme.ts +0 -10
- package/src/controlStyles.ts +0 -12
- package/src/crash/LastCrashDialog.tsx +36 -0
- package/src/crash/lastCrash.ts +218 -0
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +1 -0
- package/src/entries/auth.ts +0 -4
- package/src/entries/bottom-sheet.ts +0 -2
- package/src/entries/brand.ts +0 -1
- package/src/entries/button.ts +0 -1
- package/src/entries/crash.ts +13 -0
- package/src/entries/date-time.ts +0 -2
- package/src/entries/expo-router.ts +0 -3
- package/src/entries/expo-web-root.ts +0 -2
- package/src/entries/floating.ts +0 -2
- package/src/entries/generative-ui.ts +0 -4
- package/src/entries/gesture-handler.ts +0 -3
- package/src/entries/keyboard-controller.ts +0 -3
- package/src/entries/layout.ts +0 -2
- package/src/entries/markdown.ts +0 -3
- package/src/entries/marketing.ts +0 -1
- package/src/entries/page-title.ts +0 -5
- package/src/entries/password-input.ts +0 -2
- package/src/entries/paste-input.ts +0 -3
- package/src/entries/primitives.ts +0 -6
- package/src/entries/search-input.ts +0 -2
- package/src/entries/tab-bar.ts +0 -2
- package/src/entries/theme.ts +8 -2
- package/src/entries/toast.ts +0 -3
- package/src/entries/video.ts +0 -2
- package/src/entries/webview.ts +0 -2
- package/src/examples/AiChatGallery.tsx +0 -11
- package/src/examples/ParityGallery.tsx +0 -25
- package/src/floating.ts +0 -6
- package/src/generative-ui/GenerativeUiPanel.tsx +0 -15
- package/src/generative-ui/components.tsx +0 -9
- package/src/generative-ui/context.ts +0 -2
- package/src/glass.ts +31 -0
- package/src/glassBlur.tsx +0 -15
- package/src/highlight.ts +1 -21
- package/src/index.ts +7 -2
- package/src/loadingGrid.ts +0 -12
- package/src/markdown/Markdown.tsx +0 -71
- package/src/markdown/MarkdownTable.tsx +0 -23
- package/src/markdown/tableText.ts +0 -3
- package/src/marketing/PricingModal.tsx +0 -13
- package/src/marketing/UpgradeToProCard.tsx +0 -14
- package/src/marketing/pricing.ts +0 -12
- package/src/media/ImageGallery.tsx +0 -18
- package/src/media/MediaCard.tsx +0 -8
- package/src/media/imageZoom.ts +0 -4
- package/src/media/zoom-image-gesture.tsx +0 -9
- package/src/media/zoomImage.ts +0 -5
- package/src/motion.ts +0 -3
- package/src/neutralTheme.ts +127 -0
- package/src/pagerSwipe.ts +0 -13
- package/src/palette.ts +0 -10
- package/src/pressScale.ts +0 -7
- package/src/primitives/button.tsx +0 -4
- package/src/primitives/card.tsx +0 -1
- package/src/primitives/icon.tsx +0 -2
- package/src/primitives/input.tsx +0 -4
- package/src/primitives/keyboard-controller.tsx +0 -25
- package/src/primitives/keyboard-parts.tsx +0 -27
- package/src/primitives/native-only-animated-view.tsx +0 -5
- package/src/primitives/overlay.tsx +0 -25
- package/src/primitives/pager-gesture.tsx +0 -20
- package/src/primitives/paste-input.tsx +0 -4
- package/src/primitives/paste-parts.tsx +0 -1
- package/src/primitives/select.tsx +0 -18
- package/src/primitives/sheet-drag.tsx +0 -19
- package/src/primitives/sheet-gesture.tsx +0 -22
- package/src/primitives/swipe-row-gesture.tsx +0 -33
- package/src/primitives/switch.tsx +0 -4
- package/src/primitives/text.tsx +0 -4
- package/src/primitives/toast-drag-gesture.tsx +0 -13
- package/src/primitives/web-click-guard.ts +0 -2
- package/src/primitives/window-layer.tsx +0 -18
- package/src/push.ts +0 -15
- package/src/relativeTime.ts +0 -21
- package/src/router/RouterStackPageHeader.tsx +0 -1
- package/src/settings/MoreFromProjectV.tsx +0 -8
- package/src/settings/SettingsEmptyState.tsx +0 -2
- package/src/settings/SettingsSection.tsx +0 -3
- package/src/settings/SettingsToggleRow.tsx +0 -4
- package/src/settings/ThemeModePicker.tsx +2 -16
- package/src/settings/projectVMobileApps.ts +0 -8
- package/src/sheetDrag.ts +0 -9
- package/src/swipeRow.ts +0 -23
- package/src/tabBarRoutes.ts +0 -13
- package/src/tabIndicator.ts +0 -5
- package/src/tailwind-preset.cjs +0 -54
- package/src/tailwind-preset.d.cts +0 -8
- package/src/theme.tsx +11 -2
- package/src/themeModeStore.ts +85 -0
- package/src/themeModes.ts +10 -0
- package/src/toastChrome.ts +0 -6
- package/src/toastDrag.ts +0 -13
- package/src/toastStore.ts +0 -7
- package/src/updateCheck.ts +0 -15
- package/src/video/InlineVideo.tsx +0 -5
- package/src/webview/HtmlView.tsx +0 -23
- package/src/webview/HtmlView.web.tsx +0 -1
- package/src/webview/htmlView.ts +0 -5
- package/types/prism-react-renderer.d.ts +22 -0
|
@@ -8,7 +8,8 @@ import { Input } from "../Input";
|
|
|
8
8
|
import { PasswordInput } from "../PasswordInput";
|
|
9
9
|
import { toast } from "../toastStore";
|
|
10
10
|
import { useScheme } from "../useScheme";
|
|
11
|
-
import {
|
|
11
|
+
import { SettingsField } from "../settings/SettingsField";
|
|
12
|
+
import { AuthScreen, FieldError, OrDivider, type AuthScreenProps } from "./AuthScreen";
|
|
12
13
|
import {
|
|
13
14
|
authErrorMessage,
|
|
14
15
|
DEFAULT_STAGE_TIMEOUT_MS,
|
|
@@ -31,7 +32,11 @@ import {
|
|
|
31
32
|
type SecondFactor,
|
|
32
33
|
type SecondFactorStrategy,
|
|
33
34
|
} from "./totp";
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
GoogleSignInButton,
|
|
37
|
+
type AuthNavigationOptions,
|
|
38
|
+
type GoogleSignInButtonProps,
|
|
39
|
+
} from "./GoogleSignInButton";
|
|
35
40
|
|
|
36
41
|
export type SignInMode = "sign-in" | "sign-up" | "reset-password";
|
|
37
42
|
|
|
@@ -115,62 +120,35 @@ function secondFactorCopy(strategy: SecondFactorStrategy, clientTrust: boolean)
|
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
export type SignInScreenProps = AuthNavigationOptions & {
|
|
118
|
-
/**
|
|
119
|
-
* Default `"sign-in"`. `"sign-up"` creates the account and checks an emailed
|
|
120
|
-
* code. `"reset-password"` emails a code, checks it, then sets a new password
|
|
121
|
-
* and signs in.
|
|
122
|
-
*/
|
|
123
123
|
mode?: SignInMode;
|
|
124
|
-
/** Default "Welcome back", "Create account" in `sign-up`, or "Reset password" in `reset-password`. */
|
|
125
124
|
title?: string;
|
|
126
|
-
/** Default "Sign in to continue", "Sign up to get started" in `sign-up`, or the reset hint in `reset-password`. */
|
|
127
125
|
subtitle?: string;
|
|
128
|
-
/** The app URL scheme, such as `"vibot"`, for the Google redirect `scheme://sso-callback`. */
|
|
129
126
|
scheme: string;
|
|
130
|
-
/** Default `"sso-callback"`. */
|
|
131
127
|
redirectPath?: string;
|
|
132
|
-
/** Default `true`. */
|
|
133
128
|
showGoogle?: boolean;
|
|
134
|
-
/** Default "Continue with Google". */
|
|
135
129
|
googleLabel?: string;
|
|
136
|
-
/** In `sign-in`: the "Sign up" link in the footer. No link without it. */
|
|
137
130
|
signUpHref?: Href;
|
|
138
|
-
/** In `sign-up` and `reset-password`: the "Sign in" link in the footer. No link without it. */
|
|
139
131
|
signInHref?: Href;
|
|
140
|
-
/**
|
|
141
|
-
* In `sign-in`: the "Forgot password?" link under the password, to a route
|
|
142
|
-
* that renders `ResetPasswordScreen`. No link without it.
|
|
143
|
-
*/
|
|
144
132
|
forgotPasswordHref?: Href;
|
|
145
|
-
/** Sign-up and the new-password step reject a shorter password before sending it. Default: no check. */
|
|
146
133
|
minPasswordLength?: number;
|
|
147
|
-
/** Default `"toast"`. `"inline"` shows errors under the fields. */
|
|
148
134
|
errorDisplay?: "toast" | "inline";
|
|
149
|
-
/** Prefix for every `testID`: `sign-in-email`, `sign-in-password`, `sign-in-submit` and the rest. Default the mode. */
|
|
150
135
|
testIDPrefix?: string;
|
|
151
|
-
|
|
136
|
+
testIDs?: Partial<Record<string, string>>;
|
|
152
137
|
header?: ReactNode;
|
|
153
|
-
/** Below the footer link row, such as an app credit. */
|
|
154
138
|
footer?: ReactNode;
|
|
155
|
-
/**
|
|
156
|
-
* Called with the sign-in when the built-in UI cannot finish it:
|
|
157
|
-
* `needs_identifier`, any unknown status, `needs_first_factor` when no
|
|
158
|
-
* `email_code` or `phone_code` first factor exists (with its id), and
|
|
159
|
-
* `needs_second_factor` or `needs_client_trust` when no supported strategy
|
|
160
|
-
* (totp, backup code, phone code, email code) exists. The built-in screen
|
|
161
|
-
* runs `needs_first_factor` with an email or phone code, and always runs
|
|
162
|
-
* `needs_second_factor`, `needs_client_trust` and `needs_new_password`
|
|
163
|
-
* itself. When called, the web-fallback message is not
|
|
164
|
-
* shown. Without it, the screen shows the web fallback and logs
|
|
165
|
-
* `console.warn`. Ignored in `sign-up`.
|
|
166
|
-
*/
|
|
167
139
|
onIncomplete?: (signIn: IncompleteSignIn) => void;
|
|
168
|
-
/**
|
|
169
|
-
* Time for each Clerk call (create, prepare, attempt, reset password,
|
|
170
|
-
* set active), in milliseconds. A call that takes longer fails with code
|
|
171
|
-
* `auth_timeout`. Default 20000.
|
|
172
|
-
*/
|
|
173
140
|
stageTimeoutMs?: number;
|
|
141
|
+
variant?: AuthScreenProps["variant"];
|
|
142
|
+
heroColor?: string;
|
|
143
|
+
heroForeground?: string;
|
|
144
|
+
submitLabel?: string;
|
|
145
|
+
footerPrompt?: string;
|
|
146
|
+
footerLinkLabel?: string;
|
|
147
|
+
showFieldLabels?: boolean;
|
|
148
|
+
emailPlaceholder?: string;
|
|
149
|
+
passwordPlaceholder?: string;
|
|
150
|
+
googleVariant?: GoogleSignInButtonProps["variant"];
|
|
151
|
+
googleSize?: GoogleSignInButtonProps["size"];
|
|
174
152
|
};
|
|
175
153
|
|
|
176
154
|
/**
|
|
@@ -203,12 +181,26 @@ export function SignInScreen({
|
|
|
203
181
|
minPasswordLength,
|
|
204
182
|
errorDisplay = "toast",
|
|
205
183
|
testIDPrefix,
|
|
184
|
+
testIDs,
|
|
206
185
|
header,
|
|
207
186
|
footer,
|
|
208
187
|
onIncomplete,
|
|
209
188
|
stageTimeoutMs = DEFAULT_STAGE_TIMEOUT_MS,
|
|
189
|
+
variant,
|
|
190
|
+
heroColor,
|
|
191
|
+
heroForeground,
|
|
192
|
+
submitLabel,
|
|
193
|
+
footerPrompt,
|
|
194
|
+
footerLinkLabel,
|
|
195
|
+
showFieldLabels = false,
|
|
196
|
+
emailPlaceholder = "Email",
|
|
197
|
+
passwordPlaceholder = "Password",
|
|
198
|
+
googleVariant,
|
|
199
|
+
googleSize,
|
|
210
200
|
}: SignInScreenProps) {
|
|
211
|
-
|
|
201
|
+
const heroProps = { variant, heroColor, heroForeground };
|
|
202
|
+
const labelled = (label: string, control: ReactNode) =>
|
|
203
|
+
showFieldLabels ? <SettingsField label={label}>{control}</SettingsField> : control;
|
|
212
204
|
const signIn = signInCalls(useSignIn().signIn);
|
|
213
205
|
const signUpAttempt = useSignUp().signUp;
|
|
214
206
|
const router = useRouter();
|
|
@@ -236,12 +228,11 @@ export function SignInScreen({
|
|
|
236
228
|
const secondFactor = useSecondFactor({ stageTimeoutMs });
|
|
237
229
|
const [error, setError] = useState("");
|
|
238
230
|
const [submitting, setSubmitting] = useState(false);
|
|
239
|
-
// The field each "next" key moves to.
|
|
240
231
|
const passwordField = useRef<ComponentRef<typeof TextInput>>(null);
|
|
241
232
|
const confirmField = useRef<ComponentRef<typeof TextInput>>(null);
|
|
242
233
|
const signUp = mode === "sign-up";
|
|
243
234
|
const reset = mode === "reset-password";
|
|
244
|
-
const id = (name: string) => `${testIDPrefix ?? mode}-${name}`;
|
|
235
|
+
const id = (name: string) => testIDs?.[name] ?? `${testIDPrefix ?? mode}-${name}`;
|
|
245
236
|
|
|
246
237
|
const fail = (heading: string, message: string) => {
|
|
247
238
|
if (errorDisplay === "inline") setError(message);
|
|
@@ -262,7 +253,6 @@ export function SignInScreen({
|
|
|
262
253
|
);
|
|
263
254
|
};
|
|
264
255
|
|
|
265
|
-
// A status the built-in UI cannot finish: the app's `onIncomplete`, or the web fallback.
|
|
266
256
|
const unhandled = (attempt: IncompleteSignIn) => {
|
|
267
257
|
if (onIncomplete) return onIncomplete(attempt);
|
|
268
258
|
warnIncomplete(attempt);
|
|
@@ -311,9 +301,7 @@ export function SignInScreen({
|
|
|
311
301
|
await chooseFirstStrategy(strategy, list);
|
|
312
302
|
};
|
|
313
303
|
|
|
314
|
-
// Routes a sign-in attempt. `needs_first_factor` is built in only after `signIn.create`.
|
|
315
304
|
const routeAttempt = async (attempt: IncompleteSignIn, afterCreate: boolean) => {
|
|
316
|
-
// Clerk's `SignInStatus` omits `needs_client_trust`: widen before comparing.
|
|
317
305
|
const status: string | null = attempt.status;
|
|
318
306
|
if (status === "complete" && attempt.createdSessionId) {
|
|
319
307
|
await withAuthTimeout(signIn.setActive(), "set-active", stageTimeoutMs);
|
|
@@ -371,13 +359,11 @@ export function SignInScreen({
|
|
|
371
359
|
setError("");
|
|
372
360
|
try {
|
|
373
361
|
const result = await withAuthTimeout(signIn.resetPassword(newPassword), "reset-password", stageTimeoutMs);
|
|
374
|
-
// Clerk's `SignInStatus` omits `needs_client_trust`: widen before comparing.
|
|
375
362
|
const afterReset: string | null = result.status;
|
|
376
363
|
if (afterReset === "complete" && result.createdSessionId) {
|
|
377
364
|
await withAuthTimeout(signIn.setActive(), "set-active", stageTimeoutMs);
|
|
378
365
|
done();
|
|
379
366
|
} else if (afterReset === "needs_second_factor" || afterReset === "needs_client_trust") {
|
|
380
|
-
// A reset on an account with two-step verification: the code step, then the session.
|
|
381
367
|
setPendingNewPassword(false);
|
|
382
368
|
await startSecondFactor(result, afterReset === "needs_client_trust");
|
|
383
369
|
} else if (onIncomplete) {
|
|
@@ -413,7 +399,6 @@ export function SignInScreen({
|
|
|
413
399
|
}
|
|
414
400
|
};
|
|
415
401
|
|
|
416
|
-
// Emails the reset code. Throws what the call throws.
|
|
417
402
|
const requestResetCode = async () => {
|
|
418
403
|
await withAuthTimeout(signIn.sendResetCode(email.trim()), "create", stageTimeoutMs);
|
|
419
404
|
};
|
|
@@ -449,7 +434,6 @@ export function SignInScreen({
|
|
|
449
434
|
}
|
|
450
435
|
};
|
|
451
436
|
|
|
452
|
-
// Checks the emailed code. A good code gives `needs_new_password`, which `routeAttempt` shows.
|
|
453
437
|
const onResetCode = async (resetCode: string) => {
|
|
454
438
|
if (resetLoading) return;
|
|
455
439
|
setResetLoading(true);
|
|
@@ -480,7 +464,6 @@ export function SignInScreen({
|
|
|
480
464
|
};
|
|
481
465
|
|
|
482
466
|
const onSecondFactorBack = () => {
|
|
483
|
-
// The pending attempt stays; the next `signIn.create` replaces it.
|
|
484
467
|
setPendingSecondFactor(false);
|
|
485
468
|
setPendingFirstFactor(false);
|
|
486
469
|
setFirstError("");
|
|
@@ -501,7 +484,6 @@ export function SignInScreen({
|
|
|
501
484
|
return fail(AUTH_MESSAGES.signUpFailed, `Use at least ${minPasswordLength} characters for the password`);
|
|
502
485
|
}
|
|
503
486
|
if (password !== signUpConfirm) {
|
|
504
|
-
// Always under the confirm field, also with `errorDisplay="toast"`.
|
|
505
487
|
setError("");
|
|
506
488
|
setMismatch(true);
|
|
507
489
|
return;
|
|
@@ -546,7 +528,8 @@ export function SignInScreen({
|
|
|
546
528
|
{linkHref && !pendingVerification ? (
|
|
547
529
|
<>
|
|
548
530
|
<Text className="font-instrument-sans text-sm" style={textStyle("muted", colorScheme)}>
|
|
549
|
-
{
|
|
531
|
+
{footerPrompt ??
|
|
532
|
+
(reset ? "Remembered your password?" : signUp ? "Already have an account?" : "Don't have an account?")}
|
|
550
533
|
</Text>
|
|
551
534
|
<Button
|
|
552
535
|
testID={id(toSignIn ? "sign-in-link" : "sign-up-link")}
|
|
@@ -555,7 +538,7 @@ export function SignInScreen({
|
|
|
555
538
|
fullWidth={false}
|
|
556
539
|
onPress={() => router.push(linkHref)}
|
|
557
540
|
>
|
|
558
|
-
{toSignIn ? "Sign in" : "Sign up"}
|
|
541
|
+
{footerLinkLabel ?? (toSignIn ? "Sign in" : "Sign up")}
|
|
559
542
|
</Button>
|
|
560
543
|
</>
|
|
561
544
|
) : null}
|
|
@@ -571,6 +554,7 @@ export function SignInScreen({
|
|
|
571
554
|
title={AUTH_MESSAGES.newPasswordTitle}
|
|
572
555
|
subtitle={reset ? AUTH_MESSAGES.resetNewPasswordDescription : AUTH_MESSAGES.newPasswordDescription}
|
|
573
556
|
header={header}
|
|
557
|
+
{...heroProps}
|
|
574
558
|
>
|
|
575
559
|
<PasswordInput
|
|
576
560
|
testID={id("new-password")}
|
|
@@ -634,6 +618,7 @@ export function SignInScreen({
|
|
|
634
618
|
onBack={onSecondFactorBack}
|
|
635
619
|
backLabel="Use a different email"
|
|
636
620
|
header={header}
|
|
621
|
+
{...heroProps}
|
|
637
622
|
testIDPrefix={id("email-code")}
|
|
638
623
|
/>
|
|
639
624
|
);
|
|
@@ -668,6 +653,7 @@ export function SignInScreen({
|
|
|
668
653
|
onBack={onSecondFactorBack}
|
|
669
654
|
backLabel="Use a different account"
|
|
670
655
|
header={header}
|
|
656
|
+
{...heroProps}
|
|
671
657
|
testIDPrefix={id("first-factor")}
|
|
672
658
|
/>
|
|
673
659
|
);
|
|
@@ -677,7 +663,6 @@ export function SignInScreen({
|
|
|
677
663
|
const active = secondFactor.strategy;
|
|
678
664
|
const available = supportedSecondFactorStrategies(factors);
|
|
679
665
|
const others = available.filter((strategy) => strategy !== active);
|
|
680
|
-
// From a backup code, go back to the default non-backup method. Otherwise offer a backup code.
|
|
681
666
|
const switchTo =
|
|
682
667
|
active === "backup_code"
|
|
683
668
|
? pickSecondFactorStrategy(factors.filter((factor) => factor.strategy !== "backup_code"))
|
|
@@ -714,6 +699,7 @@ export function SignInScreen({
|
|
|
714
699
|
onBack={onSecondFactorBack}
|
|
715
700
|
backLabel="Use a different account"
|
|
716
701
|
header={header}
|
|
702
|
+
{...heroProps}
|
|
717
703
|
testIDPrefix={id("second-factor")}
|
|
718
704
|
/>
|
|
719
705
|
);
|
|
@@ -727,6 +713,7 @@ export function SignInScreen({
|
|
|
727
713
|
subtitle="Enter the code we sent to your email."
|
|
728
714
|
header={header}
|
|
729
715
|
footer={hasFooter ? footerRow : undefined}
|
|
716
|
+
{...heroProps}
|
|
730
717
|
>
|
|
731
718
|
<Input
|
|
732
719
|
testID={id("code")}
|
|
@@ -769,6 +756,7 @@ export function SignInScreen({
|
|
|
769
756
|
}
|
|
770
757
|
header={header}
|
|
771
758
|
footer={hasFooter ? footerRow : undefined}
|
|
759
|
+
{...heroProps}
|
|
772
760
|
>
|
|
773
761
|
{showGoogle && !reset ? (
|
|
774
762
|
<>
|
|
@@ -782,61 +770,72 @@ export function SignInScreen({
|
|
|
782
770
|
onError={(message) => fail(message, message)}
|
|
783
771
|
label={googleLabel}
|
|
784
772
|
disabled={submitting}
|
|
773
|
+
{...(googleVariant ? { variant: googleVariant } : null)}
|
|
774
|
+
{...(googleSize ? { size: googleSize } : null)}
|
|
785
775
|
/>
|
|
786
776
|
<OrDivider />
|
|
787
777
|
</>
|
|
788
778
|
) : null}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
textContentType="emailAddress"
|
|
795
|
-
keyboardType="email-address"
|
|
796
|
-
returnKeyType={reset ? "go" : "next"}
|
|
797
|
-
submitBehavior={reset ? undefined : "submit"}
|
|
798
|
-
onSubmitEditing={() => (reset ? void onResetRequest() : passwordField.current?.focus())}
|
|
799
|
-
value={email}
|
|
800
|
-
placeholder="Email"
|
|
801
|
-
onChangeText={setEmail}
|
|
802
|
-
/>
|
|
803
|
-
{reset ? null : (
|
|
804
|
-
<PasswordInput
|
|
805
|
-
testID={id("password")}
|
|
806
|
-
ref={passwordField}
|
|
807
|
-
accessibilityLabel="Password"
|
|
779
|
+
{labelled(
|
|
780
|
+
"Email",
|
|
781
|
+
<Input
|
|
782
|
+
testID={id("email")}
|
|
783
|
+
accessibilityLabel="Email"
|
|
808
784
|
autoCapitalize="none"
|
|
809
|
-
autoComplete=
|
|
810
|
-
textContentType=
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
onSubmitEditing={() => (signUp ? confirmField.current?.focus() : void onSignIn())}
|
|
820
|
-
/>
|
|
785
|
+
autoComplete="email"
|
|
786
|
+
textContentType="emailAddress"
|
|
787
|
+
keyboardType="email-address"
|
|
788
|
+
returnKeyType={reset ? "go" : "next"}
|
|
789
|
+
submitBehavior={reset ? undefined : "submit"}
|
|
790
|
+
onSubmitEditing={() => (reset ? void onResetRequest() : passwordField.current?.focus())}
|
|
791
|
+
value={email}
|
|
792
|
+
placeholder={emailPlaceholder}
|
|
793
|
+
onChangeText={setEmail}
|
|
794
|
+
/>,
|
|
821
795
|
)}
|
|
796
|
+
{reset
|
|
797
|
+
? null
|
|
798
|
+
: labelled(
|
|
799
|
+
"Password",
|
|
800
|
+
<PasswordInput
|
|
801
|
+
testID={id("password")}
|
|
802
|
+
ref={passwordField}
|
|
803
|
+
accessibilityLabel="Password"
|
|
804
|
+
autoCapitalize="none"
|
|
805
|
+
autoComplete={signUp ? "new-password" : "password"}
|
|
806
|
+
textContentType={signUp ? "newPassword" : "password"}
|
|
807
|
+
returnKeyType={signUp ? "next" : "go"}
|
|
808
|
+
submitBehavior={signUp ? "submit" : undefined}
|
|
809
|
+
value={password}
|
|
810
|
+
placeholder={passwordPlaceholder}
|
|
811
|
+
onChangeText={(text) => {
|
|
812
|
+
setPassword(text);
|
|
813
|
+
setMismatch(false);
|
|
814
|
+
}}
|
|
815
|
+
onSubmitEditing={() => (signUp ? confirmField.current?.focus() : void onSignIn())}
|
|
816
|
+
/>,
|
|
817
|
+
)}
|
|
822
818
|
{signUp ? (
|
|
823
819
|
<>
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
820
|
+
{labelled(
|
|
821
|
+
"Confirm password",
|
|
822
|
+
<PasswordInput
|
|
823
|
+
testID={id("confirm-password")}
|
|
824
|
+
ref={confirmField}
|
|
825
|
+
accessibilityLabel={AUTH_MESSAGES.confirmSignUpPasswordLabel}
|
|
826
|
+
autoCapitalize="none"
|
|
827
|
+
autoComplete="new-password"
|
|
828
|
+
textContentType="newPassword"
|
|
829
|
+
returnKeyType="go"
|
|
830
|
+
value={signUpConfirm}
|
|
831
|
+
placeholder={AUTH_MESSAGES.confirmSignUpPasswordLabel}
|
|
832
|
+
onChangeText={(text) => {
|
|
833
|
+
setSignUpConfirm(text);
|
|
834
|
+
setMismatch(false);
|
|
835
|
+
}}
|
|
836
|
+
onSubmitEditing={() => void onSignUp()}
|
|
837
|
+
/>,
|
|
838
|
+
)}
|
|
840
839
|
<FieldError testID={id("confirm-error")} message={mismatch ? AUTH_MESSAGES.passwordMismatch : ""} />
|
|
841
840
|
</>
|
|
842
841
|
) : null}
|
|
@@ -859,9 +858,8 @@ export function SignInScreen({
|
|
|
859
858
|
loading={submitting}
|
|
860
859
|
onPress={() => void (reset ? onResetRequest() : signUp ? onSignUp() : onSignIn())}
|
|
861
860
|
>
|
|
862
|
-
{reset ? AUTH_MESSAGES.sendResetCode : signUp ? "Create account" : "Sign in"}
|
|
861
|
+
{reset ? AUTH_MESSAGES.sendResetCode : (submitLabel ?? (signUp ? "Create account" : "Sign in"))}
|
|
863
862
|
</Button>
|
|
864
|
-
{/* Bot protection mounts its widget here on web sign-up. */}
|
|
865
863
|
{signUp ? <View nativeID="clerk-captcha" /> : null}
|
|
866
864
|
</AuthScreen>
|
|
867
865
|
);
|
package/src/auth/authErrors.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isClerkAPIResponseError } from "@clerk/expo";
|
|
2
2
|
|
|
3
|
-
/** Words that must not reach the user: the auth provider and stack names. */
|
|
4
3
|
const PRODUCT_NAMES = /\b(clerk|convex)\b/gi;
|
|
5
4
|
|
|
6
5
|
/** The only Clerk codes that mean "Invalid email or password". */
|
|
@@ -23,7 +22,6 @@ type ParsedAuthError = {
|
|
|
23
22
|
const asString = (value: unknown): string | undefined =>
|
|
24
23
|
typeof value === "string" && value.length > 0 ? value : undefined;
|
|
25
24
|
|
|
26
|
-
/** Reads a Clerk API error, or a plain `{ errors: [...] }` object. No `zod`. */
|
|
27
25
|
function parseAuthError(error: unknown): ParsedAuthError | null {
|
|
28
26
|
if (typeof error !== "object" || error === null) return null;
|
|
29
27
|
const record = error as Record<string, unknown>;
|
|
@@ -120,10 +118,6 @@ export function logAuthFailure(stage: string, error: unknown): void {
|
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
export type AuthErrorOptions = {
|
|
123
|
-
/**
|
|
124
|
-
* Sign-in with email and password. `form_password_incorrect` and
|
|
125
|
-
* `form_identifier_not_found` (only these) return `fallback`.
|
|
126
|
-
*/
|
|
127
121
|
credentials?: boolean;
|
|
128
122
|
};
|
|
129
123
|
|
package/src/auth/clerkCore3.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { useSignIn } from "@clerk/expo";
|
|
|
2
2
|
import type { IncompleteSignIn } from "./SignInScreen";
|
|
3
3
|
import type { PrepareFirstFactorParams, PrepareSecondFactorParams, SecondFactorStrategy } from "./totp";
|
|
4
4
|
|
|
5
|
-
/** The sign-in resource of the `useSignIn` hook at the root of `@clerk/expo` 4. */
|
|
6
5
|
type CoreSignIn = ReturnType<typeof useSignIn>["signIn"];
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -35,12 +34,10 @@ export function signInCalls(signIn: CoreSignIn) {
|
|
|
35
34
|
get supportedSecondFactors() {
|
|
36
35
|
return signIn.supportedSecondFactors;
|
|
37
36
|
},
|
|
38
|
-
/** Starts a new sign-in with email and password. */
|
|
39
37
|
async password(identifier: string, password: string) {
|
|
40
38
|
await clerkCall(signIn.password({ identifier, password }));
|
|
41
39
|
return state();
|
|
42
40
|
},
|
|
43
|
-
/** Starts a new sign-in for `identifier` and emails its password-reset code. */
|
|
44
41
|
async sendResetCode(identifier: string) {
|
|
45
42
|
await clerkCall(signIn.create({ identifier }));
|
|
46
43
|
await clerkCall(signIn.resetPasswordEmailCode.sendCode());
|
|
@@ -49,7 +46,6 @@ export function signInCalls(signIn: CoreSignIn) {
|
|
|
49
46
|
await clerkCall(signIn.resetPasswordEmailCode.verifyCode({ code }));
|
|
50
47
|
return state();
|
|
51
48
|
},
|
|
52
|
-
/** Sets the new password. Other sessions stay signed in, as before. */
|
|
53
49
|
async resetPassword(password: string) {
|
|
54
50
|
await clerkCall(signIn.resetPasswordEmailCode.submitPassword({ password, signOutOfOtherSessions: false }));
|
|
55
51
|
return state();
|
|
@@ -67,7 +63,6 @@ export function signInCalls(signIn: CoreSignIn) {
|
|
|
67
63
|
else await clerkCall(signIn.emailCode.verifyCode({ code }));
|
|
68
64
|
return state();
|
|
69
65
|
},
|
|
70
|
-
/** Sends the second-factor code. Clerk picks the phone number or email of the sign-in itself. */
|
|
71
66
|
async prepareSecondFactor(params: PrepareSecondFactorParams) {
|
|
72
67
|
if (params.strategy === "phone_code") await clerkCall(signIn.mfa.sendPhoneCode());
|
|
73
68
|
else await clerkCall(signIn.mfa.sendEmailCode());
|
|
@@ -80,7 +75,6 @@ export function signInCalls(signIn: CoreSignIn) {
|
|
|
80
75
|
else await clerkCall(signIn.mfa.verifyEmailCode({ code }));
|
|
81
76
|
return state();
|
|
82
77
|
},
|
|
83
|
-
/** Makes the session of a complete sign-in the active one. */
|
|
84
78
|
async setActive() {
|
|
85
79
|
await clerkCall(signIn.finalize());
|
|
86
80
|
},
|
package/src/auth/index.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// Clerk + Convex providers and the shared sign-in and sign-up screens. On
|
|
2
|
-
// `@vvedantb/native-ui/auth` only: they import `@clerk/expo`, `convex`,
|
|
3
|
-
// `expo-auth-session`, `expo-web-browser` and `expo-router`, and Metro does not
|
|
4
|
-
// tree-shake.
|
|
5
1
|
export { AuthProviders } from "./AuthProviders";
|
|
6
2
|
export type { AuthProvidersProps } from "./AuthProviders";
|
|
7
3
|
export { AuthScreen, OrDivider, FieldError } from "./AuthScreen";
|
package/src/auth/totp.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from "./authErrors";
|
|
10
10
|
import { signInCalls } from "./clerkCore3";
|
|
11
11
|
|
|
12
|
-
/** Logs a timed-out stage. Other failures are not logged here. */
|
|
13
12
|
const logTimeout = (stage: string, error: unknown) => {
|
|
14
13
|
if (isAuthTimeoutError(error)) logAuthFailure(stage, error);
|
|
15
14
|
};
|
|
@@ -102,7 +101,6 @@ export async function prepareSecondFactorIfNeeded(args: {
|
|
|
102
101
|
signIn: Pick<SecondFactorSignIn, "supportedSecondFactors" | "prepareSecondFactor">;
|
|
103
102
|
strategy: SecondFactorStrategy;
|
|
104
103
|
factor?: SecondFactor;
|
|
105
|
-
/** Time for the Clerk call. Default 20000 ms. */
|
|
106
104
|
timeoutMs?: number;
|
|
107
105
|
}): Promise<TotpResult> {
|
|
108
106
|
const { signIn, strategy } = args;
|
|
@@ -149,7 +147,6 @@ export async function submitSecondFactor(args: {
|
|
|
149
147
|
setActive: TotpSetActive;
|
|
150
148
|
code: string;
|
|
151
149
|
strategy: SecondFactorStrategy;
|
|
152
|
-
/** Time for each Clerk call. Default 20000 ms. */
|
|
153
150
|
timeoutMs?: number;
|
|
154
151
|
}): Promise<TotpResult> {
|
|
155
152
|
const ms = args.timeoutMs ?? DEFAULT_STAGE_TIMEOUT_MS;
|
|
@@ -229,7 +226,6 @@ export async function prepareFirstFactorIfNeeded(args: {
|
|
|
229
226
|
signIn: Pick<FirstFactorSignIn, "supportedFirstFactors" | "prepareFirstFactor">;
|
|
230
227
|
strategy: FirstFactorStrategy;
|
|
231
228
|
factor?: FirstFactor;
|
|
232
|
-
/** Time for the Clerk call. Default 20000 ms. */
|
|
233
229
|
timeoutMs?: number;
|
|
234
230
|
}): Promise<TotpResult> {
|
|
235
231
|
const { signIn, strategy } = args;
|
|
@@ -268,7 +264,6 @@ export async function submitFirstFactor(args: {
|
|
|
268
264
|
signIn: Pick<FirstFactorSignIn, "attemptFirstFactor">;
|
|
269
265
|
code: string;
|
|
270
266
|
strategy: FirstFactorStrategy;
|
|
271
|
-
/** Time for the Clerk call. Default 20000 ms. */
|
|
272
267
|
timeoutMs?: number;
|
|
273
268
|
}): Promise<FirstFactorResult> {
|
|
274
269
|
try {
|
|
@@ -301,23 +296,16 @@ export function submitTotpSecondFactor(args: {
|
|
|
301
296
|
}
|
|
302
297
|
|
|
303
298
|
export type UseSecondFactorOptions = {
|
|
304
|
-
/** The strategy `submit` uses until `setStrategy` changes it. Default `"totp"`. */
|
|
305
299
|
strategy?: SecondFactorStrategy;
|
|
306
|
-
/** Time for each Clerk call, in milliseconds. Default 20000. */
|
|
307
300
|
stageTimeoutMs?: number;
|
|
308
301
|
};
|
|
309
302
|
|
|
310
303
|
export type UseSecondFactorResult = {
|
|
311
|
-
/** Checks the code and starts the session. Never throws. Sets `error` on failure. */
|
|
312
304
|
submit: (code: string) => Promise<TotpResult>;
|
|
313
|
-
/** Sends the code for `phone_code` and `email_code` (no call for the others). Never throws. Sets `error` on failure. */
|
|
314
305
|
prepare: (strategy?: SecondFactorStrategy, factor?: SecondFactor) => Promise<TotpResult>;
|
|
315
|
-
/** The strategy `submit` uses. */
|
|
316
306
|
strategy: SecondFactorStrategy;
|
|
317
307
|
setStrategy: (strategy: SecondFactorStrategy) => void;
|
|
318
|
-
/** True while `submit` or `prepare` runs. */
|
|
319
308
|
loading: boolean;
|
|
320
|
-
/** The last failure message, or `""`. */
|
|
321
309
|
error: string;
|
|
322
310
|
clearError: () => void;
|
|
323
311
|
};
|
|
@@ -330,7 +318,6 @@ export type UseSecondFactorResult = {
|
|
|
330
318
|
* `{ ok: true }` the session is active: navigate in the caller.
|
|
331
319
|
*/
|
|
332
320
|
export function useSecondFactor(options: UseSecondFactorOptions = {}): UseSecondFactorResult {
|
|
333
|
-
// Always defined: before Clerk loads, a call waits for it, inside the stage timeout.
|
|
334
321
|
const signIn = signInCalls(useSignIn().signIn);
|
|
335
322
|
const [chosen, setChosen] = useState<SecondFactorStrategy | null>(null);
|
|
336
323
|
const strategy = chosen ?? options.strategy ?? "totp";
|
package/src/brand/AppIcons.tsx
CHANGED
|
@@ -14,17 +14,11 @@ import {
|
|
|
14
14
|
} from "./svg";
|
|
15
15
|
|
|
16
16
|
export type AppIconProps = {
|
|
17
|
-
/** Rendered width and height in points (the glyph is square). Default 24. */
|
|
18
17
|
size?: number;
|
|
19
|
-
/** Glyph colour, for fill and stroke glyphs. Default the scheme's `tokens.color.foreground`. */
|
|
20
18
|
color?: string;
|
|
21
|
-
/** Stroke width in rendered points, for stroke glyphs. Default: the glyph's own weight. Fill glyphs ignore it. */
|
|
22
19
|
stroke?: number;
|
|
23
|
-
/** Accessible name. Without it the icon is hidden from assistive tech. On web: `role="img"` and `aria-label`, or `aria-hidden`. */
|
|
24
20
|
title?: string;
|
|
25
|
-
/** `"center"` (default) centres the glyph in its square. `"start"` left-aligns its ink, for vertical lists. */
|
|
26
21
|
align?: "center" | "start";
|
|
27
|
-
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
28
22
|
testID?: string;
|
|
29
23
|
style?: ViewProps["style"];
|
|
30
24
|
};
|
package/src/brand/AppMark.tsx
CHANGED
|
@@ -13,15 +13,10 @@ import {
|
|
|
13
13
|
} from "./svg";
|
|
14
14
|
|
|
15
15
|
export type AppMarkProps = {
|
|
16
|
-
/** Which family app's mark to draw. */
|
|
17
16
|
app: AppName;
|
|
18
|
-
/** `"mark"` (default): the plain `APP_ICONS` glyph. `"tile"`: white glyph on a black rounded tile. `"tile-light"`: black glyph on a white tile. */
|
|
19
17
|
variant?: AppMarkVariant;
|
|
20
|
-
/** Width and height in points. Default 24. */
|
|
21
18
|
size?: number;
|
|
22
|
-
/** Accessible name. Without it the mark is hidden from assistive tech. On web: `role="img"` and `aria-label`, or `aria-hidden`. */
|
|
23
19
|
title?: string;
|
|
24
|
-
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
25
20
|
testID?: string;
|
|
26
21
|
style?: ViewProps["style"];
|
|
27
22
|
};
|
|
@@ -10,15 +10,10 @@ import type { AppName } from "./svg";
|
|
|
10
10
|
export type ProductAppName = Exclude<AppName, "projectv" | "eva" | "bee">;
|
|
11
11
|
|
|
12
12
|
export type AppWordmarkProps = {
|
|
13
|
-
/** Which product app's name to show. The label is always the lowercase app id. */
|
|
14
13
|
app: ProductAppName;
|
|
15
|
-
/** Text font size in points (default 24). The icon is `Math.round(size * 1.4)` square and the gap is `0.2em`. */
|
|
16
14
|
size?: number;
|
|
17
|
-
/** `false` renders the name only (default `true`). */
|
|
18
15
|
icon?: boolean;
|
|
19
|
-
/** Icon and text colour. Default the scheme's `tokens.color.foreground`. */
|
|
20
16
|
color?: string;
|
|
21
|
-
/** When set, the wordmark is a pressable link (the web `href`). */
|
|
22
17
|
onPress?: () => void;
|
|
23
18
|
accessibilityLabel?: string;
|
|
24
19
|
className?: string;
|
|
@@ -54,8 +49,6 @@ export function AppWordmark({
|
|
|
54
49
|
fontSize: size,
|
|
55
50
|
lineHeight: size,
|
|
56
51
|
letterSpacing: size * WORDMARK.letterSpacingEm,
|
|
57
|
-
// The class alone draws Regular where an app maps every Instrument
|
|
58
|
-
// Sans class to one family.
|
|
59
52
|
fontWeight: WORDMARK.fontWeight,
|
|
60
53
|
color: fg,
|
|
61
54
|
includeFontPadding: false,
|
package/src/brand/GoogleMark.tsx
CHANGED
|
@@ -3,16 +3,12 @@ import Svg, { Path } from "react-native-svg";
|
|
|
3
3
|
import { svgA11yProps } from "../svgA11y";
|
|
4
4
|
|
|
5
5
|
export type GoogleMarkProps = {
|
|
6
|
-
/** Width and height in points. Default 18. */
|
|
7
6
|
size?: number;
|
|
8
|
-
/** Accessible name. Without it the mark is hidden from assistive tech, as it should be beside a "Continue with Google" label. On web: `role="img"` and `aria-label`, or `aria-hidden`. */
|
|
9
7
|
title?: string;
|
|
10
|
-
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
11
8
|
testID?: string;
|
|
12
9
|
style?: ViewProps["style"];
|
|
13
10
|
};
|
|
14
11
|
|
|
15
|
-
/** The four paths of the Google "G" on the 24 grid, each in its brand colour. */
|
|
16
12
|
const GOOGLE_G = [
|
|
17
13
|
{
|
|
18
14
|
fill: "#4285F4",
|
|
@@ -3,12 +3,10 @@ import Svg, { Path, Rect } from "react-native-svg";
|
|
|
3
3
|
import { svgA11yProps } from "../svgA11y";
|
|
4
4
|
import { useScheme } from "../useScheme";
|
|
5
5
|
|
|
6
|
-
/** A fill that follows the colour scheme, as the web `text-black dark:text-white`. */
|
|
7
6
|
type SchemeFill = string | { light: string; dark: string };
|
|
8
7
|
|
|
9
8
|
type ProviderMarkLayer =
|
|
10
9
|
| { d: string; fill: SchemeFill; evenOdd?: boolean }
|
|
11
|
-
/** A full-bleed square behind the glyph (the OpenCode tile). */
|
|
12
10
|
| { square: number; fill: SchemeFill };
|
|
13
11
|
|
|
14
12
|
export type ProviderMark = { viewBox: string; layers: readonly ProviderMarkLayer[] };
|
|
@@ -92,13 +90,9 @@ export function providerLabel(provider: string): string {
|
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
export type ProviderIconProps = {
|
|
95
|
-
/** "claude", "codex", "opencode" or "cursor". Any other value draws the Claude mark, as the web. */
|
|
96
93
|
provider: string;
|
|
97
|
-
/** Width and height in points. Default 14, as the web. */
|
|
98
94
|
size?: number;
|
|
99
|
-
/** Accessible name. Without it the mark is hidden from assistive tech (web `aria-hidden`). */
|
|
100
95
|
title?: string;
|
|
101
|
-
/** Set as `data-testid` on web, where `Svg` does not map `testID`. */
|
|
102
96
|
testID?: string;
|
|
103
97
|
style?: ViewProps["style"];
|
|
104
98
|
};
|