@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
42 lines (41 loc) • 1.33 kB
TypeScript
import { DataChannelCryptorDecryptStatus } from "../Types";
import { KeyStore } from "./KeyStore";
export interface EncryptToWireFormatParams {
plaintext: Uint8Array;
sequenceNumber: number;
}
export interface DecryptFromWireFormatParams {
frame: Uint8Array;
lastSequenceNumber: number;
}
export interface ParsedEncryptedFrame {
version: number;
sequenceNumber: number;
keyId: string;
iv: Uint8Array;
ciphertext: Uint8Array;
header: Uint8Array;
}
export declare class DataChannelCryptor {
private keyStore;
private readonly textEncoder;
private readonly textDecoder;
constructor(keyStore: KeyStore);
encryptToWireFormat(params: EncryptToWireFormatParams): Promise<Uint8Array>;
decryptFromWireFormat(params: DecryptFromWireFormatParams): Promise<{
data: Uint8Array;
seq: number;
}>;
parseEncryptedFrame(frame: Uint8Array, lastSeq: number): ParsedEncryptedFrame;
private serializeHeader;
private assertFrameLength;
private assertKeyId;
private assertSequence;
private assertSequenceNumberValue;
private assertIv;
private concat;
}
export declare class DataChannelCryptorError extends Error {
readonly code: DataChannelCryptorDecryptStatus;
constructor(code: DataChannelCryptorDecryptStatus, message: string);
}