| import * as us from 'unscan' |
| import fetch from 'node-fetch' |
| import { writeFileSync } from 'fs' |
| import generateFileName from './temp/generateFileName.js' |
| import * as path from 'path' |
| import {fileURLToPath} from 'url'; |
| const __filename = fileURLToPath(import.meta.url); |
| const __dirname = path.dirname(__filename); |
| |
| export async function testNSFW(link: string): Promise<JSON> { |
| const image = (await (await fetch(link)).buffer()).toString('base64') |
| let fileName = generateFileName(link.split('/').pop().split('.').pop()) |
| let p = path.join(__dirname, '/temp', fileName) |
| writeFileSync(p, image, 'base64') |
| let result = await us.nsfw.file(p) |
| return result |
| } |
| |
| export async function testMalware(link: string): Promise<JSON> { |
| const file = (await (await fetch(link)).buffer()).toString('base64') |
| let fileName = generateFileName(link.split('/').pop().split('.').pop()) |
| let p = path.join(__dirname, '/temp', fileName) |
| writeFileSync(p, file, 'base64') |
| let result = await us.malware.file(p) |
| return result |
| } |
| |
| export async function testLink(link: string): Promise<JSON> { |
| return await us.link.scan(link) |
| } |