NIP-46: stringify event object in accordance with updated spec

This commit is contained in:
Alex Gleason 2024-04-25 21:47:13 -05:00
parent d6b5fb8fe7
commit 22586004e8
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 2 additions and 7 deletions

View file

@ -21,7 +21,7 @@ function useSignerStream() {
const respMsg = {
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({

View file

@ -24,16 +24,11 @@ const eventSchema = eventTemplateSchema.extend({
/** Nostr event schema that also verifies the event's signature. */
const signedEventSchema = eventSchema.refine(verifyEvent);
/** NIP-46 signer options. */
const signEventOptsSchema = z.object({
pow: z.number().int().nonnegative(),
}).partial();
/** NIP-46 signer request. */
const connectRequestSchema = z.object({
id: z.string(),
method: z.literal('sign_event'),
params: z.tuple([eventTemplateSchema]).or(z.tuple([eventTemplateSchema, signEventOptsSchema])),
params: z.tuple([z.string()]),
});
/** NIP-47 signer response. */