Refactor runtime around isolated bot instances
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import crypto from "node:crypto";
|
||||
import type { AppConfig } from "../config.js";
|
||||
import type { WebhookConfig } from "../config.js";
|
||||
import type { PromptSession } from "./prompt.js";
|
||||
|
||||
export async function configureGenericWebhook(
|
||||
prompt: PromptSession,
|
||||
existing: AppConfig["platforms"]["webhook"]
|
||||
): Promise<AppConfig["platforms"]["webhook"]> {
|
||||
console.log("\nGeneric webhook setup");
|
||||
console.log("Use POST /webhook/generic with optional X-Gori-Signature HMAC-SHA256 authentication.");
|
||||
|
||||
const generated = existing.secret && existing.secret !== "replace-me" ? existing.secret : crypto.randomBytes(24).toString("hex");
|
||||
const secret = await prompt.ask("Webhook secret", generated);
|
||||
return { enabled: true, secret };
|
||||
export async function configureGenericWebhook(prompt: PromptSession, existing: WebhookConfig): Promise<WebhookConfig> {
|
||||
const answer = await prompt.askSecret("Webhook secret (leave blank to generate)", Boolean(existing.secret));
|
||||
return { type: "webhook", secret: answer || existing.secret || crypto.randomBytes(24).toString("hex") };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user