Refactor signers

This commit is contained in:
2023-07-04 18:18:52 +01:00
parent 7c2340d7fb
commit 9640a7fa57
5 changed files with 112 additions and 65 deletions

View File

@ -6,7 +6,7 @@ import { StrictMode } from "react";
import * as ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import { EventPublisher, NostrSystem, ProfileLoaderService } from "@snort/system";
import { EventPublisher, NostrSystem, ProfileLoaderService, Nip7Signer } from "@snort/system";
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
import { IntlProvider } from "IntlProvider";
@ -46,8 +46,12 @@ export const System = new NostrSystem({
relayMetrics: RelayMetrics,
authHandler: async (c, r) => {
const { publicKey, privateKey } = LoginStore.snapshot();
if (privateKey) {
const pub = EventPublisher.privateKey(privateKey);
return await pub.nip42Auth(c, r);
}
if (publicKey) {
const pub = new EventPublisher(publicKey, privateKey);
const pub = new EventPublisher(new Nip7Signer(), publicKey);
return await pub.nip42Auth(c, r);
}
},