nostr-tools
Advanced tools
Comparing version 1.5.0 to 1.6.0
10
build.js
#!/usr/bin/env node | ||
const fs = require('fs') | ||
const esbuild = require('esbuild') | ||
@@ -14,8 +15,13 @@ | ||
...common, | ||
outfile: 'lib/nostr.esm.js', | ||
outfile: 'lib/esm/nostr.mjs', | ||
format: 'esm', | ||
packages: 'external' | ||
}) | ||
.then(() => console.log('esm build success.')) | ||
.then(() => { | ||
const packageJson = JSON.stringify({ type: 'module' }) | ||
fs.writeFileSync(`${__dirname}/lib/esm/package.json`, packageJson, 'utf8') | ||
console.log('esm build success.') | ||
}) | ||
esbuild | ||
@@ -22,0 +28,0 @@ .build({ |
@@ -334,3 +334,2 @@ "use strict"; | ||
var ws; | ||
var resolveClose; | ||
var openSubs = {}; | ||
@@ -358,3 +357,2 @@ var listeners = { | ||
listeners.disconnect.forEach((cb) => cb()); | ||
resolveClose && resolveClose(); | ||
}; | ||
@@ -552,7 +550,4 @@ let incomingMessageQueue = []; | ||
if (ws.readyState > 1) | ||
return Promise.resolve(); | ||
return; | ||
ws.close(); | ||
return new Promise((resolve) => { | ||
resolveClose = resolve; | ||
}); | ||
}, | ||
@@ -572,10 +567,8 @@ get status() { | ||
} | ||
async close(relays) { | ||
await Promise.all( | ||
relays.map(async (url) => { | ||
let relay = this._conn[normalizeURL(url)]; | ||
if (relay) | ||
await relay.close(); | ||
}) | ||
); | ||
close(relays) { | ||
relays.map((url) => { | ||
let relay = this._conn[normalizeURL(url)]; | ||
if (relay) | ||
relay.close(); | ||
}); | ||
} | ||
@@ -582,0 +575,0 @@ async ensureRelay(url) { |
{ | ||
"name": "nostr-tools", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Tools for making a Nostr client.", | ||
@@ -10,3 +10,7 @@ "repository": { | ||
"main": "lib/nostr.cjs.js", | ||
"module": "lib/nostr.esm.js", | ||
"module": "lib/esm/nostr.mjs", | ||
"exports": { | ||
"import": "./lib/esm/nostr.mjs", | ||
"require": "./lib/nostr.cjs.js" | ||
}, | ||
"dependencies": { | ||
@@ -13,0 +17,0 @@ "@noble/hashes": "1.0.0", |
@@ -22,4 +22,4 @@ /* eslint-env jest */ | ||
afterAll(async () => { | ||
await pool.close([ | ||
afterAll(() => { | ||
pool.close([ | ||
...relays, | ||
@@ -26,0 +26,0 @@ 'wss://nostr-relay.untethr.me', |
@@ -15,9 +15,7 @@ import {Relay, relayInit} from './relay' | ||
async close(relays: string[]): Promise<void> { | ||
await Promise.all( | ||
relays.map(async url => { | ||
close(relays: string[]): void { | ||
relays.map(url => { | ||
let relay = this._conn[normalizeURL(url)] | ||
if (relay) await relay.close() | ||
if (relay) relay.close() | ||
}) | ||
) | ||
} | ||
@@ -24,0 +22,0 @@ |
@@ -123,3 +123,3 @@ # nostr-tools | ||
await relay.close() | ||
relay.close() | ||
``` | ||
@@ -126,0 +126,0 @@ |
@@ -18,4 +18,4 @@ /* eslint-env jest */ | ||
afterAll(async () => { | ||
await relay.close() | ||
afterAll(() => { | ||
relay.close() | ||
}) | ||
@@ -22,0 +22,0 @@ |
11
relay.ts
@@ -13,3 +13,3 @@ /* global WebSocket */ | ||
connect: () => Promise<void> | ||
close: () => Promise<void> | ||
close: () => void | ||
sub: (filters: Filter[], opts?: SubscriptionOptions) => Sub | ||
@@ -41,3 +41,2 @@ list: (filters: Filter[], opts?: SubscriptionOptions) => Promise<Event[]> | ||
var ws: WebSocket | ||
var resolveClose: () => void | ||
var openSubs: {[id: string]: {filters: Filter[]} & SubscriptionOptions} = {} | ||
@@ -83,3 +82,2 @@ var listeners: { | ||
listeners.disconnect.forEach(cb => cb()) | ||
resolveClose && resolveClose() | ||
} | ||
@@ -297,3 +295,3 @@ | ||
connect, | ||
close(): Promise<void> { | ||
close(): void { | ||
listeners = {connect: [], disconnect: [], error: [], notice: []} | ||
@@ -303,7 +301,4 @@ subListeners = {} | ||
if (ws.readyState > 1) return Promise.resolve() | ||
if (ws.readyState > 1) return | ||
ws.close() | ||
return new Promise<void>(resolve => { | ||
resolveClose = resolve | ||
}) | ||
}, | ||
@@ -310,0 +305,0 @@ get status() { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2091515
46
14209
1
9