Repository navigation
fix(line): 不自行註冊 E2EE 群組金鑰,即時解密失敗改顯示佔位 - #3
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Fixes #2
原因(推論,未以真實帳號重現)
linejs 3.5.0
getE2EELocalPublicKey在 LINE 對群組金鑰回NOT_FOUND時,會呼叫tryRegisterE2EEGroupKey自行產生並註冊一把新的群組金鑰。這條路徑:getE2EEGroupSharedKey回NOT_FOUND,再getLastE2EEGroupSharedKey也NOT_FOUND時,讀一則訊息就會註冊新金鑰。issue 回報的「同一世代下有兩把金鑰、部分可解大部分不可解、換代後痊癒」與「本裝置自行註冊的金鑰和官方 App 的新世代並存」吻合。LINE 伺服器端如何處理同時註冊無法在本機驗證,因此屬推論。
另外,linejs 的即時事件迴圈先
decryptE2EEMessage再 emit,解密失敗會被 catch 後靜默丟棄(還以LegyPusherError記錄),違反本專案「解密失敗 fail-closed 顯示佔位」的規則,也是 issue 裡「即時路徑收不到任何事件」的原因。修正(只改 adapter)
activate時把base.e2ee.tryRegisterE2EEGroupKey改為一律失敗:本服務不再自行建立群組金鑰,只用 LINE 發下的金鑰。decryptE2EEMessage:失敗時回傳原密文並標記為無法解密;即時訊息因此顯示「無法解密此訊息」佔位,不再消失。歷史路徑行為不變。代價:成員剛變動、LINE 尚未發下新金鑰時,本服務傳送 E2EE 群組訊息會失敗(草稿保留)、收到的訊息顯示佔位;成員用官方 App 發言、LINE 建立新金鑰後恢復。
無法修復的部分:已經損壞的世代(如 178007062)無法由本修正救回,仍需換代(新成員加入)。
驗證
BaseClient/E2EE 程式碼與真實Client.listen事件迴圈,只把 LINE 回應換成群組金鑰NOT_FOUND。確認傳送失敗且未送出密文、歷史與即時訊息都是decryptFailed佔位、沒有任何註冊流程。getLastE2EEPublicKeys),即時訊息被丟棄(測試失敗)。npm run typecheck、npm test(363/363)、npm audit --audit-level=high(0)。文件:三語 README、AGENTS(adapter 規則)、PLAN 已同步。