lordceaser-baileys 3.4.0 → 3.4.2
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/LICENSE +22 -0
- package/README.md +201 -0
- package/WAProto/_orig.js +92429 -277359
- package/WAProto/index.d.ts +11659 -95047
- package/WAProto/index.js +5 -2
- package/banner.png +0 -0
- package/index.js +11 -6
- package/lib/Defaults/index.d.ts +118 -48
- package/lib/Defaults/index.d.ts.map +1 -1
- package/lib/Defaults/index.js +29 -6
- package/lib/Defaults/index.js.map +1 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +8 -8
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -1
- package/lib/Signal/Group/ciphertext-message.js.map +1 -1
- package/lib/Signal/Group/group-session-builder.d.ts +6 -13
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -1
- package/lib/Signal/Group/group-session-builder.js.map +1 -1
- package/lib/Signal/Group/group_cipher.d.ts +9 -15
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -1
- package/lib/Signal/Group/group_cipher.js.map +1 -1
- package/lib/Signal/Group/index.d.ts +11 -11
- package/lib/Signal/Group/index.d.ts.map +1 -1
- package/lib/Signal/Group/index.js.map +1 -1
- package/lib/Signal/Group/keyhelper.d.ts +6 -10
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -1
- package/lib/Signal/Group/keyhelper.js.map +1 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +10 -10
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-chain-key.js.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +14 -14
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-message.d.ts +16 -16
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-message.js.map +1 -1
- package/lib/Signal/Group/sender-key-name.d.ts +7 -13
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-name.js.map +1 -1
- package/lib/Signal/Group/sender-key-record.d.ts +10 -28
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-record.js.map +1 -1
- package/lib/Signal/Group/sender-key-state.d.ts +14 -36
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -1
- package/lib/Signal/Group/sender-key-state.js.map +1 -1
- package/lib/Signal/Group/sender-message-key.d.ts +10 -10
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -1
- package/lib/Signal/Group/sender-message-key.js.map +1 -1
- package/lib/Signal/libsignal.d.ts +54 -4
- package/lib/Signal/libsignal.d.ts.map +1 -1
- package/lib/Signal/libsignal.js.map +1 -1
- package/lib/Signal/lid-mapping.d.ts +15 -17
- package/lib/Signal/lid-mapping.d.ts.map +1 -1
- package/lib/Signal/lid-mapping.js.map +1 -1
- package/lib/Socket/Client/index.d.ts +2 -2
- package/lib/Socket/Client/index.d.ts.map +1 -1
- package/lib/Socket/Client/index.js +1 -0
- package/lib/Socket/Client/index.js.map +1 -1
- package/lib/Socket/Client/types.d.ts +4 -14
- package/lib/Socket/Client/types.d.ts.map +1 -1
- package/lib/Socket/Client/types.js +2 -1
- package/lib/Socket/Client/types.js.map +1 -1
- package/lib/Socket/Client/websocket.d.ts +5 -5
- package/lib/Socket/Client/websocket.d.ts.map +1 -1
- package/lib/Socket/Client/websocket.js +2 -1
- package/lib/Socket/Client/websocket.js.map +1 -1
- package/lib/Socket/business.d.ts +353 -175
- package/lib/Socket/business.d.ts.map +1 -1
- package/lib/Socket/business.js +43 -70
- package/lib/Socket/business.js.map +1 -1
- package/lib/Socket/chats.d.ts +112 -93
- package/lib/Socket/chats.d.ts.map +1 -1
- package/lib/Socket/chats.js +20 -709
- package/lib/Socket/chats.js.map +1 -1
- package/lib/Socket/communities.d.ts +499 -210
- package/lib/Socket/communities.d.ts.map +1 -1
- package/lib/Socket/communities.js +1 -0
- package/lib/Socket/communities.js.map +1 -1
- package/lib/Socket/groups.d.ts +245 -120
- package/lib/Socket/groups.d.ts.map +1 -1
- package/lib/Socket/groups.js +5 -206
- package/lib/Socket/groups.js.map +1 -1
- package/lib/Socket/index.d.ts +478 -208
- package/lib/Socket/index.d.ts.map +1 -1
- package/lib/Socket/index.js +3 -28
- package/lib/Socket/index.js.map +1 -1
- package/lib/Socket/messages-recv.d.ts +295 -164
- package/lib/Socket/messages-recv.d.ts.map +1 -1
- package/lib/Socket/messages-recv.js +9 -381
- package/lib/Socket/messages-recv.js.map +1 -1
- package/lib/Socket/messages-send.d.ts +290 -159
- package/lib/Socket/messages-send.d.ts.map +1 -1
- package/lib/Socket/messages-send.js +154 -1963
- package/lib/Socket/messages-send.js.map +1 -1
- package/lib/Socket/mex.d.ts +1 -2
- package/lib/Socket/mex.d.ts.map +1 -1
- package/lib/Socket/mex.js +2 -1
- package/lib/Socket/mex.js.map +1 -1
- package/lib/Socket/newsletter.d.ts +251 -138
- package/lib/Socket/newsletter.d.ts.map +1 -1
- package/lib/Socket/newsletter.js +9 -43
- package/lib/Socket/newsletter.js.map +1 -1
- package/lib/Socket/socket.d.ts +44 -42
- package/lib/Socket/socket.d.ts.map +1 -1
- package/lib/Socket/socket.js +17 -64
- package/lib/Socket/socket.js.map +1 -1
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.d.ts.map +1 -0
- package/lib/Store/index.js +4 -0
- package/lib/Store/index.js.map +1 -0
- package/lib/Store/make-in-memory-store.d.ts +63 -0
- package/lib/Store/make-in-memory-store.d.ts.map +1 -0
- package/lib/Store/make-in-memory-store.js +421 -0
- package/lib/Store/make-in-memory-store.js.map +1 -0
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/make-ordered-dictionary.d.ts.map +1 -0
- package/lib/Store/make-ordered-dictionary.js +79 -0
- package/lib/Store/make-ordered-dictionary.js.map +1 -0
- package/lib/Store/object-repository.d.ts +11 -0
- package/lib/Store/object-repository.d.ts.map +1 -0
- package/lib/Store/object-repository.js +24 -0
- package/lib/Store/object-repository.js.map +1 -0
- package/lib/Types/Auth.d.ts +0 -115
- package/lib/Types/Auth.d.ts.map +1 -1
- package/lib/Types/Auth.js.map +1 -1
- package/lib/Types/Bussines.d.ts +1 -24
- package/lib/Types/Bussines.d.ts.map +1 -1
- package/lib/Types/Bussines.js.map +1 -1
- package/lib/Types/Call.d.ts +1 -14
- package/lib/Types/Call.d.ts.map +1 -1
- package/lib/Types/Call.js.map +1 -1
- package/lib/Types/Chat.d.ts +1 -123
- package/lib/Types/Chat.d.ts.map +1 -1
- package/lib/Types/Chat.js.map +1 -1
- package/lib/Types/Contact.d.ts +1 -25
- package/lib/Types/Contact.d.ts.map +1 -1
- package/lib/Types/Contact.js.map +1 -1
- package/lib/Types/Events.d.ts +1 -255
- package/lib/Types/Events.d.ts.map +1 -1
- package/lib/Types/Events.js.map +1 -1
- package/lib/Types/GroupMetadata.d.ts +1 -70
- package/lib/Types/GroupMetadata.d.ts.map +1 -1
- package/lib/Types/GroupMetadata.js.map +1 -1
- package/lib/Types/Label.d.ts +1 -45
- package/lib/Types/Label.d.ts.map +1 -1
- package/lib/Types/Label.js.map +1 -1
- package/lib/Types/LabelAssociation.d.ts +1 -28
- package/lib/Types/LabelAssociation.d.ts.map +1 -1
- package/lib/Types/LabelAssociation.js.map +1 -1
- package/lib/Types/Message.d.ts +10 -318
- package/lib/Types/Message.d.ts.map +1 -1
- package/lib/Types/Message.js +7 -0
- package/lib/Types/Message.js.map +1 -1
- package/lib/Types/Mex.d.ts +2 -140
- package/lib/Types/Mex.d.ts.map +1 -1
- package/lib/Types/Mex.js +2 -0
- package/lib/Types/Mex.js.map +1 -1
- package/lib/Types/Product.d.ts +1 -78
- package/lib/Types/Product.d.ts.map +1 -1
- package/lib/Types/Product.js.map +1 -1
- package/lib/Types/RichType.d.ts +3 -0
- package/lib/Types/RichType.d.ts.map +1 -0
- package/lib/Types/RichType.js +23 -0
- package/lib/Types/RichType.js.map +1 -0
- package/lib/Types/Signal.d.ts +0 -85
- package/lib/Types/Signal.d.ts.map +1 -1
- package/lib/Types/Signal.js.map +1 -1
- package/lib/Types/Socket.d.ts +1 -135
- package/lib/Types/Socket.d.ts.map +1 -1
- package/lib/Types/Socket.js +0 -1
- package/lib/Types/Socket.js.map +1 -1
- package/lib/Types/State.d.ts +5 -96
- package/lib/Types/State.d.ts.map +1 -1
- package/lib/Types/State.js.map +1 -1
- package/lib/Types/USync.d.ts +1 -25
- package/lib/Types/USync.d.ts.map +1 -1
- package/lib/Types/USync.js.map +1 -1
- package/lib/Types/index.d.ts +13 -65
- package/lib/Types/index.d.ts.map +1 -1
- package/lib/Types/index.js.map +1 -1
- package/lib/Utils/auth-utils.d.ts +51 -17
- package/lib/Utils/auth-utils.d.ts.map +1 -1
- package/lib/Utils/auth-utils.js +5 -1
- package/lib/Utils/auth-utils.js.map +1 -1
- package/lib/Utils/browser-utils.d.ts +9 -3
- package/lib/Utils/browser-utils.d.ts.map +1 -1
- package/lib/Utils/browser-utils.js.map +1 -1
- package/lib/Utils/business.d.ts +46 -19
- package/lib/Utils/business.d.ts.map +1 -1
- package/lib/Utils/business.js.map +1 -1
- package/lib/Utils/chat-utils.d.ts +398 -89
- package/lib/Utils/chat-utils.d.ts.map +1 -1
- package/lib/Utils/chat-utils.js.map +1 -1
- package/lib/Utils/companion-reg-client-utils.d.ts +4 -16
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -1
- package/lib/Utils/companion-reg-client-utils.js +7 -2
- package/lib/Utils/companion-reg-client-utils.js.map +1 -1
- package/lib/Utils/crypto.d.ts +29 -26
- package/lib/Utils/crypto.d.ts.map +1 -1
- package/lib/Utils/crypto.js +2 -0
- package/lib/Utils/crypto.js.map +1 -1
- package/lib/Utils/decode-wa-message.d.ts +76 -58
- package/lib/Utils/decode-wa-message.d.ts.map +1 -1
- package/lib/Utils/decode-wa-message.js.map +1 -1
- package/lib/Utils/event-buffer.d.ts +9 -32
- package/lib/Utils/event-buffer.d.ts.map +1 -1
- package/lib/Utils/event-buffer.js.map +1 -1
- package/lib/Utils/generics.d.ts +45 -73
- package/lib/Utils/generics.d.ts.map +1 -1
- package/lib/Utils/generics.js +17 -15
- package/lib/Utils/generics.js.map +1 -1
- package/lib/Utils/history.d.ts +73 -21
- package/lib/Utils/history.d.ts.map +1 -1
- package/lib/Utils/history.js.map +1 -1
- package/lib/Utils/identity-change-handler.d.ts +9 -39
- package/lib/Utils/identity-change-handler.d.ts.map +1 -1
- package/lib/Utils/identity-change-handler.js.map +1 -1
- package/lib/Utils/index.d.ts +24 -21
- package/lib/Utils/index.d.ts.map +1 -1
- package/lib/Utils/index.js +3 -0
- package/lib/Utils/index.js.map +1 -1
- package/lib/Utils/link-preview.d.ts +8 -16
- package/lib/Utils/link-preview.d.ts.map +1 -1
- package/lib/Utils/link-preview.js.map +1 -1
- package/lib/Utils/logger.d.ts +1 -10
- package/lib/Utils/logger.d.ts.map +1 -1
- package/lib/Utils/logger.js.map +1 -1
- package/lib/Utils/lt-hash.d.ts +1 -2
- package/lib/Utils/lt-hash.d.ts.map +1 -1
- package/lib/Utils/lt-hash.js.map +1 -1
- package/lib/Utils/make-mutex.d.ts +4 -6
- package/lib/Utils/make-mutex.d.ts.map +1 -1
- package/lib/Utils/make-mutex.js.map +1 -1
- package/lib/Utils/message-retry-manager.d.ts +36 -71
- package/lib/Utils/message-retry-manager.d.ts.map +1 -1
- package/lib/Utils/message-retry-manager.js +1 -1
- package/lib/Utils/message-retry-manager.js.map +1 -1
- package/lib/Utils/messages-media.d.ts +121 -117
- package/lib/Utils/messages-media.d.ts.map +1 -1
- package/lib/Utils/messages-media.js +87 -32
- package/lib/Utils/messages-media.js.map +1 -1
- package/lib/Utils/messages.d.ts +33 -78
- package/lib/Utils/messages.d.ts.map +1 -1
- package/lib/Utils/messages.js +1010 -63
- package/lib/Utils/messages.js.map +1 -1
- package/lib/Utils/noise-handler.d.ts +18 -17
- package/lib/Utils/noise-handler.d.ts.map +1 -1
- package/lib/Utils/noise-handler.js.map +1 -1
- package/lib/Utils/offline-node-processor.d.ts +2 -9
- package/lib/Utils/offline-node-processor.d.ts.map +1 -1
- package/lib/Utils/offline-node-processor.js.map +1 -1
- package/lib/Utils/pre-key-manager.d.ts +9 -11
- package/lib/Utils/pre-key-manager.d.ts.map +1 -1
- package/lib/Utils/pre-key-manager.js.map +1 -1
- package/lib/Utils/process-message.d.ts +70 -46
- package/lib/Utils/process-message.d.ts.map +1 -1
- package/lib/Utils/process-message.js +119 -0
- package/lib/Utils/process-message.js.map +1 -1
- package/lib/Utils/reporting-utils.d.ts +12 -10
- package/lib/Utils/reporting-utils.d.ts.map +1 -1
- package/lib/Utils/reporting-utils.js.map +1 -1
- package/lib/Utils/rich-message-utils.d.ts +49 -0
- package/lib/Utils/rich-message-utils.d.ts.map +1 -0
- package/lib/Utils/rich-message-utils.js +370 -0
- package/lib/Utils/rich-message-utils.js.map +1 -0
- package/lib/Utils/signal.d.ts +71 -35
- package/lib/Utils/signal.d.ts.map +1 -1
- package/lib/Utils/signal.js.map +1 -1
- package/lib/Utils/stanza-ack.d.ts +8 -2
- package/lib/Utils/stanza-ack.d.ts.map +1 -1
- package/lib/Utils/stanza-ack.js.map +1 -1
- package/lib/Utils/sync-action-utils.d.ts +2 -18
- package/lib/Utils/sync-action-utils.d.ts.map +1 -1
- package/lib/Utils/sync-action-utils.js.map +1 -1
- package/lib/Utils/tc-token-utils.d.ts +23 -30
- package/lib/Utils/tc-token-utils.d.ts.map +1 -1
- package/lib/Utils/tc-token-utils.js.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts +9 -11
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -1
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-single-file-auth-state.js.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-sqlite-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.js.map +1 -0
- package/lib/Utils/validate-connection.d.ts +42 -9
- package/lib/Utils/validate-connection.d.ts.map +1 -1
- package/lib/Utils/validate-connection.js.map +1 -1
- package/lib/WABinary/constants.d.ts +60 -26
- package/lib/WABinary/constants.d.ts.map +1 -1
- package/lib/WABinary/constants.js +166 -0
- package/lib/WABinary/constants.js.map +1 -1
- package/lib/WABinary/decode.d.ts +8 -5
- package/lib/WABinary/decode.d.ts.map +1 -1
- package/lib/WABinary/decode.js.map +1 -1
- package/lib/WABinary/encode.d.ts +2 -2
- package/lib/WABinary/encode.d.ts.map +1 -1
- package/lib/WABinary/encode.js.map +1 -1
- package/lib/WABinary/generic-utils.d.ts +75 -13
- package/lib/WABinary/generic-utils.d.ts.map +1 -1
- package/lib/WABinary/generic-utils.js +114 -1
- package/lib/WABinary/generic-utils.js.map +1 -1
- package/lib/WABinary/index.d.ts +5 -5
- package/lib/WABinary/index.d.ts.map +1 -1
- package/lib/WABinary/index.js.map +1 -1
- package/lib/WABinary/jid-utils.d.ts +28 -47
- package/lib/WABinary/jid-utils.d.ts.map +1 -1
- package/lib/WABinary/jid-utils.js +1 -1
- package/lib/WABinary/jid-utils.js.map +1 -1
- package/lib/WABinary/types.d.ts +1 -18
- package/lib/WABinary/types.d.ts.map +1 -1
- package/lib/WABinary/types.js.map +1 -1
- package/lib/WAM/BinaryInfo.d.ts +4 -5
- package/lib/WAM/BinaryInfo.d.ts.map +1 -1
- package/lib/WAM/BinaryInfo.js.map +1 -1
- package/lib/WAM/constants.d.ts +34916 -29
- package/lib/WAM/constants.d.ts.map +1 -1
- package/lib/WAM/constants.js.map +1 -1
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.d.ts.map +1 -1
- package/lib/WAM/encode.js.map +1 -1
- package/lib/WAM/index.d.ts +3 -3
- package/lib/WAM/index.d.ts.map +1 -1
- package/lib/WAM/index.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +34 -7
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -7
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +20 -20
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +7 -7
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +3 -2
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +36 -23
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +12 -7
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +2 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -1
- package/lib/WAUSync/Protocols/index.d.ts +5 -5
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -1
- package/lib/WAUSync/Protocols/index.js +1 -7
- package/lib/WAUSync/Protocols/index.js.map +1 -1
- package/lib/WAUSync/USyncQuery.d.ts +10 -19
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -1
- package/lib/WAUSync/USyncQuery.js +23 -126
- package/lib/WAUSync/USyncQuery.js.map +1 -1
- package/lib/WAUSync/USyncUser.d.ts +15 -15
- package/lib/WAUSync/USyncUser.d.ts.map +1 -1
- package/lib/WAUSync/USyncUser.js +1 -24
- package/lib/WAUSync/USyncUser.js.map +1 -1
- package/lib/WAUSync/index.d.ts +3 -3
- package/lib/WAUSync/index.d.ts.map +1 -1
- package/lib/WAUSync/index.js +2 -1
- package/lib/WAUSync/index.js.map +1 -1
- package/lib/index.d.ts +9 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +11 -3
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/V +0 -1
- package/WAProto/WAProto.proto +0 -8423
- package/WAProto/fix-imports.js +0 -85
- package/lib/Socket/aigroups.js +0 -315
- package/lib/Socket/ban-checker.js +0 -153
- package/lib/Socket/chats.js[old] +0 -1227
- package/lib/Socket/graphql.js +0 -899
- package/lib/Socket/groups.js[old] +0 -347
- package/lib/Socket/interactive-handler.js +0 -600
- package/lib/Socket/interop.js +0 -563
- package/lib/Socket/managed-account.js +0 -208
- package/lib/Socket/package.json +0 -1
- package/lib/Socket/privacy.js +0 -446
- package/lib/Socket/registration.js +0 -428
- package/lib/Socket/username.js +0 -229
- package/lib/Utils/package.json +0 -1
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +0 -96
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +0 -70
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +0 -28
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +0 -25
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +0 -34
- package/lib/package.json +0 -1
package/WAProto/fix-imports.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
-
import { exit } from 'process';
|
|
3
|
-
|
|
4
|
-
const filePath = './index.js'
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
let content = readFileSync(filePath, 'utf8')
|
|
8
|
-
|
|
9
|
-
content = content.replace(/import \* as (\$protobuf) from/g, 'import $1 from')
|
|
10
|
-
content = content.replace(/(['"])protobufjs\/minimal(['"])/g, '$1protobufjs/minimal.js$2')
|
|
11
|
-
|
|
12
|
-
const marker = 'const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});\n\n'
|
|
13
|
-
const longToStringHelper =
|
|
14
|
-
'function longToString(value, unsigned) {\n' +
|
|
15
|
-
'\tif (typeof value === "string") {\n' +
|
|
16
|
-
'\t\treturn value;\n' +
|
|
17
|
-
'\t}\n' +
|
|
18
|
-
'\tif (typeof value === "number") {\n' +
|
|
19
|
-
'\t\treturn String(value);\n' +
|
|
20
|
-
'\t}\n' +
|
|
21
|
-
'\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
|
|
22
|
-
'\t// BigInt.toString() is a native C++ operation, much faster than Long\'s pure JS division loops\n' +
|
|
23
|
-
'\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
|
|
24
|
-
'\t\tconst lo = BigInt(value.low >>> 0);\n' +
|
|
25
|
-
'\t\tconst hi = BigInt(value.high >>> 0);\n' +
|
|
26
|
-
'\t\tconst combined = (hi << 32n) | lo;\n' +
|
|
27
|
-
'\t\tif (!unsigned && value.high < 0) {\n' +
|
|
28
|
-
'\t\t\treturn (combined - (1n << 64n)).toString();\n' +
|
|
29
|
-
'\t\t}\n' +
|
|
30
|
-
'\t\treturn combined.toString();\n' +
|
|
31
|
-
'\t}\n' +
|
|
32
|
-
'\treturn String(value);\n' +
|
|
33
|
-
'}\n\n'
|
|
34
|
-
const longToNumberHelper =
|
|
35
|
-
'function longToNumber(value, unsigned) {\n' +
|
|
36
|
-
'\tif (typeof value === "number") {\n' +
|
|
37
|
-
'\t\treturn value;\n' +
|
|
38
|
-
'\t}\n' +
|
|
39
|
-
'\tif (typeof value === "string") {\n' +
|
|
40
|
-
'\t\treturn Number(value);\n' +
|
|
41
|
-
'\t}\n' +
|
|
42
|
-
'\t// Fast path: convert Long {low, high} directly via native BigInt\n' +
|
|
43
|
-
'\tif (value && typeof value.low === "number" && typeof value.high === "number") {\n' +
|
|
44
|
-
'\t\tconst lo = BigInt(value.low >>> 0);\n' +
|
|
45
|
-
'\t\tconst hi = BigInt(value.high >>> 0);\n' +
|
|
46
|
-
'\t\tconst combined = (hi << 32n) | lo;\n' +
|
|
47
|
-
'\t\tif (!unsigned && value.high < 0) {\n' +
|
|
48
|
-
'\t\t\treturn Number(combined - (1n << 64n));\n' +
|
|
49
|
-
'\t\t}\n' +
|
|
50
|
-
'\t\treturn Number(combined);\n' +
|
|
51
|
-
'\t}\n' +
|
|
52
|
-
'\treturn Number(value);\n' +
|
|
53
|
-
'}\n\n'
|
|
54
|
-
|
|
55
|
-
if (!content.includes('function longToString(')) {
|
|
56
|
-
const markerIndex = content.indexOf(marker)
|
|
57
|
-
if (markerIndex === -1) {
|
|
58
|
-
throw new Error('Unable to inject Long helpers: marker not found in WAProto index output')
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
content = content.replace(marker, `${marker}${longToStringHelper}${longToNumberHelper}`)
|
|
62
|
-
} else {
|
|
63
|
-
const longToStringRegex = /function longToString\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
|
|
64
|
-
const longToNumberRegex = /function longToNumber\(value, unsigned\) {\n[\s\S]*?\n}\n\n/
|
|
65
|
-
|
|
66
|
-
if (!longToStringRegex.test(content) || !longToNumberRegex.test(content)) {
|
|
67
|
-
throw new Error('Unable to update Long helpers: existing definitions not found')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
content = content.replace(longToStringRegex, longToStringHelper)
|
|
71
|
-
content = content.replace(longToNumberRegex, longToNumberHelper)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const longPattern = /([ \t]+d\.(\w+) = )o\.longs === String \? \$util\.Long\.prototype\.toString\.call\(m\.\2\) : o\.longs === Number \? new \$util\.LongBits\(m\.\2\.low >>> 0, m\.\2\.high >>> 0\)\.toNumber\((true)?\) : m\.\2;/g
|
|
75
|
-
content = content.replace(longPattern, (_match, prefix, field, unsignedFlag) => {
|
|
76
|
-
const unsignedArg = unsignedFlag ? ', true' : ''
|
|
77
|
-
return `${prefix}o.longs === String ? longToString(m.${field}${unsignedArg}) : o.longs === Number ? longToNumber(m.${field}${unsignedArg}) : m.${field};`
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
writeFileSync(filePath, content, 'utf8')
|
|
81
|
-
console.log(`✅ Fixed imports in ${filePath}`)
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error(`❌ Error fixing imports: ${error.message}`)
|
|
84
|
-
exit(1)
|
|
85
|
-
}
|
package/lib/Socket/aigroups.js
DELETED
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { WAMessageAddressingMode } from '../Types/index.js';
|
|
2
|
-
import { generateMessageIDV2, normalizeMessageContent } from '../Utils/index.js';
|
|
3
|
-
import { getBinaryNodeChild, getBinaryNodeChildren, getBinaryNodeChildString, isJidGroup, isJidMetaAI, isLidUser, isPnUser, jidEncode, jidNormalizedUser } from '../WABinary/index.js';
|
|
4
|
-
import { makeGroupsSocket } from './groups.js';
|
|
5
|
-
|
|
6
|
-
/** Default Meta AI bot JID used inside AI groups. */
|
|
7
|
-
export const META_AI_BOT_JID = '867051314767696@bot';
|
|
8
|
-
|
|
9
|
-
// `@bot` JIDs carry their device as a trailing suffix (`bot:1`), which
|
|
10
|
-
// jidNormalizedUser does not strip — normalize it before comparing.
|
|
11
|
-
const stripDeviceSuffix = (jid) => String(jid || '').replace(/:\d+$/, '');
|
|
12
|
-
const sameBotJid = (a, b) => {
|
|
13
|
-
if (!a || !b) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return jidNormalizedUser(stripDeviceSuffix(a)) === jidNormalizedUser(stripDeviceSuffix(b));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Pull the reply stanzaId out of a message: normalizeMessageContent returns the
|
|
20
|
-
// type-keyed wrapper (`{ extendedTextMessage: { ... } }`), so unwrap one level.
|
|
21
|
-
const extractReplyStanzaId = (message) => {
|
|
22
|
-
const content = message ? normalizeMessageContent(message) : undefined;
|
|
23
|
-
const inner = content && typeof content === 'object'
|
|
24
|
-
? content[Object.keys(content)[0]]
|
|
25
|
-
: undefined;
|
|
26
|
-
return inner?.contextInfo?.stanzaId || content?.contextInfo?.stanzaId || message?.messageContextInfo?.stanzaId;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Pure matcher: is `message` a Meta AI bot response in `chatJid`?
|
|
31
|
-
*
|
|
32
|
-
* A message is treated as a bot response when ALL of these hold:
|
|
33
|
-
* 1. it is not from me, and its remoteJid is the chat we prompted in;
|
|
34
|
-
* 2. the sender is a known bot JID (`@bot` suffix or one of `botJids`); OR
|
|
35
|
-
* its reply context (`contextInfo.stanzaId`) references the prompt we sent.
|
|
36
|
-
*
|
|
37
|
-
* The `botJids` fallback lets callers pass the bot's LID participant JID
|
|
38
|
-
* (resolved from group metadata) so LID-addressed AI groups match too.
|
|
39
|
-
*/
|
|
40
|
-
export const isMetaAIBotResponse = (message, chatJid, promptId, botJids = []) => {
|
|
41
|
-
if (!message || !message.key || message.key.fromMe) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
if (message.key.remoteJid !== chatJid) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
const sender = stripDeviceSuffix(message.key.participant || message.key.remoteJid);
|
|
48
|
-
if (isJidMetaAI(sender)) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
for (const botJid of botJids) {
|
|
52
|
-
if (sameBotJid(botJid, sender)) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (promptId && extractReplyStanzaId(message.message) === promptId) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
// Resolve the bot's real participant JID(s) inside an AI group so the response
|
|
63
|
-
// matcher can recognize LID-addressed bot messages. Falls back to the canonical
|
|
64
|
-
// `@bot` JID when metadata is unavailable.
|
|
65
|
-
export const collectMetaAIBotParticipantJids = async (sock, jid, botUser) => {
|
|
66
|
-
const candidates = new Set([botUser]);
|
|
67
|
-
if (!isJidGroup(jid)) {
|
|
68
|
-
return candidates;
|
|
69
|
-
}
|
|
70
|
-
const botNumber = jidNormalizedUser(botUser).split('@')[0];
|
|
71
|
-
try {
|
|
72
|
-
const meta = await sock.groupMetadata(jid);
|
|
73
|
-
for (const participant of meta.participants || []) {
|
|
74
|
-
const pn = participant.phoneNumber
|
|
75
|
-
? jidNormalizedUser(participant.phoneNumber).split('@')[0]
|
|
76
|
-
: undefined;
|
|
77
|
-
const idNumber = jidNormalizedUser(participant.id).split('@')[0];
|
|
78
|
-
if (pn === botNumber || idNumber === botNumber || isJidMetaAI(participant.id)) {
|
|
79
|
-
candidates.add(participant.id);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// metadata unavailable — the canonical @bot JID is already in the set
|
|
85
|
-
}
|
|
86
|
-
return candidates;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const makeAIGroupsSocket = (config) => {
|
|
90
|
-
const sock = makeGroupsSocket(config);
|
|
91
|
-
const { ev, query } = sock;
|
|
92
|
-
|
|
93
|
-
/** Query helper for AI groups (w:gp2 namespace) */
|
|
94
|
-
const aiGroupQuery = async (jid, type, content) => query({
|
|
95
|
-
tag: 'iq',
|
|
96
|
-
attrs: {
|
|
97
|
-
type,
|
|
98
|
-
xmlns: 'w:g2',
|
|
99
|
-
to: jid
|
|
100
|
-
},
|
|
101
|
-
content
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const aiGroupMetadata = async (jid) => {
|
|
105
|
-
const result = await aiGroupQuery(jid, 'get', [{ tag: 'query', attrs: { request: 'interactive' } }]);
|
|
106
|
-
return extractAIGroupMetadata(result);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Handle incoming w:gp2 notifications (create, promote, remove, add)
|
|
110
|
-
sock.ws.on('CB:notification,w:gp2', async (node) => {
|
|
111
|
-
const { attrs, content } = node;
|
|
112
|
-
if (!Array.isArray(content) || content.length === 0) return;
|
|
113
|
-
|
|
114
|
-
const inner = content[0];
|
|
115
|
-
const tag = inner.tag;
|
|
116
|
-
const groupId = typeof attrs.from === 'string'
|
|
117
|
-
? attrs.from
|
|
118
|
-
: attrs.from?.$1?.user
|
|
119
|
-
? jidEncode(attrs.from.$1.user, 'g.us')
|
|
120
|
-
: undefined;
|
|
121
|
-
|
|
122
|
-
if (!groupId) return;
|
|
123
|
-
|
|
124
|
-
if (tag === 'create') {
|
|
125
|
-
// New AI group created — emit groups.upsert
|
|
126
|
-
try {
|
|
127
|
-
const meta = await aiGroupMetadata(groupId);
|
|
128
|
-
ev.emit('groups.upsert', [meta]);
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
// metadata fetch may fail; emit minimal info
|
|
132
|
-
ev.emit('groups.upsert', [{ id: groupId }]);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else if (tag === 'promote' || tag === 'demote' || tag === 'remove' || tag === 'add') {
|
|
136
|
-
const participants = getBinaryNodeChildren(inner, 'participant')
|
|
137
|
-
.map(p => {
|
|
138
|
-
const jid = p.attrs.jid;
|
|
139
|
-
if (typeof jid === 'string') return jid;
|
|
140
|
-
if (jid?.$1) {
|
|
141
|
-
return jidEncode(jid.$1.user, jid.$1.server || 's.whatsapp.net');
|
|
142
|
-
}
|
|
143
|
-
return undefined;
|
|
144
|
-
})
|
|
145
|
-
.filter(Boolean);
|
|
146
|
-
|
|
147
|
-
ev.emit('group-participants.update', {
|
|
148
|
-
id: groupId,
|
|
149
|
-
participants,
|
|
150
|
-
action: tag
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
else if (tag === 'subject') {
|
|
154
|
-
ev.emit('groups.update', [{ id: groupId, subject: inner.attrs?.subject }]);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
await sock.sendMessageAck(node);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
...sock,
|
|
162
|
-
aiGroupMetadata,
|
|
163
|
-
aiGroupCreate: async (subject, participants = [], options = {}) => {
|
|
164
|
-
if (!Array.isArray(participants)) participants = [];
|
|
165
|
-
const key = generateMessageIDV2();
|
|
166
|
-
const {
|
|
167
|
-
ephemeralExpiration = 86400,
|
|
168
|
-
memberAddMode = 'all_member_add',
|
|
169
|
-
memberShareGroupHistoryMode = 'all_member_share',
|
|
170
|
-
memberLinkMode = 'all_member_link'
|
|
171
|
-
} = options;
|
|
172
|
-
const result = await aiGroupQuery('@g.us', 'set', [
|
|
173
|
-
{
|
|
174
|
-
tag: 'create',
|
|
175
|
-
attrs: {
|
|
176
|
-
subject,
|
|
177
|
-
key
|
|
178
|
-
},
|
|
179
|
-
content: participants.map(jid => ({
|
|
180
|
-
tag: 'participant',
|
|
181
|
-
attrs: { jid }
|
|
182
|
-
}))
|
|
183
|
-
}
|
|
184
|
-
]);
|
|
185
|
-
return extractAIGroupMetadata(result);
|
|
186
|
-
},
|
|
187
|
-
aiGroupAddBot: async (jid, botUser = '867051314767696') => {
|
|
188
|
-
const result = await aiGroupQuery(jid, 'set', [
|
|
189
|
-
{
|
|
190
|
-
tag: 'add',
|
|
191
|
-
attrs: {},
|
|
192
|
-
content: [
|
|
193
|
-
{
|
|
194
|
-
tag: 'participant',
|
|
195
|
-
attrs: { jid: `${botUser}@bot` }
|
|
196
|
-
}
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
]);
|
|
200
|
-
const node = getBinaryNodeChild(result, 'add');
|
|
201
|
-
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
202
|
-
return participantsAffected.map(p => ({
|
|
203
|
-
status: p.attrs.error || '200',
|
|
204
|
-
jid: p.attrs.jid
|
|
205
|
-
}));
|
|
206
|
-
},
|
|
207
|
-
aiGroupLeave: async (id) => {
|
|
208
|
-
await aiGroupQuery('@g.us', 'set', [
|
|
209
|
-
{
|
|
210
|
-
tag: 'leave',
|
|
211
|
-
attrs: {},
|
|
212
|
-
content: [{ tag: 'group', attrs: { id } }]
|
|
213
|
-
}
|
|
214
|
-
]);
|
|
215
|
-
},
|
|
216
|
-
aiGroupParticipantsUpdate: async (jid, participants, action) => {
|
|
217
|
-
const result = await aiGroupQuery(jid, 'set', [
|
|
218
|
-
{
|
|
219
|
-
tag: action,
|
|
220
|
-
attrs: {},
|
|
221
|
-
content: participants.map(jid => ({
|
|
222
|
-
tag: 'participant',
|
|
223
|
-
attrs: { jid }
|
|
224
|
-
}))
|
|
225
|
-
}
|
|
226
|
-
]);
|
|
227
|
-
const node = getBinaryNodeChild(result, action);
|
|
228
|
-
const participantsAffected = getBinaryNodeChildren(node, 'participant');
|
|
229
|
-
return participantsAffected.map(p => ({
|
|
230
|
-
status: p.attrs.error || '200',
|
|
231
|
-
jid: p.attrs.jid,
|
|
232
|
-
content: p
|
|
233
|
-
}));
|
|
234
|
-
},
|
|
235
|
-
aiGroupUpdateSubject: async (jid, subject) => {
|
|
236
|
-
await aiGroupQuery(jid, 'set', [
|
|
237
|
-
{
|
|
238
|
-
tag: 'subject',
|
|
239
|
-
attrs: {},
|
|
240
|
-
content: Buffer.from(subject, 'utf-8')
|
|
241
|
-
}
|
|
242
|
-
]);
|
|
243
|
-
},
|
|
244
|
-
aiGroupInviteCode: async (jid) => {
|
|
245
|
-
const result = await aiGroupQuery(jid, 'get', [{ tag: 'invite', attrs: {} }]);
|
|
246
|
-
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
247
|
-
return inviteNode?.attrs.code;
|
|
248
|
-
},
|
|
249
|
-
aiGroupRevokeInvite: async (jid) => {
|
|
250
|
-
const result = await aiGroupQuery(jid, 'set', [{ tag: 'invite', attrs: {} }]);
|
|
251
|
-
const inviteNode = getBinaryNodeChild(result, 'invite');
|
|
252
|
-
return inviteNode?.attrs.code;
|
|
253
|
-
},
|
|
254
|
-
aiGroupAcceptInvite: async (code) => {
|
|
255
|
-
const results = await aiGroupQuery('@g.us', 'set', [{ tag: 'invite', attrs: { code } }]);
|
|
256
|
-
const result = getBinaryNodeChild(results, 'group');
|
|
257
|
-
return result?.attrs.jid;
|
|
258
|
-
},
|
|
259
|
-
aiGroupSettingUpdate: async (jid, setting) => {
|
|
260
|
-
await aiGroupQuery(jid, 'set', [{ tag: setting, attrs: {} }]);
|
|
261
|
-
},
|
|
262
|
-
aiGroupToggleEphemeral: async (jid, ephemeralExpiration) => {
|
|
263
|
-
const content = ephemeralExpiration
|
|
264
|
-
? { tag: 'ephemeral', attrs: { expiration: ephemeralExpiration.toString() } }
|
|
265
|
-
: { tag: 'not_ephemeral', attrs: {} };
|
|
266
|
-
await aiGroupQuery(jid, 'set', [content]);
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
export const extractAIGroupMetadata = (result) => {
|
|
272
|
-
// IQ response nests group inside create node: result → create → group
|
|
273
|
-
const createNode = getBinaryNodeChild(result, 'create');
|
|
274
|
-
const group =
|
|
275
|
-
getBinaryNodeChild(createNode || result, 'group') ||
|
|
276
|
-
getBinaryNodeChild(result, 'group');
|
|
277
|
-
const descChild = getBinaryNodeChild(group, 'description');
|
|
278
|
-
let desc, descId, descOwner, descOwnerPn, descTime;
|
|
279
|
-
if (descChild) {
|
|
280
|
-
desc = getBinaryNodeChildString(descChild, 'body');
|
|
281
|
-
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined;
|
|
282
|
-
descOwnerPn = descChild.attrs.participant_pn
|
|
283
|
-
? jidNormalizedUser(descChild.attrs.participant_pn)
|
|
284
|
-
: undefined;
|
|
285
|
-
descTime = +descChild.attrs.t;
|
|
286
|
-
descId = descChild.attrs.id;
|
|
287
|
-
}
|
|
288
|
-
const groupId = group.attrs.id.includes('@') ? group.attrs.id : jidEncode(group.attrs.id, 'g.us');
|
|
289
|
-
const eph = getBinaryNodeChild(group, 'ephemeral')?.attrs.expiration;
|
|
290
|
-
const metadata = {
|
|
291
|
-
id: groupId,
|
|
292
|
-
subject: group.attrs.subject,
|
|
293
|
-
subjectTime: +group.attrs.s_t,
|
|
294
|
-
creation: +group.attrs.creation,
|
|
295
|
-
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
|
296
|
-
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
|
297
|
-
owner_country_code: group.attrs.creator_country_code,
|
|
298
|
-
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
|
299
|
-
desc,
|
|
300
|
-
descId,
|
|
301
|
-
descOwner,
|
|
302
|
-
descOwnerPn,
|
|
303
|
-
descTime,
|
|
304
|
-
isAIGroup: true,
|
|
305
|
-
addressingMode: group.attrs.addressing_mode === 'lid' ? WAMessageAddressingMode.LID : WAMessageAddressingMode.PN,
|
|
306
|
-
participants: getBinaryNodeChildren(group, 'participant').map(({ attrs }) => ({
|
|
307
|
-
id: attrs.jid,
|
|
308
|
-
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
|
309
|
-
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
|
310
|
-
admin: attrs.type || null
|
|
311
|
-
})),
|
|
312
|
-
ephemeralDuration: eph ? +eph : undefined
|
|
313
|
-
};
|
|
314
|
-
return metadata;
|
|
315
|
-
};
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { randomBytes, randomUUID } from 'crypto';
|
|
2
|
-
import { initAuthCreds } from '../Utils/auth-utils.js';
|
|
3
|
-
import { Curve, md5, signedKeyPair } from '../Utils/crypto.js';
|
|
4
|
-
import {
|
|
5
|
-
GRAPHQL_ACCESS_TOKEN,
|
|
6
|
-
GRAPHQL_BAN_STATUS_DOC_ID,
|
|
7
|
-
GRAPHQL_ENDPOINT,
|
|
8
|
-
MOBILE_COUNTRY_CODE,
|
|
9
|
-
MOBILE_REGISTRATION_ENDPOINT,
|
|
10
|
-
MOBILE_TOKEN,
|
|
11
|
-
MOBILE_USERAGENT
|
|
12
|
-
} from '../Defaults/ban-checker.js';
|
|
13
|
-
|
|
14
|
-
const COUNTRY_CODES = [
|
|
15
|
-
'1', '20', '27', '30', '31', '32', '33', '34', '36', '39', '40', '41', '43', '44', '45', '46', '47', '48', '49',
|
|
16
|
-
'51', '52', '53', '54', '55', '56', '57', '58', '60', '61', '62', '63', '64', '65', '66', '81', '82', '84', '86',
|
|
17
|
-
'90', '91', '92', '93', '94', '95', '98', '211', '212', '213', '216', '218', '220', '221', '222', '223', '224', '225',
|
|
18
|
-
'226', '227', '228', '229', '230', '231', '232', '233', '234', '235', '236', '237', '238', '239', '240', '241', '242',
|
|
19
|
-
'243', '244', '245', '246', '248', '249', '250', '251', '252', '253', '254', '255', '256', '257', '258', '260', '261',
|
|
20
|
-
'262', '263', '264', '265', '266', '267', '268', '269', '290', '291', '297', '298', '299', '350', '351', '352', '353',
|
|
21
|
-
'354', '355', '356', '357', '358', '359', '370', '371', '372', '373', '374', '375', '376', '377', '378', '380', '381',
|
|
22
|
-
'382', '383', '385', '386', '387', '389', '420', '421', '423', '500', '501', '502', '503', '504', '505', '506', '507',
|
|
23
|
-
'508', '509', '590', '591', '592', '593', '594', '595', '596', '597', '598', '599', '670', '672', '673', '674', '675',
|
|
24
|
-
'676', '677', '678', '679', '680', '681', '682', '683', '685', '686', '687', '688', '689', '690', '691', '692', '850',
|
|
25
|
-
'852', '853', '855', '856', '880', '886', '960', '961', '962', '963', '964', '965', '966', '967', '968', '970', '971',
|
|
26
|
-
'972', '973', '974', '975', '976', '977', '992', '993', '994', '995', '996', '998'
|
|
27
|
-
].sort((a, b) => b.length - a.length);
|
|
28
|
-
|
|
29
|
-
const PLACEHOLDER = /^REPLACE_WITH_/;
|
|
30
|
-
|
|
31
|
-
const cleanNumber = (value) => String(value || '').replace(/[\s().\-/]/g, '').replace(/^00/, '');
|
|
32
|
-
|
|
33
|
-
const normalizePhone = (value, options = {}) => {
|
|
34
|
-
const raw = cleanNumber(typeof value === 'object' ? value.number : value).replace(/^\+/, '');
|
|
35
|
-
if (!/^\d{6,15}$/.test(raw)) throw new TypeError('number must be an international phone number');
|
|
36
|
-
const requestedCountry = String(options.countryCode || MOBILE_COUNTRY_CODE || '').replace(/\D/g, '');
|
|
37
|
-
const countryCode = requestedCountry || COUNTRY_CODES.find((code) => raw.startsWith(code));
|
|
38
|
-
if (!countryCode || !raw.startsWith(countryCode)) throw new TypeError('number must include a recognized country calling code');
|
|
39
|
-
const nationalNumber = raw.slice(countryCode.length);
|
|
40
|
-
if (!nationalNumber) throw new TypeError('number is missing its national part');
|
|
41
|
-
return { countryCode, nationalNumber, e164: `+${raw}` };
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const urlEncode = (value) => encodeURIComponent(String(value)).replace(/%25([0-9a-f]{2})/gi, '%$1');
|
|
45
|
-
const urlHex = (buffer) => [...buffer].map((byte) => `%${byte.toString(16).padStart(2, '0')}`).join('');
|
|
46
|
-
|
|
47
|
-
const makeRegistrationParams = (countryCode, nationalNumber) => {
|
|
48
|
-
const creds = initAuthCreds();
|
|
49
|
-
const eRegId = Buffer.alloc(4);
|
|
50
|
-
eRegId.writeInt32BE(creds.registrationId);
|
|
51
|
-
const eSkeyId = Buffer.alloc(3);
|
|
52
|
-
eSkeyId.writeInt16BE(creds.signedPreKey.keyId);
|
|
53
|
-
return {
|
|
54
|
-
cc: countryCode,
|
|
55
|
-
in: nationalNumber,
|
|
56
|
-
Rc: '0', lg: 'en', lc: 'GB', mistyped: '6',
|
|
57
|
-
authkey: Buffer.from(creds.noiseKey.public).toString('base64url'),
|
|
58
|
-
e_regid: eRegId.toString('base64url'),
|
|
59
|
-
e_keytype: 'BQ',
|
|
60
|
-
e_ident: Buffer.from(creds.signedIdentityKey.public).toString('base64url'),
|
|
61
|
-
e_skey_id: eSkeyId.toString('base64url'),
|
|
62
|
-
e_skey_val: Buffer.from(creds.signedPreKey.keyPair.public).toString('base64url'),
|
|
63
|
-
e_skey_sig: Buffer.from(creds.signedPreKey.signature).toString('base64url'),
|
|
64
|
-
fdid: randomUUID(),
|
|
65
|
-
network_ratio_type: '1', expid: randomUUID(), simnum: '1', hasinrc: '1',
|
|
66
|
-
pid: String(Math.floor(Math.random() * 1000)),
|
|
67
|
-
id: urlHex(randomBytes(16)),
|
|
68
|
-
backup_token: urlHex(randomBytes(32)),
|
|
69
|
-
token: Buffer.from(md5(Buffer.concat([MOBILE_TOKEN, Buffer.from(nationalNumber)]))).toString('hex')
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const requestJson = async (url, options = {}) => {
|
|
74
|
-
const response = await fetch(url, { ...options, headers: { 'User-Agent': MOBILE_USERAGENT, ...(options.headers || {}) } });
|
|
75
|
-
let body = null;
|
|
76
|
-
try { body = await response.json(); } catch { body = {}; }
|
|
77
|
-
return { response, body };
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const getBanDetails = async (appealToken) => {
|
|
81
|
-
if (!appealToken || PLACEHOLDER.test(GRAPHQL_ACCESS_TOKEN) || PLACEHOLDER.test(GRAPHQL_BAN_STATUS_DOC_ID)) return null;
|
|
82
|
-
const { response, body } = await requestJson(GRAPHQL_ENDPOINT, {
|
|
83
|
-
method: 'POST',
|
|
84
|
-
headers: { 'Content-Type': 'application/json' },
|
|
85
|
-
body: JSON.stringify({
|
|
86
|
-
variables: JSON.stringify({ app_id: 'dev.app.id', request_token: appealToken }),
|
|
87
|
-
access_token: GRAPHQL_ACCESS_TOKEN,
|
|
88
|
-
doc_id: GRAPHQL_BAN_STATUS_DOC_ID,
|
|
89
|
-
lang: 'en_GB'
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
if (!response.ok) return null;
|
|
93
|
-
return body?.data?.whatsapp_support_ban_appeal_status || null;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const result = (number, status, isBanned = false, isNeedOfficialWa = false, banInfo = null) => ({ number, status, isBanned, isNeedOfficialWa, banInfo });
|
|
97
|
-
|
|
98
|
-
const getDiagnostic = (response, body) => {
|
|
99
|
-
const bodyObject = body && typeof body === 'object' && !Array.isArray(body) ? body : {};
|
|
100
|
-
const nestedData = bodyObject.data && typeof bodyObject.data === 'object' && !Array.isArray(bodyObject.data)
|
|
101
|
-
? bodyObject.data
|
|
102
|
-
: {};
|
|
103
|
-
const keys = Object.keys(bodyObject).sort();
|
|
104
|
-
return {
|
|
105
|
-
httpStatus: Number.isInteger(response?.status) ? response.status : null,
|
|
106
|
-
ok: response?.ok === true,
|
|
107
|
-
contentType: response?.headers?.get?.('content-type') || null,
|
|
108
|
-
bodyKeys: keys,
|
|
109
|
-
dataKeys: Object.keys(nestedData).sort(),
|
|
110
|
-
signals: {
|
|
111
|
-
hasReason: Object.prototype.hasOwnProperty.call(bodyObject, 'reason'),
|
|
112
|
-
hasError: Object.prototype.hasOwnProperty.call(bodyObject, 'error'),
|
|
113
|
-
hasStatus: Object.prototype.hasOwnProperty.call(bodyObject, 'status'),
|
|
114
|
-
hasAppealToken: Boolean(bodyObject.appeal_token || bodyObject.appealToken || nestedData.appeal_token),
|
|
115
|
-
hasBanFields: Boolean(bodyObject.ban_type || bodyObject.banType || bodyObject.violation_type || bodyObject.violationType)
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const withDiagnostic = (value, diagnostic) => diagnostic ? { ...value, diagnostics: diagnostic } : value;
|
|
121
|
-
|
|
122
|
-
export const checkStatusWA = async (number, options = {}) => {
|
|
123
|
-
const normalized = normalizePhone(number, options);
|
|
124
|
-
const params = makeRegistrationParams(normalized.countryCode, normalized.nationalNumber);
|
|
125
|
-
const query = Object.entries(params).map(([key, value]) => `${key}=${urlEncode(value)}`).join('&');
|
|
126
|
-
const { response, body } = await requestJson(`${MOBILE_REGISTRATION_ENDPOINT}/exist?${query}`);
|
|
127
|
-
const diagnostic = options.diagnostic === true ? getDiagnostic(response, body) : null;
|
|
128
|
-
const reason = String(body?.reason || body?.error || body?.status || '').toLowerCase();
|
|
129
|
-
const appealToken = body?.appeal_token || body?.appealToken || body?.data?.appeal_token;
|
|
130
|
-
|
|
131
|
-
if (response.status === 429 || /rate.?limit|too many/.test(reason)) return withDiagnostic(result(normalized.e164, 'rate_limited'), diagnostic);
|
|
132
|
-
if (/blocked|official/.test(reason) && !appealToken) return withDiagnostic(result(normalized.e164, 'blocked', false, true), diagnostic);
|
|
133
|
-
if (appealToken || /banned|ban|temporar|perman/.test(reason)) {
|
|
134
|
-
const details = await getBanDetails(appealToken);
|
|
135
|
-
const banType = details?.ban_type || details?.banType || body?.ban_type || body?.banType || (reason.includes('perman') ? 'permanent' : 'temporary');
|
|
136
|
-
return withDiagnostic(result(normalized.e164, 'banned', true, false, {
|
|
137
|
-
banType,
|
|
138
|
-
violationType: body?.violation_type || body?.violationType || null,
|
|
139
|
-
violationReason: body?.violation_reason || body?.violationReason || null,
|
|
140
|
-
canAppeal: banType !== 'permanent',
|
|
141
|
-
appealToken: appealToken || null,
|
|
142
|
-
banTime: details?.ban_time || details?.banTime || null,
|
|
143
|
-
banDate: details?.ban_date || details?.banDate || null,
|
|
144
|
-
appealStatus: details?.appeal_status || details?.appealStatus || null,
|
|
145
|
-
appealCreatedAt: details?.appeal_created_at || details?.appealCreatedAt || null
|
|
146
|
-
}), diagnostic);
|
|
147
|
-
}
|
|
148
|
-
if (response.ok && (!body?.reason || /^(ok|sent|active|registered)$/.test(reason))) return withDiagnostic(result(normalized.e164, 'active'), diagnostic);
|
|
149
|
-
if (/not.?registered|does.?not.?exist/.test(reason)) return withDiagnostic(result(normalized.e164, 'not_registered'), diagnostic);
|
|
150
|
-
return withDiagnostic(result(normalized.e164, 'unknown'), diagnostic);
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export { getBanDetails, normalizePhone };
|