@haex-space/vault-sdk 4.1.0 → 4.3.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.
Files changed (55) hide show
  1. package/README.md +69 -0
  2. package/dist/cli/index.js +2 -1
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli/index.mjs +2 -1
  5. package/dist/cli/index.mjs.map +1 -1
  6. package/dist/{client-Cx4ZyQFL.d.mts → client-CDox5_KH.d.mts} +263 -27
  7. package/dist/{client-CD5QZi7F.d.ts → client-pppDo5Q3.d.ts} +263 -27
  8. package/dist/haex_bundle_bg.wasm +0 -0
  9. package/dist/index.d.mts +45 -6
  10. package/dist/index.d.ts +45 -6
  11. package/dist/index.js +363 -14
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +360 -15
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/node.d.mts +1 -1
  16. package/dist/node.d.ts +1 -1
  17. package/dist/node.js +2 -1
  18. package/dist/node.js.map +1 -1
  19. package/dist/node.mjs +2 -1
  20. package/dist/node.mjs.map +1 -1
  21. package/dist/nuxt.js +10 -2
  22. package/dist/nuxt.js.map +1 -1
  23. package/dist/nuxt.mjs +10 -2
  24. package/dist/nuxt.mjs.map +1 -1
  25. package/dist/react.d.mts +2 -2
  26. package/dist/react.d.ts +2 -2
  27. package/dist/react.js +339 -14
  28. package/dist/react.js.map +1 -1
  29. package/dist/react.mjs +339 -14
  30. package/dist/react.mjs.map +1 -1
  31. package/dist/runtime/nuxt.plugin.client.d.mts +2 -2
  32. package/dist/runtime/nuxt.plugin.client.d.ts +2 -2
  33. package/dist/runtime/nuxt.plugin.client.js +329 -14
  34. package/dist/runtime/nuxt.plugin.client.js.map +1 -1
  35. package/dist/runtime/nuxt.plugin.client.mjs +329 -14
  36. package/dist/runtime/nuxt.plugin.client.mjs.map +1 -1
  37. package/dist/svelte.d.mts +2 -2
  38. package/dist/svelte.d.ts +2 -2
  39. package/dist/svelte.js +339 -14
  40. package/dist/svelte.js.map +1 -1
  41. package/dist/svelte.mjs +339 -14
  42. package/dist/svelte.mjs.map +1 -1
  43. package/dist/{types-BwFKGH70.d.mts → types-DoNvKiW_.d.mts} +75 -1
  44. package/dist/{types-BwFKGH70.d.ts → types-DoNvKiW_.d.ts} +75 -1
  45. package/dist/vite.js +8 -1
  46. package/dist/vite.js.map +1 -1
  47. package/dist/vite.mjs +8 -1
  48. package/dist/vite.mjs.map +1 -1
  49. package/dist/vue.d.mts +2 -2
  50. package/dist/vue.d.ts +2 -2
  51. package/dist/vue.js +339 -14
  52. package/dist/vue.js.map +1 -1
  53. package/dist/vue.mjs +339 -14
  54. package/dist/vue.mjs.map +1 -1
  55. package/package.json +1 -1
@@ -156,6 +156,39 @@ declare enum PermissionErrorCode {
156
156
  /** Permission prompt is required - user has not yet granted or denied */
157
157
  PROMPT_REQUIRED = 1004
158
158
  }
159
+ /**
160
+ * Numeric `code` of an error the host answers a request with
161
+ * (`{ code, message, details? }`), as holzi sends it. The permission codes are
162
+ * the same as in {@link PermissionErrorCode}.
163
+ */
164
+ declare enum HostErrorCode {
165
+ /** A request that cannot be attributed, a blocked path, an unknown frame */
166
+ SECURITY_VIOLATION = 1000,
167
+ NOT_FOUND = 1001,
168
+ /** {@link PermissionErrorCode.DENIED} */
169
+ PERMISSION_DENIED = 1002,
170
+ /** {@link PermissionErrorCode.PROMPT_REQUIRED}: the SDK waits for the answer and retries */
171
+ PERMISSION_PROMPT_REQUIRED = 1004,
172
+ DATABASE = 2000,
173
+ FILESYSTEM = 2001,
174
+ /** Network or provider error; `details.kind` names the kind (e.g. `accessDenied`, `network`, `bucketMissing`) */
175
+ HTTP = 2002,
176
+ SHELL = 2003,
177
+ WEB = 2005,
178
+ MANIFEST = 3000,
179
+ /** Invalid parameters (e.g. a path, an unknown identifier) */
180
+ VALIDATION = 3001,
181
+ /** An entry of an encrypted folder failed its integrity checks and cannot be read */
182
+ ENCRYPTED_DATA_DAMAGED = 3010,
183
+ /** Size, run time, rows or concurrent requests over the host's limit */
184
+ LIMIT_EXCEEDED = 7000,
185
+ /** The method is unknown or deliberately not offered */
186
+ NOT_SUPPORTED = 8000,
187
+ /** The function does not exist on this device or in this build */
188
+ NOT_AVAILABLE = 8001,
189
+ /** The extension is disabled */
190
+ DISABLED = 8002
191
+ }
159
192
  /**
160
193
  * Base interface for permission errors from haex-vault
161
194
  */
@@ -164,6 +197,10 @@ interface PermissionErrorBase {
164
197
  message: string;
165
198
  extensionId: string;
166
199
  extensionName: string;
200
+ /**
201
+ * Permission kind, e.g. `web`, `remoteStorage` or `encryptedFolder` (target
202
+ * `<storageId>/<folderId>`, actions `read` / `readWrite`).
203
+ */
167
204
  resourceType: string;
168
205
  target: string;
169
206
  action: string;
@@ -311,6 +348,36 @@ interface ManifestI18nEntry {
311
348
  name?: string | null;
312
349
  description?: string | null;
313
350
  }
351
+ /** How a tool affects the user's data; the host's approval follows it (holzi spec 018). */
352
+ type ManifestToolEffect = "read" | "change" | "destructive";
353
+ /**
354
+ * A tool an extension offers to the agent of its host, declared in the signed manifest and served
355
+ * by `sdk.tools` (holzi spec 018, `contracts/manifest-tools.md`). The bundle check enforces the
356
+ * limits: a name of `[a-z][a-z0-9_]{0,31}`, titles of 1–80 characters, a description of 1–1024,
357
+ * 1–10 examples per language of 1–200 characters each, at most 32 tools. The manifest is canonical
358
+ * JSON without fractions, so the schema holds integers only.
359
+ */
360
+ interface ManifestTool {
361
+ /** Unique within the extension. */
362
+ name: string;
363
+ /** Shown to the user, for example in the install dialog and the approval prompt. */
364
+ title: {
365
+ de: string;
366
+ en: string;
367
+ };
368
+ /** For the model: what the tool does and when to use it, in English. */
369
+ description: string;
370
+ /** JSON schema of the input; `type` is always `"object"`. */
371
+ inputSchema: {
372
+ type: "object";
373
+ } & Record<string, unknown>;
374
+ effect: ManifestToolEffect;
375
+ /** Sentences a user would ask the tool with; the host matches messages against them. */
376
+ examples: {
377
+ de: string[];
378
+ en: string[];
379
+ };
380
+ }
314
381
  interface ExtensionManifest {
315
382
  name: string;
316
383
  /** Human-readable display name. Falls back to `name` when absent. */
@@ -320,6 +387,11 @@ interface ExtensionManifest {
320
387
  entry?: string | null;
321
388
  icon?: string | null;
322
389
  publicKey: string;
390
+ /**
391
+ * Permissions the extension declares. Runtime-only kinds such as
392
+ * `encryptedFolder` are granted by the user while the extension runs and
393
+ * can never be declared here: the host refuses such a manifest.
394
+ */
323
395
  permissions: {
324
396
  database?: any[];
325
397
  filesystem?: any[];
@@ -342,6 +414,8 @@ interface ExtensionManifest {
342
414
  * Key is locale code (e.g. "de", "en"), value contains localized fields.
343
415
  */
344
416
  i18n?: Record<string, ManifestI18nEntry> | null;
417
+ /** Tools the extension offers to the agent of its host (holzi spec 018). */
418
+ tools?: ManifestTool[] | null;
345
419
  }
346
420
  interface HaexHubConfig {
347
421
  debug?: boolean;
@@ -423,4 +497,4 @@ declare class HaexVaultSdkError extends Error {
423
497
  };
424
498
  }
425
499
 
426
- export { TABLE_SEPARATOR as $, type ApplicationContext as A, MAIL_EVENTS as B, type ClaimRequirement as C, type DatabaseQueryResult as D, type ExtensionInfo as E, type FileChangeEvent as F, type MailEvent as G, type HaexHubConfig as H, type IdentityClaim as I, type ManifestI18nEntry as J, type NotificationEvent as K, type PermissionDeniedError as L, type Migration as M, NOTIFICATION_EVENTS as N, type PermissionErrorBase as O, type PermissionResponse as P, PermissionErrorCode as Q, type RequestOptions as R, type SearchResult as S, type PermissionPromptError as T, PermissionStatus as U, SHELL_EVENTS as V, type WebRequestOptions as W, type SearchQuery as X, type SearchRequestEvent as Y, type ShellEvent as Z, type SyncTablesUpdatedEvent as _, type ExtensionManifest as a, getTableName as a0, isPermissionDeniedError as a1, isPermissionError as a2, isPermissionPromptError as a3, type HaexHubEvent as b, EXTERNAL_EVENTS as c, type MigrationResult as d, type WebResponse as e, type EventCallback as f, type DatabasePermissionRequest as g, type SignedClaimPresentation as h, type ContextChangedEvent as i, DEFAULT_TIMEOUT as j, type DatabaseColumnInfo as k, type DatabaseExecuteParams as l, type DatabasePermission as m, type DatabaseQueryParams as n, type DatabaseTableInfo as o, ErrorCode as p, type ExtensionRuntimeMode as q, type ExternalEvent as r, type FileChangePayload as s, type FileChangeType as t, type FilteredSyncTablesResult as u, HAEXTENSION_EVENTS as v, type HaexHubRequest as w, type HaexHubResponse as x, HaexVaultSdkError as y, type HaextensionEvent as z };
500
+ export { type SearchRequestEvent as $, type ApplicationContext as A, HostErrorCode as B, type ClaimRequirement as C, type DatabaseQueryResult as D, type ExtensionInfo as E, type FileChangeEvent as F, MAIL_EVENTS as G, type HaexHubConfig as H, type IdentityClaim as I, type MailEvent as J, type ManifestI18nEntry as K, type ManifestTool as L, type Migration as M, type ManifestToolEffect as N, NOTIFICATION_EVENTS as O, type PermissionResponse as P, type NotificationEvent as Q, type RequestOptions as R, type SearchResult as S, type PermissionDeniedError as T, type PermissionErrorBase as U, PermissionErrorCode as V, type WebRequestOptions as W, type PermissionPromptError as X, PermissionStatus as Y, SHELL_EVENTS as Z, type SearchQuery as _, type ExtensionManifest as a, type ShellEvent as a0, type SyncTablesUpdatedEvent as a1, TABLE_SEPARATOR as a2, getTableName as a3, isPermissionDeniedError as a4, isPermissionError as a5, isPermissionPromptError as a6, type HaexHubEvent as b, EXTERNAL_EVENTS as c, type MigrationResult as d, type WebResponse as e, type EventCallback as f, type DatabasePermissionRequest as g, type SignedClaimPresentation as h, type ContextChangedEvent as i, DEFAULT_TIMEOUT as j, type DatabaseColumnInfo as k, type DatabaseExecuteParams as l, type DatabasePermission as m, type DatabaseQueryParams as n, type DatabaseTableInfo as o, ErrorCode as p, type ExtensionRuntimeMode as q, type ExternalEvent as r, type FileChangePayload as s, type FileChangeType as t, type FilteredSyncTablesResult as u, HAEXTENSION_EVENTS as v, type HaexHubRequest as w, type HaexHubResponse as x, HaexVaultSdkError as y, type HaextensionEvent as z };
@@ -156,6 +156,39 @@ declare enum PermissionErrorCode {
156
156
  /** Permission prompt is required - user has not yet granted or denied */
157
157
  PROMPT_REQUIRED = 1004
158
158
  }
159
+ /**
160
+ * Numeric `code` of an error the host answers a request with
161
+ * (`{ code, message, details? }`), as holzi sends it. The permission codes are
162
+ * the same as in {@link PermissionErrorCode}.
163
+ */
164
+ declare enum HostErrorCode {
165
+ /** A request that cannot be attributed, a blocked path, an unknown frame */
166
+ SECURITY_VIOLATION = 1000,
167
+ NOT_FOUND = 1001,
168
+ /** {@link PermissionErrorCode.DENIED} */
169
+ PERMISSION_DENIED = 1002,
170
+ /** {@link PermissionErrorCode.PROMPT_REQUIRED}: the SDK waits for the answer and retries */
171
+ PERMISSION_PROMPT_REQUIRED = 1004,
172
+ DATABASE = 2000,
173
+ FILESYSTEM = 2001,
174
+ /** Network or provider error; `details.kind` names the kind (e.g. `accessDenied`, `network`, `bucketMissing`) */
175
+ HTTP = 2002,
176
+ SHELL = 2003,
177
+ WEB = 2005,
178
+ MANIFEST = 3000,
179
+ /** Invalid parameters (e.g. a path, an unknown identifier) */
180
+ VALIDATION = 3001,
181
+ /** An entry of an encrypted folder failed its integrity checks and cannot be read */
182
+ ENCRYPTED_DATA_DAMAGED = 3010,
183
+ /** Size, run time, rows or concurrent requests over the host's limit */
184
+ LIMIT_EXCEEDED = 7000,
185
+ /** The method is unknown or deliberately not offered */
186
+ NOT_SUPPORTED = 8000,
187
+ /** The function does not exist on this device or in this build */
188
+ NOT_AVAILABLE = 8001,
189
+ /** The extension is disabled */
190
+ DISABLED = 8002
191
+ }
159
192
  /**
160
193
  * Base interface for permission errors from haex-vault
161
194
  */
@@ -164,6 +197,10 @@ interface PermissionErrorBase {
164
197
  message: string;
165
198
  extensionId: string;
166
199
  extensionName: string;
200
+ /**
201
+ * Permission kind, e.g. `web`, `remoteStorage` or `encryptedFolder` (target
202
+ * `<storageId>/<folderId>`, actions `read` / `readWrite`).
203
+ */
167
204
  resourceType: string;
168
205
  target: string;
169
206
  action: string;
@@ -311,6 +348,36 @@ interface ManifestI18nEntry {
311
348
  name?: string | null;
312
349
  description?: string | null;
313
350
  }
351
+ /** How a tool affects the user's data; the host's approval follows it (holzi spec 018). */
352
+ type ManifestToolEffect = "read" | "change" | "destructive";
353
+ /**
354
+ * A tool an extension offers to the agent of its host, declared in the signed manifest and served
355
+ * by `sdk.tools` (holzi spec 018, `contracts/manifest-tools.md`). The bundle check enforces the
356
+ * limits: a name of `[a-z][a-z0-9_]{0,31}`, titles of 1–80 characters, a description of 1–1024,
357
+ * 1–10 examples per language of 1–200 characters each, at most 32 tools. The manifest is canonical
358
+ * JSON without fractions, so the schema holds integers only.
359
+ */
360
+ interface ManifestTool {
361
+ /** Unique within the extension. */
362
+ name: string;
363
+ /** Shown to the user, for example in the install dialog and the approval prompt. */
364
+ title: {
365
+ de: string;
366
+ en: string;
367
+ };
368
+ /** For the model: what the tool does and when to use it, in English. */
369
+ description: string;
370
+ /** JSON schema of the input; `type` is always `"object"`. */
371
+ inputSchema: {
372
+ type: "object";
373
+ } & Record<string, unknown>;
374
+ effect: ManifestToolEffect;
375
+ /** Sentences a user would ask the tool with; the host matches messages against them. */
376
+ examples: {
377
+ de: string[];
378
+ en: string[];
379
+ };
380
+ }
314
381
  interface ExtensionManifest {
315
382
  name: string;
316
383
  /** Human-readable display name. Falls back to `name` when absent. */
@@ -320,6 +387,11 @@ interface ExtensionManifest {
320
387
  entry?: string | null;
321
388
  icon?: string | null;
322
389
  publicKey: string;
390
+ /**
391
+ * Permissions the extension declares. Runtime-only kinds such as
392
+ * `encryptedFolder` are granted by the user while the extension runs and
393
+ * can never be declared here: the host refuses such a manifest.
394
+ */
323
395
  permissions: {
324
396
  database?: any[];
325
397
  filesystem?: any[];
@@ -342,6 +414,8 @@ interface ExtensionManifest {
342
414
  * Key is locale code (e.g. "de", "en"), value contains localized fields.
343
415
  */
344
416
  i18n?: Record<string, ManifestI18nEntry> | null;
417
+ /** Tools the extension offers to the agent of its host (holzi spec 018). */
418
+ tools?: ManifestTool[] | null;
345
419
  }
346
420
  interface HaexHubConfig {
347
421
  debug?: boolean;
@@ -423,4 +497,4 @@ declare class HaexVaultSdkError extends Error {
423
497
  };
424
498
  }
425
499
 
426
- export { TABLE_SEPARATOR as $, type ApplicationContext as A, MAIL_EVENTS as B, type ClaimRequirement as C, type DatabaseQueryResult as D, type ExtensionInfo as E, type FileChangeEvent as F, type MailEvent as G, type HaexHubConfig as H, type IdentityClaim as I, type ManifestI18nEntry as J, type NotificationEvent as K, type PermissionDeniedError as L, type Migration as M, NOTIFICATION_EVENTS as N, type PermissionErrorBase as O, type PermissionResponse as P, PermissionErrorCode as Q, type RequestOptions as R, type SearchResult as S, type PermissionPromptError as T, PermissionStatus as U, SHELL_EVENTS as V, type WebRequestOptions as W, type SearchQuery as X, type SearchRequestEvent as Y, type ShellEvent as Z, type SyncTablesUpdatedEvent as _, type ExtensionManifest as a, getTableName as a0, isPermissionDeniedError as a1, isPermissionError as a2, isPermissionPromptError as a3, type HaexHubEvent as b, EXTERNAL_EVENTS as c, type MigrationResult as d, type WebResponse as e, type EventCallback as f, type DatabasePermissionRequest as g, type SignedClaimPresentation as h, type ContextChangedEvent as i, DEFAULT_TIMEOUT as j, type DatabaseColumnInfo as k, type DatabaseExecuteParams as l, type DatabasePermission as m, type DatabaseQueryParams as n, type DatabaseTableInfo as o, ErrorCode as p, type ExtensionRuntimeMode as q, type ExternalEvent as r, type FileChangePayload as s, type FileChangeType as t, type FilteredSyncTablesResult as u, HAEXTENSION_EVENTS as v, type HaexHubRequest as w, type HaexHubResponse as x, HaexVaultSdkError as y, type HaextensionEvent as z };
500
+ export { type SearchRequestEvent as $, type ApplicationContext as A, HostErrorCode as B, type ClaimRequirement as C, type DatabaseQueryResult as D, type ExtensionInfo as E, type FileChangeEvent as F, MAIL_EVENTS as G, type HaexHubConfig as H, type IdentityClaim as I, type MailEvent as J, type ManifestI18nEntry as K, type ManifestTool as L, type Migration as M, type ManifestToolEffect as N, NOTIFICATION_EVENTS as O, type PermissionResponse as P, type NotificationEvent as Q, type RequestOptions as R, type SearchResult as S, type PermissionDeniedError as T, type PermissionErrorBase as U, PermissionErrorCode as V, type WebRequestOptions as W, type PermissionPromptError as X, PermissionStatus as Y, SHELL_EVENTS as Z, type SearchQuery as _, type ExtensionManifest as a, type ShellEvent as a0, type SyncTablesUpdatedEvent as a1, TABLE_SEPARATOR as a2, getTableName as a3, isPermissionDeniedError as a4, isPermissionError as a5, isPermissionPromptError as a6, type HaexHubEvent as b, EXTERNAL_EVENTS as c, type MigrationResult as d, type WebResponse as e, type EventCallback as f, type DatabasePermissionRequest as g, type SignedClaimPresentation as h, type ContextChangedEvent as i, DEFAULT_TIMEOUT as j, type DatabaseColumnInfo as k, type DatabaseExecuteParams as l, type DatabasePermission as m, type DatabaseQueryParams as n, type DatabaseTableInfo as o, ErrorCode as p, type ExtensionRuntimeMode as q, type ExternalEvent as r, type FileChangePayload as s, type FileChangeType as t, type FilteredSyncTablesResult as u, HAEXTENSION_EVENTS as v, type HaexHubRequest as w, type HaexHubResponse as x, HaexVaultSdkError as y, type HaextensionEvent as z };
package/dist/vite.js CHANGED
@@ -242,7 +242,14 @@ var HAEXSPACE_MESSAGE_TYPES = {
242
242
  *
243
243
  * Payload: `{ type: PORT_READY }` — no data.
244
244
  */
245
- PORT_READY: "haexspace:port:ready"
245
+ PORT_READY: "haexspace:port:ready",
246
+ /**
247
+ * One MCP message of the tool connection (holzi spec 018), in both directions over the
248
+ * MessagePort: the host calls the extension's tools, `sdk.tools` answers.
249
+ *
250
+ * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.
251
+ */
252
+ MCP: "haexspace:mcp"
246
253
  };
247
254
 
248
255
  // src/polyfills/debug.ts
package/dist/vite.js.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,EA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O,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"]}
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;AAAA,EAC5E;AAGA,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,MAAM,SAAA,uBAAgB,GAAA,EAAoB;AAE1C,IAAA,MAAM,gBAAA,GAA4B;AAAA,MAChC,QAAQ,GAAA,EAA4B;AAClC,QAAA,OAAO,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,IAAK,IAAA;AAAA,MAC/B,CAAA;AAAA,MACA,OAAA,CAAQ,KAAa,KAAA,EAAqB;AACxC,QAAA,SAAA,CAAU,GAAA,CAAI,GAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,MAClC,CAAA;AAAA,MACA,WAAW,GAAA,EAAmB;AAC5B,QAAA,SAAA,CAAU,OAAO,GAAG,CAAA;AAAA,MACtB,CAAA;AAAA,MACA,KAAA,GAAc;AACZ,QAAA,SAAA,CAAU,KAAA,EAAM;AAAA,MAClB,CAAA;AAAA,MACA,IAAI,MAAA,GAAiB;AACnB,QAAA,OAAO,SAAA,CAAU,IAAA;AAAA,MACnB,CAAA;AAAA,MACA,IAAI,KAAA,EAA8B;AAChC,QAAA,OAAO,MAA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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.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\n /**\n * One MCP message of the tool connection (holzi spec 018), in both directions over the\n * MessagePort: the host calls the extension's tools, `sdk.tools` answers.\n *\n * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.\n */\n MCP: 'haexspace:mcp',\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
@@ -238,7 +238,14 @@ var HAEXSPACE_MESSAGE_TYPES = {
238
238
  *
239
239
  * Payload: `{ type: PORT_READY }` — no data.
240
240
  */
241
- PORT_READY: "haexspace:port:ready"
241
+ PORT_READY: "haexspace:port:ready",
242
+ /**
243
+ * One MCP message of the tool connection (holzi spec 018), in both directions over the
244
+ * MessagePort: the host calls the extension's tools, `sdk.tools` answers.
245
+ *
246
+ * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.
247
+ */
248
+ MCP: "haexspace:mcp"
242
249
  };
243
250
 
244
251
  // src/polyfills/debug.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,G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,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\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"]}
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,OA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,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\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\n /**\n * One MCP message of the tool connection (holzi spec 018), in both directions over the\n * MessagePort: the host calls the extension's tools, `sdk.tools` answers.\n *\n * Payload: `{ type: MCP, message }`, where `message` is a JSON-RPC 2.0 object.\n */\n MCP: 'haexspace:mcp',\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-Cx4ZyQFL.mjs';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-CDox5_KH.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-BwFKGH70.mjs';
4
+ import { H as HaexHubConfig } from './types-DoNvKiW_.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-CD5QZi7F.js';
1
+ import { H as HaexVaultSdk, S as StorageAPI } from './client-pppDo5Q3.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-BwFKGH70.js';
4
+ import { H as HaexHubConfig } from './types-DoNvKiW_.js';
5
5
 
6
6
  /**
7
7
  * Vue 3 composable for HaexVault SDK