Skip to content

docs(xchat): correct chat-xdk SDK API surface across guides - #255

Closed
santiagomed wants to merge 6 commits into
mainfrom
docs/chat-xdk-api-accuracy
Closed

docs(xchat): correct chat-xdk SDK API surface across guides#255
santiagomed wants to merge 6 commits into
mainfrom
docs/chat-xdk-api-accuracy

Conversation

@santiagomed

Copy link
Copy Markdown
Collaborator

What

Corrects API-accuracy bugs in the X Chat SDK guides (xchat/*.mdx) against the current chat-xdk SDK. Several examples were copy-paste-and-it-breaks; this makes every language tab match the shipped API.

Bugs fixed

  • Streaming: encrypt_stream/decrypt_stream are two-arg, raw-bytes calls — the docs showed a {ciphertext, media_hash_key} return and a 3-arg decrypt. media_hash_key comes from the media-upload finalize step, not encrypt_stream.
  • Prepare methods take a single params object/struct in every binding except Python (which is positional/kwargs); the docs called them positionally. The params types also dropped the Prepare prefix (PrepareGroupCreateParamsGroupCreateParams).
  • encrypt_message/encrypt_reply/reactions: TypeScript tabs used positional args; the WASM binding takes a params object (reply uses replyToSequenceId).
  • decrypt_events .errors is a map { index → message }, not a list — the JS for…of would throw.
  • Go conversation keys are raw []byte, not base64 strings (base64 is an internal FFI detail); Go ImportKeys takes []byte; Go utility calls honor their (value, error) arities.
  • Java reads the public conversationKey field (no getter); C#/Java/Rust image-dimension and conversation-key types corrected (ImageDimensions, Option<XChatConversationKey> + .to_bytes(), &XChatConversationKey for stream/encrypt/decrypt).
  • Verification default: it is fail-closed by default — the docs implied omitting signing keys skips verification and that set_reject_unverified(true) is how you fail closed. Corrected: verification is mandatory unless you call set_reject_unverified(false).

Gaps added

  • Incremental streaming API (stream_encryptor/stream_decryptor, push/finish, ~1 MB chunks, JS "never free() after finish()").
  • The keyVersion-per-event → media key selection contract (decrypt old media with the key of that event's version after a rotation).
  • The three accepted Juicebox config shapes; the hex utility helpers.

Verification

Every signature verified against the SDK source (index.d.ts, __init__.pyi, go/chatxdk, Chat.cs/Types.cs, Chat.java/Types.java, core.rs/params.rs/utils.rs, keys/juicebox.rs). Ran a reviewer pass; applied all valid findings (one "only two juicebox shapes" finding was rejected — verified #114 landed the third key_store_token_map_json branch). All <Tabs>/<Tab> blocks balanced.

…sync

Replaces the branch's 21-commit history (which included an accidental
site-wide content overlay later reverted) with the intended content
re-applied on current main:

- xchat/ guide pages (introduction, cryptography primer, getting
  started, XDK reference, media, groups, real-time events,
  troubleshooting) carried over from the previous branch head
- Chat API product navigation spliced into docs.json (additive only)
- openapi.json synced verbatim from the live https://api.x.com/2/openapi.json,
  which now serves the chat action-signature, error-message, and
  public-key contract updates
…ract changes

Reflect the current Chat API and Chat XDK surface:

- conversation-key setup now uses prepare_conversation_key_change
  (one call: fresh key + participant wraps + signed action signature);
  the keys endpoint adds or rotates keys and returns the canonical
  conversation_id alongside sequence_id
- group creation uses prepare_group_create and member adds use
  prepare_group_members_change; both return two action signatures and
  the docs show sending both
- action signatures are required and validated at the API boundary
  (400 problem-details on malformed input); group endpoints return
  stable human-readable error messages
- public-key responses name the version field public_key_version;
  every fields list and sample read updated
- removed dropped SDK methods (prepare_conversation_keys,
  sign_add_members, sign_key_change,
  encrypt_conversation_key_for_recipients) and renamed
  PreparedConversationKeys to PreparedConversationChange
- documented conversation-id form flexibility (colon, hyphen, or bare
  recipient id all sign identically; URL paths still use hyphens),
  permanent verification failures, and chunked stream encryption
- teach verify_key_binding before wrapping conversation keys (warnings
  in Getting Started and the XDK reference, step in Groups)
- state the group title/avatar verbatim-match rule: values passed to
  prepare_group_create are signed and embedded exactly as given, so the
  POST body must carry byte-identical group_name/group_avatar_url; the
  encrypted-metadata section explains why a create-time title cannot be
  ciphertext under the group's own key
- point group flows at the batch public-keys route
- add rotation semantics: fresh keys on member adds mean new members
  cannot read earlier versions, rotation never revokes old versions,
  and rotating after suspected exposure protects future messages only
- primer: new 'Signed state changes (action signatures)' section
  covering what is signed, why the server validates structurally, and
  where cryptographic verification happens
- fix encrypt_reply samples to the real positional signatures and
  encrypt_message optional-argument names
- replace every ellipsis with explicit paths, field lists, example
  values, or complete code
Fix API-accuracy bugs against the current SDK: streaming is a two-arg
raw-bytes call (media_hash_key comes from upload finalize, not
encrypt_stream); prepare methods take a single params object/struct in
every binding except Python (and the params types dropped the Prepare
prefix); decrypt_events .errors is a map, not a list; Go conversation
keys are raw bytes, not base64; verification is fail-closed by default.
Add the incremental streaming API, the keyVersion-per-event media key
selection contract, the three Juicebox config shapes, and the hex
utility helpers.
Address code-review findings on the API-accuracy pass: TypeScript
encrypt_message/encrypt_reply/reactions take a single params object;
Go import_keys takes raw bytes (decode the base64 env var first); Go
utility calls honor their (value, error) arities; Java reads the public
conversationKey field, not a getter; C#/Java/Rust image-dimension and
conversation-key types match the SDK; width/height casts added where
narrowing.
@mintlify

mintlify Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
x-corp 🟢 Ready View Preview Jul 15, 2026, 11:49 PM

@mintlify

mintlify Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
x-corp 🟡 Building Jul 15, 2026, 11:48 PM

@santiagomed

Copy link
Copy Markdown
Collaborator Author

Superseded by #256, which targets the xchat-docs branch (the chat API docs integration branch). This PR was mistakenly based on main, where the xchat guides don't yet exist, so its diff re-introduced the whole doc set.

@santiagomed
santiagomed deleted the docs/chat-xdk-api-accuracy branch July 16, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant