@softtynet/zca-js 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -21
- package/dist/apis/auth/exportSession.d.ts +7 -0
- package/dist/apis/auth/exportSession.js +17 -0
- package/dist/apis/call/addUserGroupCall.d.ts +11 -0
- package/dist/apis/call/addUserGroupCall.js +48 -0
- package/dist/apis/call/answerAckVoiceCall.d.ts +5 -0
- package/dist/apis/call/answerAckVoiceCall.js +38 -0
- package/dist/apis/call/answerGroupCall.d.ts +10 -0
- package/dist/apis/call/answerGroupCall.js +45 -0
- package/dist/apis/call/answerVoiceCall.d.ts +11 -0
- package/dist/apis/call/answerVoiceCall.js +50 -0
- package/dist/apis/call/broadcastGroupCallState.d.ts +10 -0
- package/dist/apis/call/broadcastGroupCallState.js +45 -0
- package/dist/apis/call/cancelGroupCall.d.ts +10 -0
- package/dist/apis/call/cancelGroupCall.js +45 -0
- package/dist/apis/call/cancelVoiceCall.d.ts +1 -1
- package/dist/apis/call/cancelVoiceCall.js +5 -1
- package/dist/apis/call/createController.d.ts +7 -0
- package/dist/apis/call/createController.js +9 -0
- package/dist/apis/call/createRtcSession.d.ts +8 -0
- package/dist/apis/call/createRtcSession.js +10 -0
- package/dist/apis/call/endGroupCall.d.ts +10 -0
- package/dist/apis/call/endGroupCall.js +45 -0
- package/dist/apis/call/finishGroupCall.d.ts +12 -0
- package/dist/apis/call/finishGroupCall.js +47 -0
- package/dist/apis/call/getGroupCallState.d.ts +3 -0
- package/dist/apis/call/getGroupCallState.js +38 -0
- package/dist/apis/call/holdVoiceCall.d.ts +5 -0
- package/dist/apis/call/holdVoiceCall.js +34 -0
- package/dist/apis/call/joinGroupCall.d.ts +11 -0
- package/dist/apis/call/joinGroupCall.js +46 -0
- package/dist/apis/call/logEndVoiceCall.d.ts +8 -0
- package/dist/apis/call/logEndVoiceCall.js +46 -0
- package/dist/apis/call/notifyGroupCall.d.ts +9 -0
- package/dist/apis/call/notifyGroupCall.js +44 -0
- package/dist/apis/call/pingGroupCall.d.ts +10 -0
- package/dist/apis/call/pingGroupCall.js +45 -0
- package/dist/apis/call/requestAudioToVideoCall.d.ts +5 -0
- package/dist/apis/call/requestAudioToVideoCall.js +37 -0
- package/dist/apis/call/requestGroupCall.d.ts +9 -0
- package/dist/apis/call/requestGroupCall.js +46 -0
- package/dist/apis/call/requestShareScreenCall.d.ts +5 -0
- package/dist/apis/call/requestShareScreenCall.js +37 -0
- package/dist/apis/call/requestVoiceCall.d.ts +10 -0
- package/dist/apis/call/requestVoiceCall.js +47 -0
- package/dist/apis/call/ringRingGroupCall.d.ts +10 -0
- package/dist/apis/call/ringRingGroupCall.js +45 -0
- package/dist/apis/call/ringRingVoiceCall.d.ts +5 -0
- package/dist/apis/call/ringRingVoiceCall.js +38 -0
- package/dist/apis/call/sendRequestGroupCall.d.ts +11 -0
- package/dist/apis/call/sendRequestGroupCall.js +48 -0
- package/dist/apis/call/sendRequestVoiceCall.d.ts +11 -0
- package/dist/apis/call/sendRequestVoiceCall.js +51 -0
- package/dist/apis/call/sendVoiceCall.d.ts +8 -1
- package/dist/apis/call/sendVoiceCall.js +10 -8
- package/dist/apis/call/shareScreenGroupCall.d.ts +10 -0
- package/dist/apis/call/shareScreenGroupCall.js +45 -0
- package/dist/apis/call/unholdVoiceCall.d.ts +5 -0
- package/dist/apis/call/unholdVoiceCall.js +34 -0
- package/dist/apis/call/updateCallMediaState.d.ts +7 -0
- package/dist/apis/call/updateCallMediaState.js +61 -0
- package/dist/apis/chat/getDirectMessageStatus.d.ts +14 -0
- package/dist/apis/chat/getDirectMessageStatus.js +52 -0
- package/dist/apis/chat/getSuggestedConversations.d.ts +5 -0
- package/dist/apis/chat/getSuggestedConversations.js +24 -0
- package/dist/apis/chat/updatePinConversations.d.ts +24 -0
- package/dist/apis/chat/updatePinConversations.js +40 -0
- package/dist/apis/friend/getFriendProfilesV2.d.ts +26 -0
- package/dist/apis/friend/getFriendProfilesV2.js +38 -0
- package/dist/apis/friend/getFriendsActivePCWeb.d.ts +6 -0
- package/dist/apis/friend/getFriendsActivePCWeb.js +15 -0
- package/dist/apis/friend/verifyFriend.d.ts +11 -0
- package/dist/apis/friend/verifyFriend.js +37 -0
- package/dist/apis/group/analyseGroup.d.ts +4 -0
- package/dist/apis/group/analyseGroup.js +28 -0
- package/dist/apis/group/checkQuotaCommunityMember.d.ts +6 -0
- package/dist/apis/group/checkQuotaCommunityMember.js +34 -0
- package/dist/apis/group/getE2eeGroupList.d.ts +7 -0
- package/dist/apis/group/getE2eeGroupList.js +15 -0
- package/dist/apis/group/getGroupCloudMessagePath.d.ts +19 -0
- package/dist/apis/group/getGroupCloudMessagePath.js +51 -0
- package/dist/apis/group/getMultiGroupCloudMessages.d.ts +5 -0
- package/dist/apis/group/getMultiGroupCloudMessages.js +29 -0
- package/dist/apis/media/getPersonalMedia.d.ts +8 -0
- package/dist/apis/media/getPersonalMedia.js +31 -0
- package/dist/apis/media/getPersonalMediaPreview.d.ts +3 -0
- package/dist/apis/media/getPersonalMediaPreview.js +24 -0
- package/dist/apis/media/removePersonalMedia.d.ts +9 -0
- package/dist/apis/media/removePersonalMedia.js +28 -0
- package/dist/apis.d.ts +126 -0
- package/dist/apis.js +210 -0
- package/dist/call-engine/ZRTPPacketCodec.d.ts +262 -0
- package/dist/call-engine/ZRTPPacketCodec.js +506 -0
- package/dist/call-engine/ZaloCallController.d.ts +134 -0
- package/dist/call-engine/ZaloCallController.js +638 -0
- package/dist/call-engine/ZaloCallTransport.d.ts +83 -0
- package/dist/call-engine/ZaloCallTransport.js +233 -0
- package/dist/call-engine/ZaloRtcSession.d.ts +609 -0
- package/dist/call-engine/ZaloRtcSession.js +2931 -0
- package/dist/call-engine/ZaloSrtpSession.d.ts +80 -0
- package/dist/call-engine/ZaloSrtpSession.js +278 -0
- package/dist/call-engine/index.d.ts +18 -0
- package/dist/call-engine/index.js +24 -0
- package/dist/cjs/apis/auth/exportSession.cjs +22 -0
- package/dist/cjs/apis/call/addUserGroupCall.cjs +53 -0
- package/dist/cjs/apis/call/answerAckVoiceCall.cjs +43 -0
- package/dist/cjs/apis/call/answerGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/answerVoiceCall.cjs +55 -0
- package/dist/cjs/apis/call/broadcastGroupCallState.cjs +50 -0
- package/dist/cjs/apis/call/cancelGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/cancelVoiceCall.cjs +5 -1
- package/dist/cjs/apis/call/createController.cjs +14 -0
- package/dist/cjs/apis/call/createRtcSession.cjs +15 -0
- package/dist/cjs/apis/call/endGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/finishGroupCall.cjs +52 -0
- package/dist/cjs/apis/call/getGroupCallState.cjs +43 -0
- package/dist/cjs/apis/call/holdVoiceCall.cjs +39 -0
- package/dist/cjs/apis/call/joinGroupCall.cjs +51 -0
- package/dist/cjs/apis/call/logEndVoiceCall.cjs +51 -0
- package/dist/cjs/apis/call/notifyGroupCall.cjs +49 -0
- package/dist/cjs/apis/call/pingGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/requestAudioToVideoCall.cjs +42 -0
- package/dist/cjs/apis/call/requestGroupCall.cjs +51 -0
- package/dist/cjs/apis/call/requestShareScreenCall.cjs +42 -0
- package/dist/cjs/apis/call/requestVoiceCall.cjs +52 -0
- package/dist/cjs/apis/call/ringRingGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/ringRingVoiceCall.cjs +43 -0
- package/dist/cjs/apis/call/sendRequestGroupCall.cjs +53 -0
- package/dist/cjs/apis/call/sendRequestVoiceCall.cjs +56 -0
- package/dist/cjs/apis/call/sendVoiceCall.cjs +10 -8
- package/dist/cjs/apis/call/shareScreenGroupCall.cjs +50 -0
- package/dist/cjs/apis/call/unholdVoiceCall.cjs +39 -0
- package/dist/cjs/apis/call/updateCallMediaState.cjs +66 -0
- package/dist/cjs/apis/chat/getDirectMessageStatus.cjs +58 -0
- package/dist/cjs/apis/chat/getSuggestedConversations.cjs +29 -0
- package/dist/cjs/apis/chat/updatePinConversations.cjs +45 -0
- package/dist/cjs/apis/friend/getFriendProfilesV2.cjs +43 -0
- package/dist/cjs/apis/friend/getFriendsActivePCWeb.cjs +20 -0
- package/dist/cjs/apis/friend/verifyFriend.cjs +42 -0
- package/dist/cjs/apis/group/analyseGroup.cjs +33 -0
- package/dist/cjs/apis/group/checkQuotaCommunityMember.cjs +39 -0
- package/dist/cjs/apis/group/getE2eeGroupList.cjs +20 -0
- package/dist/cjs/apis/group/getGroupChatHistory.cjs +8 -7
- package/dist/cjs/apis/group/getGroupCloudMessagePath.cjs +69 -0
- package/dist/cjs/apis/group/getGroupHistoryLegacy.cjs +7 -6
- package/dist/cjs/apis/group/getGroupMessageStatus.cjs +7 -6
- package/dist/cjs/apis/group/getMultiGroupCloudMessages.cjs +34 -0
- package/dist/cjs/apis/media/getPersonalMedia.cjs +36 -0
- package/dist/cjs/apis/media/getPersonalMediaPreview.cjs +29 -0
- package/dist/cjs/apis/media/removePersonalMedia.cjs +33 -0
- package/dist/cjs/apis.cjs +210 -0
- package/dist/cjs/call-engine/ZRTPPacketCodec.cjs +525 -0
- package/dist/cjs/call-engine/ZaloCallController.cjs +643 -0
- package/dist/cjs/call-engine/ZaloCallTransport.cjs +239 -0
- package/dist/cjs/call-engine/ZaloRtcSession.cjs +2937 -0
- package/dist/cjs/call-engine/ZaloSrtpSession.cjs +287 -0
- package/dist/cjs/constants/protocol.cjs +1 -1
- package/dist/cjs/context.cjs +20 -2
- package/dist/cjs/core/zcloud-client.cjs +1 -2
- package/dist/cjs/crypto/ws-cipher.cjs +66 -2
- package/dist/cjs/index.cjs +63 -6
- package/dist/cjs/models/CallEvent.cjs +95 -1
- package/dist/cjs/realtime/handlers/control.handler.cjs +17 -3
- package/dist/cjs/realtime/listener.cjs +37 -6
- package/dist/cjs/update.cjs +10 -1
- package/dist/cjs/utils.cjs +21 -68
- package/dist/constants/protocol.d.ts +1 -1
- package/dist/constants/protocol.js +1 -1
- package/dist/context.d.ts +10 -0
- package/dist/context.js +20 -2
- package/dist/crypto/ws-cipher.d.ts +7 -0
- package/dist/crypto/ws-cipher.js +64 -2
- package/dist/index.d.ts +47 -4
- package/dist/index.js +2 -0
- package/dist/models/CallEvent.d.ts +15 -0
- package/dist/models/CallEvent.js +95 -1
- package/dist/realtime/handlers/control.handler.js +17 -3
- package/dist/realtime/listener.d.ts +6 -0
- package/dist/realtime/listener.js +37 -6
- package/dist/update.js +10 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.js +15 -64
- package/index.d.ts +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getFriendProfilesV2Factory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/getprofiles/v2`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy hàng loạt hồ sơ chi tiết của danh sách bạn bè kèm trạng thái online qua `/api/social/friend/getprofiles/v2` (command 11140)
|
|
7
|
+
*
|
|
8
|
+
* @param friendIds Mảng UID cần lấy hồ sơ (có thể kèm hậu tố `_version` hoặc truyền UID thuần)
|
|
9
|
+
* @param options Tùy chọn truy vấn
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getFriendProfilesV2(friendIds, options = {}) {
|
|
13
|
+
const rawIds = Array.isArray(friendIds) ? friendIds : [friendIds];
|
|
14
|
+
if (rawIds.length === 0) {
|
|
15
|
+
throw new ZaloApiError("Missing friendIds");
|
|
16
|
+
}
|
|
17
|
+
const friendPversionMap = rawIds.map((id) => (id.includes("_") ? id : `${id}_0`));
|
|
18
|
+
const params = {
|
|
19
|
+
phonebook_version: options.phonebookVersion ?? 0,
|
|
20
|
+
friend_pversion_map: friendPversionMap,
|
|
21
|
+
avatar_size: options.avatarSize ?? 120,
|
|
22
|
+
language: options.language ?? ctx.language ?? "vi",
|
|
23
|
+
show_online_status: options.showOnlineStatus !== false ? 1 : 0,
|
|
24
|
+
imei: ctx.imei,
|
|
25
|
+
};
|
|
26
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
27
|
+
if (!encryptedParams) {
|
|
28
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
29
|
+
}
|
|
30
|
+
const response = await utils.request(serviceURL, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
body: new URLSearchParams({
|
|
33
|
+
params: encryptedParams,
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
return utils.resolve(response);
|
|
37
|
+
};
|
|
38
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type GetFriendsActivePCWebResponse = {
|
|
2
|
+
uids?: string[];
|
|
3
|
+
activeUsers?: unknown[];
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const getFriendsActivePCWebFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => () => Promise<GetFriendsActivePCWebResponse>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { apiFactory } from "../../utils.js";
|
|
2
|
+
export const getFriendsActivePCWebFactory = apiFactory()((api, _ctx, utils) => {
|
|
3
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/active-pcweb`);
|
|
4
|
+
/**
|
|
5
|
+
* Lấy danh sách bạn bè đang hoạt động trên Zalo PC / Web qua `/api/social/friend/active-pcweb` (command 12072)
|
|
6
|
+
*
|
|
7
|
+
* @throws {ZaloApiError}
|
|
8
|
+
*/
|
|
9
|
+
return async function getFriendsActivePCWeb() {
|
|
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 VerifyFriendOptions = {
|
|
2
|
+
phonebookVersion?: number;
|
|
3
|
+
avatarSize?: number;
|
|
4
|
+
language?: string;
|
|
5
|
+
};
|
|
6
|
+
export type VerifyFriendResponse = {
|
|
7
|
+
profiles?: Record<string, unknown>;
|
|
8
|
+
unchangeds_profile?: string[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
export declare const verifyFriendFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (friendIds: string | string[], options?: VerifyFriendOptions) => Promise<VerifyFriendResponse>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const verifyFriendFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/friend/verify`);
|
|
5
|
+
/**
|
|
6
|
+
* Kiểm tra và xác thực danh sách bạn bè qua `/api/social/friend/verify` (command 11138)
|
|
7
|
+
*
|
|
8
|
+
* @param friendIds Danh sách UID bạn bè cần xác thực
|
|
9
|
+
* @param options Tùy chọn truy vấn
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function verifyFriend(friendIds, options = {}) {
|
|
13
|
+
const rawIds = Array.isArray(friendIds) ? friendIds : [friendIds];
|
|
14
|
+
if (rawIds.length === 0) {
|
|
15
|
+
throw new ZaloApiError("Missing friendIds");
|
|
16
|
+
}
|
|
17
|
+
const friendPversionMap = rawIds.map((id) => (id.includes("_") ? id : `${id}_0`));
|
|
18
|
+
const params = {
|
|
19
|
+
phonebook_version: options.phonebookVersion ?? 0,
|
|
20
|
+
friend_pversion_map: friendPversionMap,
|
|
21
|
+
avatar_size: options.avatarSize ?? 120,
|
|
22
|
+
language: options.language ?? ctx.language ?? "vi",
|
|
23
|
+
imei: ctx.imei,
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams) {
|
|
27
|
+
throw new 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
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const analyseGroupFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/analyse`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy dữ liệu phân tích/thống kê của nhóm qua `/api/group/analyse` (command 12407)
|
|
7
|
+
*
|
|
8
|
+
* @param groupId ID của nhóm
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function analyseGroup(groupId) {
|
|
12
|
+
if (!groupId) {
|
|
13
|
+
throw new ZaloApiError("Missing groupId");
|
|
14
|
+
}
|
|
15
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
16
|
+
const params = {
|
|
17
|
+
grid: cleanGroupId,
|
|
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,6 @@
|
|
|
1
|
+
export type CheckQuotaCommunityMemberResponse = {
|
|
2
|
+
status?: number;
|
|
3
|
+
canUpgrade?: boolean | number;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
export declare const checkQuotaCommunityMemberFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupId: string, uid: string) => Promise<CheckQuotaCommunityMemberResponse>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const checkQuotaCommunityMemberFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/quota/members-comm`);
|
|
5
|
+
/**
|
|
6
|
+
* Kiểm tra điều kiện/hạn mức thành viên Cộng đồng đối với một thành viên cụ thể trong nhóm (command 12182)
|
|
7
|
+
*
|
|
8
|
+
* @param groupId ID của nhóm
|
|
9
|
+
* @param uid UID của thành viên cần kiểm tra
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function checkQuotaCommunityMember(groupId, uid) {
|
|
13
|
+
if (!groupId) {
|
|
14
|
+
throw new ZaloApiError("Missing groupId");
|
|
15
|
+
}
|
|
16
|
+
if (!uid) {
|
|
17
|
+
throw new ZaloApiError("Missing uid");
|
|
18
|
+
}
|
|
19
|
+
const cleanGroupId = groupId.startsWith("g") ? groupId.slice(1) : groupId;
|
|
20
|
+
const params = {
|
|
21
|
+
language: ctx.language || "vi",
|
|
22
|
+
grId: cleanGroupId,
|
|
23
|
+
uid: String(uid),
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams) {
|
|
27
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
28
|
+
}
|
|
29
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
30
|
+
method: "GET",
|
|
31
|
+
});
|
|
32
|
+
return utils.resolve(response);
|
|
33
|
+
};
|
|
34
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type GetE2eeGroupListResponse = {
|
|
2
|
+
version?: number;
|
|
3
|
+
gridVerMap?: Record<string, string>;
|
|
4
|
+
e2eeGroups?: string[];
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const getE2eeGroupListFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => () => Promise<GetE2eeGroupListResponse>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { apiFactory } from "../../utils.js";
|
|
2
|
+
export const getE2eeGroupListFactory = apiFactory()((api, _ctx, utils) => {
|
|
3
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/getlg/e2ee`);
|
|
4
|
+
/**
|
|
5
|
+
* Lấy danh sách các nhóm đang bật mã hóa đầu cuối E2EE (command 12146)
|
|
6
|
+
*
|
|
7
|
+
* @throws {ZaloApiError}
|
|
8
|
+
*/
|
|
9
|
+
return async function getE2eeGroupList() {
|
|
10
|
+
const response = await utils.request(serviceURL, {
|
|
11
|
+
method: "GET",
|
|
12
|
+
});
|
|
13
|
+
return utils.resolve(response);
|
|
14
|
+
};
|
|
15
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GroupMessage } from "../../models/index.js";
|
|
2
|
+
export type GetGroupCloudMessagePathOptions = {
|
|
3
|
+
groupId: string;
|
|
4
|
+
globalMsgId: string | number;
|
|
5
|
+
count?: number;
|
|
6
|
+
reverse?: number | boolean;
|
|
7
|
+
rGlobalMsgId?: string | number;
|
|
8
|
+
rOwnerId?: string;
|
|
9
|
+
rClientMsgId?: string | number;
|
|
10
|
+
};
|
|
11
|
+
export type GetGroupCloudMessagePathResponse = {
|
|
12
|
+
lastMsgId?: string | number;
|
|
13
|
+
minMsgId?: string | number;
|
|
14
|
+
maxMsgId?: string | number;
|
|
15
|
+
hasMore?: boolean;
|
|
16
|
+
groupMsgs: GroupMessage[];
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
export declare const getGroupCloudMessagePathFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (options: GetGroupCloudMessagePathOptions) => Promise<GetGroupCloudMessagePathResponse>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { GroupMessage } from "../../models/index.js";
|
|
3
|
+
import { apiFactory, preParseJsonIds } from "../../utils.js";
|
|
4
|
+
export const getGroupCloudMessagePathFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/getpath`);
|
|
6
|
+
/**
|
|
7
|
+
* Lấy chuỗi tin nhắn nhóm theo đường dẫn nhảy tới một tin nhắn cụ thể (`globalMsgId` / `rGlobalMsgId`) qua `/api/cm/getpath` (command 12504)
|
|
8
|
+
*
|
|
9
|
+
* @param options Cấu hình truy vấn đường dẫn tin nhắn nhóm
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getGroupCloudMessagePath(options) {
|
|
13
|
+
if (!options?.groupId) {
|
|
14
|
+
throw new ZaloApiError("Missing groupId");
|
|
15
|
+
}
|
|
16
|
+
const cleanGroupId = options.groupId.startsWith("g") ? options.groupId.slice(1) : options.groupId;
|
|
17
|
+
const params = {
|
|
18
|
+
groupId: cleanGroupId,
|
|
19
|
+
globalMsgId: options.globalMsgId,
|
|
20
|
+
count: options.count ?? 50,
|
|
21
|
+
reverse: typeof options.reverse === "boolean" ? (options.reverse ? 1 : 0) : (options.reverse ?? 0),
|
|
22
|
+
};
|
|
23
|
+
if (options.rGlobalMsgId !== undefined && options.rOwnerId) {
|
|
24
|
+
params.rGlobalMsgId = options.rGlobalMsgId;
|
|
25
|
+
params.rOwnerId = options.rOwnerId;
|
|
26
|
+
if (options.rClientMsgId !== undefined) {
|
|
27
|
+
params.rClientMsgId = options.rClientMsgId;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
31
|
+
if (!encryptedParams) {
|
|
32
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
33
|
+
}
|
|
34
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams, nretry: 0 }), {
|
|
35
|
+
method: "GET",
|
|
36
|
+
});
|
|
37
|
+
return utils.resolve(response, (result) => {
|
|
38
|
+
let data = result.data;
|
|
39
|
+
if (typeof data === "string") {
|
|
40
|
+
data = JSON.parse(preParseJsonIds(data));
|
|
41
|
+
}
|
|
42
|
+
const rawObj = (data && typeof data === "object" ? data : {});
|
|
43
|
+
const rawMsgs = Array.isArray(rawObj.groupMsgs) ? rawObj.groupMsgs : [];
|
|
44
|
+
const groupMsgs = rawMsgs.map((m) => new GroupMessage(ctx.uid, m));
|
|
45
|
+
return {
|
|
46
|
+
...rawObj,
|
|
47
|
+
groupMsgs,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type GetMultiGroupCloudMessagesResponse = {
|
|
2
|
+
groupMsgs?: Record<string, unknown[]>;
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const getMultiGroupCloudMessagesFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (groupIds: string[], nretry?: number) => Promise<GetMultiGroupCloudMessagesResponse>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getMultiGroupCloudMessagesFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group_cloud_message[0]}/api/cm/mget`);
|
|
5
|
+
/**
|
|
6
|
+
* Đồng bộ nhanh tin nhắn Cloud của nhiều nhóm cùng lúc theo danh sách `groupIds` (command 12503 - `syncCloudMsgFirstLogin`)
|
|
7
|
+
*
|
|
8
|
+
* @param groupIds Danh sách ID nhóm cần tải tin nhắn Cloud
|
|
9
|
+
* @param nretry Số lần thử lại (mặc định: `0`)
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function getMultiGroupCloudMessages(groupIds, nretry = 0) {
|
|
13
|
+
if (!Array.isArray(groupIds) || groupIds.length === 0) {
|
|
14
|
+
throw new ZaloApiError("Missing groupIds");
|
|
15
|
+
}
|
|
16
|
+
const cleanGroupIds = groupIds.map((gid) => (gid.startsWith("g") ? gid.slice(1) : gid));
|
|
17
|
+
const params = {
|
|
18
|
+
groupIds: cleanGroupIds,
|
|
19
|
+
};
|
|
20
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
21
|
+
if (!encryptedParams) {
|
|
22
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
23
|
+
}
|
|
24
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams, nretry }), {
|
|
25
|
+
method: "GET",
|
|
26
|
+
});
|
|
27
|
+
return utils.resolve(response);
|
|
28
|
+
};
|
|
29
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GetConversationMediaResponse, MediaStoreType } from "./getConversationMedia.js";
|
|
2
|
+
export type GetPersonalMediaOptions = {
|
|
3
|
+
mediaType?: MediaStoreType;
|
|
4
|
+
limit?: number;
|
|
5
|
+
lastId?: number | string;
|
|
6
|
+
lastFetchId?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const getPersonalMediaFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (options?: GetPersonalMediaOptions) => Promise<GetConversationMediaResponse>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getPersonalMediaFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store_send2me[0]}/api/media/oneone/list`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách Kho Lưu Trữ Ảnh/Video (`"media"`), File (`"file"`), hoặc Link (`"link"`) trong Cloud của tôi (Send2Me) (command 12220)
|
|
7
|
+
*
|
|
8
|
+
* @param options Tùy chọn truy vấn (`mediaType`, `limit`, `lastId`, `lastFetchId`)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getPersonalMedia(options = {}) {
|
|
12
|
+
const params = {
|
|
13
|
+
media_type: options.mediaType ?? "media",
|
|
14
|
+
limit: options.limit ?? 20,
|
|
15
|
+
};
|
|
16
|
+
if (options.lastId !== undefined) {
|
|
17
|
+
params.last_id = options.lastId;
|
|
18
|
+
}
|
|
19
|
+
if (options.lastFetchId !== undefined && !Number.isNaN(options.lastFetchId)) {
|
|
20
|
+
params.lastFetchId = options.lastFetchId;
|
|
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: "GET",
|
|
28
|
+
});
|
|
29
|
+
return utils.resolve(response);
|
|
30
|
+
};
|
|
31
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MediaStoreItem } from "./getConversationMedia.js";
|
|
2
|
+
export type GetPersonalMediaPreviewResponse = MediaStoreItem[];
|
|
3
|
+
export declare const getPersonalMediaPreviewFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (limit?: number) => Promise<GetPersonalMediaPreviewResponse>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const getPersonalMediaPreviewFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store_send2me[0]}/api/media/oneone/preview`);
|
|
5
|
+
/**
|
|
6
|
+
* Lấy danh sách xem trước nhanh Kho Lưu Trữ trong Cloud của tôi (Send2Me) (command 12221)
|
|
7
|
+
*
|
|
8
|
+
* @param limit Số lượng mục tối đa (mặc định: `50`)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function getPersonalMediaPreview(limit = 50) {
|
|
12
|
+
const params = {
|
|
13
|
+
limit,
|
|
14
|
+
};
|
|
15
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
16
|
+
if (!encryptedParams) {
|
|
17
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
18
|
+
}
|
|
19
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
20
|
+
method: "POST",
|
|
21
|
+
});
|
|
22
|
+
return utils.resolve(response);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MediaStoreType } from "./getConversationMedia.js";
|
|
2
|
+
export type RemovePersonalMediaOptions = {
|
|
3
|
+
mediaType: MediaStoreType;
|
|
4
|
+
mediaId: number | string | Array<number | string>;
|
|
5
|
+
};
|
|
6
|
+
export type RemovePersonalMediaResponse = {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare const removePersonalMediaFactory: (ctx: import("../../context.js").ContextBase, api: import("../../apis.js").API) => (options: RemovePersonalMediaOptions) => Promise<RemovePersonalMediaResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../../utils.js";
|
|
3
|
+
export const removePersonalMediaFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.media_store_send2me[0]}/api/media/oneone/remove`);
|
|
5
|
+
/**
|
|
6
|
+
* Xóa mục lưu trữ trong Kho Lưu Trữ Cloud của tôi (Send2Me) (command 12222)
|
|
7
|
+
*
|
|
8
|
+
* @param options Thông tin mục cần xóa (`mediaType`, `mediaId`)
|
|
9
|
+
* @throws {ZaloApiError}
|
|
10
|
+
*/
|
|
11
|
+
return async function removePersonalMedia(options) {
|
|
12
|
+
if (!options?.mediaType || options.mediaId === undefined) {
|
|
13
|
+
throw new ZaloApiError("Missing mediaType or mediaId");
|
|
14
|
+
}
|
|
15
|
+
const params = {
|
|
16
|
+
media_type: options.mediaType,
|
|
17
|
+
media_id: options.mediaId,
|
|
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: "POST",
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|