@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,178 +1,178 @@
|
|
|
1
|
-
import { createStore } from
|
|
2
|
-
import authStore, { EzpAuthorizationService } from
|
|
3
|
-
import fetchIntercept from
|
|
4
|
-
import { AnonymousCredential, BlockBlobClient, newPipeline } from
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import authStore, { EzpAuthorizationService } from "./auth";
|
|
3
|
+
import fetchIntercept from "fetch-intercept";
|
|
4
|
+
import { AnonymousCredential, BlockBlobClient, newPipeline } from "@azure/storage-blob";
|
|
5
5
|
export class EzpPrintService {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
checkStoredRefreshToken() {
|
|
21
|
-
if (authStore.state.refreshToken !== '') {
|
|
22
|
-
return;
|
|
6
|
+
constructor(redirectURI, clientID) {
|
|
7
|
+
this.abortController = null;
|
|
8
|
+
this.getPrintStatus = () => {
|
|
9
|
+
return fetch(`https://${this.printingApi}/sfapi/Status/?id=${encodeURIComponent(printStore.state.jobID)}`, {
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: 'Bearer ' + authStore.state.accessToken,
|
|
12
|
+
},
|
|
13
|
+
}).then((response) => response.json());
|
|
14
|
+
};
|
|
15
|
+
this.redirectURI = redirectURI;
|
|
16
|
+
this.clientID = clientID;
|
|
17
|
+
this.printingApi = printStore.state.printApiHostUrl;
|
|
18
|
+
this.checkStoredRefreshToken();
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
checkStoredRefreshToken() {
|
|
21
|
+
if (authStore.state.refreshToken !== '') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (localStorage.getItem('refreshToken') === null) {
|
|
25
|
+
authStore.state.refreshToken = '';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
authStore.state.refreshToken = localStorage.getItem('refreshToken');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
registerFetchInterceptor() {
|
|
32
|
+
fetchIntercept.register({
|
|
33
|
+
request: (url, config) => {
|
|
34
|
+
// Modify the url or config here
|
|
35
|
+
return [url, config];
|
|
36
|
+
},
|
|
37
|
+
requestError: (error) => {
|
|
38
|
+
// Called when an error occured during another 'request' interceptor call
|
|
39
|
+
return Promise.reject(error);
|
|
40
|
+
},
|
|
41
|
+
// check for response status here
|
|
42
|
+
response: (response) => {
|
|
43
|
+
if (response.status === 401) {
|
|
44
|
+
if (authStore.state.refreshToken === '') {
|
|
45
|
+
return response;
|
|
46
|
+
}
|
|
47
|
+
const authService = new EzpAuthorizationService(this.redirectURI, this.clientID);
|
|
48
|
+
authService.refreshTokens();
|
|
49
|
+
}
|
|
50
|
+
// Modify the reponse object
|
|
51
|
+
return response;
|
|
52
|
+
},
|
|
53
|
+
responseError: (error) => {
|
|
54
|
+
// Handle a fetch error
|
|
55
|
+
return Promise.reject(error);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getPrinterList(accessToken) {
|
|
60
|
+
return fetch(`https://${this.printingApi}/sfapi/GetPrinter/`, {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: 'Bearer ' + accessToken,
|
|
64
|
+
},
|
|
65
|
+
}).then((response) => response.json());
|
|
66
|
+
}
|
|
67
|
+
async getConfig(accessToken) {
|
|
68
|
+
return fetch(`https://${this.printingApi}/sfapi/GetConfiguration/`, {
|
|
69
|
+
method: 'GET',
|
|
70
|
+
headers: {
|
|
71
|
+
Authorization: 'Bearer ' + accessToken,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
26
74
|
}
|
|
27
|
-
|
|
28
|
-
|
|
75
|
+
getPrinterProperties(accessToken, printerID) {
|
|
76
|
+
return fetch(`https://${this.printingApi}/sfapi/GetPrinterProperties/?id=${printerID}`, {
|
|
77
|
+
method: 'GET',
|
|
78
|
+
headers: {
|
|
79
|
+
Authorization: 'Bearer ' + accessToken,
|
|
80
|
+
},
|
|
81
|
+
}).then((response) => {
|
|
82
|
+
return response.json();
|
|
83
|
+
});
|
|
29
84
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
85
|
+
getAllPrinterProperties(accessToken) {
|
|
86
|
+
return fetch(`https://${this.printingApi}/sfapi/GetPrinterProperties/`, {
|
|
87
|
+
method: 'GET',
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: 'Bearer ' + accessToken,
|
|
90
|
+
},
|
|
91
|
+
}).then((response) => {
|
|
92
|
+
return response.json();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
printFileByUrl(accessToken, fileUrl, fileType, printerID, properties, filename, printAndDelete) {
|
|
96
|
+
this.abortController = new AbortController();
|
|
97
|
+
return fetch(`https://${this.printingApi}/sfapi/Print/`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: 'Bearer ' + accessToken,
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
},
|
|
103
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign({ fileurl: fileUrl, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties })),
|
|
104
|
+
signal: this.abortController.signal
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
abortPrint() {
|
|
108
|
+
if (this.abortController) {
|
|
109
|
+
this.abortController.abort();
|
|
110
|
+
this.abortController = null;
|
|
49
111
|
}
|
|
50
|
-
|
|
112
|
+
}
|
|
113
|
+
printByFileID(accessToken, fileID, fileType, printerID, properties, filename, printAndDelete) {
|
|
114
|
+
return fetch(`https://${this.printingApi}/sfapi/Print/`, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers: {
|
|
117
|
+
Authorization: 'Bearer ' + accessToken,
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
},
|
|
120
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign({ fileid: fileID, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties })),
|
|
121
|
+
}).then((response) => response.json());
|
|
122
|
+
}
|
|
123
|
+
prepareFileUpload(accessToken) {
|
|
124
|
+
return fetch(`https://${this.printingApi}/sfapi/PrepareUpload/`, {
|
|
125
|
+
method: 'GET',
|
|
126
|
+
headers: {
|
|
127
|
+
Authorization: 'Bearer ' + accessToken,
|
|
128
|
+
},
|
|
129
|
+
}).then((response) => response.json());
|
|
130
|
+
}
|
|
131
|
+
uploadFile(sasURI, formData) {
|
|
132
|
+
return fetch(`${sasURI}`, {
|
|
133
|
+
method: 'PUT',
|
|
134
|
+
headers: {
|
|
135
|
+
'x-ms-blob-type': 'BlockBlob',
|
|
136
|
+
'Content-Type:': 'multipart/form-data', // try and not set it, see if it does it automatically
|
|
137
|
+
},
|
|
138
|
+
body: formData,
|
|
139
|
+
}).then((response) => response.json());
|
|
140
|
+
}
|
|
141
|
+
async uploadBlobFiles(sasUri, file) {
|
|
142
|
+
printStore.state.uploadProgress = 0;
|
|
143
|
+
const pipeline = newPipeline(new AnonymousCredential(), {
|
|
144
|
+
retryOptions: { maxTries: 4 },
|
|
145
|
+
userAgentOptions: { userAgentPrefix: 'AdvancedSample V1.0.0' }, // Customized telemetry string
|
|
146
|
+
keepAliveOptions: {
|
|
147
|
+
// Keep alive is enabled by default, disable keep alive by setting false
|
|
148
|
+
enable: false,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
const client = new BlockBlobClient(sasUri, pipeline);
|
|
152
|
+
const response = await client.uploadData(file, {
|
|
153
|
+
blockSize: 4 * 1024 * 1024, //4mb blocksize
|
|
154
|
+
concurrency: 20,
|
|
155
|
+
onProgress: (e) => {
|
|
156
|
+
let progress = (100 * e.loadedBytes) / file.size;
|
|
157
|
+
printStore.state.uploadProgress = progress;
|
|
158
|
+
},
|
|
159
|
+
blobHTTPHeaders: { blobContentType: 'application/octet-stream' },
|
|
160
|
+
});
|
|
51
161
|
return response;
|
|
52
|
-
},
|
|
53
|
-
responseError: (error) => {
|
|
54
|
-
// Handle a fetch error
|
|
55
|
-
return Promise.reject(error);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
getPrinterList(accessToken) {
|
|
60
|
-
return fetch(`https://${this.printingApi}/sfapi/GetPrinter/`, {
|
|
61
|
-
method: 'GET',
|
|
62
|
-
headers: {
|
|
63
|
-
Authorization: 'Bearer ' + accessToken,
|
|
64
|
-
},
|
|
65
|
-
}).then((response) => response.json());
|
|
66
|
-
}
|
|
67
|
-
async getConfig(accessToken) {
|
|
68
|
-
return fetch(`https://${this.printingApi}/sfapi/GetConfiguration/`, {
|
|
69
|
-
method: 'GET',
|
|
70
|
-
headers: {
|
|
71
|
-
Authorization: 'Bearer ' + accessToken,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
getPrinterProperties(accessToken, printerID) {
|
|
76
|
-
return fetch(`https://${this.printingApi}/sfapi/GetPrinterProperties/?id=${printerID}`, {
|
|
77
|
-
method: 'GET',
|
|
78
|
-
headers: {
|
|
79
|
-
Authorization: 'Bearer ' + accessToken,
|
|
80
|
-
},
|
|
81
|
-
}).then((response) => {
|
|
82
|
-
return response.json();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
getAllPrinterProperties(accessToken) {
|
|
86
|
-
return fetch(`https://${this.printingApi}/sfapi/GetPrinterProperties/`, {
|
|
87
|
-
method: 'GET',
|
|
88
|
-
headers: {
|
|
89
|
-
Authorization: 'Bearer ' + accessToken,
|
|
90
|
-
},
|
|
91
|
-
}).then((response) => {
|
|
92
|
-
return response.json();
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
printFileByUrl(accessToken, fileUrl, fileType, printerID, properties, filename, printAndDelete) {
|
|
96
|
-
this.abortController = new AbortController();
|
|
97
|
-
return fetch(`https://${this.printingApi}/sfapi/Print/`, {
|
|
98
|
-
method: 'POST',
|
|
99
|
-
headers: {
|
|
100
|
-
Authorization: 'Bearer ' + accessToken,
|
|
101
|
-
'Content-Type': 'application/json',
|
|
102
|
-
},
|
|
103
|
-
body: JSON.stringify(Object.assign(Object.assign(Object.assign({ fileurl: fileUrl, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties })),
|
|
104
|
-
signal: this.abortController.signal
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
abortPrint() {
|
|
108
|
-
if (this.abortController) {
|
|
109
|
-
this.abortController.abort();
|
|
110
|
-
this.abortController = null;
|
|
111
162
|
}
|
|
112
|
-
}
|
|
113
|
-
printByFileID(accessToken, fileID, fileType, printerID, properties, filename, printAndDelete) {
|
|
114
|
-
return fetch(`https://${this.printingApi}/sfapi/Print/`, {
|
|
115
|
-
method: 'POST',
|
|
116
|
-
headers: {
|
|
117
|
-
Authorization: 'Bearer ' + accessToken,
|
|
118
|
-
'Content-Type': 'application/json',
|
|
119
|
-
},
|
|
120
|
-
body: JSON.stringify(Object.assign(Object.assign(Object.assign({ fileid: fileID, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties })),
|
|
121
|
-
}).then((response) => response.json());
|
|
122
|
-
}
|
|
123
|
-
prepareFileUpload(accessToken) {
|
|
124
|
-
return fetch(`https://${this.printingApi}/sfapi/PrepareUpload/`, {
|
|
125
|
-
method: 'GET',
|
|
126
|
-
headers: {
|
|
127
|
-
Authorization: 'Bearer ' + accessToken,
|
|
128
|
-
},
|
|
129
|
-
}).then((response) => response.json());
|
|
130
|
-
}
|
|
131
|
-
uploadFile(sasURI, formData) {
|
|
132
|
-
return fetch(`${sasURI}`, {
|
|
133
|
-
method: 'PUT',
|
|
134
|
-
headers: {
|
|
135
|
-
'x-ms-blob-type': 'BlockBlob',
|
|
136
|
-
'Content-Type:': 'multipart/form-data', // try and not set it, see if it does it automatically
|
|
137
|
-
},
|
|
138
|
-
body: formData,
|
|
139
|
-
}).then((response) => response.json());
|
|
140
|
-
}
|
|
141
|
-
async uploadBlobFiles(sasUri, file) {
|
|
142
|
-
printStore.state.uploadProgress = 0;
|
|
143
|
-
const pipeline = newPipeline(new AnonymousCredential(), {
|
|
144
|
-
retryOptions: { maxTries: 4 },
|
|
145
|
-
userAgentOptions: { userAgentPrefix: 'AdvancedSample V1.0.0' },
|
|
146
|
-
keepAliveOptions: {
|
|
147
|
-
// Keep alive is enabled by default, disable keep alive by setting false
|
|
148
|
-
enable: false,
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
const client = new BlockBlobClient(sasUri, pipeline);
|
|
152
|
-
const response = await client.uploadData(file, {
|
|
153
|
-
blockSize: 4 * 1024 * 1024,
|
|
154
|
-
concurrency: 20,
|
|
155
|
-
onProgress: (e) => {
|
|
156
|
-
let progress = (100 * e.loadedBytes) / file.size;
|
|
157
|
-
printStore.state.uploadProgress = progress;
|
|
158
|
-
},
|
|
159
|
-
blobHTTPHeaders: { blobContentType: 'application/octet-stream' },
|
|
160
|
-
});
|
|
161
|
-
return response;
|
|
162
|
-
}
|
|
163
163
|
}
|
|
164
164
|
const printStore = createStore({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
165
|
+
printers: [],
|
|
166
|
+
jobID: '',
|
|
167
|
+
printFinished: false,
|
|
168
|
+
printApiHostUrl: '',
|
|
169
|
+
printerProperties: {},
|
|
170
|
+
fileID: '',
|
|
171
|
+
fileUrl: '',
|
|
172
|
+
fileType: '',
|
|
173
|
+
printerID: '',
|
|
174
|
+
fileName: '',
|
|
175
|
+
uploadProgress: 0,
|
|
176
|
+
supportedFileExtensions: '',
|
|
177
177
|
});
|
|
178
178
|
export default printStore;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { createStore } from
|
|
2
|
-
import authStore from
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
import authStore from "./auth";
|
|
3
3
|
export class EzpUserService {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
getUserInfo() {
|
|
5
|
+
return fetch(`https://${authStore.state.authApiHostUrl}/v1/users/me`, {
|
|
6
|
+
headers: {
|
|
7
|
+
Authorization: 'Bearer ' + authStore.state.accessToken,
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
},
|
|
10
|
+
method: 'GET',
|
|
11
|
+
}).then((response) => {
|
|
12
|
+
return response.json();
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
15
|
}
|
|
16
16
|
const userStore = createStore({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
user: null,
|
|
18
|
+
theme: '',
|
|
19
|
+
appearance: '',
|
|
20
20
|
});
|
|
21
21
|
export default userStore;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default async () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const font = new FontFace('Inter', 'url(https://rsms.me/inter/font-files/Inter-roman.var.woff2)', {
|
|
3
|
+
style: 'normal',
|
|
4
|
+
weight: '400 600',
|
|
5
|
+
});
|
|
6
|
+
font.load().then(() => {
|
|
7
|
+
document.fonts.add(font);
|
|
8
|
+
});
|
|
9
9
|
};
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import i18next from
|
|
2
|
-
import translationsDE from
|
|
3
|
-
import translationsEN from
|
|
1
|
+
import i18next from "i18next";
|
|
2
|
+
import translationsDE from "../data/locales/de.json";
|
|
3
|
+
import translationsEN from "../data/locales/en.json";
|
|
4
4
|
export function encodeFormData(data) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
return Object.keys(data)
|
|
6
|
+
.map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
|
|
7
|
+
.join('&');
|
|
8
8
|
}
|
|
9
9
|
export function capitalize(string) {
|
|
10
|
-
|
|
10
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
11
11
|
}
|
|
12
12
|
export function initi18n(language) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
i18next.init({
|
|
33
|
-
resources,
|
|
34
|
-
lng: navigator.language,
|
|
35
|
-
// allow keys to be phrases having `:`, `.`
|
|
36
|
-
nsSeparator: false,
|
|
37
|
-
fallbackLng: 'en',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export const poll = async ({ fn, validate, interval, maxAttempts }) => {
|
|
42
|
-
let attempts = 0;
|
|
43
|
-
const executePoll = async (resolve, reject) => {
|
|
44
|
-
const result = await fn();
|
|
45
|
-
attempts++;
|
|
46
|
-
if (validate(result)) {
|
|
47
|
-
return resolve(result);
|
|
48
|
-
}
|
|
49
|
-
else if (maxAttempts && attempts === maxAttempts) {
|
|
50
|
-
return reject(new Error('Exceeded max attempts.'));
|
|
13
|
+
const resources = {
|
|
14
|
+
en: {
|
|
15
|
+
translation: translationsEN,
|
|
16
|
+
},
|
|
17
|
+
de: {
|
|
18
|
+
translation: translationsDE,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
// override browserlanguage if language is provided
|
|
22
|
+
if (language != '') {
|
|
23
|
+
i18next.init({
|
|
24
|
+
resources,
|
|
25
|
+
lng: language,
|
|
26
|
+
// allow keys to be phrases having `:`, `.`
|
|
27
|
+
nsSeparator: false,
|
|
28
|
+
fallbackLng: 'en',
|
|
29
|
+
});
|
|
51
30
|
}
|
|
52
31
|
else {
|
|
53
|
-
|
|
32
|
+
i18next.init({
|
|
33
|
+
resources,
|
|
34
|
+
lng: navigator.language,
|
|
35
|
+
// allow keys to be phrases having `:`, `.`
|
|
36
|
+
nsSeparator: false,
|
|
37
|
+
fallbackLng: 'en',
|
|
38
|
+
});
|
|
54
39
|
}
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
}
|
|
41
|
+
export const poll = async ({ fn, validate, interval, maxAttempts }) => {
|
|
42
|
+
let attempts = 0;
|
|
43
|
+
const executePoll = async (resolve, reject) => {
|
|
44
|
+
const result = await fn();
|
|
45
|
+
attempts++;
|
|
46
|
+
if (validate(result)) {
|
|
47
|
+
return resolve(result);
|
|
48
|
+
}
|
|
49
|
+
else if (maxAttempts && attempts === maxAttempts) {
|
|
50
|
+
return reject(new Error('Exceeded max attempts.'));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setTimeout(executePoll, interval, resolve, reject);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return new Promise(executePoll);
|
|
57
57
|
};
|
|
58
58
|
export const removeEmptyStrings = (obj) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
let newObj = {};
|
|
60
|
+
Object.keys(obj).forEach((prop) => {
|
|
61
|
+
if (obj[prop] !== '') {
|
|
62
|
+
newObj[prop] = obj[prop];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return newObj;
|
|
66
66
|
};
|
|
67
67
|
export const managePaperDimensions = (properties) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
if (properties.paperid != PAPER_ID) {
|
|
69
|
+
delete properties.paperlength;
|
|
70
|
+
delete properties.paperwidth;
|
|
71
|
+
}
|
|
72
|
+
if (properties.paperlength && properties.paperwidth) {
|
|
73
|
+
properties.paperlength = +properties.paperlength * 10;
|
|
74
|
+
properties.paperwidth = +properties.paperwidth * 10;
|
|
75
|
+
}
|
|
76
|
+
return properties;
|
|
77
77
|
};
|
|
78
78
|
export const formatPageRange = (pageRange) => {
|
|
79
|
-
|
|
79
|
+
return pageRange.replace(/,/g, ';');
|
|
80
80
|
};
|
|
81
81
|
export const validatePageRange = (pageRange) => {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
const regex = /^(\d+(-\d+)?(,\d+(-\d+)?)*|(\d+,\d+(-\d+)?(,\d+(-\d+)?)*)+)$/;
|
|
86
|
-
const isValid = regex.test(pageRange);
|
|
87
|
-
if (!isValid) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
let ranges = pageRange.split(',');
|
|
91
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
92
|
-
let rng = ranges[i].trim();
|
|
93
|
-
if (rng.includes('-')) {
|
|
94
|
-
let [start, end] = rng.split('-');
|
|
95
|
-
start = parseInt(start);
|
|
96
|
-
end = parseInt(end);
|
|
97
|
-
if (isNaN(start) || isNaN(end) || start > end || start <= 0) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
82
|
+
if (!pageRange) {
|
|
83
|
+
return true;
|
|
100
84
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
const regex = /^(\d+(-\d+)?(,\d+(-\d+)?)*|(\d+,\d+(-\d+)?(,\d+(-\d+)?)*)+)$/;
|
|
86
|
+
const isValid = regex.test(pageRange);
|
|
87
|
+
if (!isValid) {
|
|
104
88
|
return false;
|
|
105
|
-
}
|
|
106
89
|
}
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
let ranges = pageRange.split(',');
|
|
91
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
92
|
+
let rng = ranges[i].trim();
|
|
93
|
+
if (rng.includes('-')) {
|
|
94
|
+
let [start, end] = rng.split('-');
|
|
95
|
+
start = parseInt(start);
|
|
96
|
+
end = parseInt(end);
|
|
97
|
+
if (isNaN(start) || isNaN(end) || start > end || start <= 0) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
let page = parseInt(rng);
|
|
103
|
+
if (isNaN(page) || page <= 0) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
109
|
};
|
|
110
110
|
export const PAPER_ID = 256;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@stencil/core/internal/client";import{i as t}from"./i18next.js";const n=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys()){const n=e.get(t).filter((e=>{const t=e.deref();return t&&(!("isConnected"in(n=t))||n.isConnected);var n}));e.set(t,n)}})(...t)}),2e3)}})(),r=e.forceUpdate,i=e.getRenderingRef,o=(e,t)=>{const n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],e.length--)},s=(e,t)=>{const s=((e,t=(e,t)=>e!==t)=>{const n=()=>{return("function"==typeof(t=e)?t():t)??{};var t},r=n();let i=new Map(Object.entries(r));const s="undefined"!=typeof Proxy,a=s?null:{},c={dispose:[],get:[],set:[],reset:[]},l=new Map,u=()=>{i=new Map(Object.entries(n())),s||f(),c.reset.forEach((e=>e()))},d=e=>(c.get.forEach((t=>t(e))),i.get(e)),p=(e,n)=>{const r=i.get(e);t(n,r,e)&&(i.set(e,n),s||_(e),c.set.forEach((t=>t(e,n,r))))},h=s?new Proxy(r,{get:(e,t)=>d(t),ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>i.has(t),set:(e,t,n)=>(p(t,n),!0)}):(f(),a),g=(e,t)=>(c[e].push(t),()=>{o(c[e],t)});function _(e){!s&&a&&(Object.prototype.hasOwnProperty.call(a,e)||Object.defineProperty(a,e,{configurable:!0,enumerable:!0,get:()=>d(e),set(t){p(e,t)}}))}function f(){if(s||!a)return;const e=new Set(i.keys());for(const t of Object.keys(a))e.has(t)||delete a[t];for(const t of e)_(t)}return{state:h,get:d,set:p,on:g,onChange:(e,t)=>{const r=(n,r)=>{n===e&&t(r)},i=()=>{const r=n();t(r[e])},o=g("set",r),s=g("reset",i);return l.set(t,{setHandler:r,resetHandler:i,propName:e}),()=>{o(),s(),l.delete(t)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(g("set",t.set)),t.get&&e.push(g("get",t.get)),t.reset&&e.push(g("reset",t.reset)),t.dispose&&e.push(g("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{c.dispose.forEach((e=>e())),u()},reset:u,forceUpdate:e=>{const t=i.get(e);c.set.forEach((n=>n(e,t,t)))},removeListener:(e,t)=>{const n=l.get(t);n&&n.propName===e&&(o(c.set,n.setHandler),o(c.reset,n.resetHandler),l.delete(t))}}})(e,t);return s.use((()=>{if("function"!=typeof i||"function"!=typeof r)return{};const e=r,t=i,o=new Map;return{dispose:()=>o.clear(),get:e=>{const n=t();n&&((e,t,n)=>{let r=e.get(t);r||(r=[],e.set(t,r)),r.some((e=>e.deref()===n))||r.push(new WeakRef(n))})(o,e,n)},set:t=>{const r=o.get(t);if(r){const n=r.filter((t=>{const n=t.deref();return!!n&&e(n)}));o.set(t,n)}n(o)},reset:()=>{o.forEach((t=>{t.forEach((t=>{const n=t.deref();n&&e(n)}))})),n(o)}}})()),s};var a={login_dialog:{heading:"Drucke mit ezeep Blue",description:"Melde dich mit deinem ezeep Blue-Konto an, um zu drucken.",action:"Anmelden"},no_document_dialog:{heading:"Keine Datei ausgewählt",description:"Wähle zunächst eine Datei zum Drucken aus.",action:"OK"},printer_selection:{loading:"Lade meine Drucker…",print:"Drucken",printer:"Drucker",print_processing:"Drucken…",print_success:"Erfolgreich gedruckt.",print_failed:"Druck fehlgeschlagen",not_supported:"Der ausgewählte Dateityp wird nicht unterstützt.",color:"Farbe",orientation:"Ausrichtung",size:"Papierformat",duplex:"Beidseitig",quality:"Druckqualität",select_printer:"Wähle einen Drucker",select_color:"Wähle Farbe/Graustufen",select_size:"Wähle Papierformat",select_orientation:"Wähle Ausrichtung",select_quality:"Wähle Druckqualität",select_duplex:"Wähle Beidseitig",color_color:"Farbe",color_grayscale:"Graustufen",orientation_portrait:"Hochformat",orientation_landscape:"Querformat",unknown_location:"Unbekannter Standort",no_printers:"Keine Drucker gefunden.",prepare_upload:"Vorbereiten…",uploading:"Hochladen…",duplex_none:"Keine",copies:"Kopien",duplex_long:"auf der langen Seite umdrehen",duplex_short:"auf der kurzen Seite umdrehen",pull_print_success:"Bereit zum Auslösen.",width:"Breite",length:"Länge",trays:"Papierfach",select_trays:"Wähle Papierfach",page_ranges:"Druckbereich",paper_ranges:"Papier-Ranges",files_selected:"{{count}} Dateien ausgewählt",files:"Dateien"},button_actions:{login:"Anmelden",print:"Drucken",cancel:"Abbrechen",close:"Schließen",retry:"Wiederholen",select_printer:"Wähle Drucker"},upload:{description:"Ziehe Dateien hier in den Browser ",meta_leading:"oder",meta_select:"wähle Dateien aus",meta_trailing:"um mit ezeep Blue zu drucken.",selected_files:"Ausgewählte Dateien:"},user_menu:{theme:"Farbschema",appearance:"Darstellung",system:"System",light:"Hell",dark:"Dunkel",account:"Konto verwalten",help:"Hilfe & Unterstützung",logout:"Ausloggen"}},c={login_dialog:{heading:"Print with ezeep Blue",description:"Sign in with your ezeep Blue account to print.",action:"Sign in"},no_document_dialog:{heading:"No file selected",description:"Select a file first to print.",action:"OK"},printer_selection:{loading:"Loading My Printers…",print_processing:"Printing…",print_success:"Successfully printed.",pull_print_success:"Ready to be released.",print_failed:"Print failed",not_supported:"The selected file type is not supported.",prepare_upload:"Preparing…",uploading:"Uploading…",print:"Print",printer:"Printer",color:"Color",orientation:"Orientation",size:"Paper Size",duplex:"Double-sided",duplex_none:"None",duplex_long:"flip on long side",duplex_short:"flip on short side",quality:"Print Quality",select_printer:"Select a printer",select_color:"Select Color/Grayscale",select_orientation:"Select Orientation",select_size:"Select Paper Size",select_quality:"Select Print Quality",select_duplex:"Select Double-sided",color_color:"Color",color_grayscale:"Grayscale",orientation_portrait:"Portrait",orientation_landscape:"Landscape",unknown_location:"Unknown location",no_printers:"No printers found.",copies:"Copies",width:"Width",length:"Length",trays:"Tray",select_trays:"Select Tray",page_ranges:"Page Ranges",paper_ranges:"Paper Ranges",files_selected:"{{count}} files selected",files:"files"},button_actions:{login:"Sign In",print:"Print",cancel:"Cancel",close:"Close",retry:"Retry",select_printer:"Select Printer"},upload:{description:"Drop files here into the browser ",meta_leading:"or",meta_select:"select files",meta_trailing:"to print with ezeep Blue.",selected_files:"Selected Files:"},user_menu:{theme:"Color theme",appearance:"Appearance",system:"System",light:"Light",dark:"Dark",account:"Manage Account",help:"Help & Support",logout:"Logout"}};function l(e){return Object.keys(e).map((t=>encodeURIComponent(t)+"="+encodeURIComponent(e[t]))).join("&")}function u(e){const n={en:{translation:c},de:{translation:a}};t.init(""!=e?{resources:n,lng:e,nsSeparator:!1,fallbackLng:"en"}:{resources:n,lng:navigator.language,nsSeparator:!1,fallbackLng:"en"})}const d=async({fn:e,validate:t,interval:n,maxAttempts:r})=>{let i=0;const o=async(s,a)=>{const c=await e();return i++,t(c)?s(c):r&&i===r?a(new Error("Exceeded max attempts.")):void setTimeout(o,n,s,a)};return new Promise(o)},p=e=>{let t={};return Object.keys(e).forEach((n=>{""!==e[n]&&(t[n]=e[n])})),t},h=e=>(e.paperid!=f&&(delete e.paperlength,delete e.paperwidth),e.paperlength&&e.paperwidth&&(e.paperlength=10*+e.paperlength,e.paperwidth=10*+e.paperwidth),e),g=e=>e.replace(/,/g,";"),_=e=>{if(!e)return!0;if(!/^(\d+(-\d+)?(,\d+(-\d+)?)*|(\d+,\d+(-\d+)?(,\d+(-\d+)?)*)+)$/.test(e))return!1;let t=e.split(",");for(let e=0;e<t.length;e++){let n=t[e].trim();if(n.includes("-")){let[e,t]=n.split("-");if(e=parseInt(e),t=parseInt(t),isNaN(e)||isNaN(t)||e>t||e<=0)return!1}else{let e=parseInt(n);if(isNaN(e)||e<=0)return!1}}return!0},f=256;class m{constructor(e,t){this.urlParams=new URLSearchParams,this.isAuthorized=!1,this.redirectURI=e,this.clientID=t,this.oauthUrl=y.state.authApiHostUrl,this.authURI=new URL(`https://${this.oauthUrl}/oauth/authorize/`),this.accessTokenURL=`https://${this.oauthUrl}/oauth/access_token/`}generateCodeVerifier(){if(""!==y.state.codeVerifier)this.codeVerifier=y.state.codeVerifier;else{const e=new Uint8Array(128),t=crypto.getRandomValues(e),n=btoa(t.toString()).substr(0,128);this.codeVerifier=n,y.state.codeVerifier=this.codeVerifier}}async generateCodeChallenge(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t),r=btoa(String.fromCharCode.apply(null,new Uint8Array(n)));this.codeChallenge=r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}buildAuthURI(){this.urlParams.append("response_type","code"),this.urlParams.append("client_id",this.clientID),this.urlParams.append("redirect_uri",this.redirectURI),this.urlParams.append("code_challenge",this.codeChallenge),this.urlParams.append("code_challenge_method","S256"),this.authURI.search=this.urlParams.toString(),y.state.authUri=this.authURI.toString()}getAccessToken(){return fetch(this.accessTokenURL,{credentials:"include",headers:{Authorization:"Basic "+btoa(this.clientID+":"),"Content-Type":"application/x-www-form-urlencoded"},method:"POST",body:l({grant_type:"authorization_code",scope:"printing",code:y.state.code,redirect_uri:this.redirectURI,code_verifier:y.state.codeVerifier})}).then((e=>e.json())).then((e=>{e.access_token&&(y.state.isAuthorized=!0,this.isAuthorized=y.state.isAuthorized,localStorage.setItem("isAuthorized",this.isAuthorized.toString()),this.accessToken=e.access_token,localStorage.setItem("access_token",this.accessToken),y.state.accessToken=this.accessToken,this.refreshToken=e.refresh_token,localStorage.setItem("refreshToken",this.refreshToken),y.state.refreshToken=this.refreshToken)}))}refreshTokens(){return fetch(this.accessTokenURL,{credentials:"include",headers:{Authorization:"Basic "+btoa(this.clientID+":"),"Content-Type":"application/x-www-form-urlencoded"},method:"POST",body:l({grant_type:"refresh_token",scope:"printing",refresh_token:y.state.refreshToken})}).then((e=>e.json())).then((e=>{e.access_token&&(this.accessToken=e.access_token,localStorage.setItem("access_token",this.accessToken),y.state.accessToken=this.accessToken,this.refreshToken=e.refresh_token,localStorage.setItem("refreshToken",this.refreshToken),y.state.refreshToken=this.refreshToken,y.state.isAuthorized=!0,localStorage.setItem("isAuthorized","true"))}))}revokeRefreshToken(){y.state.refreshToken&&fetch(`https://${this.oauthUrl}/oauth/revoke/`,{credentials:"include",headers:{Authorization:"Basic "+btoa(this.clientID+":"),"Content-Type":"application/x-www-form-urlencoded"},method:"POST",body:l({token:y.state.refreshToken})}).catch((e=>{console.log(e)}))}}const y=s({code:"",codeVerifier:"",accessToken:"",refreshToken:"",isAuthorized:!1,devApi:!1,authApiHostUrl:"",redirectUri:"",authUri:""});function w(){const e=new URLSearchParams(window.location.search).get("code");window.opener&&e&&(window.opener.postMessage(e,y.state.redirectUri),window.close())}export{m as E,f as P,y as a,s as c,g as f,u as i,h as m,d as p,p as r,w as s,_ as v}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface EzpAuth extends Components.EzpAuth, HTMLElement {}
|
|
4
|
+
export const EzpAuth: {
|
|
5
|
+
prototype: EzpAuth;
|
|
6
|
+
new (): EzpAuth;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as o,d as s}from"./ezp-auth2.js";const t=o,a=s;export{t as EzpAuth,a as defineCustomElement}
|