@helia/ipns 9.1.9 → 9.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.
@@ -1,61 +1,172 @@
1
- import { isPublicKey } from '@libp2p/interface';
1
+ import { isPublicKey, NotFoundError, setMaxListeners } from '@libp2p/interface';
2
2
  import { logger } from '@libp2p/logger';
3
+ import { PeerSet } from '@libp2p/peer-collections';
4
+ import { Queue } from '@libp2p/utils';
5
+ import { anySignal } from 'any-signal';
6
+ import delay from 'delay';
3
7
  import { multihashToIPNSRoutingKey } from 'ipns';
4
8
  import { ipnsSelector } from 'ipns/selector';
5
9
  import { ipnsValidator } from 'ipns/validator';
6
10
  import { CustomProgressEvent } from 'progress-events';
11
+ import { raceSignal } from 'race-signal';
7
12
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals';
8
13
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
9
14
  import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
10
- import { InvalidTopicError } from '../errors.js';
11
- import { localStore } from '../local-store.js';
15
+ import { InvalidTopicError } from "../errors.js";
16
+ import { localStore } from "../local-store.js";
17
+ import { IPNS_STRING_PREFIX } from "../utils.js";
12
18
  const log = logger('helia:ipns:routing:pubsub');
13
- class PubSubRouting {
19
+ export class PubSubRouting {
14
20
  subscriptions;
15
21
  localStore;
16
- peerId;
17
- pubsub;
18
- constructor(components) {
19
- this.subscriptions = [];
22
+ libp2p;
23
+ fetchConcurrency;
24
+ fetchTimeout;
25
+ fetchDelay;
26
+ fetchQueue;
27
+ fetchPeers;
28
+ shutdownController;
29
+ fetchTopologyId;
30
+ constructor(components, init = {}) {
31
+ this.subscriptions = new Set();
32
+ this.shutdownController = new AbortController();
33
+ setMaxListeners(Infinity, this.shutdownController.signal);
34
+ this.fetchPeers = new PeerSet();
20
35
  this.localStore = localStore(components.datastore, components.logger.forComponent('helia:ipns:local-store'));
21
- this.peerId = components.libp2p.peerId;
22
- this.pubsub = components.libp2p.services.pubsub;
23
- this.pubsub.addEventListener('message', (evt) => {
36
+ this.libp2p = components.libp2p;
37
+ this.fetchConcurrency = init.fetchConcurrency ?? 8;
38
+ this.fetchDelay = init.fetchDelay ?? 0;
39
+ // default libp2p-fetch timeout is 10 seconds - we should have an existing
40
+ // connection to the peer so this can be shortened
41
+ this.fetchTimeout = init.fetchTimeout ?? 2_500;
42
+ this.fetchQueue = new Queue({
43
+ concurrency: this.fetchConcurrency,
44
+ metrics: components.metrics,
45
+ metricName: 'helia_ipns_pubsub_fetch_queue'
46
+ });
47
+ this.libp2p.services.pubsub.addEventListener('message', (evt) => {
24
48
  const message = evt.detail;
25
- if (!this.subscriptions.includes(message.topic)) {
49
+ if (!this.subscriptions.has(message.topic)) {
26
50
  return;
27
51
  }
28
- this.#processPubSubMessage(message).catch(err => {
52
+ this.#processPubSubMessage(message, {
53
+ signal: this.shutdownController.signal
54
+ }).catch(err => {
29
55
  log.error('Error processing message - %e', err);
30
56
  });
31
57
  });
58
+ // ipns over libp2p-fetch feature
59
+ if (this.libp2p.services.fetch != null) {
60
+ try {
61
+ this.libp2p.services.pubsub.addEventListener('subscription-change', (evt) => {
62
+ const { peerId, subscriptions } = evt.detail;
63
+ if (!this.fetchPeers.has(peerId)) {
64
+ return;
65
+ }
66
+ for (const sub of subscriptions) {
67
+ if (!this.subscriptions.has(sub.topic)) {
68
+ continue;
69
+ }
70
+ if (sub.subscribe === false) {
71
+ continue;
72
+ }
73
+ log('peer %s joined topic %s', peerId, sub.topic);
74
+ const routingKey = topicToKey(sub.topic);
75
+ this.#fetchFromPeer(sub.topic, routingKey, peerId, {
76
+ signal: this.shutdownController.signal
77
+ })
78
+ .catch(err => {
79
+ log.error('failed to fetch IPNS record for %m from peer %s - %e', routingKey, peerId, err);
80
+ });
81
+ }
82
+ });
83
+ this.libp2p.services.fetch.registerLookupFunction(IPNS_STRING_PREFIX, async (key) => {
84
+ try {
85
+ const { record } = await this.localStore.get(key, {
86
+ signal: this.shutdownController.signal
87
+ });
88
+ return record;
89
+ }
90
+ catch (err) {
91
+ if (err.name !== 'NotFoundError') {
92
+ throw err;
93
+ }
94
+ }
95
+ });
96
+ log('registered lookup function for IPNS with libp2p/fetch service');
97
+ }
98
+ catch (e) {
99
+ log('unable to register lookup function for IPNS with libp2p/fetch service - %e', e);
100
+ }
101
+ }
102
+ else {
103
+ log('no libp2p/fetch service found. Skipping registration of lookup function for IPNS.');
104
+ }
32
105
  }
33
- async #processPubSubMessage(message) {
106
+ async #processPubSubMessage(message, options) {
34
107
  log('message received for topic', message.topic);
35
108
  if (message.type !== 'signed') {
36
109
  log.error('unsigned message received, this module can only work with signed messages');
37
110
  return;
38
111
  }
39
- if (message.from.equals(this.peerId)) {
112
+ if (message.from.equals(this.libp2p.peerId)) {
40
113
  log('not storing record from self');
41
114
  return;
42
115
  }
43
- const routingKey = topicToKey(message.topic);
44
- await ipnsValidator(routingKey, message.data);
116
+ await this.#handleRecord(message.topic, topicToKey(message.topic), message.data, false, options);
117
+ }
118
+ async #fetchFromPeer(topic, routingKey, peerId, options) {
119
+ const marshalledRecord = await this.fetchQueue.add(async ({ signal }) => {
120
+ log('fetching ipns record for %m from peer %s', routingKey, peerId);
121
+ const sig = anySignal([
122
+ signal,
123
+ AbortSignal.timeout(this.fetchTimeout)
124
+ ]);
125
+ try {
126
+ return await this.libp2p.services.fetch?.fetch(peerId, routingKey, {
127
+ signal: sig
128
+ });
129
+ }
130
+ finally {
131
+ sig.clear();
132
+ }
133
+ }, options);
134
+ if (marshalledRecord == null) {
135
+ throw new NotFoundError(`Peer ${peerId} did not have record for routing key ${uint8ArrayToString(routingKey, 'base64')}`);
136
+ }
137
+ log('fetched ipns record for %m from peer %s', routingKey, peerId);
138
+ return this.#handleRecord(topic, routingKey, marshalledRecord, true, options);
139
+ }
140
+ async #handleRecord(topic, routingKey, marshalledRecord, publish, options) {
141
+ await ipnsValidator(routingKey, marshalledRecord);
142
+ this.shutdownController.signal.throwIfAborted();
45
143
  if (await this.localStore.has(routingKey)) {
46
- const { record: currentRecord } = await this.localStore.get(routingKey);
47
- if (uint8ArrayEquals(currentRecord, message.data)) {
48
- log('not storing record as we already have it');
49
- return;
144
+ const { record: currentRecord } = await this.localStore.get(routingKey, options);
145
+ if (uint8ArrayEquals(currentRecord, marshalledRecord)) {
146
+ log.trace('found identical record for %m', routingKey);
147
+ return currentRecord;
50
148
  }
51
- const records = [currentRecord, message.data];
149
+ const records = [currentRecord, marshalledRecord];
52
150
  const index = ipnsSelector(routingKey, records);
53
151
  if (index === 0) {
54
- log('not storing record as the one we have is better');
55
- return;
152
+ log.trace('found old record for %m', routingKey);
153
+ return currentRecord;
154
+ }
155
+ }
156
+ log('found new record for %m', routingKey);
157
+ await this.localStore.put(routingKey, marshalledRecord, options);
158
+ // if the record was received via fetch, republish it
159
+ if (publish) {
160
+ log('publish value for topic %s', topic);
161
+ try {
162
+ const result = await this.libp2p.services.pubsub.publish(topic, marshalledRecord);
163
+ log('published record on topic %s to %d recipients', topic, result.recipients);
164
+ }
165
+ catch (err) {
166
+ log.error('could not publish record on topic %s - %e', err);
56
167
  }
57
168
  }
58
- await this.localStore.put(routingKey, message.data);
169
+ return marshalledRecord;
59
170
  }
60
171
  /**
61
172
  * Put a value to the pubsub datastore indexed by the received key properly encoded
@@ -64,7 +175,8 @@ class PubSubRouting {
64
175
  try {
65
176
  const topic = keyToTopic(routingKey);
66
177
  log('publish value for topic %s', topic);
67
- const result = await this.pubsub.publish(topic, marshaledRecord);
178
+ const result = await this.libp2p.services.pubsub.publish(topic, marshaledRecord);
179
+ options?.signal?.throwIfAborted();
68
180
  log('published record on topic %s to %d recipients', topic, result.recipients);
69
181
  options.onProgress?.(new CustomProgressEvent('ipns:pubsub:publish', { topic, result }));
70
182
  }
@@ -79,29 +191,53 @@ class PubSubRouting {
79
191
  * updated once new publishes occur
80
192
  */
81
193
  async get(routingKey, options = {}) {
194
+ const topic = keyToTopic(routingKey);
82
195
  try {
83
- const topic = keyToTopic(routingKey);
84
196
  // ensure we are subscribed to topic
85
- if (!this.pubsub.getTopics().includes(topic)) {
197
+ if (!this.libp2p.services.pubsub.getTopics().includes(topic)) {
86
198
  log('add subscription for topic', topic);
87
- this.pubsub.subscribe(topic);
88
- this.subscriptions.push(topic);
199
+ this.libp2p.services.pubsub.subscribe(topic);
200
+ this.subscriptions.add(topic);
89
201
  options.onProgress?.(new CustomProgressEvent('ipns:pubsub:subscribe', { topic }));
90
202
  }
91
- // chain through to local store
92
- const { record } = await this.localStore.get(routingKey, options);
93
- return record;
94
203
  }
95
204
  catch (err) {
96
205
  options.onProgress?.(new CustomProgressEvent('ipns:pubsub:error', err));
97
206
  throw err;
98
207
  }
208
+ // delay before fetch to allow pubsub to resolve
209
+ await raceSignal(delay(this.fetchDelay), this.shutdownController.signal);
210
+ const fetchController = new AbortController();
211
+ const promises = [];
212
+ for (const peerId of this.libp2p.services.pubsub.getSubscribers(topic)) {
213
+ const signal = anySignal([
214
+ options?.signal,
215
+ fetchController.signal
216
+ ]);
217
+ promises.push(this.#fetchFromPeer(topic, routingKey, peerId, {
218
+ ...options,
219
+ signal
220
+ })
221
+ .finally(() => {
222
+ signal.clear();
223
+ }));
224
+ }
225
+ if (promises.length > 0) {
226
+ // fetch record from topic peers
227
+ const record = await Promise.any(promises);
228
+ // cancel any in-flight requests
229
+ fetchController.abort();
230
+ if (record != null) {
231
+ return record;
232
+ }
233
+ }
234
+ throw new NotFoundError('Pubsub routing does not actively query peers');
99
235
  }
100
236
  /**
101
237
  * Get pubsub subscriptions related to ipns
102
238
  */
103
239
  getSubscriptions() {
104
- return this.subscriptions;
240
+ return [...this.subscriptions];
105
241
  }
106
242
  /**
107
243
  * Cancel pubsub subscriptions related to ipns
@@ -111,15 +247,38 @@ class PubSubRouting {
111
247
  const routingKey = multihashToIPNSRoutingKey(digest);
112
248
  const topic = keyToTopic(routingKey);
113
249
  // Not found topic
114
- if (!this.subscriptions.includes(topic)) {
250
+ if (!this.subscriptions.has(topic)) {
115
251
  return;
116
252
  }
117
- this.pubsub.unsubscribe(topic);
118
- this.subscriptions = this.subscriptions.filter(t => t !== topic);
253
+ this.libp2p.services.pubsub.unsubscribe(topic);
254
+ this.subscriptions.delete(topic);
119
255
  }
120
256
  toString() {
121
257
  return 'PubSubRouting()';
122
258
  }
259
+ async start() {
260
+ this.shutdownController = new AbortController();
261
+ setMaxListeners(Infinity, this.shutdownController.signal);
262
+ if (this.libp2p.services.fetch != null) {
263
+ this.fetchTopologyId = await this.libp2p.register(this.libp2p.services.fetch.protocol, {
264
+ onConnect: (peerId) => {
265
+ this.fetchPeers.add(peerId);
266
+ },
267
+ onDisconnect: (peerId) => {
268
+ this.fetchPeers.delete(peerId);
269
+ }
270
+ }, {
271
+ signal: this.shutdownController.signal
272
+ });
273
+ }
274
+ }
275
+ stop() {
276
+ this.fetchQueue.abort();
277
+ this.shutdownController.abort();
278
+ if (this.fetchTopologyId != null) {
279
+ this.libp2p.unregister(this.fetchTopologyId);
280
+ }
281
+ }
123
282
  }
124
283
  const PUBSUB_NAMESPACE = '/record/';
125
284
  /**
@@ -147,7 +306,7 @@ function topicToKey(topic) {
147
306
  * updated records, so the first call to `.get` should be expected
148
307
  * to fail!
149
308
  */
150
- export function pubsub(components) {
151
- return new PubSubRouting(components);
309
+ export function pubsub(components, init = {}) {
310
+ return new PubSubRouting(components, init);
152
311
  }
153
312
  //# sourceMappingURL=pubsub.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pubsub.js","sourceRoot":"","sources":["../../../src/routing/pubsub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,MAAM,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE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;AACH,SAAS,UAAU,CAAE,GAAe;IAClC,MAAM,MAAM,GAAG,kBAAkB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAEnD,OAAO,GAAG,gBAAgB,GAAG,MAAM,EAAE,CAAA;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAE,KAAa;IAChC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAAK,gBAAgB,EAAE,CAAC;QACrE,MAAM,IAAI,iBAAiB,CAAC,qCAAqC,CAAC,CAAA;IACpE,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAEpD,OAAO,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAE,UAAmC,EAAE,OAA0B,EAAE;IACvF,OAAO,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/ipns",
3
- "version": "9.1.9",
3
+ "version": "9.2.0",
4
4
  "description": "An implementation of IPNS for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/ipns#readme",
@@ -73,28 +73,33 @@
73
73
  "test:electron-main": "aegir test -t electron-main"
74
74
  },
75
75
  "dependencies": {
76
- "@helia/interface": "^6.1.1",
76
+ "@helia/interface": "^6.2.0",
77
77
  "@libp2p/crypto": "^5.1.7",
78
- "@libp2p/interface": "^3.1.0",
78
+ "@libp2p/fetch": "^4.1.0",
79
+ "@libp2p/interface": "^3.2.0",
79
80
  "@libp2p/kad-dht": "^16.1.0",
80
81
  "@libp2p/keychain": "^6.0.5",
81
82
  "@libp2p/logger": "^6.0.5",
83
+ "@libp2p/peer-collections": "^7.0.14",
82
84
  "@libp2p/utils": "^7.0.5",
85
+ "any-signal": "^4.2.0",
86
+ "delay": "^7.0.0",
83
87
  "interface-datastore": "^9.0.2",
84
88
  "ipns": "^10.1.2",
85
89
  "multiformats": "^13.4.1",
86
90
  "progress-events": "^1.0.1",
87
- "protons-runtime": "^5.5.0",
91
+ "protons-runtime": "^6.0.1",
92
+ "race-signal": "^2.0.0",
88
93
  "uint8arraylist": "^2.4.8",
89
94
  "uint8arrays": "^5.1.0"
90
95
  },
91
96
  "devDependencies": {
92
97
  "@libp2p/crypto": "^5.1.12",
93
- "@libp2p/peer-id": "^6.0.3",
98
+ "@libp2p/peer-id": "^6.0.6",
94
99
  "aegir": "^47.0.22",
95
100
  "datastore-core": "^11.0.2",
96
101
  "it-drain": "^3.0.10",
97
- "protons": "^7.6.1",
102
+ "protons": "^8.1.1",
98
103
  "sinon": "^21.0.0",
99
104
  "sinon-ts": "^2.0.0"
100
105
  },
package/src/index.ts CHANGED
@@ -181,13 +181,13 @@
181
181
 
182
182
  import { ipnsValidator } from 'ipns/validator'
183
183
  import { CID } from 'multiformats/cid'
184
- import { IPNSResolver as IPNSResolverClass } from './ipns/resolver.js'
185
- import { IPNS as IPNSClass } from './ipns.js'
184
+ import { IPNSResolver as IPNSResolverClass } from './ipns/resolver.ts'
185
+ import { IPNS as IPNSClass } from './ipns.ts'
186
186
  import { localStore } from './local-store.ts'
187
- import { helia } from './routing/index.js'
187
+ import { helia } from './routing/index.ts'
188
188
  import { localStoreRouting } from './routing/local-store.ts'
189
- import type { IPNSResolverComponents } from './ipns/resolver.js'
190
- import type { IPNSRouting, IPNSRoutingProgressEvents } from './routing/index.js'
189
+ import type { IPNSResolverComponents } from './ipns/resolver.ts'
190
+ import type { IPNSRouting, IPNSRoutingProgressEvents } from './routing/index.ts'
191
191
  import type { Routing, HeliaEvents } from '@helia/interface'
192
192
  import type { AbortOptions, ComponentLogger, Libp2p, PeerId, PublicKey, TypedEventEmitter } from '@libp2p/interface'
193
193
  import type { Keychain } from '@libp2p/keychain'
@@ -355,7 +355,7 @@ export interface IPNS {
355
355
  unpublish(keyName: string, options?: AbortOptions): Promise<void>
356
356
  }
357
357
 
358
- export type { IPNSRouting } from './routing/index.js'
358
+ export type { IPNSRouting } from './routing/index.ts'
359
359
 
360
360
  export type { IPNSRecord } from 'ipns'
361
361
 
@@ -4,9 +4,9 @@ import { createIPNSRecord, marshalIPNSRecord, multihashToIPNSRoutingKey, unmarsh
4
4
  import { CID } from 'multiformats/cid'
5
5
  import { CustomProgressEvent } from 'progress-events'
6
6
  import { DEFAULT_LIFETIME_MS, DEFAULT_TTL_NS } from '../constants.ts'
7
- import type { IPNSPublishResult, PublishOptions } from '../index.js'
8
- import type { LocalStore } from '../local-store.js'
9
- import type { IPNSRouting } from '../routing/index.js'
7
+ import type { IPNSPublishResult, PublishOptions } from '../index.ts'
8
+ import type { LocalStore } from '../local-store.ts'
9
+ import type { IPNSRouting } from '../routing/index.ts'
10
10
  import type { AbortOptions, ComponentLogger, Libp2p, PeerId, PrivateKey, PublicKey } from '@libp2p/interface'
11
11
  import type { Keychain } from '@libp2p/keychain'
12
12
  import type { Datastore } from 'interface-datastore'
@@ -1,9 +1,9 @@
1
1
  import { Queue, repeatingTask } from '@libp2p/utils'
2
2
  import { createIPNSRecord, marshalIPNSRecord, unmarshalIPNSRecord } from 'ipns'
3
3
  import { DEFAULT_REPUBLISH_CONCURRENCY, DEFAULT_REPUBLISH_INTERVAL_MS, DEFAULT_TTL_NS } from '../constants.ts'
4
- import { shouldRepublish } from '../utils.js'
5
- import type { LocalStore } from '../local-store.js'
6
- import type { IPNSRouting } from '../routing/index.js'
4
+ import { shouldRepublish } from '../utils.ts'
5
+ import type { LocalStore } from '../local-store.ts'
6
+ import type { IPNSRouting } from '../routing/index.ts'
7
7
  import type { AbortOptions, ComponentLogger, Libp2p, Logger, PrivateKey } from '@libp2p/interface'
8
8
  import type { Keychain } from '@libp2p/keychain'
9
9
  import type { RepeatingTask } from '@libp2p/utils'
@@ -7,11 +7,11 @@ import { base58btc } from 'multiformats/bases/base58'
7
7
  import { CID } from 'multiformats/cid'
8
8
  import * as Digest from 'multiformats/hashes/digest'
9
9
  import { DEFAULT_TTL_NS } from '../constants.ts'
10
- import { InvalidValueError, RecordNotFoundError, RecordsFailedValidationError, UnsupportedMultibasePrefixError, UnsupportedMultihashCodecError } from '../errors.js'
11
- import { isCodec, IDENTITY_CODEC, SHA2_256_CODEC, isLibp2pCID } from '../utils.js'
12
- import type { IPNSResolveResult, ResolveOptions, ResolveResult } from '../index.js'
13
- import type { LocalStore } from '../local-store.js'
14
- import type { IPNSRouting } from '../routing/index.js'
10
+ import { InvalidValueError, RecordNotFoundError, RecordsFailedValidationError, UnsupportedMultibasePrefixError, UnsupportedMultihashCodecError } from '../errors.ts'
11
+ import { isCodec, IDENTITY_CODEC, SHA2_256_CODEC, isLibp2pCID } from '../utils.ts'
12
+ import type { IPNSResolveResult, ResolveOptions, ResolveResult } from '../index.ts'
13
+ import type { LocalStore } from '../local-store.ts'
14
+ import type { IPNSRouting } from '../routing/index.ts'
15
15
  import type { Routing } from '@helia/interface'
16
16
  import type { ComponentLogger, Logger, PeerId, PublicKey } from '@libp2p/interface'
17
17
  import type { Datastore } from 'interface-datastore'
package/src/ipns.ts CHANGED
@@ -2,12 +2,12 @@ import { CID } from 'multiformats/cid'
2
2
  import { IPNSPublisher } from './ipns/publisher.ts'
3
3
  import { IPNSRepublisher } from './ipns/republisher.ts'
4
4
  import { IPNSResolver } from './ipns/resolver.ts'
5
- import { localStore } from './local-store.js'
6
- import { helia } from './routing/helia.js'
5
+ import { localStore } from './local-store.ts'
6
+ import { helia } from './routing/helia.ts'
7
7
  import { localStoreRouting } from './routing/local-store.ts'
8
- import type { IPNSComponents, IPNS as IPNSInterface, IPNSOptions, IPNSPublishResult, IPNSResolveResult, PublishOptions, ResolveOptions } from './index.js'
9
- import type { LocalStore } from './local-store.js'
10
- import type { IPNSRouting } from './routing/index.js'
8
+ import type { IPNSComponents, IPNS as IPNSInterface, IPNSOptions, IPNSPublishResult, IPNSResolveResult, PublishOptions, ResolveOptions } from './index.ts'
9
+ import type { LocalStore } from './local-store.ts'
10
+ import type { IPNSRouting } from './routing/index.ts'
11
11
  import type { AbortOptions, PeerId, PublicKey, Startable } from '@libp2p/interface'
12
12
  import type { MultihashDigest } from 'multiformats/hashes/interface'
13
13
 
@@ -2,9 +2,9 @@ import { Record } from '@libp2p/kad-dht'
2
2
  import { CustomProgressEvent } from 'progress-events'
3
3
  import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
4
4
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
5
- import { IPNSPublishMetadata } from './pb/metadata.js'
6
- import { dhtRoutingKey, DHT_RECORD_PREFIX, ipnsMetadataKey } from './utils.js'
7
- import type { DatastoreProgressEvents, GetOptions, PutOptions } from './routing/index.js'
5
+ import { IPNSPublishMetadata } from './pb/metadata.ts'
6
+ import { dhtRoutingKey, DHT_RECORD_PREFIX, ipnsMetadataKey } from './utils.ts'
7
+ import type { DatastoreProgressEvents, GetOptions, PutOptions } from './routing/index.ts'
8
8
  import type { AbortOptions, Logger } from '@libp2p/interface'
9
9
  import type { Datastore } from 'interface-datastore'
10
10
 
@@ -1,4 +1,4 @@
1
- import { decodeMessage, encodeMessage, message } from 'protons-runtime'
1
+ import { decodeMessage, encodeMessage, message, streamMessage } from 'protons-runtime'
2
2
  import type { Codec, DecodeOptions } from 'protons-runtime'
3
3
  import type { Uint8ArrayList } from 'uint8arraylist'
4
4
 
@@ -58,17 +58,58 @@ export namespace IPNSPublishMetadata {
58
58
  }
59
59
 
60
60
  return obj
61
+ }, function * (reader, length, prefix, opts = {}) {
62
+ const end = length == null ? reader.len : reader.pos + length
63
+
64
+ while (reader.pos < end) {
65
+ const tag = reader.uint32()
66
+
67
+ switch (tag >>> 3) {
68
+ case 1: {
69
+ yield {
70
+ field: `${prefix}.keyName`,
71
+ value: reader.string()
72
+ }
73
+ break
74
+ }
75
+ case 2: {
76
+ yield {
77
+ field: `${prefix}.lifetime`,
78
+ value: reader.uint32()
79
+ }
80
+ break
81
+ }
82
+ default: {
83
+ reader.skipType(tag & 7)
84
+ break
85
+ }
86
+ }
87
+ }
61
88
  })
62
89
  }
63
90
 
64
91
  return _codec
65
92
  }
66
93
 
67
- export const encode = (obj: Partial<IPNSPublishMetadata>): Uint8Array => {
94
+ export interface IPNSPublishMetadataKeyNameFieldEvent {
95
+ field: '$.keyName'
96
+ value: string
97
+ }
98
+
99
+ export interface IPNSPublishMetadataLifetimeFieldEvent {
100
+ field: '$.lifetime'
101
+ value: number
102
+ }
103
+
104
+ export function encode (obj: Partial<IPNSPublishMetadata>): Uint8Array {
68
105
  return encodeMessage(obj, IPNSPublishMetadata.codec())
69
106
  }
70
107
 
71
- export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPNSPublishMetadata>): IPNSPublishMetadata => {
108
+ export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPNSPublishMetadata>): IPNSPublishMetadata {
72
109
  return decodeMessage(buf, IPNSPublishMetadata.codec(), opts)
73
110
  }
111
+
112
+ export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPNSPublishMetadata>): Generator<IPNSPublishMetadataKeyNameFieldEvent | IPNSPublishMetadataLifetimeFieldEvent> {
113
+ return streamMessage(buf, IPNSPublishMetadata.codec(), opts)
114
+ }
74
115
  }
@@ -1,6 +1,6 @@
1
1
  import { CustomProgressEvent } from 'progress-events'
2
- import type { GetOptions, PutOptions } from './index.js'
3
- import type { IPNSRouting } from '../index.js'
2
+ import type { GetOptions, PutOptions } from './index.ts'
3
+ import type { IPNSRouting } from '../index.ts'
4
4
  import type { Routing } from '@helia/interface'
5
5
  import type { ProgressEvent } from 'progress-events'
6
6
 
@@ -1,6 +1,6 @@
1
- import type { HeliaRoutingProgressEvents } from './helia.js'
2
- import type { DatastoreProgressEvents } from '../index.js'
3
- import type { PubSubProgressEvents } from './pubsub.js'
1
+ import type { HeliaRoutingProgressEvents } from './helia.ts'
2
+ import type { DatastoreProgressEvents } from '../index.ts'
3
+ import type { PubSubProgressEvents } from './pubsub.ts'
4
4
  import type { IPNSPublishMetadata } from '../pb/metadata.ts'
5
5
  import type { AbortOptions } from '@libp2p/interface'
6
6
  import type { ProgressOptions } from 'progress-events'
@@ -32,6 +32,6 @@ export type IPNSRoutingProgressEvents =
32
32
  HeliaRoutingProgressEvents |
33
33
  PubSubProgressEvents
34
34
 
35
- export { helia } from './helia.js'
36
- export { pubsub } from './pubsub.js'
37
- export type { PubsubRoutingComponents, PubSub, Message, PublishResult, PubSubEvents } from './pubsub.js'
35
+ export { helia } from './helia.ts'
36
+ export { pubsub } from './pubsub.ts'
37
+ export type { PubsubRoutingComponents, PubSub, Message, PublishResult, PubSubEvents } from './pubsub.ts'