@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.
Files changed (170) hide show
  1. package/dist/cjs/app-globals-D7ISNeUi.js +16 -0
  2. package/dist/cjs/ezeep.cjs.js +43 -12
  3. package/dist/cjs/ezp-auth_15.cjs.entry.js +27992 -26047
  4. package/dist/cjs/index-dv_gozsq.js +4694 -0
  5. package/dist/cjs/loader.cjs.js +7 -17
  6. package/dist/collection/collection-manifest.json +19 -18
  7. package/dist/collection/components/ezp-auth/ezp-auth.js +266 -245
  8. package/dist/collection/components/ezp-backdrop/ezp-backdrop.js +93 -81
  9. package/dist/collection/components/ezp-dialog/ezp-dialog.js +226 -210
  10. package/dist/collection/components/ezp-icon/ezp-icon.js +117 -102
  11. package/dist/collection/components/ezp-icon-button/ezp-icon-button.js +181 -159
  12. package/dist/collection/components/ezp-input/ezp-input.css +5 -5
  13. package/dist/collection/components/ezp-input/ezp-input.js +227 -205
  14. package/dist/collection/components/ezp-label/ezp-label.css +5 -5
  15. package/dist/collection/components/ezp-label/ezp-label.js +151 -132
  16. package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.css +5 -5
  17. package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.js +1134 -1107
  18. package/dist/collection/components/ezp-printing/ezp-printing.css +183 -125
  19. package/dist/collection/components/ezp-printing/ezp-printing.js +872 -807
  20. package/dist/collection/components/ezp-select/ezp-select.css +4 -4
  21. package/dist/collection/components/ezp-select/ezp-select.js +376 -351
  22. package/dist/collection/components/ezp-status/ezp-status.css +5 -5
  23. package/dist/collection/components/ezp-status/ezp-status.js +238 -223
  24. package/dist/collection/components/ezp-stepper/ezp-stepper.css +5 -5
  25. package/dist/collection/components/ezp-stepper/ezp-stepper.js +256 -243
  26. package/dist/collection/components/ezp-text-button/ezp-text-button.js +196 -174
  27. package/dist/collection/components/ezp-upload/ezp-upload.js +134 -141
  28. package/dist/collection/components/ezp-user-menu/ezp-user-menu.css +5 -5
  29. package/dist/collection/components/ezp-user-menu/ezp-user-menu.js +180 -185
  30. package/dist/collection/services/auth.js +133 -133
  31. package/dist/collection/services/print.js +167 -167
  32. package/dist/collection/services/user.js +16 -16
  33. package/dist/collection/shared/global.js +7 -7
  34. package/dist/collection/types/shared/types.d.ts +1 -0
  35. package/dist/collection/utils/utils.js +89 -89
  36. package/dist/components/auth.js +1 -0
  37. package/dist/components/ezp-auth.d.ts +11 -0
  38. package/dist/components/ezp-auth.js +1 -0
  39. package/dist/components/ezp-auth2.js +1 -0
  40. package/dist/components/ezp-backdrop.d.ts +11 -0
  41. package/dist/components/ezp-backdrop.js +1 -0
  42. package/dist/components/ezp-backdrop2.js +1 -0
  43. package/dist/components/ezp-dialog.d.ts +11 -0
  44. package/dist/components/ezp-dialog.js +1 -0
  45. package/dist/components/ezp-dialog2.js +1 -0
  46. package/dist/components/ezp-icon-button.d.ts +11 -0
  47. package/dist/components/ezp-icon-button.js +1 -0
  48. package/dist/components/ezp-icon-button2.js +1 -0
  49. package/dist/components/ezp-icon.d.ts +11 -0
  50. package/dist/components/ezp-icon.js +1 -0
  51. package/dist/components/ezp-icon2.js +1 -0
  52. package/dist/components/ezp-input.d.ts +11 -0
  53. package/dist/components/ezp-input.js +1 -0
  54. package/dist/components/ezp-input2.js +1 -0
  55. package/dist/components/ezp-label.d.ts +11 -0
  56. package/dist/components/ezp-label.js +1 -0
  57. package/dist/components/ezp-label2.js +1 -0
  58. package/dist/components/ezp-printer-selection.d.ts +11 -0
  59. package/dist/components/ezp-printer-selection.js +1 -0
  60. package/dist/components/ezp-printer-selection2.js +1 -0
  61. package/dist/components/ezp-printing.d.ts +11 -0
  62. package/dist/components/ezp-printing.js +1 -0
  63. package/dist/components/ezp-select.d.ts +11 -0
  64. package/dist/components/ezp-select.js +1 -0
  65. package/dist/components/ezp-select2.js +1 -0
  66. package/dist/components/ezp-status.d.ts +11 -0
  67. package/dist/components/ezp-status.js +1 -0
  68. package/dist/components/ezp-status2.js +1 -0
  69. package/dist/components/ezp-stepper.d.ts +11 -0
  70. package/dist/components/ezp-stepper.js +1 -0
  71. package/dist/components/ezp-stepper2.js +1 -0
  72. package/dist/components/ezp-text-button.d.ts +11 -0
  73. package/dist/components/ezp-text-button.js +1 -0
  74. package/dist/components/ezp-text-button2.js +1 -0
  75. package/dist/components/ezp-upload.d.ts +11 -0
  76. package/dist/components/ezp-upload.js +1 -0
  77. package/dist/components/ezp-upload2.js +1 -0
  78. package/dist/components/ezp-user-menu.d.ts +11 -0
  79. package/dist/components/ezp-user-menu.js +1 -0
  80. package/dist/components/ezp-user-menu2.js +1 -0
  81. package/dist/components/i18next.js +1 -0
  82. package/dist/components/index.d.ts +35 -0
  83. package/dist/components/index.js +1 -0
  84. package/dist/directives/angular-component-lib/utils.ts +33 -14
  85. package/dist/directives/proxies.ts +231 -111
  86. package/dist/esm/app-globals-CpP67t2l.js +14 -0
  87. package/dist/esm/ezeep.js +41 -12
  88. package/dist/esm/ezp-auth_15.entry.js +27996 -26049
  89. package/dist/esm/index-BTfWEHH9.js +4677 -0
  90. package/dist/esm/loader.js +7 -15
  91. package/dist/esm-es5/app-globals-CpP67t2l.js +1 -0
  92. package/dist/esm-es5/ezeep.js +1 -1
  93. package/dist/esm-es5/ezp-auth_15.entry.js +2 -2
  94. package/dist/esm-es5/index-BTfWEHH9.js +13 -0
  95. package/dist/esm-es5/loader.js +1 -1
  96. package/dist/ezeep/ezeep.esm.js +1 -1
  97. package/dist/ezeep/ezeep.js +16 -19
  98. package/dist/ezeep/p-2177b8f4.system.entry.js +7 -0
  99. package/dist/ezeep/p-5ok9OZMg.system.js +1 -0
  100. package/dist/ezeep/p-BTfWEHH9.js +2 -0
  101. package/dist/ezeep/p-CfQRcOh8.system.js +1 -0
  102. package/dist/ezeep/p-CpP67t2l.js +1 -0
  103. package/dist/ezeep/p-DhXN1yGM.system.js +13 -0
  104. package/dist/ezeep/p-de8f6583.entry.js +1 -0
  105. package/dist/ezeep/types/shared/types.d.ts +1 -0
  106. package/dist/types/components/ezp-auth/ezp-auth.d.ts +20 -20
  107. package/dist/types/components/ezp-backdrop/ezp-backdrop.d.ts +7 -7
  108. package/dist/types/components/ezp-dialog/ezp-dialog.d.ts +38 -38
  109. package/dist/types/components/ezp-icon/ezp-icon.d.ts +24 -24
  110. package/dist/types/components/ezp-icon-button/ezp-icon-button.d.ts +23 -23
  111. package/dist/types/components/ezp-input/ezp-input.d.ts +38 -38
  112. package/dist/types/components/ezp-label/ezp-label.d.ts +21 -21
  113. package/dist/types/components/ezp-printer-selection/ezp-printer-selection.d.ts +116 -116
  114. package/dist/types/components/ezp-printing/ezp-printing.d.ts +83 -83
  115. package/dist/types/components/ezp-select/ezp-select.d.ts +80 -80
  116. package/dist/types/components/ezp-status/ezp-status.d.ts +40 -40
  117. package/dist/types/components/ezp-stepper/ezp-stepper.d.ts +65 -65
  118. package/dist/types/components/ezp-text-button/ezp-text-button.d.ts +25 -25
  119. package/dist/types/components/ezp-upload/ezp-upload.d.ts +38 -38
  120. package/dist/types/components/ezp-user-menu/ezp-user-menu.d.ts +43 -43
  121. package/dist/types/components.d.ts +493 -50
  122. package/dist/types/services/auth.d.ts +27 -27
  123. package/dist/types/services/print.d.ts +32 -32
  124. package/dist/types/services/user.d.ts +4 -4
  125. package/dist/types/shared/types.d.ts +1 -0
  126. package/dist/types/stencil-public-runtime.d.ts +335 -40
  127. package/dist/types/utils/utils.d.ts +6 -6
  128. package/loader/cdn.js +1 -2
  129. package/loader/index.cjs.js +1 -2
  130. package/loader/index.d.ts +13 -1
  131. package/loader/index.es2017.js +1 -2
  132. package/loader/index.js +1 -2
  133. package/package.json +10 -10
  134. package/www/build/ezeep.esm.js +1 -1
  135. package/www/build/ezeep.js +16 -19
  136. package/www/build/p-2177b8f4.system.entry.js +7 -0
  137. package/www/build/p-256870db.js +1 -0
  138. package/www/build/p-5ok9OZMg.system.js +1 -0
  139. package/www/build/p-BTfWEHH9.js +2 -0
  140. package/www/build/p-CfQRcOh8.system.js +1 -0
  141. package/www/build/p-CpP67t2l.js +1 -0
  142. package/www/build/p-DhXN1yGM.system.js +13 -0
  143. package/www/build/p-de8f6583.entry.js +1 -0
  144. package/www/index.html +1 -1
  145. package/dist/cjs/app-globals-53afb196.js +0 -15
  146. package/dist/cjs/index-1f953145.js +0 -1482
  147. package/dist/custom-elements/index.d.ts +0 -129
  148. package/dist/custom-elements/index.js +0 -34555
  149. package/dist/esm/app-globals-28960cbc.js +0 -13
  150. package/dist/esm/index-3ac1b749.js +0 -1450
  151. package/dist/esm/polyfills/css-shim.js +0 -1
  152. package/dist/esm-es5/app-globals-28960cbc.js +0 -1
  153. package/dist/esm-es5/index-3ac1b749.js +0 -1
  154. package/dist/ezeep/p-0cc2026d.system.js +0 -1
  155. package/dist/ezeep/p-312f40d7.js +0 -1
  156. package/dist/ezeep/p-4a7d6c3a.system.entry.js +0 -7
  157. package/dist/ezeep/p-84bd195a.system.js +0 -1
  158. package/dist/ezeep/p-a4d37138.js +0 -1
  159. package/dist/ezeep/p-ded04529.system.js +0 -1
  160. package/dist/ezeep/p-e20ee337.entry.js +0 -1
  161. package/loader/package.json +0 -10
  162. package/www/build/p-0cc2026d.system.js +0 -1
  163. package/www/build/p-312f40d7.js +0 -1
  164. package/www/build/p-4a7d6c3a.system.entry.js +0 -7
  165. package/www/build/p-84bd195a.system.js +0 -1
  166. package/www/build/p-a4d37138.js +0 -1
  167. package/www/build/p-ded04529.system.js +0 -1
  168. package/www/build/p-e20ee337.entry.js +0 -1
  169. /package/dist/ezeep/{p-50ea2036.system.js → p-YWpyar7R.system.js} +0 -0
  170. /package/www/build/{p-50ea2036.system.js → p-YWpyar7R.system.js} +0 -0
@@ -1,190 +1,185 @@
1
- import { Component, Host, Prop, Event, Element, Watch, h } from '@stencil/core';
2
- import authStore from '../../services/auth';
3
- import userStore from '../../services/user';
4
- import i18next from 'i18next';
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
- 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
- };
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
- else {
63
- this.backdrop.visible = false;
64
- this.userMenuClosure.emit();
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
- * 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, { class: this.open ? 'is-open' : '' },
88
- h("div", { id: "header" },
89
- h("ezp-label", { ellipsis: true, id: "name", weight: "heavy", text: this.name }),
90
- h("ezp-icon-button", { id: "close", level: "tertiary", icon: "close", onClick: this.handleClose })),
91
- h("div", { id: "links" },
92
- this.links.map((link) => (h("a", { class: "link", href: link.href, target: "_blank", rel: "noopener noreferrer" },
93
- h("ezp-icon", { class: "link__icon", name: link.icon }),
94
- h("ezp-label", { text: link.title })))),
95
- h("a", { class: "link", onClick: this.logOut },
96
- h("ezp-icon", { class: "link__icon", name: "logout" }),
97
- h("ezp-label", { text: i18next.t('user_menu.logout') }))),
98
- h("div", { id: "theme" },
99
- h("ezp-label", { class: "caption", text: `${i18next.t('user_menu.theme')}:`, weight: "heavy" }),
100
- h("div", { id: "swatches" }, this.themes.map((theme) => (h("button", { class: `swatch swatch--${theme} ${theme === userStore.state.theme ? 'selected' : ''}`, onClick: () => this.handleTheme(theme) },
101
- h("span", { class: "dot" })))))),
102
- h("div", { id: "appearance" },
103
- h("ezp-label", { class: "caption", text: `${i18next.t('user_menu.appearance')}:`, weight: "heavy" }),
104
- h("div", { id: "tabs" }, this.appearances.map((appearance) => (h("button", { class: `tab ${appearance.name === userStore.state.appearance ? 'selected' : ''}`, onClick: () => this.handleAppearance(appearance.name) },
105
- h("ezp-icon", { name: appearance.name }),
106
- h("ezp-label", { text: appearance.title, level: "tertiary", weight: "strong" }))))))));
107
- }
108
- static get is() { return "ezp-user-menu"; }
109
- static get encapsulation() { return "shadow"; }
110
- static get originalStyleUrls() { return {
111
- "$": ["ezp-user-menu.scss"]
112
- }; }
113
- static get styleUrls() { return {
114
- "$": ["ezp-user-menu.css"]
115
- }; }
116
- static get properties() { return {
117
- "name": {
118
- "type": "string",
119
- "mutable": false,
120
- "complexType": {
121
- "original": "string",
122
- "resolved": "string",
123
- "references": {}
124
- },
125
- "required": false,
126
- "optional": false,
127
- "docs": {
128
- "tags": [],
129
- "text": ""
130
- },
131
- "attribute": "name",
132
- "reflect": false,
133
- "defaultValue": "'John Doe'"
134
- },
135
- "open": {
136
- "type": "boolean",
137
- "mutable": true,
138
- "complexType": {
139
- "original": "boolean",
140
- "resolved": "boolean",
141
- "references": {}
142
- },
143
- "required": false,
144
- "optional": false,
145
- "docs": {
146
- "tags": [],
147
- "text": ""
148
- },
149
- "attribute": "open",
150
- "reflect": false,
151
- "defaultValue": "false"
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 '@stencil/store';
2
- import { encodeFormData } from '../utils/utils';
1
+ import { createStore } from "@stencil/store";
2
+ import { encodeFormData } from "../utils/utils";
3
3
  export class EzpAuthorizationService {
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/`;
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
- 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;
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
- code: '',
122
- codeVerifier: '',
123
- accessToken: '',
124
- refreshToken: '',
125
- isAuthorized: false,
126
- devApi: false,
127
- authApiHostUrl: '',
128
- redirectUri: '',
129
- authUri: '',
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
- // 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();
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
  }