mirror of https://codeberg.org/pzp/pzp-set.git
update secret-stack to 8.1
This commit is contained in:
parent
c1117ca0be
commit
d637be5195
25
lib/index.js
25
lib/index.js
|
@ -63,17 +63,6 @@ function fromSubdomain(subdomain) {
|
||||||
return PREFIX + subdomain
|
return PREFIX + subdomain
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {{
|
|
||||||
* db: PPPPPDB | null,
|
|
||||||
* close: ClosableHook,
|
|
||||||
* }} peer
|
|
||||||
* @returns {asserts peer is { db: PPPPPDB, close: ClosableHook }}
|
|
||||||
*/
|
|
||||||
function assertDBPlugin(peer) {
|
|
||||||
if (!peer.db) throw new Error('"set" plugin requires "db" plugin')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {unknown} check
|
* @param {unknown} check
|
||||||
* @param {string} message
|
* @param {string} message
|
||||||
|
@ -84,12 +73,10 @@ function assert(check, message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{ db: PPPPPDB | null, close: ClosableHook }} peer
|
* @param {{ db: PPPPPDB, close: ClosableHook }} peer
|
||||||
* @param {Config} config
|
* @param {Config} config
|
||||||
*/
|
*/
|
||||||
function initSet(peer, config) {
|
function initSet(peer, config) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
|
|
||||||
let ghostSpan = config.set?.ghostSpan ?? 32
|
let ghostSpan = config.set?.ghostSpan ?? 32
|
||||||
if (ghostSpan < 1) throw new Error('config.set.ghostSpan must be >= 0')
|
if (ghostSpan < 1) throw new Error('config.set.ghostSpan must be >= 0')
|
||||||
|
|
||||||
|
@ -205,7 +192,6 @@ function initSet(peer, config) {
|
||||||
* @param {string} subdomain
|
* @param {string} subdomain
|
||||||
*/
|
*/
|
||||||
function readSet(id, subdomain) {
|
function readSet(id, subdomain) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
const domain = fromSubdomain(subdomain)
|
const domain = fromSubdomain(subdomain)
|
||||||
const mootID = MsgV4.getMootID(id, domain)
|
const mootID = MsgV4.getMootID(id, domain)
|
||||||
const tangle = peer.db.getTangle(mootID)
|
const tangle = peer.db.getTangle(mootID)
|
||||||
|
@ -293,7 +279,6 @@ function initSet(peer, config) {
|
||||||
* @param {string} subdomain
|
* @param {string} subdomain
|
||||||
*/
|
*/
|
||||||
function _squeezePotential(subdomain) {
|
function _squeezePotential(subdomain) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
if (!loadedAccountID) throw new Error('Cannot squeeze potential before loading')
|
if (!loadedAccountID) throw new Error('Cannot squeeze potential before loading')
|
||||||
// TODO: improve this so that the squeezePotential is the size of the
|
// TODO: improve this so that the squeezePotential is the size of the
|
||||||
|
@ -319,7 +304,6 @@ function initSet(peer, config) {
|
||||||
* @param {CB<void>} cb
|
* @param {CB<void>} cb
|
||||||
*/
|
*/
|
||||||
function load(accountID, cb) {
|
function load(accountID, cb) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
if (accountID === loadedAccountID) {
|
if (accountID === loadedAccountID) {
|
||||||
loaded(cb)
|
loaded(cb)
|
||||||
return
|
return
|
||||||
|
@ -360,7 +344,6 @@ function initSet(peer, config) {
|
||||||
* @param {CB<boolean>} cb
|
* @param {CB<boolean>} cb
|
||||||
*/
|
*/
|
||||||
function add(subdomain, value, cb) {
|
function add(subdomain, value, cb) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
// TODO this error needs to be put into the `cb`, not thrown
|
// TODO this error needs to be put into the `cb`, not thrown
|
||||||
assert(!!loadedAccountID, 'Cannot add to Set before loading')
|
assert(!!loadedAccountID, 'Cannot add to Set before loading')
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -411,7 +394,6 @@ function initSet(peer, config) {
|
||||||
* @param {CB<boolean>} cb
|
* @param {CB<boolean>} cb
|
||||||
*/
|
*/
|
||||||
function del(subdomain, value, cb) {
|
function del(subdomain, value, cb) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
// TODO this error needs to be put into the `cb`, not thrown
|
// TODO this error needs to be put into the `cb`, not thrown
|
||||||
assert(!!loadedAccountID, 'Cannot add to Set before loading')
|
assert(!!loadedAccountID, 'Cannot add to Set before loading')
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -483,7 +465,6 @@ function initSet(peer, config) {
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
function minRequiredDepth(tangleID) {
|
function minRequiredDepth(tangleID) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
const tangle = peer.db.getTangle(tangleID)
|
const tangle = peer.db.getTangle(tangleID)
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -523,7 +504,6 @@ function initSet(peer, config) {
|
||||||
*/
|
*/
|
||||||
function getFeedID(subdomain) {
|
function getFeedID(subdomain) {
|
||||||
assert(!!loadedAccountID, 'Cannot getFeedID() before loading')
|
assert(!!loadedAccountID, 'Cannot getFeedID() before loading')
|
||||||
assertDBPlugin(peer)
|
|
||||||
const domain = fromSubdomain(subdomain)
|
const domain = fromSubdomain(subdomain)
|
||||||
return MsgV4.getMootID(loadedAccountID, domain)
|
return MsgV4.getMootID(loadedAccountID, domain)
|
||||||
}
|
}
|
||||||
|
@ -536,7 +516,6 @@ function initSet(peer, config) {
|
||||||
function isGhostable(ghostableMsgID, tangleID) {
|
function isGhostable(ghostableMsgID, tangleID) {
|
||||||
if (ghostableMsgID === tangleID) return false
|
if (ghostableMsgID === tangleID) return false
|
||||||
|
|
||||||
assertDBPlugin(peer)
|
|
||||||
const msg = peer.db.get(ghostableMsgID)
|
const msg = peer.db.get(ghostableMsgID)
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
@ -578,7 +557,6 @@ function initSet(peer, config) {
|
||||||
* @param {CB<boolean>} cb
|
* @param {CB<boolean>} cb
|
||||||
*/
|
*/
|
||||||
function squeeze(subdomain, cb) {
|
function squeeze(subdomain, cb) {
|
||||||
assertDBPlugin(peer)
|
|
||||||
// TODO this error needs to be put into the `cb`, not thrown
|
// TODO this error needs to be put into the `cb`, not thrown
|
||||||
assert(!!loadedAccountID, 'Cannot squeeze Set before loading')
|
assert(!!loadedAccountID, 'Cannot squeeze Set before loading')
|
||||||
|
|
||||||
|
@ -633,4 +611,5 @@ function initSet(peer, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.name = 'set'
|
exports.name = 'set'
|
||||||
|
exports.needs = ['db']
|
||||||
exports.init = initSet
|
exports.init = initSet
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
"ppppp-caps": "github:staltz/ppppp-caps",
|
"ppppp-caps": "github:staltz/ppppp-caps",
|
||||||
"ppppp-keypair": "github:staltz/ppppp-keypair",
|
"ppppp-keypair": "github:staltz/ppppp-keypair",
|
||||||
"rimraf": "^4.4.0",
|
"rimraf": "^4.4.0",
|
||||||
"secret-stack": "~8.0.0",
|
"secret-stack": "~8.1.0",
|
||||||
"secret-handshake-ext": "0.0.10",
|
"secret-handshake-ext": "0.0.10",
|
||||||
"ssb-box": "^1.0.1",
|
"ssb-box": "^1.0.1",
|
||||||
"typescript": "^5.1.3"
|
"typescript": "^5.1.3"
|
||||||
|
|
|
@ -11,6 +11,6 @@
|
||||||
"module": "node16",
|
"module": "node16",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"target": "es2021"
|
"target": "es2022"
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue