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.26%
=======================================
Files ? 619
Lines ? 40370
Branches ? 8181
=======================================
Hits ? 23522
Misses ? 14893
Partials ? 1955 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
93e4a1e to
ee6de4f
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
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.
6cc5a54 to
7ee319a
Compare
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