@wovin/connect-web3storage
v0.1.15
Published
Utilities for interacting with web3.storage services, including IPNS name watching.
Readme
@wovin/connect-web3storage
Utilities for interacting with web3.storage services, including IPNS name watching.
Installation
pnpm add @wovin/connect-web3storageWatch IPNS Names
Subscribe to IPNS name updates via the name.web3.storage WebSocket API.
Callback-based
import { watchName } from '@wovin/connect-web3storage'
const subscription = watchName('k51qzi5uqudle5hbd7yajvk3dxpw5p', {
onUpdate: (record) => {
console.log('New value:', record.value) // e.g. "/ipfs/bafy..."
},
onError: (err) => console.error('Watch error:', err),
onOpen: () => console.log('Connected'),
onClose: (event) => console.log('Closed:', event.code),
})
// Stop watching
subscription.close()Async Iterator
import { watchNameIterator } from '@wovin/connect-web3storage'
const controller = new AbortController()
for await (const record of watchNameIterator('k51qzi5u...', controller.signal)) {
console.log('Update:', record.value)
if (shouldStop) controller.abort()
}Types
interface W3NameRecord {
value: string // IPFS path, e.g. "/ipfs/bafy..."
seq?: number // Sequence number
validity?: string
}
interface WatchSubscription {
close: () => void
ws: WebSocket
}