@softtynet/zca-js 2.2.8 → 2.2.9
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 +1 -0
- package/dist/apis/clearUnreadFriendRequests.d.ts +2 -0
- package/dist/apis/clearUnreadFriendRequests.js +29 -0
- package/dist/apis/encryptGids.d.ts +4 -0
- package/dist/apis/encryptGids.js +24 -0
- package/dist/apis/getAliasListV2.d.ts +10 -0
- package/dist/apis/getAliasListV2.js +28 -0
- package/dist/apis/getBlockFriends.d.ts +6 -0
- package/dist/apis/getBlockFriends.js +28 -0
- package/dist/apis/getCloudInfo.d.ts +3 -0
- package/dist/apis/getCloudInfo.js +34 -0
- package/dist/apis/getCloudSettings.d.ts +10 -0
- package/dist/apis/getCloudSettings.js +34 -0
- package/dist/apis/getCloudViewerKey.d.ts +5 -0
- package/dist/apis/getCloudViewerKey.js +25 -0
- package/dist/apis/getConversationMedia.d.ts +26 -0
- package/dist/apis/getConversationMedia.js +39 -0
- package/dist/apis/getEmojiStatusConfig.d.ts +17 -0
- package/dist/apis/getEmojiStatusConfig.js +23 -0
- package/dist/apis/getExtraFriendInfo.d.ts +3 -0
- package/dist/apis/getExtraFriendInfo.js +31 -0
- package/dist/apis/getExtraGroupInfo.d.ts +7 -0
- package/dist/apis/getExtraGroupInfo.js +32 -0
- package/dist/apis/getFamilyProfile.d.ts +3 -0
- package/dist/apis/getFamilyProfile.js +34 -0
- package/dist/apis/getFamilyUsage.d.ts +7 -0
- package/dist/apis/getFamilyUsage.js +34 -0
- package/dist/apis/getFamilyViewerKey.d.ts +5 -0
- package/dist/apis/getFamilyViewerKey.js +25 -0
- package/dist/apis/getFriendsEmojiStatus.d.ts +17 -0
- package/dist/apis/getFriendsEmojiStatus.js +30 -0
- package/dist/apis/getGroupCloudMessageJump.d.ts +3 -0
- package/dist/apis/getGroupCloudMessageJump.js +46 -0
- package/dist/apis/getLastReadContactTab.d.ts +4 -0
- package/dist/apis/getLastReadContactTab.js +15 -0
- package/dist/apis/getLastSeen.d.ts +11 -0
- package/dist/apis/getLastSeen.js +40 -0
- package/dist/apis/getLastSeenReaction.d.ts +9 -0
- package/dist/apis/getLastSeenReaction.js +28 -0
- package/dist/apis/getListPinTopics.d.ts +5 -0
- package/dist/apis/getListPinTopics.js +28 -0
- package/dist/apis/getMediaStorePreview.d.ts +3 -0
- package/dist/apis/getMediaStorePreview.js +31 -0
- package/dist/apis/getMiniProfile.d.ts +13 -0
- package/dist/apis/getMiniProfile.js +34 -0
- package/dist/apis/getPersonalizedStickerList.d.ts +5 -0
- package/dist/apis/getPersonalizedStickerList.js +24 -0
- package/dist/apis/getPhonebookV2.d.ts +6 -0
- package/dist/apis/getPhonebookV2.js +21 -0
- package/dist/apis/getProfileRank.d.ts +5 -0
- package/dist/apis/getProfileRank.js +25 -0
- package/dist/apis/getProfileVerificationStatus.d.ts +5 -0
- package/dist/apis/getProfileVerificationStatus.js +20 -0
- package/dist/apis/getQuotaCommunity.d.ts +8 -0
- package/dist/apis/getQuotaCommunity.js +27 -0
- package/dist/apis/getRecentSearchList.d.ts +6 -0
- package/dist/apis/getRecentSearchList.js +25 -0
- package/dist/apis/getStickerCategoriesV2.d.ts +17 -0
- package/dist/apis/getStickerCategoriesV2.js +21 -0
- package/dist/apis/getStickerCategoryData.d.ts +3 -0
- package/dist/apis/getStickerCategoryData.js +25 -0
- package/dist/apis/getStickerHello.d.ts +16 -0
- package/dist/apis/getStickerHello.js +34 -0
- package/dist/apis/getStickerSuggestKeywords.d.ts +12 -0
- package/dist/apis/getStickerSuggestKeywords.js +24 -0
- package/dist/apis/getStickerSuggestion.d.ts +12 -0
- package/dist/apis/getStickerSuggestion.js +30 -0
- package/dist/apis/getUsageMyCloud.d.ts +7 -0
- package/dist/apis/getUsageMyCloud.js +34 -0
- package/dist/apis/getUsageZCloud.d.ts +11 -0
- package/dist/apis/getUsageZCloud.js +34 -0
- package/dist/apis/keepAlive.d.ts +2 -1
- package/dist/apis/keepAlive.js +5 -3
- package/dist/apis/listen.d.ts +13 -0
- package/dist/apis/listen.js +10 -0
- package/dist/apis/readContactTab.d.ts +2 -0
- package/dist/apis/readContactTab.js +26 -0
- package/dist/apis/removeConversationMedia.d.ts +8 -0
- package/dist/apis/removeConversationMedia.js +30 -0
- package/dist/apis/undoMultiMessage.d.ts +9 -0
- package/dist/apis/undoMultiMessage.js +46 -0
- package/dist/apis/updateRecentSearch.d.ts +11 -0
- package/dist/apis/updateRecentSearch.js +41 -0
- package/dist/apis/verifyCloudMedia.d.ts +14 -0
- package/dist/apis/verifyCloudMedia.js +43 -0
- package/dist/apis/voiceToText.d.ts +4 -0
- package/dist/apis/voiceToText.js +30 -0
- package/dist/apis.d.ts +82 -0
- package/dist/apis.js +82 -0
- package/dist/cjs/apis/clearUnreadFriendRequests.cjs +34 -0
- package/dist/cjs/apis/encryptGids.cjs +29 -0
- package/dist/cjs/apis/getAliasListV2.cjs +33 -0
- package/dist/cjs/apis/getBlockFriends.cjs +33 -0
- package/dist/cjs/apis/getCloudInfo.cjs +39 -0
- package/dist/cjs/apis/getCloudSettings.cjs +39 -0
- package/dist/cjs/apis/getCloudViewerKey.cjs +30 -0
- package/dist/cjs/apis/getConversationMedia.cjs +44 -0
- package/dist/cjs/apis/getEmojiStatusConfig.cjs +28 -0
- package/dist/cjs/apis/getExtraFriendInfo.cjs +36 -0
- package/dist/cjs/apis/getExtraGroupInfo.cjs +37 -0
- package/dist/cjs/apis/getFamilyProfile.cjs +39 -0
- package/dist/cjs/apis/getFamilyUsage.cjs +39 -0
- package/dist/cjs/apis/getFamilyViewerKey.cjs +30 -0
- package/dist/cjs/apis/getFriendsEmojiStatus.cjs +35 -0
- package/dist/cjs/apis/getGroupCloudMessageJump.cjs +63 -0
- package/dist/cjs/apis/getLastReadContactTab.cjs +20 -0
- package/dist/cjs/apis/getLastSeen.cjs +45 -0
- package/dist/cjs/apis/getLastSeenReaction.cjs +33 -0
- package/dist/cjs/apis/getListPinTopics.cjs +33 -0
- package/dist/cjs/apis/getMediaStorePreview.cjs +36 -0
- package/dist/cjs/apis/getMiniProfile.cjs +39 -0
- package/dist/cjs/apis/getPersonalizedStickerList.cjs +29 -0
- package/dist/cjs/apis/getPhonebookV2.cjs +26 -0
- package/dist/cjs/apis/getProfileRank.cjs +30 -0
- package/dist/cjs/apis/getProfileVerificationStatus.cjs +25 -0
- package/dist/cjs/apis/getQuotaCommunity.cjs +32 -0
- package/dist/cjs/apis/getRecentSearchList.cjs +30 -0
- package/dist/cjs/apis/getStickerCategoriesV2.cjs +26 -0
- package/dist/cjs/apis/getStickerCategoryData.cjs +30 -0
- package/dist/cjs/apis/getStickerHello.cjs +39 -0
- package/dist/cjs/apis/getStickerSuggestKeywords.cjs +29 -0
- package/dist/cjs/apis/getStickerSuggestion.cjs +35 -0
- package/dist/cjs/apis/getUsageMyCloud.cjs +39 -0
- package/dist/cjs/apis/getUsageZCloud.cjs +39 -0
- package/dist/cjs/apis/keepAlive.cjs +5 -3
- package/dist/cjs/apis/listen.cjs +10 -0
- package/dist/cjs/apis/readContactTab.cjs +31 -0
- package/dist/cjs/apis/removeConversationMedia.cjs +35 -0
- package/dist/cjs/apis/undoMultiMessage.cjs +62 -0
- package/dist/cjs/apis/updateRecentSearch.cjs +46 -0
- package/dist/cjs/apis/verifyCloudMedia.cjs +48 -0
- package/dist/cjs/apis/voiceToText.cjs +35 -0
- package/dist/cjs/apis.cjs +82 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/utils.cjs +25 -0
- package/dist/context.d.ts +4 -0
- package/dist/index.d.ts +42 -1
- package/dist/index.js +1 -1
- package/dist/utils.d.ts +10 -0
- package/dist/utils.js +23 -0
- package/docs/INTEGRATION_GUIDE_SYNC_AND_CALL.md +110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getListPinTopicsFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/pin/list`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách chủ đề / tin nhắn đã ghim trong bảng tin nhóm (command 12001)
|
|
10
|
+
*
|
|
11
|
+
* @param groupId ID nhóm
|
|
12
|
+
* @param boardVersion Phiên bản bảng ghim hiện tại (mặc định `0`)
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getListPinTopics(groupId, boardVersion = 0) {
|
|
16
|
+
const params = {
|
|
17
|
+
groupId,
|
|
18
|
+
boardVersion,
|
|
19
|
+
imei: ctx.imei,
|
|
20
|
+
};
|
|
21
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
22
|
+
if (!encryptedParams)
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
24
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
25
|
+
params: encryptedParams,
|
|
26
|
+
}), {
|
|
27
|
+
method: "GET",
|
|
28
|
+
});
|
|
29
|
+
return utils.resolve(response);
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
exports.getListPinTopicsFactory = getListPinTopicsFactory;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getMediaStorePreviewFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store[0]}/api/mediastore/preview`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách xem trước nhanh Kho Lưu Trữ (Ảnh/Video, File, Link) của nhóm (command 11843)
|
|
10
|
+
*
|
|
11
|
+
* @param groupId ID của nhóm
|
|
12
|
+
* @param limit Số lượng mục tối đa (mặc định: 50)
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getMediaStorePreview(groupId, limit = 50) {
|
|
16
|
+
if (!groupId) {
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Missing groupId");
|
|
18
|
+
}
|
|
19
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
20
|
+
const params = {
|
|
21
|
+
limit,
|
|
22
|
+
group_id: cleanGroupId,
|
|
23
|
+
imei: ctx.imei,
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams) {
|
|
27
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
28
|
+
}
|
|
29
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
30
|
+
method: "POST",
|
|
31
|
+
});
|
|
32
|
+
return utils.resolve(response);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
exports.getMediaStorePreviewFactory = getMediaStorePreviewFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getMiniProfileFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/getminiprofiles`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy nhanh thông tin hồ sơ rút gọn (Avatar, Global ID, gói Biz) của danh sách người dùng (command 12134)
|
|
10
|
+
*
|
|
11
|
+
* @param friendIds Mảng UID cần lấy thông tin
|
|
12
|
+
* @param avatarSize Kích thước ảnh đại diện (mặc định: 120)
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getMiniProfile(friendIds, avatarSize = 120) {
|
|
16
|
+
if (!Array.isArray(friendIds) || friendIds.length === 0) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
const params = {
|
|
20
|
+
friend_ids: friendIds,
|
|
21
|
+
avatar_size: avatarSize,
|
|
22
|
+
incInvalid: 1,
|
|
23
|
+
srcReq: -1,
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams) {
|
|
27
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
28
|
+
}
|
|
29
|
+
const response = await utils.request(serviceURL, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: new URLSearchParams({
|
|
32
|
+
params: encryptedParams,
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
return utils.resolve(response);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.getMiniProfileFactory = getMiniProfileFactory;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getPersonalizedStickerListFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/personalized/list`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách Sticker cá nhân hóa của tài khoản (command 11745)
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getPersonalizedStickerList() {
|
|
14
|
+
const params = {
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
21
|
+
params: encryptedParams,
|
|
22
|
+
}), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.getPersonalizedStickerListFactory = getPersonalizedStickerListFactory;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getPhonebookV2Factory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/phonebook/v2`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh bạ bạn bè đồng bộ từ số điện thoại chuẩn V2 (command 12428)
|
|
10
|
+
*
|
|
11
|
+
* @param phonebookVersion Phiên bản danh bạ (mặc định: 0 để lấy toàn bộ)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getPhonebookV2(phonebookVersion = 0) {
|
|
15
|
+
const encryptedParams = utils.encodeAES(JSON.stringify({ phonebook_version: phonebookVersion }));
|
|
16
|
+
if (!encryptedParams) {
|
|
17
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
18
|
+
}
|
|
19
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
20
|
+
method: "GET",
|
|
21
|
+
});
|
|
22
|
+
return utils.resolve(response);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.getPhonebookV2Factory = getPhonebookV2Factory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getProfileRankFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/getrank`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy hạng tài khoản Zalo của một người dùng (ví dụ `"WHITE"`, `"GOLD"` - command 12012)
|
|
10
|
+
*
|
|
11
|
+
* @param profileId UID của người dùng cần kiểm tra (mặc định: UID của tài khoản đang đăng nhập)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getProfileRank(profileId) {
|
|
15
|
+
const params = {
|
|
16
|
+
profile_id: profileId !== null && profileId !== void 0 ? profileId : ctx.uid,
|
|
17
|
+
imei: ctx.imei,
|
|
18
|
+
};
|
|
19
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
20
|
+
if (!encryptedParams) {
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
22
|
+
}
|
|
23
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
24
|
+
method: "GET",
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.getProfileRankFactory = getProfileRankFactory;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getProfileVerificationStatusFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/verification/status`);
|
|
8
|
+
/**
|
|
9
|
+
* Kiểm tra trạng thái xác thực định danh (eKYC) của tài khoản Zalo (command 12150)
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getProfileVerificationStatus() {
|
|
14
|
+
const encryptedParams = utils.encodeAES(JSON.stringify({ imei: ctx.imei }));
|
|
15
|
+
if (!encryptedParams) {
|
|
16
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
17
|
+
}
|
|
18
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
19
|
+
method: "GET",
|
|
20
|
+
});
|
|
21
|
+
return utils.resolve(response);
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.getProfileVerificationStatusFactory = getProfileVerificationStatusFactory;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getQuotaCommunityFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/quota/community`);
|
|
8
|
+
/**
|
|
9
|
+
* Kiểm tra hạn mức nâng cấp nhóm lên Cộng đồng của tài khoản (command 12181)
|
|
10
|
+
*
|
|
11
|
+
* @param groupId (Tùy chọn) ID của nhóm cần kiểm tra
|
|
12
|
+
* @param language Ngôn ngữ thông báo (mặc định: `"vi"`)
|
|
13
|
+
* @throws {ZaloApiError}
|
|
14
|
+
*/
|
|
15
|
+
return async function getQuotaCommunity(groupId = null, language = "vi") {
|
|
16
|
+
const cleanGroupId = groupId && groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
17
|
+
const params = {
|
|
18
|
+
language,
|
|
19
|
+
grId: cleanGroupId,
|
|
20
|
+
};
|
|
21
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
22
|
+
if (!encryptedParams) {
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
24
|
+
}
|
|
25
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
26
|
+
method: "GET",
|
|
27
|
+
});
|
|
28
|
+
return utils.resolve(response);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
exports.getQuotaCommunityFactory = getQuotaCommunityFactory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getRecentSearchListFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.recent_search[0]}/api/recentsearch/list`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách lịch sử tìm kiếm gần đây trên Zalo (command 12125)
|
|
10
|
+
*
|
|
11
|
+
* @param version Phiên bản lịch sử tìm kiếm (mặc định: 0)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getRecentSearchList(version = 0) {
|
|
15
|
+
const params = {
|
|
16
|
+
version,
|
|
17
|
+
imei: ctx.imei,
|
|
18
|
+
};
|
|
19
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
20
|
+
if (!encryptedParams) {
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
22
|
+
}
|
|
23
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
24
|
+
method: "GET",
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.getRecentSearchListFactory = getRecentSearchListFactory;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getStickerCategoriesV2Factory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/category/list/v2`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách danh mục bộ nhãn dán (Sticker Categories V2 - command 12020)
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getStickerCategoriesV2() {
|
|
14
|
+
const encryptedParams = utils.encodeAES("");
|
|
15
|
+
if (!encryptedParams)
|
|
16
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
17
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
18
|
+
params: encryptedParams,
|
|
19
|
+
}), {
|
|
20
|
+
method: "GET",
|
|
21
|
+
});
|
|
22
|
+
return utils.resolve(response);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.getStickerCategoriesV2Factory = getStickerCategoriesV2Factory;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getStickerCategoryDataFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/category/detail`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy thông tin chi tiết một bộ nhãn dán theo `cid` (command 11156)
|
|
10
|
+
*
|
|
11
|
+
* @param cid ID bộ nhãn dán (Category ID)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getStickerCategoryData(cid) {
|
|
15
|
+
const params = {
|
|
16
|
+
cid,
|
|
17
|
+
};
|
|
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, {
|
|
22
|
+
params: encryptedParams,
|
|
23
|
+
}), {
|
|
24
|
+
method: "GET",
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports.getStickerCategoryDataFactory = getStickerCategoryDataFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getStickerHelloFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/suggestion`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy danh sách Sticker chào hỏi gợi ý khi bắt đầu trò chuyện mới (command 11751)
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getStickerHello() {
|
|
14
|
+
const params = {
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
21
|
+
params: encryptedParams,
|
|
22
|
+
}), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response, (result) => {
|
|
26
|
+
if (typeof result.data === "string") {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(result.data);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return result.data;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result.data;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.getStickerHelloFactory = getStickerHelloFactory;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getStickerSuggestKeywordsFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/suggest/keywords`);
|
|
8
|
+
/**
|
|
9
|
+
* Lấy bộ từ khóa gợi ý Sticker tự động khi gõ tin nhắn (command 11740)
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function getStickerSuggestKeywords() {
|
|
14
|
+
const params = {
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
21
|
+
params: encryptedParams,
|
|
22
|
+
}), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
exports.getStickerSuggestKeywordsFactory = getStickerSuggestKeywordsFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getStickerSuggestionFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/suggest/stickers`);
|
|
8
|
+
/**
|
|
9
|
+
* Gợi ý Sticker/GIF theo từ khóa đang nhập (command 11741)
|
|
10
|
+
*
|
|
11
|
+
* @param options Từ khóa và tùy chọn kèm theo (`gif`, `guggy`)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function getStickerSuggestion(options) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const normalized = typeof options === "string" ? { keyword: options } : options;
|
|
17
|
+
const params = {
|
|
18
|
+
keyword: normalized.keyword,
|
|
19
|
+
gif: (_a = normalized.gif) !== null && _a !== void 0 ? _a : 1,
|
|
20
|
+
guggy: (_b = normalized.guggy) !== null && _b !== void 0 ? _b : 0,
|
|
21
|
+
imei: ctx.imei,
|
|
22
|
+
};
|
|
23
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
24
|
+
if (!encryptedParams)
|
|
25
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
26
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
27
|
+
params: encryptedParams,
|
|
28
|
+
}), {
|
|
29
|
+
method: "GET",
|
|
30
|
+
});
|
|
31
|
+
return utils.resolve(response);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.getStickerSuggestionFactory = getStickerSuggestionFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getUsageMyCloudFactory = utils.apiFactory()((api, _ctx, utils$1) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const baseDomain = ((_a = api.zpwServiceMap.zcloud) === null || _a === void 0 ? void 0 : _a[0]) || "https://zcld.chat.zalo.me";
|
|
9
|
+
const serviceURL = utils$1.makeURL(`${baseDomain}/cloudmedia/info/pc/v1/usage-mycloud`);
|
|
10
|
+
/**
|
|
11
|
+
* Kiểm tra hạn mức và dung lượng sử dụng Cloud của tôi (MyCloud - command 12748)
|
|
12
|
+
*
|
|
13
|
+
* @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`. Nếu không truyền sẽ tự động lấy mới.
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function getUsageMyCloud(viewerKeyInfo) {
|
|
17
|
+
const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
|
|
18
|
+
if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Invalid CloudViewerKey");
|
|
20
|
+
}
|
|
21
|
+
const response = await utils$1.request(serviceURL, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
headers: {
|
|
24
|
+
"cloud-viewer-key": keyInfo.viewer_key,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const json = (await response.json());
|
|
28
|
+
if (json.error_code !== 0 && json.error_code !== -904) {
|
|
29
|
+
throw new ZaloApiError.ZaloApiError(json.error_message || "getUsageMyCloud failed", json.error_code);
|
|
30
|
+
}
|
|
31
|
+
if (!json.data) {
|
|
32
|
+
throw new ZaloApiError.ZaloApiError("Empty MyCloud usage data", json.error_code);
|
|
33
|
+
}
|
|
34
|
+
const decrypted = utils.decryptZCloudAES(json.data, keyInfo.enk);
|
|
35
|
+
return JSON.parse(decrypted);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.getUsageMyCloudFactory = getUsageMyCloudFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const getUsageZCloudFactory = utils.apiFactory()((api, _ctx, utils$1) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const baseDomain = ((_a = api.zpwServiceMap.zcloud) === null || _a === void 0 ? void 0 : _a[0]) || "https://zcld.chat.zalo.me";
|
|
9
|
+
const serviceURL = utils$1.makeURL(`${baseDomain}/cloudmedia/info/pc/v2/usage`);
|
|
10
|
+
/**
|
|
11
|
+
* Kiểm tra dung lượng sử dụng ZCloud V2 (bao gồm MyCloud và Sao lưu tin nhắn - command 12749)
|
|
12
|
+
*
|
|
13
|
+
* @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`. Nếu không truyền sẽ tự động lấy mới.
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function getUsageZCloud(viewerKeyInfo) {
|
|
17
|
+
const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
|
|
18
|
+
if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Invalid CloudViewerKey");
|
|
20
|
+
}
|
|
21
|
+
const response = await utils$1.request(serviceURL, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
headers: {
|
|
24
|
+
"cloud-viewer-key": keyInfo.viewer_key,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const json = (await response.json());
|
|
28
|
+
if (json.error_code !== 0 && json.error_code !== -904) {
|
|
29
|
+
throw new ZaloApiError.ZaloApiError(json.error_message || "getUsageZCloud failed", json.error_code);
|
|
30
|
+
}
|
|
31
|
+
if (!json.data) {
|
|
32
|
+
throw new ZaloApiError.ZaloApiError("Empty ZCloud usage data", json.error_code);
|
|
33
|
+
}
|
|
34
|
+
const decrypted = utils.decryptZCloudAES(json.data, keyInfo.enk);
|
|
35
|
+
return JSON.parse(decrypted);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.getUsageZCloudFactory = getUsageZCloudFactory;
|
|
@@ -6,7 +6,7 @@ var utils = require('../utils.cjs');
|
|
|
6
6
|
const keepAliveFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
7
|
const serviceURL = utils.makeURL(`${api.zpwServiceMap.chat[0]}/keepalive`);
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Gửi tín hiệu duy trì phiên kết nối HTTP tới máy chủ Chat (KeepAlive - command 11770)
|
|
10
10
|
*
|
|
11
11
|
* @throws {ZaloApiError}
|
|
12
12
|
*/
|
|
@@ -17,10 +17,12 @@ const keepAliveFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
|
17
17
|
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
18
|
if (!encryptedParams)
|
|
19
19
|
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
20
|
-
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
21
|
+
params: encryptedParams,
|
|
22
|
+
}), {
|
|
21
23
|
method: "GET",
|
|
22
24
|
});
|
|
23
|
-
return utils.resolve(response
|
|
25
|
+
return utils.resolve(response);
|
|
24
26
|
};
|
|
25
27
|
});
|
|
26
28
|
|
package/dist/cjs/apis/listen.cjs
CHANGED
|
@@ -373,6 +373,16 @@ class Listener extends EventEmitter {
|
|
|
373
373
|
const callEvent = CallEvent.initializeCallEvent(callEventData, control.content.act, control.content.act_type);
|
|
374
374
|
this.emit("call_event", callEvent);
|
|
375
375
|
}
|
|
376
|
+
else if (control.content.act_type == "voice2text") {
|
|
377
|
+
const v2tData = typeof control.content.data == "string"
|
|
378
|
+
? JSON.parse(control.content.data)
|
|
379
|
+
: control.content.data;
|
|
380
|
+
this.emit("voice2text_event", {
|
|
381
|
+
act: control.content.act,
|
|
382
|
+
act_type: "voice2text",
|
|
383
|
+
data: v2tData,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
388
|
if (cmd == 612) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const readContactTabFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/read-contact-tab`);
|
|
8
|
+
/**
|
|
9
|
+
* Đánh dấu đã đọc tab Danh bạ (command 12231)
|
|
10
|
+
*
|
|
11
|
+
* @param ts Dấu thời gian (mặc định: `Date.now()`)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function readContactTab(ts = Date.now()) {
|
|
15
|
+
const params = {
|
|
16
|
+
ts,
|
|
17
|
+
};
|
|
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(serviceURL, {
|
|
22
|
+
method: "POST",
|
|
23
|
+
body: new URLSearchParams({
|
|
24
|
+
params: encryptedParams,
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
return utils.resolve(response);
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
exports.readContactTabFactory = readContactTabFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const removeConversationMediaFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store[0]}/api/mediastore/remove`);
|
|
8
|
+
/**
|
|
9
|
+
* Xóa mục Ảnh/Video, File hoặc Link khỏi Kho Lưu Trữ của nhóm (command 11842)
|
|
10
|
+
*
|
|
11
|
+
* @param options Thông tin mục cần xóa (`groupId`, `mediaType`, `mediaId`)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function removeConversationMedia(options) {
|
|
15
|
+
if (!options.groupId) {
|
|
16
|
+
throw new ZaloApiError.ZaloApiError("Missing groupId");
|
|
17
|
+
}
|
|
18
|
+
const cleanGroupId = options.groupId.startsWith("g") ? options.groupId.slice(1) : options.groupId;
|
|
19
|
+
const params = {
|
|
20
|
+
media_type: options.mediaType,
|
|
21
|
+
media_id: options.mediaId,
|
|
22
|
+
group_id: cleanGroupId,
|
|
23
|
+
};
|
|
24
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
25
|
+
if (!encryptedParams) {
|
|
26
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
27
|
+
}
|
|
28
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
29
|
+
method: "POST",
|
|
30
|
+
});
|
|
31
|
+
return utils.resolve(response);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.removeConversationMediaFactory = removeConversationMediaFactory;
|