From 7fb5a0f10755042ddf9e21bb079750865833c77e Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Mon, 8 Jan 2024 11:23:23 +0200 Subject: [PATCH] update secret-stack to 8.1 --- lib/index.js | 23 ++--------------------- package.json | 2 +- tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3b8e72d..fae001a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -60,23 +60,10 @@ function fromSubdomain(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('"dict" plugin requires "db" plugin') -} - -/** - * @param {{ db: PPPPPDB | null, close: ClosableHook }} peer + * @param {{ db: PPPPPDB, close: ClosableHook }} peer * @param {Config} config */ function initDict(peer, config) { - assertDBPlugin(peer) - let ghostSpan = config.dict?.ghostSpan ?? 32 if (ghostSpan < 1) throw new Error('config.dict.ghostSpan must be >= 0') @@ -261,7 +248,6 @@ function initDict(peer, config) { * @returns {number} */ function _squeezePotential(subdomain) { - assertDBPlugin(peer) // prettier-ignore if (!loadedAccountID) throw new Error('Cannot squeeze potential before loading') // TODO: improve this so that the squeezePotential is the size of the @@ -286,7 +272,6 @@ function initDict(peer, config) { * @param {CB} cb */ function forceUpdate(subdomain, update, cb) { - assertDBPlugin(peer) if (!loadedAccountID) throw new Error('Cannot force update before loading') const domain = fromSubdomain(subdomain) @@ -315,7 +300,6 @@ function initDict(peer, config) { * @param {CB} cb */ function load(accountID, cb) { - assertDBPlugin(peer) if (accountID === loadedAccountID) { loaded(cb) return @@ -365,7 +349,6 @@ function initDict(peer, config) { * @returns {number} */ function minRequiredDepth(tangleID) { - assertDBPlugin(peer) const tangle = peer.db.getTangle(tangleID) // prettier-ignore @@ -414,7 +397,6 @@ function initDict(peer, config) { * @returns {{[field in string]: any} | null} */ function read(id, subdomain) { - assertDBPlugin(peer) const domain = fromSubdomain(subdomain) const mootID = MsgV4.getMootID(id, domain) const tangle = peer.db.getTangle(mootID) @@ -441,7 +423,6 @@ function initDict(peer, config) { */ function getFeedID(subdomain) { if (!loadedAccountID) throw new Error('Cannot getFeedID() before loading') - assertDBPlugin(peer) const domain = fromSubdomain(subdomain) return MsgV4.getMootID(loadedAccountID, domain) } @@ -454,7 +435,6 @@ function initDict(peer, config) { function isGhostable(ghostableMsgID, tangleID) { if (ghostableMsgID === tangleID) return false - assertDBPlugin(peer) const msg = peer.db.get(ghostableMsgID) // prettier-ignore @@ -554,4 +534,5 @@ function initDict(peer, config) { } exports.name = 'dict' +exports.needs = ['db'] exports.init = initDict diff --git a/package.json b/package.json index 98e6690..56ba8cb 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "ppppp-caps": "github:staltz/ppppp-caps", "ppppp-keypair": "github:staltz/ppppp-keypair", "rimraf": "^4.4.0", - "secret-stack": "~8.0.0", + "secret-stack": "~8.1.0", "secret-handshake-ext": "0.0.10", "ssb-box": "^1.0.1", "typescript": "^5.1.3" diff --git a/tsconfig.json b/tsconfig.json index bd2acd5..cc6e7af 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,6 @@ "module": "node16", "skipLibCheck": true, "strict": true, - "target": "es2021" + "target": "es2022" } } \ No newline at end of file