@helia/ipns 9.2.1-35b081c7 → 9.2.1-73a28eda

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.
Files changed (68) hide show
  1. package/README.md +12 -49
  2. package/dist/index.min.js +5 -16
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/errors.d.ts +33 -5
  5. package/dist/src/errors.d.ts.map +1 -1
  6. package/dist/src/errors.js +33 -20
  7. package/dist/src/errors.js.map +1 -1
  8. package/dist/src/index.d.ts +53 -91
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +12 -52
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/ipns/publisher.d.ts +5 -9
  13. package/dist/src/ipns/publisher.d.ts.map +1 -1
  14. package/dist/src/ipns/publisher.js +30 -22
  15. package/dist/src/ipns/publisher.js.map +1 -1
  16. package/dist/src/ipns/republisher.d.ts +3 -5
  17. package/dist/src/ipns/republisher.d.ts.map +1 -1
  18. package/dist/src/ipns/republisher.js +18 -9
  19. package/dist/src/ipns/republisher.js.map +1 -1
  20. package/dist/src/ipns/resolver.d.ts +6 -5
  21. package/dist/src/ipns/resolver.d.ts.map +1 -1
  22. package/dist/src/ipns/resolver.js +32 -78
  23. package/dist/src/ipns/resolver.js.map +1 -1
  24. package/dist/src/ipns.d.ts +6 -4
  25. package/dist/src/ipns.d.ts.map +1 -1
  26. package/dist/src/ipns.js +33 -4
  27. package/dist/src/ipns.js.map +1 -1
  28. package/dist/src/pb/ipns.d.ts +62 -0
  29. package/dist/src/pb/ipns.d.ts.map +1 -0
  30. package/dist/src/pb/ipns.js +203 -0
  31. package/dist/src/pb/ipns.js.map +1 -0
  32. package/dist/src/pb/metadata.d.ts +1 -1
  33. package/dist/src/pb/metadata.d.ts.map +1 -1
  34. package/dist/src/records.d.ts +155 -0
  35. package/dist/src/records.d.ts.map +1 -0
  36. package/dist/src/records.js +88 -0
  37. package/dist/src/records.js.map +1 -0
  38. package/dist/src/routing/pubsub.d.ts +3 -0
  39. package/dist/src/routing/pubsub.d.ts.map +1 -1
  40. package/dist/src/routing/pubsub.js +15 -10
  41. package/dist/src/routing/pubsub.js.map +1 -1
  42. package/dist/src/selector.d.ts +14 -0
  43. package/dist/src/selector.d.ts.map +1 -0
  44. package/dist/src/selector.js +47 -0
  45. package/dist/src/selector.js.map +1 -0
  46. package/dist/src/utils.d.ts +29 -2
  47. package/dist/src/utils.d.ts.map +1 -1
  48. package/dist/src/utils.js +308 -0
  49. package/dist/src/utils.js.map +1 -1
  50. package/dist/src/validator.d.ts +18 -0
  51. package/dist/src/validator.d.ts.map +1 -0
  52. package/dist/src/validator.js +58 -0
  53. package/dist/src/validator.js.map +1 -0
  54. package/package.json +18 -17
  55. package/src/errors.ts +40 -25
  56. package/src/index.ts +54 -92
  57. package/src/ipns/publisher.ts +34 -29
  58. package/src/ipns/republisher.ts +24 -13
  59. package/src/ipns/resolver.ts +40 -88
  60. package/src/ipns.ts +44 -7
  61. package/src/pb/ipns.proto +39 -0
  62. package/src/pb/ipns.ts +280 -0
  63. package/src/pb/metadata.ts +1 -1
  64. package/src/records.ts +273 -0
  65. package/src/routing/pubsub.ts +17 -10
  66. package/src/selector.ts +55 -0
  67. package/src/utils.ts +371 -2
  68. package/src/validator.ts +67 -0
@@ -1,25 +1,53 @@
1
1
  export declare class RecordsFailedValidationError extends Error {
2
2
  static name: string;
3
- constructor(message?: string);
3
+ name: string;
4
4
  }
5
5
  export declare class UnsupportedMultibasePrefixError extends Error {
6
6
  static name: string;
7
- constructor(message?: string);
7
+ name: string;
8
8
  }
9
9
  export declare class UnsupportedMultihashCodecError extends Error {
10
10
  static name: string;
11
- constructor(message?: string);
11
+ name: string;
12
12
  }
13
13
  export declare class InvalidValueError extends Error {
14
14
  static name: string;
15
- constructor(message?: string);
15
+ name: string;
16
16
  }
17
17
  export declare class InvalidTopicError extends Error {
18
18
  static name: string;
19
- constructor(message?: string);
19
+ name: string;
20
20
  }
21
21
  export declare class RecordNotFoundError extends Error {
22
22
  static name: string;
23
23
  name: string;
24
24
  }
25
+ export declare class SignatureCreationError extends Error {
26
+ static name: string;
27
+ name: string;
28
+ }
29
+ export declare class SignatureVerificationError extends Error {
30
+ static name: string;
31
+ name: string;
32
+ }
33
+ export declare class RecordExpiredError extends Error {
34
+ static name: string;
35
+ name: string;
36
+ }
37
+ export declare class UnsupportedValidityError extends Error {
38
+ static name: string;
39
+ name: string;
40
+ }
41
+ export declare class RecordTooLargeError extends Error {
42
+ static name: string;
43
+ name: string;
44
+ }
45
+ export declare class InvalidRecordDataError extends Error {
46
+ static name: string;
47
+ name: string;
48
+ }
49
+ export declare class InvalidEmbeddedPublicKeyError extends Error {
50
+ static name: string;
51
+ name: string;
52
+ }
25
53
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,MAAM,CAAC,IAAI,SAAiC;gBAE/B,OAAO,SAA8B;CAInD;AAED,qBAAa,+BAAgC,SAAQ,KAAK;IACxD,MAAM,CAAC,IAAI,SAAoC;gBAElC,OAAO,SAAiC;CAItD;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,IAAI,SAAmC;gBAEjC,OAAO,SAAgC;CAIrD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,SAAwB;IACnC,IAAI,SAAwB;CAC7B"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,4BAA6B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name = 'RecordsFailedValidationError';
3
- constructor(message = 'Records failed validation') {
4
- super(message);
5
- this.name = 'RecordsFailedValidationError';
6
- }
3
+ name = 'RecordsFailedValidationError';
7
4
  }
8
5
  export class UnsupportedMultibasePrefixError extends Error {
9
6
  static name = 'UnsupportedMultibasePrefixError';
10
- constructor(message = 'Unsupported multibase prefix') {
11
- super(message);
12
- this.name = 'UnsupportedMultibasePrefixError';
13
- }
7
+ name = 'UnsupportedMultibasePrefixError';
14
8
  }
15
9
  export class UnsupportedMultihashCodecError extends Error {
16
10
  static name = 'UnsupportedMultihashCodecError';
17
- constructor(message = 'Unsupported multihash codec') {
18
- super(message);
19
- this.name = 'UnsupportedMultihashCodecError';
20
- }
11
+ name = 'UnsupportedMultihashCodecError';
21
12
  }
22
13
  export class InvalidValueError extends Error {
23
14
  static name = 'InvalidValueError';
24
- constructor(message = 'Invalid value') {
25
- super(message);
26
- this.name = 'InvalidValueError';
27
- }
15
+ name = 'InvalidValueError';
28
16
  }
29
17
  export class InvalidTopicError extends Error {
30
18
  static name = 'InvalidTopicError';
31
- constructor(message = 'Invalid topic') {
32
- super(message);
33
- this.name = 'InvalidTopicError';
34
- }
19
+ name = 'InvalidTopicError';
35
20
  }
36
21
  export class RecordNotFoundError extends Error {
37
22
  static name = 'RecordNotFoundError';
38
23
  name = 'RecordNotFoundError';
39
24
  }
25
+ export class SignatureCreationError extends Error {
26
+ static name = 'SignatureCreationError';
27
+ name = 'SignatureCreationError';
28
+ }
29
+ export class SignatureVerificationError extends Error {
30
+ static name = 'SignatureVerificationError';
31
+ name = 'SignatureVerificationError';
32
+ }
33
+ export class RecordExpiredError extends Error {
34
+ static name = 'RecordExpiredError';
35
+ name = 'RecordExpiredError';
36
+ }
37
+ export class UnsupportedValidityError extends Error {
38
+ static name = 'UnsupportedValidityError';
39
+ name = 'UnsupportedValidityError';
40
+ }
41
+ export class RecordTooLargeError extends Error {
42
+ static name = 'RecordTooLargeError';
43
+ name = 'RecordTooLargeError';
44
+ }
45
+ export class InvalidRecordDataError extends Error {
46
+ static name = 'InvalidRecordDataError';
47
+ name = 'InvalidRecordDataError';
48
+ }
49
+ export class InvalidEmbeddedPublicKeyError extends Error {
50
+ static name = 'InvalidEmbeddedPublicKeyError';
51
+ name = 'InvalidEmbeddedPublicKeyError';
52
+ }
40
53
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD,MAAM,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAE5C,YAAa,OAAO,GAAG,2BAA2B;QAChD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAC5C,CAAC;;AAGH,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACxD,MAAM,CAAC,IAAI,GAAG,iCAAiC,CAAA;IAE/C,YAAa,OAAO,GAAG,8BAA8B;QACnD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAA;IAC/C,CAAC;;AAGH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,IAAI,GAAG,gCAAgC,CAAA;IAE9C,YAAa,OAAO,GAAG,6BAA6B;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAA;IAC9C,CAAC;;AAGH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAEjC,YAAa,OAAO,GAAG,eAAe;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;;AAGH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAE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IAC1C,IAAI,GAAG,4BAA4B,CAAA;;AAGrC,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,MAAM,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,IAAI,GAAG,oBAAoB,CAAA;;AAG7B,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,MAAM,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,IAAI,GAAG,0BAA0B,CAAA;;AAGnC,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,IAAI,GAAG,qBAAqB,CAAA;;AAG9B,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,MAAM,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,IAAI,GAAG,wBAAwB,CAAA;;AAGjC,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,MAAM,CAAC,IAAI,GAAG,+BAA+B,CAAA;IAC7C,IAAI,GAAG,+BAA+B,CAAA"}
@@ -23,9 +23,9 @@
23
23
  * const { publicKey } = await name.publish('key-1', cid)
24
24
  *
25
25
  * // resolve the name
26
- * const result = await name.resolve(publicKey)
27
- *
28
- * console.info(result.cid, result.path)
26
+ * for await (const result of name.resolve(publicKey)) {
27
+ * console.info(result.record.value) // /ipfs/QmFoo
28
+ * }
29
29
  * ```
30
30
  *
31
31
  * @example Publishing a recursive record
@@ -53,8 +53,9 @@
53
53
  * const { publicKey: recursivePublicKey } = await name.publish('key-2', publicKey)
54
54
  *
55
55
  * // resolve the name recursively - it resolves until a CID is found
56
- * const result = await name.resolve(recursivePublicKey)
57
- * console.info(result.cid.toString() === cid.toString()) // true
56
+ * for await (const result of name.resolve(recursivePublicKey)) {
57
+ * console.info(result.record.value) // /ipfs/QmFoo../foo.txt
58
+ * }
58
59
  * ```
59
60
  *
60
61
  * @example Publishing a record with a path
@@ -82,9 +83,9 @@
82
83
  * const { publicKey } = await name.publish('key-1', `/ipfs/${finalDirCid}/foo.txt`)
83
84
  *
84
85
  * // resolve the name
85
- * const result = await name.resolve(publicKey)
86
- *
87
- * console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
86
+ * for await (const result of name.resolve(publicKey)) {
87
+ * console.info(result.record.value) // /ipfs/QmFoo../foo.txt
88
+ * }
88
89
  * ```
89
90
  *
90
91
  * @example Using custom PubSub router
@@ -135,58 +136,19 @@
135
136
  * const { publicKey } = await name.publish('key-1', cid)
136
137
  *
137
138
  * // resolve the name
138
- * const result = await name.resolve(publicKey)
139
- * ```
140
- *
141
- * @example Republishing an existing IPNS record
142
- *
143
- * It is sometimes useful to be able to republish an existing IPNS record
144
- * without needing the private key. This allows you to extend the availability
145
- * of a record that was created elsewhere.
146
- *
147
- * ```TypeScript
148
- * import { createHelia } from 'helia'
149
- * import { ipns, ipnsValidator } from '@helia/ipns'
150
- * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
151
- * import { CID } from 'multiformats/cid'
152
- * import { multihashToIPNSRoutingKey, marshalIPNSRecord } from 'ipns'
153
- * import { defaultLogger } from '@libp2p/logger'
154
- *
155
- * const helia = await createHelia()
156
- * const name = ipns(helia)
157
- *
158
- * const ipnsName = 'k51qzi5uqu5dktsyfv7xz8h631pri4ct7osmb43nibxiojpttxzoft6hdyyzg4'
159
- * const parsedCid: CID<unknown, 114, 0 | 18, 1> = CID.parse(ipnsName)
160
- * const delegatedClient = delegatedRoutingV1HttpApiClient({
161
- * url: 'https://delegated-ipfs.dev'
162
- * })({
163
- * logger: defaultLogger()
164
- * })
165
- * const record = await delegatedClient.getIPNS(parsedCid)
166
- *
167
- * const routingKey = multihashToIPNSRoutingKey(parsedCid.multihash)
168
- * const marshaledRecord = marshalIPNSRecord(record)
169
- *
170
- * // validate that they key corresponds to the record
171
- * await ipnsValidator(routingKey, marshaledRecord)
172
- *
173
- * // publish record to routing
174
- * await Promise.all(
175
- * name.routers.map(async r => {
176
- * await r.put(routingKey, marshaledRecord)
177
- * })
178
- * )
139
+ * for await (const result of name.resolve(publicKey)) {
140
+ * console.info(result.record.value)
141
+ * }
179
142
  * ```
180
143
  */
181
- import { ipnsValidator } from 'ipns/validator';
182
144
  import { CID } from 'multiformats/cid';
183
145
  import type { IPNSResolverComponents } from './ipns/resolver.ts';
146
+ import type { IPNSRecord } from './records.ts';
184
147
  import type { IPNSRouting, IPNSRoutingProgressEvents } from './routing/index.ts';
185
- import type { Routing, HeliaEvents } from '@helia/interface';
186
- import type { AbortOptions, ComponentLogger, Libp2p, PeerId, PublicKey, TypedEventEmitter } from '@libp2p/interface';
187
- import type { Keychain } from '@libp2p/keychain';
148
+ import type { Routing, HeliaEvents, Keychain, PublicKey } from '@helia/interface';
149
+ import type { ComponentLogger, TypedEventEmitter } from '@libp2p/interface';
150
+ import type { AbortOptions } from 'abort-error';
188
151
  import type { Datastore } from 'interface-datastore';
189
- import type { IPNSRecord } from 'ipns';
190
152
  import type { MultihashDigest } from 'multiformats/hashes/interface';
191
153
  import type { ProgressEvent, ProgressOptions } from 'progress-events';
192
154
  export type PublishProgressEvents = ProgressEvent<'ipns:publish:start'> | ProgressEvent<'ipns:publish:success', IPNSRecord> | ProgressEvent<'ipns:publish:error', Error>;
@@ -194,20 +156,28 @@ export type ResolveProgressEvents = ProgressEvent<'ipns:resolve:start', unknown>
194
156
  export type DatastoreProgressEvents = ProgressEvent<'ipns:routing:datastore:put'> | ProgressEvent<'ipns:routing:datastore:get'> | ProgressEvent<'ipns:routing:datastore:list'> | ProgressEvent<'ipns:routing:datastore:error', Error>;
195
157
  export interface PublishOptions extends AbortOptions, ProgressOptions<PublishProgressEvents | IPNSRoutingProgressEvents> {
196
158
  /**
197
- * Time duration of the signature validity in ms (default: 48hrs)
159
+ * Time duration of the signature validity in ms
160
+ *
161
+ * @default 172_800_000
198
162
  */
199
163
  lifetime?: number;
200
164
  /**
201
- * Only publish to a local datastore (default: false)
165
+ * Only publish to a local datastore
166
+ *
167
+ * @default false
202
168
  */
203
169
  offline?: boolean;
204
170
  /**
205
171
  * By default a IPNS V1 and a V2 signature is added to every record. Pass
206
- * false here to only add a V2 signature. (default: true)
172
+ * false here to only add a V2 signature.
173
+ *
174
+ * @default true
207
175
  */
208
176
  v1Compatible?: boolean;
209
177
  /**
210
- * The TTL of the record in ms (default: 5 minutes)
178
+ * The TTL of the record in ms
179
+ *
180
+ * @default 300_000
211
181
  */
212
182
  ttl?: number;
213
183
  }
@@ -230,28 +200,22 @@ export interface ResolveOptions extends AbortOptions, ProgressOptions<ResolvePro
230
200
  nocache?: boolean;
231
201
  }
232
202
  export interface ResolveResult {
233
- /**
234
- * The CID that was resolved
235
- */
236
- cid: CID;
237
- /**
238
- * Any path component that was part of the resolved record
239
- */
240
- path?: string;
241
- }
242
- export interface IPNSResolveResult extends ResolveResult {
243
203
  /**
244
204
  * The resolved record
245
205
  */
246
206
  record: IPNSRecord;
247
207
  }
248
- export interface IPNSPublishResult {
208
+ export interface PublishResult {
249
209
  /**
250
210
  * The published record
251
211
  */
252
212
  record: IPNSRecord;
253
213
  /**
254
- * The public key that was used to publish the record
214
+ * The IPNS name that can be used to resolve this record
215
+ */
216
+ name: string;
217
+ /**
218
+ * The public key that was used to sign and publish the record
255
219
  */
256
220
  publicKey: PublicKey;
257
221
  }
@@ -263,7 +227,7 @@ export interface IPNSResolver {
263
227
  * Ed25519, secp256k1 or RSA PeerId and recursively resolves the IPNS record
264
228
  * corresponding to that key until a value is found.
265
229
  */
266
- resolve(key: CID<unknown, 0x72, 0x00 | 0x12, 1> | PublicKey | MultihashDigest<0x00 | 0x12> | PeerId, options?: ResolveOptions): Promise<IPNSResolveResult>;
230
+ resolve(key: CID<unknown, 0x72> | MultihashDigest, options?: ResolveOptions): AsyncGenerator<ResolveResult>;
267
231
  }
268
232
  export interface IPNS {
269
233
  /**
@@ -274,12 +238,14 @@ export interface IPNS {
274
238
  * Creates and publishes an IPNS record that will resolve the passed value
275
239
  * signed by a key stored in the libp2p keychain under the passed key name.
276
240
  *
241
+ * If the key does not exist, a new Ed25519 key will be created. To use a
242
+ * different key types, ensure the key is created and stored in the keychain
243
+ * before invoking this method.
244
+ *
277
245
  * It is possible to create a recursive IPNS record by passing:
278
246
  *
279
- * - A PeerId,
280
- * - A PublicKey
281
- * - A CID with the libp2p-key codec and Identity or SHA256 hash algorithms
282
- * - A Multihash with the Identity or SHA256 hash algorithms
247
+ * - A CID with the libp2p-key codec
248
+ * - A Multihash
283
249
  * - A string IPNS key (e.g. `/ipns/Qmfoo`)
284
250
  *
285
251
  * @example
@@ -298,35 +264,32 @@ export interface IPNS {
298
264
  * console.info(result) // { answer: ... }
299
265
  * ```
300
266
  */
301
- publish(keyName: string, value: CID | PublicKey | MultihashDigest<0x00 | 0x12> | PeerId | string, options?: PublishOptions): Promise<IPNSPublishResult>;
267
+ publish(keyName: string, value: CID | PublicKey | MultihashDigest | string, options?: PublishOptions): Promise<PublishResult>;
302
268
  /**
303
- * Accepts a libp2p public key, a CID with the libp2p-key codec and either the
304
- * identity hash (for Ed25519 and secp256k1 public keys) or a SHA256 hash (for
305
- * RSA public keys), or the multihash of a libp2p-key encoded CID, or a
306
- * Ed25519, secp256k1 or RSA PeerId and recursively resolves the IPNS record
307
- * corresponding to that key until a value is found.
269
+ * Accepts a multihash of a public key, a libp2p-key CID containing the
270
+ * multihash of a public key, or an IPNS name in it's string representation
271
+ * and recursively resolves IPNS records until a non-recursive record is found
272
+ * (e.g. the value can be parsed as a string that does not start with
273
+ * `/ipns/`).
308
274
  */
309
- resolve(key: CID<unknown, 0x72, 0x00 | 0x12, 1> | PublicKey | MultihashDigest<0x00 | 0x12> | PeerId, options?: ResolveOptions): Promise<IPNSResolveResult>;
275
+ resolve(name: CID<unknown, 0x72> | PublicKey | MultihashDigest | string, options?: ResolveOptions): AsyncGenerator<ResolveResult>;
310
276
  /**
311
277
  * Stop republishing of an IPNS record
312
278
  *
313
- * This will delete the last signed IPNS record from the datastore, but the
314
- * key will remain in the keychain.
279
+ * This will delete the last signed IPNS record from the datastore.
315
280
  *
316
281
  * Note that the record may still be resolved by other peers until it expires
317
- * or is no longer valid.
282
+ * or is otherwise no longer valid.
318
283
  */
319
284
  unpublish(keyName: string, options?: AbortOptions): Promise<void>;
320
285
  }
321
286
  export type { IPNSRouting } from './routing/index.ts';
322
- export type { IPNSRecord } from 'ipns';
287
+ export type { IPNSRecord } from './records.ts';
323
288
  export interface IPNSComponents {
324
289
  datastore: Datastore;
325
290
  routing: Routing;
326
291
  logger: ComponentLogger;
327
- libp2p: Libp2p<{
328
- keychain: Keychain;
329
- }>;
292
+ keychain: Keychain;
330
293
  events: TypedEventEmitter<HeliaEvents>;
331
294
  }
332
295
  export interface IPNSOptions {
@@ -356,6 +319,5 @@ export interface IPNSResolverOptions {
356
319
  }
357
320
  export declare function ipns(components: IPNSComponents, options?: IPNSOptions): IPNS;
358
321
  export declare function ipnsResolver(components: IPNSResolverComponents, options?: IPNSResolverOptions): IPNSResolver;
359
- export { ipnsValidator, type IPNSRoutingProgressEvents };
360
- export { ipnsSelector } from 'ipns/selector';
322
+ export type { IPNSRoutingProgressEvents };
361
323
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmLG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAMtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM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AAI,CAAE,UAAU,EAAE,cAAc,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEjF;AAED,wBAAgB,YAAY,CAAE,UAAU,EAAE,sBAAsB,EAAE,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAYjH;AAED,YAAY,EAAE,yBAAyB,EAAE,CAAA"}
package/dist/src/index.js CHANGED
@@ -23,9 +23,9 @@
23
23
  * const { publicKey } = await name.publish('key-1', cid)
24
24
  *
25
25
  * // resolve the name
26
- * const result = await name.resolve(publicKey)
27
- *
28
- * console.info(result.cid, result.path)
26
+ * for await (const result of name.resolve(publicKey)) {
27
+ * console.info(result.record.value) // /ipfs/QmFoo
28
+ * }
29
29
  * ```
30
30
  *
31
31
  * @example Publishing a recursive record
@@ -53,8 +53,9 @@
53
53
  * const { publicKey: recursivePublicKey } = await name.publish('key-2', publicKey)
54
54
  *
55
55
  * // resolve the name recursively - it resolves until a CID is found
56
- * const result = await name.resolve(recursivePublicKey)
57
- * console.info(result.cid.toString() === cid.toString()) // true
56
+ * for await (const result of name.resolve(recursivePublicKey)) {
57
+ * console.info(result.record.value) // /ipfs/QmFoo../foo.txt
58
+ * }
58
59
  * ```
59
60
  *
60
61
  * @example Publishing a record with a path
@@ -82,9 +83,9 @@
82
83
  * const { publicKey } = await name.publish('key-1', `/ipfs/${finalDirCid}/foo.txt`)
83
84
  *
84
85
  * // resolve the name
85
- * const result = await name.resolve(publicKey)
86
- *
87
- * console.info(result.cid, result.path) // QmFoo.. 'foo.txt'
86
+ * for await (const result of name.resolve(publicKey)) {
87
+ * console.info(result.record.value) // /ipfs/QmFoo../foo.txt
88
+ * }
88
89
  * ```
89
90
  *
90
91
  * @example Using custom PubSub router
@@ -135,50 +136,11 @@
135
136
  * const { publicKey } = await name.publish('key-1', cid)
136
137
  *
137
138
  * // resolve the name
138
- * const result = await name.resolve(publicKey)
139
- * ```
140
- *
141
- * @example Republishing an existing IPNS record
142
- *
143
- * It is sometimes useful to be able to republish an existing IPNS record
144
- * without needing the private key. This allows you to extend the availability
145
- * of a record that was created elsewhere.
146
- *
147
- * ```TypeScript
148
- * import { createHelia } from 'helia'
149
- * import { ipns, ipnsValidator } from '@helia/ipns'
150
- * import { delegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
151
- * import { CID } from 'multiformats/cid'
152
- * import { multihashToIPNSRoutingKey, marshalIPNSRecord } from 'ipns'
153
- * import { defaultLogger } from '@libp2p/logger'
154
- *
155
- * const helia = await createHelia()
156
- * const name = ipns(helia)
157
- *
158
- * const ipnsName = 'k51qzi5uqu5dktsyfv7xz8h631pri4ct7osmb43nibxiojpttxzoft6hdyyzg4'
159
- * const parsedCid: CID<unknown, 114, 0 | 18, 1> = CID.parse(ipnsName)
160
- * const delegatedClient = delegatedRoutingV1HttpApiClient({
161
- * url: 'https://delegated-ipfs.dev'
162
- * })({
163
- * logger: defaultLogger()
164
- * })
165
- * const record = await delegatedClient.getIPNS(parsedCid)
166
- *
167
- * const routingKey = multihashToIPNSRoutingKey(parsedCid.multihash)
168
- * const marshaledRecord = marshalIPNSRecord(record)
169
- *
170
- * // validate that they key corresponds to the record
171
- * await ipnsValidator(routingKey, marshaledRecord)
172
- *
173
- * // publish record to routing
174
- * await Promise.all(
175
- * name.routers.map(async r => {
176
- * await r.put(routingKey, marshaledRecord)
177
- * })
178
- * )
139
+ * for await (const result of name.resolve(publicKey)) {
140
+ * console.info(result.record.value)
141
+ * }
179
142
  * ```
180
143
  */
181
- import { ipnsValidator } from 'ipns/validator';
182
144
  import { CID } from 'multiformats/cid';
183
145
  import { IPNSResolver as IPNSResolverClass } from "./ipns/resolver.js";
184
146
  import { IPNS as IPNSClass } from "./ipns.js";
@@ -200,6 +162,4 @@ export function ipnsResolver(components, options = {}) {
200
162
  localStore: store
201
163
  });
202
164
  }
203
- export { ipnsValidator };
204
- export { ipnsSelector } from 'ipns/selector';
205
165
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRo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AA;AACJ,CAAC"}
@@ -1,17 +1,13 @@
1
- import { CID } from 'multiformats/cid';
2
- import type { IPNSPublishResult, PublishOptions } from '../index.ts';
1
+ import type { PublishResult, PublishOptions } from '../index.ts';
3
2
  import type { LocalStore } from '../local-store.ts';
4
3
  import type { IPNSRouting } from '../routing/index.ts';
5
- import type { AbortOptions, ComponentLogger, Libp2p, PeerId, PublicKey } from '@libp2p/interface';
6
- import type { Keychain } from '@libp2p/keychain';
4
+ import type { Keychain } from '@helia/interface';
5
+ import type { AbortOptions, ComponentLogger } from '@libp2p/interface';
7
6
  import type { Datastore } from 'interface-datastore';
8
- import type { MultihashDigest } from 'multiformats/hashes/interface';
9
7
  export interface IPNSPublisherComponents {
10
8
  datastore: Datastore;
11
9
  logger: ComponentLogger;
12
- libp2p: Libp2p<{
13
- keychain: Keychain;
14
- }>;
10
+ keychain: Keychain;
15
11
  }
16
12
  export interface IPNSPublisherInit {
17
13
  localStore: LocalStore;
@@ -23,7 +19,7 @@ export declare class IPNSPublisher {
23
19
  private readonly localStore;
24
20
  private readonly keychain;
25
21
  constructor(components: IPNSPublisherComponents, init: IPNSPublisherInit);
26
- publish(keyName: string, value: CID | PublicKey | MultihashDigest<0x00 | 0x12> | PeerId | string, options?: PublishOptions): Promise<IPNSPublishResult>;
22
+ publish(keyName: string, value: string, options?: PublishOptions): Promise<PublishResult>;
27
23
  unpublish(keyName: string, options?: AbortOptions): Promise<void>;
28
24
  }
29
25
  //# sourceMappingURL=publisher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publisher.d.ts","sourceRoot":"","sources":["../../../src/ipns/publisher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,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