@authing/react-ui-components 3.0.2-alpha.2 → 3.0.2-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +620 -52
- package/lib/index.min.css +2 -2
- package/lib/index.min.js +1 -1
- package/package.json +29 -8
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -7
- package/.prettierrc +0 -5
- package/.vscode/settings.json +0 -31
- package/build/asset-manifest.json +0 -26
- package/build/favicon.ico +0 -0
- package/build/index.html +0 -1
- package/build/logo192.png +0 -0
- package/build/logo512.png +0 -0
- package/build/manifest.json +0 -25
- package/build/robots.txt +0 -3
- package/build/static/css/2.9512539b.chunk.css +0 -3
- package/build/static/css/2.9512539b.chunk.css.map +0 -1
- package/build/static/css/main.0ff9e24a.chunk.css +0 -2
- package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
- package/build/static/js/2.1105ecfb.chunk.js +0 -3
- package/build/static/js/2.1105ecfb.chunk.js.LICENSE.txt +0 -102
- package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
- package/build/static/js/3.fd17f196.chunk.js +0 -2
- package/build/static/js/3.fd17f196.chunk.js.map +0 -1
- package/build/static/js/main.a47645ff.chunk.js +0 -2
- package/build/static/js/main.a47645ff.chunk.js.map +0 -1
- package/build/static/js/runtime-main.ef138021.js +0 -2
- package/build/static/js/runtime-main.ef138021.js.map +0 -1
- package/build/static/media/loading.4a67a5f3.svg +0 -29
- package/components/AuthingDropdown/index.tsx +0 -52
- package/components/AuthingDropdown/style.less +0 -43
- package/components/AuthingGuard/AppMFALayout/index.tsx +0 -74
- package/components/AuthingGuard/AppMFALayout/style.less +0 -12
- package/components/AuthingGuard/CompleteUserInfoLayout/index.tsx +0 -29
- package/components/AuthingGuard/CompleteUserInfoLayout/style.less +0 -8
- package/components/AuthingGuard/Forms/ADLoginForm/index.tsx +0 -117
- package/components/AuthingGuard/Forms/Agreements/index.tsx +0 -81
- package/components/AuthingGuard/Forms/Agreements/style.less +0 -44
- package/components/AuthingGuard/Forms/CompleteUserInfoForm/index.tsx +0 -139
- package/components/AuthingGuard/Forms/EmailMfaVerifyForm/CheckEmailForm.tsx +0 -84
- package/components/AuthingGuard/Forms/EmailMfaVerifyForm/VerifyCodeForm.tsx +0 -116
- package/components/AuthingGuard/Forms/EmailMfaVerifyForm/index.tsx +0 -40
- package/components/AuthingGuard/Forms/EmailMfaVerifyForm/style.less +0 -0
- package/components/AuthingGuard/Forms/EmailRegisterForm/index.tsx +0 -181
- package/components/AuthingGuard/Forms/EmailRegisterForm/style.less +0 -0
- package/components/AuthingGuard/Forms/LdapLoginForm/index.tsx +0 -166
- package/components/AuthingGuard/Forms/LdapLoginForm/style.less +0 -0
- package/components/AuthingGuard/Forms/LoginFormFooter/index.tsx +0 -76
- package/components/AuthingGuard/Forms/LoginFormFooter/style.less +0 -6
- package/components/AuthingGuard/Forms/MfaResetCodeForm/Step1.tsx +0 -86
- package/components/AuthingGuard/Forms/MfaResetCodeForm/Step2.tsx +0 -53
- package/components/AuthingGuard/Forms/MfaResetCodeForm/index.tsx +0 -65
- package/components/AuthingGuard/Forms/MfaResetCodeForm/style.less +0 -20
- package/components/AuthingGuard/Forms/MfaVerifyForm/index.tsx +0 -105
- package/components/AuthingGuard/Forms/MfaVerifyForm/style.less +0 -12
- package/components/AuthingGuard/Forms/PasswordLoginForm/index.tsx +0 -261
- package/components/AuthingGuard/Forms/PhoneCodeLoginForm/index.tsx +0 -133
- package/components/AuthingGuard/Forms/PhoneRegisterForm/index.tsx +0 -202
- package/components/AuthingGuard/Forms/QrCodeLoginForm/index.tsx +0 -59
- package/components/AuthingGuard/Forms/QrCodeLoginForm/style.less +0 -14
- package/components/AuthingGuard/Forms/RegisterFormFooter/index.tsx +0 -56
- package/components/AuthingGuard/Forms/RegisterFormFooter/style.less +0 -0
- package/components/AuthingGuard/Forms/ResetPwdForm/Footer.tsx +0 -21
- package/components/AuthingGuard/Forms/ResetPwdForm/Step1.tsx +0 -86
- package/components/AuthingGuard/Forms/ResetPwdForm/Step2.tsx +0 -127
- package/components/AuthingGuard/Forms/ResetPwdForm/Step3.tsx +0 -141
- package/components/AuthingGuard/Forms/ResetPwdForm/Step4.tsx +0 -51
- package/components/AuthingGuard/Forms/ResetPwdForm/index.tsx +0 -96
- package/components/AuthingGuard/Forms/ResetPwdForm/style.less +0 -3
- package/components/AuthingGuard/Forms/SendPhoneCode/SendCodeBtn.tsx +0 -88
- package/components/AuthingGuard/Forms/SendPhoneCode/index.tsx +0 -50
- package/components/AuthingGuard/Forms/SendPhoneCode/style.less +0 -26
- package/components/AuthingGuard/Forms/SmsMfaVerifyForm/CheckPhoneForm.tsx +0 -86
- package/components/AuthingGuard/Forms/SmsMfaVerifyForm/VerifyCodeForm.tsx +0 -113
- package/components/AuthingGuard/Forms/SmsMfaVerifyForm/index.tsx +0 -40
- package/components/AuthingGuard/Forms/SmsMfaVerifyForm/style.less +0 -3
- package/components/AuthingGuard/Forms/SocialAndIdpLogin/index.tsx +0 -325
- package/components/AuthingGuard/Forms/SocialAndIdpLogin/style.less +0 -75
- package/components/AuthingGuard/Forms/UploadImage/index.tsx +0 -70
- package/components/AuthingGuard/Forms/index.ts +0 -13
- package/components/AuthingGuard/GuardLayout/index.tsx +0 -474
- package/components/AuthingGuard/GuardLayout/style.less +0 -111
- package/components/AuthingGuard/Header/index.tsx +0 -25
- package/components/AuthingGuard/Header/style.less +0 -52
- package/components/AuthingGuard/IconFont/iconfont.js +0 -74
- package/components/AuthingGuard/IconFont/index.tsx +0 -19
- package/components/AuthingGuard/IconFont/style.less +0 -6
- package/components/AuthingGuard/IconFont/svg.js +0 -2
- package/components/AuthingGuard/LoginLayout/index.tsx +0 -161
- package/components/AuthingGuard/LoginLayout/style.less +0 -0
- package/components/AuthingGuard/MfaLayout/Steps.ts +0 -4
- package/components/AuthingGuard/MfaLayout/index.tsx +0 -49
- package/components/AuthingGuard/MfaLayout/style.less +0 -3
- package/components/AuthingGuard/RegisterLayout/index.tsx +0 -89
- package/components/AuthingGuard/RegisterLayout/style.less +0 -0
- package/components/AuthingGuard/ResetPwdLayout/index.tsx +0 -20
- package/components/AuthingGuard/ToggleLang/index.tsx +0 -51
- package/components/AuthingGuard/api/appConfig.ts +0 -146
- package/components/AuthingGuard/api/index.ts +0 -3
- package/components/AuthingGuard/api/sso.ts +0 -29
- package/components/AuthingGuard/api/userPoolConfig.ts +0 -111
- package/components/AuthingGuard/constants.ts +0 -105
- package/components/AuthingGuard/hooks/index.tsx +0 -70
- package/components/AuthingGuard/hooks/useScreenSize.tsx +0 -68
- package/components/AuthingGuard/index.tsx +0 -126
- package/components/AuthingGuard/style.less +0 -103
- package/components/AuthingGuard/types/Forms.ts +0 -94
- package/components/AuthingGuard/types/GuardConfig.ts +0 -420
- package/components/AuthingGuard/types/GuardState.ts +0 -7
- package/components/AuthingGuard/types/Locales.ts +0 -12
- package/components/AuthingGuard/types/index.ts +0 -4
- package/components/AuthingTabs/index.tsx +0 -98
- package/components/AuthingTabs/style.less +0 -135
- package/components/BindTotp/core/bindSuccess.tsx +0 -61
- package/components/BindTotp/core/securityCode.tsx +0 -119
- package/components/BindTotp/index.tsx +0 -134
- package/components/BindTotp/interface.ts +0 -30
- package/components/BindTotp/styles.less +0 -57
- package/components/ChangeLanguage/index.tsx +0 -35
- package/components/ChangePassword/core/firstLoginReset.tsx +0 -104
- package/components/ChangePassword/core/rotateReset.tsx +0 -114
- package/components/ChangePassword/index.tsx +0 -59
- package/components/CompleteInfo/core/completeInfo.tsx +0 -155
- package/components/CompleteInfo/index.tsx +0 -45
- package/components/CompleteInfo/interface.ts +0 -40
- package/components/CompleteInfo/styles.less +0 -7
- package/components/CopyAbleText/index.tsx +0 -54
- package/components/CopyAbleText/style.less +0 -13
- package/components/DownloadAuthenticator/index.tsx +0 -97
- package/components/DownloadAuthenticator/interface.ts +0 -22
- package/components/DownloadAuthenticator/styles.less +0 -52
- package/components/Error/index.tsx +0 -21
- package/components/Error/interface.ts +0 -9
- package/components/Error/styles.less +0 -12
- package/components/ForgetPassword/core/resetPassword.tsx +0 -162
- package/components/ForgetPassword/index.tsx +0 -75
- package/components/ForgetPassword/interface.ts +0 -32
- package/components/Guard/Guard.tsx +0 -242
- package/components/Guard/authClient.ts +0 -55
- package/components/Guard/config.ts +0 -19
- package/components/Guard/event.ts +0 -52
- package/components/Guard/index.tsx +0 -4
- package/components/Guard/module.ts +0 -19
- package/components/Guard/stateMachine.ts +0 -133
- package/components/Guard/styles.less +0 -444
- package/components/IconFont/iconfont.js +0 -74
- package/components/IconFont/index.tsx +0 -16
- package/components/IconFont/style.less +0 -6
- package/components/IconFont/svg.js +0 -2
- package/components/ImagePro/index.tsx +0 -52
- package/components/ImagePro/styles.less +0 -40
- package/components/InputNumber/index.tsx +0 -33
- package/components/Login/codemap.ts +0 -39
- package/components/Login/core/withAD.tsx +0 -9
- package/components/Login/core/withAppQrcode.tsx +0 -49
- package/components/Login/core/withLDAP.tsx +0 -146
- package/components/Login/core/withPassword.tsx +0 -176
- package/components/Login/core/withPhonecode.tsx +0 -121
- package/components/Login/core/withWechatMiniQrcode.tsx +0 -60
- package/components/Login/core/withWechatmpQrcode.tsx +0 -53
- package/components/Login/index.tsx +0 -368
- package/components/Login/props.ts +0 -74
- package/components/Login/socialLogin/index.tsx +0 -413
- package/components/Login/socialLogin/style.less +0 -61
- package/components/Login/styles.less +0 -53
- package/components/MFA/codemap.ts +0 -21
- package/components/MFA/core/email.tsx +0 -225
- package/components/MFA/core/face.tsx +0 -297
- package/components/MFA/core/face_deps.tsx +0 -37
- package/components/MFA/core/sms.tsx +0 -229
- package/components/MFA/core/totp.tsx +0 -137
- package/components/MFA/index.tsx +0 -137
- package/components/MFA/mfaMethods/index.tsx +0 -81
- package/components/MFA/mfaMethods/style.less +0 -39
- package/components/MFA/props.ts +0 -51
- package/components/MFA/styles.less +0 -93
- package/components/NeedHelpView/core/describeQuestions.tsx +0 -223
- package/components/NeedHelpView/index.tsx +0 -99
- package/components/RecoveryCode/core/useCode.tsx +0 -71
- package/components/RecoveryCode/index.tsx +0 -27
- package/components/RecoveryCode/interface.ts +0 -31
- package/components/RecoveryCode/style.less +0 -13
- package/components/Register/codemap.ts +0 -16
- package/components/Register/components/Agreements/index.tsx +0 -81
- package/components/Register/components/Agreements/style.less +0 -44
- package/components/Register/core/WithEmail.tsx +0 -236
- package/components/Register/core/WithPhone.tsx +0 -184
- package/components/Register/index.tsx +0 -123
- package/components/Register/props.ts +0 -50
- package/components/SendCode/SendCodeBtn.tsx +0 -96
- package/components/SendCode/index.tsx +0 -94
- package/components/SendCode/style.less +0 -31
- package/components/ShieldSpin/index.tsx +0 -27
- package/components/ShieldSpin/loading.svg +0 -29
- package/components/SubmitButton/index.tsx +0 -50
- package/components/Type/index.ts +0 -52
- package/components/ValidatorRules/EmailFormItem.tsx +0 -81
- package/components/ValidatorRules/PhoneFormItem.tsx +0 -90
- package/components/ValidatorRules/index.ts +0 -14
- package/components/VerifyCodeInput/index.tsx +0 -76
- package/components/VerifyCodeInput/style.less +0 -24
- package/components/_utils/GuardErrorCode.ts +0 -8
- package/components/_utils/clipboard.ts +0 -27
- package/components/_utils/config.ts +0 -121
- package/components/_utils/guradHttp.ts +0 -93
- package/components/_utils/hooks/index.ts +0 -64
- package/components/_utils/http.ts +0 -85
- package/components/_utils/index.ts +0 -319
- package/components/_utils/locales/en/common.json +0 -223
- package/components/_utils/locales/en/index.ts +0 -6
- package/components/_utils/locales/en/login.json +0 -96
- package/components/_utils/locales/en/map.json +0 -4
- package/components/_utils/locales/en/user.json +0 -82
- package/components/_utils/locales/index.ts +0 -45
- package/components/_utils/locales/zh/common.json +0 -223
- package/components/_utils/locales/zh/index.ts +0 -6
- package/components/_utils/locales/zh/login.json +0 -96
- package/components/_utils/locales/zh/map.json +0 -4
- package/components/_utils/locales/zh/user.json +0 -82
- package/components/_utils/popupCenter.ts +0 -48
- package/components/assets/images/error.png +0 -0
- package/components/context/base.tsx +0 -28
- package/components/context/global/context.tsx +0 -39
- package/components/context/global/reducer.tsx +0 -56
- package/components/context/module/context.tsx +0 -23
- package/components/index.ts +0 -12
- package/config/antdReplacer.js +0 -51
- package/config/env.js +0 -104
- 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 -835
- package/config/webpackDevServer.config.js +0 -130
- package/examples.tsx +0 -107
- package/index.js +0 -1
- package/lib/static/media/loading.4a67a5f3.svg +0 -29
- package/logo.svg +0 -7
- 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/react-app-env.d.ts +0 -71
- package/reportWebVitals.ts +0 -15
- package/scripts/build.js +0 -208
- package/scripts/lib.js +0 -200
- package/scripts/start.js +0 -162
- package/scripts/test.js +0 -49
- package/setupTests.ts +0 -5
- 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,29 +0,0 @@
|
|
|
1
|
-
import { User } from '../types'
|
|
2
|
-
import { requestClient } from '../../_utils/http'
|
|
3
|
-
|
|
4
|
-
export interface SessionData {
|
|
5
|
-
session: null | {
|
|
6
|
-
_id: string
|
|
7
|
-
cookie: {
|
|
8
|
-
originalMaxAge: number
|
|
9
|
-
expires: Date
|
|
10
|
-
secure: boolean
|
|
11
|
-
httpOnly: boolean
|
|
12
|
-
path: string
|
|
13
|
-
sameSite: string
|
|
14
|
-
}
|
|
15
|
-
appId?: string
|
|
16
|
-
type: string
|
|
17
|
-
userId: string
|
|
18
|
-
}
|
|
19
|
-
userInfo?: User
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const trackSession = () =>
|
|
23
|
-
requestClient.get<SessionData>(
|
|
24
|
-
`/cas/session`,
|
|
25
|
-
{},
|
|
26
|
-
{
|
|
27
|
-
credentials: 'include',
|
|
28
|
-
}
|
|
29
|
-
)
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Lang, Protocol } from '../types'
|
|
2
|
-
import { SocialConnectionProvider } from 'authing-js-sdk'
|
|
3
|
-
|
|
4
|
-
export interface OIDCConnectionConfig {
|
|
5
|
-
issuerUrl: string
|
|
6
|
-
authorizationEdpoint: string
|
|
7
|
-
responseType: string
|
|
8
|
-
mode: OIDCConnectionMode
|
|
9
|
-
clientId: string
|
|
10
|
-
clientSecret: string
|
|
11
|
-
scopes: string
|
|
12
|
-
redirectUri: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface IOAuthConnectionConfig {
|
|
16
|
-
authEndPoint: string
|
|
17
|
-
tokenEndPoint: string
|
|
18
|
-
scope: string
|
|
19
|
-
clientId: string
|
|
20
|
-
clientSecret: string
|
|
21
|
-
authUrlTemplate: string
|
|
22
|
-
codeToTokenScript: string
|
|
23
|
-
tokenToUserInfoScript: string
|
|
24
|
-
tokenToUserInfoScriptFuncId: string
|
|
25
|
-
codeToTokenScriptFuncId: string
|
|
26
|
-
authUrl?: string // 根据模板拼接出来的授权 url
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface IAzureAdConnectionConfig {
|
|
30
|
-
microsoftAzureAdDomain: string
|
|
31
|
-
clientId: string
|
|
32
|
-
syncUserProfileOnLogin: string
|
|
33
|
-
emailVerifiedDefault: boolean
|
|
34
|
-
authorizationUrl: string
|
|
35
|
-
callbackUrl: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export enum OIDCConnectionMode {
|
|
39
|
-
FRONT_CHANNEL = 'FRONT_CHANNEL',
|
|
40
|
-
BACK_CHANNEL = 'BACK_CHANNEL',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface ISamlConnectionConfig {
|
|
44
|
-
signInEndPoint: string
|
|
45
|
-
samlRequest?: string
|
|
46
|
-
|
|
47
|
-
// saml assertion 验签公钥
|
|
48
|
-
|
|
49
|
-
samlIdpCert: string
|
|
50
|
-
|
|
51
|
-
// saml request 验签公钥
|
|
52
|
-
|
|
53
|
-
samlSpCert: string
|
|
54
|
-
|
|
55
|
-
// saml request 签名私钥
|
|
56
|
-
|
|
57
|
-
samlSpKey: string
|
|
58
|
-
|
|
59
|
-
signOutEndPoint: string
|
|
60
|
-
|
|
61
|
-
signSamlRequest: boolean
|
|
62
|
-
|
|
63
|
-
signatureAlgorithm: string
|
|
64
|
-
|
|
65
|
-
digestAlgorithm: string
|
|
66
|
-
|
|
67
|
-
protocolBinding: string
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface ICasConnectionConfig {
|
|
71
|
-
casConnectionLoginUrl: string
|
|
72
|
-
}
|
|
73
|
-
export interface SocialConnectionItem {
|
|
74
|
-
name: string
|
|
75
|
-
name_en: string
|
|
76
|
-
logo: string
|
|
77
|
-
description: string
|
|
78
|
-
provider: SocialConnectionProvider
|
|
79
|
-
authorizationUrl: string
|
|
80
|
-
tooltip: Record<Lang, string>
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface EnterpriseConnectionItem {
|
|
84
|
-
id: string
|
|
85
|
-
createdAt: Date
|
|
86
|
-
updatedAt: Date
|
|
87
|
-
userPoolId: string
|
|
88
|
-
protocol: Protocol
|
|
89
|
-
identifier: string
|
|
90
|
-
displayName: string
|
|
91
|
-
logo: string
|
|
92
|
-
enabled: boolean
|
|
93
|
-
config:
|
|
94
|
-
| OIDCConnectionConfig
|
|
95
|
-
| ISamlConnectionConfig
|
|
96
|
-
| ICasConnectionConfig
|
|
97
|
-
| IAzureAdConnectionConfig
|
|
98
|
-
| IOAuthConnectionConfig
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface UserPoolConfig {
|
|
102
|
-
name: string
|
|
103
|
-
logo: string
|
|
104
|
-
socialConnections: SocialConnectionItem[]
|
|
105
|
-
enterpriseConnections: EnterpriseConnectionItem[]
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// export const fetchUserPoolConfig = (userPoolId: string) =>
|
|
109
|
-
// requestClient.get<UserPoolConfig>(
|
|
110
|
-
// `/api/v2/userpools/${userPoolId}/public-config`
|
|
111
|
-
// )
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
GuardMode,
|
|
3
|
-
UserConfig,
|
|
4
|
-
GuardScenes,
|
|
5
|
-
LoginMethods,
|
|
6
|
-
RegisterMethods,
|
|
7
|
-
LocalesConfig,
|
|
8
|
-
} from '../../components/AuthingGuard/types'
|
|
9
|
-
import { i18n } from '../_utils/locales'
|
|
10
|
-
|
|
11
|
-
// 个人版 OTP MFA 的 error code
|
|
12
|
-
export const OTP_MFA_CODE = 1635
|
|
13
|
-
// 企业版手机和短信验证吗 MFA 的 error code
|
|
14
|
-
export const APP_MFA_CODE = 1636
|
|
15
|
-
|
|
16
|
-
// 需要验证吗
|
|
17
|
-
export const NEED_CAPTCHA = 2000
|
|
18
|
-
|
|
19
|
-
export const LOGIN_METHODS_MAP = () => ({
|
|
20
|
-
[LoginMethods.Password]: i18n.t('login.pwdLogin'),
|
|
21
|
-
[LoginMethods.PhoneCode]: i18n.t('login.verifyCodeLogin'),
|
|
22
|
-
[LoginMethods.AppQr]: i18n.t('login.appScanLogin'),
|
|
23
|
-
[LoginMethods.WxMinQr]: i18n.t('login.scanLogin'),
|
|
24
|
-
[LoginMethods.LDAP]: i18n.t('login.ldapLogin'),
|
|
25
|
-
[LoginMethods.AD]: i18n.t('login.adLogin'),
|
|
26
|
-
[LoginMethods.WechatMpQrcode]: i18n.t('login.wechatmpQrcode'),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
export const REGISTER_METHODS_MAP = () => ({
|
|
30
|
-
[RegisterMethods.Email]: i18n.t('login.emailRegister'),
|
|
31
|
-
[RegisterMethods.Phone]: i18n.t('login.phoneRegister'),
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
// 某些社会化登录会在 tabs 中显示,或者无法在 Guard 中使用,所以底部不显示了
|
|
35
|
-
export const HIDE_SOCIALS = [
|
|
36
|
-
'wechat:miniprogram:app-launch',
|
|
37
|
-
'wechat:miniprogram:qrconnect',
|
|
38
|
-
'wechat:webpage-authorization',
|
|
39
|
-
'wechat:miniprogram:default',
|
|
40
|
-
'wechatwork:addressbook',
|
|
41
|
-
'wechat:mobile',
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
// 企业版 MFA 支持的方式
|
|
45
|
-
export enum ApplicationMfaType {
|
|
46
|
-
SMS = 'SMS',
|
|
47
|
-
EMAIL = 'EMAIL',
|
|
48
|
-
// OTP = 'OTP',
|
|
49
|
-
// FACE = 'FACE',
|
|
50
|
-
// FINGERPRINT = 'FINGERPRINT',
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const defaultGuardConfig: Partial<UserConfig> = {
|
|
54
|
-
isSSO: false,
|
|
55
|
-
title: 'Authing',
|
|
56
|
-
text: {
|
|
57
|
-
loginTabs: LOGIN_METHODS_MAP(),
|
|
58
|
-
loginBtn: {
|
|
59
|
-
normal: '登录',
|
|
60
|
-
loading: '登录',
|
|
61
|
-
},
|
|
62
|
-
registerBtn: {
|
|
63
|
-
normal: '注册',
|
|
64
|
-
loading: '注册',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
escCloseable: true,
|
|
68
|
-
autoRegister: false,
|
|
69
|
-
clickCloseable: true,
|
|
70
|
-
mode: GuardMode.Normal,
|
|
71
|
-
disableRegister: false,
|
|
72
|
-
disableResetPwd: false,
|
|
73
|
-
defaultScenes: GuardScenes.Login,
|
|
74
|
-
appHost: 'https://core.authing.cn',
|
|
75
|
-
defaultLoginMethod: LoginMethods.Password,
|
|
76
|
-
defaultRegisterMethod: RegisterMethods.Email,
|
|
77
|
-
loginMethods: [LoginMethods.Password, LoginMethods.PhoneCode],
|
|
78
|
-
registerMethods: [RegisterMethods.Email, RegisterMethods.Phone],
|
|
79
|
-
logo:
|
|
80
|
-
'https://files.authing.co/user-contents/photos/0a4c99ff-b8ce-4030-aaaf-584c807cb21c.png',
|
|
81
|
-
passwordLoginMethods: [
|
|
82
|
-
'email-password',
|
|
83
|
-
'username-password',
|
|
84
|
-
'phone-password',
|
|
85
|
-
],
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export const defaultLocalesConfig: LocalesConfig = {
|
|
89
|
-
defaultLang: 'zh-CN',
|
|
90
|
-
isShowChange: false,
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export const defaultHeaders: {
|
|
94
|
-
'userpool-id': string
|
|
95
|
-
'app-id': string
|
|
96
|
-
'sdk-version': string
|
|
97
|
-
'request-from': string
|
|
98
|
-
lang: string
|
|
99
|
-
} = {
|
|
100
|
-
'userpool-id': 'x-authing-userpool-id',
|
|
101
|
-
'app-id': 'x-authing-app-id',
|
|
102
|
-
'request-from': 'x-authing-request-from',
|
|
103
|
-
'sdk-version': 'x-authing-sdk-version',
|
|
104
|
-
lang: 'x-authing-lang',
|
|
105
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthenticationClient,
|
|
3
|
-
AuthenticationClientOptions,
|
|
4
|
-
} from 'authing-js-sdk'
|
|
5
|
-
import { defaultGuardConfig } from '../constants'
|
|
6
|
-
|
|
7
|
-
let authClient: AuthenticationClient | null = null
|
|
8
|
-
|
|
9
|
-
export interface AuthClientConfig extends AuthenticationClientOptions {
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated 使用 appHost
|
|
12
|
-
*/
|
|
13
|
-
appDomain?: string
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated 无需传入
|
|
16
|
-
*/
|
|
17
|
-
isSSO?: boolean
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated 使用 appHost
|
|
20
|
-
*/
|
|
21
|
-
host?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const initAuthClient = (config: AuthClientConfig) => {
|
|
25
|
-
if (authClient) {
|
|
26
|
-
return authClient
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const { appHost, appDomain, host } = config
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 兼容之前的参数
|
|
33
|
-
*/
|
|
34
|
-
let realHost
|
|
35
|
-
if (appHost) {
|
|
36
|
-
realHost = appHost
|
|
37
|
-
} else if (appDomain) {
|
|
38
|
-
const parsedUrl = new URL(host || defaultGuardConfig.appHost!)
|
|
39
|
-
realHost = `${parsedUrl.protocol}//${appDomain}${
|
|
40
|
-
parsedUrl.port ? ':' + parsedUrl.port : ''
|
|
41
|
-
}`
|
|
42
|
-
} else if (host) {
|
|
43
|
-
realHost = host
|
|
44
|
-
} else {
|
|
45
|
-
realHost = defaultGuardConfig.appHost
|
|
46
|
-
}
|
|
47
|
-
config.appHost = realHost!
|
|
48
|
-
|
|
49
|
-
authClient = new AuthenticationClient(config)
|
|
50
|
-
|
|
51
|
-
return authClient
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export const useAuthing = (config?: AuthClientConfig) => {
|
|
55
|
-
return { authClient: getAuthClient(config) }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const getAuthClient = (config?: AuthClientConfig) => {
|
|
59
|
-
if (!authClient && !config) {
|
|
60
|
-
throw new Error(
|
|
61
|
-
'Please `initAuthClient` first or pass `AuthClientConfig` to useAuthing.'
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (config) {
|
|
66
|
-
initAuthClient(config)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return authClient
|
|
70
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
// import { inRange, debounce } from 'lodash'
|
|
3
|
-
|
|
4
|
-
function debounce(fn: Function, delay: number, immediate = true) {
|
|
5
|
-
let timer: any
|
|
6
|
-
|
|
7
|
-
return function (this: any) {
|
|
8
|
-
let context = this
|
|
9
|
-
let args = arguments
|
|
10
|
-
timer && clearTimeout(timer)
|
|
11
|
-
|
|
12
|
-
if (immediate && !timer) {
|
|
13
|
-
fn.apply(context, args)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
timer = setTimeout(function () {
|
|
17
|
-
fn.apply(context, args)
|
|
18
|
-
}, delay)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function inRange(n: number, start: number, end?: number): boolean {
|
|
23
|
-
if (end || end === 0) {
|
|
24
|
-
return n >= start && n <= end
|
|
25
|
-
}
|
|
26
|
-
return n >= start
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export enum ScreenSize {
|
|
30
|
-
Mobile = 'mobile',
|
|
31
|
-
Desktop = 'desktop',
|
|
32
|
-
}
|
|
33
|
-
export const SCREEN_SIZE_RANG: {
|
|
34
|
-
size: ScreenSize
|
|
35
|
-
range: [number, number]
|
|
36
|
-
}[] = [
|
|
37
|
-
{
|
|
38
|
-
size: ScreenSize.Mobile,
|
|
39
|
-
range: [0, 719],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
size: ScreenSize.Desktop,
|
|
43
|
-
range: [720, Infinity],
|
|
44
|
-
},
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
export const getScreenSize = () => {
|
|
48
|
-
const viewportWidth = document.body.clientWidth
|
|
49
|
-
return (
|
|
50
|
-
SCREEN_SIZE_RANG.find((item) => inRange(viewportWidth, ...item.range))
|
|
51
|
-
?.size ?? ScreenSize.Desktop
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const useScreenSize = () => {
|
|
56
|
-
const [screenSize, setScreenSize] = useState(getScreenSize)
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const onResize = debounce(() => {
|
|
60
|
-
setScreenSize(getScreenSize())
|
|
61
|
-
}, 200)
|
|
62
|
-
window.addEventListener('resize', onResize)
|
|
63
|
-
|
|
64
|
-
return () => window.removeEventListener('resize', onResize)
|
|
65
|
-
}, [])
|
|
66
|
-
|
|
67
|
-
return [screenSize]
|
|
68
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { ConfigProvider, message } from 'antd'
|
|
2
|
-
import React, { FC } from 'react'
|
|
3
|
-
import { AuthenticationClient } from 'authing-js-sdk'
|
|
4
|
-
|
|
5
|
-
import { GuardContext } from '../context/global/context'
|
|
6
|
-
import { GuardScenes } from '../../components/AuthingGuard/types'
|
|
7
|
-
import { requestClient } from '../_utils/http'
|
|
8
|
-
import {
|
|
9
|
-
defaultGuardConfig,
|
|
10
|
-
OTP_MFA_CODE,
|
|
11
|
-
APP_MFA_CODE,
|
|
12
|
-
defaultLocalesConfig,
|
|
13
|
-
defaultHeaders,
|
|
14
|
-
} from '../../components/AuthingGuard/constants'
|
|
15
|
-
import { GuardLayout } from '../../components/AuthingGuard/GuardLayout'
|
|
16
|
-
import {
|
|
17
|
-
UserConfig,
|
|
18
|
-
GuardEventsHandler,
|
|
19
|
-
} from '../../components/AuthingGuard/types/GuardConfig'
|
|
20
|
-
|
|
21
|
-
import './style.less'
|
|
22
|
-
import { initI18n } from '../_utils/locales'
|
|
23
|
-
const PREFIX_CLS = 'authing-ant'
|
|
24
|
-
|
|
25
|
-
message.config({
|
|
26
|
-
prefixCls: `${PREFIX_CLS}-message`,
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
interface AuthingGuardProps extends GuardEventsHandler {
|
|
30
|
-
appId: string
|
|
31
|
-
config?: UserConfig
|
|
32
|
-
visible?: boolean
|
|
33
|
-
className?: string
|
|
34
|
-
id?: string
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const AuthingGuard: FC<AuthingGuardProps> = ({
|
|
38
|
-
appId,
|
|
39
|
-
config = {},
|
|
40
|
-
visible,
|
|
41
|
-
className,
|
|
42
|
-
id,
|
|
43
|
-
...guardEvents
|
|
44
|
-
}) => {
|
|
45
|
-
const {
|
|
46
|
-
apiHost,
|
|
47
|
-
appDomain,
|
|
48
|
-
appHost,
|
|
49
|
-
defaultLoginMethod = defaultGuardConfig.defaultLoginMethod,
|
|
50
|
-
defaultScenes = defaultGuardConfig.defaultScenes,
|
|
51
|
-
defaultRegisterMethod = defaultGuardConfig.defaultRegisterMethod,
|
|
52
|
-
lang,
|
|
53
|
-
localesConfig = defaultLocalesConfig,
|
|
54
|
-
headers = defaultHeaders,
|
|
55
|
-
} = config
|
|
56
|
-
|
|
57
|
-
initI18n(localesConfig, lang)
|
|
58
|
-
|
|
59
|
-
let realHost: string | undefined
|
|
60
|
-
if (appHost) {
|
|
61
|
-
realHost = appHost
|
|
62
|
-
} else if (appDomain) {
|
|
63
|
-
const parsedUrl = new URL(defaultGuardConfig.appHost!)
|
|
64
|
-
realHost = `${parsedUrl.protocol}//${appDomain}${
|
|
65
|
-
parsedUrl.port ? ':' + parsedUrl.port : ''
|
|
66
|
-
}`
|
|
67
|
-
} else {
|
|
68
|
-
realHost = apiHost || defaultGuardConfig.appHost!
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
requestClient.setBaseUrl(realHost)
|
|
72
|
-
requestClient.setLangHeader(headers?.lang)
|
|
73
|
-
|
|
74
|
-
const authClient = new AuthenticationClient({
|
|
75
|
-
appHost: realHost!,
|
|
76
|
-
appId,
|
|
77
|
-
requestFrom: 'ui-components',
|
|
78
|
-
lang: localesConfig.defaultLang ?? lang,
|
|
79
|
-
headers,
|
|
80
|
-
onError: (code, msg: any) => {
|
|
81
|
-
if (code === 2020) {
|
|
82
|
-
return
|
|
83
|
-
}
|
|
84
|
-
if ([OTP_MFA_CODE, APP_MFA_CODE].includes(code)) {
|
|
85
|
-
message.info(msg)
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
message.error(msg)
|
|
89
|
-
},
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const activeTabs = {
|
|
93
|
-
[GuardScenes.Login]: defaultLoginMethod,
|
|
94
|
-
[GuardScenes.Register]: defaultRegisterMethod,
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<ConfigProvider prefixCls={PREFIX_CLS}>
|
|
99
|
-
<GuardContext
|
|
100
|
-
value={{
|
|
101
|
-
authClient,
|
|
102
|
-
config: { ...config },
|
|
103
|
-
userConfig: config,
|
|
104
|
-
appId,
|
|
105
|
-
guardScenes: defaultScenes,
|
|
106
|
-
activeTabs,
|
|
107
|
-
guardTitle: config.title,
|
|
108
|
-
mfaData: {
|
|
109
|
-
mfaToken: '',
|
|
110
|
-
},
|
|
111
|
-
guardEvents,
|
|
112
|
-
localesConfig: config.localesConfig,
|
|
113
|
-
realHost: realHost,
|
|
114
|
-
}}
|
|
115
|
-
>
|
|
116
|
-
<GuardLayout
|
|
117
|
-
id={id}
|
|
118
|
-
className={className}
|
|
119
|
-
visible={visible}
|
|
120
|
-
lang={lang}
|
|
121
|
-
userConfig={config}
|
|
122
|
-
/>
|
|
123
|
-
</GuardContext>
|
|
124
|
-
</ConfigProvider>
|
|
125
|
-
)
|
|
126
|
-
}
|