@@ -448,9 +448,7 @@ describe('/password', () => {
448448 mockRequest
449449 ) . then ( ( response : any ) => {
450450 expect ( Object . keys ( response ) ) . toEqual ( [ 'accountResetToken' ] ) ;
451- expect ( response . accountResetToken ) . toBe (
452- accountResetToken . data
453- ) ;
451+ expect ( response . accountResetToken ) . toBe ( accountResetToken . data ) ;
454452
455453 expect ( mockCustoms . check . callCount ) . toBe ( 1 ) ;
456454
@@ -1230,5 +1228,56 @@ describe('/password', () => {
12301228 expect ( response . sessionToken ) . toBeTruthy ( ) ;
12311229 expect ( response . keyFetchToken ) . toBeFalsy ( ) ;
12321230 } ) ;
1231+
1232+ it ( 'should include sessionVerified in the response reflecting token verification status' , async ( ) => {
1233+ const oldAuthPW = crypto . randomBytes ( 32 ) . toString ( 'hex' ) ;
1234+ const authPW = crypto . randomBytes ( 32 ) . toString ( 'hex' ) ;
1235+ const wrapKb = crypto . randomBytes ( 32 ) . toString ( 'hex' ) ;
1236+
1237+ const mockRequest = mocks . mockRequest ( {
1238+ log : mockLog ,
1239+ auth : {
1240+ credentials : {
1241+ uid,
1242+ email : TEST_EMAIL ,
1243+ emailVerified : true ,
1244+ tokenVerified : true ,
1245+ deviceId : crypto . randomBytes ( 16 ) . toString ( 'hex' ) ,
1246+ authenticatorAssuranceLevel : 2 ,
1247+ lastAuthAt : ( ) => Date . now ( ) ,
1248+ data : crypto . randomBytes ( 32 ) . toString ( 'hex' ) ,
1249+ } ,
1250+ } ,
1251+ payload : {
1252+ email : TEST_EMAIL ,
1253+ oldAuthPW,
1254+ authPW,
1255+ wrapKb,
1256+ } ,
1257+ query : { } ,
1258+ } ) ;
1259+
1260+ const passwordRoutes = makeRoutes ( {
1261+ db : mockDB ,
1262+ mailer : mockMailer ,
1263+ push : mockPush ,
1264+ log : mockLog ,
1265+ statsd : mockStatsd ,
1266+ customs : mockCustoms ,
1267+ } ) ;
1268+
1269+ const response = await runRoute (
1270+ passwordRoutes ,
1271+ '/mfa/password/change' ,
1272+ mockRequest
1273+ ) ;
1274+
1275+ // sessionVerified must be present so that client-side storage correctly
1276+ // reflects the verified session after a password change.
1277+ expect ( response . sessionVerified ) . toBe ( true ) ;
1278+
1279+ // verified (deprecated compat field) should remain present and consistent
1280+ expect ( response . verified ) . toBe ( true ) ;
1281+ } ) ;
12331282 } ) ;
12341283} ) ;
0 commit comments