Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
68bf3f4
feat: add working GroupInfo constructor
Bilb Aug 28, 2023
bc9a98d
feat: add createGroup getGroup and destroyGroup
Bilb Aug 28, 2023
213775f
feat: wip of info and members group
Bilb Aug 30, 2023
ce17ec8
Merge remote-tracking branch 'origin/main' into groups
Bilb Aug 30, 2023
1ba3a4f
feat: wip of groupkeys wrapper
Bilb Aug 31, 2023
e6d7aae
feat: add metagroup wrapper compiling with some methods only
Bilb Aug 31, 2023
14495a3
feat: add start of metagroup wrapper+js bindings
Bilb Sep 4, 2023
786e669
feat: add meta_group wrapper functions exported to JS
Bilb Sep 5, 2023
088fa82
broken state after metagroup dump and load
Bilb Sep 6, 2023
6fb9446
chore: removed useless metabase
Bilb Sep 6, 2023
fbe6c5d
feat: first working version with metagroup wrapper
Bilb Sep 7, 2023
4c83eaf
feat: add groups set, erase and getAll from usergroups
Bilb Sep 7, 2023
e8060f3
feat: add metaMerge for group wrapper
Bilb Sep 14, 2023
d03e55d
feat: add a type for 05 pubkeys and blinded ones
Bilb Sep 15, 2023
02021c1
fix: do not confirmKeys when pushed. wait for poll event
Bilb Sep 18, 2023
9534f51
feat: add encrypt/decrypt and expose make_dump
Bilb Sep 21, 2023
05606d5
fix: compile issues and bump libsession-util
Bilb Oct 3, 2023
d51297f
fix: linking error and remove groupKeys function for now
Bilb Oct 9, 2023
363e21d
chore: pull protobuf branch
Bilb Oct 9, 2023
097e2d2
feat: add makeDump function to configBase calls too
Bilb Oct 10, 2023
d1b7579
feat: libsession merge returns vector of hashes merged now
Bilb Oct 10, 2023
dfa737a
fix: no point of having a shared_ptr for the meta_group
Bilb Oct 13, 2023
60eb5d8
remove: removed unused configsig file
Bilb Oct 13, 2023
9d2697c
chore: address pr reviews
Bilb Oct 18, 2023
5fe572f
chore: remove the fixedlength uint8array as it is not convenient at all
Bilb Oct 19, 2023
b337a95
chore: bump to 0.4.0 for groups
Bilb Oct 27, 2023
373edca
chore: ignore files in archive for release
Bilb Oct 27, 2023
13cb613
feat: add subaccount calls
Bilb Oct 27, 2023
0ad80e5
feat: add subaccount verify and subaccount token
Bilb Nov 2, 2023
9fcc2f0
fix: memberErase takes a list and rekeys, add memberSetAdmin
Bilb Nov 13, 2023
1a1f771
fix: add admin boolean on usergroupget
Bilb Nov 13, 2023
322d3da
feat: add loadAdminKeys for handling incoming promote message
Bilb Nov 16, 2023
88557e2
feat: added kicked and invite pending group state
Bilb Nov 16, 2023
b48defd
group wip
Bilb Dec 5, 2023
2df5c6f
Merge remote-tracking branch 'origin/main' into groups-chunk-2
Bilb Jan 4, 2024
0c22618
fix: add back fixeduint8array type
Bilb Jan 4, 2024
b2cbddb
feat: add convo volatile 03group functions
Bilb Jan 10, 2024
bc1d34f
fix: fix getAllGroups returning empty array
Bilb Jan 18, 2024
420496c
feat: add keyGetAll function
Bilb Mar 14, 2024
22e9d28
chore: bump libsession-util
Bilb Mar 14, 2024
835dc91
feat: add multi encrypt/decrypt simple wrapped functions
Bilb Mar 25, 2024
676c910
feat: add memberPendingAprovals methods
Bilb Apr 16, 2024
56ecc11
Merge branch 'originMain' into groups-chunk-2
Bilb Apr 16, 2024
11bd80a
Merge remote-tracking branch 'origin/main' into groups-chunk-2
Bilb Apr 18, 2024
225b5ba
feat: finished up multi encrypt/decrypt logic
Bilb May 22, 2024
a8dd0e5
fix: track hashes of all group wrappers
Bilb Jun 13, 2024
2513820
fix: gen supplemental keys once for all new members
Bilb Jun 13, 2024
3bcae62
feat: update libsession-util to latest dev
Bilb Jun 13, 2024
0ebfa1d
Merge remote-tracking branch 'upstream/main' into groups-chunk-2
Bilb Jun 26, 2024
156f340
fix: test with libsession-util not of libquic
Bilb Jun 28, 2024
50b9a31
fix: fix build without onionreq
Bilb Jun 28, 2024
f4985cc
feat: keep groupPk/secKey in metagroup for debugging purposes if needed
Bilb Jul 3, 2024
737a3e4
bump libsesison-util with dirty hack to make dump work as expected
Bilb Jul 5, 2024
945b66d
feat: add keys for group when provided for easier debugging
Bilb Jul 8, 2024
52bd57f
fix: do not get_or_construct except when excplicitely being called
Bilb Jul 9, 2024
760fffc
feat: add keysAdmin and memberConstruct&Set
Bilb Jul 24, 2024
04cf81e
feat: move back from libquic branch, for now
Bilb Aug 7, 2024
81e191c
feat: break down set promotion&invite setters
Bilb Aug 7, 2024
7b126e5
Merge remote-tracking branch 'upstream/main' into groups-chunk-2
Bilb Sep 30, 2024
adbb3ce
chore: pull latest libsession-util and fix typo
Bilb Oct 29, 2024
6820f4a
feat: memberStatus instead of a bunch of bools for libsession state
Bilb Nov 12, 2024
3134efa
chore: fetch latest libsession-util dev
Bilb Nov 12, 2024
d421a73
chore: change submodule of libsession-util to foundation's
Bilb Nov 13, 2024
f72a970
chore: move to session-foundation
Bilb Nov 17, 2024
c2793b5
fix: memberStatus priority custom enum was incorrect
Bilb Nov 17, 2024
873c63b
fix: add enum for removedStatus too
Bilb Nov 17, 2024
d6c00f9
chore: bump to 0.4.4
Bilb Nov 18, 2024
15151d7
chore: address PR reviews
Bilb Nov 19, 2024
240f77c
Merge remote-tracking branch 'upstream/main' into groups-chunk-2
Bilb Nov 19, 2024
1911a48
fix: disable sed on windows as not needed without libquic branch
Bilb Nov 19, 2024
771f343
fix: windows build
Bilb Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrency:
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -49,6 +50,13 @@ jobs:
run: |
yarn global add node-gyp@latest

# - name: sed it
# if: runner.os == 'Windows'
# shell: bash
# run: |
# 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
# cat libsession-util/external/oxen-libquic/external/oxen-logging/CMakeLists.txt

- name: build libsession-util-nodejs
shell: bash
run: yarn install --frozen-lockfile --network-timeout 600000
run: yarn install --frozen-lockfile
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
/package-lock.json
/compile_commands.json
/.cache
.yarn/
*.cjs
*.mjs

2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "libsession-util"]
path = libsession-util
url = https://github.com/oxen-io/libsession-util.git
url = https://github.com/session-foundation/libsession-util.git
1 change: 0 additions & 1 deletion .yarnrc

This file was deleted.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

patchFolder: patches
23 changes: 20 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)

set(VERBOSE ON)

# Detect the number of processors
include(ProcessorCount)
ProcessorCount(N)

# Set a default value in case the detection fails
if(NOT N EQUAL 0)
set(CMAKE_BUILD_PARALLEL_LEVEL ${N})
else()
set(CMAKE_BUILD_PARALLEL_LEVEL 4) # Fallback to 16 if detection fails
endif()
message(STATUS "Number of processors detected: ${N}")


add_definitions(-DNAPI_VERSION=8)
set(CMAKE_CONFIGURATION_TYPES Release)

Expand All @@ -15,11 +28,15 @@ SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_BUILD_TYPE Release)
SET(WITH_TESTS OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

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

file(GLOB SOURCE_FILES src/*.cpp src/groups/*.cpp src/multi_encrypt/*.cpp)

add_subdirectory(libsession-util)

Expand All @@ -33,7 +50,7 @@ add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
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")

set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB} libsession::config libsession::crypto)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB} ${LIBSESSION_STATIC_BUNDLE_LIBS})

if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
# Generate node.lib
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Clone this project to somewhere **not** part of `session-desktop` node_modules:

```
cd [FOLDER_NOT_IN_SESSION_DESKTOP]
git clone --recursive git@github.com:oxen-io/libsession-util-nodejs.git
git clone --recursive git@github.com:session-foundation/libsession-util-nodejs.git
```

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.
Expand All @@ -31,7 +31,7 @@ Replace `[SESSION_DESKTOP_PATH]` with the full path to your `session-desktop` fo

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.

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.
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.

### Making a Release and updating Session-desktop

Expand Down Expand Up @@ -71,7 +71,7 @@ Once this is done, update the dependency on `session-desktop`.
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.

```
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
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
```

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.
Expand Down
5 changes: 2 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference path="./shared.d.ts" />
/// <reference path="./user/index.d.ts" />

/// <reference path="./types/index.d.ts" />

declare module 'libsession_util_nodejs' {
Expand All @@ -10,7 +9,7 @@ declare module 'libsession_util_nodejs' {
* - one side are calls made by the webworker directly to the wrapper
* - the other side are calls made by the renderer to the webworker (which should forward them to the wrapper)
*
* We cannot pass unserializable data between those two, so we need to have a serializable way of calling one
* We cannot pass non serializable data between those two, so we need to have a serializable way of calling one
* method of a wrapper with the required arguments.
* 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.
*
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
"main": "index.js",
"name": "libsession_util_nodejs",
"description": "Wrappers for the Session Util Library",
"version": "0.3.23",
"version": "0.4.4",
"license": "GPL-3.0",
"author": {
"name": "Oxen Project",
"email": "team@oxen.io"
},
"scripts": {
"clean": "rimraf .cache build",
"install": "cmake-js compile --runtime=electron --runtime-version=25.8.4 -p16 --CDSUBMODULE_CHECK=OFF --CDLOCAL_MIRROR=https://oxen.rocks/deps --CDENABLE_ONIONREQ=OFF"
"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"
},
"devDependencies": {
"clang-format": "^1.8.0",
"rimraf": "2.6.2"
},
"dependencies": {
"cmake-js": "^7.2.1",
"cmake-js": "7.2.1",
"node-addon-api": "^6.1.0"
},
"typings": "index.d.ts"
}
"typings": "index.d.ts",
"packageManager": "yarn@1.22.19"
}
83 changes: 0 additions & 83 deletions shared.d.ts

This file was deleted.

9 changes: 8 additions & 1 deletion src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
#include "constants.hpp"
#include "contacts_config.hpp"
#include "convo_info_volatile_config.hpp"
#include "groups/meta_group_wrapper.hpp"
#include "multi_encrypt/multi_encrypt.hpp"
#include "user_config.hpp"
#include "user_groups_config.hpp"

Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
using namespace session::nodeapi;

ConstantsWrapper::Init(env, exports);

// Group wrappers init
MetaGroupWrapper::Init(env, exports);

// User wrappers init
UserConfigWrapper::Init(env, exports);
ContactsConfigWrapper::Init(env, exports);
UserGroupsWrapper::Init(env, exports);
ConvoInfoVolatileWrapper::Init(env, exports);

// Fully static wrappers init
MultiEncryptWrapper::Init(env, exports);
BlindingWrapper::Init(env, exports);

return exports;
Expand Down
26 changes: 11 additions & 15 deletions src/base_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,17 @@ Napi::Value ConfigBaseImpl::needsPush(const Napi::CallbackInfo& info) {
return wrapResult(info, [&] { return get_config<ConfigBase>().needs_push(); });
}

Napi::Value ConfigBaseImpl::storageNamespace(const Napi::CallbackInfo& info) {
return wrapResult(info, [&] {
return static_cast<uint16_t>(get_config<ConfigBase>().storage_namespace());
});
}

Napi::Value ConfigBaseImpl::currentHashes(const Napi::CallbackInfo& info) {
return wrapResult(info, [&] { return (get_config<ConfigBase>().current_hashes()); });
}

Napi::Value ConfigBaseImpl::push(const Napi::CallbackInfo& info) {
return wrapResult(info, [&]() {
assertInfoLength(info, 0);
auto [seqno, to_push, hashes] = get_config<ConfigBase>().push();
auto& conf = get_config<ConfigBase>();
auto to_push = conf.push();

auto env = info.Env();
Napi::Object result = Napi::Object::New(env);
result["data"] = toJs(env, to_push);
result["seqno"] = toJs(env, seqno);
result["hashes"] = toJs(env, hashes);

return result;
return push_result_to_JS(info.Env(), to_push, conf.storage_namespace());
});
}

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

Napi::Value ConfigBaseImpl::makeDump(const Napi::CallbackInfo& info) {
return wrapResult(info, [&]() {
assertInfoLength(info, 0);
return get_config<ConfigBase>().make_dump();
});
}

void ConfigBaseImpl::confirmPushed(const Napi::CallbackInfo& info) {
return wrapResult(info, [&]() {
assertInfoLength(info, 2);
assertIsNumber(info[0]);
assertIsNumber(info[0], "confirmPushed");
assertIsString(info[1]);

get_config<ConfigBase>().confirm_pushed(
Expand Down
Loading
Loading