@serve.zone/interfaces 32.123.0 → 32.125.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.
Files changed (51) hide show
  1. package/changelog.md +17 -0
  2. package/dist_ts/00_commitinfo_data.js +1 -1
  3. package/dist_ts/data/backupmx.d.ts +135 -0
  4. package/dist_ts/data/backupmx.js +128 -0
  5. package/dist_ts/data/certificateauthority.d.ts +57 -0
  6. package/dist_ts/data/certificateauthority.js +69 -0
  7. package/dist_ts/data/externaldns.d.ts +135 -0
  8. package/dist_ts/data/externaldns.js +138 -0
  9. package/dist_ts/data/gateway.d.ts +22 -0
  10. package/dist_ts/data/gateway.js +1 -1
  11. package/dist_ts/data/gatewayarearows.d.ts +2 -1
  12. package/dist_ts/data/gatewayarearows.js +1 -1
  13. package/dist_ts/data/gatewayareas.d.ts +19 -0
  14. package/dist_ts/data/gatewayareas.js +1 -1
  15. package/dist_ts/data/gatewayareas.validation.js +37 -5
  16. package/dist_ts/data/hetzner.d.ts +177 -0
  17. package/dist_ts/data/hetzner.js +253 -0
  18. package/dist_ts/data/index.d.ts +5 -0
  19. package/dist_ts/data/index.js +6 -1
  20. package/dist_ts/data/pathrouting.d.ts +170 -0
  21. package/dist_ts/data/pathrouting.js +227 -0
  22. package/dist_ts/requests/backupmx.d.ts +209 -0
  23. package/dist_ts/requests/backupmx.js +2 -0
  24. package/dist_ts/requests/certificateauthority.d.ts +118 -0
  25. package/dist_ts/requests/certificateauthority.js +2 -0
  26. package/dist_ts/requests/externaldns.d.ts +213 -0
  27. package/dist_ts/requests/externaldns.js +2 -0
  28. package/dist_ts/requests/hetzner.d.ts +216 -0
  29. package/dist_ts/requests/hetzner.js +2 -0
  30. package/dist_ts/requests/index.d.ts +6 -1
  31. package/dist_ts/requests/index.js +7 -2
  32. package/dist_ts/requests/pathrouting.d.ts +107 -0
  33. package/dist_ts/requests/pathrouting.js +2 -0
  34. package/package.json +47 -8
  35. package/ts/00_commitinfo_data.ts +1 -1
  36. package/ts/data/backupmx.ts +252 -0
  37. package/ts/data/certificateauthority.ts +115 -0
  38. package/ts/data/externaldns.ts +273 -0
  39. package/ts/data/gateway.ts +22 -0
  40. package/ts/data/gatewayarearows.ts +2 -0
  41. package/ts/data/gatewayareas.ts +20 -0
  42. package/ts/data/gatewayareas.validation.ts +40 -4
  43. package/ts/data/hetzner.ts +419 -0
  44. package/ts/data/index.ts +5 -0
  45. package/ts/data/pathrouting.ts +410 -0
  46. package/ts/requests/backupmx.ts +275 -0
  47. package/ts/requests/certificateauthority.ts +139 -0
  48. package/ts/requests/externaldns.ts +263 -0
  49. package/ts/requests/hetzner.ts +276 -0
  50. package/ts/requests/index.ts +10 -0
  51. package/ts/requests/pathrouting.ts +134 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serve.zone/interfaces",
3
- "version": "32.123.0",
3
+ "version": "32.125.0",
4
4
  "private": false,
5
5
  "description": "Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.",
6
6
  "exports": {
@@ -20,6 +20,22 @@
20
20
  "types": "./dist_ts/data/backup/index.d.ts",
21
21
  "default": "./dist_ts/data/backup/index.js"
22
22
  },
23
+ "./data/backupmx": {
24
+ "types": "./dist_ts/data/backupmx.d.ts",
25
+ "default": "./dist_ts/data/backupmx.js"
26
+ },
27
+ "./data/certificateauthority": {
28
+ "types": "./dist_ts/data/certificateauthority.d.ts",
29
+ "default": "./dist_ts/data/certificateauthority.js"
30
+ },
31
+ "./data/pathrouting": {
32
+ "types": "./dist_ts/data/pathrouting.d.ts",
33
+ "default": "./dist_ts/data/pathrouting.js"
34
+ },
35
+ "./data/hetzner": {
36
+ "types": "./dist_ts/data/hetzner.d.ts",
37
+ "default": "./dist_ts/data/hetzner.js"
38
+ },
23
39
  "./data/controlledtakeover": {
24
40
  "types": "./dist_ts/data/controlledtakeover.d.ts",
25
41
  "default": "./dist_ts/data/controlledtakeover.js"
@@ -44,6 +60,10 @@
44
60
  "types": "./dist_ts/data/diskencryption.d.ts",
45
61
  "default": "./dist_ts/data/diskencryption.js"
46
62
  },
63
+ "./data/externaldns": {
64
+ "types": "./dist_ts/data/externaldns.d.ts",
65
+ "default": "./dist_ts/data/externaldns.js"
66
+ },
47
67
  "./data/gateway": {
48
68
  "types": "./dist_ts/data/gateway.d.ts",
49
69
  "default": "./dist_ts/data/gateway.js"
@@ -80,6 +100,22 @@
80
100
  "types": "./dist_ts/requests/backup.d.ts",
81
101
  "default": "./dist_ts/requests/backup.js"
82
102
  },
103
+ "./requests/backupmx": {
104
+ "types": "./dist_ts/requests/backupmx.d.ts",
105
+ "default": "./dist_ts/requests/backupmx.js"
106
+ },
107
+ "./requests/certificateauthority": {
108
+ "types": "./dist_ts/requests/certificateauthority.d.ts",
109
+ "default": "./dist_ts/requests/certificateauthority.js"
110
+ },
111
+ "./requests/pathrouting": {
112
+ "types": "./dist_ts/requests/pathrouting.d.ts",
113
+ "default": "./dist_ts/requests/pathrouting.js"
114
+ },
115
+ "./requests/hetzner": {
116
+ "types": "./dist_ts/requests/hetzner.d.ts",
117
+ "default": "./dist_ts/requests/hetzner.js"
118
+ },
83
119
  "./requests/controlledtakeover": {
84
120
  "types": "./dist_ts/requests/controlledtakeover.d.ts",
85
121
  "default": "./dist_ts/requests/controlledtakeover.js"
@@ -108,6 +144,10 @@
108
144
  "types": "./dist_ts/requests/diskencryption.d.ts",
109
145
  "default": "./dist_ts/requests/diskencryption.js"
110
146
  },
147
+ "./requests/externaldns": {
148
+ "types": "./dist_ts/requests/externaldns.d.ts",
149
+ "default": "./dist_ts/requests/externaldns.js"
150
+ },
111
151
  "./requests/gateway": {
112
152
  "types": "./dist_ts/requests/gateway.d.ts",
113
153
  "default": "./dist_ts/requests/gateway.js"
@@ -148,11 +188,6 @@
148
188
  "type": "module",
149
189
  "author": "Task Venture Capital GmbH",
150
190
  "license": "MIT",
151
- "scripts": {
152
- "test": "tsrepo test test/ --verbose --logfile --timeout 60",
153
- "build": "tsrepo build tsfolders",
154
- "buildDocs": "tsrepo docs"
155
- },
156
191
  "dependencies": {
157
192
  "@api.global/typedrequest-interfaces": "^7.1.0",
158
193
  "@push.rocks/smartcrypto": "^3.0.0",
@@ -192,5 +227,9 @@
192
227
  "browserslist": [
193
228
  "last 1 chrome versions"
194
229
  ],
195
- "packageManager": "pnpm@12.21.0"
196
- }
230
+ "scripts": {
231
+ "test": "tsrepo test test/ --verbose --logfile --timeout 60",
232
+ "build": "tsrepo build tsfolders",
233
+ "buildDocs": "tsrepo docs"
234
+ }
235
+ }
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/interfaces',
6
- version: '32.122.0',
6
+ version: '32.125.0',
7
7
  description: 'Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.'
8
8
  }
@@ -0,0 +1,252 @@
1
+ import { compareWireTokens } from '../private/canonicaljson.js';
2
+ import { parseCanonicalIpAddress } from '../private/ipaddress.js';
3
+ import { validateManagedHetznerFqdn } from './hetzner.js';
4
+
5
+ export const backupMxContract = Object.freeze({
6
+ typedSocketPath: '/backupmx-socket',
7
+ defaultMxPriority: 30,
8
+ minimumMxPriority: 21,
9
+ maximumMxPriority: 65535,
10
+ maximumDomains: 1024,
11
+ maximumRecipientsPerDomain: 10_000,
12
+ maximumMessageSizeBytes: 50 * 1024 * 1024,
13
+ defaultMaxAgeMs: 5 * 24 * 60 * 60 * 1000,
14
+ defaultDsnMaxAgeMs: 2 * 24 * 60 * 60 * 1000,
15
+ defaultInitialRetryMs: 60_000,
16
+ defaultMaxRetryMs: 4 * 60 * 60 * 1000,
17
+ defaultScanIntervalMs: 15_000,
18
+ defaultMaxConcurrentDeliveries: 4,
19
+ maximumQueuePageLimit: 200,
20
+ credentialRandomBytes: 32,
21
+ } as const);
22
+
23
+ export const backupMxRefusals = Object.freeze([
24
+ 'request-invalid',
25
+ 'credential-invalid',
26
+ 'controller-mismatch',
27
+ 'controller-epoch-older',
28
+ 'config-epoch-stale',
29
+ 'instance-not-found',
30
+ 'instance-disconnected',
31
+ 'instance-queue-not-empty',
32
+ 'queue-item-not-found',
33
+ 'queue-item-not-dead',
34
+ ] as const);
35
+
36
+ export type TBackupMxRefusalCode = typeof backupMxRefusals[number];
37
+
38
+ export type TBackupMxRecipientPolicy =
39
+ | {
40
+ mode: 'allow-list';
41
+ /** Lowercase canonical `local@domain` addresses sorted ascending (`compareWireTokens`). */
42
+ recipients: string[];
43
+ }
44
+ | {
45
+ /** Reflects a Cloudly/DcRouter managed domain whose inbound policy is catch-all store. */
46
+ mode: 'domain-catchall';
47
+ };
48
+
49
+ export interface IBackupMxManagedDomain {
50
+ /** Lowercase ASCII FQDN of a Cloudly/DcRouter-managed mail domain. */
51
+ domain: string;
52
+ /** Hostnames belonging to this Backup MX (loop guard — MX >= self are excluded). */
53
+ selfMxHostnames: string[];
54
+ /** Canonical IPv4/IPv6 addresses belonging to this Backup MX (additional loop guard). */
55
+ selfMxIps: string[];
56
+ recipientPolicy: TBackupMxRecipientPolicy;
57
+ }
58
+
59
+ export interface IBackupMxQueuePolicy {
60
+ maxAgeMs: number;
61
+ dsnMaxAgeMs: number;
62
+ initialRetryMs: number;
63
+ maxRetryMs: number;
64
+ jitter: number;
65
+ scanIntervalMs: number;
66
+ maxConcurrentDeliveries: number;
67
+ maxMessageSizeBytes: number;
68
+ }
69
+
70
+ export interface IBackupMxInboundTls {
71
+ certificatePem: string;
72
+ privateKeyPem: string;
73
+ fingerprintSha256: string;
74
+ expiresAt: number;
75
+ }
76
+
77
+ /**
78
+ * Canonical desired-state snapshot pushed by Cloudly to a Backup MX daemon over TypedSocket.
79
+ * Persisted locally on the Backup MX host so restarts during a Cloudly outage remain autonomous.
80
+ */
81
+ export interface IBackupMxDesiredState {
82
+ configEpoch: number;
83
+ hostname: string;
84
+ listenPorts: number[];
85
+ domains: IBackupMxManagedDomain[];
86
+ queuePolicy: IBackupMxQueuePolicy;
87
+ inboundTls: IBackupMxInboundTls | null;
88
+ }
89
+
90
+ export interface IBackupMxDomainStatus {
91
+ domain: string;
92
+ pendingCount: number;
93
+ deadCount: number;
94
+ circuitBlockedUntil: number | null;
95
+ lastDeliveredAt: number | null;
96
+ lastError: string | null;
97
+ }
98
+
99
+ export interface IBackupMxStatus {
100
+ instanceId: string;
101
+ hostname: string;
102
+ version: string;
103
+ bridgeState: string;
104
+ appliedConfigEpoch: number;
105
+ checkedAt: number;
106
+ queue: {
107
+ pending: number;
108
+ dead: number;
109
+ };
110
+ counters: {
111
+ acceptedTotal: number;
112
+ deliveredTotal: number;
113
+ retriedTotal: number;
114
+ permanentlyFailedTotal: number;
115
+ rejectedRecipientsTotal: number;
116
+ deliveryAttemptsTotal: number;
117
+ };
118
+ tlsCertificate: {
119
+ configured: boolean;
120
+ fingerprintSha256: string | null;
121
+ expiresAt: number | null;
122
+ };
123
+ domains: IBackupMxDomainStatus[];
124
+ }
125
+
126
+ export interface IBackupMxQueueItemSummary {
127
+ id: string;
128
+ queue: 'pending' | 'dead';
129
+ kind: 'relay' | 'dsn';
130
+ destinationDomain: string;
131
+ envelopeFrom: string;
132
+ recipients: string[];
133
+ sizeBytes: number;
134
+ createdAt: number;
135
+ attempts: number;
136
+ nextAttemptAt: number;
137
+ deadlineAt: number;
138
+ lastAttemptAt: number | null;
139
+ lastError: string | null;
140
+ deadAt: number | null;
141
+ }
142
+
143
+ export interface IBackupMxInstance {
144
+ id: string;
145
+ name: string;
146
+ hostname: string;
147
+ mxPriority: number;
148
+ ipv4: string | null;
149
+ ipv6: string | null;
150
+ hetznerHostId: string | null;
151
+ enabled: boolean;
152
+ connected: boolean;
153
+ desiredConfigEpoch: number;
154
+ appliedConfigEpoch: number;
155
+ /** Managed domain names currently assigned to this Backup MX. */
156
+ managedDomains: string[];
157
+ observedStatus: IBackupMxStatus | null;
158
+ lastConnectedAt: number | null;
159
+ createdAt: number;
160
+ updatedAt: number;
161
+ }
162
+
163
+ export function validateBackupMxHostname(hostnameArg: string): boolean {
164
+ return validateManagedHetznerFqdn(hostnameArg);
165
+ }
166
+
167
+ export function validateBackupMxDesiredState(stateArg: IBackupMxDesiredState): string[] {
168
+ const errors: string[] = [];
169
+ if (!Number.isSafeInteger(stateArg.configEpoch) || stateArg.configEpoch < 1) {
170
+ errors.push('configEpoch must be a positive safe integer');
171
+ }
172
+ if (!validateBackupMxHostname(stateArg.hostname)) {
173
+ errors.push('hostname must be a lowercase FQDN');
174
+ }
175
+ if (!Array.isArray(stateArg.listenPorts) || stateArg.listenPorts.length === 0) {
176
+ errors.push('listenPorts must be a non-empty array of valid ports');
177
+ } else {
178
+ for (const port of stateArg.listenPorts) {
179
+ if (!Number.isSafeInteger(port) || port < 1 || port > 65535) {
180
+ errors.push(`invalid listenPort: ${port}`);
181
+ }
182
+ }
183
+ }
184
+ if (!Array.isArray(stateArg.domains) || stateArg.domains.length > backupMxContract.maximumDomains) {
185
+ errors.push(`domains must be an array of at most ${backupMxContract.maximumDomains} entries`);
186
+ } else {
187
+ let prevDomain: string | null = null;
188
+ for (const entry of stateArg.domains) {
189
+ if (!validateBackupMxHostname(entry.domain)) {
190
+ errors.push(`invalid domain: ${entry.domain}`);
191
+ }
192
+ if (prevDomain !== null && compareWireTokens(prevDomain, entry.domain) >= 0) {
193
+ errors.push(`domains must be strictly ascending: ${entry.domain}`);
194
+ }
195
+ prevDomain = entry.domain;
196
+
197
+ if (!Array.isArray(entry.selfMxHostnames) || !entry.selfMxHostnames.includes(stateArg.hostname)) {
198
+ errors.push(`domain ${entry.domain} selfMxHostnames must include ${stateArg.hostname}`);
199
+ }
200
+ for (const ip of entry.selfMxIps) {
201
+ if (!parseCanonicalIpAddress(ip)) {
202
+ errors.push(`domain ${entry.domain} has non-canonical selfMxIp: ${ip}`);
203
+ }
204
+ }
205
+ if (entry.recipientPolicy.mode === 'allow-list') {
206
+ if (entry.recipientPolicy.recipients.length > backupMxContract.maximumRecipientsPerDomain) {
207
+ errors.push(`domain ${entry.domain} exceeds recipient allow-list limit`);
208
+ }
209
+ let prevRcpt: string | null = null;
210
+ for (const rcpt of entry.recipientPolicy.recipients) {
211
+ const at = rcpt.lastIndexOf('@');
212
+ if (at <= 0 || rcpt.slice(at + 1) !== entry.domain || rcpt !== rcpt.toLowerCase()) {
213
+ errors.push(`domain ${entry.domain} invalid recipient in allow-list: ${rcpt}`);
214
+ }
215
+ if (prevRcpt !== null && compareWireTokens(prevRcpt, rcpt) >= 0) {
216
+ errors.push(`domain ${entry.domain} recipients must be strictly ascending`);
217
+ }
218
+ prevRcpt = rcpt;
219
+ }
220
+ } else if (entry.recipientPolicy.mode !== 'domain-catchall') {
221
+ errors.push(`domain ${entry.domain} has invalid recipientPolicy mode`);
222
+ }
223
+ }
224
+ }
225
+
226
+ const qp = stateArg.queuePolicy;
227
+ if (!qp || typeof qp !== 'object') {
228
+ errors.push('queuePolicy is required');
229
+ } else {
230
+ if (!Number.isSafeInteger(qp.maxAgeMs) || qp.maxAgeMs < 60_000) errors.push('invalid queuePolicy.maxAgeMs');
231
+ if (!Number.isSafeInteger(qp.dsnMaxAgeMs) || qp.dsnMaxAgeMs < 60_000) errors.push('invalid queuePolicy.dsnMaxAgeMs');
232
+ if (!Number.isSafeInteger(qp.initialRetryMs) || qp.initialRetryMs < 1_000) errors.push('invalid queuePolicy.initialRetryMs');
233
+ if (!Number.isSafeInteger(qp.maxRetryMs) || qp.maxRetryMs < qp.initialRetryMs) errors.push('invalid queuePolicy.maxRetryMs');
234
+ if (typeof qp.jitter !== 'number' || !Number.isFinite(qp.jitter) || qp.jitter < 0 || qp.jitter > 0.5) errors.push('invalid queuePolicy.jitter');
235
+ if (!Number.isSafeInteger(qp.scanIntervalMs) || qp.scanIntervalMs < 1_000) errors.push('invalid queuePolicy.scanIntervalMs');
236
+ if (!Number.isSafeInteger(qp.maxConcurrentDeliveries) || qp.maxConcurrentDeliveries < 1 || qp.maxConcurrentDeliveries > 64) {
237
+ errors.push('invalid queuePolicy.maxConcurrentDeliveries');
238
+ }
239
+ if (!Number.isSafeInteger(qp.maxMessageSizeBytes) || qp.maxMessageSizeBytes < 1024 || qp.maxMessageSizeBytes > backupMxContract.maximumMessageSizeBytes) {
240
+ errors.push('invalid queuePolicy.maxMessageSizeBytes');
241
+ }
242
+ }
243
+
244
+ if (stateArg.inboundTls !== null) {
245
+ if (!stateArg.inboundTls.certificatePem.includes('BEGIN CERTIFICATE')
246
+ || !stateArg.inboundTls.privateKeyPem.includes('BEGIN ')) {
247
+ errors.push('inboundTls must contain PEM certificate and private key');
248
+ }
249
+ }
250
+
251
+ return errors;
252
+ }
@@ -0,0 +1,115 @@
1
+ export const cloudlyCertificateSources = Object.freeze([
2
+ 'acme',
3
+ 'imported',
4
+ 'gateway-migrated',
5
+ ] as const);
6
+
7
+ export type TCloudlyCertificateSource = typeof cloudlyCertificateSources[number];
8
+
9
+ export const cloudlyCertificateRefusalCodes = Object.freeze([
10
+ 'administrator-required',
11
+ 'fresh-sign-in-required',
12
+ 'invalid-request',
13
+ 'acme-not-configured',
14
+ 'certificate-not-found',
15
+ 'zone-not-found',
16
+ 'issuance-failed',
17
+ 'invalid-certificate-material',
18
+ 'gateway-unavailable',
19
+ ] as const);
20
+
21
+ export type TCloudlyCertificateRefusalCode = typeof cloudlyCertificateRefusalCodes[number];
22
+
23
+ export const cloudlyCertificateContract = Object.freeze({
24
+ defaultRenewBeforeDays: 30,
25
+ minimumRenewBeforeDays: 1,
26
+ maximumRenewBeforeDays: 60,
27
+ maximumAltNames: 100,
28
+ maximumBundleCertificates: 500,
29
+ acmeChallengePrefix: '_acme-challenge.',
30
+ acmeChallengeTtlSeconds: 60,
31
+ } as const);
32
+
33
+ export interface ICloudlyAcmeConfig {
34
+ enabled: boolean;
35
+ accountEmail: string;
36
+ useProduction: boolean;
37
+ directoryUrl: string | null;
38
+ renewBeforeDays: number;
39
+ accountRegisteredAt: number | null;
40
+ updatedAt: number;
41
+ }
42
+
43
+ /** Public certificate metadata returned to operators (never carries private key PEM). */
44
+ export interface ICloudlyCertificateSummary {
45
+ id: string;
46
+ domain: string;
47
+ altNames: string[];
48
+ issuer: string;
49
+ serialNumber: string;
50
+ fingerprintSha256: string;
51
+ validFrom: number;
52
+ validUntil: number;
53
+ source: TCloudlyCertificateSource;
54
+ autoRenew: boolean;
55
+ lastPushedRevision: number;
56
+ createdAt: number;
57
+ updatedAt: number;
58
+ }
59
+
60
+ /**
61
+ * Leaf certificate + private key bundle pushed exclusively from Cloudly to authenticated
62
+ * adopted dcrouter gateways over TypedSocket when `certificates.controllerPushed === true`.
63
+ */
64
+ export interface ICloudlyCertificateBundleItem {
65
+ domain: string;
66
+ altNames: string[];
67
+ certPem: string;
68
+ keyPem: string;
69
+ caPem: string | null;
70
+ validFrom: number;
71
+ validUntil: number;
72
+ fingerprintSha256: string;
73
+ }
74
+
75
+ const certLabelPattern = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
76
+
77
+ export const normalizeCertificateDomain = (domainArg: unknown): string | null => {
78
+ if (typeof domainArg !== 'string') return null;
79
+ const trimmed = domainArg.trim().toLowerCase().replace(/\.+$/, '');
80
+ if (trimmed.length === 0 || trimmed.length > 253) return null;
81
+ const labels = trimmed.split('.');
82
+ if (labels.length < 2) return null;
83
+ const [first, ...rest] = labels;
84
+ if (first === '*') {
85
+ if (rest.length < 2) return null;
86
+ return rest.every((label) => certLabelPattern.test(label)) ? trimmed : null;
87
+ }
88
+ return labels.every((label) => certLabelPattern.test(label)) ? trimmed : null;
89
+ };
90
+
91
+ /**
92
+ * RFC 6125 single-label wildcard & exact hostname matching for certificate lookup.
93
+ */
94
+ export const certificateMatchesHostname = (
95
+ certDomainArg: string,
96
+ altNamesArg: readonly string[],
97
+ hostnameArg: string,
98
+ ): boolean => {
99
+ const host = normalizeCertificateDomain(hostnameArg);
100
+ if (!host || host.startsWith('*.')) return false;
101
+ const candidates = [certDomainArg, ...altNamesArg];
102
+ for (const raw of candidates) {
103
+ const pattern = normalizeCertificateDomain(raw);
104
+ if (!pattern) continue;
105
+ if (pattern === host) return true;
106
+ if (pattern.startsWith('*.')) {
107
+ const suffix = pattern.slice(2);
108
+ if (host.endsWith(`.${suffix}`)) {
109
+ const prefix = host.slice(0, host.length - suffix.length - 1);
110
+ if (prefix.length > 0 && !prefix.includes('.')) return true;
111
+ }
112
+ }
113
+ }
114
+ return false;
115
+ };