mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +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
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
push:
|
||||
tags: [v*]
|
||||
|
||||
jobs:
|
||||
publish-npm:
|
||||
@@ -11,8 +11,9 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: 18
|
||||
- run: yarn --ignore-engines
|
||||
- run: node build.js
|
||||
- run: npm publish
|
||||
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
|
||||
on:
|
||||
- push
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -11,5 +13,5 @@ jobs:
|
||||
with:
|
||||
node-version: 18
|
||||
- run: yarn --ignore-engines
|
||||
- run: node build.cjs
|
||||
- run: node build.js
|
||||
- run: yarn test
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,7 +3,5 @@ dist
|
||||
yarn.lock
|
||||
package-lock.json
|
||||
.envrc
|
||||
standalone
|
||||
cjs
|
||||
esm
|
||||
lib
|
||||
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)
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/nostr-tools/standalone/index.js"></script>
|
||||
<script src="https://unpkg.com/nostr-tools/nostr.bundle.js"></script>
|
||||
<script>
|
||||
window.NostrTools.generatePrivateKey('...') // and so on
|
||||
</script>
|
||||
|
||||
@@ -15,17 +15,27 @@ let common = {
|
||||
}
|
||||
|
||||
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.'))
|
||||
|
||||
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.'))
|
||||
|
||||
esbuild
|
||||
.build({
|
||||
...common,
|
||||
outdir: 'standalone/',
|
||||
outfile: 'lib/nostr.bundle.js',
|
||||
format: 'iife',
|
||||
globalName: 'NostrTools',
|
||||
define: {
|
||||
@@ -6,7 +6,7 @@ const {
|
||||
signEvent,
|
||||
getEventHash,
|
||||
getPublicKey
|
||||
} = require('./cjs')
|
||||
} = require('./lib/nostr.cjs')
|
||||
|
||||
const event = {
|
||||
id: 'd7dd5eb3ab747e16f8d0212d53032ea2a7cadef53837e5a6c66d42849fcb9027',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-env jest */
|
||||
|
||||
const {matchFilters} = require('./cjs')
|
||||
const {matchFilters} = require('./lib/nostr.cjs')
|
||||
|
||||
test('test if filters match', () => {
|
||||
;[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-env jest */
|
||||
|
||||
const {generatePrivateKey, getPublicKey} = require('./cjs')
|
||||
const {generatePrivateKey, getPublicKey} = require('./lib/nostr.cjs')
|
||||
|
||||
test('test private key generation', () => {
|
||||
expect(generatePrivateKey()).toMatch(/[a-f0-9]{64}/)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-env jest */
|
||||
|
||||
const {nip04, getPublicKey, generatePrivateKey} = require('./cjs')
|
||||
const {nip04, getPublicKey, generatePrivateKey} = require('./lib/nostr.cjs')
|
||||
|
||||
test('encrypt and decrypt message', () => {
|
||||
let sk1 = generatePrivateKey()
|
||||
|
||||
10
package.json
10
package.json
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "nostr-tools",
|
||||
"version": "1.0.0-alpha",
|
||||
"version": "1.0.0-alpha2",
|
||||
"description": "Tools for making a Nostr client.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fiatjaf/nostr-tools.git"
|
||||
},
|
||||
"main": "cjs/index.js",
|
||||
"module": "esm/index.js",
|
||||
"main": "lib/nostr.cjs.js",
|
||||
"module": "lib/nostr.esm.js",
|
||||
"dependencies": {
|
||||
"@noble/hashes": "^0.5.7",
|
||||
"@noble/secp256k1": "^1.7.0",
|
||||
@@ -40,8 +40,8 @@
|
||||
"typescript": "^4.9.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node build.cjs",
|
||||
"pretest": "node build.cjs",
|
||||
"build": "node build.js",
|
||||
"pretest": "node build.js",
|
||||
"test": "jest"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ const {
|
||||
getPublicKey,
|
||||
getEventHash,
|
||||
signEvent
|
||||
} = require('./cjs')
|
||||
} = require('./lib/nostr.cjs')
|
||||
|
||||
describe('relay interaction', () => {
|
||||
let relay = relayInit('wss://nostr-pub.wellorder.net/')
|
||||
let relay = relayInit('wss://nostr-pub.semisol.dev/')
|
||||
|
||||
beforeAll(() => {
|
||||
relay.connect()
|
||||
|
||||
Reference in New Issue
Block a user