static #storage: IDBDatabase
static {
- Safe.listen()
+ this.listen()
}
static async work (headers: Headers, data: Data): Promise<any> {
try {
const records: SafeRecord[] = []
const salt = await Entropy.create()
- const encryptionKey = await Safe.#createAesKey('encrypt', password, salt.buffer)
+ const encryptionKey = await this.#createAesKey('encrypt', password, salt.buffer)
for (const label of Object.keys(data)) {
const iv = await Entropy.create()
const encrypted = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv: iv.buffer }, encryptionKey, data[label])
throw new Error('Failed to find record')
}
const salt = await Entropy.import(record.salt)
- const decryptionKey = await Safe.#createAesKey('decrypt', password, salt.buffer)
+ const decryptionKey = await this.#createAesKey('decrypt', password, salt.buffer)
const iv = await Entropy.import(record.iv)
const decrypted = await globalThis.crypto.subtle.decrypt({ name: 'AES-GCM', iv: iv.buffer }, decryptionKey, record.encrypted)
return { [record.label]: decrypted }