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

@tabcat/orbit-db-fsstore

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tabcat/orbit-db-fsstore - npm Package Compare versions

Comparing version 3.1.3 to 3.1.4

2

package.json
{
"name": "@tabcat/orbit-db-fsstore",
"version": "3.1.3",
"version": "3.1.4",
"description": "a custom orbit-db store representing a file system",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -28,5 +28,5 @@

const defaultRoot = '/r'
const setRoot = (fs) => {
fs.root = defaultRoot
return fs.set(defaultRoot, { type: cTypes.dir })
const setRoot = (fs, root = defaultRoot) => {
fs.root = root
return fs.set(root, { type: cTypes.dir })
}

@@ -211,2 +211,3 @@ const root = (fs) => fs.root

ops,
setRoot,
root,

@@ -213,0 +214,0 @@ create,

@@ -5,3 +5,3 @@

const FS = require('./FS')
const { opcodes, lowercase } = FS
const { opcodes, lowercase, setRoot } = FS
const { ab2str } = require('./util')

@@ -11,12 +11,18 @@ const b64 = require('base64-js')

const fsReducer = (crypter) => async (fs, { payload } = {}) => {
fs = await fs
try {
fs = await fs
const fsCopy = new Map(fs)
if (crypter) {
const bytes = await crypter.decrypt(
b64.toByteArray(payload.cipherbytes).buffer,
b64.toByteArray(payload.iv)
)
payload = JSON.parse(ab2str(bytes))
if (payload.cipherbytes && payload.iv) {
const bytes = await crypter.decrypt(
b64.toByteArray(payload.cipherbytes).buffer,
b64.toByteArray(payload.iv)
)
payload = JSON.parse(ab2str(bytes))
if (opcodes[payload.op]) FS.ops[lowercase[payload.op]](fsCopy, payload)
}
} else {
if (opcodes[payload.op]) FS.ops[lowercase[payload.op]](fsCopy, payload)
}
if (opcodes[payload.op]) FS.ops[lowercase[payload.op]](fs, payload)
fs = fsCopy
} catch (e) {

@@ -28,15 +34,15 @@ console.log(e)

const passOptionsToIndex = (options = {}) =>
class FSIndex {
constructor () {
this._index = FS.create()
}
class FSIndex {
constructor () {
this._index = FS.create()
this._crypter = null
}
async updateIndex (oplog) {
const fs = FS.create()
await oplog.values.reduce(fsReducer(options.crypter), fs)
this._index = fs
}
async updateIndex (oplog) {
const fs = FS.create()
this._index = await oplog.values.reduce(fsReducer(this._crypter), fs)
setRoot(this._index, fs.root)
}
}
module.exports = passOptionsToIndex
module.exports = FSIndex

@@ -68,3 +68,3 @@

constructor (ipfs, identity, dbname, options = {}) {
options = Object.assign({}, options, { Index: FSIndex(options) })
options = Object.assign({}, options, { Index: FSIndex })
super(ipfs, identity, dbname, options)

@@ -83,3 +83,8 @@ this._type = FSStore.type

this.crypter = options.crypter
this._crypter = null
this.setCrypter = (crypter) => {
this._crypter = crypter
this._index._crypter = crypter
}
if (options.crypter) this.setCrypter(options.crypter)
}

@@ -95,5 +100,5 @@

let payload = { op, ...params }
if (this.crypter) {
if (this._crypter) {
const serializedPayload = str2ab(JSON.stringify(payload))
const { cipherbytes, iv } = await this.crypter.encrypt(serializedPayload)
const { cipherbytes, iv } = await this._crypter.encrypt(serializedPayload)
payload = {

@@ -100,0 +105,0 @@ cipherbytes: b64.fromByteArray(new Uint8Array(cipherbytes)),

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