@remnawave/backend-contract 2.9.32 → 2.9.33
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/build/backend/commands/subscription-settings/get-subscription-settings.command.d.ts +25 -3
- package/build/backend/commands/subscription-settings/get-subscription-settings.command.d.ts.map +1 -1
- package/build/backend/commands/subscription-settings/update-subscription-settings.command.d.ts +50 -6
- package/build/backend/commands/subscription-settings/update-subscription-settings.command.d.ts.map +1 -1
- package/build/backend/commands/system/testers/test-srr-matcher.command.d.ts +47 -5
- package/build/backend/commands/system/testers/test-srr-matcher.command.d.ts.map +1 -1
- package/build/backend/constants/response-rules/response-rules.contants.d.ts +3 -23
- package/build/backend/constants/response-rules/response-rules.contants.d.ts.map +1 -1
- package/build/backend/constants/response-rules/response-rules.contants.js +3 -22
- package/build/backend/models/response-rules/index.d.ts +0 -2
- package/build/backend/models/response-rules/index.d.ts.map +1 -1
- package/build/backend/models/response-rules/index.js +0 -2
- package/build/backend/models/response-rules/response-rule-condition.schema.d.ts +3 -40
- package/build/backend/models/response-rules/response-rule-condition.schema.d.ts.map +1 -1
- package/build/backend/models/response-rules/response-rule-condition.schema.js +6 -156
- package/build/backend/models/response-rules/response-rule.schema.d.ts +44 -4
- package/build/backend/models/response-rules/response-rule.schema.d.ts.map +1 -1
- package/build/backend/models/response-rules/response-rule.schema.js +10 -26
- package/build/backend/models/response-rules/response-rules-config.schema.d.ts +25 -3
- package/build/backend/models/response-rules/response-rules-config.schema.d.ts.map +1 -1
- package/build/backend/models/response-rules/response-rules-config.schema.js +4 -9
- package/build/backend/models/response-rules/response-rules-examples.d.ts +2 -2
- package/build/backend/models/response-rules/response-rules-examples.d.ts.map +1 -1
- package/build/backend/models/response-rules/response-rules-examples.js +22 -30
- package/build/backend/models/subscription-settings.schema.d.ts +25 -3
- package/build/backend/models/subscription-settings.schema.d.ts.map +1 -1
- package/build/frontend/constants/response-rules/response-rules.contants.js +3 -22
- package/build/frontend/models/response-rules/index.js +0 -2
- package/build/frontend/models/response-rules/response-rule-condition.schema.js +6 -156
- package/build/frontend/models/response-rules/response-rule.schema.js +10 -26
- package/build/frontend/models/response-rules/response-rules-config.schema.js +4 -9
- package/build/frontend/models/response-rules/response-rules-examples.js +22 -30
- package/package.json +1 -1
- package/build/backend/models/response-rules/response-rules-legacy.schema.d.ts +0 -157
- package/build/backend/models/response-rules/response-rules-legacy.schema.d.ts.map +0 -1
- package/build/backend/models/response-rules/response-rules-legacy.schema.js +0 -33
- package/build/backend/models/response-rules/response-rules-migration.d.ts +0 -10
- package/build/backend/models/response-rules/response-rules-migration.d.ts.map +0 -1
- package/build/backend/models/response-rules/response-rules-migration.js +0 -45
- package/build/frontend/models/response-rules/response-rules-legacy.schema.js +0 -33
- package/build/frontend/models/response-rules/response-rules-migration.js +0 -45
|
@@ -3,7 +3,27 @@ export declare const ResponseRuleSchemaBase: z.ZodObject<{
|
|
|
3
3
|
name: z.ZodString;
|
|
4
4
|
description: z.ZodOptional<z.ZodString>;
|
|
5
5
|
enabled: z.ZodBoolean;
|
|
6
|
-
|
|
6
|
+
operator: z.ZodEnum<{
|
|
7
|
+
readonly AND: "AND";
|
|
8
|
+
readonly OR: "OR";
|
|
9
|
+
}>;
|
|
10
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
11
|
+
headerName: z.ZodString;
|
|
12
|
+
operator: z.ZodEnum<{
|
|
13
|
+
readonly EQUALS: "EQUALS";
|
|
14
|
+
readonly NOT_EQUALS: "NOT_EQUALS";
|
|
15
|
+
readonly CONTAINS: "CONTAINS";
|
|
16
|
+
readonly NOT_CONTAINS: "NOT_CONTAINS";
|
|
17
|
+
readonly STARTS_WITH: "STARTS_WITH";
|
|
18
|
+
readonly NOT_STARTS_WITH: "NOT_STARTS_WITH";
|
|
19
|
+
readonly ENDS_WITH: "ENDS_WITH";
|
|
20
|
+
readonly NOT_ENDS_WITH: "NOT_ENDS_WITH";
|
|
21
|
+
readonly REGEX: "REGEX";
|
|
22
|
+
readonly NOT_REGEX: "NOT_REGEX";
|
|
23
|
+
}>;
|
|
24
|
+
value: z.ZodString;
|
|
25
|
+
caseSensitive: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>>;
|
|
7
27
|
responseType: z.ZodEnum<{
|
|
8
28
|
readonly BROWSER: "BROWSER";
|
|
9
29
|
readonly BLOCK: "BLOCK";
|
|
@@ -37,12 +57,32 @@ export declare const ResponseRuleSchemaBase: z.ZodObject<{
|
|
|
37
57
|
}, z.core.$strip>>;
|
|
38
58
|
excludeHostsByTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
59
|
}, z.core.$strip>>;
|
|
40
|
-
}, z.core.$
|
|
60
|
+
}, z.core.$strip>;
|
|
41
61
|
export declare const ResponseRuleSchema: z.ZodObject<{
|
|
42
62
|
name: z.ZodString;
|
|
43
63
|
description: z.ZodOptional<z.ZodString>;
|
|
44
64
|
enabled: z.ZodBoolean;
|
|
45
|
-
|
|
65
|
+
operator: z.ZodEnum<{
|
|
66
|
+
readonly AND: "AND";
|
|
67
|
+
readonly OR: "OR";
|
|
68
|
+
}>;
|
|
69
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
70
|
+
headerName: z.ZodString;
|
|
71
|
+
operator: z.ZodEnum<{
|
|
72
|
+
readonly EQUALS: "EQUALS";
|
|
73
|
+
readonly NOT_EQUALS: "NOT_EQUALS";
|
|
74
|
+
readonly CONTAINS: "CONTAINS";
|
|
75
|
+
readonly NOT_CONTAINS: "NOT_CONTAINS";
|
|
76
|
+
readonly STARTS_WITH: "STARTS_WITH";
|
|
77
|
+
readonly NOT_STARTS_WITH: "NOT_STARTS_WITH";
|
|
78
|
+
readonly ENDS_WITH: "ENDS_WITH";
|
|
79
|
+
readonly NOT_ENDS_WITH: "NOT_ENDS_WITH";
|
|
80
|
+
readonly REGEX: "REGEX";
|
|
81
|
+
readonly NOT_REGEX: "NOT_REGEX";
|
|
82
|
+
}>;
|
|
83
|
+
value: z.ZodString;
|
|
84
|
+
caseSensitive: z.ZodBoolean;
|
|
85
|
+
}, z.core.$strip>>;
|
|
46
86
|
responseType: z.ZodEnum<{
|
|
47
87
|
readonly BROWSER: "BROWSER";
|
|
48
88
|
readonly BLOCK: "BLOCK";
|
|
@@ -76,5 +116,5 @@ export declare const ResponseRuleSchema: z.ZodObject<{
|
|
|
76
116
|
}, z.core.$strip>>;
|
|
77
117
|
excludeHostsByTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
78
118
|
}, z.core.$strip>>;
|
|
79
|
-
}, z.core.$
|
|
119
|
+
}, z.core.$strip>;
|
|
80
120
|
//# sourceMappingURL=response-rule.schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-rule.schema.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rule.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"response-rule.schema.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rule.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCjC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB7B,CAAC"}
|
|
@@ -6,7 +6,7 @@ const constants_1 = require("../../constants");
|
|
|
6
6
|
const response_rule_condition_schema_1 = require("./response-rule-condition.schema");
|
|
7
7
|
const response_rule_modifications_schema_1 = require("./response-rule-modifications.schema");
|
|
8
8
|
const response_rules_examples_1 = require("./response-rules-examples");
|
|
9
|
-
exports.ResponseRuleSchemaBase = zod_1.z.
|
|
9
|
+
exports.ResponseRuleSchemaBase = zod_1.z.object({
|
|
10
10
|
name: zod_1.z
|
|
11
11
|
.string()
|
|
12
12
|
.min(1, 'Name is required')
|
|
@@ -28,28 +28,12 @@ exports.ResponseRuleSchemaBase = zod_1.z.strictObject({
|
|
|
28
28
|
title: 'Enabled',
|
|
29
29
|
markdownDescription: 'Control whether the response rule is enabled or disabled. \n\n - `true` the rule will be applied. \n\n - `false` the rule will be always ignored.',
|
|
30
30
|
}),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (depth > response_rule_condition_schema_1.RESPONSE_RULES_MAX_CONDITION_DEPTH) {
|
|
38
|
-
ctx.addIssue({
|
|
39
|
-
code: 'custom',
|
|
40
|
-
message: `Condition tree is too deep. Maximum depth is ${response_rule_condition_schema_1.RESPONSE_RULES_MAX_CONDITION_DEPTH}.`,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (nodes > response_rule_condition_schema_1.RESPONSE_RULES_MAX_CONDITION_NODES) {
|
|
44
|
-
ctx.addIssue({
|
|
45
|
-
code: 'custom',
|
|
46
|
-
message: `Condition tree is too big. Maximum number of nodes is ${response_rule_condition_schema_1.RESPONSE_RULES_MAX_CONDITION_NODES}.`,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
.meta({
|
|
51
|
-
title: 'When',
|
|
52
|
-
markdownDescription: 'Condition tree to check against the request headers. The root is either a single **condition** or a **group** (`AND`/`OR`/`NOT`) with nested conditions — groups can be nested to express complex logic, e.g. `A AND (B OR C)`. If **when** is omitted, the rule will always be matched.',
|
|
31
|
+
operator: zod_1.z.enum(constants_1.RESPONSE_RULES_OPERATORS).meta({
|
|
32
|
+
markdownDescription: 'Operator to use for combining conditions in the rule.',
|
|
33
|
+
}),
|
|
34
|
+
conditions: zod_1.z.array(response_rule_condition_schema_1.ResponseRuleConditionSchema).meta({
|
|
35
|
+
title: 'Conditions',
|
|
36
|
+
markdownDescription: 'Array of conditions to check against the request headers. Conditions are applied with **operator**. If conditions are empty, the rule will be matched.',
|
|
53
37
|
}),
|
|
54
38
|
responseType: zod_1.z.enum(constants_1.RESPONSE_RULES_RESPONSE_TYPES).meta({
|
|
55
39
|
errorMessage: 'Invalid response type. Please select a valid response type.',
|
|
@@ -70,10 +54,10 @@ exports.ResponseRuleSchema = exports.ResponseRuleSchemaBase.meta({
|
|
|
70
54
|
},
|
|
71
55
|
},
|
|
72
56
|
{
|
|
73
|
-
label: 'Examples:
|
|
74
|
-
markdownDescription: `Block
|
|
57
|
+
label: 'Examples: Block Legacy Clients',
|
|
58
|
+
markdownDescription: `Block requests from legacy clients\n\`\`\`json\n${JSON.stringify(response_rules_examples_1.EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE, null, 2)}\n\`\`\``,
|
|
75
59
|
body: {
|
|
76
|
-
...response_rules_examples_1.
|
|
60
|
+
...response_rules_examples_1.EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE,
|
|
77
61
|
},
|
|
78
62
|
},
|
|
79
63
|
],
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const ResponseRulesConfigSchema: z.ZodObject<{
|
|
3
|
-
version: z.
|
|
3
|
+
version: z.ZodEnum<{
|
|
4
|
+
readonly 1: "1";
|
|
5
|
+
}>;
|
|
4
6
|
settings: z.ZodOptional<z.ZodObject<{
|
|
5
7
|
disableSubscriptionAccessByPath: z.ZodOptional<z.ZodBoolean>;
|
|
6
8
|
}, z.core.$strip>>;
|
|
@@ -8,7 +10,27 @@ export declare const ResponseRulesConfigSchema: z.ZodObject<{
|
|
|
8
10
|
name: z.ZodString;
|
|
9
11
|
description: z.ZodOptional<z.ZodString>;
|
|
10
12
|
enabled: z.ZodBoolean;
|
|
11
|
-
|
|
13
|
+
operator: z.ZodEnum<{
|
|
14
|
+
readonly AND: "AND";
|
|
15
|
+
readonly OR: "OR";
|
|
16
|
+
}>;
|
|
17
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
18
|
+
headerName: z.ZodString;
|
|
19
|
+
operator: z.ZodEnum<{
|
|
20
|
+
readonly EQUALS: "EQUALS";
|
|
21
|
+
readonly NOT_EQUALS: "NOT_EQUALS";
|
|
22
|
+
readonly CONTAINS: "CONTAINS";
|
|
23
|
+
readonly NOT_CONTAINS: "NOT_CONTAINS";
|
|
24
|
+
readonly STARTS_WITH: "STARTS_WITH";
|
|
25
|
+
readonly NOT_STARTS_WITH: "NOT_STARTS_WITH";
|
|
26
|
+
readonly ENDS_WITH: "ENDS_WITH";
|
|
27
|
+
readonly NOT_ENDS_WITH: "NOT_ENDS_WITH";
|
|
28
|
+
readonly REGEX: "REGEX";
|
|
29
|
+
readonly NOT_REGEX: "NOT_REGEX";
|
|
30
|
+
}>;
|
|
31
|
+
value: z.ZodString;
|
|
32
|
+
caseSensitive: z.ZodBoolean;
|
|
33
|
+
}, z.core.$strip>>;
|
|
12
34
|
responseType: z.ZodEnum<{
|
|
13
35
|
readonly BROWSER: "BROWSER";
|
|
14
36
|
readonly BLOCK: "BLOCK";
|
|
@@ -42,6 +64,6 @@ export declare const ResponseRulesConfigSchema: z.ZodObject<{
|
|
|
42
64
|
}, z.core.$strip>>;
|
|
43
65
|
excludeHostsByTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
66
|
}, z.core.$strip>>;
|
|
45
|
-
}, z.core.$
|
|
67
|
+
}, z.core.$strip>>;
|
|
46
68
|
}, z.core.$strip>;
|
|
47
69
|
//# sourceMappingURL=response-rules-config.schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-rules-config.schema.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rules-config.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,yBAAyB
|
|
1
|
+
{"version":3,"file":"response-rules-config.schema.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rules-config.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAYpC,CAAC"}
|
|
@@ -6,20 +6,15 @@ const constants_1 = require("../../constants");
|
|
|
6
6
|
const response_rule_settings_schema_1 = require("./response-rule-settings.schema");
|
|
7
7
|
const response_rule_schema_1 = require("./response-rule.schema");
|
|
8
8
|
const response_rules_examples_1 = require("./response-rules-examples");
|
|
9
|
-
exports.ResponseRulesConfigSchema = zod_1.z
|
|
10
|
-
.
|
|
11
|
-
version: zod_1.z.literal(constants_1.RESPONSE_RULES_CONFIG_VERSION[2]).meta({
|
|
9
|
+
exports.ResponseRulesConfigSchema = zod_1.z.object({
|
|
10
|
+
version: zod_1.z.enum(constants_1.RESPONSE_RULES_CONFIG_VERSION).meta({
|
|
12
11
|
title: 'Response Rules Config Version',
|
|
13
|
-
markdownDescription: 'Version of the **response rules** config. Currently supported version is **
|
|
12
|
+
markdownDescription: 'Version of the **response rules** config. Currently supported version is **1**.',
|
|
14
13
|
}),
|
|
15
14
|
settings: response_rule_settings_schema_1.ResponseRuleSettingsSchema,
|
|
16
15
|
rules: zod_1.z.array(response_rule_schema_1.ResponseRuleSchema).meta({
|
|
17
16
|
title: 'Response Rules',
|
|
18
|
-
markdownDescription: `Array of **response rules**. Rules are evaluated in order and the first rule that matches is applied. If no rule matches, request will be blocked by default.\n\n**Example:**\n\`\`\`json\n${JSON.stringify([response_rules_examples_1.
|
|
17
|
+
markdownDescription: `Array of **response rules**. Rules are evaluated in order and the first rule that matches is applied. If no rule matches, request will be blocked by default.\n\n**Example:**\n\`\`\`json\n${JSON.stringify([response_rules_examples_1.EXAMPLES_SRR_BLANK_RULE], null, 2)}\n\`\`\``,
|
|
19
18
|
defaultSnippets: [],
|
|
20
19
|
}),
|
|
21
|
-
})
|
|
22
|
-
.meta({
|
|
23
|
-
title: 'Response Rules Config',
|
|
24
|
-
markdownDescription: 'Configuration of the **response rules**.',
|
|
25
20
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ResponseRuleSchemaBase } from './response-rule.schema';
|
|
2
1
|
import z from 'zod';
|
|
2
|
+
import type { ResponseRuleSchemaBase } from './response-rule.schema';
|
|
3
3
|
export declare const EXAMPLES_SRR_BLANK_RULE: z.infer<typeof ResponseRuleSchemaBase>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE: z.infer<typeof ResponseRuleSchemaBase>;
|
|
5
5
|
export declare function generateResponseRuleDescription(schema: typeof ResponseRuleSchemaBase): string;
|
|
6
6
|
//# sourceMappingURL=response-rules-examples.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-rules-examples.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rules-examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,
|
|
1
|
+
{"version":3,"file":"response-rules-examples.d.ts","sourceRoot":"","sources":["../../../../models/response-rules/response-rules-examples.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAOpB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAU1E,CAAC;AAEF,eAAO,MAAM,sCAAsC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAoBzF,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,OAAO,sBAAsB,UAcpF"}
|
|
@@ -1,46 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE = exports.EXAMPLES_SRR_BLANK_RULE = void 0;
|
|
4
4
|
exports.generateResponseRuleDescription = generateResponseRuleDescription;
|
|
5
5
|
const constants_1 = require("../../constants");
|
|
6
6
|
exports.EXAMPLES_SRR_BLANK_RULE = {
|
|
7
7
|
name: 'Blank rule',
|
|
8
8
|
description: 'Blank rule',
|
|
9
|
+
operator: 'AND',
|
|
9
10
|
enabled: true,
|
|
11
|
+
conditions: [],
|
|
10
12
|
responseType: 'BLOCK',
|
|
11
13
|
responseModifications: {
|
|
12
14
|
headers: [],
|
|
13
15
|
},
|
|
14
16
|
};
|
|
15
|
-
exports.
|
|
16
|
-
name: 'Block Legacy
|
|
17
|
-
description: 'Block
|
|
17
|
+
exports.EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE = {
|
|
18
|
+
name: 'Block Legacy Clients',
|
|
19
|
+
description: 'Block requests from legacy clients',
|
|
18
20
|
enabled: true,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
headerName: 'user-agent',
|
|
37
|
-
operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
|
|
38
|
-
value: 'FoxRay',
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
21
|
+
operator: constants_1.RESPONSE_RULES_OPERATORS.OR,
|
|
22
|
+
conditions: [
|
|
23
|
+
{
|
|
24
|
+
headerName: 'user-agent',
|
|
25
|
+
operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
|
|
26
|
+
value: 'Hiddify',
|
|
27
|
+
caseSensitive: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
headerName: 'user-agent',
|
|
31
|
+
operator: constants_1.RESPONSE_RULES_CONDITION_OPERATORS.CONTAINS,
|
|
32
|
+
value: 'FoxRay',
|
|
33
|
+
caseSensitive: true,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
44
36
|
responseType: constants_1.RESPONSE_RULES_RESPONSE_TYPES.BLOCK,
|
|
45
37
|
};
|
|
46
38
|
function generateResponseRuleDescription(schema) {
|
|
@@ -54,5 +46,5 @@ function generateResponseRuleDescription(schema) {
|
|
|
54
46
|
const fieldsText = fields
|
|
55
47
|
.map((field) => `- **${field.name}**: ${field.description}`)
|
|
56
48
|
.join('\n');
|
|
57
|
-
return `Response rule configuration.\n\n**Fields:**\n${fieldsText}\n\n**Example:**\n\`\`\`json\n${JSON.stringify(exports.
|
|
49
|
+
return `Response rule configuration.\n\n**Fields:**\n${fieldsText}\n\n**Example:**\n\`\`\`json\n${JSON.stringify(exports.EXAMPLES_SRR_BLOCK_LEGACY_CLIENTS_RULE, null, 2)}\n\`\`\``;
|
|
58
50
|
}
|
|
@@ -14,7 +14,9 @@ export declare const SubscriptionSettingsSchema: z.ZodObject<{
|
|
|
14
14
|
customResponseHeaders: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
15
15
|
randomizeHosts: z.ZodBoolean;
|
|
16
16
|
responseRules: z.ZodNullable<z.ZodObject<{
|
|
17
|
-
version: z.
|
|
17
|
+
version: z.ZodEnum<{
|
|
18
|
+
readonly 1: "1";
|
|
19
|
+
}>;
|
|
18
20
|
settings: z.ZodOptional<z.ZodObject<{
|
|
19
21
|
disableSubscriptionAccessByPath: z.ZodOptional<z.ZodBoolean>;
|
|
20
22
|
}, z.core.$strip>>;
|
|
@@ -22,7 +24,27 @@ export declare const SubscriptionSettingsSchema: z.ZodObject<{
|
|
|
22
24
|
name: z.ZodString;
|
|
23
25
|
description: z.ZodOptional<z.ZodString>;
|
|
24
26
|
enabled: z.ZodBoolean;
|
|
25
|
-
|
|
27
|
+
operator: z.ZodEnum<{
|
|
28
|
+
readonly AND: "AND";
|
|
29
|
+
readonly OR: "OR";
|
|
30
|
+
}>;
|
|
31
|
+
conditions: z.ZodArray<z.ZodObject<{
|
|
32
|
+
headerName: z.ZodString;
|
|
33
|
+
operator: z.ZodEnum<{
|
|
34
|
+
readonly EQUALS: "EQUALS";
|
|
35
|
+
readonly NOT_EQUALS: "NOT_EQUALS";
|
|
36
|
+
readonly CONTAINS: "CONTAINS";
|
|
37
|
+
readonly NOT_CONTAINS: "NOT_CONTAINS";
|
|
38
|
+
readonly STARTS_WITH: "STARTS_WITH";
|
|
39
|
+
readonly NOT_STARTS_WITH: "NOT_STARTS_WITH";
|
|
40
|
+
readonly ENDS_WITH: "ENDS_WITH";
|
|
41
|
+
readonly NOT_ENDS_WITH: "NOT_ENDS_WITH";
|
|
42
|
+
readonly REGEX: "REGEX";
|
|
43
|
+
readonly NOT_REGEX: "NOT_REGEX";
|
|
44
|
+
}>;
|
|
45
|
+
value: z.ZodString;
|
|
46
|
+
caseSensitive: z.ZodBoolean;
|
|
47
|
+
}, z.core.$strip>>;
|
|
26
48
|
responseType: z.ZodEnum<{
|
|
27
49
|
readonly BROWSER: "BROWSER";
|
|
28
50
|
readonly BLOCK: "BLOCK";
|
|
@@ -56,7 +78,7 @@ export declare const SubscriptionSettingsSchema: z.ZodObject<{
|
|
|
56
78
|
}, z.core.$strip>>;
|
|
57
79
|
excludeHostsByTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
80
|
}, z.core.$strip>>;
|
|
59
|
-
}, z.core.$
|
|
81
|
+
}, z.core.$strip>>;
|
|
60
82
|
}, z.core.$strip>>;
|
|
61
83
|
hwidSettings: z.ZodNullable<z.ZodObject<{
|
|
62
84
|
enabled: z.ZodBoolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-settings.schema.d.ts","sourceRoot":"","sources":["../../../models/subscription-settings.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"subscription-settings.schema.d.ts","sourceRoot":"","sources":["../../../models/subscription-settings.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBrC,CAAC"}
|
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESPONSE_RULES_CONDITION_OPERATORS_DESCRIPTION = exports.RESPONSE_RULES_RESPONSE_TYPES_DESCRIPTION = exports.RESPONSE_RULES_CONDITION_OPERATORS_VALUES = exports.RESPONSE_RULES_RESPONSE_TYPES_VALUES = exports.RESPONSE_RULES_RESPONSE_TYPES = exports.RESPONSE_RULES_CONDITION_OPERATORS = exports.
|
|
3
|
+
exports.RESPONSE_RULES_CONDITION_OPERATORS_DESCRIPTION = exports.RESPONSE_RULES_RESPONSE_TYPES_DESCRIPTION = exports.RESPONSE_RULES_CONDITION_OPERATORS_VALUES = exports.RESPONSE_RULES_RESPONSE_TYPES_VALUES = exports.RESPONSE_RULES_RESPONSE_TYPES = exports.RESPONSE_RULES_CONDITION_OPERATORS = exports.RESPONSE_RULE_CONDITION_TYPES = exports.RESPONSE_RULES_OPERATORS = exports.RESPONSE_RULES_CONFIG_VERSION = void 0;
|
|
4
4
|
const subscription_template_1 = require("../subscription-template");
|
|
5
5
|
exports.RESPONSE_RULES_CONFIG_VERSION = {
|
|
6
6
|
1: '1',
|
|
7
|
-
2: '2',
|
|
8
7
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Version 1
|
|
11
|
-
*/
|
|
12
8
|
exports.RESPONSE_RULES_OPERATORS = {
|
|
13
9
|
AND: 'AND',
|
|
14
10
|
OR: 'OR',
|
|
15
11
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
exports.RESPONSE_RULES_GROUP_OPERATORS = {
|
|
20
|
-
AND: 'AND',
|
|
21
|
-
OR: 'OR',
|
|
22
|
-
NOT: 'NOT',
|
|
23
|
-
};
|
|
24
|
-
exports.RESPONSE_RULES_GROUP_OPERATORS_VALUES = Object.values(exports.RESPONSE_RULES_GROUP_OPERATORS);
|
|
25
|
-
exports.RESPONSE_RULES_GROUP_OPERATORS_DESCRIPTION = {
|
|
26
|
-
[exports.RESPONSE_RULES_GROUP_OPERATORS.AND]: 'Matches only if **all** nested conditions match. `conditions.every()`',
|
|
27
|
-
[exports.RESPONSE_RULES_GROUP_OPERATORS.OR]: 'Matches if **at least one** nested condition matches. `conditions.some()`',
|
|
28
|
-
[exports.RESPONSE_RULES_GROUP_OPERATORS.NOT]: 'Inverts the result of the nested **condition**. `!condition`',
|
|
12
|
+
exports.RESPONSE_RULE_CONDITION_TYPES = {
|
|
13
|
+
HEADER: 'HEADER',
|
|
29
14
|
};
|
|
30
15
|
exports.RESPONSE_RULES_CONDITION_OPERATORS = {
|
|
31
16
|
EQUALS: 'EQUALS',
|
|
@@ -38,8 +23,6 @@ exports.RESPONSE_RULES_CONDITION_OPERATORS = {
|
|
|
38
23
|
NOT_ENDS_WITH: 'NOT_ENDS_WITH',
|
|
39
24
|
REGEX: 'REGEX',
|
|
40
25
|
NOT_REGEX: 'NOT_REGEX',
|
|
41
|
-
EXISTS: 'EXISTS',
|
|
42
|
-
NOT_EXISTS: 'NOT_EXISTS',
|
|
43
26
|
};
|
|
44
27
|
exports.RESPONSE_RULES_RESPONSE_TYPES = {
|
|
45
28
|
...subscription_template_1.SUBSCRIPTION_TEMPLATE_TYPE,
|
|
@@ -75,6 +58,4 @@ exports.RESPONSE_RULES_CONDITION_OPERATORS_DESCRIPTION = {
|
|
|
75
58
|
[exports.RESPONSE_RULES_CONDITION_OPERATORS.NOT_ENDS_WITH]: 'Confirms the header value does not end with the specified string. `!string.endsWith()`',
|
|
76
59
|
[exports.RESPONSE_RULES_CONDITION_OPERATORS.REGEX]: 'Evaluates if the header value matches the specified regular expression pattern. `regex.test()`',
|
|
77
60
|
[exports.RESPONSE_RULES_CONDITION_OPERATORS.NOT_REGEX]: 'Evaluates if the header value does not match the specified regular expression pattern. `!regex.test()`',
|
|
78
|
-
[exports.RESPONSE_RULES_CONDITION_OPERATORS.EXISTS]: 'Checks that the header is present in the request, regardless of its value. `value` is not required. `string !== undefined`',
|
|
79
|
-
[exports.RESPONSE_RULES_CONDITION_OPERATORS.NOT_EXISTS]: 'Checks that the header is not present in the request. `value` is not required. `string === undefined`',
|
|
80
61
|
};
|
|
@@ -18,5 +18,3 @@ __exportStar(require("./response-rule-condition.schema"), exports);
|
|
|
18
18
|
__exportStar(require("./response-rule-modifications.schema"), exports);
|
|
19
19
|
__exportStar(require("./response-rule.schema"), exports);
|
|
20
20
|
__exportStar(require("./response-rules-config.schema"), exports);
|
|
21
|
-
__exportStar(require("./response-rules-legacy.schema"), exports);
|
|
22
|
-
__exportStar(require("./response-rules-migration"), exports);
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.forEachResponseRuleCondition = forEachResponseRuleCondition;
|
|
5
|
-
exports.measureResponseRuleConditionTree = measureResponseRuleConditionTree;
|
|
3
|
+
exports.ResponseRuleConditionSchema = void 0;
|
|
6
4
|
const zod_1 = require("zod");
|
|
7
5
|
const constants_1 = require("../../constants");
|
|
8
|
-
exports.RESPONSE_RULES_MAX_CONDITION_DEPTH = 10;
|
|
9
|
-
exports.RESPONSE_RULES_MAX_CONDITION_NODES = 100;
|
|
10
|
-
const OPERATORS_WITHOUT_VALUE = [
|
|
11
|
-
constants_1.RESPONSE_RULES_CONDITION_OPERATORS.EXISTS,
|
|
12
|
-
constants_1.RESPONSE_RULES_CONDITION_OPERATORS.NOT_EXISTS,
|
|
13
|
-
];
|
|
14
6
|
exports.ResponseRuleConditionSchema = zod_1.z
|
|
15
|
-
.
|
|
7
|
+
.object({
|
|
16
8
|
headerName: zod_1.z
|
|
17
9
|
.string()
|
|
18
10
|
.regex(/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/, 'Invalid header name. Only letters(a-z, A-Z), numbers(0-9), underscores(_) and hyphens(-) are allowed.')
|
|
@@ -29,27 +21,14 @@ exports.ResponseRuleConditionSchema = zod_1.z
|
|
|
29
21
|
.string()
|
|
30
22
|
.min(1, 'Value is required')
|
|
31
23
|
.max(255, 'Value must be less than 255 characters')
|
|
32
|
-
.optional()
|
|
33
24
|
.meta({
|
|
34
|
-
markdownDescription: '**Value** to check against the **headerName**.
|
|
25
|
+
markdownDescription: '**Value** to check against the **headerName**.',
|
|
35
26
|
}),
|
|
36
|
-
caseSensitive: zod_1.z.boolean().
|
|
37
|
-
|
|
38
|
-
markdownDescription: 'Whether the value is **case sensitive**. Optional, defaults to `false`. \n\n - `true`: the value will be compared as is. \n\n - `false`: the value will be lowercased **before** comparison.',
|
|
27
|
+
caseSensitive: zod_1.z.boolean().meta({
|
|
28
|
+
markdownDescription: 'Whether the value is **case sensitive**. \n\n - `true`: the value will be compared as is. \n\n - `false`: the value will be lowercased **before** comparison.',
|
|
39
29
|
}),
|
|
40
|
-
})
|
|
41
|
-
.superRefine((condition, ctx) => {
|
|
42
|
-
if (condition.value === undefined &&
|
|
43
|
-
!OPERATORS_WITHOUT_VALUE.includes(condition.operator)) {
|
|
44
|
-
ctx.addIssue({
|
|
45
|
-
code: 'custom',
|
|
46
|
-
path: ['value'],
|
|
47
|
-
message: `Value is required for operator "${condition.operator}".`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
30
|
})
|
|
51
31
|
.meta({
|
|
52
|
-
title: 'Condition',
|
|
53
32
|
markdownDescription: 'Condition to check against the **headerName**.',
|
|
54
33
|
defaultSnippets: [
|
|
55
34
|
{
|
|
@@ -59,137 +38,8 @@ exports.ResponseRuleConditionSchema = zod_1.z
|
|
|
59
38
|
headerName: 'accept',
|
|
60
39
|
operator: 'CONTAINS',
|
|
61
40
|
value: 'text/html',
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: 'Examples: Check if header exists',
|
|
66
|
-
markdownDescription: 'Condition to check if **headerName** is present in the request',
|
|
67
|
-
body: {
|
|
68
|
-
headerName: 'x-hwid',
|
|
69
|
-
operator: 'EXISTS',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
exports.ResponseRuleConditionGroupSchema = zod_1.z
|
|
75
|
-
.strictObject({
|
|
76
|
-
operator: zod_1.z
|
|
77
|
-
.enum([constants_1.RESPONSE_RULES_GROUP_OPERATORS.AND, constants_1.RESPONSE_RULES_GROUP_OPERATORS.OR])
|
|
78
|
-
.meta({
|
|
79
|
-
markdownDescription: 'Logical operator to use for combining nested **conditions**.',
|
|
80
|
-
markdownEnumDescriptions: [
|
|
81
|
-
constants_1.RESPONSE_RULES_GROUP_OPERATORS_DESCRIPTION.AND,
|
|
82
|
-
constants_1.RESPONSE_RULES_GROUP_OPERATORS_DESCRIPTION.OR,
|
|
83
|
-
],
|
|
84
|
-
}),
|
|
85
|
-
get conditions() {
|
|
86
|
-
return zod_1.z
|
|
87
|
-
.array(exports.ResponseRuleConditionNodeSchema)
|
|
88
|
-
.min(1, 'Group must contain at least one condition')
|
|
89
|
-
.meta({
|
|
90
|
-
title: 'Conditions',
|
|
91
|
-
markdownDescription: 'Array of nested conditions. Each item is either a **condition** or another **group** (`AND`/`OR`/`NOT`), so groups can be nested to express complex logic.',
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
})
|
|
95
|
-
.meta({
|
|
96
|
-
title: 'Condition Group',
|
|
97
|
-
markdownDescription: 'Group of nested conditions combined with a logical **operator** (`AND`/`OR`). Groups can be nested inside each other.',
|
|
98
|
-
defaultSnippets: [
|
|
99
|
-
{
|
|
100
|
-
label: 'Examples: OR group',
|
|
101
|
-
markdownDescription: 'Group that matches if **at least one** nested condition matches',
|
|
102
|
-
body: {
|
|
103
|
-
operator: 'OR',
|
|
104
|
-
conditions: [
|
|
105
|
-
{
|
|
106
|
-
headerName: 'user-agent',
|
|
107
|
-
operator: 'CONTAINS',
|
|
108
|
-
value: 'Hiddify',
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
headerName: 'user-agent',
|
|
112
|
-
operator: 'CONTAINS',
|
|
113
|
-
value: 'FoxRay',
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
});
|
|
120
|
-
exports.ResponseRuleConditionNotSchema = zod_1.z
|
|
121
|
-
.strictObject({
|
|
122
|
-
operator: zod_1.z.literal(constants_1.RESPONSE_RULES_GROUP_OPERATORS.NOT).meta({
|
|
123
|
-
markdownDescription: constants_1.RESPONSE_RULES_GROUP_OPERATORS_DESCRIPTION.NOT,
|
|
124
|
-
}),
|
|
125
|
-
get condition() {
|
|
126
|
-
return exports.ResponseRuleConditionNodeSchema.meta({
|
|
127
|
-
title: 'Condition',
|
|
128
|
-
markdownDescription: 'Nested condition to invert. Can be a **condition** or a **group**.',
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
})
|
|
132
|
-
.meta({
|
|
133
|
-
title: 'NOT Group',
|
|
134
|
-
markdownDescription: 'Inverts the result of the nested **condition**. The nested condition can be a single condition or a whole group.',
|
|
135
|
-
defaultSnippets: [
|
|
136
|
-
{
|
|
137
|
-
label: 'Examples: NOT group',
|
|
138
|
-
markdownDescription: 'Matches if the nested condition does **not** match',
|
|
139
|
-
body: {
|
|
140
|
-
operator: 'NOT',
|
|
141
|
-
condition: {
|
|
142
|
-
headerName: 'user-agent',
|
|
143
|
-
operator: 'CONTAINS',
|
|
144
|
-
value: 'Happ',
|
|
145
|
-
},
|
|
41
|
+
caseSensitive: true,
|
|
146
42
|
},
|
|
147
43
|
},
|
|
148
44
|
],
|
|
149
45
|
});
|
|
150
|
-
exports.ResponseRuleConditionNodeSchema = zod_1.z
|
|
151
|
-
.lazy(() => zod_1.z.discriminatedUnion('operator', [
|
|
152
|
-
exports.ResponseRuleConditionSchema,
|
|
153
|
-
exports.ResponseRuleConditionGroupSchema,
|
|
154
|
-
exports.ResponseRuleConditionNotSchema,
|
|
155
|
-
]))
|
|
156
|
-
.meta({
|
|
157
|
-
title: 'Condition Node',
|
|
158
|
-
markdownDescription: 'Either a single **condition** (header check) or a **group** (`AND`/`OR`/`NOT`) with nested conditions. Groups can be nested to express complex logic, e.g. `A AND (B OR C)`.',
|
|
159
|
-
});
|
|
160
|
-
function forEachResponseRuleCondition(node, callback) {
|
|
161
|
-
switch (node.operator) {
|
|
162
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.AND:
|
|
163
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.OR:
|
|
164
|
-
for (const child of node.conditions) {
|
|
165
|
-
forEachResponseRuleCondition(child, callback);
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.NOT:
|
|
169
|
-
forEachResponseRuleCondition(node.condition, callback);
|
|
170
|
-
return;
|
|
171
|
-
default:
|
|
172
|
-
callback(node);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
function measureResponseRuleConditionTree(node) {
|
|
176
|
-
switch (node.operator) {
|
|
177
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.AND:
|
|
178
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.OR: {
|
|
179
|
-
let depth = 0;
|
|
180
|
-
let nodes = 1;
|
|
181
|
-
for (const child of node.conditions) {
|
|
182
|
-
const childMetrics = measureResponseRuleConditionTree(child);
|
|
183
|
-
depth = Math.max(depth, childMetrics.depth);
|
|
184
|
-
nodes += childMetrics.nodes;
|
|
185
|
-
}
|
|
186
|
-
return { depth: depth + 1, nodes };
|
|
187
|
-
}
|
|
188
|
-
case constants_1.RESPONSE_RULES_GROUP_OPERATORS.NOT: {
|
|
189
|
-
const childMetrics = measureResponseRuleConditionTree(node.condition);
|
|
190
|
-
return { depth: childMetrics.depth + 1, nodes: childMetrics.nodes + 1 };
|
|
191
|
-
}
|
|
192
|
-
default:
|
|
193
|
-
return { depth: 1, nodes: 1 };
|
|
194
|
-
}
|
|
195
|
-
}
|