@descope/web-component 0.0.0-custom-screens.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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/cjs/constants/content.js +1 -0
- package/dist/cjs/constants/general.js +1 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/uiComponents.js +1 -0
- package/dist/cjs/debugger-wc.js +1 -0
- package/dist/cjs/descope-wc/BaseDescopeWc.js +1 -0
- package/dist/cjs/descope-wc/DescopeWc.js +1 -0
- package/dist/cjs/descope-wc/index.js +1 -0
- package/dist/cjs/descope-wc/initTemplate.js +1 -0
- package/dist/cjs/descope-wc/sdkScripts/fingerprint.js +1 -0
- package/dist/cjs/descope-wc/sdkScripts/fingerprintDescope.js +1 -0
- package/dist/cjs/descope-wc/sdkScripts/forter.js +1 -0
- package/dist/cjs/descope-wc/sdkScripts/index.js +1 -0
- package/dist/cjs/helpers/abTestingKey.js +1 -0
- package/dist/cjs/helpers/conditions.js +1 -0
- package/dist/cjs/helpers/flowInputs.js +1 -0
- package/dist/cjs/helpers/helpers.js +1 -0
- package/dist/cjs/helpers/lastAuth.js +1 -0
- package/dist/cjs/helpers/positionHelpers.js +1 -0
- package/dist/cjs/helpers/state.js +1 -0
- package/dist/cjs/helpers/templates.js +1 -0
- package/dist/cjs/helpers/webauthn.js +1 -0
- package/dist/cjs/mixins/formMountMixin.js +1 -0
- package/dist/cjs/types.js +1 -0
- package/dist/esm/constants/content.js +1 -0
- package/dist/esm/constants/general.js +1 -0
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/constants/uiComponents.js +1 -0
- package/dist/esm/debugger-wc.js +1 -0
- package/dist/esm/descope-wc/BaseDescopeWc.js +1 -0
- package/dist/esm/descope-wc/DescopeWc.js +1 -0
- package/dist/esm/descope-wc/index.js +1 -0
- package/dist/esm/descope-wc/initTemplate.js +1 -0
- package/dist/esm/descope-wc/sdkScripts/fingerprint.js +1 -0
- package/dist/esm/descope-wc/sdkScripts/fingerprintDescope.js +1 -0
- package/dist/esm/descope-wc/sdkScripts/forter.js +1 -0
- package/dist/esm/descope-wc/sdkScripts/index.js +1 -0
- package/dist/esm/helpers/abTestingKey.js +1 -0
- package/dist/esm/helpers/conditions.js +1 -0
- package/dist/esm/helpers/flowInputs.js +1 -0
- package/dist/esm/helpers/helpers.js +1 -0
- package/dist/esm/helpers/lastAuth.js +1 -0
- package/dist/esm/helpers/positionHelpers.js +1 -0
- package/dist/esm/helpers/state.js +1 -0
- package/dist/esm/helpers/templates.js +1 -0
- package/dist/esm/helpers/webauthn.js +1 -0
- package/dist/esm/mixins/formMountMixin.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/index.d.ts +1365 -0
- package/dist/index.js +3 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 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,166 @@
|
|
|
1
|
+
# @descope/web-component
|
|
2
|
+
|
|
3
|
+
Create your login pages on our console-app, once done, you can use this library to inject those pages to your app</br>
|
|
4
|
+
it registers- a [web component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) and update the web-component content based on the relevant page,
|
|
5
|
+
See usage example below
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
### Install the package
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @descope/web-component
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### As a library
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import '@descope/web-component' // This import will define `descope-wc` custom element
|
|
19
|
+
import { DescopeWc } // In case you need types definition or you want to use the class directly
|
|
20
|
+
|
|
21
|
+
// Render Descope Web Component, for example:
|
|
22
|
+
render(){
|
|
23
|
+
return (
|
|
24
|
+
<descope-wc project-id="myProjectId"/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### In HTML file
|
|
30
|
+
|
|
31
|
+
- Copy the file `@descope/web-component/dist/index.js` rename it to `descope-wc.js` and place it where your HTML file is located
|
|
32
|
+
|
|
33
|
+
- Add the following script tag to your HTML file
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<head>
|
|
37
|
+
<script src="./descope-wc.js"></script>
|
|
38
|
+
</head>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- Now you can add the custom element to your HTML
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<descope-wc project-id="<project-id>" flow-id="<flow-id>" form='{ "email": "predefinedname@domain.com", "myCustomInput": "12" }' client='{ "browserVersion": window.navigator.appVersion }'></descope-wc>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Note: the `form` and `client` are optional parameters to add additional information that can be used in the flow. For more information [click here](https://docs.descope.com/knowledgebase/descopeflows/flowinputs/#HTML).
|
|
48
|
+
|
|
49
|
+
### Run Example
|
|
50
|
+
|
|
51
|
+
To run the example:
|
|
52
|
+
|
|
53
|
+
1. Install dependencies `pnpm i`
|
|
54
|
+
1. Create a `.env` file and the following variables:
|
|
55
|
+
|
|
56
|
+
```env
|
|
57
|
+
// .env
|
|
58
|
+
# Descope Project ID
|
|
59
|
+
DESCOPE_PROJECT_ID=<project-id>
|
|
60
|
+
# Flow ID to run, e.g. sign-up-or-in
|
|
61
|
+
DESCOPE_FLOW_ID=<flow-id>
|
|
62
|
+
# Optional - Descope base URL
|
|
63
|
+
DESCOPE_BASE_URL
|
|
64
|
+
# Optional - Descope locale (according to the target locales configured in the flow)
|
|
65
|
+
DESCOPE_LOCALE=<locale>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
1. Run the sample `pnpm run start` / `pnpm run start-web-sample`
|
|
69
|
+
|
|
70
|
+
NOTE: This package is a part of a monorepo. so if you make changes in a dependency, you will have to rerun `npm run start` / `pnpm run start-web-sample` (this is a temporary solution until we improve the process to fit to monorepo).
|
|
71
|
+
|
|
72
|
+
## Optional Attributes
|
|
73
|
+
|
|
74
|
+
| Attribute | Available options | Default value |
|
|
75
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
|
|
76
|
+
| base-url | Custom Descope base URL | **""** |
|
|
77
|
+
| theme | **"light"** - Light theme</br>**"dark"** - Dark theme</br>**"os"** - Auto select a theme based on the OS theme settings | **"light"** |
|
|
78
|
+
| debug | **"true"** - Enable debugger</br>**"false"** - Disable debugger | **"false"** |
|
|
79
|
+
| preview | **"true"** - Run flow in a preview mode</br>**"false"** - Do run flow in a preview mode | **"false"** |
|
|
80
|
+
| auto-focus | **"true"** - Automatically focus on the first input of each screen</br>**"false"** - Do not automatically focus on screen's inputs</br>**"skipFirstScreen"** - Automatically focus on the first input of each screen, except first screen | **"true"** |
|
|
81
|
+
|
|
82
|
+
| validate-on-blur | **"true"** - Triggers the input validation upon blur in addition to the validation on submit</br>**"false"** - Do not triggers validation upon blur</br> | **"false"** |
|
|
83
|
+
|
|
84
|
+
| restart-on-error | **"true"** - In case of flow version mismatch, will restart the flow if the components version was not changed</br>**"false"** - Do not restart the flow automatically</br> | **"false"** |
|
|
85
|
+
|
|
86
|
+
| storage-prefix | **String** - A prefix to add to the key of the local storage when persisting tokens | **""** |
|
|
87
|
+
| store-last-authenticated-user | **"true"** - Stores last-authenticated user details in local storage when flow is completed</br>**"false"** - Do not store last-auth user details. Disabling this flag may cause last-authenticated user features to not function properly | **"true"** |
|
|
88
|
+
| keep-last-authenticated-user-after-logout | **"true"** - Do not clear the last authenticated user details from the browser storage after logout</br>**"false"** - Clear the last authenticated user details from the browser storage after logout | **"false"** |
|
|
89
|
+
| style-id | **"String"** - Set a specific style to load rather then the default style | **""** |
|
|
90
|
+
|
|
91
|
+
## Optional Properties
|
|
92
|
+
|
|
93
|
+
### `errorTransformer` - A function that receives an error object and returns a string. The returned string will be displayed to the user.
|
|
94
|
+
|
|
95
|
+
The function can be used to translate error messages to the user's language or to change the error message.
|
|
96
|
+
|
|
97
|
+
Usage example:
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
function translateError(error) {
|
|
101
|
+
const translationMap = {
|
|
102
|
+
SAMLStartFailed: 'No es posible iniciar sesión en este momento, por favor intenta nuevamente más tarde',
|
|
103
|
+
};
|
|
104
|
+
return translationMap[error.type] || error.text;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const descopeWcEle = document.getElementsByTagName('descope-wc')[0];
|
|
108
|
+
|
|
109
|
+
descopeWcEle.errorTransformer = translateError;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### `logger` - An object that defines how to log error, warning and info. Defaults to console.error, console.warn and console.info respectively
|
|
113
|
+
|
|
114
|
+
Usage example:
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
const logger = {
|
|
118
|
+
info: (message: string, description: string, state: any) => {
|
|
119
|
+
console.log(message, description);
|
|
120
|
+
},
|
|
121
|
+
warn: (title: string, description: string) => {
|
|
122
|
+
console.warn(`WARN: ${title}`, description);
|
|
123
|
+
},
|
|
124
|
+
error: (title: string, description: string) => {
|
|
125
|
+
console.error(`ERROR: ${title}`, description);
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const descopeWcEle = document.getElementsByTagName('descope-wc')[0];
|
|
130
|
+
|
|
131
|
+
descopeWcEle.logger = logger;
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Events
|
|
135
|
+
|
|
136
|
+
### `error` - Fired when an error occurs. The event detail contains the error object.
|
|
137
|
+
|
|
138
|
+
Usage example:
|
|
139
|
+
|
|
140
|
+
```javascript
|
|
141
|
+
const descopeWcEle = document.getElementsByTagName('descope-wc')[0];
|
|
142
|
+
descopeWcEle.addEventListener('error', (e) => alert(`Error! - ${e.detail.errorMessage}`));
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### `success` - Fired when the flow is completed successfully. The event detail contains the flow result.
|
|
146
|
+
|
|
147
|
+
Usage example:
|
|
148
|
+
|
|
149
|
+
```javascript
|
|
150
|
+
const descopeWcEle = document.getElementsByTagName('descope-wc')[0];
|
|
151
|
+
descopeWcEle.addEventListener('success', (e) => alert(`Success! - ${JSON.stringify(e.detail)}`));
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `ready` - Fired when the page is ready.
|
|
155
|
+
|
|
156
|
+
This event is useful for showing/hiding a loading indication before the page is loading.
|
|
157
|
+
Note: in cases where the flow involves redirection to a non-initial stage of the process, such as with Magic Link or OAuth, this event is also dispatched.
|
|
158
|
+
|
|
159
|
+
Usage example:
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
const descopeWcEle = document.getElementsByTagName('descope-wc')[0];
|
|
163
|
+
descopeWcEle.addEventListener('ready', () => {
|
|
164
|
+
// Remove/hide the loading indication
|
|
165
|
+
});
|
|
166
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("./general.js").IS_LOCAL_STORAGE&&localStorage.getItem("base.content.url")||"";exports.ASSETS_FOLDER="v2-beta",exports.BASE_CONTENT_URL="https://static.descope.com/pages",exports.CONFIG_FILENAME="config.json",exports.OVERRIDE_CONTENT_URL=e,exports.PREV_VER_ASSETS_FOLDER="v2-alpha";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const E="undefined"!=typeof localStorage;exports.FETCH_ERROR_RESPONSE_ERROR_CODE="J151001",exports.FETCH_EXCEPTION_ERROR_CODE="J151000",exports.IS_LOCAL_STORAGE=E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _=require("./content.js"),E=require("./uiComponents.js");exports.ASSETS_FOLDER=_.ASSETS_FOLDER,exports.BASE_CONTENT_URL=_.BASE_CONTENT_URL,exports.CONFIG_FILENAME=_.CONFIG_FILENAME,exports.OVERRIDE_CONTENT_URL=_.OVERRIDE_CONTENT_URL,exports.PREV_VER_ASSETS_FOLDER=_.PREV_VER_ASSETS_FOLDER,exports.UI_COMPONENTS_URL_KEY=E.UI_COMPONENTS_URL_KEY,exports.APPLICATION_SCOPES_PARAM_NAME="application_scopes",exports.CUSTOM_INTERACTIONS={submit:"submit",polling:"polling"},exports.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD="data-exclude-field",exports.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON="data-exclude-next",exports.DESCOPE_ATTRIBUTE_PREFIX="data-descope-",exports.DESCOPE_IDP_INITIATED_PARAM_NAME="descope_idp_initiated",exports.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY="dls_last_auth",exports.ELEMENTS_TO_IGNORE_ENTER_KEY_ON=["descope-multi-select-combo-box","descope-text-area"],exports.ELEMENT_TYPE_ATTRIBUTE="data-type",exports.HAS_DYNAMIC_VALUES_ATTR_NAME="data-has-dynamic-attr-values",exports.OIDC_ERROR_REDIRECT_URI_PARAM_NAME="oidc_error_redirect_uri",exports.OIDC_IDP_STATE_ID_PARAM_NAME="state_id",exports.OIDC_LOGIN_HINT_PARAM_NAME="oidc_login_hint",exports.OIDC_PROMPT_PARAM_NAME="oidc_prompt",exports.RESPONSE_ACTIONS={redirect:"redirect",poll:"poll",webauthnCreate:"webauthnCreate",webauthnGet:"webauthnGet",nativeBridge:"nativeBridge",loadForm:"loadForm"},exports.SAML_IDP_STATE_ID_PARAM_NAME="saml_idp_state_id",exports.SAML_IDP_USERNAME_PARAM_NAME="saml_idp_username",exports.SDK_SCRIPT_RESULTS_KEY="sdkScriptsResults",exports.SSO_APP_ID_PARAM_NAME="sso_app_id",exports.THIRD_PARTY_APP_ID_PARAM_NAME="third_party_app_id",exports.THIRD_PARTY_APP_STATE_ID_PARAM_NAME="third_party_app_state_id",exports.URL_CODE_PARAM_NAME="code",exports.URL_ERR_PARAM_NAME="err",exports.URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME="ra-backup-callback",exports.URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME="ra-callback",exports.URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME="ra-challenge",exports.URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME="ra-initiator",exports.URL_RUN_IDS_PARAM_NAME="descope-login-flow",exports.URL_TOKEN_PARAM_NAME="t";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./general.js");const t="base.ui.components.url";e.IS_LOCAL_STORAGE&&localStorage.getItem(t),e.IS_LOCAL_STORAGE&&localStorage.getItem(t),exports.UI_COMPONENTS_URL_KEY=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("tslib");require("./constants/content.js"),require("./constants/uiComponents.js"),require("./types.js");var s=require("./helpers/state.js");require("@descope/escape-markdown"),require("./helpers/webauthn.js");var t,n,i,l,a,r,o,d,c,p,h=require("./helpers/positionHelpers.js");const g=document.createElement("template");g.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class v extends HTMLElement{constructor(){super(),t.add(this),n.set(this,new s({messages:[]})),i.set(this,void 0),l.set(this,void 0),a.set(this,void 0),r.set(this,{resize:e.__classPrivateFieldGet(this,t,"m",p).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(g.content.cloneNode(!0)),e.__classPrivateFieldSet(this,i,this.shadowRoot.querySelector(".debugger"),"f"),e.__classPrivateFieldSet(this,l,e.__classPrivateFieldGet(this,i,"f").querySelector(".content"),"f"),e.__classPrivateFieldSet(this,a,e.__classPrivateFieldGet(this,i,"f").querySelector(".header"),"f")}updateData(s){e.__classPrivateFieldGet(this,n,"f").update((e=>({messages:e.messages.concat(s)})))}connectedCallback(){h.dragElement(e.__classPrivateFieldGet(this,i,"f"),e.__classPrivateFieldGet(this,a,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",e.__classPrivateFieldGet(this,r,"f").resize),h.addOnResize(e.__classPrivateFieldGet(this,i,"f")),e.__classPrivateFieldGet(this,i,"f").onresize=e.__classPrivateFieldGet(this,t,"m",c).bind(this),e.__classPrivateFieldGet(this,n,"f").subscribe(e.__classPrivateFieldGet(this,t,"m",o).bind(this))}disconnectedCallback(){e.__classPrivateFieldGet(this,n,"f").unsubscribeAll(),window.removeEventListener("resize",e.__classPrivateFieldGet(this,r,"f").resize)}}n=new WeakMap,i=new WeakMap,l=new WeakMap,a=new WeakMap,r=new WeakMap,t=new WeakSet,o=function(s){e.__classPrivateFieldGet(this,t,"m",d).call(this,s),e.__classPrivateFieldGet(this,t,"m",c).call(this)},d=function(s){e.__classPrivateFieldGet(this,l,"f").innerHTML=s.messages.map((e=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${e.title}\n </div>\n <div class="msg_desc">\n ${e.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},c=function(){e.__classPrivateFieldGet(this,l,"f").querySelectorAll(".msg").forEach((e=>{const s=e.querySelector(".msg_desc"),t=s.scrollWidth>s.clientWidth,n=s.clientHeight>20;t||n?(e.classList.add("collapsible"),e.onclick=s=>{s.target.classList.contains("msg_desc")||e.classList.toggle("collapsed")}):(e.classList.remove("collapsible"),e.onclick=null)}))},p=function(){const[s,t]=h.limitCoordinateToScreenBoundaries(e.__classPrivateFieldGet(this,i,"f"),Number.parseInt(e.__classPrivateFieldGet(this,i,"f").style.left,10),Number.parseInt(e.__classPrivateFieldGet(this,i,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});e.__classPrivateFieldGet(this,i,"f").style.top=`${t}px`,e.__classPrivateFieldGet(this,i,"f").style.left=`${s}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",v),module.exports=v;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("tslib"),e=require("@descope/sdk-helpers"),i=require("@descope/sdk-mixins/static-resources-mixin"),s=require("@descope/sdk-mixins/theme-mixin"),r=require("@descope/web-js-sdk"),o=require("../constants/index.js"),n=require("../helpers/helpers.js"),a=require("../helpers/state.js");require("@descope/escape-markdown"),require("../helpers/webauthn.js");var l,u,d,c,h,g,f,v,p,_,b,m,w,C,F,A,P,x,E,k,I,y=require("../helpers/flowInputs.js"),G=require("../mixins/formMountMixin.js"),j=require("./initTemplate.js"),L=require("../constants/content.js"),S=require("../constants/general.js");function U(t){return Object.freeze({__proto__:null,default:t})}const M=e.compose(s.themeMixin,i.staticResourcesMixin,G.formMountMixin)(HTMLElement);class O extends M{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(e){super(),l.add(this),d.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t.__classPrivateFieldGet(this,l,"m",k).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},c.set(this,new a),h.set(this,new a),g.set(this,{}),this.getComponentsContext=()=>t.__classPrivateFieldGet(this,g,"f"),this.nextRequestStatus=new a({isLoading:!1}),f.set(this,void 0),v.set(this,{popstate:t.__classPrivateFieldGet(this,l,"m",m).bind(this),componentsContext:t.__classPrivateFieldGet(this,l,"m",P).bind(this)}),p.set(this,void 0),this.getConfig=n.withMemCache((()=>t.__awaiter(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(L.CONFIG_FILENAME,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),t.__classPrivateFieldSet(this,p,e,"f"),t.__classPrivateFieldGet(this,l,"m",_).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return y.transformFlowInputFormData(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return y.extractNestedAttribute(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return t.__awaiter(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return t.__awaiter(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),s=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=s.version)&&void 0!==e||(s.version=0),s}))}getTargetLocales(){return t.__awaiter(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return t.__awaiter(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return t.__awaiter(this,void 0,void 0,(function*(){var i;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(i=e.init)||void 0===i?void 0:i.call(this),t.__classPrivateFieldGet(this,h,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",E).bind(this)),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug}),t.__classPrivateFieldGet(this,l,"m",b).call(this),yield t.__classPrivateFieldGet(this,l,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t.__classPrivateFieldGet(this,l,"m",I).call(this);const{executionId:s,stepId:r,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_,ssoQueryParams:m}=n.handleUrlParams(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.addEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext),t.__classPrivateFieldGet(this,c,"f").subscribe(t.__classPrivateFieldGet(this,l,"m",C).bind(this)),t.__classPrivateFieldGet(this,c,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:r,executionId:s,token:o,code:a,exchangeError:u,redirectAuthCallbackUrl:g,redirectAuthBackupCallbackUri:f,redirectAuthCodeChallenge:p,redirectAuthInitiator:_},m)),t.__classPrivateFieldSet(this,d,!0,"f")}))}disconnectedCallback(){t.__classPrivateFieldGet(this,c,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,h,"f").unsubscribeAll(),t.__classPrivateFieldGet(this,l,"m",x).call(this),window.removeEventListener("popstate",t.__classPrivateFieldGet(this,v,"f").popstate),window.removeEventListener("components-context",t.__classPrivateFieldGet(this,v,"f").componentsContext)}attributeChangedCallback(e,i,s){if(this.shadowRoot.isConnected&&t.__classPrivateFieldGet(this,d,"f")&&i!==s&&u.observedAttributes.includes(e)){t.__classPrivateFieldGet(this,l,"m",b).call(this);const r=null===i;t.__classPrivateFieldGet(this,c,"f").update((({stepId:t,executionId:i})=>{let o=t,a=i;return r||(a=null,o=null,n.clearRunIdsFromUrl()),{[n.camelCase(e)]:s,stepId:o,executionId:a}})),t.__classPrivateFieldGet(this,h,"f").update({isDebug:this.debug})}}}u=O,d=new WeakMap,c=new WeakMap,h=new WeakMap,g=new WeakMap,f=new WeakMap,v=new WeakMap,p=new WeakMap,l=new WeakSet,_=function(){this.shadowRoot.appendChild(j.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},b=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];u.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[n.camelCase(e)])throw Error(`${e} cannot be empty`)}))},m=function(){const{stepId:e,executionId:i}=n.getRunIdsFromUrl(this.flowId);t.__classPrivateFieldGet(this,c,"f").update({stepId:e,executionId:i})},w=function(e,i){this.sdk=r(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},u.sdkConfigOverrides),{projectId:e,baseUrl:i})),["start","next"].forEach((e=>{const i=this.sdk.flow[e];this.sdk.flow[e]=(...e)=>t.__awaiter(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...e)}catch(t){return{error:{errorCode:S.FETCH_EXCEPTION_ERROR_CODE,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},C=function(e,i,s){return t.__awaiter(this,void 0,void 0,(function*(){const{projectId:i,baseUrl:r}=e;if(s("projectId")||s("baseUrl")){if(!i)return;t.__classPrivateFieldGet(this,l,"m",w).call(this,i,r)}t.__classPrivateFieldGet(this,p,"f").call(this,e)}))},F=function(){return t.__awaiter(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t.__classPrivateFieldGet(this,l,"m",A).call(this))}))},A=function(){return t.__awaiter(this,void 0,void 0,(function*(){const t=n.getContentUrl({projectId:this.projectId,filename:L.CONFIG_FILENAME,assetsFolder:L.PREV_VER_ASSETS_FOLDER,baseUrl:this.baseStaticUrl});try{return yield n.fetchContent(t,"json"),!0}catch(t){return!1}}))},P=function(e){t.__classPrivateFieldSet(this,g,Object.assign(Object.assign({},t.__classPrivateFieldGet(this,g,"f")),e.detail),"f")},x=function(){var e;null===(e=t.__classPrivateFieldGet(this,f,"f"))||void 0===e||e.remove(),t.__classPrivateFieldSet(this,f,null,"f")},E=function(e){return t.__awaiter(this,arguments,void 0,(function*({isDebug:e}){e?(t.__classPrivateFieldSet(this,f,document.createElement("descope-debugger"),"f"),Object.assign(t.__classPrivateFieldGet(this,f,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield Promise.resolve().then((function(){return U(require("../debugger-wc.js"))})),document.body.appendChild(t.__classPrivateFieldGet(this,f,"f"))):t.__classPrivateFieldGet(this,l,"m",x).call(this)}))},k=function(e,i){var s;e&&this.debug&&(null===(s=t.__classPrivateFieldGet(this,f,"f"))||void 0===s||s.updateData({title:e,description:i}))},I=function(){this.rootElement.onkeydown=t=>{var e,i,s;const r=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),n=o.ELEMENTS_TO_IGNORE_ENTER_KEY_ON.includes(null!==(s=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==s?s:"");if("Enter"!==t.key||r||n)return;t.preventDefault();const a=this.rootElement.querySelectorAll("descope-button");if(1===a.length&&"false"!==a[0].getAttribute("auto-submit"))return void a[0].click();const l=Array.from(a).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===l.length)return void l[0].click();const u=Array.from(a).filter((t=>"button"===t.getAttribute("data-type")));if(1===u.length)"false"!==u[0].getAttribute("auto-submit")&&u[0].click();else if(0===u.length){const t=Array.from(a).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},O.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"0.0.0-customScreen.1"}},module.exports=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,i,s,o,n,r,a,l,d,c,h,u,p,g,v,m,f,_,b,w,S,I,C,E,y=require("tslib"),O=require("@descope/web-js-sdk"),R=require("../constants/index.js"),P=require("../helpers/helpers.js"),T=require("../helpers/state.js"),F=require("../helpers/templates.js"),A=require("../helpers/webauthn.js"),k=require("../helpers/abTestingKey.js"),U=require("../helpers/conditions.js"),N=require("../helpers/lastAuth.js"),j=require("../types.js"),x=require("./BaseDescopeWc.js"),G=require("./sdkScripts/index.js"),L=require("../constants/general.js");t=new WeakMap,i=new WeakMap,s=new WeakMap,r=new WeakMap,a=new WeakMap,l=new WeakMap,d=new WeakMap,c=new WeakMap,w=new WeakMap,e=new WeakSet,o=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},n=function(){return y.__awaiter(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},h=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},u=function(t,s){return y.__awaiter(this,void 0,void 0,(function*(){var o;null===(o=y.__classPrivateFieldGet(this,i,"f"))||void 0===o||o.abort();const n=t.querySelector('*[autocomplete="webauthn"]');if(n&&(yield A.isConditionalLoginSupported())){const{options:t,transactionId:o}=(yield y.__classPrivateFieldGet(this,c,"f").call(this))||{};t&&o&&(y.__classPrivateFieldGet(this,e,"m",h).call(this,n),y.__classPrivateFieldSet(this,i,new AbortController,"f"),yield this.getFlowConfig(),yield this.getProjectConfig(),this.sdk.webauthn.helpers.conditional(t,y.__classPrivateFieldGet(this,i,"f")).then((e=>y.__awaiter(this,void 0,void 0,(function*(){s(n.id,{transactionId:o,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},p=function(t){t&&y.__classPrivateFieldGet(this,e,"m",E).call(this,"ready",{}),y.__classPrivateFieldGet(this,e,"m",E).call(this,"page-updated",{})},g=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,s;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(s=t.checkValidity)||void 0===s?void 0:s.call(t)))})),e},v=function(){return y.__awaiter(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${R.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`));return(yield Promise.all(e.map((e=>y.__awaiter(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},m=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},f=function(e={}){var t,i;const s=P.getFirstNonEmptyValue(e,["externalId","email","phone"]),o=P.getFirstNonEmptyValue(e,["newPassword","password"]);if(s&&o)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:s,password:o});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},_=function(){P.clearPreviousExternalInputs();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>y.__classPrivateFieldGet(this,e,"m",b).call(this,t)))},b=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),s=`input-${e.id}-${i}`,o=document.createElement("slot");o.setAttribute("name",s),o.setAttribute("slot",i),e.appendChild(o),t.setAttribute("slot",s),this.appendChild(t)}))},S=function(e){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((t=>{t.addEventListener("input",(()=>{var i;(null===(i=t.checkValidity)||void 0===i?void 0:i.call(t))&&y.__classPrivateFieldGet(this,w,"f").call(this,t,e)}))}))},I=function(t){this.contentRootElement.querySelectorAll(`descope-button:not([${R.DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON}])`).forEach((e=>{e.onclick=()=>{y.__classPrivateFieldGet(this,w,"f").call(this,e,t)}})),y.__classPrivateFieldGet(this,e,"m",S).call(this,t)},C=function(e,t){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===j.Direction.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.contentRootElement.classList.add("fade-out")},E=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))},module.exports=class extends x{static set sdkConfigOverrides(e){x.sdkConfigOverrides=e}static get sdkConfigOverrides(){return x.sdkConfigOverrides}constructor(){const h=new T({deferredRedirect:!1});super(h.update.bind(h)),e.add(this),this.stepState=new T({},{updateOnlyOnChange:!1}),t.set(this,void 0),i.set(this,null),s.set(this,{visibilitychange:y.__classPrivateFieldGet(this,e,"m",o).bind(this)}),this.bridgeVersion=1,this.nativeResume=(e,t)=>{var i;const s=JSON.parse(t);if(this.logger.info(`nativeResume received payload of type '${e}'`),"oauthWeb"===e||"sso"===e){let{exchangeCode:e}=s;if(!e){e=null===(i=new URL(s.url).searchParams)||void 0===i?void 0:i.get(R.URL_CODE_PARAM_NAME)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===e){const e=new URL(s.url),t=e.searchParams.get(R.URL_TOKEN_PARAM_NAME),i=e.searchParams.get(R.URL_RUN_IDS_PARAM_NAME).split("_").pop();y.__classPrivateFieldGet(this,l,"f").call(this),this.flowState.update({token:t,stepId:i,action:void 0})}else this.nativeComplete(s)},r.set(this,(e=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e)})),a.set(this,((e,i,s,o,n=!1)=>{if(this.flowState.current.action===R.RESPONSE_ACTIONS.poll){this.logger.debug("polling - Scheduling polling request");const r=Date.now(),l=n?500:2e3;y.__classPrivateFieldSet(this,t,setTimeout((()=>y.__awaiter(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const c=this.sdk.flow.next(e,i,R.CUSTOM_INTERACTIONS.polling,s,o,{}),h=document.hidden&&!n&&Date.now()-r>l+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield P.timeoutPromise(e,c)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void y.__classPrivateFieldGet(this,a,"f").call(this,e,i,s,o,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===L.FETCH_EXCEPTION_ERROR_CODE)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void y.__classPrivateFieldGet(this,a,"f").call(this,e,i,s,o);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),y.__classPrivateFieldGet(this,d,"f").call(this,u),y.__classPrivateFieldGet(this,a,"f").call(this,e,i,s,o)}))),l),"f")}})),l.set(this,(()=>{clearTimeout(y.__classPrivateFieldGet(this,t,"f")),y.__classPrivateFieldSet(this,t,null,"f")})),d.set(this,(t=>{var i,s,o,r,a,l,d,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const d=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,c=`${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.status} - ${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.statusText}`;y.__classPrivateFieldGet(this,e,"m",E).call(this,"error",(null==t?void 0:t.error)||{errorCode:L.FETCH_ERROR_RESPONSE_ERROR_CODE,errorDescription:c,errorMessage:d}),this.loggerWrapper.error((null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorDescription)||d,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||c);const h=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==h&&"E103205"!==h||!this.isRestartOnError||y.__classPrivateFieldGet(this,e,"m",n).call(this))}null===(c=null===(d=t.data)||void 0===d?void 0:d.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:s}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,s):this.loggerWrapper.info(i,s)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:_}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&N.setLastAuth(_),void y.__classPrivateFieldGet(this,e,"m",E).call(this,"success",f);const{executionId:b,stepId:w,stepName:S,action:I,screen:C,redirect:O,openInNewTabUrl:P,webauthn:T,error:F,samlIdpResponse:A,nativeResponse:k}=t.data;I!==R.RESPONSE_ACTIONS.poll?(this.loggerWrapper.info(`Step "${S||`#${w}`}" is ${m}`,"",{screen:C,status:m,stepId:w,stepName:S,action:I,error:F}),this.flowState.update({stepId:w,executionId:b,action:I,redirectTo:null==O?void 0:O.url,openInNewTabUrl:P,screenId:null==C?void 0:C.id,screenState:null==C?void 0:C.state,webauthnTransactionId:null==T?void 0:T.transactionId,webauthnOptions:null==T?void 0:T.options,samlIdpResponseUrl:null==A?void 0:A.url,samlIdpResponseSamlResponse:null==A?void 0:A.samlResponse,samlIdpResponseRelayState:null==A?void 0:A.relayState,nativeResponseType:null==k?void 0:k.type,nativePayload:null==k?void 0:k.payload})):this.flowState.update({action:I})})),c.set(this,P.withMemCache((()=>y.__awaiter(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),w.set(this,P.leadingDebounce(((t,i)=>y.__awaiter(this,void 0,void 0,(function*(){var s;if("true"===t.getAttribute("formnovalidate")||y.__classPrivateFieldGet(this,e,"m",g).call(this)){const o=null==t?void 0:t.getAttribute("id");y.__classPrivateFieldGet(this,e,"m",m).call(this,t);const n=yield y.__classPrivateFieldGet(this,e,"m",v).call(this),r=P.getElementDescopeAttributes(t),a=this.getComponentsContext(),l=Object.assign(Object.assign(Object.assign(Object.assign({},a),r),n),{origin:(null===(s=this.nativeOptions)||void 0===s?void 0:s.origin)||window.location.origin});i(o,l),y.__classPrivateFieldGet(this,e,"m",f).call(this,n)}}))))),this.flowState=h}loadSdkScripts(){return y.__awaiter(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>y.__awaiter(this,void 0,void 0,(function*(){(yield G.default(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[G.getScriptResultPath(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const e=Object.create(null,{init:{get:()=>super.init}});return y.__awaiter(this,void 0,void 0,(function*(){var t,i,o;this.shadowRoot.isConnected&&(null===(t=this.flowState)||void 0===t||t.subscribe(this.onFlowChange.bind(this)),null===(i=this.stepState)||void 0===i||i.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",y.__classPrivateFieldGet(this,s,"f").visibilitychange)),yield null===(o=e.init)||void 0===o?void 0:o.call(this)}))}disconnectedCallback(){var e;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(e=y.__classPrivateFieldGet(this,i,"f"))||void 0===e||e.abort(),y.__classPrivateFieldSet(this,i,null,"f"),window.removeEventListener("visibilitychange",y.__classPrivateFieldGet(this,s,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return y.__awaiter(this,void 0,void 0,(function*(){let i;const s=P.getUserLocale(e),o=yield this.getTargetLocales();return o.includes(s.locale)?i=`${t}-${s.locale}.html`:o.includes(s.fallback)&&(i=`${t}-${s.fallback}.html`),i}))}getPageContent(e,t){return y.__awaiter(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(t,s,o){return y.__awaiter(this,void 0,void 0,(function*(){var n,l,c;const{projectId:h,flowId:u,tenant:g,stepId:v,executionId:m,action:f,screenId:_,screenState:b,redirectTo:w,openInNewTabUrl:S,redirectUrl:I,token:C,code:T,exchangeError:F,webauthnTransactionId:A,webauthnOptions:j,redirectAuthCodeChallenge:x,redirectAuthCallbackUrl:G,redirectAuthBackupCallbackUri:L,redirectAuthInitiator:W,locale:M,samlIdpResponseUrl:D,samlIdpResponseSamlResponse:q,samlIdpResponseRelayState:$,nativeResponseType:V,nativePayload:B}=t,H=y.__rest(t,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let K,X;const J=k.getABTestingKey(),Y=this.sdk.getLastUserLoginId(),z=yield this.getFlowConfig(),Q=yield this.getProjectConfig(),Z=Object.entries(Q.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),ee=G&&x?{callbackUrl:G,codeChallenge:x,backupCallbackUri:L}:void 0,te=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!m&&(this.loadSdkScripts(),z.fingerprintEnabled&&z.fingerprintKey?yield O.ensureFingerprintIds(z.fingerprintKey,this.baseUrl):O.clearFingerprintData(),z.conditions?({startScreenId:K,conditionInteractionId:X}=U.calculateConditions({loginId:Y,code:T,token:C,abTestingKey:J},z.conditions)):z.condition?({startScreenId:K,conditionInteractionId:X}=U.calculateCondition(z.condition,{loginId:Y,code:T,token:C,abTestingKey:J})):K=z.startScreenId,!P.showFirstScreenOnExecutionInit(K,H))){const e=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:g,redirectAuth:ee},H),{client:this.client}),I&&{redirectUrl:I}),{lastAuth:N.getLastAuth(Y),abTestingKey:J,locale:P.getUserLocale(M).locale,nativeOptions:te}),X,"",Q.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),T?{exchangeCode:T,idpInitiated:!0}:{}),H.descopeIdpInitiated&&{idpInitiated:!0}),C?{token:C}:{}),H.oidcLoginHint?{externalId:H.oidcLoginHint}:{}));return y.__classPrivateFieldGet(this,d,"f").call(this,e),void("completed"!==(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.status)&&this.flowState.update({code:void 0,token:void 0}))}if(m&&(o("token")&&C||o("code")&&T||o("exchangeError")&&F)){const e=yield this.sdk.flow.next(m,v,R.CUSTOM_INTERACTIONS.submit,z.version,Q.componentsVersion,{token:C,exchangeCode:T,exchangeError:F});return y.__classPrivateFieldGet(this,d,"f").call(this,e),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(f===R.RESPONSE_ACTIONS.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>o(e)))){if(!D||!q)return void this.loggerWrapper.error("Did not get saml idp params data to load");P.injectSamlIdpForm(D,q,$||"",P.submitForm)}if(f===R.RESPONSE_ACTIONS.redirect&&(o("redirectTo")||o("deferredRedirect")))return w?"android"===W&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(w):void this.loggerWrapper.error("Did not get redirect url");if(f===R.RESPONSE_ACTIONS.webauthnCreate||f===R.RESPONSE_ACTIONS.webauthnGet){if(!A||!j)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let e,t;null===(l=y.__classPrivateFieldGet(this,i,"f"))||void 0===l||l.abort(),y.__classPrivateFieldSet(this,i,null,"f");try{e=f===R.RESPONSE_ACTIONS.webauthnCreate?yield this.sdk.webauthn.helpers.create(j):yield this.sdk.webauthn.helpers.get(j)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),t=e.name}const s=yield this.sdk.flow.next(m,v,R.CUSTOM_INTERACTIONS.submit,z.version,Q.componentsVersion,{transactionId:A,response:e,failure:t});y.__classPrivateFieldGet(this,d,"f").call(this,s)}if(f===R.RESPONSE_ACTIONS.nativeBridge)return this.nativeComplete=e=>y.__awaiter(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(m,v,R.CUSTOM_INTERACTIONS.submit,z.version,Q.componentsVersion,e);y.__classPrivateFieldGet(this,d,"f").call(this,t)})),void y.__classPrivateFieldGet(this,e,"m",E).call(this,"bridge",{type:V,payload:B});if(y.__classPrivateFieldGet(this,a,"f").call(this,m,v,z.version,Q.componentsVersion),!_&&!K)return void this.loggerWrapper.warn("No screen was found to show");const ie=K||_,se=yield this.getHtmlFilenameWithLocale(M,ie),{oidcLoginHint:oe,oidcPrompt:ne,oidcErrorRedirectUri:re,samlIdpUsername:ae}=H,le={direction:P.getAnimationDirection(v,s.stepId),screenState:Object.assign(Object.assign({},b),{form:Object.assign(Object.assign({},this.formConfigValues),null==b?void 0:b.form),lastAuth:{loginId:Y,name:this.sdk.getLastUserDisplayName()||Y}}),htmlFilename:`${ie}.html`,htmlLocaleFilename:se,samlIdpUsername:ae,oidcLoginHint:oe,oidcPrompt:ne,oidcErrorRedirectUri:re,openInNewTabUrl:S},de=N.getLastAuth(Y);P.showFirstScreenOnExecutionInit(K,H)?le.next=(e,t)=>y.__awaiter(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.start(u,Object.assign(Object.assign(Object.assign(Object.assign({tenant:g,redirectAuth:ee},H),{lastAuth:de,preview:this.preview,abTestingKey:J,client:this.client}),I&&{redirectUrl:I}),{locale:P.getUserLocale(M).locale,nativeOptions:te}),X,e,Q.componentsVersion,Z,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),t),T&&{exchangeCode:T,idpInitiated:!0}),H.descopeIdpInitiated&&{idpInitiated:!0}),C&&{token:C}));return y.__classPrivateFieldGet(this,d,"f").call(this,i),i})):(o("projectId")||o("baseUrl")||o("executionId")||o("stepId"))&&(le.next=(e,t)=>y.__awaiter(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(m,v,e,z.version,Q.componentsVersion,t);return y.__classPrivateFieldGet(this,d,"f").call(this,i),i})));const ce=!!(yield null===(c=this.onPageUpdate)||void 0===c?void 0:c.call(this,P.transformStepStateForCustomScreen(Object.assign(Object.assign({},this.stepState.current),le)),this));if(ce){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",y.__classPrivateFieldGet(this,e,"m",p).call(this,!this.stepState.current.htmlFilename),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{var e;this.stepState.unsubscribe(t),null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this))}))}this.stepState.update(le),y.__classPrivateFieldGet(this,r,"f").call(this,ce)}))}onStepChange(t,i){return y.__awaiter(this,void 0,void 0,(function*(){var s,o;const{htmlFilename:n,htmlLocaleFilename:r,direction:a,next:l,screenState:d,openInNewTabUrl:c}=t,h=document.createElement("template");h.innerHTML=yield this.getPageContent(n,r);const g=h.content.cloneNode(!0),v=this.loadDescopeUiComponents(h);this.sdk.webauthn.helpers.isSupported()?yield y.__classPrivateFieldGet(this,e,"m",u).call(this,g,l):F.disableWebauthnButtons(g),!t.samlIdpUsername||(null===(s=d.form)||void 0===s?void 0:s.loginId)||(null===(o=d.form)||void 0===o?void 0:o.email)||(d.form||(d.form={}),d.form.loginId=t.samlIdpUsername,d.form.email=t.samlIdpUsername),F.updateTemplateFromScreenState(g,d,d.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:m}=yield this.getExecutionContext();F.setPhoneAutoDetectDefaultCode(g,m);const f=()=>y.__awaiter(this,void 0,void 0,(function*(){var t,s;yield v;const o=this.contentRootElement;F.setTOTPVariable(o,null===(t=null==d?void 0:d.totp)||void 0===t?void 0:t.image),F.setNOTPVariable(o,null===(s=null==d?void 0:d.notp)||void 0===s?void 0:s.image),F.setCssVars(o,g,d.cssVars,this.loggerWrapper),o.replaceChildren(g);const n=!i.htmlFilename;setTimeout((()=>{y.__classPrivateFieldGet(this,e,"m",_).call(this),this.validateOnBlur&&P.handleReportValidityOnBlur(o),F.updateScreenFromScreenState(o,d),y.__classPrivateFieldGet(this,e,"m",p).call(this,n),P.handleAutoFocus(o,this.autoFocus,n)})),y.__classPrivateFieldGet(this,e,"m",I).call(this,l);o.querySelector(`[${R.ELEMENT_TYPE_ATTRIBUTE}="polling"]`)&&(yield this.getFlowConfig(),yield this.getProjectConfig(),l(R.CUSTOM_INTERACTIONS.polling,{})),c&&!i.openInNewTabUrl&&window.open(c,"_blank")}));a?y.__classPrivateFieldGet(this,e,"m",C).call(this,f,a):f()}))}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./DescopeWc.js");customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",e),module.exports=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=document.createElement("template");t.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n transition: opacity 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n\n\t</style>\n\t",module.exports=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@fingerprintjs/fingerprintjs-pro");const r=(r,i,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:i,cloudflareScriptUrl:o,cloudflareEndpointUrl:l}=r;let a=[];a=i&&l?[l,t.defaultEndpoint]:[t.defaultEndpoint];let d=[];if(i&&o){const e=new URL(o);d=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,t.defaultScriptUrlPattern]}else d=[t.defaultScriptUrlPattern];const p=t.load({apiKey:e,endpoint:a,scriptUrlPattern:d}),s=yield p,{requestId:u}=yield s.get();n(u)}catch(e){console.warn("Could not load fingerprint",e)}}));exports.default=r,exports.loadFingerprint=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("@fingerprintjs/fingerprintjs-pro");const r=(r,o,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{customDomain:e,publicApiKey:n,cloudflareEndpointPath:a,cloudflareScriptPath:p}=r,{baseUrl:s}=o;let d;d=e?`https://${e}`:s||"https://api.descope.com";const l=new URL(d);l.pathname=a;const c=new URL(d);c.pathname=p;const u=`${c.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,f=t.load({apiKey:n,endpoint:[l.toString(),t.defaultEndpoint],scriptUrlPattern:[u,t.defaultScriptUrlPattern]}),y=yield f,{requestId:g}=yield y.get();i(g)}catch(e){console.warn("Could not load descope fingerprint",e)}}));exports.default=r,exports.loadFingerprint=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("tslib");const n='\n(function () {\nvar merchantConfig = {\n csp: false\n};\n\nvar siteId = "{{SITE_ID}}";\nfunction t(t,n){for(var e=t.split(""),r=0;r<e.length;++r)e[r]=String.fromCharCode(e[r].charCodeAt(0)+n);return e.join("")}function n(n){return t(n,-L).replace(/%SN%/g,siteId)}function e(){var t="no"+"op"+"fn",n="g"+"a",e="n"+"ame";return window[n]&&window[n][e]===t}function r(){return!(!navigator.brave||"function"!=typeof navigator.brave.isBrave)}function o(){return document.currentScript&&document.currentScript.src}function i(t){try{if("number"==typeof t&&window.location&&window.location.pathname){for(var n=window.location.pathname.split("/"),e=[],r=0;r<=Math.min(n.length-1,Math.abs(t));r++)e.push(n[r]);return e.join("/")||"/"}}catch(t){}return"/"}function c(t){try{G.ex=t,e()&&-1===G.ex.indexOf(B.uB)&&(G.ex+=B.uB),r()&&-1===G.ex.indexOf(B.uBr)&&(G.ex+=B.uBr),o()&&-1===G.ex.indexOf(B.nIL)&&(G.ex+=B.nIL),window.ftr__snp_cwc||(G.ex+=B.s),M(G)}catch(t){}}function a(t,n){function e(o){try{o.blockedURI===t&&(n(),document.removeEventListener(r,e))}catch(t){document.removeEventListener(r,e)}}var r="securitypolicyviolation";document.addEventListener(r,e),setTimeout(function(){document.removeEventListener(r,e)},2*60*1e3)}function u(t,n,e,r){var o=!1;t="https://"+t,a(t,function(){r(!0),o=!0});var i=document.createElement("script");i.onerror=function(){if(!o)try{r(!1),o=!0}catch(t){}},i.onload=e,i.type="text/javascript",i.id="ftr__script",i.async=!0,i.src=t;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(i,c)}function f(){J(B.uDF),setTimeout(h,I,B.uDF)}function d(t,n,e,r){var o=!1,i=new XMLHttpRequest;if(a("https:"+t,function(){e(new Error("CSP Violation"),!0),o=!0}),"//"===t.slice(0,2)&&(t="https:"+t),"withCredentials"in i)i.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return;i=new XDomainRequest,i.open("GET",t)}Object.keys(r).forEach(function(t){i.setRequestHeader(t,r[t])}),i.onload=function(){"function"==typeof n&&n(i)},i.onerror=function(t){if("function"==typeof e&&!o)try{e(t,!1),o=!0}catch(t){}},i.onprogress=function(){},i.ontimeout=function(){"function"==typeof e&&e("tim"+"eo"+"ut",!1)},setTimeout(function(){i.send()},0)}function s(t,siteId,n){function e(t){var n=t.toString(16);return n.length%2?"0"+n:n}function r(t){if(t<=0)return"";for(var n="0123456789abcdef",e="",r=0;r<t;r++)e+=n[Math.floor(Math.random()*n.length)];return e}function o(t){for(var n="",r=0;r<t.length;r++)n+=e(t.charCodeAt(r));return n}function i(t){for(var n=t.split(""),e=0;e<n.length;++e)n[e]=String.fromCharCode(255^n[e].charCodeAt(0));return n.join("")}n=n?"1":"0";var c=[];return c.push(t),c.push(siteId),c.push(n),function(t){var n=40,e="";return t.length<n/2&&(e=","+r(n/2-t.length-1)),o(i(t+e))}(c.join(","))}function w(){function t(){D&&(J(B.dUAL),setTimeout(h,I,B.dUAL))}function n(t,n){c(n?B.uAS+B.uF+B.cP:B.uAS+B.uF)}window.ftr__fdad(t,n)}function h(t){try{var n;switch(t){case B.uFP:n=q;break;case B.uDF:n=E;break;default:n=D}if(!n)return;u(n,void 0,function(){try{K(),c(t+B.uS)}catch(t){}},function(n){try{K(),G.td=1*new Date-G.ts,c(n?t+B.uF+B.cP:t+B.uF),t===B.uFP&&f(),t===B.uDF&&w()}catch(t){c(B.eUoe)}})}catch(n){c(t+B.eTlu)}}var m="22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv",v="fort",l="erTo",p="ken";window.ftr__config={m:merchantConfig,s:"23",si:siteId};var g=!1,_=v+l+p,y=400*24*60,T=10,k={write:function(t,n,e,r){void 0===r&&(r=!0);var o=0;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.ckDepth&&(o=window.ftr__config.m.ckDepth);var c,a,u=i(o);if(e?(c=new Date,c.setTime(c.getTime()+60*e*1e3),a="; expires="+c.toGMTString()):a="",!r)return void(document.cookie=escape(t)+"="+escape(n)+a+"; path="+u);for(var f=1,d=document.domain.split("."),s=T,w=!0;w&&d.length>=f&&s>0;){var h=d.slice(-f).join(".");document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h;var m=k.read(t);null!=m&&m==n||(h="."+h,document.cookie=escape(t)+"="+escape(n)+a+"; path="+u+"; domain="+h),w=-1===document.cookie.indexOf(t+"="+n),f++,s--}},read:function(t){var n=null;try{for(var e=escape(t)+"=",r=document.cookie.split(";"),o=32,i=0;i<r.length;i++){for(var c=r[i];c.charCodeAt(0)===o;)c=c.substring(1,c.length);0===c.indexOf(e)&&(n=unescape(c.substring(e.length,c.length)))}}finally{return n}}},S=window.ftr__config.s;S+="ck";var x=function(t){var n=!1,e=null,r=function(){try{if(!e||!n)return;e.remove&&"function"==typeof e.remove?e.remove():document.head.removeChild(e),n=!1}catch(t){}};document.head&&(!function(){e=document.createElement("link"),e.setAttribute("rel","pre"+"con"+"nect"),e.setAttribute("cros"+"sori"+"gin","anonymous"),e.onload=r,e.onerror=r,e.setAttribute("href",t),document.head.appendChild(e),n=!0}(),setTimeout(r,3e3))},L=3,A=n(m||"22ge:t7mj8unkn;1forxgiurqw1qhw2vwdwxv"),F=t("[0Uhtxhvw0LG",-L),U=t("[0Fruuhodwlrq0LG",-L),b=t("Li0Qrqh0Pdwfk",-L),D,C="fgq71iruwhu1frp",E=n("(VQ(1"+C+"2vq2(VQ(2vfulsw1mv"),V=n("(VQ(1"+C+"2vqV2(VQ(2vfulsw1mv"),q;window.ftr__config&&window.ftr__config.m&&window.ftr__config.m.fpi&&(q=window.ftr__config.m.fpi+n("2vq2(VQ(2vfulsw1mv"));var I=10;window.ftr__startScriptLoad=1*new Date;var R=function(t){var n="ft"+"r:tok"+"enR"+"eady";window.ftr__tt&&clearTimeout(window.ftr__tt),window.ftr__tt=setTimeout(function(){try{delete window.ftr__tt,t+="_tt";var e=document.createEvent("Event");e.initEvent(n,!1,!1),e.detail=t,document.dispatchEvent(e)}catch(t){}},1e3)},M=function(t){var n=function(t){return t||""},e=n(t.id)+"_"+n(t.ts)+"_"+n(t.td)+"_"+n(t.ex)+"_"+n(S),r=y;!isNaN(window.ftr__config.m.ckTTL)&&window.ftr__config.m.ckTTL&&(r=window.ftr__config.m.ckTTL),k.write(_,e,r,!0),R(e),window.ftr__gt=e},P=function(){var t=k.read(_)||"",n=t.split("_"),e=function(t){return n[t]||void 0};return{id:e(0),ts:e(1),td:e(2),ex:e(3),vr:e(4)}},j=function(){for(var t={},n="fgu",e=[],r=0;r<256;r++)e[r]=(r<16?"0":"")+r.toString(16);var o=function(t,n,r,o,i){var c=i?"-":"";return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+c+e[255&n]+e[n>>8&255]+c+e[n>>16&15|64]+e[n>>24&255]+c+e[63&r|128]+e[r>>8&255]+c+e[r>>16&255]+e[r>>24&255]+e[255&o]+e[o>>8&255]+e[o>>16&255]+e[o>>24&255]},i=function(){if(window.Uint32Array&&window.crypto&&window.crypto.getRandomValues){var t=new window.Uint32Array(4);return window.crypto.getRandomValues(t),{d0:t[0],d1:t[1],d2:t[2],d3:t[3]}}return{d0:4294967296*Math.random()>>>0,d1:4294967296*Math.random()>>>0,d2:4294967296*Math.random()>>>0,d3:4294967296*Math.random()>>>0}},c=function(){var t="",n=function(t,n){for(var e="",r=t;r>0;--r)e+=n.charAt(1e3*Math.random()%n.length);return e};return t+=n(2,"0123456789"),t+=n(1,"123456789"),t+=n(8,"0123456789")};return t.safeGenerateNoDash=function(){try{var t=i();return o(t.d0,t.d1,t.d2,t.d3,!1)}catch(t){try{return n+c()}catch(t){}}},t.isValidNumericalToken=function(t){return t&&t.toString().length<=11&&t.length>=9&&parseInt(t,10).toString().length<=11&&parseInt(t,10).toString().length>=9},t.isValidUUIDToken=function(t){return t&&32===t.toString().length&&/^[a-z0-9]+$/.test(t)},t.isValidFGUToken=function(t){return 0==t.indexOf(n)&&t.length>=12},t}(),B={uDF:"UDF",dUAL:"dUAL",uAS:"UAS",uFP:"UFP",mLd:"1",eTlu:"2",eUoe:"3",uS:"4",uF:"9",tmos:["T5","T10","T15","T30","T60"],tmosSecs:[5,10,15,30,60],bIR:"43",uB:"u",uBr:"b",cP:"c",nIL:"i",s:"s"};try{var G=P();try{G.id&&(j.isValidNumericalToken(G.id)||j.isValidUUIDToken(G.id)||j.isValidFGUToken(G.id))?window.ftr__ncd=!1:(G.id=j.safeGenerateNoDash(),window.ftr__ncd=!0),G.ts=window.ftr__startScriptLoad,M(G),window.ftr__snp_cwc=!!k.read(_),window.ftr__snp_cwc||(E=V);for(var N="for"+"ter"+".co"+"m",O="ht"+"tps://c"+"dn9."+N,Q="ht"+"tps://"+G.id+"-"+siteId+".cd"+"n."+N,H="http"+"s://cd"+"n3."+N,X=[O,Q,H],z=0;z<X.length;z++)x(X[z]);var $=new Array(B.tmosSecs.length),J=function(t){for(var n=0;n<B.tmosSecs.length;n++)$[n]=setTimeout(c,1e3*B.tmosSecs[n],t+B.tmos[n])},K=function(){for(var t=0;t<B.tmosSecs.length;t++)clearTimeout($[t])};window.ftr__fdad=function(n,e){if(!g){g=!0;var r={};r[b]=s(window.ftr__config.s,siteId,window.ftr__config.m.csp),d(A,function(e){try{var r=e.getAllResponseHeaders().toLowerCase();if(r.indexOf(U.toLowerCase())>=0){var o=e.getResponseHeader(U);window.ftr__altd2=t(atob(o),-L-1)}if(r.indexOf(F.toLowerCase())<0)return;var i=e.getResponseHeader(F),c=t(atob(i),-L-1);if(c){var a=c.split(":");if(a&&2===a.length){for(var u=a[0],f=a[1],d="",s=0,w=0;s<20;++s)d+=s%3>0&&w<12?siteId.charAt(w++):G.id.charAt(s);var h=f.split(",");if(h.length>1){var m=h[0],v=h[1];D=u+"/"+m+"."+d+"."+v}}}n()}catch(t){}},function(t,n){e&&e(t,n)},r)}};var W=q?B.uFP:B.uDF;J(W),setTimeout(h,I,W)}catch(t){c(B.mLd)}}catch(t){}})();\n';module.exports=(e,r,o)=>t.__awaiter(void 0,void 0,void 0,(function*(){const{siteId:t}=e,r=n.replace(/{{SITE_ID}}/g,t),i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("id",t),i.text=r,document.body.appendChild(i),document.addEventListener("ftr:tokenReady",(t=>{o(t.detail)}))}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("../../constants/index.js");function t(e){return Object.freeze({__proto__:null,default:e})}exports.default=function(r){return e.__awaiter(this,void 0,void 0,(function*(){let e;switch(r){case"forter":return e=yield Promise.resolve().then((function(){return t(require("./forter.js"))})),e.default;case"fingerprint":return e=yield Promise.resolve().then((function(){return require("./fingerprint.js")})),e.default;case"fingerprintDescope":return e=yield Promise.resolve().then((function(){return require("./fingerprintDescope.js")})),e.default;default:throw new Error(`Unknown script id: ${r}`)}}))},exports.getScriptResultPath=function(e,t){const n=t?`${e}_${t}`:e;return`${r.SDK_SCRIPT_RESULTS_KEY}.${n}`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t="dls_ab_testing_id";exports.getABTestingKey=()=>{const e=localStorage.getItem(t);if(!e){const e=Math.floor(100*Math.random()+1);return localStorage.setItem(t,e.toString()),e}return Number(e)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code},externalToken:{"is-true":t=>!!t.token,"is-false":t=>!t.token},abTestingKey:{"greater-than":(t,e)=>(t.abTestingKey||0)>e,"less-than":(t,e)=>(t.abTestingKey||0)<e}};exports.calculateCondition=(e,n)=>{var i;const o=null===(i=t[null==e?void 0:e.key])||void 0===i?void 0:i[e.operator];if(!o)return{};const r=o(n,e.predicate)?e.met:e.unmet;return{startScreenId:null==r?void 0:r.screenId,conditionInteractionId:null==r?void 0:r.interactionId}},exports.calculateConditions=(e,n)=>{const i=null==n?void 0:n.find((({key:n,operator:i,predicate:o})=>{var r;if("ELSE"===n)return!0;const d=null===(r=t[n])||void 0===r?void 0:r[i];return!!(null==d?void 0:d(e,o))}));return i?{startScreenId:i.met.screenId,conditionInteractionId:i.met.interactionId}:{}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=(t,r="")=>Object.keys(t).reduce(((s,a)=>{var c;if("object"==typeof t[a]&&null!==t[a]&&!(null===(c=t[a])||void 0===c?void 0:c.value))return Object.assign(Object.assign({},s),e(t[a],`${r+a}.`));const n="object"==typeof t[a]?t[a]:{value:t[a]},o=Object.assign(Object.assign({},s),{[r+a]:n,[`form.${r}${a}`]:n});return"displayName"===a?Object.assign(Object.assign({},o),{[`${r}fullName`]:n,[`form.${r}fullName`]:n}):o}),[]);exports.extractNestedAttribute=(e,t)=>Object.fromEntries(Object.entries(e).map((([e,r])=>[e,r[t]]))),exports.transformFlowInputFormData=t=>{try{return e(JSON.parse(t))}catch(e){return{}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("tslib"),r=require("../constants/index.js"),t=require("../types.js"),o=require("../constants/content.js");const n=["descope-enriched-text"];function a(e){return new URLSearchParams(window.location.search).get(e)}function i(e){if(window.history.replaceState&&a(e)){const r=new URL(window.location.href),t=new URLSearchParams(r.search);t.delete(e),r.search=t.toString(),window.history.replaceState({},"",r.toString())}}const s=e=>{let[t="",o=""]=(a(r.URL_RUN_IDS_PARAM_NAME)||"").split("_");const n=(e=>{var r;return(null===(r=/(.*)\|#\|.*/.exec(e))||void 0===r?void 0:r[1])||""})(t);return(!e||n&&n!==e)&&(t="",o=""),{executionId:t,stepId:o,executionFlowId:n}};function c(){i(r.URL_RUN_IDS_PARAM_NAME)}function l(){return a(r.URL_TOKEN_PARAM_NAME)||void 0}function A(){i(r.URL_TOKEN_PARAM_NAME)}function u(){return a(r.URL_CODE_PARAM_NAME)||void 0}function d(){return a(r.URL_ERR_PARAM_NAME)||void 0}function _(){i(r.URL_CODE_PARAM_NAME)}function p(){i(r.URL_ERR_PARAM_NAME)}function m(){return{redirectAuthCodeChallenge:a(r.URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME),redirectAuthCallbackUrl:a(r.URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME),redirectAuthBackupCallbackUri:a(r.URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME),redirectAuthInitiator:a(r.URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME)}}function P(){return a(r.OIDC_IDP_STATE_ID_PARAM_NAME)}function I(){i(r.OIDC_IDP_STATE_ID_PARAM_NAME)}function R(){return a(r.SAML_IDP_STATE_ID_PARAM_NAME)}function E(){i(r.SAML_IDP_STATE_ID_PARAM_NAME)}function M(){return a(r.SAML_IDP_USERNAME_PARAM_NAME)}function U(){i(r.SAML_IDP_USERNAME_PARAM_NAME)}function h(){return a(r.DESCOPE_IDP_INITIATED_PARAM_NAME)}function S(){i(r.DESCOPE_IDP_INITIATED_PARAM_NAME)}function C(){return a(r.SSO_APP_ID_PARAM_NAME)}function f(){return a(r.THIRD_PARTY_APP_ID_PARAM_NAME)}function D(){i(r.SSO_APP_ID_PARAM_NAME)}function x(){i(r.THIRD_PARTY_APP_ID_PARAM_NAME)}function T(){return a(r.THIRD_PARTY_APP_STATE_ID_PARAM_NAME)}function g(){i(r.THIRD_PARTY_APP_STATE_ID_PARAM_NAME)}function N(){return a(r.APPLICATION_SCOPES_PARAM_NAME)}function L(){i(r.APPLICATION_SCOPES_PARAM_NAME)}function O(){return a(r.OIDC_LOGIN_HINT_PARAM_NAME)}function F(){i(r.OIDC_LOGIN_HINT_PARAM_NAME)}function v(){return a(r.OIDC_PROMPT_PARAM_NAME)}function b(){i(r.OIDC_PROMPT_PARAM_NAME)}function y(){return a(r.OIDC_ERROR_REDIRECT_URI_PARAM_NAME)}function w(){i(r.OIDC_ERROR_REDIRECT_URI_PARAM_NAME)}exports.camelCase=e=>e.replace(/-./g,(e=>e[1].toUpperCase())),exports.clearApplicationScopesParamFromUrl=L,exports.clearCodeFromUrl=_,exports.clearDescopeIDPInitiatedParamFromUrl=S,exports.clearExchangeErrorFromUrl=p,exports.clearOIDCErrorRedirectUriParamFromUrl=w,exports.clearOIDCIDPParamFromUrl=I,exports.clearOIDCLoginHintParamFromUrl=F,exports.clearOIDCPromptParamFromUrl=b,exports.clearPreviousExternalInputs=()=>{document.querySelectorAll('[data-hidden-input="true"]').forEach((e=>e.remove()))},exports.clearRunIdsFromUrl=c,exports.clearSAMLIDPParamFromUrl=E,exports.clearSAMLIDPUsernameParamFromUrl=U,exports.clearSSOAppIdParamFromUrl=D,exports.clearThirdPartyAppIdParamFromUrl=x,exports.clearThirdPartyAppStateIdParamFromUrl=g,exports.clearTokenFromUrl=A,exports.createIsChanged=(e,r)=>t=>e[t]!==r[t],exports.fetchContent=function(r,t){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield fetch(r,{cache:"default"});if(!e.ok)throw Error(`Error fetching URL ${r} [${e.status}]`);return{body:yield e[t||"text"](),headers:Object.fromEntries(e.headers.entries())}}))},exports.getAnimationDirection=function(e,r){if(!r)return;const o=+e,n=+r;return Number.isNaN(o)||Number.isNaN(n)?void 0:o>n?t.Direction.forward:o<n?t.Direction.backward:void 0},exports.getApplicationScopesParamFromUrl=N,exports.getChromiumVersion=()=>{var e;const r=null===(e=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===e?void 0:e.brands,t=null==r?void 0:r.find((({brand:e,version:r})=>"Chromium"===e&&parseFloat(r)));return t?t.version:0},exports.getCodeFromUrl=u,exports.getContentUrl=function({projectId:e,filename:r,assetsFolder:t=o.ASSETS_FOLDER,baseUrl:n}){const a=new URL(o.OVERRIDE_CONTENT_URL||n||o.BASE_CONTENT_URL);return a.pathname=((...e)=>e.join("/").replace(/\/+/g,"/"))(a.pathname,e,t,r),a.toString()},exports.getDescopeIDPInitiatedParamFromUrl=h,exports.getElementDescopeAttributes=e=>Array.from((null==e?void 0:e.attributes)||[]).reduce(((e,t)=>{var o;const n=null===(o=new RegExp(`^${r.DESCOPE_ATTRIBUTE_PREFIX}(\\S+)$`).exec(t.name))||void 0===o?void 0:o[1];return n?Object.assign(e,{[n]:t.value}):e}),{}),exports.getExchangeErrorFromUrl=d,exports.getFirstNonEmptyValue=(e,r)=>{const t=r.find((r=>e[r]));return t?e[t]:null},exports.getOIDCErrorRedirectUriParamFromUrl=y,exports.getOIDCIDPParamFromUrl=P,exports.getOIDCLoginHintParamFromUrl=O,exports.getOIDCPromptParamFromUrl=v,exports.getRedirectAuthFromUrl=m,exports.getRunIdsFromUrl=s,exports.getSAMLIDPParamFromUrl=R,exports.getSAMLIDPUsernameParamFromUrl=M,exports.getSSOAppIdParamFromUrl=C,exports.getThirdPartyAppIdParamFromUrl=f,exports.getThirdPartyAppStateIdParamFromUrl=T,exports.getTokenFromUrl=l,exports.getUserLocale=function(e){if(e)return{locale:e.toLowerCase(),fallback:e.toLowerCase()};const r=navigator.language;return r?r.includes("-")?{locale:r.toLowerCase(),fallback:r.split("-")[0].toLowerCase()}:{locale:r.toLowerCase(),fallback:r.toLowerCase()}:{locale:"",fallback:""}},exports.handleAutoFocus=(e,r,t)=>{if(!0===r||"skipFirstScreen"===r&&!t){const r=e.querySelector("*[name]");setTimeout((()=>{null==r||r.focus()}))}},exports.handleReportValidityOnBlur=e=>{e.querySelectorAll("*[name]").forEach((e=>{e.addEventListener("blur",(()=>{var r;const t=e.focus;e.focus=()=>{},null===(r=e.reportValidity)||void 0===r||r.call(e),setTimeout((()=>{e.focus=t}))}))}))},exports.handleUrlParams=(e,r)=>{const{executionId:t,stepId:o,executionFlowId:n}=s(e);if(n&&e!==n)return r.debug("Flow id does not match the execution flow id, skipping url params handling"),{ssoQueryParams:{}};(t||o)&&c();const a=l();a&&A();const i=u();i&&_();const k=d();k&&p();const{redirectAuthCodeChallenge:H,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:B,redirectAuthInitiator:q}=m(),$=P();$&&I();const K=R();K&&E();const V=M();K&&U();const G=h();G&&S();const Y=C();Y&&D();const Q=f();Q&&x();const X=T();X&&g();const z=N();z&&L();const J=O();J&&F();const W=v();W&&b();const Z=y();Z&&w();return{executionId:t,stepId:o,token:a,code:i,exchangeError:k,redirectAuthCodeChallenge:H,redirectAuthCallbackUrl:j,redirectAuthBackupCallbackUri:B,redirectAuthInitiator:q,ssoQueryParams:{oidcIdpStateId:$,samlIdpStateId:K,samlIdpUsername:V,descopeIdpInitiated:"true"===G,ssoAppId:Y,oidcLoginHint:J,oidcPrompt:W,oidcErrorRedirectUri:Z,thirdPartyAppId:Q,thirdPartyAppStateId:X,applicationScopes:z}}},exports.injectSamlIdpForm=(e,r,t,o)=>{const n=document.createElement("form");n.method="POST",n.action=e,n.innerHTML=`\n <input type="hidden" role="saml-response" name="SAMLResponse" value="${r}" />\n <input type="hidden" role="saml-relay-state" name="RelayState" value="${t}" />\n <input style="display: none;" id="SAMLSubmitButton" type="submit" value="Continue" />\n `,document.body.appendChild(n),o(n)},exports.isChromium=function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},exports.leadingDebounce=(e,r=100)=>{let t;return function(...o){t||e.apply(this,o),clearTimeout(t),t=setTimeout((()=>{t=null}),r)}},exports.shouldHandleMarkdown=e=>n.includes(e),exports.showFirstScreenOnExecutionInit=(e,{oidcIdpStateId:r,samlIdpStateId:t,samlIdpUsername:o,ssoAppId:n,oidcLoginHint:a,oidcPrompt:i,oidcErrorRedirectUri:s,thirdPartyAppId:c,thirdPartyAppStateId:l,applicationScopes:A})=>!(!e||r||t||o||n||a||i||s||c||l||A),exports.submitForm=e=>null==e?void 0:e.submit(),exports.timeoutPromise=function(e,r,t){return new Promise(((o,n)=>{let a=!1;const i=setTimeout((()=>{a=!0,void 0!==t?o(t):n(new Error(`Promise timed out after ${e} ms`))}),e);r.then((e=>{a||(clearTimeout(i),o(e))})).catch((e=>{a||(clearTimeout(i),n(e))}))}))},exports.transformStepStateForCustomScreen=r=>{const t=r.screenState,o=e.__rest(t,["inputs"]),{htmlFilename:n,htmlLocaleFilename:a}=r,i=e.__rest(r,["screenState","htmlFilename","htmlLocaleFilename"]),s=null==n?void 0:n.replace(".html","");return Object.assign(Object.assign({},i),{screenId:s,screenState:Object.assign({},o)})},exports.withMemCache=e=>{let r,t;return Object.assign(((...o)=>{return r&&(a=o,(n=r).length===a.length&&n.every(((e,r)=>e===a[r])))||(r=o,t=e(...o)),t;var n,a}),{reset:()=>{r=void 0,t=void 0}})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("../constants/index.js"),e=require("../constants/general.js");exports.getLastAuth=function(e){const s={};if(e)try{Object.assign(s,JSON.parse(localStorage.getItem(t.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY)))}catch(t){}return s},exports.setLastAuth=function(s){(null==s?void 0:s.authMethod)&&e.IS_LOCAL_STORAGE&&localStorage.setItem(t.DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY,JSON.stringify(s))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=(t,e,o,n={})=>{var i,l,f,s;return[Math.min(Math.max(e,("all"===n.left?t.offsetWidth:null!==(i=n.left)&&void 0!==i?i:0)-t.offsetWidth),window.innerWidth-("all"===n.right?t.offsetWidth:null!==(l=n.right)&&void 0!==l?l:0)),Math.min(Math.max(o,("all"===n.top?t.offsetHeight:null!==(f=n.top)&&void 0!==f?f:0)-t.offsetHeight),window.innerHeight-("all"===n.bottom?t.offsetHeight:null!==(s=n.bottom)&&void 0!==s?s:0))]};exports.addOnResize=t=>{t.onmousemove=e=>{(e.target.w&&e.target.w!==e.target.offsetWidth||e.target.h&&e.target.h!==e.target.offsetHeight)&&t.onresize(e),e.target.w=e.target.offsetWidth,e.target.h=e.target.offsetHeight}},exports.dragElement=(e,o,n)=>{let i=0,l=0,f=0,s=0;function r(o){o.preventDefault(),i=f-o.clientX,l=s-o.clientY,f=o.clientX,s=o.clientY;const[r,a]=t(e,e.offsetLeft-i,e.offsetTop-l,n);e.style.top=`${a}px`,e.style.left=`${r}px`}function a(){document.onmouseup=null,document.onmousemove=null}function u(t){t.preventDefault(),f=t.clientX,s=t.clientY,document.onmouseup=a,document.onmousemove=r}o?o.onmousedown=u:e.onmousedown=u},exports.limitCoordinateToScreenBoundaries=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t,s,i,r=require("tslib"),a=require("./helpers.js");function l(e,t){const s=Object.getOwnPropertyNames(e),i=Object.getOwnPropertyNames(t);if(s.length!==i.length)return!1;for(let i=0;i<s.length;i+=1){const r=s[i],a=e[r],c=t[r];if(null===a||null===c){if(a!==c)return!1}else if("object"==typeof a&&"object"==typeof c){if(!l(a,c))return!1}else if(a!==c)return!1}return!0}e=new WeakMap,t=new WeakMap,s=new WeakMap,i=new WeakMap,module.exports=class{constructor(c={},{updateOnlyOnChange:n=!0}={}){e.set(this,void 0),t.set(this,{}),s.set(this,0),i.set(this,!1),this.update=s=>{const c="function"==typeof s?s(r.__classPrivateFieldGet(this,e,"f")):s,n=Object.assign(Object.assign({},r.__classPrivateFieldGet(this,e,"f")),c);if(!r.__classPrivateFieldGet(this,i,"f")||!l(r.__classPrivateFieldGet(this,e,"f"),n)){const s=r.__classPrivateFieldGet(this,e,"f");r.__classPrivateFieldSet(this,e,n,"f"),Object.freeze(r.__classPrivateFieldGet(this,e,"f")),setTimeout((()=>{Object.values(r.__classPrivateFieldGet(this,t,"f")).forEach((e=>e(n,s,a.createIsChanged(n,s))))}),0)}},r.__classPrivateFieldSet(this,e,c,"f"),r.__classPrivateFieldSet(this,i,n,"f")}get current(){return Object.assign({},r.__classPrivateFieldGet(this,e,"f"))}subscribe(e){return r.__classPrivateFieldSet(this,s,r.__classPrivateFieldGet(this,s,"f")+1,"f"),r.__classPrivateFieldGet(this,t,"f")[r.__classPrivateFieldGet(this,s,"f")]=e,r.__classPrivateFieldGet(this,s,"f").toString()}unsubscribe(e){const s=!!r.__classPrivateFieldGet(this,t,"f")[e];return s&&delete r.__classPrivateFieldGet(this,t,"f")[e],s}unsubscribeAll(){return r.__classPrivateFieldSet(this,t,{},"f"),!0}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("@descope/escape-markdown"),t=require("../constants/index.js"),r=require("./helpers.js");const o=["disabled"],s=(e,r)=>{Object.entries(r||{}).forEach((([r,o])=>{Array.from(e.querySelectorAll(`*[name="${r}"]:not([${t.DESCOPE_ATTRIBUTE_EXCLUDE_FIELD}])`)).forEach((e=>{e.value=o}))}))},l=(e,t)=>t.split(".").reduce(((e,t)=>(null==e?void 0:e[t])||""),e),n=(t,r,o)=>t.replace(/{{(.+?)}}/g,((t,s)=>o?e.escapeMarkdown(l(r,s)):l(r,s))),c=(e,r,o)=>{e.querySelectorAll(`[${t.ELEMENT_TYPE_ATTRIBUTE}="${r}"]`).forEach((e=>{e.setAttribute("href",o)}))},i=(e,t,r)=>{var o,s;const l=null===(o=customElements.get(t))||void 0===o?void 0:o.cssVarList.url;r&&l&&(null===(s=null==e?void 0:e.style)||void 0===s||s.setProperty(l,`url(data:image/jpg;base64,${r})`))};exports.disableWebauthnButtons=e=>{e.querySelectorAll(`descope-button[${t.ELEMENT_TYPE_ATTRIBUTE}="biometrics"]`).forEach((e=>e.setAttribute("disabled","true")))},exports.setCssVars=(e,t,r,o)=>{r&&Object.keys(r).forEach((s=>{t.querySelector(s)||o.debug(`Skipping css vars for component "${s}}"`,`Got css vars for component ${s} but Could not find it on next page`);const l=customElements.get(s);l?Object.keys(r[s]).forEach((t=>{var n;const c=r[s],i=null===(n=null==l?void 0:l.cssVarList)||void 0===n?void 0:n[t];if(!i)return void o.info(`Could not find css variable name for ${t} in ${s}`,"Check if the css variable is defined in the component");const a=c[t];e.style.setProperty(i,a)})):o.info(`Could not find component class for ${s}`,"Check if the component is registered")}))},exports.setNOTPVariable=(e,t)=>{i(e,"descope-notp-image",t)},exports.setPhoneAutoDetectDefaultCode=(e,t)=>{Array.from(e.querySelectorAll('[default-code="autoDetect"]')).forEach((e=>{e.setAttribute("default-code",t)}))},exports.setTOTPVariable=(e,t)=>{i(e,"descope-totp-image",t)},exports.updateScreenFromScreenState=(e,t)=>{s(e,null==t?void 0:t.inputs),s(e,null==t?void 0:t.form)},exports.updateTemplateFromScreenState=(e,s,l,i,a,u)=>{var d,p;let f=null==s?void 0:s.errorText;try{f=(null==a?void 0:a({text:null==s?void 0:s.errorText,type:null==s?void 0:s.errorType}))||(null==s?void 0:s.errorText)}catch(e){u.error("Error transforming error message",e.message)}((e,r,o="")=>{e.querySelectorAll(`[${t.ELEMENT_TYPE_ATTRIBUTE}="${r}"]`).forEach((e=>{e.textContent=o,e.classList[o?"remove":"add"]("hide")}))})(e,"error-message",f),c(e,"totp-link",null===(d=null==s?void 0:s.totp)||void 0===d?void 0:d.provisionUrl),c(e,"notp-link",null===(p=null==s?void 0:s.notp)||void 0===p?void 0:p.redirectUrl),((e,t)=>{e.querySelectorAll("descope-text,descope-link,descope-enriched-text,descope-code-snippet").forEach((e=>{const o=r.shouldHandleMarkdown(e.localName);e.textContent=n(e.textContent,t,o);const s=e.getAttribute("href");s&&e.setAttribute("href",n(s,t))}))})(e,s),((e,t,r)=>{t&&Object.keys(t).forEach((o=>{e.querySelectorAll(`[name=${o}]`).forEach((e=>{const s=t[o];Object.keys(s).forEach((t=>{let o=s[t];if("string"!=typeof o)try{o=JSON.stringify(o)}catch(e){r.error(`Could not stringify value "${o}" for "${t}"`,e.message),o=""}e.setAttribute(t,o)}))}))}))})(e,l,u),((e,r)=>{e.querySelectorAll(`[${t.HAS_DYNAMIC_VALUES_ATTR_NAME}]`).forEach((e=>{Array.from(e.attributes).forEach((e=>{e.value=n(e.value,r)}))}))})(e,s),((e,t)=>{Object.entries(t).forEach((([t,r])=>{e.querySelectorAll(`[name="${t}"]`).forEach((e=>{Object.entries(r).forEach((([t,r])=>{o.includes(t)&&e.setAttribute(t,r)}))}))}))})(e,i)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=require("tslib"),e=require("./helpers.js");const o=e.withMemCache((()=>i.__awaiter(void 0,void 0,void 0,(function*(){var i,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return!1;try{const r=Promise.all([null===(i=window.PublicKeyCredential)||void 0===i?void 0:i.isConditionalMediationAvailable(),null===(o=window.PublicKeyCredential)||void 0===o?void 0:o.isUserVerifyingPlatformAuthenticatorAvailable()]).then((i=>i.every((i=>!!i)))),t=e.getChromiumVersion()>=108;return yield e.timeoutPromise(100,r,t)}catch(i){return console.error("Conditional login check failed",i),!1}}))));exports.isConditionalLoginSupported=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@descope/sdk-helpers"),s=require("../helpers/helpers.js");require("../helpers/state.js"),require("@descope/escape-markdown"),require("../constants/content.js"),require("../constants/uiComponents.js"),require("../helpers/webauthn.js");const r=t.createSingletonMixin((t=>{var r,i,n,o;return o=class extends t{constructor(){super(...arguments),r.add(this)}connectedCallback(){var t;e.__classPrivateFieldGet(this,r,"m",i).call(this)&&e.__classPrivateFieldGet(this,r,"m",n).call(this),null===(t=super.connectedCallback)||void 0===t||t.call(this)}},r=new WeakSet,i=function(){return!this.shadowRoot.host.closest("form")&&s.isChromium()},n=function(){const e=this.shadowRoot.host,t=document.createElement("form");t.style.width="100%",t.style.height="100%",e.parentElement.appendChild(t),t.appendChild(e)},o}));exports.formMountMixin=r;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r;exports.Direction=void 0,(r=exports.Direction||(exports.Direction={})).backward="backward",r.forward="forward";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IS_LOCAL_STORAGE as t}from"./general.js";const e=t&&localStorage.getItem("base.content.url")||"",o="https://static.descope.com/pages",a="v2-beta",s="v2-alpha",c="config.json";export{a as ASSETS_FOLDER,o as BASE_CONTENT_URL,c as CONFIG_FILENAME,e as OVERRIDE_CONTENT_URL,s as PREV_VER_ASSETS_FOLDER};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="undefined"!=typeof localStorage,o="J151000",t="J151001";export{t as FETCH_ERROR_RESPONSE_ERROR_CODE,o as FETCH_EXCEPTION_ERROR_CODE,e as IS_LOCAL_STORAGE};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{ASSETS_FOLDER,BASE_CONTENT_URL,CONFIG_FILENAME,OVERRIDE_CONTENT_URL,PREV_VER_ASSETS_FOLDER}from"./content.js";export{UI_COMPONENTS_URL_KEY}from"./uiComponents.js";const e="descope-login-flow",t="t",a="code",i="err",d="ra-challenge",o="ra-callback",_="ra-backup-callback",r="ra-initiator",p="data-descope-",l="data-exclude-field",s="data-exclude-next",c="dls_last_auth",n="state_id",u="saml_idp_state_id",E="saml_idp_username",m="descope_idp_initiated",b="sso_app_id",h="third_party_app_id",R="third_party_app_state_id",S="oidc_login_hint",x="oidc_prompt",N="oidc_error_redirect_uri",O="application_scopes",g="data-type",C="sdkScriptsResults",T={redirect:"redirect",poll:"poll",webauthnCreate:"webauthnCreate",webauthnGet:"webauthnGet",nativeBridge:"nativeBridge",loadForm:"loadForm"},F={submit:"submit",polling:"polling"},L="data-has-dynamic-attr-values",w=["descope-multi-select-combo-box","descope-text-area"];export{O as APPLICATION_SCOPES_PARAM_NAME,F as CUSTOM_INTERACTIONS,l as DESCOPE_ATTRIBUTE_EXCLUDE_FIELD,s as DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON,p as DESCOPE_ATTRIBUTE_PREFIX,m as DESCOPE_IDP_INITIATED_PARAM_NAME,c as DESCOPE_LAST_AUTH_LOCAL_STORAGE_KEY,w as ELEMENTS_TO_IGNORE_ENTER_KEY_ON,g as ELEMENT_TYPE_ATTRIBUTE,L as HAS_DYNAMIC_VALUES_ATTR_NAME,N as OIDC_ERROR_REDIRECT_URI_PARAM_NAME,n as OIDC_IDP_STATE_ID_PARAM_NAME,S as OIDC_LOGIN_HINT_PARAM_NAME,x as OIDC_PROMPT_PARAM_NAME,T as RESPONSE_ACTIONS,u as SAML_IDP_STATE_ID_PARAM_NAME,E as SAML_IDP_USERNAME_PARAM_NAME,C as SDK_SCRIPT_RESULTS_KEY,b as SSO_APP_ID_PARAM_NAME,h as THIRD_PARTY_APP_ID_PARAM_NAME,R as THIRD_PARTY_APP_STATE_ID_PARAM_NAME,a as URL_CODE_PARAM_NAME,i as URL_ERR_PARAM_NAME,_ as URL_REDIRECT_AUTH_BACKUP_CALLBACK_PARAM_NAME,o as URL_REDIRECT_AUTH_CALLBACK_PARAM_NAME,d as URL_REDIRECT_AUTH_CHALLENGE_PARAM_NAME,r as URL_REDIRECT_AUTH_INITIATOR_PARAM_NAME,e as URL_RUN_IDS_PARAM_NAME,t as URL_TOKEN_PARAM_NAME};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IS_LOCAL_STORAGE as e}from"./general.js";const o="base.ui.components.url";e&&localStorage.getItem(o),e&&localStorage.getItem(o);export{o as UI_COMPONENTS_URL_KEY};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__classPrivateFieldGet as n,__classPrivateFieldSet as e}from"tslib";import"./constants/content.js";import"./constants/uiComponents.js";import"./types.js";import t from"./helpers/state.js";import"@descope/escape-markdown";import"./helpers/webauthn.js";import{dragElement as s,addOnResize as i,limitCoordinateToScreenBoundaries as o}from"./helpers/positionHelpers.js";var l,r,a,d,p,c,h,g,m,f;const x=document.createElement("template");x.innerHTML=`\n<style>\n .debugger {\n width: 300px;\n height: 200px;\n background-color: #FAFAFA;\n position: fixed;\n font-family: "Helvetica Neue", sans-serif;\n box-shadow: rgba(0, 0, 0, 0.1) 0px 5px 10px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid lightgrey;\n pointer-events: initial;\n display: flex;\n flex-direction: column;\n min-width: 200px;\n max-width: 600px;\n max-height: calc(100% - 64px);\n min-height: 200px;\n resize: both;\n }\n\n .header {\n padding: 8px 16px;\n display: flex;\n align-items: center;\n background-color: #EEEEEE;\n cursor: move;\n border-bottom: 1px solid #e0e0e0;\n }\n\n .content {\n font-size: 14px;\n flex-grow: 1;\n overflow: auto;\n }\n\n .msg {\n border-bottom: 1px solid lightgrey;\n padding: 8px 16px;\n display: flex;\n gap: 5px;\n background-color: #FAFAFA;\n }\n\n .msg.collapsible {\n cursor: pointer;\n }\n\n .empty-state {\n padding: 8px 16px;\n background-color: #FAFAFA;\n }\n\n\n .msg.collapsible:not(.collapsed) {\n background-color: #F5F5F5;\n }\n\n .msg_title {\n padding-bottom: 5px;\n display: flex;\n gap: 8px;\n font-weight: 500;\n }\n\n .msg svg {\n padding: 1px;\n flex-shrink: 0;\n margin-top: -2px;\n }\n\n .msg_content {\n overflow: hidden;\n flex-grow: 1;\n margin-right:5px;\n }\n\n .msg_desc {\n color: #646464;\n cursor: initial;\n word-wrap: break-word;\n }\n\n .msg.collapsed .msg_desc {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .msg.collapsible.collapsed .chevron {\n transform: rotate(-45deg) translateX(-2px);\n }\n\n .msg.collapsible .chevron {\n content: "";\n width:6px;\n height:6px;\n border-bottom: 2px solid grey;\n border-right: 2px solid grey;\n transform: rotate(45deg) translateX(-1px);\n margin: 5px;\n flex-shrink:0;\n }\n</style>\n\n<div style="top:32px; left:${window.innerWidth-300-32}px;" class="debugger">\n <div class="header">\n <span>Debugger messages</span>\n </div>\n <div class="content">\n <div class="empty-state">\n No errors detected 👀\n </div>\n </div>\n</div>\n`;class b extends HTMLElement{constructor(){super(),l.add(this),r.set(this,new t({messages:[]})),a.set(this,void 0),d.set(this,void 0),p.set(this,void 0),c.set(this,{resize:n(this,l,"m",f).bind(this)}),this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(x.content.cloneNode(!0)),e(this,a,this.shadowRoot.querySelector(".debugger"),"f"),e(this,d,n(this,a,"f").querySelector(".content"),"f"),e(this,p,n(this,a,"f").querySelector(".header"),"f")}updateData(e){n(this,r,"f").update((n=>({messages:n.messages.concat(e)})))}connectedCallback(){s(n(this,a,"f"),n(this,p,"f"),{top:"all",bottom:100,left:100,right:100}),window.addEventListener("resize",n(this,c,"f").resize),i(n(this,a,"f")),n(this,a,"f").onresize=n(this,l,"m",m).bind(this),n(this,r,"f").subscribe(n(this,l,"m",h).bind(this))}disconnectedCallback(){n(this,r,"f").unsubscribeAll(),window.removeEventListener("resize",n(this,c,"f").resize)}}r=new WeakMap,a=new WeakMap,d=new WeakMap,p=new WeakMap,c=new WeakMap,l=new WeakSet,h=function(e){n(this,l,"m",g).call(this,e),n(this,l,"m",m).call(this)},g=function(e){n(this,d,"f").innerHTML=e.messages.map((n=>`\n <div class="msg">\n <svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M5.99984 13.167L8.99984 10.167L11.9998 13.167L13.1665 12.0003L10.1665 9.00033L13.1665 6.00033L11.9998 4.83366L8.99984 7.83366L5.99984 4.83366L4.83317 6.00033L7.83317 9.00033L4.83317 12.0003L5.99984 13.167ZM8.99984 17.3337C7.84706 17.3337 6.76373 17.1148 5.74984 16.677C4.73595 16.2398 3.854 15.6462 3.104 14.8962C2.354 14.1462 1.76039 13.2642 1.32317 12.2503C0.885393 11.2364 0.666504 10.1531 0.666504 9.00033C0.666504 7.84755 0.885393 6.76421 1.32317 5.75033C1.76039 4.73644 2.354 3.85449 3.104 3.10449C3.854 2.35449 4.73595 1.7606 5.74984 1.32283C6.76373 0.885603 7.84706 0.666992 8.99984 0.666992C10.1526 0.666992 11.2359 0.885603 12.2498 1.32283C13.2637 1.7606 14.1457 2.35449 14.8957 3.10449C15.6457 3.85449 16.2393 4.73644 16.6765 5.75033C17.1143 6.76421 17.3332 7.84755 17.3332 9.00033C17.3332 10.1531 17.1143 11.2364 16.6765 12.2503C16.2393 13.2642 15.6457 14.1462 14.8957 14.8962C14.1457 15.6462 13.2637 16.2398 12.2498 16.677C11.2359 17.1148 10.1526 17.3337 8.99984 17.3337ZM8.99984 15.667C10.8609 15.667 12.4373 15.0212 13.729 13.7295C15.0207 12.4378 15.6665 10.8614 15.6665 9.00033C15.6665 7.13921 15.0207 5.56283 13.729 4.27116C12.4373 2.97949 10.8609 2.33366 8.99984 2.33366C7.13873 2.33366 5.56234 2.97949 4.27067 4.27116C2.979 5.56283 2.33317 7.13921 2.33317 9.00033C2.33317 10.8614 2.979 12.4378 4.27067 13.7295C5.56234 15.0212 7.13873 15.667 8.99984 15.667Z" fill="#ED404A"/>\n</svg>\n\n <div class="msg_content">\n <div class="msg_title">\n ${n.title}\n </div>\n <div class="msg_desc">\n ${n.description}\n </div>\n </div>\n <div class="chevron"></div>\n </div>\n `)).join("")},m=function(){n(this,d,"f").querySelectorAll(".msg").forEach((n=>{const e=n.querySelector(".msg_desc"),t=e.scrollWidth>e.clientWidth,s=e.clientHeight>20;t||s?(n.classList.add("collapsible"),n.onclick=e=>{e.target.classList.contains("msg_desc")||n.classList.toggle("collapsed")}):(n.classList.remove("collapsible"),n.onclick=null)}))},f=function(){const[e,t]=o(n(this,a,"f"),Number.parseInt(n(this,a,"f").style.left,10),Number.parseInt(n(this,a,"f").style.top,10),{top:"all",bottom:100,left:100,right:100});n(this,a,"f").style.top=`${t}px`,n(this,a,"f").style.left=`${e}px`},customElements.get("descope-debugger")||customElements.define("descope-debugger",b);export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__classPrivateFieldGet as t,__awaiter as e,__classPrivateFieldSet as i}from"tslib";import{compose as r}from"@descope/sdk-helpers";import{staticResourcesMixin as s}from"@descope/sdk-mixins/static-resources-mixin";import{themeMixin as o}from"@descope/sdk-mixins/theme-mixin";import n from"@descope/web-js-sdk";import{ELEMENTS_TO_IGNORE_ENTER_KEY_ON as u}from"../constants/index.js";import{withMemCache as a,handleUrlParams as l,clearRunIdsFromUrl as d,camelCase as c,getRunIdsFromUrl as h,getContentUrl as f,fetchContent as g}from"../helpers/helpers.js";import p from"../helpers/state.js";import"@descope/escape-markdown";import"../helpers/webauthn.js";import{transformFlowInputFormData as m,extractNestedAttribute as v}from"../helpers/flowInputs.js";import{formMountMixin as b}from"../mixins/formMountMixin.js";import w from"./initTemplate.js";import{CONFIG_FILENAME as C,PREV_VER_ASSETS_FOLDER as A}from"../constants/content.js";import{FETCH_EXCEPTION_ERROR_CODE as k}from"../constants/general.js";var x,y,j,I,E,L,U,S,M,O,W,D,R,P,F,T,q,B,N,V,H;const K=r(o,s,b)(HTMLElement);class z extends K{static get observedAttributes(){return["project-id","flow-id","base-url","tenant","locale","debug","storage-prefix","preview","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","validate-on-blur","style-id"]}constructor(r){super(),x.add(this),j.set(this,!1),this.flowStatus="initial",this.loggerWrapper={error:(e,i="")=>{this.logger.error(e,i,new Error),t(this,x,"m",V).call(this,e,i)},warn:(t,e="")=>{this.logger.warn(t,e)},info:(t,e="",i={})=>{this.logger.info(t,e,i)},debug:(t,e="")=>{this.logger.debug(t,e)}},I.set(this,new p),E.set(this,new p),L.set(this,{}),this.getComponentsContext=()=>t(this,L,"f"),this.nextRequestStatus=new p({isLoading:!1}),U.set(this,void 0),S.set(this,{popstate:t(this,x,"m",D).bind(this),componentsContext:t(this,x,"m",q).bind(this)}),M.set(this,void 0),this.getConfig=a((()=>e(this,void 0,void 0,(function*(){try{const{body:t,headers:e}=yield this.fetchStaticResource(C,"json");return{projectConfig:t,executionContext:{geo:e["x-geo"]}}}catch(t){return{isMissingConfig:!0}}})))),i(this,M,r,"f"),t(this,x,"m",O).call(this)}get flowId(){return this.getAttribute("flow-id")}get client(){try{return JSON.parse(this.getAttribute("client"))||{}}catch(t){return{}}}get tenant(){return this.getAttribute("tenant")||void 0}get redirectUrl(){return this.getAttribute("redirect-url")||void 0}get debug(){return"true"===this.getAttribute("debug")}get locale(){return this.getAttribute("locale")||void 0}get autoFocus(){var t;const e=null!==(t=this.getAttribute("auto-focus"))&&void 0!==t?t:"true";return"skipFirstScreen"===e?e:"true"===e}get validateOnBlur(){return"true"===this.getAttribute("validate-on-blur")}get storeLastAuthenticatedUser(){var t;return"true"===(null!==(t=this.getAttribute("store-last-authenticated-user"))&&void 0!==t?t:"true")}get keepLastAuthenticatedUserAfterLogout(){return"true"===this.getAttribute("keep-last-authenticated-user-after-logout")}get storagePrefix(){return this.getAttribute("storage-prefix")||""}get preview(){return!!this.getAttribute("preview")}get formConfig(){return m(this.form)}get form(){return this.getAttribute("form")}get formConfigValues(){return v(this.formConfig,"value")}get isRestartOnError(){return"true"===this.getAttribute("restart-on-error")}getExecutionContext(){return e(this,void 0,void 0,(function*(){const{executionContext:t}=yield this.getConfig();return t}))}getProjectConfig(){return e(this,void 0,void 0,(function*(){const{projectConfig:t}=yield this.getConfig();return t}))}getFlowConfig(){return e(this,void 0,void 0,(function*(){var t,e;const i=yield this.getProjectConfig(),r=(null===(t=null==i?void 0:i.flows)||void 0===t?void 0:t[this.flowId])||{};return null!==(e=r.version)&&void 0!==e||(r.version=0),r}))}getTargetLocales(){return e(this,void 0,void 0,(function*(){const t=yield this.getFlowConfig();return((null==t?void 0:t.targetLocales)||[]).map((t=>t.toLowerCase()))}))}getComponentsVersion(){return e(this,void 0,void 0,(function*(){var t,e;const i=null===(e=null===(t=yield this.getConfig())||void 0===t?void 0:t.projectConfig)||void 0===e?void 0:e.componentsVersion;return i||(this.logger.error("Did not get components version, using latest version"),"latest")}))}init(){const r=Object.create(null,{init:{get:()=>super.init}});return e(this,void 0,void 0,(function*(){var e;if(this.flowStatus="loading",["ready","error","success"].forEach((t=>this.addEventListener(t,(()=>{this.flowStatus=t})))),yield null===(e=r.init)||void 0===e?void 0:e.call(this),t(this,E,"f").subscribe(t(this,x,"m",N).bind(this)),t(this,E,"f").update({isDebug:this.debug}),t(this,x,"m",W).call(this),yield t(this,x,"m",F).call(this))return void this.loggerWrapper.error("This SDK version does not support your flows version","Make sure to upgrade your flows to the latest version or use an older SDK version");if((yield this.getConfig()).isMissingConfig)return void this.loggerWrapper.error("Cannot get config file","Make sure that your projectId & flowId are correct");t(this,x,"m",H).call(this);const{executionId:s,stepId:o,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f,ssoQueryParams:g}=l(this.flowId,this.loggerWrapper);window.addEventListener("popstate",t(this,S,"f").popstate),window.addEventListener("components-context",t(this,S,"f").componentsContext),t(this,I,"f").subscribe(t(this,x,"m",P).bind(this)),t(this,I,"f").update(Object.assign({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,locale:this.locale,stepId:o,executionId:s,token:n,code:u,exchangeError:a,redirectAuthCallbackUrl:d,redirectAuthBackupCallbackUri:c,redirectAuthCodeChallenge:h,redirectAuthInitiator:f},g)),i(this,j,!0,"f")}))}disconnectedCallback(){t(this,I,"f").unsubscribeAll(),t(this,E,"f").unsubscribeAll(),t(this,x,"m",B).call(this),window.removeEventListener("popstate",t(this,S,"f").popstate),window.removeEventListener("components-context",t(this,S,"f").componentsContext)}attributeChangedCallback(e,i,r){if(this.shadowRoot.isConnected&&t(this,j,"f")&&i!==r&&y.observedAttributes.includes(e)){t(this,x,"m",W).call(this);const s=null===i;t(this,I,"f").update((({stepId:t,executionId:i})=>{let o=t,n=i;return s||(n=null,o=null,d()),{[c(e)]:r,stepId:o,executionId:n}})),t(this,E,"f").update({isDebug:this.debug})}}}y=z,j=new WeakMap,I=new WeakMap,E=new WeakMap,L=new WeakMap,U=new WeakMap,S=new WeakMap,M=new WeakMap,x=new WeakSet,O=function(){this.shadowRoot.appendChild(w.content.cloneNode(!0)),this.slotElement=document.createElement("slot"),this.slotElement.classList.add("hidden"),this.rootElement.appendChild(this.slotElement)},W=function(){const t=["base-url","tenant","locale","debug","redirect-url","auto-focus","store-last-authenticated-user","keep-last-authenticated-user-after-logout","preview","storage-prefix","form","client","validate-on-blur","style-id"];y.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[c(e)])throw Error(`${e} cannot be empty`)}))},D=function(){const{stepId:e,executionId:i}=h(this.flowId);t(this,I,"f").update({stepId:e,executionId:i})},R=function(t,i){this.sdk=n(Object.assign(Object.assign({persistTokens:!0,preview:this.preview,storagePrefix:this.storagePrefix,storeLastAuthenticatedUser:this.storeLastAuthenticatedUser,keepLastAuthenticatedUserAfterLogout:this.keepLastAuthenticatedUserAfterLogout},y.sdkConfigOverrides),{projectId:t,baseUrl:i})),["start","next"].forEach((t=>{const i=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>e(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield i(...t)}catch(t){return{error:{errorCode:k,errorDescription:t.toString()}}}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},P=function(i,r,s){return e(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:r}=i;if(s("projectId")||s("baseUrl")){if(!e)return;t(this,x,"m",R).call(this,e,r)}t(this,M,"f").call(this,i)}))},F=function(){return e(this,void 0,void 0,(function*(){return(yield this.getConfig()).isMissingConfig&&(yield t(this,x,"m",T).call(this))}))},T=function(){return e(this,void 0,void 0,(function*(){const t=f({projectId:this.projectId,filename:C,assetsFolder:A,baseUrl:this.baseStaticUrl});try{return yield g(t,"json"),!0}catch(t){return!1}}))},q=function(e){i(this,L,Object.assign(Object.assign({},t(this,L,"f")),e.detail),"f")},B=function(){var e;null===(e=t(this,U,"f"))||void 0===e||e.remove(),i(this,U,null,"f")},N=function(r){return e(this,arguments,void 0,(function*({isDebug:e}){e?(i(this,U,document.createElement("descope-debugger"),"f"),Object.assign(t(this,U,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),yield import("../debugger-wc.js"),document.body.appendChild(t(this,U,"f"))):t(this,x,"m",B).call(this)}))},V=function(e,i){var r;e&&this.debug&&(null===(r=t(this,U,"f"))||void 0===r||r.updateData({title:e,description:i}))},H=function(){this.rootElement.onkeydown=t=>{var e,i,r;const s=!!(null===(e=this.shadowRoot.activeElement)||void 0===e?void 0:e.getAttribute("href")),o=u.includes(null!==(r=null===(i=this.shadowRoot.activeElement)||void 0===i?void 0:i.localName)&&void 0!==r?r:"");if("Enter"!==t.key||s||o)return;t.preventDefault();const n=this.rootElement.querySelectorAll("descope-button");if(1===n.length&&"false"!==n[0].getAttribute("auto-submit"))return void n[0].click();const a=Array.from(n).filter((t=>"true"===t.getAttribute("auto-submit")));if(1===a.length)return void a[0].click();const l=Array.from(n).filter((t=>"button"===t.getAttribute("data-type")));if(1===l.length)"false"!==l[0].getAttribute("auto-submit")&&l[0].click();else if(0===l.length){const t=Array.from(n).filter((t=>"sso"===t.getAttribute("data-type")));1===t.length&&"false"!==t[0].getAttribute("auto-submit")&&t[0].click()}}},z.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"0.0.0-customScreen.1"}};export{z as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__classPrivateFieldGet as e,__classPrivateFieldSet as t,__awaiter as i,__rest as o}from"tslib";import{ensureFingerprintIds as s,clearFingerprintData as n}from"@descope/web-js-sdk";import{URL_CODE_PARAM_NAME as r,URL_TOKEN_PARAM_NAME as l,URL_RUN_IDS_PARAM_NAME as a,RESPONSE_ACTIONS as d,CUSTOM_INTERACTIONS as c,ELEMENT_TYPE_ATTRIBUTE as h,DESCOPE_ATTRIBUTE_EXCLUDE_FIELD as u,DESCOPE_ATTRIBUTE_EXCLUDE_NEXT_BUTTON as p}from"../constants/index.js";import{timeoutPromise as g,withMemCache as v,leadingDebounce as m,getUserLocale as f,showFirstScreenOnExecutionInit as b,injectSamlIdpForm as w,getAnimationDirection as y,transformStepStateForCustomScreen as I,getElementDescopeAttributes as C,submitForm as k,handleReportValidityOnBlur as S,handleAutoFocus as R,getFirstNonEmptyValue as O,clearPreviousExternalInputs as j}from"../helpers/helpers.js";import E from"../helpers/state.js";import{disableWebauthnButtons as A,updateTemplateFromScreenState as x,setPhoneAutoDetectDefaultCode as W,setTOTPVariable as U,setNOTPVariable as T,setCssVars as L,updateScreenFromScreenState as $}from"../helpers/templates.js";import{isConditionalLoginSupported as P}from"../helpers/webauthn.js";import{getABTestingKey as F}from"../helpers/abTestingKey.js";import{calculateConditions as N,calculateCondition as V}from"../helpers/conditions.js";import{setLastAuth as M,getLastAuth as q}from"../helpers/lastAuth.js";import{Direction as D}from"../types.js";import H from"./BaseDescopeWc.js";import K,{getScriptResultPath as B}from"./sdkScripts/index.js";import{FETCH_EXCEPTION_ERROR_CODE as G,FETCH_ERROR_RESPONSE_ERROR_CODE as J}from"../constants/general.js";var _,z,Q,X,Y,Z,ee,te,ie,oe,se,ne,re,le,ae,de,ce,he,ue,pe,ge,ve,me,fe,be;class we extends H{static set sdkConfigOverrides(e){H.sdkConfigOverrides=e}static get sdkConfigOverrides(){return H.sdkConfigOverrides}constructor(){const o=new E({deferredRedirect:!1});super(o.update.bind(o)),_.add(this),this.stepState=new E({},{updateOnlyOnChange:!1}),z.set(this,void 0),Q.set(this,null),X.set(this,{visibilitychange:e(this,_,"m",Y).bind(this)}),this.bridgeVersion=1,this.nativeResume=(t,i)=>{var o;const s=JSON.parse(i);if(this.logger.info(`nativeResume received payload of type '${t}'`),"oauthWeb"===t||"sso"===t){let{exchangeCode:e}=s;if(!e){e=null===(o=new URL(s.url).searchParams)||void 0===o?void 0:o.get(r)}this.nativeComplete({exchangeCode:e,idpInitiated:!0})}else if("magicLink"===t){const t=new URL(s.url),i=t.searchParams.get(l),o=t.searchParams.get(a).split("_").pop();e(this,ie,"f").call(this),this.flowState.update({token:i,stepId:o,action:void 0})}else this.nativeComplete(s)},ee.set(this,(e=>{this.contentRootElement.classList.toggle("hidden",e),this.slotElement.classList.toggle("hidden",!e)})),te.set(this,((o,s,n,r,l=!1)=>{if(this.flowState.current.action===d.poll){this.logger.debug("polling - Scheduling polling request");const a=Date.now(),d=l?500:2e3;t(this,z,setTimeout((()=>i(this,void 0,void 0,(function*(){var t;this.logger.debug("polling - Calling next");const i=this.sdk.flow.next(o,s,c.polling,n,r,{}),h=document.hidden&&!l&&Date.now()-a>d+500;let u;h&&this.logger.debug("polling - The polling seems to be throttled");try{const e=h?1e3:6e3;u=yield g(e,i)}catch(t){return this.logger.warn(`polling - The ${h?"throttled fetch":"fetch"} call timed out or was aborted`),void e(this,te,"f").call(this,o,s,n,r,h)}if((null===(t=null==u?void 0:u.error)||void 0===t?void 0:t.errorCode)===G)return this.logger.debug("polling - Got a generic error due to exception in fetch call"),void e(this,te,"f").call(this,o,s,n,r);this.logger.debug("polling - Got a response"),(null==u?void 0:u.error)&&this.logger.debug("polling - Response has an error",JSON.stringify(u.error,null,4)),e(this,oe,"f").call(this,u),e(this,te,"f").call(this,o,s,n,r)}))),d),"f")}})),ie.set(this,(()=>{clearTimeout(e(this,z,"f")),t(this,z,null,"f")})),oe.set(this,(t=>{var i,o,s,n,r,l,a,c,h,u,p,g;if(!(null==t?void 0:t.ok)){const a=null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.url,d=`${null===(o=null==t?void 0:t.response)||void 0===o?void 0:o.status} - ${null===(s=null==t?void 0:t.response)||void 0===s?void 0:s.statusText}`;e(this,_,"m",be).call(this,"error",(null==t?void 0:t.error)||{errorCode:J,errorDescription:d,errorMessage:a}),this.loggerWrapper.error((null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.errorDescription)||a,(null===(r=null==t?void 0:t.error)||void 0===r?void 0:r.errorMessage)||d);const c=null===(l=null==t?void 0:t.error)||void 0===l?void 0:l.errorCode;return void("E102004"!==c&&"E103205"!==c||!this.isRestartOnError||e(this,_,"m",Z).call(this))}null===(c=null===(a=t.data)||void 0===a?void 0:a.runnerLogs)||void 0===c||c.forEach((e=>{const{level:t,title:i,log:o}=e;t&&this.loggerWrapper[t]?this.loggerWrapper[t](i,o):this.loggerWrapper.info(i,o)}));const v=null===(p=null===(u=null===(h=t.data)||void 0===h?void 0:h.screen)||void 0===u?void 0:u.state)||void 0===p?void 0:p.errorText;(null===(g=t.data)||void 0===g?void 0:g.error)?this.loggerWrapper.error(`[${t.data.error.code}]: ${t.data.error.description}`,`${v?`${v} - `:""}${t.data.error.message}`):v&&this.loggerWrapper.error(v);const{status:m,authInfo:f,lastAuth:b}=t.data;if("completed"===m)return this.storeLastAuthenticatedUser&&M(b),void e(this,_,"m",be).call(this,"success",f);const{executionId:w,stepId:y,stepName:I,action:C,screen:k,redirect:S,openInNewTabUrl:R,webauthn:O,error:j,samlIdpResponse:E,nativeResponse:A}=t.data;C!==d.poll?(this.loggerWrapper.info(`Step "${I||`#${y}`}" is ${m}`,"",{screen:k,status:m,stepId:y,stepName:I,action:C,error:j}),this.flowState.update({stepId:y,executionId:w,action:C,redirectTo:null==S?void 0:S.url,openInNewTabUrl:R,screenId:null==k?void 0:k.id,screenState:null==k?void 0:k.state,webauthnTransactionId:null==O?void 0:O.transactionId,webauthnOptions:null==O?void 0:O.options,samlIdpResponseUrl:null==E?void 0:E.url,samlIdpResponseSamlResponse:null==E?void 0:E.samlResponse,samlIdpResponseRelayState:null==E?void 0:E.relayState,nativeResponseType:null==A?void 0:A.type,nativePayload:null==A?void 0:A.payload})):this.flowState.update({action:C})})),se.set(this,v((()=>i(this,void 0,void 0,(function*(){var e;try{const t=yield this.sdk.webauthn.signIn.start("",window.location.origin);return t.ok||this.loggerWrapper.warn("Webauthn start failed",null===(e=null==t?void 0:t.error)||void 0===e?void 0:e.errorMessage),t.data}catch(e){this.loggerWrapper.warn("Webauthn start failed",e.message)}}))))),ge.set(this,m(((t,o)=>i(this,void 0,void 0,(function*(){var i;if("true"===t.getAttribute("formnovalidate")||e(this,_,"m",ae).call(this)){const s=null==t?void 0:t.getAttribute("id");e(this,_,"m",ce).call(this,t);const n=yield e(this,_,"m",de).call(this),r=C(t),l=this.getComponentsContext(),a=Object.assign(Object.assign(Object.assign(Object.assign({},l),r),n),{origin:(null===(i=this.nativeOptions)||void 0===i?void 0:i.origin)||window.location.origin});o(s,a),e(this,_,"m",he).call(this,n)}}))))),this.flowState=o}loadSdkScripts(){return i(this,void 0,void 0,(function*(){const e=(yield this.getFlowConfig()).sdkScripts;null==e||e.forEach((e=>i(this,void 0,void 0,(function*(){(yield K(e.id))(e.initArgs,{baseUrl:this.baseUrl},(t=>{this.dispatchEvent(new CustomEvent("components-context",{detail:{[B(e.id,e.resultKey)]:t},bubbles:!0,composed:!0}))}))}))))}))}init(){const t=Object.create(null,{init:{get:()=>super.init}});return i(this,void 0,void 0,(function*(){var i,o,s;this.shadowRoot.isConnected&&(null===(i=this.flowState)||void 0===i||i.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this)),window.addEventListener("visibilitychange",e(this,X,"f").visibilitychange)),yield null===(s=t.init)||void 0===s?void 0:s.call(this)}))}disconnectedCallback(){var i;super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll(),null===(i=e(this,Q,"f"))||void 0===i||i.abort(),t(this,Q,null,"f"),window.removeEventListener("visibilitychange",e(this,X,"f").visibilitychange)}getHtmlFilenameWithLocale(e,t){return i(this,void 0,void 0,(function*(){let i;const o=f(e),s=yield this.getTargetLocales();return s.includes(o.locale)?i=`${t}-${o.locale}.html`:s.includes(o.fallback)&&(i=`${t}-${o.fallback}.html`),i}))}getPageContent(e,t){return i(this,void 0,void 0,(function*(){if(t)try{const{body:e}=yield this.fetchStaticResource(t,"text");return e}catch(i){this.loggerWrapper.error(`Failed to fetch flow page from ${t}. Fallback to url ${e}`,i)}try{const{body:t}=yield this.fetchStaticResource(e,"text");return t}catch(e){this.loggerWrapper.error("Failed to fetch flow page",e.message)}return null}))}onFlowChange(r,l,a){return i(this,void 0,void 0,(function*(){var h,u,p;const{projectId:g,flowId:v,tenant:m,stepId:C,executionId:S,action:R,screenId:O,screenState:j,redirectTo:E,openInNewTabUrl:A,redirectUrl:x,token:W,code:U,exchangeError:T,webauthnTransactionId:L,webauthnOptions:$,redirectAuthCodeChallenge:P,redirectAuthCallbackUrl:M,redirectAuthBackupCallbackUri:D,redirectAuthInitiator:H,locale:K,samlIdpResponseUrl:B,samlIdpResponseSamlResponse:G,samlIdpResponseRelayState:J,nativeResponseType:z,nativePayload:X}=r,Y=o(r,["projectId","flowId","tenant","stepId","executionId","action","screenId","screenState","redirectTo","openInNewTabUrl","redirectUrl","token","code","exchangeError","webauthnTransactionId","webauthnOptions","redirectAuthCodeChallenge","redirectAuthCallbackUrl","redirectAuthBackupCallbackUri","redirectAuthInitiator","locale","samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState","nativeResponseType","nativePayload"]);let Z,ie;const se=F(),ne=this.sdk.getLastUserLoginId(),re=yield this.getFlowConfig(),ae=yield this.getProjectConfig(),de=Object.entries(ae.flows||{}).reduce(((e,[t,i])=>(e[t]=i.version,e)),{}),ce=M&&P?{callbackUrl:M,codeChallenge:P,backupCallbackUri:D}:void 0,he=this.nativeOptions?{platform:this.nativeOptions.platform,oauthProvider:this.nativeOptions.oauthProvider,oauthRedirect:this.nativeOptions.oauthRedirect,magicLinkRedirect:this.nativeOptions.magicLinkRedirect,ssoRedirect:this.nativeOptions.ssoRedirect}:void 0;if(!S&&(this.loadSdkScripts(),re.fingerprintEnabled&&re.fingerprintKey?yield s(re.fingerprintKey,this.baseUrl):n(),re.conditions?({startScreenId:Z,conditionInteractionId:ie}=N({loginId:ne,code:U,token:W,abTestingKey:se},re.conditions)):re.condition?({startScreenId:Z,conditionInteractionId:ie}=V(re.condition,{loginId:ne,code:U,token:W,abTestingKey:se})):Z=re.startScreenId,!b(Z,Y))){const t=yield this.sdk.flow.start(v,Object.assign(Object.assign(Object.assign(Object.assign({tenant:m,redirectAuth:ce},Y),{client:this.client}),x&&{redirectUrl:x}),{lastAuth:q(ne),abTestingKey:se,locale:f(K).locale,nativeOptions:he}),ie,"",ae.componentsVersion,de,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),U?{exchangeCode:U,idpInitiated:!0}:{}),Y.descopeIdpInitiated&&{idpInitiated:!0}),W?{token:W}:{}),Y.oidcLoginHint?{externalId:Y.oidcLoginHint}:{}));return e(this,oe,"f").call(this,t),void("completed"!==(null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.status)&&this.flowState.update({code:void 0,token:void 0}))}if(S&&(a("token")&&W||a("code")&&U||a("exchangeError")&&T)){const t=yield this.sdk.flow.next(S,C,c.submit,re.version,ae.componentsVersion,{token:W,exchangeCode:U,exchangeError:T});return e(this,oe,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(R===d.loadForm&&["samlIdpResponseUrl","samlIdpResponseSamlResponse","samlIdpResponseRelayState"].some((e=>a(e)))){if(!B||!G)return void this.loggerWrapper.error("Did not get saml idp params data to load");w(B,G,J||"",k)}if(R===d.redirect&&(a("redirectTo")||a("deferredRedirect")))return E?"android"===H&&document.hidden?void this.flowState.update({deferredRedirect:!0}):void window.location.assign(E):void this.loggerWrapper.error("Did not get redirect url");if(R===d.webauthnCreate||R===d.webauthnGet){if(!L||!$)return void this.loggerWrapper.error("Did not get webauthn transaction id or options");let i,o;null===(u=e(this,Q,"f"))||void 0===u||u.abort(),t(this,Q,null,"f");try{i=R===d.webauthnCreate?yield this.sdk.webauthn.helpers.create($):yield this.sdk.webauthn.helpers.get($)}catch(e){"InvalidStateError"===e.name?this.loggerWrapper.warn("WebAuthn operation failed",e.message):"NotAllowedError"!==e.name&&this.loggerWrapper.error(e.message),o=e.name}const s=yield this.sdk.flow.next(S,C,c.submit,re.version,ae.componentsVersion,{transactionId:L,response:i,failure:o});e(this,oe,"f").call(this,s)}if(R===d.nativeBridge)return this.nativeComplete=t=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(S,C,c.submit,re.version,ae.componentsVersion,t);e(this,oe,"f").call(this,i)})),void e(this,_,"m",be).call(this,"bridge",{type:z,payload:X});if(e(this,te,"f").call(this,S,C,re.version,ae.componentsVersion),!O&&!Z)return void this.loggerWrapper.warn("No screen was found to show");const ue=Z||O,pe=yield this.getHtmlFilenameWithLocale(K,ue),{oidcLoginHint:ge,oidcPrompt:ve,oidcErrorRedirectUri:me,samlIdpUsername:fe}=Y,we={direction:y(C,l.stepId),screenState:Object.assign(Object.assign({},j),{form:Object.assign(Object.assign({},this.formConfigValues),null==j?void 0:j.form),lastAuth:{loginId:ne,name:this.sdk.getLastUserDisplayName()||ne}}),htmlFilename:`${ue}.html`,htmlLocaleFilename:pe,samlIdpUsername:fe,oidcLoginHint:ge,oidcPrompt:ve,oidcErrorRedirectUri:me,openInNewTabUrl:A},ye=q(ne);b(Z,Y)?we.next=(t,o)=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.start(v,Object.assign(Object.assign(Object.assign(Object.assign({tenant:m,redirectAuth:ce},Y),{lastAuth:ye,preview:this.preview,abTestingKey:se,client:this.client}),x&&{redirectUrl:x}),{locale:f(K).locale,nativeOptions:he}),ie,t,ae.componentsVersion,de,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},this.formConfigValues),o),U&&{exchangeCode:U,idpInitiated:!0}),Y.descopeIdpInitiated&&{idpInitiated:!0}),W&&{token:W}));return e(this,oe,"f").call(this,i),i})):(a("projectId")||a("baseUrl")||a("executionId")||a("stepId"))&&(we.next=(t,o)=>i(this,void 0,void 0,(function*(){const i=yield this.sdk.flow.next(S,C,t,re.version,ae.componentsVersion,o);return e(this,oe,"f").call(this,i),i})));const Ie=!!(yield null===(p=this.onPageUpdate)||void 0===p?void 0:p.call(this,I(Object.assign(Object.assign({},this.stepState.current),we)),this));if(Ie){this.loggerWrapper.debug("Rendering a custom screen"),this.contentRootElement.innerHTML="",e(this,_,"m",le).call(this,!this.stepState.current.htmlFilename),this.stepState.unsubscribeAll();const t=this.stepState.subscribe((()=>{var e;this.stepState.unsubscribe(t),null===(e=this.stepState)||void 0===e||e.subscribe(this.onStepChange.bind(this))}))}this.stepState.update(we),e(this,ee,"f").call(this,Ie)}))}onStepChange(t,o){return i(this,void 0,void 0,(function*(){var s,n;const{htmlFilename:r,htmlLocaleFilename:l,direction:a,next:d,screenState:u,openInNewTabUrl:p}=t,g=document.createElement("template");g.innerHTML=yield this.getPageContent(r,l);const v=g.content.cloneNode(!0),m=this.loadDescopeUiComponents(g);this.sdk.webauthn.helpers.isSupported()?yield e(this,_,"m",re).call(this,v,d):A(v),!t.samlIdpUsername||(null===(s=u.form)||void 0===s?void 0:s.loginId)||(null===(n=u.form)||void 0===n?void 0:n.email)||(u.form||(u.form={}),u.form.loginId=t.samlIdpUsername,u.form.email=t.samlIdpUsername),x(v,u,u.componentsConfig,this.formConfig,this.errorTransformer,this.loggerWrapper);const{geo:f}=yield this.getExecutionContext();W(v,f);const b=()=>i(this,void 0,void 0,(function*(){var t,i;yield m;const s=this.contentRootElement;U(s,null===(t=null==u?void 0:u.totp)||void 0===t?void 0:t.image),T(s,null===(i=null==u?void 0:u.notp)||void 0===i?void 0:i.image),L(s,v,u.cssVars,this.loggerWrapper),s.replaceChildren(v);const n=!o.htmlFilename;setTimeout((()=>{e(this,_,"m",ue).call(this),this.validateOnBlur&&S(s),$(s,u),e(this,_,"m",le).call(this,n),R(s,this.autoFocus,n)})),e(this,_,"m",me).call(this,d);s.querySelector(`[${h}="polling"]`)&&(yield this.getFlowConfig(),yield this.getProjectConfig(),d(c.polling,{})),p&&!o.openInNewTabUrl&&window.open(p,"_blank")}));a?e(this,_,"m",fe).call(this,b,a):b()}))}}z=new WeakMap,Q=new WeakMap,X=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,oe=new WeakMap,se=new WeakMap,ge=new WeakMap,_=new WeakSet,Y=function(){document.hidden||setTimeout((()=>{this.flowState.update({deferredRedirect:!1})}),300)},Z=function(){return i(this,void 0,void 0,(function*(){this.loggerWrapper.debug("Trying to restart the flow");const e=yield this.getComponentsVersion();this.getConfig.reset();e===(yield this.getComponentsVersion())?(this.loggerWrapper.debug("Components version was not changed, restarting flow"),this.flowState.update({stepId:null,executionId:null})):this.loggerWrapper.error("Components version mismatch, please reload the page")}))},ne=function(e){const t=e.getAttribute("name");if(!["email"].includes(t)){const i=`user-${t}`;e.setAttribute("name",i),e.addEventListener("input",(()=>{e.setAttribute("name",e.value?t:i)}))}},re=function(o,s){return i(this,void 0,void 0,(function*(){var n;null===(n=e(this,Q,"f"))||void 0===n||n.abort();const r=o.querySelector('*[autocomplete="webauthn"]');if(r&&(yield P())){const{options:o,transactionId:n}=(yield e(this,se,"f").call(this))||{};o&&n&&(e(this,_,"m",ne).call(this,r),t(this,Q,new AbortController,"f"),yield this.getFlowConfig(),yield this.getProjectConfig(),this.sdk.webauthn.helpers.conditional(o,e(this,Q,"f")).then((e=>i(this,void 0,void 0,(function*(){s(r.id,{transactionId:n,response:e})})))).catch((e=>{"AbortError"!==e.name&&this.loggerWrapper.error("Conditional login failed",e.message)})))}}))},le=function(t){t&&e(this,_,"m",be).call(this,"ready",{}),e(this,_,"m",be).call(this,"page-updated",{})},ae=function(){let e=!0;return Array.from(this.shadowRoot.querySelectorAll("*[name]")).reverse().forEach((t=>{var i,o;"slot"!==t.localName&&(null===(i=t.reportValidity)||void 0===i||i.call(t),e&&(e=null===(o=t.checkValidity)||void 0===o?void 0:o.call(t)))})),e},de=function(){return i(this,void 0,void 0,(function*(){const e=Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${u}])`));return(yield Promise.all(e.map((e=>i(this,void 0,void 0,(function*(){return{name:e.getAttribute("name"),value:e.value}})))))).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.name]:t.value})),{})}))},ce=function(e){const t=this.nextRequestStatus.subscribe((({isLoading:i})=>{i?e.setAttribute("loading","true"):(this.nextRequestStatus.unsubscribe(t),e.removeAttribute("loading"))}))},he=function(e={}){var t,i;const o=O(e,["externalId","email","phone"]),s=O(e,["newPassword","password"]);if(o&&s)try{if(!globalThis.PasswordCredential)return;const e=new globalThis.PasswordCredential({id:o,password:s});null===(i=null===(t=null===navigator||void 0===navigator?void 0:navigator.credentials)||void 0===t?void 0:t.store)||void 0===i||i.call(t,e)}catch(e){this.loggerWrapper.error("Could not store credentials",e.message)}},ue=function(){j();this.contentRootElement.querySelectorAll('[external-input="true"]').forEach((t=>e(this,_,"m",pe).call(this,t)))},pe=function(e){if(!e)return;e.querySelectorAll("input").forEach((t=>{const i=t.getAttribute("slot"),o=`input-${e.id}-${i}`,s=document.createElement("slot");s.setAttribute("name",o),s.setAttribute("slot",i),e.appendChild(s),t.setAttribute("slot",o),this.appendChild(t)}))},ve=function(t){this.contentRootElement.querySelectorAll('descope-passcode[data-auto-submit="true"]').forEach((i=>{i.addEventListener("input",(()=>{var o;(null===(o=i.checkValidity)||void 0===o?void 0:o.call(i))&&e(this,ge,"f").call(this,i,t)}))}))},me=function(t){this.contentRootElement.querySelectorAll(`descope-button:not([${p}])`).forEach((i=>{i.onclick=()=>{e(this,ge,"f").call(this,i,t)}})),e(this,_,"m",ve).call(this,t)},fe=function(e,t){this.contentRootElement.addEventListener("transitionend",(()=>{this.contentRootElement.classList.remove("fade-out"),e()}),{once:!0});const i=t===D.forward?"slide-forward":"slide-backward";Array.from(this.contentRootElement.getElementsByClassName("input-container")).forEach(((e,t)=>{e.style["transition-delay"]=40*t+"ms",e.classList.add(i)})),this.contentRootElement.classList.add("fade-out")},be=function(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t}))};export{we as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"./DescopeWc.js";customElements.get("descope-wc")?console.log("descope-wc is already defined"):customElements.define("descope-wc",e);export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=document.createElement("template");t.innerHTML="\n\t<style>\n\t\t:host {\n all: initial;\n\t\t\twidth: 100%;\n display: block;\n\t\t}\n\n\t\t#root {\n\t\t\theight: 100%;\n display: flex;\n flex-direction: column;\n\t\t}\n\n #content-root {\n transition: opacity 300ms ease-in-out;\n }\n\n\t\t#root[data-theme] {\n\t\t\tbackground-color: transparent;\n\t\t}\n\n\t\t.fade-out {\n\t\t\topacity: 0.1;\n\t\t}\n\n .hidden {\n display: none;\n }\n\n\t</style>\n\t";export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"tslib";import{defaultEndpoint as o,defaultScriptUrlPattern as r,load as i}from"@fingerprintjs/fingerprintjs-pro";const t=(t,n,l)=>e(void 0,void 0,void 0,(function*(){try{const{publicApiKey:e,useCloudflareIntegration:n,cloudflareScriptUrl:s,cloudflareEndpointUrl:d}=t;let p=[];p=n&&d?[d,o]:[o];let a=[];if(n&&s){const e=new URL(s);a=[`${e.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,r]}else a=[r];const c=i({apiKey:e,endpoint:p,scriptUrlPattern:a}),f=yield c,{requestId:u}=yield f.get();l(u)}catch(e){console.warn("Could not load fingerprint",e)}}));export{t as default,t as loadFingerprint};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as t}from"tslib";import{load as o,defaultEndpoint as e,defaultScriptUrlPattern as i}from"@fingerprintjs/fingerprintjs-pro";const n=(n,r,p)=>t(void 0,void 0,void 0,(function*(){try{const{customDomain:t,publicApiKey:a,cloudflareEndpointPath:s,cloudflareScriptPath:c}=n,{baseUrl:d}=r;let l;l=t?`https://${t}`:d||"https://api.descope.com";const f=new URL(l);f.pathname=s;const m=new URL(l);m.pathname=c;const u=`${m.toString()}?apiKey=<apiKey>&version=<version>&loaderVersion=<loaderVersion>`,h=o({apiKey:a,endpoint:[f.toString(),e],scriptUrlPattern:[u,i]}),y=yield h,{requestId:g}=yield y.get();p(g)}catch(t){console.warn("Could not load descope fingerprint",t)}}));export{n as default,n as loadFingerprint};
|