cabal-core
Advanced tools
Comparing version 11.2.0 to 11.2.1
@@ -55,4 +55,4 @@ var kappa = require('kappa-core') | ||
this.maxFeeds = opts.maxFeeds | ||
this.modKeys = [] | ||
this.adminKeys = [] | ||
this.modKeys = opts.modKeys || [] | ||
this.adminKeys = opts.adminKeys || [] | ||
@@ -63,6 +63,3 @@ if (!key) this.key = generateKeyHex() | ||
if (!key.startsWith('cabal://')) key = 'cabal://' + key | ||
const uri = new URL(key) | ||
this.key = sanitizeKey(key) | ||
this.modKeys = uri.searchParams.getAll('mod') | ||
this.adminKeys = uri.searchParams.getAll('admin') | ||
} | ||
@@ -98,3 +95,3 @@ if (!isHypercoreKey(this.key)) throw new Error('invalid cabal key') | ||
sublevel(this.db, USERS, { valueEncoding: json }))) | ||
this.kcore.use('moderation', createModerationView( | ||
this.kcore.use('moderation', 2, createModerationView( | ||
this, | ||
@@ -101,0 +98,0 @@ sublevel(this.db, MODERATION_AUTH, { valueEncoding: json }), |
{ | ||
"name": "cabal-core", | ||
"version": "11.2.0", | ||
"version": "11.2.1", | ||
"description": " p2p db functions for chat ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
var mauth = require('materialized-group-auth') | ||
var Writable = require('readable-stream').Writable | ||
var sub = require('subleveldown') | ||
@@ -53,3 +54,3 @@ var EventEmitter = require('events').EventEmitter | ||
if (flags.includes('admin') && row.key === undefined && | ||
cabal.adminKeys.includes(row.id) && row.id !== key) { | ||
!cabal.adminKeys.includes(row.id) && row.id !== key) { | ||
batch.push({ | ||
@@ -68,3 +69,3 @@ type: 'remove', | ||
if (flags.includes('mod') && row.key === undefined && | ||
cabal.modKeys.includes(row.id) && row.id !== key) { | ||
!cabal.modKeys.includes(row.id) && row.id !== key) { | ||
batch.push({ | ||
@@ -155,3 +156,2 @@ type: 'remove', | ||
} | ||
var r = auth.list(opts) | ||
var out = through.obj(function (row, enc, next) { | ||
@@ -162,3 +162,6 @@ row.channel = row.group | ||
}) | ||
pump(r, out) | ||
this.ready(function () { | ||
var r = auth.list(opts) | ||
pump(r, out) | ||
}) | ||
var ro = readonly(out) | ||
@@ -194,2 +197,57 @@ if (cb) collect(ro, cb) | ||
}, | ||
}, | ||
// view lifecycle | ||
storeState: function (state, cb) { | ||
state = state.toString('base64') | ||
authDb.put('state', state, cb) | ||
}, | ||
fetchState: function (cb) { | ||
authDb.get('state', function (err, state) { | ||
if (err && err.notFound) cb() | ||
else if (err) cb(err) | ||
else cb(null, Buffer.from(state, 'base64')) | ||
}) | ||
}, | ||
clearIndex: function (cb) { | ||
var batch = [] | ||
var maxSize = 5000 | ||
let pending = 2 | ||
infoDb.open(function () { | ||
pump(infoDb.createKeyStream(), new Writable({ | ||
objectMode: true, | ||
write: function (key, enc, next) { | ||
batch.push({ type: 'del', key }) | ||
if (batch.length >= maxSize) { | ||
infoDb.batch(batch, next) | ||
} else next() | ||
}, | ||
final: function (next) { | ||
if (batch.length > 0) infoDb.batch(batch, next) | ||
else next() | ||
} | ||
}), ondone) | ||
}) | ||
authDb.open(function () { | ||
pump(authDb.createKeyStream(), new Writable({ | ||
objectMode: true, | ||
write: function (key, enc, next) { | ||
batch.push({ type: 'del', key }) | ||
if (batch.length >= maxSize) { | ||
authDb.batch(batch, next) | ||
} else next() | ||
}, | ||
final: function (next) { | ||
if (batch.length > 0) authDb.batch(batch, next) | ||
else next() | ||
} | ||
}), ondone) | ||
}) | ||
function ondone (err) { | ||
if (--pending) return | ||
if (err) cb(err) | ||
else cb() | ||
} | ||
} | ||
@@ -196,0 +254,0 @@ } |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
79396
1115
1