@ezeep/ezeep-js 1.0.272 → 1.0.277
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 → app-globals-L_3XPZxT.js} +7 -1
- package/dist/cjs/ezeep.cjs.js +4 -4
- package/dist/cjs/ezp-auth_15.cjs.entry.js +7240 -3678
- package/dist/cjs/{index-dv_gozsq.js → index-DM5v_sge.js} +3 -2
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ezp-auth/ezp-auth.css +1 -1
- package/dist/collection/components/ezp-auth/ezp-auth.js +56 -15
- package/dist/collection/components/ezp-backdrop/ezp-backdrop.js +5 -5
- package/dist/collection/components/ezp-dialog/ezp-dialog.js +85 -13
- package/dist/collection/components/ezp-icon/ezp-icon.js +7 -2
- package/dist/collection/components/ezp-icon-button/ezp-icon-button.js +4 -1
- package/dist/collection/components/ezp-input/ezp-input.css +9 -12
- package/dist/collection/components/ezp-input/ezp-input.js +15 -13
- package/dist/collection/components/ezp-printer-selection/ezp-printer-selection.js +207 -323
- package/dist/collection/components/ezp-printing/ezp-printing.css +9 -9
- package/dist/collection/components/ezp-printing/ezp-printing.js +107 -35
- package/dist/collection/components/ezp-select/ezp-select.css +2 -2
- package/dist/collection/components/ezp-select/ezp-select.js +92 -13
- package/dist/collection/components/ezp-status/ezp-status.js +23 -13
- package/dist/collection/components/ezp-stepper/ezp-stepper.js +13 -6
- package/dist/collection/components/ezp-text-button/ezp-text-button.js +1 -1
- package/dist/collection/components/ezp-upload/ezp-upload.css +9 -9
- package/dist/collection/components/ezp-upload/ezp-upload.js +26 -8
- package/dist/collection/components/ezp-user-menu/ezp-user-menu.css +2 -1
- package/dist/collection/components/ezp-user-menu/ezp-user-menu.js +15 -15
- package/dist/collection/services/auth.js +37 -36
- package/dist/collection/services/http.js +11 -0
- package/dist/collection/services/print-job.js +72 -0
- package/dist/collection/services/print.js +21 -69
- package/dist/collection/services/user.js +2 -9
- package/dist/collection/shared/constants.js +55 -0
- package/dist/collection/shared/global.js +7 -1
- package/dist/collection/shared/storage.js +71 -0
- package/dist/collection/types/shared/types.d.ts +40 -9
- package/dist/collection/utils/printer.js +68 -0
- package/dist/collection/utils/utils.js +24 -9
- package/dist/components/auth.js +1 -1
- package/dist/components/ezp-auth2.js +1 -1
- package/dist/components/ezp-backdrop2.js +1 -1
- package/dist/components/ezp-dialog2.js +1 -1
- package/dist/components/ezp-icon-button2.js +1 -1
- package/dist/components/ezp-icon2.js +1 -1
- package/dist/components/ezp-input2.js +1 -1
- package/dist/components/ezp-printer-selection2.js +1 -1
- package/dist/components/ezp-printing.js +1 -1
- package/dist/components/ezp-select2.js +1 -1
- package/dist/components/ezp-status2.js +1 -1
- package/dist/components/ezp-stepper2.js +1 -1
- package/dist/components/ezp-text-button2.js +1 -1
- package/dist/components/ezp-upload2.js +1 -1
- package/dist/components/ezp-user-menu.js +1 -1
- package/dist/components/ezp-user-menu2.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/utils.js +1 -0
- package/dist/directives/proxies.ts +65 -42
- package/dist/esm/{app-globals-CpP67t2l.js → app-globals-C0WTlb31.js} +7 -1
- package/dist/esm/ezeep.js +5 -5
- package/dist/esm/ezp-auth_15.entry.js +7240 -3678
- package/dist/esm/{index-BTfWEHH9.js → index-BButrLnB.js} +3 -3
- package/dist/esm/loader.js +4 -4
- package/dist/esm-es5/{app-globals-CpP67t2l.js → app-globals-C0WTlb31.js} +1 -1
- 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 → index-BButrLnB.js} +3 -3
- package/dist/esm-es5/loader.js +1 -1
- package/dist/ezeep/ezeep.esm.js +1 -1
- package/dist/ezeep/ezeep.js +1 -1
- package/dist/ezeep/p-644e48a0.system.entry.js +7 -0
- package/dist/ezeep/{p-BTfWEHH9.js → p-BButrLnB.js} +2 -2
- package/dist/ezeep/{p-CpP67t2l.js → p-C0WTlb31.js} +1 -1
- package/{www/build/p-DhXN1yGM.system.js → dist/ezeep/p-CYpousxy.system.js} +2 -2
- package/dist/ezeep/{p-5ok9OZMg.system.js → p-D4aCr1OK.system.js} +1 -1
- package/dist/ezeep/{p-CfQRcOh8.system.js → p-DCznw2Ee.system.js} +1 -1
- package/dist/ezeep/p-ebd2beda.entry.js +1 -0
- package/dist/ezeep/types/shared/types.d.ts +40 -9
- package/dist/types/components/ezp-auth/ezp-auth.d.ts +8 -5
- package/dist/types/components/ezp-backdrop/ezp-backdrop.d.ts +2 -2
- package/dist/types/components/ezp-dialog/ezp-dialog.d.ts +14 -3
- package/dist/types/components/ezp-input/ezp-input.d.ts +17 -14
- package/dist/types/components/ezp-printer-selection/ezp-printer-selection.d.ts +23 -7
- package/dist/types/components/ezp-printing/ezp-printing.d.ts +25 -2
- package/dist/types/components/ezp-select/ezp-select.d.ts +10 -4
- package/dist/types/components/ezp-status/ezp-status.d.ts +6 -4
- package/dist/types/components/ezp-stepper/ezp-stepper.d.ts +1 -1
- package/dist/types/components/ezp-upload/ezp-upload.d.ts +4 -1
- package/dist/types/components/ezp-user-menu/ezp-user-menu.d.ts +5 -2
- package/dist/types/components.d.ts +38 -38
- package/dist/types/services/auth.d.ts +10 -0
- package/dist/types/services/http.d.ts +4 -0
- package/dist/types/services/print-job.d.ts +48 -0
- package/dist/types/services/print.d.ts +10 -9
- package/dist/types/services/user.d.ts +13 -2
- package/dist/types/shared/constants.d.ts +51 -0
- package/dist/types/shared/storage.d.ts +24 -0
- package/dist/types/shared/types.d.ts +40 -9
- package/dist/types/stencil-public-runtime.d.ts +1 -0
- package/dist/types/utils/printer.d.ts +22 -0
- package/dist/types/utils/utils.d.ts +22 -10
- package/package.json +30 -18
- package/readme.md +1 -0
- package/www/build/ezeep.esm.js +1 -1
- package/www/build/ezeep.js +1 -1
- package/www/build/p-644e48a0.system.entry.js +7 -0
- package/www/build/{p-BTfWEHH9.js → p-BButrLnB.js} +2 -2
- package/www/build/{p-CpP67t2l.js → p-C0WTlb31.js} +1 -1
- package/{dist/ezeep/p-DhXN1yGM.system.js → www/build/p-CYpousxy.system.js} +2 -2
- package/www/build/{p-5ok9OZMg.system.js → p-D4aCr1OK.system.js} +1 -1
- package/www/build/{p-CfQRcOh8.system.js → p-DCznw2Ee.system.js} +1 -1
- package/www/build/p-c7252f1c.js +1 -0
- package/www/build/p-ebd2beda.entry.js +1 -0
- package/www/data/locales/de.json +1 -0
- package/www/data/locales/en.json +1 -0
- package/www/index.html +2 -5
- package/dist/components/i18next.js +0 -1
- package/dist/ezeep/p-2177b8f4.system.entry.js +0 -7
- package/dist/ezeep/p-de8f6583.entry.js +0 -1
- package/www/build/p-2177b8f4.system.entry.js +0 -7
- package/www/build/p-256870db.js +0 -1
- package/www/build/p-de8f6583.entry.js +0 -1
|
@@ -2,15 +2,13 @@ import { createStore } from "@stencil/store";
|
|
|
2
2
|
import authStore, { EzpAuthorizationService } from "./auth";
|
|
3
3
|
import fetchIntercept from "fetch-intercept";
|
|
4
4
|
import { AnonymousCredential, BlockBlobClient, newPipeline } from "@azure/storage-blob";
|
|
5
|
+
import { authGetJson, bearer } from "./http";
|
|
6
|
+
import { storage } from "../shared/storage";
|
|
5
7
|
export class EzpPrintService {
|
|
6
8
|
constructor(redirectURI, clientID) {
|
|
7
9
|
this.abortController = null;
|
|
8
10
|
this.getPrintStatus = () => {
|
|
9
|
-
return
|
|
10
|
-
headers: {
|
|
11
|
-
Authorization: 'Bearer ' + authStore.state.accessToken,
|
|
12
|
-
},
|
|
13
|
-
}).then((response) => response.json());
|
|
11
|
+
return authGetJson(`https://${this.printingApi}/sfapi/Status/?id=${encodeURIComponent(printStore.state.jobID)}`, authStore.state.accessToken);
|
|
14
12
|
};
|
|
15
13
|
this.redirectURI = redirectURI;
|
|
16
14
|
this.clientID = clientID;
|
|
@@ -18,15 +16,11 @@ export class EzpPrintService {
|
|
|
18
16
|
this.checkStoredRefreshToken();
|
|
19
17
|
}
|
|
20
18
|
checkStoredRefreshToken() {
|
|
19
|
+
var _a;
|
|
21
20
|
if (authStore.state.refreshToken !== '') {
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
authStore.state.refreshToken = '';
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
authStore.state.refreshToken = localStorage.getItem('refreshToken');
|
|
29
|
-
}
|
|
23
|
+
authStore.state.refreshToken = (_a = storage.getRefreshToken()) !== null && _a !== void 0 ? _a : '';
|
|
30
24
|
}
|
|
31
25
|
registerFetchInterceptor() {
|
|
32
26
|
fetchIntercept.register({
|
|
@@ -57,52 +51,23 @@ export class EzpPrintService {
|
|
|
57
51
|
});
|
|
58
52
|
}
|
|
59
53
|
getPrinterList(accessToken) {
|
|
60
|
-
return
|
|
61
|
-
method: 'GET',
|
|
62
|
-
headers: {
|
|
63
|
-
Authorization: 'Bearer ' + accessToken,
|
|
64
|
-
},
|
|
65
|
-
}).then((response) => response.json());
|
|
54
|
+
return authGetJson(`https://${this.printingApi}/sfapi/GetPrinter/`, accessToken);
|
|
66
55
|
}
|
|
67
56
|
async getConfig(accessToken) {
|
|
68
57
|
return fetch(`https://${this.printingApi}/sfapi/GetConfiguration/`, {
|
|
69
58
|
method: 'GET',
|
|
70
|
-
headers:
|
|
71
|
-
Authorization: 'Bearer ' + accessToken,
|
|
72
|
-
},
|
|
59
|
+
headers: bearer(accessToken),
|
|
73
60
|
});
|
|
74
61
|
}
|
|
75
62
|
getPrinterProperties(accessToken, printerID) {
|
|
76
|
-
return
|
|
77
|
-
method: 'GET',
|
|
78
|
-
headers: {
|
|
79
|
-
Authorization: 'Bearer ' + accessToken,
|
|
80
|
-
},
|
|
81
|
-
}).then((response) => {
|
|
82
|
-
return response.json();
|
|
83
|
-
});
|
|
63
|
+
return authGetJson(`https://${this.printingApi}/sfapi/GetPrinterProperties/?id=${printerID}`, accessToken);
|
|
84
64
|
}
|
|
85
65
|
getAllPrinterProperties(accessToken) {
|
|
86
|
-
return
|
|
87
|
-
method: 'GET',
|
|
88
|
-
headers: {
|
|
89
|
-
Authorization: 'Bearer ' + accessToken,
|
|
90
|
-
},
|
|
91
|
-
}).then((response) => {
|
|
92
|
-
return response.json();
|
|
93
|
-
});
|
|
66
|
+
return authGetJson(`https://${this.printingApi}/sfapi/GetPrinterProperties/`, accessToken);
|
|
94
67
|
}
|
|
95
68
|
printFileByUrl(accessToken, fileUrl, fileType, printerID, properties, filename, printAndDelete) {
|
|
96
69
|
this.abortController = new AbortController();
|
|
97
|
-
return
|
|
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
|
-
});
|
|
70
|
+
return this.printRequest(accessToken, Object.assign(Object.assign(Object.assign({ fileurl: fileUrl, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties }), this.abortController.signal);
|
|
106
71
|
}
|
|
107
72
|
abortPrint() {
|
|
108
73
|
if (this.abortController) {
|
|
@@ -110,33 +75,20 @@ export class EzpPrintService {
|
|
|
110
75
|
this.abortController = null;
|
|
111
76
|
}
|
|
112
77
|
}
|
|
113
|
-
|
|
78
|
+
/** Shared POST to the `Print` endpoint. Returns the raw response. */
|
|
79
|
+
printRequest(accessToken, body, signal) {
|
|
114
80
|
return fetch(`https://${this.printingApi}/sfapi/Print/`, {
|
|
115
81
|
method: 'POST',
|
|
116
|
-
headers: {
|
|
117
|
-
|
|
118
|
-
|
|
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());
|
|
82
|
+
headers: Object.assign(Object.assign({}, bearer(accessToken)), { 'Content-Type': 'application/json' }),
|
|
83
|
+
body: JSON.stringify(body),
|
|
84
|
+
signal,
|
|
85
|
+
});
|
|
122
86
|
}
|
|
123
|
-
|
|
124
|
-
return
|
|
125
|
-
method: 'GET',
|
|
126
|
-
headers: {
|
|
127
|
-
Authorization: 'Bearer ' + accessToken,
|
|
128
|
-
},
|
|
129
|
-
}).then((response) => response.json());
|
|
87
|
+
printByFileID(accessToken, fileID, fileType, printerID, properties, filename, printAndDelete) {
|
|
88
|
+
return this.printRequest(accessToken, Object.assign(Object.assign(Object.assign({ fileid: fileID, type: fileType, printerid: printerID }, (filename && { alias: filename })), (printAndDelete && { printanddelete: printAndDelete })), { properties })).then((response) => response.json());
|
|
130
89
|
}
|
|
131
|
-
|
|
132
|
-
return
|
|
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());
|
|
90
|
+
prepareFileUpload(accessToken) {
|
|
91
|
+
return authGetJson(`https://${this.printingApi}/sfapi/PrepareUpload/`, accessToken);
|
|
140
92
|
}
|
|
141
93
|
async uploadBlobFiles(sasUri, file) {
|
|
142
94
|
printStore.state.uploadProgress = 0;
|
|
@@ -153,7 +105,7 @@ export class EzpPrintService {
|
|
|
153
105
|
blockSize: 4 * 1024 * 1024, //4mb blocksize
|
|
154
106
|
concurrency: 20,
|
|
155
107
|
onProgress: (e) => {
|
|
156
|
-
|
|
108
|
+
const progress = (100 * e.loadedBytes) / file.size;
|
|
157
109
|
printStore.state.uploadProgress = progress;
|
|
158
110
|
},
|
|
159
111
|
blobHTTPHeaders: { blobContentType: 'application/octet-stream' },
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { createStore } from "@stencil/store";
|
|
2
2
|
import authStore from "./auth";
|
|
3
|
+
import { authGetJson } from "./http";
|
|
3
4
|
export class EzpUserService {
|
|
4
5
|
getUserInfo() {
|
|
5
|
-
return
|
|
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
|
-
});
|
|
6
|
+
return authGetJson(`https://${authStore.state.authApiHostUrl}/v1/users/me`, authStore.state.accessToken);
|
|
14
7
|
}
|
|
15
8
|
}
|
|
16
9
|
const userStore = createStore({
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralised magic numbers used across the print/auth flow.
|
|
3
|
+
*
|
|
4
|
+
* These previously appeared as inline literals in `ezp-printer-selection`,
|
|
5
|
+
* `print.ts` and `utils.ts`, with the same job-status codes duplicated across
|
|
6
|
+
* three separate state machines. Keep them here so the meaning is explicit and
|
|
7
|
+
* there is a single source of truth.
|
|
8
|
+
*/
|
|
9
|
+
/** Print-job status codes returned by `sfapi/Status`. */
|
|
10
|
+
export var JobStatus;
|
|
11
|
+
(function (JobStatus) {
|
|
12
|
+
JobStatus[JobStatus["Success"] = 0] = "Success";
|
|
13
|
+
/** Job accepted / spooling — keep polling. */
|
|
14
|
+
JobStatus[JobStatus["Processing"] = 1246] = "Processing";
|
|
15
|
+
/** Job rendering — keep polling. */
|
|
16
|
+
JobStatus[JobStatus["Rendering"] = 129] = "Rendering";
|
|
17
|
+
JobStatus[JobStatus["Failed"] = 3011] = "Failed";
|
|
18
|
+
/** Generic failure. */
|
|
19
|
+
JobStatus[JobStatus["Error"] = 2] = "Error";
|
|
20
|
+
})(JobStatus || (JobStatus = {}));
|
|
21
|
+
/** Status codes that mean "still working — keep polling". */
|
|
22
|
+
export const PROCESSING_JOB_STATUSES = [
|
|
23
|
+
JobStatus.Processing,
|
|
24
|
+
JobStatus.Rendering,
|
|
25
|
+
];
|
|
26
|
+
/** Status codes that mean "terminal failure". */
|
|
27
|
+
export const FAILED_JOB_STATUSES = [JobStatus.Failed, JobStatus.Error];
|
|
28
|
+
/**
|
|
29
|
+
* Status/error codes that, for hub (queue) printers, indicate the print driver
|
|
30
|
+
* is missing or misconfigured rather than a transient failure. Surfaced to the
|
|
31
|
+
* user as a distinct "driver error" message.
|
|
32
|
+
*/
|
|
33
|
+
export const HUB_DRIVER_ERROR_CODES = [412, 500, 503, 1048579];
|
|
34
|
+
/** `Print` response `code` meaning the upload expired and a fileid re-print is required. */
|
|
35
|
+
export const FILE_EXPIRED_STATUS = 412;
|
|
36
|
+
/** `Print` response `code` meaning the job was rejected outright. */
|
|
37
|
+
export const PRINT_REJECTED_CODE = 804;
|
|
38
|
+
/** Successful Azure Blob upload (`uploadData`) HTTP status. */
|
|
39
|
+
export const BLOB_UPLOAD_CREATED = 201;
|
|
40
|
+
/** Paper-format id that represents a custom (user-defined width/length) size. */
|
|
41
|
+
export const PAPER_ID = 256;
|
|
42
|
+
/** Print-status polling cadence and bounds. */
|
|
43
|
+
export const POLL_INTERVAL_MS = 2000;
|
|
44
|
+
/**
|
|
45
|
+
* Overall polling budget before a still-processing job is treated as failed.
|
|
46
|
+
* Prevents polling the status endpoint indefinitely on a stuck job (only hub
|
|
47
|
+
* printers had a timeout before). Generous — 10 minutes — to tolerate slow
|
|
48
|
+
* server-side rendering of large documents.
|
|
49
|
+
*/
|
|
50
|
+
export const POLL_TIMEOUT_MS = 10 * 60 * 1000;
|
|
51
|
+
export const MAX_POLL_ATTEMPTS = Math.ceil(POLL_TIMEOUT_MS / POLL_INTERVAL_MS);
|
|
52
|
+
/** Fallback timeout for hub printers so the UI never hangs indefinitely. */
|
|
53
|
+
export const HUB_TIMEOUT_MS = 30000;
|
|
54
|
+
/** How often the access token is proactively refreshed, in seconds. */
|
|
55
|
+
export const TOKEN_REFRESH_INTERVAL_S = 1800;
|
|
@@ -3,7 +3,13 @@ export default async () => {
|
|
|
3
3
|
style: 'normal',
|
|
4
4
|
weight: '400 600',
|
|
5
5
|
});
|
|
6
|
-
font
|
|
6
|
+
font
|
|
7
|
+
.load()
|
|
8
|
+
.then(() => {
|
|
7
9
|
document.fonts.add(font);
|
|
10
|
+
})
|
|
11
|
+
.catch(() => {
|
|
12
|
+
// The remote webfont is a progressive enhancement; if it can't be
|
|
13
|
+
// fetched (offline, blocked, CI without egress) fall back silently.
|
|
8
14
|
});
|
|
9
15
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single typed entry point for the `localStorage` keys this library persists.
|
|
3
|
+
*
|
|
4
|
+
* Previously these keys were referenced as string literals in ~30 places across
|
|
5
|
+
* services and components, with inconsistent naming (`access_token` vs
|
|
6
|
+
* `refreshToken`). The literal key strings are preserved here exactly so that
|
|
7
|
+
* users who are already signed in keep their session across an upgrade.
|
|
8
|
+
*/
|
|
9
|
+
/** Persisted localStorage keys. Do not change the string values — see note above. */
|
|
10
|
+
const KEY = {
|
|
11
|
+
accessToken: 'access_token',
|
|
12
|
+
refreshToken: 'refreshToken',
|
|
13
|
+
isAuthorized: 'isAuthorized',
|
|
14
|
+
properties: 'properties',
|
|
15
|
+
printer: 'printer',
|
|
16
|
+
};
|
|
17
|
+
function getJSON(key) {
|
|
18
|
+
const raw = localStorage.getItem(key);
|
|
19
|
+
if (raw === null)
|
|
20
|
+
return null;
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const storage = {
|
|
29
|
+
// Note: the access token is intentionally NOT persisted (kept in memory only,
|
|
30
|
+
// for XSS defense-in-depth). `clearSession` still removes any legacy value.
|
|
31
|
+
getRefreshToken() {
|
|
32
|
+
return localStorage.getItem(KEY.refreshToken);
|
|
33
|
+
},
|
|
34
|
+
setRefreshToken(token) {
|
|
35
|
+
localStorage.setItem(KEY.refreshToken, token);
|
|
36
|
+
},
|
|
37
|
+
getIsAuthorized() {
|
|
38
|
+
return localStorage.getItem(KEY.isAuthorized) === 'true';
|
|
39
|
+
},
|
|
40
|
+
setIsAuthorized(value) {
|
|
41
|
+
localStorage.setItem(KEY.isAuthorized, value.toString());
|
|
42
|
+
},
|
|
43
|
+
hasIsAuthorized() {
|
|
44
|
+
return localStorage.getItem(KEY.isAuthorized) !== null;
|
|
45
|
+
},
|
|
46
|
+
getProperties() {
|
|
47
|
+
return getJSON(KEY.properties);
|
|
48
|
+
},
|
|
49
|
+
setProperties(properties) {
|
|
50
|
+
localStorage.setItem(KEY.properties, JSON.stringify(properties));
|
|
51
|
+
},
|
|
52
|
+
getPrinter() {
|
|
53
|
+
return getJSON(KEY.printer);
|
|
54
|
+
},
|
|
55
|
+
setPrinter(printer) {
|
|
56
|
+
localStorage.setItem(KEY.printer, JSON.stringify(printer));
|
|
57
|
+
},
|
|
58
|
+
/** Remove everything tied to the current session (used on logout). */
|
|
59
|
+
clearSession() {
|
|
60
|
+
localStorage.removeItem(KEY.properties);
|
|
61
|
+
localStorage.removeItem(KEY.refreshToken);
|
|
62
|
+
localStorage.removeItem(KEY.accessToken);
|
|
63
|
+
localStorage.removeItem(KEY.printer);
|
|
64
|
+
localStorage.removeItem(KEY.isAuthorized);
|
|
65
|
+
},
|
|
66
|
+
/** Remove just the saved printer + its properties (used when the saved printer is gone). */
|
|
67
|
+
clearSavedPrinter() {
|
|
68
|
+
localStorage.removeItem(KEY.printer);
|
|
69
|
+
localStorage.removeItem(KEY.properties);
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -55,6 +55,37 @@ export type AppearanceTypes = 'system' | 'light' | 'dark'
|
|
|
55
55
|
export type TriggerTypes = 'custom' | 'file' | 'button'
|
|
56
56
|
export type AlertType = { open: boolean; heading: string; description: string }
|
|
57
57
|
export type SystemAppearanceTypes = 'light' | 'dark'
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Payload emitted by selection-style components (`ezp-select`, `ezp-input`,
|
|
61
|
+
* `ezp-stepper`) and consumed by `ezp-printer-selection.setSelectedProperties`.
|
|
62
|
+
*/
|
|
63
|
+
export interface PropertyChangeDetail {
|
|
64
|
+
type: string
|
|
65
|
+
id?: string | number | boolean
|
|
66
|
+
title?: string
|
|
67
|
+
is_queue?: boolean
|
|
68
|
+
value?: string | number
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Response of `sfapi/Print` (POST). */
|
|
72
|
+
export interface PrintResponse {
|
|
73
|
+
code?: number
|
|
74
|
+
jobid?: string
|
|
75
|
+
fileid?: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Response of `sfapi/Status`. */
|
|
79
|
+
export interface JobStatusResponse {
|
|
80
|
+
jobstatus: number
|
|
81
|
+
jobstatusstring?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Response of `sfapi/PrepareUpload`. */
|
|
85
|
+
export interface PrepareUploadResponse {
|
|
86
|
+
fileid: string
|
|
87
|
+
sasUri: string
|
|
88
|
+
}
|
|
58
89
|
export interface PrinterProperties {
|
|
59
90
|
paper?: string
|
|
60
91
|
paperid?: number | string
|
|
@@ -64,11 +95,11 @@ export interface PrinterProperties {
|
|
|
64
95
|
orientation?: number | string
|
|
65
96
|
copies?: number | string
|
|
66
97
|
resolution?: string | number
|
|
67
|
-
paperlength
|
|
68
|
-
paperwidth
|
|
98
|
+
paperlength?: string | number
|
|
99
|
+
paperwidth?: string | number
|
|
69
100
|
defaultSource?: number | string
|
|
70
|
-
trayname?: string
|
|
71
|
-
PageRanges
|
|
101
|
+
trayname?: string
|
|
102
|
+
PageRanges?: string
|
|
72
103
|
}
|
|
73
104
|
|
|
74
105
|
export interface Printer {
|
|
@@ -87,8 +118,8 @@ export interface PaperFormat {
|
|
|
87
118
|
}
|
|
88
119
|
|
|
89
120
|
export interface Trays {
|
|
90
|
-
Default
|
|
91
|
-
Index:
|
|
121
|
+
Default: boolean
|
|
122
|
+
Index: number
|
|
92
123
|
Name: string
|
|
93
124
|
}
|
|
94
125
|
|
|
@@ -101,7 +132,7 @@ export interface PrinterConfig {
|
|
|
101
132
|
Resolution?: string
|
|
102
133
|
Paper?: string
|
|
103
134
|
Tray?: string
|
|
104
|
-
}
|
|
135
|
+
}
|
|
105
136
|
Collate?: boolean
|
|
106
137
|
Color?: boolean
|
|
107
138
|
ColorSupported?: boolean
|
|
@@ -123,7 +154,7 @@ export interface PrinterConfig {
|
|
|
123
154
|
}
|
|
124
155
|
|
|
125
156
|
export interface User {
|
|
126
|
-
azureProfile:
|
|
157
|
+
azureProfile: unknown
|
|
127
158
|
dateJoined: string
|
|
128
159
|
displayName: string
|
|
129
160
|
email: string
|
|
@@ -137,5 +168,5 @@ export interface User {
|
|
|
137
168
|
isVerfified: boolean
|
|
138
169
|
lastName: string
|
|
139
170
|
roles: Array<string>
|
|
140
|
-
userInvitations:
|
|
171
|
+
userInvitations: unknown
|
|
141
172
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { JobStatus, PROCESSING_JOB_STATUSES, FAILED_JOB_STATUSES, HUB_DRIVER_ERROR_CODES, } from "../shared/constants";
|
|
2
|
+
/**
|
|
3
|
+
* Derive the default print properties for a printer from its configuration.
|
|
4
|
+
*
|
|
5
|
+
* This logic previously lived inline and **duplicated verbatim** in
|
|
6
|
+
* `ezp-printer-selection` (in `setSelectedProperties` and `connectedCallback`).
|
|
7
|
+
* It mutates `properties` in place — matching the original behaviour exactly —
|
|
8
|
+
* and returns it for convenience.
|
|
9
|
+
*/
|
|
10
|
+
export function applyPrinterDefaults(config, properties) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
+
properties.color = ((_a = config.Default) === null || _a === void 0 ? void 0 : _a.Color) == 'color' ? true : false;
|
|
13
|
+
const defaultOrientation = (_b = config.Default) === null || _b === void 0 ? void 0 : _b.Orientation;
|
|
14
|
+
const defaultOrientationIndex = (_c = config.Default) === null || _c === void 0 ? void 0 : _c.OrientationIndex;
|
|
15
|
+
let orientationFallback;
|
|
16
|
+
if (defaultOrientation) {
|
|
17
|
+
const idx = (_d = config.OrientationsSupported) === null || _d === void 0 ? void 0 : _d.indexOf(defaultOrientation);
|
|
18
|
+
if (typeof idx === 'number' && idx >= 0)
|
|
19
|
+
orientationFallback = idx + 1;
|
|
20
|
+
}
|
|
21
|
+
properties.orientation = defaultOrientationIndex !== null && defaultOrientationIndex !== void 0 ? defaultOrientationIndex : orientationFallback;
|
|
22
|
+
properties.resolution = (_e = config.Default) === null || _e === void 0 ? void 0 : _e.Resolution;
|
|
23
|
+
const defaultPaper = (_f = config.PaperFormats) === null || _f === void 0 ? void 0 : _f.find((obj) => obj.Default === true);
|
|
24
|
+
properties.paper = defaultPaper === null || defaultPaper === void 0 ? void 0 : defaultPaper.Name;
|
|
25
|
+
properties.paperid = defaultPaper === null || defaultPaper === void 0 ? void 0 : defaultPaper.Id;
|
|
26
|
+
// `obj?.` guards against an explicit "no trays" report of `[null]`, which the
|
|
27
|
+
// original inline code would crash on before reaching the guards below.
|
|
28
|
+
const defaultSource = (_g = config.Trays) === null || _g === void 0 ? void 0 : _g.find((obj) => (obj === null || obj === void 0 ? void 0 : obj.Default) === true);
|
|
29
|
+
if (config.Trays && config.Trays.length >= 1 && config.Trays[0] != null) {
|
|
30
|
+
properties.trayname = defaultSource === null || defaultSource === void 0 ? void 0 : defaultSource.Name;
|
|
31
|
+
properties.defaultSource = defaultSource === null || defaultSource === void 0 ? void 0 : defaultSource.Index;
|
|
32
|
+
}
|
|
33
|
+
// When the printer reports an explicit "no trays" ([null]) we must not send
|
|
34
|
+
// tray attributes at all.
|
|
35
|
+
if (config.Trays && config.Trays.length >= 0 && config.Trays[0] == null) {
|
|
36
|
+
delete properties.trayname;
|
|
37
|
+
delete properties.defaultSource;
|
|
38
|
+
}
|
|
39
|
+
properties.duplex = config.DuplexSupported;
|
|
40
|
+
properties.duplexmode = config.DuplexMode;
|
|
41
|
+
delete properties.PageRanges;
|
|
42
|
+
return properties;
|
|
43
|
+
}
|
|
44
|
+
/** Does this printer config report an explicit "no usable trays" state? */
|
|
45
|
+
export function hasNoTrays(config) {
|
|
46
|
+
return !!config.Trays && config.Trays.length >= 0 && config.Trays[0] == null;
|
|
47
|
+
}
|
|
48
|
+
/** Does this printer config expose at least one selectable tray? */
|
|
49
|
+
export function hasTrays(config) {
|
|
50
|
+
return !!config.Trays && config.Trays.length >= 1 && config.Trays[0] != null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Classify a print-job status code into a single outcome. Centralises the
|
|
54
|
+
* status logic that was previously duplicated (with slightly inconsistent code
|
|
55
|
+
* sets) across `validateData`, `waitForPrintCompletion` and the inline checks
|
|
56
|
+
* in `handlePrint`. Unknown codes are treated as failures for safety.
|
|
57
|
+
*/
|
|
58
|
+
export function classifyJobStatus(jobstatus, isQueue) {
|
|
59
|
+
if (jobstatus === JobStatus.Success)
|
|
60
|
+
return 'success';
|
|
61
|
+
if (PROCESSING_JOB_STATUSES.includes(jobstatus))
|
|
62
|
+
return 'processing';
|
|
63
|
+
if (isQueue && HUB_DRIVER_ERROR_CODES.includes(jobstatus))
|
|
64
|
+
return 'hub-error';
|
|
65
|
+
if (FAILED_JOB_STATUSES.includes(jobstatus))
|
|
66
|
+
return 'failed';
|
|
67
|
+
return 'failed';
|
|
68
|
+
}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
import { forceUpdate } from "@stencil/core";
|
|
1
2
|
import i18next from "i18next";
|
|
2
3
|
import translationsDE from "../data/locales/de.json";
|
|
3
4
|
import translationsEN from "../data/locales/en.json";
|
|
5
|
+
import { PAPER_ID } from "../shared/constants";
|
|
6
|
+
export { PAPER_ID } from '../shared/constants';
|
|
7
|
+
/**
|
|
8
|
+
* Re-render a Stencil component whenever the i18next language changes.
|
|
9
|
+
* i18next fires `languageChanged` but has no hook into Stencil's render cycle,
|
|
10
|
+
* so any component that calls `i18next.t()` in render() must force an update —
|
|
11
|
+
* otherwise a runtime language switch leaves already-mounted text stale.
|
|
12
|
+
* Call from connectedCallback and invoke the returned disposer in
|
|
13
|
+
* disconnectedCallback.
|
|
14
|
+
*/
|
|
15
|
+
export function subscribeToLanguageChange(component) {
|
|
16
|
+
const rerender = () => forceUpdate(component);
|
|
17
|
+
i18next.on('languageChanged', rerender);
|
|
18
|
+
return () => i18next.off('languageChanged', rerender);
|
|
19
|
+
}
|
|
4
20
|
export function encodeFormData(data) {
|
|
5
21
|
return Object.keys(data)
|
|
6
22
|
.map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
|
|
@@ -38,7 +54,7 @@ export function initi18n(language) {
|
|
|
38
54
|
});
|
|
39
55
|
}
|
|
40
56
|
}
|
|
41
|
-
export const poll = async ({ fn, validate, interval, maxAttempts }) => {
|
|
57
|
+
export const poll = async ({ fn, validate, interval, maxAttempts, }) => {
|
|
42
58
|
let attempts = 0;
|
|
43
59
|
const executePoll = async (resolve, reject) => {
|
|
44
60
|
const result = await fn();
|
|
@@ -56,7 +72,7 @@ export const poll = async ({ fn, validate, interval, maxAttempts }) => {
|
|
|
56
72
|
return new Promise(executePoll);
|
|
57
73
|
};
|
|
58
74
|
export const removeEmptyStrings = (obj) => {
|
|
59
|
-
|
|
75
|
+
const newObj = {};
|
|
60
76
|
Object.keys(obj).forEach((prop) => {
|
|
61
77
|
if (obj[prop] !== '') {
|
|
62
78
|
newObj[prop] = obj[prop];
|
|
@@ -87,19 +103,19 @@ export const validatePageRange = (pageRange) => {
|
|
|
87
103
|
if (!isValid) {
|
|
88
104
|
return false;
|
|
89
105
|
}
|
|
90
|
-
|
|
106
|
+
const ranges = pageRange.split(',');
|
|
91
107
|
for (let i = 0; i < ranges.length; i++) {
|
|
92
|
-
|
|
108
|
+
const rng = ranges[i].trim();
|
|
93
109
|
if (rng.includes('-')) {
|
|
94
|
-
|
|
95
|
-
start = parseInt(
|
|
96
|
-
end = parseInt(
|
|
110
|
+
const [startStr, endStr] = rng.split('-');
|
|
111
|
+
const start = parseInt(startStr);
|
|
112
|
+
const end = parseInt(endStr);
|
|
97
113
|
if (isNaN(start) || isNaN(end) || start > end || start <= 0) {
|
|
98
114
|
return false;
|
|
99
115
|
}
|
|
100
116
|
}
|
|
101
117
|
else {
|
|
102
|
-
|
|
118
|
+
const page = parseInt(rng);
|
|
103
119
|
if (isNaN(page) || page <= 0) {
|
|
104
120
|
return false;
|
|
105
121
|
}
|
|
@@ -107,4 +123,3 @@ export const validatePageRange = (pageRange) => {
|
|
|
107
123
|
}
|
|
108
124
|
return true;
|
|
109
125
|
};
|
|
110
|
-
export const PAPER_ID = 256;
|
package/dist/components/auth.js
CHANGED
|
@@ -1 +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}
|
|
1
|
+
import*as e from"@stencil/core/internal/client";import{h as t}from"./utils.js";const r=(()=>{let e;return(...t)=>{e&&clearTimeout(e),e=setTimeout((()=>{e=0,(e=>{for(let t of e.keys()){const r=e.get(t).filter((e=>{const t=e.deref();return t&&(!("isConnected"in(r=t))||r.isConnected);var r}));e.set(t,r)}})(...t)}),2e3)}})(),o=e.forceUpdate,s=e.getRenderingRef,n=(e,t)=>{const r=e.indexOf(t);r>=0&&(e[r]=e[e.length-1],e.length--)},i=(e,t)=>{const i=((e,t=(e,t)=>e!==t)=>{const r=()=>{return("function"==typeof(t=e)?t():t)??{};var t},o=r();let s=new Map(Object.entries(o));const i="undefined"!=typeof Proxy,c=i?null:{},a={dispose:[],get:[],set:[],reset:[]},h=new Map,l=()=>{s=new Map(Object.entries(r())),i||S(),a.reset.forEach((e=>e()))},u=e=>(a.get.forEach((t=>t(e))),s.get(e)),d=(e,r)=>{const o=s.get(e);t(r,o,e)&&(s.set(e,r),i||g(e),a.set.forEach((t=>t(e,r,o))))},f=i?new Proxy(o,{get:(e,t)=>u(t),ownKeys:()=>Array.from(s.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>s.has(t),set:(e,t,r)=>(d(t,r),!0)}):(S(),c),p=(e,t)=>(a[e].push(t),()=>{n(a[e],t)});function g(e){!i&&c&&(Object.prototype.hasOwnProperty.call(c,e)||Object.defineProperty(c,e,{configurable:!0,enumerable:!0,get:()=>u(e),set(t){d(e,t)}}))}function S(){if(i||!c)return;const e=new Set(s.keys());for(const t of Object.keys(c))e.has(t)||delete c[t];for(const t of e)g(t)}return{state:f,get:u,set:d,on:p,onChange:(e,t)=>{const o=(r,o)=>{r===e&&t(o)},s=()=>{const o=r();t(o[e])},n=p("set",o),i=p("reset",s);return h.set(t,{setHandler:o,resetHandler:s,propName:e}),()=>{n(),i(),h.delete(t)}},use:(...e)=>{const t=e.reduce(((e,t)=>(t.set&&e.push(p("set",t.set)),t.get&&e.push(p("get",t.get)),t.reset&&e.push(p("reset",t.reset)),t.dispose&&e.push(p("dispose",t.dispose)),e)),[]);return()=>t.forEach((e=>e()))},dispose:()=>{a.dispose.forEach((e=>e())),l()},reset:l,forceUpdate:e=>{const t=s.get(e);a.set.forEach((r=>r(e,t,t)))},removeListener:(e,t)=>{const r=h.get(t);r&&r.propName===e&&(n(a.set,r.setHandler),n(a.reset,r.resetHandler),h.delete(t))}}})(e,t);return i.use((()=>{if("function"!=typeof s||"function"!=typeof o)return{};const e=o,t=s,n=new Map;return{dispose:()=>n.clear(),get:e=>{const r=t();r&&((e,t,r)=>{let o=e.get(t);o||(o=[],e.set(t,o)),o.some((e=>e.deref()===r))||o.push(new WeakRef(r))})(n,e,r)},set:t=>{const o=n.get(t);if(o){const r=o.filter((t=>{const r=t.deref();return!!r&&e(r)}));n.set(t,r)}r(n)},reset:()=>{n.forEach((t=>{t.forEach((t=>{const r=t.deref();r&&e(r)}))})),r(n)}}})()),i},c="refreshToken",a="isAuthorized",h="properties",l="printer";function u(e){const t=localStorage.getItem(e);if(null===t)return null;try{return JSON.parse(t)}catch(e){return null}}const d={getRefreshToken:()=>localStorage.getItem(c),setRefreshToken(e){localStorage.setItem(c,e)},getIsAuthorized:()=>"true"===localStorage.getItem(a),setIsAuthorized(e){localStorage.setItem(a,e.toString())},hasIsAuthorized:()=>null!==localStorage.getItem(a),getProperties:()=>u(h),setProperties(e){localStorage.setItem(h,JSON.stringify(e))},getPrinter:()=>u(l),setPrinter(e){localStorage.setItem(l,JSON.stringify(e))},clearSession(){localStorage.removeItem(h),localStorage.removeItem(c),localStorage.removeItem("access_token"),localStorage.removeItem(l),localStorage.removeItem(a)},clearSavedPrinter(){localStorage.removeItem(l),localStorage.removeItem(h)}};class f{constructor(e,t){this.urlParams=new URLSearchParams,this.isAuthorized=!1,this.redirectURI=e,this.clientID=t,p.state.clientID=t,this.oauthUrl=p.state.authApiHostUrl,this.authURI=new URL(`https://${this.oauthUrl}/oauth/authorize/`),this.accessTokenURL=`https://${this.oauthUrl}/oauth/access_token/`}generateCodeVerifier(){if(""!==p.state.codeVerifier)this.codeVerifier=p.state.codeVerifier;else{const e=new Uint8Array(128),t=crypto.getRandomValues(e),r=btoa(t.toString()).substr(0,128);this.codeVerifier=r,p.state.codeVerifier=this.codeVerifier}}async generateCodeChallenge(e){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t),o=btoa(String.fromCharCode(...new Uint8Array(r)));this.codeChallenge=o.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(),p.state.authUri=this.authURI.toString()}oauthHeaders(){return{Authorization:"Basic "+btoa(this.clientID+":"),"Content-Type":"application/x-www-form-urlencoded"}}persistTokens(e,t){this.accessToken=e,p.state.accessToken=e,this.refreshToken=t,p.state.refreshToken=t,d.setRefreshToken(t),this.isAuthorized=!0,p.state.isAuthorized=!0,d.setIsAuthorized(!0)}getAccessToken(){return fetch(this.accessTokenURL,{credentials:"include",headers:this.oauthHeaders(),method:"POST",body:t({grant_type:"authorization_code",scope:"printing",code:p.state.code,redirect_uri:this.redirectURI,code_verifier:p.state.codeVerifier})}).then((e=>e.json())).then((e=>{e.access_token&&this.persistTokens(e.access_token,e.refresh_token)}))}refreshTokens(){return fetch(this.accessTokenURL,{credentials:"include",headers:this.oauthHeaders(),method:"POST",body:t({grant_type:"refresh_token",scope:"printing",refresh_token:p.state.refreshToken})}).then((e=>e.json())).then((e=>{e.access_token&&this.persistTokens(e.access_token,e.refresh_token)}))}revokeRefreshToken(){p.state.refreshToken&&fetch(`https://${this.oauthUrl}/oauth/revoke/`,{credentials:"include",headers:this.oauthHeaders(),method:"POST",body:t({token:p.state.refreshToken})}).catch((()=>{}))}}const p=i({code:"",codeVerifier:"",accessToken:"",refreshToken:"",isAuthorized:!1,devApi:!1,authApiHostUrl:"",redirectUri:"",authUri:"",clientID:""});function g(){const e=new URLSearchParams(window.location.search).get("code");window.opener&&e&&(window.opener.postMessage(e,p.state.redirectUri),window.close())}export{f as E,p as a,g as b,i as c,d as s}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,createEvent as
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,createEvent as s,h as i,Host as n,transformTag as o}from"@stencil/core/internal/client";import{a,E as l}from"./auth.js";import{s as c,i as h}from"./utils.js";import{d as r}from"./ezp-dialog2.js";import{d as p}from"./ezp-icon2.js";import{d as u}from"./ezp-icon-button2.js";import{d}from"./ezp-label2.js";import{d as m}from"./ezp-status2.js";import{d as g}from"./ezp-text-button2.js";const z=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.authCancel=s(this,"authCancel",7),this.authSuccess=s(this,"authSuccess",7),this.userCancel=s(this,"userCancel",7),this.oauthPopupWindow=null,this.previousUrl=null,this.receiveMessage=t=>{if(this.oauthPopupWindow&&t.source&&t.source!==this.oauthPopupWindow)return void console.warn("[ezeep] Ignored auth message from an unexpected source window.");let e=null;try{e=new URL(this.redirectURI).origin}catch(t){e=null}e&&t.origin!==e?console.warn(`[ezeep] Ignored auth message from unexpected origin "${t.origin}" (expected "${e}").`):(a.state.code=t.data,this.auth.getAccessToken().then((()=>{this.authCancel.emit(),this.authSuccess.emit()})))}}listenDialogAction(){this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login")}listenDialogClose(){this.authCancel.emit()}listenStatusCancel(){this.authCancel.emit()}connectedCallback(){this.unsubscribeLanguage=c(this)}disconnectedCallback(){var t;null===(t=this.unsubscribeLanguage)||void 0===t||t.call(this),window.removeEventListener("message",this.receiveMessage)}openSignInWindow(t,e){var s;if(a.state.isAuthorized)return this.authCancel.emit(),void this.authSuccess.emit();window.removeEventListener("message",this.receiveMessage);const i="toolbar=no, menubar=no, width=600, height=7000, top=100, left=100";null===this.oauthPopupWindow||this.oauthPopupWindow.closed?this.oauthPopupWindow=window.open(t,e,i):this.previousUrl!==this.auth.authURI.toString()?(this.oauthPopupWindow=window.open(t,e,i),this.oauthPopupWindow&&!this.oauthPopupWindow.closed&&void 0!==this.oauthPopupWindow.closed||alert("popup blocked"),null===(s=this.oauthPopupWindow)||void 0===s||s.focus()):this.oauthPopupWindow.focus(),window.addEventListener("message",this.receiveMessage,!1),this.previousUrl=this.auth.authURI}async componentWillLoad(){this.auth=new l(this.redirectURI,this.clientID),this.code&&(a.state.code=this.code,await this.auth.getAccessToken(),this.authCancel.emit(),this.authSuccess.emit()),!1===a.state.isAuthorized&&(this.auth.generateCodeVerifier(),await this.auth.generateCodeChallenge(a.state.codeVerifier),this.auth.buildAuthURI()),this.hidelogin&&"button"===this.trigger&&this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login")}render(){return i(n,{key:"adde3ddd8f6afddc27c3a5503569b3c0d9eea420"},this.hidelogin&&"button"===this.trigger?i("ezp-status",{description:h.t("login_dialog.action"),processing:!0,cancel:!0}):this.hidelogin&&"file"===this.trigger?i("div",{class:"auth-actions"},i("ezp-text-button",{type:"button",level:"secondary",onClick:()=>this.userCancel.emit(),label:h.t("button_actions.cancel")}),i("ezp-text-button",{type:"button",level:"primary",onClick:()=>this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login"),label:h.t("button_actions.select_printer")})):i("ezp-dialog",{heading:h.t("login_dialog.heading"),description:h.t("login_dialog.description"),action:h.t("login_dialog.action"),iconName:"logo",iconSize:"huge",iconFramed:!1,instance:"login"}))}static get style(){return":host{--ezp-theme-solid:var(--ezp-accent-cyan-solid);--ezp-theme-translucent:var(--ezp-accent-cyan-translucent);display:block}.auth-actions{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;gap:var(--ezp-spacing-3);-ms-flex-pack:justify;justify-content:space-between;width:100%}.auth-actions ezp-text-button{-ms-flex:1;flex:1;max-width:calc(50% - var(--ezp-spacing-3) / 2)}"}},[1,"ezp-auth",{clientID:[1025,"client-i-d"],redirectURI:[1025,"redirect-u-r-i"],hidelogin:[4],trigger:[1],code:[1],auth:[32],authURI:[32],accessToken:[32]},[[0,"dialogAction","listenDialogAction"],[0,"dialogClose","listenDialogClose"],[0,"statusCancel","listenStatusCancel"]]]);function b(){"undefined"!=typeof customElements&&["ezp-auth","ezp-dialog","ezp-icon","ezp-icon-button","ezp-label","ezp-status","ezp-text-button"].forEach((t=>{switch(t){case"ezp-auth":customElements.get(o(t))||customElements.define(o(t),z);break;case"ezp-dialog":customElements.get(o(t))||r();break;case"ezp-icon":customElements.get(o(t))||p();break;case"ezp-icon-button":customElements.get(o(t))||u();break;case"ezp-label":customElements.get(o(t))||d();break;case"ezp-status":customElements.get(o(t))||m();break;case"ezp-text-button":customElements.get(o(t))||g()}}))}export{z as E,b as d}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as a,Host as o,transformTag as n}from"@stencil/core/internal/client";const s=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.backdropHideStart=i(this,"backdropHideStart",7),this.backdropHideEnd=i(this,"backdropHideEnd",7),this.visible=!0}handleClick(){this.visible=!1,this.backdropHideStart.emit()}listenAnimationEnd(){this.visible||this.backdropHideEnd.emit()}render(){return a(o,{key:"
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as a,Host as o,transformTag as n}from"@stencil/core/internal/client";const s=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.backdropHideStart=i(this,"backdropHideStart",7),this.backdropHideEnd=i(this,"backdropHideEnd",7),this.visible=!0}handleClick(){this.visible=!1,this.backdropHideStart.emit()}listenAnimationEnd(){this.visible||this.backdropHideEnd.emit()}render(){return a(o,{key:"723bc1fc67fbe5a491e80094ec2444f4d6f9ce32",class:{hide:!this.visible},onClick:()=>this.handleClick()})}get component(){return this}static get style(){return":host{-webkit-animation:var(--ezp-backdrop-animation-name, host-in) var(--ezp-duration-3) forwards var(--ezp-easing-out-quart);animation:var(--ezp-backdrop-animation-name, host-in) var(--ezp-duration-3) forwards var(--ezp-easing-out-quart);background:var(--ezp-core-backdrop);border-radius:var(--ezp-backdrop-border-radius, 6px);display:block;height:100%;left:0;opacity:0;position:absolute;top:0;width:100%;z-index:4}:host(.hide){--ezp-backdrop-animation-name:host-out}@-webkit-keyframes host-in{0%{opacity:0}100%{opacity:1}}@keyframes host-in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes host-out{0%{opacity:1}100%{opacity:0}}@keyframes host-out{0%{opacity:1}100%{opacity:0}}"}},[1,"ezp-backdrop",{visible:[1028]},[[0,"animationend","listenAnimationEnd"]]]);function r(){"undefined"!=typeof customElements&&["ezp-backdrop"].forEach((t=>{"ezp-backdrop"===t&&(customElements.get(n(t))||customElements.define(n(t),s))}))}export{s as E,r as d}
|