mockrtc 0.3.2 → 0.5.0

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 (60) hide show
  1. package/.github/workflows/ci.yml +5 -3
  2. package/README.md +2 -10
  3. package/dist/handling/handler-builder.js +13 -13
  4. package/dist/handling/handler-builder.js.map +1 -1
  5. package/dist/handling/handler-step-definitions.d.ts +36 -22
  6. package/dist/handling/handler-step-definitions.js +47 -34
  7. package/dist/handling/handler-step-definitions.js.map +1 -1
  8. package/dist/handling/handler-step-impls.d.ts +56 -0
  9. package/dist/handling/handler-step-impls.js +228 -0
  10. package/dist/handling/handler-step-impls.js.map +1 -0
  11. package/dist/main-browser.d.ts +2 -2
  12. package/dist/main-browser.js +3 -3
  13. package/dist/main-browser.js.map +1 -1
  14. package/dist/main.d.ts +3 -3
  15. package/dist/main.js +3 -3
  16. package/dist/main.js.map +1 -1
  17. package/dist/matching/matcher-definition-impls.d.ts +51 -0
  18. package/dist/matching/matcher-definition-impls.js +94 -0
  19. package/dist/matching/matcher-definition-impls.js.map +1 -0
  20. package/dist/matching/matcher-definition.d.ts +51 -0
  21. package/dist/matching/matcher-definition.js +94 -0
  22. package/dist/matching/matcher-definition.js.map +1 -0
  23. package/dist/matching/matcher-definitions.d.ts +14 -14
  24. package/dist/matching/matcher-definitions.js +22 -22
  25. package/dist/matching/matcher-definitions.js.map +1 -1
  26. package/dist/matching/matcher-impls.d.ts +27 -0
  27. package/dist/matching/matcher-impls.js +87 -0
  28. package/dist/matching/matcher-impls.js.map +1 -0
  29. package/dist/matching/matchers.d.ts +9 -9
  30. package/dist/matching/matchers.js +23 -23
  31. package/dist/matching/matchers.js.map +1 -1
  32. package/dist/rule-builder.js +7 -7
  33. package/dist/rule-builder.js.map +1 -1
  34. package/dist/server/mockrtc-admin-plugin.d.ts +1 -1
  35. package/dist/server/mockrtc-admin-plugin.js +7 -7
  36. package/dist/server/mockrtc-admin-plugin.js.map +1 -1
  37. package/dist/server/mockrtc-server-peer.d.ts +2 -2
  38. package/dist/server/mockrtc-server-peer.js.map +1 -1
  39. package/dist/server/mockrtc-server.js +6 -6
  40. package/dist/server/mockrtc-server.js.map +1 -1
  41. package/dist/webrtc/mockrtc-connection.d.ts +1 -1
  42. package/dist/webrtc/mockrtc-connection.js +1 -0
  43. package/dist/webrtc/mockrtc-connection.js.map +1 -1
  44. package/dist/webrtc/rtc-connection.d.ts +3 -3
  45. package/dist/webrtc/rtc-connection.js +3 -6
  46. package/dist/webrtc/rtc-connection.js.map +1 -1
  47. package/package.json +5 -6
  48. package/src/handling/handler-builder.ts +24 -24
  49. package/src/handling/handler-step-definitions.ts +38 -22
  50. package/src/handling/{handler-steps.ts → handler-step-impls.ts} +36 -39
  51. package/src/main-browser.ts +2 -2
  52. package/src/main.ts +3 -3
  53. package/src/matching/matcher-definitions.ts +14 -14
  54. package/src/matching/{matchers.ts → matcher-impls.ts} +22 -22
  55. package/src/rule-builder.ts +14 -14
  56. package/src/server/mockrtc-admin-plugin.ts +8 -8
  57. package/src/server/mockrtc-server-peer.ts +3 -3
  58. package/src/server/mockrtc-server.ts +8 -8
  59. package/src/webrtc/mockrtc-connection.ts +1 -0
  60. package/src/webrtc/rtc-connection.ts +9 -20
@@ -12,27 +12,27 @@ import type { MockRTCConnection } from '../webrtc/mockrtc-connection';
12
12
  import { RTCConnection } from '../webrtc/rtc-connection';
13
13
  import {
14
14
  StepDefinitionLookup,
15
- CloseStepDefinition,
16
- DynamicProxyStepDefinition,
17
- EchoStepDefinition,
15
+ CloseStep,
16
+ DynamicProxyStep,
17
+ EchoStep,
18
18
  HandlerStepDefinition,
19
- PeerProxyStepDefinition,
20
- CreateChannelStepDefinition,
21
- SendStepDefinition,
22
- WaitForChannelStepDefinition,
23
- WaitForDurationStepDefinition,
24
- WaitForMediaStepDefinition,
25
- WaitForMessageStepDefinition,
26
- WaitForTrackStepDefinition
19
+ PeerProxyStep,
20
+ CreateChannelStep,
21
+ SendStep,
22
+ WaitForChannelStep,
23
+ WaitForDurationStep,
24
+ WaitForMediaStep,
25
+ WaitForMessageStep,
26
+ WaitForTrackStep
27
27
  } from './handler-step-definitions';
28
28
 
29
29
  type ClientServerChannel = PluggableAdmin.Serialization.ClientServerChannel;
30
30
 
31
- export interface HandlerStep extends HandlerStepDefinition {
31
+ export interface HandlerStepImpl extends HandlerStepDefinition {
32
32
  handle(connection: MockRTCConnection): Promise<void>;
33
33
  }
34
34
 
35
- export class WaitForDurationStep extends WaitForDurationStepDefinition {
35
+ export class WaitForDurationStepImpl extends WaitForDurationStep {
36
36
 
37
37
  async handle(): Promise<void> {
38
38
  return new Promise<void>((resolve) => setTimeout(resolve, this.durationMs));
@@ -40,7 +40,7 @@ export class WaitForDurationStep extends WaitForDurationStepDefinition {
40
40
 
41
41
  }
42
42
 
43
- export class WaitForChannelStep extends WaitForChannelStepDefinition {
43
+ export class WaitForChannelStepImpl extends WaitForChannelStep {
44
44
 
45
45
  private matchesChannel(channel: DataChannelStream) {
46
46
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -62,7 +62,7 @@ export class WaitForChannelStep extends WaitForChannelStepDefinition {
62
62
 
63
63
  }
64
64
 
65
- export class WaitForMessageStep extends WaitForMessageStepDefinition {
65
+ export class WaitForMessageStepImpl extends WaitForMessageStep {
66
66
 
67
67
  private matchesChannel(channel: DataChannelStream) {
68
68
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -93,7 +93,7 @@ export class WaitForMessageStep extends WaitForMessageStepDefinition {
93
93
 
94
94
  }
95
95
 
96
- export class WaitForTrackStep extends WaitForTrackStepDefinition {
96
+ export class WaitForTrackStepImpl extends WaitForTrackStep {
97
97
 
98
98
  async handle(connection: MockRTCConnection): Promise<void> {
99
99
  await new Promise<void>((resolve) => {
@@ -104,7 +104,7 @@ export class WaitForTrackStep extends WaitForTrackStepDefinition {
104
104
 
105
105
  }
106
106
 
107
- export class WaitForMediaStep extends WaitForMediaStepDefinition {
107
+ export class WaitForMediaStepImpl extends WaitForMediaStep {
108
108
 
109
109
  async handle(connection: MockRTCConnection): Promise<void> {
110
110
  return new Promise<void>((resolve) => {
@@ -129,7 +129,7 @@ export class WaitForMediaStep extends WaitForMediaStepDefinition {
129
129
 
130
130
  }
131
131
 
132
- export class CreateChannelStep extends CreateChannelStepDefinition {
132
+ export class CreateChannelStepImpl extends CreateChannelStep {
133
133
 
134
134
  async handle(conn: MockRTCConnection): Promise<void> {
135
135
  const channel = conn.createDataChannel(this.channelLabel);
@@ -140,7 +140,7 @@ export class CreateChannelStep extends CreateChannelStepDefinition {
140
140
 
141
141
  }
142
142
 
143
- export class SendStep extends SendStepDefinition {
143
+ export class SendStepImpl extends SendStep {
144
144
 
145
145
  private matchesChannel(channel: DataChannelStream) {
146
146
  return this.channelLabel === undefined || this.channelLabel === channel.label;
@@ -177,7 +177,7 @@ export class SendStep extends SendStepDefinition {
177
177
 
178
178
  }
179
179
 
180
- export class CloseStep extends CloseStepDefinition {
180
+ export class CloseStepImpl extends CloseStep {
181
181
 
182
182
  async handle(connection: MockRTCConnection): Promise<void> {
183
183
  await connection.close();
@@ -185,7 +185,7 @@ export class CloseStep extends CloseStepDefinition {
185
185
 
186
186
  }
187
187
 
188
- export class EchoStep extends EchoStepDefinition {
188
+ export class EchoStepImpl extends EchoStep {
189
189
 
190
190
  async handle(connection: MockRTCConnection): Promise<void> {
191
191
  const echoContent = (stream: DataChannelStream | MediaTrackStream) => {
@@ -203,9 +203,7 @@ export class EchoStep extends EchoStepDefinition {
203
203
 
204
204
  }
205
205
 
206
- export class PeerProxyStep extends PeerProxyStepDefinition {
207
-
208
- private externalConnections: RTCConnection[] = [];
206
+ export class PeerProxyStepImpl extends PeerProxyStep {
209
207
 
210
208
  async handle(connection: MockRTCConnection) {
211
209
  const externalConn = new RTCConnection();
@@ -250,12 +248,11 @@ export class PeerProxyStep extends PeerProxyStepDefinition {
250
248
 
251
249
  }
252
250
 
253
- export class DynamicProxyStep extends DynamicProxyStepDefinition {
254
-
255
- private externalConnections: RTCConnection[] = [];
251
+ export class DynamicProxyStepImpl extends DynamicProxyStep {
256
252
 
257
253
  async handle(connection: MockRTCConnection) {
258
- await connection.proxyTrafficToExternalConnection();
254
+ const externalConn = await connection.proxyTrafficToExternalConnection();
255
+ this.externalConnections.push(externalConn);
259
256
 
260
257
  // This step keeps running indefinitely, until the connection closes
261
258
  return new Promise<void>((resolve) => connection.on('connection-closed', resolve));
@@ -268,15 +265,15 @@ export class DynamicProxyStep extends DynamicProxyStepDefinition {
268
265
  }
269
266
 
270
267
  export const StepLookup: typeof StepDefinitionLookup = {
271
- 'wait-for-duration': WaitForDurationStep,
272
- 'wait-for-rtc-data-channel': WaitForChannelStep,
273
- 'wait-for-rtc-track': WaitForTrackStep,
274
- 'wait-for-rtc-media': WaitForMediaStep,
275
- 'wait-for-rtc-message': WaitForMessageStep,
276
- 'create-rtc-data-channel': CreateChannelStep,
277
- 'send-rtc-data-message': SendStep,
278
- 'close-rtc-connection': CloseStep,
279
- 'echo-rtc': EchoStep,
280
- 'rtc-peer-proxy': PeerProxyStep,
281
- 'rtc-dynamic-proxy': DynamicProxyStep
268
+ 'wait-for-duration': WaitForDurationStepImpl,
269
+ 'wait-for-rtc-data-channel': WaitForChannelStepImpl,
270
+ 'wait-for-rtc-track': WaitForTrackStepImpl,
271
+ 'wait-for-rtc-media': WaitForMediaStepImpl,
272
+ 'wait-for-rtc-message': WaitForMessageStepImpl,
273
+ 'create-rtc-data-channel': CreateChannelStepImpl,
274
+ 'send-rtc-data-message': SendStepImpl,
275
+ 'close-rtc-connection': CloseStepImpl,
276
+ 'echo-rtc': EchoStepImpl,
277
+ 'rtc-peer-proxy': PeerProxyStepImpl,
278
+ 'rtc-dynamic-proxy': DynamicProxyStepImpl
282
279
  };
@@ -10,8 +10,8 @@ import type {
10
10
  import { MockRTCClient, MockRTCClientOptions } from "./client/mockrtc-client";
11
11
 
12
12
  // Export the required structures to remotely build and send rules to the admin API:
13
- export * as HandlerStepDefinitions from "./handling/handler-step-definitions";
14
- export * as MatcherDefinitions from "./matching/matcher-definitions";
13
+ export * as steps from "./handling/handler-step-definitions";
14
+ export * as matchers from "./matching/matcher-definitions";
15
15
  export { MockRTCAdminRequestBuilder } from "./client/mockrtc-admin-request-builder";
16
16
 
17
17
  export type {
package/src/main.ts CHANGED
@@ -22,12 +22,12 @@ export { MockRTCAdminPlugin } from "./server/mockrtc-admin-plugin";
22
22
  import { MockRTCClient, MockRTCClientOptions } from "./client/mockrtc-client";
23
23
 
24
24
  // Export the required structures to remotely build and send rules to the admin API:
25
- export * as HandlerStepDefinitions from "./handling/handler-step-definitions";
26
- export * as MatcherDefinitions from "./matching/matcher-definitions";
25
+ export * as steps from "./handling/handler-step-definitions";
26
+ export * as matchers from "./matching/matcher-definitions";
27
27
  export { MockRTCAdminRequestBuilder } from "./client/mockrtc-admin-request-builder";
28
28
 
29
29
  // Re-export lots of types are used in various APIs (mostly to make TypeDoc happy):
30
- export type { HandlerStep } from "./handling/handler-steps";
30
+ export type { HandlerStepImpl as HandlerStep } from "./handling/handler-step-impls";
31
31
  export type { MockRTCHandlerBuilder } from "./handling/handler-builder";
32
32
  export type { MockRTCRuleBuilder, RuleHandlerBuilder } from "./rule-builder";
33
33
 
@@ -12,7 +12,7 @@ export interface MatcherDefinition extends Serializable {
12
12
  readonly type: keyof typeof MatcherDefinitionLookup;
13
13
  }
14
14
 
15
- export class HasDataChannelMatcherDefinition extends Serializable implements MatcherDefinition {
15
+ export class HasDataChannelMatcher extends Serializable implements MatcherDefinition {
16
16
  readonly type = 'has-rtc-data-channel';
17
17
 
18
18
  explain() {
@@ -20,7 +20,7 @@ export class HasDataChannelMatcherDefinition extends Serializable implements Mat
20
20
  }
21
21
  }
22
22
 
23
- export class HasVideoTrackMatcherDefinition extends Serializable implements MatcherDefinition {
23
+ export class HasVideoTrackMatcher extends Serializable implements MatcherDefinition {
24
24
  readonly type = 'has-rtc-video-track';
25
25
 
26
26
  explain() {
@@ -28,7 +28,7 @@ export class HasVideoTrackMatcherDefinition extends Serializable implements Matc
28
28
  }
29
29
  }
30
30
 
31
- export class HasAudioTrackMatcherDefinition extends Serializable implements MatcherDefinition {
31
+ export class HasAudioTrackMatcher extends Serializable implements MatcherDefinition {
32
32
  readonly type = 'has-rtc-audio-track';
33
33
 
34
34
  explain() {
@@ -36,7 +36,7 @@ export class HasAudioTrackMatcherDefinition extends Serializable implements Matc
36
36
  }
37
37
  }
38
38
 
39
- export class HasMediaTrackMatcherDefinition extends Serializable implements MatcherDefinition {
39
+ export class HasMediaTrackMatcher extends Serializable implements MatcherDefinition {
40
40
  readonly type = 'has-rtc-media-track';
41
41
 
42
42
  explain() {
@@ -44,7 +44,7 @@ export class HasMediaTrackMatcherDefinition extends Serializable implements Matc
44
44
  }
45
45
  }
46
46
 
47
- export class HostnameMatcherDefinition extends Serializable implements MatcherDefinition {
47
+ export class HostnameMatcher extends Serializable implements MatcherDefinition {
48
48
 
49
49
  readonly type = 'rtc-page-hostname';
50
50
 
@@ -60,7 +60,7 @@ export class HostnameMatcherDefinition extends Serializable implements MatcherDe
60
60
 
61
61
  }
62
62
 
63
- export class UrlRegexMatcherDefinition extends Serializable implements MatcherDefinition {
63
+ export class UrlRegexMatcher extends Serializable implements MatcherDefinition {
64
64
 
65
65
  readonly type = 'rtc-page-regex';
66
66
 
@@ -79,7 +79,7 @@ export class UrlRegexMatcherDefinition extends Serializable implements MatcherDe
79
79
 
80
80
  }
81
81
 
82
- export class UserAgentRegexMatcherDefinition extends Serializable implements MatcherDefinition {
82
+ export class UserAgentRegexMatcher extends Serializable implements MatcherDefinition {
83
83
 
84
84
  readonly type = 'rtc-user-agent-regex';
85
85
 
@@ -99,11 +99,11 @@ export class UserAgentRegexMatcherDefinition extends Serializable implements Ma
99
99
  }
100
100
 
101
101
  export const MatcherDefinitionLookup = {
102
- 'has-rtc-data-channel': HasDataChannelMatcherDefinition,
103
- 'has-rtc-video-track': HasVideoTrackMatcherDefinition,
104
- 'has-rtc-audio-track': HasAudioTrackMatcherDefinition,
105
- 'has-rtc-media-track': HasMediaTrackMatcherDefinition,
106
- 'rtc-page-hostname': HostnameMatcherDefinition,
107
- 'rtc-page-regex': UrlRegexMatcherDefinition,
108
- 'rtc-user-agent-regex': UserAgentRegexMatcherDefinition
102
+ 'has-rtc-data-channel': HasDataChannelMatcher,
103
+ 'has-rtc-video-track': HasVideoTrackMatcher,
104
+ 'has-rtc-audio-track': HasAudioTrackMatcher,
105
+ 'has-rtc-media-track': HasMediaTrackMatcher,
106
+ 'rtc-page-hostname': HostnameMatcher,
107
+ 'rtc-page-regex': UrlRegexMatcher,
108
+ 'rtc-user-agent-regex': UserAgentRegexMatcher
109
109
  };
@@ -7,20 +7,20 @@ import { RTCConnection } from "../webrtc/rtc-connection";
7
7
  import {
8
8
  MatcherDefinition,
9
9
  MatcherDefinitionLookup,
10
- HasAudioTrackMatcherDefinition,
11
- HasDataChannelMatcherDefinition,
12
- HasMediaTrackMatcherDefinition,
13
- HasVideoTrackMatcherDefinition,
14
- HostnameMatcherDefinition,
15
- UrlRegexMatcherDefinition,
16
- UserAgentRegexMatcherDefinition
10
+ HasAudioTrackMatcher,
11
+ HasDataChannelMatcher,
12
+ HasMediaTrackMatcher,
13
+ HasVideoTrackMatcher,
14
+ HostnameMatcher,
15
+ UrlRegexMatcher,
16
+ UserAgentRegexMatcher
17
17
  } from "./matcher-definitions";
18
18
 
19
- export interface Matcher extends MatcherDefinition {
19
+ export interface MatcherImpl extends MatcherDefinition {
20
20
  matches(connection: RTCConnection): boolean;
21
21
  }
22
22
 
23
- export class HasDataChannelMatcher extends HasDataChannelMatcherDefinition {
23
+ export class HasDataChannelMatcherImpl extends HasDataChannelMatcher {
24
24
 
25
25
  matches(connection: RTCConnection): boolean {
26
26
  return [
@@ -31,7 +31,7 @@ export class HasDataChannelMatcher extends HasDataChannelMatcherDefinition {
31
31
 
32
32
  }
33
33
 
34
- export class HasVideoTrackMatcher extends HasVideoTrackMatcherDefinition {
34
+ export class HasVideoTrackMatcherImpl extends HasVideoTrackMatcher {
35
35
 
36
36
  matches(connection: RTCConnection): boolean {
37
37
  return [
@@ -42,7 +42,7 @@ export class HasVideoTrackMatcher extends HasVideoTrackMatcherDefinition {
42
42
 
43
43
  }
44
44
 
45
- export class HasAudioTrackMatcher extends HasAudioTrackMatcherDefinition {
45
+ export class HasAudioTrackMatcherImpl extends HasAudioTrackMatcher {
46
46
 
47
47
  matches(connection: RTCConnection): boolean {
48
48
  return [
@@ -53,7 +53,7 @@ export class HasAudioTrackMatcher extends HasAudioTrackMatcherDefinition {
53
53
 
54
54
  }
55
55
 
56
- export class HasMediaTrackMatcher extends HasMediaTrackMatcherDefinition {
56
+ export class HasMediaTrackMatcherImpl extends HasMediaTrackMatcher {
57
57
 
58
58
  matches(connection: RTCConnection): boolean {
59
59
  return [
@@ -76,7 +76,7 @@ const getConnectionSourceURL = (connection: RTCConnection): URL | undefined => {
76
76
  }
77
77
  };
78
78
 
79
- export class HostnameMatcher extends HostnameMatcherDefinition {
79
+ export class HostnameMatcherImpl extends HostnameMatcher {
80
80
 
81
81
  matches(connection: RTCConnection): boolean {
82
82
  const url = getConnectionSourceURL(connection);
@@ -85,7 +85,7 @@ export class HostnameMatcher extends HostnameMatcherDefinition {
85
85
 
86
86
  }
87
87
 
88
- export class UrlRegexMatcher extends UrlRegexMatcherDefinition {
88
+ export class UrlRegexMatcherImpl extends UrlRegexMatcher {
89
89
 
90
90
  matches(connection: RTCConnection): boolean {
91
91
  const url = getConnectionSourceURL(connection);
@@ -96,7 +96,7 @@ export class UrlRegexMatcher extends UrlRegexMatcherDefinition {
96
96
 
97
97
  }
98
98
 
99
- export class UserAgentRegexMatcher extends UserAgentRegexMatcherDefinition {
99
+ export class UserAgentRegexMatcherImpl extends UserAgentRegexMatcher {
100
100
 
101
101
  matches(connection: RTCConnection): boolean {
102
102
  const userAgent = connection.metadata.userAgent;
@@ -108,11 +108,11 @@ export class UserAgentRegexMatcher extends UserAgentRegexMatcherDefinition {
108
108
  }
109
109
 
110
110
  export const MatcherLookup: typeof MatcherDefinitionLookup = {
111
- 'has-rtc-data-channel': HasDataChannelMatcher,
112
- 'has-rtc-video-track': HasVideoTrackMatcher,
113
- 'has-rtc-audio-track': HasAudioTrackMatcher,
114
- 'has-rtc-media-track': HasMediaTrackMatcher,
115
- 'rtc-page-hostname': HostnameMatcher,
116
- 'rtc-page-regex': UrlRegexMatcher,
117
- 'rtc-user-agent-regex': UserAgentRegexMatcher
111
+ 'has-rtc-data-channel': HasDataChannelMatcherImpl,
112
+ 'has-rtc-video-track': HasVideoTrackMatcherImpl,
113
+ 'has-rtc-audio-track': HasAudioTrackMatcherImpl,
114
+ 'has-rtc-media-track': HasMediaTrackMatcherImpl,
115
+ 'rtc-page-hostname': HostnameMatcherImpl,
116
+ 'rtc-page-regex': UrlRegexMatcherImpl,
117
+ 'rtc-user-agent-regex': UserAgentRegexMatcherImpl
118
118
  };
@@ -7,13 +7,13 @@ import { MockRTCHandlerBuilder } from "./handling/handler-builder";
7
7
  import { HandlerStepDefinition } from "./handling/handler-step-definitions";
8
8
  import {
9
9
  MatcherDefinition,
10
- HostnameMatcherDefinition,
11
- UrlRegexMatcherDefinition,
12
- UserAgentRegexMatcherDefinition,
13
- HasAudioTrackMatcherDefinition,
14
- HasVideoTrackMatcherDefinition,
15
- HasMediaTrackMatcherDefinition,
16
- HasDataChannelMatcherDefinition
10
+ HostnameMatcher,
11
+ UrlRegexMatcher,
12
+ UserAgentRegexMatcher,
13
+ HasAudioTrackMatcher,
14
+ HasVideoTrackMatcher,
15
+ HasMediaTrackMatcher,
16
+ HasDataChannelMatcher
17
17
  } from "./matching/matcher-definitions";
18
18
 
19
19
  export type RuleHandlerBuilder = MockRTCHandlerBuilder<void>;
@@ -38,7 +38,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
38
38
  * Match RTC connections whose initial negotiation includes a data channel.
39
39
  */
40
40
  withDataChannels() {
41
- this.matchers.push(new HasDataChannelMatcherDefinition());
41
+ this.matchers.push(new HasDataChannelMatcher());
42
42
  return this;
43
43
  }
44
44
 
@@ -47,7 +47,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
47
47
  * media track.
48
48
  */
49
49
  withMedia() {
50
- this.matchers.push(new HasMediaTrackMatcherDefinition());
50
+ this.matchers.push(new HasMediaTrackMatcher());
51
51
  return this;
52
52
  }
53
53
 
@@ -55,7 +55,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
55
55
  * Match RTC connections whose initial negotiation includes a video media track
56
56
  */
57
57
  withVideo() {
58
- this.matchers.push(new HasVideoTrackMatcherDefinition());
58
+ this.matchers.push(new HasVideoTrackMatcher());
59
59
  return this;
60
60
  }
61
61
 
@@ -63,7 +63,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
63
63
  * Match RTC connections whose initial negotiation includes an audio media track
64
64
  */
65
65
  withAudio() {
66
- this.matchers.push(new HasAudioTrackMatcherDefinition());
66
+ this.matchers.push(new HasAudioTrackMatcher());
67
67
  return this;
68
68
  }
69
69
 
@@ -78,7 +78,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
78
78
  * @category Matcher
79
79
  */
80
80
  fromPageHostname(hostname: string): this {
81
- this.matchers.push(new HostnameMatcherDefinition(hostname));
81
+ this.matchers.push(new HostnameMatcher(hostname));
82
82
  return this;
83
83
  }
84
84
 
@@ -93,7 +93,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
93
93
  * @category Matcher
94
94
  */
95
95
  fromPageUrlMatching(urlRegex: RegExp): this {
96
- this.matchers.push(new UrlRegexMatcherDefinition(urlRegex));
96
+ this.matchers.push(new UrlRegexMatcher(urlRegex));
97
97
  return this;
98
98
  }
99
99
 
@@ -109,7 +109,7 @@ export class MockRTCRuleBuilder implements Omit<RuleHandlerBuilder, 'handlerStep
109
109
  * @category Matcher
110
110
  */
111
111
  fromUserAgentMatching(userAgentRegEx: RegExp): this {
112
- this.matchers.push(new UserAgentRegexMatcherDefinition(userAgentRegEx));
112
+ this.matchers.push(new UserAgentRegexMatcher(userAgentRegEx));
113
113
  return this;
114
114
  }
115
115
 
@@ -10,12 +10,12 @@ import { PluggableAdmin } from 'mockttp';
10
10
  import type { IResolvers } from "@graphql-tools/utils";
11
11
  import { PubSub } from "graphql-subscriptions";
12
12
 
13
- import { StepLookup } from '../handling/handler-steps';
13
+ import { StepLookup } from '../handling/handler-step-impls';
14
14
  import { MockRTCOptions, MockRTCSessionDescription } from '../mockrtc';
15
15
  import { MockRTCServer } from './mockrtc-server';
16
16
  import { AnswerOptions, OfferOptions } from '../mockrtc-peer';
17
17
  import { MatcherDefinition } from '../matching/matcher-definitions';
18
- import { MatcherLookup } from '../matching/matchers';
18
+ import { MatcherLookup } from '../matching/matcher-impls';
19
19
  import { HandlerStepDefinition } from '../handling/handler-step-definitions';
20
20
 
21
21
  const { deserialize } = PluggableAdmin.Serialization;
@@ -225,7 +225,7 @@ export class MockRTCAdminPlugin implements PluggableAdmin.AdminPlugin<MockRTCOpt
225
225
  }
226
226
  `;
227
227
 
228
- buildResolvers(adminStream: stream.Duplex, ruleParams: {}): IResolvers {
228
+ buildResolvers(adminStream: stream.Duplex): IResolvers {
229
229
  const pubsub = new PubSub();
230
230
 
231
231
  EVENTS.forEach((eventName) => {
@@ -241,7 +241,7 @@ export class MockRTCAdminPlugin implements PluggableAdmin.AdminPlugin<MockRTCOpt
241
241
  } }) => {
242
242
  return this.mockRTCServer.buildPeerFromDefinition(
243
243
  steps.map((stepData) =>
244
- deserialize(stepData, adminStream, ruleParams, StepLookup)
244
+ deserialize(stepData, adminStream, {}, StepLookup)
245
245
  )
246
246
  );
247
247
  },
@@ -251,10 +251,10 @@ export class MockRTCAdminPlugin implements PluggableAdmin.AdminPlugin<MockRTCOpt
251
251
  } }) => {
252
252
  return this.mockRTCServer.addRuleFromDefinition(
253
253
  matchers.map((matcherData) =>
254
- deserialize(matcherData, adminStream, ruleParams, MatcherLookup)
254
+ deserialize(matcherData, adminStream, {}, MatcherLookup)
255
255
  ),
256
256
  steps.map((stepData) =>
257
- deserialize(stepData, adminStream, ruleParams, StepLookup)
257
+ deserialize(stepData, adminStream, {}, StepLookup)
258
258
  )
259
259
  );
260
260
  },
@@ -265,10 +265,10 @@ export class MockRTCAdminPlugin implements PluggableAdmin.AdminPlugin<MockRTCOpt
265
265
  return this.mockRTCServer.setRulesFromDefinitions(
266
266
  rules.map(({ matchers, steps }) => ({
267
267
  matchers: matchers.map((matcherData) =>
268
- deserialize(matcherData, adminStream, ruleParams, MatcherLookup)
268
+ deserialize(matcherData, adminStream, {}, MatcherLookup)
269
269
  ),
270
270
  steps: steps.map((stepData) =>
271
- deserialize(stepData, adminStream, ruleParams, StepLookup)
271
+ deserialize(stepData, adminStream, {}, StepLookup)
272
272
  )
273
273
  }))
274
274
  );
@@ -18,7 +18,7 @@ import {
18
18
  OfferOptions,
19
19
  AnswerOptions
20
20
  } from "../mockrtc-peer";
21
- import { HandlerStep } from '../handling/handler-steps';
21
+ import { HandlerStepImpl } from '../handling/handler-step-impls';
22
22
 
23
23
  import { RTCConnection } from '../webrtc/rtc-connection';
24
24
  import { MockRTCConnection } from '../webrtc/mockrtc-connection';
@@ -28,7 +28,7 @@ import { TimingEvents } from '../mockrtc';
28
28
 
29
29
  export class MockRTCServerPeer implements MockRTCPeer {
30
30
 
31
- readonly peerId = randomUUID();
31
+ readonly peerId: string = randomUUID();
32
32
 
33
33
  private debug: boolean = false;
34
34
 
@@ -40,7 +40,7 @@ export class MockRTCServerPeer implements MockRTCPeer {
40
40
 
41
41
  constructor(
42
42
  private getHandlerSteps: (conn: RTCConnection) =>
43
- (HandlerStep[] | Promise<HandlerStep[]>),
43
+ (HandlerStepImpl[] | Promise<HandlerStepImpl[]>),
44
44
  private options: MockRTCPeerOptions & { peerId?: string } = {},
45
45
  private eventEmitter: EventEmitter
46
46
  ) {
@@ -12,9 +12,9 @@ import { MockRTCPeer } from "../mockrtc-peer";
12
12
  import { RTCConnection } from "../webrtc/rtc-connection";
13
13
 
14
14
  import type { MatcherDefinition } from "../matching/matcher-definitions";
15
- import { Matcher, MatcherLookup } from "../matching/matchers";
15
+ import { MatcherImpl, MatcherLookup } from "../matching/matcher-impls";
16
16
  import type { HandlerStepDefinition } from "../handling/handler-step-definitions";
17
- import { DynamicProxyStep, HandlerStep, StepLookup } from "../handling/handler-steps";
17
+ import { DynamicProxyStepImpl, HandlerStepImpl, StepLookup } from "../handling/handler-step-impls";
18
18
 
19
19
  const MATCHING_PEER_ID = 'matching-peer';
20
20
 
@@ -86,8 +86,8 @@ export class MockRTCServer extends MockRTCBase implements MockRTC {
86
86
  }
87
87
 
88
88
  private rules: Array<{
89
- matchers: Matcher[],
90
- handlerSteps: HandlerStep[]
89
+ matchers: MatcherImpl[],
90
+ handlerSteps: HandlerStepImpl[]
91
91
  }> = [];
92
92
 
93
93
  async setRulesFromDefinitions(
@@ -106,14 +106,14 @@ export class MockRTCServer extends MockRTCBase implements MockRTC {
106
106
  matcherDefinitions: MatcherDefinition[],
107
107
  handlerStepDefinitions: HandlerStepDefinition[]
108
108
  ) {
109
- const matchers = matcherDefinitions.map((definition): Matcher => {
109
+ const matchers = matcherDefinitions.map((definition): MatcherImpl => {
110
110
  return Object.assign(
111
111
  Object.create(MatcherLookup[definition.type].prototype),
112
112
  definition
113
113
  );
114
114
  });
115
115
 
116
- const handlerSteps = handlerStepDefinitions.map((definition): HandlerStep => {
116
+ const handlerSteps = handlerStepDefinitions.map((definition): HandlerStepImpl => {
117
117
  return Object.assign(
118
118
  Object.create(StepLookup[definition.type].prototype),
119
119
  definition
@@ -143,13 +143,13 @@ export class MockRTCServer extends MockRTCBase implements MockRTC {
143
143
 
144
144
  // Unmatched connections are proxied dynamically. In practice, that means they're accepted
145
145
  // and ignored initially, unless an external peer also connects and is attached:
146
- return [new DynamicProxyStep()];
146
+ return [new DynamicProxyStepImpl()];
147
147
  }
148
148
 
149
149
  // Peer definition API:
150
150
 
151
151
  async buildPeerFromDefinition(handlerStepDefinitions: HandlerStepDefinition[]): Promise<MockRTCServerPeer> {
152
- const handlerSteps = handlerStepDefinitions.map((definition): HandlerStep => {
152
+ const handlerSteps = handlerStepDefinitions.map((definition): HandlerStepImpl => {
153
153
  return Object.assign(
154
154
  Object.create(StepLookup[definition.type].prototype),
155
155
  definition
@@ -90,6 +90,7 @@ export class MockRTCConnection extends RTCConnection {
90
90
  }
91
91
 
92
92
  await this.proxyTrafficTo(this.externalConnection!);
93
+ return this.externalConnection!;
93
94
  }
94
95
 
95
96
  async proxyTrafficTo(externalConnection: RTCConnection) {