Skip to content

Commit

Permalink
Merge pull request #17 from chkpwd/feat/totp_accounts_output
Browse files Browse the repository at this point in the history
New features and lots of improvements to functionality and docs
  • Loading branch information
chkpwd authored Nov 28, 2024
2 parents cd7e3c4 + a303920 commit 19e10ad
Show file tree
Hide file tree
Showing 12 changed files with 350 additions and 225 deletions.
50 changes: 30 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Ente Auth - Alfred Workflow for Ente Exports

Easily integrate your **Ente Auth** with Alfred using this simple and powerful workflow to manage your Ente secrets and authentication.
Easily integrate your **Ente Auth** with Alfred using this simple workflow to query your Ente Auth TOTP accounts.

The workflow uses Ente CLI to export your secrets from Ente Auth and then stashes them securely into the macOS Keychain.

## 📸 Shots
![image1](./metadata/image.png)

## 🚀 Setup

### 1. Install the Workflow
Download and install the workflow from the latest [releases](https://github.com/chkpwd/alfred-ente-auth/releases) page.


> [!NOTE]
> Currently, Homebrew installation is not available for the Ente CLI due to an issue with the formula. When running brew test for the formula, the ente CLI fails with an error. As a result, the formula is not ready for installation via brew yet. Please use the manual installation steps outlined above. https://github.com/ente-io/ente/pull/4028
> Currently, Homebrew installation is not available for the Ente CLI. A formula will be added pending a new release including a [required fix](https://github.com/ente-io/ente/pull/4028). For the time being, please use the manual installation steps outlined below.
### 1. Download and Install the Ente CLI

### 2. Download and Install the Ente CLI
To use the **Ente Auth** workflow, you'll need the **Ente CLI**. Follow the steps below to install it:

1. Visit the [Ente CLI releases page](https://github.com/ente-io/ente/releases?q=tag%3Acli-v0).
Expand All @@ -32,26 +31,37 @@ Once installed, verify that it's working by running the following command in you
ente version
```

### 3. Configure Your Database
To configure the Ente CLI and ensure the workflow has access to your data, you'll need to set the **export path**. This path should be the same one you configured when adding your Ente account.
### 2. Configure Ente CLI

- Run `ente account add` to authenticate yourself with Ente CLI.
- You'll first be prompted for the app type. Enter `auth`.
- Next, you'll be asked for an export directory. You can choose any path you wish, but it must exist before you press return, else Ente CLI will not accept it.
- Finally, you'll be prompted to provide your Ente login credentials.

### 3. Install the Workflow

Download and open the workflow file from the [latest release](https://github.com/chkpwd/alfred-ente-auth/releases/latest) page.

> [!NOTE]
> To ensure the workflow can import your accounts from Ente Auth, you'll need to define the "Ente Export Directory" when you add this extension to Alfred.
> This path should be the same one you configured when adding your Ente account.
> To show the Ente CLI's configured export path, run `ente account list` and refer to the `ExportDir` value.
---

## 📖 Instructions
## 📖 Usage Instructions

1. **Launch Alfred**
- Open Alfred and navigate to the **Workflows** tab.

2. **Select Ente Auth**
- Find the "Ente Auth" workflow in your list and click on it.

3. **Configure Workflow**
- Hit the **Configure Workflow** button to open the settings.
- Specify the **export path**—this should be the same path you configured when adding your Ente account.
- Configure any additional settings as needed (e.g., API keys, other preferences).
2. **Import Your Data**
- To import your Ente Auth TOTP accounts, simply trigger the workflow by running **`ente import`** in Alfred.

4. **Import Your Data**
- To import your Ente secrets, simply trigger the workflow by running the command **Import Ente Secrets** in Alfred. This will import your stored Ente secrets into the workflow.
3. **Search for an Ente Auth TOTP account**
- To list all of your Ente Auth TOTP accounts, run `ente` in Alfred.
- To search for a specific account, simply append a search string to the previous command.
Example: `ente GitHub`
- The search feature also supports loose search queries, matching words in the account name in any order.
- For example "Docker Hub" will match with the queries "Docker Hub", "Hub", "Do Hu".

---

Expand Down
59 changes: 40 additions & 19 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@

import tomllib

WORKFLOW_PLIST_PATH = "info.plist"


def find_venv_py_version() -> str:
venv_python_version = os.listdir(os.path.join(os.getcwd(), ".venv", "lib"))[0]
return venv_python_version


def parse_info_plist():
"""Parse the info.plist file"""
with open("info.plist", "rb") as f:
"""Parse a plist file"""
with open(WORKFLOW_PLIST_PATH, "rb") as f:
plist = plistlib.load(f)
return plist


def get_workflow_name():
def get_workflow_name(plist):
"""Get the workflow name from parsed plist"""
plist = parse_info_plist()
name = plist["name"].replace(" ", "_").lower()
return name


def get_workflow_version():
"""Get the workflow version from parsed plist"""
plist = parse_info_plist()
version = plist["version"].replace(" ", "_").lower()
return version


def get_pyproject_version():
"""Get the project version from pyproject.toml"""
with open("pyproject.toml", "rb") as f:
Expand All @@ -38,11 +37,25 @@ def get_pyproject_version():
return version


def update_version(version: str, plist_path: str = "info.plist"):
"""Update the version in info.plist"""
plist = parse_info_plist()
def get_workflow_version(plist):
"""Get the workflow version from parsed plist"""
version = plist["version"].replace(" ", "_").lower()
return version


def update_workflow_version(plist, version: str):
"""Update "version" string in parsed plist"""
plist["version"] = version
with open(plist_path, "wb") as f:
with open(WORKFLOW_PLIST_PATH, "wb") as f:
plistlib.dump(plist, f)


def update_workflow_pythonpath_var(plist, python_dirname: str):
"""Update "PYTHONPATH" string variables dict in parsed plist"""
plist["variables"]["PYTHONPATH"] = os.path.join(
".venv", "lib", python_dirname, "site-packages"
)
with open(WORKFLOW_PLIST_PATH, "wb") as f:
plistlib.dump(plist, f)


Expand Down Expand Up @@ -86,16 +99,24 @@ def should_include(path):


def main():
workflow_name = get_workflow_name()
workflow_version = get_workflow_version()
plist = parse_info_plist()

workflow_name = get_workflow_name(plist)
workflow_version = get_workflow_version(plist)
pyproject_version = get_pyproject_version()

init_venv()

venv_python_version = find_venv_py_version()
update_workflow_pythonpath_var(plist, venv_python_version)

if workflow_version != pyproject_version:
update_version(pyproject_version)
update_workflow_version(plist, pyproject_version)
workflow_version = pyproject_version
else:
print("Workflow version matches PyProject version. Should this be updated?")
print(
"\nWARNING: Workflow version matches PyProject version. Should this be updated?"
)

zip_name = f"{workflow_name}-{workflow_version}.alfredworkflow"
zip_workflow(zip_name)
Expand Down
Loading

0 comments on commit 19e10ad

Please sign in to comment.