Merge branch 'nip44' into 'main'

Switch all nip04 calls to nip44

See merge request soapbox-pub/ditto!114
This commit is contained in:
Alex Gleason 2024-02-21 20:41:30 +00:00
commit 37e55b4e18
4 changed files with 8 additions and 8 deletions

View File

@ -18,7 +18,7 @@ const frontendConfigController: AppController = async (c) => {
}], { signal }); }], { signal });
const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse( const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse(
event?.content ? await new AdminSigner().nip04.decrypt(Conf.pubkey, event.content) : '', event?.content ? await new AdminSigner().nip44.decrypt(Conf.pubkey, event.content) : '',
); );
const frontendConfig = configs.find(({ group, key }) => group === ':pleroma' && key === ':frontend_configurations'); const frontendConfig = configs.find(({ group, key }) => group === ':pleroma' && key === ':frontend_configurations');
@ -47,7 +47,7 @@ const configController: AppController = async (c) => {
}], { signal }); }], { signal });
const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse( const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse(
event?.content ? await new AdminSigner().nip04.decrypt(pubkey, event.content) : '', event?.content ? await new AdminSigner().nip44.decrypt(pubkey, event.content) : '',
); );
return c.json({ configs, need_reboot: false }); return c.json({ configs, need_reboot: false });
@ -66,7 +66,7 @@ const updateConfigController: AppController = async (c) => {
}], { signal }); }], { signal });
const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse( const configs = jsonSchema.pipe(z.array(configSchema)).catch([]).parse(
event?.content ? await await new AdminSigner().nip04.decrypt(pubkey, event.content) : '', event?.content ? await await new AdminSigner().nip44.decrypt(pubkey, event.content) : '',
); );
const { configs: newConfigs } = z.object({ configs: z.array(configSchema) }).parse(await c.req.json()); const { configs: newConfigs } = z.object({ configs: z.array(configSchema) }).parse(await c.req.json());
@ -82,7 +82,7 @@ const updateConfigController: AppController = async (c) => {
await createAdminEvent({ await createAdminEvent({
kind: 30078, kind: 30078,
content: await new AdminSigner().nip04.encrypt(pubkey, JSON.stringify(configs)), content: await new AdminSigner().nip44.encrypt(pubkey, JSON.stringify(configs)),
tags: [['d', 'pub.ditto.pleroma.config']], tags: [['d', 'pub.ditto.pleroma.config']],
}, c); }, c);

View File

@ -93,6 +93,6 @@ export {
NSet, NSet,
type NStore, type NStore,
type NStoreOpts, type NStoreOpts,
} from 'https://gitlab.com/soapbox-pub/NSpec/-/raw/v0.1.0/mod.ts'; } from 'https://gitlab.com/soapbox-pub/NSpec/-/raw/v0.3.0/mod.ts';
export type * as TypeFest from 'npm:type-fest@^4.3.0'; export type * as TypeFest from 'npm:type-fest@^4.3.0';

View File

@ -197,7 +197,7 @@ async function payZap(event: DittoEvent, signal: AbortSignal) {
const nwcRequestEvent = await signer.signEvent({ const nwcRequestEvent = await signer.signEvent({
kind: 23194, kind: 23194,
content: await signer.nip04.encrypt( content: await signer.nip44.encrypt(
event.pubkey, event.pubkey,
JSON.stringify({ method: 'pay_invoice', params: { invoice: pr } }), JSON.stringify({ method: 'pay_invoice', params: { invoice: pr } }),
), ),

View File

@ -63,7 +63,7 @@ export class APISigner implements NostrSigner {
createAdminEvent({ createAdminEvent({
kind: 24133, kind: 24133,
content: await new AdminSigner().nip04.encrypt( content: await new AdminSigner().nip44.encrypt(
pubkey, pubkey,
JSON.stringify({ JSON.stringify({
id: messageId, id: messageId,
@ -93,7 +93,7 @@ export class APISigner implements NostrSigner {
this.#c.req.raw.signal.addEventListener('abort', close); this.#c.req.raw.signal.addEventListener('abort', close);
for await (const event of sub) { for await (const event of sub) {
const decrypted = await new AdminSigner().nip04.decrypt(event.pubkey, event.content); const decrypted = await new AdminSigner().nip44.decrypt(event.pubkey, event.content);
const result = jsonSchema const result = jsonSchema
.pipe(connectResponseSchema) .pipe(connectResponseSchema)