2021-08-22 15:34:28 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <quickjs.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef struct _tf_ssb_t tf_ssb_t;
|
|
|
|
|
|
|
|
void tf_ssb_db_init(tf_ssb_t* ssb);
|
2022-02-02 21:00:05 -05:00
|
|
|
bool tf_ssb_db_store_message(tf_ssb_t* ssb, JSContext* context, const char* id, JSValue val, const char* signature, bool sequence_before_author);
|
2021-08-22 15:41:27 -04:00
|
|
|
bool tf_ssb_db_message_content_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size);
|
|
|
|
bool tf_ssb_db_blob_get(tf_ssb_t* ssb, const char* id, uint8_t** out_blob, size_t* out_size);
|
|
|
|
bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char* out_id, size_t out_id_size);
|
2021-08-22 15:34:28 -04:00
|
|
|
|
2022-02-11 20:44:11 -05:00
|
|
|
bool tf_ssb_db_get_message_by_author_and_sequence(tf_ssb_t* ssb, const char* author, int64_t sequence, char* out_message_id, size_t out_message_id_size, double* out_timestamp, char** out_content);
|
2021-08-22 15:41:27 -04:00
|
|
|
bool tf_ssb_db_get_latest_message_by_author(tf_ssb_t* ssb, const char* author, int64_t* out_sequence, char* out_message_id, size_t out_message_id_size);
|
2022-04-17 20:24:00 -04:00
|
|
|
JSValue tf_ssb_db_visit_query(tf_ssb_t* ssb, const char* query, const JSValue binds, void (*callback)(JSValue row, void* user_data), void* user_data);
|
2022-02-09 22:58:33 -05:00
|
|
|
|
|
|
|
typedef struct sqlite3 sqlite3;
|
2022-02-10 21:44:27 -05:00
|
|
|
bool tf_ssb_db_check(sqlite3* db, const char* author);
|
2022-07-13 21:01:14 -04:00
|
|
|
|
|
|
|
int tf_ssb_db_identity_get_count_for_user(tf_ssb_t* ssb, const char* user);
|
|
|
|
bool tf_ssb_db_identity_add(tf_ssb_t* ssb, const char* user, const char* public_key, const char* private_key);
|
|
|
|
void tf_ssb_db_identity_visit(tf_ssb_t* ssb, const char* user, void (*callback)(const char* identity, void* user_data), void* user_data);
|
|
|
|
bool tf_ssb_db_identity_get_private_key(tf_ssb_t* ssb, const char* user, const char* public_key, uint8_t* out_private_key, size_t private_key_size);
|