@helia/ipns 10.1.1 → 10.2.0
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.js +1 -1
- package/dist/src/pb/metadata.d.ts +14 -1
- package/dist/src/pb/metadata.d.ts.map +1 -1
- package/dist/src/pb/metadata.js +36 -3
- 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/dist/typedoc-urls.json +23 -1
- package/package.json +3 -3
- 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 +1 -1
- package/src/pb/metadata.proto +10 -0
- package/src/pb/metadata.ts +45 -4
- package/src/routing/index.ts +30 -1
- package/src/utils.ts +19 -0
- package/src/validator.ts +30 -18
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.
|
|
173
|
+
|
|
174
|
+
There should be only one republisher per IPNS key. Multiple machines
|
|
175
|
+
republishing the same key flood the routers with redundant writes.
|
|
176
|
+
|
|
177
|
+
```TypeScript
|
|
178
|
+
import { createHelia } from 'helia'
|
|
179
|
+
import { ipns } from '@helia/ipns'
|
|
180
|
+
import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
|
|
181
|
+
import { defaultLogger } from 'birnam'
|
|
182
|
+
import { CID } from 'multiformats/cid'
|
|
183
|
+
|
|
184
|
+
const helia = await createHelia()
|
|
185
|
+
const name = ipns(helia)
|
|
186
|
+
|
|
187
|
+
const ipnsName = 'k51qzi5uqu5dktsyfv7xz8h631pri4ct7osmb43nibxiojpttxzoft6hdyyzg4'
|
|
188
|
+
const parsedCid: CID<unknown, 114, 0 | 18, 1> = CID.parse(ipnsName)
|
|
189
|
+
const delegatedClient = delegatedRoutingV1HttpApiClient({
|
|
190
|
+
url: 'https://delegated-ipfs.dev'
|
|
191
|
+
})({
|
|
192
|
+
logger: defaultLogger()
|
|
193
|
+
})
|
|
194
|
+
const record = await delegatedClient.getIPNS(parsedCid)
|
|
195
|
+
|
|
196
|
+
// import the record into the local store (validates and stores it locally,
|
|
197
|
+
// but does not publish it to the routers)
|
|
198
|
+
await name.import(parsedCid, record)
|
|
199
|
+
|
|
200
|
+
// start republishing it; throws RecordObsoleteError if the routers
|
|
201
|
+
// already have a newer record for this key
|
|
202
|
+
const { record: latestRecord } = 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
|