@authing/react-ui-components 3.1.39-beta.0 → 3.1.39-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -1575,6 +1575,329 @@ declare module '@authing/react-ui-components/components/Guard/config' {
1575
1575
  }
1576
1576
  export const getDefaultGuardLocalConfig: () => GuardLocalConfig;
1577
1577
 
1578
+ }
1579
+ declare module '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts' {
1580
+ /**
1581
+ * 整体的思路:
1582
+ * 在所有登录方式中,当进行登录时保存登录方式(FE侧自定义)
1583
+ * 之后在登录成功(onLogin)中,触发store的方法保存用户信息以及对应的登录方式进入localStorage。
1584
+ * 当用户再次打开页面时,拿出数据进行对比。(主要对比 LoginWay ),TODO: 这里的代码主要显得乱的原因是因为枚举的不正当使用。(主要要和Server端进行互相映射,后续维护时可优化)
1585
+ *
1586
+ * 核心思路:登录成功时,保存的FE侧自定义 LoginWay
1587
+ * 再次打开页面时,初始化时先根据 FE 自定义的 LoginWay 跳转到不同的 tab 下(way)下使用 account 进行回填。TODO: 这里也可优化,应该在登录成功时候就进行 LoginWay 的格式化,而非转来转去。(但是这样无法直观的体现是哪种方式进行登录)
1588
+ */
1589
+ import { SelectOptions } from '@authing/react-ui-components/components/Login/multipleAccounts/panel';
1590
+ export const QR_CODE_WAY: LoginWay[];
1591
+ /**
1592
+ * 登录时所有支持的登录列表(前端定义列表)
1593
+ * 这里稍微有点乱 因为Login中的登录方式和这里的不匹配,暂时放在了一起
1594
+ */
1595
+ export type LoginWay = 'email' | 'phone' | 'password' | 'phone-code' | 'email-code' | 'social' | 'wechat-miniprogram-qrcode' | 'wechatmp-qrcode' | 'app-qrcode' | 'ad' | 'ldap' | 'ldap-password' | 'ldap-email' | 'ldap-phone';
1596
+ /**
1597
+ * when: 多账号页面跳转进入登录页面
1598
+ * 携带的回填数据信息
1599
+ */
1600
+ export interface BackFillMultipleState extends Omit<User, 'id' | 'name' | 'nickname' | 'username' | 'phone' | 'email' | 'photo' | '_updateTime'> {
1601
+ /**
1602
+ * 回填的账号名称 邮箱/用户名/手机
1603
+ */
1604
+ account: string;
1605
+ }
1606
+ /**
1607
+ * Store instance
1608
+ */
1609
+ export type StoreInstance = ReturnType<MultipleAccount['getStore']>;
1610
+ /**
1611
+ * 当前 userId 对应的类型
1612
+ */
1613
+ export interface CurrentStore {
1614
+ [id: string]: User;
1615
+ }
1616
+ export interface User {
1617
+ /**
1618
+ * userId
1619
+ */
1620
+ id: string;
1621
+ /**
1622
+ * Tab 栏状态
1623
+ */
1624
+ tab: 'input' | 'qrcode';
1625
+ /**
1626
+ * 登录方式
1627
+ */
1628
+ way: LoginWay;
1629
+ /**
1630
+ * 姓名
1631
+ */
1632
+ name?: string | null;
1633
+ /**
1634
+ * 昵称
1635
+ */
1636
+ nickname?: string | null;
1637
+ /**
1638
+ * 用户名
1639
+ */
1640
+ username?: string | null;
1641
+ /**
1642
+ * 手机号
1643
+ */
1644
+ phone?: string | null;
1645
+ /**
1646
+ * 邮箱
1647
+ */
1648
+ email?: string | null;
1649
+ /**
1650
+ * 头像
1651
+ */
1652
+ photo?: string | null;
1653
+ /**
1654
+ * qrCodeId 对应的ID
1655
+ */
1656
+ qrCodeId?: string;
1657
+ /**
1658
+ * 国际化短信区号
1659
+ */
1660
+ phoneCountryCode?: string;
1661
+ /**
1662
+ * 国际化短信选择框回填
1663
+ */
1664
+ areaCode?: string;
1665
+ /**
1666
+ * 登录时间
1667
+ */
1668
+ _updateTime?: string;
1669
+ }
1670
+ class MultipleAccount {
1671
+ /**
1672
+ * 原始的登录账号
1673
+ */
1674
+ private originAccount;
1675
+ private originWay;
1676
+ /**
1677
+ * 原始的 localStore 值
1678
+ */
1679
+ private originStore;
1680
+ /**
1681
+ * 当前 AppId Store
1682
+ */
1683
+ private currentStore;
1684
+ /**
1685
+ * 单账号直接回填
1686
+ */
1687
+ private firstBackFillData?;
1688
+ /**
1689
+ * server 返回支持的登录方式
1690
+ */
1691
+ private serverSideLoginMethods;
1692
+ /**
1693
+ * 是否显示多账号登录页面
1694
+ * true 存在
1695
+ */
1696
+ private memberState;
1697
+ /**
1698
+ * 二维码登录时的ID
1699
+ */
1700
+ private qrCodeId?;
1701
+ /**
1702
+ * 国际化短信前缀 区号
1703
+ */
1704
+ private phoneCountryCode?;
1705
+ /**
1706
+ * 国际化短信前缀 选中地区编号
1707
+ */
1708
+ private areaCode?;
1709
+ private tabStatus?;
1710
+ /**
1711
+ * 当前登录二级状态
1712
+ */
1713
+ private loginWay?;
1714
+ private appId;
1715
+ /**
1716
+ * 是否开启国际化短信
1717
+ */
1718
+ private isInternationSms?;
1719
+ constructor();
1720
+ /**
1721
+ * 页面首次加载时初始化 Store
1722
+ * 从 LocalStore 中拿值 放到这里来
1723
+ */
1724
+ private initStore;
1725
+ /**
1726
+ * 初始化记住账号相关信息
1727
+ * @param normalCount
1728
+ * @returns
1729
+ */
1730
+ private initMemberState;
1731
+ /**
1732
+ * 获取当前ID下有效账号个数
1733
+ * @returns qrCount 有效的二维码登录个数 normalCount 有效的账号登录方式
1734
+ */
1735
+ private memberStateCount;
1736
+ /**
1737
+ * 初始化第一次的数据 TODO: 逻辑有点脏 待整理
1738
+ */
1739
+ private initBackfillData;
1740
+ /**
1741
+ * 根据前端存储的登录方式返回后端映射方式
1742
+ * @param front
1743
+ */
1744
+ private getServerLoginMethodByFront;
1745
+ /**
1746
+ * 当前 Store DONE
1747
+ */
1748
+ private getCurrentStore;
1749
+ /**
1750
+ * 国际化短信过滤
1751
+ * true 表示通过 需要保留
1752
+ * false 表示不通过 需要过滤
1753
+ */
1754
+ private validateInternationSms;
1755
+ /**
1756
+ * 校验有效的登录方式账号
1757
+ * @param user
1758
+ * @param serverSideLoginMethods
1759
+ * @returns
1760
+ */
1761
+ private validateMethod;
1762
+ /**
1763
+ *
1764
+ * @param tab 一级Tab状态
1765
+ * @param way 二级Tab状态
1766
+ * @param id 二维码登录时 记录对应的二维码 ID
1767
+ */
1768
+ private setLoginWay;
1769
+ /**
1770
+ * 设置/更新 store 内的用户信息
1771
+ */
1772
+ private setUserInfo;
1773
+ /**
1774
+ * 持久化保存
1775
+ */
1776
+ private saveStore;
1777
+ /**
1778
+ * 根据登录的 account 判断本次登录的方式
1779
+ * @param account 登录输入的账号
1780
+ * @param param1 登录成功返回的相关信息 用户名/手机号/邮箱
1781
+ * @returns
1782
+ */
1783
+ private setLoginWayByHttpData;
1784
+ /**
1785
+ * 根据登录的 account 判断本次LDAP登录方式
1786
+ * @param account 登录输入的账号
1787
+ * @param param1 登录成功返回的相关信息 用户名/手机号/邮箱
1788
+ * @returns
1789
+ */
1790
+ private setLoginWayByLDAPData;
1791
+ /**
1792
+ * 根据用户 ID 删除 localStorage 中当前用户 ID
1793
+ */
1794
+ private delUserById;
1795
+ /**
1796
+ * 获得多账号登录页面的所有用户列表
1797
+ * @param excludeWays
1798
+ */
1799
+ private getMemoUser;
1800
+ /**
1801
+ * 根据 id 获得当前已登录的用户信息
1802
+ * @param userId
1803
+ * @returns User / undefined
1804
+ */
1805
+ private getMemoSingleUser;
1806
+ /**
1807
+ * 该方法仅仅需要回填账号的登录方式,其他都不计入
1808
+ * 当用户名/手机号/邮箱/AD/LDAP 相同时,根据登录顺序匹配不同的账号
1809
+ * 根据记住的用户登录方式获取对应的登录账户名
1810
+ * @param way
1811
+ * @param user
1812
+ * @returns
1813
+ */
1814
+ private getAccountByWay;
1815
+ private _mappingUser;
1816
+ /**
1817
+ * 外部暴露方法
1818
+ */
1819
+ getStore: () => {
1820
+ initStore: (appId: string, options: {
1821
+ serverSideLoginMethods: LoginWay[];
1822
+ isInternationSms: boolean;
1823
+ }) => void;
1824
+ setLoginWay: (tab: 'input' | 'qrcode', way: LoginWay, id?: string | undefined, internation?: {
1825
+ phoneCountryCode: string;
1826
+ areaCode: string;
1827
+ } | undefined) => void;
1828
+ setUserInfo: (user: Pick<User & {
1829
+ id: string;
1830
+ }, "email" | "username" | "phone" | "id" | "nickname" | "photo" | "name" | "_updateTime" | "qrCodeId" | "areaCode">) => void;
1831
+ setLoginWayByHttpData: (account: string, data: {
1832
+ username?: string | undefined;
1833
+ phone?: string | undefined;
1834
+ email?: string | undefined;
1835
+ }) => void;
1836
+ setLoginWayByLDAPData: (account: string, data: {
1837
+ name?: string | undefined;
1838
+ phone?: string | undefined;
1839
+ email?: string | undefined;
1840
+ }) => void;
1841
+ getMemoUser: (excludeWays?: LoginWay[]) => SelectOptions[];
1842
+ getMemoSingleUser: (id: string) => {
1843
+ way: LoginWay;
1844
+ account: string;
1845
+ } | undefined;
1846
+ delUserById: (id: string) => string;
1847
+ getMemberState: () => boolean;
1848
+ getFirstBackFillData: () => BackFillMultipleState | undefined;
1849
+ getOriginAccount: () => string;
1850
+ getOriginWay: () => string;
1851
+ };
1852
+ }
1853
+ /**
1854
+ * MultipleAccounts 相关 Hook
1855
+ * Finally Config 类型过滤
1856
+ */
1857
+ const useMultipleAccounts: ({ appId, finallyConfig }: {
1858
+ appId?: string | undefined;
1859
+ finallyConfig?: any;
1860
+ }) => {
1861
+ instance: {
1862
+ initStore: (appId: string, options: {
1863
+ serverSideLoginMethods: LoginWay[];
1864
+ isInternationSms: boolean;
1865
+ }) => void;
1866
+ setLoginWay: (tab: 'input' | 'qrcode', way: LoginWay, id?: string | undefined, internation?: {
1867
+ phoneCountryCode: string;
1868
+ areaCode: string;
1869
+ } | undefined) => void;
1870
+ setUserInfo: (user: Pick<User & {
1871
+ id: string;
1872
+ }, "email" | "username" | "phone" | "id" | "nickname" | "photo" | "name" | "_updateTime" | "qrCodeId" | "areaCode">) => void;
1873
+ setLoginWayByHttpData: (account: string, data: {
1874
+ username?: string | undefined;
1875
+ phone?: string | undefined;
1876
+ email?: string | undefined;
1877
+ }) => void;
1878
+ setLoginWayByLDAPData: (account: string, data: {
1879
+ name?: string | undefined;
1880
+ phone?: string | undefined;
1881
+ email?: string | undefined;
1882
+ }) => void;
1883
+ getMemoUser: (excludeWays?: LoginWay[]) => SelectOptions[];
1884
+ getMemoSingleUser: (id: string) => {
1885
+ way: LoginWay;
1886
+ account: string;
1887
+ } | undefined;
1888
+ delUserById: (id: string) => string;
1889
+ getMemberState: () => boolean;
1890
+ getFirstBackFillData: () => BackFillMultipleState | undefined;
1891
+ getOriginAccount: () => string;
1892
+ getOriginWay: () => string;
1893
+ } | undefined;
1894
+ isMultipleAccount: boolean;
1895
+ referMultipleState: (type: 'login' | 'multiple', data?: BackFillMultipleState | undefined) => void;
1896
+ multipleAccountData: BackFillMultipleState | undefined;
1897
+ clearBackFillData: () => void;
1898
+ };
1899
+ export default useMultipleAccounts;
1900
+
1578
1901
  }
1579
1902
  declare module '@authing/react-ui-components/components/Guard/core/index' {
1580
1903
  /// <reference types="react" />
@@ -1634,7 +1957,39 @@ declare module '@authing/react-ui-components/components/Guard/event' {
1634
1957
  export interface GuardEvents extends LoginEvents, RegisterEvents, CompleteInfoEvents, ForgetPasswordEvents, IdentityBindingEvents, IdentityBindingAskEvents {
1635
1958
  onBeforeChangeModule?: (key: GuardModuleType, initData?: any) => boolean | Promise<boolean>;
1636
1959
  }
1637
- export const guardEventsFilter: (props: any, openEventsMapping?: boolean | undefined) => GuardEvents;
1960
+ export const guardEventsFilter: (props: any, multipleInstance?: {
1961
+ initStore: (appId: string, options: {
1962
+ serverSideLoginMethods: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay[];
1963
+ isInternationSms: boolean;
1964
+ }) => void;
1965
+ setLoginWay: (tab: "input" | "qrcode", way: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay, id?: string | undefined, internation?: {
1966
+ phoneCountryCode: string;
1967
+ areaCode: string;
1968
+ } | undefined) => void;
1969
+ setUserInfo: (user: Pick<import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").User & {
1970
+ id: string;
1971
+ }, "email" | "username" | "phone" | "id" | "nickname" | "photo" | "name" | "_updateTime" | "qrCodeId" | "areaCode">) => void;
1972
+ setLoginWayByHttpData: (account: string, data: {
1973
+ username?: string | undefined;
1974
+ phone?: string | undefined;
1975
+ email?: string | undefined;
1976
+ }) => void;
1977
+ setLoginWayByLDAPData: (account: string, data: {
1978
+ name?: string | undefined;
1979
+ phone?: string | undefined;
1980
+ email?: string | undefined;
1981
+ }) => void;
1982
+ getMemoUser: (excludeWays?: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay[]) => import("../Login/multipleAccounts/panel").SelectOptions[];
1983
+ getMemoSingleUser: (id: string) => {
1984
+ way: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay;
1985
+ account: string;
1986
+ } | undefined;
1987
+ delUserById: (id: string) => string;
1988
+ getMemberState: () => boolean;
1989
+ getFirstBackFillData: () => import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").BackFillMultipleState | undefined;
1990
+ getOriginAccount: () => string;
1991
+ getOriginWay: () => string;
1992
+ } | undefined, openEventsMapping?: boolean | undefined) => GuardEvents;
1638
1993
  export const guardEventsHijacking: (events: GuardEvents, openEventsMapping?: boolean | undefined) => GuardEvents;
1639
1994
  export const GuardEventsCamelToKebabMapping: {
1640
1995
  readonly onLoad: "load";
@@ -1926,6 +2281,7 @@ declare module '@authing/react-ui-components/components/Login/codemap' {
1926
2281
  declare module '@authing/react-ui-components/components/Login/core/withAD' {
1927
2282
  /// <reference types="react" />
1928
2283
  import { Agreement } from '@authing/react-ui-components/components/AuthingGuard/api/index';
2284
+ import { BackFillMultipleState, StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
1929
2285
  interface LoginWithADProps {
1930
2286
  publicKey: string;
1931
2287
  autoRegister?: boolean;
@@ -1933,6 +2289,14 @@ declare module '@authing/react-ui-components/components/Login/core/withAD' {
1933
2289
  onLoginFailed: any;
1934
2290
  onBeforeLogin: any;
1935
2291
  agreements: Agreement[];
2292
+ /**
2293
+ * 回填的数据
2294
+ */
2295
+ backfillData?: BackFillMultipleState;
2296
+ /**
2297
+ * 根据输入的账号 & 返回获得对应的登录方法
2298
+ */
2299
+ multipleInstance?: StoreInstance;
1936
2300
  }
1937
2301
  export const LoginWithAD: (props: LoginWithADProps) => JSX.Element;
1938
2302
  export {};
@@ -1940,17 +2304,21 @@ declare module '@authing/react-ui-components/components/Login/core/withAD' {
1940
2304
  }
1941
2305
  declare module '@authing/react-ui-components/components/Login/core/withAppQrcode' {
1942
2306
  /// <reference types="react" />
2307
+ import { StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
1943
2308
  interface LoginWithAppQrcodeProps {
1944
2309
  onLoginSuccess: any;
1945
2310
  canLoop: boolean;
2311
+ qrCodeScanOptions: any;
2312
+ multipleInstance?: StoreInstance;
1946
2313
  }
1947
- export const LoginWithAppQrcode: (props: LoginWithAppQrcodeProps) => JSX.Element | null;
2314
+ export const LoginWithAppQrcode: (props: LoginWithAppQrcodeProps) => JSX.Element;
1948
2315
  export {};
1949
2316
 
1950
2317
  }
1951
2318
  declare module '@authing/react-ui-components/components/Login/core/withLDAP' {
1952
2319
  /// <reference types="react" />
1953
2320
  import { Agreement } from '@authing/react-ui-components/components/AuthingGuard/api/index';
2321
+ import { BackFillMultipleState, StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
1954
2322
  interface LoginWithLDAPProps {
1955
2323
  publicKey: string;
1956
2324
  autoRegister?: boolean;
@@ -1959,6 +2327,14 @@ declare module '@authing/react-ui-components/components/Login/core/withLDAP' {
1959
2327
  onLoginFailed: any;
1960
2328
  onBeforeLogin: any;
1961
2329
  agreements: Agreement[];
2330
+ /**
2331
+ * 根据输入的账号 & 返回获得对应的登录方法
2332
+ */
2333
+ multipleInstance?: StoreInstance;
2334
+ /**
2335
+ * 多账号回填的数据
2336
+ */
2337
+ backfillData?: BackFillMultipleState;
1962
2338
  }
1963
2339
  export const LoginWithLDAP: (props: LoginWithLDAPProps) => JSX.Element;
1964
2340
  export {};
@@ -1999,6 +2375,7 @@ declare module '@authing/react-ui-components/components/Login/core/withPassword/
1999
2375
  import { Agreement, PasswordLoginMethods } from '@authing/react-ui-components/components/AuthingGuard/api/index';
2000
2376
  import { LoginMethods } from '@authing/react-ui-components/components/index';
2001
2377
  import { AuthingResponse } from '@authing/react-ui-components/components/_utils/http';
2378
+ import { BackFillMultipleState, StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2002
2379
  interface LoginWithPasswordProps {
2003
2380
  publicKey: string;
2004
2381
  autoRegister?: boolean;
@@ -2012,6 +2389,14 @@ declare module '@authing/react-ui-components/components/Login/core/withPassword/
2012
2389
  loginWay?: LoginMethods;
2013
2390
  submitButText?: string;
2014
2391
  saveIdentify?: (type: LoginMethods, identity: string) => void;
2392
+ /**
2393
+ * 根据输入的账号 & 返回获得对应的登录方法
2394
+ */
2395
+ multipleInstance?: StoreInstance;
2396
+ /**
2397
+ * 多账号回填的数据
2398
+ */
2399
+ backfillData?: BackFillMultipleState;
2015
2400
  }
2016
2401
  export const LoginWithPassword: (props: LoginWithPasswordProps) => JSX.Element;
2017
2402
  export {};
@@ -2045,6 +2430,10 @@ declare module '@authing/react-ui-components/components/Login/core/withVerifyCod
2045
2430
  import React, { FC } from 'react';
2046
2431
  import './styles.less';
2047
2432
  export interface VirtualDropdownProps {
2433
+ /**
2434
+ * 回填的国际化区号
2435
+ */
2436
+ regionCode?: string;
2048
2437
  value?: string;
2049
2438
  onChange?: (value: string) => void;
2050
2439
  style?: React.CSSProperties;
@@ -2055,7 +2444,8 @@ declare module '@authing/react-ui-components/components/Login/core/withVerifyCod
2055
2444
  declare module '@authing/react-ui-components/components/Login/core/withVerifyCode/index' {
2056
2445
  /// <reference types="react" />
2057
2446
  import './styles.less';
2058
- export const LoginWithVerifyCode: (props: any) => JSX.Element;
2447
+ const LoginWithVerifyCode: (props: any) => JSX.Element;
2448
+ export { LoginWithVerifyCode };
2059
2449
 
2060
2450
  }
2061
2451
  declare module '@authing/react-ui-components/components/Login/core/withVerifyCode/inputIdentify' {
@@ -2070,23 +2460,99 @@ declare module '@authing/react-ui-components/components/Login/core/withVerifyCod
2070
2460
  }
2071
2461
  declare module '@authing/react-ui-components/components/Login/core/withWechatMiniQrcode' {
2072
2462
  /// <reference types="react" />
2463
+ import { StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2073
2464
  interface LoginWithWechatMiniQrcodeProps {
2074
2465
  onLoginSuccess: any;
2075
2466
  canLoop: boolean;
2467
+ qrCodeScanOptions: any;
2468
+ id: string;
2469
+ multipleInstance?: StoreInstance;
2076
2470
  }
2077
- export const LoginWithWechatMiniQrcode: (props: LoginWithWechatMiniQrcodeProps) => JSX.Element | null;
2471
+ export const LoginWithWechatMiniQrcode: (props: LoginWithWechatMiniQrcodeProps) => JSX.Element;
2078
2472
  export {};
2079
2473
 
2080
2474
  }
2081
2475
  declare module '@authing/react-ui-components/components/Login/core/withWechatmpQrcode' {
2082
2476
  /// <reference types="react" />
2477
+ import { StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2083
2478
  interface LoginWithWechatmpQrcodeProps {
2084
2479
  onLoginSuccess: any;
2085
2480
  canLoop: boolean;
2481
+ qrCodeScanOptions: any;
2482
+ id: string;
2483
+ /**
2484
+ * 多账号存储实例
2485
+ */
2486
+ multipleInstance?: StoreInstance;
2086
2487
  }
2087
- export const LoginWithWechatmpQrcode: (props: LoginWithWechatmpQrcodeProps) => JSX.Element | null;
2488
+ export const LoginWithWechatmpQrcode: (props: LoginWithWechatmpQrcodeProps) => JSX.Element;
2088
2489
  export {};
2089
2490
 
2491
+ }
2492
+ declare module '@authing/react-ui-components/components/Login/hooks/useLoginMultiple' {
2493
+ /// <reference types="react" />
2494
+ import { FormInstance } from 'antd/lib/form';
2495
+ import { BackFillMultipleState, LoginWay } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2496
+ /**
2497
+ * 多账号登录下 账户 & 登录方式自动回填
2498
+ * TODO: HOOK 参数有时间整理成为对象,开始没有想到有这么多
2499
+ * 调用地方 core 中需要回填的两个登录方式
2500
+ */
2501
+ function useLoginMultipleBackFill(options: {
2502
+ form: FormInstance<any>;
2503
+ way: LoginWay;
2504
+ formKey: string;
2505
+ backfillData?: BackFillMultipleState;
2506
+ isOnlyInternationSms?: boolean;
2507
+ setAreaCode?: React.Dispatch<React.SetStateAction<string>>;
2508
+ cancelBackfill?: boolean;
2509
+ }): void;
2510
+ /**
2511
+ * 多账号统一状态管理
2512
+ * @param setLoginWay
2513
+ * @returns
2514
+ */
2515
+ function useLoginMultiple(setLoginWay: React.Dispatch<any>): {
2516
+ isMultipleAccount: boolean;
2517
+ multipleInstance: {
2518
+ initStore: (appId: string, options: {
2519
+ serverSideLoginMethods: LoginWay[];
2520
+ isInternationSms: boolean;
2521
+ }) => void;
2522
+ setLoginWay: (tab: "input" | "qrcode", way: LoginWay, id?: string | undefined, internation?: {
2523
+ phoneCountryCode: string;
2524
+ areaCode: string;
2525
+ } | undefined) => void;
2526
+ setUserInfo: (user: Pick<import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").User & {
2527
+ id: string;
2528
+ }, "email" | "username" | "phone" | "id" | "nickname" | "photo" | "name" | "_updateTime" | "qrCodeId" | "areaCode">) => void;
2529
+ setLoginWayByHttpData: (account: string, data: {
2530
+ username?: string | undefined;
2531
+ phone?: string | undefined;
2532
+ email?: string | undefined;
2533
+ }) => void;
2534
+ setLoginWayByLDAPData: (account: string, data: {
2535
+ name?: string | undefined;
2536
+ phone?: string | undefined;
2537
+ email?: string | undefined;
2538
+ }) => void;
2539
+ getMemoUser: (excludeWays?: LoginWay[]) => import("@authing/react-ui-components/components/Login/multipleAccounts/panel").SelectOptions[];
2540
+ getMemoSingleUser: (id: string) => {
2541
+ way: LoginWay;
2542
+ account: string;
2543
+ } | undefined;
2544
+ delUserById: (id: string) => string;
2545
+ getMemberState: () => boolean;
2546
+ getFirstBackFillData: () => BackFillMultipleState | undefined;
2547
+ getOriginAccount: () => string;
2548
+ getOriginWay: () => string;
2549
+ } | undefined;
2550
+ referMultipleState: ((type: "login" | "multiple") => void) | undefined;
2551
+ backfillData: BackFillMultipleState | undefined;
2552
+ defaultQrWay: string | undefined;
2553
+ };
2554
+ export { useLoginMultipleBackFill, useLoginMultiple };
2555
+
2090
2556
  }
2091
2557
  declare module '@authing/react-ui-components/components/Login/index' {
2092
2558
  /// <reference types="react" />
@@ -2135,6 +2601,79 @@ declare module '@authing/react-ui-components/components/Login/interface' {
2135
2601
  }
2136
2602
  export const getDefaultLoginConfig: () => LoginConfig;
2137
2603
 
2604
+ }
2605
+ declare module '@authing/react-ui-components/components/Login/multipleAccounts/index' {
2606
+ import React from 'react';
2607
+ import { LoginWay, StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2608
+ import { GuardModuleType } from '@authing/react-ui-components/components/Guard/index';
2609
+ interface MultipleAccountsProps {
2610
+ /**
2611
+ * 多账号存储实例
2612
+ */
2613
+ multipleInstance?: StoreInstance;
2614
+ /**
2615
+ * 切换 Guard 方法
2616
+ */
2617
+ changeModule?: (moduleName: GuardModuleType, initData?: any) => Promise<void>;
2618
+ /**
2619
+ * 切换多账号状态
2620
+ */
2621
+ referMultipleState?: (type: 'login' | 'multiple', data?: {
2622
+ account: string;
2623
+ way: LoginWay;
2624
+ }) => void;
2625
+ }
2626
+ const MultipleAccounts: React.NamedExoticComponent<MultipleAccountsProps>;
2627
+ export { MultipleAccounts };
2628
+
2629
+ }
2630
+ declare module '@authing/react-ui-components/components/Login/multipleAccounts/panel' {
2631
+ import React from 'react';
2632
+ import './style.less';
2633
+ interface SelectPanelProps {
2634
+ lists: SelectOptions[];
2635
+ /**
2636
+ * 点击删除
2637
+ */
2638
+ handleDel: (id: string) => void;
2639
+ /**
2640
+ * 点击 li
2641
+ */
2642
+ onClick: (id: string) => void;
2643
+ }
2644
+ export interface SelectOptions {
2645
+ /**
2646
+ * 头像
2647
+ */
2648
+ photo?: string;
2649
+ /**
2650
+ * 标题
2651
+ */
2652
+ title?: string;
2653
+ /**
2654
+ * 描述
2655
+ */
2656
+ description?: string;
2657
+ /**
2658
+ * 用户 ID 唯一标识符
2659
+ */
2660
+ id: string | 'other';
2661
+ /**
2662
+ * 显示操作栏 default: true
2663
+ */
2664
+ operation?: boolean;
2665
+ /**
2666
+ * 登录时间
2667
+ */
2668
+ _updateTime: number;
2669
+ /**
2670
+ * 替代图片元素
2671
+ */
2672
+ element?: React.ReactElement;
2673
+ }
2674
+ const SelectPanel: React.FC<SelectPanelProps>;
2675
+ export { SelectPanel };
2676
+
2138
2677
  }
2139
2678
  declare module '@authing/react-ui-components/components/Login/socialLogin/IdpButton/index' {
2140
2679
  /// <reference types="react" />
@@ -2146,6 +2685,7 @@ declare module '@authing/react-ui-components/components/Login/socialLogin/index'
2146
2685
  import { ApplicationConfig, SocialConnectionItem } from '@authing/react-ui-components/components/AuthingGuard/api/index';
2147
2686
  import './style.less';
2148
2687
  import { GuardLocalConfig } from '@authing/react-ui-components/components/Guard/index';
2688
+ import { StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
2149
2689
  export interface SocialLoginProps {
2150
2690
  appId: string;
2151
2691
  config: GuardLocalConfig;
@@ -2153,6 +2693,10 @@ declare module '@authing/react-ui-components/components/Login/socialLogin/index'
2153
2693
  onLoginSuccess: any;
2154
2694
  enterpriseConnectionObjs: ApplicationConfig['identityProviders'];
2155
2695
  socialConnectionObjs: SocialConnectionItem[];
2696
+ /**
2697
+ * 根据输入的账号 & 返回获得对应的登录方法
2698
+ */
2699
+ multipleInstance?: StoreInstance;
2156
2700
  }
2157
2701
  export const SocialLogin: React.FC<SocialLoginProps>;
2158
2702
 
@@ -2429,233 +2973,6 @@ declare module '@authing/react-ui-components/components/NeedHelpView/index' {
2429
2973
  /// <reference types="react" />
2430
2974
  export const GuardNeedHelpView: (props: any) => JSX.Element;
2431
2975
 
2432
- }
2433
- declare module '@authing/react-ui-components/components/Qrcode/UiQrCode' {
2434
- import React from 'react';
2435
- import './index.less';
2436
- import { CodeStatusDescriptions } from '@authing/react-ui-components/components/Qrcode/WorkQrCode';
2437
- export type CodeStatus = 'loading' | 'ready' | 'already' | 'success' | 'error' | 'expired' | 'cancel' | 'MFA';
2438
- export const prefix = "refactor";
2439
- export interface UiQrProps {
2440
- /**
2441
- * Loading 组件
2442
- */
2443
- loadingComponent?: React.ReactElement;
2444
- /**
2445
- * 二维码组件三种状态
2446
- * ready 准备状态
2447
- * already 已扫描状态
2448
- * success 扫描成功/登录成功状态
2449
- * error 错误状态(超时、网络错误)
2450
- */
2451
- status: CodeStatus;
2452
- /**
2453
- * 二维码 URL
2454
- */
2455
- src?: string;
2456
- /**
2457
- * 二维码底部内容
2458
- */
2459
- descriptions: CodeStatusDescriptions;
2460
- /**
2461
- * 外层 container 样式
2462
- */
2463
- containerStyle?: React.CSSProperties;
2464
- /**
2465
- * 内层 container 样式(图片)
2466
- */
2467
- imageStyle?: React.CSSProperties;
2468
- /**
2469
- * 二维码图片准备好的回调
2470
- */
2471
- onLoad?: () => void;
2472
- /**
2473
- * 点击遮罩中的内容区
2474
- * status 当前组件所处状态
2475
- */
2476
- onClickMaskEl?: (status: CodeStatus) => void;
2477
- /**
2478
- * 点击全部遮罩区域
2479
- * status 当前组件所处状态
2480
- */
2481
- onMaskContent?: (status: CodeStatus) => void;
2482
- }
2483
- const UiQrCode: React.NamedExoticComponent<UiQrProps>;
2484
- export { UiQrCode };
2485
-
2486
- }
2487
- declare module '@authing/react-ui-components/components/Qrcode/WorkQrCode' {
2488
- import React from 'react';
2489
- import { QrCodeResponse } from '@authing/react-ui-components/components/Qrcode/hooks/usePostQrCode';
2490
- import { CodeStatus, UiQrProps } from '@authing/react-ui-components/components/Qrcode/UiQrCode';
2491
- /**
2492
- * 二维码不同状态下的底部描述文字
2493
- */
2494
- export type CodeStatusDescriptions = Partial<Record<Exclude<CodeStatus, 'loading'>, React.ReactNode | ((referQrCode?: () => void) => React.ReactNode)>>;
2495
- export interface WorkQrCodeRef {
2496
- referQrCode: () => Promise<{
2497
- random: string;
2498
- url: string;
2499
- } | undefined>;
2500
- }
2501
- interface WorkQrCodeProps extends Omit<UiQrProps, 'description' | 'status'> {
2502
- /**
2503
- * 二维码场景
2504
- */
2505
- scene: 'WXAPP_AUTH' | 'APP_AUTH' | 'WECHATMP_AUTH';
2506
- /**
2507
- * 不同状态请求文字
2508
- */
2509
- descriptions: CodeStatusDescriptions;
2510
- /**
2511
- * 睡眠时间 默认 1000
2512
- */
2513
- sleepTime?: number;
2514
- /**
2515
- * 每当状态变化时,触发的 callback 。
2516
- */
2517
- onStatusChange?: (status: CodeStatus, data: QrCodeResponse) => void;
2518
- /**
2519
- * 不同状态下点击遮罩中间区域方法
2520
- */
2521
- onClickMaskContent?: (status: CodeStatus) => void;
2522
- }
2523
- const WorkQrCode: React.ForwardRefExoticComponent<WorkQrCodeProps & React.RefAttributes<any>>;
2524
- export { WorkQrCode };
2525
-
2526
- }
2527
- declare module '@authing/react-ui-components/components/Qrcode/hooks/useImage' {
2528
- const useImage: (src: string | undefined, options: {
2529
- onLoad?: (() => void) | undefined;
2530
- }) => (string | undefined)[];
2531
- export { useImage };
2532
-
2533
- }
2534
- declare module '@authing/react-ui-components/components/Qrcode/hooks/usePostQrCode' {
2535
- /// <reference types="react" />
2536
- import { AuthingGuardResponse, AuthingResponse } from '@authing/react-ui-components/components/_utils/http';
2537
- import { CodeStatus } from '@authing/react-ui-components/components/Qrcode/UiQrCode';
2538
- import { CodeStatusDescriptions } from '@authing/react-ui-components/components/Qrcode/WorkQrCode';
2539
- import { ReducerType, RootState } from '@authing/react-ui-components/components/Qrcode/hooks/usePreQrCode';
2540
- export interface QrCodeResponse {
2541
- /**
2542
- * 根据状态确定不同的流程
2543
- */
2544
- status: number;
2545
- /**
2546
- * 返回的随机值
2547
- */
2548
- random: number;
2549
- /**
2550
- * 返回的用户信息
2551
- */
2552
- userInfo?: any;
2553
- /**
2554
- * 扫码成功后 Tick 换取用户信息
2555
- */
2556
- ticket?: string;
2557
- /**
2558
- * MFA 状态下的返回
2559
- */
2560
- scannedResult?: AuthingResponse;
2561
- }
2562
- /**
2563
- * 二维码请求相关
2564
- */
2565
- interface QrCodeRequest {
2566
- genCodeRequest?: () => Promise<AuthingGuardResponse<{
2567
- random: string;
2568
- url: string;
2569
- }>>;
2570
- /**
2571
- * 未扫码下的请求方法
2572
- */
2573
- readyCheckedRequest?: () => Promise<AuthingGuardResponse<QrCodeResponse>>;
2574
- /**
2575
- * 已经扫码下的请求方法(待确认)
2576
- */
2577
- alreadyCheckedRequest?: () => Promise<AuthingGuardResponse<QrCodeResponse>>;
2578
- /**
2579
- * 使用 ticket 交换用户信息
2580
- */
2581
- exchangeUserInfo?: (ticket: string) => Promise<any>;
2582
- }
2583
- interface QrCodeOptions {
2584
- state: RootState;
2585
- dispatch: React.Dispatch<{
2586
- type: ReducerType;
2587
- payload: Partial<RootState>;
2588
- }>;
2589
- descriptions: CodeStatusDescriptions;
2590
- sleepTime?: number;
2591
- /**
2592
- * 状态改变时触发事件,仅在 Server 返回的二维码状态改变时进行触发
2593
- */
2594
- onStatusChange?: (status: CodeStatus, data: QrCodeResponse) => void;
2595
- }
2596
- /**
2597
- * 二维码处理阶段
2598
- * 二维码处理阶段分为两个主要流程
2599
- * 1. 同一状态下的轮询逻辑处理
2600
- * 2. 根据不同返回状态码进行处理
2601
- */
2602
- export const useQrCode: (options: QrCodeOptions, request: QrCodeRequest) => void;
2603
- export {};
2604
-
2605
- }
2606
- declare module '@authing/react-ui-components/components/Qrcode/hooks/usePreQrCode' {
2607
- /// <reference types="react" />
2608
- import { CodeStatus } from '@authing/react-ui-components/components/Qrcode/UiQrCode';
2609
- export type ReducerType = 'change' | 'changeStatus' | 'changeDesc';
2610
- export type RootState = {
2611
- /**
2612
- * 状态
2613
- */
2614
- status: CodeStatus;
2615
- /**
2616
- * 底部描述
2617
- */
2618
- /**
2619
- * 当前二维码 URL
2620
- */
2621
- src?: string;
2622
- /**
2623
- * 二维码随机值
2624
- */
2625
- random?: string;
2626
- };
2627
- /**
2628
- * QrCode 准备阶段 Hook
2629
- */
2630
- const usePreQrCode: () => {
2631
- state: RootState;
2632
- dispatch: import("react").Dispatch<{
2633
- type: ReducerType;
2634
- payload: Partial<RootState>;
2635
- }>;
2636
- };
2637
- export { usePreQrCode };
2638
-
2639
- }
2640
- declare module '@authing/react-ui-components/components/Qrcode/hooks/useStatus' {
2641
- import { CodeStatus } from '@authing/react-ui-components/components/Qrcode/UiQrCode';
2642
- /**
2643
- * 根据不同状态添加不同的元素
2644
- * 维护不同状态的处理
2645
- */
2646
- const useStatus: (status: CodeStatus) => ({} | null | undefined)[];
2647
- export { useStatus };
2648
-
2649
- }
2650
- declare module '@authing/react-ui-components/components/Qrcode/index' {
2651
- import { UiQrCode } from '@authing/react-ui-components/components/Qrcode/UiQrCode';
2652
- import { WorkQrCode } from '@authing/react-ui-components/components/Qrcode/WorkQrCode';
2653
- type IQrCode = typeof WorkQrCode & {
2654
- UI: typeof UiQrCode;
2655
- };
2656
- const QrCode: IQrCode;
2657
- export { QrCode };
2658
-
2659
2976
  }
2660
2977
  declare module '@authing/react-ui-components/components/RecoveryCode/businessRequest' {
2661
2978
  export enum TotpRecoveryCodeBusinessAction {
@@ -3245,6 +3562,7 @@ declare module '@authing/react-ui-components/components/_utils/context' {
3245
3562
  import React from 'react';
3246
3563
  import { GuardEvents, GuardLocalConfig, GuardModuleType, GuardPageConfig } from '@authing/react-ui-components/components/index';
3247
3564
  import { ApplicationConfig } from '@authing/react-ui-components/components/AuthingGuard/api/index';
3565
+ import { BackFillMultipleState, StoreInstance } from '@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts';
3248
3566
  import { ModuleState } from '@authing/react-ui-components/components/Guard/GuardModule/stateMachine';
3249
3567
  import { GuardHttp } from '@authing/react-ui-components/components/_utils/guardHttp';
3250
3568
  export interface IGuardContext {
@@ -3262,6 +3580,29 @@ declare module '@authing/react-ui-components/components/_utils/context' {
3262
3580
  isAuthFlow: boolean;
3263
3581
  contextLoaded: boolean;
3264
3582
  guardPageConfig: Partial<GuardPageConfig>;
3583
+ multipleInstance: {
3584
+ /**
3585
+ * 多账号相关
3586
+ */
3587
+ isMultipleAccount: boolean;
3588
+ /**
3589
+ * when: 多账号页面跳转进入登录页面
3590
+ * 携带的回填数据信息
3591
+ */
3592
+ multipleAccountData?: BackFillMultipleState;
3593
+ /**
3594
+ * 多账号 store 实例
3595
+ */
3596
+ instance?: StoreInstance;
3597
+ /**
3598
+ * 切换多账号 isMultipleAccount 状态
3599
+ */
3600
+ referMultipleState?: (type: 'login' | 'multiple') => void;
3601
+ /**
3602
+ * 清空回填数据
3603
+ */
3604
+ clearBackFillData?: () => void;
3605
+ };
3265
3606
  }
3266
3607
  export const createGuardXContext: () => {
3267
3608
  Provider: React.FC<{
@@ -3299,6 +3640,64 @@ declare module '@authing/react-ui-components/components/_utils/context' {
3299
3640
  export const useGuardContextLoaded: () => boolean;
3300
3641
  export const useGuardIsAuthFlow: () => boolean;
3301
3642
  export const useGuardPageConfig: () => Partial<GuardPageConfig>;
3643
+ /**
3644
+ * 多账号登录 store 实例
3645
+ */
3646
+ export const useGuardMultipleInstance: () => {
3647
+ /**
3648
+ * 多账号相关
3649
+ */
3650
+ isMultipleAccount: boolean;
3651
+ /**
3652
+ * when: 多账号页面跳转进入登录页面
3653
+ * 携带的回填数据信息
3654
+ */
3655
+ multipleAccountData?: BackFillMultipleState | undefined;
3656
+ /**
3657
+ * 多账号 store 实例
3658
+ */
3659
+ instance?: {
3660
+ initStore: (appId: string, options: {
3661
+ serverSideLoginMethods: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay[];
3662
+ isInternationSms: boolean;
3663
+ }) => void;
3664
+ setLoginWay: (tab: "input" | "qrcode", way: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay, id?: string | undefined, internation?: {
3665
+ phoneCountryCode: string;
3666
+ areaCode: string;
3667
+ } | undefined) => void;
3668
+ setUserInfo: (user: Pick<import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").User & {
3669
+ id: string;
3670
+ }, "email" | "username" | "phone" | "id" | "nickname" | "photo" | "name" | "_updateTime" | "qrCodeId" | "areaCode">) => void;
3671
+ setLoginWayByHttpData: (account: string, data: {
3672
+ username?: string | undefined;
3673
+ phone?: string | undefined;
3674
+ email?: string | undefined;
3675
+ }) => void;
3676
+ setLoginWayByLDAPData: (account: string, data: {
3677
+ name?: string | undefined;
3678
+ phone?: string | undefined;
3679
+ email?: string | undefined;
3680
+ }) => void;
3681
+ getMemoUser: (excludeWays?: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay[]) => import("../Login/multipleAccounts/panel").SelectOptions[];
3682
+ getMemoSingleUser: (id: string) => {
3683
+ way: import("@authing/react-ui-components/components/Guard/core/hooks/useMultipleAccounts").LoginWay;
3684
+ account: string;
3685
+ } | undefined;
3686
+ delUserById: (id: string) => string;
3687
+ getMemberState: () => boolean;
3688
+ getFirstBackFillData: () => BackFillMultipleState | undefined;
3689
+ getOriginAccount: () => string;
3690
+ getOriginWay: () => string;
3691
+ } | undefined;
3692
+ /**
3693
+ * 切换多账号 isMultipleAccount 状态
3694
+ */
3695
+ referMultipleState?: ((type: 'login' | 'multiple') => void) | undefined;
3696
+ /**
3697
+ * 清空回填数据
3698
+ */
3699
+ clearBackFillData?: (() => void) | undefined;
3700
+ };
3302
3701
 
3303
3702
  }
3304
3703
  declare module '@authing/react-ui-components/components/_utils/corsVerification' {
@@ -3509,7 +3908,11 @@ declare module '@authing/react-ui-components/components/_utils/index' {
3509
3908
  * @param ...sources
3510
3909
  */
3511
3910
  export function deepMerge<T extends any = any>(target: T, ...sources: any[]): T;
3512
- export const getUserRegisterParams: () => {
3911
+ /**
3912
+ * 在托管页下上传query中指定的用户自定义字段进行补全
3913
+ * @param params 指定上传的用户自定义字段
3914
+ */
3915
+ export const getUserRegisterParams: (params?: string[] | undefined) => {
3513
3916
  key: string;
3514
3917
  value: string | string[] | qs.ParsedQs | qs.ParsedQs[] | undefined;
3515
3918
  }[];
@@ -3763,7 +4166,7 @@ declare module '@authing/react-ui-components/components/version/index' {
3763
4166
 
3764
4167
  }
3765
4168
  declare module '@authing/react-ui-components/components/version/version' {
3766
- const _default: "3.1.39-beta.0";
4169
+ const _default: "3.1.39-beta.1";
3767
4170
  export default _default;
3768
4171
 
3769
4172
  }