diff --git a/src/ssb.js.c b/src/ssb.js.c index 55982359..a08dff6f 100644 --- a/src/ssb.js.c +++ b/src/ssb.js.c @@ -96,6 +96,21 @@ static JSValue _tf_ssb_getIdentities(JSContext* context, JSValueConst this_val, return result; } +static JSValue _tf_ssb_getServerIdentity(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) +{ + JSValue result = JS_NewArray(context); + tf_ssb_t* ssb = JS_GetOpaque(this_val, _tf_ssb_classId); + if (ssb) + { + char id[k_id_base64_len] = { 0 }; + if (tf_ssb_whoami(ssb, id, sizeof(id))) + { + result = JS_NewString(context, id); + } + } + return result; +} + static JSValue _tf_ssb_getAllIdentities(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv) { JSValue result = JS_NewArray(context); @@ -1459,6 +1474,7 @@ void tf_ssb_register(JSContext* context, tf_ssb_t* ssb) JS_SetPropertyStr(context, object, "appendMessageWithIdentity", JS_NewCFunction(context, _tf_ssb_appendMessageWithIdentity, "appendMessageWithIdentity", 3)); /* Does not require an identity. */ + JS_SetPropertyStr(context, object, "getServerIdentity", JS_NewCFunction(context, _tf_ssb_getServerIdentity, "getServerIdentity", 0)); JS_SetPropertyStr(context, object, "getAllIdentities", JS_NewCFunction(context, _tf_ssb_getAllIdentities, "getAllIdentities", 0)); JS_SetPropertyStr(context, object, "getMessage", JS_NewCFunction(context, _tf_ssb_getMessage, "getMessage", 2)); JS_SetPropertyStr(context, object, "blobGet", JS_NewCFunction(context, _tf_ssb_blobGet, "blobGet", 1));