/** * Slack Events API verification and Phase 1 event normalization. * * These helpers are pure library primitives for the managed channel service. * They do not perform HTTP I/O or durable enqueue. */ import { type InstallationKind, type SourceThreadMode } from "./source-thread.js"; import type { ChannelEvent } from "../types.js"; import type { RequiredSlackChannelConfig, SlackChannelTrigger } from "./index.js"; export interface SlackSignatureHeaders { signature: string; timestamp: string; } export interface SlackInstallationContext { kind: InstallationKind; id: string; /** Workspace context for the conversation (team_id or context_team_id). */ contextTeamId: string; /** * Optional install pin for the bot user id. When unset, normalize reads the * installing bot from the Events envelope `authorizations` field. */ botUserId?: string; apiAppId: string; } export interface NormalizeSlackEventInput { body: unknown; config: RequiredSlackChannelConfig; installation: SlackInstallationContext; deliveryId: string; /** When true, treat `message` events as `message.im` (DM surface). */ isDirectMessageSurface?: boolean; } export type NormalizeSlackEventResult = { status: "url_verification"; challenge: string; } | { status: "filtered"; reason: string; eventId?: string; } | { status: "accepted"; event: ChannelEvent; userId: string; sourceThreadKey: string; trigger: SlackChannelTrigger; groupingMode: SourceThreadMode; }; /** * Verify a Slack request signature over the exact raw body bytes. * * Computes HMAC-SHA256 of `v0:{timestamp}:{raw_body}` and compares safely. * Rejects timestamps older than five minutes. */ export declare function verifySlackRequest(rawBody: string | Uint8Array, headers: SlackSignatureHeaders, signingSecret: string, nowSeconds?: number): Promise; /** * Normalize a verified Slack Events API payload into a channel-neutral event. * * Filters bot/system/unsupported shapes and applies declarative trigger/filters. */ export declare function normalizeSlackEvent(input: NormalizeSlackEventInput): NormalizeSlackEventResult; /** Decode Slack transport escaping (`&` `<` `>`). */ export declare function decodeSlackEscaping(text: string): string; //# sourceMappingURL=normalize.d.ts.map