@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
26 lines (25 loc) • 1.17 kB
TypeScript
type BufferLike = ArrayBuffer | Uint8Array;
type CryptoMaterial = BufferLike | CryptoKey;
interface EncryptionResult {
success: true;
data: Uint8Array;
}
interface EncryptionError {
success: false;
error: string;
}
type EncryptionResponse = EncryptionResult | EncryptionError;
interface DecryptionResult {
success: true;
data: Uint8Array;
}
interface DecryptionError {
success: false;
error: string;
}
type DecryptionResponse = DecryptionResult | DecryptionError;
declare function encryptWithAES256GCM(key: CryptoMaterial, iv: BufferLike, data: BufferLike, header: BufferLike): Promise<EncryptionResponse>;
declare function decryptWithAES256GCM(key: CryptoMaterial, iv: BufferLike, encryptedData: BufferLike, header: BufferLike): Promise<DecryptionResponse>;
declare function isEncryptionSuccess(result: EncryptionResponse): result is EncryptionResult;
declare function isDecryptionSuccess(result: DecryptionResponse): result is DecryptionResult;
export { encryptWithAES256GCM, decryptWithAES256GCM, isEncryptionSuccess, isDecryptionSuccess, type EncryptionResponse, type DecryptionResponse, type BufferLike, type CryptoMaterial, };