Skip to content

Feat/appcheck debugtoken cli#10801

Open
AustinBenoit wants to merge 13 commits into
firebase:mainfrom
AustinBenoit:feat/appcheck-debugtoken-cli
Open

Feat/appcheck debugtoken cli#10801
AustinBenoit wants to merge 13 commits into
firebase:mainfrom
AustinBenoit:feat/appcheck-debugtoken-cli

Conversation

@AustinBenoit

Copy link
Copy Markdown

Description

Adding to the Firebase CLI App Check debug token workflows under the unified appcheck:debugtoken namespace, aligning directly with the backend REST API (projects.apps.debugTokens).

Key changes:

  • Added appcheck:debugtoken:create for headless/non-interactive script execution and CI/CD automation pipelines.
  • Implemented appcheck:debugtoken:list to render registered tokens in tabular format (Display Name, Resource Name, Update Time) with full backend pagination.
  • Implemented appcheck:debugtoken:delete to permanently revoke tokens by ID or resource path, supporting interactive confirmation and --force flag overrides.

Scenarios Tested

  • Interactive Wizard (appcheck:debugtoken): Tested running with no arguments to verify automatic app detection and interactive choice selection.
  • Explicit Arguments (appcheck:debugtoken <appId> <debugToken>): Tested supplying appId and debugToken positional arguments to confirm prompt skipping.
  • Display Name Collisions: Verified interactive confirmation prompt asking whether to overwrite when a token with the same display name already exists.
  • Headless Creation (appcheck:debugtoken:create): Verified execution with --non-interactive flag using fallback defaults without blocking prompts.
  • Token Listing (appcheck:debugtoken:list): Verified table rendering of returned tokens and multi-page pagination handling.
  • Token Revocation (appcheck:debugtoken:delete): Tested interactive deletion confirmation as well as non-interactive --force deletion.
  • Build & Test Suite: Ran npm run build and npx 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

andrewheard and others added 5 commits May 28, 2026 15:14
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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/appcheck/index.ts Outdated
Comment thread src/commands/appcheck-debugtokens-create.ts
Comment thread src/commands/appcheck-debugtokens-delete.ts
Comment thread src/commands/appcheck-debugtokens-delete.ts
Comment thread src/commands/appcheck-debug.ts
@AustinBenoit AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from efc0d61 to 284fbf9 Compare July 15, 2026 21:16
@AustinBenoit AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from 8fd6d16 to 6dd0076 Compare July 15, 2026 21:18
@AustinBenoit AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from 1804817 to f6b9b82 Compare July 15, 2026 22:21
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.26347% with 53 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@03a71ef). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/commands/appcheck-debug.ts 41.26% 31 Missing and 6 partials ⚠️
src/commands/appcheck-debugtokens-delete.ts 76.92% 4 Missing and 2 partials ⚠️
src/commands/appcheck-debugtokens-create.ts 75.00% 3 Missing and 2 partials ⚠️
src/commands/appcheck-debugtokens-list.ts 81.81% 2 Missing and 2 partials ⚠️
src/appcheck/index.ts 96.55% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants