starting the plumbing for the extension
This commit is contained in:
@@ -1,10 +1,26 @@
|
||||
import { generatePrivateKey } from "nostr-tools";
|
||||
import { generatePrivateKey, getPublicKey } from "nostr-tools";
|
||||
|
||||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
console.log('generating a key!');
|
||||
console.log(generatePrivateKey());
|
||||
console.log("Received request: ", request);
|
||||
let profiles = [
|
||||
{name: 'Default', privKey: generatePrivateKey(), hosts: [
|
||||
{host: 'yosup.app', allowed: true},
|
||||
{host: 'iris.to', allowed: false},
|
||||
]},
|
||||
{name: 'Extra', privKey: generatePrivateKey(), hosts: []},
|
||||
];
|
||||
|
||||
if (request.greeting === "hello")
|
||||
sendResponse({ farewell: "goodbye" });
|
||||
let activeProfile = 0;
|
||||
|
||||
browser.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
||||
console.log(message);
|
||||
if (message.kind === 'getPubKey') {
|
||||
const privKey = getPublicKey(message.payload);
|
||||
sendResponse(privKey);
|
||||
} else if (message.kind === 'newKey') {
|
||||
const privKey = generatePrivateKey();
|
||||
sendResponse(privKey);
|
||||
} else if (message.kind === 'getProfiles') {
|
||||
sendResponse(profiles);
|
||||
} else if (message.kind === 'getActiveProfile') {
|
||||
sendResponse(activeProfile);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user