Use non-singleton broker
This commit is contained in:
parent
f2eb04adff
commit
94a0077b09
5 changed files with 9 additions and 6 deletions
|
|
@ -60,7 +60,7 @@
|
|||
"@welshman/net": "^0.2.2",
|
||||
"@welshman/relay": "^0.2.0",
|
||||
"@welshman/router": "^0.2.0",
|
||||
"@welshman/signer": "^0.2.1",
|
||||
"@welshman/signer": "^0.2.3",
|
||||
"@welshman/store": "^0.2.0",
|
||||
"@welshman/util": "^0.2.2",
|
||||
"daisyui": "^4.12.10",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
loading = $state(false)
|
||||
clientSecret = makeSecret()
|
||||
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
|
||||
|
||||
constructor({onNostrConnect}: {onNostrConnect: (response: Nip46ResponseWithResult) => void}) {
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
|
||||
stop() {
|
||||
this.broker.cleanup()
|
||||
this.abortController.abort()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,12 +46,13 @@
|
|||
|
||||
try {
|
||||
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 pubkey = await broker.getPublicKey()
|
||||
|
||||
// TODO: remove ack result
|
||||
if (pubkey && ["ack", connectSecret].includes(result)) {
|
||||
broker.cleanup()
|
||||
controller.stop()
|
||||
|
||||
await loadUserData(pubkey)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
? [normalizeRelayUrl("ws://" + stripProtocol(BURROW_URL))]
|
||||
: [normalizeRelayUrl(BURROW_URL)]
|
||||
|
||||
const broker = Nip46Broker.get({clientSecret, relays})
|
||||
const broker = new Nip46Broker({clientSecret, relays})
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
await loadUserData(pubkey)
|
||||
|
||||
addSession({...session, email})
|
||||
|
||||
broker.cleanup()
|
||||
setChecked("*")
|
||||
clearModals()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
if (login?.startsWith("bunker://")) {
|
||||
const clientSecret = makeSecret()
|
||||
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 pubkey = await broker.getPublicKey()
|
||||
|
||||
|
|
@ -105,6 +105,7 @@
|
|||
await loadUserData(pubkey)
|
||||
|
||||
loginWithNip46(pubkey, clientSecret, signerPubkey, relays)
|
||||
broker.cleanup()
|
||||
success = true
|
||||
}
|
||||
} else if (login) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue