-
-
Notifications
You must be signed in to change notification settings - Fork 57
fix: decrypt poll votes across PN and LID parent authors #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1857af1
96ef260
0649be1
7c5e5b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,4 @@ bench-profiles-*/ | |
| /test/ | ||
| .claude | ||
| *.log | ||
| ___* | ||
| ___* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -600,9 +600,11 @@ export class WaMessageDispatchCoordinator { | |
| sendOptions.id && | ||
| (this.deps.persistAllMessageSecrets || needsSecretPersistence(messageWithSecret)) | ||
| ) { | ||
| const meJid = this.deps.getCurrentCredentials()?.meJid ?? '' | ||
| void this.deps.messageSecretStore | ||
| .set(sendOptions.id, { secret: rawSecret, senderJid: meJid }) | ||
| .set(sendOptions.id, { | ||
| secret: rawSecret, | ||
| senderJid: this.resolveOutgoingSecretSenderJid() | ||
| }) | ||
| .catch((error) => { | ||
| this.deps.logger.warn('failed to persist outgoing message secret', { | ||
| id: sendOptions.id, | ||
|
|
@@ -1480,6 +1482,40 @@ export class WaMessageDispatchCoordinator { | |
| return WA_ADDRESSING_MODES.PN | ||
| } | ||
|
|
||
| /** | ||
| * Parent-author JID stored with the outgoing message secret. Peers address | ||
| * us by LID in `pollCreationMessageKey` during the PN→LID migration, so a | ||
| * valid `meLid` wins. A malformed LID must not abort the send: fall back to | ||
| * a normalized `meJid`, then to the empty sender (same recoverable path as | ||
| * {@link resolveSenderForAddressingMode}). | ||
| */ | ||
| private resolveOutgoingSecretSenderJid(): string { | ||
| const credentials = this.deps.getCurrentCredentials() | ||
| const meLid = credentials?.meLid | ||
| if (meLid && meLid.includes('@')) { | ||
| try { | ||
| return toUserJid(meLid) | ||
| } catch (error) { | ||
| this.deps.logger.trace('ignoring malformed me lid jid', { | ||
| meLid, | ||
| message: toError(error).message | ||
| }) | ||
| } | ||
| } | ||
| const meJid = credentials?.meJid | ||
| if (meJid && meJid.includes('@')) { | ||
| try { | ||
| return toUserJid(meJid) | ||
|
Comment on lines
+1495
to
+1508
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Require a LID before preferring
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| } catch (error) { | ||
| this.deps.logger.trace('ignoring malformed me jid', { | ||
| meJid, | ||
| message: toError(error).message | ||
| }) | ||
| } | ||
| } | ||
| return '' | ||
| } | ||
|
|
||
| private resolveSenderForAddressingMode( | ||
| addressingMode: GroupAddressingMode, | ||
| meJid: string | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: resolveOutgoingSecretSenderJid only checks that
meLidcontains '@' before normalizing and returning it, without verifying it is actually a LID JID (e.g. viaisLidJid). Ifcredentials.meLidis ever populated with a PN-shaped value, this will persist the PN as the parent sender instead of falling back tomeJid, which can cause the stored sender fallback used during addon decryption to be wrong. Consider normalizingmeLidfirst and only returning it whenisLidJid()is true, falling back tomeJidotherwise.Prompt for AI agents