@helia/ipns 10.1.0 → 10.1.1-2ab3bfc6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/index.min.js +5 -5
- package/dist/index.min.js.map +4 -4
- package/dist/src/errors.d.ts +11 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +13 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +136 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +41 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ipns/publisher.d.ts +3 -3
- package/dist/src/ipns/publisher.d.ts.map +1 -1
- package/dist/src/ipns/publisher.js +17 -18
- package/dist/src/ipns/publisher.js.map +1 -1
- package/dist/src/ipns/republisher.d.ts +6 -1
- package/dist/src/ipns/republisher.d.ts.map +1 -1
- package/dist/src/ipns/republisher.js +157 -24
- package/dist/src/ipns/republisher.js.map +1 -1
- package/dist/src/ipns/resolver.d.ts +13 -1
- package/dist/src/ipns/resolver.d.ts.map +1 -1
- package/dist/src/ipns/resolver.js +40 -31
- package/dist/src/ipns/resolver.js.map +1 -1
- package/dist/src/ipns.d.ts +6 -3
- package/dist/src/ipns.d.ts.map +1 -1
- package/dist/src/ipns.js +12 -3
- package/dist/src/ipns.js.map +1 -1
- package/dist/src/local-store.d.ts +5 -0
- package/dist/src/local-store.d.ts.map +1 -1
- package/dist/src/local-store.js +68 -23
- package/dist/src/local-store.js.map +1 -1
- package/dist/src/pb/ipns.d.ts +9 -9
- package/dist/src/pb/ipns.d.ts.map +1 -1
- package/dist/src/pb/ipns.js +23 -9
- package/dist/src/pb/ipns.js.map +1 -1
- package/dist/src/pb/metadata.d.ts +16 -3
- package/dist/src/pb/metadata.d.ts.map +1 -1
- package/dist/src/pb/metadata.js +51 -4
- package/dist/src/pb/metadata.js.map +1 -1
- package/dist/src/routing/index.d.ts +13 -1
- package/dist/src/routing/index.d.ts.map +1 -1
- package/dist/src/routing/index.js +17 -0
- package/dist/src/routing/index.js.map +1 -1
- package/dist/src/utils.d.ts +5 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +18 -0
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validator.d.ts +6 -0
- package/dist/src/validator.d.ts.map +1 -1
- package/dist/src/validator.js +24 -14
- package/dist/src/validator.js.map +1 -1
- package/package.json +4 -4
- package/src/errors.ts +18 -0
- package/src/index.ts +145 -7
- package/src/ipns/publisher.ts +22 -20
- package/src/ipns/republisher.ts +182 -26
- package/src/ipns/resolver.ts +54 -36
- package/src/ipns.ts +20 -6
- package/src/local-store.ts +77 -22
- package/src/pb/ipns.ts +34 -18
- package/src/pb/metadata.proto +10 -0
- package/src/pb/metadata.ts +64 -7
- package/src/routing/index.ts +30 -1
- package/src/utils.ts +19 -0
- package/src/validator.ts +30 -18
- package/dist/typedoc-urls.json +0 -68
package/README.md
CHANGED
|
@@ -165,6 +165,46 @@ for await (const result of name.resolve(publicKey)) {
|
|
|
165
165
|
}
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
## Example - Republishing an existing IPNS record
|
|
169
|
+
|
|
170
|
+
It is sometimes useful to be able to republish an existing IPNS record
|
|
171
|
+
without needing the private key. This allows you to extend the availability
|
|
172
|
+
of a record that was created elsewhere: use `import` to store the record
|
|
173
|
+
locally, then `republish` to broadcast it and keep it alive.
|
|
174
|
+
|
|
175
|
+
> **There should be only one republisher per IPNS key.** Multiple machines
|
|
176
|
+
> republishing the same key flood the routers with redundant writes.
|
|
177
|
+
|
|
178
|
+
```TypeScript
|
|
179
|
+
import { createHelia } from 'helia'
|
|
180
|
+
import { ipns } from '@helia/ipns'
|
|
181
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
182
|
+
import { defaultLogger } from 'birnam'
|
|
183
|
+
import { CID } from 'multiformats/cid'
|
|
184
|
+
|
|
185
|
+
const helia = await createHelia()
|
|
186
|
+
const name = ipns(helia)
|
|
187
|
+
|
|
188
|
+
const ipnsName = 'k51qzi5uqu5dktsyfv7xz8h631pri4ct7osmb43nibxiojpttxzoft6hdyyzg4'
|
|
189
|
+
const parsedCid: CID<unknown, 114, 0 | 18, 1> = CID.parse(ipnsName)
|
|
190
|
+
const delegatedClient = delegatedRoutingV1HttpApiClient({
|
|
191
|
+
url: 'https://delegated-ipfs.dev'
|
|
192
|
+
})({
|
|
193
|
+
logger: defaultLogger()
|
|
194
|
+
})
|
|
195
|
+
const record = await delegatedClient.getIPNS(parsedCid)
|
|
196
|
+
|
|
197
|
+
// bring the record fetched from elsewhere into the local store
|
|
198
|
+
await name.import(parsedCid, record)
|
|
199
|
+
|
|
200
|
+
// republish the imported record and keep it alive. Throws
|
|
201
|
+
// RecordObsoleteError if the routing already has a newer record
|
|
202
|
+
await name.republish(parsedCid)
|
|
203
|
+
|
|
204
|
+
// stop republishing a key
|
|
205
|
+
await name.unpublish(parsedCid)
|
|
206
|
+
```
|
|
207
|
+
|
|
168
208
|
# Install
|
|
169
209
|
|
|
170
210
|
```console
|