Skip to content

Commit 207e735

Browse files
feat(builderlab): isolate shared CLI sign-in in an opt-in plugin
Move the native session owner into tauri-plugin-builderlab and give block.builderlab one Settings > Integrations account card. Keep credentials in Rust and the bl-shared store; remove the global app commands and unused community-request helpers. Desktop no longer mounts the broker-only Hosted communities card. Standard builds exclude the new frontend module, native companion, dependency and grants; opted-in builds retain plugin enablement. Adapt Jarrod Sibbison's callback protections and card layout from #581 at 5d84bb9174515aa8a50c5a0075c538633c7024c9. Keep #582's persistence, superseding login, reload survival and server revocation. Bound callback requests, validate Host/Origin and payloads, and report receipt rather than premature sign-in success in the browser. Serialize storage transactions through commit or rollback, revoke displaced sessions on cancellation, and compare before logout deletion. Deserialize credentials into Zeroizing, retain saved items on incomplete HTTP bodies, honor BL_SKILLS_CONFIG, and show the resolved profile/service with conditional sharing copy. Plugin disposal fences UI work without ending a saved CLI session. Validation: 39 native plugin tests; 156 focused frontend tests; 29 plugin-manager tests each with/without builderlab; real Tauri ACL tests with/without the feature; workspace Clippy with all features/targets, TypeScript, formatting, changed-link and diff checks. Standard and opted-in frontend builds pass; inspected assets and the standard native dependency graph confirm exclusion. Native fixtures exercise the callback-to-persistence-to-logout round trip without Keychain. No browser journeys added or removed. Attended Keychain/bl and Windows/Linux acceptance, independent review, and hosted checks remain deferred. Cross-process CLI store writes and best-effort remote revocation remain documented limits. Co-authored-by: Jarrod Sibbison <[email protected]> Signed-off-by: Matt Toohey <[email protected]>
1 parent 2d96a77 commit 207e735

41 files changed

Lines changed: 1757 additions & 743 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Cargo.lock‎

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["crates/plugin-manager", "crates/agent-controller", "crates/credential-store", "src-tauri"]
2+
members = ["crates/plugin-manager", "crates/agent-controller", "crates/credential-store", "src-tauri", "crates/tauri-plugin-builderlab"]
33
default-members = ["crates/plugin-manager"]
44
resolver = "2"
55
exclude = ["vendor/mac-notification-sys"]

‎crates/plugin-manager/Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ rust-version = "1.89"
88
name = "buzzodz"
99
path = "src/main.rs"
1010

11+
[features]
12+
builderlab = []
13+
1114
[dependencies]
1215
serde = { version = "1", features = ["derive"] }
1316
serde_json = "1"

‎crates/plugin-manager/src/lib.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ pub fn valid_id(id: &str) -> Result<()> {
9999
}
100100
pub fn bundled_manifests() -> Vec<Manifest> {
101101
vec![
102+
#[cfg(feature = "builderlab")]
103+
serde_json::from_str(include_str!(
104+
"../../../src/bundled/builderlab/manifest.json"
105+
))
106+
.expect("bundled Builderlab manifest"),
102107
serde_json::from_str(include_str!("../../../src/bundled/todos/manifest.json"))
103108
.expect("todos manifest"),
104109
serde_json::from_str(include_str!("../../../src/bundled/diffs/manifest.json"))
@@ -377,6 +382,7 @@ impl Manager {
377382
| "buzz.workflows"
378383
| "buzz.sessions"
379384
| "block.hosted-communities"
385+
| "block.builderlab"
380386
| "buzz.moderation"
381387
));
382388
PluginInfo {

‎crates/plugin-manager/tests/management.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,10 @@ fn channels_is_required_even_with_saved_disabled_settings() {
600600
fn bundled_defaults_preserve_saved_choices_and_only_channels_is_required() {
601601
let (_root, manager, _source) = fixture();
602602
let catalog = manager.catalog().unwrap();
603-
assert_eq!(catalog.plugins.len(), 21);
603+
assert_eq!(
604+
catalog.plugins.len(),
605+
21 + usize::from(cfg!(feature = "builderlab"))
606+
);
604607
for plugin in &catalog.plugins {
605608
let id = plugin.manifest.id.as_str();
606609
let default = !matches!(id, "buzz.bestie" | "buzz.todos" | "buzz.channel-templates");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/permissions/autogenerated/
2+
/permissions/schemas/
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[package]
2+
name = "tauri-plugin-builderlab"
3+
version = "0.1.0"
4+
edition = "2021"
5+
rust-version = "1.89"
6+
links = "tauri-plugin-builderlab"
7+
8+
[build-dependencies]
9+
tauri-plugin = { version = "2", features = ["build"] }
10+
11+
[dependencies]
12+
tauri = { version = "2", default-features = false, features = ["dynamic-acl"] }
13+
tauri-plugin-opener = "2"
14+
builderlab-auth = { git = "https://github.com/block/builderlab-cli.git", rev = "78f9ea0044f7265b5e72aacd822215f6621fad7b", default-features = false }
15+
serde = { version = "1", features = ["derive"] }
16+
serde_json = "1"
17+
serde_yaml = "0.9"
18+
tokio = { version = "1", features = ["sync", "time", "macros", "io-util", "net", "rt"] }
19+
reqwest = { version = "0.13", default-features = false, features = ["rustls", "json"] }
20+
url = "2"
21+
uuid = { version = "1", features = ["v4"] }
22+
zeroize = { version = "1.9", features = ["serde"] }
23+
24+
[dev-dependencies]
25+
anyhow = "1"
26+
axum = "0.8"
27+
tempfile = "3"
28+
tokio = { version = "1", features = ["test-util", "rt-multi-thread"] }
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Builderlab native companion
2+
3+
The `block.builderlab` Settings plugin owns the UI; this optional Tauri plugin
4+
owns the session. The app includes it only with `--features builderlab`, paired
5+
with `BUZZ_BUILD_BUILDERLAB=1` for the frontend. See
6+
[configuration](../../docs/configuration.md#builderlab-session-shared-with-the-bl-cli).
7+
8+
## Ownership and protocol
9+
10+
- `auth`, `login`, `cancel`, and `sign_out` return only account metadata or fixed
11+
errors over `plugin:builderlab|…`. The local main webview is the only recipient
12+
of the plugin's capability. No generic OAuth, credential or authenticated-fetch
13+
API is exposed.
14+
- Storage is the source of truth. Each operation opens the `builderlab-auth`
15+
store under the resolved `bl` profile/service key. A mutex serializes this
16+
process's read/replace/compare-and-delete operations. Writes commit or roll
17+
back under that same lock; the state lock never spans a Keychain prompt.
18+
- A second login supersedes the first. Cancel/sign-out fence pending writes.
19+
Once an exchange starts, its spawned finish task survives a lost IPC caller:
20+
it either persists a verified session or attempts to revoke it. Both displaced
21+
and canceled minted sessions are revoked. Revocation has a five-second cap;
22+
server/network failures cannot guarantee remote revocation, and local sign-out
23+
still proceeds. A rotation observed before local delete is preserved.
24+
- The private callback receiver adapts Jarrod Sibbison's
25+
[PR #581](https://github.com/block/buzz-app/pull/581) at `5d84bb9174515aa8a50c5a0075c538633c7024c9`:
26+
loopback-only bind, random single-use path, exact Host, no Origin, GET only,
27+
8 KiB request cap, 4 KiB code cap, five-second connection deadline and ten-minute
28+
attempt deadline. Malformed callbacks do not consume the attempt. The response
29+
uses CSP, no-store and no-referrer, and says the code was received, not that
30+
verification succeeded. The socket closes before publishing the result.
31+
- kgoose's CLI protocol accepts `{code}` and echoes `returnTo`. It does not offer
32+
client-bound PKCE or echo OAuth state; those require a server protocol change.
33+
This is not a general OAuth receiver.
34+
- Exchange credentials must be bounded printable ASCII; `/me` must have a
35+
nonblank subject. Redirects are disabled, bodies bounded, and only 401/403
36+
invalidate saved sessions. Transport, truncated/stalled-body, malformed-body
37+
and 5xx failures preserve the shared item. HTTPS is required except for local
38+
development loopback endpoints.
39+
- Owned credentials and response buffers use `Zeroizing`; plain credentials
40+
returned/required by the CLI crate are wiped after use. HTTP, serde, OS and
41+
storage internals may retain copies. No credential is delivered to JavaScript
42+
or interpolated into an error.
43+
44+
`builderlab-auth` supplies no transaction shared with other processes. Simultaneous
45+
`bl`/Buzz writes, including whole-file updates across profiles, remain a limitation.
46+
No app-owned credential cache, migration, retry loop or provider registry is added.
47+
Native identity binding and community management remain outside this plugin.
48+
49+
## Validation
50+
51+
```sh
52+
CARGO_TARGET_DIR=target bin/cargo test -p tauri-plugin-builderlab --locked
53+
CARGO_TARGET_DIR=target bin/cargo test -p buzz-foundation --features builderlab --lib browser_permissions_tests --locked
54+
CARGO_TARGET_DIR=target bin/cargo test -p buzz-foundation --lib browser_permissions_tests --locked
55+
CARGO_TARGET_DIR=target bin/cargo test -p buzzodz-plugins --features builderlab --locked
56+
bin/pnpm exec vitest run src/bundled/builderlab src/bundled/hosted-communities
57+
```
58+
59+
The native suite uses a fake HTTP service, real TCP callbacks, the CLI's real
60+
file-store format and gated/failing storage handles. It never touches Keychain.
61+
The app ACL test uses a marker handler, without opening windows or resolving
62+
the real session. Frontend tests mount React and exercise the real adapter with
63+
controlled IPC responses. No browser journeys are added or removed: the changed
64+
contract is plugin registration and account lifecycle, not browser geometry.
65+
Existing broker tests remain; shared-session wording moved to the new card.
66+
Tests for the removed unused `/v1/buzz/*` helper were removed with that API.
67+
68+
Attended macOS Keychain/`bl` interoperability and Windows/Linux file-store runs
69+
remain required before native live-use acceptance. Independent review and human
70+
testing are separate from these automated checks.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
tauri_plugin::Builder::new(&["auth", "login", "cancel", "sign_out"]).build();
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"identifier": "builderlab-main",
3+
"description": "Builderlab account access for the local main webview only",
4+
"webviews": ["main"],
5+
"permissions": ["builderlab:default"]
6+
}

0 commit comments

Comments
 (0)