Rename to pzp (#4)

For https://codeberg.org/pzp/pzp-sdk/issues/1

Reviewed-on: https://codeberg.org/pzp/pzp-db/pulls/4
Co-authored-by: Jacob Karlsson <jacob.karlsson95@gmail.com>
Co-committed-by: Jacob Karlsson <jacob.karlsson95@gmail.com>
This commit is contained in:
Jacob Karlsson 2024-04-27 21:47:50 +00:00 committed by Powersource
parent f93082f38d
commit 8e6128f238
38 changed files with 97 additions and 88 deletions

View File

@ -1,19 +1,18 @@
# ppppp-db # pzp-db
The message database for ppppp. The message database for PZP.
## Installation ## Installation
We're not on npm yet. In your package.json, include this as
```js ```
"ppppp-db": "github:staltz/ppppp-db" npm install pzp-db
``` ```
## Usage ## Usage
It's a secret-stack plugin much like ssb-db2. Other than that, you can also use It's a secret-stack plugin much like ssb-db2. Other than that, you can also use
the feed format `const FeedV1 = require('ppppp-db/feed-v1')`. the feed format `const FeedV1 = require('pzp-db/feed-v1')`.
You can use it like You can use it like
@ -21,15 +20,15 @@ You can use it like
const p = require('node:util').promisify const p = require('node:util').promisify
const keypair = Keypair.generate('ed25519', 'alice') const keypair = Keypair.generate('ed25519', 'alice')
const DIR = path.join(os.tmpdir(), 'ppppp-db-temp') const DIR = path.join(os.tmpdir(), 'pzp-db-temp')
const pzp = require('secret-stack/bare')() const pzp = require('secret-stack/bare')()
.use(require('secret-stack/plugins/net')) .use(require('secret-stack/plugins/net'))
.use(require('secret-handshake-ext/secret-stack')) .use(require('secret-handshake-ext/secret-stack'))
.use(require('ppppp-db')) .use(require('pzp-db'))
.use(require('ssb-box')) .use(require('ssb-box'))
.call(null, { .call(null, {
shse: { caps: require('ppppp-caps') shse: { caps: require('pzp-caps')
}, },
global: { global: {
keypair, keypair,

View File

@ -7,7 +7,7 @@ const MsgV4 = require('./msg-v4')
* @typedef {import('./index').RecPresent} RecPresent * @typedef {import('./index').RecPresent} RecPresent
* @typedef {import('./index').Rec} Rec * @typedef {import('./index').Rec} Rec
* @typedef {import('./index').Misc} Misc * @typedef {import('./index').Misc} Misc
* @typedef {import('ppppp-keypair').Keypair} Keypair * @typedef {import('pzp-keypair').Keypair} Keypair
* *
* @typedef {Buffer | Uint8Array} B4A * @typedef {Buffer | Uint8Array} B4A
* *

View File

@ -3,7 +3,7 @@ const promisify = require('promisify-4loc')
const b4a = require('b4a') const b4a = require('b4a')
const base58 = require('bs58') const base58 = require('bs58')
const Obz = require('obz') const Obz = require('obz')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const pull = require('pull-stream') const pull = require('pull-stream')
const p = require('node:util').promisify const p = require('node:util').promisify
const Log = require('./log') const Log = require('./log')
@ -19,9 +19,9 @@ const Ghosts = require('./ghosts')
const { decrypt } = require('./encryption') const { decrypt } = require('./encryption')
/** /**
* @typedef {import('ppppp-keypair').Keypair} Keypair * @typedef {import('pzp-keypair').Keypair} Keypair
* @typedef {import('ppppp-keypair').KeypairPublicSlice} KeypairPublicSlice * @typedef {import('pzp-keypair').KeypairPublicSlice} KeypairPublicSlice
* @typedef {import('ppppp-keypair').KeypairPrivateSlice} KeypairPrivateSlice * @typedef {import('pzp-keypair').KeypairPrivateSlice} KeypairPrivateSlice
* @typedef {string} MsgID * @typedef {string} MsgID
* @typedef {import('./msg-v4').Msg} Msg * @typedef {import('./msg-v4').Msg} Msg
* @typedef {import('./msg-v4').AccountData} AccountData * @typedef {import('./msg-v4').AccountData} AccountData
@ -1237,7 +1237,7 @@ function initDB(peer, config) {
...fullOpts, ...fullOpts,
recps: recps.map( recps: recps.map(
(recp) => (recp) =>
// TODO: temporary until our encryption formats are ppppp not SSB // TODO: temporary until our encryption formats are pzp not SSB
`@${b4a.from(base58.decode(recp)).toString('base64')}.ed25519` `@${b4a.from(base58.decode(recp)).toString('base64')}.ed25519`
), ),
} }
@ -1309,7 +1309,7 @@ function initDB(peer, config) {
// TODO: improve performance of this when getting many messages, the arg // TODO: improve performance of this when getting many messages, the arg
// could be an array of hashes, so we can do a single pass over the records. // could be an array of hashes, so we can do a single pass over the records.
rescanning.onDone(() => { rescanning.onDone(() => {
const isUri = msgID.startsWith('ppppp:') const isUri = msgID.startsWith('pzp:')
for (let i = 0; i < recs.length; i++) { for (let i = 0; i < recs.length; i++) {
const rec = recs[i] const rec = recs[i]
if (!rec) continue if (!rec) continue

View File

@ -8,7 +8,7 @@ const Cache = require('@alloc/quick-lru') // @ts-ignore
const RAF = require('polyraf') // @ts-ignore const RAF = require('polyraf') // @ts-ignore
const debounce = require('lodash.debounce') // @ts-ignore const debounce = require('lodash.debounce') // @ts-ignore
const isBufferZero = require('is-buffer-zero') // @ts-ignore const isBufferZero = require('is-buffer-zero') // @ts-ignore
const debug = require('debug')('ppppp-db:log') const debug = require('debug')('pzp-db:log')
const { const {
deletedRecordErr, deletedRecordErr,

View File

@ -25,7 +25,7 @@ function getMsgHashBuf(msg) {
*/ */
function getMsgID(x) { function getMsgID(x) {
if (typeof x === 'string') { if (typeof x === 'string') {
if (x.startsWith('ppppp:message/v4/')) { if (x.startsWith('pzp:message/v4/')) {
const msgUri = x const msgUri = x
const parts = msgUri.split('/') const parts = msgUri.split('/')
return parts[parts.length - 1] return parts[parts.length - 1]
@ -48,9 +48,9 @@ function getMsgURI(msg) {
const { account, domain } = msg.metadata const { account, domain } = msg.metadata
const msgHash = getMsgID(msg) const msgHash = getMsgID(msg)
if (domain) { if (domain) {
return `ppppp:message/v4/${account}/${domain}/${msgHash}` return `pzp:message/v4/${account}/${domain}/${msgHash}`
} else { } else {
return `ppppp:message/v4/${account}/${msgHash}` return `pzp:message/v4/${account}/${msgHash}`
} }
} }

View File

@ -3,7 +3,7 @@ const base58 = require('bs58')
const b4a = require('b4a') const b4a = require('b4a')
// @ts-ignore // @ts-ignore
const stringify = require('json-canon') const stringify = require('json-canon')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
// @ts-ignore // @ts-ignore
const union = require('set.prototype.union') const union = require('set.prototype.union')
const { stripAccount } = require('./strip') const { stripAccount } = require('./strip')
@ -26,7 +26,7 @@ const {
const { isEmptyObject } = require('./util') const { isEmptyObject } = require('./util')
/** /**
* @typedef {import('ppppp-keypair').Keypair} Keypair * @typedef {import('pzp-keypair').Keypair} Keypair
*/ */
/** /**

View File

@ -7,8 +7,8 @@
* @returns {string} * @returns {string}
*/ */
function stripAccount(accountId) { function stripAccount(accountId) {
if (accountId.startsWith('ppppp:account/v4/') === false) return accountId if (accountId.startsWith('pzp:account/v4/') === false) return accountId
const withoutPrefix = accountId.replace('ppppp:account/v4/', '') const withoutPrefix = accountId.replace('pzp:account/v4/', '')
return withoutPrefix.split('/')[0] return withoutPrefix.split('/')[0]
} }

View File

@ -1,6 +1,6 @@
const b4a = require('b4a') const b4a = require('b4a')
const base58 = require('bs58') const base58 = require('bs58')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
// @ts-ignore // @ts-ignore
const stringify = require('json-canon') const stringify = require('json-canon')
const Tangle = require('./tangle') const Tangle = require('./tangle')
@ -55,6 +55,7 @@ function validateShape(msg) {
if (typeof msg.sig !== 'string') { if (typeof msg.sig !== 'string') {
return 'invalid msg: must have sig\n' + JSON.stringify(msg) return 'invalid msg: must have sig\n' + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -77,6 +78,7 @@ function validateSigkey(msg) {
// prettier-ignore // prettier-ignore
return `invalid msg: sigkey "${sigkey}" should have been a base58 string\n` + JSON.stringify(msg) return `invalid msg: sigkey "${sigkey}" should have been a base58 string\n` + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -106,6 +108,7 @@ function validateSigkeyAndAccount(msg, tangle, sigkeys) {
return `invalid msg: accountTips "${msg.metadata.accountTips}" should have been null in an account tangle\n` + JSON.stringify(msg) return `invalid msg: accountTips "${msg.metadata.accountTips}" should have been null in an account tangle\n` + JSON.stringify(msg)
} }
} }
return undefined
} }
/** /**
@ -122,6 +125,7 @@ function validateMsgID(str) {
} catch (err) { } catch (err) {
return `invalid msgID "${str}": should have been a base58 string` return `invalid msgID "${str}": should have been a base58 string`
} }
return undefined
} }
/** /**
@ -158,6 +162,7 @@ function validateSignature(msg) {
if (!verified) { if (!verified) {
return 'invalid msg: sig is invalid\n' + JSON.stringify(msg) return 'invalid msg: sig is invalid\n' + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -203,7 +208,7 @@ function validateTangle(msg, tangle, tangleID) {
// prettier-ignore // prettier-ignore
return `invalid msg: prev item "${p}" should have been a string\n` + JSON.stringify(msg) return `invalid msg: prev item "${p}" should have been a string\n` + JSON.stringify(msg)
} }
if (p.startsWith('ppppp:')) { if (p.startsWith('pzp:')) {
// prettier-ignore // prettier-ignore
return `invalid msg: prev item "${p}" is a URI, but should have been a hash\n` + JSON.stringify(msg) return `invalid msg: prev item "${p}" is a URI, but should have been a hash\n` + JSON.stringify(msg)
} }
@ -241,6 +246,7 @@ function validateTangle(msg, tangle, tangleID) {
// prettier-ignore // prettier-ignore
return `invalid msg: depth must be the largest prev depth plus one\n` + JSON.stringify(msg) return `invalid msg: depth must be the largest prev depth plus one\n` + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -257,6 +263,7 @@ function validateTangleRoot(msg, msgID, tangleID) {
// prettier-ignore // prettier-ignore
return `invalid msg: tangle root "${tangleID}" must not have self tangle data\n` + JSON.stringify(msg) return `invalid msg: tangle root "${tangleID}" must not have self tangle data\n` + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -277,6 +284,7 @@ function validateDomain(domain) {
// prettier-ignore // prettier-ignore
return `invalid domain: "${domain}" contains characters other than a-z, A-Z, 0-9, or _` return `invalid domain: "${domain}" contains characters other than a-z, A-Z, 0-9, or _`
} }
return undefined
} }
/** /**
@ -295,6 +303,7 @@ function validateData(msg) {
// prettier-ignore // prettier-ignore
return `invalid msg: data "${data}" must be an object or a string` + JSON.stringify(msg) return `invalid msg: data "${data}" must be an object or a string` + JSON.stringify(msg)
} }
return undefined
} }
/** /**
@ -317,6 +326,7 @@ function validateDataSizeHash(msg) {
// prettier-ignore // prettier-ignore
return `invalid msg: metadata.dataSize ${actualSize} should have been "${expectedSize}"\n` + JSON.stringify(msg) return `invalid msg: metadata.dataSize ${actualSize} should have been "${expectedSize}"\n` + JSON.stringify(msg)
} }
return undefined
} }
/** /**

View File

@ -1,11 +1,11 @@
{ {
"name": "ppppp-db", "name": "pzp-db",
"version": "0.0.1", "version": "1.0.1",
"description": "Default ppppp database", "description": "Default PZP database",
"homepage": "https://github.com/staltz/ppppp-db", "homepage": "https://codeberg.org/pzp/pzp-db",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@github.com:staltz/ppppp-db.git" "url": "git@codeberg.org:pzp/pzp-db.git"
}, },
"author": "Andre Staltz <contact@staltz.com>", "author": "Andre Staltz <contact@staltz.com>",
"license": "MIT", "license": "MIT",
@ -40,7 +40,7 @@
"mutexify": "~1.4.0", "mutexify": "~1.4.0",
"obz": "~1.1.0", "obz": "~1.1.0",
"polyraf": "^1.1.0", "polyraf": "^1.1.0",
"ppppp-keypair": "github:staltz/ppppp-keypair#61ef4420578f450dc2cc7b1efc1c5a691a871c74", "pzp-keypair": "^1.0.0",
"promisify-4loc": "~1.0.0", "promisify-4loc": "~1.0.0",
"promisify-tuple": "~1.2.0", "promisify-tuple": "~1.2.0",
"pull-stream": "^3.7.0", "pull-stream": "^3.7.0",
@ -53,7 +53,7 @@
"c8": "^7.11.0", "c8": "^7.11.0",
"flumecodec": "~0.0.1", "flumecodec": "~0.0.1",
"husky": "^4.3.0", "husky": "^4.3.0",
"ppppp-caps": "github:staltz/ppppp-caps#93fa810b9a40b78aef4872d4c2a8412cccb52929", "pzp-caps": "^1.0.0",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"pretty-quick": "^3.1.3", "pretty-quick": "^3.1.3",
"rimraf": "^4.4.0", "rimraf": "^4.4.0",

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const p = require('node:util').promisify const p = require('node:util').promisify
const os = require('node:os') const os = require('node:os')
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const DIR = path.join(os.tmpdir(), 'ppppp-db-account-add') const DIR = path.join(os.tmpdir(), 'pzp-db-account-add')
rimraf.sync(DIR) rimraf.sync(DIR)
test('account.add()', async (t) => { test('account.add()', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-account-create') const DIR = path.join(os.tmpdir(), 'pzp-db-account-create')
rimraf.sync(DIR) rimraf.sync(DIR)
test('account.create() ', async (t) => { test('account.create() ', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-add') const DIR = path.join(os.tmpdir(), 'pzp-db-add')
rimraf.sync(DIR) rimraf.sync(DIR)
test('add()', async (t) => { test('add()', async (t) => {

View File

@ -5,10 +5,10 @@ const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Log = require('../lib/log') const Log = require('../lib/log')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-del') const DIR = path.join(os.tmpdir(), 'pzp-db-del')
rimraf.sync(DIR) rimraf.sync(DIR)
test('del()', async (t) => { test('del()', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const Log = require('../lib/log') const Log = require('../lib/log')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-erase') const DIR = path.join(os.tmpdir(), 'pzp-db-erase')
rimraf.sync(DIR) rimraf.sync(DIR)
test('erase()', async (t) => { test('erase()', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-find-moot') const DIR = path.join(os.tmpdir(), 'pzp-db-feed-find-moot')
rimraf.sync(DIR) rimraf.sync(DIR)
test('feed.findMoot()', async (t) => { test('feed.findMoot()', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-get-id') const DIR = path.join(os.tmpdir(), 'pzp-db-feed-get-id')
rimraf.sync(DIR) rimraf.sync(DIR)
test('feed.getID()', async (t) => { test('feed.getID()', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-feed-publish') const DIR = path.join(os.tmpdir(), 'pzp-db-feed-publish')
rimraf.sync(DIR) rimraf.sync(DIR)
test('feed.publish()', async (t) => { test('feed.publish()', async (t) => {

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-get') const DIR = path.join(os.tmpdir(), 'pzp-db-get')
rimraf.sync(DIR) rimraf.sync(DIR)
test('get()', async (t) => { test('get()', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-tangle') const DIR = path.join(os.tmpdir(), 'pzp-db-tangle')
rimraf.sync(DIR) rimraf.sync(DIR)
/** /**

View File

@ -4,11 +4,11 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const DIR = path.join(os.tmpdir(), 'ppppp-db-ghosts') const DIR = path.join(os.tmpdir(), 'pzp-db-ghosts')
rimraf.sync(DIR) rimraf.sync(DIR)
const keypair = Keypair.generate('ed25519', 'alice') const keypair = Keypair.generate('ed25519', 'alice')

View File

@ -6,7 +6,7 @@ const Log = require('../../lib/log')
test('Log basics', async function (t) { test('Log basics', async function (t) {
await t.test('Log handles basic binary records', async function (t) { await t.test('Log handles basic binary records', async function (t) {
const file = '/tmp/ppppp-db-log-test-basic-binary.log' const file = '/tmp/pzp-db-log-test-basic-binary.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}
@ -34,7 +34,7 @@ test('Log basics', async function (t) {
const json2 = { test: 'testing2' } const json2 = { test: 'testing2' }
await t.test('Log handles basic json records', async function (t) { await t.test('Log handles basic json records', async function (t) {
const file = '/tmp/ppppp-db-log-test-basic-json.log' const file = '/tmp/pzp-db-log-test-basic-json.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}
@ -59,7 +59,7 @@ test('Log basics', async function (t) {
}) })
await t.test('Log handles basic json record re-reading', async function (t) { await t.test('Log handles basic json record re-reading', async function (t) {
const file = '/tmp/ppppp-db-log-test-basic-json.log' const file = '/tmp/pzp-db-log-test-basic-json.log'
const log = Log(file, { const log = Log(file, {
blockSize: 2 * 1024, blockSize: 2 * 1024,
codec: require('flumecodec/json'), codec: require('flumecodec/json'),

View File

@ -5,7 +5,7 @@ const Log = require('../../lib/log')
test('Log compaction', async (t) => { test('Log compaction', async (t) => {
await t.test('compact a log that does not have holes', async (t) => { await t.test('compact a log that does not have holes', async (t) => {
const file = '/tmp/ppppp-db-log-compaction-test-' + Date.now() + '.log' const file = '/tmp/pzp-db-log-compaction-test-' + Date.now() + '.log'
const log = Log(file, { blockSize: 15 }) const log = Log(file, { blockSize: 15 })
const stats = await p(log.stats)() const stats = await p(log.stats)()
@ -62,7 +62,7 @@ test('Log compaction', async (t) => {
}) })
await t.test('delete first record, compact, stream', async (t) => { await t.test('delete first record, compact, stream', async (t) => {
const file = '/tmp/ppppp-db-log-compaction-test-' + Date.now() + '.log' const file = '/tmp/pzp-db-log-compaction-test-' + Date.now() + '.log'
const log = Log(file, { blockSize: 15 }) const log = Log(file, { blockSize: 15 })
const buf1 = Buffer.from('first') const buf1 = Buffer.from('first')
@ -119,7 +119,7 @@ test('Log compaction', async (t) => {
}) })
await t.test('delete last record, compact, stream', async (t) => { await t.test('delete last record, compact, stream', async (t) => {
const file = '/tmp/ppppp-db-log-compaction-test-' + Date.now() + '.log' const file = '/tmp/pzp-db-log-compaction-test-' + Date.now() + '.log'
const log = Log(file, { blockSize: 15 }) const log = Log(file, { blockSize: 15 })
const buf1 = Buffer.from('first') const buf1 = Buffer.from('first')

View File

@ -15,7 +15,7 @@ function decode(buf) {
} }
test('Log handles corrupted records', async (t) => { test('Log handles corrupted records', async (t) => {
const file = '/tmp/ppppp-db-log-corrupt-records.log' const file = '/tmp/pzp-db-log-corrupt-records.log'
await t.test('Simulate corruption', async (t) => { await t.test('Simulate corruption', async (t) => {
try { try {
@ -93,7 +93,7 @@ test('Log handles corrupted records', async (t) => {
}) })
test('Log handles corrupted length', async (t) => { test('Log handles corrupted length', async (t) => {
const file = '/tmp/ppppp-db-log-corrupt-length.log' const file = '/tmp/pzp-db-log-corrupt-length.log'
await t.test('Simulate length corruption', async (t) => { await t.test('Simulate length corruption', async (t) => {
try { try {

View File

@ -16,7 +16,7 @@ const msg3 = Buffer.from(
test('Log deletes', async (t) => { test('Log deletes', async (t) => {
await t.test('Simple delete', async (t) => { await t.test('Simple delete', async (t) => {
const file = '/tmp/ppppp-db-log-test-del.log' const file = '/tmp/pzp-db-log-test-del.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}
@ -49,7 +49,7 @@ test('Log deletes', async (t) => {
}) })
await t.test('Deleted records are not invalid upon re-opening', async (t) => { await t.test('Deleted records are not invalid upon re-opening', async (t) => {
const file = '/tmp/ppppp-db-log-test-del-invalid.log' const file = '/tmp/pzp-db-log-test-del-invalid.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}

View File

@ -9,7 +9,7 @@ const msg2 = Buffer.from('ola mundo ola mundo ola mundo')
test('Log overwrites', async (t) => { test('Log overwrites', async (t) => {
await t.test('Simple overwrite', async (t) => { await t.test('Simple overwrite', async (t) => {
const file = '/tmp/ppppp-db-log-test-overwrite.log' const file = '/tmp/pzp-db-log-test-overwrite.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}
@ -49,7 +49,7 @@ test('Log overwrites', async (t) => {
}) })
await t.test('Cannot overwrite larger data', async (t) => { await t.test('Cannot overwrite larger data', async (t) => {
const file = '/tmp/ppppp-db-log-test-overwrite-larger.log' const file = '/tmp/pzp-db-log-test-overwrite-larger.log'
try { try {
fs.unlinkSync(file) fs.unlinkSync(file)
} catch (_) {} } catch (_) {}

View File

@ -1,6 +1,6 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
let account let account

View File

@ -1,6 +1,6 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
test('MsgV4 domain validation', async (t) => { test('MsgV4 domain validation', async (t) => {

View File

@ -1,7 +1,7 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const base58 = require('bs58') const base58 = require('bs58')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
const keypair = Keypair.generate('ed25519', 'alice') const keypair = Keypair.generate('ed25519', 'alice')
@ -121,7 +121,7 @@ test('MsgV4 tangles prev validation', async (t) => {
}) })
const msgID2 = MsgV4.getMsgID(msg2) const msgID2 = MsgV4.getMsgID(msg2)
const randBuf = Buffer.alloc(16).fill(16) const randBuf = Buffer.alloc(16).fill(16)
const fakeMsgKey1 = `ppppp:message/v4/${base58.encode(randBuf)}` const fakeMsgKey1 = `pzp:message/v4/${base58.encode(randBuf)}`
msg2.metadata.tangles[mootID].depth = 1 msg2.metadata.tangles[mootID].depth = 1
msg2.metadata.tangles[mootID].prev = [fakeMsgKey1] msg2.metadata.tangles[mootID].prev = [fakeMsgKey1]

View File

@ -1,6 +1,6 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
test('MsgV4 lipmaa prevs', (t) => { test('MsgV4 lipmaa prevs', (t) => {

View File

@ -1,6 +1,6 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
test('MsgV4.Tangle simple multi-author tangle', (t) => { test('MsgV4.Tangle simple multi-author tangle', (t) => {

View File

@ -1,6 +1,6 @@
const test = require('node:test') const test = require('node:test')
const assert = require('node:assert') const assert = require('node:assert')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const MsgV4 = require('../../lib/msg-v4') const MsgV4 = require('../../lib/msg-v4')
test('MsgV4 validation', async (t) => { test('MsgV4 validation', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-msgs-iter') const DIR = path.join(os.tmpdir(), 'pzp-db-msgs-iter')
rimraf.sync(DIR) rimraf.sync(DIR)
test('msgs() iterator', async (t) => { test('msgs() iterator', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-on-msg-added') const DIR = path.join(os.tmpdir(), 'pzp-db-on-msg-added')
rimraf.sync(DIR) rimraf.sync(DIR)
test('onRecordAdded', async (t) => { test('onRecordAdded', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-on-record-deleted-or-erased') const DIR = path.join(os.tmpdir(), 'pzp-db-on-record-deleted-or-erased')
rimraf.sync(DIR) rimraf.sync(DIR)
test('onRecordDeletedOrErased()', async (t) => { test('onRecordDeletedOrErased()', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-re-open') const DIR = path.join(os.tmpdir(), 'pzp-db-re-open')
rimraf.sync(DIR) rimraf.sync(DIR)
test('publish some msgs, close, re-open', async (t) => { test('publish some msgs, close, re-open', async (t) => {

View File

@ -4,10 +4,10 @@ const path = require('node:path')
const os = require('node:os') const os = require('node:os')
const p = require('node:util').promisify const p = require('node:util').promisify
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const DIR = path.join(os.tmpdir(), 'ppppp-db-records-iter') const DIR = path.join(os.tmpdir(), 'pzp-db-records-iter')
rimraf.sync(DIR) rimraf.sync(DIR)
test('records() iterator', async (t) => { test('records() iterator', async (t) => {

View File

@ -4,12 +4,12 @@ const path = require('node:path')
const p = require('node:util').promisify const p = require('node:util').promisify
const os = require('node:os') const os = require('node:os')
const rimraf = require('rimraf') const rimraf = require('rimraf')
const Keypair = require('ppppp-keypair') const Keypair = require('pzp-keypair')
const { createPeer } = require('./util') const { createPeer } = require('./util')
const MsgV4 = require('../lib/msg-v4') const MsgV4 = require('../lib/msg-v4')
const DIR = path.join(os.tmpdir(), 'ppppp-db-sigkeys') const DIR = path.join(os.tmpdir(), 'pzp-db-sigkeys')
const DIR2 = path.join(os.tmpdir(), 'ppppp-db-sigkeys2') const DIR2 = path.join(os.tmpdir(), 'pzp-db-sigkeys2')
rimraf.sync(DIR) rimraf.sync(DIR)
rimraf.sync(DIR2) rimraf.sync(DIR2)

View File

@ -4,7 +4,7 @@ function createPeer(globalConfig) {
.use(require('secret-handshake-ext/secret-stack')) .use(require('secret-handshake-ext/secret-stack'))
.use(require('../lib')) .use(require('../lib'))
.use(require('ssb-box')) .use(require('ssb-box'))
.call(null, { shse: { caps: require('ppppp-caps') }, global: globalConfig }) .call(null, { shse: { caps: require('pzp-caps') }, global: globalConfig })
} }
module.exports = { module.exports = {