@descope/web-component 2.0.5 → 2.0.7
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/README.md +12 -9
- package/dist/esm/{debugger-wc-7607ab6e.js → debugger-wc-e72126e7.js} +1 -2
- package/dist/esm/index-3b6683c4.js +2 -0
- package/dist/esm/index.js +1 -2
- package/dist/index.js +2 -3
- package/package.json +79 -88
- package/dist/esm/debugger-wc-7607ab6e.js.map +0 -1
- package/dist/esm/index-d7eb861e.js +0 -3
- package/dist/esm/index-d7eb861e.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,89 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"typescript": "^4.5.3"
|
|
82
|
-
},
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"@descope/web-js-sdk": "1.0.0"
|
|
85
|
-
},
|
|
86
|
-
"overrides": {
|
|
87
|
-
"terser": "5.16.5"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
2
|
+
"name": "@descope/web-component",
|
|
3
|
+
"version": "2.0.7",
|
|
4
|
+
"author": "Descope Team <info@descope.com>",
|
|
5
|
+
"homepage": "https://github.com/descope/web-component",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/descope/web-component/issues",
|
|
8
|
+
"email": "help@descope.com"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"module": "dist/esm/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"description": "Descope WC",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/descope/web-component.git"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@open-wc/rollup-plugin-html": "1.2.5",
|
|
24
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
25
|
+
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
26
|
+
"@rollup/plugin-replace": "^5.0.0",
|
|
27
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
28
|
+
"@testing-library/dom": "^8.19.0",
|
|
29
|
+
"@testing-library/jest-dom": "5.16.5",
|
|
30
|
+
"@types/testing-library__jest-dom": "5.14.5",
|
|
31
|
+
"@types/jest": "^29.0.0",
|
|
32
|
+
"@types/node": "18.15.0",
|
|
33
|
+
"dotenv": "^16.0.3",
|
|
34
|
+
"eslint": "8.34.0",
|
|
35
|
+
"eslint-config-airbnb": "19.0.4",
|
|
36
|
+
"eslint-config-airbnb-typescript": "17.0.0",
|
|
37
|
+
"eslint-config-prettier": "8.7.0",
|
|
38
|
+
"eslint-config-standard": "17.0.0",
|
|
39
|
+
"eslint-import-resolver-typescript": "3.4.0",
|
|
40
|
+
"eslint-plugin-import": "2.27.5",
|
|
41
|
+
"eslint-plugin-jest": "27.2.1",
|
|
42
|
+
"eslint-plugin-jest-dom": "4.0.3",
|
|
43
|
+
"eslint-plugin-jest-formatting": "3.1.0",
|
|
44
|
+
"eslint-plugin-n": "15.6.1",
|
|
45
|
+
"eslint-plugin-no-only-tests": "3.1.0",
|
|
46
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
47
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
48
|
+
"eslint-plugin-promise": "6.1.1",
|
|
49
|
+
"jest": "^29.0.0",
|
|
50
|
+
"jest-environment-jsdom": "^29.0.0",
|
|
51
|
+
"lint-staged": "^13.0.3",
|
|
52
|
+
"prettier": "^2.6.2",
|
|
53
|
+
"pretty-quick": "^3.1.3",
|
|
54
|
+
"rollup": "^2.62.0",
|
|
55
|
+
"rollup-plugin-browsersync": "^1.3.3",
|
|
56
|
+
"rollup-plugin-define": "^1.0.1",
|
|
57
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
58
|
+
"rollup-plugin-dts": "^4.2.2",
|
|
59
|
+
"rollup-plugin-livereload": "^2.0.5",
|
|
60
|
+
"rollup-plugin-terser": "7.0.2",
|
|
61
|
+
"shadow-dom-testing-library": "^1.2.0",
|
|
62
|
+
"string-to-arraybuffer": "^1.0.2",
|
|
63
|
+
"ts-jest": "^29.0.0",
|
|
64
|
+
"ts-node": "10.9.1",
|
|
65
|
+
"typescript": "^4.5.3"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@descope/web-js-sdk": "1.0.2"
|
|
69
|
+
},
|
|
70
|
+
"overrides": {
|
|
71
|
+
"terser": "5.16.5"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"start": "rollup -c rollup.config.app.serve.js -w",
|
|
75
|
+
"build-app": "rollup -c rollup.config.app.js",
|
|
76
|
+
"build": "rollup -c",
|
|
77
|
+
"test": "jest",
|
|
78
|
+
"lint": "eslint '+(src|test)/**/*.ts'"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debugger-wc-7607ab6e.js","sources":["../../src/lib/helpers/positionHelpers.ts","../../src/lib/debugger-wc.ts"],"sourcesContent":["type Boundary = number | 'all'; // all means that all the element is visible\ntype Boundaries = { top?: Boundary; left?: Boundary; right?: Boundary; bottom?: Boundary };\n\nexport const limitCoordinateToScreenBoundaries = (\n\tele: HTMLElement,\n\tx: number,\n\ty: number,\n\tboundaries: Boundaries = {}\n) => [\n\tMath.min(\n\t\tMath.max(\n\t\t\tx,\n\t\t\t(boundaries.left === 'all' ? ele.offsetWidth : boundaries.left ?? 0) - ele.offsetWidth\n\t\t),\n\t\twindow.innerWidth - (boundaries.right === 'all' ? ele.offsetWidth : boundaries.right ?? 0)\n\t),\n\tMath.min(\n\t\tMath.max(\n\t\t\ty,\n\t\t\t(boundaries.top === 'all' ? ele.offsetHeight : boundaries.top ?? 0) - ele.offsetHeight\n\t\t),\n\t\twindow.innerHeight - (boundaries.bottom === 'all' ? ele.offsetHeight : boundaries.bottom ?? 0)\n\t)\n];\n\nexport const dragElement = (\n\tele: HTMLElement,\n\ttriggerEle?: HTMLElement,\n\tkeepVisible?: Boundaries\n) => {\n\tlet deltaX = 0;\n\tlet deltaY = 0;\n\tlet currentX = 0;\n\tlet currentY = 0;\n\n\tfunction elementDrag(e: MouseEvent) {\n\t\te.preventDefault();\n\t\t// calculate the new cursor position:\n\t\tdeltaX = currentX - e.clientX;\n\t\tdeltaY = currentY - e.clientY;\n\t\tcurrentX = e.clientX;\n\t\tcurrentY = e.clientY;\n\t\t// set the element's new position:\n\t\tconst [left, top] = limitCoordinateToScreenBoundaries(\n\t\t\tele,\n\t\t\tele.offsetLeft - deltaX,\n\t\t\tele.offsetTop - deltaY,\n\t\t\tkeepVisible\n\t\t);\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tele.style.top = `${top}px`;\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tele.style.left = `${left}px`;\n\t}\n\n\tfunction closeDragElement() {\n\t\t// stop moving when mouse button is released:\n\t\tdocument.onmouseup = null;\n\t\tdocument.onmousemove = null;\n\t}\n\n\tfunction dragMouseDown(e: MouseEvent) {\n\t\te.preventDefault();\n\t\t// get the mouse cursor position at startup:\n\t\tcurrentX = e.clientX;\n\t\tcurrentY = e.clientY;\n\t\tdocument.onmouseup = closeDragElement;\n\t\t// call a function whenever the cursor moves:\n\t\tdocument.onmousemove = elementDrag;\n\t}\n\n\tif (triggerEle) {\n\t\t// if provided, the triggerEle is where you move the div from\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttriggerEle.onmousedown = dragMouseDown;\n\t} else {\n\t\t// otherwise, move the DIV from anywhere inside the DIV:\n\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tele.onmousedown = dragMouseDown;\n\t}\n};\n\nexport const addOnResize = (ele: HTMLElement) => {\n\t// eslint-disable-next-line no-param-reassign\n\tele.onmousemove = (\n\t\te: MouseEvent & { target: { w: number; h: number; offsetWidth: number; offsetHeight: number } }\n\t) => {\n\t\tif (\n\t\t\t(e.target.w && e.target.w !== e.target.offsetWidth) ||\n\t\t\t(e.target.h && e.target.h !== e.target.offsetHeight)\n\t\t) {\n\t\t\tele.onresize(e);\n\t\t}\n\t\te.target.w = e.target.offsetWidth;\n\t\te.target.h = e.target.offsetHeight;\n\t};\n};\n","/* eslint-disable no-param-reassign */\nimport { addOnResize, dragElement, limitCoordinateToScreenBoundaries, State } from './helpers';\nimport { DebuggerMessage } from './types';\n\nconst INITIAL_POS_THRESHOLD = 32;\nconst INITIAL_WIDTH = 300;\nconst INITIAL_HEIGHT = 200;\nconst MIN_SIZE = 200;\n\nconst template = document.createElement('template');\ntemplate.innerHTML = `\n<style>\n .debugger {\n width: ${INITIAL_WIDTH}px;\n height: ${INITIAL_HEIGHT}px;\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: ${MIN_SIZE}px;\n max-width: 600px;\n max-height: calc(100% - ${INITIAL_POS_THRESHOLD * 2}px);\n min-height: ${MIN_SIZE}px;\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 } \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:${INITIAL_POS_THRESHOLD}px; left:${\n\twindow.innerWidth - INITIAL_WIDTH - INITIAL_POS_THRESHOLD\n}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`;\n\nconst icon = `<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\ntype MessagesState = { messages: DebuggerMessage[] };\n\nclass Debugger extends HTMLElement {\n\t#messagesState = new State<MessagesState>({ messages: [] });\n\n\t#rootEle: HTMLDivElement;\n\n\t#contentEle: HTMLDivElement;\n\n\t#headerEle: HTMLDivElement;\n\n\t#eventsCbRefs = {\n\t\tresize: this.#onWindowResize.bind(this)\n\t};\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.attachShadow({ mode: 'open' });\n\t\tthis.shadowRoot.appendChild(template.content.cloneNode(true));\n\n\t\tthis.#rootEle = this.shadowRoot.querySelector<HTMLDivElement>('.debugger');\n\t\tthis.#contentEle = this.#rootEle.querySelector<HTMLDivElement>('.content');\n\t\tthis.#headerEle = this.#rootEle.querySelector<HTMLDivElement>('.header');\n\t}\n\n\tupdateData(data: DebuggerMessage | DebuggerMessage[]) {\n\t\tthis.#messagesState.update((state) => ({\n\t\t\tmessages: state.messages.concat(data)\n\t\t}));\n\t}\n\n\t#onNewMessages(data: MessagesState) {\n\t\tthis.#renderMessages(data);\n\t\tthis.#setCollapsibleMessages();\n\t}\n\n\t#renderMessages(data: MessagesState) {\n\t\tthis.#contentEle.innerHTML = data.messages\n\t\t\t.map(\n\t\t\t\t(message) => `\n <div class=\"msg\">\n ${icon}\n <div class=\"msg_content\">\n <div class=\"msg_title\">\n ${message.title}\n </div>\n <div class=\"msg_desc\">\n ${message.description}\n </div>\n </div>\n <div class=\"chevron\"></div>\n </div>\n `\n\t\t\t)\n\t\t\t.join('');\n\t}\n\n\t#setCollapsibleMessages() {\n\t\tthis.#contentEle.querySelectorAll('.msg').forEach((ele: HTMLElement) => {\n\t\t\tconst descEle = ele.querySelector('.msg_desc');\n\t\t\tconst lineHeight = 20;\n\t\t\tconst isScroll = descEle.scrollWidth > descEle.clientWidth;\n\t\t\tconst isMultiLine = descEle.clientHeight > lineHeight;\n\t\t\tconst isCollapsible = isScroll || isMultiLine;\n\n\t\t\tif (isCollapsible) {\n\t\t\t\tele.classList.add('collapsible');\n\t\t\t\tele.onclick = (e: MouseEvent) => {\n\t\t\t\t\t// message description should not toggle collapse\n\t\t\t\t\tif (!(e.target as HTMLElement).classList.contains('msg_desc')) {\n\t\t\t\t\t\tele.classList.toggle('collapsed');\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tele.classList.remove('collapsible');\n\t\t\t\tele.onclick = null;\n\t\t\t}\n\t\t});\n\t}\n\n\t#onWindowResize() {\n\t\t// when window is resizing we want to make sure debugger is still visible\n\t\tconst [left, top] = limitCoordinateToScreenBoundaries(\n\t\t\tthis.#rootEle,\n\t\t\tNumber.parseInt(this.#rootEle.style.left, 10),\n\t\t\tNumber.parseInt(this.#rootEle.style.top, 10),\n\t\t\t{ top: 'all', bottom: 100, left: 100, right: 100 }\n\t\t);\n\t\tthis.#rootEle.style.top = `${top}px`;\n\t\tthis.#rootEle.style.left = `${left}px`;\n\t}\n\n\tconnectedCallback() {\n\t\tdragElement(this.#rootEle, this.#headerEle, { top: 'all', bottom: 100, left: 100, right: 100 });\n\n\t\twindow.addEventListener('resize', this.#eventsCbRefs.resize);\n\n\t\taddOnResize(this.#rootEle);\n\t\tthis.#rootEle.onresize = this.#setCollapsibleMessages.bind(this);\n\n\t\tthis.#messagesState.subscribe(this.#onNewMessages.bind(this));\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.#messagesState.unsubscribeAll();\n\t\twindow.removeEventListener('resize', this.#eventsCbRefs.resize);\n\t}\n}\n\ncustomElements.define('descope-debugger', Debugger);\nexport default Debugger;\n"],"names":["limitCoordinateToScreenBoundaries","ele","x","y","boundaries","Math","min","max","left","offsetWidth","_a","window","innerWidth","right","_b","top","offsetHeight","_c","innerHeight","bottom","_d","template","document","createElement","innerHTML","Debugger","HTMLElement","constructor","super","_Debugger_messagesState","set","this","State","messages","_Debugger_rootEle","_Debugger_contentEle","_Debugger_headerEle","_Debugger_eventsCbRefs","resize","__classPrivateFieldGet","_Debugger_instances","_Debugger_onWindowResize","bind","attachShadow","mode","shadowRoot","appendChild","content","cloneNode","__classPrivateFieldSet","querySelector","updateData","data","update","state","concat","connectedCallback","triggerEle","keepVisible","deltaX","deltaY","currentX","currentY","elementDrag","e","preventDefault","clientX","clientY","offsetLeft","offsetTop","style","closeDragElement","onmouseup","onmousemove","dragMouseDown","onmousedown","dragElement","addEventListener","target","w","h","onresize","_Debugger_setCollapsibleMessages","subscribe","_Debugger_onNewMessages","disconnectedCallback","unsubscribeAll","removeEventListener","_Debugger_renderMessages","call","map","message","title","description","join","querySelectorAll","forEach","descEle","isScroll","scrollWidth","clientWidth","isMultiLine","clientHeight","classList","add","onclick","contains","toggle","remove","Number","parseInt","customElements","define"],"mappings":"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"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var t=function(){return t=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};function e(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)e.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}function n(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}l((o=o.apply(t,e||[])).next())}))}function o(t,e,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(t):o?o.value:e.get(t)}function i(t,e,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(t,n):i?i.value=n:e.set(t,n),n}const r="undefined"!=typeof localStorage,s=r&&localStorage.getItem("base.content.url")||"https://static.descope.com/pages",a="descope-login-flow",l="t",c="code",u="err",d="data-exclude-field",h="dls_last_auth",p="data-type",f="redirect",g="poll",v="webauthnCreate",b="webauthnGet",m="v2-alpha",y="submit",w="polling";var k,I,O;function j(t){return new URLSearchParams(window.location.search).get(t)}function S(t){if(window.history.replaceState&&j(t)){const e=new URL(window.location.href),n=new URLSearchParams(e.search);n.delete(t),e.search=n.toString(),window.history.replaceState({},"",e.toString())}}function E(t,e){return n(this,void 0,void 0,(function*(){const n=yield fetch(t,{cache:"default"});if(!n.ok)throw Error(`Error fetching URL ${t}`);return{body:yield n[e||"text"](),headers:Object.fromEntries(n.headers.entries())}}))}!function(t){t.backward="backward",t.forward="forward"}(k||(k={}));const x=(...t)=>t.join("/").replace(/\/+/g,"/");function C(t,e){const n=new URL(s);return n.pathname=x(n.pathname,t,m,e),n.toString()}function _(t,e){if(!Number.isNaN(t)&&!Number.isNaN(e))return t>e?k.forward:t<e?k.backward:void 0}const A=()=>{const[t="",e=""]=(j(a)||"").split("_");return{executionId:t,stepId:e}};function U(){S(a)}const P=t=>t.replace(/-./g,(t=>t[1].toUpperCase())),R=()=>{const{executionId:t,stepId:e}=A();(t||e)&&U();const n=j(l)||void 0;n&&S(l);const o=j(c)||void 0;o&&S(c);const i=j(u)||void 0;return i&&S(u),{executionId:t,stepId:e,token:n,code:o,exchangeError:i}},T=t=>{let e,n;return(...o)=>{return e&&(r=o,(i=e).length===r.length&&i.every(((t,e)=>t===r[e])))||(e=o,n=t(...o)),n;var i,r}},q=null===(O=null===(I=null===navigator||void 0===navigator?void 0:navigator.userAgentData)||void 0===I?void 0:I.brands)||void 0===O?void 0:O.find((({brand:t,version:e})=>"Chromium"===t&&parseFloat(e)));var D,M,$,L;function N(t,e){const n=Object.getOwnPropertyNames(t),o=Object.getOwnPropertyNames(e);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const i=n[o],r=t[i],s=e[i];if(null===r||null===s){if(r!==s)return!1}else if("object"==typeof r&&"object"==typeof s){if(!N(r,s))return!1}else if(r!==s)return!1}return!0}class K{constructor(t={},{updateOnlyOnChange:e=!0}={}){D.set(this,void 0),M.set(this,{}),$.set(this,0),L.set(this,!1),this.update=t=>{const e="function"==typeof t?t(o(this,D,"f")):t,n=Object.assign(Object.assign({},o(this,D,"f")),e);if(!o(this,L,"f")||!N(o(this,D,"f"),n)){const t=o(this,D,"f");i(this,D,n,"f"),Object.freeze(o(this,D,"f")),setTimeout((()=>{Object.values(o(this,M,"f")).forEach((e=>e(n,t,((t,e)=>n=>t[n]!==e[n])(n,t))))}),0)}},i(this,D,t,"f"),i(this,L,e,"f")}get current(){return Object.assign({},o(this,D,"f"))}subscribe(t){return i(this,$,o(this,$,"f")+1,"f"),o(this,M,"f")[o(this,$,"f")]=t,o(this,$,"f").toString()}unsubscribe(t){const e=!!o(this,M,"f")[t];return e&&delete o(this,M,"f")[t],e}unsubscribeAll(){return i(this,M,{},"f"),!0}}D=new WeakMap,M=new WeakMap,$=new WeakMap,L=new WeakMap;const J=(t,e)=>{var n;((t,e,n="")=>{t.querySelectorAll(`[${p}="${e}"]`).forEach((t=>{t.textContent=n,t.classList[n?"remove":"add"]("hide")}))})(t,"error-message",null==e?void 0:e.errorText),((t,e)=>{Object.entries(e||{}).forEach((([e,n])=>{Array.from(t.querySelectorAll(`.descope-input[name="${e}"]:not([${d}])`)).forEach((t=>{t.value=n}))}))})(t,null==e?void 0:e.inputs),((t,e)=>{t.querySelectorAll(`[${p}="totp-link"]`).forEach((t=>{t.href=e}))})(t,null===(n=null==e?void 0:e.totp)||void 0===n?void 0:n.provisionUrl),((t,e)=>{t.querySelectorAll(".descope-text,.descope-link").forEach((t=>{t.textContent=((t,e)=>t.replace(/{{(.+?)}}/g,((t,n)=>{return o=e,n.split(".").reduce(((t,e)=>(null==t?void 0:t[e])||""),o);var o})))(t.textContent,e)}))})(t,e)},F=T((()=>n(void 0,void 0,void 0,(function*(){var t,e,n,o;if(!window.PublicKeyCredential||!PublicKeyCredential.isConditionalMediationAvailable||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable)return console.warn("webauthn","Conditional UI is not supported"),!1;try{const i=Promise.all([null===(t=window.PublicKeyCredential)||void 0===t?void 0:t.isConditionalMediationAvailable(),null===(e=window.PublicKeyCredential)||void 0===e?void 0:e.isUserVerifyingPlatformAuthenticatorAvailable()]).then((t=>t.every((t=>!!t)))),r=108;return yield Promise.race([i,(n=100,new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error(`Promise timed out after ${n} ms`))}),n);null==o||o((e=>{clearTimeout(i),t(e)}),(t=>{clearTimeout(i),e(t)}))}))).catch((()=>q()>=r))])}catch(t){return console.warn("webauthn","Conditional login check failed",t),!1}})))),W={"lastAuth.loginId":{"not-empty":t=>!!t.loginId,empty:t=>!t.loginId},idpInitiated:{"is-true":t=>!!t.code,"is-false":t=>!t.code}};function H(t){this.message=t}H.prototype=new Error,H.prototype.name="InvalidCharacterError";var B="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new H("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,i=0,r=0,s="";o=e.charAt(r++);~o&&(n=i%4?64*n+o:o,i++%4)?s+=String.fromCharCode(255&n>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function V(t){this.message=t}function z(t,e){if("string"!=typeof t)throw new V("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(B(t).replace(/(.)/g,(function(t,e){var n=e.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(e)}catch(t){return B(e)}}(t.split(".")[n]))}catch(t){throw new V("Invalid token specified: "+t.message)}}V.prototype=new Error,V.prototype.name="InvalidTokenError";var G="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Z="Expected a function",Q="__lodash_hash_undefined__",Y=1/0,X="[object Function]",tt="[object GeneratorFunction]",et="[object Symbol]",nt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ot=/^\w*$/,it=/^\./,rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/\\(\\)?/g,at=/^\[object .+?Constructor\]$/,lt="object"==typeof G&&G&&G.Object===Object&&G,ct="object"==typeof self&&self&&self.Object===Object&&self,ut=lt||ct||Function("return this")();var dt,ht=Array.prototype,pt=Function.prototype,ft=Object.prototype,gt=ut["__core-js_shared__"],vt=(dt=/[^.]+$/.exec(gt&>.keys&>.keys.IE_PROTO||""))?"Symbol(src)_1."+dt:"",bt=pt.toString,mt=ft.hasOwnProperty,yt=ft.toString,wt=RegExp("^"+bt.call(mt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),kt=ut.Symbol,It=ht.splice,Ot=Tt(ut,"Map"),jt=Tt(Object,"create"),St=kt?kt.prototype:void 0,Et=St?St.toString:void 0;function xt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function Ct(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function _t(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1])}}function At(t,e){for(var n,o,i=t.length;i--;)if((n=t[i][0])===(o=e)||n!=n&&o!=o)return i;return-1}function Ut(t,e){var n;e=function(t,e){if($t(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||Nt(t))return!0;return ot.test(t)||!nt.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:$t(n=e)?n:qt(n);for(var o=0,i=e.length;null!=t&&o<i;)t=t[Dt(e[o++])];return o&&o==i?t:void 0}function Pt(t){if(!Lt(t)||(e=t,vt&&vt in e))return!1;var e,n=function(t){var e=Lt(t)?yt.call(t):"";return e==X||e==tt}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?wt:at;return n.test(function(t){if(null!=t){try{return bt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t))}function Rt(t,e){var n,o,i=t.__data__;return("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Tt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Pt(n)?n:void 0}xt.prototype.clear=function(){this.__data__=jt?jt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(jt){var n=e[t];return n===Q?void 0:n}return mt.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:mt.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=jt&&void 0===e?Q:e,this},Ct.prototype.clear=function(){this.__data__=[]},Ct.prototype.delete=function(t){var e=this.__data__,n=At(e,t);return!(n<0)&&(n==e.length-1?e.pop():It.call(e,n,1),!0)},Ct.prototype.get=function(t){var e=this.__data__,n=At(e,t);return n<0?void 0:e[n][1]},Ct.prototype.has=function(t){return At(this.__data__,t)>-1},Ct.prototype.set=function(t,e){var n=this.__data__,o=At(n,t);return o<0?n.push([t,e]):n[o][1]=e,this},_t.prototype.clear=function(){this.__data__={hash:new xt,map:new(Ot||Ct),string:new xt}},_t.prototype.delete=function(t){return Rt(this,t).delete(t)},_t.prototype.get=function(t){return Rt(this,t).get(t)},_t.prototype.has=function(t){return Rt(this,t).has(t)},_t.prototype.set=function(t,e){return Rt(this,t).set(t,e),this};var qt=Mt((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(Nt(t))return Et?Et.call(t):"";var e=t+"";return"0"==e&&1/t==-Y?"-0":e}(e);var n=[];return it.test(t)&&n.push(""),t.replace(rt,(function(t,e,o,i){n.push(o?i.replace(st,"$1"):e||t)})),n}));function Dt(t){if("string"==typeof t||Nt(t))return t;var e=t+"";return"0"==e&&1/t==-Y?"-0":e}function Mt(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError(Z);var n=function(){var o=arguments,i=e?e.apply(this,o):o[0],r=n.cache;if(r.has(i))return r.get(i);var s=t.apply(this,o);return n.cache=r.set(i,s),s};return n.cache=new(Mt.Cache||_t),n}Mt.Cache=_t;var $t=Array.isArray;function Lt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Nt(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&yt.call(t)==et}var Kt=function(t,e,n){var o=null==t?void 0:Ut(t,e);return void 0===o?n:o},Jt="/v1/auth/accesskey/exchange",Ft="/v1/auth/otp/verify",Wt="/v1/auth/otp/signin",Ht="/v1/auth/otp/signup",Bt={email:"/v1/auth/otp/update/email",phone:"/v1/auth/otp/update/phone"},Vt="/v1/auth/otp/signup-in",zt="/v1/auth/magiclink/verify",Gt="/v1/auth/magiclink/signin",Zt="/v1/auth/magiclink/signup",Qt={email:"/v1/auth/magiclink/update/email",phone:"/v1/auth/magiclink/update/phone"},Yt="/v1/auth/magiclink/signup-in",Xt="/v1/auth/enchantedlink/verify",te="/v1/auth/enchantedlink/signin",ee="/v1/auth/enchantedlink/signup",ne="/v1/auth/enchantedlink/pending-session",oe={email:"/v1/auth/enchantedlink/update/email"},ie="/v1/auth/enchantedlink/signup-in",re="/v1/auth/oauth/authorize",se="/v1/auth/oauth/exchange",ae="/v1/auth/saml/authorize",le="/v1/auth/saml/exchange",ce="/v1/auth/totp/verify",ue="/v1/auth/totp/signup",de="/v1/auth/totp/update",he={start:"/v1/auth/webauthn/signup/start",finish:"/v1/auth/webauthn/signup/finish"},pe={start:"/v1/auth/webauthn/signin/start",finish:"/v1/auth/webauthn/signin/finish"},fe={start:"/v1/auth/webauthn/signup-in/start"},ge={start:"v1/auth/webauthn/update/start",finish:"/v1/auth/webauthn/update/finish"},ve="/v1/auth/refresh",be="/v1/auth/logout",me="/v1/auth/logoutall",ye="/v1/auth/me",we="/v1/flow/start",ke="/v1/flow/next";const Ie=()=>{const t={};return{headers(e){const n="function"==typeof e.entries?Object.fromEntries(e.entries()):e;return t.Headers=JSON.stringify(n),this},body(e){return t.Body=e,this},url(e){return t.Url=e.toString(),this},method(e){return t.Method=e,this},title(e){return t.Title=e,this},status(e){return t.Status=e,this},build:()=>Object.keys(t).flatMap((e=>t[e]?[`${"Title"!==e?`${e}: `:""}${t[e]}`]:[])).join("\n")}};var Oe;!function(t){t.get="GET",t.delete="DELETE",t.post="POST",t.put="PUT"}(Oe||(Oe={}));const je=(...t)=>new Headers(t.reduce(((t,e)=>{const n=(t=>Array.isArray(t)?t:t instanceof Headers?Array.from(t.entries()):t?Object.entries(t):[])(e);return n.reduce(((e,[n,o])=>(t[n]=o,t)),t),t}),{})),Se=t=>void 0===t?void 0:JSON.stringify(t),Ee=(t,e="")=>{let n=t;return e&&(n=n+":"+e),{Authorization:`Bearer ${n}`}},xe=({baseUrl:t,projectId:e,baseConfig:n,logger:o,hooks:i,cookiePolicy:r,fetch:s})=>{const a=((t,e)=>{const n=e||fetch;return n||null==t||t.warn("Fetch is not defined, you will not be able to send http requests, if you are running in a test, make sure fetch is defined globally"),t?async(...e)=>{if(!n)throw Error("Cannot send http request, fetch is not defined, if you are running in a test, make sure fetch is defined globally");t.log((t=>Ie().title("Request").url(t[0]).method(t[1].method).headers(t[1].headers).body(t[1].body).build())(e));const o=await n(...e);return t[o.ok?"log":"error"](await(async t=>{const e=await(t.clone?t.clone().text():t.text());return t.text=()=>Promise.resolve(e),t.json=()=>Promise.resolve(JSON.parse(e)),Ie().title("Response").url(t.url.toString()).status(`${t.status} ${t.statusText}`).headers(t.headers).body(e).build()})(o)),o}:n})(o,s),l=async o=>{const s=(null==i?void 0:i.beforeRequest)?i.beforeRequest(o):o,{path:l,body:c,headers:u,queryParams:d,method:h,token:p}=s,f=await a((({path:t,baseUrl:e,queryParams:n})=>{const o=new URL(t,e);return n&&(o.search=new URLSearchParams(n).toString()),o})({path:l,baseUrl:t,queryParams:d}),{headers:je(Ee(e,p),{"x-descope-sdk-name":"core-js","x-descope-sdk-version":"1.0.1"},(null==n?void 0:n.baseHeaders)||{},u),method:h,body:Se(c),credentials:r||"include"});return(null==i?void 0:i.afterRequest)&&await i.afterRequest(o,null==f?void 0:f.clone()),f};return{get:(t,{headers:e,queryParams:n,token:o}={})=>l({path:t,headers:e,queryParams:n,body:void 0,method:Oe.get,token:o}),post:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Oe.post,token:i}),put:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Oe.put,token:i}),delete:(t,e,{headers:n,queryParams:o,token:i}={})=>l({path:t,headers:n,queryParams:o,body:e,method:Oe.delete,token:i}),hooks:i}};var Ce={TOO_MANY_REQUESTS:429};function _e(t,e,n){var o;let i=Ae(t);e&&(i=null===(o=null==i?void 0:i.tenants)||void 0===o?void 0:o[e]);const r=null==i?void 0:i[n];return Array.isArray(r)?r:[]}function Ae(t){if("string"!=typeof t||!t)throw new Error("Invalid token provided");return z(t)}function Ue(t){const{exp:e}=Ae(t);return(new Date).getTime()/1e3>e}function Pe(t,e){return _e(t,e,"permissions")}function Re(t,e){return _e(t,e,"roles")}const Te=(...t)=>t.join("/").replace(/\/{2,}/g,"/");async function qe(t,e){var n;const o=await t,i={code:o.status,ok:o.ok,response:o},r=await o.clone().json();return o.ok?i.data=e?e(r):r:(i.error=r,o.status===Ce.TOO_MANY_REQUESTS&&Object.assign(i.error,{retryAfter:Number.parseInt(null===(n=o.headers)||void 0===n?void 0:n.get("retry-after"))||0})),i}const De=(t,e)=>(n=e)=>e=>!t(e)&&n.replace("{val}",e),Me=(...t)=>({validate:e=>(t.forEach((t=>{const n=t(e);if(n)throw new Error(n)})),!0)}),$e=t=>e=>t.test(e),Le=$e(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/),Ne=$e(/^\+[1-9]{1}[0-9]{3,14}$/),Ke=De(Le,'"{val}" is not a valid email'),Je=De(Ne,'"{val}" is not a valid phone number'),Fe=De((1,t=>t.length>=1),"Minimum length is 1");const We=De((t=>"string"==typeof t),"Input is not a string"),He=(...t)=>e=>(...n)=>(t.forEach(((t,e)=>Me(...t).validate(n[e]))),e(...n)),Be=t=>[We(`"${t}" must be a string`),Fe(`"${t}" must not be empty`)],Ve=t=>[We(`"${t}" must be a string`),Ke()],ze=t=>[We(`"${t}" must be a string`),Je()],Ge=He(Be("accessKey")),Ze=t=>({exchange:Ge((e=>qe(t.post(Jt,{},{token:e}))))});var Qe,Ye,Xe,tn;!function(t){t.sms="sms",t.whatsapp="whatsapp"}(Qe||(Qe={})),function(t){t.email="email",t.sms="sms",t.whatsapp="whatsapp"}(Ye||(Ye={})),function(t){t.waiting="waiting",t.running="running",t.completed="completed",t.failed="failed"}(Xe||(Xe={})),function(t){t.signUp="signup",t.signIn="signin",t.verify="verify"}(tn||(tn={}));const en=Be("loginId"),nn=He(Be("token")),on=He(en),rn=He(Be("pendingRef")),sn=He(en,Ve("email")),an=t=>({verify:nn((e=>qe(t.post(Xt,{token:e})))),signIn:on(((e,n,o,i)=>qe(t.post(Te(te,Ye.email),{loginId:e,URI:n,loginOptions:o},{token:i})))),signUpOrIn:on(((e,n)=>qe(t.post(Te(ie,Ye.email),{loginId:e,URI:n})))),signUp:on(((e,n,o)=>qe(t.post(Te(ee,Ye.email),{loginId:e,URI:n,user:o})))),waitForSession:rn(((e,n)=>new Promise((o=>{const{pollingIntervalMs:i,timeoutMs:r}=(({pollingIntervalMs:t=1e3,timeoutMs:e=6e5}={})=>({pollingIntervalMs:Math.max(t||1e3,1e3),timeoutMs:Math.min(e||6e5,6e5)}))(n);let s;const a=setInterval((async()=>{const n=await t.post(ne,{pendingRef:e});n.ok&&(clearInterval(a),s&&clearTimeout(s),o(qe(Promise.resolve(n))))}),i);s=setTimeout((()=>{o({error:{errorDescription:`Session polling timeout exceeded: ${r}ms`,errorCode:"0"},ok:!1}),clearInterval(a)}),r)})))),update:{email:sn(((e,n,o,i)=>qe(t.post(oe.email,{loginId:e,email:n,URI:o},{token:i}))))}}),ln=He(Be("flowId")),cn=He(Be("executionId"),Be("stepId"),Be("interactionId")),un=t=>({start:ln(((e,n,o,i,r)=>qe(t.post(we,{flowId:e,options:n,conditionInteractionId:o,interactionId:i,input:r})))),next:cn(((e,n,o,i)=>qe(t.post(ke,{executionId:e,stepId:n,interactionId:o,input:i}))))}),dn=Be("loginId"),hn=He(Be("token")),pn=He(dn),fn=He(dn,ze("phone")),gn=He(dn,Ve("email")),vn=t=>({verify:hn((e=>qe(t.post(zt,{token:e})))),signIn:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pn(((e,o,i,r)=>qe(t.post(Te(Gt,n),{loginId:e,URI:o,loginOptions:i},{token:r}))))})),{}),signUp:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pn(((e,o,i)=>qe(t.post(Te(Zt,n),{loginId:e,URI:o,user:i}))))})),{}),signUpOrIn:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:pn(((e,o)=>qe(t.post(Te(Yt,n),{loginId:e,URI:o}))))})),{}),update:{email:gn(((e,n,o,i)=>qe(t.post(Qt.email,{loginId:e,email:n,URI:o},{token:i})))),phone:Object.keys(Qe).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:fn(((e,o,i,r)=>qe(t.post(Te(Qt.phone,n),{loginId:e,phone:o,URI:i},{token:r}))))})),{})}});var bn;!function(t){t.facebook="facebook",t.github="github",t.google="google",t.microsoft="microsoft",t.gitlab="gitlab",t.apple="apple",t.discord="discord",t.linkedin="linkedin"}(bn||(bn={}));const mn=He(Be("code")),yn=t=>({start:Object.keys(bn).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:async(e,{redirect:o=!1}={},i,r)=>{const s=await t.post(re,i||{},{queryParams:Object.assign({provider:n},e&&{redirectURL:e}),token:r});if(!o||!s.ok)return qe(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a}})),{}),exchange:mn((e=>qe(t.post(se,{code:e}))))});var wn;!function(t){t.signUp="signup",t.signIn="signin",t.verify="verify",t.updatePhone="updatePhone"}(wn||(wn={}));const kn=Be("loginId"),In=He(kn,Be("code")),On=He(kn),jn=He(kn,ze("phone")),Sn=He(kn,Ve("email")),En=t=>({verify:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:In(((e,o)=>qe(t.post(Te(Ft,n),{code:o,loginId:e}))))})),{}),signIn:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o,i)=>qe(t.post(Te(Wt,n),{loginId:e,loginOptions:o},{token:i}))))})),{}),signUp:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On(((e,o)=>qe(t.post(Te(Ht,n),{loginId:e,user:o}))))})),{}),signUpOrIn:Object.keys(Ye).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:On((e=>qe(t.post(Te(Vt,n),{loginId:e}))))})),{}),update:{email:Sn(((e,n,o)=>qe(t.post(Bt.email,{loginId:e,email:n},{token:o})))),phone:Object.keys(Qe).reduce(((e,n)=>Object.assign(Object.assign({},e),{[n]:jn(((e,o,i)=>qe(t.post(Te(Bt.phone,n),{loginId:e,phone:o},{token:i}))))})),{})}}),xn=He(Be("tenant")),Cn=He(Be("code")),_n=t=>({start:xn((async(e,n,{redirect:o=!1}={},i,r)=>{const s=await t.post(ae,i||{},{queryParams:{tenant:e,redirectURL:n},token:r});if(!o||!s.ok)return qe(Promise.resolve(s));const{url:a}=await s.json();window.location.href=a})),exchange:Cn((e=>qe(t.post(le,{code:e}))))}),An=Be("loginId"),Un=He(An,Be("code")),Pn=He(An),Rn=He(An),Tn=t=>({signUp:Pn(((e,n)=>qe(t.post(ue,{loginId:e,user:n})))),verify:Un(((e,n,o,i)=>qe(t.post(ce,{loginId:e,code:n,loginOptions:o},{token:i})))),update:Rn(((e,n)=>qe(t.post(de,{loginId:e},{token:n}))))}),qn=[We('"loginId" must be a string')],Dn=Be("loginId"),Mn=Be("origin"),$n=He(Dn,Mn,Be("name")),Ln=He(Dn,Mn),Nn=He(qn,Mn),Kn=He(Dn,Mn,Be("token")),Jn=He(Be("transactionId"),Be("response")),Fn=t=>({signUp:{start:$n(((e,n,o)=>qe(t.post(he.start,{user:{loginId:e,name:o},origin:n})))),finish:Jn(((e,n)=>qe(t.post(he.finish,{transactionId:e,response:n}))))},signIn:{start:Nn(((e,n,o,i)=>qe(t.post(pe.start,{loginId:e,origin:n,loginOptions:o},{token:i})))),finish:Jn(((e,n)=>qe(t.post(pe.finish,{transactionId:e,response:n}))))},signUpOrIn:{start:Ln(((e,n)=>qe(t.post(fe.start,{loginId:e,origin:n}))))},update:{start:Kn(((e,n,o)=>qe(t.post(ge.start,{loginId:e,origin:n},{token:o})))),finish:Jn(((e,n)=>qe(t.post(ge.finish,{transactionId:e,response:n}))))}}),Wn=He(Be("token"));var Hn,Bn=He([("projectId",Hn=Be("projectId"),De(((t,e)=>n=>Me(...e).validate(Kt(n,t)))("projectId",Hn))())])((t=>{var e,n;const o=[].concat((null===(e=t.hooks)||void 0===e?void 0:e.beforeRequest)||[]),i=[].concat((null===(n=t.hooks)||void 0===n?void 0:n.afterRequest)||[]);return(({projectId:t,logger:e,baseUrl:n,hooks:o,cookiePolicy:i,baseHeaders:r={},fetch:s})=>{return a=xe({baseUrl:n||"https://api.descope.com",projectId:t,logger:e,hooks:o,cookiePolicy:i,baseConfig:{baseHeaders:r},fetch:s}),{accessKey:Ze(a),otp:En(a),magicLink:vn(a),enchantedLink:an(a),oauth:yn(a),saml:_n(a),totp:Tn(a),webauthn:Fn(a),flow:un(a),refresh:t=>qe(a.post(ve,{},{token:t})),logout:t=>qe(a.post(be,{},{token:t})),logoutAll:t=>qe(a.post(me,{},{token:t})),me:t=>qe(a.get(ye,{token:t})),isJwtExpired:Wn(Ue),getJwtPermissions:Wn(Pe),getJwtRoles:Wn(Re),httpClient:a};var a})(Object.assign(Object.assign({},t),{hooks:{beforeRequest:t=>null==o?void 0:o.reduce(((t,e)=>e(t)),t),afterRequest:async(e,n)=>{(await Promise.allSettled(null==i?void 0:i.map((t=>t(e,null==n?void 0:n.clone()))))).forEach((e=>{var n;return"rejected"===e.status&&(null===(n=t.logger)||void 0===n?void 0:n.error(e.reason))}))}}}))}));const Vn=(t,e,n)=>(e.forEach((e=>{const o=e.split(".");let i=o.shift(),r=t;for(;o.length>0;){if(r=r[i],!i||!r)throw Error(`Invalid path "${e}", "${i}" is missing or has no value`);i=o.shift()}if("function"!=typeof r[i])throw Error(`"${e}" is not a function`);const s=r[i];r[i]=n(s)})),t);var zn=Object.assign(Bn,{DeliveryMethods:Ye});var Gn="Blocked by CSP",Zn="API key required",Qn="3.8.2",Yn="9319";function Xn(t,e){var n=[];return function(t,e){var n,o,i=(o=function(t,e,n){if(n||2===arguments.length)for(var o,i=0,r=e.length;i<r;i++)!o&&i in e||(o||(o=Array.prototype.slice.call(e,0,i)),o[i]=e[i]);return t.concat(o||Array.prototype.slice.call(e))}([],t,!0),{current:function(){return o[0]},postpone:function(){var t=o.shift();void 0!==t&&o.push(t)},exclude:function(){o.shift()}}),r=(100,3e3,n=0,function(){return Math.random()*Math.min(3e3,100*Math.pow(2,n++))}),s=i.current();if(void 0===s)return Promise.reject(new TypeError("The list of script URL patterns is empty"));var a=function(t,n){return e(t).catch((function(t){if(n+1>=5)throw t;!function(t){if(!(t instanceof Error))return!1;var e=t.message;return e===Gn||e===Yn}(t)?i.postpone():i.exclude();var e,o=i.current();if(void 0===o)throw t;return(e=r(),new Promise((function(t){return setTimeout(t,e)}))).then((function(){return a(o,n+1)}))}))};return a(s,0)}(t,(function(t){var o=new Date,i=function(){return n.push({url:t,startedAt:o,finishedAt:new Date})},r=e(t);return r.then(i,i),r})).then((function(t){return[t,{attempts:n}]}))}var to="https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js",eo="Failed to load the JS script of the agent";function no(n){var o;n.scriptUrlPattern;var i=n.token,r=n.apiKey,s=void 0===r?i:r,a=e(n,["scriptUrlPattern","token","apiKey"]),l=null!==(o=function(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)?t[e]:void 0}(n,"scriptUrlPattern"))&&void 0!==o?o:to;return Promise.resolve().then((function(){if(!s||"string"!=typeof s)throw new Error(Zn);var t=function(t,e){return(Array.isArray(t)?t:[t]).map((function(t){return function(t,e){var n=encodeURIComponent;return t.replace(/<[^<>]+>/g,(function(t){return"<version>"===t?"3":"<apiKey>"===t?n(e):"<loaderVersion>"===t?n(Qn):t}))}(String(t),e)}))}(l,s);return Xn(t,oo).catch(ro)})).then((function(e){var n=e[0],o=e[1];return n.load(t(t({},a),{ldi:o}))}))}function oo(t){return function(t,e,n,o){var i,r=document,s="securitypolicyviolation",a=function(e){var n=new URL(t,location.href),o=e.blockedURI;o!==n.href&&o!==n.protocol.slice(0,-1)&&o!==n.origin||(i=e,l())};r.addEventListener(s,a);var l=function(){return r.removeEventListener(s,a)};return Promise.resolve().then(e).then((function(t){return l(),t}),(function(t){return new Promise((function(t){return setTimeout(t)})).then((function(){if(l(),i)return function(){throw new Error(Gn)}();throw t}))}))}(t,(function(){return function(t){return new Promise((function(e,n){var o=document.createElement("script"),i=function(){var t;return null===(t=o.parentNode)||void 0===t?void 0:t.removeChild(o)},r=document.head||document.getElementsByTagName("head")[0];o.onload=function(){i(),e()},o.onerror=function(){i(),n(new Error(eo))},o.async=!0,o.src=t,r.appendChild(o)}))}(t)})).then(io)}function io(){var t=window,e="__fpjs_p_l_b",n=t[e];if(function(t,e){var n,o=null===(n=Object.getOwnPropertyDescriptor)||void 0===n?void 0:n.call(Object,t,e);(null==o?void 0:o.configurable)?delete t[e]:o&&!o.writable||(t[e]=void 0)}(t,e),"function"!=typeof(null==n?void 0:n.load))throw new Error(Yn);return n}function ro(t){throw t instanceof Error&&t.message===Yn?new Error(eo):t}
|
|
2
|
-
/*! js-cookie v3.0.1 | MIT */function so(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)t[o]=n[o]}return t}var ao=function t(e,n){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=so({},n,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var r="";for(var s in i)i[s]&&(r+="; "+s,!0!==i[s]&&(r+="="+i[s].split(";")[0]));return document.cookie=t+"="+e.write(o,t)+r}}return Object.create({set:o,get:function(t){if("undefined"!=typeof document&&(!arguments.length||t)){for(var n=document.cookie?document.cookie.split("; "):[],o={},i=0;i<n.length;i++){var r=n[i].split("="),s=r.slice(1).join("=");try{var a=decodeURIComponent(r[0]);if(o[a]=e.read(s,a),t===a)break}catch(t){}}return t?o[t]:o}},remove:function(t,e){o(t,"",so({},e,{expires:-1}))},withAttributes:function(e){return t(this.converter,so({},this.attributes,e))},withConverter:function(e){return t(so({},this.converter,e),this.attributes)}},{attributes:{value:Object.freeze(n)},converter:{value:Object.freeze(e)}})}({read:function(t){return'"'===t[0]&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});const lo=(t,e)=>{var n;return["beforeRequest","afterRequest"].reduce(((n,o)=>{var i;return n[o]=[].concat((null===(i=t.hooks)||void 0===i?void 0:i[o])||[]).concat((null==e?void 0:e[o])||[]),n}),null!==(n=t.hooks)&&void 0!==n?n:t.hooks={}),t},co=async t=>{if(!(null==t?void 0:t.ok))return{};const e=await(null==t?void 0:t.clone().json());return(null==e?void 0:e.authInfo)||e||{}},uo=async t=>{const e=await co(t);return(null==e?void 0:e.user)||((null==e?void 0:e.hasOwnProperty("userId"))?e:void 0)},ho="undefined"!=typeof localStorage,po=(t,e)=>ho&&(null===localStorage||void 0===localStorage?void 0:localStorage.setItem(t,e)),fo=t=>ho&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem(t)),go=t=>ho&&(null===localStorage||void 0===localStorage?void 0:localStorage.removeItem(t)),vo="undefined"!=typeof window,bo=vo&&(null===localStorage||void 0===localStorage?void 0:localStorage.getItem("fingerprint.endpoint.url"))||"https://fp.descope.com",mo=(t="",e="")=>({vsid:t,vrid:e}),yo=(t=!1)=>{const e=localStorage.getItem("fp");if(!e)return null;const n=JSON.parse(e);return(new Date).getTime()>n.expiry&&!t?null:n.value},wo=t=>(t.body&&(t.body.fpData=yo(!0)||mo()),t),ko=()=>fo("dls_last_user_login_id"),Io=()=>fo("dls_last_user_display_name"),Oo=t=>async(...e)=>{var n;e[1]=e[1]||{};const[,o={}]=e,i=ko(),r=Io();return i&&(null!==(n=o.lastAuth)&&void 0!==n||(o.lastAuth={}),o.lastAuth.loginId=i,o.lastAuth.name=r),await t(...e)},jo=t=>async(...e)=>{const n=await t(...e);return go("dls_last_user_login_id"),go("dls_last_user_display_name"),n};function So(){const t=[];return{pub:e=>{t.forEach((t=>t(e)))},sub:e=>{const n=t.push(e)-1;return()=>t.splice(n,1)}}}const Eo=(t={},n)=>{var{refreshJwt:o,sessionJwt:i}=t,r=e(t,["refreshJwt","sessionJwt"]);void 0===n&&(n=!1),o&&po("DSR",o),i&&(n?function(t,e,{cookiePath:n,cookieDomain:o,cookieExpiration:i}){if(e){const r=new Date(1e3*i);ao.set(t,e,{path:n,domain:o,expires:r,sameSite:"Strict",secure:!0})}}("DS",i,r):po("DS",i))};function xo(){return fo("DSR")||""}function Co(){return ao.get("DS")||fo("DS")||""}function _o(){go("DSR"),go("DS"),ao.remove("DS")}const Ao=t=>Object.assign(t,{token:t.token||xo()}),Uo=t=>async(...e)=>{const n=await t(...e);return _o(),n};async function Po(t){const e=function(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=$o(n.publicKey.challenge),n.publicKey.user.id=$o(n.publicKey.user.id),null===(e=n.publicKey.excludeCredentials)||void 0===e||e.forEach((t=>{t.id=$o(t.id)})),n}(t);return n=await navigator.credentials.create(e),JSON.stringify({id:n.id,rawId:Lo(n.rawId),type:n.type,response:{attestationObject:Lo(n.response.attestationObject),clientDataJSON:Lo(n.response.clientDataJSON)}});var n}async function Ro(t){const e=Do(t);return Mo(await navigator.credentials.get(e))}async function To(t,e){const n=Do(t);return n.signal=e.signal,n.mediation="conditional",Mo(await navigator.credentials.get(n))}async function qo(t=!1){if(!vo)return Promise.resolve(!1);const e=!!(PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get);return e&&t&&PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable():e}function Do(t){var e;const n=JSON.parse(t);return n.publicKey.challenge=$o(n.publicKey.challenge),null===(e=n.publicKey.allowCredentials)||void 0===e||e.forEach((t=>{t.id=$o(t.id)})),n}function Mo(t){return JSON.stringify({id:t.id,rawId:Lo(t.rawId),type:t.type,response:{authenticatorData:Lo(t.response.authenticatorData),clientDataJSON:Lo(t.response.clientDataJSON),signature:Lo(t.response.signature),userHandle:t.response.userHandle?Lo(t.response.userHandle):void 0}})}function $o(t){const e=t.replace(/_/g,"/").replace(/-/g,"+");return Uint8Array.from(atob(e),(t=>t.charCodeAt(0))).buffer}function Lo(t){return btoa(String.fromCharCode.apply(null,new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}var No,Ko=(No=t=>({async signUp(e,n){const o=await t.webauthn.signUp.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Po(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,i)},async signIn(e){const n=await t.webauthn.signIn.start(e,window.location.origin);if(!n.ok)return n;const o=await Ro(n.data.options);return await t.webauthn.signIn.finish(n.data.transactionId,o)},async signUpOrIn(e){var n;const o=await t.webauthn.signUpOrIn.start(e,window.location.origin);if(!o.ok)return o;if(null===(n=o.data)||void 0===n?void 0:n.create){const e=await Po(o.data.options);return await t.webauthn.signUp.finish(o.data.transactionId,e)}{const e=await Ro(o.data.options);return await t.webauthn.signIn.finish(o.data.transactionId,e)}},async update(e,n){const o=await t.webauthn.update.start(e,window.location.origin,n);if(!o.ok)return o;const i=await Po(o.data.options);return await t.webauthn.update.finish(o.data.transactionId,i)},helpers:{create:Po,get:Ro,isSupported:qo,conditional:To}}),(...t)=>{const e=No(...t);return Object.assign(e.signUp,t[0].webauthn.signUp),Object.assign(e.signIn,t[0].webauthn.signIn),Object.assign(e.signUpOrIn,t[0].webauthn.signUpOrIn),Object.assign(e.update,t[0].webauthn.update),e}),Jo=t=>Object.assign(Object.assign({},t.flow),{start:async(...e)=>{const n=await qo(),o=Object.assign(Object.assign({redirectUrl:window.location.href},e[1]),{deviceInfo:{webAuthnSupport:n}});return e[1]=o,t.flow.start(...e)}});const Fo=function(...t){return e=>t.reduce(((t,e)=>e(t)),e)}((t=>n=>{var{fpKey:o,fpLoad:i}=n,r=e(n,["fpKey","fpLoad"]);return o?(vo?i&&(async t=>{try{if(yo())return;const e=(Date.now().toString(36)+Math.random().toString(36).substring(2)+Math.random().toString(36).substring(2)).substring(0,27),n=no({apiKey:t,endpoint:bo}),o=await n,{requestId:i}=await o.get({linkedId:e});(t=>{const e={value:t,expiry:(new Date).getTime()+864e5};localStorage.setItem("fp",JSON.stringify(e))})(mo(e,i))}catch(t){global.FB_DEBUG&&console.error(t)}})(o).catch((()=>null)):console.warn("Fingerprint is a client side only capability and will not work when running in the server"),t(lo(r,{beforeRequest:wo}))):t(Object.assign({},r))}),(t=>n=>{var o=e(n,["autoRefresh"]);const{clearAllTimers:i,setTimer:r}=(()=>{const t=[];return{clearAllTimers:()=>{for(;t.length;)clearTimeout(t.pop())},setTimer:(e,n)=>{t.push(setTimeout(e,n))}}})(),s=t(lo(o,{afterRequest:async(t,e)=>{const{refreshJwt:n,sessionJwt:o}=await co(e);if(401===(null==e?void 0:e.status))i();else if(o){const t=((a=(t=>{const e=t.split(".");try{if(3===e.length){const t=JSON.parse(window.atob(e[1]));if(t.exp)return new Date(1e3*t.exp)}}catch(t){}return null})(o))?a.getTime()-(new Date).getTime():0)-2e4;i(),r((()=>s.refresh(n)),t)}var a}}));return Vn(s,["logout","logoutAll"],(t=>async(...e)=>{const n=await t(...e);return i(),n}))}),(t=>e=>t(Object.assign(Object.assign({},e),{baseHeaders:Object.assign({"x-descope-sdk-name":"web-js","x-descope-sdk-version":"1.0.0"},e.baseHeaders)}))),(t=>e=>{const n=So(),o=So(),i=t(lo(e,{afterRequest:async(t,e)=>{if(401===(null==e?void 0:e.status))n.pub(null),o.pub(null);else{const t=await uo(e);t&&o.pub(t);const{sessionJwt:i}=await co(e);i&&n.pub(i)}}})),r=Vn(i,["logout","logoutAll"],(t=>async(...e)=>{const i=await t(...e);return n.pub(null),o.pub(null),i}));return Object.assign(r,{onSessionTokenChange:n.sub,onUserChange:o.sub})}),(t=>e=>{const n=t(lo(e,{afterRequest:async(t,e)=>{var n;const o=await uo(e),i=null===(n=null==o?void 0:o.loginIds)||void 0===n?void 0:n[0],r=null==o?void 0:o.name;i&&((t=>{po("dls_last_user_login_id",t)})(i),(t=>{po("dls_last_user_display_name",t)})(r))}}));let o=Vn(n,["flow.start"],Oo);return o=Vn(o,["logout","logoutAll"],jo),Object.assign(o,{getLastUserLoginId:ko,getLastUserDisplayName:Io})}),(t=>n=>{var{persistTokens:o,sessionTokenViaCookie:i}=n,r=e(n,["persistTokens","sessionTokenViaCookie"]);if(!o||!vo)return o&&console.warn("Storing auth tokens in local storage and cookies are a client side only capabilities and will not be done when running in the server"),t(r);const s=t(lo(r,{beforeRequest:Ao,afterRequest:async(t,e)=>{401===(null==e?void 0:e.status)?_o():Eo(await co(e),i)}})),a=Vn(s,["logout","logoutAll"],Uo);return Object.assign(a,{getRefreshToken:xo,getSessionToken:Co})}))(((...t)=>{const e=zn(...t);return Object.assign(Object.assign({},e),{flow:Jo(e),webauthn:Ko(e)})})),Wo=document.createElement("template");var Ho,Bo,Vo,zo,Go,Zo,Qo,Yo,Xo,ti,ei,ni,oi,ii,ri,si,ai,li,ci,ui,di,hi,pi,fi,gi,vi,bi,mi,yi,wi,ki,Ii,Oi,ji,Si,Ei,xi,Ci;Wo.innerHTML='\n\t<style>\n\t\t:host {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\t\t\n\t\t#wc-root {\n\t\t\theight: 100%;\n\t\t\ttransition: opacity 300ms ease-in-out;\n\t\t}\n\n\t\t#wc-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\t</style>\n\t<div id="wc-root"></div>\n\t';class _i extends HTMLElement{constructor(t){super(),Ho.add(this),Bo.set(this,!1),Vo.set(this,new K),zo.set(this,new K),this.nextRequestStatus=new K({isLoading:!1}),Go.set(this,void 0),Zo.set(this,{popstate:o(this,Ho,"m",ni).bind(this)}),Qo.set(this,void 0),ri.set(this,T((()=>n(this,void 0,void 0,(function*(){const t=C(this.projectId,"config.json");try{const{body:e,headers:n}=yield E(t,"json");return{projectConfig:e,executionContext:{geo:n["x-geo"]}}}catch(t){this.logger.error("Cannot get config file","make sure that your projectId & flowId are correct")}}))))),this.logger={error:(t,e="")=>{console.error(t,e,new Error),o(this,Ho,"m",hi).call(this,t,e)},info:(t,e="")=>{console.log(t,e)}},i(this,Qo,t,"f"),o(this,Ho,"m",Yo).call(this)}static get observedAttributes(){return["project-id","flow-id","base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"]}get projectId(){return this.getAttribute("project-id")}get flowId(){return this.getAttribute("flow-id")}get baseUrl(){return this.getAttribute("base-url")||void 0}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 theme(){var t,e;const n=this.getAttribute("theme");if("os"===n){return window.matchMedia&&(null===(e=null===(t=window.matchMedia)||void 0===t?void 0:t.call(window,"(prefers-color-scheme: dark)"))||void 0===e?void 0:e.matches)?"dark":"light"}return n||"light"}get telemetryKey(){return this.getAttribute("telemetryKey")||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}getExecutionContext(){return n(this,void 0,void 0,(function*(){const{executionContext:t}=yield o(this,ri,"f").call(this);return t}))}getFlowConfig(){var t;return n(this,void 0,void 0,(function*(){const{projectConfig:e}=yield o(this,ri,"f").call(this);return(null===(t=null==e?void 0:e.flows)||void 0===t?void 0:t[this.flowId])||{}}))}connectedCallback(){return n(this,void 0,void 0,(function*(){if(this.shadowRoot.isConnected){if(o(this,Ho,"m",Xo).call(this))return void o(this,Ho,"m",ti).call(this);o(this,Ho,"m",ei).call(this),o(this,Ho,"m",ai).call(this),o(this,Ho,"m",si).call(this),o(this,Ho,"m",pi).call(this);const{executionId:t,stepId:e,token:n,code:r,exchangeError:s}=R();window.addEventListener("popstate",o(this,Zo,"f").popstate),o(this,Vo,"f").subscribe(o(this,Ho,"m",ii).bind(this)),o(this,zo,"f").subscribe(o(this,Ho,"m",di).bind(this)),o(this,Vo,"f").update({projectId:this.projectId,flowId:this.flowId,baseUrl:this.baseUrl,tenant:this.tenant,redirectUrl:this.redirectUrl,stepId:e,executionId:t,token:n,code:r,exchangeError:s,telemetryKey:this.telemetryKey}),o(this,zo,"f").update({isDebug:this.debug}),i(this,Bo,!0,"f")}}))}disconnectedCallback(){o(this,Vo,"f").unsubscribeAll(),o(this,zo,"f").unsubscribeAll(),o(this,Ho,"m",ui).call(this),window.removeEventListener("popstate",o(this,Zo,"f").popstate)}attributeChangedCallback(t,e,n){if(this.shadowRoot.isConnected&&o(this,Bo,"f")&&e!==n&&_i.observedAttributes.includes(t)){o(this,Ho,"m",ei).call(this);const i=null===e;o(this,Vo,"f").update((({stepId:e,executionId:o})=>{let r=e,s=o;return i||(s=null,r=null,U()),{[P(t)]:n,stepId:r,executionId:s}})),o(this,zo,"f").update({isDebug:this.debug})}}}Bo=new WeakMap,Vo=new WeakMap,zo=new WeakMap,Go=new WeakMap,Zo=new WeakMap,Qo=new WeakMap,ri=new WeakMap,Ho=new WeakSet,Yo=function(){this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wo.content.cloneNode(!0)),this.rootElement=this.shadowRoot.querySelector("#wc-root")},Xo=function(){const t=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);return!this.shadowRoot.host.closest("form")&&t},ti=function(){const t=this.shadowRoot.host,e=document.createElement("form");t.parentElement.appendChild(e),e.appendChild(t)},ei=function(){const t=["base-url","tenant","theme","debug","telemetryKey","redirect-url","auto-focus"];if(_i.observedAttributes.forEach((e=>{if(!t.includes(e)&&!this[P(e)])throw Error(`${e} cannot be empty`)})),this.theme&&"light"!==this.theme&&"dark"!==this.theme)throw Error('Supported theme values are "light", "dark", or leave empty for using the OS theme')},ni=function(){const{stepId:t,executionId:e}=A();o(this,Vo,"f").update({stepId:t,executionId:e})},oi=function(t,e,o){const i=o||void 0,r=!!i;this.sdk=Fo(Object.assign(Object.assign({persistTokens:!0},_i.sdkConfigOverrides),{projectId:t,baseUrl:e,fpKey:i,fpLoad:r})),["start","next"].forEach((t=>{const e=this.sdk.flow[t];this.sdk.flow[t]=(...t)=>n(this,void 0,void 0,(function*(){this.nextRequestStatus.update({isLoading:!0});try{return yield e(...t)}finally{this.nextRequestStatus.update({isLoading:!1})}}))}))},ii=function(t,e,i){return n(this,void 0,void 0,(function*(){const{projectId:e,baseUrl:n,telemetryKey:r}=t;if(i("projectId")||i("baseUrl")||i("telemetryKey")){if(!e)return;o(this,Ho,"m",oi).call(this,e,n,r)}o(this,Qo,"f").call(this,t)}))},si=function(){var t,e,i,r;return n(this,void 0,void 0,(function*(){const{projectConfig:n}=yield o(this,ri,"f").call(this);null===(r=null===(i=null===(e=null===(t=null==n?void 0:n.cssTemplate)||void 0===t?void 0:t[this.theme])||void 0===e?void 0:e.typography)||void 0===i?void 0:i.fontFamilies)||void 0===r||r.forEach((t=>(t=>{if(!t)return;const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)})(t.url)))}))},ai=function(){o(this,Ho,"m",li).call(this),o(this,Ho,"m",ci).call(this)},li=function(){return n(this,void 0,void 0,(function*(){const t=document.createElement("style"),e=C(this.projectId,"theme.css");try{const{body:n}=yield E(e,"text");t.innerText=n}catch(t){this.logger.error("Cannot fetch theme file","make sure that your projectId & flowId are correct")}this.shadowRoot.appendChild(t)}))},ci=function(){this.rootElement.setAttribute("data-theme",this.theme)},ui=function(){var t;null===(t=o(this,Go,"f"))||void 0===t||t.remove(),i(this,Go,null,"f")},di=function({isDebug:t}){return n(this,void 0,void 0,(function*(){t?(yield import("./debugger-wc-7607ab6e.js"),i(this,Go,document.createElement("descope-debugger"),"f"),Object.assign(o(this,Go,"f").style,{position:"fixed",top:"0",right:"0",height:"100vh",width:"100vw",pointerEvents:"none",zIndex:99999}),document.body.appendChild(o(this,Go,"f"))):o(this,Ho,"m",ui).call(this)}))},hi=function(t,e){var n;t&&this.debug&&(null===(n=o(this,Go,"f"))||void 0===n||n.updateData({title:t,description:e}))},pi=function(){this.rootElement.onkeydown=t=>{if("Enter"!==t.key)return;t.preventDefault();const e=this.rootElement.querySelectorAll("button");if(1===e.length)return void e[0].click();const n=Array.from(e).filter((t=>"button"===t.getAttribute("data-type")));1===n.length&&n[0].click()}},_i.sdkConfigOverrides={baseHeaders:{"x-descope-sdk-name":"web-component","x-descope-sdk-version":"2.0.5"}};class Ai extends _i{constructor(){const t=new K;super(t.update.bind(t)),fi.add(this),this.stepState=new K({},{updateOnlyOnChange:!1}),gi.set(this,void 0),vi.set(this,null),bi.set(this,(()=>{clearInterval(o(this,gi,"f")),i(this,gi,null,"f")})),mi.set(this,(t=>{var e,n,i,s,a,l,c,u,d;if(!(null==t?void 0:t.ok)){o(this,bi,"f").call(this),o(this,fi,"m",Ci).call(this,"error",null==t?void 0:t.error);const r=null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.url,l=`${null===(n=null==t?void 0:t.response)||void 0===n?void 0:n.status} - ${null===(i=null==t?void 0:t.response)||void 0===i?void 0:i.statusText}`;return void this.logger.error((null===(s=null==t?void 0:t.error)||void 0===s?void 0:s.errorDescription)||r,(null===(a=null==t?void 0:t.error)||void 0===a?void 0:a.errorMessage)||l)}const p=null===(u=null===(c=null===(l=t.data)||void 0===l?void 0:l.screen)||void 0===c?void 0:c.state)||void 0===u?void 0:u.errorText;p&&this.logger.error(p),(null===(d=t.data)||void 0===d?void 0:d.error)&&this.logger.error(`[${t.data.error.code}]: ${t.data.error.description}`,t.data.error.message);const{status:f,authInfo:v,lastAuth:b}=t.data;if("completed"===f)return function(t){(null==t?void 0:t.authMethod)&&r&&localStorage.setItem(h,JSON.stringify(t))}(b),o(this,bi,"f").call(this),void o(this,fi,"m",Ci).call(this,"success",v);const{executionId:m,stepId:y,action:w,screen:k,redirect:I,webauthn:O}=t.data;w!==g?this.flowState.update({stepId:y,executionId:m,action:w,redirectTo:null==I?void 0:I.url,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}):this.flowState.update({action:w})})),yi.set(this,T((()=>n(this,void 0,void 0,(function*(){var t;try{const e=yield this.sdk.webauthn.signIn.start("",window.location.origin);return e.ok||this.logger.error("Webauthn start failed",null===(t=null==e?void 0:e.error)||void 0===t?void 0:t.errorMessage),e.data}catch(t){this.logger.error("Webauthn start failed",t.message)}}))))),this.flowState=t}static set sdkConfigOverrides(t){_i.sdkConfigOverrides=t}connectedCallback(){const t=Object.create(null,{connectedCallback:{get:()=>super.connectedCallback}});var e,o;return n(this,void 0,void 0,(function*(){this.shadowRoot.isConnected&&(null===(e=this.flowState)||void 0===e||e.subscribe(this.onFlowChange.bind(this)),null===(o=this.stepState)||void 0===o||o.subscribe(this.onStepChange.bind(this))),yield t.connectedCallback.call(this)}))}disconnectedCallback(){super.disconnectedCallback(),this.flowState.unsubscribeAll(),this.stepState.unsubscribeAll()}onFlowChange(t,e,r){var s,a;return n(this,void 0,void 0,(function*(){const{projectId:l,flowId:c,tenant:u,stepId:d,executionId:p,action:m,screenId:k,screenState:I,redirectTo:O,redirectUrl:j,token:S,code:E,exchangeError:x,webauthnTransactionId:A,webauthnOptions:U}=t;let P,R;o(this,gi,"f")&&o(this,bi,"f").call(this);const T=this.sdk.getLastUserLoginId();if(!p){if(!c)return;const t=yield this.getFlowConfig();if(({startScreenId:P=t.startScreenId,conditionInteractionId:R}=((t,e)=>{var n;const o=null===(n=W[null==t?void 0:t.key])||void 0===n?void 0:n[t.operator];if(!o)return{};const i=o(e)?t.met:t.unmet;return{startScreenId:null==i?void 0:i.screenId,conditionInteractionId:null==i?void 0:i.interactionId}})(t.condition,{loginId:T,code:E})),!P){const t=E?{exchangeCode:E,idpInitiated:!0}:void 0,e=yield this.sdk.flow.start(c,Object.assign({tenant:u},j&&{redirectUrl:j}),R,"",t);return o(this,mi,"f").call(this,e),void("completed"!==(null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.status)&&this.flowState.update({code:void 0}))}}if(p&&(r("token")&&S||r("code")&&E||r("exchangeError")&&x)){const t=yield this.sdk.flow.next(p,d,y,{token:S,exchangeCode:E,exchangeError:x});return o(this,mi,"f").call(this,t),void this.flowState.update({token:void 0,code:void 0,exchangeError:void 0})}if(m===f)return O||this.logger.error("Did not get redirect url"),void window.location.assign(O);if(m===v||m===b){if(!A||!U)return void this.logger.error("Did not get webauthn transaction id or options");let t,e;null===(a=o(this,vi,"f"))||void 0===a||a.abort(),i(this,vi,null,"f");try{t=m===v?yield this.sdk.webauthn.helpers.create(U):yield this.sdk.webauthn.helpers.get(U)}catch(t){if("NotAllowedError"!==t.name)return void this.logger.error(t.message);e=!0}const n=yield this.sdk.flow.next(p,d,y,{transactionId:A,response:t,cancelWebauthn:e});o(this,mi,"f").call(this,n)}if(m===g&&i(this,gi,setInterval((()=>n(this,void 0,void 0,(function*(){const t=yield this.sdk.flow.next(p,d,w,{});o(this,mi,"f").call(this,t)}))),2e3),"f"),!k&&!P)return void this.logger.info("Refreshing the page during a flow is not supported yet");const q={direction:_(+d,+e.stepId),screenState:Object.assign(Object.assign({},I),{lastAuth:{loginId:T,name:this.sdk.getLastUserDisplayName()||T}}),htmlUrl:C(l,`${P||k}.html`)},D=function(t){const e={};if(t)try{Object.assign(e,JSON.parse(localStorage.getItem(h)))}catch(t){}return e}(T);P?q.next=(t,e)=>this.sdk.flow.start(c,Object.assign({tenant:u,lastAuth:D},j&&{redirectUrl:j}),R,t,Object.assign(Object.assign({},e),E&&{exchangeCode:E,idpInitiated:!0})):(r("projectId")||r("baseUrl")||r("executionId")||r("stepId"))&&(q.next=(...t)=>this.sdk.flow.next(p,d,...t)),this.stepState.update(q)}))}onStepChange(t,e){var i;return n(this,void 0,void 0,(function*(){const{htmlUrl:r,direction:s,next:a,screenState:l}=t,c=document.createElement("template"),{body:u}=yield E(r,"text");c.innerHTML=u;const d=c.content.cloneNode(!0),h=((t,e)=>{var n;const o=Array.from(t.querySelectorAll("script[data-id]")).map((n=>{var o;const i=n.getAttribute("data-id"),r=null===(o=t.getElementById(i))||void 0===o?void 0:o.innerHTML,s=Function(r).bind(n.previousSibling,e);return n.remove(),s}));return null===(n=t.querySelector("scripts"))||void 0===n||n.remove(),o})(d,yield this.getExecutionContext());this.sdk.webauthn.helpers.isSupported()?yield o(this,fi,"m",ki).call(this,d,a):d.querySelectorAll(`button[${p}="biometrics"]`).forEach((t=>t.setAttribute("disabled","true"))),J(d,l),((t,e)=>{var n;e&&(null===(n=null==t?void 0:t.style)||void 0===n||n.setProperty("--totp-image",`url(data:image/jpg;base64,${e})`))})(d.querySelector("div"),null===(i=null==l?void 0:l.totp)||void 0===i?void 0:i.image);const f=()=>n(this,void 0,void 0,(function*(){try{h.forEach((t=>{t()}))}catch(t){this.logger.error(t.message)}this.rootElement.replaceChildren(d);const t=!e.htmlUrl;((t,e,n)=>{if(!0===e||"skipFirstScreen"===e&&!n){const e=t.querySelector('input:not([aria-hidden="true"])');null==e||e.focus()}})(this.rootElement,this.autoFocus,t),o(this,fi,"m",Ei).call(this,a),o(this,fi,"m",Ci).call(this,"page-updated",{});if(this.rootElement.querySelector(`[${p}="polling"]`)){const t=yield a(w,{});o(this,mi,"f").call(this,t)}}));s?o(this,fi,"m",xi).call(this,f,s):f()}))}}gi=new WeakMap,vi=new WeakMap,bi=new WeakMap,mi=new WeakMap,yi=new WeakMap,fi=new WeakSet,wi=function(t){const e=t.name;if(!["email"].includes(e)){const n=`user-${e}`;t.name=n,t.addEventListener("input",(()=>{t.name=t.value?e:n}))}},ki=function(t,e){var r;return n(this,void 0,void 0,(function*(){null===(r=o(this,vi,"f"))||void 0===r||r.abort();const s=t.querySelector('input[autocomplete="webauthn"]');if(s&&(yield F())){const{options:t,transactionId:r}=(yield o(this,yi,"f").call(this))||{};t&&r&&(o(this,fi,"m",wi).call(this,s),i(this,vi,new AbortController,"f"),this.sdk.webauthn.helpers.conditional(t,o(this,vi,"f")).then((t=>n(this,void 0,void 0,(function*(){const n=yield e(s.id,{transactionId:r,response:t});o(this,mi,"f").call(this,n)})))).catch((t=>{"AbortError"!==t.name&&this.logger.error("Conditional login failed",t.message)})))}}))},Ii=function(){return Array.from(this.shadowRoot.querySelectorAll(".descope-input")).every((t=>(t.reportValidity(),t.checkValidity())))},Oi=function(){return Array.from(this.shadowRoot.querySelectorAll(`*[name]:not([${d}])`)).reduce(((t,e)=>e.name?Object.assign(t,{[e.name]:e.value}):t),{})},ji=function(t){const e=this.nextRequestStatus.subscribe((({isLoading:n})=>{var o,i;n?null===(o=null==t?void 0:t.classList)||void 0===o||o.add("loading"):(this.nextRequestStatus.unsubscribe(e),null===(i=null==t?void 0:t.classList)||void 0===i||i.remove("loading"))}))},Si=function(t,e){return n(this,void 0,void 0,(function*(){if(t.formNoValidate||o(this,fi,"m",Ii).call(this)){const i=null==t?void 0:t.getAttribute("id");o(this,fi,"m",ji).call(this,t);const r=o(this,fi,"m",Oi).call(this),s=(n=t,Array.from((null==n?void 0:n.attributes)||[]).reduce(((t,e)=>{var n;const o=null===(n=new RegExp("^data-descope-(\\S+)$").exec(e.name))||void 0===n?void 0:n[1];return o?Object.assign(t,{[o]:e.value}):t}),{})),a=Object.assign(Object.assign(Object.assign({},s),r),{origin:window.location.origin}),l=yield e(i,a);o(this,mi,"f").call(this,l)}var n}))},Ei=function(t){this.rootElement.querySelectorAll("button").forEach((e=>{e.onclick=()=>{o(this,fi,"m",Si).call(this,e,t)}}))},xi=function(t,e){this.rootElement.addEventListener("transitionend",(()=>{this.rootElement.classList.remove("fade-out"),t()}),{once:!0});const n=e===k.forward?"slide-forward":"slide-backward";Array.from(this.rootElement.getElementsByClassName("input-container")).forEach(((t,e)=>{t.style["transition-delay"]=40*e+"ms",t.classList.add(n)})),this.rootElement.classList.add("fade-out")},Ci=function(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))},customElements.define("descope-wc",Ai);export{Ai as D,K as S,o as _,i as a};
|
|
3
|
-
//# sourceMappingURL=index-d7eb861e.js.map
|