fiatjaf / nos2x

nostr signer extension
281 stars 56 forks source link

nostr.getPublicKey() gives an incorrect serialization in firefox #2

Closed melvincarvalho closed 2 years ago

melvincarvalho commented 2 years ago

nostr.getPublicKey is giving an incorrect serialization on firefox (v 1.3.1)

Instead of giving a hex string it displays an ascii version of the hex

Unsure what causes it, but the following line may be related

https://github.com/fiatjaf/nostr-tools/commit/c47f091d9b94ee49bdfc9e47e6407d320dc36b46

A possible workaround for now:

    // workaround for now
    if (navigator.userAgent.indexOf("Firefox") > 0) {
      publicKey = publicKey.split(/(..)/g).filter(i => i).map(i => String.fromCharCode(parseInt(i, 16))).join('')
    }
melvincarvalho commented 2 years ago

Thanks!

Tested, works.