Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,8 @@ The [Alby OAuth API](https://guides.getalby.com/alby-wallet-api/reference/gettin

**This library relies on a global fetch() function which will work in browsers and node v18.x or newer.** (In older versions you have to use a polyfill.)

#### Websocket polyfill

To use this on Node.js you first must install `websocket-polyfill@0.0.3` and import it:

```js
import "websocket-polyfill";
// or: require('websocket-polyfill');
```
#### WebSocket Polyfill
If you are using Node.js < v22, you may need a WebSocket polyfill. We recommend `websocket-polyfill` but checking your node version is preferred.

## WebLN Documentation

Expand Down
5 changes: 0 additions & 5 deletions docs/lnclient.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ See [the LNClient examples directory](./examples/lnclient) for a full list of ex

## For Node.js

To use this on Node.js you first must install `websocket-polyfill@0.0.3` and import it:

```js
import "websocket-polyfill";
// or: require('websocket-polyfill');
```

if you get an `crypto is not defined` error, either upgrade to node.js 20 or above, or import it manually:

Expand Down
5 changes: 0 additions & 5 deletions docs/nwc.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,7 @@ Look at our [NWC React Native Expo Demo app](https://github.com/getAlby/nwc-reac

#### For Node.js

To use this on Node.js you first must install `websocket-polyfill@0.0.3` and import it:

```js
import "websocket-polyfill";
// or: require('websocket-polyfill');
```

if you get an `crypto is not defined` error, either upgrade to node.js 20 or above, or import it manually:

Expand Down
1 change: 0 additions & 1 deletion examples/lnclient/pay_ln_address.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/lnclient/paywall.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js
import qrcode from "qrcode-terminal";

import * as readline from "node:readline/promises";
Expand Down
1 change: 0 additions & 1 deletion examples/lnclient/splitter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js
import qrcode from "qrcode-terminal";

import * as readline from "node:readline/promises";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/create-connection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/get-balance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/get-budget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/get-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/get-wallet-service-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/hold-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/list-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/lookup-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/make-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/multi-pay-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import { LightningAddress } from "@getalby/lightning-tools";

Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/multi-pay-keysend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/nwa-accept.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/nwa.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js
import qrcode from "qrcode-terminal";

import * as readline from "node:readline/promises";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/pay-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/pay-keysend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/sign-message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/subscribe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/client/wrapped-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/get-balance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/get-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/keysend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/list-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/lookup-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/make-invoice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/multi-keysend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/send-multi-payment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import { LightningAddress } from "@getalby/lightning-tools";

Expand Down
1 change: 0 additions & 1 deletion examples/nwc/send-payment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/sign-message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
Expand Down
1 change: 0 additions & 1 deletion examples/nwc/wallet-service/example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "websocket-polyfill"; // required in node.js

import { generateSecretKey, getPublicKey } from "nostr-tools";
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
Expand Down
9 changes: 6 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
export default {
preset: "ts-jest",
testEnvironment: "node",
transform: {
"^.+\\.tsx?$": ["ts-jest", { useESM: true }],
},
Comment on lines +2 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check full jest config
echo "=== jest.config.ts ===" 
cat jest.config.ts 2>/dev/null || echo "File not found"

echo ""
echo "=== package.json (test script and ts-jest version) ==="
cat package.json | grep -A5 '"test"' || echo "Not found"
echo ""
cat package.json | grep -A2 '"ts-jest"' || echo "Not found"

echo ""
echo "=== Searching for extensionsToTreatAsEsm ==="
rg -n "extensionsToTreatAsEsm" 2>/dev/null || echo "Not found"

echo ""
echo "=== Searching for experimental-vm-modules ==="
rg -n "experimental-vm-modules" 2>/dev/null || echo "Not found"

Repository: getAlby/js-sdk

Length of output: 650


🌐 Web query:

ts-jest useESM configuration extensionsToTreatAsEsm requirements 2025

💡 Result:

When using ts-jest in ESM mode (useESM: true), you generally must also tell Jest to treat TypeScript files as native ESM via extensionsToTreatAsEsm, otherwise Jest may still execute .ts as CJS semantics. [1][2]

Minimal working pattern (no preset):

// jest.config.ts
import type { Config } from 'jest'

export default {
  extensionsToTreatAsEsm: ['.ts'],           // (often also '.tsx' if you use it)
  transform: {
    '^.+\\.tsx?$': ['ts-jest', { useESM: true }],
  },
} satisfies Config

Key requirements / notes:

  • extensionsToTreatAsEsm should include .ts (and .tsx if applicable) when you want those files to run as ESM in Jest. [1][2]
  • useESM: true is the ts-jest switch that makes ts-jest emit/transform to ESM where possible; it’s separate from Jest’s extensionsToTreatAsEsm toggle. [3][2]
  • If you use ts-jest’s ESM helpers, you can use their provided constants/patterns (e.g., TS_EXT_TO_TREAT_AS_ESM, ESM_TS_TRANSFORM_PATTERN) instead of hardcoding extensions/regex. [1]
  • For .mts / .mjs-style setups, ts-jest documents additional requirements such as having package.json include "type": "module", and sometimes a custom resolver for .mjs.mts resolution. [1]

Add extensionsToTreatAsEsm to the Jest configuration.

When using ts-jest with useESM: true, you must also configure extensionsToTreatAsEsm: ['.ts'] in the Jest config. Without it, Jest will still execute .ts files as CommonJS, creating a mismatch between ts-jest's ESM transformation and Jest's runtime expectations.

Add to jest.config.ts:

export default {
  preset: "ts-jest",
  testEnvironment: "node",
  extensionsToTreatAsEsm: ['.ts'],
  transform: {
    "^.+\\.tsx?$": ["ts-jest", { useESM: true }],
  },
};
🤖 Prompt for AI Agents
In `@jest.config.ts` around lines 2 - 7, The Jest config is missing
extensionsToTreatAsEsm which causes a mismatch when using ts-jest with useESM:
true; update the exported config object to include extensionsToTreatAsEsm:
['.ts'] alongside preset/testEnvironment and the transform entry so Jest treats
.ts files as ESM (modify the object containing transform and the ts-jest {
useESM: true } option to add the extensionsToTreatAsEsm key).

};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@
"ts-jest": "^29.4.1",
"ts-node": "^10.9.1",
"tslib": "^2.8.1",
"typescript": "^5.1.6",
"websocket-polyfill": "^0.0.3"
"typescript": "^5.1.6"
},
"engines": {
"node": ">=14"
Expand Down
2 changes: 1 addition & 1 deletion src/nwc/NWAClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "websocket-polyfill";

import { NWAClient } from "./NWAClient";
import { bytesToHex, hexToBytes } from "@noble/hashes/utils";
import { generateSecretKey, getPublicKey } from "nostr-tools";
Expand Down
6 changes: 3 additions & 3 deletions src/nwc/NWAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Nip47NotificationType,
} from "./types";
import { NWCClient } from "./NWCClient";
import { SubCloser } from "nostr-tools/lib/types/abstract-pool";
import { SubCloser } from "nostr-tools/abstract-pool";

export type NWAOptions = {
relayUrls: string[];
Expand Down Expand Up @@ -51,8 +51,8 @@ export class NWAClient {
this.pool = new SimplePool();

if (globalThis.WebSocket === undefined) {
console.error(
"WebSocket is undefined. Make sure to `import websocket-polyfill` for nodejs environments",
throw new Error(
"WebSocket is undefined. Make sure to polyfill it for nodejs environments",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/nwc/NWCClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "websocket-polyfill";

import { NWCClient } from "./NWCClient";

// this has no funds on it, I think ;-)
Expand Down
26 changes: 21 additions & 5 deletions src/nwc/NWCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EventTemplate,
SimplePool,
} from "nostr-tools";
import { normalizeURL } from "nostr-tools/utils";
import { hexToBytes, bytesToHex } from "@noble/hashes/utils";
import {
Nip47EncryptionType,
Expand Down Expand Up @@ -55,7 +56,7 @@ import {
Nip47CancelHoldInvoiceResponse,
Nip47NetworkError,
} from "./types";
import { SubCloser } from "nostr-tools/lib/types/abstract-pool";
import { SubCloser } from "nostr-tools/abstract-pool";

export interface NWCOptions {
relayUrls: string[];
Expand Down Expand Up @@ -140,8 +141,8 @@ export class NWCClient {
// this.subscribers = {};

if (globalThis.WebSocket === undefined) {
console.error(
"WebSocket is undefined. Make sure to `import websocket-polyfill` for nodejs environments",
throw new Error(
"WebSocket is undefined. Make sure to polyfill it for nodejs environments",
);
}
}
Expand Down Expand Up @@ -198,8 +199,23 @@ export class NWCClient {
return getEventHash(event);
}

close() {
return this.pool.close(this.relayUrls);

async close(): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes are unrelated to this PR

const closePromises: Promise<void>[] = [];
for (const url of this.relayUrls) {
const relayUrl = normalizeURL(url);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const relay = (this.pool as any).relays.get(relayUrl);
if (relay?.ws && relay.ws.readyState !== WebSocket.CLOSED) {
closePromises.push(
new Promise<void>((resolve) => {
relay.ws?.addEventListener("close", () => resolve(), { once: true });
}),
);
}
}
this.pool.close(this.relayUrls);
await Promise.all(closePromises);
Comment on lines +203 to +218
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Check if SimplePool is from nostr-tools and understand its type
fd "pool" --type ts | head -20

Repository: getAlby/js-sdk

Length of output: 227


🏁 Script executed:

# Search for SimplePool type definitions and usage in the codebase
rg "SimplePool" --type ts -B 2 -A 2

Repository: getAlby/js-sdk

Length of output: 1430


🏁 Script executed:

# Check imports to understand where SimplePool comes from
rg "import.*SimplePool\|from.*nostr" --type ts | head -20

Repository: getAlby/js-sdk

Length of output: 40


🏁 Script executed:

# Look for any type definitions or interfaces for pool
ast-grep --pattern 'interface.*Pool {
  $$$
}' | head -50

Repository: getAlby/js-sdk

Length of output: 40


🌐 Web query:

nostr-tools SimplePool public API relay close

💡 Result:

In nostr-tools, the pool’s “relay close” API works like this:

  • Close (disconnect) specific relay connections managed by the pool:
    pool.close(relayUrls) closes only the relays whose URLs you pass in, and removes them from the pool’s internal relay map. Example:

    pool.close(['wss://relay.example.com'])

    (Implementation: normalize URL → relay.close() → delete from map.) [2]

  • Close a Relay directly (if you created/obtained a Relay instance):
    The README shows calling:

    relay.close()

    to close that relay’s websocket connection. [1]

  • Close all relays in the pool:
    pool.close([]) closes none (empty list). If you want to disconnect everything, use:

    pool.destroy()

    which iterates all connected relays, closes them, and resets the pool’s relay map. [2]
    (The README snippet that calls pool.close([]) is just passing an empty list—i.e., it won’t disconnect relays.) [1]

Sources: nostr-tools README examples [1], AbstractSimplePool implementation (close, destroy) [2].


🏁 Script executed:

rg "pool\.close|relay\.close" --type=typescript -B 2 -A 5 | head -40

Repository: getAlby/js-sdk

Length of output: 92


🏁 Script executed:

# Look for how close() is typically used elsewhere in codebase
rg "\.close\(" --type=typescript | grep -E "(pool|relay)" | head -20

Repository: getAlby/js-sdk

Length of output: 92


🌐 Web query:

nostr-tools SimplePool close method async await behavior

💡 Result:

In nostr-tools / @nostr/tools, SimplePool.close(relays) is not async and returns void, so await pool.close(...) does not wait for anything. The implementation just normalizes each URL, calls the cached relay’s .close(), and removes it from the pool’s internal map. [1]

Under the hood, relay.close() is also synchronous: it marks the relay as intentionally closed, clears reconnect/ping timers, closes all subscriptions, flips connected to false, calls the relay’s onclose callback, and then initiates the WebSocket close (ws.close()) if the socket is open—without returning a Promise you can await. [2]

Implication: pool.close() only starts shutdown; it doesn’t provide an “await until sockets are fully closed” mechanism.
If you need an awaitable close in your code, you’ll have to build it yourself (e.g., track the WebSocket close event for each relay connection you created).

Sources
[1] AbstractSimplePool.close(relays): void implementation (JSR, abstract-pool.ts) (jsr.io)
[2] AbstractRelay.close(): void implementation (JSR, abstract-relay.ts) (jsr.io)

Citations:


Add timeout to WebSocket close promises and document reliance on private API.

Two concerns with this close() implementation:

  1. Accessing private internals: (this.pool as any).relays accesses SimplePool's internal Map. While nostr-tools exposes pool.close(relayUrls) as a public API, it is synchronous and does not wait for WebSocket close events—it only initiates them. Your manual event tracking is necessary to ensure connections fully close, but this fragile reliance on private API will break silently if the field is renamed or restructured. Document this as a workaround for nostr-tools' lack of awaitable close.

  2. No timeout on close promises: If a WebSocket close event never fires (e.g., network stall), await Promise.all(closePromises) hangs indefinitely. Add a timeout to each close promise:

Suggested timeout wrapper
       if (relay?.ws && relay.ws.readyState !== WebSocket.CLOSED) {
         closePromises.push(
-          new Promise<void>((resolve) => {
-            relay.ws?.addEventListener("close", () => resolve(), { once: true });
-          }),
+          new Promise<void>((resolve) => {
+            const timer = setTimeout(resolve, 5000);
+            relay.ws?.addEventListener("close", () => { clearTimeout(timer); resolve(); }, { once: true });
+          }),
         );
       }
🤖 Prompt for AI Agents
In `@src/nwc/NWCClient.ts` around lines 203 - 218, The close() method currently
reaches into SimplePool internals via (this.pool as any).relays to await
relay.ws "close" events but doesn’t guard against missing events; update close()
to wrap each close promise with a timeout (e.g., reject/resolve after
configurable ms) so Promise.all(closePromises) cannot hang indefinitely, and
ensure the timeout value is configurable/constant. Also add an inline comment
above the use of (this.pool as any).relays documenting that this is a deliberate
workaround for nostr-tools' synchronous pool.close() (since
pool.close(relayUrls) only initiates closes and does not await them) and mark
reliance on the private API as fragile so future maintainers know why it’s used.
Ensure references: close(), relayUrls, this.pool/(SimplePool).relays,
closePromises, and WebSocket close event are updated accordingly.

}

async encrypt(pubkey: string, content: string) {
Expand Down
6 changes: 3 additions & 3 deletions src/nwc/NWCWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Relay,
} from "nostr-tools";
import { hexToBytes } from "@noble/hashes/utils";
import { Subscription } from "nostr-tools/lib/types/abstract-relay";
import { Subscription } from "nostr-tools/abstract-relay";

import {
Nip47MakeInvoiceRequest,
Expand Down Expand Up @@ -60,8 +60,8 @@ export class NWCWalletService {
this.relay = new Relay(this.relayUrl);

if (globalThis.WebSocket === undefined) {
console.error(
"WebSocket is undefined. Make sure to `import websocket-polyfill` for nodejs environments",
throw new Error(
"WebSocket is undefined. Make sure to polyfill it for nodejs environments",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/oauth/AlbyResponseError.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AlbyResponseError } from "./AlbyResponseError";
import "websocket-polyfill";


describe("AlbyResponseError", () => {
test("Error message is generated", () => {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"moduleResolution": "bundler",
"lib": ["ES2021", "DOM"],
"target": "es2020",
"strict": true,
Expand Down
Loading