Merge branch 'nip46-param' into 'main'

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

See merge request soapbox-pub/soapbox!3004
This commit is contained in:
Alex Gleason 2024-04-26 03:03:43 +00:00
commit 4df1fbe29b
2 changed files with 2 additions and 7 deletions

View File

@ -21,7 +21,7 @@ function useSignerStream() {
const respMsg = { const respMsg = {
id: reqMsg.data.id, 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({ 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. */ /** Nostr event schema that also verifies the event's signature. */
const signedEventSchema = eventSchema.refine(verifyEvent); const signedEventSchema = eventSchema.refine(verifyEvent);
/** NIP-46 signer options. */
const signEventOptsSchema = z.object({
pow: z.number().int().nonnegative(),
}).partial();
/** NIP-46 signer request. */ /** NIP-46 signer request. */
const connectRequestSchema = z.object({ const connectRequestSchema = z.object({
id: z.string(), id: z.string(),
method: z.literal('sign_event'), method: z.literal('sign_event'),
params: z.tuple([eventTemplateSchema]).or(z.tuple([eventTemplateSchema, signEventOptsSchema])), params: z.tuple([z.string()]),
}); });
/** NIP-47 signer response. */ /** NIP-47 signer response. */