@glrs-dev/assume 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # @glrs-dev/assume
2
+
3
+ ## 0.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#21](https://github.com/iceglober/glrs/pull/21) [`4db487c`](https://github.com/iceglober/glrs/commit/4db487ce0b6e13cbee62c2f6a88be5574649b4b2) Thanks [@iceglober](https://github.com/iceglober)! - Fix gs-assume daemon auto-refresh — stop launchd respawn loop, verify PID ownership, enable default tracing, truncate oversized log.
8
+
9
+ - `gs-assume serve --foreground` now exits 0 (not error) when a healthy daemon is already running, breaking the launchd KeepAlive tight-respawn loop
10
+ - `is_daemon_running()` now verifies process identity via `ps -p <pid> -o comm=` to detect recycled PIDs
11
+ - Added `RUST_LOG=info,hyper=warn` to launchd plist EnvironmentVariables and as default tracing filter
12
+ - Added `ThrottleInterval=10` to launchd plist as defense-in-depth
13
+ - Added log truncation on startup if `daemon.stderr.log` exceeds 10 MB
14
+ - After successful session refresh, credentials are now re-fetched in the same tick (eliminating the 60s dead window)
15
+
16
+ ## 0.6.3
17
+
18
+ ### Major Changes
19
+
20
+ - First release under the `@glrs-dev` npm scope. Rust crate renamed from `assume` to `glrs-assume` for crates.io publishing; npm package name is `@glrs-dev/assume`.
21
+ - Bins `gs-assume` and `gsa` are preserved — existing shell aliases and muscle memory keep working.
22
+ - Source moved from [`iceglober/glorious`](https://github.com/iceglober/glorious) (now archived) to [`iceglober/glrs/packages/assume/`](https://github.com/iceglober/glrs/tree/main/packages/assume). Full git history preserved via `git-filter-repo`.
23
+
24
+ ### Packaging
25
+
26
+ - npm package ships via the prebuilt-binary `optionalDependencies` pattern: five platform packages (`@glrs-dev/assume-{darwin-arm64,darwin-x64,linux-x64,linux-arm64,win32-x64}`) each carry the prebuilt binary; the main `@glrs-dev/assume` package selects the right one at runtime via its TypeScript shim. No postinstall scripts.
27
+ - Rust crate also publishes to crates.io as `glrs-assume` — `cargo install glrs-assume` still works.
28
+
29
+ ### Install
30
+
31
+ ```bash
32
+ # Prebuilt binary via npm (recommended for most users)
33
+ npm i -g @glrs-dev/assume
34
+
35
+ # Build from source via cargo
36
+ cargo install glrs-assume
37
+ ```
38
+
39
+ ---
40
+
41
+ _For version history before the monorepo consolidation, see [`iceglober/glorious/releases`](https://github.com/iceglober/glorious/releases) (filter: `assume-*`)._
package/README.md ADDED
@@ -0,0 +1,221 @@
1
+ <div align="center">
2
+
3
+ <br/>
4
+
5
+ # `@glrs-dev/assume`
6
+
7
+ **Authenticate once, work all day.**<br/>
8
+ Multi-cloud credential manager with per-shell context switching.
9
+
10
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)
11
+ [![npm version](https://img.shields.io/npm/v/@glrs-dev/assume?style=flat-square)](https://www.npmjs.com/package/@glrs-dev/assume)
12
+
13
+ <br/>
14
+
15
+ </div>
16
+
17
+ ## Getting Started
18
+
19
+ ### Install
20
+
21
+ ```bash
22
+ npm i -g @glrs-dev/assume
23
+ ```
24
+
25
+ The prebuilt binary for your platform is auto-selected via npm's `optionalDependencies`. No postinstall scripts.
26
+
27
+ Two equivalent bins ship with the package: `gs-assume` and `gsa` (shorter alias). Pick one; they're identical.
28
+
29
+ > [!NOTE]
30
+ > Crates.io publishing (`cargo install glrs-assume`) is planned but not yet enabled. For now, `npm i -g @glrs-dev/assume` is the only install path.
31
+
32
+ ### First-time setup
33
+
34
+ ```bash
35
+ gsa login aws # Opens browser for AWS Identity Center
36
+ gsa profiles # List all available account/role pairs
37
+ gsa use dev # Switch context by fuzzy match
38
+ ```
39
+
40
+ <br/>
41
+
42
+ ## The Daily Loop
43
+
44
+ > Login once, switch instantly, credentials follow you.
45
+
46
+ ```bash
47
+ gsa login aws # authenticate (once per session)
48
+ gsa use dev # switch context in this shell
49
+ gsa use prod # different context in another shell
50
+ aws s3 ls # just works — credentials served locally
51
+ gsa console # open AWS console in browser
52
+ ```
53
+
54
+ <br/>
55
+
56
+ ## Commands
57
+
58
+ | Command | What happens |
59
+ |:--|:--|
60
+ | `gsa login <provider>` | Interactive auth — opens browser, polls for completion |
61
+ | `gsa use <pattern>` | Fuzzy-match context switch, per-shell. TUI picker if no pattern. |
62
+ | `gsa profiles` | List all contexts with active marker and danger tags |
63
+ | `gsa status` | Auth status, token expiry, active context, daemon health |
64
+ | `gsa sync` | Re-fetch contexts from provider APIs |
65
+ | `gsa exec -- <cmd>` | Run a command with injected credentials |
66
+ | `gsa console` | Open provider's web console for active context |
67
+ | `gsa credential-process` | AWS `credential_process` JSON output for SDK integration |
68
+ | `gsa config show` | View current configuration |
69
+ | `gsa config set <key> <val>` | Set a config value (dot notation) |
70
+ | `gsa shell-init <shell>` | Print shell integration script (bash, zsh, fish) |
71
+ | `gsa serve --install` | Install to PATH + launch agent (daemon starts on login) |
72
+ | `gsa serve --uninstall` | Remove binary, symlink, and launch agent |
73
+ | `gsa upgrade` | Self-update to latest release |
74
+ | `gsa logout [provider]` | Clear stored credentials |
75
+
76
+ <br/>
77
+
78
+ ## Agent & MCP Integration
79
+
80
+ Permission-gated credential access for AI agents (Claude Code, etc.).
81
+
82
+ | Command | What happens |
83
+ |:--|:--|
84
+ | `gsa agent allow` | TUI multi-select to toggle which contexts agents can access |
85
+ | `gsa agent allow --list` | Show currently approved contexts |
86
+ | `gsa agent allow --clear` | Revoke all agent access |
87
+ | `gsa agent exec -- <cmd>` | Run a command with auto-refreshing credentials (permission-gated) |
88
+ | `gsa agent mcp` | Start MCP server for AI agent integration |
89
+
90
+ **Default deny** — no context is agent-accessible unless explicitly approved via `gsa agent allow`.
91
+
92
+ ### MCP server
93
+
94
+ Register in your Claude Code settings:
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "gsa": { "command": "gsa", "args": ["agent", "mcp"] }
100
+ }
101
+ }
102
+ ```
103
+
104
+ Tools provided:
105
+ - **`run_with_credentials`** — run a shell command with auto-refreshing AWS credentials
106
+ - **`list_contexts`** — list contexts approved for agent access
107
+
108
+ ### Wrapping other MCP servers
109
+
110
+ Any MCP server that needs AWS credentials can be wrapped with `gsa agent exec`:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "aws-tools": { "command": "gsa", "args": ["agent", "exec", "--", "npx", "@aws/mcp-server"] }
116
+ }
117
+ }
118
+ ```
119
+
120
+ The wrapped server inherits `AWS_CONTAINER_CREDENTIALS_FULL_URI` pointing at the daemon, so credentials auto-refresh indefinitely.
121
+
122
+ <br/>
123
+
124
+ ## Shell Integration
125
+
126
+ `serve --install` adds this to your shell rc automatically:
127
+
128
+ ```bash
129
+ eval "$(gsa shell-init zsh)"
130
+ ```
131
+
132
+ This gives you:
133
+ - **`gsa` wrapper** — `gsa use` sets context as an env var in the current shell
134
+ - **Prompt segment** — shows `[aws:account/role]` in green (or red for dangerous contexts)
135
+ - **Per-shell isolation** — each terminal can have a different active context
136
+ - **Zero prompt delay** — reads an env var, no subprocess
137
+
138
+ <br/>
139
+
140
+ ## Configuration
141
+
142
+ Config file: `~/.config/gs-assume/config.toml` (macOS: `~/Library/Application Support/gs-assume/config.toml`)
143
+
144
+ ```toml
145
+ [providers.aws]
146
+ start_url = "https://myorg.awsapps.com/start"
147
+ region = "us-east-1"
148
+
149
+ [[providers.aws.profiles]]
150
+ account_id = "111111111111"
151
+ role_name = "AdministratorAccess"
152
+ alias = "prod/admin"
153
+ tags = ["production", "dangerous"]
154
+ color = "red"
155
+ confirm = true
156
+ ```
157
+
158
+ Team config (`gs-assume.team.toml` in repo root) merges with user config — user wins on conflicts.
159
+
160
+ <br/>
161
+
162
+ ## Security
163
+
164
+ - Credentials encrypted at rest with **AES-256-GCM** (not plaintext like AWS CLI, granted, or Leapp)
165
+ - Encryption key stored at `vault.key` with `0600` permissions
166
+ - Credential daemon serves tokens over `localhost` only
167
+ - All token files are `0600`
168
+ - Agent access gated by `agent-allowed.json` allowlist (default deny)
169
+ - All credential operations audit-logged to `~/.config/gs-assume/audit.log`
170
+
171
+ <br/>
172
+
173
+ ## Architecture
174
+
175
+ ```
176
+ src/
177
+ ├── main.rs # CLI entry (clap)
178
+ ├── cli/
179
+ │ ├── agent.rs # Agent access: allow, exec, mcp dispatch
180
+ │ ├── mcp.rs # MCP JSON-RPC 2.0 server over stdio
181
+ │ ├── login.rs # Interactive auth + first-time setup
182
+ │ ├── use_cmd.rs # Fuzzy context switch, per-shell env vars
183
+ │ ├── status.rs # Auth status + prompt segment
184
+ │ ├── profiles.rs # Context listing with danger tags
185
+ │ ├── sync.rs # Re-fetch contexts from APIs
186
+ │ ├── exec.rs # Run command with injected creds
187
+ │ ├── serve.rs # Daemon + install/uninstall
188
+ │ ├── console.rs # Open web console
189
+ │ ├── config_cmd.rs # Config get/set/show
190
+ │ ├── shell_init.rs # Shell integration output
191
+ │ ├── credential_process.rs # AWS credential_process
192
+ │ ├── logout.rs # Clear credentials
193
+ │ └── upgrade.rs # Self-update
194
+ ├── core/
195
+ │ ├── config.rs # TOML config + team config merging
196
+ │ ├── keychain.rs # AES-256-GCM encrypted storage
197
+ │ ├── cache.rs # Context + active context + agent-allowed cache
198
+ │ ├── daemon.rs # Daemon lifecycle, refresh loop, launchd
199
+ │ ├── fuzzy.rs # nucleo fuzzy matching
200
+ │ ├── rpc.rs # Unix socket RPC
201
+ │ ├── audit.rs # Event logging
202
+ │ ├── notify.rs # Desktop notifications
203
+ │ └── update_check.rs # Version check + auto-upgrade
204
+ ├── plugin/
205
+ │ ├── mod.rs # Provider trait + data types
206
+ │ └── registry.rs # Plugin registry + validation
207
+ ├── providers/
208
+ │ ├── aws/ # AWS Identity Center (SSO OIDC + STS)
209
+ │ └── gcp/ # Google Cloud (stub)
210
+ ├── tui/
211
+ │ └── picker.rs # Interactive context picker + multi-select
212
+ └── shell/
213
+ ├── prompt.rs # ANSI prompt formatting
214
+ └── completions.rs # Shell completions
215
+ ```
216
+
217
+ ---
218
+
219
+ <div align="center">
220
+ <sub>MIT License</sub>
221
+ </div>
@@ -0,0 +1,42 @@
1
+ // src/npm-shim/index.ts
2
+ import { createRequire } from "module";
3
+ import * as path from "path";
4
+ import * as fs from "fs";
5
+ var require2 = createRequire(import.meta.url);
6
+ function detectPlatform() {
7
+ const { platform, arch } = process;
8
+ if (platform === "darwin" && arch === "arm64") return "darwin-arm64";
9
+ if (platform === "darwin" && arch === "x64") return "darwin-x64";
10
+ if (platform === "linux" && arch === "x64") return "linux-x64";
11
+ if (platform === "linux" && arch === "arm64") return "linux-arm64";
12
+ throw new Error(
13
+ `[@glrs-dev/assume] Unsupported platform: ${platform}-${arch}. Supported: darwin-arm64, darwin-x64, linux-x64, linux-arm64. Windows support is not currently available \u2014 the daemon is Unix-architectured. File an issue at https://github.com/iceglober/glrs/issues if you need another target.`
14
+ );
15
+ }
16
+ var BIN_NAME = "gs-assume";
17
+ function getBinaryPath() {
18
+ const platform = detectPlatform();
19
+ const pkgName = `@glrs-dev/assume-${platform}`;
20
+ let pkgJsonPath;
21
+ try {
22
+ pkgJsonPath = require2.resolve(`${pkgName}/package.json`);
23
+ } catch (err) {
24
+ throw new Error(
25
+ `[@glrs-dev/assume] Platform package '${pkgName}' not found. This usually means 'optionalDependencies' were skipped (e.g. 'npm install --no-optional'). Reinstall with optional deps enabled, or run 'npm i ${pkgName}' directly.`,
26
+ { cause: err }
27
+ );
28
+ }
29
+ const pkgDir = path.dirname(pkgJsonPath);
30
+ const binPath = path.join(pkgDir, "bin", BIN_NAME);
31
+ if (!fs.existsSync(binPath)) {
32
+ throw new Error(
33
+ `[@glrs-dev/assume] Binary not found at ${binPath}. The platform package '${pkgName}' appears corrupted. Try reinstalling.`
34
+ );
35
+ }
36
+ return binPath;
37
+ }
38
+
39
+ export {
40
+ BIN_NAME,
41
+ getBinaryPath
42
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getBinaryPath
4
+ } from "./chunk-J5BWAQEL.js";
5
+
6
+ // src/npm-shim/cli.ts
7
+ import { spawn } from "child_process";
8
+ try {
9
+ const binary = getBinaryPath();
10
+ const args = process.argv.slice(2);
11
+ const child = spawn(binary, args, {
12
+ stdio: "inherit",
13
+ windowsHide: false
14
+ });
15
+ child.on("error", (err) => {
16
+ console.error(`[@glrs-dev/assume] Failed to spawn binary: ${err.message}`);
17
+ process.exit(127);
18
+ });
19
+ child.on("exit", (code, signal) => {
20
+ if (signal) {
21
+ process.kill(process.pid, signal);
22
+ return;
23
+ }
24
+ process.exit(code ?? 0);
25
+ });
26
+ } catch (err) {
27
+ console.error(err.message);
28
+ process.exit(1);
29
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @glrs-dev/assume — platform resolution shim.
3
+ *
4
+ * The main npm package contains no binaries itself. Instead, one of five
5
+ * platform-specific packages is installed via `optionalDependencies`, and
6
+ * this shim locates the correct prebuilt binary at runtime.
7
+ *
8
+ * The pattern mirrors esbuild, swc, and turbo. No postinstall scripts are
9
+ * involved — npm's `os` + `cpu` fields in each platform package cause
10
+ * npm/pnpm/bun to skip packages that don't match the user's platform.
11
+ */
12
+ declare const BIN_NAME = "gs-assume";
13
+ /**
14
+ * Resolve the path to the prebuilt binary for this platform.
15
+ *
16
+ * If you hit a "platform package not found" error, you may have run `npm
17
+ * install --no-optional` or have a package manager that silently skipped
18
+ * the optional dep. In that case install the matching platform package
19
+ * directly:
20
+ *
21
+ * npm i @glrs-dev/assume-<platform>
22
+ */
23
+ declare function getBinaryPath(): string;
24
+
25
+ export { BIN_NAME, getBinaryPath };
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ BIN_NAME,
3
+ getBinaryPath
4
+ } from "./chunk-J5BWAQEL.js";
5
+ export {
6
+ BIN_NAME,
7
+ getBinaryPath
8
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@glrs-dev/assume",
3
+ "version": "0.6.4",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Unified SSO credential manager for AWS, GCP, and more — npm distribution of the glrs-assume Rust binary.",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/iceglober/glrs.git",
12
+ "directory": "packages/assume"
13
+ },
14
+ "homepage": "https://glrs.dev/assume",
15
+ "bugs": {
16
+ "url": "https://github.com/iceglober/glrs/issues"
17
+ },
18
+ "type": "module",
19
+ "main": "./dist/index.js",
20
+ "bin": {
21
+ "gs-assume": "./dist/cli.js",
22
+ "gsa": "./dist/cli.js"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "CHANGELOG.md"
27
+ ],
28
+ "keywords": [
29
+ "sso",
30
+ "aws",
31
+ "gcp",
32
+ "credentials",
33
+ "assume",
34
+ "glrs"
35
+ ],
36
+ "engines": {
37
+ "bun": ">=1.2.0"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup src/npm-shim/index.ts src/npm-shim/cli.ts --format esm --dts --clean",
41
+ "typecheck": "tsc --noEmit",
42
+ "test": "bun test scripts/sync-version.test.mjs scripts/pack-platform-tarballs.test.mjs",
43
+ "lint": "echo 'no linter configured yet'",
44
+ "pack:platforms": "bun scripts/pack-platform-tarballs.mjs",
45
+ "sync:version": "bun scripts/sync-version.mjs"
46
+ },
47
+ "devDependencies": {
48
+ "@types/bun": "latest",
49
+ "@types/node": "^22",
50
+ "tsup": "^8",
51
+ "typescript": "^5"
52
+ },
53
+ "optionalDependencies": {
54
+ "@glrs-dev/assume-darwin-arm64": "0.6.4",
55
+ "@glrs-dev/assume-darwin-x64": "0.6.4",
56
+ "@glrs-dev/assume-linux-x64": "0.6.4",
57
+ "@glrs-dev/assume-linux-arm64": "0.6.4"
58
+ }
59
+ }