Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f5384c3
feat: add 1o1 encrypt
Bilb Oct 15, 2025
ab784e8
feat: added encode for a bunch for other destinations
Bilb Oct 15, 2025
9ffcc9d
feat: add working encryption for groups & communities
Bilb Oct 16, 2025
c055c5f
feat: added decrypt for community wrapping
Bilb Oct 20, 2025
74193c6
feat: added serverId to decryptCommunity
Bilb Oct 20, 2025
d25efc8
chore: fetch latest commit from doyle fork
Bilb Oct 20, 2025
43ee42f
fix: decrypt for 1o1 work as expected
Bilb Oct 21, 2025
1b8b269
feat: add decryptForGroup through MultiEncrypt
Bilb Oct 21, 2025
ebcb599
feat: add pro url constants
Aerilym Oct 23, 2025
16a256d
feat: add pro provider constants
Aerilym Oct 23, 2025
3ac1e0e
chore: create pro types
Aerilym Oct 23, 2025
78a46bb
chore: update libsession version
Aerilym Oct 23, 2025
a2007db
fix: add store other to nil
Aerilym Oct 23, 2025
70a4cc3
chore: fix space
Aerilym Oct 23, 2025
4072aab
Merge pull request #34 from session-foundation/aerilym/feat-app-pro-b…
Bilb Oct 23, 2025
5891fc3
feat: added generate master pro key & get/set pro config
Bilb Oct 23, 2025
c3bad38
Merge remote-tracking branch 'upstream/feat-add-pro-backend-fns' into…
Bilb Oct 23, 2025
a6bfefb
chore: cleanup
Bilb Oct 23, 2025
d603683
Merge pull request #35 from session-foundation/bilb/feat-add-pro-back…
Bilb Oct 23, 2025
fa808f1
feat: add pro utf stuff and move it to its own wrapper
Bilb Oct 24, 2025
94e4144
chore: fix import for session-desktop
Bilb Oct 24, 2025
fa8daef
Merge pull request #36 from session-foundation/bilb/feat-add-pro-back…
Bilb Oct 24, 2025
4980e28
fix: add proFeaturesForMessage linking
Bilb Oct 26, 2025
bfd89aa
chore: lint with clang format our files
Bilb Oct 26, 2025
f1bc003
chore: copy changes to work on clangd
Bilb Oct 27, 2025
56a0f57
chore: use clang-format-19 as libsession-util
Bilb Oct 27, 2025
61e0d1a
Merge pull request #37 from session-foundation/bilb/feat-add-pro-back…
Bilb Oct 27, 2025
38bb785
chore: fix build for clangd
Bilb Oct 27, 2025
2064c97
chore: run CI on our `dev` branch too
Bilb Oct 27, 2025
655738a
Merge pull request #39 from session-foundation/fix-build-clangd
Bilb Oct 27, 2025
dfd8373
feat: create pro backend wrapper for getting pro proofs
Aerilym Oct 27, 2025
0ac8165
fix: use buffer view for rotating key
Aerilym Oct 27, 2025
1ac97e8
fix: use new build_to_json method to construct proof request wrapper
Aerilym Oct 29, 2025
ce4429a
chore: add types for pro proof request
Aerilym Oct 29, 2025
195eda7
chore: return early with pro proof wrapper
Aerilym Oct 29, 2025
29699f6
Merge pull request #41 from session-foundation/feat/pro-backend-wrappers
Bilb Oct 29, 2025
60f407b
chore: update libsession-util so that build is passing
Bilb Oct 29, 2025
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
25 changes: 20 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- main
- feat-add-pro-backend-fns
pull_request:
branches:
- main
- feat-add-pro-backend-fns

concurrency:
group: ${{ github.workflow }}
Expand All @@ -19,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-13, macos-14, ubuntu-22.04]
os: [windows-2022, macos-13, macos-14, ubuntu-24.04]
env:
SIGNAL_ENV: production
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -29,16 +31,21 @@ jobs:
- name: Checkout git repo
uses: actions/checkout@v4
with:
submodules: 'recursive'
submodules: "recursive"

- name: Install correct clang versions
if: runner.os == 'Linux'
run: sudo apt update && sudo apt search clang && sudo apt install clang-format-19 #clang-tidy-19
shell: bash

- name: Install node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
node-version-file: ".nvmrc"

- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.3.1
Expand All @@ -48,7 +55,15 @@ jobs:
shell: bash
run: yarn update_version


- name: build libsession-util-nodejs
shell: bash
run: yarn install --frozen-lockfile

- name: Check formatting
if: runner.os == 'Linux'
run: clang-format-19 --dry-run --Werror src/*.cpp include/*.hpp src/**/*.cpp include/**/*.hpp
shell: bash

# - name: Run clang-tidy
# run: clang-tidy-19 -p build src/*.cpp include/*.hpp src/**/*.cpp include/**/*.hpp
# shell: bash
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ set(ENABLE_ONIONREQ OFF)
# 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)
file(GLOB SOURCE_FILES src/*.cpp src/groups/*.cpp src/encrypt_decrypt/*.cpp src/pro/*.cpp src/meta/*.cpp )

add_subdirectory(libsession-util)


if(MSVC)
# Windows is horrible
add_compile_definitions(NOMINMAX)
endif()

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} "include/" "node_modules/node-addon-api" "../../node_modules/node-addon-api" "node_modules/node-api-headers/include" "../../node_modules/node-api-headers/include")
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} "include/" "${CMAKE_CURRENT_SOURCE_DIR}/node_modules/node-addon-api" "${CMAKE_CURRENT_SOURCE_DIR}/node_modules" "${CMAKE_CURRENT_SOURCE_DIR}/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_STATIC_BUNDLE_LIBS})
Expand Down
3 changes: 0 additions & 3 deletions include/base_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
#include <cassert>
#include <memory>
#include <oxen/log.hpp>
#include <span>
#include <stdexcept>
#include <unordered_set>

#include "session/config/base.hpp"
#include "session/logging.hpp"
#include "session/types.hpp"
#include "utilities.hpp"

namespace session::nodeapi {
Expand Down
111 changes: 111 additions & 0 deletions include/encrypt_decrypt/encrypt_decrypt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#pragma once

#include <napi.h>
#include <oxenc/base64.h>
#include <oxenc/hex.h>

#include "meta/meta_base_wrapper.hpp"

namespace session::nodeapi {

class MultiEncryptWrapper : public Napi::ObjectWrap<MultiEncryptWrapper> {
public:
MultiEncryptWrapper(const Napi::CallbackInfo& info) :
Napi::ObjectWrap<MultiEncryptWrapper>{info} {
throw std::invalid_argument(
"MultiEncryptWrapper is static and doesn't need to be constructed");
}

static void Init(Napi::Env env, Napi::Object exports) {
MetaBaseWrapper::NoBaseClassInitHelper<MultiEncryptWrapper>(
env,
exports,
"MultiEncryptWrapperNode",
{
StaticMethod<&MultiEncryptWrapper::multiEncrypt>(
"multiEncrypt",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::multiDecryptEd25519>(
"multiDecryptEd25519",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
// Attachments encrypt/decrypt
StaticMethod<&MultiEncryptWrapper::attachmentDecrypt>(
"attachmentDecrypt",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::attachmentEncrypt>(
"attachmentEncrypt",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),

// Destination encrypt
StaticMethod<&MultiEncryptWrapper::encryptFor1o1>(
"encryptFor1o1",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),

StaticMethod<&MultiEncryptWrapper::encryptForCommunity>(
"encryptForCommunity",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::encryptForCommunityInbox>(
"encryptForCommunityInbox",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::encryptForGroup>(
"encryptForGroup",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),

// Destination decrypt
StaticMethod<&MultiEncryptWrapper::decryptForCommunity>(
"decryptForCommunity",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::decryptFor1o1>(
"decryptFor1o1",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
StaticMethod<&MultiEncryptWrapper::decryptForGroup>(
"decryptForGroup",
static_cast<napi_property_attributes>(
napi_writable | napi_configurable)),
});
}

private:
static Napi::Value multiEncrypt(const Napi::CallbackInfo& info);
static Napi::Value multiDecryptEd25519(const Napi::CallbackInfo& info);

/**
* ===========================================
* =========== ATTACHMENTS CALLS =============
* ===========================================
*/

static Napi::Value attachmentEncrypt(const Napi::CallbackInfo& info);
static Napi::Value attachmentDecrypt(const Napi::CallbackInfo& info);

/**
* ===========================================
* ============= ENCRYPT CALLS ===============
* ===========================================
*/

static Napi::Value encryptFor1o1(const Napi::CallbackInfo& info);
static Napi::Value encryptForCommunityInbox(const Napi::CallbackInfo& info);
static Napi::Value encryptForCommunity(const Napi::CallbackInfo& info);
static Napi::Value encryptForGroup(const Napi::CallbackInfo& info);
/**
* ===========================================
* ============= DECRYPT CALLS ===============
* ===========================================
*/

static Napi::Value decryptForCommunity(const Napi::CallbackInfo& info);
static Napi::Value decryptFor1o1(const Napi::CallbackInfo& info);
static Napi::Value decryptForGroup(const Napi::CallbackInfo& info);
};
}; // namespace session::nodeapi
6 changes: 5 additions & 1 deletion include/groups/meta_group.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <napi.h>

#include <vector>

#include "session/config/groups/info.hpp"
Expand Down Expand Up @@ -35,7 +36,10 @@ class MetaGroup {
shared_ptr<config::groups::Keys> keys,
std::vector<unsigned char> edGroupPubKey,
std::optional<std::vector<unsigned char>> edGroupSecKey) :
info{info}, members{members}, keys{keys}, edGroupPubKey{oxenc::to_hex(edGroupPubKey.begin(), edGroupPubKey.end())} {
info{info},
members{members},
keys{keys},
edGroupPubKey{oxenc::to_hex(edGroupPubKey.begin(), edGroupPubKey.end())} {

if (edGroupSecKey.has_value()) {
this->edGroupSecKey = oxenc::to_hex(edGroupSecKey->begin(), edGroupSecKey->end());
Expand Down
1 change: 1 addition & 0 deletions include/groups/meta_group_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class MetaGroupWrapper : public Napi::ObjectWrap<MetaGroupWrapper> {
Napi::Value keysNeedsRekey(const Napi::CallbackInfo& info);
Napi::Value keyRekey(const Napi::CallbackInfo& info);
Napi::Value keyGetAll(const Napi::CallbackInfo& info);
Napi::Value keyGetEncryptionKeyHex(const Napi::CallbackInfo& info);
Napi::Value loadKeyMessage(const Napi::CallbackInfo& info);
Napi::Value keyGetCurrentGen(const Napi::CallbackInfo& info);
Napi::Value activeHashes(const Napi::CallbackInfo& info);
Expand Down
89 changes: 5 additions & 84 deletions include/meta/meta_base_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

#include <napi.h>

#include <optional>
#include <span>
#include <memory>
#include <vector>

#include "../base_config.hpp"
#include "../groups/meta_group.hpp"
#include "groups/meta_group.hpp"

namespace session::nodeapi {

class MetaBaseWrapper {

public:
explicit MetaBaseWrapper(){};
explicit MetaBaseWrapper() {};

virtual ~MetaBaseWrapper() = default;

Expand All @@ -35,86 +35,7 @@ class MetaBaseWrapper {
}

static std::unique_ptr<session::nodeapi::MetaGroup> constructGroupWrapper(
const Napi::CallbackInfo& info, const std::string& class_name) {
return wrapExceptions(info, [&] {
if (!info.IsConstructCall())
throw std::invalid_argument{
"You need to call the constructor with the `new` syntax"};

assertInfoLength(info, 1);
auto arg = info[0];
assertIsObject(arg);
auto obj = arg.As<Napi::Object>();

if (obj.IsEmpty())
throw std::invalid_argument("constructGroupWrapper received empty");

assertIsUInt8Array(obj.Get("userEd25519Secretkey"), "constructGroupWrapper userEd");
auto user_ed25519_secretkey = toCppBuffer(
obj.Get("userEd25519Secretkey"),
class_name + ":constructGroupWrapper.userEd25519Secretkey");

assertIsUInt8Array(obj.Get("groupEd25519Pubkey"), "constructGroupWrapper groupEd");
auto group_ed25519_pubkey = toCppBuffer(
obj.Get("groupEd25519Pubkey"),
class_name + ":constructGroupWrapper.groupEd25519Pubkey");

std::optional<std::vector<unsigned char>> group_ed25519_secretkey = maybeNonemptyBuffer(
obj.Get("groupEd25519Secretkey"),
class_name + ":constructGroupWrapper.groupEd25519Secretkey");

std::optional<std::vector<unsigned char>> dumped_meta = maybeNonemptyBuffer(
obj.Get("metaDumped"), class_name + ":constructGroupWrapper.metaDumped");

std::optional<std::string> dumped_info;
std::optional<std::string> dumped_members;
std::optional<std::string> dumped_keys;

if (dumped_meta) {
auto dumped_meta_str = to_string(*dumped_meta);

oxenc::bt_dict_consumer combined{dumped_meta_str};
// NB: must read in ascii-sorted order:
if (!combined.skip_until("info"))
throw std::runtime_error{"info dump not found in combined dump!"};
dumped_info = combined.consume_string();

if (!combined.skip_until("keys"))
throw std::runtime_error{"keys dump not found in combined dump!"};
dumped_keys = combined.consume_string();

if (!combined.skip_until("members"))
throw std::runtime_error{"members dump not found in combined dump!"};
dumped_members = combined.consume_string();
}

// Note, we keep shared_ptr for those as the Keys one need a reference to Members and
// Info on its own currently.
auto info = std::make_shared<config::groups::Info>(
group_ed25519_pubkey,
group_ed25519_secretkey,
(dumped_info ? std::make_optional(session::to_span(*dumped_info))
: std::nullopt));

auto members = std::make_shared<config::groups::Members>(
group_ed25519_pubkey,
group_ed25519_secretkey,
(dumped_members ? std::make_optional(session::to_span(*dumped_members))
: std::nullopt));

auto keys = std::make_shared<config::groups::Keys>(
user_ed25519_secretkey,
group_ed25519_pubkey,
group_ed25519_secretkey,
(dumped_keys ? std::make_optional(session::to_span(*dumped_keys))
: std::nullopt),
*info,
*members);

return std::make_unique<session::nodeapi::MetaGroup>(
info, members, keys, group_ed25519_pubkey, group_ed25519_secretkey);
});
}
const Napi::CallbackInfo& info, const std::string& class_name);
};

} // namespace session::nodeapi
Loading
Loading