@descope/tenant-profile-widget 0.10.5 → 0.11.1

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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /**
3
- * @descope/tenant-profile-widget v0.10.5
3
+ * @descope/tenant-profile-widget v0.11.1
4
4
  */
5
- import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createSingletonMixin as n,compose as s,createTemplate as o,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as r,observeAttributesMixin as d,loggerMixin as l,baseUrlMixin as h,cookieConfigMixin as c,DEFAULT_STYLE_ID as u,createStateManagementMixin as f,initLifecycleMixin as v,localeMixin as m,flowModalMixin as g,themeMixin as p,flowInputMixin as w,descopeUiMixin as y,initElementMixin as S,createFetchWidgetPagesMixin as k,modalMixin as b,debuggerMixin as R,componentsConditionsMixin as T}from"@descope/sdk-mixins";import{FlowDriver as W,MultiSsoConfigurationsDriver as I,LinkDriver as x,UserAttributeDriver as O,UserAuthMethodDriver as F}from"@descope/sdk-component-drivers";import{createSelector as M}from"reselect";import{createAsyncThunk as D}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import E from"@descope/web-js-sdk";import"@descope/web-component";const C=t=>t.tenant.data,A=t=>t.tenantAdminLinkSSO.data.defaultLink,L=M(C,(t=>t.customAttributes||{})),j=M(C,(t=>t.name||"")),q=M(C,(t=>t.selfProvisioningDomains||[])),P=M(C,(t=>t.enforceSSOExclusions||[])),N=M(C,(t=>t.enforceSSO||!1)),U=M(C,A,(t=>t.tenantAdminLinkSSO.data.ssoIdToLink),((t,e,i)=>[...t?[{id:"",name:"Default SSO Configuration",authType:t.authType,isDefault:!0,link:e}]:[],...((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t,name:e,authType:n})=>({id:t,name:e,authType:n,link:i[t]||""})))])),$=M(C,(t=>((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t})=>t))));function B(t){return new URLSearchParams(window.location.search).get(t)}const H=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},_=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),z=D("users/me",((t,{extra:{api:e}})=>e.user.me())),X=H(z)({onFulfilled:(t,e)=>{t.me.data=e.payload}},_((t=>t.me))),Y={action:z,reducer:X},G=D("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),J=H(G)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},_((t=>t.tenant))),K={action:G,reducer:J},Q=D("tenant/adminLinkSso",(({ssoIds:t},{extra:{api:e}})=>e.tenant.adminLinkSso({ssoIds:t}))),V={action:Q,reducer:H(Q)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=null!==(i=e.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},_((t=>t.tenantAdminLinkSSO)))},Z={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},tt={me:"/v1/auth/me"},et={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},it=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),nt=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),st=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),ot=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),at=({httpClient:e,tenantId:i,mock:n})=>{const s=encodeURIComponent(i||""),o=`?tenant=${s}&id=${s}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(n)return st();if(!i)throw new Error("tenantId is not defined");const t=`${et.details}${o}`,s=yield e.get(t);yield it(s);return yield s.json()})),adminLinkSso:o=>t(void 0,[o],void 0,(function*({ssoIds:t}){if(n)return ot();if(!i)throw new Error("tenantId is not defined");const o=yield e.post(`${et.adminLinkSso}?tenant=${s}`,{tenantId:s,ssoIds:t},{headers:{"Content-Type":"application/json"}});yield it(o);return yield o.json()}))}},rt=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return nt();const t=yield e.get(tt.me);return yield it(t),t.json()}))}),dt=n((n=>{var o,a,f,v;const m=s(r,d,l,h,c)(n);return v=class extends m{constructor(){super(...arguments),o.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||u}get api(){return e(this,a,"f")||e(this,o,"m",f).call(this),e(this,a,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,a,"f")&&e(this,o,"m",f).call(this)}))}))}},a=new WeakMap,o=new WeakSet,f=function(){this.logger.debug("creating an sdk instance"),i(this,a,((t,e,i,n)=>{const s=E(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.10.5"}}));return{user:rt({httpClient:s.httpClient,mock:i}),tenant:at({httpClient:s.httpClient,tenantId:e,mock:i}),httpClient:s.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},v})),lt=n((t=>{const e=s(f({name:"widget",initialState:Z,reducers:{},extraReducers:t=>{Y.reducer(t),K.reducer(t),V.reducer(t)},asyncActions:{getMe:Y.action,getTenant:K.action,getTenantAdminLinkSSO:V.action}}),v,l,dt)(t);return class extends e{constructor(...t){super(...t),this.state=Z,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),ht="widget-flow",ct=n((i=>{var n,o,a;return a=class extends(s(m,v,g,lt,c,l,p,w)(i)){constructor(){super(...arguments),n.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const s=B(ht);s&&(!function(t){if(window.history.replaceState&&B(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(ht),e(this,n,"m",o).call(this,s))}))}},n=new WeakSet,o=function(e){const i=this.createFlowModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId}));new W((()=>{var t;return null===(t=i.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>t(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const t=$(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})})))),i.afterClose=()=>{i.remove()},i.open()},a})),ut=n((t=>class extends(s(p,d)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}}));const ft=n((i=>{var n,a,r;return r=class extends(s(l,v,y,S,k("tenant-profile-widget"),lt)(i)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const t=$(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}catch(t){}const s=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const t="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",e.appendChild(i);const n=document.createElement("div");return n.textContent=t,n.style.fontWeight="bold",n.style.fontSize="20px",n.style.color="#222",n.style.textAlign="center",n.style.marginTop="8px",e.appendChild(n),e}({mainMessage:t}))}else yield e(this,n,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,a=function(){return t(this,void 0,void 0,(function*(){const t=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},r})),vt=n((n=>{var o,a,r,d,h,c,u,f,v,m,p,y;return y=class extends(s(ut,lt,g,l,ft,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const n=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=n.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,a,new I((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e(this,a,"f").isExists&&(e(this,o,"m",p).call(this),e(this,a,"f").data=U(this.state),this.subscribe((t=>{e(this,a,"f").data=t}),U))}))}},a=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,c=new WeakMap,o=new WeakSet,u=function(){i(this,r,this.createFlowModal({"data-id":"multi-sso-create-modal"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,d,"f"))},f=function(){i(this,h,this.createFlowModal({"data-id":"multi-sso-delete-modal"}),"f"),i(this,c,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,c,"f"))},v=function(i){e(this,r,"f").setContent(this.createFlowTemplate({flowId:i,tenant:this.tenantId})),e(this,r,"f").open(),e(this,d,"f").onSuccess((()=>t(this,void 0,void 0,(function*(){e(this,r,"f").close(),yield this.actions.getTenant();const t=$(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},m=function(t,i){e(this,h,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e(this,h,"f").open(),e(this,c,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:t,deleteFlowId:i}=e(this,a,"f");i&&(e(this,o,"m",f).call(this),e(this,a,"f").onDeleteClicked((({id:t})=>e(this,o,"m",m).call(this,i,t)))),t&&(e(this,o,"m",u).call(this),e(this,a,"f").onCreateClicked((()=>e(this,o,"m",v).call(this,t))))},y})),mt=n((i=>{var n,o,r,d;return d=class extends(s(ut,lt,l,ft,c,b)(i)){constructor(){super(...arguments),n.add(this),r.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",o).call(this),e(this,r,"f").call(this,A(this.state)),this.subscribe(e(this,r,"f").bind(this),A)}))}},r=new WeakMap,n=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},d}));var gt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(gt||(gt={}));const pt=n((i=>{var n,o,r,d,h,u,f,v,p,y,S;return S=class extends(s(m,ut,lt,l,ft,c,g,w)(i)){constructor(){super(...arguments),n.add(this),o.set(this,{}),r.set(this,{}),d.set(this,{}),h.set(this,{}),v.set(this,a((t=>{var i;const s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((i=>{const s=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||gt.TEXT,a=t[s],r=new O(i,{logger:this.logger});r.value=((t,e)=>t===gt.DATE&&e?new Date(e).toLocaleString():t===gt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,a),e(this,n,"m",p).call(this,i,s,r,o,s),e(this,n,"m",y).call(this,i,s,r)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,v,"f").call(this,L(this.state)),this.subscribe(e(this,v,"f").bind(this),L)}))}},o=new WeakMap,r=new WeakMap,d=new WeakMap,h=new WeakMap,v=new WeakMap,n=new WeakSet,u=function(t,i,n){var s,a;const d=L(this.state)[n],l=i===gt.ARRAY?(d||[]).join(","):d;null===(s=e(this,o,"f")[t])||void 0===s||s.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[n]:l}}})),null===(a=e(this,r,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,n;null===(i=e(this,d,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(n=e(this,h,"f")[t])||void 0===n||n.onSuccess((()=>{var i;null===(i=e(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},p=function(t,i,s,a,d){const l=t.getAttribute("edit-flow-id");l&&(e(this,o,"f")[l]||(e(this,o,"f")[l]=this.createFlowModal({"data-id":`edit-${i}`}),e(this,r,"f")[l]=new W((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[l].beforeOpen=e(this,n,"m",u).bind(this,l,a,d),s.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),this.syncFlowTheme(e(this,r,"f")[l])))},y=function(t,i,s){const o=t.getAttribute("delete-flow-id");o&&(e(this,d,"f")[o]||(e(this,d,"f")[o]=this.createFlowModal({"data-id":`delete-${i}`}),e(this,h,"f")[o]=new W((()=>{var t,i;return null===(i=null===(t=e(this,d,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,d,"f")[o].beforeOpen=e(this,n,"m",f).bind(this,o),s.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,d,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e(this,h,"f")[o])))},S})),wt=n((n=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,q(this.state)),this.subscribe(e(this,k,"f").bind(this),q)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,r,this.createFlowModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:q(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEmailDomainsDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),yt=n((n=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,P(this.state)),this.subscribe(e(this,k,"f").bind(this),P)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,r,this.createFlowModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:P(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantSSOExclusionsDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),St=n((n=>{var o,r,d,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,N(this.state)),this.subscribe(e(this,k,"f").bind(this),N)}))}},r=new WeakMap,d=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,r,this.createFlowModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,d,"f")))},v=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:N(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEnforceSSODriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),kt=n((n=>{var o,r,d,h,u,f,v,p;return p=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),r.set(this,void 0),d.set(this,void 0),v.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",f).call(this),e(this,o,"m",h).call(this),e(this,v,"f").call(this,j(this.state)),this.subscribe(e(this,v,"f").bind(this),j)}))}},r=new WeakMap,d=new WeakMap,v=new WeakMap,o=new WeakSet,h=function(){this.tenantNameDriver.editFlowId&&(i(this,r,this.createFlowModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,r,"f").beforeOpen=e(this,o,"m",u).bind(this),e(this,o,"m",u).call(this),this.syncFlowTheme(e(this,d,"f")))},u=function(){e(this,r,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:j(this.state)}})),e(this,d,"f").onSuccess((()=>{e(this,r,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,r,"f"))||void 0===t||t.open()}))},p})),bt=n((n=>{var o,a,r,d,h,u,f;return f=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(i(this,a,this.createFlowModal({"data-id":"password-policy"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new F((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),Rt=n((n=>{var o,a,r,d,h,u,f;return f=class extends(s(m,ut,lt,l,ft,c,g,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),r.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",d).call(this)}))}},a=new WeakMap,r=new WeakMap,o=new WeakSet,d=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(i(this,a,this.createFlowModal({"data-id":"session-settings"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,r,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,r,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantSessionSettingsUserAuthMethodDriver=new F((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),Tt=n((e=>class extends(s(R,p,ct,ft,kt,wt,yt,St,pt,mt,bt,Rt,vt,T)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),Wt=s((e=>class extends(Tt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.10.5"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",Wt);export{Wt as default};
5
+ import{__awaiter as t,__classPrivateFieldGet as e,__classPrivateFieldSet as i}from"tslib";import{createSingletonMixin as n,compose as s,createTemplate as o,withMemCache as a}from"@descope/sdk-helpers";import{projectIdMixin as d,observeAttributesMixin as r,loggerMixin as l,baseUrlMixin as h,cookieConfigMixin as c,DEFAULT_STYLE_ID as u,createStateManagementMixin as f,initLifecycleMixin as v,localeMixin as m,flowModalMixin as g,themeMixin as p,flowInputMixin as w,descopeUiMixin as y,initElementMixin as S,createFetchWidgetPagesMixin as k,modalMixin as b,debuggerMixin as R,componentsConditionsMixin as T}from"@descope/sdk-mixins";import{FlowDriver as W,MultiSsoConfigurationsDriver as I,LinkDriver as x,UserAttributeDriver as O,UserAuthMethodDriver as F}from"@descope/sdk-component-drivers";import{createSelector as M}from"reselect";import{createAsyncThunk as D}from"@reduxjs/toolkit";import"@descope/core-js-sdk";import E from"@descope/web-js-sdk";import"@descope/web-component";const C=t=>t.tenant.data,A=t=>t.tenantAdminLinkSSO.data.defaultLink,L={},j=M(C,(t=>t.customAttributes||{})),q=M(C,(t=>t.name||"")),P=M(C,(t=>t.selfProvisioningDomains||[])),N=M(C,(t=>t.enforceSSOExclusions||[])),U=M(C,(t=>t.enforceSSO||!1)),$=M(C,A,(t=>t.tenantAdminLinkSSO.data.ssoIdToLink),(t=>t.tenantAdminLinkSSO.data.ssoIdToAuthenticationOnly||L),((t,e,i,n)=>[...t?[{id:"",name:"Default SSO Configuration",authType:t.authType,isDefault:!0,link:e,authOnly:n.default_ssoid||!1}]:[],...((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t,name:e,authType:s})=>({id:t,name:e,authType:s,link:i[t]||"",authOnly:n[t]||!1})))])),B=M(C,(t=>((null==t?void 0:t.additionalSSOConfigs)||[]).map((({ssoId:t})=>t))));function H(t){return new URLSearchParams(window.location.search).get(t)}const _=t=>(...e)=>i=>{i.addCase(t.pending,((t,i)=>{e.forEach((({onPending:e})=>{null==e||e(t,i)}))})),i.addCase(t.fulfilled,((t,i)=>{e.forEach((({onFulfilled:e})=>{null==e||e(t,i)}))})),i.addCase(t.rejected,((t,i)=>{e.forEach((({onRejected:e})=>{null==e||e(t,i)}))}))},z=t=>({onFulfilled:e=>{t(e).loading=!1},onPending:e=>{t(e).loading=!0,t(e).error=null},onRejected:(e,i)=>{t(e).loading=!1,t(e).error=i.error}}),X=D("users/me",((t,{extra:{api:e}})=>e.user.me())),Y=_(X)({onFulfilled:(t,e)=>{t.me.data=e.payload}},z((t=>t.me))),G={action:X,reducer:Y},J=D("tenant/details",((t,{extra:{api:e}})=>e.tenant.details())),K=_(J)({onFulfilled:(t,e)=>{t.tenant.data=e.payload}},z((t=>t.tenant))),Q={action:J,reducer:K},V=D("tenant/adminLinkSso",(({ssoIds:t},{extra:{api:e}})=>e.tenant.adminLinkSso({ssoIds:t}))),Z={action:V,reducer:_(V)({onFulfilled:(t,e)=>{var i;t.tenantAdminLinkSSO.data=null!==(i=e.payload)&&void 0!==i?i:{defaultLink:"",ssoIdToLink:{}}}},z((t=>t.tenantAdminLinkSSO)))},tt={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:{defaultLink:"",ssoIdToLink:{}}}},et={me:"/v1/auth/me"},it={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated/batch"},nt=e=>t(void 0,void 0,void 0,(function*(){const t=yield e.text(),i=JSON.parse(t);if(!e.ok){const t=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(t||`${e.status} ${e.statusText}`)}e.json=()=>Promise.resolve(i),e.text=()=>Promise.resolve(t)})),st=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({loginIds:["user@company.com"],externalIds:["user@company.com"],userId:"user-1",name:"Test User",email:"user@company.com",roleNames:["Role"],phone:"+1-202-555-010",verifiedEmail:!0,verifiedPhone:!0,userTenants:[],status:"enabled",editable:!0,createdTime:(new Date).getTime(),customAttributes:{},familyName:"",givenName:"",middleName:"",picture:void 0,password:!0,SAML:!1,test:!1,TOTP:!1,webauthn:!0})}))})),ot=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({tenantId:"tenant-1",roleNames:["admin"],id:"tenant-1",name:"Test Tenant",selfProvisioningDomains:["example1.com","example2.com"],customAttributes:{},authType:"password",domains:[],createdTime:Date.now(),disabled:!1,enforceSSO:!0})}))})),at=()=>t(void 0,void 0,void 0,(function*(){return new Promise((t=>{t({defaultLink:"_blank",ssoIdToLink:{"okta-prod":"_blank?ssoId=okta-prod","entra-eu":"_blank?ssoId=entra-eu"}})}))})),dt=({httpClient:e,tenantId:i,mock:n})=>{const s=encodeURIComponent(i||""),o=`?tenant=${s}&id=${s}`;return{details:()=>t(void 0,void 0,void 0,(function*(){if(n)return ot();if(!i)throw new Error("tenantId is not defined");const t=`${it.details}${o}`,s=yield e.get(t);yield nt(s);return yield s.json()})),adminLinkSso:o=>t(void 0,[o],void 0,(function*({ssoIds:t}){if(n)return at();if(!i)throw new Error("tenantId is not defined");const o=yield e.post(`${it.adminLinkSso}?tenant=${s}`,{tenantId:s,ssoIds:t},{headers:{"Content-Type":"application/json"}});yield nt(o);return yield o.json()}))}},rt=({httpClient:e,mock:i})=>({me:()=>t(void 0,void 0,void 0,(function*(){if(i)return st();const t=yield e.get(et.me);return yield nt(t),t.json()}))}),lt=n((n=>{var o,a,f,v;const m=s(d,r,l,h,c)(n);return v=class extends m{constructor(){super(...arguments),o.add(this),a.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get styleId(){return this.getAttribute("style-id")||u}get api(){return e(this,a,"f")||e(this,o,"m",f).call(this),e(this,a,"f")}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e(this,a,"f")&&e(this,o,"m",f).call(this)}))}))}},a=new WeakMap,o=new WeakSet,f=function(){this.logger.debug("creating an sdk instance"),i(this,a,((t,e,i,n)=>{const s=E(Object.assign(Object.assign({},t),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":n,"x-descope-widget-version":"0.11.1"}}));return{user:rt({httpClient:s.httpClient,mock:i}),tenant:dt({httpClient:s.httpClient,tenantId:e,mock:i}),httpClient:s.httpClient}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},v})),ht=n((t=>{const e=s(f({name:"widget",initialState:tt,reducers:{},extraReducers:t=>{G.reducer(t),Q.reducer(t),Z.reducer(t)},asyncActions:{getMe:G.action,getTenant:Q.action,getTenantAdminLinkSSO:Z.action}}),v,l,lt)(t);return class extends e{constructor(...t){super(...t),this.state=tt,this.subscribe((t=>{this.logger.debug("State update:",t),this.state=t}))}}})),ct="widget-flow",ut=n((i=>{var n,o,a;return a=class extends(s(m,v,g,ht,c,l,p,w)(i)){constructor(){super(...arguments),n.add(this)}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);const s=H(ct);s&&(!function(t){if(window.history.replaceState&&H(t)){const e=new URL(window.location.href),i=new URLSearchParams(e.search);i.delete(t),e.search=i.toString(),window.history.replaceState({},"",e.toString())}}(ct),e(this,n,"m",o).call(this,s))}))}},n=new WeakSet,o=function(e){const i=this.createFlowModal({"data-id":"redirect-flow"});i.setContent(this.createFlowTemplate({flowId:e,tenant:this.tenantId}));new W((()=>{var t;return null===(t=i.ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>t(this,void 0,void 0,(function*(){i.close(),this.actions.getMe(),yield this.actions.getTenant();const t=B(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})})))),i.afterClose=()=>{i.remove()},i.open()},a})),ft=n((t=>class extends(s(p,r)(t)){syncFlowTheme(t){t.theme=this.theme,this.observeAttributes(["theme"],(()=>{t.theme=this.theme}))}}));const vt=n((i=>{var n,a,d;return d=class extends(s(l,v,y,S,k("tenant-profile-widget"),ht)(i)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return t(this,void 0,void 0,(function*(){}))}init(){const i=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.init)||void 0===t?void 0:t.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant()]);const t=B(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}catch(t){}const s=this.state.me.error||(t=>t.tenant.error)(this.state)||(t=>t.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const t="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:t="An error occurred"}){const e=document.createElement("div");e.setAttribute("data-id","widget-error"),e.style.display="flex",e.style.flexDirection="column",e.style.alignItems="center",e.style.justifyContent="center",e.style.padding="72px 36px",e.style.background="#fff",e.style.borderRadius="12px",e.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",e.style.margin="32px auto",e.style.maxWidth="400px";const i=document.createElement("div");i.innerHTML='\n <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="20" cy="20" r="18" stroke="#FF3B3B" stroke-width="3" fill="#fff"/>\n <text x="20" y="27" text-anchor="middle" font-size="24" font-family="Arial, sans-serif" fill="#FF3B3B">!</text>\n </svg>\n ',i.style.marginBottom="12px",e.appendChild(i);const n=document.createElement("div");return n.textContent=t,n.style.fontWeight="bold",n.style.fontSize="20px",n.style.color="#222",n.style.textAlign="center",n.style.marginTop="8px",e.appendChild(n),e}({mainMessage:t}))}else yield e(this,n,"m",a).call(this),yield this.onWidgetRootReady(),this.dispatchEvent(new CustomEvent("ready"))}))}},n=new WeakSet,a=function(){return t(this,void 0,void 0,(function*(){const t=o(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(t),this.contentRootElement.append(t.content.cloneNode(!0))}))},d})),mt=n((n=>{var o,a,d,r,h,c,u,f,v,m,p,y;return y=class extends(s(ft,ht,g,l,vt,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),d.set(this,void 0),r.set(this,void 0),h.set(this,void 0),c.set(this,void 0)}onWidgetRootReady(){const n=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=n.onWidgetRootReady)||void 0===t?void 0:t.call(this),i(this,a,new I((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector("descope-multi-sso")}),{logger:this.logger}),"f"),e(this,a,"f").isExists&&(e(this,o,"m",p).call(this),e(this,a,"f").data=$(this.state),this.subscribe((t=>{e(this,a,"f").data=t}),$))}))}},a=new WeakMap,d=new WeakMap,r=new WeakMap,h=new WeakMap,c=new WeakMap,o=new WeakSet,u=function(){i(this,d,this.createFlowModal({"data-id":"multi-sso-create-modal"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,r,"f"))},f=function(){i(this,h,this.createFlowModal({"data-id":"multi-sso-delete-modal"}),"f"),i(this,c,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),this.syncFlowTheme(e(this,c,"f"))},v=function(i){e(this,d,"f").setContent(this.createFlowTemplate({flowId:i,tenant:this.tenantId})),e(this,d,"f").open(),e(this,r,"f").onSuccess((()=>t(this,void 0,void 0,(function*(){e(this,d,"f").close(),yield this.actions.getTenant();const t=B(this.state);yield this.actions.getTenantAdminLinkSSO({ssoIds:t})}))))},m=function(t,i){e(this,h,"f").setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{deleteSSOConfigurationId:i}})),e(this,h,"f").open(),e(this,c,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},p=function(){const{createFlowId:t,deleteFlowId:i}=e(this,a,"f");i&&(e(this,o,"m",f).call(this),e(this,a,"f").onDeleteClicked((({id:t})=>e(this,o,"m",m).call(this,i,t)))),t&&(e(this,o,"m",u).call(this),e(this,a,"f").onCreateClicked((()=>e(this,o,"m",v).call(this,t))))},y})),gt=n((i=>{var n,o,d,r;return r=class extends(s(ft,ht,l,vt,c,b)(i)){constructor(){super(...arguments),n.add(this),d.set(this,a((t=>{this.tenantAdminLinkSSODriver.href=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,n,"m",o).call(this),e(this,d,"f").call(this,A(this.state)),this.subscribe(e(this,d,"f").bind(this),A)}))}},d=new WeakMap,n=new WeakSet,o=function(){this.tenantAdminLinkSSODriver=new x((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},r}));var pt;!function(t){t.TEXT="text",t.NUMBER="number",t.BOOLEAN="boolean",t.SINGLE_SELECT="singleSelect",t.ARRAY="array",t.DATE="date"}(pt||(pt={}));const wt=n((i=>{var n,o,d,r,h,u,f,v,p,y,S;return S=class extends(s(m,ft,ht,l,vt,c,g,w)(i)){constructor(){super(...arguments),n.add(this),o.set(this,{}),d.set(this,{}),r.set(this,{}),h.set(this,{}),v.set(this,a((t=>{var i;const s=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(s).forEach((i=>{const s=i.getAttribute("data-id").replace("customAttributes.",""),o=i.getAttribute("data-type")||pt.TEXT,a=t[s],d=new O(i,{logger:this.logger});d.value=((t,e)=>t===pt.DATE&&e?new Date(e).toLocaleString():t===pt.BOOLEAN&&void 0!==e?e?"True":"False":(e||"").toString())(o,a),e(this,n,"m",p).call(this,i,s,d,o,s),e(this,n,"m",y).call(this,i,s,d)}))})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,v,"f").call(this,j(this.state)),this.subscribe(e(this,v,"f").bind(this),j)}))}},o=new WeakMap,d=new WeakMap,r=new WeakMap,h=new WeakMap,v=new WeakMap,n=new WeakSet,u=function(t,i,n){var s,a;const r=j(this.state)[n],l=i===pt.ARRAY?(r||[]).join(","):r;null===(s=e(this,o,"f")[t])||void 0===s||s.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId,form:{customAttributes:{[n]:l}}})),null===(a=e(this,d,"f")[t])||void 0===a||a.onSuccess((()=>{var i;null===(i=e(this,o,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},f=function(t){var i,n;null===(i=e(this,r,"f")[t])||void 0===i||i.setContent(this.createFlowTemplate({flowId:t,tenant:this.tenantId})),null===(n=e(this,h,"f")[t])||void 0===n||n.onSuccess((()=>{var i;null===(i=e(this,r,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},p=function(t,i,s,a,r){const l=t.getAttribute("edit-flow-id");l&&(e(this,o,"f")[l]||(e(this,o,"f")[l]=this.createFlowModal({"data-id":`edit-${i}`}),e(this,d,"f")[l]=new W((()=>{var t,i;return null===(i=null===(t=e(this,o,"f")[l])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,o,"f")[l].beforeOpen=e(this,n,"m",u).bind(this,l,a,r),s.onEditClick((()=>{var t,i;null===(i=null===(t=e(this,o,"f"))||void 0===t?void 0:t[l])||void 0===i||i.open()})),this.syncFlowTheme(e(this,d,"f")[l])))},y=function(t,i,s){const o=t.getAttribute("delete-flow-id");o&&(e(this,r,"f")[o]||(e(this,r,"f")[o]=this.createFlowModal({"data-id":`delete-${i}`}),e(this,h,"f")[o]=new W((()=>{var t,i;return null===(i=null===(t=e(this,r,"f")[o])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e(this,r,"f")[o].beforeOpen=e(this,n,"m",f).bind(this,o),s.onDeleteClick((()=>{var t,i;null===(i=null===(t=e(this,r,"f"))||void 0===t?void 0:t[o])||void 0===i||i.open()})),this.syncFlowTheme(e(this,h,"f")[o])))},S})),yt=n((n=>{var o,d,r,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),d.set(this,void 0),r.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEmailDomainsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,P(this.state)),this.subscribe(e(this,k,"f").bind(this),P)}))}},d=new WeakMap,r=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEmailDomainsDriver.editFlowId&&(i(this,d,this.createFlowModal({"data-id":"edit-tenant-email-domains"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,r,"f")))},v=function(){e(this,d,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,form:{tenantEmailDomains:P(this.state)}})),e(this,r,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-email-domains"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEmailDomainsDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),St=n((n=>{var o,d,r,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),d.set(this,void 0),r.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantSSOExclusionsDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,N(this.state)),this.subscribe(e(this,k,"f").bind(this),N)}))}},d=new WeakMap,r=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantSSOExclusionsDriver.editFlowId&&(i(this,d,this.createFlowModal({"data-id":"edit-tenant-sso-exclusions"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,r,"f")))},v=function(){e(this,d,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.editFlowId,tenant:this.tenantId,form:{enforceSSOExclusions:N(this.state)}})),e(this,r,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantSSOExclusionsDriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-sso-exclusions"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantSSOExclusionsDriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantSSOExclusionsDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-force-sso-exclusions-edit"]')}),{logger:this.logger}),this.tenantSSOExclusionsDriver.onEditClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()})),this.tenantSSOExclusionsDriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),kt=n((n=>{var o,d,r,h,u,f,v,p,y,S,k,b;return b=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),d.set(this,void 0),r.set(this,void 0),h.set(this,void 0),u.set(this,void 0),k.set(this,a((t=>{this.tenantEnforceSSODriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",S).call(this),e(this,o,"m",f).call(this),e(this,o,"m",p).call(this),e(this,k,"f").call(this,U(this.state)),this.subscribe(e(this,k,"f").bind(this),U)}))}},d=new WeakMap,r=new WeakMap,h=new WeakMap,u=new WeakMap,k=new WeakMap,o=new WeakSet,f=function(){this.tenantEnforceSSODriver.editFlowId&&(i(this,d,this.createFlowModal({"data-id":"edit-tenant-enforce-sso"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").beforeOpen=e(this,o,"m",v).bind(this),e(this,o,"m",v).call(this),this.syncFlowTheme(e(this,r,"f")))},v=function(){e(this,d,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,form:{enforceSSO:U(this.state)}})),e(this,r,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getTenant()}))},p=function(){this.tenantEnforceSSODriver.deleteFlowId&&(i(this,h,this.createFlowModal({"data-id":"delete-tenant-enforce-sso"}),"f"),i(this,u,new W((()=>{var t;return null===(t=e(this,h,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,h,"f").beforeOpen=e(this,o,"m",y).bind(this),e(this,o,"m",y).call(this),this.syncFlowTheme(e(this,u,"f")))},y=function(){e(this,h,"f").setContent(this.createFlowTemplate({flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId})),e(this,u,"f").onSuccess((()=>{e(this,h,"f").close(),this.actions.getTenant()}))},S=function(){this.tenantEnforceSSODriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e(this,h,"f"))||void 0===t||t.open()}))},b})),bt=n((n=>{var o,d,r,h,u,f,v,p;return p=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),d.set(this,void 0),r.set(this,void 0),v.set(this,a((t=>{this.tenantNameDriver.value=t})))}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",f).call(this),e(this,o,"m",h).call(this),e(this,v,"f").call(this,q(this.state)),this.subscribe(e(this,v,"f").bind(this),q)}))}},d=new WeakMap,r=new WeakMap,v=new WeakMap,o=new WeakSet,h=function(){this.tenantNameDriver.editFlowId&&(i(this,d,this.createFlowModal({"data-id":"tenant-profile-set-name"}),"f"),i(this,r,new W((()=>{var t;return null===(t=e(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,d,"f").beforeOpen=e(this,o,"m",u).bind(this),e(this,o,"m",u).call(this),this.syncFlowTheme(e(this,r,"f")))},u=function(){e(this,d,"f").setContent(this.createFlowTemplate({flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,form:{tenantName:q(this.state)}})),e(this,r,"f").onSuccess((()=>{e(this,d,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantNameDriver=new O((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e(this,d,"f"))||void 0===t||t.open()}))},p})),Rt=n((n=>{var o,a,d,r,h,u,f;return f=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),d.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",r).call(this)}))}},a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.TenantPasswordPolicyUserAuthMethodDriver.flowId&&(i(this,a,this.createFlowModal({"data-id":"password-policy"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,d,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantPasswordPolicyUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,d,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantPasswordPolicyUserAuthMethodDriver=new F((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="password-policy"]')}),{logger:this.logger}),this.TenantPasswordPolicyUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),Tt=n((n=>{var o,a,d,r,h,u,f;return f=class extends(s(m,ft,ht,l,vt,c,g,w)(n)){constructor(){super(...arguments),o.add(this),a.set(this,void 0),d.set(this,void 0)}onWidgetRootReady(){const i=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=i.onWidgetRootReady)||void 0===t?void 0:t.call(this),e(this,o,"m",u).call(this),e(this,o,"m",r).call(this)}))}},a=new WeakMap,d=new WeakMap,o=new WeakSet,r=function(){this.TenantSessionSettingsUserAuthMethodDriver.flowId&&(i(this,a,this.createFlowModal({"data-id":"session-settings"}),"f"),i(this,d,new W((()=>{var t;return null===(t=e(this,a,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e(this,a,"f").afterClose=e(this,o,"m",h).bind(this),e(this,o,"m",h).call(this),this.syncFlowTheme(e(this,d,"f")))},h=function(){e(this,a,"f").setContent(this.createFlowTemplate({flowId:this.TenantSessionSettingsUserAuthMethodDriver.flowId,tenant:this.tenantId})),e(this,d,"f").onSuccess((()=>{e(this,a,"f").close(),this.actions.getTenant()}))},u=function(){this.TenantSessionSettingsUserAuthMethodDriver=new F((()=>{var t;return null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('descope-user-auth-method[data-id="session-settings"]')}),{logger:this.logger}),this.TenantSessionSettingsUserAuthMethodDriver.onUnfulfilledButtonClick((()=>{var t;null===(t=e(this,a,"f"))||void 0===t||t.open()}))},f})),Wt=n((e=>class extends(s(R,p,ut,vt,bt,yt,St,kt,wt,gt,Rt,Tt,mt,T)(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this)}))}})),It=s((e=>class extends(Wt(e)){init(){const e=Object.create(null,{init:{get:()=>super.init}});return t(this,void 0,void 0,(function*(){var t;yield null===(t=e.init)||void 0===t?void 0:t.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((t=>t.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.11.1"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",It);export{It as default};
6
6
  //# sourceMappingURL=index.js.map