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.
- package/.github/workflows/ci.yml +5 -3
- package/README.md +2 -10
- 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 +36 -22
- 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-step-impls.js +228 -0
- 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-definition-impls.d.ts +51 -0
- package/dist/matching/matcher-definition-impls.js +94 -0
- package/dist/matching/matcher-definition-impls.js.map +1 -0
- package/dist/matching/matcher-definition.d.ts +51 -0
- package/dist/matching/matcher-definition.js +94 -0
- package/dist/matching/matcher-definition.js.map +1 -0
- package/dist/matching/matcher-definitions.d.ts +14 -14
- 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/matcher-impls.js +87 -0
- package/dist/matching/matcher-impls.js.map +1 -0
- package/dist/matching/matchers.d.ts +9 -9
- package/dist/matching/matchers.js +23 -23
- package/dist/matching/matchers.js.map +1 -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 +7 -7
- package/dist/server/mockrtc-admin-plugin.js.map +1 -1
- package/dist/server/mockrtc-server-peer.d.ts +2 -2
- 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/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 +3 -3
- package/dist/webrtc/rtc-connection.js +3 -6
- package/dist/webrtc/rtc-connection.js.map +1 -1
- package/package.json +5 -6
- 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 +8 -8
- package/src/server/mockrtc-server-peer.ts +3 -3
- package/src/server/mockrtc-server.ts +8 -8
- package/src/webrtc/mockrtc-connection.ts +1 -0
- package/src/webrtc/rtc-connection.ts +9 -20
package/.github/workflows/ci.yml
CHANGED
|
@@ -7,7 +7,7 @@ jobs:
|
|
|
7
7
|
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
|
-
node-version: [
|
|
10
|
+
node-version: [20.x, v22.14.0, 22.x, 24.x]
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
13
|
- uses: actions/checkout@v3
|
|
@@ -22,11 +22,13 @@ jobs:
|
|
|
22
22
|
- run: npm install
|
|
23
23
|
- run: npm run build
|
|
24
24
|
- run: npm test
|
|
25
|
+
env:
|
|
26
|
+
NODE_OPTIONS: ${{ matrix.node-version == '22.x' && '--experimental-require-module' || '' }}
|
|
25
27
|
|
|
26
28
|
- name: Deploy docs
|
|
27
|
-
if: github.ref == 'refs/heads/main' && matrix.node-version == 'v20.
|
|
29
|
+
if: github.ref == 'refs/heads/main' && matrix.node-version == 'v20.18.1'
|
|
28
30
|
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
|
29
31
|
with:
|
|
30
32
|
single-commit: true
|
|
31
33
|
branch: gh-pages
|
|
32
|
-
folder: typedoc
|
|
34
|
+
folder: typedoc
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# MockRTC [](https://github.com/httptoolkit/mockrtc/actions) [](https://npmjs.com/package/mockrtc)
|
|
2
2
|
|
|
3
|
-
> _Part of [HTTP Toolkit](https://httptoolkit.
|
|
3
|
+
> _Part of [HTTP Toolkit](https://httptoolkit.com): powerful tools for building, testing & debugging HTTP(S), WebSockets and WebRTC_
|
|
4
4
|
|
|
5
5
|
MockRTC lets you intercept, assert on and mock WebRTC peers. This makes it possible to:
|
|
6
6
|
|
|
@@ -9,14 +9,6 @@ MockRTC lets you intercept, assert on and mock WebRTC peers. This makes it possi
|
|
|
9
9
|
* Capture and inspect traffic between real WebRTC peers for debugging.
|
|
10
10
|
* Create WebRTC proxy peers to automate message transformation, monitoring or logging.
|
|
11
11
|
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
:warning: _MockRTC is still new & rapidly developing!_ :warning:
|
|
15
|
-
|
|
16
|
-
_Everything described here works today, but there's lots more to come, and some advanced WebRTC use cases may run into rough edges. If you hit any problems or missing features, please [open an issue](https://github.com/httptoolkit/mockrtc/issues/new)._
|
|
17
|
-
|
|
18
|
-
---
|
|
19
|
-
|
|
20
12
|
## Example
|
|
21
13
|
|
|
22
14
|
Let's write an automated test with MockRTC. To test WebRTC-based code, you will typically need to:
|
|
@@ -22,7 +22,7 @@ class MockRTCHandlerBuilder {
|
|
|
22
22
|
* @category Steps
|
|
23
23
|
*/
|
|
24
24
|
sleep(duration) {
|
|
25
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
25
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForDurationStep(duration));
|
|
26
26
|
return this;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -31,7 +31,7 @@ class MockRTCHandlerBuilder {
|
|
|
31
31
|
* @category Steps
|
|
32
32
|
*/
|
|
33
33
|
waitForChannel(channelLabel) {
|
|
34
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
34
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForChannelStep(channelLabel));
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -40,7 +40,7 @@ class MockRTCHandlerBuilder {
|
|
|
40
40
|
* @category Steps
|
|
41
41
|
*/
|
|
42
42
|
waitForTrack() {
|
|
43
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
43
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForTrackStep());
|
|
44
44
|
return this;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -52,7 +52,7 @@ class MockRTCHandlerBuilder {
|
|
|
52
52
|
* @category Steps
|
|
53
53
|
*/
|
|
54
54
|
waitForNextMessage() {
|
|
55
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
55
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForMessageStep());
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -63,7 +63,7 @@ class MockRTCHandlerBuilder {
|
|
|
63
63
|
* @category Steps
|
|
64
64
|
*/
|
|
65
65
|
waitForNextMedia() {
|
|
66
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
66
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForMediaStep());
|
|
67
67
|
return this;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
@@ -75,7 +75,7 @@ class MockRTCHandlerBuilder {
|
|
|
75
75
|
* @category Steps
|
|
76
76
|
*/
|
|
77
77
|
waitForNextMessageOnChannel(channelLabel) {
|
|
78
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
78
|
+
this.handlerSteps.push(new handler_step_definitions_1.WaitForMessageStep(channelLabel));
|
|
79
79
|
return this;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -85,17 +85,17 @@ class MockRTCHandlerBuilder {
|
|
|
85
85
|
* @category Steps
|
|
86
86
|
*/
|
|
87
87
|
createDataChannel(channelLabel) {
|
|
88
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
88
|
+
this.handlerSteps.push(new handler_step_definitions_1.CreateChannelStep(channelLabel));
|
|
89
89
|
return this;
|
|
90
90
|
}
|
|
91
91
|
send(...args) {
|
|
92
92
|
if (args[1] !== undefined) {
|
|
93
93
|
const [channel, message] = args;
|
|
94
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
94
|
+
this.handlerSteps.push(new handler_step_definitions_1.SendStep(channel, message));
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
const [message] = args;
|
|
98
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
98
|
+
this.handlerSteps.push(new handler_step_definitions_1.SendStep(undefined, message));
|
|
99
99
|
}
|
|
100
100
|
return this;
|
|
101
101
|
}
|
|
@@ -109,7 +109,7 @@ class MockRTCHandlerBuilder {
|
|
|
109
109
|
* @category Final Steps
|
|
110
110
|
*/
|
|
111
111
|
thenClose() {
|
|
112
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
112
|
+
this.handlerSteps.push(new handler_step_definitions_1.CloseStep());
|
|
113
113
|
return this.buildCallback(this.handlerSteps);
|
|
114
114
|
}
|
|
115
115
|
thenSend(...args) {
|
|
@@ -127,7 +127,7 @@ class MockRTCHandlerBuilder {
|
|
|
127
127
|
* @category Final Steps
|
|
128
128
|
*/
|
|
129
129
|
thenEcho() {
|
|
130
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
130
|
+
this.handlerSteps.push(new handler_step_definitions_1.EchoStep());
|
|
131
131
|
return this.buildCallback(this.handlerSteps);
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
@@ -142,7 +142,7 @@ class MockRTCHandlerBuilder {
|
|
|
142
142
|
* @category Final Steps
|
|
143
143
|
*/
|
|
144
144
|
thenForwardTo(peer) {
|
|
145
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
145
|
+
this.handlerSteps.push(new handler_step_definitions_1.PeerProxyStep(peer));
|
|
146
146
|
return this.buildCallback(this.handlerSteps);
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
@@ -166,7 +166,7 @@ class MockRTCHandlerBuilder {
|
|
|
166
166
|
* @category Final Steps
|
|
167
167
|
*/
|
|
168
168
|
thenPassThrough() {
|
|
169
|
-
this.handlerSteps.push(new handler_step_definitions_1.
|
|
169
|
+
this.handlerSteps.push(new handler_step_definitions_1.DynamicProxyStep());
|
|
170
170
|
return this.buildCallback(this.handlerSteps);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-builder.js","sourceRoot":"","sources":["../../src/handling/handler-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAaoC;AAEpC;;;;GAIG;AACH,MAAa,qBAAqB;IAI9B,YACY,aAAoE;QAApE,kBAAa,GAAb,aAAa,CAAuD;QAHxE,iBAAY,GAA4B,EAAE,CAAC;IAIhD,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,QAAgB;QAClB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"handler-builder.js","sourceRoot":"","sources":["../../src/handling/handler-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAaoC;AAEpC;;;;GAIG;AACH,MAAa,qBAAqB;IAI9B,YACY,aAAoE;QAApE,kBAAa,GAAb,aAAa,CAAuD;QAHxE,iBAAY,GAA4B,EAAE,CAAC;IAIhD,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,QAAgB;QAClB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,8CAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,YAAqB;QAChC,IAAI,CAAC,YAAY,CAAC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E,OAAO,CAAC,CAAC,CAAC;SAC5D;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS;QACL,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,oCAAS,EAAE,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAeD,QAAQ,CAAC,GAAG,IAAmD;QAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,IAA6C,CAAC;aAC7D,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ;QACJ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,mCAAQ,EAAE,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;OAUG;IACH,aAAa,CAAC,IAAuB;QACjC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,wCAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe;QACX,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,2CAAgB,EAAE,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;CAEJ;AAzMD,sDAyMC"}
|
|
@@ -1,81 +1,95 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as PluggableAdmin from 'mockttp/dist/pluggable-admin-api/pluggable-admin.browser';
|
|
3
3
|
import { MockRTCSessionDescription } from '../mockrtc';
|
|
4
|
+
import type { RTCConnection } from '../webrtc/rtc-connection';
|
|
4
5
|
export declare type Serializable = PluggableAdmin.Serialization.Serializable;
|
|
5
6
|
export declare const Serializable: typeof PluggableAdmin.Serialization.Serializable;
|
|
6
7
|
declare type ClientServerChannel = PluggableAdmin.Serialization.ClientServerChannel;
|
|
7
8
|
export interface HandlerStepDefinition extends Serializable {
|
|
8
9
|
readonly type: keyof typeof StepDefinitionLookup;
|
|
9
10
|
}
|
|
10
|
-
export declare class
|
|
11
|
+
export declare class WaitForDurationStep extends Serializable implements HandlerStepDefinition {
|
|
11
12
|
readonly durationMs: number;
|
|
12
13
|
readonly type = "wait-for-duration";
|
|
14
|
+
static readonly isFinal = false;
|
|
13
15
|
constructor(durationMs: number);
|
|
14
16
|
explain(): string;
|
|
15
17
|
}
|
|
16
|
-
export declare class
|
|
18
|
+
export declare class WaitForChannelStep extends Serializable implements HandlerStepDefinition {
|
|
17
19
|
readonly channelLabel?: string | undefined;
|
|
18
20
|
readonly type = "wait-for-rtc-data-channel";
|
|
21
|
+
static readonly isFinal = false;
|
|
19
22
|
constructor(channelLabel?: string | undefined);
|
|
20
23
|
explain(): string;
|
|
21
24
|
}
|
|
22
|
-
export declare class
|
|
25
|
+
export declare class WaitForMessageStep extends Serializable implements HandlerStepDefinition {
|
|
23
26
|
readonly channelLabel?: string | undefined;
|
|
24
27
|
readonly type = "wait-for-rtc-message";
|
|
28
|
+
static readonly isFinal = false;
|
|
25
29
|
constructor(channelLabel?: string | undefined);
|
|
26
30
|
explain(): string;
|
|
27
31
|
}
|
|
28
|
-
export declare class
|
|
32
|
+
export declare class WaitForTrackStep extends Serializable implements HandlerStepDefinition {
|
|
29
33
|
readonly type = "wait-for-rtc-track";
|
|
34
|
+
static readonly isFinal = false;
|
|
30
35
|
explain(): string;
|
|
31
36
|
}
|
|
32
|
-
export declare class
|
|
37
|
+
export declare class WaitForMediaStep extends Serializable implements HandlerStepDefinition {
|
|
33
38
|
readonly type = "wait-for-rtc-media";
|
|
39
|
+
static readonly isFinal = false;
|
|
34
40
|
explain(): string;
|
|
35
41
|
}
|
|
36
|
-
export declare class
|
|
42
|
+
export declare class CreateChannelStep extends Serializable implements HandlerStepDefinition {
|
|
37
43
|
readonly channelLabel: string;
|
|
38
44
|
readonly type = "create-rtc-data-channel";
|
|
45
|
+
static readonly isFinal = false;
|
|
39
46
|
constructor(channelLabel: string);
|
|
40
47
|
explain(): string;
|
|
41
48
|
}
|
|
42
|
-
export declare class
|
|
49
|
+
export declare class SendStep extends Serializable implements HandlerStepDefinition {
|
|
43
50
|
readonly channelLabel: string | undefined;
|
|
44
51
|
readonly message: string | Buffer;
|
|
45
52
|
readonly type = "send-rtc-data-message";
|
|
53
|
+
static readonly isFinal = false;
|
|
46
54
|
constructor(channelLabel: string | undefined, message: string | Buffer);
|
|
47
55
|
explain(): string;
|
|
48
56
|
}
|
|
49
|
-
export declare class
|
|
57
|
+
export declare class CloseStep extends Serializable implements HandlerStepDefinition {
|
|
50
58
|
readonly type = "close-rtc-connection";
|
|
59
|
+
static readonly isFinal = true;
|
|
51
60
|
explain(): string;
|
|
52
61
|
}
|
|
53
|
-
export declare class
|
|
62
|
+
export declare class EchoStep extends Serializable implements HandlerStepDefinition {
|
|
54
63
|
readonly type = "echo-rtc";
|
|
64
|
+
static readonly isFinal = true;
|
|
55
65
|
explain(): string;
|
|
56
66
|
}
|
|
57
|
-
export declare class
|
|
67
|
+
export declare class PeerProxyStep extends Serializable implements HandlerStepDefinition {
|
|
58
68
|
readonly type = "rtc-peer-proxy";
|
|
69
|
+
static readonly isFinal = true;
|
|
70
|
+
protected externalConnections: RTCConnection[];
|
|
59
71
|
protected getAnswer: (offer: MockRTCSessionDescription) => Promise<RTCSessionDescriptionInit>;
|
|
60
72
|
constructor(connectionTarget: RTCPeerConnection | ((offer: MockRTCSessionDescription) => Promise<RTCSessionDescriptionInit>));
|
|
61
73
|
explain(): string;
|
|
62
74
|
serialize(channel: ClientServerChannel): {};
|
|
63
75
|
}
|
|
64
|
-
export declare class
|
|
76
|
+
export declare class DynamicProxyStep extends Serializable implements HandlerStepDefinition {
|
|
65
77
|
readonly type = "rtc-dynamic-proxy";
|
|
78
|
+
static readonly isFinal = true;
|
|
79
|
+
protected externalConnections: RTCConnection[];
|
|
66
80
|
explain(): string;
|
|
67
81
|
}
|
|
68
82
|
export declare const StepDefinitionLookup: {
|
|
69
|
-
'wait-for-duration': typeof
|
|
70
|
-
'wait-for-rtc-data-channel': typeof
|
|
71
|
-
'wait-for-rtc-track': typeof
|
|
72
|
-
'wait-for-rtc-media': typeof
|
|
73
|
-
'wait-for-rtc-message': typeof
|
|
74
|
-
'create-rtc-data-channel': typeof
|
|
75
|
-
'send-rtc-data-message': typeof
|
|
76
|
-
'close-rtc-connection': typeof
|
|
77
|
-
'echo-rtc': typeof
|
|
78
|
-
'rtc-peer-proxy': typeof
|
|
79
|
-
'rtc-dynamic-proxy': typeof
|
|
83
|
+
'wait-for-duration': typeof WaitForDurationStep;
|
|
84
|
+
'wait-for-rtc-data-channel': typeof WaitForChannelStep;
|
|
85
|
+
'wait-for-rtc-track': typeof WaitForTrackStep;
|
|
86
|
+
'wait-for-rtc-media': typeof WaitForMediaStep;
|
|
87
|
+
'wait-for-rtc-message': typeof WaitForMessageStep;
|
|
88
|
+
'create-rtc-data-channel': typeof CreateChannelStep;
|
|
89
|
+
'send-rtc-data-message': typeof SendStep;
|
|
90
|
+
'close-rtc-connection': typeof CloseStep;
|
|
91
|
+
'echo-rtc': typeof EchoStep;
|
|
92
|
+
'rtc-peer-proxy': typeof PeerProxyStep;
|
|
93
|
+
'rtc-dynamic-proxy': typeof DynamicProxyStep;
|
|
80
94
|
};
|
|
81
95
|
export {};
|
|
@@ -13,10 +13,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.StepDefinitionLookup = exports.
|
|
16
|
+
exports.StepDefinitionLookup = exports.DynamicProxyStep = exports.PeerProxyStep = exports.EchoStep = exports.CloseStep = exports.SendStep = exports.CreateChannelStep = exports.WaitForMediaStep = exports.WaitForTrackStep = exports.WaitForMessageStep = exports.WaitForChannelStep = exports.WaitForDurationStep = exports.Serializable = void 0;
|
|
17
17
|
const PluggableAdmin = require("mockttp/dist/pluggable-admin-api/pluggable-admin.browser");
|
|
18
18
|
exports.Serializable = PluggableAdmin.Serialization.Serializable;
|
|
19
|
-
class
|
|
19
|
+
class WaitForDurationStep extends exports.Serializable {
|
|
20
20
|
constructor(durationMs) {
|
|
21
21
|
super();
|
|
22
22
|
this.durationMs = durationMs;
|
|
@@ -26,8 +26,9 @@ class WaitForDurationStepDefinition extends exports.Serializable {
|
|
|
26
26
|
return `wait for ${this.durationMs}ms`;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.
|
|
30
|
-
|
|
29
|
+
exports.WaitForDurationStep = WaitForDurationStep;
|
|
30
|
+
WaitForDurationStep.isFinal = false;
|
|
31
|
+
class WaitForChannelStep extends exports.Serializable {
|
|
31
32
|
constructor(channelLabel) {
|
|
32
33
|
super();
|
|
33
34
|
this.channelLabel = channelLabel;
|
|
@@ -37,8 +38,9 @@ class WaitForChannelStepDefinition extends exports.Serializable {
|
|
|
37
38
|
return `wait for an RTC channel${this.channelLabel ? ` labelled '${this.channelLabel}'` : ''}`;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
exports.
|
|
41
|
-
|
|
41
|
+
exports.WaitForChannelStep = WaitForChannelStep;
|
|
42
|
+
WaitForChannelStep.isFinal = false;
|
|
43
|
+
class WaitForMessageStep extends exports.Serializable {
|
|
42
44
|
constructor(channelLabel) {
|
|
43
45
|
super();
|
|
44
46
|
this.channelLabel = channelLabel;
|
|
@@ -48,8 +50,9 @@ class WaitForMessageStepDefinition extends exports.Serializable {
|
|
|
48
50
|
return `wait for an RTC message${this.channelLabel ? ` on channel '${this.channelLabel}'` : ''}`;
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
exports.
|
|
52
|
-
|
|
53
|
+
exports.WaitForMessageStep = WaitForMessageStep;
|
|
54
|
+
WaitForMessageStep.isFinal = false;
|
|
55
|
+
class WaitForTrackStep extends exports.Serializable {
|
|
53
56
|
constructor() {
|
|
54
57
|
super(...arguments);
|
|
55
58
|
this.type = 'wait-for-rtc-track';
|
|
@@ -58,8 +61,9 @@ class WaitForTrackStepDefinition extends exports.Serializable {
|
|
|
58
61
|
return `wait for an RTC track`;
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
exports.
|
|
62
|
-
|
|
64
|
+
exports.WaitForTrackStep = WaitForTrackStep;
|
|
65
|
+
WaitForTrackStep.isFinal = false;
|
|
66
|
+
class WaitForMediaStep extends exports.Serializable {
|
|
63
67
|
constructor() {
|
|
64
68
|
super(...arguments);
|
|
65
69
|
this.type = 'wait-for-rtc-media';
|
|
@@ -68,8 +72,9 @@ class WaitForMediaStepDefinition extends exports.Serializable {
|
|
|
68
72
|
return `wait for RTC media data`;
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
|
-
exports.
|
|
72
|
-
|
|
75
|
+
exports.WaitForMediaStep = WaitForMediaStep;
|
|
76
|
+
WaitForMediaStep.isFinal = false;
|
|
77
|
+
class CreateChannelStep extends exports.Serializable {
|
|
73
78
|
constructor(channelLabel) {
|
|
74
79
|
super();
|
|
75
80
|
this.channelLabel = channelLabel;
|
|
@@ -79,8 +84,9 @@ class CreateChannelStepDefinition extends exports.Serializable {
|
|
|
79
84
|
return `create an RTC data channel labelled '${this.channelLabel}'`;
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
|
-
exports.
|
|
83
|
-
|
|
87
|
+
exports.CreateChannelStep = CreateChannelStep;
|
|
88
|
+
CreateChannelStep.isFinal = false;
|
|
89
|
+
class SendStep extends exports.Serializable {
|
|
84
90
|
constructor(channelLabel, message) {
|
|
85
91
|
super();
|
|
86
92
|
this.channelLabel = channelLabel;
|
|
@@ -91,8 +97,9 @@ class SendStepDefinition extends exports.Serializable {
|
|
|
91
97
|
return `send an RTC data message${this.channelLabel ? ` on channel '${this.channelLabel}'` : ''}`;
|
|
92
98
|
}
|
|
93
99
|
}
|
|
94
|
-
exports.
|
|
95
|
-
|
|
100
|
+
exports.SendStep = SendStep;
|
|
101
|
+
SendStep.isFinal = false;
|
|
102
|
+
class CloseStep extends exports.Serializable {
|
|
96
103
|
constructor() {
|
|
97
104
|
super(...arguments);
|
|
98
105
|
this.type = 'close-rtc-connection';
|
|
@@ -101,8 +108,9 @@ class CloseStepDefinition extends exports.Serializable {
|
|
|
101
108
|
return `close the RTC connection`;
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
|
-
exports.
|
|
105
|
-
|
|
111
|
+
exports.CloseStep = CloseStep;
|
|
112
|
+
CloseStep.isFinal = true;
|
|
113
|
+
class EchoStep extends exports.Serializable {
|
|
106
114
|
constructor() {
|
|
107
115
|
super(...arguments);
|
|
108
116
|
this.type = 'echo-rtc';
|
|
@@ -111,11 +119,13 @@ class EchoStepDefinition extends exports.Serializable {
|
|
|
111
119
|
return `echo all RTC media & data`;
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
|
-
exports.
|
|
115
|
-
|
|
122
|
+
exports.EchoStep = EchoStep;
|
|
123
|
+
EchoStep.isFinal = true;
|
|
124
|
+
class PeerProxyStep extends exports.Serializable {
|
|
116
125
|
constructor(connectionTarget) {
|
|
117
126
|
super();
|
|
118
127
|
this.type = 'rtc-peer-proxy';
|
|
128
|
+
this.externalConnections = []; // Set here so it can be used in impl subclass
|
|
119
129
|
if (connectionTarget instanceof Function) {
|
|
120
130
|
this.getAnswer = connectionTarget;
|
|
121
131
|
}
|
|
@@ -138,28 +148,31 @@ class PeerProxyStepDefinition extends exports.Serializable {
|
|
|
138
148
|
return { type: this.type };
|
|
139
149
|
}
|
|
140
150
|
}
|
|
141
|
-
exports.
|
|
142
|
-
|
|
151
|
+
exports.PeerProxyStep = PeerProxyStep;
|
|
152
|
+
PeerProxyStep.isFinal = true;
|
|
153
|
+
class DynamicProxyStep extends exports.Serializable {
|
|
143
154
|
constructor() {
|
|
144
155
|
super(...arguments);
|
|
145
156
|
this.type = 'rtc-dynamic-proxy';
|
|
157
|
+
this.externalConnections = []; // Set here so it can be used in impl subclass
|
|
146
158
|
}
|
|
147
159
|
explain() {
|
|
148
160
|
return `proxy the RTC connection to a remote peer`;
|
|
149
161
|
}
|
|
150
162
|
}
|
|
151
|
-
exports.
|
|
163
|
+
exports.DynamicProxyStep = DynamicProxyStep;
|
|
164
|
+
DynamicProxyStep.isFinal = true;
|
|
152
165
|
exports.StepDefinitionLookup = {
|
|
153
|
-
'wait-for-duration':
|
|
154
|
-
'wait-for-rtc-data-channel':
|
|
155
|
-
'wait-for-rtc-track':
|
|
156
|
-
'wait-for-rtc-media':
|
|
157
|
-
'wait-for-rtc-message':
|
|
158
|
-
'create-rtc-data-channel':
|
|
159
|
-
'send-rtc-data-message':
|
|
160
|
-
'close-rtc-connection':
|
|
161
|
-
'echo-rtc':
|
|
162
|
-
'rtc-peer-proxy':
|
|
163
|
-
'rtc-dynamic-proxy':
|
|
166
|
+
'wait-for-duration': WaitForDurationStep,
|
|
167
|
+
'wait-for-rtc-data-channel': WaitForChannelStep,
|
|
168
|
+
'wait-for-rtc-track': WaitForTrackStep,
|
|
169
|
+
'wait-for-rtc-media': WaitForMediaStep,
|
|
170
|
+
'wait-for-rtc-message': WaitForMessageStep,
|
|
171
|
+
'create-rtc-data-channel': CreateChannelStep,
|
|
172
|
+
'send-rtc-data-message': SendStep,
|
|
173
|
+
'close-rtc-connection': CloseStep,
|
|
174
|
+
'echo-rtc': EchoStep,
|
|
175
|
+
'rtc-peer-proxy': PeerProxyStep,
|
|
176
|
+
'rtc-dynamic-proxy': DynamicProxyStep
|
|
164
177
|
};
|
|
165
178
|
//# sourceMappingURL=handler-step-definitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-step-definitions.js","sourceRoot":"","sources":["../../src/handling/handler-step-definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,2FAA2F;
|
|
1
|
+
{"version":3,"file":"handler-step-definitions.js","sourceRoot":"","sources":["../../src/handling/handler-step-definitions.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,2FAA2F;AAM5E,oBAAY,GAAK,cAAc,CAAC,aAAa,cAAC;AAO7D,MAAa,mBAAoB,SAAQ,oBAAY;IAKjD,YACoB,UAAkB;QAElC,KAAK,EAAE,CAAC;QAFQ,eAAU,GAAV,UAAU,CAAQ;QAJ7B,SAAI,GAAG,mBAAmB,CAAC;IAOpC,CAAC;IAED,OAAO;QACH,OAAO,YAAY,IAAI,CAAC,UAAU,IAAI,CAAC;IAC3C,CAAC;;AAbL,kDAeC;AAZmB,2BAAO,GAAG,KAAK,CAAC;AAcpC,MAAa,kBAAmB,SAAQ,oBAAY;IAKhD,YACoB,YAAqB;QAErC,KAAK,EAAE,CAAC;QAFQ,iBAAY,GAAZ,YAAY,CAAS;QAJhC,SAAI,GAAG,2BAA2B,CAAC;IAO5C,CAAC;IAED,OAAO;QACH,OAAO,0BAA0B,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACnG,CAAC;;AAbL,gDAeC;AAZmB,0BAAO,GAAG,KAAK,CAAC;AAcpC,MAAa,kBAAmB,SAAQ,oBAAY;IAKhD,YACoB,YAAqB;QAErC,KAAK,EAAE,CAAC;QAFQ,iBAAY,GAAZ,YAAY,CAAS;QAJhC,SAAI,GAAG,sBAAsB,CAAC;IAOvC,CAAC;IAED,OAAO;QACH,OAAO,0BAA0B,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAgB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACrG,CAAC;;AAbL,gDAeC;AAZmB,0BAAO,GAAG,KAAK,CAAC;AAcpC,M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A8C;IAMvG,CAAC;IAJG,OAAO;QACH,OAAO,2CAA2C,CAAC;IACvD,CAAC;;AATL,4CAWC;AARmB,wBAAO,GAAG,IAAI,CAAC;AAUtB,QAAA,oBAAoB,GAAG;IAChC,mBAAmB,EAAE,mBAAmB;IACxC,2BAA2B,EAAE,kBAAkB;IAC/C,oBAAoB,EAAE,gBAAgB;IACtC,oBAAoB,EAAE,gBAAgB;IACtC,sBAAsB,EAAE,kBAAkB;IAC1C,yBAAyB,EAAE,iBAAiB;IAC5C,uBAAuB,EAAE,QAAQ;IACjC,sBAAsB,EAAE,SAAS;IACjC,UAAU,EAAE,QAAQ;IACpB,gBAAgB,EAAE,aAAa;IAC/B,mBAAmB,EAAE,gBAAgB;CACxC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PluggableAdmin } from 'mockttp';
|
|
2
|
+
import type { MockRTCConnection } from '../webrtc/mockrtc-connection';
|
|
3
|
+
import { StepDefinitionLookup, CloseStep, DynamicProxyStep, EchoStep, HandlerStepDefinition, PeerProxyStep, CreateChannelStep, SendStep, WaitForChannelStep, WaitForDurationStep, WaitForMediaStep, WaitForMessageStep, WaitForTrackStep } from './handler-step-definitions';
|
|
4
|
+
declare type ClientServerChannel = PluggableAdmin.Serialization.ClientServerChannel;
|
|
5
|
+
export interface HandlerStepImpl extends HandlerStepDefinition {
|
|
6
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class WaitForDurationStepImpl extends WaitForDurationStep {
|
|
9
|
+
handle(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class WaitForChannelStepImpl extends WaitForChannelStep {
|
|
12
|
+
private matchesChannel;
|
|
13
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare class WaitForMessageStepImpl extends WaitForMessageStep {
|
|
16
|
+
private matchesChannel;
|
|
17
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class WaitForTrackStepImpl extends WaitForTrackStep {
|
|
20
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare class WaitForMediaStepImpl extends WaitForMediaStep {
|
|
23
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export declare class CreateChannelStepImpl extends CreateChannelStep {
|
|
26
|
+
handle(conn: MockRTCConnection): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare class SendStepImpl extends SendStep {
|
|
29
|
+
private matchesChannel;
|
|
30
|
+
handle({ channels }: MockRTCConnection): Promise<void>;
|
|
31
|
+
static deserialize(data: {
|
|
32
|
+
channelLabel: string | undefined;
|
|
33
|
+
message: string | {
|
|
34
|
+
type: 'Buffer';
|
|
35
|
+
data: number[];
|
|
36
|
+
};
|
|
37
|
+
}): SendStep;
|
|
38
|
+
}
|
|
39
|
+
export declare class CloseStepImpl extends CloseStep {
|
|
40
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export declare class EchoStepImpl extends EchoStep {
|
|
43
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export declare class PeerProxyStepImpl extends PeerProxyStep {
|
|
46
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
47
|
+
serialize(channel: ClientServerChannel): {};
|
|
48
|
+
static deserialize(_data: {}, channel: ClientServerChannel): PeerProxyStep;
|
|
49
|
+
dispose(): void;
|
|
50
|
+
}
|
|
51
|
+
export declare class DynamicProxyStepImpl extends DynamicProxyStep {
|
|
52
|
+
handle(connection: MockRTCConnection): Promise<void>;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
}
|
|
55
|
+
export declare const StepLookup: typeof StepDefinitionLookup;
|
|
56
|
+
export {};
|