/* eslint-disable @typescript-eslint/no-extraneous-class */
import { EncryptionEventTypes } from './EncryptionEventTypes.js';
import { ContextEvent } from '../BaseEvents.js';
export class EncryptionEvents {
    /**
     * Dispatches an event handled by the encryption module to encrypt the data
     *
     * @param data The data to encrypt
     * @param passphrase The passphrase to use in 2-way data encryption
     * @param method Encryption method to use
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved to the encryption result
     */
    static async encrypt(data, passphrase, method, target = window) {
        const config = { data, passphrase, method };
        const e = new ContextEvent(EncryptionEventTypes.encrypt, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
    /**
     * Dispatches an event handled by the encryption module to decrypt the data
     *
     * @param data The data to decrypt
     * @param passphrase The passphrase to use to decrypt the data
     * @param method Method used to encrypt the data
     * @param target A node on which to dispatch the event.
     * @returns Promise resolved to the decrypted result
     */
    static async decrypt(data, passphrase, method, target = window) {
        const config = { data, passphrase, method };
        const e = new ContextEvent(EncryptionEventTypes.decrypt, config);
        target.dispatchEvent(e);
        return e.detail.result;
    }
}
//# sourceMappingURL=EncryptionEvents.js.map