Fix decoding keys

This commit is contained in:
Jonathan Staab 2023-02-20 15:39:04 -06:00
parent 927d04b74e
commit 7caae932ac
3 changed files with 13 additions and 3 deletions

View File

@ -189,7 +189,7 @@ const relays = new Table('relays', 'url')
const routes = new Table('routes', 'id', {
initialize: async table => {
const isValid = r => r.last_seen > now() - timedelta(7, 'days')
const isValid = r => r.last_seen > now() - timedelta(1, 'days')
const [valid, invalid] = partition(isValid, Object.values(await table.dump() || {}))
// Delete stale routes asynchronously

View File

@ -11,7 +11,12 @@
const nip07 = "https://github.com/nostr-protocol/nips/blob/master/07.md"
const logIn = () => {
const privkey = (nsec.startsWith('nsec') ? nip19.decode(nsec).data : nsec) as string
let privkey = ''
try {
privkey = (nsec.startsWith('nsec') ? nip19.decode(nsec).data : nsec) as string
} catch (e) {
// pass
}
if (!privkey.match(/[a-z0-9]{64}/)) {
toast.show("error", "Sorry, but that's an invalid private key.")

View File

@ -10,7 +10,12 @@
let npub = ''
const logIn = () => {
const pubkey = (npub.startsWith('npub') ? nip19.decode(npub).data : npub) as string
let pubkey = ''
try {
pubkey = (npub.startsWith('npub') ? nip19.decode(npub).data : npub) as string
} catch (e) {
// pass
}
if (!pubkey.match(/[a-z0-9]{64}/)) {
toast.show("error", "Sorry, but that's an invalid public key.")