@unicitylabs/nostr-js-sdk 0.0.2 → 0.0.3

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.
@@ -4434,8 +4434,8 @@
4434
4434
  });
4435
4435
 
4436
4436
  /**
4437
- * WebSocketAdapter - Cross-platform WebSocket implementation.
4438
- * Provides a unified interface for WebSocket connections in Node.js and browsers.
4437
+ * WebSocketAdapter - Browser implementation.
4438
+ * Uses the native WebSocket API.
4439
4439
  */
4440
4440
  /** WebSocket ready state constants */
4441
4441
  const CONNECTING = 0;
@@ -4443,28 +4443,18 @@
4443
4443
  const CLOSING = 2;
4444
4444
  const CLOSED = 3;
4445
4445
  /**
4446
- * Create a WebSocket connection that works in both Node.js and browsers.
4446
+ * Create a WebSocket connection using native browser WebSocket.
4447
4447
  * @param url WebSocket URL (ws:// or wss://)
4448
4448
  * @returns WebSocket instance
4449
4449
  */
4450
4450
  async function createWebSocket(url) {
4451
- // Check if we're in a browser environment
4452
- if (typeof WebSocket !== 'undefined') {
4453
- return new WebSocket(url);
4454
- }
4455
- // Node.js environment - dynamically import ws
4456
- try {
4457
- // @vite-ignore
4458
- const { default: WS } = await import(/* @vite-ignore */ 'ws');
4459
- return new WS(url);
4460
- }
4461
- catch {
4462
- throw new Error('WebSocket not available. In Node.js, install the "ws" package: npm install ws');
4451
+ if (typeof WebSocket === 'undefined') {
4452
+ throw new Error('WebSocket not available in this environment');
4463
4453
  }
4454
+ return new WebSocket(url);
4464
4455
  }
4465
4456
  /**
4466
4457
  * Extract string data from WebSocket message event.
4467
- * Handles different message types across platforms.
4468
4458
  * @param event WebSocket message event
4469
4459
  * @returns String message data
4470
4460
  */
@@ -4476,13 +4466,8 @@
4476
4466
  return new TextDecoder().decode(event.data);
4477
4467
  }
4478
4468
  if (typeof Blob !== 'undefined' && event.data instanceof Blob) {
4479
- // This shouldn't happen in normal Nostr relay communication
4480
4469
  throw new Error('Blob messages are not supported');
4481
4470
  }
4482
- // Node.js Buffer case
4483
- if (Buffer && Buffer.isBuffer(event.data)) {
4484
- return event.data.toString('utf-8');
4485
- }
4486
4471
  return String(event.data);
4487
4472
  }
4488
4473