@haex-space/vault-sdk 2.5.107 → 2.5.109

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.
@@ -1,4 +1,4 @@
1
- import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-NWYbdRXr.mjs';
1
+ import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-DwLhX7mx.mjs';
2
2
  import { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
3
3
 
4
4
  declare class StorageAPI {
@@ -1,4 +1,4 @@
1
- import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-NWYbdRXr.js';
1
+ import { D as DatabaseQueryResult, M as Migration, b as MigrationResult, W as WebRequestOptions, c as WebResponse, H as HaexHubConfig, a as ExtensionInfo, A as ApplicationContext, d as DatabasePermissionRequest, P as PermissionResponse, S as SearchResult, e as ExternalRequestHandler, f as ExternalResponse, g as EventCallback } from './types-DwLhX7mx.js';
2
2
  import { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy';
3
3
 
4
4
  declare class StorageAPI {
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultSdk } from './client-CBCjziWo.mjs';
2
- export { D as DatabaseAPI, a as Device, b as DeviceInfo, c as DeviceType, d as DirEntry, F as FileStat, e as FilesystemAPI, L as LOCALSEND_EVENTS, f as LocalSendAPI, g as LocalSendEvent, h as LocalSendFileInfo, i as LocalSendSettings, P as PendingTransfer, j as PermissionsAPI, A as RemoteAddBackendRequest, k as RemoteS3Config, l as RemoteS3PublicConfig, R as RemoteStorageAPI, m as RemoteStorageBackendInfo, n as RemoteStorageObjectInfo, U as RemoteUpdateBackendRequest, o as SelectFileOptions, p as SelectFolderOptions, q as ServerInfo, r as ServerStatus, T as TransferDirection, s as TransferProgress, t as TransferState, W as WebAPI } from './client-CBCjziWo.mjs';
3
- import { h as SpaceRole, E as ExtensionManifest, H as HaexHubConfig } from './types-NWYbdRXr.mjs';
4
- export { A as ApplicationContext, i as AuthorizedClient, B as BlockedClient, C as ContextChangedEvent, j as DEFAULT_TIMEOUT, k as DatabaseColumnInfo, l as DatabaseExecuteParams, m as DatabasePermission, d as DatabasePermissionRequest, n as DatabaseQueryParams, D as DatabaseQueryResult, o as DatabaseTableInfo, p as EXTERNAL_EVENTS, q as ErrorCode, g as EventCallback, a as ExtensionInfo, r as ExtensionRuntimeMode, s as ExternalAuthDecision, t as ExternalConnection, u as ExternalConnectionErrorCode, v as ExternalConnectionState, w as ExternalEvent, x as ExternalRequest, y as ExternalRequestEvent, e as ExternalRequestHandler, z as ExternalRequestPayload, f as ExternalResponse, F as FileChangeEvent, G as FileChangePayload, I as FileChangeType, J as FilteredSyncTablesResult, K as HAEXTENSION_EVENTS, L as HaexHubEvent, N as HaexHubRequest, O as HaexHubResponse, Q as HaexVaultSdkError, R as HaextensionEvent, T as PendingAuthorization, U as PermissionDeniedError, V as PermissionErrorBase, X as PermissionErrorCode, Y as PermissionPromptError, P as PermissionResponse, Z as PermissionStatus, _ as RequestedExtension, $ as SearchQuery, a0 as SearchRequestEvent, S as SearchResult, a1 as SessionAuthorization, a2 as SharedSpace, a3 as SpaceAccessTokenInfo, a4 as SpaceInvite, a5 as SpaceKeyGrantInfo, a6 as SpaceMemberInfo, a7 as SyncTablesUpdatedEvent, a8 as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, a9 as canExternalClientSendRequests, aa as getTableName, ab as isExternalClientConnected, ac as isPermissionDeniedError, ad as isPermissionError, ae as isPermissionPromptError } from './types-NWYbdRXr.mjs';
1
+ import { H as HaexVaultSdk } from './client-C3UTSqYM.mjs';
2
+ export { D as DatabaseAPI, a as Device, b as DeviceInfo, c as DeviceType, d as DirEntry, F as FileStat, e as FilesystemAPI, L as LOCALSEND_EVENTS, f as LocalSendAPI, g as LocalSendEvent, h as LocalSendFileInfo, i as LocalSendSettings, P as PendingTransfer, j as PermissionsAPI, A as RemoteAddBackendRequest, k as RemoteS3Config, l as RemoteS3PublicConfig, R as RemoteStorageAPI, m as RemoteStorageBackendInfo, n as RemoteStorageObjectInfo, U as RemoteUpdateBackendRequest, o as SelectFileOptions, p as SelectFolderOptions, q as ServerInfo, r as ServerStatus, T as TransferDirection, s as TransferProgress, t as TransferState, W as WebAPI } from './client-C3UTSqYM.mjs';
3
+ import { E as ExtensionManifest, H as HaexHubConfig } from './types-DwLhX7mx.mjs';
4
+ export { A as ApplicationContext, h as AuthorizedClient, B as BlockedClient, C as ContextChangedEvent, i as DEFAULT_TIMEOUT, j as DatabaseColumnInfo, k as DatabaseExecuteParams, l as DatabasePermission, d as DatabasePermissionRequest, m as DatabaseQueryParams, D as DatabaseQueryResult, n as DatabaseTableInfo, o as EXTERNAL_EVENTS, p as ErrorCode, g as EventCallback, a as ExtensionInfo, q as ExtensionRuntimeMode, r as ExternalAuthDecision, s as ExternalConnection, t as ExternalConnectionErrorCode, u as ExternalConnectionState, v as ExternalEvent, w as ExternalRequest, x as ExternalRequestEvent, e as ExternalRequestHandler, y as ExternalRequestPayload, f as ExternalResponse, F as FileChangeEvent, z as FileChangePayload, G as FileChangeType, I as FilteredSyncTablesResult, J as HAEXTENSION_EVENTS, K as HaexHubEvent, L as HaexHubRequest, N as HaexHubResponse, O as HaexVaultSdkError, Q as HaextensionEvent, R as PendingAuthorization, T as PermissionDeniedError, U as PermissionErrorBase, V as PermissionErrorCode, X as PermissionPromptError, P as PermissionResponse, Y as PermissionStatus, Z as RequestedExtension, _ as SearchQuery, $ as SearchRequestEvent, S as SearchResult, a0 as SessionAuthorization, a1 as SharedSpace, a2 as SpaceAccessTokenInfo, a3 as SpaceInvite, a4 as SpaceKeyGrantInfo, a5 as SpaceMemberInfo, a6 as SpaceRole, a7 as SyncTablesUpdatedEvent, a8 as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, a9 as canExternalClientSendRequests, aa as getTableName, ab as isExternalClientConnected, ac as isPermissionDeniedError, ad as isPermissionError, ae as isPermissionPromptError } from './types-DwLhX7mx.mjs';
5
5
  export { H as HaextensionConfig } from './config-D_HXjsEV.mjs';
6
6
  import 'drizzle-orm/sqlite-proxy';
7
7
 
@@ -88,7 +88,6 @@ declare function installPolyfills(): void;
88
88
  * Types for communicating with the haex-sync-server authentication endpoints.
89
89
  * Used by haex-vault and extensions that need to interact with the sync server.
90
90
  */
91
-
92
91
  /**
93
92
  * S3-compatible storage configuration provided by the sync server.
94
93
  *
@@ -192,6 +191,7 @@ interface CreateSpaceRequest {
192
191
  id: string;
193
192
  encryptedName: string;
194
193
  nameNonce: string;
194
+ label: string;
195
195
  keyGrant: {
196
196
  encryptedSpaceKey: string;
197
197
  keyNonce: string;
@@ -199,8 +199,10 @@ interface CreateSpaceRequest {
199
199
  };
200
200
  }
201
201
  interface InviteMemberRequest {
202
- userId: string;
203
- role: SpaceRole;
202
+ publicKey: string;
203
+ label: string;
204
+ role: 'member' | 'viewer';
205
+ canInvite?: boolean;
204
206
  keyGrant: {
205
207
  encryptedSpaceKey: string;
206
208
  keyNonce: string;
@@ -796,6 +798,25 @@ interface SignableRecord {
796
798
  }
797
799
  declare function signRecordAsync(record: SignableRecord, privateKeyBase64: string): Promise<string>;
798
800
  declare function verifyRecordSignatureAsync(record: SignableRecord, signatureBase64: string, publicKeyBase64: string): Promise<boolean>;
801
+ /**
802
+ * Sign a space challenge to prove private key possession.
803
+ * Generates a fresh timestamp internally to prevent misuse.
804
+ *
805
+ * @returns signature (Base64) + timestamp (ISO 8601) to send as
806
+ * X-Space-Signature / X-Space-Timestamp headers.
807
+ */
808
+ declare function signSpaceChallengeAsync(spaceId: string, privateKeyBase64: string): Promise<{
809
+ signature: string;
810
+ timestamp: string;
811
+ }>;
812
+ /**
813
+ * Verify a space challenge signature (server-side).
814
+ * Checks both cryptographic validity and timestamp freshness (max 30s).
815
+ */
816
+ declare function verifySpaceChallengeAsync(spaceId: string, timestamp: string, signatureBase64: string, publicKeyBase64: string): Promise<{
817
+ valid: boolean;
818
+ error?: string;
819
+ }>;
799
820
 
800
821
  /**
801
822
  * Crypto utilities for WebAuthn/Passkey operations
@@ -871,4 +892,4 @@ declare function exportKeyPairAsync(keyPair: PasskeyKeyPair): Promise<ExportedPa
871
892
 
872
893
  declare function createHaexVaultSdk(config?: HaexHubConfig): HaexVaultSdk;
873
894
 
874
- export { type AuthUser, COSE_ALGORITHM, type CoseAlgorithm, type CreateSpaceRequest, type EncryptedSpaceKey, type ExportedPasskeyKeyPair, type ExportedUserKeypair, ExtensionManifest, HAEXSPACE_MESSAGE_TYPES, HaexHubConfig, HaexVaultSdk, type HaexspaceMessageType, type InviteMemberRequest, KEY_AGREEMENT_ALGO, type PasskeyKeyPair, type RegisterKeypairRequest, SIGNING_ALGO, type SignableRecord, SpaceRole, type StorageConfig, type ErrorResponse as SyncServerErrorResponse, type ServerInfo as SyncServerInfo, type LoginRequest as SyncServerLoginRequest, type LoginResponse as SyncServerLoginResponse, type RefreshRequest as SyncServerRefreshRequest, TAURI_COMMANDS, type TauriCommand, type UserKeypair, type VerifyResult, type ZipFileEntry, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, signRecordAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifyWithPasskeyAsync, wrapKey };
895
+ export { type AuthUser, COSE_ALGORITHM, type CoseAlgorithm, type CreateSpaceRequest, type EncryptedSpaceKey, type ExportedPasskeyKeyPair, type ExportedUserKeypair, ExtensionManifest, HAEXSPACE_MESSAGE_TYPES, HaexHubConfig, HaexVaultSdk, type HaexspaceMessageType, type InviteMemberRequest, KEY_AGREEMENT_ALGO, type PasskeyKeyPair, type RegisterKeypairRequest, SIGNING_ALGO, type SignableRecord, type StorageConfig, type ErrorResponse as SyncServerErrorResponse, type ServerInfo as SyncServerInfo, type LoginRequest as SyncServerLoginRequest, type LoginResponse as SyncServerLoginResponse, type RefreshRequest as SyncServerRefreshRequest, TAURI_COMMANDS, type TauriCommand, type UserKeypair, type VerifyResult, type ZipFileEntry, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { H as HaexVaultSdk } from './client-_FhZZse3.js';
2
- export { D as DatabaseAPI, a as Device, b as DeviceInfo, c as DeviceType, d as DirEntry, F as FileStat, e as FilesystemAPI, L as LOCALSEND_EVENTS, f as LocalSendAPI, g as LocalSendEvent, h as LocalSendFileInfo, i as LocalSendSettings, P as PendingTransfer, j as PermissionsAPI, A as RemoteAddBackendRequest, k as RemoteS3Config, l as RemoteS3PublicConfig, R as RemoteStorageAPI, m as RemoteStorageBackendInfo, n as RemoteStorageObjectInfo, U as RemoteUpdateBackendRequest, o as SelectFileOptions, p as SelectFolderOptions, q as ServerInfo, r as ServerStatus, T as TransferDirection, s as TransferProgress, t as TransferState, W as WebAPI } from './client-_FhZZse3.js';
3
- import { h as SpaceRole, E as ExtensionManifest, H as HaexHubConfig } from './types-NWYbdRXr.js';
4
- export { A as ApplicationContext, i as AuthorizedClient, B as BlockedClient, C as ContextChangedEvent, j as DEFAULT_TIMEOUT, k as DatabaseColumnInfo, l as DatabaseExecuteParams, m as DatabasePermission, d as DatabasePermissionRequest, n as DatabaseQueryParams, D as DatabaseQueryResult, o as DatabaseTableInfo, p as EXTERNAL_EVENTS, q as ErrorCode, g as EventCallback, a as ExtensionInfo, r as ExtensionRuntimeMode, s as ExternalAuthDecision, t as ExternalConnection, u as ExternalConnectionErrorCode, v as ExternalConnectionState, w as ExternalEvent, x as ExternalRequest, y as ExternalRequestEvent, e as ExternalRequestHandler, z as ExternalRequestPayload, f as ExternalResponse, F as FileChangeEvent, G as FileChangePayload, I as FileChangeType, J as FilteredSyncTablesResult, K as HAEXTENSION_EVENTS, L as HaexHubEvent, N as HaexHubRequest, O as HaexHubResponse, Q as HaexVaultSdkError, R as HaextensionEvent, T as PendingAuthorization, U as PermissionDeniedError, V as PermissionErrorBase, X as PermissionErrorCode, Y as PermissionPromptError, P as PermissionResponse, Z as PermissionStatus, _ as RequestedExtension, $ as SearchQuery, a0 as SearchRequestEvent, S as SearchResult, a1 as SessionAuthorization, a2 as SharedSpace, a3 as SpaceAccessTokenInfo, a4 as SpaceInvite, a5 as SpaceKeyGrantInfo, a6 as SpaceMemberInfo, a7 as SyncTablesUpdatedEvent, a8 as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, a9 as canExternalClientSendRequests, aa as getTableName, ab as isExternalClientConnected, ac as isPermissionDeniedError, ad as isPermissionError, ae as isPermissionPromptError } from './types-NWYbdRXr.js';
1
+ import { H as HaexVaultSdk } from './client-CRWI0t-2.js';
2
+ export { D as DatabaseAPI, a as Device, b as DeviceInfo, c as DeviceType, d as DirEntry, F as FileStat, e as FilesystemAPI, L as LOCALSEND_EVENTS, f as LocalSendAPI, g as LocalSendEvent, h as LocalSendFileInfo, i as LocalSendSettings, P as PendingTransfer, j as PermissionsAPI, A as RemoteAddBackendRequest, k as RemoteS3Config, l as RemoteS3PublicConfig, R as RemoteStorageAPI, m as RemoteStorageBackendInfo, n as RemoteStorageObjectInfo, U as RemoteUpdateBackendRequest, o as SelectFileOptions, p as SelectFolderOptions, q as ServerInfo, r as ServerStatus, T as TransferDirection, s as TransferProgress, t as TransferState, W as WebAPI } from './client-CRWI0t-2.js';
3
+ import { E as ExtensionManifest, H as HaexHubConfig } from './types-DwLhX7mx.js';
4
+ export { A as ApplicationContext, h as AuthorizedClient, B as BlockedClient, C as ContextChangedEvent, i as DEFAULT_TIMEOUT, j as DatabaseColumnInfo, k as DatabaseExecuteParams, l as DatabasePermission, d as DatabasePermissionRequest, m as DatabaseQueryParams, D as DatabaseQueryResult, n as DatabaseTableInfo, o as EXTERNAL_EVENTS, p as ErrorCode, g as EventCallback, a as ExtensionInfo, q as ExtensionRuntimeMode, r as ExternalAuthDecision, s as ExternalConnection, t as ExternalConnectionErrorCode, u as ExternalConnectionState, v as ExternalEvent, w as ExternalRequest, x as ExternalRequestEvent, e as ExternalRequestHandler, y as ExternalRequestPayload, f as ExternalResponse, F as FileChangeEvent, z as FileChangePayload, G as FileChangeType, I as FilteredSyncTablesResult, J as HAEXTENSION_EVENTS, K as HaexHubEvent, L as HaexHubRequest, N as HaexHubResponse, O as HaexVaultSdkError, Q as HaextensionEvent, R as PendingAuthorization, T as PermissionDeniedError, U as PermissionErrorBase, V as PermissionErrorCode, X as PermissionPromptError, P as PermissionResponse, Y as PermissionStatus, Z as RequestedExtension, _ as SearchQuery, $ as SearchRequestEvent, S as SearchResult, a0 as SessionAuthorization, a1 as SharedSpace, a2 as SpaceAccessTokenInfo, a3 as SpaceInvite, a4 as SpaceKeyGrantInfo, a5 as SpaceMemberInfo, a6 as SpaceRole, a7 as SyncTablesUpdatedEvent, a8 as TABLE_SEPARATOR, W as WebRequestOptions, c as WebResponse, a9 as canExternalClientSendRequests, aa as getTableName, ab as isExternalClientConnected, ac as isPermissionDeniedError, ad as isPermissionError, ae as isPermissionPromptError } from './types-DwLhX7mx.js';
5
5
  export { H as HaextensionConfig } from './config-D_HXjsEV.js';
6
6
  import 'drizzle-orm/sqlite-proxy';
7
7
 
@@ -88,7 +88,6 @@ declare function installPolyfills(): void;
88
88
  * Types for communicating with the haex-sync-server authentication endpoints.
89
89
  * Used by haex-vault and extensions that need to interact with the sync server.
90
90
  */
91
-
92
91
  /**
93
92
  * S3-compatible storage configuration provided by the sync server.
94
93
  *
@@ -192,6 +191,7 @@ interface CreateSpaceRequest {
192
191
  id: string;
193
192
  encryptedName: string;
194
193
  nameNonce: string;
194
+ label: string;
195
195
  keyGrant: {
196
196
  encryptedSpaceKey: string;
197
197
  keyNonce: string;
@@ -199,8 +199,10 @@ interface CreateSpaceRequest {
199
199
  };
200
200
  }
201
201
  interface InviteMemberRequest {
202
- userId: string;
203
- role: SpaceRole;
202
+ publicKey: string;
203
+ label: string;
204
+ role: 'member' | 'viewer';
205
+ canInvite?: boolean;
204
206
  keyGrant: {
205
207
  encryptedSpaceKey: string;
206
208
  keyNonce: string;
@@ -796,6 +798,25 @@ interface SignableRecord {
796
798
  }
797
799
  declare function signRecordAsync(record: SignableRecord, privateKeyBase64: string): Promise<string>;
798
800
  declare function verifyRecordSignatureAsync(record: SignableRecord, signatureBase64: string, publicKeyBase64: string): Promise<boolean>;
801
+ /**
802
+ * Sign a space challenge to prove private key possession.
803
+ * Generates a fresh timestamp internally to prevent misuse.
804
+ *
805
+ * @returns signature (Base64) + timestamp (ISO 8601) to send as
806
+ * X-Space-Signature / X-Space-Timestamp headers.
807
+ */
808
+ declare function signSpaceChallengeAsync(spaceId: string, privateKeyBase64: string): Promise<{
809
+ signature: string;
810
+ timestamp: string;
811
+ }>;
812
+ /**
813
+ * Verify a space challenge signature (server-side).
814
+ * Checks both cryptographic validity and timestamp freshness (max 30s).
815
+ */
816
+ declare function verifySpaceChallengeAsync(spaceId: string, timestamp: string, signatureBase64: string, publicKeyBase64: string): Promise<{
817
+ valid: boolean;
818
+ error?: string;
819
+ }>;
799
820
 
800
821
  /**
801
822
  * Crypto utilities for WebAuthn/Passkey operations
@@ -871,4 +892,4 @@ declare function exportKeyPairAsync(keyPair: PasskeyKeyPair): Promise<ExportedPa
871
892
 
872
893
  declare function createHaexVaultSdk(config?: HaexHubConfig): HaexVaultSdk;
873
894
 
874
- export { type AuthUser, COSE_ALGORITHM, type CoseAlgorithm, type CreateSpaceRequest, type EncryptedSpaceKey, type ExportedPasskeyKeyPair, type ExportedUserKeypair, ExtensionManifest, HAEXSPACE_MESSAGE_TYPES, HaexHubConfig, HaexVaultSdk, type HaexspaceMessageType, type InviteMemberRequest, KEY_AGREEMENT_ALGO, type PasskeyKeyPair, type RegisterKeypairRequest, SIGNING_ALGO, type SignableRecord, SpaceRole, type StorageConfig, type ErrorResponse as SyncServerErrorResponse, type ServerInfo as SyncServerInfo, type LoginRequest as SyncServerLoginRequest, type LoginResponse as SyncServerLoginResponse, type RefreshRequest as SyncServerRefreshRequest, TAURI_COMMANDS, type TauriCommand, type UserKeypair, type VerifyResult, type ZipFileEntry, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, signRecordAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifyWithPasskeyAsync, wrapKey };
895
+ export { type AuthUser, COSE_ALGORITHM, type CoseAlgorithm, type CreateSpaceRequest, type EncryptedSpaceKey, type ExportedPasskeyKeyPair, type ExportedUserKeypair, ExtensionManifest, HAEXSPACE_MESSAGE_TYPES, HaexHubConfig, HaexVaultSdk, type HaexspaceMessageType, type InviteMemberRequest, KEY_AGREEMENT_ALGO, type PasskeyKeyPair, type RegisterKeypairRequest, SIGNING_ALGO, type SignableRecord, type StorageConfig, type ErrorResponse as SyncServerErrorResponse, type ServerInfo as SyncServerInfo, type LoginRequest as SyncServerLoginRequest, type LoginResponse as SyncServerLoginResponse, type RefreshRequest as SyncServerRefreshRequest, TAURI_COMMANDS, type TauriCommand, type UserKeypair, type VerifyResult, type ZipFileEntry, arrayBufferToBase64, base64ToArrayBuffer, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceKeyAsync, decryptString, decryptVaultKey, decryptVaultName, deriveKeyFromPassword, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceKeyForRecipientAsync, encryptString, encryptVaultKey, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
package/dist/index.js CHANGED
@@ -2885,6 +2885,42 @@ async function verifyRecordSignatureAsync(record, signatureBase64, publicKeyBase
2885
2885
  canonicalize(record)
2886
2886
  );
2887
2887
  }
2888
+ var CHALLENGE_MAX_AGE_MS = 3e4;
2889
+ function canonicalizeChallenge(spaceId, timestamp) {
2890
+ return new TextEncoder().encode(`${spaceId}\0${timestamp}`).buffer;
2891
+ }
2892
+ async function signSpaceChallengeAsync(spaceId, privateKeyBase64) {
2893
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2894
+ const key = await importUserPrivateKeyAsync(privateKeyBase64);
2895
+ const sig = await crypto.subtle.sign(
2896
+ { name: "ECDSA", hash: "SHA-256" },
2897
+ key,
2898
+ canonicalizeChallenge(spaceId, timestamp)
2899
+ );
2900
+ return { signature: arrayBufferToBase64(sig), timestamp };
2901
+ }
2902
+ async function verifySpaceChallengeAsync(spaceId, timestamp, signatureBase64, publicKeyBase64) {
2903
+ const tsMs = new Date(timestamp).getTime();
2904
+ if (Number.isNaN(tsMs)) {
2905
+ return { valid: false, error: "Invalid timestamp format" };
2906
+ }
2907
+ const age = Date.now() - tsMs;
2908
+ if (age < 0 || age > CHALLENGE_MAX_AGE_MS) {
2909
+ return { valid: false, error: "Challenge timestamp expired or in the future" };
2910
+ }
2911
+ try {
2912
+ const key = await importUserPublicKeyAsync(publicKeyBase64);
2913
+ const isValid = await crypto.subtle.verify(
2914
+ { name: "ECDSA", hash: "SHA-256" },
2915
+ key,
2916
+ base64ToArrayBuffer(signatureBase64),
2917
+ canonicalizeChallenge(spaceId, timestamp)
2918
+ );
2919
+ return isValid ? { valid: true } : { valid: false, error: "Invalid challenge signature" };
2920
+ } catch {
2921
+ return { valid: false, error: "Challenge verification failed" };
2922
+ }
2923
+ }
2888
2924
 
2889
2925
  // src/crypto/passkey.ts
2890
2926
  function toArrayBuffer(data) {
@@ -3124,11 +3160,13 @@ exports.isPermissionDeniedError = isPermissionDeniedError;
3124
3160
  exports.isPermissionError = isPermissionError;
3125
3161
  exports.isPermissionPromptError = isPermissionPromptError;
3126
3162
  exports.signRecordAsync = signRecordAsync;
3163
+ exports.signSpaceChallengeAsync = signSpaceChallengeAsync;
3127
3164
  exports.signWithPasskeyAsync = signWithPasskeyAsync;
3128
3165
  exports.sortObjectKeysRecursively = sortObjectKeysRecursively;
3129
3166
  exports.unwrapKey = unwrapKey;
3130
3167
  exports.verifyExtensionSignature = verifyExtensionSignature;
3131
3168
  exports.verifyRecordSignatureAsync = verifyRecordSignatureAsync;
3169
+ exports.verifySpaceChallengeAsync = verifySpaceChallengeAsync;
3132
3170
  exports.verifyWithPasskeyAsync = verifyWithPasskeyAsync;
3133
3171
  exports.wrapKey = wrapKey;
3134
3172
  //# sourceMappingURL=index.js.map