@authing/native-js-ui-components 3.1.39-rc.1 → 4.0.0
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/LICENSE +21 -0
- package/lib/index.d.ts +8 -32
- package/lib/index.min.css +2 -2
- package/lib/index.min.js +1 -1
- package/package.json +5 -4
- package/src/App.tsx +0 -1
- package/src/components/Guard/index.tsx +9 -7
- package/src/components/index.ts +2 -50
- package/tsconfig.json +4 -17
- package/src/components/AuthingGuard/index.tsx +0 -98
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authing/native-js-ui-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"framework": "Native",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/index.min.js",
|
|
@@ -165,7 +165,8 @@
|
|
|
165
165
|
"workbox-webpack-plugin": "5.1.4"
|
|
166
166
|
},
|
|
167
167
|
"dependencies": {
|
|
168
|
-
"@authing/react-ui-components": "
|
|
169
|
-
"authing-js-sdk": "4.23.
|
|
170
|
-
}
|
|
168
|
+
"@authing/react-ui-components": "4.0.8",
|
|
169
|
+
"authing-js-sdk": "4.23.36-alpha.1"
|
|
170
|
+
},
|
|
171
|
+
"gitHead": "44b6d3f22978d3e56895a8aeb580d2f5dcac89d8"
|
|
171
172
|
}
|
package/src/App.tsx
CHANGED
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
AuthenticationClient,
|
|
8
8
|
GuardEventsKebabToCamelType,
|
|
9
9
|
GuardEventsCamelToKebabMapping,
|
|
10
|
+
GuardLocalConfig,
|
|
11
|
+
GuardProps,
|
|
10
12
|
} from "@authing/react-ui-components";
|
|
11
13
|
import "@authing/react-ui-components/lib/index.min.css";
|
|
12
|
-
import { GuardComponentConfig, GuardLocalConfig } from "@authing/react-ui-components/components/Guard/config";
|
|
14
|
+
// import { GuardComponentConfig, GuardLocalConfig } from "@authing/react-ui-components/components/Guard/config";
|
|
13
15
|
|
|
14
16
|
export interface NativeGuardProps {
|
|
15
17
|
appId?: string;
|
|
@@ -34,12 +36,12 @@ export type GuardEventListeners = {
|
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
export class Guard {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
public appId?: string;
|
|
40
|
+
public config?: Partial<GuardLocalConfig>;
|
|
41
|
+
public tenantId?: string;
|
|
42
|
+
public authClient?: AuthenticationClient;
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
public visible?: boolean;
|
|
43
45
|
constructor(props?: NativeGuardProps);
|
|
44
46
|
constructor(appId?: string, config?: Partial<GuardLocalConfig>, tenantId?: string, authClient?: AuthenticationClient);
|
|
45
47
|
|
|
@@ -161,7 +163,7 @@ export class Guard {
|
|
|
161
163
|
<ReactAuthingGuard
|
|
162
164
|
{...(evts as GuardEvents)}
|
|
163
165
|
appId={this.appId}
|
|
164
|
-
config={this.config as
|
|
166
|
+
config={this.config as GuardProps["config"]}
|
|
165
167
|
visible={this.visible}
|
|
166
168
|
tenantId={this.tenantId}
|
|
167
169
|
authClient={this.authClient}
|
package/src/components/index.ts
CHANGED
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
// export * from "./Guard";
|
|
2
1
|
import { Guard } from "./Guard";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
User,
|
|
7
|
-
GuardMode,
|
|
8
|
-
UserConfig,
|
|
9
|
-
GuardScenes,
|
|
10
|
-
LoginMethods,
|
|
11
|
-
getAuthClient,
|
|
12
|
-
CommonMessage,
|
|
13
|
-
initAuthClient,
|
|
14
|
-
RegisterMethods,
|
|
15
|
-
GuardModuleType,
|
|
16
|
-
GuardEventsHandler,
|
|
17
|
-
AuthenticationClient,
|
|
18
|
-
GuardEventsHandlerKebab,
|
|
19
|
-
GuardEventsCamelToKebabMap,
|
|
20
|
-
GuardEvents,
|
|
21
|
-
GuardEventsKebabToCamelType,
|
|
22
|
-
GuardEventsCamelToKebabMapping,
|
|
23
|
-
GuardConfig,
|
|
24
|
-
GuardLocalConfig,
|
|
25
|
-
} from "@authing/react-ui-components";
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
Guard,
|
|
29
|
-
AuthingGuard,
|
|
30
|
-
GuardMode,
|
|
31
|
-
GuardScenes,
|
|
32
|
-
LoginMethods,
|
|
33
|
-
getAuthClient,
|
|
34
|
-
initAuthClient,
|
|
35
|
-
RegisterMethods,
|
|
36
|
-
GuardEventsCamelToKebabMap,
|
|
37
|
-
GuardEventsCamelToKebabMapping,
|
|
38
|
-
};
|
|
39
|
-
export type {
|
|
40
|
-
GuardConfig,
|
|
41
|
-
GuardLocalConfig,
|
|
42
|
-
GuardEvents,
|
|
43
|
-
User,
|
|
44
|
-
UserConfig,
|
|
45
|
-
CommonMessage,
|
|
46
|
-
GuardModuleType,
|
|
47
|
-
GuardEventsHandler,
|
|
48
|
-
AuthenticationClient,
|
|
49
|
-
GuardEventsHandlerKebab,
|
|
50
|
-
GuardEventsKebabToCamelType,
|
|
51
|
-
};
|
|
2
|
+
export { Guard };
|
|
3
|
+
export * from "@authing/react-ui-components";
|
package/tsconfig.json
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
"baseUrl": ".",
|
|
4
4
|
"outDir": "lib/",
|
|
5
5
|
"target": "es5",
|
|
6
|
-
"lib": [
|
|
7
|
-
"dom",
|
|
8
|
-
"dom.iterable",
|
|
9
|
-
"esnext"
|
|
10
|
-
],
|
|
6
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
11
7
|
"allowJs": true,
|
|
12
8
|
"skipLibCheck": true,
|
|
13
9
|
"esModuleInterop": true,
|
|
@@ -18,20 +14,11 @@
|
|
|
18
14
|
"module": "esnext",
|
|
19
15
|
"moduleResolution": "node",
|
|
20
16
|
"resolveJsonModule": true,
|
|
21
|
-
"isolatedModules": true,
|
|
22
17
|
"declaration": true,
|
|
23
18
|
"noEmit": false,
|
|
24
19
|
"jsx": "react",
|
|
25
20
|
"downlevelIteration": true
|
|
26
21
|
},
|
|
27
|
-
"include": [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"src/**/*.json"
|
|
31
|
-
],
|
|
32
|
-
"exclude": [
|
|
33
|
-
"node_modules",
|
|
34
|
-
"lib",
|
|
35
|
-
"build"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
22
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.json"],
|
|
23
|
+
"exclude": ["node_modules", "lib", "build"]
|
|
24
|
+
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactDOM from "react-dom";
|
|
3
|
-
import { AuthingGuard as ReactAuthingGuard } from "@authing/react-ui-components";
|
|
4
|
-
import {
|
|
5
|
-
GuardMode,
|
|
6
|
-
UserConfig,
|
|
7
|
-
GuardEventsHandler,
|
|
8
|
-
GuardEventsHandlerKebab,
|
|
9
|
-
GuardEventsCamelToKebabMap,
|
|
10
|
-
} from "@authing/react-ui-components";
|
|
11
|
-
import "@authing/react-ui-components/lib/index.min.css";
|
|
12
|
-
|
|
13
|
-
export type EventListeners = {
|
|
14
|
-
[key in keyof GuardEventsHandlerKebab]: Exclude<Required<GuardEventsHandlerKebab>[key], undefined>[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export class AuthingGuard {
|
|
18
|
-
constructor(private appId: string, private config?: UserConfig, private tenantId?: string) {
|
|
19
|
-
this.render();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static getGuardContainer(selector?: string | HTMLElement) {
|
|
23
|
-
const defaultId = "authing_guard_container";
|
|
24
|
-
|
|
25
|
-
if (!selector) {
|
|
26
|
-
let container = document.querySelector(`#${defaultId}`);
|
|
27
|
-
if (!container) {
|
|
28
|
-
container = document.createElement("div");
|
|
29
|
-
container.id = defaultId;
|
|
30
|
-
document.body.appendChild(container);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return container;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (typeof selector === "string") {
|
|
37
|
-
return document.querySelector(selector);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return selector;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private visible = this.config?.mode === GuardMode.Modal ? false : true;
|
|
44
|
-
|
|
45
|
-
private eventListeners = Object.values(GuardEventsCamelToKebabMap).reduce((acc, evtName) => {
|
|
46
|
-
return Object.assign({}, acc, {
|
|
47
|
-
[evtName]: [],
|
|
48
|
-
});
|
|
49
|
-
}, {} as EventListeners);
|
|
50
|
-
|
|
51
|
-
private render(cb?: () => void) {
|
|
52
|
-
const evts: GuardEventsHandler = Object.entries(GuardEventsCamelToKebabMap).reduce((acc, [reactEvt, nativeEvt]) => {
|
|
53
|
-
return Object.assign({}, acc, {
|
|
54
|
-
[reactEvt]: (...rest: any) => {
|
|
55
|
-
if (nativeEvt === "close") {
|
|
56
|
-
this.hide();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// TODO 返回最后一个执行函数的值,实际应该只让监听一次
|
|
60
|
-
return (
|
|
61
|
-
this.eventListeners[nativeEvt]
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
.map((item: any) => {
|
|
64
|
-
return item(...rest);
|
|
65
|
-
})
|
|
66
|
-
.slice(-1)[0] ?? true
|
|
67
|
-
);
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}, {} as GuardEventsHandler);
|
|
71
|
-
|
|
72
|
-
return ReactDOM.render(
|
|
73
|
-
<ReactAuthingGuard
|
|
74
|
-
{...evts}
|
|
75
|
-
appId={this.appId}
|
|
76
|
-
tenantId={this.tenantId}
|
|
77
|
-
config={this.config}
|
|
78
|
-
visible={this.visible}
|
|
79
|
-
/>,
|
|
80
|
-
AuthingGuard.getGuardContainer(this.config?.target),
|
|
81
|
-
cb
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
on<T extends keyof GuardEventsHandlerKebab>(evt: T, handler: Exclude<GuardEventsHandlerKebab[T], undefined>) {
|
|
86
|
-
this.eventListeners[evt]!.push(handler as any);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
show() {
|
|
90
|
-
this.visible = true;
|
|
91
|
-
this.render();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
hide() {
|
|
95
|
-
this.visible = false;
|
|
96
|
-
this.render();
|
|
97
|
-
}
|
|
98
|
-
}
|