import { WebClient, type FetchFunction } from '@slack/web-api'; import type { ChannelConnectionIssue } from '@xopcai/xopc/channels/channel-domain.js'; import type { SlackRuntimeCaches } from '../state/caches.js'; export declare const SLACK_API_BASE = "https://slack.com/api/"; export declare const PERMANENT_AUTH_ERROR_CODES: Set; export declare const PERMANENT_SCOPE_ERROR_CODES: Set; export declare class SlackConnectionRejectedError extends Error { readonly issue: Exclude; readonly slackCode?: string | undefined; constructor(issue: Exclude, message: string, slackCode?: string | undefined); } export declare class SlackApiError extends Error { readonly method: string; readonly code: string; readonly neededScope?: string | undefined; readonly status?: number | undefined; constructor(method: string, code: string, message?: string, neededScope?: string | undefined, status?: number | undefined); } export interface SlackAuthIdentity { teamId: string; teamName?: string; userId: string; botId?: string; enterpriseId?: string; isEnterpriseInstall: boolean; scopes: string[]; } export declare function formatSlackIdentityKey(identity: Pick): string; export declare function resolveSlackProxyUrl(explicitProxy?: string): string | undefined; export declare function parseScopesHeader(headerValue: string | null | undefined): string[]; /** * Fetch wrapper with proxy support, HTTP 429 `Retry-After` retry, and optional `x-oauth-scopes` capture. */ export declare function createSlackFetch(options?: { proxyUrl?: string; timeoutMs?: number; onScopes?: (scopes: string[]) => void; }): FetchFunction; export interface CreateSlackClientOptions { token: string; teamId?: string; proxyUrl?: string; timeoutMs?: number; onScopes?: (scopes: string[]) => void; } export declare function createSlackWebClient(options: CreateSlackClientOptions): WebClient; /** * Direct JSON Web API call with HTTP 429 `Retry-After` retry, strict error classification, * and automatic `x-oauth-scopes` capture. */ export declare function slackJsonCall(method: string, token: string, body: Record, options?: { signal?: AbortSignal; proxyUrl?: string; timeoutMs?: number; onScopes?: (scopes: string[]) => void; }): Promise>; /** * Form-urlencoded Web API call (required by Slack methods like `files.getUploadURLExternal`). */ export declare function slackFormCall(method: string, token: string, params: Record, options?: { signal?: AbortSignal; proxyUrl?: string; timeoutMs?: number; }): Promise>; export declare function isValidBotTokenFormat(token: string): boolean; export declare function isValidUserTokenFormat(token: string): boolean; export declare function isValidAppTokenFormat(token: string): boolean; export declare function authenticateSlackToken(token: string, options?: { postAs?: 'bot' | 'user'; signal?: AbortSignal; proxyUrl?: string; }): Promise; export declare function openSlackSocketUrl(appToken: string, options?: { signal?: AbortSignal; proxyUrl?: string; }): Promise; /** * Extract the Slack App ID embedded in an `xapp---...` token when present. */ export declare function extractAppIdFromAppToken(appToken: string | undefined): string | undefined; /** * Resolve a Slack user ID (`U...`/`W...`) to a DM channel ID (`D...`) using `conversations.open`, with caching. */ export declare function resolveSlackDmChannelId(params: { token: string; userId: string; accountId: string; teamId?: string; proxyUrl?: string; caches?: SlackRuntimeCaches; }): Promise; export declare function formatSlackError(err: unknown): string;