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 @@ -39,6 +39,7 @@ ...LogInExtraInfo, +username: string, +password: string, + +primaryIdentityPublicKey?: string, }; type DeviceTokenUpdateRequest = { 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 @@ -33,6 +33,7 @@ import { setNativeCredentials } from './native-credentials.js'; import { PanelButton, Panel } from './panel-components.react.js'; import SWMansionIcon from '../components/swmansion-icon.react.js'; +import { commCoreModule } from '../native-modules.js'; import { NavContext } from '../navigation/navigation-context.js'; import { useSelector } from '../redux/redux-utils.js'; import { nativeLogInExtraInfoSelector } from '../selectors/account-selectors.js'; @@ -51,13 +52,11 @@ }; type Props = { ...BaseProps, - // Redux state +loadingStatus: LoadingStatus, +logInExtraInfo: () => LogInExtraInfo, - // Redux dispatch functions +dispatchActionPromise: DispatchActionPromise, - // async functions that hit server APIs +register: (registerInfo: RegisterInfo) => Promise, + +primaryIdentityPublicKey: ?string, }; type State = { +confirmPasswordFocused: boolean, @@ -329,11 +328,18 @@ }; async registerAction(extraInfo: LogInExtraInfo) { + const { primaryIdentityPublicKey } = this.props; try { + invariant( + primaryIdentityPublicKey !== null && + primaryIdentityPublicKey !== undefined, + 'primaryIdentityPublicKey must exist in logInAction', + ); const result = await this.props.register({ + ...extraInfo, username: this.props.registerState.state.usernameInputText, password: this.props.registerState.state.passwordInputText, - ...extraInfo, + primaryIdentityPublicKey: primaryIdentityPublicKey, }); this.props.setActiveAlert(false); await setNativeCredentials({ @@ -461,13 +467,26 @@ const dispatchActionPromise = useDispatchActionPromise(); const callRegister = useServerCall(register); + const [ + primaryIdentityPublicKey, + setPrimaryIdentityPublicKey, + ] = React.useState(null); + React.useEffect(() => { + (async () => { + await commCoreModule.initializeCryptoAccount('PLACEHOLDER'); + const { ed25519 } = await commCoreModule.getUserPublicKey(); + setPrimaryIdentityPublicKey(ed25519); + })(); + }, []); + return ( ); },