Registry / database / y-fdp-storage

y-fdp-storage

JSON →
library0.2.13jsnpmunverified

Yjs database provider using Swarm Feeds Sequential mechanism for decentralized document synchronization. Current version 0.2.13 (alpha). Released on GitHub with no fixed cadence. Key differentiator: uses Sequential feed (more efficient than Epoch), complete TypeScript implementation, avoids Beeson dependency for simplicity. Integrates with @ethersphere/bee-js and @fairdatasociety/fdp-storage. Suitable for building collaborative applications on Swarm/Ethereum Swarm network.

databasestorage
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM-only; named export from package

import { FdpStoragePersistence } from 'y-fdp-storage'

Utility function to create signer from private key bytes

import { makePrivateKeySigner } from 'y-fdp-storage'

Helper to convert hex string to Uint8Array

import { hexToBytes } from 'y-fdp-storage'

Yjs default import; Doc is a named export but commonly used via namespace

import * as Y from 'yjs'; const doc = new Y.Doc()

Shows how to create a FdpStoragePersistence instance, connect to Bee, and sync Yjs document updates to Swarm Feed.

import * as Y from 'yjs'; import { Bee } from '@ethersphere/bee-js'; import { hexToBytes, makePrivateKeySigner, FdpStoragePersistence } from 'y-fdp-storage'; // Setup Bee connection const postageBatchId = process.env.BEE_POSTAGE || '1c082c5e642e15d49b6689f5437c2eb9e6aa9c546a8ed1d11d0024b043bca371'; const bee = new Bee('http://localhost:1633'); // Identity (private key hex) const testIdentity = { privateKey: '634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd', }; const wallet = makePrivateKeySigner(hexToBytes(testIdentity.privateKey)); const topic = '/crdt/document/test'; // Create persistence const persistence = new FdpStoragePersistence(bee, wallet, topic, postageBatchId); // Create Yjs document const doc = new Y.Doc(); doc.on('update', async update => { await persistence.storeUpdate(update); }); doc.getText('test').insert(0, 'Hello World'); // Retrieve latest document const latestDoc = await persistence.getYDoc(); console.log(latestDoc.getText('test').toString()); // 'Hello World'
Debug
Known footguns
breakingConstructor signature changed: v0.2.0+ requires postageBatchId as 4th argument
deprecatedstoreUpdate() method: silently catches errors; use store() for error propagation
gotchahexToBytes expects lowercase hex string without 0x prefix
gotchasubscribe() returns a close function; forgetting to call it may cause memory leaks
gotchagetYDoc() only returns latest full state; incremental updates not tracked
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
18 hits · last 30 days
gptbot
3
petalbot
2
ahrefsbot
1
amazonbot
1
Resources