mockrtc 0.4.0 → 0.5.1
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/.github/workflows/ci.yml +99 -8
- package/README.md +1 -9
- package/dist/client/mockrtc-client.d.ts +1 -1
- package/dist/client/mockrtc-remote-peer.d.ts +1 -0
- package/dist/handling/handler-builder.d.ts +1 -0
- package/dist/handling/handler-builder.js +13 -13
- package/dist/handling/handler-builder.js.map +1 -1
- package/dist/handling/handler-step-definitions.d.ts +39 -24
- package/dist/handling/handler-step-definitions.js +47 -34
- package/dist/handling/handler-step-definitions.js.map +1 -1
- package/dist/handling/handler-step-impls.d.ts +56 -0
- package/dist/handling/{handler-steps.js → handler-step-impls.js} +39 -46
- package/dist/handling/handler-step-impls.js.map +1 -0
- package/dist/main-browser.d.ts +2 -2
- package/dist/main-browser.js +3 -3
- package/dist/main-browser.js.map +1 -1
- package/dist/main.d.ts +3 -3
- package/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/matching/matcher-definitions.d.ts +15 -15
- package/dist/matching/matcher-definitions.js +22 -22
- package/dist/matching/matcher-definitions.js.map +1 -1
- package/dist/matching/matcher-impls.d.ts +27 -0
- package/dist/matching/{matchers.js → matcher-impls.js} +23 -23
- package/dist/matching/matcher-impls.js.map +1 -0
- package/dist/mockrtc-peer.d.ts +1 -0
- package/dist/mockrtc.d.ts +4 -3
- package/dist/rule-builder.d.ts +2 -1
- package/dist/rule-builder.js +7 -7
- package/dist/rule-builder.js.map +1 -1
- package/dist/server/mockrtc-admin-plugin.d.ts +1 -1
- package/dist/server/mockrtc-admin-plugin.js +12 -10
- package/dist/server/mockrtc-admin-plugin.js.map +1 -1
- package/dist/server/mockrtc-server-peer.d.ts +4 -2
- package/dist/server/mockrtc-server-peer.js +9 -10
- package/dist/server/mockrtc-server-peer.js.map +1 -1
- package/dist/server/mockrtc-server.js +6 -6
- package/dist/server/mockrtc-server.js.map +1 -1
- package/dist/webrtc/control-channel.d.ts +1 -1
- package/dist/webrtc/datachannel-stream.d.ts +6 -0
- package/dist/webrtc/datachannel-stream.js +4 -0
- package/dist/webrtc/datachannel-stream.js.map +1 -1
- package/dist/webrtc/mediatrack-stream.d.ts +7 -0
- package/dist/webrtc/mediatrack-stream.js +5 -0
- package/dist/webrtc/mediatrack-stream.js.map +1 -1
- package/dist/webrtc/mockrtc-connection.d.ts +1 -1
- package/dist/webrtc/mockrtc-connection.js +1 -0
- package/dist/webrtc/mockrtc-connection.js.map +1 -1
- package/dist/webrtc/rtc-connection.d.ts +4 -4
- package/dist/webrtc/rtc-connection.js +51 -36
- package/dist/webrtc/rtc-connection.js.map +1 -1
- package/package.json +10 -14
- package/src/handling/handler-builder.ts +24 -24
- package/src/handling/handler-step-definitions.ts +38 -22
- package/src/handling/{handler-steps.ts → handler-step-impls.ts} +36 -39
- package/src/main-browser.ts +2 -2
- package/src/main.ts +3 -3
- package/src/matching/matcher-definitions.ts +14 -14
- package/src/matching/{matchers.ts → matcher-impls.ts} +22 -22
- package/src/rule-builder.ts +14 -14
- package/src/server/mockrtc-admin-plugin.ts +15 -11
- package/src/server/mockrtc-server-peer.ts +12 -14
- package/src/server/mockrtc-server.ts +8 -8
- package/src/webrtc/datachannel-stream.ts +4 -0
- package/src/webrtc/mediatrack-stream.ts +5 -0
- package/src/webrtc/mockrtc-connection.ts +1 -0
- package/src/webrtc/rtc-connection.ts +9 -5
- package/test/tsconfig.json +2 -1
- package/tsconfig.json +3 -1
- package/dist/control-channel.d.ts +0 -8
- package/dist/control-channel.js +0 -11
- package/dist/control-channel.js.map +0 -1
- package/dist/handling/handler-steps.d.ts +0 -58
- package/dist/handling/handler-steps.js.map +0 -1
- package/dist/matching/matchers.d.ts +0 -27
- package/dist/matching/matchers.js.map +0 -1
- package/dist/mockrtc-admin-plugin.d.ts +0 -56
- package/dist/mockrtc-admin-plugin.js +0 -151
- package/dist/mockrtc-admin-plugin.js.map +0 -1
- package/dist/mockrtc-admin-server.d.ts +0 -7
- package/dist/mockrtc-admin-server.js +0 -18
- package/dist/mockrtc-admin-server.js.map +0 -1
- package/dist/mockrtc-client.d.ts +0 -12
- package/dist/mockrtc-client.js +0 -64
- package/dist/mockrtc-client.js.map +0 -1
- package/dist/mockrtc-handler-builder.d.ts +0 -15
- package/dist/mockrtc-handler-builder.js +0 -24
- package/dist/mockrtc-handler-builder.js.map +0 -1
- package/dist/mockrtc-remote-peer.d.ts +0 -15
- package/dist/mockrtc-remote-peer.js +0 -234
- package/dist/mockrtc-remote-peer.js.map +0 -1
- package/dist/mockrtc-server-peer.d.ts +0 -29
- package/dist/mockrtc-server-peer.js +0 -145
- package/dist/mockrtc-server-peer.js.map +0 -1
- package/dist/mockrtc-server.d.ts +0 -14
- package/dist/mockrtc-server.js +0 -53
- package/dist/mockrtc-server.js.map +0 -1
- package/dist/package.json +0 -52
- package/dist/src/main.d.ts +0 -1
- package/dist/src/main.js +0 -24
- package/dist/src/main.js.map +0 -1
- package/dist/src/mockrtc-peer.d.ts +0 -0
- package/dist/src/mockrtc-peer.js +0 -2
- package/dist/src/mockrtc-peer.js.map +0 -1
- package/dist/src/mockrtc.d.ts +0 -0
- package/dist/src/mockrtc.js +0 -65
- package/dist/src/mockrtc.js.map +0 -1
- package/dist/webrtc/peer-connection.d.ts +0 -16
- package/dist/webrtc/peer-connection.js +0 -81
- package/dist/webrtc/peer-connection.js.map +0 -1
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import * as PluggableAdmin from 'mockttp/dist/pluggable-admin-api/pluggable-admin.browser';
|
|
7
7
|
|
|
8
8
|
import { MockRTCSessionDescription } from '../mockrtc';
|
|
9
|
+
import type { RTCConnection } from '../webrtc/rtc-connection';
|
|
9
10
|
|
|
10
11
|
export type Serializable = PluggableAdmin.Serialization.Serializable;
|
|
11
12
|
export const { Serializable } = PluggableAdmin.Serialization;
|
|
@@ -15,9 +16,10 @@ export interface HandlerStepDefinition extends Serializable {
|
|
|
15
16
|
readonly type: keyof typeof StepDefinitionLookup;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
export class
|
|
19
|
+
export class WaitForDurationStep extends Serializable implements HandlerStepDefinition {
|
|
19
20
|
|
|
20
21
|
readonly type = 'wait-for-duration';
|
|
22
|
+
static readonly isFinal = false;
|
|
21
23
|
|
|
22
24
|
constructor(
|
|
23
25
|
public readonly durationMs: number
|
|
@@ -31,9 +33,10 @@ export class WaitForDurationStepDefinition extends Serializable implements Handl
|
|
|
31
33
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
export class
|
|
36
|
+
export class WaitForChannelStep extends Serializable implements HandlerStepDefinition {
|
|
35
37
|
|
|
36
38
|
readonly type = 'wait-for-rtc-data-channel';
|
|
39
|
+
static readonly isFinal = false;
|
|
37
40
|
|
|
38
41
|
constructor(
|
|
39
42
|
public readonly channelLabel?: string
|
|
@@ -47,9 +50,10 @@ export class WaitForChannelStepDefinition extends Serializable implements Handle
|
|
|
47
50
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
export class
|
|
53
|
+
export class WaitForMessageStep extends Serializable implements HandlerStepDefinition {
|
|
51
54
|
|
|
52
55
|
readonly type = 'wait-for-rtc-message';
|
|
56
|
+
static readonly isFinal = false;
|
|
53
57
|
|
|
54
58
|
constructor(
|
|
55
59
|
public readonly channelLabel?: string
|
|
@@ -63,9 +67,10 @@ export class WaitForMessageStepDefinition extends Serializable implements Handle
|
|
|
63
67
|
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
export class
|
|
70
|
+
export class WaitForTrackStep extends Serializable implements HandlerStepDefinition {
|
|
67
71
|
|
|
68
72
|
readonly type = 'wait-for-rtc-track';
|
|
73
|
+
static readonly isFinal = false;
|
|
69
74
|
|
|
70
75
|
explain() {
|
|
71
76
|
return `wait for an RTC track`;
|
|
@@ -73,9 +78,10 @@ export class WaitForTrackStepDefinition extends Serializable implements HandlerS
|
|
|
73
78
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
export class
|
|
81
|
+
export class WaitForMediaStep extends Serializable implements HandlerStepDefinition {
|
|
77
82
|
|
|
78
83
|
readonly type = 'wait-for-rtc-media';
|
|
84
|
+
static readonly isFinal = false;
|
|
79
85
|
|
|
80
86
|
explain() {
|
|
81
87
|
return `wait for RTC media data`;
|
|
@@ -83,9 +89,10 @@ export class WaitForMediaStepDefinition extends Serializable implements HandlerS
|
|
|
83
89
|
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
export class
|
|
92
|
+
export class CreateChannelStep extends Serializable implements HandlerStepDefinition {
|
|
87
93
|
|
|
88
94
|
readonly type = 'create-rtc-data-channel';
|
|
95
|
+
static readonly isFinal = false;
|
|
89
96
|
|
|
90
97
|
constructor(
|
|
91
98
|
public readonly channelLabel: string
|
|
@@ -99,9 +106,10 @@ export class CreateChannelStepDefinition extends Serializable implements Handler
|
|
|
99
106
|
|
|
100
107
|
}
|
|
101
108
|
|
|
102
|
-
export class
|
|
109
|
+
export class SendStep extends Serializable implements HandlerStepDefinition {
|
|
103
110
|
|
|
104
111
|
readonly type = 'send-rtc-data-message';
|
|
112
|
+
static readonly isFinal = false;
|
|
105
113
|
|
|
106
114
|
constructor(
|
|
107
115
|
public readonly channelLabel: string | undefined,
|
|
@@ -116,9 +124,10 @@ export class SendStepDefinition extends Serializable implements HandlerStepDefin
|
|
|
116
124
|
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
export class
|
|
127
|
+
export class CloseStep extends Serializable implements HandlerStepDefinition {
|
|
120
128
|
|
|
121
129
|
readonly type = 'close-rtc-connection';
|
|
130
|
+
static readonly isFinal = true;
|
|
122
131
|
|
|
123
132
|
explain() {
|
|
124
133
|
return `close the RTC connection`;
|
|
@@ -126,9 +135,10 @@ export class CloseStepDefinition extends Serializable implements HandlerStepDefi
|
|
|
126
135
|
|
|
127
136
|
}
|
|
128
137
|
|
|
129
|
-
export class
|
|
138
|
+
export class EchoStep extends Serializable implements HandlerStepDefinition {
|
|
130
139
|
|
|
131
140
|
readonly type = 'echo-rtc';
|
|
141
|
+
static readonly isFinal = true;
|
|
132
142
|
|
|
133
143
|
explain() {
|
|
134
144
|
return `echo all RTC media & data`;
|
|
@@ -136,9 +146,12 @@ export class EchoStepDefinition extends Serializable implements HandlerStepDefin
|
|
|
136
146
|
|
|
137
147
|
}
|
|
138
148
|
|
|
139
|
-
export class
|
|
149
|
+
export class PeerProxyStep extends Serializable implements HandlerStepDefinition {
|
|
140
150
|
|
|
141
151
|
readonly type = 'rtc-peer-proxy';
|
|
152
|
+
static readonly isFinal = true;
|
|
153
|
+
|
|
154
|
+
protected externalConnections: RTCConnection[] = []; // Set here so it can be used in impl subclass
|
|
142
155
|
|
|
143
156
|
protected getAnswer: (offer: MockRTCSessionDescription) => Promise<RTCSessionDescriptionInit>;
|
|
144
157
|
|
|
@@ -177,9 +190,12 @@ export class PeerProxyStepDefinition extends Serializable implements HandlerStep
|
|
|
177
190
|
|
|
178
191
|
}
|
|
179
192
|
|
|
180
|
-
export class
|
|
193
|
+
export class DynamicProxyStep extends Serializable implements HandlerStepDefinition {
|
|
181
194
|
|
|
182
195
|
readonly type = 'rtc-dynamic-proxy';
|
|
196
|
+
static readonly isFinal = true;
|
|
197
|
+
|
|
198
|
+
protected externalConnections: RTCConnection[] = []; // Set here so it can be used in impl subclass
|
|
183
199
|
|
|
184
200
|
explain() {
|
|
185
201
|
return `proxy the RTC connection to a remote peer`;
|
|
@@ -188,15 +204,15 @@ export class DynamicProxyStepDefinition extends Serializable implements HandlerS
|
|
|
188
204
|
}
|
|
189
205
|
|
|
190
206
|
export const StepDefinitionLookup = {
|
|
191
|
-
'wait-for-duration':
|
|
192
|
-
'wait-for-rtc-data-channel':
|
|
193
|
-
'wait-for-rtc-track':
|
|
194
|
-
'wait-for-rtc-media':
|
|
195
|
-
'wait-for-rtc-message':
|
|
196
|
-
'create-rtc-data-channel':
|
|
197
|
-
'send-rtc-data-message':
|
|
198
|
-
'close-rtc-connection':
|
|
199
|
-
'echo-rtc':
|
|
200
|
-
'rtc-peer-proxy':
|
|
201
|
-
'rtc-dynamic-proxy':
|
|
207
|
+
'wait-for-duration': WaitForDurationStep,
|
|
208
|
+
'wait-for-rtc-data-channel': WaitForChannelStep,
|
|
209
|
+
'wait-for-rtc-track': WaitForTrackStep,
|
|
210
|
+
'wait-for-rtc-media': WaitForMediaStep,
|
|
211
|
+
'wait-for-rtc-message': WaitForMessageStep,
|
|
212
|
+
'create-rtc-data-channel': CreateChannelStep,
|
|
213
|
+
'send-rtc-data-message': SendStep,
|
|
214
|
+
'close-rtc-connection': CloseStep,
|
|
215
|
+
'echo-rtc': EchoStep,
|
|
216
|
+
'rtc-peer-proxy': PeerProxyStep,
|
|
217
|
+
'rtc-dynamic-proxy': DynamicProxyStep
|
|
202
218
|
};
|
|
@@ -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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
CloseStep,
|
|
16
|
+
DynamicProxyStep,
|
|
17
|
+
EchoStep,
|
|
18
18
|
HandlerStepDefinition,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
31
|
+
export interface HandlerStepImpl extends HandlerStepDefinition {
|
|
32
32
|
handle(connection: MockRTCConnection): Promise<void>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export class
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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':
|
|
272
|
-
'wait-for-rtc-data-channel':
|
|
273
|
-
'wait-for-rtc-track':
|
|
274
|
-
'wait-for-rtc-media':
|
|
275
|
-
'wait-for-rtc-message':
|
|
276
|
-
'create-rtc-data-channel':
|
|
277
|
-
'send-rtc-data-message':
|
|
278
|
-
'close-rtc-connection':
|
|
279
|
-
'echo-rtc':
|
|
280
|
-
'rtc-peer-proxy':
|
|
281
|
-
'rtc-dynamic-proxy':
|
|
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
|
};
|
package/src/main-browser.ts
CHANGED
|
@@ -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
|
|
14
|
-
export * as
|
|
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
|
|
26
|
-
export * as
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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':
|
|
103
|
-
'has-rtc-video-track':
|
|
104
|
-
'has-rtc-audio-track':
|
|
105
|
-
'has-rtc-media-track':
|
|
106
|
-
'rtc-page-hostname':
|
|
107
|
-
'rtc-page-regex':
|
|
108
|
-
'rtc-user-agent-regex':
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
HasAudioTrackMatcher,
|
|
11
|
+
HasDataChannelMatcher,
|
|
12
|
+
HasMediaTrackMatcher,
|
|
13
|
+
HasVideoTrackMatcher,
|
|
14
|
+
HostnameMatcher,
|
|
15
|
+
UrlRegexMatcher,
|
|
16
|
+
UserAgentRegexMatcher
|
|
17
17
|
} from "./matcher-definitions";
|
|
18
18
|
|
|
19
|
-
export interface
|
|
19
|
+
export interface MatcherImpl extends MatcherDefinition {
|
|
20
20
|
matches(connection: RTCConnection): boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export class
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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':
|
|
112
|
-
'has-rtc-video-track':
|
|
113
|
-
'has-rtc-audio-track':
|
|
114
|
-
'has-rtc-media-track':
|
|
115
|
-
'rtc-page-hostname':
|
|
116
|
-
'rtc-page-regex':
|
|
117
|
-
'rtc-user-agent-regex':
|
|
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
|
};
|
package/src/rule-builder.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
112
|
+
this.matchers.push(new UserAgentRegexMatcher(userAgentRegEx));
|
|
113
113
|
return this;
|
|
114
114
|
}
|
|
115
115
|
|