Compare commits
3 Commits
86751362cb
...
82d1a294a6
Author | SHA1 | Date | |
---|---|---|---|
82d1a294a6 | |||
de20274589 | |||
2f193e64c8 |
@ -182,7 +182,11 @@ class TfComposeElement extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
document.execCommand('insertText', false, event.clipboardData.getData('text/plain'));
|
document.execCommand(
|
||||||
|
'insertText',
|
||||||
|
false,
|
||||||
|
event.clipboardData.getData('text/plain')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
@ -29,7 +29,10 @@ class TfReactionsModalElement extends LitElement {
|
|||||||
style="display: block; box-sizing: border-box"
|
style="display: block; box-sizing: border-box"
|
||||||
@click=${this.clear}
|
@click=${this.clear}
|
||||||
>
|
>
|
||||||
<div class="w3-modal-content w3-card-4 w3-theme-d1" onclick="event.stopPropagation()">
|
<div
|
||||||
|
class="w3-modal-content w3-card-4 w3-theme-d1"
|
||||||
|
onclick="event.stopPropagation()"
|
||||||
|
>
|
||||||
<div class="w3-container w3-padding">
|
<div class="w3-container w3-padding">
|
||||||
<header class="w3-container">
|
<header class="w3-container">
|
||||||
<h2>Reactions</h2>
|
<h2>Reactions</h2>
|
||||||
|
@ -172,11 +172,7 @@ async function socket(request, response, client) {
|
|||||||
0x1
|
0x1
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
process = await core.getProcessBlob(
|
process = await core.getProcessBlob(blobId, sessionId, options);
|
||||||
blobId,
|
|
||||||
sessionId,
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process) {
|
if (process) {
|
||||||
|
@ -335,9 +335,9 @@ async function getProcessBlob(blobId, key, options) {
|
|||||||
settings.userPermissions[user] &&
|
settings.userPermissions[user] &&
|
||||||
settings.userPermissions[user][options.packageOwner]
|
settings.userPermissions[user][options.packageOwner]
|
||||||
) {
|
) {
|
||||||
return settings.userPermissions[user][
|
return settings.userPermissions[user][options.packageOwner][
|
||||||
options.packageOwner
|
options.packageName
|
||||||
][options.packageName];
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
allPermissionsGranted: async function () {
|
allPermissionsGranted: async function () {
|
||||||
|
123
src/main.c
123
src/main.c
@ -48,11 +48,12 @@ struct backtrace_state* g_backtrace_state;
|
|||||||
const char* k_db_path_default = "db.sqlite";
|
const char* k_db_path_default = "db.sqlite";
|
||||||
|
|
||||||
#if !TARGET_OS_IPHONE && !defined(__ANDROID__)
|
#if !TARGET_OS_IPHONE && !defined(__ANDROID__)
|
||||||
static int _tf_command_test(const char* file, int argc, char* argv[]);
|
|
||||||
static int _tf_command_import(const char* file, int argc, char* argv[]);
|
|
||||||
static int _tf_command_export(const char* file, int argc, char* argv[]);
|
static int _tf_command_export(const char* file, int argc, char* argv[]);
|
||||||
|
static int _tf_command_import(const char* file, int argc, char* argv[]);
|
||||||
|
static int _tf_command_publish(const char* file, int argc, char* argv[]);
|
||||||
static int _tf_command_run(const char* file, int argc, char* argv[]);
|
static int _tf_command_run(const char* file, int argc, char* argv[]);
|
||||||
static int _tf_command_sandbox(const char* file, int argc, char* argv[]);
|
static int _tf_command_sandbox(const char* file, int argc, char* argv[]);
|
||||||
|
static int _tf_command_test(const char* file, int argc, char* argv[]);
|
||||||
static int _tf_command_verify(const char* file, int argc, char* argv[]);
|
static int _tf_command_verify(const char* file, int argc, char* argv[]);
|
||||||
static int _tf_command_usage(const char* file);
|
static int _tf_command_usage(const char* file);
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ const command_t k_commands[] = {
|
|||||||
{ "sandbox", _tf_command_sandbox, "Run a sandboxed tildefriends sandbox process (used internally)." },
|
{ "sandbox", _tf_command_sandbox, "Run a sandboxed tildefriends sandbox process (used internally)." },
|
||||||
{ "import", _tf_command_import, "Import apps to SSB." },
|
{ "import", _tf_command_import, "Import apps to SSB." },
|
||||||
{ "export", _tf_command_export, "Export apps from SSB." },
|
{ "export", _tf_command_export, "Export apps from SSB." },
|
||||||
|
{ "publish", _tf_command_publish, "Append a message to a feed." },
|
||||||
{ "verify", _tf_command_verify, "Verify a feed." },
|
{ "verify", _tf_command_verify, "Verify a feed." },
|
||||||
{ "test", _tf_command_test, "Test SSB." },
|
{ "test", _tf_command_test, "Test SSB." },
|
||||||
};
|
};
|
||||||
@ -274,6 +276,121 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
|
|||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _tf_published_callback(const char* id, bool verified, bool stored, void* user_data)
|
||||||
|
{
|
||||||
|
if (verified)
|
||||||
|
{
|
||||||
|
if (stored)
|
||||||
|
{
|
||||||
|
tf_printf("Message %s stored.\n", id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tf_printf("Unable to store the message.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tf_printf("Failed to verify the message.\n");
|
||||||
|
}
|
||||||
|
*(int*)user_data = stored ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _tf_command_publish(const char* file, int argc, char* argv[])
|
||||||
|
{
|
||||||
|
const char* user = NULL;
|
||||||
|
const char* identity = NULL;
|
||||||
|
const char* db_path = k_db_path_default;
|
||||||
|
const char* content = NULL;
|
||||||
|
bool show_usage = false;
|
||||||
|
|
||||||
|
while (!show_usage)
|
||||||
|
{
|
||||||
|
static const struct option k_options[] = {
|
||||||
|
{ "user", required_argument, NULL, 'u' },
|
||||||
|
{ "id", required_argument, NULL, 'i' },
|
||||||
|
{ "db-path", required_argument, NULL, 'd' },
|
||||||
|
{ "content", required_argument, NULL, 'c' },
|
||||||
|
{ "help", no_argument, NULL, 'h' },
|
||||||
|
{ 0 },
|
||||||
|
};
|
||||||
|
int c = getopt_long(argc, argv, "u:i:d:c:h", k_options, NULL);
|
||||||
|
if (c == -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case '?':
|
||||||
|
case 'h':
|
||||||
|
default:
|
||||||
|
show_usage = true;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
user = optarg;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
identity = optarg;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
db_path = optarg;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
content = optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (show_usage || !user || !identity || !content)
|
||||||
|
{
|
||||||
|
tf_printf("\n%s publish [options]\n\n", file);
|
||||||
|
tf_printf("options:\n");
|
||||||
|
tf_printf(" -y, --user user User owning identity with which to publish.\n");
|
||||||
|
tf_printf(" -i, --identity identity Identity with which to publish message.\n");
|
||||||
|
tf_printf(" -d, --db-path db_path SQLite database path (default: %s).\n", k_db_path_default);
|
||||||
|
tf_printf(" -c, --content json JSON content of message to publish.\n");
|
||||||
|
tf_printf(" -h, --help Show this usage information.\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = EXIT_FAILURE;
|
||||||
|
tf_printf("Posting %s as account %s belonging to %s...\n", content, identity, user);
|
||||||
|
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
|
||||||
|
uint8_t private_key[512] = { 0 };
|
||||||
|
if (tf_ssb_db_identity_get_private_key(ssb, user, identity, private_key, sizeof(private_key)))
|
||||||
|
{
|
||||||
|
JSContext* context = tf_ssb_get_context(ssb);
|
||||||
|
int64_t sequence = 0;
|
||||||
|
char previous[k_id_base64_len] = { 0 };
|
||||||
|
tf_ssb_db_get_latest_message_by_author(ssb, identity, &sequence, previous, sizeof(previous));
|
||||||
|
JSValue content_value = JS_ParseJSON(context, content, strlen(content), NULL);
|
||||||
|
if (!JS_IsException(content_value))
|
||||||
|
{
|
||||||
|
JSValue message = tf_ssb_sign_message(ssb, identity, private_key, content_value, previous, sequence);
|
||||||
|
JSValue message_value = JS_JSONStringify(context, message, JS_NULL, JS_NULL);
|
||||||
|
const char* message_str = JS_ToCString(context, message_value);
|
||||||
|
tf_printf("Posting: %s.\n", message_str);
|
||||||
|
tf_ssb_verify_strip_and_store_message(ssb, message, _tf_published_callback, &result);
|
||||||
|
JS_FreeCString(context, message_str);
|
||||||
|
JS_FreeValue(context, message_value);
|
||||||
|
JS_FreeValue(context, message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tf_printf("Unable to parse content as JSON: ");
|
||||||
|
tf_util_report_error(context, content_value);
|
||||||
|
}
|
||||||
|
JS_FreeValue(context, content_value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tf_printf("Did not find private key for identity %s belonging to %s.\n", identity, user);
|
||||||
|
}
|
||||||
|
tf_ssb_destroy(ssb);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static int _tf_command_verify(const char* file, int argc, char* argv[])
|
static int _tf_command_verify(const char* file, int argc, char* argv[])
|
||||||
{
|
{
|
||||||
const char* identity = NULL;
|
const char* identity = NULL;
|
||||||
@ -283,7 +400,7 @@ static int _tf_command_verify(const char* file, int argc, char* argv[])
|
|||||||
while (!show_usage)
|
while (!show_usage)
|
||||||
{
|
{
|
||||||
static const struct option k_options[] = {
|
static const struct option k_options[] = {
|
||||||
{ "id", required_argument, NULL, 'u' },
|
{ "id", required_argument, NULL, 'i' },
|
||||||
{ "db-path", required_argument, NULL, 'd' },
|
{ "db-path", required_argument, NULL, 'd' },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
|
48
src/ssb.c
48
src/ssb.c
@ -698,7 +698,8 @@ static void _tf_ssb_request_activity_timer(uv_timer_t* timer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _tf_ssb_connection_get_request_callback(tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t** out_callback, void** out_user_data)
|
static bool _tf_ssb_connection_get_request_callback(
|
||||||
|
tf_ssb_connection_t* connection, int32_t request_number, tf_ssb_rpc_callback_t** out_callback, void** out_user_data, const char** out_name)
|
||||||
{
|
{
|
||||||
if (!connection->requests)
|
if (!connection->requests)
|
||||||
{
|
{
|
||||||
@ -715,6 +716,10 @@ static bool _tf_ssb_connection_get_request_callback(tf_ssb_connection_t* connect
|
|||||||
{
|
{
|
||||||
*out_user_data = request->user_data;
|
*out_user_data = request->user_data;
|
||||||
}
|
}
|
||||||
|
if (out_name)
|
||||||
|
{
|
||||||
|
*out_name = request->name;
|
||||||
|
}
|
||||||
request->last_active = uv_now(connection->ssb->loop);
|
request->last_active = uv_now(connection->ssb->loop);
|
||||||
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
if (uv_timer_get_due_in(&connection->ssb->request_activity_timer) == 0)
|
||||||
{
|
{
|
||||||
@ -838,6 +843,7 @@ void tf_ssb_connection_remove_request(tf_ssb_connection_t* connection, int32_t r
|
|||||||
bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, const uint8_t* message, size_t size,
|
bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, const char* new_request_name, const uint8_t* message, size_t size,
|
||||||
tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data)
|
tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data)
|
||||||
{
|
{
|
||||||
|
const char* request_name = "<unknown>";
|
||||||
if (!connection)
|
if (!connection)
|
||||||
{
|
{
|
||||||
if (cleanup)
|
if (cleanup)
|
||||||
@ -849,10 +855,10 @@ bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
|||||||
if (flags & k_ssb_rpc_flag_new_request)
|
if (flags & k_ssb_rpc_flag_new_request)
|
||||||
{
|
{
|
||||||
assert(request_number > 0);
|
assert(request_number > 0);
|
||||||
assert(!_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL));
|
assert(!_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL, NULL));
|
||||||
assert(new_request_name);
|
assert(new_request_name);
|
||||||
}
|
}
|
||||||
else if (!_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL))
|
else if (!_tf_ssb_connection_get_request_callback(connection, request_number, NULL, NULL, &request_name))
|
||||||
{
|
{
|
||||||
if (flags & k_ssb_rpc_flag_binary)
|
if (flags & k_ssb_rpc_flag_binary)
|
||||||
{
|
{
|
||||||
@ -874,9 +880,9 @@ bool tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
|||||||
memcpy(combined + 1 + 2 * sizeof(uint32_t), message, size);
|
memcpy(combined + 1 + 2 * sizeof(uint32_t), message, size);
|
||||||
if (connection->ssb->verbose)
|
if (connection->ssb->verbose)
|
||||||
{
|
{
|
||||||
tf_printf(MAGENTA "%s RPC SEND" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B] %.*s\n", connection->name, (flags & k_ssb_rpc_flag_end_error) ? "true" : "false",
|
tf_printf(MAGENTA "%s RPC SEND[%s]" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B] %.*s\n", connection->name, request_name,
|
||||||
(flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type], request_number, size,
|
(flags & k_ssb_rpc_flag_end_error) ? "true" : "false", (flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type],
|
||||||
(flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary ? 0 : (int)size, message);
|
request_number, size, (flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary ? 0 : (int)size, message);
|
||||||
}
|
}
|
||||||
_tf_ssb_connection_add_debug_message(connection, true, flags & k_ssb_rpc_mask_send, request_number, message, size);
|
_tf_ssb_connection_add_debug_message(connection, true, flags & k_ssb_rpc_mask_send, request_number, message, size);
|
||||||
_tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size);
|
_tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size);
|
||||||
@ -1613,21 +1619,22 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
}
|
}
|
||||||
else if (flags & k_ssb_rpc_flag_json)
|
else if (flags & k_ssb_rpc_flag_json)
|
||||||
{
|
{
|
||||||
char id[k_id_base64_len] = "";
|
tf_ssb_rpc_callback_t* callback = NULL;
|
||||||
tf_ssb_id_bin_to_str(id, sizeof(id), connection->serverpub);
|
void* user_data = NULL;
|
||||||
|
const char* request_name = "<unknown>";
|
||||||
|
bool have_request = _tf_ssb_connection_get_request_callback(connection, -request_number, &callback, &user_data, &request_name);
|
||||||
if (connection->ssb->verbose)
|
if (connection->ssb->verbose)
|
||||||
{
|
{
|
||||||
tf_printf(CYAN "%s RPC RECV" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B] %.*s\n", connection->name, (flags & k_ssb_rpc_flag_end_error) ? "true" : "false",
|
tf_printf(CYAN "%s RPC RECV[%s]" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B] %.*s\n", connection->name, request_name,
|
||||||
(flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type], request_number, size, (int)size, message);
|
(flags & k_ssb_rpc_flag_end_error) ? "true" : "false", (flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type],
|
||||||
|
request_number, size, (int)size, message);
|
||||||
}
|
}
|
||||||
JSContext* context = connection->ssb->context;
|
JSContext* context = connection->ssb->context;
|
||||||
JSValue val = JS_ParseJSON(context, (const char*)message, size, NULL);
|
JSValue val = JS_ParseJSON(context, (const char*)message, size, NULL);
|
||||||
|
|
||||||
if (!JS_IsUndefined(val))
|
if (!JS_IsUndefined(val))
|
||||||
{
|
{
|
||||||
tf_ssb_rpc_callback_t* callback = NULL;
|
if (have_request)
|
||||||
void* user_data = NULL;
|
|
||||||
if (_tf_ssb_connection_get_request_callback(connection, -request_number, &callback, &user_data))
|
|
||||||
{
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
@ -1680,14 +1687,17 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t
|
|||||||
}
|
}
|
||||||
else if ((flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary)
|
else if ((flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary)
|
||||||
{
|
{
|
||||||
if (connection->ssb->verbose)
|
|
||||||
{
|
|
||||||
tf_printf(CYAN "%s RPC RECV" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B]\n", connection->name, (flags & k_ssb_rpc_flag_end_error) ? "true" : "false",
|
|
||||||
(flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type], request_number, size);
|
|
||||||
}
|
|
||||||
tf_ssb_rpc_callback_t* callback = NULL;
|
tf_ssb_rpc_callback_t* callback = NULL;
|
||||||
void* user_data = NULL;
|
void* user_data = NULL;
|
||||||
if (_tf_ssb_connection_get_request_callback(connection, -request_number, &callback, &user_data))
|
const char* request_name = "<unknown>";
|
||||||
|
bool have_request = _tf_ssb_connection_get_request_callback(connection, -request_number, &callback, &user_data, &request_name);
|
||||||
|
if (connection->ssb->verbose)
|
||||||
|
{
|
||||||
|
tf_printf(CYAN "%s RPC RECV[%s]" RESET " end/error=%s stream=%s type=%s RN=%d: [%zd B]\n", connection->name, request_name,
|
||||||
|
(flags & k_ssb_rpc_flag_end_error) ? "true" : "false", (flags & k_ssb_rpc_flag_stream) ? "true" : "false", k_ssb_type_names[flags & k_ssb_rpc_mask_type],
|
||||||
|
request_number, size);
|
||||||
|
}
|
||||||
|
if (have_request)
|
||||||
{
|
{
|
||||||
if (callback)
|
if (callback)
|
||||||
{
|
{
|
||||||
|
@ -1530,7 +1530,7 @@ static void _tf_task_run_jobs_async(uv_async_t* async)
|
|||||||
|
|
||||||
void tf_task_check_jobs(tf_task_t* task)
|
void tf_task_check_jobs(tf_task_t* task)
|
||||||
{
|
{
|
||||||
if (JS_IsJobPending(task->_runtime))
|
if (task && JS_IsJobPending(task->_runtime))
|
||||||
{
|
{
|
||||||
uv_async_send(&task->run_jobs_async);
|
uv_async_send(&task->run_jobs_async);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ void tf_taskstub_startup()
|
|||||||
JS_NewClassID(&_classId);
|
JS_NewClassID(&_classId);
|
||||||
size_t size = sizeof(_executable);
|
size_t size = sizeof(_executable);
|
||||||
uv_exepath(_executable, &size);
|
uv_exepath(_executable, &size);
|
||||||
tf_printf("exepath is %s\n", _executable);
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user