nostr-tools 0.23.0 → 0.23.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 +17 -0
- package/build.js +25 -0
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -70,3 +70,20 @@ pool.addRelay('<url>')
|
|
|
70
70
|
All functions expect bytearrays as hex strings and output bytearrays as hex strings.
|
|
71
71
|
|
|
72
72
|
For other utils please read the source (for now).
|
|
73
|
+
|
|
74
|
+
### Using from the browser (if you don't want to use a bundler)
|
|
75
|
+
|
|
76
|
+
You can import nostr-tools as an ES module. Just add a script tag like this:
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<script type="module">
|
|
80
|
+
import {generatePrivateKey} from 'https://unpkg.com/nostr-tools/nostr.js'
|
|
81
|
+
console.log(generatePrivateKey())
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
And import whatever function you would import from `"nostr-tools"` in a bundler.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
Public domain.
|
package/build.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const esbuild = require('esbuild')
|
|
4
|
+
const alias = require('esbuild-plugin-alias')
|
|
5
|
+
const nodeGlobals = require('@esbuild-plugins/node-globals-polyfill').default
|
|
6
|
+
|
|
7
|
+
const buildOptions = {
|
|
8
|
+
entryPoints: ['index.js'],
|
|
9
|
+
outfile: 'nostr.js',
|
|
10
|
+
bundle: true,
|
|
11
|
+
format: 'esm',
|
|
12
|
+
plugins: [
|
|
13
|
+
alias({
|
|
14
|
+
stream: require.resolve('readable-stream')
|
|
15
|
+
}),
|
|
16
|
+
nodeGlobals({buffer: true})
|
|
17
|
+
],
|
|
18
|
+
define: {
|
|
19
|
+
window: 'self',
|
|
20
|
+
global: 'self'
|
|
21
|
+
},
|
|
22
|
+
loader: {'.js': 'jsx'}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
esbuild.build(buildOptions).then(() => console.log('build success.'))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-tools",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Tools for making a Nostr client.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,15 @@
|
|
|
30
30
|
"client"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
34
|
+
"esbuild": "^0.14.38",
|
|
35
|
+
"esbuild-plugin-alias": "^0.2.1",
|
|
33
36
|
"eslint": "^8.5.0",
|
|
34
|
-
"eslint-plugin-babel": "^5.3.1"
|
|
37
|
+
"eslint-plugin-babel": "^5.3.1",
|
|
38
|
+
"events": "^3.3.0",
|
|
39
|
+
"readable-stream": "^3.6.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"prepublish": "node build.js"
|
|
35
43
|
}
|
|
36
44
|
}
|