Skip to content

Feat/appcheck debugtoken cli#10801

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

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

Conversation

@AustinBenoit

@AustinBenoit AustinBenoit commented Jul 15, 2026

Copy link
Copy Markdown

Description

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

Key changes:

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

Scenarios Tested

  • Interactive Wizard (appcheck:debugtokens:create): Tested running without --app to verify automatic app detection and interactive choice selection.
  • Explicit Arguments (appcheck:debugtokens:create [debugToken] --app <appId>): Tested supplying --app and debugToken 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:debugtokens:create --non-interactive): Verified execution with global --non-interactive flag using fallback defaults without blocking prompts, and correctly enforcing --force for display name collision overwrites.
  • Token Listing (appcheck:debugtokens:list --app <appId>): Verified table rendering of returned tokens and multi-page pagination handling.
  • Token Revocation (appcheck:debugtokens:delete <debugTokenId> --app <appId>): 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-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

@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 Outdated
@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch 3 times, most recently from 1804817 to f6b9b82 Compare July 15, 2026 22:21
@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.39080% with 55 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@48242c1). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/commands/appcheck-debugtokens-utils.ts 35.00% 24 Missing and 2 partials ⚠️
src/commands/appcheck-debugtokens-create.ts 64.00% 12 Missing and 6 partials ⚠️
src/commands/appcheck-debugtokens-delete.ts 78.57% 4 Missing and 2 partials ⚠️
src/commands/appcheck-debugtokens-list.ts 83.33% 2 Missing and 2 partials ⚠️
src/appcheck/api.ts 95.65% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10801   +/-   ##
=======================================
  Coverage        ?   58.31%           
=======================================
  Files           ?      620           
  Lines           ?    40426           
  Branches        ?     8196           
=======================================
  Hits            ?    23575           
  Misses          ?    14896           
  Partials        ?     1955           

☔ 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.

@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from 93e4a1e to ee6de4f Compare July 20, 2026 19:26
andrewheard and others added 15 commits July 21, 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
@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from ee6de4f to acd5428 Compare July 21, 2026 15:14

@andrewheard andrewheard 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.

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.

Comment thread src/appcheck/index.ts Outdated
Comment thread src/appcheck/index.ts Outdated
Comment thread src/commands/appcheck-debugtokens-list.ts Outdated
Comment thread src/commands/appcheck-debugtokens-delete.ts Outdated
Comment thread src/commands/appcheck-debugtokens-list.ts Outdated
Comment thread src/commands/appcheck-debugtokens-delete.ts Outdated
@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch 7 times, most recently from 727ff90 to 8fd9577 Compare July 24, 2026 18:57

@joehan joehan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!

/**
*
*/
export async function getOrPromptProjectAndAppId(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't be prompting for project ID here. The CLI has a well established way of handling project selection (either using the active project system, or the -P flag), and we do not want this command to subvert that.

If a project ID is not specified, the command should jsut error our with a clear message.

}

const projectDir = options.cwd || process.cwd();
let apps = await listFirebaseApps(projectId, AppPlatform.ANY);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As I'm revieiwng this, I'm realizing that there is duplicated logic for selecting an app from the list of exisitng apps in 3 places in the CLI already 🤦 That's an oversight on my part, but we really ought to centralize this . I'm gonna send you a PR shortly to do so - please review and we can merge that before this one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@@ -0,0 +1,74 @@
import { Options } from "../options";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The src/commands directory should only include files that implement and export a command. Please move the types to src/appcheck/types.ts, and the prompt function (if it is still needed after that pr to centralize logic) to src/appcheck/prompts.ts

Comment thread src/appcheck/index.ts Outdated
@@ -0,0 +1,67 @@
import { appCheckOrigin } from "../api";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

index.ts is a very generic name for a file that tells us nothing. We do it in a few other places in the codebase, but it is a code smell. This file just has API methods and types. Please split it into 2 files: src/appcheck/types.ts and src/appcheck/api.ts

Then, we can also move the AppCheckDebugOptions to the types file too.

@AustinBenoit

Copy link
Copy Markdown
Author

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.

@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from 8fd9577 to 48031bd Compare July 24, 2026 20:34
@AustinBenoit
AustinBenoit force-pushed the feat/appcheck-debugtoken-cli branch from 48031bd to c203f4d Compare July 24, 2026 20:41
throw new FirebaseError("Must specify an App ID using --app.");
}
.action(async (debugTokenId: string, options: AppCheckDebugOptions): Promise<void> => {
const { appId } = await getOrPromptProjectAndAppId(options);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Moe directly - use needProjectID here instead of rolling your own

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.

5 participants