@signalapp/mock-server
Version:
Mock Signal Server for writing tests
111 lines (110 loc) • 3.46 kB
TypeScript
import z from 'zod';
import { CallingPublicKey } from './sfu/crypto';
export type Uint32 = number & {
Uint32: never;
};
export type HexString = string & {
HexString: never;
};
export declare function getRandomHexString(size: number): HexString;
/**
* Calling IDs
* ----------------------------------------------------------------------------
*/
/**
* In multi-participant calls, the room id is the permanent ID
* equivalent to an ACI. It comes from a shared secret owned by the clients.
*/
export type CallingRoomId = string & {
RoomId: never;
};
/**
* Ephemeral, generated by calling service.
* Only used for group/adhoc calls.
*/
export type CallingEraId = HexString & {
EraId: never;
};
export declare function getRandomCallingEraId(): CallingEraId;
export type CallingDemuxId = Uint32 & {
DemuxId: never;
};
export declare function getRandomCallingDemuxId(): CallingDemuxId;
export type CallingUserId = HexString & {
UserId: never;
};
export declare enum CallType {
Group = 0,
Adhoc = 1
}
export declare enum CallLinkRestrictions {
AdminApproval = 0,
None = 1
}
/**
* Http
* ----------------------------------------------------------------------------
*/
export declare const CallingPublicKeySchema: z.ZodEffects<z.ZodString, HexString, string>;
export declare function decodeCallingPublicKey(input: HexString): CallingPublicKey;
export declare function encodeCallingPublicKey(key: CallingPublicKey): HexString;
/**
* Peek
* ----------------------------------------------------------------------------
*/
export type CallInfoClient = Readonly<{
demuxId: CallingDemuxId;
opaqueUserId: CallingUserId;
}>;
export type CallInfo = Readonly<{
eraId: CallingEraId;
maxClients: number;
creatorUserId: CallingUserId;
activeClients: ReadonlyArray<CallInfoClient>;
pendingClients: ReadonlyArray<CallInfoClient> | null;
}>;
/**
* Errors
* ----------------------------------------------------------------------------
*/
export declare enum CallingErrorCode {
AuthError = 0,
CallNotFound = 1,
TooManyClients = 2,
NoPermissionToCreateCall = 3,
DuplicateDemuxIdDetected = 4,
InternalError = 5
}
export declare class CallingError extends Error {
#private;
constructor(code: CallingErrorCode, message?: string);
get code(): CallingErrorCode;
}
export declare const CallingErrorCodesToHttpStatus: Record<CallingErrorCode, number>;
/**
* Auth
* ----------------------------------------------------------------------------
*/
export declare const CALLING_SERVICE_SECRET: NonSharedBuffer;
export type CallingAuthToken = Readonly<{
userId: CallingUserId;
groupId: CallingRoomId;
time: number;
isAllowedToInitiateGroupCall: boolean;
macCiphertext: string;
macDigest: Uint8Array<ArrayBuffer>;
}>;
export declare function parseCallingAuthHeader(authHeader?: string): CallingAuthToken;
export type CallingAuth = Readonly<{
userId: CallingUserId;
roomId: CallingRoomId;
isAllowedToInitiateGroupCall: boolean;
}>;
export declare function verifyCallingAuthToken(token: CallingAuthToken, key: Uint8Array<ArrayBuffer>): CallingAuth;
export type GenerateCallingAuthTokenOptions = Readonly<{
userId: Uint8Array<ArrayBuffer>;
groupId: string;
isAllowedToInitiateGroupCall: boolean;
key: Uint8Array<ArrayBuffer>;
}>;
export declare function generateCallingAuthToken(options: GenerateCallingAuthTokenOptions): string;