Skip to content

Commit 0ebfa1d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into groups-chunk-2
2 parents 3bcae62 + 027e9e0 commit 0ebfa1d

File tree

10 files changed

+101
-13
lines changed

10 files changed

+101
-13
lines changed

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
.github export-ignore
33
libsession-util/external/libsodium-internal/test export-ignore
44
libsession-util/external/zstd/doc export-ignore
5-
libsession-util/tests export-ignore
6-
libsession-util/external/oxen-encoding/tests export-ignore
75
libsession-util/external/zstd/tests export-ignore
6+
libsession-util/tests export-ignore
87
libsession-util/external/nlohmann-json/tests export-ignore
98
libsession-util/external/nlohmann-json/docs export-ignore
9+
libsession-util/external/oxen-encoding/tests export-ignore

.github/workflows/test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: libession-util-nodejs build test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
9+
concurrency:
10+
group: ${{ github.workflow }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [windows-2022, macos-11, ubuntu-20.04]
20+
env:
21+
SIGNAL_ENV: production
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
steps:
24+
- run: git config --global core.autocrlf false
25+
26+
- name: Checkout git repo
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: 'recursive'
30+
31+
- name: Install node
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version-file: '.nvmrc'
35+
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: '3.11'
39+
40+
- name: Add msbuild to PATH
41+
uses: microsoft/[email protected]
42+
if: runner.os == 'Windows'
43+
44+
- name: Setup node for windows
45+
if: runner.os == 'Windows'
46+
shell: bash
47+
run: |
48+
yarn global add node-gyp@latest
49+
50+
- name: build libsession-util-nodejs
51+
shell: bash
52+
run: yarn install --frozen-lockfile --network-timeout 600000

.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/Bilb/libsession-util.git

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
cmake_minimum_required(VERSION 3.19)
22
cmake_policy(SET CMP0091 NEW)
33
cmake_policy(SET CMP0042 NEW)
4+
cmake_policy(SET CMP0069 NEW)
5+
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
6+
7+
set(VERBOSE ON)
8+
49
add_definitions(-DNAPI_VERSION=8)
10+
set(CMAKE_CONFIGURATION_TYPES Release)
511

612
project(libsession_util_nodejs LANGUAGES CXX)
713

814
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
15+
SET(CMAKE_BUILD_TYPE Release)
16+
SET(WITH_TESTS OFF)
917

1018
set(CMAKE_CXX_STANDARD 17)
1119
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -19,6 +27,7 @@ file(GLOB SOURCE_FILES src/*.cpp src/groups/*.cpp src/multi_encrypt/*.cpp)
1927

2028
add_subdirectory(libsession-util)
2129

30+
2231
if(MSVC)
2332
# Windows is horrible
2433
add_compile_definitions(NOMINMAX)

Readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This library is the wrappers around libsession-util for NodeJS. It is built using the [node-addon-api](https://github.com/nodejs/node-addon-api) and [cmake-js](https://github.com/cmake-js/cmake-js). The build and dev instructions are quite custom, so check them out below.
44

5-
### Issue with Yarn
5+
### Issue with yarn
66

77
The yarn package manager (used on session-desktop) does understand what is a git url in a dependency as part of a package.json file, but won't do a full clone including submodules when forking such a repository. For more details, see https://github.com/yarnpkg/yarn/issues/1488
88

@@ -51,9 +51,12 @@ git commit
5151
git push upstream main
5252
# Make sure you do the steps above, otherwise the tag won't be on the right commit with the `gh release create`
5353
54+
virtualenv venv
55+
source venv/bin/activate
5456
pip install git-archive-all
5557
PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[", ]//g')
56-
git-archive-all libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
58+
echo $PACKAGE_VERSION
59+
python3 build_release_archive.py libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
5760
gh release create v$PACKAGE_VERSION -t v$PACKAGE_VERSION --latest --generate-notes
5861
gh release upload v$PACKAGE_VERSION libsession_util_nodejs-v$PACKAGE_VERSION.tar.gz
5962
```

build_release_archive.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/python3
2+
# -*- coding: utf-8 -*-
3+
import sys
4+
from git_archive_all import main
5+
6+
sys.exit(main())
7+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"email": "[email protected]"
1010
},
1111
"scripts": {
12-
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16"
12+
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF"
1313
},
1414
"devDependencies": {
1515
"clang-format": "^1.8.0"

src/base_config.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,24 @@ class ConfigBaseImpl {
101101
if (!second.IsEmpty() && !second.IsNull() && !second.IsUndefined())
102102
dump = toCppBufferView(second, class_name + ".new");
103103

104-
return std::make_shared<Config>(secretKey, dump);
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+
config->logger = [env, class_name](session::config::LogLevel, std::string_view x) {
110+
std::string toLog =
111+
"libsession-util:" + std::string(class_name) + ": " + std::string(x) + "\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;
105122
});
106123
}
107124

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ has-unicode@^2.0.1:
248248
resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9"
249249
integrity sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==
250250

251-
hasown@^2.0.0:
251+
hasown@^2.0.2:
252252
version "2.0.2"
253253
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003"
254254
integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==
@@ -274,11 +274,11 @@ ini@~1.3.0:
274274
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==
275275

276276
is-core-module@^2.13.0:
277-
version "2.13.1"
278-
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384"
279-
integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==
277+
version "2.14.0"
278+
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.14.0.tgz#43b8ef9f46a6a08888db67b1ffd4ec9e3dfd59d1"
279+
integrity sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==
280280
dependencies:
281-
hasown "^2.0.0"
281+
hasown "^2.0.2"
282282

283283
is-fullwidth-code-point@^3.0.0:
284284
version "3.0.0"

0 commit comments

Comments
 (0)