@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,46 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { GroupMessage } from "../models/index.js";
|
|
3
|
+
import { apiFactory } from "../utils.js";
|
|
4
|
+
export const getGroupCloudMessageJumpFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/rgetv2`);
|
|
6
|
+
/**
|
|
7
|
+
* Nhảy tới vị trí một tin nhắn nhóm cụ thể trên Zalo Cloud Message và lấy ngữ cảnh xung quanh (command 12508)
|
|
8
|
+
*
|
|
9
|
+
* @param groupId ID nhóm
|
|
10
|
+
* @param globalMsgId ID tin nhắn toàn cục cần nhảy tới
|
|
11
|
+
* @param count Số lượng tin nhắn ngữ cảnh cần tải (mặc định `20`)
|
|
12
|
+
* @param msgJump Cờ nhảy tin nhắn (mặc định `1`)
|
|
13
|
+
* @param msgIds Danh sách msgId bổ sung (mặc định `[]`)
|
|
14
|
+
* @throws {ZaloApiError}
|
|
15
|
+
*/
|
|
16
|
+
return async function getGroupCloudMessageJump(groupId, globalMsgId, count = 20, msgJump = 1, msgIds = []) {
|
|
17
|
+
if (!groupId)
|
|
18
|
+
throw new ZaloApiError("Missing groupId");
|
|
19
|
+
if (groupId.startsWith("g"))
|
|
20
|
+
groupId = groupId.slice(1);
|
|
21
|
+
const params = {
|
|
22
|
+
groupId,
|
|
23
|
+
globalMsgId: String(globalMsgId),
|
|
24
|
+
count: Math.min(Math.max(count, 1), 50),
|
|
25
|
+
msgJump,
|
|
26
|
+
msgIds,
|
|
27
|
+
src: 3,
|
|
28
|
+
};
|
|
29
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
30
|
+
if (!encryptedParams)
|
|
31
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
32
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams, nretry: 0 }), {
|
|
33
|
+
method: "GET",
|
|
34
|
+
});
|
|
35
|
+
const page = await utils.resolve(response, (result) => {
|
|
36
|
+
let data = result.data;
|
|
37
|
+
if (typeof data === "string") {
|
|
38
|
+
data = JSON.parse(data);
|
|
39
|
+
}
|
|
40
|
+
return data;
|
|
41
|
+
});
|
|
42
|
+
const rawMsgs = Array.isArray(page === null || page === void 0 ? void 0 : page.groupMsgs) ? page.groupMsgs : [];
|
|
43
|
+
const groupMsgs = rawMsgs.map((data) => new GroupMessage(ctx.uid, data));
|
|
44
|
+
return Object.assign({}, page || {}, { groupMsgs });
|
|
45
|
+
};
|
|
46
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { apiFactory } from "../utils.js";
|
|
2
|
+
export const getLastReadContactTabFactory = apiFactory()((api, _ctx, utils) => {
|
|
3
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/last-read-contact-tab`);
|
|
4
|
+
/**
|
|
5
|
+
* Lấy dấu thời gian lần cuối đọc tab Danh bạ (command 12230)
|
|
6
|
+
*
|
|
7
|
+
* @throws {ZaloApiError}
|
|
8
|
+
*/
|
|
9
|
+
return async function getLastReadContactTab() {
|
|
10
|
+
const response = await utils.request(serviceURL, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
});
|
|
13
|
+
return utils.resolve(response);
|
|
14
|
+
};
|
|
15
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type GetLastSeenOptions = {
|
|
2
|
+
groupIds?: string[];
|
|
3
|
+
userIds?: string[];
|
|
4
|
+
};
|
|
5
|
+
export type GetLastSeenResponse = {
|
|
6
|
+
clearUnreadInfo?: Record<string, unknown>[];
|
|
7
|
+
data?: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export declare const getLastSeenFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options?: GetLastSeenOptions) => Promise<GetLastSeenResponse>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getLastSeenFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/preloadconvers/get-last-seen`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy thông tin trạng thái đã xem cuối cùng của danh sách nhóm và cá nhân (command 12009)
|
|
7
|
+
*
|
|
8
|
+
* @param options Danh sách ID nhóm (`groupIds`) và UID cá nhân (`userIds`)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getLastSeen(options = {}) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const group = ((_a = options.groupIds) !== null && _a !== void 0 ? _a : []).map((g) => (g.startsWith("g") ? g.slice(1) : g));
|
|
14
|
+
const oneone = (_b = options.userIds) !== null && _b !== void 0 ? _b : [];
|
|
15
|
+
const params = {
|
|
16
|
+
param: JSON.stringify({ group, oneone }),
|
|
17
|
+
};
|
|
18
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
19
|
+
if (!encryptedParams) {
|
|
20
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
21
|
+
}
|
|
22
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response, (result) => {
|
|
26
|
+
var _a;
|
|
27
|
+
const raw = result.data;
|
|
28
|
+
if (raw && typeof raw.data === "string") {
|
|
29
|
+
try {
|
|
30
|
+
const inner = JSON.parse(raw.data);
|
|
31
|
+
return ((_a = inner === null || inner === void 0 ? void 0 : inner.data) !== null && _a !== void 0 ? _a : inner);
|
|
32
|
+
}
|
|
33
|
+
catch (_b) {
|
|
34
|
+
return raw;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return raw;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type GetLastSeenReactionOptions = {
|
|
2
|
+
groupIds?: string[];
|
|
3
|
+
userIds?: string[];
|
|
4
|
+
};
|
|
5
|
+
export type GetLastSeenReactionResponse = {
|
|
6
|
+
clearUnreadInfo: Record<string, unknown>[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const getLastSeenReactionFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (options?: GetLastSeenReactionOptions) => Promise<GetLastSeenReactionResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getLastSeenReactionFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.reaction[0]}/api/react/gLastSn`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy trạng thái đã xem cảm xúc (Reaction) cuối cùng của danh sách nhóm và cá nhân (command 12450)
|
|
7
|
+
*
|
|
8
|
+
* @param options Danh sách ID nhóm (`groupIds`) và UID cá nhân (`userIds`)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getLastSeenReaction(options = {}) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const group = ((_a = options.groupIds) !== null && _a !== void 0 ? _a : []).map((g) => (g.startsWith("g") ? g.slice(1) : g));
|
|
14
|
+
const oneone = (_b = options.userIds) !== null && _b !== void 0 ? _b : [];
|
|
15
|
+
const params = {
|
|
16
|
+
group,
|
|
17
|
+
oneone,
|
|
18
|
+
};
|
|
19
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
20
|
+
if (!encryptedParams) {
|
|
21
|
+
throw new 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
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type GetListPinTopicsResponse = {
|
|
2
|
+
items: unknown[];
|
|
3
|
+
version: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const getListPinTopicsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId: string, boardVersion?: number) => Promise<GetListPinTopicsResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getListPinTopicsFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/pin/list`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách chủ đề / tin nhắn đã ghim trong bảng tin nhóm (command 12001)
|
|
7
|
+
*
|
|
8
|
+
* @param groupId ID nhóm
|
|
9
|
+
* @param boardVersion Phiên bản bảng ghim hiện tại (mặc định `0`)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getListPinTopics(groupId, boardVersion = 0) {
|
|
13
|
+
const params = {
|
|
14
|
+
groupId,
|
|
15
|
+
boardVersion,
|
|
16
|
+
imei: ctx.imei,
|
|
17
|
+
};
|
|
18
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
19
|
+
if (!encryptedParams)
|
|
20
|
+
throw new 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
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MediaStoreItem } from "./getConversationMedia.js";
|
|
2
|
+
export type GetMediaStorePreviewResponse = MediaStoreItem[];
|
|
3
|
+
export declare const getMediaStorePreviewFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId: string, limit?: number) => Promise<GetMediaStorePreviewResponse>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getMediaStorePreviewFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store[0]}/api/mediastore/preview`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách xem trước nhanh Kho Lưu Trữ (Ảnh/Video, File, Link) của nhóm (command 11843)
|
|
7
|
+
*
|
|
8
|
+
* @param groupId ID của nhóm
|
|
9
|
+
* @param limit Số lượng mục tối đa (mặc định: 50)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getMediaStorePreview(groupId, limit = 50) {
|
|
13
|
+
if (!groupId) {
|
|
14
|
+
throw new ZaloApiError("Missing groupId");
|
|
15
|
+
}
|
|
16
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
17
|
+
const params = {
|
|
18
|
+
limit,
|
|
19
|
+
group_id: cleanGroupId,
|
|
20
|
+
imei: ctx.imei,
|
|
21
|
+
};
|
|
22
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
23
|
+
if (!encryptedParams) {
|
|
24
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
25
|
+
}
|
|
26
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
27
|
+
method: "POST",
|
|
28
|
+
});
|
|
29
|
+
return utils.resolve(response);
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MiniProfileItem = {
|
|
2
|
+
userId: string;
|
|
3
|
+
avatar: string;
|
|
4
|
+
globalId: string;
|
|
5
|
+
type: number;
|
|
6
|
+
bizPkg?: {
|
|
7
|
+
label: string | null;
|
|
8
|
+
pkgId: number;
|
|
9
|
+
};
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type GetMiniProfileResponse = Record<string, MiniProfileItem>;
|
|
13
|
+
export declare const getMiniProfileFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (friendIds: string[], avatarSize?: number) => Promise<GetMiniProfileResponse>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getMiniProfileFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/getminiprofiles`);
|
|
5
|
+
/**
|
|
6
|
+
* 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)
|
|
7
|
+
*
|
|
8
|
+
* @param friendIds Mảng UID cần lấy thông tin
|
|
9
|
+
* @param avatarSize Kích thước ảnh đại diện (mặc định: 120)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getMiniProfile(friendIds, avatarSize = 120) {
|
|
13
|
+
if (!Array.isArray(friendIds) || friendIds.length === 0) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const params = {
|
|
17
|
+
friend_ids: friendIds,
|
|
18
|
+
avatar_size: avatarSize,
|
|
19
|
+
incInvalid: 1,
|
|
20
|
+
srcReq: -1,
|
|
21
|
+
};
|
|
22
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
23
|
+
if (!encryptedParams) {
|
|
24
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
25
|
+
}
|
|
26
|
+
const response = await utils.request(serviceURL, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
body: new URLSearchParams({
|
|
29
|
+
params: encryptedParams,
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
return utils.resolve(response);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type GetPersonalizedStickerListResponse = {
|
|
2
|
+
list: unknown[];
|
|
3
|
+
version: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const getPersonalizedStickerListFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetPersonalizedStickerListResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getPersonalizedStickerListFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/personalized/list`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách Sticker cá nhân hóa của tài khoản (command 11745)
|
|
7
|
+
*
|
|
8
|
+
* @throws {ZaloApiError}
|
|
9
|
+
*/
|
|
10
|
+
return async function getPersonalizedStickerList() {
|
|
11
|
+
const params = {
|
|
12
|
+
imei: ctx.imei,
|
|
13
|
+
};
|
|
14
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
15
|
+
if (!encryptedParams)
|
|
16
|
+
throw new 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
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type GetPhonebookV2Response = {
|
|
2
|
+
phonebook: Record<string, string>;
|
|
3
|
+
version?: number;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const getPhonebookV2Factory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (phonebookVersion?: number) => Promise<GetPhonebookV2Response>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getPhonebookV2Factory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/phonebook/v2`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh bạ bạn bè đồng bộ từ số điện thoại chuẩn V2 (command 12428)
|
|
7
|
+
*
|
|
8
|
+
* @param phonebookVersion Phiên bản danh bạ (mặc định: 0 để lấy toàn bộ)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getPhonebookV2(phonebookVersion = 0) {
|
|
12
|
+
const encryptedParams = utils.encodeAES(JSON.stringify({ phonebook_version: phonebookVersion }));
|
|
13
|
+
if (!encryptedParams) {
|
|
14
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
15
|
+
}
|
|
16
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
17
|
+
method: "GET",
|
|
18
|
+
});
|
|
19
|
+
return utils.resolve(response);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getProfileRankFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/getrank`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy hạng tài khoản Zalo của một người dùng (ví dụ `"WHITE"`, `"GOLD"` - command 12012)
|
|
7
|
+
*
|
|
8
|
+
* @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)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getProfileRank(profileId) {
|
|
12
|
+
const params = {
|
|
13
|
+
profile_id: profileId !== null && profileId !== void 0 ? profileId : ctx.uid,
|
|
14
|
+
imei: ctx.imei,
|
|
15
|
+
};
|
|
16
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
17
|
+
if (!encryptedParams) {
|
|
18
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
19
|
+
}
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
21
|
+
method: "GET",
|
|
22
|
+
});
|
|
23
|
+
return utils.resolve(response);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type GetProfileVerificationStatusResponse = {
|
|
2
|
+
status: number;
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const getProfileVerificationStatusFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetProfileVerificationStatusResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getProfileVerificationStatusFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/verification/status`);
|
|
5
|
+
/**
|
|
6
|
+
* Kiểm tra trạng thái xác thực định danh (eKYC) của tài khoản Zalo (command 12150)
|
|
7
|
+
*
|
|
8
|
+
* @throws {ZaloApiError}
|
|
9
|
+
*/
|
|
10
|
+
return async function getProfileVerificationStatus() {
|
|
11
|
+
const encryptedParams = utils.encodeAES(JSON.stringify({ imei: ctx.imei }));
|
|
12
|
+
if (!encryptedParams) {
|
|
13
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
14
|
+
}
|
|
15
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
16
|
+
method: "GET",
|
|
17
|
+
});
|
|
18
|
+
return utils.resolve(response);
|
|
19
|
+
};
|
|
20
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type GetQuotaCommunityResponse = {
|
|
2
|
+
canUpgr: boolean;
|
|
3
|
+
curComm: number;
|
|
4
|
+
quotaComm: number;
|
|
5
|
+
error_message_localize?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
export declare const getQuotaCommunityFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (groupId?: string | null, language?: string) => Promise<GetQuotaCommunityResponse>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getQuotaCommunityFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/quota/community`);
|
|
5
|
+
/**
|
|
6
|
+
* 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)
|
|
7
|
+
*
|
|
8
|
+
* @param groupId (Tùy chọn) ID của nhóm cần kiểm tra
|
|
9
|
+
* @param language Ngôn ngữ thông báo (mặc định: `"vi"`)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getQuotaCommunity(groupId = null, language = "vi") {
|
|
13
|
+
const cleanGroupId = groupId && groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
14
|
+
const params = {
|
|
15
|
+
language,
|
|
16
|
+
grId: cleanGroupId,
|
|
17
|
+
};
|
|
18
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
19
|
+
if (!encryptedParams) {
|
|
20
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
21
|
+
}
|
|
22
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
23
|
+
method: "GET",
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type GetRecentSearchListResponse = {
|
|
2
|
+
version: number;
|
|
3
|
+
list_recent: Record<string, unknown>[];
|
|
4
|
+
list_keyword: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare const getRecentSearchListFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (version?: number) => Promise<GetRecentSearchListResponse>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getRecentSearchListFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.recent_search[0]}/api/recentsearch/list`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách lịch sử tìm kiếm gần đây trên Zalo (command 12125)
|
|
7
|
+
*
|
|
8
|
+
* @param version Phiên bản lịch sử tìm kiếm (mặc định: 0)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getRecentSearchList(version = 0) {
|
|
12
|
+
const params = {
|
|
13
|
+
version,
|
|
14
|
+
imei: ctx.imei,
|
|
15
|
+
};
|
|
16
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
17
|
+
if (!encryptedParams) {
|
|
18
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
19
|
+
}
|
|
20
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
21
|
+
method: "GET",
|
|
22
|
+
});
|
|
23
|
+
return utils.resolve(response);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type StickerCategoryV2Item = {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string;
|
|
4
|
+
desc?: string;
|
|
5
|
+
totalImage?: number;
|
|
6
|
+
iconUrl?: string;
|
|
7
|
+
thumbUrl?: string;
|
|
8
|
+
previewUrl?: string;
|
|
9
|
+
status?: number;
|
|
10
|
+
type?: number;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type GetStickerCategoriesV2Response = {
|
|
14
|
+
categories: StickerCategoryV2Item[];
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
export declare const getStickerCategoriesV2Factory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetStickerCategoriesV2Response>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getStickerCategoriesV2Factory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/category/list/v2`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách danh mục bộ nhãn dán (Sticker Categories V2 - command 12020)
|
|
7
|
+
*
|
|
8
|
+
* @throws {ZaloApiError}
|
|
9
|
+
*/
|
|
10
|
+
return async function getStickerCategoriesV2() {
|
|
11
|
+
const encryptedParams = utils.encodeAES("");
|
|
12
|
+
if (!encryptedParams)
|
|
13
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
14
|
+
const response = await utils.request(utils.makeURL(serviceURL, {
|
|
15
|
+
params: encryptedParams,
|
|
16
|
+
}), {
|
|
17
|
+
method: "GET",
|
|
18
|
+
});
|
|
19
|
+
return utils.resolve(response);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { StickerCategoryV2Item } from "./getStickerCategoriesV2.js";
|
|
2
|
+
export type GetStickerCategoryDataResponse = StickerCategoryV2Item;
|
|
3
|
+
export declare const getStickerCategoryDataFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (cid: number) => Promise<StickerCategoryV2Item>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getStickerCategoryDataFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/category/detail`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy thông tin chi tiết một bộ nhãn dán theo `cid` (command 11156)
|
|
7
|
+
*
|
|
8
|
+
* @param cid ID bộ nhãn dán (Category ID)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getStickerCategoryData(cid) {
|
|
12
|
+
const params = {
|
|
13
|
+
cid,
|
|
14
|
+
};
|
|
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, {
|
|
19
|
+
params: encryptedParams,
|
|
20
|
+
}), {
|
|
21
|
+
method: "GET",
|
|
22
|
+
});
|
|
23
|
+
return utils.resolve(response);
|
|
24
|
+
};
|
|
25
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StickerHelloItem = {
|
|
2
|
+
id: number;
|
|
3
|
+
cateId: number;
|
|
4
|
+
type: number;
|
|
5
|
+
text: string;
|
|
6
|
+
uri: string;
|
|
7
|
+
fkey: number;
|
|
8
|
+
status: number;
|
|
9
|
+
stickerUrl: string;
|
|
10
|
+
stickerSpriteUrl: string;
|
|
11
|
+
stickerWebpUrl?: string | null;
|
|
12
|
+
totalFrames: number;
|
|
13
|
+
duration: number;
|
|
14
|
+
};
|
|
15
|
+
export type GetStickerHelloResponse = Record<string, unknown> | StickerHelloItem[];
|
|
16
|
+
export declare const getStickerHelloFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetStickerHelloResponse>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getStickerHelloFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/suggestion`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách Sticker chào hỏi gợi ý khi bắt đầu trò chuyện mới (command 11751)
|
|
7
|
+
*
|
|
8
|
+
* @throws {ZaloApiError}
|
|
9
|
+
*/
|
|
10
|
+
return async function getStickerHello() {
|
|
11
|
+
const params = {
|
|
12
|
+
imei: ctx.imei,
|
|
13
|
+
};
|
|
14
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
15
|
+
if (!encryptedParams)
|
|
16
|
+
throw new 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, (result) => {
|
|
23
|
+
if (typeof result.data === "string") {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(result.data);
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
return result.data;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result.data;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type GetStickerSuggestKeywordsResponse = {
|
|
2
|
+
time: number;
|
|
3
|
+
suggest_data: {
|
|
4
|
+
version: number;
|
|
5
|
+
sdata: Array<{
|
|
6
|
+
keyword: string;
|
|
7
|
+
stickers?: number[];
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare const getStickerSuggestKeywordsFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => () => Promise<GetStickerSuggestKeywordsResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const getStickerSuggestKeywordsFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.sticker[0]}/api/message/sticker/suggest/keywords`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy bộ từ khóa gợi ý Sticker tự động khi gõ tin nhắn (command 11740)
|
|
7
|
+
*
|
|
8
|
+
* @throws {ZaloApiError}
|
|
9
|
+
*/
|
|
10
|
+
return async function getStickerSuggestKeywords() {
|
|
11
|
+
const params = {
|
|
12
|
+
imei: ctx.imei,
|
|
13
|
+
};
|
|
14
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
15
|
+
if (!encryptedParams)
|
|
16
|
+
throw new 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
|
+
});
|