@signalapp/mock-server
Version:
Mock Signal Server for writing tests
61 lines (60 loc) • 3.11 kB
TypeScript
/// <reference types="node" />
import { Buffer } from 'buffer';
import { PrivateKey, PublicKey, SenderCertificate } from '@signalapp/libsignal-client';
import { signalservice as Proto } from '../protos/compiled';
import { Attachment } from './data/attachment';
import type { ServerPreKey, ServerSignedPreKey } from './data/schemas';
import { AciString, DeviceId, KyberPreKey, PreKey, SignedPreKey } from './types';
export type EncryptedProvisionMessage = {
body: Buffer;
ephemeralKey: Buffer;
};
export type ServerCertificate = {
privateKey: PrivateKey;
certificate: Proto.IServerCertificate;
};
export type Sender = {
readonly aci: AciString;
readonly number?: string;
readonly deviceId: DeviceId;
readonly identityKey: PublicKey;
readonly expires?: number;
};
export declare function encryptProvisionMessage(data: Buffer, remotePubKey: PublicKey): EncryptedProvisionMessage;
export type EncryptAttachmentOptions = Readonly<{
aesKey: Buffer;
macKey: Buffer;
iv: Buffer;
}>;
export declare function encryptAttachment(cleartext: Buffer, { aesKey, macKey, iv }?: EncryptAttachmentOptions): Attachment;
export declare function generateServerCertificate(rootKey: PrivateKey): ServerCertificate;
export declare function generateSenderCertificate(serverCert: ServerCertificate, sender: Sender): SenderCertificate;
export declare function deriveAccessKey(profileKey: Buffer): Buffer;
export declare function deriveMasterKey(accountEntropyPool: string): Buffer;
export declare function deriveStorageKey(masterKey: Buffer): Buffer;
export type DeriveStorageItemKeyOptions = Readonly<{
storageKey: Buffer;
recordIkm: Buffer | undefined;
key: Buffer;
}>;
export declare function deriveStorageItemKey({ storageKey, recordIkm, key, }: DeriveStorageItemKeyOptions): Buffer;
export declare function decryptStorageManifest(storageKey: Buffer, manifest: Proto.IStorageManifest): Proto.IManifestRecord;
export declare function encryptStorageManifest(storageKey: Buffer, manifestRecord: Proto.IManifestRecord): Proto.IStorageManifest;
export type DecryptStorageItemOptions = Readonly<{
storageKey: Buffer;
recordIkm: Buffer | undefined;
item: Proto.IStorageItem;
}>;
export declare function decryptStorageItem({ storageKey, recordIkm, item, }: DecryptStorageItemOptions): Proto.IStorageRecord;
export type EncryptStorageItemOptions = Readonly<{
storageKey: Buffer;
key: Buffer;
recordIkm: Buffer | undefined;
record: Proto.IStorageRecord;
}>;
export declare function encryptStorageItem({ storageKey, key, recordIkm, record, }: EncryptStorageItemOptions): Proto.IStorageItem;
export declare function encryptProfileName(profileKey: Buffer, name: string): Buffer;
export declare function generateAccessKeyVerifier(accessKey: Buffer): Buffer;
export declare function decodePreKey({ keyId, publicKey }: ServerPreKey): PreKey;
export declare function decodeSignedPreKey({ keyId, publicKey, signature, }: ServerSignedPreKey): SignedPreKey;
export declare function decodeKyberPreKey({ keyId, publicKey, signature, }: ServerSignedPreKey): KyberPreKey;