update secret-stack to 8.1

This commit is contained in:
Andre Staltz 2024-01-08 11:23:23 +02:00
parent 32a51697e4
commit 7fb5a0f107
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
3 changed files with 4 additions and 23 deletions

View File

@ -60,23 +60,10 @@ function fromSubdomain(subdomain) {
} }
/** /**
* @param {{ * @param {{ db: PPPPPDB, close: ClosableHook }} peer
* db: PPPPPDB | null,
* close: ClosableHook,
* }} peer
* @returns {asserts peer is { db: PPPPPDB, close: ClosableHook }}
*/
function assertDBPlugin(peer) {
if (!peer.db) throw new Error('"dict" plugin requires "db" plugin')
}
/**
* @param {{ db: PPPPPDB | null, close: ClosableHook }} peer
* @param {Config} config * @param {Config} config
*/ */
function initDict(peer, config) { function initDict(peer, config) {
assertDBPlugin(peer)
let ghostSpan = config.dict?.ghostSpan ?? 32 let ghostSpan = config.dict?.ghostSpan ?? 32
if (ghostSpan < 1) throw new Error('config.dict.ghostSpan must be >= 0') if (ghostSpan < 1) throw new Error('config.dict.ghostSpan must be >= 0')
@ -261,7 +248,6 @@ function initDict(peer, config) {
* @returns {number} * @returns {number}
*/ */
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
@ -286,7 +272,6 @@ function initDict(peer, config) {
* @param {CB<boolean>} cb * @param {CB<boolean>} cb
*/ */
function forceUpdate(subdomain, update, cb) { function forceUpdate(subdomain, update, cb) {
assertDBPlugin(peer)
if (!loadedAccountID) throw new Error('Cannot force update before loading') if (!loadedAccountID) throw new Error('Cannot force update before loading')
const domain = fromSubdomain(subdomain) const domain = fromSubdomain(subdomain)
@ -315,7 +300,6 @@ function initDict(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
@ -365,7 +349,6 @@ function initDict(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
@ -414,7 +397,6 @@ function initDict(peer, config) {
* @returns {{[field in string]: any} | null} * @returns {{[field in string]: any} | null}
*/ */
function read(id, subdomain) { function read(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)
@ -441,7 +423,6 @@ function initDict(peer, config) {
*/ */
function getFeedID(subdomain) { function getFeedID(subdomain) {
if (!loadedAccountID) throw new Error('Cannot getFeedID() before loading') if (!loadedAccountID) throw new Error('Cannot getFeedID() before loading')
assertDBPlugin(peer)
const domain = fromSubdomain(subdomain) const domain = fromSubdomain(subdomain)
return MsgV4.getMootID(loadedAccountID, domain) return MsgV4.getMootID(loadedAccountID, domain)
} }
@ -454,7 +435,6 @@ function initDict(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
@ -554,4 +534,5 @@ function initDict(peer, config) {
} }
exports.name = 'dict' exports.name = 'dict'
exports.needs = ['db']
exports.init = initDict exports.init = initDict

View File

@ -33,7 +33,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"

View File

@ -11,6 +11,6 @@
"module": "node16", "module": "node16",
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"target": "es2021" "target": "es2022"
} }
} }