Repository navigation
feat(appcheck): add --local to appcheck:debugtokens:list - #11420
AustinBenoit merged 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces local machine configuration persistence for Firebase App Check debug tokens. It adds support for saving debug tokens locally to ~/.config/configstore/firebase-appcheck.json during creation (appcheck:debugtokens:create) and inspecting these locally saved tokens via a new --local flag on the list command (appcheck:debugtokens:list). It also includes robust validation, secure file handling (preventing prototype pollution and zero-byte truncation), and comprehensive unit tests. No review comments were provided, so there is no additional feedback to address.
ee568a5 to
ce0191d
Compare
|
/joe-review |
05cb454 to
b74a9c6
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11420 +/- ##
=======================================
Coverage ? 59.53%
=======================================
Files ? 861
Lines ? 50404
Branches ? 10102
=======================================
Hits ? 30006
Misses ? 18097
Partials ? 2301 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
70caeb4 to
b2eb75d
Compare
b2eb75d to
5247888
Compare
### Description Part 2 of 3 (stacked on firebase#11418) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens). `appcheck:debugtokens:list --local` lists debug tokens saved in `~/.config/configstore/firebase-appcheck.json` as a table of App ID, token prefix, and server status (optionally filtered by `--app`). It works offline (`Unchecked`) and, when authenticated with an active project, reports `Active`, `Revoked`, or `App Deleted`. Without `--local`, `list` is unchanged. ### Scenarios Tested - `npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts'` - `npm run build`, `npm run test:compile`, lint, prettier. ### Sample Commands ```bash firebase appcheck:debugtokens:list --local firebase appcheck:debugtokens:list --local --app 1:1234567890:ios:abcdef ```
5247888 to
144fc27
Compare
### Description Part 2 of 3 (stacked on #11418) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens). `appcheck:debugtokens:list --local` lists debug tokens saved in `~/.config/configstore/firebase-appcheck.json` as a table of App ID, token prefix, and server status (optionally filtered by `--app`). It works offline (`Unchecked`) and, when authenticated with an active project, reports `Active`, `Revoked`, or `App Deleted`. Without `--local`, `list` is unchanged. ### Scenarios Tested - `npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts'` - `npm run build`, `npm run test:compile`, lint, prettier. ### Sample Commands ```bash firebase appcheck:debugtokens:list --local firebase appcheck:debugtokens:list --local --app 1:1234567890:ios:abcdef ```
…ly (lazyCompileValidationSchemas) to cut ~10 s per createApp() (#11176) * perf(auth-emulator): lazily compile OpenAPI validation schemas (b/566319964) * refactor(functions): add KitSourceAdapter for npm and directory kits (#11370) * refactor(functions): add KitSourceAdapter for npm and directory kits * refactor(functions): decouple createdPaths and inline adapter selection * test(functions): clean up overfitted adapter tests and simplify directory adapter signature * feat(appcheck): save debug tokens to local machine config on create (#11418) ### Description Part 1 of 3 (stacked) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens). `appcheck:debugtokens:create` now saves the token to `~/.config/configstore/firebase-appcheck.json` so local client SDKs and build plugins can discover it without copy-pasting from the Console. - **`src/appcheck/localConfig.ts`**: reads/writes `firebase-appcheck.json` (tokens keyed by GMP App ID, plus the optional server resource name under `tokenNames`), mirroring to an absolute `$XDG_CONFIG_HOME` when it differs from `~/.config`. Reads JSON directly so a malformed file raises an actionable error instead of being wiped by `Configstore`. - **`appcheck:debugtokens:create`**: - Saves locally by default; `--no-save-local` opts out (for CI/remote tokens). - Defaults `--display-name` to `<username>@<hostname>` (bounded to the backend's 50-char limit), or `CLI Debug Token (<shortHost>)` with `--no-save-local` so CI tokens don't replace the host's own token. - Validates UUID v4 / display name before any API call, respects the 20-token limit, creates the replacement before deleting the old token, includes `token` in `--json` output, and prints `.env.local` snippets for Web apps. ### Scenarios Tested - `npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts'` - `npm run build`, `npm run test:compile`, lint, prettier. ### Sample Commands ```bash firebase appcheck:debugtokens:create --app 1:1234567890:ios:abcdef firebase appcheck:debugtokens:create --app 1:1234567890:web:abcdef --display-name "github-actions" --no-save-local --force --json ``` * feat(appcheck): add --local to appcheck:debugtokens:list (#11420) ### Description Part 2 of 3 (stacked on #11418) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens). `appcheck:debugtokens:list --local` lists debug tokens saved in `~/.config/configstore/firebase-appcheck.json` as a table of App ID, token prefix, and server status (optionally filtered by `--app`). It works offline (`Unchecked`) and, when authenticated with an active project, reports `Active`, `Revoked`, or `App Deleted`. Without `--local`, `list` is unchanged. ### Scenarios Tested - `npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts'` - `npm run build`, `npm run test:compile`, lint, prettier. ### Sample Commands ```bash firebase appcheck:debugtokens:list --local firebase appcheck:debugtokens:list --local --app 1:1234567890:ios:abcdef ``` * feat(appcheck): add appcheck:debugtokens:prune and local cleanup on delete (#11421) ### Description Part 3 of 3 (stacked on the `list --local` PR) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens). - **`appcheck:debugtokens:prune`**: removes local entries in `~/.config/configstore/firebase-appcheck.json` for the active project whose app was deleted or whose token was revoked on the server. Prompts for confirmation unless `--force`, and states that server-registered tokens are untouched. - **`appcheck:debugtokens:delete`**: also removes the matching local entry when deleting this machine's server token; uses `.withForce()`. ### Scenarios Tested - `npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts' 'src/commands/index.spec.ts'` - `npm run build`, `npm run test:compile`, lint, prettier. ### Sample Commands ```bash firebase appcheck:debugtokens:prune firebase appcheck:debugtokens:prune --force ``` * fix: address PR review feedback on PR #11176 - Add CHANGELOG entry for lazy OpenAPI validation schema compilation. - Export specForRouter() and support CreateAppOptions in createApp() to allow schema compilation override. - Add unit test in rest.spec.ts eagerly compiling all OpenAPI validation schemas to catch spec regressions in CI. --------- Co-authored-by: shettyvarun268 <[email protected]> Co-authored-by: Wanda Mora <[email protected]> Co-authored-by: Austin Benoit <[email protected]>
Description
Part 2 of 3 (stacked on #11418) for seamless App Check debug tokens (go/firebase-api-sdk-cli-seamless-debug-tokens).
appcheck:debugtokens:list --locallists debug tokens saved in~/.config/configstore/firebase-appcheck.jsonas a table of App ID, token prefix, and server status (optionally filtered by--app). It works offline (Unchecked) and, when authenticated with an active project, reportsActive,Revoked, orApp Deleted. Without--local,listis unchanged.Scenarios Tested
npx mocha 'src/appcheck/**/*.spec.ts' 'src/commands/appcheck*.spec.ts'npm run build,npm run test:compile, lint, prettier.Sample Commands
Note
Stacked on #11418. Until that merges, this PR also shows its commit; please review only the top commit (
feat(appcheck): add --local to appcheck:debugtokens:list).