@haex-space/vault-sdk 2.5.86 → 2.5.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -185,6 +185,52 @@ var REMOTE_STORAGE_COMMANDS = {
185
185
  list: "extension_remote_storage_list"
186
186
  };
187
187
 
188
+ // src/commands/localsend.ts
189
+ var LOCALSEND_COMMANDS = {
190
+ // Initialization
191
+ /** Initialize LocalSend (generate identity, etc.) */
192
+ init: "localsend_init",
193
+ /** Get our device info */
194
+ getDeviceInfo: "localsend_get_device_info",
195
+ /** Set our device alias */
196
+ setAlias: "localsend_set_alias",
197
+ // Settings
198
+ /** Get current settings */
199
+ getSettings: "localsend_get_settings",
200
+ /** Update settings */
201
+ setSettings: "localsend_set_settings",
202
+ // Discovery (desktop only)
203
+ /** Start device discovery via multicast UDP */
204
+ startDiscovery: "localsend_start_discovery",
205
+ /** Stop device discovery */
206
+ stopDiscovery: "localsend_stop_discovery",
207
+ /** Get list of discovered devices */
208
+ getDevices: "localsend_get_devices",
209
+ // Network scan (mobile only)
210
+ /** Scan network for devices via HTTP */
211
+ scanNetwork: "localsend_scan_network",
212
+ // Server (receiving files)
213
+ /** Start the HTTPS server for receiving files */
214
+ startServer: "localsend_start_server",
215
+ /** Stop the HTTPS server */
216
+ stopServer: "localsend_stop_server",
217
+ /** Get server status */
218
+ getServerStatus: "localsend_get_server_status",
219
+ /** Get pending incoming transfer requests */
220
+ getPendingTransfers: "localsend_get_pending_transfers",
221
+ /** Accept an incoming transfer */
222
+ acceptTransfer: "localsend_accept_transfer",
223
+ /** Reject an incoming transfer */
224
+ rejectTransfer: "localsend_reject_transfer",
225
+ // Client (sending files)
226
+ /** Prepare files for sending - collect metadata */
227
+ prepareFiles: "localsend_prepare_files",
228
+ /** Send files to a device */
229
+ sendFiles: "localsend_send_files",
230
+ /** Cancel an outgoing transfer */
231
+ cancelSend: "localsend_cancel_send"
232
+ };
233
+
188
234
  // src/api/storage.ts
189
235
  var StorageAPI = class {
190
236
  constructor(client) {
@@ -822,6 +868,163 @@ var BackendManagement = class {
822
868
  }
823
869
  };
824
870
 
871
+ // src/api/localsend.ts
872
+ var LocalSendAPI = class {
873
+ constructor(client) {
874
+ this.client = client;
875
+ }
876
+ // ==========================================================================
877
+ // Initialization
878
+ // ==========================================================================
879
+ /**
880
+ * Initialize LocalSend (generate identity, etc.)
881
+ * Call this on app start
882
+ * @returns Our device info
883
+ */
884
+ async init() {
885
+ return this.client.request(LOCALSEND_COMMANDS.init, {});
886
+ }
887
+ /**
888
+ * Get our device info
889
+ * @returns Our device info
890
+ */
891
+ async getDeviceInfo() {
892
+ return this.client.request(LOCALSEND_COMMANDS.getDeviceInfo, {});
893
+ }
894
+ /**
895
+ * Set our device alias (display name)
896
+ * @param alias New alias
897
+ */
898
+ async setAlias(alias) {
899
+ await this.client.request(LOCALSEND_COMMANDS.setAlias, { alias });
900
+ }
901
+ // ==========================================================================
902
+ // Settings
903
+ // ==========================================================================
904
+ /**
905
+ * Get current LocalSend settings
906
+ * @returns Settings
907
+ */
908
+ async getSettings() {
909
+ return this.client.request(LOCALSEND_COMMANDS.getSettings, {});
910
+ }
911
+ /**
912
+ * Update LocalSend settings
913
+ * @param settings New settings
914
+ */
915
+ async setSettings(settings) {
916
+ await this.client.request(LOCALSEND_COMMANDS.setSettings, { settings });
917
+ }
918
+ // ==========================================================================
919
+ // Discovery (Desktop only - multicast UDP)
920
+ // ==========================================================================
921
+ /**
922
+ * Start device discovery via multicast UDP
923
+ * Desktop only - on mobile use scanNetwork()
924
+ */
925
+ async startDiscovery() {
926
+ await this.client.request(LOCALSEND_COMMANDS.startDiscovery, {});
927
+ }
928
+ /**
929
+ * Stop device discovery
930
+ * Desktop only
931
+ */
932
+ async stopDiscovery() {
933
+ await this.client.request(LOCALSEND_COMMANDS.stopDiscovery, {});
934
+ }
935
+ /**
936
+ * Get list of discovered devices
937
+ * @returns Array of discovered devices
938
+ */
939
+ async getDevices() {
940
+ return this.client.request(LOCALSEND_COMMANDS.getDevices, {});
941
+ }
942
+ // ==========================================================================
943
+ // Network Scan (Mobile only - HTTP)
944
+ // ==========================================================================
945
+ /**
946
+ * Scan network for devices via HTTP
947
+ * Mobile only - on desktop use startDiscovery()
948
+ * @returns Array of discovered devices
949
+ */
950
+ async scanNetwork() {
951
+ return this.client.request(LOCALSEND_COMMANDS.scanNetwork, {});
952
+ }
953
+ // ==========================================================================
954
+ // Server (Receiving files)
955
+ // ==========================================================================
956
+ /**
957
+ * Start the HTTPS server for receiving files
958
+ * @param port Optional port to listen on (default: 53317)
959
+ * @returns Server info with port, fingerprint, and addresses
960
+ */
961
+ async startServer(port) {
962
+ return this.client.request(LOCALSEND_COMMANDS.startServer, { port });
963
+ }
964
+ /**
965
+ * Stop the HTTPS server
966
+ */
967
+ async stopServer() {
968
+ await this.client.request(LOCALSEND_COMMANDS.stopServer, {});
969
+ }
970
+ /**
971
+ * Get server status
972
+ * @returns Server status
973
+ */
974
+ async getServerStatus() {
975
+ return this.client.request(LOCALSEND_COMMANDS.getServerStatus, {});
976
+ }
977
+ /**
978
+ * Get pending incoming transfer requests
979
+ * @returns Array of pending transfers
980
+ */
981
+ async getPendingTransfers() {
982
+ return this.client.request(LOCALSEND_COMMANDS.getPendingTransfers, {});
983
+ }
984
+ /**
985
+ * Accept an incoming transfer
986
+ * @param sessionId Session ID of the transfer
987
+ * @param saveDir Directory to save files to
988
+ */
989
+ async acceptTransfer(sessionId, saveDir) {
990
+ await this.client.request(LOCALSEND_COMMANDS.acceptTransfer, { sessionId, saveDir });
991
+ }
992
+ /**
993
+ * Reject an incoming transfer
994
+ * @param sessionId Session ID of the transfer
995
+ */
996
+ async rejectTransfer(sessionId) {
997
+ await this.client.request(LOCALSEND_COMMANDS.rejectTransfer, { sessionId });
998
+ }
999
+ // ==========================================================================
1000
+ // Client (Sending files)
1001
+ // ==========================================================================
1002
+ /**
1003
+ * Prepare files for sending - collect metadata
1004
+ * @param paths Array of file/folder paths to send
1005
+ * @returns Array of file info with metadata
1006
+ */
1007
+ async prepareFiles(paths) {
1008
+ return this.client.request(LOCALSEND_COMMANDS.prepareFiles, { paths });
1009
+ }
1010
+ /**
1011
+ * Send files to a device
1012
+ * @param device Target device
1013
+ * @param files Files to send (from prepareFiles)
1014
+ * @returns Session ID for tracking progress
1015
+ */
1016
+ async sendFiles(device, files) {
1017
+ return this.client.request(LOCALSEND_COMMANDS.sendFiles, { device, files });
1018
+ }
1019
+ /**
1020
+ * Cancel an outgoing transfer
1021
+ * @param sessionId Session ID of the transfer
1022
+ */
1023
+ async cancelSend(sessionId) {
1024
+ await this.client.request(LOCALSEND_COMMANDS.cancelSend, { sessionId });
1025
+ }
1026
+ };
1027
+
825
1028
  // src/messages.ts
826
1029
  var HAEXSPACE_MESSAGE_TYPES = {
827
1030
  /** Debug message for development/troubleshooting */
@@ -1075,6 +1278,25 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1075
1278
  console.error("[HaexVault SDK] Failed to setup file change listener:", error);
1076
1279
  log("Failed to setup file change listener:", error);
1077
1280
  }
1281
+ console.log("[HaexVault SDK] About to register sync tables updated listener for:", HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED);
1282
+ try {
1283
+ await listen(HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED, (event) => {
1284
+ console.log("[HaexVault SDK] Sync tables updated event received:", event.payload);
1285
+ log("Received sync tables updated event:", event);
1286
+ if (event.payload) {
1287
+ const payload = event.payload;
1288
+ onEvent({
1289
+ type: HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED,
1290
+ data: { tables: payload.tables },
1291
+ timestamp: Date.now()
1292
+ });
1293
+ }
1294
+ });
1295
+ console.log("[HaexVault SDK] Sync tables updated listener registered successfully");
1296
+ } catch (error) {
1297
+ console.error("[HaexVault SDK] Failed to setup sync tables updated listener:", error);
1298
+ log("Failed to setup sync tables updated listener:", error);
1299
+ }
1078
1300
  }
1079
1301
  async function initIframeMode(ctx, log, messageHandler, request) {
1080
1302
  if (!isInIframe()) {
@@ -1408,6 +1630,7 @@ var HaexVaultSdk = class {
1408
1630
  this.web = new WebAPI(this);
1409
1631
  this.permissions = new PermissionsAPI(this);
1410
1632
  this.remoteStorage = new RemoteStorageAPI(this);
1633
+ this.localsend = new LocalSendAPI(this);
1411
1634
  installConsoleForwarding(this.config.debug);
1412
1635
  this.readyPromise = new Promise((resolve) => {
1413
1636
  this.resolveReady = resolve;