@haex-space/vault-sdk 3.1.0 → 3.2.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/{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 +212 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +209 -25
- 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 +205 -23
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +205 -23
- 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 +205 -27
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +205 -27
- 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 +205 -23
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +205 -23
- 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 +205 -23
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +205 -23
- package/dist/vue.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -648,6 +648,40 @@ var SHELL_COMMANDS = {
|
|
|
648
648
|
close: "extension_shell_close"
|
|
649
649
|
};
|
|
650
650
|
|
|
651
|
+
// src/commands/passwords.ts
|
|
652
|
+
var PASSWORD_COMMANDS = {
|
|
653
|
+
/** List items (no secrets) within the extension's tag scope */
|
|
654
|
+
list: "extension_password_list",
|
|
655
|
+
/** Read full item including secrets, by id */
|
|
656
|
+
read: "extension_password_read",
|
|
657
|
+
/** Create item — must include >=1 tag in scope */
|
|
658
|
+
create: "extension_password_create",
|
|
659
|
+
/** Update item — keeps >=1 tag in scope */
|
|
660
|
+
update: "extension_password_update",
|
|
661
|
+
/** Delete item — must be in scope */
|
|
662
|
+
delete: "extension_password_delete"
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
// src/commands/mail.ts
|
|
666
|
+
var MAIL_COMMANDS = {
|
|
667
|
+
/** LIST mailboxes + optional STATUS counts */
|
|
668
|
+
listMailboxes: "extension_mail_list_mailboxes",
|
|
669
|
+
/** Lightweight envelope fetch for list views */
|
|
670
|
+
fetchEnvelopes: "extension_mail_fetch_envelopes",
|
|
671
|
+
/** Full message fetch (envelope + body + attachment metadata) */
|
|
672
|
+
fetchMessage: "extension_mail_fetch_message",
|
|
673
|
+
/** Set or unset IMAP flags on a UID set */
|
|
674
|
+
setFlags: "extension_mail_set_flags",
|
|
675
|
+
/** MOVE messages between mailboxes (COPY+EXPUNGE fallback) */
|
|
676
|
+
moveMessages: "extension_mail_move_messages",
|
|
677
|
+
/** APPEND a base64-encoded RFC822 message into a mailbox */
|
|
678
|
+
appendMessage: "extension_mail_append_message",
|
|
679
|
+
/** SMTP send. Returns the assigned Message-ID. */
|
|
680
|
+
sendMessage: "extension_mail_send_message",
|
|
681
|
+
/** Build RFC822 bytes without sending (for Drafts via APPEND) */
|
|
682
|
+
buildRfc822: "extension_mail_build_rfc822"
|
|
683
|
+
};
|
|
684
|
+
|
|
651
685
|
// src/api/storage.ts
|
|
652
686
|
var StorageAPI = class {
|
|
653
687
|
constructor(client) {
|
|
@@ -671,6 +705,12 @@ var StorageAPI = class {
|
|
|
671
705
|
};
|
|
672
706
|
|
|
673
707
|
// src/api/database.ts
|
|
708
|
+
function quoteIdent(identifier) {
|
|
709
|
+
if (identifier.startsWith('"') && identifier.endsWith('"')) {
|
|
710
|
+
return identifier;
|
|
711
|
+
}
|
|
712
|
+
return `"${identifier.replace(/"/g, '""')}"`;
|
|
713
|
+
}
|
|
674
714
|
var DatabaseAPI = class {
|
|
675
715
|
constructor(client) {
|
|
676
716
|
this.client = client;
|
|
@@ -701,11 +741,11 @@ var DatabaseAPI = class {
|
|
|
701
741
|
});
|
|
702
742
|
}
|
|
703
743
|
async createTable(tableName, columns) {
|
|
704
|
-
const query = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns})`;
|
|
744
|
+
const query = `CREATE TABLE IF NOT EXISTS ${quoteIdent(tableName)} (${columns})`;
|
|
705
745
|
await this.execute(query);
|
|
706
746
|
}
|
|
707
747
|
async dropTable(tableName) {
|
|
708
|
-
const query = `DROP TABLE IF EXISTS ${tableName}`;
|
|
748
|
+
const query = `DROP TABLE IF EXISTS ${quoteIdent(tableName)}`;
|
|
709
749
|
await this.execute(query);
|
|
710
750
|
}
|
|
711
751
|
/**
|
|
@@ -734,18 +774,17 @@ var DatabaseAPI = class {
|
|
|
734
774
|
async insert(tableName, data) {
|
|
735
775
|
const keys = Object.keys(data);
|
|
736
776
|
const values = Object.values(data);
|
|
777
|
+
const quotedCols = keys.map(quoteIdent).join(", ");
|
|
737
778
|
const placeholders = keys.map(() => "?").join(", ");
|
|
738
|
-
const query = `INSERT INTO ${tableName} (${
|
|
739
|
-
", "
|
|
740
|
-
)}) VALUES (${placeholders})`;
|
|
779
|
+
const query = `INSERT INTO ${quoteIdent(tableName)} (${quotedCols}) VALUES (${placeholders})`;
|
|
741
780
|
const result = await this.execute(query, values);
|
|
742
781
|
return result.lastInsertId ?? -1;
|
|
743
782
|
}
|
|
744
783
|
async update(tableName, data, where, whereParams) {
|
|
745
784
|
const keys = Object.keys(data);
|
|
746
785
|
const values = Object.values(data);
|
|
747
|
-
const setClause = keys.map((key) => `${key} = ?`).join(", ");
|
|
748
|
-
const query = `UPDATE ${tableName} SET ${setClause} WHERE ${where}`;
|
|
786
|
+
const setClause = keys.map((key) => `${quoteIdent(key)} = ?`).join(", ");
|
|
787
|
+
const query = `UPDATE ${quoteIdent(tableName)} SET ${setClause} WHERE ${where}`;
|
|
749
788
|
const result = await this.execute(query, [
|
|
750
789
|
...values,
|
|
751
790
|
...whereParams || []
|
|
@@ -753,12 +792,12 @@ var DatabaseAPI = class {
|
|
|
753
792
|
return result.rowsAffected;
|
|
754
793
|
}
|
|
755
794
|
async delete(tableName, where, whereParams) {
|
|
756
|
-
const query = `DELETE FROM ${tableName} WHERE ${where}`;
|
|
795
|
+
const query = `DELETE FROM ${quoteIdent(tableName)} WHERE ${where}`;
|
|
757
796
|
const result = await this.execute(query, whereParams);
|
|
758
797
|
return result.rowsAffected;
|
|
759
798
|
}
|
|
760
799
|
async count(tableName, where, whereParams) {
|
|
761
|
-
const query = where ? `SELECT COUNT(*) as count FROM ${tableName} WHERE ${where}` : `SELECT COUNT(*) as count FROM ${tableName}`;
|
|
800
|
+
const query = where ? `SELECT COUNT(*) as count FROM ${quoteIdent(tableName)} WHERE ${where}` : `SELECT COUNT(*) as count FROM ${quoteIdent(tableName)}`;
|
|
762
801
|
const result = await this.queryOne(query, whereParams);
|
|
763
802
|
return result?.count ?? 0;
|
|
764
803
|
}
|
|
@@ -1580,6 +1619,140 @@ var ShellAPI = class {
|
|
|
1580
1619
|
}
|
|
1581
1620
|
};
|
|
1582
1621
|
|
|
1622
|
+
// src/api/passwords.ts
|
|
1623
|
+
var PasswordsAPI = class {
|
|
1624
|
+
constructor(client) {
|
|
1625
|
+
this.client = client;
|
|
1626
|
+
}
|
|
1627
|
+
/** List items in scope — summaries only, no secrets. */
|
|
1628
|
+
async listAsync() {
|
|
1629
|
+
return this.client.request(
|
|
1630
|
+
PASSWORD_COMMANDS.list,
|
|
1631
|
+
{}
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
/** Read a single item by id with full secrets. */
|
|
1635
|
+
async readAsync(itemId) {
|
|
1636
|
+
return this.client.request(PASSWORD_COMMANDS.read, {
|
|
1637
|
+
itemId
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Create a new password item. `input.tags` must contain at least one
|
|
1642
|
+
* tag within the extension's permission scope, otherwise the write
|
|
1643
|
+
* is rejected as a security violation.
|
|
1644
|
+
*
|
|
1645
|
+
* Returns the new item id.
|
|
1646
|
+
*/
|
|
1647
|
+
async createAsync(input) {
|
|
1648
|
+
return this.client.request(PASSWORD_COMMANDS.create, { input });
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Update an existing item. The item must already be in scope, and
|
|
1652
|
+
* the new tag set must keep at least one tag in scope (extensions
|
|
1653
|
+
* cannot orphan an item out of their own reach).
|
|
1654
|
+
*/
|
|
1655
|
+
async updateAsync(itemId, input) {
|
|
1656
|
+
return this.client.request(PASSWORD_COMMANDS.update, {
|
|
1657
|
+
itemId,
|
|
1658
|
+
input
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
/** Delete an item by id. Item must be in scope. */
|
|
1662
|
+
async deleteAsync(itemId) {
|
|
1663
|
+
return this.client.request(PASSWORD_COMMANDS.delete, { itemId });
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
// src/api/mail.ts
|
|
1668
|
+
var MailAPI = class {
|
|
1669
|
+
constructor(client) {
|
|
1670
|
+
this.client = client;
|
|
1671
|
+
}
|
|
1672
|
+
/**
|
|
1673
|
+
* LIST mailboxes for an IMAP account. Pass `includeStatus=true` for
|
|
1674
|
+
* EXISTS/UNSEEN/UIDVALIDITY/UIDNEXT per box (one extra round-trip
|
|
1675
|
+
* per mailbox — fine for typical accounts, expensive for large
|
|
1676
|
+
* trees).
|
|
1677
|
+
*/
|
|
1678
|
+
async listMailboxesAsync(imap, options = {}) {
|
|
1679
|
+
return this.client.request(MAIL_COMMANDS.listMailboxes, {
|
|
1680
|
+
imap,
|
|
1681
|
+
reference: options.reference,
|
|
1682
|
+
pattern: options.pattern,
|
|
1683
|
+
includeStatus: options.includeStatus
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
/** Fetch lightweight envelopes for a mailbox + range (for list views). */
|
|
1687
|
+
async fetchEnvelopesAsync(imap, mailbox, range) {
|
|
1688
|
+
return this.client.request(
|
|
1689
|
+
MAIL_COMMANDS.fetchEnvelopes,
|
|
1690
|
+
{ imap, mailbox, range }
|
|
1691
|
+
);
|
|
1692
|
+
}
|
|
1693
|
+
/** Fetch a full message (envelope + body + attachment metadata) by UID. */
|
|
1694
|
+
async fetchMessageAsync(imap, mailbox, uid) {
|
|
1695
|
+
return this.client.request(MAIL_COMMANDS.fetchMessage, {
|
|
1696
|
+
imap,
|
|
1697
|
+
mailbox,
|
|
1698
|
+
uid
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Set or unset IMAP flags. Use `flags=["\\Seen"]` + `add=true` to
|
|
1703
|
+
* mark messages as read; `add=false` removes the flag(s).
|
|
1704
|
+
*/
|
|
1705
|
+
async setFlagsAsync(imap, mailbox, uids, flags, add) {
|
|
1706
|
+
return this.client.request(MAIL_COMMANDS.setFlags, {
|
|
1707
|
+
imap,
|
|
1708
|
+
mailbox,
|
|
1709
|
+
uids,
|
|
1710
|
+
flags,
|
|
1711
|
+
add
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
/** Move messages between mailboxes. Falls back to COPY+EXPUNGE on servers without MOVE. */
|
|
1715
|
+
async moveMessagesAsync(imap, sourceMailbox, destinationMailbox, uids) {
|
|
1716
|
+
return this.client.request(MAIL_COMMANDS.moveMessages, {
|
|
1717
|
+
imap,
|
|
1718
|
+
sourceMailbox,
|
|
1719
|
+
destinationMailbox,
|
|
1720
|
+
uids
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* APPEND a base64-encoded RFC822 message into a mailbox. Combine
|
|
1725
|
+
* with `buildRfc822Async` to save drafts, or with the bytes returned
|
|
1726
|
+
* after `sendMessageAsync` to mirror the sent copy into "Sent".
|
|
1727
|
+
*/
|
|
1728
|
+
async appendMessageAsync(imap, mailbox, rfc822Base64, flags) {
|
|
1729
|
+
return this.client.request(MAIL_COMMANDS.appendMessage, {
|
|
1730
|
+
imap,
|
|
1731
|
+
mailbox,
|
|
1732
|
+
rfc822Base64,
|
|
1733
|
+
flags
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
/** Send a message via SMTP. Returns the assigned Message-ID (no angle brackets). */
|
|
1737
|
+
async sendMessageAsync(smtp, message) {
|
|
1738
|
+
return this.client.request(MAIL_COMMANDS.sendMessage, {
|
|
1739
|
+
smtp,
|
|
1740
|
+
message
|
|
1741
|
+
});
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Build RFC822 bytes for a message without sending — useful for
|
|
1745
|
+
* drafts that get APPENDed to a "Drafts" folder. Permission-wise
|
|
1746
|
+
* this is a fetch operation (no SMTP host involved).
|
|
1747
|
+
*/
|
|
1748
|
+
async buildRfc822Async(imapHost, message) {
|
|
1749
|
+
return this.client.request(MAIL_COMMANDS.buildRfc822, {
|
|
1750
|
+
imapHost,
|
|
1751
|
+
message
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1583
1756
|
// src/client/tableName.ts
|
|
1584
1757
|
function validatePublicKey(publicKey) {
|
|
1585
1758
|
if (!publicKey || typeof publicKey !== "string" || publicKey.trim() === "") {
|
|
@@ -1936,7 +2109,7 @@ async function initIframeMode(ctx, log, messageHandler, request) {
|
|
|
1936
2109
|
publicKey: ctx.config.manifest.publicKey,
|
|
1937
2110
|
name: ctx.config.manifest.name,
|
|
1938
2111
|
version: ctx.config.manifest.version,
|
|
1939
|
-
displayName: ctx.config.manifest.name
|
|
2112
|
+
displayName: ctx.config.manifest.displayName ?? ctx.config.manifest.name
|
|
1940
2113
|
};
|
|
1941
2114
|
log("Extension info loaded from manifest:", ctx.state.extensionInfo);
|
|
1942
2115
|
}
|
|
@@ -2127,11 +2300,10 @@ function processEvent(event, log, eventListeners, onContextChanged, onExternalRe
|
|
|
2127
2300
|
emitEvent(event, log, eventListeners);
|
|
2128
2301
|
}
|
|
2129
2302
|
function emitEvent(event, log, eventListeners) {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
log("Event received:", event);
|
|
2303
|
+
log("emitEvent called with:", event.type, event);
|
|
2304
|
+
log("Registered event types:", Array.from(eventListeners.keys()));
|
|
2133
2305
|
const listeners = eventListeners.get(event.type);
|
|
2134
|
-
|
|
2306
|
+
log("Listeners for", event.type, ":", listeners?.size ?? 0);
|
|
2135
2307
|
if (listeners) {
|
|
2136
2308
|
listeners.forEach((callback) => callback(event));
|
|
2137
2309
|
}
|
|
@@ -2228,9 +2400,9 @@ function registerExternalHandler(action, handler, handlers, log) {
|
|
|
2228
2400
|
};
|
|
2229
2401
|
}
|
|
2230
2402
|
async function handleExternalRequest(request, handlers, respond, log) {
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2403
|
+
log("handleExternalRequest called");
|
|
2404
|
+
log("Request:", request);
|
|
2405
|
+
log("Available handlers:", Array.from(handlers.keys()));
|
|
2234
2406
|
log(`[ExternalRequest] Received request: ${request.action} from ${request.publicKey.substring(0, 20)}...`);
|
|
2235
2407
|
const handler = handlers.get(request.action);
|
|
2236
2408
|
if (!handler) {
|
|
@@ -2256,7 +2428,6 @@ async function handleExternalRequest(request, handlers, respond, log) {
|
|
|
2256
2428
|
}
|
|
2257
2429
|
}
|
|
2258
2430
|
async function respondToExternalRequest(response, request) {
|
|
2259
|
-
console.log("[SDK Debug] respondToExternalRequest called with:", JSON.stringify(response, null, 2));
|
|
2260
2431
|
await request(EXTERNAL_BRIDGE_COMMANDS.respond, response);
|
|
2261
2432
|
}
|
|
2262
2433
|
|
|
@@ -2314,11 +2485,17 @@ var HaexVaultSdk = class {
|
|
|
2314
2485
|
this.localsend = new LocalSendAPI(this);
|
|
2315
2486
|
this.spaces = new SpacesAPI(this);
|
|
2316
2487
|
this.shell = new ShellAPI(this);
|
|
2488
|
+
this.passwords = new PasswordsAPI(this);
|
|
2489
|
+
this.mail = new MailAPI(this);
|
|
2317
2490
|
installConsoleForwarding(this.config.debug);
|
|
2318
|
-
this.readyPromise = new Promise((resolve) => {
|
|
2491
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
2319
2492
|
this.resolveReady = resolve;
|
|
2493
|
+
this.rejectReady = reject;
|
|
2494
|
+
});
|
|
2495
|
+
this.init().catch((error) => {
|
|
2496
|
+
this.log("Init failed:", error);
|
|
2497
|
+
this.rejectReady(error);
|
|
2320
2498
|
});
|
|
2321
|
-
this.init();
|
|
2322
2499
|
}
|
|
2323
2500
|
// ==========================================================================
|
|
2324
2501
|
// Lifecycle
|
|
@@ -2346,9 +2523,14 @@ var HaexVaultSdk = class {
|
|
|
2346
2523
|
return this.setupPromise;
|
|
2347
2524
|
}
|
|
2348
2525
|
destroy() {
|
|
2349
|
-
if (this.messageHandler) {
|
|
2350
|
-
|
|
2526
|
+
if (this.messageHandler && this.hostPort) {
|
|
2527
|
+
this.hostPort.removeEventListener("message", this.messageHandler);
|
|
2528
|
+
}
|
|
2529
|
+
if (this.hostPort) {
|
|
2530
|
+
this.hostPort.close();
|
|
2531
|
+
this.hostPort = null;
|
|
2351
2532
|
}
|
|
2533
|
+
this.messageHandler = null;
|
|
2352
2534
|
this.pendingRequests.forEach(({ timeout }) => clearTimeout(timeout));
|
|
2353
2535
|
this.pendingRequests.clear();
|
|
2354
2536
|
this.eventListeners.clear();
|
|
@@ -2576,7 +2758,7 @@ var HaexVaultSdk = class {
|
|
|
2576
2758
|
publicKey: this.config.manifest.publicKey,
|
|
2577
2759
|
name: this.config.manifest.name,
|
|
2578
2760
|
version: this.config.manifest.version,
|
|
2579
|
-
displayName: this.config.manifest.name
|
|
2761
|
+
displayName: this.config.manifest.displayName ?? this.config.manifest.name
|
|
2580
2762
|
};
|
|
2581
2763
|
this.notifySubscribersInternal();
|
|
2582
2764
|
}
|