@haex-space/vault-sdk 2.5.111 → 2.5.113
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/{client-DFGx115H.d.mts → client-Dfy9UQeu.d.mts} +161 -1
- package/dist/{client-8dlKVNDZ.d.ts → client-Dhn288AJ.d.ts} +161 -1
- package/dist/index.d.mts +49 -51
- package/dist/index.d.ts +49 -51
- package/dist/index.js +149 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +123 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +123 -0
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +1 -1
- package/dist/runtime/nuxt.plugin.client.d.ts +1 -1
- package/dist/runtime/nuxt.plugin.client.js +123 -0
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +123 -0
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +123 -0
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +123 -0
- package/dist/svelte.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +123 -0
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +123 -0
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -674,6 +674,22 @@ var LOCALSEND_COMMANDS = {
|
|
|
674
674
|
cancelSend: "localsend_cancel_send"
|
|
675
675
|
};
|
|
676
676
|
|
|
677
|
+
// src/commands/spaces.ts
|
|
678
|
+
var SPACE_COMMANDS = {
|
|
679
|
+
/** Bulk assign rows to spaces */
|
|
680
|
+
assign: "extension_space_assign",
|
|
681
|
+
/** Bulk unassign rows from spaces */
|
|
682
|
+
unassign: "extension_space_unassign",
|
|
683
|
+
/** Get space assignments for a table */
|
|
684
|
+
getAssignments: "extension_space_get_assignments",
|
|
685
|
+
/** List all spaces the user is a member of (with decrypted names) */
|
|
686
|
+
list: "extension_space_list",
|
|
687
|
+
/** Create a new shared space */
|
|
688
|
+
create: "extension_space_create",
|
|
689
|
+
/** List available sync backends */
|
|
690
|
+
listBackends: "extension_space_list_backends"
|
|
691
|
+
};
|
|
692
|
+
|
|
677
693
|
// src/commands/index.ts
|
|
678
694
|
var TAURI_COMMANDS = {
|
|
679
695
|
database: DATABASE_COMMANDS,
|
|
@@ -684,7 +700,8 @@ var TAURI_COMMANDS = {
|
|
|
684
700
|
externalBridge: EXTERNAL_BRIDGE_COMMANDS,
|
|
685
701
|
extension: EXTENSION_COMMANDS,
|
|
686
702
|
remoteStorage: REMOTE_STORAGE_COMMANDS,
|
|
687
|
-
localsend: LOCALSEND_COMMANDS
|
|
703
|
+
localsend: LOCALSEND_COMMANDS,
|
|
704
|
+
spaces: SPACE_COMMANDS
|
|
688
705
|
};
|
|
689
706
|
|
|
690
707
|
// src/api/storage.ts
|
|
@@ -1686,6 +1703,112 @@ var LocalSendAPI = class {
|
|
|
1686
1703
|
}
|
|
1687
1704
|
};
|
|
1688
1705
|
|
|
1706
|
+
// src/api/spaces.ts
|
|
1707
|
+
var SpacesAPI = class {
|
|
1708
|
+
constructor(client) {
|
|
1709
|
+
this.client = client;
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Bulk assign rows to spaces.
|
|
1713
|
+
* @param assignments - Array of row-to-space mappings
|
|
1714
|
+
* @returns Number of assignments created
|
|
1715
|
+
*/
|
|
1716
|
+
async assignAsync(assignments) {
|
|
1717
|
+
return this.client.request(SPACE_COMMANDS.assign, {
|
|
1718
|
+
assignments: assignments.map(toSnakeCase)
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Bulk unassign rows from spaces.
|
|
1723
|
+
* @param assignments - Array of row-to-space mappings to remove
|
|
1724
|
+
* @returns Number of assignments removed
|
|
1725
|
+
*/
|
|
1726
|
+
async unassignAsync(assignments) {
|
|
1727
|
+
return this.client.request(SPACE_COMMANDS.unassign, {
|
|
1728
|
+
assignments: assignments.map(toSnakeCase)
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Get space assignments for a table, optionally filtered by row.
|
|
1733
|
+
* @param tableName - The table to query assignments for
|
|
1734
|
+
* @param rowPks - Optional row primary key(s) to filter by
|
|
1735
|
+
* @returns Array of space assignments
|
|
1736
|
+
*/
|
|
1737
|
+
async getAssignmentsAsync(tableName, rowPks) {
|
|
1738
|
+
const result = await this.client.request(
|
|
1739
|
+
SPACE_COMMANDS.getAssignments,
|
|
1740
|
+
{
|
|
1741
|
+
table_name: tableName,
|
|
1742
|
+
row_pks: rowPks
|
|
1743
|
+
}
|
|
1744
|
+
);
|
|
1745
|
+
return result.map(fromSnakeCase);
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Convenience method to assign a single row to a space.
|
|
1749
|
+
* @param tableName - The table name
|
|
1750
|
+
* @param rowPks - The row primary key(s)
|
|
1751
|
+
* @param spaceId - The space ID to assign to
|
|
1752
|
+
* @returns Number of assignments created (0 or 1)
|
|
1753
|
+
*/
|
|
1754
|
+
async assignRowAsync(tableName, rowPks, spaceId) {
|
|
1755
|
+
return this.assignAsync([{ tableName, rowPks, spaceId }]);
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Convenience method to unassign a single row from a space.
|
|
1759
|
+
* @param tableName - The table name
|
|
1760
|
+
* @param rowPks - The row primary key(s)
|
|
1761
|
+
* @param spaceId - The space ID to unassign from
|
|
1762
|
+
* @returns Number of assignments removed (0 or 1)
|
|
1763
|
+
*/
|
|
1764
|
+
async unassignRowAsync(tableName, rowPks, spaceId) {
|
|
1765
|
+
return this.unassignAsync([{ tableName, rowPks, spaceId }]);
|
|
1766
|
+
}
|
|
1767
|
+
// ==========================================================================
|
|
1768
|
+
// Space Management
|
|
1769
|
+
// ==========================================================================
|
|
1770
|
+
/**
|
|
1771
|
+
* List all shared spaces the user is a member of.
|
|
1772
|
+
* Returns spaces with decrypted names (decryption happens vault-side).
|
|
1773
|
+
*/
|
|
1774
|
+
async listSpacesAsync() {
|
|
1775
|
+
return this.client.request(SPACE_COMMANDS.list);
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Create a new shared space.
|
|
1779
|
+
* @param name - Human-readable space name
|
|
1780
|
+
* @param serverUrl - The sync server URL to create the space on
|
|
1781
|
+
* @returns The created space with decrypted name
|
|
1782
|
+
*/
|
|
1783
|
+
async createSpaceAsync(name, serverUrl) {
|
|
1784
|
+
return this.client.request(SPACE_COMMANDS.create, {
|
|
1785
|
+
name,
|
|
1786
|
+
server_url: serverUrl
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* List available sync backends that can host shared spaces.
|
|
1791
|
+
* @returns Array of backend info with server URLs
|
|
1792
|
+
*/
|
|
1793
|
+
async listSyncBackendsAsync() {
|
|
1794
|
+
return this.client.request(SPACE_COMMANDS.listBackends);
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
function toSnakeCase(assignment) {
|
|
1798
|
+
return {
|
|
1799
|
+
table_name: assignment.tableName,
|
|
1800
|
+
row_pks: assignment.rowPks,
|
|
1801
|
+
space_id: assignment.spaceId
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
function fromSnakeCase(assignment) {
|
|
1805
|
+
return {
|
|
1806
|
+
tableName: assignment.table_name,
|
|
1807
|
+
rowPks: assignment.row_pks,
|
|
1808
|
+
spaceId: assignment.space_id
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1689
1812
|
// src/client/tableName.ts
|
|
1690
1813
|
function validatePublicKey(publicKey) {
|
|
1691
1814
|
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
@@ -2310,6 +2433,7 @@ var HaexVaultSdk = class {
|
|
|
2310
2433
|
this.permissions = new PermissionsAPI(this);
|
|
2311
2434
|
this.remoteStorage = new RemoteStorageAPI(this);
|
|
2312
2435
|
this.localsend = new LocalSendAPI(this);
|
|
2436
|
+
this.spaces = new SpacesAPI(this);
|
|
2313
2437
|
installConsoleForwarding(this.config.debug);
|
|
2314
2438
|
this.readyPromise = new Promise((resolve) => {
|
|
2315
2439
|
this.resolveReady = resolve;
|
|
@@ -2859,6 +2983,27 @@ async function decryptSpaceKeyAsync(encrypted, ownPrivateKeyBase64) {
|
|
|
2859
2983
|
);
|
|
2860
2984
|
return new Uint8Array(decrypted);
|
|
2861
2985
|
}
|
|
2986
|
+
async function encryptSpaceNameAsync(spaceKey, spaceName) {
|
|
2987
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
2988
|
+
"raw",
|
|
2989
|
+
new Uint8Array(spaceKey).buffer,
|
|
2990
|
+
{ name: "AES-GCM" },
|
|
2991
|
+
false,
|
|
2992
|
+
["encrypt"]
|
|
2993
|
+
);
|
|
2994
|
+
const { encryptedData, nonce } = await encryptString(spaceName, cryptoKey);
|
|
2995
|
+
return { encryptedName: encryptedData, nameNonce: nonce };
|
|
2996
|
+
}
|
|
2997
|
+
async function decryptSpaceNameAsync(spaceKey, encryptedName, nameNonce) {
|
|
2998
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
2999
|
+
"raw",
|
|
3000
|
+
new Uint8Array(spaceKey).buffer,
|
|
3001
|
+
{ name: "AES-GCM" },
|
|
3002
|
+
false,
|
|
3003
|
+
["decrypt"]
|
|
3004
|
+
);
|
|
3005
|
+
return decryptString(encryptedName, nameNonce, cryptoKey);
|
|
3006
|
+
}
|
|
2862
3007
|
|
|
2863
3008
|
// src/crypto/recordSigning.ts
|
|
2864
3009
|
function canonicalize(record) {
|
|
@@ -3092,6 +3237,6 @@ function createHaexVaultSdk(config = {}) {
|
|
|
3092
3237
|
return new HaexVaultSdk(config);
|
|
3093
3238
|
}
|
|
3094
3239
|
|
|
3095
|
-
export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, LOCALSEND_EVENTS, LocalSendAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SIGNING_ALGO, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
|
|
3240
|
+
export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, LOCALSEND_EVENTS, LocalSendAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SIGNING_ALGO, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
|
|
3096
3241
|
//# sourceMappingURL=index.mjs.map
|
|
3097
3242
|
//# sourceMappingURL=index.mjs.map
|