@jsb188/auth-web 1.1.10 → 1.1.11

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,109 +1,135 @@
1
1
  import i18n from '@jsb188/app/i18n/index.ts';
2
2
  import type { AccountSessionData } from '@jsb188/app/types/auth.d.ts';
3
- import { useRevokeMyAccountSession, useRevokeMyOtherAccountSessions } from '@jsb188/graphql/hooks/use-auth-mtn';
3
+ import {
4
+ useRevokeMyAccountSession,
5
+ useRevokeMyOtherAccountSessions,
6
+ } from '@jsb188/graphql/hooks/use-auth-mtn';
4
7
  import { useMyAccountSessions } from '@jsb188/graphql/hooks/use-auth-qry';
5
8
  import { FullWidthButton } from '@jsb188/react-web/ui/Button';
6
9
  import { BigLoading } from '@jsb188/react-web/ui/Loading';
7
10
  import { useMemo, useState } from 'react';
8
- import { type ManagedSessionListItem, ManagedSessionListUI } from '../ui/ManagedSessionUI.tsx';
11
+ import {
12
+ type ManagedSessionListItem,
13
+ ManagedSessionListUI,
14
+ } from '../ui/ManagedSessionUI.tsx';
9
15
 
10
16
  /*
11
17
  * Format one managed-session timestamp for the current browser locale.
12
18
  */
13
19
  function formatManagedSessionDate(value?: string | null) {
14
- const date = value ? new Date(value) : null;
15
- return date && !isNaN(date.getTime()) ? date.toLocaleString() : '-';
20
+ const date = value ? new Date(value) : null;
21
+ return date && !isNaN(date.getTime()) ? date.toLocaleString() : '-';
16
22
  }
17
23
 
18
24
  /*
19
25
  * Convert server session rows into display-ready immutable list items.
20
26
  */
21
- export function mapManagedSessionItems(sessions?: AccountSessionData[] | null): ManagedSessionListItem[] {
22
- return (sessions || [])
23
- .filter((session) => !session.revokedAt)
24
- .map((session) => ({
25
- ...session,
26
- displayName: session.deviceName || session.userAgent || i18n.t('account.session_unknown_device'),
27
- displayExpiresAt: formatManagedSessionDate(session.absoluteExpiresAt),
28
- displayLastActivityAt: formatManagedSessionDate(session.lastActivityAt),
29
- }))
30
- .sort((a, b) => Number(b.current) - Number(a.current) || new Date(b.lastActivityAt).getTime() - new Date(a.lastActivityAt).getTime());
27
+ export function mapManagedSessionItems(
28
+ sessions?: AccountSessionData[] | null,
29
+ ): ManagedSessionListItem[] {
30
+ return (sessions || [])
31
+ .filter((session) => !session.revokedAt)
32
+ .map((session) => ({
33
+ ...session,
34
+ displayName:
35
+ session.deviceName ||
36
+ session.userAgent ||
37
+ i18n.t('account.session_unknown_device'),
38
+ displayExpiresAt: formatManagedSessionDate(session.absoluteExpiresAt),
39
+ displayLastActivityAt: formatManagedSessionDate(session.lastActivityAt),
40
+ }))
41
+ .sort(
42
+ (a, b) =>
43
+ Number(b.current) - Number(a.current) ||
44
+ new Date(b.lastActivityAt).getTime() -
45
+ new Date(a.lastActivityAt).getTime(),
46
+ );
31
47
  }
32
48
 
33
49
  /*
34
50
  * Load and manage the current account's active device sessions.
35
51
  */
36
52
  export function ManagedSessions() {
37
- const { accountSessions, loading } = useMyAccountSessions();
38
- const [savingSessionId, setSavingSessionId] = useState<string | null>(null);
39
- const [revokedSessionIds, setRevokedSessionIds] = useState<Set<string>>(() => new Set());
40
- const [hideOtherSessions, setHideOtherSessions] = useState(false);
41
- const { revokeMyAccountSession } = useRevokeMyAccountSession({
42
- onCompleted: (data, _error, variables) => {
43
- if (data?.revokeMyAccountSession && variables?.sessionId) {
44
- setRevokedSessionIds((current) => new Set(current).add(variables.sessionId));
45
- }
46
- setSavingSessionId(null);
47
- },
48
- onError: () => setSavingSessionId(null),
49
- });
50
- const { revokeMyOtherAccountSessions, saving: savingOthers } = useRevokeMyOtherAccountSessions({
51
- onCompleted: (data) => {
52
- if (data?.revokeMyOtherAccountSessions) {
53
- setHideOtherSessions(true);
54
- }
55
- },
56
- });
57
- const items = useMemo(
58
- () => mapManagedSessionItems(accountSessions).filter((session) => !revokedSessionIds.has(session.id) && (!hideOtherSessions || session.current)),
59
- [accountSessions, hideOtherSessions, revokedSessionIds],
60
- );
53
+ const { accountSessions, loading } = useMyAccountSessions();
54
+ const [savingSessionId, setSavingSessionId] = useState<string | null>(null);
55
+ const [revokedSessionIds, setRevokedSessionIds] = useState<Set<string>>(
56
+ () => new Set(),
57
+ );
58
+ const [hideOtherSessions, setHideOtherSessions] = useState(false);
59
+ const { revokeMyAccountSession } = useRevokeMyAccountSession({
60
+ onCompleted: (data, _error, variables) => {
61
+ if (data?.revokeMyAccountSession && variables?.sessionId) {
62
+ setRevokedSessionIds((current) =>
63
+ new Set(current).add(variables.sessionId),
64
+ );
65
+ }
66
+ setSavingSessionId(null);
67
+ },
68
+ onError: () => setSavingSessionId(null),
69
+ });
70
+ const { revokeMyOtherAccountSessions, saving: savingOthers } =
71
+ useRevokeMyOtherAccountSessions({
72
+ onCompleted: (data) => {
73
+ if (data?.revokeMyOtherAccountSessions) {
74
+ setHideOtherSessions(true);
75
+ }
76
+ },
77
+ });
78
+ const items = useMemo(
79
+ () =>
80
+ mapManagedSessionItems(accountSessions).filter(
81
+ (session) =>
82
+ !revokedSessionIds.has(session.id) &&
83
+ (!hideOtherSessions || session.current),
84
+ ),
85
+ [accountSessions, hideOtherSessions, revokedSessionIds],
86
+ );
61
87
 
62
- /*
63
- * Revoke one selected managed session.
64
- */
65
- const onRevokeSession = (sessionId: string) => {
66
- setSavingSessionId(sessionId);
67
- revokeMyAccountSession({
68
- variables: {
69
- sessionId,
70
- },
71
- });
72
- };
88
+ /*
89
+ * Revoke one selected managed session.
90
+ */
91
+ const onRevokeSession = (sessionId: string) => {
92
+ setSavingSessionId(sessionId);
93
+ revokeMyAccountSession({
94
+ variables: {
95
+ sessionId,
96
+ },
97
+ });
98
+ };
73
99
 
74
- if (loading && !accountSessions) {
75
- return (
76
- <div className='h_160 v_center'>
77
- <BigLoading />
78
- </div>
79
- );
80
- }
100
+ if (loading && !accountSessions) {
101
+ return (
102
+ <div className="h_160 v_center">
103
+ <BigLoading />
104
+ </div>
105
+ );
106
+ }
81
107
 
82
- return (
83
- <div className='max_w_600'>
84
- <p className='cl_lt mb_sm'>{i18n.t('account.sessions_desc')}</p>
85
- <ManagedSessionListUI
86
- items={items}
87
- emptyText={i18n.t('account.session_none')}
88
- revokeText={i18n.t('account.session_sign_out')}
89
- currentText={i18n.t('account.session_current')}
90
- expiresText={i18n.t('account.session_expires')}
91
- lastActiveText={i18n.t('account.session_last_active')}
92
- savingSessionId={savingSessionId}
93
- onRevoke={onRevokeSession}
94
- />
95
- {items.length <= 1 ? null : (
96
- <FullWidthButton
97
- fullWidth={false}
98
- className='mt_md'
99
- preset='outline'
100
- loading={savingOthers}
101
- disabled={savingOthers}
102
- onClick={() => revokeMyOtherAccountSessions()}
103
- >
104
- {i18n.t('account.session_sign_out_others')}
105
- </FullWidthButton>
106
- )}
107
- </div>
108
- );
108
+ return (
109
+ <div className="max_w_600">
110
+ <p className="cl_lt mb_sm">{i18n.t('account.sessions_desc')}</p>
111
+ <ManagedSessionListUI
112
+ items={items}
113
+ emptyText={i18n.t('account.session_none')}
114
+ revokeText={i18n.t('account.session_sign_out')}
115
+ currentText={i18n.t('account.session_current')}
116
+ expiresText={i18n.t('account.session_expires')}
117
+ lastActiveText={i18n.t('account.session_last_active')}
118
+ savingSessionId={savingSessionId}
119
+ onRevoke={onRevokeSession}
120
+ />
121
+ {items.length <= 1 ? null : (
122
+ <FullWidthButton
123
+ fullWidth={false}
124
+ className="mt_md"
125
+ preset="outline"
126
+ loading={savingOthers}
127
+ disabled={savingOthers}
128
+ onClick={() => revokeMyOtherAccountSessions()}
129
+ >
130
+ {i18n.t('account.session_sign_out_others')}
131
+ </FullWidthButton>
132
+ )}
133
+ </div>
134
+ );
109
135
  }
@@ -2,18 +2,18 @@ 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
4
  import {
5
- type OnFinishSignInFn,
6
- useContinueWithGoogle,
7
- useContinueWithMicrosoft,
5
+ type OnFinishSignInFn,
6
+ useContinueWithGoogle,
7
+ useContinueWithMicrosoft,
8
8
  } from '../hooks/use-oauth';
9
9
 
10
10
  interface OAuthButtonProps {
11
- formPublicId?: string | null;
12
- onFinishSignIn: OnFinishSignInFn;
11
+ formPublicId?: string | null;
12
+ onFinishSignIn: OnFinishSignInFn;
13
13
  }
14
14
 
15
15
  interface AuthMethodButtonProps {
16
- onClickButton: () => void;
16
+ onClickButton: () => void;
17
17
  }
18
18
 
19
19
  /**
@@ -21,28 +21,29 @@ interface AuthMethodButtonProps {
21
21
  */
22
22
 
23
23
  export const ContinueWithGoogle = (p: OAuthButtonProps) => {
24
- const { onFinishSignIn, formPublicId } = p;
25
- const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithGoogle({
26
- onFinishSignIn
27
- });
24
+ const { onFinishSignIn, formPublicId } = p;
25
+ const { onInitiateGoogleSignIn, oauthButtonDisabled, waitingForOAuth } =
26
+ useContinueWithGoogle({
27
+ onFinishSignIn,
28
+ });
28
29
 
29
- /* Launch Google OAuth with the current public-form context. */
30
- const onClick = useCallback(() => {
31
- onInitiateGoogleSignIn(undefined, null, formPublicId ?? null);
32
- }, [formPublicId, onInitiateGoogleSignIn]);
30
+ /* Launch Google OAuth with the current public-form context. */
31
+ const onClick = useCallback(() => {
32
+ onInitiateGoogleSignIn(undefined, null, formPublicId ?? null);
33
+ }, [formPublicId, onInitiateGoogleSignIn]);
33
34
 
34
- return (
35
- <FullWidthButton
36
- disabled={oauthButtonDisabled}
37
- loading={waitingForOAuth}
38
- onClick={onClick}
39
- preset='em'
40
- className='mb_sm'
41
- iconName='brand-google-color'
42
- >
43
- {i18n.t('auth.continue_with_google')}
44
- </FullWidthButton>
45
- );
35
+ return (
36
+ <FullWidthButton
37
+ disabled={oauthButtonDisabled}
38
+ loading={waitingForOAuth}
39
+ onClick={onClick}
40
+ preset="em"
41
+ className="mb_sm"
42
+ iconName="brand-google-color"
43
+ >
44
+ {i18n.t('auth.continue_with_google')}
45
+ </FullWidthButton>
46
+ );
46
47
  };
47
48
 
48
49
  /**
@@ -50,28 +51,29 @@ export const ContinueWithGoogle = (p: OAuthButtonProps) => {
50
51
  */
51
52
 
52
53
  export const ContinueWithMicrosoft = (p: OAuthButtonProps) => {
53
- const { onFinishSignIn, formPublicId } = p;
54
- const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } = useContinueWithMicrosoft({
55
- onFinishSignIn
56
- });
54
+ const { onFinishSignIn, formPublicId } = p;
55
+ const { onInitiateMicrosoftSignIn, oauthButtonDisabled, waitingForOAuth } =
56
+ useContinueWithMicrosoft({
57
+ onFinishSignIn,
58
+ });
57
59
 
58
- /* Launch Microsoft OAuth with the current public-form context. */
59
- const onClick = useCallback(() => {
60
- onInitiateMicrosoftSignIn(undefined, undefined, formPublicId ?? null);
61
- }, [formPublicId, onInitiateMicrosoftSignIn]);
60
+ /* Launch Microsoft OAuth with the current public-form context. */
61
+ const onClick = useCallback(() => {
62
+ onInitiateMicrosoftSignIn(undefined, undefined, formPublicId ?? null);
63
+ }, [formPublicId, onInitiateMicrosoftSignIn]);
62
64
 
63
- return (
64
- <FullWidthButton
65
- disabled={oauthButtonDisabled}
66
- loading={waitingForOAuth}
67
- onClick={onClick}
68
- preset='em'
69
- className='mb_sm'
70
- iconName='brand-microsoft-color'
71
- >
72
- {i18n.t('auth.continue_with_microsoft')}
73
- </FullWidthButton>
74
- );
65
+ return (
66
+ <FullWidthButton
67
+ disabled={oauthButtonDisabled}
68
+ loading={waitingForOAuth}
69
+ onClick={onClick}
70
+ preset="em"
71
+ className="mb_sm"
72
+ iconName="brand-microsoft-color"
73
+ >
74
+ {i18n.t('auth.continue_with_microsoft')}
75
+ </FullWidthButton>
76
+ );
75
77
  };
76
78
 
77
79
  /**
@@ -79,18 +81,18 @@ export const ContinueWithMicrosoft = (p: OAuthButtonProps) => {
79
81
  */
80
82
 
81
83
  export const ContinueWithSso = (p: AuthMethodButtonProps) => {
82
- const { onClickButton } = p;
83
- return (
84
- <FullWidthButton
85
- onClick={onClickButton}
86
- preset='em'
87
- className='mb_sm'
88
- iconName='buildings-2-color'
89
- iconClassName='ft_md shift_up'
90
- >
91
- {i18n.t('auth.continue_with_sso')}
92
- </FullWidthButton>
93
- );
84
+ const { onClickButton } = p;
85
+ return (
86
+ <FullWidthButton
87
+ onClick={onClickButton}
88
+ preset="em"
89
+ className="mb_sm"
90
+ iconName="buildings-2-color"
91
+ iconClassName="ft_md shift_up"
92
+ >
93
+ {i18n.t('auth.continue_with_sso')}
94
+ </FullWidthButton>
95
+ );
94
96
  };
95
97
 
96
98
  /**
@@ -98,17 +100,17 @@ export const ContinueWithSso = (p: AuthMethodButtonProps) => {
98
100
  */
99
101
 
100
102
  export const ContinueWithPhone = (p: AuthMethodButtonProps) => {
101
- const { onClickButton } = p;
102
- return (
103
- <FullWidthButton
104
- onClick={onClickButton}
105
- preset='em'
106
- className='mb_sm'
107
- iconName='phone-circle'
108
- iconClassName='ft_md shift_up'
109
- tryColor
110
- >
111
- {i18n.t('auth.continue_with_phone')}
112
- </FullWidthButton>
113
- );
103
+ const { onClickButton } = p;
104
+ return (
105
+ <FullWidthButton
106
+ onClick={onClickButton}
107
+ preset="em"
108
+ className="mb_sm"
109
+ iconName="phone-circle"
110
+ iconClassName="ft_md shift_up"
111
+ tryColor
112
+ >
113
+ {i18n.t('auth.continue_with_phone')}
114
+ </FullWidthButton>
115
+ );
114
116
  };
@@ -4,20 +4,26 @@ import { runWithAuthSessionBrowserLock } from '@jsb188/app/utils/authSession.ts'
4
4
  * Types
5
5
  */
6
6
 
7
- export type AuthPageName = 'signin' | 'signin_success' | 'signup' | 'signup_success' | 'reset_password' | 'welcome';
7
+ export type AuthPageName =
8
+ | 'signin'
9
+ | 'signin_success'
10
+ | 'signup'
11
+ | 'signup_success'
12
+ | 'reset_password'
13
+ | 'welcome';
8
14
 
9
15
  export type OAuthSessionAuthenticationInput = {
10
- provider: 'GOOGLE' | 'MICROSOFT';
11
- oauthToken?: string | null;
12
- idToken?: string | null;
13
- ssoConnectionId?: string | null;
14
- formPublicId?: string | null;
15
- authenticateOnly?: boolean;
16
+ provider: 'GOOGLE' | 'MICROSOFT';
17
+ oauthToken?: string | null;
18
+ idToken?: string | null;
19
+ ssoConnectionId?: string | null;
20
+ formPublicId?: string | null;
21
+ authenticateOnly?: boolean;
16
22
  };
17
23
 
18
24
  export type OAuthSessionAuthenticationResult = {
19
- auth: any | null;
20
- error: any | null;
25
+ auth: any | null;
26
+ error: any | null;
21
27
  };
22
28
 
23
29
  /**
@@ -25,43 +31,47 @@ export type OAuthSessionAuthenticationResult = {
25
31
  */
26
32
 
27
33
  export function getAuthRoute(
28
- pageName: AuthPageName,
29
- authRoutesMap?: Record<AuthPageName, string>,
30
- queryStr?: string
34
+ pageName: AuthPageName,
35
+ authRoutesMap?: Record<AuthPageName, string>,
36
+ queryStr?: string,
31
37
  ) {
32
- const defaultAuthRoutesMap: Record<AuthPageName, string> = {
33
- signin: '/auth/signin',
34
- signin_success: '/auth/success',
35
- signup: '/auth/signup',
36
- signup_success: '/auth/signup-finished',
37
- reset_password: '/auth/reset-password',
38
- welcome: '/auth/welcome',
39
- };
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
+ };
40
46
 
41
- const pathname = authRoutesMap?.[pageName] || defaultAuthRoutesMap[pageName] || 'auth';
42
- return queryStr ? `${pathname}?${queryStr}` : pathname;
47
+ const pathname =
48
+ authRoutesMap?.[pageName] || defaultAuthRoutesMap[pageName] || 'auth';
49
+ return queryStr ? `${pathname}?${queryStr}` : pathname;
43
50
  }
44
51
 
45
52
  /*
46
53
  * Post one login credential to the same-origin HttpOnly-cookie endpoint.
47
54
  */
48
- async function postSignInSessionCredential(name: 'bootstrapToken' | 'token', value: string): Promise<boolean> {
49
- try {
50
- const response = await fetch('/auth/session', {
51
- method: 'POST',
52
- credentials: 'same-origin',
53
- headers: {
54
- 'Content-Type': 'application/x-www-form-urlencoded',
55
- },
56
- body: new URLSearchParams({
57
- [name]: value,
58
- managedSessionVersion: '1',
59
- }),
60
- });
61
- return response.ok;
62
- } catch {
63
- return false;
64
- }
55
+ async function postSignInSessionCredential(
56
+ name: 'bootstrapToken' | 'token',
57
+ value: string,
58
+ ): Promise<boolean> {
59
+ try {
60
+ const response = await fetch('/auth/session', {
61
+ method: 'POST',
62
+ credentials: 'same-origin',
63
+ headers: {
64
+ 'Content-Type': 'application/x-www-form-urlencoded',
65
+ },
66
+ body: new URLSearchParams({
67
+ [name]: value,
68
+ managedSessionVersion: '1',
69
+ }),
70
+ });
71
+ return response.ok;
72
+ } catch {
73
+ return false;
74
+ }
65
75
  }
66
76
 
67
77
  /*
@@ -69,57 +79,65 @@ async function postSignInSessionCredential(name: 'bootstrapToken' | 'token', val
69
79
  * atomically persist the resulting HttpOnly managed-session cookie.
70
80
  */
71
81
  export async function authenticateOAuthSignInSession(
72
- input: OAuthSessionAuthenticationInput,
82
+ input: OAuthSessionAuthenticationInput,
73
83
  ): Promise<OAuthSessionAuthenticationResult> {
74
- if (typeof fetch !== 'function') {
75
- return { auth: null, error: { errorCode: 'network_error' } };
76
- }
84
+ if (typeof fetch !== 'function') {
85
+ return { auth: null, error: { errorCode: 'network_error' } };
86
+ }
77
87
 
78
- try {
79
- return await runWithAuthSessionBrowserLock(async () => {
80
- const body = new URLSearchParams({
81
- provider: input.provider,
82
- managedSessionVersion: '1',
83
- ...(input.oauthToken ? { oauthToken: input.oauthToken } : {}),
84
- ...(input.idToken ? { idToken: input.idToken } : {}),
85
- ...(input.ssoConnectionId ? { ssoConnectionId: input.ssoConnectionId } : {}),
86
- ...(input.formPublicId ? { formPublicId: input.formPublicId } : {}),
87
- ...(input.authenticateOnly ? { authenticateOnly: '1' } : {}),
88
- });
89
- const response = await fetch('/auth/session', {
90
- method: 'POST',
91
- credentials: 'same-origin',
92
- headers: {
93
- 'Content-Type': 'application/x-www-form-urlencoded',
94
- },
95
- body,
96
- });
97
- const result = await response.json().catch(() => null);
98
- if (!response.ok || !result?.ok) {
99
- return {
100
- auth: null,
101
- error: result?.error || { errorCode: 'network_error' },
102
- };
103
- }
104
- return { auth: result.auth || null, error: null };
105
- });
106
- } catch {
107
- return { auth: null, error: { errorCode: 'network_error' } };
108
- }
88
+ try {
89
+ return await runWithAuthSessionBrowserLock(async () => {
90
+ const body = new URLSearchParams({
91
+ provider: input.provider,
92
+ managedSessionVersion: '1',
93
+ ...(input.oauthToken ? { oauthToken: input.oauthToken } : {}),
94
+ ...(input.idToken ? { idToken: input.idToken } : {}),
95
+ ...(input.ssoConnectionId
96
+ ? { ssoConnectionId: input.ssoConnectionId }
97
+ : {}),
98
+ ...(input.formPublicId ? { formPublicId: input.formPublicId } : {}),
99
+ ...(input.authenticateOnly ? { authenticateOnly: '1' } : {}),
100
+ });
101
+ const response = await fetch('/auth/session', {
102
+ method: 'POST',
103
+ credentials: 'same-origin',
104
+ headers: {
105
+ 'Content-Type': 'application/x-www-form-urlencoded',
106
+ },
107
+ body,
108
+ });
109
+ const result = await response.json().catch(() => null);
110
+ if (!response.ok || !result?.ok) {
111
+ return {
112
+ auth: null,
113
+ error: result?.error || { errorCode: 'network_error' },
114
+ };
115
+ }
116
+ return { auth: result.auth || null, error: null };
117
+ });
118
+ } catch {
119
+ return { auth: null, error: { errorCode: 'network_error' } };
120
+ }
109
121
  }
110
122
 
111
123
  /*
112
124
  * Persist an OAuth or phone login before navigating without a bearer-token query.
113
125
  */
114
- export async function persistSignInSession(token: string, bootstrapToken?: string | null): Promise<boolean> {
115
- if (typeof fetch !== 'function' || (!token && !bootstrapToken)) {
116
- return false;
117
- }
126
+ export async function persistSignInSession(
127
+ token: string,
128
+ bootstrapToken?: string | null,
129
+ ): Promise<boolean> {
130
+ if (typeof fetch !== 'function' || (!token && !bootstrapToken)) {
131
+ return false;
132
+ }
118
133
 
119
- return await runWithAuthSessionBrowserLock(async () => {
120
- if (bootstrapToken && await postSignInSessionCredential('bootstrapToken', bootstrapToken)) {
121
- return true;
122
- }
123
- return token ? await postSignInSessionCredential('token', token) : false;
124
- });
134
+ return await runWithAuthSessionBrowserLock(async () => {
135
+ if (
136
+ bootstrapToken &&
137
+ (await postSignInSessionCredential('bootstrapToken', bootstrapToken))
138
+ ) {
139
+ return true;
140
+ }
141
+ return token ? await postSignInSessionCredential('token', token) : false;
142
+ });
125
143
  }