@helia/ipns 9.2.1 → 10.0.0-3d869e9d
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 +21 -57
- package/dist/index.min.js +5 -16
- package/dist/index.min.js.map +4 -4
- package/dist/src/errors.d.ts +33 -5
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +33 -20
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +67 -105
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +21 -60
- package/dist/src/index.js.map +1 -1
- package/dist/src/ipns/publisher.d.ts +4 -8
- package/dist/src/ipns/publisher.d.ts.map +1 -1
- package/dist/src/ipns/publisher.js +30 -22
- package/dist/src/ipns/publisher.js.map +1 -1
- package/dist/src/ipns/republisher.d.ts +3 -5
- package/dist/src/ipns/republisher.d.ts.map +1 -1
- package/dist/src/ipns/republisher.js +18 -9
- package/dist/src/ipns/republisher.js.map +1 -1
- package/dist/src/ipns/resolver.d.ts +6 -5
- package/dist/src/ipns/resolver.d.ts.map +1 -1
- package/dist/src/ipns/resolver.js +32 -78
- package/dist/src/ipns/resolver.js.map +1 -1
- package/dist/src/ipns.d.ts +6 -4
- package/dist/src/ipns.d.ts.map +1 -1
- package/dist/src/ipns.js +33 -4
- package/dist/src/ipns.js.map +1 -1
- package/dist/src/pb/ipns.d.ts +62 -0
- package/dist/src/pb/ipns.d.ts.map +1 -0
- package/dist/src/pb/ipns.js +203 -0
- package/dist/src/pb/ipns.js.map +1 -0
- package/dist/src/pb/metadata.d.ts +1 -1
- package/dist/src/pb/metadata.d.ts.map +1 -1
- package/dist/src/records.d.ts +155 -0
- package/dist/src/records.d.ts.map +1 -0
- package/dist/src/records.js +88 -0
- package/dist/src/records.js.map +1 -0
- package/dist/src/routing/pubsub.d.ts +3 -0
- package/dist/src/routing/pubsub.d.ts.map +1 -1
- package/dist/src/routing/pubsub.js +15 -10
- package/dist/src/routing/pubsub.js.map +1 -1
- package/dist/src/selector.d.ts +14 -0
- package/dist/src/selector.d.ts.map +1 -0
- package/dist/src/selector.js +47 -0
- package/dist/src/selector.js.map +1 -0
- package/dist/src/utils.d.ts +29 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +308 -0
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validator.d.ts +18 -0
- package/dist/src/validator.d.ts.map +1 -0
- package/dist/src/validator.js +58 -0
- package/dist/src/validator.js.map +1 -0
- package/package.json +24 -23
- package/src/errors.ts +40 -25
- package/src/index.ts +68 -106
- package/src/ipns/publisher.ts +33 -28
- package/src/ipns/republisher.ts +24 -13
- package/src/ipns/resolver.ts +41 -89
- package/src/ipns.ts +44 -7
- package/src/pb/ipns.proto +39 -0
- package/src/pb/ipns.ts +280 -0
- package/src/pb/metadata.ts +1 -1
- package/src/records.ts +273 -0
- package/src/routing/pubsub.ts +17 -10
- package/src/selector.ts +55 -0
- package/src/utils.ts +371 -2
- package/src/validator.ts +67 -0
- package/dist/typedoc-urls.json +0 -51
package/dist/src/errors.d.ts
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
export declare class RecordsFailedValidationError extends Error {
|
|
2
2
|
static name: string;
|
|
3
|
-
|
|
3
|
+
name: string;
|
|
4
4
|
}
|
|
5
5
|
export declare class UnsupportedMultibasePrefixError extends Error {
|
|
6
6
|
static name: string;
|
|
7
|
-
|
|
7
|
+
name: string;
|
|
8
8
|
}
|
|
9
9
|
export declare class UnsupportedMultihashCodecError extends Error {
|
|
10
10
|
static name: string;
|
|
11
|
-
|
|
11
|
+
name: string;
|
|
12
12
|
}
|
|
13
13
|
export declare class InvalidValueError extends Error {
|
|
14
14
|
static name: string;
|
|
15
|
-
|
|
15
|
+
name: string;
|
|
16
16
|
}
|
|
17
17
|
export declare class InvalidTopicError extends Error {
|
|
18
18
|
static name: string;
|
|
19
|
-
|
|
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
|
package/dist/src/errors.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,MAAM,CAAC,IAAI,SAAiC;IAC5C,IAAI,SAAiC;CACtC;AAED,qBAAa,+BAAgC,SAAQ,KAAK;IACxD,MAAM,CAAC,IAAI,SAAoC;IAC/C,IAAI,SAAoC;CACzC;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,IAAI,SAAmC;IAC9C,IAAI,SAAmC;CACxC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;IACjC,IAAI,SAAsB;CAC3B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;IACjC,IAAI,SAAsB;CAC3B;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,SAAwB;IACnC,IAAI,SAAwB;CAC7B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,MAAM,CAAC,IAAI,SAA2B;IACtC,IAAI,SAA2B;CAChC;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,SAA+B;IAC1C,IAAI,SAA+B;CACpC;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,MAAM,CAAC,IAAI,SAAuB;IAClC,IAAI,SAAuB;CAC5B;AAED,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,MAAM,CAAC,IAAI,SAA6B;IACxC,IAAI,SAA6B;CAClC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,MAAM,CAAC,IAAI,SAAwB;IACnC,IAAI,SAAwB;CAC7B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,MAAM,CAAC,IAAI,SAA2B;IACtC,IAAI,SAA2B;CAChC;AAED,qBAAa,6BAA8B,SAAQ,KAAK;IACtD,MAAM,CAAC,IAAI,SAAkC;IAC7C,IAAI,SAAkC;CACvC"}
|
package/dist/src/errors.js
CHANGED
|
@@ -1,40 +1,53 @@
|
|
|
1
1
|
export class RecordsFailedValidationError extends Error {
|
|
2
2
|
static name = 'RecordsFailedValidationError';
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/dist/src/errors.js.map
CHANGED
|
@@ -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;
|
|
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;IAC5C,IAAI,GAAG,8BAA8B,CAAA;;AAGvC,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACxD,MAAM,CAAC,IAAI,GAAG,iCAAiC,CAAA;IAC/C,IAAI,GAAG,iCAAiC,CAAA;;AAG1C,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,MAAM,CAAC,IAAI,GAAG,gCAAgC,CAAA;IAC9C,IAAI,GAAG,gCAAgC,CAAA;;AAGzC,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,IAAI,GAAG,mBAAmB,CAAA;;AAG5B,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,IAAI,GAAG,mBAAmB,CAAA;;AAG5B,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,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,GAAG,4BAA4B,CAAA;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"}
|
package/dist/src/index.d.ts
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
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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
|
|
57
|
-
*
|
|
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
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
|
@@ -104,29 +105,30 @@
|
|
|
104
105
|
* may fail to be published with "Insufficient peers" errors.
|
|
105
106
|
*
|
|
106
107
|
* ```TypeScript
|
|
107
|
-
* import { createHelia, libp2pDefaults } from 'helia'
|
|
108
108
|
* import { ipns } from '@helia/ipns'
|
|
109
109
|
* import { pubsub } from '@helia/ipns/routing'
|
|
110
|
+
* import { withLibp2p, libp2pDefaults } from '@helia/libp2p'
|
|
110
111
|
* import { unixfs } from '@helia/unixfs'
|
|
111
|
-
* import { floodsub } from '@libp2p/floodsub'
|
|
112
112
|
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
113
|
+
* import { floodsub } from '@libp2p/floodsub'
|
|
114
|
+
* import { createHelia } from 'helia'
|
|
115
|
+
* import type { Helia } from '@helia/interface'
|
|
113
116
|
* import type { PubSub } from '@helia/ipns/routing'
|
|
117
|
+
* import type { DefaultLibp2pServices } from '@helia/libp2p'
|
|
118
|
+
* import type { FloodSub } from '@libp2p/floodsub'
|
|
114
119
|
* import type { Libp2p } from '@libp2p/interface'
|
|
115
|
-
* import type { DefaultLibp2pServices } from 'helia'
|
|
116
120
|
*
|
|
117
|
-
* const libp2pOptions = libp2pDefaults()
|
|
121
|
+
* const libp2pOptions = libp2pDefaults() as any
|
|
118
122
|
* libp2pOptions.services.pubsub = floodsub()
|
|
119
123
|
*
|
|
120
|
-
* const helia = await
|
|
121
|
-
*
|
|
122
|
-
* })
|
|
124
|
+
* const helia = await withLibp2p<Helia, { pubsub: FloodSub }>(createHelia(), libp2pOptions).start()
|
|
125
|
+
*
|
|
123
126
|
* const name = ipns(helia, {
|
|
124
127
|
* routers: [
|
|
125
128
|
* pubsub(helia)
|
|
126
129
|
* ]
|
|
127
130
|
* })
|
|
128
131
|
*
|
|
129
|
-
*
|
|
130
132
|
* // store some data to publish
|
|
131
133
|
* const fs = unixfs(helia)
|
|
132
134
|
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
@@ -135,58 +137,19 @@
|
|
|
135
137
|
* const { publicKey } = await name.publish('key-1', cid)
|
|
136
138
|
*
|
|
137
139
|
* // resolve the name
|
|
138
|
-
* const result
|
|
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
|
-
* )
|
|
140
|
+
* for await (const result of name.resolve(publicKey)) {
|
|
141
|
+
* console.info(result.record.value)
|
|
142
|
+
* }
|
|
179
143
|
* ```
|
|
180
144
|
*/
|
|
181
|
-
import { ipnsValidator } from 'ipns/validator';
|
|
182
145
|
import { CID } from 'multiformats/cid';
|
|
183
146
|
import type { IPNSResolverComponents } from './ipns/resolver.ts';
|
|
147
|
+
import type { IPNSRecord } from './records.ts';
|
|
184
148
|
import type { IPNSRouting, IPNSRoutingProgressEvents } from './routing/index.ts';
|
|
185
|
-
import type { Routing, HeliaEvents } from '@helia/interface';
|
|
186
|
-
import type {
|
|
187
|
-
import type {
|
|
149
|
+
import type { Routing, HeliaEvents, Keychain, PublicKey } from '@helia/interface';
|
|
150
|
+
import type { ComponentLogger, TypedEventEmitter } from '@libp2p/interface';
|
|
151
|
+
import type { AbortOptions } from 'abort-error';
|
|
188
152
|
import type { Datastore } from 'interface-datastore';
|
|
189
|
-
import type { IPNSRecord } from 'ipns';
|
|
190
153
|
import type { MultihashDigest } from 'multiformats/hashes/interface';
|
|
191
154
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
192
155
|
export type PublishProgressEvents = ProgressEvent<'ipns:publish:start'> | ProgressEvent<'ipns:publish:success', IPNSRecord> | ProgressEvent<'ipns:publish:error', Error>;
|
|
@@ -194,20 +157,28 @@ export type ResolveProgressEvents = ProgressEvent<'ipns:resolve:start', unknown>
|
|
|
194
157
|
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
158
|
export interface PublishOptions extends AbortOptions, ProgressOptions<PublishProgressEvents | IPNSRoutingProgressEvents> {
|
|
196
159
|
/**
|
|
197
|
-
* Time duration of the signature validity in ms
|
|
160
|
+
* Time duration of the signature validity in ms
|
|
161
|
+
*
|
|
162
|
+
* @default 172_800_000
|
|
198
163
|
*/
|
|
199
164
|
lifetime?: number;
|
|
200
165
|
/**
|
|
201
|
-
* Only publish to a local datastore
|
|
166
|
+
* Only publish to a local datastore
|
|
167
|
+
*
|
|
168
|
+
* @default false
|
|
202
169
|
*/
|
|
203
170
|
offline?: boolean;
|
|
204
171
|
/**
|
|
205
172
|
* By default a IPNS V1 and a V2 signature is added to every record. Pass
|
|
206
|
-
* false here to only add a V2 signature.
|
|
173
|
+
* false here to only add a V2 signature.
|
|
174
|
+
*
|
|
175
|
+
* @default true
|
|
207
176
|
*/
|
|
208
177
|
v1Compatible?: boolean;
|
|
209
178
|
/**
|
|
210
|
-
* The TTL of the record in ms
|
|
179
|
+
* The TTL of the record in ms
|
|
180
|
+
*
|
|
181
|
+
* @default 300_000
|
|
211
182
|
*/
|
|
212
183
|
ttl?: number;
|
|
213
184
|
}
|
|
@@ -215,7 +186,7 @@ export interface IPNSRecordMetadata {
|
|
|
215
186
|
keyName: string;
|
|
216
187
|
lifetime: number;
|
|
217
188
|
}
|
|
218
|
-
export interface
|
|
189
|
+
export interface IPNSResolveOptions extends AbortOptions, ProgressOptions<ResolveProgressEvents | IPNSRoutingProgressEvents> {
|
|
219
190
|
/**
|
|
220
191
|
* Do not query the network for the IPNS record
|
|
221
192
|
*
|
|
@@ -229,17 +200,7 @@ export interface ResolveOptions extends AbortOptions, ProgressOptions<ResolvePro
|
|
|
229
200
|
*/
|
|
230
201
|
nocache?: boolean;
|
|
231
202
|
}
|
|
232
|
-
export interface
|
|
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 {
|
|
203
|
+
export interface IPNSResolveResult {
|
|
243
204
|
/**
|
|
244
205
|
* The resolved record
|
|
245
206
|
*/
|
|
@@ -251,19 +212,22 @@ export interface IPNSPublishResult {
|
|
|
251
212
|
*/
|
|
252
213
|
record: IPNSRecord;
|
|
253
214
|
/**
|
|
254
|
-
* The
|
|
215
|
+
* The IPNS name that can be used to resolve this record
|
|
216
|
+
*/
|
|
217
|
+
name: string;
|
|
218
|
+
/**
|
|
219
|
+
* The public key that was used to sign and publish the record
|
|
255
220
|
*/
|
|
256
221
|
publicKey: PublicKey;
|
|
257
222
|
}
|
|
258
223
|
export interface IPNSResolver {
|
|
259
224
|
/**
|
|
260
|
-
* Accepts a
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* corresponding to that key until a value is found.
|
|
225
|
+
* Accepts a CID with the libp2p-key codec and either the identity hash (for
|
|
226
|
+
* Ed25519 and secp256k1 public keys) or a SHA256 hash (for RSA public keys),
|
|
227
|
+
* or the multihash of a libp2p-key encoded CID and recursively resolves the
|
|
228
|
+
* IPNS record corresponding to that key until a value is found.
|
|
265
229
|
*/
|
|
266
|
-
resolve(key: CID
|
|
230
|
+
resolve(key: CID | MultihashDigest, options?: IPNSResolveOptions): AsyncGenerator<IPNSResolveResult>;
|
|
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
|
|
280
|
-
* - A
|
|
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
|
|
267
|
+
publish(keyName: string, value: CID | PublicKey | MultihashDigest | string, options?: PublishOptions): Promise<IPNSPublishResult>;
|
|
302
268
|
/**
|
|
303
|
-
* Accepts a
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
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(
|
|
275
|
+
resolve(name: CID | PublicKey | MultihashDigest | string, options?: IPNSResolveOptions): AsyncGenerator<IPNSResolveResult>;
|
|
310
276
|
/**
|
|
311
277
|
* Stop republishing of an IPNS record
|
|
312
278
|
*
|
|
313
|
-
* This will delete the last signed IPNS record from the datastore
|
|
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 '
|
|
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
|
-
|
|
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 {
|
|
360
|
-
export { ipnsSelector } from 'ipns/selector';
|
|
322
|
+
export type { IPNSRoutingProgressEvents };
|
|
361
323
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
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
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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
|
|
57
|
-
*
|
|
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
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
|
@@ -104,29 +105,30 @@
|
|
|
104
105
|
* may fail to be published with "Insufficient peers" errors.
|
|
105
106
|
*
|
|
106
107
|
* ```TypeScript
|
|
107
|
-
* import { createHelia, libp2pDefaults } from 'helia'
|
|
108
108
|
* import { ipns } from '@helia/ipns'
|
|
109
109
|
* import { pubsub } from '@helia/ipns/routing'
|
|
110
|
+
* import { withLibp2p, libp2pDefaults } from '@helia/libp2p'
|
|
110
111
|
* import { unixfs } from '@helia/unixfs'
|
|
111
|
-
* import { floodsub } from '@libp2p/floodsub'
|
|
112
112
|
* import { generateKeyPair } from '@libp2p/crypto/keys'
|
|
113
|
+
* import { floodsub } from '@libp2p/floodsub'
|
|
114
|
+
* import { createHelia } from 'helia'
|
|
115
|
+
* import type { Helia } from '@helia/interface'
|
|
113
116
|
* import type { PubSub } from '@helia/ipns/routing'
|
|
117
|
+
* import type { DefaultLibp2pServices } from '@helia/libp2p'
|
|
118
|
+
* import type { FloodSub } from '@libp2p/floodsub'
|
|
114
119
|
* import type { Libp2p } from '@libp2p/interface'
|
|
115
|
-
* import type { DefaultLibp2pServices } from 'helia'
|
|
116
120
|
*
|
|
117
|
-
* const libp2pOptions = libp2pDefaults()
|
|
121
|
+
* const libp2pOptions = libp2pDefaults() as any
|
|
118
122
|
* libp2pOptions.services.pubsub = floodsub()
|
|
119
123
|
*
|
|
120
|
-
* const helia = await
|
|
121
|
-
*
|
|
122
|
-
* })
|
|
124
|
+
* const helia = await withLibp2p<Helia, { pubsub: FloodSub }>(createHelia(), libp2pOptions).start()
|
|
125
|
+
*
|
|
123
126
|
* const name = ipns(helia, {
|
|
124
127
|
* routers: [
|
|
125
128
|
* pubsub(helia)
|
|
126
129
|
* ]
|
|
127
130
|
* })
|
|
128
131
|
*
|
|
129
|
-
*
|
|
130
132
|
* // store some data to publish
|
|
131
133
|
* const fs = unixfs(helia)
|
|
132
134
|
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
@@ -135,50 +137,11 @@
|
|
|
135
137
|
* const { publicKey } = await name.publish('key-1', cid)
|
|
136
138
|
*
|
|
137
139
|
* // resolve the name
|
|
138
|
-
* const result
|
|
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
|
-
* )
|
|
140
|
+
* for await (const result of name.resolve(publicKey)) {
|
|
141
|
+
* console.info(result.record.value)
|
|
142
|
+
* }
|
|
179
143
|
* ```
|
|
180
144
|
*/
|
|
181
|
-
import { ipnsValidator } from 'ipns/validator';
|
|
182
145
|
import { CID } from 'multiformats/cid';
|
|
183
146
|
import { IPNSResolver as IPNSResolverClass } from "./ipns/resolver.js";
|
|
184
147
|
import { IPNS as IPNSClass } from "./ipns.js";
|
|
@@ -200,6 +163,4 @@ export function ipnsResolver(components, options = {}) {
|
|
|
200
163
|
localStore: store
|
|
201
164
|
});
|
|
202
165
|
}
|
|
203
|
-
export { ipnsValidator };
|
|
204
|
-
export { ipnsSelector } from 'ipns/selector';
|
|
205
166
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+IG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAmN5D,MAAM,UAAU,IAAI,CAAE,UAA0B,EAAE,UAAuB,EAAE;IACzE,OAAO,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,UAAkC,EAAE,UAA+B,EAAE;IACjG,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAA;IACxG,MAAM,OAAO,GAAG;QACd,iBAAiB,CAAC,KAAK,CAAC;QACxB,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;QACzB,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;KAC3B,CAAA;IAED,OAAO,IAAI,iBAAiB,CAAC,UAAU,EAAE;QACvC,OAAO;QACP,UAAU,EAAE,KAAK;KAClB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { CID } from 'multiformats/cid';
|
|
2
1
|
import type { IPNSPublishResult, 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 {
|
|
6
|
-
import type {
|
|
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
|
-
|
|
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:
|
|
22
|
+
publish(keyName: string, value: string, options?: PublishOptions): Promise<IPNSPublishResult>;
|
|
27
23
|
unpublish(keyName: string, options?: AbortOptions): Promise<void>;
|
|
28
24
|
}
|
|
29
25
|
//# sourceMappingURL=publisher.d.ts.map
|