Skip to content

fix(emails): Update oauth_client_info service/name check#20374

Open
LZoog wants to merge 1 commit intomainfrom
FXA-13080
Open

fix(emails): Update oauth_client_info service/name check#20374
LZoog wants to merge 1 commit intomainfrom
FXA-13080

Conversation

@LZoog
Copy link
Copy Markdown
Contributor

@LZoog LZoog commented Apr 14, 2026

Because:

  • In the verifyLoginCode email, Smart Window and VPN say '... Mozilla?' (the default) in the subject line/body copy, and we want to be consistent with Sync and Relay and focus on '... Firefox?' wording

This commit:

  • Changes the hardcoded check against sync/relay to include the OAuthNativeServices enum to return 'Firefox' as the name

closes FXA-13080


This is easiest to check in Maildev by running yarn pm2 stop inbox and sudo maildev -s 9999 then checking port 1080 to compare.

Please see the ticket for a comment with a chart of the state of things before this change. This affects the email code email (you may need to use a @mozilla email locally and set SIGNIN_CONFIRMATION_SKIP_FOR_NEW_ACCOUNTS to false) and the new device email.

I messaged Ipsita and Ross for how we want to make these consistent and they prefer the "Firefox" wording.

Because:
* In the verifyLoginCode email, Smart Window and VPN say '...  Mozilla?' (the default) in the subject line/body copy, and we want to be consistent with Sync and Relay and focus on '... Firefox?' wording

This commit:
* Changes the hardcoded check against sync/relay to include the OAuthNativeServices enum to return 'Firefox' as the name

closes FXA-13080
@LZoog LZoog requested a review from a team as a code owner April 14, 2026 17:39
@vpomerleau vpomerleau requested a review from Copilot April 15, 2026 21:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates how oauth_client_info decides when to label an OAuth flow as coming from “Firefox” (vs “Mozilla”) by switching from a hardcoded sync/relay check to an OAuthNativeServices allowlist, to make Smart Window and VPN emails consistent.

Changes:

  • Use OAuthNativeServices to classify “native Firefox services” and return the Firefox client name for all of them.
  • Add tests asserting smartwindow and vpn resolve to Firefox.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/fxa-auth-server/lib/senders/oauth_client_info.js Switches Firefox/Mozilla naming logic to use OAuthNativeServices instead of hardcoded service strings.
packages/fxa-auth-server/lib/senders/oauth_client_info.spec.ts Adds test cases for smartwindow and vpn returning Firefox.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to +71
it('returns Firefox if service=smartwindow', async () => {
const res = await fetch('smartwindow');
expect(res.name).toBe('Firefox');
});

it('returns Firefox if service=vpn', async () => {
const res = await fetch('vpn');
expect(res.name).toBe('Firefox');
});
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The new smartwindow/vpn assertions will pass even if the code doesn't treat those services as native, because the client mock’s default branch returns { name: 'Firefox' } for any unknown id. To validate the intended behavior, make the mock return a non-Firefox name for these values (or spy on getClientById and assert it is not called) so the test fails without the native-services short-circuit.

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 10
const client = require('../oauth/client');
const { OAuthNativeServices } = require('@fxa/accounts/oauth');

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

New runtime dependency added via require('@fxa/accounts/oauth'), but packages/fxa-auth-server/package.json does not list @fxa/accounts/oauth. This can break installs that focus/pack auth-server (e.g., Yarn workspaces focus/production) with MODULE_NOT_FOUND. Add @fxa/accounts/oauth as a workspace dependency of fxa-auth-server.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +48
// Set the client name to 'Firefox' if the service is a native Firefox service
const nativeServices = new Set(Object.values(OAuthNativeServices));
if (nativeServices.has(service)) {
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

nativeServices is re-created on every fetch() call. Since OAuthNativeServices is static, build the Set once (e.g., in the module factory scope) and reuse it to avoid repeated allocations on a hot path.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@vbudhram vbudhram left a comment

Choose a reason for hiding this comment

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

Image

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