web/src/utils/fetch-website-info.ts
144 lines · 2769 bytes
17 symbols in this file
1import { fetchEnrich } from './fetch-enrich';
2
3export const fetchWebsiteInfo = (url: string): Promise<WebsiteData | null> =>
4 fetchEnrich<WebsiteData>(
5 'Website',
6 `/v1/enrich/website?url=${encodeURIComponent(url)}`,
7 url,
8 );
9
10interface DNSRecord {
11 target: string;
12 ip: string;
13 country_code: string;
14 country_name: string;
15 isp: string;
16}
17
18interface DNSRecords {
19 ns: {
20 records: DNSRecord[];
21 };
22 mx: {
23 records: DNSRecord[];
24 };
25}
26
27interface Engine {
28 name: string;
29 reference: string;
30 detected: boolean;
31}
32
33interface DomainBlacklist {
34 engines: Engine[];
35 detections: number;
36}
37
38interface FileType {
39 signature: string;
40 extension: string;
41 headers: string;
42}
43
44interface GeoLocation {
45 countries: string[];
46}
47
48interface HtmlForms {
49 number_of_total_forms: number;
50 number_of_total_input_fields: number;
51 two_text_inputs_in_a_form: boolean;
52 credit_card_field_present: boolean;
53 password_field_present: boolean;
54 email_field_present: boolean;
55}
56
57interface Redirection {
58 found: boolean;
59 external: boolean;
60 url: string;
61 redirects: string[];
62}
63
64interface ResponseHeaders {
65 code: number;
66 status: string;
67 date: string;
68 last_modified: string;
69 etag: string;
70 accept_ranges: string;
71 vary: string;
72 content_encoding: string;
73 cache_control: string;
74 content_length: string;
75 content_type: string;
76 age: string;
77 content_security_policy_report_only: string;
78 strict_transport_security: string;
79 public_key_pins_report_only: string;
80 x_frame_options: string;
81 x_content_type_options: string;
82 x_xss_protection: string;
83 referrer_policy: string;
84 x_permitted_cross_domain_policies: string;
85 onion_location: string;
86}
87
88interface RiskScore {
89 result: number;
90}
91
92interface SecurityChecks {
93 [key: string]: boolean | string;
94}
95
96interface ServerDetails {
97 ip: string;
98 hostname: string;
99 continent_code: string;
100 continent_name: string;
101 country_code: string;
102 country_name: string;
103 region_name: string;
104 city_name: string;
105 latitude: number;
106 longitude: number;
107 isp: string;
108 asn: string;
109}
110
111interface SiteCategory {
112 [key: string]: boolean;
113}
114
115interface UrlParts {
116 scheme: string;
117 host: string;
118 host_nowww: string;
119 port: null | number;
120 path: null | string;
121 query: null | string;
122}
123
124interface WebPage {
125 title: string;
126 description: string;
127 keywords: string;
128}
129
130export interface WebsiteData {
131 dns_records: DNSRecords;
132 domain_blacklist: DomainBlacklist;
133 file_type: FileType;
134 geo_location: GeoLocation;
135 html_forms: HtmlForms;
136 redirection: Redirection;
137 response_headers: ResponseHeaders;
138 risk_score: RiskScore;
139 security_checks: SecurityChecks;
140 server_details: ServerDetails;
141 site_category: SiteCategory;
142 url_parts: UrlParts;
143 web_page: WebPage;
144}