@@ -110,19 +110,21 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
110110 static_cast <napi_property_attributes>(
111111 napi_writable | napi_configurable)),
112112
113+ // Note: those are not plugged in for now as we do this parsing through zod
114+ // on desktop.
113115 // Pro responses parsing
114- StaticMethod<&ProWrapper::proProofParseResponse>(
115- " proProofParseResponse" ,
116- static_cast <napi_property_attributes>(
117- napi_writable | napi_configurable)),
118- StaticMethod<&ProWrapper::proRevocationsParseResponse>(
119- " proRevocationsParseResponse" ,
120- static_cast <napi_property_attributes>(
121- napi_writable | napi_configurable)),
122- StaticMethod<&ProWrapper::proStatusParseResponse>(
123- " proStatusParseResponse" ,
124- static_cast <napi_property_attributes>(
125- napi_writable | napi_configurable)),
116+ // StaticMethod<&ProWrapper::proProofParseResponse>(
117+ // "proProofParseResponse",
118+ // static_cast<napi_property_attributes>(
119+ // napi_writable | napi_configurable)),
120+ // StaticMethod<&ProWrapper::proRevocationsParseResponse>(
121+ // "proRevocationsParseResponse",
122+ // static_cast<napi_property_attributes>(
123+ // napi_writable | napi_configurable)),
124+ // StaticMethod<&ProWrapper::proStatusParseResponse>(
125+ // "proStatusParseResponse",
126+ // static_cast<napi_property_attributes>(
127+ // napi_writable | napi_configurable)),
126128 });
127129 }
128130
@@ -187,8 +189,8 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
187189 // we expect arguments that match:
188190 // first: {
189191 // "requestVersion": number,
190- // "masterPrivkey ": Uint8Array ,
191- // "rotatingPrivkey ": Uint8Array ,
192+ // "masterPrivKeyHex ": string ,
193+ // "rotatingPrivKeyHex ": string ,
192194 // "unixTsMs": number,
193195 // }
194196
@@ -197,32 +199,35 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
197199 auto env = info.Env ();
198200
199201 auto first = info[0 ].As <Napi::Object>();
200-
201202 if (first.IsEmpty ())
202203 throw std::invalid_argument (" proProofRequestBody first received empty" );
203204
204205 assertIsNumber (first.Get (" requestVersion" ), " proProofRequestBody.requestVersion" );
206+ Napi::Number requestVersion = first.Get (" requestVersion" ).As <Napi::Number>();
205207 assertIsNumber (first.Get (" unixTsMs" ), " proProofRequestBody.unixTsMs" );
206- auto requestVersion = first.Get (" requestVersion" ).As <Napi::Number>();
207208 auto unix_ts_ms = toCppSysMs (first.Get (" unixTsMs" ), " proProofRequestBody.unixTsMs" );
208209
209- assertIsUInt8Array (first.Get (" masterPrivkey" ), " proProofRequestBody.masterPrivkey" );
210- assertIsUInt8Array (first.Get (" rotatingPrivkey" ), " proProofRequestBody.rotatingPrivkey" );
210+ assertIsString (first.Get (" masterPrivKeyHex" ), " proProofRequestBody.masterPrivKeyHex" );
211+ assertIsString (
212+ first.Get (" rotatingPrivKeyHex" ), " proProofRequestBody.rotatingPrivKeyHex" );
211213
212- auto master_privkey_js = first.Get (" masterPrivkey" );
213- auto rotating_privkey_js = first.Get (" rotatingPrivkey" );
214- auto master_privkey =
215- toCppBuffer (master_privkey_js, " proProofRequestBody.masterPrivkey" );
216- auto rotating_privkey =
217- toCppBuffer (rotating_privkey_js, " proProofRequestBody.rotatingPrivkey" );
214+ auto master_privkey_js = first.Get (" masterPrivKeyHex" );
215+ auto rotating_privkey_js = first.Get (" rotatingPrivKeyHex" );
216+ std::string master_privkey =
217+ toCppString (master_privkey_js, " proProofRequestBody.masterPrivKeyHex" );
218+ std::string rotating_privkey =
219+ toCppString (rotating_privkey_js, " proProofRequestBody.rotatingPrivKeyHex" );
220+
221+ assert_length (master_privkey, 64 , " masterPrivKeyHex" );
222+ assert_length (rotating_privkey, 64 , " rotatingPrivkey" );
218223
219- assert_length (master_privkey, 64 , " master_privkey" );
220- assert_length (rotating_privkey, 64 , " rotating_prevkey " );
224+ auto master_privkey_decoded = from_hex ( master_privkey);
225+ auto rotating_privkey_decoded = from_hex (rotating_privkey );
221226
222- auto json = pro_backend::GetProProofRequest::build_to_json (
227+ std::string json = pro_backend::GetProProofRequest::build_to_json (
223228 static_cast <uint8_t >(requestVersion.Int32Value ()),
224- master_privkey ,
225- rotating_privkey ,
229+ to_span (master_privkey_decoded) ,
230+ to_span (rotating_privkey_decoded) ,
226231 unix_ts_ms);
227232
228233 return json;
@@ -321,7 +326,7 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
321326 // we expect arguments that match:
322327 // first: {
323328 // "requestVersion": number,
324- // "masterPrivkey ": Uint8Array ,
329+ // "masterPrivKeyHex ": string ,
325330 // "unixTsMs": number,
326331 // "withPaymentHistory": boolean,
327332 // }
@@ -343,17 +348,17 @@ class ProWrapper : public Napi::ObjectWrap<ProWrapper> {
343348 auto unix_ts_ms = toCppSysMs (first.Get (" unixTsMs" ), " proStatusRequestBody.unixTsMs" );
344349 auto withPaymentHistory = toCppBoolean (
345350 first.Get (" withPaymentHistory" ), " proStatusRequestBody.withPaymentHistory" );
346- assertIsUInt8Array (first.Get (" masterPrivkey " ), " proStatusRequestBody.masterPrivkey " );
351+ assertIsString (first.Get (" masterPrivKeyHex " ), " proStatusRequestBody.masterPrivKeyHex " );
347352
348- auto master_privkey_js = first.Get (" masterPrivkey " );
353+ auto master_privkey_js = first.Get (" masterPrivKeyHex " );
349354 auto master_privkey =
350- toCppBuffer (master_privkey_js, " proStatusRequestBody.masterPrivkey " );
355+ toCppString (master_privkey_js, " proStatusRequestBody.masterPrivKeyHex " );
351356
352- assert_length (master_privkey, 64 , " proStatusRequestBody.master_privkey " );
357+ assert_length (master_privkey, 64 , " proStatusRequestBody.masterPrivKeyHex " );
353358
354359 auto json = pro_backend::GetProStatusRequest::build_to_json (
355360 static_cast <uint8_t >(requestVersion.Int32Value ()),
356- master_privkey,
361+ to_span ( from_hex ( master_privkey)) ,
357362 unix_ts_ms,
358363 withPaymentHistory);
359364
0 commit comments