@jsb188/auth-web 1.1.11 → 1.1.13

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.
@@ -1,14 +1,10 @@
1
1
  import i18n from '@jsb188/app/i18n/index.ts';
2
2
  import { FullWidthButton } from '@jsb188/react-web/ui/Button';
3
3
  import { useCallback } from 'react';
4
- import {
5
- type OnFinishSignInFn,
6
- useContinueWithGoogle,
7
- useContinueWithMicrosoft,
8
- } from '../hooks/use-oauth';
4
+ import { type OnFinishSignInFn, useContinueWithGoogle, useContinueWithMicrosoft } from '../hooks/use-oauth';
5
+ import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
9
6
 
10
7
  interface OAuthButtonProps {
11
- formPublicId?: string | null;
12
8
  onFinishSignIn: OnFinishSignInFn;
13
9
  }
14
10
 
@@ -21,16 +17,15 @@ interface AuthMethodButtonProps {
21
17
  */
22
18
 
23
19
  export const ContinueWithGoogle = (p: OAuthButtonProps) => {
24
- const { onFinishSignIn, formPublicId } = p;
25
- const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } =
26
- useContinueWithGoogle({
27
- onFinishSignIn,
28
- });
20
+ const { onFinishSignIn } = p;
21
+ const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithGoogle({
22
+ onFinishSignIn,
23
+ });
29
24
 
30
- /* Launch Google OAuth with the current public-form context. */
25
+ /* Launch Google OAuth with the current account credentials. */
31
26
  const onClick = useCallback(() => {
32
- onInitiateGoogleSignIn(undefined, null, formPublicId ?? null);
33
- }, [formPublicId, onInitiateGoogleSignIn]);
27
+ onInitiateGoogleSignIn(undefined);
28
+ }, [onInitiateGoogleSignIn]);
34
29
 
35
30
  return (
36
31
  <FullWidthButton
@@ -51,16 +46,15 @@ export const ContinueWithGoogle = (p: OAuthButtonProps) => {
51
46
  */
52
47
 
53
48
  export const ContinueWithMicrosoft = (p: OAuthButtonProps) => {
54
- const { onFinishSignIn, formPublicId } = p;
55
- const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } =
56
- useContinueWithMicrosoft({
57
- onFinishSignIn,
58
- });
49
+ const { onFinishSignIn } = p;
50
+ const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithMicrosoft({
51
+ onFinishSignIn,
52
+ });
59
53
 
60
- /* Launch Microsoft OAuth with the current public-form context. */
54
+ /* Launch Microsoft OAuth with the current account credentials. */
61
55
  const onClick = useCallback(() => {
62
- onInitiateMicrosoftSignIn(undefined, undefined, formPublicId ?? null);
63
- }, [formPublicId, onInitiateMicrosoftSignIn]);
56
+ onInitiateMicrosoftSignIn();
57
+ }, [onInitiateMicrosoftSignIn]);
64
58
 
65
59
  return (
66
60
  <FullWidthButton
@@ -87,8 +81,9 @@ export const ContinueWithSso = (p: AuthMethodButtonProps) => {
87
81
  onClick={onClickButton}
88
82
  preset="em"
89
83
  className="mb_sm"
90
- iconName="buildings-2-color"
84
+ iconName={COMMON_ICON_NAMES.enterprise_signin}
91
85
  iconClassName="ft_md shift_up"
86
+ tryColor
92
87
  >
93
88
  {i18n.t('auth.continue_with_sso')}
94
89
  </FullWidthButton>
@@ -4,21 +4,13 @@ import { runWithAuthSessionBrowserLock } from '@jsb188/app/utils/authSession.ts'
4
4
  * Types
5
5
  */
6
6
 
7
- export type AuthPageName =
8
- | 'signin'
9
- | 'signin_success'
10
- | 'signup'
11
- | 'signup_success'
12
- | 'reset_password'
13
- | 'welcome';
7
+ export type AuthPageName = 'signin' | 'signin_success' | 'signup' | 'signup_success' | 'reset_password' | 'welcome';
14
8
 
15
9
  export type OAuthSessionAuthenticationInput = {
16
10
  provider: 'GOOGLE' | 'MICROSOFT';
17
11
  oauthToken?: string | null;
18
12
  idToken?: string | null;
19
13
  ssoConnectionId?: string | null;
20
- formPublicId?: string | null;
21
- authenticateOnly?: boolean;
22
14
  };
23
15
 
24
16
  export type OAuthSessionAuthenticationResult = {
@@ -26,36 +18,53 @@ export type OAuthSessionAuthenticationResult = {
26
18
  error: any | null;
27
19
  };
28
20
 
21
+ export type AuthenticationSessionHydrationResult = {
22
+ auth: any | null;
23
+ error: any | null;
24
+ };
25
+
26
+ const DEFAULT_AUTH_ROUTES: Record<AuthPageName, string> = {
27
+ signin: '/auth/signin',
28
+ signin_success: '/auth/success',
29
+ signup: '/auth/signup',
30
+ signup_success: '/auth/signup-finished',
31
+ reset_password: '/auth/reset-password',
32
+ welcome: '/auth/welcome',
33
+ };
34
+
29
35
  /**
30
36
  * Helper; get route path
31
37
  */
32
38
 
33
- export function getAuthRoute(
34
- pageName: AuthPageName,
35
- authRoutesMap?: Record<AuthPageName, string>,
36
- queryStr?: string,
37
- ) {
38
- const defaultAuthRoutesMap: Record<AuthPageName, string> = {
39
- signin: '/auth/signin',
40
- signin_success: '/auth/success',
41
- signup: '/auth/signup',
42
- signup_success: '/auth/signup-finished',
43
- reset_password: '/auth/reset-password',
44
- welcome: '/auth/welcome',
45
- };
46
-
47
- const pathname =
48
- authRoutesMap?.[pageName] || defaultAuthRoutesMap[pageName] || 'auth';
39
+ export function getAuthRoute(pageName: AuthPageName, authRoutesMap?: Record<AuthPageName, string>, queryStr?: string) {
40
+ const pathname = authRoutesMap?.[pageName] || DEFAULT_AUTH_ROUTES[pageName] || 'auth';
49
41
  return queryStr ? `${pathname}?${queryStr}` : pathname;
50
42
  }
51
43
 
44
+ /*
45
+ * Encode one validated post-authentication destination for auth route links.
46
+ */
47
+ export function getAuthReturnQuery(returnTo?: string | null) {
48
+ return returnTo ? new URLSearchParams({ returnTo }).toString() : undefined;
49
+ }
50
+
51
+ /*
52
+ * Preserve only explicitly supported account-auth destinations. MCP consent is
53
+ * account authentication.
54
+ */
55
+ export function getAuthReturnContext(value?: string | null) {
56
+ const consent = value?.match(
57
+ /^\/auth\/mcp-consent\?request=([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$/,
58
+ );
59
+ return {
60
+ returnTo: consent ? `/auth/mcp-consent?request=${consent[1]}` : value === '/auth/mcp-connections' ? value : null,
61
+ };
62
+ }
63
+
52
64
  /*
53
65
  * Post one login credential to the same-origin HttpOnly-cookie endpoint.
54
66
  */
55
- async function postSignInSessionCredential(
56
- name: 'bootstrapToken' | 'token',
57
- value: string,
58
- ): Promise<boolean> {
67
+ async function postSignInSessionCredential(name: 'bootstrapToken' | 'token', value: string): Promise<boolean> {
59
68
  try {
60
69
  const response = await fetch('/auth/session', {
61
70
  method: 'POST',
@@ -80,6 +89,7 @@ async function postSignInSessionCredential(
80
89
  */
81
90
  export async function authenticateOAuthSignInSession(
82
91
  input: OAuthSessionAuthenticationInput,
92
+ signal?: AbortSignal,
83
93
  ): Promise<OAuthSessionAuthenticationResult> {
84
94
  if (typeof fetch !== 'function') {
85
95
  return { auth: null, error: { errorCode: 'network_error' } };
@@ -87,18 +97,16 @@ export async function authenticateOAuthSignInSession(
87
97
 
88
98
  try {
89
99
  return await runWithAuthSessionBrowserLock(async () => {
100
+ signal?.throwIfAborted();
90
101
  const body = new URLSearchParams({
91
102
  provider: input.provider,
92
103
  managedSessionVersion: '1',
93
104
  ...(input.oauthToken ? { oauthToken: input.oauthToken } : {}),
94
105
  ...(input.idToken ? { idToken: input.idToken } : {}),
95
- ...(input.ssoConnectionId
96
- ? { ssoConnectionId: input.ssoConnectionId }
97
- : {}),
98
- ...(input.formPublicId ? { formPublicId: input.formPublicId } : {}),
99
- ...(input.authenticateOnly ? { authenticateOnly: '1' } : {}),
106
+ ...(input.ssoConnectionId ? { ssoConnectionId: input.ssoConnectionId } : {}),
100
107
  });
101
108
  const response = await fetch('/auth/session', {
109
+ signal,
102
110
  method: 'POST',
103
111
  credentials: 'same-origin',
104
112
  headers: {
@@ -120,22 +128,49 @@ export async function authenticateOAuthSignInSession(
120
128
  }
121
129
  }
122
130
 
131
+ /*
132
+ * Rehydrate browser authentication from the shared HttpOnly managed-session
133
+ * cookie after a same-origin popup establishes it.
134
+ */
135
+ export async function hydrateAuthenticationSession(): Promise<AuthenticationSessionHydrationResult> {
136
+ if (typeof fetch !== 'function') {
137
+ return { auth: null, error: { errorCode: 'network_error' } };
138
+ }
139
+
140
+ try {
141
+ return await runWithAuthSessionBrowserLock(async () => {
142
+ const response = await fetch('/auth/session', {
143
+ method: 'POST',
144
+ credentials: 'same-origin',
145
+ headers: {
146
+ 'Content-Type': 'application/x-www-form-urlencoded',
147
+ },
148
+ body: new URLSearchParams({ hydrate: '1' }),
149
+ });
150
+ const result = await response.json().catch(() => null);
151
+ if (!response.ok || !result?.ok || !result.auth?.token) {
152
+ return {
153
+ auth: null,
154
+ error: result?.error || { errorCode: 'network_error' },
155
+ };
156
+ }
157
+ return { auth: result.auth, error: null };
158
+ });
159
+ } catch {
160
+ return { auth: null, error: { errorCode: 'network_error' } };
161
+ }
162
+ }
163
+
123
164
  /*
124
165
  * Persist an OAuth or phone login before navigating without a bearer-token query.
125
166
  */
126
- export async function persistSignInSession(
127
- token: string,
128
- bootstrapToken?: string | null,
129
- ): Promise<boolean> {
167
+ export async function persistSignInSession(token: string, bootstrapToken?: string | null): Promise<boolean> {
130
168
  if (typeof fetch !== 'function' || (!token && !bootstrapToken)) {
131
169
  return false;
132
170
  }
133
171
 
134
172
  return await runWithAuthSessionBrowserLock(async () => {
135
- if (
136
- bootstrapToken &&
137
- (await postSignInSessionCredential('bootstrapToken', bootstrapToken))
138
- ) {
173
+ if (bootstrapToken && (await postSignInSessionCredential('bootstrapToken', bootstrapToken))) {
139
174
  return true;
140
175
  }
141
176
  return token ? await postSignInSessionCredential('token', token) : false;
@@ -1,307 +1,177 @@
1
1
  import i18n from '@jsb188/app/i18n/index.ts';
2
- import {
3
- isPhone,
4
- isEmail,
5
- passwordStrength,
6
- } from '@jsb188/app/utils/string.ts';
2
+ import { defineForm } from '@jsb188/form/libs/defineForm';
3
+ import { rules } from '@jsb188/form/libs/rules';
4
+ import { z } from 'zod';
7
5
 
8
- /**
9
- * Types
10
- */
11
-
12
- interface SignInFormType {
13
- identifier?: string;
14
- password?: string;
15
- }
6
+ export type SignInFormValues = z.input<ReturnType<typeof makeSignInSchema>['schema']>;
16
7
 
17
- interface SignUpFormType {
18
- email: string;
19
- password: string;
20
- passwordRepeat: string;
21
- }
22
-
23
- interface SignInDataForSchema {
8
+ export interface SignInFormContext {
24
9
  hidePassword: boolean;
25
- lastIdentifier: string;
10
+ lastIdentifier?: string;
26
11
  }
27
12
 
28
- /**
29
- * Values for validation
30
- */
31
-
32
- const MIN_LEN_VALUES = {
33
- password: 8,
34
- description: 750,
35
- };
36
-
37
- /**
38
- * Rules for each field
39
- */
40
-
41
- const RULES = (function () {
42
- return {
43
- email: {
44
- for: 'email',
45
- rule: isEmail,
46
- error: (value: string) => ({
47
- message: i18n.t('error.msg_email_invalid', { value }),
48
- }),
49
- },
50
- password: {
51
- for: 'password',
52
- rule: (value: string) =>
53
- passwordStrength(value, MIN_LEN_VALUES.password).valid,
54
- error: (value: string) => {
55
- const {
56
- isLongEnough,
57
- hasLowercase,
58
- hasUppercase,
59
- hasDigit,
60
- hasSpecial,
61
- } = passwordStrength(value, MIN_LEN_VALUES.password);
62
- const errorMessages = [];
63
-
64
- if (!isLongEnough) {
65
- errorMessages.push(
66
- i18n.t('error.msg_password_too_short', {
67
- length: MIN_LEN_VALUES.password,
68
- }),
69
- );
70
- }
71
- if (!hasLowercase) {
72
- errorMessages.push(i18n.t('error.msg_password_lowercase'));
73
- }
74
- if (!hasUppercase) {
75
- errorMessages.push(i18n.t('error.msg_password_uppercase'));
76
- }
77
- if (!hasDigit) {
78
- errorMessages.push(i18n.t('error.msg_password_digit'));
79
- }
80
- if (!hasSpecial) {
81
- errorMessages.push(i18n.t('error.msg_password_special'));
82
- }
83
-
84
- return {
85
- message:
86
- errorMessages.length > 1
87
- ? i18n.t('error.msg_password_insecure')
88
- : errorMessages[0],
89
- };
90
- },
91
- },
92
- passwordRepeat: {
93
- for: 'passwordRepeat',
94
- rule: (value: string, formValues: Partial<SignUpFormType>) =>
95
- value === formValues.password,
96
- error: {
97
- message: i18n.t('error.msg_password_mismatch'),
98
- },
99
- },
100
- phone: {
101
- for: 'phone',
102
- rule: (value: string) => isPhone(value),
103
- error: (value: string) => ({
104
- message: i18n.t('error.msg_phone_invalid', { value }),
105
- }),
106
- },
107
- };
108
- })();
109
-
110
- /**
111
- * Schema; Change password
13
+ /*
14
+ * Define the current password and matching new password fields for account changes and token resets.
112
15
  */
113
-
114
- export const makeChangeAccountPasswordSchema = () => ({
115
- listData: [
116
- {
117
- __type: 'input',
118
- hidden: (dataForSchema?: SignInDataForSchema) =>
119
- !!dataForSchema?.hidePassword,
120
- item: {
121
- autoFocus: true,
122
- name: 'currentPassword',
16
+ export function makeChangeAccountPasswordSchema() {
17
+ return defineForm({
18
+ schema: z
19
+ .object({
20
+ currentPassword: z.string(),
21
+ password: rules.password(),
22
+ passwordRepeat: z.string(),
23
+ })
24
+ .superRefine(rules.matches('passwordRepeat', 'password')),
25
+ defaults: { currentPassword: '', password: '', passwordRepeat: '' },
26
+ fields: {
27
+ currentPassword: {
28
+ kind: 'input',
123
29
  type: 'password',
30
+ autoFocus: true,
124
31
  label: i18n.t('account.currentPassword'),
125
32
  placeholder: i18n.t('account.password_ph'),
126
- // info: 'whatever you want',
33
+ visibleWhen: ({ context }: { context?: Partial<SignInFormContext> }) => !context?.hidePassword,
127
34
  },
128
- },
129
- {
130
- __type: 'password',
131
- item: {
132
- name: 'password',
35
+ password: {
36
+ kind: 'password',
133
37
  type: 'password',
134
38
  label: i18n.t('account.newPassword'),
135
- // placeholder: ''
136
- // info: 'whatever you want',
137
39
  },
138
- },
139
- {
140
- __type: 'password',
141
- item: {
142
- name: 'passwordRepeat',
40
+ passwordRepeat: {
41
+ kind: 'password',
143
42
  type: 'password',
144
43
  label: i18n.t('account.newPasswordRepeat'),
145
44
  },
146
45
  },
147
- ],
148
- rules: [RULES.password],
149
- });
46
+ });
47
+ }
150
48
 
151
- /**
152
- * Schema; Assign a new password
49
+ /*
50
+ * Define a matching password pair when an account does not yet have a password.
153
51
  */
154
-
155
- export const makeAssignPasswordSchema = () => ({
156
- listData: [
157
- {
158
- __type: 'password',
159
- item: {
160
- name: 'password',
52
+ export function makeAssignPasswordSchema() {
53
+ return defineForm({
54
+ schema: z
55
+ .object({
56
+ password: rules.password(),
57
+ passwordRepeat: z.string(),
58
+ })
59
+ .superRefine(rules.matches('passwordRepeat', 'password')),
60
+ defaults: { password: '', passwordRepeat: '' },
61
+ fields: {
62
+ password: {
63
+ kind: 'password',
161
64
  type: 'password',
162
65
  label: i18n.t('account.password'),
163
66
  },
164
- },
165
- {
166
- __type: 'password',
167
- item: {
168
- name: 'passwordRepeat',
67
+ passwordRepeat: {
68
+ kind: 'password',
169
69
  type: 'password',
170
70
  label: i18n.t('account.passwordRepeat'),
171
71
  },
172
72
  },
173
- ],
174
- rules: [RULES.password],
175
- isButtonDisabled: (formValues: any) => {
176
- return !formValues?.password?.trim() || !formValues?.passwordRepeat?.trim();
177
- },
178
- });
73
+ canSubmit: ({ values }) => !!values.password.trim() && !!values.passwordRepeat.trim(),
74
+ });
75
+ }
179
76
 
180
- /**
181
- * Schema; sign in
77
+ /*
78
+ * Define identifier discovery and the password step without applying new-password rules to existing passwords.
182
79
  */
183
-
184
- export const makeSignInSchema = () => ({
185
- listData: [
186
- {
187
- __type: 'input',
188
- // Can't do this because disabling the input will make post form ignore this field
189
- // locked: ({ hidePassword, lastIdentifier }: SignInDataForSchema) => !hidePassword && !!lastIdentifier,
190
- item: {
191
- name: 'identifier',
80
+ export function makeSignInSchema() {
81
+ return defineForm({
82
+ schema: z.object({ identifier: z.string(), password: z.string() }),
83
+ defaults: { identifier: '', password: '' },
84
+ fields: {
85
+ identifier: {
86
+ kind: 'input',
87
+ // Keep the identifier enabled so native form POST includes it.
88
+ suppressHydrationWarning: true,
192
89
  allowClearIfLocked: true,
193
90
  label: i18n.t('auth.login_opts_main'),
194
91
  placeholder: i18n.t('account.email_ph'),
195
92
  },
196
- },
197
- {
198
- __type: 'password',
199
- hidden: (dataForSchema?: SignInDataForSchema) =>
200
- !!dataForSchema?.hidePassword,
201
- autoFocus: true,
202
- item: {
203
- name: 'password',
93
+ password: {
94
+ kind: 'password',
204
95
  type: 'password',
96
+ autoFocus: true,
97
+ suppressHydrationWarning: true,
205
98
  label: i18n.t('account.password'),
206
99
  placeholder: i18n.t('account.password_ph'),
100
+ visibleWhen: ({ context }: { context?: Partial<SignInFormContext> }) => !context?.hidePassword,
207
101
  },
208
102
  },
209
- ],
210
- isButtonDisabled: (formValues: SignInFormType) => {
211
- return !formValues?.identifier?.trim();
212
- },
213
- });
103
+ canSubmit: ({ values }) => !!values.identifier.trim(),
104
+ });
105
+ }
214
106
 
215
- /**
216
- * Schema; Sign up
107
+ /*
108
+ * Define the email sign-up fields and the shared password strength and confirmation rules.
217
109
  */
218
-
219
- export const makeSignUpSchema = () => ({
220
- listData: [
221
- {
222
- __type: 'input',
223
- item: {
224
- name: 'email',
110
+ export function makeSignUpSchema() {
111
+ return defineForm({
112
+ schema: z
113
+ .object({
114
+ email: rules.email(),
115
+ password: rules.password(),
116
+ passwordRepeat: z.string(),
117
+ })
118
+ .superRefine(rules.matches('passwordRepeat', 'password')),
119
+ defaults: { email: '', password: '', passwordRepeat: '' },
120
+ fields: {
121
+ email: {
122
+ kind: 'input',
225
123
  label: i18n.t('account.email'),
226
124
  placeholder: i18n.t('account.email_ph'),
227
125
  },
228
- },
229
- {
230
- __type: 'password',
231
- item: {
232
- name: 'password',
126
+ password: {
127
+ kind: 'password',
233
128
  type: 'password',
234
129
  label: i18n.t('account.password'),
235
130
  placeholder: i18n.t('account.password_ph'),
236
131
  },
237
- },
238
- {
239
- __type: 'password',
240
- item: {
241
- name: 'passwordRepeat',
132
+ passwordRepeat: {
133
+ kind: 'password',
242
134
  type: 'password',
243
135
  label: i18n.t('account.passwordRepeat'),
244
136
  placeholder: i18n.t('account.password_ph'),
245
137
  },
246
138
  },
247
- ],
248
- isButtonDisabled: (formValues: Partial<SignUpFormType>) => {
249
- const fields: (keyof SignUpFormType)[] = [
250
- 'email',
251
- 'password',
252
- 'passwordRepeat',
253
- ];
254
- return fields.some((s) => !formValues[s]?.trim());
255
- },
256
- rules: [RULES.email, RULES.password, RULES.passwordRepeat],
257
- });
258
-
259
- /**
260
- * Schema; Request a link to reset password
261
- */
262
-
263
- interface RequestTokenizedEmailObj {
264
- email: string;
139
+ canSubmit: ({ values }) => !!values.email.trim() && !!values.password.trim() && !!values.passwordRepeat.trim(),
140
+ });
265
141
  }
266
142
 
267
- export const makeRequestTokenizedEmailSchema = () => ({
268
- listData: [
269
- {
270
- __type: 'input',
271
- item: {
272
- name: 'email',
143
+ /*
144
+ * Define the email field shared by verification, recovery, and organization sign-in discovery.
145
+ */
146
+ export function makeRequestTokenizedEmailSchema() {
147
+ return defineForm({
148
+ schema: z.object({ email: rules.email() }),
149
+ defaults: { email: '' },
150
+ fields: {
151
+ email: {
152
+ kind: 'input',
273
153
  label: i18n.t('account.email'),
274
154
  placeholder: i18n.t('account.email_ph'),
275
155
  },
276
156
  },
277
- ],
278
- isButtonDisabled: (formValues: Partial<RequestTokenizedEmailObj>) => {
279
- return !formValues.email?.trim();
280
- },
281
- rules: [RULES.email],
282
- });
283
-
284
- /**
285
- * Schema; Send phone verification code
286
- */
287
-
288
- interface SendPhoneVerificationObj {
289
- phone: string;
157
+ canSubmit: ({ values }) => !!values.email.trim(),
158
+ });
290
159
  }
291
160
 
292
- export const makeSendPhoneVerificationSchema = () => ({
293
- listData: [
294
- {
295
- __type: 'input',
296
- item: {
297
- name: 'phone',
298
- label: i18n.t('form.phone_number'),
161
+ /*
162
+ * Define the phone field used to request a sign-in verification code.
163
+ */
164
+ export function makeSendPhoneVerificationSchema() {
165
+ return defineForm({
166
+ schema: z.object({ phone: rules.phone() }),
167
+ defaults: { phone: '' },
168
+ fields: {
169
+ phone: {
170
+ kind: 'input',
171
+ label: i18n.t('c.phone_number'),
299
172
  placeholder: i18n.t('account.phone_ph'),
300
173
  },
301
174
  },
302
- ],
303
- isButtonDisabled: (formValues: Partial<SendPhoneVerificationObj>) => {
304
- return !formValues.phone?.trim();
305
- },
306
- rules: [RULES.phone],
307
- });
175
+ canSubmit: ({ values }) => !!values.phone.trim(),
176
+ });
177
+ }