logos-chat/library/api/identity_api.nim

46 lines
1.2 KiB
Nim
Raw Normal View History

## Identity API - FFI bindings for identity operations
## Uses the {.ffi.} pragma for async request handling
import std/json
import chronicles
import chronos
import ffi
import stew/byteutils
2026-01-09 11:29:14 +02:00
import src/chat
import library/utils
logScope:
topics = "chat ffi identity"
#################################################
# Identity Operations
#################################################
proc chat_get_identity(
2026-01-12 18:16:01 +02:00
ctx: ptr FFIContext[ChatClient],
callback: FFICallBack,
userData: pointer
) {.ffi.} =
## Get the client identity
## Returns JSON string: {"name": "..."}
let identJson = %*{
"name": ctx.myLib[].getId()
}
return ok($identJson)
#################################################
# IntroBundle Operations
#################################################
proc chat_create_intro_bundle(
2026-01-12 18:16:01 +02:00
ctx: ptr FFIContext[ChatClient],
callback: FFICallBack,
userData: pointer
) {.ffi.} =
## Create an IntroBundle for initiating private conversations
## Returns the intro bundle as an ASCII string (format: logos_chatintro_<version>_<base64url payload>)
2026-01-09 11:49:04 +02:00
let bundle = ctx.myLib[].createIntroBundle()
return ok(string.fromBytes(bundle))