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
115
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 5.0.0 to 5.0.1

2

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

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -160,3 +160,2 @@ /// <reference types="node" />

private readonly identity;
readonly signedPreKeyId: number;
readonly publicKey: PublicKey;

@@ -167,3 +166,2 @@ readonly profileKey: ProfileKey;

readonly masterKey: Buffer;
lastResortKeyId: number;
readonly userAgent = "OWI";

@@ -170,0 +168,0 @@ constructor(device: Device, config: Config);

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

class SignedPreKeyStore extends libsignal_client_1.SignedPreKeyStore {
lastId = 0;
records = new Map();

@@ -75,2 +76,7 @@ async saveSignedPreKey(id, record) {

}
getNextId() {
this.lastId += 1;
// Note: intentionally starting from 1
return this.lastId;
}
}

@@ -223,3 +229,2 @@ class PreKeyStore extends libsignal_client_1.PreKeyStore {

identity = new Map();
signedPreKeyId = 1;
publicKey = this.privateKey.getPublicKey();

@@ -230,3 +235,2 @@ profileKey;

masterKey = crypto_1.default.randomBytes(16);
lastResortKeyId = 1;
// TODO(indutny): make primary device type configurable

@@ -283,13 +287,14 @@ userAgent = 'OWI';

async generateKeys(device, serviceIdKind) {
const shouldSave = device === this.device;
const isPrimary = device === this.device;
const signedPreKey = libsignal_client_1.PrivateKey.generate();
const signedPreKeySig = this.getPrivateKey(serviceIdKind).sign(signedPreKey.getPublicKey().serialize());
const signedPreKeyRecord = libsignal_client_1.SignedPreKeyRecord.new(this.signedPreKeyId, Date.now(), signedPreKey.getPublicKey(), signedPreKey, signedPreKeySig);
if (shouldSave) {
await this.signedPreKeys.get(serviceIdKind)?.saveSignedPreKey(this.signedPreKeyId, signedPreKeyRecord);
const signedPreKeyId = this.signedPreKeys.get(serviceIdKind)?.getNextId() || 1;
const signedPreKeyRecord = libsignal_client_1.SignedPreKeyRecord.new(signedPreKeyId, Date.now(), signedPreKey.getPublicKey(), signedPreKey, signedPreKeySig);
if (isPrimary) {
await this.signedPreKeys.get(serviceIdKind)?.saveSignedPreKey(signedPreKeyId, signedPreKeyRecord);
}
this.lastResortKeyId = this.kyberPreKeys.get(serviceIdKind)?.getNextId() || 1;
const lastResortKeyRecord = this.generateKyberPreKey(this.lastResortKeyId, serviceIdKind);
if (shouldSave) {
await this.kyberPreKeys.get(serviceIdKind)?.saveLastResortKey(this.lastResortKeyId, lastResortKeyRecord);
const lastResortKeyId = this.kyberPreKeys.get(serviceIdKind)?.getNextId() || 1;
const lastResortKeyRecord = this.generateKyberPreKey(lastResortKeyId, serviceIdKind);
if (isPrimary) {
await this.kyberPreKeys.get(serviceIdKind)?.saveLastResortKey(lastResortKeyId, lastResortKeyRecord);
}

@@ -299,3 +304,3 @@ return {

signedPreKey: {
keyId: this.signedPreKeyId,
keyId: signedPreKeyId,
publicKey: signedPreKey.getPublicKey(),

@@ -305,3 +310,3 @@ signature: signedPreKeySig,

lastResortKey: {
keyId: this.lastResortKeyId,
keyId: lastResortKeyId,
publicKey: lastResortKeyRecord.publicKey(),

@@ -319,3 +324,6 @@ signature: lastResortKeyRecord.signature(),

assert_1.default.ok(preKeyStore, 'Missing preKey store');
const shouldSave = device === this.device;
const isPrimary = device === this.device;
if (!isPrimary) {
return;
}
while (true) {

@@ -325,6 +333,4 @@ const preKey = libsignal_client_1.PrivateKey.generate();

const keyId = preKeyStore.getNextId();
if (shouldSave) {
const record = libsignal_client_1.PreKeyRecord.new(keyId, publicKey, preKey);
await preKeyStore.savePreKey(keyId, record);
}
const record = libsignal_client_1.PreKeyRecord.new(keyId, publicKey, preKey);
await preKeyStore.savePreKey(keyId, record);
yield { keyId, publicKey };

@@ -342,9 +348,10 @@ }

assert_1.default.ok(kyberPreKeyStore, 'Missing kyberPreKeyStore store');
const shouldSave = device === this.device;
const isPrimary = device === this.device;
if (!isPrimary) {
return;
}
while (true) {
const keyId = kyberPreKeyStore.getNextId();
const record = this.generateKyberPreKey(keyId, serviceIdKind);
if (shouldSave) {
await kyberPreKeyStore.saveKyberPreKey(keyId, record);
}
await kyberPreKeyStore.saveKyberPreKey(keyId, record);
yield {

@@ -351,0 +358,0 @@ keyId,

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