NIP-46: stringify event according to updated spec

nip46-string
Alex Gleason 2024-04-25 13:28:32 -05:00
rodzic 268ca72782
commit 4d3ae06407
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -1,8 +1,8 @@
import { type NostrEvent } from '@nostrify/nostrify';
import { type NostrEvent, NSchema as n, NostrConnectResponse } from '@nostrify/nostrify';
import { useEffect } from 'react';
import { useNostr } from 'soapbox/contexts/nostr-context';
import { connectRequestSchema, nwcRequestSchema } from 'soapbox/schemas/nostr';
import { nwcRequestSchema } from 'soapbox/schemas/nostr';
import { jsonSchema } from 'soapbox/schemas/utils';
function useSignerStream() {
@ -12,16 +12,16 @@ function useSignerStream() {
if (!relay || !pubkey || !signer) return;
const decrypted = await signer.nip04!.decrypt(pubkey, event.content);
const reqMsg = jsonSchema.pipe(connectRequestSchema).safeParse(decrypted);
const reqMsg = n.json().pipe(n.connectRequest()).safeParse(decrypted);
if (!reqMsg.success) {
console.warn(decrypted);
console.warn(reqMsg.error);
return;
}
const respMsg = {
const respMsg: NostrConnectResponse = {
id: reqMsg.data.id,
result: await signer.signEvent(reqMsg.data.params[0]),
result: JSON.stringify(await signer.signEvent(JSON.parse(reqMsg.data.params[0]))),
};
const respEvent = await signer.signEvent({