@haex-space/vault-sdk 2.9.3 → 3.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/{client-BRsLRztg.d.ts → client-B_B6rLIw.d.ts} +11 -1
- package/dist/{client-CUZX5oKJ.d.mts → client-C0DPNG62.d.mts} +11 -1
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +90 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -22
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.js +18 -1
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +18 -1
- package/dist/nuxt.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +90 -22
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +90 -22
- package/dist/react.mjs.map +1 -1
- package/dist/runtime/nuxt.plugin.client.d.mts +1 -1
- package/dist/runtime/nuxt.plugin.client.d.ts +1 -1
- package/dist/runtime/nuxt.plugin.client.js +90 -22
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +90 -22
- package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +90 -22
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +90 -22
- package/dist/svelte.mjs.map +1 -1
- package/dist/vite.js +18 -1
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +18 -1
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +90 -22
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +90 -22
- package/dist/vue.mjs.map +1 -1
- package/package.json +2 -1
package/dist/svelte.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HaexVaultSdk, S as StorageAPI } from './client-
|
|
1
|
+
import { H as HaexVaultSdk, S as StorageAPI } from './client-C0DPNG62.mjs';
|
|
2
2
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
import { Readable } from 'svelte/store';
|
|
4
4
|
import { A as ApplicationContext, a as ExtensionInfo, H as HaexHubConfig } from './types-DmCSegdY.mjs';
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HaexVaultSdk, S as StorageAPI } from './client-
|
|
1
|
+
import { H as HaexVaultSdk, S as StorageAPI } from './client-B_B6rLIw.js';
|
|
2
2
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
import { Readable } from 'svelte/store';
|
|
4
4
|
import { A as ApplicationContext, a as ExtensionInfo, H as HaexHubConfig } from './types-DmCSegdY.js';
|
package/dist/svelte.js
CHANGED
|
@@ -269,7 +269,24 @@ var HAEXSPACE_MESSAGE_TYPES = {
|
|
|
269
269
|
/** Debug message for development/troubleshooting */
|
|
270
270
|
DEBUG: "haexspace:debug",
|
|
271
271
|
/** Console forwarding from extension iframe */
|
|
272
|
-
CONSOLE_FORWARD: "console.forward"
|
|
272
|
+
CONSOLE_FORWARD: "console.forward",
|
|
273
|
+
/**
|
|
274
|
+
* Sent from main window to iframe on the shared window listener, carrying
|
|
275
|
+
* one `MessagePort` in `event.ports[0]`. Once received, the SDK switches
|
|
276
|
+
* to port-based messaging and never reads the window listener again.
|
|
277
|
+
*
|
|
278
|
+
* Payload: `{ type: PORT_INIT }` — no data. The port itself is the payload.
|
|
279
|
+
*/
|
|
280
|
+
PORT_INIT: "haexspace:port:init",
|
|
281
|
+
/**
|
|
282
|
+
* Sent from SDK to main window *over the MessagePort* after the port is
|
|
283
|
+
* installed. Main uses this to mark the iframe as ready and flush any
|
|
284
|
+
* events buffered during the handshake window. Only valid on the port —
|
|
285
|
+
* a READY sent over window.postMessage is ignored.
|
|
286
|
+
*
|
|
287
|
+
* Payload: `{ type: PORT_READY }` — no data.
|
|
288
|
+
*/
|
|
289
|
+
PORT_READY: "haexspace:port:ready"
|
|
273
290
|
};
|
|
274
291
|
|
|
275
292
|
// src/polyfills/debug.ts
|
|
@@ -682,7 +699,7 @@ var DatabaseAPI = class {
|
|
|
682
699
|
}
|
|
683
700
|
async transaction(statements) {
|
|
684
701
|
await this.client.request(DATABASE_COMMANDS.transaction, {
|
|
685
|
-
statements
|
|
702
|
+
statements: statements.map((s) => [s.sql, s.params || []])
|
|
686
703
|
});
|
|
687
704
|
}
|
|
688
705
|
async createTable(tableName, columns) {
|
|
@@ -1651,6 +1668,7 @@ function parseTableName(fullTableName) {
|
|
|
1651
1668
|
}
|
|
1652
1669
|
|
|
1653
1670
|
// src/client/init.ts
|
|
1671
|
+
var PORT_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
1654
1672
|
function isInIframe() {
|
|
1655
1673
|
return window.self !== window.top;
|
|
1656
1674
|
}
|
|
@@ -1907,11 +1925,14 @@ async function initIframeMode(ctx, log, messageHandler, request) {
|
|
|
1907
1925
|
if (!isInIframe()) {
|
|
1908
1926
|
throw new HaexVaultSdkError("NOT_IN_IFRAME" /* NOT_IN_IFRAME */, "errors.not_in_iframe");
|
|
1909
1927
|
}
|
|
1928
|
+
const port = await waitForHostPortAsync(log);
|
|
1910
1929
|
ctx.handlers.messageHandler = messageHandler;
|
|
1911
|
-
|
|
1930
|
+
port.addEventListener("message", messageHandler);
|
|
1931
|
+
port.start();
|
|
1932
|
+
port.postMessage({ type: HAEXSPACE_MESSAGE_TYPES.PORT_READY });
|
|
1912
1933
|
ctx.state.isNativeWindow = false;
|
|
1913
1934
|
ctx.state.initialized = true;
|
|
1914
|
-
log("HaexVault SDK initialized in iframe mode");
|
|
1935
|
+
log("HaexVault SDK initialized in iframe mode (MessagePort transport)");
|
|
1915
1936
|
if (ctx.config.manifest) {
|
|
1916
1937
|
ctx.state.extensionInfo = {
|
|
1917
1938
|
publicKey: ctx.config.manifest.publicKey,
|
|
@@ -1925,7 +1946,42 @@ async function initIframeMode(ctx, log, messageHandler, request) {
|
|
|
1925
1946
|
const context2 = await request(EXTENSION_COMMANDS.getContext);
|
|
1926
1947
|
ctx.state.context = context2;
|
|
1927
1948
|
log("Application context received:", context2);
|
|
1928
|
-
return { context: context2 };
|
|
1949
|
+
return { context: context2, port };
|
|
1950
|
+
}
|
|
1951
|
+
function waitForHostPortAsync(log) {
|
|
1952
|
+
return new Promise((resolve, reject) => {
|
|
1953
|
+
let settled = false;
|
|
1954
|
+
const cleanup = () => {
|
|
1955
|
+
window.removeEventListener("message", handler);
|
|
1956
|
+
};
|
|
1957
|
+
const timeoutId = setTimeout(() => {
|
|
1958
|
+
if (settled) return;
|
|
1959
|
+
settled = true;
|
|
1960
|
+
cleanup();
|
|
1961
|
+
reject(
|
|
1962
|
+
new HaexVaultSdkError(
|
|
1963
|
+
"TIMEOUT" /* TIMEOUT */,
|
|
1964
|
+
"errors.port_handshake_timeout",
|
|
1965
|
+
{ timeout: PORT_HANDSHAKE_TIMEOUT_MS }
|
|
1966
|
+
)
|
|
1967
|
+
);
|
|
1968
|
+
}, PORT_HANDSHAKE_TIMEOUT_MS);
|
|
1969
|
+
const handler = (event) => {
|
|
1970
|
+
const type = event.data?.type;
|
|
1971
|
+
if (type !== HAEXSPACE_MESSAGE_TYPES.PORT_INIT) return;
|
|
1972
|
+
const port = event.ports[0];
|
|
1973
|
+
if (!port) {
|
|
1974
|
+
log("PORT_INIT received but event.ports is empty \u2014 ignoring");
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
if (settled) return;
|
|
1978
|
+
settled = true;
|
|
1979
|
+
clearTimeout(timeoutId);
|
|
1980
|
+
cleanup();
|
|
1981
|
+
resolve(port);
|
|
1982
|
+
};
|
|
1983
|
+
window.addEventListener("message", handler);
|
|
1984
|
+
});
|
|
1929
1985
|
}
|
|
1930
1986
|
function sendDebugInfo(config) {
|
|
1931
1987
|
if (!config.debug) return;
|
|
@@ -1949,7 +2005,15 @@ postMessage error: ${e}`);
|
|
|
1949
2005
|
function generateRequestId(counter) {
|
|
1950
2006
|
return `req_${counter}`;
|
|
1951
2007
|
}
|
|
1952
|
-
function sendPostMessage(method, params, requestId, config, extensionInfo2, pendingRequests) {
|
|
2008
|
+
function sendPostMessage(method, params, requestId, config, extensionInfo2, pendingRequests, port) {
|
|
2009
|
+
if (!port) {
|
|
2010
|
+
return Promise.reject(
|
|
2011
|
+
new HaexVaultSdkError(
|
|
2012
|
+
"EXTENSION_NOT_INITIALIZED" /* EXTENSION_NOT_INITIALIZED */,
|
|
2013
|
+
"errors.port_not_connected"
|
|
2014
|
+
)
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
1953
2017
|
const request = {
|
|
1954
2018
|
method,
|
|
1955
2019
|
params,
|
|
@@ -1965,17 +2029,16 @@ function sendPostMessage(method, params, requestId, config, extensionInfo2, pend
|
|
|
1965
2029
|
);
|
|
1966
2030
|
}, config.timeout);
|
|
1967
2031
|
pendingRequests.set(requestId, { resolve, reject, timeout });
|
|
1968
|
-
const targetOrigin = "*";
|
|
1969
2032
|
if (config.debug) {
|
|
1970
2033
|
console.log("[SDK Debug] ========== Sending Request ==========");
|
|
1971
2034
|
console.log("[SDK Debug] Request ID:", requestId);
|
|
1972
2035
|
console.log("[SDK Debug] Method:", request.method);
|
|
1973
2036
|
console.log("[SDK Debug] Params:", request.params);
|
|
1974
|
-
console.log("[SDK Debug]
|
|
2037
|
+
console.log("[SDK Debug] Transport: MessagePort");
|
|
1975
2038
|
console.log("[SDK Debug] Extension info:", extensionInfo2);
|
|
1976
2039
|
console.log("[SDK Debug] ========================================");
|
|
1977
2040
|
}
|
|
1978
|
-
|
|
2041
|
+
port.postMessage({ id: requestId, ...request });
|
|
1979
2042
|
});
|
|
1980
2043
|
}
|
|
1981
2044
|
async function sendInvoke(method, params, config, _log) {
|
|
@@ -1994,11 +2057,6 @@ function createMessageHandler(config, pendingRequests, extensionInfo2, onEvent)
|
|
|
1994
2057
|
return (event) => {
|
|
1995
2058
|
if (config.debug) {
|
|
1996
2059
|
console.log("[SDK Debug] ========== Message Received ==========");
|
|
1997
|
-
console.log("[SDK Debug] Event origin:", event.origin);
|
|
1998
|
-
console.log(
|
|
1999
|
-
"[SDK Debug] Event source:",
|
|
2000
|
-
event.source === window.parent ? "parent window" : "unknown"
|
|
2001
|
-
);
|
|
2002
2060
|
console.log("[SDK Debug] Event data:", event.data);
|
|
2003
2061
|
console.log("[SDK Debug] Extension info loaded:", !!extensionInfo2());
|
|
2004
2062
|
console.log(
|
|
@@ -2006,12 +2064,6 @@ function createMessageHandler(config, pendingRequests, extensionInfo2, onEvent)
|
|
|
2006
2064
|
pendingRequests.size
|
|
2007
2065
|
);
|
|
2008
2066
|
}
|
|
2009
|
-
if (event.source !== window.parent) {
|
|
2010
|
-
if (config.debug) {
|
|
2011
|
-
console.error("[SDK Debug] \u274C REJECTED: Message not from parent window!");
|
|
2012
|
-
}
|
|
2013
|
-
return;
|
|
2014
|
-
}
|
|
2015
2067
|
const data = event.data;
|
|
2016
2068
|
if ("id" in data && pendingRequests.has(data.id)) {
|
|
2017
2069
|
if (config.debug) {
|
|
@@ -2233,6 +2285,13 @@ var HaexVaultSdk = class {
|
|
|
2233
2285
|
this.reactiveSubscribers = /* @__PURE__ */ new Set();
|
|
2234
2286
|
// Handlers
|
|
2235
2287
|
this.messageHandler = null;
|
|
2288
|
+
/**
|
|
2289
|
+
* MessagePort obtained from the main window during iframe-mode handshake.
|
|
2290
|
+
* `null` until `initIframe()` completes successfully. Every outbound
|
|
2291
|
+
* request in iframe mode flows through this port; `sendPostMessage` rejects
|
|
2292
|
+
* if called before the handshake finishes.
|
|
2293
|
+
*/
|
|
2294
|
+
this.hostPort = null;
|
|
2236
2295
|
this.setupPromise = null;
|
|
2237
2296
|
this.setupHook = null;
|
|
2238
2297
|
// Public APIs
|
|
@@ -2406,7 +2465,15 @@ var HaexVaultSdk = class {
|
|
|
2406
2465
|
return sendInvoke(method, paramsWithCredentials, this.config, this.log.bind(this));
|
|
2407
2466
|
}
|
|
2408
2467
|
const requestId = generateRequestId(++this.requestCounter);
|
|
2409
|
-
return sendPostMessage(
|
|
2468
|
+
return sendPostMessage(
|
|
2469
|
+
method,
|
|
2470
|
+
resolvedParams,
|
|
2471
|
+
requestId,
|
|
2472
|
+
this.config,
|
|
2473
|
+
this._extensionInfo,
|
|
2474
|
+
this.pendingRequests,
|
|
2475
|
+
this.hostPort
|
|
2476
|
+
);
|
|
2410
2477
|
}
|
|
2411
2478
|
// ==========================================================================
|
|
2412
2479
|
// Private: Initialization
|
|
@@ -2473,7 +2540,7 @@ var HaexVaultSdk = class {
|
|
|
2473
2540
|
() => this._extensionInfo,
|
|
2474
2541
|
this.handleEvent.bind(this)
|
|
2475
2542
|
);
|
|
2476
|
-
const { context: context2 } = await initIframeMode(
|
|
2543
|
+
const { context: context2, port } = await initIframeMode(
|
|
2477
2544
|
{
|
|
2478
2545
|
config: this.config,
|
|
2479
2546
|
state: {
|
|
@@ -2505,6 +2572,7 @@ var HaexVaultSdk = class {
|
|
|
2505
2572
|
this.messageHandler,
|
|
2506
2573
|
this.request.bind(this)
|
|
2507
2574
|
);
|
|
2575
|
+
this.hostPort = port;
|
|
2508
2576
|
if (this.config.manifest) {
|
|
2509
2577
|
this._extensionInfo = {
|
|
2510
2578
|
publicKey: this.config.manifest.publicKey,
|