Show/Hide Button for private key in Options page. Move experimental page into separate sub-folder. Move delegation wizard to sub-folder. Move permission page into separate folder. Basic functional SwiftUI look for the app. Beginning to define the main app view. NavigationStack and Privacy Policy Show App Icon on main screen. Getting Started: macOS Getting Started: iPhone Getting Started: iPad Removing old default UIKit code. Added "No Thanks" toggle to the relay reminder. Clearly indicate in the Settings page when a profile is a delegated profile. Changed recommended relays to all public relays. Use x-cloak in all the places. Fix bundle display name to use capital N. Added copy button to pubkey in settings. Window default size. Updating event kind list. Allow events to be copied by clicking on them in the event log. Tweaking the colors for a more purple-ish look. Added Tips and Tricks view to native app. Move utilities modules into separate folder. Rename event_log files to event_history to escape some content blockers. Renamed Event Log to Event History in the UI as well.
104 lines
2.7 KiB
JavaScript
104 lines
2.7 KiB
JavaScript
import Alpine from 'alpinejs';
|
|
import jsonFormatHighlight from 'json-format-highlight';
|
|
import { KINDS } from '../utilities/utils';
|
|
|
|
storage = browser.storage.local;
|
|
|
|
window.addEventListener('beforeunload', () => {
|
|
browser.runtime.sendMessage({ kind: 'closePrompt' });
|
|
return true;
|
|
});
|
|
|
|
Alpine.data('permission', () => ({
|
|
host: '',
|
|
permission: '',
|
|
key: '',
|
|
event: '',
|
|
remember: false,
|
|
|
|
async init() {
|
|
let qs = new URLSearchParams(location.search);
|
|
console.log(location.search);
|
|
this.host = qs.get('host');
|
|
this.permission = qs.get('kind');
|
|
this.key = qs.get('uuid');
|
|
this.event = JSON.parse(qs.get('payload'));
|
|
},
|
|
|
|
async allow() {
|
|
console.log('allowing');
|
|
await browser.runtime.sendMessage({
|
|
kind: 'allowed',
|
|
payload: this.key,
|
|
origKind: this.permission,
|
|
event: this.event,
|
|
remember: this.remember,
|
|
host: this.host,
|
|
});
|
|
console.log('closing');
|
|
await this.close();
|
|
},
|
|
|
|
async deny() {
|
|
await browser.runtime.sendMessage({
|
|
kind: 'denied',
|
|
payload: this.key,
|
|
origKind: this.permission,
|
|
event: this.event,
|
|
remember: this.remember,
|
|
host: this.host,
|
|
});
|
|
await this.close();
|
|
},
|
|
|
|
async close() {
|
|
let tab = await browser.tabs.getCurrent();
|
|
console.log('closing current tab: ', tab.id);
|
|
await browser.tabs.update(tab.openerTabId, { active: true });
|
|
window.close();
|
|
},
|
|
|
|
async openNip() {
|
|
await browser.tabs.create({ url: this.eventInfo.nip, active: true });
|
|
},
|
|
|
|
get humanPermission() {
|
|
switch (this.permission) {
|
|
case 'getPubKey':
|
|
return 'Read public key';
|
|
case 'signEvent':
|
|
return 'Sign event';
|
|
case 'getRelays':
|
|
return 'Read relay list';
|
|
case 'nip04.encrypt':
|
|
return 'Encrypt private message';
|
|
case 'nip04.decrypt':
|
|
return 'Decrypt private message';
|
|
default:
|
|
break;
|
|
}
|
|
},
|
|
|
|
get humanEvent() {
|
|
return jsonFormatHighlight(this.event);
|
|
},
|
|
|
|
get isSigningEvent() {
|
|
return this.permission === 'signEvent';
|
|
},
|
|
|
|
get eventInfo() {
|
|
if (!this.isSigningEvent) {
|
|
return {};
|
|
}
|
|
|
|
let [kind, desc, nip] = KINDS.find(([kind, desc, nip]) => {
|
|
return kind === this.event.kind;
|
|
}) || ['Unknown', 'Unknown', 'https://github.com/nostr-protocol/nips'];
|
|
|
|
return { kind, desc, nip };
|
|
},
|
|
}));
|
|
|
|
Alpine.start();
|