Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tabcat/encrypted-docstore

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tabcat/encrypted-docstore - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

package.json
{
"name": "@tabcat/encrypted-docstore",
"version": "1.0.1",
"version": "1.0.2",
"description": "mount encrypted docstores with a key",

@@ -5,0 +5,0 @@ "repository": {

@@ -9,7 +9,7 @@

constructor(encryptedDocstore, key) {
if (!isDefined(encryptedDocstore)) throw new Error('encryptedDocstore must be defined')
if (!isDefined(key)) throw new Error('key must be defined')
if (!encryptedDocstore) throw new Error('encryptedDocstore must be defined')
if (!key) throw new Error('key must be defined')
this._docstore = encryptedDocstore
this.indexBy = this.docstore.options.indexBy
this._key = key
this.indexBy = this._docstore.options.indexBy
}

@@ -195,1 +195,2 @@

module.exports = EncryptedDocstore

@@ -31,3 +31,3 @@

constructor(cryptoKey) {
this.key = cryptoKey
this.cryptoKey = cryptoKey
}

@@ -78,4 +78,4 @@

static async importKey(rawKey) {
if (cryptoKeyAb === undefined) {
throw new Error('cryptoKeyAb must be defined')
if (rawKey === undefined) {
throw new Error('rawKey must be defined')
}

@@ -98,5 +98,5 @@ const cryptoKey = await crypto.subtle.importKey(

iv = iv || await randomBytes(12)
const algo = { ...this.key.algorithm, iv }
const algo = { ...this.cryptoKey.algorithm, iv }
const cipherbytes = new Uint8Array(
await crypto.subtle.encrypt(algo, this.key, bytes)
await crypto.subtle.encrypt(algo, this.cryptoKey, bytes)
)

@@ -109,4 +109,4 @@ return { cipherbytes, iv }

}
const algo = { ...this.key.algorithm, iv }
return await crypto.subtle.decrypt(algo, this.key, bytes)
const algo = { ...this.cryptoKey.algorithm, iv }
return await crypto.subtle.decrypt(algo, this.cryptoKey, bytes)
}

@@ -128,4 +128,7 @@

const bytes = str2ab(JSON.stringify(doc))
const { cipherbytes, iv } = await this.encrypt(bytes)
return { _id:`entry-${iv.join('')}`, cipherbytes, iv }
const enc = await this.encrypt(bytes)
const prepUint = (uint) => Object.values(uint)
const cipherbytes = prepUint(enc.cipherbytes)
const iv = prepUint(enc.iv)
return { _id:`entry-${iv.join('')}`, cipherbytes, iv, }
}

@@ -137,3 +140,6 @@

}
const decrypted = await this.decrypt(encDoc.cipherbytes, encDoc.iv)
const deserializeUint = (obj) => new Uint8Array(Object.values(obj))
const cipherbytes = deserializeUint(encDoc.cipherbytes)
const iv = deserializeUint(encDoc.iv)
const decrypted = await this.decrypt(cipherbytes, iv, )
const clearObj = JSON.parse(ab2str(decrypted))

@@ -144,1 +150,2 @@ return { internal:clearObj, external:encDoc }

module.exports = Key
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc