@helyx/bot 0.4.31 → 0.4.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/CHANGELOG.md +22 -0
- package/dist/control-permissions.d.ts +38 -0
- package/dist/control-permissions.js +139 -0
- package/dist/control-server.d.ts +24 -16
- package/dist/control-server.js +149 -166
- package/dist/discord-guild-health.d.ts +174 -0
- package/dist/discord-guild-health.js +370 -0
- package/dist/events.d.ts +15 -0
- package/dist/events.js +338 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -7
- package/dist/interactions.js +36 -6
- package/dist/modules.d.ts +2 -0
- package/dist/modules.js +10 -1
- package/dist/oauth-module.d.ts +2 -0
- package/dist/oauth-module.js +196 -0
- package/dist/oauth-module.test.d.ts +2 -0
- package/dist/oauth-module.test.js +172 -0
- package/dist/oauth-service.d.ts +16 -0
- package/dist/oauth-service.js +40 -0
- package/dist/shard-contracts.d.ts +42 -0
- package/dist/shard-contracts.js +26 -0
- package/dist/shard-router.d.ts +1 -0
- package/dist/shard-router.js +3 -0
- package/dist/shard-supervisor.js +29 -3
- package/dist/shard-worker.d.ts +5 -0
- package/dist/shard-worker.js +16 -1
- package/package.json +1 -1
package/dist/shard-supervisor.js
CHANGED
|
@@ -22,6 +22,7 @@ import { ShardControlRouter } from "./shard-router.js";
|
|
|
22
22
|
import { createDeveloperOperationsModule } from "./developer-operations-module.js";
|
|
23
23
|
import { SupervisorCloudDiscordDirectory } from "./supervisor-cloud-directory.js";
|
|
24
24
|
import { createSupportModule } from "./support-module.js";
|
|
25
|
+
import { createOAuthModule } from "./oauth-module.js";
|
|
25
26
|
import { createScheduledTaskRunner, schedulerOperationalHealth, } from "./scheduled-task-runner.js";
|
|
26
27
|
import { numericWriteBehindRegistrations } from "./numeric-write-behind.js";
|
|
27
28
|
import { executeRedisNumericOperation, RedisNumericWriteBehindService, } from "./numeric-write-behind-redis.js";
|
|
@@ -187,10 +188,14 @@ export async function startShardSupervisor(environment, processEnvironment, work
|
|
|
187
188
|
})
|
|
188
189
|
: undefined;
|
|
189
190
|
const supportModule = createSupportModule(cloudConnector);
|
|
191
|
+
const oauthModule = environment.HELYX_OAUTH_ENABLED
|
|
192
|
+
? createOAuthModule()
|
|
193
|
+
: undefined;
|
|
190
194
|
const publicModules = [
|
|
191
195
|
managementModule,
|
|
192
196
|
permissionsModule,
|
|
193
197
|
supportModule,
|
|
198
|
+
...(oauthModule ? [oauthModule] : []),
|
|
194
199
|
...(cloudManagementModule ? [cloudManagementModule] : []),
|
|
195
200
|
...featureModules,
|
|
196
201
|
];
|
|
@@ -210,6 +215,7 @@ export async function startShardSupervisor(environment, processEnvironment, work
|
|
|
210
215
|
managementModule,
|
|
211
216
|
permissionsModule,
|
|
212
217
|
supportModule,
|
|
218
|
+
...(oauthModule ? [oauthModule] : []),
|
|
213
219
|
...(cloudManagementModule ? [cloudManagementModule] : []),
|
|
214
220
|
].map(({ manifest }) => manifest),
|
|
215
221
|
modules: featureModules.map(({ manifest }) => manifest),
|
|
@@ -645,7 +651,22 @@ export async function startShardSupervisor(environment, processEnvironment, work
|
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
653
|
assertShardMessageSize(response);
|
|
648
|
-
await
|
|
654
|
+
await sendWorkerResponse(shardId, response);
|
|
655
|
+
}
|
|
656
|
+
async function sendWorkerResponse(shardId, response) {
|
|
657
|
+
if (shuttingDown)
|
|
658
|
+
return;
|
|
659
|
+
const worker = workers.get(shardId);
|
|
660
|
+
if (!worker?.process)
|
|
661
|
+
return;
|
|
662
|
+
try {
|
|
663
|
+
await worker.send(response);
|
|
664
|
+
}
|
|
665
|
+
catch (error) {
|
|
666
|
+
if (shuttingDown || !worker.process)
|
|
667
|
+
return;
|
|
668
|
+
throw error;
|
|
669
|
+
}
|
|
649
670
|
}
|
|
650
671
|
async function handleWorkerMessage(shardId, raw) {
|
|
651
672
|
if (serializedBytes(raw) > SHARD_CONTROL_MAX_BYTES)
|
|
@@ -703,7 +724,7 @@ export async function startShardSupervisor(environment, processEnvironment, work
|
|
|
703
724
|
const response = leaderLease
|
|
704
725
|
? await executeLeaderCloud(message.data)
|
|
705
726
|
: await routeCloudToLeader(message.data);
|
|
706
|
-
await
|
|
727
|
+
await sendWorkerResponse(shardId, response);
|
|
707
728
|
return;
|
|
708
729
|
}
|
|
709
730
|
if (message.data.type === "helyx.operations.health.request") {
|
|
@@ -714,7 +735,7 @@ export async function startShardSupervisor(environment, processEnvironment, work
|
|
|
714
735
|
health: boundedOperationalHealth(await buildHealth()),
|
|
715
736
|
};
|
|
716
737
|
assertShardMessageSize(response);
|
|
717
|
-
await
|
|
738
|
+
await sendWorkerResponse(shardId, response);
|
|
718
739
|
}
|
|
719
740
|
}
|
|
720
741
|
function dispatchLocal(shardId, request) {
|
|
@@ -1386,9 +1407,14 @@ export function buildShardWorkerEnvironment(source, identity, restartCount) {
|
|
|
1386
1407
|
"HELYX_SUPPORT_STAFF_CHANNEL_ID",
|
|
1387
1408
|
"HELYX_MODULE_PACKAGES",
|
|
1388
1409
|
"HELYX_MESSAGE_CONTENT_ENABLED",
|
|
1410
|
+
"HELYX_GUILD_MEMBERS_ENABLED",
|
|
1411
|
+
"HELYX_GUILD_RECONCILIATION_INTERVAL_SECONDS",
|
|
1389
1412
|
"HELYX_MODULE_CATALOGUE_PATH",
|
|
1390
1413
|
"HELYX_CLOUD_CONNECT_ENABLED",
|
|
1414
|
+
"HELYX_CLOUD_API_URL",
|
|
1391
1415
|
"HELYX_OWNER_USER_IDS",
|
|
1416
|
+
"HELYX_OAUTH_ENABLED",
|
|
1417
|
+
"HELYX_OAUTH_INTERNAL_SECRET",
|
|
1392
1418
|
"HELYX_VERIFICATION_ENABLED",
|
|
1393
1419
|
"HELYX_VERIFICATION_INSTALLATION_ID",
|
|
1394
1420
|
"HELYX_VERIFICATION_URL",
|
package/dist/shard-worker.d.ts
CHANGED
|
@@ -34,6 +34,7 @@ export declare function parseShardWorkerEnvironment(processEnvironment: NodeJS.P
|
|
|
34
34
|
APPROVED_ROLES: string[];
|
|
35
35
|
HELYX_MODULE_PACKAGES: string[];
|
|
36
36
|
HELYX_MODULE_CATALOGUE_PATH: string | undefined;
|
|
37
|
+
HELYX_DASHBOARD_PUBLIC_URL: string;
|
|
37
38
|
HELYX_SUPPORT_STAFF_CHANNEL_ID: string | undefined;
|
|
38
39
|
HELYX_VERIFICATION_ENABLED: boolean;
|
|
39
40
|
HELYX_VERIFICATION_SIGNING_PUBLIC_KEYS: Record<string, string>;
|
|
@@ -41,10 +42,12 @@ export declare function parseShardWorkerEnvironment(processEnvironment: NodeJS.P
|
|
|
41
42
|
HELYX_GUILD_RECONCILIATION_INTERVAL_SECONDS: number;
|
|
42
43
|
HELYX_PRIVACY_ENABLED: boolean;
|
|
43
44
|
HELYX_MESSAGE_CONTENT_ENABLED: boolean;
|
|
45
|
+
HELYX_GUILD_MEMBERS_ENABLED: boolean;
|
|
44
46
|
HELYX_CLOUD_CONNECT_ENABLED: boolean;
|
|
45
47
|
HELYX_CLOUD_ENROLMENT_TOKEN: string | undefined;
|
|
46
48
|
HELYX_CLOUD_ENROLMENT_FILE: string;
|
|
47
49
|
HELYX_CLOUD_API_URL: string;
|
|
50
|
+
HELYX_OAUTH_ENABLED: boolean;
|
|
48
51
|
HELYX_CLOUD_ENDPOINT: string;
|
|
49
52
|
HELYX_OWNER_USER_IDS: string[];
|
|
50
53
|
HELYX_SHARD_MODE: "off" | "auto" | "fixed";
|
|
@@ -60,6 +63,7 @@ export declare function parseShardWorkerEnvironment(processEnvironment: NodeJS.P
|
|
|
60
63
|
HELYX_VERIFICATION_INTERNAL_SECRET?: string | undefined;
|
|
61
64
|
HELYX_PRIVACY_EXECUTOR_DATABASE_URL?: string | undefined;
|
|
62
65
|
HELYX_PRIVACY_EXECUTOR_DATABASE_SSL?: "disable" | "require" | "verify-full" | undefined;
|
|
66
|
+
HELYX_OAUTH_INTERNAL_SECRET?: string | undefined;
|
|
63
67
|
HELYX_SHARD_COUNT?: number | undefined;
|
|
64
68
|
HELYX_SHARD_REDIS_URL?: string | undefined;
|
|
65
69
|
HELYX_SHARD_REDIS_NAMESPACE?: string | undefined;
|
|
@@ -71,5 +75,6 @@ export declare function shardWorkerCommandRegistration(input: {
|
|
|
71
75
|
prepare: NonNullable<CommandRegistration["prepare"]>;
|
|
72
76
|
operationsModuleId?: string;
|
|
73
77
|
supportModuleId: string;
|
|
78
|
+
oauthModuleId?: string;
|
|
74
79
|
}): CommandRegistration;
|
|
75
80
|
//# sourceMappingURL=shard-worker.d.ts.map
|
package/dist/shard-worker.js
CHANGED
|
@@ -20,11 +20,14 @@ import { loadConfiguredModulePackages, platformServiceOptions, secureRandomSelec
|
|
|
20
20
|
import { createPermissionsModule } from "./permissions-module.js";
|
|
21
21
|
import { WorkerCloudConnectorProxy } from "./shard-cloud-proxy.js";
|
|
22
22
|
import { DiscordOwnedMessageDeletionService } from "./discord-owned-message-service.js";
|
|
23
|
+
import { DiscordGuildHealthInspection } from "./discord-guild-health.js";
|
|
23
24
|
import { CoreResourceAuthorizationService } from "./resource-authorization.js";
|
|
24
25
|
import { createDeveloperOperationsModule, WorkerShardHealthProvider, } from "./developer-operations-module.js";
|
|
25
26
|
import { assertShardMessageSize, controlOperationGuildId, executeShardControlOperation, guildIdToShardId, SHARD_LEASE_HEARTBEAT_TIMEOUT_MS, shardIdentitySchema, supervisorMessageSchema, } from "./shard-contracts.js";
|
|
26
27
|
import { gatewayIntentsForModules, readBotVersion, } from "./index.js";
|
|
27
28
|
import { createSupportModule } from "./support-module.js";
|
|
29
|
+
import { createOAuthModule } from "./oauth-module.js";
|
|
30
|
+
import { HttpOAuthService } from "./oauth-service.js";
|
|
28
31
|
import { createLocalScheduledTaskRoute, } from "./scheduled-task-runner.js";
|
|
29
32
|
import { createLocalNumericWriteBehind } from "./numeric-write-behind.js";
|
|
30
33
|
import { WorkerNumericWriteBehindProxy } from "./numeric-write-behind-proxy.js";
|
|
@@ -111,7 +114,7 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
111
114
|
const modulePackages = await loadConfiguredModulePackages(moduleSpecifiers);
|
|
112
115
|
const featureModules = modulePackages.map(({ definition }) => definition);
|
|
113
116
|
client = new Client({
|
|
114
|
-
intents: gatewayIntentsForModules(featureModules, environment.HELYX_MESSAGE_CONTENT_ENABLED),
|
|
117
|
+
intents: gatewayIntentsForModules(featureModules, environment.HELYX_MESSAGE_CONTENT_ENABLED, environment.HELYX_GUILD_MEMBERS_ENABLED),
|
|
115
118
|
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
|
|
116
119
|
allowedMentions: { parse: [] },
|
|
117
120
|
shards: [identity.shardId],
|
|
@@ -130,10 +133,14 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
130
133
|
})
|
|
131
134
|
: undefined;
|
|
132
135
|
const supportModule = createSupportModule(cloudProxy);
|
|
136
|
+
const oauthModule = environment.HELYX_OAUTH_ENABLED
|
|
137
|
+
? createOAuthModule()
|
|
138
|
+
: undefined;
|
|
133
139
|
const publicModules = [
|
|
134
140
|
managementModule,
|
|
135
141
|
permissionsModule,
|
|
136
142
|
supportModule,
|
|
143
|
+
...(oauthModule ? [oauthModule] : []),
|
|
137
144
|
...(cloudManagementModule ? [cloudManagementModule] : []),
|
|
138
145
|
...featureModules,
|
|
139
146
|
];
|
|
@@ -152,6 +159,7 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
152
159
|
managementModule,
|
|
153
160
|
permissionsModule,
|
|
154
161
|
supportModule,
|
|
162
|
+
...(oauthModule ? [oauthModule] : []),
|
|
155
163
|
...(cloudManagementModule ? [cloudManagementModule] : []),
|
|
156
164
|
].map(({ manifest }) => manifest),
|
|
157
165
|
modules: featureModules.map(({ manifest }) => manifest),
|
|
@@ -182,6 +190,9 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
182
190
|
}));
|
|
183
191
|
platformServices.set(HELYX_SERVICE_NAMES.verificationMembers, new DiscordVerificationMemberService(client));
|
|
184
192
|
}
|
|
193
|
+
if (environment.HELYX_OAUTH_ENABLED &&
|
|
194
|
+
environment.HELYX_OAUTH_INTERNAL_SECRET)
|
|
195
|
+
platformServices.set(HELYX_SERVICE_NAMES.oauth, new HttpOAuthService(environment.HELYX_CLOUD_API_URL, environment.HELYX_OAUTH_INTERNAL_SECRET));
|
|
185
196
|
numericWriteBehind =
|
|
186
197
|
identity.scope === "coordinated"
|
|
187
198
|
? new WorkerNumericWriteBehindProxy(identity)
|
|
@@ -193,6 +204,7 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
193
204
|
platformServices.set(HELYX_SERVICE_NAMES.memberEnforcement, new DiscordMemberEnforcementService(client));
|
|
194
205
|
platformServices.set(HELYX_SERVICE_NAMES.memberRoles, new DiscordMemberRoleService(client));
|
|
195
206
|
platformServices.set(HELYX_SERVICE_NAMES.discordResources, new DiscordResourceInspection(client));
|
|
207
|
+
platformServices.set(HELYX_SERVICE_NAMES.discordGuildHealth, new DiscordGuildHealthInspection(client, publicModules, serviceAccess));
|
|
196
208
|
if (featureModules.some(({ manifest }) => manifest.id === "helyx.logging"))
|
|
197
209
|
platformServices.set(HELYX_SERVICE_NAMES.moduleLogging, new DiscordModuleLoggingService(client, database, publicModules, logger));
|
|
198
210
|
const scheduledTaskRoute = createLocalScheduledTaskRoute({
|
|
@@ -205,6 +217,7 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
205
217
|
managementModule.manifest.id,
|
|
206
218
|
permissionsModule.manifest.id,
|
|
207
219
|
supportModule.manifest.id,
|
|
220
|
+
...(oauthModule ? [oauthModule.manifest.id] : []),
|
|
208
221
|
...(cloudManagementModule ? [cloudManagementModule.manifest.id] : []),
|
|
209
222
|
...(operationsModule ? [operationsModule.manifest.id] : []),
|
|
210
223
|
]);
|
|
@@ -226,6 +239,7 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
226
239
|
? { operationsModuleId: operationsModule.manifest.id }
|
|
227
240
|
: {}),
|
|
228
241
|
supportModuleId: supportModule.manifest.id,
|
|
242
|
+
...(oauthModule ? { oauthModuleId: oauthModule.manifest.id } : {}),
|
|
229
243
|
}), logger, serviceAccess);
|
|
230
244
|
moduleEvents = installModuleEvents(client, publicModules, logger, serviceAccess);
|
|
231
245
|
const controlService = new BotControlService(database, publicModules, guildResources, serviceAccess, undefined, environment.DISCORD_INTERNAL_GUILD_ID &&
|
|
@@ -419,6 +433,7 @@ export function shardWorkerCommandRegistration(input) {
|
|
|
419
433
|
synchronise: false,
|
|
420
434
|
selfAuthorizingGuildModuleIds: new Set([
|
|
421
435
|
input.supportModuleId,
|
|
436
|
+
...(input.oauthModuleId ? [input.oauthModuleId] : []),
|
|
422
437
|
...(input.operationsModuleId ? [input.operationsModuleId] : []),
|
|
423
438
|
]),
|
|
424
439
|
};
|