diff --git a/include/pro/pro.hpp b/include/pro/pro.hpp index 4ab3dfd..6a19560 100644 --- a/include/pro/pro.hpp +++ b/include/pro/pro.hpp @@ -117,10 +117,9 @@ class ProWrapper : public Napi::ObjectWrap { private: static Napi::Value proFeaturesForMessage(const Napi::CallbackInfo& info) { return wrapResult(info, [&] { - // we expect two arguments that match: + // we expect one argument that matches: // first: { // "utf16": string, - // "proFeaturesBitset": bigint, // } assertInfoLength(info, 1); @@ -132,17 +131,12 @@ class ProWrapper : public Napi::ObjectWrap { if (first.IsEmpty()) throw std::invalid_argument("proFeaturesForMessage first received empty"); - assertIsBigint( - first.Get("proFeaturesBitset"), "proFeaturesForMessage.proFeaturesBitset"); - auto lossless = true; - SESSION_PROTOCOL_PRO_FEATURES flags = - first.Get("proFeaturesBitset").As().Uint64Value(&lossless); assertIsString(first.Get("utf16"), "proFeaturesForMessage.utf16"); std::u16string utf16 = first.Get("utf16").As().Utf16Value(); - auto pro_features_msg = - session::pro_features_for_utf16((utf16.data()), utf16.length(), flags); + ProFeaturesForMsg pro_features_msg = + session::pro_features_for_utf16((utf16.data()), utf16.length()); auto obj = Napi::Object::New(env); @@ -150,7 +144,7 @@ class ProWrapper : public Napi::ObjectWrap { obj["error"] = pro_features_msg.error.size() ? toJs(env, pro_features_msg.error) : env.Null(); obj["codepointCount"] = toJs(env, pro_features_msg.codepoint_count); - obj["proFeaturesBitset"] = proFeaturesToJsBitset(env, pro_features_msg.features); + obj["proMessageBitset"] = proMessageBitsetToJS(env, pro_features_msg.bitset); return obj; }); diff --git a/include/pro/types.hpp b/include/pro/types.hpp index 4ddede2..aca78bf 100644 --- a/include/pro/types.hpp +++ b/include/pro/types.hpp @@ -75,7 +75,8 @@ struct toJs_impl { : decoded_pro.status == ProStatus::InvalidUserSig ? "InvalidUserSig" : "Valid"); obj["proProof"] = toJs(env, decoded_pro.proof); - obj["proFeaturesBitset"] = proFeaturesToJsBitset(env, decoded_pro.features); + obj["proProfileBitset"] = proProfileBitsetToJS(env, decoded_pro.profile_bitset); + obj["proMessageBitset"] = proMessageBitsetToJS(env, decoded_pro.msg_bitset); return obj; } diff --git a/include/user_config.hpp b/include/user_config.hpp index 7ae20c1..b179a49 100644 --- a/include/user_config.hpp +++ b/include/user_config.hpp @@ -40,7 +40,7 @@ class UserConfigWrapper : public ConfigBaseImpl, public Napi::ObjectWrap from_hex_to_span(std::string_view x); diff --git a/libsession-util b/libsession-util index 41cfac4..3d79bb2 160000 --- a/libsession-util +++ b/libsession-util @@ -1 +1 @@ -Subproject commit 41cfac4aabb77fc2165016cb06eb514e9fafe158 +Subproject commit 3d79bb2d2b5b62d5240fa3307e0901a2e217192a diff --git a/package.json b/package.json index 24612c7..339fe64 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.6.4", + "version": "0.6.5", "license": "GPL-3.0", "author": { "name": "Oxen Project", diff --git a/src/user_config.cpp b/src/user_config.cpp index e1aade4..098ba8c 100644 --- a/src/user_config.cpp +++ b/src/user_config.cpp @@ -106,8 +106,7 @@ void UserConfigWrapper::Init(Napi::Env env, Napi::Object exports) { InstanceMethod("removeProConfig", &UserConfigWrapper::removeProConfig), InstanceMethod("setProBadge", &UserConfigWrapper::setProBadge), InstanceMethod("setAnimatedAvatar", &UserConfigWrapper::setAnimatedAvatar), - InstanceMethod( - "getProFeaturesBitset", &UserConfigWrapper::getProFeaturesBitset), + InstanceMethod("getProProfileBitset", &UserConfigWrapper::getProProfileBitset), InstanceMethod( "generateProMasterKey", &UserConfigWrapper::generateProMasterKey), InstanceMethod( @@ -292,9 +291,9 @@ Napi::Value UserConfigWrapper::removeProConfig(const Napi::CallbackInfo& info) { }); } -Napi::Value UserConfigWrapper::getProFeaturesBitset(const Napi::CallbackInfo& info) { +Napi::Value UserConfigWrapper::getProProfileBitset(const Napi::CallbackInfo& info) { return wrapResult( - info, [&] { return proFeaturesToJsBitset(info.Env(), config.get_pro_features()); }); + info, [&] { return proProfileBitsetToJS(info.Env(), config.get_profile_bitset()); }); } void UserConfigWrapper::setProBadge(const Napi::CallbackInfo& info) { diff --git a/src/utilities.cpp b/src/utilities.cpp index ae8abaa..5940a6f 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -362,9 +362,12 @@ confirm_pushed_entry_t confirm_pushed_entry_from_JS(const Napi::Env& env, const return confirmed_pushed_entry; } -Napi::BigInt proFeaturesToJsBitset( - const Napi::Env& env, const SESSION_PROTOCOL_PRO_FEATURES bitset) { - return Napi::BigInt::New(env, bitset); +Napi::BigInt proProfileBitsetToJS(const Napi::Env& env, const ProProfileBitset bitset) { + return Napi::BigInt::New(env, bitset.data); +} + +Napi::BigInt proMessageBitsetToJS(const Napi::Env& env, const ProMessageBitset bitset) { + return Napi::BigInt::New(env, bitset.data); } std::span from_hex_to_span(std::string_view x) { diff --git a/types/multi_encrypt/multi_encrypt.d.ts b/types/multi_encrypt/multi_encrypt.d.ts index add4909..37f187e 100644 --- a/types/multi_encrypt/multi_encrypt.d.ts +++ b/types/multi_encrypt/multi_encrypt.d.ts @@ -53,7 +53,7 @@ declare module 'libsession_util_nodejs' { }; type WithNowMs = { nowMs: number }; - type DecodedPro = WithProFeaturesBitset & { + type DecodedPro = WithProProfileBitset & WithProMessageBitset & { proStatus: ProStatus; proProof: ProProof; }; diff --git a/types/pro/pro.d.ts b/types/pro/pro.d.ts index 41550e7..60944d1 100644 --- a/types/pro/pro.d.ts +++ b/types/pro/pro.d.ts @@ -11,7 +11,8 @@ declare module 'libsession_util_nodejs' { }; type ProStatus = 'InvalidProBackendSig' | 'InvalidUserSig' | 'Valid'; - type WithProFeaturesBitset = { proFeaturesBitset: bigint }; + type WithProProfileBitset = { proProfileBitset: bigint }; + type WithProMessageBitset = { proMessageBitset: bigint }; type WithGenIndexHash = { genIndexHashB64: string }; type WithRequestVersion = { requestVersion: number }; @@ -157,11 +158,7 @@ declare module 'libsession_util_nodejs' { }; type ProWrapper = { - proFeaturesForMessage: ( - args: WithProFeaturesBitset & { - utf16: string; - } - ) => WithProFeaturesBitset & { + proFeaturesForMessage: (args: { utf16: string }) => WithProMessageBitset & { status: 'SUCCESS' | 'UTF_DECODING_ERROR' | 'EXCEEDS_CHARACTER_LIMIT'; }; proProofRequestBody: ( diff --git a/types/user/userconfig.d.ts b/types/user/userconfig.d.ts index 786bc35..d6cfed0 100644 --- a/types/user/userconfig.d.ts +++ b/types/user/userconfig.d.ts @@ -48,7 +48,7 @@ declare module 'libsession_util_nodejs' { * * @returns 0 if no pro user features are enabled, the bitset of pro features enabled otherwise */ - getProFeaturesBitset: () => bigint; + getProProfileBitset: () => bigint; generateProMasterKey: ({ ed25519SeedHex, @@ -94,7 +94,7 @@ declare module 'libsession_util_nodejs' { public getProConfig: UserConfigWrapper['getProConfig']; public setProConfig: UserConfigWrapper['setProConfig']; public removeProConfig: UserConfigWrapper['removeProConfig']; - public getProFeaturesBitset: UserConfigWrapper['getProFeaturesBitset']; + public getProProfileBitset: UserConfigWrapper['getProProfileBitset']; public setAnimatedAvatar: UserConfigWrapper['setAnimatedAvatar']; public setProBadge: UserConfigWrapper['setProBadge']; @@ -126,7 +126,7 @@ declare module 'libsession_util_nodejs' { | MakeActionCall | MakeActionCall | MakeActionCall - | MakeActionCall + | MakeActionCall | MakeActionCall | MakeActionCall | MakeActionCall