Use non-singleton broker
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@
|
|||||||
"@welshman/net": "^0.2.2",
|
"@welshman/net": "^0.2.2",
|
||||||
"@welshman/relay": "^0.2.0",
|
"@welshman/relay": "^0.2.0",
|
||||||
"@welshman/router": "^0.2.0",
|
"@welshman/router": "^0.2.0",
|
||||||
"@welshman/signer": "^0.2.1",
|
"@welshman/signer": "^0.2.3",
|
||||||
"@welshman/store": "^0.2.0",
|
"@welshman/store": "^0.2.0",
|
||||||
"@welshman/util": "^0.2.2",
|
"@welshman/util": "^0.2.2",
|
||||||
"daisyui": "^4.12.10",
|
"daisyui": "^4.12.10",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
loading = $state(false)
|
loading = $state(false)
|
||||||
clientSecret = makeSecret()
|
clientSecret = makeSecret()
|
||||||
abortController = new AbortController()
|
abortController = new AbortController()
|
||||||
broker = Nip46Broker.get({clientSecret: this.clientSecret, relays: SIGNER_RELAYS})
|
broker = new Nip46Broker({clientSecret: this.clientSecret, relays: SIGNER_RELAYS})
|
||||||
onNostrConnect: (response: Nip46ResponseWithResult) => void
|
onNostrConnect: (response: Nip46ResponseWithResult) => void
|
||||||
|
|
||||||
constructor({onNostrConnect}: {onNostrConnect: (response: Nip46ResponseWithResult) => void}) {
|
constructor({onNostrConnect}: {onNostrConnect: (response: Nip46ResponseWithResult) => void}) {
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
this.broker.cleanup()
|
||||||
this.abortController.abort()
|
this.abortController.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,13 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const {clientSecret} = controller
|
const {clientSecret} = controller
|
||||||
const broker = Nip46Broker.get({relays, clientSecret, signerPubkey})
|
const broker = new Nip46Broker({relays, clientSecret, signerPubkey})
|
||||||
const result = await broker.connect(connectSecret, NIP46_PERMS)
|
const result = await broker.connect(connectSecret, NIP46_PERMS)
|
||||||
const pubkey = await broker.getPublicKey()
|
const pubkey = await broker.getPublicKey()
|
||||||
|
|
||||||
// TODO: remove ack result
|
// TODO: remove ack result
|
||||||
if (pubkey && ["ack", connectSecret].includes(result)) {
|
if (pubkey && ["ack", connectSecret].includes(result)) {
|
||||||
|
broker.cleanup()
|
||||||
controller.stop()
|
controller.stop()
|
||||||
|
|
||||||
await loadUserData(pubkey)
|
await loadUserData(pubkey)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
? [normalizeRelayUrl("ws://" + stripProtocol(BURROW_URL))]
|
? [normalizeRelayUrl("ws://" + stripProtocol(BURROW_URL))]
|
||||||
: [normalizeRelayUrl(BURROW_URL)]
|
: [normalizeRelayUrl(BURROW_URL)]
|
||||||
|
|
||||||
const broker = Nip46Broker.get({clientSecret, relays})
|
const broker = new Nip46Broker({clientSecret, relays})
|
||||||
|
|
||||||
const back = () => history.back()
|
const back = () => history.back()
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
await loadUserData(pubkey)
|
await loadUserData(pubkey)
|
||||||
|
|
||||||
addSession({...session, email})
|
addSession({...session, email})
|
||||||
|
broker.cleanup()
|
||||||
setChecked("*")
|
setChecked("*")
|
||||||
clearModals()
|
clearModals()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
if (login?.startsWith("bunker://")) {
|
if (login?.startsWith("bunker://")) {
|
||||||
const clientSecret = makeSecret()
|
const clientSecret = makeSecret()
|
||||||
const {signerPubkey, connectSecret, relays} = Nip46Broker.parseBunkerUrl(login)
|
const {signerPubkey, connectSecret, relays} = Nip46Broker.parseBunkerUrl(login)
|
||||||
const broker = Nip46Broker.get({relays, clientSecret, signerPubkey})
|
const broker = new Nip46Broker({relays, clientSecret, signerPubkey})
|
||||||
const result = await broker.connect(connectSecret, appState.NIP46_PERMS)
|
const result = await broker.connect(connectSecret, appState.NIP46_PERMS)
|
||||||
const pubkey = await broker.getPublicKey()
|
const pubkey = await broker.getPublicKey()
|
||||||
|
|
||||||
@@ -105,6 +105,7 @@
|
|||||||
await loadUserData(pubkey)
|
await loadUserData(pubkey)
|
||||||
|
|
||||||
loginWithNip46(pubkey, clientSecret, signerPubkey, relays)
|
loginWithNip46(pubkey, clientSecret, signerPubkey, relays)
|
||||||
|
broker.cleanup()
|
||||||
success = true
|
success = true
|
||||||
}
|
}
|
||||||
} else if (login) {
|
} else if (login) {
|
||||||
|
|||||||
Reference in New Issue
Block a user