nolimit-x 1.0.19 → 1.0.21

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nolimit-x",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Advanced email sender ",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  "puppeteer": "^23.0.0",
20
20
  "qrcode": "^1.5.3",
21
21
  "p-map": "^5.0.0",
22
- "ora": "^6.1.2"
22
+ "ora": "^6.1.2",
23
+ "node-fetch": "^2.6.7"
23
24
  }
24
25
  }
@@ -97,15 +97,20 @@ const dynamicPlaceholders = [
97
97
  {
98
98
  pattern: /\[\[-\s*FAVICON(?:\|([^\]]+))?\s*-\]\]/g,
99
99
  handler: async (match, customUrl, email) => {
100
- // If custom URL is provided, use it
101
100
  if (customUrl) {
102
101
  return customUrl.trim();
103
102
  }
104
- // Otherwise fetch favicon for the domain as base64
103
+ if (!email) {
104
+ console.error('FAVICON placeholder: No email provided!');
105
+ // Return a default favicon
106
+ return 'https://www.google.com/s2/favicons?sz=32&domain_url=default.com';
107
+ }
105
108
  const domain = utils.getDomainFromEmail(email);
109
+ const faviconUrl = await utils.fetchFavicon(domain);
106
110
  const dataUri = await utils.fetchFaviconBase64(domain);
107
- console.log('FAVICON placeholder:', { email, domain, dataUriLength: dataUri.length, dataUri: dataUri.slice(0, 60) });
108
- return dataUri;
111
+ console.log('FAVICON placeholder:', { email, domain, faviconUrl, dataUriLength: dataUri.length });
112
+ // Fallback: if dataUri is empty, use the external favicon URL
113
+ return dataUri || faviconUrl || 'https://www.google.com/s2/favicons?sz=32&domain_url=default.com';
109
114
  }
110
115
  },
111
116
 
package/src/utils.js CHANGED
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const natural = require('natural');
4
4
  const { Buffer } = require('buffer');
5
5
  const https = require('https');
6
+ const fetch = require('node-fetch');
6
7
 
7
8
  // Date and Time Functions
8
9
  function formatDate(date, format) {
@@ -346,22 +347,24 @@ async function batchFetchFavicons(domains) {
346
347
  // Initialize cache on module load
347
348
  loadFaviconCache();
348
349
 
349
- // Fetch favicon as base64 data URI
350
+ // Fetch favicon as base64 data URI using node-fetch
350
351
  async function fetchFaviconBase64(domain) {
351
352
  const faviconUrl = await fetchFavicon(domain);
352
353
  if (!faviconUrl) return '';
353
- return new Promise((resolve) => {
354
- https.get(faviconUrl, (res) => {
355
- const data = [];
356
- res.on('data', chunk => data.push(chunk));
357
- res.on('end', () => {
358
- const buffer = Buffer.concat(data);
359
- const base64 = buffer.toString('base64');
360
- const mime = res.headers['content-type'] || 'image/png';
361
- resolve(`data:${mime};base64,${base64}`);
362
- });
363
- }).on('error', () => resolve(''));
364
- });
354
+ try {
355
+ const res = await fetch(faviconUrl, { timeout: 5000 });
356
+ if (!res.ok) {
357
+ console.error(`Failed to fetch favicon for ${domain}: HTTP ${res.status}`);
358
+ return '';
359
+ }
360
+ const buffer = await res.buffer();
361
+ const base64 = buffer.toString('base64');
362
+ const mime = res.headers.get('content-type') || 'image/png';
363
+ return `data:${mime};base64,${base64}`;
364
+ } catch (err) {
365
+ console.error(`Error fetching favicon for ${domain}:`, err.message);
366
+ return '';
367
+ }
365
368
  }
366
369
 
367
370
  // Export all functions