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