@helyx/bot 1.5.1 → 1.5.2
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 +9 -0
- package/dist/creator-invite-key.d.ts +6 -0
- package/dist/creator-invite-key.js +16 -0
- package/dist/creator-invite-service.d.ts +3 -1
- package/dist/creator-invite-service.js +8 -7
- package/dist/creator-onboarding-platform.d.ts +1 -0
- package/dist/creator-onboarding-platform.js +5 -2
- package/dist/shard-supervisor.js +7 -0
- package/dist/shard-worker.d.ts +1 -0
- package/dist/shard-worker.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Supply hosted shard workers with the purpose-derived Creator invite key instead
|
|
8
|
+
of requiring the application-wide data encryption key in those workers. Preserve
|
|
9
|
+
existing v1 invite ciphertext and fingerprints, and keep startup fail-closed
|
|
10
|
+
when the required scoped key is absent or invalid.
|
|
11
|
+
|
|
3
12
|
## 1.5.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Internal launch material, never the application-wide data encryption key. */
|
|
2
|
+
export declare const creatorInviteWorkerKeyName = "HELYX_INTERNAL_CREATOR_INVITE_KEY";
|
|
3
|
+
export declare function decodeCreatorInviteKey(encodedKey: string): Buffer;
|
|
4
|
+
/** Keep the existing v1 derivation: old ciphertext and fingerprints stay valid. */
|
|
5
|
+
export declare function deriveCreatorInviteKey(encodedDataEncryptionKey: string): Buffer;
|
|
6
|
+
//# sourceMappingURL=creator-invite-key.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
/** Internal launch material, never the application-wide data encryption key. */
|
|
3
|
+
export const creatorInviteWorkerKeyName = "HELYX_INTERNAL_CREATOR_INVITE_KEY";
|
|
4
|
+
export function decodeCreatorInviteKey(encodedKey) {
|
|
5
|
+
const key = Buffer.from(encodedKey, "base64");
|
|
6
|
+
if (key.length !== 32)
|
|
7
|
+
throw new Error("Creator invites require a 32-byte encryption key");
|
|
8
|
+
return key;
|
|
9
|
+
}
|
|
10
|
+
/** Keep the existing v1 derivation: old ciphertext and fingerprints stay valid. */
|
|
11
|
+
export function deriveCreatorInviteKey(encodedDataEncryptionKey) {
|
|
12
|
+
return createHmac("sha256", decodeCreatorInviteKey(encodedDataEncryptionKey))
|
|
13
|
+
.update("helyx.creator-owned-invites.v1")
|
|
14
|
+
.digest();
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=creator-invite-key.js.map
|
|
@@ -8,7 +8,9 @@ export declare class DiscordCreatorInviteService implements CreatorInviteService
|
|
|
8
8
|
private readonly repository;
|
|
9
9
|
private readonly services;
|
|
10
10
|
private readonly module;
|
|
11
|
-
constructor(client: Client, repository: CreatorInviteRepository, services: ServiceAccess, module: ModuleDefinition | undefined,
|
|
11
|
+
constructor(client: Client, repository: CreatorInviteRepository, services: ServiceAccess, module: ModuleDefinition | undefined, encryption: string | {
|
|
12
|
+
inviteEncryptionKey: string;
|
|
13
|
+
});
|
|
12
14
|
selectableRoles(input: Parameters<CreatorInviteService["selectableRoles"]>[0]): ReturnType<CreatorInviteService["selectableRoles"]>;
|
|
13
15
|
create(input: Parameters<CreatorInviteService["create"]>[0]): Promise<CreatorOwnedInvite>;
|
|
14
16
|
inspect(input: Parameters<CreatorInviteService["inspect"]>[0]): Promise<CreatorOwnedInvite>;
|
|
@@ -5,6 +5,7 @@ import { createCipheriv, createDecipheriv, createHmac, createHash, randomBytes,
|
|
|
5
5
|
import { normalizeDiscordPermission } from "./interactions.js";
|
|
6
6
|
import { canAccessModule } from "./premium-access.js";
|
|
7
7
|
import { discordRestOptions } from "./discord-rest.js";
|
|
8
|
+
import { decodeCreatorInviteKey, deriveCreatorInviteKey, } from "./creator-invite-key.js";
|
|
8
9
|
const MODULE_ID = "helyx.creator-connections";
|
|
9
10
|
const snowflake = /^\d{17,20}$/u;
|
|
10
11
|
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
@@ -18,17 +19,17 @@ export class DiscordCreatorInviteService {
|
|
|
18
19
|
#key;
|
|
19
20
|
#rest = null;
|
|
20
21
|
#cleanupCursor;
|
|
21
|
-
constructor(client, repository, services, module,
|
|
22
|
+
constructor(client, repository, services, module, encryption) {
|
|
22
23
|
this.client = client;
|
|
23
24
|
this.repository = repository;
|
|
24
25
|
this.services = services;
|
|
25
26
|
this.module = module;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
// Unsharded runtimes derive locally; workers receive only this scoped key.
|
|
28
|
+
// Do not derive again in workers: existing v1 records use this exact key.
|
|
29
|
+
this.#key =
|
|
30
|
+
typeof encryption === "string"
|
|
31
|
+
? deriveCreatorInviteKey(encryption)
|
|
32
|
+
: decodeCreatorInviteKey(encryption.inviteEncryptionKey);
|
|
32
33
|
}
|
|
33
34
|
async selectableRoles(input) {
|
|
34
35
|
validateId(input.guildId);
|
|
@@ -8,9 +8,12 @@ export async function installCreatorInvitePlatform(input) {
|
|
|
8
8
|
const repository = new CreatorInviteRepository(input.database);
|
|
9
9
|
if (!module && !(await repository.isInstalled()))
|
|
10
10
|
return undefined;
|
|
11
|
-
|
|
11
|
+
const encryption = input.inviteEncryptionKey
|
|
12
|
+
? { inviteEncryptionKey: input.inviteEncryptionKey }
|
|
13
|
+
: input.encryptionKey;
|
|
14
|
+
if (!encryption)
|
|
12
15
|
throw new Error("Hosted Creator Connections invites require HELYX_DATA_ENCRYPTION_KEY");
|
|
13
|
-
const service = new DiscordCreatorInviteService(input.client, repository, input.services, module,
|
|
16
|
+
const service = new DiscordCreatorInviteService(input.client, repository, input.services, module, encryption);
|
|
14
17
|
input.register(HELYX_SERVICE_NAMES.creatorInvites, service);
|
|
15
18
|
if (input.oauthBroker) {
|
|
16
19
|
const broker = input.oauthBroker;
|
package/dist/shard-supervisor.js
CHANGED
|
@@ -13,6 +13,7 @@ import { CloudConnectorController, } from "./cloud-connector.js";
|
|
|
13
13
|
import { createCloudManagementModule } from "./cloud-management-module.js";
|
|
14
14
|
import { BotControlService, createBotControlServer, mapBotControlError, } from "./control-server.js";
|
|
15
15
|
import { createManagementModule } from "./management-module.js";
|
|
16
|
+
import { creatorInviteWorkerKeyName, deriveCreatorInviteKey, } from "./creator-invite-key.js";
|
|
16
17
|
import { createDiagnosticModule } from "./diagnostic-command.js";
|
|
17
18
|
import { buildApplicationCommandDefinitions } from "./interactions.js";
|
|
18
19
|
import { resolveModulePackageSpecifiers } from "./module-configuration.js";
|
|
@@ -1716,6 +1717,9 @@ export function buildShardWorkerEnvironment(source, identity, restartCount) {
|
|
|
1716
1717
|
const selectionKey = source.HELYX_DATA_ENCRYPTION_KEY
|
|
1717
1718
|
? Buffer.from(deriveSecureRandomSelectionKey(source.HELYX_DATA_ENCRYPTION_KEY)).toString("base64")
|
|
1718
1719
|
: undefined;
|
|
1720
|
+
const creatorInviteKey = source.HELYX_DATA_ENCRYPTION_KEY
|
|
1721
|
+
? deriveCreatorInviteKey(source.HELYX_DATA_ENCRYPTION_KEY).toString("base64")
|
|
1722
|
+
: undefined;
|
|
1719
1723
|
const hostedModerationCredential = source.HELYX_HOSTED_MODERATION_ENABLED === "true" &&
|
|
1720
1724
|
source.HELYX_BOT_CONTROL_SECRET
|
|
1721
1725
|
? { HELYX_BOT_CONTROL_SECRET: source.HELYX_BOT_CONTROL_SECRET }
|
|
@@ -1726,6 +1730,9 @@ export function buildShardWorkerEnvironment(source, identity, restartCount) {
|
|
|
1726
1730
|
...(selectionKey
|
|
1727
1731
|
? { [secureRandomSelectionWorkerKeyName]: selectionKey }
|
|
1728
1732
|
: {}),
|
|
1733
|
+
...(creatorInviteKey
|
|
1734
|
+
? { [creatorInviteWorkerKeyName]: creatorInviteKey }
|
|
1735
|
+
: {}),
|
|
1729
1736
|
SHARDING_MANAGER: "true",
|
|
1730
1737
|
SHARDING_MANAGER_MODE: "process",
|
|
1731
1738
|
SHARDS: String(identity.shardId),
|
package/dist/shard-worker.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare function startShardWorker(processEnvironment?: NodeJS.ProcessEnv,
|
|
|
23
23
|
export declare function executeShardScheduledTaskRequest(identity: ShardIdentity, request: ShardScheduledTaskRequest, route: ScheduledTaskRoute, now?: number): Promise<ShardScheduledTaskResponse>;
|
|
24
24
|
export declare function parseShardWorkerLaunchContract(value: string | undefined): ShardIdentity;
|
|
25
25
|
export declare function parseShardWorkerEnvironment(processEnvironment: NodeJS.ProcessEnv, identity: ShardIdentity): {
|
|
26
|
+
HELYX_INTERNAL_CREATOR_INVITE_KEY?: string;
|
|
26
27
|
HELYX_INTERNAL_SECURE_RANDOM_SELECTION_KEY?: string;
|
|
27
28
|
HELYX_DATA_ENCRYPTION_KEY: undefined;
|
|
28
29
|
HELYX_SHARD_WORKERS_PER_REPLICA: number;
|
package/dist/shard-worker.js
CHANGED
|
@@ -15,6 +15,7 @@ import { HttpVerificationService } from "./verification-service.js";
|
|
|
15
15
|
import { DiscordMessageDeliveryService, DiscordMemberRoleService, DiscordVerificationMemberService, DiscordResourceInspection, installModuleEvents, } from "./events.js";
|
|
16
16
|
import { DiscordModerationMemberEnforcementAdapter } from "./discord-member-enforcement-service.js";
|
|
17
17
|
import { installCreatorInvitePlatform } from "./creator-onboarding-platform.js";
|
|
18
|
+
import { creatorInviteWorkerKeyName, decodeCreatorInviteKey, } from "./creator-invite-key.js";
|
|
18
19
|
import { installGuildTracking, } from "./guilds.js";
|
|
19
20
|
import { installInteractions, } from "./interactions.js";
|
|
20
21
|
import { createManagementModule } from "./management-module.js";
|
|
@@ -318,6 +319,11 @@ export async function startShardWorker(processEnvironment = process.env, identit
|
|
|
318
319
|
services: serviceAccess,
|
|
319
320
|
modules: publicModules,
|
|
320
321
|
encryptionKey: environment.HELYX_DATA_ENCRYPTION_KEY,
|
|
322
|
+
...(environment.HELYX_INTERNAL_CREATOR_INVITE_KEY
|
|
323
|
+
? {
|
|
324
|
+
inviteEncryptionKey: environment.HELYX_INTERNAL_CREATOR_INVITE_KEY,
|
|
325
|
+
}
|
|
326
|
+
: {}),
|
|
321
327
|
...(environment.HELYX_CLOUD_API_URL &&
|
|
322
328
|
environment.HELYX_OAUTH_INTERNAL_SECRET
|
|
323
329
|
? {
|
|
@@ -582,12 +588,18 @@ export function parseShardWorkerEnvironment(processEnvironment, identity) {
|
|
|
582
588
|
environment.HELYX_SHARD_SCOPE !== identity.scope)
|
|
583
589
|
throw new Error("Shard worker launch contract conflicts with configuration");
|
|
584
590
|
const internalSelectionKey = processEnvironment[secureRandomSelectionWorkerKeyName];
|
|
591
|
+
const internalCreatorInviteKey = processEnvironment[creatorInviteWorkerKeyName];
|
|
592
|
+
if (internalCreatorInviteKey !== undefined)
|
|
593
|
+
decodeCreatorInviteKey(internalCreatorInviteKey);
|
|
585
594
|
return {
|
|
586
595
|
...environment,
|
|
587
596
|
HELYX_DATA_ENCRYPTION_KEY: undefined,
|
|
588
597
|
...(internalSelectionKey
|
|
589
598
|
? { HELYX_INTERNAL_SECURE_RANDOM_SELECTION_KEY: internalSelectionKey }
|
|
590
599
|
: {}),
|
|
600
|
+
...(internalCreatorInviteKey
|
|
601
|
+
? { HELYX_INTERNAL_CREATOR_INVITE_KEY: internalCreatorInviteKey }
|
|
602
|
+
: {}),
|
|
591
603
|
};
|
|
592
604
|
}
|
|
593
605
|
export function shardWorkerCommandRegistration(input) {
|