@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.
package/dist/svelte.mjs CHANGED
@@ -511,6 +511,52 @@ var REMOTE_STORAGE_COMMANDS = {
511
511
  list: "extension_remote_storage_list"
512
512
  };
513
513
 
514
+ // src/commands/localsend.ts
515
+ var LOCALSEND_COMMANDS = {
516
+ // Initialization
517
+ /** Initialize LocalSend (generate identity, etc.) */
518
+ init: "localsend_init",
519
+ /** Get our device info */
520
+ getDeviceInfo: "localsend_get_device_info",
521
+ /** Set our device alias */
522
+ setAlias: "localsend_set_alias",
523
+ // Settings
524
+ /** Get current settings */
525
+ getSettings: "localsend_get_settings",
526
+ /** Update settings */
527
+ setSettings: "localsend_set_settings",
528
+ // Discovery (desktop only)
529
+ /** Start device discovery via multicast UDP */
530
+ startDiscovery: "localsend_start_discovery",
531
+ /** Stop device discovery */
532
+ stopDiscovery: "localsend_stop_discovery",
533
+ /** Get list of discovered devices */
534
+ getDevices: "localsend_get_devices",
535
+ // Network scan (mobile only)
536
+ /** Scan network for devices via HTTP */
537
+ scanNetwork: "localsend_scan_network",
538
+ // Server (receiving files)
539
+ /** Start the HTTPS server for receiving files */
540
+ startServer: "localsend_start_server",
541
+ /** Stop the HTTPS server */
542
+ stopServer: "localsend_stop_server",
543
+ /** Get server status */
544
+ getServerStatus: "localsend_get_server_status",
545
+ /** Get pending incoming transfer requests */
546
+ getPendingTransfers: "localsend_get_pending_transfers",
547
+ /** Accept an incoming transfer */
548
+ acceptTransfer: "localsend_accept_transfer",
549
+ /** Reject an incoming transfer */
550
+ rejectTransfer: "localsend_reject_transfer",
551
+ // Client (sending files)
552
+ /** Prepare files for sending - collect metadata */
553
+ prepareFiles: "localsend_prepare_files",
554
+ /** Send files to a device */
555
+ sendFiles: "localsend_send_files",
556
+ /** Cancel an outgoing transfer */
557
+ cancelSend: "localsend_cancel_send"
558
+ };
559
+
514
560
  // src/api/storage.ts
515
561
  var StorageAPI = class {
516
562
  constructor(client) {
@@ -1148,6 +1194,163 @@ var BackendManagement = class {
1148
1194
  }
1149
1195
  };
1150
1196
 
1197
+ // src/api/localsend.ts
1198
+ var LocalSendAPI = class {
1199
+ constructor(client) {
1200
+ this.client = client;
1201
+ }
1202
+ // ==========================================================================
1203
+ // Initialization
1204
+ // ==========================================================================
1205
+ /**
1206
+ * Initialize LocalSend (generate identity, etc.)
1207
+ * Call this on app start
1208
+ * @returns Our device info
1209
+ */
1210
+ async init() {
1211
+ return this.client.request(LOCALSEND_COMMANDS.init, {});
1212
+ }
1213
+ /**
1214
+ * Get our device info
1215
+ * @returns Our device info
1216
+ */
1217
+ async getDeviceInfo() {
1218
+ return this.client.request(LOCALSEND_COMMANDS.getDeviceInfo, {});
1219
+ }
1220
+ /**
1221
+ * Set our device alias (display name)
1222
+ * @param alias New alias
1223
+ */
1224
+ async setAlias(alias) {
1225
+ await this.client.request(LOCALSEND_COMMANDS.setAlias, { alias });
1226
+ }
1227
+ // ==========================================================================
1228
+ // Settings
1229
+ // ==========================================================================
1230
+ /**
1231
+ * Get current LocalSend settings
1232
+ * @returns Settings
1233
+ */
1234
+ async getSettings() {
1235
+ return this.client.request(LOCALSEND_COMMANDS.getSettings, {});
1236
+ }
1237
+ /**
1238
+ * Update LocalSend settings
1239
+ * @param settings New settings
1240
+ */
1241
+ async setSettings(settings) {
1242
+ await this.client.request(LOCALSEND_COMMANDS.setSettings, { settings });
1243
+ }
1244
+ // ==========================================================================
1245
+ // Discovery (Desktop only - multicast UDP)
1246
+ // ==========================================================================
1247
+ /**
1248
+ * Start device discovery via multicast UDP
1249
+ * Desktop only - on mobile use scanNetwork()
1250
+ */
1251
+ async startDiscovery() {
1252
+ await this.client.request(LOCALSEND_COMMANDS.startDiscovery, {});
1253
+ }
1254
+ /**
1255
+ * Stop device discovery
1256
+ * Desktop only
1257
+ */
1258
+ async stopDiscovery() {
1259
+ await this.client.request(LOCALSEND_COMMANDS.stopDiscovery, {});
1260
+ }
1261
+ /**
1262
+ * Get list of discovered devices
1263
+ * @returns Array of discovered devices
1264
+ */
1265
+ async getDevices() {
1266
+ return this.client.request(LOCALSEND_COMMANDS.getDevices, {});
1267
+ }
1268
+ // ==========================================================================
1269
+ // Network Scan (Mobile only - HTTP)
1270
+ // ==========================================================================
1271
+ /**
1272
+ * Scan network for devices via HTTP
1273
+ * Mobile only - on desktop use startDiscovery()
1274
+ * @returns Array of discovered devices
1275
+ */
1276
+ async scanNetwork() {
1277
+ return this.client.request(LOCALSEND_COMMANDS.scanNetwork, {});
1278
+ }
1279
+ // ==========================================================================
1280
+ // Server (Receiving files)
1281
+ // ==========================================================================
1282
+ /**
1283
+ * Start the HTTPS server for receiving files
1284
+ * @param port Optional port to listen on (default: 53317)
1285
+ * @returns Server info with port, fingerprint, and addresses
1286
+ */
1287
+ async startServer(port) {
1288
+ return this.client.request(LOCALSEND_COMMANDS.startServer, { port });
1289
+ }
1290
+ /**
1291
+ * Stop the HTTPS server
1292
+ */
1293
+ async stopServer() {
1294
+ await this.client.request(LOCALSEND_COMMANDS.stopServer, {});
1295
+ }
1296
+ /**
1297
+ * Get server status
1298
+ * @returns Server status
1299
+ */
1300
+ async getServerStatus() {
1301
+ return this.client.request(LOCALSEND_COMMANDS.getServerStatus, {});
1302
+ }
1303
+ /**
1304
+ * Get pending incoming transfer requests
1305
+ * @returns Array of pending transfers
1306
+ */
1307
+ async getPendingTransfers() {
1308
+ return this.client.request(LOCALSEND_COMMANDS.getPendingTransfers, {});
1309
+ }
1310
+ /**
1311
+ * Accept an incoming transfer
1312
+ * @param sessionId Session ID of the transfer
1313
+ * @param saveDir Directory to save files to
1314
+ */
1315
+ async acceptTransfer(sessionId, saveDir) {
1316
+ await this.client.request(LOCALSEND_COMMANDS.acceptTransfer, { sessionId, saveDir });
1317
+ }
1318
+ /**
1319
+ * Reject an incoming transfer
1320
+ * @param sessionId Session ID of the transfer
1321
+ */
1322
+ async rejectTransfer(sessionId) {
1323
+ await this.client.request(LOCALSEND_COMMANDS.rejectTransfer, { sessionId });
1324
+ }
1325
+ // ==========================================================================
1326
+ // Client (Sending files)
1327
+ // ==========================================================================
1328
+ /**
1329
+ * Prepare files for sending - collect metadata
1330
+ * @param paths Array of file/folder paths to send
1331
+ * @returns Array of file info with metadata
1332
+ */
1333
+ async prepareFiles(paths) {
1334
+ return this.client.request(LOCALSEND_COMMANDS.prepareFiles, { paths });
1335
+ }
1336
+ /**
1337
+ * Send files to a device
1338
+ * @param device Target device
1339
+ * @param files Files to send (from prepareFiles)
1340
+ * @returns Session ID for tracking progress
1341
+ */
1342
+ async sendFiles(device, files) {
1343
+ return this.client.request(LOCALSEND_COMMANDS.sendFiles, { device, files });
1344
+ }
1345
+ /**
1346
+ * Cancel an outgoing transfer
1347
+ * @param sessionId Session ID of the transfer
1348
+ */
1349
+ async cancelSend(sessionId) {
1350
+ await this.client.request(LOCALSEND_COMMANDS.cancelSend, { sessionId });
1351
+ }
1352
+ };
1353
+
1151
1354
  // src/client/tableName.ts
1152
1355
  function validatePublicKey(publicKey) {
1153
1356
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1327,6 +1530,25 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
1327
1530
  console.error("[HaexVault SDK] Failed to setup file change listener:", error);
1328
1531
  log("Failed to setup file change listener:", error);
1329
1532
  }
1533
+ console.log("[HaexVault SDK] About to register sync tables updated listener for:", HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED);
1534
+ try {
1535
+ await listen(HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED, (event) => {
1536
+ console.log("[HaexVault SDK] Sync tables updated event received:", event.payload);
1537
+ log("Received sync tables updated event:", event);
1538
+ if (event.payload) {
1539
+ const payload = event.payload;
1540
+ onEvent({
1541
+ type: HAEXTENSION_EVENTS.SYNC_TABLES_UPDATED,
1542
+ data: { tables: payload.tables },
1543
+ timestamp: Date.now()
1544
+ });
1545
+ }
1546
+ });
1547
+ console.log("[HaexVault SDK] Sync tables updated listener registered successfully");
1548
+ } catch (error) {
1549
+ console.error("[HaexVault SDK] Failed to setup sync tables updated listener:", error);
1550
+ log("Failed to setup sync tables updated listener:", error);
1551
+ }
1330
1552
  }
1331
1553
  async function initIframeMode(ctx, log, messageHandler, request) {
1332
1554
  if (!isInIframe()) {
@@ -1660,6 +1882,7 @@ var HaexVaultSdk = class {
1660
1882
  this.web = new WebAPI(this);
1661
1883
  this.permissions = new PermissionsAPI(this);
1662
1884
  this.remoteStorage = new RemoteStorageAPI(this);
1885
+ this.localsend = new LocalSendAPI(this);
1663
1886
  installConsoleForwarding(this.config.debug);
1664
1887
  this.readyPromise = new Promise((resolve) => {
1665
1888
  this.resolveReady = resolve;