yowtech 1.0.1-rv
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 +82 -0
- package/WAProto/W +1 -0
- package/WAProto/WAProto.proto +6035 -0
- package/WAProto/index.d.ts +15932 -0
- package/WAProto/index.js +115856 -0
- package/engine-requirements.js +13 -0
- package/lib/Defaults/D +1 -0
- package/lib/Defaults/index.d.ts +145 -0
- package/lib/Defaults/index.d.ts.map +1 -0
- package/lib/Defaults/index.js +152 -0
- package/lib/Defaults/index.js.map +1 -0
- package/lib/Signal/Group/G +1 -0
- package/lib/Signal/Group/ciphertext-message.d.ts +10 -0
- package/lib/Signal/Group/ciphertext-message.d.ts.map +1 -0
- package/lib/Signal/Group/ciphertext-message.js +12 -0
- package/lib/Signal/Group/ciphertext-message.js.map +1 -0
- package/lib/Signal/Group/group-session-builder.d.ts +8 -0
- package/lib/Signal/Group/group-session-builder.d.ts.map +1 -0
- package/lib/Signal/Group/group-session-builder.js +30 -0
- package/lib/Signal/Group/group-session-builder.js.map +1 -0
- package/lib/Signal/Group/group_cipher.d.ts +11 -0
- package/lib/Signal/Group/group_cipher.d.ts.map +1 -0
- package/lib/Signal/Group/group_cipher.js +82 -0
- package/lib/Signal/Group/group_cipher.js.map +1 -0
- package/lib/Signal/Group/index.d.ts +12 -0
- package/lib/Signal/Group/index.d.ts.map +1 -0
- package/lib/Signal/Group/index.js +12 -0
- package/lib/Signal/Group/index.js.map +1 -0
- package/lib/Signal/Group/keyhelper.d.ts +7 -0
- package/lib/Signal/Group/keyhelper.d.ts.map +1 -0
- package/lib/Signal/Group/keyhelper.js +18 -0
- package/lib/Signal/Group/keyhelper.js.map +1 -0
- package/lib/Signal/Group/sender-chain-key.d.ts +14 -0
- package/lib/Signal/Group/sender-chain-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-chain-key.js +26 -0
- package/lib/Signal/Group/sender-chain-key.js.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts +17 -0
- package/lib/Signal/Group/sender-key-distribution-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-distribution-message.js +63 -0
- package/lib/Signal/Group/sender-key-distribution-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-message.d.ts +19 -0
- package/lib/Signal/Group/sender-key-message.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-message.js +66 -0
- package/lib/Signal/Group/sender-key-message.js.map +1 -0
- package/lib/Signal/Group/sender-key-name.d.ts +12 -0
- package/lib/Signal/Group/sender-key-name.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-name.js +48 -0
- package/lib/Signal/Group/sender-key-name.js.map +1 -0
- package/lib/Signal/Group/sender-key-record.d.ts +13 -0
- package/lib/Signal/Group/sender-key-record.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-record.js +41 -0
- package/lib/Signal/Group/sender-key-record.js.map +1 -0
- package/lib/Signal/Group/sender-key-state.d.ts +17 -0
- package/lib/Signal/Group/sender-key-state.d.ts.map +1 -0
- package/lib/Signal/Group/sender-key-state.js +84 -0
- package/lib/Signal/Group/sender-key-state.js.map +1 -0
- package/lib/Signal/Group/sender-message-key.d.ts +12 -0
- package/lib/Signal/Group/sender-message-key.d.ts.map +1 -0
- package/lib/Signal/Group/sender-message-key.js +26 -0
- package/lib/Signal/Group/sender-message-key.js.map +1 -0
- package/lib/Signal/S +1 -0
- package/lib/Signal/libsignal.d.ts +55 -0
- package/lib/Signal/libsignal.d.ts.map +1 -0
- package/lib/Signal/libsignal.js +431 -0
- package/lib/Signal/libsignal.js.map +1 -0
- package/lib/Signal/lid-mapping.d.ts +21 -0
- package/lib/Signal/lid-mapping.d.ts.map +1 -0
- package/lib/Signal/lid-mapping.js +277 -0
- package/lib/Signal/lid-mapping.js.map +1 -0
- package/lib/Socket/Client/C +1 -0
- package/lib/Socket/Client/index.d.ts +3 -0
- package/lib/Socket/Client/index.d.ts.map +1 -0
- package/lib/Socket/Client/index.js +3 -0
- package/lib/Socket/Client/index.js.map +1 -0
- package/lib/Socket/Client/types.d.ts +6 -0
- package/lib/Socket/Client/types.d.ts.map +1 -0
- package/lib/Socket/Client/types.js +11 -0
- package/lib/Socket/Client/types.js.map +1 -0
- package/lib/Socket/Client/websocket.d.ts +13 -0
- package/lib/Socket/Client/websocket.d.ts.map +1 -0
- package/lib/Socket/Client/websocket.js +54 -0
- package/lib/Socket/Client/websocket.js.map +1 -0
- package/lib/Socket/business.d.ts +395 -0
- package/lib/Socket/business.d.ts.map +1 -0
- package/lib/Socket/business.js +380 -0
- package/lib/Socket/business.js.map +1 -0
- package/lib/Socket/chats.d.ts +144 -0
- package/lib/Socket/chats.d.ts.map +1 -0
- package/lib/Socket/chats.js +1219 -0
- package/lib/Socket/chats.js.map +1 -0
- package/lib/Socket/communities.d.ts +562 -0
- package/lib/Socket/communities.d.ts.map +1 -0
- package/lib/Socket/communities.js +432 -0
- package/lib/Socket/communities.js.map +1 -0
- package/lib/Socket/groups.d.ts +286 -0
- package/lib/Socket/groups.d.ts.map +1 -0
- package/lib/Socket/groups.js +348 -0
- package/lib/Socket/groups.js.map +1 -0
- package/lib/Socket/index.d.ts +530 -0
- package/lib/Socket/index.d.ts.map +1 -0
- package/lib/Socket/index.js +22 -0
- package/lib/Socket/index.js.map +1 -0
- package/lib/Socket/messages-recv.d.ts +334 -0
- package/lib/Socket/messages-recv.d.ts.map +1 -0
- package/lib/Socket/messages-recv.js +1797 -0
- package/lib/Socket/messages-recv.js.map +1 -0
- package/lib/Socket/messages-send.d.ts +330 -0
- package/lib/Socket/messages-send.d.ts.map +1 -0
- package/lib/Socket/messages-send.js +1396 -0
- package/lib/Socket/messages-send.js.map +1 -0
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.d.ts.map +1 -0
- package/lib/Socket/mex.js +42 -0
- package/lib/Socket/mex.js.map +1 -0
- package/lib/Socket/newsletter.d.ts +283 -0
- package/lib/Socket/newsletter.d.ts.map +1 -0
- package/lib/Socket/newsletter.js +226 -0
- package/lib/Socket/newsletter.js.map +1 -0
- package/lib/Socket/socket.d.ts +61 -0
- package/lib/Socket/socket.d.ts.map +1 -0
- package/lib/Socket/socket.js +970 -0
- package/lib/Socket/socket.js.map +1 -0
- package/lib/Store/S +1 -0
- 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 +2 -0
- package/lib/Types/Auth.d.ts.map +1 -0
- package/lib/Types/Auth.js +2 -0
- package/lib/Types/Auth.js.map +1 -0
- package/lib/Types/Bussines.d.ts +2 -0
- package/lib/Types/Bussines.d.ts.map +1 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Bussines.js.map +1 -0
- package/lib/Types/Call.d.ts +2 -0
- package/lib/Types/Call.d.ts.map +1 -0
- package/lib/Types/Call.js +2 -0
- package/lib/Types/Call.js.map +1 -0
- package/lib/Types/Chat.d.ts +2 -0
- package/lib/Types/Chat.d.ts.map +1 -0
- package/lib/Types/Chat.js +8 -0
- package/lib/Types/Chat.js.map +1 -0
- package/lib/Types/Contact.d.ts +2 -0
- package/lib/Types/Contact.d.ts.map +1 -0
- package/lib/Types/Contact.js +2 -0
- package/lib/Types/Contact.js.map +1 -0
- package/lib/Types/Events.d.ts +2 -0
- package/lib/Types/Events.d.ts.map +1 -0
- package/lib/Types/Events.js +2 -0
- package/lib/Types/Events.js.map +1 -0
- package/lib/Types/GroupMetadata.d.ts +2 -0
- package/lib/Types/GroupMetadata.d.ts.map +1 -0
- package/lib/Types/GroupMetadata.js +2 -0
- package/lib/Types/GroupMetadata.js.map +1 -0
- package/lib/Types/Label.d.ts +3 -0
- package/lib/Types/Label.d.ts.map +1 -0
- package/lib/Types/Label.js +25 -0
- package/lib/Types/Label.js.map +1 -0
- package/lib/Types/LabelAssociation.d.ts +3 -0
- package/lib/Types/LabelAssociation.d.ts.map +1 -0
- package/lib/Types/LabelAssociation.js +7 -0
- package/lib/Types/LabelAssociation.js.map +1 -0
- package/lib/Types/Message.d.ts +12 -0
- package/lib/Types/Message.d.ts.map +1 -0
- package/lib/Types/Message.js +18 -0
- package/lib/Types/Message.js.map +1 -0
- package/lib/Types/Mex.d.ts +3 -0
- package/lib/Types/Mex.d.ts.map +1 -0
- package/lib/Types/Mex.js +39 -0
- package/lib/Types/Mex.js.map +1 -0
- package/lib/Types/Product.d.ts +2 -0
- package/lib/Types/Product.d.ts.map +1 -0
- package/lib/Types/Product.js +2 -0
- package/lib/Types/Product.js.map +1 -0
- 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 +2 -0
- package/lib/Types/Signal.d.ts.map +1 -0
- package/lib/Types/Signal.js +2 -0
- package/lib/Types/Signal.js.map +1 -0
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Types/Socket.d.ts.map +1 -0
- package/lib/Types/Socket.js +2 -0
- package/lib/Types/Socket.js.map +1 -0
- package/lib/Types/State.d.ts +6 -0
- package/lib/Types/State.d.ts.map +1 -0
- package/lib/Types/State.js +56 -0
- package/lib/Types/State.js.map +1 -0
- package/lib/Types/T +1 -0
- package/lib/Types/USync.d.ts +2 -0
- package/lib/Types/USync.d.ts.map +1 -0
- package/lib/Types/USync.js +2 -0
- package/lib/Types/USync.js.map +1 -0
- package/lib/Types/index.d.ts +14 -0
- package/lib/Types/index.d.ts.map +1 -0
- package/lib/Types/index.js +26 -0
- package/lib/Types/index.js.map +1 -0
- package/lib/Utils/U +1 -0
- package/lib/Utils/advanced.js +89 -0
- package/lib/Utils/auth-utils.d.ts +58 -0
- package/lib/Utils/auth-utils.d.ts.map +1 -0
- package/lib/Utils/auth-utils.js +306 -0
- package/lib/Utils/auth-utils.js.map +1 -0
- package/lib/Utils/browser-utils.d.ts +10 -0
- package/lib/Utils/browser-utils.d.ts.map +1 -0
- package/lib/Utils/browser-utils.js +29 -0
- package/lib/Utils/browser-utils.js.map +1 -0
- package/lib/Utils/business.d.ts +50 -0
- package/lib/Utils/business.d.ts.map +1 -0
- package/lib/Utils/business.js +231 -0
- package/lib/Utils/business.js.map +1 -0
- package/lib/Utils/chat-utils.d.ts +409 -0
- package/lib/Utils/chat-utils.d.ts.map +1 -0
- package/lib/Utils/chat-utils.js +872 -0
- package/lib/Utils/chat-utils.js.map +1 -0
- package/lib/Utils/companion-reg-client-utils.d.ts +5 -0
- package/lib/Utils/companion-reg-client-utils.d.ts.map +1 -0
- package/lib/Utils/companion-reg-client-utils.js +40 -0
- package/lib/Utils/companion-reg-client-utils.js.map +1 -0
- package/lib/Utils/crypto.d.ts +40 -0
- package/lib/Utils/crypto.d.ts.map +1 -0
- package/lib/Utils/crypto.js +118 -0
- package/lib/Utils/crypto.js.map +1 -0
- package/lib/Utils/decode-wa-message.d.ts +84 -0
- package/lib/Utils/decode-wa-message.d.ts.map +1 -0
- package/lib/Utils/decode-wa-message.js +317 -0
- package/lib/Utils/decode-wa-message.js.map +1 -0
- package/lib/Utils/enchanted-utils.js +93 -0
- package/lib/Utils/event-buffer.d.ts +13 -0
- package/lib/Utils/event-buffer.d.ts.map +1 -0
- package/lib/Utils/event-buffer.js +622 -0
- package/lib/Utils/event-buffer.js.map +1 -0
- package/lib/Utils/generics.d.ts +64 -0
- package/lib/Utils/generics.d.ts.map +1 -0
- package/lib/Utils/generics.js +395 -0
- package/lib/Utils/generics.js.map +1 -0
- package/lib/Utils/history.d.ts +76 -0
- package/lib/Utils/history.d.ts.map +1 -0
- package/lib/Utils/history.js +134 -0
- package/lib/Utils/history.js.map +1 -0
- package/lib/Utils/identity-change-handler.d.ts +14 -0
- package/lib/Utils/identity-change-handler.d.ts.map +1 -0
- package/lib/Utils/identity-change-handler.js +50 -0
- package/lib/Utils/identity-change-handler.js.map +1 -0
- package/lib/Utils/index.d.ts +25 -0
- package/lib/Utils/index.d.ts.map +1 -0
- package/lib/Utils/index.js +43 -0
- package/lib/Utils/index.js.map +1 -0
- package/lib/Utils/link-preview.d.ts +13 -0
- package/lib/Utils/link-preview.d.ts.map +1 -0
- package/lib/Utils/link-preview.js +85 -0
- package/lib/Utils/link-preview.js.map +1 -0
- package/lib/Utils/logger.d.ts +3 -0
- package/lib/Utils/logger.d.ts.map +1 -0
- package/lib/Utils/logger.js +3 -0
- package/lib/Utils/logger.js.map +1 -0
- package/lib/Utils/lt-hash.d.ts +7 -0
- package/lib/Utils/lt-hash.d.ts.map +1 -0
- package/lib/Utils/lt-hash.js +8 -0
- package/lib/Utils/lt-hash.js.map +1 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/lib/Utils/make-mutex.d.ts.map +1 -0
- package/lib/Utils/make-mutex.js +33 -0
- package/lib/Utils/make-mutex.js.map +1 -0
- package/lib/Utils/message-builder.js +198 -0
- package/lib/Utils/message-cache.js +144 -0
- package/lib/Utils/message-download-pipeline.js +216 -0
- package/lib/Utils/message-error.js +176 -0
- package/lib/Utils/message-framework.js +364 -0
- package/lib/Utils/message-logger.js +63 -0
- package/lib/Utils/message-metrics.js +173 -0
- package/lib/Utils/message-pipeline.js +236 -0
- package/lib/Utils/message-plugin.js +229 -0
- package/lib/Utils/message-queue.js +266 -0
- package/lib/Utils/message-retry-adaptive.js +216 -0
- package/lib/Utils/message-retry-manager.d.ts +80 -0
- package/lib/Utils/message-retry-manager.d.ts.map +1 -0
- package/lib/Utils/message-retry-manager.js +265 -0
- package/lib/Utils/message-retry-manager.js.map +1 -0
- package/lib/Utils/message-upload-pipeline.js +244 -0
- package/lib/Utils/messages-media.d.ts +137 -0
- package/lib/Utils/messages-media.d.ts.map +1 -0
- package/lib/Utils/messages-media.js +843 -0
- package/lib/Utils/messages-media.js.map +1 -0
- package/lib/Utils/messages.d.ts +46 -0
- package/lib/Utils/messages.d.ts.map +1 -0
- package/lib/Utils/messages.js +1840 -0
- package/lib/Utils/messages.js.map +1 -0
- package/lib/Utils/noise-handler.d.ts +21 -0
- package/lib/Utils/noise-handler.d.ts.map +1 -0
- package/lib/Utils/noise-handler.js +201 -0
- package/lib/Utils/noise-handler.js.map +1 -0
- package/lib/Utils/offline-node-processor.d.ts +10 -0
- package/lib/Utils/offline-node-processor.d.ts.map +1 -0
- package/lib/Utils/offline-node-processor.js +40 -0
- package/lib/Utils/offline-node-processor.js.map +1 -0
- package/lib/Utils/pre-key-manager.d.ts +26 -0
- package/lib/Utils/pre-key-manager.d.ts.map +1 -0
- package/lib/Utils/pre-key-manager.js +106 -0
- package/lib/Utils/pre-key-manager.js.map +1 -0
- package/lib/Utils/process-message.d.ts +84 -0
- package/lib/Utils/process-message.d.ts.map +1 -0
- package/lib/Utils/process-message.js +749 -0
- package/lib/Utils/process-message.js.map +1 -0
- package/lib/Utils/reliability.js +70 -0
- package/lib/Utils/reporting-utils.d.ts +13 -0
- package/lib/Utils/reporting-utils.d.ts.map +1 -0
- package/lib/Utils/reporting-utils.js +258 -0
- package/lib/Utils/reporting-utils.js.map +1 -0
- 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 +83 -0
- package/lib/Utils/signal.d.ts.map +1 -0
- package/lib/Utils/signal.js +201 -0
- package/lib/Utils/signal.js.map +1 -0
- package/lib/Utils/stanza-ack.d.ts +17 -0
- package/lib/Utils/stanza-ack.d.ts.map +1 -0
- package/lib/Utils/stanza-ack.js +38 -0
- package/lib/Utils/stanza-ack.js.map +1 -0
- package/lib/Utils/sync-action-utils.d.ts +3 -0
- package/lib/Utils/sync-action-utils.d.ts.map +1 -0
- package/lib/Utils/sync-action-utils.js +49 -0
- package/lib/Utils/sync-action-utils.js.map +1 -0
- package/lib/Utils/tc-token-utils.d.ts +30 -0
- package/lib/Utils/tc-token-utils.d.ts.map +1 -0
- package/lib/Utils/tc-token-utils.js +164 -0
- package/lib/Utils/tc-token-utils.js.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-multi-file-auth-state.d.ts.map +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +121 -0
- package/lib/Utils/use-multi-file-auth-state.js.map +1 -0
- 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 +44 -0
- package/lib/Utils/validate-connection.d.ts.map +1 -0
- package/lib/Utils/validate-connection.js +210 -0
- package/lib/Utils/validate-connection.js.map +1 -0
- package/lib/WABinary/constants.d.ts +62 -0
- package/lib/WABinary/constants.d.ts.map +1 -0
- package/lib/WABinary/constants.js +1467 -0
- package/lib/WABinary/constants.js.map +1 -0
- package/lib/WABinary/decode.d.ts +10 -0
- package/lib/WABinary/decode.d.ts.map +1 -0
- package/lib/WABinary/decode.js +262 -0
- package/lib/WABinary/decode.js.map +1 -0
- package/lib/WABinary/enchanted-binary.js +38 -0
- package/lib/WABinary/encode.d.ts +3 -0
- package/lib/WABinary/encode.d.ts.map +1 -0
- package/lib/WABinary/encode.js +220 -0
- package/lib/WABinary/encode.js.map +1 -0
- package/lib/WABinary/generic-utils.d.ts +77 -0
- package/lib/WABinary/generic-utils.d.ts.map +1 -0
- package/lib/WABinary/generic-utils.js +226 -0
- package/lib/WABinary/generic-utils.js.map +1 -0
- package/lib/WABinary/index.d.ts +6 -0
- package/lib/WABinary/index.d.ts.map +1 -0
- package/lib/WABinary/index.js +8 -0
- package/lib/WABinary/index.js.map +1 -0
- package/lib/WABinary/jid-utils.d.ts +29 -0
- package/lib/WABinary/jid-utils.d.ts.map +1 -0
- package/lib/WABinary/jid-utils.js +96 -0
- package/lib/WABinary/jid-utils.js.map +1 -0
- package/lib/WABinary/types.d.ts +2 -0
- package/lib/WABinary/types.d.ts.map +1 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WABinary/types.js.map +1 -0
- package/lib/WABinary/w +1 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/BinaryInfo.d.ts.map +1 -0
- package/lib/WAM/BinaryInfo.js +10 -0
- package/lib/WAM/BinaryInfo.js.map +1 -0
- package/lib/WAM/constants.d.ts +34927 -0
- package/lib/WAM/constants.d.ts.map +1 -0
- package/lib/WAM/constants.js +22853 -0
- package/lib/WAM/constants.js.map +1 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/encode.d.ts.map +1 -0
- package/lib/WAM/encode.js +150 -0
- package/lib/WAM/encode.js.map +1 -0
- package/lib/WAM/index.d.ts +4 -0
- package/lib/WAM/index.d.ts.map +1 -0
- package/lib/WAM/index.js +4 -0
- package/lib/WAM/index.js.map +1 -0
- package/lib/WAM/w +1 -0
- package/lib/WAUSync/Protocols/P +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +37 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +52 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +23 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +54 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +27 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +13 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +38 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +10 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +25 -0
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +39 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +51 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +15 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +29 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js.map +1 -0
- package/lib/WAUSync/Protocols/index.d.ts +6 -0
- package/lib/WAUSync/Protocols/index.d.ts.map +1 -0
- package/lib/WAUSync/Protocols/index.js +6 -0
- package/lib/WAUSync/Protocols/index.js.map +1 -0
- package/lib/WAUSync/USyncQuery.d.ts +21 -0
- package/lib/WAUSync/USyncQuery.d.ts.map +1 -0
- package/lib/WAUSync/USyncQuery.js +98 -0
- package/lib/WAUSync/USyncQuery.js.map +1 -0
- package/lib/WAUSync/USyncUser.d.ts +17 -0
- package/lib/WAUSync/USyncUser.d.ts.map +1 -0
- package/lib/WAUSync/USyncUser.js +31 -0
- package/lib/WAUSync/USyncUser.js.map +1 -0
- package/lib/WAUSync/W +1 -0
- package/lib/WAUSync/index.d.ts +4 -0
- package/lib/WAUSync/index.d.ts.map +1 -0
- package/lib/WAUSync/index.js +4 -0
- package/lib/WAUSync/index.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error System — Standarisasi semua error pada pipeline send/receive.
|
|
3
|
+
* Setiap error memiliki: code, type, category, retryable, originalError, stack, metadata.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const ErrorCategory = Object.freeze({
|
|
7
|
+
VALIDATION: 'validation',
|
|
8
|
+
NETWORK: 'network',
|
|
9
|
+
ENCRYPTION: 'encryption',
|
|
10
|
+
MEDIA: 'media',
|
|
11
|
+
AUTH: 'auth',
|
|
12
|
+
RATE_LIMIT: 'rate_limit',
|
|
13
|
+
TIMEOUT: 'timeout',
|
|
14
|
+
QUEUE: 'queue',
|
|
15
|
+
PIPELINE: 'pipeline',
|
|
16
|
+
UNKNOWN: 'unknown',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const ErrorType = Object.freeze({
|
|
20
|
+
SEND_FAILED: 'SEND_FAILED',
|
|
21
|
+
RECEIVE_FAILED: 'RECEIVE_FAILED',
|
|
22
|
+
ENCODE_FAILED: 'ENCODE_FAILED',
|
|
23
|
+
DECODE_FAILED: 'DECODE_FAILED',
|
|
24
|
+
ENCRYPT_FAILED: 'ENCRYPT_FAILED',
|
|
25
|
+
DECRYPT_FAILED: 'DECRYPT_FAILED',
|
|
26
|
+
UPLOAD_FAILED: 'UPLOAD_FAILED',
|
|
27
|
+
DOWNLOAD_FAILED: 'DOWNLOAD_FAILED',
|
|
28
|
+
VALIDATION_FAILED: 'VALIDATION_FAILED',
|
|
29
|
+
QUEUE_OVERFLOW: 'QUEUE_OVERFLOW',
|
|
30
|
+
RETRY_EXHAUSTED: 'RETRY_EXHAUSTED',
|
|
31
|
+
CANCELLED: 'CANCELLED',
|
|
32
|
+
TIMEOUT: 'TIMEOUT',
|
|
33
|
+
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
34
|
+
RATE_LIMITED: 'RATE_LIMITED',
|
|
35
|
+
MEDIA_INVALID: 'MEDIA_INVALID',
|
|
36
|
+
MEDIA_TOO_LARGE: 'MEDIA_TOO_LARGE',
|
|
37
|
+
SESSION_INVALID: 'SESSION_INVALID',
|
|
38
|
+
UNKNOWN: 'UNKNOWN',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// ─────────────────────────────────────────────
|
|
42
|
+
// BASE PIPELINE ERROR CLASS
|
|
43
|
+
// ─────────────────────────────────────────────
|
|
44
|
+
|
|
45
|
+
export class PipelineError extends Error {
|
|
46
|
+
constructor(message, opts = {}) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = 'PipelineError';
|
|
49
|
+
this.code = opts.code || 'ERR_PIPELINE_UNKNOWN';
|
|
50
|
+
this.type = opts.type || ErrorType.UNKNOWN;
|
|
51
|
+
this.category = opts.category || ErrorCategory.UNKNOWN;
|
|
52
|
+
this.retryable = opts.retryable !== undefined ? opts.retryable : false;
|
|
53
|
+
this.originalError = opts.originalError || null;
|
|
54
|
+
this.metadata = opts.metadata || {};
|
|
55
|
+
this.statusCode = opts.statusCode || 500;
|
|
56
|
+
this.timestamp = Date.now();
|
|
57
|
+
if (opts.originalError?.stack) {
|
|
58
|
+
this.stack = `${this.stack}\nCaused by: ${opts.originalError.stack}`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
toJSON() {
|
|
62
|
+
return {
|
|
63
|
+
name: this.name, message: this.message, code: this.code,
|
|
64
|
+
type: this.type, category: this.category, retryable: this.retryable,
|
|
65
|
+
statusCode: this.statusCode, metadata: this.metadata, timestamp: this.timestamp,
|
|
66
|
+
originalError: this.originalError
|
|
67
|
+
? { message: this.originalError.message, name: this.originalError.name } : null,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export class SendError extends PipelineError {
|
|
73
|
+
constructor(message, opts = {}) {
|
|
74
|
+
super(message, { code: 'ERR_SEND', type: ErrorType.SEND_FAILED,
|
|
75
|
+
category: ErrorCategory.NETWORK, retryable: true, ...opts });
|
|
76
|
+
this.name = 'SendError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class ReceiveError extends PipelineError {
|
|
81
|
+
constructor(message, opts = {}) {
|
|
82
|
+
super(message, { code: 'ERR_RECEIVE', type: ErrorType.RECEIVE_FAILED,
|
|
83
|
+
category: ErrorCategory.NETWORK, retryable: false, ...opts });
|
|
84
|
+
this.name = 'ReceiveError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class EncodeError extends PipelineError {
|
|
89
|
+
constructor(message, opts = {}) {
|
|
90
|
+
super(message, { code: 'ERR_ENCODE', type: ErrorType.ENCODE_FAILED,
|
|
91
|
+
category: ErrorCategory.ENCRYPTION, retryable: false, ...opts });
|
|
92
|
+
this.name = 'EncodeError';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export class DecodeError extends PipelineError {
|
|
97
|
+
constructor(message, opts = {}) {
|
|
98
|
+
super(message, { code: 'ERR_DECODE', type: ErrorType.DECODE_FAILED,
|
|
99
|
+
category: ErrorCategory.ENCRYPTION, retryable: true, ...opts });
|
|
100
|
+
this.name = 'DecodeError';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class MediaUploadError extends PipelineError {
|
|
105
|
+
constructor(message, opts = {}) {
|
|
106
|
+
super(message, { code: 'ERR_MEDIA_UPLOAD', type: ErrorType.UPLOAD_FAILED,
|
|
107
|
+
category: ErrorCategory.MEDIA, retryable: true, ...opts });
|
|
108
|
+
this.name = 'MediaUploadError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class MediaDownloadError extends PipelineError {
|
|
113
|
+
constructor(message, opts = {}) {
|
|
114
|
+
super(message, { code: 'ERR_MEDIA_DOWNLOAD', type: ErrorType.DOWNLOAD_FAILED,
|
|
115
|
+
category: ErrorCategory.MEDIA, retryable: true, ...opts });
|
|
116
|
+
this.name = 'MediaDownloadError';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export class ValidationError extends PipelineError {
|
|
121
|
+
constructor(message, opts = {}) {
|
|
122
|
+
super(message, { code: 'ERR_VALIDATION', type: ErrorType.VALIDATION_FAILED,
|
|
123
|
+
category: ErrorCategory.VALIDATION, retryable: false, statusCode: 400, ...opts });
|
|
124
|
+
this.name = 'ValidationError';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export class RetryExhaustedError extends PipelineError {
|
|
129
|
+
constructor(message, opts = {}) {
|
|
130
|
+
super(message, { code: 'ERR_RETRY_EXHAUSTED', type: ErrorType.RETRY_EXHAUSTED,
|
|
131
|
+
category: ErrorCategory.NETWORK, retryable: false, ...opts });
|
|
132
|
+
this.name = 'RetryExhaustedError';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export class QueueOverflowError extends PipelineError {
|
|
137
|
+
constructor(message, opts = {}) {
|
|
138
|
+
super(message, { code: 'ERR_QUEUE_OVERFLOW', type: ErrorType.QUEUE_OVERFLOW,
|
|
139
|
+
category: ErrorCategory.QUEUE, retryable: true, statusCode: 429, ...opts });
|
|
140
|
+
this.name = 'QueueOverflowError';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class TimeoutError extends PipelineError {
|
|
145
|
+
constructor(message, opts = {}) {
|
|
146
|
+
super(message, { code: 'ERR_TIMEOUT', type: ErrorType.TIMEOUT,
|
|
147
|
+
category: ErrorCategory.TIMEOUT, retryable: true, statusCode: 408, ...opts });
|
|
148
|
+
this.name = 'TimeoutError';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export class RateLimitError extends PipelineError {
|
|
153
|
+
constructor(message, opts = {}) {
|
|
154
|
+
super(message, { code: 'ERR_RATE_LIMIT', type: ErrorType.RATE_LIMITED,
|
|
155
|
+
category: ErrorCategory.RATE_LIMIT, retryable: true, statusCode: 429, ...opts });
|
|
156
|
+
this.name = 'RateLimitError';
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Konversi error apapun menjadi PipelineError terstandarisasi.
|
|
162
|
+
*/
|
|
163
|
+
export function normalizeToPipelineError(err, defaultOpts = {}) {
|
|
164
|
+
if (err instanceof PipelineError) return err;
|
|
165
|
+
if (err?.isBoom) {
|
|
166
|
+
const statusCode = err.output?.statusCode || 500;
|
|
167
|
+
const retryable = statusCode >= 500 || statusCode === 429 || statusCode === 408;
|
|
168
|
+
return new PipelineError(err.message, {
|
|
169
|
+
code: `ERR_BOOM_${statusCode}`,
|
|
170
|
+
type: statusCode >= 500 ? ErrorType.SEND_FAILED : ErrorType.VALIDATION_FAILED,
|
|
171
|
+
category: statusCode >= 500 ? ErrorCategory.NETWORK : ErrorCategory.VALIDATION,
|
|
172
|
+
retryable, statusCode, originalError: err, metadata: err.data || {}, ...defaultOpts,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return new PipelineError(err?.message || 'Unknown error', { originalError: err, ...defaultOpts });
|
|
176
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MessageFramework — Entry point utama yang menggabungkan semua sistem:
|
|
3
|
+
* Pipeline, Hook, Queue, Cache, Metrics, Logger, Retry, Plugin, Builder.
|
|
4
|
+
*
|
|
5
|
+
* Digunakan oleh messages-send.js dan messages-recv.js sebagai fondasi framework.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { PipelineRegistry, HookSystem, createMessageContext, LifecycleEvents } from './message-pipeline.js';
|
|
9
|
+
import { PipelineLogger, pipelineLogger } from './message-logger.js';
|
|
10
|
+
import { MetricsRegistry, globalMetrics } from './message-metrics.js';
|
|
11
|
+
import { MessageQueue, QueueManager, globalQueueManager } from './message-queue.js';
|
|
12
|
+
import { CacheRegistry, globalCache } from './message-cache.js';
|
|
13
|
+
import { AdaptiveRetryManager, DEFAULT_SEND_POLICY, DEFAULT_MEDIA_POLICY } from './message-retry-adaptive.js';
|
|
14
|
+
import { PluginManager, globalPluginManager } from './message-plugin.js';
|
|
15
|
+
import { MessageBuilder, globalMessageBuilder, createBuildContext } from './message-builder.js';
|
|
16
|
+
import { UploadPipeline, globalUploadPipeline, createUploadContext } from './message-upload-pipeline.js';
|
|
17
|
+
import { DownloadPipeline, globalDownloadPipeline, createDownloadContext } from './message-download-pipeline.js';
|
|
18
|
+
import { normalizeToPipelineError } from './message-error.js';
|
|
19
|
+
|
|
20
|
+
// ─────────────────────────────────────────────
|
|
21
|
+
// FRAMEWORK CLASS
|
|
22
|
+
// ─────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export class MessageFramework {
|
|
25
|
+
/**
|
|
26
|
+
* @param {object} config — Baileys socket config
|
|
27
|
+
*/
|
|
28
|
+
constructor(config = {}) {
|
|
29
|
+
const logger = config.logger ?? null;
|
|
30
|
+
|
|
31
|
+
// ── Core Logger ───────────────────────────────────────────────────────
|
|
32
|
+
this.logger = new PipelineLogger({
|
|
33
|
+
logger,
|
|
34
|
+
prefix: '[protection]',
|
|
35
|
+
minLevel: config.frameworkLogLevel ?? 1, // DEBUG
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// ── Metrics ───────────────────────────────────────────────────────────
|
|
39
|
+
this.metrics = new MetricsRegistry();
|
|
40
|
+
|
|
41
|
+
// ── Cache ─────────────────────────────────────────────────────────────
|
|
42
|
+
this.cache = new CacheRegistry({ adapter: config.frameworkCacheAdapter });
|
|
43
|
+
|
|
44
|
+
// ── Hook + Pipeline ───────────────────────────────────────────────────
|
|
45
|
+
this.hooks = new HookSystem();
|
|
46
|
+
this.pipeline = new PipelineRegistry();
|
|
47
|
+
this.pipeline.hooks = this.hooks;
|
|
48
|
+
|
|
49
|
+
// ── Queue Manager ─────────────────────────────────────────────────────
|
|
50
|
+
this.queue = new QueueManager();
|
|
51
|
+
this.sendQueue = this.queue.getQueue('send', {
|
|
52
|
+
maxSize: config.sendQueueMaxSize ?? 10_000,
|
|
53
|
+
concurrency: config.sendQueueConcurrency ?? 5,
|
|
54
|
+
rateLimitPerSec: config.sendQueueRateLimit ?? 20,
|
|
55
|
+
rateLimitBurst: config.sendQueueBurst ?? 30,
|
|
56
|
+
deduplication: config.sendQueueDedup !== false,
|
|
57
|
+
onError: (err, item) => {
|
|
58
|
+
this.logger.error(`Queue send error [${item.id}]: ${err?.message}`, { err });
|
|
59
|
+
this.metrics.inc('errors.total');
|
|
60
|
+
},
|
|
61
|
+
onMetrics: (event, data) => {
|
|
62
|
+
if (event === 'enqueued') this.metrics.inc('queue.enqueued');
|
|
63
|
+
if (event === 'dequeued') this.metrics.inc('queue.dequeued');
|
|
64
|
+
if (event === 'dropped') this.metrics.inc('queue.dropped');
|
|
65
|
+
if (data?.waitMs !== undefined) this.metrics.observe('queue.wait_ms', data.waitMs);
|
|
66
|
+
if (data?.size !== undefined) this.metrics.set('queue.size', data.size);
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// ── Retry Manager ─────────────────────────────────────────────────────
|
|
71
|
+
this.retryManager = new AdaptiveRetryManager({
|
|
72
|
+
logger,
|
|
73
|
+
metrics: this.metrics,
|
|
74
|
+
hooks: this.hooks,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// ── Plugin Manager ────────────────────────────────────────────────────
|
|
78
|
+
this.plugins = new PluginManager({
|
|
79
|
+
logger,
|
|
80
|
+
hooks: this.hooks,
|
|
81
|
+
metrics: this.metrics,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// ── Message Builder ───────────────────────────────────────────────────
|
|
85
|
+
this.builder = new MessageBuilder({
|
|
86
|
+
logger,
|
|
87
|
+
hooks: this.hooks,
|
|
88
|
+
metrics: this.metrics,
|
|
89
|
+
plugins: this.plugins,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ── Upload Pipeline ───────────────────────────────────────────────────
|
|
93
|
+
this.uploadPipeline = new UploadPipeline({
|
|
94
|
+
logger,
|
|
95
|
+
hooks: this.hooks,
|
|
96
|
+
metrics: this.metrics,
|
|
97
|
+
cache: this.cache,
|
|
98
|
+
retryPolicy: config.mediaRetryPolicy ?? DEFAULT_MEDIA_POLICY,
|
|
99
|
+
timeoutMs: config.mediaUploadTimeoutMs ?? 120_000,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// ── Download Pipeline ─────────────────────────────────────────────────
|
|
103
|
+
this.downloadPipeline = new DownloadPipeline({
|
|
104
|
+
logger,
|
|
105
|
+
hooks: this.hooks,
|
|
106
|
+
metrics: this.metrics,
|
|
107
|
+
cache: this.cache,
|
|
108
|
+
retryPolicy: config.mediaRetryPolicy ?? DEFAULT_MEDIA_POLICY,
|
|
109
|
+
timeoutMs: config.mediaDownloadTimeoutMs ?? 60_000,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// ── Retry Policies ────────────────────────────────────────────────────
|
|
113
|
+
this.sendPolicy = config.sendRetryPolicy ?? DEFAULT_SEND_POLICY;
|
|
114
|
+
this.mediaPolicy = config.mediaRetryPolicy ?? DEFAULT_MEDIA_POLICY;
|
|
115
|
+
|
|
116
|
+
this._config = config;
|
|
117
|
+
this._attached = false;
|
|
118
|
+
this.socket = null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ─────────────────────────────────────────
|
|
122
|
+
// ATTACH / TEARDOWN
|
|
123
|
+
// ─────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Attach framework ke socket Baileys.
|
|
127
|
+
* Dipanggil dari makeMessagesSocket().
|
|
128
|
+
*
|
|
129
|
+
* @param {object} socket — partial atau full socket instance
|
|
130
|
+
*/
|
|
131
|
+
attach(socket) {
|
|
132
|
+
if (this._attached) return this;
|
|
133
|
+
this.socket = socket;
|
|
134
|
+
|
|
135
|
+
// Wire plugins
|
|
136
|
+
if (socket?.ev) {
|
|
137
|
+
this.plugins.attach(socket, this.pipeline);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Bridge framework logger ke socket logger
|
|
141
|
+
if (this._config.logger) {
|
|
142
|
+
this.logger.setCustomLogger((level, msg, data) => {
|
|
143
|
+
if (this._config.logger?.[level]) {
|
|
144
|
+
this._config.logger[level](data ?? {}, msg);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Wire events ke metrics
|
|
150
|
+
if (socket?.ev) {
|
|
151
|
+
socket.ev.on('messages.upsert', ({ messages, type }) => {
|
|
152
|
+
if (type === 'notify') {
|
|
153
|
+
this.metrics.inc('messages.received.total', messages?.length ?? 1);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
socket.ev.on('messages.update', (updates) => {
|
|
157
|
+
this.metrics.inc('messages.updated.total', updates?.length ?? 1);
|
|
158
|
+
});
|
|
159
|
+
socket.ev.on('connection.update', (update) => {
|
|
160
|
+
if (update.connection === 'open') this.metrics.gauge('connections.active').inc();
|
|
161
|
+
if (update.connection === 'close') this.metrics.gauge('connections.active').dec();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
this._attached = true;
|
|
166
|
+
this.logger.info('MessageFramework berhasil di-attach ke socket');
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Teardown — dipanggil saat socket ditutup.
|
|
172
|
+
*/
|
|
173
|
+
async teardown() {
|
|
174
|
+
try {
|
|
175
|
+
this.sendQueue?.stop();
|
|
176
|
+
this.queue?.stopAll();
|
|
177
|
+
await this.plugins?.uninstallAll?.();
|
|
178
|
+
this.hooks?.removeAll();
|
|
179
|
+
this._attached = false;
|
|
180
|
+
this.logger.info('MessageFramework di-teardown');
|
|
181
|
+
} catch (_) {}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ─────────────────────────────────────────
|
|
185
|
+
// CONTEXT FACTORIES
|
|
186
|
+
// ─────────────────────────────────────────
|
|
187
|
+
|
|
188
|
+
createContext(overrides = {}) {
|
|
189
|
+
return createMessageContext({ socket: this.socket, ...overrides });
|
|
190
|
+
}
|
|
191
|
+
createBuildContext(overrides = {}) { return createBuildContext(overrides); }
|
|
192
|
+
createUploadContext(overrides = {}) { return createUploadContext(overrides); }
|
|
193
|
+
createDownloadContext(overrides = {}) { return createDownloadContext(overrides); }
|
|
194
|
+
|
|
195
|
+
// ─────────────────────────────────────────
|
|
196
|
+
// PLUGIN / MIDDLEWARE / HOOK SHORTCUTS
|
|
197
|
+
// ─────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
/** Install plugin */
|
|
200
|
+
async use(plugin) { await this.plugins.install(plugin); return this; }
|
|
201
|
+
|
|
202
|
+
/** Daftarkan middleware pipeline */
|
|
203
|
+
middleware(pipelineName, fn, priority = 0) {
|
|
204
|
+
this.pipeline.use(pipelineName, fn, priority);
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Daftarkan lifecycle hook */
|
|
209
|
+
hook(event, handler) { this.hooks.on(event, handler); return this; }
|
|
210
|
+
|
|
211
|
+
// ─────────────────────────────────────────
|
|
212
|
+
// QUEUE SEND
|
|
213
|
+
// ─────────────────────────────────────────
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Tambahkan task ke send queue.
|
|
217
|
+
* @param {Function} sendFn — async () => result
|
|
218
|
+
* @param {object} opts — { priority, delayMs, dedupKey, jid }
|
|
219
|
+
*/
|
|
220
|
+
queueSend(sendFn, opts = {}) {
|
|
221
|
+
return this.sendQueue.enqueue(sendFn, opts);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ─────────────────────────────────────────
|
|
225
|
+
// METRICS
|
|
226
|
+
// ─────────────────────────────────────────
|
|
227
|
+
|
|
228
|
+
/** Ambil semua metrics */
|
|
229
|
+
getMetrics() {
|
|
230
|
+
return {
|
|
231
|
+
framework: this.metrics.getAll(),
|
|
232
|
+
queues: this.queue.getAllStats(),
|
|
233
|
+
cache: this.cache.stats,
|
|
234
|
+
retry: this.retryManager.getStats(),
|
|
235
|
+
plugins: this.plugins.list(),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// ─────────────────────────────────────────
|
|
240
|
+
// PIPELINE RUNNERS
|
|
241
|
+
// ─────────────────────────────────────────
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Jalankan full send pipeline: before → relay → after + hooks.
|
|
245
|
+
*/
|
|
246
|
+
async runSendPipeline(relayFn, ctx) {
|
|
247
|
+
const start = Date.now();
|
|
248
|
+
await this._emitHook(LifecycleEvents.SEND_START, ctx);
|
|
249
|
+
|
|
250
|
+
await this.pipeline.beforeSend.run(ctx, async () => {});
|
|
251
|
+
if (ctx.cancelled) {
|
|
252
|
+
this.logger.info(`[Framework] Send dibatalkan: ${ctx.jid}`);
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let result;
|
|
257
|
+
try {
|
|
258
|
+
result = await this.retryManager.run(
|
|
259
|
+
relayFn,
|
|
260
|
+
this.sendPolicy,
|
|
261
|
+
ctx.metadata?.msgId,
|
|
262
|
+
{ type: 'send', jid: ctx.jid }
|
|
263
|
+
);
|
|
264
|
+
this.metrics.inc('messages.sent.total');
|
|
265
|
+
this.metrics.observe('send.duration_ms', Date.now() - start);
|
|
266
|
+
ctx.result = result;
|
|
267
|
+
ctx.timestamps.sent = Date.now();
|
|
268
|
+
} catch (err) {
|
|
269
|
+
ctx.error = normalizeToPipelineError(err);
|
|
270
|
+
this.metrics.inc('messages.failed.total');
|
|
271
|
+
this.metrics.inc('errors.total');
|
|
272
|
+
await this._emitHook(LifecycleEvents.SEND_FAILED, ctx);
|
|
273
|
+
throw ctx.error;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
await this.pipeline.afterSend.run(ctx, async () => {});
|
|
277
|
+
await this._emitHook(LifecycleEvents.SEND_FINISH, ctx);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Jalankan full receive pipeline.
|
|
283
|
+
*/
|
|
284
|
+
async runReceivePipeline(processFn, ctx) {
|
|
285
|
+
const start = Date.now();
|
|
286
|
+
await this._emitHook(LifecycleEvents.MESSAGE_RECEIVE, ctx);
|
|
287
|
+
|
|
288
|
+
await this.pipeline.beforeReceive.run(ctx, async () => {});
|
|
289
|
+
if (ctx.cancelled) return null;
|
|
290
|
+
|
|
291
|
+
let result;
|
|
292
|
+
try {
|
|
293
|
+
result = await processFn();
|
|
294
|
+
this.metrics.inc('messages.received.total');
|
|
295
|
+
this.metrics.observe('receive.duration_ms', Date.now() - start);
|
|
296
|
+
ctx.result = result;
|
|
297
|
+
ctx.timestamps.received = Date.now();
|
|
298
|
+
} catch (err) {
|
|
299
|
+
ctx.error = normalizeToPipelineError(err);
|
|
300
|
+
this.metrics.inc('errors.total');
|
|
301
|
+
throw ctx.error;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
await this.pipeline.afterReceive.run(ctx, async () => {});
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Jalankan full decode pipeline.
|
|
310
|
+
*/
|
|
311
|
+
async runDecodePipeline(decodeFn, ctx) {
|
|
312
|
+
const start = Date.now();
|
|
313
|
+
await this._emitHook(LifecycleEvents.MESSAGE_DECODE, ctx);
|
|
314
|
+
|
|
315
|
+
await this.pipeline.beforeDecode.run(ctx, async () => {});
|
|
316
|
+
if (ctx.cancelled) return null;
|
|
317
|
+
|
|
318
|
+
let result;
|
|
319
|
+
try {
|
|
320
|
+
result = await decodeFn();
|
|
321
|
+
this.metrics.inc('decode.total');
|
|
322
|
+
this.metrics.observe('decode.duration_ms', Date.now() - start);
|
|
323
|
+
ctx.timestamps.decoded = Date.now();
|
|
324
|
+
} catch (err) {
|
|
325
|
+
ctx.error = normalizeToPipelineError(err);
|
|
326
|
+
this.metrics.inc('errors.total');
|
|
327
|
+
throw ctx.error;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
await this.pipeline.afterDecode.run(ctx, async () => {});
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ── Internal ──────────────────────────────
|
|
335
|
+
|
|
336
|
+
async _emitHook(event, ctx) {
|
|
337
|
+
if (this.hooks) {
|
|
338
|
+
try { await this.hooks.emit(event, ctx); } catch (_) {}
|
|
339
|
+
}
|
|
340
|
+
this.metrics.inc('hooks.fired');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ─────────────────────────────────────────────
|
|
345
|
+
// FACTORY
|
|
346
|
+
// ─────────────────────────────────────────────
|
|
347
|
+
|
|
348
|
+
export function createMessageFramework(config) {
|
|
349
|
+
return new MessageFramework(config);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// Re-export semua subsystems untuk akses langsung
|
|
353
|
+
export {
|
|
354
|
+
PipelineRegistry, HookSystem, createMessageContext, LifecycleEvents,
|
|
355
|
+
PipelineLogger, pipelineLogger,
|
|
356
|
+
MetricsRegistry, globalMetrics,
|
|
357
|
+
MessageQueue, QueueManager, globalQueueManager,
|
|
358
|
+
CacheRegistry, globalCache,
|
|
359
|
+
AdaptiveRetryManager, DEFAULT_SEND_POLICY, DEFAULT_MEDIA_POLICY,
|
|
360
|
+
PluginManager, globalPluginManager,
|
|
361
|
+
MessageBuilder, globalMessageBuilder, createBuildContext,
|
|
362
|
+
UploadPipeline, globalUploadPipeline, createUploadContext,
|
|
363
|
+
DownloadPipeline, globalDownloadPipeline, createDownloadContext,
|
|
364
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger Integration — Internal logger dengan level lengkap dan custom logger support.
|
|
3
|
+
* Level: trace(0) debug(1) info(2) warn(3) error(4) fatal(5)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const LogLevel = Object.freeze({
|
|
7
|
+
TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, FATAL: 5, SILENT: 99,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const LEVEL_NAMES = { 0:'trace', 1:'debug', 2:'info', 3:'warn', 4:'error', 5:'fatal' };
|
|
11
|
+
|
|
12
|
+
export class PipelineLogger {
|
|
13
|
+
constructor(opts = {}) {
|
|
14
|
+
this._logger = opts.logger || null;
|
|
15
|
+
this._prefix = opts.prefix || '[Pipeline]';
|
|
16
|
+
this._minLevel = opts.minLevel !== undefined ? opts.minLevel : LogLevel.DEBUG;
|
|
17
|
+
this._customFn = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setCustomLogger(fn) {
|
|
21
|
+
if (typeof fn !== 'function') throw new TypeError('Custom logger harus berupa function');
|
|
22
|
+
this._customFn = fn;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setLevel(level) { this._minLevel = level; return this; }
|
|
27
|
+
|
|
28
|
+
_log(level, msg, data) {
|
|
29
|
+
if (level < this._minLevel) return;
|
|
30
|
+
const lvName = LEVEL_NAMES[level] || 'debug';
|
|
31
|
+
const full = `${this._prefix} ${msg}`;
|
|
32
|
+
|
|
33
|
+
if (this._customFn) {
|
|
34
|
+
try { this._customFn(lvName, full, data); } catch (_) {}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (this._logger && typeof this._logger[lvName] === 'function') {
|
|
38
|
+
data !== undefined ? this._logger[lvName](data, full) : this._logger[lvName](full);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const out = data !== undefined ? [full, data] : [full];
|
|
42
|
+
level >= LogLevel.ERROR ? console.error(...out)
|
|
43
|
+
: level >= LogLevel.WARN ? console.warn(...out)
|
|
44
|
+
: console.log(...out);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
trace(msg, data) { this._log(LogLevel.TRACE, msg, data); }
|
|
48
|
+
debug(msg, data) { this._log(LogLevel.DEBUG, msg, data); }
|
|
49
|
+
info (msg, data) { this._log(LogLevel.INFO, msg, data); }
|
|
50
|
+
warn (msg, data) { this._log(LogLevel.WARN, msg, data); }
|
|
51
|
+
error(msg, data) { this._log(LogLevel.ERROR, msg, data); }
|
|
52
|
+
fatal(msg, data) { this._log(LogLevel.FATAL, msg, data); }
|
|
53
|
+
|
|
54
|
+
child(prefix) {
|
|
55
|
+
return new PipelineLogger({
|
|
56
|
+
logger: this._logger,
|
|
57
|
+
prefix: `${this._prefix}:${prefix}`,
|
|
58
|
+
minLevel: this._minLevel,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const pipelineLogger = new PipelineLogger({ prefix: '[protection]' });
|