@haex-space/vault-sdk 3.5.0 → 3.6.0

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
@@ -733,6 +733,10 @@ var SHELL_EVENTS = {
733
733
  /** Shell session has exited */
734
734
  EXIT: "shell:exit"
735
735
  };
736
+ var MAIL_EVENTS = {
737
+ /** A watched mailbox's UID high-water mark advanced — new mail arrived. */
738
+ NEW_MESSAGES: "mail:new-messages"
739
+ };
736
740
 
737
741
  // src/types.ts
738
742
  var DEFAULT_TIMEOUT = 3e4;
@@ -1088,7 +1092,11 @@ var MAIL_COMMANDS = {
1088
1092
  /** SMTP send. Returns the assigned Message-ID. */
1089
1093
  sendMessage: "extension_mail_send_message",
1090
1094
  /** Build RFC822 bytes without sending (for Drafts via APPEND) */
1091
- buildRfc822: "extension_mail_build_rfc822"
1095
+ buildRfc822: "extension_mail_build_rfc822",
1096
+ /** Start (or replace) a background poll watch for an account/mailbox */
1097
+ startWatch: "extension_mail_start_watch",
1098
+ /** Stop a background poll watch */
1099
+ stopWatch: "extension_mail_stop_watch"
1092
1100
  };
1093
1101
 
1094
1102
  // src/commands/notifications.ts
@@ -2213,6 +2221,41 @@ var MailAPI = class {
2213
2221
  message
2214
2222
  });
2215
2223
  }
2224
+ /**
2225
+ * Start (or replace) a background poll watch for `accountId`/`mailboxName`.
2226
+ * The host resolves credentials itself from `accountId` — no `ImapConfig`
2227
+ * is passed in. Requires `mail` permission with action `poll` on the
2228
+ * account's IMAP host (prompted on first call, same as `fetch`/`send`).
2229
+ *
2230
+ * `intervalSeconds` is clamped host-side to [30, 3600]. Listen for
2231
+ * results via `onNewMessages`.
2232
+ */
2233
+ async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
2234
+ return this.client.request(MAIL_COMMANDS.startWatch, {
2235
+ accountId,
2236
+ mailboxName,
2237
+ intervalSeconds
2238
+ });
2239
+ }
2240
+ /** Stop a background poll watch previously started with `startWatchingAsync`. */
2241
+ async stopWatchingAsync(accountId, mailboxName) {
2242
+ return this.client.request(MAIL_COMMANDS.stopWatch, {
2243
+ accountId,
2244
+ mailboxName
2245
+ });
2246
+ }
2247
+ /**
2248
+ * Register a callback for new-mail notifications from any active watch.
2249
+ * `event.data` is a `MailNewMessagesEvent` — check `accountId`/`mailboxName`
2250
+ * before refreshing if watching more than one account.
2251
+ */
2252
+ onNewMessages(callback) {
2253
+ this.client.on(MAIL_EVENTS.NEW_MESSAGES, callback);
2254
+ }
2255
+ /** Remove a new-mail callback registered with `onNewMessages`. */
2256
+ offNewMessages(callback) {
2257
+ this.client.off(MAIL_EVENTS.NEW_MESSAGES, callback);
2258
+ }
2216
2259
  };
2217
2260
 
2218
2261
  // src/api/notifications.ts
@@ -2415,6 +2458,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2415
2458
  EXTERNAL_EVENTS.REQUEST,
2416
2459
  EXTERNAL_EVENTS.ACTION_REQUEST,
2417
2460
  NOTIFICATION_EVENTS.CLICK,
2461
+ MAIL_EVENTS.NEW_MESSAGES,
2418
2462
  ...Object.values(LOCALSEND_EVENTS)
2419
2463
  ]) {
2420
2464
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -3829,6 +3873,6 @@ function createHaexVaultSdk(config = {}) {
3829
3873
  return new HaexVaultSdk(config);
3830
3874
  }
3831
3875
 
3832
- export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyClaimPresentationAsync, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3876
+ export { COSE_ALGORITHM, DEFAULT_TIMEOUT, DatabaseAPI, EXTERNAL_EVENTS, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MailAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PasswordsAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, WebAPI, arrayBufferToBase64, base58btcDecode, base58btcEncode, base64ToArrayBuffer, canExternalClientSendRequests, createHaexVaultSdk, decryptCrdtData, decryptPrivateKeyAsync, decryptSpaceNameAsync, decryptString, decryptVaultKey, decryptVaultName, decryptWithPrivateKeyAsync, deriveKeyFromPassword, didKeyToPublicKeyAsync, encryptCrdtData, encryptPrivateKeyAsync, encryptSpaceNameAsync, encryptString, encryptVaultKey, encryptWithPublicKeyAsync, exportKeyPairAsync, exportPrivateKeyAsync, exportPublicKeyAsync, exportPublicKeyCoseAsync, exportUserKeypairAsync, generateCredentialId, generateIdentityAsync, generatePasskeyPairAsync, generateSpaceKey, generateUserKeypairAsync, generateVaultKey, getTableName, hexToBytes, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, sortObjectKeysRecursively, unwrapKey, verifyClaimPresentationAsync, verifyExtensionSignature, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
3833
3877
  //# sourceMappingURL=index.mjs.map
3834
3878
  //# sourceMappingURL=index.mjs.map