Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signalapp/mock-server

Package Overview
Dependencies
Maintainers
6
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalapp/mock-server - npm Package Compare versions

Comparing version 4.5.0 to 4.6.0

4

package.json
{
"name": "@signalapp/mock-server",
"version": "4.5.0",
"version": "4.6.0",
"description": "Mock Signal Server for writing tests",

@@ -43,3 +43,3 @@ "main": "src/index.js",

"dependencies": {
"@signalapp/libsignal-client": "^0.39.1",
"@signalapp/libsignal-client": "^0.39.2",
"debug": "^4.3.2",

@@ -46,0 +46,0 @@ "long": "^4.0.0",

@@ -116,5 +116,2 @@ /// <reference types="node" />

export type PrepareChangeNumberResult = ReadonlyArray<PrepareChangeNumberEntry>;
export type ToContactOptions = Readonly<{
includeProfileKey?: boolean;
}>;
export declare class SessionStore extends SessionStoreBase {

@@ -164,3 +161,3 @@ private readonly sessions;

init(): Promise<void>;
toContact({ includeProfileKey, }?: ToContactOptions): Contact;
toContact(): Contact;
addSecondaryDevice(device: Device): void;

@@ -167,0 +164,0 @@ generateKeys(device: Device, serviceIdKind: ServiceIdKind): Promise<DeviceKeys & {

@@ -262,3 +262,3 @@ "use strict";

}
toContact({ includeProfileKey = true, } = {}) {
toContact() {
return {

@@ -268,3 +268,2 @@ aci: this.device.aci,

profileName: this.profileName,
profileKey: includeProfileKey ? this.profileKey.serialize() : undefined,
};

@@ -271,0 +270,0 @@ }

@@ -160,5 +160,3 @@ "use strict";

...contacts.map((device) => device.toContact()),
...contactsWithoutProfileKey.map((device) => device.toContact({
includeProfileKey: false,
})),
...contactsWithoutProfileKey.map((device) => device.toContact()),
]));

@@ -165,0 +163,0 @@ const contactsCDNKey = await this.storeAttachment(contactsAttachment.blob);

@@ -7,4 +7,3 @@ /// <reference types="node" />

profileName: string;
profileKey?: Buffer;
}>;
export declare function serializeContacts(contacts: ReadonlyArray<Contact>): Buffer;

@@ -9,3 +9,3 @@ "use strict";

const chunks = contacts.map((contact) => {
const { aci, number, profileName: name, profileKey } = contact;
const { aci, number, profileName: name } = contact;
return Buffer.from(compiled_1.signalservice.ContactDetails.encode({

@@ -15,3 +15,2 @@ aci,

name,
profileKey,
}).finish());

@@ -18,0 +17,0 @@ }).map((chunk) => {

@@ -15,2 +15,3 @@ "use strict";

const zkgroup_1 = require("@signalapp/libsignal-client/zkgroup");
const SealedSenderMultiRecipientMessage_1 = __importDefault(require("@signalapp/libsignal-client/dist/SealedSenderMultiRecipientMessage"));
const compiled_1 = require("../../../protos/compiled");

@@ -117,6 +118,6 @@ const schemas_1 = require("../../data/schemas");

}
const { recipients, commonMaterial, } = (0, util_1.parseMultiRecipientMessage)(buffer_1.Buffer.from(body));
const message = new SealedSenderMultiRecipientMessage_1.default(buffer_1.Buffer.from(body));
const listByServiceId = new Map();
for (const recipient of recipients) {
const { serviceId, destinations, material, } = recipient;
const recipients = message.recipientsByServiceIdString();
for (const [serviceId, recipient] of Object.entries(recipients)) {
let list = listByServiceId.get(serviceId);

@@ -127,3 +128,4 @@ if (!list) {

}
for (const { deviceId, registrationId } of destinations) {
for (const [i, deviceId] of recipient.deviceIds.entries()) {
const registrationId = recipient.registrationIds.at(i);
list.push({

@@ -133,6 +135,3 @@ type: compiled_1.signalservice.Envelope.Type.UNIDENTIFIED_SENDER,

destinationRegistrationId: registrationId,
content: (0, util_1.combineMultiRecipientMessage)({
material,
commonMaterial,
}).toString('base64'),
content: message.messageForRecipient(recipient).toString('base64'),
});

@@ -139,0 +138,0 @@ }

/// <reference types="node" />
import { ProtocolAddress } from '@signalapp/libsignal-client';
import type { DeviceId, RegistrationId, ServiceIdString } from './types';
import type { RegistrationId } from './types';
export type PromiseQueueConfig = Readonly<{
timeout?: number;
}>;
export type MultiRecipientDestination = Readonly<{
deviceId: DeviceId;
registrationId: RegistrationId;
}>;
export type MultiRecipientMessageRecipient = Readonly<{
serviceId: ServiceIdString;
destinations: ReadonlyArray<MultiRecipientDestination>;
material: Buffer;
}>;
export type MultiRecipientMessage = Readonly<{
recipients: ReadonlyArray<MultiRecipientMessageRecipient>;
commonMaterial: Buffer;
}>;
export declare function generateRandomE164(): string;

@@ -41,7 +28,2 @@ export type ParseAuthHeaderResult = {

export declare function addressToString(address: ProtocolAddress): string;
export declare function parseMultiRecipientMessage(message: Buffer): MultiRecipientMessage;
export declare function combineMultiRecipientMessage({ material, commonMaterial }: {
material: Buffer;
commonMaterial: Buffer;
}): Buffer;
export declare function getTodayInSeconds(): number;

@@ -48,0 +30,0 @@ export declare function generateRegistrationId(): RegistrationId;

@@ -8,6 +8,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fromURLSafeBase64 = exports.toURLSafeBase64 = exports.generateRegistrationId = exports.getTodayInSeconds = exports.combineMultiRecipientMessage = exports.parseMultiRecipientMessage = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0;
exports.fromURLSafeBase64 = exports.toURLSafeBase64 = exports.generateRegistrationId = exports.getTodayInSeconds = exports.addressToString = exports.PromiseQueue = exports.parseAuthHeader = exports.generateRandomE164 = void 0;
const assert_1 = __importDefault(require("assert"));
const libsignal_client_1 = require("@signalapp/libsignal-client");
const protobufjs_1 = require("protobufjs");
const constants_1 = require("./constants");

@@ -23,5 +21,2 @@ function generateRandomE164() {

exports.generateRandomE164 = generateRandomE164;
const MULTI_RECIPIENT_MESSAGE_VERSION = 0x23;
const MULTI_RECIPIENT_SERVICE_ID_LEN = 17;
const MULTI_RECIPIENT_SHARED_MATERIAL_LEN = 48;
function parseAuthHeader(header) {

@@ -142,42 +137,2 @@ if (!header) {

exports.addressToString = addressToString;
function parseMultiRecipientMessage(message) {
if (message[0] !== MULTI_RECIPIENT_MESSAGE_VERSION) {
throw new Error('Invalid multi-recipient message');
}
const reader = new protobufjs_1.BufferReader(message);
// Version
reader.skip(1);
const count = reader.uint32();
const recipients = new Array();
while (recipients.length < count) {
const serviceId = libsignal_client_1.ServiceId.parseFromServiceIdFixedWidthBinary(message.slice(reader.pos, reader.pos + MULTI_RECIPIENT_SERVICE_ID_LEN)).getServiceIdString();
reader.skip(MULTI_RECIPIENT_SERVICE_ID_LEN);
const destinations = new Array();
while (reader.pos + 3 <= reader.len) {
const deviceId = reader.uint32();
const registrationIdAndFlag = message.readUInt16BE(reader.pos);
reader.skip(2);
const registrationId = (registrationIdAndFlag & 0x7fff);
destinations.push({ deviceId, registrationId });
if ((registrationIdAndFlag & 0x8000) === 0) {
break;
}
}
const material = message.slice(reader.pos, reader.pos + MULTI_RECIPIENT_SHARED_MATERIAL_LEN);
assert_1.default.strictEqual(material.length, MULTI_RECIPIENT_SHARED_MATERIAL_LEN);
reader.skip(MULTI_RECIPIENT_SHARED_MATERIAL_LEN);
recipients.push({ serviceId, destinations, material });
}
const commonMaterial = message.slice(reader.pos);
return { recipients, commonMaterial };
}
exports.parseMultiRecipientMessage = parseMultiRecipientMessage;
function combineMultiRecipientMessage({ material, commonMaterial }) {
return Buffer.concat([
Buffer.from([MULTI_RECIPIENT_MESSAGE_VERSION]),
material,
commonMaterial,
]);
}
exports.combineMultiRecipientMessage = combineMultiRecipientMessage;
function getTodayInSeconds() {

@@ -184,0 +139,0 @@ const now = Date.now() / 1000;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc