@libp2p/plaintext 1.1.6 → 2.0.0-18dd3cb26
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 +1 -1
- package/dist/index.min.js +4 -5
- package/dist/src/index.d.ts +4 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +33 -56
- package/dist/src/index.js.map +1 -1
- package/dist/src/pb/proto.d.ts +4 -4
- package/dist/src/pb/proto.d.ts.map +1 -1
- package/dist/src/pb/proto.js +26 -17
- package/dist/src/pb/proto.js.map +1 -1
- package/package.json +10 -9
- package/src/index.ts +35 -64
- package/src/pb/proto.proto +1 -1
- package/src/pb/proto.ts +26 -18
- package/dist/typedoc-urls.json +0 -8
package/src/pb/proto.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
7
|
+
import { type Codec, decodeMessage, type DecodeOptions, encodeMessage, enumeration, message } from 'protons-runtime'
|
|
8
|
+
import { alloc as uint8ArrayAlloc } from 'uint8arrays/alloc'
|
|
9
9
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
10
10
|
|
|
11
11
|
export interface Exchange {
|
|
@@ -36,7 +36,7 @@ export namespace Exchange {
|
|
|
36
36
|
if (opts.lengthDelimited !== false) {
|
|
37
37
|
w.ldelim()
|
|
38
38
|
}
|
|
39
|
-
}, (reader, length) => {
|
|
39
|
+
}, (reader, length, opts = {}) => {
|
|
40
40
|
const obj: any = {}
|
|
41
41
|
|
|
42
42
|
const end = length == null ? reader.len : reader.pos + length
|
|
@@ -45,15 +45,20 @@ export namespace Exchange {
|
|
|
45
45
|
const tag = reader.uint32()
|
|
46
46
|
|
|
47
47
|
switch (tag >>> 3) {
|
|
48
|
-
case 1:
|
|
48
|
+
case 1: {
|
|
49
49
|
obj.id = reader.bytes()
|
|
50
50
|
break
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
}
|
|
52
|
+
case 2: {
|
|
53
|
+
obj.pubkey = PublicKey.codec().decode(reader, reader.uint32(), {
|
|
54
|
+
limits: opts.limits?.pubkey
|
|
55
|
+
})
|
|
53
56
|
break
|
|
54
|
-
|
|
57
|
+
}
|
|
58
|
+
default: {
|
|
55
59
|
reader.skipType(tag & 7)
|
|
56
60
|
break
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -68,22 +73,22 @@ export namespace Exchange {
|
|
|
68
73
|
return encodeMessage(obj, Exchange.codec())
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): Exchange => {
|
|
72
|
-
return decodeMessage(buf, Exchange.codec())
|
|
76
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Exchange>): Exchange => {
|
|
77
|
+
return decodeMessage(buf, Exchange.codec(), opts)
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
export enum KeyType {
|
|
77
82
|
RSA = 'RSA',
|
|
78
83
|
Ed25519 = 'Ed25519',
|
|
79
|
-
|
|
84
|
+
secp256k1 = 'secp256k1',
|
|
80
85
|
ECDSA = 'ECDSA'
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
enum __KeyTypeValues {
|
|
84
89
|
RSA = 0,
|
|
85
90
|
Ed25519 = 1,
|
|
86
|
-
|
|
91
|
+
secp256k1 = 2,
|
|
87
92
|
ECDSA = 3
|
|
88
93
|
}
|
|
89
94
|
|
|
@@ -120,10 +125,10 @@ export namespace PublicKey {
|
|
|
120
125
|
if (opts.lengthDelimited !== false) {
|
|
121
126
|
w.ldelim()
|
|
122
127
|
}
|
|
123
|
-
}, (reader, length) => {
|
|
128
|
+
}, (reader, length, opts = {}) => {
|
|
124
129
|
const obj: any = {
|
|
125
130
|
Type: KeyType.RSA,
|
|
126
|
-
Data:
|
|
131
|
+
Data: uint8ArrayAlloc(0)
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
const end = length == null ? reader.len : reader.pos + length
|
|
@@ -132,15 +137,18 @@ export namespace PublicKey {
|
|
|
132
137
|
const tag = reader.uint32()
|
|
133
138
|
|
|
134
139
|
switch (tag >>> 3) {
|
|
135
|
-
case 1:
|
|
140
|
+
case 1: {
|
|
136
141
|
obj.Type = KeyType.codec().decode(reader)
|
|
137
142
|
break
|
|
138
|
-
|
|
143
|
+
}
|
|
144
|
+
case 2: {
|
|
139
145
|
obj.Data = reader.bytes()
|
|
140
146
|
break
|
|
141
|
-
|
|
147
|
+
}
|
|
148
|
+
default: {
|
|
142
149
|
reader.skipType(tag & 7)
|
|
143
150
|
break
|
|
151
|
+
}
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
|
|
@@ -155,7 +163,7 @@ export namespace PublicKey {
|
|
|
155
163
|
return encodeMessage(obj, PublicKey.codec())
|
|
156
164
|
}
|
|
157
165
|
|
|
158
|
-
export const decode = (buf: Uint8Array | Uint8ArrayList): PublicKey => {
|
|
159
|
-
return decodeMessage(buf, PublicKey.codec())
|
|
166
|
+
export const decode = (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<PublicKey>): PublicKey => {
|
|
167
|
+
return decodeMessage(buf, PublicKey.codec(), opts)
|
|
160
168
|
}
|
|
161
169
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
3
|
-
".:PlaintextComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextComponents.html",
|
|
4
|
-
"PlaintextInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextInit.html",
|
|
5
|
-
".:PlaintextInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_plaintext.PlaintextInit.html",
|
|
6
|
-
"plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html",
|
|
7
|
-
".:plaintext": "https://libp2p.github.io/js-libp2p/functions/_libp2p_plaintext.plaintext.html"
|
|
8
|
-
}
|