@haex-space/vault-sdk 3.0.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-dpJHb3FP.d.ts → client-GeColu97.d.mts} +270 -2
- package/dist/{client-BXtzUBWv.d.mts → client-z1jTcuQE.d.ts} +270 -2
- package/dist/index.d.mts +93 -6
- package/dist/index.d.ts +93 -6
- package/dist/index.js +301 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -46
- 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 +34 -7
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +34 -7
- 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 +294 -44
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +294 -44
- 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 +294 -48
- package/dist/runtime/nuxt.plugin.client.js.map +1 -1
- package/dist/runtime/nuxt.plugin.client.mjs +294 -48
- 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 +294 -44
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +294 -44
- 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 +33 -6
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +33 -6
- 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 +294 -44
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +294 -44
- package/dist/vue.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -293,6 +293,8 @@ interface ManifestI18nEntry {
|
|
|
293
293
|
}
|
|
294
294
|
interface ExtensionManifest {
|
|
295
295
|
name: string;
|
|
296
|
+
/** Human-readable display name. Falls back to `name` when absent. */
|
|
297
|
+
displayName?: string | null;
|
|
296
298
|
version: string;
|
|
297
299
|
author?: string | null;
|
|
298
300
|
entry?: string | null;
|
|
@@ -293,6 +293,8 @@ interface ManifestI18nEntry {
|
|
|
293
293
|
}
|
|
294
294
|
interface ExtensionManifest {
|
|
295
295
|
name: string;
|
|
296
|
+
/** Human-readable display name. Falls back to `name` when absent. */
|
|
297
|
+
displayName?: string | null;
|
|
296
298
|
version: string;
|
|
297
299
|
author?: string | null;
|
|
298
300
|
entry?: string | null;
|
package/dist/vite.js
CHANGED
|
@@ -225,7 +225,24 @@ var HAEXSPACE_MESSAGE_TYPES = {
|
|
|
225
225
|
/** Debug message for development/troubleshooting */
|
|
226
226
|
DEBUG: "haexspace:debug",
|
|
227
227
|
/** Console forwarding from extension iframe */
|
|
228
|
-
CONSOLE_FORWARD: "console.forward"
|
|
228
|
+
CONSOLE_FORWARD: "console.forward",
|
|
229
|
+
/**
|
|
230
|
+
* Sent from main window to iframe on the shared window listener, carrying
|
|
231
|
+
* one `MessagePort` in `event.ports[0]`. Once received, the SDK switches
|
|
232
|
+
* to port-based messaging and never reads the window listener again.
|
|
233
|
+
*
|
|
234
|
+
* Payload: `{ type: PORT_INIT }` — no data. The port itself is the payload.
|
|
235
|
+
*/
|
|
236
|
+
PORT_INIT: "haexspace:port:init",
|
|
237
|
+
/**
|
|
238
|
+
* Sent from SDK to main window *over the MessagePort* after the port is
|
|
239
|
+
* installed. Main uses this to mark the iframe as ready and flush any
|
|
240
|
+
* events buffered during the handshake window. Only valid on the port —
|
|
241
|
+
* a READY sent over window.postMessage is ignored.
|
|
242
|
+
*
|
|
243
|
+
* Payload: `{ type: PORT_READY }` — no data.
|
|
244
|
+
*/
|
|
245
|
+
PORT_READY: "haexspace:port:ready"
|
|
229
246
|
};
|
|
230
247
|
|
|
231
248
|
// src/polyfills/debug.ts
|
|
@@ -282,14 +299,24 @@ function getPolyfillCode() {
|
|
|
282
299
|
// src/cors.ts
|
|
283
300
|
var HAEXSPACE_CORS_HEADERS = {
|
|
284
301
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
285
|
-
"Access-Control-Allow-Headers": "*"
|
|
286
|
-
"Access-Control-Allow-Credentials": "true"
|
|
302
|
+
"Access-Control-Allow-Headers": "*"
|
|
287
303
|
};
|
|
288
|
-
function
|
|
289
|
-
|
|
304
|
+
function isWildcardOrigin(origin) {
|
|
305
|
+
return !origin || origin === "*";
|
|
306
|
+
}
|
|
307
|
+
function applyCorsHeaders(res, origin, options = {}) {
|
|
308
|
+
const effectiveOrigin = origin || "*";
|
|
309
|
+
if (options.credentials && isWildcardOrigin(origin)) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
"[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin."
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
res.setHeader("Access-Control-Allow-Origin", effectiveOrigin);
|
|
290
315
|
res.setHeader("Access-Control-Allow-Methods", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Methods"]);
|
|
291
316
|
res.setHeader("Access-Control-Allow-Headers", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Headers"]);
|
|
292
|
-
|
|
317
|
+
if (options.credentials && !isWildcardOrigin(origin)) {
|
|
318
|
+
res.setHeader("Access-Control-Allow-Credentials", "true");
|
|
319
|
+
}
|
|
293
320
|
}
|
|
294
321
|
|
|
295
322
|
// src/vite.ts
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/pol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AAY,OAAA,GAAU,CAAA;AAG5B,QAAA,MAAM,cAAA,GAAiB,WAAW,YAAY,CAAA,SAAA,CAAA;AAC9C,QAAA,MAAM,YAAA,GAAe,KAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAErF,QAAA,OAAA,CAAQ,IAAI,4DAAuD,CAAA;AAEnE,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.js","sourcesContent":["/**\n * localStorage Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory fallback when localStorage is blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installLocalStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // Test if localStorage is available\n let localStorageWorks = false;\n try {\n const testKey = '__ls_test__';\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n localStorageWorks = true;\n } catch {\n console.warn('[HaexSpace] localStorage blocked – using in-memory fallback');\n }\n\n // If blocked: Replace with In-Memory Storage\n if (!localStorageWorks) {\n const lsStorage = new Map<string, string>();\n\n const localStoragePoly: Storage = {\n getItem(key: string): string | null {\n return lsStorage.get(key) || null;\n },\n setItem(key: string, value: string): void {\n lsStorage.set(key, String(value));\n },\n removeItem(key: string): void {\n lsStorage.delete(key);\n },\n clear(): void {\n lsStorage.clear();\n },\n get length(): number {\n return lsStorage.size;\n },\n key(index: number): string | null {\n return Array.from(lsStorage.keys())[index] || null;\n }\n };\n\n try {\n Object.defineProperty(window, 'localStorage', {\n value: localStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { localStorage: Storage }).localStorage = localStoragePoly;\n }\n\n console.log('[HaexSpace] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexSpace Extensions\n *\n * Provides a no-op implementation as session state doesn't work\n * reliably in custom protocol contexts\n */\nexport function installSessionStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n try {\n const sessionStoragePoly: Storage = {\n getItem(): null {\n return null;\n },\n setItem(): void {},\n removeItem(): void {},\n clear(): void {},\n get length(): number {\n return 0;\n },\n key(): null {\n return null;\n }\n };\n\n Object.defineProperty(window, 'sessionStorage', {\n value: sessionStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { sessionStorage: Storage }).sessionStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n clear: () => {},\n get length() { return 0; },\n key: () => null\n };\n }\n\n console.log('[HaexSpace] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory cookie implementation when cookies are blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installCookiePolyfill(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return; // Skip in Node.js environment\n }\n\n // Test if cookies are available\n let cookiesWork = false;\n try {\n document.cookie = \"__cookie_test__=1\";\n cookiesWork = document.cookie.indexOf(\"__cookie_test__\") !== -1;\n } catch {\n console.warn(\"[HaexSpace] Cookies blocked – using in-memory fallback\");\n }\n\n if (!cookiesWork) {\n const cookieStore = new Map<string, string>();\n\n Object.defineProperty(document, \"cookie\", {\n get(): string {\n const cookies: string[] = [];\n cookieStore.forEach((value, key) => {\n cookies.push(`${key}=${value}`);\n });\n return cookies.join(\"; \");\n },\n set(cookieString: string): void {\n const parts = cookieString.split(\";\").map((p) => p.trim());\n const [keyValue] = parts;\n\n if (!keyValue) return;\n\n const [key, value] = keyValue.split(\"=\");\n if (!key) return;\n\n // Parse options\n const options: Record<string, string | boolean> = {};\n for (let i = 1; i < parts.length; i++) {\n const part = parts[i];\n if (!part) continue;\n const parts_split = part.split(\"=\");\n const optKey = parts_split[0];\n const optValue = parts_split[1];\n if (optKey) {\n options[optKey.toLowerCase()] = optValue || true;\n }\n }\n\n // Check for deletion (expires in past)\n const expiresValue = options.expires;\n if (expiresValue && typeof expiresValue === \"string\") {\n const expiresDate = new Date(expiresValue);\n if (expiresDate < new Date()) {\n cookieStore.delete(key);\n return;\n }\n }\n\n // Check for max-age=0 deletion\n const maxAgeValue = options[\"max-age\"];\n if (typeof maxAgeValue === \"string\" && maxAgeValue === \"0\") {\n cookieStore.delete(key);\n return;\n }\n\n // Store cookie\n cookieStore.set(key, value || \"\");\n },\n configurable: true,\n });\n\n console.log(\"[HaexSpace] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexSpace Extensions\n *\n * Works around SecurityError when using pushState/replaceState\n * in custom protocol contexts (haex-extension://)\n *\n * Falls back to hash-based routing when necessary\n */\n\nexport function installHistoryPolyfill(): void {\n if (typeof window === 'undefined' || typeof history === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n // Install after DOM is ready to avoid race conditions\n const install = () => {\n console.log('[HaexSpace] History Patch loading');\n\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n let skipNextPush = false;\n let skipNextReplace = false;\n\n // Patch pushState\n history.pushState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexSpace] pushState skipped');\n return;\n }\n\n try {\n return originalPushState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextPush = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n // Patch replaceState\n history.replaceState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexSpace] replaceState skipped');\n return;\n }\n\n try {\n return originalReplaceState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextReplace = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n console.log('[HaexSpace] History API patched');\n };\n\n // Install after DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', install, { once: true });\n } else {\n // DOM already loaded, install immediately\n install();\n }\n}\n","/**\n * Central message type definitions for HaexSpace SDK\n *\n * Message Naming Schema: haexspace:{subject}\n *\n * These are used for internal communication between extensions and HaexSpace\n */\n\nexport const HAEXSPACE_MESSAGE_TYPES = {\n /** Debug message for development/troubleshooting */\n DEBUG: 'haexspace:debug',\n\n /** Console forwarding from extension iframe */\n CONSOLE_FORWARD: 'console.forward',\n} as const;\n\nexport type HaexspaceMessageType =\n (typeof HAEXSPACE_MESSAGE_TYPES)[keyof typeof HAEXSPACE_MESSAGE_TYPES];\n","import { HAEXSPACE_MESSAGE_TYPES } from '../messages';\n\n/**\n * Debug diagnostics for Android debugging\n * Tests window.parent availability and postMessage functionality\n */\nexport function installDebugDiagnostics(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hasParent = window.parent && window.parent !== window;\n console.log('[HaexSpace] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexSpace] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: HAEXSPACE_MESSAGE_TYPES.DEBUG,\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexSpace] Debug message sent!');\n } else {\n console.log('[HaexSpace] No parent window or parent === window');\n }\n}\n","/**\n * Generates standalone polyfill code for HTML injection\n * This wraps the modular polyfills into an IIFE for immediate execution\n */\nimport {\n installLocalStoragePolyfill,\n installSessionStoragePolyfill,\n} from './localStorage'\nimport { installCookiePolyfill } from './cookies'\nimport { installHistoryPolyfill } from './history'\nimport { installDebugDiagnostics } from './debug'\nimport { HAEXSPACE_MESSAGE_TYPES } from '../messages'\n\n/**\n * Get the standalone polyfill code as a string\n * This is used by the Nuxt and Vite plugins to inject polyfills into HTML\n *\n * Note: Base tag is injected statically by the Vite plugin, not at runtime\n */\nexport function getPolyfillCode(): string {\n // Convert functions to string and wrap in IIFE\n // We need to inject the HAEXSPACE_MESSAGE_TYPES constant since it's used by installDebugDiagnostics\n const iife = `(function() {\n 'use strict';\n\n // Message types constant (injected from HAEXSPACE_MESSAGE_TYPES)\n var HAEXSPACE_MESSAGE_TYPES = ${JSON.stringify(HAEXSPACE_MESSAGE_TYPES)};\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // localStorage Polyfill\n (${installLocalStoragePolyfill.toString()})();\n\n // sessionStorage Polyfill\n (${installSessionStoragePolyfill.toString()})();\n\n // Cookie Polyfill\n (${installCookiePolyfill.toString()})();\n\n // History API Polyfill\n (${installHistoryPolyfill.toString()})();\n\n // Note: Base tag is injected at build-time by Vite plugin, not at runtime\n\n console.log('[HaexSpace] All polyfills loaded successfully');\n\n // Debug diagnostics for Android debugging\n (${installDebugDiagnostics.toString()})();\n})();`\n\n return iife\n}\n","/**\n * CORS Configuration for HaexSpace Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexSpace dev servers\n * Allows extensions to be loaded in custom protocol iframes (haex-extension://)\n */\nexport const HAEXSPACE_CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n 'Access-Control-Allow-Credentials': 'true',\n} as const\n\n/**\n * Apply CORS headers to a Node.js response object\n * Used in Vite middleware\n */\nexport function applyCorsHeaders(\n res: { setHeader: (name: string, value: string) => void },\n origin?: string\n) {\n res.setHeader('Access-Control-Allow-Origin', origin || '*')\n res.setHeader('Access-Control-Allow-Methods', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'])\n res.setHeader('Access-Control-Allow-Credentials', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Credentials'])\n}\n\n/**\n * Get CORS headers as a plain object\n * Used in Vite/Nuxt config\n */\nexport function getCorsHeaders(origin?: string): Record<string, string> {\n return {\n 'Access-Control-Allow-Origin': origin || HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'],\n 'Access-Control-Allow-Credentials': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Credentials'],\n }\n}\n","/**\n * Vite Plugin for HaexSpace SDK\n * Automatically injects polyfills into HTML files\n * Works with React, Vue, Svelte, and any other Vite-based project\n */\nimport type { Plugin } from 'vite'\nimport { getPolyfillCode } from './polyfills/standalone'\nimport { applyCorsHeaders } from './cors'\n\nexport interface VitePluginOptions {\n /**\n * Enable/disable polyfill injection\n * @default true\n */\n injectPolyfills?: boolean\n\n /**\n * Configure CORS for dev server\n * @default true\n */\n configureCors?: boolean\n}\n\n/**\n * HaexSpace Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexspacePlugin } from '@haex-space/vault-sdk/vite'\n *\n * export default {\n * plugins: [haexspacePlugin()]\n * }\n * ```\n */\nexport function haexspacePlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haex-space/vault-sdk',\n enforce: 'post', // Run after other plugins\n\n configResolved(config) {\n if (injectPolyfills) {\n try {\n // Get polyfill code from modular polyfills\n polyfillCode = getPolyfillCode()\n console.log('✓ [@haex-space/vault-sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haex-space/vault-sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haex-space/vault-sdk] CORS configured for HaexSpace development')\n console.log(' - Allowing all origins (required for custom protocols)')\n console.log(' - Allowing credentials')\n }\n },\n\n configureServer(server) {\n if (!configureCors) return\n\n // Add CORS middleware for HaexSpace using shared CORS configuration\n server.middlewares.use((req, res, next) => {\n // Apply CORS headers (allows custom protocols like haex-extension://)\n applyCorsHeaders(res, req.headers.origin)\n\n // Handle preflight requests\n if (req.method === 'OPTIONS') {\n res.statusCode = 200\n res.end()\n return\n }\n\n next()\n })\n },\n\n transformIndexHtml: {\n order: 'pre', // Inject before other transformations\n handler(html: string) {\n if (!injectPolyfills || !polyfillCode) {\n return html\n }\n\n // Inject polyfill script directly after <head>\n const headPos = html.indexOf('<head>')\n if (headPos === -1) {\n console.warn('[@haex-space/vault-sdk] No <head> tag found in HTML')\n return html\n }\n\n const insertPos = headPos + 6 // after <head>\n\n // Inject polyfill only (no base tag needed)\n const polyfillScript = `<script>${polyfillCode}</script>`\n const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos)\n\n console.log('✓ [@haex-space/vault-sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexspacePlugin\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/messages.ts","../src/polyfills/debug.ts","../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AAK;AAAA,MACP,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IAEA,kBAAA,EAAoB;AAAA,MAClB,KAAA,EAAO,KAAA;AAAA;AAAA,MACP,QAAQ,IAAA,EAAc;AACpB,QAAA,IAAI,CAAC,eAAA,IAAmB,CAAC,YAAA,EAAc;AACrC,UAAA,OAAO,IAAA;AAAA,QACT;AAGA,QAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACrC,QAAA,IAAI,YAAY,EAAA,EAAI;AAClB,UAAA,OAAA,CAAQ,KAAK,qDAAqD,CAAA;AAClE,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,MAAM,YAAY,OAAA,GAAU,CAAA;AAG5B,QAAA,MAAM,cAAA,GAAiB,WAAW,YAAY,CAAA,SAAA,CAAA;AAC9C,QAAA,MAAM,YAAA,GAAe,KAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAErF,QAAA,OAAA,CAAQ,IAAI,4DAAuD,CAAA;AAEnE,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.js","sourcesContent":["/**\n * localStorage Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory fallback when localStorage is blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installLocalStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // Test if localStorage is available\n let localStorageWorks = false;\n try {\n const testKey = '__ls_test__';\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n localStorageWorks = true;\n } catch {\n console.warn('[HaexSpace] localStorage blocked – using in-memory fallback');\n }\n\n // If blocked: Replace with In-Memory Storage\n if (!localStorageWorks) {\n const lsStorage = new Map<string, string>();\n\n const localStoragePoly: Storage = {\n getItem(key: string): string | null {\n return lsStorage.get(key) || null;\n },\n setItem(key: string, value: string): void {\n lsStorage.set(key, String(value));\n },\n removeItem(key: string): void {\n lsStorage.delete(key);\n },\n clear(): void {\n lsStorage.clear();\n },\n get length(): number {\n return lsStorage.size;\n },\n key(index: number): string | null {\n return Array.from(lsStorage.keys())[index] || null;\n }\n };\n\n try {\n Object.defineProperty(window, 'localStorage', {\n value: localStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { localStorage: Storage }).localStorage = localStoragePoly;\n }\n\n console.log('[HaexSpace] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexSpace Extensions\n *\n * Provides a no-op implementation as session state doesn't work\n * reliably in custom protocol contexts\n */\nexport function installSessionStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n try {\n const sessionStoragePoly: Storage = {\n getItem(): null {\n return null;\n },\n setItem(): void {},\n removeItem(): void {},\n clear(): void {},\n get length(): number {\n return 0;\n },\n key(): null {\n return null;\n }\n };\n\n Object.defineProperty(window, 'sessionStorage', {\n value: sessionStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { sessionStorage: Storage }).sessionStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n clear: () => {},\n get length() { return 0; },\n key: () => null\n };\n }\n\n console.log('[HaexSpace] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory cookie implementation when cookies are blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installCookiePolyfill(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return; // Skip in Node.js environment\n }\n\n // Test if cookies are available\n let cookiesWork = false;\n try {\n document.cookie = \"__cookie_test__=1\";\n cookiesWork = document.cookie.indexOf(\"__cookie_test__\") !== -1;\n } catch {\n console.warn(\"[HaexSpace] Cookies blocked – using in-memory fallback\");\n }\n\n if (!cookiesWork) {\n const cookieStore = new Map<string, string>();\n\n Object.defineProperty(document, \"cookie\", {\n get(): string {\n const cookies: string[] = [];\n cookieStore.forEach((value, key) => {\n cookies.push(`${key}=${value}`);\n });\n return cookies.join(\"; \");\n },\n set(cookieString: string): void {\n const parts = cookieString.split(\";\").map((p) => p.trim());\n const [keyValue] = parts;\n\n if (!keyValue) return;\n\n const [key, value] = keyValue.split(\"=\");\n if (!key) return;\n\n // Parse options\n const options: Record<string, string | boolean> = {};\n for (let i = 1; i < parts.length; i++) {\n const part = parts[i];\n if (!part) continue;\n const parts_split = part.split(\"=\");\n const optKey = parts_split[0];\n const optValue = parts_split[1];\n if (optKey) {\n options[optKey.toLowerCase()] = optValue || true;\n }\n }\n\n // Check for deletion (expires in past)\n const expiresValue = options.expires;\n if (expiresValue && typeof expiresValue === \"string\") {\n const expiresDate = new Date(expiresValue);\n if (expiresDate < new Date()) {\n cookieStore.delete(key);\n return;\n }\n }\n\n // Check for max-age=0 deletion\n const maxAgeValue = options[\"max-age\"];\n if (typeof maxAgeValue === \"string\" && maxAgeValue === \"0\") {\n cookieStore.delete(key);\n return;\n }\n\n // Store cookie\n cookieStore.set(key, value || \"\");\n },\n configurable: true,\n });\n\n console.log(\"[HaexSpace] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexSpace Extensions\n *\n * Works around SecurityError when using pushState/replaceState\n * in custom protocol contexts (haex-extension://)\n *\n * Falls back to hash-based routing when necessary\n */\n\nexport function installHistoryPolyfill(): void {\n if (typeof window === 'undefined' || typeof history === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n // Install after DOM is ready to avoid race conditions\n const install = () => {\n console.log('[HaexSpace] History Patch loading');\n\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n let skipNextPush = false;\n let skipNextReplace = false;\n\n // Patch pushState\n history.pushState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexSpace] pushState skipped');\n return;\n }\n\n try {\n return originalPushState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextPush = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n // Patch replaceState\n history.replaceState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexSpace] replaceState skipped');\n return;\n }\n\n try {\n return originalReplaceState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextReplace = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n console.log('[HaexSpace] History API patched');\n };\n\n // Install after DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', install, { once: true });\n } else {\n // DOM already loaded, install immediately\n install();\n }\n}\n","/**\n * Central message type definitions for HaexSpace SDK\n *\n * Message Naming Schema: haexspace:{subject}\n *\n * These are used for internal communication between extensions and HaexSpace\n */\n\nexport const HAEXSPACE_MESSAGE_TYPES = {\n /** Debug message for development/troubleshooting */\n DEBUG: 'haexspace:debug',\n\n /** Console forwarding from extension iframe */\n CONSOLE_FORWARD: 'console.forward',\n\n /**\n * Sent from main window to iframe on the shared window listener, carrying\n * one `MessagePort` in `event.ports[0]`. Once received, the SDK switches\n * to port-based messaging and never reads the window listener again.\n *\n * Payload: `{ type: PORT_INIT }` — no data. The port itself is the payload.\n */\n PORT_INIT: 'haexspace:port:init',\n\n /**\n * Sent from SDK to main window *over the MessagePort* after the port is\n * installed. Main uses this to mark the iframe as ready and flush any\n * events buffered during the handshake window. Only valid on the port —\n * a READY sent over window.postMessage is ignored.\n *\n * Payload: `{ type: PORT_READY }` — no data.\n */\n PORT_READY: 'haexspace:port:ready',\n} as const;\n\nexport type HaexspaceMessageType =\n (typeof HAEXSPACE_MESSAGE_TYPES)[keyof typeof HAEXSPACE_MESSAGE_TYPES];\n","import { HAEXSPACE_MESSAGE_TYPES } from '../messages';\n\n/**\n * Debug diagnostics for Android debugging\n * Tests window.parent availability and postMessage functionality\n */\nexport function installDebugDiagnostics(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hasParent = window.parent && window.parent !== window;\n console.log('[HaexSpace] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexSpace] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: HAEXSPACE_MESSAGE_TYPES.DEBUG,\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexSpace] Debug message sent!');\n } else {\n console.log('[HaexSpace] No parent window or parent === window');\n }\n}\n","/**\n * Generates standalone polyfill code for HTML injection\n * This wraps the modular polyfills into an IIFE for immediate execution\n */\nimport {\n installLocalStoragePolyfill,\n installSessionStoragePolyfill,\n} from './localStorage'\nimport { installCookiePolyfill } from './cookies'\nimport { installHistoryPolyfill } from './history'\nimport { installDebugDiagnostics } from './debug'\nimport { HAEXSPACE_MESSAGE_TYPES } from '../messages'\n\n/**\n * Get the standalone polyfill code as a string\n * This is used by the Nuxt and Vite plugins to inject polyfills into HTML\n *\n * Note: Base tag is injected statically by the Vite plugin, not at runtime\n */\nexport function getPolyfillCode(): string {\n // Convert functions to string and wrap in IIFE\n // We need to inject the HAEXSPACE_MESSAGE_TYPES constant since it's used by installDebugDiagnostics\n const iife = `(function() {\n 'use strict';\n\n // Message types constant (injected from HAEXSPACE_MESSAGE_TYPES)\n var HAEXSPACE_MESSAGE_TYPES = ${JSON.stringify(HAEXSPACE_MESSAGE_TYPES)};\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // localStorage Polyfill\n (${installLocalStoragePolyfill.toString()})();\n\n // sessionStorage Polyfill\n (${installSessionStoragePolyfill.toString()})();\n\n // Cookie Polyfill\n (${installCookiePolyfill.toString()})();\n\n // History API Polyfill\n (${installHistoryPolyfill.toString()})();\n\n // Note: Base tag is injected at build-time by Vite plugin, not at runtime\n\n console.log('[HaexSpace] All polyfills loaded successfully');\n\n // Debug diagnostics for Android debugging\n (${installDebugDiagnostics.toString()})();\n})();`\n\n return iife\n}\n","/**\n * CORS Configuration for HaexSpace Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexSpace dev servers\n *\n * Note: `Access-Control-Allow-Credentials` is intentionally NOT part of this\n * base constant. Per the CORS spec that header is incompatible with\n * `Access-Control-Allow-Origin: *` — browsers silently drop the response.\n * We only emit the credentials header when a specific (non-wildcard) origin\n * is set at runtime.\n */\nexport const HAEXSPACE_CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n} as const\n\nexport interface CorsOptions {\n /** If true, include `Access-Control-Allow-Credentials: true`. Requires a concrete origin. */\n credentials?: boolean\n}\n\nfunction isWildcardOrigin(origin: string | undefined): boolean {\n return !origin || origin === '*'\n}\n\n/**\n * Apply CORS headers to a Node.js response object\n * Used in Vite middleware\n *\n * @throws if credentials are requested with a wildcard origin\n */\nexport function applyCorsHeaders(\n res: { setHeader: (name: string, value: string) => void },\n origin?: string,\n options: CorsOptions = {}\n) {\n const effectiveOrigin = origin || '*'\n\n if (options.credentials && isWildcardOrigin(origin)) {\n throw new Error(\n '[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin.'\n )\n }\n\n res.setHeader('Access-Control-Allow-Origin', effectiveOrigin)\n res.setHeader('Access-Control-Allow-Methods', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'])\n\n if (options.credentials && !isWildcardOrigin(origin)) {\n res.setHeader('Access-Control-Allow-Credentials', 'true')\n }\n}\n\n/**\n * Get CORS headers as a plain object\n * Used in Vite/Nuxt config\n *\n * @throws if credentials are requested with a wildcard origin\n */\nexport function getCorsHeaders(\n origin?: string,\n options: CorsOptions = {}\n): Record<string, string> {\n if (options.credentials && isWildcardOrigin(origin)) {\n throw new Error(\n '[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin.'\n )\n }\n\n const headers: Record<string, string> = {\n 'Access-Control-Allow-Origin': origin || HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'],\n }\n\n if (options.credentials && !isWildcardOrigin(origin)) {\n headers['Access-Control-Allow-Credentials'] = 'true'\n }\n\n return headers\n}\n","/**\n * Vite Plugin for HaexSpace SDK\n * Automatically injects polyfills into HTML files\n * Works with React, Vue, Svelte, and any other Vite-based project\n */\nimport type { Plugin } from 'vite'\nimport { getPolyfillCode } from './polyfills/standalone'\nimport { applyCorsHeaders } from './cors'\n\nexport interface VitePluginOptions {\n /**\n * Enable/disable polyfill injection\n * @default true\n */\n injectPolyfills?: boolean\n\n /**\n * Configure CORS for dev server\n * @default true\n */\n configureCors?: boolean\n}\n\n/**\n * HaexSpace Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexspacePlugin } from '@haex-space/vault-sdk/vite'\n *\n * export default {\n * plugins: [haexspacePlugin()]\n * }\n * ```\n */\nexport function haexspacePlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haex-space/vault-sdk',\n enforce: 'post', // Run after other plugins\n\n configResolved(config) {\n if (injectPolyfills) {\n try {\n // Get polyfill code from modular polyfills\n polyfillCode = getPolyfillCode()\n console.log('✓ [@haex-space/vault-sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haex-space/vault-sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haex-space/vault-sdk] CORS configured for HaexSpace development')\n console.log(' - Allowing all origins (required for custom protocols)')\n console.log(' - Allowing credentials')\n }\n },\n\n configureServer(server) {\n if (!configureCors) return\n\n // Add CORS middleware for HaexSpace using shared CORS configuration\n server.middlewares.use((req, res, next) => {\n // Apply CORS headers (allows custom protocols like haex-extension://)\n applyCorsHeaders(res, req.headers.origin)\n\n // Handle preflight requests\n if (req.method === 'OPTIONS') {\n res.statusCode = 200\n res.end()\n return\n }\n\n next()\n })\n },\n\n transformIndexHtml: {\n order: 'pre', // Inject before other transformations\n handler(html: string) {\n if (!injectPolyfills || !polyfillCode) {\n return html\n }\n\n // Inject polyfill script directly after <head>\n const headPos = html.indexOf('<head>')\n if (headPos === -1) {\n console.warn('[@haex-space/vault-sdk] No <head> tag found in HTML')\n return html\n }\n\n const insertPos = headPos + 6 // after <head>\n\n // Inject polyfill only (no base tag needed)\n const polyfillScript = `<script>${polyfillCode}</script>`\n const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos)\n\n console.log('✓ [@haex-space/vault-sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexspacePlugin\n"]}
|
package/dist/vite.mjs
CHANGED
|
@@ -221,7 +221,24 @@ var HAEXSPACE_MESSAGE_TYPES = {
|
|
|
221
221
|
/** Debug message for development/troubleshooting */
|
|
222
222
|
DEBUG: "haexspace:debug",
|
|
223
223
|
/** Console forwarding from extension iframe */
|
|
224
|
-
CONSOLE_FORWARD: "console.forward"
|
|
224
|
+
CONSOLE_FORWARD: "console.forward",
|
|
225
|
+
/**
|
|
226
|
+
* Sent from main window to iframe on the shared window listener, carrying
|
|
227
|
+
* one `MessagePort` in `event.ports[0]`. Once received, the SDK switches
|
|
228
|
+
* to port-based messaging and never reads the window listener again.
|
|
229
|
+
*
|
|
230
|
+
* Payload: `{ type: PORT_INIT }` — no data. The port itself is the payload.
|
|
231
|
+
*/
|
|
232
|
+
PORT_INIT: "haexspace:port:init",
|
|
233
|
+
/**
|
|
234
|
+
* Sent from SDK to main window *over the MessagePort* after the port is
|
|
235
|
+
* installed. Main uses this to mark the iframe as ready and flush any
|
|
236
|
+
* events buffered during the handshake window. Only valid on the port —
|
|
237
|
+
* a READY sent over window.postMessage is ignored.
|
|
238
|
+
*
|
|
239
|
+
* Payload: `{ type: PORT_READY }` — no data.
|
|
240
|
+
*/
|
|
241
|
+
PORT_READY: "haexspace:port:ready"
|
|
225
242
|
};
|
|
226
243
|
|
|
227
244
|
// src/polyfills/debug.ts
|
|
@@ -278,14 +295,24 @@ function getPolyfillCode() {
|
|
|
278
295
|
// src/cors.ts
|
|
279
296
|
var HAEXSPACE_CORS_HEADERS = {
|
|
280
297
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
281
|
-
"Access-Control-Allow-Headers": "*"
|
|
282
|
-
"Access-Control-Allow-Credentials": "true"
|
|
298
|
+
"Access-Control-Allow-Headers": "*"
|
|
283
299
|
};
|
|
284
|
-
function
|
|
285
|
-
|
|
300
|
+
function isWildcardOrigin(origin) {
|
|
301
|
+
return !origin || origin === "*";
|
|
302
|
+
}
|
|
303
|
+
function applyCorsHeaders(res, origin, options = {}) {
|
|
304
|
+
const effectiveOrigin = origin || "*";
|
|
305
|
+
if (options.credentials && isWildcardOrigin(origin)) {
|
|
306
|
+
throw new Error(
|
|
307
|
+
"[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin."
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
res.setHeader("Access-Control-Allow-Origin", effectiveOrigin);
|
|
286
311
|
res.setHeader("Access-Control-Allow-Methods", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Methods"]);
|
|
287
312
|
res.setHeader("Access-Control-Allow-Headers", HAEXSPACE_CORS_HEADERS["Access-Control-Allow-Headers"]);
|
|
288
|
-
|
|
313
|
+
if (options.credentials && !isWildcardOrigin(origin)) {
|
|
314
|
+
res.setHeader("Access-Control-Allow-Credentials", "true");
|
|
315
|
+
}
|
|
289
316
|
}
|
|
290
317
|
|
|
291
318
|
// src/vite.ts
|
package/dist/vite.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/messages.ts","../src/polyfills/debug.ts","../src/polyfills/standalone.ts","../src/cors.ts","../src/vite.ts"],"names":[],"mappings":";AAOO,SAAS,2BAAA,GAAoC;AAClD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA;AAAA,EACF;AAEA,EAAA,OAAA,CAAQ,IAAI,kDAAkD,CAAA;AAG9D,EAAA,IAAI,iBAAA,GAAoB,KAAA;AACxB,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,aAAA;AAChB,IAAA,YAAA,CAAa,OAAA,CAAQ,SAAS,OAAO,CAAA;AACrC,IAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAC/B,IAAA,iBAAA,GAAoB,IAAA;AAAA,EACtB,CAAA,CAAA,MAAQ;AACN,I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AA,CAAY,GAAA,CAAI,CAAC,GAAA,EAAK,KAAK,IAAA,KAAS;AAEzC,QAAA,gBAAA,CAAiB,GAAA,EAAK,GAAA,CAAI,OAAA,CAAQ,MAAM,CAAA;AAGxC,QAAA,IAAI,GAAA,CAAI,WAAW,SAAA,EAAW;AAC5B,UAAA,GAAA,CAAI,UAAA,GAAa,GAAA;AACjB,UAAA,GAAA,CAAI,GAAA,EAAI;AACR,UAAA;AAAA,QACF;AAEA,QAAA,IAAA,EAAK;AAAA,MACP,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IAEA,kBAAA,EAAoB;AAAA,MAClB,KAAA,EAAO,KAAA;AAAA;AAAA,MACP,QAAQ,IAAA,EAAc;AACpB,QAAA,IAAI,CAAC,eAAA,IAAmB,CAAC,YAAA,EAAc;AACrC,UAAA,OAAO,IAAA;AAAA,QACT;AAGA,QAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,QAAQ,CAAA;AACrC,QAAA,IAAI,YAAY,EAAA,EAAI;AAClB,UAAA,OAAA,CAAQ,KAAK,qDAAqD,CAAA;AAClE,UAAA,OAAO,IAAA;AAAA,QACT;AAEA,QAAA,MAAM,YAAY,OAAA,GAAU,CAAA;AAG5B,QAAA,MAAM,cAAA,GAAiB,WAAW,YAAY,CAAA,SAAA,CAAA;AAC9C,QAAA,MAAM,YAAA,GAAe,KAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAErF,QAAA,OAAA,CAAQ,IAAI,4DAAuD,CAAA;AAEnE,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.mjs","sourcesContent":["/**\n * localStorage Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory fallback when localStorage is blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installLocalStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // Test if localStorage is available\n let localStorageWorks = false;\n try {\n const testKey = '__ls_test__';\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n localStorageWorks = true;\n } catch {\n console.warn('[HaexSpace] localStorage blocked – using in-memory fallback');\n }\n\n // If blocked: Replace with In-Memory Storage\n if (!localStorageWorks) {\n const lsStorage = new Map<string, string>();\n\n const localStoragePoly: Storage = {\n getItem(key: string): string | null {\n return lsStorage.get(key) || null;\n },\n setItem(key: string, value: string): void {\n lsStorage.set(key, String(value));\n },\n removeItem(key: string): void {\n lsStorage.delete(key);\n },\n clear(): void {\n lsStorage.clear();\n },\n get length(): number {\n return lsStorage.size;\n },\n key(index: number): string | null {\n return Array.from(lsStorage.keys())[index] || null;\n }\n };\n\n try {\n Object.defineProperty(window, 'localStorage', {\n value: localStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { localStorage: Storage }).localStorage = localStoragePoly;\n }\n\n console.log('[HaexSpace] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexSpace Extensions\n *\n * Provides a no-op implementation as session state doesn't work\n * reliably in custom protocol contexts\n */\nexport function installSessionStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n try {\n const sessionStoragePoly: Storage = {\n getItem(): null {\n return null;\n },\n setItem(): void {},\n removeItem(): void {},\n clear(): void {},\n get length(): number {\n return 0;\n },\n key(): null {\n return null;\n }\n };\n\n Object.defineProperty(window, 'sessionStorage', {\n value: sessionStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { sessionStorage: Storage }).sessionStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n clear: () => {},\n get length() { return 0; },\n key: () => null\n };\n }\n\n console.log('[HaexSpace] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory cookie implementation when cookies are blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installCookiePolyfill(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return; // Skip in Node.js environment\n }\n\n // Test if cookies are available\n let cookiesWork = false;\n try {\n document.cookie = \"__cookie_test__=1\";\n cookiesWork = document.cookie.indexOf(\"__cookie_test__\") !== -1;\n } catch {\n console.warn(\"[HaexSpace] Cookies blocked – using in-memory fallback\");\n }\n\n if (!cookiesWork) {\n const cookieStore = new Map<string, string>();\n\n Object.defineProperty(document, \"cookie\", {\n get(): string {\n const cookies: string[] = [];\n cookieStore.forEach((value, key) => {\n cookies.push(`${key}=${value}`);\n });\n return cookies.join(\"; \");\n },\n set(cookieString: string): void {\n const parts = cookieString.split(\";\").map((p) => p.trim());\n const [keyValue] = parts;\n\n if (!keyValue) return;\n\n const [key, value] = keyValue.split(\"=\");\n if (!key) return;\n\n // Parse options\n const options: Record<string, string | boolean> = {};\n for (let i = 1; i < parts.length; i++) {\n const part = parts[i];\n if (!part) continue;\n const parts_split = part.split(\"=\");\n const optKey = parts_split[0];\n const optValue = parts_split[1];\n if (optKey) {\n options[optKey.toLowerCase()] = optValue || true;\n }\n }\n\n // Check for deletion (expires in past)\n const expiresValue = options.expires;\n if (expiresValue && typeof expiresValue === \"string\") {\n const expiresDate = new Date(expiresValue);\n if (expiresDate < new Date()) {\n cookieStore.delete(key);\n return;\n }\n }\n\n // Check for max-age=0 deletion\n const maxAgeValue = options[\"max-age\"];\n if (typeof maxAgeValue === \"string\" && maxAgeValue === \"0\") {\n cookieStore.delete(key);\n return;\n }\n\n // Store cookie\n cookieStore.set(key, value || \"\");\n },\n configurable: true,\n });\n\n console.log(\"[HaexSpace] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexSpace Extensions\n *\n * Works around SecurityError when using pushState/replaceState\n * in custom protocol contexts (haex-extension://)\n *\n * Falls back to hash-based routing when necessary\n */\n\nexport function installHistoryPolyfill(): void {\n if (typeof window === 'undefined' || typeof history === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n // Install after DOM is ready to avoid race conditions\n const install = () => {\n console.log('[HaexSpace] History Patch loading');\n\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n let skipNextPush = false;\n let skipNextReplace = false;\n\n // Patch pushState\n history.pushState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexSpace] pushState skipped');\n return;\n }\n\n try {\n return originalPushState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextPush = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n // Patch replaceState\n history.replaceState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexSpace] replaceState skipped');\n return;\n }\n\n try {\n return originalReplaceState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextReplace = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n console.log('[HaexSpace] History API patched');\n };\n\n // Install after DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', install, { once: true });\n } else {\n // DOM already loaded, install immediately\n install();\n }\n}\n","/**\n * Central message type definitions for HaexSpace SDK\n *\n * Message Naming Schema: haexspace:{subject}\n *\n * These are used for internal communication between extensions and HaexSpace\n */\n\nexport const HAEXSPACE_MESSAGE_TYPES = {\n /** Debug message for development/troubleshooting */\n DEBUG: 'haexspace:debug',\n\n /** Console forwarding from extension iframe */\n CONSOLE_FORWARD: 'console.forward',\n} as const;\n\nexport type HaexspaceMessageType =\n (typeof HAEXSPACE_MESSAGE_TYPES)[keyof typeof HAEXSPACE_MESSAGE_TYPES];\n","import { HAEXSPACE_MESSAGE_TYPES } from '../messages';\n\n/**\n * Debug diagnostics for Android debugging\n * Tests window.parent availability and postMessage functionality\n */\nexport function installDebugDiagnostics(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hasParent = window.parent && window.parent !== window;\n console.log('[HaexSpace] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexSpace] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: HAEXSPACE_MESSAGE_TYPES.DEBUG,\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexSpace] Debug message sent!');\n } else {\n console.log('[HaexSpace] No parent window or parent === window');\n }\n}\n","/**\n * Generates standalone polyfill code for HTML injection\n * This wraps the modular polyfills into an IIFE for immediate execution\n */\nimport {\n installLocalStoragePolyfill,\n installSessionStoragePolyfill,\n} from './localStorage'\nimport { installCookiePolyfill } from './cookies'\nimport { installHistoryPolyfill } from './history'\nimport { installDebugDiagnostics } from './debug'\nimport { HAEXSPACE_MESSAGE_TYPES } from '../messages'\n\n/**\n * Get the standalone polyfill code as a string\n * This is used by the Nuxt and Vite plugins to inject polyfills into HTML\n *\n * Note: Base tag is injected statically by the Vite plugin, not at runtime\n */\nexport function getPolyfillCode(): string {\n // Convert functions to string and wrap in IIFE\n // We need to inject the HAEXSPACE_MESSAGE_TYPES constant since it's used by installDebugDiagnostics\n const iife = `(function() {\n 'use strict';\n\n // Message types constant (injected from HAEXSPACE_MESSAGE_TYPES)\n var HAEXSPACE_MESSAGE_TYPES = ${JSON.stringify(HAEXSPACE_MESSAGE_TYPES)};\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // localStorage Polyfill\n (${installLocalStoragePolyfill.toString()})();\n\n // sessionStorage Polyfill\n (${installSessionStoragePolyfill.toString()})();\n\n // Cookie Polyfill\n (${installCookiePolyfill.toString()})();\n\n // History API Polyfill\n (${installHistoryPolyfill.toString()})();\n\n // Note: Base tag is injected at build-time by Vite plugin, not at runtime\n\n console.log('[HaexSpace] All polyfills loaded successfully');\n\n // Debug diagnostics for Android debugging\n (${installDebugDiagnostics.toString()})();\n})();`\n\n return iife\n}\n","/**\n * CORS Configuration for HaexSpace Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexSpace dev servers\n * Allows extensions to be loaded in custom protocol iframes (haex-extension://)\n */\nexport const HAEXSPACE_CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n 'Access-Control-Allow-Credentials': 'true',\n} as const\n\n/**\n * Apply CORS headers to a Node.js response object\n * Used in Vite middleware\n */\nexport function applyCorsHeaders(\n res: { setHeader: (name: string, value: string) => void },\n origin?: string\n) {\n res.setHeader('Access-Control-Allow-Origin', origin || '*')\n res.setHeader('Access-Control-Allow-Methods', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'])\n res.setHeader('Access-Control-Allow-Credentials', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Credentials'])\n}\n\n/**\n * Get CORS headers as a plain object\n * Used in Vite/Nuxt config\n */\nexport function getCorsHeaders(origin?: string): Record<string, string> {\n return {\n 'Access-Control-Allow-Origin': origin || HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'],\n 'Access-Control-Allow-Credentials': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Credentials'],\n }\n}\n","/**\n * Vite Plugin for HaexSpace SDK\n * Automatically injects polyfills into HTML files\n * Works with React, Vue, Svelte, and any other Vite-based project\n */\nimport type { Plugin } from 'vite'\nimport { getPolyfillCode } from './polyfills/standalone'\nimport { applyCorsHeaders } from './cors'\n\nexport interface VitePluginOptions {\n /**\n * Enable/disable polyfill injection\n * @default true\n */\n injectPolyfills?: boolean\n\n /**\n * Configure CORS for dev server\n * @default true\n */\n configureCors?: boolean\n}\n\n/**\n * HaexSpace Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexspacePlugin } from '@haex-space/vault-sdk/vite'\n *\n * export default {\n * plugins: [haexspacePlugin()]\n * }\n * ```\n */\nexport function haexspacePlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haex-space/vault-sdk',\n enforce: 'post', // Run after other plugins\n\n configResolved(config) {\n if (injectPolyfills) {\n try {\n // Get polyfill code from modular polyfills\n polyfillCode = getPolyfillCode()\n console.log('✓ [@haex-space/vault-sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haex-space/vault-sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haex-space/vault-sdk] CORS configured for HaexSpace development')\n console.log(' - Allowing all origins (required for custom protocols)')\n console.log(' - Allowing credentials')\n }\n },\n\n configureServer(server) {\n if (!configureCors) return\n\n // Add CORS middleware for HaexSpace using shared CORS configuration\n server.middlewares.use((req, res, next) => {\n // Apply CORS headers (allows custom protocols like haex-extension://)\n applyCorsHeaders(res, req.headers.origin)\n\n // Handle preflight requests\n if (req.method === 'OPTIONS') {\n res.statusCode = 200\n res.end()\n return\n }\n\n next()\n })\n },\n\n transformIndexHtml: {\n order: 'pre', // Inject before other transformations\n handler(html: string) {\n if (!injectPolyfills || !polyfillCode) {\n return html\n }\n\n // Inject polyfill script directly after <head>\n const headPos = html.indexOf('<head>')\n if (headPos === -1) {\n console.warn('[@haex-space/vault-sdk] No <head> tag found in HTML')\n return html\n }\n\n const insertPos = headPos + 6 // after <head>\n\n // Inject polyfill only (no base tag needed)\n const polyfillScript = `<script>${polyfillCode}</script>`\n const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos)\n\n console.log('✓ [@haex-space/vault-sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexspacePlugin\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/polyfills/localStorage.ts","../src/polyfills/cookies.ts","../src/polyfills/history.ts","../src/messages.ts","../src/polyfills/debug.ts","../src/polyfills/standalone.ts","../src/cors.ts","../src/vite.ts"],"names":[],"mappings":";AAOO,SAAS,2BAAA,GAAoC;AAClD,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AACjC,IAAA;AAAA,EACF;AAEA,EAAA,OAAA,CAAQ,IAAI,kDAAkD,CAAA;AAG9D,EAAA,IAAI,iBAAA,GAAoB,KAAA;AACxB,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,aAAA;AAChB,IAAA,YAAA,CAAa,OAAA,CAAQ,SAAS,OAAO,CAAA;AACrC,IAAA,YAAA,CAAa,WAAW,OAAO,CAAA;AAC/B,IAAA,iBAAA,GAAoB,IAAA;AAAA,EACtB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAA,CAAQ,KAAK,kEAA6D,CAAA;AAA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,CAAA,SAAA,CAAA;AAC9C,QAAA,MAAM,YAAA,GAAe,KAAK,KAAA,CAAM,CAAA,EAAG,SAAS,CAAA,GAAI,cAAA,GAAiB,IAAA,CAAK,KAAA,CAAM,SAAS,CAAA;AAErF,QAAA,OAAA,CAAQ,IAAI,4DAAuD,CAAA;AAEnE,QAAA,OAAO,YAAA;AAAA,MACT;AAAA;AACF,GACF;AACF;AAGA,IAAO,YAAA,GAAQ","file":"vite.mjs","sourcesContent":["/**\n * localStorage Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory fallback when localStorage is blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installLocalStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // Test if localStorage is available\n let localStorageWorks = false;\n try {\n const testKey = '__ls_test__';\n localStorage.setItem(testKey, testKey);\n localStorage.removeItem(testKey);\n localStorageWorks = true;\n } catch {\n console.warn('[HaexSpace] localStorage blocked – using in-memory fallback');\n }\n\n // If blocked: Replace with In-Memory Storage\n if (!localStorageWorks) {\n const lsStorage = new Map<string, string>();\n\n const localStoragePoly: Storage = {\n getItem(key: string): string | null {\n return lsStorage.get(key) || null;\n },\n setItem(key: string, value: string): void {\n lsStorage.set(key, String(value));\n },\n removeItem(key: string): void {\n lsStorage.delete(key);\n },\n clear(): void {\n lsStorage.clear();\n },\n get length(): number {\n return lsStorage.size;\n },\n key(index: number): string | null {\n return Array.from(lsStorage.keys())[index] || null;\n }\n };\n\n try {\n Object.defineProperty(window, 'localStorage', {\n value: localStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { localStorage: Storage }).localStorage = localStoragePoly;\n }\n\n console.log('[HaexSpace] localStorage replaced with in-memory polyfill');\n }\n}\n\n/**\n * sessionStorage Polyfill for HaexSpace Extensions\n *\n * Provides a no-op implementation as session state doesn't work\n * reliably in custom protocol contexts\n */\nexport function installSessionStoragePolyfill(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n try {\n const sessionStoragePoly: Storage = {\n getItem(): null {\n return null;\n },\n setItem(): void {},\n removeItem(): void {},\n clear(): void {},\n get length(): number {\n return 0;\n },\n key(): null {\n return null;\n }\n };\n\n Object.defineProperty(window, 'sessionStorage', {\n value: sessionStoragePoly,\n writable: true,\n configurable: true\n });\n } catch {\n // Fallback: Direct assignment\n (window as unknown as { sessionStorage: Storage }).sessionStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n clear: () => {},\n get length() { return 0; },\n key: () => null\n };\n }\n\n console.log('[HaexSpace] sessionStorage polyfill installed');\n}\n","/**\n * Cookie Polyfill for HaexSpace Extensions\n *\n * Provides an in-memory cookie implementation when cookies are blocked\n * due to custom protocol restrictions (haex-extension://)\n */\n\nexport function installCookiePolyfill(): void {\n if (typeof window === \"undefined\" || typeof document === \"undefined\") {\n return; // Skip in Node.js environment\n }\n\n // Test if cookies are available\n let cookiesWork = false;\n try {\n document.cookie = \"__cookie_test__=1\";\n cookiesWork = document.cookie.indexOf(\"__cookie_test__\") !== -1;\n } catch {\n console.warn(\"[HaexSpace] Cookies blocked – using in-memory fallback\");\n }\n\n if (!cookiesWork) {\n const cookieStore = new Map<string, string>();\n\n Object.defineProperty(document, \"cookie\", {\n get(): string {\n const cookies: string[] = [];\n cookieStore.forEach((value, key) => {\n cookies.push(`${key}=${value}`);\n });\n return cookies.join(\"; \");\n },\n set(cookieString: string): void {\n const parts = cookieString.split(\";\").map((p) => p.trim());\n const [keyValue] = parts;\n\n if (!keyValue) return;\n\n const [key, value] = keyValue.split(\"=\");\n if (!key) return;\n\n // Parse options\n const options: Record<string, string | boolean> = {};\n for (let i = 1; i < parts.length; i++) {\n const part = parts[i];\n if (!part) continue;\n const parts_split = part.split(\"=\");\n const optKey = parts_split[0];\n const optValue = parts_split[1];\n if (optKey) {\n options[optKey.toLowerCase()] = optValue || true;\n }\n }\n\n // Check for deletion (expires in past)\n const expiresValue = options.expires;\n if (expiresValue && typeof expiresValue === \"string\") {\n const expiresDate = new Date(expiresValue);\n if (expiresDate < new Date()) {\n cookieStore.delete(key);\n return;\n }\n }\n\n // Check for max-age=0 deletion\n const maxAgeValue = options[\"max-age\"];\n if (typeof maxAgeValue === \"string\" && maxAgeValue === \"0\") {\n cookieStore.delete(key);\n return;\n }\n\n // Store cookie\n cookieStore.set(key, value || \"\");\n },\n configurable: true,\n });\n\n console.log(\"[HaexSpace] Cookie polyfill installed\");\n }\n}\n","/**\n * History API Polyfill for HaexSpace Extensions\n *\n * Works around SecurityError when using pushState/replaceState\n * in custom protocol contexts (haex-extension://)\n *\n * Falls back to hash-based routing when necessary\n */\n\nexport function installHistoryPolyfill(): void {\n if (typeof window === 'undefined' || typeof history === 'undefined') {\n return; // Skip in Node.js environment\n }\n\n // Install after DOM is ready to avoid race conditions\n const install = () => {\n console.log('[HaexSpace] History Patch loading');\n\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n let skipNextPush = false;\n let skipNextReplace = false;\n\n // Patch pushState\n history.pushState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] pushState called:', url, 'skip:', skipNextPush);\n\n if (skipNextPush) {\n skipNextPush = false;\n console.log('[HaexSpace] pushState skipped');\n return;\n }\n\n try {\n return originalPushState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextPush = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n // Patch replaceState\n history.replaceState = function(\n state: any,\n title: string,\n url?: string | URL | null\n ): void {\n console.log('[HaexSpace] replaceState called:', url, 'skip:', skipNextReplace);\n\n if (skipNextReplace) {\n skipNextReplace = false;\n console.log('[HaexSpace] replaceState skipped');\n return;\n }\n\n try {\n return originalReplaceState.call(this, state, title, url);\n } catch (e) {\n if ((e as Error).name === 'SecurityError' && url) {\n // Remove duplicate /#/ prefix\n const urlString = url.toString();\n let hashUrl = urlString.replace(/^\\/#/, '');\n hashUrl = hashUrl.startsWith('#') ? hashUrl : '#' + hashUrl;\n console.log('[HaexSpace] SecurityError - setting hash to:', hashUrl);\n skipNextReplace = true;\n window.location.hash = hashUrl.replace(/^#/, '');\n return; // Silent fallback\n }\n throw e;\n }\n };\n\n console.log('[HaexSpace] History API patched');\n };\n\n // Install after DOM is ready\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', install, { once: true });\n } else {\n // DOM already loaded, install immediately\n install();\n }\n}\n","/**\n * Central message type definitions for HaexSpace SDK\n *\n * Message Naming Schema: haexspace:{subject}\n *\n * These are used for internal communication between extensions and HaexSpace\n */\n\nexport const HAEXSPACE_MESSAGE_TYPES = {\n /** Debug message for development/troubleshooting */\n DEBUG: 'haexspace:debug',\n\n /** Console forwarding from extension iframe */\n CONSOLE_FORWARD: 'console.forward',\n\n /**\n * Sent from main window to iframe on the shared window listener, carrying\n * one `MessagePort` in `event.ports[0]`. Once received, the SDK switches\n * to port-based messaging and never reads the window listener again.\n *\n * Payload: `{ type: PORT_INIT }` — no data. The port itself is the payload.\n */\n PORT_INIT: 'haexspace:port:init',\n\n /**\n * Sent from SDK to main window *over the MessagePort* after the port is\n * installed. Main uses this to mark the iframe as ready and flush any\n * events buffered during the handshake window. Only valid on the port —\n * a READY sent over window.postMessage is ignored.\n *\n * Payload: `{ type: PORT_READY }` — no data.\n */\n PORT_READY: 'haexspace:port:ready',\n} as const;\n\nexport type HaexspaceMessageType =\n (typeof HAEXSPACE_MESSAGE_TYPES)[keyof typeof HAEXSPACE_MESSAGE_TYPES];\n","import { HAEXSPACE_MESSAGE_TYPES } from '../messages';\n\n/**\n * Debug diagnostics for Android debugging\n * Tests window.parent availability and postMessage functionality\n */\nexport function installDebugDiagnostics(): void {\n if (typeof window === 'undefined') {\n return;\n }\n\n const hasParent = window.parent && window.parent !== window;\n console.log('[HaexSpace] hasParent:', hasParent);\n\n if (hasParent) {\n console.log('[HaexSpace] Attempting to send debug message to parent...');\n window.parent.postMessage({\n type: HAEXSPACE_MESSAGE_TYPES.DEBUG,\n data: `[Polyfills] window.parent test: exists=${!!window.parent}, different=${hasParent}, selfIsTop=${window.self === window.top}`\n }, '*');\n console.log('[HaexSpace] Debug message sent!');\n } else {\n console.log('[HaexSpace] No parent window or parent === window');\n }\n}\n","/**\n * Generates standalone polyfill code for HTML injection\n * This wraps the modular polyfills into an IIFE for immediate execution\n */\nimport {\n installLocalStoragePolyfill,\n installSessionStoragePolyfill,\n} from './localStorage'\nimport { installCookiePolyfill } from './cookies'\nimport { installHistoryPolyfill } from './history'\nimport { installDebugDiagnostics } from './debug'\nimport { HAEXSPACE_MESSAGE_TYPES } from '../messages'\n\n/**\n * Get the standalone polyfill code as a string\n * This is used by the Nuxt and Vite plugins to inject polyfills into HTML\n *\n * Note: Base tag is injected statically by the Vite plugin, not at runtime\n */\nexport function getPolyfillCode(): string {\n // Convert functions to string and wrap in IIFE\n // We need to inject the HAEXSPACE_MESSAGE_TYPES constant since it's used by installDebugDiagnostics\n const iife = `(function() {\n 'use strict';\n\n // Message types constant (injected from HAEXSPACE_MESSAGE_TYPES)\n var HAEXSPACE_MESSAGE_TYPES = ${JSON.stringify(HAEXSPACE_MESSAGE_TYPES)};\n\n console.log('[HaexSpace] Storage Polyfill loading immediately');\n\n // localStorage Polyfill\n (${installLocalStoragePolyfill.toString()})();\n\n // sessionStorage Polyfill\n (${installSessionStoragePolyfill.toString()})();\n\n // Cookie Polyfill\n (${installCookiePolyfill.toString()})();\n\n // History API Polyfill\n (${installHistoryPolyfill.toString()})();\n\n // Note: Base tag is injected at build-time by Vite plugin, not at runtime\n\n console.log('[HaexSpace] All polyfills loaded successfully');\n\n // Debug diagnostics for Android debugging\n (${installDebugDiagnostics.toString()})();\n})();`\n\n return iife\n}\n","/**\n * CORS Configuration for HaexSpace Extensions\n * Used by both Vite and Nuxt plugins to ensure consistent CORS headers\n */\n\n/**\n * Standard CORS headers for HaexSpace dev servers\n *\n * Note: `Access-Control-Allow-Credentials` is intentionally NOT part of this\n * base constant. Per the CORS spec that header is incompatible with\n * `Access-Control-Allow-Origin: *` — browsers silently drop the response.\n * We only emit the credentials header when a specific (non-wildcard) origin\n * is set at runtime.\n */\nexport const HAEXSPACE_CORS_HEADERS = {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',\n 'Access-Control-Allow-Headers': '*',\n} as const\n\nexport interface CorsOptions {\n /** If true, include `Access-Control-Allow-Credentials: true`. Requires a concrete origin. */\n credentials?: boolean\n}\n\nfunction isWildcardOrigin(origin: string | undefined): boolean {\n return !origin || origin === '*'\n}\n\n/**\n * Apply CORS headers to a Node.js response object\n * Used in Vite middleware\n *\n * @throws if credentials are requested with a wildcard origin\n */\nexport function applyCorsHeaders(\n res: { setHeader: (name: string, value: string) => void },\n origin?: string,\n options: CorsOptions = {}\n) {\n const effectiveOrigin = origin || '*'\n\n if (options.credentials && isWildcardOrigin(origin)) {\n throw new Error(\n '[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin.'\n )\n }\n\n res.setHeader('Access-Control-Allow-Origin', effectiveOrigin)\n res.setHeader('Access-Control-Allow-Methods', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'])\n res.setHeader('Access-Control-Allow-Headers', HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'])\n\n if (options.credentials && !isWildcardOrigin(origin)) {\n res.setHeader('Access-Control-Allow-Credentials', 'true')\n }\n}\n\n/**\n * Get CORS headers as a plain object\n * Used in Vite/Nuxt config\n *\n * @throws if credentials are requested with a wildcard origin\n */\nexport function getCorsHeaders(\n origin?: string,\n options: CorsOptions = {}\n): Record<string, string> {\n if (options.credentials && isWildcardOrigin(origin)) {\n throw new Error(\n '[@haex-space/vault-sdk] CORS: credentials=true cannot be combined with a wildcard origin. Pass a specific origin.'\n )\n }\n\n const headers: Record<string, string> = {\n 'Access-Control-Allow-Origin': origin || HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Origin'],\n 'Access-Control-Allow-Methods': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Methods'],\n 'Access-Control-Allow-Headers': HAEXSPACE_CORS_HEADERS['Access-Control-Allow-Headers'],\n }\n\n if (options.credentials && !isWildcardOrigin(origin)) {\n headers['Access-Control-Allow-Credentials'] = 'true'\n }\n\n return headers\n}\n","/**\n * Vite Plugin for HaexSpace SDK\n * Automatically injects polyfills into HTML files\n * Works with React, Vue, Svelte, and any other Vite-based project\n */\nimport type { Plugin } from 'vite'\nimport { getPolyfillCode } from './polyfills/standalone'\nimport { applyCorsHeaders } from './cors'\n\nexport interface VitePluginOptions {\n /**\n * Enable/disable polyfill injection\n * @default true\n */\n injectPolyfills?: boolean\n\n /**\n * Configure CORS for dev server\n * @default true\n */\n configureCors?: boolean\n}\n\n/**\n * HaexSpace Vite Plugin\n * Injects browser API polyfills for extensions running in custom protocols\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { haexspacePlugin } from '@haex-space/vault-sdk/vite'\n *\n * export default {\n * plugins: [haexspacePlugin()]\n * }\n * ```\n */\nexport function haexspacePlugin(options: VitePluginOptions = {}): Plugin {\n const { injectPolyfills = true, configureCors = true } = options\n\n let polyfillCode: string | null = null\n\n return {\n name: '@haex-space/vault-sdk',\n enforce: 'post', // Run after other plugins\n\n configResolved(config) {\n if (injectPolyfills) {\n try {\n // Get polyfill code from modular polyfills\n polyfillCode = getPolyfillCode()\n console.log('✓ [@haex-space/vault-sdk] Polyfills initialized')\n } catch (error) {\n console.error('[@haex-space/vault-sdk] Failed to initialize:', error)\n throw error\n }\n }\n\n // Log CORS configuration\n if (configureCors && config.command === 'serve') {\n console.log('✓ [@haex-space/vault-sdk] CORS configured for HaexSpace development')\n console.log(' - Allowing all origins (required for custom protocols)')\n console.log(' - Allowing credentials')\n }\n },\n\n configureServer(server) {\n if (!configureCors) return\n\n // Add CORS middleware for HaexSpace using shared CORS configuration\n server.middlewares.use((req, res, next) => {\n // Apply CORS headers (allows custom protocols like haex-extension://)\n applyCorsHeaders(res, req.headers.origin)\n\n // Handle preflight requests\n if (req.method === 'OPTIONS') {\n res.statusCode = 200\n res.end()\n return\n }\n\n next()\n })\n },\n\n transformIndexHtml: {\n order: 'pre', // Inject before other transformations\n handler(html: string) {\n if (!injectPolyfills || !polyfillCode) {\n return html\n }\n\n // Inject polyfill script directly after <head>\n const headPos = html.indexOf('<head>')\n if (headPos === -1) {\n console.warn('[@haex-space/vault-sdk] No <head> tag found in HTML')\n return html\n }\n\n const insertPos = headPos + 6 // after <head>\n\n // Inject polyfill only (no base tag needed)\n const polyfillScript = `<script>${polyfillCode}</script>`\n const modifiedHtml = html.slice(0, insertPos) + polyfillScript + html.slice(insertPos)\n\n console.log('✓ [@haex-space/vault-sdk] Polyfill injected into HTML')\n\n return modifiedHtml\n }\n }\n }\n}\n\n// Default export for convenience\nexport default haexspacePlugin\n"]}
|
package/dist/vue.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { H as HaexVaultSdk, S as StorageAPI } from './client-
|
|
1
|
+
import { H as HaexVaultSdk, S as StorageAPI } from './client-GeColu97.mjs';
|
|
2
2
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
|
-
import { H as HaexHubConfig } from './types-
|
|
4
|
+
import { H as HaexHubConfig } from './types-CDMBvvjl.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Vue 3 composable for HaexVault SDK
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { H as HaexVaultSdk, S as StorageAPI } from './client-
|
|
1
|
+
import { H as HaexVaultSdk, S as StorageAPI } from './client-z1jTcuQE.js';
|
|
2
2
|
import * as drizzle_orm_sqlite_proxy from 'drizzle-orm/sqlite-proxy';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
|
-
import { H as HaexHubConfig } from './types-
|
|
4
|
+
import { H as HaexHubConfig } from './types-CDMBvvjl.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Vue 3 composable for HaexVault SDK
|