fix(core): update

This commit is contained in:
2023-07-28 09:54:22 +02:00
parent b80e042cbd
commit ca1d0bd9a3
5 changed files with 36 additions and 23 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/abuse.ch',
version: '1.0.4',
version: '1.0.5',
description: 'an unofficial client to retrieve abuse.ch data'
}

View File

@ -1,5 +1,6 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import axios from 'axios';
export interface IThreatFoxData {
ID: string;
@ -20,19 +21,13 @@ export class ThreatFox {
const zipPath = plugins.path.join(paths.threatFoxTmp, 'threatfox.zip');
const csvPath = plugins.path.join(paths.threatFoxTmp, 'full.csv');
const response = await fetch(ThreatFox.THREATFOX_API_URL);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const response = await axios.get(ThreatFox.THREATFOX_API_URL, { responseType: 'stream' });
await new Promise((resolve, reject) => {
const fileStream = plugins.fs.createWriteStream(zipPath);
// @ts-ignore
const readable = plugins.stream.Readable.from(response.body);
plugins.stream.pipeline(readable, fileStream, (err) => {
if (err) reject(err);
else resolve(null);
});
response.data.pipe(fileStream);
fileStream.on('finish', resolve);
fileStream.on('error', reject);
});
await new Promise((resolve, reject) => {

View File

@ -1,5 +1,6 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import axios from 'axios';
export interface IUrlHouseData {
ID: string;
@ -20,19 +21,13 @@ export class UrlHouse {
const zipPath = plugins.path.join(paths.urlHouseTmp, 'urlhaus.zip');
const csvPath = plugins.path.join(paths.urlHouseTmp, 'csv.txt');
const response = await fetch(UrlHouse.URLHOUSE_API_URL);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const response = await axios.get(UrlHouse.URLHOUSE_API_URL, { responseType: 'stream' });
await new Promise((resolve, reject) => {
const fileStream = plugins.fs.createWriteStream(zipPath);
// @ts-ignore
const readable = plugins.stream.Readable.from(response.body);
plugins.stream.pipeline(readable, fileStream, (err) => {
if (err) reject(err);
else resolve(null);
});
response.data.pipe(fileStream);
fileStream.on('finish', resolve);
fileStream.on('error', reject);
});
await new Promise((resolve, reject) => {