diff --git a/src/store/actions.ts b/src/store/actions.ts index 85bd2d4..769688b 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -31,6 +31,13 @@ export const { fetchCredentials, logout } = createActions({ LOGOUT: () => undefined, }); +// FIXME: This is duplicating behaviour from the fetchCredentials above +export const { deriveKey } = createActions({ + DERIVE_KEY: (username: string, encryptionPassword: string) => { + return EteSync.deriveKey(username, encryptionPassword); + }, +}); + export const { fetchJournals } = createActions({ FETCH_JOURNALS: (etesync: CredentialsData) => { const creds = etesync.credentials; diff --git a/src/store/reducers.ts b/src/store/reducers.ts index ecf373a..b866e48 100644 --- a/src/store/reducers.ts +++ b/src/store/reducers.ts @@ -90,6 +90,9 @@ const encryptionKeyReducer = handleActions( return {key: action.payload.encryptionKey}; } }, + [actions.deriveKey.toString()]: (state: {key: string | null}, action: any) => ( + {key: action.payload} + ), [actions.logout.toString()]: (state: {key: string | null}, action: any) => { return {out: true, key: null}; },