@libp2p/plaintext 3.0.29-e48eabf67 → 3.0.30-2d4c93ed6
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/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -10
- package/dist/src/index.js.map +1 -1
- package/dist/src/pb/proto.d.ts +9 -40
- package/dist/src/pb/proto.d.ts.map +1 -1
- package/dist/src/pb/proto.js +22 -114
- package/dist/src/pb/proto.js.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +9 -10
- package/src/pb/proto.proto +2 -13
- package/src/pb/proto.ts +33 -156
package/src/pb/proto.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { decodeMessage, encodeMessage,
|
|
2
|
-
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
|
|
1
|
+
import { decodeMessage, encodeMessage, message, streamMessage } from 'protons-runtime'
|
|
3
2
|
import type { Codec, DecodeOptions } from 'protons-runtime'
|
|
4
3
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
5
4
|
|
|
6
5
|
export interface Exchange {
|
|
7
|
-
id?: Uint8Array
|
|
8
|
-
pubkey?:
|
|
6
|
+
id?: Uint8Array<ArrayBuffer>
|
|
7
|
+
pubkey?: Uint8Array<ArrayBuffer>
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export namespace Exchange {
|
|
@@ -25,7 +24,7 @@ export namespace Exchange {
|
|
|
25
24
|
|
|
26
25
|
if (obj.pubkey != null) {
|
|
27
26
|
w.uint32(18)
|
|
28
|
-
|
|
27
|
+
w.bytes(obj.pubkey)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
if (opts.lengthDelimited !== false) {
|
|
@@ -45,9 +44,7 @@ export namespace Exchange {
|
|
|
45
44
|
break
|
|
46
45
|
}
|
|
47
46
|
case 2: {
|
|
48
|
-
obj.pubkey =
|
|
49
|
-
limits: opts.limits?.pubkey
|
|
50
|
-
})
|
|
47
|
+
obj.pubkey = reader.bytes()
|
|
51
48
|
break
|
|
52
49
|
}
|
|
53
50
|
default: {
|
|
@@ -61,141 +58,13 @@ export namespace Exchange {
|
|
|
61
58
|
}, function * (reader, length, prefix, opts = {}) {
|
|
62
59
|
const end = length == null ? reader.len : reader.pos + length
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
yield {
|
|
70
|
-
field: `${prefix}.id`,
|
|
71
|
-
value: reader.bytes()
|
|
72
|
-
}
|
|
73
|
-
break
|
|
74
|
-
}
|
|
75
|
-
case 2: {
|
|
76
|
-
yield * PublicKey.codec().stream(reader, reader.uint32(), `${prefix}.pubkey`, {
|
|
77
|
-
limits: opts.limits?.pubkey
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
break
|
|
81
|
-
}
|
|
82
|
-
default: {
|
|
83
|
-
reader.skipType(tag & 7)
|
|
84
|
-
break
|
|
85
|
-
}
|
|
61
|
+
if (prefix !== '.') {
|
|
62
|
+
yield {
|
|
63
|
+
field: prefix.endsWith('.') ? prefix.substring(0, prefix.length - 1) : prefix,
|
|
64
|
+
type: 'start',
|
|
65
|
+
message: 'Exchange'
|
|
86
66
|
}
|
|
87
67
|
}
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return _codec
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ExchangeIdFieldEvent {
|
|
95
|
-
field: '$.id'
|
|
96
|
-
value: Uint8Array
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface ExchangePubkeyTypeFieldEvent {
|
|
100
|
-
field: '$.pubkey.Type'
|
|
101
|
-
value: KeyType
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface ExchangePubkeyDataFieldEvent {
|
|
105
|
-
field: '$.pubkey.Data'
|
|
106
|
-
value: Uint8Array
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function encode (obj: Partial<Exchange>): Uint8Array {
|
|
110
|
-
return encodeMessage(obj, Exchange.codec())
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Exchange>): Exchange {
|
|
114
|
-
return decodeMessage(buf, Exchange.codec(), opts)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Exchange>): Generator<ExchangeIdFieldEvent | ExchangePubkeyTypeFieldEvent | ExchangePubkeyDataFieldEvent> {
|
|
118
|
-
return streamMessage(buf, Exchange.codec(), opts)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export enum KeyType {
|
|
123
|
-
RSA = 'RSA',
|
|
124
|
-
Ed25519 = 'Ed25519',
|
|
125
|
-
secp256k1 = 'secp256k1',
|
|
126
|
-
ECDSA = 'ECDSA'
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
enum __KeyTypeValues {
|
|
130
|
-
RSA = 0,
|
|
131
|
-
Ed25519 = 1,
|
|
132
|
-
secp256k1 = 2,
|
|
133
|
-
ECDSA = 3
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export namespace KeyType {
|
|
137
|
-
export const codec = (): Codec<KeyType> => {
|
|
138
|
-
return enumeration<KeyType>(__KeyTypeValues)
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export interface PublicKey {
|
|
143
|
-
Type?: KeyType
|
|
144
|
-
Data: Uint8Array
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export namespace PublicKey {
|
|
148
|
-
let _codec: Codec<PublicKey>
|
|
149
|
-
|
|
150
|
-
export const codec = (): Codec<PublicKey> => {
|
|
151
|
-
if (_codec == null) {
|
|
152
|
-
_codec = message<PublicKey>((obj, w, opts = {}) => {
|
|
153
|
-
if (opts.lengthDelimited !== false) {
|
|
154
|
-
w.fork()
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (obj.Type != null) {
|
|
158
|
-
w.uint32(8)
|
|
159
|
-
KeyType.codec().encode(obj.Type, w)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if ((obj.Data != null && obj.Data.byteLength > 0)) {
|
|
163
|
-
w.uint32(18)
|
|
164
|
-
w.bytes(obj.Data)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (opts.lengthDelimited !== false) {
|
|
168
|
-
w.ldelim()
|
|
169
|
-
}
|
|
170
|
-
}, (reader, length, opts = {}) => {
|
|
171
|
-
const obj: any = {
|
|
172
|
-
Data: uint8ArrayAlloc(0)
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
176
|
-
|
|
177
|
-
while (reader.pos < end) {
|
|
178
|
-
const tag = reader.uint32()
|
|
179
|
-
|
|
180
|
-
switch (tag >>> 3) {
|
|
181
|
-
case 1: {
|
|
182
|
-
obj.Type = KeyType.codec().decode(reader)
|
|
183
|
-
break
|
|
184
|
-
}
|
|
185
|
-
case 2: {
|
|
186
|
-
obj.Data = reader.bytes()
|
|
187
|
-
break
|
|
188
|
-
}
|
|
189
|
-
default: {
|
|
190
|
-
reader.skipType(tag & 7)
|
|
191
|
-
break
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return obj
|
|
197
|
-
}, function * (reader, length, prefix, opts = {}) {
|
|
198
|
-
const end = length == null ? reader.len : reader.pos + length
|
|
199
68
|
|
|
200
69
|
while (reader.pos < end) {
|
|
201
70
|
const tag = reader.uint32()
|
|
@@ -203,14 +72,14 @@ export namespace PublicKey {
|
|
|
203
72
|
switch (tag >>> 3) {
|
|
204
73
|
case 1: {
|
|
205
74
|
yield {
|
|
206
|
-
field: `${prefix}
|
|
207
|
-
value:
|
|
75
|
+
field: `${prefix}id`,
|
|
76
|
+
value: reader.bytes()
|
|
208
77
|
}
|
|
209
78
|
break
|
|
210
79
|
}
|
|
211
80
|
case 2: {
|
|
212
81
|
yield {
|
|
213
|
-
field: `${prefix}
|
|
82
|
+
field: `${prefix}pubkey`,
|
|
214
83
|
value: reader.bytes()
|
|
215
84
|
}
|
|
216
85
|
break
|
|
@@ -221,31 +90,39 @@ export namespace PublicKey {
|
|
|
221
90
|
}
|
|
222
91
|
}
|
|
223
92
|
}
|
|
93
|
+
|
|
94
|
+
if (prefix !== '.') {
|
|
95
|
+
yield {
|
|
96
|
+
field: prefix.endsWith('.') ? prefix.substring(0, prefix.length - 1) : prefix,
|
|
97
|
+
type: 'end',
|
|
98
|
+
message: 'Exchange'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
224
101
|
})
|
|
225
102
|
}
|
|
226
103
|
|
|
227
104
|
return _codec
|
|
228
105
|
}
|
|
229
106
|
|
|
230
|
-
export interface
|
|
231
|
-
field: '
|
|
232
|
-
value:
|
|
107
|
+
export interface ExchangeIdFieldEvent {
|
|
108
|
+
field: '.id'
|
|
109
|
+
value: Uint8Array<ArrayBuffer>
|
|
233
110
|
}
|
|
234
111
|
|
|
235
|
-
export interface
|
|
236
|
-
field: '
|
|
237
|
-
value: Uint8Array
|
|
112
|
+
export interface ExchangePubkeyFieldEvent {
|
|
113
|
+
field: '.pubkey'
|
|
114
|
+
value: Uint8Array<ArrayBuffer>
|
|
238
115
|
}
|
|
239
116
|
|
|
240
|
-
export function encode (obj: Partial<
|
|
241
|
-
return encodeMessage(obj,
|
|
117
|
+
export function encode (obj: Partial<Exchange>): Uint8Array<ArrayBuffer> {
|
|
118
|
+
return encodeMessage(obj, Exchange.codec())
|
|
242
119
|
}
|
|
243
120
|
|
|
244
|
-
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<
|
|
245
|
-
return decodeMessage(buf,
|
|
121
|
+
export function decode (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Exchange>): Exchange {
|
|
122
|
+
return decodeMessage(buf, Exchange.codec(), opts)
|
|
246
123
|
}
|
|
247
124
|
|
|
248
|
-
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<
|
|
249
|
-
return streamMessage(buf,
|
|
125
|
+
export function stream (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Exchange>): Generator<ExchangeIdFieldEvent | ExchangePubkeyFieldEvent> {
|
|
126
|
+
return streamMessage(buf, Exchange.codec(), opts)
|
|
250
127
|
}
|
|
251
128
|
}
|