Conversation
| useEffect(() => { | ||
| if (recoveryFailed) { | ||
| const localizedErrorMessage = ftlMsg.getMsg( | ||
| 'signin-recovery-error', |
There was a problem hiding this comment.
Looks like we need this added to an FTL file.
| import firefox from '../../channels/firefox'; | ||
| import { hardNavigate } from 'fxa-react/lib/utils'; | ||
|
|
||
| export type OAuthFlowRecoveryResult = { |
There was a problem hiding this comment.
Just a nit but it could be good to have JS Doc style comments for this type, mostly because I'm not sure if I'd know what isRecovering means in this context without digging in a bit more. Something like, "The oauth query params from the browser are no longer valid (oftentimes from a page refresh) - are we currently fetching fresh params via webchannel?" would make it super clear to me.
| stack: string; | ||
| }; | ||
| }; | ||
| params?: Record<string, any>; // Some commands use params instead of data |
There was a problem hiding this comment.
Since we later check const responseData = message.data || message.params I guess we're saying one or the other is present - we could do something like...
interface FirefoxMessageBase {
command: FirefoxCommand;
messageId: string;
error?: string;
}
interface FirefoxMessageWithData extends FirefoxMessageBase {
data: Record<string, any> & {
error?: {
message: string;
stack: string;
};
};
params?: never;
}
interface FirefoxMessageWithParams extends FirefoxMessageBase {
params: Record<string, any>;
data?: never;
}
export type FirefoxMessage =
| FirefoxMessageWithData
| FirefoxMessageWithParams;
... Feels like a lot of types but could be worth it for clarity? I'll leave it up to you.
| getPermissions: jest | ||
| .fn() | ||
| .mockReturnValue(['profile', 'https://identity.mozilla.com/apps/oldsync']), | ||
| }; |
There was a problem hiding this comment.
I guess one small improvement here is setting the return type to as unknown as Integration so you don't have to set each one as any further down in each test. Better though would be no casting here at all - it'd require setting integration: Integration in the hook, to something like integration: UseOAuthFlowRecoveryIntegration and then setting that to only what we need, similar to how we do others like SigninIntegration. 🤔
| useEffect(() => { | ||
| const shouldAttemptRecovery = | ||
| !recoveryAttempted && | ||
| isOAuthNativeIntegration(integration) && |
There was a problem hiding this comment.
Makes sense to check this for isOAuthNativeIntegration and not just Sync flow 👍
There might be an opportunity to share more of this in the hook so any time we use it it'd prevent some extra set up but eh maybe this is more clear and we don't need it in too many places.
LZoog
left a comment
There was a problem hiding this comment.
I'm having problems getting Firefox running from the download link and this isn't available in Nightly yet so I'm going to r+ based on what I see in the code, and sounds like we might pair for a bit later too.
My only real "blocker" is the FTL file update, but had one or two other suggestions as well.
| new CustomEvent(FirefoxCommand.Error, { detail: error }) | ||
| ); | ||
| } else { | ||
| const responseData = message.data || message.params; |
There was a problem hiding this comment.

Because
keyFetchToken,unwrapBKey) are lost on page refresh with no recovery pathThis pull request
useOAuthFlowRecoveryhook to recover from interrupted OAuth Native flows via Firefox webchannelfxaOAuthFlowBeginandfxaOAuthFlowIsActivecommands tofirefox.tsSigninTokenCodeandConfirmSignupCodeto attempt recovery when state is missing/signinwith fresh OAuth params on successful recoveryIssue
Closes: https://mozilla-hub.atlassian.net/browse/FXA-12118
Checklist
Other Information
How to test:
/signininstead of "Bad Request" errorNote: Requires Firefox with
fxaccounts:oauth_flow_beginwebchannel supportYOu can download it here: https://drive.google.com/file/d/1oKZHHJXqJ5C0LniU-iJwxnLoCQE1FvWt/view?usp=drive_link