UNPKG

open-collaboration-protocol

Version:

Open Collaboration Protocol implementation, part of the Open Collaboration Tools project

52 lines 3.37 kB
import { NotificationMessage, EncryptedNotificationMessage, RequestMessage, EncryptedRequestMessage, ErrorMessage, ResponseErrorMessage, EncryptedResponseErrorMessage, BroadcastMessage, EncryptedBroadcastMessage, BinaryErrorMessage, ResponseMessage, EncryptedResponseMessage, Message, CompressionAlgorithm } from './messages.js'; import { MaybePromise } from '../utils/promise.js'; export declare namespace Encryption { interface KeyPair { publicKey: string; privateKey: string; } interface AsymmetricKey { peerId: string; publicKey: string; supportedCompression: CompressionAlgorithm[]; } interface EncryptionKey { symmetricKey: MaybePromise<string>; cache?: Record<string, string>; } interface DecryptionKey { privateKey: string; cache?: Record<string, string>; } function generateKeyPair(): Promise<KeyPair>; function generateSymKey(): Promise<string>; function symEncrypt(data: Uint8Array, key: string, iv: string): Promise<Uint8Array>; function symDecrypt(data: Uint8Array, key: string, iv: string): Promise<Uint8Array>; function publicEncrypt(data: Uint8Array, key: string): Promise<Uint8Array>; function privateDecrypt(data: Uint8Array, key: string): Promise<Uint8Array>; function generateIV(): Promise<string>; function encrypt(message: NotificationMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<EncryptedNotificationMessage>; function encrypt(message: RequestMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<EncryptedRequestMessage>; function encrypt(message: ResponseMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<EncryptedResponseMessage>; function encrypt(message: ErrorMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<BinaryErrorMessage>; function encrypt(message: ResponseErrorMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<EncryptedResponseErrorMessage>; function encrypt(message: BroadcastMessage, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<EncryptedBroadcastMessage>; function encrypt(message: Message & { content: unknown; }, symKey: EncryptionKey, ...keys: AsymmetricKey[]): Promise<Message & { content: Uint8Array; }>; function decrypt(message: EncryptedNotificationMessage, privateKey: DecryptionKey): Promise<NotificationMessage>; function decrypt(message: EncryptedBroadcastMessage, privateKey: DecryptionKey): Promise<BroadcastMessage>; function decrypt(message: EncryptedRequestMessage, privateKey: DecryptionKey): Promise<RequestMessage>; function decrypt(message: EncryptedResponseMessage, privateKey: DecryptionKey): Promise<ResponseMessage>; function decrypt(message: EncryptedResponseErrorMessage, privateKey: DecryptionKey): Promise<ResponseErrorMessage>; function decrypt(message: BinaryErrorMessage, privateKey: DecryptionKey): Promise<ErrorMessage>; function decrypt(message: EncryptedBroadcastMessage | EncryptedNotificationMessage, privateKey: DecryptionKey): Promise<BroadcastMessage | NotificationMessage>; function decrypt(message: Message & { content: Uint8Array; }, privateKey: DecryptionKey): Promise<Message & { content: unknown; }>; } //# sourceMappingURL=encryption.d.ts.map