nostr-wot-sdk 0.8.4 → 0.8.6

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.
Files changed (2) hide show
  1. package/README.md +87 -10
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,25 +1,102 @@
1
1
  # nostr-wot-sdk
2
2
 
3
- > **This package is a back-compat meta re-export.** New code should depend on the scoped packages directly.
3
+ Meta-package and unified React provider for the `@nostr-wot/*` family. Re-exports every scoped package, plus the recommended top-level `<NostrSdkProvider>` that wires up the data layer and (optionally) WoT context with one component.
4
4
 
5
- | Old import | New import |
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i nostr-wot-sdk
9
+ ```
10
+
11
+ This installs the meta and pulls in the scoped packages as transitive deps. New code can also depend on the scoped packages directly:
12
+
13
+ ```bash
14
+ npm i @nostr-wot/data
15
+ npm i @nostr-wot/dm
16
+ npm i @nostr-wot/wot
17
+ npm i @nostr-wot/relay
18
+ npm i @nostr-wot/signers
19
+ npm i @nostr-wot/blossom
20
+ npm i @nostr-wot/wallet
21
+ ```
22
+
23
+ ## React provider (recommended top-level)
24
+
25
+ ```tsx
26
+ import { NostrSdkProvider } from "nostr-wot-sdk/react";
27
+
28
+ <NostrSdkProvider
29
+ relays={["wss://relay.damus.io", "wss://nos.lol"]}
30
+ profileAggregators={["wss://purplepag.es"]}
31
+ persistence={{ namespace: "myapp", ttlMs: 86400_000 }}
32
+ wot={{ enabled: true, options: { maxHops: 2 } }}
33
+ >
34
+ <App />
35
+ </NostrSdkProvider>;
36
+ ```
37
+
38
+ `<NostrSdkProvider>` is the recommended root for any app using the SDK. It composes:
39
+
40
+ - `<NostrDataProvider>` from `@nostr-wot/data/react` — configures default relays, profile aggregators, and SWR cache persistence
41
+ - `<WoTProvider>` from `@nostr-wot/wot/react` (only when `wot.enabled: true`) — provides WoT scoring context
42
+
43
+ WoT hooks (`useWoT`, `useTrustScore`, `useIsInWoT`, `useBatchWoT`) require `wot.enabled: true`. Data hooks (`useProfile`, `useNote`, `useThread`, …) work either way.
44
+
45
+ ## Re-export map
46
+
47
+ | Import from `nostr-wot-sdk` | Equivalent scoped package |
6
48
  |---|---|
7
49
  | `nostr-wot-sdk` | `@nostr-wot/wot` |
8
- | `nostr-wot-sdk/react` | `@nostr-wot/wot/react` + `@nostr-wot/data/react` |
50
+ | `nostr-wot-sdk/react` | `@nostr-wot/wot/react` + `@nostr-wot/data/react` + `<NostrSdkProvider>` |
9
51
  | `nostr-wot-sdk/solid` | `@nostr-wot/wot/solid` |
10
52
  | `nostr-wot-sdk/relay` | `@nostr-wot/relay` |
11
53
  | `nostr-wot-sdk/relay/react` | `@nostr-wot/relay/react` |
12
54
  | `nostr-wot-sdk/data` | `@nostr-wot/data` |
13
55
  | `nostr-wot-sdk/data/cache` | `@nostr-wot/data/cache` |
14
56
 
15
- Existing imports keep working — this package just re-exports the scoped packages so older consumers don't break. It will continue to be published in lock-step with `@nostr-wot/*` minor releases.
57
+ For DM, signers, blossom, and wallet, use the scoped packages directly — they're not re-exported from this meta:
16
58
 
17
- For new projects, install only the scoped package(s) you actually need:
59
+ ```ts
60
+ import { Nip07Signer } from "@nostr-wot/signers";
61
+ import { sealAndGiftWrap } from "@nostr-wot/dm";
62
+ import { useDMSession } from "@nostr-wot/dm/react";
63
+ import { uploadToBlossom } from "@nostr-wot/blossom";
64
+ import { NwcClient, requestZapInvoice } from "@nostr-wot/wallet";
65
+ ```
18
66
 
19
- ```bash
20
- npm i @nostr-wot/data # event fetchers + cache + hooks
21
- npm i @nostr-wot/wot # WoT scoring + browser-extension bridge
22
- npm i @nostr-wot/relay # low-level relay utilities
67
+ ## Architecture
68
+
69
+ ```
70
+ ┌────────────────────┐
71
+ │ Your app │
72
+ └─────────┬──────────┘
73
+ │
74
+ ┌─────────▼──────────┐
75
+ │ <NostrSdkProvider> │ ← unified config
76
+ └─────────┬──────────┘
77
+ ┌──────────────┼─────────────┐
78
+ ▼ ▼ ▼
79
+ data fetchers WoT scoring DM cache
80
+ │ │ │
81
+ └──────────────┼─────────────┘
82
+ ▼
83
+ ┌──────────────────┐
84
+ │ shared SimplePool│ ← one set of WebSocket
85
+ └──────────────────┘ connections
23
86
  ```
24
87
 
25
- See [the monorepo README](https://github.com/nostr-wot/nostr-wot-sdk) for architecture and per-package docs.
88
+ Every `@nostr-wot/*` package shares the same connection pool via `getPool()` / `setPool()` from `@nostr-wot/data`. Subscribe-once-fan-out-everywhere is enforced by `sharedCoalescer`, so DM inbox, profile reads, follower lists, and engagement queries are all coalesced on the wire.
89
+
90
+ ## Per-package docs
91
+
92
+ - [@nostr-wot/data](https://www.npmjs.com/package/@nostr-wot/data) — fetchers, cache, hooks
93
+ - [@nostr-wot/relay](https://www.npmjs.com/package/@nostr-wot/relay) — pool, batcher, stats
94
+ - [@nostr-wot/signers](https://www.npmjs.com/package/@nostr-wot/signers) — NIP-07/46/55 + private key
95
+ - [@nostr-wot/dm](https://www.npmjs.com/package/@nostr-wot/dm) — NIP-04, NIP-17, cache, hooks
96
+ - [@nostr-wot/blossom](https://www.npmjs.com/package/@nostr-wot/blossom) — uploads
97
+ - [@nostr-wot/wallet](https://www.npmjs.com/package/@nostr-wot/wallet) — NWC + zaps
98
+ - [@nostr-wot/wot](https://www.npmjs.com/package/@nostr-wot/wot) — Web-of-Trust scoring
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nostr-wot-sdk",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Meta-package re-exporting @nostr-wot/{wot,relay,data}. Existing imports keep working; new code should depend on the scoped packages directly.",
5
5
  "author": "Leon Acosta <leon@nostr-wot.com>",
6
6
  "license": "MIT",
@@ -114,9 +114,9 @@
114
114
  "prepublishOnly": "npm run build"
115
115
  },
116
116
  "dependencies": {
117
- "@nostr-wot/data": "^0.3.0",
118
- "@nostr-wot/relay": "^0.1.0",
119
- "@nostr-wot/wot": "^0.1.3"
117
+ "@nostr-wot/data": "^0.3.1",
118
+ "@nostr-wot/relay": "^0.1.1",
119
+ "@nostr-wot/wot": "^0.1.4"
120
120
  },
121
121
  "peerDependencies": {
122
122
  "react": ">=16.8.0",