Skip to content

Commit fe1fd78

Browse files
committed
refactor: implement HWID settings in subscription and external squad management
- Updated .env.sample to remove HWID_DEVICE_LIMIT_ENABLED configuration. - Bumped package versions to 2.3.0 and updated dependencies. - Introduced HWID settings in subscription and external squad schemas. - Enhanced subscription and external squad services to handle HWID settings. - Refactored related queries and commands to incorporate HWID settings. - Improved caching mechanisms for subscription settings.
1 parent 0c88878 commit fe1fd78

File tree

44 files changed

+595
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+595
-396
lines changed

.env.sample

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ WEBHOOK_URL=https://your-webhook-url.com/endpoint
6565
### This secret is used to sign the webhook payload, must be exact 64 characters. Only a-z, 0-9, A-Z are allowed.
6666
WEBHOOK_SECRET_HEADER=vsmu67Kmg6R8FjIOF1WUY8LWBHie4scdEqrfsKmyf4IAf8dY3nFS0wwYHkhh6ZvQ
6767

68-
### HWID DEVICE DETECTION AND LIMITATION ###
69-
# Don't enable this if you don't know what you are doing.
70-
# Review documentation before enabling this feature.
71-
# https://docs.rw/docs/features/hwid-device-limit/
72-
HWID_DEVICE_LIMIT_ENABLED=false
73-
74-
7568
### Bandwidth usage reached notifications
7669
BANDWIDTH_USAGE_NOTIFICATIONS_ENABLED=false
7770
# Only in ASC order (example: [60, 80]), must be valid array of integer(min: 25, max: 95) numbers. No more than 5 values.

libs/contract/commands/external-squads/update-external-squad.command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ExternalSquadResponseHeadersSchema,
66
ExternalSquadSchema,
77
ExternalSquadSubscriptionSettingsSchema,
8+
HwidSettingsSchema,
89
} from '../../models';
910
import { getEndpointDetails, SUBSCRIPTION_TEMPLATE_TYPE } from '../../constants';
1011
import { EXTERNAL_SQUADS_ROUTES, REST_API } from '../../api';
@@ -41,6 +42,7 @@ export namespace UpdateExternalSquadCommand {
4142
subscriptionSettings: ExternalSquadSubscriptionSettingsSchema.optional(),
4243
hostOverrides: ExternalSquadHostOverridesSchema.optional(),
4344
responseHeaders: ExternalSquadResponseHeadersSchema.optional(),
45+
hwidSettings: z.optional(z.nullable(HwidSettingsSchema)),
4446
});
4547

4648
export type Request = z.infer<typeof RequestSchema>;

libs/contract/commands/subscription-settings/update-subscription-settings.command.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { z } from 'zod';
22

3-
import { ResponseRulesConfigSchema, SubscriptionSettingsSchema } from '../../models';
3+
import {
4+
HwidSettingsSchema,
5+
ResponseRulesConfigSchema,
6+
SubscriptionSettingsSchema,
7+
} from '../../models';
48
import { REST_API, SUBSCRIPTION_SETTINGS_ROUTES } from '../../api';
59
import { getEndpointDetails } from '../../constants';
610

@@ -52,6 +56,7 @@ export namespace UpdateSubscriptionSettingsCommand {
5256
randomizeHosts: z.optional(z.boolean()),
5357

5458
responseRules: z.optional(ResponseRulesConfigSchema),
59+
hwidSettings: z.optional(HwidSettingsSchema),
5560
});
5661

5762
export type Request = z.infer<typeof RequestSchema>;

libs/contract/constants/cache-keys/cache-keys.constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { TSubscriptionTemplateType } from '../subscription-template';
22

33
export const CACHE_KEYS = {
44
SUBSCRIPTION_SETTINGS: 'subscription_settings',
5+
EXTERNAL_SQUAD_SETTINGS: (uuid: string) => `external_squad_settings:${uuid}`,
56
SUBSCRIPTION_TEMPLATE: (name: string, type: TSubscriptionTemplateType) =>
67
`subscription_template:${name}:${type}`,
78
PASSKEY_REGISTRATION_OPTIONS: (uuid: string) => `passkey_registration_options:${uuid}`,
@@ -11,4 +12,6 @@ export const CACHE_KEYS = {
1112

1213
export const CACHE_KEYS_TTL = {
1314
REMNAWAVE_SETTINGS: 86_400_000, // 1 day
15+
EXTERNAL_SQUAD_SETTINGS: 3_600_000, // 1 hour
16+
SUBSCRIPTION_SETTINGS: 3_600_000, // 1 hour
1417
} as const;

libs/contract/models/external-squad.schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ExternalSquadHostOverridesSchema,
66
ExternalSquadResponseHeadersSchema,
77
} from './external-squads';
8+
import { HwidSettingsSchema } from './subscription-settings/hwid-settings.schema';
89
import { SUBSCRIPTION_TEMPLATE_TYPE } from '../constants';
910

1011
export const ExternalSquadSchema = z.object({
@@ -24,6 +25,7 @@ export const ExternalSquadSchema = z.object({
2425
subscriptionSettings: z.nullable(ExternalSquadSubscriptionSettingsSchema),
2526
hostOverrides: z.nullable(ExternalSquadHostOverridesSchema),
2627
responseHeaders: ExternalSquadResponseHeadersSchema,
28+
hwidSettings: z.nullable(HwidSettingsSchema),
2729

2830
createdAt: z
2931
.string()

libs/contract/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export * from './response-rules';
2222
export * from './snippets.schema';
2323
export * from './subscription-info.schema';
2424
export * from './subscription-request-history.schema';
25+
export * from './subscription-settings';
2526
export * from './subscription-settings.schema';
2627
export * from './tanstack-query';
2728
export * from './users.schema';

libs/contract/models/subscription-settings.schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from 'zod';
22

3+
import { HwidSettingsSchema } from './subscription-settings/hwid-settings.schema';
34
import { ResponseRulesConfigSchema } from './response-rules';
45

56
export const SubscriptionSettingsSchema = z.object({
@@ -30,6 +31,8 @@ export const SubscriptionSettingsSchema = z.object({
3031

3132
responseRules: z.nullable(ResponseRulesConfigSchema),
3233

34+
hwidSettings: z.nullable(HwidSettingsSchema),
35+
3336
createdAt: z
3437
.string()
3538
.datetime()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import z from 'zod';
2+
3+
export const HwidSettingsSchema = z.object({
4+
enabled: z.boolean(),
5+
fallbackDeviceLimit: z.number(),
6+
maxDevicesAnnounce: z.nullable(
7+
z.string().max(200, { message: 'Announce must be less than 200 characters' }),
8+
),
9+
});
10+
11+
export type THwidSettings = z.infer<typeof HwidSettingsSchema>;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './hwid-settings.schema';

libs/contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remnawave/backend-contract",
3-
"version": "2.2.37",
3+
"version": "2.3.0",
44
"public": true,
55
"license": "AGPL-3.0-only",
66
"description": "A contract library for Remnawave Backend. It can be used in backend and frontend.",

0 commit comments

Comments
 (0)