@@ -1579,252 +1579,6 @@ export default class AutofillService implements AutofillServiceInterface {
1579
1579
return [ expectedDateFormat , dateFormatPatterns ] ;
1580
1580
}
1581
1581
1582
- /**
1583
- * Generates the autofill script for the specified page details and identify cipher item.
1584
- * @param {AutofillScript } fillScript
1585
- * @param {AutofillPageDetails } pageDetails
1586
- * @param {{[p: string]: AutofillField} } filledFields
1587
- * @param {GenerateFillScriptOptions } options
1588
- * @returns {AutofillScript }
1589
- * @private
1590
- */
1591
- private async generateIdentityFillScript (
1592
- fillScript : AutofillScript ,
1593
- pageDetails : AutofillPageDetails ,
1594
- filledFields : { [ id : string ] : AutofillField } ,
1595
- options : GenerateFillScriptOptions ,
1596
- ) : Promise < AutofillScript > {
1597
- if ( await this . configService . getFeatureFlag ( FeatureFlag . GenerateIdentityFillScriptRefactor ) ) {
1598
- return this . _generateIdentityFillScript ( fillScript , pageDetails , filledFields , options ) ;
1599
- }
1600
-
1601
- if ( ! options . cipher . identity ) {
1602
- return null ;
1603
- }
1604
-
1605
- const fillFields : { [ id : string ] : AutofillField } = { } ;
1606
-
1607
- pageDetails . fields . forEach ( ( f ) => {
1608
- if (
1609
- AutofillService . isExcludedFieldType ( f , AutoFillConstants . ExcludedAutofillTypes ) ||
1610
- [ "current-password" , "new-password" ] . includes ( f . autoCompleteType )
1611
- ) {
1612
- return ;
1613
- }
1614
-
1615
- for ( let i = 0 ; i < IdentityAutoFillConstants . IdentityAttributes . length ; i ++ ) {
1616
- const attr = IdentityAutoFillConstants . IdentityAttributes [ i ] ;
1617
- // eslint-disable-next-line
1618
- if ( ! f . hasOwnProperty ( attr ) || ! f [ attr ] || ! f . viewable ) {
1619
- continue ;
1620
- }
1621
-
1622
- // ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
1623
- // ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
1624
- if (
1625
- ! fillFields . name &&
1626
- AutofillService . isFieldMatch (
1627
- f [ attr ] ,
1628
- IdentityAutoFillConstants . FullNameFieldNames ,
1629
- IdentityAutoFillConstants . FullNameFieldNameValues ,
1630
- )
1631
- ) {
1632
- fillFields . name = f ;
1633
- break ;
1634
- } else if (
1635
- ! fillFields . firstName &&
1636
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . FirstnameFieldNames )
1637
- ) {
1638
- fillFields . firstName = f ;
1639
- break ;
1640
- } else if (
1641
- ! fillFields . middleName &&
1642
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . MiddlenameFieldNames )
1643
- ) {
1644
- fillFields . middleName = f ;
1645
- break ;
1646
- } else if (
1647
- ! fillFields . lastName &&
1648
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . LastnameFieldNames )
1649
- ) {
1650
- fillFields . lastName = f ;
1651
- break ;
1652
- } else if (
1653
- ! fillFields . title &&
1654
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . TitleFieldNames )
1655
- ) {
1656
- fillFields . title = f ;
1657
- break ;
1658
- } else if (
1659
- ! fillFields . email &&
1660
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . EmailFieldNames )
1661
- ) {
1662
- fillFields . email = f ;
1663
- break ;
1664
- } else if (
1665
- ! fillFields . address1 &&
1666
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . Address1FieldNames )
1667
- ) {
1668
- fillFields . address1 = f ;
1669
- break ;
1670
- } else if (
1671
- ! fillFields . address2 &&
1672
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . Address2FieldNames )
1673
- ) {
1674
- fillFields . address2 = f ;
1675
- break ;
1676
- } else if (
1677
- ! fillFields . address3 &&
1678
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . Address3FieldNames )
1679
- ) {
1680
- fillFields . address3 = f ;
1681
- break ;
1682
- } else if (
1683
- ! fillFields . address &&
1684
- AutofillService . isFieldMatch (
1685
- f [ attr ] ,
1686
- IdentityAutoFillConstants . AddressFieldNames ,
1687
- IdentityAutoFillConstants . AddressFieldNameValues ,
1688
- )
1689
- ) {
1690
- fillFields . address = f ;
1691
- break ;
1692
- } else if (
1693
- ! fillFields . postalCode &&
1694
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . PostalCodeFieldNames )
1695
- ) {
1696
- fillFields . postalCode = f ;
1697
- break ;
1698
- } else if (
1699
- ! fillFields . city &&
1700
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . CityFieldNames )
1701
- ) {
1702
- fillFields . city = f ;
1703
- break ;
1704
- } else if (
1705
- ! fillFields . state &&
1706
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . StateFieldNames )
1707
- ) {
1708
- fillFields . state = f ;
1709
- break ;
1710
- } else if (
1711
- ! fillFields . country &&
1712
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . CountryFieldNames )
1713
- ) {
1714
- fillFields . country = f ;
1715
- break ;
1716
- } else if (
1717
- ! fillFields . phone &&
1718
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . PhoneFieldNames )
1719
- ) {
1720
- fillFields . phone = f ;
1721
- break ;
1722
- } else if (
1723
- ! fillFields . username &&
1724
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . UserNameFieldNames )
1725
- ) {
1726
- fillFields . username = f ;
1727
- break ;
1728
- } else if (
1729
- ! fillFields . company &&
1730
- AutofillService . isFieldMatch ( f [ attr ] , IdentityAutoFillConstants . CompanyFieldNames )
1731
- ) {
1732
- fillFields . company = f ;
1733
- break ;
1734
- }
1735
- }
1736
- } ) ;
1737
-
1738
- const identity = options . cipher . identity ;
1739
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "title" ) ;
1740
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "firstName" ) ;
1741
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "middleName" ) ;
1742
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "lastName" ) ;
1743
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "address1" ) ;
1744
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "address2" ) ;
1745
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "address3" ) ;
1746
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "city" ) ;
1747
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "postalCode" ) ;
1748
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "company" ) ;
1749
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "email" ) ;
1750
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "phone" ) ;
1751
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "username" ) ;
1752
-
1753
- let filledState = false ;
1754
- if ( fillFields . state && identity . state && identity . state . length > 2 ) {
1755
- const stateLower = identity . state . toLowerCase ( ) ;
1756
- const isoState =
1757
- IdentityAutoFillConstants . IsoStates [ stateLower ] ||
1758
- IdentityAutoFillConstants . IsoProvinces [ stateLower ] ;
1759
- if ( isoState ) {
1760
- filledState = true ;
1761
- this . makeScriptActionWithValue ( fillScript , isoState , fillFields . state , filledFields ) ;
1762
- }
1763
- }
1764
-
1765
- if ( ! filledState ) {
1766
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "state" ) ;
1767
- }
1768
-
1769
- let filledCountry = false ;
1770
- if ( fillFields . country && identity . country && identity . country . length > 2 ) {
1771
- const countryLower = identity . country . toLowerCase ( ) ;
1772
- const isoCountry = IdentityAutoFillConstants . IsoCountries [ countryLower ] ;
1773
- if ( isoCountry ) {
1774
- filledCountry = true ;
1775
- this . makeScriptActionWithValue ( fillScript , isoCountry , fillFields . country , filledFields ) ;
1776
- }
1777
- }
1778
-
1779
- if ( ! filledCountry ) {
1780
- this . makeScriptAction ( fillScript , identity , fillFields , filledFields , "country" ) ;
1781
- }
1782
-
1783
- if ( fillFields . name && ( identity . firstName || identity . lastName ) ) {
1784
- let fullName = "" ;
1785
- if ( AutofillService . hasValue ( identity . firstName ) ) {
1786
- fullName = identity . firstName ;
1787
- }
1788
- if ( AutofillService . hasValue ( identity . middleName ) ) {
1789
- if ( fullName !== "" ) {
1790
- fullName += " " ;
1791
- }
1792
- fullName += identity . middleName ;
1793
- }
1794
- if ( AutofillService . hasValue ( identity . lastName ) ) {
1795
- if ( fullName !== "" ) {
1796
- fullName += " " ;
1797
- }
1798
- fullName += identity . lastName ;
1799
- }
1800
-
1801
- this . makeScriptActionWithValue ( fillScript , fullName , fillFields . name , filledFields ) ;
1802
- }
1803
-
1804
- if ( fillFields . address && AutofillService . hasValue ( identity . address1 ) ) {
1805
- let address = "" ;
1806
- if ( AutofillService . hasValue ( identity . address1 ) ) {
1807
- address = identity . address1 ;
1808
- }
1809
- if ( AutofillService . hasValue ( identity . address2 ) ) {
1810
- if ( address !== "" ) {
1811
- address += ", " ;
1812
- }
1813
- address += identity . address2 ;
1814
- }
1815
- if ( AutofillService . hasValue ( identity . address3 ) ) {
1816
- if ( address !== "" ) {
1817
- address += ", " ;
1818
- }
1819
- address += identity . address3 ;
1820
- }
1821
-
1822
- this . makeScriptActionWithValue ( fillScript , address , fillFields . address , filledFields ) ;
1823
- }
1824
-
1825
- return fillScript ;
1826
- }
1827
-
1828
1582
/**
1829
1583
* Generates the autofill script for the specified page details and identity cipher item.
1830
1584
*
@@ -1833,7 +1587,7 @@ export default class AutofillService implements AutofillServiceInterface {
1833
1587
* @param filledFields - The fields that have already been filled, passed between method references
1834
1588
* @param options - Contains data used to fill cipher items
1835
1589
*/
1836
- private _generateIdentityFillScript (
1590
+ private generateIdentityFillScript (
1837
1591
fillScript : AutofillScript ,
1838
1592
pageDetails : AutofillPageDetails ,
1839
1593
filledFields : { [ id : string ] : AutofillField } ,
0 commit comments