@xnetjs/slack-compat
v0.0.2
Published
Slack wire-protocol compatibility primitives — Block Kit + mrkdwn → GitHub-flavored markdown, incoming-webhook + slash-command parsing, and signing-secret verification. Pure logic, zero runtime dependencies (node:crypto only). The shared core under XNet's
Downloads
298
Readme
@xnetjs/slack-compat
Slack wire-protocol compatibility primitives for XNet — the shared, pure-logic core that lets integrations written against Slack work against XNet (exploration 0198).
Zero runtime dependencies (node:crypto only). Used by the Slack migration
connector (@xnetjs/plugins) and the hub slack-compat feature
(@xnetjs/hub).
What's here
| Export | Purpose |
| --- | --- |
| slackMrkdwnToMarkdown(text) | Translate Slack mrkdwn (<url\|label>, <@U1>, *bold*, escaped entities) → GitHub-flavored markdown. |
| blockKitToMarkdown(blocks) | Best-effort Block Kit (header/section/context/divider) → markdown. Interactive blocks degrade to their text. |
| normalizeIncomingWebhook(payload) | Collapse a Slack incoming-webhook body (blocks → attachments → text) into a transport-agnostic { content, channelHint?, username?, iconEmoji? }. |
| parseSlashCommand(body) / formatSlashResponse(opts) | Slack-compatible slash-command request parsing + response formatting (defaults to ephemeral, matching Slack). |
| verifySlackSignature(opts) / signSlackRequest(opts) | v0=HMAC_SHA256 signing-secret verification with replay protection. |
Design notes
- Lossy by design.
ChatMessage.contentis GFM markdown; Slack messages are Block Kit JSON / legacy attachments. Translation is best-effort — buttons, selects, modals and App Home have no markdown equivalent and degrade to their text. Callers can park the original JSON in anext:overlay for richer rendering later. - Pure + injectable. No I/O, no globals, no clock except an injectable
nowSecondson signature verification — so every branch is unit-testable.
See the exploration for the full tiered-compatibility plan and what is deliberately deferred (OAuth authorization server, bot identity, the full Events API, interactive Block Kit).
