@klauswuestefeld/jux-web 2024.2.2 → 2024.2.5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jux/query.d.ts +1 -0
- package/dist/jux-web.js +385 -458
- package/dist/main.d.ts +1 -0
- package/dist/main.esm.js +384 -458
- package/dist/main.js +384 -457
- package/package.json +1 -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
|
});
|
|
@@ -111,54 +110,25 @@ var juxWeb = (function (exports) {
|
|
|
111
110
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
112
111
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
113
112
|
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function __generator$2(thisArg, body) {
|
|
117
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
118
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
119
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
120
|
-
function step(op) {
|
|
121
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
122
|
-
while (_) try {
|
|
123
|
-
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;
|
|
124
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
125
|
-
switch (op[0]) {
|
|
126
|
-
case 0: case 1: t = op; break;
|
|
127
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
128
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
129
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
130
|
-
default:
|
|
131
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
132
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
133
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
134
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
135
|
-
if (t[2]) _.ops.pop();
|
|
136
|
-
_.trys.pop(); continue;
|
|
137
|
-
}
|
|
138
|
-
op = body.call(thisArg, _);
|
|
139
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
140
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
141
|
-
}
|
|
142
113
|
}
|
|
143
114
|
|
|
144
|
-
|
|
145
|
-
if (additionalParam === void 0) { additionalParam = ''; }
|
|
115
|
+
const extractTokenFromWindowLocation = (tokenParam, additionalParam = '') => {
|
|
146
116
|
if (!tokenParam)
|
|
147
117
|
return;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
118
|
+
let token = '';
|
|
119
|
+
const tokenParameterName = `${tokenParam}=`;
|
|
120
|
+
const search = window.location.search;
|
|
121
|
+
const tokenParameterIndex = search.indexOf(tokenParameterName);
|
|
152
122
|
if (tokenParameterIndex !== -1) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
123
|
+
const tokenParameterNameLength = tokenParameterName.length;
|
|
124
|
+
const leadingAmpersandIndex = search.indexOf('&', tokenParameterIndex);
|
|
125
|
+
let searchWithoutToken = search;
|
|
156
126
|
token = search.substring(tokenParameterIndex + tokenParameterNameLength);
|
|
157
127
|
if (leadingAmpersandIndex !== -1) {
|
|
158
128
|
token = search.substring(tokenParameterIndex + tokenParameterNameLength, leadingAmpersandIndex);
|
|
159
129
|
searchWithoutToken = searchWithoutToken.slice(0, leadingAmpersandIndex) + searchWithoutToken.slice(leadingAmpersandIndex + 1);
|
|
160
130
|
}
|
|
161
|
-
searchWithoutToken = searchWithoutToken.replace(
|
|
131
|
+
searchWithoutToken = searchWithoutToken.replace(`${tokenParam}=` + token, '')
|
|
162
132
|
.replace(additionalParam, '')
|
|
163
133
|
.replace('\&cypress=true', '');
|
|
164
134
|
if (searchWithoutToken === '?') {
|
|
@@ -169,31 +139,31 @@ var juxWeb = (function (exports) {
|
|
|
169
139
|
return token;
|
|
170
140
|
};
|
|
171
141
|
|
|
172
|
-
|
|
142
|
+
const setBackendUrl = (backendUrl) => localStorage.setItem('backend-url', backendUrl);
|
|
173
143
|
//@ts-ignore
|
|
174
|
-
|
|
144
|
+
const getBackendUrl = () => process.env.BACKEND_URL || localStorage.getItem('backend-url');
|
|
175
145
|
//@ts-ignore
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
146
|
+
const getSecondaryBackendUrl = () => process.env.STAGING_BACKEND_URL || getBackendUrl();
|
|
147
|
+
let getBackendUrlToTry = () => getBackendUrl();
|
|
148
|
+
const getApiUrl = () => getBackendUrl() + 'api/';
|
|
149
|
+
const getGoogleAuthUrl = () => getBackendUrl() + 'auth-google?google-id-token=';
|
|
150
|
+
const getMicrosoftAuthUrl = () => getBackendUrl() + 'auth-microsoft?access-token=';
|
|
151
|
+
const getMagicAuthUrl = () => {
|
|
182
152
|
var _a;
|
|
183
153
|
// @ts-ignore
|
|
184
|
-
|
|
154
|
+
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkAuthEndpoint) || 'auth-magic';
|
|
185
155
|
return getBackendUrl() + endpoint + '?token=';
|
|
186
156
|
};
|
|
187
|
-
|
|
157
|
+
const getMagicAuthReqUrl = () => {
|
|
188
158
|
var _a;
|
|
189
159
|
// @ts-ignore
|
|
190
|
-
|
|
160
|
+
const endpoint = ((_a = window === null || window === void 0 ? void 0 : window.store) === null || _a === void 0 ? void 0 : _a.magicLinkRequestEndpoint) || 'magic-link-request';
|
|
191
161
|
return getBackendUrl() + endpoint + '?email=';
|
|
192
162
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
163
|
+
let timeout;
|
|
164
|
+
const maxRetries = 20;
|
|
165
|
+
let retries = 0;
|
|
166
|
+
const applySpinnerStyle = (spinner) => {
|
|
197
167
|
spinner.style.position = 'fixed';
|
|
198
168
|
spinner.style.top = '50%';
|
|
199
169
|
spinner.style.zIndex = '2147483647';
|
|
@@ -202,22 +172,22 @@ var juxWeb = (function (exports) {
|
|
|
202
172
|
spinner.style.height = '80px';
|
|
203
173
|
spinner.style.width = '80px';
|
|
204
174
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
175
|
+
const renderOverlay = () => {
|
|
176
|
+
const overlay = document.createElement('reconnect-overlay');
|
|
177
|
+
const spinner = document.createElement('loading-spinner');
|
|
208
178
|
spinner.className = 'reconnect-spinner';
|
|
209
179
|
applySpinnerStyle(spinner);
|
|
210
180
|
document.body.append(overlay, spinner);
|
|
211
181
|
};
|
|
212
|
-
|
|
182
|
+
const removeOverlay = () => {
|
|
213
183
|
var _a, _b;
|
|
214
184
|
(_a = document.querySelector('reconnect-overlay')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
215
185
|
(_b = document.querySelector('.reconnect-spinner')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
216
186
|
};
|
|
217
|
-
|
|
187
|
+
const backendHelpMessage = (req) => {
|
|
218
188
|
return req.response && req.response.error || req.response || req;
|
|
219
189
|
};
|
|
220
|
-
|
|
190
|
+
const backendRequest = (requestType, url, postContent, onJsonResponse, onHelpMessage) => {
|
|
221
191
|
if (url.includes(getBackendUrl())) {
|
|
222
192
|
url = url.replace(getBackendUrl(), getBackendUrlToTry());
|
|
223
193
|
}
|
|
@@ -225,16 +195,16 @@ var juxWeb = (function (exports) {
|
|
|
225
195
|
url = url.replace(getSecondaryBackendUrl(), getBackendUrlToTry());
|
|
226
196
|
}
|
|
227
197
|
clearInterval(timeout);
|
|
228
|
-
|
|
198
|
+
const req = new XMLHttpRequest();
|
|
229
199
|
req.open(requestType, url, true);
|
|
230
200
|
// @ts-ignore
|
|
231
|
-
|
|
201
|
+
const backendToken = window.store.backendToken;
|
|
232
202
|
if (backendToken) {
|
|
233
203
|
req.setRequestHeader('auth', backendToken);
|
|
234
204
|
}
|
|
235
205
|
req.setRequestHeader('Content-Type', 'application/json');
|
|
236
206
|
req.responseType = 'json';
|
|
237
|
-
req.onerror = req.ontimeout =
|
|
207
|
+
req.onerror = req.ontimeout = () => {
|
|
238
208
|
if (req.status === 401) {
|
|
239
209
|
localStorage.removeItem('token');
|
|
240
210
|
alert(getTranslation('session-expired-msg'));
|
|
@@ -251,12 +221,12 @@ var juxWeb = (function (exports) {
|
|
|
251
221
|
if (!document.querySelector('reconnect-overlay')) {
|
|
252
222
|
renderOverlay();
|
|
253
223
|
}
|
|
254
|
-
|
|
224
|
+
const backupBackendUrl = getBackendUrlToTry() === getBackendUrl()
|
|
255
225
|
? getSecondaryBackendUrl()
|
|
256
226
|
: getBackendUrl();
|
|
257
|
-
url = url.replace(getBackendUrlToTry(),
|
|
258
|
-
getBackendUrlToTry =
|
|
259
|
-
timeout = setTimeout(
|
|
227
|
+
url = url.replace(getBackendUrlToTry(), backupBackendUrl);
|
|
228
|
+
getBackendUrlToTry = () => backupBackendUrl;
|
|
229
|
+
timeout = setTimeout(() => {
|
|
260
230
|
backendRequest(requestType, url, postContent, onJsonResponse, onHelpMessage);
|
|
261
231
|
}, 2000);
|
|
262
232
|
}
|
|
@@ -264,7 +234,7 @@ var juxWeb = (function (exports) {
|
|
|
264
234
|
onHelpMessage(backendHelpMessage(req));
|
|
265
235
|
}
|
|
266
236
|
};
|
|
267
|
-
req.onload =
|
|
237
|
+
req.onload = () => {
|
|
268
238
|
retries = 0;
|
|
269
239
|
removeOverlay();
|
|
270
240
|
if (req.status === 200 || req.status === 202) {
|
|
@@ -280,57 +250,45 @@ var juxWeb = (function (exports) {
|
|
|
280
250
|
req.timeout = 25000;
|
|
281
251
|
req.send(postContent);
|
|
282
252
|
};
|
|
283
|
-
|
|
253
|
+
const backendPost = (endpoint, postContent, onJsonResponse, onHelpMessage) => {
|
|
284
254
|
backendRequest('POST', getApiUrl() + endpoint, postContent, onJsonResponse, onHelpMessage);
|
|
285
255
|
};
|
|
286
|
-
|
|
287
|
-
|
|
256
|
+
const backendGet = (endpoint, onJsonResponse, onHelpMessage) => {
|
|
257
|
+
let api = getApiUrl() + endpoint;
|
|
288
258
|
if (endpoint.includes(getGoogleAuthUrl()) || endpoint.includes(getMicrosoftAuthUrl())) {
|
|
289
259
|
api = endpoint;
|
|
290
260
|
}
|
|
291
261
|
backendRequest('GET', api, undefined, onJsonResponse, onHelpMessage);
|
|
292
262
|
};
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var requestMagicLink = function (data, onJsonResponse) {
|
|
297
|
-
backendRequest('GET', getMagicAuthReqUrl() + encodeURIComponent(data.email) + '&destination=' + extractTokenFromWindowLocation('destination') + '&token=' + data.token, undefined, onJsonResponse, function () { });
|
|
263
|
+
const backendGetPromise = (endpoint) => new Promise((resolve, reject) => backendGet(endpoint, resolve, reject));
|
|
264
|
+
const requestMagicLink = (data, onJsonResponse) => {
|
|
265
|
+
backendRequest('GET', getMagicAuthReqUrl() + encodeURIComponent(data.email) + '&destination=' + extractTokenFromWindowLocation('destination') + '&token=' + data.token, undefined, onJsonResponse, () => { });
|
|
298
266
|
};
|
|
299
|
-
|
|
267
|
+
const openMagicLink = (magicToken, onJsonResponse, onHelpMessage) => {
|
|
300
268
|
backendRequest('GET', getMagicAuthUrl() + magicToken, undefined, onJsonResponse, onHelpMessage);
|
|
301
269
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
})];
|
|
312
|
-
case 1:
|
|
313
|
-
records = _a.sent();
|
|
314
|
-
if (!records.ok) {
|
|
315
|
-
console.log('response was not ok');
|
|
316
|
-
return [2 /*return*/, null];
|
|
317
|
-
}
|
|
318
|
-
return [4 /*yield*/, records.json()];
|
|
319
|
-
case 2:
|
|
320
|
-
recordsJson = _a.sent();
|
|
321
|
-
answer = recordsJson.Answer;
|
|
322
|
-
if (!answer) {
|
|
323
|
-
return [2 /*return*/, null];
|
|
324
|
-
}
|
|
325
|
-
return [2 /*return*/, Array.from(answer).map(function (a) { return a.data; })];
|
|
326
|
-
case 3:
|
|
327
|
-
error_1 = _a.sent();
|
|
328
|
-
console.error('Fetch failed: ', error_1);
|
|
329
|
-
return [2 /*return*/, null];
|
|
330
|
-
case 4: return [2 /*return*/];
|
|
270
|
+
const getMXData = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
271
|
+
try {
|
|
272
|
+
const records = yield fetch(`https://dns.google.com/resolve?name=${domainName}&type=MX`, {
|
|
273
|
+
method: 'GET',
|
|
274
|
+
mode: 'cors'
|
|
275
|
+
});
|
|
276
|
+
if (!records.ok) {
|
|
277
|
+
console.log('response was not ok');
|
|
278
|
+
return null;
|
|
331
279
|
}
|
|
332
|
-
|
|
333
|
-
|
|
280
|
+
const recordsJson = yield records.json();
|
|
281
|
+
const answer = recordsJson.Answer;
|
|
282
|
+
if (!answer) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
return Array.from(answer).map((a) => a.data);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
console.error('Fetch failed: ', error);
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
334
292
|
|
|
335
293
|
/*! @azure/msal-browser v2.21.0 2022-01-04 */
|
|
336
294
|
/*! *****************************************************************************
|
|
@@ -13651,13 +13609,13 @@ var juxWeb = (function (exports) {
|
|
|
13651
13609
|
return PublicClientApplication;
|
|
13652
13610
|
}(ClientApplication));
|
|
13653
13611
|
|
|
13654
|
-
|
|
13655
|
-
|
|
13612
|
+
let cleared = false;
|
|
13613
|
+
const clearCookieValidation = () => {
|
|
13656
13614
|
var _a;
|
|
13657
13615
|
(_a = document.querySelector('#cookie-test-iframe')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
13658
13616
|
cleared = true;
|
|
13659
13617
|
};
|
|
13660
|
-
|
|
13618
|
+
const checkCookiesEnable = (ev, onEnabled, onDisabled) => {
|
|
13661
13619
|
if (ev.data === 'MM:3PCunsupported') {
|
|
13662
13620
|
clearCookieValidation();
|
|
13663
13621
|
if (onDisabled) {
|
|
@@ -13669,18 +13627,18 @@ var juxWeb = (function (exports) {
|
|
|
13669
13627
|
onEnabled();
|
|
13670
13628
|
}
|
|
13671
13629
|
};
|
|
13672
|
-
|
|
13673
|
-
|
|
13630
|
+
const cookieTest = () => {
|
|
13631
|
+
const frame = document.createElement('iframe');
|
|
13674
13632
|
frame.id = 'cookie-test-iframe';
|
|
13675
13633
|
frame.src = 'https://mindmup.github.io/3rdpartycookiecheck/start.html';
|
|
13676
13634
|
frame.style.display = 'none';
|
|
13677
13635
|
document.body.appendChild(frame);
|
|
13678
13636
|
};
|
|
13679
|
-
|
|
13637
|
+
const validateThirdPartyCookies = (onEnabled, onDisabled) => {
|
|
13680
13638
|
cleared = false;
|
|
13681
|
-
|
|
13639
|
+
const listener = (ev) => checkCookiesEnable(ev, onEnabled, onDisabled);
|
|
13682
13640
|
window.addEventListener('message', listener);
|
|
13683
|
-
|
|
13641
|
+
const timer = setInterval(() => {
|
|
13684
13642
|
if (cleared) {
|
|
13685
13643
|
window.removeEventListener('message', listener);
|
|
13686
13644
|
clearInterval(timer);
|
|
@@ -13689,26 +13647,26 @@ var juxWeb = (function (exports) {
|
|
|
13689
13647
|
cookieTest();
|
|
13690
13648
|
};
|
|
13691
13649
|
|
|
13692
|
-
|
|
13650
|
+
const enableSignInLayout = () => {
|
|
13693
13651
|
document.documentElement.style.cursor = 'progress';
|
|
13694
13652
|
document.body.style.opacity = '0.5';
|
|
13695
13653
|
document.body.style.pointerEvents = 'none';
|
|
13696
13654
|
};
|
|
13697
|
-
|
|
13655
|
+
const disableSignInLayout = () => {
|
|
13698
13656
|
document.documentElement.style.cursor = 'default';
|
|
13699
13657
|
document.body.style.opacity = '1';
|
|
13700
13658
|
document.body.style.pointerEvents = 'auto';
|
|
13701
13659
|
};
|
|
13702
13660
|
|
|
13703
13661
|
// TODO: find a better way to import external scripts
|
|
13704
|
-
|
|
13662
|
+
const script$1 = document.createElement('script');
|
|
13705
13663
|
script$1.type = 'text/javascript';
|
|
13706
13664
|
script$1.src = 'https://apis.google.com/js/api.js';
|
|
13707
13665
|
document.head.appendChild(script$1);
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13666
|
+
let authStatus;
|
|
13667
|
+
let authError;
|
|
13668
|
+
const highLevelUser = (gUser) => {
|
|
13669
|
+
const profile = gUser.getBasicProfile();
|
|
13712
13670
|
return {
|
|
13713
13671
|
name: profile.getName(),
|
|
13714
13672
|
email: profile.getEmail(),
|
|
@@ -13716,62 +13674,54 @@ var juxWeb = (function (exports) {
|
|
|
13716
13674
|
googletoken: gUser.getAuthResponse().id_token
|
|
13717
13675
|
};
|
|
13718
13676
|
};
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
// @ts-ignore
|
|
13734
|
-
window.store.currentUser = res;
|
|
13735
|
-
onTokenAcquired(token, onUserLogin);
|
|
13736
|
-
})
|
|
13737
|
-
.catch(function (error) { throw Error(error); })];
|
|
13738
|
-
case 2:
|
|
13739
|
-
_a.sent();
|
|
13740
|
-
return [3 /*break*/, 4];
|
|
13741
|
-
case 3:
|
|
13742
|
-
error_1 = _a.sent();
|
|
13743
|
-
console.error(error_1);
|
|
13744
|
-
// logError(error); TODO
|
|
13745
|
-
// checkMixpanel(() => mixpanel.track('Login Error', { 'Login Type': 'Google', 'Error': error })); TODO
|
|
13746
|
-
return [2 /*return*/];
|
|
13747
|
-
case 4: return [3 /*break*/, 6];
|
|
13748
|
-
case 5:
|
|
13749
|
-
setBackendToken('');
|
|
13750
|
-
_a.label = 6;
|
|
13751
|
-
case 6: return [2 /*return*/];
|
|
13677
|
+
const onUserChanged = (googleUser, onUserLogin) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
13678
|
+
document.documentElement.classList.remove('progress');
|
|
13679
|
+
document.body.classList.remove('disabled');
|
|
13680
|
+
if (googleUser) {
|
|
13681
|
+
// mixpanelIdentify(googleUser); TODO
|
|
13682
|
+
try {
|
|
13683
|
+
yield backendGetPromise(getGoogleAuthUrl() + googleUser.googletoken)
|
|
13684
|
+
.then(res => {
|
|
13685
|
+
const { token } = res;
|
|
13686
|
+
// @ts-ignore
|
|
13687
|
+
window.store.currentUser = res;
|
|
13688
|
+
onTokenAcquired(token, onUserLogin);
|
|
13689
|
+
})
|
|
13690
|
+
.catch((error) => { throw Error(error); });
|
|
13752
13691
|
}
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13692
|
+
catch (error) {
|
|
13693
|
+
console.error(error);
|
|
13694
|
+
// logError(error); TODO
|
|
13695
|
+
// checkMixpanel(() => mixpanel.track('Login Error', { 'Login Type': 'Google', 'Error': error })); TODO
|
|
13696
|
+
return;
|
|
13697
|
+
}
|
|
13698
|
+
// checkMixpanel(() => mixpanel.track('Login', { 'Login Type': 'Google' })); TODO
|
|
13699
|
+
}
|
|
13700
|
+
else {
|
|
13701
|
+
setBackendToken('');
|
|
13702
|
+
// checkMixpanel(() => mixpanel.reset()); TODO
|
|
13703
|
+
// displayPage(Page.LOGIN); TODO
|
|
13704
|
+
}
|
|
13705
|
+
});
|
|
13706
|
+
const onGoogleUserChanged = (gUser, onUserLogin) => {
|
|
13756
13707
|
onUserChanged(gUser.isSignedIn() ? highLevelUser(gUser) : null, onUserLogin);
|
|
13757
13708
|
};
|
|
13758
|
-
|
|
13709
|
+
const initGapiClient = (callbackFn, onUserLogin) => {
|
|
13759
13710
|
// @ts-ignore
|
|
13760
|
-
|
|
13761
|
-
gapi.auth2.init({ client_id: clientId, prompt: 'select_account' }).then(
|
|
13711
|
+
const clientId = process.env.GOOGLE_CLIENT_ID;
|
|
13712
|
+
gapi.auth2.init({ client_id: clientId, prompt: 'select_account' }).then(() => {
|
|
13762
13713
|
authStatus = 'LOADED';
|
|
13763
|
-
|
|
13714
|
+
const currentUser = getAuth().currentUser;
|
|
13764
13715
|
currentUser.listen(onGoogleUserChanged);
|
|
13765
13716
|
callbackFn ? callbackFn(clientId) : onGoogleUserChanged(currentUser.get(), onUserLogin);
|
|
13766
13717
|
}, onAuthError);
|
|
13767
13718
|
};
|
|
13768
|
-
|
|
13719
|
+
const onAuthError = (error) => {
|
|
13769
13720
|
authError = error;
|
|
13770
13721
|
console.error(error);
|
|
13771
13722
|
// logError(error, authError); // TODO
|
|
13772
13723
|
};
|
|
13773
|
-
|
|
13774
|
-
if (callbackFn === void 0) { callbackFn = null; }
|
|
13724
|
+
const initGapi = (callbackFn = null, onUserLogin) => {
|
|
13775
13725
|
if (!window.location.protocol.startsWith('http')) {
|
|
13776
13726
|
onAuthError('To use Google Auth you must access this page using http(s), not ' + window.location.protocol);
|
|
13777
13727
|
return;
|
|
@@ -13782,27 +13732,27 @@ var juxWeb = (function (exports) {
|
|
|
13782
13732
|
}
|
|
13783
13733
|
authStatus = 'LOADING';
|
|
13784
13734
|
gapi.load('auth2', {
|
|
13785
|
-
callback:
|
|
13735
|
+
callback: () => initGapiClient(callbackFn, onUserLogin),
|
|
13786
13736
|
onerror: onAuthError,
|
|
13787
13737
|
ontimeout: onAuthError,
|
|
13788
13738
|
timeout: 5000
|
|
13789
13739
|
});
|
|
13790
13740
|
};
|
|
13791
|
-
|
|
13741
|
+
const authAlert = (error) => {
|
|
13792
13742
|
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));
|
|
13793
13743
|
location.reload();
|
|
13794
13744
|
};
|
|
13795
|
-
|
|
13745
|
+
const onSignInError = (error) => {
|
|
13796
13746
|
disableSignInLayout();
|
|
13797
13747
|
console.error(error);
|
|
13798
13748
|
// logError(error); TODO
|
|
13799
13749
|
if (error && error.error === 'popup_closed_by_user') {
|
|
13800
|
-
onUserChanged(null,
|
|
13750
|
+
onUserChanged(null, () => { });
|
|
13801
13751
|
return;
|
|
13802
13752
|
}
|
|
13803
13753
|
authAlert(error);
|
|
13804
13754
|
};
|
|
13805
|
-
|
|
13755
|
+
const getAuth = () => {
|
|
13806
13756
|
if (typeof gapi === 'undefined') {
|
|
13807
13757
|
console.error('gapi is undefined');
|
|
13808
13758
|
// logError('gapi is undefined'); TODO
|
|
@@ -13810,8 +13760,8 @@ var juxWeb = (function (exports) {
|
|
|
13810
13760
|
}
|
|
13811
13761
|
return gapi.auth2 && gapi.auth2.getAuthInstance();
|
|
13812
13762
|
};
|
|
13813
|
-
|
|
13814
|
-
|
|
13763
|
+
const googleSignIn = () => getAuth().signIn().catch(onSignInError);
|
|
13764
|
+
const authSignIn = (onUserLogin) => {
|
|
13815
13765
|
if (authError) {
|
|
13816
13766
|
authAlert(authError);
|
|
13817
13767
|
return;
|
|
@@ -13825,7 +13775,7 @@ var juxWeb = (function (exports) {
|
|
|
13825
13775
|
}
|
|
13826
13776
|
catch (err) {
|
|
13827
13777
|
try {
|
|
13828
|
-
initGapi(
|
|
13778
|
+
initGapi(() => googleSignIn(), onUserLogin);
|
|
13829
13779
|
}
|
|
13830
13780
|
catch (error) {
|
|
13831
13781
|
onSignInError(error);
|
|
@@ -13835,13 +13785,13 @@ var juxWeb = (function (exports) {
|
|
|
13835
13785
|
};
|
|
13836
13786
|
|
|
13837
13787
|
// TODO: find a better way to import external scripts
|
|
13838
|
-
|
|
13788
|
+
const script = document.createElement('script');
|
|
13839
13789
|
script.type = 'text/javascript';
|
|
13840
13790
|
script.src = 'https://www.google.com/recaptcha/api.js';
|
|
13841
13791
|
document.head.appendChild(script);
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
window.submitCaptcha =
|
|
13792
|
+
const googleCaptcha = () => {
|
|
13793
|
+
const result = document.createElement('google-captcha');
|
|
13794
|
+
window.submitCaptcha = (token) => result.setAttribute('token', token);
|
|
13845
13795
|
result.className = 'g-recaptcha';
|
|
13846
13796
|
// @ts-ignore
|
|
13847
13797
|
result.setAttribute('data-sitekey', process.env.GOOGLE_CAPTCHA_KEY);
|
|
@@ -13850,14 +13800,14 @@ var juxWeb = (function (exports) {
|
|
|
13850
13800
|
return result;
|
|
13851
13801
|
};
|
|
13852
13802
|
|
|
13853
|
-
|
|
13854
|
-
|
|
13855
|
-
|
|
13856
|
-
|
|
13857
|
-
|
|
13858
|
-
|
|
13803
|
+
const juxWhite = '#FFF';
|
|
13804
|
+
const juxDarkGrey = '#282828';
|
|
13805
|
+
const juxDimmedDarkGrey = '#28282822';
|
|
13806
|
+
const juxDimmedBlack = '#00000088';
|
|
13807
|
+
const juxLightGreen = '#20B03D';
|
|
13808
|
+
const juxMediumGreen = '#0D631E';
|
|
13859
13809
|
|
|
13860
|
-
|
|
13810
|
+
const onKeyDown = (ev, el, persitent, onClose) => {
|
|
13861
13811
|
if (ev.key === 'Escape') {
|
|
13862
13812
|
if (persitent) {
|
|
13863
13813
|
return;
|
|
@@ -13871,34 +13821,34 @@ var juxWeb = (function (exports) {
|
|
|
13871
13821
|
el.dispatchEvent(new CustomEvent('ok'));
|
|
13872
13822
|
}
|
|
13873
13823
|
};
|
|
13874
|
-
|
|
13824
|
+
const close = (el, onClose) => {
|
|
13875
13825
|
el.remove();
|
|
13876
13826
|
if (onClose) {
|
|
13877
13827
|
onClose();
|
|
13878
13828
|
}
|
|
13879
13829
|
};
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click',
|
|
13830
|
+
const attachEventHandlers = (el, persitent, onClose) => {
|
|
13831
|
+
const cancelButton = el.querySelector('.cancel');
|
|
13832
|
+
cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click', (_e) => {
|
|
13883
13833
|
el.dispatchEvent(new CustomEvent('cancel'));
|
|
13884
13834
|
if (el.hasAttribute('dont-remove')) {
|
|
13885
13835
|
return;
|
|
13886
13836
|
}
|
|
13887
13837
|
close(el, onClose);
|
|
13888
13838
|
});
|
|
13889
|
-
|
|
13839
|
+
const closeButton = el.querySelector('.close');
|
|
13890
13840
|
if (closeButton) {
|
|
13891
|
-
closeButton.addEventListener('click',
|
|
13841
|
+
closeButton.addEventListener('click', (_e) => {
|
|
13892
13842
|
close(el, onClose);
|
|
13893
13843
|
});
|
|
13894
13844
|
}
|
|
13895
|
-
|
|
13896
|
-
okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click',
|
|
13845
|
+
const okButton = el.querySelector('.ok');
|
|
13846
|
+
okButton === null || okButton === void 0 ? void 0 : okButton.addEventListener('click', (_e) => {
|
|
13897
13847
|
el.dispatchEvent(new CustomEvent('ok'));
|
|
13898
13848
|
});
|
|
13899
|
-
el.removeEventListener('keydown',
|
|
13900
|
-
el.addEventListener('keydown',
|
|
13901
|
-
el === null || el === void 0 ? void 0 : el.addEventListener('click',
|
|
13849
|
+
el.removeEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
|
|
13850
|
+
el.addEventListener('keydown', (ev) => onKeyDown(ev, el, persitent, () => onClose));
|
|
13851
|
+
el === null || el === void 0 ? void 0 : el.addEventListener('click', (e) => {
|
|
13902
13852
|
if (e.target === el) {
|
|
13903
13853
|
if (persitent) {
|
|
13904
13854
|
return;
|
|
@@ -13920,11 +13870,11 @@ var juxWeb = (function (exports) {
|
|
|
13920
13870
|
// onClose?: any,
|
|
13921
13871
|
// titleStyle?: string,
|
|
13922
13872
|
// }
|
|
13923
|
-
|
|
13873
|
+
const applyWrapperStyle = (wrapper) => {
|
|
13924
13874
|
wrapper.style.alignItems = 'center';
|
|
13925
13875
|
wrapper.style.backgroundColor = juxWhite;
|
|
13926
13876
|
wrapper.style.borderRadius = '.3125rem';
|
|
13927
|
-
wrapper.style.boxShadow =
|
|
13877
|
+
wrapper.style.boxShadow = `0 0 1.33rem ${juxDimmedBlack}`;
|
|
13928
13878
|
wrapper.style.boxSizing = 'content-box';
|
|
13929
13879
|
wrapper.style.display = 'flex';
|
|
13930
13880
|
wrapper.style.flexDirection = 'column';
|
|
@@ -13936,7 +13886,7 @@ var juxWeb = (function (exports) {
|
|
|
13936
13886
|
wrapper.style.padding = '1.33rem';
|
|
13937
13887
|
wrapper.style.position = 'relative';
|
|
13938
13888
|
};
|
|
13939
|
-
|
|
13889
|
+
const applyModalStyle = (modal) => {
|
|
13940
13890
|
modal.style.alignItems = 'center';
|
|
13941
13891
|
modal.style.backgroundColor = juxDimmedBlack;
|
|
13942
13892
|
modal.style.display = 'flex';
|
|
@@ -13949,7 +13899,7 @@ var juxWeb = (function (exports) {
|
|
|
13949
13899
|
modal.style.width = '100%';
|
|
13950
13900
|
modal.style.zIndex = '9999';
|
|
13951
13901
|
};
|
|
13952
|
-
|
|
13902
|
+
const applyHeaderStyle = (header) => {
|
|
13953
13903
|
header.style.alignItems = 'center';
|
|
13954
13904
|
header.style.color = juxMediumGreen;
|
|
13955
13905
|
header.style.flexDirection = 'row';
|
|
@@ -13961,7 +13911,7 @@ var juxWeb = (function (exports) {
|
|
|
13961
13911
|
header.style.position = 'relative';
|
|
13962
13912
|
header.style.width = '100%';
|
|
13963
13913
|
};
|
|
13964
|
-
|
|
13914
|
+
const applyJuxModalContentStyle = (el) => {
|
|
13965
13915
|
el.style.display = 'flex';
|
|
13966
13916
|
el.style.position = 'relative';
|
|
13967
13917
|
el.style.width = '100%';
|
|
@@ -13969,37 +13919,32 @@ var juxWeb = (function (exports) {
|
|
|
13969
13919
|
el.style.marginTop = '1.33rem';
|
|
13970
13920
|
el.style.rowGap = '8px';
|
|
13971
13921
|
};
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
if (content === void 0) { content = ''; }
|
|
13975
|
-
if (persistent === void 0) { persistent = false; }
|
|
13976
|
-
if (okTxt === void 0) { okTxt = getTranslation('alert-ok-btn-txt'); }
|
|
13977
|
-
if (cancelTxt === void 0) { cancelTxt = getTranslation('alert-cancel-btn-txt'); }
|
|
13978
|
-
var result = document.createElement('jux-modal');
|
|
13922
|
+
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) => {
|
|
13923
|
+
const result = document.createElement('jux-modal');
|
|
13979
13924
|
applyModalStyle(result);
|
|
13980
|
-
|
|
13925
|
+
const wrapper = document.createElement('modal-wrapper');
|
|
13981
13926
|
applyWrapperStyle(wrapper);
|
|
13982
13927
|
// START close
|
|
13983
|
-
|
|
13928
|
+
const closeBtn = document.createElement('button');
|
|
13984
13929
|
if (!persistent) {
|
|
13985
13930
|
closeBtn.className = 'close';
|
|
13986
13931
|
closeBtn.setAttribute('aria-label', getTranslation('close'));
|
|
13987
13932
|
}
|
|
13988
13933
|
// END close
|
|
13989
13934
|
// START header
|
|
13990
|
-
|
|
13935
|
+
const header = document.createElement('modal-header');
|
|
13991
13936
|
applyHeaderStyle(header);
|
|
13992
13937
|
if (title) {
|
|
13993
13938
|
if (titleStyle) {
|
|
13994
13939
|
header.classList.add(titleStyle);
|
|
13995
13940
|
}
|
|
13996
|
-
|
|
13941
|
+
const h3 = document.createElement('h3');
|
|
13997
13942
|
h3.textContent = title;
|
|
13998
13943
|
header.appendChild(h3);
|
|
13999
13944
|
}
|
|
14000
13945
|
// END header
|
|
14001
13946
|
// START content
|
|
14002
|
-
|
|
13947
|
+
const modalContent = document.createElement('jux-modal-content');
|
|
14003
13948
|
applyJuxModalContentStyle(modalContent);
|
|
14004
13949
|
if (content) {
|
|
14005
13950
|
modalContent.innerHTML = content;
|
|
@@ -14009,22 +13954,22 @@ var juxWeb = (function (exports) {
|
|
|
14009
13954
|
}
|
|
14010
13955
|
// END content
|
|
14011
13956
|
// START footer
|
|
14012
|
-
|
|
13957
|
+
const footer = document.createElement('modal-footer');
|
|
14013
13958
|
if (btns.includes('cancel')) {
|
|
14014
|
-
|
|
13959
|
+
const cancelBtn = document.createElement('button');
|
|
14015
13960
|
cancelBtn.classList.add('secondary-button', 'modal-button', 'action', 'cancel-btn', 'cancel');
|
|
14016
|
-
|
|
13961
|
+
const cancelText = document.createElement('button-text');
|
|
14017
13962
|
cancelText.textContent = cancelTxt;
|
|
14018
|
-
|
|
13963
|
+
const cancelSpinner = document.createElement('loading-spinner');
|
|
14019
13964
|
cancelBtn.append(cancelText, cancelSpinner);
|
|
14020
13965
|
footer.appendChild(cancelBtn);
|
|
14021
13966
|
}
|
|
14022
13967
|
if (btns.includes('ok')) {
|
|
14023
|
-
|
|
13968
|
+
const okBtn = document.createElement('button');
|
|
14024
13969
|
okBtn.classList.add('primary-button', 'modal-button', 'action', 'ok');
|
|
14025
|
-
|
|
13970
|
+
const okText = document.createElement('button-text');
|
|
14026
13971
|
okText.textContent = okTxt;
|
|
14027
|
-
|
|
13972
|
+
const okSpinner = document.createElement('loading-spinner');
|
|
14028
13973
|
okBtn.append(okText, okSpinner);
|
|
14029
13974
|
footer.appendChild(okBtn);
|
|
14030
13975
|
}
|
|
@@ -14048,15 +13993,13 @@ var juxWeb = (function (exports) {
|
|
|
14048
13993
|
return result;
|
|
14049
13994
|
};
|
|
14050
13995
|
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
var elId = 'contact-' + elName;
|
|
14056
|
-
var label = document.createElement('label');
|
|
13996
|
+
const contactField = (tag = 'input', elType, elName, required = true, value) => {
|
|
13997
|
+
const result = document.createElement('contact-field');
|
|
13998
|
+
const elId = 'contact-' + elName;
|
|
13999
|
+
const label = document.createElement('label');
|
|
14057
14000
|
label.textContent = getTranslation(elId + '-label');
|
|
14058
14001
|
label.htmlFor = elId;
|
|
14059
|
-
|
|
14002
|
+
const el = document.createElement(tag);
|
|
14060
14003
|
el.id = elId;
|
|
14061
14004
|
el.setAttribute('name', elName);
|
|
14062
14005
|
el.setAttribute('placeholder', getTranslation(elId + '-placeholder'));
|
|
@@ -14073,72 +14016,75 @@ var juxWeb = (function (exports) {
|
|
|
14073
14016
|
return result;
|
|
14074
14017
|
};
|
|
14075
14018
|
|
|
14076
|
-
|
|
14077
|
-
|
|
14019
|
+
const getNestedElValue = (el, nestedTag) => {
|
|
14020
|
+
const nestedEl = el.querySelector(nestedTag);
|
|
14078
14021
|
return nestedEl.value;
|
|
14079
14022
|
};
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
subject:
|
|
14083
|
-
body:
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14023
|
+
const sendInquiry = (name, email, msg, whatsapp, subject, token) => {
|
|
14024
|
+
const inquiryPayload = {
|
|
14025
|
+
subject: `[${subject.charAt(0).toUpperCase()}${subject.slice(1)}] ${getNestedElValue(name, 'input')}`,
|
|
14026
|
+
body: `<strong>Name</strong>: ${getNestedElValue(name, 'input')}<br><br>
|
|
14027
|
+
<strong>E-mail</strong>: ${getNestedElValue(email, 'input')}<br><br>
|
|
14028
|
+
<strong>Whatsapp</strong>: ${getNestedElValue(whatsapp, 'input')}<br><br>
|
|
14029
|
+
<strong>Message</strong>: ${getNestedElValue(msg, 'textarea')}`,
|
|
14030
|
+
token,
|
|
14031
|
+
};
|
|
14032
|
+
backendPost('contact-us', JSON.stringify(inquiryPayload), (_res) => {
|
|
14087
14033
|
var _a;
|
|
14088
14034
|
// success(getTranslation('form-success'), Length.long);
|
|
14089
14035
|
(_a = document.querySelector('#contact-us-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
14090
|
-
},
|
|
14036
|
+
}, () => { } // TODO: change it to be an error handling fn provided by the client
|
|
14091
14037
|
);
|
|
14092
14038
|
// checkMixpanel(() => mixpanel.track('Sent Contact Inquiry', {}));
|
|
14093
14039
|
};
|
|
14094
|
-
|
|
14040
|
+
const contactUsModal = (subject) => {
|
|
14095
14041
|
var _a, _b, _c, _d, _e;
|
|
14096
|
-
|
|
14042
|
+
const result = document.createElement('contact-us-modal');
|
|
14097
14043
|
// @ts-ignore
|
|
14098
|
-
|
|
14044
|
+
const currentName = window.store.currentUser ? window.store.currentUser.name : '';
|
|
14099
14045
|
// @ts-ignore
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14046
|
+
const currentEmail = window.store.currentUser ? window.store.currentUser.email : (_a = document.querySelector('#magic-link-email')) === null || _a === void 0 ? void 0 : _a.textContent;
|
|
14047
|
+
const modalBody = document.createElement('modal-body');
|
|
14048
|
+
const form = document.createElement('form');
|
|
14103
14049
|
form.id = 'contact-form';
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14050
|
+
const nameField = contactField('input', 'text', 'name', true, currentName);
|
|
14051
|
+
const emailField = contactField('input', 'email', 'email', true, currentEmail);
|
|
14052
|
+
const messageField = contactField('textarea', 'text', 'message', true);
|
|
14053
|
+
const whatsappField = contactField('input', 'tel', 'whatsapp', false);
|
|
14054
|
+
const btn = document.createElement('button');
|
|
14109
14055
|
btn.textContent = getTranslation('contact-submit');
|
|
14110
14056
|
btn.className = 'primary-button';
|
|
14111
14057
|
form.append(nameField, emailField, whatsappField, messageField, btn);
|
|
14112
14058
|
modalBody.appendChild(form);
|
|
14113
|
-
|
|
14059
|
+
const modal = juxModal(getTranslation('contact-page'), [], '', false, false, modalBody, '', '', () => result.remove());
|
|
14114
14060
|
modal.id = 'contact-us-modal';
|
|
14115
14061
|
document.body.appendChild(modal);
|
|
14116
14062
|
(_b = modal.querySelector('modal-wrapper')) === null || _b === void 0 ? void 0 : _b.setAttribute('style', 'max-width: 680px; width: 100%; overflow-y: auto;');
|
|
14117
|
-
|
|
14063
|
+
const captcha = googleCaptcha();
|
|
14118
14064
|
if (subject !== 'email-not-sent') {
|
|
14119
14065
|
// @ts-ignore
|
|
14120
|
-
|
|
14121
|
-
backendGet(
|
|
14122
|
-
|
|
14066
|
+
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;
|
|
14067
|
+
backendGet(`credits-balance-for?admin=${admin}`, (res) => {
|
|
14068
|
+
const balance = res;
|
|
14123
14069
|
if (balance <= 0) {
|
|
14124
14070
|
form.insertBefore(captcha, btn);
|
|
14125
14071
|
}
|
|
14126
|
-
},
|
|
14072
|
+
}, () => { } // TODO: change it to be an error handling fn provided by the client
|
|
14127
14073
|
);
|
|
14128
14074
|
}
|
|
14129
14075
|
else {
|
|
14130
14076
|
form.insertBefore(captcha, btn);
|
|
14131
14077
|
}
|
|
14132
14078
|
(_e = nameField.querySelector('input')) === null || _e === void 0 ? void 0 : _e.select();
|
|
14133
|
-
form.addEventListener('submit',
|
|
14079
|
+
form.addEventListener('submit', (event) => {
|
|
14134
14080
|
event.preventDefault();
|
|
14135
14081
|
sendInquiry(nameField, emailField, messageField, whatsappField, subject, captcha.getAttribute('token'));
|
|
14136
14082
|
});
|
|
14137
14083
|
return result;
|
|
14138
14084
|
};
|
|
14139
14085
|
|
|
14140
|
-
|
|
14141
|
-
page.style.backgroundImage =
|
|
14086
|
+
const applyPageStyles$1 = (page, backgroundImg) => {
|
|
14087
|
+
page.style.backgroundImage = `url(${backgroundImg})`;
|
|
14142
14088
|
page.style.display = 'block';
|
|
14143
14089
|
page.style.width = '100%';
|
|
14144
14090
|
page.style.height = '100%';
|
|
@@ -14146,7 +14092,7 @@ var juxWeb = (function (exports) {
|
|
|
14146
14092
|
page.style.backgroundSize = 'cover';
|
|
14147
14093
|
page.style.display = 'block';
|
|
14148
14094
|
};
|
|
14149
|
-
|
|
14095
|
+
const applyContainerStyles$1 = (container) => {
|
|
14150
14096
|
container.style.backgroundColor = '#ffffffdd';
|
|
14151
14097
|
container.style.borderRadius = '16px';
|
|
14152
14098
|
container.style.inset = '50% 50% 50% 0';
|
|
@@ -14162,7 +14108,7 @@ var juxWeb = (function (exports) {
|
|
|
14162
14108
|
container.style.margin = '0 auto';
|
|
14163
14109
|
container.style.paddingTop = '0';
|
|
14164
14110
|
};
|
|
14165
|
-
|
|
14111
|
+
const applyBtnStyles = (btn) => {
|
|
14166
14112
|
btn.style.cursor = 'pointer';
|
|
14167
14113
|
btn.style.textDecoration = 'underline';
|
|
14168
14114
|
btn.style.border = 'none';
|
|
@@ -14175,31 +14121,31 @@ var juxWeb = (function (exports) {
|
|
|
14175
14121
|
btn.style.whiteSpace = 'normal';
|
|
14176
14122
|
btn.style.font = 'inherit';
|
|
14177
14123
|
};
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14124
|
+
const magicLinkRequestedPage = (backgroundImg, onReturn) => {
|
|
14125
|
+
const result = document.createElement('magic-link-requested-page');
|
|
14126
|
+
const section = document.createElement('section');
|
|
14181
14127
|
applyContainerStyles$1(section);
|
|
14182
|
-
|
|
14128
|
+
const magicLinkSent = document.createElement('p');
|
|
14183
14129
|
magicLinkSent.id = 'magic-link-sent';
|
|
14184
14130
|
magicLinkSent.textContent = getTranslation(magicLinkSent.id);
|
|
14185
14131
|
magicLinkSent.style.marginBottom = '10px';
|
|
14186
|
-
|
|
14132
|
+
const magicLinkEmail = document.createElement('p');
|
|
14187
14133
|
magicLinkEmail.id = 'magic-link-email';
|
|
14188
14134
|
magicLinkEmail.style.fontWeight = '700';
|
|
14189
14135
|
magicLinkEmail.style.marginBottom = '10px';
|
|
14190
|
-
|
|
14136
|
+
const magicLinkHowTo = document.createElement('p');
|
|
14191
14137
|
magicLinkHowTo.id = 'magic-link-how-to';
|
|
14192
14138
|
magicLinkHowTo.innerHTML = getTranslation(magicLinkHowTo.id);
|
|
14193
14139
|
magicLinkHowTo.style.padding = '0 30px';
|
|
14194
14140
|
magicLinkHowTo.style.textAlign = 'center';
|
|
14195
|
-
|
|
14141
|
+
const btn = document.createElement('button');
|
|
14196
14142
|
btn.id = 'email-not-received-btn';
|
|
14197
|
-
btn.addEventListener('click',
|
|
14143
|
+
btn.addEventListener('click', () => document.body.appendChild(contactUsModal('email-not-sent')));
|
|
14198
14144
|
btn.textContent = getTranslation('magic-link-let-us-know');
|
|
14199
14145
|
applyBtnStyles(btn);
|
|
14200
|
-
|
|
14146
|
+
const returnLink = document.createElement('a');
|
|
14201
14147
|
returnLink.textContent = getTranslation('return-link');
|
|
14202
|
-
returnLink.onclick =
|
|
14148
|
+
returnLink.onclick = () => {
|
|
14203
14149
|
result.remove();
|
|
14204
14150
|
onReturn();
|
|
14205
14151
|
};
|
|
@@ -14213,37 +14159,37 @@ var juxWeb = (function (exports) {
|
|
|
14213
14159
|
return result;
|
|
14214
14160
|
};
|
|
14215
14161
|
|
|
14216
|
-
|
|
14162
|
+
const setBackendToken = (token) => {
|
|
14217
14163
|
// @ts-ignore
|
|
14218
14164
|
window.store.backendToken = token;
|
|
14219
14165
|
if (token) {
|
|
14220
14166
|
localStorage.setItem('token', token);
|
|
14221
14167
|
}
|
|
14222
14168
|
};
|
|
14223
|
-
|
|
14169
|
+
const getBackendToken = () => {
|
|
14224
14170
|
var _a;
|
|
14225
|
-
|
|
14171
|
+
const token = (_a = localStorage.getItem('token')) !== null && _a !== void 0 ? _a : '';
|
|
14226
14172
|
// @ts-ignore
|
|
14227
14173
|
window.store.backendToken = token;
|
|
14228
14174
|
return token;
|
|
14229
14175
|
};
|
|
14230
|
-
|
|
14176
|
+
const onTokenAcquired = (token, onUserLogin) => {
|
|
14231
14177
|
setBackendToken(token);
|
|
14232
14178
|
// setSuperToken();
|
|
14233
14179
|
onUserLogin();
|
|
14234
14180
|
};
|
|
14235
|
-
|
|
14181
|
+
const clearSession = () => {
|
|
14236
14182
|
// onUserChanged(null);
|
|
14237
14183
|
localStorage.clear();
|
|
14238
14184
|
// @ts-ignore
|
|
14239
14185
|
window.store = {};
|
|
14240
14186
|
};
|
|
14241
|
-
|
|
14187
|
+
const onAuthenticationFailure = (msg) => {
|
|
14242
14188
|
localStorage.removeItem('token');
|
|
14243
14189
|
// displayPage(Page.LOGIN);
|
|
14244
14190
|
alert(getTranslation(msg));
|
|
14245
14191
|
};
|
|
14246
|
-
|
|
14192
|
+
const onAuthentication = (onUserLogin, user, type) => {
|
|
14247
14193
|
if ((user.token && getBackendToken()) && getBackendToken() !== user.token) {
|
|
14248
14194
|
clearSession();
|
|
14249
14195
|
}
|
|
@@ -14256,11 +14202,11 @@ var juxWeb = (function (exports) {
|
|
|
14256
14202
|
// mixpanelIdentify(user);
|
|
14257
14203
|
// checkMixpanel(() => mixpanel.track('Login', { 'Login Type': type }));
|
|
14258
14204
|
};
|
|
14259
|
-
|
|
14260
|
-
Array.from(clientApp.children).forEach(
|
|
14205
|
+
const displayPage = (clientApp, page) => {
|
|
14206
|
+
Array.from(clientApp.children).forEach(el => el.remove());
|
|
14261
14207
|
clientApp.appendChild(page);
|
|
14262
14208
|
};
|
|
14263
|
-
|
|
14209
|
+
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14264
14210
|
// if (startNewDemo()) {
|
|
14265
14211
|
// initDemo(setBackendToken, onAuthentication);
|
|
14266
14212
|
// return;
|
|
@@ -14276,25 +14222,25 @@ var juxWeb = (function (exports) {
|
|
|
14276
14222
|
window.store.magicLinkRequestEndpoint = magicLinkRequestEndpoint;
|
|
14277
14223
|
// @ts-ignore
|
|
14278
14224
|
window.store.magicLinkAuthEndpoint = magicLinkAuthEndpoint;
|
|
14279
|
-
|
|
14225
|
+
const magicToken = extractTokenFromWindowLocation('magic-link');
|
|
14280
14226
|
if (magicToken) {
|
|
14281
|
-
|
|
14282
|
-
openMagicLink(magicToken,
|
|
14227
|
+
const onOpenMagicLink = () => {
|
|
14228
|
+
openMagicLink(magicToken, (res) => onAuthentication(onUserLogin, res, 'Magic Link'), () => onAuthenticationFailure('unable-magic-login'));
|
|
14283
14229
|
};
|
|
14284
|
-
|
|
14230
|
+
const host = extractTokenFromWindowLocation('host');
|
|
14285
14231
|
if (host) {
|
|
14286
14232
|
// @ts-ignore
|
|
14287
|
-
window.store.fetchUserBackendUrl({ host
|
|
14233
|
+
window.store.fetchUserBackendUrl({ host }, (backendUrl) => {
|
|
14288
14234
|
setBackendUrl(backendUrl);
|
|
14289
|
-
|
|
14235
|
+
onOpenMagicLink();
|
|
14290
14236
|
});
|
|
14291
14237
|
return;
|
|
14292
14238
|
}
|
|
14293
|
-
|
|
14239
|
+
onOpenMagicLink();
|
|
14294
14240
|
return;
|
|
14295
14241
|
}
|
|
14296
14242
|
if (getBackendToken()) {
|
|
14297
|
-
backendGet('profile',
|
|
14243
|
+
backendGet('profile', (res) => onAuthentication(onUserLogin, res, 'Token Authentication'), (_err) => onAuthenticationFailure('login-failed'));
|
|
14298
14244
|
return;
|
|
14299
14245
|
}
|
|
14300
14246
|
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
@@ -14310,73 +14256,58 @@ var juxWeb = (function (exports) {
|
|
|
14310
14256
|
// validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
|
|
14311
14257
|
// checkMixpanel(() => mixpanel.track('View Login Page'));
|
|
14312
14258
|
};
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
.finally(function () { return disableSignInLayout(); })];
|
|
14338
|
-
case 3:
|
|
14339
|
-
_a.sent();
|
|
14340
|
-
return [3 /*break*/, 5];
|
|
14341
|
-
case 4:
|
|
14342
|
-
err_1 = _a.sent();
|
|
14343
|
-
reportError(err_1);
|
|
14344
|
-
disableSignInLayout();
|
|
14345
|
-
return [3 /*break*/, 5];
|
|
14346
|
-
case 5: return [2 /*return*/];
|
|
14347
|
-
}
|
|
14348
|
-
});
|
|
14349
|
-
}); };
|
|
14350
|
-
var onCookieError = function () {
|
|
14259
|
+
const onMicrosoftSignIn = (onUserLogin) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14260
|
+
const msalConfig = { auth: { clientId: process.env.MICROSOFT_CLIENT_ID } };
|
|
14261
|
+
const msalInstance = new PublicClientApplication(msalConfig);
|
|
14262
|
+
const loginRequest = { scopes: ['user.read'] };
|
|
14263
|
+
enableSignInLayout();
|
|
14264
|
+
try {
|
|
14265
|
+
const loginResponse = yield msalInstance.loginPopup(loginRequest);
|
|
14266
|
+
const { accessToken } = loginResponse;
|
|
14267
|
+
yield backendGetPromise(getMicrosoftAuthUrl() + accessToken)
|
|
14268
|
+
.then((res) => {
|
|
14269
|
+
const { token } = res;
|
|
14270
|
+
// @ts-ignore
|
|
14271
|
+
window.store.currentUser = res;
|
|
14272
|
+
onTokenAcquired(token, onUserLogin);
|
|
14273
|
+
})
|
|
14274
|
+
.catch(console.error)
|
|
14275
|
+
.finally(() => disableSignInLayout());
|
|
14276
|
+
}
|
|
14277
|
+
catch (err) {
|
|
14278
|
+
reportError(err);
|
|
14279
|
+
disableSignInLayout();
|
|
14280
|
+
}
|
|
14281
|
+
});
|
|
14282
|
+
const onCookieError = () => {
|
|
14351
14283
|
disableSignInLayout();
|
|
14352
14284
|
// warning('cookie-error'); TODO
|
|
14353
14285
|
return;
|
|
14354
14286
|
};
|
|
14355
|
-
|
|
14356
|
-
validateThirdPartyCookies(
|
|
14287
|
+
const onGoogleSignIn = (onUserLogin) => {
|
|
14288
|
+
validateThirdPartyCookies(() => {
|
|
14357
14289
|
enableSignInLayout();
|
|
14358
14290
|
authSignIn(onUserLogin);
|
|
14359
14291
|
}, onCookieError);
|
|
14360
14292
|
};
|
|
14361
|
-
|
|
14362
|
-
if (email === void 0) { email = ''; }
|
|
14293
|
+
const handleMagicLinkRequest = (token, onReturn, backgroundImage, currentPage, clientBody, email = '') => {
|
|
14363
14294
|
if (!email) {
|
|
14364
|
-
|
|
14295
|
+
const mailMagic = document.querySelector('#mail-magic');
|
|
14365
14296
|
email = mailMagic.value;
|
|
14366
14297
|
}
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
requestMagicLink(payload,
|
|
14298
|
+
const payload = { email, token };
|
|
14299
|
+
const onRequestMagicLink = () => {
|
|
14300
|
+
requestMagicLink(payload, (_res) => {
|
|
14370
14301
|
currentPage.remove();
|
|
14371
14302
|
clientBody.appendChild(magicLinkRequestedPage(backgroundImage, onReturn));
|
|
14372
|
-
|
|
14303
|
+
const magicLinkEmail = document.querySelector('#magic-link-email');
|
|
14373
14304
|
magicLinkEmail.textContent = email;
|
|
14374
14305
|
});
|
|
14375
14306
|
};
|
|
14376
14307
|
// @ts-ignore
|
|
14377
14308
|
if (window.store.fetchUserBackendUrl) {
|
|
14378
14309
|
// @ts-ignore
|
|
14379
|
-
window.store.fetchUserBackendUrl({ email
|
|
14310
|
+
window.store.fetchUserBackendUrl({ email }, (backendUrl) => {
|
|
14380
14311
|
setBackendUrl(backendUrl);
|
|
14381
14312
|
onRequestMagicLink();
|
|
14382
14313
|
});
|
|
@@ -14385,118 +14316,101 @@ var juxWeb = (function (exports) {
|
|
|
14385
14316
|
onRequestMagicLink();
|
|
14386
14317
|
};
|
|
14387
14318
|
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
email.textContent = "
|
|
14392
|
-
|
|
14319
|
+
const socialLoginModal = (userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal) => {
|
|
14320
|
+
const result = document.createElement('social-login-modal');
|
|
14321
|
+
const email = document.createElement('p');
|
|
14322
|
+
email.textContent = `"${userEmail}"`;
|
|
14323
|
+
const msg = document.createElement('social-login-msg');
|
|
14393
14324
|
msg.textContent = getTranslation('social-login-recommendation') + mailExchanger + '.' + getTranslation('social-login-advantage');
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
loginButton('Microsoft',
|
|
14397
|
-
loginButton('Google',
|
|
14398
|
-
|
|
14325
|
+
const body = document.createElement('social-login-body');
|
|
14326
|
+
const socialLoginBtn = mailExchanger === 'Microsoft' ?
|
|
14327
|
+
loginButton('Microsoft', () => onMicrosoftSignIn(onUserLogin)) :
|
|
14328
|
+
loginButton('Google', () => onGoogleSignIn(onUserLogin));
|
|
14329
|
+
const proceedMagicLinkRequest = document.createElement('a');
|
|
14399
14330
|
proceedMagicLinkRequest.textContent = getTranslation('proceed-magic-link-request');
|
|
14400
|
-
proceedMagicLinkRequest.addEventListener('click',
|
|
14331
|
+
proceedMagicLinkRequest.addEventListener('click', () => {
|
|
14401
14332
|
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody, userEmail);
|
|
14402
14333
|
closeMagicLinkModal();
|
|
14403
14334
|
result.remove();
|
|
14404
14335
|
});
|
|
14405
14336
|
body.append(email, msg, socialLoginBtn, proceedMagicLinkRequest);
|
|
14406
|
-
|
|
14337
|
+
const modal = juxModal(getTranslation(`using-${mailExchanger.toLowerCase()}-email`), [], '', false, false, body, '', '', () => result.remove());
|
|
14407
14338
|
modal.setAttribute('data-cy', 'social-login-modal');
|
|
14408
14339
|
result.appendChild(modal);
|
|
14409
|
-
|
|
14340
|
+
const wrapper = modal.querySelector('modal-wrapper');
|
|
14410
14341
|
wrapper.style.maxWidth = '360px';
|
|
14411
14342
|
wrapper.style.width = '100%';
|
|
14412
14343
|
return result;
|
|
14413
14344
|
};
|
|
14414
14345
|
|
|
14415
|
-
|
|
14416
|
-
|
|
14346
|
+
const isValidEmail = (email) => {
|
|
14347
|
+
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,}))$/;
|
|
14417
14348
|
return re.test(email);
|
|
14418
14349
|
};
|
|
14419
14350
|
|
|
14420
|
-
|
|
14351
|
+
const recommendSocialLogin = (userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal) => {
|
|
14421
14352
|
var _a;
|
|
14422
14353
|
(_a = document.querySelector('magic-link-modal')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
14423
14354
|
document.body.appendChild(socialLoginModal(userEmail, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal));
|
|
14424
14355
|
};
|
|
14425
|
-
|
|
14426
|
-
return data.some(
|
|
14356
|
+
const hasProvider = (data, provider) => {
|
|
14357
|
+
return data.some((entry) => entry.includes(provider));
|
|
14427
14358
|
};
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
14435
|
-
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
console.error('invalid-captcha-response');
|
|
14456
|
-
// logError('invalid-captcha-response');
|
|
14457
|
-
return [2 /*return*/];
|
|
14458
|
-
}
|
|
14459
|
-
if (!isValidEmail(email)) return [3 /*break*/, 2];
|
|
14460
|
-
domain = email.split('@')[1] || '';
|
|
14461
|
-
return [4 /*yield*/, getMailExchanger(domain)];
|
|
14462
|
-
case 1:
|
|
14463
|
-
mailExchanger = _a.sent();
|
|
14464
|
-
supportedMailExchanger = mailExchanger !== null;
|
|
14465
|
-
if (supportedMailExchanger && loginTypes.includes(mailExchanger)) {
|
|
14466
|
-
recommendSocialLogin(email, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal);
|
|
14467
|
-
return [2 /*return*/];
|
|
14468
|
-
}
|
|
14469
|
-
_a.label = 2;
|
|
14470
|
-
case 2:
|
|
14471
|
-
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody);
|
|
14472
|
-
closeMagicLinkModal();
|
|
14473
|
-
return [2 /*return*/];
|
|
14359
|
+
const getMailExchanger = (domainName) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14360
|
+
const data = yield getMXData(domainName);
|
|
14361
|
+
if (!data) {
|
|
14362
|
+
return null;
|
|
14363
|
+
}
|
|
14364
|
+
if (hasProvider(data, 'outlook.com')) {
|
|
14365
|
+
return 'Microsoft';
|
|
14366
|
+
}
|
|
14367
|
+
if (hasProvider(data, 'google.com')) {
|
|
14368
|
+
return 'Google';
|
|
14369
|
+
}
|
|
14370
|
+
return null;
|
|
14371
|
+
});
|
|
14372
|
+
const onMagicLinkRequest = (token, input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes) => __awaiter$2(void 0, void 0, void 0, function* () {
|
|
14373
|
+
const email = input.value;
|
|
14374
|
+
if (!email.includes('-test@') && !token) {
|
|
14375
|
+
console.error('invalid-captcha-response');
|
|
14376
|
+
// logError('invalid-captcha-response');
|
|
14377
|
+
return;
|
|
14378
|
+
}
|
|
14379
|
+
if (isValidEmail(email)) {
|
|
14380
|
+
const domain = email.split('@')[1] || '';
|
|
14381
|
+
const mailExchanger = yield getMailExchanger(domain);
|
|
14382
|
+
const supportedMailExchanger = mailExchanger !== null;
|
|
14383
|
+
if (supportedMailExchanger && loginTypes.includes(mailExchanger)) {
|
|
14384
|
+
recommendSocialLogin(email, mailExchanger, token, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal);
|
|
14385
|
+
return;
|
|
14474
14386
|
}
|
|
14475
|
-
}
|
|
14476
|
-
|
|
14477
|
-
|
|
14387
|
+
}
|
|
14388
|
+
handleMagicLinkRequest(token, onReturn, backgroundImage, currentPage, clientBody);
|
|
14389
|
+
closeMagicLinkModal();
|
|
14390
|
+
});
|
|
14391
|
+
const applyMagicEmailFieldStyle = (el) => {
|
|
14478
14392
|
el.style.display = 'flex';
|
|
14479
14393
|
el.style.flexFlow = 'column';
|
|
14480
14394
|
el.style.marginTop = '8px';
|
|
14481
14395
|
el.style.rowGap = '8px';
|
|
14482
14396
|
el.style.width = '100%';
|
|
14483
14397
|
};
|
|
14484
|
-
|
|
14485
|
-
input.style.border =
|
|
14398
|
+
const applyInputStyle = (input) => {
|
|
14399
|
+
input.style.border = `1px solid ${juxDarkGrey}`;
|
|
14486
14400
|
input.style.maxWidth = '390px';
|
|
14487
14401
|
input.style.padding = '10px';
|
|
14488
14402
|
input.style.width = '100%';
|
|
14489
14403
|
input.style.backgroundColor = juxWhite;
|
|
14490
14404
|
input.style.borderRadius = '8px';
|
|
14491
|
-
input.style.boxShadow =
|
|
14405
|
+
input.style.boxShadow = `inset 0 2px 3px ${juxDimmedDarkGrey}`;
|
|
14492
14406
|
input.style.height = '40px';
|
|
14493
14407
|
input.style.whiteSpace = 'pre-line';
|
|
14494
14408
|
input.style.boxSizing = 'border-box';
|
|
14495
14409
|
};
|
|
14496
|
-
|
|
14410
|
+
const applyBtnStyle = (btn) => {
|
|
14497
14411
|
btn.style.alignSelf = 'flex-end';
|
|
14498
14412
|
btn.style.backgroundColor = juxLightGreen;
|
|
14499
|
-
btn.style.border =
|
|
14413
|
+
btn.style.border = `2px solid ${juxLightGreen}`;
|
|
14500
14414
|
btn.style.borderRadius = '8px';
|
|
14501
14415
|
btn.style.color = juxWhite;
|
|
14502
14416
|
btn.style.cursor = 'pointer';
|
|
@@ -14508,48 +14422,48 @@ var juxWeb = (function (exports) {
|
|
|
14508
14422
|
btn.style.padding = '10px 16px';
|
|
14509
14423
|
btn.style.position = 'relative';
|
|
14510
14424
|
};
|
|
14511
|
-
|
|
14512
|
-
|
|
14425
|
+
const magicEmailField = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes) => {
|
|
14426
|
+
const result = document.createElement('magic-email-field');
|
|
14513
14427
|
applyMagicEmailFieldStyle(result);
|
|
14514
|
-
|
|
14515
|
-
|
|
14428
|
+
const captcha = googleCaptcha();
|
|
14429
|
+
const input = document.createElement('input');
|
|
14516
14430
|
input.id = 'mail-magic';
|
|
14517
14431
|
input.type = 'text';
|
|
14518
14432
|
input.className = 'textfield';
|
|
14519
14433
|
input.placeholder = 'e-mail';
|
|
14520
14434
|
applyInputStyle(input);
|
|
14521
|
-
input.addEventListener('keydown',
|
|
14435
|
+
input.addEventListener('keydown', (ev) => {
|
|
14522
14436
|
if (ev.key === 'Enter') {
|
|
14523
14437
|
onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes);
|
|
14524
14438
|
}
|
|
14525
14439
|
});
|
|
14526
|
-
|
|
14440
|
+
const btn = document.createElement('button');
|
|
14527
14441
|
applyBtnStyle(btn);
|
|
14528
14442
|
btn.id = 'send-magic';
|
|
14529
14443
|
btn.className = 'primary-button';
|
|
14530
|
-
btn.addEventListener('click',
|
|
14444
|
+
btn.addEventListener('click', (_ev) => onMagicLinkRequest(captcha.getAttribute('token'), input, onUserLogin, onReturn, backgroundImage, currentPage, clientBody, closeMagicLinkModal, loginTypes));
|
|
14531
14445
|
btn.textContent = getTranslation('send-magic');
|
|
14532
14446
|
result.append(input, captcha, btn);
|
|
14533
14447
|
return result;
|
|
14534
14448
|
};
|
|
14535
14449
|
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14450
|
+
const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, clientBody, loginTypes) => {
|
|
14451
|
+
const result = document.createElement('magic-link-modal');
|
|
14452
|
+
const subtitle = document.createElement('magic-link-request-subtitle');
|
|
14539
14453
|
subtitle.style.fontSize = '14px';
|
|
14540
14454
|
subtitle.textContent = getTranslation('magic-link-request-subtitle');
|
|
14541
|
-
|
|
14542
|
-
body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody,
|
|
14543
|
-
|
|
14455
|
+
const body = document.createElement('magic-link-request-body');
|
|
14456
|
+
body.append(subtitle, magicEmailField(onUserLogin, onReturn, backgroundImage, currentPage, clientBody, () => result.remove(), loginTypes));
|
|
14457
|
+
const modal = juxModal(getTranslation('magic-link-request-title'), [], '', false, false, body, '', '', () => result.remove());
|
|
14544
14458
|
modal.setAttribute('data-cy', 'magic-link-modal');
|
|
14545
14459
|
result.appendChild(modal);
|
|
14546
|
-
|
|
14460
|
+
const wrapper = modal.querySelector('modal-wrapper');
|
|
14547
14461
|
wrapper.style.maxWidth = '360px';
|
|
14548
14462
|
wrapper.style.width = '100%';
|
|
14549
14463
|
return result;
|
|
14550
14464
|
};
|
|
14551
14465
|
|
|
14552
|
-
|
|
14466
|
+
const applyContainerStyles = (container) => {
|
|
14553
14467
|
container.style.backgroundColor = '#ffffffdd';
|
|
14554
14468
|
container.style.borderRadius = '16px';
|
|
14555
14469
|
container.style.inset = '50% 50% 50% 0';
|
|
@@ -14565,48 +14479,60 @@ var juxWeb = (function (exports) {
|
|
|
14565
14479
|
container.style.margin = '0 auto';
|
|
14566
14480
|
container.style.paddingTop = '0';
|
|
14567
14481
|
};
|
|
14568
|
-
|
|
14482
|
+
const applyPageStyles = (page) => {
|
|
14569
14483
|
page.style.backgroundPosition = '50%';
|
|
14570
14484
|
page.style.backgroundSize = 'cover';
|
|
14571
14485
|
page.style.display = 'block';
|
|
14572
14486
|
page.style.height = '100%';
|
|
14573
14487
|
};
|
|
14574
|
-
|
|
14575
|
-
|
|
14488
|
+
const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) => {
|
|
14489
|
+
const onReturn = () => clientApp.appendChild(loginPage);
|
|
14576
14490
|
loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes));
|
|
14577
14491
|
};
|
|
14578
|
-
|
|
14492
|
+
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes, backgroundImg) => {
|
|
14579
14493
|
if (loginTypes.includes('Google')) {
|
|
14580
|
-
section.appendChild(loginButton('Google',
|
|
14494
|
+
section.appendChild(loginButton('Google', () => onGoogleSignIn(onUserLogin)));
|
|
14581
14495
|
}
|
|
14582
14496
|
if (loginTypes.includes('Microsoft')) {
|
|
14583
|
-
section.appendChild(loginButton('Microsoft',
|
|
14497
|
+
section.appendChild(loginButton('Microsoft', () => onMicrosoftSignIn(onUserLogin)));
|
|
14584
14498
|
}
|
|
14585
14499
|
if (loginTypes.includes('Linkedin')) {
|
|
14586
|
-
section.appendChild(loginButton('LinkedIn',
|
|
14500
|
+
section.appendChild(loginButton('LinkedIn', () => console.log('login with Linkedin')));
|
|
14587
14501
|
}
|
|
14588
14502
|
if (loginTypes.includes('Email')) {
|
|
14589
|
-
section.appendChild(loginButton('Email',
|
|
14503
|
+
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
14590
14504
|
}
|
|
14591
14505
|
};
|
|
14592
|
-
|
|
14593
|
-
|
|
14506
|
+
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
14507
|
+
const result = document.createElement('login-page');
|
|
14594
14508
|
applyPageStyles(result);
|
|
14595
|
-
|
|
14509
|
+
const section = document.createElement('section');
|
|
14596
14510
|
applyContainerStyles(section);
|
|
14597
|
-
|
|
14511
|
+
const salutation = document.createElement('sign-in-salutation');
|
|
14598
14512
|
salutation.textContent = getTranslation('sign-in-salutation');
|
|
14599
|
-
|
|
14513
|
+
const explanation = document.createElement('sign-in-explanation');
|
|
14600
14514
|
explanation.textContent = getTranslation('sign-in-explanation');
|
|
14601
|
-
|
|
14515
|
+
const msg = document.createElement('sign-in-msg');
|
|
14602
14516
|
msg.textContent = getTranslation('sign-in-msg-general');
|
|
14603
|
-
result.style.backgroundImage =
|
|
14517
|
+
result.style.backgroundImage = `url(${backgroundImg})`;
|
|
14604
14518
|
section.append(salutation, explanation, msg);
|
|
14605
14519
|
appendLoginTypes(result, section, clientApp, onUserLogin, loginTypes, backgroundImg);
|
|
14606
14520
|
result.appendChild(section);
|
|
14607
14521
|
return result;
|
|
14608
14522
|
};
|
|
14609
14523
|
|
|
14524
|
+
class Query extends Event {
|
|
14525
|
+
constructor(endpoint, onResult, params, onError) {
|
|
14526
|
+
super(endpoint); // if needed, it is possible to modify bubbles, cancelable and composed properties
|
|
14527
|
+
this.params = params;
|
|
14528
|
+
this.onResult = onResult;
|
|
14529
|
+
this.onError = onError;
|
|
14530
|
+
}
|
|
14531
|
+
}
|
|
14532
|
+
const query = (element, endpoint, onResult, params, onError) => {
|
|
14533
|
+
element.dispatchEvent(new Query(endpoint, onResult, params, onError));
|
|
14534
|
+
};
|
|
14535
|
+
|
|
14610
14536
|
exports.chosenLanguage = chosenLanguage;
|
|
14611
14537
|
exports.getTranslation = getTranslation;
|
|
14612
14538
|
exports.handleMagicLinkRequest = handleMagicLinkRequest;
|
|
@@ -14616,6 +14542,7 @@ var juxWeb = (function (exports) {
|
|
|
14616
14542
|
exports.loginPage = loginPage;
|
|
14617
14543
|
exports.magicLinkModal = magicLinkModal;
|
|
14618
14544
|
exports.onMicrosoftSignIn = onMicrosoftSignIn;
|
|
14545
|
+
exports.query = query;
|
|
14619
14546
|
exports.reloadWithLanguageOverride = reloadWithLanguageOverride;
|
|
14620
14547
|
exports.requestMagicLink = requestMagicLink;
|
|
14621
14548
|
|