@authing/vue-ui-components 3.0.0-rc.4 → 3.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/lib/index.min.css +2 -1
- package/lib/index.min.js +1 -1
- package/package.json +4 -4
- package/src/components/AuthingGuard.vue +40 -14
- package/src/components/Guard.vue +175 -0
- package/src/components/index.js +2 -19
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authing/vue-ui-components",
|
|
3
3
|
"description": "Authing Vue UI components",
|
|
4
|
-
"version": "3.0.0
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
7
7
|
"vuejs",
|
|
8
8
|
"authing"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "
|
|
11
|
+
"main": "lib/index.min.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"demo:serve": "vue-cli-service serve",
|
|
14
14
|
"demo:build": "vue-cli-service build",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"registry": "https://registry.npmjs.org"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@authing/native-js-ui-components": "^3.0.0
|
|
36
|
+
"@authing/native-js-ui-components": "^3.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@babel/core": "^7.4.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"> 10%",
|
|
80
80
|
"last 2 versions"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "9056f23895fd3f0f6358a735605212246f8526f8"
|
|
83
83
|
}
|
|
@@ -4,12 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
6
|
import {
|
|
7
|
+
getAuthClient,
|
|
8
|
+
initAuthClient,
|
|
7
9
|
AuthingGuard as NativeAuthingGuard,
|
|
8
10
|
GuardEventsCamelToKebabMap,
|
|
11
|
+
GuardMode,
|
|
12
|
+
GuardScenes,
|
|
13
|
+
LoginMethods,
|
|
14
|
+
RegisterMethods,
|
|
9
15
|
} from "@authing/native-js-ui-components";
|
|
10
|
-
|
|
11
16
|
import "@authing/native-js-ui-components/lib/index.min.css";
|
|
12
17
|
|
|
18
|
+
export {
|
|
19
|
+
getAuthClient,
|
|
20
|
+
initAuthClient,
|
|
21
|
+
GuardMode,
|
|
22
|
+
GuardScenes,
|
|
23
|
+
LoginMethods,
|
|
24
|
+
RegisterMethods,
|
|
25
|
+
};
|
|
26
|
+
|
|
13
27
|
const format = (a, b) => {
|
|
14
28
|
return !a || a === "false" ? b : true;
|
|
15
29
|
};
|
|
@@ -70,7 +84,6 @@ export default {
|
|
|
70
84
|
return {
|
|
71
85
|
localVisible: false,
|
|
72
86
|
$guard: null,
|
|
73
|
-
localConfig: this.config
|
|
74
87
|
};
|
|
75
88
|
},
|
|
76
89
|
watch: {
|
|
@@ -97,26 +110,39 @@ export default {
|
|
|
97
110
|
},
|
|
98
111
|
},
|
|
99
112
|
mounted() {
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
113
|
+
this.config = this.config || {};
|
|
114
|
+
this.config.mode = this.mode ? this.mode : this.config.mode;
|
|
115
|
+
this.config.autoRegister = this.autoRegister
|
|
116
|
+
? this.autoRegister
|
|
117
|
+
: this.config.autoRegister;
|
|
118
|
+
this.config.isSSO = this.isSSO ? this.isSSO : this.config.isSSO;
|
|
119
|
+
this.config.clickCloseable = this.clickCloseable
|
|
120
|
+
? this.clickCloseable
|
|
121
|
+
: this.config.clickCloseable;
|
|
122
|
+
this.config.escCloseable = this.escCloseable
|
|
123
|
+
? this.escCloseable
|
|
124
|
+
: this.config.escCloseable;
|
|
106
125
|
|
|
107
126
|
// this.config.autoRegister = format(this.autoRegister, this.config.autoRegister)
|
|
108
127
|
// this.config.isSSO = format(this.isSSO, this.config.isSSO)
|
|
109
128
|
// this.config.clickCloseable = format(this.clickCloseable, this.config.clickCloseable)
|
|
110
129
|
// this.config.escCloseable = format(this.escCloseable, this.config.escCloseable)
|
|
111
130
|
|
|
112
|
-
const guard = new NativeAuthingGuard(
|
|
131
|
+
const guard = new NativeAuthingGuard(
|
|
132
|
+
this.appId,
|
|
133
|
+
this.config,
|
|
134
|
+
this.tenantId
|
|
135
|
+
);
|
|
113
136
|
|
|
114
137
|
const evts = Object.values(GuardEventsCamelToKebabMap);
|
|
115
|
-
const kebabToCamelMap = Object.entries(GuardEventsCamelToKebabMap).reduce(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
138
|
+
const kebabToCamelMap = Object.entries(GuardEventsCamelToKebabMap).reduce(
|
|
139
|
+
(acc, [camel, kebab]) => {
|
|
140
|
+
return Object.assign({}, acc, {
|
|
141
|
+
[kebab]: camel,
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
{}
|
|
145
|
+
);
|
|
120
146
|
|
|
121
147
|
const listeners = evts.reduce((acc, evtName) => {
|
|
122
148
|
return Object.assign({}, acc, {
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="authing_guard_container"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import {
|
|
7
|
+
getAuthClient,
|
|
8
|
+
initAuthClient,
|
|
9
|
+
Guard as NativeGuard,
|
|
10
|
+
GuardEventsCamelToKebabMap,
|
|
11
|
+
GuardMode,
|
|
12
|
+
GuardScenes,
|
|
13
|
+
LoginMethods,
|
|
14
|
+
RegisterMethods,
|
|
15
|
+
} from "@authing/native-js-ui-components";
|
|
16
|
+
import "@authing/native-js-ui-components/lib/index.min.css";
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
getAuthClient,
|
|
20
|
+
initAuthClient,
|
|
21
|
+
GuardMode,
|
|
22
|
+
GuardScenes,
|
|
23
|
+
LoginMethods,
|
|
24
|
+
RegisterMethods,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const format = (a, b) => {
|
|
28
|
+
return !a || a === "false" ? b : true;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const callbackEvent = ["before-login", "before-register"];
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
name: "Guard",
|
|
35
|
+
props: {
|
|
36
|
+
appId: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
config: {
|
|
41
|
+
type: Object,
|
|
42
|
+
required: false,
|
|
43
|
+
},
|
|
44
|
+
visible: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
mode: {
|
|
49
|
+
type: String,
|
|
50
|
+
required: false, // normal(全屏) modal(弹窗)
|
|
51
|
+
},
|
|
52
|
+
autoRegister: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
required: false,
|
|
55
|
+
},
|
|
56
|
+
isSSO: {
|
|
57
|
+
type: Boolean,
|
|
58
|
+
required: false,
|
|
59
|
+
},
|
|
60
|
+
clickCloseable: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
required: false,
|
|
64
|
+
},
|
|
65
|
+
escCloseable: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: true,
|
|
68
|
+
required: false,
|
|
69
|
+
},
|
|
70
|
+
onBeforeLogin: {
|
|
71
|
+
type: Function,
|
|
72
|
+
required: false,
|
|
73
|
+
},
|
|
74
|
+
onBeforeRegister: {
|
|
75
|
+
type: Function,
|
|
76
|
+
required: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
data() {
|
|
80
|
+
return {
|
|
81
|
+
localVisible: false,
|
|
82
|
+
$guard: null,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
watch: {
|
|
86
|
+
visible: {
|
|
87
|
+
immediate: true,
|
|
88
|
+
handler(val) {
|
|
89
|
+
if (val !== this.localVisible) {
|
|
90
|
+
this.localVisible = val;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
localVisible: {
|
|
95
|
+
handler(val) {
|
|
96
|
+
if (val !== this.visible) {
|
|
97
|
+
this.$emit("update:visible", val);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (val) {
|
|
101
|
+
this.show();
|
|
102
|
+
} else {
|
|
103
|
+
this.hide();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
mounted() {
|
|
109
|
+
this.config = this.config || {};
|
|
110
|
+
this.config.mode = this.mode ? this.mode : this.config.mode;
|
|
111
|
+
this.config.autoRegister = this.autoRegister
|
|
112
|
+
? this.autoRegister
|
|
113
|
+
: this.config.autoRegister;
|
|
114
|
+
this.config.isSSO = this.isSSO ? this.isSSO : this.config.isSSO;
|
|
115
|
+
this.config.clickCloseable = this.clickCloseable
|
|
116
|
+
? this.clickCloseable
|
|
117
|
+
: this.config.clickCloseable;
|
|
118
|
+
this.config.escCloseable = this.escCloseable
|
|
119
|
+
? this.escCloseable
|
|
120
|
+
: this.config.escCloseable;
|
|
121
|
+
|
|
122
|
+
// this.config.autoRegister = format(this.autoRegister, this.config.autoRegister)
|
|
123
|
+
// this.config.isSSO = format(this.isSSO, this.config.isSSO)
|
|
124
|
+
// this.config.clickCloseable = format(this.clickCloseable, this.config.clickCloseable)
|
|
125
|
+
// this.config.escCloseable = format(this.escCloseable, this.config.escCloseable)
|
|
126
|
+
|
|
127
|
+
const guard = new NativeGuard(this.appId, this.config);
|
|
128
|
+
|
|
129
|
+
const evts = Object.values(GuardEventsCamelToKebabMap);
|
|
130
|
+
const kebabToCamelMap = Object.entries(GuardEventsCamelToKebabMap).reduce(
|
|
131
|
+
(acc, [camel, kebab]) => {
|
|
132
|
+
return Object.assign({}, acc, {
|
|
133
|
+
[kebab]: camel,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
{}
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const listeners = evts.reduce((acc, evtName) => {
|
|
140
|
+
return Object.assign({}, acc, {
|
|
141
|
+
[evtName]: (...rest) => {
|
|
142
|
+
if (evtName === "close") {
|
|
143
|
+
this.localVisible = false;
|
|
144
|
+
}
|
|
145
|
+
if (!callbackEvent.includes(evtName)) {
|
|
146
|
+
this.$emit(evtName, ...rest);
|
|
147
|
+
} else {
|
|
148
|
+
const camelEvtName = kebabToCamelMap[evtName];
|
|
149
|
+
|
|
150
|
+
if (this[camelEvtName]) {
|
|
151
|
+
return this[camelEvtName](...rest);
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}, {});
|
|
158
|
+
|
|
159
|
+
evts.forEach((evtName) => guard.on(evtName, listeners[evtName]));
|
|
160
|
+
|
|
161
|
+
if (this.localVisible) {
|
|
162
|
+
guard.show();
|
|
163
|
+
}
|
|
164
|
+
this.$guard = guard;
|
|
165
|
+
},
|
|
166
|
+
methods: {
|
|
167
|
+
show() {
|
|
168
|
+
this.$guard.show();
|
|
169
|
+
},
|
|
170
|
+
hide() {
|
|
171
|
+
this.$guard.hide();
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
</script>
|
package/src/components/index.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
import AuthingGuard from './AuthingGuard.vue'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
initAuthClient,
|
|
6
|
-
GuardMode,
|
|
7
|
-
GuardScenes,
|
|
8
|
-
LoginMethods,
|
|
9
|
-
RegisterMethods,
|
|
10
|
-
} from "@authing/native-js-ui-components";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
AuthingGuard,
|
|
15
|
-
getAuthClient,
|
|
16
|
-
initAuthClient,
|
|
17
|
-
GuardMode,
|
|
18
|
-
GuardScenes,
|
|
19
|
-
LoginMethods,
|
|
20
|
-
RegisterMethods
|
|
21
|
-
}
|
|
3
|
+
export * from './AuthingGuard.vue'
|
|
4
|
+
export { AuthingGuard }
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Authing
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|