Repository navigation
feat(auth): use a lone BASE44_ACCESS_TOKEN as an in-memory credential - #681
Draft
amitbardos wants to merge 1 commit into
Draft
amitbardos wants to merge 1 commit into
amitbardos wants to merge 1 commit into
Conversation
When BASE44_ACCESS_TOKEN is set without BASE44_REFRESH_TOKEN (e.g. the MCP run_command tool injecting a short-lived token into a shared app sandbox for one command), hold it in memory for the current process only: readAuth() returns it ahead of auth.json, it is never written to disk, and refreshAndSaveTokens() returns null without refreshing, writing or deleting auth.json, so on expiry the 401 surfaces. The paired access+refresh path and BASE44_API_KEY precedence are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.2.3-pr.681.1d316b6Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.2.3-pr.681.1d316b6"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.2.3-pr.681.1d316b6"
}
}
Preview published to npm registry — try new features instantly! |
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.
Note
Description
Adds support for
BASE44_ACCESS_TOKENbeing set withoutBASE44_REFRESH_TOKEN. Previously that combination was ignored entirely — seeding no-opped and the CLI fell back to whatever login was in~/.base44/auth/auth.json. Now the lone access token is held in memory for the current process and used as the bearer, which is what the MCPrun_commandtool needs when it injects a short-lived token into a shared app sandbox for a single command. The token is never written to disk, so the next command in that sandbox does not inherit the identity, and any pre-existing stored login is left untouched.Related Issue
None
Type of Change
Changes Made
core/auth/config.ts: added a process-scopedenvAccessTokenAuthholder.seedAuthFromEnv()now splits its validation — a token still requiressub/expclaims, but a missing refresh token no longer aborts seeding; instead it builds an in-memoryAuthData(emptyrefreshToken,expiresAtfromexp) rather than writingauth.json.readAuth()returns the in-memory env auth ahead of the stored file, so all downstream callers use the injected token with no other call-site changes.refreshAndSaveTokens()short-circuits tonullwhen an env access token is active: there is nothing to refresh with, andauth.jsonbelongs to a different identity, so it is never refreshed, rewritten, or deleted. On expiry the 401 simply surfaces.BASE44_ACCESS_TOKEN+BASE44_REFRESH_TOKENpath is unchanged — it still writes a standardauth.jsonand participates in normal refresh/self-heal.docs/api-patterns.md: documented the lone-token path alongside the existing paired-credential behavior.tests/cli/env-token-auth.spec.ts: replaced the now-obsolete "incomplete env credentials are ignored" test with four cases — noauth.jsonis created from a lone token; the token is sent as the bearer while a stored login is left byte-identical; a 401 neither triggers a refresh call nor deletes the stored login; and a token missingsub/expis still ignored in favor of the stored login.Testing
Checklist
Additional Notes
Behavior change worth calling out: when
BASE44_ACCESS_TOKENis set with validsub/expclaims and no refresh token, it now takes precedence over an existingbase44 loginfor the duration of the process. Before this PR the env var was ignored in that case. Precedence relative toBASE44_API_KEY(workspace keys) is unchanged.🤖 Generated by Claude | 2026-10-25 15:40 UTC | 1d316b6