Skip to content

feat: add private package sources - #249

Merged
M4n0x merged 1 commit into
mainfrom
t3/private-package-sources
Oct 23, 2026
Merged

M4n0x merged 1 commit into
mainfrom
t3/private-package-sources

Conversation

@M4n0x

@M4n0x M4n0x commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Teams can't share StableBar packages privately. The Store reads one fixed index, and nothing records where an installed package came from. So StableBar can't tell a team's package from a Store package with the same ID, or know where its updates should come from. Closes #248.

#33 settled "Other repositories: only the curated one" for the Store. This keeps the curated Store as it is and lets people add their own sources on top of it, with the safeguards below.

Changes

  • Sources. A source is a name and an HTTPS index.json in the Store's format, listed under packageSources in config.json.
    • Sources merge by id across includes, so a team can share them; packages and profiles can't add them.
    • URLs can't contain a user name, password, ?query or #fragment.
    • stablebar and local are reserved IDs, and only the public Store can be named "StableBar Store".
    • The public Store is always on.
  • Tokens. Each source can have its own token, kept in the login Keychain.
    • A token is bound to the host it was entered for, and sent only there: PRIVATE-TOKEN for GitLab /api/v4/ URLs, Authorization: Bearer otherwise.
    • It's dropped on redirects to another host, never written to the HTTP cache (source requests use an ephemeral session), and configuration can't read it (@secret.source: resolves to nothing).
  • Store and Installed.
    • Store grid: one grid for every source, with a source menu, a source tag on each card, and "Installed from " when another source owns the ID.
    • Installed: rows show their source.
    • Package pages: say where a package came from. Private packages add "StableBar’s maintainers didn’t review this package."
    • With no private source configured, these screens look as before.
    • A broken source shows its own error, and the other sources keep working.
  • Install records. Each installed package ID records its source in packages/<id>/.source.json, plus any versions installed from a folder.
    • Updates come only from the recorded source.
    • A source can't take over an ID another source installed.
    • A folder copy is only attributed to a source when its files match that source's verified download.
    • Packages installed before records existed keep getting updates from the Store.
  • Settings → Packages → Sources… lists the sources, and adds, edits and removes them.
    • The Add form checks the index before Add source is enabled, and can Check again after a failure.
    • Sources defined in an include are read-only here, but can still get a token.
    • Edits go through the configuration history with Undo.
    • A new packageSource batch action does the same from the command line.
  • Join links. stablebar://add-source?name=…&url=… opens the Add form filled in.
    • A link never carries a token and never adds anything without your confirmation.
    • Copy join link in the sheet makes one.
  • Publishing. StableBar --build-source PACKAGES OUT [--previous INDEX] [--url URL --name NAME] checks package folders and writes the index and archives in the same layout as stablebar-packages' build-index.sh.
  • Command line. --install-package ID --source SOURCE picks a source. Without --source, it stops when two sources list the ID, or when another source can't be read. --packages now lists each package's source.
  • Docs. docs/packages.md gains "Private sources", "Tokens" and "Publishing a source" (a Mac, a GitHub workflow on macOS runners, GitLab's package registry). docs/settings.md, docs/configuration.md and docs/command-line.md are updated, and stablebar.schema.json has packageSources.
  • Renames. The old PackageSource badge enum is now PackageOrigin, freeing the name for configured sources. Inside the loader, packageSources became packageBoundaries.

Testing

  • swift test on this commit: 314 XCTest tests pass. Of the 434 Swift Testing tests, only popupResizesWithItsContentAndKeepsItsWidthAndTopEdge(animated: true) fails, and it fails because the display was asleep (CGDisplayIsAsleep = 1). No popup code changed.
  • The new tests cover:
    • decoding and merging of sources, with rejection in packages and profiles;
    • the header and origin rules, including a real cross-host redirect through a stub URLProtocol and the ephemeral session;
    • per-source errors, including an HTML login page answering 200;
    • install records and the claiming rules, including folder versions and file comparison;
    • updates by source, the Sources sheet's Add, Edit and Undo, and join link parsing;
    • --install-package --source and --build-source, with a round trip through the client.
  • StableBar --validate accepts a scratch configuration with a packageSources entry. StableBar --build-source examples/packages <scratch> writes three archives and an index and prints a join link.
  • The screenshots below were rendered offscreen from a test harness with stubbed sources; they're not from a running bar.
  • Not checked:
    • real GitLab and GitHub hosts with real tokens: the headers follow GitLab's generic-registry docs and GitHub's raw-file token support;
    • macOS delivering a stablebar:// link to a running app;
    • the Sources sheet inside a live Settings window.
  • Behaviour changes to know:
    • --install-package ID now reads the configuration to find sources, so a configuration that doesn't load stops it.
    • The docs say sources need StableBar 0.6.0 or later, because older versions refuse the unknown packageSources key.

Screenshots (before → after): Store, Installed and package page, Sources sheet, Add form opened from a link.

Before (main) After (this PR)
Store on main Store with sources
Installed on main Installed with sources
Sources sheet Add form opened from a join link
Sources sheet Add source form from a link

Merging

One commit, so every merge method gives the same changelog entry. #243 also changes the Store grid's order, so whichever lands second needs a small rebase.

Claude Opus 5.5 via Claude Code

@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner October 23, 2026 03:01
Teams can now list their own package catalogs next to the StableBar Store and
see where each package comes from.

- packageSources in config.json: a name and an https index.json in the Store's
  format, merged by id across includes. URLs can't hold a user name, password,
  query or fragment.
- Tokens per source live in the login Keychain, bound to the host they were
  entered for. They are sent only there (PRIVATE-TOKEN for GitLab API URLs,
  Bearer otherwise), dropped on redirects to another host, kept out of the
  HTTP cache, and unreadable from configuration.
- One Store grid for every source, with a source menu, source tags and
  "Installed from <source>". Package pages say where a package came from, and
  private packages note that StableBar's maintainers didn't review them.
- Each installed package records its source in packages/<id>/.source.json,
  along with versions installed from a folder. Updates come only from that
  source, and a source can't take over an ID another source installed or
  claim a folder copy whose files differ.
- Settings → Packages → Sources… adds, checks, edits and removes sources.
- stablebar://add-source links open the Add form filled in, without a token.
- StableBar --build-source turns package folders into an index and archives;
  --install-package ID --source SOURCE and a source field in --packages.

Closes #248
@M4n0x
M4n0x force-pushed the t3/private-package-sources branch from 650e108 to a4e6a08 Compare October 23, 2026 03:10
@M4n0x
M4n0x merged commit 2335591 into main Oct 23, 2026
7 checks passed
@M4n0x
M4n0x deleted the t3/private-package-sources branch October 23, 2026 05:14
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add private package sources next to the Store

1 participant