33#include < napi.h>
44
55#include < memory>
6+ #include < span>
7+ #include < vector>
68
79#include " oxenc/bt_producer.h"
810#include " session/types.hpp"
@@ -208,12 +210,12 @@ Napi::Value MetaGroupWrapper::metaDump(const Napi::CallbackInfo& info) {
208210 oxenc::bt_dict_producer combined;
209211
210212 // NOTE: the keys have to be in ascii-sorted order:
211- combined.append (" info" , session::from_unsigned_sv (this ->meta_group ->info ->dump ()));
212- combined.append (" keys" , session::from_unsigned_sv (this ->meta_group ->keys ->dump ()));
213- combined.append (" members" , session::from_unsigned_sv (this ->meta_group ->members ->dump ()));
213+ combined.append (" info" , session::to_string (this ->meta_group ->info ->dump ()));
214+ combined.append (" keys" , session::to_string (this ->meta_group ->keys ->dump ()));
215+ combined.append (" members" , session::to_string (this ->meta_group ->members ->dump ()));
214216 auto to_dump = std::move (combined).str ();
215217
216- return session::ustring{ to_unsigned_sv (to_dump)} ;
218+ return session::to_vector (to_dump);
217219 });
218220}
219221
@@ -222,13 +224,13 @@ Napi::Value MetaGroupWrapper::metaMakeDump(const Napi::CallbackInfo& info) {
222224 oxenc::bt_dict_producer combined;
223225
224226 // NOTE: the keys have to be in ascii-sorted order:
225- combined.append (" info" , session::from_unsigned_sv (this ->meta_group ->info ->make_dump ()));
226- combined.append (" keys" , session::from_unsigned_sv (this ->meta_group ->keys ->make_dump ()));
227+ combined.append (" info" , session::to_string (this ->meta_group ->info ->make_dump ()));
228+ combined.append (" keys" , session::to_string (this ->meta_group ->keys ->make_dump ()));
227229 combined.append (
228- " members" , session::from_unsigned_sv (this ->meta_group ->members ->make_dump ()));
230+ " members" , session::to_string (this ->meta_group ->members ->make_dump ()));
229231 auto to_dump = std::move (combined).str ();
230232
231- return ustring{ to_unsigned_sv (to_dump)} ;
233+ return session::to_vector (to_dump);
232234 });
233235}
234236
@@ -326,7 +328,7 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) {
326328 assertIsArray (groupInfo);
327329 auto asArr = groupInfo.As <Napi::Array>();
328330
329- std::vector<std::pair<std::string, ustring_view >> conf_strs;
331+ std::vector<std::pair<std::string, std::span< const unsigned char > >> conf_strs;
330332 conf_strs.reserve (asArr.Length ());
331333
332334 for (uint32_t i = 0 ; i < asArr.Length (); i++) {
@@ -353,7 +355,7 @@ Napi::Value MetaGroupWrapper::metaMerge(const Napi::CallbackInfo& info) {
353355 assertIsArray (groupMember);
354356 auto asArr = groupMember.As <Napi::Array>();
355357
356- std::vector<std::pair<std::string, ustring_view >> conf_strs;
358+ std::vector<std::pair<std::string, std::span< const unsigned char > >> conf_strs;
357359 conf_strs.reserve (asArr.Length ());
358360
359361 for (uint32_t i = 0 ; i < asArr.Length (); i++) {
@@ -790,7 +792,7 @@ Napi::Value MetaGroupWrapper::encryptMessages(const Napi::CallbackInfo& info) {
790792
791793 auto plaintextsJS = info[0 ].As <Napi::Array>();
792794 uint32_t arrayLength = plaintextsJS.Length ();
793- std::vector<session::ustring > encryptedMessages;
795+ std::vector<std::vector< unsigned char > > encryptedMessages;
794796 encryptedMessages.reserve (arrayLength);
795797
796798 for (uint32_t i = 0 ; i < plaintextsJS.Length (); i++) {
@@ -820,10 +822,10 @@ Napi::Value MetaGroupWrapper::makeSwarmSubAccount(const Napi::CallbackInfo& info
820822 assertIsString (info[0 ]);
821823
822824 auto memberPk = toCppString (info[0 ], " makeSwarmSubAccount" );
823- ustring subaccount = this ->meta_group ->keys ->swarm_make_subaccount (memberPk);
825+ std::vector< unsigned char > subaccount = this ->meta_group ->keys ->swarm_make_subaccount (memberPk);
824826
825827 session::nodeapi::checkOrThrow (
826- subaccount.length () == 100 , " expected subaccount to be 100 bytes long" );
828+ subaccount.size () == 100 , " expected subaccount to be 100 bytes long" );
827829
828830 return subaccount;
829831 });
@@ -835,12 +837,12 @@ Napi::Value MetaGroupWrapper::swarmSubAccountToken(const Napi::CallbackInfo& inf
835837 assertIsString (info[0 ]);
836838
837839 auto memberPk = toCppString (info[0 ], " swarmSubAccountToken" );
838- ustring subaccount = this ->meta_group ->keys ->swarm_subaccount_token (memberPk);
840+ std::vector< unsigned char > subaccount = this ->meta_group ->keys ->swarm_subaccount_token (memberPk);
839841
840842 session::nodeapi::checkOrThrow (
841- subaccount.length () == 36 , " expected subaccount token to be 36 bytes long" );
843+ subaccount.size () == 36 , " expected subaccount token to be 36 bytes long" );
842844
843- return oxenc::to_hex (subaccount);
845+ return oxenc::to_hex (subaccount. begin (), subaccount. end () );
844846 });
845847}
846848
0 commit comments