nostr-comments 0.3.0 → 0.6.0

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.
package/README.md CHANGED
@@ -39,7 +39,7 @@ function App() {
39
39
  | Prop | Type | Default | Description |
40
40
  | -------------------- | ----------------------------------- | ------------------ | ---------------------------------------------------- |
41
41
  | `url` | `string` | **Required** | Web page URL, used to identify comment scope |
42
- | `authorPubkeys` | `string[]` | - | List of article author public keys for notifications |
42
+ | `mention` | `string` | - | Public key to mention in comments (receives notifications) |
43
43
  | `relays` | `string[]` | Default relay list | List of Nostr relay addresses |
44
44
  | `pageSize` | `number` | `50` | Number of comments per page |
45
45
  | `locale` | `string` | Auto-detect | Interface language (20 languages supported) |
@@ -48,6 +48,7 @@ function App() {
48
48
  | `headless` | `boolean` | `false` | Enable Headless mode |
49
49
  | `classNames` | `object` | - | Custom CSS class names |
50
50
  | `enabledSigners` | `('nip07' \| 'bunker' \| 'temp')[]` | All enabled | Enabled login methods |
51
+ | `pow` | `number` | `18` | POW difficulty (leading zero bits) to prevent spam |
51
52
  | `onCommentPublished` | `(event: NostrEvent) => void` | - | Callback when comment is published |
52
53
  | `onError` | `(error: Error) => void` | - | Error callback |
53
54
 
@@ -96,6 +97,14 @@ function App() {
96
97
  />
97
98
  ```
98
99
 
100
+ ### Anti-Spam with POW
101
+
102
+ ```tsx
103
+ <NostrComments url="https://example.com/post/123" pow={16} />
104
+ ```
105
+
106
+ Requires commenters to compute a proof-of-work (NIP-13) before publishing. Higher values = more computation time = stronger spam prevention. Recommended: 8-16 bits.
107
+
99
108
  ### Extension Login Only
100
109
 
101
110
  ```tsx
@@ -2,7 +2,8 @@ import type { NostrEvent } from "nostr-tools";
2
2
  interface CommentEditorProps {
3
3
  url: string;
4
4
  relays?: string[];
5
- authorPubkeys?: string[];
5
+ mention?: string;
6
+ pow?: number;
6
7
  parentEvent?: NostrEvent | null;
7
8
  onClearParent?: () => void;
8
9
  onPublished?: (event: NostrEvent) => void;
@@ -10,5 +11,5 @@ interface CommentEditorProps {
10
11
  onError?: (error: Error) => void;
11
12
  className?: string;
12
13
  }
13
- export declare function CommentEditor({ url, relays, authorPubkeys, parentEvent, onClearParent, onPublished, onLoginRequired, onError, className, }: CommentEditorProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function CommentEditor({ url, relays, mention, pow, parentEvent, onClearParent, onPublished, onLoginRequired, onError, className, }: CommentEditorProps): import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -2,9 +2,10 @@ import type { NostrEvent } from "nostr-tools";
2
2
  import type { Comment } from "../types";
3
3
  export interface UseCommentsOptions {
4
4
  url: string;
5
- authors?: string[];
5
+ mention?: string;
6
6
  relays?: string[];
7
7
  pageSize?: number;
8
+ pow?: number;
8
9
  }
9
10
  export declare function useComments(options: UseCommentsOptions): {
10
11
  comments: Comment[];
package/dist/index.d.ts CHANGED
@@ -6,9 +6,10 @@ export { useSigner, useComments, useProfile, isLoggedIn } from "./hooks";
6
6
  export type { UseCommentsOptions } from "./hooks";
7
7
  export { Avatar, Username, CommentItem, CommentList, CommentEditor, LoginModal, } from "./components";
8
8
  export { getDefaultRelays, queryEvents, subscribeEvents, publishEvent, } from "./services/nostr";
9
- export { subscribeComments, fetchComments, publishComment, publishReply, buildCommentTree, } from "./services/comment";
9
+ export { subscribeComments, fetchComments, publishComment, buildCommentTree, } from "./services/comment";
10
10
  export { subscribeReactions, fetchReactions, publishReaction, countLikes, hasLiked, buildReactionEvent, } from "./services/reaction";
11
- export { buildWebComment, buildReplyComment, isReply, getParentId, getRootUrl, } from "./utils/nip22";
11
+ export { buildWebComment, isReply, getParentId, getRootUrl, } from "./utils/nip22";
12
+ export { isValidPubkey } from "./utils/pubkey";
12
13
  export { getColorFromPubkey, generateAvatarSvg, getAvatarDataUrl, } from "./utils/avatar";
13
14
  export { I18nProvider, useI18n, en, zhCN } from "./i18n";
14
15
  import "./styles/base.css";