-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathindex.js
More file actions
168 lines (156 loc) · 5.57 KB
/
index.js
File metadata and controls
168 lines (156 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { TERMS_PRIVACY_REGEX } = require('./content-server-routes');
/**
* When you're ready to serve the React version of a page, identify which feature flag
* group object it should go in and add a new object in `routes` by calling `.getRoute`
* or setting `routes` with `.getRoutes` on the react route object.
*
* If a routeGroup should always be rendered with React in production, set `fullProdRollout` to true.
* These routes can still be turned off on SRE side by switching featureFlagOn to false
* on stage or prod for the relevant route if needed. React will ALWAYS be off for the routeGroup
* if featureFlagOn is set to false.
*
* NOTE however that routes that have been sunset in content-server (i.e, simple routes) can no longer
* fall back to backbone.
*
* When setting a regex, the corresponding matches for `router.js` must be set in
* `react-route-client.js`.
* @type {import("./types").GetReactRouteGroups}
*/
const getReactRouteGroups = (showReactApp, reactRoute) => {
return {
emailFirstRoutes: {
featureFlagOn: showReactApp.emailFirstRoutes,
// the order of the routes in the array is important. do not put '/'
// first.
routes: reactRoute.getRoutes([
'authorization',
// NOTE: 'oauth' is currently a weird case because because Fx desktop uses
// it to initiate the pairing flow. We have logic at the Express level to
// handle showing React/Backbone for this route until pairing is Reactified.
'oauth',
'/',
]),
fullProdRollout: true,
},
simpleRoutes: {
featureFlagOn: showReactApp.simpleRoutes,
routes: reactRoute.getRoutes([
'clear',
'cookies_disabled',
'legal',
// Match (allow for optional trailing slash):
// * /legal/terms
// * /<locale>/legal/terms
// * /legal/privacy
// * /<locale>/legal/privacy
TERMS_PRIVACY_REGEX,
]),
fullProdRollout: true,
},
resetPasswordRoutes: {
featureFlagOn: showReactApp.resetPasswordRoutes,
routes: reactRoute.getRoutes([
'reset_password',
'complete_reset_password',
'confirm_reset_password',
'reset_password_verified',
'reset_password_with_recovery_key_verified',
'account_recovery_confirm_key',
'account_recovery_reset_password',
]),
fullProdRollout: true,
},
oauthRoutes: {
featureFlagOn: showReactApp.oauthRoutes,
routes: [],
fullProdRollout: false,
},
signInRoutes: {
featureFlagOn: showReactApp.signInRoutes,
routes: reactRoute.getRoutes([
'signin',
'oauth/signin',
'oauth/force_auth',
'signin_token_code',
'signin_totp_code',
'signin_reported',
'signin_confirmed',
'signin_verified',
'signin_bounced',
'report_signin',
'complete_signin',
'signin_unblock',
'force_auth',
'signin_recovery_code',
'signin_recovery_choice',
'signin_recovery_phone',
'inline_totp_setup',
'inline_recovery_setup',
'inline_recovery_key_setup',
'signin_push_code',
'signin_push_code_confirm',
'signin_passwordless_code',
'oauth/signin_passwordless_code',
]),
fullProdRollout: true,
},
signUpRoutes: {
featureFlagOn: showReactApp.signUpRoutes,
routes: reactRoute.getRoutes([
'signup',
'confirm_signup_code',
'primary_email_verified',
'signup_confirmed',
'signup_verified',
'signup_confirmed_sync',
'oauth/signup',
]),
fullProdRollout: true,
},
pairRoutes: {
featureFlagOn: showReactApp.pairRoutes,
// TODO: see comment above about the '/oauth' route in `emailFirstRoutes`. We cannot
// check React experiment status at the Express level, so adding pair routes here
// without accounting for the 'oauth' conditional would mean Backbone
// `/oauth?channel_id=...` would get 100% of traffic while all other pairing gets 15%.
// Are we OK with that and then rolling Fx Desktop pairing out at 100%, or, relying on
// a feature flag only for the '/pair' flow, meaning at the Express level we could add
// a check for this flag to conditionally show '/oauth' React/Backbone?
routes: [],
fullProdRollout: false,
},
postVerifyOtherRoutes: {
featureFlagOn: showReactApp.postVerifyOtherRoutes,
routes: [],
fullProdRollout: false,
},
postVerifyCADViaQRRoutes: {
featureFlagOn: showReactApp.postVerifyCADViaQRRoutes,
routes: [],
fullProdRollout: false,
},
postVerifyThirdPartyAuthRoutes: {
featureFlagOn: showReactApp.postVerifyThirdPartyAuthRoutes,
routes: reactRoute.getRoutes([
'post_verify/third_party_auth/callback',
'post_verify/third_party_auth/set_password',
// NOTE: This is not a third party auth route, but it must be added
// to a react-app.index.js list so if users refresh on the page,
// Express points to React.
'post_verify/service_welcome',
]),
fullProdRollout: true,
},
webChannelExampleRoutes: {
featureFlagOn: showReactApp.webChannelExampleRoutes,
routes: reactRoute.getRoutes(['web_channel_example']),
fullProdRollout: false,
},
};
};
module.exports = {
getReactRouteGroups,
};