@softtynet/zca-js 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/group/getGroupChatHistory.d.ts +37 -6
- package/dist/apis/group/getGroupChatHistory.js +41 -19
- package/dist/apis/group/getGroupHistoryLegacy.d.ts +7 -0
- package/dist/apis/group/getGroupHistoryLegacy.js +62 -0
- package/dist/apis/group/getGroupInfoV2.d.ts +30 -0
- package/dist/apis/group/getGroupInfoV2.js +48 -0
- package/dist/apis/group/getGroupListV3.d.ts +19 -0
- package/dist/apis/group/getGroupListV3.js +29 -0
- package/dist/apis/group/getGroupMessageStatus.d.ts +26 -0
- package/dist/apis/group/getGroupMessageStatus.js +77 -0
- package/dist/apis/media/getConversationMedia.d.ts +10 -0
- package/dist/apis.d.ts +12 -0
- package/dist/apis.js +20 -0
- package/dist/cjs/apis/group/getGroupChatHistory.cjs +43 -21
- package/dist/cjs/apis/group/getGroupHistoryLegacy.cjs +79 -0
- package/dist/cjs/apis/group/getGroupInfoV2.cjs +53 -0
- package/dist/cjs/apis/group/getGroupListV3.cjs +34 -0
- package/dist/cjs/apis/group/getGroupMessageStatus.cjs +82 -0
- package/dist/cjs/apis.cjs +20 -0
- package/dist/cjs/constants/endpoints.cjs +13 -0
- package/dist/cjs/constants/protocol.cjs +1 -1
- package/dist/cjs/index.cjs +2 -7
- package/dist/cjs/utils.cjs +65 -1
- package/dist/constants/endpoints.d.ts +13 -0
- package/dist/constants/endpoints.js +13 -0
- package/dist/constants/protocol.d.ts +1 -1
- package/dist/constants/protocol.js +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +63 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -68,8 +68,12 @@ export type { GetFriendRecommendationsResponse, FriendRecommendationsCollapseMsg
|
|
|
68
68
|
export type { GetFriendRequestStatusResponse } from "./apis/friend/getFriendRequestStatus.js";
|
|
69
69
|
export type { GetFullAvatarResponse } from "./apis/profile/getFullAvatar.js";
|
|
70
70
|
export type { GetGroupBlockedMemberPayload, GetGroupBlockedMemberResponse } from "./apis/group/getGroupBlockedMember.js";
|
|
71
|
-
export type { GetGroupChatHistoryResponse } from "./apis/group/getGroupChatHistory.js";
|
|
71
|
+
export type { GetGroupChatHistoryOptions, GetGroupChatHistoryResponse } from "./apis/group/getGroupChatHistory.js";
|
|
72
|
+
export type { GetGroupHistoryLegacyResponse } from "./apis/group/getGroupHistoryLegacy.js";
|
|
72
73
|
export type { GroupInfoPendingApprove, GroupInfoResponse } from "./apis/group/getGroupInfo.js";
|
|
74
|
+
export type { GetGroupInfoV2Options, GetGroupInfoV2Response } from "./apis/group/getGroupInfoV2.js";
|
|
75
|
+
export type { GetGroupListV3Options, GetGroupListV3Response } from "./apis/group/getGroupListV3.js";
|
|
76
|
+
export type { GetGroupMessageStatusQueryItem, GetGroupMessageStatusResponse, GroupMessageStatusMemberItem, GroupMessageStatusThreadInfo, } from "./apis/group/getGroupMessageStatus.js";
|
|
73
77
|
export type { GetGroupInviteBoxInfoPayload, GetGroupInviteBoxInfoResponse } from "./apis/group/getGroupInviteBoxInfo.js";
|
|
74
78
|
export type { GetGroupInviteBoxListPayload, GetGroupInviteBoxListResponse } from "./apis/group/getGroupInviteBoxList.js";
|
|
75
79
|
export type { GetGroupLinkDetailResponse } from "./apis/group/getGroupLinkDetail.js";
|
|
@@ -176,7 +180,7 @@ export type { GetBlockFriendsResponse } from "./apis/friend/getBlockFriends.js";
|
|
|
176
180
|
export type { GetCloudInfoResponse } from "./apis/zcloud/getCloudInfo.js";
|
|
177
181
|
export type { GetCloudSettingsResponse } from "./apis/zcloud/getCloudSettings.js";
|
|
178
182
|
export type { GetCloudViewerKeyResponse } from "./apis/zcloud/getCloudViewerKey.js";
|
|
179
|
-
export type { GetConversationMediaOptions, GetConversationMediaResponse } from "./apis/media/getConversationMedia.js";
|
|
183
|
+
export type { GetConversationMediaOptions, GetConversationMediaResponse, MediaStoreItem, MediaStoreType, } from "./apis/media/getConversationMedia.js";
|
|
180
184
|
export type { GetEmojiStatusConfigResponse } from "./apis/profile/getEmojiStatusConfig.js";
|
|
181
185
|
export type { GetExtraFriendInfoResponse } from "./apis/friend/getExtraFriendInfo.js";
|
|
182
186
|
export type { GetExtraGroupInfoResponse } from "./apis/group/getExtraGroupInfo.js";
|
|
@@ -221,4 +225,4 @@ export { ChatTTL } from "./apis/chat/updateAutoDeleteChat.js";
|
|
|
221
225
|
export { UpdateLangAvailableLanguages } from "./apis/auth/updateLang.js";
|
|
222
226
|
export { UpdateSettingsType } from "./apis/profile/updateSettings.js";
|
|
223
227
|
export { CallType } from "./apis/call/sendVoiceCall.js";
|
|
224
|
-
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, type ZdbTocEntry, } from "./utils.js";
|
|
228
|
+
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, preParseJsonIds, type ZdbTocEntry, } from "./utils.js";
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,4 @@ export { ChatTTL } from "./apis/chat/updateAutoDeleteChat.js";
|
|
|
16
16
|
export { UpdateLangAvailableLanguages } from "./apis/auth/updateLang.js";
|
|
17
17
|
export { UpdateSettingsType } from "./apis/profile/updateSettings.js";
|
|
18
18
|
export { CallType } from "./apis/call/sendVoiceCall.js";
|
|
19
|
-
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, } from "./utils.js";
|
|
19
|
+
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, preParseJsonIds, } from "./utils.js";
|
package/dist/utils.d.ts
CHANGED
|
@@ -112,6 +112,13 @@ export type ZaloResponse<T> = {
|
|
|
112
112
|
code?: number;
|
|
113
113
|
} | null;
|
|
114
114
|
};
|
|
115
|
+
export declare const DEFAULT_BIGINT_ID_FIELDS: readonly ["owner_id", "group_id", "uidFrom", "uidTo", "uid", "ownerId", "destId", "srcId", "fromUid", "threadId", "globalMsgId", "global_msg_id", "globalDelMsgId", "msgId", "refMessageId", "cliMsgId", "client_msg_id", "actionId", "lastActionIdOther", "lastActionId", "resetLastActionId", "lastId", "ids", "topicId", "reminderId", "eventId"];
|
|
116
|
+
/**
|
|
117
|
+
* Tiền xử lý chuỗi JSON trước khi `JSON.parse` (tương đương `preParse(e, t)` trong `app.asar` của Zalo PC).
|
|
118
|
+
* Bọc dấu ngoặc kép quanh các trường định danh 64-bit (`owner_id`, `group_id`, hoặc các số nguyên >= 16 chữ số
|
|
119
|
+
* vượt quá `Number.MAX_SAFE_INTEGER`) để tránh mất 3 chữ số cuối của UID/MsgId do làm tròn IEEE-754.
|
|
120
|
+
*/
|
|
121
|
+
export declare function preParseJsonIds(jsonStr: string, alwaysStringFields?: readonly string[], bigIntSafeFields?: readonly string[]): string;
|
|
115
122
|
export declare function handleZaloResponse<T = unknown>(ctx: ContextSession, response: Response, isEncrypted?: boolean): Promise<ZaloResponse<T>>;
|
|
116
123
|
export declare function resolveResponse<T = unknown>(ctx: ContextSession, res: Response, cb?: (result: ZaloResponse<unknown>) => T, isEncrypted?: boolean): Promise<T>;
|
|
117
124
|
export type FactoryUtils<T> = {
|
package/dist/utils.js
CHANGED
|
@@ -447,6 +447,67 @@ export function getFriendEventType(act) {
|
|
|
447
447
|
return FriendEventType.PIN_CREATE;
|
|
448
448
|
return FriendEventType.UNKNOWN;
|
|
449
449
|
}
|
|
450
|
+
export const DEFAULT_BIGINT_ID_FIELDS = [
|
|
451
|
+
"owner_id",
|
|
452
|
+
"group_id",
|
|
453
|
+
"uidFrom",
|
|
454
|
+
"uidTo",
|
|
455
|
+
"uid",
|
|
456
|
+
"ownerId",
|
|
457
|
+
"destId",
|
|
458
|
+
"srcId",
|
|
459
|
+
"fromUid",
|
|
460
|
+
"threadId",
|
|
461
|
+
"globalMsgId",
|
|
462
|
+
"global_msg_id",
|
|
463
|
+
"globalDelMsgId",
|
|
464
|
+
"msgId",
|
|
465
|
+
"refMessageId",
|
|
466
|
+
"cliMsgId",
|
|
467
|
+
"client_msg_id",
|
|
468
|
+
"actionId",
|
|
469
|
+
"lastActionIdOther",
|
|
470
|
+
"lastActionId",
|
|
471
|
+
"resetLastActionId",
|
|
472
|
+
"lastId",
|
|
473
|
+
"ids",
|
|
474
|
+
"topicId",
|
|
475
|
+
"reminderId",
|
|
476
|
+
"eventId",
|
|
477
|
+
];
|
|
478
|
+
/**
|
|
479
|
+
* Tiền xử lý chuỗi JSON trước khi `JSON.parse` (tương đương `preParse(e, t)` trong `app.asar` của Zalo PC).
|
|
480
|
+
* Bọc dấu ngoặc kép quanh các trường định danh 64-bit (`owner_id`, `group_id`, hoặc các số nguyên >= 16 chữ số
|
|
481
|
+
* vượt quá `Number.MAX_SAFE_INTEGER`) để tránh mất 3 chữ số cuối của UID/MsgId do làm tròn IEEE-754.
|
|
482
|
+
*/
|
|
483
|
+
export function preParseJsonIds(jsonStr, alwaysStringFields = ["owner_id", "group_id"], bigIntSafeFields = DEFAULT_BIGINT_ID_FIELDS) {
|
|
484
|
+
if (!jsonStr || typeof jsonStr !== "string")
|
|
485
|
+
return jsonStr;
|
|
486
|
+
const alwaysSet = new Set(alwaysStringFields);
|
|
487
|
+
const allFields = Array.from(new Set([...alwaysStringFields, ...bigIntSafeFields]));
|
|
488
|
+
if (allFields.length === 0)
|
|
489
|
+
return jsonStr;
|
|
490
|
+
const escapedKeys = allFields.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
491
|
+
const keyValueRegex = new RegExp(`"(${escapedKeys})"(\\s*:\\s*)(\\d+|\\[\\s*\\d+(?:\\s*,\\s*\\d+)*\\s*\\])`, "g");
|
|
492
|
+
return jsonStr.replace(keyValueRegex, (fullMatch, key, sep, rawVal) => {
|
|
493
|
+
const forceString = alwaysSet.has(key);
|
|
494
|
+
if (rawVal.startsWith("[")) {
|
|
495
|
+
const inner = rawVal.slice(1, -1);
|
|
496
|
+
const parts = inner.split(",").map((part) => {
|
|
497
|
+
const trimmed = part.trim();
|
|
498
|
+
if (forceString || trimmed.length >= 16 || Number(trimmed) > Number.MAX_SAFE_INTEGER) {
|
|
499
|
+
return `"${trimmed}"`;
|
|
500
|
+
}
|
|
501
|
+
return trimmed;
|
|
502
|
+
});
|
|
503
|
+
return `"${key}"${sep}[${parts.join(",")}]`;
|
|
504
|
+
}
|
|
505
|
+
if (forceString || rawVal.length >= 16 || Number(rawVal) > Number.MAX_SAFE_INTEGER) {
|
|
506
|
+
return `"${key}"${sep}"${rawVal}"`;
|
|
507
|
+
}
|
|
508
|
+
return fullMatch;
|
|
509
|
+
});
|
|
510
|
+
}
|
|
450
511
|
export async function handleZaloResponse(ctx, response, isEncrypted = true) {
|
|
451
512
|
const result = {
|
|
452
513
|
data: null,
|
|
@@ -476,7 +537,8 @@ export async function handleZaloResponse(ctx, response, isEncrypted = true) {
|
|
|
476
537
|
result.data = {};
|
|
477
538
|
return result;
|
|
478
539
|
}
|
|
479
|
-
const
|
|
540
|
+
const safeJsonStr = isEncrypted ? preParseJsonIds(decodedStr) : null;
|
|
541
|
+
const decodedData = isEncrypted ? JSON.parse(safeJsonStr) : jsonData;
|
|
480
542
|
if (decodedData.error_code != 0) {
|
|
481
543
|
result.error = {
|
|
482
544
|
message: decodedData.error_message,
|