@haex-space/vault-sdk 3.1.0 → 3.2.2
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/{client-C0DPNG62.d.mts → client-GeColu97.d.mts} +263 -2
- package/dist/{client-B_B6rLIw.d.ts → client-z1jTcuQE.d.ts} +263 -2
- package/dist/index.d.mts +76 -6
- package/dist/index.d.ts +76 -6
- package/dist/index.js +244 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +241 -48
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/nuxt.js +16 -6
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +16 -6
- 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 +237 -46
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +237 -46
- 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 +237 -50
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +237 -50
- 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 +237 -46
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +237 -46
- package/dist/svelte.mjs.map +1 -1
- package/dist/{types-DmCSegdY.d.mts → types-CDMBvvjl.d.mts} +2 -0
- package/dist/{types-DmCSegdY.d.ts → types-CDMBvvjl.d.ts} +2 -0
- package/dist/vite.js +15 -5
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +15 -5
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +237 -46
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +237 -46
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1047,6 +1047,40 @@ var SHELL_COMMANDS = {
|
|
|
1047
1047
|
close: "extension_shell_close"
|
|
1048
1048
|
};
|
|
1049
1049
|
|
|
1050
|
+
// src/commands/passwords.ts
|
|
1051
|
+
var PASSWORD_COMMANDS = {
|
|
1052
|
+
/** List items (no secrets) within the extension's tag scope */
|
|
1053
|
+
list: "extension_password_list",
|
|
1054
|
+
/** Read full item including secrets, by id */
|
|
1055
|
+
read: "extension_password_read",
|
|
1056
|
+
/** Create item — must include >=1 tag in scope */
|
|
1057
|
+
create: "extension_password_create",
|
|
1058
|
+
/** Update item — keeps >=1 tag in scope */
|
|
1059
|
+
update: "extension_password_update",
|
|
1060
|
+
/** Delete item — must be in scope */
|
|
1061
|
+
delete: "extension_password_delete"
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
// src/commands/mail.ts
|
|
1065
|
+
var MAIL_COMMANDS = {
|
|
1066
|
+
/** LIST mailboxes + optional STATUS counts */
|
|
1067
|
+
listMailboxes: "extension_mail_list_mailboxes",
|
|
1068
|
+
/** Lightweight envelope fetch for list views */
|
|
1069
|
+
fetchEnvelopes: "extension_mail_fetch_envelopes",
|
|
1070
|
+
/** Full message fetch (envelope + body + attachment metadata) */
|
|
1071
|
+
fetchMessage: "extension_mail_fetch_message",
|
|
1072
|
+
/** Set or unset IMAP flags on a UID set */
|
|
1073
|
+
setFlags: "extension_mail_set_flags",
|
|
1074
|
+
/** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
|
|
1075
|
+
moveMessages: "extension_mail_move_messages",
|
|
1076
|
+
/** APPEND a base64-encoded RFC822 message into a mailbox */
|
|
1077
|
+
appendMessage: "extension_mail_append_message",
|
|
1078
|
+
/** SMTP send. Returns the assigned Message-ID. */
|
|
1079
|
+
sendMessage: "extension_mail_send_message",
|
|
1080
|
+
/** Build RFC822 bytes without sending (for Drafts via APPEND) */
|
|
1081
|
+
buildRfc822: "extension_mail_build_rfc822"
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1050
1084
|
// src/commands/index.ts
|
|
1051
1085
|
var TAURI_COMMANDS = {
|
|
1052
1086
|
database: DATABASE_COMMANDS,
|
|
@@ -1059,7 +1093,9 @@ var TAURI_COMMANDS = {
|
|
|
1059
1093
|
remoteStorage: REMOTE_STORAGE_COMMANDS,
|
|
1060
1094
|
localsend: LOCALSEND_COMMANDS,
|
|
1061
1095
|
spaces: SPACE_COMMANDS,
|
|
1062
|
-
shell: SHELL_COMMANDS
|
|
1096
|
+
shell: SHELL_COMMANDS,
|
|
1097
|
+
passwords: PASSWORD_COMMANDS,
|
|
1098
|
+
mail: MAIL_COMMANDS
|
|
1063
1099
|
};
|
|
1064
1100
|
|
|
1065
1101
|
// src/api/storage.ts
|
|
@@ -1085,6 +1121,12 @@ var StorageAPI = class {
|
|
|
1085
1121
|
};
|
|
1086
1122
|
|
|
1087
1123
|
// src/api/database.ts
|
|
1124
|
+
function quoteIdent(identifier) {
|
|
1125
|
+
if (identifier.startsWith('"') && identifier.endsWith('"')) {
|
|
1126
|
+
return identifier;
|
|
1127
|
+
}
|
|
1128
|
+
return `"${identifier.replace(/"/g, '""')}"`;
|
|
1129
|
+
}
|
|
1088
1130
|
var DatabaseAPI = class {
|
|
1089
1131
|
constructor(client) {
|
|
1090
1132
|
this.client = client;
|
|
@@ -1115,11 +1157,11 @@ var DatabaseAPI = class {
|
|
|
1115
1157
|
});
|
|
1116
1158
|
}
|
|
1117
1159
|
async createTable(tableName, columns) {
|
|
1118
|
-
const query = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns})`;
|
|
1160
|
+
const query = `CREATE TABLE IF NOT EXISTS ${quoteIdent(tableName)} (${columns})`;
|
|
1119
1161
|
await this.execute(query);
|
|
1120
1162
|
}
|
|
1121
1163
|
async dropTable(tableName) {
|
|
1122
|
-
const query = `DROP TABLE IF EXISTS ${tableName}`;
|
|
1164
|
+
const query = `DROP TABLE IF EXISTS ${quoteIdent(tableName)}`;
|
|
1123
1165
|
await this.execute(query);
|
|
1124
1166
|
}
|
|
1125
1167
|
/**
|
|
@@ -1148,18 +1190,17 @@ var DatabaseAPI = class {
|
|
|
1148
1190
|
async insert(tableName, data) {
|
|
1149
1191
|
const keys = Object.keys(data);
|
|
1150
1192
|
const values = Object.values(data);
|
|
1193
|
+
const quotedCols = keys.map(quoteIdent).join(", ");
|
|
1151
1194
|
const placeholders = keys.map(() => "?").join(", ");
|
|
1152
|
-
const query = `INSERT INTO ${tableName} (${
|
|
1153
|
-
", "
|
|
1154
|
-
)}) VALUES (${placeholders})`;
|
|
1195
|
+
const query = `INSERT INTO ${quoteIdent(tableName)} (${quotedCols}) VALUES (${placeholders})`;
|
|
1155
1196
|
const result = await this.execute(query, values);
|
|
1156
1197
|
return result.lastInsertId ?? -1;
|
|
1157
1198
|
}
|
|
1158
1199
|
async update(tableName, data, where, whereParams) {
|
|
1159
1200
|
const keys = Object.keys(data);
|
|
1160
1201
|
const values = Object.values(data);
|
|
1161
|
-
const setClause = keys.map((key) => `${key} = ?`).join(", ");
|
|
1162
|
-
const query = `UPDATE ${tableName} SET ${setClause} WHERE ${where}`;
|
|
1202
|
+
const setClause = keys.map((key) => `${quoteIdent(key)} = ?`).join(", ");
|
|
1203
|
+
const query = `UPDATE ${quoteIdent(tableName)} SET ${setClause} WHERE ${where}`;
|
|
1163
1204
|
const result = await this.execute(query, [
|
|
1164
1205
|
...values,
|
|
1165
1206
|
...whereParams || []
|
|
@@ -1167,12 +1208,12 @@ var DatabaseAPI = class {
|
|
|
1167
1208
|
return result.rowsAffected;
|
|
1168
1209
|
}
|
|
1169
1210
|
async delete(tableName, where, whereParams) {
|
|
1170
|
-
const query = `DELETE FROM ${tableName} WHERE ${where}`;
|
|
1211
|
+
const query = `DELETE FROM ${quoteIdent(tableName)} WHERE ${where}`;
|
|
1171
1212
|
const result = await this.execute(query, whereParams);
|
|
1172
1213
|
return result.rowsAffected;
|
|
1173
1214
|
}
|
|
1174
1215
|
async count(tableName, where, whereParams) {
|
|
1175
|
-
const query = where ? `SELECT COUNT(*) as count FROM ${tableName} WHERE ${where}` : `SELECT COUNT(*) as count FROM ${tableName}`;
|
|
1216
|
+
const query = where ? `SELECT COUNT(*) as count FROM ${quoteIdent(tableName)} WHERE ${where}` : `SELECT COUNT(*) as count FROM ${quoteIdent(tableName)}`;
|
|
1176
1217
|
const result = await this.queryOne(query, whereParams);
|
|
1177
1218
|
return result?.count ?? 0;
|
|
1178
1219
|
}
|
|
@@ -2003,6 +2044,140 @@ var ShellAPI = class {
|
|
|
2003
2044
|
}
|
|
2004
2045
|
};
|
|
2005
2046
|
|
|
2047
|
+
// src/api/passwords.ts
|
|
2048
|
+
var PasswordsAPI = class {
|
|
2049
|
+
constructor(client) {
|
|
2050
|
+
this.client = client;
|
|
2051
|
+
}
|
|
2052
|
+
/** List items in scope — summaries only, no secrets. */
|
|
2053
|
+
async listAsync() {
|
|
2054
|
+
return this.client.request(
|
|
2055
|
+
PASSWORD_COMMANDS.list,
|
|
2056
|
+
{}
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2059
|
+
/** Read a single item by id with full secrets. */
|
|
2060
|
+
async readAsync(itemId) {
|
|
2061
|
+
return this.client.request(PASSWORD_COMMANDS.read, {
|
|
2062
|
+
itemId
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Create a new password item. `input.tags` must contain at least one
|
|
2067
|
+
* tag within the extension's permission scope, otherwise the write
|
|
2068
|
+
* is rejected as a security violation.
|
|
2069
|
+
*
|
|
2070
|
+
* Returns the new item id.
|
|
2071
|
+
*/
|
|
2072
|
+
async createAsync(input) {
|
|
2073
|
+
return this.client.request(PASSWORD_COMMANDS.create, { input });
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Update an existing item. The item must already be in scope, and
|
|
2077
|
+
* the new tag set must keep at least one tag in scope (extensions
|
|
2078
|
+
* cannot orphan an item out of their own reach).
|
|
2079
|
+
*/
|
|
2080
|
+
async updateAsync(itemId, input) {
|
|
2081
|
+
return this.client.request(PASSWORD_COMMANDS.update, {
|
|
2082
|
+
itemId,
|
|
2083
|
+
input
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
/** Delete an item by id. Item must be in scope. */
|
|
2087
|
+
async deleteAsync(itemId) {
|
|
2088
|
+
return this.client.request(PASSWORD_COMMANDS.delete, { itemId });
|
|
2089
|
+
}
|
|
2090
|
+
};
|
|
2091
|
+
|
|
2092
|
+
// src/api/mail.ts
|
|
2093
|
+
var MailAPI = class {
|
|
2094
|
+
constructor(client) {
|
|
2095
|
+
this.client = client;
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* LIST mailboxes for an IMAP account. Pass `includeStatus=true` for
|
|
2099
|
+
* EXISTS/UNSEEN/UIDVALIDITY/UIDNEXT per box (one extra round-trip
|
|
2100
|
+
* per mailbox — fine for typical accounts, expensive for large
|
|
2101
|
+
* trees).
|
|
2102
|
+
*/
|
|
2103
|
+
async listMailboxesAsync(imap, options = {}) {
|
|
2104
|
+
return this.client.request(MAIL_COMMANDS.listMailboxes, {
|
|
2105
|
+
imap,
|
|
2106
|
+
reference: options.reference,
|
|
2107
|
+
pattern: options.pattern,
|
|
2108
|
+
includeStatus: options.includeStatus
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
/** Fetch lightweight envelopes for a mailbox + range (for list views). */
|
|
2112
|
+
async fetchEnvelopesAsync(imap, mailbox, range) {
|
|
2113
|
+
return this.client.request(
|
|
2114
|
+
MAIL_COMMANDS.fetchEnvelopes,
|
|
2115
|
+
{ imap, mailbox, range }
|
|
2116
|
+
);
|
|
2117
|
+
}
|
|
2118
|
+
/** Fetch a full message (envelope + body + attachment metadata) by UID. */
|
|
2119
|
+
async fetchMessageAsync(imap, mailbox, uid) {
|
|
2120
|
+
return this.client.request(MAIL_COMMANDS.fetchMessage, {
|
|
2121
|
+
imap,
|
|
2122
|
+
mailbox,
|
|
2123
|
+
uid
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
/**
|
|
2127
|
+
* Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
|
|
2128
|
+
* mark messages as read; `add=false` removes the flag(s).
|
|
2129
|
+
*/
|
|
2130
|
+
async setFlagsAsync(imap, mailbox, uids, flags, add) {
|
|
2131
|
+
return this.client.request(MAIL_COMMANDS.setFlags, {
|
|
2132
|
+
imap,
|
|
2133
|
+
mailbox,
|
|
2134
|
+
uids,
|
|
2135
|
+
flags,
|
|
2136
|
+
add
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
/** Move messages between mailboxes. Falls back to COPY+EXPUNGE on servers without MOVE. */
|
|
2140
|
+
async moveMessagesAsync(imap, sourceMailbox, destinationMailbox, uids) {
|
|
2141
|
+
return this.client.request(MAIL_COMMANDS.moveMessages, {
|
|
2142
|
+
imap,
|
|
2143
|
+
sourceMailbox,
|
|
2144
|
+
destinationMailbox,
|
|
2145
|
+
uids
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
/**
|
|
2149
|
+
* APPEND a base64-encoded RFC822 message into a mailbox. Combine
|
|
2150
|
+
* with `buildRfc822Async` to save drafts, or with the bytes returned
|
|
2151
|
+
* after `sendMessageAsync` to mirror the sent copy into "Sent".
|
|
2152
|
+
*/
|
|
2153
|
+
async appendMessageAsync(imap, mailbox, rfc822Base64, flags) {
|
|
2154
|
+
return this.client.request(MAIL_COMMANDS.appendMessage, {
|
|
2155
|
+
imap,
|
|
2156
|
+
mailbox,
|
|
2157
|
+
rfc822Base64,
|
|
2158
|
+
flags
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
/** Send a message via SMTP. Returns the assigned Message-ID (no angle brackets). */
|
|
2162
|
+
async sendMessageAsync(smtp, message) {
|
|
2163
|
+
return this.client.request(MAIL_COMMANDS.sendMessage, {
|
|
2164
|
+
smtp,
|
|
2165
|
+
message
|
|
2166
|
+
});
|
|
2167
|
+
}
|
|
2168
|
+
/**
|
|
2169
|
+
* Build RFC822 bytes for a message without sending — useful for
|
|
2170
|
+
* drafts that get APPENDed to a "Drafts" folder. Permission-wise
|
|
2171
|
+
* this is a fetch operation (no SMTP host involved).
|
|
2172
|
+
*/
|
|
2173
|
+
async buildRfc822Async(imapHost, message) {
|
|
2174
|
+
return this.client.request(MAIL_COMMANDS.buildRfc822, {
|
|
2175
|
+
imapHost,
|
|
2176
|
+
message
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
|
|
2006
2181
|
// src/client/tableName.ts
|
|
2007
2182
|
function validatePublicKey(publicKey) {
|
|
2008
2183
|
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
@@ -2090,6 +2265,10 @@ function parseTableName(fullTableName) {
|
|
|
2090
2265
|
|
|
2091
2266
|
// src/client/init.ts
|
|
2092
2267
|
var PORT_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
2268
|
+
function getCurrentWebviewLabel() {
|
|
2269
|
+
const internals = window.__TAURI_INTERNALS__;
|
|
2270
|
+
return internals?.metadata?.currentWebview?.label;
|
|
2271
|
+
}
|
|
2093
2272
|
function isInIframe() {
|
|
2094
2273
|
return window.self !== window.top;
|
|
2095
2274
|
}
|
|
@@ -2118,6 +2297,13 @@ async function initNativeMode(ctx, log, onEvent, onContextChange) {
|
|
|
2118
2297
|
}
|
|
2119
2298
|
async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
2120
2299
|
const { listen } = getTauriEvent();
|
|
2300
|
+
const webviewLabel = getCurrentWebviewLabel();
|
|
2301
|
+
const listenOptions = webviewLabel ? { target: webviewLabel } : void 0;
|
|
2302
|
+
if (!webviewLabel) {
|
|
2303
|
+
log(
|
|
2304
|
+
"WARNING: could not read __TAURI_INTERNALS__.metadata.currentWebview.label \u2014 registering listeners without a target. Label-scoped emits from the host will not be delivered until the metadata is available."
|
|
2305
|
+
);
|
|
2306
|
+
}
|
|
2121
2307
|
log("Setting up Tauri event listener for:", HAEXTENSION_EVENTS.CONTEXT_CHANGED);
|
|
2122
2308
|
try {
|
|
2123
2309
|
await listen(HAEXTENSION_EVENTS.CONTEXT_CHANGED, (event) => {
|
|
@@ -2135,7 +2321,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2135
2321
|
} else {
|
|
2136
2322
|
log("Event received but no context in payload:", event);
|
|
2137
2323
|
}
|
|
2138
|
-
});
|
|
2324
|
+
}, listenOptions);
|
|
2139
2325
|
log("Context change listener registered successfully");
|
|
2140
2326
|
} catch (error) {
|
|
2141
2327
|
log("Failed to setup context change listener:", error);
|
|
@@ -2153,7 +2339,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2153
2339
|
} else {
|
|
2154
2340
|
log("External request event has no payload!");
|
|
2155
2341
|
}
|
|
2156
|
-
});
|
|
2342
|
+
}, listenOptions);
|
|
2157
2343
|
log("External request listener registered successfully");
|
|
2158
2344
|
} catch (error) {
|
|
2159
2345
|
log("Failed to setup external request listener:", error);
|
|
@@ -2171,7 +2357,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2171
2357
|
} else {
|
|
2172
2358
|
log("AI action request event has no payload!");
|
|
2173
2359
|
}
|
|
2174
|
-
});
|
|
2360
|
+
}, listenOptions);
|
|
2175
2361
|
log("AI action request listener registered successfully");
|
|
2176
2362
|
} catch (error) {
|
|
2177
2363
|
log("Failed to setup AI action request listener:", error);
|
|
@@ -2190,7 +2376,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2190
2376
|
timestamp: Date.now()
|
|
2191
2377
|
});
|
|
2192
2378
|
}
|
|
2193
|
-
});
|
|
2379
|
+
}, listenOptions);
|
|
2194
2380
|
log("File change listener registered successfully");
|
|
2195
2381
|
} catch (error) {
|
|
2196
2382
|
log("Failed to setup file change listener:", error);
|
|
@@ -2207,14 +2393,14 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2207
2393
|
timestamp: Date.now()
|
|
2208
2394
|
});
|
|
2209
2395
|
}
|
|
2210
|
-
});
|
|
2396
|
+
}, listenOptions);
|
|
2211
2397
|
log("Sync tables updated listener registered successfully");
|
|
2212
2398
|
} catch (error) {
|
|
2213
2399
|
log("Failed to setup sync tables updated listener:", error);
|
|
2214
2400
|
}
|
|
2215
2401
|
log("Setting up LocalSend event listeners");
|
|
2216
2402
|
try {
|
|
2217
|
-
await setupLocalSendEventListeners(log, onEvent);
|
|
2403
|
+
await setupLocalSendEventListeners(log, onEvent, listenOptions);
|
|
2218
2404
|
log("LocalSend event listeners setup complete");
|
|
2219
2405
|
} catch (error) {
|
|
2220
2406
|
log("Failed to setup LocalSend event listeners:", error);
|
|
@@ -2231,7 +2417,7 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2231
2417
|
data: payload.data
|
|
2232
2418
|
});
|
|
2233
2419
|
}
|
|
2234
|
-
});
|
|
2420
|
+
}, listenOptions);
|
|
2235
2421
|
log("Shell output listener registered");
|
|
2236
2422
|
await listen(SHELL_EVENTS.EXIT, (event) => {
|
|
2237
2423
|
if (event.payload) {
|
|
@@ -2243,13 +2429,13 @@ async function setupTauriEventListeners(ctx, log, onEvent, onContextChange) {
|
|
|
2243
2429
|
exitCode: payload.exitCode
|
|
2244
2430
|
});
|
|
2245
2431
|
}
|
|
2246
|
-
});
|
|
2432
|
+
}, listenOptions);
|
|
2247
2433
|
log("Shell exit listener registered");
|
|
2248
2434
|
} catch (error) {
|
|
2249
2435
|
log("Failed to setup Shell event listeners:", error);
|
|
2250
2436
|
}
|
|
2251
2437
|
}
|
|
2252
|
-
async function setupLocalSendEventListeners(log, onEvent) {
|
|
2438
|
+
async function setupLocalSendEventListeners(log, onEvent, listenOptions) {
|
|
2253
2439
|
const { listen } = getTauriEvent();
|
|
2254
2440
|
try {
|
|
2255
2441
|
await listen(LOCALSEND_EVENTS.deviceDiscovered, (event) => {
|
|
@@ -2261,7 +2447,7 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2261
2447
|
timestamp: Date.now()
|
|
2262
2448
|
});
|
|
2263
2449
|
}
|
|
2264
|
-
});
|
|
2450
|
+
}, listenOptions);
|
|
2265
2451
|
log("LocalSend device discovered listener registered");
|
|
2266
2452
|
} catch (error) {
|
|
2267
2453
|
log("Failed to setup LocalSend device discovered listener:", error);
|
|
@@ -2276,7 +2462,7 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2276
2462
|
timestamp: Date.now()
|
|
2277
2463
|
});
|
|
2278
2464
|
}
|
|
2279
|
-
});
|
|
2465
|
+
}, listenOptions);
|
|
2280
2466
|
log("LocalSend device lost listener registered");
|
|
2281
2467
|
} catch (error) {
|
|
2282
2468
|
log("Failed to setup LocalSend device lost listener:", error);
|
|
@@ -2291,7 +2477,7 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2291
2477
|
timestamp: Date.now()
|
|
2292
2478
|
});
|
|
2293
2479
|
}
|
|
2294
|
-
});
|
|
2480
|
+
}, listenOptions);
|
|
2295
2481
|
log("LocalSend transfer request listener registered");
|
|
2296
2482
|
} catch (error) {
|
|
2297
2483
|
log("Failed to setup LocalSend transfer request listener:", error);
|
|
@@ -2306,7 +2492,7 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2306
2492
|
timestamp: Date.now()
|
|
2307
2493
|
});
|
|
2308
2494
|
}
|
|
2309
|
-
});
|
|
2495
|
+
}, listenOptions);
|
|
2310
2496
|
log("LocalSend transfer progress listener registered");
|
|
2311
2497
|
} catch (error) {
|
|
2312
2498
|
log("Failed to setup LocalSend transfer progress listener:", error);
|
|
@@ -2321,7 +2507,7 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2321
2507
|
timestamp: Date.now()
|
|
2322
2508
|
});
|
|
2323
2509
|
}
|
|
2324
|
-
});
|
|
2510
|
+
}, listenOptions);
|
|
2325
2511
|
log("LocalSend transfer complete listener registered");
|
|
2326
2512
|
} catch (error) {
|
|
2327
2513
|
log("Failed to setup LocalSend transfer complete listener:", error);
|
|
@@ -2336,13 +2522,13 @@ async function setupLocalSendEventListeners(log, onEvent) {
|
|
|
2336
2522
|
timestamp: Date.now()
|
|
2337
2523
|
});
|
|
2338
2524
|
}
|
|
2339
|
-
});
|
|
2525
|
+
}, listenOptions);
|
|
2340
2526
|
log("LocalSend transfer failed listener registered");
|
|
2341
2527
|
} catch (error) {
|
|
2342
2528
|
log("Failed to setup LocalSend transfer failed listener:", error);
|
|
2343
2529
|
}
|
|
2344
2530
|
}
|
|
2345
|
-
async function initIframeMode(ctx, log, messageHandler
|
|
2531
|
+
async function initIframeMode(ctx, log, messageHandler) {
|
|
2346
2532
|
if (!isInIframe()) {
|
|
2347
2533
|
throw new HaexVaultSdkError("NOT_IN_IFRAME" /* NOT_IN_IFRAME */, "errors.not_in_iframe");
|
|
2348
2534
|
}
|
|
@@ -2359,15 +2545,12 @@ async function initIframeMode(ctx, log, messageHandler, request) {
|
|
|
2359
2545
|
publicKey: ctx.config.manifest.publicKey,
|
|
2360
2546
|
name: ctx.config.manifest.name,
|
|
2361
2547
|
version: ctx.config.manifest.version,
|
|
2362
|
-
displayName: ctx.config.manifest.name
|
|
2548
|
+
displayName: ctx.config.manifest.displayName ?? ctx.config.manifest.name
|
|
2363
2549
|
};
|
|
2364
2550
|
log("Extension info loaded from manifest:", ctx.state.extensionInfo);
|
|
2365
2551
|
}
|
|
2366
2552
|
sendDebugInfo(ctx.config);
|
|
2367
|
-
|
|
2368
|
-
ctx.state.context = context;
|
|
2369
|
-
log("Application context received:", context);
|
|
2370
|
-
return { context, port };
|
|
2553
|
+
return port;
|
|
2371
2554
|
}
|
|
2372
2555
|
function waitForHostPortAsync(log) {
|
|
2373
2556
|
return new Promise((resolve, reject) => {
|
|
@@ -2550,11 +2733,10 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
|
|
|
2550
2733
|
emitEvent(event, log, eventListeners);
|
|
2551
2734
|
}
|
|
2552
2735
|
function emitEvent(event, log, eventListeners) {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
log("Event received:", event);
|
|
2736
|
+
log("emitEvent called with:", event.type, event);
|
|
2737
|
+
log("Registered event types:", Array.from(eventListeners.keys()));
|
|
2556
2738
|
const listeners = eventListeners.get(event.type);
|
|
2557
|
-
|
|
2739
|
+
log("Listeners for", event.type, ":", listeners?.size ?? 0);
|
|
2558
2740
|
if (listeners) {
|
|
2559
2741
|
listeners.forEach((callback) => callback(event));
|
|
2560
2742
|
}
|
|
@@ -2651,9 +2833,9 @@ function registerExternalHandler(action, handler, handlers, log) {
|
|
|
2651
2833
|
};
|
|
2652
2834
|
}
|
|
2653
2835
|
async function handleExternalRequest(request, handlers, respond, log) {
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2836
|
+
log("handleExternalRequest called");
|
|
2837
|
+
log("Request:", request);
|
|
2838
|
+
log("Available handlers:", Array.from(handlers.keys()));
|
|
2657
2839
|
log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
2658
2840
|
const handler = handlers.get(request.action);
|
|
2659
2841
|
if (!handler) {
|
|
@@ -2679,7 +2861,6 @@ async function handleExternalRequest(request, handlers, respond, log) {
|
|
|
2679
2861
|
}
|
|
2680
2862
|
}
|
|
2681
2863
|
async function respondToExternalRequest(response, request) {
|
|
2682
|
-
console.log("[SDK Debug] respondToExternalRequest called with:", JSON.stringify(response, null, 2));
|
|
2683
2864
|
await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
|
|
2684
2865
|
}
|
|
2685
2866
|
|
|
@@ -2737,11 +2918,17 @@ var HaexVaultSdk = class {
|
|
|
2737
2918
|
this.localsend = new LocalSendAPI(this);
|
|
2738
2919
|
this.spaces = new SpacesAPI(this);
|
|
2739
2920
|
this.shell = new ShellAPI(this);
|
|
2921
|
+
this.passwords = new PasswordsAPI(this);
|
|
2922
|
+
this.mail = new MailAPI(this);
|
|
2740
2923
|
installConsoleForwarding(this.config.debug);
|
|
2741
|
-
this.readyPromise = new Promise((resolve) => {
|
|
2924
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
2742
2925
|
this.resolveReady = resolve;
|
|
2926
|
+
this.rejectReady = reject;
|
|
2927
|
+
});
|
|
2928
|
+
this.init().catch((error) => {
|
|
2929
|
+
this.log("Init failed:", error);
|
|
2930
|
+
this.rejectReady(error);
|
|
2743
2931
|
});
|
|
2744
|
-
this.init();
|
|
2745
2932
|
}
|
|
2746
2933
|
// ==========================================================================
|
|
2747
2934
|
// Lifecycle
|
|
@@ -2769,9 +2956,14 @@ var HaexVaultSdk = class {
|
|
|
2769
2956
|
return this.setupPromise;
|
|
2770
2957
|
}
|
|
2771
2958
|
destroy() {
|
|
2772
|
-
if (this.messageHandler) {
|
|
2773
|
-
|
|
2959
|
+
if (this.messageHandler && this.hostPort) {
|
|
2960
|
+
this.hostPort.removeEventListener("message", this.messageHandler);
|
|
2774
2961
|
}
|
|
2962
|
+
if (this.hostPort) {
|
|
2963
|
+
this.hostPort.close();
|
|
2964
|
+
this.hostPort = null;
|
|
2965
|
+
}
|
|
2966
|
+
this.messageHandler = null;
|
|
2775
2967
|
this.pendingRequests.forEach(({ timeout }) => clearTimeout(timeout));
|
|
2776
2968
|
this.pendingRequests.clear();
|
|
2777
2969
|
this.eventListeners.clear();
|
|
@@ -2961,7 +3153,7 @@ var HaexVaultSdk = class {
|
|
|
2961
3153
|
() => this._extensionInfo,
|
|
2962
3154
|
this.handleEvent.bind(this)
|
|
2963
3155
|
);
|
|
2964
|
-
const
|
|
3156
|
+
const port = await initIframeMode(
|
|
2965
3157
|
{
|
|
2966
3158
|
config: this.config,
|
|
2967
3159
|
state: {
|
|
@@ -2990,8 +3182,7 @@ var HaexVaultSdk = class {
|
|
|
2990
3182
|
}
|
|
2991
3183
|
},
|
|
2992
3184
|
this.log.bind(this),
|
|
2993
|
-
this.messageHandler
|
|
2994
|
-
this.request.bind(this)
|
|
3185
|
+
this.messageHandler
|
|
2995
3186
|
);
|
|
2996
3187
|
this.hostPort = port;
|
|
2997
3188
|
if (this.config.manifest) {
|
|
@@ -2999,10 +3190,12 @@ var HaexVaultSdk = class {
|
|
|
2999
3190
|
publicKey: this.config.manifest.publicKey,
|
|
3000
3191
|
name: this.config.manifest.name,
|
|
3001
3192
|
version: this.config.manifest.version,
|
|
3002
|
-
displayName: this.config.manifest.name
|
|
3193
|
+
displayName: this.config.manifest.displayName ?? this.config.manifest.name
|
|
3003
3194
|
};
|
|
3004
3195
|
this.notifySubscribersInternal();
|
|
3005
3196
|
}
|
|
3197
|
+
const context = await this.request(EXTENSION_COMMANDS.getContext);
|
|
3198
|
+
this.log("Application context received:", context);
|
|
3006
3199
|
this._context = context;
|
|
3007
3200
|
this.isNativeWindow = false;
|
|
3008
3201
|
this.initialized = true;
|
|
@@ -3654,6 +3847,6 @@ function createHaexVaultSdk(config = {}) {
|
|
|
3654
3847
|
return new HaexVaultSdk(config);
|
|
3655
3848
|
}
|
|
3656
3849
|
|
|
3657
|
-
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, 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 };
|
|
3850
|
+
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 };
|
|
3658
3851
|
//# sourceMappingURL=index.mjs.map
|
|
3659
3852
|
//# sourceMappingURL=index.mjs.map
|