Skip to content

feat: add Feishu/Lark adapter (@chat-adapter/feishu)#108

Open
moeyua wants to merge 4 commits intovercel:mainfrom
moeyua:feat/adapter-feishu
Open

feat: add Feishu/Lark adapter (@chat-adapter/feishu)#108
moeyua wants to merge 4 commits intovercel:mainfrom
moeyua:feat/adapter-feishu

Conversation

@moeyua
Copy link

@moeyua moeyua commented Feb 25, 2026

Summary

Add a complete Feishu (飞书/Lark) adapter to the Chat SDK, implementing the full Adapter interface with production-quality security and platform integration.

New Package

@chat-adapter/feishu — 11 new files, ~3,200 lines (source + tests + config)

Source Files

  • src/index.ts — Full Adapter implementation: webhook handling, message CRUD, reactions, typing indicators, thread/channel operations, DM support
  • src/types.ts — Feishu API types (events, messages, responses, config)
  • src/markdown.ts — Bidirectional mdast ↔ Feishu markdown conversion (bold, italic, links, code blocks, lists, mentions)
  • src/cards.ts — Interactive card message conversion (Card → Feishu card JSON)

Tests (87 total, all passing)

  • src/index.test.ts — 35 tests: webhook verification, message parsing, encryption/decryption, signature verification, thread ID encoding, config validation
  • src/markdown.test.ts — 34 tests: format conversion, mention parsing, edge cases
  • src/cards.test.ts — 18 tests: card element conversion, nested structures

Key Features

  • Security: AES-256-CBC event encryption/decryption, SHA-256 webhook signature verification
  • Reactions: Proper list-then-delete-by-UUID pattern matching Feishu's API
  • Format conversion: Full mdast-based markdown pipeline matching other adapters
  • Thread ID format: feishu:{chatId}:{base64(messageId)}
  • Config validation: Uses ValidationError from @chat-adapter/shared
  • Factory pattern: createFeishuAdapter(config) matching existing adapter conventions

Monorepo Integration

  • turbo.json updated with FEISHU_* env vars
  • ESM-only, tsup build, vitest config — matches all existing adapters
  • pnpm validate passes (knip, biome check, typecheck 23/23, all test suites, build)

Checklist

  • Implements full Adapter interface from packages/chat/src/types.ts
  • Follows existing adapter patterns (Slack, Teams, GChat, Discord)
  • 87 unit tests, all passing
  • pnpm validate clean (knip + biome + typecheck + test + build)
  • No as any / @ts-ignore / @ts-expect-error
  • ESM only, TypeScript strict mode

Implement complete Feishu/Lark platform adapter following existing adapter patterns:

- FeishuAdapter class implementing full Adapter interface
- FeishuFormatConverter extending BaseFormatConverter for rich text (post) format
- Interactive card support (cardToFeishuPayload, cardToFallbackText)
- Webhook verification, message parsing, reactions, thread management
- createFeishuAdapter() factory function with config validation
- Add FEISHU_* env vars to turbo.json globalEnv
- Tests for cards (18) and markdown (30) converters, all passing
…s, file uploads

- Add AES-256-CBC event decryption with SHA-256 key derivation
- Add SHA-256 signature verification for webhook security
- Fix removeReaction to list-then-delete by reaction UUID
- Broaden mention regex to support hyphens/dots in usernames
- Add logger.warn for silently dropped file attachments
- Add 10 new tests covering all fixes (87 total, all passing)
@vercel
Copy link
Contributor

vercel bot commented Feb 25, 2026

@moeyua is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@socket-security
Copy link

socket-security bot commented Feb 25, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​larksuiteoapi/​node-sdk@​1.59.08910010098100

View full report

…ader rejection, DM routing

- Use crypto.timingSafeEqual for signature verification to prevent timing attacks
- Return 401 when encryptKey is configured but signature headers are missing
- Add sendToChat() helper to route DM threads via message.create instead of reply
- Update and add corresponding unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant