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.

npm install y-fdp-storage
INSTALL
IMPORT
SIG · Y-FDP-STORAGE
Y
y-fdp-storage
databasejavascriptv0.2.13
harness data pending
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.

FdpStoragePersistence
import { FdpStoragePersistence } from 'y-fdp-storage'
const { FdpStoragePersistence } = require('y-fdp-storage')
ESM-only; named export from package
makePrivateKeySigner
import { makePrivateKeySigner } from 'y-fdp-storage'
import { makePrivateKeySigner } from 'fdp-storage'
Utility function to create signer from private key bytes
hexToBytes
import { hexToBytes } from 'y-fdp-storage'
import { hexToBytes } from '@ethersphere/bee-js'
Helper to convert hex string to Uint8Array
Y.Doc
import * as Y from 'yjs'; const doc = new Y.Doc()
import { Doc } from 'yjs'; const doc = new Doc()
Yjs default import; Doc is a named export but commonly used via namespace

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 issues
breakingConstructor signature changed: v0.2.0+ requires postageBatchId as 4th argument
fix
Update constructor call to include postageBatchId: new FdpStoragePersistence(bee, wallet, topic, batchId)
affects: <0.2.0
deprecatedstoreUpdate() method: silently catches errors; use store() for error propagation
fix
Use persistence.store(update) instead if you need to handle errors
affects: >=0.1.0
gotchahexToBytes expects lowercase hex string without 0x prefix
fix
Ensure private key is lowercase and without 0x: '634fb5a8...' not '0x634f...'
affects: >=0.1.0
gotchasubscribe() returns a close function; forgetting to call it may cause memory leaks
fix
Call close() when no longer needed, e.g., on component unmount
affects: >=0.1.0
gotchagetYDoc() only returns latest full state; incremental updates not tracked
fix
Use storeUpdate() and subscribe() to keep a local doc in sync continuously
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: FdpStoragePersistence is not a constructor
Importing wrong symbol or using CommonJS require with ESM package
fix
Use ES module import: import { FdpStoragePersistence } from 'y-fdp-storage'
Error: Private key must be 32 bytes
hexToBytes received hex string of incorrect length or with 0x prefix
fix
Ensure private key is exactly 64 hex characters (32 bytes) without 0x prefix
Request failed with status code 400
Invalid postage batch ID or insufficient batch depth/amount
fix
Check that postageBatchId is valid and funded on the Bee node
Failed to fetch
Bee node not running or unreachable at the specified URL
fix
Start Bee node on http://localhost:1633 or update the URL
Upgrade
Version history
0.2.13latest on npm
Audit
Dependencies
yjsrequiredPeer dependency for CRDT document model
@ethersphere/bee-jsrequiredRequired for Bee node connection
Agent activity
41 hits · last 30 days
node
36
Meta
1
OpenAI (training)
1
Resources
y-fdp-storage — npm install y-fdp-storage · libregistry