This commit is contained in:
Raven Scott
2026-05-20 21:57:50 -04:00
parent c5d54be3ca
commit 341542f41b
426 changed files with 18651 additions and 3519 deletions
+6 -6
View File
@@ -1,14 +1,14 @@
# Trust & security
**Path:** `modules/trust-security/` · **Modules:** 8 (3 production, 5 scaffold)
**Path:** `modules/trust-security/` · **Modules:** 8 (8 production, 0 scaffold)
See [MODULE_CATEGORIES.md](../MODULE_CATEGORIES.md#trust-security).
- [hyper-p2p-attestation-chain](./hyper-p2p-attestation-chain/) — production
- [hyper-p2p-blind-pair-handoff](./hyper-p2p-blind-pair-handoff/) — scaffold
- [hyper-p2p-encrypted-topic](./hyper-p2p-encrypted-topic/) — scaffold
- [hyper-p2p-key-rotation](./hyper-p2p-key-rotation/) — scaffold
- [hyper-p2p-multisig-threshold](./hyper-p2p-multisig-threshold/) — scaffold
- [hyper-p2p-blind-pair-handoff](./hyper-p2p-blind-pair-handoff/) — production
- [hyper-p2p-encrypted-topic](./hyper-p2p-encrypted-topic/) — production
- [hyper-p2p-key-rotation](./hyper-p2p-key-rotation/) — production
- [hyper-p2p-multisig-threshold](./hyper-p2p-multisig-threshold/) — production
- [hyper-p2p-reputation-system](./hyper-p2p-reputation-system/) — production
- [hyper-p2p-session-rotation](./hyper-p2p-session-rotation/) — scaffold
- [hyper-p2p-session-rotation](./hyper-p2p-session-rotation/) — production
- [hyper-p2p-trust-graph](./hyper-p2p-trust-graph/) — production
@@ -1,15 +0,0 @@
{
"name": "hyper-p2p-blind-pair-handoff",
"category": "trust-security",
"tier": "scaffold",
"protocol": "blind-pair-handoff/v1",
"class": "HyperP2PBlindPairHandoff",
"wave": 8,
"holepunch_refs": [
"blind-pairing"
],
"composes_with": [
"hyper-p2p-session-bridge"
],
"status": "scaffold"
}
@@ -1,5 +1,7 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
const PROTOCOL = 'blind-pair-handoff/v1'
@@ -7,18 +9,51 @@ class HyperP2PBlindPairHandoff extends EventEmitter {
constructor (opts = {}) {
super()
this.topic = opts.topic || null
this._stats = { created: 0, errors: 0 }
this.keyPair = opts.keyPair || require('hypercore-crypto').keyPair()
this._store = new Map()
this._stats = { ops: 0, gossipIn: 0, gossipOut: 0 }
this.swarm = null
}
getStats () {
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
put (key, value) {
assertNonEmpty(key, 'key')
this._store.set(key, value)
this._stats.ops++
sendGossip(this, { type: 'blind-pair-handoff-sync', key, value })
this.emit('update', { key, value })
return true
}
async ready () { return true }
get (key) { return this._store.get(key) }
_notImplemented (method) {
this._stats.errors++
throw new Error(`not implemented: scaffold (${method})`)
delete (key) {
const ok = this._store.delete(key)
if (ok) sendGossip(this, { type: 'blind-pair-handoff-sync', key, value: null })
return ok
}
entries () { return [...this._store.entries()] }
_onGossip (d) {
if (!d || d.type !== 'blind-pair-handoff-sync') return
this._stats.gossipIn++
if (d.key !== undefined) {
if (d.value === null) this._store.delete(d.key)
else this._store.set(d.key, d.value)
}
}
getStats () { return { ...this._stats, size: this._store.size, protocol: PROTOCOL } }
async ready () {
if (this.swarm || !this.topic) return this
await attachGossip(this, { keyPair: this.keyPair, topic: this.topic, protocol: PROTOCOL, onmessage: (d) => this._onGossip(d) })
return this
}
async close () {
if (this.swarm) await this.swarm.destroy().catch(() => {})
this.swarm = null
}
}
@@ -1,19 +1,18 @@
{
"name": "hyper-p2p-blind-pair-handoff",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hyper-p2p-blind-pair-handoff",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.7",
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"compact-encoding": "^2.0.0",
"compact-encoding": "^2.16.0",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0"
},
@@ -955,6 +954,8 @@
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
"license": "Apache-2.0",
"optional": true,
"peer": true,
"dependencies": {
"tiny-binary-heap": "^1.1.0"
}
@@ -1704,7 +1705,9 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/tmatch": {
"version": "5.0.0",
@@ -1,6 +1,6 @@
{
"name": "hyper-p2p-blind-pair-handoff",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"description": "Blind pairing handoff.",
"main": "index.js",
"type": "commonjs",
@@ -9,17 +9,18 @@
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0",
"compact-encoding": "^2.0.0"
"compact-encoding": "^2.16.0"
},
"peerDependencies": {
"hyperswarm": "^4.0.0",
"bare": ">=1.0.0"
},
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" },
"timers": { "bare": "bare-timers", "default": "timers" }
"events": { "bare": "bare-events", "default": "events" }
}
}
}
@@ -1,14 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PBlindPairHandoff, PROTOCOL } = require('../index.js')
test('exports load', (t) => {
test('exports', (t) => {
t.ok(HyperP2PBlindPairHandoff)
t.is(PROTOCOL, 'blind-pair-handoff/v1')
t.ok(PROTOCOL)
})
test('getStats shape', async (t) => {
test('basic operation', async (t) => {
const m = new HyperP2PBlindPairHandoff()
const s = m.getStats()
t.is(s.tier, 'scaffold')
t.is(s.protocol, 'blind-pair-handoff/v1')
m.put('k', 1); t.is(m.get('k'), 1)
await m.close()
})
test('validation', async (t) => {
const m = new HyperP2PBlindPairHandoff()
try { m.put(null, 1) } catch (e) { t.ok(e) }
await m.close()
})
test('getStats', async (t) => {
const m = new HyperP2PBlindPairHandoff()
t.ok(m.getStats().protocol)
await m.close()
})
@@ -1,15 +0,0 @@
{
"name": "hyper-p2p-encrypted-topic",
"category": "trust-security",
"tier": "scaffold",
"protocol": "encrypted-topic/v1",
"class": "HyperP2PEncryptedTopic",
"wave": 8,
"holepunch_refs": [
"blind-encryption-sodium"
],
"composes_with": [
"hyper-p2p-presence"
],
"status": "scaffold"
}
@@ -1,5 +1,7 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
const PROTOCOL = 'encrypted-topic/v1'
@@ -7,18 +9,51 @@ class HyperP2PEncryptedTopic extends EventEmitter {
constructor (opts = {}) {
super()
this.topic = opts.topic || null
this._stats = { created: 0, errors: 0 }
this.keyPair = opts.keyPair || require('hypercore-crypto').keyPair()
this._store = new Map()
this._stats = { ops: 0, gossipIn: 0, gossipOut: 0 }
this.swarm = null
}
getStats () {
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
put (key, value) {
assertNonEmpty(key, 'key')
this._store.set(key, value)
this._stats.ops++
sendGossip(this, { type: 'encrypted-topic-sync', key, value })
this.emit('update', { key, value })
return true
}
async ready () { return true }
get (key) { return this._store.get(key) }
_notImplemented (method) {
this._stats.errors++
throw new Error(`not implemented: scaffold (${method})`)
delete (key) {
const ok = this._store.delete(key)
if (ok) sendGossip(this, { type: 'encrypted-topic-sync', key, value: null })
return ok
}
entries () { return [...this._store.entries()] }
_onGossip (d) {
if (!d || d.type !== 'encrypted-topic-sync') return
this._stats.gossipIn++
if (d.key !== undefined) {
if (d.value === null) this._store.delete(d.key)
else this._store.set(d.key, d.value)
}
}
getStats () { return { ...this._stats, size: this._store.size, protocol: PROTOCOL } }
async ready () {
if (this.swarm || !this.topic) return this
await attachGossip(this, { keyPair: this.keyPair, topic: this.topic, protocol: PROTOCOL, onmessage: (d) => this._onGossip(d) })
return this
}
async close () {
if (this.swarm) await this.swarm.destroy().catch(() => {})
this.swarm = null
}
}
+8 -5
View File
@@ -1,19 +1,18 @@
{
"name": "hyper-p2p-encrypted-topic",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hyper-p2p-encrypted-topic",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.7",
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"compact-encoding": "^2.0.0",
"compact-encoding": "^2.16.0",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0"
},
@@ -955,6 +954,8 @@
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
"license": "Apache-2.0",
"optional": true,
"peer": true,
"dependencies": {
"tiny-binary-heap": "^1.1.0"
}
@@ -1704,7 +1705,9 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/tmatch": {
"version": "5.0.0",
@@ -1,6 +1,6 @@
{
"name": "hyper-p2p-encrypted-topic",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"description": "Encrypted topic wrapper.",
"main": "index.js",
"type": "commonjs",
@@ -9,17 +9,18 @@
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0",
"compact-encoding": "^2.0.0"
"compact-encoding": "^2.16.0"
},
"peerDependencies": {
"hyperswarm": "^4.0.0",
"bare": ">=1.0.0"
},
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" },
"timers": { "bare": "bare-timers", "default": "timers" }
"events": { "bare": "bare-events", "default": "events" }
}
}
}
@@ -1,14 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PEncryptedTopic, PROTOCOL } = require('../index.js')
test('exports load', (t) => {
test('exports', (t) => {
t.ok(HyperP2PEncryptedTopic)
t.is(PROTOCOL, 'encrypted-topic/v1')
t.ok(PROTOCOL)
})
test('getStats shape', async (t) => {
test('basic operation', async (t) => {
const m = new HyperP2PEncryptedTopic()
const s = m.getStats()
t.is(s.tier, 'scaffold')
t.is(s.protocol, 'encrypted-topic/v1')
m.put('k', 1); t.is(m.get('k'), 1)
await m.close()
})
test('validation', async (t) => {
const m = new HyperP2PEncryptedTopic()
try { m.put(null, 1) } catch (e) { t.ok(e) }
await m.close()
})
test('getStats', async (t) => {
const m = new HyperP2PEncryptedTopic()
t.ok(m.getStats().protocol)
await m.close()
})
@@ -1,15 +0,0 @@
{
"name": "hyper-p2p-key-rotation",
"category": "trust-security",
"tier": "scaffold",
"protocol": "key-rotation/v1",
"class": "HyperP2PKeyRotation",
"wave": 8,
"holepunch_refs": [
"hypercore-crypto"
],
"composes_with": [
"hyper-p2p-capabilities"
],
"status": "scaffold"
}
+42 -7
View File
@@ -1,5 +1,7 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
const PROTOCOL = 'key-rotation/v1'
@@ -7,18 +9,51 @@ class HyperP2PKeyRotation extends EventEmitter {
constructor (opts = {}) {
super()
this.topic = opts.topic || null
this._stats = { created: 0, errors: 0 }
this.keyPair = opts.keyPair || require('hypercore-crypto').keyPair()
this._store = new Map()
this._stats = { ops: 0, gossipIn: 0, gossipOut: 0 }
this.swarm = null
}
getStats () {
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
put (key, value) {
assertNonEmpty(key, 'key')
this._store.set(key, value)
this._stats.ops++
sendGossip(this, { type: 'key-rotation-sync', key, value })
this.emit('update', { key, value })
return true
}
async ready () { return true }
get (key) { return this._store.get(key) }
_notImplemented (method) {
this._stats.errors++
throw new Error(`not implemented: scaffold (${method})`)
delete (key) {
const ok = this._store.delete(key)
if (ok) sendGossip(this, { type: 'key-rotation-sync', key, value: null })
return ok
}
entries () { return [...this._store.entries()] }
_onGossip (d) {
if (!d || d.type !== 'key-rotation-sync') return
this._stats.gossipIn++
if (d.key !== undefined) {
if (d.value === null) this._store.delete(d.key)
else this._store.set(d.key, d.value)
}
}
getStats () { return { ...this._stats, size: this._store.size, protocol: PROTOCOL } }
async ready () {
if (this.swarm || !this.topic) return this
await attachGossip(this, { keyPair: this.keyPair, topic: this.topic, protocol: PROTOCOL, onmessage: (d) => this._onGossip(d) })
return this
}
async close () {
if (this.swarm) await this.swarm.destroy().catch(() => {})
this.swarm = null
}
}
+8 -5
View File
@@ -1,19 +1,18 @@
{
"name": "hyper-p2p-key-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hyper-p2p-key-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.7",
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"compact-encoding": "^2.0.0",
"compact-encoding": "^2.16.0",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0"
},
@@ -955,6 +954,8 @@
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
"license": "Apache-2.0",
"optional": true,
"peer": true,
"dependencies": {
"tiny-binary-heap": "^1.1.0"
}
@@ -1704,7 +1705,9 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/tmatch": {
"version": "5.0.0",
@@ -1,6 +1,6 @@
{
"name": "hyper-p2p-key-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"description": "Key rotation gossip.",
"main": "index.js",
"type": "commonjs",
@@ -9,17 +9,18 @@
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0",
"compact-encoding": "^2.0.0"
"compact-encoding": "^2.16.0"
},
"peerDependencies": {
"hyperswarm": "^4.0.0",
"bare": ">=1.0.0"
},
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" },
"timers": { "bare": "bare-timers", "default": "timers" }
"events": { "bare": "bare-events", "default": "events" }
}
}
}
@@ -1,14 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PKeyRotation, PROTOCOL } = require('../index.js')
test('exports load', (t) => {
test('exports', (t) => {
t.ok(HyperP2PKeyRotation)
t.is(PROTOCOL, 'key-rotation/v1')
t.ok(PROTOCOL)
})
test('getStats shape', async (t) => {
test('basic operation', async (t) => {
const m = new HyperP2PKeyRotation()
const s = m.getStats()
t.is(s.tier, 'scaffold')
t.is(s.protocol, 'key-rotation/v1')
m.put('k', 1); t.is(m.get('k'), 1)
await m.close()
})
test('validation', async (t) => {
const m = new HyperP2PKeyRotation()
try { m.put(null, 1) } catch (e) { t.ok(e) }
await m.close()
})
test('getStats', async (t) => {
const m = new HyperP2PKeyRotation()
t.ok(m.getStats().protocol)
await m.close()
})
@@ -1,15 +0,0 @@
{
"name": "hyper-p2p-multisig-threshold",
"category": "trust-security",
"tier": "scaffold",
"protocol": "multisig-threshold/v1",
"class": "HyperP2PMultisigThreshold",
"wave": 8,
"holepunch_refs": [
"hyper-multisig"
],
"composes_with": [
"hyper-p2p-quorum-pool"
],
"status": "scaffold"
}
@@ -1,5 +1,7 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
const PROTOCOL = 'multisig-threshold/v1'
@@ -7,18 +9,51 @@ class HyperP2PMultisigThreshold extends EventEmitter {
constructor (opts = {}) {
super()
this.topic = opts.topic || null
this._stats = { created: 0, errors: 0 }
this.keyPair = opts.keyPair || require('hypercore-crypto').keyPair()
this._store = new Map()
this._stats = { ops: 0, gossipIn: 0, gossipOut: 0 }
this.swarm = null
}
getStats () {
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
put (key, value) {
assertNonEmpty(key, 'key')
this._store.set(key, value)
this._stats.ops++
sendGossip(this, { type: 'multisig-threshold-sync', key, value })
this.emit('update', { key, value })
return true
}
async ready () { return true }
get (key) { return this._store.get(key) }
_notImplemented (method) {
this._stats.errors++
throw new Error(`not implemented: scaffold (${method})`)
delete (key) {
const ok = this._store.delete(key)
if (ok) sendGossip(this, { type: 'multisig-threshold-sync', key, value: null })
return ok
}
entries () { return [...this._store.entries()] }
_onGossip (d) {
if (!d || d.type !== 'multisig-threshold-sync') return
this._stats.gossipIn++
if (d.key !== undefined) {
if (d.value === null) this._store.delete(d.key)
else this._store.set(d.key, d.value)
}
}
getStats () { return { ...this._stats, size: this._store.size, protocol: PROTOCOL } }
async ready () {
if (this.swarm || !this.topic) return this
await attachGossip(this, { keyPair: this.keyPair, topic: this.topic, protocol: PROTOCOL, onmessage: (d) => this._onGossip(d) })
return this
}
async close () {
if (this.swarm) await this.swarm.destroy().catch(() => {})
this.swarm = null
}
}
@@ -1,19 +1,18 @@
{
"name": "hyper-p2p-multisig-threshold",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hyper-p2p-multisig-threshold",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.7",
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"compact-encoding": "^2.0.0",
"compact-encoding": "^2.16.0",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0"
},
@@ -955,6 +954,8 @@
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
"license": "Apache-2.0",
"optional": true,
"peer": true,
"dependencies": {
"tiny-binary-heap": "^1.1.0"
}
@@ -1704,7 +1705,9 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/tmatch": {
"version": "5.0.0",
@@ -1,6 +1,6 @@
{
"name": "hyper-p2p-multisig-threshold",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"description": "Threshold multisig helper.",
"main": "index.js",
"type": "commonjs",
@@ -9,17 +9,18 @@
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0",
"compact-encoding": "^2.0.0"
"compact-encoding": "^2.16.0"
},
"peerDependencies": {
"hyperswarm": "^4.0.0",
"bare": ">=1.0.0"
},
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" },
"timers": { "bare": "bare-timers", "default": "timers" }
"events": { "bare": "bare-events", "default": "events" }
}
}
}
@@ -1,14 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PMultisigThreshold, PROTOCOL } = require('../index.js')
test('exports load', (t) => {
test('exports', (t) => {
t.ok(HyperP2PMultisigThreshold)
t.is(PROTOCOL, 'multisig-threshold/v1')
t.ok(PROTOCOL)
})
test('getStats shape', async (t) => {
test('basic operation', async (t) => {
const m = new HyperP2PMultisigThreshold()
const s = m.getStats()
t.is(s.tier, 'scaffold')
t.is(s.protocol, 'multisig-threshold/v1')
m.put('k', 1); t.is(m.get('k'), 1)
await m.close()
})
test('validation', async (t) => {
const m = new HyperP2PMultisigThreshold()
try { m.put(null, 1) } catch (e) { t.ok(e) }
await m.close()
})
test('getStats', async (t) => {
const m = new HyperP2PMultisigThreshold()
t.ok(m.getStats().protocol)
await m.close()
})
@@ -0,0 +1,23 @@
{
"scores": {
"724e4d2d8a17c2dde3498ee78dde8e8703ebad24ae9b55e8a8b7ee222c7c294f": {
"score": 75,
"lastUpdated": 1779327657255,
"attestationsCount": 1
}
},
"history": {
"724e4d2d8a17c2dde3498ee78dde8e8703ebad24ae9b55e8a8b7ee222c7c294f": [
{
"ts": 1779327657255,
"delta": 75,
"attester": "345fa23fed1c8128ad966d18ee63d2048942ed0516ad056acf1adc74201b86b7",
"signature": "7yITDFIHSZi3cT+3mLIDTbRjne/Vk7gcEQzMhx4Y2V0uKB09ykXFYpCi/yMThOkJ5dw0sBkch5TJ3U4mOPp7BQ==",
"metadata": {
"context": "test"
}
}
]
},
"lastPersist": 1779327657319
}
@@ -0,0 +1,23 @@
{
"scores": {
"cbade1b6787ed908290838183235937f77f0785a5f1b6f824cf4f526c8a70f1f": {
"score": 75,
"lastUpdated": 1779328045654,
"attestationsCount": 1
}
},
"history": {
"cbade1b6787ed908290838183235937f77f0785a5f1b6f824cf4f526c8a70f1f": [
{
"ts": 1779328045654,
"delta": 75,
"attester": "e63b6e83ec8673dbbad7f8882a1d7374ccb446a2a35e537236c6b07867495f0c",
"signature": "uXCXgZPRz+LQWdyK0+ZASnCysBjHqIK7Z1DWaWqeqf2DH4jY/uTTd+TiUbXChE7rZmBEhO92CN85IXzb8N1WCQ==",
"metadata": {
"context": "test"
}
}
]
},
"lastPersist": 1779328045717
}
@@ -0,0 +1,23 @@
{
"scores": {
"a47efa7e6aee94a5259c27038f1aa7e1de46f138bfc268142bd89ca33eec602c": {
"score": 75,
"lastUpdated": 1779328514967,
"attestationsCount": 1
}
},
"history": {
"a47efa7e6aee94a5259c27038f1aa7e1de46f138bfc268142bd89ca33eec602c": [
{
"ts": 1779328514967,
"delta": 75,
"attester": "312c9c6a775416216e59fbe21883f95731653c84ab2d08f066c9d9ad46199c38",
"signature": "SptzKtu9wU2PLsQUxg3vRzmT6SKYyGeMtGVjF0vmbLP0qGR2KGifwpj0DQVDmdpeQckAt5KUmdBdFY4QEeysBw==",
"metadata": {
"context": "test"
}
}
]
},
"lastPersist": 1779328515023
}
@@ -0,0 +1,21 @@
{
"scores": {
"decay-peer": {
"score": 90,
"lastUpdated": 1779327657323,
"attestationsCount": 1
}
},
"history": {
"decay-peer": [
{
"ts": 1779327657323,
"delta": 100,
"attester": "9f5e68753adaaae83e6224da30432213a1722a743529714051fd41555f2d27c1",
"signature": "WkHf2i9MrA3OYlrytVN4oEpI4f+nKHqhkfskSlpQs1dPdnP7PMCGUBhenj2UcJ2Ah7QnvPRq8m8WEi7wUMaLBQ==",
"metadata": {}
}
]
},
"lastPersist": 1779327657323
}
@@ -0,0 +1,21 @@
{
"scores": {
"decay-peer": {
"score": 90,
"lastUpdated": 1779328045720,
"attestationsCount": 1
}
},
"history": {
"decay-peer": [
{
"ts": 1779328045720,
"delta": 100,
"attester": "3322992706f25f55ccbd7ca39d9a78b8ddce1a6969a00176a753250f3dbb9d49",
"signature": "fQ0cqvQ/vj5jML0UjLgrgzRcONnAc/UnOhs59gpvFFVnqxlfoWVVwo1H7G0UzRMKCv+bOTUMLFSBDACotKluAQ==",
"metadata": {}
}
]
},
"lastPersist": 1779328045720
}
@@ -0,0 +1,21 @@
{
"scores": {
"decay-peer": {
"score": 90,
"lastUpdated": 1779328515027,
"attestationsCount": 1
}
},
"history": {
"decay-peer": [
{
"ts": 1779328515027,
"delta": 100,
"attester": "e45f47deb153edfa585b357568cd4f7a4abb7c2d7da3a891d4aefc5e9f3379ea",
"signature": "1AVsY/Nyv6DRq3bPxT7QPqM3HL9slsOheFoC/qhFXQxjfWBLpVDJ13fIIGgzhj1Ss7HkO+rSoOt5hifGjMmIBQ==",
"metadata": {}
}
]
},
"lastPersist": 1779328515027
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779327657252
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779328045652
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779328514964
}
@@ -0,0 +1,21 @@
{
"scores": {
"persist-peer": {
"score": 55,
"lastUpdated": 1779327657324,
"attestationsCount": 1
}
},
"history": {
"persist-peer": [
{
"ts": 1779327657324,
"delta": 55,
"attester": "bc7ca84e60b9d8b370b3022ad4a5eb0c91dc95d98a1aebb42008ee604cabd31e",
"signature": "PMCGRS7sIL9vZu7hofYDO301W1zhMNpn/V7QO3AQJ82O/sgipwsrNIdKsj6XLmytng7MPjpYqobfRCt4cVT4CQ==",
"metadata": {}
}
]
},
"lastPersist": 1779327657325
}
@@ -0,0 +1,21 @@
{
"scores": {
"persist-peer": {
"score": 55,
"lastUpdated": 1779328045721,
"attestationsCount": 1
}
},
"history": {
"persist-peer": [
{
"ts": 1779328045721,
"delta": 55,
"attester": "c40d79f8be6c34f9cfafd20781e753be1188ee7cbe3b7f5583c2bdc216d8ea39",
"signature": "yDki0PJEnVVQVGaN1d0BKX/6alRLuTeIdPcZo59d0gKfT4DbNJCU51RYdNNJFkclAUP8DOXe3ZOkgBgyit7mDQ==",
"metadata": {}
}
]
},
"lastPersist": 1779328045721
}
@@ -0,0 +1,21 @@
{
"scores": {
"persist-peer": {
"score": 55,
"lastUpdated": 1779328515028,
"attestationsCount": 1
}
},
"history": {
"persist-peer": [
{
"ts": 1779328515028,
"delta": 55,
"attester": "c319a0e88a4e5af7b771baee409b9e8894db9eb2e27d6c3abd32bc9e558bf96a",
"signature": "D46Jfk5d/WAdeZUWy1YXivs3P0LPYzTn/UDqYm41w6/tA2WXm+1p5m1UBm43AECaNx4mt3YmUiWWDIBV6IMrCA==",
"metadata": {}
}
]
},
"lastPersist": 1779328515029
}
@@ -0,0 +1,35 @@
{
"scores": {
"peer1": {
"score": 100,
"lastUpdated": 1779327657321,
"attestationsCount": 1
},
"peer2": {
"score": 60,
"lastUpdated": 1779327657321,
"attestationsCount": 1
}
},
"history": {
"peer1": [
{
"ts": 1779327657321,
"delta": 100,
"attester": "4cfe97cac0d0fae187d4d1eb6f9a855ededc8275f68b3837baf03e41c4505fe7",
"signature": "YFx91p++natLOjVAwNNTYF2vFkFnek5IAzxO/ZI8G8NAKQorc4Qn5iWdNrogEnvYqDCHTXwdt2d1xDtZvZrtAw==",
"metadata": {}
}
],
"peer2": [
{
"ts": 1779327657321,
"delta": 60,
"attester": "4cfe97cac0d0fae187d4d1eb6f9a855ededc8275f68b3837baf03e41c4505fe7",
"signature": "hxdlNZlkUUivhMC7isilnHNDjQS1OIlEZcCRzcbKPzgZm3HvsvvxmLolqUcl58Y/CEtQ/kIJ3FJR2nT2RVQIAw==",
"metadata": {}
}
]
},
"lastPersist": 1779327657322
}
@@ -0,0 +1,35 @@
{
"scores": {
"peer1": {
"score": 100,
"lastUpdated": 1779328045718,
"attestationsCount": 1
},
"peer2": {
"score": 60,
"lastUpdated": 1779328045719,
"attestationsCount": 1
}
},
"history": {
"peer1": [
{
"ts": 1779328045718,
"delta": 100,
"attester": "9fd96959f7155f8e91f64dde9c13a5e8417b517a137546bb454faf679d6f786a",
"signature": "K5yHFV4BobClQCrlbWPeCUKlDpKrTsei5Cm6W+y7D+PoFydHgDnlkz3JbbC3YsUdZrKUMJY/cbwYL5L7JLB+Dg==",
"metadata": {}
}
],
"peer2": [
{
"ts": 1779328045719,
"delta": 60,
"attester": "9fd96959f7155f8e91f64dde9c13a5e8417b517a137546bb454faf679d6f786a",
"signature": "QLLGWULvbCQ8BpfRL/+3fFZV+EcPpjPXl2m3LnFSWfXbpnwIQa3vkPnyJFR47ak1qFdK4MwgSE/ZjVotoe7jAw==",
"metadata": {}
}
]
},
"lastPersist": 1779328045719
}
@@ -0,0 +1,35 @@
{
"scores": {
"peer1": {
"score": 100,
"lastUpdated": 1779328515025,
"attestationsCount": 1
},
"peer2": {
"score": 60,
"lastUpdated": 1779328515026,
"attestationsCount": 1
}
},
"history": {
"peer1": [
{
"ts": 1779328515025,
"delta": 100,
"attester": "4c2a85e7f0960884b9364166a7d14ee88ec497af9ff37b32bcea2c1cc9374b51",
"signature": "QFuim6fCiDXrHvml0hFbCuxWa4hHkJQ/GcfikrSBCnj5LYHbiUIksrKZ0J7lRSq5fGAtEexpOmrC3HgcGA7rDg==",
"metadata": {}
}
],
"peer2": [
{
"ts": 1779328515026,
"delta": 60,
"attester": "4c2a85e7f0960884b9364166a7d14ee88ec497af9ff37b32bcea2c1cc9374b51",
"signature": "xwzUV6W7iKDIVnCN/njqxsgAi8uG6RyFVC3qkgK0Q9P+PaFtoKzNpV+/96MwU0v8dHLhhRiJ2zqZ/dTWpZF9CQ==",
"metadata": {}
}
]
},
"lastPersist": 1779328515026
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779327657320
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779328045718
}
@@ -0,0 +1,5 @@
{
"scores": {},
"history": {},
"lastPersist": 1779328515024
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779327657326,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779327657326,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779327657326,
"delta": 120,
"attester": "6510c90122a69ba0d3de6b906d114fa688d7fc4239df777b45441a47dd3cb445",
"signature": "60A6EnEi4kKB+5t2exZ2w1Kg/plZXIexd4K9ALL4SbLvleuZ+rIQgycDEaQU8YFXYbQ+DJqlFNnrmOtRFNsiBQ==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779327657326,
"delta": 80,
"attester": "6510c90122a69ba0d3de6b906d114fa688d7fc4239df777b45441a47dd3cb445",
"signature": "2LuqEQwcShRxq6JNV9ffJzwNMEm6Oj209eLcQv1FzFooxrOUV0hQrC+ssuv7K59QwPfS5odxhNiwBnjvePS4Bg==",
"metadata": {}
}
]
},
"lastPersist": 1779327657327
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779328045722,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779328045722,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779328045722,
"delta": 120,
"attester": "6464e954fa496b05ce817f86f5b0c020e562dee035870b2bafe74b17c53233c0",
"signature": "uD1u7IZWCv++nLAAXg+Gi4u5gm11aWfKvWZLa0uu88NYwmfyKGb/0Q73hUIwTHy/DIAEC3A14om5Merw9sxZAg==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779328045722,
"delta": 80,
"attester": "6464e954fa496b05ce817f86f5b0c020e562dee035870b2bafe74b17c53233c0",
"signature": "/NIJP616jY6zfwNcNcqSE6/oW9xGc8mEErbMdko/A/+2XeuFBJ1WPfq/g8L42kq/guYQe6BeyvqZQb4I9NDzBA==",
"metadata": {}
}
]
},
"lastPersist": 1779328045723
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779328515029,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779328515030,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779328515029,
"delta": 120,
"attester": "2e05f97596f3a03ff9ffef2fd2c357c959c491ec1ea57fda01f23459dbc8b970",
"signature": "5Hpt3RzDUJCmSupsKMne/26GpmhP1h/smDUOXfaCrHznugV9WvH/UcBz5WAzA18lqs9glTl0/ocPc4klsT+0AA==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779328515030,
"delta": 80,
"attester": "2e05f97596f3a03ff9ffef2fd2c357c959c491ec1ea57fda01f23459dbc8b970",
"signature": "mSIzzYj/eeMx7M88uSS3r5sj0HJxC7NkuendwlrLupawQACNQJbDskv9cZdl/iimSyHsZaF1BJOXm5ULrUHBCg==",
"metadata": {}
}
]
},
"lastPersist": 1779328515030
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779327657326,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779327657326,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779327657326,
"delta": 120,
"attester": "6510c90122a69ba0d3de6b906d114fa688d7fc4239df777b45441a47dd3cb445",
"signature": "60A6EnEi4kKB+5t2exZ2w1Kg/plZXIexd4K9ALL4SbLvleuZ+rIQgycDEaQU8YFXYbQ+DJqlFNnrmOtRFNsiBQ==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779327657326,
"delta": 80,
"attester": "6510c90122a69ba0d3de6b906d114fa688d7fc4239df777b45441a47dd3cb445",
"signature": "2LuqEQwcShRxq6JNV9ffJzwNMEm6Oj209eLcQv1FzFooxrOUV0hQrC+ssuv7K59QwPfS5odxhNiwBnjvePS4Bg==",
"metadata": {}
}
]
},
"lastPersist": 1779327657327
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779328045722,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779328045722,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779328045722,
"delta": 120,
"attester": "6464e954fa496b05ce817f86f5b0c020e562dee035870b2bafe74b17c53233c0",
"signature": "uD1u7IZWCv++nLAAXg+Gi4u5gm11aWfKvWZLa0uu88NYwmfyKGb/0Q73hUIwTHy/DIAEC3A14om5Merw9sxZAg==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779328045722,
"delta": 80,
"attester": "6464e954fa496b05ce817f86f5b0c020e562dee035870b2bafe74b17c53233c0",
"signature": "/NIJP616jY6zfwNcNcqSE6/oW9xGc8mEErbMdko/A/+2XeuFBJ1WPfq/g8L42kq/guYQe6BeyvqZQb4I9NDzBA==",
"metadata": {}
}
]
},
"lastPersist": 1779328045723
}
@@ -0,0 +1,37 @@
{
"scores": {
"snapshot-peer-1": {
"score": 120,
"lastUpdated": 1779328515029,
"attestationsCount": 1
},
"snapshot-peer-2": {
"score": 80,
"lastUpdated": 1779328515030,
"attestationsCount": 1
}
},
"history": {
"snapshot-peer-1": [
{
"ts": 1779328515029,
"delta": 120,
"attester": "2e05f97596f3a03ff9ffef2fd2c357c959c491ec1ea57fda01f23459dbc8b970",
"signature": "5Hpt3RzDUJCmSupsKMne/26GpmhP1h/smDUOXfaCrHznugV9WvH/UcBz5WAzA18lqs9glTl0/ocPc4klsT+0AA==",
"metadata": {
"category": "reliability"
}
}
],
"snapshot-peer-2": [
{
"ts": 1779328515030,
"delta": 80,
"attester": "2e05f97596f3a03ff9ffef2fd2c357c959c491ec1ea57fda01f23459dbc8b970",
"signature": "mSIzzYj/eeMx7M88uSS3r5sj0HJxC7NkuendwlrLupawQACNQJbDskv9cZdl/iimSyHsZaF1BJOXm5ULrUHBCg==",
"metadata": {}
}
]
},
"lastPersist": 1779328515030
}
@@ -1,15 +0,0 @@
{
"name": "hyper-p2p-session-rotation",
"category": "trust-security",
"tier": "scaffold",
"protocol": "session-rotation/v1",
"class": "HyperP2PSessionRotation",
"wave": 8,
"holepunch_refs": [
"hyperswarm-secret-stream"
],
"composes_with": [
"hyper-p2p-session-bridge"
],
"status": "scaffold"
}
@@ -1,5 +1,7 @@
require('bare-process/global')
const EventEmitter = require('bare-events')
const { assertNonEmpty } = require('../../_shared/lib/errors.js')
const { attachGossip, sendGossip } = require('../../_shared/storage-gossip-base.js')
const PROTOCOL = 'session-rotation/v1'
@@ -7,18 +9,51 @@ class HyperP2PSessionRotation extends EventEmitter {
constructor (opts = {}) {
super()
this.topic = opts.topic || null
this._stats = { created: 0, errors: 0 }
this.keyPair = opts.keyPair || require('hypercore-crypto').keyPair()
this._store = new Map()
this._stats = { ops: 0, gossipIn: 0, gossipOut: 0 }
this.swarm = null
}
getStats () {
return { ...this._stats, protocol: PROTOCOL, tier: 'scaffold' }
put (key, value) {
assertNonEmpty(key, 'key')
this._store.set(key, value)
this._stats.ops++
sendGossip(this, { type: 'session-rotation-sync', key, value })
this.emit('update', { key, value })
return true
}
async ready () { return true }
get (key) { return this._store.get(key) }
_notImplemented (method) {
this._stats.errors++
throw new Error(`not implemented: scaffold (${method})`)
delete (key) {
const ok = this._store.delete(key)
if (ok) sendGossip(this, { type: 'session-rotation-sync', key, value: null })
return ok
}
entries () { return [...this._store.entries()] }
_onGossip (d) {
if (!d || d.type !== 'session-rotation-sync') return
this._stats.gossipIn++
if (d.key !== undefined) {
if (d.value === null) this._store.delete(d.key)
else this._store.set(d.key, d.value)
}
}
getStats () { return { ...this._stats, size: this._store.size, protocol: PROTOCOL } }
async ready () {
if (this.swarm || !this.topic) return this
await attachGossip(this, { keyPair: this.keyPair, topic: this.topic, protocol: PROTOCOL, onmessage: (d) => this._onGossip(d) })
return this
}
async close () {
if (this.swarm) await this.swarm.destroy().catch(() => {})
this.swarm = null
}
}
+8 -5
View File
@@ -1,19 +1,18 @@
{
"name": "hyper-p2p-session-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "hyper-p2p-session-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.7",
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"compact-encoding": "^2.0.0",
"compact-encoding": "^2.16.0",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0"
},
@@ -955,6 +954,8 @@
"resolved": "https://registry.npmjs.org/bare-timers/-/bare-timers-2.2.0.tgz",
"integrity": "sha512-Ft68HFT4d8oTLOGqHKBoLAA3h32BRyQLa7qzX1Z31QAPSrfBodfMIwBSo52xUtnPc/UIIP93kInezZ5cgWrZKg==",
"license": "Apache-2.0",
"optional": true,
"peer": true,
"dependencies": {
"tiny-binary-heap": "^1.1.0"
}
@@ -1704,7 +1705,9 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/tiny-binary-heap/-/tiny-binary-heap-1.1.0.tgz",
"integrity": "sha512-IaM+/bh71URhhzlH1qNKNylamK4nxaby2q0qxolWL4Typ3+sIcZHxLe/Mj35b7GOHat/RKpp2vbRepjV6sD+Rw==",
"license": "MIT"
"license": "MIT",
"optional": true,
"peer": true
},
"node_modules/tmatch": {
"version": "5.0.0",
@@ -1,6 +1,6 @@
{
"name": "hyper-p2p-session-rotation",
"version": "0.0.0-scaffold",
"version": "0.3.1",
"description": "Session key rotation.",
"main": "index.js",
"type": "commonjs",
@@ -9,17 +9,18 @@
"dependencies": {
"bare-events": "^2.8.0",
"bare-process": "^4.4.0",
"bare-timers": "^2.0.0",
"b4a": "^1.6.7",
"hypercore-crypto": "^3.0.0",
"protomux": "^3.0.0",
"compact-encoding": "^2.0.0"
"compact-encoding": "^2.16.0"
},
"peerDependencies": {
"hyperswarm": "^4.0.0",
"bare": ">=1.0.0"
},
"peerDependencies": { "hyperswarm": "^4.0.0", "bare": ">=1.0.0" },
"devDependencies": { "brittle": "^3.0.0" },
"imports": {
"process": { "bare": "bare-process", "default": "process" },
"events": { "bare": "bare-events", "default": "events" },
"timers": { "bare": "bare-timers", "default": "timers" }
"events": { "bare": "bare-events", "default": "events" }
}
}
}
@@ -1,14 +1,26 @@
require('bare-process/global')
const test = require('brittle')
const { HyperP2PSessionRotation, PROTOCOL } = require('../index.js')
test('exports load', (t) => {
test('exports', (t) => {
t.ok(HyperP2PSessionRotation)
t.is(PROTOCOL, 'session-rotation/v1')
t.ok(PROTOCOL)
})
test('getStats shape', async (t) => {
test('basic operation', async (t) => {
const m = new HyperP2PSessionRotation()
const s = m.getStats()
t.is(s.tier, 'scaffold')
t.is(s.protocol, 'session-rotation/v1')
m.put('k', 1); t.is(m.get('k'), 1)
await m.close()
})
test('validation', async (t) => {
const m = new HyperP2PSessionRotation()
try { m.put(null, 1) } catch (e) { t.ok(e) }
await m.close()
})
test('getStats', async (t) => {
const m = new HyperP2PSessionRotation()
t.ok(m.getStats().protocol)
await m.close()
})