nappup 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "git+https://github.com/44billion/nappup.git"
7
7
  },
8
8
  "license": "GPL-3.0-or-later",
9
- "version": "1.0.2",
9
+ "version": "1.0.4",
10
10
  "description": "Nostr App Uploader",
11
11
  "type": "module",
12
12
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import fs from 'node:fs'
2
+ import path from 'node:path'
2
3
  import { fileURLToPath } from 'node:url'
3
4
  import * as dotenv from 'dotenv'
4
5
  import { getPublicKey, finalizeEvent } from 'nostr-tools/pure'
@@ -6,8 +7,9 @@ import { getConversationKey, encrypt, decrypt } from 'nostr-tools/nip44'
6
7
  import nostrRelays, { seedRelays, freeRelays } from '#services/nostr-relays.js'
7
8
  const __dirname = fileURLToPath(new URL('.', import.meta.url))
8
9
 
10
+ const dotenvPath = process.env.DOTENV_CONFIG_PATH ?? `${__dirname}/../../.env`
9
11
  dotenv.config({
10
- path: process.env.DOTENV_CONFIG_PATH ?? `${__dirname}/../../.env`,
12
+ path: dotenvPath,
11
13
  quiet: true
12
14
  })
13
15
 
@@ -40,7 +42,7 @@ export default class NostrSigner {
40
42
  } else {
41
43
  isNewSk = true
42
44
  skHex = generateSecretKey()
43
- fs.appendFileSync('.env', `NOSTR_SECRET_KEY=${skHex}\n`)
45
+ fs.appendFileSync(path.resolve(dotenvPath), `NOSTR_SECRET_KEY=${skHex}\n`)
44
46
  skBytes = hexToBytes(skHex)
45
47
  }
46
48
  const ret = new this(createToken, skBytes)
@@ -53,7 +55,7 @@ export default class NostrSigner {
53
55
 
54
56
  const relayLists = await nostrRelays.getEvents({ authors: [await this.getPublicKey()], kinds: [10002], limit: 1 }, seedRelays)
55
57
  const relayList = relayLists.sort((a, b) => b.created_at - a.created_at)[0]
56
- const rTags = relayList.tags.filter(v => v[0] === 'r' && /^wss?:\/\//.test(v[1]))
58
+ const rTags = (relayList?.tags ?? []).filter(v => v[0] === 'r' && /^wss?:\/\//.test(v[1]))
57
59
  if (rTags.length === 0) return (this.relays = await this.#initRelays())
58
60
 
59
61
  let keys