@peerbit/stream-interface 6.0.4 → 6.0.6
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/src/keys.d.ts.map +1 -1
- package/dist/src/keys.js +7 -2
- package/dist/src/keys.js.map +1 -1
- package/dist/src/messages.d.ts +1 -1
- package/package.json +2 -2
- package/src/keys.ts +9 -2
package/dist/src/keys.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAExE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,QAAQ,GACjB,OAAO,GACP,OAAO,EAAE,GACT,GAAG,CAAC,MAAM,CAAC,GACX,gBAAgB,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAY,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAA0B,MAAM,iBAAiB,CAAC;AAExE,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,QAAQ,GACjB,OAAO,GACP,OAAO,EAAE,GACT,GAAG,CAAC,MAAM,CAAC,GACX,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAS7B,eAAO,MAAM,mBAAmB,GAAI,IAAI,OAAO,WAM9C,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,KAAK,QAAQ,aAqBnD,CAAC"}
|
package/dist/src/keys.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { isPeerId } from "@libp2p/interface";
|
|
2
2
|
import { PublicSignKey, getPublicKeyFromPeerId } from "@peerbit/crypto";
|
|
3
|
+
const isPublicSignKeyLike = (value) => value instanceof PublicSignKey ||
|
|
4
|
+
(!!value &&
|
|
5
|
+
typeof value === "object" &&
|
|
6
|
+
typeof value.hashcode === "function" &&
|
|
7
|
+
value.bytes instanceof Uint8Array);
|
|
3
8
|
export const coercePeerRefToHash = (to) => {
|
|
4
|
-
return to
|
|
9
|
+
return isPublicSignKeyLike(to)
|
|
5
10
|
? to.hashcode()
|
|
6
11
|
: typeof to === "string"
|
|
7
12
|
? to
|
|
@@ -9,7 +14,7 @@ export const coercePeerRefToHash = (to) => {
|
|
|
9
14
|
};
|
|
10
15
|
export const coercePeerRefsToHashes = (tos) => {
|
|
11
16
|
if (isPeerId(tos) ||
|
|
12
|
-
tos
|
|
17
|
+
isPublicSignKeyLike(tos) ||
|
|
13
18
|
typeof tos === "string") {
|
|
14
19
|
return [coercePeerRefToHash(tos)];
|
|
15
20
|
}
|
package/dist/src/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AASxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAW,EAAE,EAAE;IAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AASxE,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAA0B,EAAE,CACtE,KAAK,YAAY,aAAa;IAC9B,CAAC,CAAC,CA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essage<T extends SilentDelivery | AcknowledgeDelivery
|
|
|
154
154
|
get dataByteLength(): number;
|
|
155
155
|
get hasData(): boolean;
|
|
156
156
|
/** Manually ser/der for performance gains */
|
|
157
|
-
bytes():
|
|
157
|
+
bytes(): Uint8Array<ArrayBufferLike> | Uint8ArrayList;
|
|
158
158
|
getSignableBytes(): Uint8Array;
|
|
159
159
|
private setDataSource;
|
|
160
160
|
private serializeBytes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peerbit/stream-interface",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Block store streaming",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@dao-xyz/borsh": "^6.0.0",
|
|
72
72
|
"@libp2p/interface": "^3.1.0",
|
|
73
73
|
"uint8arraylist": "^2.4.8",
|
|
74
|
-
"@peerbit/crypto": "3.0
|
|
74
|
+
"@peerbit/crypto": "3.1.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"clean": "aegir clean",
|
package/src/keys.ts
CHANGED
|
@@ -8,8 +8,15 @@ export type PeerRefs =
|
|
|
8
8
|
| Set<string>
|
|
9
9
|
| IterableIterator<PeerRef>;
|
|
10
10
|
|
|
11
|
+
const isPublicSignKeyLike = (value: unknown): value is PublicSignKey =>
|
|
12
|
+
value instanceof PublicSignKey ||
|
|
13
|
+
(!!value &&
|
|
14
|
+
typeof value === "object" &&
|
|
15
|
+
typeof (value as PublicSignKey).hashcode === "function" &&
|
|
16
|
+
(value as PublicSignKey).bytes instanceof Uint8Array);
|
|
17
|
+
|
|
11
18
|
export const coercePeerRefToHash = (to: PeerRef) => {
|
|
12
|
-
return to
|
|
19
|
+
return isPublicSignKeyLike(to)
|
|
13
20
|
? to.hashcode()
|
|
14
21
|
: typeof to === "string"
|
|
15
22
|
? to
|
|
@@ -19,7 +26,7 @@ export const coercePeerRefToHash = (to: PeerRef) => {
|
|
|
19
26
|
export const coercePeerRefsToHashes = (tos: PeerRefs) => {
|
|
20
27
|
if (
|
|
21
28
|
isPeerId(tos) ||
|
|
22
|
-
tos
|
|
29
|
+
isPublicSignKeyLike(tos) ||
|
|
23
30
|
typeof tos === "string"
|
|
24
31
|
) {
|
|
25
32
|
return [coercePeerRefToHash(tos)];
|