UNPKG

@wireapp/cryptobox

Version:

High-level API with persistent storage for Proteus.

31 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CryptoboxSession = void 0; const DecryptionError_1 = require("./error/DecryptionError"); const proteus_1 = require("@wireapp/proteus"); class CryptoboxSession { constructor(id, session) { this.id = id; this.session = session; Object.freeze(this); } async decrypt(ciphertext, pk_store) { if (ciphertext.byteLength === 0) { throw new DecryptionError_1.DecryptionError('Cannot decrypt an empty ArrayBuffer.'); } const envelope = proteus_1.message.Envelope.deserialise(ciphertext); return this.session.decrypt(pk_store, envelope); } encrypt(plaintext) { const ciphertext = proteus_1.session.Session.encrypt(this.session, plaintext); return ciphertext.serialise(); } fingerprint_local() { return this.session.local_identity.public_key.fingerprint(); } fingerprint_remote() { return this.session.remote_identity.fingerprint(); } } exports.CryptoboxSession = CryptoboxSession; //# sourceMappingURL=CryptoboxSession.js.map