@private.me/xbind 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -7
- package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1920 -1
- package/dist-standalone/_deps/shared/cjs/errors.js +729 -1
- package/dist-standalone/_deps/shared/cjs/index.js +463 -1
- package/dist-standalone/_deps/shared/cjs/types.js +315 -1
- package/dist-standalone/_deps/shared/errors.js +244 -1
- package/dist-standalone/_deps/shared/index.js +72 -1
- package/dist-standalone/_deps/shared/types.js +86 -1
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
- package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/search.js +1 -1
- package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
- package/dist-standalone/_deps/xchange/errors.js +1 -1
- package/dist-standalone/_deps/xchange/index.js +1 -1
- package/dist-standalone/_deps/xchange/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/xchange.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
- package/dist-standalone/_deps/xregistry/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/index.js +1 -1
- package/dist-standalone/_deps/xregistry/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/types.js +1 -1
- package/dist-standalone/agent-call.js +659 -1
- package/dist-standalone/agent-sdk.js +328 -1
- package/dist-standalone/agent.js +1800 -1
- package/dist-standalone/approval.js +193 -1
- package/dist-standalone/async-iterators.js +382 -1
- package/dist-standalone/auth.js +219 -1
- package/dist-standalone/auto-accept.js +229 -1
- package/dist-standalone/backup-config.js +201 -1
- package/dist-standalone/backup.js +326 -1
- package/dist-standalone/batch-operations.js +388 -1
- package/dist-standalone/cancellation.js +477 -1
- package/dist-standalone/checkpoint.js +186 -1
- package/dist-standalone/circuit-breaker.js +468 -1
- package/dist-standalone/cjs/agent-call.js +701 -1
- package/dist-standalone/cjs/agent-sdk.js +332 -1
- package/dist-standalone/cjs/agent.js +1837 -1
- package/dist-standalone/cjs/approval.js +199 -1
- package/dist-standalone/cjs/async-iterators.js +392 -1
- package/dist-standalone/cjs/auth.js +225 -1
- package/dist-standalone/cjs/auto-accept.js +233 -1
- package/dist-standalone/cjs/backup-config.js +207 -1
- package/dist-standalone/cjs/backup.js +330 -1
- package/dist-standalone/cjs/batch-operations.js +397 -1
- package/dist-standalone/cjs/cancellation.js +490 -1
- package/dist-standalone/cjs/checkpoint.js +193 -1
- package/dist-standalone/cjs/circuit-breaker.js +476 -1
- package/dist-standalone/cjs/cli/init.js +492 -1
- package/dist-standalone/cjs/config-validation.js +522 -1
- package/dist-standalone/cjs/connect.js +312 -1
- package/dist-standalone/cjs/connection-pool.js +506 -1
- package/dist-standalone/cjs/correlation-id.js +339 -1
- package/dist-standalone/cjs/crypto-utils.js +176 -1
- package/dist-standalone/cjs/debug-mode.js +534 -1
- package/dist-standalone/cjs/did-document.js +101 -1
- package/dist-standalone/cjs/did-privateme.js +130 -1
- package/dist-standalone/cjs/did-web.js +201 -1
- package/dist-standalone/cjs/discovery.js +462 -1
- package/dist-standalone/cjs/dual-mode.js +251 -1
- package/dist-standalone/cjs/email-templates.js +313 -1
- package/dist-standalone/cjs/email-transport.js +239 -1
- package/dist-standalone/cjs/envelope.js +538 -1
- package/dist-standalone/cjs/errors.js +913 -1
- package/dist-standalone/cjs/event-emitter.js +461 -1
- package/dist-standalone/cjs/gateway-state.js +55 -1
- package/dist-standalone/cjs/gateway-transport.js +120 -1
- package/dist-standalone/cjs/graceful-degradation.js +403 -1
- package/dist-standalone/cjs/guardrails.js +223 -1
- package/dist-standalone/cjs/health-check.js +336 -1
- package/dist-standalone/cjs/http-compat.js +272 -1
- package/dist-standalone/cjs/http-status-map.js +571 -1
- package/dist-standalone/cjs/identity.js +645 -1
- package/dist-standalone/cjs/index.js +406 -1
- package/dist-standalone/cjs/invitation.js +421 -1
- package/dist-standalone/cjs/invite.js +328 -1
- package/dist-standalone/cjs/key-agreement.js +335 -1
- package/dist-standalone/cjs/lazy-init.js +300 -1
- package/dist-standalone/cjs/logger.js +291 -1
- package/dist-standalone/cjs/mdns-discovery.js +202 -1
- package/dist-standalone/cjs/nonce-store.js +80 -1
- package/dist-standalone/cjs/pairing-manager.js +223 -1
- package/dist-standalone/cjs/plugin-system.js +264 -1
- package/dist-standalone/cjs/plugins/logging.js +168 -1
- package/dist-standalone/cjs/plugins/metrics.js +181 -1
- package/dist-standalone/cjs/plugins/validation.js +302 -1
- package/dist-standalone/cjs/policy.js +320 -1
- package/dist-standalone/cjs/progress-callbacks.js +583 -1
- package/dist-standalone/cjs/redis-nonce-store.js +76 -1
- package/dist-standalone/cjs/registry-middleware.js +50 -1
- package/dist-standalone/cjs/retry-strategies.js +544 -1
- package/dist-standalone/cjs/retry-transport.js +102 -1
- package/dist-standalone/cjs/runtime/browser.js +533 -1
- package/dist-standalone/cjs/runtime/edge.js +526 -1
- package/dist-standalone/cjs/runtime/react-native.js +394 -1
- package/dist-standalone/cjs/security-policy.js +245 -1
- package/dist-standalone/cjs/serialization.js +1040 -1
- package/dist-standalone/cjs/split-channel.js +225 -1
- package/dist-standalone/cjs/subscription-proof.js +230 -1
- package/dist-standalone/cjs/succession.js +148 -1
- package/dist-standalone/cjs/timeouts.js +412 -1
- package/dist-standalone/cjs/trace-context.js +424 -1
- package/dist-standalone/cjs/trace-spans.js +495 -1
- package/dist-standalone/cjs/transport.js +63 -1
- package/dist-standalone/cjs/trust-registry.js +991 -1
- package/dist-standalone/cjs/types/error-response.js +56 -1
- package/dist-standalone/cjs/vault-auth.js +178 -1
- package/dist-standalone/cjs/vault-store-loader.js +194 -1
- package/dist-standalone/cjs/verify.js +25 -1
- package/dist-standalone/cjs/version-info.js +543 -1
- package/dist-standalone/cjs/xfetch.js +340 -1
- package/dist-standalone/cli/init.js +455 -1
- package/dist-standalone/cli/setup.js +514 -1
- package/dist-standalone/cli/types.js +27 -1
- package/dist-standalone/cli/xbind.js +148 -1
- package/dist-standalone/config-validation.js +513 -1
- package/dist-standalone/connect.js +274 -1
- package/dist-standalone/connection-pool.js +500 -1
- package/dist-standalone/correlation-id.js +326 -1
- package/dist-standalone/crypto-utils.js +157 -1
- package/dist-standalone/debug-mode.js +510 -1
- package/dist-standalone/did-document.js +96 -1
- package/dist-standalone/did-privateme.js +121 -1
- package/dist-standalone/did-web.js +196 -1
- package/dist-standalone/discovery.js +458 -1
- package/dist-standalone/dual-mode.js +247 -1
- package/dist-standalone/email-templates.js +309 -1
- package/dist-standalone/email-transport.js +232 -1
- package/dist-standalone/envelope.js +525 -1
- package/dist-standalone/errors.js +896 -1
- package/dist-standalone/event-emitter.js +456 -1
- package/dist-standalone/gateway-state.js +51 -1
- package/dist-standalone/gateway-transport.js +116 -1
- package/dist-standalone/graceful-degradation.js +396 -1
- package/dist-standalone/guardrails.js +216 -1
- package/dist-standalone/health-check.js +332 -1
- package/dist-standalone/http-compat.js +267 -1
- package/dist-standalone/http-status-map.js +561 -1
- package/dist-standalone/identity.js +619 -1
- package/dist-standalone/index.js +78 -1
- package/dist-standalone/invitation.js +415 -1
- package/dist-standalone/invite.js +324 -1
- package/dist-standalone/key-agreement.js +325 -1
- package/dist-standalone/lazy-init.js +295 -1
- package/dist-standalone/logger.js +285 -1
- package/dist-standalone/mdns-discovery.js +195 -1
- package/dist-standalone/nonce-store.js +76 -1
- package/dist-standalone/pairing-manager.js +219 -1
- package/dist-standalone/plugin-system.js +257 -1
- package/dist-standalone/plugins/logging.d.ts +84 -0
- package/dist-standalone/plugins/logging.js +163 -0
- package/dist-standalone/plugins/metrics.d.ts +111 -0
- package/dist-standalone/plugins/metrics.js +176 -0
- package/dist-standalone/plugins/validation.d.ts +104 -0
- package/dist-standalone/plugins/validation.js +297 -0
- package/dist-standalone/policy.js +315 -1
- package/dist-standalone/progress-callbacks.js +576 -1
- package/dist-standalone/redis-nonce-store.js +72 -1
- package/dist-standalone/registry-middleware.js +47 -1
- package/dist-standalone/retry-strategies.js +534 -1
- package/dist-standalone/retry-transport.js +98 -1
- package/dist-standalone/runtime/browser.d.ts +311 -0
- package/dist-standalone/runtime/browser.js +516 -0
- package/dist-standalone/runtime/edge.d.ts +282 -0
- package/dist-standalone/runtime/edge.js +511 -0
- package/dist-standalone/runtime/react-native.d.ts +157 -0
- package/dist-standalone/runtime/react-native.js +383 -0
- package/dist-standalone/security-policy.js +239 -1
- package/dist-standalone/serialization.js +1031 -1
- package/dist-standalone/split-channel.js +219 -1
- package/dist-standalone/subscription-proof.js +224 -1
- package/dist-standalone/succession.js +142 -1
- package/dist-standalone/timeouts.js +398 -1
- package/dist-standalone/trace-context.js +414 -1
- package/dist-standalone/trace-spans.js +488 -1
- package/dist-standalone/transport.js +59 -1
- package/dist-standalone/trust-registry.js +950 -1
- package/dist-standalone/types/error-response.d.ts +209 -0
- package/dist-standalone/types/error-response.js +52 -0
- package/dist-standalone/vault-auth.js +174 -1
- package/dist-standalone/vault-store-loader.js +187 -1
- package/dist-standalone/verify.js +16 -1
- package/dist-standalone/version-info.js +530 -1
- package/dist-standalone/xfetch.js +335 -1
- package/package.json +4 -10
- package/share1.dat +0 -0
- package/dist-standalone/_deps/mldsa-wasm/LICENSE +0 -24
- package/dist-standalone/_deps/mldsa-wasm/package.json +0 -46
- package/dist-standalone/_deps/shared/cjs/package.json +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/package.json +0 -1
- package/dist-standalone/_deps/xchange/cjs/package.json +0 -1
- package/dist-standalone/_deps/xregistry/cjs/package.json +0 -1
- package/dist-standalone/cjs/package.json +0 -3
- package/dist-standalone/package.json +0 -10
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Runtime Compatibility Layer
|
|
3
|
+
*
|
|
4
|
+
* Provides polyfills and runtime detection for browser environments.
|
|
5
|
+
* Ensures xBind works seamlessly in Chrome, Firefox, Safari, and service workers.
|
|
6
|
+
*
|
|
7
|
+
* @module runtime/browser
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { Result } from '@private.me/shared';
|
|
11
|
+
/**
|
|
12
|
+
* Runtime environment type.
|
|
13
|
+
*/
|
|
14
|
+
export type RuntimeEnvironment = 'browser' | 'node' | 'service-worker' | 'web-worker' | 'unknown';
|
|
15
|
+
/**
|
|
16
|
+
* Detect the current runtime environment.
|
|
17
|
+
*
|
|
18
|
+
* @returns The detected runtime environment type
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { detectRuntime } from '@private.me/xbind/runtime/browser';
|
|
23
|
+
*
|
|
24
|
+
* const runtime = detectRuntime();
|
|
25
|
+
* console.log('Running in:', runtime);
|
|
26
|
+
* // => 'browser' | 'node' | 'service-worker' | 'web-worker' | 'unknown'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function detectRuntime(): RuntimeEnvironment;
|
|
30
|
+
/**
|
|
31
|
+
* Check if running in a browser environment.
|
|
32
|
+
*
|
|
33
|
+
* @returns True if running in browser, service worker, or web worker
|
|
34
|
+
*/
|
|
35
|
+
export declare function isBrowser(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if running in Node.js environment.
|
|
38
|
+
*
|
|
39
|
+
* @returns True if running in Node.js
|
|
40
|
+
*/
|
|
41
|
+
export declare function isNode(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if running in a service worker.
|
|
44
|
+
*
|
|
45
|
+
* @returns True if running in service worker context
|
|
46
|
+
*/
|
|
47
|
+
export declare function isServiceWorker(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Browser-compatible random bytes generator.
|
|
50
|
+
* Uses Web Crypto API's getRandomValues.
|
|
51
|
+
*
|
|
52
|
+
* @param length - Number of random bytes to generate
|
|
53
|
+
* @returns Uint8Array of cryptographically secure random bytes
|
|
54
|
+
*
|
|
55
|
+
* @throws {Error} If Web Crypto API is not available
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* import { getRandomBytes } from '@private.me/xbind/runtime/browser';
|
|
60
|
+
*
|
|
61
|
+
* const nonce = getRandomBytes(16);
|
|
62
|
+
* console.log('Random nonce:', nonce);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function getRandomBytes(length: number): Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
* Generate a cryptographically secure random UUID.
|
|
68
|
+
* Uses Web Crypto API's randomUUID if available, falls back to manual generation.
|
|
69
|
+
*
|
|
70
|
+
* @returns UUID v4 string (e.g., "550e8400-e29b-41d4-a716-446655440000")
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { generateUUID } from '@private.me/xbind/runtime/browser';
|
|
75
|
+
*
|
|
76
|
+
* const id = generateUUID();
|
|
77
|
+
* console.log('Generated UUID:', id);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function generateUUID(): string;
|
|
81
|
+
/**
|
|
82
|
+
* Browser storage interface for persisting agent identity and state.
|
|
83
|
+
*/
|
|
84
|
+
export interface BrowserStorage {
|
|
85
|
+
/**
|
|
86
|
+
* Store a value.
|
|
87
|
+
* @param key - Storage key
|
|
88
|
+
* @param value - Value to store (will be JSON serialized)
|
|
89
|
+
*/
|
|
90
|
+
setItem(key: string, value: unknown): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Retrieve a value.
|
|
93
|
+
* @param key - Storage key
|
|
94
|
+
* @returns Stored value or null if not found
|
|
95
|
+
*/
|
|
96
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
97
|
+
/**
|
|
98
|
+
* Remove a value.
|
|
99
|
+
* @param key - Storage key
|
|
100
|
+
*/
|
|
101
|
+
removeItem(key: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Clear all stored values.
|
|
104
|
+
*/
|
|
105
|
+
clear(): Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* LocalStorage-based implementation of BrowserStorage.
|
|
109
|
+
* Suitable for browser environments with persistent storage needs.
|
|
110
|
+
*/
|
|
111
|
+
export declare class LocalStorageAdapter implements BrowserStorage {
|
|
112
|
+
private prefix;
|
|
113
|
+
/**
|
|
114
|
+
* Create a new LocalStorage adapter.
|
|
115
|
+
*
|
|
116
|
+
* @param prefix - Key prefix to avoid collisions (default: 'xbind:')
|
|
117
|
+
*/
|
|
118
|
+
constructor(prefix?: string);
|
|
119
|
+
setItem(key: string, value: unknown): Promise<void>;
|
|
120
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
121
|
+
removeItem(key: string): Promise<void>;
|
|
122
|
+
clear(): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* IndexedDB-based implementation of BrowserStorage.
|
|
126
|
+
* Suitable for larger datasets and service workers.
|
|
127
|
+
*/
|
|
128
|
+
export declare class IndexedDBAdapter implements BrowserStorage {
|
|
129
|
+
private dbName;
|
|
130
|
+
private storeName;
|
|
131
|
+
private version;
|
|
132
|
+
private db;
|
|
133
|
+
/**
|
|
134
|
+
* Create a new IndexedDB adapter.
|
|
135
|
+
*
|
|
136
|
+
* @param dbName - Database name (default: 'xbind-storage')
|
|
137
|
+
* @param storeName - Object store name (default: 'keyval')
|
|
138
|
+
* @param version - Database version (default: 1)
|
|
139
|
+
*/
|
|
140
|
+
constructor(dbName?: string, storeName?: string, version?: number);
|
|
141
|
+
/**
|
|
142
|
+
* Initialize the database connection.
|
|
143
|
+
* Called automatically by storage operations.
|
|
144
|
+
*/
|
|
145
|
+
private ensureDB;
|
|
146
|
+
setItem(key: string, value: unknown): Promise<void>;
|
|
147
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
148
|
+
removeItem(key: string): Promise<void>;
|
|
149
|
+
clear(): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Close the database connection.
|
|
152
|
+
* Should be called when storage is no longer needed.
|
|
153
|
+
*/
|
|
154
|
+
close(): void;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* In-memory storage implementation for testing and ephemeral use cases.
|
|
158
|
+
*/
|
|
159
|
+
export declare class MemoryStorageAdapter implements BrowserStorage {
|
|
160
|
+
private store;
|
|
161
|
+
setItem(key: string, value: unknown): Promise<void>;
|
|
162
|
+
getItem<T = unknown>(key: string): Promise<T | null>;
|
|
163
|
+
removeItem(key: string): Promise<void>;
|
|
164
|
+
clear(): Promise<void>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Error codes for WASM operations.
|
|
168
|
+
*/
|
|
169
|
+
export type WasmError = 'WASM_NOT_SUPPORTED' | 'WASM_LOAD_FAILED' | 'WASM_INIT_FAILED';
|
|
170
|
+
/**
|
|
171
|
+
* Check if WebAssembly is supported in the current environment.
|
|
172
|
+
*
|
|
173
|
+
* @returns True if WebAssembly is supported
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* import { isWasmSupported } from '@private.me/xbind/runtime/browser';
|
|
178
|
+
*
|
|
179
|
+
* if (isWasmSupported()) {
|
|
180
|
+
* console.log('WASM is supported - using post-quantum crypto');
|
|
181
|
+
* } else {
|
|
182
|
+
* console.log('WASM not supported - falling back to classical crypto');
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function isWasmSupported(): boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Load and instantiate a WebAssembly module from a URL.
|
|
189
|
+
*
|
|
190
|
+
* @param url - URL to WASM module
|
|
191
|
+
* @param importObject - Optional imports for WASM module
|
|
192
|
+
* @returns Result containing the WASM instance or error
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* import { loadWasmModule } from '@private.me/xbind/runtime/browser';
|
|
197
|
+
*
|
|
198
|
+
* const result = await loadWasmModule('/mldsa.wasm');
|
|
199
|
+
* if (!result.ok) {
|
|
200
|
+
* console.error('Failed to load WASM:', result.error);
|
|
201
|
+
* return;
|
|
202
|
+
* }
|
|
203
|
+
*
|
|
204
|
+
* const instance = result.value;
|
|
205
|
+
* // Use WASM exports...
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export declare function loadWasmModule(url: string, importObject?: WebAssembly.Imports): Promise<Result<WebAssembly.Instance, WasmError>>;
|
|
209
|
+
/**
|
|
210
|
+
* Browser capabilities and feature support.
|
|
211
|
+
*/
|
|
212
|
+
export interface BrowserCapabilities {
|
|
213
|
+
/** WebCrypto API available */
|
|
214
|
+
webCrypto: boolean;
|
|
215
|
+
/** SubtleCrypto API available */
|
|
216
|
+
subtleCrypto: boolean;
|
|
217
|
+
/** Ed25519 support in WebCrypto */
|
|
218
|
+
ed25519: boolean;
|
|
219
|
+
/** X25519 support in WebCrypto */
|
|
220
|
+
x25519: boolean;
|
|
221
|
+
/** WebAssembly support */
|
|
222
|
+
wasm: boolean;
|
|
223
|
+
/** IndexedDB support */
|
|
224
|
+
indexedDB: boolean;
|
|
225
|
+
/** LocalStorage support */
|
|
226
|
+
localStorage: boolean;
|
|
227
|
+
/** Service Worker support */
|
|
228
|
+
serviceWorker: boolean;
|
|
229
|
+
/** Web Worker support */
|
|
230
|
+
webWorker: boolean;
|
|
231
|
+
/** Fetch API support */
|
|
232
|
+
fetch: boolean;
|
|
233
|
+
/** TextEncoder/TextDecoder support */
|
|
234
|
+
textEncoding: boolean;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Detect browser capabilities and feature support.
|
|
238
|
+
*
|
|
239
|
+
* @returns Object describing available browser features
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* import { detectCapabilities } from '@private.me/xbind/runtime/browser';
|
|
244
|
+
*
|
|
245
|
+
* const caps = await detectCapabilities();
|
|
246
|
+
*
|
|
247
|
+
* if (!caps.webCrypto) {
|
|
248
|
+
* throw new Error('WebCrypto required for xBind');
|
|
249
|
+
* }
|
|
250
|
+
*
|
|
251
|
+
* if (!caps.ed25519) {
|
|
252
|
+
* console.warn('Ed25519 not supported - using polyfill');
|
|
253
|
+
* }
|
|
254
|
+
*
|
|
255
|
+
* if (caps.serviceWorker) {
|
|
256
|
+
* console.log('Service workers supported - can run in background');
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export declare function detectCapabilities(): Promise<BrowserCapabilities>;
|
|
261
|
+
/**
|
|
262
|
+
* Install Node.js compatibility shims for browser environments.
|
|
263
|
+
* Only installs missing APIs - does not override existing implementations.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* import { installNodePolyfills } from '@private.me/xbind/runtime/browser';
|
|
268
|
+
*
|
|
269
|
+
* // Install polyfills at application startup
|
|
270
|
+
* installNodePolyfills();
|
|
271
|
+
*
|
|
272
|
+
* // Now Node.js-style code works in browser
|
|
273
|
+
* import { randomBytes } from 'crypto'; // Works!
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
export declare function installNodePolyfills(): void;
|
|
277
|
+
/**
|
|
278
|
+
* Configuration for service worker compatibility mode.
|
|
279
|
+
*/
|
|
280
|
+
export interface ServiceWorkerConfig {
|
|
281
|
+
/** Cache strategy for WASM modules */
|
|
282
|
+
wasmCacheStrategy: 'cache-first' | 'network-first' | 'no-cache';
|
|
283
|
+
/** Maximum age for cached WASM modules (milliseconds) */
|
|
284
|
+
wasmCacheMaxAge: number;
|
|
285
|
+
/** Enable background sync for pending messages */
|
|
286
|
+
enableBackgroundSync: boolean;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Default service worker configuration.
|
|
290
|
+
*/
|
|
291
|
+
export declare const DEFAULT_SERVICE_WORKER_CONFIG: ServiceWorkerConfig;
|
|
292
|
+
/**
|
|
293
|
+
* Initialize xBind for service worker environment.
|
|
294
|
+
* Sets up caching strategies and background sync handlers.
|
|
295
|
+
*
|
|
296
|
+
* @param config - Service worker configuration
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* ```typescript
|
|
300
|
+
* // In your service worker (sw.js):
|
|
301
|
+
* import { initServiceWorker } from '@private.me/xbind/runtime/browser';
|
|
302
|
+
*
|
|
303
|
+
* initServiceWorker({
|
|
304
|
+
* wasmCacheStrategy: 'cache-first',
|
|
305
|
+
* wasmCacheMaxAge: 24 * 60 * 60 * 1000,
|
|
306
|
+
* enableBackgroundSync: true,
|
|
307
|
+
* });
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
export declare function initServiceWorker(config?: Partial<ServiceWorkerConfig>): void;
|
|
311
|
+
export type { Result, };
|