@klauswuestefeld/jux-web 2024.2.6 → 2024.2.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/dist/api-client.d.ts +6 -6
- package/dist/jux/jux-event.d.ts +10 -0
- package/dist/jux-web.js +492 -550
- package/dist/login/base-page.d.ts +1 -0
- package/dist/login/unauthorized-magic-link-request-page.d.ts +1 -0
- package/dist/main.d.ts +1 -1
- package/dist/main.esm.js +495 -554
- package/dist/main.js +495 -553
- package/package.json +1 -1
- package/dist/jux/query.d.ts +0 -1
package/dist/jux-web.js
CHANGED
|
@@ -1,37 +1,36 @@
|
|
|
1
1
|
var juxWeb = (function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const getBrowserLanguage = () => {
|
|
5
|
+
const result = (navigator.languages && navigator.languages.length)
|
|
6
6
|
? navigator.languages[0]
|
|
7
7
|
: navigator.userLanguage || navigator.language || navigator.browserLanguage || 'en';
|
|
8
8
|
return result.substring(0, 2);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const OVERRIDE_KEY = 'jux.language.override';
|
|
11
|
+
let translations = {};
|
|
12
|
+
const chosenLanguage = localStorage.getItem(OVERRIDE_KEY) || getBrowserLanguage();
|
|
13
|
+
const reloadWithLanguageOverride = (lang) => {
|
|
14
14
|
localStorage.setItem(OVERRIDE_KEY, lang);
|
|
15
15
|
location.reload();
|
|
16
16
|
};
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (defaultLanguage === void 0) { defaultLanguage = 'en'; }
|
|
18
|
+
const getTranslation = (k) => translations[k] || k;
|
|
19
|
+
const initLanguage = (translations_, defaultLanguage = 'en') => {
|
|
21
20
|
translations = translations_[chosenLanguage] || translations_[defaultLanguage];
|
|
22
21
|
document.title = getTranslation('title');
|
|
23
22
|
document.documentElement.lang = translations_[chosenLanguage] ? chosenLanguage : defaultLanguage;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
const THRESHOLD_WIDTH = 640;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
const icons = {
|
|
29
28
|
email: '<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 64.000000 48.000000" preserveAspectRatio="xMidYMid meet"> <g transform="translate(0.000000,48.000000) scale(0.100000,-0.100000)" fill="#000000" stroke="none"> <path d="M44 468 c-38 -18 -44 -51 -44 -228 0 -180 6 -210 47 -229 33 -15 513 -15 546 0 41 19 47 49 47 229 0 180 -6 210 -47 229 -31 14 -519 14 -549 -1z m516 -33 c0 -7 -232 -205 -240 -205 -8 0 -240 198 -240 205 0 3 108 5 240 5 132 0 240 -2 240 -5z m-406 -118 l59 -53 -87 -97 -86 -97 0 170 0 171 28 -20 c15 -11 54 -44 86 -74z m446 -77 l0 -170 -85 95 c-47 53 -85 98 -85 99 0 5 162 146 167 146 1 0 3 -77 3 -170z m-319 -31 l39 -31 40 32 39 31 33 -37 c18 -21 57 -65 87 -99 l53 -60 -126 -3 c-69 -1 -183 -1 -252 0 l-126 3 84 97 c46 53 85 97 87 97 2 1 21 -13 42 -30z"/> </g> </svg>',
|
|
30
29
|
google: '<svg viewBox="0 0 24 24" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(1, 0, 0, 1, 27.009001, -39.238998)"><path fill="#4285F4" d="M -3.264 51.509 C -3.264 50.719 -3.334 49.969 -3.454 49.239 L -14.754 49.239 L -14.754 53.749 L -8.284 53.749 C -8.574 55.229 -9.424 56.479 -10.684 57.329 L -10.684 60.329 L -6.824 60.329 C -4.564 58.239 -3.264 55.159 -3.264 51.509 Z"/><path fill="#34A853" d="M -14.754 63.239 C -11.514 63.239 -8.804 62.159 -6.824 60.329 L -10.684 57.329 C -11.764 58.049 -13.134 58.489 -14.754 58.489 C -17.884 58.489 -20.534 56.379 -21.484 53.529 L -25.464 53.529 L -25.464 56.619 C -23.494 60.539 -19.444 63.239 -14.754 63.239 Z"/><path fill="#FBBC05" d="M -21.484 53.529 C -21.734 52.809 -21.864 52.039 -21.864 51.239 C -21.864 50.439 -21.724 49.669 -21.484 48.949 L -21.484 45.859 L -25.464 45.859 C -26.284 47.479 -26.754 49.299 -26.754 51.239 C -26.754 53.179 -26.284 54.999 -25.464 56.619 L -21.484 53.529 Z"/><path fill="#EA4335" d="M -14.754 43.989 C -12.984 43.989 -11.404 44.599 -10.154 45.789 L -6.734 42.369 C -8.804 40.429 -11.514 39.239 -14.754 39.239 C -19.444 39.239 -23.494 41.939 -25.464 45.859 L -21.484 48.949 C -20.534 46.099 -17.884 43.989 -14.754 43.989 Z"/></g></svg>',
|
|
31
30
|
linkedin: '<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="100%" height="100%" viewBox="1.786 1.783 76.226652 76.248" version="1.1" id="svg72" sodipodi:docname="linkedin.svg" inkscape:version="0.92.4 (5da689c313, 2019-01-14)"> <metadata id="metadata78"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <defs id="defs76" /> <sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="1916" inkscape:window-height="1036" id="namedview74" showgrid="false" inkscape:zoom="0.79365665" inkscape:cx="428.70379" inkscape:cy="325.16058" inkscape:window-x="0" inkscape:window-y="20" inkscape:window-maximized="0" inkscape:current-layer="svg72" inkscape:pagecheckerboard="false" /> <path d="m 2.10821,7.2952417 c 0,-3.015 2.508,-5.462 5.6,-5.462 h 64.568 c 3.093,0 5.6,2.447 5.6,5.462 V 72.620242 c 0,3.016 -2.507,5.461 -5.6,5.461 h -64.568 c -3.092,0 -5.6,-2.445 -5.6,-5.46 V 7.2942417 Z" id="path64" inkscape:connector-curvature="0" style="fill:#0b78b7;fill-opacity:1" /> <path d="m 25.07621,65.660242 v -34.43 h -11.444 v 34.43 h 11.445 z m -5.72,-39.13 c 3.99,0 6.474,-2.644 6.474,-5.948 -0.075,-3.379 -2.484,-5.949 -6.398,-5.949 -3.917,0 -6.475,2.57 -6.475,5.949 0,3.304 2.483,5.948 6.324,5.948 h 0.074 z m 12.054,39.13 h 11.443 v -19.225 c 0,-1.028 0.075,-2.058 0.377,-2.792 0.827,-2.057 2.71,-4.186 5.872,-4.186 4.14,0 5.797,3.157 5.797,7.786 v 18.417 h 11.443 v -19.741 c 0,-10.575 -5.645,-15.496 -13.174,-15.496 -6.173,0 -8.884,3.45 -10.39,5.8 h 0.076 v -4.992 h -11.443 c 0.149,3.23 -0.001,34.43 -0.001,34.43 z" id="path70" inkscape:connector-curvature="0" style="fill:#ffffff" /> </svg>',
|
|
32
31
|
microsoft: '<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 21 21"><title>MS-SymbolLockup</title><rect x="1" y="1" width="9" height="9" fill="#f25022"/><rect x="1" y="11" width="9" height="9" fill="#00a4ef"/><rect x="11" y="1" width="9" height="9" fill="#7fba00"/><rect x="11" y="11" width="9" height="9" fill="#ffb900"/></svg>',
|
|
33
32
|
};
|
|
34
|
-
|
|
33
|
+
const applyComponentStyle = (component) => {
|
|
35
34
|
component.style.alignItems = 'center';
|
|
36
35
|
component.style.background = '#fff';
|
|
37
36
|
component.style.border = 'thin solid #888';
|
|
@@ -48,7 +47,7 @@ var juxWeb = (function (exports) {
|
|
|
48
47
|
component.style.width = '276px';
|
|
49
48
|
component.style.boxSizing = 'content-box';
|
|
50
49
|
};
|
|
51
|
-
|
|
50
|
+
const applyLabelStyle = (label) => {
|
|
52
51
|
label.style.display = 'inline-block';
|
|
53
52
|
label.style.fontSize = '14px';
|
|
54
53
|
label.style.fontWeight = '500';
|
|
@@ -56,13 +55,13 @@ var juxWeb = (function (exports) {
|
|
|
56
55
|
label.style.marginRight = '34px';
|
|
57
56
|
label.style.paddingLeft = '20px';
|
|
58
57
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const loginButton = (type, fn) => {
|
|
59
|
+
const loweredCasedType = type.toLowerCase();
|
|
60
|
+
const result = document.createElement('login-button');
|
|
62
61
|
applyComponentStyle(result);
|
|
63
62
|
result.tabIndex = 0;
|
|
64
|
-
result.setAttribute('data-cy',
|
|
65
|
-
|
|
63
|
+
result.setAttribute('data-cy', `${loweredCasedType}-button`);
|
|
64
|
+
const icon = document.createElement('login-icon');
|
|
66
65
|
icon.style.gridColumnStart = '2';
|
|
67
66
|
icon.style.width = '28px';
|
|
68
67
|
icon.style.height = '28px';
|
|
@@ -72,16 +71,16 @@ var juxWeb = (function (exports) {
|
|
|
72
71
|
icon.className = 'ico';
|
|
73
72
|
// @ts-ignore
|
|
74
73
|
icon.innerHTML = icons[loweredCasedType];
|
|
75
|
-
|
|
76
|
-
label.textContent = window.innerWidth <= THRESHOLD_WIDTH ? type : getTranslation(
|
|
74
|
+
const label = document.createElement('login-label');
|
|
75
|
+
label.textContent = window.innerWidth <= THRESHOLD_WIDTH ? type : getTranslation(`${loweredCasedType}-label`);
|
|
77
76
|
applyLabelStyle(label);
|
|
78
77
|
result.append(icon, label);
|
|
79
78
|
result.addEventListener('click', fn);
|
|
80
|
-
result.addEventListener('mouseenter',
|
|
79
|
+
result.addEventListener('mouseenter', () => {
|
|
81
80
|
result.style.cursor = 'pointer';
|
|
82
81
|
result.style.boxShadow = '0 0 6px #808080';
|
|
83
82
|
});
|
|
84
|
-
result.addEventListener('mouseleave',
|
|
83
|
+
result.addEventListener('mouseleave', () => {
|
|
85
84
|
result.style.cursor = 'auto';
|
|
86
85
|
result.style.boxShadow = '1px 1px 1px grey';
|
|
87
86
|
});
|
|
@@ -102,22 +101,6 @@ var juxWeb = (function (exports) {
|
|
|
102
101
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
103
102
|
PERFORMANCE OF THIS SOFTWARE.
|
|
104
103
|
***************************************************************************** */
|
|
105
|
-
/* global Reflect, Promise */
|
|
106
|
-
|
|
107
|
-
var extendStatics$2 = function(d, b) {
|
|
108
|
-
extendStatics$2 = Object.setPrototypeOf ||
|
|
109
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
110
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
111
|
-
return extendStatics$2(d, b);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
function __extends$2(d, b) {
|
|
115
|
-
if (typeof b !== "function" && b !== null)
|
|
116
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
117
|
-
extendStatics$2(d, b);
|
|
118
|
-
function __() { this.constructor = d; }
|
|
119
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
120
|
-
}
|
|
121
104
|
|
|
122
105
|
function __awaiter$2(thisArg, _arguments, P, generator) {
|
|
123
106
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -127,54 +110,25 @@ var juxWeb = (function (exports) {
|
|
|
127
110
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
128
111
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
129
112
|
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function __generator$2(thisArg, body) {
|
|
133
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
134
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
135
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
136
|
-
function step(op) {
|
|
137
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
138
|
-
while (_) try {
|
|
139
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
140
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
141
|
-
switch (op[0]) {
|
|
142
|
-
case 0: case 1: t = op; break;
|
|
143
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
144
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
145
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
146
|
-
default:
|
|
147
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
148
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
149
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
150
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
151
|
-
if (t[2]) _.ops.pop();
|
|
152
|
-
_.trys.pop(); continue;
|
|
153
|
-
}
|
|
154
|
-
op = body.call(thisArg, _);
|
|
155
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
156
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
157
|
-
}
|
|
158
113
|
}
|
|
159
114
|
|
|
160
|
-
|
|
161
|
-
if (additionalParam === void 0) { additionalParam = ''; }
|
|
115
|
+
const extractTokenFromWindowLocation = (tokenParam, additionalParam = '') => {
|
|
162
116
|
if (!tokenParam)
|
|
163
117
|
return;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
118
|
+
let token = '';
|
|
119
|
+
const tokenParameterName = `${tokenParam}=`;
|
|
120
|
+
const search = window.location.search;
|
|
121
|
+
const tokenParameterIndex = search.indexOf(tokenParameterName);
|
|
168
122
|
if (tokenParameterIndex !== -1) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
123
|
+
const tokenParameterNameLength = tokenParameterName.length;
|
|
124
|
+
const leadingAmpersandIndex = search.indexOf('&', tokenParameterIndex);
|
|
125
|
+
let searchWithoutToken = search;
|
|
172
126
|
token = search.substring(tokenParameterIndex + tokenParameterNameLength);
|
|
173
127
|
if (leadingAmpersandIndex !== -1) {
|
|
174
128
|
token = search.substring(tokenParameterIndex + tokenParameterNameLength, leadingAmpersandIndex);
|
|
175
129
|
searchWithoutToken = searchWithoutToken.slice(0, leadingAmpersandIndex) + searchWithoutToken.slice(leadingAmpersandIndex + 1);
|
|
176
130
|
}
|
|
177
|
-
searchWithoutToken = searchWithoutToken.replace(
|
|
131
|
+
searchWithoutToken = searchWithoutToken.replace(`${tokenParam}=` + token, '')
|
|
178
132
|
.replace(additionalParam, '')
|
|
179
133
|
.replace('\&cypress=true', '');
|
|
180
134
|
if (searchWithoutToken === '?') {
|
|
@@ -185,31 +139,40 @@ var juxWeb = (function (exports) {
|
|
|
185
139
|
return token;
|
|
186
140
|
};
|
|
187
141
|
|
|
188
|
-
|
|
142
|
+
const setBackendUrl = (backendUrl) => localStorage.setItem('backend-url', backendUrl);
|
|
189
143
|
//@ts-ignore
|
|
190
|
-
|
|
144
|
+
const getBackendUrl = () => process.env.BACKEND_URL || localStorage.getItem('backend-url');
|
|
191
145
|
//@ts-ignore
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
var getMicrosoftAuthUrl = function () { return getBackendUrl() + 'auth-microsoft?access-token='; };
|
|
197
|
-
var getMagicAuthUrl = function () {
|
|
146
|
+
const getSecondaryBackendUrl = () => process.env.STAGING_BACKEND_URL || getBackendUrl();
|
|
147
|
+
const getApiUrl = () => getBackendUrl() + 'api/';
|
|
148
|
+
let getBackendUrlToTry = () => getBackendUrl();
|
|
149
|
+
const getMagicAuthUrl = () => {
|
|
198
150
|
var _a;
|
|
199
151
|
// @ts-ignore
|
|
200
|
-
|
|
152
|
+
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkAuthEndpoint) || 'auth-magic';
|
|
201
153
|
return getBackendUrl() + endpoint + '?token=';
|
|
202
154
|
};
|
|
203
|
-
|
|
155
|
+
const getMagicAuthReqUrl = () => {
|
|
204
156
|
var _a;
|
|
205
157
|
// @ts-ignore
|
|
206
|
-
|
|
158
|
+
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkRequestEndpoint) || 'magic-link-request';
|
|
207
159
|
return getBackendUrl() + endpoint + '?email=';
|
|
208
160
|
};
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
161
|
+
const handleJuxEvents = (ev) => {
|
|
162
|
+
const { method, endpoint, onResult, params, onError } = ev;
|
|
163
|
+
const onJsonResponse = (res) => onResult ? onResult(res) : null;
|
|
164
|
+
const onHelpMessage = (err) => onError ? onError(err) : null;
|
|
165
|
+
if (method === 'GET') {
|
|
166
|
+
backendGet(endpoint, params, onJsonResponse, onHelpMessage);
|
|
167
|
+
}
|
|
168
|
+
if (method === 'POST') {
|
|
169
|
+
backendPost(endpoint, params, onJsonResponse, onHelpMessage);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
let timeout;
|
|
173
|
+
const maxRetries = 20;
|
|
174
|
+
let retries = 0;
|
|
175
|
+
const applySpinnerStyle = (spinner) => {
|
|
213
176
|
spinner.style.position = 'fixed';
|
|
214
177
|
spinner.style.top = '50%';
|
|
215
178
|
spinner.style.zIndex = '2147483647';
|
|
@@ -218,44 +181,51 @@ var juxWeb = (function (exports) {
|
|
|
218
181
|
spinner.style.height = '80px';
|
|
219
182
|
spinner.style.width = '80px';
|
|
220
183
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
184
|
+
const renderOverlay = () => {
|
|
185
|
+
const overlay = document.createElement('reconnect-overlay');
|
|
186
|
+
const spinner = document.createElement('loading-spinner');
|
|
224
187
|
spinner.className = 'reconnect-spinner';
|
|
225
188
|
applySpinnerStyle(spinner);
|
|
226
189
|
document.body.append(overlay, spinner);
|
|
227
190
|
};
|
|
228
|
-
|
|
191
|
+
const removeOverlay = () => {
|
|
229
192
|
var _a, _b;
|
|
230
193
|
(_a = document.querySelector('reconnect-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
231
194
|
(_b = document.querySelector('.reconnect-spinner')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
232
195
|
};
|
|
233
|
-
|
|
196
|
+
const backendHelpMessage = (req) => {
|
|
234
197
|
return req.response && req.response.error || req.response || req;
|
|
235
198
|
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
199
|
+
const defaultHandleUnauthorized = () => {
|
|
200
|
+
localStorage.removeItem('token');
|
|
201
|
+
alert(getTranslation('session-expired-msg'));
|
|
202
|
+
location.reload();
|
|
203
|
+
// googleAuthSignOut(); TODO
|
|
204
|
+
};
|
|
205
|
+
const backendRequest = (requestType, urlString, params, onJsonResponse, onHelpMessage, handleUnauthorized = defaultHandleUnauthorized) => {
|
|
206
|
+
if (urlString.includes(getBackendUrl())) {
|
|
207
|
+
urlString = urlString.replace(getBackendUrl(), getBackendUrlToTry());
|
|
239
208
|
}
|
|
240
|
-
else if (
|
|
241
|
-
|
|
209
|
+
else if (urlString.includes(getSecondaryBackendUrl())) {
|
|
210
|
+
urlString = urlString.replace(getSecondaryBackendUrl(), getBackendUrlToTry());
|
|
242
211
|
}
|
|
243
212
|
clearInterval(timeout);
|
|
244
|
-
|
|
213
|
+
const req = new XMLHttpRequest();
|
|
214
|
+
const url = new URL(urlString);
|
|
215
|
+
if (requestType === 'GET' && params) {
|
|
216
|
+
Object.keys(params).forEach(k => url.searchParams.set(k, params[k]));
|
|
217
|
+
}
|
|
245
218
|
req.open(requestType, url, true);
|
|
246
219
|
// @ts-ignore
|
|
247
|
-
|
|
220
|
+
const backendToken = window.store.backendToken;
|
|
248
221
|
if (backendToken) {
|
|
249
222
|
req.setRequestHeader('auth', backendToken);
|
|
250
223
|
}
|
|
251
224
|
req.setRequestHeader('Content-Type', 'application/json');
|
|
252
225
|
req.responseType = 'json';
|
|
253
|
-
req.onerror = req.ontimeout =
|
|
226
|
+
req.onerror = req.ontimeout = () => {
|
|
254
227
|
if (req.status === 401) {
|
|
255
|
-
|
|
256
|
-
alert(getTranslation('session-expired-msg'));
|
|
257
|
-
location.reload();
|
|
258
|
-
// googleAuthSignOut(); TODO
|
|
228
|
+
handleUnauthorized();
|
|
259
229
|
}
|
|
260
230
|
else if (req.status === 0) {
|
|
261
231
|
if (retries >= maxRetries) {
|
|
@@ -267,20 +237,20 @@ var juxWeb = (function (exports) {
|
|
|
267
237
|
if (!document.querySelector('reconnect-overlay')) {
|
|
268
238
|
renderOverlay();
|
|
269
239
|
}
|
|
270
|
-
|
|
240
|
+
const backupBackendUrl = getBackendUrlToTry() === getBackendUrl()
|
|
271
241
|
? getSecondaryBackendUrl()
|
|
272
242
|
: getBackendUrl();
|
|
273
|
-
|
|
274
|
-
getBackendUrlToTry =
|
|
275
|
-
timeout = setTimeout(
|
|
276
|
-
backendRequest(requestType,
|
|
243
|
+
urlString = urlString.replace(getBackendUrlToTry(), backupBackendUrl);
|
|
244
|
+
getBackendUrlToTry = () => backupBackendUrl;
|
|
245
|
+
timeout = setTimeout(() => {
|
|
246
|
+
backendRequest(requestType, urlString, params, onJsonResponse, onHelpMessage);
|
|
277
247
|
}, 2000);
|
|
278
248
|
}
|
|
279
249
|
else {
|
|
280
250
|
onHelpMessage(backendHelpMessage(req));
|
|
281
251
|
}
|
|
282
252
|
};
|
|
283
|
-
req.onload =
|
|
253
|
+
req.onload = () => {
|
|
284
254
|
retries = 0;
|
|
285
255
|
removeOverlay();
|
|
286
256
|
if (req.status === 200 || req.status === 202) {
|
|
@@ -294,59 +264,52 @@ var juxWeb = (function (exports) {
|
|
|
294
264
|
}
|
|
295
265
|
};
|
|
296
266
|
req.timeout = 25000;
|
|
297
|
-
req.send(
|
|
267
|
+
req.send(params);
|
|
298
268
|
};
|
|
299
|
-
|
|
269
|
+
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
300
270
|
backendRequest('POST', getApiUrl() + endpoint, postContent, onJsonResponse, onHelpMessage);
|
|
301
271
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (endpoint.includes(getGoogleAuthUrl()) || endpoint.includes(getMicrosoftAuthUrl())) {
|
|
305
|
-
api = endpoint;
|
|
306
|
-
}
|
|
307
|
-
backendRequest('GET', api, undefined, onJsonResponse, onHelpMessage);
|
|
272
|
+
const backendGet = (endpoint, params, onJsonResponse, onHelpMessage) => {
|
|
273
|
+
backendRequest('GET', getApiUrl() + endpoint, params, onJsonResponse, onHelpMessage);
|
|
308
274
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
backendRequest('GET', getMagicAuthReqUrl() + encodeURIComponent(data.email) + '&destination=' + extractTokenFromWindowLocation('destination') + '&token=' + data.token, undefined, onJsonResponse, function () { });
|
|
275
|
+
const requestMagicLink = (data, onJsonResponse, onUnauthorized) => {
|
|
276
|
+
const { email, token } = data;
|
|
277
|
+
const url = getMagicAuthReqUrl() + encodeURIComponent(email) + '&destination=' + extractTokenFromWindowLocation('destination') + '&token=' + token;
|
|
278
|
+
backendRequest('GET', url, null, onJsonResponse, console.error, onUnauthorized);
|
|
314
279
|
};
|
|
315
|
-
|
|
316
|
-
backendRequest('GET', getMagicAuthUrl() + magicToken,
|
|
280
|
+
const openMagicLink = (magicToken, onJsonResponse, onHelpMessage) => {
|
|
281
|
+
backendRequest('GET', getMagicAuthUrl() + magicToken, null, onJsonResponse, onHelpMessage);
|
|
317
282
|
};
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
case 2:
|
|
336
|
-
recordsJson = _a.sent();
|
|
337
|
-
answer = recordsJson.Answer;
|
|
338
|
-
if (!answer) {
|
|
339
|
-
return [2 /*return*/, null];
|
|
340
|
-
}
|
|
341
|
-
return [2 /*return*/, Array.from(answer).map(function (a) { return a.data; })];
|
|
342
|
-
case 3:
|
|
343
|
-
error_1 = _a.sent();
|
|
344
|
-
console.error('Fetch failed: ', error_1);
|
|
345
|
-
return [2 /*return*/, null];
|
|
346
|
-
case 4: return [2 /*return*/];
|
|
283
|
+
const googleLogin = (token, onLogin, onLoginError) => {
|
|
284
|
+
const url = getBackendUrl() + 'auth-google?google-id-token=' + token;
|
|
285
|
+
backendRequest('GET', url, null, onLogin, onLoginError);
|
|
286
|
+
};
|
|
287
|
+
const microsoftLogin = (token, onLogin, onLoginError) => {
|
|
288
|
+
const url = getBackendUrl() + 'auth-microsoft?access-token=' + token;
|
|
289
|
+
backendRequest('GET', url, null, onLogin, onLoginError);
|
|
290
|
+
};
|
|
291
|
+
const getMXData = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
292
|
+
try {
|
|
293
|
+
const records = yield fetch(`https://dns.google.com/resolve?name=${domainName}&type=MX`, {
|
|
294
|
+
method: 'GET',
|
|
295
|
+
mode: 'cors'
|
|
296
|
+
});
|
|
297
|
+
if (!records.ok) {
|
|
298
|
+
console.log('response was not ok');
|
|
299
|
+
return null;
|
|
347
300
|
}
|
|
348
|
-
|
|
349
|
-
|
|
301
|
+
const recordsJson = yield records.json();
|
|
302
|
+
const answer = recordsJson.Answer;
|
|
303
|
+
if (!answer) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return Array.from(answer).map((a) => a.data);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
console.error('Fetch failed: ', error);
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
350
313
|
|
|
351
314
|
/*! @azure/msal-browser v2.21.0 2022-01-04 */
|
|
352
315
|
/*! *****************************************************************************
|
|
@@ -13667,13 +13630,13 @@ var juxWeb = (function (exports) {
|
|
|
13667
13630
|
return PublicClientApplication;
|
|
13668
13631
|
}(ClientApplication));
|
|
13669
13632
|
|
|
13670
|
-
|
|
13671
|
-
|
|
13633
|
+
let cleared = false;
|
|
13634
|
+
const clearCookieValidation = () => {
|
|
13672
13635
|
var _a;
|
|
13673
13636
|
(_a = document.querySelector('#cookie-test-iframe')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
13674
13637
|
cleared = true;
|
|
13675
13638
|
};
|
|
13676
|
-
|
|
13639
|
+
const checkCookiesEnable = (ev, onEnabled, onDisabled) => {
|
|
13677
13640
|
if (ev.data === 'MM:3PCunsupported') {
|
|
13678
13641
|
clearCookieValidation();
|
|
13679
13642
|
if (onDisabled) {
|
|
@@ -13685,18 +13648,18 @@ var juxWeb = (function (exports) {
|
|
|
13685
13648
|
onEnabled();
|
|
13686
13649
|
}
|
|
13687
13650
|
};
|
|
13688
|
-
|
|
13689
|
-
|
|
13651
|
+
const cookieTest = () => {
|
|
13652
|
+
const frame = document.createElement('iframe');
|
|
13690
13653
|
frame.id = 'cookie-test-iframe';
|
|
13691
13654
|
frame.src = 'https://mindmup.github.io/3rdpartycookiecheck/start.html';
|
|
13692
13655
|
frame.style.display = 'none';
|
|
13693
13656
|
document.body.appendChild(frame);
|
|
13694
13657
|
};
|
|
13695
|
-
|
|
13658
|
+
const validateThirdPartyCookies = (onEnabled, onDisabled) => {
|
|
13696
13659
|
cleared = false;
|
|
13697
|
-
|
|
13660
|
+
const listener = (ev) => checkCookiesEnable(ev, onEnabled, onDisabled);
|
|
13698
13661
|
window.addEventListener('message', listener);
|
|
13699
|
-
|
|
13662
|
+
const timer = setInterval(() => {
|
|
13700
13663
|
if (cleared) {
|
|
13701
13664
|
window.removeEventListener('message', listener);
|
|
13702
13665
|
clearInterval(timer);
|
|
@@ -13705,26 +13668,26 @@ var juxWeb = (function (exports) {
|
|
|
13705
13668
|
cookieTest();
|
|
13706
13669
|
};
|
|
13707
13670
|
|
|
13708
|
-
|
|
13671
|
+
const enableSignInLayout = () => {
|
|
13709
13672
|
document.documentElement.style.cursor = 'progress';
|
|
13710
13673
|
document.body.style.opacity = '0.5';
|
|
13711
13674
|
document.body.style.pointerEvents = 'none';
|
|
13712
13675
|
};
|
|
13713
|
-
|
|
13676
|
+
const disableSignInLayout = () => {
|
|
13714
13677
|
document.documentElement.style.cursor = 'default';
|
|
13715
13678
|
document.body.style.opacity = '1';
|
|
13716
13679
|
document.body.style.pointerEvents = 'auto';
|
|
13717
13680
|
};
|
|
13718
13681
|
|
|
13719
13682
|
// TODO: find a better way to import external scripts
|
|
13720
|
-
|
|
13683
|
+
const script$1 = document.createElement('script');
|
|
13721
13684
|
script$1.type = 'text/javascript';
|
|
13722
13685
|
script$1.src = 'https://apis.google.com/js/api.js';
|
|
13723
13686
|
document.head.appendChild(script$1);
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13687
|
+
let authStatus;
|
|
13688
|
+
let authError;
|
|
13689
|
+
const highLevelUser = (gUser) => {
|
|
13690
|
+
const profile = gUser.getBasicProfile();
|
|
13728
13691
|
return {
|
|
13729
13692
|
name: profile.getName(),
|
|
13730
13693
|
email: profile.getEmail(),
|
|
@@ -13732,62 +13695,50 @@ var juxWeb = (function (exports) {
|
|
|
13732
13695
|
googletoken: gUser.getAuthResponse().id_token
|
|
13733
13696
|
};
|
|
13734
13697
|
};
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
// checkMixpanel(() => mixpanel.track('Login Error', { 'Login Type': 'Google', 'Error': error })); TODO
|
|
13762
|
-
return [2 /*return*/];
|
|
13763
|
-
case 4: return [3 /*break*/, 6];
|
|
13764
|
-
case 5:
|
|
13765
|
-
setBackendToken('');
|
|
13766
|
-
_a.label = 6;
|
|
13767
|
-
case 6: return [2 /*return*/];
|
|
13768
|
-
}
|
|
13769
|
-
});
|
|
13770
|
-
}); };
|
|
13771
|
-
var onGoogleUserChanged = function (gUser, onUserLogin) {
|
|
13698
|
+
const onUserChanged = (googleUser, onUserLogin) => {
|
|
13699
|
+
document.documentElement.classList.remove('progress');
|
|
13700
|
+
document.body.classList.remove('disabled');
|
|
13701
|
+
if (googleUser) {
|
|
13702
|
+
// mixpanelIdentify(googleUser); TODO
|
|
13703
|
+
const onSuccess = (res) => {
|
|
13704
|
+
const { token } = res;
|
|
13705
|
+
// @ts-ignore
|
|
13706
|
+
window.store.currentUser = res;
|
|
13707
|
+
onTokenAcquired(token, onUserLogin);
|
|
13708
|
+
};
|
|
13709
|
+
const onError = (err) => {
|
|
13710
|
+
console.error(err);
|
|
13711
|
+
// logError(error); TODO
|
|
13712
|
+
// checkMixpanel(() => mixpanel.track('Login Error', { 'Login Type': 'Google', 'Error': error })); TODO
|
|
13713
|
+
};
|
|
13714
|
+
googleLogin(googleUser.googletoken, onSuccess, onError);
|
|
13715
|
+
// checkMixpanel(() => mixpanel.track('Login', { 'Login Type': 'Google' })); TODO
|
|
13716
|
+
}
|
|
13717
|
+
else {
|
|
13718
|
+
setBackendToken('');
|
|
13719
|
+
// checkMixpanel(() => mixpanel.reset()); TODO
|
|
13720
|
+
// displayPage(Page.LOGIN); TODO
|
|
13721
|
+
}
|
|
13722
|
+
};
|
|
13723
|
+
const onGoogleUserChanged = (gUser, onUserLogin) => {
|
|
13772
13724
|
onUserChanged(gUser.isSignedIn() ? highLevelUser(gUser) : null, onUserLogin);
|
|
13773
13725
|
};
|
|
13774
|
-
|
|
13726
|
+
const initGapiClient = (callbackFn, onUserLogin) => {
|
|
13775
13727
|
// @ts-ignore
|
|
13776
|
-
|
|
13777
|
-
gapi.auth2.init({ client_id: clientId, prompt: 'select_account' }).then(
|
|
13728
|
+
const clientId = process.env.GOOGLE_CLIENT_ID;
|
|
13729
|
+
gapi.auth2.init({ client_id: clientId, prompt: 'select_account' }).then(() => {
|
|
13778
13730
|
authStatus = 'LOADED';
|
|
13779
|
-
|
|
13731
|
+
const currentUser = getAuth().currentUser;
|
|
13780
13732
|
currentUser.listen(onGoogleUserChanged);
|
|
13781
13733
|
callbackFn ? callbackFn(clientId) : onGoogleUserChanged(currentUser.get(), onUserLogin);
|
|
13782
13734
|
}, onAuthError);
|
|
13783
13735
|
};
|
|
13784
|
-
|
|
13736
|
+
const onAuthError = (error) => {
|
|
13785
13737
|
authError = error;
|
|
13786
13738
|
console.error(error);
|
|
13787
13739
|
// logError(error, authError); // TODO
|
|
13788
13740
|
};
|
|
13789
|
-
|
|
13790
|
-
if (callbackFn === void 0) { callbackFn = null; }
|
|
13741
|
+
const initGapi = (callbackFn = null, onUserLogin) => {
|
|
13791
13742
|
if (!window.location.protocol.startsWith('http')) {
|
|
13792
13743
|
onAuthError('To use Google Auth you must access this page using http(s), not ' + window.location.protocol);
|
|
13793
13744
|
return;
|
|
@@ -13798,27 +13749,27 @@ var juxWeb = (function (exports) {
|
|
|
13798
13749
|
}
|
|
13799
13750
|
authStatus = 'LOADING';
|
|
13800
13751
|
gapi.load('auth2', {
|
|
13801
|
-
callback:
|
|
13752
|
+
callback: () => initGapiClient(callbackFn, onUserLogin),
|
|
13802
13753
|
onerror: onAuthError,
|
|
13803
13754
|
ontimeout: onAuthError,
|
|
13804
13755
|
timeout: 5000
|
|
13805
13756
|
});
|
|
13806
13757
|
};
|
|
13807
|
-
|
|
13758
|
+
const authAlert = (error) => {
|
|
13808
13759
|
alert('Google authentication is not working at this moment.\n\nPlease try again later or use a magic sign-in link.\n\nError: ' + JSON.stringify(error));
|
|
13809
13760
|
location.reload();
|
|
13810
13761
|
};
|
|
13811
|
-
|
|
13762
|
+
const onSignInError = (error) => {
|
|
13812
13763
|
disableSignInLayout();
|
|
13813
13764
|
console.error(error);
|
|
13814
13765
|
// logError(error); TODO
|
|
13815
13766
|
if (error && error.error === 'popup_closed_by_user') {
|
|
13816
|
-
onUserChanged(null,
|
|
13767
|
+
onUserChanged(null, () => { });
|
|
13817
13768
|
return;
|
|
13818
13769
|
}
|
|
13819
13770
|
authAlert(error);
|
|
13820
13771
|
};
|
|
13821
|
-
|
|
13772
|
+
const getAuth = () => {
|
|
13822
13773
|
if (typeof gapi === 'undefined') {
|
|
13823
13774
|
console.error('gapi is undefined');
|
|
13824
13775
|
// logError('gapi is undefined'); TODO
|
|
@@ -13826,8 +13777,8 @@ var juxWeb = (function (exports) {
|
|
|
13826
13777
|
}
|
|
13827
13778
|
return gapi.auth2 && gapi.auth2.getAuthInstance();
|
|
13828
13779
|
};
|
|
13829
|
-
|
|
13830
|
-
|
|
13780
|
+
const googleSignIn = () => getAuth().signIn().catch(onSignInError);
|
|
13781
|
+
const authSignIn = (onUserLogin) => {
|
|
13831
13782
|
if (authError) {
|
|
13832
13783
|
authAlert(authError);
|
|
13833
13784
|
return;
|
|
@@ -13841,7 +13792,7 @@ var juxWeb = (function (exports) {
|
|
|
13841
13792
|
}
|
|
13842
13793
|
catch (err) {
|
|
13843
13794
|
try {
|
|
13844
|
-
initGapi(
|
|
13795
|
+
initGapi(() => googleSignIn(), onUserLogin);
|
|
13845
13796
|
}
|
|
13846
13797
|
catch (error) {
|
|
13847
13798
|
onSignInError(error);
|
|
@@ -13851,13 +13802,13 @@ var juxWeb = (function (exports) {
|
|
|
13851
13802
|
};
|
|
13852
13803
|
|
|
13853
13804
|
// TODO: find a better way to import external scripts
|
|
13854
|
-
|
|
13805
|
+
const script = document.createElement('script');
|
|
13855
13806
|
script.type = 'text/javascript';
|
|
13856
13807
|
script.src = 'https://www.google.com/recaptcha/api.js';
|
|
13857
13808
|
document.head.appendChild(script);
|
|
13858
|
-
|
|
13859
|
-
|
|
13860
|
-
window.submitCaptcha =
|
|
13809
|
+
const googleCaptcha = () => {
|
|
13810
|
+
const result = document.createElement('google-captcha');
|
|
13811
|
+
window.submitCaptcha = (token) => result.setAttribute('token', token);
|
|
13861
13812
|
result.className = 'g-recaptcha';
|
|
13862
13813
|
// @ts-ignore
|
|
13863
13814
|
result.setAttribute('data-sitekey', process.env.GOOGLE_CAPTCHA_KEY);
|
|
@@ -13866,14 +13817,14 @@ var juxWeb = (function (exports) {
|
|
|
13866
13817
|
return result;
|
|
13867
13818
|
};
|
|
13868
13819
|
|
|
13869
|
-
|
|
13870
|
-
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13820
|
+
const juxWhite = '#FFF';
|
|
13821
|
+
const juxDarkGrey = '#282828';
|
|
13822
|
+
const juxDimmedDarkGrey = '#28282822';
|
|
13823
|
+
const juxDimmedBlack = '#00000088';
|
|
13824
|
+
const juxLightGreen = '#20B03D';
|
|
13825
|
+
const juxMediumGreen = '#0D631E';
|
|
13875
13826
|
|
|
13876
|
-
|
|
13827
|
+
const onKeyDown = (ev, el, persitent, onClose) => {
|
|
13877
13828
|
if (ev.key === 'Escape') {
|
|
13878
13829
|
if (persitent) {
|
|
13879
13830
|
return;
|
|
@@ -13887,34 +13838,34 @@ var juxWeb = (function (exports) {
|
|
|
13887
13838
|
el.dispatchEvent(new CustomEvent('ok'));
|
|
13888
13839
|
}
|
|
13889
13840
|
};
|
|
13890
|
-
|
|
13841
|
+
const close = (el, onClose) => {
|
|
13891
13842
|
el.remove();
|
|
13892
13843
|
if (onClose) {
|
|
13893
13844
|
onClose();
|
|
13894
13845
|
}
|
|
13895
13846
|
};
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click',
|
|
13847
|
+
const attachEventHandlers = (el, persitent, onClose) => {
|
|
13848
|
+
const cancelButton = el.querySelector('.cancel');
|
|
13849
|
+
cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click', (_e) => {
|
|
13899
13850
|
el.dispatchEvent(new CustomEvent('cancel'));
|
|
13900
13851
|
if (el.hasAttribute('dont-remove')) {
|
|
13901
13852
|
return;
|
|
13902
13853
|
}
|
|
13903
13854
|
close(el, onClose);
|
|
13904
13855
|
});
|
|
13905
|
-
|
|
13856
|
+
const closeButton = el.querySelector('.close');
|
|
13906
13857
|
if (closeButton) {
|
|
13907
|
-
closeButton.addEventListener('click',
|
|
13858
|
+
closeButton.addEventListener('click', (_e) => {
|
|
13908
13859
|
close(el, onClose);
|
|
13909
13860
|
});
|
|
13910
13861
|
}
|
|
13911
|
-
|
|
13912
|
-
okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click',
|
|
13862
|
+
const okButton = el.querySelector('.ok');
|
|
13863
|
+
okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click', (_e) => {
|
|
13913
13864
|
el.dispatchEvent(new CustomEvent('ok'));
|
|
13914
13865
|
});
|
|
13915
|
-
el.removeEventListener('keydown',
|
|
13916
|
-
el.addEventListener('keydown',
|
|
13917
|
-
el === null || el === void 0 ? void 0 : el.addEventListener('click',
|
|
13866
|
+
el.removeEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
|
|
13867
|
+
el.addEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
|
|
13868
|
+
el === null || el === void 0 ? void 0 : el.addEventListener('click', (e) => {
|
|
13918
13869
|
if (e.target === el) {
|
|
13919
13870
|
if (persitent) {
|
|
13920
13871
|
return;
|
|
@@ -13936,11 +13887,11 @@ var juxWeb = (function (exports) {
|
|
|
13936
13887
|
// onClose?: any,
|
|
13937
13888
|
// titleStyle?: string,
|
|
13938
13889
|
// }
|
|
13939
|
-
|
|
13890
|
+
const applyWrapperStyle = (wrapper) => {
|
|
13940
13891
|
wrapper.style.alignItems = 'center';
|
|
13941
13892
|
wrapper.style.backgroundColor = juxWhite;
|
|
13942
13893
|
wrapper.style.borderRadius = '.3125rem';
|
|
13943
|
-
wrapper.style.boxShadow =
|
|
13894
|
+
wrapper.style.boxShadow = `0 0 1.33rem ${juxDimmedBlack}`;
|
|
13944
13895
|
wrapper.style.boxSizing = 'content-box';
|
|
13945
13896
|
wrapper.style.display = 'flex';
|
|
13946
13897
|
wrapper.style.flexDirection = 'column';
|
|
@@ -13952,7 +13903,7 @@ var juxWeb = (function (exports) {
|
|
|
13952
13903
|
wrapper.style.padding = '1.33rem';
|
|
13953
13904
|
wrapper.style.position = 'relative';
|
|
13954
13905
|
};
|
|
13955
|
-
|
|
13906
|
+
const applyModalStyle = (modal) => {
|
|
13956
13907
|
modal.style.alignItems = 'center';
|
|
13957
13908
|
modal.style.backgroundColor = juxDimmedBlack;
|
|
13958
13909
|
modal.style.display = 'flex';
|
|
@@ -13965,7 +13916,7 @@ var juxWeb = (function (exports) {
|
|
|
13965
13916
|
modal.style.width = '100%';
|
|
13966
13917
|
modal.style.zIndex = '9999';
|
|
13967
13918
|
};
|
|
13968
|
-
|
|
13919
|
+
const applyHeaderStyle = (header) => {
|
|
13969
13920
|
header.style.alignItems = 'center';
|
|
13970
13921
|
header.style.color = juxMediumGreen;
|
|
13971
13922
|
header.style.flexDirection = 'row';
|
|
@@ -13977,7 +13928,7 @@ var juxWeb = (function (exports) {
|
|
|
13977
13928
|
header.style.position = 'relative';
|
|
13978
13929
|
header.style.width = '100%';
|
|
13979
13930
|
};
|
|
13980
|
-
|
|
13931
|
+
const applyJuxModalContentStyle = (el) => {
|
|
13981
13932
|
el.style.display = 'flex';
|
|
13982
13933
|
el.style.position = 'relative';
|
|
13983
13934
|
el.style.width = '100%';
|
|
@@ -13985,37 +13936,32 @@ var juxWeb = (function (exports) {
|
|
|
13985
13936
|
el.style.marginTop = '1.33rem';
|
|
13986
13937
|
el.style.rowGap = '8px';
|
|
13987
13938
|
};
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
if (content === void 0) { content = ''; }
|
|
13991
|
-
if (persistent === void 0) { persistent = false; }
|
|
13992
|
-
if (okTxt === void 0) { okTxt = getTranslation('alert-ok-btn-txt'); }
|
|
13993
|
-
if (cancelTxt === void 0) { cancelTxt = getTranslation('alert-cancel-btn-txt'); }
|
|
13994
|
-
var result = document.createElement('jux-modal');
|
|
13939
|
+
const juxModal = (title, btns = ['ok', 'cancel'], content = '', persistent = false, _busy = false, body, okTxt = getTranslation('alert-ok-btn-txt'), cancelTxt = getTranslation('alert-cancel-btn-txt'), onClose, titleStyle) => {
|
|
13940
|
+
const result = document.createElement('jux-modal');
|
|
13995
13941
|
applyModalStyle(result);
|
|
13996
|
-
|
|
13942
|
+
const wrapper = document.createElement('modal-wrapper');
|
|
13997
13943
|
applyWrapperStyle(wrapper);
|
|
13998
13944
|
// START close
|
|
13999
|
-
|
|
13945
|
+
const closeBtn = document.createElement('button');
|
|
14000
13946
|
if (!persistent) {
|
|
14001
13947
|
closeBtn.className = 'close';
|
|
14002
13948
|
closeBtn.setAttribute('aria-label', getTranslation('close'));
|
|
14003
13949
|
}
|
|
14004
13950
|
// END close
|
|
14005
13951
|
// START header
|
|
14006
|
-
|
|
13952
|
+
const header = document.createElement('modal-header');
|
|
14007
13953
|
applyHeaderStyle(header);
|
|
14008
13954
|
if (title) {
|
|
14009
13955
|
if (titleStyle) {
|
|
14010
13956
|
header.classList.add(titleStyle);
|
|
14011
13957
|
}
|
|
14012
|
-
|
|
13958
|
+
const h3 = document.createElement('h3');
|
|
14013
13959
|
h3.textContent = title;
|
|
14014
13960
|
header.appendChild(h3);
|
|
14015
13961
|
}
|
|
14016
13962
|
// END header
|
|
14017
13963
|
// START content
|
|
14018
|
-
|
|
13964
|
+
const modalContent = document.createElement('jux-modal-content');
|
|
14019
13965
|
applyJuxModalContentStyle(modalContent);
|
|
14020
13966
|
if (content) {
|
|
14021
13967
|
modalContent.innerHTML = content;
|
|
@@ -14025,22 +13971,22 @@ var juxWeb = (function (exports) {
|
|
|
14025
13971
|
}
|
|
14026
13972
|
// END content
|
|
14027
13973
|
// START footer
|
|
14028
|
-
|
|
13974
|
+
const footer = document.createElement('modal-footer');
|
|
14029
13975
|
if (btns.includes('cancel')) {
|
|
14030
|
-
|
|
13976
|
+
const cancelBtn = document.createElement('button');
|
|
14031
13977
|
cancelBtn.classList.add('secondary-button', 'modal-button', 'action', 'cancel-btn', 'cancel');
|
|
14032
|
-
|
|
13978
|
+
const cancelText = document.createElement('button-text');
|
|
14033
13979
|
cancelText.textContent = cancelTxt;
|
|
14034
|
-
|
|
13980
|
+
const cancelSpinner = document.createElement('loading-spinner');
|
|
14035
13981
|
cancelBtn.append(cancelText, cancelSpinner);
|
|
14036
13982
|
footer.appendChild(cancelBtn);
|
|
14037
13983
|
}
|
|
14038
13984
|
if (btns.includes('ok')) {
|
|
14039
|
-
|
|
13985
|
+
const okBtn = document.createElement('button');
|
|
14040
13986
|
okBtn.classList.add('primary-button', 'modal-button', 'action', 'ok');
|
|
14041
|
-
|
|
13987
|
+
const okText = document.createElement('button-text');
|
|
14042
13988
|
okText.textContent = okTxt;
|
|
14043
|
-
|
|
13989
|
+
const okSpinner = document.createElement('loading-spinner');
|
|
14044
13990
|
okBtn.append(okText, okSpinner);
|
|
14045
13991
|
footer.appendChild(okBtn);
|
|
14046
13992
|
}
|
|
@@ -14064,15 +14010,13 @@ var juxWeb = (function (exports) {
|
|
|
14064
14010
|
return result;
|
|
14065
14011
|
};
|
|
14066
14012
|
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
var elId = 'contact-' + elName;
|
|
14072
|
-
var label = document.createElement('label');
|
|
14013
|
+
const contactField = (tag = 'input', elType, elName, required = true, value) => {
|
|
14014
|
+
const result = document.createElement('contact-field');
|
|
14015
|
+
const elId = 'contact-' + elName;
|
|
14016
|
+
const label = document.createElement('label');
|
|
14073
14017
|
label.textContent = getTranslation(elId + '-label');
|
|
14074
14018
|
label.htmlFor = elId;
|
|
14075
|
-
|
|
14019
|
+
const el = document.createElement(tag);
|
|
14076
14020
|
el.id = elId;
|
|
14077
14021
|
el.setAttribute('name', elName);
|
|
14078
14022
|
el.setAttribute('placeholder', getTranslation(elId + '-placeholder'));
|
|
@@ -14089,80 +14033,74 @@ var juxWeb = (function (exports) {
|
|
|
14089
14033
|
return result;
|
|
14090
14034
|
};
|
|
14091
14035
|
|
|
14092
|
-
|
|
14093
|
-
|
|
14036
|
+
const getNestedElValue = (el, nestedTag) => {
|
|
14037
|
+
const nestedEl = el.querySelector(nestedTag);
|
|
14094
14038
|
return nestedEl.value;
|
|
14095
14039
|
};
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
subject:
|
|
14099
|
-
body:
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14040
|
+
const sendInquiry = (name, email, msg, whatsapp, subject, token) => {
|
|
14041
|
+
const inquiryPayload = {
|
|
14042
|
+
subject: `[${subject.charAt(0).toUpperCase()}${subject.slice(1)}] ${getNestedElValue(name, 'input')}`,
|
|
14043
|
+
body: `<strong>Name</strong>: ${getNestedElValue(name, 'input')}<br><br>
|
|
14044
|
+
<strong>E-mail</strong>: ${getNestedElValue(email, 'input')}<br><br>
|
|
14045
|
+
<strong>Whatsapp</strong>: ${getNestedElValue(whatsapp, 'input')}<br><br>
|
|
14046
|
+
<strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
|
|
14047
|
+
token,
|
|
14048
|
+
};
|
|
14049
|
+
backendPost('contact-us', JSON.stringify(inquiryPayload), (_res) => {
|
|
14103
14050
|
var _a;
|
|
14104
14051
|
// success(getTranslation('form-success'), Length.long);
|
|
14105
14052
|
(_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
14106
|
-
},
|
|
14053
|
+
}, () => { } // TODO: change it to be an error handling fn provided by the client
|
|
14107
14054
|
);
|
|
14108
14055
|
// checkMixpanel(() => mixpanel.track('Sent Contact Inquiry', {}));
|
|
14109
14056
|
};
|
|
14110
|
-
|
|
14057
|
+
const contactUsModal = (subject) => {
|
|
14111
14058
|
var _a, _b, _c, _d, _e;
|
|
14112
|
-
|
|
14059
|
+
const result = document.createElement('contact-us-modal');
|
|
14113
14060
|
// @ts-ignore
|
|
14114
|
-
|
|
14061
|
+
const currentName = window.store.currentUser ? window.store.currentUser.name : '';
|
|
14115
14062
|
// @ts-ignore
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14063
|
+
const currentEmail = window.store.currentUser ? window.store.currentUser.email : (_a = document.querySelector('#magic-link-email')) === null || _a === void 0 ? void 0 : _a.textContent;
|
|
14064
|
+
const modalBody = document.createElement('modal-body');
|
|
14065
|
+
const form = document.createElement('form');
|
|
14119
14066
|
form.id = 'contact-form';
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14067
|
+
const nameField = contactField('input', 'text', 'name', true, currentName);
|
|
14068
|
+
const emailField = contactField('input', 'email', 'email', true, currentEmail);
|
|
14069
|
+
const messageField = contactField('textarea', 'text', 'message', true);
|
|
14070
|
+
const whatsappField = contactField('input', 'tel', 'whatsapp', false);
|
|
14071
|
+
const btn = document.createElement('button');
|
|
14125
14072
|
btn.textContent = getTranslation('contact-submit');
|
|
14126
14073
|
btn.className = 'primary-button';
|
|
14127
14074
|
form.append(nameField, emailField, whatsappField, messageField, btn);
|
|
14128
14075
|
modalBody.appendChild(form);
|
|
14129
|
-
|
|
14076
|
+
const modal = juxModal(getTranslation('contact-page'), [], '', false, false, modalBody, '', '', () => result.remove());
|
|
14130
14077
|
modal.id = 'contact-us-modal';
|
|
14131
14078
|
document.body.appendChild(modal);
|
|
14132
14079
|
(_b = modal.querySelector('modal-wrapper')) === null || _b === void 0 ? void 0 : _b.setAttribute('style', 'max-width: 680px; width: 100%; overflow-y: auto;');
|
|
14133
|
-
|
|
14080
|
+
const captcha = googleCaptcha();
|
|
14134
14081
|
if (subject !== 'email-not-sent') {
|
|
14135
14082
|
// @ts-ignore
|
|
14136
|
-
|
|
14137
|
-
backendGet(
|
|
14138
|
-
|
|
14083
|
+
const admin = ((_d = (_c = window.store) === null || _c === void 0 ? void 0 : _c.selectedTeam) === null || _d === void 0 ? void 0 : _d.admin) || window.store.currentUser.email;
|
|
14084
|
+
backendGet(`credits-balance-for?admin=${admin}`, null, (res) => {
|
|
14085
|
+
const balance = res;
|
|
14139
14086
|
if (balance <= 0) {
|
|
14140
14087
|
form.insertBefore(captcha, btn);
|
|
14141
14088
|
}
|
|
14142
|
-
},
|
|
14089
|
+
}, () => { } // TODO: change it to be an error handling fn provided by the client
|
|
14143
14090
|
);
|
|
14144
14091
|
}
|
|
14145
14092
|
else {
|
|
14146
14093
|
form.insertBefore(captcha, btn);
|
|
14147
14094
|
}
|
|
14148
14095
|
(_e = nameField.querySelector('input')) === null || _e === void 0 ? void 0 : _e.select();
|
|
14149
|
-
form.addEventListener('submit',
|
|
14096
|
+
form.addEventListener('submit', (event) => {
|
|
14150
14097
|
event.preventDefault();
|
|
14151
14098
|
sendInquiry(nameField, emailField, messageField, whatsappField, subject, captcha.getAttribute('token'));
|
|
14152
14099
|
});
|
|
14153
14100
|
return result;
|
|
14154
14101
|
};
|
|
14155
14102
|
|
|
14156
|
-
|
|
14157
|
-
page.style.backgroundImage = "url(".concat(backgroundImg, ")");
|
|
14158
|
-
page.style.display = 'block';
|
|
14159
|
-
page.style.width = '100%';
|
|
14160
|
-
page.style.height = '100%';
|
|
14161
|
-
page.style.backgroundPosition = '50%';
|
|
14162
|
-
page.style.backgroundSize = 'cover';
|
|
14163
|
-
page.style.display = 'block';
|
|
14164
|
-
};
|
|
14165
|
-
var applyContainerStyles$1 = function (container) {
|
|
14103
|
+
const applyContainerStyles = (container) => {
|
|
14166
14104
|
container.style.backgroundColor = '#ffffffdd';
|
|
14167
14105
|
container.style.borderRadius = '16px';
|
|
14168
14106
|
container.style.inset = '50% 50% 50% 0';
|
|
@@ -14178,7 +14116,25 @@ var juxWeb = (function (exports) {
|
|
|
14178
14116
|
container.style.margin = '0 auto';
|
|
14179
14117
|
container.style.paddingTop = '0';
|
|
14180
14118
|
};
|
|
14181
|
-
|
|
14119
|
+
const applyPageStyles = (page, backgroundImg) => {
|
|
14120
|
+
page.style.backgroundImage = `url(${backgroundImg})`;
|
|
14121
|
+
page.style.backgroundPosition = '50%';
|
|
14122
|
+
page.style.backgroundSize = 'cover';
|
|
14123
|
+
page.style.display = 'block';
|
|
14124
|
+
page.style.height = '100%';
|
|
14125
|
+
};
|
|
14126
|
+
const basePage = (pageName, backgroundImg, content) => {
|
|
14127
|
+
const result = document.createElement(pageName);
|
|
14128
|
+
result.className = 'base-login-page';
|
|
14129
|
+
applyPageStyles(result, backgroundImg);
|
|
14130
|
+
const section = document.createElement('section');
|
|
14131
|
+
applyContainerStyles(section);
|
|
14132
|
+
content.forEach(element => section.appendChild(element));
|
|
14133
|
+
result.appendChild(section);
|
|
14134
|
+
return result;
|
|
14135
|
+
};
|
|
14136
|
+
|
|
14137
|
+
const applyBtnStyles = (btn) => {
|
|
14182
14138
|
btn.style.cursor = 'pointer';
|
|
14183
14139
|
btn.style.textDecoration = 'underline';
|
|
14184
14140
|
btn.style.border = 'none';
|
|
@@ -14191,31 +14147,29 @@ var juxWeb = (function (exports) {
|
|
|
14191
14147
|
btn.style.whiteSpace = 'normal';
|
|
14192
14148
|
btn.style.font = 'inherit';
|
|
14193
14149
|
};
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
magicLinkHowTo.style.textAlign = 'center';
|
|
14211
|
-
var btn = document.createElement('button');
|
|
14150
|
+
const magicLinkRequestedPage = (backgroundImg, onReturn) => {
|
|
14151
|
+
const content = [];
|
|
14152
|
+
const sent = document.createElement('p');
|
|
14153
|
+
sent.id = 'magic-link-sent';
|
|
14154
|
+
sent.textContent = getTranslation(sent.id);
|
|
14155
|
+
sent.style.marginBottom = '10px';
|
|
14156
|
+
const email = document.createElement('p');
|
|
14157
|
+
email.id = 'magic-link-email';
|
|
14158
|
+
email.style.fontWeight = '700';
|
|
14159
|
+
email.style.marginBottom = '10px';
|
|
14160
|
+
const howTo = document.createElement('p');
|
|
14161
|
+
howTo.id = 'magic-link-how-to';
|
|
14162
|
+
howTo.innerHTML = getTranslation(howTo.id);
|
|
14163
|
+
howTo.style.padding = '0 30px';
|
|
14164
|
+
howTo.style.textAlign = 'center';
|
|
14165
|
+
const btn = document.createElement('button');
|
|
14212
14166
|
btn.id = 'email-not-received-btn';
|
|
14213
|
-
btn.addEventListener('click',
|
|
14167
|
+
btn.addEventListener('click', () => document.body.appendChild(contactUsModal('email-not-sent')));
|
|
14214
14168
|
btn.textContent = getTranslation('magic-link-let-us-know');
|
|
14215
14169
|
applyBtnStyles(btn);
|
|
14216
|
-
|
|
14170
|
+
const returnLink = document.createElement('a');
|
|
14217
14171
|
returnLink.textContent = getTranslation('return-link');
|
|
14218
|
-
returnLink.onclick =
|
|
14172
|
+
returnLink.onclick = () => {
|
|
14219
14173
|
result.remove();
|
|
14220
14174
|
onReturn();
|
|
14221
14175
|
};
|
|
@@ -14223,43 +14177,72 @@ var juxWeb = (function (exports) {
|
|
|
14223
14177
|
returnLink.style.cursor = 'pointer';
|
|
14224
14178
|
returnLink.style.fontWeight = '700';
|
|
14225
14179
|
returnLink.style.textDecoration = 'underline';
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
result.appendChild(section);
|
|
14180
|
+
content.push(sent, email, howTo, btn, returnLink);
|
|
14181
|
+
const result = basePage('magic-link-requested-page', backgroundImg, content);
|
|
14229
14182
|
return result;
|
|
14230
14183
|
};
|
|
14231
14184
|
|
|
14232
|
-
|
|
14185
|
+
const unauthorizedMagicLinkRequestPage = (backgroundImg, onReturn) => {
|
|
14186
|
+
const content = [];
|
|
14187
|
+
const notSent = document.createElement('p');
|
|
14188
|
+
notSent.id = 'magic-link-not-sent';
|
|
14189
|
+
notSent.textContent = getTranslation(notSent.id);
|
|
14190
|
+
notSent.style.marginBottom = '10px';
|
|
14191
|
+
const email = document.createElement('p');
|
|
14192
|
+
email.id = 'magic-link-email';
|
|
14193
|
+
email.style.fontWeight = '700';
|
|
14194
|
+
email.style.marginBottom = '10px';
|
|
14195
|
+
const info = document.createElement('p');
|
|
14196
|
+
info.id = 'magic-link-fail-info';
|
|
14197
|
+
info.innerHTML = getTranslation(info.id);
|
|
14198
|
+
info.style.padding = '0 30px';
|
|
14199
|
+
info.style.textAlign = 'center';
|
|
14200
|
+
const back = document.createElement('a');
|
|
14201
|
+
back.textContent = getTranslation('return-link');
|
|
14202
|
+
back.onclick = () => {
|
|
14203
|
+
result.remove();
|
|
14204
|
+
onReturn();
|
|
14205
|
+
};
|
|
14206
|
+
back.style.marginTop = '32px';
|
|
14207
|
+
back.style.cursor = 'pointer';
|
|
14208
|
+
back.style.fontWeight = '700';
|
|
14209
|
+
back.style.textDecoration = 'underline';
|
|
14210
|
+
content.push(notSent, email, info, back);
|
|
14211
|
+
const result = basePage('unauthorized-magic-link-request-page', backgroundImg, content);
|
|
14212
|
+
return result;
|
|
14213
|
+
};
|
|
14214
|
+
|
|
14215
|
+
const setBackendToken = (token) => {
|
|
14233
14216
|
// @ts-ignore
|
|
14234
14217
|
window.store.backendToken = token;
|
|
14235
14218
|
if (token) {
|
|
14236
14219
|
localStorage.setItem('token', token);
|
|
14237
14220
|
}
|
|
14238
14221
|
};
|
|
14239
|
-
|
|
14222
|
+
const getBackendToken = () => {
|
|
14240
14223
|
var _a;
|
|
14241
|
-
|
|
14224
|
+
const token = (_a = localStorage.getItem('token')) !== null && _a !== void 0 ? _a : '';
|
|
14242
14225
|
// @ts-ignore
|
|
14243
14226
|
window.store.backendToken = token;
|
|
14244
14227
|
return token;
|
|
14245
14228
|
};
|
|
14246
|
-
|
|
14229
|
+
const onTokenAcquired = (token, onUserLogin) => {
|
|
14247
14230
|
setBackendToken(token);
|
|
14248
14231
|
// setSuperToken();
|
|
14249
14232
|
onUserLogin();
|
|
14250
14233
|
};
|
|
14251
|
-
|
|
14234
|
+
const clearSession = () => {
|
|
14252
14235
|
// onUserChanged(null);
|
|
14253
14236
|
localStorage.clear();
|
|
14254
14237
|
// @ts-ignore
|
|
14255
14238
|
window.store = {};
|
|
14256
14239
|
};
|
|
14257
|
-
|
|
14240
|
+
const onAuthenticationFailure = (msg) => {
|
|
14258
14241
|
localStorage.removeItem('token');
|
|
14259
14242
|
// displayPage(Page.LOGIN);
|
|
14260
14243
|
alert(getTranslation(msg));
|
|
14261
14244
|
};
|
|
14262
|
-
|
|
14245
|
+
const onAuthentication = (onUserLogin, user, type) => {
|
|
14263
14246
|
if ((user.token && getBackendToken()) && getBackendToken() !== user.token) {
|
|
14264
14247
|
clearSession();
|
|
14265
14248
|
}
|
|
@@ -14272,11 +14255,15 @@ var juxWeb = (function (exports) {
|
|
|
14272
14255
|
// mixpanelIdentify(user);
|
|
14273
14256
|
// checkMixpanel(() => mixpanel.track('Login', { 'Login Type': type }));
|
|
14274
14257
|
};
|
|
14275
|
-
|
|
14276
|
-
Array.from(clientApp.children).forEach(
|
|
14258
|
+
const displayPage = (clientApp, page) => {
|
|
14259
|
+
Array.from(clientApp.children).forEach(el => el.remove());
|
|
14277
14260
|
clientApp.appendChild(page);
|
|
14278
14261
|
};
|
|
14279
|
-
|
|
14262
|
+
const setJuxEventHandler = () => {
|
|
14263
|
+
document.removeEventListener('jux-event', handleJuxEvents);
|
|
14264
|
+
document.addEventListener('jux-event', handleJuxEvents);
|
|
14265
|
+
};
|
|
14266
|
+
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14280
14267
|
// if (startNewDemo()) {
|
|
14281
14268
|
// initDemo(setBackendToken, onAuthentication);
|
|
14282
14269
|
// return;
|
|
@@ -14292,25 +14279,27 @@ var juxWeb = (function (exports) {
|
|
|
14292
14279
|
window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
|
|
14293
14280
|
// @ts-ignore
|
|
14294
14281
|
window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14282
|
+
// TODO: use jux-events to call commands and queries
|
|
14283
|
+
setJuxEventHandler();
|
|
14284
|
+
const signInToken = extractTokenFromWindowLocation('sign-in') || extractTokenFromWindowLocation('magic-link');
|
|
14285
|
+
if (signInToken) {
|
|
14286
|
+
const onOpenMagicLink = () => {
|
|
14287
|
+
openMagicLink(signInToken, (res) => onAuthentication(onUserLogin, res, 'Magic Link'), () => onAuthenticationFailure('unable-magic-login'));
|
|
14299
14288
|
};
|
|
14300
|
-
|
|
14289
|
+
const host = extractTokenFromWindowLocation('host');
|
|
14301
14290
|
if (host) {
|
|
14302
14291
|
// @ts-ignore
|
|
14303
|
-
window.store.fetchUserBackendUrl({ host
|
|
14292
|
+
window.store.fetchUserBackendUrl({ host }, (backendUrl) => {
|
|
14304
14293
|
setBackendUrl(backendUrl);
|
|
14305
|
-
|
|
14294
|
+
onOpenMagicLink();
|
|
14306
14295
|
});
|
|
14307
14296
|
return;
|
|
14308
14297
|
}
|
|
14309
|
-
|
|
14298
|
+
onOpenMagicLink();
|
|
14310
14299
|
return;
|
|
14311
14300
|
}
|
|
14312
14301
|
if (getBackendToken()) {
|
|
14313
|
-
backendGet('profile',
|
|
14302
|
+
backendGet('profile', null, (res) => onAuthentication(onUserLogin, res, 'Token Authentication'), (_err) => onAuthenticationFailure('login-failed'));
|
|
14314
14303
|
return;
|
|
14315
14304
|
}
|
|
14316
14305
|
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
@@ -14326,73 +14315,65 @@ var juxWeb = (function (exports) {
|
|
|
14326
14315
|
// validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
|
|
14327
14316
|
// checkMixpanel(() => mixpanel.track('View Login Page'));
|
|
14328
14317
|
};
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
case 4:
|
|
14358
|
-
err_1 = _a.sent();
|
|
14359
|
-
reportError(err_1);
|
|
14360
|
-
disableSignInLayout();
|
|
14361
|
-
return [3 /*break*/, 5];
|
|
14362
|
-
case 5: return [2 /*return*/];
|
|
14363
|
-
}
|
|
14364
|
-
});
|
|
14365
|
-
}); };
|
|
14366
|
-
var onCookieError = function () {
|
|
14318
|
+
const onMicrosoftSignIn = (onUserLogin) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14319
|
+
const msalConfig = { auth: { clientId: process.env.MICROSOFT_CLIENT_ID } };
|
|
14320
|
+
const msalInstance = new PublicClientApplication(msalConfig);
|
|
14321
|
+
const loginRequest = { scopes: ['user.read'] };
|
|
14322
|
+
enableSignInLayout();
|
|
14323
|
+
try {
|
|
14324
|
+
const loginResponse = yield msalInstance.loginPopup(loginRequest);
|
|
14325
|
+
const { accessToken } = loginResponse;
|
|
14326
|
+
const onSuccess = (res) => {
|
|
14327
|
+
const { token } = res;
|
|
14328
|
+
// @ts-ignore
|
|
14329
|
+
window.store.currentUser = res;
|
|
14330
|
+
onTokenAcquired(token, onUserLogin);
|
|
14331
|
+
disableSignInLayout();
|
|
14332
|
+
};
|
|
14333
|
+
const onError = (err) => {
|
|
14334
|
+
console.error(err);
|
|
14335
|
+
reportError(err);
|
|
14336
|
+
disableSignInLayout();
|
|
14337
|
+
};
|
|
14338
|
+
microsoftLogin(accessToken, onSuccess, onError);
|
|
14339
|
+
}
|
|
14340
|
+
catch (err) {
|
|
14341
|
+
reportError(err);
|
|
14342
|
+
disableSignInLayout();
|
|
14343
|
+
}
|
|
14344
|
+
});
|
|
14345
|
+
const onCookieError = () => {
|
|
14367
14346
|
disableSignInLayout();
|
|
14368
14347
|
// warning('cookie-error'); TODO
|
|
14369
14348
|
return;
|
|
14370
14349
|
};
|
|
14371
|
-
|
|
14372
|
-
validateThirdPartyCookies(
|
|
14350
|
+
const onGoogleSignIn = (onUserLogin) => {
|
|
14351
|
+
validateThirdPartyCookies(() => {
|
|
14373
14352
|
enableSignInLayout();
|
|
14374
14353
|
authSignIn(onUserLogin);
|
|
14375
14354
|
}, onCookieError);
|
|
14376
14355
|
};
|
|
14377
|
-
|
|
14378
|
-
if (email === void 0) { email = ''; }
|
|
14356
|
+
const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
|
|
14379
14357
|
if (!email) {
|
|
14380
|
-
|
|
14358
|
+
const mailMagic = document.querySelector('#mail-magic');
|
|
14381
14359
|
email = mailMagic.value;
|
|
14382
14360
|
}
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14361
|
+
const payload = { email, token };
|
|
14362
|
+
const onRequestMagicLink = () => {
|
|
14363
|
+
const onResponse = (page) => {
|
|
14386
14364
|
currentPage.remove();
|
|
14387
|
-
clientBody.appendChild(
|
|
14388
|
-
|
|
14365
|
+
clientBody.appendChild(page);
|
|
14366
|
+
const magicLinkEmail = page.querySelector('#magic-link-email');
|
|
14389
14367
|
magicLinkEmail.textContent = email;
|
|
14390
|
-
}
|
|
14368
|
+
};
|
|
14369
|
+
const onSuccess = () => onResponse(magicLinkRequestedPage(backgroundImage, onReturn));
|
|
14370
|
+
const onUnauthorized = () => onResponse(unauthorizedMagicLinkRequestPage(backgroundImage, onReturn));
|
|
14371
|
+
requestMagicLink(payload, onSuccess, onUnauthorized);
|
|
14391
14372
|
};
|
|
14392
14373
|
// @ts-ignore
|
|
14393
14374
|
if (window.store.fetchUserBackendUrl) {
|
|
14394
14375
|
// @ts-ignore
|
|
14395
|
-
window.store.fetchUserBackendUrl({ email
|
|
14376
|
+
window.store.fetchUserBackendUrl({ email }, (backendUrl) => {
|
|
14396
14377
|
setBackendUrl(backendUrl);
|
|
14397
14378
|
onRequestMagicLink();
|
|
14398
14379
|
});
|
|
@@ -14401,118 +14382,101 @@ var juxWeb = (function (exports) {
|
|
|
14401
14382
|
onRequestMagicLink();
|
|
14402
14383
|
};
|
|
14403
14384
|
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
email.textContent = "
|
|
14408
|
-
|
|
14385
|
+
const socialLoginModal = (userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal) => {
|
|
14386
|
+
const result = document.createElement('social-login-modal');
|
|
14387
|
+
const email = document.createElement('p');
|
|
14388
|
+
email.textContent = `"${userEmail}"`;
|
|
14389
|
+
const msg = document.createElement('social-login-msg');
|
|
14409
14390
|
msg.textContent = getTranslation('social-login-recommendation') + mailExchanger + '.' + getTranslation('social-login-advantage');
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
loginButton('Microsoft',
|
|
14413
|
-
loginButton('Google',
|
|
14414
|
-
|
|
14391
|
+
const body = document.createElement('social-login-body');
|
|
14392
|
+
const socialLoginBtn = mailExchanger === 'Microsoft' ?
|
|
14393
|
+
loginButton('Microsoft', () => onMicrosoftSignIn(onUserLogin)) :
|
|
14394
|
+
loginButton('Google', () => onGoogleSignIn(onUserLogin));
|
|
14395
|
+
const proceedMagicLinkRequest = document.createElement('a');
|
|
14415
14396
|
proceedMagicLinkRequest.textContent = getTranslation('proceed-magic-link-request');
|
|
14416
|
-
proceedMagicLinkRequest.addEventListener('click',
|
|
14397
|
+
proceedMagicLinkRequest.addEventListener('click', () => {
|
|
14417
14398
|
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody, userEmail);
|
|
14418
14399
|
closeMagicLinkModal();
|
|
14419
14400
|
result.remove();
|
|
14420
14401
|
});
|
|
14421
14402
|
body.append(email, msg, socialLoginBtn, proceedMagicLinkRequest);
|
|
14422
|
-
|
|
14403
|
+
const modal = juxModal(getTranslation(`using-${mailExchanger.toLowerCase()}-email`), [], '', false, false, body, '', '', () => result.remove());
|
|
14423
14404
|
modal.setAttribute('data-cy', 'social-login-modal');
|
|
14424
14405
|
result.appendChild(modal);
|
|
14425
|
-
|
|
14406
|
+
const wrapper = modal.querySelector('modal-wrapper');
|
|
14426
14407
|
wrapper.style.maxWidth = '360px';
|
|
14427
14408
|
wrapper.style.width = '100%';
|
|
14428
14409
|
return result;
|
|
14429
14410
|
};
|
|
14430
14411
|
|
|
14431
|
-
|
|
14432
|
-
|
|
14412
|
+
const isValidEmail = (email) => {
|
|
14413
|
+
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
14433
14414
|
return re.test(email);
|
|
14434
14415
|
};
|
|
14435
14416
|
|
|
14436
|
-
|
|
14417
|
+
const recommendSocialLogin = (userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal) => {
|
|
14437
14418
|
var _a;
|
|
14438
14419
|
(_a = document.querySelector('magic-link-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
14439
14420
|
document.body.appendChild(socialLoginModal(userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal));
|
|
14440
14421
|
};
|
|
14441
|
-
|
|
14442
|
-
return data.some(
|
|
14422
|
+
const hasProvider = (data, provider) => {
|
|
14423
|
+
return data.some((entry) => entry.includes(provider));
|
|
14443
14424
|
};
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
console.error('invalid-captcha-response');
|
|
14472
|
-
// logError('invalid-captcha-response');
|
|
14473
|
-
return [2 /*return*/];
|
|
14474
|
-
}
|
|
14475
|
-
if (!isValidEmail(email)) return [3 /*break*/, 2];
|
|
14476
|
-
domain = email.split('@')[1] || '';
|
|
14477
|
-
return [4 /*yield*/, getMailExchanger(domain)];
|
|
14478
|
-
case 1:
|
|
14479
|
-
mailExchanger = _a.sent();
|
|
14480
|
-
supportedMailExchanger = mailExchanger !== null;
|
|
14481
|
-
if (supportedMailExchanger && loginTypes.includes(mailExchanger)) {
|
|
14482
|
-
recommendSocialLogin(email, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal);
|
|
14483
|
-
return [2 /*return*/];
|
|
14484
|
-
}
|
|
14485
|
-
_a.label = 2;
|
|
14486
|
-
case 2:
|
|
14487
|
-
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody);
|
|
14488
|
-
closeMagicLinkModal();
|
|
14489
|
-
return [2 /*return*/];
|
|
14425
|
+
const getMailExchanger = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14426
|
+
const data = yield getMXData(domainName);
|
|
14427
|
+
if (!data) {
|
|
14428
|
+
return null;
|
|
14429
|
+
}
|
|
14430
|
+
if (hasProvider(data, 'outlook.com')) {
|
|
14431
|
+
return 'Microsoft';
|
|
14432
|
+
}
|
|
14433
|
+
if (hasProvider(data, 'google.com')) {
|
|
14434
|
+
return 'Google';
|
|
14435
|
+
}
|
|
14436
|
+
return null;
|
|
14437
|
+
});
|
|
14438
|
+
const onMagicLinkRequest = (token, input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14439
|
+
const email = input.value;
|
|
14440
|
+
if (!email.includes('-test@') && !token) {
|
|
14441
|
+
console.error('invalid-captcha-response');
|
|
14442
|
+
// logError('invalid-captcha-response');
|
|
14443
|
+
return;
|
|
14444
|
+
}
|
|
14445
|
+
if (isValidEmail(email)) {
|
|
14446
|
+
const domain = email.split('@')[1] || '';
|
|
14447
|
+
const mailExchanger = yield getMailExchanger(domain);
|
|
14448
|
+
const supportedMailExchanger = mailExchanger !== null;
|
|
14449
|
+
if (supportedMailExchanger && loginTypes.includes(mailExchanger)) {
|
|
14450
|
+
recommendSocialLogin(email, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal);
|
|
14451
|
+
return;
|
|
14490
14452
|
}
|
|
14491
|
-
}
|
|
14492
|
-
|
|
14493
|
-
|
|
14453
|
+
}
|
|
14454
|
+
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody);
|
|
14455
|
+
closeMagicLinkModal();
|
|
14456
|
+
});
|
|
14457
|
+
const applyMagicEmailFieldStyle = (el) => {
|
|
14494
14458
|
el.style.display = 'flex';
|
|
14495
14459
|
el.style.flexFlow = 'column';
|
|
14496
14460
|
el.style.marginTop = '8px';
|
|
14497
14461
|
el.style.rowGap = '8px';
|
|
14498
14462
|
el.style.width = '100%';
|
|
14499
14463
|
};
|
|
14500
|
-
|
|
14501
|
-
input.style.border =
|
|
14464
|
+
const applyInputStyle = (input) => {
|
|
14465
|
+
input.style.border = `1px solid ${juxDarkGrey}`;
|
|
14502
14466
|
input.style.maxWidth = '390px';
|
|
14503
14467
|
input.style.padding = '10px';
|
|
14504
14468
|
input.style.width = '100%';
|
|
14505
14469
|
input.style.backgroundColor = juxWhite;
|
|
14506
14470
|
input.style.borderRadius = '8px';
|
|
14507
|
-
input.style.boxShadow =
|
|
14471
|
+
input.style.boxShadow = `inset 0 2px 3px ${juxDimmedDarkGrey}`;
|
|
14508
14472
|
input.style.height = '40px';
|
|
14509
14473
|
input.style.whiteSpace = 'pre-line';
|
|
14510
14474
|
input.style.boxSizing = 'border-box';
|
|
14511
14475
|
};
|
|
14512
|
-
|
|
14476
|
+
const applyBtnStyle = (btn) => {
|
|
14513
14477
|
btn.style.alignSelf = 'flex-end';
|
|
14514
14478
|
btn.style.backgroundColor = juxLightGreen;
|
|
14515
|
-
btn.style.border =
|
|
14479
|
+
btn.style.border = `2px solid ${juxLightGreen}`;
|
|
14516
14480
|
btn.style.borderRadius = '8px';
|
|
14517
14481
|
btn.style.color = juxWhite;
|
|
14518
14482
|
btn.style.cursor = 'pointer';
|
|
@@ -14524,121 +14488,99 @@ var juxWeb = (function (exports) {
|
|
|
14524
14488
|
btn.style.padding = '10px 16px';
|
|
14525
14489
|
btn.style.position = 'relative';
|
|
14526
14490
|
};
|
|
14527
|
-
|
|
14528
|
-
|
|
14491
|
+
const magicEmailField = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes) => {
|
|
14492
|
+
const result = document.createElement('magic-email-field');
|
|
14529
14493
|
applyMagicEmailFieldStyle(result);
|
|
14530
|
-
|
|
14531
|
-
|
|
14494
|
+
const captcha = googleCaptcha();
|
|
14495
|
+
const input = document.createElement('input');
|
|
14532
14496
|
input.id = 'mail-magic';
|
|
14533
14497
|
input.type = 'text';
|
|
14534
14498
|
input.className = 'textfield';
|
|
14535
14499
|
input.placeholder = 'e-mail';
|
|
14536
14500
|
applyInputStyle(input);
|
|
14537
|
-
input.addEventListener('keydown',
|
|
14501
|
+
input.addEventListener('keydown', (ev) => {
|
|
14538
14502
|
if (ev.key === 'Enter') {
|
|
14539
14503
|
onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes);
|
|
14540
14504
|
}
|
|
14541
14505
|
});
|
|
14542
|
-
|
|
14506
|
+
const btn = document.createElement('button');
|
|
14543
14507
|
applyBtnStyle(btn);
|
|
14544
14508
|
btn.id = 'send-magic';
|
|
14545
14509
|
btn.className = 'primary-button';
|
|
14546
|
-
btn.addEventListener('click',
|
|
14510
|
+
btn.addEventListener('click', (_ev) => onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes));
|
|
14547
14511
|
btn.textContent = getTranslation('send-magic');
|
|
14548
14512
|
result.append(input, captcha, btn);
|
|
14549
14513
|
return result;
|
|
14550
14514
|
};
|
|
14551
14515
|
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14516
|
+
const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, loginTypes) => {
|
|
14517
|
+
const result = document.createElement('magic-link-modal');
|
|
14518
|
+
const subtitle = document.createElement('magic-link-request-subtitle');
|
|
14555
14519
|
subtitle.style.fontSize = '14px';
|
|
14556
14520
|
subtitle.textContent = getTranslation('magic-link-request-subtitle');
|
|
14557
|
-
|
|
14558
|
-
body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody,
|
|
14559
|
-
|
|
14521
|
+
const body = document.createElement('magic-link-request-body');
|
|
14522
|
+
body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody, () => result.remove(), loginTypes));
|
|
14523
|
+
const modal = juxModal(getTranslation('magic-link-request-title'), [], '', false, false, body, '', '', () => result.remove());
|
|
14560
14524
|
modal.setAttribute('data-cy', 'magic-link-modal');
|
|
14561
14525
|
result.appendChild(modal);
|
|
14562
|
-
|
|
14526
|
+
const wrapper = modal.querySelector('modal-wrapper');
|
|
14563
14527
|
wrapper.style.maxWidth = '360px';
|
|
14564
14528
|
wrapper.style.width = '100%';
|
|
14565
14529
|
return result;
|
|
14566
14530
|
};
|
|
14567
14531
|
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
container.style.borderRadius = '16px';
|
|
14571
|
-
container.style.inset = '50% 50% 50% 0';
|
|
14572
|
-
container.style.position = 'relative';
|
|
14573
|
-
container.style.transform = 'translateY(-50%)';
|
|
14574
|
-
container.style.width = '620px';
|
|
14575
|
-
container.style.alignItems = 'center';
|
|
14576
|
-
container.style.display = 'flex';
|
|
14577
|
-
container.style.flexDirection = 'column';
|
|
14578
|
-
container.style.fontSize = '16px';
|
|
14579
|
-
container.style.height = '100%';
|
|
14580
|
-
container.style.justifyContent = 'center';
|
|
14581
|
-
container.style.margin = '0 auto';
|
|
14582
|
-
container.style.paddingTop = '0';
|
|
14583
|
-
};
|
|
14584
|
-
var applyPageStyles = function (page) {
|
|
14585
|
-
page.style.backgroundPosition = '50%';
|
|
14586
|
-
page.style.backgroundSize = 'cover';
|
|
14587
|
-
page.style.display = 'block';
|
|
14588
|
-
page.style.height = '100%';
|
|
14589
|
-
};
|
|
14590
|
-
var onEmailLoginRequest = function (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) {
|
|
14591
|
-
var onReturn = function () { return clientApp.appendChild(loginPage); };
|
|
14532
|
+
const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) => {
|
|
14533
|
+
const onReturn = () => clientApp.appendChild(loginPage);
|
|
14592
14534
|
loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes));
|
|
14593
14535
|
};
|
|
14594
|
-
|
|
14536
|
+
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes, backgroundImg) => {
|
|
14595
14537
|
if (loginTypes.includes('Google')) {
|
|
14596
|
-
section.appendChild(loginButton('Google',
|
|
14538
|
+
section.appendChild(loginButton('Google', () => onGoogleSignIn(onUserLogin)));
|
|
14597
14539
|
}
|
|
14598
14540
|
if (loginTypes.includes('Microsoft')) {
|
|
14599
|
-
section.appendChild(loginButton('Microsoft',
|
|
14541
|
+
section.appendChild(loginButton('Microsoft', () => onMicrosoftSignIn(onUserLogin)));
|
|
14600
14542
|
}
|
|
14601
14543
|
if (loginTypes.includes('Linkedin')) {
|
|
14602
|
-
section.appendChild(loginButton('LinkedIn',
|
|
14544
|
+
section.appendChild(loginButton('LinkedIn', () => console.log('login with Linkedin')));
|
|
14603
14545
|
}
|
|
14604
14546
|
if (loginTypes.includes('Email')) {
|
|
14605
|
-
section.appendChild(loginButton('Email',
|
|
14547
|
+
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
14606
14548
|
}
|
|
14607
14549
|
};
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
var section = document.createElement('section');
|
|
14612
|
-
applyContainerStyles(section);
|
|
14613
|
-
var salutation = document.createElement('sign-in-salutation');
|
|
14550
|
+
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
14551
|
+
const content = [];
|
|
14552
|
+
const salutation = document.createElement('sign-in-salutation');
|
|
14614
14553
|
salutation.textContent = getTranslation('sign-in-salutation');
|
|
14615
|
-
|
|
14554
|
+
const explanation = document.createElement('sign-in-explanation');
|
|
14616
14555
|
explanation.textContent = getTranslation('sign-in-explanation');
|
|
14617
|
-
|
|
14556
|
+
const msg = document.createElement('sign-in-msg');
|
|
14618
14557
|
msg.textContent = getTranslation('sign-in-msg-general');
|
|
14619
|
-
|
|
14620
|
-
|
|
14558
|
+
content.push(salutation, explanation, msg);
|
|
14559
|
+
const result = basePage('login-page', backgroundImg, content);
|
|
14560
|
+
const section = result.querySelector('section');
|
|
14621
14561
|
appendLoginTypes(result, section, clientApp, onUserLogin, loginTypes, backgroundImg);
|
|
14622
|
-
result.appendChild(section);
|
|
14623
14562
|
return result;
|
|
14624
14563
|
};
|
|
14625
14564
|
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14565
|
+
class JuxEvent extends Event {
|
|
14566
|
+
constructor(method, endpoint, onResult, params, onError) {
|
|
14567
|
+
super('jux-event', { bubbles: true, cancelable: true, composed: true });
|
|
14568
|
+
this.method = method;
|
|
14569
|
+
this.endpoint = endpoint;
|
|
14570
|
+
this.onResult = onResult;
|
|
14571
|
+
this.params = params;
|
|
14572
|
+
this.onError = onError;
|
|
14634
14573
|
}
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14574
|
+
}
|
|
14575
|
+
const query = (element, endpoint, onResult, params, onError) => {
|
|
14576
|
+
element.dispatchEvent(new JuxEvent('GET', endpoint, onResult, params, onError));
|
|
14577
|
+
};
|
|
14578
|
+
const command = (element, endpoint, onResult, params, onError) => {
|
|
14579
|
+
element.dispatchEvent(new JuxEvent('POST', endpoint, onResult, params, onError));
|
|
14639
14580
|
};
|
|
14640
14581
|
|
|
14641
14582
|
exports.chosenLanguage = chosenLanguage;
|
|
14583
|
+
exports.command = command;
|
|
14642
14584
|
exports.getTranslation = getTranslation;
|
|
14643
14585
|
exports.handleMagicLinkRequest = handleMagicLinkRequest;
|
|
14644
14586
|
exports.initLanguage = initLanguage;
|