@authing/react-ui-components 3.0.2-alpha.2 → 3.0.2-beta.12

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 (254) hide show
  1. package/lib/index.d.ts +620 -52
  2. package/lib/index.min.css +2 -2
  3. package/lib/index.min.js +1 -1
  4. package/package.json +29 -8
  5. package/.eslintignore +0 -6
  6. package/.eslintrc.js +0 -7
  7. package/.prettierrc +0 -5
  8. package/.vscode/settings.json +0 -31
  9. package/build/asset-manifest.json +0 -26
  10. package/build/favicon.ico +0 -0
  11. package/build/index.html +0 -1
  12. package/build/logo192.png +0 -0
  13. package/build/logo512.png +0 -0
  14. package/build/manifest.json +0 -25
  15. package/build/robots.txt +0 -3
  16. package/build/static/css/2.9512539b.chunk.css +0 -3
  17. package/build/static/css/2.9512539b.chunk.css.map +0 -1
  18. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  19. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  20. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  21. package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
  22. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  23. package/build/static/js/3.fd17f196.chunk.js +0 -2
  24. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  25. package/build/static/js/main.a47645ff.chunk.js +0 -2
  26. package/build/static/js/main.a47645ff.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.ef138021.js +0 -2
  28. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  29. package/build/static/media/loading.4a67a5f3.svg +0 -29
  30. package/components/AuthingDropdown/index.tsx +0 -52
  31. package/components/AuthingDropdown/style.less +0 -43
  32. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  33. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  34. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  35. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  36. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  37. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  38. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  39. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  46. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  47. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  48. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  49. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  56. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  57. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  58. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  68. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  69. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  70. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  71. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  72. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  79. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  80. package/components/AuthingGuard/Forms/index.ts +0 -13
  81. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  82. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  83. package/components/AuthingGuard/Header/index.tsx +0 -25
  84. package/components/AuthingGuard/Header/style.less +0 -52
  85. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  86. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  87. package/components/AuthingGuard/IconFont/style.less +0 -6
  88. package/components/AuthingGuard/IconFont/svg.js +0 -2
  89. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  90. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  91. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  92. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  93. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  94. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  95. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  96. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  97. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  98. package/components/AuthingGuard/api/appConfig.ts +0 -146
  99. package/components/AuthingGuard/api/index.ts +0 -3
  100. package/components/AuthingGuard/api/sso.ts +0 -29
  101. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  102. package/components/AuthingGuard/constants.ts +0 -105
  103. package/components/AuthingGuard/hooks/index.tsx +0 -70
  104. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  105. package/components/AuthingGuard/index.tsx +0 -126
  106. package/components/AuthingGuard/style.less +0 -103
  107. package/components/AuthingGuard/types/Forms.ts +0 -94
  108. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  109. package/components/AuthingGuard/types/GuardState.ts +0 -7
  110. package/components/AuthingGuard/types/Locales.ts +0 -12
  111. package/components/AuthingGuard/types/index.ts +0 -4
  112. package/components/AuthingTabs/index.tsx +0 -98
  113. package/components/AuthingTabs/style.less +0 -135
  114. package/components/BindTotp/core/bindSuccess.tsx +0 -61
  115. package/components/BindTotp/core/securityCode.tsx +0 -119
  116. package/components/BindTotp/index.tsx +0 -134
  117. package/components/BindTotp/interface.ts +0 -30
  118. package/components/BindTotp/styles.less +0 -57
  119. package/components/ChangeLanguage/index.tsx +0 -35
  120. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  121. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  122. package/components/ChangePassword/index.tsx +0 -59
  123. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  124. package/components/CompleteInfo/index.tsx +0 -45
  125. package/components/CompleteInfo/interface.ts +0 -40
  126. package/components/CompleteInfo/styles.less +0 -7
  127. package/components/CopyAbleText/index.tsx +0 -54
  128. package/components/CopyAbleText/style.less +0 -13
  129. package/components/DownloadAuthenticator/index.tsx +0 -97
  130. package/components/DownloadAuthenticator/interface.ts +0 -22
  131. package/components/DownloadAuthenticator/styles.less +0 -52
  132. package/components/Error/index.tsx +0 -21
  133. package/components/Error/interface.ts +0 -9
  134. package/components/Error/styles.less +0 -12
  135. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  136. package/components/ForgetPassword/index.tsx +0 -75
  137. package/components/ForgetPassword/interface.ts +0 -32
  138. package/components/Guard/Guard.tsx +0 -242
  139. package/components/Guard/authClient.ts +0 -55
  140. package/components/Guard/config.ts +0 -19
  141. package/components/Guard/event.ts +0 -52
  142. package/components/Guard/index.tsx +0 -4
  143. package/components/Guard/module.ts +0 -19
  144. package/components/Guard/stateMachine.ts +0 -133
  145. package/components/Guard/styles.less +0 -444
  146. package/components/IconFont/iconfont.js +0 -74
  147. package/components/IconFont/index.tsx +0 -16
  148. package/components/IconFont/style.less +0 -6
  149. package/components/IconFont/svg.js +0 -2
  150. package/components/ImagePro/index.tsx +0 -52
  151. package/components/ImagePro/styles.less +0 -40
  152. package/components/InputNumber/index.tsx +0 -33
  153. package/components/Login/codemap.ts +0 -39
  154. package/components/Login/core/withAD.tsx +0 -9
  155. package/components/Login/core/withAppQrcode.tsx +0 -49
  156. package/components/Login/core/withLDAP.tsx +0 -146
  157. package/components/Login/core/withPassword.tsx +0 -176
  158. package/components/Login/core/withPhonecode.tsx +0 -121
  159. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  160. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  161. package/components/Login/index.tsx +0 -368
  162. package/components/Login/props.ts +0 -74
  163. package/components/Login/socialLogin/index.tsx +0 -413
  164. package/components/Login/socialLogin/style.less +0 -61
  165. package/components/Login/styles.less +0 -53
  166. package/components/MFA/codemap.ts +0 -21
  167. package/components/MFA/core/email.tsx +0 -225
  168. package/components/MFA/core/face.tsx +0 -297
  169. package/components/MFA/core/face_deps.tsx +0 -37
  170. package/components/MFA/core/sms.tsx +0 -229
  171. package/components/MFA/core/totp.tsx +0 -137
  172. package/components/MFA/index.tsx +0 -137
  173. package/components/MFA/mfaMethods/index.tsx +0 -81
  174. package/components/MFA/mfaMethods/style.less +0 -39
  175. package/components/MFA/props.ts +0 -51
  176. package/components/MFA/styles.less +0 -93
  177. package/components/NeedHelpView/core/describeQuestions.tsx +0 -223
  178. package/components/NeedHelpView/index.tsx +0 -99
  179. package/components/RecoveryCode/core/useCode.tsx +0 -71
  180. package/components/RecoveryCode/index.tsx +0 -27
  181. package/components/RecoveryCode/interface.ts +0 -31
  182. package/components/RecoveryCode/style.less +0 -13
  183. package/components/Register/codemap.ts +0 -16
  184. package/components/Register/components/Agreements/index.tsx +0 -81
  185. package/components/Register/components/Agreements/style.less +0 -44
  186. package/components/Register/core/WithEmail.tsx +0 -236
  187. package/components/Register/core/WithPhone.tsx +0 -184
  188. package/components/Register/index.tsx +0 -123
  189. package/components/Register/props.ts +0 -50
  190. package/components/SendCode/SendCodeBtn.tsx +0 -96
  191. package/components/SendCode/index.tsx +0 -94
  192. package/components/SendCode/style.less +0 -31
  193. package/components/ShieldSpin/index.tsx +0 -27
  194. package/components/ShieldSpin/loading.svg +0 -29
  195. package/components/SubmitButton/index.tsx +0 -50
  196. package/components/Type/index.ts +0 -52
  197. package/components/ValidatorRules/EmailFormItem.tsx +0 -81
  198. package/components/ValidatorRules/PhoneFormItem.tsx +0 -90
  199. package/components/ValidatorRules/index.ts +0 -14
  200. package/components/VerifyCodeInput/index.tsx +0 -76
  201. package/components/VerifyCodeInput/style.less +0 -24
  202. package/components/_utils/GuardErrorCode.ts +0 -8
  203. package/components/_utils/clipboard.ts +0 -27
  204. package/components/_utils/config.ts +0 -121
  205. package/components/_utils/guradHttp.ts +0 -93
  206. package/components/_utils/hooks/index.ts +0 -64
  207. package/components/_utils/http.ts +0 -85
  208. package/components/_utils/index.ts +0 -319
  209. package/components/_utils/locales/en/common.json +0 -223
  210. package/components/_utils/locales/en/index.ts +0 -6
  211. package/components/_utils/locales/en/login.json +0 -96
  212. package/components/_utils/locales/en/map.json +0 -4
  213. package/components/_utils/locales/en/user.json +0 -82
  214. package/components/_utils/locales/index.ts +0 -45
  215. package/components/_utils/locales/zh/common.json +0 -223
  216. package/components/_utils/locales/zh/index.ts +0 -6
  217. package/components/_utils/locales/zh/login.json +0 -96
  218. package/components/_utils/locales/zh/map.json +0 -4
  219. package/components/_utils/locales/zh/user.json +0 -82
  220. package/components/_utils/popupCenter.ts +0 -48
  221. package/components/assets/images/error.png +0 -0
  222. package/components/context/base.tsx +0 -28
  223. package/components/context/global/context.tsx +0 -39
  224. package/components/context/global/reducer.tsx +0 -56
  225. package/components/context/module/context.tsx +0 -23
  226. package/components/index.ts +0 -12
  227. package/config/antdReplacer.js +0 -51
  228. package/config/env.js +0 -104
  229. package/config/getHttpsConfig.js +0 -66
  230. package/config/jest/cssTransform.js +0 -14
  231. package/config/jest/fileTransform.js +0 -40
  232. package/config/modules.js +0 -134
  233. package/config/paths.js +0 -71
  234. package/config/pnpTs.js +0 -35
  235. package/config/webpack.config.js +0 -835
  236. package/config/webpackDevServer.config.js +0 -130
  237. package/examples.tsx +0 -107
  238. package/index.js +0 -1
  239. package/lib/static/media/loading.4a67a5f3.svg +0 -29
  240. package/logo.svg +0 -7
  241. package/public/favicon.ico +0 -0
  242. package/public/index.html +0 -43
  243. package/public/logo192.png +0 -0
  244. package/public/logo512.png +0 -0
  245. package/public/manifest.json +0 -25
  246. package/public/robots.txt +0 -3
  247. package/react-app-env.d.ts +0 -71
  248. package/reportWebVitals.ts +0 -15
  249. package/scripts/build.js +0 -208
  250. package/scripts/lib.js +0 -200
  251. package/scripts/start.js +0 -162
  252. package/scripts/test.js +0 -49
  253. package/setupTests.ts +0 -5
  254. package/tsconfig.json +0 -30
@@ -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
- }
@@ -1,126 +0,0 @@
1
- import { ConfigProvider, message } from 'antd'
2
- import React, { FC } from 'react'
3
- import { AuthenticationClient } from 'authing-js-sdk'
4
-
5
- import { GuardContext } from '../context/global/context'
6
- import { GuardScenes } from '../../components/AuthingGuard/types'
7
- import { requestClient } from '../_utils/http'
8
- import {
9
- defaultGuardConfig,
10
- OTP_MFA_CODE,
11
- APP_MFA_CODE,
12
- defaultLocalesConfig,
13
- defaultHeaders,
14
- } from '../../components/AuthingGuard/constants'
15
- import { GuardLayout } from '../../components/AuthingGuard/GuardLayout'
16
- import {
17
- UserConfig,
18
- GuardEventsHandler,
19
- } from '../../components/AuthingGuard/types/GuardConfig'
20
-
21
- import './style.less'
22
- import { initI18n } from '../_utils/locales'
23
- const PREFIX_CLS = 'authing-ant'
24
-
25
- message.config({
26
- prefixCls: `${PREFIX_CLS}-message`,
27
- })
28
-
29
- interface AuthingGuardProps extends GuardEventsHandler {
30
- appId: string
31
- config?: UserConfig
32
- visible?: boolean
33
- className?: string
34
- id?: string
35
- }
36
-
37
- export const AuthingGuard: FC<AuthingGuardProps> = ({
38
- appId,
39
- config = {},
40
- visible,
41
- className,
42
- id,
43
- ...guardEvents
44
- }) => {
45
- const {
46
- apiHost,
47
- appDomain,
48
- appHost,
49
- defaultLoginMethod = defaultGuardConfig.defaultLoginMethod,
50
- defaultScenes = defaultGuardConfig.defaultScenes,
51
- defaultRegisterMethod = defaultGuardConfig.defaultRegisterMethod,
52
- lang,
53
- localesConfig = defaultLocalesConfig,
54
- headers = defaultHeaders,
55
- } = config
56
-
57
- initI18n(localesConfig, lang)
58
-
59
- let realHost: string | undefined
60
- if (appHost) {
61
- realHost = appHost
62
- } else if (appDomain) {
63
- const parsedUrl = new URL(defaultGuardConfig.appHost!)
64
- realHost = `${parsedUrl.protocol}//${appDomain}${
65
- parsedUrl.port ? ':' + parsedUrl.port : ''
66
- }`
67
- } else {
68
- realHost = apiHost || defaultGuardConfig.appHost!
69
- }
70
-
71
- requestClient.setBaseUrl(realHost)
72
- requestClient.setLangHeader(headers?.lang)
73
-
74
- const authClient = new AuthenticationClient({
75
- appHost: realHost!,
76
- appId,
77
- requestFrom: 'ui-components',
78
- lang: localesConfig.defaultLang ?? lang,
79
- headers,
80
- onError: (code, msg: any) => {
81
- if (code === 2020) {
82
- return
83
- }
84
- if ([OTP_MFA_CODE, APP_MFA_CODE].includes(code)) {
85
- message.info(msg)
86
- return
87
- }
88
- message.error(msg)
89
- },
90
- })
91
-
92
- const activeTabs = {
93
- [GuardScenes.Login]: defaultLoginMethod,
94
- [GuardScenes.Register]: defaultRegisterMethod,
95
- }
96
-
97
- return (
98
- <ConfigProvider prefixCls={PREFIX_CLS}>
99
- <GuardContext
100
- value={{
101
- authClient,
102
- config: { ...config },
103
- userConfig: config,
104
- appId,
105
- guardScenes: defaultScenes,
106
- activeTabs,
107
- guardTitle: config.title,
108
- mfaData: {
109
- mfaToken: '',
110
- },
111
- guardEvents,
112
- localesConfig: config.localesConfig,
113
- realHost: realHost,
114
- }}
115
- >
116
- <GuardLayout
117
- id={id}
118
- className={className}
119
- visible={visible}
120
- lang={lang}
121
- userConfig={config}
122
- />
123
- </GuardContext>
124
- </ConfigProvider>
125
- )
126
- }