@haex-space/vault-sdk 3.7.0 → 4.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/README.md +51 -19
- package/dist/cli/index.js +437 -355
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +428 -339
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{client-DH4Km77u.d.ts → client-CD5QZi7F.d.ts} +76 -12
- package/dist/{client-Dn4AbXbT.d.mts → client-Cx4ZyQFL.d.mts} +76 -12
- package/dist/haex_bundle_bg.wasm +0 -0
- package/dist/index.d.mts +16 -61
- package/dist/index.d.ts +16 -61
- package/dist/index.js +185 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -134
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +53 -2
- package/dist/node.d.ts +53 -2
- package/dist/node.js +319 -2
- package/dist/node.js.map +1 -1
- package/dist/node.mjs +320 -5
- package/dist/node.mjs.map +1 -1
- package/dist/nuxt.js +7 -5
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +3 -2
- package/dist/nuxt.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +192 -18
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +212 -38
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
- package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
- package/dist/runtime/nuxt.plugin.client.js +100 -18
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +100 -18
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +2 -2
- package/dist/svelte.d.ts +2 -2
- package/dist/svelte.js +192 -18
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +212 -38
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-DQZCRfC-.d.mts → types-BwFKGH70.d.mts} +11 -3
- package/dist/{types-DQZCRfC-.d.ts → types-BwFKGH70.d.ts} +11 -3
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +192 -18
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +212 -38
- package/dist/vue.mjs.map +1 -1
- package/package.json +9 -7
package/dist/index.js
CHANGED
|
@@ -12,6 +12,12 @@ var __export = (target, all) => {
|
|
|
12
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.29_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js
|
|
16
|
+
var init_cjs_shims = __esm({
|
|
17
|
+
"node_modules/.pnpm/tsup@8.5.1_jiti@2.7.0_postcss@8.5.29_typescript@6.0.3_yaml@2.9.0/node_modules/tsup/assets/cjs_shims.js"() {
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
15
21
|
// src/crypto/vaultKey.ts
|
|
16
22
|
async function deriveKeyFromPassword(password, salt) {
|
|
17
23
|
const encoder = new TextEncoder();
|
|
@@ -229,6 +235,7 @@ function base64ToArrayBuffer(base64) {
|
|
|
229
235
|
var PBKDF2_ITERATIONS, KEY_LENGTH, ALGORITHM;
|
|
230
236
|
var init_vaultKey = __esm({
|
|
231
237
|
"src/crypto/vaultKey.ts"() {
|
|
238
|
+
init_cjs_shims();
|
|
232
239
|
PBKDF2_ITERATIONS = 6e5;
|
|
233
240
|
KEY_LENGTH = 256;
|
|
234
241
|
ALGORITHM = "AES-GCM";
|
|
@@ -312,13 +319,21 @@ async function decryptPrivateKeyAsync(encryptedPrivateKey, nonce, salt, password
|
|
|
312
319
|
exports.SIGNING_ALGO = void 0; exports.KEY_AGREEMENT_ALGO = void 0;
|
|
313
320
|
var init_userKeypair = __esm({
|
|
314
321
|
"src/crypto/userKeypair.ts"() {
|
|
322
|
+
init_cjs_shims();
|
|
315
323
|
init_vaultKey();
|
|
316
324
|
exports.SIGNING_ALGO = { name: "Ed25519" };
|
|
317
325
|
exports.KEY_AGREEMENT_ALGO = { name: "X25519" };
|
|
318
326
|
}
|
|
319
327
|
});
|
|
320
328
|
|
|
329
|
+
// src/index.ts
|
|
330
|
+
init_cjs_shims();
|
|
331
|
+
|
|
332
|
+
// src/polyfills/index.ts
|
|
333
|
+
init_cjs_shims();
|
|
334
|
+
|
|
321
335
|
// src/polyfills/localStorage.ts
|
|
336
|
+
init_cjs_shims();
|
|
322
337
|
function installLocalStoragePolyfill() {
|
|
323
338
|
if (typeof window === "undefined") {
|
|
324
339
|
return;
|
|
@@ -413,6 +428,7 @@ function installSessionStoragePolyfill() {
|
|
|
413
428
|
}
|
|
414
429
|
|
|
415
430
|
// src/polyfills/cookies.ts
|
|
431
|
+
init_cjs_shims();
|
|
416
432
|
function installCookiePolyfill() {
|
|
417
433
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
418
434
|
return;
|
|
@@ -473,6 +489,7 @@ function installCookiePolyfill() {
|
|
|
473
489
|
}
|
|
474
490
|
|
|
475
491
|
// src/polyfills/history.ts
|
|
492
|
+
init_cjs_shims();
|
|
476
493
|
function installHistoryPolyfill() {
|
|
477
494
|
if (typeof window === "undefined" || typeof history === "undefined") {
|
|
478
495
|
return;
|
|
@@ -536,7 +553,11 @@ function installHistoryPolyfill() {
|
|
|
536
553
|
}
|
|
537
554
|
}
|
|
538
555
|
|
|
556
|
+
// src/polyfills/debug.ts
|
|
557
|
+
init_cjs_shims();
|
|
558
|
+
|
|
539
559
|
// src/messages.ts
|
|
560
|
+
init_cjs_shims();
|
|
540
561
|
var HAEXSPACE_MESSAGE_TYPES = {
|
|
541
562
|
/** Debug message for development/troubleshooting */
|
|
542
563
|
DEBUG: "haexspace:debug",
|
|
@@ -581,6 +602,7 @@ function installDebugDiagnostics() {
|
|
|
581
602
|
}
|
|
582
603
|
|
|
583
604
|
// src/polyfills/baseTag.ts
|
|
605
|
+
init_cjs_shims();
|
|
584
606
|
function installBaseTag() {
|
|
585
607
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
586
608
|
return;
|
|
@@ -622,6 +644,7 @@ function installBaseTag() {
|
|
|
622
644
|
}
|
|
623
645
|
|
|
624
646
|
// src/polyfills/consoleForwarding.ts
|
|
647
|
+
init_cjs_shims();
|
|
625
648
|
var originalConsole = {
|
|
626
649
|
log: console.log,
|
|
627
650
|
info: console.info,
|
|
@@ -702,7 +725,14 @@ if (typeof window !== "undefined") {
|
|
|
702
725
|
installPolyfills();
|
|
703
726
|
}
|
|
704
727
|
|
|
728
|
+
// src/client.ts
|
|
729
|
+
init_cjs_shims();
|
|
730
|
+
|
|
731
|
+
// src/types.ts
|
|
732
|
+
init_cjs_shims();
|
|
733
|
+
|
|
705
734
|
// src/events.ts
|
|
735
|
+
init_cjs_shims();
|
|
706
736
|
var HAEXTENSION_EVENTS = {
|
|
707
737
|
/** Context (theme, locale, platform) has changed */
|
|
708
738
|
CONTEXT_CHANGED: "haextension:context:changed",
|
|
@@ -817,7 +847,17 @@ var HaexVaultSdkError = class extends Error {
|
|
|
817
847
|
}
|
|
818
848
|
};
|
|
819
849
|
|
|
850
|
+
// src/api/storage.ts
|
|
851
|
+
init_cjs_shims();
|
|
852
|
+
|
|
853
|
+
// src/commands.ts
|
|
854
|
+
init_cjs_shims();
|
|
855
|
+
|
|
856
|
+
// src/commands/index.ts
|
|
857
|
+
init_cjs_shims();
|
|
858
|
+
|
|
820
859
|
// src/commands/database.ts
|
|
860
|
+
init_cjs_shims();
|
|
821
861
|
var DATABASE_COMMANDS = {
|
|
822
862
|
/** Execute a SELECT query */
|
|
823
863
|
query: "extension_database_query",
|
|
@@ -830,6 +870,7 @@ var DATABASE_COMMANDS = {
|
|
|
830
870
|
};
|
|
831
871
|
|
|
832
872
|
// src/commands/permissions.ts
|
|
873
|
+
init_cjs_shims();
|
|
833
874
|
var PERMISSIONS_COMMANDS = {
|
|
834
875
|
/** Check web/fetch permission */
|
|
835
876
|
checkWeb: "extension_permissions_check_web",
|
|
@@ -840,6 +881,7 @@ var PERMISSIONS_COMMANDS = {
|
|
|
840
881
|
};
|
|
841
882
|
|
|
842
883
|
// src/commands/web.ts
|
|
884
|
+
init_cjs_shims();
|
|
843
885
|
var WEB_COMMANDS = {
|
|
844
886
|
/** Open URL in external browser */
|
|
845
887
|
open: "extension_web_open",
|
|
@@ -848,6 +890,7 @@ var WEB_COMMANDS = {
|
|
|
848
890
|
};
|
|
849
891
|
|
|
850
892
|
// src/commands/webStorage.ts
|
|
893
|
+
init_cjs_shims();
|
|
851
894
|
var WEB_STORAGE_COMMANDS = {
|
|
852
895
|
/** Get item from storage */
|
|
853
896
|
getItem: "extension_web_storage_get_item",
|
|
@@ -862,6 +905,7 @@ var WEB_STORAGE_COMMANDS = {
|
|
|
862
905
|
};
|
|
863
906
|
|
|
864
907
|
// src/commands/filesystem.ts
|
|
908
|
+
init_cjs_shims();
|
|
865
909
|
var FILESYSTEM_COMMANDS = {
|
|
866
910
|
// Dialog commands
|
|
867
911
|
/** Show save file dialog */
|
|
@@ -905,6 +949,7 @@ var FILESYSTEM_COMMANDS = {
|
|
|
905
949
|
};
|
|
906
950
|
|
|
907
951
|
// src/commands/externalBridge.ts
|
|
952
|
+
init_cjs_shims();
|
|
908
953
|
var EXTERNAL_BRIDGE_COMMANDS = {
|
|
909
954
|
// Response handling (called by extensions)
|
|
910
955
|
/** Respond to an external request */
|
|
@@ -944,6 +989,7 @@ var EXTERNAL_BRIDGE_COMMANDS = {
|
|
|
944
989
|
};
|
|
945
990
|
|
|
946
991
|
// src/commands/extension.ts
|
|
992
|
+
init_cjs_shims();
|
|
947
993
|
var EXTENSION_COMMANDS = {
|
|
948
994
|
/** Get extension info (manifest, id, etc.) */
|
|
949
995
|
getInfo: "extension_get_info",
|
|
@@ -958,10 +1004,15 @@ var EXTENSION_COMMANDS = {
|
|
|
958
1004
|
/** Filter sync tables by extension permissions (returns filtered map) */
|
|
959
1005
|
filterSyncTables: "extension_filter_sync_tables",
|
|
960
1006
|
/** Emit sync tables to webviews (host-only, desktop only) */
|
|
961
|
-
emitSyncTables: "extension_emit_sync_tables"
|
|
1007
|
+
emitSyncTables: "extension_emit_sync_tables",
|
|
1008
|
+
/** Ask the host to mark (or unmark) this extension's own tab as wanting attention */
|
|
1009
|
+
tabAttention: "extension_tab_attention",
|
|
1010
|
+
/** Ask the user to confirm, in a dialog the host draws over this extension's tab */
|
|
1011
|
+
dialogConfirm: "extension_dialog_confirm"
|
|
962
1012
|
};
|
|
963
1013
|
|
|
964
1014
|
// src/commands/remoteStorage.ts
|
|
1015
|
+
init_cjs_shims();
|
|
965
1016
|
var REMOTE_STORAGE_COMMANDS = {
|
|
966
1017
|
// Backend Management
|
|
967
1018
|
/** List all storage backends */
|
|
@@ -986,6 +1037,7 @@ var REMOTE_STORAGE_COMMANDS = {
|
|
|
986
1037
|
};
|
|
987
1038
|
|
|
988
1039
|
// src/commands/localsend.ts
|
|
1040
|
+
init_cjs_shims();
|
|
989
1041
|
var LOCALSEND_COMMANDS = {
|
|
990
1042
|
// Initialization
|
|
991
1043
|
/** Initialize LocalSend (generate identity, etc.) */
|
|
@@ -1032,6 +1084,7 @@ var LOCALSEND_COMMANDS = {
|
|
|
1032
1084
|
};
|
|
1033
1085
|
|
|
1034
1086
|
// src/commands/spaces.ts
|
|
1087
|
+
init_cjs_shims();
|
|
1035
1088
|
var SPACE_COMMANDS = {
|
|
1036
1089
|
/** Bulk assign rows to spaces */
|
|
1037
1090
|
assign: "extension_space_assign",
|
|
@@ -1050,6 +1103,7 @@ var SPACE_COMMANDS = {
|
|
|
1050
1103
|
};
|
|
1051
1104
|
|
|
1052
1105
|
// src/commands/shell.ts
|
|
1106
|
+
init_cjs_shims();
|
|
1053
1107
|
var SHELL_COMMANDS = {
|
|
1054
1108
|
/** List available shell environments (no permission required) */
|
|
1055
1109
|
listAvailable: "extension_shell_list_available",
|
|
@@ -1057,6 +1111,8 @@ var SHELL_COMMANDS = {
|
|
|
1057
1111
|
create: "extension_shell_create",
|
|
1058
1112
|
/** Write data to a shell session's stdin */
|
|
1059
1113
|
write: "extension_shell_write",
|
|
1114
|
+
/** Acknowledge `shell:output` events handed on (backpressure; sent by the SDK itself) */
|
|
1115
|
+
ack: "extension_shell_ack",
|
|
1060
1116
|
/** Resize a shell session's terminal */
|
|
1061
1117
|
resize: "extension_shell_resize",
|
|
1062
1118
|
/** Close a shell session */
|
|
@@ -1064,6 +1120,7 @@ var SHELL_COMMANDS = {
|
|
|
1064
1120
|
};
|
|
1065
1121
|
|
|
1066
1122
|
// src/commands/passwords.ts
|
|
1123
|
+
init_cjs_shims();
|
|
1067
1124
|
var PASSWORD_COMMANDS = {
|
|
1068
1125
|
/** List items (no secrets) within the extension's tag scope */
|
|
1069
1126
|
list: "extension_password_list",
|
|
@@ -1078,6 +1135,7 @@ var PASSWORD_COMMANDS = {
|
|
|
1078
1135
|
};
|
|
1079
1136
|
|
|
1080
1137
|
// src/commands/mail.ts
|
|
1138
|
+
init_cjs_shims();
|
|
1081
1139
|
var MAIL_COMMANDS = {
|
|
1082
1140
|
/** LIST mailboxes + optional STATUS counts */
|
|
1083
1141
|
listMailboxes: "extension_mail_list_mailboxes",
|
|
@@ -1097,13 +1155,14 @@ var MAIL_COMMANDS = {
|
|
|
1097
1155
|
sendMessage: "extension_mail_send_message",
|
|
1098
1156
|
/** Build RFC822 bytes without sending (for Drafts via APPEND) */
|
|
1099
1157
|
buildRfc822: "extension_mail_build_rfc822",
|
|
1100
|
-
/** Start (or replace) a background
|
|
1158
|
+
/** Start (or replace) a background new-mail watch for an account/mailbox */
|
|
1101
1159
|
startWatch: "extension_mail_start_watch",
|
|
1102
|
-
/** Stop a background
|
|
1160
|
+
/** Stop a background new-mail watch */
|
|
1103
1161
|
stopWatch: "extension_mail_stop_watch"
|
|
1104
1162
|
};
|
|
1105
1163
|
|
|
1106
1164
|
// src/commands/notifications.ts
|
|
1165
|
+
init_cjs_shims();
|
|
1107
1166
|
var NOTIFICATION_COMMANDS = {
|
|
1108
1167
|
/** Show an OS notification. Returns the assigned notification id. */
|
|
1109
1168
|
show: "extension_notifications_show",
|
|
@@ -1152,6 +1211,7 @@ var StorageAPI = class {
|
|
|
1152
1211
|
};
|
|
1153
1212
|
|
|
1154
1213
|
// src/api/database.ts
|
|
1214
|
+
init_cjs_shims();
|
|
1155
1215
|
function quoteIdent(identifier) {
|
|
1156
1216
|
if (identifier.startsWith('"') && identifier.endsWith('"')) {
|
|
1157
1217
|
return identifier;
|
|
@@ -1251,6 +1311,7 @@ var DatabaseAPI = class {
|
|
|
1251
1311
|
};
|
|
1252
1312
|
|
|
1253
1313
|
// src/api/filesystem.ts
|
|
1314
|
+
init_cjs_shims();
|
|
1254
1315
|
init_vaultKey();
|
|
1255
1316
|
var KnownPath = /* @__PURE__ */ ((KnownPath2) => {
|
|
1256
1317
|
KnownPath2["Home"] = "home";
|
|
@@ -1495,6 +1556,7 @@ var FilesystemAPI = class {
|
|
|
1495
1556
|
};
|
|
1496
1557
|
|
|
1497
1558
|
// src/api/web.ts
|
|
1559
|
+
init_cjs_shims();
|
|
1498
1560
|
var WebAPI = class {
|
|
1499
1561
|
constructor(client) {
|
|
1500
1562
|
this.client = client;
|
|
@@ -1608,6 +1670,7 @@ var WebAPI = class {
|
|
|
1608
1670
|
};
|
|
1609
1671
|
|
|
1610
1672
|
// src/api/permissions.ts
|
|
1673
|
+
init_cjs_shims();
|
|
1611
1674
|
var PermissionsAPI = class {
|
|
1612
1675
|
constructor(client) {
|
|
1613
1676
|
this.client = client;
|
|
@@ -1662,6 +1725,7 @@ var PermissionsAPI = class {
|
|
|
1662
1725
|
};
|
|
1663
1726
|
|
|
1664
1727
|
// src/api/remoteStorage.ts
|
|
1728
|
+
init_cjs_shims();
|
|
1665
1729
|
init_vaultKey();
|
|
1666
1730
|
var RemoteStorageAPI = class {
|
|
1667
1731
|
constructor(client) {
|
|
@@ -1772,6 +1836,7 @@ var BackendManagement = class {
|
|
|
1772
1836
|
};
|
|
1773
1837
|
|
|
1774
1838
|
// src/api/localsend.ts
|
|
1839
|
+
init_cjs_shims();
|
|
1775
1840
|
var LOCALSEND_EVENTS = {
|
|
1776
1841
|
/** New device discovered */
|
|
1777
1842
|
deviceDiscovered: "localsend:device-discovered",
|
|
@@ -1943,6 +2008,7 @@ var LocalSendAPI = class {
|
|
|
1943
2008
|
};
|
|
1944
2009
|
|
|
1945
2010
|
// src/api/spaces.ts
|
|
2011
|
+
init_cjs_shims();
|
|
1946
2012
|
var SpacesAPI = class {
|
|
1947
2013
|
constructor(client) {
|
|
1948
2014
|
this.client = client;
|
|
@@ -2015,9 +2081,45 @@ var SpacesAPI = class {
|
|
|
2015
2081
|
};
|
|
2016
2082
|
|
|
2017
2083
|
// src/api/shell.ts
|
|
2084
|
+
init_cjs_shims();
|
|
2085
|
+
var NOT_SUPPORTED = 8e3;
|
|
2086
|
+
function isUnsupported(error) {
|
|
2087
|
+
if (error?.code === NOT_SUPPORTED) return true;
|
|
2088
|
+
return typeof error === "string" && /\bcommand (\S+ )?not found\b/i.test(error);
|
|
2089
|
+
}
|
|
2018
2090
|
var ShellAPI = class {
|
|
2019
2091
|
constructor(sdk) {
|
|
2020
2092
|
this.sdk = sdk;
|
|
2093
|
+
/** `shell:output` events per session handed on but not yet acknowledged. */
|
|
2094
|
+
this.unacknowledged = /* @__PURE__ */ new Map();
|
|
2095
|
+
this.flushScheduled = false;
|
|
2096
|
+
/** The host does not know `extension_shell_ack` (it reads output without backpressure). */
|
|
2097
|
+
this.ackUnsupported = false;
|
|
2098
|
+
this.sdk.on(SHELL_EVENTS.OUTPUT, (event) => this.acknowledge(event));
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Backpressure: the host keeps reading a shell's output only while this frame has few
|
|
2102
|
+
* events open, so a shell that writes fast waits instead of flooding the page. The SDK
|
|
2103
|
+
* acknowledges every event once the listeners have had it, in one request per session and
|
|
2104
|
+
* task.
|
|
2105
|
+
*/
|
|
2106
|
+
acknowledge(event) {
|
|
2107
|
+
const sessionId = event.data?.sessionId;
|
|
2108
|
+
if (this.ackUnsupported || typeof sessionId !== "string") return;
|
|
2109
|
+
this.unacknowledged.set(sessionId, (this.unacknowledged.get(sessionId) ?? 0) + 1);
|
|
2110
|
+
if (this.flushScheduled) return;
|
|
2111
|
+
this.flushScheduled = true;
|
|
2112
|
+
queueMicrotask(() => this.flushAcknowledgements());
|
|
2113
|
+
}
|
|
2114
|
+
flushAcknowledgements() {
|
|
2115
|
+
this.flushScheduled = false;
|
|
2116
|
+
const counts = [...this.unacknowledged];
|
|
2117
|
+
this.unacknowledged.clear();
|
|
2118
|
+
for (const [sessionId, count] of counts) {
|
|
2119
|
+
this.sdk.request(SHELL_COMMANDS.ack, { sessionId, count }).catch((error) => {
|
|
2120
|
+
if (isUnsupported(error)) this.ackUnsupported = true;
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2021
2123
|
}
|
|
2022
2124
|
/**
|
|
2023
2125
|
* List available shell environments on the host system.
|
|
@@ -2086,6 +2188,7 @@ var ShellAPI = class {
|
|
|
2086
2188
|
};
|
|
2087
2189
|
|
|
2088
2190
|
// src/api/passwords.ts
|
|
2191
|
+
init_cjs_shims();
|
|
2089
2192
|
var PasswordsAPI = class {
|
|
2090
2193
|
constructor(client) {
|
|
2091
2194
|
this.client = client;
|
|
@@ -2131,6 +2234,7 @@ var PasswordsAPI = class {
|
|
|
2131
2234
|
};
|
|
2132
2235
|
|
|
2133
2236
|
// src/api/mail.ts
|
|
2237
|
+
init_cjs_shims();
|
|
2134
2238
|
var MailAPI = class {
|
|
2135
2239
|
constructor(client) {
|
|
2136
2240
|
this.client = client;
|
|
@@ -2233,22 +2337,29 @@ var MailAPI = class {
|
|
|
2233
2337
|
});
|
|
2234
2338
|
}
|
|
2235
2339
|
/**
|
|
2236
|
-
* Start (or replace) a background
|
|
2237
|
-
*
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
2340
|
+
* Start (or replace) a background watch for `accountId`/`mailboxName`.
|
|
2341
|
+
* Requires `mail` permission with action `poll` on the account's IMAP
|
|
2342
|
+
* host (`imap.host` when passed; prompted on first call, same as
|
|
2343
|
+
* `fetch`/`send`).
|
|
2240
2344
|
*
|
|
2241
|
-
* `
|
|
2242
|
-
*
|
|
2345
|
+
* Pass the account's `imap` config, as for every other mail call: the host
|
|
2346
|
+
* keeps the credentials in memory for as long as the watch runs and never
|
|
2347
|
+
* stores them. Hosts that wait with IMAP IDLE are told about new mail by the
|
|
2348
|
+
* server; `intervalSeconds` (clamped host-side to [30, 3600]) is the polling
|
|
2349
|
+
* interval for servers without IDLE. Listen for results via `onNewMessages`.
|
|
2350
|
+
*
|
|
2351
|
+
* `imap` is optional for hosts that resolve the credentials themselves from
|
|
2352
|
+
* `accountId`; holzi requires it.
|
|
2243
2353
|
*/
|
|
2244
|
-
async startWatchingAsync(accountId, mailboxName, intervalSeconds) {
|
|
2354
|
+
async startWatchingAsync(accountId, mailboxName, intervalSeconds, imap) {
|
|
2245
2355
|
return this.client.request(MAIL_COMMANDS.startWatch, {
|
|
2246
2356
|
accountId,
|
|
2247
2357
|
mailboxName,
|
|
2248
|
-
intervalSeconds
|
|
2358
|
+
intervalSeconds,
|
|
2359
|
+
imap
|
|
2249
2360
|
});
|
|
2250
2361
|
}
|
|
2251
|
-
/** Stop a background
|
|
2362
|
+
/** Stop a background watch previously started with `startWatchingAsync`. */
|
|
2252
2363
|
async stopWatchingAsync(accountId, mailboxName) {
|
|
2253
2364
|
return this.client.request(MAIL_COMMANDS.stopWatch, {
|
|
2254
2365
|
accountId,
|
|
@@ -2270,6 +2381,7 @@ var MailAPI = class {
|
|
|
2270
2381
|
};
|
|
2271
2382
|
|
|
2272
2383
|
// src/api/notifications.ts
|
|
2384
|
+
init_cjs_shims();
|
|
2273
2385
|
var NotificationsAPI = class {
|
|
2274
2386
|
constructor(client) {
|
|
2275
2387
|
this.client = client;
|
|
@@ -2301,7 +2413,36 @@ var NotificationsAPI = class {
|
|
|
2301
2413
|
}
|
|
2302
2414
|
};
|
|
2303
2415
|
|
|
2416
|
+
// src/api/tab.ts
|
|
2417
|
+
init_cjs_shims();
|
|
2418
|
+
var TabAPI = class {
|
|
2419
|
+
constructor(client) {
|
|
2420
|
+
this.client = client;
|
|
2421
|
+
}
|
|
2422
|
+
/**
|
|
2423
|
+
* Mark the tab as wanting the user's attention (`true`), e.g. for unread
|
|
2424
|
+
* content, or clear the mark (`false`).
|
|
2425
|
+
*/
|
|
2426
|
+
async requestAttention(active) {
|
|
2427
|
+
await this.client.request(EXTENSION_COMMANDS.tabAttention, { active });
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
|
|
2431
|
+
// src/api/dialog.ts
|
|
2432
|
+
init_cjs_shims();
|
|
2433
|
+
var DialogAPI = class {
|
|
2434
|
+
constructor(client) {
|
|
2435
|
+
this.client = client;
|
|
2436
|
+
}
|
|
2437
|
+
/** Asks the user; resolves `true` for confirm, `false` for cancel or when the dialog is closed. */
|
|
2438
|
+
async confirm(options) {
|
|
2439
|
+
const answer = await this.client.request(EXTENSION_COMMANDS.dialogConfirm, { ...options }, { timeout: null });
|
|
2440
|
+
return answer === true;
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
|
|
2304
2444
|
// src/client/tableName.ts
|
|
2445
|
+
init_cjs_shims();
|
|
2305
2446
|
function validatePublicKey(publicKey) {
|
|
2306
2447
|
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
2307
2448
|
throw new HaexVaultSdkError(
|
|
@@ -2387,6 +2528,7 @@ function parseTableName(fullTableName) {
|
|
|
2387
2528
|
}
|
|
2388
2529
|
|
|
2389
2530
|
// src/client/init.ts
|
|
2531
|
+
init_cjs_shims();
|
|
2390
2532
|
var PORT_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
2391
2533
|
function getCurrentWebviewLabel() {
|
|
2392
2534
|
const internals = window.__TAURI_INTERNALS__;
|
|
@@ -2535,6 +2677,10 @@ function waitForHostPortAsync(log) {
|
|
|
2535
2677
|
const handler = (event) => {
|
|
2536
2678
|
const type = event.data?.type;
|
|
2537
2679
|
if (type !== HAEXSPACE_MESSAGE_TYPES.PORT_INIT) return;
|
|
2680
|
+
if (event.source !== window.parent) {
|
|
2681
|
+
log("PORT_INIT from a window other than the parent \u2014 ignoring");
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2538
2684
|
const port = event.ports[0];
|
|
2539
2685
|
if (!port) {
|
|
2540
2686
|
log("PORT_INIT received but event.ports is empty \u2014 ignoring");
|
|
@@ -2568,10 +2714,11 @@ postMessage error: ${e}`);
|
|
|
2568
2714
|
}
|
|
2569
2715
|
|
|
2570
2716
|
// src/client/transport.ts
|
|
2717
|
+
init_cjs_shims();
|
|
2571
2718
|
function generateRequestId(counter) {
|
|
2572
2719
|
return `req_${counter}`;
|
|
2573
2720
|
}
|
|
2574
|
-
function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port) {
|
|
2721
|
+
function sendPostMessage(method, params, requestId, config, extensionInfo, pendingRequests, port, timeoutMs = config.timeout) {
|
|
2575
2722
|
if (!port) {
|
|
2576
2723
|
return Promise.reject(
|
|
2577
2724
|
new HaexVaultSdkError(
|
|
@@ -2586,14 +2733,14 @@ function sendPostMessage(method, params, requestId, config, extensionInfo, pendi
|
|
|
2586
2733
|
timestamp: Date.now()
|
|
2587
2734
|
};
|
|
2588
2735
|
return new Promise((resolve, reject) => {
|
|
2589
|
-
const timeout = setTimeout(() => {
|
|
2736
|
+
const timeout = timeoutMs === null ? void 0 : setTimeout(() => {
|
|
2590
2737
|
pendingRequests.delete(requestId);
|
|
2591
2738
|
reject(
|
|
2592
2739
|
new HaexVaultSdkError("TIMEOUT" /* TIMEOUT */, "errors.timeout", {
|
|
2593
|
-
timeout:
|
|
2740
|
+
timeout: timeoutMs
|
|
2594
2741
|
})
|
|
2595
2742
|
);
|
|
2596
|
-
},
|
|
2743
|
+
}, timeoutMs);
|
|
2597
2744
|
pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
2598
2745
|
if (config.debug) {
|
|
2599
2746
|
console.log("[SDK Debug] ========== Sending Request ==========");
|
|
@@ -2619,6 +2766,7 @@ async function sendInvoke(method, params, config, _log) {
|
|
|
2619
2766
|
}
|
|
2620
2767
|
|
|
2621
2768
|
// src/client/events.ts
|
|
2769
|
+
init_cjs_shims();
|
|
2622
2770
|
function createMessageHandler(config, pendingRequests, extensionInfo, onEvent) {
|
|
2623
2771
|
return (event) => {
|
|
2624
2772
|
if (config.debug) {
|
|
@@ -2718,6 +2866,9 @@ function removeEventListener(eventType, callback, eventListeners) {
|
|
|
2718
2866
|
function notifySubscribers(subscribers) {
|
|
2719
2867
|
subscribers.forEach((callback) => callback());
|
|
2720
2868
|
}
|
|
2869
|
+
|
|
2870
|
+
// src/client/database.ts
|
|
2871
|
+
init_cjs_shims();
|
|
2721
2872
|
function createDrizzleInstance(schema, extensionInfo, request, log) {
|
|
2722
2873
|
if (!extensionInfo) {
|
|
2723
2874
|
throw new HaexVaultSdkError(
|
|
@@ -2786,6 +2937,7 @@ async function executeRaw(sql, params, request) {
|
|
|
2786
2937
|
}
|
|
2787
2938
|
|
|
2788
2939
|
// src/client/external.ts
|
|
2940
|
+
init_cjs_shims();
|
|
2789
2941
|
function registerExternalHandler(action, handler, handlers, log) {
|
|
2790
2942
|
handlers.set(action, handler);
|
|
2791
2943
|
log(`[ExternalRequest] Registered handler for action: ${action}`);
|
|
@@ -2827,12 +2979,14 @@ async function respondToExternalRequest(response, request) {
|
|
|
2827
2979
|
}
|
|
2828
2980
|
|
|
2829
2981
|
// src/commands/ai.ts
|
|
2982
|
+
init_cjs_shims();
|
|
2830
2983
|
var AI_COMMANDS = {
|
|
2831
2984
|
/** Respond to an AI action request */
|
|
2832
2985
|
actionRespond: "ai_action_respond"
|
|
2833
2986
|
};
|
|
2834
2987
|
|
|
2835
2988
|
// src/client/permissionRetry.ts
|
|
2989
|
+
init_cjs_shims();
|
|
2836
2990
|
var PERMISSION_DECISION_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2837
2991
|
var MAX_PERMISSION_RETRIES = 3;
|
|
2838
2992
|
function permissionKey(resourceType, action, target) {
|
|
@@ -2946,6 +3100,8 @@ var HaexVaultSdk = class {
|
|
|
2946
3100
|
this.passwords = new PasswordsAPI(this);
|
|
2947
3101
|
this.mail = new MailAPI(this);
|
|
2948
3102
|
this.notifications = new NotificationsAPI(this);
|
|
3103
|
+
this.tab = new TabAPI(this);
|
|
3104
|
+
this.dialog = new DialogAPI(this);
|
|
2949
3105
|
installConsoleForwarding(this.config.debug);
|
|
2950
3106
|
this.on(HAEXTENSION_EVENTS.PERMISSION_RESOLVED, (event) => {
|
|
2951
3107
|
const data = event.data;
|
|
@@ -3101,7 +3257,7 @@ var HaexVaultSdk = class {
|
|
|
3101
3257
|
// ==========================================================================
|
|
3102
3258
|
// Communication
|
|
3103
3259
|
// ==========================================================================
|
|
3104
|
-
async request(method, params) {
|
|
3260
|
+
async request(method, params, options) {
|
|
3105
3261
|
const resolvedParams = params ?? {};
|
|
3106
3262
|
const send = () => {
|
|
3107
3263
|
if (this.isNativeWindow && hasTauri()) {
|
|
@@ -3120,7 +3276,8 @@ var HaexVaultSdk = class {
|
|
|
3120
3276
|
this.config,
|
|
3121
3277
|
this._extensionInfo,
|
|
3122
3278
|
this.pendingRequests,
|
|
3123
|
-
this.hostPort
|
|
3279
|
+
this.hostPort,
|
|
3280
|
+
options?.timeout
|
|
3124
3281
|
);
|
|
3125
3282
|
};
|
|
3126
3283
|
return withPermissionRetry(send, this.permissionWaiters, this.log.bind(this));
|
|
@@ -3298,6 +3455,7 @@ var HaexVaultSdk = class {
|
|
|
3298
3455
|
};
|
|
3299
3456
|
|
|
3300
3457
|
// src/types/external.ts
|
|
3458
|
+
init_cjs_shims();
|
|
3301
3459
|
var ExternalConnectionState = /* @__PURE__ */ ((ExternalConnectionState2) => {
|
|
3302
3460
|
ExternalConnectionState2["DISCONNECTED"] = "disconnected";
|
|
3303
3461
|
ExternalConnectionState2["CONNECTING"] = "connecting";
|
|
@@ -3325,107 +3483,15 @@ function canExternalClientSendRequests(state) {
|
|
|
3325
3483
|
return state === "paired" /* PAIRED */;
|
|
3326
3484
|
}
|
|
3327
3485
|
|
|
3328
|
-
// src/
|
|
3329
|
-
|
|
3330
|
-
if (typeof obj !== "object" || obj === null) {
|
|
3331
|
-
return obj;
|
|
3332
|
-
}
|
|
3333
|
-
if (Array.isArray(obj)) {
|
|
3334
|
-
return obj.map((item) => sortObjectKeysRecursively(item));
|
|
3335
|
-
}
|
|
3336
|
-
return Object.keys(obj).sort().reduce((result, key) => {
|
|
3337
|
-
result[key] = sortObjectKeysRecursively(obj[key]);
|
|
3338
|
-
return result;
|
|
3339
|
-
}, {});
|
|
3340
|
-
}
|
|
3341
|
-
function hexToBytes(hex) {
|
|
3342
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
3343
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
3344
|
-
bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);
|
|
3345
|
-
}
|
|
3346
|
-
return bytes.buffer;
|
|
3347
|
-
}
|
|
3348
|
-
async function verifyExtensionSignature(files, manifest) {
|
|
3349
|
-
try {
|
|
3350
|
-
if (typeof crypto === "undefined" || !crypto.subtle) {
|
|
3351
|
-
return { valid: false, error: "WebCrypto API not available" };
|
|
3352
|
-
}
|
|
3353
|
-
const { publicKey: publicKeyHex, signature: signatureHex } = manifest;
|
|
3354
|
-
if (!publicKeyHex) {
|
|
3355
|
-
return { valid: false, error: "Missing publicKey in manifest" };
|
|
3356
|
-
}
|
|
3357
|
-
if (!signatureHex) {
|
|
3358
|
-
return { valid: false, error: "Missing signature in manifest" };
|
|
3359
|
-
}
|
|
3360
|
-
if (!/^[0-9a-fA-F]+$/.test(publicKeyHex)) {
|
|
3361
|
-
return { valid: false, error: "Invalid publicKey format (must be hex)" };
|
|
3362
|
-
}
|
|
3363
|
-
if (!/^[0-9a-fA-F]+$/.test(signatureHex)) {
|
|
3364
|
-
return { valid: false, error: "Invalid signature format (must be hex)" };
|
|
3365
|
-
}
|
|
3366
|
-
const publicKeyBuffer = hexToBytes(publicKeyHex);
|
|
3367
|
-
let publicKey;
|
|
3368
|
-
try {
|
|
3369
|
-
publicKey = await crypto.subtle.importKey(
|
|
3370
|
-
"raw",
|
|
3371
|
-
publicKeyBuffer,
|
|
3372
|
-
{ name: "Ed25519", namedCurve: "Ed25519" },
|
|
3373
|
-
false,
|
|
3374
|
-
["verify"]
|
|
3375
|
-
);
|
|
3376
|
-
} catch (err) {
|
|
3377
|
-
return {
|
|
3378
|
-
valid: false,
|
|
3379
|
-
error: `Failed to import public key: ${err instanceof Error ? err.message : "Ed25519 may not be supported in this browser"}`
|
|
3380
|
-
};
|
|
3381
|
-
}
|
|
3382
|
-
const manifestForHashing = sortObjectKeysRecursively({
|
|
3383
|
-
...manifest,
|
|
3384
|
-
signature: ""
|
|
3385
|
-
});
|
|
3386
|
-
const manifestJson = JSON.stringify(manifestForHashing, null, 2);
|
|
3387
|
-
const manifestBytes = new TextEncoder().encode(manifestJson);
|
|
3388
|
-
const filesForHashing = files.map((file) => {
|
|
3389
|
-
if (file.path === "haextension/manifest.json") {
|
|
3390
|
-
return { path: file.path, content: manifestBytes };
|
|
3391
|
-
}
|
|
3392
|
-
return file;
|
|
3393
|
-
});
|
|
3394
|
-
filesForHashing.sort((a, b) => {
|
|
3395
|
-
if (a.path < b.path) return -1;
|
|
3396
|
-
if (a.path > b.path) return 1;
|
|
3397
|
-
return 0;
|
|
3398
|
-
});
|
|
3399
|
-
const totalLength = filesForHashing.reduce((sum, f) => sum + f.content.length, 0);
|
|
3400
|
-
const combined = new Uint8Array(totalLength);
|
|
3401
|
-
let offset = 0;
|
|
3402
|
-
for (const file of filesForHashing) {
|
|
3403
|
-
combined.set(file.content, offset);
|
|
3404
|
-
offset += file.content.length;
|
|
3405
|
-
}
|
|
3406
|
-
const hashBuffer = await crypto.subtle.digest("SHA-256", combined);
|
|
3407
|
-
const signatureBuffer = hexToBytes(signatureHex);
|
|
3408
|
-
const isValid = await crypto.subtle.verify(
|
|
3409
|
-
"Ed25519",
|
|
3410
|
-
publicKey,
|
|
3411
|
-
signatureBuffer,
|
|
3412
|
-
hashBuffer
|
|
3413
|
-
);
|
|
3414
|
-
return { valid: isValid };
|
|
3415
|
-
} catch (err) {
|
|
3416
|
-
console.error("Signature verification error:", err);
|
|
3417
|
-
return {
|
|
3418
|
-
valid: false,
|
|
3419
|
-
error: err instanceof Error ? err.message : "Unknown verification error"
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
}
|
|
3486
|
+
// src/types/spaces.ts
|
|
3487
|
+
init_cjs_shims();
|
|
3423
3488
|
|
|
3424
3489
|
// src/index.ts
|
|
3425
3490
|
init_vaultKey();
|
|
3426
3491
|
init_userKeypair();
|
|
3427
3492
|
|
|
3428
3493
|
// src/crypto/didKey.ts
|
|
3494
|
+
init_cjs_shims();
|
|
3429
3495
|
init_userKeypair();
|
|
3430
3496
|
init_vaultKey();
|
|
3431
3497
|
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -3524,6 +3590,7 @@ async function generateIdentityAsync() {
|
|
|
3524
3590
|
}
|
|
3525
3591
|
|
|
3526
3592
|
// src/crypto/spaceKey.ts
|
|
3593
|
+
init_cjs_shims();
|
|
3527
3594
|
init_userKeypair();
|
|
3528
3595
|
init_vaultKey();
|
|
3529
3596
|
function generateSpaceKey() {
|
|
@@ -3614,6 +3681,7 @@ async function decryptSpaceNameAsync(spaceKey, encryptedName, nameNonce) {
|
|
|
3614
3681
|
}
|
|
3615
3682
|
|
|
3616
3683
|
// src/crypto/claims.ts
|
|
3684
|
+
init_cjs_shims();
|
|
3617
3685
|
init_userKeypair();
|
|
3618
3686
|
async function signClaimPresentationAsync(did, publicKeyBase64, claims, privateKeyBase64) {
|
|
3619
3687
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -3650,6 +3718,7 @@ async function verifyClaimPresentationAsync(presentation) {
|
|
|
3650
3718
|
}
|
|
3651
3719
|
|
|
3652
3720
|
// src/crypto/recordSigning.ts
|
|
3721
|
+
init_cjs_shims();
|
|
3653
3722
|
init_userKeypair();
|
|
3654
3723
|
init_vaultKey();
|
|
3655
3724
|
function canonicalize(record) {
|
|
@@ -3714,6 +3783,7 @@ async function verifySpaceChallengeAsync(spaceId, timestamp, signatureBase64, pu
|
|
|
3714
3783
|
}
|
|
3715
3784
|
|
|
3716
3785
|
// src/crypto/passkey.ts
|
|
3786
|
+
init_cjs_shims();
|
|
3717
3787
|
init_vaultKey();
|
|
3718
3788
|
function toArrayBuffer(data) {
|
|
3719
3789
|
if (data instanceof ArrayBuffer) {
|
|
@@ -3887,6 +3957,7 @@ function createHaexVaultSdk(config = {}) {
|
|
|
3887
3957
|
exports.COSE_ALGORITHM = COSE_ALGORITHM;
|
|
3888
3958
|
exports.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT;
|
|
3889
3959
|
exports.DatabaseAPI = DatabaseAPI;
|
|
3960
|
+
exports.DialogAPI = DialogAPI;
|
|
3890
3961
|
exports.EXTERNAL_EVENTS = EXTERNAL_EVENTS;
|
|
3891
3962
|
exports.ErrorCode = ErrorCode;
|
|
3892
3963
|
exports.ExternalConnectionErrorCode = ExternalConnectionErrorCode;
|
|
@@ -3917,6 +3988,7 @@ exports.ShellAPI = ShellAPI;
|
|
|
3917
3988
|
exports.SpacesAPI = SpacesAPI;
|
|
3918
3989
|
exports.TABLE_SEPARATOR = TABLE_SEPARATOR;
|
|
3919
3990
|
exports.TAURI_COMMANDS = TAURI_COMMANDS;
|
|
3991
|
+
exports.TabAPI = TabAPI;
|
|
3920
3992
|
exports.WebAPI = WebAPI;
|
|
3921
3993
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
3922
3994
|
exports.base58btcDecode = base58btcDecode;
|
|
@@ -3951,7 +4023,6 @@ exports.generateSpaceKey = generateSpaceKey;
|
|
|
3951
4023
|
exports.generateUserKeypairAsync = generateUserKeypairAsync;
|
|
3952
4024
|
exports.generateVaultKey = generateVaultKey;
|
|
3953
4025
|
exports.getTableName = getTableName;
|
|
3954
|
-
exports.hexToBytes = hexToBytes;
|
|
3955
4026
|
exports.importPrivateKeyAsync = importPrivateKeyAsync;
|
|
3956
4027
|
exports.importPrivateKeyForKeyAgreementAsync = importPrivateKeyForKeyAgreementAsync;
|
|
3957
4028
|
exports.importPublicKeyAsync = importPublicKeyAsync;
|
|
@@ -3973,10 +4044,8 @@ exports.signClaimPresentationAsync = signClaimPresentationAsync;
|
|
|
3973
4044
|
exports.signRecordAsync = signRecordAsync;
|
|
3974
4045
|
exports.signSpaceChallengeAsync = signSpaceChallengeAsync;
|
|
3975
4046
|
exports.signWithPasskeyAsync = signWithPasskeyAsync;
|
|
3976
|
-
exports.sortObjectKeysRecursively = sortObjectKeysRecursively;
|
|
3977
4047
|
exports.unwrapKey = unwrapKey;
|
|
3978
4048
|
exports.verifyClaimPresentationAsync = verifyClaimPresentationAsync;
|
|
3979
|
-
exports.verifyExtensionSignature = verifyExtensionSignature;
|
|
3980
4049
|
exports.verifyRecordSignatureAsync = verifyRecordSignatureAsync;
|
|
3981
4050
|
exports.verifySpaceChallengeAsync = verifySpaceChallengeAsync;
|
|
3982
4051
|
exports.verifyWithPasskeyAsync = verifyWithPasskeyAsync;
|