dexie-encrypted
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -94,4 +94,3 @@ 'use strict'; | ||
function encrypt(db, key, cryptoSettings, nonceOverride) { | ||
if ((key instanceof Uint8Array) === false || key.length !== 32) { | ||
if (key instanceof Uint8Array === false || key.length !== 32) { | ||
throw new Error('Dexie-encrypted requires a UInt8Array of length 32 for a encryption key.'); | ||
@@ -109,3 +108,5 @@ } | ||
} catch (error) { | ||
throw new Error("Dexie-encrypt: The call to encrypt() cannot be done on an open database"); | ||
throw new Error( | ||
'Dexie-encrypt: The call to encrypt() cannot be done on an open database' | ||
); | ||
} | ||
@@ -151,3 +152,3 @@ } | ||
} | ||
if (entity.__encryptedData) { | ||
if (entity && entity.__encryptedData) { | ||
const nonce = entity.__encryptedData.slice(0, nacl.secretbox.nonceLength); | ||
@@ -177,5 +178,7 @@ const message = entity.__encryptedData.slice( | ||
try { | ||
encryptionSettings = db.table("_encryptionSettings"); | ||
encryptionSettings = db.table('_encryptionSettings'); | ||
} catch (error) { | ||
throw new Error("Dexie-encrypted can't find its encryption table. You may need to bump your database version."); | ||
throw new Error( | ||
"Dexie-encrypted can't find its encryption table. You may need to bump your database version." | ||
); | ||
} | ||
@@ -196,3 +199,3 @@ return encryptionSettings | ||
table.hook('creating', function(primKey, obj) { | ||
const preservedValue = {...obj}; | ||
const preservedValue = { ...obj }; | ||
encryptWithRule(table, obj, newSetting); | ||
@@ -247,5 +250,8 @@ this.onsuccess = () => { | ||
return encryptionSettings.put(cryptoSettings); | ||
}).catch(error => { | ||
if (error.name === "NotFoundError") { | ||
throw new Error("Dexie-encrypted can't find its encryption table. You may need to bump your database version."); | ||
}) | ||
.catch(error => { | ||
if (error.name === 'NotFoundError') { | ||
throw new Error( | ||
"Dexie-encrypted can't find its encryption table. You may need to bump your database version." | ||
); | ||
} else { | ||
@@ -252,0 +258,0 @@ return Promise.reject(error); |
{ | ||
"name": "dexie-encrypted", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Encryption middleware for Dexie", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16264
237