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 11
11
12
12
Napi::Object InitAll (Napi::Env env, Napi::Object exports) {
13
13
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
+
14
25
ConstantsWrapper::Init (env, exports);
15
26
16
27
// 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) {
48
48
}
49
49
50
50
void ConfigBaseImpl::confirmPushed (const Napi::CallbackInfo& info) {
51
- return wrapResult (info, [&]() {
51
+ return wrapExceptions (info, [&]() {
52
52
assertInfoLength (info, 1 );
53
53
assertIsObject (info[0 ]);
54
54
auto obj = info[0 ].As <Napi::Object>();
55
-
56
55
auto confirmed_pushed_entry = confirm_pushed_entry_from_JS (info.Env (), obj);
57
56
58
57
get_config<ConfigBase>().confirm_pushed (
Original file line number Diff line number Diff line change 5
5
6
6
#include < cassert>
7
7
#include < memory>
8
+ #include < oxen/log.hpp>
8
9
#include < span>
9
10
#include < stdexcept>
10
11
#include < unordered_set>
@@ -101,24 +102,7 @@ class ConfigBaseImpl {
101
102
if (!second.IsEmpty () && !second.IsNull () && !second.IsUndefined ())
102
103
dump = toCppBuffer (second, class_name + " .new" );
103
104
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);
122
106
});
123
107
}
124
108
Original file line number Diff line number Diff line change @@ -232,7 +232,6 @@ Napi::Object decrypt_result_to_JS(
232
232
}
233
233
234
234
confirm_pushed_entry_t confirm_pushed_entry_from_JS (const Napi::Env& env, const Napi::Object& obj) {
235
-
236
235
auto seqnoJsValue = obj.Get (" seqno" );
237
236
assertIsNumber (seqnoJsValue, " confirm_pushed_entry_from_JS.seqno" );
238
237
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" />
2
2
3
3
declare module 'libsession_util_nodejs' {
4
4
type BlindingWrapper = {
Original file line number Diff line number Diff line change 1
- /// <reference path="../../ shared.d.ts" />
1
+ /// <reference path="../shared.d.ts" />
2
2
/// <reference path="./blinding.d.ts" />
Original file line number Diff line number Diff line change
1
+ /// <reference path="./utilities/index.d.ts" />
1
2
/// <reference path="./blinding/index.d.ts" />
2
3
/// <reference path="./groups/index.d.ts" />
3
4
/// <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' {
97
97
export type PubkeyType = `05${string } `; // type of a string which starts by the 05 prefixed used for **legacy** closed group and session ids
98
98
export type BlindedPubkeyType = `15${string } `;
99
99
100
- type MakeGroupActionCall < A extends BaseConfigWrapper , B extends keyof A > = [
100
+ type MakeGroupActionCall < A extends RecordOfFunctions , B extends keyof A > = [
101
101
B ,
102
102
...Parameters < A [ B ] >
103
103
] ; // 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