waton 0.1.0__tar.gz

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.
Files changed (94) hide show
  1. waton-0.1.0/.claude/settings.local.json +15 -0
  2. waton-0.1.0/.gitignore +27 -0
  3. waton-0.1.0/CHANGELOG.md +45 -0
  4. waton-0.1.0/Cargo.lock +1523 -0
  5. waton-0.1.0/Cargo.toml +29 -0
  6. waton-0.1.0/PKG-INFO +189 -0
  7. waton-0.1.0/README.md +167 -0
  8. waton-0.1.0/docs/plans/2025-02-27-multi-device-query.md +325 -0
  9. waton-0.1.0/docs/plans/2026-02-26-pywa-implementation.md +580 -0
  10. waton-0.1.0/docs/plans/2026-02-27-receive-messages.md +266 -0
  11. waton-0.1.0/examples/basic_bot.py +34 -0
  12. waton-0.1.0/examples/cli_chat.py +96 -0
  13. waton-0.1.0/examples/live_connect.py +127 -0
  14. waton-0.1.0/pyproject.toml +40 -0
  15. waton-0.1.0/pyrightconfig.json +6 -0
  16. waton-0.1.0/rename_script.py +27 -0
  17. waton-0.1.0/ruff.toml +9 -0
  18. waton-0.1.0/rust/errors.txt +193 -0
  19. waton-0.1.0/rust/full_errors.txt +23 -0
  20. waton-0.1.0/rust/src/aes_gcm.rs +57 -0
  21. waton-0.1.0/rust/src/curve.rs +131 -0
  22. waton-0.1.0/rust/src/hkdf_utils.rs +12 -0
  23. waton-0.1.0/rust/src/hmac_utils.rs +16 -0
  24. waton-0.1.0/rust/src/lib.rs +264 -0
  25. waton-0.1.0/rust/src/signal.rs +408 -0
  26. waton-0.1.0/test_out.txt +0 -0
  27. waton-0.1.0/tests/golden/test_codec_golden.py +37 -0
  28. waton-0.1.0/tests/golden/test_golden_codec.py +13 -0
  29. waton-0.1.0/tests/integration/test_whatsapp_connection.py +29 -0
  30. waton-0.1.0/tests/unit/test_app.py +84 -0
  31. waton-0.1.0/tests/unit/test_auth.py +28 -0
  32. waton-0.1.0/tests/unit/test_binary_codec.py +55 -0
  33. waton-0.1.0/tests/unit/test_chats.py +51 -0
  34. waton-0.1.0/tests/unit/test_client.py +195 -0
  35. waton-0.1.0/tests/unit/test_crypto.py +53 -0
  36. waton-0.1.0/tests/unit/test_filters.py +27 -0
  37. waton-0.1.0/tests/unit/test_groups.py +47 -0
  38. waton-0.1.0/tests/unit/test_jid.py +46 -0
  39. waton-0.1.0/tests/unit/test_messages.py +295 -0
  40. waton-0.1.0/tests/unit/test_noise.py +49 -0
  41. waton-0.1.0/tests/unit/test_protobuf_wire.py +56 -0
  42. waton-0.1.0/tests/unit/test_rust_crypto.py +7 -0
  43. waton-0.1.0/tests/unit/test_signal.py +219 -0
  44. waton-0.1.0/tests/unit/test_storage.py +69 -0
  45. waton-0.1.0/tests/unit/test_websocket.py +58 -0
  46. waton-0.1.0/waton/__init__.py +62 -0
  47. waton-0.1.0/waton/app/__init__.py +6 -0
  48. waton-0.1.0/waton/app/app.py +116 -0
  49. waton-0.1.0/waton/app/context.py +48 -0
  50. waton-0.1.0/waton/app/filters.py +40 -0
  51. waton-0.1.0/waton/app/middleware.py +34 -0
  52. waton-0.1.0/waton/app/router.py +43 -0
  53. waton-0.1.0/waton/client/__init__.py +5 -0
  54. waton-0.1.0/waton/client/chats.py +44 -0
  55. waton-0.1.0/waton/client/client.py +623 -0
  56. waton-0.1.0/waton/client/communities.py +47 -0
  57. waton-0.1.0/waton/client/groups.py +50 -0
  58. waton-0.1.0/waton/client/media.py +70 -0
  59. waton-0.1.0/waton/client/messages.py +305 -0
  60. waton-0.1.0/waton/client/newsletter.py +49 -0
  61. waton-0.1.0/waton/client/presence.py +25 -0
  62. waton-0.1.0/waton/client/usync.py +147 -0
  63. waton-0.1.0/waton/core/__init__.py +33 -0
  64. waton-0.1.0/waton/core/entities.py +37 -0
  65. waton-0.1.0/waton/core/errors.py +26 -0
  66. waton-0.1.0/waton/core/events.py +17 -0
  67. waton-0.1.0/waton/core/jid.py +69 -0
  68. waton-0.1.0/waton/defaults/__init__.py +5 -0
  69. waton-0.1.0/waton/defaults/config.py +30 -0
  70. waton-0.1.0/waton/infra/logger.py +31 -0
  71. waton-0.1.0/waton/infra/storage_json.py +194 -0
  72. waton-0.1.0/waton/infra/storage_sqlite.py +232 -0
  73. waton-0.1.0/waton/infra/websocket.py +82 -0
  74. waton-0.1.0/waton/protocol/__init__.py +7 -0
  75. waton-0.1.0/waton/protocol/binary_codec.py +364 -0
  76. waton-0.1.0/waton/protocol/binary_node.py +12 -0
  77. waton-0.1.0/waton/protocol/constants.py +1305 -0
  78. waton-0.1.0/waton/protocol/frame_codec.py +30 -0
  79. waton-0.1.0/waton/protocol/group_cipher.py +41 -0
  80. waton-0.1.0/waton/protocol/noise_handler.py +182 -0
  81. waton-0.1.0/waton/protocol/protobuf/WAProto.proto +5479 -0
  82. waton-0.1.0/waton/protocol/protobuf/WAProto_pb2.py +151 -0
  83. waton-0.1.0/waton/protocol/protobuf/__init__.py +67 -0
  84. waton-0.1.0/waton/protocol/protobuf/wire.py +543 -0
  85. waton-0.1.0/waton/protocol/signal_repo.py +238 -0
  86. waton-0.1.0/waton/utils/auth.py +96 -0
  87. waton-0.1.0/waton/utils/chat_utils.py +20 -0
  88. waton-0.1.0/waton/utils/crypto.py +170 -0
  89. waton-0.1.0/waton/utils/event_buffer.py +32 -0
  90. waton-0.1.0/waton/utils/generics.py +26 -0
  91. waton-0.1.0/waton/utils/lt_hash.py +37 -0
  92. waton-0.1.0/waton/utils/media_utils.py +16 -0
  93. waton-0.1.0/waton/utils/message_utils.py +36 -0
  94. waton-0.1.0/waton/utils/process_message.py +53 -0
@@ -0,0 +1,15 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(python -m pytest tests/unit/test_messages.py -v)",
5
+ "Bash(git init)",
6
+ "Bash(git remote add origin https://github.com/kaivyy/pywa.git)",
7
+ "Bash(git add .gitignore CHANGELOG.md Cargo.lock Cargo.toml README.md docs/ examples/ pyproject.toml pyrightconfig.json pywa/ ruff.toml rust/ tests/)",
8
+ "Bash(git commit -m \"$\\(cat <<''EOF''\nInitial release: PyWA - Python WhatsApp Web Multi-Device Library\n\n- Pure Python WhatsApp Web client with Rust crypto backend\n- Multi-device support with USync device query\n- Signal Protocol encryption \\(E2EE\\)\n- SQLite session storage\n- Async/await API\n\nFeatures:\n- QR code pairing\n- Send/receive text messages\n- Multi-device message routing\n- Session persistence\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
9
+ "Bash(git branch -M main)",
10
+ "Bash(git push -u https://kaivyy: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@github.com/kaivyy/pywa.git main)",
11
+ "Bash(git add README.md)",
12
+ "Bash(git commit -m \"$\\(cat <<''EOF''\ndocs: Improve README with comprehensive documentation\n\n- Add badges \\(Python version, License\\)\n- Add Why PyWA section with key benefits\n- Add Quick Start code example\n- Add Architecture diagram\n- Add detailed comparison table vs Baileys\n- Add Contributing section\n- Add Requirements and Disclaimer\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")"
13
+ ]
14
+ }
15
+ }
waton-0.1.0/.gitignore ADDED
@@ -0,0 +1,27 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ target/
8
+ .venv/
9
+ *.so
10
+ *.dll
11
+ *.pyd
12
+ .ruff_cache/
13
+ .pytest_cache/
14
+ .tmp-*/
15
+ *.db
16
+ *.log
17
+ debug.txt
18
+ out.txt
19
+ out2.txt
20
+ err.txt
21
+ pytest_out.txt
22
+ pytest_err.log
23
+ pytest.log
24
+ convert_constants.py
25
+ extract.js
26
+ .tmp-curve25519-index.js
27
+ howtouse.md
@@ -0,0 +1,45 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+ - **Multi-device query support**: Messages are now encrypted and sent to ALL devices
12
+ of the recipient (phone, WhatsApp Web, linked devices) via USync device query,
13
+ fixing the issue where messages were ACKed by server but never received
14
+ - **Incoming Message Decryption**: The app now successfully decrypts incoming `pkmsg` and `msg` E2E E2E (End-to-End) encrypted nodes inside the Signal Protocol.
15
+ - **Interactive CLI Chat (`cli_chat.py`)**: Added an interactive terminal application `examples/cli_chat.py` to test receiving and sending messages directly from the terminal.
16
+ - **High-Level App Parser Integration**: The `@app.message()` router now seamlessly unwraps `<enc>` message nodes and yields decrypted `Message` objects.
17
+ - New `waton/client/usync.py` module with `USyncQuery` class for querying device lists
18
+ - Real Rust-backed Signal helper integration (`wa-rs-libsignal`) for session bootstrap
19
+ and session encryption
20
+ - `send_text` E2E relay flow: device key fetch (`iq encrypt`), session injection, per-device
21
+ encrypted participant fanout, and `device-identity` inclusion for `pkmsg`
22
+ - Minimal WA protobuf wire serializer used for outgoing message payloads
23
+ - Runtime guidance for wheel-first installation (end users do not need Rust toolchain)
24
+
25
+ ### Changed
26
+ - Architecture remains standalone `waton` (Python API), with Rust used only as internal
27
+ performance/crypto helper
28
+ - No runtime dependency on Node.js/Baileys wrapper layers
29
+
30
+ ### Fixed
31
+ - **PKCS#7 Payload Padding**: Protobuf message payloads are now padded with 1-16 random bytes
32
+ prior to encryption, fixing Server Error 479 (`Invalid Format`).
33
+ - **Exact Sender Device Filtering**: `send_text` now strictly filters out the exact sending device
34
+ using normalized session keys to avoid Error 479 (`Invalid Receiver`) when the server
35
+ detects a client sending an enc payload to itself.
36
+ - **AD_JID encoding for multi-device**: Device-specific JIDs (`user:device@server`) are
37
+ now correctly encoded as AD_JID (tag 247) in the binary codec, instead of mangled JID_PAIR.
38
+ This was preventing multi-device messages from reaching the server correctly.
39
+ - Server reject/disconnect on message send (`ack error 479`) by replacing stub relay path
40
+ with encrypted Signal relay
41
+ - Invalid JSON-based WAProto shim replaced with binary protobuf wire implementation
42
+
43
+ ### Docs
44
+ - Added installation guidance differentiating end-user install (wheel, no Rust) vs source
45
+ contributor setup (requires Rust + maturin)