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,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateGroupSettingsFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.group[0]}/api/group/setting/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Update group settings
|
|
10
|
+
*
|
|
11
|
+
* @param options Options
|
|
12
|
+
* @param groupId Group ID
|
|
13
|
+
*
|
|
14
|
+
* @note Zalo might throw an error with code 166 if you don't have enough permissions to change the settings.
|
|
15
|
+
*
|
|
16
|
+
* @throws ZaloApiError
|
|
17
|
+
*/
|
|
18
|
+
return async function updateGroupSettings(options, groupId) {
|
|
19
|
+
const params = {
|
|
20
|
+
blockName: options.blockName ? 1 : 0,
|
|
21
|
+
signAdminMsg: options.signAdminMsg ? 1 : 0,
|
|
22
|
+
// addMemberOnly: 0, // very tricky, any idea?
|
|
23
|
+
setTopicOnly: options.setTopicOnly ? 1 : 0,
|
|
24
|
+
enableMsgHistory: options.enableMsgHistory ? 1 : 0,
|
|
25
|
+
joinAppr: options.joinAppr ? 1 : 0,
|
|
26
|
+
lockCreatePost: options.lockCreatePost ? 1 : 0,
|
|
27
|
+
lockCreatePoll: options.lockCreatePoll ? 1 : 0,
|
|
28
|
+
lockSendMsg: options.lockSendMsg ? 1 : 0,
|
|
29
|
+
lockViewMember: options.lockViewMember ? 1 : 0,
|
|
30
|
+
// default values for not implemented options
|
|
31
|
+
bannFeature: 0,
|
|
32
|
+
dirtyMedia: 0,
|
|
33
|
+
banDuration: 0,
|
|
34
|
+
blocked_members: [],
|
|
35
|
+
grid: groupId,
|
|
36
|
+
imei: ctx.imei,
|
|
37
|
+
};
|
|
38
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
39
|
+
if (!encryptedParams)
|
|
40
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
41
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
42
|
+
method: "GET",
|
|
43
|
+
});
|
|
44
|
+
return utils.resolve(response);
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
exports.updateGroupSettingsFactory = updateGroupSettingsFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateHiddenConversPinFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
7
|
+
const serviceURL = utils$1.makeURL(`${api.zpwServiceMap.conversation[0]}/api/hiddenconvers/update-pin`);
|
|
8
|
+
const pinRegex = /^\d{4}$/;
|
|
9
|
+
/**
|
|
10
|
+
* Update hidden conversation pin
|
|
11
|
+
*
|
|
12
|
+
* @param pin The pin to update (must be a 4-digit number between 0000-9999)
|
|
13
|
+
*
|
|
14
|
+
* @throws ZaloApiError
|
|
15
|
+
*/
|
|
16
|
+
return async function updateHiddenConversPin(pin) {
|
|
17
|
+
if (!pinRegex.test(pin)) {
|
|
18
|
+
throw new ZaloApiError.ZaloApiError("Pin must be a 4-digit number between 0000-9999");
|
|
19
|
+
}
|
|
20
|
+
const encryptedPin = utils.encryptPin(pin);
|
|
21
|
+
const params = {
|
|
22
|
+
new_pin: encryptedPin,
|
|
23
|
+
imei: ctx.imei,
|
|
24
|
+
};
|
|
25
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
26
|
+
if (!encryptedParams)
|
|
27
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
28
|
+
const response = await utils$1.request(utils$1.makeURL(serviceURL, { params: encryptedParams }), {
|
|
29
|
+
method: "GET",
|
|
30
|
+
});
|
|
31
|
+
return utils$1.resolve(response);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
exports.updateHiddenConversPinFactory = updateHiddenConversPinFactory;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateLabelsFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.label[0]}/api/convlabel/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Update labels
|
|
10
|
+
*
|
|
11
|
+
* @param label label data
|
|
12
|
+
*
|
|
13
|
+
* @throws ZaloApiError
|
|
14
|
+
*/
|
|
15
|
+
return async function updateLabels(label) {
|
|
16
|
+
const params = {
|
|
17
|
+
labelData: JSON.stringify(label.labelData),
|
|
18
|
+
version: label.version,
|
|
19
|
+
imei: ctx.imei,
|
|
20
|
+
};
|
|
21
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
22
|
+
if (!encryptedParams)
|
|
23
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
24
|
+
const response = await utils.request(serviceURL, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
body: new URLSearchParams({
|
|
27
|
+
params: encryptedParams,
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
const unFormatted = (await utils.resolve(response));
|
|
31
|
+
return {
|
|
32
|
+
labelData: JSON.parse(unFormatted.labelData),
|
|
33
|
+
version: unFormatted.version,
|
|
34
|
+
lastUpdateTime: unFormatted.lastUpdateTime,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
exports.updateLabelsFactory = updateLabelsFactory;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
exports.UpdateLangAvailableLanguages = void 0;
|
|
7
|
+
(function (UpdateLangAvailableLanguages) {
|
|
8
|
+
UpdateLangAvailableLanguages["VI"] = "VI";
|
|
9
|
+
UpdateLangAvailableLanguages["EN"] = "EN";
|
|
10
|
+
UpdateLangAvailableLanguages["MY"] = "MY";
|
|
11
|
+
})(exports.UpdateLangAvailableLanguages || (exports.UpdateLangAvailableLanguages = {}));
|
|
12
|
+
const updateLangFactory = utils.apiFactory()((api, _, utils) => {
|
|
13
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/updatelang`);
|
|
14
|
+
/**
|
|
15
|
+
* Update language?
|
|
16
|
+
*
|
|
17
|
+
* @param language language to update (VI, EN, MY)
|
|
18
|
+
*
|
|
19
|
+
* @note Calling this API alone will not update the user's language.
|
|
20
|
+
*
|
|
21
|
+
* @throws ZaloApiError
|
|
22
|
+
*/
|
|
23
|
+
return async function updateLang(language = exports.UpdateLangAvailableLanguages.VI) {
|
|
24
|
+
const params = {
|
|
25
|
+
language: language,
|
|
26
|
+
};
|
|
27
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
28
|
+
if (!encryptedParams)
|
|
29
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
30
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
31
|
+
method: "GET",
|
|
32
|
+
});
|
|
33
|
+
return utils.resolve(response);
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
exports.updateLangFactory = updateLangFactory;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateProductCatalogFactory = utils.apiFactory()((api, _, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.catalog[0]}/api/prodcatalog/product/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Update product catalog?
|
|
10
|
+
*
|
|
11
|
+
* @param payload payload
|
|
12
|
+
*
|
|
13
|
+
* @note this API is used for zBusiness - Maximum 5 media files are supported
|
|
14
|
+
* @throws ZaloApiError
|
|
15
|
+
*/
|
|
16
|
+
return async function updateProductCatalog(payload) {
|
|
17
|
+
const productPhoto = payload.product_photos || [];
|
|
18
|
+
if (payload.files && payload.files.length == 0) {
|
|
19
|
+
if (payload.files.length > 5) {
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Maximum 5 media files are allowed");
|
|
21
|
+
}
|
|
22
|
+
for (const mediaFile of payload.files) {
|
|
23
|
+
const uploadMedia = await api.uploadProductPhoto({
|
|
24
|
+
file: mediaFile,
|
|
25
|
+
});
|
|
26
|
+
const url = uploadMedia.normalUrl || uploadMedia.hdUrl;
|
|
27
|
+
productPhoto.push(url);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (productPhoto.length > 5) {
|
|
31
|
+
throw new ZaloApiError.ZaloApiError("Maximum 5 media files are allowed");
|
|
32
|
+
}
|
|
33
|
+
const params = {
|
|
34
|
+
product_id: payload.productId,
|
|
35
|
+
product_name: payload.productName,
|
|
36
|
+
price: payload.price,
|
|
37
|
+
description: payload.description,
|
|
38
|
+
product_photos: productPhoto,
|
|
39
|
+
catalog_id: payload.catalogId,
|
|
40
|
+
currency_unit: "₫",
|
|
41
|
+
create_time: payload.createTime,
|
|
42
|
+
};
|
|
43
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
44
|
+
if (!encryptedParams)
|
|
45
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
46
|
+
const response = await utils.request(serviceURL, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: new URLSearchParams({
|
|
49
|
+
params: encryptedParams,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
return utils.resolve(response);
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
exports.updateProductCatalogFactory = updateProductCatalogFactory;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateProfileFactory = utils.apiFactory()((api, ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.profile[0]}/api/social/profile/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Change account setting information
|
|
10
|
+
*
|
|
11
|
+
* @param payload payload
|
|
12
|
+
* @param isBusiness add info for business
|
|
13
|
+
*
|
|
14
|
+
* @throws ZaloApiError
|
|
15
|
+
*/
|
|
16
|
+
return async function updateProfile(payload, isBusiness = false) {
|
|
17
|
+
const zBusiness = {
|
|
18
|
+
desc: payload.description,
|
|
19
|
+
cate: payload.cate,
|
|
20
|
+
addr: payload.address,
|
|
21
|
+
website: payload.website,
|
|
22
|
+
email: payload.email,
|
|
23
|
+
};
|
|
24
|
+
const infoBusiness = isBusiness ? JSON.stringify(zBusiness) : JSON.stringify({});
|
|
25
|
+
const params = {
|
|
26
|
+
profile: JSON.stringify({
|
|
27
|
+
name: payload.name,
|
|
28
|
+
dob: payload.dob,
|
|
29
|
+
gender: payload.gender,
|
|
30
|
+
}),
|
|
31
|
+
biz: infoBusiness,
|
|
32
|
+
language: ctx.language,
|
|
33
|
+
};
|
|
34
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
35
|
+
if (!encryptedParams)
|
|
36
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
37
|
+
const response = await utils.request(serviceURL, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: new URLSearchParams({
|
|
40
|
+
params: encryptedParams,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
return utils.resolve(response);
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
exports.updateProfileFactory = updateProfileFactory;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateQuickMessageFactory = utils.apiFactory()((api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`${api.zpwServiceMap.quick_message[0]}/api/quickmessage/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Update quick message
|
|
10
|
+
*
|
|
11
|
+
* @param updatePayload - The payload containing data to update the quick message
|
|
12
|
+
* @param itemId - The id of the quick message to update
|
|
13
|
+
*
|
|
14
|
+
* @note Zalo might throw an error with code 212 if the itemId does not exist.
|
|
15
|
+
*
|
|
16
|
+
* @throws ZaloApiError
|
|
17
|
+
*/
|
|
18
|
+
return async function updateQuickMessage(updatePayload, itemId) {
|
|
19
|
+
const isType = !updatePayload.media ? 0 : 1;
|
|
20
|
+
const params = {
|
|
21
|
+
itemId: itemId,
|
|
22
|
+
keyword: updatePayload.keyword,
|
|
23
|
+
message: {
|
|
24
|
+
title: updatePayload.title,
|
|
25
|
+
params: "",
|
|
26
|
+
},
|
|
27
|
+
type: isType,
|
|
28
|
+
};
|
|
29
|
+
if (isType === 1) {
|
|
30
|
+
if (!updatePayload.media)
|
|
31
|
+
throw new ZaloApiError.ZaloApiError("Media is required");
|
|
32
|
+
const uploadMedia = await api.uploadProductPhoto({
|
|
33
|
+
file: updatePayload.media,
|
|
34
|
+
});
|
|
35
|
+
const photoId = uploadMedia.photoId;
|
|
36
|
+
const thumbUrl = uploadMedia.thumbUrl;
|
|
37
|
+
const normalUrl = uploadMedia.normalUrl;
|
|
38
|
+
const hdUrl = uploadMedia.hdUrl;
|
|
39
|
+
params.media = {
|
|
40
|
+
items: [
|
|
41
|
+
{
|
|
42
|
+
type: 0,
|
|
43
|
+
photoId: photoId,
|
|
44
|
+
title: "",
|
|
45
|
+
width: "",
|
|
46
|
+
height: "",
|
|
47
|
+
previewThumb: thumbUrl,
|
|
48
|
+
rawUrl: normalUrl || hdUrl,
|
|
49
|
+
thumbUrl: thumbUrl,
|
|
50
|
+
normalUrl: normalUrl || hdUrl,
|
|
51
|
+
hdUrl: hdUrl || normalUrl,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
57
|
+
if (!encryptedParams)
|
|
58
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
59
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
60
|
+
method: "GET",
|
|
61
|
+
});
|
|
62
|
+
return utils.resolve(response);
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
exports.updateQuickMessageFactory = updateQuickMessageFactory;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
4
|
+
var utils = require('../utils.cjs');
|
|
5
|
+
|
|
6
|
+
const updateSettingsFactory = utils.apiFactory()((_api, _ctx, utils) => {
|
|
7
|
+
const serviceURL = utils.makeURL(`https://wpa.chat.zalo.me/api/setting/update`);
|
|
8
|
+
/**
|
|
9
|
+
* Set account settings - implement managing various account settings
|
|
10
|
+
*
|
|
11
|
+
* @param type The type of setting to update
|
|
12
|
+
* @param status
|
|
13
|
+
*
|
|
14
|
+
* @throws ZaloApiError
|
|
15
|
+
*/
|
|
16
|
+
return async function updateSettings(type, status) {
|
|
17
|
+
const params = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (type === "view_birthday" && { view_birthday: status })), (type === "online_status" && { show_online_status: status })), (type === "seen_status" && { display_seen_status: status })), (type === "receive_message" && { receive_message: status })), (type === "accept_call" && { accept_stranger_call: status })), (type === "phone_search" && { add_friend_via_phone: status })), (type === "find_me_via_qr" && { add_friend_via_qr: status })), (type === "common_group" && { add_friend_via_group: status })), (type === "find_me_via_contact" && { add_friend_via_contact: status })), (type === "recommend_friend" && { display_on_recommend_friend: status })), (type === "archive_chat" && { archivedChatStatus: status })), (type === "quick_msg" && { quickMessageStatus: status }));
|
|
18
|
+
const encryptedParams = utils.encodeAES(JSON.stringify(params));
|
|
19
|
+
if (!encryptedParams)
|
|
20
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
21
|
+
const response = await utils.request(utils.makeURL(serviceURL, { params: encryptedParams }), {
|
|
22
|
+
method: "GET",
|
|
23
|
+
});
|
|
24
|
+
return utils.resolve(response);
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
exports.updateSettingsFactory = updateSettingsFactory;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var FormData = require('form-data');
|
|
4
|
+
var fs = require('node:fs');
|
|
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 urlType = {
|
|
15
|
+
image: "photo_original/upload",
|
|
16
|
+
video: "asyncfile/upload",
|
|
17
|
+
others: "asyncfile/upload",
|
|
18
|
+
};
|
|
19
|
+
const uploadAttachmentFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
20
|
+
const serviceURL = `${api.zpwServiceMap.file[0]}/api`;
|
|
21
|
+
const { sharefile } = ctx.settings.features;
|
|
22
|
+
function isExceedMaxFile(totalFile) {
|
|
23
|
+
return totalFile > sharefile.max_file;
|
|
24
|
+
}
|
|
25
|
+
function isExceedMaxFileSize(fileSize) {
|
|
26
|
+
return fileSize > sharefile.max_size_share_file_v3 * 1024 * 1024;
|
|
27
|
+
}
|
|
28
|
+
function isExtensionValid(ext) {
|
|
29
|
+
return sharefile.restricted_ext_file.indexOf(ext) == -1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Upload an attachment to a thread
|
|
33
|
+
*
|
|
34
|
+
* @param sources path to files or attachment sources
|
|
35
|
+
* @param threadId Group or User ID
|
|
36
|
+
* @param type Message type (User or Group)
|
|
37
|
+
*
|
|
38
|
+
* @throws ZaloApiError
|
|
39
|
+
*/
|
|
40
|
+
return async function uploadAttachment(sources, threadId, type = Enum.ThreadType.User) {
|
|
41
|
+
if (!sources)
|
|
42
|
+
throw new ZaloApiError.ZaloApiError("Missing sources");
|
|
43
|
+
if (!Array.isArray(sources))
|
|
44
|
+
sources = [sources];
|
|
45
|
+
if (sources.length == 0)
|
|
46
|
+
throw new ZaloApiError.ZaloApiError("Missing sources");
|
|
47
|
+
if (isExceedMaxFile(sources.length))
|
|
48
|
+
throw new ZaloApiError.ZaloApiError("Exceed maximum file of " + sharefile.max_file);
|
|
49
|
+
if (!threadId)
|
|
50
|
+
throw new ZaloApiError.ZaloApiError("Missing threadId");
|
|
51
|
+
sources = await Promise.all(sources.map(async (s) => {
|
|
52
|
+
if (typeof s === "string" && /^https?:\/\//i.test(s)) {
|
|
53
|
+
const downloaded = await utils.downloadAttachmentFromUrl(s);
|
|
54
|
+
if (!downloaded)
|
|
55
|
+
throw new ZaloApiError.ZaloApiError(`Failed to download attachment from URL: ${s}`);
|
|
56
|
+
return downloaded;
|
|
57
|
+
}
|
|
58
|
+
return s;
|
|
59
|
+
}));
|
|
60
|
+
const chunkSize = ctx.settings.features.sharefile.chunk_size_file;
|
|
61
|
+
const isGroupMessage = type == Enum.ThreadType.Group;
|
|
62
|
+
const attachmentsData = [];
|
|
63
|
+
const url = `${serviceURL}/${isGroupMessage ? "group" : "message"}/`;
|
|
64
|
+
const typeParam = isGroupMessage ? "11" : "2";
|
|
65
|
+
let clientId = Date.now();
|
|
66
|
+
for (const source of sources) {
|
|
67
|
+
const isFilePath = typeof source == "string";
|
|
68
|
+
const isBuffer = typeof source == "object" && source.data instanceof Buffer;
|
|
69
|
+
if (!isFilePath && !isBuffer)
|
|
70
|
+
throw new ZaloApiError.ZaloApiError("Invalid source type");
|
|
71
|
+
if (!isFilePath && !source.filename)
|
|
72
|
+
throw new ZaloApiError.ZaloApiError("Missing filename");
|
|
73
|
+
if (isFilePath && !fs.existsSync(source))
|
|
74
|
+
throw new ZaloApiError.ZaloApiError("File not found");
|
|
75
|
+
const extFile = utils.getFileExtension(isFilePath ? source : source.filename).toLowerCase();
|
|
76
|
+
const fileName = isFilePath ? utils.getFileName(source) : source.filename;
|
|
77
|
+
if (isExtensionValid(extFile) == false)
|
|
78
|
+
throw new ZaloApiError.ZaloApiError(`File extension "${extFile}" is not allowed`);
|
|
79
|
+
const data = {
|
|
80
|
+
filePath: isFilePath ? source : source.filename,
|
|
81
|
+
chunkContent: [],
|
|
82
|
+
params: {},
|
|
83
|
+
source,
|
|
84
|
+
};
|
|
85
|
+
if (isGroupMessage)
|
|
86
|
+
data.params.grid = threadId;
|
|
87
|
+
else
|
|
88
|
+
data.params.toid = threadId;
|
|
89
|
+
switch (extFile) {
|
|
90
|
+
case "jpg":
|
|
91
|
+
case "jpeg":
|
|
92
|
+
case "png":
|
|
93
|
+
case "webp": {
|
|
94
|
+
const imageData = isFilePath ? await utils.getImageMetaData(source) : Object.assign(Object.assign({}, source.metadata), { fileName });
|
|
95
|
+
if (isExceedMaxFileSize(imageData.totalSize))
|
|
96
|
+
throw new ZaloApiError.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
97
|
+
data.fileData = imageData;
|
|
98
|
+
data.fileType = "image";
|
|
99
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
100
|
+
data.params.fileName = fileName;
|
|
101
|
+
data.params.clientId = clientId++;
|
|
102
|
+
data.params.totalSize = imageData.totalSize;
|
|
103
|
+
data.params.imei = ctx.imei;
|
|
104
|
+
data.params.isE2EE = 0;
|
|
105
|
+
data.params.jxl = 0;
|
|
106
|
+
data.params.chunkId = 1;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case "mp4": {
|
|
110
|
+
const videoSize = isFilePath ? await utils.getFileSize(source) : source.metadata.totalSize;
|
|
111
|
+
if (isExceedMaxFileSize(videoSize))
|
|
112
|
+
throw new ZaloApiError.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
113
|
+
data.fileType = "video";
|
|
114
|
+
data.fileData = {
|
|
115
|
+
fileName,
|
|
116
|
+
totalSize: videoSize,
|
|
117
|
+
};
|
|
118
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
119
|
+
data.params.fileName = fileName;
|
|
120
|
+
data.params.clientId = clientId++;
|
|
121
|
+
data.params.totalSize = videoSize;
|
|
122
|
+
data.params.imei = ctx.imei;
|
|
123
|
+
data.params.isE2EE = 0;
|
|
124
|
+
data.params.jxl = 0;
|
|
125
|
+
data.params.chunkId = 1;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
default: {
|
|
129
|
+
const fileSize = isFilePath ? await utils.getFileSize(source) : source.metadata.totalSize;
|
|
130
|
+
if (isExceedMaxFileSize(fileSize))
|
|
131
|
+
throw new ZaloApiError.ZaloApiError(`File ${fileName} size exceed maximum size of ${sharefile.max_size_share_file_v3}MB`);
|
|
132
|
+
data.fileType = "others";
|
|
133
|
+
data.fileData = {
|
|
134
|
+
fileName,
|
|
135
|
+
totalSize: fileSize,
|
|
136
|
+
};
|
|
137
|
+
data.params.totalChunk = Math.ceil(data.fileData.totalSize / chunkSize);
|
|
138
|
+
data.params.fileName = fileName;
|
|
139
|
+
data.params.clientId = clientId++;
|
|
140
|
+
data.params.totalSize = fileSize;
|
|
141
|
+
data.params.imei = ctx.imei;
|
|
142
|
+
data.params.isE2EE = 0;
|
|
143
|
+
data.params.jxl = 0;
|
|
144
|
+
data.params.chunkId = 1;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const fileBuffer = isFilePath ? await fs.promises.readFile(source) : source.data;
|
|
149
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
150
|
+
const formData = new FormData();
|
|
151
|
+
const slicedBuffer = fileBuffer.subarray(i * chunkSize, (i + 1) * chunkSize);
|
|
152
|
+
formData.append("chunkContent", slicedBuffer, {
|
|
153
|
+
filename: fileName,
|
|
154
|
+
contentType: "application/octet-stream",
|
|
155
|
+
});
|
|
156
|
+
data.chunkContent[i] = formData;
|
|
157
|
+
}
|
|
158
|
+
attachmentsData.push(data);
|
|
159
|
+
}
|
|
160
|
+
const requests = [], results = [];
|
|
161
|
+
for (const data of attachmentsData) {
|
|
162
|
+
for (let i = 0; i < data.params.totalChunk; i++) {
|
|
163
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(data.params));
|
|
164
|
+
if (!encryptedParams)
|
|
165
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt message");
|
|
166
|
+
requests.push(utils$1
|
|
167
|
+
.request(utils$1.makeURL(url + urlType[data.fileType], { type: typeParam, params: encryptedParams }), {
|
|
168
|
+
method: "POST",
|
|
169
|
+
headers: data.chunkContent[i].getHeaders(),
|
|
170
|
+
body: data.chunkContent[i].getBuffer(),
|
|
171
|
+
})
|
|
172
|
+
.then(async (response) => {
|
|
173
|
+
/**
|
|
174
|
+
* @TODO: better type rather than any
|
|
175
|
+
*/
|
|
176
|
+
const resData = await utils.resolveResponse(ctx, response);
|
|
177
|
+
if (resData && resData.fileId != "-1" && resData.photoId != "-1")
|
|
178
|
+
await new Promise((resolve) => {
|
|
179
|
+
if (data.fileType == "video" || data.fileType == "others") {
|
|
180
|
+
const uploadCallback = async (wsData) => {
|
|
181
|
+
const result = Object.assign(Object.assign(Object.assign({ fileType: data.fileType }, resData), wsData), { totalSize: data.fileData.totalSize, fileName: data.fileData.fileName, checksum: (await utils.getMd5LargeFileObject(data.source, data.fileData.totalSize)).data });
|
|
182
|
+
results.push(result);
|
|
183
|
+
resolve();
|
|
184
|
+
};
|
|
185
|
+
ctx.uploadCallbacks.set(resData.fileId.toString(), uploadCallback);
|
|
186
|
+
}
|
|
187
|
+
if (data.fileType == "image") {
|
|
188
|
+
const result = {
|
|
189
|
+
fileType: "image",
|
|
190
|
+
width: data.fileData.width,
|
|
191
|
+
height: data.fileData.height,
|
|
192
|
+
totalSize: data.fileData.totalSize,
|
|
193
|
+
hdSize: data.fileData.totalSize,
|
|
194
|
+
finished: resData.finished,
|
|
195
|
+
normalUrl: resData.normalUrl,
|
|
196
|
+
hdUrl: resData.hdUrl,
|
|
197
|
+
thumbUrl: resData.thumbUrl,
|
|
198
|
+
chunkId: resData.chunkId,
|
|
199
|
+
photoId: resData.photoId,
|
|
200
|
+
clientFileId: resData.clientFileId,
|
|
201
|
+
};
|
|
202
|
+
results.push(result);
|
|
203
|
+
resolve();
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}));
|
|
207
|
+
data.params.chunkId++;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
await Promise.all(requests);
|
|
211
|
+
return results;
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
exports.uploadAttachmentFactory = uploadAttachmentFactory;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('node:fs');
|
|
4
|
+
var FormData = require('form-data');
|
|
5
|
+
var ZaloApiError = require('../Errors/ZaloApiError.cjs');
|
|
6
|
+
var utils = require('../utils.cjs');
|
|
7
|
+
|
|
8
|
+
const uploadProductPhotoFactory = utils.apiFactory()((api, ctx, utils$1) => {
|
|
9
|
+
const serviceURL = utils$1.makeURL(`${api.zpwServiceMap.file[0]}/api/product/upload/photo`);
|
|
10
|
+
/**
|
|
11
|
+
* Upload product photo for api quick message, product catalog or custom local storage
|
|
12
|
+
*
|
|
13
|
+
* @param payload file path or attachment source
|
|
14
|
+
*
|
|
15
|
+
* @throws ZaloApiError
|
|
16
|
+
*/
|
|
17
|
+
return async function uploadProductPhoto(payload) {
|
|
18
|
+
const isSourceFilePath = typeof payload.file == "string";
|
|
19
|
+
const fileMetaData = isSourceFilePath
|
|
20
|
+
? await utils.getImageMetaData(payload.file)
|
|
21
|
+
: payload.file.metadata;
|
|
22
|
+
const fileSize = fileMetaData.totalSize || 0;
|
|
23
|
+
const fileBuffer = isSourceFilePath
|
|
24
|
+
? await fs.promises.readFile(payload.file)
|
|
25
|
+
: payload.file.data;
|
|
26
|
+
const formData = new FormData();
|
|
27
|
+
formData.append("chunkContent", fileBuffer, {
|
|
28
|
+
filename: "undefined",
|
|
29
|
+
contentType: "application/octet-stream",
|
|
30
|
+
});
|
|
31
|
+
const params = {
|
|
32
|
+
totalChunk: 1,
|
|
33
|
+
fileName: `Base64_Img_Picker_${Date.now()}.jpg`,
|
|
34
|
+
clientId: Date.now(),
|
|
35
|
+
totalSize: fileSize,
|
|
36
|
+
imei: ctx.imei,
|
|
37
|
+
chunkId: 1,
|
|
38
|
+
toid: ctx.loginInfo.send2me_id,
|
|
39
|
+
featureId: 1,
|
|
40
|
+
};
|
|
41
|
+
const encryptedParams = utils$1.encodeAES(JSON.stringify(params));
|
|
42
|
+
if (!encryptedParams)
|
|
43
|
+
throw new ZaloApiError.ZaloApiError("Failed to encrypt params");
|
|
44
|
+
const response = await utils$1.request(utils$1.makeURL(serviceURL, {
|
|
45
|
+
params: encryptedParams,
|
|
46
|
+
}), {
|
|
47
|
+
method: "POST",
|
|
48
|
+
headers: formData.getHeaders(),
|
|
49
|
+
body: formData.getBuffer(),
|
|
50
|
+
});
|
|
51
|
+
return utils$1.resolve(response);
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
exports.uploadProductPhotoFactory = uploadProductPhotoFactory;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _5_MINUTES = 5 * 60 * 1000;
|
|
4
|
+
class CallbacksMap extends Map {
|
|
5
|
+
/**
|
|
6
|
+
* @param ttl Time to live in milliseconds. Default is 5 minutes.
|
|
7
|
+
*/
|
|
8
|
+
set(key, value, ttl = _5_MINUTES) {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
this.delete(key);
|
|
11
|
+
}, ttl);
|
|
12
|
+
return super.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const createContext = (apiType = 30, apiVersion = 665) => ({
|
|
16
|
+
API_TYPE: apiType,
|
|
17
|
+
API_VERSION: apiVersion,
|
|
18
|
+
uploadCallbacks: new CallbacksMap(),
|
|
19
|
+
options: {
|
|
20
|
+
selfListen: false,
|
|
21
|
+
checkUpdate: true,
|
|
22
|
+
logging: true,
|
|
23
|
+
polyfill: global.fetch,
|
|
24
|
+
},
|
|
25
|
+
secretKey: null,
|
|
26
|
+
});
|
|
27
|
+
function isContextSession(ctx) {
|
|
28
|
+
return !!ctx.secretKey;
|
|
29
|
+
}
|
|
30
|
+
const MAX_MESSAGES_PER_SEND = 50;
|
|
31
|
+
|
|
32
|
+
exports.MAX_MESSAGES_PER_SEND = MAX_MESSAGES_PER_SEND;
|
|
33
|
+
exports.createContext = createContext;
|
|
34
|
+
exports.isContextSession = isContextSession;
|