Use new compact representations in protobufs

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
Fedor Indutny
2025-06-25 10:30:40 -07:00
committed by GitHub
parent 157496f822
commit 8251720444
64 changed files with 1000 additions and 459 deletions

View File

@@ -106,7 +106,7 @@ describe('backups', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [pinned.device.aci],
recipientServiceIdsBinary: [pinned.device.aciBinary],
},
},
});
@@ -119,7 +119,7 @@ describe('backups', function (this: Mocha.Suite) {
identifier: uuidToBytes(DISTRIBUTION1),
isBlockList: false,
name: 'friend',
recipientServiceIds: [friend.device.aci],
recipientServiceIdsBinary: [friend.device.aciBinary],
},
},
});
@@ -262,14 +262,14 @@ describe('backups', function (this: Mocha.Suite) {
async (window, snapshot) => {
const leftPane = window.locator('#LeftPane');
const pinnedElem = leftPane.locator(
`[data-testid="${pinned.toContact().aci}"] >> "cat photo"`
`[data-testid="${pinned.device.aci}"] >> "cat photo"`
);
debug('Waiting for messages to pinned contact to come through');
await pinnedElem.click();
const contactElem = leftPane.locator(
`[data-testid="${friend.toContact().aci}"] >> "respond 4"`
`[data-testid="${friend.device.aci}"] >> "respond 4"`
);
debug('Waiting for messages to regular contact to come through');

View File

@@ -62,9 +62,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
const openConvo = async (contact: PrimaryDevice): Promise<void> => {
debug('opening conversation', contact.profileName);
const item = leftPane.locator(
`[data-testid="${contact.toContact().aci}"]`
);
const item = leftPane.locator(`[data-testid="${contact.device.aci}"]`);
await item.click();
};

View File

@@ -126,39 +126,49 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
}
debug('encrypted');
await Promise.all(messages.map(message => server.send(desktop, message)));
debug('sending first message');
{
const firstMessage = messages.shift();
if (firstMessage != null) {
await server.send(desktop, firstMessage);
}
}
const window = await app.getWindow();
debug('waiting for conversation');
{
const leftPane = window.locator('#LeftPane');
// Left pane should show either the message preview or
// "You were added to the group".
await leftPane
.locator(
`.module-conversation-list__item--contact-or-conversation[data-testid="${group.id}"]`
)
.waitFor();
}
debug('sending the rest of messages');
await Promise.all(messages.map(message => server.send(desktop, message)));
debug('opening conversation');
{
const leftPane = window.locator('#LeftPane');
const item = leftPane
await leftPane
.locator(
`.module-conversation-list__item--contact-or-conversation[data-testid="${group.id}"]`
`.module-conversation-list__item--contact-or-conversation[data-testid="${group.id}"]` +
` >> text=${LAST_MESSAGE}`
)
.first();
// Wait for unread indicator to give desktop time to process messages without
// the timeline open
await item
.locator(
'.module-conversation-list__item--contact-or-conversation__content'
)
.locator(
'.module-conversation-list__item--contact-or-conversation__unread-indicator'
)
.first()
.waitFor();
await item.click();
.click();
}
debug('scrolling to bottom of timeline');
await window
.locator('.module-timeline__messages__at-bottom-detector')
.scrollIntoViewIfNeeded();
.locator('.ScrollDownButton')
.or(window.locator(`.module-message >> text="${LAST_MESSAGE}"`))
.click({ timeout: MINUTE });
debug('finding message in timeline');
{

View File

@@ -68,7 +68,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
{
const leftPane = window.locator('#LeftPane');
const item = leftPane.locator(
`[data-testid="${first.toContact().aci}"] >> text=${LAST_MESSAGE}`
`[data-testid="${first.device.aci}"] >> text=${LAST_MESSAGE}`
);
await item.click();
}

View File

@@ -49,9 +49,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
const leftPane = window.locator('#LeftPane');
const item = leftPane.locator(
`[data-testid="${lastContact?.toContact().aci}"]`
);
const item = leftPane.locator(`[data-testid="${lastContact?.device.aci}"]`);
await item.waitFor();
const duration = Date.now() - start;

View File

@@ -129,11 +129,11 @@ function maybeWrapInSyncMessage({
? {
syncMessage: {
sent: {
destinationServiceId: getDevice(to).aci,
destinationServiceIdBinary: getDevice(to).aciBinary,
message: dataMessage,
timestamp: dataMessage.timestamp,
unidentifiedStatus: (sentTo ?? [to]).map(contact => ({
destinationServiceId: getDevice(contact).aci,
destinationServiceIdBinary: getDevice(contact).aciBinary,
destination: getDevice(contact).number,
})),
},
@@ -222,7 +222,7 @@ export function sendReaction({
timestamp: Long.fromNumber(reactionTimestamp),
reaction: {
emoji,
targetAuthorAci: getDevice(targetAuthor).aci,
targetAuthorAciBinary: getDevice(targetAuthor).aciRawUuid,
targetSentTimestamp: Long.fromNumber(targetMessageTimestamp),
},
},

View File

@@ -119,13 +119,13 @@ describe('attachment backfill', function (this: Mocha.Suite) {
return entry.syncMessage.attachmentBackfillRequest != null;
});
assert.strictEqual(
request?.targetConversation?.threadServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetConversation?.threadServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.authorServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetMessage?.authorServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.sentTimestamp?.toNumber(),
@@ -302,13 +302,13 @@ describe('attachment backfill', function (this: Mocha.Suite) {
return entry.syncMessage.attachmentBackfillRequest != null;
});
assert.strictEqual(
request?.targetConversation?.threadServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetConversation?.threadServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.authorServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetMessage?.authorServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.sentTimestamp?.toNumber(),
@@ -380,13 +380,13 @@ describe('attachment backfill', function (this: Mocha.Suite) {
return entry.syncMessage.attachmentBackfillRequest != null;
});
assert.strictEqual(
request?.targetConversation?.threadServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetConversation?.threadServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.authorServiceId,
unknownContact.device.aci
assert.deepEqual(
request?.targetMessage?.authorServiceIdBinary,
unknownContact.device.aciBinary
);
assert.strictEqual(
request?.targetMessage?.sentTimestamp?.toNumber(),
@@ -439,7 +439,7 @@ describe('attachment backfill', function (this: Mocha.Suite) {
desktop,
quote: {
id: Long.fromNumber(bootstrap.getTimestamp()),
authorAci: unknownContact.device.aci,
authorAciBinary: unknownContact.device.aciRawUuid,
text: 'quote text',
attachments: [
{

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { Proto } from '@signalapp/mock-server';
import { Aci } from '@signalapp/libsignal-client';
import { assert } from 'chai';
import createDebug from 'debug';
import Long from 'long';
@@ -23,6 +24,7 @@ import { sleep } from '../../util/sleep';
export const debug = createDebug('mock:test:edit');
const ACI_1 = generateAci();
const ACI_1_BINARY = Aci.parseFromServiceIdString(ACI_1).getRawUuidBytes();
const UNPROCESSED_ATTACHMENT: Proto.IAttachmentPointer = {
cdnId: Long.fromNumber(123),
key: new Uint8Array([1, 2, 3]),
@@ -57,7 +59,7 @@ function createMessageWithQuote(body: string): Proto.IDataMessage {
body,
quote: {
id: Long.fromNumber(1),
authorAci: ACI_1,
authorAciBinary: ACI_1_BINARY,
text: 'text',
attachments: [
{
@@ -516,7 +518,6 @@ describe('editing', function (this: Mocha.Suite) {
const { contacts, desktop } = bootstrap;
const [friend] = contacts;
const contact = friend.toContact();
const page = await app.getWindow();
@@ -567,7 +568,7 @@ describe('editing', function (this: Mocha.Suite) {
debug("getting friend's conversationId");
const conversationId = await page.evaluate(
serviceId => window.SignalCI?.getConversationId(serviceId),
contact.aci
friend.device.aci
);
debug(`got friend's conversationId: ${conversationId}`);
strictAssert(conversationId, 'conversationId exists');

View File

@@ -70,7 +70,6 @@ describe('messaging/expireTimerVersion', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -180,11 +179,11 @@ describe('messaging/expireTimerVersion', function (this: Mocha.Suite) {
const sendSync = async () => {
debug('Send a sync message');
const timestamp = bootstrap.getTimestamp();
const destinationServiceId = stranger.device.aci;
const destinationServiceIdBinary = stranger.device.aciBinary;
const content = {
syncMessage: {
sent: {
destinationServiceId,
destinationServiceIdBinary,
timestamp: Long.fromNumber(timestamp),
message: {
body: 'request',
@@ -194,7 +193,7 @@ describe('messaging/expireTimerVersion', function (this: Mocha.Suite) {
},
unidentifiedStatus: [
{
destinationServiceId,
destinationServiceIdBinary,
},
],
},

View File

@@ -102,14 +102,14 @@ describe('readSync', function (this: Mocha.Suite) {
Long.fromNumber(timestamp)
);
const senderAci = friend.device.aci;
const senderAciBinary = friend.device.aciRawUuid;
await phone.sendRaw(
desktop,
{
syncMessage: {
read: longTimestamps.map(timestamp => ({
senderAci,
senderAciBinary,
timestamp,
})),
},

View File

@@ -55,7 +55,7 @@ describe('safety number', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: false,
name: MY_STORY_ID,
recipientServiceIds: [alice.device.aci],
recipientServiceIdsBinary: [alice.device.aciBinary],
},
},
});

View File

@@ -68,7 +68,7 @@ describe('sendSync', function (this: Mocha.Suite) {
timestamp: Long.fromNumber(timestamp),
message: originalDataMessage,
unidentifiedStatus: members.map(member => ({
destinationServiceId: member.device.aci,
destinationServiceIdBinary: member.device.aciBinary,
destination: member.device.number,
})),
},

View File

@@ -51,7 +51,6 @@ describe('story/messaging', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: false,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -65,7 +64,7 @@ describe('story/messaging', function (this: Mocha.Suite) {
identifier: uuidToBytes(DISTRIBUTION1),
isBlockList: false,
name: 'first',
recipientServiceIds: [first.device.aci],
recipientServiceIdsBinary: [first.device.aciBinary],
},
},
});
@@ -77,7 +76,7 @@ describe('story/messaging', function (this: Mocha.Suite) {
identifier: uuidToBytes(DISTRIBUTION2),
isBlockList: false,
name: 'second',
recipientServiceIds: [second.device.aci],
recipientServiceIdsBinary: [second.device.aciBinary],
},
},
});
@@ -148,12 +147,12 @@ describe('story/messaging', function (this: Mocha.Suite) {
},
storyMessageRecipients: [
{
destinationServiceId: first.device.aci,
destinationServiceIdBinary: first.device.aciBinary,
distributionListIds: [DISTRIBUTION1],
isAllowedToReply: true,
},
{
destinationServiceId: second.device.aci,
destinationServiceIdBinary: second.device.aciBinary,
distributionListIds: [DISTRIBUTION2],
isAllowedToReply: true,
},
@@ -171,7 +170,7 @@ describe('story/messaging', function (this: Mocha.Suite) {
dataMessage: {
body: 'first reply',
storyContext: {
authorAci: phone.device.aci,
authorAciBinary: phone.device.aciRawUuid,
sentTimestamp: Long.fromNumber(sentAt),
},
timestamp: Long.fromNumber(sentAt + 1),
@@ -185,7 +184,7 @@ describe('story/messaging', function (this: Mocha.Suite) {
dataMessage: {
body: 'second reply',
storyContext: {
authorAci: phone.device.aci,
authorAciBinary: phone.device.aciRawUuid,
sentTimestamp: Long.fromNumber(sentAt),
},
timestamp: Long.fromNumber(sentAt + 2),
@@ -245,7 +244,7 @@ describe('story/messaging', function (this: Mocha.Suite) {
dataMessage: {
body: 'first reply',
storyContext: {
authorAci: desktop.aci,
authorAciBinary: desktop.aciRawUuid,
sentTimestamp: Long.fromNumber(sentAt),
},
groupV2: {

View File

@@ -98,7 +98,7 @@ describe('unknown contacts', function (this: Mocha.Suite) {
syncMessage: {
messageRequestResponse: {
type: Proto.SyncMessage.MessageRequestResponse.Type.ACCEPT,
threadAci: unknownContact.device.aci,
threadAciBinary: unknownContact.device.aciRawUuid,
},
},
});

View File

@@ -64,7 +64,7 @@ describe('Libsignal-net', function (this: Mocha.Suite) {
{
const leftPane = window.locator('#LeftPane');
const item = leftPane
.getByTestId(contact.toContact().aci)
.getByTestId(contact.device.aci)
.getByText('incoming message');
await item.click();
}

View File

@@ -81,7 +81,7 @@ describe('pnp/calling', function (this: Mocha.Suite) {
});
debug('Open conversation with a known contact');
await leftPane.locator(`[data-testid="${alice.toContact().aci}"]`).click();
await leftPane.locator(`[data-testid="${alice.device.aci}"]`).click();
debug('Accept conversation from a known contact');
await acceptConversation(window);

View File

@@ -61,7 +61,7 @@ describe('pnp/change number', function (this: Mocha.Suite) {
]);
debug('opening conversation with the first contact');
await leftPane.locator(`[data-testid="${first.toContact().aci}"]`).click();
await leftPane.locator(`[data-testid="${first.device.aci}"]`).click();
debug('done');
});

View File

@@ -1,6 +1,7 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { timingSafeEqual } from 'node:crypto';
import { assert } from 'chai';
import { ServiceIdKind, Proto, StorageState } from '@signalapp/mock-server';
import type { PrimaryDevice } from '@signalapp/mock-server';
@@ -10,7 +11,6 @@ import Long from 'long';
import * as durations from '../../util/durations';
import { uuidToBytes } from '../../util/uuidToBytes';
import { generateConfigMatrix } from '../../util/generateConfigMatrix';
import { toUntaggedPni } from '../../types/ServiceId';
import { MY_STORY_ID } from '../../types/Stories';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
@@ -87,7 +87,6 @@ describe('pnp/merge', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -282,7 +281,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
let state = await phone.expectStorageState('consistency check');
state = state.updateContact(pniContact, {
pni: undefined,
pniBinary: undefined,
e164: undefined,
unregisteredAtTimestamp: Long.fromNumber(bootstrap.getTimestamp()),
});
@@ -403,25 +402,34 @@ describe('pnp/merge', function (this: Mocha.Suite) {
throw new Error('Invalid record');
}
const { aci, e164, pni } = contact;
if (aci === pniContact.device.aci) {
const { aciBinary, e164, pniBinary } = contact;
if (
aciBinary?.length &&
timingSafeEqual(aciBinary, pniContact.device.aciRawUuid)
) {
aciContacts += 1;
assert.strictEqual(pni, '');
assert.strictEqual(pniBinary?.length, 0);
assert.strictEqual(e164, '');
} else if (pni === toUntaggedPni(pniContact.device.pni)) {
} else if (
pniBinary?.length &&
timingSafeEqual(pniBinary, pniContact.device.pniRawUuid)
) {
pniContacts += 1;
assert.strictEqual(aci, '');
assert.strictEqual(aciBinary?.length, 0);
assert.strictEqual(e164, pniContact.device.number);
}
}
assert.strictEqual(aciContacts, 1);
assert.strictEqual(pniContacts, 1);
assert.strictEqual(
removed[0].contact?.pni,
toUntaggedPni(pniContact.device.pni)
assert.deepEqual(
removed[0].contact?.pniBinary,
pniContact.device.pniRawUuid
);
assert.deepEqual(
removed[0].contact?.aciBinary,
pniContact.device.aciRawUuid
);
assert.strictEqual(removed[0].contact?.aci, pniContact.device.aci);
// Pin PNI so that it appears in the left pane
const updated = newState.pin(pniContact, ServiceIdKind.PNI);
@@ -556,12 +564,12 @@ describe('pnp/merge', function (this: Mocha.Suite) {
for (const key of ['aci' as const, 'pni' as const]) {
debug(`Send a ${key} sync message`);
const timestamp = bootstrap.getTimestamp();
const destinationServiceId = pniContact.device[key];
const destinationServiceIdBinary = pniContact.device[`${key}Binary`];
const destination = key === 'pni' ? pniContact.device.number : undefined;
const content = {
syncMessage: {
sent: {
destinationServiceId,
destinationServiceIdBinary,
destination,
timestamp: Long.fromNumber(timestamp),
message: {
@@ -572,7 +580,7 @@ describe('pnp/merge', function (this: Mocha.Suite) {
},
unidentifiedStatus: [
{
destinationServiceId,
destinationServiceIdBinary,
destination,
},
],

View File

@@ -9,7 +9,6 @@ import createDebug from 'debug';
import * as durations from '../../util/durations';
import { uuidToBytes } from '../../util/uuidToBytes';
import { MY_STORY_ID } from '../../types/Stories';
import { toUntaggedPni } from '../../types/ServiceId';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
import {
@@ -73,7 +72,6 @@ describe('pnp/phone discovery', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -119,7 +117,7 @@ describe('pnp/phone discovery', function (this: Mocha.Suite) {
whitelisted: true,
identityKey: pniContact.publicKey.serialize(),
profileKey: pniContact.profileKey.serialize(),
pni: toUntaggedPni(pniContact.device.pni),
pniBinary: pniContact.device.pniRawUuid,
})
);
await phone.sendFetchStorage({

View File

@@ -1,13 +1,15 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { timingSafeEqual } from 'node:crypto';
import { assert } from 'chai';
import { ServiceIdKind, StorageState, Proto } from '@signalapp/mock-server';
import type { PrimaryDevice } from '@signalapp/mock-server';
import createDebug from 'debug';
import * as durations from '../../util/durations';
import { generatePni, toUntaggedPni } from '../../types/ServiceId';
import { generatePni } from '../../types/ServiceId';
import { toPniObject } from '../../util/ServiceId';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
import {
@@ -54,7 +56,7 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
whitelisted: true,
e164: contactA.device.number,
identityKey: contactA.getPublicKey(ServiceIdKind.PNI).serialize(),
pni: toUntaggedPni(contactA.device.pni),
pniBinary: contactA.device.pniRawUuid,
givenName: 'ContactA',
},
ServiceIdKind.PNI
@@ -135,17 +137,21 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
const updated = await phone.setStorageState(
state
.removeRecord(
item =>
item.record.contact?.pni === toUntaggedPni(contactA.device.pni)
)
.removeRecord(item => {
return item.record.contact?.pniBinary?.length
? timingSafeEqual(
item.record.contact.pniBinary,
contactA.device.pniRawUuid
)
: false;
})
.addContact(
contactA,
{
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
whitelisted: true,
e164: contactA.device.number,
pni: toUntaggedPni(updatedPni),
pniBinary: toPniObject(updatedPni).getRawUuidBytes(),
identityKey: contactA.getPublicKey(ServiceIdKind.PNI).serialize(),
},
ServiceIdKind.PNI
@@ -232,17 +238,21 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
const updated = await phone.setStorageState(
state
.removeRecord(
item =>
item.record.contact?.pni === toUntaggedPni(contactA.device.pni)
)
.removeRecord(item => {
return item.record.contact?.pniBinary?.length
? timingSafeEqual(
item.record.contact.pniBinary,
contactA.device.pniRawUuid
)
: false;
})
.addContact(
contactB,
{
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
whitelisted: true,
e164: contactA.device.number,
pni: toUntaggedPni(contactB.device.pni),
pniBinary: contactB.device.pniRawUuid,
// Key change - different identity key
identityKey: contactB.publicKey.serialize(),
@@ -334,17 +344,21 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
const updated = await phone.setStorageState(
state
.removeRecord(
item =>
item.record.contact?.pni === toUntaggedPni(contactA.device.pni)
)
.removeRecord(item => {
return item.record.contact?.pniBinary?.length
? timingSafeEqual(
item.record.contact.pniBinary,
contactA.device.pniRawUuid
)
: false;
})
.addContact(
contactB,
{
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
whitelisted: true,
e164: contactA.device.number,
pni: toUntaggedPni(contactB.device.pni),
pniBinary: contactB.device.pniRawUuid,
// Note: No identityKey key provided here!
},
@@ -465,17 +479,21 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
const updated = await phone.setStorageState(
state
.removeRecord(
item =>
item.record.contact?.pni === toUntaggedPni(contactA.device.pni)
)
.removeRecord(item => {
return item.record.contact?.pniBinary?.length
? timingSafeEqual(
item.record.contact.pniBinary,
contactA.device.pniRawUuid
)
: false;
})
.addContact(
contactB,
{
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
whitelisted: true,
e164: contactA.device.number,
pni: toUntaggedPni(contactB.device.pni),
pniBinary: contactB.device.pniRawUuid,
// Note: No identityKey key provided here!
},
@@ -497,17 +515,21 @@ describe('pnp/PNI Change', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
const updated = await phone.setStorageState(
state
.removeRecord(
item =>
item.record.contact?.pni === toUntaggedPni(contactB.device.pni)
)
.removeRecord(item => {
return item.record.contact?.pniBinary?.length
? timingSafeEqual(
item.record.contact.pniBinary,
contactB.device.pniRawUuid
)
: false;
})
.addContact(
contactB,
{
identityState: Proto.ContactRecord.IdentityState.DEFAULT,
whitelisted: true,
e164: contactA.device.number,
pni: toUntaggedPni(contactA.device.pni),
pniBinary: contactA.device.pniRawUuid,
},
ServiceIdKind.PNI
)

View File

@@ -15,7 +15,6 @@ import createDebug from 'debug';
import * as durations from '../../util/durations';
import { uuidToBytes } from '../../util/uuidToBytes';
import { MY_STORY_ID } from '../../types/Stories';
import { isUntaggedPniString, toTaggedPni } from '../../types/ServiceId';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
import {
@@ -61,7 +60,6 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -132,9 +130,7 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
});
debug('Open conversation with the stranger');
await leftPane
.locator(`[data-testid="${stranger.toContact().aci}"]`)
.click();
await leftPane.locator(`[data-testid="${stranger.device.aci}"]`).click();
debug('Accept conversation from a stranger');
await acceptConversation(window);
@@ -259,7 +255,7 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
debug('Send a PNI sync message');
const timestamp = bootstrap.getTimestamp();
const destinationServiceId = stranger.device.pni;
const destinationServiceIdBinary = stranger.device.pniBinary;
const destinationE164 = stranger.device.number;
const destinationPniIdentityKey = await stranger.device.getIdentityKey(
ServiceIdKind.PNI
@@ -271,13 +267,13 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
const content = {
syncMessage: {
sent: {
destinationServiceId,
destinationServiceIdBinary,
destinationE164,
timestamp: Long.fromNumber(timestamp),
message: originalDataMessage,
unidentifiedStatus: [
{
destinationServiceId,
destinationServiceIdBinary,
destinationPniIdentityKey: destinationPniIdentityKey.serialize(),
},
],
@@ -367,9 +363,7 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
});
debug('Wait for merge to happen');
await leftPane
.locator(`[data-testid="${stranger.toContact().aci}"]`)
.waitFor();
await leftPane.locator(`[data-testid="${stranger.device.aci}"]`).waitFor();
{
debug('Wait for composition input to clear');
@@ -409,13 +403,8 @@ describe('pnp/PNI Signature', function (this: Mocha.Suite) {
);
assert(aciRecord, 'ACI Contact must be in storage service');
assert.strictEqual(aciRecord?.aci, stranger.device.aci);
assert.strictEqual(
aciRecord?.pni &&
isUntaggedPniString(aciRecord?.pni) &&
toTaggedPni(aciRecord?.pni),
stranger.device.pni
);
assert.deepEqual(aciRecord?.aciBinary, stranger.device.aciRawUuid);
assert.deepEqual(aciRecord?.pniBinary, stranger.device.pniRawUuid);
assert.strictEqual(aciRecord?.pniSignatureVerified, true);
// Two outgoing, one incoming

View File

@@ -12,7 +12,7 @@ import {
import createDebug from 'debug';
import * as durations from '../../util/durations';
import { generatePni, toUntaggedPni } from '../../types/ServiceId';
import { generatePni } from '../../types/ServiceId';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
@@ -93,7 +93,7 @@ describe('pnp/PNI DecryptionError unlink', function (this: Mocha.Suite) {
},
{
timestamp: bootstrap.getTimestamp(),
updatedPni: toUntaggedPni(generatePni()),
updatedPni: generatePni(),
}
)
);
@@ -107,7 +107,7 @@ describe('pnp/PNI DecryptionError unlink', function (this: Mocha.Suite) {
},
{
timestamp: bootstrap.getTimestamp(),
updatedPni: toUntaggedPni(desktop.pni),
updatedPni: desktop.pni,
}
)
);

View File

@@ -73,7 +73,6 @@ describe('pnp/send gv2 invite', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});

View File

@@ -67,7 +67,6 @@ describe('pnp/username', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});
@@ -146,10 +145,16 @@ describe('pnp/username', function (this: Mocha.Suite) {
'only one record must be removed'
);
assert.strictEqual(added[0].contact?.aci, usernameContact.device.aci);
assert.deepEqual(
added[0].contact?.aciBinary,
usernameContact.device.aciRawUuid
);
assert.strictEqual(added[0].contact?.username, '');
assert.strictEqual(removed[0].contact?.aci, usernameContact.device.aci);
assert.deepEqual(
removed[0].contact?.aciBinary,
usernameContact.device.aciRawUuid
);
assert.strictEqual(removed[0].contact?.username, USERNAME);
}

View File

@@ -46,7 +46,6 @@ describe('story/no-sender-key', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});

View File

@@ -9,7 +9,6 @@ import * as durations from '../../util/durations';
import { Bootstrap } from '../bootstrap';
import type { App } from '../bootstrap';
import { ReceiptType } from '../../types/Receipt';
import { toUntaggedPni } from '../../types/ServiceId';
import {
acceptConversation,
typeIntoInput,
@@ -57,7 +56,7 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
whitelisted: true,
e164: contact.device.number,
identityKey: contact.getPublicKey(ServiceIdKind.PNI).serialize(),
pni: toUntaggedPni(contact.device.pni),
pniBinary: contact.device.pniRawUuid,
givenName: 'Jamie',
},
ServiceIdKind.PNI
@@ -68,7 +67,7 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
whitelisted: true,
e164: contactB.device.number,
identityKey: contactB.getPublicKey(ServiceIdKind.PNI).serialize(),
pni: toUntaggedPni(contactB.device.pni),
pniBinary: contactB.device.pniRawUuid,
givenName: 'Kim',
},
ServiceIdKind.PNI
@@ -111,10 +110,8 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
const window = await app.getWindow();
const leftPane = window.locator('#LeftPane');
debug(`Opening conversation with contact (${contact.toContact().aci})`);
await leftPane
.locator(`[data-testid="${contact.toContact().aci}"]`)
.click();
debug(`Opening conversation with contact (${contact.device.aci})`);
await leftPane.locator(`[data-testid="${contact.device.aci}"]`).click();
debug('Accept conversation from contact - does not trigger captcha!');
await acceptConversation(window);
@@ -172,10 +169,8 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
timestamp: timestampA,
});
debug(`Opening conversation with ContactA (${contact.toContact().aci})`);
await leftPane
.locator(`[data-testid="${contact.toContact().aci}"]`)
.click();
debug(`Opening conversation with ContactA (${contact.device.aci})`);
await leftPane.locator(`[data-testid="${contact.device.aci}"]`).click();
debug('Accept conversation from ContactA - does not trigger captcha!');
await acceptConversation(window);
@@ -186,10 +181,8 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
timestamp: timestampB,
});
debug(`Opening conversation with ContactB (${contact.toContact().aci})`);
await leftPane
.locator(`[data-testid="${contactB.toContact().aci}"]`)
.click();
debug(`Opening conversation with ContactB (${contact.device.aci})`);
await leftPane.locator(`[data-testid="${contactB.device.aci}"]`).click();
debug('Accept conversation from ContactB - does not trigger captcha!');
await acceptConversation(window);
@@ -273,10 +266,8 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
const window = await app.getWindow();
const leftPane = window.locator('#LeftPane');
debug(`Opening conversation with contact (${contact.toContact().aci})`);
await leftPane
.locator(`[data-testid="${contact.toContact().aci}"]`)
.click();
debug(`Opening conversation with contact (${contact.device.aci})`);
await leftPane.locator(`[data-testid="${contact.device.aci}"]`).click();
debug('Accept conversation from contact - does not trigger captcha!');
await acceptConversation(window);
@@ -342,10 +333,8 @@ describe('challenge/receipts', function (this: Mocha.Suite) {
timestamp,
});
debug(`Opening conversation with Contact B (${contactB.toContact().aci})`);
await leftPane
.locator(`[data-testid="${contactB.toContact().aci}"]`)
.click();
debug(`Opening conversation with Contact B (${contactB.device.aci})`);
await leftPane.locator(`[data-testid="${contactB.device.aci}"]`).click();
debug('Accept conversation from Contact B - does not trigger captcha!');
await acceptConversation(window);

View File

@@ -57,7 +57,7 @@ describe('routing', function (this: Mocha.Suite) {
await page.locator('#LeftPane').waitFor();
const token = await page.evaluate(
serviceId => window.SignalCI?.createNotificationToken(serviceId),
friend.toContact().aci
friend.device.aci
);
strictAssert(typeof token === 'string', 'token must be returned');
const conversationUrl = showConversationRoute.toAppUrl({

View File

@@ -49,7 +49,7 @@ describe('storage service', function (this: Mocha.Suite) {
});
await leftPane
.locator(`[data-testid="${firstContact.toContact().aci}"]`)
.locator(`[data-testid="${firstContact.device.aci}"]`)
.waitFor({ state: 'hidden' });
await leftPane
@@ -74,7 +74,7 @@ describe('storage service', function (this: Mocha.Suite) {
});
await leftPane
.locator(`[data-testid="${firstContact.toContact().aci}"]`)
.locator(`[data-testid="${firstContact.device.aci}"]`)
.waitFor();
await leftPane
@@ -89,7 +89,7 @@ describe('storage service', function (this: Mocha.Suite) {
const state = await phone.expectStorageState('consistency check');
await leftPane
.locator(`[data-testid="${firstContact.toContact().aci}"]`)
.locator(`[data-testid="${firstContact.device.aci}"]`)
.click();
const moreButton = conversationStack.locator(

View File

@@ -41,7 +41,6 @@ describe('storage service', function (this: Mocha.Suite) {
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});

View File

@@ -101,7 +101,6 @@ export async function initStorage(
identifier: uuidToBytes(MY_STORY_ID),
isBlockList: true,
name: MY_STORY_ID,
recipientServiceIds: [],
},
},
});

View File

@@ -6,6 +6,7 @@ import { Proto } from '@signalapp/mock-server';
import * as durations from '../../util/durations';
import { generateAci } from '../../types/ServiceId';
import { toAciObject } from '../../util/ServiceId';
import { MAX_READ_KEYS } from '../../services/storageConstants';
import type { App, Bootstrap } from './fixtures';
import { initStorage, debug } from './fixtures';
@@ -45,7 +46,7 @@ describe('storage service', function (this: Mocha.Suite) {
debug('wait for first contact to be pinned in the left pane');
await leftPane
.locator(`[data-testid="${firstContact.toContact().aci}"]`)
.locator(`[data-testid="${firstContact.device.aci}"]`)
.waitFor();
{
@@ -57,7 +58,7 @@ describe('storage service', function (this: Mocha.Suite) {
type: IdentifierType.CONTACT,
record: {
contact: {
aci: generateAci(),
aciBinary: toAciObject(generateAci()).getRawUuidBytes(),
},
},
});
@@ -76,7 +77,7 @@ describe('storage service', function (this: Mocha.Suite) {
debug('wait for last contact to be pinned in the left pane');
await leftPane
.locator(`[data-testid="${lastContact.toContact().aci}"]`)
.locator(`[data-testid="${lastContact.device.aci}"]`)
.waitFor({ timeout: durations.MINUTE });
debug('Verifying the final manifest version');

View File

@@ -56,10 +56,8 @@ describe('storage service', function (this: Mocha.Suite) {
const leftPane = window.locator('#LeftPane');
debug('Opening conversation with a stranger');
debug(stranger.toContact().aci);
await leftPane
.locator(`[data-testid="${stranger.toContact().aci}"]`)
.click();
debug(stranger.device.aci);
await leftPane.locator(`[data-testid="${stranger.device.aci}"]`).click();
debug("Verify that we stored stranger's profile key");
const postMessageState = await phone.waitForStorageState({

View File

@@ -108,7 +108,7 @@ describe('storage service', function (this: Mocha.Suite) {
debug('pinning contact=%d', i);
const convo = leftPane.locator(
`[data-testid="${contact.toContact().aci}"]`
`[data-testid="${contact.device.aci}"]`
);
await convo.click();

View File

@@ -61,7 +61,7 @@ describe('storage service', function (this: Mocha.Suite) {
);
await leftPane
.locator(`[data-testid="${firstContact.toContact().aci}"]`)
.locator(`[data-testid="${firstContact.device.aci}"]`)
.click();
{