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