|
| 1 | +# Keeper Vault REPL |
| 2 | + |
| 3 | +An interactive shell for the Keeper Vault: log in once, then run `ls`, `cd`, `get`, `find`, and |
| 4 | +other commands against your vault until you exit. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +- Node.js 20 LTS or newer |
| 9 | +- A Keeper account with credentials |
| 10 | + |
| 11 | +## Setup |
| 12 | + |
| 13 | +This example depends on the sibling `KeeperSdk` and `keeperapi` packages by local path |
| 14 | +(`file:../../KeeperSdk`, `file:../../keeperapi`), so those need to be built once before the REPL |
| 15 | +can resolve `@keeper-security/keeperapi` at runtime: |
| 16 | + |
| 17 | +```bash |
| 18 | +# From the repository root |
| 19 | +cd keeperapi && npm install && npm run build |
| 20 | +cd ../KeeperSdk && npm install && npm run link-local && npm run build |
| 21 | + |
| 22 | +# Now the REPL itself |
| 23 | +cd ../examples/repl |
| 24 | +npm install |
| 25 | +``` |
| 26 | + |
| 27 | +## Run |
| 28 | + |
| 29 | +```bash |
| 30 | +npm start |
| 31 | +``` |
| 32 | + |
| 33 | +There's no config file to set up first — on first run you'll be prompted interactively for |
| 34 | +server, username, and password. Credentials/session are then saved to `~/.keeper/config.json` for |
| 35 | +persistent login on subsequent runs (same file used by the other examples in this repo). |
| 36 | + |
| 37 | +## Commands |
| 38 | + |
| 39 | +Type `help` inside the REPL for the live list. Summary: |
| 40 | + |
| 41 | +| Command | Description | |
| 42 | +|---|---| |
| 43 | +| `help` | List available commands | |
| 44 | +| `whoami` | Show current session info | |
| 45 | +| `pwd` | Print current working folder | |
| 46 | +| `ls [path]` | List contents of the current (or given) folder | |
| 47 | +| `cd [path]` | Change the current working folder (`cd /` for vault root) | |
| 48 | +| `tree [path]` | Show the folder tree from the current (or given) folder | |
| 49 | +| `list` | List every record in the vault | |
| 50 | +| `find <text>` | Search records by title, login, or URL | |
| 51 | +| `get <uid\|title>` | Show details for a single record | |
| 52 | +| `sync` | Re-sync the vault with the server | |
| 53 | +| `get_controllers` | Call the PAM router API (`pam/get_controllers`) and list enterprise gateways | |
| 54 | +| `get_online_controllers` | Call the PAM router API (`loadOnlineControllers`) and list connected gateways | |
| 55 | +| `run <script.ts> [args...]` | Execute a TypeScript file exporting `default async function(vault, args)` — see [`scripts/README.md`](scripts/README.md) | |
| 56 | +| `history` | Show command history | |
| 57 | +| `clear` | Clear the screen | |
| 58 | +| `exit` / `quit` | Log out and quit the REPL | |
| 59 | + |
| 60 | +Command history persists across sessions in `~/.keeper/repl_history` (excluding `history`, `exit`, |
| 61 | +`quit`, `clear`); use `!<n>` to re-run entry `n` from `history`, bash-style. |
| 62 | + |
| 63 | +## Extending |
| 64 | + |
| 65 | +Drop a `.ts` file under [`scripts/`](scripts/README.md) and run it with `run scripts/<file>.ts` for |
| 66 | +one-off tasks against the live, authenticated `vault` — no rebuild needed. Promote anything that |
| 67 | +turns out to be a permanent command into `src/commands.ts`. |
0 commit comments