Skip to content

Commit 3eae898

Browse files
committed
Update to Mockttp v4 for SOCKS, non-HTTP, delays & URL transforms
Lots of exciting things here! None of it directly exposed yet - this PR just updates and does the minimum required to match breaking changes & renames etc. Note that this bumps the minimum desktop & server versions, to versions which don't need the polyfill (though we include it anyway to give a little slack there). Should affect <0.3% of users.
1 parent be49fc8 commit 3eae898

39 files changed

+2326
-1698
lines changed

package-lock.json

Lines changed: 1192 additions & 623 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"author": "Tim Perry <[email protected]>",
3030
"license": "AGPL-3.0-or-later",
3131
"runtimeDependencies": {
32-
"httptoolkit-server": ">=1.0.0",
33-
"httptoolkit-desktop": ">=1.1.0"
32+
"httptoolkit-server": ">=1.9.0",
33+
"httptoolkit-desktop": ">=1.7.0"
3434
},
3535
"dependencies": {
3636
"@ethersproject/abi": "^5.7.0",
@@ -106,8 +106,8 @@
106106
"mobx-react-lite": "^2.2.2",
107107
"mobx-shallow-undo": "^1.0.0",
108108
"mobx-utils": "^5.1.0",
109-
"mockrtc": "^0.4.0",
110-
"mockttp": "^3.17.1",
109+
"mockrtc": "^0.5.0",
110+
"mockttp": "^4.0.0",
111111
"monaco-editor": "^0.27.0",
112112
"node-forge": "^1.3.0",
113113
"openapi-directory": "^1.3.0",

src/components/intercept/config/android-device-config.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { EventsStore } from '../../../model/events/events-store';
1818

1919
import {
2020
MethodMatchers,
21-
StaticResponseHandler
21+
StaticResponseStep
2222
} from '../../../model/rules/definitions/http-rule-definitions';
2323
import { RulesStore } from '../../../model/rules/rules-store';
2424
import { RulePriority } from '../../../model/rules/rules';
@@ -89,16 +89,16 @@ export function setUpAndroidCertificateRule(
8989
priority: RulePriority.OVERRIDE,
9090
matchers: [
9191
new MethodMatchers.GET(),
92-
new matchers.SimplePathMatcher(
92+
new matchers.FlexiblePathMatcher(
9393
"http://android.httptoolkit.tech/config"
9494
)
9595
],
9696
completionChecker: new completionCheckers.Always(),
97-
handler: new StaticResponseHandler(200, undefined, JSON.stringify({
97+
steps: [new StaticResponseStep(200, undefined, JSON.stringify({
9898
certificate: certContent
9999
}), {
100100
'content-type': 'application/json'
101-
})
101+
})]
102102
});
103103

104104
// When the next Android config request comes in:

src/components/modify/handler-selection.tsx

Lines changed: 0 additions & 220 deletions
This file was deleted.

src/components/modify/matcher-config.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ import {
4545
IpfsArgDescription
4646
} from '../../model/rules/definitions/ipfs-rule-definitions';
4747
import {
48-
HasDataChannelMatcherDefinition,
49-
HasVideoTrackMatcherDefinition,
50-
HasAudioTrackMatcherDefinition,
51-
HasMediaTrackMatcherDefinition
48+
HasDataChannelMatcher,
49+
HasVideoTrackMatcher,
50+
HasAudioTrackMatcher,
51+
HasMediaTrackMatcher
5252
} from '../../model/rules/definitions/rtc-rule-definitions';
5353

5454
import { Select, TextInput } from '../common/inputs';
@@ -154,7 +154,7 @@ export function AdditionalMatcherConfiguration(props:
154154
case 'host':
155155
return <HostMatcherConfig {...configProps} />;
156156
case 'simple-path':
157-
return <SimplePathMatcherConfig {...configProps} />;
157+
return <FlexiblePathMatcherConfig {...configProps} />;
158158
case 'regex-path':
159159
return <RegexPathMatcherConfig {...configProps} />;
160160
case 'query':
@@ -447,7 +447,7 @@ class HostMatcherConfig extends MatcherConfig<matchers.HostMatcher> {
447447
}
448448

449449
@observer
450-
class SimplePathMatcherConfig extends MatcherConfig<matchers.SimplePathMatcher> {
450+
class FlexiblePathMatcherConfig extends MatcherConfig<matchers.FlexiblePathMatcher> {
451451

452452
private fieldId = _.uniqueId();
453453

@@ -511,7 +511,7 @@ class SimplePathMatcherConfig extends MatcherConfig<matchers.SimplePathMatcher>
511511
new URL(this.url);
512512
}
513513

514-
// We leave the rest of the parsing to the SimplePathMatcher itself
514+
// We leave the rest of the parsing to the FlexiblePathMatcher itself
515515
}
516516

517517
@action.bound
@@ -524,12 +524,12 @@ class SimplePathMatcherConfig extends MatcherConfig<matchers.SimplePathMatcher>
524524
const [baseUrl, query] = this.url.split('?');
525525

526526
if (query === undefined) {
527-
this.props.onChange(new matchers.SimplePathMatcher(baseUrl));
527+
this.props.onChange(new matchers.FlexiblePathMatcher(baseUrl));
528528
} else {
529529
if (this.props.matcherIndex !== undefined) this.url = baseUrl;
530530

531531
this.props.onChange(
532-
new matchers.SimplePathMatcher(baseUrl),
532+
new matchers.FlexiblePathMatcher(baseUrl),
533533
new matchers.ExactQueryMatcher('?' + query)
534534
);
535535
}
@@ -1133,10 +1133,10 @@ class EthParamsMatcherConfig extends MatcherConfig<EthereumParamsMatcher> {
11331133

11341134
@observer
11351135
class RTCContentMatcherConfig<T extends
1136-
| typeof HasDataChannelMatcherDefinition
1137-
| typeof HasVideoTrackMatcherDefinition
1138-
| typeof HasAudioTrackMatcherDefinition
1139-
| typeof HasMediaTrackMatcherDefinition
1136+
| typeof HasDataChannelMatcher
1137+
| typeof HasVideoTrackMatcher
1138+
| typeof HasAudioTrackMatcher
1139+
| typeof HasMediaTrackMatcher
11401140
> extends MatcherConfig<InstanceType<T>, { matcherClass?: T, matcherKey: InstanceType<T>['type'] }> {
11411141

11421142
componentDidMount() {

src/components/modify/modify-page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { RulesStore } from '../../model/rules/rules-store';
1414
import { AccountStore } from '../../model/account/account-store';
1515

1616
import { RuleType } from '../../model/rules/rules';
17-
import { getNewRule, getRuleDefaultHandler } from '../../model/rules/rule-creation';
17+
import { getNewRule, getRuleDefaultStep } from '../../model/rules/rule-creation';
1818
import {
1919
cloneItem,
2020
getItemAtPath,
@@ -222,7 +222,7 @@ class ModifyPage extends React.Component<ModifyPageProps> {
222222
deleteItem={deleteDraftItem}
223223
toggleRuleCollapsed={this.toggleRuleCollapsed}
224224
updateGroupTitle={updateGroupTitle}
225-
getRuleDefaultHandler={this.getRuleDefaultHandler}
225+
getRuleDefaultStep={this.getRuleDefaultStep}
226226

227227
moveRule={moveDraftRule}
228228
combineRulesAsGroup={combineDraftRulesAsGroup}
@@ -316,8 +316,8 @@ class ModifyPage extends React.Component<ModifyPageProps> {
316316
this.collapsedRulesMap[ruleId] = !this.collapsedRulesMap[ruleId];
317317
}
318318

319-
getRuleDefaultHandler = (type: RuleType) => {
320-
return getRuleDefaultHandler(type, this.props.rulesStore);
319+
getRuleDefaultStep = (type: RuleType) => {
320+
return getRuleDefaultStep(type, this.props.rulesStore);
321321
};
322322

323323
readonly importRules = async () => {

0 commit comments

Comments
 (0)