@authing/vue-ui-components 4.4.0-alpha.7 → 4.4.2

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/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Authing Vue UI Components
2
+
3
+ [Authing](https://authing.cn) 是一个企业级身份认证提供商,其集成了 OAuth、LDAP、OIDC 等多种身份认证和授权解决方案。此仓库包含了 Authing 提供的一些 Vue UI 组件。
4
+
5
+ ## Guard
6
+
7
+ Guard 是一种可嵌入的登录表单,可根据你的需求进行配置,建议用于单页面应用程序。 它使你可以轻松添加各种社会化登录方式,以便你的用户可以无缝登录,并且在不同平台拥有一致的登录体验。
8
+ Guard 拥有以下基本功能:
9
+
10
+ - 登录:
11
+ - 账号密码登录(包括手机号 + 密码、邮箱 + 密码、用户名 + 密码);
12
+ - 手机验证码登录;
13
+ - 微信小程序扫码登录(需先在后台配置);
14
+ - APP 扫码登录(需要接入 APP 扫码登录);
15
+ - 小程序扫码登录(需先在后台配置);
16
+ - 社会化登录(需要配置社会化登录);
17
+ - 企业身份源登录(需要配置企业身份源);
18
+ - 注册:
19
+ - 账号密码注册;
20
+ - 手机验证码注册;
21
+ - 忘记密码以及重置密码;
22
+ - MFA 认证;
23
+ - 响应式特性(兼容移动端和 PC 端);
24
+ - 完整的 UI 自定义功能;
25
+ - 兼容主流前端 UI 库:
26
+ - 原生 JavaScript 调用;
27
+ - Vue 组件;
28
+ - React 组件;
29
+ - Angular 组件。
30
+
31
+ ![Guard Demo](./static/images/guard-demo.jpg)
32
+
33
+ 详细使用文档请查看 [Guard for Web](https://docs.authing.cn/sdk/guard/#guard-for-vue)
@@ -0,0 +1,8 @@
1
+ import Guard from './src/index.vue'
2
+ import '@authing/native-js-ui-components/lib/index.min.css'
3
+
4
+ Guard.install = (app) => {
5
+ app.component(Guard.name, Guard)
6
+ }
7
+
8
+ export default Guard
@@ -0,0 +1,166 @@
1
+ <template>
2
+ <div id="authing_guard_container" />
3
+ </template>
4
+
5
+ <script>
6
+ import { Guard as NativeGuard, GuardEventsCamelToKebabMapping } from "@authing/native-js-ui-components";
7
+ import "@authing/native-js-ui-components/lib/index.min.css";
8
+
9
+ const callbackEvent = ["before-login", "before-register"];
10
+
11
+ export default {
12
+ name: "Guard",
13
+ props: {
14
+ appId: {
15
+ type: String,
16
+ required: false,
17
+ },
18
+ tenantId: {
19
+ type: String,
20
+ required: false,
21
+ },
22
+
23
+ config: {
24
+ type: Object,
25
+ required: false,
26
+ },
27
+ authClient: {
28
+ type: Object,
29
+ required: false,
30
+ },
31
+ visible: {
32
+ type: Boolean,
33
+ default: false,
34
+ },
35
+ mode: {
36
+ type: String,
37
+ required: false, // normal(全屏) modal(弹窗)
38
+ },
39
+ autoRegister: {
40
+ type: Boolean,
41
+ required: false,
42
+ },
43
+ isSSO: {
44
+ type: Boolean,
45
+ required: false,
46
+ },
47
+ clickCloseable: {
48
+ type: Boolean,
49
+ default: true,
50
+ required: false,
51
+ },
52
+ escCloseable: {
53
+ type: Boolean,
54
+ default: true,
55
+ required: false,
56
+ },
57
+ onBeforeLogin: {
58
+ type: Function,
59
+ required: false,
60
+ },
61
+ onBeforeRegister: {
62
+ type: Function,
63
+ required: false,
64
+ },
65
+ },
66
+ data() {
67
+ return {
68
+ localVisible: false,
69
+ guardInstance: null,
70
+ guarConfig: {},
71
+ };
72
+ },
73
+ computed: {
74
+ mergeConfig: function () {
75
+ return {
76
+ ...this.config,
77
+ appId: this.appId,
78
+ mode: this.mode ?? this.config?.mode,
79
+ autoRegister: this.autoRegister ?? this.config?.autoRegister,
80
+ isSSO: this.isSSO ?? this.config?.isSSO,
81
+ clickCloseable: this.clickCloseable ?? this.config?.clickCloseable,
82
+ escCloseable: this.escCloseable ?? this.config?.escCloseable,
83
+ };
84
+ },
85
+ },
86
+ watch: {
87
+ visible: {
88
+ immediate: true,
89
+ handler(val) {
90
+ if (val !== this.localVisible) {
91
+ this.localVisible = val;
92
+ }
93
+ },
94
+ },
95
+ localVisible: {
96
+ handler(val) {
97
+ if (val !== this.visible) {
98
+ this.$emit("visible", val);
99
+ }
100
+
101
+ if (val) {
102
+ this.show();
103
+ } else {
104
+ this.hide();
105
+ }
106
+ },
107
+ },
108
+ },
109
+ mounted() {
110
+ this.guardInstance = new NativeGuard({
111
+ appId: this.appId,
112
+ tenantId: this.tenantId,
113
+ config: this.mergeConfig,
114
+ authClient: this.authClient,
115
+ });
116
+
117
+ const evts = Object.values(GuardEventsCamelToKebabMapping);
118
+ const kebabToCamelMap = Object.entries(GuardEventsCamelToKebabMapping).reduce((acc, [camel, kebab]) => {
119
+ return Object.assign({}, acc, {
120
+ [kebab]: camel,
121
+ });
122
+ }, {});
123
+
124
+ const listeners = evts.reduce((acc, evtName) => {
125
+ return Object.assign({}, acc, {
126
+ [evtName]: (...rest) => {
127
+ if (evtName === "close") {
128
+ this.localVisible = false;
129
+ }
130
+ if (!callbackEvent.includes(evtName)) {
131
+ this.$emit(evtName, ...rest);
132
+ } else {
133
+ const camelEvtName = kebabToCamelMap[evtName];
134
+
135
+ if (this[camelEvtName]) {
136
+ return this[camelEvtName](...rest);
137
+ }
138
+ return true;
139
+ }
140
+ },
141
+ });
142
+ }, {});
143
+
144
+ evts.forEach((evtName) => this.guardInstance.on(evtName, listeners[evtName]));
145
+
146
+ if (this.localVisible) {
147
+ this.guardInstance.show();
148
+ }
149
+ },
150
+
151
+ beforeUnmount() {
152
+ this.guardInstance.unmountComponent();
153
+ },
154
+ beforeDestroy() {
155
+ this.guardInstance.unmountComponent();
156
+ },
157
+ methods: {
158
+ show() {
159
+ this.guardInstance.show();
160
+ },
161
+ hide() {
162
+ this.guardInstance.hide();
163
+ },
164
+ },
165
+ };
166
+ </script>
@@ -0,0 +1,26 @@
1
+ // import AuthingGuard from './AuthingGuard'
2
+ import Guard from './Guard'
3
+ import '@authing/native-js-ui-components/lib/index.min.css'
4
+
5
+ const components = [
6
+ // AuthingGuard,
7
+ Guard,
8
+ ]
9
+ // 全局注册
10
+ const install = (app) => {
11
+ components.forEach(component => {
12
+ app.component(component.name, component)
13
+ })
14
+ }
15
+
16
+ // 局部注册
17
+ export {
18
+ install,
19
+ Guard,
20
+ // AuthingGuard
21
+ }
22
+ export default {
23
+ install,
24
+ }
25
+
26
+ export * from "@authing/native-js-ui-components";