Skip to content

Commit bb1184e

Browse files
authored
Merge branch 'main' into feat/no-ref/blind_version_sign_request
2 parents f6ab450 + 8aef9d0 commit bb1184e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2277
-258
lines changed

.github/workflows/test.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
- dev
7+
pull_request:
8+
branches:
9+
- main
810

911
concurrency:
1012
group: ${{ github.workflow }}
@@ -13,6 +15,7 @@ concurrency:
1315
jobs:
1416
build:
1517
runs-on: ${{ matrix.os }}
18+
1619
strategy:
1720
fail-fast: false
1821
matrix:
@@ -47,6 +50,13 @@ jobs:
4750
run: |
4851
yarn global add node-gyp@latest
4952
53+
# - name: sed it
54+
# if: runner.os == 'Windows'
55+
# shell: bash
56+
# run: |
57+
# sed -i "s/target_compile_options(oxen-logging-warnings INTERFACE/#target_compile_options(oxen-logging-warnings INTERFACE/" libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt
58+
# cat libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt
59+
5060
- name: build libsession-util-nodejs
5161
shell: bash
52-
run: yarn install --frozen-lockfile --network-timeout 600000
62+
run: yarn install --frozen-lockfile

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
/package-lock.json
1010
/compile_commands.json
1111
/.cache
12+
.yarn/
13+
*.cjs
14+
*.mjs
15+

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "libsession-util"]
22
path = libsession-util
3-
url = https://github.com/oxen-io/libsession-util.git
3+
url = https://github.com/session-foundation/libsession-util.git

.yarnrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
patchFolder: patches

CMakeLists.txt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
66

77
set(VERBOSE ON)
88

9+
# Detect the number of processors
10+
include(ProcessorCount)
11+
ProcessorCount(N)
12+
13+
# Set a default value in case the detection fails
14+
if(NOT N EQUAL 0)
15+
set(CMAKE_BUILD_PARALLEL_LEVEL ${N})
16+
else()
17+
set(CMAKE_BUILD_PARALLEL_LEVEL 4) # Fallback to 16 if detection fails
18+
endif()
19+
message(STATUS "Number of processors detected: ${N}")
20+
21+
922
add_definitions(-DNAPI_VERSION=8)
1023
set(CMAKE_CONFIGURATION_TYPES Release)
1124

@@ -15,11 +28,15 @@ SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1528
SET(CMAKE_BUILD_TYPE Release)
1629
SET(WITH_TESTS OFF)
1730

18-
set(CMAKE_CXX_STANDARD 17)
31+
set(CMAKE_CXX_STANDARD 20)
1932
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2033
set(CMAKE_CXX_EXTENSIONS OFF)
2134

22-
file(GLOB SOURCE_FILES src/*.cpp)
35+
# when building from a release of libsession on desktop, it complains that ios-cmake is not up to date
36+
# as it is not part of the archive. We actually don't care about it on session-desktop
37+
set(SUBMODULE_CHECK OFF)
38+
39+
file(GLOB SOURCE_FILES src/*.cpp src/groups/*.cpp src/multi_encrypt/*.cpp)
2340

2441
add_subdirectory(libsession-util)
2542

@@ -33,7 +50,7 @@ add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
3350
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} "node_modules/node-addon-api" "../../node_modules/node-addon-api" "node_modules/node-api-headers/include" "../../node_modules/node-api-headers/include")
3451

3552
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
36-
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB} libsession::config libsession::crypto)
53+
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB} ${LIBSESSION_STATIC_BUNDLE_LIBS})
3754

3855
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
3956
# Generate node.lib

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Clone this project to somewhere **not** part of `session-desktop` node_modules:
1616

1717
```
1818
cd [FOLDER_NOT_IN_SESSION_DESKTOP]
19-
git clone --recursive [email protected]:oxen-io/libsession-util-nodejs.git
19+
git clone --recursive [email protected]:session-foundation/libsession-util-nodejs.git
2020
```
2121

2222
Always do your changes in `[FOLDER_NOT_IN_SESSION_DESKTOP]/libsession-util-nodejs`, never in the one under session-desktop's `node_modules` as you might override your local changes.
@@ -31,7 +31,7 @@ Replace `[SESSION_DESKTOP_PATH]` with the full path to your `session-desktop` fo
3131

3232
Every part of this command is needed and might need to be updated using your paths. Also, the `worker:libsession` needs to be recompiled too to include the just created .node file in itself. This is done by the `yarn build:workers` command.
3333

34-
Note: The `electron` property in the `config` object will need to be updated in the `package.json` every time we update `electron` package in [session-desktop](https://github.com/oxen-io/session-desktop/) so that the versions match. It is a node version, but not part of the official node docs. If you compiled the node module for an incorrect electron/node version you will get an error on `session-desktop` start.
34+
Note: The `electron` property in the `config` object will need to be updated in the `package.json` every time we update `electron` package in [session-desktop](https://github.com/session-foundation/session-desktop/) so that the versions match. It is a node version, but not part of the official node docs. If you compiled the node module for an incorrect electron/node version you will get an error on `session-desktop` start.
3535

3636
### Making a Release and updating Session-desktop
3737

@@ -71,7 +71,7 @@ Once this is done, update the dependency on `session-desktop`.
7171
Make sure to remove the existing one first (with the include `yarn remove` below) as you might have messed up your `node_modules` doing the dev instructions.
7272

7373
```
74-
yarn remove libsession_util_nodejs && yarn add https://github.com/oxen-io/libsession-util-nodejs/releases/download/v0.1.15/libsession_util_nodejs-v0.1.15.tar.gz
74+
yarn remove libsession_util_nodejs && yarn add https://github.com/session-foundation/libsession-util-nodejs/releases/download/v0.1.15/libsession_util_nodejs-v0.1.15.tar.gz
7575
```
7676

7777
Keep in mind that you need to update the two version numbers (e.g. `0.1.15`) to the just created release version of this project.

index.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
/// <reference path="./shared.d.ts" />
2-
/// <reference path="./user/index.d.ts" />
1+
32
/// <reference path="./types/index.d.ts" />
43

54
declare module 'libsession_util_nodejs' {
@@ -10,7 +9,7 @@ declare module 'libsession_util_nodejs' {
109
* - one side are calls made by the webworker directly to the wrapper
1110
* - the other side are calls made by the renderer to the webworker (which should forward them to the wrapper)
1211
*
13-
* We cannot pass unserializable data between those two, so we need to have a serializable way of calling one
12+
* We cannot pass non serializable data between those two, so we need to have a serializable way of calling one
1413
* method of a wrapper with the required arguments.
1514
* Those serializable data, are `UserConfigActionsType` or just any of the `*ActionsType`. They are defined with a tuple of what each methods accepts on which wrapper with which argument.
1615
*

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22
"main": "index.js",
33
"name": "libsession_util_nodejs",
44
"description": "Wrappers for the Session Util Library",
5-
"version": "0.3.23",
5+
"version": "0.4.5",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",
99
"email": "[email protected]"
1010
},
1111
"scripts": {
1212
"clean": "rimraf .cache build",
13-
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF"
13+
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF --CDWITH_TESTS=OFF"
1414
},
1515
"devDependencies": {
1616
"clang-format": "^1.8.0",
1717
"rimraf": "2.6.2"
1818
},
1919
"dependencies": {
20-
"cmake-js": "^7.2.1",
20+
"cmake-js": "7.2.1",
2121
"node-addon-api": "^6.1.0"
2222
},
23-
"typings": "index.d.ts"
24-
}
23+
"typings": "index.d.ts",
24+
"packageManager": "[email protected]"
25+
}

shared.d.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/addon.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@
44
#include "constants.hpp"
55
#include "contacts_config.hpp"
66
#include "convo_info_volatile_config.hpp"
7+
#include "groups/meta_group_wrapper.hpp"
8+
#include "multi_encrypt/multi_encrypt.hpp"
79
#include "user_config.hpp"
810
#include "user_groups_config.hpp"
911

1012
Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
1113
using namespace session::nodeapi;
12-
1314
ConstantsWrapper::Init(env, exports);
15+
16+
// Group wrappers init
17+
MetaGroupWrapper::Init(env, exports);
18+
19+
// User wrappers init
1420
UserConfigWrapper::Init(env, exports);
1521
ContactsConfigWrapper::Init(env, exports);
1622
UserGroupsWrapper::Init(env, exports);
1723
ConvoInfoVolatileWrapper::Init(env, exports);
1824

1925
// Fully static wrappers init
26+
MultiEncryptWrapper::Init(env, exports);
2027
BlindingWrapper::Init(env, exports);
2128

2229
return exports;

src/base_config.cpp

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,17 @@ Napi::Value ConfigBaseImpl::needsPush(const Napi::CallbackInfo& info) {
1515
return wrapResult(info, [&] { return get_config<ConfigBase>().needs_push(); });
1616
}
1717

18-
Napi::Value ConfigBaseImpl::storageNamespace(const Napi::CallbackInfo& info) {
19-
return wrapResult(info, [&] {
20-
return static_cast<uint16_t>(get_config<ConfigBase>().storage_namespace());
21-
});
22-
}
23-
2418
Napi::Value ConfigBaseImpl::currentHashes(const Napi::CallbackInfo& info) {
2519
return wrapResult(info, [&] { return (get_config<ConfigBase>().current_hashes()); });
2620
}
2721

2822
Napi::Value ConfigBaseImpl::push(const Napi::CallbackInfo& info) {
2923
return wrapResult(info, [&]() {
3024
assertInfoLength(info, 0);
31-
auto [seqno, to_push, hashes] = get_config<ConfigBase>().push();
25+
auto& conf = get_config<ConfigBase>();
26+
auto to_push = conf.push();
3227

33-
auto env = info.Env();
34-
Napi::Object result = Napi::Object::New(env);
35-
result["data"] = toJs(env, to_push);
36-
result["seqno"] = toJs(env, seqno);
37-
result["hashes"] = toJs(env, hashes);
38-
39-
return result;
28+
return push_result_to_JS(info.Env(), to_push, conf.storage_namespace());
4029
});
4130
}
4231

@@ -47,10 +36,17 @@ Napi::Value ConfigBaseImpl::dump(const Napi::CallbackInfo& info) {
4736
});
4837
}
4938

39+
Napi::Value ConfigBaseImpl::makeDump(const Napi::CallbackInfo& info) {
40+
return wrapResult(info, [&]() {
41+
assertInfoLength(info, 0);
42+
return get_config<ConfigBase>().make_dump();
43+
});
44+
}
45+
5046
void ConfigBaseImpl::confirmPushed(const Napi::CallbackInfo& info) {
5147
return wrapResult(info, [&]() {
5248
assertInfoLength(info, 2);
53-
assertIsNumber(info[0]);
49+
assertIsNumber(info[0], "confirmPushed");
5450
assertIsString(info[1]);
5551

5652
get_config<ConfigBase>().confirm_pushed(

0 commit comments

Comments
 (0)