Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIP-96] validateFileUploadResponse considers an empty message string as an invalid response #454

Open
eyemono-moe opened this issue Nov 6, 2024 · 1 comment

Comments

@eyemono-moe
Copy link

When the message in the response object is an empty string, validateFileUploadResponse treats it as an invalid response.
This is because !response.message is used in the if statement.

nostr-tools/nip96.ts

Lines 272 to 274 in bf0c4d4

if (!response.status || !response.message) {
return false
}

Some file storage servers (e.g., https://github.com/quentintaranpino/nostrcheck-server) return an empty message, which results in responses from such file storage servers being considered invalid.
Is this the intended behavior?

reproduction

import { validateFileUploadResponse } from "nostr-tools/nip96";

const valid = validateFileUploadResponse({
  status: "success",
  message: "not empty",
  nip94_event: {
    tags: [
      ["url", "https://example.com/test.webp"],
      ["ox", "..."],
    ],
  },
});
console.log(valid); // -> true

const invalid = validateFileUploadResponse({
  status: "success",
  message: "", // empty
  nip94_event: {
    tags: [
      ["url", "https://example.com/test.webp"],
      ["ox", "..."],
    ],
  },
});
console.log(invalid); // -> false
@AsaiToshiya
Copy link
Collaborator

Probably, I think it seems necessary to compare to undefined not as falsy value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants