@ezeep/ezeep-js 1.0.316 → 1.0.323
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/ezeep.cjs.js +1 -1
- package/dist/cjs/ezp-auth_16.cjs.entry.js +137 -16
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ezp-auth/ezp-auth.js +99 -10
- package/dist/collection/components/ezp-user-menu/ezp-user-menu.css +7 -0
- package/dist/collection/services/auth.js +21 -0
- package/dist/collection/services/print-job.js +14 -2
- package/dist/components/auth.js +1 -1
- package/dist/components/ezp-auth2.js +1 -1
- package/dist/components/ezp-printer-selection2.js +1 -1
- package/dist/components/ezp-user-menu2.js +1 -1
- package/dist/components/utils.js +1 -1
- package/dist/esm/ezeep.js +1 -1
- package/dist/esm/ezp-auth_16.entry.js +137 -16
- package/dist/esm/loader.js +1 -1
- package/dist/esm-es5/ezeep.js +1 -1
- package/dist/esm-es5/ezp-auth_16.entry.js +2 -2
- package/dist/esm-es5/loader.js +1 -1
- package/dist/ezeep/ezeep.esm.js +1 -1
- package/dist/ezeep/{p-f348cbab.system.entry.js → p-5a755dc7.system.entry.js} +2 -2
- package/dist/ezeep/p-DCznw2Ee.system.js +1 -1
- package/dist/ezeep/p-f567a8c5.entry.js +1 -0
- package/dist/types/components/ezp-auth/ezp-auth.d.ts +34 -0
- package/dist/types/services/auth.d.ts +13 -1
- package/package.json +3 -2
- package/www/build/ezeep.esm.js +1 -1
- package/www/build/p-570b689d.js +1 -0
- package/www/build/{p-f348cbab.system.entry.js → p-5a755dc7.system.entry.js} +2 -2
- package/www/build/p-DCznw2Ee.system.js +1 -1
- package/www/build/p-f567a8c5.entry.js +1 -0
- package/www/data/locales/de.json +2 -2
- package/www/data/locales/en.json +2 -2
- package/www/index.html +1 -1
- package/dist/ezeep/p-98a77798.entry.js +0 -1
- package/www/build/p-4f218598.js +0 -1
- package/www/build/p-98a77798.entry.js +0 -1
|
@@ -40,19 +40,31 @@ export async function waitForJobCompletion(getStatus, isQueue, pollIntervalMs =
|
|
|
40
40
|
* any failure, so callers can aggregate per-file outcomes.
|
|
41
41
|
*/
|
|
42
42
|
export async function uploadAndPrintFile(ctx, file, hooks = {}) {
|
|
43
|
-
var _a, _b, _c, _d
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
44
|
(_a = hooks.onPreparing) === null || _a === void 0 ? void 0 : _a.call(hooks, true);
|
|
45
45
|
const response = await ctx.service.prepareFileUpload(ctx.accessToken);
|
|
46
46
|
(_b = hooks.onPreparing) === null || _b === void 0 ? void 0 : _b.call(hooks, false);
|
|
47
47
|
const fileid = response.fileid;
|
|
48
48
|
const sasUri = response.sasUri;
|
|
49
49
|
const filetype = fileExtension(file.name);
|
|
50
|
+
// The upload stage ends as soon as the blob is stored — not when the whole
|
|
51
|
+
// job does — so the UI moves on from "Uploading…" to "Printing…" while the
|
|
52
|
+
// job is submitted and polled. `finally` covers a failed upload.
|
|
53
|
+
let uploading = true;
|
|
54
|
+
const uploadDone = () => {
|
|
55
|
+
var _a;
|
|
56
|
+
if (!uploading)
|
|
57
|
+
return;
|
|
58
|
+
uploading = false;
|
|
59
|
+
(_a = hooks.onUploading) === null || _a === void 0 ? void 0 : _a.call(hooks, false);
|
|
60
|
+
};
|
|
50
61
|
(_c = hooks.onUploading) === null || _c === void 0 ? void 0 : _c.call(hooks, true);
|
|
51
62
|
try {
|
|
52
63
|
const res = await ctx.service.uploadBlobFiles(sasUri, file);
|
|
53
64
|
if (res._response.status !== BLOB_UPLOAD_CREATED) {
|
|
54
65
|
throw new Error(`Upload failed for file: ${file.name}`);
|
|
55
66
|
}
|
|
67
|
+
uploadDone();
|
|
56
68
|
const data = await ctx.service.printByFileID(ctx.accessToken, fileid, filetype, ctx.printerId, ctx.properties, file.name);
|
|
57
69
|
if (data.code === PRINT_REJECTED_CODE) {
|
|
58
70
|
throw new Error(`Print failed for file: ${file.name}`);
|
|
@@ -67,6 +79,6 @@ export async function uploadAndPrintFile(ctx, file, hooks = {}) {
|
|
|
67
79
|
await waitForJobCompletion(() => ctx.service.getPrintStatus(), ctx.isQueue, ctx.pollIntervalMs);
|
|
68
80
|
}
|
|
69
81
|
finally {
|
|
70
|
-
(
|
|
82
|
+
uploadDone();
|
|
71
83
|
}
|
|
72
84
|
}
|
package/dist/components/auth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"@stencil/core/internal/client";import{k 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)}})(),n=e.forceUpdate,o=e.getRenderingRef,s=(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},n=r();let o=new Map(Object.entries(n));const i="undefined"!=typeof Proxy,c=i?null:{},a={dispose:[],get:[],set:[],reset:[]},h=new Map,l=()=>{o=new Map(Object.entries(r())),i||
|
|
1
|
+
import*as e from"@stencil/core/internal/client";import{k 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)}})(),n=e.forceUpdate,o=e.getRenderingRef,s=(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},n=r();let o=new Map(Object.entries(n));const i="undefined"!=typeof Proxy,c=i?null:{},a={dispose:[],get:[],set:[],reset:[]},h=new Map,l=()=>{o=new Map(Object.entries(r())),i||w(),a.reset.forEach((e=>e()))},u=e=>(a.get.forEach((t=>t(e))),o.get(e)),d=(e,r)=>{const n=o.get(e);t(r,n,e)&&(o.set(e,r),i||g(e),a.set.forEach((t=>t(e,r,n))))},f=i?new Proxy(n,{get:(e,t)=>u(t),ownKeys:()=>Array.from(o.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(e,t)=>o.has(t),set:(e,t,r)=>(d(t,r),!0)}):(w(),c),p=(e,t)=>(a[e].push(t),()=>{s(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 w(){if(i||!c)return;const e=new Set(o.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 n=(r,n)=>{r===e&&t(n)},o=()=>{const n=r();t(n[e])},s=p("set",n),i=p("reset",o);return h.set(t,{setHandler:n,resetHandler:o,propName:e}),()=>{s(),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=o.get(e);a.set.forEach((r=>r(e,t,t)))},removeListener:(e,t)=>{const r=h.get(t);r&&r.propName===e&&(s(a.set,r.setHandler),s(a.reset,r.resetHandler),h.delete(t))}}})(e,t);return i.use((()=>{if("function"!=typeof o||"function"!=typeof n)return{};const e=n,t=o,s=new Map;return{dispose:()=>s.clear(),get:e=>{const r=t();r&&((e,t,r)=>{let n=e.get(t);n||(n=[],e.set(t,n)),n.some((e=>e.deref()===r))||n.push(new WeakRef(r))})(s,e,r)},set:t=>{const n=s.get(t);if(n){const r=n.filter((t=>{const r=t.deref();return!!r&&e(r)}));s.set(t,r)}r(s)},reset:()=>{s.forEach((t=>{t.forEach((t=>{const r=t.deref();r&&e(r)}))})),r(s)}}})()),i},c="refreshToken",a="isAuthorized",h="printer",l="printerSettings";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),getPrinterSettings(e){var t;return null!==(t=f()[e])&&void 0!==t?t:null},setPrinterSettings(e,t){const r=f();r[e]=t,localStorage.setItem(l,JSON.stringify(r))},getPrinter:()=>u(h),setPrinter(e){localStorage.setItem(h,JSON.stringify(e))},clearSession(){localStorage.removeItem(c),localStorage.removeItem("access_token"),localStorage.removeItem(a)},clearSavedPrinter(){localStorage.removeItem(h)}};function f(){const e=u(l);if(e)return e;const t=u("properties"),r=u(h);return t&&(null==r?void 0:r.id)?{[r.id]:t}:{}}class p{constructor(e,t){this.urlParams=new URLSearchParams,this.isAuthorized=!1,this.redirectURI=e,this.clientID=t,g.state.clientID=t,this.oauthUrl=g.state.authApiHostUrl,this.authURI=new URL(`https://${this.oauthUrl}/oauth/authorize/`),this.accessTokenURL=`https://${this.oauthUrl}/oauth/access_token/`}generateCodeVerifier(){if(""!==g.state.codeVerifier)this.codeVerifier=g.state.codeVerifier;else{const e=new Uint8Array(128),t=crypto.getRandomValues(e),r=btoa(t.toString()).substr(0,128);this.codeVerifier=r,g.state.codeVerifier=this.codeVerifier}}async generateCodeChallenge(e){const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t),n=btoa(String.fromCharCode(...new Uint8Array(r)));this.codeChallenge=n.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(),g.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,g.state.accessToken=e,this.refreshToken=t,g.state.refreshToken=t,d.setRefreshToken(t),this.isAuthorized=!0,g.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:g.state.code,redirect_uri:this.redirectURI,code_verifier:g.state.codeVerifier})}).then((e=>e.json())).then((e=>{var t;if(e.access_token)return this.persistTokens(e.access_token,e.refresh_token),g.state.exchangedCode=g.state.code,!0;if("invalid_grant"===e.error)return!1;throw new Error(`Token endpoint error: ${null!==(t=e.error)&&void 0!==t?t:"unexpected response"}`)}))}refreshTokens(){return fetch(this.accessTokenURL,{credentials:"include",headers:this.oauthHeaders(),method:"POST",body:t({grant_type:"refresh_token",scope:"printing",refresh_token:g.state.refreshToken})}).then((e=>e.json())).then((e=>{e.access_token&&this.persistTokens(e.access_token,e.refresh_token)}))}revokeRefreshToken(){g.state.refreshToken&&fetch(`https://${this.oauthUrl}/oauth/revoke/`,{credentials:"include",headers:this.oauthHeaders(),method:"POST",body:t({token:g.state.refreshToken})}).catch((()=>{}))}}const g=i({code:"",exchangedCode:"",codeVerifier:"",accessToken:"",refreshToken:"",isAuthorized:!1,devApi:!1,authApiHostUrl:"",redirectUri:"",authUri:"",clientID:""});function w(){const e=new URLSearchParams(window.location.search).get("code");window.opener&&e&&(window.opener.postMessage(e,g.state.redirectUri),window.close())}export{p as E,g as a,w as b,i as c,d as s}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,Host as o,transformTag as n}from"@stencil/core/internal/client";import{a,E as h}from"./auth.js";import{s as c,i as l}from"./utils.js";import{d}from"./ezp-dialog2.js";import{d as r}from"./ezp-icon2.js";import{d as p}from"./ezp-icon-button2.js";import{d as u}from"./ezp-label2.js";import{d as g}from"./ezp-status2.js";import{d as m}from"./ezp-text-button2.js";const z=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.authCancel=i(this,"authCancel",7),this.authSuccess=i(this,"authSuccess",7),this.userCancel=i(this,"userCancel",7),this.popupBlocked=i(this,"popupBlocked",7),this.isPopupBlocked=!1,this.codeExchangePending=!1,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.exchangeCode())}}listenDialogAction(t){"popup-blocked"!==t.detail?this.codeExchangePending?this.retryHostCode():this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login"):this.handleRetry()}listenDialogClose(t){"popup-blocked"===t.detail&&(this.isPopupBlocked=!1,this.showsSignInStatus())||this.codeExchangePending&&this.showsSignInStatus()?this.listenStatusCancel():this.authCancel.emit()}listenStatusCancel(){"file"===this.trigger?this.userCancel.emit():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 i;if(a.state.isAuthorized)return this.authCancel.emit(),void this.authSuccess.emit();window.removeEventListener("message",this.receiveMessage);const s="toolbar=no, menubar=no, width=600, height=7000, top=100, left=100";if(null===this.oauthPopupWindow||this.oauthPopupWindow.closed){if(this.oauthPopupWindow=window.open(t,e,s),this.isWindowBlocked(this.oauthPopupWindow))return void this.handlePopupBlocked()}else if(this.previousUrl!==this.auth.authURI.toString()){const o=this.oauthPopupWindow;if(this.oauthPopupWindow=window.open(t,e,s),this.isWindowBlocked(this.oauthPopupWindow))return null==o||o.close(),void this.handlePopupBlocked();null===(i=this.oauthPopupWindow)||void 0===i||i.focus()}else this.oauthPopupWindow.focus();window.addEventListener("message",this.receiveMessage,!1),this.previousUrl=this.auth.authURI.toString()}showsSignInStatus(){return this.hidelogin&&("button"===this.trigger||"file"===this.trigger)}isWindowBlocked(t){return!t||t.closed||void 0===t.closed}handlePopupBlocked(){this.oauthPopupWindow=null,this.isPopupBlocked=!0,this.popupBlocked.emit()}handleRetry(){this.isPopupBlocked=!1,this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login")}async exchangeCode(){let t;try{t=!0===await this.auth.getAccessToken()?"signed-in":"rejected"}catch(e){t="failed"}return"signed-in"!==t?(console.warn("rejected"===t?"[ezeep] Sign-in failed: the authorization code was rejected.":"[ezeep] Sign-in failed: the authorization code could not be exchanged."),t):(this.authCancel.emit(),this.authSuccess.emit(),t)}async exchangeHostCode(){a.state.code=this.code;const t=await this.exchangeCode();return this.codeExchangePending="failed"===t,t}async retryHostCode(){"rejected"===await this.exchangeHostCode()&&this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login")}async componentWillLoad(){if(this.auth=new h(this.redirectURI,this.clientID),this.code){if(a.state.isAuthorized&&this.code===a.state.exchangedCode)return this.authCancel.emit(),void this.authSuccess.emit();if("signed-in"===await this.exchangeHostCode())return}!1===a.state.isAuthorized&&(this.auth.generateCodeVerifier(),await this.auth.generateCodeChallenge(a.state.codeVerifier),this.auth.buildAuthURI()),this.codeExchangePending||!this.hidelogin||"button"!==this.trigger&&"file"!==this.trigger||(a.state.isAuthorized?(this.authCancel.emit(),this.authSuccess.emit()):this.openSignInWindow(this.auth.authURI.toString(),"ezeep Login"))}render(){return s(o,{key:"91c2e44bba5f080dfe37a0e128ca9e1f769448be"},this.isPopupBlocked?s("ezp-dialog",{heading:l.t("popup_blocked_dialog.heading"),description:l.t("popup_blocked_dialog.description"),action:l.t("popup_blocked_dialog.action"),iconName:"exclamation-mark",instance:"popup-blocked",key:"popup-blocked"}):this.showsSignInStatus()&&!this.codeExchangePending?s("ezp-status",{description:l.t("login_dialog.action"),processing:!0,cancel:!0}):s("ezp-dialog",{heading:l.t("login_dialog.heading"),description:l.t("login_dialog.description"),action:l.t("login_dialog.action"),iconName:"logo",iconSize:"huge",iconFramed:!1,instance:"login",key:"login"}))}static get style(){return":host{--ezp-theme-solid:var(--ezp-accent-cyan-solid);--ezp-theme-translucent:var(--ezp-accent-cyan-translucent);display:block}"}},[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],isPopupBlocked:[32],codeExchangePending:[32]},[[0,"dialogAction","listenDialogAction"],[0,"dialogClose","listenDialogClose"],[0,"statusCancel","listenStatusCancel"]]]);function f(){"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(n(t))||customElements.define(n(t),z);break;case"ezp-dialog":customElements.get(n(t))||d();break;case"ezp-icon":customElements.get(n(t))||r();break;case"ezp-icon-button":customElements.get(n(t))||p();break;case"ezp-label":customElements.get(n(t))||u();break;case"ezp-status":customElements.get(n(t))||g();break;case"ezp-text-button":customElements.get(n(t))||m()}}))}export{z as E,f as d}
|