11#pragma once
22
3+ #include < napi.h>
34#include < oxenc/base64.h>
45#include < oxenc/hex.h>
56
@@ -135,7 +136,7 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
135136 // we expect two arguments that match:
136137 // first: {
137138 // "utf16": string,
138- // "proFeatures ": Array<ProFeature> ,
139+ // "proFeaturesBitset ": bigint ,
139140 // }
140141
141142 assertInfoLength (info, 1 );
@@ -147,27 +148,13 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
147148 if (first.IsEmpty ())
148149 throw std::invalid_argument (" proFeaturesForMessage first received empty" );
149150
150- assertIsArray (first.Get (" proFeatures" ), " proFeaturesForMessage.proFeatures" );
151- auto proFeaturesJS = first.Get (" proFeatures" ).As <Napi::Array>();
152- std::vector<std::string> proFeatures;
153- proFeatures.reserve (proFeaturesJS.Length ());
154- for (uint32_t i = 0 ; i < proFeaturesJS.Length (); i++) {
155- auto itemValue = proFeaturesJS.Get (i);
156- assertIsString (itemValue, " proFeaturesForMessage.proFeatures.itemValue" );
157- std::string item =
158- toCppString (itemValue, " proFeaturesForMessage.proFeatures.itemValue" );
159- proFeatures.push_back (item);
160- }
161-
162- SESSION_PROTOCOL_PRO_EXTRA_FEATURES flags = 0 ;
163- for (std::string& feature : proFeatures) {
164- // Note: 10K_CHARACTER_LIMIT cannot be requested by the caller
165- if (feature == " PRO_BADGE" ) {
166- flags |= SESSION_PROTOCOL_PRO_EXTRA_FEATURES_PRO_BADGE;
167- } else if (feature == " ANIMATED_AVATAR" ) {
168- flags |= SESSION_PROTOCOL_PRO_EXTRA_FEATURES_ANIMATED_AVATAR;
169- }
170- }
151+ assertIsBigint (
152+ first.Get (" proFeaturesBitset" ), " proFeaturesForMessage.proFeaturesBitset" );
153+
154+ auto lossless = true ;
155+ SESSION_PROTOCOL_PRO_FEATURES flags =
156+ first.Get (" proFeaturesBitset" ).As <Napi::BigInt>().Uint64Value (&lossless);
157+
171158 assertIsString (first.Get (" utf16" ), " proFeaturesForMessage.utf16" );
172159 std::u16string utf16 = first.Get (" utf16" ).As <Napi::String>().Utf16Value ();
173160 auto pro_features_msg =
@@ -179,7 +166,7 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
179166 obj[" error" ] =
180167 pro_features_msg.error .size () ? toJs (env, pro_features_msg.error ) : env.Null ();
181168 obj[" codepointCount" ] = toJs (env, pro_features_msg.codepoint_count );
182- obj[" proFeatures " ] = proFeaturesToJs (env, pro_features_msg.features );
169+ obj[" proFeaturesBitset " ] = proFeaturesToJsBitset (env, pro_features_msg.features );
183170
184171 return obj;
185172 });
@@ -355,11 +342,12 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
355342 auto master_privkey =
356343 toCppString (master_privkey_js, " proStatusRequestBody.masterPrivKeyHex" );
357344
358- assert_length (master_privkey, 64 , " proStatusRequestBody.masterPrivKeyHex" );
345+ auto master_privkey_decoded = from_hex (master_privkey);
346+ assert_length (master_privkey_decoded, 64 , " proStatusRequestBody.masterPrivKeyHex" );
359347
360348 auto json = pro_backend::GetProStatusRequest::build_to_json (
361349 static_cast <uint8_t >(requestVersion.Int32Value ()),
362- to_span (from_hex (master_privkey) ),
350+ to_span (master_privkey_decoded ),
363351 unix_ts_ms,
364352 withPaymentHistory);
365353
0 commit comments