@softtynet/zca-js 2.1.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/.prettierrc +5 -0
- package/CODE_OF_CONDUCT.md +163 -0
- package/CONTRIBUTING.md +470 -0
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/SECURITY.md +83 -0
- package/dist/Errors/ZaloApiError.d.ts +4 -0
- package/dist/Errors/ZaloApiError.js +7 -0
- package/dist/Errors/ZaloApiLoginQRAborted.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRAborted.js +7 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.d.ts +4 -0
- package/dist/Errors/ZaloApiLoginQRDeclined.js +7 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.d.ts +4 -0
- package/dist/Errors/ZaloApiMissingImageMetadataGetter.js +7 -0
- package/dist/Errors/index.d.ts +4 -0
- package/dist/Errors/index.js +4 -0
- package/dist/apis/acceptFriendRequest.d.ts +2 -0
- package/dist/apis/acceptFriendRequest.js +28 -0
- package/dist/apis/addGroupBlockedMember.d.ts +2 -0
- package/dist/apis/addGroupBlockedMember.js +28 -0
- package/dist/apis/addGroupDeputy.d.ts +2 -0
- package/dist/apis/addGroupDeputy.js +30 -0
- package/dist/apis/addPollOptions.d.ts +14 -0
- package/dist/apis/addPollOptions.js +26 -0
- package/dist/apis/addQuickMessage.d.ts +11 -0
- package/dist/apis/addQuickMessage.js +60 -0
- package/dist/apis/addReaction.d.ts +18 -0
- package/dist/apis/addReaction.js +294 -0
- package/dist/apis/addUnreadMark.d.ts +8 -0
- package/dist/apis/addUnreadMark.js +52 -0
- package/dist/apis/addUserToGroup.d.ts +5 -0
- package/dist/apis/addUserToGroup.js +34 -0
- package/dist/apis/blockUser.d.ts +2 -0
- package/dist/apis/blockUser.js +28 -0
- package/dist/apis/blockViewFeed.d.ts +2 -0
- package/dist/apis/blockViewFeed.js +30 -0
- package/dist/apis/changeAccountAvatar.d.ts +3 -0
- package/dist/apis/changeAccountAvatar.js +52 -0
- package/dist/apis/changeFriendAlias.d.ts +2 -0
- package/dist/apis/changeFriendAlias.js +27 -0
- package/dist/apis/changeGroupAvatar.d.ts +3 -0
- package/dist/apis/changeGroupAvatar.js +44 -0
- package/dist/apis/changeGroupName.d.ts +4 -0
- package/dist/apis/changeGroupName.js +32 -0
- package/dist/apis/changeGroupOwner.d.ts +4 -0
- package/dist/apis/changeGroupOwner.js +30 -0
- package/dist/apis/createAutoReply.d.ts +14 -0
- package/dist/apis/createAutoReply.js +37 -0
- package/dist/apis/createCatalog.d.ts +7 -0
- package/dist/apis/createCatalog.js +29 -0
- package/dist/apis/createGroup.d.ts +28 -0
- package/dist/apis/createGroup.js +43 -0
- package/dist/apis/createNote.d.ts +7 -0
- package/dist/apis/createNote.js +47 -0
- package/dist/apis/createPoll.d.ts +36 -0
- package/dist/apis/createPoll.js +40 -0
- package/dist/apis/createProductCatalog.d.ts +23 -0
- package/dist/apis/createProductCatalog.js +50 -0
- package/dist/apis/createReminder.d.ts +12 -0
- package/dist/apis/createReminder.js +63 -0
- package/dist/apis/custom.d.ts +9 -0
- package/dist/apis/custom.js +15 -0
- package/dist/apis/deleteAutoReply.d.ts +5 -0
- package/dist/apis/deleteAutoReply.js +29 -0
- package/dist/apis/deleteAvatar.d.ts +9 -0
- package/dist/apis/deleteAvatar.js +27 -0
- package/dist/apis/deleteCatalog.d.ts +2 -0
- package/dist/apis/deleteCatalog.js +28 -0
- package/dist/apis/deleteChat.d.ts +19 -0
- package/dist/apis/deleteChat.js +50 -0
- package/dist/apis/deleteGroupInviteBox.d.ts +9 -0
- package/dist/apis/deleteGroupInviteBox.js +27 -0
- package/dist/apis/deleteMessage.d.ts +14 -0
- package/dist/apis/deleteMessage.js +52 -0
- package/dist/apis/deleteProductCatalog.d.ts +10 -0
- package/dist/apis/deleteProductCatalog.js +31 -0
- package/dist/apis/disableGroupLink.d.ts +2 -0
- package/dist/apis/disableGroupLink.js +24 -0
- package/dist/apis/disperseGroup.d.ts +2 -0
- package/dist/apis/disperseGroup.js +28 -0
- package/dist/apis/editNote.d.ts +17 -0
- package/dist/apis/editNote.js +46 -0
- package/dist/apis/editReminder.d.ts +13 -0
- package/dist/apis/editReminder.js +61 -0
- package/dist/apis/enableGroupLink.d.ts +6 -0
- package/dist/apis/enableGroupLink.js +25 -0
- package/dist/apis/fetchAccountInfo.d.ts +5 -0
- package/dist/apis/fetchAccountInfo.js +10 -0
- package/dist/apis/findUser.d.ts +3 -0
- package/dist/apis/findUser.js +42 -0
- package/dist/apis/findUserByUsername.d.ts +3 -0
- package/dist/apis/findUserByUsername.js +27 -0
- package/dist/apis/forwardMessage.d.ts +24 -0
- package/dist/apis/forwardMessage.js +99 -0
- package/dist/apis/getAliasList.d.ts +8 -0
- package/dist/apis/getAliasList.js +27 -0
- package/dist/apis/getAllFriends.d.ts +3 -0
- package/dist/apis/getAllFriends.js +34 -0
- package/dist/apis/getAllGroups.d.ts +7 -0
- package/dist/apis/getAllGroups.js +10 -0
- package/dist/apis/getArchivedChatList.d.ts +5 -0
- package/dist/apis/getArchivedChatList.js +23 -0
- package/dist/apis/getAutoDeleteChat.d.ts +9 -0
- package/dist/apis/getAutoDeleteChat.js +21 -0
- package/dist/apis/getAutoReplyList.d.ts +6 -0
- package/dist/apis/getAutoReplyList.js +24 -0
- package/dist/apis/getAvatarList.d.ts +12 -0
- package/dist/apis/getAvatarList.js +28 -0
- package/dist/apis/getAvatarUrlProfile.d.ts +7 -0
- package/dist/apis/getAvatarUrlProfile.js +30 -0
- package/dist/apis/getBizAccount.d.ts +24 -0
- package/dist/apis/getBizAccount.js +27 -0
- package/dist/apis/getCatalogList.d.ts +18 -0
- package/dist/apis/getCatalogList.js +32 -0
- package/dist/apis/getCloseFriends.d.ts +3 -0
- package/dist/apis/getCloseFriends.js +20 -0
- package/dist/apis/getContext.d.ts +1 -0
- package/dist/apis/getContext.js +4 -0
- package/dist/apis/getCookie.d.ts +1 -0
- package/dist/apis/getCookie.js +9 -0
- package/dist/apis/getFriendBoardList.d.ts +5 -0
- package/dist/apis/getFriendBoardList.js +26 -0
- package/dist/apis/getFriendOnlines.d.ts +10 -0
- package/dist/apis/getFriendOnlines.js +35 -0
- package/dist/apis/getFriendRecommendations.d.ts +42 -0
- package/dist/apis/getFriendRecommendations.js +27 -0
- package/dist/apis/getFriendRequestStatus.d.ts +8 -0
- package/dist/apis/getFriendRequestStatus.js +25 -0
- package/dist/apis/getFullAvatar.d.ts +5 -0
- package/dist/apis/getFullAvatar.js +25 -0
- package/dist/apis/getGroupBlockedMember.d.ts +23 -0
- package/dist/apis/getGroupBlockedMember.js +29 -0
- package/dist/apis/getGroupChatHistory.d.ts +8 -0
- package/dist/apis/getGroupChatHistory.js +36 -0
- package/dist/apis/getGroupInfo.d.ts +16 -0
- package/dist/apis/getGroupInfo.js +32 -0
- package/dist/apis/getGroupInviteBoxInfo.d.ts +32 -0
- package/dist/apis/getGroupInviteBoxInfo.js +38 -0
- package/dist/apis/getGroupInviteBoxList.d.ts +38 -0
- package/dist/apis/getGroupInviteBoxList.js +31 -0
- package/dist/apis/getGroupLinkDetail.d.ts +9 -0
- package/dist/apis/getGroupLinkDetail.js +25 -0
- package/dist/apis/getGroupLinkInfo.d.ts +34 -0
- package/dist/apis/getGroupLinkInfo.js +28 -0
- package/dist/apis/getGroupMembersInfo.d.ts +17 -0
- package/dist/apis/getGroupMembersInfo.js +24 -0
- package/dist/apis/getHiddenConversations.d.ts +11 -0
- package/dist/apis/getHiddenConversations.js +23 -0
- package/dist/apis/getLabels.d.ts +7 -0
- package/dist/apis/getLabels.js +28 -0
- package/dist/apis/getListBoard.d.ts +21 -0
- package/dist/apis/getListBoard.js +45 -0
- package/dist/apis/getListReminder.d.ts +28 -0
- package/dist/apis/getListReminder.js +47 -0
- package/dist/apis/getMultiUsersByPhones.d.ts +5 -0
- package/dist/apis/getMultiUsersByPhones.js +39 -0
- package/dist/apis/getMute.d.ts +13 -0
- package/dist/apis/getMute.js +22 -0
- package/dist/apis/getOwnId.d.ts +1 -0
- package/dist/apis/getOwnId.js +4 -0
- package/dist/apis/getPendingGroupMembers.d.ts +11 -0
- package/dist/apis/getPendingGroupMembers.js +27 -0
- package/dist/apis/getPinConversations.d.ts +5 -0
- package/dist/apis/getPinConversations.js +22 -0
- package/dist/apis/getPollDetail.d.ts +3 -0
- package/dist/apis/getPollDetail.js +30 -0
- package/dist/apis/getProductCatalogList.d.ts +20 -0
- package/dist/apis/getProductCatalogList.js +33 -0
- package/dist/apis/getQR.d.ts +4 -0
- package/dist/apis/getQR.js +29 -0
- package/dist/apis/getQuickMessageList.d.ts +7 -0
- package/dist/apis/getQuickMessageList.js +24 -0
- package/dist/apis/getRelatedFriendGroup.d.ts +6 -0
- package/dist/apis/getRelatedFriendGroup.js +30 -0
- package/dist/apis/getReminder.d.ts +3 -0
- package/dist/apis/getReminder.js +25 -0
- package/dist/apis/getReminderResponses.d.ts +5 -0
- package/dist/apis/getReminderResponses.js +24 -0
- package/dist/apis/getSentFriendRequest.d.ts +18 -0
- package/dist/apis/getSentFriendRequest.js +24 -0
- package/dist/apis/getSettings.d.ts +3 -0
- package/dist/apis/getSettings.js +20 -0
- package/dist/apis/getStickerCategoryDetail.d.ts +3 -0
- package/dist/apis/getStickerCategoryDetail.js +24 -0
- package/dist/apis/getStickers.d.ts +1 -0
- package/dist/apis/getStickers.js +40 -0
- package/dist/apis/getStickersDetail.d.ts +3 -0
- package/dist/apis/getStickersDetail.js +40 -0
- package/dist/apis/getUnreadMark.d.ts +14 -0
- package/dist/apis/getUnreadMark.js +30 -0
- package/dist/apis/getUserInfo.d.ts +8 -0
- package/dist/apis/getUserInfo.js +44 -0
- package/dist/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/apis/inviteUserToGroups.js +30 -0
- package/dist/apis/joinGroupInviteBox.d.ts +2 -0
- package/dist/apis/joinGroupInviteBox.js +25 -0
- package/dist/apis/joinGroupLink.d.ts +2 -0
- package/dist/apis/joinGroupLink.js +27 -0
- package/dist/apis/keepAlive.d.ts +4 -0
- package/dist/apis/keepAlive.js +22 -0
- package/dist/apis/lastOnline.d.ts +7 -0
- package/dist/apis/lastOnline.js +26 -0
- package/dist/apis/leaveGroup.d.ts +4 -0
- package/dist/apis/leaveGroup.js +33 -0
- package/dist/apis/listen.d.ts +102 -0
- package/dist/apis/listen.js +425 -0
- package/dist/apis/lockPoll.d.ts +2 -0
- package/dist/apis/lockPoll.js +28 -0
- package/dist/apis/login.d.ts +3 -0
- package/dist/apis/login.js +96 -0
- package/dist/apis/loginQR.d.ts +71 -0
- package/dist/apis/loginQR.js +338 -0
- package/dist/apis/parseLink.d.ts +21 -0
- package/dist/apis/parseLink.js +27 -0
- package/dist/apis/rejectFriendRequest.d.ts +2 -0
- package/dist/apis/rejectFriendRequest.js +27 -0
- package/dist/apis/removeFriend.d.ts +2 -0
- package/dist/apis/removeFriend.js +28 -0
- package/dist/apis/removeFriendAlias.d.ts +2 -0
- package/dist/apis/removeFriendAlias.js +24 -0
- package/dist/apis/removeGroupBlockedMember.d.ts +2 -0
- package/dist/apis/removeGroupBlockedMember.js +28 -0
- package/dist/apis/removeGroupDeputy.d.ts +2 -0
- package/dist/apis/removeGroupDeputy.js +30 -0
- package/dist/apis/removeQuickMessage.d.ts +5 -0
- package/dist/apis/removeQuickMessage.js +27 -0
- package/dist/apis/removeReminder.d.ts +3 -0
- package/dist/apis/removeReminder.js +40 -0
- package/dist/apis/removeUnreadMark.d.ts +8 -0
- package/dist/apis/removeUnreadMark.js +50 -0
- package/dist/apis/removeUserFromGroup.d.ts +4 -0
- package/dist/apis/removeUserFromGroup.js +34 -0
- package/dist/apis/resetHiddenConversPin.d.ts +2 -0
- package/dist/apis/resetHiddenConversPin.js +20 -0
- package/dist/apis/reuseAvatar.d.ts +2 -0
- package/dist/apis/reuseAvatar.js +26 -0
- package/dist/apis/reviewPendingMemberRequest.d.ts +14 -0
- package/dist/apis/reviewPendingMemberRequest.js +38 -0
- package/dist/apis/searchSticker.d.ts +3 -0
- package/dist/apis/searchSticker.js +28 -0
- package/dist/apis/sendBankCard.d.ts +9 -0
- package/dist/apis/sendBankCard.js +37 -0
- package/dist/apis/sendCard.d.ts +10 -0
- package/dist/apis/sendCard.js +59 -0
- package/dist/apis/sendDeliveredEvent.d.ts +16 -0
- package/dist/apis/sendDeliveredEvent.js +55 -0
- package/dist/apis/sendFriendRequest.d.ts +2 -0
- package/dist/apis/sendFriendRequest.js +39 -0
- package/dist/apis/sendLink.d.ts +10 -0
- package/dist/apis/sendLink.js +61 -0
- package/dist/apis/sendMessage.d.ts +99 -0
- package/dist/apis/sendMessage.js +452 -0
- package/dist/apis/sendReport.d.ts +17 -0
- package/dist/apis/sendReport.js +53 -0
- package/dist/apis/sendSeenEvent.d.ts +16 -0
- package/dist/apis/sendSeenEvent.js +63 -0
- package/dist/apis/sendSticker.d.ts +10 -0
- package/dist/apis/sendSticker.js +57 -0
- package/dist/apis/sendTypingEvent.d.ts +5 -0
- package/dist/apis/sendTypingEvent.js +33 -0
- package/dist/apis/sendVideo.d.ts +35 -0
- package/dist/apis/sendVideo.js +118 -0
- package/dist/apis/sendVoice.d.ts +12 -0
- package/dist/apis/sendVoice.js +73 -0
- package/dist/apis/setHiddenConversations.d.ts +3 -0
- package/dist/apis/setHiddenConversations.js +39 -0
- package/dist/apis/setMute.d.ts +20 -0
- package/dist/apis/setMute.js +67 -0
- package/dist/apis/setPinnedConversations.d.ts +3 -0
- package/dist/apis/setPinnedConversations.js +34 -0
- package/dist/apis/sharePoll.d.ts +2 -0
- package/dist/apis/sharePoll.js +28 -0
- package/dist/apis/unblockUser.d.ts +2 -0
- package/dist/apis/unblockUser.js +28 -0
- package/dist/apis/undo.d.ts +9 -0
- package/dist/apis/undo.js +42 -0
- package/dist/apis/undoFriendRequest.d.ts +2 -0
- package/dist/apis/undoFriendRequest.js +27 -0
- package/dist/apis/updateActiveStatus.d.ts +4 -0
- package/dist/apis/updateActiveStatus.js +27 -0
- package/dist/apis/updateArchivedChatList.d.ts +10 -0
- package/dist/apis/updateArchivedChatList.js +34 -0
- package/dist/apis/updateAutoDeleteChat.d.ts +9 -0
- package/dist/apis/updateAutoDeleteChat.js +40 -0
- package/dist/apis/updateAutoReply.d.ts +15 -0
- package/dist/apis/updateAutoReply.js +38 -0
- package/dist/apis/updateCatalog.d.ts +11 -0
- package/dist/apis/updateCatalog.js +30 -0
- package/dist/apis/updateGroupSettings.d.ts +40 -0
- package/dist/apis/updateGroupSettings.js +43 -0
- package/dist/apis/updateHiddenConversPin.d.ts +2 -0
- package/dist/apis/updateHiddenConversPin.js +30 -0
- package/dist/apis/updateLabels.d.ts +15 -0
- package/dist/apis/updateLabels.js +34 -0
- package/dist/apis/updateLang.d.ts +6 -0
- package/dist/apis/updateLang.js +30 -0
- package/dist/apis/updateProductCatalog.d.ts +25 -0
- package/dist/apis/updateProductCatalog.js +51 -0
- package/dist/apis/updateProfile.d.ts +20 -0
- package/dist/apis/updateProfile.js +43 -0
- package/dist/apis/updateProfileBio.d.ts +2 -0
- package/dist/apis/updateProfileBio.js +27 -0
- package/dist/apis/updateQuickMessage.d.ts +11 -0
- package/dist/apis/updateQuickMessage.js +61 -0
- package/dist/apis/updateSettings.d.ts +16 -0
- package/dist/apis/updateSettings.js +90 -0
- package/dist/apis/upgradeGroupToCommunity.d.ts +2 -0
- package/dist/apis/upgradeGroupToCommunity.js +27 -0
- package/dist/apis/uploadAttachment.d.ts +50 -0
- package/dist/apis/uploadAttachment.js +197 -0
- package/dist/apis/uploadProductPhoto.d.ts +14 -0
- package/dist/apis/uploadProductPhoto.js +50 -0
- package/dist/apis/votePoll.d.ts +5 -0
- package/dist/apis/votePoll.js +29 -0
- package/dist/apis.d.ts +299 -0
- package/dist/apis.js +299 -0
- package/dist/cjs/Errors/ZaloApiError.cjs +11 -0
- package/dist/cjs/Errors/ZaloApiLoginQRAborted.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiLoginQRDeclined.cjs +12 -0
- package/dist/cjs/Errors/ZaloApiMissingImageMetadataGetter.cjs +12 -0
- package/dist/cjs/apis/acceptFriendRequest.cjs +33 -0
- package/dist/cjs/apis/addGroupBlockedMember.cjs +33 -0
- package/dist/cjs/apis/addGroupDeputy.cjs +35 -0
- package/dist/cjs/apis/addPollOptions.cjs +31 -0
- package/dist/cjs/apis/addQuickMessage.cjs +65 -0
- package/dist/cjs/apis/addReaction.cjs +307 -0
- package/dist/cjs/apis/addUnreadMark.cjs +65 -0
- package/dist/cjs/apis/addUserToGroup.cjs +39 -0
- package/dist/cjs/apis/blockUser.cjs +33 -0
- package/dist/cjs/apis/blockViewFeed.cjs +35 -0
- package/dist/cjs/apis/changeAccountAvatar.cjs +57 -0
- package/dist/cjs/apis/changeFriendAlias.cjs +32 -0
- package/dist/cjs/apis/changeGroupAvatar.cjs +49 -0
- package/dist/cjs/apis/changeGroupName.cjs +37 -0
- package/dist/cjs/apis/changeGroupOwner.cjs +35 -0
- package/dist/cjs/apis/createAutoReply.cjs +42 -0
- package/dist/cjs/apis/createCatalog.cjs +34 -0
- package/dist/cjs/apis/createGroup.cjs +48 -0
- package/dist/cjs/apis/createNote.cjs +52 -0
- package/dist/cjs/apis/createPoll.cjs +45 -0
- package/dist/cjs/apis/createProductCatalog.cjs +55 -0
- package/dist/cjs/apis/createReminder.cjs +76 -0
- package/dist/cjs/apis/custom.cjs +19 -0
- package/dist/cjs/apis/deleteAutoReply.cjs +34 -0
- package/dist/cjs/apis/deleteAvatar.cjs +32 -0
- package/dist/cjs/apis/deleteCatalog.cjs +33 -0
- package/dist/cjs/apis/deleteChat.cjs +63 -0
- package/dist/cjs/apis/deleteGroupInviteBox.cjs +32 -0
- package/dist/cjs/apis/deleteMessage.cjs +65 -0
- package/dist/cjs/apis/deleteProductCatalog.cjs +36 -0
- package/dist/cjs/apis/disableGroupLink.cjs +29 -0
- package/dist/cjs/apis/disperseGroup.cjs +33 -0
- package/dist/cjs/apis/editNote.cjs +51 -0
- package/dist/cjs/apis/editReminder.cjs +74 -0
- package/dist/cjs/apis/enableGroupLink.cjs +30 -0
- package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
- package/dist/cjs/apis/findUser.cjs +55 -0
- package/dist/cjs/apis/findUserByUsername.cjs +40 -0
- package/dist/cjs/apis/forwardMessage.cjs +112 -0
- package/dist/cjs/apis/getAliasList.cjs +32 -0
- package/dist/cjs/apis/getAllFriends.cjs +47 -0
- package/dist/cjs/apis/getAllGroups.cjs +15 -0
- package/dist/cjs/apis/getArchivedChatList.cjs +28 -0
- package/dist/cjs/apis/getAutoDeleteChat.cjs +26 -0
- package/dist/cjs/apis/getAutoReplyList.cjs +29 -0
- package/dist/cjs/apis/getAvatarList.cjs +33 -0
- package/dist/cjs/apis/getAvatarUrlProfile.cjs +43 -0
- package/dist/cjs/apis/getBizAccount.cjs +32 -0
- package/dist/cjs/apis/getCatalogList.cjs +37 -0
- package/dist/cjs/apis/getCloseFriends.cjs +25 -0
- package/dist/cjs/apis/getContext.cjs +9 -0
- package/dist/cjs/apis/getCookie.cjs +14 -0
- package/dist/cjs/apis/getFriendBoardList.cjs +31 -0
- package/dist/cjs/apis/getFriendOnlines.cjs +40 -0
- package/dist/cjs/apis/getFriendRecommendations.cjs +32 -0
- package/dist/cjs/apis/getFriendRequestStatus.cjs +30 -0
- package/dist/cjs/apis/getFullAvatar.cjs +30 -0
- package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
- package/dist/cjs/apis/getGroupChatHistory.cjs +50 -0
- package/dist/cjs/apis/getGroupInfo.cjs +37 -0
- package/dist/cjs/apis/getGroupInviteBoxInfo.cjs +43 -0
- package/dist/cjs/apis/getGroupInviteBoxList.cjs +36 -0
- package/dist/cjs/apis/getGroupLinkDetail.cjs +30 -0
- package/dist/cjs/apis/getGroupLinkInfo.cjs +33 -0
- package/dist/cjs/apis/getGroupMembersInfo.cjs +29 -0
- package/dist/cjs/apis/getHiddenConversations.cjs +28 -0
- package/dist/cjs/apis/getLabels.cjs +33 -0
- package/dist/cjs/apis/getListBoard.cjs +58 -0
- package/dist/cjs/apis/getListReminder.cjs +60 -0
- package/dist/cjs/apis/getMultiUsersByPhones.cjs +52 -0
- package/dist/cjs/apis/getMute.cjs +27 -0
- package/dist/cjs/apis/getOwnId.cjs +9 -0
- package/dist/cjs/apis/getPendingGroupMembers.cjs +32 -0
- package/dist/cjs/apis/getPinConversations.cjs +27 -0
- package/dist/cjs/apis/getPollDetail.cjs +35 -0
- package/dist/cjs/apis/getProductCatalogList.cjs +38 -0
- package/dist/cjs/apis/getQR.cjs +34 -0
- package/dist/cjs/apis/getQuickMessageList.cjs +29 -0
- package/dist/cjs/apis/getRelatedFriendGroup.cjs +35 -0
- package/dist/cjs/apis/getReminder.cjs +30 -0
- package/dist/cjs/apis/getReminderResponses.cjs +29 -0
- package/dist/cjs/apis/getSentFriendRequest.cjs +29 -0
- package/dist/cjs/apis/getSettings.cjs +25 -0
- package/dist/cjs/apis/getStickerCategoryDetail.cjs +29 -0
- package/dist/cjs/apis/getStickers.cjs +45 -0
- package/dist/cjs/apis/getStickersDetail.cjs +45 -0
- package/dist/cjs/apis/getUnreadMark.cjs +35 -0
- package/dist/cjs/apis/getUserInfo.cjs +57 -0
- package/dist/cjs/apis/inviteUserToGroups.cjs +35 -0
- package/dist/cjs/apis/joinGroupInviteBox.cjs +30 -0
- package/dist/cjs/apis/joinGroupLink.cjs +32 -0
- package/dist/cjs/apis/keepAlive.cjs +27 -0
- package/dist/cjs/apis/lastOnline.cjs +31 -0
- package/dist/cjs/apis/leaveGroup.cjs +38 -0
- package/dist/cjs/apis/listen.cjs +439 -0
- package/dist/cjs/apis/lockPoll.cjs +33 -0
- package/dist/cjs/apis/login.cjs +102 -0
- package/dist/cjs/apis/loginQR.cjs +343 -0
- package/dist/cjs/apis/parseLink.cjs +32 -0
- package/dist/cjs/apis/rejectFriendRequest.cjs +32 -0
- package/dist/cjs/apis/removeFriend.cjs +33 -0
- package/dist/cjs/apis/removeFriendAlias.cjs +29 -0
- package/dist/cjs/apis/removeGroupBlockedMember.cjs +33 -0
- package/dist/cjs/apis/removeGroupDeputy.cjs +35 -0
- package/dist/cjs/apis/removeQuickMessage.cjs +32 -0
- package/dist/cjs/apis/removeReminder.cjs +53 -0
- package/dist/cjs/apis/removeUnreadMark.cjs +63 -0
- package/dist/cjs/apis/removeUserFromGroup.cjs +39 -0
- package/dist/cjs/apis/resetHiddenConversPin.cjs +25 -0
- package/dist/cjs/apis/reuseAvatar.cjs +31 -0
- package/dist/cjs/apis/reviewPendingMemberRequest.cjs +43 -0
- package/dist/cjs/apis/searchSticker.cjs +33 -0
- package/dist/cjs/apis/sendBankCard.cjs +50 -0
- package/dist/cjs/apis/sendCard.cjs +72 -0
- package/dist/cjs/apis/sendDeliveredEvent.cjs +68 -0
- package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
- package/dist/cjs/apis/sendLink.cjs +74 -0
- package/dist/cjs/apis/sendMessage.cjs +465 -0
- package/dist/cjs/apis/sendReport.cjs +66 -0
- package/dist/cjs/apis/sendSeenEvent.cjs +76 -0
- package/dist/cjs/apis/sendSticker.cjs +70 -0
- package/dist/cjs/apis/sendTypingEvent.cjs +46 -0
- package/dist/cjs/apis/sendVideo.cjs +131 -0
- package/dist/cjs/apis/sendVoice.cjs +86 -0
- package/dist/cjs/apis/setHiddenConversations.cjs +52 -0
- package/dist/cjs/apis/setMute.cjs +80 -0
- package/dist/cjs/apis/setPinnedConversations.cjs +47 -0
- package/dist/cjs/apis/sharePoll.cjs +33 -0
- package/dist/cjs/apis/unblockUser.cjs +33 -0
- package/dist/cjs/apis/undo.cjs +55 -0
- package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
- package/dist/cjs/apis/updateActiveStatus.cjs +32 -0
- package/dist/cjs/apis/updateArchivedChatList.cjs +39 -0
- package/dist/cjs/apis/updateAutoDeleteChat.cjs +53 -0
- package/dist/cjs/apis/updateAutoReply.cjs +43 -0
- package/dist/cjs/apis/updateCatalog.cjs +35 -0
- package/dist/cjs/apis/updateGroupSettings.cjs +48 -0
- package/dist/cjs/apis/updateHiddenConversPin.cjs +35 -0
- package/dist/cjs/apis/updateLabels.cjs +39 -0
- package/dist/cjs/apis/updateLang.cjs +35 -0
- package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
- package/dist/cjs/apis/updateProfile.cjs +48 -0
- package/dist/cjs/apis/updateProfileBio.cjs +32 -0
- package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
- package/dist/cjs/apis/updateSettings.cjs +95 -0
- package/dist/cjs/apis/upgradeGroupToCommunity.cjs +32 -0
- package/dist/cjs/apis/uploadAttachment.cjs +210 -0
- package/dist/cjs/apis/uploadProductPhoto.cjs +55 -0
- package/dist/cjs/apis/votePoll.cjs +34 -0
- package/dist/cjs/apis.cjs +304 -0
- package/dist/cjs/context.cjs +34 -0
- package/dist/cjs/index.cjs +158 -0
- package/dist/cjs/models/AutoReply.cjs +9 -0
- package/dist/cjs/models/Board.cjs +8 -0
- package/dist/cjs/models/DeliveredMessage.cjs +23 -0
- package/dist/cjs/models/Enum.cjs +258 -0
- package/dist/cjs/models/FriendEvent.cjs +87 -0
- package/dist/cjs/models/Group.cjs +13 -0
- package/dist/cjs/models/GroupEvent.cjs +94 -0
- package/dist/cjs/models/Message.cjs +35 -0
- package/dist/cjs/models/Reaction.cjs +74 -0
- package/dist/cjs/models/Reminder.cjs +9 -0
- package/dist/cjs/models/SeenMessage.cjs +23 -0
- package/dist/cjs/models/Typing.cjs +23 -0
- package/dist/cjs/models/Undo.cjs +16 -0
- package/dist/cjs/models/ZBusiness.cjs +39 -0
- package/dist/cjs/update.cjs +34 -0
- package/dist/cjs/utils.cjs +731 -0
- package/dist/cjs/zalo.cjs +112 -0
- package/dist/context.d.ts +179 -0
- package/dist/context.js +28 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.js +14 -0
- package/dist/models/Attachment.d.ts +9 -0
- package/dist/models/Attachment.js +1 -0
- package/dist/models/AutoReply.d.ts +20 -0
- package/dist/models/AutoReply.js +7 -0
- package/dist/models/Board.d.ts +60 -0
- package/dist/models/Board.js +6 -0
- package/dist/models/Catalog.d.ts +16 -0
- package/dist/models/Catalog.js +1 -0
- package/dist/models/DeliveredMessage.d.ts +27 -0
- package/dist/models/DeliveredMessage.js +17 -0
- package/dist/models/Enum.d.ts +251 -0
- package/dist/models/Enum.js +256 -0
- package/dist/models/FriendEvent.d.ts +107 -0
- package/dist/models/FriendEvent.js +83 -0
- package/dist/models/Group.d.ts +125 -0
- package/dist/models/Group.js +11 -0
- package/dist/models/GroupEvent.d.ts +178 -0
- package/dist/models/GroupEvent.js +90 -0
- package/dist/models/Label.d.ts +10 -0
- package/dist/models/Label.js +1 -0
- package/dist/models/Message.d.ts +91 -0
- package/dist/models/Message.js +29 -0
- package/dist/models/ProductCatalog.d.ts +17 -0
- package/dist/models/ProductCatalog.js +1 -0
- package/dist/models/QuickMessage.d.ts +25 -0
- package/dist/models/QuickMessage.js +1 -0
- package/dist/models/Reaction.d.ts +85 -0
- package/dist/models/Reaction.js +70 -0
- package/dist/models/Reminder.d.ts +51 -0
- package/dist/models/Reminder.js +7 -0
- package/dist/models/SeenMessage.d.ts +26 -0
- package/dist/models/SeenMessage.js +17 -0
- package/dist/models/Sticker.d.ts +27 -0
- package/dist/models/Sticker.js +1 -0
- package/dist/models/Typing.d.ts +24 -0
- package/dist/models/Typing.js +17 -0
- package/dist/models/Undo.d.ts +34 -0
- package/dist/models/Undo.js +12 -0
- package/dist/models/User.d.ts +62 -0
- package/dist/models/User.js +1 -0
- package/dist/models/ZBusiness.d.ts +22 -0
- package/dist/models/ZBusiness.js +35 -0
- package/dist/models/index.d.ts +21 -0
- package/dist/models/index.js +21 -0
- package/dist/update.d.ts +2 -0
- package/dist/update.js +29 -0
- package/dist/utils.d.ts +190 -0
- package/dist/utils.js +746 -0
- package/dist/zalo.d.ts +41 -0
- package/dist/zalo.js +107 -0
- package/eslint.config.js +21 -0
- package/index.d.ts +2 -0
- package/package.json +78 -0
- package/rollup.config.js +28 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { CookieJar } from "tough-cookie";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
4
|
+
import { logger, request, getPlatformFromUA, getChromeVersionFromUA } from "../utils.js";
|
|
5
|
+
import { ZaloApiLoginQRAborted } from "../Errors/ZaloApiLoginQRAborted.js";
|
|
6
|
+
import { ZaloApiLoginQRDeclined } from "../Errors/ZaloApiLoginQRDeclined.js";
|
|
7
|
+
/**
|
|
8
|
+
* Tạo bộ header Sec-CH-UA dùng chung cho toàn bộ các request trong luồng đăng nhập QR.
|
|
9
|
+
*
|
|
10
|
+
* Trước đây 8 hàm con trong loginQR đều copy-paste cùng một bộ header với giá trị
|
|
11
|
+
* `sec-ch-ua-platform: "Windows"` bị hardcode cứng. Điều này gây ra mâu thuẫn fingerprint
|
|
12
|
+
* (Browser Mismatch) khi người dùng truyền vào User-Agent của Mac hoặc Linux,
|
|
13
|
+
* khiến hệ thống chống bot của Zalo phát hiện và ban session ngay lập tức.
|
|
14
|
+
*
|
|
15
|
+
* Giải pháp: Tất cả giá trị sec-ch-ua-* đều được suy luận ĐỘNG từ ctx.userAgent,
|
|
16
|
+
* đảm bảo nhất quán 100% giữa User-Agent và các Client Hint headers.
|
|
17
|
+
*
|
|
18
|
+
* @param ctx - Context chứa ctx.userAgent đã được gán trước khi gọi hàm này
|
|
19
|
+
* @param extra - Các header bổ sung đặc thù cho từng request (sec-fetch-dest, Referer...)
|
|
20
|
+
*/
|
|
21
|
+
function getLoginHeaders(ctx, extra) {
|
|
22
|
+
// Suy luận platform từ UA: "Windows" | "macOS" | "Linux" (mặc định "Windows" nếu không nhận ra)
|
|
23
|
+
const platform = getPlatformFromUA(ctx.userAgent);
|
|
24
|
+
// Trích xuất phiên bản Chrome major từ UA (ví dụ: "130"), fallback về "130" nếu không phải Chrome
|
|
25
|
+
const chromeVer = getChromeVersionFromUA(ctx.userAgent);
|
|
26
|
+
return Object.assign({ "accept-language": "vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5",
|
|
27
|
+
// sec-ch-ua phải khớp với phiên bản Chrome trong User-Agent
|
|
28
|
+
"sec-ch-ua": `"Chromium";v="${chromeVer}", "Google Chrome";v="${chromeVer}", "Not?A_Brand";v="99"`,
|
|
29
|
+
// Luôn là desktop (?0) vì Zalo Web không hỗ trợ mobile
|
|
30
|
+
"sec-ch-ua-mobile": "?0",
|
|
31
|
+
// sec-ch-ua-platform PHẢI nhất quán với User-Agent — đây là nguyên nhân gốc rễ gây ban session
|
|
32
|
+
"sec-ch-ua-platform": `"${platform}"` }, extra);
|
|
33
|
+
}
|
|
34
|
+
export var LoginQRCallbackEventType;
|
|
35
|
+
(function (LoginQRCallbackEventType) {
|
|
36
|
+
LoginQRCallbackEventType[LoginQRCallbackEventType["QRCodeGenerated"] = 0] = "QRCodeGenerated";
|
|
37
|
+
LoginQRCallbackEventType[LoginQRCallbackEventType["QRCodeExpired"] = 1] = "QRCodeExpired";
|
|
38
|
+
LoginQRCallbackEventType[LoginQRCallbackEventType["QRCodeScanned"] = 2] = "QRCodeScanned";
|
|
39
|
+
LoginQRCallbackEventType[LoginQRCallbackEventType["QRCodeDeclined"] = 3] = "QRCodeDeclined";
|
|
40
|
+
LoginQRCallbackEventType[LoginQRCallbackEventType["GotLoginInfo"] = 4] = "GotLoginInfo";
|
|
41
|
+
})(LoginQRCallbackEventType || (LoginQRCallbackEventType = {}));
|
|
42
|
+
async function loadLoginPage(ctx) {
|
|
43
|
+
const response = await request(ctx, "https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F", {
|
|
44
|
+
headers: Object.assign({ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", "cache-control": "max-age=0", priority: "u=0, i" }, getLoginHeaders(ctx, {
|
|
45
|
+
"sec-fetch-dest": "document",
|
|
46
|
+
"sec-fetch-mode": "navigate",
|
|
47
|
+
"sec-fetch-site": "same-site",
|
|
48
|
+
"sec-fetch-user": "?1",
|
|
49
|
+
"upgrade-insecure-requests": "1",
|
|
50
|
+
Referer: "https://chat.zalo.me/",
|
|
51
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
52
|
+
})),
|
|
53
|
+
method: "GET",
|
|
54
|
+
});
|
|
55
|
+
const html = await response.text();
|
|
56
|
+
const regex = /https:\/\/stc-zlogin\.zdn\.vn\/main-([\d.]+)\.js/;
|
|
57
|
+
const match = html.match(regex);
|
|
58
|
+
return match === null || match === void 0 ? void 0 : match[1];
|
|
59
|
+
}
|
|
60
|
+
async function getLoginInfo(ctx, version) {
|
|
61
|
+
const form = new URLSearchParams();
|
|
62
|
+
form.append("continue", "https://zalo.me/pc");
|
|
63
|
+
form.append("v", version);
|
|
64
|
+
return await request(ctx, "https://id.zalo.me/account/logininfo", {
|
|
65
|
+
headers: Object.assign({ accept: "*/*", "content-type": "application/x-www-form-urlencoded", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
66
|
+
"sec-fetch-dest": "empty",
|
|
67
|
+
"sec-fetch-mode": "cors",
|
|
68
|
+
"sec-fetch-site": "same-origin",
|
|
69
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc",
|
|
70
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
71
|
+
})),
|
|
72
|
+
body: form,
|
|
73
|
+
method: "POST",
|
|
74
|
+
})
|
|
75
|
+
.then((res) => res.json())
|
|
76
|
+
.catch(logger(ctx).error);
|
|
77
|
+
}
|
|
78
|
+
async function verifyClient(ctx, version) {
|
|
79
|
+
const form = new URLSearchParams();
|
|
80
|
+
form.append("type", "device");
|
|
81
|
+
form.append("continue", "https://zalo.me/pc");
|
|
82
|
+
form.append("v", version);
|
|
83
|
+
return await request(ctx, "https://id.zalo.me/account/verify-client", {
|
|
84
|
+
headers: Object.assign({ accept: "*/*", "content-type": "application/x-www-form-urlencoded", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
85
|
+
"sec-fetch-dest": "empty",
|
|
86
|
+
"sec-fetch-mode": "cors",
|
|
87
|
+
"sec-fetch-site": "same-origin",
|
|
88
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc",
|
|
89
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
90
|
+
})),
|
|
91
|
+
body: form,
|
|
92
|
+
method: "POST",
|
|
93
|
+
})
|
|
94
|
+
.then((res) => res.json())
|
|
95
|
+
.catch(logger(ctx).error);
|
|
96
|
+
}
|
|
97
|
+
async function generate(ctx, version) {
|
|
98
|
+
const form = new URLSearchParams();
|
|
99
|
+
form.append("continue", "https://zalo.me/pc");
|
|
100
|
+
form.append("v", version);
|
|
101
|
+
return await request(ctx, "https://id.zalo.me/account/authen/qr/generate", {
|
|
102
|
+
headers: Object.assign({ accept: "*/*", "content-type": "application/x-www-form-urlencoded", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
103
|
+
"sec-fetch-dest": "empty",
|
|
104
|
+
"sec-fetch-mode": "cors",
|
|
105
|
+
"sec-fetch-site": "same-origin",
|
|
106
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc",
|
|
107
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
108
|
+
})),
|
|
109
|
+
body: form,
|
|
110
|
+
method: "POST",
|
|
111
|
+
})
|
|
112
|
+
.then((res) => res.json())
|
|
113
|
+
.catch(logger(ctx).error);
|
|
114
|
+
}
|
|
115
|
+
async function saveQRCodeToFile(filepath, imageData) {
|
|
116
|
+
await writeFile(filepath, imageData, "base64");
|
|
117
|
+
}
|
|
118
|
+
async function waitingScan(ctx, version, code, signal) {
|
|
119
|
+
const form = new URLSearchParams();
|
|
120
|
+
form.append("code", code);
|
|
121
|
+
form.append("continue", "https://chat.zalo.me/");
|
|
122
|
+
form.append("v", version);
|
|
123
|
+
return await request(ctx, "https://id.zalo.me/account/authen/qr/waiting-scan", {
|
|
124
|
+
headers: Object.assign({ accept: "*/*", "content-type": "application/x-www-form-urlencoded", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
125
|
+
"sec-fetch-dest": "empty",
|
|
126
|
+
"sec-fetch-mode": "cors",
|
|
127
|
+
"sec-fetch-site": "same-origin",
|
|
128
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F",
|
|
129
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
130
|
+
})),
|
|
131
|
+
body: form,
|
|
132
|
+
method: "POST",
|
|
133
|
+
signal,
|
|
134
|
+
})
|
|
135
|
+
.then((res) => res.json())
|
|
136
|
+
.then((data) => {
|
|
137
|
+
if (data.error_code == 8) {
|
|
138
|
+
return waitingScan(ctx, version, code, signal);
|
|
139
|
+
}
|
|
140
|
+
return data;
|
|
141
|
+
})
|
|
142
|
+
.catch((e) => {
|
|
143
|
+
if (!signal.aborted)
|
|
144
|
+
logger(ctx).error(e);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
async function waitingConfirm(ctx, version, code, signal) {
|
|
148
|
+
const form = new URLSearchParams();
|
|
149
|
+
form.append("code", code);
|
|
150
|
+
form.append("gToken", "");
|
|
151
|
+
form.append("gAction", "CONFIRM_QR");
|
|
152
|
+
form.append("continue", "https://chat.zalo.me/");
|
|
153
|
+
form.append("v", version);
|
|
154
|
+
logger(ctx).info("Please confirm on your phone");
|
|
155
|
+
return await request(ctx, "https://id.zalo.me/account/authen/qr/waiting-confirm", {
|
|
156
|
+
headers: Object.assign({ accept: "*/*", "content-type": "application/x-www-form-urlencoded", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
157
|
+
"sec-fetch-dest": "empty",
|
|
158
|
+
"sec-fetch-mode": "cors",
|
|
159
|
+
"sec-fetch-site": "same-origin",
|
|
160
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F",
|
|
161
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
162
|
+
})),
|
|
163
|
+
body: form,
|
|
164
|
+
method: "POST",
|
|
165
|
+
signal,
|
|
166
|
+
})
|
|
167
|
+
.then((res) => res.json())
|
|
168
|
+
.then((data) => {
|
|
169
|
+
if (data.error_code == 8) {
|
|
170
|
+
return waitingConfirm(ctx, version, code, signal);
|
|
171
|
+
}
|
|
172
|
+
return data;
|
|
173
|
+
})
|
|
174
|
+
.catch((e) => {
|
|
175
|
+
if (!signal.aborted)
|
|
176
|
+
logger(ctx).error(e);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
async function checkSession(ctx) {
|
|
180
|
+
return await request(ctx, "https://id.zalo.me/account/checksession?continue=https%3A%2F%2Fchat.zalo.me%2Findex.html", {
|
|
181
|
+
headers: Object.assign({ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", priority: "u=0, i" }, getLoginHeaders(ctx, {
|
|
182
|
+
"sec-fetch-dest": "document",
|
|
183
|
+
"sec-fetch-mode": "navigate",
|
|
184
|
+
"sec-fetch-site": "same-origin",
|
|
185
|
+
"upgrade-insecure-requests": "1",
|
|
186
|
+
Referer: "https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F",
|
|
187
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
188
|
+
})),
|
|
189
|
+
redirect: "manual",
|
|
190
|
+
method: "GET",
|
|
191
|
+
}).catch(logger(ctx).error);
|
|
192
|
+
}
|
|
193
|
+
async function getUserInfo(ctx) {
|
|
194
|
+
return await request(ctx, "https://jr.chat.zalo.me/jr/userinfo", {
|
|
195
|
+
headers: Object.assign({ accept: "*/*", priority: "u=1, i" }, getLoginHeaders(ctx, {
|
|
196
|
+
"sec-fetch-dest": "empty",
|
|
197
|
+
"sec-fetch-mode": "cors",
|
|
198
|
+
"sec-fetch-site": "same-site",
|
|
199
|
+
Referer: "https://chat.zalo.me/",
|
|
200
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
201
|
+
})),
|
|
202
|
+
method: "GET",
|
|
203
|
+
})
|
|
204
|
+
.then((res) => res.json())
|
|
205
|
+
.catch(logger(ctx).error);
|
|
206
|
+
}
|
|
207
|
+
export async function loginQR(ctx, options, callback) {
|
|
208
|
+
ctx.cookie = new CookieJar();
|
|
209
|
+
ctx.userAgent = options.userAgent;
|
|
210
|
+
return new Promise(async (resolve, reject) => {
|
|
211
|
+
var _a;
|
|
212
|
+
const controller = new AbortController();
|
|
213
|
+
let qrTimeout = null;
|
|
214
|
+
function cleanUp() {
|
|
215
|
+
controller.abort();
|
|
216
|
+
if (qrTimeout) {
|
|
217
|
+
clearTimeout(qrTimeout);
|
|
218
|
+
qrTimeout = null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
function retry() {
|
|
223
|
+
cleanUp();
|
|
224
|
+
return resolve(loginQR(ctx, options, callback));
|
|
225
|
+
}
|
|
226
|
+
function abort() {
|
|
227
|
+
cleanUp();
|
|
228
|
+
return reject(new ZaloApiLoginQRAborted());
|
|
229
|
+
}
|
|
230
|
+
if (ctx.options.logging)
|
|
231
|
+
console.log();
|
|
232
|
+
const loginVersion = await loadLoginPage(ctx);
|
|
233
|
+
if (!loginVersion)
|
|
234
|
+
throw new ZaloApiError("Cannot get API login version");
|
|
235
|
+
logger(ctx).info("Got login version:", loginVersion);
|
|
236
|
+
await getLoginInfo(ctx, loginVersion);
|
|
237
|
+
await verifyClient(ctx, loginVersion);
|
|
238
|
+
const qrGenResult = await generate(ctx, loginVersion);
|
|
239
|
+
if (!qrGenResult || !qrGenResult.data)
|
|
240
|
+
throw new ZaloApiError(`Unable to generate QRCode\nResponse: ${JSON.stringify(qrGenResult, null, 2)}`);
|
|
241
|
+
const qrData = qrGenResult.data;
|
|
242
|
+
if (callback) {
|
|
243
|
+
callback({
|
|
244
|
+
type: LoginQRCallbackEventType.QRCodeGenerated,
|
|
245
|
+
data: Object.assign(Object.assign({}, qrGenResult.data), { image: qrGenResult.data.image.replace(/^data:image\/png;base64,/, "") }),
|
|
246
|
+
actions: {
|
|
247
|
+
async saveToFile(qrPath) {
|
|
248
|
+
var _a;
|
|
249
|
+
if (qrPath === void 0) { qrPath = (_a = options.qrPath) !== null && _a !== void 0 ? _a : "qr.png"; }
|
|
250
|
+
await saveQRCodeToFile(qrPath, qrData.image.replace(/^data:image\/png;base64,/, ""));
|
|
251
|
+
logger(ctx).info("Scan the QR code at", `'${qrPath}'`, "to proceed with login");
|
|
252
|
+
},
|
|
253
|
+
retry,
|
|
254
|
+
abort,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
const qrPath = (_a = options.qrPath) !== null && _a !== void 0 ? _a : "qr.png";
|
|
260
|
+
await saveQRCodeToFile(qrPath, qrData.image.replace(/^data:image\/png;base64,/, ""));
|
|
261
|
+
logger(ctx).info("Scan the QR code at", `'${qrPath}'`, "to proceed with login");
|
|
262
|
+
}
|
|
263
|
+
qrTimeout = setTimeout(() => {
|
|
264
|
+
cleanUp();
|
|
265
|
+
logger(ctx).info("QR expired!");
|
|
266
|
+
if (callback) {
|
|
267
|
+
callback({
|
|
268
|
+
type: LoginQRCallbackEventType.QRCodeExpired,
|
|
269
|
+
data: null,
|
|
270
|
+
actions: {
|
|
271
|
+
retry,
|
|
272
|
+
abort,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
retry();
|
|
278
|
+
}
|
|
279
|
+
}, 100000);
|
|
280
|
+
const scanResult = await waitingScan(ctx, loginVersion, qrGenResult.data.code, controller.signal);
|
|
281
|
+
if (!scanResult || !scanResult.data)
|
|
282
|
+
throw new ZaloApiError("Cannot get scan result");
|
|
283
|
+
if (callback) {
|
|
284
|
+
callback({
|
|
285
|
+
type: LoginQRCallbackEventType.QRCodeScanned,
|
|
286
|
+
data: scanResult.data,
|
|
287
|
+
actions: {
|
|
288
|
+
retry,
|
|
289
|
+
abort,
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
const confirmResult = await waitingConfirm(ctx, loginVersion, qrGenResult.data.code, controller.signal);
|
|
294
|
+
if (!confirmResult)
|
|
295
|
+
throw new ZaloApiError("Cannot get confirm result");
|
|
296
|
+
clearTimeout(qrTimeout);
|
|
297
|
+
if (confirmResult.error_code == -13) {
|
|
298
|
+
if (callback) {
|
|
299
|
+
callback({
|
|
300
|
+
type: LoginQRCallbackEventType.QRCodeDeclined,
|
|
301
|
+
data: {
|
|
302
|
+
code: qrData.code,
|
|
303
|
+
},
|
|
304
|
+
actions: {
|
|
305
|
+
retry,
|
|
306
|
+
abort,
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
logger(ctx).error("QRCode login declined");
|
|
312
|
+
throw new ZaloApiLoginQRDeclined();
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
else if (confirmResult.error_code != 0) {
|
|
317
|
+
throw new ZaloApiError(`An error has occurred.\nResponse: ${JSON.stringify(confirmResult, null, 2)}`);
|
|
318
|
+
}
|
|
319
|
+
const checkSessionResult = await checkSession(ctx);
|
|
320
|
+
if (!checkSessionResult)
|
|
321
|
+
throw new ZaloApiError("Cannot get session, login failed");
|
|
322
|
+
logger(ctx).info("Successfully logged into the account", scanResult.data.display_name);
|
|
323
|
+
const userInfo = await getUserInfo(ctx);
|
|
324
|
+
if (!userInfo || !userInfo.data)
|
|
325
|
+
throw new ZaloApiError("Can't get account info");
|
|
326
|
+
if (!userInfo.data.logged)
|
|
327
|
+
throw new ZaloApiError("Can't login");
|
|
328
|
+
resolve({
|
|
329
|
+
cookies: ctx.cookie.toJSON().cookies,
|
|
330
|
+
userInfo: userInfo.data.info,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
cleanUp();
|
|
335
|
+
reject(error);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ParseLinkErrorMaps = Record<string, number>;
|
|
2
|
+
export type ParseLinkResponse = {
|
|
3
|
+
data: {
|
|
4
|
+
thumb: string;
|
|
5
|
+
title: string;
|
|
6
|
+
desc: string;
|
|
7
|
+
src: string;
|
|
8
|
+
href: string;
|
|
9
|
+
media: {
|
|
10
|
+
type: number;
|
|
11
|
+
count: number;
|
|
12
|
+
mediaTitle: string;
|
|
13
|
+
artist: string;
|
|
14
|
+
streamUrl: string;
|
|
15
|
+
stream_icon: string;
|
|
16
|
+
};
|
|
17
|
+
stream_icon: string;
|
|
18
|
+
};
|
|
19
|
+
error_maps: ParseLinkErrorMaps;
|
|
20
|
+
};
|
|
21
|
+
export declare const parseLinkFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (link: string) => Promise<ParseLinkResponse>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const parseLinkFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.file[0]}/api/message/parselink`);
|
|
5
|
+
/**
|
|
6
|
+
* Parse link
|
|
7
|
+
*
|
|
8
|
+
* @param link link to parse
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
return async function parseLink(link) {
|
|
14
|
+
const params = {
|
|
15
|
+
link,
|
|
16
|
+
version: 1, // version 0 is not available errorMaps || version 1 is errorMaps (for response)
|
|
17
|
+
imei: ctx.imei,
|
|
18
|
+
};
|
|
19
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
20
|
+
if (!encryptedParams)
|
|
21
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
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,27 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const rejectFriendRequestFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/reject`);
|
|
5
|
+
/**
|
|
6
|
+
* Reject a friend request from a User
|
|
7
|
+
*
|
|
8
|
+
* @param friendId
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function rejectFriendRequest(friendId) {
|
|
13
|
+
const params = {
|
|
14
|
+
fid: friendId,
|
|
15
|
+
};
|
|
16
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
17
|
+
if (!encryptedParams)
|
|
18
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
19
|
+
const response = await utils.request(serviceURL, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
body: new URLSearchParams({
|
|
22
|
+
params: encryptedParams,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
return utils.resolve(response);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const removeFriendFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.friend[0]}/api/friend/remove`);
|
|
5
|
+
/**
|
|
6
|
+
* Remove friend
|
|
7
|
+
*
|
|
8
|
+
* @param friendId - ID of the friend to remove
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function removeFriend(friendId) {
|
|
13
|
+
const params = {
|
|
14
|
+
fid: friendId,
|
|
15
|
+
imei: ctx.imei,
|
|
16
|
+
};
|
|
17
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
18
|
+
if (!encryptedParams)
|
|
19
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
20
|
+
const response = await utils.request(serviceURL, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
body: new URLSearchParams({
|
|
23
|
+
params: encryptedParams,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
return utils.resolve(response);
|
|
27
|
+
};
|
|
28
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const removeFriendAliasFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.alias[0]}/api/alias/remove`);
|
|
5
|
+
/**
|
|
6
|
+
* Remove friend's alias
|
|
7
|
+
*
|
|
8
|
+
* @param friendId friend id
|
|
9
|
+
*
|
|
10
|
+
* @throws {ZaloApiError}
|
|
11
|
+
*/
|
|
12
|
+
return async function removeFriendAlias(friendId) {
|
|
13
|
+
const params = {
|
|
14
|
+
friendId: friendId,
|
|
15
|
+
};
|
|
16
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
17
|
+
if (!encryptedParams)
|
|
18
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
19
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
20
|
+
method: "GET",
|
|
21
|
+
});
|
|
22
|
+
return utils.resolve(response);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const removeGroupBlockedMemberFactory = apiFactory()((api, _, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/blockedmems/remove`);
|
|
5
|
+
/**
|
|
6
|
+
* Remove group blocked member
|
|
7
|
+
*
|
|
8
|
+
* @param memberId member id(s)
|
|
9
|
+
* @param groupId group id
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*/
|
|
13
|
+
return async function removeGroupBlockedMember(memberId, groupId) {
|
|
14
|
+
if (!Array.isArray(memberId))
|
|
15
|
+
memberId = [memberId];
|
|
16
|
+
const params = {
|
|
17
|
+
grid: groupId,
|
|
18
|
+
members: memberId,
|
|
19
|
+
};
|
|
20
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
21
|
+
if (!encryptedParams)
|
|
22
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
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,30 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const removeGroupDeputyFactory = apiFactory()((api, ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/admins/remove`);
|
|
5
|
+
/**
|
|
6
|
+
* Remove group deputy
|
|
7
|
+
*
|
|
8
|
+
* @param memberId user Id or list of user Ids
|
|
9
|
+
* @param groupId group Id
|
|
10
|
+
*
|
|
11
|
+
* @throws {ZaloApiError}
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
return async function removeGroupDeputy(memberId, groupId) {
|
|
15
|
+
if (!Array.isArray(memberId))
|
|
16
|
+
memberId = [memberId];
|
|
17
|
+
const params = {
|
|
18
|
+
grid: groupId,
|
|
19
|
+
members: memberId,
|
|
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
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
26
|
+
method: "GET",
|
|
27
|
+
});
|
|
28
|
+
return utils.resolve(response);
|
|
29
|
+
};
|
|
30
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type RemoveQuickMessageResponse = {
|
|
2
|
+
itemIds: number[];
|
|
3
|
+
version: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const removeQuickMessageFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (itemIds: number | number[]) => Promise<RemoveQuickMessageResponse>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { apiFactory } from "../utils.js";
|
|
3
|
+
export const removeQuickMessageFactory = apiFactory()((api, _ctx, utils) => {
|
|
4
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/delete`);
|
|
5
|
+
/**
|
|
6
|
+
* Remove quick message
|
|
7
|
+
*
|
|
8
|
+
* @param itemIds - The id(s) of the quick message(s) to remove (number or number[])
|
|
9
|
+
*
|
|
10
|
+
* @note Zalo might throw an error with code 212 if the item does not exist
|
|
11
|
+
*
|
|
12
|
+
* @throws {ZaloApiError}
|
|
13
|
+
*/
|
|
14
|
+
return async function removeQuickMessage(itemIds) {
|
|
15
|
+
const idsArray = Array.isArray(itemIds) ? itemIds : [itemIds];
|
|
16
|
+
const params = {
|
|
17
|
+
itemIds: idsArray,
|
|
18
|
+
};
|
|
19
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
20
|
+
if (!encryptedParams)
|
|
21
|
+
throw new ZaloApiError("Failed to encrypt params");
|
|
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,3 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type RemoveReminderResponse = "" | number;
|
|
3
|
+
export declare const removeReminderFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (reminderId: string, threadId: string, type?: ThreadType) => Promise<RemoveReminderResponse>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ZaloApiError } from "../Errors/ZaloApiError.js";
|
|
2
|
+
import { ThreadType } from "../models/index.js";
|
|
3
|
+
import { apiFactory } from "../utils.js";
|
|
4
|
+
export const removeReminderFactory = apiFactory()((api, ctx, utils) => {
|
|
5
|
+
const serviceURL = {
|
|
6
|
+
[ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/oneone/remove`),
|
|
7
|
+
[ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group_board[0]}/api/board/topic/remove`),
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Remove a reminder in a (user/group)
|
|
11
|
+
*
|
|
12
|
+
* @param reminderId Reminder ID to remove reminder from
|
|
13
|
+
* @param threadId (User/Group) ID to remove reminder from
|
|
14
|
+
* @param type Thread type (User or Group)
|
|
15
|
+
*
|
|
16
|
+
* @throws {ZaloApiError}
|
|
17
|
+
*/
|
|
18
|
+
return async function removeReminder(reminderId, threadId, type = ThreadType.User) {
|
|
19
|
+
const params = type === ThreadType.User
|
|
20
|
+
? {
|
|
21
|
+
uid: threadId,
|
|
22
|
+
reminderId: reminderId,
|
|
23
|
+
}
|
|
24
|
+
: {
|
|
25
|
+
grid: threadId,
|
|
26
|
+
topicId: reminderId,
|
|
27
|
+
imei: ctx.imei,
|
|
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(serviceURL[type], {
|
|
33
|
+
method: "POST",
|
|
34
|
+
body: new URLSearchParams({
|
|
35
|
+
params: encryptedParams,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
return utils.resolve(response);
|
|
39
|
+
};
|
|
40
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ThreadType } from "../models/index.js";
|
|
2
|
+
export type RemoveUnreadMarkResponse = {
|
|
3
|
+
data: {
|
|
4
|
+
updateId: number;
|
|
5
|
+
};
|
|
6
|
+
status: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const removeUnreadMarkFactory: (ctx: import("../context.js").ContextBase, api: import("../apis.js").API) => (threadId: string, type?: ThreadType) => Promise<RemoveUnreadMarkResponse>;
|