Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"@typescript-eslint/no-unused-vars": ["warn", { "args": "none" }],
"no-console": ["error", { "allow": ["info", "warn", "error"] }],
"no-console": ["error", { "allow": ["debug", "warn", "error"] }],
Copy link
Copy Markdown

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

🌐 Web query:

In current Node.js documentation, does console.debug()write to stdout or stderr, and is it an alias ofconsole.log()?

💡 Result:

In the current Node.js docs, console.debug() is an alias of console.log() [1]. Since console.log() prints to stdout, console.debug() also writes to stdout (not stderr) [2].

Sources: [1] [2]


console.debug writes to stdout and will still violate the "no stdout pollution" goal.

Allowing console.debug in this config still emits to stdout in Node.js (it's an alias of console.log), which keeps the original parsing risk in place.

Suggested fix
-    "no-console": ["error", { "allow": ["debug", "warn", "error"] }],
+    "no-console": ["error", { "allow": ["warn", "error"] }],

Route debug logs through an explicit logger interface (noop by default, opt-in by consumers).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"no-console": ["error", { "allow": ["debug", "warn", "error"] }],
"no-console": ["error", { "allow": ["warn", "error"] }],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.eslintrc.json at line 24, The ESLint rule currently allows console.debug
via "no-console": ["error", { "allow": ["debug", "warn", "error"] }], but
console.debug still writes to stdout in Node and violates the "no stdout
pollution" goal; update the lint config to remove "debug" from the allowed list
and instead route debug-level logging through a dedicated logger interface
(e.g., replace usages of console.debug with a Logger.debug call or a noop
default logger), so keep "warn" and "error" allowed but ensure all debug output
uses the new logger rather than console.debug.

"no-constant-binary-expression": "error"
},
"globals": {
Expand Down
4 changes: 2 additions & 2 deletions src/nwc/NWAClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ export class NWAClient {
onclose: (reasons) => {
// NOTE: this fires when all relays were closed once. There is no reconnect logic in nostr-tools
// See https://github.com/nbd-wtf/nostr-tools/issues/513
console.info("relay connection closed", reasons);
console.debug("relay connection closed", reasons);
endPromise?.();
},
},
);
console.info("subscribed to relays");
console.debug("subscribed to relays");

await new Promise<void>((resolve) => {
endPromise = () => {
Expand Down
13 changes: 6 additions & 7 deletions src/nwc/NWCClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ export class NWCClient {
} as NWCOptions;

this.relayUrls = this.options.relayUrls;
this.pool = new SimplePool({
});
this.pool = new SimplePool({});
if (this.options.secret) {
this.secret = (
this.options.secret.toLowerCase().startsWith("nsec")
Expand Down Expand Up @@ -718,7 +717,7 @@ export class NWCClient {
try {
await this._checkConnected();
await this._selectEncryptionType();
console.info("subscribing to relays");
console.debug("subscribing to relays");
sub = this.pool.subscribe(
this.relayUrls,
{
Expand Down Expand Up @@ -765,12 +764,12 @@ export class NWCClient {
onclose: (reasons) => {
// NOTE: this fires when all relays were closed once. There is no reconnect logic in nostr-tools
// See https://github.com/nbd-wtf/nostr-tools/issues/513
console.info("relay connection closed", reasons);
console.debug("relay connection closed", reasons);
endPromise?.();
},
},
);
console.info("subscribed to relays");
console.debug("subscribed to relays");

await new Promise<void>((resolve) => {
endPromise = () => {
Expand Down Expand Up @@ -865,7 +864,7 @@ export class NWCClient {
return;
}
if (response.result) {
// console.info("NIP-47 result", response.result);
// console.debug("NIP-47 result", response.result);
if (resultValidator(response.result)) {
resolve(response.result);
} else {
Expand Down Expand Up @@ -1009,7 +1008,7 @@ export class NWCClient {
);
}
if (response.result) {
// console.info("NIP-47 result", response.result);
// console.debug("NIP-47 result", response.result);
if (!resultValidator(response.result)) {
clearTimeout(replyTimeoutCheck);
sub.close();
Expand Down
12 changes: 6 additions & 6 deletions src/nwc/NWCWalletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export class NWCWalletService {
(async () => {
while (subscribed) {
try {
console.info("checking connection to relay");
console.debug("checking connection to relay");
await this._checkConnected();
console.info("subscribing to relay");
console.debug("subscribing to relay");
sub = this.relay.subscribe(
[
{
Expand All @@ -115,11 +115,11 @@ export class NWCWalletService {
],
{},
);
console.info("subscribed to relays");
console.debug("subscribed to relays");

sub.onevent = async (event) => {
try {
// console.info("Got event", event);
// console.debug("Got event", event);
const encryptionType = (event.tags.find(
(t) => t[0] === "encryption",
)?.[1] || "nip04") as Nip47EncryptionType;
Expand Down Expand Up @@ -271,7 +271,7 @@ export class NWCWalletService {
encryptionType: Nip47EncryptionType,
) {
let encrypted;
// console.info("encrypting with" + encryptionType);
// console.debug("encrypting with" + encryptionType);
if (encryptionType === "nip04") {
encrypted = await nip04.encrypt(
keypair.walletSecret,
Expand All @@ -294,7 +294,7 @@ export class NWCWalletService {
encryptionType: Nip47EncryptionType,
) {
let decrypted;
// console.info("decrypting with" + encryptionType);
// console.debug("decrypting with" + encryptionType);
if (encryptionType === "nip04") {
decrypted = await nip04.decrypt(
keypair.walletSecret,
Expand Down
2 changes: 1 addition & 1 deletion src/webln/OauthWeblnProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class OauthWeblnProvider {
!processingCode
) {
processingCode = true; // make sure we request the access token only once
console.info("Processing OAuth code response");
console.debug("Processing OAuth code response");
const code = data.payload.code;
try {
await this.auth.requestAccessToken(code);
Expand Down
Loading