Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update phishing config request logic #244

Merged
merged 1 commit into from
Jun 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/third-party/PhishingController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface PhishingState extends BaseState {
* Controller that passively polls on a set interval for approved and unapproved website origins
*/
export class PhishingController extends BaseController<PhishingConfig, PhishingState> {
private configUrl = 'https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/master/src/config.json';
private configUrl = 'https://api.github.com/repos/MetaMask/eth-phishing-detect/contents/src/config.json';
private configEtag: string = '';
private detector: any;
private handle?: NodeJS.Timer;
Expand Down Expand Up @@ -140,6 +140,7 @@ export class PhishingController extends BaseController<PhishingConfig, PhishingS
private async queryConfig(input: RequestInfo): Promise<EthPhishingResponse | null> {
const response = await fetch(input, {
headers: {
'Accept': 'application/vnd.github.v3.raw+json',
'If-None-Match': this.configEtag
}
});
Expand All @@ -149,7 +150,8 @@ export class PhishingController extends BaseController<PhishingConfig, PhishingS
this.configEtag = response.headers.get('ETag') || /* istanbul ignore next */ '';
return await response.json();
}
case 304: {
case 304:
case 403: {
return null;
}
default: {
Expand Down