XDevPlatform.ChatXdk
0.7.2
See the version list below for details.
dotnet add package XDevPlatform.ChatXdk --version 0.7.2
NuGet\Install-Package XDevPlatform.ChatXdk -Version 0.7.2
<PackageReference Include="XDevPlatform.ChatXdk" Version="0.7.2" />
<PackageVersion Include="XDevPlatform.ChatXdk" Version="0.7.2" />
<PackageReference Include="XDevPlatform.ChatXdk" />
paket add XDevPlatform.ChatXdk --version 0.7.2
#r "nuget: XDevPlatform.ChatXdk, 0.7.2"
#:package XDevPlatform.ChatXdk@0.7.2
#addin nuget:?package=XDevPlatform.ChatXdk&version=0.7.2
#tool nuget:?package=XDevPlatform.ChatXdk&version=0.7.2
chat-xdk .NET bindings
.NET bindings for the X Chat SDK — encryption for X Direct Messages.
Architecture
C# (ChatXdk) → P/Invoke → Rust cdylib (chat_xdk_ffi) → chat-xdk-core
Complex values cross the FFI boundary as JSON strings. P/Invoke entry points are generated with csbindgen from src/lib.rs into dotnet/ChatXdk/NativeMethods.g.cs.
Prerequisites
- .NET 8+ SDK
- Rust (stable) to build the native
chat_xdk_ffilibrary
Setup
From the repo root, build the native library:
cargo build -p chat-xdk-ffi --release
Then build the managed wrapper:
cd crates/dotnet/dotnet/ChatXdk
dotnet build -c Release
The published XDevPlatform.ChatXdk package bundles the native library for macOS (arm64, x64), Linux (x64, arm64) and Windows (x64) under runtimes/<rid>/native/. With a wrapper you build yourself, place the native library (libchat_xdk_ffi.dylib / .so / chat_xdk_ffi.dll) on the loader path next to your app. NativeMethods.g.cs is generated from the C ABI in crates/ffi by its build script, so building the native library regenerates it.
Quick Start
using ChatXdk;
using var chat = new Chat(juiceboxConfigJson);
await chat.UnlockAsync(pinBytes); // the PIN's UTF-8 bytes; zero them afterwards
// Or create the chat with new Chat() and load a local key blob + its
// registered version instead of Juicebox:
// chat.ImportKeys(new ImportKeysParams(privateKeyBytes) { SigningKeyVersion = registeredKeyVersion });
// Set the session once: your user id + registered signing-key version,
// the opt-in conversation-key cache, and the participants' signing keys.
chat.SetIdentity(new SetIdentityParams(myUserId, registeredKeyVersion));
chat.SetCacheKeys(true);
chat.SetSigningKeys(signingKeys);
// Batch load — signing keys come from the store; the verified conversation
// keys populate the cache.
var batch = chat.DecryptEvents(new DecryptEventsParams(rawEventB64List));
foreach (var dm in batch.Events)
{
if (dm.Event.GetProperty("type").GetString() == "Message")
Console.WriteLine(dm.Event.GetProperty("sender_id").GetString());
}
// Individual events: the empty key map and unset signing keys resolve from
// the session stores (pass conversation/signing keys explicitly to override).
var evt = chat.DecryptEvent(new DecryptEventParams(eventB64, new Dictionary<string, byte[]>()));
var conversationId = evt.GetProperty("conversation_id").GetString()!;
// Sending resolves the identity and conversation key from the session too.
var payload = chat.EncryptMessage(new EncryptMessageParams(conversationId, "hi!"));
// Reply / react by handing back the raw event being answered.
var reply = chat.EncryptReply(new EncryptReplyParams(conversationId, "pong", eventB64));
var reaction = chat.EncryptAddReaction(new EncryptReactionParams(eventB64, "👍"));
var plaintext = chat.Decrypt(encryptedGroupNameB64, convKeyBytes);
Stateless helpers (base64/hex, MIME sniffing, image dimensions) live on ChatXdkUtilities.
API
See the .NET column of the unified tables in docs/API.md for the full method list, parameters, and return types. Files (media) are covered under Files (Media).
Network access
Each chat makes one kind of request itself: an anonymous
GET https://api.x.com/2/chat/features in the background, which reads the X
API's feature switches that pick the format the SDK sends in. A chat reads
them when it is created, again once SetIdentity gives it a sender, and
again 5 minutes after each answer, so a change reaches a running chat. The
sender's request carries its bucket, the last four digits of the user id
(?bucket=1234), so every chat of one sender gets the same answer; before
that, the X API buckets the request by its address. Chats that read the same
URL share one request, and a chat that joins it takes its latest answer at
once. The request carries no credentials and never delays or fails a call.
One that fails is retried in the background, 1 second later, then after
twice the previous wait, at most 5 minutes apart. Each answer replaces the
one before; until an answer for the chat's URL arrives, sends stay in v0,
the format 0.5.x sends.
Security limitations
The underlying protocol provides no forward secrecy and no post-compromise security: compromise of an identity private key exposes all conversation keys ever encrypted to that public key — and therefore all past and future messages in those conversations. Key rotation does not retroactively protect messages encrypted under a previous key. See docs/CRYPTO.md — Known Limitations.
License
MIT — see the repo LICENSE. Third-party notices:
THIRD_PARTY_NOTICES.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.7.6 | 78 | 11/20/2026 |
| 0.7.5 | 141 | 11/17/2026 |
| 0.7.4 | 92 | 11/17/2026 |
| 0.7.3 | 99 | 11/13/2026 |
| 0.7.2 | 155 | 11/3/2026 |
| 0.7.1 | 126 | 10/28/2026 |
| 0.7.0 | 116 | 10/27/2026 |
| 0.5.2 | 726 | 10/15/2026 |
| 0.5.0 | 3,216 | 8/18/2026 |
| 0.4.3 | 582 | 7/24/2026 |
| 0.4.2 | 126 | 7/23/2026 |
| 0.4.1 | 584 | 7/20/2026 |
| 0.4.0 | 122 | 7/20/2026 |
| 0.2.1 | 117 | 7/16/2026 |
| 0.2.0 | 122 | 7/10/2026 |