remove websocket-polyfill, instruct nodejs users to install it manually.

This commit is contained in:
fiatjaf
2022-12-21 16:23:47 -03:00
parent 4bd4469357
commit 8aa31bb437
3 changed files with 13 additions and 5 deletions

View File

@@ -2,6 +2,8 @@
Tools for developing [Nostr](https://github.com/fiatjaf/nostr) clients. Tools for developing [Nostr](https://github.com/fiatjaf/nostr) clients.
Very lean on dependencies.
## Usage ## Usage
### Generating a private key and a public key ### Generating a private key and a public key
@@ -112,6 +114,12 @@ pub.on('failed', reason => {
await relay.close() await relay.close()
``` ```
To use this on Node.js you first must install `websocket-polyfill` and import it:
```js
import 'websocket-polyfill'
```
### Querying profile data from a NIP-05 address ### Querying profile data from a NIP-05 address
```js ```js
@@ -122,8 +130,11 @@ console.log(profile.pubkey)
// prints: 32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245 // prints: 32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245
console.log(profile.relays) console.log(profile.relays)
// prints: [wss://relay.damus.io] // prints: [wss://relay.damus.io]
```
// on nodejs, install node-fetch@2 and call this first: To use this on Node.js you first must install `node-fetch@2` and call something like this:
```js
nip05.useFetchImplementation(require('node-fetch')) nip05.useFetchImplementation(require('node-fetch'))
``` ```

View File

@@ -14,8 +14,7 @@
"@scure/bip32": "^1.1.1", "@scure/bip32": "^1.1.1",
"@scure/bip39": "^1.1.0", "@scure/bip39": "^1.1.0",
"base64-arraybuffer": "^1.0.2", "base64-arraybuffer": "^1.0.2",
"bech32": "^2.0.0", "bech32": "^2.0.0"
"websocket-polyfill": "^0.0.3"
}, },
"keywords": [ "keywords": [
"decentralization", "decentralization",

View File

@@ -1,7 +1,5 @@
/* global WebSocket */ /* global WebSocket */
import 'websocket-polyfill'
import {Event, verifySignature, validateEvent} from './event' import {Event, verifySignature, validateEvent} from './event'
import {Filter, matchFilters} from './filter' import {Filter, matchFilters} from './filter'