feat: add image message decryption and download#18
Open
echowxsy wants to merge 1 commit intocv-cat:masterfrom
Open
feat: add image message decryption and download#18echowxsy wants to merge 1 commit intocv-cat:masterfrom
echowxsy wants to merge 1 commit intocv-cat:masterfrom
Conversation
Feishu encrypts image messages with AES-256-GCM. This adds: - Image decryption pipeline: download from CDN → decrypt → detect type → save - Raw protobuf parsing to extract image_id, decrypt key, and IV from nested image message content structure - Local caching to avoid re-downloading images - Image type detection from magic bytes (JPEG, PNG, WebP, GIF, BMP, TIFF) - WebSocket handler now processes image messages (type=5) and auto-decrypts - MCP tool `download_image` for on-demand image decryption - Images saved to ~/.lark/msg/images/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feishu encrypts image messages with AES-256-GCM before sending them via WebSocket. This PR adds full support for receiving, decrypting, and saving image messages.
Changes
app/api/image_decrypt.py(new): Complete image decryption pipelineimage_id, decrypt key, and IV from nested image message structure~/.lark/msg/images/builder/proto.py: Handle image messages (type=5) indecode_receive_msg_proto, storing raw content bytes andmessageTypefieldapp/api/lark_client.py: Updateprocess_msgto detect image messages, extract decrypt info, download and decrypt automatically, passmessage_typeandimage_infoto handlerapp/core/message_service.py: Accept newmessage_typeandimage_infoparameters, log image detailsapp/core/mcp_server.py: Adddownload_imageMCP tool for on-demand image decryptionEncryption scheme
The WebSocket push for image messages contains:
image_id(e.g.,img_v3_xxxx) identifying the image on Feishu CDNFlow: parse protobuf → extract key/IV → download encrypted payload from CDN → decrypt with AES-256-GCM → detect type → save to disk.
Test plan
download_imageMCP tool with known image_id, key_hex, iv_hex🤖 Generated with Claude Code