Yikes. I broke appending?

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4351 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-07-18 00:59:25 +00:00
parent 68ca99e9d9
commit 7fe8f66fd3
2 changed files with 9 additions and 8 deletions

View File

@ -1683,8 +1683,7 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui
{
JS_SetPropertyStr(context, root, "previous", JS_NULL);
}
JSValue authorstr = JS_NewString(context, author);
JS_SetPropertyStr(context, root, "author", authorstr);
JS_SetPropertyStr(context, root, "author", JS_NewString(context, author));
JS_SetPropertyStr(context, root, "sequence", JS_NewInt64(context, previous_sequence + 1));
int64_t now = (int64_t)time(NULL);
@ -1706,9 +1705,6 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui
tf_printf("crypto_sign_detached failed\n");
}
JS_FreeCString(context, json);
JS_FreeValue(context, jsonval);
char signature_base64[crypto_sign_BYTES * 2];
tf_base64_encode(signature, sizeof(signature), signature_base64, sizeof(signature_base64));
strcat(signature_base64, ".sig.ed25519");
@ -1733,6 +1729,8 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui
else
{
tf_printf("Failed to verify message signature.\n");
tf_printf("json = %s\n", json);
tf_printf("sig = %s\n", signature_base64);
}
if (!stored && out_id && out_id_size)
@ -1740,6 +1738,9 @@ bool tf_ssb_append_message_with_keys(tf_ssb_t* ssb, const char* author, const ui
*out_id = '\0';
}
JS_FreeCString(context, json);
JS_FreeValue(context, jsonval);
JS_FreeValue(context, root);
return stored;
}

View File

@ -118,9 +118,9 @@ static JSValue _tf_ssb_appendMessageWithIdentity(JSContext* context, JSValueCons
uint8_t private_key[crypto_sign_SECRETKEYBYTES];
if (tf_ssb_db_identity_get_private_key(ssb, user, id, private_key, sizeof(private_key)))
{
char id[k_id_base64_len] = { 0 };
tf_ssb_append_message_with_keys(ssb, id, private_key, argv[2], id, sizeof(id));
result = JS_NewString(context, id);
char message_id[k_id_base64_len] = { 0 };
tf_ssb_append_message_with_keys(ssb, id, private_key, argv[2], message_id, sizeof(message_id));
result = JS_NewString(context, message_id);
}
else
{