feat(init): connect scaffolds to a managed instance when logged in#60
Merged
Conversation
Previously init hardwired AUTH_SERVER_URL and API_URL to localhost and minted the app's service token locally, so a developer who ran seamless login and then init got an app pointed at localhost. When a profile has an active session, init now defaults to the managed control plane: it reads the keychain session, lists the developer's applications from portal-api, issues the application's service token from the control plane, and points the scaffolded web and api at the managed auth instance. The self-hosted flow stays available with --local and is used automatically when no session is present. Running init inside an existing project wires the managed credentials into api/.env in place, or prints them when there is no api directory. Closes #59
Bccorb
added a commit
that referenced
this pull request
Jul 17, 2026
feat(init): connect scaffolds to a managed instance when logged in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
seamless initnow connects a scaffolded app to a managed Seamless Auth instance instead of hardwiring localhost.Before,
initsetAUTH_SERVER_URL=http://localhost:5312andAPI_URL=http://localhost:3000and minted the app'sAPI_SERVICE_TOKENwith a localgenerateSecret(). It never read the logged-in profile, keychain session, or instance URL, so runningseamless loginand thenseamless initproduced an app pointed at localhost. The existing-project path was an unimplemented stub.How
When a profile has an active session (and
--localis not passed),initdefaults to the managed control plane:createAuthClient).GET /applications), auto-selecting a single app or prompting to choose (--app <id>skips the prompt).POST /applications/:id/rotateServiceToken), the real credential rather than a local secret. Because the token is shown only once, it confirms before issuing a new token for an app that already has one (issuing invalidates the old one).web+apipointed at the application's managed auth instance (domain), with no local auth server, Docker Compose, or admin dashboard.Running
initin an existing (non-empty) project wires the managed credentials intoapi/.envin place, preserving existing keys, or prints the values when there is noapidirectory. Source is never overwritten.The self-hosted/local flow is unchanged, reachable with
seamless init --local, and still used automatically when no session is present.SEAMLESS_PORTAL_API_URLoverrides the control-plane host (defaults to the managed service).Notes
src/core/portal.ts(control-plane client, reuses the profile's Bearer session against the portal host) andsrc/prompts/appSelect.ts(application selection).authServerUrl= the app'sdomain,serviceSecret= the issued token,jwksKiddefault).Testing
npm run buildandnpm testpass (new unit tests forportal.tsandappSelect.ts).api/.envwhile preserving existing keys; the no-api-dir branch printed the values; the no-session branch fell back correctly.Closes #59