@@ -1421,7 +1421,7 @@ describe('admin.auth', () => {
1421
1421
1422
1422
describe ( 'importUsers()' , ( ) => {
1423
1423
const randomUid = 'import_' + generateRandomString ( 20 ) . toLowerCase ( ) ;
1424
- let importUserRecord : any ;
1424
+ let importUserRecord : admin . auth . UserImportRecord ;
1425
1425
const rawPassword = 'password' ;
1426
1426
const rawSalt = 'NaCl' ;
1427
1427
// Simulate a user stored using SCRYPT being migrated to Firebase Auth via importUsers.
@@ -1635,15 +1635,15 @@ describe('admin.auth', () => {
1635
1635
return admin . auth ( ) . getUser ( uid ) ;
1636
1636
} ) . then ( ( userRecord ) => {
1637
1637
// The phone number provider will be appended to the list of accounts.
1638
- importUserRecord . providerData . push ( {
1639
- uid : importUserRecord . phoneNumber ,
1638
+ importUserRecord . providerData ? .push ( {
1639
+ uid : importUserRecord . phoneNumber ! ,
1640
1640
providerId : 'phone' ,
1641
- phoneNumber : importUserRecord . phoneNumber ,
1641
+ phoneNumber : importUserRecord . phoneNumber ! ,
1642
1642
} ) ;
1643
1643
const actualUserRecord : { [ key : string ] : any } = userRecord . toJSON ( ) ;
1644
1644
for ( const key of Object . keys ( importUserRecord ) ) {
1645
1645
expect ( JSON . stringify ( actualUserRecord [ key ] ) )
1646
- . to . be . equal ( JSON . stringify ( importUserRecord [ key ] ) ) ;
1646
+ . to . be . equal ( JSON . stringify ( ( importUserRecord as any ) [ key ] ) ) ;
1647
1647
}
1648
1648
} ) . should . eventually . be . fulfilled ;
1649
1649
} ) ;
@@ -1652,6 +1652,23 @@ describe('admin.auth', () => {
1652
1652
const uid = generateRandomString ( 20 ) . toLowerCase ( ) ;
1653
1653
const email = uid + '@example.com' ;
1654
1654
const now = new Date ( 1476235905000 ) . toUTCString ( ) ;
1655
+ const enrolledFactors : admin . auth . UpdatePhoneMultiFactorInfoRequest [ ] = [
1656
+ {
1657
+ uid : 'mfaUid1' ,
1658
+ phoneNumber : '+16505550001' ,
1659
+ displayName : 'Work phone number' ,
1660
+ factorId : 'phone' ,
1661
+ enrollmentTime : now ,
1662
+ } ,
1663
+ {
1664
+ uid : 'mfaUid2' ,
1665
+ phoneNumber : '+16505550002' ,
1666
+ displayName : 'Personal phone number' ,
1667
+ factorId : 'phone' ,
1668
+ enrollmentTime : now ,
1669
+ } ,
1670
+ ] ;
1671
+
1655
1672
importUserRecord = {
1656
1673
uid,
1657
1674
email,
@@ -1671,22 +1688,7 @@ describe('admin.auth', () => {
1671
1688
} ,
1672
1689
] ,
1673
1690
multiFactor : {
1674
- enrolledFactors : [
1675
- {
1676
- uid : 'mfaUid1' ,
1677
- phoneNumber : '+16505550001' ,
1678
- displayName : 'Work phone number' ,
1679
- factorId : 'phone' ,
1680
- enrollmentTime : now ,
1681
- } ,
1682
- {
1683
- uid : 'mfaUid2' ,
1684
- phoneNumber : '+16505550002' ,
1685
- displayName : 'Personal phone number' ,
1686
- factorId : 'phone' ,
1687
- enrollmentTime : now ,
1688
- } ,
1689
- ] ,
1691
+ enrolledFactors,
1690
1692
} ,
1691
1693
} ;
1692
1694
uids . push ( importUserRecord . uid ) ;
@@ -1702,7 +1704,7 @@ describe('admin.auth', () => {
1702
1704
const actualUserRecord : { [ key : string ] : any } = userRecord . toJSON ( ) ;
1703
1705
expect ( actualUserRecord . multiFactor . enrolledFactors . length ) . to . equal ( 2 ) ;
1704
1706
expect ( actualUserRecord . multiFactor . enrolledFactors )
1705
- . to . deep . equal ( importUserRecord . multiFactor . enrolledFactors ) ;
1707
+ . to . deep . equal ( importUserRecord . multiFactor ? .enrolledFactors ) ;
1706
1708
} ) . should . eventually . be . fulfilled ;
1707
1709
} ) ;
1708
1710
@@ -1741,7 +1743,9 @@ describe('admin.auth', () => {
1741
1743
* @retunr {Promise<void>} A promise that resolved on success.
1742
1744
*/
1743
1745
function testImportAndSignInUser (
1744
- importUserRecord : any , importOptions : any , rawPassword : string ) : Promise < void > {
1746
+ importUserRecord : admin . auth . UserImportRecord ,
1747
+ importOptions : any ,
1748
+ rawPassword : string ) : Promise < void > {
1745
1749
const users = [ importUserRecord ] ;
1746
1750
// Import the user record.
1747
1751
return admin . auth ( ) . importUsers ( users , importOptions )
@@ -1751,7 +1755,7 @@ function testImportAndSignInUser(
1751
1755
expect ( result . successCount ) . to . equal ( 1 ) ;
1752
1756
expect ( result . errors . length ) . to . equal ( 0 ) ;
1753
1757
// Sign in with an email and password to the imported account.
1754
- return clientAuth ( ) . signInWithEmailAndPassword ( users [ 0 ] . email , rawPassword ) ;
1758
+ return clientAuth ( ) . signInWithEmailAndPassword ( users [ 0 ] . email ! , rawPassword ) ;
1755
1759
} )
1756
1760
. then ( ( { user} ) => {
1757
1761
// Confirm successful sign-in.
0 commit comments