@libp2p/interface-compliance-tests 3.0.7 → 4.0.0-72e81dc1

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 (184) hide show
  1. package/README.md +12 -3
  2. package/dist/src/connection/index.d.ts +5 -0
  3. package/dist/src/connection/index.d.ts.map +1 -0
  4. package/dist/src/connection/index.js +150 -0
  5. package/dist/src/connection/index.js.map +1 -0
  6. package/dist/src/connection-encryption/index.d.ts +5 -0
  7. package/dist/src/connection-encryption/index.d.ts.map +1 -0
  8. package/dist/src/connection-encryption/index.js +71 -0
  9. package/dist/src/connection-encryption/index.js.map +1 -0
  10. package/dist/src/connection-encryption/utils/index.d.ts +3 -0
  11. package/dist/src/connection-encryption/utils/index.d.ts.map +1 -0
  12. package/dist/src/connection-encryption/utils/index.js +19 -0
  13. package/dist/src/connection-encryption/utils/index.js.map +1 -0
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/is-valid-tick.d.ts.map +1 -1
  16. package/dist/src/is-valid-tick.js.map +1 -1
  17. package/dist/src/mocks/connection-encrypter.d.ts +3 -0
  18. package/dist/src/mocks/connection-encrypter.d.ts.map +1 -0
  19. package/dist/src/mocks/connection-encrypter.js +98 -0
  20. package/dist/src/mocks/connection-encrypter.js.map +1 -0
  21. package/dist/src/mocks/connection-gater.d.ts +3 -0
  22. package/dist/src/mocks/connection-gater.d.ts.map +1 -0
  23. package/dist/src/mocks/connection-gater.js +17 -0
  24. package/dist/src/mocks/connection-gater.js.map +1 -0
  25. package/dist/src/mocks/connection-manager.d.ts +29 -0
  26. package/dist/src/mocks/connection-manager.d.ts.map +1 -0
  27. package/dist/src/mocks/connection-manager.js +145 -0
  28. package/dist/src/mocks/connection-manager.js.map +1 -0
  29. package/dist/src/mocks/connection.d.ts +32 -0
  30. package/dist/src/mocks/connection.d.ts.map +1 -0
  31. package/dist/src/mocks/connection.js +167 -0
  32. package/dist/src/mocks/connection.js.map +1 -0
  33. package/dist/src/mocks/duplex.d.ts +3 -0
  34. package/dist/src/mocks/duplex.d.ts.map +1 -0
  35. package/dist/src/mocks/duplex.js +9 -0
  36. package/dist/src/mocks/duplex.js.map +1 -0
  37. package/dist/src/mocks/index.d.ts +13 -0
  38. package/dist/src/mocks/index.d.ts.map +1 -0
  39. package/dist/src/mocks/index.js +11 -0
  40. package/dist/src/mocks/index.js.map +1 -0
  41. package/dist/src/mocks/metrics.d.ts +3 -0
  42. package/dist/src/mocks/metrics.d.ts.map +1 -0
  43. package/dist/src/mocks/metrics.js +115 -0
  44. package/dist/src/mocks/metrics.js.map +1 -0
  45. package/dist/src/mocks/multiaddr-connection.d.ts +17 -0
  46. package/dist/src/mocks/multiaddr-connection.d.ts.map +1 -0
  47. package/dist/src/mocks/multiaddr-connection.js +60 -0
  48. package/dist/src/mocks/multiaddr-connection.js.map +1 -0
  49. package/dist/src/mocks/muxer.d.ts +36 -0
  50. package/dist/src/mocks/muxer.d.ts.map +1 -0
  51. package/dist/src/mocks/muxer.js +213 -0
  52. package/dist/src/mocks/muxer.js.map +1 -0
  53. package/dist/src/mocks/peer-discovery.d.ts +22 -0
  54. package/dist/src/mocks/peer-discovery.d.ts.map +1 -0
  55. package/dist/src/mocks/peer-discovery.js +47 -0
  56. package/dist/src/mocks/peer-discovery.js.map +1 -0
  57. package/dist/src/mocks/registrar.d.ts +18 -0
  58. package/dist/src/mocks/registrar.d.ts.map +1 -0
  59. package/dist/src/mocks/registrar.js +66 -0
  60. package/dist/src/mocks/registrar.js.map +1 -0
  61. package/dist/src/mocks/upgrader.d.ts +10 -0
  62. package/dist/src/mocks/upgrader.d.ts.map +1 -0
  63. package/dist/src/mocks/upgrader.js +31 -0
  64. package/dist/src/mocks/upgrader.js.map +1 -0
  65. package/dist/src/peer-discovery/index.d.ts +5 -0
  66. package/dist/src/peer-discovery/index.d.ts.map +1 -0
  67. package/dist/src/peer-discovery/index.js +66 -0
  68. package/dist/src/peer-discovery/index.js.map +1 -0
  69. package/dist/src/pubsub/api.d.ts +6 -0
  70. package/dist/src/pubsub/api.d.ts.map +1 -0
  71. package/dist/src/pubsub/api.js +87 -0
  72. package/dist/src/pubsub/api.js.map +1 -0
  73. package/dist/src/pubsub/connection-handlers.d.ts +6 -0
  74. package/dist/src/pubsub/connection-handlers.d.ts.map +1 -0
  75. package/dist/src/pubsub/connection-handlers.js +329 -0
  76. package/dist/src/pubsub/connection-handlers.js.map +1 -0
  77. package/dist/src/pubsub/emit-self.d.ts +6 -0
  78. package/dist/src/pubsub/emit-self.d.ts.map +1 -0
  79. package/dist/src/pubsub/emit-self.js +80 -0
  80. package/dist/src/pubsub/emit-self.js.map +1 -0
  81. package/dist/src/pubsub/index.d.ts +18 -0
  82. package/dist/src/pubsub/index.d.ts.map +1 -0
  83. package/dist/src/pubsub/index.js +17 -0
  84. package/dist/src/pubsub/index.js.map +1 -0
  85. package/dist/src/pubsub/messages.d.ts +6 -0
  86. package/dist/src/pubsub/messages.d.ts.map +1 -0
  87. package/dist/src/pubsub/messages.js +48 -0
  88. package/dist/src/pubsub/messages.js.map +1 -0
  89. package/dist/src/pubsub/multiple-nodes.d.ts +6 -0
  90. package/dist/src/pubsub/multiple-nodes.d.ts.map +1 -0
  91. package/dist/src/pubsub/multiple-nodes.js +350 -0
  92. package/dist/src/pubsub/multiple-nodes.js.map +1 -0
  93. package/dist/src/pubsub/two-nodes.d.ts +6 -0
  94. package/dist/src/pubsub/two-nodes.d.ts.map +1 -0
  95. package/dist/src/pubsub/two-nodes.js +217 -0
  96. package/dist/src/pubsub/two-nodes.js.map +1 -0
  97. package/dist/src/pubsub/utils.d.ts +6 -0
  98. package/dist/src/pubsub/utils.d.ts.map +1 -0
  99. package/dist/src/pubsub/utils.js +22 -0
  100. package/dist/src/pubsub/utils.js.map +1 -0
  101. package/dist/src/stream-muxer/base-test.d.ts +5 -0
  102. package/dist/src/stream-muxer/base-test.d.ts.map +1 -0
  103. package/dist/src/stream-muxer/base-test.js +153 -0
  104. package/dist/src/stream-muxer/base-test.js.map +1 -0
  105. package/dist/src/stream-muxer/close-test.d.ts +5 -0
  106. package/dist/src/stream-muxer/close-test.d.ts.map +1 -0
  107. package/dist/src/stream-muxer/close-test.js +357 -0
  108. package/dist/src/stream-muxer/close-test.js.map +1 -0
  109. package/dist/src/stream-muxer/fixtures/pb/message.d.ts +13 -0
  110. package/dist/src/stream-muxer/fixtures/pb/message.d.ts.map +1 -0
  111. package/dist/src/stream-muxer/fixtures/pb/message.js +67 -0
  112. package/dist/src/stream-muxer/fixtures/pb/message.js.map +1 -0
  113. package/dist/src/stream-muxer/index.d.ts +5 -0
  114. package/dist/src/stream-muxer/index.d.ts.map +1 -0
  115. package/dist/src/stream-muxer/index.js +13 -0
  116. package/dist/src/stream-muxer/index.js.map +1 -0
  117. package/dist/src/stream-muxer/mega-stress-test.d.ts +5 -0
  118. package/dist/src/stream-muxer/mega-stress-test.d.ts.map +1 -0
  119. package/dist/src/stream-muxer/mega-stress-test.js +11 -0
  120. package/dist/src/stream-muxer/mega-stress-test.js.map +1 -0
  121. package/dist/src/stream-muxer/spawner.d.ts +4 -0
  122. package/dist/src/stream-muxer/spawner.d.ts.map +1 -0
  123. package/dist/src/stream-muxer/spawner.js +37 -0
  124. package/dist/src/stream-muxer/spawner.js.map +1 -0
  125. package/dist/src/stream-muxer/stress-test.d.ts +5 -0
  126. package/dist/src/stream-muxer/stress-test.d.ts.map +1 -0
  127. package/dist/src/stream-muxer/stress-test.js +23 -0
  128. package/dist/src/stream-muxer/stress-test.js.map +1 -0
  129. package/dist/src/transport/dial-test.d.ts +5 -0
  130. package/dist/src/transport/dial-test.d.ts.map +1 -0
  131. package/dist/src/transport/dial-test.js +98 -0
  132. package/dist/src/transport/dial-test.js.map +1 -0
  133. package/dist/src/transport/filter-test.d.ts +5 -0
  134. package/dist/src/transport/filter-test.d.ts.map +1 -0
  135. package/dist/src/transport/filter-test.js +18 -0
  136. package/dist/src/transport/filter-test.js.map +1 -0
  137. package/dist/src/transport/index.d.ts +15 -0
  138. package/dist/src/transport/index.d.ts.map +1 -0
  139. package/dist/src/transport/index.js +11 -0
  140. package/dist/src/transport/index.js.map +1 -0
  141. package/dist/src/transport/listen-test.d.ts +5 -0
  142. package/dist/src/transport/listen-test.d.ts.map +1 -0
  143. package/dist/src/transport/listen-test.js +152 -0
  144. package/dist/src/transport/listen-test.js.map +1 -0
  145. package/package.json +74 -97
  146. package/src/connection/index.ts +182 -0
  147. package/src/connection-encryption/index.ts +97 -0
  148. package/src/connection-encryption/utils/index.ts +24 -0
  149. package/src/index.ts +0 -1
  150. package/src/is-valid-tick.ts +0 -1
  151. package/src/mocks/connection-encrypter.ts +113 -0
  152. package/src/mocks/connection-gater.ts +18 -0
  153. package/src/mocks/connection-manager.ts +211 -0
  154. package/src/mocks/connection.ts +226 -0
  155. package/src/mocks/duplex.ts +10 -0
  156. package/src/mocks/index.ts +12 -0
  157. package/src/mocks/metrics.ts +162 -0
  158. package/src/mocks/multiaddr-connection.ts +76 -0
  159. package/src/mocks/muxer.ts +303 -0
  160. package/src/mocks/peer-discovery.ts +60 -0
  161. package/src/mocks/registrar.ts +88 -0
  162. package/src/mocks/upgrader.ts +49 -0
  163. package/src/peer-discovery/index.ts +90 -0
  164. package/src/pubsub/api.ts +114 -0
  165. package/src/pubsub/connection-handlers.ts +413 -0
  166. package/src/pubsub/emit-self.ts +99 -0
  167. package/src/pubsub/index.ts +34 -0
  168. package/src/pubsub/messages.ts +59 -0
  169. package/src/pubsub/multiple-nodes.ts +440 -0
  170. package/src/pubsub/two-nodes.ts +273 -0
  171. package/src/pubsub/utils.ts +29 -0
  172. package/src/stream-muxer/base-test.ts +196 -0
  173. package/src/stream-muxer/close-test.ts +442 -0
  174. package/src/stream-muxer/fixtures/pb/message.proto +7 -0
  175. package/src/stream-muxer/fixtures/pb/message.ts +87 -0
  176. package/src/stream-muxer/index.ts +15 -0
  177. package/src/stream-muxer/mega-stress-test.ts +14 -0
  178. package/src/stream-muxer/spawner.ts +55 -0
  179. package/src/stream-muxer/stress-test.ts +27 -0
  180. package/src/transport/dial-test.ts +124 -0
  181. package/src/transport/filter-test.ts +25 -0
  182. package/src/transport/index.ts +25 -0
  183. package/src/transport/listen-test.ts +191 -0
  184. package/dist/typedoc-urls.json +0 -3
package/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
4
4
  [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
5
- [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces)
6
- [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-interfaces/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-interfaces/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
5
+ [![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
6
+ [![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)
7
7
 
8
8
  > Compliance tests for JS libp2p interfaces
9
9
 
10
10
  ## Table of contents <!-- omit in toc -->
11
11
 
12
12
  - [Install](#install)
13
+ - [Browser `<script>` tag](#browser-script-tag)
13
14
  - [Usage](#usage)
14
15
  - [API Docs](#api-docs)
15
16
  - [License](#license)
@@ -21,13 +22,21 @@
21
22
  $ npm i @libp2p/interface-compliance-tests
22
23
  ```
23
24
 
25
+ ### Browser `<script>` tag
26
+
27
+ Loading this module through a script tag will make it's exports available as `Libp2pInterfaceComplianceTests` in the global namespace.
28
+
29
+ ```html
30
+ <script src="https://unpkg.com/@libp2p/interface-compliance-tests/dist/index.min.js"></script>
31
+ ```
32
+
24
33
  ## Usage
25
34
 
26
35
  Each [interface](https://npmjs.org/packages/@libp2p/interfaces) has its documentation on how to use the compliance tests and should be used as the source of truth.
27
36
 
28
37
  ## API Docs
29
38
 
30
- - <https://libp2p.github.io/js-libp2p-interfaces/modules/_libp2p_interface_compliance_tests.html>
39
+ - <https://libp2p.github.io/js-libp2p/modules/_libp2p_interface_compliance_tests.html>
31
40
 
32
41
  ## License
33
42
 
@@ -0,0 +1,5 @@
1
+ import type { TestSetup } from '../index.js';
2
+ import type { Connection } from '@libp2p/interface/connection';
3
+ declare const _default: (test: TestSetup<Connection>) => void;
4
+ export default _default;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,8BAA8B,CAAA;+BAEhD,UAAU,UAAU,CAAC,KAAG,IAAI;AAAlD,wBA+KC"}
@@ -0,0 +1,150 @@
1
+ import { expect } from 'aegir/chai';
2
+ import sinon from 'sinon';
3
+ import { stubInterface } from 'ts-sinon';
4
+ export default (test) => {
5
+ describe('connection', () => {
6
+ describe('open connection', () => {
7
+ let connection;
8
+ beforeEach(async () => {
9
+ connection = await test.setup();
10
+ });
11
+ afterEach(async () => {
12
+ await connection.close();
13
+ await test.teardown();
14
+ });
15
+ it('should have properties set', () => {
16
+ expect(connection.id).to.exist();
17
+ expect(connection.remotePeer).to.exist();
18
+ expect(connection.remoteAddr).to.exist();
19
+ expect(connection.status).to.equal('open');
20
+ expect(connection.timeline.open).to.exist();
21
+ expect(connection.timeline.close).to.not.exist();
22
+ expect(connection.direction).to.exist();
23
+ expect(connection.streams).to.eql([]);
24
+ expect(connection.tags).to.eql([]);
25
+ });
26
+ it('should get the metadata of an open connection', () => {
27
+ expect(connection.status).to.equal('open');
28
+ expect(connection.direction).to.exist();
29
+ expect(connection.timeline.open).to.exist();
30
+ expect(connection.timeline.close).to.not.exist();
31
+ });
32
+ it('should return an empty array of streams', () => {
33
+ const streams = connection.streams;
34
+ expect(streams).to.eql([]);
35
+ });
36
+ it('should be able to create a new stream', async () => {
37
+ expect(connection.streams).to.be.empty();
38
+ const protocolToUse = '/echo/0.0.1';
39
+ const stream = await connection.newStream([protocolToUse]);
40
+ expect(stream).to.have.property('protocol', protocolToUse);
41
+ const connStreams = connection.streams;
42
+ expect(stream).to.exist();
43
+ expect(connStreams).to.exist();
44
+ expect(connStreams).to.have.lengthOf(1);
45
+ expect(connStreams[0]).to.equal(stream);
46
+ });
47
+ });
48
+ describe('close connection', () => {
49
+ let connection;
50
+ let timelineProxy;
51
+ const proxyHandler = {
52
+ set() {
53
+ // @ts-expect-error - TS fails to infer here
54
+ return Reflect.set(...arguments);
55
+ }
56
+ };
57
+ beforeEach(async () => {
58
+ timelineProxy = new Proxy({
59
+ open: Date.now() - 10,
60
+ upgraded: Date.now()
61
+ }, proxyHandler);
62
+ connection = await test.setup();
63
+ connection.timeline = timelineProxy;
64
+ });
65
+ afterEach(async () => {
66
+ await test.teardown();
67
+ });
68
+ it('should be able to close the connection after being created', async () => {
69
+ expect(connection.timeline.close).to.not.exist();
70
+ await connection.close();
71
+ expect(connection.timeline.close).to.exist();
72
+ expect(connection.status).to.equal('closed');
73
+ });
74
+ it('should be able to close the connection after opening a stream', async () => {
75
+ // Open stream
76
+ const protocol = '/echo/0.0.1';
77
+ await connection.newStream([protocol]);
78
+ // Close connection
79
+ expect(connection.timeline.close).to.not.exist();
80
+ await connection.close();
81
+ expect(connection.timeline.close).to.exist();
82
+ expect(connection.status).to.equal('closed');
83
+ });
84
+ it('should properly track streams', async () => {
85
+ // Open stream
86
+ const protocol = '/echo/0.0.1';
87
+ const stream = await connection.newStream([protocol]);
88
+ expect(stream).to.have.property('protocol', protocol);
89
+ // Close stream
90
+ await stream.close();
91
+ expect(connection.streams.filter(s => s.id === stream.id)).to.be.empty();
92
+ });
93
+ it('should track outbound streams', async () => {
94
+ // Open stream
95
+ const protocol = '/echo/0.0.1';
96
+ const stream = await connection.newStream(protocol);
97
+ expect(stream).to.have.property('direction', 'outbound');
98
+ });
99
+ it.skip('should track inbound streams', async () => {
100
+ // Add an remotely opened stream
101
+ const stream = stubInterface();
102
+ connection.addStream(stream);
103
+ expect(stream).to.have.property('direction', 'inbound');
104
+ });
105
+ it('should support a proxy on the timeline', async () => {
106
+ sinon.spy(proxyHandler, 'set');
107
+ expect(connection.timeline.close).to.not.exist();
108
+ await connection.close();
109
+ // @ts-expect-error - fails to infer callCount
110
+ expect(proxyHandler.set.callCount).to.equal(1);
111
+ // @ts-expect-error - fails to infer getCall
112
+ const [obj, key, value] = proxyHandler.set.getCall(0).args;
113
+ expect(obj).to.eql(connection.timeline);
114
+ expect(key).to.equal('close');
115
+ expect(value).to.be.a('number').that.equals(connection.timeline.close);
116
+ });
117
+ it('should fail to create a new stream if the connection is closing', async () => {
118
+ expect(connection.timeline.close).to.not.exist();
119
+ const p = connection.close();
120
+ try {
121
+ const protocol = '/echo/0.0.1';
122
+ await connection.newStream([protocol]);
123
+ }
124
+ catch (err) {
125
+ expect(err).to.exist();
126
+ return;
127
+ }
128
+ finally {
129
+ await p;
130
+ }
131
+ throw new Error('should fail to create a new stream if the connection is closing');
132
+ });
133
+ it('should fail to create a new stream if the connection is closed', async () => {
134
+ expect(connection.timeline.close).to.not.exist();
135
+ await connection.close();
136
+ try {
137
+ const protocol = '/echo/0.0.1';
138
+ await connection.newStream([protocol]);
139
+ }
140
+ catch (err) {
141
+ expect(err).to.exist();
142
+ expect(err.code).to.equal('ERR_CONNECTION_CLOSED');
143
+ return;
144
+ }
145
+ throw new Error('should fail to create a new stream if the connection is closing');
146
+ });
147
+ });
148
+ });
149
+ };
150
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],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,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;iBACvC;gBAAC,OAAO,GAAQ,EAAE;oBACjB,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;oBACtB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;oBAClD,OAAM;iBACP;gBAED,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;YACpF,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { TestSetup } from '../index.js';
2
+ import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter';
3
+ declare const _default: (common: TestSetup<ConnectionEncrypter>) => void;
4
+ export default _default;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-encryption/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;iCAGzD,UAAU,mBAAmB,CAAC,KAAG,IAAI;AAA7D,wBAoFC"}
@@ -0,0 +1,71 @@
1
+ import { UnexpectedPeerError } from '@libp2p/interface/errors';
2
+ import * as PeerIdFactory from '@libp2p/peer-id-factory';
3
+ import { expect } from 'aegir/chai';
4
+ import all from 'it-all';
5
+ import { pipe } from 'it-pipe';
6
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
7
+ import peers from '../peers.js';
8
+ import { createMaConnPair } from './utils/index.js';
9
+ export default (common) => {
10
+ describe('interface-connection-encrypter compliance tests', () => {
11
+ let crypto;
12
+ let localPeer;
13
+ let remotePeer;
14
+ let mitmPeer;
15
+ before(async () => {
16
+ [
17
+ crypto,
18
+ localPeer,
19
+ remotePeer,
20
+ mitmPeer
21
+ ] = await Promise.all([
22
+ common.setup(),
23
+ PeerIdFactory.createFromJSON(peers[0]),
24
+ PeerIdFactory.createFromJSON(peers[1]),
25
+ PeerIdFactory.createFromJSON(peers[2])
26
+ ]);
27
+ });
28
+ after(async () => {
29
+ await common.teardown();
30
+ });
31
+ it('has a protocol string', () => {
32
+ expect(crypto.protocol).to.exist();
33
+ expect(crypto.protocol).to.be.a('string');
34
+ });
35
+ it('it wraps the provided duplex connection', async () => {
36
+ const [localConn, remoteConn] = createMaConnPair();
37
+ const [inboundResult, outboundResult] = await Promise.all([
38
+ crypto.secureInbound(remotePeer, localConn),
39
+ crypto.secureOutbound(localPeer, remoteConn, remotePeer)
40
+ ]);
41
+ // Echo server
42
+ void pipe(inboundResult.conn, inboundResult.conn);
43
+ // Send some data and collect the result
44
+ const input = uint8ArrayFromString('data to encrypt');
45
+ const result = await pipe([input], outboundResult.conn, async (source) => all(source));
46
+ expect(result).to.eql([input]);
47
+ });
48
+ it('should return the remote peer id', async () => {
49
+ const [localConn, remoteConn] = createMaConnPair();
50
+ const [inboundResult, outboundResult] = await Promise.all([
51
+ crypto.secureInbound(remotePeer, localConn),
52
+ crypto.secureOutbound(localPeer, remoteConn, remotePeer)
53
+ ]);
54
+ // Inbound should return the initiator (local) peer
55
+ expect(inboundResult.remotePeer.toBytes()).to.equalBytes(localPeer.toBytes());
56
+ // Outbound should return the receiver (remote) peer
57
+ expect(outboundResult.remotePeer.toBytes()).to.equalBytes(remotePeer.toBytes());
58
+ });
59
+ it('inbound connections should verify peer integrity if known', async () => {
60
+ const [localConn, remoteConn] = createMaConnPair();
61
+ await Promise.all([
62
+ crypto.secureInbound(remotePeer, localConn, mitmPeer),
63
+ crypto.secureOutbound(localPeer, remoteConn, remotePeer)
64
+ ]).then(() => expect.fail(), (err) => {
65
+ expect(err).to.exist();
66
+ expect(err).to.have.property('code', UnexpectedPeerError.code);
67
+ });
68
+ });
69
+ });
70
+ };
71
+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BAC3C,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;aACzD,CAAC,CAAA;YAEF,mDAAmD;YACnD,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;YAC7E,oDAAoD;YACpD,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;QACjF,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,gBAAgB,EAAE,CAAA;YAElD,MAAM,OAAO,CAAC,GAAG,CAAC;gBAChB,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;gBACrD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;aACzD,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;gBACnC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;gBACtB,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAA;YAChE,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { MultiaddrConnection } from '@libp2p/interface/connection';
2
+ export declare function createMaConnPair(): [MultiaddrConnection, MultiaddrConnection];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection-encryption/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAGvE,wBAAgB,gBAAgB,IAAK,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAkB9E"}
@@ -0,0 +1,19 @@
1
+ import { multiaddr } from '@multiformats/multiaddr';
2
+ import { duplexPair } from 'it-pair/duplex';
3
+ export function createMaConnPair() {
4
+ const [local, remote] = duplexPair();
5
+ function duplexToMaConn(duplex) {
6
+ const output = {
7
+ ...duplex,
8
+ close: async () => { },
9
+ abort: () => { },
10
+ remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
11
+ timeline: {
12
+ open: Date.now()
13
+ }
14
+ };
15
+ return output;
16
+ }
17
+ return [duplexToMaConn(local), duplexToMaConn(remote)];
18
+ }
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/connection-encryption/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAI3C,MAAM,UAAU,gBAAgB;IAC9B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,UAAU,EAAc,CAAA;IAEhD,SAAS,cAAc,CAAE,MAA6E;QACpG,MAAM,MAAM,GAAwB;YAClC,GAAG,MAAM;YACT,KAAK,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;YACrB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,UAAU,EAAE,SAAS,CAAC,yBAAyB,CAAC;YAChD,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;aACjB;SACF,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;AACxD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACvC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/D,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IACvC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-tick.d.ts","sourceRoot":"","sources":["../../src/is-valid-tick.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAE,MAAa,GAAG,OAAO,CAYtE"}
1
+ {"version":3,"file":"is-valid-tick.d.ts","sourceRoot":"","sources":["../../src/is-valid-tick.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAE,MAAa,GAAG,OAAO,CAYtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"is-valid-tick.js","sourceRoot":"","sources":["../../src/is-valid-tick.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,IAAa,EAAE,KAAa,IAAI;IAC3D,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;KACzC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAEtB,IAAI,IAAI,GAAG,GAAG,GAAG,EAAE,IAAI,IAAI,IAAI,GAAG,EAAE;QAClC,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
1
+ {"version":3,"file":"is-valid-tick.js","sourceRoot":"","sources":["../../src/is-valid-tick.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,IAAa,EAAE,KAAa,IAAI;IAC3D,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;KACzC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAEtB,IAAI,IAAI,GAAG,GAAG,GAAG,EAAE,IAAI,IAAI,IAAI,GAAG,EAAE;QAClC,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter';
2
+ export declare function mockConnectionEncrypter(): ConnectionEncrypter;
3
+ //# sourceMappingURL=connection-encrypter.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,98 @@
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
@@ -0,0 +1 @@
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;S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,CAAC,CAAC,CAAC,CAAC,sBAAsB;aAClC,CAAA;YAED,OAAO;gBACL,IAAI,EAAE;oBACJ,GAAG,OAAO,CAAC,CAAC,CAAC;oBACb,KAAK,EAAE,KAAK,IAAI,EAAE,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"}
@@ -0,0 +1,3 @@
1
+ import type { ConnectionGater } from '@libp2p/interface/connection-gater';
2
+ export declare function mockConnectionGater(): ConnectionGater;
3
+ //# sourceMappingURL=connection-gater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-gater.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection-gater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAEzE,wBAAgB,mBAAmB,IAAK,eAAe,CAetD"}
@@ -0,0 +1,17 @@
1
+ export function mockConnectionGater() {
2
+ return {
3
+ denyDialPeer: async () => Promise.resolve(false),
4
+ denyDialMultiaddr: async () => Promise.resolve(false),
5
+ denyInboundConnection: async () => Promise.resolve(false),
6
+ denyOutboundConnection: async () => Promise.resolve(false),
7
+ denyInboundEncryptedConnection: async () => Promise.resolve(false),
8
+ denyOutboundEncryptedConnection: async () => Promise.resolve(false),
9
+ denyInboundUpgradedConnection: async () => Promise.resolve(false),
10
+ denyOutboundUpgradedConnection: async () => Promise.resolve(false),
11
+ denyInboundRelayReservation: async () => Promise.resolve(false),
12
+ denyOutboundRelayedConnection: async () => Promise.resolve(false),
13
+ denyInboundRelayedConnection: async () => Promise.resolve(false),
14
+ filterMultiaddrForPeer: async () => Promise.resolve(true)
15
+ };
16
+ }
17
+ //# sourceMappingURL=connection-gater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-gater.js","sourceRoot":"","sources":["../../../src/mocks/connection-gater.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB;IACjC,OAAO;QACL,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAChD,iBAAiB,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACrD,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACzD,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1D,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAClE,+BAA+B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACnE,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACjE,8BAA8B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAClE,2BAA2B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/D,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QACjE,4BAA4B,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;QAChE,sBAAsB,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;KAC1D,CAAA;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type PeerId } from '@libp2p/interface/peer-id';
2
+ import { type Multiaddr } from '@multiformats/multiaddr';
3
+ import type { Libp2pEvents } from '@libp2p/interface';
4
+ import type { EventEmitter } from '@libp2p/interface/events';
5
+ import type { PubSub } from '@libp2p/interface/pubsub';
6
+ import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager';
7
+ import type { Registrar } from '@libp2p/interface-internal/registrar';
8
+ export interface MockNetworkComponents {
9
+ peerId: PeerId;
10
+ registrar: Registrar;
11
+ connectionManager: ConnectionManager;
12
+ events: EventEmitter<Libp2pEvents>;
13
+ pubsub?: PubSub;
14
+ }
15
+ declare class MockNetwork {
16
+ private components;
17
+ addNode(components: MockNetworkComponents): void;
18
+ getNode(peerId: PeerId | Multiaddr[]): MockNetworkComponents;
19
+ reset(): void;
20
+ }
21
+ export declare const mockNetwork: MockNetwork;
22
+ export interface MockConnectionManagerComponents {
23
+ peerId: PeerId;
24
+ registrar: Registrar;
25
+ events: EventEmitter<Libp2pEvents>;
26
+ }
27
+ export declare function mockConnectionManager(components: MockConnectionManagerComponents): ConnectionManager;
28
+ export {};
29
+ //# sourceMappingURL=connection-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-manager.d.ts","sourceRoot":"","sources":["../../../src/mocks/connection-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGjE,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAErE,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAA;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAA;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAErE,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAA;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,cAAM,WAAW;IACf,OAAO,CAAC,UAAU,CAA8B;IAEhD,OAAO,CAAE,UAAU,EAAE,qBAAqB,GAAG,IAAI;IAIjD,OAAO,CAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAG,GAAG,qBAAqB;IAc9D,KAAK,IAAK,IAAI;CAGf;AAED,eAAO,MAAM,WAAW,aAAoB,CAAA;AAE5C,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAA;CACnC;AA0JD,wBAAgB,qBAAqB,CAAE,UAAU,EAAE,+BAA+B,GAAG,iBAAiB,CAErG"}