@digital-realty/app-shell 13.0.9 → 13.0.10

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/bootstrap.js CHANGED
@@ -1 +1 @@
1
- import{__decorate as P}from"tslib";import{LitElement as b,html as c}from"lit";import{property as R}from"lit/decorators.js";import{ApplicationInsights as te,DistributedTracingModes as se}from"@microsoft/applicationinsights-web";import{authedUser as T}from"@digital-realty/ix-account-switcher";import{UserManager as ne}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as oe,action as re,observable as ae,toJS as ie}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:le,PortalGlobalPortal:ce,PortalServiceFabric:ue,PortalMarketplacePortal:pe}=i(),de={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},me={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell"},v="globalportalappshell",p="user-authentication",E="redirect-url",ge="ui-cookie-policy",he="date-format",y="Global Portal",N="Service Fabric",O="Marketplace Portal",k="EMEA Customer Portal",L="x-auth",[d,_e,Ee,fe]=["CREATE","UPDATE","READ","APPROVE"],[x,f,we,Ce,U,Se,Ct,Ae,M,St,Ie,Pe,D,V,G,At,be,It,Re,j,$,H,Te,B,ve,ye,F,Ne]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],Oe=[Re,Se,ve,Te,ye,be,Ce],ke=[f,x,U,D,V,G,j,$,H,B],z=[f,x,U,D,V,G,j,$,H,B],Le={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},K={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[xe,Ue,Me]=["Security","DCIM","Planned Site Maintenance"],De=[xe,Ue,Me],Ve=[{label:y,href:ce,selected:!0},{label:O,href:pe},{label:k,href:le},{label:N,href:ue,target:"_blank"}],J={appInsights:"_appInsights"},Ge=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new te({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:se.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=v}),s},m=(e,t,s)=>(...n)=>{const[o,...r]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:r[0].message,stack:r[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},r),e.apply(console,[o,...r])},je=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},$e=()=>{const e=Ge();window[J.appInsights]=e,window.dispatchEvent(new Event("appInsightsInitialized")),je(e)},W=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function He(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:r}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:r,monitorSession:!1}}const w=new ne(He()),Be=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},Fe=()=>{localStorage.removeItem(p)},l=()=>{const e=localStorage.getItem(p);return e?JSON.parse(e):null},Y=()=>{var e;const t=localStorage.getItem(L);return t?(e=JSON.parse(t))==null?void 0:e.email:null},ze=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await W(t)},q=()=>{const e=l();return e?e.id_token:null},X=(e,t)=>{const s={...t,...e},n=Be(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),T.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(p,JSON.stringify(s)),s},Ke=e=>{X(e,null)},Q=()=>{const e=l();return e?e.access_token:null},Je=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},We=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},Ye=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},qe=["authenticate","auth-callback","logout"],Xe=e=>e.expires_at&&new Date(e.expires_at*1e3),Qe=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Z=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!q())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>Xe(e):t>Qe(e)},Ze=()=>{const e=window.location.pathname.split("/");return qe.includes(e[e.length-1])},et=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?w.signinRedirect():window.location.href="/",!0):!1},tt=()=>{let e="/";const t=localStorage.getItem(E);t&&(localStorage.removeItem(E),e=t),sessionStorage.setItem(K.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},st=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},C=e=>{const t=Ze();(!t||e)&&(t||localStorage.setItem(E,window.location.href),window.location.href="/authenticate")},nt=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await W(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},ot=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(w.signinRedirectCallback().then(st).then(nt).then(Ke).then(tt).catch(C),!0):!1};class rt extends b{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",rt);var at=Object.defineProperty,it=(e,t,s)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,S=(e,t,s)=>it(e,typeof t!="symbol"?t+"":t,s);class lt{constructor(){S(this,"permissions",[]),S(this,"loading",!1),S(this,"getPermissions",async()=>{var t;const s=(t=T)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]}),oe(this,{permissions:ae,setPermissions:re})}setPermissions(t){this.permissions=t.reduce((s,n)=>(s[n.permission_name]=n.privilege,s),{})}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(M,d)||this.hasPermission(F,d)}hasConnectivityCreate(){return this.hasPermission(f,d)}hasPrivilegeLevel(t,s){const n=[fe,d,_e,Ee],o=n.findIndex(a=>a===t),r=n.findIndex(a=>a===s);return o>=r}hasPermission(t,s){let n=!1;const o=ie(this.permissions),r=Object.keys(o).find(a=>a===t);return r&&(n=this.hasPrivilegeLevel(s,o[r])),n}}const A=new lt,ee=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${Q()}`),e},ct=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const r=await fetch(`${t}&cursor=${n}`,{headers:ee()});if(!r.ok)return Promise.reject();const a=await r.json();if(s.push(...a.items),a.self===a.last)break;n++}s=s.filter(r=>r.permissions.some(a=>z.includes(a.name)));const o=new Map;for(const r of s)o.has(r.account_number)?o.get(r.account_number).push(r.site_id):o.set(r.account_number,[r.site_id]);return o},ut=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const r=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:ee()});return r.ok?await r.json():Promise.reject()},pt=async()=>{try{const e=await ct();return e.size===0?!1:(await ut(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}};class I extends b{constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&Z()&&C()};try{$e()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(et()||ot()){this._currentView="splash";return}if(Z()){this._currentView="splash",C();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-CEMELcLl.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var s,n,o;const r=Y(),a=structuredClone(window.gpConfig);if(!r||!a)return t;const g=((s=i().SuperusersWhitelist)!=null?s:"").split(",").map(_=>_.trim().toLowerCase()).includes(r.toLowerCase()),h=!!((n=t["ui-gom"])!=null&&n.enabled)&&!!((o=a["ui-launchpad"])!=null&&o.IsInventoryManagementEnabled),u=await pt()&&(g||h);return a["app-shell"].IsInventoryManagementEnabled=u,a["ui-launchpad"].IsInventoryManagementEnabled=u,window.gpConfig=Object.freeze(a),t["ui-gom"]?{...t,"ui-gom":{...t["ui-gom"],enabled:u}}:t}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(_=>_.json()),A.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:r}=n.value,a=o.value,g=(t=this._getAccountNumber())!=null?t:"",h=this._isESGAccessOnly(a,g)?this._applyMfeOverrides(r,["ui-esg"]):r,u=await this._applyGomFF(h);window.registeredApps=Object.freeze(u),A.setPermissions(a),await import("./app-3ukRjcHW.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}P([R({type:String})],I.prototype,"_currentView",void 0),P([R({type:Boolean})],I.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",I);export{Le as A,ge as B,we as C,he as D,Ne as E,me as F,y as G,ke as I,O as M,z as O,De as R,Oe as S,F as U,q as a,ze as b,Fe as c,Y as d,Q as e,l as f,i as g,X as h,Ye as i,Je as j,K as k,Pe as l,M as m,Ae as n,Ie as o,A as p,k as q,Ve as r,N as s,J as t,w as u,v,We as w,p as x,L as y,de as z};
1
+ import{__decorate as I}from"tslib";import{LitElement as P,html as c}from"lit";import{property as b}from"lit/decorators.js";import{ApplicationInsights as ee,DistributedTracingModes as te}from"@microsoft/applicationinsights-web";import{authedUser as R}from"@digital-realty/ix-account-switcher";import{UserManager as se}from"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import{makeObservable as ne,action as oe,observable as ae,toJS as re}from"mobx";function i(){var e;const t=(e=window.gpConfig)==null?void 0:e["app-shell"];if(!t)throw new Error("App-shell config not loaded. Ensure config.json is fetched before app bootstrap.");return t}const{PortalInterxion:ie,PortalGlobalPortal:le,PortalServiceFabric:ce,PortalMarketplacePortal:pe}=i(),ue={strict:"strictly_necessary",performance:"performance",targeting:"targeting"},de={accept:"accept_all",reject:"reject_all",custom:"customize",no:"no_sell",bypass:"gpc_bypass"},T="globalportalappshell",u="user-authentication",E="redirect-url",me="ui-cookie-policy",ge="date-format",y="Global Portal",v="Service Fabric",N="Marketplace Portal",O="EMEA Customer Portal",k="x-auth",[d,he,_e,Ee]=["CREATE","UPDATE","READ","APPROVE"],[L,f,fe,Ce,x,Se,Et,we,U,ft,Ae,Ie,M,D,V,Ct,Pe,St,be,G,j,$,Re,H,Te,ye,B,ve]=["Cloud Connect","Cross Connect","Custom Roles","Customer Care","Customer Equipment Connection (CEC)","Customer Support","DCIM-enabled location data","Default System Roles","External User","Facility Access","Internal Roles","Internal User","Internet Exchange","Intra-Customer Connectivity (ICC)","IP Bandwidth","OSP Access","Permanent Badge","PoP/POE Room Access","Remote Hands","Remote Hands Package","Service Exchange Cloud Router","Service Exchange Port","Shipping & Receiving","Space & Power","Trouble Ticket","Visitor Access","User","ESG Reporting"],Ne=[be,Se,Te,Re,ye,Pe,Ce],Oe=[f,L,x,M,D,V,G,j,$,H],F=[f,L,x,M,D,V,G,j,$,H],ke={LocationChanged:"location-changed",VaadinRouterLocationChanged:"vaadin-router-location-changed",CreateUserClicked:"create-user-clicked"},z={SessionStorage:{HasOutstandingChanges:"hasOutstandingChanges",ShowLastLoginPopup:"showLastLoginPopup"}},[Le,xe,Ue]=["Security","DCIM","Planned Site Maintenance"],Me=[Le,xe,Ue],De=[{label:y,href:le,selected:!0},{label:N,href:pe},{label:O,href:ie},{label:v,href:ce,target:"_blank"}],K={appInsights:"_appInsights"},Ve=()=>{const{ApplicationInsightsInstrumentationKey:e,ApplicationInsightsCorrelationHeaderExcludedDomains:t}=i(),s=new ee({config:{instrumentationKey:e,enableCorsCorrelation:!0,enableRequestHeaderTracking:!0,enableResponseHeaderTracking:!0,enableAutoRouteTracking:!0,autoTrackPageVisitTime:!0,enableAjaxErrorStatusText:!0,enableAjaxPerfTracking:!0,enableUnhandledPromiseRejectionTracking:!0,isCookieUseDisabled:!0,distributedTracingMode:te.AI_AND_W3C,correlationHeaderExcludedDomains:t.split(",").map(n=>n.trim())}});return s.loadAppInsights(),s.trackPageView(),s.addTelemetryInitializer(n=>{n.tags["ai.cloud.role"]=T}),s},m=(e,t,s)=>(...n)=>{const[o,...a]=n;typeof o=="string"&&o.startsWith("[mobx]")&&t===4?s.trackException({exception:{message:a[0].message,stack:a[0].stack,name:o},severityLevel:4}):s.trackTrace({severityLevel:t,message:o},a),e.apply(console,[o,...a])},Ge=e=>{console.log=m(console.log,2,e),console.info=m(console.info,2,e),console.warn=m(console.warn,3,e),console.error=m(console.error,4,e),window.console=console},je=()=>{const{ApplicationInsightsInstrumentationKey:e}=i();if(!e)return;const t=Ve();window[K.appInsights]=t,window.dispatchEvent(new Event("appInsightsInitialized")),Ge(t)},J=async e=>{const t=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(s)).map(n=>n.toString(16).padStart(2,"0")).join("")};function $e(){const{location:e}=window,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}`,{LoginAuthority:s,GlobalPortalClientId:n,GlobalPortalUIScopes:o,GlobalPlanBShellPostLogoutRedirectUrl:a}=i();return{authority:s,client_id:n,redirect_uri:`${t}/auth-callback`,response_type:"code",scope:o,post_logout_redirect_uri:a,monitorSession:!1}}const C=new se($e()),He=e=>{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(window.atob(t).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(s)},Be=()=>{localStorage.removeItem(u)},l=()=>{const e=localStorage.getItem(u);return e?JSON.parse(e):null},W=()=>{var e;const t=localStorage.getItem(k);return t?(e=JSON.parse(t))==null?void 0:e.email:null},Fe=async()=>{const e=l();if(!e)return null;const t=(e.profile.given_name||"")+(e.profile.family_name||"")+e.profile.sub;return await J(t)},Y=()=>{const e=l();return e?e.id_token:null},q=(e,t)=>{const s={...t,...e},n=He(e.access_token);return s.profile.sub=n.sub,s.profile.account_number=n.account_number,s.expires_at=n.exp,s.is_federated=n.is_federated,n.previous_login_date&&(s.profile.previous_login_date=n.previous_login_date),R.setAccount({accountNumber:n.account_number,email:n.email,name:n.name,givenName:n.given_name,familyName:n.family_name,authTime:n.exp,accessToken:e.access_token,idToken:e.id_token}),localStorage.setItem(u,JSON.stringify(s)),s},ze=e=>{q(e,null)},X=()=>{const e=l();return e?e.access_token:null},Ke=()=>{const e=l();return e&&e.is_federated!==null&&e.is_federated!==void 0?String(e.is_federated).toLowerCase()==="true":!1},Je=()=>{const e=l();return e!=null&&e.expires_at?e.expires_at>Date.now()/1e3:!1},We=()=>{var e;const t=l();return((e=t==null?void 0:t.profile)==null?void 0:e.previous_login_date)||null},Ye=["authenticate","auth-callback","logout"],qe=e=>e.expires_at&&new Date(e.expires_at*1e3),Xe=e=>e.expires_at&&new Date(e.expires_at*1e3+i().TokenValidForOfflineUsePostExpiryInHours*60*60*1e3),Q=()=>{if(!i().IsLoginEnabled)return!1;const e=l();if(!Y())return!0;if(!e.expires_at)return!1;const t=new Date;return navigator.onLine?t>qe(e):t>Xe(e)},Qe=()=>{const e=window.location.pathname.split("/");return Ye.includes(e[e.length-1])},Ze=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="authenticate"?(i().IsLoginEnabled?C.signinRedirect():window.location.href="/",!0):!1},et=()=>{let e="/";const t=localStorage.getItem(E);t&&(localStorage.removeItem(E),e=t),sessionStorage.setItem(z.SessionStorage.ShowLastLoginPopup,"true"),window.location.href=e},tt=e=>{if(!e.id_token)throw new Error("Missing property:id_token");return e},S=e=>{const t=Qe();(!t||e)&&(t||localStorage.setItem(E,window.location.href),window.location.href="/authenticate")},st=async e=>{const t=`${e.profile.sub}-${e.profile.customer_id}`,s=await J(t);return{...e,profile:{...e.profile,hashed_identifier:s}}},nt=()=>{const e=window.location.pathname.split("/");return e[e.length-1]==="auth-callback"?(C.signinRedirectCallback().then(tt).then(st).then(ze).then(et).catch(S),!0):!1};class ot extends P{render(){return c` <ix-splash-screen></ix-splash-screen> `}}window.customElements.define("splash-screen",ot);class at{constructor(){this.permissions=[],this.loading=!1,this.getPermissions=async()=>{var t;const s=(t=R)==null?void 0:t.access_token;if(!s)return[];const{ApiBaseUrl:n}=i(),o=await fetch(`${n}/usermanagement/my-permissions?exclude_parents=false&exclude_siblings=true`,{headers:{Authorization:`Bearer ${s}`}});return o.ok?o.json():[]},ne(this,{permissions:ae,setPermissions:oe})}setPermissions(t){this.permissions=t.reduce((s,n)=>(s[n.permission_name]=n.privilege,s),{})}tryLoadPermissions(){try{this.loading||(this.loading=!0,this.getPermissions().then(t=>{this.setPermissions(t),this.loading=!1}).catch(()=>{this.loading=!1}))}catch(t){this.loading=!1}}clearPermissions(){this.setPermissions([])}hasExternalUserCreate(){return this.hasPermission(U,d)||this.hasPermission(B,d)}hasConnectivityCreate(){return this.hasPermission(f,d)}hasPrivilegeLevel(t,s){const n=[Ee,d,he,_e],o=n.findIndex(r=>r===t),a=n.findIndex(r=>r===s);return o>=a}hasPermission(t,s){let n=!1;const o=re(this.permissions),a=Object.keys(o).find(r=>r===t);return a&&(n=this.hasPrivilegeLevel(s,o[a])),n}}const w=new at,Z=()=>{const e=new Headers;return e.append("Authorization",`Bearer ${X()}`),e},rt=async()=>{const{ApiBaseUrl:e}=i(),t=`${e}/inventory/locations?embed=permissions&page_size=1000`;let s=[],n=1;for(;;){const a=await fetch(`${t}&cursor=${n}`,{headers:Z()});if(!a.ok)return Promise.reject();const r=await a.json();if(s.push(...r.items),r.self===r.last)break;n++}s=s.filter(a=>a.permissions.some(r=>F.includes(r.name)));const o=new Map;for(const a of s)o.has(a.account_number)?o.get(a.account_number).push(a.site_id):o.set(a.account_number,[a.site_id]);return o},it=async e=>{const{ApiBaseUrl:t}=i(),s=new URLSearchParams;s.append("process","Cross_connect");const n=[...e.keys()],o=[...new Set([...e.values()].flat())];s.append("account_number",n.join(",")),s.append("site",o.join(","));const a=await fetch(`${t}/site-navigations/site-configurations?${s}`,{headers:Z()});return a.ok?await a.json():Promise.reject()},lt=async()=>{try{const e=await rt();return e.size===0?!1:(await it(e)).some(t=>{var s;return t.portal==="GlobalPortal"&&!!((s=e.get(t.account_number))!=null&&s.includes(t.site))})}catch(e){return console.error("Failed to determine portal-managed inventory:",e),!1}};class A extends P{constructor(){super(),this._currentView="splash",this.appLoaded=!1,this._onPopState=()=>{i().IsLoginEnabled&&Q()&&S()};try{je()}catch(s){console.error("Telemetry initialization failed:",s)}const t=window.location.pathname;if(t==="/session-expired"){this._currentView="session-expired",this._loadView("session-expired");return}if(t==="/logout"){this._currentView="logout",this._loadView("logout");return}if(Ze()||nt()){this._currentView="splash";return}if(Q()){this._currentView="splash",S();return}this._currentView="app",this._loadApp()}async _loadView(t){t==="session-expired"?await import("@digital-realty/ix-app-logic/views/session-expiry.js"):t==="logout"&&await import("./logout-DHu3NPe-.js")}connectedCallback(){super.connectedCallback(),window.addEventListener("popstate",this._onPopState)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("popstate",this._onPopState)}_getAccountNumber(){var t,s,n;return(n=new URLSearchParams(window.location.search).get("selected_account_number"))!=null?n:(s=(t=l())==null?void 0:t.profile)==null?void 0:s.account_number}_isESGAccessOnly(t,s){const n=t.filter(o=>o.account_number===s);return n.length===1&&n[0].permission_name==="ESG Reporting"}async _applyGomFF(t){var s,n,o;const a=W(),r=structuredClone(window.gpConfig);if(!a||!r)return t;const g=((s=i().SuperusersWhitelist)!=null?s:"").split(",").map(_=>_.trim().toLowerCase()).includes(a.toLowerCase()),h=!!((n=t["ui-gom"])!=null&&n.enabled)&&!!((o=r["ui-launchpad"])!=null&&o.IsInventoryManagementEnabled),p=await lt()&&(g||h);return r["app-shell"].IsInventoryManagementEnabled=p,r["ui-launchpad"].IsInventoryManagementEnabled=p,window.gpConfig=Object.freeze(r),t["ui-gom"]?{...t,"ui-gom":{...t["ui-gom"],enabled:p}}:t}_applyMfeOverrides(t,s){const n={};for(const o of Object.keys(t))n[o]={...t[o],enabled:s.includes(o)};return n}async _loadApp(){var t;const{authedUser:s}=await import("@digital-realty/ix-account-switcher");await s.hydrateStore();const[n,o]=await Promise.allSettled([fetch("./registered-apps.json").then(_=>_.json()),w.getPermissions()]);if(n.status==="rejected"){console.error("Failed to load registered apps:",n.reason);return}if(o.status==="rejected"){console.error("Failed to load permissions:",o.reason);return}const{registeredApps:a}=n.value,r=o.value,g=(t=this._getAccountNumber())!=null?t:"",h=this._isESGAccessOnly(r,g)?this._applyMfeOverrides(a,["ui-esg"]):a,p=await this._applyGomFF(h);window.registeredApps=Object.freeze(p),w.setPermissions(r),await import("./app-V8jsWuSg.js"),this.appLoaded=!0}render(){switch(this._currentView){case"session-expired":return c`<ix-session-expiry></ix-session-expiry>`;case"logout":return c`<ixp-logout></ixp-logout>`;case"app":return this.appLoaded?c`<global-portal-app appTitle="DLR" showDrawer></global-portal-app>`:c`<splash-screen></splash-screen>`;default:return c`<splash-screen></splash-screen>`}}}I([b({type:String})],A.prototype,"_currentView",void 0),I([b({type:Boolean})],A.prototype,"appLoaded",void 0),window.customElements.define("gp-bootstrap",A);export{ke as A,k as B,fe as C,ge as D,ve as E,me as F,y as G,Oe as I,N as M,F as O,Me as R,Ne as S,B as U,Y as a,Fe as b,Be as c,W as d,X as e,l as f,i as g,q as h,We as i,Ke as j,z as k,Ie as l,U as m,we as n,Ae as o,w as p,O as q,De as r,v as s,K as t,C as u,T as v,ue as w,Je as x,de as y,u as z};
@@ -0,0 +1 @@
1
+ import{LitElement as c,html as l}from"lit";import{appState as s}from"@digital-realty/ix-app-logic/state/app-state.js";import{g,a as m,u as i,c as h}from"./bootstrap.js";import"tslib";import"lit/decorators.js";import"@microsoft/applicationinsights-web";import"@digital-realty/ix-account-switcher";import"oidc-client-ts";import"@digital-realty/ix-app-logic/views/splash-screen.js";import"mobx";class a extends c{constructor(){super(...arguments),this.isIdle=!1,this.clearLocalStorageExcept=e=>{const r=new Set((typeof e=="string"?e.split(","):[]).map(t=>t.trim().toLowerCase())),o=[];Object.keys(window.localStorage).forEach(t=>{Array.from(r).some(n=>t.toLowerCase().includes(n))||o.push(t)}),o.forEach(t=>window.localStorage.removeItem(t))},this.clearGridSessionStorage=()=>{Object.keys(sessionStorage).filter(e=>e.startsWith("grid-")).forEach(e=>sessionStorage.removeItem(e))},this.logout=async()=>{const{PreserveLocalStorageItems:e,PreventLogoutOnTimeout:r}=g();s.lastActive=-1,await s.hydrateStore(),await s.getStoredData();const o=m();this.clearState(),this.clearLocalStorageExcept(e),this.clearGridSessionStorage(),sessionStorage.removeItem("accountSelection:lastAll"),sessionStorage.removeItem("accountSelection:lastFiltered"),this.unregisterServiceWorkers().then(async()=>{if(this.isIdle)try{r||await i.signoutSilent(o),window.location.href="/session-expired"}catch(t){window.location.href="/session-expired"}else{if(!o){await i.clearStaleState(),window.location.href="/authenticate";return}i.signoutRedirect(o)}})},this.unregisterServiceWorkers=async()=>{const e=await navigator.serviceWorker.getRegistrations();for(const r of e)r.unregister()},this.clearState=()=>{h()}}firstUpdated(){const{searchParams:e}=new URL(document.location.toString());this.isIdle=e.has("isIdle"),this.logout()}render(){return l` <splash-screen></splash-screen> `}}window.customElements.define("ixp-logout",a);export{a as Logout};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digital-realty/app-shell",
3
- "version": "13.0.9",
3
+ "version": "13.0.10",
4
4
  "license": "UNLICENSED",
5
5
  "contributors": [
6
6
  "DLR"
@@ -18,101 +18,52 @@
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
- "workspaces": [
22
- "../lib-components/packages/*"
23
- ],
24
- "scripts": {
25
- "build:local": "npm run build --env=local",
26
- "build:workspace": "npm run build",
27
- "prepack": "npm run build",
28
- "generate-import-map-localhost": "ix-import-map write-import-map --cdn=http://localhost:8081 && node build_scripts/inject-mfe-importmap.cjs",
29
- "generate-import-map": "ix-import-map write-import-map --latest-packages=true && node build_scripts/inject-mfe-importmap.cjs",
30
- "inject-mfe-importmap": "node build_scripts/inject-mfe-importmap.cjs",
31
- "build": "run-s build:step:*",
32
- "build:step:generate": "npm run generate-api:notifications && npm run compile-less-to-styles && npm run tailwindcss:build && npm run twlit:build",
33
- "build:step:package": "rimraf dist && tsc && rollup -c rollup.config.mjs",
34
- "serve:dist": "web-dev-server --config web-dist-server.config.mjs",
35
- "ts:watch": "concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"npm run tailwindcss:watch\" \"npm run twlit:watch\"",
36
- "start": "npm run start:pre-serve && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\" \"npm run tailwindcss:watch\" \"npm run twlit:watch\"",
37
- "start:pre-serve": "rimraf lib && rollup -c preserve.rollup.config.mjs && tsc",
38
- "start:serve": "web-dev-server",
39
- "compile-less-to-styles": "rimraf --glob \"src/styles/*.js\" && node build_scripts/compile-less-to-styles.cjs",
40
- "serve": "npm run build && prpl-server --root dist",
41
- "test": "npm run test:prebuild && web-test-runner --coverage",
42
- "test:prebuild": "rimraf lib && tsc && rollup -c preserve.rollup.config.mjs && npm run compile-less-to-styles && npm run tailwindcss:build && npm run twlit:build",
43
- "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
44
- "lint": "npm run lint:eslint && npm run lint:prettier",
45
- "lint:eslint": "eslint --ext .js,.html .",
46
- "lint:prettier": "prettier \"**/*.js\" --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
47
- "format": "npm run format:eslint && npm run format:prettier",
48
- "format:eslint": "eslint --ext .js,.html . --fix",
49
- "format:prettier": "prettier \"**/*.js\" --write",
50
- "pipelines-npm-audit": "node build_scripts/pipelines-npm-audit.cjs",
51
- "tailwindcss:build": "tailwind -i ./src/tailwindlib.css -o ./src/styles/tw.css",
52
- "tailwindcss:watch": "tailwind -i ./src/tailwindlib.css -o ./src/styles/tw.css --watch",
53
- "twlit:build": "ix-twlit --input ./src/styles/tw.css --output ./src/styles/tw.js",
54
- "twlit:watch": "ix-twlit --input ./src/styles/tw.css --output ./src/styles/tw.js --watch",
55
- "generate-api:notifications": "openapi-generator-cli generate -i src/components/notifications/api/notifications-api.yaml -g typescript-fetch -o src/components/notifications/api/notifications-api --additional-properties=typescriptThreePlus=true,importFileExtension=.js"
56
- },
57
21
  "resolutions": {
58
22
  "ini": "1.3.6",
59
23
  "minimist": "1.2.5"
60
24
  },
61
25
  "dependencies": {
62
26
  "@adobe/lit-mobx": "^2.2.2",
63
- "@digital-realty/ix-account-switcher": "^1.1.6",
64
- "@digital-realty/ix-app-logic": "^2.0.1",
65
- "@digital-realty/ix-divider": "^1.2.3",
66
- "@digital-realty/ix-icon": "^1.1.3",
67
- "@digital-realty/ix-icon-button": "1.2.2",
68
- "@digital-realty/ix-intraportal-nav": "^1.0.1",
69
- "@digital-realty/ix-menu": "1.0.4",
70
- "@digital-realty/ix-toast": "1.0.27",
71
- "@digital-realty/ix-tooltip": "^1.1.3",
72
- "@digital-realty/theme": "^3.0.1",
27
+ "@digital-realty/ix-account-switcher": "^1.3.9",
28
+ "@digital-realty/ix-app-logic": "^2.1.6",
29
+ "@digital-realty/ix-button": "^3.5.6",
30
+ "@digital-realty/ix-date": "^1.3.4",
31
+ "@digital-realty/ix-divider": "^1.3.4",
32
+ "@digital-realty/ix-drawer": "^1.3.6",
33
+ "@digital-realty/ix-icon": "^1.3.4",
34
+ "@digital-realty/ix-icon-button": "1.3.4",
35
+ "@digital-realty/ix-intraportal-nav": "^1.3.4",
36
+ "@digital-realty/ix-menu": "1.3.4",
37
+ "@digital-realty/ix-switch": "^2.4.4",
38
+ "@digital-realty/ix-toast": "1.3.5",
39
+ "@digital-realty/ix-tooltip": "^1.3.4",
40
+ "@digital-realty/theme": "^3.1.4",
73
41
  "@floating-ui/dom": "^1.6.7",
74
42
  "@koa/cors": "^3.4.3",
75
43
  "@lit-labs/motion": "^1.0.7",
76
- "@lit/react": "^1.0.5",
77
44
  "@lit/reactive-element": "^2.0.4",
78
45
  "@material/web": "2.4.0",
79
46
  "@microsoft/applicationinsights-web": "^2.5.10",
80
- "@redux-offline/redux-offline": "^2.6.0",
81
47
  "@vaadin/grid": "^24.4.7",
82
48
  "@vaadin/router": "^1.7.2",
83
- "@web/dev-server-import-maps": "^0.0.7",
84
49
  "@web/dev-server-rollup": "^0.3.19",
85
- "@webcomponents/custom-elements": "^1.4.2",
86
- "@webcomponents/webcomponentsjs": "^2.4.3",
87
- "cross-fetch": "^4.0.0",
88
50
  "date-fns": "4.1.0",
89
- "http-request-mock": "^1.8.28",
90
- "http-status-codes": "^1.4.0",
91
51
  "lit": "^3.1.0",
92
52
  "lit-element": "^4.1.1",
93
53
  "lit-html": "^2.8.0",
94
- "lodash.debounce": "^4.0.8",
95
54
  "markdown-it": "^14.1.0",
96
55
  "mobx": "^6.12.3",
97
56
  "mobx-persist-store": "^1.1.5",
98
- "moment": "^2.29.1",
99
- "moment-timezone": "^0.5.45",
100
- "oidc-client": "^1.11.5",
101
57
  "oidc-client-ts": "^3.0.1",
102
58
  "path": "^0.12.7",
103
- "react": "^18.2.0",
104
- "react-dom": "^18.2.0",
105
- "redux-persist": "^6.0.0",
106
- "toastify-js": "^1.12.0",
107
59
  "tslib": "^2.8.1",
108
- "uuid": "^10.0.0",
109
- "validator": "^13.12.0",
110
60
  "workbox-window": "^7.3.0"
111
61
  },
112
62
  "devDependencies": {
113
63
  "@babel/eslint-parser": "^7.25.8",
114
64
  "@custom-elements-manifest/analyzer": "^0.10.3",
115
- "@digital-realty/ix-twlit": "1.0.1",
65
+ "@digital-realty/ix-twlit": "1.2.4",
66
+ "@esm-bundle/chai": "^4.3.4-fix.0",
116
67
  "@open-wc/eslint-config": "^12.0.3",
117
68
  "@open-wc/testing": "^4.0.0",
118
69
  "@openapitools/openapi-generator-cli": "^2.13.4",
@@ -134,10 +85,12 @@
134
85
  "@web/storybook-builder": "^0.1.16",
135
86
  "@web/storybook-framework-web-components": "^0.1.2",
136
87
  "@web/test-runner": "^0.18.2",
88
+ "@web/test-runner-commands": "^0.9.0",
137
89
  "@web/test-runner-junit-reporter": "^0.8.0",
138
90
  "@web/test-runner-playwright": "^0.11.1",
139
91
  "babel-plugin-template-html-minifier": "^4.1.0",
140
92
  "change-case": "^3.1.0",
93
+ "concurrently": "^10.0.3",
141
94
  "deepmerge": "^4.3.1",
142
95
  "eslint": "^8.57.0",
143
96
  "eslint-config-prettier": "^9.1.0",
@@ -147,6 +100,7 @@
147
100
  "lint-staged": "^15.2.7",
148
101
  "minimist": "^1.2.8",
149
102
  "npm-run-all": "^4.1.5",
103
+ "playwright": "^1.60.0",
150
104
  "prettier": "^3.3.2",
151
105
  "rimraf": "^5.0.9",
152
106
  "rollup": "^4.18.1",
@@ -155,10 +109,37 @@
155
109
  "rollup-plugin-modify": "^3.0.0",
156
110
  "rollup-plugin-workbox": "^8.1.0",
157
111
  "sinon": "^15.0.1",
158
- "tailwindcss": "^3.3.5"
112
+ "tailwindcss": "^3.3.5",
113
+ "typescript": "^5.5.4"
159
114
  },
160
115
  "optionalDependencies": {
161
116
  "@rollup/rollup-darwin-x64": "^4.24.0",
162
117
  "@rollup/rollup-win32-x64-msvc": "^4.24.0"
118
+ },
119
+ "scripts": {
120
+ "build:local": "pnpm run build --env=local",
121
+ "build:workspace": "pnpm run build",
122
+ "build": "run-s build:step:*",
123
+ "build:step:generate": "pnpm run generate-api:notifications && pnpm run compile-less-to-styles && pnpm run tailwindcss:build && pnpm run twlit:build",
124
+ "build:step:package": "rimraf dist && tsc && rollup -c rollup.config.mjs",
125
+ "serve:dist": "web-dev-server --config web-dist-server.config.mjs",
126
+ "ts:watch": "concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"pnpm run tailwindcss:watch\" \"pnpm run twlit:watch\"",
127
+ "compile-less-to-styles": "rimraf --glob \"src/styles/*.js\" && node build_scripts/compile-less-to-styles.cjs",
128
+ "serve": "pnpm run build && prpl-server --root dist",
129
+ "test": "pnpm run test:prebuild && web-test-runner --coverage",
130
+ "test:prebuild": "rimraf lib && tsc && rollup -c preserve.rollup.config.mjs && pnpm run compile-less-to-styles && pnpm run tailwindcss:build && pnpm run twlit:build",
131
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
132
+ "lint": "pnpm run lint:eslint && pnpm run lint:prettier",
133
+ "lint:eslint": "eslint --ext .js,.html .",
134
+ "lint:prettier": "prettier \"**/*.js\" --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
135
+ "format": "pnpm run format:eslint && pnpm run format:prettier",
136
+ "format:eslint": "eslint --ext .js,.html . --fix",
137
+ "format:prettier": "prettier \"**/*.js\" --write",
138
+ "pipelines-npm-audit": "node build_scripts/pipelines-npm-audit.cjs",
139
+ "tailwindcss:build": "tailwind -i ./src/tailwindlib.css -o ./src/styles/tw.css",
140
+ "tailwindcss:watch": "tailwind -i ./src/tailwindlib.css -o ./src/styles/tw.css --watch",
141
+ "twlit:build": "ix-twlit --input ./src/styles/tw.css --output ./src/styles/tw.js",
142
+ "twlit:watch": "ix-twlit --input ./src/styles/tw.css --output ./src/styles/tw.js --watch",
143
+ "generate-api:notifications": "openapi-generator-cli generate -i src/components/notifications/api/notifications-api.yaml -g typescript-fetch -o src/components/notifications/api/notifications-api --additional-properties=typescriptThreePlus=true,importFileExtension=.js"
163
144
  }
164
- }
145
+ }