nostr-tools 1.5.0 → 1.6.1
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 +7 -9
- package/build.js +8 -2
- package/lib/esm/nostr.mjs +1144 -0
- package/lib/esm/nostr.mjs.map +7 -0
- package/lib/esm/package.json +1 -0
- package/lib/nostr.bundle.js +29 -23
- package/lib/nostr.bundle.js.map +2 -2
- package/lib/nostr.cjs.js +29 -23
- package/lib/nostr.cjs.js.map +2 -2
- package/nip19.test.js +12 -0
- package/nip19.ts +3 -3
- package/package.json +6 -2
- package/pool.test.js +2 -2
- package/pool.ts +17 -10
- package/relay.test.js +2 -2
- package/relay.ts +11 -11
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ let event = await relay.get({
|
|
|
120
120
|
ids: ['44e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245']
|
|
121
121
|
})
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
relay.close()
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
To use this on Node.js you first must install `websocket-polyfill` and import it:
|
|
@@ -140,16 +140,14 @@ let relays = ['wss://relay.example.com', 'wss://relay.example2.com']
|
|
|
140
140
|
|
|
141
141
|
let relay = await pool.ensureRelay('wss://relay.example3.com')
|
|
142
142
|
|
|
143
|
-
let
|
|
143
|
+
let sub = pool.sub([...relays, relay], [{
|
|
144
144
|
authors: ['32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245']
|
|
145
|
-
})
|
|
145
|
+
}])
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
})
|
|
152
|
-
)
|
|
147
|
+
sub.on('event', event => {
|
|
148
|
+
// this will only be called once the first time the event is received
|
|
149
|
+
// ...
|
|
150
|
+
})
|
|
153
151
|
|
|
154
152
|
let pubs = pool.publish(relays, newEvent)
|
|
155
153
|
pubs.forEach(pub =>
|
package/build.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
const fs = require('fs')
|
|
3
4
|
const esbuild = require('esbuild')
|
|
4
5
|
|
|
5
6
|
let common = {
|
|
@@ -11,11 +12,16 @@ let common = {
|
|
|
11
12
|
esbuild
|
|
12
13
|
.build({
|
|
13
14
|
...common,
|
|
14
|
-
outfile: 'lib/nostr.
|
|
15
|
+
outfile: 'lib/esm/nostr.mjs',
|
|
15
16
|
format: 'esm',
|
|
16
17
|
packages: 'external'
|
|
17
18
|
})
|
|
18
|
-
.then(() =>
|
|
19
|
+
.then(() => {
|
|
20
|
+
const packageJson = JSON.stringify({ type: 'module' })
|
|
21
|
+
fs.writeFileSync(`${__dirname}/lib/esm/package.json`, packageJson, 'utf8')
|
|
22
|
+
|
|
23
|
+
console.log('esm build success.')
|
|
24
|
+
})
|
|
19
25
|
|
|
20
26
|
esbuild
|
|
21
27
|
.build({
|