remove clipboardRead permission & pretty

This commit is contained in:
Sebastian 2022-12-22 12:13:59 -03:00
parent 9ac1c902c0
commit f1962dceb3
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
6 changed files with 53 additions and 50 deletions

View File

@ -24,8 +24,7 @@
"optional_permissions": [
"http://*/*",
"https://*/*",
"webRequest",
"clipboardRead"
"webRequest"
],
"browser_action": {
"default_icon": {

View File

@ -27,8 +27,7 @@
}
},
"optional_permissions": [
"webRequest",
"clipboardRead"
"webRequest"
],
"host_permissions": [
"http://*/*",

View File

@ -83,13 +83,14 @@ const hostPermissions = {
export function containsClipboardPermissions(): Promise<boolean> {
return new Promise((res, rej) => {
chrome.permissions.contains({ permissions: ["clipboardRead"] }, (resp) => {
const le = chrome.runtime.lastError?.message;
if (le) {
rej(le);
}
res(resp);
});
res(false);
// chrome.permissions.contains({ permissions: ["clipboardRead"] }, (resp) => {
// const le = chrome.runtime.lastError?.message;
// if (le) {
// rej(le);
// }
// res(resp);
// });
});
}
@ -107,13 +108,14 @@ export function containsHostPermissions(): Promise<boolean> {
export async function requestClipboardPermissions(): Promise<boolean> {
return new Promise((res, rej) => {
chrome.permissions.request({ permissions: ["clipboardRead"] }, (resp) => {
const le = chrome.runtime.lastError?.message;
if (le) {
rej(le);
}
res(resp);
});
res(false);
// chrome.permissions.request({ permissions: ["clipboardRead"] }, (resp) => {
// const le = chrome.runtime.lastError?.message;
// if (le) {
// rej(le);
// }
// res(resp);
// });
});
}
@ -187,13 +189,14 @@ export async function removeHostPermissions(): Promise<boolean> {
export function removeClipboardPermissions(): Promise<boolean> {
return new Promise((res, rej) => {
chrome.permissions.remove({ permissions: ["clipboardRead"] }, (resp) => {
const le = chrome.runtime.lastError?.message;
if (le) {
rej(le);
}
res(resp);
});
res(true);
// chrome.permissions.remove({ permissions: ["clipboardRead"] }, (resp) => {
// const le = chrome.runtime.lastError?.message;
// if (le) {
// rej(le);
// }
// res(resp);
// });
});
}
@ -775,21 +778,23 @@ async function timeout(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function findTalerUriInClipboard(): Promise<string | undefined> {
try {
//It looks like clipboard promise does not return, so we need a timeout
const textInClipboard = await Promise.any([
timeout(100),
window.navigator.clipboard.readText(),
]);
if (!textInClipboard) return;
return textInClipboard.startsWith("taler://") ||
textInClipboard.startsWith("taler+http://")
? textInClipboard
: undefined;
} catch (e) {
logger.error("could not read clipboard", e);
return undefined;
}
//FIXME: add clipboard feature
// try {
// //It looks like clipboard promise does not return, so we need a timeout
// const textInClipboard = await Promise.any([
// timeout(100),
// window.navigator.clipboard.readText(),
// ]);
// if (!textInClipboard) return;
// return textInClipboard.startsWith("taler://") ||
// textInClipboard.startsWith("taler+http://")
// ? textInClipboard
// : undefined;
// } catch (e) {
// logger.error("could not read clipboard", e);
// return undefined;
// }
return undefined;
}
async function findTalerUriInActiveTab(): Promise<string | undefined> {

View File

@ -115,12 +115,12 @@ export function SettingsView({
error={autoOpenToggle.button.error.errorDetail}
/>
)}
{clipboardToggle.button.error && (
{/* {clipboardToggle.button.error && (
<ErrorTalerOperation
title={<i18n.Translate>Could not toggle clipboard</i18n.Translate>}
error={clipboardToggle.button.error.errorDetail}
/>
)}
)} */}
<SubTitle>
<i18n.Translate>Navigator</i18n.Translate>
</SubTitle>
@ -140,7 +140,7 @@ export function SettingsView({
enabled={autoOpenToggle.value!}
onToggle={autoOpenToggle.button.onClick!}
/>
<Checkbox
{/* <Checkbox
label={
<i18n.Translate>
Automatically check clipboard for Taler URI
@ -155,7 +155,7 @@ export function SettingsView({
}
enabled={clipboardToggle.value!}
onToggle={clipboardToggle.button.onClick!}
/>
/> */}
<SubTitle>
<i18n.Translate>Trust</i18n.Translate>

View File

@ -58,9 +58,9 @@ export interface BackgroundOperations {
response: void;
};
sum: {
request: number[],
response: number,
}
request: number[];
response: number;
};
resetDb: {
request: void;
response: void;

View File

@ -164,12 +164,12 @@ async function toggleHeaderListener(
function freeze(time: number): Promise<void> {
return new Promise((res, rej) => {
setTimeout(res, time)
})
setTimeout(res, time);
});
}
async function sum(ns: Array<number>): Promise<number> {
return ns.reduce((prev, cur) => prev + cur, 0)
return ns.reduce((prev, cur) => prev + cur, 0);
}
const backendHandlers: BackendHandlerType = {