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