nostr-comments 0.6.0 → 0.7.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
@@ -25,7 +25,6 @@ npm install nostr-comments
25
25
 
26
26
  ```tsx
27
27
  import { NostrComments } from "nostr-comments";
28
- import "nostr-comments/style.css";
29
28
 
30
29
  function App() {
31
30
  return <NostrComments url="https://example.com/blog/my-post" locale="en" />;
@@ -36,21 +35,22 @@ function App() {
36
35
 
37
36
  ### NostrComments Component Props
38
37
 
39
- | Prop | Type | Default | Description |
40
- | -------------------- | ----------------------------------- | ------------------ | ---------------------------------------------------- |
41
- | `url` | `string` | **Required** | Web page URL, used to identify comment scope |
38
+ | Prop | Type | Default | Description |
39
+ | -------------------- | ----------------------------------- | ------------------ | ---------------------------------------------------------- |
40
+ | `url` | `string` | **Required** | Web page URL, used to identify comment scope |
42
41
  | `mention` | `string` | - | Public key to mention in comments (receives notifications) |
43
- | `relays` | `string[]` | Default relay list | List of Nostr relay addresses |
44
- | `pageSize` | `number` | `50` | Number of comments per page |
45
- | `locale` | `string` | Auto-detect | Interface language (20 languages supported) |
46
- | `translations` | `Partial<Translations>` | - | Custom translation text |
47
- | `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Theme mode |
48
- | `headless` | `boolean` | `false` | Enable Headless mode |
49
- | `classNames` | `object` | - | Custom CSS class names |
50
- | `enabledSigners` | `('nip07' \| 'bunker' \| 'temp')[]` | All enabled | Enabled login methods |
51
- | `pow` | `number` | `18` | POW difficulty (leading zero bits) to prevent spam |
52
- | `onCommentPublished` | `(event: NostrEvent) => void` | - | Callback when comment is published |
53
- | `onError` | `(error: Error) => void` | - | Error callback |
42
+ | `relays` | `string[]` | Default relay list | List of Nostr relay addresses |
43
+ | `pageSize` | `number` | `50` | Number of comments per page |
44
+ | `locale` | `string` | Auto-detect | Interface language (20 languages supported) |
45
+ | `translations` | `Partial<Translations>` | - | Custom translation text |
46
+ | `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | Theme mode |
47
+ | `headless` | `boolean` | `false` | Enable Headless mode |
48
+ | `classNames` | `object` | - | Custom CSS class names |
49
+ | `signer` | `Signer` | - | External signer instance (skips login modal when provided) |
50
+ | `enabledSigners` | `('nip07' \| 'bunker' \| 'temp')[]` | All enabled | Enabled login methods |
51
+ | `pow` | `number` | `18` | POW difficulty (leading zero bits) to prevent spam |
52
+ | `onCommentPublished` | `(event: NostrEvent) => void` | - | Callback when comment is published |
53
+ | `onError` | `(error: Error) => void` | - | Error callback |
54
54
 
55
55
  ### classNames Object
56
56
 
@@ -100,10 +100,10 @@ function App() {
100
100
  ### Anti-Spam with POW
101
101
 
102
102
  ```tsx
103
- <NostrComments url="https://example.com/post/123" pow={16} />
103
+ <NostrComments url="https://example.com/post/123" pow={18} />
104
104
  ```
105
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.
106
+ Requires commenters to compute a proof-of-work (NIP-13) before publishing. Higher values = more computation time = stronger spam prevention. Recommended: 10-20 bits.
107
107
 
108
108
  ### Extension Login Only
109
109
 
@@ -111,6 +111,28 @@ Requires commenters to compute a proof-of-work (NIP-13) before publishing. Highe
111
111
  <NostrComments url="https://example.com/post/123" enabledSigners={["nip07"]} />
112
112
  ```
113
113
 
114
+ ### External Signer
115
+
116
+ Pass your own signer instance to skip the built-in login modal:
117
+
118
+ ```tsx
119
+ import { NostrComments, Nip07Signer, TempSigner } from "nostr-comments";
120
+
121
+ // Use NIP-07 extension
122
+ const signer = new Nip07Signer();
123
+
124
+ // Or use a temporary signer
125
+ const signer = new TempSigner();
126
+
127
+ // Or any object that implements the Signer interface
128
+ const customSigner = {
129
+ getPublicKey: async () => "your-pubkey",
130
+ signEvent: async (event) => signedEvent,
131
+ };
132
+
133
+ <NostrComments url="https://example.com/post/123" signer={signer} />;
134
+ ```
135
+
114
136
  ### Headless Mode
115
137
 
116
138
  ```tsx
@@ -169,8 +191,10 @@ For dark mode, override the base colors under `[data-theme="dark"]` or `[data-th
169
191
 
170
192
  /* Border Radius */
171
193
  --nc-radius-sm: 8px;
194
+ /* button, textarea radius */
172
195
  --nc-radius-md: 12px;
173
196
  --nc-radius-lg: 16px;
197
+ /* modal radius */
174
198
  --nc-radius-xl: 24px;
175
199
 
176
200
  /* Avatar Border Radius */
@@ -1,4 +1,4 @@
1
- export { useSigner, isLoggedIn } from "./useSigner";
1
+ export { useSigner, isLoggedIn, setExternalSigner } from "./useSigner";
2
2
  export { useComments } from "./useComments";
3
3
  export type { UseCommentsOptions } from "./useComments";
4
4
  export { useProfile } from "./useProfile";
@@ -1,6 +1,7 @@
1
1
  import { TempSigner } from "../signers";
2
2
  import type { Signer, SignerInfo } from "../signers/types";
3
3
  export declare function isLoggedIn(): boolean;
4
+ export declare function setExternalSigner(signer: Signer): Promise<boolean>;
4
5
  export declare function useSigner(): {
5
6
  signer: Signer | null;
6
7
  signerInfo: SignerInfo | null;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { NostrComments } from "./NostrComments";
2
2
  export type { NostrCommentsProps, Comment, Profile, Translations, } from "./types";
3
3
  export { Nip07Signer, TempSigner, BunkerSigner } from "./signers";
4
4
  export type { Signer, SignerType, SignerInfo } from "./signers";
5
- export { useSigner, useComments, useProfile, isLoggedIn } from "./hooks";
5
+ export { useSigner, useComments, useProfile, isLoggedIn, setExternalSigner } 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";