nappup 1.5.7 → 1.5.8

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": "MIT",
9
- "version": "1.5.7",
9
+ "version": "1.5.8",
10
10
  "description": "Nostr App Uploader",
11
11
  "type": "module",
12
12
  "scripts": {
package/src/index.js CHANGED
@@ -23,7 +23,7 @@ export async function toApp (fileList, nostrSigner, { log = () => {}, dTag, dTag
23
23
  if (typeof window !== 'undefined' && nostrSigner === window.nostr) {
24
24
  nostrSigner.getRelays = NostrSigner.prototype.getRelays
25
25
  }
26
- const writeRelays = (await nostrSigner.getRelays()).write
26
+ const writeRelays = [...new Set((await nostrSigner.getRelays()).write.map(r => r.trim().replace(/\/$/, '')))]
27
27
  log(`Found ${writeRelays.length} outbox relays for pubkey ${nostrSigner.getPublicKey()}:\n${writeRelays.join(', ')}`)
28
28
  if (writeRelays.length === 0) throw new Error('No outbox relays found')
29
29
 
@@ -167,7 +167,7 @@ export async function toApp (fileList, nostrSigner, { log = () => {}, dTag, dTag
167
167
 
168
168
  async function uploadBinaryDataChunks ({ nmmr, signer, filename, chunkLength, log, pause = 0, mimeType, shouldReupload = false }) {
169
169
  const writeRelays = (await signer.getRelays()).write
170
- const relays = [...new Set([...writeRelays, ...nappRelays])]
170
+ const relays = [...new Set([...writeRelays, ...nappRelays].map(r => r.trim().replace(/\/$/, '')))]
171
171
  let chunkIndex = 0
172
172
  for await (const chunk of nmmr.getChunks()) {
173
173
  const dTag = chunk.x
@@ -274,7 +274,7 @@ async function throttledSendEvent (event, relays, {
274
274
  }
275
275
 
276
276
  async function getPreviousCtags (dTagValue, currentCtagValue, relays, signer) {
277
- const targetRelays = [...new Set([...relays, ...nappRelays])]
277
+ const targetRelays = [...new Set([...relays, ...nappRelays].map(r => r.trim().replace(/\/$/, '')))]
278
278
  const storedEvents = (await nostrRelays.getEvents({
279
279
  kinds: [34600],
280
280
  authors: [await signer.getPublicKey()],
@@ -333,7 +333,7 @@ async function uploadBundle ({ dTag, channel, fileMetadata, signer, pause = 0, s
333
333
  ...fileTags
334
334
  ]
335
335
 
336
- const writeRelays = [...new Set([...(await signer.getRelays()).write, ...nappRelays])]
336
+ const writeRelays = [...new Set([...(await signer.getRelays()).write, ...nappRelays].map(r => r.trim().replace(/\/$/, '')))]
337
337
 
338
338
  let mostRecentEvent
339
339
  const events = (await nostrRelays.getEvents({
@@ -428,7 +428,7 @@ async function maybeUploadStall ({
428
428
  const hasMetadata = Boolean(trimmedName) || Boolean(trimmedSummary) || Boolean(iconRootHash) ||
429
429
  Boolean(self) || (countries && countries.length > 0) || (categories && categories.length > 0) || (hashtags && hashtags.length > 0)
430
430
 
431
- const relays = [...new Set([...writeRelays, ...nappRelays])]
431
+ const relays = [...new Set([...writeRelays, ...nappRelays].map(r => r.trim().replace(/\/$/, '')))]
432
432
 
433
433
  const previousResult = await getPreviousStall(dTag, relays, signer, channel)
434
434
  const previous = previousResult?.previous
@@ -71,10 +71,13 @@ export default class NostrSigner {
71
71
  const relays = rTags.reduce((r, v) => {
72
72
  keys = [v[2]].filter(v2 => keyAllowList[v2])
73
73
  if (keys.length === 0) keys = ['read', 'write']
74
- keys.forEach(k => r[k].push(v[1]))
74
+ keys.forEach(k => r[k].push(v[1].trim().replace(/\/$/, '')))
75
75
  return r
76
76
  }, { read: [], write: [] })
77
- Object.values(relays).forEach(v => { v.length === 0 && v.push(...freeRelays) })
77
+ for (const k in relays) {
78
+ if (relays[k].length === 0) relays[k].push(...freeRelays)
79
+ relays[k] = [...new Set(relays[k])]
80
+ }
78
81
  return (this.relays = relays)
79
82
  }
80
83
 
@@ -91,7 +94,7 @@ export default class NostrSigner {
91
94
  content: '',
92
95
  created_at: Math.floor(Date.now() / 1000)
93
96
  })
94
- await nostrRelays.sendEvent(relayList, [...new Set([...seedRelays, ...this.relays.write])])
97
+ await nostrRelays.sendEvent(relayList, [...new Set([...seedRelays, ...this.relays.write].map(r => r.trim().replace(/\/$/, '')))])
95
98
  return this.relays
96
99
  }
97
100