Skip to content

Commit 2419721

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/add-contact-pro-details-tracking
2 parents 3ae12fe + 0efc996 commit 2419721

File tree

11 files changed

+30
-35
lines changed

11 files changed

+30
-35
lines changed

include/pro/pro.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
117117
private:
118118
static Napi::Value proFeaturesForMessage(const Napi::CallbackInfo& info) {
119119
return wrapResult(info, [&] {
120-
// we expect two arguments that match:
120+
// we expect one argument that matches:
121121
// first: {
122122
// "utf16": string,
123-
// "proFeaturesBitset": bigint,
124123
// }
125124

126125
assertInfoLength(info, 1);
@@ -132,25 +131,20 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
132131
if (first.IsEmpty())
133132
throw std::invalid_argument("proFeaturesForMessage first received empty");
134133

135-
assertIsBigint(
136-
first.Get("proFeaturesBitset"), "proFeaturesForMessage.proFeaturesBitset");
137-
138134
auto lossless = true;
139-
SESSION_PROTOCOL_PRO_FEATURES flags =
140-
first.Get("proFeaturesBitset").As<Napi::BigInt>().Uint64Value(&lossless);
141135

142136
assertIsString(first.Get("utf16"), "proFeaturesForMessage.utf16");
143137
std::u16string utf16 = first.Get("utf16").As<Napi::String>().Utf16Value();
144-
auto pro_features_msg =
145-
session::pro_features_for_utf16((utf16.data()), utf16.length(), flags);
138+
ProFeaturesForMsg pro_features_msg =
139+
session::pro_features_for_utf16((utf16.data()), utf16.length());
146140

147141
auto obj = Napi::Object::New(env);
148142

149143
obj["status"] = toJs(env, proBackendEnumToString(pro_features_msg.status));
150144
obj["error"] =
151145
pro_features_msg.error.size() ? toJs(env, pro_features_msg.error) : env.Null();
152146
obj["codepointCount"] = toJs(env, pro_features_msg.codepoint_count);
153-
obj["proFeaturesBitset"] = proFeaturesToJsBitset(env, pro_features_msg.features);
147+
obj["proMessageBitset"] = proMessageBitsetToJS(env, pro_features_msg.bitset);
154148

155149
return obj;
156150
});

include/pro/types.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ struct toJs_impl<session::DecodedPro> {
7575
? "ValidOrExpired"
7676
: "Invalid");
7777
obj["proProof"] = toJs(env, decoded_pro.proof);
78-
obj["proFeaturesBitset"] = proFeaturesToJsBitset(env, decoded_pro.features);
78+
obj["proProfileBitset"] = proProfileBitsetToJS(env, decoded_pro.profile_bitset);
79+
obj["proMessageBitset"] = proMessageBitsetToJS(env, decoded_pro.msg_bitset);
7980

8081
return obj;
8182
}

include/user_config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class UserConfigWrapper : public ConfigBaseImpl, public Napi::ObjectWrap<UserCon
4040
void setProConfig(const Napi::CallbackInfo& info);
4141
Napi::Value removeProConfig(const Napi::CallbackInfo& info);
4242

43-
Napi::Value getProFeaturesBitset(const Napi::CallbackInfo& info);
4443
Napi::Value getProAccessExpiry(const Napi::CallbackInfo& info);
44+
Napi::Value getProProfileBitset(const Napi::CallbackInfo& info);
4545
void setProBadge(const Napi::CallbackInfo& info);
4646
void setAnimatedAvatar(const Napi::CallbackInfo& info);
4747
void setProAccessExpiry(const Napi::CallbackInfo& info);

include/utilities.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "oxenc/hex.h"
1818
#include "session/config/namespaces.hpp"
1919
#include "session/config/profile_pic.hpp"
20-
#include "session/session_protocol.h"
20+
#include "session/session_protocol.hpp"
2121
#include "session/types.h"
2222
#include "session/types.hpp"
2323

@@ -408,8 +408,9 @@ Napi::Object decrypt_result_to_JS(
408408

409409
confirm_pushed_entry_t confirm_pushed_entry_from_JS(const Napi::Env& env, const Napi::Object& obj);
410410

411-
Napi::BigInt proFeaturesToJsBitset(
412-
const Napi::Env& env, const SESSION_PROTOCOL_PRO_FEATURES bitset);
411+
Napi::BigInt proProfileBitsetToJS(const Napi::Env& env, const ProProfileBitset bitset);
412+
413+
Napi::BigInt proMessageBitsetToJS(const Napi::Env& env, const ProMessageBitset bitset);
413414

414415
std::span<const uint8_t> from_hex_to_span(std::string_view x);
415416

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "index.js",
33
"name": "libsession_util_nodejs",
44
"description": "Wrappers for the Session Util Library",
5-
"version": "0.6.4",
5+
"version": "0.6.5",
66
"license": "GPL-3.0",
77
"author": {
88
"name": "Oxen Project",

src/user_config.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ void UserConfigWrapper::Init(Napi::Env env, Napi::Object exports) {
107107
InstanceMethod("setProBadge", &UserConfigWrapper::setProBadge),
108108
InstanceMethod("setAnimatedAvatar", &UserConfigWrapper::setAnimatedAvatar),
109109
InstanceMethod("setProAccessExpiry", &UserConfigWrapper::setProAccessExpiry),
110-
InstanceMethod(
111-
"getProFeaturesBitset", &UserConfigWrapper::getProFeaturesBitset),
112110
InstanceMethod("getProAccessExpiry", &UserConfigWrapper::getProAccessExpiry),
111+
InstanceMethod("getProProfileBitset", &UserConfigWrapper::getProProfileBitset),
113112
InstanceMethod(
114113
"generateProMasterKey", &UserConfigWrapper::generateProMasterKey),
115114
InstanceMethod(
@@ -294,9 +293,9 @@ Napi::Value UserConfigWrapper::removeProConfig(const Napi::CallbackInfo& info) {
294293
});
295294
}
296295

297-
Napi::Value UserConfigWrapper::getProFeaturesBitset(const Napi::CallbackInfo& info) {
296+
Napi::Value UserConfigWrapper::getProProfileBitset(const Napi::CallbackInfo& info) {
298297
return wrapResult(
299-
info, [&] { return proFeaturesToJsBitset(info.Env(), config.get_pro_features()); });
298+
info, [&] { return proProfileBitsetToJS(info.Env(), config.get_profile_bitset()); });
300299
}
301300

302301
Napi::Value UserConfigWrapper::getProAccessExpiry(const Napi::CallbackInfo& info) {

src/utilities.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,12 @@ confirm_pushed_entry_t confirm_pushed_entry_from_JS(const Napi::Env& env, const
391391
return confirmed_pushed_entry;
392392
}
393393

394-
Napi::BigInt proFeaturesToJsBitset(
395-
const Napi::Env& env, const SESSION_PROTOCOL_PRO_FEATURES bitset) {
396-
return Napi::BigInt::New(env, bitset);
394+
Napi::BigInt proProfileBitsetToJS(const Napi::Env& env, const ProProfileBitset bitset) {
395+
return Napi::BigInt::New(env, bitset.data);
396+
}
397+
398+
Napi::BigInt proMessageBitsetToJS(const Napi::Env& env, const ProMessageBitset bitset) {
399+
return Napi::BigInt::New(env, bitset.data);
397400
}
398401

399402
std::span<const uint8_t> from_hex_to_span(std::string_view x) {

types/multi_encrypt/multi_encrypt.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ declare module 'libsession_util_nodejs' {
5353
};
5454
type WithNowMs = { nowMs: number };
5555

56-
type DecodedPro = WithProFeaturesBitset & {
56+
type DecodedPro = WithProProfileBitset & WithProMessageBitset & {
5757
proStatus: ProStatus;
5858
proProof: ProProof;
5959
};

types/pro/pro.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ declare module 'libsession_util_nodejs' {
1111
};
1212

1313
type ProStatus = 'ValidOrExpired' | 'Invalid';
14-
type WithProFeaturesBitset = { proFeaturesBitset: bigint };
14+
type WithProProfileBitset = { proProfileBitset: bigint };
15+
type WithProMessageBitset = { proMessageBitset: bigint };
1516
type WithGenIndexHash = { genIndexHashB64: string };
1617

1718
type WithRequestVersion = { requestVersion: number };
@@ -157,11 +158,7 @@ declare module 'libsession_util_nodejs' {
157158
};
158159

159160
type ProWrapper = {
160-
proFeaturesForMessage: (
161-
args: WithProFeaturesBitset & {
162-
utf16: string;
163-
}
164-
) => WithProFeaturesBitset & {
161+
proFeaturesForMessage: (args: { utf16: string }) => WithProMessageBitset & {
165162
status: 'SUCCESS' | 'UTF_DECODING_ERROR' | 'EXCEEDS_CHARACTER_LIMIT';
166163
};
167164
proProofRequestBody: (

0 commit comments

Comments
 (0)