From 0a3eb6b18709119e833e3668aacd3bb206fe319e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 19 Feb 2024 15:13:10 -0600 Subject: [PATCH] NKeyStorage: fix schema parser --- src/features/nostr/NKeyStorage.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/features/nostr/NKeyStorage.ts b/src/features/nostr/NKeyStorage.ts index 156733082..926249448 100644 --- a/src/features/nostr/NKeyStorage.ts +++ b/src/features/nostr/NKeyStorage.ts @@ -1,6 +1,5 @@ import { getPublicKey, nip19 } from 'nostr-tools'; import { NSchema as n, NostrSigner, NSecSigner } from 'nspec'; -import { z } from 'zod'; import { lockStorageKey } from 'soapbox/utils/storage'; @@ -23,7 +22,9 @@ export class NKeyStorage implements ReadonlyMap { lockStorageKey(storageKey); try { - for (const nsec of this.#dataSchema().parse(data)) { + const nsecs = new Set(this.#dataSchema().parse(data)); + + for (const nsec of nsecs) { const { data: secretKey } = nip19.decode(nsec); const pubkey = getPublicKey(secretKey); this.#keypairs.set(pubkey, secretKey); @@ -34,7 +35,7 @@ export class NKeyStorage implements ReadonlyMap { } #dataSchema() { - return n.json().pipe(z.set(n.bech32('nsec'))); + return n.json().pipe(n.bech32('nsec').array()); } #syncStorage() {