zalo-toolkit 1.1.3 → 1.1.4
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/dist/apis/forwardAttachment.d.ts +3 -3
- package/dist/apis/forwardAttachment.js +16 -20
- package/dist/apis/pullMobileMsg.d.ts +10 -0
- package/dist/apis/pullMobileMsg.js +23 -0
- package/dist/apis.d.ts +2 -0
- package/dist/apis.js +2 -0
- package/dist/cjs/apis/forwardAttachment.cjs +11 -15
- package/dist/cjs/apis/pullMobileMsg.cjs +28 -0
- package/dist/cjs/apis.cjs +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AttachmentType } from
|
|
2
|
-
import { ThreadType } from
|
|
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
|
|
2
|
-
import { getFileUpload } from
|
|
3
|
-
import { ZaloApiError } from
|
|
4
|
-
import { ThreadType } from
|
|
5
|
-
import { apiFactory, getMd5LargeFileObject } from
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -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);
|