@libp2p/interface-compliance-tests 4.1.5-c960eb659 → 4.1.5-d8f5bc211

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.
Files changed (54) hide show
  1. package/README.md +1 -1
  2. package/dist/src/connection-encryption/utils/index.d.ts.map +1 -1
  3. package/dist/src/connection-encryption/utils/index.js +3 -1
  4. package/dist/src/connection-encryption/utils/index.js.map +1 -1
  5. package/dist/src/mocks/connection-manager.d.ts +2 -1
  6. package/dist/src/mocks/connection-manager.d.ts.map +1 -1
  7. package/dist/src/mocks/connection-manager.js.map +1 -1
  8. package/dist/src/mocks/connection.d.ts +2 -0
  9. package/dist/src/mocks/connection.d.ts.map +1 -1
  10. package/dist/src/mocks/connection.js +56 -12
  11. package/dist/src/mocks/connection.js.map +1 -1
  12. package/dist/src/mocks/index.d.ts +0 -1
  13. package/dist/src/mocks/index.d.ts.map +1 -1
  14. package/dist/src/mocks/index.js +0 -1
  15. package/dist/src/mocks/index.js.map +1 -1
  16. package/dist/src/mocks/multiaddr-connection.d.ts.map +1 -1
  17. package/dist/src/mocks/multiaddr-connection.js +6 -2
  18. package/dist/src/mocks/multiaddr-connection.js.map +1 -1
  19. package/dist/src/mocks/muxer.d.ts +1 -1
  20. package/dist/src/mocks/muxer.d.ts.map +1 -1
  21. package/dist/src/mocks/muxer.js +17 -5
  22. package/dist/src/mocks/muxer.js.map +1 -1
  23. package/dist/src/mocks/peer-discovery.d.ts.map +1 -1
  24. package/dist/src/mocks/peer-discovery.js +1 -2
  25. package/dist/src/mocks/peer-discovery.js.map +1 -1
  26. package/dist/src/pubsub/api.d.ts.map +1 -1
  27. package/dist/src/pubsub/api.js +0 -2
  28. package/dist/src/pubsub/api.js.map +1 -1
  29. package/dist/src/pubsub/index.d.ts +2 -0
  30. package/dist/src/pubsub/index.d.ts.map +1 -1
  31. package/dist/src/pubsub/index.js.map +1 -1
  32. package/dist/src/pubsub/utils.d.ts.map +1 -1
  33. package/dist/src/pubsub/utils.js +3 -1
  34. package/dist/src/pubsub/utils.js.map +1 -1
  35. package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
  36. package/dist/src/stream-muxer/close-test.js +42 -11
  37. package/dist/src/stream-muxer/close-test.js.map +1 -1
  38. package/package.json +15 -15
  39. package/src/connection-encryption/utils/index.ts +3 -1
  40. package/src/mocks/connection-manager.ts +2 -1
  41. package/src/mocks/connection.ts +64 -14
  42. package/src/mocks/index.ts +0 -1
  43. package/src/mocks/multiaddr-connection.ts +6 -2
  44. package/src/mocks/muxer.ts +20 -7
  45. package/src/mocks/peer-discovery.ts +1 -2
  46. package/src/pubsub/api.ts +0 -2
  47. package/src/pubsub/index.ts +2 -0
  48. package/src/pubsub/utils.ts +3 -1
  49. package/src/stream-muxer/close-test.ts +47 -9
  50. package/dist/src/mocks/connection-encrypter.d.ts +0 -3
  51. package/dist/src/mocks/connection-encrypter.d.ts.map +0 -1
  52. package/dist/src/mocks/connection-encrypter.js +0 -98
  53. package/dist/src/mocks/connection-encrypter.js.map +0 -1
  54. package/src/mocks/connection-encrypter.ts +0 -113
@@ -1,3 +0,0 @@
1
- import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter';
2
- export declare function mockConnectionEncrypter(): ConnectionEncrypter;
3
- //# sourceMappingURL=connection-encrypter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-encrypter.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection-encrypter.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAYjF,wBAAgB,uBAAuB,IAAK,mBAAmB,CA6F9D"}
@@ -1,98 +0,0 @@
1
- import { UnexpectedPeerError } from '@libp2p/interface/errors';
2
- import { peerIdFromBytes } from '@libp2p/peer-id';
3
- import { multiaddr } from '@multiformats/multiaddr';
4
- import { handshake } from 'it-handshake';
5
- import map from 'it-map';
6
- import { duplexPair } from 'it-pair/duplex';
7
- import { pipe } from 'it-pipe';
8
- // A basic transform that does nothing to the data
9
- const transform = () => {
10
- return (source) => (async function* () {
11
- for await (const chunk of source) {
12
- yield chunk;
13
- }
14
- })();
15
- };
16
- export function mockConnectionEncrypter() {
17
- const encrypter = {
18
- protocol: 'insecure',
19
- secureInbound: async (localPeer, duplex, expectedPeer) => {
20
- // 1. Perform a basic handshake.
21
- const shake = handshake(duplex);
22
- shake.write(localPeer.toBytes());
23
- const remoteId = await shake.read();
24
- if (remoteId == null) {
25
- throw new Error('Could not read remote ID');
26
- }
27
- const remotePeer = peerIdFromBytes(remoteId.slice());
28
- shake.rest();
29
- if (expectedPeer?.equals(remotePeer) === false) {
30
- throw new UnexpectedPeerError();
31
- }
32
- // 2. Create your encryption box/unbox wrapper
33
- const wrapper = duplexPair();
34
- const encrypt = transform(); // Use transform iterables to modify data
35
- const decrypt = transform();
36
- void pipe(wrapper[0], // We write to wrapper
37
- encrypt, // The data is encrypted
38
- shake.stream, // It goes to the remote peer
39
- // It goes to the remote peer
40
- source => map(source, (list) => list.subarray()), // turn lists into arrays
41
- decrypt, // Decrypt the incoming data
42
- wrapper[0] // Pipe to the wrapper
43
- );
44
- return {
45
- conn: {
46
- ...wrapper[1],
47
- close: async () => { },
48
- localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
49
- remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
50
- timeline: {
51
- open: Date.now()
52
- },
53
- conn: true
54
- },
55
- remotePeer,
56
- remoteExtensions: {}
57
- };
58
- },
59
- secureOutbound: async (localPeer, duplex, remotePeer) => {
60
- // 1. Perform a basic handshake.
61
- const shake = handshake(duplex);
62
- shake.write(localPeer.toBytes());
63
- const remoteId = await shake.read();
64
- if (remoteId == null) {
65
- throw new Error('Could not read remote ID');
66
- }
67
- shake.rest();
68
- // 2. Create your encryption box/unbox wrapper
69
- const wrapper = duplexPair();
70
- const encrypt = transform();
71
- const decrypt = transform();
72
- void pipe(wrapper[0], // We write to wrapper
73
- encrypt, // The data is encrypted
74
- shake.stream, // It goes to the remote peer
75
- // It goes to the remote peer
76
- source => map(source, (list) => list.subarray()), // turn lists into arrays
77
- decrypt, // Decrypt the incoming data
78
- wrapper[0] // Pipe to the wrapper
79
- );
80
- return {
81
- conn: {
82
- ...wrapper[1],
83
- close: async () => { },
84
- localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
85
- remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
86
- timeline: {
87
- open: Date.now()
88
- },
89
- conn: true
90
- },
91
- remotePeer: peerIdFromBytes(remoteId.slice()),
92
- remoteExtensions: {}
93
- };
94
- }
95
- };
96
- return encrypter;
97
- }
98
- //# sourceMappingURL=connection-encrypter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connection-encrypter.js","sourceRoot":"","sources":["../../../src/mocks/connection-encrypter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAI9B,kDAAkD;AAClD,MAAM,SAAS,GAAG,GAA+C,EAAE;IACjE,OAAO,CAAC,MAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,SAAU,CAAC;QAC7C,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE;YAChC,MAAM,KAAK,CAAA;SACZ;IACH,CAAC,CAAC,EAAE,CAAA;AACN,CAAC,CAAA;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,SAAS,GAAwB;QACrC,QAAQ,EAAE,UAAU;QACpB,aAAa,EAAE,K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E,GAAG,CAAC;oBACtB,SAAS,EAAE,SAAS,CAAC,yBAAyB,CAAC;oBAC/C,UAAU,EAAE,SAAS,CAAC,yBAAyB,CAAC;oBAChD,QAAQ,EAAE;wBACR,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;qBACjB;oBACD,IAAI,EAAE,IAAI;iBACX;gBACD,UAAU,EAAE,eAAe,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAC7C,gBAAgB,EAAE,EAAE;aACrB,CAAA;QACH,CAAC;KACF,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -1,113 +0,0 @@
1
- import { UnexpectedPeerError } from '@libp2p/interface/errors'
2
- import { peerIdFromBytes } from '@libp2p/peer-id'
3
- import { multiaddr } from '@multiformats/multiaddr'
4
- import { handshake } from 'it-handshake'
5
- import map from 'it-map'
6
- import { duplexPair } from 'it-pair/duplex'
7
- import { pipe } from 'it-pipe'
8
- import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter'
9
- import type { Transform, Source } from 'it-stream-types'
10
-
11
- // A basic transform that does nothing to the data
12
- const transform = <T>(): Transform<Source<T>, AsyncGenerator<T>> => {
13
- return (source: Source<T>) => (async function * () {
14
- for await (const chunk of source) {
15
- yield chunk
16
- }
17
- })()
18
- }
19
-
20
- export function mockConnectionEncrypter (): ConnectionEncrypter {
21
- const encrypter: ConnectionEncrypter = {
22
- protocol: 'insecure',
23
- secureInbound: async (localPeer, duplex, expectedPeer) => {
24
- // 1. Perform a basic handshake.
25
- const shake = handshake<Uint8Array>(duplex)
26
- shake.write(localPeer.toBytes())
27
- const remoteId = await shake.read()
28
-
29
- if (remoteId == null) {
30
- throw new Error('Could not read remote ID')
31
- }
32
-
33
- const remotePeer = peerIdFromBytes(remoteId.slice())
34
- shake.rest()
35
-
36
- if (expectedPeer?.equals(remotePeer) === false) {
37
- throw new UnexpectedPeerError()
38
- }
39
-
40
- // 2. Create your encryption box/unbox wrapper
41
- const wrapper = duplexPair<Uint8Array>()
42
- const encrypt = transform<Uint8Array>() // Use transform iterables to modify data
43
- const decrypt = transform<Uint8Array>()
44
-
45
- void pipe(
46
- wrapper[0], // We write to wrapper
47
- encrypt, // The data is encrypted
48
- shake.stream, // It goes to the remote peer
49
- source => map(source, (list) => list.subarray()), // turn lists into arrays
50
- decrypt, // Decrypt the incoming data
51
- wrapper[0] // Pipe to the wrapper
52
- )
53
-
54
- return {
55
- conn: {
56
- ...wrapper[1],
57
- close: async () => { },
58
- localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
59
- remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
60
- timeline: {
61
- open: Date.now()
62
- },
63
- conn: true
64
- },
65
- remotePeer,
66
- remoteExtensions: {}
67
- }
68
- },
69
- secureOutbound: async (localPeer, duplex, remotePeer) => {
70
- // 1. Perform a basic handshake.
71
- const shake = handshake<Uint8Array>(duplex)
72
- shake.write(localPeer.toBytes())
73
- const remoteId = await shake.read()
74
-
75
- if (remoteId == null) {
76
- throw new Error('Could not read remote ID')
77
- }
78
-
79
- shake.rest()
80
-
81
- // 2. Create your encryption box/unbox wrapper
82
- const wrapper = duplexPair<Uint8Array>()
83
- const encrypt = transform<Uint8Array>()
84
- const decrypt = transform<Uint8Array>()
85
-
86
- void pipe(
87
- wrapper[0], // We write to wrapper
88
- encrypt, // The data is encrypted
89
- shake.stream, // It goes to the remote peer
90
- source => map(source, (list) => list.subarray()), // turn lists into arrays
91
- decrypt, // Decrypt the incoming data
92
- wrapper[0] // Pipe to the wrapper
93
- )
94
-
95
- return {
96
- conn: {
97
- ...wrapper[1],
98
- close: async () => { },
99
- localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
100
- remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
101
- timeline: {
102
- open: Date.now()
103
- },
104
- conn: true
105
- },
106
- remotePeer: peerIdFromBytes(remoteId.slice()),
107
- remoteExtensions: {}
108
- }
109
- }
110
- }
111
-
112
- return encrypter
113
- }