@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
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./models/index.js";
|
|
|
3
3
|
export * from "./constants/index.js";
|
|
4
4
|
export * from "./crypto/index.js";
|
|
5
5
|
export * from "./core/index.js";
|
|
6
|
+
export * from "./realtime/index.js";
|
|
6
7
|
export * from "./zalo.js";
|
|
7
8
|
export type { AuthDomainAPI, BoardDomainAPI, BusinessDomainAPI, CallDomainAPI, ChatDomainAPI, FriendDomainAPI, GroupDomainAPI, MediaDomainAPI, ProfileDomainAPI, StickerDomainAPI, SyncDomainAPI, ZcloudDomainAPI, } from "./apis.js";
|
|
8
9
|
export type { ContextSession, ContextBase, AppContextExtended, AppContextBase, Options, ZPWServiceMap, ImageMetadataGetter, ImageMetadataGetterResponse, ViewerKeyCacheEntry } from "./context.js";
|
|
@@ -74,6 +75,21 @@ export type { GroupInfoPendingApprove, GroupInfoResponse } from "./apis/group/ge
|
|
|
74
75
|
export type { GetGroupInfoV2Options, GetGroupInfoV2Response } from "./apis/group/getGroupInfoV2.js";
|
|
75
76
|
export type { GetGroupListV3Options, GetGroupListV3Response } from "./apis/group/getGroupListV3.js";
|
|
76
77
|
export type { GetGroupMessageStatusQueryItem, GetGroupMessageStatusResponse, GroupMessageStatusMemberItem, GroupMessageStatusThreadInfo, } from "./apis/group/getGroupMessageStatus.js";
|
|
78
|
+
export type { CheckQuotaCommunityMemberResponse } from "./apis/group/checkQuotaCommunityMember.js";
|
|
79
|
+
export type { GetE2eeGroupListResponse } from "./apis/group/getE2eeGroupList.js";
|
|
80
|
+
export type { GetMultiGroupCloudMessagesResponse } from "./apis/group/getMultiGroupCloudMessages.js";
|
|
81
|
+
export type { GetGroupCloudMessagePathOptions, GetGroupCloudMessagePathResponse } from "./apis/group/getGroupCloudMessagePath.js";
|
|
82
|
+
export type { AnalyseGroupResponse } from "./apis/group/analyseGroup.js";
|
|
83
|
+
export type { DirectMessageStatusItem, GetDirectMessageStatusResponse } from "./apis/chat/getDirectMessageStatus.js";
|
|
84
|
+
export type { GetSuggestedConversationsResponse } from "./apis/chat/getSuggestedConversations.js";
|
|
85
|
+
export type { UpdatePinConversationsOptions, UpdatePinConversationsResponse } from "./apis/chat/updatePinConversations.js";
|
|
86
|
+
export type { GetFriendProfilesV2Options, GetFriendProfilesV2Response } from "./apis/friend/getFriendProfilesV2.js";
|
|
87
|
+
export type { GetFriendsActivePCWebResponse } from "./apis/friend/getFriendsActivePCWeb.js";
|
|
88
|
+
export type { VerifyFriendOptions, VerifyFriendResponse } from "./apis/friend/verifyFriend.js";
|
|
89
|
+
export type { GetPersonalMediaOptions } from "./apis/media/getPersonalMedia.js";
|
|
90
|
+
export type { GetPersonalMediaPreviewResponse } from "./apis/media/getPersonalMediaPreview.js";
|
|
91
|
+
export type { RemovePersonalMediaOptions, RemovePersonalMediaResponse } from "./apis/media/removePersonalMedia.js";
|
|
92
|
+
export type { ExportedSession } from "./apis/auth/exportSession.js";
|
|
77
93
|
export type { GetGroupInviteBoxInfoPayload, GetGroupInviteBoxInfoResponse } from "./apis/group/getGroupInviteBoxInfo.js";
|
|
78
94
|
export type { GetGroupInviteBoxListPayload, GetGroupInviteBoxListResponse } from "./apis/group/getGroupInviteBoxList.js";
|
|
79
95
|
export type { GetGroupLinkDetailResponse } from "./apis/group/getGroupLinkDetail.js";
|
|
@@ -85,6 +101,7 @@ export type { GetListBankResponse } from "./apis/business/getListBank.js";
|
|
|
85
101
|
export type { GetListBankAccountResponse } from "./apis/business/getListBankAccount.js";
|
|
86
102
|
export type { BoardItem, GetListBoardResponse, ListBoardOptions } from "./apis/board/getListBoard.js";
|
|
87
103
|
export type { GetListDeviceResponse } from "./apis/auth/getListDevice.js";
|
|
104
|
+
export type { GetListPinTopicsResponse } from "./apis/board/getListPinTopics.js";
|
|
88
105
|
export type { GetListReminderResponse, ListReminderOptions, ReminderListGroup, ReminderListUser } from "./apis/board/getListReminder.js";
|
|
89
106
|
export type { GetMultiUsersByPhonesResponse } from "./apis/friend/getMultiUsersByPhones.js";
|
|
90
107
|
export type { GetMuteResponse, MuteEntriesInfo } from "./apis/chat/getMute.js";
|
|
@@ -145,7 +162,7 @@ export type { SendStickerResponse, SendStickerPayload } from "./apis/chat/sendSt
|
|
|
145
162
|
export type { SendTypingEventResponse } from "./apis/chat/sendTypingEvent.js";
|
|
146
163
|
export type { SendVideoOptions, SendVideoResponse } from "./apis/chat/sendVideo.js";
|
|
147
164
|
export type { SendVoiceOptions, SendVoiceResponse } from "./apis/chat/sendVoice.js";
|
|
148
|
-
export type { RequestCallServerInfo, SendVoiceCallOptions, SendVoiceCallResponse } from "./apis/call/sendVoiceCall.js";
|
|
165
|
+
export type { RequestCallServerEntry, RequestCallServerInfo, SendVoiceCallOptions, SendVoiceCallResponse } from "./apis/call/sendVoiceCall.js";
|
|
149
166
|
export type { SetHiddenConversationsResponse } from "./apis/chat/setHiddenConversations.js";
|
|
150
167
|
export type { SetMuteParams, SetMuteResponse } from "./apis/chat/setMute.js";
|
|
151
168
|
export type { SetPinnedConversationsResponse } from "./apis/chat/setPinnedConversations.js";
|
|
@@ -175,15 +192,15 @@ export type { VotePollResponse } from "./apis/board/votePoll.js";
|
|
|
175
192
|
export type { CustomAPICallback, CustomAPIProps } from "./apis/custom.js";
|
|
176
193
|
export type { ClearUnreadFriendRequestsResponse } from "./apis/friend/clearUnreadFriendRequests.js";
|
|
177
194
|
export type { EncryptGidsResponse } from "./apis/auth/encryptGids.js";
|
|
178
|
-
export type { GetAliasListV2Response } from "./apis/friend/getAliasListV2.js";
|
|
195
|
+
export type { AliasItemV2, GetAliasListV2Response } from "./apis/friend/getAliasListV2.js";
|
|
179
196
|
export type { GetBlockFriendsResponse } from "./apis/friend/getBlockFriends.js";
|
|
180
197
|
export type { GetCloudInfoResponse } from "./apis/zcloud/getCloudInfo.js";
|
|
181
198
|
export type { GetCloudSettingsResponse } from "./apis/zcloud/getCloudSettings.js";
|
|
182
199
|
export type { GetCloudViewerKeyResponse } from "./apis/zcloud/getCloudViewerKey.js";
|
|
183
200
|
export type { GetConversationMediaOptions, GetConversationMediaResponse, MediaStoreItem, MediaStoreType, } from "./apis/media/getConversationMedia.js";
|
|
184
|
-
export type { GetEmojiStatusConfigResponse } from "./apis/profile/getEmojiStatusConfig.js";
|
|
201
|
+
export type { EmojiStatusItem, GetEmojiStatusConfigResponse } from "./apis/profile/getEmojiStatusConfig.js";
|
|
185
202
|
export type { GetExtraFriendInfoResponse } from "./apis/friend/getExtraFriendInfo.js";
|
|
186
|
-
export type { GetExtraGroupInfoResponse } from "./apis/group/getExtraGroupInfo.js";
|
|
203
|
+
export type { ExtraContextInfo, GetExtraGroupInfoResponse } from "./apis/group/getExtraGroupInfo.js";
|
|
187
204
|
export type { GetFamilyProfileResponse } from "./apis/zcloud/getFamilyProfile.js";
|
|
188
205
|
export type { GetFamilyUsageResponse } from "./apis/zcloud/getFamilyUsage.js";
|
|
189
206
|
export type { GetFamilyViewerKeyResponse } from "./apis/zcloud/getFamilyViewerKey.js";
|
|
@@ -214,6 +231,31 @@ export type { UpdateRecentSearchOptions, UpdateRecentSearchResponse } from "./ap
|
|
|
214
231
|
export type { VerifyCloudMediaOptions, VerifyCloudMediaResponse } from "./apis/zcloud/verifyCloudMedia.js";
|
|
215
232
|
export type { VoiceToTextResponse } from "./apis/media/voiceToText.js";
|
|
216
233
|
export type { Voice2TextEvent, Voice2TextEventData } from "./apis/listen.js";
|
|
234
|
+
export type { AddUserGroupCallOptions, AddUserGroupCallResponse } from "./apis/call/addUserGroupCall.js";
|
|
235
|
+
export type { AnswerAckVoiceCallOptions, AnswerAckVoiceCallResponse } from "./apis/call/answerAckVoiceCall.js";
|
|
236
|
+
export type { AnswerGroupCallOptions, AnswerGroupCallResponse } from "./apis/call/answerGroupCall.js";
|
|
237
|
+
export type { AnswerVoiceCallOptions, AnswerVoiceCallResponse } from "./apis/call/answerVoiceCall.js";
|
|
238
|
+
export type { BroadcastGroupCallStateOptions, BroadcastGroupCallStateResponse } from "./apis/call/broadcastGroupCallState.js";
|
|
239
|
+
export type { CancelGroupCallOptions, CancelGroupCallResponse } from "./apis/call/cancelGroupCall.js";
|
|
240
|
+
export type { EndGroupCallOptions, EndGroupCallResponse } from "./apis/call/endGroupCall.js";
|
|
241
|
+
export type { FinishGroupCallOptions, FinishGroupCallResponse } from "./apis/call/finishGroupCall.js";
|
|
242
|
+
export type { GetGroupCallStateResponse } from "./apis/call/getGroupCallState.js";
|
|
243
|
+
export type { HoldVoiceCallOptions, HoldVoiceCallResponse } from "./apis/call/holdVoiceCall.js";
|
|
244
|
+
export type { JoinGroupCallOptions, JoinGroupCallResponse } from "./apis/call/joinGroupCall.js";
|
|
245
|
+
export type { LogEndVoiceCallOptions, LogEndVoiceCallResponse } from "./apis/call/logEndVoiceCall.js";
|
|
246
|
+
export type { NotifyGroupCallOptions, NotifyGroupCallResponse } from "./apis/call/notifyGroupCall.js";
|
|
247
|
+
export type { PingGroupCallOptions, PingGroupCallResponse } from "./apis/call/pingGroupCall.js";
|
|
248
|
+
export type { RequestAudioToVideoCallOptions, RequestAudioToVideoCallResponse } from "./apis/call/requestAudioToVideoCall.js";
|
|
249
|
+
export type { RequestGroupCallOptions, RequestGroupCallResponse } from "./apis/call/requestGroupCall.js";
|
|
250
|
+
export type { RequestShareScreenCallOptions, RequestShareScreenCallResponse } from "./apis/call/requestShareScreenCall.js";
|
|
251
|
+
export type { RequestVoiceCallOptions, RequestVoiceCallResponse } from "./apis/call/requestVoiceCall.js";
|
|
252
|
+
export type { RingRingGroupCallOptions, RingRingGroupCallResponse } from "./apis/call/ringRingGroupCall.js";
|
|
253
|
+
export type { RingRingVoiceCallOptions, RingRingVoiceCallResponse } from "./apis/call/ringRingVoiceCall.js";
|
|
254
|
+
export type { SendRequestGroupCallOptions, SendRequestGroupCallResponse } from "./apis/call/sendRequestGroupCall.js";
|
|
255
|
+
export type { SendRequestVoiceCallOptions, SendRequestVoiceCallResponse } from "./apis/call/sendRequestVoiceCall.js";
|
|
256
|
+
export type { ShareScreenGroupCallOptions, ShareScreenGroupCallResponse } from "./apis/call/shareScreenGroupCall.js";
|
|
257
|
+
export type { UnholdVoiceCallOptions, UnholdVoiceCallResponse } from "./apis/call/unholdVoiceCall.js";
|
|
258
|
+
export type { UpdateCallMediaStateOptions, UpdateCallMediaStateResponse } from "./apis/call/updateCallMediaState.js";
|
|
217
259
|
export { CloseReason } from "./apis/listen.js";
|
|
218
260
|
export { LoginQRCallbackEventType } from "./apis/loginQR.js";
|
|
219
261
|
export { FriendRecommendationsType } from "./apis/friend/getFriendRecommendations.js";
|
|
@@ -225,4 +267,5 @@ export { ChatTTL } from "./apis/chat/updateAutoDeleteChat.js";
|
|
|
225
267
|
export { UpdateLangAvailableLanguages } from "./apis/auth/updateLang.js";
|
|
226
268
|
export { UpdateSettingsType } from "./apis/profile/updateSettings.js";
|
|
227
269
|
export { CallType } from "./apis/call/sendVoiceCall.js";
|
|
270
|
+
export { DEFAULT_ZALOCALL_IPC_KEY_BASE64, DEFAULT_ZALO_AUDIO_CODEC, DEFAULT_ZALO_VIDEO_CODEC, ZRTCMediaSubCommand, ZRTPControlCommand, ZRTPForwardSubCommand, ZRTPLegacyMediaType, ZRTCRole, ZaloCallController, ZaloCallTransport, ZaloRtcSession, ZaloSrtpSession, buildEchoRequest, buildEndCallRequest, buildInitCallRequest, buildInitCallResponse, buildPingRequest, buildPingResponse, buildRelayPingRequest, buildRequestForwardPacket, buildRtpPacket, buildZrtcExtendData, deriveSrtpSessionKey, generateSrtpMasterKeyBase64, parseIncomingCallEvent, parseRtpPacket, parseZRTPPacket, uidToUint32, wrapLegacyMediaPacket, wrapZrtcMediaPacket, type AcceptIncomingCallOptions, type BuildRtpPacketOptions, type IncomingAudioFrameEvent, type IncomingRtcpEvent, type IncomingRtpEvent, type IncomingVideoAnnexBFrameEvent, type IncomingVideoFrameEvent, type JoinGroupCallSessionOptions, type MakeDesktopCallOptions, type MakeDesktopGroupCallOptions, type ParsedIncomingCallInfo, type ParsedRtpPacket, type ParsedZRTPPacket, type RejectIncomingCallOptions, type SrtpCryptoSuite, type StartGroupCallOptions, type StartOutgoingCallOptions, type ZRTCMultiplexedMediaPacket, type ZRTCP2PPacket, type ZRTPControlPacket, type ZRTPEchoRequestOptions, type ZRTPEndCallRequestOptions, type ZRTPInitCallRequestOptions, type ZRTPInitCallResponseOptions, type ZRTPLegacyMediaPacket, type ZRTPPingRequestOptions, type ZRTPRawPacket, type ZRTPRelayPingRequestOptions, type ZRTPRequestForwardOptions, type ZaloCallConnectionParams, type ZaloCallControllerEvents, type ZaloCallControllerOptions, type ZaloCallIpcMessage, type ZaloCallMediaStateEvent, type ZaloCallSignalPayload, type ZaloCallTransportEvents, type ZaloCallTransportOptions, type ZaloMobileDirectHandoffBundle, type ZaloRtcSessionEvents, type ZaloRtcSessionOptions, type ZaloRtcSessionState, type ZrtcExtendDataOptions, } from "./call-engine/index.js";
|
|
228
271
|
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, preParseJsonIds, type ZdbTocEntry, } from "./utils.js";
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./models/index.js";
|
|
|
3
3
|
export * from "./constants/index.js";
|
|
4
4
|
export * from "./crypto/index.js";
|
|
5
5
|
export * from "./core/index.js";
|
|
6
|
+
export * from "./realtime/index.js";
|
|
6
7
|
export * from "./zalo.js";
|
|
7
8
|
// Others (Enum)
|
|
8
9
|
export { CloseReason } from "./apis/listen.js";
|
|
@@ -16,4 +17,5 @@ export { ChatTTL } from "./apis/chat/updateAutoDeleteChat.js";
|
|
|
16
17
|
export { UpdateLangAvailableLanguages } from "./apis/auth/updateLang.js";
|
|
17
18
|
export { UpdateSettingsType } from "./apis/profile/updateSettings.js";
|
|
18
19
|
export { CallType } from "./apis/call/sendVoiceCall.js";
|
|
20
|
+
export { DEFAULT_ZALOCALL_IPC_KEY_BASE64, DEFAULT_ZALO_AUDIO_CODEC, DEFAULT_ZALO_VIDEO_CODEC, ZRTCMediaSubCommand, ZRTPControlCommand, ZRTPForwardSubCommand, ZRTPLegacyMediaType, ZRTCRole, ZaloCallController, ZaloCallTransport, ZaloRtcSession, ZaloSrtpSession, buildEchoRequest, buildEndCallRequest, buildInitCallRequest, buildInitCallResponse, buildPingRequest, buildPingResponse, buildRelayPingRequest, buildRequestForwardPacket, buildRtpPacket, buildZrtcExtendData, deriveSrtpSessionKey, generateSrtpMasterKeyBase64, parseIncomingCallEvent, parseRtpPacket, parseZRTPPacket, uidToUint32, wrapLegacyMediaPacket, wrapZrtcMediaPacket, } from "./call-engine/index.js";
|
|
19
21
|
export { generateRSAKeyPair, decryptWithPrivateKey, deriveZdbAesKey, decryptZdbBuffer, parseZdbHeader, encryptZCloudAES, decryptZCloudAES, preParseJsonIds, } from "./utils.js";
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
export declare enum CallEventType {
|
|
2
2
|
REQUEST = "request",
|
|
3
3
|
ANSWER = "answer",
|
|
4
|
+
ANSWER_ACK = "answer_ack",
|
|
4
5
|
CANCEL = "cancel",
|
|
5
6
|
END = "end",
|
|
6
7
|
RINGRING = "ringring",
|
|
8
|
+
ONOFF_CAMERA = "onoff_camera",
|
|
9
|
+
MUTE_AUDIO = "mute_audio",
|
|
10
|
+
AUDIO_TO_VIDEO = "audio_to_video",
|
|
11
|
+
SHARE_SCREEN = "share_screen",
|
|
7
12
|
GROUP_REQUEST = "group_request",
|
|
13
|
+
GROUP_RINGRING = "group_ring_ring",
|
|
8
14
|
GROUP_ANSWER = "group_answer",
|
|
15
|
+
GROUP_ANSWER_ACK = "group_answer_ack",
|
|
16
|
+
GROUP_CANCEL = "group_cancel",
|
|
17
|
+
GROUP_END = "group_end_call",
|
|
18
|
+
GROUP_ADD_USER = "group_add_user",
|
|
19
|
+
GROUP_NOTIFY = "group_notify",
|
|
20
|
+
GROUP_BROADCAST = "group_broadcast",
|
|
21
|
+
GROUP_BROADCAST_CONFIG = "group_broadcast_config",
|
|
9
22
|
UNKNOWN = "unknown"
|
|
10
23
|
}
|
|
11
24
|
export type TCallEventData = {
|
|
@@ -18,6 +31,8 @@ export type TCallEventData = {
|
|
|
18
31
|
sessId?: string;
|
|
19
32
|
status?: number;
|
|
20
33
|
callType?: number;
|
|
34
|
+
codec?: string;
|
|
35
|
+
params?: string | Record<string, unknown>;
|
|
21
36
|
ts?: number | string;
|
|
22
37
|
[key: string]: unknown;
|
|
23
38
|
};
|
package/dist/models/CallEvent.js
CHANGED
|
@@ -2,11 +2,24 @@ export var CallEventType;
|
|
|
2
2
|
(function (CallEventType) {
|
|
3
3
|
CallEventType["REQUEST"] = "request";
|
|
4
4
|
CallEventType["ANSWER"] = "answer";
|
|
5
|
+
CallEventType["ANSWER_ACK"] = "answer_ack";
|
|
5
6
|
CallEventType["CANCEL"] = "cancel";
|
|
6
7
|
CallEventType["END"] = "end";
|
|
7
8
|
CallEventType["RINGRING"] = "ringring";
|
|
9
|
+
CallEventType["ONOFF_CAMERA"] = "onoff_camera";
|
|
10
|
+
CallEventType["MUTE_AUDIO"] = "mute_audio";
|
|
11
|
+
CallEventType["AUDIO_TO_VIDEO"] = "audio_to_video";
|
|
12
|
+
CallEventType["SHARE_SCREEN"] = "share_screen";
|
|
8
13
|
CallEventType["GROUP_REQUEST"] = "group_request";
|
|
14
|
+
CallEventType["GROUP_RINGRING"] = "group_ring_ring";
|
|
9
15
|
CallEventType["GROUP_ANSWER"] = "group_answer";
|
|
16
|
+
CallEventType["GROUP_ANSWER_ACK"] = "group_answer_ack";
|
|
17
|
+
CallEventType["GROUP_CANCEL"] = "group_cancel";
|
|
18
|
+
CallEventType["GROUP_END"] = "group_end_call";
|
|
19
|
+
CallEventType["GROUP_ADD_USER"] = "group_add_user";
|
|
20
|
+
CallEventType["GROUP_NOTIFY"] = "group_notify";
|
|
21
|
+
CallEventType["GROUP_BROADCAST"] = "group_broadcast";
|
|
22
|
+
CallEventType["GROUP_BROADCAST_CONFIG"] = "group_broadcast_config";
|
|
10
23
|
CallEventType["UNKNOWN"] = "unknown";
|
|
11
24
|
})(CallEventType || (CallEventType = {}));
|
|
12
25
|
export function initializeCallEvent(data, act, act_type) {
|
|
@@ -18,30 +31,111 @@ export function initializeCallEvent(data, act, act_type) {
|
|
|
18
31
|
case "answer":
|
|
19
32
|
type = CallEventType.ANSWER;
|
|
20
33
|
break;
|
|
34
|
+
case "answer_ack":
|
|
35
|
+
case "answerack":
|
|
36
|
+
type = CallEventType.ANSWER_ACK;
|
|
37
|
+
break;
|
|
21
38
|
case "cancel":
|
|
22
39
|
type = CallEventType.CANCEL;
|
|
23
40
|
break;
|
|
24
41
|
case "end":
|
|
25
42
|
case "endcall":
|
|
43
|
+
case "end_call":
|
|
26
44
|
type = CallEventType.END;
|
|
27
45
|
break;
|
|
28
46
|
case "ringring":
|
|
47
|
+
case "ring_ring":
|
|
29
48
|
type = CallEventType.RINGRING;
|
|
30
49
|
break;
|
|
50
|
+
case "onoff_camera":
|
|
51
|
+
type = CallEventType.ONOFF_CAMERA;
|
|
52
|
+
break;
|
|
53
|
+
case "mute_audio":
|
|
54
|
+
type = CallEventType.MUTE_AUDIO;
|
|
55
|
+
break;
|
|
56
|
+
case "audio_to_video":
|
|
57
|
+
type = CallEventType.AUDIO_TO_VIDEO;
|
|
58
|
+
break;
|
|
59
|
+
case "share_screen":
|
|
60
|
+
type = CallEventType.SHARE_SCREEN;
|
|
61
|
+
break;
|
|
31
62
|
case "group_request":
|
|
32
63
|
type = CallEventType.GROUP_REQUEST;
|
|
33
64
|
break;
|
|
65
|
+
case "group_ring_ring":
|
|
66
|
+
case "group_ringring":
|
|
67
|
+
type = CallEventType.GROUP_RINGRING;
|
|
68
|
+
break;
|
|
34
69
|
case "group_answer":
|
|
35
70
|
type = CallEventType.GROUP_ANSWER;
|
|
36
71
|
break;
|
|
72
|
+
case "group_answer_ack":
|
|
73
|
+
type = CallEventType.GROUP_ANSWER_ACK;
|
|
74
|
+
break;
|
|
75
|
+
case "group_cancel":
|
|
76
|
+
type = CallEventType.GROUP_CANCEL;
|
|
77
|
+
break;
|
|
78
|
+
case "group_end_call":
|
|
79
|
+
case "group_endcall":
|
|
80
|
+
case "group_end":
|
|
81
|
+
type = CallEventType.GROUP_END;
|
|
82
|
+
break;
|
|
83
|
+
case "group_add_user":
|
|
84
|
+
type = CallEventType.GROUP_ADD_USER;
|
|
85
|
+
break;
|
|
86
|
+
case "group_notify":
|
|
87
|
+
type = CallEventType.GROUP_NOTIFY;
|
|
88
|
+
break;
|
|
89
|
+
case "group_broadcast":
|
|
90
|
+
type = CallEventType.GROUP_BROADCAST;
|
|
91
|
+
break;
|
|
92
|
+
case "group_broadcast_config":
|
|
93
|
+
type = CallEventType.GROUP_BROADCAST_CONFIG;
|
|
94
|
+
break;
|
|
37
95
|
default:
|
|
38
96
|
type = CallEventType.UNKNOWN;
|
|
39
97
|
break;
|
|
40
98
|
}
|
|
99
|
+
const enrichedData = { ...data };
|
|
100
|
+
let parsedParams;
|
|
101
|
+
if (typeof enrichedData.params === "string") {
|
|
102
|
+
try {
|
|
103
|
+
const p = JSON.parse(enrichedData.params);
|
|
104
|
+
if (p && typeof p === "object")
|
|
105
|
+
parsedParams = p;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Ignore invalid JSON
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (enrichedData.params && typeof enrichedData.params === "object") {
|
|
112
|
+
parsedParams = enrichedData.params;
|
|
113
|
+
}
|
|
114
|
+
if (enrichedData.callId === undefined) {
|
|
115
|
+
const extractedCallId = Number(enrichedData.call_id ??
|
|
116
|
+
enrichedData.id ??
|
|
117
|
+
parsedParams?.callId ??
|
|
118
|
+
parsedParams?.call_id ??
|
|
119
|
+
parsedParams?.id ??
|
|
120
|
+
0);
|
|
121
|
+
if (extractedCallId > 0) {
|
|
122
|
+
enrichedData.callId = extractedCallId;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (enrichedData.callerId === undefined) {
|
|
126
|
+
const extractedCallerId = enrichedData.uidN ??
|
|
127
|
+
parsedParams?.uidN ??
|
|
128
|
+
enrichedData.uidFrom ??
|
|
129
|
+
enrichedData.fromId ??
|
|
130
|
+
parsedParams?.uidFrom;
|
|
131
|
+
if (extractedCallerId !== undefined) {
|
|
132
|
+
enrichedData.callerId = String(extractedCallerId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
41
135
|
return {
|
|
42
136
|
type,
|
|
43
137
|
act,
|
|
44
138
|
act_type,
|
|
45
|
-
data,
|
|
139
|
+
data: enrichedData,
|
|
46
140
|
};
|
|
47
141
|
}
|
|
@@ -4,10 +4,15 @@ import { initializeGroupEvent } from "../../models/GroupEvent.js";
|
|
|
4
4
|
import { initializeSyncEvent } from "../../models/SyncEvent.js";
|
|
5
5
|
import { decodeEventData, getFriendEventType, getGroupEventType } from "../../utils.js";
|
|
6
6
|
export async function handleRealtimeControlPacket(listener, ctx, selfListen, version, cmd, subCmd, parsed, cipherKey) {
|
|
7
|
-
if (version == 1 && cmd == 601 && subCmd == 0) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
if (version == 1 && (cmd == 601 || cmd == 603 || cmd == 604) && subCmd == 0) {
|
|
8
|
+
const decoded = await decodeEventData(parsed, cipherKey);
|
|
9
|
+
const parsedData = decoded?.data;
|
|
10
|
+
const controls = parsedData?.controls;
|
|
11
|
+
if (!Array.isArray(controls))
|
|
12
|
+
return false;
|
|
10
13
|
for (const control of controls) {
|
|
14
|
+
if (!control?.content)
|
|
15
|
+
continue;
|
|
11
16
|
if (control.content.act_type == "file_done") {
|
|
12
17
|
const data = {
|
|
13
18
|
fileUrl: control.content.data.url,
|
|
@@ -58,6 +63,15 @@ export async function handleRealtimeControlPacket(listener, ctx, selfListen, ver
|
|
|
58
63
|
const callEventData = typeof control.content.data == "string"
|
|
59
64
|
? JSON.parse(control.content.data)
|
|
60
65
|
: control.content.data;
|
|
66
|
+
// Bỏ qua các gói mời gọi cũ (> 60s) nằm trong hàng đợi offline (cmd 603 / 604)
|
|
67
|
+
if ((cmd == 603 || cmd == 604) &&
|
|
68
|
+
(control.content.act == "request" || control.content.act == "group_request") &&
|
|
69
|
+
callEventData?.ts) {
|
|
70
|
+
const eventTs = Number.parseInt(String(callEventData.ts), 10);
|
|
71
|
+
if (Number.isFinite(eventTs) && Date.now() - eventTs > 60_000) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
61
75
|
const callEvent = initializeCallEvent(callEventData, control.content.act, control.content.act_type);
|
|
62
76
|
listener.emit("call_event", callEvent);
|
|
63
77
|
}
|
|
@@ -21,6 +21,7 @@ export declare class Listener extends EventEmitter<ListenerEvents> {
|
|
|
21
21
|
private retryTimeout?;
|
|
22
22
|
private watchdogTimeout?;
|
|
23
23
|
private consecutive1006Count;
|
|
24
|
+
private isManualStop;
|
|
24
25
|
private id;
|
|
25
26
|
constructor(ctx: ContextSession, urls: string[]);
|
|
26
27
|
/**
|
|
@@ -65,5 +66,10 @@ export declare class Listener extends EventEmitter<ListenerEvents> {
|
|
|
65
66
|
* @param lastMsgId Optional cursor message ID
|
|
66
67
|
*/
|
|
67
68
|
requestOldReactions(threadType: ThreadType, lastMsgId?: string | null): void;
|
|
69
|
+
/**
|
|
70
|
+
* Kích hoạt và kéo hàng đợi sự kiện điều khiển / VoIP (`cmd 603` CTRL_PULL_CTRL và `cmd 604` CTRL_PULL_VOIP).
|
|
71
|
+
* Giúp nhận ngay các cuộc gọi đến đang đổ chuông ngay cả khi vừa mở kết nối WebSocket.
|
|
72
|
+
*/
|
|
73
|
+
requestOfflineVoipControls(): void;
|
|
68
74
|
private reset;
|
|
69
75
|
}
|
|
@@ -27,6 +27,7 @@ export class Listener extends EventEmitter {
|
|
|
27
27
|
retryTimeout;
|
|
28
28
|
watchdogTimeout;
|
|
29
29
|
consecutive1006Count = 0;
|
|
30
|
+
isManualStop = false;
|
|
30
31
|
id = 0;
|
|
31
32
|
constructor(ctx, urls) {
|
|
32
33
|
super();
|
|
@@ -152,6 +153,7 @@ export class Listener extends EventEmitter {
|
|
|
152
153
|
logger(this.ctx).verbose(`Rotating endpoint to ${this.wsURL}`);
|
|
153
154
|
}
|
|
154
155
|
start({ retryOnClose = false } = {}) {
|
|
156
|
+
this.isManualStop = false;
|
|
155
157
|
if (this.retryTimeout) {
|
|
156
158
|
clearTimeout(this.retryTimeout);
|
|
157
159
|
this.retryTimeout = undefined;
|
|
@@ -175,6 +177,10 @@ export class Listener extends EventEmitter {
|
|
|
175
177
|
t: Date.now(),
|
|
176
178
|
});
|
|
177
179
|
const cookie = this.ctx.cookie.getCookieStringSync(ZALO_DOMAINS.CHAT_WEB);
|
|
180
|
+
const wsAgent = this.ctx.options.agent &&
|
|
181
|
+
typeof this.ctx.options.agent.dispatch !== "function"
|
|
182
|
+
? this.ctx.options.agent
|
|
183
|
+
: undefined;
|
|
178
184
|
const ws = new WebSocket(this.wsURL, {
|
|
179
185
|
headers: {
|
|
180
186
|
"accept-language": getBrowserLanguage(this.ctx.language),
|
|
@@ -189,7 +195,7 @@ export class Listener extends EventEmitter {
|
|
|
189
195
|
"user-agent": this.userAgent,
|
|
190
196
|
cookie,
|
|
191
197
|
},
|
|
192
|
-
agent:
|
|
198
|
+
...(wsAgent ? { agent: wsAgent } : {}),
|
|
193
199
|
});
|
|
194
200
|
this.ws = ws;
|
|
195
201
|
ws.onopen = () => {
|
|
@@ -202,7 +208,8 @@ export class Listener extends EventEmitter {
|
|
|
202
208
|
ws.onclose = (event) => {
|
|
203
209
|
this.reset();
|
|
204
210
|
this.emit("disconnected", event.code, event.reason);
|
|
205
|
-
const retry =
|
|
211
|
+
const retry = !this.isManualStop &&
|
|
212
|
+
retryOnClose &&
|
|
206
213
|
this.isRetryable(event.code) &&
|
|
207
214
|
this.canRetry(event.code);
|
|
208
215
|
if (retry && retryOnClose) {
|
|
@@ -246,6 +253,7 @@ export class Listener extends EventEmitter {
|
|
|
246
253
|
if (version == 1 && cmd == 1 && subCmd == 1 && hasOwn(parsed, "key")) {
|
|
247
254
|
this.cipherKey = parsed.key;
|
|
248
255
|
this.emit("cipher_key", this.cipherKey);
|
|
256
|
+
this.requestOfflineVoipControls();
|
|
249
257
|
if (this.pingInterval)
|
|
250
258
|
clearInterval(this.pingInterval);
|
|
251
259
|
const ping = () => {
|
|
@@ -288,19 +296,24 @@ export class Listener extends EventEmitter {
|
|
|
288
296
|
};
|
|
289
297
|
}
|
|
290
298
|
stop() {
|
|
291
|
-
|
|
299
|
+
this.isManualStop = true;
|
|
300
|
+
if (this.retryTimeout) {
|
|
292
301
|
clearTimeout(this.retryTimeout);
|
|
293
|
-
|
|
302
|
+
this.retryTimeout = undefined;
|
|
303
|
+
}
|
|
304
|
+
if (this.watchdogTimeout) {
|
|
294
305
|
clearTimeout(this.watchdogTimeout);
|
|
306
|
+
this.watchdogTimeout = undefined;
|
|
307
|
+
}
|
|
295
308
|
if (this.ws) {
|
|
296
|
-
if (this.ws.readyState !== WebSocket.CLOSED) {
|
|
309
|
+
if (this.ws.readyState !== WebSocket.CLOSED && this.ws.readyState !== WebSocket.CLOSING) {
|
|
297
310
|
this.ws.close(CloseReason.ManualClosure);
|
|
298
311
|
}
|
|
299
312
|
}
|
|
300
313
|
this.reset();
|
|
301
314
|
}
|
|
302
315
|
sendWs(payload, requireId = true) {
|
|
303
|
-
if (this.ws) {
|
|
316
|
+
if (this.ws && (this.ws.readyState === undefined || this.ws.readyState === WebSocket.OPEN)) {
|
|
304
317
|
if (requireId)
|
|
305
318
|
payload.data["req_id"] = `req_${this.id++}`;
|
|
306
319
|
const encodedData = new TextEncoder().encode(JSON.stringify(payload.data));
|
|
@@ -346,6 +359,24 @@ export class Listener extends EventEmitter {
|
|
|
346
359
|
};
|
|
347
360
|
this.sendWs(payload);
|
|
348
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* Kích hoạt và kéo hàng đợi sự kiện điều khiển / VoIP (`cmd 603` CTRL_PULL_CTRL và `cmd 604` CTRL_PULL_VOIP).
|
|
364
|
+
* Giúp nhận ngay các cuộc gọi đến đang đổ chuông ngay cả khi vừa mở kết nối WebSocket.
|
|
365
|
+
*/
|
|
366
|
+
requestOfflineVoipControls() {
|
|
367
|
+
this.sendWs({
|
|
368
|
+
version: 1,
|
|
369
|
+
cmd: 604,
|
|
370
|
+
subCmd: 0,
|
|
371
|
+
data: { first: true, lastId: 1, preIds: [] },
|
|
372
|
+
});
|
|
373
|
+
this.sendWs({
|
|
374
|
+
version: 1,
|
|
375
|
+
cmd: 603,
|
|
376
|
+
subCmd: 0,
|
|
377
|
+
data: { first: true, lastId: "1", preIds: [] },
|
|
378
|
+
});
|
|
379
|
+
}
|
|
349
380
|
reset() {
|
|
350
381
|
this.ws = null;
|
|
351
382
|
this.cipherKey = undefined;
|
package/dist/update.js
CHANGED
|
@@ -6,6 +6,9 @@ const NPM_REGISTRY = ZALO_DOMAINS.NPM_REGISTRY;
|
|
|
6
6
|
export async function checkUpdate(ctx) {
|
|
7
7
|
if (!ctx.options.checkUpdate)
|
|
8
8
|
return;
|
|
9
|
+
const isAgentUndiciDispatcher = Boolean(ctx.options.agent && typeof ctx.options.agent.dispatch === "function");
|
|
10
|
+
const resolvedDispatcher = ctx.options.dispatcher ?? (isAgentUndiciDispatcher ? ctx.options.agent : undefined);
|
|
11
|
+
const resolvedAgent = ctx.options.agent && !isAgentUndiciDispatcher ? ctx.options.agent : undefined;
|
|
9
12
|
const _options = {
|
|
10
13
|
...(isBun
|
|
11
14
|
? {
|
|
@@ -13,7 +16,13 @@ export async function checkUpdate(ctx) {
|
|
|
13
16
|
// @ts-ignore
|
|
14
17
|
proxy: ctx.options.agent?.proxy?.href,
|
|
15
18
|
}
|
|
16
|
-
: {
|
|
19
|
+
: {
|
|
20
|
+
...(resolvedAgent ? { agent: resolvedAgent } : {}),
|
|
21
|
+
...(resolvedDispatcher ? { dispatcher: resolvedDispatcher } : {}),
|
|
22
|
+
}),
|
|
23
|
+
...(typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function"
|
|
24
|
+
? { signal: AbortSignal.timeout(3000) }
|
|
25
|
+
: {}),
|
|
17
26
|
};
|
|
18
27
|
const response = await ctx.options.polyfill(NPM_REGISTRY, _options).catch(() => null);
|
|
19
28
|
if (!response || !response.ok)
|
package/dist/utils.d.ts
CHANGED
|
@@ -112,13 +112,6 @@ 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;
|
|
122
115
|
export declare function handleZaloResponse<T = unknown>(ctx: ContextSession, response: Response, isEncrypted?: boolean): Promise<ZaloResponse<T>>;
|
|
123
116
|
export declare function resolveResponse<T = unknown>(ctx: ContextSession, res: Response, cb?: (result: ZaloResponse<unknown>) => T, isEncrypted?: boolean): Promise<T>;
|
|
124
117
|
export type FactoryUtils<T> = {
|
package/dist/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ import { ZaloApiError, ZaloApiMissingImageMetadataGetter } from "./Errors/index.
|
|
|
9
9
|
import { FriendEventType } from "./models/FriendEvent.js";
|
|
10
10
|
import { GroupEventType } from "./models/GroupEvent.js";
|
|
11
11
|
import { ZALO_DEFAULTS, ZALO_DOMAINS, ZALO_PROTOCOL } from "./constants/index.js";
|
|
12
|
-
import { decodeAES, encodeAES } from "./crypto/index.js";
|
|
12
|
+
import { decodeAES, encodeAES, preParseJsonIds } from "./crypto/index.js";
|
|
13
13
|
export * from "./constants/index.js";
|
|
14
14
|
export * from "./crypto/index.js";
|
|
15
15
|
export * from "./core/index.js";
|
|
@@ -161,8 +161,20 @@ export async function request(ctx, url, options, raw = false) {
|
|
|
161
161
|
options = { ...(options || {}), headers: defaultHeaders };
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
const timeoutMs = ctx.options?.requestTimeout;
|
|
165
|
+
const defaultSignal = !options?.signal &&
|
|
166
|
+
typeof timeoutMs === "number" &&
|
|
167
|
+
timeoutMs > 0 &&
|
|
168
|
+
typeof AbortSignal !== "undefined" &&
|
|
169
|
+
typeof AbortSignal.timeout === "function"
|
|
170
|
+
? AbortSignal.timeout(timeoutMs)
|
|
171
|
+
: undefined;
|
|
172
|
+
const isAgentUndiciDispatcher = Boolean(ctx.options.agent && typeof ctx.options.agent.dispatch === "function");
|
|
173
|
+
const resolvedDispatcher = ctx.options.dispatcher ?? (isAgentUndiciDispatcher ? ctx.options.agent : undefined);
|
|
174
|
+
const resolvedAgent = ctx.options.agent && !isAgentUndiciDispatcher ? ctx.options.agent : undefined;
|
|
164
175
|
const _options = {
|
|
165
176
|
...(options ?? {}),
|
|
177
|
+
...(defaultSignal ? { signal: defaultSignal } : {}),
|
|
166
178
|
...(isBun
|
|
167
179
|
? {
|
|
168
180
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -170,8 +182,8 @@ export async function request(ctx, url, options, raw = false) {
|
|
|
170
182
|
proxy: ctx.options.agent?.proxy?.href,
|
|
171
183
|
}
|
|
172
184
|
: {
|
|
173
|
-
agent:
|
|
174
|
-
dispatcher:
|
|
185
|
+
...(resolvedAgent ? { agent: resolvedAgent } : {}),
|
|
186
|
+
...(resolvedDispatcher ? { dispatcher: resolvedDispatcher } : {}),
|
|
175
187
|
}),
|
|
176
188
|
};
|
|
177
189
|
const response = await ctx.options.polyfill(url, _options);
|
|
@@ -447,67 +459,6 @@ export function getFriendEventType(act) {
|
|
|
447
459
|
return FriendEventType.PIN_CREATE;
|
|
448
460
|
return FriendEventType.UNKNOWN;
|
|
449
461
|
}
|
|
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
|
-
}
|
|
511
462
|
export async function handleZaloResponse(ctx, response, isEncrypted = true) {
|
|
512
463
|
const result = {
|
|
513
464
|
data: null,
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./dist";
|
|
1
|
+
export * from "./dist/index.js";
|
|
2
2
|
export as namespace Zalo;
|