@@ -14,6 +14,7 @@ import type { LoginResponse } from '../../sdk';
14
14
import { Platform } from '../../sdk' ;
15
15
import { arrangeAuthAPIs } from '../../sdk/__fixtures__/auth' ;
16
16
import { MOCK_USER_PROFILE_LINEAGE_RESPONSE } from '../../sdk/mocks/auth' ;
17
+ import { hasProperty } from '@metamask/utils' ;
17
18
18
19
const MOCK_ENTROPY_SOURCE_IDS = [
19
20
'MOCK_ENTROPY_SOURCE_ID' ,
@@ -543,6 +544,7 @@ describe('metadata', () => {
543
544
const controller = new AuthenticationController ( {
544
545
messenger : createMockAuthenticationMessenger ( ) . messenger ,
545
546
metametrics : createMockAuthMetaMetrics ( ) ,
547
+ state : mockSignedInState ( ) ,
546
548
} ) ;
547
549
548
550
expect (
@@ -553,41 +555,114 @@ describe('metadata', () => {
553
555
) ,
554
556
) . toMatchInlineSnapshot ( `
555
557
Object {
556
- "isSignedIn": false ,
558
+ "isSignedIn": true ,
557
559
}
558
560
` ) ;
559
561
} ) ;
560
562
561
- it ( 'includes expected state in state logs' , ( ) => {
562
- const controller = new AuthenticationController ( {
563
- messenger : createMockAuthenticationMessenger ( ) . messenger ,
564
- metametrics : createMockAuthMetaMetrics ( ) ,
565
- } ) ;
563
+ describe ( 'includeInStateLogs' , ( ) => {
564
+ it ( 'includes expected state in state logs, with access token stripped out' , ( ) => {
565
+ const controller = new AuthenticationController ( {
566
+ messenger : createMockAuthenticationMessenger ( ) . messenger ,
567
+ metametrics : createMockAuthMetaMetrics ( ) ,
568
+ state : mockSignedInState ( ) ,
569
+ } ) ;
566
570
567
- expect (
568
- deriveStateFromMetadata (
571
+ const derivedState = deriveStateFromMetadata (
569
572
controller . state ,
570
573
controller . metadata ,
571
574
'includeInStateLogs' ,
572
- ) ,
573
- ) . toMatchInlineSnapshot ( `
574
- Object {
575
- "isSignedIn": false,
576
- }
577
- ` ) ;
575
+ ) ;
576
+
577
+ expect ( derivedState ) . toMatchInlineSnapshot ( `
578
+ Object {
579
+ "isSignedIn": true,
580
+ "srpSessionData": Object {
581
+ "MOCK_ENTROPY_SOURCE_ID": Object {
582
+ "profile": Object {
583
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
584
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
585
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
586
+ },
587
+ "token": Object {
588
+ "expiresIn": 1757528159922,
589
+ "obtainedAt": 0,
590
+ },
591
+ },
592
+ "MOCK_ENTROPY_SOURCE_ID2": Object {
593
+ "profile": Object {
594
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
595
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
596
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
597
+ },
598
+ "token": Object {
599
+ "expiresIn": 1757528159922,
600
+ "obtainedAt": 0,
601
+ },
602
+ },
603
+ },
604
+ }
605
+ ` ) ;
606
+ } ) ;
607
+
608
+ it ( 'returns expected state in state logs when srpSessionData is unset' , ( ) => {
609
+ const controller = new AuthenticationController ( {
610
+ messenger : createMockAuthenticationMessenger ( ) . messenger ,
611
+ metametrics : createMockAuthMetaMetrics ( ) ,
612
+ } ) ;
613
+
614
+ expect (
615
+ deriveStateFromMetadata (
616
+ controller . state ,
617
+ controller . metadata ,
618
+ 'includeInStateLogs' ,
619
+ ) ,
620
+ ) . toMatchInlineSnapshot ( `
621
+ Object {
622
+ "isSignedIn": false,
623
+ }
624
+ ` ) ;
625
+ } ) ;
578
626
} ) ;
579
627
580
628
it ( 'persists expected state' , ( ) => {
581
629
const controller = new AuthenticationController ( {
582
630
messenger : createMockAuthenticationMessenger ( ) . messenger ,
583
631
metametrics : createMockAuthMetaMetrics ( ) ,
632
+ state : mockSignedInState ( ) ,
584
633
} ) ;
585
634
586
635
expect (
587
636
deriveStateFromMetadata ( controller . state , controller . metadata , 'persist' ) ,
588
637
) . toMatchInlineSnapshot ( `
589
638
Object {
590
- "isSignedIn": false,
639
+ "isSignedIn": true,
640
+ "srpSessionData": Object {
641
+ "MOCK_ENTROPY_SOURCE_ID": Object {
642
+ "profile": Object {
643
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
644
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
645
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
646
+ },
647
+ "token": Object {
648
+ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
649
+ "expiresIn": 1757528159923,
650
+ "obtainedAt": 0,
651
+ },
652
+ },
653
+ "MOCK_ENTROPY_SOURCE_ID2": Object {
654
+ "profile": Object {
655
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
656
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
657
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
658
+ },
659
+ "token": Object {
660
+ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
661
+ "expiresIn": 1757528159923,
662
+ "obtainedAt": 0,
663
+ },
664
+ },
665
+ },
591
666
}
592
667
` ) ;
593
668
} ) ;
@@ -596,6 +671,7 @@ describe('metadata', () => {
596
671
const controller = new AuthenticationController ( {
597
672
messenger : createMockAuthenticationMessenger ( ) . messenger ,
598
673
metametrics : createMockAuthMetaMetrics ( ) ,
674
+ state : mockSignedInState ( ) ,
599
675
} ) ;
600
676
601
677
expect (
@@ -606,7 +682,33 @@ describe('metadata', () => {
606
682
) ,
607
683
) . toMatchInlineSnapshot ( `
608
684
Object {
609
- "isSignedIn": false,
685
+ "isSignedIn": true,
686
+ "srpSessionData": Object {
687
+ "MOCK_ENTROPY_SOURCE_ID": Object {
688
+ "profile": Object {
689
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
690
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
691
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
692
+ },
693
+ "token": Object {
694
+ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
695
+ "expiresIn": 1757528159924,
696
+ "obtainedAt": 0,
697
+ },
698
+ },
699
+ "MOCK_ENTROPY_SOURCE_ID2": Object {
700
+ "profile": Object {
701
+ "identifierId": "da9a9fc7b09edde9cc23cec9b7e11a71fb0ab4d2ddd8af8af905306f3e1456fb",
702
+ "metaMetricsId": "561ec651-a844-4b36-a451-04d6eac35740",
703
+ "profileId": "f88227bd-b615-41a3-b0be-467dd781a4ad",
704
+ },
705
+ "token": Object {
706
+ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
707
+ "expiresIn": 1757528159924,
708
+ "obtainedAt": 0,
709
+ },
710
+ },
711
+ },
610
712
}
611
713
` ) ;
612
714
} ) ;
0 commit comments