mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
Compare commits
2 Commits
v1.0.0-alp
...
v1.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b96159ad36 | ||
|
|
6dede4a688 |
11
.github/workflows/npm-publish.yml
vendored
11
.github/workflows/npm-publish.yml
vendored
@@ -1,8 +1,8 @@
|
|||||||
name: publish npm package
|
name: publish npm package
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types: [created]
|
tags: [v*]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish-npm:
|
publish-npm:
|
||||||
@@ -11,8 +11,9 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v3
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 16
|
node-version: 18
|
||||||
registry-url: https://registry.npmjs.org/
|
- run: yarn --ignore-engines
|
||||||
|
- run: node build.js
|
||||||
- run: npm publish
|
- run: npm publish
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||||
|
|||||||
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -1,6 +1,8 @@
|
|||||||
name: test every commit
|
name: test every commit
|
||||||
on:
|
on:
|
||||||
- push
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
@@ -11,5 +13,5 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: 18
|
||||||
- run: yarn --ignore-engines
|
- run: yarn --ignore-engines
|
||||||
- run: node build.cjs
|
- run: node build.js
|
||||||
- run: yarn test
|
- run: yarn test
|
||||||
|
|||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,7 +3,5 @@ dist
|
|||||||
yarn.lock
|
yarn.lock
|
||||||
package-lock.json
|
package-lock.json
|
||||||
.envrc
|
.envrc
|
||||||
standalone
|
lib
|
||||||
cjs
|
|
||||||
esm
|
|
||||||
test.html
|
test.html
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ Please consult the tests or [the source code](https://github.com/fiatjaf/nostr-t
|
|||||||
### Using from the browser (if you don't want to use a bundler)
|
### Using from the browser (if you don't want to use a bundler)
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://unpkg.com/nostr-tools/standalone/index.js"></script>
|
<script src="https://unpkg.com/nostr-tools/nostr.bundle.js"></script>
|
||||||
<script>
|
<script>
|
||||||
window.NostrTools.generatePrivateKey('...') // and so on
|
window.NostrTools.generatePrivateKey('...') // and so on
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -15,17 +15,27 @@ let common = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
esbuild
|
esbuild
|
||||||
.build({...common, outdir: 'esm/', format: 'esm', packages: 'external'})
|
.build({
|
||||||
|
...common,
|
||||||
|
outfile: 'lib/nostr.esm.js',
|
||||||
|
format: 'esm',
|
||||||
|
packages: 'external'
|
||||||
|
})
|
||||||
.then(() => console.log('esm build success.'))
|
.then(() => console.log('esm build success.'))
|
||||||
|
|
||||||
esbuild
|
esbuild
|
||||||
.build({...common, outdir: 'cjs/', format: 'cjs', packages: 'external'})
|
.build({
|
||||||
|
...common,
|
||||||
|
outfile: 'lib/nostr.cjs.js',
|
||||||
|
format: 'cjs',
|
||||||
|
packages: 'external'
|
||||||
|
})
|
||||||
.then(() => console.log('cjs build success.'))
|
.then(() => console.log('cjs build success.'))
|
||||||
|
|
||||||
esbuild
|
esbuild
|
||||||
.build({
|
.build({
|
||||||
...common,
|
...common,
|
||||||
outdir: 'standalone/',
|
outfile: 'lib/nostr.bundle.js',
|
||||||
format: 'iife',
|
format: 'iife',
|
||||||
globalName: 'NostrTools',
|
globalName: 'NostrTools',
|
||||||
define: {
|
define: {
|
||||||
@@ -6,7 +6,7 @@ const {
|
|||||||
signEvent,
|
signEvent,
|
||||||
getEventHash,
|
getEventHash,
|
||||||
getPublicKey
|
getPublicKey
|
||||||
} = require('./cjs')
|
} = require('./lib/nostr.cjs')
|
||||||
|
|
||||||
const event = {
|
const event = {
|
||||||
id: 'd7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027',
|
id: 'd7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
const {matchFilters} = require('./cjs')
|
const {matchFilters} = require('./lib/nostr.cjs')
|
||||||
|
|
||||||
test('test if filters match', () => {
|
test('test if filters match', () => {
|
||||||
;[
|
;[
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
const {generatePrivateKey, getPublicKey} = require('./cjs')
|
const {generatePrivateKey, getPublicKey} = require('./lib/nostr.cjs')
|
||||||
|
|
||||||
test('test private key generation', () => {
|
test('test private key generation', () => {
|
||||||
expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/)
|
expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-env jest */
|
/* eslint-env jest */
|
||||||
|
|
||||||
const {nip04, getPublicKey, generatePrivateKey} = require('./cjs')
|
const {nip04, getPublicKey, generatePrivateKey} = require('./lib/nostr.cjs')
|
||||||
|
|
||||||
test('encrypt and decrypt message', () => {
|
test('encrypt and decrypt message', () => {
|
||||||
let sk1 = generatePrivateKey()
|
let sk1 = generatePrivateKey()
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "1.0.0-alpha",
|
"version": "1.0.0-alpha2",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/fiatjaf/nostr-tools.git"
|
"url": "https://github.com/fiatjaf/nostr-tools.git"
|
||||||
},
|
},
|
||||||
"main": "cjs/index.js",
|
"main": "lib/nostr.cjs.js",
|
||||||
"module": "esm/index.js",
|
"module": "lib/nostr.esm.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/hashes": "^0.5.7",
|
"@noble/hashes": "^0.5.7",
|
||||||
"@noble/secp256k1": "^1.7.0",
|
"@noble/secp256k1": "^1.7.0",
|
||||||
@@ -40,8 +40,8 @@
|
|||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build.cjs",
|
"build": "node build.js",
|
||||||
"pretest": "node build.cjs",
|
"pretest": "node build.js",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ const {
|
|||||||
getPublicKey,
|
getPublicKey,
|
||||||
getEventHash,
|
getEventHash,
|
||||||
signEvent
|
signEvent
|
||||||
} = require('./cjs')
|
} = require('./lib/nostr.cjs')
|
||||||
|
|
||||||
describe('relay interaction', () => {
|
describe('relay interaction', () => {
|
||||||
let relay = relayInit('wss://nostr-pub.wellorder.net/')
|
let relay = relayInit('wss://nostr-pub.semisol.dev/')
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
relay.connect()
|
relay.connect()
|
||||||
|
|||||||
Reference in New Issue
Block a user