zalo-toolkit 1.1.3 → 1.1.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.
@@ -1,5 +1,5 @@
1
- import { AttachmentType } from "../core/enums/common.js";
2
- import { ThreadType } from "../models/Enum.js";
1
+ import { AttachmentType } from '../core/enums/common.js';
2
+ import { ThreadType } from '../models/Enum.js';
3
3
  export type FileAttachmentOptions = {
4
4
  msg?: string;
5
5
  url: string;
@@ -13,4 +13,4 @@ export type ForwardAttachmentOptions<T extends AttachmentType> = T extends Attac
13
13
  export type ForwardAttachmentResponse = {
14
14
  msgId: number;
15
15
  };
16
- export declare const forwardAttachmentFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => <T extends AttachmentType>(options: ForwardAttachmentOptions<T>, threadId: string, type: ThreadType | undefined, messageType: T) => Promise<ForwardAttachmentResponse>;
16
+ export declare const forwardAttachmentFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => <T extends AttachmentType>(options: ForwardAttachmentOptions<T>, threadId: string, type: ThreadType | undefined, messageType: T, msgInfo?: any) => Promise<ForwardAttachmentResponse>;
@@ -1,25 +1,19 @@
1
- import { AttachmentType } from "../core/enums/common.js";
2
- import { getFileUpload } from "../core/utils/index.js";
3
- import { ZaloApiError } from "../Errors/ZaloApiError.js";
4
- import { ThreadType } from "../models/Enum.js";
5
- import { apiFactory, getMd5LargeFileObject } from "../utils.js";
1
+ import { AttachmentType } from '../core/enums/common.js';
2
+ import { getFileUpload } from '../core/utils/index.js';
3
+ import { ZaloApiError } from '../Errors/ZaloApiError.js';
4
+ import { ThreadType } from '../models/Enum.js';
5
+ import { apiFactory, getMd5LargeFileObject } from '../utils.js';
6
6
  export const forwardAttachmentFactory = apiFactory()((api, ctx, utils) => {
7
7
  const serviceURL = {
8
8
  [ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
9
9
  [ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
10
10
  };
11
- return async function forwardAttachment(options, threadId, type = ThreadType.User, messageType) {
11
+ return async function forwardAttachment(options, threadId, type = ThreadType.User, messageType, msgInfo) {
12
12
  var _a;
13
13
  const timestamp = Date.now();
14
14
  const fileAttachment = await getFileUpload(options.url);
15
15
  const checksum = await getMd5LargeFileObject(fileAttachment);
16
- let params = {
17
- clientId: String(timestamp),
18
- ttl: 0,
19
- zsource: 703,
20
- imei: ctx.imei,
21
- msgInfo: {
22
- reference: JSON.stringify({
16
+ let params = Object.assign(Object.assign({ clientId: String(timestamp), ttl: 0, zsource: 703, imei: ctx.imei, msgInfo: Object.assign(Object.assign({}, msgInfo), { reference: JSON.stringify({
23
17
  type: 3,
24
18
  data: JSON.stringify({
25
19
  ts: timestamp,
@@ -30,9 +24,13 @@ export const forwardAttachmentFactory = apiFactory()((api, ctx, utils) => {
30
24
  logSrcType: 1,
31
25
  },
32
26
  }),
33
- }),
34
- },
35
- decorLog: JSON.stringify({
27
+ }) }) }, ((msgInfo === null || msgInfo === void 0 ? void 0 : msgInfo.groupLayoutId) && {
28
+ extMsgProp: JSON.stringify({
29
+ groupMediaMsg: {
30
+ groupLayoutId: msgInfo.groupLayoutId,
31
+ },
32
+ }),
33
+ })), { decorLog: JSON.stringify({
36
34
  fw: {
37
35
  pmsg: {
38
36
  st: 1,
@@ -44,13 +42,11 @@ export const forwardAttachmentFactory = apiFactory()((api, ctx, utils) => {
44
42
  },
45
43
  fwLvl: 1,
46
44
  },
47
- }),
48
- };
45
+ }) });
49
46
  switch (messageType) {
50
47
  case AttachmentType.IMAGE:
51
48
  const imageOptions = options;
52
- const fileImage = await getFileUpload(imageOptions.url);
53
- params = Object.assign(Object.assign({}, params), { msgType: 2, msgInfo: Object.assign(Object.assign({}, params.msgInfo), { title: '', oriUrl: imageOptions.url, url: imageOptions.url, thumbUrl: imageOptions.url, width: 720, height: 1280, properties: null, hdSize: fileImage.size, normalUrl: '' }), jcp: {
49
+ params = Object.assign(Object.assign({}, params), { msgType: 2, msgInfo: Object.assign(Object.assign({}, params.msgInfo), { title: '', oriUrl: imageOptions.url, url: imageOptions.url, thumbUrl: imageOptions.url, normalUrl: '' }), jcp: {
54
50
  convertible: 'jxl',
55
51
  } });
56
52
  break;
@@ -1,4 +1,6 @@
1
1
  import { EventEmitter } from 'stream';
2
+ import WebSocket from 'ws';
3
+ import type { ZaloAPI } from '../apis.js';
2
4
  import { type DeliveredMessage } from '../models/DeliveredMessage.js';
3
5
  import { type FriendEvent } from '../models/FriendEvent.js';
4
6
  import { type GroupEvent } from '../models/GroupEvent.js';
@@ -9,8 +11,7 @@ import { Reaction } from '../models/Reaction.js';
9
11
  import { type SeenMessage } from '../models/SeenMessage.js';
10
12
  import { type Typing } from '../models/Typing.js';
11
13
  import { Undo } from '../models/Undo.js';
12
- import type { ZaloAPI } from '../apis.js';
13
- import WebSocket from 'ws';
14
+ import { type HiddenConversationEvent } from '../models/ConversationEvent.js';
14
15
  type MessageEventData = Message | GroupMessage;
15
16
  type UploadEventData = {
16
17
  fileUrl: string;
@@ -31,6 +32,7 @@ export type OnUndoMessageCallback = (undos: Undo[]) => void | Promise<void>;
31
32
  export type OnUpdateQueueStatus = (queueStatus: TypeQueueStatus, timestamp: number) => void | Promise<void>;
32
33
  export type OnLabelEventCallback = () => void | Promise<void>;
33
34
  export type OnFriendEventCallback = (friendEvents: FriendEvent[]) => void | Promise<void>;
35
+ export type OnHiddenConversationCallback = (hiddenEvents: HiddenConversationEvent[]) => void | Promise<void>;
34
36
  type SocketEventMap = {
35
37
  [key in keyof typeof SocketEvent]: any[];
36
38
  };
@@ -68,6 +70,7 @@ export declare class Listener extends EventEmitter<ListenerEvents> {
68
70
  private onUpdateQueueStatusCallback;
69
71
  private onLabelEventCallback;
70
72
  private onFriendEventCallback;
73
+ private onHiddenConversationCallback;
71
74
  private cipherKey?;
72
75
  private selfListen;
73
76
  private pingInterval?;
@@ -105,6 +108,7 @@ export declare class Listener extends EventEmitter<ListenerEvents> {
105
108
  onUpdateQueueStatus(cb: OnUpdateQueueStatus): void;
106
109
  onLabelEvent(cb: OnLabelEventCallback): void;
107
110
  onFriendEvent(cb: OnFriendEventCallback): void;
111
+ onHiddenConversation(cb: OnHiddenConversationCallback): void;
108
112
  start(): void;
109
113
  stop(): void;
110
114
  getSocketUrl(shouldRotate?: boolean, forceFirstEndpoint?: boolean): string;
@@ -1,4 +1,7 @@
1
+ import { last } from 'lodash';
1
2
  import { EventEmitter } from 'stream';
3
+ import WebSocket from 'ws';
4
+ import { ZaloApiError } from '../Errors/ZaloApiError.js';
2
5
  import { GroupDeliveredMessage, UserDeliveredMessage } from '../models/DeliveredMessage.js';
3
6
  import { initializeFriendEvent } from '../models/FriendEvent.js';
4
7
  import { initializeGroupEvent } from '../models/GroupEvent.js';
@@ -8,11 +11,9 @@ import { Reaction } from '../models/Reaction.js';
8
11
  import { GroupSeenMessage, UserSeenMessage } from '../models/SeenMessage.js';
9
12
  import { GroupTyping, UserTyping } from '../models/Typing.js';
10
13
  import { Undo } from '../models/Undo.js';
11
- import { decodeEventData, FibonacciRetry, getFriendEventType, getGroupEventType, hasOwn, logger, looksLikeJson, makeURL, safeJsonParse } from '../utils.js';
12
14
  import { ConfigSocket } from '../socket/config-socket.js';
13
- import { ZaloApiError } from '../Errors/ZaloApiError.js';
14
- import WebSocket from 'ws';
15
- import { last } from 'lodash';
15
+ import { decodeEventData, FibonacciRetry, getFriendEventType, getGroupEventType, hasOwn, logger, looksLikeJson, makeURL, safeJsonParse } from '../utils.js';
16
+ import { initializeHiddenConversationEvent } from '../models/ConversationEvent.js';
16
17
  export class Listener extends EventEmitter {
17
18
  constructor(api) {
18
19
  super();
@@ -79,6 +80,7 @@ export class Listener extends EventEmitter {
79
80
  this.onUpdateQueueStatusCallback = () => { };
80
81
  this.onLabelEventCallback = () => { };
81
82
  this.onFriendEventCallback = () => { };
83
+ this.onHiddenConversationCallback = () => { };
82
84
  }
83
85
  onConnected(cb) {
84
86
  this.onConnectedCallback = cb;
@@ -116,6 +118,9 @@ export class Listener extends EventEmitter {
116
118
  onFriendEvent(cb) {
117
119
  this.onFriendEventCallback = cb;
118
120
  }
121
+ onHiddenConversation(cb) {
122
+ this.onHiddenConversationCallback = cb;
123
+ }
119
124
  start() {
120
125
  if (this.ws)
121
126
  throw new ZaloApiError('Already started');
@@ -182,7 +187,7 @@ export class Listener extends EventEmitter {
182
187
  this.ping();
183
188
  }, 3 * 60 * 1000);
184
189
  }
185
- if (version == 1 && cmd == 501 && subCmd == 0) {
190
+ if (version == 1 && cmd == 501) {
186
191
  const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
187
192
  const { msgs, queueStatus } = parsedData;
188
193
  const listUndo = [];
@@ -209,7 +214,7 @@ export class Listener extends EventEmitter {
209
214
  this.onMessageCallback(listMessages);
210
215
  this.onUpdateQueueStatusCallback(queueStatus, timestamp);
211
216
  }
212
- if (version == 1 && cmd == 521 && subCmd == 0) {
217
+ if (version == 1 && cmd == 521) {
213
218
  const parsedData = (await decodeEventData(parsed, this.cipherKey)).data;
214
219
  const { groupMsgs, queueStatus } = parsedData;
215
220
  const listUndo = [];
@@ -246,6 +251,7 @@ export class Listener extends EventEmitter {
246
251
  const listGroupEvents = [];
247
252
  const listMuteEvents = [];
248
253
  const listFriendEvents = [];
254
+ const listHiddenEvents = [];
249
255
  let hasLabelEvent = false;
250
256
  for (const control of controls) {
251
257
  if (control.content.act_type == 'file_done') {
@@ -300,10 +306,16 @@ export class Listener extends EventEmitter {
300
306
  else if (control.content.act_type == 'label_convers') {
301
307
  hasLabelEvent = true;
302
308
  }
309
+ else if (control.content.act_type == 'hidden_chat') {
310
+ const hiddenEventData = typeof control.content.data === 'string' && looksLikeJson(control.content.data) ? safeJsonParse(control.content.data) : control.content.data;
311
+ const hiddenEvent = initializeHiddenConversationEvent(this.ctx.uid, hiddenEventData);
312
+ listHiddenEvents.push(hiddenEvent);
313
+ }
303
314
  }
304
315
  this.onGroupEventCallback(listGroupEvents);
305
316
  this.onMuteCallback(listMuteEvents);
306
317
  this.onFriendEventCallback(listFriendEvents);
318
+ this.onHiddenConversationCallback(listHiddenEvents);
307
319
  if (hasLabelEvent) {
308
320
  this.onLabelEventCallback();
309
321
  }
@@ -0,0 +1,10 @@
1
+ export type PullMobileMsgParams = {
2
+ pc_name: string;
3
+ public_key: string;
4
+ from_seq_id: string;
5
+ min_seq_id: string;
6
+ is_retry: number;
7
+ temp_key?: string;
8
+ };
9
+ export type PullMobileMsgResponse = {};
10
+ export declare const pullMobileMsgFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").ZaloAPI) => (payload: PullMobileMsgParams) => Promise<PullMobileMsgResponse>;
@@ -0,0 +1,23 @@
1
+ import { ZaloApiError } from '../Errors/ZaloApiError.js';
2
+ import { apiFactory } from '../utils.js';
3
+ export const pullMobileMsgFactory = apiFactory()((api, ctx, utils) => {
4
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/pull_mobile_msg`);
5
+ /**
6
+ * Pull mobile message
7
+ *
8
+ * @param payload payload to pull mobile message
9
+ *
10
+ * @throws {ZaloApiError}
11
+ *
12
+ */
13
+ return async function pullMobileMsg(payload) {
14
+ const params = Object.assign(Object.assign({}, payload), { imei: ctx.imei });
15
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
16
+ if (!encryptedParams)
17
+ throw new ZaloApiError('Failed to encrypt params');
18
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
19
+ method: 'GET',
20
+ });
21
+ return utils.resolve(response);
22
+ };
23
+ });
package/dist/apis.d.ts CHANGED
@@ -108,6 +108,7 @@ import { sendVideoFactory } from "./apis/sendVideo.js";
108
108
  import { getCatalogListFactory } from "./apis/getCatalogList.js";
109
109
  import { getUserInfoFactory } from "./apis/getUserInfo.js";
110
110
  import { sharePollFactory } from "./apis/sharePoll.js";
111
+ import { pullMobileMsgFactory } from "./apis/pullMobileMsg.js";
111
112
  import { getRecommendFriendsFactory } from "./apis/getRecommendFriends.js";
112
113
  import { getGroupMembersInfoFactory } from "./apis/getGroupMembersInfo.js";
113
114
  import { removeUnreadMarkFactory } from "./apis/removeUnreadMark.js";
@@ -258,6 +259,7 @@ export declare class ZaloAPI {
258
259
  getCatalogList: ReturnType<typeof getCatalogListFactory>;
259
260
  getUserInfo: ReturnType<typeof getUserInfoFactory>;
260
261
  sharePoll: ReturnType<typeof sharePollFactory>;
262
+ pullMobileMsg: ReturnType<typeof pullMobileMsgFactory>;
261
263
  getRecommendFriends: ReturnType<typeof getRecommendFriendsFactory>;
262
264
  getGroupMembersInfo: ReturnType<typeof getGroupMembersInfoFactory>;
263
265
  removeUnreadMark: ReturnType<typeof removeUnreadMarkFactory>;
package/dist/apis.js CHANGED
@@ -107,6 +107,7 @@ import { sendVideoFactory } from "./apis/sendVideo.js";
107
107
  import { getCatalogListFactory } from "./apis/getCatalogList.js";
108
108
  import { getUserInfoFactory } from "./apis/getUserInfo.js";
109
109
  import { sharePollFactory } from "./apis/sharePoll.js";
110
+ import { pullMobileMsgFactory } from "./apis/pullMobileMsg.js";
110
111
  import { getRecommendFriendsFactory } from "./apis/getRecommendFriends.js";
111
112
  import { getGroupMembersInfoFactory } from "./apis/getGroupMembersInfo.js";
112
113
  import { removeUnreadMarkFactory } from "./apis/removeUnreadMark.js";
@@ -252,6 +253,7 @@ export class ZaloAPI {
252
253
  this.getCatalogList = getCatalogListFactory(ctx, this);
253
254
  this.getUserInfo = getUserInfoFactory(ctx, this);
254
255
  this.sharePoll = sharePollFactory(ctx, this);
256
+ this.pullMobileMsg = pullMobileMsgFactory(ctx, this);
255
257
  this.getRecommendFriends = getRecommendFriendsFactory(ctx, this);
256
258
  this.getGroupMembersInfo = getGroupMembersInfoFactory(ctx, this);
257
259
  this.removeUnreadMark = removeUnreadMarkFactory(ctx, this);
@@ -11,18 +11,12 @@ const forwardAttachmentFactory = utils.apiFactory()((api, ctx, utils$1) => {
11
11
  [Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.file[0]}/api/message/forward`),
12
12
  [Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.file[0]}/api/group/forward`),
13
13
  };
14
- return async function forwardAttachment(options, threadId, type = Enum.ThreadType.User, messageType) {
14
+ return async function forwardAttachment(options, threadId, type = Enum.ThreadType.User, messageType, msgInfo) {
15
15
  var _a;
16
16
  const timestamp = Date.now();
17
17
  const fileAttachment = await index.getFileUpload(options.url);
18
18
  const checksum = await utils.getMd5LargeFileObject(fileAttachment);
19
- let params = {
20
- clientId: String(timestamp),
21
- ttl: 0,
22
- zsource: 703,
23
- imei: ctx.imei,
24
- msgInfo: {
25
- reference: JSON.stringify({
19
+ let params = Object.assign(Object.assign({ clientId: String(timestamp), ttl: 0, zsource: 703, imei: ctx.imei, msgInfo: Object.assign(Object.assign({}, msgInfo), { reference: JSON.stringify({
26
20
  type: 3,
27
21
  data: JSON.stringify({
28
22
  ts: timestamp,
@@ -33,9 +27,13 @@ const forwardAttachmentFactory = utils.apiFactory()((api, ctx, utils$1) => {
33
27
  logSrcType: 1,
34
28
  },
35
29
  }),
36
- }),
37
- },
38
- decorLog: JSON.stringify({
30
+ }) }) }, ((msgInfo === null || msgInfo === void 0 ? void 0 : msgInfo.groupLayoutId) && {
31
+ extMsgProp: JSON.stringify({
32
+ groupMediaMsg: {
33
+ groupLayoutId: msgInfo.groupLayoutId,
34
+ },
35
+ }),
36
+ })), { decorLog: JSON.stringify({
39
37
  fw: {
40
38
  pmsg: {
41
39
  st: 1,
@@ -47,13 +45,11 @@ const forwardAttachmentFactory = utils.apiFactory()((api, ctx, utils$1) => {
47
45
  },
48
46
  fwLvl: 1,
49
47
  },
50
- }),
51
- };
48
+ }) });
52
49
  switch (messageType) {
53
50
  case common.AttachmentType.IMAGE:
54
51
  const imageOptions = options;
55
- const fileImage = await index.getFileUpload(imageOptions.url);
56
- params = Object.assign(Object.assign({}, params), { msgType: 2, msgInfo: Object.assign(Object.assign({}, params.msgInfo), { title: '', oriUrl: imageOptions.url, url: imageOptions.url, thumbUrl: imageOptions.url, width: 720, height: 1280, properties: null, hdSize: fileImage.size, normalUrl: '' }), jcp: {
52
+ params = Object.assign(Object.assign({}, params), { msgType: 2, msgInfo: Object.assign(Object.assign({}, params.msgInfo), { title: '', oriUrl: imageOptions.url, url: imageOptions.url, thumbUrl: imageOptions.url, normalUrl: '' }), jcp: {
57
53
  convertible: 'jxl',
58
54
  } });
59
55
  break;
@@ -1,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var lodash = require('lodash');
3
4
  var stream = require('stream');
5
+ var WebSocket = require('ws');
6
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
7
  var DeliveredMessage = require('../models/DeliveredMessage.cjs');
5
8
  var FriendEvent = require('../models/FriendEvent.cjs');
6
9
  var GroupEvent = require('../models/GroupEvent.cjs');
@@ -10,11 +13,9 @@ var Reaction = require('../models/Reaction.cjs');
10
13
  var SeenMessage = require('../models/SeenMessage.cjs');
11
14
  var Typing = require('../models/Typing.cjs');
12
15
  var Undo = require('../models/Undo.cjs');
13
- var utils = require('../utils.cjs');
14
16
  var configSocket = require('../socket/config-socket.cjs');
15
- var ZaloApiError = require('../Errors/ZaloApiError.cjs');
16
- var WebSocket = require('ws');
17
- var lodash = require('lodash');
17
+ var utils = require('../utils.cjs');
18
+ var ConversationEvent = require('../models/ConversationEvent.cjs');
18
19
 
19
20
  class Listener extends stream.EventEmitter {
20
21
  constructor(api) {
@@ -82,6 +83,7 @@ class Listener extends stream.EventEmitter {
82
83
  this.onUpdateQueueStatusCallback = () => { };
83
84
  this.onLabelEventCallback = () => { };
84
85
  this.onFriendEventCallback = () => { };
86
+ this.onHiddenConversationCallback = () => { };
85
87
  }
86
88
  onConnected(cb) {
87
89
  this.onConnectedCallback = cb;
@@ -119,6 +121,9 @@ class Listener extends stream.EventEmitter {
119
121
  onFriendEvent(cb) {
120
122
  this.onFriendEventCallback = cb;
121
123
  }
124
+ onHiddenConversation(cb) {
125
+ this.onHiddenConversationCallback = cb;
126
+ }
122
127
  start() {
123
128
  if (this.ws)
124
129
  throw new ZaloApiError.ZaloApiError('Already started');
@@ -185,7 +190,7 @@ class Listener extends stream.EventEmitter {
185
190
  this.ping();
186
191
  }, 3 * 60 * 1000);
187
192
  }
188
- if (version == 1 && cmd == 501 && subCmd == 0) {
193
+ if (version == 1 && cmd == 501) {
189
194
  const parsedData = (await utils.decodeEventData(parsed, this.cipherKey)).data;
190
195
  const { msgs, queueStatus } = parsedData;
191
196
  const listUndo = [];
@@ -212,7 +217,7 @@ class Listener extends stream.EventEmitter {
212
217
  this.onMessageCallback(listMessages);
213
218
  this.onUpdateQueueStatusCallback(queueStatus, timestamp);
214
219
  }
215
- if (version == 1 && cmd == 521 && subCmd == 0) {
220
+ if (version == 1 && cmd == 521) {
216
221
  const parsedData = (await utils.decodeEventData(parsed, this.cipherKey)).data;
217
222
  const { groupMsgs, queueStatus } = parsedData;
218
223
  const listUndo = [];
@@ -249,6 +254,7 @@ class Listener extends stream.EventEmitter {
249
254
  const listGroupEvents = [];
250
255
  const listMuteEvents = [];
251
256
  const listFriendEvents = [];
257
+ const listHiddenEvents = [];
252
258
  let hasLabelEvent = false;
253
259
  for (const control of controls) {
254
260
  if (control.content.act_type == 'file_done') {
@@ -303,10 +309,16 @@ class Listener extends stream.EventEmitter {
303
309
  else if (control.content.act_type == 'label_convers') {
304
310
  hasLabelEvent = true;
305
311
  }
312
+ else if (control.content.act_type == 'hidden_chat') {
313
+ const hiddenEventData = typeof control.content.data === 'string' && utils.looksLikeJson(control.content.data) ? utils.safeJsonParse(control.content.data) : control.content.data;
314
+ const hiddenEvent = ConversationEvent.initializeHiddenConversationEvent(this.ctx.uid, hiddenEventData);
315
+ listHiddenEvents.push(hiddenEvent);
316
+ }
306
317
  }
307
318
  this.onGroupEventCallback(listGroupEvents);
308
319
  this.onMuteCallback(listMuteEvents);
309
320
  this.onFriendEventCallback(listFriendEvents);
321
+ this.onHiddenConversationCallback(listHiddenEvents);
310
322
  if (hasLabelEvent) {
311
323
  this.onLabelEventCallback();
312
324
  }
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var ZaloApiError = require('../Errors/ZaloApiError.cjs');
4
+ var utils = require('../utils.cjs');
5
+
6
+ const pullMobileMsgFactory = utils.apiFactory()((api, ctx, utils) => {
7
+ const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/pull_mobile_msg`);
8
+ /**
9
+ * Pull mobile message
10
+ *
11
+ * @param payload payload to pull mobile message
12
+ *
13
+ * @throws {ZaloApiError}
14
+ *
15
+ */
16
+ return async function pullMobileMsg(payload) {
17
+ const params = Object.assign(Object.assign({}, payload), { imei: ctx.imei });
18
+ const encryptedParams = utils.encodeAES(JSON.stringify(params));
19
+ if (!encryptedParams)
20
+ throw new ZaloApiError.ZaloApiError('Failed to encrypt params');
21
+ const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
22
+ method: 'GET',
23
+ });
24
+ return utils.resolve(response);
25
+ };
26
+ });
27
+
28
+ exports.pullMobileMsgFactory = pullMobileMsgFactory;
package/dist/cjs/apis.cjs CHANGED
@@ -109,6 +109,7 @@ var sendVideo = require('./apis/sendVideo.cjs');
109
109
  var getCatalogList = require('./apis/getCatalogList.cjs');
110
110
  var getUserInfo = require('./apis/getUserInfo.cjs');
111
111
  var sharePoll = require('./apis/sharePoll.cjs');
112
+ var pullMobileMsg = require('./apis/pullMobileMsg.cjs');
112
113
  var getRecommendFriends = require('./apis/getRecommendFriends.cjs');
113
114
  var getGroupMembersInfo = require('./apis/getGroupMembersInfo.cjs');
114
115
  var removeUnreadMark = require('./apis/removeUnreadMark.cjs');
@@ -255,6 +256,7 @@ class ZaloAPI {
255
256
  this.getCatalogList = getCatalogList.getCatalogListFactory(ctx, this);
256
257
  this.getUserInfo = getUserInfo.getUserInfoFactory(ctx, this);
257
258
  this.sharePoll = sharePoll.sharePollFactory(ctx, this);
259
+ this.pullMobileMsg = pullMobileMsg.pullMobileMsgFactory(ctx, this);
258
260
  this.getRecommendFriends = getRecommendFriends.getRecommendFriendsFactory(ctx, this);
259
261
  this.getGroupMembersInfo = getGroupMembersInfo.getGroupMembersInfoFactory(ctx, this);
260
262
  this.removeUnreadMark = removeUnreadMark.removeUnreadMarkFactory(ctx, this);
@@ -18,6 +18,7 @@ var SeenMessage = require('./models/SeenMessage.cjs');
18
18
  var Typing = require('./models/Typing.cjs');
19
19
  var Undo = require('./models/Undo.cjs');
20
20
  var ZBusiness = require('./models/ZBusiness.cjs');
21
+ var ConversationEvent = require('./models/ConversationEvent.cjs');
21
22
  var zalo = require('./zalo.cjs');
22
23
  var Listen = require('./models/Listen.cjs');
23
24
  var reviewPendingMemberRequest = require('./apis/reviewPendingMemberRequest.cjs');
@@ -102,6 +103,7 @@ Object.defineProperty(exports, "BusinessCategory", {
102
103
  get: function () { return ZBusiness.BusinessCategory; }
103
104
  });
104
105
  exports.BusinessCategoryName = ZBusiness.BusinessCategoryName;
106
+ exports.initializeHiddenConversationEvent = ConversationEvent.initializeHiddenConversationEvent;
105
107
  exports.Zalo = zalo.Zalo;
106
108
  Object.defineProperty(exports, "CloseReason", {
107
109
  enumerable: true,
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ function initializeHiddenConversationEvent(uid, data) {
4
+ return {
5
+ type: 'hidden_chat',
6
+ data,
7
+ threadId: uid,
8
+ };
9
+ }
10
+
11
+ exports.initializeHiddenConversationEvent = initializeHiddenConversationEvent;
@@ -0,0 +1,14 @@
1
+ export type THiddenConversationItem = {
2
+ thread_id: string;
3
+ is_group: boolean;
4
+ };
5
+ export type THiddenConversationEvent = {
6
+ add_items: THiddenConversationItem[];
7
+ del_items: THiddenConversationItem[];
8
+ };
9
+ export type HiddenConversationEvent = {
10
+ type: 'hidden_chat';
11
+ data: THiddenConversationEvent;
12
+ threadId: string;
13
+ };
14
+ export declare function initializeHiddenConversationEvent(uid: string, data: THiddenConversationEvent): HiddenConversationEvent;
@@ -0,0 +1,7 @@
1
+ export function initializeHiddenConversationEvent(uid, data) {
2
+ return {
3
+ type: 'hidden_chat',
4
+ data,
5
+ threadId: uid,
6
+ };
7
+ }
@@ -17,3 +17,4 @@ export * from "./Undo.js";
17
17
  export * from "./User.js";
18
18
  export * from "./ZBusiness.js";
19
19
  export * from "./Label.js";
20
+ export * from "./ConversationEvent.js";
@@ -17,3 +17,4 @@ export * from "./Undo.js";
17
17
  export * from "./User.js";
18
18
  export * from "./ZBusiness.js";
19
19
  export * from "./Label.js";
20
+ export * from "./ConversationEvent.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zalo-toolkit",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Unofficial Zalo API for JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",