@authing/react-ui-components 3.0.2-beta.1 → 3.0.2-beta.14

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 (263) hide show
  1. package/lib/index.d.ts +555 -46
  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 +30 -10
  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/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.9512539b.chunk.css +0 -3
  18. package/build/static/css/2.9512539b.chunk.css.map +0 -1
  19. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  20. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  21. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  22. package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
  23. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  24. package/build/static/js/3.fd17f196.chunk.js +0 -2
  25. package/build/static/js/3.fd17f196.chunk.js.map +0 -1
  26. package/build/static/js/main.a47645ff.chunk.js +0 -2
  27. package/build/static/js/main.a47645ff.chunk.js.map +0 -1
  28. package/build/static/js/runtime-main.ef138021.js +0 -2
  29. package/build/static/js/runtime-main.ef138021.js.map +0 -1
  30. package/build/static/media/loading.4a67a5f3.svg +0 -29
  31. package/components/AuthingDropdown/index.tsx +0 -52
  32. package/components/AuthingDropdown/style.less +0 -43
  33. package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
  34. package/components/AuthingGuard/AppMFALayout/style.less +0 -12
  35. package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
  36. package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
  37. package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
  38. package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
  39. package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
  40. package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
  41. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
  42. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
  43. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
  44. package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
  45. package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
  46. package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
  47. package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
  48. package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
  49. package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
  50. package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
  51. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
  52. package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
  53. package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
  54. package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
  55. package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
  56. package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
  57. package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
  58. package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
  59. package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
  60. package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
  61. package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
  62. package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
  63. package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
  64. package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
  65. package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
  66. package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
  67. package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
  68. package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
  69. package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
  70. package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
  71. package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
  72. package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
  73. package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
  74. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
  75. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
  76. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
  77. package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
  78. package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
  79. package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
  80. package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
  81. package/components/AuthingGuard/Forms/index.ts +0 -13
  82. package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
  83. package/components/AuthingGuard/GuardLayout/style.less +0 -111
  84. package/components/AuthingGuard/Header/index.tsx +0 -25
  85. package/components/AuthingGuard/Header/style.less +0 -52
  86. package/components/AuthingGuard/IconFont/iconfont.js +0 -74
  87. package/components/AuthingGuard/IconFont/index.tsx +0 -19
  88. package/components/AuthingGuard/IconFont/style.less +0 -6
  89. package/components/AuthingGuard/IconFont/svg.js +0 -2
  90. package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
  91. package/components/AuthingGuard/LoginLayout/style.less +0 -0
  92. package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
  93. package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
  94. package/components/AuthingGuard/MfaLayout/style.less +0 -3
  95. package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
  96. package/components/AuthingGuard/RegisterLayout/style.less +0 -0
  97. package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
  98. package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
  99. package/components/AuthingGuard/api/appConfig.ts +0 -146
  100. package/components/AuthingGuard/api/index.ts +0 -3
  101. package/components/AuthingGuard/api/sso.ts +0 -29
  102. package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
  103. package/components/AuthingGuard/constants.ts +0 -107
  104. package/components/AuthingGuard/hooks/index.tsx +0 -70
  105. package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
  106. package/components/AuthingGuard/index.tsx +0 -126
  107. package/components/AuthingGuard/style.less +0 -103
  108. package/components/AuthingGuard/types/Forms.ts +0 -94
  109. package/components/AuthingGuard/types/GuardConfig.ts +0 -420
  110. package/components/AuthingGuard/types/GuardState.ts +0 -7
  111. package/components/AuthingGuard/types/Locales.ts +0 -12
  112. package/components/AuthingGuard/types/index.ts +0 -4
  113. package/components/AuthingTabs/index.tsx +0 -98
  114. package/components/AuthingTabs/style.less +0 -135
  115. package/components/BindTotp/core/bindSuccess.tsx +0 -73
  116. package/components/BindTotp/core/securityCode.tsx +0 -108
  117. package/components/BindTotp/index.tsx +0 -134
  118. package/components/BindTotp/interface.ts +0 -30
  119. package/components/BindTotp/styles.less +0 -57
  120. package/components/ChangeLanguage/index.tsx +0 -35
  121. package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
  122. package/components/ChangePassword/core/rotateReset.tsx +0 -114
  123. package/components/ChangePassword/index.tsx +0 -59
  124. package/components/CompleteInfo/core/completeInfo.tsx +0 -155
  125. package/components/CompleteInfo/index.tsx +0 -45
  126. package/components/CompleteInfo/interface.ts +0 -40
  127. package/components/CompleteInfo/styles.less +0 -7
  128. package/components/CopyAbleText/index.tsx +0 -54
  129. package/components/CopyAbleText/style.less +0 -13
  130. package/components/DownloadAuthenticator/index.tsx +0 -97
  131. package/components/DownloadAuthenticator/interface.ts +0 -22
  132. package/components/DownloadAuthenticator/styles.less +0 -52
  133. package/components/Error/index.tsx +0 -21
  134. package/components/Error/interface.ts +0 -9
  135. package/components/Error/styles.less +0 -12
  136. package/components/ForgetPassword/core/resetPassword.tsx +0 -162
  137. package/components/ForgetPassword/index.tsx +0 -78
  138. package/components/ForgetPassword/interface.ts +0 -32
  139. package/components/Guard/Guard.tsx +0 -255
  140. package/components/Guard/authClient.ts +0 -46
  141. package/components/Guard/config.ts +0 -19
  142. package/components/Guard/event.ts +0 -52
  143. package/components/Guard/index.tsx +0 -4
  144. package/components/Guard/module.ts +0 -20
  145. package/components/Guard/stateMachine.ts +0 -133
  146. package/components/Guard/styles.less +0 -461
  147. package/components/IconFont/iconfont.js +0 -74
  148. package/components/IconFont/index.tsx +0 -16
  149. package/components/IconFont/style.less +0 -6
  150. package/components/IconFont/svg.js +0 -2
  151. package/components/ImagePro/index.tsx +0 -53
  152. package/components/ImagePro/styles.less +0 -40
  153. package/components/InputNumber/index.tsx +0 -33
  154. package/components/Login/codemap.ts +0 -47
  155. package/components/Login/core/withAD.tsx +0 -9
  156. package/components/Login/core/withAppQrcode.tsx +0 -49
  157. package/components/Login/core/withLDAP.tsx +0 -146
  158. package/components/Login/core/withPassword/FormItemAccount.tsx +0 -42
  159. package/components/Login/core/withPassword/GraphicVerifyCode.tsx +0 -31
  160. package/components/Login/core/withPassword/InputAccount.tsx +0 -64
  161. package/components/Login/core/withPassword/index.tsx +0 -173
  162. package/components/Login/core/withPhonecode.tsx +0 -122
  163. package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
  164. package/components/Login/core/withWechatmpQrcode.tsx +0 -53
  165. package/components/Login/index.tsx +0 -373
  166. package/components/Login/props.ts +0 -74
  167. package/components/Login/socialLogin/index.tsx +0 -407
  168. package/components/Login/socialLogin/style.less +0 -69
  169. package/components/Login/styles.less +0 -53
  170. package/components/MFA/VerifyCodeInput/VerifyCodeFormItem.tsx +0 -41
  171. package/components/MFA/VerifyCodeInput/index.tsx +0 -145
  172. package/components/MFA/VerifyCodeInput/style.less +0 -35
  173. package/components/MFA/codemap.ts +0 -24
  174. package/components/MFA/core/email.tsx +0 -203
  175. package/components/MFA/core/face.tsx +0 -297
  176. package/components/MFA/core/face_deps.tsx +0 -37
  177. package/components/MFA/core/sms.tsx +0 -204
  178. package/components/MFA/core/totp.tsx +0 -122
  179. package/components/MFA/index.tsx +0 -143
  180. package/components/MFA/mfaMethods/index.tsx +0 -88
  181. package/components/MFA/mfaMethods/style.less +0 -39
  182. package/components/MFA/props.ts +0 -51
  183. package/components/MFA/styles.less +0 -100
  184. package/components/NeedHelpView/core/describeQuestions.tsx +0 -245
  185. package/components/NeedHelpView/index.tsx +0 -47
  186. package/components/RecoveryCode/core/useCode.tsx +0 -71
  187. package/components/RecoveryCode/index.tsx +0 -27
  188. package/components/RecoveryCode/interface.ts +0 -31
  189. package/components/RecoveryCode/style.less +0 -13
  190. package/components/Register/codemap.ts +0 -12
  191. package/components/Register/components/Agreements/index.tsx +0 -81
  192. package/components/Register/components/Agreements/style.less +0 -44
  193. package/components/Register/core/WithEmail.tsx +0 -239
  194. package/components/Register/core/WithPhone.tsx +0 -184
  195. package/components/Register/index.tsx +0 -138
  196. package/components/Register/props.ts +0 -50
  197. package/components/SendCode/SendCodeBtn.tsx +0 -96
  198. package/components/SendCode/index.tsx +0 -94
  199. package/components/SendCode/style.less +0 -31
  200. package/components/ShieldSpin/index.tsx +0 -27
  201. package/components/ShieldSpin/loading.svg +0 -29
  202. package/components/SubmitButton/index.tsx +0 -50
  203. package/components/SubmitSuccess/index.tsx +0 -66
  204. package/components/SubmitSuccess/interface.ts +0 -17
  205. package/components/Type/index.ts +0 -52
  206. package/components/ValidatorRules/EmailFormItem.tsx +0 -95
  207. package/components/ValidatorRules/PhoneFormItem.tsx +0 -100
  208. package/components/ValidatorRules/index.ts +0 -14
  209. package/components/VerifyCodeInput/index.tsx +0 -76
  210. package/components/VerifyCodeInput/style.less +0 -24
  211. package/components/_utils/GuardErrorCode.ts +0 -9
  212. package/components/_utils/clipboard.ts +0 -27
  213. package/components/_utils/config.ts +0 -118
  214. package/components/_utils/guradHttp.ts +0 -97
  215. package/components/_utils/hooks/index.ts +0 -64
  216. package/components/_utils/http.ts +0 -85
  217. package/components/_utils/index.ts +0 -322
  218. package/components/_utils/locales/en/common.json +0 -227
  219. package/components/_utils/locales/en/index.ts +0 -6
  220. package/components/_utils/locales/en/login.json +0 -96
  221. package/components/_utils/locales/en/map.json +0 -4
  222. package/components/_utils/locales/en/user.json +0 -82
  223. package/components/_utils/locales/index.ts +0 -45
  224. package/components/_utils/locales/zh/common.json +0 -227
  225. package/components/_utils/locales/zh/index.ts +0 -6
  226. package/components/_utils/locales/zh/login.json +0 -96
  227. package/components/_utils/locales/zh/map.json +0 -4
  228. package/components/_utils/locales/zh/user.json +0 -82
  229. package/components/_utils/popupCenter.ts +0 -48
  230. package/components/assets/images/error.png +0 -0
  231. package/components/context/base.tsx +0 -28
  232. package/components/context/global/context.tsx +0 -39
  233. package/components/context/global/reducer.tsx +0 -56
  234. package/components/context/module/context.tsx +0 -23
  235. package/components/index.ts +0 -12
  236. package/config/antdReplacer.js +0 -51
  237. package/config/env.js +0 -104
  238. package/config/getHttpsConfig.js +0 -66
  239. package/config/jest/cssTransform.js +0 -14
  240. package/config/jest/fileTransform.js +0 -40
  241. package/config/modules.js +0 -134
  242. package/config/paths.js +0 -71
  243. package/config/pnpTs.js +0 -35
  244. package/config/webpack.config.js +0 -835
  245. package/config/webpackDevServer.config.js +0 -130
  246. package/examples.tsx +0 -82
  247. package/index.js +0 -1
  248. package/logo.svg +0 -7
  249. package/public/favicon.ico +0 -0
  250. package/public/index.html +0 -43
  251. package/public/logo192.png +0 -0
  252. package/public/logo512.png +0 -0
  253. package/public/manifest.json +0 -25
  254. package/public/robots.txt +0 -3
  255. package/react-app-env.d.ts +0 -71
  256. package/reportWebVitals.ts +0 -15
  257. package/scripts/build.js +0 -208
  258. package/scripts/lib.js +0 -200
  259. package/scripts/publish.js +0 -57
  260. package/scripts/start.js +0 -162
  261. package/scripts/test.js +0 -49
  262. package/setupTests.ts +0 -5
  263. package/tsconfig.json +0 -30
@@ -1,94 +0,0 @@
1
- import { Col, message, Row } from 'antd'
2
- import React, { FC } from 'react'
3
- import { EmailScene } from 'authing-js-sdk'
4
-
5
- import { SendCodeBtn } from './SendCodeBtn'
6
-
7
- import './style.less'
8
- import { useTranslation } from 'react-i18next'
9
- import { useAuthClient } from '../Guard/authClient'
10
- import { validate } from '../_utils'
11
- import { InputProps } from 'antd/lib/input'
12
- import { InputNumber } from '../InputNumber'
13
-
14
- export interface SendPhoneCodeProps extends InputProps {
15
- method: 'phone' | 'email'
16
- data: string
17
- form?: any
18
- onSendCodeBefore?: any // 点击的时候先做这个
19
- }
20
-
21
- export const SendCode: FC<SendPhoneCodeProps> = ({
22
- method,
23
- data,
24
- value,
25
- onChange,
26
- form,
27
- onSendCodeBefore,
28
- maxLength,
29
- ...inputProps
30
- }) => {
31
- const { t } = useTranslation()
32
-
33
- const authClient = useAuthClient()
34
-
35
- const sendEmail = async (email: string) => {
36
- if (!email) {
37
- message.error(t('login.inputEmail'))
38
- return false
39
- }
40
- if (!validate('email', email)) {
41
- message.error(t('common.emailFormatError'))
42
- return false
43
- }
44
- try {
45
- await authClient.sendEmail(email, EmailScene.ResetPassword)
46
- // onSend?.()
47
- return true
48
- } catch (error) {
49
- // onError?.(error)
50
- return false
51
- }
52
- }
53
-
54
- const sendPhone = async (phone: string) => {
55
- try {
56
- await authClient.sendSmsCode(phone)
57
- return true
58
- } catch (error) {
59
- return false
60
- }
61
- }
62
-
63
- return (
64
- <>
65
- <Row justify="space-between" align="middle">
66
- <Col span={15} className="g2-send-code-input-col">
67
- <InputNumber
68
- value={value}
69
- onChange={onChange}
70
- {...inputProps}
71
- maxLength={maxLength}
72
- />
73
- </Col>
74
- <Col offset={1} span={8}>
75
- <SendCodeBtn
76
- beforeSend={() => {
77
- return onSendCodeBefore()
78
- .then(async (b: any) => {
79
- let phoneData = form ? form.getFieldValue(method) : data
80
- return method === 'phone'
81
- ? await sendPhone(phoneData)
82
- : await sendEmail(phoneData)
83
- })
84
- .catch((e: any) => {
85
- // console.log('e', e)
86
- return false
87
- })
88
- }}
89
- />
90
- </Col>
91
- </Row>
92
- </>
93
- )
94
- }
@@ -1,31 +0,0 @@
1
- .authing-g2-send-code-btn {
2
- height: 46px;
3
- width: 100%;
4
- border: 1px solid #d4d6dc;
5
- border-radius: 4px;
6
- }
7
-
8
- .authing-g2-send-code-btn:hover {
9
- background: rgba(57, 106, 255, 0.1);
10
- }
11
-
12
- .authing-g2-send-code-btn:focus {
13
- outline: none;
14
- }
15
-
16
- .authing-g2-send-code-btn[disabled] {
17
- cursor: not-allowed;
18
- filter: opacity(0.5);
19
- }
20
-
21
- @media only screen and (max-width: 719px) {
22
- .authing-g2-send-code-btn {
23
- font-size: 14px;
24
- }
25
- }
26
-
27
- .g2-loading-btn-center {
28
- .authing-ant-btn-loading-icon .anticon {
29
- padding-right: 0;
30
- }
31
- }
@@ -1,27 +0,0 @@
1
- import React from 'react'
2
- import { ReactComponent as LoadShielding } from './loading.svg'
3
-
4
- interface IG2SpinProps {
5
- size?: number
6
- }
7
-
8
- export const ShieldSpin = (props: IG2SpinProps) => {
9
- let size = props.size ? props.size : 50
10
-
11
- return (
12
- <div
13
- style={{
14
- width: size,
15
- height: size,
16
- }}
17
- >
18
- <LoadShielding />
19
- </div>
20
- )
21
- }
22
-
23
- export const Spin = () => (
24
- <div className="g2-init-setting-loading">
25
- <ShieldSpin size={100} />
26
- </div>
27
- )
@@ -1,29 +0,0 @@
1
- <svg width="100%" height="100%"
2
- viewBox="0 0 150 150" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <style>
4
- #path-f {
5
- fill: none;
6
- stroke: #eaebee;
7
- stroke-width: 10;
8
- stroke-dasharray: 100 220;
9
- animation: dash 40s infinite linear forwards;
10
- }
11
- #path-b {
12
- fill: none;
13
- stroke: #0080ff;
14
- stroke-width: 8;
15
- stroke-linecap: round;
16
- stroke-linejoin: round;
17
- }
18
- @keyframes dash {
19
- to {
20
- stroke-dashoffset: 12000;
21
- }
22
- }
23
- </style>
24
- <title>Loading</title>
25
- <g id="单独" transform="translate(25.000000, 16.000000)" fill-rule="nonzero" stroke-width="2" >
26
- <path d="M50,0 L0,30 C0,31 0,32 0,33 C0,69 20,100 50,116 C79,100 100,69 100,33 C100,32 99,31 99,30 L50,0 Z" id="path-b"/>
27
- <path d="M50,0 L0,30 C0,31 0,32 0,33 C0,69 20,100 50,116 C79,100 100,69 100,33 C100,32 99,31 99,30 L50,0 Z" id="path-f"/>
28
- </g>
29
- </svg>
@@ -1,50 +0,0 @@
1
- import React, {
2
- forwardRef,
3
- useState,
4
- useImperativeHandle,
5
- useEffect,
6
- } from 'react'
7
- import { Button } from 'antd'
8
-
9
- interface SubmitButtonProps {
10
- text?: string
11
- className?: string
12
- onClick?: any
13
- }
14
- const SubmitButton = (props: SubmitButtonProps, ref: any) => {
15
- let [spin, setSpin] = useState(false) // spin 状态需要手动设置关闭
16
- let [shaking, setShaking] = useState(false) // 抖动状态会自动关闭
17
-
18
- useEffect(() => {
19
- if (shaking === true) {
20
- setTimeout(() => {
21
- setShaking(false)
22
- }, 1000)
23
- }
24
- }, [shaking])
25
-
26
- useImperativeHandle(ref, () => ({
27
- onError: (text?: string) => {
28
- setShaking(true)
29
- },
30
- onSpin: (sp: boolean) => {
31
- setSpin(sp)
32
- },
33
- }))
34
-
35
- let propsCls = props.className ? props.className : ''
36
- let shakingCls = shaking ? 'shaking' : ''
37
- return (
38
- <Button
39
- size="large"
40
- type="primary"
41
- htmlType="submit"
42
- loading={spin}
43
- onClick={props.onClick ? props.onClick : () => {}}
44
- className={`authing-g2-submit-button ${propsCls} ${shakingCls}`}
45
- >
46
- {props.text}
47
- </Button>
48
- )
49
- }
50
- export default forwardRef(SubmitButton)
@@ -1,66 +0,0 @@
1
- import React, { useEffect, useRef, useState } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { GuardModuleType } from '..'
4
- import { ImagePro } from '../ImagePro'
5
- import SubmitButton from '../SubmitButton'
6
- import { GuardSubmitSuccessViewProps } from './interface'
7
-
8
- export const GuardSubmitSuccessView: React.FC<GuardSubmitSuccessViewProps> = (
9
- props
10
- ) => {
11
- const { t } = useTranslation()
12
- const { initData, config } = props
13
- const [countDown, setCountDown] = useState(5)
14
-
15
- const timerRef = useRef<any>(0)
16
-
17
- const {
18
- title = t('common.problem.successTip'),
19
- message = t('common.problem.successTipMsg'),
20
- } = initData ?? {}
21
-
22
- const cdnBase = config?.__publicConfig__?.cdnBase
23
-
24
- useEffect(() => {
25
- timerRef.current = setInterval(() => {
26
- setCountDown((prev) => {
27
- return prev - 1
28
- })
29
- }, 1000)
30
-
31
- return () => clearInterval(timerRef.current)
32
- }, [])
33
-
34
- useEffect(() => {
35
- if (countDown <= 0) {
36
- clearInterval(timerRef.current)
37
- props.__changeModule?.(GuardModuleType.LOGIN)
38
- }
39
- // eslint-disable-next-line react-hooks/exhaustive-deps
40
- }, [countDown])
41
-
42
- return (
43
- <div className="g2-view-container">
44
- <div className="g2-view-tabs g2-questions-send-success-page">
45
- <ImagePro
46
- className="plate"
47
- src={`${cdnBase}/questions-send-ok.png`}
48
- alt=""
49
- width={191}
50
- height={146}
51
- />
52
- <div className="title">{title}</div>
53
- <div className="message">{message}</div>
54
- <SubmitButton
55
- onClick={() => {
56
- props.__changeModule?.(GuardModuleType.LOGIN)
57
- }}
58
- text={t('common.backLoginPage')}
59
- />
60
- <div className="timer-tip">
61
- {countDown} {t('common.pToLogin')}
62
- </div>
63
- </div>
64
- </div>
65
- )
66
- }
@@ -1,17 +0,0 @@
1
- import { IG2Config, IG2Events, IG2FCViewProps } from '../Type'
2
-
3
- export interface SubmitSuccessEvents extends IG2Events {}
4
-
5
- export interface SubmitSuccessConfig extends IG2Config {}
6
-
7
- export interface SubmitSuccessInitData {
8
- title?: string
9
- message?: string
10
- }
11
-
12
- export interface GuardSubmitSuccessViewProps
13
- extends IG2FCViewProps,
14
- SubmitSuccessEvents {
15
- config: SubmitSuccessConfig
16
- initData?: SubmitSuccessInitData
17
- }
@@ -1,52 +0,0 @@
1
- import { AuthenticationClient, CommonMessage } from 'authing-js-sdk'
2
- import { Lang } from 'authing-js-sdk/build/main/types'
3
- import { GuardMode } from '..'
4
- import { ApplicationConfig } from '../AuthingGuard/api'
5
- import { GuardModuleType } from '../Guard/module'
6
- export interface IG2FCProps extends IG2Events {
7
- appId: string
8
- config?: Partial<IG2Config>
9
- }
10
-
11
- export interface IG2FCViewProps extends IG2FCProps {
12
- config: IG2Config
13
- }
14
-
15
- export interface IG2Config {
16
- title: string
17
- logo: string
18
- lang: Lang
19
- langRange: Lang[]
20
- host: string
21
- mode: GuardMode
22
- clickCloseable: boolean
23
- escCloseable: boolean
24
- userpool?: string
25
- contentCss?: string
26
- target?: HTMLElement | string
27
- __appHost__?: string
28
- __publicConfig__?: ApplicationConfig
29
- }
30
-
31
- const defaultG2Config: IG2Config = {
32
- lang: 'zh-CN',
33
- langRange: ['zh-CN', 'en-US'],
34
- title: 'Authing',
35
- escCloseable: true,
36
- clickCloseable: true,
37
- mode: GuardMode.Normal,
38
- host: 'https://core.authing.cn',
39
- logo:
40
- 'https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png',
41
- }
42
-
43
- export interface IG2Events {
44
- onLoad?: (authClient: AuthenticationClient) => void
45
- onLoadError?: (error: CommonMessage) => void
46
- onClose?: () => void
47
- onLangChange?: (lang: Lang) => void
48
- // __codePaser?: (code: number) => Function
49
- __changeModule?: (moduleName: GuardModuleType, initData?: any) => void
50
- }
51
-
52
- export const getDefaultG2Config = (): IG2Config => defaultG2Config
@@ -1,95 +0,0 @@
1
- import { Form } from 'antd'
2
- import React, {
3
- forwardRef,
4
- useCallback,
5
- useImperativeHandle,
6
- useMemo,
7
- useState,
8
- } from 'react'
9
- import { fieldRequiredRule, sleep, VALIDATE_PATTERN } from '../_utils'
10
- import { useGuardHttp } from '../_utils/guradHttp'
11
- import { useTranslation } from 'react-i18next'
12
- import { ICheckProps, ValidatorFormItemProps } from '.'
13
- import { Rule } from 'antd/lib/form'
14
- import { useDebounce } from '../_utils/hooks'
15
-
16
- const checkError = (message: string) => Promise.reject(new Error(message))
17
-
18
- const checkSuccess = (message?: string) => Promise.resolve(message ?? '')
19
-
20
- export const EmailFormItem = forwardRef<ICheckProps, ValidatorFormItemProps>(
21
- (props, ref) => {
22
- const { userPoolId, form, checkRepeat = false, ...formItemProps } = props
23
- const { get } = useGuardHttp()
24
- const { t } = useTranslation()
25
- const [checked, setChecked] = useState(false)
26
-
27
- const [isReady, setIsReady] = useState(false)
28
-
29
- const checkEmail = useDebounce(async () => {
30
- const email = form?.getFieldValue('email')
31
- if (!(email && VALIDATE_PATTERN.email.test(email))) {
32
- return
33
- }
34
- let { data } = await get<boolean>(`/api/v2/users/find`, {
35
- userPoolId: userPoolId,
36
- key: email,
37
- type: 'email',
38
- })
39
- setChecked(Boolean(data))
40
- setIsReady(true)
41
- form?.validateFields(['email'])
42
- }, 500)
43
-
44
- useImperativeHandle(ref, () => ({
45
- check: () => {
46
- setChecked(false)
47
- setIsReady(false)
48
- checkEmail()
49
- },
50
- }))
51
-
52
- const checkReady = useCallback(async (): Promise<boolean> => {
53
- if (isReady) return true
54
-
55
- await sleep(100)
56
-
57
- return await checkReady()
58
- }, [isReady])
59
-
60
- const validator = useCallback(async () => {
61
- if ((await checkReady()) && checked)
62
- return checkError(t('common.checkEmail'))
63
- else return checkSuccess()
64
- }, [checkReady, checked, t])
65
-
66
- const rules = useMemo<Rule[]>(() => {
67
- const rules = [
68
- ...fieldRequiredRule(t('common.emailLabel')),
69
- {
70
- validator: (_: any, value: any) => {
71
- if (!VALIDATE_PATTERN.email.test(value))
72
- return checkError(t('common.emailFormatError'))
73
-
74
- return checkSuccess()
75
- },
76
- },
77
- ]
78
- checkRepeat &&
79
- rules.push({
80
- validator,
81
- })
82
-
83
- return rules
84
- }, [checkRepeat, t, validator])
85
-
86
- return (
87
- <Form.Item
88
- validateFirst={true}
89
- name="email"
90
- rules={[...rules, ...(formItemProps?.rules ?? [])]}
91
- {...formItemProps}
92
- />
93
- )
94
- }
95
- )
@@ -1,100 +0,0 @@
1
- import { Form } from 'antd'
2
- import React, {
3
- forwardRef,
4
- useCallback,
5
- useImperativeHandle,
6
- useMemo,
7
- useState,
8
- } from 'react'
9
- import { fieldRequiredRule, sleep, VALIDATE_PATTERN } from '../_utils'
10
- import { useGuardHttp } from '../_utils/guradHttp'
11
- import { useDebounce } from '../_utils/hooks'
12
- import { useTranslation } from 'react-i18next'
13
- import { ICheckProps, ValidatorFormItemProps } from '.'
14
- import { Rule } from 'antd/lib/form'
15
-
16
- const checkError = (message: string) => Promise.reject(new Error(message))
17
-
18
- const checkSuccess = (message?: string) => Promise.resolve(message)
19
-
20
- export const PhoneFormItem = forwardRef<ICheckProps, ValidatorFormItemProps>(
21
- (props, ref) => {
22
- const { userPoolId, form, checkRepeat = false, ...formItemProps } = props
23
-
24
- const { get } = useGuardHttp()
25
- const { t } = useTranslation()
26
- const [checked, setChecked] = useState(false)
27
-
28
- const [isReady, setIsReady] = useState(false)
29
-
30
- const checkPhone = useDebounce(async () => {
31
- const phone = form?.getFieldValue('phone')
32
- if (!(phone && VALIDATE_PATTERN.phone.test(phone))) {
33
- return
34
- }
35
- let { data } = await get<boolean>(`/api/v2/users/find`, {
36
- userPoolId: userPoolId,
37
- key: phone,
38
- type: 'phone',
39
- })
40
-
41
- setChecked(Boolean(data))
42
- setIsReady(true)
43
- form?.validateFields(['phone'])
44
- }, 500)
45
-
46
- useImperativeHandle(ref, () => ({
47
- check: () => {
48
- setChecked(false)
49
- setIsReady(false)
50
- checkPhone()
51
- },
52
- }))
53
-
54
- const checkReady = useCallback(async (): Promise<boolean> => {
55
- if (isReady) return true
56
-
57
- await sleep(100)
58
-
59
- return await checkReady()
60
- }, [isReady])
61
-
62
- const validator = useCallback(
63
- async (_: any, value: any) => {
64
- if ((await checkReady()) && checked)
65
- return checkError(t('common.checkPhone'))
66
- else return checkSuccess()
67
- },
68
- [checkReady, checked, t]
69
- )
70
-
71
- const rules = useMemo<Rule[]>(() => {
72
- const rules = [
73
- ...fieldRequiredRule(t('common.phone')),
74
- {
75
- validator: (_: any, value: any) => {
76
- if (!VALIDATE_PATTERN.phone.test(value))
77
- return checkError(t('common.phoneFormateError'))
78
-
79
- return checkSuccess()
80
- },
81
- },
82
- ]
83
- checkRepeat &&
84
- rules.push({
85
- validator,
86
- })
87
-
88
- return rules
89
- }, [checkRepeat, t, validator])
90
-
91
- return (
92
- <Form.Item
93
- validateFirst={true}
94
- name="phone"
95
- rules={[...rules, ...(formItemProps?.rules ?? [])]}
96
- {...formItemProps}
97
- />
98
- )
99
- }
100
- )
@@ -1,14 +0,0 @@
1
- import { FormInstance, FormItemProps } from 'antd/lib/form'
2
-
3
- export interface ValidatorFormItemProps extends FormItemProps {
4
- userPoolId?: string
5
- form?: FormInstance
6
- checkRepeat?: boolean
7
- }
8
-
9
- export interface ICheckProps {
10
- check: () => void
11
- }
12
-
13
- export { EmailFormItem } from './EmailFormItem'
14
- export { PhoneFormItem } from './PhoneFormItem'
@@ -1,76 +0,0 @@
1
- import { Divider, Input } from 'antd'
2
- import React, { FC, Fragment, useRef } from 'react'
3
-
4
- import './style.less'
5
-
6
- interface VerifyCodeInputProps extends React.HTMLAttributes<HTMLDivElement> {
7
- verifyCode: string[]
8
- setVerifyCode: (code: string[]) => void
9
- length?: number
10
- onEnter?: Function
11
- }
12
-
13
- export const VerifyCodeInput: FC<VerifyCodeInputProps> = ({
14
- verifyCode,
15
- setVerifyCode,
16
- length = 6,
17
- onEnter,
18
- }) => {
19
- const inputRef = useRef<any[]>([])
20
-
21
- const handleChange = (val: string | undefined = '', index: number) => {
22
- const num = parseInt(val)
23
- if (isNaN(num)) {
24
- val = ''
25
- } else {
26
- val = String(num)
27
- }
28
- const codes = [...verifyCode]
29
- codes[index] = val.split('').slice(-1)[0] || ''
30
- setVerifyCode(codes)
31
-
32
- if (val && inputRef.current[index + 1]) {
33
- inputRef.current[index + 1].focus()
34
- }
35
- }
36
-
37
- const handleKeyDown = (evt: any, index: number) => {
38
- const currentVal = verifyCode[index]
39
-
40
- switch (evt.keyCode) {
41
- case 8:
42
- if (!currentVal && inputRef.current[index - 1]) {
43
- handleChange('', index - 1)
44
- inputRef.current[index - 1].focus()
45
- }
46
- break
47
-
48
- case 13:
49
- onEnter?.()
50
- break
51
- default:
52
- break
53
- }
54
- }
55
-
56
- return (
57
- <div className="authing-code-input">
58
- {new Array(length).fill(0).map((_, index) => (
59
- <Fragment key={index}>
60
- <Input
61
- ref={(el) => (inputRef.current[index] = el)}
62
- className="authing-code-input-item"
63
- size="large"
64
- autoFocus={index === 0}
65
- onKeyDown={(evt) => handleKeyDown(evt, index)}
66
- value={verifyCode[index]}
67
- onChange={(evt) => handleChange(evt.target.value, index)}
68
- />
69
- {index === Math.floor(length / 2 - 1) && (
70
- <Divider className="authing-code-input-divider" />
71
- )}
72
- </Fragment>
73
- ))}
74
- </div>
75
- )
76
- }
@@ -1,24 +0,0 @@
1
- .authing-code-input-item {
2
- text-align: center;
3
- width: 40px;
4
- min-width: 40px;
5
- min-height: 40px;
6
- height: 40px;
7
- line-height: 40px;
8
- &:not(:first-child) {
9
- margin-left: 18px;
10
- }
11
- input {
12
- text-align: center;
13
- }
14
- }
15
- .authing-code-input-divider {
16
- width: 14px;
17
- min-width: 14px;
18
- max-width: 14px;
19
- margin-left: 18px;
20
- }
21
- .authing-code-input {
22
- display: flex;
23
- align-items: center;
24
- }
@@ -1,9 +0,0 @@
1
- export enum ErrorCode {
2
- OTP_MFA_CODE = 1635,
3
- APP_MFA_CODE = 1636,
4
- INPUT_CAPTCHACODE = 2000,
5
- USER_EXISTENCE = 2026,
6
- LOGIN_INVALID = 2021,
7
- PASSWORD_ERROR = 2333,
8
- USER_NOT_EXIST = 2004,
9
- }