diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -103,6 +103,7 @@ export type LogInExtraInfo = { +calendarQuery: CalendarQuery, +deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest, + +primaryIdentityPublicKey?: string, }; export type LogInInfo = { diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js --- a/native/account/log-in-panel.react.js +++ b/native/account/log-in-panel.react.js @@ -52,7 +52,7 @@ type Props = { ...BaseProps, +loadingStatus: LoadingStatus, - +logInExtraInfo: () => LogInExtraInfo, + +logInExtraInfo: () => Promise, +dispatchActionPromise: DispatchActionPromise, +logIn: (logInInfo: LogInInfo) => Promise, +primaryIdentityPublicKey: ?string, @@ -203,7 +203,7 @@ this.props.logInState.setState({ passwordInputText: text }); }; - onSubmit: () => void = () => { + onSubmit: () => Promise = async () => { this.props.setActiveAlert(true); if (this.usernameInputText.search(validEmailRegex) > -1) { Alert.alert( @@ -232,7 +232,7 @@ } Keyboard.dismiss(); - const extraInfo = this.props.logInExtraInfo(); + const extraInfo = await this.props.logInExtraInfo(); this.props.dispatchActionPromise( logInActionTypes, this.logInAction(extraInfo), diff --git a/native/account/panel-components.react.js b/native/account/panel-components.react.js --- a/native/account/panel-components.react.js +++ b/native/account/panel-components.react.js @@ -20,7 +20,7 @@ type ButtonProps = { +text: string, +loadingStatus: LoadingStatus, - +onSubmit: () => void, + +onSubmit: () => mixed, +disabled?: boolean, }; function PanelButton(props: ButtonProps): React.Node { diff --git a/native/account/register-panel.react.js b/native/account/register-panel.react.js --- a/native/account/register-panel.react.js +++ b/native/account/register-panel.react.js @@ -53,7 +53,7 @@ type Props = { ...BaseProps, +loadingStatus: LoadingStatus, - +logInExtraInfo: () => LogInExtraInfo, + +logInExtraInfo: () => Promise, +dispatchActionPromise: DispatchActionPromise, +register: (registerInfo: RegisterInfo) => Promise, +primaryIdentityPublicKey: ?string, @@ -260,7 +260,7 @@ this.setState({ confirmPasswordFocused: true }); }; - onSubmit = () => { + onSubmit = async () => { this.props.setActiveAlert(true); if (this.props.registerState.state.passwordInputText === '') { Alert.alert( @@ -294,7 +294,7 @@ ); } else { Keyboard.dismiss(); - const extraInfo = this.props.logInExtraInfo(); + const extraInfo = await this.props.logInExtraInfo(); this.props.dispatchActionPromise( registerActionTypes, this.registerAction(extraInfo), diff --git a/native/account/resolve-invalidated-cookie.js b/native/account/resolve-invalidated-cookie.js --- a/native/account/resolve-invalidated-cookie.js +++ b/native/account/resolve-invalidated-cookie.js @@ -19,7 +19,7 @@ if (!keychainCredentials) { return; } - const extraInfo = nativeLogInExtraInfoSelector({ + const extraInfo = await nativeLogInExtraInfoSelector({ redux: store.getState(), navContext: getGlobalNavContext(), })(); diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -140,8 +140,8 @@ ); const handleSIWE = React.useCallback( - ({ message, signature }) => { - const extraInfo = logInExtraInfo(); + async ({ message, signature }) => { + const extraInfo = await logInExtraInfo(); dispatchActionPromise( siweAuthActionTypes, callSIWE(message, signature, extraInfo), @@ -155,14 +155,14 @@ const { nextMode } = props; const disableOnClose = React.useRef(false); const handleMessage = React.useCallback( - event => { + async event => { const data: SIWEWebViewMessage = JSON.parse(event.nativeEvent.data); if (data.type === 'siwe_success') { const { address, message, signature } = data; if (address && signature) { disableOnClose.current = true; closeBottomSheet?.(); - handleSIWE({ message, signature }); + await handleSIWE({ message, signature }); } } else if (data.type === 'siwe_closed') { onClose(); diff --git a/native/selectors/account-selectors.js b/native/selectors/account-selectors.js --- a/native/selectors/account-selectors.js +++ b/native/selectors/account-selectors.js @@ -7,6 +7,7 @@ import type { UserPolicies } from 'lib/types/policy-types.js'; import { values } from 'lib/utils/objects.js'; +import { commCoreModule } from '../native-modules.js'; import { calendarActiveSelector } from '../navigation/nav-selectors.js'; import type { AppState } from '../redux/state-types.js'; import type { ConnectivityInfo } from '../types/connectivity.js'; @@ -14,13 +15,23 @@ const nativeLogInExtraInfoSelector: ( input: NavPlusRedux, -) => () => LogInExtraInfo = createSelector( +) => () => Promise = createSelector( (input: NavPlusRedux) => logInExtraInfoSelector(input.redux), (input: NavPlusRedux) => calendarActiveSelector(input.navContext), ( logInExtraInfoFunc: (calendarActive: boolean) => LogInExtraInfo, calendarActive: boolean, - ) => () => logInExtraInfoFunc(calendarActive), + ) => { + const loginExtraFuncWithIdentityKey = async () => { + await commCoreModule.initializeCryptoAccount('PLACEHOLDER'); + const { ed25519 } = await commCoreModule.getUserPublicKey(); + return { + ...logInExtraInfoFunc(calendarActive), + primaryIdentityPublicKey: ed25519, + }; + }; + return loginExtraFuncWithIdentityKey; + }, ); const noDataAfterPolicyAcknowledgmentSelector: (