Skip to content

feat: add message-edit and message-delete producers#8

Merged
santiagomed merged 3 commits into
mainfrom
santiagomed/edit-delete-producers
Jul 24, 2026
Merged

feat: add message-edit and message-delete producers#8
santiagomed merged 3 commits into
mainfrom
santiagomed/edit-delete-producers

Conversation

@santiagomed

Copy link
Copy Markdown
Contributor

Summary

Closes the produce-side gap for message edits and deletes. The SDK could already decrypt both (contentType: 'edit' and Event::MessageDeleted) but had no way to create them.

encrypt_edit(EncryptEditParams)

An edit is an encrypted MessageEdit content payload — target sequence id, replacement text, and rich-text entities — signed and packaged as a regular MessageCreateEvent, so it ships through the existing message-send channel with a fresh SDK-minted message id. Params mirror EncryptReactionParams: pass targetEvent (the raw event being edited) and the SDK derives the conversation id and target sequence id, or pass the explicit fields. The conversation key resolves from the opt-in cache; key material is zeroized on drop and redacted from Debug.

Consumer fix bundled in: decoded Edit content now surfaces its entities, which were previously parsed off the wire and dropped.

prepare_message_delete(MessageDeleteParams)

A delete is a plaintext signed event, not an encrypted message. This builds the thrift MessageDeleteEvent (sequence ids + delete-for-self/delete-for-all), signs the payload
MessageDeleteEvent,{msg_id},{sender_id},{conv_id},{action},{sequence_ids...}
and returns an ActionSignature carrying the encoded event detail — the shape receiving clients verify with the existing MessageDeleteEvent arm of the signature verifier. The 1:1 conversation id is canonicalized to the colon form before signing.

Binding parity

All six surfaces move together per AGENTS.md §2: Rust core, wasm/JS (encryptEdit / prepareMessageDelete + index.d.ts types), Python (encrypt_edit / prepare_message_delete + .pyi stubs), Go (EncryptEdit / PrepareMessageDelete), .NET, and JVM. docs/API.md tables updated in lockstep; examples/js/src/chat-core.mjs gains thin passthroughs.

Testing

  • Core: sign↔verify round trips through build_event_signature_payload for both delete actions (exact payload pins, canonical colon-form id from a hyphen-form input), encoded-detail thrift round trip, empty-sequence_ids rejection, and an encrypt-edit → decrypt_event round trip asserting verified content with entities.
  • Every binding suite gained matching tests: JS (api.test.mjs 4c2/4c3), Python (58 tests OK), Go, .NET (69 OK), JVM (56 OK, JDK 21).
  • make ci clean (fmt, clippy -D warnings, 554 workspace tests).

Notes

  • darwin_arm64 Go prebuilt regenerated; linux_amd64/musl prebuilts still need regeneration on a machine with cargo-zigbuild (or the prebuilt workflow) before release.
  • No wire-format changes: the edit reuses the frozen MessageEdit thrift struct and the delete signs the payload form the verifier already reconstructs.

@CLAassistant

CLAassistant commented Jul 24, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ santiagomed
❌ github-actions[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@santiagomed
santiagomed force-pushed the santiagomed/edit-delete-producers branch from e2b989b to 8ad6ddb Compare July 24, 2026 02:42
Adds the two producer APIs that let SDK callers edit and delete messages:

- encrypt_edit(EncryptEditParams): encrypts a MessageEdit content payload
  (target sequence id, replacement text, entities) as a regular signed
  MessageCreateEvent, sendable through the existing message-send channel.
  The decoded Edit content now also surfaces its entities, which were
  previously dropped.
- prepare_message_delete(MessageDeleteParams): builds and signs the
  plaintext MessageDeleteEvent action (delete-for-self or delete-for-all
  over one or more sequence ids), returning the ActionSignature with the
  encoded event detail, ready to submit alongside a delete request. The
  1:1 conversation id is canonicalized to the colon form before signing.

All six bindings gain the new surface with matching semantics (wasm/JS,
Python, Go, .NET, JVM), docs/API.md tables are updated in lockstep, and
each binding's test suite covers the new methods, including exact
signature-payload pins and an encrypt-edit decrypt round trip with
signature verification.

The darwin_arm64 Go prebuilt is regenerated; the linux prebuilts need a
machine with cargo-zigbuild (or the prebuilt workflow) before release.
@santiagomed
santiagomed force-pushed the santiagomed/edit-delete-producers branch from 1c2114d to 08acf69 Compare July 24, 2026 20:54
@santiagomed
santiagomed merged commit 408851b into main Jul 24, 2026
17 of 18 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants