@descope/tenant-profile-widget 0.0.0-next-d3790478-20250722

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Descope <help@descope.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @descope/tenant-profile-widget
2
+
3
+ ## Setup
4
+
5
+ ### Create an `.env` file
6
+
7
+ In the widget package create an `.env` file which includes;
8
+
9
+ ```
10
+ DESCOPE_BASE_URL= # env base url
11
+ DESCOPE_PROJECT_ID= # project ID
12
+ DESCOPE_WIDGET_ID= # default: tenant-profile-widget
13
+ DESCOPE_TENANT_ID= # tenant id
14
+ DEBUG_MODE= # "true" / "false", default: "false"
15
+ DESCOPE_THEME= # "light" / "dark" / "os", default: "light"
16
+ ```
17
+
18
+ ### Example
19
+
20
+ ```
21
+ // replace x.x.x with the latest release of the widget: https://www.npmjs.com/package/@descope/tenant-profile-widget
22
+ <script src="https://descopecdn.com/npm/@descope/tenant-profile-widget@x.x.x/dist/index.js"></script>
23
+ <descope-tenant-profile-widget
24
+ base-url="<DESCOPE_BASE_URL>"
25
+ project-id="<DESCOPE_PROJECT_ID>"
26
+ tenant="<DESCOPE_TENANT_ID>"
27
+ debug="<DEBUG_MODE>"
28
+ theme="<DESCOPE_THEME>"
29
+ widget-id="<DESCOPE_WIDGET_ID>"
30
+ ></descope-tenant-profile-widget>
31
+
32
+ <script>
33
+ function onLogout(error) {
34
+ window.location.reload();
35
+ }
36
+ const descopeWidgetEle = document.getElementsByTagName('descope-tenant-profile-widget')[0];
37
+ descopeWidgetEle.logout = onLogout;
38
+ </script>
39
+ ```
40
+
41
+ ### Authenticate
42
+
43
+ In order to work with the widget, you must be logged in
44
+ In case you are not authenticated, a login flow will run first, and after logging in, the widget will be rendered
45
+
46
+ ### Start the widget
47
+
48
+ run `npm start` to start the widget.
49
+
50
+ ## Architecture
51
+
52
+ ## Project Structure
53
+
54
+ - `/app` - contains `index.html`
55
+ - `/lib` - widget's source code
56
+ - `lib/widget` - widget related implementations
57
+ - `lib/widget/api` - Logic related to API calls
58
+ - `lib/widget/mixins` - Widget specific logic
59
+ - `lib/widget/state` - State management logic
60
+
61
+ ### API
62
+
63
+ ---
64
+
65
+ ### Mixins
66
+
67
+ The widget is composed of mixins, each mixin contains specific logic parts, and sometime exposes an API that can be used in other mixins.
68
+
69
+ Mixins can be composed on top of each other, so we can create new mixins by composing several mixins together.
70
+
71
+ #### Mixins Creators
72
+
73
+ Functions that create mixins, can get a configuration, and returns the mixin functions.
74
+
75
+ #### Singleton Mixin
76
+
77
+ Since mixins are composable, in some cases we want to make sure a mixin is loaded only once. For example: When there is no need for its logic to run multiple times when composed in different mixins.
78
+
79
+ For this case we have a wrapper function (`createSingletonMixin`) to ensure that a mixin is loaded only once, regardless how many times it will be composed.
80
+
81
+ Mixins should be wrapped with the `createSingletonMixin` wrapper function, unless there is a reason for running the mixin's logic multiple times.
82
+
83
+ ### State
84
+
85
+ We're using several tools to handle the widget's state:
86
+
87
+ - [Redux Toolkit](https://redux-toolkit.js.org/) for the widget's state management.
88
+ - [Redux Thunk](https://github.com/reduxjs/redux-thunk) for API calls and async operations we're using
89
+ - [Reselect](https://github.com/reduxjs/reselect) to compute derived data without hitting performance or triggering state recalculation when state is not mutated.
90
+
91
+ ### Drivers
92
+
93
+ An abstraction layer that provides an API for components, and enables handling interactions with components within the widget.
94
+
95
+ The motivation to use drivers is to decouple the widget's code from the component's implementation, and therefore it's important to interact with components only using drivers (and not relying on component's implementation details).
96
+
97
+ ## Dev
98
+
99
+ ### Use mock screens
100
+
101
+ Since screen are fetched dynamically, when developing a new screen for the widget you will probably want to use mock templates. To do so, simply replace the call to `fetchWidgetPage` with a string which includes your HTML.
@@ -0,0 +1,6 @@
1
+
2
+ /**
3
+ * @descope/tenant-profile-widget v0.0.1
4
+ */
5
+ "use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins"),s=require("@descope/sdk-component-drivers"),n=require("@reduxjs/toolkit");require("@descope/core-js-sdk");var a=require("@descope/web-js-sdk"),r=require("reselect");require("@descope/web-component");const o=(e={})=>{const i=t.createTemplate("<descope-wc></descope-wc>");return Object.entries(e).forEach((([e,s])=>{i.content.querySelector("descope-wc").setAttribute(t.kebabCase(e),s)})),i};function l(e){return new URLSearchParams(window.location.search).get(e)}const d=e=>(...t)=>i=>{i.addCase(e.pending,((e,i)=>{t.forEach((({onPending:t})=>{null==t||t(e,i)}))})),i.addCase(e.fulfilled,((e,i)=>{t.forEach((({onFulfilled:t})=>{null==t||t(e,i)}))})),i.addCase(e.rejected,((e,i)=>{t.forEach((({onRejected:t})=>{null==t||t(e,i)}))}))},c=e=>({onFulfilled:t=>{e(t).loading=!1},onPending:t=>{e(t).loading=!0,e(t).error=null},onRejected:(t,i)=>{e(t).loading=!1,e(t).error=i.error}}),h=n.createAsyncThunk("users/me",((e,{extra:{api:t}})=>t.user.me())),v=d(h)({onFulfilled:(e,t)=>{e.me.data=t.payload}},c((e=>e.me))),u={action:h,reducer:v},m=n.createAsyncThunk("tenant/details",((e,{extra:{api:t}})=>t.tenant.details())),f=d(m)({onFulfilled:(e,t)=>{e.tenant.data=t.payload}},c((e=>e.tenant))),_={action:m,reducer:f},g=n.createAsyncThunk("tenant/adminLinkSso",((e,{extra:{api:t}})=>t.tenant.adminLinkSso())),p={action:g,reducer:d(g)({onFulfilled:(e,t)=>{var i;e.tenantAdminLinkSSO.data=(null===(i=t.payload)||void 0===i?void 0:i.adminSSOConfigurationLink)||""}},c((e=>e.tenantAdminLinkSSO)))},w={me:{loading:!1,error:null,data:{}},tenant:{loading:!1,error:null,data:{}},tenantAdminLinkSSO:{loading:!1,error:null,data:""}},b={me:"/v1/auth/me"},S={details:"/v1/mgmt/tenant",adminLinkSso:"/v1/mgmt/tenant/adminlinks/sso/authenticated"},F=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield t.text(),i=JSON.parse(e);if(!t.ok){const e=`${i.errorDescription}${i.errorMessage?`: ${i.errorMessage}`:""}`;throw Error(e||`${t.status} ${t.statusText}`)}t.json=()=>Promise.resolve(i),t.text=()=>Promise.resolve(e)})),P=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({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})}))})),y=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({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})}))})),x=()=>e.__awaiter(void 0,void 0,void 0,(function*(){return new Promise((e=>{e({adminSSOConfigurationLink:"_blank"})}))})),k=({httpClient:t,tenantId:i,mock:s})=>{const n=encodeURIComponent(i||""),a=`?tenant=${n}&id=${n}`;return{details:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(s)return y();if(!i)throw new Error("tenantId is not defined");const e=`${S.details}${a}`,n=yield t.get(e);yield F(n);return yield n.json()})),adminLinkSso:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(s)return x();if(!i)throw new Error("tenantId is not defined");const e=yield t.post(`${S.adminLinkSso}?tenant=${n}`,{tenantId:n},{headers:{"Content-Type":"application/json"}});yield F(e);return yield e.json()}))}},M=({httpClient:t,mock:i})=>({me:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i)return P();const e=yield t.get(b.me);return yield F(e),e.json()}))}),G=t.createSingletonMixin((s=>{var n,r,o,l;const d=t.compose(i.projectIdMixin,i.observeAttributesMixin,i.loggerMixin,i.baseUrlMixin,i.cookieConfigMixin)(s);return l=class extends d{constructor(){super(...arguments),n.add(this),r.set(this,void 0)}get widgetId(){return this.getAttribute("widget-id")}get tenantId(){return this.getAttribute("tenant")}get mock(){return this.getAttribute("mock")}get api(){return e.__classPrivateFieldGet(this,r,"f")||e.__classPrivateFieldGet(this,n,"m",o).call(this),e.__classPrivateFieldGet(this,r,"f")}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this),this.observeAttributes(["project-id","base-url","tenant","mock"],(()=>{e.__classPrivateFieldGet(this,r,"f")&&e.__classPrivateFieldGet(this,n,"m",o).call(this)}))}))}},r=new WeakMap,n=new WeakSet,o=function(){this.logger.debug("creating an sdk instance"),e.__classPrivateFieldSet(this,r,((e,t,i,s)=>{const n=a(Object.assign(Object.assign({},e),{persistTokens:!0,baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":s,"x-descope-widget-version":"0.0.1"}}));return{user:M({httpClient:n.httpClient,mock:i}),tenant:k({httpClient:n.httpClient,tenantId:t,mock:i})}})({projectId:this.projectId,baseUrl:this.baseUrl,refreshCookieName:this.refreshCookieName},this.tenantId,"true"===this.mock,this.widgetId),"f")},l})),C=t.createSingletonMixin((e=>{const s=t.compose(i.createStateManagementMixin({name:"widget",initialState:w,reducers:{},extraReducers:e=>{u.reducer(e),_.reducer(e),p.reducer(e)},asyncActions:{getMe:u.action,getTenant:_.action,getTenantAdminLinkSSO:p.action}}),i.initLifecycleMixin,i.loggerMixin,G)(e);return class extends s{constructor(...e){super(...e),this.state=w,this.subscribe((e=>{this.logger.debug("State update:",e),this.state=e}))}}})),R="widget-flow",I=t.createSingletonMixin((n=>{var a,r,d;return d=class extends(t.compose(i.initLifecycleMixin,i.modalMixin,C,i.cookieConfigMixin,i.loggerMixin,i.themeMixin)(n)){constructor(){super(...arguments),a.add(this)}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);const s=l(R);s&&(!function(e){if(window.history.replaceState&&l(e)){const t=new URL(window.location.href),i=new URLSearchParams(t.search);i.delete(e),t.search=i.toString(),window.history.replaceState({},"",t.toString())}}(R),e.__classPrivateFieldGet(this,a,"m",r).call(this,s))}))}},a=new WeakSet,r=function(e){const t=this.createModal({"data-id":"redirect-flow"});t.setContent(o({projectId:this.projectId,flowId:e,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme}));new s.FlowDriver((()=>{var e;return null===(e=t.ele)||void 0===e?void 0:e.querySelector("descope-wc")}),{logger:this.logger}).onSuccess((()=>{t.close(),this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()})),t.afterClose=()=>{t.remove()},t.open()},d})),U=e=>e.tenant.data,D=e=>e.tenantAdminLinkSSO.data,A=r.createSelector(U,(e=>e.customAttributes||{})),W=r.createSelector(U,(e=>e.name||"")),T=r.createSelector(U,(e=>e.selfProvisioningDomains||[])),E=r.createSelector(U,(e=>e.enforceSSO||!1)),j=t.createSingletonMixin((e=>class extends(t.compose(i.themeMixin,i.observeAttributesMixin)(e)){syncFlowTheme(e){e.theme=this.theme,this.observeAttributes(["theme"],(()=>{e.theme=this.theme}))}})),O=t.createSingletonMixin((s=>{const n=t.compose(i.staticResourcesMixin,i.createValidateAttributesMixin({"widget-id":i.createValidateAttributesMixin.missingAttrValidator}))(s);return class extends n{get widgetId(){return this.getAttribute("widget-id")}fetchWidgetPage(t){return e.__awaiter(this,void 0,void 0,(function*(){return(yield this.fetchStaticResource(`tenant-profile-widget/${this.widgetId}/${t}`,"text")).body}))}}}));const N=t.createSingletonMixin((s=>{var n,a,r;return r=class extends(t.compose(i.loggerMixin,i.initLifecycleMixin,i.descopeUiMixin,i.initElementMixin,O,C)(s)){constructor(){super(...arguments),n.add(this)}onWidgetRootReady(){return e.__awaiter(this,void 0,void 0,(function*(){}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.init)||void 0===i?void 0:i.call(this);try{yield Promise.all([this.actions.getMe(),this.actions.getTenant(),this.actions.getTenantAdminLinkSSO()])}catch(e){}const s=this.state.me.error||(e=>e.tenant.error)(this.state)||(e=>e.tenantAdminLinkSSO.error)(this.state);if(s){this.contentRootElement.innerHTML="";const e="object"==typeof s&&null!==s&&"message"in s?s.message:String(s)||"An error occurred";this.contentRootElement.append(function({mainMessage:e="An error occurred"}){const t=document.createElement("div");t.setAttribute("data-id","widget-error"),t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="center",t.style.justifyContent="center",t.style.padding="72px 36px",t.style.background="#fff",t.style.borderRadius="12px",t.style.boxShadow="0 2px 8px rgba(0,0,0,0.03)",t.style.margin="32px auto",t.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",t.appendChild(i);const s=document.createElement("div");return s.textContent=e,s.style.fontWeight="bold",s.style.fontSize="20px",s.style.color="#222",s.style.textAlign="center",s.style.marginTop="8px",t.appendChild(s),t}({mainMessage:e}))}else yield e.__classPrivateFieldGet(this,n,"m",a).call(this),this.onWidgetRootReady()}))}},n=new WeakSet,a=function(){return e.__awaiter(this,void 0,void 0,(function*(){const e=t.createTemplate(yield this.fetchWidgetPage("root.html"));yield this.loadDescopeUiComponents(e),this.contentRootElement.append(e.content.cloneNode(!0))}))},r})),L=t.createSingletonMixin((n=>{var a,r,o,l;return l=class extends(t.compose(j,C,i.loggerMixin,N,i.cookieConfigMixin,i.modalMixin)(n)){constructor(){super(...arguments),a.add(this),o.set(this,t.withMemCache((e=>{this.tenantAdminLinkSSODriver.href=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",r).call(this),e.__classPrivateFieldGet(this,o,"f").call(this,D(this.state)),this.subscribe(e.__classPrivateFieldGet(this,o,"f").bind(this),D)}))}},o=new WeakMap,a=new WeakSet,r=function(){this.tenantAdminLinkSSODriver=new s.LinkDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-link[data-id="tenant-admin-link-sso"]')}),{logger:this.logger})},l}));var q;!function(e){e.TEXT="text",e.NUMBER="number",e.BOOLEAN="boolean",e.SINGLE_SELECT="singleSelect",e.ARRAY="array",e.DATE="date"}(q||(q={}));const $=t.createSingletonMixin((n=>{var a,r,l,d,c,h,v,u,m,f,_;return _=class extends(t.compose(j,C,i.loggerMixin,N,i.cookieConfigMixin,i.modalMixin)(n)){constructor(){super(...arguments),a.add(this),r.set(this,{}),l.set(this,{}),d.set(this,{}),c.set(this,{}),u.set(this,t.withMemCache((t=>{var i;const n=null===(i=this.shadowRoot)||void 0===i?void 0:i.querySelectorAll('descope-user-attribute[data-id^="customAttributes."]');Array.from(n).forEach((i=>{const n=i.getAttribute("data-id").replace("customAttributes.",""),r=i.getAttribute("data-type")||q.TEXT,o=t[n],l=new s.UserAttributeDriver(i,{logger:this.logger});l.value=((e,t)=>e===q.DATE&&t?new Date(t).toLocaleString():e===q.BOOLEAN&&void 0!==t?t?"True":"False":(t||"").toString())(r,o),e.__classPrivateFieldGet(this,a,"m",m).call(this,i,n,l,r,n,o),e.__classPrivateFieldGet(this,a,"m",f).call(this,i,n,l)}))})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,u,"f").call(this,A(this.state)),this.subscribe(e.__classPrivateFieldGet(this,u,"f").bind(this),A)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakMap,a=new WeakSet,h=function(t,i,s,n){var a,d;const c=i===q.ARRAY?(n||[]).join(","):n;null===(a=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===a||a.setContent(o({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({customAttributes:{[s]:c}})})),null===(d=e.__classPrivateFieldGet(this,l,"f")[t])||void 0===d||d.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,r,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},v=function(t){var i,s;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.setContent(o({projectId:this.projectId,flowId:t,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),null===(s=e.__classPrivateFieldGet(this,c,"f")[t])||void 0===s||s.onSuccess((()=>{var i;null===(i=e.__classPrivateFieldGet(this,d,"f")[t])||void 0===i||i.close(),this.actions.getTenant()}))},m=function(t,i,n,o,d,c){const v=t.getAttribute("edit-flow-id");v&&(e.__classPrivateFieldGet(this,r,"f")[v]=this.createModal({"data-id":`edit-${i}`}),e.__classPrivateFieldGet(this,l,"f")[v]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f")[v])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,r,"f")[v].afterClose=e.__classPrivateFieldGet(this,a,"m",h).bind(this,v),n.onEditClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t?void 0:t[v])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",h).call(this,v,o,d,c),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")[v]))},f=function(t,i,n){const r=t.getAttribute("delete-flow-id");r&&(e.__classPrivateFieldGet(this,d,"f")[r]=this.createModal({"data-id":`delete-${i}`}),e.__classPrivateFieldGet(this,c,"f")[r]=new s.FlowDriver((()=>{var t,i;return null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f")[r])||void 0===t?void 0:t.ele)||void 0===i?void 0:i.querySelector("descope-wc")}),{logger:this.logger}),e.__classPrivateFieldGet(this,d,"f")[r].afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this,r),n.onDeleteClick((()=>{var t,i;null===(i=null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t?void 0:t[r])||void 0===i||i.open()})),e.__classPrivateFieldGet(this,a,"m",v).call(this,r),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")[r]))},_})),B=t.createSingletonMixin((n=>{var a,r,l,d,c,h,v,u,m,f,_,g;return g=class extends(t.compose(j,C,i.loggerMixin,N,i.cookieConfigMixin,i.modalMixin)(n)){constructor(){super(...arguments),a.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),_.set(this,t.withMemCache((e=>{this.tenantEmailDomainsDriver.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",f).call(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,_,"f").call(this,T(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),T)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,_=new WeakMap,a=new WeakSet,h=function(){this.tenantEmailDomainsDriver.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,l,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantEmailDomains:T(this.state)})})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantEmailDomainsDriver.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-tenant-email-domains"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",m).bind(this),e.__classPrivateFieldGet(this,a,"m",m).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},m=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.tenantEmailDomainsDriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEmailDomainsDriver=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-email-domains-edit"]')}),{logger:this.logger}),this.tenantEmailDomainsDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()})),this.tenantEmailDomainsDriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},g})),H=t.createSingletonMixin((n=>{var a,r,l,d,c,h,v,u,m,f,_,g;return g=class extends(t.compose(j,C,i.loggerMixin,N,i.cookieConfigMixin,i.modalMixin)(n)){constructor(){super(...arguments),a.add(this),r.set(this,void 0),l.set(this,void 0),d.set(this,void 0),c.set(this,void 0),_.set(this,t.withMemCache((e=>{this.tenantEnforceSSODriver.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",f).call(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,a,"m",u).call(this),e.__classPrivateFieldGet(this,_,"f").call(this,E(this.state)),this.subscribe(e.__classPrivateFieldGet(this,_,"f").bind(this),E)}))}},r=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,_=new WeakMap,a=new WeakSet,h=function(){this.tenantEnforceSSODriver.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"edit-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,l,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",v).bind(this),e.__classPrivateFieldGet(this,a,"m",v).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},v=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({enforceSSO:E(this.state)})})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},u=function(){this.tenantEnforceSSODriver.deleteFlowId&&(e.__classPrivateFieldSet(this,d,this.createModal({"data-id":"delete-tenant-enforce-sso"}),"f"),e.__classPrivateFieldSet(this,c,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,d,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,d,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",m).bind(this),e.__classPrivateFieldGet(this,a,"m",m).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,c,"f")))},m=function(){e.__classPrivateFieldGet(this,d,"f").setContent(o({projectId:this.projectId,flowId:this.tenantEnforceSSODriver.deleteFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme})),e.__classPrivateFieldGet(this,c,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,d,"f").close(),this.actions.getTenant()}))},f=function(){this.tenantEnforceSSODriver=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-enforce-sso-edit"]')}),{logger:this.logger}),this.tenantEnforceSSODriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()})),this.tenantEnforceSSODriver.onDeleteClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,d,"f"))||void 0===t||t.open()}))},g})),J=t.createSingletonMixin((n=>{var a,r,l,d,c,h,v,u;return u=class extends(t.compose(j,C,i.loggerMixin,N,i.cookieConfigMixin,i.modalMixin)(n)){constructor(){super(...arguments),a.add(this),r.set(this,void 0),l.set(this,void 0),v.set(this,t.withMemCache((e=>{this.tenantNameDriver.value=e})))}onWidgetRootReady(){const t=Object.create(null,{onWidgetRootReady:{get:()=>super.onWidgetRootReady}});return e.__awaiter(this,void 0,void 0,(function*(){var i;yield null===(i=t.onWidgetRootReady)||void 0===i?void 0:i.call(this),e.__classPrivateFieldGet(this,a,"m",h).call(this),e.__classPrivateFieldGet(this,a,"m",d).call(this),e.__classPrivateFieldGet(this,v,"f").call(this,W(this.state)),this.subscribe(e.__classPrivateFieldGet(this,v,"f").bind(this),W)}))}},r=new WeakMap,l=new WeakMap,v=new WeakMap,a=new WeakSet,d=function(){this.tenantNameDriver.editFlowId&&(e.__classPrivateFieldSet(this,r,this.createModal({"data-id":"tenant-profile-set-name"}),"f"),e.__classPrivateFieldSet(this,l,new s.FlowDriver((()=>{var t;return null===(t=e.__classPrivateFieldGet(this,r,"f").ele)||void 0===t?void 0:t.querySelector("descope-wc")}),{logger:this.logger}),"f"),e.__classPrivateFieldGet(this,r,"f").afterClose=e.__classPrivateFieldGet(this,a,"m",c).bind(this),e.__classPrivateFieldGet(this,a,"m",c).call(this),this.syncFlowTheme(e.__classPrivateFieldGet(this,l,"f")))},c=function(){e.__classPrivateFieldGet(this,r,"f").setContent(o({projectId:this.projectId,flowId:this.tenantNameDriver.editFlowId,tenant:this.tenantId,baseUrl:this.baseUrl,baseStaticUrl:this.baseStaticUrl,baseCdnUrl:this.baseCdnUrl,refreshCookieName:this.refreshCookieName,theme:this.theme,form:JSON.stringify({tenantName:W(this.state)})})),e.__classPrivateFieldGet(this,l,"f").onSuccess((()=>{e.__classPrivateFieldGet(this,r,"f").close(),this.actions.getTenant()}))},h=function(){this.tenantNameDriver=new s.UserAttributeDriver((()=>{var e;return null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector('descope-user-attribute[data-id="tenant-name-edit"]')}),{logger:this.logger}),this.tenantNameDriver.onEditClick((()=>{var t;null===(t=e.__classPrivateFieldGet(this,r,"f"))||void 0===t||t.open()}))},u})),V=t.createSingletonMixin((s=>class extends(t.compose(i.debuggerMixin,i.themeMixin,I,N,J,B,H,$,L)(s)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this)}))}})),z=t.compose((t=>class extends(V(t)){init(){const t=Object.create(null,{init:{get:()=>super.init}});return e.__awaiter(this,void 0,void 0,(function*(){var e;yield null===(e=t.init)||void 0===e?void 0:e.call(this);(customElements.get("descope-wc")||(yield import("@descope/web-component").then((e=>e.default)))).sdkConfigOverrides={baseHeaders:{"x-descope-widget-type":"tenant-profile-widget","x-descope-widget-id":this.getAttribute("widget-id"),"x-descope-widget-version":"0.0.1"}}}))}}))(HTMLElement);customElements.define("descope-tenant-profile-widget",z),module.exports=z;
6
+ //# sourceMappingURL=index.js.map