Feat/appcheck debugtoken cli - #10801
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Firebase App Check debug token management commands (appcheck:debugtoken, appcheck:debugtoken:create, appcheck:debugtoken:list, and appcheck:debugtoken:delete) along with their corresponding API client methods, CLI command registrations, and unit tests. Feedback focuses on improving robustness and error handling: safely accessing res.body properties via optional chaining in listDebugTokens to prevent potential TypeErrors; explicitly handling non-interactive mode when prompting for a display name in the creation command; failing early in non-interactive mode if --force is omitted during deletion; validating that full resource names belong to the specified app and project; and aborting with a FirebaseError if a user declines to overwrite an existing token with the same display name.
1804817 to
f6b9b82
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10801 +/- ##
=======================================
Coverage ? 58.53%
=======================================
Files ? 621
Lines ? 40618
Branches ? 8240
=======================================
Hits ? 23776
Misses ? 14856
Partials ? 1986 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ee6de4f to
acd5428
Compare
andrewheard
left a comment
There was a problem hiding this comment.
LGTM. I'd recommend replacing the any with a type like in create and cleaning up get / update if we don't need them but no big concerns on my end.
727ff90 to
8fd9577
Compare
joehan
left a comment
There was a problem hiding this comment.
Left some comments, but also:
- Please move this to a branch on the main repo - go/firebase-github-access will get you access if needed. That will allow the tests to run automatically for you.
- Please add a changelog entry - users need to know about this change!
I have requested access and will update the change log. |
48031bd to
c203f4d
Compare
c203f4d to
6e6d3ac
Compare
Introduces CLI support for managing Firebase App Check debug tokens via the App Check REST API (`projects.apps.debugTokens`). Key changes: * api: Added `appCheckOrigin` to `src/api.ts` (`https://firebaseappcheck.googleapis.com`). * appcheck: Created the `src/appcheck/index.ts` API client supporting `create`, `list`, `get`, `update`, and `delete` operations, along with comprehensive unit tests in `index.spec.ts`. * commands: Added a suite of management commands under the `appcheck:debug-tokens` namespace: - `appcheck:debug-tokens:create <appId> [debugToken]`: Creates a debug token (with auto-generated UUIDv4 fallback and interactive display name prompting). - `appcheck:debug-tokens:list <appId>`: Lists all debug tokens for an app in a formatted table. - `appcheck:debug-tokens:get <appId> <debugTokenId>`: Fetches and displays metadata for a specific debug token. - `appcheck:debug-tokens:update <appId> <debugTokenId>`: Updates the display name of a debug token via `patch`. - `appcheck:debug-tokens:delete <appId> <debugTokenId>`: Revokes/deletes a debug token with interactive confirmation support. * commands: Registered the new commands in `src/commands/index.ts`. feat: Add App Check debug token commands
…rebase-debug-token and update .gitignore
…ames in non-interactive mode
…ate.ts and remove old files
6e6d3ac to
06960f6
Compare
joehan
left a comment
There was a problem hiding this comment.
LGTM if this has alreayd been approved by API council - otherwise, lets stick it behind an experiement and remove the changelog entry
| @@ -0,0 +1,3 @@ | |||
| export * from "./types"; | |||
There was a problem hiding this comment.
Nit: No need to use an index file here. It's generally better to just have importing files pull in from the individual files, as it keeps our dependency graph a little bit cleaner (and avoids unnecessary improts
c2e4e65 to
32d71ad
Compare
I have gotten the API council LGTM! |
* feat: Add App Check debug token management commands Introduces CLI support for managing Firebase App Check debug tokens via the App Check REST API (`projects.apps.debugTokens`). Key changes: * api: Added `appCheckOrigin` to `src/api.ts` (`https://firebaseappcheck.googleapis.com`). * appcheck: Created the `src/appcheck/index.ts` API client supporting `create`, `list`, `get`, `update`, and `delete` operations, along with comprehensive unit tests in `index.spec.ts`. * commands: Added a suite of management commands under the `appcheck:debug-tokens` namespace: - `appcheck:debug-tokens:create <appId> [debugToken]`: Creates a debug token (with auto-generated UUIDv4 fallback and interactive display name prompting). - `appcheck:debug-tokens:list <appId>`: Lists all debug tokens for an app in a formatted table. - `appcheck:debug-tokens:get <appId> <debugTokenId>`: Fetches and displays metadata for a specific debug token. - `appcheck:debug-tokens:update <appId> <debugTokenId>`: Updates the display name of a debug token via `patch`. - `appcheck:debug-tokens:delete <appId> <debugTokenId>`: Revokes/deletes a debug token with interactive confirmation support. * commands: Registered the new commands in `src/commands/index.ts`. feat: Add App Check debug token commands * feat: Implement firebase appcheck:debug <appId> to generate local .firebase-debug-token and update .gitignore * feat: align appcheck:debugtoken CLI commands with REST backend specification * test: add command unit tests for appcheck:debugtoken CLI scenario suite * fix: address code review comments for appcheck:debugtoken CLI and REST layer * fix: resolve lint errors and formatting in appcheck commands and spec * fix: stub requireAuth in spec and enable auth on App Check Client for CI runner * fix: bypass command pre-action hooks in spec for CI test runner * Fix nock matching for Node 24 by using RegExp * Fix prettier formatting in tests * fix(appcheck): stub client directly to bypass Node 24 nock fetch bug * feat(appcheck): refactor cli command namespace and args * feat(appcheck): require --force to overwrite existing token display names in non-interactive mode * fix(lint): fix prettier formatting errors in appcheck-debugtokens-create.ts and remove old files * chore: remove old appcheck-debug files properly * Refactor: extract App Check prompt utils and remove stale endpoints --------- Co-authored-by: Andrew Heard <andrewheard@google.com>
Description
Adding to the Firebase CLI App Check debug token workflows under the unified
appcheck:debugtokensnamespace, aligning directly with the backend REST API (projects.apps.debugTokens).Key changes:
appcheck:debugtokens:createfor both interactive wizard registration and headless/non-interactive script execution in CI/CD automation pipelines.appcheck:debugtokens:listto render registered tokens in tabular format (Display Name,Resource Name,Update Time) with full backend pagination.appcheck:debugtokens:deleteto permanently revoke tokens by ID or resource path, supporting interactive confirmation and--forceflag overrides.Scenarios Tested
appcheck:debugtokens:create): Tested running without--appto verify automatic app detection and interactive choice selection.appcheck:debugtokens:create [debugToken] --app <appId>): Tested supplying--appanddebugTokento confirm prompt skipping.appcheck:debugtokens:create --non-interactive): Verified execution with global--non-interactiveflag using fallback defaults without blocking prompts, and correctly enforcing--forcefor display name collision overwrites.appcheck:debugtokens:list --app <appId>): Verified table rendering of returned tokens and multi-page pagination handling.appcheck:debugtokens:delete <debugTokenId> --app <appId>): Tested interactive deletion confirmation as well as non-interactive--forcedeletion.npm run buildandnpx mocha src/appcheck/index.spec.ts&src/commands/appcheck-debugtokens-create.spec.ts(12/12 unit tests passing).Sample Commands
Interactive wizard: Register a token copied from SDK logs
firebase appcheck:debugtokens:create e3d9b1a0-cf48-4389-8d19-482a177ffec8 --app 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e
Interactive wizard: Auto-detect project & prompt for app selection
firebase appcheck:debugtokens:create
Non-interactive creation for CI/CD pipelines
firebase appcheck:debugtokens:create e3d9b1a0-cf48-4389-8d19-482a177ffec8 --app 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e --display-name "CI Runner Token" --non-interactive
List registered tokens for an app
firebase appcheck:debugtokens:list --app 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e
Delete / revoke a token by ID
firebase appcheck:debugtokens:delete 7890-abcd --app 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e --force