Refactor Telegram attestation verification to support 'validate' mode…#432
Refactor Telegram attestation verification to support 'validate' mode…#432tcsenpai merged 2 commits intotg_identitiesfrom
Conversation
… and improve challenge handling
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
WalkthroughTelegram verification and transaction handling were extended: web2 parser and abstraction now accept an optional Transaction and invoke verification in 'validate' mode; identity tools add a 'validate' mode, stronger parsing, transaction-aware challenge hashing, and updated transaction/payload shapes and signatures. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client App
participant Parser as TelegramProofParser
participant TG as Identity.Tools.Telegram
participant Crypto as Crypto Verify
participant Store as Challenge Store
note over Client,Parser: Read/validation flow (non-interactive)
Client->>Parser: readData(proofData, transaction)
Parser->>TG: verifyAttestation(attestationData, "validate", txHash)
TG->>Crypto: verify bot & user signatures (uses txHash for replay check)
Crypto-->>TG: verification result
TG-->>Parser: validation result (does not mark challenge used)
Parser-->>Client: signature data / error
sequenceDiagram
autonumber
participant User as End User
participant App as Client App
participant TG as Identity.Tools.Telegram
participant Store as Challenge Store
participant Crypto as Crypto Verify
note over User,App: Interactive attestation flow (mode: "attest")
User->>App: submit attestation request
App->>TG: verifyAttestation(request, "attest")
TG->>Store: load stored challenge (must exist & unused)
Store-->>TG: challenge record
TG->>Crypto: verify bot & user signatures
Crypto-->>TG: verification result
alt valid
TG->>Store: mark challenge used
TG-->>App: success response
else invalid
TG-->>App: error response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (4)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
I'd look at this from #432 (comment) and then it looks good @SergeyG-Solicy |
…h for replay protection
User description
Description:
PR Type
Enhancement
Description
Added 'validate' mode to Telegram attestation verification
Fixed genesis block parsing for bot authorization
Improved challenge format parsing and error handling
Enhanced transaction structure with required fields
Diagram Walkthrough
File Walkthrough
telegram.ts
Switch to validate mode for attestation verificationsrc/libs/abstraction/web2/telegram.ts
verifyAttestationcall to use 'validate' modetelegram.ts
Major refactor of Telegram verification logicsrc/libs/identity/tools/telegram.ts
verifyAttestationmethodSummary by CodeRabbit
New Features
Bug Fixes
Improvements