zalo-api-sdk 1.0.0
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/.tmp-cache/_update-notifier-last-checked +0 -0
- package/CODE_OF_CONDUCT.md +157 -0
- package/CONTRIBUTING.md +491 -0
- package/LICENSE +21 -0
- package/README.md +421 -0
- package/SECURITY.md +82 -0
- package/commit-push.sh +79 -0
- package/deploy.sh +172 -0
- package/dist/Errors/ZaloApiError.d.ts +4 -0
- package/dist/Errors/ZaloApiError.js +7 -0
- package/dist/Errors/index.d.ts +1 -0
- package/dist/Errors/index.js +1 -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/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/createNoteGroup.d.ts +7 -0
- package/dist/apis/createNoteGroup.js +47 -0
- package/dist/apis/createPoll.d.ts +57 -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 +10 -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/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/editNoteGroup.d.ts +32 -0
- package/dist/apis/editNoteGroup.js +40 -0
- package/dist/apis/editReminder.d.ts +18 -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 +34 -0
- package/dist/apis/fetchAccountInfo.js +10 -0
- package/dist/apis/findUser.d.ts +15 -0
- package/dist/apis/findUser.js +40 -0
- package/dist/apis/forwardMessage.d.ts +26 -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 +34 -0
- package/dist/apis/getAllFriends.js +32 -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/getBizAccount.d.ts +19 -0
- package/dist/apis/getBizAccount.js +27 -0
- package/dist/apis/getCatalogList.d.ts +12 -0
- package/dist/apis/getCatalogList.js +32 -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/getFriendRequestStatus.d.ts +8 -0
- package/dist/apis/getFriendRequestStatus.js +25 -0
- package/dist/apis/getGroupBlockedMember.d.ts +17 -0
- package/dist/apis/getGroupBlockedMember.js +29 -0
- package/dist/apis/getGroupInfo.d.ts +43 -0
- package/dist/apis/getGroupInfo.js +32 -0
- package/dist/apis/getGroupLinkDetail.d.ts +6 -0
- package/dist/apis/getGroupLinkDetail.js +25 -0
- package/dist/apis/getGroupLinkInfo.d.ts +31 -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 +15 -0
- package/dist/apis/getLabels.js +28 -0
- package/dist/apis/getListBoard.d.ts +15 -0
- package/dist/apis/getListBoard.js +45 -0
- package/dist/apis/getListReminder.d.ts +22 -0
- package/dist/apis/getListReminder.js +47 -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 +10 -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 +14 -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/getQuickMessage.d.ts +7 -0
- package/dist/apis/getQuickMessage.js +24 -0
- package/dist/apis/getReceivedFriendRequests.d.ts +35 -0
- package/dist/apis/getReceivedFriendRequests.js +22 -0
- package/dist/apis/getReminder.d.ts +13 -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 +17 -0
- package/dist/apis/getSentFriendRequest.js +24 -0
- package/dist/apis/getStickers.d.ts +1 -0
- package/dist/apis/getStickers.js +40 -0
- package/dist/apis/getStickersDetail.d.ts +24 -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 +39 -0
- package/dist/apis/getUserInfo.js +42 -0
- package/dist/apis/inviteUserToGroups.d.ts +10 -0
- package/dist/apis/inviteUserToGroups.js +30 -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 +100 -0
- package/dist/apis/listen.js +424 -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 +70 -0
- package/dist/apis/loginQR.js +359 -0
- package/dist/apis/parseLink.d.ts +21 -0
- package/dist/apis/parseLink.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 +6 -0
- package/dist/apis/reviewPendingMemberRequest.js +31 -0
- package/dist/apis/sendBankCard.d.ts +9 -0
- package/dist/apis/sendBankCard.js +39 -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 +460 -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 +6 -0
- package/dist/apis/sendSticker.js +56 -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 +37 -0
- package/dist/apis/setMute.d.ts +17 -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/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/updateAutoDeleteChat.d.ts +9 -0
- package/dist/apis/updateAutoDeleteChat.js +40 -0
- package/dist/apis/updateAutoReply.d.ts +14 -0
- package/dist/apis/updateAutoReply.js +37 -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 +24 -0
- package/dist/apis/updateLabels.js +34 -0
- package/dist/apis/updateLang.d.ts +7 -0
- package/dist/apis/updateLang.js +32 -0
- package/dist/apis/updateProductCatalog.d.ts +25 -0
- package/dist/apis/updateProductCatalog.js +51 -0
- package/dist/apis/updateProfile.d.ts +13 -0
- package/dist/apis/updateProfile.js +42 -0
- package/dist/apis/updateQuickMessage.d.ts +11 -0
- package/dist/apis/updateQuickMessage.js +61 -0
- package/dist/apis/updateSettings.d.ts +3 -0
- package/dist/apis/updateSettings.js +23 -0
- package/dist/apis/uploadAttachment.d.ts +50 -0
- package/dist/apis/uploadAttachment.js +205 -0
- package/dist/apis/uploadProductPhoto.d.ts +14 -0
- package/dist/apis/uploadProductPhoto.js +50 -0
- package/dist/cjs/Errors/ZaloApiError.cjs +11 -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/addQuickMessage.cjs +65 -0
- package/dist/cjs/apis/addReaction.cjs +304 -0
- package/dist/cjs/apis/addUnreadMark.cjs +62 -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/createNoteGroup.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 +73 -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 +60 -0
- package/dist/cjs/apis/deleteMessage.cjs +62 -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/editNoteGroup.cjs +45 -0
- package/dist/cjs/apis/editReminder.cjs +71 -0
- package/dist/cjs/apis/enableGroupLink.cjs +30 -0
- package/dist/cjs/apis/fetchAccountInfo.cjs +15 -0
- package/dist/cjs/apis/findUser.cjs +45 -0
- package/dist/cjs/apis/forwardMessage.cjs +109 -0
- package/dist/cjs/apis/getAliasList.cjs +32 -0
- package/dist/cjs/apis/getAllFriends.cjs +37 -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/getBizAccount.cjs +32 -0
- package/dist/cjs/apis/getCatalogList.cjs +37 -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/getFriendRequestStatus.cjs +30 -0
- package/dist/cjs/apis/getGroupBlockedMember.cjs +34 -0
- package/dist/cjs/apis/getGroupInfo.cjs +37 -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 +55 -0
- package/dist/cjs/apis/getListReminder.cjs +57 -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/getQuickMessage.cjs +29 -0
- package/dist/cjs/apis/getReceivedFriendRequests.cjs +27 -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/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 +47 -0
- package/dist/cjs/apis/inviteUserToGroups.cjs +35 -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 +435 -0
- package/dist/cjs/apis/lockPoll.cjs +33 -0
- package/dist/cjs/apis/login.cjs +102 -0
- package/dist/cjs/apis/loginQR.cjs +364 -0
- package/dist/cjs/apis/parseLink.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 +50 -0
- package/dist/cjs/apis/removeUnreadMark.cjs +60 -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 +36 -0
- package/dist/cjs/apis/sendBankCard.cjs +49 -0
- package/dist/cjs/apis/sendCard.cjs +69 -0
- package/dist/cjs/apis/sendDeliveredEvent.cjs +65 -0
- package/dist/cjs/apis/sendFriendRequest.cjs +44 -0
- package/dist/cjs/apis/sendLink.cjs +71 -0
- package/dist/cjs/apis/sendMessage.cjs +469 -0
- package/dist/cjs/apis/sendReport.cjs +63 -0
- package/dist/cjs/apis/sendSeenEvent.cjs +73 -0
- package/dist/cjs/apis/sendSticker.cjs +66 -0
- package/dist/cjs/apis/sendTypingEvent.cjs +43 -0
- package/dist/cjs/apis/sendVideo.cjs +128 -0
- package/dist/cjs/apis/sendVoice.cjs +83 -0
- package/dist/cjs/apis/setHiddenConversations.cjs +47 -0
- package/dist/cjs/apis/setMute.cjs +77 -0
- package/dist/cjs/apis/setPinnedConversations.cjs +44 -0
- package/dist/cjs/apis/unblockUser.cjs +33 -0
- package/dist/cjs/apis/undo.cjs +52 -0
- package/dist/cjs/apis/undoFriendRequest.cjs +32 -0
- package/dist/cjs/apis/updateAutoDeleteChat.cjs +50 -0
- package/dist/cjs/apis/updateAutoReply.cjs +42 -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 +37 -0
- package/dist/cjs/apis/updateProductCatalog.cjs +56 -0
- package/dist/cjs/apis/updateProfile.cjs +47 -0
- package/dist/cjs/apis/updateQuickMessage.cjs +66 -0
- package/dist/cjs/apis/updateSettings.cjs +28 -0
- package/dist/cjs/apis/uploadAttachment.cjs +215 -0
- package/dist/cjs/apis/uploadProductPhoto.cjs +55 -0
- package/dist/cjs/context.cjs +34 -0
- package/dist/cjs/index.cjs +121 -0
- package/dist/cjs/models/AutoReply.cjs +9 -0
- package/dist/cjs/models/DeliveredMessage.cjs +23 -0
- package/dist/cjs/models/Enum.cjs +95 -0
- package/dist/cjs/models/FriendEvent.cjs +87 -0
- package/dist/cjs/models/GroupEvent.cjs +88 -0
- package/dist/cjs/models/Message.cjs +32 -0
- package/dist/cjs/models/Reaction.cjs +74 -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 +46 -0
- package/dist/cjs/update.cjs +27 -0
- package/dist/cjs/utils.cjs +732 -0
- package/dist/cjs/zalo.cjs +360 -0
- package/dist/context.d.ts +177 -0
- package/dist/context.js +28 -0
- package/dist/index.d.ts +130 -0
- package/dist/index.js +11 -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 +54 -0
- package/dist/models/Board.js +1 -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 +87 -0
- package/dist/models/Enum.js +93 -0
- package/dist/models/FriendEvent.d.ts +107 -0
- package/dist/models/FriendEvent.js +83 -0
- package/dist/models/GroupEvent.d.ts +197 -0
- package/dist/models/GroupEvent.js +84 -0
- package/dist/models/Message.d.ts +91 -0
- package/dist/models/Message.js +26 -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 +35 -0
- package/dist/models/Reminder.js +1 -0
- package/dist/models/SeenMessage.d.ts +26 -0
- package/dist/models/SeenMessage.js +17 -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/ZBusiness.d.ts +29 -0
- package/dist/models/ZBusiness.js +42 -0
- package/dist/models/index.d.ts +17 -0
- package/dist/models/index.js +17 -0
- package/dist/update.d.ts +2 -0
- package/dist/update.js +22 -0
- package/dist/utils.d.ts +168 -0
- package/dist/utils.js +748 -0
- package/dist/zalo.d.ts +291 -0
- package/dist/zalo.js +354 -0
- package/eslint.config.js +21 -0
- package/index.d.ts +2 -0
- package/package.json +143 -0
- package/qr.png +0 -0
- package/rollup.config.js +28 -0
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var FormData = require('form-data');
|
|
4
|
+
var fs = require('node:fs/promises');
|
|
5
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
6
|
+
var Enum = require('../models/Enum.cjs');
|
|
7
|
+
require('../models/FriendEvent.cjs');
|
|
8
|
+
require('../models/GroupEvent.cjs');
|
|
9
|
+
require('../models/Reaction.cjs');
|
|
10
|
+
require('../models/ZBusiness.cjs');
|
|
11
|
+
require('../models/AutoReply.cjs');
|
|
12
|
+
var utils = require('../utils.cjs');
|
|
13
|
+
|
|
14
|
+
const attachmentUrlType = {
|
|
15
|
+
image: "photo_original/send?",
|
|
16
|
+
gif: "gif?",
|
|
17
|
+
video: "asyncfile/msg?",
|
|
18
|
+
others: "asyncfile/msg?",
|
|
19
|
+
};
|
|
20
|
+
function prepareQMSGAttach(quote) {
|
|
21
|
+
const quoteData = quote;
|
|
22
|
+
if (typeof quoteData.content == "string")
|
|
23
|
+
return quoteData.propertyExt;
|
|
24
|
+
if (quoteData.msgType == "chat.todo")
|
|
25
|
+
return {
|
|
26
|
+
properties: {
|
|
27
|
+
color: 0,
|
|
28
|
+
size: 0,
|
|
29
|
+
type: 0,
|
|
30
|
+
subType: 0,
|
|
31
|
+
ext: '{"shouldParseLinkOrContact":0}',
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
return Object.assign(Object.assign({}, quoteData.content), { thumbUrl: quoteData.content.thumb, oriUrl: quoteData.content.href, normalUrl: quoteData.content.href });
|
|
35
|
+
}
|
|
36
|
+
function prepareQMSG(quote) {
|
|
37
|
+
const quoteData = quote;
|
|
38
|
+
if (quoteData.msgType == "chat.todo" && typeof quoteData.content == "object" && typeof quoteData.content.params == "string") {
|
|
39
|
+
return JSON.parse(quoteData.content.params).item.content;
|
|
40
|
+
}
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
exports.TextStyle = void 0;
|
|
44
|
+
(function (TextStyle) {
|
|
45
|
+
TextStyle["Bold"] = "b";
|
|
46
|
+
TextStyle["Italic"] = "i";
|
|
47
|
+
TextStyle["Underline"] = "u";
|
|
48
|
+
TextStyle["StrikeThrough"] = "s";
|
|
49
|
+
TextStyle["Red"] = "c_db342e";
|
|
50
|
+
TextStyle["Orange"] = "c_f27806";
|
|
51
|
+
TextStyle["Yellow"] = "c_f7b503";
|
|
52
|
+
TextStyle["Green"] = "c_15a85f";
|
|
53
|
+
TextStyle["Small"] = "f_13";
|
|
54
|
+
TextStyle["Big"] = "f_18";
|
|
55
|
+
TextStyle["UnorderedList"] = "lst_1";
|
|
56
|
+
TextStyle["OrderedList"] = "lst_2";
|
|
57
|
+
TextStyle["Indent"] = "ind_$";
|
|
58
|
+
})(exports.TextStyle || (exports.TextStyle = {}));
|
|
59
|
+
exports.Urgency = void 0;
|
|
60
|
+
(function (Urgency) {
|
|
61
|
+
Urgency[Urgency["Default"] = 0] = "Default";
|
|
62
|
+
Urgency[Urgency["Important"] = 1] = "Important";
|
|
63
|
+
Urgency[Urgency["Urgent"] = 2] = "Urgent";
|
|
64
|
+
})(exports.Urgency || (exports.Urgency = {}));
|
|
65
|
+
const sendMessageFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
66
|
+
const serviceURLs = {
|
|
67
|
+
message: {
|
|
68
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message`, {
|
|
69
|
+
nretry: 0,
|
|
70
|
+
}),
|
|
71
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group`, {
|
|
72
|
+
nretry: 0,
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
attachment: {
|
|
76
|
+
[Enum.ThreadType.User]: `${api.zpwServiceMap.file[0]}/api/message/`,
|
|
77
|
+
[Enum.ThreadType.Group]: `${api.zpwServiceMap.file[0]}/api/group/`,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
const { sharefile } = ctx.settings.features;
|
|
81
|
+
function isExceedMaxFile(totalFile) {
|
|
82
|
+
return totalFile > sharefile.max_file;
|
|
83
|
+
}
|
|
84
|
+
function isExceedMaxFileSize(fileSize) {
|
|
85
|
+
return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
|
|
86
|
+
}
|
|
87
|
+
function getGroupLayoutId() {
|
|
88
|
+
return Date.now();
|
|
89
|
+
}
|
|
90
|
+
async function send(data) {
|
|
91
|
+
if (!Array.isArray(data))
|
|
92
|
+
data = [data];
|
|
93
|
+
const requests = [];
|
|
94
|
+
for (const each of data) {
|
|
95
|
+
requests.push((async () => {
|
|
96
|
+
const response = await utils$1.request(each.url, {
|
|
97
|
+
method: "POST",
|
|
98
|
+
body: each.body,
|
|
99
|
+
headers: each.headers,
|
|
100
|
+
});
|
|
101
|
+
return await utils.resolveResponse(ctx, response);
|
|
102
|
+
})());
|
|
103
|
+
}
|
|
104
|
+
return await Promise.all(requests);
|
|
105
|
+
}
|
|
106
|
+
async function upthumb(source, url) {
|
|
107
|
+
const formData = new FormData();
|
|
108
|
+
const buffer = typeof source == "string" ? await fs.readFile(source) : source.data;
|
|
109
|
+
formData.append("fileContent", buffer, {
|
|
110
|
+
filename: "blob",
|
|
111
|
+
contentType: "image/png",
|
|
112
|
+
});
|
|
113
|
+
const params = {
|
|
114
|
+
clientId: Date.now(),
|
|
115
|
+
imei: ctx.imei,
|
|
116
|
+
};
|
|
117
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
118
|
+
if (!encryptedParams)
|
|
119
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
120
|
+
const response = await utils$1.request(utils$1.makeURL(url + "upthumb?", {
|
|
121
|
+
params: encryptedParams,
|
|
122
|
+
}), {
|
|
123
|
+
method: "POST",
|
|
124
|
+
headers: formData.getHeaders(),
|
|
125
|
+
body: formData.getBuffer(),
|
|
126
|
+
});
|
|
127
|
+
return await utils.resolveResponse(ctx, response);
|
|
128
|
+
}
|
|
129
|
+
function handleMentions(type, msg, mentions) {
|
|
130
|
+
let totalMentionLen = 0;
|
|
131
|
+
const mentionsFinal = Array.isArray(mentions) && type == Enum.ThreadType.Group
|
|
132
|
+
? mentions
|
|
133
|
+
.filter((m) => m.pos >= 0 && m.uid && m.len > 0)
|
|
134
|
+
.map((m) => {
|
|
135
|
+
totalMentionLen += m.len;
|
|
136
|
+
return {
|
|
137
|
+
pos: m.pos,
|
|
138
|
+
uid: m.uid,
|
|
139
|
+
len: m.len,
|
|
140
|
+
type: m.uid == "-1" ? 1 : 0,
|
|
141
|
+
};
|
|
142
|
+
})
|
|
143
|
+
: [];
|
|
144
|
+
if (totalMentionLen > (msg === null || msg === void 0 ? void 0 : msg.length)) {
|
|
145
|
+
throw new ZaloApiError.ZaloApiError("Invalid mentions: total mention characters exceed message length");
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
mentionsFinal,
|
|
149
|
+
msgFinal: msg,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function handleStyles(params, styles) {
|
|
153
|
+
if (styles)
|
|
154
|
+
Object.assign(params, {
|
|
155
|
+
textProperties: JSON.stringify({
|
|
156
|
+
styles: styles.map((e) => {
|
|
157
|
+
var _a;
|
|
158
|
+
const styleFinal = Object.assign(Object.assign({}, e), { indentSize: undefined, st: e.st == exports.TextStyle.Indent
|
|
159
|
+
? exports.TextStyle.Indent.replace(/\$/g, `${(_a = e.indentSize) !== null && _a !== void 0 ? _a : 1}0`)
|
|
160
|
+
: e.st });
|
|
161
|
+
utils.removeUndefinedKeys(styleFinal);
|
|
162
|
+
return styleFinal;
|
|
163
|
+
}),
|
|
164
|
+
ver: 0,
|
|
165
|
+
}),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function handleUrgency(params, urgency) {
|
|
169
|
+
if (urgency == exports.Urgency.Important || urgency == exports.Urgency.Urgent) {
|
|
170
|
+
Object.assign(params, { metaData: { urgency } });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function handleMessage({ msg, styles, urgency, mentions, quote, ttl }, threadId, type) {
|
|
174
|
+
if (!msg || (msg === null || msg === void 0 ? void 0 : msg.length) == 0)
|
|
175
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
176
|
+
const isGroupMessage = type == Enum.ThreadType.Group;
|
|
177
|
+
const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
|
|
178
|
+
msg = msgFinal;
|
|
179
|
+
if (quote) {
|
|
180
|
+
if (typeof quote.content != "string" && quote.msgType == "webchat") {
|
|
181
|
+
throw new ZaloApiError.ZaloApiError("This kind of `webchat` quote type is not available");
|
|
182
|
+
}
|
|
183
|
+
if (quote.msgType == "group.poll") {
|
|
184
|
+
throw new ZaloApiError.ZaloApiError("The `group.poll` quote type is not available");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage;
|
|
188
|
+
const params = quote
|
|
189
|
+
? {
|
|
190
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
191
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
192
|
+
message: msg,
|
|
193
|
+
clientId: Date.now(),
|
|
194
|
+
mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
|
|
195
|
+
qmsgOwner: quote.uidFrom,
|
|
196
|
+
qmsgId: quote.msgId,
|
|
197
|
+
qmsgCliId: quote.cliMsgId,
|
|
198
|
+
qmsgType: utils.getClientMessageType(quote.msgType),
|
|
199
|
+
qmsgTs: quote.ts,
|
|
200
|
+
qmsg: typeof quote.content == "string" ? quote.content : prepareQMSG(quote),
|
|
201
|
+
imei: isGroupMessage ? undefined : ctx.imei,
|
|
202
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
203
|
+
qmsgAttach: isGroupMessage ? JSON.stringify(prepareQMSGAttach(quote)) : undefined,
|
|
204
|
+
qmsgTTL: quote.ttl,
|
|
205
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
206
|
+
}
|
|
207
|
+
: {
|
|
208
|
+
message: msg,
|
|
209
|
+
clientId: Date.now(),
|
|
210
|
+
mentionInfo: isMentionsValid ? JSON.stringify(mentionsFinal) : undefined,
|
|
211
|
+
imei: isGroupMessage ? undefined : ctx.imei,
|
|
212
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
213
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
214
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
215
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
216
|
+
};
|
|
217
|
+
handleStyles(params, styles);
|
|
218
|
+
handleUrgency(params, urgency);
|
|
219
|
+
utils.removeUndefinedKeys(params);
|
|
220
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
221
|
+
if (!encryptedParams)
|
|
222
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
223
|
+
const finalServiceUrl = new URL(serviceURLs.message[type]);
|
|
224
|
+
if (quote) {
|
|
225
|
+
finalServiceUrl.pathname = finalServiceUrl.pathname + "/quote";
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
finalServiceUrl.pathname =
|
|
229
|
+
finalServiceUrl.pathname +
|
|
230
|
+
"/" +
|
|
231
|
+
(isGroupMessage ? (params.mentionInfo ? "mention" : "sendmsg") : "sms");
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
url: finalServiceUrl.toString(),
|
|
235
|
+
body: new URLSearchParams({ params: encryptedParams }),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
async function handleAttachment({ msg, attachments, mentions, quote, ttl, urgency }, threadId, type) {
|
|
239
|
+
if (!attachments)
|
|
240
|
+
throw new ZaloApiError.ZaloApiError("Missing attachments");
|
|
241
|
+
if (!Array.isArray(attachments))
|
|
242
|
+
attachments = [attachments];
|
|
243
|
+
if (attachments.length == 0)
|
|
244
|
+
throw new ZaloApiError.ZaloApiError("Missing attachments");
|
|
245
|
+
attachments = await Promise.all(attachments.map(async (att) => {
|
|
246
|
+
if (typeof att === "string" && /^https?:\/\//i.test(att)) {
|
|
247
|
+
const downloaded = await utils.downloadAttachmentFromUrl(att);
|
|
248
|
+
if (!downloaded)
|
|
249
|
+
throw new ZaloApiError.ZaloApiError(`Failed to download attachment from URL: ${att}`);
|
|
250
|
+
return downloaded;
|
|
251
|
+
}
|
|
252
|
+
return att;
|
|
253
|
+
}));
|
|
254
|
+
const firstSource = attachments[0];
|
|
255
|
+
const firstExtFile = utils.getExtensionFromSource(firstSource);
|
|
256
|
+
const isSingleFile = attachments.length == 1;
|
|
257
|
+
const isGroupMessage = type == Enum.ThreadType.Group;
|
|
258
|
+
const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
|
|
259
|
+
const gifFiles = attachments.filter((e) => utils.getExtensionFromSource(e) == "gif");
|
|
260
|
+
attachments = attachments.filter((e) => utils.getExtensionFromSource(e) != "gif");
|
|
261
|
+
const uploadAttachment = attachments.length == 0 ? [] : await api.uploadAttachment(attachments, threadId, type);
|
|
262
|
+
const attachmentsData = [];
|
|
263
|
+
let indexInGroupLayout = uploadAttachment.length - 1;
|
|
264
|
+
const groupLayoutId = getGroupLayoutId();
|
|
265
|
+
const { mentionsFinal, msgFinal } = handleMentions(type, msg, mentions);
|
|
266
|
+
msg = msgFinal;
|
|
267
|
+
const isMentionsValid = mentionsFinal.length > 0 && isGroupMessage && attachments.length == 1;
|
|
268
|
+
const isMultiFile = attachments.length > 1;
|
|
269
|
+
let clientId = Date.now();
|
|
270
|
+
for (const attachment of uploadAttachment) {
|
|
271
|
+
let data;
|
|
272
|
+
switch (attachment.fileType) {
|
|
273
|
+
case "image": {
|
|
274
|
+
data = {
|
|
275
|
+
fileType: attachment.fileType,
|
|
276
|
+
params: {
|
|
277
|
+
photoId: attachment.photoId,
|
|
278
|
+
clientId: (clientId++).toString(),
|
|
279
|
+
desc: msg,
|
|
280
|
+
width: attachment.width,
|
|
281
|
+
height: attachment.height,
|
|
282
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
283
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
284
|
+
rawUrl: attachment.normalUrl,
|
|
285
|
+
hdUrl: attachment.hdUrl,
|
|
286
|
+
thumbUrl: attachment.thumbUrl,
|
|
287
|
+
oriUrl: isGroupMessage ? attachment.normalUrl : undefined,
|
|
288
|
+
normalUrl: isGroupMessage ? undefined : attachment.normalUrl,
|
|
289
|
+
hdSize: String(attachment.totalSize),
|
|
290
|
+
zsource: -1,
|
|
291
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
292
|
+
jcp: '{"convertible":"jxl"}',
|
|
293
|
+
groupLayoutId: isMultiFile ? groupLayoutId : undefined,
|
|
294
|
+
isGroupLayout: isMultiFile ? 1 : undefined,
|
|
295
|
+
idInGroup: isMultiFile ? indexInGroupLayout-- : undefined,
|
|
296
|
+
totalItemInGroup: isMultiFile ? uploadAttachment.length : undefined,
|
|
297
|
+
mentionInfo: isMentionsValid && canBeDesc && !quote ? JSON.stringify(mentionsFinal) : undefined,
|
|
298
|
+
},
|
|
299
|
+
body: new URLSearchParams(),
|
|
300
|
+
};
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case "video": {
|
|
304
|
+
data = {
|
|
305
|
+
fileType: attachment.fileType,
|
|
306
|
+
params: {
|
|
307
|
+
fileId: attachment.fileId,
|
|
308
|
+
checksum: attachment.checksum,
|
|
309
|
+
checksumSha: "",
|
|
310
|
+
extention: utils.getFileExtension(attachment.fileName),
|
|
311
|
+
totalSize: attachment.totalSize,
|
|
312
|
+
fileName: attachment.fileName,
|
|
313
|
+
clientId: attachment.clientFileId,
|
|
314
|
+
fType: 1,
|
|
315
|
+
fileCount: 0,
|
|
316
|
+
fdata: "{}",
|
|
317
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
318
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
319
|
+
fileUrl: attachment.fileUrl,
|
|
320
|
+
zsource: -1,
|
|
321
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
322
|
+
},
|
|
323
|
+
body: new URLSearchParams(),
|
|
324
|
+
};
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
case "others": {
|
|
328
|
+
data = {
|
|
329
|
+
fileType: attachment.fileType,
|
|
330
|
+
params: {
|
|
331
|
+
fileId: attachment.fileId,
|
|
332
|
+
checksum: attachment.checksum,
|
|
333
|
+
checksumSha: "",
|
|
334
|
+
extention: utils.getFileExtension(attachment.fileName),
|
|
335
|
+
totalSize: attachment.totalSize,
|
|
336
|
+
fileName: attachment.fileName,
|
|
337
|
+
clientId: attachment.clientFileId,
|
|
338
|
+
fType: 1,
|
|
339
|
+
fileCount: 0,
|
|
340
|
+
fdata: "{}",
|
|
341
|
+
toid: isGroupMessage ? undefined : String(threadId),
|
|
342
|
+
grid: isGroupMessage ? String(threadId) : undefined,
|
|
343
|
+
fileUrl: attachment.fileUrl,
|
|
344
|
+
zsource: -1,
|
|
345
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
346
|
+
},
|
|
347
|
+
body: new URLSearchParams(),
|
|
348
|
+
};
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
handleUrgency(data.params, urgency);
|
|
353
|
+
utils.removeUndefinedKeys(data.params);
|
|
354
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(data.params));
|
|
355
|
+
if (!encryptedParams)
|
|
356
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
357
|
+
data.body.append("params", encryptedParams);
|
|
358
|
+
attachmentsData.push(data);
|
|
359
|
+
}
|
|
360
|
+
for (const gif of gifFiles) {
|
|
361
|
+
const isFilePath = typeof gif == "string";
|
|
362
|
+
const gifData = isFilePath ? await utils.getGifMetaData(gif) : Object.assign(Object.assign({}, gif.metadata), { fileName: gif.filename });
|
|
363
|
+
if (isExceedMaxFileSize(gifData.totalSize))
|
|
364
|
+
throw new ZaloApiError.ZaloApiError(`File ${isFilePath ? utils.getFileName(gif) : gif.filename} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
365
|
+
const _upthumb = await upthumb(gif, serviceURLs.attachment[Enum.ThreadType.User]);
|
|
366
|
+
const formData = new FormData();
|
|
367
|
+
formData.append("chunkContent", isFilePath ? await fs.readFile(gif) : gif.data, {
|
|
368
|
+
filename: isFilePath ? utils.getFileName(gif) : gif.filename,
|
|
369
|
+
contentType: "application/octet-stream",
|
|
370
|
+
});
|
|
371
|
+
const params = {
|
|
372
|
+
clientId: Date.now().toString(),
|
|
373
|
+
fileName: gifData.fileName,
|
|
374
|
+
totalSize: gifData.totalSize,
|
|
375
|
+
width: gifData.width,
|
|
376
|
+
height: gifData.height,
|
|
377
|
+
msg: msg,
|
|
378
|
+
type: 1,
|
|
379
|
+
ttl: ttl !== null && ttl !== void 0 ? ttl : 0,
|
|
380
|
+
visibility: isGroupMessage ? 0 : undefined,
|
|
381
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
382
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
383
|
+
thumb: _upthumb.url,
|
|
384
|
+
checksum: (await utils.getMd5LargeFileObject(gif, gifData.totalSize)).data,
|
|
385
|
+
totalChunk: 1,
|
|
386
|
+
chunkId: 1,
|
|
387
|
+
};
|
|
388
|
+
handleUrgency(params, urgency);
|
|
389
|
+
utils.removeUndefinedKeys(params);
|
|
390
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
391
|
+
if (!encryptedParams)
|
|
392
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
393
|
+
attachmentsData.push({
|
|
394
|
+
query: {
|
|
395
|
+
params: encryptedParams,
|
|
396
|
+
type: "1",
|
|
397
|
+
},
|
|
398
|
+
body: formData.getBuffer(),
|
|
399
|
+
headers: formData.getHeaders(),
|
|
400
|
+
fileType: "gif",
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
const responses = [];
|
|
404
|
+
for (const data of attachmentsData) {
|
|
405
|
+
responses.push({
|
|
406
|
+
url: utils$1.makeURL(serviceURLs.attachment[type] + attachmentUrlType[data.fileType], Object.assign({
|
|
407
|
+
nretry: "0",
|
|
408
|
+
}, data.query || {})),
|
|
409
|
+
body: data.body,
|
|
410
|
+
headers: data.fileType == "gif" ? data.headers : {},
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
return responses;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Send a message to a thread
|
|
417
|
+
*
|
|
418
|
+
* @param message Message content
|
|
419
|
+
* @param threadId group or user id
|
|
420
|
+
* @param type Message type (User or Group)
|
|
421
|
+
* @param quote Message or GroupMessage instance (optional), used for quoting
|
|
422
|
+
*
|
|
423
|
+
* @throws {ZaloApiError}
|
|
424
|
+
*/
|
|
425
|
+
return async function sendMessage(message, threadId, type = Enum.ThreadType.User) {
|
|
426
|
+
if (!message)
|
|
427
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
428
|
+
if (!threadId)
|
|
429
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
430
|
+
if (typeof message == "string")
|
|
431
|
+
message = { msg: message };
|
|
432
|
+
let { msg, attachments, mentions } = message;
|
|
433
|
+
const { quote, ttl, styles, urgency } = message;
|
|
434
|
+
if (attachments && !Array.isArray(attachments)) {
|
|
435
|
+
attachments = [attachments];
|
|
436
|
+
}
|
|
437
|
+
if (!msg && (!attachments || (attachments && attachments.length == 0)))
|
|
438
|
+
throw new ZaloApiError.ZaloApiError("Missing message content");
|
|
439
|
+
if (attachments && isExceedMaxFile(attachments.length))
|
|
440
|
+
throw new ZaloApiError.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
|
|
441
|
+
const responses = {
|
|
442
|
+
message: null,
|
|
443
|
+
attachment: [],
|
|
444
|
+
};
|
|
445
|
+
if (attachments && attachments.length > 0) {
|
|
446
|
+
const firstExtFile = utils.getExtensionFromSource(attachments[0]);
|
|
447
|
+
const isSingleFile = attachments.length == 1;
|
|
448
|
+
const canBeDesc = isSingleFile && ["jpg", "jpeg", "png", "webp"].includes(firstExtFile);
|
|
449
|
+
if ((!canBeDesc && (msg === null || msg === void 0 ? void 0 : msg.length) > 0) || ((msg === null || msg === void 0 ? void 0 : msg.length) > 0 && quote)) {
|
|
450
|
+
// send message and attachment separately
|
|
451
|
+
await handleMessage(message, threadId, type).then(async (data) => {
|
|
452
|
+
responses.message = (await send(data))[0];
|
|
453
|
+
});
|
|
454
|
+
msg = "";
|
|
455
|
+
mentions = undefined;
|
|
456
|
+
}
|
|
457
|
+
const handledData = await handleAttachment({ msg, mentions, attachments, quote, ttl, urgency }, threadId, type);
|
|
458
|
+
responses.attachment = await send(handledData);
|
|
459
|
+
msg = "";
|
|
460
|
+
}
|
|
461
|
+
if ((msg === null || msg === void 0 ? void 0 : msg.length) > 0) {
|
|
462
|
+
const handledData = await handleMessage(message, threadId, type);
|
|
463
|
+
responses.message = (await send(handledData))[0];
|
|
464
|
+
}
|
|
465
|
+
return responses;
|
|
466
|
+
};
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
exports.sendMessageFactory = sendMessageFactory;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var Enum = require('../models/Enum.cjs');
|
|
5
|
+
require('../models/FriendEvent.cjs');
|
|
6
|
+
require('../models/GroupEvent.cjs');
|
|
7
|
+
require('../models/Reaction.cjs');
|
|
8
|
+
require('../models/ZBusiness.cjs');
|
|
9
|
+
require('../models/AutoReply.cjs');
|
|
10
|
+
var utils = require('../utils.cjs');
|
|
11
|
+
|
|
12
|
+
exports.ReportReason = void 0;
|
|
13
|
+
(function (ReportReason) {
|
|
14
|
+
ReportReason[ReportReason["Sensitive"] = 1] = "Sensitive";
|
|
15
|
+
ReportReason[ReportReason["Annoy"] = 2] = "Annoy";
|
|
16
|
+
ReportReason[ReportReason["Fraud"] = 3] = "Fraud";
|
|
17
|
+
ReportReason[ReportReason["Other"] = 0] = "Other";
|
|
18
|
+
})(exports.ReportReason || (exports.ReportReason = {}));
|
|
19
|
+
const sendReportFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
20
|
+
const serviceURL = {
|
|
21
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/report/abuse-v2`),
|
|
22
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/reportabuse`),
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Send report to Zalo
|
|
26
|
+
*
|
|
27
|
+
* @param options Report options
|
|
28
|
+
* @param threadId The threadID to report
|
|
29
|
+
* @param type Thread type, default direct
|
|
30
|
+
*
|
|
31
|
+
* @throws ZaloApiError
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
return async function sendReport(options, threadId, type = Enum.ThreadType.User) {
|
|
35
|
+
const params = type == Enum.ThreadType.User
|
|
36
|
+
? {
|
|
37
|
+
idTo: threadId,
|
|
38
|
+
objId: "person.profile",
|
|
39
|
+
reason: options.reason.toString(),
|
|
40
|
+
content: options.reason == exports.ReportReason.Other ? options.content : undefined,
|
|
41
|
+
}
|
|
42
|
+
: {
|
|
43
|
+
uidTo: threadId,
|
|
44
|
+
type: 14,
|
|
45
|
+
reason: options.reason,
|
|
46
|
+
content: options.reason == exports.ReportReason.Other ? options.content : "",
|
|
47
|
+
imei: ctx.imei,
|
|
48
|
+
};
|
|
49
|
+
utils.removeUndefinedKeys(params);
|
|
50
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
51
|
+
if (!encryptedParams)
|
|
52
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
53
|
+
const response = await utils$1.request(serviceURL[type], {
|
|
54
|
+
method: "POST",
|
|
55
|
+
body: new URLSearchParams({
|
|
56
|
+
params: encryptedParams,
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
return utils$1.resolve(response);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
exports.sendReportFactory = sendReportFactory;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var context = require('../context.cjs');
|
|
5
|
+
var Enum = require('../models/Enum.cjs');
|
|
6
|
+
require('../models/FriendEvent.cjs');
|
|
7
|
+
require('../models/GroupEvent.cjs');
|
|
8
|
+
require('../models/Reaction.cjs');
|
|
9
|
+
require('../models/ZBusiness.cjs');
|
|
10
|
+
require('../models/AutoReply.cjs');
|
|
11
|
+
var utils = require('../utils.cjs');
|
|
12
|
+
|
|
13
|
+
const sendSeenEventFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
14
|
+
const serviceURL = {
|
|
15
|
+
[Enum.ThreadType.User]: utils.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/seenv2`, {
|
|
16
|
+
nretry: 0,
|
|
17
|
+
}),
|
|
18
|
+
[Enum.ThreadType.Group]: utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/seenv2`, {
|
|
19
|
+
nretry: 0,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Send message seen event
|
|
24
|
+
*
|
|
25
|
+
* @param messages List of messages to send seen event
|
|
26
|
+
* @param type Messages type (User or Group), defaults to User
|
|
27
|
+
*
|
|
28
|
+
* @throws ZaloApiError
|
|
29
|
+
*/
|
|
30
|
+
return async function sendSeenEvent(messages, type = Enum.ThreadType.User) {
|
|
31
|
+
if (!messages)
|
|
32
|
+
throw new ZaloApiError.ZaloApiError("messages are missing or not in a valid array format.");
|
|
33
|
+
if (!Array.isArray(messages))
|
|
34
|
+
messages = [messages];
|
|
35
|
+
if (messages.length === 0 || messages.length > context.MAX_MESSAGES_PER_SEND)
|
|
36
|
+
throw new ZaloApiError.ZaloApiError("messages must contain between 1 and 50 messages.");
|
|
37
|
+
const isGroup = type === Enum.ThreadType.Group;
|
|
38
|
+
const threadId = isGroup ? messages[0].idTo : messages[0].uidFrom;
|
|
39
|
+
const msgInfos = {
|
|
40
|
+
data: messages.map((msg) => {
|
|
41
|
+
const curThreadId = isGroup ? msg.idTo : msg.uidFrom;
|
|
42
|
+
if (curThreadId !== threadId) {
|
|
43
|
+
throw new ZaloApiError.ZaloApiError("All messages must belong to the same thread.");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
cmi: msg.cliMsgId,
|
|
47
|
+
gmi: msg.msgId,
|
|
48
|
+
si: msg.uidFrom,
|
|
49
|
+
di: msg.idTo === ctx.uid ? "0" : msg.idTo,
|
|
50
|
+
mt: msg.msgType,
|
|
51
|
+
st: msg.st || 0 === msg.st ? 0 : -1,
|
|
52
|
+
at: msg.at || 0 === msg.at ? 0 : -1,
|
|
53
|
+
cmd: msg.cmd || 0 === msg.cmd ? 0 : -1,
|
|
54
|
+
ts: parseInt(`${msg.ts}`) || 0 === parseInt(`${msg.ts}`) ? 0 : -1,
|
|
55
|
+
};
|
|
56
|
+
}),
|
|
57
|
+
[isGroup ? "grid" : "senderId"]: threadId,
|
|
58
|
+
};
|
|
59
|
+
const params = Object.assign({ msgInfos: JSON.stringify(msgInfos) }, (isGroup ? { imei: ctx.imei } : {}));
|
|
60
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
61
|
+
if (!encryptedParams)
|
|
62
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
63
|
+
const response = await utils.request(serviceURL[type], {
|
|
64
|
+
method: "POST",
|
|
65
|
+
body: new URLSearchParams({
|
|
66
|
+
params: encryptedParams,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
return utils.resolve(response);
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
exports.sendSeenEventFactory = sendSeenEventFactory;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var Enum = require('../models/Enum.cjs');
|
|
5
|
+
require('../models/FriendEvent.cjs');
|
|
6
|
+
require('../models/GroupEvent.cjs');
|
|
7
|
+
require('../models/Reaction.cjs');
|
|
8
|
+
require('../models/ZBusiness.cjs');
|
|
9
|
+
require('../models/AutoReply.cjs');
|
|
10
|
+
var utils = require('../utils.cjs');
|
|
11
|
+
|
|
12
|
+
const sendStickerFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
13
|
+
const serviceURL = {
|
|
14
|
+
[Enum.ThreadType.User]: utils$1.makeURL(`${api.zpwServiceMap.chat[0]}/api/message/sticker`, {
|
|
15
|
+
nretry: "0",
|
|
16
|
+
}),
|
|
17
|
+
[Enum.ThreadType.Group]: utils$1.makeURL(`${api.zpwServiceMap.group[0]}/api/group/sticker`, {
|
|
18
|
+
nretry: "0",
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Send a sticker to a thread
|
|
23
|
+
*
|
|
24
|
+
* @param sticker Sticker object
|
|
25
|
+
* @param threadId group or user id
|
|
26
|
+
* @param type Message type (User or GroupMessage)
|
|
27
|
+
*
|
|
28
|
+
* @throws ZaloApiError
|
|
29
|
+
*/
|
|
30
|
+
return async function sendSticker(sticker, threadId, type = Enum.ThreadType.User) {
|
|
31
|
+
if (!sticker)
|
|
32
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker");
|
|
33
|
+
if (!threadId)
|
|
34
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
35
|
+
if (!sticker.id)
|
|
36
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker id");
|
|
37
|
+
if (!sticker.cateId)
|
|
38
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker cateId");
|
|
39
|
+
if (!sticker.type)
|
|
40
|
+
throw new ZaloApiError.ZaloApiError("Missing sticker type");
|
|
41
|
+
const isGroupMessage = type === Enum.ThreadType.Group;
|
|
42
|
+
const params = {
|
|
43
|
+
stickerId: sticker.id,
|
|
44
|
+
cateId: sticker.cateId,
|
|
45
|
+
type: sticker.type,
|
|
46
|
+
clientId: Date.now(),
|
|
47
|
+
imei: ctx.imei,
|
|
48
|
+
zsource: 101,
|
|
49
|
+
toid: isGroupMessage ? undefined : threadId,
|
|
50
|
+
grid: isGroupMessage ? threadId : undefined,
|
|
51
|
+
};
|
|
52
|
+
utils.removeUndefinedKeys(params);
|
|
53
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
54
|
+
if (!encryptedParams)
|
|
55
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
56
|
+
const response = await utils$1.request(serviceURL[type], {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: new URLSearchParams({
|
|
59
|
+
params: encryptedParams,
|
|
60
|
+
}),
|
|
61
|
+
});
|
|
62
|
+
return utils$1.resolve(response);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
exports.sendStickerFactory = sendStickerFactory;
|