chore: cleanup FIXMEs and remove sig_timestamp as we cannot rely on it

we use timestamp instead of sig_timestamp for store requests
This commit is contained in:
Audric Ackermann 2023-02-14 11:05:51 +11:00
parent f870eff45b
commit 22329bc745
12 changed files with 26 additions and 29 deletions

View file

@ -1062,7 +1062,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
options: {
fromSync?: boolean;
} = {},
shouldCommit = true,
shouldCommit = true
): Promise<void> {
let expireTimer = providedExpireTimer;
let source = providedSource;

View file

@ -88,7 +88,7 @@ export type StoreOnNodeParams = {
timestamp: number;
data: string;
namespace: number;
sig_timestamp?: number;
// sig_timestamp?: number;
signature?: string;
pubkey_ed25519?: string;
};

View file

@ -5,7 +5,7 @@ import { GetNetworkTime } from './getNetworkTime';
export type SnodeSignatureResult = {
timestamp: number;
sig_timestamp: number;
// sig_timestamp: number;
signature: string;
pubkey_ed25519: string;
pubkey: string; // this is the x25519 key of the pubkey we are doing the request to (ourself for our swarm usually)
@ -82,7 +82,7 @@ async function getSnodeSignatureParams(params: {
const signatureBase64 = fromUInt8ArrayToBase64(signature);
return {
sig_timestamp: signatureTimestamp,
// sig_timestamp: signatureTimestamp,
timestamp: signatureTimestamp,
signature: signatureBase64,
pubkey_ed25519: ourEd25519Key.pubKey,

View file

@ -244,8 +244,8 @@ export class SwarmPolling {
);
}
console.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`);
console.info(
window.log.info(`received userConfigMessagesMerged: ${userConfigMessagesMerged.length}`);
window.log.info(
`received allNamespacesWithoutUserConfigIfNeeded: ${allNamespacesWithoutUserConfigIfNeeded.length}`
);

View file

@ -74,7 +74,11 @@ export const sendDataExtractionNotification = async (
);
try {
await getMessageQueue().sendToPubKey(pubkey, dataExtractionNotificationMessage, SnodeNamespaces.UserMessages);
await getMessageQueue().sendToPubKey(
pubkey,
dataExtractionNotificationMessage,
SnodeNamespaces.UserMessages
);
} catch (e) {
window.log.warn('failed to send data extraction notification', e);
}

View file

@ -204,7 +204,9 @@ async function sendMessagesDataToSnode(
namespace: item.namespace,
pubkey: item.pubkey,
timestamp: item.timestamp,
sig_timestamp: item.timestamp,
// sig_timestamp: item.timestamp,
// sig_timestamp is currently not forwarded from the receiving snode to the other swarm members, and so their sig verify fail.
// This timestamp is not really needed so we just don't send it in the meantime (the timestamp value is used if the sig_timestamp is not present)
ttl: item.ttl,
...signOpts,
};

View file

@ -591,7 +591,7 @@ const findLastMessageTypeFromSender = (sender: string, msgType: SignalService.Ca
return undefined;
}
// FIXME this does not sort by timestamp as we do not have a timestamp stored in the SignalService.CallMessage object...
// this does not sort by timestamp as we do not have a timestamp stored in the SignalService.CallMessage object
const allMsg = _.flattenDeep([...msgCacheFromSenderWithDevices.values()]);
const allMsgFromType = allMsg.filter(m => m.type === msgType);
const lastMessageOfType = _.last(allMsgFromType);

View file

@ -214,7 +214,6 @@ function variantToKind(variant: ConfigWrapperObjectTypes): SignalService.SharedC
*/
async function markAsPushed(variant: ConfigWrapperObjectTypes, pubkey: string, seqno: number) {
if (pubkey !== UserUtils.getOurPubKeyStrFromCache()) {
//FIXME libsession closed group
throw new Error('FIXME, generic case is to be done');
}
await GenericWrapperActions.confirmPushed(variant, seqno);

View file

@ -522,10 +522,6 @@ function handleMessageExpiredOrDeleted(
...state.messages.slice(messageInStoreIndex + 1),
];
// FIXME two other thing we have to do:
// * update the last message text if the message deleted was the last one
// * update the unread count of the convo if the message was the one counted as an unread
return {
...state,
messages: editedMessages,

View file

@ -3,7 +3,7 @@ import { expect } from 'chai';
import { from_hex, from_string } from 'libsodium-wrappers-sumo';
// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace no-require-imports variable-name
import * as SessionUtilWrapper from 'session_util_wrapper';
// import * as SessionUtilWrapper from 'session_util_wrapper';
describe('libsession_contacts', () => {
// Note: To run this test, you need to compile the libsession wrapper for node (and not for electron).
@ -17,7 +17,7 @@ describe('libsession_contacts', () => {
const edSecretKey = from_hex(
'0123456789abcdef0123456789abcdef000000000000000000000000000000004cb76fdc6d32278e3f83dbf608360ecc6b65727934b85d2fb86862ff98c46ab7'
);
// const SessionUtilWrapper = require('session_util_wrapper');
const SessionUtilWrapper = require('session_util_wrapper');
// Initialize a brand new, empty config because we have no dump data to deal with.
const contacts = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null);
@ -55,7 +55,7 @@ describe('libsession_contacts', () => {
created.approvedMe = true;
contacts.set(created);
let updated = contacts.get(real_id);
const updated = contacts.get(real_id);
expect(updated).to.not.be.null;
expect(updated).to.not.be.undefined;
@ -212,11 +212,7 @@ describe('libsession_contacts', () => {
c.nickname = 'Joey';
c.approved = true;
c.approvedMe = true;
contacts.set(c); // FIXME use .set when ready
// contacts.setName(real_id, c.name);
// contacts.setNickname(real_id, c.nickname);
// contacts.setApproved(real_id, c.approved);
// contacts.setApprovedMe(real_id, c.approvedMe);
contacts.set(c);
const c2 = contacts.getOrCreate(realId);
expect(c2.name).to.be.eq('Joe');
@ -230,7 +226,7 @@ describe('libsession_contacts', () => {
expect(contacts.needsDump()).to.be.true;
expect(contacts.needsPush()).to.be.true;
let push1 = contacts.push();
const push1 = contacts.push();
expect(push1.seqno).to.be.equal(1);
const contacts2 = new SessionUtilWrapper.ContactsConfigWrapperInsideWorker(edSecretKey, null);
@ -262,7 +258,7 @@ describe('libsession_contacts', () => {
contacts2.set(c3);
let push2 = contacts2.push();
const push2 = contacts2.push();
accepted = contacts.merge([push2.data]);
expect(accepted).to.be.equal(1);
@ -281,9 +277,9 @@ describe('libsession_contacts', () => {
const allContacts3 = contacts.getAll();
let deletions = 0;
let non_deletions = 0;
allContacts3.forEach((c: any) => {
if (c.id !== realId) {
contacts.erase(c.id);
allContacts3.forEach((contact: any) => {
if (contact.id !== realId) {
contacts.erase(contact.id);
deletions++;
} else {
non_deletions++;

View file

@ -4,7 +4,7 @@ import { stringToUint8Array } from '../../../../session/utils/String';
import { from_hex, to_hex } from 'libsodium-wrappers-sumo';
import { concatUInt8Array } from '../../../../session/crypto';
// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace
// tslint:disable: chai-vague-errors no-unused-expression no-http-string no-octal-literal whitespace no-require-imports variable-name
describe('libsession_wrapper', () => {
it('libsession_user', () => {

View file

@ -94,7 +94,7 @@ onmessage = async (e: { data: [number, ConfigWrapperObjectTypes, string, ...any]
return;
}
const wrapper = await getCorrespondingWrapper(config);
const wrapper = getCorrespondingWrapper(config);
const fn = (wrapper as any)[action];
if (!fn) {