From b17a7d106738d03f761fc36eac48226af3357de4 Mon Sep 17 00:00:00 2001 From: Ryan Breen Date: Fri, 20 Jan 2023 00:58:06 -0500 Subject: [PATCH] Automatically handle nsec keys entered into the extension. --- Shared (Extension)/Resources/background.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Shared (Extension)/Resources/background.js b/Shared (Extension)/Resources/background.js index 3b38b5d..055bcbe 100644 --- a/Shared (Extension)/Resources/background.js +++ b/Shared (Extension)/Resources/background.js @@ -1,4 +1,4 @@ -import { generatePrivateKey, getPublicKey, signEvent, nip04 } from "nostr-tools"; +import { generatePrivateKey, getPublicKey, signEvent, nip04, nip19 } from "nostr-tools"; const storage = browser.storage.local; @@ -133,6 +133,9 @@ async function newProfile() { } async function saveProfile(profile) { + if (profile.privKey.startsWith('nsec')) { + profile.privKey = nip19.decode(profile.privKey).data; + } let index = await getProfileIndex(); let profiles = await get('profiles'); profiles[index] = profile;