diff --git a/README.md b/README.md index d7e08aa..3505377 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,42 @@ -## matrix-utils ## - -Random matrix utilities. - -### `megolm_backup.py` ### +### `megolm_filter.py` ### This script can be used to modify your offline megolm key backups from a shell. The main use of this is to filter what keys you'd like to share with another user (let's say you have a 1:1 chat, and the other user lost all their keys and you need to give them access without giving access to all of your rooms). -[There is currently no Riot-based tooling for this][riotweb-issue6454], so this +[There is currently no Element-based support for this](https://github.com/element-hq/element-meta/issues/1287), so this script can help in the meantime. I've tested the output and input format with my own room keys and it has worked so far. ``` -usage: megolm_backup.py [-h] [-o OUTPUT] (--into | --from) [file] +usage: megolm_filter.py [-h] [-o OUTPUT] [--plain] [file] [room_id] Operate on megolm session backups. positional arguments: - file Input text file (- for stdin). + file megolm session data + room_id Room id to filter (optional) -optional arguments: - -h, --help show this help message and exit - -o OUTPUT, --output OUTPUT - Output text file (- for stdout). - --into Encrypt and represent file as a megolm session backup. - --from Decrypt the given megolm session and output the - contents. +options: + -h, --help show this help message and exit + -o, --output OUTPUT Output to file + -p, --plain Returns the plain unencrypted content ``` Using the above example, let's say we want to only get session keys of the room -`!foo:matrix.org`. You can do this fairly easily with [`jq`][jq]: +`!foo:matrix.org`. You can do this fairly easily with: ```bash -% megolm_backup.py --from riot-keys.py | - jq 'map(select(.room_id == "!foo:matrix.org"))' | - megolm_backup.py --into > new-riot-keys.txt + $ ./megolm_filter.py element-keys.txt '!foo:matrix.org' ``` You need to have PyCryptodome installed in order for this script to work. -[riotweb-issue6454]: https://github.com/vector-im/riot-web/issues/6454 -[jq]: https://stedolan.github.io/jq/ - -### License ### - -matrix-utils is licensed under the GNU General Public License version 3 or -later. - -``` -Copyright (C) 2019 Aleksa Sarai <cyphar@cyphar.com> +___ +Copyright (C) 2019 Aleksa Sarai <cyphar@cyphar.com> +Copyright (C) 2025 Lain Iwakura <lain@serialexperiments.club> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -65,4 +50,3 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. -``` diff --git a/megolm_backup.py b/megolm_filter.py similarity index 98% rename from megolm_backup.py rename to megolm_filter.py index 0961d5e..0c10f4e 100755 --- a/megolm_backup.py +++ b/megolm_filter.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 -# megolm_export: operate on megolm session data +# megolm_filter.py: operate on megolm session data # Copyright (C) 2019 Aleksa Sarai <cyphar@cyphar.com> +# Copyright (C) 2025 Lain Iwakura <lain@serialexperiments.club> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by