@jsb188/auth-web 1.1.12 → 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.
@@ -6,7 +6,7 @@ import { PopOverButton, TooltipButton } from '@jsb188/react-web/modules/PopOver'
6
6
  import { Icon } from '@jsb188/react-web/svgs/Icon';
7
7
  import { AvatarImg } from '@jsb188/react-web/ui/Avatar';
8
8
  import { ActivityDots, ActivityIndicator } from '@jsb188/react-web/ui/Loading';
9
- import Markdown, { TextWithLinks } from '@jsb188/react-web/ui/Markdown';
9
+ import { TextWithLinks } from '@jsb188/react-web/ui/Markdown';
10
10
  import { memo, type ReactNode, useCallback, useContext, useEffect, useId, useState } from 'react';
11
11
  import { useAuthenticationPopup } from '../hooks/use-auth-popup.ts';
12
12
  import { useContinueWithGoogle, useContinueWithMicrosoft } from '../hooks/use-oauth';
@@ -24,25 +24,10 @@ interface InlineAuthFormProps {
24
24
  googleLabel?: string | null;
25
25
  microsoftLabel?: string | null;
26
26
  phoneLabel?: string | null;
27
- // Verified email of a temporary account-less respondent token holder
28
- respondentEmail?: string | null;
29
- // Respondent status / helper text shown next to the buttons; a plain string
30
- // is parsed for inline links, a node is rendered as-is
31
27
  accountMessage?: ReactNode;
32
- // When true, an OAuth-verified email with no account does not error; the
33
- // server returns a temporary respondent token (ANYONE web forms)
34
- authenticateOnly?: boolean;
35
- // Keep OAuth verification available to signed-in accounts whose primary
36
- // email cannot yet prove a respondent identity.
37
28
  requireVerifiedEmail?: boolean;
38
- // Require a real account identity and disable temporary verified-email
39
- // respondent authentication.
40
29
  requireOrgAuth?: boolean;
41
- // When supplied, the route owns respondent identity selection and this
42
- // module only renders that explicit choice.
43
- identityMode?: 'NONE' | 'ACCOUNT' | 'RESPONDENT';
44
- // Public web form context (contact-gated account creation / respondent token)
45
- formPublicId?: string | null;
30
+ identityMode?: 'NONE' | 'ACCOUNT';
46
31
  // Same-origin sign-in route opened for password and phone authentication
47
32
  authenticationPopupHref?: string | null;
48
33
  authenticationPopupLabel?: string;
@@ -51,8 +36,6 @@ interface InlineAuthFormProps {
51
36
  // Called after a real account sign-in flips the app into a logged-in state,
52
37
  // with the fresh auth token (e.g. to silently persist the SSR session cookie)
53
38
  onSignedIn?: (token: string, sessionBootstrapToken?: string | null, sessionPersisted?: boolean) => boolean | Promise<boolean>;
54
- // Called when authenticateOnly returned a temporary form respondent token
55
- onRespondentToken?: (token: string, email: string | null) => void;
56
39
  }
57
40
 
58
41
  /*
@@ -63,11 +46,11 @@ const InlineAuthFormOAuthButtonUI = memo(
63
46
  return (
64
47
  <button
65
48
  aria-label={p.label}
66
- className='btn outline av av_sm r h_center no_shrink bg'
49
+ className="btn outline av av_sm r h_center no_shrink bg"
67
50
  disabled={p.disabled || p.loading}
68
51
  onClick={p.onClick}
69
52
  title={p.label}
70
- type='button'
53
+ type="button"
71
54
  >
72
55
  {p.loading ? (
73
56
  <ActivityDots />
@@ -90,8 +73,6 @@ InlineAuthFormOAuthButtonUI.displayName = 'InlineAuthFormOAuthButtonUI';
90
73
  * Inline provider and popup sign-in that keeps the user on the current page.
91
74
  * The OAuth popup authenticates the user and the underlying hooks flip the
92
75
  * shared app state to logged-in (via onAccountLogin) with no navigation.
93
- * ANYONE web forms may pass authenticateOnly to accept account-less
94
- * respondents via a temporary token instead of forcing account creation.
95
76
  */
96
77
 
97
78
  const InlineAuthForm = memo((p: InlineAuthFormProps) => {
@@ -99,15 +80,11 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
99
80
  googleLabel,
100
81
  microsoftLabel,
101
82
  phoneLabel,
102
- respondentEmail,
103
83
  accountMessage,
104
- authenticateOnly,
105
84
  authenticationPopupHref,
106
85
  authenticationPopupLabel = i18n.t('auth.sign_in'),
107
- formPublicId,
108
86
  signOutHref = '/signout',
109
87
  onSignedIn,
110
- onRespondentToken,
111
88
  requireOrgAuth,
112
89
  requireVerifiedEmail,
113
90
  identityMode,
@@ -136,21 +113,10 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
136
113
  const canSwitchOrganizations = !!requireOrgAuth && (myOrganizations?.length || 0) > 1;
137
114
  const accountCanRespond = isLoggedIn && (!requireVerifiedEmail || (!!account?.email?.address && account.email.verified));
138
115
  const accountRequiresEmailVerification = isLoggedIn && requireVerifiedEmail && !accountCanRespond;
139
- const signedInName = identityMode
140
- ? identityMode === 'ACCOUNT'
141
- ? displayName || labelName
142
- : identityMode === 'RESPONDENT'
143
- ? respondentEmail || null
144
- : null
145
- : accountCanRespond
146
- ? displayName || labelName
147
- : respondentEmail || null;
148
- const isNonUserEmailRespondent = !requireOrgAuth && identityMode === 'RESPONDENT' && !!respondentEmail;
149
- const effectiveAuthenticateOnly = !requireOrgAuth && authenticateOnly;
150
- const canUseEmail = !!effectiveAuthenticateOnly && !!formPublicId && !!onRespondentToken;
151
- const showLoggedOutPrompt = !isLoggedIn && !!authenticationPopupHref && !isNonUserEmailRespondent;
116
+ const signedInName = (identityMode ? identityMode === 'ACCOUNT' : accountCanRespond) ? displayName || labelName : null;
117
+ const showLoggedOutPrompt = !isLoggedIn && !!authenticationPopupHref;
152
118
  const showSignedInIdentity = !!signedInName && !showLoggedOutPrompt && (!requireOrgAuth || !!primaryOrganizationName);
153
- const showProviderActions = !isLoggedIn && (isNonUserEmailRespondent || showLoggedOutPrompt || !signedInName);
119
+ const showProviderActions = !isLoggedIn && (showLoggedOutPrompt || !signedInName);
154
120
  const organizationIdentityLoading = !!requireOrgAuth && isLoggedIn && (!myOrganizations || !primaryOrganization);
155
121
 
156
122
  /*
@@ -179,17 +145,8 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
179
145
  },
180
146
  [dispatchApp, onFinishSignIn],
181
147
  );
182
- /* Adopt popup email verification without establishing an account session. */
183
- const onPopupRespondentAuthenticated = useCallback(
184
- (token: string, email: string) => {
185
- if (!accountCanRespond && canUseEmail) onRespondentToken?.(token, email);
186
- },
187
- [accountCanRespond, canUseEmail, onRespondentToken],
188
- );
189
148
  const { openAuthenticationPopup, popupOpen } = useAuthenticationPopup({
190
149
  href: authenticationPopupHref,
191
- formPublicId: canUseEmail ? formPublicId : null,
192
- onRespondentAuthenticated: canUseEmail ? onPopupRespondentAuthenticated : undefined,
193
150
  onAuthenticated: onPopupAuthenticated,
194
151
  });
195
152
 
@@ -229,7 +186,6 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
229
186
  waitingForOAuth: googleLoading,
230
187
  } = useContinueWithGoogle({
231
188
  onFinishSignIn,
232
- onRespondentToken: requireOrgAuth ? undefined : onRespondentToken,
233
189
  });
234
190
  const {
235
191
  onInitiateMicrosoftSignIn,
@@ -237,16 +193,15 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
237
193
  waitingForOAuth: microsoftLoading,
238
194
  } = useContinueWithMicrosoft({
239
195
  onFinishSignIn,
240
- onRespondentToken: requireOrgAuth ? undefined : onRespondentToken,
241
196
  });
242
197
 
243
198
  const onGoogle = useCallback(() => {
244
- onInitiateGoogleSignIn(undefined, null, formPublicId ?? null, effectiveAuthenticateOnly);
245
- }, [onInitiateGoogleSignIn, formPublicId, effectiveAuthenticateOnly]);
199
+ onInitiateGoogleSignIn();
200
+ }, [onInitiateGoogleSignIn]);
246
201
 
247
202
  const onMicrosoft = useCallback(() => {
248
- onInitiateMicrosoftSignIn(undefined, undefined, formPublicId ?? null, effectiveAuthenticateOnly);
249
- }, [onInitiateMicrosoftSignIn, formPublicId, effectiveAuthenticateOnly]);
203
+ onInitiateMicrosoftSignIn();
204
+ }, [onInitiateMicrosoftSignIn]);
250
205
 
251
206
  /*
252
207
  * Open the same email sign-in popup from the text link and email icon.
@@ -279,16 +234,16 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
279
234
  if (p.loading || organizationIdentityLoading) {
280
235
  return (
281
236
  <div
282
- aria-busy='true'
237
+ aria-busy="true"
283
238
  className={cn('h_spread gap_sm min_w_0', p.className)}
284
239
  >
285
240
  <ActivityIndicator
286
- className='ml_df'
287
- size='sm'
241
+ className="ml_df"
242
+ size="sm"
288
243
  />
289
244
  {isLoggedIn && (
290
245
  <a
291
- className='text ft_sm cl_md link mx_df'
246
+ className="text_link ft_sm cl_md link mx_df"
292
247
  href={signOutHref}
293
248
  >
294
249
  {i18n.t('auth.sign_out')}
@@ -301,64 +256,52 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
301
256
  return (
302
257
  <div className={cn('h_spread gap_sm min_w_0 f_wrap rel', p.className)}>
303
258
  {showSignedInIdentity ? (
304
- <div className='h_item gap_8 min_w_0'>
305
- {isNonUserEmailRespondent ? (
306
- <Markdown
307
- as='p'
308
- preset='content_description'
309
- className='cl_md ml_xs'
310
- >
311
- {i18n.t('auth.signed_in_as_email', {
312
- emailAddress: respondentEmail,
259
+ <div className="h_item gap_8 min_w_0">
260
+ <>
261
+ <AvatarImg
262
+ className="shift_up"
263
+ displayName={signedInName}
264
+ size="small"
265
+ letterBackgroundClassName="bd_2 bd_lt bg"
266
+ />
267
+ <p className="ft_medium">
268
+ {i18n.t(requireOrgAuth ? 'auth.logged_in_as_org_' : 'auth.logged_in_as_', {
269
+ name: signedInName,
270
+ orgName: primaryOrganizationName || '',
313
271
  })}
314
- </Markdown>
315
- ) : (
316
- <>
317
- <AvatarImg
318
- className='shift_up'
319
- displayName={signedInName}
320
- size='small'
321
- letterBackgroundClassName='bd_2 bd_lt bg'
322
- />
323
- <p className='ft_medium'>
324
- {i18n.t(requireOrgAuth ? 'auth.logged_in_as_org_' : 'auth.logged_in_as_', {
325
- name: signedInName,
326
- orgName: primaryOrganizationName || '',
327
- })}
328
- </p>
329
- </>
330
- )}
272
+ </p>
273
+ </>
331
274
  </div>
332
- ) : accountRequiresEmailVerification && !canUseEmail ? (
275
+ ) : accountRequiresEmailVerification ? (
333
276
  <TextWithLinks
334
- as='p'
335
- className='cl_md ml_xs'
336
- linkClassName='u cl_bd'
277
+ as="p"
278
+ className="cl_md ml_xs"
279
+ linkClassName="u cl_bd"
337
280
  >
338
281
  {i18n.t('auth.verify_email_to_fill_form')}
339
282
  </TextWithLinks>
340
- ) : showLoggedOutPrompt || (accountRequiresEmailVerification && canUseEmail) ? (
341
- <p className='ft_sm cl_md mx_df'>
283
+ ) : showLoggedOutPrompt ? (
284
+ <p className="ft_sm cl_md mx_df">
342
285
  {promptBeforeSignIn}
343
286
  <button
344
- className='text ft_sm cl_md link'
287
+ className="text_link ft_sm cl_md link"
345
288
  disabled={showLoggedOutPrompt ? googleDisabled || googleLoading : popupOpen}
346
289
  onClick={showLoggedOutPrompt ? onGoogle : onSignIn}
347
- type='button'
290
+ type="button"
348
291
  >
349
292
  {showLoggedOutPrompt ? i18n.t('auth.sign_in_to_google') : authenticationPopupLabel}
350
293
  </button>
351
294
  {promptAfterSignIn}
352
295
  </p>
353
296
  ) : null}
354
- <div className='h_item gap_5 no_shrink'>
297
+ <div className="h_item gap_5 no_shrink">
355
298
  {!isLoggedIn && !showLoginOptions ? (
356
299
  <PopOverButton
357
- as='button'
300
+ as="button"
358
301
  id={loginOptionsId}
359
- position='bottom_right'
302
+ position="bottom_right"
360
303
  ariaLabel={i18n.t('auth.more_login_options')}
361
- className='av av_sm h_center no_shrink link bg_hv r'
304
+ className="av av_sm h_center no_shrink link bg_hv r"
362
305
  iface={{
363
306
  name: 'PO_LIST',
364
307
  variables: {
@@ -366,25 +309,17 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
366
309
  },
367
310
  }}
368
311
  >
369
- <span className='ic_sm'>
370
- <Icon name='dots-vertical-filled' />
312
+ <span className="ic_sm">
313
+ <Icon name="dots-vertical-filled" />
371
314
  </span>
372
315
  </PopOverButton>
373
316
  ) : (
374
317
  <>
375
- {canUseEmail && !accountCanRespond ? (
376
- <InlineAuthFormOAuthButtonUI
377
- disabled={popupOpen}
378
- iconName='read-email-at'
379
- label={i18n.t('auth.sign_in_with_email')}
380
- onClick={onSignIn}
381
- />
382
- ) : null}
383
318
  {showProviderActions && phoneLabel && authenticationPopupHref ? (
384
319
  <InlineAuthFormOAuthButtonUI
385
320
  disabled={popupOpen}
386
- iconName='phone-circle'
387
- iconClassName='ic_df shift_up'
321
+ iconName="phone-circle"
322
+ iconClassName="ic_df shift_up"
388
323
  label={phoneLabel}
389
324
  onClick={onPhone}
390
325
  />
@@ -392,7 +327,7 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
392
327
  {showProviderActions && googleLabel ? (
393
328
  <InlineAuthFormOAuthButtonUI
394
329
  disabled={googleDisabled}
395
- iconName='brand-google-color'
330
+ iconName="brand-google-color"
396
331
  label={googleLabel}
397
332
  loading={googleLoading}
398
333
  onClick={onGoogle}
@@ -401,7 +336,7 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
401
336
  {showProviderActions && microsoftLabel ? (
402
337
  <InlineAuthFormOAuthButtonUI
403
338
  disabled={microsoftDisabled}
404
- iconName='brand-microsoft-color'
339
+ iconName="brand-microsoft-color"
405
340
  label={microsoftLabel}
406
341
  loading={microsoftLoading}
407
342
  onClick={onMicrosoft}
@@ -411,10 +346,10 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
411
346
  )}
412
347
  {isLoggedIn && canSwitchOrganizations ? (
413
348
  <button
414
- className='text ft_sm cl_md link ml_df'
349
+ className="text_link ft_sm cl_md link ml_df"
415
350
  disabled={organizationPopupOpen}
416
351
  onClick={onSwitchOrganization}
417
- type='button'
352
+ type="button"
418
353
  >
419
354
  {i18n.t('org.switch_organization')}
420
355
  </button>
@@ -422,16 +357,16 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
422
357
  {isLoggedIn && canSwitchOrganizations ? (
423
358
  <TooltipButton
424
359
  ariaLabel={i18n.t('auth.sign_out')}
425
- className='cl_md link ml_5 mr_df ic_sm h_center lh_1 no_shrink'
360
+ className="cl_md link ml_5 mr_df ic_sm h_center lh_1 no_shrink"
426
361
  message={i18n.t('auth.sign_out')}
427
362
  onClick={onSignOut}
428
- position='top'
363
+ position="top"
429
364
  >
430
- <Icon name='box-arrow-right' />
365
+ <Icon name="box-arrow-right" />
431
366
  </TooltipButton>
432
367
  ) : isLoggedIn ? (
433
368
  <a
434
- className='text ft_sm cl_md link mx_df'
369
+ className="text_link ft_sm cl_md link mx_df"
435
370
  href={signOutHref}
436
371
  >
437
372
  {i18n.t('auth.sign_out')}
@@ -441,14 +376,14 @@ const InlineAuthForm = memo((p: InlineAuthFormProps) => {
441
376
  {!!accountMessage &&
442
377
  (typeof accountMessage === 'string' ? (
443
378
  <TextWithLinks
444
- as='p'
445
- className='cl_md ml_xs'
446
- linkClassName='u cl_df'
379
+ as="p"
380
+ className="cl_md ml_xs"
381
+ linkClassName="u cl_df"
447
382
  >
448
383
  {accountMessage}
449
384
  </TextWithLinks>
450
385
  ) : (
451
- <p className='cl_md ft_md'>{accountMessage}</p>
386
+ <p className="cl_md ft_md">{accountMessage}</p>
452
387
  ))}
453
388
  </div>
454
389
  );
@@ -16,12 +16,15 @@ function formatManagedSessionDate(value?: string | null) {
16
16
  }
17
17
 
18
18
  /*
19
- * Convert server session rows into display-ready immutable list items.
19
+ * Convert server session rows into display-ready immutable list items, leaving
20
+ * out revoked sessions and sessions a realtime change marked deleted.
20
21
  */
21
- export function mapManagedSessionItems(sessions?: AccountSessionData[] | null): ManagedSessionListItem[] {
22
+ export function mapManagedSessionItems(
23
+ sessions?: Array<AccountSessionData & { __deleted?: boolean }> | null,
24
+ ): ManagedSessionListItem[] {
22
25
  if (!sessions?.length) return [];
23
26
  return sessions
24
- .filter((session) => !session.revokedAt)
27
+ .filter((session) => !session.revokedAt && !session.__deleted)
25
28
  .map((session) => ({
26
29
  ...session,
27
30
  displayName: session.deviceName || session.userAgent || i18n.t('account.session_unknown_device'),
@@ -1,15 +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';
9
5
  import { COMMON_ICON_NAMES } from '@jsb188/react-web/svgs/Icon';
10
6
 
11
7
  interface OAuthButtonProps {
12
- formPublicId?: string | null;
13
8
  onFinishSignIn: OnFinishSignInFn;
14
9
  }
15
10
 
@@ -22,16 +17,15 @@ interface AuthMethodButtonProps {
22
17
  */
23
18
 
24
19
  export const ContinueWithGoogle = (p: OAuthButtonProps) => {
25
- const { onFinishSignIn, formPublicId } = p;
26
- const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } =
27
- useContinueWithGoogle({
28
- onFinishSignIn,
29
- });
20
+ const { onFinishSignIn } = p;
21
+ const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithGoogle({
22
+ onFinishSignIn,
23
+ });
30
24
 
31
- /* Launch Google OAuth with the current public-form context. */
25
+ /* Launch Google OAuth with the current account credentials. */
32
26
  const onClick = useCallback(() => {
33
- onInitiateGoogleSignIn(undefined, null, formPublicId ?? null);
34
- }, [formPublicId, onInitiateGoogleSignIn]);
27
+ onInitiateGoogleSignIn(undefined);
28
+ }, [onInitiateGoogleSignIn]);
35
29
 
36
30
  return (
37
31
  <FullWidthButton
@@ -52,16 +46,15 @@ export const ContinueWithGoogle = (p: OAuthButtonProps) => {
52
46
  */
53
47
 
54
48
  export const ContinueWithMicrosoft = (p: OAuthButtonProps) => {
55
- const { onFinishSignIn, formPublicId } = p;
56
- const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } =
57
- useContinueWithMicrosoft({
58
- onFinishSignIn,
59
- });
49
+ const { onFinishSignIn } = p;
50
+ const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithMicrosoft({
51
+ onFinishSignIn,
52
+ });
60
53
 
61
- /* Launch Microsoft OAuth with the current public-form context. */
54
+ /* Launch Microsoft OAuth with the current account credentials. */
62
55
  const onClick = useCallback(() => {
63
- onInitiateMicrosoftSignIn(undefined, undefined, formPublicId ?? null);
64
- }, [formPublicId, onInitiateMicrosoftSignIn]);
56
+ onInitiateMicrosoftSignIn();
57
+ }, [onInitiateMicrosoftSignIn]);
65
58
 
66
59
  return (
67
60
  <FullWidthButton
@@ -83,14 +76,14 @@ export const ContinueWithMicrosoft = (p: OAuthButtonProps) => {
83
76
 
84
77
  export const ContinueWithSso = (p: AuthMethodButtonProps) => {
85
78
  const { onClickButton } = p;
86
- return (
87
- <FullWidthButton
88
- onClick={onClickButton}
89
- preset="em"
90
- className="mb_sm"
91
- iconName={COMMON_ICON_NAMES.enterprise_signin}
92
- iconClassName="ft_md shift_up"
93
- tryColor
79
+ return (
80
+ <FullWidthButton
81
+ onClick={onClickButton}
82
+ preset="em"
83
+ className="mb_sm"
84
+ iconName={COMMON_ICON_NAMES.enterprise_signin}
85
+ iconClassName="ft_md shift_up"
86
+ tryColor
94
87
  >
95
88
  {i18n.t('auth.continue_with_sso')}
96
89
  </FullWidthButton>
@@ -1,5 +1,4 @@
1
1
  import { runWithAuthSessionBrowserLock } from '@jsb188/app/utils/authSession.ts';
2
- import { clearGoogleAutoSignInSuppression } from '../utils/googleIdentity';
3
2
 
4
3
  /**
5
4
  * Types
@@ -12,8 +11,6 @@ export type OAuthSessionAuthenticationInput = {
12
11
  oauthToken?: string | null;
13
12
  idToken?: string | null;
14
13
  ssoConnectionId?: string | null;
15
- formPublicId?: string | null;
16
- authenticateOnly?: boolean;
17
14
  };
18
15
 
19
16
  export type OAuthSessionAuthenticationResult = {
@@ -51,29 +48,15 @@ export function getAuthReturnQuery(returnTo?: string | null) {
51
48
  return returnTo ? new URLSearchParams({ returnTo }).toString() : undefined;
52
49
  }
53
50
 
54
- /*
55
- * Accept only a same-site public-form destination and extract its campaign id.
56
- */
57
- export function getPublicFormReturnContext(value?: string | null) {
58
- const match = value?.match(/^\/form\/([A-Za-z0-9]+)$/);
59
- return {
60
- formPublicId: match?.[1] || null,
61
- returnTo: match?.[0] || null,
62
- };
63
- }
64
-
65
51
  /*
66
52
  * Preserve only explicitly supported account-auth destinations. MCP consent is
67
- * account authentication and must never acquire public-form respondent semantics.
53
+ * account authentication.
68
54
  */
69
55
  export function getAuthReturnContext(value?: string | null) {
70
- const publicForm = getPublicFormReturnContext(value);
71
- if (publicForm.returnTo) return publicForm;
72
56
  const consent = value?.match(
73
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})$/,
74
58
  );
75
59
  return {
76
- formPublicId: null,
77
60
  returnTo: consent ? `/auth/mcp-consent?request=${consent[1]}` : value === '/auth/mcp-connections' ? value : null,
78
61
  };
79
62
  }
@@ -121,8 +104,6 @@ export async function authenticateOAuthSignInSession(
121
104
  ...(input.oauthToken ? { oauthToken: input.oauthToken } : {}),
122
105
  ...(input.idToken ? { idToken: input.idToken } : {}),
123
106
  ...(input.ssoConnectionId ? { ssoConnectionId: input.ssoConnectionId } : {}),
124
- ...(input.formPublicId ? { formPublicId: input.formPublicId } : {}),
125
- ...(input.authenticateOnly ? { authenticateOnly: '1' } : {}),
126
107
  });
127
108
  const response = await fetch('/auth/session', {
128
109
  signal,
@@ -140,9 +121,6 @@ export async function authenticateOAuthSignInSession(
140
121
  error: result?.error || { errorCode: 'network_error' },
141
122
  };
142
123
  }
143
- if (input.provider === 'GOOGLE' && (result.auth?.account?.id || result.auth?.respondentToken)) {
144
- clearGoogleAutoSignInSuppression();
145
- }
146
124
  return { auth: result.auth || null, error: null };
147
125
  });
148
126
  } catch {
@@ -1,6 +1,7 @@
1
1
  import { SUPPORTED_COUNTRIES } from '@jsb188/app/constants/app.ts';
2
2
  import i18n from '@jsb188/app/i18n/index.ts';
3
3
  import type { AddressObj } from '@jsb188/app/types/other.d.ts';
4
+ import { hasAddressDetails } from '@jsb188/app/utils/string.ts';
4
5
  import { defineForm } from '@jsb188/form/libs/defineForm';
5
6
  import { z } from 'zod';
6
7
 
@@ -13,14 +14,17 @@ export function makeAddressValueSchema() {
13
14
  city: z.string(),
14
15
  state: z.string(),
15
16
  postalCode: z.string(),
16
- country: z.string(),
17
+ country: z.string().trim(),
17
18
  })
18
19
  .superRefine((address, context) => {
19
- const hasAddress = [address.line1, address.line2, address.city, address.state, address.postalCode].some((value) => value.trim());
20
- if (!hasAddress) {
20
+ if (!hasAddressDetails(address)) {
21
21
  return;
22
22
  }
23
23
 
24
+ if (address.country && !SUPPORTED_COUNTRIES.includes(address.country)) {
25
+ context.addIssue({ code: z.ZodIssueCode.custom, path: ['country'], message: i18n.t('error.20099') });
26
+ }
27
+
24
28
  for (const field of ['line1', 'postalCode', 'city', 'state', 'country'] as const) {
25
29
  if (!address[field].trim()) {
26
30
  context.addIssue({
@@ -81,8 +85,10 @@ export function makeAddressSchema(address?: Partial<AddressObj> | null, popOverD
81
85
  'address.country': {
82
86
  kind: 'click',
83
87
  label: i18n.t('c.country'),
84
- getter: (value: string) => (value ? i18n.t(`country.from_code.${value}`) : ''),
88
+ getter: (value: string) => (SUPPORTED_COUNTRIES.includes(value) ? i18n.t(`country.from_code.${value}`) : value),
85
89
  resolve: ({ values }) => ({
90
+ rightText:
91
+ values.address.country && !SUPPORTED_COUNTRIES.includes(values.address.country.trim()) ? i18n.t('error.20099') : undefined,
86
92
  placeholder: values.address.country || i18n.t('c.country_ph'),
87
93
  popOverProps: {
88
94
  id: 'address.country',
@@ -33,63 +33,3 @@ export function isAuthPopupCompletionMessage(value: unknown, popupId: string): v
33
33
  (message.primaryOrganizationId === undefined || typeof message.primaryOrganizationId === 'string')
34
34
  );
35
35
  }
36
-
37
- export const AUTH_POPUP_RESPONDENT_MESSAGE_TYPE = 'marketday-form-auth-complete';
38
-
39
- export interface AuthPopupRespondentCompletionMessage {
40
- type: typeof AUTH_POPUP_RESPONDENT_MESSAGE_TYPE;
41
- popupId: string;
42
- formPublicId: string;
43
- respondentToken: string;
44
- respondentEmail: string;
45
- }
46
-
47
- /*
48
- * Accept a respondent credential only for the popup and public form that requested it.
49
- */
50
- export function isAuthPopupRespondentCompletionMessage(
51
- value: unknown,
52
- popupId: string,
53
- formPublicId: string,
54
- ): value is AuthPopupRespondentCompletionMessage {
55
- if (!value || typeof value !== 'object') return false;
56
- const message = value as Partial<AuthPopupRespondentCompletionMessage>;
57
- return (
58
- message.type === AUTH_POPUP_RESPONDENT_MESSAGE_TYPE &&
59
- message.popupId === popupId &&
60
- message.formPublicId === formPublicId &&
61
- typeof message.respondentToken === 'string' &&
62
- !!message.respondentToken &&
63
- typeof message.respondentEmail === 'string' &&
64
- !!message.respondentEmail
65
- );
66
- }
67
-
68
- /*
69
- * Hand a verified form identity directly to the same-origin opener without putting credentials in a URL or cookie.
70
- */
71
- export function postAuthPopupRespondentCompletion(
72
- popupId: string,
73
- formPublicId: string,
74
- respondentToken: string,
75
- respondentEmail: string,
76
- ): boolean {
77
- if (!getAuthPopupCompletionPath(popupId) || !formPublicId || !respondentToken || !respondentEmail || !globalThis.opener) {
78
- return false;
79
- }
80
- try {
81
- globalThis.opener.postMessage(
82
- {
83
- type: AUTH_POPUP_RESPONDENT_MESSAGE_TYPE,
84
- popupId,
85
- formPublicId,
86
- respondentToken,
87
- respondentEmail,
88
- } satisfies AuthPopupRespondentCompletionMessage,
89
- globalThis.location.origin,
90
- );
91
- return true;
92
- } catch {
93
- return false;
94
- }
95
- }