Benjamin-Loison / matrix-commander

simple but convenient CLI-based Matrix client app for sending and receiving
GNU General Public License v3.0
0 stars 0 forks source link

How to get session name, ID and key? #20

Open Benjamin-Loison opened 3 months ago

Benjamin-Loison commented 3 months ago

image

matrix-commander --get-devices

return all devices, not the one we are using.

Related to #18.

+65

Benjamin-Loison commented 2 months ago

Related to matrix-commander/pull/179.

grep -rw --include=*.py devices
matrix_commander/matrix_commander.py:                        "Verify with other devices or hit Control-C to "   matrix_commander/matrix_commander.py:    """List device of account while already logged in."""
matrix_commander/matrix_commander.py:    resp = await client.devices()
matrix_commander/matrix_commander.py:            "E180: " f"devices failed with {privacy_filter(str(resp))}"
matrix_commander/matrix_commander.py:        gs.log.debug(f"devices successful with {privacy_filter(str(resp))}")                                                       matrix_commander/matrix_commander.py:        for rr in resp.devices:                                            matrix_commander/matrix_commander.py:            f"Failed to delete devices because --password was not set. "   matrix_commander/matrix_commander.py:    devices = gs.pa.delete_device
matrix_commander/matrix_commander.py:        f"About to delete devices {devices} for user {user_id} "
matrix_commander/matrix_commander.py:    resp = await client.delete_devices(devices, auth)
matrix_commander/matrix_commander.py:            f"Failed to delete devices {devices} for user {user_id} "
matrix_commander/matrix_commander.py:            f"Failed to delete devices {devices} for user {user_id} due to "                                                       matrix_commander/matrix_commander.py:            f"Successfully deleted devices {devices} for user {user_id}."  matrix_commander/matrix_commander.py:        if gs.pa.devices:                                                  matrix_commander/matrix_commander.py:    """Log out one or all devices from Matrix server."""
matrix_commander/matrix_commander.py:            gs.log.debug(f"--logout has chosen to log out devices {device}")
matrix_commander/matrix_commander.py:        or gs.pa.devices
matrix_commander/matrix_commander.py:        "verification between two devices of the *same* user. For that, "
matrix_commander/matrix_commander.py:        "You should now be verified across all devices and across all users.",
matrix_commander/matrix_commander.py:        "Details:: Logout this or all devices from the Matrix homeserver. "
matrix_commander/matrix_commander.py:        "If you choose 'all', all devices of the user used by "
matrix_commander/matrix_commander.py:        "differentdevices and users.",
matrix_commander/matrix_commander.py:        "--devices",
matrix_commander/matrix_commander.py:        "--get-devices",  # alias, cause --deviced is very similar to --device
matrix_commander/matrix_commander.py:        help="Print the list of devices. "
matrix_commander/matrix_commander.py:        help=f"Delete one or multiple devices. "
matrix_commander/matrix_commander.py:        "Details:: By default devices belonging "
matrix_commander/matrix_commander.py:        f"to {PROG_WITHOUT_EXT} will be deleted. If the devices belong "
matrix_commander/matrix_commander.py:        "--device",  # do not confuse with --devices
matrix_commander/matrix_commander.py:        "Multiple devices (with different device id) may have the same device "
matrix_commander/matrix_commander.py:        "differentdevices if desired.",
matrix_commander/matrix_commander.py:<--devices,> <--get-devices>
matrix_commander/matrix_commander.py:Print the list of devices.
matrix_commander/matrix_commander.py:Delete one or multiple devices.
matrix_commander/matrix_commander.py:            "to verify devices. "
matrix_commander/matrix_commander.py:            "devices, etc. It can send one or multiple message to one or "

matrix-commander/blob/078da5f16c9b94893939ad19a21677f84a8625f9/matrix_commander/matrix_commander.py#L299

matrix-commander/blob/078da5f16c9b94893939ad19a21677f84a8625f9/matrix_commander/matrix_commander.py#L51

matrix-commander/blob/078da5f16c9b94893939ad19a21677f84a8625f9/requirements.txt#L9

https://pypi.org/project/matrix-nio/

matrix-nio

https://matrix-nio.readthedocs.io/en/latest/#api-documentation

Benjamin-Loison commented 2 months ago

https://matrix-nio.readthedocs.io/en/latest/nio.html#nio.Api.devices

matrix nio get current device results of DuckDuckGo and Google do not help much.

Benjamin-Loison commented 2 months ago

Both

gs.log.error(f'{client.device_id=}')

and

jq '.device_id' ~/.config/matrix-commander/credentials.json

work fine.

~/.config/matrix-commander/credentials.json:

{
    "homeserver": "https://matrix.org",
    "device_id": "CENSORED",
    "user_id": "@CENSORED:matrix.org",
    "room_id": "!CENSORED:matrix.org",
    "access_token": "CENSORED"
}
Benjamin-Loison commented 2 months ago

Session id is not the device id.

Benjamin-Loison commented 2 months ago

image

Benjamin-Loison commented 2 months ago

When searching session in matrix-commander/issues relevant issues are:

In matrix-commander-rs/issues there are no relevant issues, without filtering with session, according to their titles.

Benjamin-Loison commented 1 month ago

When log out of https://app.element.io there seems to be an interesting prompt.

Benjamin-Loison commented 2 weeks ago

Related to commit/1470570846f66b6c590b22d56ce9e8dda379fe30.

hostname
overclock3000
whoami
benjamin
matrix-commander -v
  _|      _|      _|_|_|    _|       matrix-commander: 7.7.0 2024-09-04
  _|_|  _|_|    _|            _|     a Matrix CLI client
  _|  _|  _|    _|              _|   enjoy and submit PRs
  _|      _|    _|            _|     matrix-nio: 0.25.0
  _|      _|      _|_|_|    _|       Python: 3.11.2
matrix-commander --verify emojireq
2024-09-20 19:25:47,254:    ERROR: matrix-commander: E240: For --verify manual and --verify emojireq a device must be specified with --device.
2024-09-20 19:25:47,255:     INFO: matrix-commander: 1 error and 0 warnings occurred.
matrix-commander -h
Output: ``` Welcome to matrix-commander, a Matrix CLI client. matrix-commander supports these arguments: --usage Print usage. -h, --help Print help. --manual Print manual. --readme Print README.md file. -d, --debug Print debug information. --log-level DEBUG|INFO|WARNING|ERROR|CRITICAL [DEBUG|INFO|WARNING|ERROR|CRITICAL ...] Set the log level(s). --verbose Set the verbosity level. --login PASSWORD|SSO Login to and authenticate with the Matrix homeserver. --verify [EMOJI] Perform verification. --logout ME|ALL Logout. -c CREDENTIALS_FILE, --credentials CREDENTIALS_FILE Specify location of credentials file. -s STORE_DIRECTORY, --store STORE_DIRECTORY Specify location of store directory. -r ROOM [ROOM ...], --room ROOM [ROOM ...] Specify one or multiple rooms. --room-default DEFAULT_ROOM Specify the default room at --login. --room-create ROOM_ALIAS [ROOM_ALIAS ...] Create one or multiple rooms for given alias(es). --room-dm-create USER [USER ...] Create one or multiple DM rooms with the specified users. --room-dm-create-allow-duplicates Allow creating duplicate DM rooms. --room-join ROOM [ROOM ...] Join one room or multiple rooms. --room-leave ROOM [ROOM ...] Leave one room or multiple rooms. --room-forget ROOM [ROOM ...] Forget one room or multiple rooms. --room-invite ROOM [ROOM ...] Invite one ore more users to join one or more rooms. --room-ban ROOM [ROOM ...] Ban one ore more users from one or more rooms. --room-unban ROOM [ROOM ...] Unban one ore more users from one or more rooms. --room-kick ROOM [ROOM ...] Kick one ore more users from one or more rooms. -u USER [USER ...], --user USER [USER ...] Specify one or multiple users. --user-login USER Specify user for --login. --name ROOM_NAME [ROOM_NAME ...] Specify one or multiple room names. --topic ROOM_TOPIC [ROOM_TOPIC ...] Specify one or multiple room topics. --alias ROOM_ALIAS [ROOM_ALIAS ...] Specify one or multiple room aliases. -m TEXT [TEXT ...], --message TEXT [TEXT ...] Send one or multiple text messages. -i IMAGE_FILE [IMAGE_FILE ...], -- image IMAGE_FILE [IMAGE_FILE ...] Send one or multiple image files. -a AUDIO_FILE [AUDIO_FILE ...], -- audio AUDIO_FILE [AUDIO_FILE ...] Send one or multiple audio files. -f FILE [FILE ...], --file FILE [FILE ...] Send one or multiple files (e.g. PDF, DOC, MP4). -e MATRIX_JSON_OBJECT [MATRIX_JSON_OBJECT ...], --event MATRIX_JSON_OBJECT [MATRIX_JSON_OBJECT ...] Send a Matrix JSON event. -w, --html Send message as format "HTML". -z, --markdown Send message as format "MARKDOWN". -k, --code Send message as format "CODE". -j, --emojize Send message after emojizing. -p SEPARATOR, --split SEPARATOR Split message text into multiple Matrix messages. --config CONFIG_FILE Specify the location of a config file. --proxy PROXY Specify a proxy for connectivity. -n, --notice Send message as notice. --encrypted Send message end-to-end encrypted. -l [NEVER|ONCE|FOREVER|TAIL|ALL], -- listen [NEVER|ONCE|FOREVER|TAIL|ALL] Print received messages and listen to messages. -t [NUMBER], --tail [NUMBER] Print last messages. -y, --listen-self Print your own messages as well. --print-event-id Print event ids of received messages. --download-media [DOWNLOAD_DIRECTORY] Download media files while listening. --download-media-name SOURCE|CLEAN|EVENTID|TIME Specify the method to derive the media filename. --os-notify Notify me of arriving messages. --set-device-name DEVICE_NAME Set or rename the current device. --set-display-name DISPLAY_NAME Set or rename the display name. --get-display-name Get the display name of yourself. --set-presence ONLINE|OFFLINE|UNAVAILABLE Set your presence. --get-presence Get your presence. --upload FILE [FILE ...] Upload one or multiple files to the content repository. --download MXC_URI [MXC_URI ...] Download one or multiple files from the content repository. --delete-mxc MXC_URI [MXC_URI ...] Delete one or multiple objects from the content repository. --delete-mxc-before TIMESTAMP [TIMESTAMP ...] Delete old objects from the content repository --joined-rooms Print the list of joined rooms. --joined-members ROOM [ROOM ...] Print the list of joined members for one or multiple rooms. --joined-dm-rooms USER [USER ...] Print the list of joined DM rooms for one or multiple users. --mxc-to-http MXC_URI [MXC_URI ...] Convert MXC URIs to HTTP URLs. --devices, --get-devices Print the list of devices. --discovery-info Print discovery information about current homeserver. --login-info Print login methods supported by the homeserver. --content-repository-config Print the content repository configuration. --rest REST_METHOD DATA URL [REST_METHOD DATA URL ...] Use the Matrix Client REST API. --set-avatar AVATAR_MXC_URI Set your avatar. --get-avatar [USER ...] Get an avatar. --get-profile [USER ...] Get a user profile. --get-room-info [ROOM ...] Get the room information. --get-client-info Print client information. --has-permission ROOM BAN|INVITE|KICK|NOTIFICATIONS|REDACT|etc [ROOM BAN|INVITE|KICK|NOTIFICATIONS|REDACT|etc ...] Inquire about permissions. --import-keys FILE PASSPHRASE FILE PASSPHRASE Import Megolm decryption keys from a file. --export-keys FILE PASSPHRASE FILE PASSPHRASE Export all the Megolm decryption keys of this device. --room-set-alias ROOM_ALIAS ROOM [ROOM_ALIAS ROOM ...], --room-put-alias ROOM_ALIAS ROOM [ROOM_ALIAS ROOM ...] Add aliases to rooms. --room-resolve-alias ROOM_ALIAS [ROOM_ALIAS ...] Show room ids corresponding to room aliases. --room-delete-alias ROOM_ALIAS [ROOM_ALIAS ...] Delete one or multiple rooms aliases. --get-openid-token [USER ...] Get an OpenID token. --room-get-visibility [ROOM ...] Get the visibility of one or more rooms. --room-get-state [ROOM ...] Get the state of one or more rooms. --delete-device DEVICE [DEVICE ...] Delete one or multiple devices. --room-redact ROOM_ID EVENT_ID REASON [ROOM_ID EVENT_ID REASON ...], --room-delete-content ROOM_ID EVENT_ID REASON [ROOM_ID EVENT_ID REASON ...] Strip information out of one or several events. --whoami Print your user id. --no-ssl Skip SSL verification. --ssl-certificate SSL_CERTIFICATE_FILE Use your own SSL certificate. --file-name FILE [FILE ...] Specify one or multiple file names for some actions. --key-dict KEY_DICTIONARY [KEY_DICTIONARY ...] Specify one or multiple key dictionaries for decryption. --plain Disable encryption for a specific action. --separator SEPARATOR Set a custom separator used for certain print outs. --access-token ACCESS_TOKEN Set a custom access token for use by certain actions. --password PASSWORD Specify a password for use by certain actions. --homeserver HOMESERVER_URL Specify a homeserver for use by certain actions. --device DEVICE_NAME Specify a device name, for use by certain actions. --sync FULL|OFF Choose synchronization options. -o TEXT|JSON|JSON-MAX|JSON-SPEC, -- output TEXT|JSON|JSON-MAX|JSON-SPEC Select an output format. --room-invites [LIST|JOIN|LIST+JOIN] List room invitations and/or join invited rooms. -v [PRINT|CHECK], -V [PRINT|CHECK], -- version [PRINT|CHECK] Print version information or check for updates. You are running version 7.7.0 2024-09-04. Enjoy, star on Github and contribute by submitting a Pull Request. Also have a look at matrix-commander-tui. ```
...
--verify [EMOJI]
  Perform verification.
...
--devices, --get-devices
  Print the list of devices.
...
--device DEVICE_NAME
  Specify a device name, for use by certain actions.
...

does not mention added means of verification, should proceed to an exhaustive verification then.

Benjamin-Loison commented 2 weeks ago
matrix-commander --get-devices
Output: ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdAbKYl0zoXr8AUf92W0Opziy86ygxHHtIOoiVrhobvFVww 33Z0mb4sRGrGvWBmg1joE/2Z9svJQFERHpBGab6TjjzPMJm+pUAdH0UQhxCqEpIm 0uoBJF9qzf9BJdAATf5KyKRRtjkqMDyDN+aWYZGl+KZKds2k4BD6ws0NFMZK2bmw BT+MXSiU+b5S+vpJM9nYx4NPcK/ep5u4Jb0yPMYTv+WvL2xvv8jUdhKP2QYTyl59 U/cFaITVjvkEK/avx6o1EfmaXCJw/wY9hivO5LQWy+a1ua4Tt0w1sPT0N79yLzGk ePkXpQhUEf4yTfER0r/JG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INPeLXEnVnHi0ett1ji0Y+H7hxHlfGuNTgiJj4nyqZA/Zn5v+A 9L6Grya1GfCRj8EBU0FKXv+HwGFwD6MDCU2lyzzNPOLCC3dVxxd6hDyTN++WGdBU iQykr+8GnBbEBGfv0uwYngX3VcPyQrDu5HWQNdoT4twVGxP035DOcL1SdbiRSGxq di0WLIkc6/a44urRZMc3UgjuSGjxFYPC0OMcQt7TgEhHwvFylMzu4O1yUsg0P/5D miwuLL8G41h846oxFwtTbJOdig0moJuCkt1ZDuAoMv9HT7LGZhlOdIh1kuola96X HtJjc+zt+BTdUt8lRUsTQgKwNKKhAnNxD9kbVdB3/XpQuIS4IL4C/sSDMuo3hZeD e8Q1U46D8/dBV+TcxJKwU51jwLhmrC6sen9ISP/9Ow4J64ubvDKH/emoX7FbLKn2 hYt7RBV/gbQoh8u+cALmrChM/1i9 =y1yz -----END PGP MESSAGE----- ```
Benjamin-Loison commented 2 weeks ago

Maybe first should remove no more used devices and see when logged with the given account how it looks.

Maybe the expected device is the other account one.

Benjamin-Loison commented 2 weeks ago

Related to Benjamin_Loison/cron/issues/11.