orbit-db-storage-adapter
Advanced tools
Comparing version 0.8.1-75dc731.0 to 0.8.1-fc61eed.0
@@ -1,44 +0,45 @@ | ||
'use strict' | ||
import path from 'path' | ||
import webpack from 'webpack' | ||
import { fileURLToPath } from 'url' | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
export default (env, argv) => { | ||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = path.dirname(__filename) | ||
module.exports = { | ||
mode: 'production', | ||
entry: './src/index.js', | ||
output: { | ||
libraryTarget: 'var', | ||
library: 'Storage', | ||
filename: '../dist/orbitdb-storage.min.js' | ||
}, | ||
target: 'web', | ||
devtool: 'source-map', | ||
externals: { | ||
fs: '{}', | ||
mkdirp: '{}' | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify(process.env.NODE_ENV) | ||
return { | ||
mode: 'production', | ||
entry: './src/index.js', | ||
output: { | ||
libraryTarget: 'var', | ||
library: 'Storage', | ||
filename: '../dist/orbit-db-storage-adapter.min.js' | ||
}, | ||
target: 'web', | ||
devtool: 'source-map', | ||
externals: { | ||
fs: '{}', | ||
mkdirp: '{}' | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify('production') | ||
}) | ||
], | ||
resolve: { | ||
modules: [ | ||
'node_modules' | ||
], | ||
alias: { | ||
leveldown: 'level-js' | ||
} | ||
}) | ||
], | ||
resolve: { | ||
modules: [ | ||
'node_modules', | ||
path.resolve(__dirname, '../node_modules') | ||
], | ||
alias: { | ||
leveldown: 'level-js' | ||
}, | ||
resolveLoader: { | ||
modules: [ | ||
'node_modules', | ||
path.resolve(__dirname, '../node_modules') | ||
], | ||
extensions: ['.js', '.json'], | ||
mainFields: ['loader', 'main'] | ||
} | ||
}, | ||
resolveLoader: { | ||
modules: [ | ||
'node_modules', | ||
path.resolve(__dirname, '../node_modules') | ||
], | ||
extensions: ['.js', '.json'], | ||
mainFields: ['loader', 'main'] | ||
} | ||
} |
@@ -1,76 +0,48 @@ | ||
'use strict' | ||
import glob from 'glob' | ||
import webpack from 'webpack' | ||
const glob = require('glob') | ||
const webpack = require('webpack') | ||
const path = require('path') | ||
module.exports = { | ||
// TODO: put all tests in a .js file that webpack can use as entry point | ||
entry: glob.sync('./test/*.spec.js'), | ||
output: { | ||
filename: '../test/browser/bundle.js' | ||
}, | ||
target: 'web', | ||
mode: 'production', | ||
devtool: 'source-map', | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
NODE_ENV: JSON.stringify(process.env.NODE_ENV) | ||
export default (env, argv) => { | ||
return { | ||
// TODO: put all tests in a .js file that webpack can use as entry point | ||
entry: glob.sync('./test/*.spec.js'), | ||
output: { | ||
filename: '../test/browser/bundle.js' | ||
}, | ||
target: 'web', | ||
mode: 'production', | ||
devtool: 'source-map', | ||
plugins: [ | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
Buffer: ['buffer', 'Buffer'] | ||
}) | ||
], | ||
experiments: { | ||
topLevelAwait: true | ||
}, | ||
resolve: { | ||
modules: [ | ||
'node_modules' | ||
], | ||
fallback: { | ||
path: false, | ||
os: false, | ||
fs: false | ||
} | ||
}), | ||
new webpack.IgnorePlugin({ | ||
resourceRegExp: /mongo|redis/, | ||
contextRegExp: /mongo|redis/ | ||
}), | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
Buffer: ['buffer', 'Buffer'] | ||
}) | ||
], | ||
externals: { | ||
fs: '{}', | ||
fatfs: '{}', | ||
runtimejs: '{}', | ||
net: '{}', | ||
tls: '{}', | ||
child_process: {}, | ||
dns: '{}' | ||
}, | ||
resolve: { | ||
modules: [ | ||
'node_modules', | ||
path.resolve(__dirname, '../node_modules') | ||
], | ||
fallback: { | ||
buffer: require.resolve('buffer'), | ||
path: false, | ||
os: false | ||
} | ||
}, | ||
resolveLoader: { | ||
modules: [ | ||
'node_modules', | ||
path.resolve(__dirname, '../node_modules') | ||
], | ||
extensions: ['.js', '.json'], | ||
mainFields: ['loader', 'main'] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: [ | ||
['@babel/preset-env', { modules: false }] | ||
], | ||
plugins: ['@babel/syntax-object-rest-spread', '@babel/transform-runtime', '@babel/plugin-transform-modules-commonjs'] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.m?js$/, | ||
exclude: /node_modules/, | ||
use: { | ||
loader: 'babel-loader', | ||
options: { | ||
presets: ['@babel/preset-env'] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} |
{ | ||
"name": "orbit-db-storage-adapter", | ||
"version": "0.8.1-75dc731.0", | ||
"version": "0.8.1-fc61eed.0", | ||
"description": "OrbitDB adapter for any abstract-leveldown compliant storage", | ||
"main": "./src/index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -11,3 +12,3 @@ "test": "npm run test:node && npm run test:browser", | ||
"build": "webpack --config ./conf/webpack.config.js", | ||
"build:tests": "webpack --config ./conf/webpack.tests.config.js --mode production", | ||
"build:tests": "webpack --config ./conf/webpack.tests.config.js", | ||
"lint": "standard", | ||
@@ -43,4 +44,2 @@ "lint:fix": "standard --fix" | ||
"level-js": "^6.1.0", | ||
"leveldown": "^6.1.1", | ||
"levelup": "^5.1.1", | ||
"mkdirp": "^1.0.4" | ||
@@ -61,10 +60,7 @@ }, | ||
"mocha-headless-chrome": "^4.0.0", | ||
"mongo-unit": "^2.0.1", | ||
"mongodb-memory-server": "^6.9.6", | ||
"mongodown": "^2.0.0", | ||
"process": "^0.11.10", | ||
"standard": "^17.0.0", | ||
"webpack": "^5.74.0", | ||
"webpack-cli": "^4.10.0" | ||
"webpack-cli": "^5.0.0" | ||
} | ||
} |
@@ -31,5 +31,7 @@ # OrbitDB Storage Adapter | ||
// Requirements | ||
const leveldown = require('leveldown') // or any abstract-leveldown complaint store | ||
import leveldown from 'leveldown' // or any abstract-leveldown complaint store | ||
import storageAdapter from 'orbit-db-storage-adapter') | ||
const leveldownOptions = {} | ||
const storage = require('orbit-db-storage-adapter')(leveldown, leveldownOptions) | ||
const storage = storageAdapter(leveldown, leveldownOptions) | ||
@@ -36,0 +38,0 @@ const levelupOptions = {} // see below |
@@ -1,7 +0,4 @@ | ||
'use strict' | ||
import { Level } from 'level' | ||
import * as fs from 'fs' | ||
const levelup = require('levelup') | ||
const { Level } = require('level') | ||
const fs = (typeof window === 'object' || typeof self === 'object') ? null : eval('require("fs")') // eslint-disable-line | ||
// Should work for all abstract-leveldown compliant stores | ||
@@ -39,28 +36,11 @@ | ||
await this.preCreate(directory, this.options) | ||
let store, db | ||
if (this.storage) { | ||
db = this.storage(directory, this.options.down) | ||
// For compatibility with older abstract-leveldown stores | ||
if (!db.status) db.status = 'unknown-shim' | ||
if (!db.location) db.location = directory | ||
store = levelup(db, options) | ||
await store.open() // TODO: Is this necessary? https://www.npmjs.com/package/levelup says it is only necessary when reopening a closed db. | ||
// More backwards compatibility | ||
db.status = db && db.status === 'unknown-shim' ? 'open' : db.status | ||
return store // should this not be db? | ||
} else { | ||
// Default leveldown or level-js store with directory creation | ||
if (!this.storage) { | ||
if (fs && fs.mkdirSync) fs.mkdirSync(directory, { recursive: true }) | ||
} | ||
const db = new Level(directory, options) | ||
await db.open() | ||
const db = new Level(directory, options) | ||
await db.open() | ||
return levelup(db) | ||
} | ||
return db | ||
} | ||
@@ -77,2 +57,2 @@ | ||
module.exports = (storage, options) => new Storage(storage, options) | ||
export default (storage, options) => new Storage(storage, options) |
@@ -1,6 +0,9 @@ | ||
module.exports = [ | ||
import leveljs from 'level-js' | ||
import memdown from 'memdown' | ||
export default [ | ||
{ | ||
key: 'level-js', | ||
type: 'browser', | ||
module: require('level-js') | ||
module: leveljs | ||
}, | ||
@@ -10,3 +13,3 @@ { | ||
type: 'browser', | ||
module: require('memdown') | ||
module: memdown | ||
} | ||
@@ -13,0 +16,0 @@ // { |
@@ -1,5 +0,15 @@ | ||
var isBrowser = new Function('try {return this===window;}catch(e){ return false;}') // eslint-disable-line | ||
var isNode = new Function('try {return this===global;}catch(e){return false;}') // eslint-disable-line | ||
const isBrowser = new Function('try {return this===window;}catch(e){return false;}') // eslint-disable-line | ||
const isNode = new Function('try {return this===global;}catch(e){return false;}') // eslint-disable-line | ||
if (isBrowser()) module.exports = require('./browser') | ||
if (isNode()) module.exports = require('./node') | ||
export default async () => { | ||
let module | ||
if (isBrowser()) { | ||
const m = await import('./browser.js') | ||
module = await m.default | ||
} else { | ||
const m = await import('./node.js') | ||
module = await m.default | ||
} | ||
return module | ||
} |
@@ -5,7 +5,10 @@ // const mongoUnit = require('mongo-unit') | ||
module.exports = [ | ||
import level from 'level' | ||
import memdown from 'memdown' | ||
export default [ | ||
{ | ||
key: 'leveldown', | ||
key: 'level', | ||
type: 'node', | ||
module: require('leveldown') | ||
module: level | ||
}, | ||
@@ -15,3 +18,3 @@ { | ||
type: 'node', | ||
module: require('memdown') | ||
module: memdown | ||
} | ||
@@ -18,0 +21,0 @@ // Disabling for now since it was breaking CI builds, but keep it available |
@@ -1,5 +0,6 @@ | ||
const assert = require('assert') | ||
import assert from 'assert' | ||
const Storage = require('../src') | ||
const implementations = require('./implementations') | ||
import Storage from '../src/index.js' | ||
import implementations from './implementations/index.js' | ||
const timeout = 2000 | ||
@@ -26,4 +27,4 @@ | ||
it('creates a level store if no storage is passed', async () => { | ||
assert.strictEqual(store.db.status, 'open') | ||
assert.strictEqual(store.db.location, './orbitdb') | ||
assert.strictEqual(store.status, 'open') | ||
assert.strictEqual(store.location, './orbitdb') | ||
}) | ||
@@ -56,3 +57,3 @@ | ||
implementations.forEach(implementation => { | ||
for (const implementation of await implementations()) { | ||
describe(`Storage Adapters - ${implementation.key}`, function () { | ||
@@ -84,4 +85,4 @@ this.timeout(timeout) | ||
store = await storage.createStore(location, implementation.defaultOptions || {}) | ||
assert.strictEqual(store.db.status, 'open') | ||
assert.strictEqual(store.db.location, location || './orbitdb') | ||
assert.strictEqual(store.status, 'open') | ||
assert.strictEqual(store.location, location || './orbitdb') | ||
}) | ||
@@ -91,4 +92,4 @@ | ||
store = await storage.createStore(location || './customDir') | ||
assert.strictEqual(store.db.status, 'open') | ||
assert.strictEqual(store.db.location, location || './customDir') | ||
assert.strictEqual(store.status, 'open') | ||
assert.strictEqual(store.location, location || './customDir') | ||
}) | ||
@@ -118,2 +119,2 @@ | ||
}) | ||
}) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
978807
3
16
42
1053
57
1
1
Yes
- Removedleveldown@^6.1.1
- Removedlevelup@^5.1.1
- Removeddeferred-leveldown@7.0.0(transitive)
- Removedlevel-errors@3.0.1(transitive)
- Removedlevel-iterator-stream@5.0.0(transitive)
- Removedleveldown@6.1.1(transitive)
- Removedlevelup@5.1.1(transitive)
- Removednapi-macros@2.0.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)