@arbidocs/client 0.4.128 → 0.4.129

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.d.cts CHANGED
@@ -37664,6 +37664,12 @@ declare function base64ToBytes(base64String: string): Uint8Array;
37664
37664
  * Convert Uint8Array to base64 string
37665
37665
  */
37666
37666
  declare function bytesToBase64(bytes: Uint8Array): string;
37667
+ /**
37668
+ * Unpadded base64url (RFC 4648 §5): safe in URL fragments and query strings.
37669
+ */
37670
+ declare function bytesToBase64Url(bytes: Uint8Array): string;
37671
+ /** Inverse of {@link bytesToBase64Url}. Throws on anything that is not unpadded base64url. */
37672
+ declare function base64UrlToBytes(encoded: string): Uint8Array;
37667
37673
  /**
37668
37674
  * Base64 encode a Uint8Array (for compatibility with existing code)
37669
37675
  */
@@ -37739,6 +37745,17 @@ declare function derivePublicKey(privateKey: Uint8Array): Uint8Array;
37739
37745
  * Used when we have stored Ed25519 keys and need X25519 for encryption
37740
37746
  */
37741
37747
  declare function deriveEncryptionKeypairFromSigning(signingKeyPair: KeyPair): KeyPair;
37748
+ /**
37749
+ * The X25519 encryption keypair of a 64-byte Ed25519 signing secret key (the
37750
+ * libsodium layout: 32-byte seed ‖ 32-byte public key). The caller owns the
37751
+ * returned secret key and should zero it when done.
37752
+ */
37753
+ declare function encryptionKeypairFromSigningKey(signingPrivateKey: Uint8Array): KeyPair;
37754
+ /**
37755
+ * Open a workspace key sealed to the user (`wrapped_key` of `/v1/user/workspaces`)
37756
+ * with the user's Ed25519 signing secret key.
37757
+ */
37758
+ declare function unwrapWorkspaceKey(wrappedKey: string, signingPrivateKey: Uint8Array): Uint8Array;
37742
37759
  /**
37743
37760
  * Generate a random Ed25519 signing keypair.
37744
37761
  * Used for agent accounts that don't derive keys from a password.
@@ -38007,6 +38024,155 @@ declare function wrapIdentityKey(identitySecretKey: Uint8Array, passwordSecretKe
38007
38024
  */
38008
38025
  declare function unwrapIdentityKey(wrapped: string | null | undefined, passwordSecretKey: Uint8Array): Uint8Array;
38009
38026
 
38027
+ /**
38028
+ * Recovery keys.
38029
+ *
38030
+ * The recovery key is the account's 64-byte Ed25519 signing secret key. It reaches the user as a
38031
+ * recovery link, `<origin>/recover?email=…[&sso=1]#KEY=<base64url bytes>` — the key travels in the
38032
+ * URL fragment, which browsers never send to a server — saved to a password manager or downloaded
38033
+ * inside a one-link HTML file.
38034
+ *
38035
+ * For SSO users the key is first wrapped with their Auth0 `sub`, so the link is useless without
38036
+ * also completing the SSO login: `nonce(24) ‖ secretbox(signing key, SHA-256(sub))`, 104 bytes.
38037
+ *
38038
+ * Older recovery files hold the raw bytes (64 plain, 104 SSO-wrapped); both are still accepted.
38039
+ */
38040
+ /** Raw Ed25519 signing secret key. */
38041
+ declare const UNENCRYPTED_RECOVERY_KEY_SIZE = 64;
38042
+ /** 24 (nonce) + 64 (key) + 16 (auth tag). */
38043
+ declare const ENCRYPTED_RECOVERY_KEY_SIZE = 104;
38044
+ /** The error strings of the recovery flow. */
38045
+ declare const RECOVERY_KEY_ERRORS: {
38046
+ readonly INVALID_SIZE: "Invalid recovery key: file must be 64 or 104 bytes";
38047
+ readonly INVALID_FORMAT: "Invalid recovery key format";
38048
+ readonly READ_ERROR: "Failed to read recovery key file";
38049
+ readonly AUTH_FAILED: "Recovery key does not match this account";
38050
+ readonly ENCRYPTED_KEY_REQUIRES_SSO: "This recovery key is encrypted with your SSO identity. Please use SSO login and then click \"Forgot Password\" to use this key.";
38051
+ readonly DECRYPTION_FAILED: "Failed to decrypt recovery key. This key may belong to a different SSO account.";
38052
+ };
38053
+ /** Wrap the signing key with the user's Auth0 `sub` (104 bytes: nonce ‖ secretbox). */
38054
+ declare function encryptRecoveryKey(signingPrivateKey: Uint8Array, auth0Sub: string): Promise<Uint8Array>;
38055
+ /** Unwrap an SSO recovery key. Throws when it belongs to another account or is damaged. */
38056
+ declare function decryptRecoveryKey(encryptedKey: Uint8Array, auth0Sub: string): Promise<Uint8Array>;
38057
+ /** Whether recovery key bytes of this length are SSO-wrapped. */
38058
+ declare function isEncryptedRecoveryKey(byteLength: number): boolean;
38059
+ /** A timestamped name for the downloadable recovery file. */
38060
+ declare function getRecoveryKeyFilename(): string;
38061
+ /** A parsed recovery link. `isEncrypted`: the key is SSO-wrapped and needs the SSO login. */
38062
+ interface ParsedRecoveryUrl {
38063
+ email: string;
38064
+ recoveryKey: Uint8Array;
38065
+ isEncrypted: boolean;
38066
+ }
38067
+ /** Read a recovery link's query and fragment. Null when it carries no email or no valid key. */
38068
+ declare function parseRecoveryUrl(search: string, hash: string): ParsedRecoveryUrl | null;
38069
+ /** What a recovery link or file is made from. With `auth0Sub` the key is SSO-wrapped first. */
38070
+ interface RecoveryKeyParams {
38071
+ signingPrivateKey: Uint8Array;
38072
+ email: string;
38073
+ /** The app origin the link opens, e.g. `window.location.origin`. */
38074
+ origin: string;
38075
+ auth0Sub?: string | null;
38076
+ }
38077
+ /** The recovery link for an account (to save in a password manager, or inside the file). */
38078
+ declare function createRecoveryUrl(params: RecoveryKeyParams): Promise<string>;
38079
+ /** The downloadable recovery file: an HTML page holding the recovery link. */
38080
+ declare function createRecoveryFile(params: RecoveryKeyParams): Promise<{
38081
+ filename: string;
38082
+ html: string;
38083
+ url: string;
38084
+ }>;
38085
+ /** The result of reading an uploaded raw recovery key file. */
38086
+ interface RecoveryKeyValidationResult {
38087
+ valid: boolean;
38088
+ /** The key is SSO-wrapped. */
38089
+ isEncrypted: boolean;
38090
+ /** The raw file bytes (wrapped or not). */
38091
+ data: Uint8Array | null;
38092
+ error?: string;
38093
+ }
38094
+ /** Read an uploaded raw recovery key file: 64 bytes (plain) or 104 (SSO-wrapped). */
38095
+ declare function validateRecoveryKeyFile(file: Blob): Promise<RecoveryKeyValidationResult>;
38096
+
38097
+ /**
38098
+ * Secure mail delivery (`/v1/mail/secure`).
38099
+ *
38100
+ * The sender's browser builds the MIME message and seals it under a fresh random 32-byte message
38101
+ * key: `ciphertext` and `metadata_ciphertext` are each `base64(nonce ‖ secretbox(bytes, key))`. The
38102
+ * key reaches each recipient only in the link fragment (`fragment_key`), and the sender keeps it
38103
+ * sealed to their own X25519 public key (`sender_wrapped_key`). To claim a message the recipient
38104
+ * proves they hold the key (`claim_hash` = hex SHA-256 of it) and re-seals it to themselves.
38105
+ */
38106
+ declare const SECURE_MAIL_KEY_BYTES = 32;
38107
+ /** The encrypted parts of a secure message, as `/secure/send` takes and `/secure/{id}` returns. */
38108
+ interface SecureMailCiphertexts {
38109
+ ciphertext: string;
38110
+ metadata_ciphertext: string;
38111
+ }
38112
+ /** A sealed message plus the key material the send request needs. */
38113
+ interface SealedSecureMail extends SecureMailCiphertexts {
38114
+ /** The message key, base64 — sent to recipients in the link fragment only. */
38115
+ fragment_key: string;
38116
+ /** The message key sealed to the sender. */
38117
+ sender_wrapped_key: string;
38118
+ }
38119
+ /** What the recipient posts to `/secure/{id}/claim`. */
38120
+ interface SecureMailClaim {
38121
+ claim_hash: string;
38122
+ wrapped_key: string;
38123
+ recipient_public_key: string;
38124
+ }
38125
+ /**
38126
+ * Seal a raw MIME message and its JSON metadata under a fresh message key, and seal the key to the
38127
+ * sender. The key is zeroed before returning; only its base64 `fragment_key` remains.
38128
+ */
38129
+ declare function sealSecureMail(raw: Uint8Array, metadata: unknown, senderPublicKey: Uint8Array): Promise<SealedSecureMail>;
38130
+ /** The message key carried in a secure-mail link. Throws when it is not a 32-byte key. */
38131
+ declare function decodeSecureMailKey(fragmentKey: string): Uint8Array;
38132
+ /** Open a secure message. Throws on a wrong key or a tampered part. */
38133
+ declare function openSecureMail<T = unknown>(payload: SecureMailCiphertexts, key: Uint8Array): Promise<{
38134
+ raw: Uint8Array;
38135
+ metadata: T;
38136
+ }>;
38137
+ /** The claim body proving possession of `key` and re-sealing it to the recipient. */
38138
+ declare function secureMailClaim(key: Uint8Array, recipientPublicKey: Uint8Array): Promise<SecureMailClaim>;
38139
+
38140
+ /**
38141
+ * Encryption at rest for offline stores (IndexedDB copies of mail, calendar, …).
38142
+ *
38143
+ * Keys are derived in memory from the user's own X25519 identity key (by default the one the session
38144
+ * store keeps, wrapped by a non-extractable WebCrypto key). Nothing derived here is ever written to disk.
38145
+ *
38146
+ * - `enc`: XSalsa20-Poly1305 (libsodium secretbox) key for record contents; each record gets a fresh
38147
+ * random nonce, stored in front of the ciphertext.
38148
+ * - `index`: keyed BLAKE2b key for blind index values, so ids never appear in plaintext.
38149
+ *
38150
+ * Both are BLAKE2b derivations of the identity secret key, domain-separated by a per-store namespace
38151
+ * (`<namespace>:enc`, `<namespace>:index`), so stores can't read each other's records.
38152
+ */
38153
+
38154
+ interface OfflineSealer {
38155
+ sealBytes(plain: Uint8Array): Promise<Uint8Array>;
38156
+ openBytes(sealed: Uint8Array): Promise<Uint8Array>;
38157
+ sealJson(value: unknown): Promise<Uint8Array>;
38158
+ openJson<T>(sealed: Uint8Array): Promise<T>;
38159
+ /** A keyed hash of `parts`, used as an IndexedDB key so ids never appear in plaintext. */
38160
+ blind(...parts: string[]): Promise<string>;
38161
+ /** Forget the derived keys (sign-out, or the offline data was removed). */
38162
+ forget(): void;
38163
+ }
38164
+ interface OfflineSealerOptions {
38165
+ /** Builds the error thrown when no identity key is unlocked. */
38166
+ locked: () => Error;
38167
+ /**
38168
+ * The identity keypair to derive from; the sealer zeroes its secret key after use. Defaults to
38169
+ * the signed-in session's ({@link getUserEncryptionKeypair}).
38170
+ */
38171
+ keypair?: () => Promise<KeyPair | null>;
38172
+ }
38173
+ /** A sealer for one offline store, namespaced so stores can't read each other's records. */
38174
+ declare function createOfflineSealer(namespace: string, { locked, keypair: getKeypair }: OfflineSealerOptions): OfflineSealer;
38175
+
38010
38176
  /**
38011
38177
  * storage.ts - IndexedDB Storage Module
38012
38178
  *
@@ -38450,4 +38616,4 @@ interface ReopenDeps {
38450
38616
  */
38451
38617
  declare function createWorkspaceReopener(deps: ReopenDeps): () => Promise<boolean>;
38452
38618
 
38453
- export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type KeyLoginCredentials, type KeyPair, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OnReloginSuccess, type PasswordChangeCredentials, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type ReopenDeps, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, buildCallFragment, buildWebSocketUrl, bytesToBase64, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createReloginHandler, createSessionManager, createWorkspaceReopener, decodeCallKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptWithChatKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isMessageType, openSealedCallKey, openSealedChatKey, type operations, parseCallFragment, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, saveSession, sealCallKey, sealChatKey, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, updateWrappedIdentityKey, type webhooks, wrapIdentityKey };
38619
+ export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, ENCRYPTED_RECOVERY_KEY_SIZE, type KeyLoginCredentials, type KeyPair, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OfflineSealer, type OfflineSealerOptions, type OnReloginSuccess, type ParsedRecoveryUrl, type PasswordChangeCredentials, RECOVERY_KEY_ERRORS, type RecoveryKeyParams, type RecoveryKeyValidationResult, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type ReopenDeps, SECURE_MAIL_KEY_BYTES, type SealedSecureMail, type SecureMailCiphertexts, type SecureMailClaim, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, UNENCRYPTED_RECOVERY_KEY_SIZE, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, buildCallFragment, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isEncryptedRecoveryKey, isMessageType, openSealedCallKey, openSealedChatKey, openSecureMail, type operations, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, saveSession, sealCallKey, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, type webhooks, wrapIdentityKey };
package/dist/index.d.ts CHANGED
@@ -37664,6 +37664,12 @@ declare function base64ToBytes(base64String: string): Uint8Array;
37664
37664
  * Convert Uint8Array to base64 string
37665
37665
  */
37666
37666
  declare function bytesToBase64(bytes: Uint8Array): string;
37667
+ /**
37668
+ * Unpadded base64url (RFC 4648 §5): safe in URL fragments and query strings.
37669
+ */
37670
+ declare function bytesToBase64Url(bytes: Uint8Array): string;
37671
+ /** Inverse of {@link bytesToBase64Url}. Throws on anything that is not unpadded base64url. */
37672
+ declare function base64UrlToBytes(encoded: string): Uint8Array;
37667
37673
  /**
37668
37674
  * Base64 encode a Uint8Array (for compatibility with existing code)
37669
37675
  */
@@ -37739,6 +37745,17 @@ declare function derivePublicKey(privateKey: Uint8Array): Uint8Array;
37739
37745
  * Used when we have stored Ed25519 keys and need X25519 for encryption
37740
37746
  */
37741
37747
  declare function deriveEncryptionKeypairFromSigning(signingKeyPair: KeyPair): KeyPair;
37748
+ /**
37749
+ * The X25519 encryption keypair of a 64-byte Ed25519 signing secret key (the
37750
+ * libsodium layout: 32-byte seed ‖ 32-byte public key). The caller owns the
37751
+ * returned secret key and should zero it when done.
37752
+ */
37753
+ declare function encryptionKeypairFromSigningKey(signingPrivateKey: Uint8Array): KeyPair;
37754
+ /**
37755
+ * Open a workspace key sealed to the user (`wrapped_key` of `/v1/user/workspaces`)
37756
+ * with the user's Ed25519 signing secret key.
37757
+ */
37758
+ declare function unwrapWorkspaceKey(wrappedKey: string, signingPrivateKey: Uint8Array): Uint8Array;
37742
37759
  /**
37743
37760
  * Generate a random Ed25519 signing keypair.
37744
37761
  * Used for agent accounts that don't derive keys from a password.
@@ -38007,6 +38024,155 @@ declare function wrapIdentityKey(identitySecretKey: Uint8Array, passwordSecretKe
38007
38024
  */
38008
38025
  declare function unwrapIdentityKey(wrapped: string | null | undefined, passwordSecretKey: Uint8Array): Uint8Array;
38009
38026
 
38027
+ /**
38028
+ * Recovery keys.
38029
+ *
38030
+ * The recovery key is the account's 64-byte Ed25519 signing secret key. It reaches the user as a
38031
+ * recovery link, `<origin>/recover?email=…[&sso=1]#KEY=<base64url bytes>` — the key travels in the
38032
+ * URL fragment, which browsers never send to a server — saved to a password manager or downloaded
38033
+ * inside a one-link HTML file.
38034
+ *
38035
+ * For SSO users the key is first wrapped with their Auth0 `sub`, so the link is useless without
38036
+ * also completing the SSO login: `nonce(24) ‖ secretbox(signing key, SHA-256(sub))`, 104 bytes.
38037
+ *
38038
+ * Older recovery files hold the raw bytes (64 plain, 104 SSO-wrapped); both are still accepted.
38039
+ */
38040
+ /** Raw Ed25519 signing secret key. */
38041
+ declare const UNENCRYPTED_RECOVERY_KEY_SIZE = 64;
38042
+ /** 24 (nonce) + 64 (key) + 16 (auth tag). */
38043
+ declare const ENCRYPTED_RECOVERY_KEY_SIZE = 104;
38044
+ /** The error strings of the recovery flow. */
38045
+ declare const RECOVERY_KEY_ERRORS: {
38046
+ readonly INVALID_SIZE: "Invalid recovery key: file must be 64 or 104 bytes";
38047
+ readonly INVALID_FORMAT: "Invalid recovery key format";
38048
+ readonly READ_ERROR: "Failed to read recovery key file";
38049
+ readonly AUTH_FAILED: "Recovery key does not match this account";
38050
+ readonly ENCRYPTED_KEY_REQUIRES_SSO: "This recovery key is encrypted with your SSO identity. Please use SSO login and then click \"Forgot Password\" to use this key.";
38051
+ readonly DECRYPTION_FAILED: "Failed to decrypt recovery key. This key may belong to a different SSO account.";
38052
+ };
38053
+ /** Wrap the signing key with the user's Auth0 `sub` (104 bytes: nonce ‖ secretbox). */
38054
+ declare function encryptRecoveryKey(signingPrivateKey: Uint8Array, auth0Sub: string): Promise<Uint8Array>;
38055
+ /** Unwrap an SSO recovery key. Throws when it belongs to another account or is damaged. */
38056
+ declare function decryptRecoveryKey(encryptedKey: Uint8Array, auth0Sub: string): Promise<Uint8Array>;
38057
+ /** Whether recovery key bytes of this length are SSO-wrapped. */
38058
+ declare function isEncryptedRecoveryKey(byteLength: number): boolean;
38059
+ /** A timestamped name for the downloadable recovery file. */
38060
+ declare function getRecoveryKeyFilename(): string;
38061
+ /** A parsed recovery link. `isEncrypted`: the key is SSO-wrapped and needs the SSO login. */
38062
+ interface ParsedRecoveryUrl {
38063
+ email: string;
38064
+ recoveryKey: Uint8Array;
38065
+ isEncrypted: boolean;
38066
+ }
38067
+ /** Read a recovery link's query and fragment. Null when it carries no email or no valid key. */
38068
+ declare function parseRecoveryUrl(search: string, hash: string): ParsedRecoveryUrl | null;
38069
+ /** What a recovery link or file is made from. With `auth0Sub` the key is SSO-wrapped first. */
38070
+ interface RecoveryKeyParams {
38071
+ signingPrivateKey: Uint8Array;
38072
+ email: string;
38073
+ /** The app origin the link opens, e.g. `window.location.origin`. */
38074
+ origin: string;
38075
+ auth0Sub?: string | null;
38076
+ }
38077
+ /** The recovery link for an account (to save in a password manager, or inside the file). */
38078
+ declare function createRecoveryUrl(params: RecoveryKeyParams): Promise<string>;
38079
+ /** The downloadable recovery file: an HTML page holding the recovery link. */
38080
+ declare function createRecoveryFile(params: RecoveryKeyParams): Promise<{
38081
+ filename: string;
38082
+ html: string;
38083
+ url: string;
38084
+ }>;
38085
+ /** The result of reading an uploaded raw recovery key file. */
38086
+ interface RecoveryKeyValidationResult {
38087
+ valid: boolean;
38088
+ /** The key is SSO-wrapped. */
38089
+ isEncrypted: boolean;
38090
+ /** The raw file bytes (wrapped or not). */
38091
+ data: Uint8Array | null;
38092
+ error?: string;
38093
+ }
38094
+ /** Read an uploaded raw recovery key file: 64 bytes (plain) or 104 (SSO-wrapped). */
38095
+ declare function validateRecoveryKeyFile(file: Blob): Promise<RecoveryKeyValidationResult>;
38096
+
38097
+ /**
38098
+ * Secure mail delivery (`/v1/mail/secure`).
38099
+ *
38100
+ * The sender's browser builds the MIME message and seals it under a fresh random 32-byte message
38101
+ * key: `ciphertext` and `metadata_ciphertext` are each `base64(nonce ‖ secretbox(bytes, key))`. The
38102
+ * key reaches each recipient only in the link fragment (`fragment_key`), and the sender keeps it
38103
+ * sealed to their own X25519 public key (`sender_wrapped_key`). To claim a message the recipient
38104
+ * proves they hold the key (`claim_hash` = hex SHA-256 of it) and re-seals it to themselves.
38105
+ */
38106
+ declare const SECURE_MAIL_KEY_BYTES = 32;
38107
+ /** The encrypted parts of a secure message, as `/secure/send` takes and `/secure/{id}` returns. */
38108
+ interface SecureMailCiphertexts {
38109
+ ciphertext: string;
38110
+ metadata_ciphertext: string;
38111
+ }
38112
+ /** A sealed message plus the key material the send request needs. */
38113
+ interface SealedSecureMail extends SecureMailCiphertexts {
38114
+ /** The message key, base64 — sent to recipients in the link fragment only. */
38115
+ fragment_key: string;
38116
+ /** The message key sealed to the sender. */
38117
+ sender_wrapped_key: string;
38118
+ }
38119
+ /** What the recipient posts to `/secure/{id}/claim`. */
38120
+ interface SecureMailClaim {
38121
+ claim_hash: string;
38122
+ wrapped_key: string;
38123
+ recipient_public_key: string;
38124
+ }
38125
+ /**
38126
+ * Seal a raw MIME message and its JSON metadata under a fresh message key, and seal the key to the
38127
+ * sender. The key is zeroed before returning; only its base64 `fragment_key` remains.
38128
+ */
38129
+ declare function sealSecureMail(raw: Uint8Array, metadata: unknown, senderPublicKey: Uint8Array): Promise<SealedSecureMail>;
38130
+ /** The message key carried in a secure-mail link. Throws when it is not a 32-byte key. */
38131
+ declare function decodeSecureMailKey(fragmentKey: string): Uint8Array;
38132
+ /** Open a secure message. Throws on a wrong key or a tampered part. */
38133
+ declare function openSecureMail<T = unknown>(payload: SecureMailCiphertexts, key: Uint8Array): Promise<{
38134
+ raw: Uint8Array;
38135
+ metadata: T;
38136
+ }>;
38137
+ /** The claim body proving possession of `key` and re-sealing it to the recipient. */
38138
+ declare function secureMailClaim(key: Uint8Array, recipientPublicKey: Uint8Array): Promise<SecureMailClaim>;
38139
+
38140
+ /**
38141
+ * Encryption at rest for offline stores (IndexedDB copies of mail, calendar, …).
38142
+ *
38143
+ * Keys are derived in memory from the user's own X25519 identity key (by default the one the session
38144
+ * store keeps, wrapped by a non-extractable WebCrypto key). Nothing derived here is ever written to disk.
38145
+ *
38146
+ * - `enc`: XSalsa20-Poly1305 (libsodium secretbox) key for record contents; each record gets a fresh
38147
+ * random nonce, stored in front of the ciphertext.
38148
+ * - `index`: keyed BLAKE2b key for blind index values, so ids never appear in plaintext.
38149
+ *
38150
+ * Both are BLAKE2b derivations of the identity secret key, domain-separated by a per-store namespace
38151
+ * (`<namespace>:enc`, `<namespace>:index`), so stores can't read each other's records.
38152
+ */
38153
+
38154
+ interface OfflineSealer {
38155
+ sealBytes(plain: Uint8Array): Promise<Uint8Array>;
38156
+ openBytes(sealed: Uint8Array): Promise<Uint8Array>;
38157
+ sealJson(value: unknown): Promise<Uint8Array>;
38158
+ openJson<T>(sealed: Uint8Array): Promise<T>;
38159
+ /** A keyed hash of `parts`, used as an IndexedDB key so ids never appear in plaintext. */
38160
+ blind(...parts: string[]): Promise<string>;
38161
+ /** Forget the derived keys (sign-out, or the offline data was removed). */
38162
+ forget(): void;
38163
+ }
38164
+ interface OfflineSealerOptions {
38165
+ /** Builds the error thrown when no identity key is unlocked. */
38166
+ locked: () => Error;
38167
+ /**
38168
+ * The identity keypair to derive from; the sealer zeroes its secret key after use. Defaults to
38169
+ * the signed-in session's ({@link getUserEncryptionKeypair}).
38170
+ */
38171
+ keypair?: () => Promise<KeyPair | null>;
38172
+ }
38173
+ /** A sealer for one offline store, namespaced so stores can't read each other's records. */
38174
+ declare function createOfflineSealer(namespace: string, { locked, keypair: getKeypair }: OfflineSealerOptions): OfflineSealer;
38175
+
38010
38176
  /**
38011
38177
  * storage.ts - IndexedDB Storage Module
38012
38178
  *
@@ -38450,4 +38616,4 @@ interface ReopenDeps {
38450
38616
  */
38451
38617
  declare function createWorkspaceReopener(deps: ReopenDeps): () => Promise<boolean>;
38452
38618
 
38453
- export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, type KeyLoginCredentials, type KeyPair, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OnReloginSuccess, type PasswordChangeCredentials, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type ReopenDeps, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, buildCallFragment, buildWebSocketUrl, bytesToBase64, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createReloginHandler, createSessionManager, createWorkspaceReopener, decodeCallKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptWithChatKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isMessageType, openSealedCallKey, openSealedChatKey, type operations, parseCallFragment, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, saveSession, sealCallKey, sealChatKey, sealKeyForSession, sealedBoxDecrypt, sealedBoxEncrypt, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, updateWrappedIdentityKey, type webhooks, wrapIdentityKey };
38619
+ export { type $defs, API_PREFIX, type ArbiClient, type ArbiClientOptions, type AuthStateProvider, type AutoReloginMiddlewareConfig, type BearerAuthMiddlewareConfig, CALL_KEY_BYTES, CHAT_KEY_BYTES, type ChangePasswordParams, type ChangePasswordRequest, type ChangePasswordResult, type CryptoProvider, ENCRYPTED_RECOVERY_KEY_SIZE, type KeyLoginCredentials, type KeyPair, type LoginCredentials, type LoginParams, type LoginProfile, type LoginProvider, type LoginRequest, type LoginResult, type LoginWithKeyParams, type OfflineSealer, type OfflineSealerOptions, type OnReloginSuccess, type ParsedRecoveryUrl, type PasswordChangeCredentials, RECOVERY_KEY_ERRORS, type RecoveryKeyParams, type RecoveryKeyValidationResult, type RegisterParams, type RegisterRequest, type RegisterResult, type RegistrationCredentials, type ReloginDeps, type ReloginHandler, type ReopenDeps, SECURE_MAIL_KEY_BYTES, type SealedSecureMail, type SecureMailCiphertexts, type SecureMailClaim, type SessionData, type SessionKeys, type SessionManager, type SessionState, type SessionStorageProvider, type SsoTokenProvider, type TokenProvider, UNENCRYPTED_RECOVERY_KEY_SIZE, type UserKeypairs, type WebSocketClientMessage, type WebSocketServerMessage, type WorkspaceKeyRefreshProvider, type WorkspaceOpenProvider, type WsAgentDmStatusMessage, type WsAuthMessage, type WsAuthResultMessage, type WsBatchCompleteMessage, type WsChatMessageMessage, type WsChatReadMessage, type WsChatUpdatedMessage, type WsConnectionClosedMessage, type WsConversationMessagePostedMessage, type WsErrorMessage, type WsNotificationResponse, type WsPresenceUpdateMessage, type WsResponseCompleteMessage, type WsTaskUpdateMessage, base64Decode, base64Encode, base64ToBytes, base64UrlToBytes, buildCallFragment, buildWebSocketUrl, bytesToBase64, bytesToBase64Url, canPersistSession, changePassword, clearAllData, clearSession, type components, computeSharedSecret, createArbiClient, createAuthMessage, createAutoReloginMiddleware, createBearerAuthMiddleware, createContentHash, createOfflineSealer, createRecoveryFile, createRecoveryUrl, createReloginHandler, createSessionManager, createWorkspaceReopener, decodeCallKey, decodeSecureMailKey, decryptCallTitle, decryptFile, decryptMessage, decryptMessageWithSharedSecret, decryptRecoveryKey, decryptWithChatKey, deriveDirectChatKey, deriveEncryptionKeypairFromSigning, derivePublicKey, encodeCallKey, encryptCallTitle, encryptFile, encryptMessage, encryptMessageWithSharedSecret, encryptRecoveryKey, encryptWithChatKey, encryptionKeypairFromSigningKey, generateCallKey, generateChatKey, generateIdentityKeypair, generateKeyPairs, generateLoginCredentials, generateLoginCredentialsFromKey, generatePasswordChangeCredentials, generateRandomSigningKeypair, generateRegistrationCredentials, generateUserKeypairs, getRecoveryKeyFilename, getSession, getUserEncryptionKeypair, hasSession, identityFromLoginResponse, initSodium, initializeDatabase, isEncryptedRecoveryKey, isMessageType, openSealedCallKey, openSealedChatKey, openSecureMail, type operations, parseCallFragment, parseRecoveryUrl, parseServerMessage, passwordChangeErrorMessage, type paths, prewarmKeyPairs, saveSession, sealCallKey, sealChatKey, sealKeyForSession, sealSecureMail, sealedBoxDecrypt, sealedBoxEncrypt, secureMailClaim, signMessage, unlockIdentityWithPassword, unwrapIdentityKey, unwrapWorkspaceKey, updateWrappedIdentityKey, validateRecoveryKeyFile, type webhooks, wrapIdentityKey };