@authing/react-ui-components 3.0.0-alpha → 3.0.0-rc.3

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.
Files changed (232) hide show
  1. package/lib/index.d.ts +781 -110
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/lib/index.min.js.LICENSE.txt +2 -0
  5. package/package.json +34 -12
  6. package/.eslintignore +0 -6
  7. package/.eslintrc.js +0 -7
  8. package/.prettierrc +0 -5
  9. package/.vscode/settings.json +0 -31
  10. package/build/favicon.ico +0 -0
  11. package/build/logo192.png +0 -0
  12. package/build/logo512.png +0 -0
  13. package/build/manifest.json +0 -25
  14. package/build/robots.txt +0 -3
  15. package/components/AuthingDropdown/index.tsx +0 -52
  16. package/components/AuthingDropdown/style.less +0 -43
  17. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  18. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  19. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  20. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  21. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  22. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  23. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  24. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  25. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  26. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  27. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  28. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  29. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  30. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  31. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  32. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  33. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  34. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  35. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  36. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  37. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  38. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  39. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  40. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  41. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  42. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  43. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  44. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  45. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  46. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  47. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  48. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  49. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  51. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  52. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  53. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  54. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  55. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  56. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  57. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  58. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  59. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  60. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  61. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  62. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  63. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  64. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  65. package/components/AuthingGuard/Forms/index.ts +0 -13
  66. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  67. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  68. package/components/AuthingGuard/Header/index.tsx +0 -25
  69. package/components/AuthingGuard/Header/style.less +0 -52
  70. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  71. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  72. package/components/AuthingGuard/IconFont/style.less +0 -6
  73. package/components/AuthingGuard/IconFont/svg.js +0 -2
  74. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  75. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  76. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  77. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  78. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  79. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  80. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  81. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  82. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  83. package/components/AuthingGuard/api/appConfig.ts +0 -146
  84. package/components/AuthingGuard/api/index.ts +0 -3
  85. package/components/AuthingGuard/api/sso.ts +0 -29
  86. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  87. package/components/AuthingGuard/constants.ts +0 -105
  88. package/components/AuthingGuard/hooks/index.tsx +0 -70
  89. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  90. package/components/AuthingGuard/index.tsx +0 -126
  91. package/components/AuthingGuard/style.less +0 -103
  92. package/components/AuthingGuard/types/Forms.ts +0 -94
  93. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  94. package/components/AuthingGuard/types/GuardState.ts +0 -7
  95. package/components/AuthingGuard/types/Locales.ts +0 -12
  96. package/components/AuthingGuard/types/index.ts +0 -4
  97. package/components/AuthingTabs/index.tsx +0 -98
  98. package/components/AuthingTabs/style.less +0 -135
  99. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  100. package/components/BindTotp/core/securityCode.tsx +0 -119
  101. package/components/BindTotp/index.tsx +0 -134
  102. package/components/BindTotp/props.ts +0 -30
  103. package/components/BindTotp/styles.less +0 -56
  104. package/components/ChangeLanguage/index.tsx +0 -35
  105. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  106. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  107. package/components/ChangePassword/index.tsx +0 -59
  108. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  109. package/components/CompleteInfo/index.tsx +0 -45
  110. package/components/CompleteInfo/props.ts +0 -40
  111. package/components/CompleteInfo/styles.less +0 -7
  112. package/components/CompleteUserInfo/index.tsx +0 -49
  113. package/components/CompleteUserInfo/props.ts +0 -25
  114. package/components/ComponentsRender/index.back +0 -64
  115. package/components/CopyAbleText/index.tsx +0 -54
  116. package/components/CopyAbleText/style.less +0 -13
  117. package/components/DownloadAuthenticator/index.tsx +0 -97
  118. package/components/DownloadAuthenticator/props.ts +0 -22
  119. package/components/DownloadAuthenticator/styles.less +0 -52
  120. package/components/ForgetPassword/core/resetPassword.tsx +0 -150
  121. package/components/ForgetPassword/index.tsx +0 -51
  122. package/components/Guard/Guard.tsx +0 -226
  123. package/components/Guard/authClient.ts +0 -55
  124. package/components/Guard/config.ts +0 -19
  125. package/components/Guard/event.ts +0 -18
  126. package/components/Guard/index.tsx +0 -10
  127. package/components/Guard/module.ts +0 -19
  128. package/components/Guard/stateMachine.ts +0 -133
  129. package/components/Guard/styles.less +0 -444
  130. package/components/IconFont/iconfont.js +0 -74
  131. package/components/IconFont/index.tsx +0 -16
  132. package/components/IconFont/style.less +0 -6
  133. package/components/IconFont/svg.js +0 -2
  134. package/components/ImagePro/index.tsx +0 -52
  135. package/components/ImagePro/styles.less +0 -40
  136. package/components/Login/codemap.ts +0 -35
  137. package/components/Login/core/withAD.tsx +0 -9
  138. package/components/Login/core/withAppQrcode.tsx +0 -49
  139. package/components/Login/core/withLDAP.tsx +0 -145
  140. package/components/Login/core/withPassword.tsx +0 -176
  141. package/components/Login/core/withPhonecode.tsx +0 -135
  142. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  143. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  144. package/components/Login/index.tsx +0 -359
  145. package/components/Login/props.ts +0 -90
  146. package/components/Login/socialLogin/index.tsx +0 -413
  147. package/components/Login/socialLogin/style.less +0 -61
  148. package/components/Login/styles.less +0 -53
  149. package/components/MFA/codemap.ts +0 -21
  150. package/components/MFA/core/email.tsx +0 -226
  151. package/components/MFA/core/face.tsx +0 -297
  152. package/components/MFA/core/face_deps.tsx +0 -37
  153. package/components/MFA/core/sms.tsx +0 -222
  154. package/components/MFA/core/totp.tsx +0 -137
  155. package/components/MFA/index.tsx +0 -135
  156. package/components/MFA/mfaMethods/index.tsx +0 -81
  157. package/components/MFA/mfaMethods/style.less +0 -39
  158. package/components/MFA/props.ts +0 -51
  159. package/components/MFA/styles.less +0 -92
  160. package/components/NeedHelpView/core/describeQuestions.tsx +0 -227
  161. package/components/NeedHelpView/index.tsx +0 -99
  162. package/components/RecoveryCode/core/useCode.tsx +0 -71
  163. package/components/RecoveryCode/index.tsx +0 -27
  164. package/components/RecoveryCode/interface.ts +0 -31
  165. package/components/RecoveryCode/style.less +0 -13
  166. package/components/Register/codemap.ts +0 -16
  167. package/components/Register/components/Agreements/index.tsx +0 -81
  168. package/components/Register/components/Agreements/style.less +0 -44
  169. package/components/Register/core/WithEmail.tsx +0 -250
  170. package/components/Register/core/WithPhone.tsx +0 -190
  171. package/components/Register/index.tsx +0 -122
  172. package/components/Register/props.ts +0 -50
  173. package/components/SendCode/SendCodeBtn.tsx +0 -96
  174. package/components/SendCode/index.tsx +0 -98
  175. package/components/SendCode/style.less +0 -31
  176. package/components/ShieldSpin/index.tsx +0 -27
  177. package/components/ShieldSpin/loading.svg +0 -29
  178. package/components/SubmitButton/index.tsx +0 -50
  179. package/components/Type/index.ts +0 -61
  180. package/components/VerifyCodeInput/index.tsx +0 -76
  181. package/components/VerifyCodeInput/style.less +0 -24
  182. package/components/_utils/GuardErrorCode.ts +0 -8
  183. package/components/_utils/clipboard.ts +0 -27
  184. package/components/_utils/config.ts +0 -123
  185. package/components/_utils/guradHttp.ts +0 -93
  186. package/components/_utils/hooks/index.ts +0 -56
  187. package/components/_utils/http.ts +0 -85
  188. package/components/_utils/index.ts +0 -310
  189. package/components/_utils/locales/en/common.json +0 -218
  190. package/components/_utils/locales/en/index.ts +0 -6
  191. package/components/_utils/locales/en/login.json +0 -95
  192. package/components/_utils/locales/en/map.json +0 -4
  193. package/components/_utils/locales/en/user.json +0 -82
  194. package/components/_utils/locales/index.ts +0 -45
  195. package/components/_utils/locales/zh/common.json +0 -218
  196. package/components/_utils/locales/zh/index.ts +0 -6
  197. package/components/_utils/locales/zh/login.json +0 -95
  198. package/components/_utils/locales/zh/map.json +0 -4
  199. package/components/_utils/locales/zh/user.json +0 -82
  200. package/components/_utils/popupCenter.ts +0 -48
  201. package/components/context/base.tsx +0 -28
  202. package/components/context/global/context.tsx +0 -39
  203. package/components/context/global/reducer.tsx +0 -56
  204. package/components/context/module/context.tsx +0 -23
  205. package/components/index.ts +0 -10
  206. package/config/antdReplacer.js +0 -51
  207. package/config/env.js +0 -104
  208. package/config/getHttpsConfig.js +0 -66
  209. package/config/jest/cssTransform.js +0 -14
  210. package/config/jest/fileTransform.js +0 -40
  211. package/config/modules.js +0 -134
  212. package/config/paths.js +0 -71
  213. package/config/pnpTs.js +0 -35
  214. package/config/webpack.config.js +0 -835
  215. package/config/webpackDevServer.config.js +0 -130
  216. package/examples.tsx +0 -100
  217. package/index.js +0 -1
  218. package/logo.svg +0 -7
  219. package/public/favicon.ico +0 -0
  220. package/public/index.html +0 -43
  221. package/public/logo192.png +0 -0
  222. package/public/logo512.png +0 -0
  223. package/public/manifest.json +0 -25
  224. package/public/robots.txt +0 -3
  225. package/react-app-env.d.ts +0 -71
  226. package/reportWebVitals.ts +0 -15
  227. package/scripts/build.js +0 -208
  228. package/scripts/lib.js +0 -200
  229. package/scripts/start.js +0 -162
  230. package/scripts/test.js +0 -49
  231. package/setupTests.ts +0 -5
  232. package/tsconfig.json +0 -30
@@ -1,20 +0,0 @@
1
- import React from 'react'
2
-
3
- import { useGuardContext } from '../../context/global/context'
4
- import { ResetPasswordForm } from '../../../components/AuthingGuard/Forms'
5
-
6
- export const ResetPwdLayout = () => {
7
- const {
8
- state: { guardEvents, authClient },
9
- } = useGuardContext()
10
-
11
- const onFail = (error: any) => {
12
- guardEvents.onPwdResetError?.(error, authClient)
13
- }
14
-
15
- const onSuccess = () => {
16
- guardEvents.onPwdReset?.(authClient)
17
- }
18
-
19
- return <ResetPasswordForm onFail={onFail} onSuccess={onSuccess} />
20
- }
@@ -1,51 +0,0 @@
1
- import React, { FC } from 'react'
2
- import { Dropdown, Menu, Space } from 'antd'
3
- import { LANG_MAP } from '../types'
4
- import { useTranslation } from 'react-i18next'
5
- import { changeLang } from '../../_utils/locales'
6
- import { useGuardContext } from '../../context/global/context'
7
- import { IconFont } from '../IconFont'
8
-
9
- export const ToggleLang: FC = () => {
10
- const {
11
- state: { authClient },
12
- } = useGuardContext()
13
-
14
- const onClick = ({ key }: any) => {
15
- changeLang(key)
16
- authClient.setLang(key)
17
- }
18
- const { i18n } = useTranslation()
19
-
20
- return (
21
- <Dropdown
22
- className="authing-toggle-language"
23
- overlay={
24
- <Menu onClick={onClick}>
25
- {LANG_MAP.map((item) => (
26
- <Menu.Item key={item.value}>{item.label}</Menu.Item>
27
- ))}
28
- </Menu>
29
- }
30
- >
31
- <Space
32
- size={1}
33
- style={{
34
- alignSelf: 'center',
35
- color: '#999',
36
- marginTop: 24,
37
- cursor: 'pointer',
38
- fontSize: 14,
39
- }}
40
- >
41
- <IconFont type="authing-yuyan" />
42
- <span>
43
- {
44
- LANG_MAP.find((item) => item.value === (i18n.language || 'zh-CN'))
45
- ?.label
46
- }
47
- </span>
48
- </Space>
49
- </Dropdown>
50
- )
51
- }
@@ -1,146 +0,0 @@
1
- import { Lang, Protocol } from '../types'
2
- import {
3
- IAzureAdConnectionConfig,
4
- ICasConnectionConfig,
5
- IOAuthConnectionConfig,
6
- ISamlConnectionConfig,
7
- OIDCConnectionConfig,
8
- SocialConnectionItem,
9
- } from './userPoolConfig'
10
- import { i18n } from '../../_utils/locales'
11
- import { requestClient } from '../../_utils/http'
12
- import { PasswordStrength } from '../../_utils'
13
-
14
- export enum ApplicationMfaType {
15
- SMS = 'SMS',
16
- EMAIL = 'EMAIL',
17
- // OTP = 'OTP',
18
- // FACE = 'FACE',
19
- // FINGERPRINT = 'FINGERPRINT',
20
- }
21
-
22
- export const ApplicationMfaTypeLabel: () => Record<
23
- ApplicationMfaType,
24
- string
25
- > = () => ({
26
- [ApplicationMfaType.SMS]: i18n.t('common.SMS'),
27
- [ApplicationMfaType.EMAIL]: i18n.t('common.EmailVerification'),
28
- })
29
-
30
- export interface OidcClientMetadata {
31
- grant_types: string[]
32
- client_id: string
33
- redirect_uris: string[]
34
- scope: string
35
- response_types: ResponseType[]
36
- }
37
- export interface InternalExtendsField {
38
- type: 'internal'
39
- name: string
40
- label: string
41
- inputType: string
42
- }
43
-
44
- export interface UserExtendsField {
45
- type: 'user'
46
- id: string
47
- name: string
48
- label: string
49
- inputType: string
50
- }
51
-
52
- export type ExtendsField = InternalExtendsField | UserExtendsField
53
-
54
- export interface ApplicationPasswordTabConfig {
55
- enabledLoginMethods?: PasswordLoginMethods[]
56
- }
57
-
58
- export interface Agreement {
59
- id: number
60
- title: string
61
- required: boolean
62
- lang: Lang
63
- }
64
-
65
- export type PasswordLoginMethods =
66
- | 'username-password'
67
- | 'email-password'
68
- | 'phone-password'
69
-
70
- export interface ApplicationConfig {
71
- id: string
72
- cdnBase: string
73
- userPoolId: string
74
- rootUserPoolId: string
75
- publicKey: string
76
- // 登录框自定义 css 代码
77
- css: string
78
- name: string
79
- logo: string
80
- redirectUris: string[]
81
- registerDisabled: boolean
82
- registerTabs: {
83
- list: string[]
84
- default: string
85
- title: { [x: string]: string }
86
- }
87
- loginTabs: {
88
- list: string[]
89
- default: string
90
- title: { [x: string]: string }
91
- }
92
- socialConnections: SocialConnectionItem[]
93
-
94
- extendsFieldsEnabled: boolean
95
- extendsFields: ExtendsField[]
96
-
97
- identifier: string
98
- identityProviders: {
99
- identifier: string
100
- protocol: Protocol
101
- displayName: string
102
- logo: string
103
- config:
104
- | ISamlConnectionConfig
105
- | OIDCConnectionConfig
106
- | ICasConnectionConfig
107
- | IAzureAdConnectionConfig
108
- | IOAuthConnectionConfig
109
- }[]
110
-
111
- ssoPageComponentDisplay: {
112
- autoRegisterThenLoginHintInfo: boolean
113
- forgetPasswordBtn: boolean
114
- idpBtns: boolean
115
- loginBtn: boolean
116
- loginByPhoneCodeTab: boolean
117
- loginByUserPasswordTab: boolean
118
- loginMethodNav: boolean
119
- phoneCodeInput: boolean
120
- registerBtn: boolean
121
- registerByEmailTab: boolean
122
- registerByPhoneTab: boolean
123
- registerMethodNav: boolean
124
- socialLoginBtns: boolean
125
- userPasswordInput: boolean
126
- wxMpScanTab: boolean
127
- }
128
-
129
- protocol: Protocol
130
- oidcConfig: OidcClientMetadata
131
- passwordTabConfig: ApplicationPasswordTabConfig
132
-
133
- agreementEnabled: boolean
134
- agreements: Agreement[]
135
- customPasswordStrength: any
136
- passwordStrength: PasswordStrength
137
- verifyCodeLength: number
138
- }
139
-
140
- export const fetchAppConfig = (appId: string) =>
141
- requestClient.get<ApplicationConfig>(
142
- `/api/v2/applications/${appId}/public-config`,
143
- {
144
- credentials: 'include',
145
- }
146
- )
@@ -1,3 +0,0 @@
1
- export * from './sso'
2
- export * from './appConfig'
3
- export * from './userPoolConfig'
@@ -1,29 +0,0 @@
1
- import { User } from '../types'
2
- import { requestClient } from '../../_utils/http'
3
-
4
- export interface SessionData {
5
- session: null | {
6
- _id: string
7
- cookie: {
8
- originalMaxAge: number
9
- expires: Date
10
- secure: boolean
11
- httpOnly: boolean
12
- path: string
13
- sameSite: string
14
- }
15
- appId?: string
16
- type: string
17
- userId: string
18
- }
19
- userInfo?: User
20
- }
21
-
22
- export const trackSession = () =>
23
- requestClient.get<SessionData>(
24
- `/cas/session`,
25
- {},
26
- {
27
- credentials: 'include',
28
- }
29
- )
@@ -1,111 +0,0 @@
1
- import { Lang, Protocol } from '../types'
2
- import { SocialConnectionProvider } from 'authing-js-sdk'
3
-
4
- export interface OIDCConnectionConfig {
5
- issuerUrl: string
6
- authorizationEdpoint: string
7
- responseType: string
8
- mode: OIDCConnectionMode
9
- clientId: string
10
- clientSecret: string
11
- scopes: string
12
- redirectUri: string
13
- }
14
-
15
- export interface IOAuthConnectionConfig {
16
- authEndPoint: string
17
- tokenEndPoint: string
18
- scope: string
19
- clientId: string
20
- clientSecret: string
21
- authUrlTemplate: string
22
- codeToTokenScript: string
23
- tokenToUserInfoScript: string
24
- tokenToUserInfoScriptFuncId: string
25
- codeToTokenScriptFuncId: string
26
- authUrl?: string // 根据模板拼接出来的授权 url
27
- }
28
-
29
- export interface IAzureAdConnectionConfig {
30
- microsoftAzureAdDomain: string
31
- clientId: string
32
- syncUserProfileOnLogin: string
33
- emailVerifiedDefault: boolean
34
- authorizationUrl: string
35
- callbackUrl: string
36
- }
37
-
38
- export enum OIDCConnectionMode {
39
- FRONT_CHANNEL = 'FRONT_CHANNEL',
40
- BACK_CHANNEL = 'BACK_CHANNEL',
41
- }
42
-
43
- export interface ISamlConnectionConfig {
44
- signInEndPoint: string
45
- samlRequest?: string
46
-
47
- // saml assertion 验签公钥
48
-
49
- samlIdpCert: string
50
-
51
- // saml request 验签公钥
52
-
53
- samlSpCert: string
54
-
55
- // saml request 签名私钥
56
-
57
- samlSpKey: string
58
-
59
- signOutEndPoint: string
60
-
61
- signSamlRequest: boolean
62
-
63
- signatureAlgorithm: string
64
-
65
- digestAlgorithm: string
66
-
67
- protocolBinding: string
68
- }
69
-
70
- export interface ICasConnectionConfig {
71
- casConnectionLoginUrl: string
72
- }
73
- export interface SocialConnectionItem {
74
- name: string
75
- name_en: string
76
- logo: string
77
- description: string
78
- provider: SocialConnectionProvider
79
- authorizationUrl: string
80
- tooltip: Record<Lang, string>
81
- }
82
-
83
- export interface EnterpriseConnectionItem {
84
- id: string
85
- createdAt: Date
86
- updatedAt: Date
87
- userPoolId: string
88
- protocol: Protocol
89
- identifier: string
90
- displayName: string
91
- logo: string
92
- enabled: boolean
93
- config:
94
- | OIDCConnectionConfig
95
- | ISamlConnectionConfig
96
- | ICasConnectionConfig
97
- | IAzureAdConnectionConfig
98
- | IOAuthConnectionConfig
99
- }
100
-
101
- export interface UserPoolConfig {
102
- name: string
103
- logo: string
104
- socialConnections: SocialConnectionItem[]
105
- enterpriseConnections: EnterpriseConnectionItem[]
106
- }
107
-
108
- // export const fetchUserPoolConfig = (userPoolId: string) =>
109
- // requestClient.get<UserPoolConfig>(
110
- // `/api/v2/userpools/${userPoolId}/public-config`
111
- // )
@@ -1,105 +0,0 @@
1
- import {
2
- GuardMode,
3
- UserConfig,
4
- GuardScenes,
5
- LoginMethods,
6
- RegisterMethods,
7
- LocalesConfig,
8
- } from '../../components/AuthingGuard/types'
9
- import { i18n } from '../_utils/locales'
10
-
11
- // 个人版 OTP MFA 的 error code
12
- export const OTP_MFA_CODE = 1635
13
- // 企业版手机和短信验证吗 MFA 的 error code
14
- export const APP_MFA_CODE = 1636
15
-
16
- // 需要验证吗
17
- export const NEED_CAPTCHA = 2000
18
-
19
- export const LOGIN_METHODS_MAP = () => ({
20
- [LoginMethods.Password]: i18n.t('login.pwdLogin'),
21
- [LoginMethods.PhoneCode]: i18n.t('login.verifyCodeLogin'),
22
- [LoginMethods.AppQr]: i18n.t('login.appScanLogin'),
23
- [LoginMethods.WxMinQr]: i18n.t('login.scanLogin'),
24
- [LoginMethods.LDAP]: i18n.t('login.ldapLogin'),
25
- [LoginMethods.AD]: i18n.t('login.adLogin'),
26
- [LoginMethods.WechatMpQrcode]: i18n.t('login.wechatmpQrcode'),
27
- })
28
-
29
- export const REGISTER_METHODS_MAP = () => ({
30
- [RegisterMethods.Email]: i18n.t('login.emailRegister'),
31
- [RegisterMethods.Phone]: i18n.t('login.phoneRegister'),
32
- })
33
-
34
- // 某些社会化登录会在 tabs 中显示,或者无法在 Guard 中使用,所以底部不显示了
35
- export const HIDE_SOCIALS = [
36
- 'wechat:miniprogram:app-launch',
37
- 'wechat:miniprogram:qrconnect',
38
- 'wechat:webpage-authorization',
39
- 'wechat:miniprogram:default',
40
- 'wechatwork:addressbook',
41
- 'wechat:mobile',
42
- ]
43
-
44
- // 企业版 MFA 支持的方式
45
- export enum ApplicationMfaType {
46
- SMS = 'SMS',
47
- EMAIL = 'EMAIL',
48
- // OTP = 'OTP',
49
- // FACE = 'FACE',
50
- // FINGERPRINT = 'FINGERPRINT',
51
- }
52
-
53
- export const defaultGuardConfig: Partial<UserConfig> = {
54
- isSSO: false,
55
- title: 'Authing',
56
- text: {
57
- loginTabs: LOGIN_METHODS_MAP(),
58
- loginBtn: {
59
- normal: '登录',
60
- loading: '登录',
61
- },
62
- registerBtn: {
63
- normal: '注册',
64
- loading: '注册',
65
- },
66
- },
67
- escCloseable: true,
68
- autoRegister: false,
69
- clickCloseable: true,
70
- mode: GuardMode.Normal,
71
- disableRegister: false,
72
- disableResetPwd: false,
73
- defaultScenes: GuardScenes.Login,
74
- appHost: 'https://core.authing.cn',
75
- defaultLoginMethod: LoginMethods.Password,
76
- defaultRegisterMethod: RegisterMethods.Email,
77
- loginMethods: [LoginMethods.Password, LoginMethods.PhoneCode],
78
- registerMethods: [RegisterMethods.Email, RegisterMethods.Phone],
79
- logo:
80
- 'https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png',
81
- passwordLoginMethods: [
82
- 'email-password',
83
- 'username-password',
84
- 'phone-password',
85
- ],
86
- }
87
-
88
- export const defaultLocalesConfig: LocalesConfig = {
89
- defaultLang: 'zh-CN',
90
- isShowChange: false,
91
- }
92
-
93
- export const defaultHeaders: {
94
- 'userpool-id': string
95
- 'app-id': string
96
- 'sdk-version': string
97
- 'request-from': string
98
- lang: string
99
- } = {
100
- 'userpool-id': 'x-authing-userpool-id',
101
- 'app-id': 'x-authing-app-id',
102
- 'request-from': 'x-authing-request-from',
103
- 'sdk-version': 'x-authing-sdk-version',
104
- lang: 'x-authing-lang',
105
- }
@@ -1,70 +0,0 @@
1
- import {
2
- AuthenticationClient,
3
- AuthenticationClientOptions,
4
- } from 'authing-js-sdk'
5
- import { defaultGuardConfig } from '../constants'
6
-
7
- let authClient: AuthenticationClient | null = null
8
-
9
- export interface AuthClientConfig extends AuthenticationClientOptions {
10
- /**
11
- * @deprecated 使用 appHost
12
- */
13
- appDomain?: string
14
- /**
15
- * @deprecated 无需传入
16
- */
17
- isSSO?: boolean
18
- /**
19
- * @deprecated 使用 appHost
20
- */
21
- host?: string
22
- }
23
-
24
- export const initAuthClient = (config: AuthClientConfig) => {
25
- if (authClient) {
26
- return authClient
27
- }
28
-
29
- const { appHost, appDomain, host } = config
30
-
31
- /**
32
- * 兼容之前的参数
33
- */
34
- let realHost
35
- if (appHost) {
36
- realHost = appHost
37
- } else if (appDomain) {
38
- const parsedUrl = new URL(host || defaultGuardConfig.appHost!)
39
- realHost = `${parsedUrl.protocol}//${appDomain}${
40
- parsedUrl.port ? ':' + parsedUrl.port : ''
41
- }`
42
- } else if (host) {
43
- realHost = host
44
- } else {
45
- realHost = defaultGuardConfig.appHost
46
- }
47
- config.appHost = realHost!
48
-
49
- authClient = new AuthenticationClient(config)
50
-
51
- return authClient
52
- }
53
-
54
- export const useAuthing = (config?: AuthClientConfig) => {
55
- return { authClient: getAuthClient(config) }
56
- }
57
-
58
- export const getAuthClient = (config?: AuthClientConfig) => {
59
- if (!authClient && !config) {
60
- throw new Error(
61
- 'Please `initAuthClient` first or pass `AuthClientConfig` to useAuthing.'
62
- )
63
- }
64
-
65
- if (config) {
66
- initAuthClient(config)
67
- }
68
-
69
- return authClient
70
- }
@@ -1,68 +0,0 @@
1
- import { useState, useEffect } from 'react'
2
- // import { inRange, debounce } from 'lodash'
3
-
4
- function debounce(fn: Function, delay: number, immediate = true) {
5
- let timer: any
6
-
7
- return function (this: any) {
8
- let context = this
9
- let args = arguments
10
- timer && clearTimeout(timer)
11
-
12
- if (immediate && !timer) {
13
- fn.apply(context, args)
14
- }
15
-
16
- timer = setTimeout(function () {
17
- fn.apply(context, args)
18
- }, delay)
19
- }
20
- }
21
-
22
- function inRange(n: number, start: number, end?: number): boolean {
23
- if (end || end === 0) {
24
- return n >= start && n <= end
25
- }
26
- return n >= start
27
- }
28
-
29
- export enum ScreenSize {
30
- Mobile = 'mobile',
31
- Desktop = 'desktop',
32
- }
33
- export const SCREEN_SIZE_RANG: {
34
- size: ScreenSize
35
- range: [number, number]
36
- }[] = [
37
- {
38
- size: ScreenSize.Mobile,
39
- range: [0, 719],
40
- },
41
- {
42
- size: ScreenSize.Desktop,
43
- range: [720, Infinity],
44
- },
45
- ]
46
-
47
- export const getScreenSize = () => {
48
- const viewportWidth = document.body.clientWidth
49
- return (
50
- SCREEN_SIZE_RANG.find((item) => inRange(viewportWidth, ...item.range))
51
- ?.size ?? ScreenSize.Desktop
52
- )
53
- }
54
-
55
- export const useScreenSize = () => {
56
- const [screenSize, setScreenSize] = useState(getScreenSize)
57
-
58
- useEffect(() => {
59
- const onResize = debounce(() => {
60
- setScreenSize(getScreenSize())
61
- }, 200)
62
- window.addEventListener('resize', onResize)
63
-
64
- return () => window.removeEventListener('resize', onResize)
65
- }, [])
66
-
67
- return [screenSize]
68
- }