skeleton.

This commit is contained in:
fiatjaf
2022-01-09 21:30:15 -03:00
commit 853a2b304b
13 changed files with 1316 additions and 0 deletions

9
extension/background.js Normal file
View File

@@ -0,0 +1,9 @@
browser.runtime.onMessage.addListener((req, sender, reply) => {
switch (req.type) {
case 'getPublicKey':
reply({})
break
case 'signEvent':
break
}
})

View File

@@ -0,0 +1,24 @@
// inject the script that will provide window.nostr
let script = document.createElement('script')
script.src = 'nostr-provider.js'
document.head.appendChild(script)
// listen for messages from that script
window.addEventListener('message', async ev => {
if (ev.source !== window) return
if (!ev.data || ev.data.ext !== 'nostr') {
// pass on to background
var reply
try {
reply = browser.runtime.sendMessage({
...ev.data,
host: window.location.host
})
} catch (error) {
reply = {error}
}
// return response
window.postMessage({id: ev.data.id, reply})
}
})

29
extension/manifest.json Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "nos2x",
"description": "Nostr Signer Extension",
"version": "0.0.1",
"manifest_version": 2,
"icons": {
"16": "icons/icon-16x16.png",
"48": "icons/icon-48x48.png",
"128": "icons/icon-128x128.png"
},
"options_page": "options.html",
"background": {
"scripts": [
"background.js"
],
"persistent": false
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": [
"content-script.js"
]
}],
"permissions": [
"activeTab",
"storage"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self';"
}

View File

@@ -0,0 +1,4 @@
window.nostr = {
getPublicKey() {},
signEvent(event) {}
}

0
extension/options.html Normal file
View File