diff --git a/web/account/log-in-form.react.js b/web/account/log-in-form.react.js --- a/web/account/log-in-form.react.js +++ b/web/account/log-in-form.react.js @@ -11,7 +11,10 @@ import SIWELoginForm from './siwe-login-form.react.js'; import TraditionalLoginForm from './traditional-login-form.react.js'; import OrBreak from '../components/or-break.react.js'; -import { setPrimaryIdentityKeys } from '../redux/crypto-store-reducer.js'; +import { + setPrimaryIdentityKeys, + setNotificationIdentityKeys, +} from '../redux/crypto-store-reducer.js'; import { useSelector } from '../redux/redux-utils.js'; function LoginForm(): React.Node { @@ -32,14 +35,31 @@ return; } await olm.init(); + const identityAccount = new olm.Account(); identityAccount.create(); const { ed25519: identityED25519, curve25519: identityCurve25519 } = JSON.parse(identityAccount.identity_keys()); + dispatch({ type: setPrimaryIdentityKeys, payload: { ed25519: identityED25519, curve25519: identityCurve25519 }, }); + + const notificationAccount = new olm.Account(); + notificationAccount.create(); + const { + ed25519: notificationED25519, + curve25519: notificationCurve25519, + } = JSON.parse(notificationAccount.identity_keys()); + + dispatch({ + type: setNotificationIdentityKeys, + payload: { + ed25519: notificationED25519, + curve25519: notificationCurve25519, + }, + }); })(); }, [dispatch, primaryIdentityPublicKey]); diff --git a/web/redux/crypto-store-reducer.js b/web/redux/crypto-store-reducer.js --- a/web/redux/crypto-store-reducer.js +++ b/web/redux/crypto-store-reducer.js @@ -10,12 +10,18 @@ import type { Action } from './redux-setup.js'; const setPrimaryIdentityKeys = 'SET_PRIMARY_IDENTITY_KEYS'; +const setNotificationIdentityKeys = 'SET_NOTIFICATION_IDENTITY_KEYS'; function reduceCryptoStore(state: CryptoStore, action: Action): CryptoStore { if (action.type === setPrimaryIdentityKeys) { return { ...state, primaryIdentityKeys: action.payload, }; + } else if (action.type === setNotificationIdentityKeys) { + return { + ...state, + notificationIdentityKeys: action.payload, + }; } else if ( action.type === logOutActionTypes.success || action.type === deleteAccountActionTypes.success || @@ -30,4 +36,8 @@ return state; } -export { setPrimaryIdentityKeys, reduceCryptoStore }; +export { + setPrimaryIdentityKeys, + setNotificationIdentityKeys, + reduceCryptoStore, +}; diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js --- a/web/redux/redux-setup.js +++ b/web/redux/redux-setup.js @@ -43,6 +43,7 @@ import { reduceCryptoStore, setPrimaryIdentityKeys, + setNotificationIdentityKeys, } from './crypto-store-reducer.js'; import { reduceDeviceID } from './device-id-reducer.js'; import reduceNavInfo from './nav-reducer.js'; @@ -101,6 +102,7 @@ payload: string, } | { +type: 'SET_PRIMARY_IDENTITY_KEYS', payload: ?OLMIdentityKeys } + | { +type: 'SET_NOTIFICATION_IDENTITY_KEYS', payload: ?OLMIdentityKeys } | { +type: 'UPDATE_CALENDAR_COMMUNITY_FILTER', +payload: string, @@ -185,7 +187,8 @@ if ( action.type !== updateNavInfoActionType && action.type !== setDeviceIDActionType && - action.type !== setPrimaryIdentityKeys + action.type !== setPrimaryIdentityKeys && + action.type !== setNotificationIdentityKeys ) { state = baseReducer(state, action).state; }