aurix-ai 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,57 +1,570 @@
1
+ const COUNTRY_CODES = {
2
+ '1': { country: 'United States / Canada', flag: 'US/CA', code2: 'US' },
3
+ '7': { country: 'Russia / Kazakhstan', flag: 'RU/KZ', code2: 'RU' },
4
+ '20': { country: 'Egypt', flag: 'EG', code2: 'EG' },
5
+ '27': { country: 'South Africa', flag: 'ZA', code2: 'ZA' },
6
+ '30': { country: 'Greece', flag: 'GR', code2: 'GR' },
7
+ '31': { country: 'Netherlands', flag: 'NL', code2: 'NL' },
8
+ '32': { country: 'Belgium', flag: 'BE', code2: 'BE' },
9
+ '33': { country: 'France', flag: 'FR', code2: 'FR' },
10
+ '34': { country: 'Spain', flag: 'ES', code2: 'ES' },
11
+ '36': { country: 'Hungary', flag: 'HU', code2: 'HU' },
12
+ '39': { country: 'Italy', flag: 'IT', code2: 'IT' },
13
+ '40': { country: 'Romania', flag: 'RO', code2: 'RO' },
14
+ '41': { country: 'Switzerland', flag: 'CH', code2: 'CH' },
15
+ '43': { country: 'Austria', flag: 'AT', code2: 'AT' },
16
+ '44': { country: 'United Kingdom', flag: 'GB', code2: 'GB' },
17
+ '45': { country: 'Denmark', flag: 'DK', code2: 'DK' },
18
+ '46': { country: 'Sweden', flag: 'SE', code2: 'SE' },
19
+ '47': { country: 'Norway', flag: 'NO', code2: 'NO' },
20
+ '48': { country: 'Poland', flag: 'PL', code2: 'PL' },
21
+ '49': { country: 'Germany', flag: 'DE', code2: 'DE' },
22
+ '51': { country: 'Peru', flag: 'PE', code2: 'PE' },
23
+ '52': { country: 'Mexico', flag: 'MX', code2: 'MX' },
24
+ '53': { country: 'Cuba', flag: 'CU', code2: 'CU' },
25
+ '54': { country: 'Argentina', flag: 'AR', code2: 'AR' },
26
+ '55': { country: 'Brazil', flag: 'BR', code2: 'BR' },
27
+ '56': { country: 'Chile', flag: 'CL', code2: 'CL' },
28
+ '57': { country: 'Colombia', flag: 'CO', code2: 'CO' },
29
+ '58': { country: 'Venezuela', flag: 'VE', code2: 'VE' },
30
+ '60': { country: 'Malaysia', flag: 'MY', code2: 'MY' },
31
+ '61': { country: 'Australia', flag: 'AU', code2: 'AU' },
32
+ '62': { country: 'Indonesia', flag: 'ID', code2: 'ID' },
33
+ '63': { country: 'Philippines', flag: 'PH', code2: 'PH' },
34
+ '64': { country: 'New Zealand', flag: 'NZ', code2: 'NZ' },
35
+ '65': { country: 'Singapore', flag: 'SG', code2: 'SG' },
36
+ '66': { country: 'Thailand', flag: 'TH', code2: 'TH' },
37
+ '81': { country: 'Japan', flag: 'JP', code2: 'JP' },
38
+ '82': { country: 'South Korea', flag: 'KR', code2: 'KR' },
39
+ '84': { country: 'Vietnam', flag: 'VN', code2: 'VN' },
40
+ '86': { country: 'China', flag: 'CN', code2: 'CN' },
41
+ '90': { country: 'Turkey', flag: 'TR', code2: 'TR' },
42
+ '91': { country: 'India', flag: 'IN', code2: 'IN' },
43
+ '92': { country: 'Pakistan', flag: 'PK', code2: 'PK' },
44
+ '93': { country: 'Afghanistan', flag: 'AF', code2: 'AF' },
45
+ '94': { country: 'Sri Lanka', flag: 'LK', code2: 'LK' },
46
+ '95': { country: 'Myanmar', flag: 'MM', code2: 'MM' },
47
+ '212': { country: 'Morocco', flag: 'MA', code2: 'MA' },
48
+ '213': { country: 'Algeria', flag: 'DZ', code2: 'DZ' },
49
+ '216': { country: 'Tunisia', flag: 'TN', code2: 'TN' },
50
+ '218': { country: 'Libya', flag: 'LY', code2: 'LY' },
51
+ '220': { country: 'Gambia', flag: 'GM', code2: 'GM' },
52
+ '221': { country: 'Senegal', flag: 'SN', code2: 'SN' },
53
+ '222': { country: 'Mauritania', flag: 'MR', code2: 'MR' },
54
+ '223': { country: 'Mali', flag: 'ML', code2: 'ML' },
55
+ '224': { country: 'Guinea', flag: 'GN', code2: 'GN' },
56
+ '225': { country: 'Ivory Coast', flag: 'CI', code2: 'CI' },
57
+ '226': { country: 'Burkina Faso', flag: 'BF', code2: 'BF' },
58
+ '227': { country: 'Niger', flag: 'NE', code2: 'NE' },
59
+ '228': { country: 'Togo', flag: 'TG', code2: 'TG' },
60
+ '229': { country: 'Benin', flag: 'BJ', code2: 'BJ' },
61
+ '230': { country: 'Mauritius', flag: 'MU', code2: 'MU' },
62
+ '231': { country: 'Liberia', flag: 'LR', code2: 'LR' },
63
+ '232': { country: 'Sierra Leone', flag: 'SL', code2: 'SL' },
64
+ '233': { country: 'Ghana', flag: 'GH', code2: 'GH' },
65
+ '234': { country: 'Nigeria', flag: 'NG', code2: 'NG' },
66
+ '235': { country: 'Chad', flag: 'TD', code2: 'TD' },
67
+ '236': { country: 'Central African Rep.', flag: 'CF', code2: 'CF' },
68
+ '237': { country: 'Cameroon', flag: 'CM', code2: 'CM' },
69
+ '238': { country: 'Cape Verde', flag: 'CV', code2: 'CV' },
70
+ '240': { country: 'Equatorial Guinea', flag: 'GQ', code2: 'GQ' },
71
+ '241': { country: 'Gabon', flag: 'GA', code2: 'GA' },
72
+ '242': { country: 'Congo', flag: 'CG', code2: 'CG' },
73
+ '244': { country: 'Angola', flag: 'AO', code2: 'AO' },
74
+ '245': { country: 'Guinea-Bissau', flag: 'GW', code2: 'GW' },
75
+ '248': { country: 'Seychelles', flag: 'SC', code2: 'SC' },
76
+ '249': { country: 'Sudan', flag: 'SD', code2: 'SD' },
77
+ '250': { country: 'Rwanda', flag: 'RW', code2: 'RW' },
78
+ '251': { country: 'Ethiopia', flag: 'ET', code2: 'ET' },
79
+ '252': { country: 'Somalia', flag: 'SO', code2: 'SO' },
80
+ '253': { country: 'Djibouti', flag: 'DJ', code2: 'DJ' },
81
+ '254': { country: 'Kenya', flag: 'KE', code2: 'KE' },
82
+ '255': { country: 'Tanzania', flag: 'TZ', code2: 'TZ' },
83
+ '256': { country: 'Uganda', flag: 'UG', code2: 'UG' },
84
+ '257': { country: 'Burundi', flag: 'BI', code2: 'BI' },
85
+ '258': { country: 'Mozambique', flag: 'MZ', code2: 'MZ' },
86
+ '260': { country: 'Zambia', flag: 'ZM', code2: 'ZM' },
87
+ '261': { country: 'Madagascar', flag: 'MG', code2: 'MG' },
88
+ '263': { country: 'Zimbabwe', flag: 'ZW', code2: 'ZW' },
89
+ '264': { country: 'Namibia', flag: 'NA', code2: 'NA' },
90
+ '265': { country: 'Malawi', flag: 'MW', code2: 'MW' },
91
+ '266': { country: 'Lesotho', flag: 'LS', code2: 'LS' },
92
+ '267': { country: 'Botswana', flag: 'BW', code2: 'BW' },
93
+ '268': { country: 'Eswatini', flag: 'SZ', code2: 'SZ' },
94
+ '269': { country: 'Comoros', flag: 'KM', code2: 'KM' },
95
+ '350': { country: 'Gibraltar', flag: 'GI', code2: 'GI' },
96
+ '351': { country: 'Portugal', flag: 'PT', code2: 'PT' },
97
+ '352': { country: 'Luxembourg', flag: 'LU', code2: 'LU' },
98
+ '353': { country: 'Ireland', flag: 'IE', code2: 'IE' },
99
+ '354': { country: 'Iceland', flag: 'IS', code2: 'IS' },
100
+ '355': { country: 'Albania', flag: 'AL', code2: 'AL' },
101
+ '356': { country: 'Malta', flag: 'MT', code2: 'MT' },
102
+ '357': { country: 'Cyprus', flag: 'CY', code2: 'CY' },
103
+ '358': { country: 'Finland', flag: 'FI', code2: 'FI' },
104
+ '359': { country: 'Bulgaria', flag: 'BG', code2: 'BG' },
105
+ '370': { country: 'Lithuania', flag: 'LT', code2: 'LT' },
106
+ '371': { country: 'Latvia', flag: 'LV', code2: 'LV' },
107
+ '372': { country: 'Estonia', flag: 'EE', code2: 'EE' },
108
+ '373': { country: 'Moldova', flag: 'MD', code2: 'MD' },
109
+ '374': { country: 'Armenia', flag: 'AM', code2: 'AM' },
110
+ '375': { country: 'Belarus', flag: 'BY', code2: 'BY' },
111
+ '376': { country: 'Andorra', flag: 'AD', code2: 'AD' },
112
+ '377': { country: 'Monaco', flag: 'MC', code2: 'MC' },
113
+ '378': { country: 'San Marino', flag: 'SM', code2: 'SM' },
114
+ '380': { country: 'Ukraine', flag: 'UA', code2: 'UA' },
115
+ '381': { country: 'Serbia', flag: 'RS', code2: 'RS' },
116
+ '382': { country: 'Montenegro', flag: 'ME', code2: 'ME' },
117
+ '383': { country: 'Kosovo', flag: 'XK', code2: 'XK' },
118
+ '385': { country: 'Croatia', flag: 'HR', code2: 'HR' },
119
+ '386': { country: 'Slovenia', flag: 'SI', code2: 'SI' },
120
+ '387': { country: 'Bosnia and Herzegovina', flag: 'BA', code2: 'BA' },
121
+ '389': { country: 'North Macedonia', flag: 'MK', code2: 'MK' },
122
+ '420': { country: 'Czech Republic', flag: 'CZ', code2: 'CZ' },
123
+ '421': { country: 'Slovakia', flag: 'SK', code2: 'SK' },
124
+ '423': { country: 'Liechtenstein', flag: 'LI', code2: 'LI' },
125
+ '500': { country: 'Falkland Islands', flag: 'FK', code2: 'FK' },
126
+ '501': { country: 'Belize', flag: 'BZ', code2: 'BZ' },
127
+ '502': { country: 'Guatemala', flag: 'GT', code2: 'GT' },
128
+ '503': { country: 'El Salvador', flag: 'SV', code2: 'SV' },
129
+ '504': { country: 'Honduras', flag: 'HN', code2: 'HN' },
130
+ '505': { country: 'Nicaragua', flag: 'NI', code2: 'NI' },
131
+ '506': { country: 'Costa Rica', flag: 'CR', code2: 'CR' },
132
+ '507': { country: 'Panama', flag: 'PA', code2: 'PA' },
133
+ '508': { country: 'Saint Pierre and Miquelon', flag: 'PM', code2: 'PM' },
134
+ '509': { country: 'Haiti', flag: 'HT', code2: 'HT' },
135
+ '590': { country: 'Guadeloupe', flag: 'GP', code2: 'GP' },
136
+ '591': { country: 'Bolivia', flag: 'BO', code2: 'BO' },
137
+ '592': { country: 'Guyana', flag: 'GY', code2: 'GY' },
138
+ '593': { country: 'Ecuador', flag: 'EC', code2: 'EC' },
139
+ '595': { country: 'Paraguay', flag: 'PY', code2: 'PY' },
140
+ '596': { country: 'Martinique', flag: 'MQ', code2: 'MQ' },
141
+ '597': { country: 'Suriname', flag: 'SR', code2: 'SR' },
142
+ '598': { country: 'Uruguay', flag: 'UY', code2: 'UY' },
143
+ '599': { country: 'Curacao', flag: 'CW', code2: 'CW' },
144
+ '670': { country: 'East Timor', flag: 'TL', code2: 'TL' },
145
+ '672': { country: 'Norfolk Island', flag: 'NF', code2: 'NF' },
146
+ '673': { country: 'Brunei', flag: 'BN', code2: 'BN' },
147
+ '674': { country: 'Nauru', flag: 'NR', code2: 'NR' },
148
+ '675': { country: 'Papua New Guinea', flag: 'PG', code2: 'PG' },
149
+ '676': { country: 'Tonga', flag: 'TO', code2: 'TO' },
150
+ '677': { country: 'Solomon Islands', flag: 'SB', code2: 'SB' },
151
+ '678': { country: 'Vanuatu', flag: 'VU', code2: 'VU' },
152
+ '679': { country: 'Fiji', flag: 'FJ', code2: 'FJ' },
153
+ '680': { country: 'Palau', flag: 'PW', code2: 'PW' },
154
+ '685': { country: 'Samoa', flag: 'WS', code2: 'WS' },
155
+ '686': { country: 'Kiribati', flag: 'KI', code2: 'KI' },
156
+ '688': { country: 'Tuvalu', flag: 'TV', code2: 'TV' },
157
+ '690': { country: 'Tokelau', flag: 'TK', code2: 'TK' },
158
+ '691': { country: 'Micronesia', flag: 'FM', code2: 'FM' },
159
+ '692': { country: 'Marshall Islands', flag: 'MH', code2: 'MH' },
160
+ '850': { country: 'North Korea', flag: 'KP', code2: 'KP' },
161
+ '852': { country: 'Hong Kong', flag: 'HK', code2: 'HK' },
162
+ '853': { country: 'Macau', flag: 'MO', code2: 'MO' },
163
+ '855': { country: 'Cambodia', flag: 'KH', code2: 'KH' },
164
+ '856': { country: 'Laos', flag: 'LA', code2: 'LA' },
165
+ '880': { country: 'Bangladesh', flag: 'BD', code2: 'BD' },
166
+ '886': { country: 'Taiwan', flag: 'TW', code2: 'TW' },
167
+ '960': { country: 'Maldives', flag: 'MV', code2: 'MV' },
168
+ '961': { country: 'Lebanon', flag: 'LB', code2: 'LB' },
169
+ '962': { country: 'Jordan', flag: 'JO', code2: 'JO' },
170
+ '963': { country: 'Syria', flag: 'SY', code2: 'SY' },
171
+ '964': { country: 'Iraq', flag: 'IQ', code2: 'IQ' },
172
+ '965': { country: 'Kuwait', flag: 'KW', code2: 'KW' },
173
+ '966': { country: 'Saudi Arabia', flag: 'SA', code2: 'SA' },
174
+ '967': { country: 'Yemen', flag: 'YE', code2: 'YE' },
175
+ '968': { country: 'Oman', flag: 'OM', code2: 'OM' },
176
+ '970': { country: 'Palestine', flag: 'PS', code2: 'PS' },
177
+ '971': { country: 'UAE', flag: 'AE', code2: 'AE' },
178
+ '972': { country: 'Israel', flag: 'IL', code2: 'IL' },
179
+ '973': { country: 'Bahrain', flag: 'BH', code2: 'BH' },
180
+ '974': { country: 'Qatar', flag: 'QA', code2: 'QA' },
181
+ '975': { country: 'Bhutan', flag: 'BT', code2: 'BT' },
182
+ '976': { country: 'Mongolia', flag: 'MN', code2: 'MN' },
183
+ '977': { country: 'Nepal', flag: 'NP', code2: 'NP' },
184
+ '992': { country: 'Tajikistan', flag: 'TJ', code2: 'TJ' },
185
+ '993': { country: 'Turkmenistan', flag: 'TM', code2: 'TM' },
186
+ '994': { country: 'Azerbaijan', flag: 'AZ', code2: 'AZ' },
187
+ '995': { country: 'Georgia', flag: 'GE', code2: 'GE' },
188
+ '996': { country: 'Kyrgyzstan', flag: 'KG', code2: 'KG' },
189
+ '998': { country: 'Uzbekistan', flag: 'UZ', code2: 'UZ' },
190
+ };
191
+ const CARRIER_PREFIXES = {
192
+ '62': {
193
+ '811': 'Telkomsel (Halo)', '812': 'Telkomsel (simPATI)', '813': 'Telkomsel (simPATI)',
194
+ '821': 'Telkomsel (simPATI)', '822': 'Telkomsel (simPATI)', '823': 'Telkomsel (AS)',
195
+ '851': 'Telkomsel (AS)', '852': 'Telkomsel (AS)', '853': 'Telkomsel (AS)',
196
+ '814': 'Indosat (IM3)', '815': 'Indosat (Matrix)', '816': 'Indosat (Mentari)',
197
+ '855': 'Indosat (IM3)', '856': 'Indosat (IM3)', '857': 'Indosat (IM3)', '858': 'Indosat (IM3)',
198
+ '817': 'XL Axiata', '818': 'XL Axiata', '819': 'XL Axiata',
199
+ '859': 'XL Axiata', '877': 'XL Axiata', '878': 'XL Axiata',
200
+ '831': 'Axis', '832': 'Axis', '833': 'Axis', '838': 'Axis',
201
+ '895': 'Three (3)', '896': 'Three (3)', '897': 'Three (3)', '898': 'Three (3)', '899': 'Three (3)',
202
+ '881': 'Smartfren', '882': 'Smartfren', '883': 'Smartfren', '884': 'Smartfren',
203
+ '885': 'Smartfren', '886': 'Smartfren', '887': 'Smartfren', '888': 'Smartfren', '889': 'Smartfren',
204
+ },
205
+ '91': {
206
+ '70': 'Airtel/Jio', '72': 'Airtel/Jio', '73': 'Airtel/Jio', '74': 'Airtel/Jio',
207
+ '75': 'Airtel/Jio', '76': 'Airtel/Jio', '77': 'Airtel/Jio', '78': 'Airtel/Jio',
208
+ '79': 'Airtel/Jio', '80': 'BSNL/Airtel', '81': 'BSNL/Airtel', '82': 'BSNL/Airtel',
209
+ '83': 'Vi/BSNL', '84': 'Vi/BSNL', '85': 'Vi/BSNL', '86': 'Vi/BSNL',
210
+ '87': 'Jio/Airtel', '88': 'Jio/Airtel', '89': 'Jio/Airtel', '90': 'Airtel/Vi',
211
+ '91': 'Airtel/Vi', '92': 'Airtel/Vi', '93': 'Airtel/Vi', '94': 'BSNL',
212
+ '95': 'Airtel/Vi', '96': 'Airtel/Vi', '97': 'Airtel/Vi', '98': 'Airtel/Vi', '99': 'Airtel/Vi',
213
+ },
214
+ '1': {
215
+ '200': 'AT&T/Verizon', '201': 'Verizon', '202': 'Verizon',
216
+ '212': 'Verizon/AT&T', '213': 'AT&T', '310': 'AT&T', '312': 'AT&T',
217
+ '347': 'T-Mobile', '408': 'AT&T', '415': 'AT&T', '510': 'AT&T',
218
+ '646': 'Verizon', '718': 'Verizon', '917': 'T-Mobile',
219
+ },
220
+ '44': {
221
+ '74': 'Mobile', '75': 'Mobile', '76': 'Mobile', '77': 'Mobile', '78': 'Mobile', '79': 'Mobile',
222
+ },
223
+ '55': {
224
+ '11': 'Sao Paulo', '21': 'Rio de Janeiro', '31': 'Belo Horizonte',
225
+ '41': 'Curitiba', '51': 'Porto Alegre', '61': 'Brasilia', '71': 'Salvador',
226
+ '81': 'Recife', '91': 'Belem',
227
+ },
228
+ };
229
+ function parsePhoneNumber(raw) {
230
+ let cleaned = raw.replace(/[^0-9+]/g, '');
231
+ if (!cleaned)
232
+ return null;
233
+ if (!cleaned.startsWith('+')) {
234
+ if (cleaned.startsWith('00'))
235
+ cleaned = '+' + cleaned.slice(2);
236
+ else
237
+ cleaned = '+' + cleaned;
238
+ }
239
+ const digits = cleaned.slice(1);
240
+ if (digits.length < 7 || digits.length > 15)
241
+ return null;
242
+ let countryCode = '';
243
+ let country = 'Unknown';
244
+ let flag = '??';
245
+ for (let len = 3; len >= 1; len--) {
246
+ const prefix = digits.slice(0, len);
247
+ if (COUNTRY_CODES[prefix]) {
248
+ countryCode = prefix;
249
+ country = COUNTRY_CODES[prefix].country;
250
+ flag = COUNTRY_CODES[prefix].flag;
251
+ break;
252
+ }
253
+ }
254
+ if (!countryCode) {
255
+ countryCode = digits.slice(0, 1);
256
+ country = COUNTRY_CODES[countryCode]?.country || 'Unknown';
257
+ flag = COUNTRY_CODES[countryCode]?.flag || '??';
258
+ }
259
+ const nationalNumber = digits.slice(countryCode.length);
260
+ let carrier = 'Unknown';
261
+ const carrierDb = CARRIER_PREFIXES[countryCode];
262
+ if (carrierDb) {
263
+ for (let prefixLen = 4; prefixLen >= 2; prefixLen--) {
264
+ const prefix = nationalNumber.slice(0, prefixLen);
265
+ if (carrierDb[prefix]) {
266
+ carrier = carrierDb[prefix];
267
+ break;
268
+ }
269
+ }
270
+ }
271
+ let lineType = 'Unknown';
272
+ if (countryCode === '62') {
273
+ if (nationalNumber.startsWith('8'))
274
+ lineType = 'Mobile';
275
+ else if (nationalNumber.startsWith('21') || nationalNumber.startsWith('22') || nationalNumber.startsWith('24'))
276
+ lineType = 'Landline';
277
+ else
278
+ lineType = 'Likely Mobile';
279
+ }
280
+ else if (countryCode === '1') {
281
+ lineType = 'Mobile/Landline (NANP)';
282
+ }
283
+ else if (countryCode === '44') {
284
+ if (nationalNumber.startsWith('7'))
285
+ lineType = 'Mobile';
286
+ else
287
+ lineType = 'Landline';
288
+ }
289
+ else if (['91', '55', '86', '81', '82'].includes(countryCode)) {
290
+ lineType = 'Likely Mobile';
291
+ }
292
+ return {
293
+ international: `+${digits}`,
294
+ countryCode: `+${countryCode}`,
295
+ country,
296
+ flag,
297
+ nationalNumber,
298
+ carrier,
299
+ lineType,
300
+ };
301
+ }
302
+ async function lookupPhone(target) {
303
+ const results = [];
304
+ const parsed = parsePhoneNumber(target);
305
+ if (!parsed) {
306
+ results.push('Invalid phone number format. Use international format: +628123456789 or 628123456789');
307
+ return results;
308
+ }
309
+ results.push(`=== Phone Number Analysis ===`);
310
+ results.push(`Number: ${parsed.international}`);
311
+ results.push(`Country: ${parsed.country} ${parsed.flag}`);
312
+ results.push(`Country Code: ${parsed.countryCode}`);
313
+ results.push(`National Number: ${parsed.nationalNumber}`);
314
+ results.push(`Carrier/Provider: ${parsed.carrier}`);
315
+ results.push(`Line Type: ${parsed.lineType}`);
316
+ try {
317
+ const { execSync } = await import('child_process');
318
+ const numverifyResult = execSync(`curl -s "http://apilayer.net/api/validate?access_key=free&number=${parsed.international}" 2>/dev/null`, { encoding: 'utf8', timeout: 8000 });
319
+ try {
320
+ const nv = JSON.parse(numverifyResult);
321
+ if (nv.valid) {
322
+ results.push(`\n=== NumVerify API ===`);
323
+ if (nv.carrier)
324
+ results.push(`Carrier (API): ${nv.carrier}`);
325
+ if (nv.line_type)
326
+ results.push(`Line Type (API): ${nv.line_type}`);
327
+ if (nv.location)
328
+ results.push(`Location: ${nv.location}`);
329
+ if (nv.country_name)
330
+ results.push(`Country (API): ${nv.country_name}`);
331
+ }
332
+ }
333
+ catch { }
334
+ }
335
+ catch { }
336
+ try {
337
+ const res = await fetch(`https://phonevalidation.abstractapi.com/v1/?api_key=free&phone=${parsed.international}`);
338
+ const data = await res.json();
339
+ if (data.valid) {
340
+ results.push(`\n=== Abstract API ===`);
341
+ if (data.carrier)
342
+ results.push(`Carrier: ${data.carrier}`);
343
+ if (data.line_type)
344
+ results.push(`Type: ${data.line_type}`);
345
+ if (data.location)
346
+ results.push(`Location: ${data.location}`);
347
+ }
348
+ }
349
+ catch { }
350
+ const formats = [
351
+ parsed.international,
352
+ `+${parsed.countryCode} ${parsed.nationalNumber.slice(0, 4)}-${parsed.nationalNumber.slice(4, 8)}-${parsed.nationalNumber.slice(8)}`,
353
+ parsed.nationalNumber,
354
+ ].filter(f => f && f.length > 3);
355
+ results.push(`\n=== Search Variants ===`);
356
+ results.push(`Use these to search: ${formats.join(' | ')}`);
357
+ results.push(`\nTip: Use the browser tool to search this number on Google, Truecaller, or social media for more information.`);
358
+ return results;
359
+ }
360
+ async function lookupDomain(target) {
361
+ const results = [];
362
+ const { execSync } = await import('child_process');
363
+ results.push(`=== Domain Analysis: ${target} ===\n`);
364
+ try {
365
+ const whois = execSync(`whois ${target} 2>/dev/null | head -40`, { encoding: 'utf8', timeout: 10000 });
366
+ results.push(`WHOIS:\n${whois}`);
367
+ }
368
+ catch {
369
+ results.push('WHOIS: not available');
370
+ }
371
+ try {
372
+ const dns = execSync(`dig ${target} +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
373
+ results.push(`DNS Records:\n${dns}`);
374
+ }
375
+ catch {
376
+ results.push('DNS: not available');
377
+ }
378
+ try {
379
+ const ns = execSync(`dig ${target} NS +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
380
+ results.push(`Nameservers:\n${ns}`);
381
+ }
382
+ catch { }
383
+ try {
384
+ const mx = execSync(`dig ${target} MX +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
385
+ results.push(`Mail Servers:\n${mx}`);
386
+ }
387
+ catch { }
388
+ try {
389
+ const txt = execSync(`dig ${target} TXT +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
390
+ if (txt.trim())
391
+ results.push(`TXT Records:\n${txt}`);
392
+ }
393
+ catch { }
394
+ return results;
395
+ }
396
+ async function lookupEmail(target) {
397
+ const results = [];
398
+ if (!target.includes('@')) {
399
+ results.push('Invalid email format.');
400
+ return results;
401
+ }
402
+ const [user, domain] = target.split('@');
403
+ results.push(`=== Email Analysis: ${target} ===\n`);
404
+ results.push(`User: ${user}`);
405
+ results.push(`Domain: ${domain}`);
406
+ results.push(`Format valid: yes`);
407
+ try {
408
+ const { execSync } = await import('child_process');
409
+ const mx = execSync(`dig ${domain} MX +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
410
+ results.push(`\nMail Servers:\n${mx}`);
411
+ if (mx.includes('google') || mx.includes('gmail')) {
412
+ results.push('Provider: Google Workspace / Gmail');
413
+ }
414
+ else if (mx.includes('outlook') || mx.includes('microsoft')) {
415
+ results.push('Provider: Microsoft 365 / Outlook');
416
+ }
417
+ else if (mx.includes('yahoo')) {
418
+ results.push('Provider: Yahoo Mail');
419
+ }
420
+ else if (mx.includes('protonmail') || mx.includes('proton')) {
421
+ results.push('Provider: ProtonMail (encrypted)');
422
+ }
423
+ else if (mx.includes('zoho')) {
424
+ results.push('Provider: Zoho Mail');
425
+ }
426
+ else {
427
+ results.push('Provider: Custom/Self-hosted');
428
+ }
429
+ }
430
+ catch { }
431
+ try {
432
+ const { execSync } = await import('child_process');
433
+ const spf = execSync(`dig ${domain} TXT +short 2>/dev/null | grep -i spf`, { encoding: 'utf8', timeout: 10000 });
434
+ if (spf.trim())
435
+ results.push(`SPF: ${spf.trim()}`);
436
+ }
437
+ catch { }
438
+ results.push(`\nTip: Use the browser tool to search this email on haveibeenpwned.com, Hunter.io, or social media for breach history and public profiles.`);
439
+ return results;
440
+ }
441
+ async function lookupIP(target) {
442
+ const results = [];
443
+ results.push(`=== IP Analysis: ${target} ===\n`);
444
+ try {
445
+ const res = await fetch(`http://ip-api.com/json/${target}?fields=status,message,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,query`);
446
+ const data = await res.json();
447
+ if (data.status === 'success') {
448
+ results.push(`Country: ${data.country} (${data.countryCode})`);
449
+ results.push(`Region: ${data.regionName}`);
450
+ results.push(`City: ${data.city}`);
451
+ results.push(`ZIP: ${data.zip}`);
452
+ results.push(`Coordinates: ${data.lat}, ${data.lon}`);
453
+ results.push(`Timezone: ${data.timezone}`);
454
+ results.push(`ISP: ${data.isp}`);
455
+ results.push(`Organization: ${data.org}`);
456
+ results.push(`AS: ${data.as}`);
457
+ }
458
+ else {
459
+ results.push(`Lookup failed: ${data.message || 'unknown error'}`);
460
+ }
461
+ }
462
+ catch {
463
+ results.push('IP-API lookup failed');
464
+ }
465
+ try {
466
+ const { execSync } = await import('child_process');
467
+ const reverse = execSync(`dig -x ${target} +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
468
+ if (reverse.trim())
469
+ results.push(`Reverse DNS: ${reverse.trim()}`);
470
+ }
471
+ catch { }
472
+ try {
473
+ const { execSync } = await import('child_process');
474
+ const nmap = execSync(`nmap -sV --top-ports 10 ${target} 2>/dev/null | head -20`, { encoding: 'utf8', timeout: 15000 });
475
+ if (nmap.trim())
476
+ results.push(`\nPort Scan (top 10):\n${nmap}`);
477
+ }
478
+ catch { }
479
+ return results;
480
+ }
481
+ async function lookupUsername(target) {
482
+ const results = [];
483
+ results.push(`=== Username Analysis: ${target} ===\n`);
484
+ const platforms = [
485
+ { name: 'GitHub', url: `https://github.com/${target}` },
486
+ { name: 'Twitter/X', url: `https://x.com/${target}` },
487
+ { name: 'Instagram', url: `https://instagram.com/${target}` },
488
+ { name: 'Reddit', url: `https://reddit.com/user/${target}` },
489
+ { name: 'YouTube', url: `https://youtube.com/@${target}` },
490
+ { name: 'TikTok', url: `https://tiktok.com/@${target}` },
491
+ { name: 'Facebook', url: `https://facebook.com/${target}` },
492
+ { name: 'Steam', url: `https://steamcommunity.com/id/${target}` },
493
+ { name: 'Twitch', url: `https://twitch.tv/${target}` },
494
+ { name: 'Pinterest', url: `https://pinterest.com/${target}` },
495
+ ];
496
+ results.push('Checking username availability across platforms...\n');
497
+ for (const p of platforms) {
498
+ try {
499
+ const res = await fetch(p.url, { method: 'HEAD', redirect: 'manual' });
500
+ const status = res.status;
501
+ const exists = status === 200;
502
+ results.push(`${p.name}: ${exists ? 'EXISTS' : 'not found'} (${p.url})`);
503
+ }
504
+ catch {
505
+ results.push(`${p.name}: timeout`);
506
+ }
507
+ }
508
+ results.push(`\nTip: Use the browser tool to visit any "EXISTS" links for detailed profile analysis.`);
509
+ return results;
510
+ }
1
511
  export const osintTool = {
2
512
  name: 'osint_investigate',
3
- description: 'Perform OSINT investigation on a target (domain, email, username, IP).',
513
+ description: `Perform OSINT investigation on a target. Supports: phone numbers (carrier, country, line type lookup), domains (WHOIS, DNS, nameservers, mail servers), emails (provider detection, MX records, breach hints), IP addresses (geolocation, ISP, port scan), and usernames (cross-platform presence check). Use type "all" for comprehensive analysis or specify: phone, domain, email, ip, username.`,
4
514
  parameters: {
5
515
  type: 'object',
6
516
  properties: {
7
- target: { type: 'string', description: 'Target: domain, email, username, or IP' },
8
- type: { type: 'string', description: 'domain, email, username, ip, or all' },
517
+ target: { type: 'string', description: 'Target: phone number (+62812...), domain (example.com), email (user@domain.com), IP (1.2.3.4), or username' },
518
+ type: { type: 'string', description: 'phone, domain, email, ip, username, or all (auto-detected if omitted)' },
9
519
  },
10
520
  required: ['target'],
11
521
  },
12
522
  async execute(args) {
13
- const target = args.target;
14
- const type = args.type || 'all';
15
- const results = [`OSINT Investigation: ${target}\nType: ${type}\n`];
16
- if (type === 'domain' || type === 'all') {
17
- if (/^[a-z0-9.-]+\.[a-z]{2,}$/i.test(target)) {
18
- try {
19
- const { execSync } = await import('child_process');
20
- const whois = execSync(`whois ${target} 2>/dev/null | head -30`, { encoding: 'utf8', timeout: 10000 });
21
- results.push(`WHOIS:\n${whois}`);
22
- }
23
- catch {
24
- results.push('WHOIS: not available');
25
- }
26
- try {
27
- const { execSync } = await import('child_process');
28
- const dns = execSync(`dig ${target} +short 2>/dev/null`, { encoding: 'utf8', timeout: 10000 });
29
- results.push(`DNS:\n${dns}`);
30
- }
31
- catch {
32
- results.push('DNS: not available');
33
- }
34
- }
523
+ const target = args.target.trim();
524
+ let type = (args.type || 'auto').toLowerCase();
525
+ if (type === 'auto' || type === 'all') {
526
+ if (/^\+?[\d\s\-()]{7,15}$/.test(target))
527
+ type = 'phone';
528
+ else if (target.includes('@'))
529
+ type = 'email';
530
+ else if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(target))
531
+ type = 'ip';
532
+ else if (/^[a-z0-9._-]+\.[a-z]{2,}$/i.test(target))
533
+ type = 'domain';
534
+ else
535
+ type = 'username';
35
536
  }
36
- if (type === 'email' || type === 'all') {
37
- if (target.includes('@')) {
38
- const [user, domain] = target.split('@');
39
- results.push(`Email: ${user}@${domain}\nDomain: ${domain}\nFormat valid: yes`);
537
+ const results = [`OSINT Investigation\nTarget: ${target}\nType: ${type}\n${'='.repeat(40)}\n`];
538
+ switch (type) {
539
+ case 'phone': {
540
+ const r = await lookupPhone(target);
541
+ results.push(...r);
542
+ break;
40
543
  }
41
- }
42
- if (type === 'ip' || type === 'all') {
43
- if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(target)) {
44
- try {
45
- const res = await fetch(`http://ip-api.com/json/${target}`);
46
- const data = await res.json();
47
- results.push(`IP Info:\n Country: ${data.country}\n City: ${data.city}\n ISP: ${data.isp}\n Org: ${data.org}`);
48
- }
49
- catch {
50
- results.push('IP lookup: not available');
51
- }
544
+ case 'domain': {
545
+ const r = await lookupDomain(target);
546
+ results.push(...r);
547
+ break;
548
+ }
549
+ case 'email': {
550
+ const r = await lookupEmail(target);
551
+ results.push(...r);
552
+ break;
553
+ }
554
+ case 'ip': {
555
+ const r = await lookupIP(target);
556
+ results.push(...r);
557
+ break;
558
+ }
559
+ case 'username': {
560
+ const r = await lookupUsername(target);
561
+ results.push(...r);
562
+ break;
52
563
  }
564
+ default:
565
+ results.push(`Unknown type: ${type}. Use: phone, domain, email, ip, username, or all`);
53
566
  }
54
- return results.join('\n\n') || 'No results found.';
567
+ return results.join('\n');
55
568
  },
56
569
  };
57
570
  //# sourceMappingURL=Osint.js.map