Skip to content

Looking up users

Read-only helpers. These need only a logged-in session, no identity. Every one accepts a numeric user id, a @handle, or a { id } object (handles are resolved and cached).

client.xchat.publicKey(userId)

A user's current XChat identity key, or null if they aren't on XChat.

js
const key = await client.xchat.publicKey("44196397");
// { version, publicKey, signingPublicKey, identityPublicKeySignature, registrationMethod }

publicKey is the identity key others use to wrap conversation keys to this user; signingPublicKey verifies their message signatures (see Protocol → Encryption).

client.xchat.publicKeys(userIds, opts?)

Keys and permissions for many users at once. opts.includeTokens includes the Juicebox realm token map. Returns an array of profiles (see profile).

js
const users = await client.xchat.publicKeys(["44196397", "tiagozip_"]);

client.xchat.profile(userId)

The full parsed XChat profile: { userId, onXChat, isManagedPinUser, permissions, keys }.

js
const p = await client.xchat.profile("44196397");

client.xchat.permissions(userId)

Just the permission flags: { canDm, canDmOnXChat, dmBlocking, passesPremiumCheck }. canDmOnXChat is relational (can you message this user over XChat).

js
const perms = await client.xchat.permissions("44196397");

client.xchat.canMessage(userId)

Boolean shortcut for permissions().canDmOnXChat.

js
if (await client.xchat.canMessage("44196397")) { /* reachable */ }

client.xchat.isOnXChat(userId)

Whether the user has any published XChat key.

js
await client.xchat.isOnXChat("44196397"); // true

client.xchat.fingerprint(key)

A short, verifiable fingerprint (colon-grouped SHA-256) of a key. Pass a key object from publicKey or a raw SPKI base64 string. Use it to compare a key out-of-band and confirm you are talking to the right person.

js
await client.xchat.fingerprint(await client.xchat.publicKey("44196397"));
// "8435:8166:a7fb:5c30:68dc:df90:dd47:b519:9eff:588c:c2bd:0772:36aa:c127:8e4b:b1c6"

client.xchat.callPermissions(userIds)

Check whether you may start an audio/video call with one or more users. Returns the per-user result ({ can_dm, error_code }).

js
await client.xchat.callPermissions("44196397");

Real-time audio/video itself needs a WebRTC stack (see Protocol → Calls); this checks reachability.

not affiliated with X Corp.