Extension: reject requests from unauthorized urls (#101)
This commit is contained in:
parent
8ad0801a29
commit
e1a0bd2db8
@ -193,7 +193,7 @@ export default class State {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public isUrlAuthorized (url: string): boolean {
|
public ensureUrlAuthorized (url: string): boolean {
|
||||||
const entry = this._authUrls[this.stripUrl(url)];
|
const entry = this._authUrls[this.stripUrl(url)];
|
||||||
|
|
||||||
assert(entry, `The source ${url} has not been enabled yet`);
|
assert(entry, `The source ${url} has not been enabled yet`);
|
||||||
|
|||||||
@ -66,6 +66,10 @@ export default class Tabs {
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
public async handle (id: string, type: MessageTypes, request: any, url: string, port: chrome.runtime.Port): Promise<any> {
|
public async handle (id: string, type: MessageTypes, request: any, url: string, port: chrome.runtime.Port): Promise<any> {
|
||||||
|
if (type !== 'authorize.tab') {
|
||||||
|
this.state.ensureUrlAuthorized(url);
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'authorize.tab':
|
case 'authorize.tab':
|
||||||
return this.authorize(url, request);
|
return this.authorize(url, request);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user