Skip to content

feat(core): introduce Client::gov_mode() with URL-host inference#1147

Open
addisonbeck wants to merge 1 commit into
mainfrom
pm-38266-gov-mode
Open

feat(core): introduce Client::gov_mode() with URL-host inference#1147
addisonbeck wants to merge 1 commit into
mainfrom
pm-38266-gov-mode

Conversation

@addisonbeck

@addisonbeck addisonbeck commented May 28, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38266

📔 Objective

Expose Client::gov_mode() on bitwarden_core::Client so SDK consumers can detect Gov environments without rebuilding URL inference locally.

Later on PM-36520 we'll replaces URL inference with a some sort of /api/config gov_mode read. After that isGovMode on clients will be updated to call the SDK.

@addisonbeck addisonbeck marked this pull request as ready for review May 28, 2026 19:41
@addisonbeck addisonbeck requested a review from a team as a code owner May 28, 2026 19:41
@addisonbeck addisonbeck requested a review from coroiu May 28, 2026 19:41
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

🔍 SDK Breaking Change Detection

SDK Version: pm-38266-gov-mode (3d03906)

⚠️ If breaking changes are detected, a corresponding pull request addressing them must be ready for merge in the affected client repository.

Client Status Details
typescript ✅ No breaking changes detected Compilation passed with new SDK version - View Details
android ✅ No breaking changes detected Compilation passed with new SDK version - View Details

Breaking change detection uses the build of the SDK from this branch, including any incompatibities pre-existing on or merged into this branch. Check the workflow logs to confirm.
Results update as workflows complete.

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.09%. Comparing base (f20702c) to head (098a8e9).

Files with missing lines Patch % Lines
crates/bitwarden-uniffi/src/lib.rs 0.00% 3 Missing ⚠️
crates/bitwarden-wasm-internal/src/client.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1147      +/-   ##
==========================================
- Coverage   85.09%   85.09%   -0.01%     
==========================================
  Files         464      465       +1     
  Lines       63866    63917      +51     
==========================================
+ Hits        54348    54390      +42     
- Misses       9518     9527       +9     

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

@addisonbeck addisonbeck marked this pull request as draft May 28, 2026 21:30
@addisonbeck

Copy link
Copy Markdown
Contributor Author

didn't get this quite ready before signing off for the weekend, sorry for the ping. Please ignore!

@addisonbeck addisonbeck removed the request for review from coroiu May 28, 2026 21:31
Expose Client::gov_mode() on bitwarden_core::Client so SDK consumers
(Key Management, Mobile, and TypeScript clients via WASM bindings)
can detect Gov environments without rebuilding URL inference locally.

The classifier infers Gov from the configured API URL host
(bitwarden-gov.com or a subdomain) using url::Url parsing rather than
substring matching, so spoofed subdomains (e.g.
api.bitwarden-gov.com.evil.example) and path-only matches do not
classify as Gov.

Exposed via UniFFI for Swift/Kotlin and WASM for TypeScript through
the existing wrapper layers.

PM-36520 is the planned fast-follow that replaces URL inference with
a /api/config server-published cloud_region read; the
Client::gov_mode() signature is unchanged across that migration.

Refs: PM-38266
@sonarqubecloud

Copy link
Copy Markdown

@addisonbeck addisonbeck marked this pull request as ready for review June 23, 2026 18:33
@addisonbeck addisonbeck requested a review from coroiu June 23, 2026 18:34
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the introduction of Client::gov_mode() on bitwarden_core::Client, which infers Gov Mode from the configured API URL host, along with its UniFFI and WASM bindings. The URL-host matching logic correctly uses parsed-host comparison rather than substring matching, and the test suite covers canonical hosts, alternate subdomains, spoofed subdomains, path-only matches, case-insensitivity, and invalid URLs. The url dependency added to bitwarden-core is already an approved workspace dependency.

Code Review Details

No findings. The implementation is correct, the security-sensitive subdomain-spoofing edge cases are explicitly handled and tested, the bindings follow existing patterns, and the known self-hosted limitation is documented and deferred to PM-36520.

@addisonbeck addisonbeck enabled auto-merge (squash) June 23, 2026 19:11
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.

1 participant