@neelegirl/baileys 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -27
- package/WAProto/WAProto.proto +665 -291
- package/WAProto/index.d.ts +48037 -2294
- package/WAProto/index.js +139804 -45203
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +64 -58
- package/lib/Defaults/index.js +96 -74
- package/lib/Defaults/phonenumber-mcc.json +223 -0
- package/lib/Signal/WASignalGroup/GroupProtocol.js +1909 -0
- package/lib/Signal/WASignalGroup/ciphertext_message.js +16 -0
- package/lib/Signal/WASignalGroup/generate-proto.sh +1 -0
- package/lib/Signal/WASignalGroup/group.proto +42 -0
- package/lib/Signal/WASignalGroup/group_cipher.js +120 -0
- package/lib/Signal/WASignalGroup/group_session_builder.js +46 -0
- package/lib/Signal/WASignalGroup/index.js +6 -0
- package/lib/Signal/WASignalGroup/keyhelper.js +21 -0
- package/lib/Signal/WASignalGroup/protobufs.js +3 -0
- package/lib/Signal/WASignalGroup/queue_job.js +69 -0
- package/lib/Signal/WASignalGroup/readme.md +6 -0
- package/lib/Signal/WASignalGroup/sender_chain_key.js +50 -0
- package/lib/Signal/WASignalGroup/sender_key_distribution_message.js +78 -0
- package/lib/Signal/WASignalGroup/sender_key_message.js +92 -0
- package/lib/Signal/WASignalGroup/sender_key_name.js +70 -0
- package/lib/Signal/WASignalGroup/sender_key_record.js +56 -0
- package/lib/Signal/WASignalGroup/sender_key_state.js +129 -0
- package/lib/Signal/{Group/sender-message-key.js → WASignalGroup/sender_message_key.js} +16 -3
- package/lib/Signal/libsignal.d.ts +4 -5
- package/lib/Signal/libsignal.js +112 -292
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/abstract-socket-client.js +13 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +22 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/types.d.ts +15 -15
- package/lib/Socket/Client/types.js +15 -8
- package/lib/Socket/Client/websocket.d.ts +12 -12
- package/lib/Socket/Client/websocket.js +36 -24
- package/lib/Socket/business.d.ts +177 -178
- package/lib/Socket/business.js +71 -179
- package/lib/Socket/chats.d.ts +93 -93
- package/lib/Socket/chats.js +625 -474
- package/lib/Socket/communities.d.ts +62 -83
- package/lib/Socket/communities.js +414 -412
- package/lib/Socket/groups.d.ts +112 -118
- package/lib/Socket/groups.js +171 -146
- package/lib/Socket/index.d.ts +182 -222
- package/lib/Socket/index.js +17 -12
- package/lib/Socket/messages-recv.d.ts +169 -165
- package/lib/Socket/messages-recv.js +1721 -1185
- package/lib/Socket/messages-send.d.ts +160 -161
- package/lib/Socket/messages-send.js +992 -642
- package/lib/Socket/mex.d.ts +0 -1
- package/lib/Socket/mex.js +9 -4
- package/lib/Socket/newsletter.d.ts +139 -139
- package/lib/Socket/newsletter.js +258 -153
- package/lib/Socket/registration.d.ts +266 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +36 -42
- package/lib/Socket/socket.js +615 -533
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +83 -0
- package/lib/Store/index.d.ts +4 -0
- package/lib/Store/index.js +24 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/lib/Store/make-cache-manager-store.js +90 -0
- package/lib/Store/make-in-memory-store.d.ts +123 -0
- package/lib/Store/make-in-memory-store.js +429 -0
- package/lib/Store/make-ordered-dictionary.d.ts +12 -0
- package/lib/Store/make-ordered-dictionary.js +86 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/lib/Store/object-repository.js +31 -0
- package/lib/Types/Auth.d.ts +96 -87
- package/lib/Types/Auth.js +3 -2
- package/lib/Types/Call.d.ts +13 -13
- package/lib/Types/Call.js +3 -2
- package/lib/Types/Chat.d.ts +94 -79
- package/lib/Types/Chat.js +9 -8
- package/lib/Types/Contact.d.ts +9 -13
- package/lib/Types/Contact.js +3 -2
- package/lib/Types/Events.d.ts +179 -152
- package/lib/Types/Events.js +3 -2
- package/lib/Types/GroupMetadata.d.ts +48 -49
- package/lib/Types/GroupMetadata.js +3 -2
- package/lib/Types/Label.d.ts +14 -13
- package/lib/Types/Label.js +30 -24
- package/lib/Types/LabelAssociation.d.ts +20 -15
- package/lib/Types/LabelAssociation.js +12 -6
- package/lib/Types/Message.d.ts +404 -234
- package/lib/Types/Message.js +13 -11
- package/lib/Types/MexUpdates.d.ts +9 -0
- package/lib/Types/MexUpdates.js +18 -0
- package/lib/Types/Newsletter.d.ts +104 -130
- package/lib/Types/Newsletter.js +40 -31
- package/lib/Types/Product.d.ts +71 -58
- package/lib/Types/Product.js +3 -2
- package/lib/Types/Signal.d.ts +55 -63
- package/lib/Types/Signal.js +3 -2
- package/lib/Types/Socket.d.ts +66 -77
- package/lib/Types/Socket.js +3 -3
- package/lib/Types/State.d.ts +19 -17
- package/lib/Types/State.js +14 -13
- package/lib/Types/USync.d.ts +8 -8
- package/lib/Types/USync.js +3 -2
- package/lib/Types/index.d.ts +61 -47
- package/lib/Types/index.js +48 -26
- package/lib/Utils/auth-utils.d.ts +10 -8
- package/lib/Utils/auth-utils.js +154 -206
- package/lib/Utils/baileys-event-stream.d.ts +7 -6
- package/lib/Utils/baileys-event-stream.js +43 -29
- package/lib/Utils/business.d.ts +20 -14
- package/lib/Utils/business.js +134 -110
- package/lib/Utils/chat-utils.d.ts +69 -57
- package/lib/Utils/chat-utils.js +380 -362
- package/lib/Utils/check-npm-version.d.ts +15 -0
- package/lib/Utils/check-npm-version.js +52 -0
- package/lib/Utils/crypto.d.ts +45 -30
- package/lib/Utils/crypto.js +178 -141
- package/lib/Utils/decode-wa-message.d.ts +35 -42
- package/lib/Utils/decode-wa-message.js +150 -176
- package/lib/Utils/event-buffer.d.ts +17 -12
- package/lib/Utils/event-buffer.js +286 -269
- package/lib/Utils/generics.d.ts +99 -60
- package/lib/Utils/generics.js +481 -244
- package/lib/Utils/history.d.ts +22 -18
- package/lib/Utils/history.js +80 -54
- package/lib/Utils/index.d.ts +19 -20
- package/lib/Utils/index.js +41 -19
- package/lib/Utils/link-preview.d.ts +14 -12
- package/lib/Utils/link-preview.js +75 -40
- package/lib/Utils/logger.d.ts +11 -10
- package/lib/Utils/logger.js +7 -3
- package/lib/Utils/lt-hash.d.ts +13 -12
- package/lib/Utils/lt-hash.js +37 -27
- package/lib/Utils/make-mutex.d.ts +7 -6
- package/lib/Utils/make-mutex.js +29 -20
- package/lib/Utils/message-retry-manager.d.ts +6 -6
- package/lib/Utils/message-retry-manager.js +36 -8
- package/lib/Utils/messages-media.d.ts +102 -87
- package/lib/Utils/messages-media.js +570 -427
- package/lib/Utils/messages.d.ts +64 -37
- package/lib/Utils/messages.js +1270 -511
- package/lib/Utils/noise-handler.d.ts +18 -18
- package/lib/Utils/noise-handler.js +109 -101
- package/lib/Utils/process-message.d.ts +32 -25
- package/lib/Utils/process-message.js +281 -266
- package/lib/Utils/signal.d.ts +32 -24
- package/lib/Utils/signal.js +105 -98
- package/lib/Utils/use-mongo-file-auth-state.d.ts +6 -0
- package/lib/Utils/use-mongo-file-auth-state.js +84 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +10 -5
- package/lib/Utils/use-multi-file-auth-state.js +186 -69
- package/lib/Utils/use-single-file-auth-state.d.ts +13 -0
- package/lib/Utils/use-single-file-auth-state.js +80 -0
- package/lib/Utils/validate-connection.d.ts +13 -11
- package/lib/Utils/validate-connection.js +116 -124
- package/lib/WABinary/constants.d.ts +27 -25
- package/lib/WABinary/constants.js +1292 -1277
- package/lib/WABinary/decode.d.ts +9 -7
- package/lib/WABinary/decode.js +189 -139
- package/lib/WABinary/encode.d.ts +3 -3
- package/lib/WABinary/encode.js +154 -105
- package/lib/WABinary/generic-utils.d.ts +27 -14
- package/lib/WABinary/generic-utils.js +102 -62
- package/lib/WABinary/index.d.ts +5 -6
- package/lib/WABinary/index.js +25 -6
- package/lib/WABinary/jid-utils.d.ts +46 -41
- package/lib/WABinary/jid-utils.js +80 -84
- package/lib/WABinary/types.d.ts +13 -10
- package/lib/WABinary/types.js +3 -2
- package/lib/WAM/BinaryInfo.d.ts +15 -8
- package/lib/WAM/BinaryInfo.js +14 -7
- package/lib/WAM/constants.d.ts +37 -30
- package/lib/WAM/constants.js +11983 -19465
- package/lib/WAM/encode.d.ts +3 -3
- package/lib/WAM/encode.js +110 -95
- package/lib/WAM/index.d.ts +3 -4
- package/lib/WAM/index.js +23 -4
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.d.ts +28 -0
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +69 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +19 -12
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -19
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +26 -18
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +20 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -11
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +24 -16
- package/lib/WAUSync/Protocols/index.d.ts +6 -5
- package/lib/WAUSync/Protocols/index.js +26 -5
- package/lib/WAUSync/USyncQuery.d.ts +28 -26
- package/lib/WAUSync/USyncQuery.js +62 -64
- package/lib/WAUSync/USyncUser.d.ts +10 -11
- package/lib/WAUSync/USyncUser.js +19 -12
- package/lib/WAUSync/index.d.ts +3 -4
- package/lib/WAUSync/index.js +23 -4
- package/lib/index.d.ts +11 -10
- package/lib/index.js +33 -11
- package/package.json +43 -48
- package/WAProto/GenerateStatics.sh +0 -3
- package/WAProto/fix-imports.js +0 -29
- package/engine-requirements.js +0 -10
- package/lib/Defaults/index.d.ts.map +0 -1
- package/lib/Defaults/index.js.map +0 -1
- package/lib/Signal/Group/ciphertext-message.d.ts +0 -10
- package/lib/Signal/Group/ciphertext-message.d.ts.map +0 -1
- package/lib/Signal/Group/ciphertext-message.js +0 -12
- package/lib/Signal/Group/ciphertext-message.js.map +0 -1
- package/lib/Signal/Group/group-session-builder.d.ts +0 -15
- package/lib/Signal/Group/group-session-builder.d.ts.map +0 -1
- package/lib/Signal/Group/group-session-builder.js +0 -30
- package/lib/Signal/Group/group-session-builder.js.map +0 -1
- package/lib/Signal/Group/group_cipher.d.ts +0 -17
- package/lib/Signal/Group/group_cipher.d.ts.map +0 -1
- package/lib/Signal/Group/group_cipher.js +0 -82
- package/lib/Signal/Group/group_cipher.js.map +0 -1
- package/lib/Signal/Group/index.d.ts +0 -12
- package/lib/Signal/Group/index.d.ts.map +0 -1
- package/lib/Signal/Group/index.js +0 -12
- package/lib/Signal/Group/index.js.map +0 -1
- package/lib/Signal/Group/keyhelper.d.ts +0 -11
- package/lib/Signal/Group/keyhelper.d.ts.map +0 -1
- package/lib/Signal/Group/keyhelper.js +0 -18
- package/lib/Signal/Group/keyhelper.js.map +0 -1
- package/lib/Signal/Group/sender-chain-key.d.ts +0 -14
- package/lib/Signal/Group/sender-chain-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-chain-key.js +0 -26
- package/lib/Signal/Group/sender-chain-key.js.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +0 -17
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-distribution-message.js +0 -63
- package/lib/Signal/Group/sender-key-distribution-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-message.d.ts +0 -19
- package/lib/Signal/Group/sender-key-message.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-message.js +0 -66
- package/lib/Signal/Group/sender-key-message.js.map +0 -1
- package/lib/Signal/Group/sender-key-name.d.ts +0 -18
- package/lib/Signal/Group/sender-key-name.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-name.js +0 -48
- package/lib/Signal/Group/sender-key-name.js.map +0 -1
- package/lib/Signal/Group/sender-key-record.d.ts +0 -31
- package/lib/Signal/Group/sender-key-record.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-record.js +0 -41
- package/lib/Signal/Group/sender-key-record.js.map +0 -1
- package/lib/Signal/Group/sender-key-state.d.ts +0 -39
- package/lib/Signal/Group/sender-key-state.d.ts.map +0 -1
- package/lib/Signal/Group/sender-key-state.js +0 -84
- package/lib/Signal/Group/sender-key-state.js.map +0 -1
- package/lib/Signal/Group/sender-message-key.d.ts +0 -12
- package/lib/Signal/Group/sender-message-key.d.ts.map +0 -1
- package/lib/Signal/Group/sender-message-key.js.map +0 -1
- package/lib/Signal/libsignal.d.ts.map +0 -1
- package/lib/Signal/libsignal.js.map +0 -1
- package/lib/Signal/lid-mapping.d.ts +0 -23
- package/lib/Signal/lid-mapping.d.ts.map +0 -1
- package/lib/Signal/lid-mapping.js +0 -171
- package/lib/Signal/lid-mapping.js.map +0 -1
- package/lib/Socket/Client/index.d.ts.map +0 -1
- package/lib/Socket/Client/index.js.map +0 -1
- package/lib/Socket/Client/types.d.ts.map +0 -1
- package/lib/Socket/Client/types.js.map +0 -1
- package/lib/Socket/Client/websocket.d.ts.map +0 -1
- package/lib/Socket/Client/websocket.js.map +0 -1
- package/lib/Socket/business.d.ts.map +0 -1
- package/lib/Socket/business.js.map +0 -1
- package/lib/Socket/chats.d.ts.map +0 -1
- package/lib/Socket/chats.js.map +0 -1
- package/lib/Socket/communities.d.ts.map +0 -1
- package/lib/Socket/communities.js.map +0 -1
- package/lib/Socket/groups.d.ts.map +0 -1
- package/lib/Socket/groups.js.map +0 -1
- package/lib/Socket/index.d.ts.map +0 -1
- package/lib/Socket/index.js.map +0 -1
- package/lib/Socket/messages-recv.d.ts.map +0 -1
- package/lib/Socket/messages-recv.js.map +0 -1
- package/lib/Socket/messages-send.d.ts.map +0 -1
- package/lib/Socket/messages-send.js.map +0 -1
- package/lib/Socket/mex.d.ts.map +0 -1
- package/lib/Socket/mex.js.map +0 -1
- package/lib/Socket/newsletter.d.ts.map +0 -1
- package/lib/Socket/newsletter.js.map +0 -1
- package/lib/Socket/socket.d.ts.map +0 -1
- package/lib/Socket/socket.js.map +0 -1
- package/lib/Types/Auth.d.ts.map +0 -1
- package/lib/Types/Auth.js.map +0 -1
- package/lib/Types/Bussines.d.ts +0 -25
- package/lib/Types/Bussines.d.ts.map +0 -1
- package/lib/Types/Bussines.js +0 -2
- package/lib/Types/Bussines.js.map +0 -1
- package/lib/Types/Call.d.ts.map +0 -1
- package/lib/Types/Call.js.map +0 -1
- package/lib/Types/Chat.d.ts.map +0 -1
- package/lib/Types/Chat.js.map +0 -1
- package/lib/Types/Contact.d.ts.map +0 -1
- package/lib/Types/Contact.js.map +0 -1
- package/lib/Types/Events.d.ts.map +0 -1
- package/lib/Types/Events.js.map +0 -1
- package/lib/Types/GroupMetadata.d.ts.map +0 -1
- package/lib/Types/GroupMetadata.js.map +0 -1
- package/lib/Types/Label.d.ts.map +0 -1
- package/lib/Types/Label.js.map +0 -1
- package/lib/Types/LabelAssociation.d.ts.map +0 -1
- package/lib/Types/LabelAssociation.js.map +0 -1
- package/lib/Types/Message.d.ts.map +0 -1
- package/lib/Types/Message.js.map +0 -1
- package/lib/Types/Newsletter.d.ts.map +0 -1
- package/lib/Types/Newsletter.js.map +0 -1
- package/lib/Types/Product.d.ts.map +0 -1
- package/lib/Types/Product.js.map +0 -1
- package/lib/Types/Signal.d.ts.map +0 -1
- package/lib/Types/Signal.js.map +0 -1
- package/lib/Types/Socket.d.ts.map +0 -1
- package/lib/Types/Socket.js.map +0 -1
- package/lib/Types/State.d.ts.map +0 -1
- package/lib/Types/State.js.map +0 -1
- package/lib/Types/USync.d.ts.map +0 -1
- package/lib/Types/USync.js.map +0 -1
- package/lib/Types/index.d.ts.map +0 -1
- package/lib/Types/index.js.map +0 -1
- package/lib/Utils/auth-utils.d.ts.map +0 -1
- package/lib/Utils/auth-utils.js.map +0 -1
- package/lib/Utils/baileys-event-stream.d.ts.map +0 -1
- package/lib/Utils/baileys-event-stream.js.map +0 -1
- package/lib/Utils/browser-utils.d.ts +0 -4
- package/lib/Utils/browser-utils.d.ts.map +0 -1
- package/lib/Utils/browser-utils.js +0 -28
- package/lib/Utils/browser-utils.js.map +0 -1
- package/lib/Utils/business.d.ts.map +0 -1
- package/lib/Utils/business.js.map +0 -1
- package/lib/Utils/chat-utils.d.ts.map +0 -1
- package/lib/Utils/chat-utils.js.map +0 -1
- package/lib/Utils/crypto.d.ts.map +0 -1
- package/lib/Utils/crypto.js.map +0 -1
- package/lib/Utils/decode-wa-message.d.ts.map +0 -1
- package/lib/Utils/decode-wa-message.js.map +0 -1
- package/lib/Utils/event-buffer.d.ts.map +0 -1
- package/lib/Utils/event-buffer.js.map +0 -1
- package/lib/Utils/generics.d.ts.map +0 -1
- package/lib/Utils/generics.js.map +0 -1
- package/lib/Utils/history.d.ts.map +0 -1
- package/lib/Utils/history.js.map +0 -1
- package/lib/Utils/index.d.ts.map +0 -1
- package/lib/Utils/index.js.map +0 -1
- package/lib/Utils/link-preview.d.ts.map +0 -1
- package/lib/Utils/link-preview.js.map +0 -1
- package/lib/Utils/logger.d.ts.map +0 -1
- package/lib/Utils/logger.js.map +0 -1
- package/lib/Utils/lt-hash.d.ts.map +0 -1
- package/lib/Utils/lt-hash.js.map +0 -1
- package/lib/Utils/make-mutex.d.ts.map +0 -1
- package/lib/Utils/make-mutex.js.map +0 -1
- package/lib/Utils/message-retry-manager.d.ts.map +0 -1
- package/lib/Utils/message-retry-manager.js.map +0 -1
- package/lib/Utils/messages-media.d.ts.map +0 -1
- package/lib/Utils/messages-media.js.map +0 -1
- package/lib/Utils/messages.d.ts.map +0 -1
- package/lib/Utils/messages.js.map +0 -1
- package/lib/Utils/noise-handler.d.ts.map +0 -1
- package/lib/Utils/noise-handler.js.map +0 -1
- package/lib/Utils/pre-key-manager.d.ts +0 -28
- package/lib/Utils/pre-key-manager.d.ts.map +0 -1
- package/lib/Utils/pre-key-manager.js +0 -106
- package/lib/Utils/pre-key-manager.js.map +0 -1
- package/lib/Utils/process-message.d.ts.map +0 -1
- package/lib/Utils/process-message.js.map +0 -1
- package/lib/Utils/signal.d.ts.map +0 -1
- package/lib/Utils/signal.js.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +0 -1
- package/lib/Utils/use-multi-file-auth-state.js.map +0 -1
- package/lib/Utils/validate-connection.d.ts.map +0 -1
- package/lib/Utils/validate-connection.js.map +0 -1
- package/lib/WABinary/constants.d.ts.map +0 -1
- package/lib/WABinary/constants.js.map +0 -1
- package/lib/WABinary/decode.d.ts.map +0 -1
- package/lib/WABinary/decode.js.map +0 -1
- package/lib/WABinary/encode.d.ts.map +0 -1
- package/lib/WABinary/encode.js.map +0 -1
- package/lib/WABinary/generic-utils.d.ts.map +0 -1
- package/lib/WABinary/generic-utils.js.map +0 -1
- package/lib/WABinary/index.d.ts.map +0 -1
- package/lib/WABinary/index.js.map +0 -1
- package/lib/WABinary/jid-utils.d.ts.map +0 -1
- package/lib/WABinary/jid-utils.js.map +0 -1
- package/lib/WABinary/types.d.ts.map +0 -1
- package/lib/WABinary/types.js.map +0 -1
- package/lib/WAM/BinaryInfo.d.ts.map +0 -1
- package/lib/WAM/BinaryInfo.js.map +0 -1
- package/lib/WAM/constants.d.ts.map +0 -1
- package/lib/WAM/constants.js.map +0 -1
- package/lib/WAM/encode.d.ts.map +0 -1
- package/lib/WAM/encode.js.map +0 -1
- package/lib/WAM/index.d.ts.map +0 -1
- package/lib/WAM/index.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +0 -26
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +0 -51
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +0 -10
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +0 -29
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +0 -1
- package/lib/WAUSync/Protocols/index.d.ts.map +0 -1
- package/lib/WAUSync/Protocols/index.js.map +0 -1
- package/lib/WAUSync/USyncQuery.d.ts.map +0 -1
- package/lib/WAUSync/USyncQuery.js.map +0 -1
- package/lib/WAUSync/USyncUser.d.ts.map +0 -1
- package/lib/WAUSync/USyncUser.js.map +0 -1
- package/lib/WAUSync/index.d.ts.map +0 -1
- package/lib/WAUSync/index.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/Utils/auth-utils.js
CHANGED
|
@@ -1,245 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
8
|
+
|
|
9
|
+
const crypto_1 = require("crypto")
|
|
10
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"))
|
|
11
|
+
const Defaults_1 = require("../Defaults")
|
|
12
|
+
const crypto_2 = require("./crypto")
|
|
13
|
+
const generics_1 = require("./generics")
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Adds caching capability to a SignalKeyStore
|
|
12
17
|
* @param store the store to add caching to
|
|
13
18
|
* @param logger to log trace events
|
|
14
19
|
* @param _cache cache store to use
|
|
15
20
|
*/
|
|
16
|
-
|
|
17
|
-
const cache = _cache ||
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
// Mutex for protecting cache operations
|
|
24
|
-
const cacheMutex = new Mutex();
|
|
21
|
+
function makeCacheableSignalKeyStore(store, logger, _cache) {
|
|
22
|
+
const cache = _cache || new node_cache_1.default({
|
|
23
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.SIGNAL_STORE,
|
|
24
|
+
useClones: false,
|
|
25
|
+
deleteOnExpire: true,
|
|
26
|
+
})
|
|
25
27
|
function getUniqueId(type, id) {
|
|
26
|
-
return `${type}.${id}
|
|
28
|
+
return `${type}.${id}`
|
|
27
29
|
}
|
|
28
30
|
return {
|
|
29
31
|
async get(type, ids) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
data[id] = item;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
idsToFetch.push(id);
|
|
40
|
-
}
|
|
32
|
+
const data = {}
|
|
33
|
+
const idsToFetch = []
|
|
34
|
+
for (const id of ids) {
|
|
35
|
+
const item = cache.get(getUniqueId(type, id))
|
|
36
|
+
if (typeof item !== 'undefined') {
|
|
37
|
+
data[id] = item
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
else {
|
|
40
|
+
idsToFetch.push(id)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (idsToFetch.length) {
|
|
44
|
+
logger?.trace({ items: idsToFetch.length }, 'loading from store')
|
|
45
|
+
const fetched = await store.get(type, idsToFetch)
|
|
46
|
+
for (const id of idsToFetch) {
|
|
47
|
+
const item = fetched[id]
|
|
48
|
+
if (item) {
|
|
49
|
+
data[id] = item
|
|
50
|
+
cache.set(getUniqueId(type, id), item)
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
}
|
|
54
|
+
return data
|
|
55
55
|
},
|
|
56
56
|
async set(data) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for (const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
keys += 1;
|
|
63
|
-
}
|
|
57
|
+
let keys = 0
|
|
58
|
+
for (const type in data) {
|
|
59
|
+
for (const id in data[type]) {
|
|
60
|
+
cache.set(getUniqueId(type, id), data[type][id])
|
|
61
|
+
keys += 1
|
|
64
62
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
}
|
|
64
|
+
logger?.trace({ keys }, 'updated cache')
|
|
65
|
+
await store.set(data)
|
|
68
66
|
},
|
|
69
67
|
async clear() {
|
|
70
|
-
|
|
71
|
-
await store.clear?.()
|
|
68
|
+
cache.flushAll()
|
|
69
|
+
await store.clear?.call(store)
|
|
72
70
|
}
|
|
73
|
-
}
|
|
71
|
+
}
|
|
74
72
|
}
|
|
73
|
+
|
|
75
74
|
/**
|
|
76
|
-
* Adds DB
|
|
77
|
-
*
|
|
75
|
+
* Adds DB like transaction capability (https://en.wikipedia.org/wiki/Database_transaction) to the SignalKeyStore,
|
|
76
|
+
* this allows batch read & write operations & improves the performance of the lib
|
|
78
77
|
* @param state the key store to apply this capability to
|
|
79
78
|
* @param logger logger to log events
|
|
80
79
|
* @returns SignalKeyStore with transaction capability
|
|
81
80
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get or create a queue for a specific key type
|
|
91
|
-
*/
|
|
92
|
-
function getQueue(key) {
|
|
93
|
-
if (!keyQueues.has(key)) {
|
|
94
|
-
keyQueues.set(key, new PQueue({ concurrency: 1 }));
|
|
95
|
-
}
|
|
96
|
-
return keyQueues.get(key);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get or create a transaction mutex
|
|
100
|
-
*/
|
|
101
|
-
function getTxMutex(key) {
|
|
102
|
-
if (!txMutexes.has(key)) {
|
|
103
|
-
txMutexes.set(key, new Mutex());
|
|
104
|
-
}
|
|
105
|
-
return txMutexes.get(key);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Check if currently in a transaction
|
|
109
|
-
*/
|
|
110
|
-
function isInTransaction() {
|
|
111
|
-
return !!txStorage.getStore();
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Commit transaction with retries
|
|
115
|
-
*/
|
|
116
|
-
async function commitWithRetry(mutations) {
|
|
117
|
-
if (Object.keys(mutations).length === 0) {
|
|
118
|
-
logger.trace('no mutations in transaction');
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
logger.trace('committing transaction');
|
|
122
|
-
for (let attempt = 0; attempt < maxCommitRetries; attempt++) {
|
|
123
|
-
try {
|
|
124
|
-
await state.set(mutations);
|
|
125
|
-
logger.trace({ mutationCount: Object.keys(mutations).length }, 'committed transaction');
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
const retriesLeft = maxCommitRetries - attempt - 1;
|
|
130
|
-
logger.warn(`failed to commit mutations, retries left=${retriesLeft}`);
|
|
131
|
-
if (retriesLeft === 0) {
|
|
132
|
-
throw error;
|
|
133
|
-
}
|
|
134
|
-
await delay(delayBetweenTriesMs);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
81
|
+
const addTransactionCapability = (state, logger, { maxCommitRetries, delayBetweenTriesMs }) => {
|
|
82
|
+
// number of queries made to the DB during the transaction
|
|
83
|
+
// only there for logging purposes
|
|
84
|
+
let dbQueriesInTransaction = 0
|
|
85
|
+
let transactionCache = {}
|
|
86
|
+
let mutations = {}
|
|
87
|
+
let transactionsInProgress = 0
|
|
138
88
|
return {
|
|
139
89
|
get: async (type, ids) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const fetched = await getTxMutex(type).runExclusive(() => state.get(type, missing));
|
|
152
|
-
// Update cache
|
|
153
|
-
ctx.cache[type] = ctx.cache[type] || {};
|
|
154
|
-
Object.assign(ctx.cache[type], fetched);
|
|
155
|
-
}
|
|
156
|
-
// Return requested ids from cache
|
|
157
|
-
const result = {};
|
|
158
|
-
for (const id of ids) {
|
|
159
|
-
const value = ctx.cache[type]?.[id];
|
|
160
|
-
if (value !== undefined && value !== null) {
|
|
161
|
-
result[id] = value;
|
|
90
|
+
if (isInTransaction()) {
|
|
91
|
+
const dict = transactionCache[type]
|
|
92
|
+
const idsRequiringFetch = dict
|
|
93
|
+
? ids.filter(item => typeof dict[item] === 'undefined')
|
|
94
|
+
: ids
|
|
95
|
+
// only fetch if there are any items to fetch
|
|
96
|
+
if (idsRequiringFetch.length) {
|
|
97
|
+
dbQueriesInTransaction += 1
|
|
98
|
+
const result = await state.get(type, idsRequiringFetch)
|
|
99
|
+
transactionCache[type] || (transactionCache[type] = {})
|
|
100
|
+
Object.assign(transactionCache[type], result)
|
|
162
101
|
}
|
|
102
|
+
return ids.reduce((dict, id) => {
|
|
103
|
+
const value = transactionCache[type]?.[id]
|
|
104
|
+
if (value) {
|
|
105
|
+
dict[id] = value
|
|
106
|
+
}
|
|
107
|
+
return dict
|
|
108
|
+
}, {})
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return state.get(type, ids)
|
|
163
112
|
}
|
|
164
|
-
return result;
|
|
165
113
|
},
|
|
166
|
-
set:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (type === 'pre-key') {
|
|
175
|
-
await preKeyManager.validateDeletions(data, type);
|
|
176
|
-
}
|
|
114
|
+
set: data => {
|
|
115
|
+
if (isInTransaction()) {
|
|
116
|
+
logger.trace({ types: Object.keys(data) }, 'caching in transaction')
|
|
117
|
+
for (const key in data) {
|
|
118
|
+
transactionCache[key] = transactionCache[key] || {}
|
|
119
|
+
Object.assign(transactionCache[key], data[key])
|
|
120
|
+
mutations[key] = mutations[key] || {}
|
|
121
|
+
Object.assign(mutations[key], data[key])
|
|
177
122
|
}
|
|
178
|
-
// Write all data in parallel
|
|
179
|
-
await Promise.all(types.map(type => getQueue(type).add(async () => {
|
|
180
|
-
const typeData = { [type]: data[type] };
|
|
181
|
-
await state.set(typeData);
|
|
182
|
-
})));
|
|
183
|
-
return;
|
|
184
123
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
for (const key_ in data) {
|
|
188
|
-
const key = key_;
|
|
189
|
-
// Ensure structures exist
|
|
190
|
-
ctx.cache[key] = ctx.cache[key] || {};
|
|
191
|
-
ctx.mutations[key] = ctx.mutations[key] || {};
|
|
192
|
-
// Special handling for pre-keys
|
|
193
|
-
if (key === 'pre-key') {
|
|
194
|
-
await preKeyManager.processOperations(data, key, ctx.cache, ctx.mutations, true);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
// Normal key types
|
|
198
|
-
Object.assign(ctx.cache[key], data[key]);
|
|
199
|
-
Object.assign(ctx.mutations[key], data[key]);
|
|
200
|
-
}
|
|
124
|
+
else {
|
|
125
|
+
return state.set(data)
|
|
201
126
|
}
|
|
202
127
|
},
|
|
203
128
|
isInTransaction,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (
|
|
208
|
-
logger.trace('
|
|
209
|
-
return work();
|
|
129
|
+
async transaction(work) {
|
|
130
|
+
let result
|
|
131
|
+
transactionsInProgress += 1
|
|
132
|
+
if (transactionsInProgress === 1) {
|
|
133
|
+
logger.trace('entering transaction')
|
|
210
134
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
mutations
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
135
|
+
try {
|
|
136
|
+
result = await work()
|
|
137
|
+
// commit if this is the outermost transaction
|
|
138
|
+
if (transactionsInProgress === 1) {
|
|
139
|
+
if (Object.keys(mutations).length) {
|
|
140
|
+
logger.trace('committing transaction')
|
|
141
|
+
// retry mechanism to ensure we've some recovery
|
|
142
|
+
// in case a transaction fails in the first attempt
|
|
143
|
+
let tries = maxCommitRetries
|
|
144
|
+
while (tries) {
|
|
145
|
+
tries -= 1
|
|
146
|
+
try {
|
|
147
|
+
await state.set(mutations)
|
|
148
|
+
logger.trace({ dbQueriesInTransaction }, 'committed transaction')
|
|
149
|
+
break
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
logger.warn(`failed to commit ${Object.keys(mutations).length} mutations, tries left=${tries}`)
|
|
153
|
+
await generics_1.delay(delayBetweenTriesMs)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
logger.trace('no mutations in transaction')
|
|
159
|
+
}
|
|
225
160
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
transactionsInProgress -= 1
|
|
164
|
+
if (transactionsInProgress === 0) {
|
|
165
|
+
transactionCache = {}
|
|
166
|
+
mutations = {}
|
|
167
|
+
dbQueriesInTransaction = 0
|
|
229
168
|
}
|
|
230
|
-
}
|
|
169
|
+
}
|
|
170
|
+
return result
|
|
231
171
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
172
|
+
}
|
|
173
|
+
function isInTransaction() {
|
|
174
|
+
return transactionsInProgress > 0
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const initAuthCreds = () => {
|
|
179
|
+
const identityKey = crypto_2.Curve.generateKeyPair()
|
|
236
180
|
return {
|
|
237
|
-
noiseKey: Curve.generateKeyPair(),
|
|
238
|
-
pairingEphemeralKeyPair: Curve.generateKeyPair(),
|
|
181
|
+
noiseKey: crypto_2.Curve.generateKeyPair(),
|
|
182
|
+
pairingEphemeralKeyPair: crypto_2.Curve.generateKeyPair(),
|
|
239
183
|
signedIdentityKey: identityKey,
|
|
240
|
-
signedPreKey: signedKeyPair(identityKey, 1),
|
|
241
|
-
registrationId: generateRegistrationId(),
|
|
242
|
-
advSecretKey: randomBytes(32).toString('base64'),
|
|
184
|
+
signedPreKey: crypto_2.signedKeyPair(identityKey, 1),
|
|
185
|
+
registrationId: generics_1.generateRegistrationId(),
|
|
186
|
+
advSecretKey: crypto_1.randomBytes(32).toString('base64'),
|
|
243
187
|
processedHistoryMessages: [],
|
|
244
188
|
nextPreKeyId: 1,
|
|
245
189
|
firstUnuploadedPreKeyId: 1,
|
|
@@ -250,8 +194,12 @@ export const initAuthCreds = () => {
|
|
|
250
194
|
registered: false,
|
|
251
195
|
pairingCode: undefined,
|
|
252
196
|
lastPropHash: undefined,
|
|
253
|
-
routingInfo: undefined
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
197
|
+
routingInfo: undefined
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = {
|
|
202
|
+
makeCacheableSignalKeyStore,
|
|
203
|
+
addTransactionCapability,
|
|
204
|
+
initAuthCreds
|
|
205
|
+
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type { BaileysEventEmitter } from '../Types
|
|
1
|
+
import type { BaileysEventEmitter } from '../Types'
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Captures events from a baileys event emitter & stores them in a file
|
|
4
5
|
* @param ev The event emitter to read events from
|
|
5
6
|
* @param filename File to save to
|
|
6
7
|
*/
|
|
7
|
-
export declare const captureEventStream: (ev: BaileysEventEmitter, filename: string) => void
|
|
8
|
+
export declare const captureEventStream: (ev: BaileysEventEmitter, filename: string) => void
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Read event file and emit events from there
|
|
10
12
|
* @param filename filename containing event data
|
|
11
13
|
* @param delayIntervalMs delay between each event emit
|
|
12
14
|
*/
|
|
13
15
|
export declare const readAndEmitEventStream: (filename: string, delayIntervalMs?: number) => {
|
|
14
|
-
ev: BaileysEventEmitter
|
|
15
|
-
task: Promise<void
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=baileys-event-stream.d.ts.map
|
|
16
|
+
ev: BaileysEventEmitter
|
|
17
|
+
task: Promise<void>
|
|
18
|
+
}
|
|
@@ -1,56 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
8
|
+
|
|
9
|
+
const events_1 = __importDefault(require("events"))
|
|
10
|
+
const fs_1 = require("fs")
|
|
11
|
+
const promises_1 = require("fs/promises")
|
|
12
|
+
const readline_1 = require("readline")
|
|
13
|
+
const generics_1 = require("./generics")
|
|
14
|
+
const make_mutex_1 = require("./make-mutex")
|
|
15
|
+
|
|
7
16
|
/**
|
|
8
17
|
* Captures events from a baileys event emitter & stores them in a file
|
|
9
18
|
* @param ev The event emitter to read events from
|
|
10
19
|
* @param filename File to save to
|
|
11
20
|
*/
|
|
12
|
-
|
|
13
|
-
const oldEmit = ev.emit
|
|
21
|
+
const captureEventStream = (ev, filename) => {
|
|
22
|
+
const oldEmit = ev.emit
|
|
14
23
|
// write mutex so data is appended in order
|
|
15
|
-
const writeMutex = makeMutex()
|
|
24
|
+
const writeMutex = make_mutex_1.makeMutex()
|
|
16
25
|
// monkey patch eventemitter to capture all events
|
|
17
26
|
ev.emit = function (...args) {
|
|
18
|
-
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n'
|
|
19
|
-
const result = oldEmit.apply(ev, args)
|
|
27
|
+
const content = JSON.stringify({ timestamp: Date.now(), event: args[0], data: args[1] }) + '\n'
|
|
28
|
+
const result = oldEmit.apply(ev, args)
|
|
20
29
|
writeMutex.mutex(async () => {
|
|
21
|
-
await writeFile(filename, content, { flag: 'a' })
|
|
22
|
-
})
|
|
23
|
-
return result
|
|
24
|
-
}
|
|
25
|
-
}
|
|
30
|
+
await promises_1.writeFile(filename, content, { flag: 'a' })
|
|
31
|
+
})
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
/**
|
|
27
37
|
* Read event file and emit events from there
|
|
28
38
|
* @param filename filename containing event data
|
|
29
39
|
* @param delayIntervalMs delay between each event emit
|
|
30
40
|
*/
|
|
31
|
-
|
|
32
|
-
const ev = new
|
|
41
|
+
const readAndEmitEventStream = (filename, delayIntervalMs = 0) => {
|
|
42
|
+
const ev = new events_1.default()
|
|
33
43
|
const fireEvents = async () => {
|
|
34
44
|
// from: https://stackoverflow.com/questions/6156501/read-a-file-one-line-at-a-time-in-node-js
|
|
35
|
-
const fileStream = createReadStream(filename)
|
|
36
|
-
const rl = createInterface({
|
|
45
|
+
const fileStream = fs_1.createReadStream(filename)
|
|
46
|
+
const rl = readline_1.createInterface({
|
|
37
47
|
input: fileStream,
|
|
38
48
|
crlfDelay: Infinity
|
|
39
|
-
})
|
|
49
|
+
})
|
|
40
50
|
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
41
51
|
// ('\r\n') in input.txt as a single line break.
|
|
42
52
|
for await (const line of rl) {
|
|
43
53
|
if (line) {
|
|
44
|
-
const { event, data } = JSON.parse(line)
|
|
45
|
-
ev.emit(event, data)
|
|
46
|
-
delayIntervalMs &&
|
|
54
|
+
const { event, data } = JSON.parse(line)
|
|
55
|
+
ev.emit(event, data)
|
|
56
|
+
delayIntervalMs && await generics_1.delay(delayIntervalMs)
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
|
-
fileStream.close()
|
|
50
|
-
}
|
|
59
|
+
fileStream.close()
|
|
60
|
+
}
|
|
51
61
|
return {
|
|
52
62
|
ev,
|
|
53
63
|
task: fireEvents()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
captureEventStream,
|
|
69
|
+
readAndEmitEventStream
|
|
70
|
+
}
|
package/lib/Utils/business.d.ts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { CatalogCollection, OrderDetails, Product, ProductCreate, ProductUpdate, WAMediaUpload, WAMediaUploadFunction } from '../Types'
|
|
2
|
+
import { BinaryNode } from '../WABinary'
|
|
3
|
+
|
|
3
4
|
export declare const parseCatalogNode: (node: BinaryNode) => {
|
|
4
|
-
products: Product[]
|
|
5
|
-
nextPageCursor: string | undefined
|
|
6
|
-
}
|
|
5
|
+
products: Product[]
|
|
6
|
+
nextPageCursor: string | undefined
|
|
7
|
+
}
|
|
8
|
+
|
|
7
9
|
export declare const parseCollectionsNode: (node: BinaryNode) => {
|
|
8
|
-
collections: CatalogCollection[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
10
|
+
collections: CatalogCollection[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare const parseOrderDetailsNode: (node: BinaryNode) => OrderDetails
|
|
14
|
+
|
|
15
|
+
export declare const toProductNode: (productId: string | undefined, product: ProductCreate | ProductUpdate) => BinaryNode
|
|
16
|
+
|
|
17
|
+
export declare const parseProductNode: (productNode: BinaryNode) => Product
|
|
18
|
+
|
|
13
19
|
/**
|
|
14
20
|
* Uploads images not already uploaded to WA's servers
|
|
15
21
|
*/
|
|
16
|
-
export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T
|
|
22
|
+
export declare function uploadingNecessaryImagesOfProduct<T extends ProductUpdate | ProductCreate>(product: T, waUploadToServer: WAMediaUploadFunction, timeoutMs?: number): Promise<T>
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Uploads images not already uploaded to WA's servers
|
|
19
26
|
*/
|
|
20
27
|
export declare const uploadingNecessaryImages: (images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs?: number) => Promise<{
|
|
21
|
-
url: string
|
|
22
|
-
}[]
|
|
23
|
-
//# sourceMappingURL=business.d.ts.map
|
|
28
|
+
url: string
|
|
29
|
+
}[]>
|