@haex-space/vault-sdk 3.2.8 → 3.3.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",
@@ -1085,6 +1089,14 @@ var MAIL_COMMANDS = {
1085
1089
  buildRfc822: "extension_mail_build_rfc822"
1086
1090
  };
1087
1091
 
1092
+ // src/commands/notifications.ts
1093
+ var NOTIFICATION_COMMANDS = {
1094
+ /** Show an OS notification. Returns the assigned notification id. */
1095
+ show: "extension_notifications_show",
1096
+ /** Dismiss a previously shown notification (only own notifications). */
1097
+ dismiss: "extension_notifications_dismiss"
1098
+ };
1099
+
1088
1100
  // src/commands/index.ts
1089
1101
  var TAURI_COMMANDS = {
1090
1102
  database: DATABASE_COMMANDS,
@@ -1099,7 +1111,8 @@ var TAURI_COMMANDS = {
1099
1111
  spaces: SPACE_COMMANDS,
1100
1112
  shell: SHELL_COMMANDS,
1101
1113
  passwords: PASSWORD_COMMANDS,
1102
- mail: MAIL_COMMANDS
1114
+ mail: MAIL_COMMANDS,
1115
+ notifications: NOTIFICATION_COMMANDS
1103
1116
  };
1104
1117
 
1105
1118
  // src/api/storage.ts
@@ -2185,6 +2198,38 @@ var MailAPI = class {
2185
2198
  }
2186
2199
  };
2187
2200
 
2201
+ // src/api/notifications.ts
2202
+ var NotificationsAPI = class {
2203
+ constructor(client) {
2204
+ this.client = client;
2205
+ }
2206
+ /** Show a notification. Returns its id so it can be dismissed later. */
2207
+ async show(opts) {
2208
+ return this.client.request(NOTIFICATION_COMMANDS.show, {
2209
+ options: opts
2210
+ });
2211
+ }
2212
+ /** Dismiss a previously shown notification (only own notifications). */
2213
+ async dismiss(id) {
2214
+ return this.client.request(NOTIFICATION_COMMANDS.dismiss, { id });
2215
+ }
2216
+ /**
2217
+ * Listen for clicks on this extension's notifications. Useful when the
2218
+ * extension is already open and wants to react in-app (e.g. router.push the
2219
+ * `path`) instead of relying on the host to focus the webview.
2220
+ *
2221
+ * Returns an unsubscribe function.
2222
+ */
2223
+ onClick(handler) {
2224
+ const wrapped = (event) => {
2225
+ const data = event.data;
2226
+ if (data) handler(data);
2227
+ };
2228
+ this.client.on(NOTIFICATION_EVENTS.CLICK, wrapped);
2229
+ return () => this.client.off(NOTIFICATION_EVENTS.CLICK, wrapped);
2230
+ }
2231
+ };
2232
+
2188
2233
  // src/client/tableName.ts
2189
2234
  function validatePublicKey(publicKey) {
2190
2235
  if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
@@ -2352,6 +2397,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
2352
2397
  HAEXTENSION_EVENTS.PERMISSION_RESOLVED,
2353
2398
  EXTERNAL_EVENTS.REQUEST,
2354
2399
  EXTERNAL_EVENTS.ACTION_REQUEST,
2400
+ NOTIFICATION_EVENTS.CLICK,
2355
2401
  ...Object.values(LOCALSEND_EVENTS)
2356
2402
  ]) {
2357
2403
  await forwardEvent(listen, log, onEvent, listenOptions, eventName);
@@ -2827,6 +2873,7 @@ var HaexVaultSdk = class {
2827
2873
  this.shell = new ShellAPI(this);
2828
2874
  this.passwords = new PasswordsAPI(this);
2829
2875
  this.mail = new MailAPI(this);
2876
+ this.notifications = new NotificationsAPI(this);
2830
2877
  installConsoleForwarding(this.config.debug);
2831
2878
  this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
2832
2879
  const data = event.data;
@@ -3765,6 +3812,6 @@ function createHaexVaultSdk(config = {}) {
3765
3812
  return new HaexVaultSdk(config);
3766
3813
  }
3767
3814
 
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 };
3815
+ 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
3816
  //# sourceMappingURL=index.mjs.map
3770
3817
  //# sourceMappingURL=index.mjs.map