dexie-encrypted
Advanced tools
Comparing version 2.0.0-beta.0 to 2.0.0-beta.1
import Dexie from 'dexie'; | ||
import { EncryptDatabaseParams } from './types'; | ||
export declare function encryptDatabaseWithCustomEncryption<T extends Dexie>({ db, encryptionKey, tableSettings, onKeyChange, encrypt, decrypt, nonceOverrideForTesting, }: EncryptDatabaseParams<T>): void; | ||
export declare function encryptDatabaseWithCustomEncryption<T extends Dexie>({ db, encryptionKey, tableSettings, onKeyChange, encrypt, decrypt, _nonceOverrideForTesting, }: EncryptDatabaseParams<T>): void; | ||
export declare function clearAllTables(db: Dexie): Promise<void[]>; | ||
export declare function clearEncryptedTables<T extends Dexie>(db: T): Promise<void[]>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encryptDatabaseWithCustomEncryption = void 0; | ||
exports.clearEncryptedTables = exports.clearAllTables = exports.encryptDatabaseWithCustomEncryption = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -18,3 +18,3 @@ const dexie_1 = tslib_1.__importDefault(require("dexie")); | ||
} | ||
function encryptDatabaseWithCustomEncryption({ db, encryptionKey, tableSettings, onKeyChange, encrypt, decrypt, nonceOverrideForTesting, }) { | ||
function encryptDatabaseWithCustomEncryption({ db, encryptionKey, tableSettings, onKeyChange, encrypt, decrypt, _nonceOverrideForTesting, }) { | ||
let keyPromise; | ||
@@ -47,3 +47,3 @@ if (encryptionKey instanceof Uint8Array) { | ||
} | ||
installHooks_1.installHooks(db, tableSettings, keyPromise, encrypt, decrypt, nonceOverrideForTesting); | ||
installHooks_1.installHooks(db, tableSettings, keyPromise, encrypt, decrypt, _nonceOverrideForTesting); | ||
db.on('ready', () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
@@ -64,3 +64,3 @@ try { | ||
yield checkForKeyChange_1.checkForKeyChange(db, oldSettings, encryptionKey, encrypt, decrypt, onKeyChange); | ||
yield upgradeTables_1.upgradeTables(db, tableSettings, encryptionKey, oldSettings === null || oldSettings === void 0 ? void 0 : oldSettings.settings, encrypt, decrypt, nonceOverrideForTesting); | ||
yield upgradeTables_1.upgradeTables(db, tableSettings, encryptionKey, oldSettings === null || oldSettings === void 0 ? void 0 : oldSettings.settings, encrypt, decrypt, _nonceOverrideForTesting); | ||
yield encryptionSettings.clear(); | ||
@@ -79,2 +79,26 @@ yield encryptionSettings.put({ | ||
exports.encryptDatabaseWithCustomEncryption = encryptDatabaseWithCustomEncryption; | ||
function clearAllTables(db) { | ||
return Promise.all(db.tables.map(function (table) { | ||
return table.clear(); | ||
})); | ||
} | ||
exports.clearAllTables = clearAllTables; | ||
function clearEncryptedTables(db) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let encryptionSettings = (yield db | ||
.table('_encryptionSettings') | ||
.toCollection() | ||
.last() | ||
.catch(() => { | ||
throw new Error("Dexie-encrypted can't find its encryption table. You may need to bump your database version."); | ||
})); | ||
const promises = Object.keys(encryptionSettings.settings).map(function (key) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield db.table(key).clear(); | ||
}); | ||
}); | ||
return Promise.all(promises); | ||
}); | ||
} | ||
exports.clearEncryptedTables = clearEncryptedTables; | ||
//# sourceMappingURL=encryptDatabase.js.map |
@@ -7,11 +7,3 @@ import Dexie from 'dexie'; | ||
export declare const UNENCRYPTED_LIST: "UNENCRYPTED_LIST"; | ||
export declare function clearAllTables(db: Dexie): Promise<void[]>; | ||
export declare function clearEncryptedTables<T extends Dexie>(db: T): Promise<void[]>; | ||
export interface EncryptDatabaseConvenientParams<T extends Dexie> { | ||
db: T; | ||
encryptionKey: Uint8Array | Promise<Uint8Array>; | ||
tableSettings: CryptoSettings<T>; | ||
onKeyChange: (db: T) => Promise<any>; | ||
nonceOverrideForTesting?: Uint8Array; | ||
} | ||
export declare function encryptDatabase<T extends Dexie>(db: T, encryptionKey: Uint8Array | Promise<Uint8Array>, tableSettings: CryptoSettings<T>, onKeyChange: (db: T) => Promise<any>, nonceOverrideForTesting?: Uint8Array): void; | ||
export { clearAllTables, clearEncryptedTables } from './encryptDatabase'; | ||
export declare function encryptDatabase<T extends Dexie>(db: T, encryptionKey: Uint8Array | Promise<Uint8Array>, tableSettings: CryptoSettings<T>, onKeyChange: (db: T) => Promise<any>, _nonceOverrideForTesting?: Uint8Array): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.encryptDatabase = exports.clearEncryptedTables = exports.clearAllTables = exports.UNENCRYPTED_LIST = exports.ENCRYPT_LIST = exports.NON_INDEXED_FIELDS = void 0; | ||
const tslib_1 = require("tslib"); | ||
exports.encryptDatabase = exports.UNENCRYPTED_LIST = exports.ENCRYPT_LIST = exports.NON_INDEXED_FIELDS = void 0; | ||
const encryptDatabase_1 = require("./encryptDatabase"); | ||
@@ -13,27 +12,6 @@ const encryptionMethods_1 = require("./encryptionMethods"); | ||
exports.UNENCRYPTED_LIST = types_1.cryptoOptions.UNENCRYPTED_LIST; | ||
function clearAllTables(db) { | ||
return Promise.all(db.tables.map(function (table) { | ||
return table.clear(); | ||
})); | ||
} | ||
exports.clearAllTables = clearAllTables; | ||
function clearEncryptedTables(db) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let encryptionSettings = (yield db | ||
.table('_encryptionSettings') | ||
.toCollection() | ||
.last() | ||
.catch(() => { | ||
throw new Error("Dexie-encrypted can't find its encryption table. You may need to bump your database version."); | ||
})); | ||
const promises = Object.keys(encryptionSettings.settings).map(function (key) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield db.table(key).clear(); | ||
}); | ||
}); | ||
return Promise.all(promises); | ||
}); | ||
} | ||
exports.clearEncryptedTables = clearEncryptedTables; | ||
function encryptDatabase(db, encryptionKey, tableSettings, onKeyChange, nonceOverrideForTesting) { | ||
var encryptDatabase_2 = require("./encryptDatabase"); | ||
Object.defineProperty(exports, "clearAllTables", { enumerable: true, get: function () { return encryptDatabase_2.clearAllTables; } }); | ||
Object.defineProperty(exports, "clearEncryptedTables", { enumerable: true, get: function () { return encryptDatabase_2.clearEncryptedTables; } }); | ||
function encryptDatabase(db, encryptionKey, tableSettings, onKeyChange, _nonceOverrideForTesting) { | ||
encryptDatabase_1.encryptDatabaseWithCustomEncryption({ | ||
@@ -46,3 +24,3 @@ db, | ||
onKeyChange, | ||
nonceOverrideForTesting, | ||
_nonceOverrideForTesting, | ||
}); | ||
@@ -49,0 +27,0 @@ } |
@@ -38,3 +38,3 @@ import Dexie from 'dexie'; | ||
decrypt: DecryptionMethod; | ||
nonceOverrideForTesting?: Uint8Array; | ||
_nonceOverrideForTesting?: Uint8Array; | ||
} |
{ | ||
"name": "dexie-encrypted", | ||
"version": "2.0.0-beta.0", | ||
"version": "2.0.0-beta.1", | ||
"description": "Encryption middleware for Dexie", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42532
0
456