@ezeep/ezeep-js 1.0.267 → 1.0.269
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/dist/cjs/app-globals-D7ISNeUi.js +16 -0
- package/dist/cjs/ezeep.cjs.js +43 -12
- package/dist/cjs/ezp-auth_15.cjs.entry.js +27992 -26047
- package/dist/cjs/index-dv_gozsq.js +4694 -0
- package/dist/cjs/loader.cjs.js +7 -17
- package/dist/collection/collection-manifest.json +19 -18
- package/dist/collection/components/ezp-auth/ezp-auth.js +266 -245
- package/dist/collection/components/ezp-backdrop/ezp-backdrop.js +93 -81
- package/dist/collection/components/ezp-dialog/ezp-dialog.js +226 -210
- package/dist/collection/components/ezp-icon/ezp-icon.js +117 -102
- package/dist/collection/components/ezp-icon-button/ezp-icon-button.js +181 -159
- package/dist/collection/components/ezp-input/ezp-input.css +5 -5
- package/dist/collection/components/ezp-input/ezp-input.js +227 -205
- package/dist/collection/components/ezp-label/ezp-label.css +5 -5
- package/dist/collection/components/ezp-label/ezp-label.js +151 -132
- package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.css +5 -5
- package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.js +1134 -1107
- package/dist/collection/components/ezp-printing/ezp-printing.css +183 -125
- package/dist/collection/components/ezp-printing/ezp-printing.js +872 -807
- package/dist/collection/components/ezp-select/ezp-select.css +4 -4
- package/dist/collection/components/ezp-select/ezp-select.js +376 -351
- package/dist/collection/components/ezp-status/ezp-status.css +5 -5
- package/dist/collection/components/ezp-status/ezp-status.js +238 -223
- package/dist/collection/components/ezp-stepper/ezp-stepper.css +5 -5
- package/dist/collection/components/ezp-stepper/ezp-stepper.js +256 -243
- package/dist/collection/components/ezp-text-button/ezp-text-button.js +196 -174
- package/dist/collection/components/ezp-upload/ezp-upload.js +134 -141
- package/dist/collection/components/ezp-user-menu/ezp-user-menu.css +5 -5
- package/dist/collection/components/ezp-user-menu/ezp-user-menu.js +180 -185
- package/dist/collection/services/auth.js +133 -133
- package/dist/collection/services/print.js +167 -167
- package/dist/collection/services/user.js +16 -16
- package/dist/collection/shared/global.js +7 -7
- package/dist/collection/types/shared/types.d.ts +1 -0
- package/dist/collection/utils/utils.js +89 -89
- package/dist/components/auth.js +1 -0
- package/dist/components/ezp-auth.d.ts +11 -0
- package/dist/components/ezp-auth.js +1 -0
- package/dist/components/ezp-auth2.js +1 -0
- package/dist/components/ezp-backdrop.d.ts +11 -0
- package/dist/components/ezp-backdrop.js +1 -0
- package/dist/components/ezp-backdrop2.js +1 -0
- package/dist/components/ezp-dialog.d.ts +11 -0
- package/dist/components/ezp-dialog.js +1 -0
- package/dist/components/ezp-dialog2.js +1 -0
- package/dist/components/ezp-icon-button.d.ts +11 -0
- package/dist/components/ezp-icon-button.js +1 -0
- package/dist/components/ezp-icon-button2.js +1 -0
- package/dist/components/ezp-icon.d.ts +11 -0
- package/dist/components/ezp-icon.js +1 -0
- package/dist/components/ezp-icon2.js +1 -0
- package/dist/components/ezp-input.d.ts +11 -0
- package/dist/components/ezp-input.js +1 -0
- package/dist/components/ezp-input2.js +1 -0
- package/dist/components/ezp-label.d.ts +11 -0
- package/dist/components/ezp-label.js +1 -0
- package/dist/components/ezp-label2.js +1 -0
- package/dist/components/ezp-printer-selection.d.ts +11 -0
- package/dist/components/ezp-printer-selection.js +1 -0
- package/dist/components/ezp-printer-selection2.js +1 -0
- package/dist/components/ezp-printing.d.ts +11 -0
- package/dist/components/ezp-printing.js +1 -0
- package/dist/components/ezp-select.d.ts +11 -0
- package/dist/components/ezp-select.js +1 -0
- package/dist/components/ezp-select2.js +1 -0
- package/dist/components/ezp-status.d.ts +11 -0
- package/dist/components/ezp-status.js +1 -0
- package/dist/components/ezp-status2.js +1 -0
- package/dist/components/ezp-stepper.d.ts +11 -0
- package/dist/components/ezp-stepper.js +1 -0
- package/dist/components/ezp-stepper2.js +1 -0
- package/dist/components/ezp-text-button.d.ts +11 -0
- package/dist/components/ezp-text-button.js +1 -0
- package/dist/components/ezp-text-button2.js +1 -0
- package/dist/components/ezp-upload.d.ts +11 -0
- package/dist/components/ezp-upload.js +1 -0
- package/dist/components/ezp-upload2.js +1 -0
- package/dist/components/ezp-user-menu.d.ts +11 -0
- package/dist/components/ezp-user-menu.js +1 -0
- package/dist/components/ezp-user-menu2.js +1 -0
- package/dist/components/i18next.js +1 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/directives/angular-component-lib/utils.ts +33 -14
- package/dist/directives/proxies.ts +231 -111
- package/dist/esm/app-globals-CpP67t2l.js +14 -0
- package/dist/esm/ezeep.js +41 -12
- package/dist/esm/ezp-auth_15.entry.js +27996 -26049
- package/dist/esm/index-BTfWEHH9.js +4677 -0
- package/dist/esm/loader.js +7 -15
- package/dist/esm-es5/app-globals-CpP67t2l.js +1 -0
- package/dist/esm-es5/ezeep.js +1 -1
- package/dist/esm-es5/ezp-auth_15.entry.js +2 -2
- package/dist/esm-es5/index-BTfWEHH9.js +13 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/ezeep/ezeep.esm.js +1 -1
- package/dist/ezeep/ezeep.js +16 -19
- package/dist/ezeep/p-2177b8f4.system.entry.js +7 -0
- package/dist/ezeep/p-5ok9OZMg.system.js +1 -0
- package/dist/ezeep/p-BTfWEHH9.js +2 -0
- package/dist/ezeep/p-CfQRcOh8.system.js +1 -0
- package/dist/ezeep/p-CpP67t2l.js +1 -0
- package/dist/ezeep/p-DhXN1yGM.system.js +13 -0
- package/dist/ezeep/p-de8f6583.entry.js +1 -0
- package/dist/ezeep/types/shared/types.d.ts +1 -0
- package/dist/types/components/ezp-auth/ezp-auth.d.ts +20 -20
- package/dist/types/components/ezp-backdrop/ezp-backdrop.d.ts +7 -7
- package/dist/types/components/ezp-dialog/ezp-dialog.d.ts +38 -38
- package/dist/types/components/ezp-icon/ezp-icon.d.ts +24 -24
- package/dist/types/components/ezp-icon-button/ezp-icon-button.d.ts +23 -23
- package/dist/types/components/ezp-input/ezp-input.d.ts +38 -38
- package/dist/types/components/ezp-label/ezp-label.d.ts +21 -21
- package/dist/types/components/ezp-printer-selection/ezp-printer-selection.d.ts +116 -116
- package/dist/types/components/ezp-printing/ezp-printing.d.ts +83 -83
- package/dist/types/components/ezp-select/ezp-select.d.ts +80 -80
- package/dist/types/components/ezp-status/ezp-status.d.ts +40 -40
- package/dist/types/components/ezp-stepper/ezp-stepper.d.ts +65 -65
- package/dist/types/components/ezp-text-button/ezp-text-button.d.ts +25 -25
- package/dist/types/components/ezp-upload/ezp-upload.d.ts +38 -38
- package/dist/types/components/ezp-user-menu/ezp-user-menu.d.ts +43 -43
- package/dist/types/components.d.ts +493 -50
- package/dist/types/services/auth.d.ts +27 -27
- package/dist/types/services/print.d.ts +32 -32
- package/dist/types/services/user.d.ts +4 -4
- package/dist/types/shared/types.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +335 -40
- package/dist/types/utils/utils.d.ts +6 -6
- package/loader/cdn.js +1 -2
- package/loader/index.cjs.js +1 -2
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -2
- package/loader/index.js +1 -2
- package/package.json +10 -10
- package/www/build/ezeep.esm.js +1 -1
- package/www/build/ezeep.js +16 -19
- package/www/build/p-2177b8f4.system.entry.js +7 -0
- package/www/build/p-256870db.js +1 -0
- package/www/build/p-5ok9OZMg.system.js +1 -0
- package/www/build/p-BTfWEHH9.js +2 -0
- package/www/build/p-CfQRcOh8.system.js +1 -0
- package/www/build/p-CpP67t2l.js +1 -0
- package/www/build/p-DhXN1yGM.system.js +13 -0
- package/www/build/p-de8f6583.entry.js +1 -0
- package/www/index.html +1 -1
- package/dist/cjs/app-globals-53afb196.js +0 -15
- package/dist/cjs/index-1f953145.js +0 -1482
- package/dist/custom-elements/index.d.ts +0 -129
- package/dist/custom-elements/index.js +0 -34555
- package/dist/esm/app-globals-28960cbc.js +0 -13
- package/dist/esm/index-3ac1b749.js +0 -1450
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm-es5/app-globals-28960cbc.js +0 -1
- package/dist/esm-es5/index-3ac1b749.js +0 -1
- package/dist/ezeep/p-0cc2026d.system.js +0 -1
- package/dist/ezeep/p-312f40d7.js +0 -1
- package/dist/ezeep/p-4a7d6c3a.system.entry.js +0 -7
- package/dist/ezeep/p-84bd195a.system.js +0 -1
- package/dist/ezeep/p-a4d37138.js +0 -1
- package/dist/ezeep/p-ded04529.system.js +0 -1
- package/dist/ezeep/p-e20ee337.entry.js +0 -1
- package/loader/package.json +0 -10
- package/www/build/p-0cc2026d.system.js +0 -1
- package/www/build/p-312f40d7.js +0 -1
- package/www/build/p-4a7d6c3a.system.entry.js +0 -7
- package/www/build/p-84bd195a.system.js +0 -1
- package/www/build/p-a4d37138.js +0 -1
- package/www/build/p-ded04529.system.js +0 -1
- package/www/build/p-e20ee337.entry.js +0 -1
- /package/dist/ezeep/{p-50ea2036.system.js → p-YWpyar7R.system.js} +0 -0
- /package/www/build/{p-50ea2036.system.js → p-YWpyar7R.system.js} +0 -0
|
@@ -1,190 +1,185 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import authStore from
|
|
3
|
-
import userStore from
|
|
4
|
-
import i18next from
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import authStore from "../../services/auth";
|
|
3
|
+
import userStore from "../../services/user";
|
|
4
|
+
import i18next from "i18next";
|
|
5
5
|
export class EzpUserMenu {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* Privatre methods
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
* Watchers
|
|
55
|
-
*
|
|
56
|
-
*/
|
|
57
|
-
watchOpen() {
|
|
58
|
-
if (this.open) {
|
|
59
|
-
this.backdrop.visible = true;
|
|
60
|
-
this.container.appendChild(this.backdrop);
|
|
6
|
+
constructor() {
|
|
7
|
+
this.backdrop = document.createElement('ezp-backdrop');
|
|
8
|
+
this.links = [
|
|
9
|
+
{
|
|
10
|
+
title: i18next.t('user_menu.account'),
|
|
11
|
+
icon: 'account',
|
|
12
|
+
href: 'https://app.ezeep.com',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: i18next.t('user_menu.help'),
|
|
16
|
+
icon: 'help',
|
|
17
|
+
href: 'https://support.ezeep.com',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
this.themes = ['pink', 'red', 'orange', 'green', 'teal', 'cyan', 'blue', 'violet'];
|
|
21
|
+
this.appearances = [
|
|
22
|
+
{ title: i18next.t('user_menu.system'), name: 'system' },
|
|
23
|
+
{ title: i18next.t('user_menu.light'), name: 'light' },
|
|
24
|
+
{ title: i18next.t('user_menu.dark'), name: 'dark' },
|
|
25
|
+
];
|
|
26
|
+
this.name = 'John Doe';
|
|
27
|
+
this.open = false;
|
|
28
|
+
this.handleClose = () => {
|
|
29
|
+
this.userMenuClosure.emit();
|
|
30
|
+
};
|
|
31
|
+
this.logOut = () => {
|
|
32
|
+
localStorage.removeItem('properties');
|
|
33
|
+
localStorage.removeItem('refreshToken');
|
|
34
|
+
localStorage.removeItem('access_token');
|
|
35
|
+
localStorage.removeItem('printer');
|
|
36
|
+
localStorage.removeItem('isAuthorized');
|
|
37
|
+
authStore.state.isAuthorized = false;
|
|
38
|
+
this.logoutEmitter.emit();
|
|
39
|
+
};
|
|
40
|
+
this.handleTheme = (theme) => {
|
|
41
|
+
userStore.state.theme = theme;
|
|
42
|
+
};
|
|
43
|
+
this.handleAppearance = (appearance) => {
|
|
44
|
+
userStore.state.appearance = appearance;
|
|
45
|
+
};
|
|
61
46
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* Privatre methods
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* Watchers
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
watchOpen() {
|
|
58
|
+
if (this.open) {
|
|
59
|
+
this.backdrop.visible = true;
|
|
60
|
+
this.container.appendChild(this.backdrop);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.backdrop.visible = false;
|
|
64
|
+
this.userMenuClosure.emit();
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* Render method
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
componentWillLoad() {
|
|
73
|
+
this.container = this.component.closest('[data-backdrop-surface]');
|
|
74
|
+
this.backdrop.addEventListener('backdropHideStart', () => {
|
|
75
|
+
this.open = false;
|
|
76
|
+
});
|
|
77
|
+
this.backdrop.addEventListener('backdropHideEnd', () => {
|
|
78
|
+
this.container.removeChild(this.backdrop);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* Render method
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
render() {
|
|
87
|
+
return (h(Host, { key: '0be3d9326b2fd15cbb61e5b9eae17e0e8c64fefd', class: this.open ? 'is-open' : '' }, h("div", { key: 'a9c3690514cf71adb590395dc4bc71c5a5f35fce', id: "header" }, h("ezp-label", { key: 'cac928c398257f57ace98662049caee2ed992aa6', ellipsis: true, id: "name", weight: "heavy", text: this.name }), h("ezp-icon-button", { key: '5d237bee7dc3d48120a3b042a25bf392965b56a3', id: "close", level: "tertiary", icon: "close", onClick: this.handleClose })), h("div", { key: '2edf3724b7590665fbd4baf27c14fdfe5e623537', id: "links" }, this.links.map((link) => (h("a", { class: "link", href: link.href, target: "_blank", rel: "noopener noreferrer" }, h("ezp-icon", { class: "link__icon", name: link.icon }), h("ezp-label", { text: link.title })))), h("a", { key: '363e6574e75c9cc2aeaa4707f3798e8c2c0f5fd4', class: "link", onClick: this.logOut }, h("ezp-icon", { key: 'b444802cd837572f61dabb28416931498db83f0e', class: "link__icon", name: "logout" }), h("ezp-label", { key: '02958987257786688345e0da79e10f0535b41dc0', text: i18next.t('user_menu.logout') }))), h("div", { key: 'e404081c99dd59cbd3d86a502fa24a76e459718d', id: "theme" }, h("ezp-label", { key: '3a8719b3ca0d6e078fb4add24efea9b28c8e8882', class: "caption", text: `${i18next.t('user_menu.theme')}:`, weight: "heavy" }), h("div", { key: '01c030aa8e66ba2fdfe968588e7c7dd3a6a7fe09', id: "swatches" }, this.themes.map((theme) => (h("button", { class: `swatch swatch--${theme} ${theme === userStore.state.theme ? 'selected' : ''}`, onClick: () => this.handleTheme(theme) }, h("span", { class: "dot" })))))), h("div", { key: '4a04a1ed776aed50e94394ca91aa91c85002d90f', id: "appearance" }, h("ezp-label", { key: '36427d1dea114b47dc6d6b86da80c68388c3b4c2', class: "caption", text: `${i18next.t('user_menu.appearance')}:`, weight: "heavy" }), h("div", { key: '5729ca40b8228644637106f728d90b53da6c09dc', id: "tabs" }, this.appearances.map((appearance) => (h("button", { class: `tab ${appearance.name === userStore.state.appearance ? 'selected' : ''}`, onClick: () => this.handleAppearance(appearance.name) }, h("ezp-icon", { name: appearance.name }), h("ezp-label", { text: appearance.title, level: "tertiary", weight: "strong" }))))))));
|
|
88
|
+
}
|
|
89
|
+
static get is() { return "ezp-user-menu"; }
|
|
90
|
+
static get encapsulation() { return "shadow"; }
|
|
91
|
+
static get originalStyleUrls() {
|
|
92
|
+
return {
|
|
93
|
+
"$": ["ezp-user-menu.scss"]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
static get styleUrls() {
|
|
97
|
+
return {
|
|
98
|
+
"$": ["ezp-user-menu.css"]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
static get properties() {
|
|
102
|
+
return {
|
|
103
|
+
"name": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"mutable": false,
|
|
106
|
+
"complexType": {
|
|
107
|
+
"original": "string",
|
|
108
|
+
"resolved": "string",
|
|
109
|
+
"references": {}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": false,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [],
|
|
115
|
+
"text": ""
|
|
116
|
+
},
|
|
117
|
+
"getter": false,
|
|
118
|
+
"setter": false,
|
|
119
|
+
"reflect": false,
|
|
120
|
+
"attribute": "name",
|
|
121
|
+
"defaultValue": "'John Doe'"
|
|
122
|
+
},
|
|
123
|
+
"open": {
|
|
124
|
+
"type": "boolean",
|
|
125
|
+
"mutable": true,
|
|
126
|
+
"complexType": {
|
|
127
|
+
"original": "boolean",
|
|
128
|
+
"resolved": "boolean",
|
|
129
|
+
"references": {}
|
|
130
|
+
},
|
|
131
|
+
"required": false,
|
|
132
|
+
"optional": false,
|
|
133
|
+
"docs": {
|
|
134
|
+
"tags": [],
|
|
135
|
+
"text": ""
|
|
136
|
+
},
|
|
137
|
+
"getter": false,
|
|
138
|
+
"setter": false,
|
|
139
|
+
"reflect": false,
|
|
140
|
+
"attribute": "open",
|
|
141
|
+
"defaultValue": "false"
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
static get events() {
|
|
146
|
+
return [{
|
|
147
|
+
"method": "userMenuClosure",
|
|
148
|
+
"name": "userMenuClosure",
|
|
149
|
+
"bubbles": true,
|
|
150
|
+
"cancelable": true,
|
|
151
|
+
"composed": true,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": "\nEvents"
|
|
155
|
+
},
|
|
156
|
+
"complexType": {
|
|
157
|
+
"original": "any",
|
|
158
|
+
"resolved": "any",
|
|
159
|
+
"references": {}
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
"method": "logoutEmitter",
|
|
163
|
+
"name": "logoutEmitter",
|
|
164
|
+
"bubbles": true,
|
|
165
|
+
"cancelable": true,
|
|
166
|
+
"composed": true,
|
|
167
|
+
"docs": {
|
|
168
|
+
"tags": [],
|
|
169
|
+
"text": ""
|
|
170
|
+
},
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "any",
|
|
173
|
+
"resolved": "any",
|
|
174
|
+
"references": {}
|
|
175
|
+
}
|
|
176
|
+
}];
|
|
177
|
+
}
|
|
178
|
+
static get elementRef() { return "component"; }
|
|
179
|
+
static get watchers() {
|
|
180
|
+
return [{
|
|
181
|
+
"propName": "open",
|
|
182
|
+
"methodName": "watchOpen"
|
|
183
|
+
}];
|
|
152
184
|
}
|
|
153
|
-
}; }
|
|
154
|
-
static get events() { return [{
|
|
155
|
-
"method": "userMenuClosure",
|
|
156
|
-
"name": "userMenuClosure",
|
|
157
|
-
"bubbles": true,
|
|
158
|
-
"cancelable": true,
|
|
159
|
-
"composed": true,
|
|
160
|
-
"docs": {
|
|
161
|
-
"tags": [],
|
|
162
|
-
"text": "\nEvents"
|
|
163
|
-
},
|
|
164
|
-
"complexType": {
|
|
165
|
-
"original": "any",
|
|
166
|
-
"resolved": "any",
|
|
167
|
-
"references": {}
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
"method": "logoutEmitter",
|
|
171
|
-
"name": "logoutEmitter",
|
|
172
|
-
"bubbles": true,
|
|
173
|
-
"cancelable": true,
|
|
174
|
-
"composed": true,
|
|
175
|
-
"docs": {
|
|
176
|
-
"tags": [],
|
|
177
|
-
"text": ""
|
|
178
|
-
},
|
|
179
|
-
"complexType": {
|
|
180
|
-
"original": "any",
|
|
181
|
-
"resolved": "any",
|
|
182
|
-
"references": {}
|
|
183
|
-
}
|
|
184
|
-
}]; }
|
|
185
|
-
static get elementRef() { return "component"; }
|
|
186
|
-
static get watchers() { return [{
|
|
187
|
-
"propName": "open",
|
|
188
|
-
"methodName": "watchOpen"
|
|
189
|
-
}]; }
|
|
190
185
|
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { createStore } from
|
|
2
|
-
import { encodeFormData } from
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import { encodeFormData } from "../utils/utils";
|
|
3
3
|
export class EzpAuthorizationService {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
generateCodeVerifier() {
|
|
14
|
-
if (authStore.state.codeVerifier !== '') {
|
|
15
|
-
this.codeVerifier = authStore.state.codeVerifier;
|
|
4
|
+
constructor(redirectURI, clientID) {
|
|
5
|
+
this.urlParams = new URLSearchParams();
|
|
6
|
+
this.isAuthorized = false;
|
|
7
|
+
this.redirectURI = redirectURI;
|
|
8
|
+
this.clientID = clientID;
|
|
9
|
+
this.oauthUrl = authStore.state.authApiHostUrl;
|
|
10
|
+
this.authURI = new URL(`https://${this.oauthUrl}/oauth/authorize/`);
|
|
11
|
+
this.accessTokenURL = `https://${this.oauthUrl}/oauth/access_token/`;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
generateCodeVerifier() {
|
|
14
|
+
if (authStore.state.codeVerifier !== '') {
|
|
15
|
+
this.codeVerifier = authStore.state.codeVerifier;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const arr = new Uint8Array(128);
|
|
19
|
+
const randomValueArray = crypto.getRandomValues(arr);
|
|
20
|
+
const codeVerifier = btoa(randomValueArray.toString()).substr(0, 128);
|
|
21
|
+
this.codeVerifier = codeVerifier;
|
|
22
|
+
authStore.state.codeVerifier = this.codeVerifier;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async generateCodeChallenge(codeVerifier) {
|
|
26
|
+
const encoder = new TextEncoder();
|
|
27
|
+
const codeData = encoder.encode(codeVerifier);
|
|
28
|
+
const digest = await crypto.subtle.digest('SHA-256', codeData);
|
|
29
|
+
const base64Digest = btoa(String.fromCharCode.apply(null, new Uint8Array(digest)));
|
|
30
|
+
this.codeChallenge = base64Digest.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
31
|
+
}
|
|
32
|
+
buildAuthURI() {
|
|
33
|
+
this.urlParams.append('response_type', 'code');
|
|
34
|
+
this.urlParams.append('client_id', this.clientID);
|
|
35
|
+
this.urlParams.append('redirect_uri', this.redirectURI);
|
|
36
|
+
this.urlParams.append('code_challenge', this.codeChallenge);
|
|
37
|
+
this.urlParams.append('code_challenge_method', 'S256');
|
|
38
|
+
this.authURI.search = this.urlParams.toString();
|
|
39
|
+
authStore.state.authUri = this.authURI.toString();
|
|
40
|
+
}
|
|
41
|
+
getAccessToken() {
|
|
42
|
+
return fetch(this.accessTokenURL, {
|
|
43
|
+
credentials: 'include',
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
46
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
47
|
+
},
|
|
48
|
+
method: 'POST',
|
|
49
|
+
body: encodeFormData({
|
|
50
|
+
grant_type: 'authorization_code',
|
|
51
|
+
scope: 'printing',
|
|
52
|
+
code: authStore.state.code,
|
|
53
|
+
redirect_uri: this.redirectURI,
|
|
54
|
+
code_verifier: authStore.state.codeVerifier,
|
|
55
|
+
}),
|
|
56
|
+
})
|
|
57
|
+
.then((response) => {
|
|
58
|
+
return response.json(); // parse response
|
|
59
|
+
})
|
|
60
|
+
.then((data) => {
|
|
61
|
+
// actual object
|
|
62
|
+
if (data.access_token) {
|
|
63
|
+
authStore.state.isAuthorized = true;
|
|
64
|
+
this.isAuthorized = authStore.state.isAuthorized;
|
|
65
|
+
localStorage.setItem('isAuthorized', this.isAuthorized.toString());
|
|
66
|
+
this.accessToken = data.access_token;
|
|
67
|
+
localStorage.setItem('access_token', this.accessToken);
|
|
68
|
+
authStore.state.accessToken = this.accessToken;
|
|
69
|
+
this.refreshToken = data.refresh_token;
|
|
70
|
+
localStorage.setItem('refreshToken', this.refreshToken);
|
|
71
|
+
authStore.state.refreshToken = this.refreshToken;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
refreshTokens() {
|
|
76
|
+
return fetch(this.accessTokenURL, {
|
|
77
|
+
credentials: 'include',
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
80
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
81
|
+
},
|
|
82
|
+
method: 'POST',
|
|
83
|
+
body: encodeFormData({
|
|
84
|
+
grant_type: 'refresh_token',
|
|
85
|
+
scope: 'printing',
|
|
86
|
+
refresh_token: authStore.state.refreshToken,
|
|
87
|
+
}),
|
|
88
|
+
})
|
|
89
|
+
.then((response) => response.json())
|
|
90
|
+
.then((data) => {
|
|
91
|
+
if (data.access_token) {
|
|
92
|
+
this.accessToken = data.access_token;
|
|
93
|
+
localStorage.setItem('access_token', this.accessToken);
|
|
94
|
+
authStore.state.accessToken = this.accessToken;
|
|
95
|
+
this.refreshToken = data.refresh_token;
|
|
96
|
+
localStorage.setItem('refreshToken', this.refreshToken);
|
|
97
|
+
authStore.state.refreshToken = this.refreshToken;
|
|
98
|
+
authStore.state.isAuthorized = true;
|
|
99
|
+
localStorage.setItem('isAuthorized', 'true');
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
revokeRefreshToken() {
|
|
104
|
+
if (authStore.state.refreshToken)
|
|
105
|
+
fetch(`https://${this.oauthUrl}/oauth/revoke/`, {
|
|
106
|
+
credentials: 'include',
|
|
107
|
+
headers: {
|
|
108
|
+
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
109
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
110
|
+
},
|
|
111
|
+
method: 'POST',
|
|
112
|
+
body: encodeFormData({
|
|
113
|
+
token: authStore.state.refreshToken,
|
|
114
|
+
}),
|
|
115
|
+
}).catch((error) => {
|
|
116
|
+
console.log(error);
|
|
117
|
+
});
|
|
23
118
|
}
|
|
24
|
-
}
|
|
25
|
-
async generateCodeChallenge(codeVerifier) {
|
|
26
|
-
const encoder = new TextEncoder();
|
|
27
|
-
const codeData = encoder.encode(codeVerifier);
|
|
28
|
-
const digest = await crypto.subtle.digest('SHA-256', codeData);
|
|
29
|
-
const base64Digest = btoa(String.fromCharCode.apply(null, new Uint8Array(digest)));
|
|
30
|
-
this.codeChallenge = base64Digest.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
31
|
-
}
|
|
32
|
-
buildAuthURI() {
|
|
33
|
-
this.urlParams.append('response_type', 'code');
|
|
34
|
-
this.urlParams.append('client_id', this.clientID);
|
|
35
|
-
this.urlParams.append('redirect_uri', this.redirectURI);
|
|
36
|
-
this.urlParams.append('code_challenge', this.codeChallenge);
|
|
37
|
-
this.urlParams.append('code_challenge_method', 'S256');
|
|
38
|
-
this.authURI.search = this.urlParams.toString();
|
|
39
|
-
authStore.state.authUri = this.authURI.toString();
|
|
40
|
-
}
|
|
41
|
-
getAccessToken() {
|
|
42
|
-
return fetch(this.accessTokenURL, {
|
|
43
|
-
credentials: 'include',
|
|
44
|
-
headers: {
|
|
45
|
-
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
46
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
47
|
-
},
|
|
48
|
-
method: 'POST',
|
|
49
|
-
body: encodeFormData({
|
|
50
|
-
grant_type: 'authorization_code',
|
|
51
|
-
scope: 'printing',
|
|
52
|
-
code: authStore.state.code,
|
|
53
|
-
redirect_uri: this.redirectURI,
|
|
54
|
-
code_verifier: authStore.state.codeVerifier,
|
|
55
|
-
}),
|
|
56
|
-
})
|
|
57
|
-
.then((response) => {
|
|
58
|
-
return response.json(); // parse response
|
|
59
|
-
})
|
|
60
|
-
.then((data) => {
|
|
61
|
-
// actual object
|
|
62
|
-
if (data.access_token) {
|
|
63
|
-
authStore.state.isAuthorized = true;
|
|
64
|
-
this.isAuthorized = authStore.state.isAuthorized;
|
|
65
|
-
localStorage.setItem('isAuthorized', this.isAuthorized.toString());
|
|
66
|
-
this.accessToken = data.access_token;
|
|
67
|
-
localStorage.setItem('access_token', this.accessToken);
|
|
68
|
-
authStore.state.accessToken = this.accessToken;
|
|
69
|
-
this.refreshToken = data.refresh_token;
|
|
70
|
-
localStorage.setItem('refreshToken', this.refreshToken);
|
|
71
|
-
authStore.state.refreshToken = this.refreshToken;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
refreshTokens() {
|
|
76
|
-
return fetch(this.accessTokenURL, {
|
|
77
|
-
credentials: 'include',
|
|
78
|
-
headers: {
|
|
79
|
-
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
80
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
81
|
-
},
|
|
82
|
-
method: 'POST',
|
|
83
|
-
body: encodeFormData({
|
|
84
|
-
grant_type: 'refresh_token',
|
|
85
|
-
scope: 'printing',
|
|
86
|
-
refresh_token: authStore.state.refreshToken,
|
|
87
|
-
}),
|
|
88
|
-
})
|
|
89
|
-
.then((response) => response.json())
|
|
90
|
-
.then((data) => {
|
|
91
|
-
if (data.access_token) {
|
|
92
|
-
this.accessToken = data.access_token;
|
|
93
|
-
localStorage.setItem('access_token', this.accessToken);
|
|
94
|
-
authStore.state.accessToken = this.accessToken;
|
|
95
|
-
this.refreshToken = data.refresh_token;
|
|
96
|
-
localStorage.setItem('refreshToken', this.refreshToken);
|
|
97
|
-
authStore.state.refreshToken = this.refreshToken;
|
|
98
|
-
authStore.state.isAuthorized = true;
|
|
99
|
-
localStorage.setItem('isAuthorized', 'true');
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
revokeRefreshToken() {
|
|
104
|
-
if (authStore.state.refreshToken)
|
|
105
|
-
fetch(`https://${this.oauthUrl}/oauth/revoke/`, {
|
|
106
|
-
credentials: 'include',
|
|
107
|
-
headers: {
|
|
108
|
-
Authorization: 'Basic ' + btoa(this.clientID + ':'),
|
|
109
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
110
|
-
},
|
|
111
|
-
method: 'POST',
|
|
112
|
-
body: encodeFormData({
|
|
113
|
-
token: authStore.state.refreshToken,
|
|
114
|
-
}),
|
|
115
|
-
}).catch((error) => {
|
|
116
|
-
console.log(error);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
119
|
}
|
|
120
120
|
const authStore = createStore({
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
code: '',
|
|
122
|
+
codeVerifier: '',
|
|
123
|
+
accessToken: '',
|
|
124
|
+
refreshToken: '',
|
|
125
|
+
isAuthorized: false,
|
|
126
|
+
devApi: false,
|
|
127
|
+
authApiHostUrl: '',
|
|
128
|
+
redirectUri: '',
|
|
129
|
+
authUri: '',
|
|
130
130
|
});
|
|
131
131
|
export default authStore;
|
|
132
132
|
export function sendCodeToParentWindow() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
133
|
+
// get the URL parameters which will include the auth code
|
|
134
|
+
const params = new URLSearchParams(window.location.search);
|
|
135
|
+
const code = params.get('code');
|
|
136
|
+
if (window.opener) {
|
|
137
|
+
if (code) {
|
|
138
|
+
// send them to the opening window
|
|
139
|
+
window.opener.postMessage(code, authStore.state.redirectUri);
|
|
140
|
+
window.close();
|
|
141
|
+
}
|
|
141
142
|
}
|
|
142
|
-
}
|
|
143
143
|
}
|