diff --git a/libsession-util b/libsession-util index e2eed34..95b9fe7 160000 --- a/libsession-util +++ b/libsession-util @@ -1 +1 @@ -Subproject commit e2eed34ef25b3076a29000e43163bda832793159 +Subproject commit 95b9fe74d1c419487f6e69458db1ebc2bb824a2a diff --git a/package.json b/package.json index 496d999..e11c334 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "main": "index.js", "name": "libsession_util_nodejs", "description": "Wrappers for the Session Util Library", - "version": "0.4.34", + "version": "0.5.0", "license": "GPL-3.0", "author": { "name": "Oxen Project", diff --git a/src/addon.cpp b/src/addon.cpp index e7fe92c..5497360 100644 --- a/src/addon.cpp +++ b/src/addon.cpp @@ -11,6 +11,17 @@ Napi::Object InitAll(Napi::Env env, Napi::Object exports) { using namespace session::nodeapi; + + session::add_logger([env](std::string_view msg) { + std::string toLog = std::string("libsession-util: ") + std::string(msg) + "\n"; + + Napi::Function consoleLog = + env.Global().Get("console").As().Get("log").As(); + consoleLog.Call({Napi::String::New(env, toLog)}); + }); + + // session::logger_set_level_default(session::LogLevel::debug); + ConstantsWrapper::Init(env, exports); // Group wrappers init diff --git a/src/base_config.cpp b/src/base_config.cpp index 0c01592..2c66de1 100644 --- a/src/base_config.cpp +++ b/src/base_config.cpp @@ -15,8 +15,12 @@ Napi::Value ConfigBaseImpl::needsPush(const Napi::CallbackInfo& info) { return wrapResult(info, [&] { return get_config().needs_push(); }); } -Napi::Value ConfigBaseImpl::currentHashes(const Napi::CallbackInfo& info) { - return wrapResult(info, [&] { return (get_config().current_hashes()); }); +Napi::Value ConfigBaseImpl::activeHashes(const Napi::CallbackInfo& info) { + return wrapResult(info, [&] { + std::unordered_set hashes = get_config().active_hashes(); + std::vector hashesVec(hashes.begin(), hashes.end()); + return hashesVec; + }); } Napi::Value ConfigBaseImpl::push(const Napi::CallbackInfo& info) { @@ -44,21 +48,21 @@ Napi::Value ConfigBaseImpl::makeDump(const Napi::CallbackInfo& info) { } void ConfigBaseImpl::confirmPushed(const Napi::CallbackInfo& info) { - return wrapResult(info, [&]() { - assertInfoLength(info, 2); - assertIsNumber(info[0], "confirmPushed"); - assertIsString(info[1]); + return wrapExceptions(info, [&]() { + assertInfoLength(info, 1); + assertIsObject(info[0]); + auto obj = info[0].As(); + auto confirmed_pushed_entry = confirm_pushed_entry_from_JS(info.Env(), obj); get_config().confirm_pushed( - toCppInteger(info[0], "confirmPushed", false), - toCppString(info[1], "confirmPushed")); + std::get<0>(confirmed_pushed_entry), std::get<1>(confirmed_pushed_entry)); }); } Napi::Value ConfigBaseImpl::merge(const Napi::CallbackInfo& info) { return wrapResult(info, [&]() { assertInfoLength(info, 1); - assertIsArray(info[0]); + assertIsArray(info[0], "ConfigBaseImpl::merge"); Napi::Array asArray = info[0].As(); std::vector>> conf_strs; @@ -75,8 +79,9 @@ Napi::Value ConfigBaseImpl::merge(const Napi::CallbackInfo& info) { toCppString(itemObject.Get("hash"), "base.merge"), toCppBuffer(itemObject.Get("data"), "base.merge")); } - - return get_config().merge(conf_strs); + std::unordered_set merged = get_config().merge(conf_strs); + std::vector mergedVec(merged.begin(), merged.end()); + return mergedVec; }); } diff --git a/src/base_config.hpp b/src/base_config.hpp index 2980375..114d864 100644 --- a/src/base_config.hpp +++ b/src/base_config.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,7 @@ class ConfigBaseImpl { // These are exposed as read-only accessors rather than methods: Napi::Value needsDump(const Napi::CallbackInfo& info); Napi::Value needsPush(const Napi::CallbackInfo& info); - Napi::Value currentHashes(const Napi::CallbackInfo& info); + Napi::Value activeHashes(const Napi::CallbackInfo& info); Napi::Value push(const Napi::CallbackInfo& info); Napi::Value dump(const Napi::CallbackInfo& info); @@ -53,7 +54,7 @@ class ConfigBaseImpl { properties.push_back(T::InstanceMethod("needsDump", &T::needsDump)); properties.push_back(T::InstanceMethod("needsPush", &T::needsPush)); - properties.push_back(T::InstanceMethod("currentHashes", &T::currentHashes)); + properties.push_back(T::InstanceMethod("activeHashes", &T::activeHashes)); properties.push_back(T::InstanceMethod("push", &T::push)); properties.push_back(T::InstanceMethod("dump", &T::dump)); properties.push_back(T::InstanceMethod("makeDump", &T::makeDump)); @@ -101,24 +102,7 @@ class ConfigBaseImpl { if (!second.IsEmpty() && !second.IsNull() && !second.IsUndefined()) dump = toCppBuffer(second, class_name + ".new"); - // return std::make_shared(secretKey, dump); - std::shared_ptr config = std::make_shared(secretKey, dump); - - Napi::Env env = info.Env(); - - session::add_logger([env, class_name](auto msg) { - std::string toLog = - "libsession-util:" + std::string(class_name) + ": " + std::string(msg) + "\n"; - - Napi::Function consoleLog = env.Global() - .Get("console") - .As() - .Get("log") - .As(); - consoleLog.Call({Napi::String::New(env, toLog)}); - }); - - return config; + return std::make_shared(secretKey, dump); }); } diff --git a/src/groups/meta_group_wrapper.cpp b/src/groups/meta_group_wrapper.cpp index ff11c5e..eca99be 100644 --- a/src/groups/meta_group_wrapper.cpp +++ b/src/groups/meta_group_wrapper.cpp @@ -140,7 +140,7 @@ void MetaGroupWrapper::Init(Napi::Env env, Napi::Object exports) { InstanceMethod("keysNeedsRekey", &MetaGroupWrapper::keysNeedsRekey), InstanceMethod("keyRekey", &MetaGroupWrapper::keyRekey), InstanceMethod("keyGetAll", &MetaGroupWrapper::keyGetAll), - InstanceMethod("currentHashes", &MetaGroupWrapper::currentHashes), + InstanceMethod("activeHashes", &MetaGroupWrapper::activeHashes), InstanceMethod("loadKeyMessage", &MetaGroupWrapper::loadKeyMessage), InstanceMethod("keyGetCurrentGen", &MetaGroupWrapper::keyGetCurrentGen), InstanceMethod("encryptMessages", &MetaGroupWrapper::encryptMessages), @@ -244,35 +244,21 @@ void MetaGroupWrapper::metaConfirmPushed(const Napi::CallbackInfo& info) { auto groupMember = obj.Get("groupMember"); if (!groupInfo.IsNull() && !groupInfo.IsUndefined()) { - assertIsArray(groupInfo); - auto groupInfoArr = groupInfo.As(); - if (groupInfoArr.Length() != 2) { - throw std::invalid_argument("groupInfoArr length was not 2"); - } + assertIsObject(groupInfo); + auto groupInfoObj = groupInfo.As(); + auto groupInfoConfirmed = confirm_pushed_entry_from_JS(info.Env(), groupInfoObj); - auto seqno = maybeNonemptyInt( - groupInfoArr.Get("0"), "MetaGroupWrapper::metaConfirmPushed groupInfo seqno"); - auto hash = maybeNonemptyString( - groupInfoArr.Get("1"), "MetaGroupWrapper::metaConfirmPushed groupInfo hash"); - if (seqno && hash) - this->meta_group->info->confirm_pushed(*seqno, *hash); + this->meta_group->info->confirm_pushed( + std::get<0>(groupInfoConfirmed), std::get<1>(groupInfoConfirmed)); } if (!groupMember.IsNull() && !groupMember.IsUndefined()) { - assertIsArray(groupMember); - auto groupMemberArr = groupMember.As(); - if (groupMemberArr.Length() != 2) { - throw std::invalid_argument("groupMemberArr length was not 2"); - } + assertIsObject(groupMember); + auto groupMemberObj = groupMember.As(); + auto groupMemberConfirmed = confirm_pushed_entry_from_JS(info.Env(), groupMemberObj); - auto seqno = maybeNonemptyInt( - groupMemberArr.Get("0"), - "MetaGroupWrapper::metaConfirmPushed groupMemberArr seqno"); - auto hash = maybeNonemptyString( - groupMemberArr.Get("1"), - "MetaGroupWrapper::metaConfirmPushed groupMemberArr hash"); - if (seqno && hash) - this->meta_group->members->confirm_pushed(*seqno, *hash); + this->meta_group->members->confirm_pushed( + std::get<0>(groupMemberConfirmed), std::get<1>(groupMemberConfirmed)); } }); }; @@ -283,17 +269,17 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) { auto arg = info[0]; assertIsObject(arg); auto obj = arg.As(); - auto groupInfo = obj.Get("groupInfo"); auto groupMember = obj.Get("groupMember"); auto groupKeys = obj.Get("groupKeys"); auto count_merged = 0; + // Note: we need to process keys first as they might allow us the incoming info+members // details if (!groupKeys.IsNull() && !groupKeys.IsUndefined()) { - assertIsArray(groupKeys); + assertIsArray(groupKeys, "metaMerge groupKeys"); auto asArr = groupKeys.As(); for (uint32_t i = 0; i < asArr.Length(); i++) { @@ -318,13 +304,13 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) { timestamp_ms, *(this->meta_group->info), *(this->meta_group->members)); - count_merged++; // load_key_message doesn't necessarely merge something as not + count_merged++; // load_key_message doesn't necessarily merge something as not // all keys are for us. } } if (!groupInfo.IsNull() && !groupInfo.IsUndefined()) { - assertIsArray(groupInfo); + assertIsArray(groupInfo, "metaMerge groupInfo"); auto asArr = groupInfo.As(); std::vector>> conf_strs; @@ -349,9 +335,8 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) { count_merged += info_merged.size(); } } - if (!groupMember.IsNull() && !groupMember.IsUndefined()) { - assertIsArray(groupMember); + assertIsArray(groupMember, "metaMerge groupMember"); auto asArr = groupMember.As(); std::vector>> conf_strs; @@ -376,7 +361,6 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) { count_merged += member_merged.size(); } } - if (this->meta_group->keys->needs_rekey()) { this->meta_group->keys->rekey(*(this->meta_group->info), *(this->meta_group->members)); } @@ -693,7 +677,7 @@ void MetaGroupWrapper::membersMarkPendingRemoval(const Napi::CallbackInfo& info) auto toUpdateJSValue = info[0]; auto withMessageJSValue = info[1]; - assertIsArray(toUpdateJSValue); + assertIsArray(toUpdateJSValue, "membersMarkPendingRemoval"); assertIsBoolean(withMessageJSValue); bool withMessages = toCppBoolean(withMessageJSValue, "membersMarkPendingRemoval"); @@ -714,7 +698,7 @@ Napi::Value MetaGroupWrapper::memberEraseAndRekey(const Napi::CallbackInfo& info assertInfoLength(info, 1); auto toRemoveJSValue = info[0]; - assertIsArray(toRemoveJSValue); + assertIsArray(toRemoveJSValue, "memberEraseAndRekey"); auto toRemoveJS = toRemoveJSValue.As(); auto rekeyed = false; @@ -771,15 +755,16 @@ Napi::Value MetaGroupWrapper::keyGetCurrentGen(const Napi::CallbackInfo& info) { }); } -Napi::Value MetaGroupWrapper::currentHashes(const Napi::CallbackInfo& info) { +Napi::Value MetaGroupWrapper::activeHashes(const Napi::CallbackInfo& info) { return wrapResult(info, [&] { - auto keysHashes = meta_group->keys->current_hashes(); - auto infoHashes = meta_group->info->current_hashes(); - auto memberHashes = meta_group->members->current_hashes(); + auto keysHashes = meta_group->keys->active_hashes(); + auto infoHashes = meta_group->info->active_hashes(); + auto memberHashes = meta_group->members->active_hashes(); std::vector merged; std::copy(std::begin(keysHashes), std::end(keysHashes), std::back_inserter(merged)); std::copy(std::begin(infoHashes), std::end(infoHashes), std::back_inserter(merged)); std::copy(std::begin(memberHashes), std::end(memberHashes), std::back_inserter(merged)); + return merged; }); } @@ -787,7 +772,7 @@ Napi::Value MetaGroupWrapper::currentHashes(const Napi::CallbackInfo& info) { Napi::Value MetaGroupWrapper::encryptMessages(const Napi::CallbackInfo& info) { return wrapResult(info, [&] { assertInfoLength(info, 1); - assertIsArray(info[0]); + assertIsArray(info[0], "encryptMessages"); auto plaintextsJS = info[0].As(); uint32_t arrayLength = plaintextsJS.Length(); @@ -880,7 +865,7 @@ Napi::Value MetaGroupWrapper::generateSupplementKeys(const Napi::CallbackInfo& i return wrapResult(info, [&] { assertInfoLength(info, 1); auto membersJSValue = info[0]; - assertIsArray(membersJSValue); + assertIsArray(membersJSValue, "generateSupplementKeys"); auto membersJS = membersJSValue.As(); uint32_t arrayLength = membersJS.Length(); diff --git a/src/groups/meta_group_wrapper.hpp b/src/groups/meta_group_wrapper.hpp index 6da4c76..9b53ec0 100644 --- a/src/groups/meta_group_wrapper.hpp +++ b/src/groups/meta_group_wrapper.hpp @@ -83,7 +83,7 @@ class MetaGroupWrapper : public Napi::ObjectWrap { Napi::Value keyGetAll(const Napi::CallbackInfo& info); Napi::Value loadKeyMessage(const Napi::CallbackInfo& info); Napi::Value keyGetCurrentGen(const Napi::CallbackInfo& info); - Napi::Value currentHashes(const Napi::CallbackInfo& info); + Napi::Value activeHashes(const Napi::CallbackInfo& info); Napi::Value encryptMessages(const Napi::CallbackInfo& info); Napi::Value decryptMessage(const Napi::CallbackInfo& info); Napi::Value makeSwarmSubAccount(const Napi::CallbackInfo& info); diff --git a/src/multi_encrypt/multi_encrypt.hpp b/src/multi_encrypt/multi_encrypt.hpp index 5980346..6720a57 100644 --- a/src/multi_encrypt/multi_encrypt.hpp +++ b/src/multi_encrypt/multi_encrypt.hpp @@ -58,7 +58,7 @@ class MultiEncryptWrapper : public Napi::ObjectWrap { // handle the messages conversion auto messagesJSValue = obj.Get("messages"); - assertIsArray(messagesJSValue); + assertIsArray(messagesJSValue, "multiEncrypt"); auto messagesJS = messagesJSValue.As(); std::vector> messages; messages.reserve(messagesJS.Length()); @@ -71,7 +71,7 @@ class MultiEncryptWrapper : public Napi::ObjectWrap { // handle the recipients conversion auto recipientsJSValue = obj.Get("recipients"); - assertIsArray(recipientsJSValue); + assertIsArray(recipientsJSValue, "multiEncrypt"); auto recipientsJS = recipientsJSValue.As(); std::vector> recipients; recipients.reserve(recipientsJS.Length()); diff --git a/src/user_groups_config.cpp b/src/user_groups_config.cpp index f4d8424..e5cd12f 100644 --- a/src/user_groups_config.cpp +++ b/src/user_groups_config.cpp @@ -213,7 +213,7 @@ void UserGroupsWrapper::setLegacyGroup(const Napi::CallbackInfo& info) { true)}; auto membersJSValue = obj.Get("members"); - assertIsArray(membersJSValue); + assertIsArray(membersJSValue, "setLegacyGroup.membersJSValue"); auto membersJS = membersJSValue.As(); uint32_t arrayLength = membersJS.Length(); std::vector> membersToAddOrUpdate; diff --git a/src/utilities.cpp b/src/utilities.cpp index 609503b..089aab0 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -27,8 +27,9 @@ void assertIsNumber(const Napi::Value& val, const std::string& identifier) { std::string("Wrong arguments: expected number" + identifier).c_str()); } -void assertIsArray(const Napi::Value& val) { - checkOrThrow(val.IsArray(), "Wrong arguments: expected array"); +void assertIsArray(const Napi::Value& val, const std::string& identifier) { + checkOrThrow( + val.IsArray(), std::string("Wrong arguments: expected array:" + identifier).c_str()); } void assertIsObject(const Napi::Value& val) { @@ -230,4 +231,23 @@ Napi::Object decrypt_result_to_JS( return obj; } +confirm_pushed_entry_t confirm_pushed_entry_from_JS(const Napi::Env& env, const Napi::Object& obj) { + auto seqnoJsValue = obj.Get("seqno"); + assertIsNumber(seqnoJsValue, "confirm_pushed_entry_from_JS.seqno"); + int64_t seqno = toCppInteger(seqnoJsValue, "confirm_pushed_entry_from_JS.seqno", false); + auto hashesJsValue = obj.Get("hashes"); + assertIsArray(hashesJsValue, "confirm_pushed_entry_from_JS.hashes"); + + auto hashesJs = hashesJsValue.As(); + std::unordered_set hashes; + for (uint32_t i = 0; i < hashesJs.Length(); i++) { + auto hashValue = hashesJs.Get(i); + assertIsString(hashValue); + std::string hash = toCppString(hashValue, "confirm_pushed_entry_from_JS.hashes.hash"); + hashes.insert(hash); + } + confirm_pushed_entry_t confirmed_pushed_entry{seqno, hashes}; + return confirmed_pushed_entry; +} + } // namespace session::nodeapi diff --git a/src/utilities.hpp b/src/utilities.hpp index a472758..2520663 100644 --- a/src/utilities.hpp +++ b/src/utilities.hpp @@ -29,7 +29,7 @@ void assertInfoMinLength(const Napi::CallbackInfo& info, const int minLength); void assertIsStringOrNull(const Napi::Value& value); void assertIsNumber(const Napi::Value& value, const std::string& identifier); -void assertIsArray(const Napi::Value& value); +void assertIsArray(const Napi::Value& value, const std::string& identifier); void assertIsObject(const Napi::Value& value); void assertIsUInt8ArrayOrNull(const Napi::Value& value); void assertIsUInt8Array(const Napi::Value& value, const std::string& identifier); @@ -56,7 +56,6 @@ auto getStringArgs(const Napi::CallbackInfo& info) { std::string toCppString(Napi::Value x, const std::string& identifier); std::vector toCppBuffer(Napi::Value x, const std::string& identifier); - int64_t toCppInteger(Napi::Value x, const std::string& identifier, bool allowUndefined = false); std::optional maybeNonemptyInt(Napi::Value x, const std::string& identifier); std::optional maybeNonemptyBoolean(Napi::Value x, const std::string& identifier); @@ -268,8 +267,11 @@ int64_t unix_timestamp_now(); using push_entry_t = std::tuple< session::config::seqno_t, - std::vector, - std::vector>>; + std::vector>, + std::vector>; + +using confirm_pushed_entry_t = + std::tuple>; Napi::Object push_result_to_JS( const Napi::Env& env, @@ -284,4 +286,6 @@ Napi::Object push_key_entry_to_JS( Napi::Object decrypt_result_to_JS( const Napi::Env& env, const std::pair> decrypted); +confirm_pushed_entry_t confirm_pushed_entry_from_JS(const Napi::Env& env, const Napi::Object& obj); + } // namespace session::nodeapi diff --git a/types/blinding/blinding.d.ts b/types/blinding/blinding.d.ts index fdca137..7ab01f0 100644 --- a/types/blinding/blinding.d.ts +++ b/types/blinding/blinding.d.ts @@ -1,4 +1,4 @@ -/// +/// declare module 'libsession_util_nodejs' { type BlindingWrapper = { diff --git a/types/blinding/index.d.ts b/types/blinding/index.d.ts index cc60fb6..9558243 100644 --- a/types/blinding/index.d.ts +++ b/types/blinding/index.d.ts @@ -1,2 +1,2 @@ -/// +/// /// diff --git a/types/groups/groupkeys.d.ts b/types/groups/groupkeys.d.ts index 41d92e1..ec5e67a 100644 --- a/types/groups/groupkeys.d.ts +++ b/types/groups/groupkeys.d.ts @@ -10,7 +10,7 @@ declare module 'libsession_util_nodejs' { keysAdmin: () => boolean; keyGetCurrentGen: () => number; - currentHashes: () => Array; + activeHashes: () => Array; encryptMessages: (plaintexts: Array) => Array; decryptMessage: (ciphertext: Uint8Array) => { pubkeyHex: string; plaintext: Uint8Array }; makeSwarmSubAccount: (memberPubkeyHex: PubkeyType) => Uint8ArrayLen100; diff --git a/types/groups/metagroup.d.ts b/types/groups/metagroup.d.ts index 413a4d4..1231955 100644 --- a/types/groups/metagroup.d.ts +++ b/types/groups/metagroup.d.ts @@ -36,7 +36,11 @@ declare module 'libsession_util_nodejs' { push: () => { groupInfo: PushConfigResult | null; groupMember: PushConfigResult | null; - groupKeys: PushKeyConfigResult | null; + // groupKeys is very custom, and not an array of Uint8Array + groupKeys: { + data: Uint8Array; + namespace: number; + } | null; }; needsDump: () => boolean; metaDump: () => Uint8Array; @@ -79,7 +83,7 @@ declare module 'libsession_util_nodejs' { public metaMakeDump: MetaGroupWrapper['metaMakeDump']; public metaConfirmPushed: MetaGroupWrapper['metaConfirmPushed']; public metaMerge: MetaGroupWrapper['metaMerge']; - public currentHashes: MetaGroupWrapper['currentHashes']; + public activeHashes: MetaGroupWrapper['activeHashes']; // info public infoGet: MetaGroupWrapper['infoGet']; @@ -165,7 +169,7 @@ declare module 'libsession_util_nodejs' { | MakeActionCall | MakeActionCall | MakeActionCall - | MakeActionCall + | MakeActionCall | MakeActionCall | MakeActionCall | MakeActionCall diff --git a/types/index.d.ts b/types/index.d.ts index 0693f7e..2762af0 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,3 +1,4 @@ +/// /// /// /// diff --git a/types/shared.d.ts b/types/shared.d.ts index 185acf3..b2890ca 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -32,7 +32,7 @@ declare module 'libsession_util_nodejs' { }; export type PushConfigResult = { - data: Uint8Array; + data: Array; seqno: number; hashes: Array; namespace: number; @@ -40,7 +40,7 @@ declare module 'libsession_util_nodejs' { export type PushKeyConfigResult = Pick; - export type ConfirmPush = [seqno: number, hash: string]; + export type ConfirmPush = { seqno: number; hashes: Array }; export type MergeSingle = { hash: string; data: Uint8Array }; type MakeActionCall = [B, ...Parameters]; @@ -57,10 +57,10 @@ declare module 'libsession_util_nodejs' { push: () => PushConfigResult; dump: () => Uint8Array; makeDump: () => Uint8Array; - confirmPushed: (seqno: number, hash: string) => void; + confirmPushed: (pushed: ConfirmPush) => void; merge: (toMerge: Array) => Array; // merge returns the array of hashes that merged correctly storageNamespace: () => number; - currentHashes: () => Array; + activeHashes: () => Array; }; export type GenericWrapperActionsCall = ( @@ -77,7 +77,7 @@ declare module 'libsession_util_nodejs' { | MakeActionCall | MakeActionCall | MakeActionCall - | MakeActionCall; + | MakeActionCall; export abstract class BaseConfigWrapperNode { public needsDump: BaseConfigWrapper['needsDump']; @@ -88,7 +88,7 @@ declare module 'libsession_util_nodejs' { public confirmPushed: BaseConfigWrapper['confirmPushed']; public merge: BaseConfigWrapper['merge']; public storageNamespace: BaseConfigWrapper['storageNamespace']; - public currentHashes: BaseConfigWrapper['currentHashes']; + public activeHashes: BaseConfigWrapper['activeHashes']; } export type BaseWrapperActionsCalls = MakeWrapperActionCalls; @@ -97,7 +97,7 @@ declare module 'libsession_util_nodejs' { export type PubkeyType = `05${string}`; // type of a string which starts by the 05 prefixed used for **legacy** closed group and session ids export type BlindedPubkeyType = `15${string}`; - type MakeGroupActionCall = [ + type MakeGroupActionCall = [ B, ...Parameters ]; // all of the groupActionCalls need the pubkey of the group we are targeting diff --git a/types/utilities/index.d.ts b/types/utilities/index.d.ts new file mode 100644 index 0000000..3dd465c --- /dev/null +++ b/types/utilities/index.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/types/utilities/utilities.d.ts b/types/utilities/utilities.d.ts new file mode 100644 index 0000000..d141b57 --- /dev/null +++ b/types/utilities/utilities.d.ts @@ -0,0 +1,23 @@ +/// + +declare module 'libsession_util_nodejs' { + type UtilitiesWrapper = { + freeAllWrappers: () => void; + }; + + /** + * To be used inside the web worker only (calls are synchronous and won't work asynchronously) + */ + export class UtilitiesWrapperNode { + public static freeAllWrappers: UtilitiesWrapper['freeAllWrappers']; + } + + export type UtilitiesWrapperActionsCalls = MakeWrapperActionCalls; + + /** + * Those actions are used internally for the web worker communication. + * You should never need to import them in Session directly + * You will need to add an entry here if you add a new function + */ + export type UtilitiesActionsType = MakeActionCall; +}