File tree Expand file tree Collapse file tree 10 files changed +43
-24
lines changed Expand file tree Collapse file tree 10 files changed +43
-24
lines changed Original file line number Diff line number Diff line change 1111
1212Napi::Object InitAll (Napi::Env env, Napi::Object exports) {
1313 using namespace session ::nodeapi;
14+
15+ session::add_logger ([env](std::string_view msg) {
16+ std::string toLog = std::string (" libsession-util: " ) + std::string (msg) + " \n " ;
17+
18+ Napi::Function consoleLog =
19+ env.Global ().Get (" console" ).As <Napi::Object>().Get (" log" ).As <Napi::Function>();
20+ consoleLog.Call ({Napi::String::New (env, toLog)});
21+ });
22+
23+ // session::logger_set_level_default(session::LogLevel::debug);
24+
1425 ConstantsWrapper::Init (env, exports);
1526
1627 // Group wrappers init
Original file line number Diff line number Diff line change @@ -48,11 +48,10 @@ Napi::Value ConfigBaseImpl::makeDump(const Napi::CallbackInfo& info) {
4848}
4949
5050void ConfigBaseImpl::confirmPushed (const Napi::CallbackInfo& info) {
51- return wrapResult (info, [&]() {
51+ return wrapExceptions (info, [&]() {
5252 assertInfoLength (info, 1 );
5353 assertIsObject (info[0 ]);
5454 auto obj = info[0 ].As <Napi::Object>();
55-
5655 auto confirmed_pushed_entry = confirm_pushed_entry_from_JS (info.Env (), obj);
5756
5857 get_config<ConfigBase>().confirm_pushed (
Original file line number Diff line number Diff line change 55
66#include < cassert>
77#include < memory>
8+ #include < oxen/log.hpp>
89#include < span>
910#include < stdexcept>
1011#include < unordered_set>
@@ -101,24 +102,7 @@ class ConfigBaseImpl {
101102 if (!second.IsEmpty () && !second.IsNull () && !second.IsUndefined ())
102103 dump = toCppBuffer (second, class_name + " .new" );
103104
104- // return std::make_shared<Config>(secretKey, dump);
105- std::shared_ptr<Config> config = std::make_shared<Config>(secretKey, dump);
106-
107- Napi::Env env = info.Env ();
108-
109- session::add_logger ([env, class_name](auto msg) {
110- std::string toLog =
111- " libsession-util:" + std::string (class_name) + " : " + std::string (msg) + " \n " ;
112-
113- Napi::Function consoleLog = env.Global ()
114- .Get (" console" )
115- .As <Napi::Object>()
116- .Get (" log" )
117- .As <Napi::Function>();
118- consoleLog.Call ({Napi::String::New (env, toLog)});
119- });
120-
121- return config;
105+ return std::make_shared<Config>(secretKey, dump);
122106 });
123107 }
124108
Original file line number Diff line number Diff line change @@ -232,7 +232,6 @@ Napi::Object decrypt_result_to_JS(
232232}
233233
234234confirm_pushed_entry_t confirm_pushed_entry_from_JS (const Napi::Env& env, const Napi::Object& obj) {
235-
236235 auto seqnoJsValue = obj.Get (" seqno" );
237236 assertIsNumber (seqnoJsValue, " confirm_pushed_entry_from_JS.seqno" );
238237 int64_t seqno = toCppInteger (seqnoJsValue, " confirm_pushed_entry_from_JS.seqno" , false );
Original file line number Diff line number Diff line change 1- /// <reference path="../../ shared.d.ts" />
1+ /// <reference path="../shared.d.ts" />
22
33declare module 'libsession_util_nodejs' {
44 type BlindingWrapper = {
Original file line number Diff line number Diff line change 1- /// <reference path="../../ shared.d.ts" />
1+ /// <reference path="../shared.d.ts" />
22/// <reference path="./blinding.d.ts" />
Original file line number Diff line number Diff line change 1+ /// <reference path="./utilities/index.d.ts" />
12/// <reference path="./blinding/index.d.ts" />
23/// <reference path="./groups/index.d.ts" />
34/// <reference path="./multi_encrypt/index.d.ts" />
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ declare module 'libsession_util_nodejs' {
9797 export type PubkeyType = `05${string } `; // type of a string which starts by the 05 prefixed used for **legacy** closed group and session ids
9898 export type BlindedPubkeyType = `15${string } `;
9999
100- type MakeGroupActionCall < A extends BaseConfigWrapper , B extends keyof A > = [
100+ type MakeGroupActionCall < A extends RecordOfFunctions , B extends keyof A > = [
101101 B ,
102102 ...Parameters < A [ B ] >
103103 ] ; // all of the groupActionCalls need the pubkey of the group we are targeting
Original file line number Diff line number Diff line change 1+ /// <reference path="../shared.d.ts" />
2+ /// <reference path="./utilities.d.ts" />
Original file line number Diff line number Diff line change 1+ /// <reference path="../shared.d.ts" />
2+
3+ declare module 'libsession_util_nodejs' {
4+ type UtilitiesWrapper = {
5+ freeAllWrappers : ( ) => void ;
6+ } ;
7+
8+ /**
9+ * To be used inside the web worker only (calls are synchronous and won't work asynchronously)
10+ */
11+ export class UtilitiesWrapperNode {
12+ public static freeAllWrappers : UtilitiesWrapper [ 'freeAllWrappers' ] ;
13+ }
14+
15+ export type UtilitiesWrapperActionsCalls = MakeWrapperActionCalls < UtilitiesWrapper > ;
16+
17+ /**
18+ * Those actions are used internally for the web worker communication.
19+ * You should never need to import them in Session directly
20+ * You will need to add an entry here if you add a new function
21+ */
22+ export type UtilitiesActionsType = MakeActionCall < UtilitiesWrapper , 'freeAllWrappers' > ;
23+ }
You can’t perform that action at this time.
0 commit comments