@haex-space/vault-sdk 2.5.40 → 2.5.42

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/index.mjs CHANGED
@@ -537,6 +537,19 @@ var HAEXTENSION_METHODS = {
537
537
  clear: "haextension:storage:clear",
538
538
  keys: "haextension:storage:keys"
539
539
  },
540
+ // Remote Storage API (S3, WebDAV, FTP, etc.)
541
+ remoteStorage: {
542
+ // Backend Management
543
+ listBackends: "haextension:remote-storage:list-backends",
544
+ addBackend: "haextension:remote-storage:add-backend",
545
+ removeBackend: "haextension:remote-storage:remove-backend",
546
+ testBackend: "haextension:remote-storage:test-backend",
547
+ // Storage Operations
548
+ upload: "haextension:remote-storage:upload",
549
+ download: "haextension:remote-storage:download",
550
+ delete: "haextension:remote-storage:delete",
551
+ list: "haextension:remote-storage:list"
552
+ },
540
553
  web: {
541
554
  fetch: "haextension:web:fetch"
542
555
  },
@@ -1231,6 +1244,111 @@ var PermissionsAPI = class {
1231
1244
  }
1232
1245
  };
1233
1246
 
1247
+ // src/api/remoteStorage.ts
1248
+ var RemoteStorageAPI = class {
1249
+ constructor(client) {
1250
+ this.client = client;
1251
+ this.backends = new BackendManagement(client);
1252
+ }
1253
+ /**
1254
+ * Upload data to a storage backend
1255
+ * @param backendId - Backend ID to upload to
1256
+ * @param key - Object key (path in the bucket)
1257
+ * @param data - Data to upload
1258
+ */
1259
+ async upload(backendId, key, data) {
1260
+ const base64 = btoa(String.fromCharCode(...data));
1261
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.upload, {
1262
+ backendId,
1263
+ key,
1264
+ data: base64
1265
+ });
1266
+ }
1267
+ /**
1268
+ * Download data from a storage backend
1269
+ * @param backendId - Backend ID to download from
1270
+ * @param key - Object key (path in the bucket)
1271
+ * @returns Downloaded data as Uint8Array
1272
+ */
1273
+ async download(backendId, key) {
1274
+ const base64 = await this.client.request(
1275
+ HAEXTENSION_METHODS.remoteStorage.download,
1276
+ { backendId, key }
1277
+ );
1278
+ const binary = atob(base64);
1279
+ const bytes = new Uint8Array(binary.length);
1280
+ for (let i = 0; i < binary.length; i++) {
1281
+ bytes[i] = binary.charCodeAt(i);
1282
+ }
1283
+ return bytes;
1284
+ }
1285
+ /**
1286
+ * Delete an object from a storage backend
1287
+ * @param backendId - Backend ID
1288
+ * @param key - Object key to delete
1289
+ */
1290
+ async delete(backendId, key) {
1291
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.delete, {
1292
+ backendId,
1293
+ key
1294
+ });
1295
+ }
1296
+ /**
1297
+ * List objects in a storage backend
1298
+ * @param backendId - Backend ID
1299
+ * @param prefix - Optional prefix to filter objects
1300
+ * @returns List of objects
1301
+ */
1302
+ async list(backendId, prefix) {
1303
+ return this.client.request(
1304
+ HAEXTENSION_METHODS.remoteStorage.list,
1305
+ { backendId, prefix }
1306
+ );
1307
+ }
1308
+ };
1309
+ var BackendManagement = class {
1310
+ constructor(client) {
1311
+ this.client = client;
1312
+ }
1313
+ /**
1314
+ * List all available storage backends
1315
+ */
1316
+ async list() {
1317
+ return this.client.request(
1318
+ HAEXTENSION_METHODS.remoteStorage.listBackends
1319
+ );
1320
+ }
1321
+ /**
1322
+ * Add a new storage backend
1323
+ * @param request - Backend configuration
1324
+ * @returns Created backend info
1325
+ */
1326
+ async add(request) {
1327
+ return this.client.request(
1328
+ HAEXTENSION_METHODS.remoteStorage.addBackend,
1329
+ request
1330
+ );
1331
+ }
1332
+ /**
1333
+ * Remove a storage backend
1334
+ * @param backendId - Backend ID to remove
1335
+ */
1336
+ async remove(backendId) {
1337
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.removeBackend, {
1338
+ backendId
1339
+ });
1340
+ }
1341
+ /**
1342
+ * Test connection to a storage backend
1343
+ * @param backendId - Backend ID to test
1344
+ */
1345
+ async test(backendId) {
1346
+ await this.client.request(HAEXTENSION_METHODS.remoteStorage.testBackend, {
1347
+ backendId
1348
+ });
1349
+ }
1350
+ };
1351
+
1234
1352
  // src/client/tableName.ts
1235
1353
  function validatePublicKey(publicKey) {
1236
1354
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -1480,6 +1598,20 @@ var TAURI_COMMANDS = {
1480
1598
  getInfo: "webview_extension_get_info",
1481
1599
  getContext: "webview_extension_context_get"
1482
1600
  },
1601
+ storage: {
1602
+ // Backend Management (generic, shared by all extensions)
1603
+ // These commands don't use webview_ prefix because storage backends are global,
1604
+ // not extension-specific. All extensions share the same storage backends.
1605
+ listBackends: "storage_list_backends",
1606
+ addBackend: "storage_add_backend",
1607
+ removeBackend: "storage_remove_backend",
1608
+ testBackend: "storage_test_backend",
1609
+ // Storage Operations
1610
+ upload: "storage_upload",
1611
+ download: "storage_download",
1612
+ delete: "storage_delete",
1613
+ list: "storage_list"
1614
+ },
1483
1615
  filesync: {
1484
1616
  // Spaces (webview_* commands extract extension info from WebviewWindow)
1485
1617
  listSpaces: "webview_filesync_list_spaces",
@@ -2100,6 +2232,7 @@ var HaexVaultSdk = class {
2100
2232
  this.filesystem = new FilesystemAPI(this);
2101
2233
  this.web = new WebAPI(this);
2102
2234
  this.permissions = new PermissionsAPI(this);
2235
+ this.remoteStorage = new RemoteStorageAPI(this);
2103
2236
  installConsoleForwarding(this.config.debug);
2104
2237
  this.readyPromise = new Promise((resolve) => {
2105
2238
  this.resolveReady = resolve;
@@ -2724,6 +2857,6 @@ function createHaexVaultSdk(config = {}) {
2724
2857
  return new HaexVaultSdk(config);
2725
2858
  }
2726
2859
 
2727
- export { CONFLICT_STRATEGY, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FILE_SYNC_STATE, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexVaultSdk, HaexVaultSdkError, PermissionStatus, PermissionsAPI, QUEUE_OPERATION, QUEUE_STATUS, STORAGE_BACKEND_TYPE, SYNC_DIRECTION, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptString, encryptVaultKey, generateVaultKey, getTableName, hexToBytes, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, wrapKey };
2860
+ export { CONFLICT_STRATEGY, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FILE_SYNC_STATE, FileSyncAPI, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HAEXTENSION_METHODS, HaexVaultSdk, HaexVaultSdkError, PermissionStatus, PermissionsAPI, QUEUE_OPERATION, QUEUE_STATUS, RemoteStorageAPI, STORAGE_BACKEND_TYPE, SYNC_DIRECTION, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptString, encryptVaultKey, generateVaultKey, getTableName, hexToBytes, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, wrapKey };
2728
2861
  //# sourceMappingURL=index.mjs.map
2729
2862
  //# sourceMappingURL=index.mjs.map