Feat/appcheck debugtoken cli#10801
Conversation
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
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.
efc0d61 to
284fbf9
Compare
8fd6d16 to
6dd0076
Compare
1804817 to
f6b9b82
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10801 +/- ##
=======================================
Coverage ? 58.24%
=======================================
Files ? 619
Lines ? 40249
Branches ? 8145
=======================================
Hits ? 23444
Misses ? 14854
Partials ? 1951 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Adding to the Firebase CLI App Check debug token workflows under the unified
appcheck:debugtokennamespace, aligning directly with the backend REST API (projects.apps.debugTokens).Key changes:
appcheck:debugtoken:createfor headless/non-interactive script execution and CI/CD automation pipelines.appcheck:debugtoken:listto render registered tokens in tabular format (Display Name,Resource Name,Update Time) with full backend pagination.appcheck:debugtoken:deleteto permanently revoke tokens by ID or resource path, supporting interactive confirmation and--forceflag overrides.Scenarios Tested
appcheck:debugtoken): Tested running with no arguments to verify automatic app detection and interactive choice selection.appcheck:debugtoken <appId> <debugToken>): Tested supplyingappIdanddebugTokenpositional arguments to confirm prompt skipping.appcheck:debugtoken:create): Verified execution with--non-interactiveflag using fallback defaults without blocking prompts.appcheck:debugtoken:list): Verified table rendering of returned tokens and multi-page pagination handling.appcheck:debugtoken:delete): Tested interactive deletion confirmation as well as non-interactive--forcedeletion.npm run buildandnpx mocha src/appcheck/index.spec.ts&src/commands/appcheck-debug.spec.ts(12/12 unit tests passing).Sample Commands
Interactive wizard: Register a token copied from SDK logs
firebase appcheck:debugtoken 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e e3d9b1a0-cf48-4389-8d19-482a177ffec8
Interactive wizard: Auto-detect project & prompt for app selection
firebase appcheck:debugtoken
Non-interactive creation for CI/CD pipelines
firebase appcheck:debugtoken:create 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e e3d9b1a0-cf48-4389-8d19-482a177ffec8 --display-name "CI Runner Token" --non-interactive
List registered tokens for an app
firebase appcheck:debugtoken:list 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e
Delete / revoke a token by ID
firebase appcheck:debugtoken:delete 1:1234567890:ios:0a1b2c3d4e5f6a7b8c9d0e 7890-abcd --force