@haex-space/vault-sdk 5.0.0 → 5.1.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
@@ -761,6 +761,10 @@ var NOTIFICATION_EVENTS = {
761
761
  /** A click on one of this extension's notifications (body or action button). */
762
762
  CLICK: "haextension:notification:click"
763
763
  };
764
+ var OPENER_EVENTS = {
765
+ /** A request waits for this extension: take it with `client.openers.take()`. The event carries no content. */
766
+ REQUEST: "opener-request"
767
+ };
764
768
  var MODEL_JOB_EVENTS = {
765
769
  /** A job of this frame ended: completed, failed or cancelled. */
766
770
  COMPLETED: "haextension:model-job:completed"
@@ -1053,7 +1057,9 @@ var EXTENSION_COMMANDS = {
1053
1057
  /** Ask the host to mark (or unmark) this extension's own tab as wanting attention */
1054
1058
  tabAttention: "extension_tab_attention",
1055
1059
  /** Ask the user to confirm, in a dialog the host draws over this extension's tab */
1056
- dialogConfirm: "extension_dialog_confirm"
1060
+ dialogConfirm: "extension_dialog_confirm",
1061
+ /** Take the request the user gave this extension (holzi spec 063): `null` or `{ action, mail }` */
1062
+ openerTake: "extension_opener_take"
1057
1063
  };
1058
1064
 
1059
1065
  // src/commands/remoteStorage.ts
@@ -2986,6 +2992,49 @@ var DialogAPI = class {
2986
2992
  }
2987
2993
  };
2988
2994
 
2995
+ // src/api/openers.ts
2996
+ init_esm_shims();
2997
+ var OpenersAPI = class {
2998
+ constructor(client) {
2999
+ this.client = client;
3000
+ }
3001
+ /**
3002
+ * Takes the request that waits for this extension, or `null` when none does (it expired after
3003
+ * 15 seconds, was taken already, or the extension did not register for the kind). Call it once when
3004
+ * the extension starts: a frame that the choice itself opened misses the event.
3005
+ */
3006
+ async take() {
3007
+ await this.client.ready();
3008
+ const request = await this.client.request(EXTENSION_COMMANDS.openerTake, {});
3009
+ return request ?? null;
3010
+ }
3011
+ /**
3012
+ * Calls `handler` with each request that arrives while the extension is open; the SDK takes it
3013
+ * for you. Errors while taking a request go to `onError`, or to the SDK console log when omitted.
3014
+ * Returns an unsubscribe function.
3015
+ */
3016
+ onRequest(handler, onError) {
3017
+ let active = true;
3018
+ const wrapped = () => {
3019
+ void this.take().then(
3020
+ (request) => {
3021
+ if (active && request) handler(request);
3022
+ },
3023
+ (error) => {
3024
+ if (!active) return;
3025
+ if (onError) onError(error);
3026
+ else console.error("[HaexVault SDK] Failed to take opener request:", error);
3027
+ }
3028
+ );
3029
+ };
3030
+ this.client.on(OPENER_EVENTS.REQUEST, wrapped);
3031
+ return () => {
3032
+ active = false;
3033
+ this.client.off(OPENER_EVENTS.REQUEST, wrapped);
3034
+ };
3035
+ }
3036
+ };
3037
+
2989
3038
  // src/api/tools/index.ts
2990
3039
  init_esm_shims();
2991
3040
 
@@ -3861,6 +3910,7 @@ var HaexVaultSdk = class {
3861
3910
  this.notifications = new NotificationsAPI(this);
3862
3911
  this.tab = new TabAPI(this);
3863
3912
  this.dialog = new DialogAPI(this);
3913
+ this.openers = new OpenersAPI(this);
3864
3914
  this.tools = new ToolsAPI({
3865
3915
  manifest: () => this.config.manifest,
3866
3916
  send: (message) => this.sendMcpMessage(message)
@@ -4726,6 +4776,6 @@ function createHaexVaultSdk(config = {}) {
4726
4776
  return new HaexVaultSdk(config);
4727
4777
  }
4728
4778
 
4729
- export { CONTACT_COMMANDS, COSE_ALGORITHM, ContactsAPI, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, ENCRYPTED_FOLDER_COMMANDS, EXTERNAL_EVENTS, EncryptedFoldersAPI, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, HostErrorCode, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MODEL_COMMANDS, MODEL_JOB_EVENTS, MailAPI, ModelsAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, PASSWORD_COMMANDS, PEERS_EVENTS, PEER_COMMANDS, PEER_ERROR_KINDS, PasswordsAPI, PeerError, PeersAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, ToolsAPI, 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, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
4779
+ export { CONTACT_COMMANDS, COSE_ALGORITHM, ContactsAPI, DEFAULT_TIMEOUT, DatabaseAPI, DialogAPI, ENCRYPTED_FOLDER_COMMANDS, EXTERNAL_EVENTS, EncryptedFoldersAPI, ErrorCode, ExternalConnectionErrorCode, ExternalConnectionState, FilesystemAPI, HAEXSPACE_MESSAGE_TYPES, HAEXTENSION_EVENTS, HaexVaultSdk, HaexVaultSdkError, HostErrorCode, KEY_AGREEMENT_ALGO, KnownPath, LOCALSEND_EVENTS, LocalSendAPI, MAIL_COMMANDS, MAIL_EVENTS, MODEL_COMMANDS, MODEL_JOB_EVENTS, MailAPI, ModelsAPI, NOTIFICATION_COMMANDS, NOTIFICATION_EVENTS, NotificationsAPI, OPENER_EVENTS, OpenersAPI, PASSWORD_COMMANDS, PEERS_EVENTS, PEER_COMMANDS, PEER_ERROR_KINDS, PasswordsAPI, PeerError, PeersAPI, PermissionErrorCode, PermissionStatus, PermissionsAPI, RemoteStorageAPI, SHELL_EVENTS, SIGNING_ALGO, SPACE_COMMANDS, ShellAPI, SpacesAPI, TABLE_SEPARATOR, TAURI_COMMANDS, TabAPI, ToolsAPI, 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, importPrivateKeyAsync, importPrivateKeyForKeyAgreementAsync, importPublicKeyAsync, importPublicKeyForKeyAgreementAsync, importUserPrivateKeyAsync, importUserPublicKeyAsync, installBaseTag, installCookiePolyfill, installHistoryPolyfill, installLocalStoragePolyfill, installPolyfills, installSessionStoragePolyfill, isExternalClientConnected, isPermissionDeniedError, isPermissionError, isPermissionPromptError, publicKeyToDidKeyAsync, signClaimPresentationAsync, signRecordAsync, signSpaceChallengeAsync, signWithPasskeyAsync, unwrapKey, verifyClaimPresentationAsync, verifyRecordSignatureAsync, verifySpaceChallengeAsync, verifyWithPasskeyAsync, wrapKey };
4730
4780
  //# sourceMappingURL=index.mjs.map
4731
4781
  //# sourceMappingURL=index.mjs.map