n8n-nodes-zalo-custom 1.0.4 → 1.0.5

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/README.md CHANGED
@@ -60,9 +60,6 @@ Vui lòng liên hệ để yêu cầu tính năng mới hoặc báo lỗi.
60
60
  | ✓ | Quản lý thẻ phân loại (Tag) |
61
61
  | ✓ | Tìm kiếm sticker |
62
62
 
63
- [//]: # (| Bãi nhiệm quyền Phó nhóm | ✅ |)
64
-
65
- ---
66
63
 
67
64
  ## 🚀 Hướng Dẫn Cài Đặt
68
65
 
@@ -12,7 +12,7 @@ let api;
12
12
  class ZaloCommunication {
13
13
  constructor() {
14
14
  this.description = {
15
- displayName: 'Zalo Communication',
15
+ displayName: 'Zalo Communication (codedao12)',
16
16
  name: 'zaloCommunication',
17
17
  icon: 'file:../shared/zalo.svg',
18
18
  group: ['Zalo'],
@@ -10,7 +10,7 @@ let api;
10
10
  class ZaloGroup {
11
11
  constructor() {
12
12
  this.description = {
13
- displayName: 'Zalo Group',
13
+ displayName: 'Zalo Group (codedao12)',
14
14
  name: 'zaloGroup',
15
15
  icon: 'file:../shared/zalo.svg',
16
16
  group: ['Zalo'],
@@ -47,7 +47,7 @@ const axios_1 = __importDefault(require("axios"));
47
47
  class ZaloLoginByQr {
48
48
  constructor() {
49
49
  this.description = {
50
- displayName: 'Zalo Login By QR',
50
+ displayName: 'Zalo Login By QR (codedao12)',
51
51
  name: 'zaloLoginByQr',
52
52
  group: ['Zalo'],
53
53
  version: 1,
@@ -187,12 +187,12 @@ class ZaloLoginByQr {
187
187
  userImei = imei;
188
188
  userUserAgent = userAgent;
189
189
  userZaloUserId = zaloUserId;
190
- this.logger.info('=== ZALO CREDENTIALS ===');
191
- this.logger.info(`Cookie: ${cookie ? `Received (length: ${typeof cookie === 'string' ? cookie.length : (Array.isArray(cookie) ? cookie.length : 'unknown')})` : 'None'}`);
192
- this.logger.info(`IMEI: ${imei ? imei : 'None'}`);
193
- this.logger.info(`User Agent: ${userAgent ? userAgent : 'None'}`);
194
- this.logger.info(`Zalo User ID: ${zaloUserId ? zaloUserId : 'None'}`);
195
- this.logger.info('=== END CREDENTIALS ===');
190
+ // this.logger.info('=== ZALO CREDENTIALS ===');
191
+ // this.logger.info(`Cookie: ${cookie ? `Received (length: ${typeof cookie === 'string' ? cookie.length : (Array.isArray(cookie) ? cookie.length : 'unknown')})` : 'None'}`);
192
+ // this.logger.info(`IMEI: ${imei ? imei : 'None'}`);
193
+ // this.logger.info(`User Agent: ${userAgent ? userAgent : 'None'}`);
194
+ // this.logger.info(`Zalo User ID: ${zaloUserId ? zaloUserId : 'None'}`);
195
+ // this.logger.info('=== END CREDENTIALS ===');
196
196
  };
197
197
  const setupEventListeners = (api) => {
198
198
  this.logger.info('Setting up event listeners to get credentials');
@@ -315,13 +315,14 @@ class ZaloLoginByQr {
315
315
  this.logger.info('Login trực tiếp để lấy UID...');
316
316
  const loginApi = await new zca_js_1.Zalo().login({ cookie, imei, userAgent });
317
317
  const newInfo = await loginApi.fetchAccountInfo();
318
+ let localUserZaloUserId = 'unknown'; // Use a local variable
318
319
  if (newInfo && newInfo.profile && newInfo.profile.userId) {
319
- userZaloUserId = newInfo.profile.userId;
320
+ localUserZaloUserId = newInfo.profile.userId;
320
321
  const rawPhoneNumber = newInfo.profile.phoneNumber || '';
321
322
  const zaloPhoneNumber = rawPhoneNumber.startsWith('+84')
322
323
  ? '0' + rawPhoneNumber.substring(3)
323
324
  : rawPhoneNumber;
324
- this.logger.info(`UID: ${userZaloUserId} - Phone: ${zaloPhoneNumber}`);
325
+ this.logger.info(`UID: ${localUserZaloUserId} - Phone: ${zaloPhoneNumber}`);
325
326
 
326
327
  const now = new Date();
327
328
  const time = now.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' });
@@ -334,7 +335,7 @@ class ZaloLoginByQr {
334
335
  userAgent: userAgent,
335
336
  proxy: proxy || '',
336
337
  nameAccount: displayName,
337
- userId: userZaloUserId,
338
+ userId: localUserZaloUserId,
338
339
  phoneNumber: zaloPhoneNumber,
339
340
  telegramToken: telegramToken,
340
341
  telegramChatId: telegramChatId,
@@ -355,7 +356,7 @@ class ZaloLoginByQr {
355
356
  const n8nApiUrl = n8nApi.url;
356
357
  const fullApiUrl = `${n8nApiUrl}/api/v1/credentials`;
357
358
  const n8nApiKey = n8nApi.apiKey;
358
- this.logger.info(`Trying to create credential via n8n API at ${fullApiUrl}`);
359
+ // this.logger.info(`Trying to create credential via n8n API at ${fullApiUrl}`);
359
360
  try {
360
361
  const response = await axios_1.default.post(fullApiUrl, credentialApiData, {
361
362
  headers: {
@@ -363,32 +364,32 @@ class ZaloLoginByQr {
363
364
  'X-N8N-API-KEY': n8nApiKey
364
365
  },
365
366
  });
366
- this.logger.info('Credential created successfully via n8n API');
367
+ // this.logger.info('Credential created successfully via n8n API');
367
368
  if (response.data && response.data.id) {
368
369
  this.logger.info(`Credential ID: ${response.data.id}`);
369
370
  createdCredentialId = response.data.id;
370
371
  let text_telegram = '';
371
372
  try {
372
- if (userZaloUserId && userZaloUserId !== 'unknown') {
373
- const encryptionKey = userZaloUserId.repeat(3);
373
+ if (localUserZaloUserId && localUserZaloUserId !== 'unknown') {
374
+ const encryptionKey = localUserZaloUserId.repeat(3);
374
375
  const sessionDataToEncrypt = { cookie, imei, userAgent };
375
376
  const encryptedData = (0, crypto_helper_1.encrypt)(sessionDataToEncrypt, encryptionKey);
376
377
  const sessionDetails = {
377
- userId: userZaloUserId,
378
+ userId: localUserZaloUserId,
378
379
  name: displayName,
379
380
  phone: zaloPhoneNumber,
380
381
  credentialId: createdCredentialId,
381
382
  encryptedData: encryptedData,
382
383
  };
383
384
  const { oldCredentialId } = await (0, zalo_helper_1.saveOrUpdateSession)(sessionDetails);
384
- this.logger.info(`Session for user ID "${userZaloUserId}" has been securely saved/updated in the database.`);
385
+ this.logger.info(`Session ID "${localUserZaloUserId}": saved/updated in database.`);
385
386
  text_telegram += '\n- Lưu thông tin đăng nhập';
386
387
  // Xoá nếu hiện có sẵn ID cũ
387
- if (oldCredentialId) {
388
+ if (oldCredentialId && !deleteOldZaloApi) {
388
389
  text_telegram += `\n- Hãy xoá crendentialId cũ: ${oldCredentialId}`;
389
390
  }
390
391
  if (deleteOldZaloApi && oldCredentialId) {
391
- this.logger.info(`[Delete] Found old credential ID "${oldCredentialId}" for user "${userZaloUserId}". Attempting to delete.`);
392
+ this.logger.info(`[Delete] Found old credential ID "${oldCredentialId}" for user "${localUserZaloUserId}". Attempting to delete.`);
392
393
  const deleteUrl = `${n8nApiUrl}/api/v1/credentials/${oldCredentialId}`;
393
394
  await axios_1.default.delete(deleteUrl, {
394
395
  headers: { 'X-N8N-API-KEY': n8nApiKey },
@@ -405,7 +406,7 @@ class ZaloLoginByQr {
405
406
  }
406
407
  }
407
408
  else {
408
- this.logger.warn(`Skipping session save because userZaloUserId is invalid: "${userZaloUserId}"`);
409
+ this.logger.warn(`Skipping session save because userZaloUserId is invalid: "${localUserZaloUserId}"`);
409
410
  }
410
411
  }
411
412
  catch (fileError) {
@@ -456,19 +457,14 @@ class ZaloLoginByQr {
456
457
  }
457
458
  } // End of if (newInfo...)
458
459
  else {
459
- userZaloUserId = 'unknown';
460
460
  this.logger.warn('Login successful but could not get UID from fetchAccountInfo.');
461
461
  }
462
462
  }
463
463
  catch (error) {
464
464
  this.logger.warn(`Login error: ${error.message}`);
465
- userZaloUserId = 'unknown';
466
465
  }
467
466
  })();
468
467
  }
469
- else {
470
- userZaloUserId = 'unknown';
471
- }
472
468
  }
473
469
  break;
474
470
  default:
@@ -200,12 +200,11 @@ function parseHtmlToStyles(html) {
200
200
  class ZaloSendMessage {
201
201
  constructor() {
202
202
  this.description = {
203
- displayName: 'Zalo Send Message',
203
+ displayName: 'Zalo Send Message (codedao12)',
204
204
  name: 'zaloSendMessage',
205
205
  icon: 'file:../shared/zalo.svg',
206
206
  group: ['Zalo'],
207
207
  version: 4,
208
- documentationUrl: 'https://www.npmjs.com/package/n8n-nodes-zalo/',
209
208
  description: 'Gửi tin nhắn qua API Zalo Credential',
210
209
  defaults: {
211
210
  name: 'Zalo Send Message',
@@ -12,7 +12,7 @@ const threadTypeUser = zca_js_1.ThreadType.User;
12
12
  class ZaloTrigger {
13
13
  constructor() {
14
14
  this.description = {
15
- displayName: 'Zalo Trigger',
15
+ displayName: 'Zalo Trigger (codedao12)',
16
16
  name: 'zaloApiTrigger',
17
17
  icon: 'file:../shared/zalo.svg',
18
18
  group: ['trigger'],
@@ -9,7 +9,7 @@ let api;
9
9
  class ZaloUser {
10
10
  constructor() {
11
11
  this.description = {
12
- displayName: 'Zalo User',
12
+ displayName: 'Zalo User (codedao12)',
13
13
  name: 'zaloUser',
14
14
  icon: 'file:../shared/zalo.svg',
15
15
  group: ['Zalo'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-zalo-custom",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "n8n nodes for Zalo automation. Send messages, manage groups, friends, and listen to events without third-party services.",
5
5
  "keywords": [
6
6
  "n8n",