@authing/react-ui-components 2.4.54 → 2.4.55

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 (33) hide show
  1. package/build/asset-manifest.json +13 -13
  2. package/build/index.html +1 -1
  3. package/build/static/css/{2.9512539b.chunk.css → 2.51c07e65.chunk.css} +2 -2
  4. package/build/static/css/2.51c07e65.chunk.css.map +1 -0
  5. package/build/static/css/main.779f221a.chunk.css +2 -0
  6. package/build/static/css/main.779f221a.chunk.css.map +1 -0
  7. package/build/static/js/2.bbae9fdb.chunk.js +3 -0
  8. package/build/static/js/{2.1105ecfb.chunk.js.LICENSE.txt → 2.bbae9fdb.chunk.js.LICENSE.txt} +0 -0
  9. package/build/static/js/2.bbae9fdb.chunk.js.map +1 -0
  10. package/build/static/js/main.5f341531.chunk.js +2 -0
  11. package/build/static/js/main.5f341531.chunk.js.map +1 -0
  12. package/lib/index.d.ts +196 -1217
  13. package/lib/index.min.css +1 -2
  14. package/lib/index.min.js +1 -1
  15. package/lib/index.min.js.LICENSE.txt +0 -32
  16. package/package.json +5 -4
  17. package/src/components/AuthingGuard/GuardLayout/index.tsx +3 -0
  18. package/src/components/AuthingGuard/Header/index.tsx +5 -2
  19. package/src/components/AuthingGuard/Header/style.less +23 -11
  20. package/src/components/AuthingGuard/api/appConfig.ts +1 -0
  21. package/src/components/AuthingGuard/api/http.ts +32 -9
  22. package/src/components/AuthingGuard/constants.ts +2 -0
  23. package/src/components/AuthingGuard/index.tsx +8 -0
  24. package/src/components/AuthingGuard/types/GuardConfig.ts +1 -0
  25. package/src/index.tsx +8 -18
  26. package/build/static/css/2.9512539b.chunk.css.map +0 -1
  27. package/build/static/css/main.0ff9e24a.chunk.css +0 -2
  28. package/build/static/css/main.0ff9e24a.chunk.css.map +0 -1
  29. package/build/static/js/2.1105ecfb.chunk.js +0 -3
  30. package/build/static/js/2.1105ecfb.chunk.js.map +0 -1
  31. package/build/static/js/main.a47645ff.chunk.js +0 -2
  32. package/build/static/js/main.a47645ff.chunk.js.map +0 -1
  33. package/lib/static/media/loading.4a67a5f3.svg +0 -29
@@ -4,38 +4,6 @@
4
4
  http://jedwatson.github.io/classnames
5
5
  */
6
6
 
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
-
22
- /**
23
- * @license
24
- * Copyright 2020 Google LLC. All Rights Reserved.
25
- * Licensed under the Apache License, Version 2.0 (the "License");
26
- * you may not use this file except in compliance with the License.
27
- * You may obtain a copy of the License at
28
- *
29
- * http://www.apache.org/licenses/LICENSE-2.0
30
- *
31
- * Unless required by applicable law or agreed to in writing, software
32
- * distributed under the License is distributed on an "AS IS" BASIS,
33
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
- * See the License for the specific language governing permissions and
35
- * limitations under the License.
36
- * =============================================================================
37
- */
38
-
39
7
  /**
40
8
  * @license
41
9
  * Lodash <https://lodash.com/>
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@authing/react-ui-components",
3
- "version": "2.4.54",
3
+ "version": "2.4.55",
4
4
  "private": false,
5
5
  "main": "lib/index.min.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "dependencies": {
8
8
  "antd": "^4.8.0",
9
- "authing-js-sdk": "4.22.18",
9
+ "authing-js-sdk": "4.22.24-alpha",
10
10
  "qs": "^6.9.4"
11
11
  },
12
12
  "peerDependencies": {
@@ -184,5 +184,6 @@
184
184
  "webpack-dev-server": "3.11.0",
185
185
  "webpack-manifest-plugin": "2.2.0",
186
186
  "workbox-webpack-plugin": "5.1.4"
187
- }
188
- }
187
+ },
188
+ "gitHead": "8c8162fd4a91c1d1376bf68d4592f90572cc3a7e"
189
+ }
@@ -184,6 +184,8 @@ const useGuardConfig = () => {
184
184
  ? ''
185
185
  : userConfig.title ?? appConfig.name ?? defaultGuardConfig.title
186
186
 
187
+ const description = loading ? '' : appConfig.description ?? ''
188
+
187
189
  // 应用 logo
188
190
  const logo = loading
189
191
  ? ''
@@ -218,6 +220,7 @@ const useGuardConfig = () => {
218
220
  {
219
221
  logo,
220
222
  title,
223
+ description,
221
224
  autoRegister,
222
225
  loginMethods,
223
226
  passwordLoginMethods,
@@ -10,7 +10,7 @@ export interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {}
10
10
  export const GuardHeader: FC<HeaderProps> = (props) => {
11
11
  const {
12
12
  state: {
13
- config: { logo, title },
13
+ config: { logo, title, description },
14
14
  },
15
15
  } = useGuardContext()
16
16
 
@@ -19,7 +19,10 @@ export const GuardHeader: FC<HeaderProps> = (props) => {
19
19
  {Boolean(logo) && (
20
20
  <Avatar className="authing-guard-logo" src={logo} size={50}></Avatar>
21
21
  )}
22
- <div className="authing-guard-title">{title}</div>
22
+ <div className="authing-guard-title-container">
23
+ <div className="authing-guard-title">{title}</div>
24
+ <div className="authing-guard-description">{description}</div>
25
+ </div>
23
26
  </div>
24
27
  )
25
28
  }
@@ -13,23 +13,26 @@
13
13
  object-fit: contain;
14
14
  }
15
15
 
16
+ .authing-guard-title-container {
17
+ display: flex;
18
+ justify-content: center;
19
+ flex-direction: column;
20
+ align-items: center;
21
+ }
22
+
16
23
  .authing-guard-title {
17
- color: #abb9d7;
24
+ color: #282d3c;
18
25
  font-size: 24px;
19
- margin-bottom: 24px;
26
+ margin-bottom: 4px;
20
27
  width: 100%;
21
28
  word-break: break-all;
22
29
  text-align: center;
23
30
  }
24
-
25
- // .large .logo {
26
- // margin-bottom: 16px;
27
- // }
28
-
29
- // .large .title {
30
- // color: #333333;
31
- // font-size: 32px;
32
- // }
31
+ .authing-guard-description {
32
+ font-size: 16px;
33
+ color: #878a95;
34
+ margin-bottom: 23px;
35
+ }
33
36
 
34
37
  @media only screen and (max-width: 719px) {
35
38
  .authing-guard-header {
@@ -45,8 +48,17 @@
45
48
  padding-left: 8px;
46
49
  color: #333333;
47
50
  font-weight: 500;
51
+ text-align: unset;
48
52
  }
49
53
  .authing-guard-logo {
50
54
  margin: 0;
51
55
  }
56
+ .authing-guard-title-container {
57
+ flex-direction: column;
58
+ align-items: flex-start;
59
+ }
60
+ .authing-guard-description {
61
+ margin-bottom: 0px;
62
+ padding-left: 8px;
63
+ }
52
64
  }
@@ -75,6 +75,7 @@ export interface ApplicationConfig {
75
75
  css: string
76
76
  name: string
77
77
  logo: string
78
+ description?: string
78
79
  redirectUris: string[]
79
80
  registerDisabled: boolean
80
81
  registerTabs: {
@@ -17,6 +17,15 @@ requestClient.get = async <T>(
17
17
  query: Record<string, any> = {},
18
18
  init?: RequestInit
19
19
  ): Promise<AuthingResponse<T>> => {
20
+ const headers: Record<string, any> = {
21
+ ...init?.headers,
22
+ 'Content-Type': 'application/json',
23
+ [requestClient.langHeader]: i18n.language,
24
+ }
25
+
26
+ if (requestClient.tenantId !== '')
27
+ headers[requestClient.tenantHeader] = requestClient.tenantId
28
+
20
29
  const res = await fetch(
21
30
  `${requestClient.baseUrl}${path}${qs.stringify(query, {
22
31
  addQueryPrefix: true,
@@ -24,10 +33,7 @@ requestClient.get = async <T>(
24
33
  {
25
34
  ...init,
26
35
  credentials: 'include',
27
- headers: {
28
- ...init?.headers,
29
- [requestClient.langHeader]: i18n.language,
30
- },
36
+ headers,
31
37
  }
32
38
  )
33
39
 
@@ -41,15 +47,20 @@ requestClient.post = async <T>(
41
47
  headers: any
42
48
  }
43
49
  ): Promise<AuthingResponse<T>> => {
50
+ const headers: Record<string, any> = {
51
+ ...config?.headers,
52
+ 'Content-Type': 'application/json',
53
+ [requestClient.langHeader]: i18n.language,
54
+ }
55
+
56
+ if (requestClient.tenantId !== '')
57
+ headers[requestClient.tenantHeader] = requestClient.tenantId
58
+
44
59
  const res = await fetch(`${requestClient.baseUrl}${path}`, {
45
60
  method: 'POST',
46
61
  body: JSON.stringify(data),
47
62
  credentials: 'include',
48
- headers: {
49
- ...config?.headers,
50
- 'Content-Type': 'application/json',
51
- [requestClient.langHeader]: i18n.language,
52
- },
63
+ headers: headers,
53
64
  })
54
65
  return res.json()
55
66
  }
@@ -59,7 +70,19 @@ requestClient.setBaseUrl = (base: string) => {
59
70
  requestClient.baseUrl = base.replace(/\/$/, '')
60
71
  }
61
72
  const DEFAULT_LANG_HEADER = 'x-authing-lang'
73
+ const DEFAULT_TENANT_HEADER = 'x-authing-app-tenant-idåå'
62
74
  requestClient.langHeader = DEFAULT_LANG_HEADER
75
+ requestClient.tenantHeader = DEFAULT_TENANT_HEADER
76
+ requestClient.tenantId = ''
77
+
63
78
  requestClient.setLangHeader = (key: string | undefined) => {
64
79
  requestClient.langHeader = key || DEFAULT_LANG_HEADER
65
80
  }
81
+
82
+ requestClient.setTenantHeader = (key: string | undefined) => {
83
+ requestClient.tenantHeader = key || DEFAULT_LANG_HEADER
84
+ }
85
+
86
+ requestClient.setTenantId = (tenantId: string) => {
87
+ requestClient.tenantId = tenantId
88
+ }
@@ -95,10 +95,12 @@ export const defaultHeaders: {
95
95
  'app-id': string
96
96
  'sdk-version': string
97
97
  'request-from': string
98
+ 'tenant-id': string
98
99
  lang: string
99
100
  } = {
100
101
  'userpool-id': 'x-authing-userpool-id',
101
102
  'app-id': 'x-authing-app-id',
103
+ 'tenant-id': 'x-authing-app-tenant-id',
102
104
  'request-from': 'x-authing-request-from',
103
105
  'sdk-version': 'x-authing-sdk-version',
104
106
  lang: 'x-authing-lang',
@@ -28,6 +28,7 @@ message.config({
28
28
 
29
29
  interface AuthingGuardProps extends GuardEventsHandler {
30
30
  appId: string
31
+ tenantId?: string
31
32
  config?: UserConfig
32
33
  visible?: boolean
33
34
  className?: string
@@ -36,6 +37,7 @@ interface AuthingGuardProps extends GuardEventsHandler {
36
37
 
37
38
  export const AuthingGuard: FC<AuthingGuardProps> = ({
38
39
  appId,
40
+ tenantId,
39
41
  config = {},
40
42
  visible,
41
43
  className,
@@ -71,9 +73,15 @@ export const AuthingGuard: FC<AuthingGuardProps> = ({
71
73
  requestClient.setBaseUrl(realHost)
72
74
  requestClient.setLangHeader(headers?.lang)
73
75
 
76
+ if (tenantId) {
77
+ requestClient.setTenantHeader(headers?.['tenant-id'])
78
+ requestClient.setTenantId(tenantId)
79
+ }
80
+
74
81
  const authClient = new AuthenticationClient({
75
82
  appHost: realHost!,
76
83
  appId,
84
+ tenantId,
77
85
  requestFrom: 'ui-components',
78
86
  lang: localesConfig.defaultLang ?? lang,
79
87
  headers,
@@ -353,6 +353,7 @@ export interface GuardEventsHandler {
353
353
  export interface UserConfig {
354
354
  logo?: string
355
355
  title?: string
356
+ description?: string
356
357
  zIndex?: number
357
358
  isSSO?: boolean
358
359
  mode?: GuardMode
package/src/index.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Button } from 'antd'
2
2
  import React, { useState } from 'react'
3
3
  import ReactDOM from 'react-dom'
4
- import { initAuthClient, Lang } from './components'
4
+ import { Lang } from './components'
5
5
  import { AuthingGuard } from './components/AuthingGuard'
6
6
 
7
7
  import {
@@ -20,9 +20,8 @@ const App = () => {
20
20
  const [title, setTitle] = useState('标题')
21
21
 
22
22
  const config: UserConfig = {
23
- title,
24
23
  mode: GuardMode.Modal,
25
- // appHost: 'https://sample-sso.authing.cn',
24
+ appHost: 'https://core.dev2.authing-inc.co/',
26
25
  // apiHost: 'http://console.authing.localhost:3000',
27
26
  // apiHost: 'http://192.168.50.57:3000',
28
27
  // loginMethods: Object.values(LoginMethods),
@@ -55,16 +54,6 @@ const App = () => {
55
54
  // `,
56
55
  // // autoRegister: true,
57
56
  // socialConnections: [SocialConnections.AppleWeb],
58
- passwordLoginMethods: ['username-password'],
59
- localesConfig: {
60
- defaultLang: 'en-US',
61
- isShowChange: true,
62
- onChange: (value) => {
63
- console.log('...........')
64
- console.log(value)
65
- },
66
- },
67
- lang: lang,
68
57
  }
69
58
 
70
59
  const [visible, setVisible] = useState(false)
@@ -73,10 +62,10 @@ const App = () => {
73
62
  // setTimeout(() => setVisible(true), 3000)
74
63
  // }, [])
75
64
 
76
- initAuthClient({
77
- appId: '60c02a89a9e0431e271d9ff0',
78
- // appHost: 'http://console.authing.localhost:3000',
79
- })
65
+ // initAuthClient({
66
+ // appId: '60c02a89a9e0431e271d9ff0',
67
+ // // appHost: 'http://console.authing.localhost:3000',
68
+ // })
80
69
 
81
70
  return (
82
71
  // eslint-disable-next-line react/jsx-no-undef
@@ -125,7 +114,8 @@ const App = () => {
125
114
  }}
126
115
  // onLoad={(a) => console.log(a, '加载完成')}
127
116
  // onPwdResetError={(e) => console.log(e)}
128
- appId="60c02a89a9e0431e271d9ff0"
117
+ appId="6191cf610f772aa56dc70637"
118
+ tenantId="6194a41abf23c1d5268b362a"
129
119
  // appId="5fd877fb0ba0421962eced94"
130
120
  config={config}
131
121
  />