@helia/ipns 10.0.0 → 10.0.1-883ff053
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 +3 -7
- package/dist/index.min.js +16 -5
- package/dist/index.min.js.map +4 -4
- package/dist/src/errors.d.ts +0 -8
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +0 -8
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +68 -31
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/ipns/publisher.d.ts +2 -2
- package/dist/src/ipns/publisher.d.ts.map +1 -1
- package/dist/src/ipns/publisher.js +27 -14
- package/dist/src/ipns/publisher.js.map +1 -1
- package/dist/src/ipns/republisher.d.ts.map +1 -1
- package/dist/src/ipns/republisher.js +22 -9
- package/dist/src/ipns/republisher.js.map +1 -1
- package/dist/src/ipns/resolver.d.ts +2 -2
- package/dist/src/ipns/resolver.d.ts.map +1 -1
- package/dist/src/ipns/resolver.js +39 -17
- package/dist/src/ipns/resolver.js.map +1 -1
- package/dist/src/ipns.d.ts +3 -3
- package/dist/src/ipns.d.ts.map +1 -1
- package/dist/src/ipns.js +8 -8
- package/dist/src/ipns.js.map +1 -1
- package/dist/src/local-store.d.ts +4 -4
- package/dist/src/local-store.d.ts.map +1 -1
- package/dist/src/local-store.js +2 -1
- package/dist/src/local-store.js.map +1 -1
- package/dist/src/pb/ipns.d.ts +29 -29
- package/dist/src/pb/ipns.d.ts.map +1 -1
- package/dist/src/pb/ipns.js +15 -15
- package/dist/src/records.d.ts +27 -142
- package/dist/src/records.d.ts.map +1 -1
- package/dist/src/records.js +39 -46
- package/dist/src/records.js.map +1 -1
- package/dist/src/routing/helia.d.ts +5 -5
- package/dist/src/routing/helia.d.ts.map +1 -1
- package/dist/src/routing/helia.js +3 -3
- package/dist/src/routing/helia.js.map +1 -1
- package/dist/src/routing/index.d.ts +7 -7
- package/dist/src/routing/index.d.ts.map +1 -1
- package/dist/src/routing/index.js +2 -2
- package/dist/src/routing/index.js.map +1 -1
- package/dist/src/routing/local-store.d.ts +1 -1
- package/dist/src/routing/local-store.d.ts.map +1 -1
- package/dist/src/routing/local-store.js +3 -3
- package/dist/src/routing/local-store.js.map +1 -1
- package/dist/src/routing/pubsub.d.ts +11 -11
- package/dist/src/routing/pubsub.d.ts.map +1 -1
- package/dist/src/routing/pubsub.js +11 -12
- package/dist/src/routing/pubsub.js.map +1 -1
- package/dist/src/selector.d.ts +2 -2
- package/dist/src/selector.d.ts.map +1 -1
- package/dist/src/selector.js +13 -9
- package/dist/src/selector.js.map +1 -1
- package/dist/src/utils.d.ts +10 -11
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +20 -128
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validator.d.ts +9 -3
- package/dist/src/validator.d.ts.map +1 -1
- package/dist/src/validator.js +57 -14
- package/dist/src/validator.js.map +1 -1
- package/package.json +6 -31
- package/src/errors.ts +0 -10
- package/src/index.ts +85 -36
- package/src/ipns/publisher.ts +29 -16
- package/src/ipns/republisher.ts +31 -13
- package/src/ipns/resolver.ts +40 -22
- package/src/ipns.ts +11 -11
- package/src/local-store.ts +8 -7
- package/src/pb/ipns.proto +1 -1
- package/src/pb/ipns.ts +37 -37
- package/src/records.ts +57 -210
- package/src/routing/helia.ts +6 -6
- package/src/routing/index.ts +7 -7
- package/src/routing/local-store.ts +6 -6
- package/src/routing/pubsub.ts +24 -25
- package/src/selector.ts +14 -11
- package/src/utils.ts +26 -148
- package/src/validator.ts +73 -16
- package/dist/typedoc-urls.json +0 -49
package/src/ipns/resolver.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { base36 } from 'multiformats/bases/base36'
|
|
1
2
|
import { DEFAULT_TTL_NS } from '../constants.ts'
|
|
2
|
-
import { RecordNotFoundError, RecordsFailedValidationError } from '../errors.ts'
|
|
3
|
+
import { InvalidValueError, RecordNotFoundError, RecordsFailedValidationError } from '../errors.ts'
|
|
4
|
+
import { IPNSEntry } from '../pb/ipns.ts'
|
|
3
5
|
import { ipnsSelector } from '../selector.ts'
|
|
4
|
-
import { multihashToIPNSRoutingKey,
|
|
6
|
+
import { multihashToIPNSRoutingKey, normalizeKey, IPNS_STRING_PREFIX, ipnsRecordValueToString, decodeExtensibleData } from '../utils.ts'
|
|
5
7
|
import { ipnsValidator } from '../validator.ts'
|
|
6
|
-
import type {
|
|
8
|
+
import type { IPNSResolveOptions, IPNSResolveResult } from '../index.ts'
|
|
7
9
|
import type { LocalStore } from '../local-store.ts'
|
|
8
10
|
import type { IPNSRouting } from '../routing/index.ts'
|
|
9
11
|
import type { Routing, Keychain } from '@helia/interface'
|
|
@@ -36,28 +38,39 @@ export class IPNSResolver {
|
|
|
36
38
|
this.keychain = components.keychain
|
|
37
39
|
}
|
|
38
40
|
|
|
39
|
-
async * resolve (key: MultihashDigest, options:
|
|
41
|
+
async * resolve (key: MultihashDigest, options: IPNSResolveOptions = {}): AsyncGenerator<IPNSResolveResult> {
|
|
40
42
|
let { digest } = normalizeKey(key)
|
|
41
43
|
|
|
42
44
|
while (true) {
|
|
43
45
|
const routingKey = multihashToIPNSRoutingKey(digest)
|
|
44
46
|
const record = await this.#findIpnsRecord(routingKey, options)
|
|
47
|
+
let value = ''
|
|
48
|
+
|
|
49
|
+
if (record.data != null) {
|
|
50
|
+
const data = decodeExtensibleData(record.data)
|
|
51
|
+
value = ipnsRecordValueToString(data.Value)
|
|
52
|
+
} else if (record.value != null) {
|
|
53
|
+
value = ipnsRecordValueToString(record.value)
|
|
54
|
+
} else {
|
|
55
|
+
throw new InvalidValueError(`Record for key ${base36.encode(digest.bytes)} contained no value`)
|
|
56
|
+
}
|
|
45
57
|
|
|
46
58
|
yield {
|
|
47
|
-
record
|
|
59
|
+
record,
|
|
60
|
+
value
|
|
48
61
|
}
|
|
49
62
|
|
|
50
|
-
if (!
|
|
63
|
+
if (!value.startsWith(IPNS_STRING_PREFIX)) {
|
|
51
64
|
// not a recursive record
|
|
52
65
|
break
|
|
53
66
|
}
|
|
54
67
|
|
|
55
|
-
({ digest } = normalizeKey(
|
|
68
|
+
({ digest } = normalizeKey(value))
|
|
56
69
|
}
|
|
57
70
|
}
|
|
58
71
|
|
|
59
|
-
async #findIpnsRecord (routingKey: Uint8Array, options:
|
|
60
|
-
const records:
|
|
72
|
+
async #findIpnsRecord (routingKey: Uint8Array, options: IPNSResolveOptions = {}): Promise<IPNSEntry> {
|
|
73
|
+
const records: IPNSEntry[] = []
|
|
61
74
|
const cached = await this.localStore.has(routingKey, options)
|
|
62
75
|
|
|
63
76
|
if (cached) {
|
|
@@ -70,19 +83,23 @@ export class IPNSResolver {
|
|
|
70
83
|
|
|
71
84
|
this.log('record retrieved from cache')
|
|
72
85
|
|
|
73
|
-
// unmarshal the record
|
|
74
|
-
|
|
86
|
+
// unmarshal and validate the record
|
|
87
|
+
let ipnsRecord: IPNSEntry
|
|
75
88
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
if (options.validate === false) {
|
|
90
|
+
ipnsRecord = IPNSEntry.decode(marshaledIPNSRecord)
|
|
91
|
+
this.log('skipped validation of record')
|
|
92
|
+
} else {
|
|
93
|
+
ipnsRecord = await ipnsValidator(routingKey, marshaledIPNSRecord, this.keychain, options)
|
|
94
|
+
this.log('record was valid')
|
|
95
|
+
}
|
|
80
96
|
|
|
81
97
|
// check the TTL
|
|
98
|
+
const data = decodeExtensibleData(ipnsRecord.data)
|
|
82
99
|
|
|
83
100
|
// IPNS TTL is in nanoseconds, convert to milliseconds, default to one
|
|
84
101
|
// hour
|
|
85
|
-
const ttlMs = Number((
|
|
102
|
+
const ttlMs = Number((data.TTL ?? DEFAULT_TTL_NS) / 1_000_000n)
|
|
86
103
|
const ttlExpires = created.getTime() + ttlMs
|
|
87
104
|
|
|
88
105
|
if (ttlExpires > Date.now()) {
|
|
@@ -138,12 +155,13 @@ export class IPNSResolver {
|
|
|
138
155
|
}
|
|
139
156
|
|
|
140
157
|
try {
|
|
141
|
-
|
|
142
|
-
// and Validity are of valid types and have a value, (3) that CBOR data matches protobuf
|
|
143
|
-
// if it's a V1+V2 record
|
|
144
|
-
const record = await unmarshalIPNSRecord(routingKey, marshaledIPNSRecord, this.keychain, options)
|
|
158
|
+
let record: IPNSEntry
|
|
145
159
|
|
|
146
|
-
|
|
160
|
+
if (options.validate === false) {
|
|
161
|
+
record = IPNSEntry.decode(marshaledIPNSRecord)
|
|
162
|
+
} else {
|
|
163
|
+
record = await ipnsValidator(routingKey, marshaledIPNSRecord, this.keychain, options)
|
|
164
|
+
}
|
|
147
165
|
|
|
148
166
|
records.push(record)
|
|
149
167
|
} catch (err) {
|
|
@@ -164,7 +182,7 @@ export class IPNSResolver {
|
|
|
164
182
|
|
|
165
183
|
const record = records[ipnsSelector(routingKey, records)]
|
|
166
184
|
|
|
167
|
-
await this.localStore.put(routingKey, record
|
|
185
|
+
await this.localStore.put(routingKey, IPNSEntry.encode(record), options)
|
|
168
186
|
|
|
169
187
|
return record
|
|
170
188
|
}
|
package/src/ipns.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid'
|
|
2
|
+
import { IPNSEntry } from './index.ts'
|
|
2
3
|
import { IPNSPublisher } from './ipns/publisher.ts'
|
|
3
4
|
import { IPNSRepublisher } from './ipns/republisher.ts'
|
|
4
5
|
import { IPNSResolver } from './ipns/resolver.ts'
|
|
5
6
|
import { localStore } from './local-store.ts'
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { heliaIPNSRouting } from './routing/helia.ts'
|
|
8
|
+
import { localStoreIPNSRouting } from './routing/local-store.ts'
|
|
8
9
|
import { ipnsSelector } from './selector.ts'
|
|
9
|
-
import { normalizeKey, normalizeValue
|
|
10
|
+
import { normalizeKey, normalizeValue } from './utils.ts'
|
|
10
11
|
import { ipnsValidator } from './validator.ts'
|
|
11
|
-
import type { IPNSComponents, IPNS as IPNSInterface, IPNSOptions,
|
|
12
|
+
import type { IPNSComponents, IPNS as IPNSInterface, IPNSOptions, IPNSPublishResult, PublishOptions, IPNSResolveOptions, IPNSResolveResult } from './index.ts'
|
|
12
13
|
import type { LocalStore } from './local-store.ts'
|
|
13
14
|
import type { IPNSRouting } from './routing/index.ts'
|
|
14
15
|
import type { PublicKey } from '@helia/interface'
|
|
@@ -31,8 +32,8 @@ export class IPNS implements IPNSInterface, Startable {
|
|
|
31
32
|
this.started = false
|
|
32
33
|
|
|
33
34
|
this.routers = [
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
localStoreIPNSRouting(this.localStore),
|
|
36
|
+
heliaIPNSRouting(components.routing),
|
|
36
37
|
...(init.routers ?? [])
|
|
37
38
|
]
|
|
38
39
|
|
|
@@ -67,14 +68,13 @@ export class IPNS implements IPNSInterface, Startable {
|
|
|
67
68
|
if (isKadDHT(service)) {
|
|
68
69
|
// @ ts-expect-error https://github.com/libp2p/js-libp2p/pull/3506
|
|
69
70
|
service.selectors.ipns = async (key: Uint8Array, values: Uint8Array[]): Promise<number> => {
|
|
70
|
-
const records =
|
|
71
|
+
const records = values.map(buf => IPNSEntry.decode(buf))
|
|
71
72
|
|
|
72
73
|
return ipnsSelector(key, records)
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
service.validators.ipns = async (key: Uint8Array, value: Uint8Array): Promise<void> => {
|
|
76
|
-
|
|
77
|
-
await ipnsValidator(record)
|
|
77
|
+
await ipnsValidator(key, value, this.components.keychain)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -100,11 +100,11 @@ export class IPNS implements IPNSInterface, Startable {
|
|
|
100
100
|
this.republisher.stop()
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
async publish (keyName: string, value: PublicKey | CID | MultihashDigest | string, options: PublishOptions = {}): Promise<
|
|
103
|
+
async publish (keyName: string, value: PublicKey | CID | MultihashDigest | string, options: PublishOptions = {}): Promise<IPNSPublishResult> {
|
|
104
104
|
return this.publisher.publish(keyName, normalizeValue(value), options)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
async * resolve (key: PublicKey | CID
|
|
107
|
+
async * resolve (key: PublicKey | CID | MultihashDigest | string, options: IPNSResolveOptions = {}): AsyncGenerator<IPNSResolveResult> {
|
|
108
108
|
const { digest } = normalizeKey(key)
|
|
109
109
|
|
|
110
110
|
yield * this.resolver.resolve(digest, options)
|
package/src/local-store.ts
CHANGED
|
@@ -2,14 +2,15 @@ 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 { withArrayBuffer } from 'uint8arrays/with-array-buffer'
|
|
5
6
|
import { IPNSPublishMetadata } from './pb/metadata.ts'
|
|
6
7
|
import { dhtRoutingKey, DHT_RECORD_PREFIX, ipnsMetadataKey } from './utils.ts'
|
|
7
|
-
import type { DatastoreProgressEvents,
|
|
8
|
+
import type { DatastoreProgressEvents, IPNSRoutingGetOptions, IPNSRoutingPutOptions } from './routing/index.ts'
|
|
8
9
|
import type { AbortOptions, Logger } from '@libp2p/interface'
|
|
9
10
|
import type { Datastore } from 'interface-datastore'
|
|
10
11
|
|
|
11
12
|
export interface GetResult {
|
|
12
|
-
record: Uint8Array
|
|
13
|
+
record: Uint8Array<ArrayBuffer>
|
|
13
14
|
created: Date
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -32,8 +33,8 @@ export interface LocalStore {
|
|
|
32
33
|
* @param marshaledRecord - The marshaled IPNS record
|
|
33
34
|
* @param options - options for the put operation including metadata
|
|
34
35
|
*/
|
|
35
|
-
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, options?:
|
|
36
|
-
get(routingKey: Uint8Array, options?:
|
|
36
|
+
put(routingKey: Uint8Array, marshaledRecord: Uint8Array, options?: IPNSRoutingPutOptions): Promise<void>
|
|
37
|
+
get(routingKey: Uint8Array, options?: IPNSRoutingGetOptions): Promise<GetResult>
|
|
37
38
|
has(routingKey: Uint8Array, options?: AbortOptions): Promise<boolean>
|
|
38
39
|
delete(routingKey: Uint8Array, options?: AbortOptions): Promise<void>
|
|
39
40
|
/**
|
|
@@ -50,7 +51,7 @@ export interface LocalStore {
|
|
|
50
51
|
*/
|
|
51
52
|
export function localStore (datastore: Datastore, log: Logger): LocalStore {
|
|
52
53
|
return {
|
|
53
|
-
async put (routingKey: Uint8Array, marshalledRecord: Uint8Array, options:
|
|
54
|
+
async put (routingKey: Uint8Array, marshalledRecord: Uint8Array, options: IPNSRoutingPutOptions = {}) {
|
|
54
55
|
try {
|
|
55
56
|
const key = dhtRoutingKey(routingKey)
|
|
56
57
|
|
|
@@ -86,7 +87,7 @@ export function localStore (datastore: Datastore, log: Logger): LocalStore {
|
|
|
86
87
|
throw err
|
|
87
88
|
}
|
|
88
89
|
},
|
|
89
|
-
async get (routingKey: Uint8Array, options:
|
|
90
|
+
async get (routingKey: Uint8Array, options: IPNSRoutingGetOptions = {}): Promise<GetResult> {
|
|
90
91
|
try {
|
|
91
92
|
const key = dhtRoutingKey(routingKey)
|
|
92
93
|
|
|
@@ -97,7 +98,7 @@ export function localStore (datastore: Datastore, log: Logger): LocalStore {
|
|
|
97
98
|
const record = Record.deserialize(buf)
|
|
98
99
|
|
|
99
100
|
return {
|
|
100
|
-
record: record.value,
|
|
101
|
+
record: withArrayBuffer(record.value),
|
|
101
102
|
created: record.timeReceived
|
|
102
103
|
}
|
|
103
104
|
} catch (err: any) {
|
package/src/pb/ipns.proto
CHANGED
package/src/pb/ipns.ts
CHANGED
|
@@ -2,19 +2,19 @@ import { decodeMessage, encodeMessage, enumeration, message, streamMessage } fro
|
|
|
2
2
|
import type { Codec, DecodeOptions } from 'protons-runtime'
|
|
3
3
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
6
|
-
value?: Uint8Array
|
|
7
|
-
signatureV1?: Uint8Array
|
|
8
|
-
validityType?:
|
|
9
|
-
validity?: Uint8Array
|
|
5
|
+
export interface IPNSEntry {
|
|
6
|
+
value?: Uint8Array<ArrayBuffer>
|
|
7
|
+
signatureV1?: Uint8Array<ArrayBuffer>
|
|
8
|
+
validityType?: IPNSEntry.ValidityType
|
|
9
|
+
validity?: Uint8Array<ArrayBuffer>
|
|
10
10
|
sequence?: bigint
|
|
11
11
|
ttl?: bigint
|
|
12
|
-
publicKey?: Uint8Array
|
|
13
|
-
signatureV2?: Uint8Array
|
|
14
|
-
data?: Uint8Array
|
|
12
|
+
publicKey?: Uint8Array<ArrayBuffer>
|
|
13
|
+
signatureV2?: Uint8Array<ArrayBuffer>
|
|
14
|
+
data?: Uint8Array<ArrayBuffer>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export namespace
|
|
17
|
+
export namespace IPNSEntry {
|
|
18
18
|
export enum ValidityType {
|
|
19
19
|
EOL = 'EOL'
|
|
20
20
|
}
|
|
@@ -29,11 +29,11 @@ export namespace IpnsEntry {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
let _codec: Codec<
|
|
32
|
+
let _codec: Codec<IPNSEntry>
|
|
33
33
|
|
|
34
|
-
export const codec = (): Codec<
|
|
34
|
+
export const codec = (): Codec<IPNSEntry> => {
|
|
35
35
|
if (_codec == null) {
|
|
36
|
-
_codec = message<
|
|
36
|
+
_codec = message<IPNSEntry>((obj, w, opts = {}) => {
|
|
37
37
|
if (opts.lengthDelimited !== false) {
|
|
38
38
|
w.fork()
|
|
39
39
|
}
|
|
@@ -50,7 +50,7 @@ export namespace IpnsEntry {
|
|
|
50
50
|
|
|
51
51
|
if (obj.validityType != null) {
|
|
52
52
|
w.uint32(24)
|
|
53
|
-
|
|
53
|
+
IPNSEntry.ValidityType.codec().encode(obj.validityType, w)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (obj.validity != null) {
|
|
@@ -104,7 +104,7 @@ export namespace IpnsEntry {
|
|
|
104
104
|
break
|
|
105
105
|
}
|
|
106
106
|
case 3: {
|
|
107
|
-
obj.validityType =
|
|
107
|
+
obj.validityType = IPNSEntry.ValidityType.codec().decode(reader)
|
|
108
108
|
break
|
|
109
109
|
}
|
|
110
110
|
case 4: {
|
|
@@ -163,7 +163,7 @@ export namespace IpnsEntry {
|
|
|
163
163
|
case 3: {
|
|
164
164
|
yield {
|
|
165
165
|
field: `${prefix}.validityType`,
|
|
166
|
-
value:
|
|
166
|
+
value: IPNSEntry.ValidityType.codec().decode(reader)
|
|
167
167
|
}
|
|
168
168
|
break
|
|
169
169
|
}
|
|
@@ -221,60 +221,60 @@ export namespace IpnsEntry {
|
|
|
221
221
|
return _codec
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
export interface
|
|
224
|
+
export interface IPNSEntryValueFieldEvent {
|
|
225
225
|
field: '$.value'
|
|
226
|
-
value: Uint8Array
|
|
226
|
+
value: Uint8Array<ArrayBuffer>
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
export interface
|
|
229
|
+
export interface IPNSEntrySignatureV1FieldEvent {
|
|
230
230
|
field: '$.signatureV1'
|
|
231
|
-
value: Uint8Array
|
|
231
|
+
value: Uint8Array<ArrayBuffer>
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
export interface
|
|
234
|
+
export interface IPNSEntryValidityTypeFieldEvent {
|
|
235
235
|
field: '$.validityType'
|
|
236
|
-
value:
|
|
236
|
+
value: IPNSEntry.ValidityType
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
export interface
|
|
239
|
+
export interface IPNSEntryValidityFieldEvent {
|
|
240
240
|
field: '$.validity'
|
|
241
|
-
value: Uint8Array
|
|
241
|
+
value: Uint8Array<ArrayBuffer>
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
export interface
|
|
244
|
+
export interface IPNSEntrySequenceFieldEvent {
|
|
245
245
|
field: '$.sequence'
|
|
246
246
|
value: bigint
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
export interface
|
|
249
|
+
export interface IPNSEntryTtlFieldEvent {
|
|
250
250
|
field: '$.ttl'
|
|
251
251
|
value: bigint
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
export interface
|
|
254
|
+
export interface IPNSEntryPublicKeyFieldEvent {
|
|
255
255
|
field: '$.publicKey'
|
|
256
|
-
value: Uint8Array
|
|
256
|
+
value: Uint8Array<ArrayBuffer>
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
export interface
|
|
259
|
+
export interface IPNSEntrySignatureV2FieldEvent {
|
|
260
260
|
field: '$.signatureV2'
|
|
261
|
-
value: Uint8Array
|
|
261
|
+
value: Uint8Array<ArrayBuffer>
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
export interface
|
|
264
|
+
export interface IPNSEntryDataFieldEvent {
|
|
265
265
|
field: '$.data'
|
|
266
|
-
value: Uint8Array
|
|
266
|
+
value: Uint8Array<ArrayBuffer>
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
export function encode (obj: Partial<
|
|
270
|
-
return encodeMessage(obj,
|
|
269
|
+
export function encode (obj: Partial<IPNSEntry>): Uint8Array<ArrayBuffer> {
|
|
270
|
+
return encodeMessage(obj, IPNSEntry.codec())
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<
|
|
274
|
-
return decodeMessage(buf,
|
|
273
|
+
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPNSEntry>): IPNSEntry {
|
|
274
|
+
return decodeMessage(buf, IPNSEntry.codec(), opts)
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<
|
|
278
|
-
return streamMessage(buf,
|
|
277
|
+
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPNSEntry>): Generator<IPNSEntryValueFieldEvent | IPNSEntrySignatureV1FieldEvent | IPNSEntryValidityTypeFieldEvent | IPNSEntryValidityFieldEvent | IPNSEntrySequenceFieldEvent | IPNSEntryTtlFieldEvent | IPNSEntryPublicKeyFieldEvent | IPNSEntrySignatureV2FieldEvent | IPNSEntryDataFieldEvent> {
|
|
278
|
+
return streamMessage(buf, IPNSEntry.codec(), opts)
|
|
279
279
|
}
|
|
280
280
|
}
|