@authing/react-ui-components 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2573 -201
- package/lib/index.min.css +2 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.LICENSE.txt +42 -0
- package/lib/static/media/loading.4a67a5f3.svg +29 -0
- package/package.json +54 -18
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -7
- package/.prettierrc +0 -5
- package/.vscode/settings.json +0 -31
- package/LICENSE +0 -21
- package/config/antdReplacer.js +0 -51
- package/config/env.js +0 -106
- package/config/getHttpsConfig.js +0 -66
- package/config/jest/cssTransform.js +0 -14
- package/config/jest/fileTransform.js +0 -40
- package/config/modules.js +0 -134
- package/config/paths.js +0 -71
- package/config/pnpTs.js +0 -35
- package/config/webpack.config.js +0 -857
- package/config/webpackDevServer.config.js +0 -130
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/scripts/build.js +0 -212
- package/scripts/lib.js +0 -200
- package/scripts/start.js +0 -166
- package/scripts/test.js +0 -53
- package/src/common/AuthingDropdown/index.tsx +0 -52
- package/src/common/AuthingDropdown/style.less +0 -43
- package/src/common/AuthingTabs/index.tsx +0 -98
- package/src/common/AuthingTabs/style.less +0 -135
- package/src/common/CopyAbleText/index.tsx +0 -54
- package/src/common/CopyAbleText/style.less +0 -13
- package/src/common/VerifyCodeInput/index.tsx +0 -76
- package/src/common/VerifyCodeInput/style.less +0 -24
- package/src/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
- package/src/components/AuthingGuard/AppMFALayout/style.less +0 -12
- package/src/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
- package/src/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
- package/src/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
- package/src/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
- package/src/components/AuthingGuard/Forms/Agreements/style.less +0 -44
- package/src/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
- package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -86
- package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
- package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
- package/src/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
- package/src/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
- package/src/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
- package/src/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -161
- package/src/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
- package/src/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
- package/src/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
- package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
- package/src/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
- package/src/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
- package/src/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
- package/src/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
- package/src/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
- package/src/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
- package/src/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
- package/src/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
- package/src/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -61
- package/src/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
- package/src/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
- package/src/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
- package/src/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
- package/src/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
- package/src/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
- package/src/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
- package/src/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
- package/src/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
- package/src/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
- package/src/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
- package/src/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
- package/src/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
- package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
- package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
- package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
- package/src/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
- package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
- package/src/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
- package/src/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
- package/src/components/AuthingGuard/Forms/index.ts +0 -13
- package/src/components/AuthingGuard/GuardLayout/index.tsx +0 -488
- package/src/components/AuthingGuard/GuardLayout/style.less +0 -111
- package/src/components/AuthingGuard/Header/index.tsx +0 -28
- package/src/components/AuthingGuard/Header/style.less +0 -64
- package/src/components/AuthingGuard/IconFont/iconfont.js +0 -74
- package/src/components/AuthingGuard/IconFont/index.tsx +0 -19
- package/src/components/AuthingGuard/IconFont/style.less +0 -6
- package/src/components/AuthingGuard/IconFont/svg.js +0 -2
- package/src/components/AuthingGuard/LoginLayout/index.tsx +0 -205
- package/src/components/AuthingGuard/LoginLayout/style.less +0 -0
- package/src/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
- package/src/components/AuthingGuard/MfaLayout/index.tsx +0 -49
- package/src/components/AuthingGuard/MfaLayout/style.less +0 -3
- package/src/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
- package/src/components/AuthingGuard/RegisterLayout/style.less +0 -0
- package/src/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
- package/src/components/AuthingGuard/ToggleLang/index.tsx +0 -51
- package/src/components/AuthingGuard/api/appConfig.ts +0 -154
- package/src/components/AuthingGuard/api/http.ts +0 -88
- package/src/components/AuthingGuard/api/index.ts +0 -3
- package/src/components/AuthingGuard/api/sso.ts +0 -29
- package/src/components/AuthingGuard/api/userPoolConfig.ts +0 -112
- package/src/components/AuthingGuard/constants.ts +0 -107
- package/src/components/AuthingGuard/hooks/index.tsx +0 -70
- package/src/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
- package/src/components/AuthingGuard/index.tsx +0 -134
- package/src/components/AuthingGuard/locales/en/common.json +0 -185
- package/src/components/AuthingGuard/locales/en/index.ts +0 -6
- package/src/components/AuthingGuard/locales/en/login.json +0 -94
- package/src/components/AuthingGuard/locales/en/map.json +0 -4
- package/src/components/AuthingGuard/locales/en/user.json +0 -81
- package/src/components/AuthingGuard/locales/index.ts +0 -45
- package/src/components/AuthingGuard/locales/zh/common.json +0 -185
- package/src/components/AuthingGuard/locales/zh/index.ts +0 -6
- package/src/components/AuthingGuard/locales/zh/login.json +0 -94
- package/src/components/AuthingGuard/locales/zh/map.json +0 -4
- package/src/components/AuthingGuard/locales/zh/user.json +0 -81
- package/src/components/AuthingGuard/style.less +0 -104
- package/src/components/AuthingGuard/types/Forms.ts +0 -95
- package/src/components/AuthingGuard/types/GuardConfig.ts +0 -424
- package/src/components/AuthingGuard/types/GuardState.ts +0 -7
- package/src/components/AuthingGuard/types/Locales.ts +0 -12
- package/src/components/AuthingGuard/types/index.ts +0 -4
- package/src/components/index.ts +0 -7
- package/src/context/base.tsx +0 -28
- package/src/context/global/context.tsx +0 -39
- package/src/context/global/reducer.tsx +0 -56
- package/src/index.tsx +0 -142
- package/src/logo.svg +0 -7
- package/src/react-app-env.d.ts +0 -71
- package/src/reportWebVitals.ts +0 -15
- package/src/setupTests.ts +0 -5
- package/src/utils/clipboard.ts +0 -27
- package/src/utils/index.ts +0 -180
- package/src/utils/popupCenter.ts +0 -48
- package/tsconfig.json +0 -24
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthenticationClient,
|
|
3
|
-
AuthenticationClientOptions,
|
|
4
|
-
CommonMessage,
|
|
5
|
-
SocialConnectionProvider,
|
|
6
|
-
User,
|
|
7
|
-
} from 'authing-js-sdk'
|
|
8
|
-
import { QrCodeAuthenticationClient } from 'authing-js-sdk/build/main/lib/authentication/QrCodeAuthenticationClient'
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
SocialConnectionItem,
|
|
12
|
-
EnterpriseConnectionItem,
|
|
13
|
-
ApplicationConfig,
|
|
14
|
-
PasswordLoginMethods,
|
|
15
|
-
Agreement,
|
|
16
|
-
QrcodeTabsSettings,
|
|
17
|
-
} from '../../../components/AuthingGuard/api'
|
|
18
|
-
import { Lang } from './Locales'
|
|
19
|
-
|
|
20
|
-
export type { AuthenticationClient, CommonMessage, User } from 'authing-js-sdk'
|
|
21
|
-
|
|
22
|
-
export enum GuardMode {
|
|
23
|
-
Modal = 'modal',
|
|
24
|
-
Normal = 'normal',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export enum LoginMethods {
|
|
28
|
-
LDAP = 'ldap',
|
|
29
|
-
AppQr = 'app-qrcode',
|
|
30
|
-
Password = 'password',
|
|
31
|
-
PhoneCode = 'phone-code',
|
|
32
|
-
WxMinQr = 'wechat-miniprogram-qrcode', // 对应社会化登录的 wechat:miniprogram:qrconnect(小程序扫码登录)
|
|
33
|
-
AD = 'ad', // 对应企业身份源的 Windows AD 登录
|
|
34
|
-
WechatMpQrcode = 'wechatmp-qrcode', // 微信扫码关注登录
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export enum RegisterMethods {
|
|
38
|
-
Email = 'email',
|
|
39
|
-
Phone = 'phone',
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export enum GuardScenes {
|
|
43
|
-
Login = 'login',
|
|
44
|
-
Register = 'register',
|
|
45
|
-
MfaVerify = 'mfaVerify',
|
|
46
|
-
AppMfaVerify = 'appMfaVerify',
|
|
47
|
-
RestPassword = 'restPassword',
|
|
48
|
-
CompleteUserInfo = 'completeUserInfo',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export enum ResetPwdMethods {
|
|
52
|
-
Email = 'email',
|
|
53
|
-
Phone = 'phone',
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export enum SocialConnections {
|
|
57
|
-
Qq = 'qq',
|
|
58
|
-
Weibo = 'weibo',
|
|
59
|
-
Github = 'github',
|
|
60
|
-
Google = 'google',
|
|
61
|
-
WxPc = 'wechat:pc',
|
|
62
|
-
Dingtalk = 'dingtalk',
|
|
63
|
-
WxWCorpQr = 'wechatwork:corp:qrconnect',
|
|
64
|
-
WxWSPQr = 'wechatwork:service-provider:qrconnect',
|
|
65
|
-
WxWSPAuth = 'wechatwork:service-provider:authorization',
|
|
66
|
-
AlipayWeb = 'alipay:web',
|
|
67
|
-
AppleWeb = 'apple:web',
|
|
68
|
-
Baidu = 'baidu',
|
|
69
|
-
LarkInternalApp = 'lark-internal',
|
|
70
|
-
LarkMarketPlaceApp = 'lark-public',
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export enum Protocol {
|
|
74
|
-
AD = 'ad',
|
|
75
|
-
CAS = 'cas',
|
|
76
|
-
LDAP = 'ldap',
|
|
77
|
-
OIDC = 'oidc',
|
|
78
|
-
SAML = 'saml',
|
|
79
|
-
OAUTH = 'oauth',
|
|
80
|
-
AZURE_AD = 'azure-ad',
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// export enum GuardEventsKebab {
|
|
84
|
-
// // 加载完成,userPool 配置和应用配置(如果有 appId)加载完成
|
|
85
|
-
// Load = 'load',
|
|
86
|
-
// // 加载失败
|
|
87
|
-
// LoadError = 'load-error',
|
|
88
|
-
// // 用户登录成功
|
|
89
|
-
// Login = 'login',
|
|
90
|
-
// // 用户登录失败
|
|
91
|
-
// LoginError = 'login-error',
|
|
92
|
-
// // 注册成功
|
|
93
|
-
// Register = 'register',
|
|
94
|
-
// // 注册失败
|
|
95
|
-
// RegisterError = 'register-error',
|
|
96
|
-
// // 忘记密码邮件发送成功
|
|
97
|
-
// PwdEmailSend = 'pwd-email-send',
|
|
98
|
-
// // 忘记密码邮件发送失败
|
|
99
|
-
// PwdEmailSendError = 'pwd-email-send-error',
|
|
100
|
-
// // 忘记密码手机验证码发送成功
|
|
101
|
-
// PwdPhoneSend = 'pwd-phone-send',
|
|
102
|
-
// // 忘记密码手机验证码发送失败
|
|
103
|
-
// PwdPhoneSendError = 'pwd-phone-send-error',
|
|
104
|
-
// // 重置密码成功
|
|
105
|
-
// PwdReset = 'pwd-reset',
|
|
106
|
-
// // 重置密码失败
|
|
107
|
-
// PwdResetError = 'pwd-reset-error',
|
|
108
|
-
// // 表单关闭事件
|
|
109
|
-
// Close = 'close',
|
|
110
|
-
// }
|
|
111
|
-
|
|
112
|
-
// export interface GuardEventsCamelCase {
|
|
113
|
-
// // 加载完成,userPool 配置和应用配置(如果有 appId)加载完成
|
|
114
|
-
// [GuardEvents.Load]: 'onLoad'
|
|
115
|
-
// // 加载失败
|
|
116
|
-
// [GuardEvents.LoadError]: 'onLoadError'
|
|
117
|
-
// // 用户登录成功
|
|
118
|
-
// [GuardEvents.Login]: 'onLogin'
|
|
119
|
-
// // 用户登录失败
|
|
120
|
-
// [GuardEvents.LoginError]: 'onLoginError'
|
|
121
|
-
// // 注册成功
|
|
122
|
-
// [GuardEvents.Register]: 'onRegister'
|
|
123
|
-
// // 注册失败
|
|
124
|
-
// [GuardEvents.RegisterError]: 'onRegisterError'
|
|
125
|
-
// // 忘记密码邮件发送成功
|
|
126
|
-
// [GuardEvents.PwdEmailSend]: 'onPwdEmailSend'
|
|
127
|
-
// // 忘记密码邮件发送失败
|
|
128
|
-
// [GuardEvents.PwdEmailSendError]: 'onPwdEmailSendError'
|
|
129
|
-
// // 忘记密码手机验证码发送成功
|
|
130
|
-
// [GuardEvents.PwdPhoneSend]: 'onPwdPhoneSend'
|
|
131
|
-
// // 忘记密码手机验证码发送失败
|
|
132
|
-
// [GuardEvents.PwdPhoneSendError]: 'onPwdPhoneSendError'
|
|
133
|
-
// // 重置密码成功
|
|
134
|
-
// [GuardEvents.PwdReset]: 'onPwdReset'
|
|
135
|
-
// // 重置密码失败
|
|
136
|
-
// [GuardEvents.PwdResetError]: 'onPwdResetError'
|
|
137
|
-
// // 表单关闭事件
|
|
138
|
-
// [GuardEvents.Close]: 'onClose'
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
// export enum GuardEvents {
|
|
142
|
-
// // 加载完成,userPool 配置和应用配置(如果有 appId)加载完成
|
|
143
|
-
// Load = 'onLoad',
|
|
144
|
-
// // 加载失败
|
|
145
|
-
// LoadError = 'onLoadError',
|
|
146
|
-
// // 用户登录成功
|
|
147
|
-
// Login = 'onLogin',
|
|
148
|
-
// // 用户登录失败
|
|
149
|
-
// LoginError = 'onLoginError',
|
|
150
|
-
// // 注册成功
|
|
151
|
-
// Register = 'onRegister',
|
|
152
|
-
// // 注册失败
|
|
153
|
-
// RegisterError = 'onRegisterError',
|
|
154
|
-
// // 忘记密码邮件发送成功
|
|
155
|
-
// PwdEmailSend = 'onPwdEmailSend',
|
|
156
|
-
// // 忘记密码邮件发送失败
|
|
157
|
-
// PwdEmailSendError = 'onPwdEmailSendError',
|
|
158
|
-
// // 忘记密码手机验证码发送成功
|
|
159
|
-
// PwdPhoneSend = 'onPwdPhoneSend',
|
|
160
|
-
// // 忘记密码手机验证码发送失败
|
|
161
|
-
// PwdPhoneSendError = 'onPwdPhoneSendError',
|
|
162
|
-
// // 重置密码成功
|
|
163
|
-
// PwdReset = 'onPwdReset',
|
|
164
|
-
// // 重置密码失败
|
|
165
|
-
// PwdResetError = 'onPwdResetError',
|
|
166
|
-
// // 表单关闭事件
|
|
167
|
-
// Close = 'onClose',
|
|
168
|
-
// }
|
|
169
|
-
|
|
170
|
-
export const GuardEventsCamelToKebabMap = {
|
|
171
|
-
onLoad: 'load',
|
|
172
|
-
onLoadError: 'load-error',
|
|
173
|
-
onLogin: 'login',
|
|
174
|
-
onBeforeLogin: 'before-login',
|
|
175
|
-
onLoginError: 'login-error',
|
|
176
|
-
onRegister: 'register',
|
|
177
|
-
onBeforeRegister: 'before-register',
|
|
178
|
-
onRegisterError: 'register-error',
|
|
179
|
-
onPwdEmailSend: 'pwd-email-send',
|
|
180
|
-
onPwdEmailSendError: 'pwd-email-send-error',
|
|
181
|
-
onPwdPhoneSend: 'pwd-phone-send',
|
|
182
|
-
onPwdPhoneSendError: 'pwd-phone-send-error',
|
|
183
|
-
onPwdReset: 'pwd-reset',
|
|
184
|
-
onPwdResetError: 'pwd-reset-error',
|
|
185
|
-
onClose: 'close',
|
|
186
|
-
onLoginTabChange: 'login-tab-change',
|
|
187
|
-
onRegisterTabChange: 'register-tab-change',
|
|
188
|
-
onRegisterInfoCompleted: 'register-info-completed',
|
|
189
|
-
onRegisterInfoCompletedError: 'register-info-completed-error',
|
|
190
|
-
} as const
|
|
191
|
-
|
|
192
|
-
export interface GuardEventsHandlerKebab {
|
|
193
|
-
// 加载完成,userPool 配置和应用配置(如果有 appId)加载完成
|
|
194
|
-
load: GuardEventsHandler['onLoad']
|
|
195
|
-
// 加载失败
|
|
196
|
-
'load-error': GuardEventsHandler['onLoadError']
|
|
197
|
-
// 登录前,即表单校验完成,请求接口前
|
|
198
|
-
'before-login': GuardEventsHandler['onBeforeLogin']
|
|
199
|
-
// 用户登录成功
|
|
200
|
-
login: GuardEventsHandler['onLogin']
|
|
201
|
-
// 用户登录失败
|
|
202
|
-
'login-error': GuardEventsHandler['onLoginError']
|
|
203
|
-
// 注册前,即表单校验完成,请求接口前
|
|
204
|
-
'before-register': GuardEventsHandler['onBeforeRegister']
|
|
205
|
-
// 注册成功
|
|
206
|
-
register: GuardEventsHandler['onRegister']
|
|
207
|
-
// 注册失败
|
|
208
|
-
'register-error': GuardEventsHandler['onRegisterError']
|
|
209
|
-
// 忘记密码邮件发送成功
|
|
210
|
-
'pwd-email-send': GuardEventsHandler['onPwdEmailSend']
|
|
211
|
-
// 忘记密码邮件发送失败
|
|
212
|
-
'pwd-email-send-error': GuardEventsHandler['onPwdEmailSendError']
|
|
213
|
-
// 忘记密码手机验证码发送成功
|
|
214
|
-
'pwd-phone-send': GuardEventsHandler['onPwdPhoneSend']
|
|
215
|
-
// 忘记密码手机验证码发送失败
|
|
216
|
-
'pwd-phone-send-error': GuardEventsHandler['onPwdPhoneSendError']
|
|
217
|
-
// 重置密码成功
|
|
218
|
-
'pwd-reset': GuardEventsHandler['onPwdReset']
|
|
219
|
-
// 重置密码失败
|
|
220
|
-
'pwd-reset-error': GuardEventsHandler['onPwdResetError']
|
|
221
|
-
// 表单关闭事件
|
|
222
|
-
close: GuardEventsHandler['onClose']
|
|
223
|
-
// 登录的 tab 切换
|
|
224
|
-
'login-tab-change': GuardEventsHandler['onLoginTabChange']
|
|
225
|
-
// 注册的 tab 切换
|
|
226
|
-
'register-tab-change': GuardEventsHandler['onRegisterTabChange']
|
|
227
|
-
// 注册信息补充完毕
|
|
228
|
-
'register-info-completed': GuardEventsHandler['onRegisterInfoCompleted']
|
|
229
|
-
// 注册信息补充失败
|
|
230
|
-
'register-info-completed-error': GuardEventsHandler['onRegisterInfoCompletedError']
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export interface PasswordLoginParams {
|
|
234
|
-
type: LoginMethods.Password
|
|
235
|
-
data: {
|
|
236
|
-
// 标识,可能是用户名、邮箱、手机号
|
|
237
|
-
identity: string
|
|
238
|
-
// 密码
|
|
239
|
-
password: string
|
|
240
|
-
// 图形验证码
|
|
241
|
-
captchaCode?: string
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export interface LDAPLoginParams {
|
|
246
|
-
type: LoginMethods.LDAP
|
|
247
|
-
data: {
|
|
248
|
-
// 标识,可能是用户名、邮箱、手机号
|
|
249
|
-
identity: string
|
|
250
|
-
// 密码
|
|
251
|
-
password: string
|
|
252
|
-
// 图形验证码
|
|
253
|
-
captchaCode?: string
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export interface ADLoginParams {
|
|
258
|
-
type: LoginMethods.AD
|
|
259
|
-
data: {
|
|
260
|
-
// 标识,可能是用户名、邮箱、手机号
|
|
261
|
-
identity: string
|
|
262
|
-
// 密码
|
|
263
|
-
password: string
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export interface PhoneCodeLoginParams {
|
|
268
|
-
type: LoginMethods.PhoneCode
|
|
269
|
-
data: {
|
|
270
|
-
// 手机号
|
|
271
|
-
phone: string
|
|
272
|
-
// 手机验证码
|
|
273
|
-
code: string
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export interface EmailRegisterParams {
|
|
278
|
-
type: RegisterMethods.Email
|
|
279
|
-
data: {
|
|
280
|
-
// 邮箱
|
|
281
|
-
email: string
|
|
282
|
-
// 密码
|
|
283
|
-
password: string
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
export interface PhoneRegisterParams {
|
|
288
|
-
type: RegisterMethods.Phone
|
|
289
|
-
data: {
|
|
290
|
-
// 手机号
|
|
291
|
-
phone: string
|
|
292
|
-
// 密码
|
|
293
|
-
password: string
|
|
294
|
-
// 手机验证码
|
|
295
|
-
code: string
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export interface GuardEventsHandler {
|
|
300
|
-
onLoad?: (authClient: AuthenticationClient) => void
|
|
301
|
-
onLoadError?: (error: CommonMessage) => void
|
|
302
|
-
onBeforeLogin?: (
|
|
303
|
-
loginInfo:
|
|
304
|
-
| PasswordLoginParams
|
|
305
|
-
| LDAPLoginParams
|
|
306
|
-
| ADLoginParams
|
|
307
|
-
| PhoneCodeLoginParams,
|
|
308
|
-
authClient: AuthenticationClient
|
|
309
|
-
) => boolean | Promise<boolean>
|
|
310
|
-
onLogin?: (user: User, authClient: AuthenticationClient) => void
|
|
311
|
-
onLoginError?: (user: User, authClient: AuthenticationClient) => void
|
|
312
|
-
onBeforeRegister?: (
|
|
313
|
-
registerInfo: EmailRegisterParams | PhoneRegisterParams,
|
|
314
|
-
authClient: AuthenticationClient
|
|
315
|
-
) => boolean | Promise<boolean>
|
|
316
|
-
onRegister?: (user: User, authClient: AuthenticationClient) => void
|
|
317
|
-
onRegisterError?: (user: User, authClient: AuthenticationClient) => void
|
|
318
|
-
onPwdEmailSend?: (authClient: AuthenticationClient) => void
|
|
319
|
-
onPwdEmailSendError?: (
|
|
320
|
-
error: CommonMessage,
|
|
321
|
-
authClient: AuthenticationClient
|
|
322
|
-
) => void
|
|
323
|
-
onPwdPhoneSend?: (authClient: AuthenticationClient) => void
|
|
324
|
-
onPwdPhoneSendError?: (
|
|
325
|
-
error: CommonMessage,
|
|
326
|
-
authClient: AuthenticationClient
|
|
327
|
-
) => void
|
|
328
|
-
onPwdReset?: (authClient: AuthenticationClient) => void
|
|
329
|
-
onPwdResetError?: (
|
|
330
|
-
error: CommonMessage,
|
|
331
|
-
authClient: AuthenticationClient
|
|
332
|
-
) => void
|
|
333
|
-
onClose?: () => void
|
|
334
|
-
onLoginTabChange?: (activeTab: LoginMethods) => void
|
|
335
|
-
onRegisterTabChange?: (activeTab: RegisterMethods) => void
|
|
336
|
-
onRegisterInfoCompleted?: (
|
|
337
|
-
user: User,
|
|
338
|
-
udfs: {
|
|
339
|
-
definition: any
|
|
340
|
-
value: any
|
|
341
|
-
}[],
|
|
342
|
-
authClient: AuthenticationClient
|
|
343
|
-
) => void
|
|
344
|
-
onRegisterInfoCompletedError?: (
|
|
345
|
-
error: CommonMessage,
|
|
346
|
-
udfs: {
|
|
347
|
-
definition: any
|
|
348
|
-
value: any
|
|
349
|
-
}[],
|
|
350
|
-
authClient: AuthenticationClient
|
|
351
|
-
) => void
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
export interface UserConfig {
|
|
355
|
-
logo?: string
|
|
356
|
-
title?: string
|
|
357
|
-
description?: string
|
|
358
|
-
zIndex?: number
|
|
359
|
-
isSSO?: boolean
|
|
360
|
-
mode?: GuardMode
|
|
361
|
-
/**
|
|
362
|
-
* @deprecated 使用 appHost
|
|
363
|
-
*/
|
|
364
|
-
apiHost?: string
|
|
365
|
-
/**
|
|
366
|
-
* @deprecated 使用 appHost
|
|
367
|
-
*/
|
|
368
|
-
appDomain?: string
|
|
369
|
-
appHost?: string
|
|
370
|
-
contentCss?: string
|
|
371
|
-
text?: {
|
|
372
|
-
loginBtn?: {
|
|
373
|
-
normal?: string
|
|
374
|
-
loading?: string
|
|
375
|
-
}
|
|
376
|
-
registerBtn?: {
|
|
377
|
-
normal?: string
|
|
378
|
-
loading?: string
|
|
379
|
-
}
|
|
380
|
-
// 登录 tab
|
|
381
|
-
loginTabs?: Partial<Record<LoginMethods, string>>
|
|
382
|
-
}
|
|
383
|
-
escCloseable?: boolean
|
|
384
|
-
autoRegister?: boolean
|
|
385
|
-
clickCloseable?: boolean
|
|
386
|
-
disableResetPwd?: boolean
|
|
387
|
-
disableRegister?: boolean
|
|
388
|
-
defaultScenes?: GuardScenes
|
|
389
|
-
loginMethods?: LoginMethods[]
|
|
390
|
-
target?: string | HTMLElement
|
|
391
|
-
enterpriseConnections?: string[]
|
|
392
|
-
defaultLoginMethod?: LoginMethods
|
|
393
|
-
registerMethods?: RegisterMethods[]
|
|
394
|
-
socialConnections?: (SocialConnections | SocialConnectionProvider)[]
|
|
395
|
-
defaultRegisterMethod?: RegisterMethods
|
|
396
|
-
qrCodeScanOptions?: Parameters<QrCodeAuthenticationClient['startScanning']>[1]
|
|
397
|
-
/**
|
|
398
|
-
* 国际化处理
|
|
399
|
-
*/
|
|
400
|
-
localesConfig?: LocalesConfig
|
|
401
|
-
lang?: Lang
|
|
402
|
-
/**
|
|
403
|
-
* 用于去品牌化
|
|
404
|
-
*/
|
|
405
|
-
headers?: AuthenticationClientOptions['headers']
|
|
406
|
-
passwordLoginMethods?: PasswordLoginMethods[]
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export interface GuardConfig extends UserConfig {
|
|
410
|
-
socialConnectionObjs: SocialConnectionItem[]
|
|
411
|
-
enterpriseConnectionObjs: EnterpriseConnectionItem[]
|
|
412
|
-
extendsFields: ApplicationConfig['extendsFields']
|
|
413
|
-
publicKey: ApplicationConfig['publicKey']
|
|
414
|
-
agreementEnabled: boolean
|
|
415
|
-
agreements: Agreement[]
|
|
416
|
-
loginMethodTitleMapping: Record<string, string>
|
|
417
|
-
qrcodeTabsSettings: QrcodeTabsSettings
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
export interface LocalesConfig {
|
|
421
|
-
defaultLang?: Lang
|
|
422
|
-
isShowChange?: boolean
|
|
423
|
-
onChange?: (lang: Lang) => void
|
|
424
|
-
}
|
package/src/components/index.ts
DELETED
package/src/context/base.tsx
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
// create context with no upfront defaultValue
|
|
4
|
-
// without having to do undefined check all the time
|
|
5
|
-
export function createBaseContext<C>() {
|
|
6
|
-
const ctx = React.createContext<C | undefined>(undefined)
|
|
7
|
-
function useBaseContext() {
|
|
8
|
-
const ctxConst = React.useContext(ctx)
|
|
9
|
-
if (!ctxConst)
|
|
10
|
-
throw new Error('useBaseContext must be inside a Provider with a value')
|
|
11
|
-
return ctxConst
|
|
12
|
-
}
|
|
13
|
-
// make TypeScript infer a tuple, not an array of union types
|
|
14
|
-
return [ctx, useBaseContext] as const
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IBaseAction<ActionType = string> {
|
|
18
|
-
type: ActionType & string
|
|
19
|
-
payload?: any
|
|
20
|
-
[key: string]: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface IBaseContext<S> {
|
|
24
|
-
state: S
|
|
25
|
-
[k: string]: any
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type BaseContextComponent<Props> = React.PropsWithChildren<Props>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useReducer } from 'react'
|
|
2
|
-
import { createBaseContext, IBaseContext, BaseContextComponent } from '../base'
|
|
3
|
-
import { reducer, IState } from './reducer'
|
|
4
|
-
|
|
5
|
-
// 页面上下文,除了状态外还有公开的方法
|
|
6
|
-
export interface IGuardContext extends IBaseContext<IState> {
|
|
7
|
-
dispatch: Function
|
|
8
|
-
getValue: (key: keyof IState) => any
|
|
9
|
-
setValue: (key: keyof IState, value: any) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// 实例化上下文,这里避免了为空检查
|
|
13
|
-
const [Context, useBaseContext] = createBaseContext<IGuardContext>()
|
|
14
|
-
|
|
15
|
-
export function useGuardContext(): IGuardContext {
|
|
16
|
-
const guardContext = useBaseContext()
|
|
17
|
-
// TODO: custom some
|
|
18
|
-
return guardContext
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function GuardContext({
|
|
22
|
-
children = null,
|
|
23
|
-
value,
|
|
24
|
-
}: BaseContextComponent<Record<string, any>>) {
|
|
25
|
-
const [state, dispatch] = useReducer(reducer, value)
|
|
26
|
-
const getValue = (key: keyof IState) => state[key]
|
|
27
|
-
const setValue = useCallback((key: keyof IState, value: any) => {
|
|
28
|
-
dispatch({ type: 'SET_VALUE', key, value })
|
|
29
|
-
}, [])
|
|
30
|
-
|
|
31
|
-
let ctx: IGuardContext = {
|
|
32
|
-
state,
|
|
33
|
-
dispatch,
|
|
34
|
-
getValue,
|
|
35
|
-
setValue,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return <Context.Provider value={ctx}>{children}</Context.Provider>
|
|
39
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GuardConfig,
|
|
3
|
-
ActiveTabs,
|
|
4
|
-
GuardScenes,
|
|
5
|
-
UserConfig,
|
|
6
|
-
GuardEventsHandler,
|
|
7
|
-
LocalesConfig,
|
|
8
|
-
Lang,
|
|
9
|
-
} from '../../components/AuthingGuard/types'
|
|
10
|
-
import { AuthenticationClient } from 'authing-js-sdk'
|
|
11
|
-
import { IBaseAction } from '../base'
|
|
12
|
-
import { ApplicationMfaType } from '../../components/AuthingGuard/api/appConfig'
|
|
13
|
-
|
|
14
|
-
export type IState = {
|
|
15
|
-
config: GuardConfig // 处理后的 Guard 配置
|
|
16
|
-
userConfig: UserConfig // 用户传入的配置
|
|
17
|
-
authClient: AuthenticationClient
|
|
18
|
-
activeTabs: ActiveTabs // 登录、注册方式
|
|
19
|
-
guardScenes: GuardScenes // 当前在哪个界面
|
|
20
|
-
guardTitle: string
|
|
21
|
-
// 需要 mfa 登录时后端返回的错误信息
|
|
22
|
-
mfaData: {
|
|
23
|
-
mfaToken: string
|
|
24
|
-
phone?: string
|
|
25
|
-
email?: string
|
|
26
|
-
applicationMfa?: {
|
|
27
|
-
status: 0 | 1
|
|
28
|
-
mfaPolicy: ApplicationMfaType
|
|
29
|
-
sort: number
|
|
30
|
-
}[]
|
|
31
|
-
}
|
|
32
|
-
userPoolId: string
|
|
33
|
-
appId: string
|
|
34
|
-
guardEvents: GuardEventsHandler
|
|
35
|
-
localesConfig: LocalesConfig
|
|
36
|
-
lang?: Lang
|
|
37
|
-
realHost: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const handlers: any = {
|
|
41
|
-
// eslint-disable-next-line
|
|
42
|
-
['SET_VALUE']: (state: IState, payloads: any) => {
|
|
43
|
-
return {
|
|
44
|
-
...state,
|
|
45
|
-
[payloads.key]: payloads.value,
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const reducer = (state: IState, { type, ...payloads }: IBaseAction) => {
|
|
51
|
-
const handler = handlers[type]
|
|
52
|
-
if (handler) {
|
|
53
|
-
return handler(state, payloads)
|
|
54
|
-
}
|
|
55
|
-
return state
|
|
56
|
-
}
|