fix: rekey explicitely when creating a group

pull/2963/head
Audric Ackermann 1 year ago
parent 1be85641cb
commit 1c58899558

@ -12,6 +12,7 @@ import { mnDecode } from '../../session/crypto/mnemonic';
import { recoveryPhraseModal } from '../../state/ducks/modalDialog'; import { recoveryPhraseModal } from '../../state/ducks/modalDialog';
import { SpacerSM } from '../basic/Text'; import { SpacerSM } from '../basic/Text';
import { isAutoLogin } from '../../shared/env_vars';
import { saveQRCode } from '../../util/saveQRCode'; import { saveQRCode } from '../../util/saveQRCode';
import { getCurrentRecoveryPhrase } from '../../util/storage'; import { getCurrentRecoveryPhrase } from '../../util/storage';
import { SessionWrapperModal } from '../SessionWrapperModal'; import { SessionWrapperModal } from '../SessionWrapperModal';
@ -131,6 +132,12 @@ const Seed = (props: SeedProps) => {
dispatch(recoveryPhraseModal(null)); dispatch(recoveryPhraseModal(null));
}; };
useMount(() => {
if (isAutoLogin()) {
copyRecoveryPhrase(recoveryPhrase);
}
});
return ( return (
<> <>
<div className="session-modal__centered text-center"> <div className="session-modal__centered text-center">
@ -186,7 +193,7 @@ interface ModalInnerProps {
onClickOk?: () => any; onClickOk?: () => any;
} }
const SessionSeedModalInner = (props: ModalInnerProps) => { export const SessionSeedModal = (props: ModalInnerProps) => {
const { onClickOk } = props; const { onClickOk } = props;
const [loadingPassword, setLoadingPassword] = useState(true); const [loadingPassword, setLoadingPassword] = useState(true);
const [loadingSeed, setLoadingSeed] = useState(true); const [loadingSeed, setLoadingSeed] = useState(true);
@ -247,5 +254,3 @@ const SessionSeedModalInner = (props: ModalInnerProps) => {
</> </>
); );
}; };
export const SessionSeedModal = SessionSeedModalInner;

@ -1,5 +1,6 @@
import classNames from 'classnames'; import classNames from 'classnames';
import React from 'react'; import React from 'react';
import useMount from 'react-use/lib/useMount';
import useTimeoutFn from 'react-use/lib/useTimeoutFn'; import useTimeoutFn from 'react-use/lib/useTimeoutFn';
import { MAX_USERNAME_BYTES } from '../../session/constants'; import { MAX_USERNAME_BYTES } from '../../session/constants';
import { isAutoLogin, isDevProd } from '../../shared/env_vars'; import { isAutoLogin, isDevProd } from '../../shared/env_vars';
@ -26,7 +27,7 @@ function useAutoRegister(props: DisplayNameProps) {
}, 100); }, 100);
useTimeoutFn(() => { useTimeoutFn(() => {
if (isDevProd() && props.displayName) { if (isAutoLogin() && props.displayName) {
props.handlePressEnter(); props.handlePressEnter();
} }
}, 200); }, 200);
@ -56,6 +57,14 @@ const RecoveryPhraseInput = (props: {
handlePressEnter: () => any; handlePressEnter: () => any;
stealAutoFocus?: boolean; stealAutoFocus?: boolean;
}) => { }) => {
useMount(() => {
if (isAutoLogin()) {
const seed = window.clipboard.readText() as string | undefined;
if (seed?.split(' ').length === 13) {
props.onSeedChanged(seed);
}
}
});
return ( return (
<SessionInput <SessionInput
label={window.i18n('recoveryPhrase')} label={window.i18n('recoveryPhrase')}

@ -1,6 +1,6 @@
import React, { useContext, useEffect, useState } from 'react'; import React, { useContext, useEffect, useState } from 'react';
import useTimeoutFn from 'react-use/lib/useTimeoutFn'; import useTimeoutFn from 'react-use/lib/useTimeoutFn';
import { isAutoLogin, isDevProd } from '../../shared/env_vars'; import { isAutoLogin } from '../../shared/env_vars';
import { Noop } from '../../types/Util'; import { Noop } from '../../types/Util';
import { Flex } from '../basic/Flex'; import { Flex } from '../basic/Flex';
import { SessionButton } from '../basic/SessionButton'; import { SessionButton } from '../basic/SessionButton';
@ -23,7 +23,7 @@ const CreateSessionIdButton = ({ createSessionID }: { createSessionID: any }) =>
function useAutoContinue(props: { continueSignUp: () => void }) { function useAutoContinue(props: { continueSignUp: () => void }) {
useTimeoutFn(() => { useTimeoutFn(() => {
if (isDevProd() && isAutoLogin()) { if (isAutoLogin()) {
props.continueSignUp(); props.continueSignUp();
} }
}, 100); }, 100);

@ -475,7 +475,7 @@ export async function innerHandleSwarmContentMessage({
* For a private conversation message, this is just the conversation with that user * For a private conversation message, this is just the conversation with that user
*/ */
if (!isPrivateConversationMessage) { if (!isPrivateConversationMessage) {
console.warn('conversationModelForUIUpdate might need to be checked for groupv2 case'); console.info('conversationModelForUIUpdate might need to be checked for groupv2 case'); // debugger
// this is a closed group message, we have a second conversation to make sure exists // this is a closed group message, we have a second conversation to make sure exists
conversationModelForUIUpdate = await ConvoHub.use().getOrCreateAndWait( conversationModelForUIUpdate = await ConvoHub.use().getOrCreateAndWait(
envelope.source, envelope.source,
@ -818,7 +818,7 @@ async function handleMessageRequestResponse(
if (previousApprovedMe) { if (previousApprovedMe) {
await conversationToApprove.commit(); await conversationToApprove.commit();
window.log.inf( window.log.info(
`convo ${ed25519Str(conversationToApprove.id)} previousApprovedMe is already true. Nothing to do ` `convo ${ed25519Str(conversationToApprove.id)} previousApprovedMe is already true. Nothing to do `
); );
await IncomingMessageCache.removeFromCache(envelope); await IncomingMessageCache.removeFromCache(envelope);

@ -53,6 +53,7 @@ async function handleGroupSharedConfigMessages(
); );
// do the merge with our current state // do the merge with our current state
await MetaGroupWrapperActions.metaMerge(groupPk, toMerge); await MetaGroupWrapperActions.metaMerge(groupPk, toMerge);
// save updated dumps to the DB right away // save updated dumps to the DB right away
await LibSessionUtil.saveDumpsToDb(groupPk); await LibSessionUtil.saveDumpsToDb(groupPk);

@ -17,6 +17,7 @@ import { TTL_DEFAULT } from '../../../constants';
import { ConvoHub } from '../../../conversations'; import { ConvoHub } from '../../../conversations';
import { GroupUpdateInfoChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateInfoChangeMessage'; import { GroupUpdateInfoChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateInfoChangeMessage';
import { GroupUpdateMemberChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateMemberChangeMessage'; import { GroupUpdateMemberChangeMessage } from '../../../messages/outgoing/controlMessage/group_v2/to_group/GroupUpdateMemberChangeMessage';
import { ed25519Str } from '../../../onions/onionPath';
import { MessageSender } from '../../../sending/MessageSender'; import { MessageSender } from '../../../sending/MessageSender';
import { PubKey } from '../../../types'; import { PubKey } from '../../../types';
import { allowOnlyOneAtATime } from '../../Promise'; import { allowOnlyOneAtATime } from '../../Promise';
@ -288,9 +289,9 @@ class GroupSyncJob extends PersistedJob<GroupSyncPersistedData> {
public async run(): Promise<RunJobResult> { public async run(): Promise<RunJobResult> {
const start = Date.now(); const start = Date.now();
const thisJobDestination = this.persistedData.identifier;
try { try {
const thisJobDestination = this.persistedData.identifier;
if (!PubKey.is03Pubkey(thisJobDestination)) { if (!PubKey.is03Pubkey(thisJobDestination)) {
return RunJobResult.PermanentFailure; return RunJobResult.PermanentFailure;
} }
@ -318,7 +319,9 @@ class GroupSyncJob extends PersistedJob<GroupSyncPersistedData> {
} catch (e) { } catch (e) {
throw e; throw e;
} finally { } finally {
window.log.debug(`UserSyncJob run() took ${Date.now() - start}ms`); window.log.debug(
`GroupSyncJob ${ed25519Str(thisJobDestination)} run() took ${Date.now() - start}ms`
);
// this is a simple way to make sure whatever happens here, we update the lastest timestamp. // this is a simple way to make sure whatever happens here, we update the lastest timestamp.
// (a finally statement is always executed (no matter if exception or returns in other try/catch block) // (a finally statement is always executed (no matter if exception or returns in other try/catch block)

@ -86,9 +86,9 @@ async function insertConvoFromDBIntoWrapperAndRefresh(convoId: string): Promise<
? timestampFromDbMs ? timestampFromDbMs
: 0; : 0;
window.log.debug( // window.log.debug(
`inserting into convoVolatile wrapper: ${convoId} lastMessageReadTimestamp:${lastReadMessageTimestamp} forcedUnread:${isForcedUnread}...` // `inserting into convoVolatile wrapper: ${convoId} lastMessageReadTimestamp:${lastReadMessageTimestamp} forcedUnread:${isForcedUnread}...`
); // );
const convoType = getConvoType(foundConvo); const convoType = getConvoType(foundConvo);
switch (convoType) { switch (convoType) {

@ -40,7 +40,6 @@ function getIsMemberGroupChangePendingFromUI(state: StateType): boolean {
export function getLibAdminsPubkeys(state: StateType, convo?: string): Array<string> { export function getLibAdminsPubkeys(state: StateType, convo?: string): Array<string> {
const members = getMembersOfGroup(state, convo); const members = getMembersOfGroup(state, convo);
return members.filter(m => m.promoted).map(m => m.pubkeyHex); return members.filter(m => m.promoted).map(m => m.pubkeyHex);
} }

@ -565,6 +565,10 @@ export const MetaGroupWrapperActions: MetaGroupWrapperActionsCalls = {
callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'keysNeedsRekey']) as Promise< callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'keysNeedsRekey']) as Promise<
ReturnType<MetaGroupWrapperActionsCalls['keysNeedsRekey']> ReturnType<MetaGroupWrapperActionsCalls['keysNeedsRekey']>
>, >,
keyGetAll: async (groupPk: GroupPubkeyType) =>
callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'keyGetAll']) as Promise<
ReturnType<MetaGroupWrapperActionsCalls['keyGetAll']>
>,
currentHashes: async (groupPk: GroupPubkeyType) => currentHashes: async (groupPk: GroupPubkeyType) =>
callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'currentHashes']) as Promise< callLibSessionWorker([`MetaGroupConfig-${groupPk}`, 'currentHashes']) as Promise<
ReturnType<MetaGroupWrapperActionsCalls['currentHashes']> ReturnType<MetaGroupWrapperActionsCalls['currentHashes']>

Loading…
Cancel
Save