@haex-space/vault-sdk 3.2.8 → 3.4.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
@@ -715,6 +715,10 @@ var HAEXTENSION_EVENTS = {
715
715
  * subscribe via `client.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, ...)`. */
716
716
  PERMISSION_RESOLVED: "extension:permission-resolved"
717
717
  };
718
+ var NOTIFICATION_EVENTS = {
719
+ /** A click on one of this extension's notifications (body or action button). */
720
+ CLICK: "haextension:notification:click"
721
+ };
718
722
  var EXTERNAL_EVENTS = {
719
723
  /** External request from authorized client */
720
724
  REQUEST: "haextension:external:request",
@@ -1073,6 +1077,8 @@ var MAIL_COMMANDS = {
1073
1077
  fetchEnvelopes: "extension_mail_fetch_envelopes",
1074
1078
  /** Full message fetch (envelope + body + attachment metadata) */
1075
1079
  fetchMessage: "extension_mail_fetch_message",
1080
+ /** Fetch a single attachment's bytes (base64) by part index */
1081
+ fetchAttachment: "extension_mail_fetch_attachment",
1076
1082
  /** Set or unset IMAP flags on a UID set */
1077
1083
  setFlags: "extension_mail_set_flags",
1078
1084
  /** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
@@ -1085,6 +1091,14 @@ var MAIL_COMMANDS = {
1085
1091
  buildRfc822: "extension_mail_build_rfc822"
1086
1092
  };
1087
1093
 
1094
+ // src/commands/notifications.ts
1095
+ var NOTIFICATION_COMMANDS = {
1096
+ /** Show an OS notification. Returns the assigned notification id. */
1097
+ show: "extension_notifications_show",
1098
+ /** Dismiss a previously shown notification (only own notifications). */
1099
+ dismiss: "extension_notifications_dismiss"
1100
+ };
1101
+
1088
1102
  // src/commands/index.ts
1089
1103
  var TAURI_COMMANDS = {
1090
1104
  database: DATABASE_COMMANDS,
@@ -1099,7 +1113,8 @@ var TAURI_COMMANDS = {
1099
1113
  spaces: SPACE_COMMANDS,
1100
1114
  shell: SHELL_COMMANDS,
1101
1115
  passwords: PASSWORD_COMMANDS,
1102
- mail: MAIL_COMMANDS
1116
+ mail: MAIL_COMMANDS,
1117
+ notifications: NOTIFICATION_COMMANDS
1103
1118
  };
1104
1119
 
1105
1120
  // src/api/storage.ts
@@ -2130,6 +2145,21 @@ var MailAPI = class {
2130
2145
  uid
2131
2146
  });
2132
2147
  }
2148
+ /**
2149
+ * Fetch a single attachment's raw bytes by its `partIndex` (from the
2150
+ * `attachments` array of a fetched `MailMessage`), returned as a
2151
+ * standard-alphabet base64 string. The base64 form drops straight into
2152
+ * `OutgoingAttachment.data` when forwarding, and decodes to bytes for
2153
+ * viewing or downloading.
2154
+ */
2155
+ async fetchAttachmentAsync(imap, mailbox, uid, partIndex) {
2156
+ return this.client.request(MAIL_COMMANDS.fetchAttachment, {
2157
+ imap,
2158
+ mailbox,
2159
+ uid,
2160
+ partIndex
2161
+ });
2162
+ }
2133
2163
  /**
2134
2164
  * Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
2135
2165
  * mark messages as read; `add=false` removes the flag(s).
@@ -2185,6 +2215,38 @@ var MailAPI = class {
2185
2215
  }
2186
2216
  };
2187
2217
 
2218
+ // src/api/notifications.ts
2219
+ var NotificationsAPI = class {
2220
+ constructor(client) {
2221
+ this.client = client;
2222
+ }
2223
+ /** Show a notification. Returns its id so it can be dismissed later. */
2224
+ async show(opts) {
2225
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
2226
+ options: opts
2227
+ });
2228
+ }
2229
+ /** Dismiss a previously shown notification (only own notifications). */
2230
+ async dismiss(id) {
2231
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
2232
+ }
2233
+ /**
2234
+ * Listen for clicks on this extension's notifications. Useful when the
2235
+ * extension is already open and wants to react in-app (e.g. router.push the
2236
+ * `path`) instead of relying on the host to focus the webview.
2237
+ *
2238
+ * Returns an unsubscribe function.
2239
+ */
2240
+ onClick(handler) {
2241
+ const wrapped = (event) => {
2242
+ const data = event.data;
2243
+ if (data) handler(data);
2244
+ };
2245
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
2246
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
2247
+ }
2248
+ };
2249
+
2188
2250
  // src/client/tableName.ts
2189
2251
  function validatePublicKey(publicKey) {
2190
2252
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -2352,6 +2414,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2352
2414
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
2353
2415
  EXTERNAL_EVENTS.REQUEST,
2354
2416
  EXTERNAL_EVENTS.ACTION_REQUEST,
2417
+ NOTIFICATION_EVENTS.CLICK,
2355
2418
  ...Object.values(LOCALSEND_EVENTS)
2356
2419
  ]) {
2357
2420
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2827,6 +2890,7 @@ var HaexVaultSdk = class {
2827
2890
  this.shell = new ShellAPI(this);
2828
2891
  this.passwords = new PasswordsAPI(this);
2829
2892
  this.mail = new MailAPI(this);
2893
+ this.notifications = new NotificationsAPI(this);
2830
2894
  installConsoleForwarding(this.config.debug);
2831
2895
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2832
2896
  const data = event.data;
@@ -3765,6 +3829,6 @@ function createHaexVaultSdk(config = {}) {
3765
3829
  return new HaexVaultSdk(config);
3766
3830
  }
3767
3831
 
3768
- 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, 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 };
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 };
3769
3833
  //# sourceMappingURL=index.mjs.map
3770
3834
  //# sourceMappingURL=index.mjs.map