@softtynet/zca-js 2.2.7 → 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 +160 -179
- 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/update.cjs +8 -6
- 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/update.js +8 -6
- 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 +12 -9
- package/CODE_OF_CONDUCT.md +0 -163
- package/CONTRIBUTING.md +0 -470
- package/SECURITY.md +0 -83
|
@@ -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;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
require('../models/AutoReply.cjs');
|
|
5
|
+
require('../models/Bank.cjs');
|
|
6
|
+
require('../models/Board.cjs');
|
|
7
|
+
var Enum = require('../models/Enum.cjs');
|
|
8
|
+
require('../models/FriendEvent.cjs');
|
|
9
|
+
require('../models/Group.cjs');
|
|
10
|
+
require('../models/GroupEvent.cjs');
|
|
11
|
+
require('../models/Reaction.cjs');
|
|
12
|
+
require('../models/Reminder.cjs');
|
|
13
|
+
require('../models/ZBusiness.cjs');
|
|
14
|
+
require('../models/SyncEvent.cjs');
|
|
15
|
+
require('../models/CallEvent.cjs');
|
|
16
|
+
var utils = require('../utils.cjs');
|
|
17
|
+
|
|
18
|
+
const undoMultiMessageFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
19
|
+
/**
|
|
20
|
+
* Thu hồi hàng loạt nhiều tin nhắn cùng lúc trong hội thoại cá nhân hoặc nhóm (command 12115 / 12116)
|
|
21
|
+
*
|
|
22
|
+
* @param msgs Danh sách tin nhắn cần thu hồi (`globalMsgId`, `cliMsgId` của tin nhắn gốc)
|
|
23
|
+
* @param threadId ID người nhận hoặc ID nhóm
|
|
24
|
+
* @param type Loại hội thoại (`ThreadType.User` hoặc `ThreadType.Group`)
|
|
25
|
+
* @throws {ZaloApiError}
|
|
26
|
+
*/
|
|
27
|
+
return async function undoMultiMessage(msgs, threadId, type = Enum.ThreadType.User) {
|
|
28
|
+
if (!Array.isArray(msgs) || msgs.length === 0) {
|
|
29
|
+
throw new ZaloApiError.ZaloApiError("Missing messages to undo");
|
|
30
|
+
}
|
|
31
|
+
if (!threadId) {
|
|
32
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
33
|
+
}
|
|
34
|
+
const isGroup = type === Enum.ThreadType.Group || threadId.startsWith("g");
|
|
35
|
+
const cleanThreadId = threadId.startsWith("g") ? threadId.slice(1) : threadId;
|
|
36
|
+
const serviceURL = isGroup
|
|
37
|
+
? utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/multi_undomsg`)
|
|
38
|
+
: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/multi_undo`);
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
const normalizedMsgs = msgs.map((m, idx) => ({
|
|
41
|
+
cliMsgId: m.cliMsgIdUndo !== undefined ? m.cliMsgId : now + idx,
|
|
42
|
+
cliMsgIdUndo: m.cliMsgIdUndo !== undefined ? m.cliMsgIdUndo : m.cliMsgId,
|
|
43
|
+
globalMsgId: String(m.globalMsgId),
|
|
44
|
+
}));
|
|
45
|
+
const payload = isGroup
|
|
46
|
+
? { grid: cleanThreadId, msgs: normalizedMsgs }
|
|
47
|
+
: { toid: cleanThreadId, msgs: normalizedMsgs };
|
|
48
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(payload));
|
|
49
|
+
if (!encryptedParams) {
|
|
50
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
51
|
+
}
|
|
52
|
+
const response = await utils.request(serviceURL, {
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: new URLSearchParams({
|
|
55
|
+
params: encryptedParams,
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
return utils.resolve(response);
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
exports.undoMultiMessageFactory = undoMultiMessageFactory;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateRecentSearchFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.recent_search[0]}/api/recentsearch/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Cập nhật danh sách lịch sử tìm kiếm gần đây trên Zalo (command 12126)
|
|
10
|
+
*
|
|
11
|
+
* @param options Danh sách tìm kiếm gần đây và từ khóa (`listRecent`, `listKeyword`, `version`)
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function updateRecentSearch(options = {}) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
let currentVersion = options.version;
|
|
17
|
+
if (currentVersion === undefined) {
|
|
18
|
+
try {
|
|
19
|
+
const current = await api.getRecentSearchList(0);
|
|
20
|
+
currentVersion = (_a = current === null || current === void 0 ? void 0 : current.version) !== null && _a !== void 0 ? _a : 0;
|
|
21
|
+
}
|
|
22
|
+
catch (_d) {
|
|
23
|
+
currentVersion = 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const params = {
|
|
27
|
+
list_recent: (_b = options.listRecent) !== null && _b !== void 0 ? _b : [],
|
|
28
|
+
version: currentVersion,
|
|
29
|
+
list_keyword: (_c = options.listKeyword) !== null && _c !== void 0 ? _c : [],
|
|
30
|
+
imei: ctx.imei,
|
|
31
|
+
};
|
|
32
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
33
|
+
if (!encryptedParams) {
|
|
34
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
35
|
+
}
|
|
36
|
+
const response = await utils.request(serviceURL, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: new URLSearchParams({
|
|
39
|
+
params: encryptedParams,
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
return utils.resolve(response);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
exports.updateRecentSearchFactory = updateRecentSearchFactory;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const verifyCloudMediaFactory = 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/queue/pc/verify`);
|
|
10
|
+
/**
|
|
11
|
+
* Kiểm tra và lấy danh sách mục Media lưu trữ trên ZCloud (command 12740 / 12761)
|
|
12
|
+
*
|
|
13
|
+
* @param options Tùy chọn truy vấn (`lastNoiseId`, `loadType`, `listNoiseIds`, `trackingSource`)
|
|
14
|
+
* @param viewerKeyInfo (Tùy chọn) Cặp `{ viewer_key, enk }` từ `api.getCloudViewerKey()`.
|
|
15
|
+
* @throws {ZaloApiError}
|
|
16
|
+
*/
|
|
17
|
+
return async function verifyCloudMedia(options = {}, viewerKeyInfo) {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
const keyInfo = viewerKeyInfo !== null && viewerKeyInfo !== void 0 ? viewerKeyInfo : (await api.getCloudViewerKey());
|
|
20
|
+
if (!(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.viewer_key) || !(keyInfo === null || keyInfo === void 0 ? void 0 : keyInfo.enk)) {
|
|
21
|
+
throw new ZaloApiError.ZaloApiError("Invalid CloudViewerKey");
|
|
22
|
+
}
|
|
23
|
+
const payload = {
|
|
24
|
+
lastNoiseId: (_a = options.lastNoiseId) !== null && _a !== void 0 ? _a : "",
|
|
25
|
+
loadType: (_b = options.loadType) !== null && _b !== void 0 ? _b : 0,
|
|
26
|
+
listNoiseIds: (_c = options.listNoiseIds) !== null && _c !== void 0 ? _c : [],
|
|
27
|
+
tracking_source: (_d = options.trackingSource) !== null && _d !== void 0 ? _d : 0,
|
|
28
|
+
};
|
|
29
|
+
const encryptedParams = utils.encryptZCloudAES(JSON.stringify(payload), keyInfo.enk);
|
|
30
|
+
const response = await utils$1.request(utils$1.makeURL(serviceURL, { params: encryptedParams }), {
|
|
31
|
+
method: "GET",
|
|
32
|
+
headers: {
|
|
33
|
+
"cloud-viewer-key": keyInfo.viewer_key,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const json = (await response.json());
|
|
37
|
+
if (json.error_code !== 0 && json.error_code !== -904) {
|
|
38
|
+
throw new ZaloApiError.ZaloApiError(json.error_message || "verifyCloudMedia failed", json.error_code);
|
|
39
|
+
}
|
|
40
|
+
if (!json.data) {
|
|
41
|
+
throw new ZaloApiError.ZaloApiError("Empty verifyCloudMedia response", json.error_code);
|
|
42
|
+
}
|
|
43
|
+
const decrypted = utils.decryptZCloudAES(json.data, keyInfo.enk);
|
|
44
|
+
return JSON.parse(decrypted);
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
exports.verifyCloudMediaFactory = verifyCloudMediaFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const voiceToTextFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const baseDomain = ((_a = api.zpwServiceMap.ai_features) === null || _a === void 0 ? void 0 : _a[0]) || "https://tt-ai-features-wpa.chat.zalo.me";
|
|
9
|
+
const serviceURL = utils.makeURL(`${baseDomain}/api/aifeatures/voice2text`);
|
|
10
|
+
/**
|
|
11
|
+
* Gửi yêu cầu chuyển đổi tin nhắn thoại sang văn bản bằng Zalo AI (command 13394).
|
|
12
|
+
* Kết quả văn bản sau khi xử lý xong sẽ được đẩy về qua sự kiện `api.listener.on("voice2text_event", ...)` khớp với `req_id`.
|
|
13
|
+
*
|
|
14
|
+
* @param voiceUrl Đường dẫn URL của tệp ghi âm tin nhắn thoại (`.aac` / `.mp3` / `.m4a`)
|
|
15
|
+
* @throws {ZaloApiError}
|
|
16
|
+
*/
|
|
17
|
+
return async function voiceToText(voiceUrl) {
|
|
18
|
+
if (!voiceUrl) {
|
|
19
|
+
throw new ZaloApiError.ZaloApiError("Missing voiceUrl");
|
|
20
|
+
}
|
|
21
|
+
const encryptedParams = utils.encodeAES(JSON.stringify({ url: voiceUrl }));
|
|
22
|
+
if (!encryptedParams) {
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
24
|
+
}
|
|
25
|
+
const response = await utils.request(serviceURL, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: new URLSearchParams({
|
|
28
|
+
params: encryptedParams,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
return utils.resolve(response);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.voiceToTextFactory = voiceToTextFactory;
|