mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2026-02-01 14:55:51 +00:00
Compare commits
3 Commits
b40f59af74
...
v2.21.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aea4bf702e | ||
|
|
42c9c7554d | ||
|
|
3588d30044 |
15
build.js
15
build.js
@@ -42,18 +42,3 @@ esbuild
|
|||||||
|
|
||||||
console.log('cjs build success.')
|
console.log('cjs build success.')
|
||||||
})
|
})
|
||||||
|
|
||||||
esbuild
|
|
||||||
.build({
|
|
||||||
...common,
|
|
||||||
entryPoints: ['index.ts'],
|
|
||||||
outfile: 'lib/nostr.bundle.js',
|
|
||||||
format: 'iife',
|
|
||||||
globalName: 'NostrTools',
|
|
||||||
define: {
|
|
||||||
window: 'self',
|
|
||||||
global: 'self',
|
|
||||||
process: '{"env": {}}',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(() => console.log('standalone build success.'))
|
|
||||||
|
|||||||
32
index.ts
32
index.ts
@@ -1,32 +0,0 @@
|
|||||||
export * from './pure.ts'
|
|
||||||
export { Relay } from './relay.ts'
|
|
||||||
export * from './filter.ts'
|
|
||||||
export { SimplePool } from './pool.ts'
|
|
||||||
export * from './references.ts'
|
|
||||||
|
|
||||||
export * as nip04 from './nip04.ts'
|
|
||||||
export * as nip05 from './nip05.ts'
|
|
||||||
export * as nip10 from './nip10.ts'
|
|
||||||
export * as nip11 from './nip11.ts'
|
|
||||||
export * as nip13 from './nip13.ts'
|
|
||||||
export * as nip17 from './nip17.ts'
|
|
||||||
export * as nip18 from './nip18.ts'
|
|
||||||
export * as nip19 from './nip19.ts'
|
|
||||||
export * as nip21 from './nip21.ts'
|
|
||||||
export * as nip25 from './nip25.ts'
|
|
||||||
export * as nip27 from './nip27.ts'
|
|
||||||
export * as nip28 from './nip28.ts'
|
|
||||||
export * as nip30 from './nip30.ts'
|
|
||||||
export * as nip39 from './nip39.ts'
|
|
||||||
export * as nip42 from './nip42.ts'
|
|
||||||
export * as nip44 from './nip44.ts'
|
|
||||||
export * as nip47 from './nip47.ts'
|
|
||||||
export * as nip54 from './nip54.ts'
|
|
||||||
export * as nip57 from './nip57.ts'
|
|
||||||
export * as nip59 from './nip59.ts'
|
|
||||||
export * as nip77 from './nip77.ts'
|
|
||||||
export * as nip98 from './nip98.ts'
|
|
||||||
|
|
||||||
export * as kinds from './kinds.ts'
|
|
||||||
export * as fj from './fakejson.ts'
|
|
||||||
export * as utils from './utils.ts'
|
|
||||||
3
jsr.json
3
jsr.json
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@nostr/tools",
|
"name": "@nostr/tools",
|
||||||
"version": "2.20.0",
|
"version": "2.21.0",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./index.ts",
|
|
||||||
"./core": "./core.ts",
|
"./core": "./core.ts",
|
||||||
"./pure": "./pure.ts",
|
"./pure": "./pure.ts",
|
||||||
"./wasm": "./wasm.ts",
|
"./wasm": "./wasm.ts",
|
||||||
|
|||||||
4
nip04.ts
4
nip04.ts
@@ -1,6 +1,6 @@
|
|||||||
import { bytesToHex, hexToBytes, randomBytes } from '@noble/hashes/utils.js'
|
import { hexToBytes, randomBytes } from '@noble/hashes/utils.js'
|
||||||
import { secp256k1 } from '@noble/curves/secp256k1.js'
|
import { secp256k1 } from '@noble/curves/secp256k1.js'
|
||||||
import { cbc } from '@noble/ciphers/aes'
|
import { cbc } from '@noble/ciphers/aes.js'
|
||||||
import { base64 } from '@scure/base'
|
import { base64 } from '@scure/base'
|
||||||
|
|
||||||
import { utf8Decoder, utf8Encoder } from './utils.ts'
|
import { utf8Decoder, utf8Encoder } from './utils.ts'
|
||||||
|
|||||||
2
nip06.ts
2
nip06.ts
@@ -1,5 +1,5 @@
|
|||||||
import { bytesToHex } from '@noble/hashes/utils.js'
|
import { bytesToHex } from '@noble/hashes/utils.js'
|
||||||
import { wordlist } from '@scure/bip39/wordlists/english'
|
import { wordlist } from '@scure/bip39/wordlists/english.js'
|
||||||
import { generateMnemonic, mnemonicToSeedSync, validateMnemonic } from '@scure/bip39'
|
import { generateMnemonic, mnemonicToSeedSync, validateMnemonic } from '@scure/bip39'
|
||||||
import { HDKey } from '@scure/bip32'
|
import { HDKey } from '@scure/bip32'
|
||||||
|
|
||||||
|
|||||||
2
nip19.ts
2
nip19.ts
@@ -110,7 +110,7 @@ export function decode(nip19: NPub): DecodedNpub
|
|||||||
export function decode(nip19: Note): DecodedNote
|
export function decode(nip19: Note): DecodedNote
|
||||||
export function decode(code: string): DecodedResult
|
export function decode(code: string): DecodedResult
|
||||||
export function decode(code: string): DecodedResult {
|
export function decode(code: string): DecodedResult {
|
||||||
let { prefix, words } = bech32.decode(code, Bech32MaxSize)
|
let { prefix, words } = bech32.decode(code as `${string}1${string}`, Bech32MaxSize)
|
||||||
let data = new Uint8Array(bech32.fromWords(words))
|
let data = new Uint8Array(bech32.fromWords(words))
|
||||||
|
|
||||||
switch (prefix) {
|
switch (prefix) {
|
||||||
|
|||||||
4
nip44.ts
4
nip44.ts
@@ -1,5 +1,5 @@
|
|||||||
import { chacha20 } from '@noble/ciphers/chacha'
|
import { chacha20 } from '@noble/ciphers/chacha.js'
|
||||||
import { equalBytes } from '@noble/ciphers/utils'
|
import { equalBytes } from '@noble/ciphers/utils.js'
|
||||||
import { secp256k1 } from '@noble/curves/secp256k1.js'
|
import { secp256k1 } from '@noble/curves/secp256k1.js'
|
||||||
import { extract as hkdf_extract, expand as hkdf_expand } from '@noble/hashes/hkdf.js'
|
import { extract as hkdf_extract, expand as hkdf_expand } from '@noble/hashes/hkdf.js'
|
||||||
import { hmac } from '@noble/hashes/hmac.js'
|
import { hmac } from '@noble/hashes/hmac.js'
|
||||||
|
|||||||
6
nip49.ts
6
nip49.ts
@@ -1,8 +1,8 @@
|
|||||||
|
import { bech32 } from '@scure/base'
|
||||||
import { scrypt } from '@noble/hashes/scrypt.js'
|
import { scrypt } from '@noble/hashes/scrypt.js'
|
||||||
import { xchacha20poly1305 } from '@noble/ciphers/chacha'
|
import { xchacha20poly1305 } from '@noble/ciphers/chacha.js'
|
||||||
import { concatBytes, randomBytes } from '@noble/hashes/utils.js'
|
import { concatBytes, randomBytes } from '@noble/hashes/utils.js'
|
||||||
import { Bech32MaxSize, Ncryptsec, encodeBytes } from './nip19.ts'
|
import { Bech32MaxSize, Ncryptsec, encodeBytes } from './nip19.ts'
|
||||||
import { bech32 } from '@scure/base'
|
|
||||||
|
|
||||||
export function encrypt(
|
export function encrypt(
|
||||||
sec: Uint8Array,
|
sec: Uint8Array,
|
||||||
@@ -22,7 +22,7 @@ export function encrypt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function decrypt(ncryptsec: string, password: string): Uint8Array {
|
export function decrypt(ncryptsec: string, password: string): Uint8Array {
|
||||||
let { prefix, words } = bech32.decode(ncryptsec, Bech32MaxSize)
|
let { prefix, words } = bech32.decode(ncryptsec as `${string}1${string}`, Bech32MaxSize)
|
||||||
if (prefix !== 'ncryptsec') {
|
if (prefix !== 'ncryptsec') {
|
||||||
throw new Error(`invalid prefix ${prefix}, expected 'ncryptsec'`)
|
throw new Error(`invalid prefix ${prefix}, expected 'ncryptsec'`)
|
||||||
}
|
}
|
||||||
|
|||||||
2
nip77.ts
2
nip77.ts
@@ -1,4 +1,4 @@
|
|||||||
import { bytesToHex, hexToBytes } from '@noble/ciphers/utils'
|
import { bytesToHex, hexToBytes } from '@noble/hashes/utils.js'
|
||||||
import { Filter } from './filter.ts'
|
import { Filter } from './filter.ts'
|
||||||
import { AbstractRelay, Subscription } from './relay.ts'
|
import { AbstractRelay, Subscription } from './relay.ts'
|
||||||
import { sha256 } from '@noble/hashes/sha2.js'
|
import { sha256 } from '@noble/hashes/sha2.js'
|
||||||
|
|||||||
265
package.json
265
package.json
@@ -1,264 +1,14 @@
|
|||||||
{
|
{
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"name": "nostr-tools",
|
|
||||||
"version": "2.20.0",
|
|
||||||
"description": "Tools for making a Nostr client.",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/nbd-wtf/nostr-tools.git"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"sideEffects": false,
|
|
||||||
"module": "./lib/esm/index.js",
|
|
||||||
"main": "./lib/cjs/index.js",
|
|
||||||
"types": "./lib/types/index.d.ts",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"import": "./lib/esm/index.js",
|
|
||||||
"require": "./lib/cjs/index.js",
|
|
||||||
"types": "./lib/types/index.d.ts"
|
|
||||||
},
|
|
||||||
"./core": {
|
|
||||||
"import": "./lib/esm/core.js",
|
|
||||||
"require": "./lib/cjs/core.js",
|
|
||||||
"types": "./lib/types/core.d.ts"
|
|
||||||
},
|
|
||||||
"./pure": {
|
|
||||||
"import": "./lib/esm/pure.js",
|
|
||||||
"require": "./lib/cjs/pure.js",
|
|
||||||
"types": "./lib/types/pure.d.ts"
|
|
||||||
},
|
|
||||||
"./wasm": {
|
|
||||||
"import": "./lib/esm/wasm.js",
|
|
||||||
"require": "./lib/cjs/wasm.js",
|
|
||||||
"types": "./lib/types/wasm.d.ts"
|
|
||||||
},
|
|
||||||
"./kinds": {
|
|
||||||
"import": "./lib/esm/kinds.js",
|
|
||||||
"require": "./lib/cjs/kinds.js",
|
|
||||||
"types": "./lib/types/kinds.d.ts"
|
|
||||||
},
|
|
||||||
"./filter": {
|
|
||||||
"import": "./lib/esm/filter.js",
|
|
||||||
"require": "./lib/cjs/filter.js",
|
|
||||||
"types": "./lib/types/filter.d.ts"
|
|
||||||
},
|
|
||||||
"./abstract-relay": {
|
|
||||||
"import": "./lib/esm/abstract-relay.js",
|
|
||||||
"require": "./lib/cjs/abstract-relay.js",
|
|
||||||
"types": "./lib/types/abstract-relay.d.ts"
|
|
||||||
},
|
|
||||||
"./relay": {
|
|
||||||
"import": "./lib/esm/relay.js",
|
|
||||||
"require": "./lib/cjs/relay.js",
|
|
||||||
"types": "./lib/types/relay.d.ts"
|
|
||||||
},
|
|
||||||
"./abstract-pool": {
|
|
||||||
"import": "./lib/esm/abstract-pool.js",
|
|
||||||
"require": "./lib/cjs/abstract-pool.js",
|
|
||||||
"types": "./lib/types/abstract-pool.d.ts"
|
|
||||||
},
|
|
||||||
"./pool": {
|
|
||||||
"import": "./lib/esm/pool.js",
|
|
||||||
"require": "./lib/cjs/pool.js",
|
|
||||||
"types": "./lib/types/pool.d.ts"
|
|
||||||
},
|
|
||||||
"./references": {
|
|
||||||
"import": "./lib/esm/references.js",
|
|
||||||
"require": "./lib/cjs/references.js",
|
|
||||||
"types": "./lib/types/references.d.ts"
|
|
||||||
},
|
|
||||||
"./nip04": {
|
|
||||||
"import": "./lib/esm/nip04.js",
|
|
||||||
"require": "./lib/cjs/nip04.js",
|
|
||||||
"types": "./lib/types/nip04.d.ts"
|
|
||||||
},
|
|
||||||
"./nip05": {
|
|
||||||
"import": "./lib/esm/nip05.js",
|
|
||||||
"require": "./lib/cjs/nip05.js",
|
|
||||||
"types": "./lib/types/nip05.d.ts"
|
|
||||||
},
|
|
||||||
"./nip06": {
|
|
||||||
"import": "./lib/esm/nip06.js",
|
|
||||||
"require": "./lib/cjs/nip06.js",
|
|
||||||
"types": "./lib/types/nip06.d.ts"
|
|
||||||
},
|
|
||||||
"./nip07": {
|
|
||||||
"types": "./lib/types/nip07.d.ts"
|
|
||||||
},
|
|
||||||
"./nip10": {
|
|
||||||
"import": "./lib/esm/nip10.js",
|
|
||||||
"require": "./lib/cjs/nip10.js",
|
|
||||||
"types": "./lib/types/nip10.d.ts"
|
|
||||||
},
|
|
||||||
"./nip11": {
|
|
||||||
"import": "./lib/esm/nip11.js",
|
|
||||||
"require": "./lib/cjs/nip11.js",
|
|
||||||
"types": "./lib/types/nip11.d.ts"
|
|
||||||
},
|
|
||||||
"./nip13": {
|
|
||||||
"import": "./lib/esm/nip13.js",
|
|
||||||
"require": "./lib/cjs/nip13.js",
|
|
||||||
"types": "./lib/types/nip13.d.ts"
|
|
||||||
},
|
|
||||||
"./nip17": {
|
|
||||||
"import": "./lib/esm/nip17.js",
|
|
||||||
"require": "./lib/cjs/nip17.js",
|
|
||||||
"types": "./lib/types/nip17.d.ts"
|
|
||||||
},
|
|
||||||
"./nip18": {
|
|
||||||
"import": "./lib/esm/nip18.js",
|
|
||||||
"require": "./lib/cjs/nip18.js",
|
|
||||||
"types": "./lib/types/nip18.d.ts"
|
|
||||||
},
|
|
||||||
"./nip19": {
|
|
||||||
"import": "./lib/esm/nip19.js",
|
|
||||||
"require": "./lib/cjs/nip19.js",
|
|
||||||
"types": "./lib/types/nip19.d.ts"
|
|
||||||
},
|
|
||||||
"./nip21": {
|
|
||||||
"import": "./lib/esm/nip21.js",
|
|
||||||
"require": "./lib/cjs/nip21.js",
|
|
||||||
"types": "./lib/types/nip21.d.ts"
|
|
||||||
},
|
|
||||||
"./nip25": {
|
|
||||||
"import": "./lib/esm/nip25.js",
|
|
||||||
"require": "./lib/cjs/nip25.js",
|
|
||||||
"types": "./lib/types/nip25.d.ts"
|
|
||||||
},
|
|
||||||
"./nip27": {
|
|
||||||
"import": "./lib/esm/nip27.js",
|
|
||||||
"require": "./lib/cjs/nip27.js",
|
|
||||||
"types": "./lib/types/nip27.d.ts"
|
|
||||||
},
|
|
||||||
"./nip28": {
|
|
||||||
"import": "./lib/esm/nip28.js",
|
|
||||||
"require": "./lib/cjs/nip28.js",
|
|
||||||
"types": "./lib/types/nip28.d.ts"
|
|
||||||
},
|
|
||||||
"./nip29": {
|
|
||||||
"import": "./lib/esm/nip29.js",
|
|
||||||
"require": "./lib/cjs/nip29.js",
|
|
||||||
"types": "./lib/types/nip29.d.ts"
|
|
||||||
},
|
|
||||||
"./nip30": {
|
|
||||||
"import": "./lib/esm/nip30.js",
|
|
||||||
"require": "./lib/cjs/nip30.js",
|
|
||||||
"types": "./lib/types/nip30.d.ts"
|
|
||||||
},
|
|
||||||
"./nip39": {
|
|
||||||
"import": "./lib/esm/nip39.js",
|
|
||||||
"require": "./lib/cjs/nip39.js",
|
|
||||||
"types": "./lib/types/nip39.d.ts"
|
|
||||||
},
|
|
||||||
"./nip42": {
|
|
||||||
"import": "./lib/esm/nip42.js",
|
|
||||||
"require": "./lib/cjs/nip42.js",
|
|
||||||
"types": "./lib/types/nip42.d.ts"
|
|
||||||
},
|
|
||||||
"./nip44": {
|
|
||||||
"import": "./lib/esm/nip44.js",
|
|
||||||
"require": "./lib/cjs/nip44.js",
|
|
||||||
"types": "./lib/types/nip44.d.ts"
|
|
||||||
},
|
|
||||||
"./nip46": {
|
|
||||||
"import": "./lib/esm/nip46.js",
|
|
||||||
"require": "./lib/cjs/nip46.js",
|
|
||||||
"types": "./lib/types/nip46.d.ts"
|
|
||||||
},
|
|
||||||
"./nip49": {
|
|
||||||
"import": "./lib/esm/nip49.js",
|
|
||||||
"require": "./lib/cjs/nip49.js",
|
|
||||||
"types": "./lib/types/nip49.d.ts"
|
|
||||||
},
|
|
||||||
"./nip54": {
|
|
||||||
"import": "./lib/esm/nip54.js",
|
|
||||||
"require": "./lib/cjs/nip54.js",
|
|
||||||
"types": "./lib/types/nip54.d.ts"
|
|
||||||
},
|
|
||||||
"./nip57": {
|
|
||||||
"import": "./lib/esm/nip57.js",
|
|
||||||
"require": "./lib/cjs/nip57.js",
|
|
||||||
"types": "./lib/types/nip57.d.ts"
|
|
||||||
},
|
|
||||||
"./nip59": {
|
|
||||||
"import": "./lib/esm/nip59.js",
|
|
||||||
"require": "./lib/cjs/nip59.js",
|
|
||||||
"types": "./lib/types/nip59.d.ts"
|
|
||||||
},
|
|
||||||
"./nip58": {
|
|
||||||
"import": "./lib/esm/nip58.js",
|
|
||||||
"require": "./lib/cjs/nip58.js",
|
|
||||||
"types": "./lib/types/nip58.d.ts"
|
|
||||||
},
|
|
||||||
"./nip75": {
|
|
||||||
"import": "./lib/esm/nip75.js",
|
|
||||||
"require": "./lib/cjs/nip75.js",
|
|
||||||
"types": "./lib/types/nip75.d.ts"
|
|
||||||
},
|
|
||||||
"./nip94": {
|
|
||||||
"import": "./lib/esm/nip94.js",
|
|
||||||
"require": "./lib/cjs/nip94.js",
|
|
||||||
"types": "./lib/types/nip94.d.ts"
|
|
||||||
},
|
|
||||||
"./nip98": {
|
|
||||||
"import": "./lib/esm/nip98.js",
|
|
||||||
"require": "./lib/cjs/nip98.js",
|
|
||||||
"types": "./lib/types/nip98.d.ts"
|
|
||||||
},
|
|
||||||
"./nip99": {
|
|
||||||
"import": "./lib/esm/nip99.js",
|
|
||||||
"require": "./lib/cjs/nip99.js",
|
|
||||||
"types": "./lib/types/nip99.d.ts"
|
|
||||||
},
|
|
||||||
"./nipb7": {
|
|
||||||
"import": "./lib/esm/nipb7.js",
|
|
||||||
"require": "./lib/cjs/nipb7.js",
|
|
||||||
"types": "./lib/types/nipb7.d.ts"
|
|
||||||
},
|
|
||||||
"./fakejson": {
|
|
||||||
"import": "./lib/esm/fakejson.js",
|
|
||||||
"require": "./lib/cjs/fakejson.js",
|
|
||||||
"types": "./lib/types/fakejson.d.ts"
|
|
||||||
},
|
|
||||||
"./signer": {
|
|
||||||
"import": "./lib/esm/signer.js",
|
|
||||||
"require": "./lib/cjs/signer.js",
|
|
||||||
"types": "./lib/types/signer.d.ts"
|
|
||||||
},
|
|
||||||
"./utils": {
|
|
||||||
"import": "./lib/esm/utils.js",
|
|
||||||
"require": "./lib/cjs/utils.js",
|
|
||||||
"types": "./lib/types/utils.d.ts"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"license": "Unlicense",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/ciphers": "^0.5.1",
|
"@noble/ciphers": "npm:@jsr/noble__ciphers@2.1.1",
|
||||||
"@noble/curves": "^2.0.1",
|
"@noble/curves": "npm:@jsr/noble__curves@2.0.1",
|
||||||
"@noble/hashes": "^2.0.1",
|
"@noble/hashes": "npm:@jsr/noble__hashes@2.0.1",
|
||||||
"@scure/base": "1.1.1",
|
"@scure/base": "npm:@jsr/scure__base@2.0.0",
|
||||||
"@scure/bip32": "1.3.1",
|
"@scure/bip32": "npm:@jsr/scure__bip32@2.0.1",
|
||||||
"@scure/bip39": "1.2.1",
|
"@scure/bip39": "npm:@jsr/scure__bip39@2.0.1",
|
||||||
"nostr-wasm": "0.1.0"
|
"nostr-wasm": "0.1.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">=5.0.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"typescript": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"decentralization",
|
|
||||||
"social",
|
|
||||||
"censorship-resistance",
|
|
||||||
"client",
|
|
||||||
"nostr"
|
|
||||||
],
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.13.0",
|
"@types/node": "^18.13.0",
|
||||||
"@types/node-fetch": "^2.6.3",
|
"@types/node-fetch": "^2.6.3",
|
||||||
@@ -274,8 +24,5 @@
|
|||||||
"node-fetch": "^2.6.9",
|
"node-fetch": "^2.6.9",
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"typescript": "^5.8.2"
|
"typescript": "^5.8.2"
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"prepublish": "just build"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user