@authing/react-ui-components 3.0.2-beta.7 → 3.0.3-rc.4

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 (260) hide show
  1. package/lib/index.d.ts +4263 -0
  2. package/lib/index.min.css +2 -0
  3. package/lib/index.min.js +2 -0
  4. package/{build/static/js/2.142555a1.chunk.js.LICENSE.txt → lib/index.min.js.LICENSE.txt} +8 -31
  5. package/{build → lib}/static/media/loading.4a67a5f3.svg +0 -0
  6. package/package.json +35 -12
  7. package/.eslintignore +0 -6
  8. package/.eslintrc.js +0 -7
  9. package/.prettierrc +0 -5
  10. package/build/asset-manifest.json +0 -26
  11. package/build/favicon.ico +0 -0
  12. package/build/index.html +0 -1
  13. package/build/logo192.png +0 -0
  14. package/build/logo512.png +0 -0
  15. package/build/manifest.json +0 -25
  16. package/build/robots.txt +0 -3
  17. package/build/static/css/2.5c23c9b8.chunk.css +0 -3
  18. package/build/static/css/2.5c23c9b8.chunk.css.map +0 -1
  19. package/build/static/css/main.6a8701e8.chunk.css +0 -2
  20. package/build/static/css/main.6a8701e8.chunk.css.map +0 -1
  21. package/build/static/js/2.142555a1.chunk.js +0 -3
  22. package/build/static/js/2.142555a1.chunk.js.map +0 -1
  23. package/build/static/js/3.ed27e06b.chunk.js +0 -2
  24. package/build/static/js/3.ed27e06b.chunk.js.map +0 -1
  25. package/build/static/js/main.8d075e4d.chunk.js +0 -2
  26. package/build/static/js/main.8d075e4d.chunk.js.map +0 -1
  27. package/build/static/js/runtime-main.9a428724.js +0 -2
  28. package/build/static/js/runtime-main.9a428724.js.map +0 -1
  29. package/components/AuthingDropdown/index.tsx +0 -52
  30. package/components/AuthingDropdown/style.less +0 -43
  31. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  32. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  33. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  34. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  35. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  36. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  37. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  38. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  39. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  40. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  43. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  44. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  46. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  48. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  49. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  50. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  53. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  54. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  55. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  56. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  57. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  58. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  59. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  60. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  61. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  62. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  63. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  67. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  68. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  69. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  70. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  71. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  72. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  73. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  76. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  77. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  78. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  79. package/components/AuthingGuard/Forms/index.ts +0 -13
  80. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  81. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  82. package/components/AuthingGuard/Header/index.tsx +0 -25
  83. package/components/AuthingGuard/Header/style.less +0 -52
  84. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  85. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  86. package/components/AuthingGuard/IconFont/style.less +0 -6
  87. package/components/AuthingGuard/IconFont/svg.js +0 -2
  88. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  89. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  90. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  91. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  92. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  93. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  94. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  95. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  96. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  97. package/components/AuthingGuard/api/appConfig.ts +0 -146
  98. package/components/AuthingGuard/api/index.ts +0 -3
  99. package/components/AuthingGuard/api/sso.ts +0 -29
  100. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  101. package/components/AuthingGuard/constants.ts +0 -107
  102. package/components/AuthingGuard/hooks/index.tsx +0 -70
  103. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  104. package/components/AuthingGuard/index.tsx +0 -126
  105. package/components/AuthingGuard/style.less +0 -103
  106. package/components/AuthingGuard/types/Forms.ts +0 -94
  107. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  108. package/components/AuthingGuard/types/GuardState.ts +0 -7
  109. package/components/AuthingGuard/types/Locales.ts +0 -12
  110. package/components/AuthingGuard/types/index.ts +0 -4
  111. package/components/AuthingTabs/index.tsx +0 -98
  112. package/components/AuthingTabs/style.less +0 -135
  113. package/components/BindTotp/core/bindSuccess.tsx +0 -72
  114. package/components/BindTotp/core/securityCode.tsx +0 -108
  115. package/components/BindTotp/index.tsx +0 -134
  116. package/components/BindTotp/interface.ts +0 -30
  117. package/components/BindTotp/styles.less +0 -57
  118. package/components/ChangeLanguage/index.tsx +0 -35
  119. package/components/ChangePassword/core/firstLoginReset.tsx +0 -111
  120. package/components/ChangePassword/core/rotateReset.tsx +0 -125
  121. package/components/ChangePassword/index.tsx +0 -72
  122. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  123. package/components/CompleteInfo/index.tsx +0 -45
  124. package/components/CompleteInfo/interface.ts +0 -40
  125. package/components/CompleteInfo/styles.less +0 -7
  126. package/components/CopyAbleText/index.tsx +0 -54
  127. package/components/CopyAbleText/style.less +0 -13
  128. package/components/DownloadAuthenticator/index.tsx +0 -97
  129. package/components/DownloadAuthenticator/interface.ts +0 -22
  130. package/components/DownloadAuthenticator/styles.less +0 -52
  131. package/components/Error/index.tsx +0 -21
  132. package/components/Error/interface.ts +0 -9
  133. package/components/Error/styles.less +0 -12
  134. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  135. package/components/ForgetPassword/index.tsx +0 -78
  136. package/components/ForgetPassword/interface.ts +0 -32
  137. package/components/Guard/Guard.tsx +0 -295
  138. package/components/Guard/authClient.ts +0 -44
  139. package/components/Guard/config.ts +0 -19
  140. package/components/Guard/event.ts +0 -52
  141. package/components/Guard/index.tsx +0 -4
  142. package/components/Guard/module.ts +0 -20
  143. package/components/Guard/stateMachine.ts +0 -152
  144. package/components/Guard/styles.less +0 -461
  145. package/components/IconFont/iconfont.js +0 -74
  146. package/components/IconFont/index.tsx +0 -16
  147. package/components/IconFont/style.less +0 -6
  148. package/components/IconFont/svg.js +0 -2
  149. package/components/ImagePro/index.tsx +0 -53
  150. package/components/ImagePro/styles.less +0 -40
  151. package/components/InputNumber/index.tsx +0 -33
  152. package/components/Login/codemap.ts +0 -49
  153. package/components/Login/core/withAD.tsx +0 -9
  154. package/components/Login/core/withAppQrcode.tsx +0 -49
  155. package/components/Login/core/withLDAP.tsx +0 -146
  156. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  157. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -30
  158. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  159. package/components/Login/core/withPassword/index.tsx +0 -173
  160. package/components/Login/core/withPhonecode.tsx +0 -122
  161. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  162. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  163. package/components/Login/index.tsx +0 -374
  164. package/components/Login/interface.ts +0 -74
  165. package/components/Login/socialLogin/index.tsx +0 -407
  166. package/components/Login/socialLogin/style.less +0 -69
  167. package/components/Login/styles.less +0 -53
  168. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  169. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  170. package/components/MFA/VerifyCodeInput/style.less +0 -35
  171. package/components/MFA/codemap.ts +0 -24
  172. package/components/MFA/core/email.tsx +0 -203
  173. package/components/MFA/core/face.tsx +0 -297
  174. package/components/MFA/core/face_deps.tsx +0 -37
  175. package/components/MFA/core/sms.tsx +0 -203
  176. package/components/MFA/core/totp.tsx +0 -122
  177. package/components/MFA/index.tsx +0 -143
  178. package/components/MFA/interface.ts +0 -51
  179. package/components/MFA/mfaMethods/index.tsx +0 -88
  180. package/components/MFA/mfaMethods/style.less +0 -39
  181. package/components/MFA/styles.less +0 -100
  182. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  183. package/components/NeedHelpView/index.tsx +0 -47
  184. package/components/RecoveryCode/core/useCode.tsx +0 -71
  185. package/components/RecoveryCode/index.tsx +0 -27
  186. package/components/RecoveryCode/interface.ts +0 -31
  187. package/components/RecoveryCode/style.less +0 -13
  188. package/components/Register/codemap.ts +0 -12
  189. package/components/Register/components/Agreements/index.tsx +0 -81
  190. package/components/Register/components/Agreements/style.less +0 -44
  191. package/components/Register/core/WithEmail.tsx +0 -242
  192. package/components/Register/core/WithPhone.tsx +0 -184
  193. package/components/Register/index.tsx +0 -139
  194. package/components/Register/interface.ts +0 -50
  195. package/components/SendCode/SendCodeBtn.tsx +0 -96
  196. package/components/SendCode/index.tsx +0 -94
  197. package/components/SendCode/style.less +0 -31
  198. package/components/ShieldSpin/index.tsx +0 -27
  199. package/components/ShieldSpin/loading.svg +0 -29
  200. package/components/SubmitButton/index.tsx +0 -50
  201. package/components/SubmitSuccess/index.tsx +0 -66
  202. package/components/SubmitSuccess/interface.ts +0 -17
  203. package/components/Type/index.ts +0 -52
  204. package/components/ValidatorRules/ValidatorFormItem.tsx +0 -139
  205. package/components/ValidatorRules/index.ts +0 -20
  206. package/components/VerifyCodeInput/index.tsx +0 -76
  207. package/components/VerifyCodeInput/style.less +0 -24
  208. package/components/_utils/GuardErrorCode.ts +0 -9
  209. package/components/_utils/clipboard.ts +0 -27
  210. package/components/_utils/config.ts +0 -116
  211. package/components/_utils/guradHttp.ts +0 -101
  212. package/components/_utils/hooks/index.ts +0 -64
  213. package/components/_utils/http.ts +0 -85
  214. package/components/_utils/index.ts +0 -326
  215. package/components/_utils/locales/en/common.json +0 -229
  216. package/components/_utils/locales/en/index.ts +0 -6
  217. package/components/_utils/locales/en/login.json +0 -96
  218. package/components/_utils/locales/en/map.json +0 -4
  219. package/components/_utils/locales/en/user.json +0 -82
  220. package/components/_utils/locales/index.ts +0 -45
  221. package/components/_utils/locales/zh/common.json +0 -229
  222. package/components/_utils/locales/zh/index.ts +0 -6
  223. package/components/_utils/locales/zh/login.json +0 -96
  224. package/components/_utils/locales/zh/map.json +0 -4
  225. package/components/_utils/locales/zh/user.json +0 -83
  226. package/components/_utils/popupCenter.ts +0 -48
  227. package/components/assets/images/error.png +0 -0
  228. package/components/context/base.tsx +0 -28
  229. package/components/context/global/context.tsx +0 -39
  230. package/components/context/global/reducer.tsx +0 -56
  231. package/components/context/module/context.tsx +0 -23
  232. package/components/index.ts +0 -9
  233. package/config/antdReplacer.js +0 -51
  234. package/config/env.js +0 -104
  235. package/config/getHttpsConfig.js +0 -66
  236. package/config/jest/cssTransform.js +0 -14
  237. package/config/jest/fileTransform.js +0 -40
  238. package/config/modules.js +0 -134
  239. package/config/paths.js +0 -71
  240. package/config/pnpTs.js +0 -35
  241. package/config/webpack.config.js +0 -835
  242. package/config/webpackDevServer.config.js +0 -130
  243. package/examples.tsx +0 -87
  244. package/index.js +0 -1
  245. package/logo.svg +0 -7
  246. package/public/favicon.ico +0 -0
  247. package/public/index.html +0 -43
  248. package/public/logo192.png +0 -0
  249. package/public/logo512.png +0 -0
  250. package/public/manifest.json +0 -25
  251. package/public/robots.txt +0 -3
  252. package/react-app-env.d.ts +0 -71
  253. package/reportWebVitals.ts +0 -15
  254. package/scripts/build.js +0 -208
  255. package/scripts/lib.js +0 -200
  256. package/scripts/publish.js +0 -57
  257. package/scripts/start.js +0 -162
  258. package/scripts/test.js +0 -49
  259. package/setupTests.ts +0 -5
  260. 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,107 +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
- 'tenant-id': string
97
- 'sdk-version': string
98
- 'request-from': string
99
- lang: string
100
- } = {
101
- 'userpool-id': 'x-authing-userpool-id',
102
- 'app-id': 'x-authing-app-id',
103
- 'tenant-id': 'x-authing-app-tenant-id',
104
- 'request-from': 'x-authing-request-from',
105
- 'sdk-version': 'x-authing-sdk-version',
106
- lang: 'x-authing-lang',
107
- }
@@ -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
- }