MLFlexer / resurrect.wezterm

A plugin to restore windows, tabs and panes for Wezterm inspired by tmux-resurrect
MIT License
33 stars 1 forks source link

Add support for multiple encryption providers #38

Closed joncrangle closed 1 month ago

joncrangle commented 1 month ago

Since the encrypt and decrypt functions have grown in complexity, it was starting to get a bit difficult for someone to provide their own functions while also properly handling errors, input size and emitters.

This PR adds support for rage and gpg by allowing the user to specify the provider in their resurrect.set_encryption() config like:

local resurrect = wezterm.plugin.require("https://github.com/MLFlexer/resurrect.wezterm")
resurrect.set_encryption({
  enable = true,
  method = "age" -- "age" is the default encryption method, but you can also specify "rage" or "gpg"
  private_key = "/path/to/private/key.txt", -- if using "gpg", you can omit this
  public_key = "age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p",
})

It doesn't remove the ability for someone to provide their own functions for an advanced user. I noticed this PR kind of negated the need for a separate encryption.md so I pulled some of its content into the main README.md.

joncrangle commented 1 month ago

I would think this covers the majority of use cases but I'm not that familiar with other encryption providers that would fit well with our use case.

This doesn't cover some of the more advanced scenarios like if someone wants to use a passphrase or symmetrical encryption, or if someone is using a hardware token (like a yubikey), but I think this keeps us with a sane default and alternatives.

The simplified encrypt and decrypt functions in https://github.com/MLFlexer/resurrect.wezterm/pull/35 will also make it easier for someone to provide their own functions or to create a PR if more features are desired.

EDIT: https://github.com/MLFlexer/resurrect.wezterm/pull/35 moves some of the encrypt and decrypt code elsewhere, so we should probably wait on this PR until the other PR is settled and I make the necessary updates here.