mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-06-13 00:01:05 +00:00
Bump common (#1788)
This commit is contained in:
@@ -21,9 +21,9 @@
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/util": "^10.0.1",
|
||||
"@polkadot/util-crypto": "^10.0.1",
|
||||
"@polkadot/x-fetch": "^10.0.1"
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/x-fetch": "^10.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import fs from 'fs';
|
||||
import { load as yamlParse } from 'js-yaml';
|
||||
|
||||
import { fetch } from '@polkadot/x-fetch';
|
||||
import { fetchJson, fetchText } from './fetch';
|
||||
|
||||
interface CryptoScamEntry {
|
||||
addresses: Record<string, string[]>;
|
||||
@@ -56,7 +56,7 @@ describe('crosscheck', (): void => {
|
||||
});
|
||||
|
||||
it('has all the relevant entries from CryptoScamDb', async (): Promise<void> => {
|
||||
const raw = await fetch(CRYPTODB).then((r) => r.text());
|
||||
const raw = await fetchText(CRYPTODB);
|
||||
|
||||
// this is a hack, the text slipped in upstream
|
||||
const scamDb = yamlParse(raw.replace('∂ç', '')) as CryptoScamEntry[];
|
||||
@@ -72,7 +72,7 @@ describe('crosscheck', (): void => {
|
||||
});
|
||||
|
||||
it('has polkadot/kusama entries from eth-phishing-detect', async (): Promise<void> => {
|
||||
const ethDb = await fetch(ETHPHISH).then<EthPhishing>((r) => r.json());
|
||||
const ethDb = await fetchJson<EthPhishing>(ETHPHISH);
|
||||
const filtered = ethDb.blacklist.filter((url) => matchName(url));
|
||||
const missing = filtered.filter((url) => !ours.includes(url));
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
import { fetch } from '@polkadot/x-fetch';
|
||||
|
||||
// this is also in @polkadot/apps-config - we may want to expose it
|
||||
// inside x-fetch at some point in the future...
|
||||
|
||||
// a fetch with a 2s timeout
|
||||
async function fetchWithTimeout (url: string, timeout = 2000): Promise<Response> {
|
||||
const controller = new AbortController();
|
||||
@@ -29,10 +32,10 @@ async function fetchWithTimeout (url: string, timeout = 2000): Promise<Response>
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchJson <T> (url: string, timeout = 2000): Promise<T> {
|
||||
export function fetchJson <T> (url: string, timeout?: number): Promise<T> {
|
||||
return fetchWithTimeout(url, timeout).then<T>((r) => r.json());
|
||||
}
|
||||
|
||||
export function fetchText (url: string, timeout = 2000): Promise<string> {
|
||||
export function fetchText (url: string, timeout?: number): Promise<string> {
|
||||
return fetchWithTimeout(url, timeout).then((r) => r.text());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user