no event.parsedAddress

This commit is contained in:
Andre Staltz 2024-01-12 17:11:39 +02:00
parent 96429e4af4
commit a63a54987d
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,3 @@
const bs58 = require('bs58')
const cat = require('pull-cat') const cat = require('pull-cat')
const Notify = require('pull-notify') const Notify = require('pull-notify')
const pull = require('pull-stream') const pull = require('pull-stream')
@ -19,13 +18,16 @@ function ErrorDuplex(message) {
} }
/** /**
* @param {Array<[any, any]>} parsedAddress * @param {string} addresses
* @returns {string | undefined} * @returns {string | undefined}
*/ */
function extractSHSEPubkey(parsedAddress) { function extractSHSEPubkey(addresses) {
for (const [transport, transform] of parsedAddress) { for (const address of addresses.split(';')) {
if (transform.name === 'shse') { for (const [transport, transform] of address.split('~')) {
return bs58.encode(transform.pubkey) const [name, pubkey, extra] = transform.split(':')
if (name === 'shse') {
return pubkey
}
} }
} }
} }
@ -82,7 +84,7 @@ module.exports = {
pull.filter( pull.filter(
({ type }) => type === 'connecting-failed' || type === 'disconnected' ({ type }) => type === 'connecting-failed' || type === 'disconnected'
), ),
pull.map(({ parsedAddress }) => extractSHSEPubkey(parsedAddress)), pull.map(({ address }) => extractSHSEPubkey(address)),
pull.filter((pubkey) => !!pubkey && attendants.has(pubkey)), pull.filter((pubkey) => !!pubkey && attendants.has(pubkey)),
pull.drain((pubkey) => { pull.drain((pubkey) => {
debug('farewell %s', pubkey) debug('farewell %s', pubkey)