UNPKG

@rocket.chat/forked-matrix-bot-sdk

Version:

TypeScript/JavaScript SDK for Matrix bots and appservices

38 lines (37 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.requiresReady = exports.requiresCrypto = void 0; /** * Flags a MatrixClient function as needing end-to-end encryption enabled. * @category Encryption */ function requiresCrypto() { return function (target, propertyKey, descriptor) { const originalMethod = descriptor.value; descriptor.value = function (...args) { const client = this; if (!client.crypto) { throw new Error("End-to-end encryption is not enabled"); } return originalMethod.apply(this, args); }; }; } exports.requiresCrypto = requiresCrypto; /** * Flags a CryptoClient function as needing the CryptoClient to be ready. * @category Encryption */ function requiresReady() { return function (target, propertyKey, descriptor) { const originalMethod = descriptor.value; descriptor.value = function (...args) { const crypto = this; if (!crypto.isReady) { throw new Error("End-to-end encryption has not initialized"); } return originalMethod.apply(this, args); }; }; } exports.requiresReady = requiresReady;