@everymatrix/player-step-up-auth 0.1.0
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-bf4d774c.js +1330 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/player-step-up-auth-2fac8df5.js +617 -0
- package/dist/cjs/player-step-up-auth.cjs.entry.js +10 -0
- package/dist/cjs/player-step-up-auth.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/player-step-up-auth/index.js +1 -0
- package/dist/collection/components/player-step-up-auth/player-step-up-auth.css +131 -0
- package/dist/collection/components/player-step-up-auth/player-step-up-auth.js +543 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/types.js +0 -0
- package/dist/collection/utils/utils.js +177 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-c6eee6d8.js +1302 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/player-step-up-auth-009badea.js +615 -0
- package/dist/esm/player-step-up-auth.entry.js +2 -0
- package/dist/esm/player-step-up-auth.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/player-step-up-auth/index.esm.js +1 -0
- package/dist/player-step-up-auth/p-3b187b6e.entry.js +1 -0
- package/dist/player-step-up-auth/p-c6a4faff.js +2 -0
- package/dist/player-step-up-auth/p-e1255160.js +1 -0
- package/dist/player-step-up-auth/p-f97ac666.js +1 -0
- package/dist/player-step-up-auth/player-step-up-auth.esm.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +18 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/packages/stencil/player-step-up-auth/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/packages/stencil/player-step-up-auth/stencil.config.dev.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/packages/stencil/player-step-up-auth/storybook/main.d.ts +3 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/packages/stencil/player-step-up-auth/storybook/preview.d.ts +70 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/tools/plugins/index.d.ts +3 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/player-step-up-auth/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/player-step-up-auth/index.d.ts +1 -0
- package/dist/types/components/player-step-up-auth/player-step-up-auth.d.ts +168 -0
- package/dist/types/components.d.ts +93 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/types.d.ts +0 -0
- package/dist/types/utils/utils.d.ts +2 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
import { h, Fragment } from "@stencil/core";
|
|
2
|
+
import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
|
|
3
|
+
import { translate, getTranslations } from "../../utils/utils";
|
|
4
|
+
export class PlayerStepUpAuth {
|
|
5
|
+
/**
|
|
6
|
+
* Watch for changes in the translation URL and fetch new translations
|
|
7
|
+
*/
|
|
8
|
+
handleNewTranslations() {
|
|
9
|
+
getTranslations(this.translationUrl);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Watch for changes in the client styling and apply the new styling
|
|
13
|
+
*
|
|
14
|
+
* @param newValue - new client styling
|
|
15
|
+
* @param oldValue - previous client styling
|
|
16
|
+
*/
|
|
17
|
+
handleClientStylingChange(newValue, oldValue) {
|
|
18
|
+
if (newValue !== oldValue) {
|
|
19
|
+
setClientStyling(this.el, this.clientStyling);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Watch for changes in the client styling URL and fetch the new CSS
|
|
24
|
+
*
|
|
25
|
+
* @param newValue - new client styling URL
|
|
26
|
+
* @param oldValue - previous client styling URL
|
|
27
|
+
*/
|
|
28
|
+
handleClientStylingUrlChange(newValue, oldValue) {
|
|
29
|
+
if (newValue != oldValue) {
|
|
30
|
+
if (this.clientStylingUrl)
|
|
31
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async handleStepUpAuthEvent(event) {
|
|
35
|
+
var _a;
|
|
36
|
+
if ((_a = event.detail) === null || _a === void 0 ? void 0 : _a['x-step-up-required']) {
|
|
37
|
+
this.hasConfigErrors = false;
|
|
38
|
+
this.hasErrors = false;
|
|
39
|
+
this.errorMessage = '';
|
|
40
|
+
this.showPopup = true;
|
|
41
|
+
this.token = event.detail['x-step-up-token'];
|
|
42
|
+
await this.getConfig();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Class constructor
|
|
47
|
+
*/
|
|
48
|
+
constructor() {
|
|
49
|
+
this.otpInputs = [];
|
|
50
|
+
this.countdownTimer = null;
|
|
51
|
+
this.mbSource = undefined;
|
|
52
|
+
this.clientStyling = undefined;
|
|
53
|
+
this.clientStylingUrl = undefined;
|
|
54
|
+
this.language = 'en';
|
|
55
|
+
this.endpoint = undefined;
|
|
56
|
+
this.userSession = undefined;
|
|
57
|
+
this.translationUrl = '';
|
|
58
|
+
this.showPopup = false;
|
|
59
|
+
this.otp = undefined;
|
|
60
|
+
this.isLoading = true;
|
|
61
|
+
this.config = null;
|
|
62
|
+
this.timeLeft = 0;
|
|
63
|
+
this.expirationTime = '';
|
|
64
|
+
this.serverTime = '';
|
|
65
|
+
this.hasErrors = false;
|
|
66
|
+
this.hasConfigErrors = false;
|
|
67
|
+
this.errorMessage = '';
|
|
68
|
+
this.token = '';
|
|
69
|
+
this.showResendOtp = false;
|
|
70
|
+
this.closePopup = this.closePopup.bind(this);
|
|
71
|
+
this.handleResendOtp = this.handleResendOtp.bind(this);
|
|
72
|
+
this.submitOtp = this.submitOtp.bind(this);
|
|
73
|
+
this.setOtpContainerRef = this.setOtpContainerRef.bind(this);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Fetches OTP configuration from the endpoint.
|
|
77
|
+
* Updates the OTP state, expiration time, and starts the countdown timer.
|
|
78
|
+
*/
|
|
79
|
+
async getConfig() {
|
|
80
|
+
if (!this.endpoint)
|
|
81
|
+
return;
|
|
82
|
+
try {
|
|
83
|
+
const url = new URL(`/api/v1/mfa/challenge/${this.token}/config`, this.endpoint);
|
|
84
|
+
this.isLoading = true;
|
|
85
|
+
const response = await fetch(url.href);
|
|
86
|
+
if (!response.ok)
|
|
87
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
88
|
+
this.config = await response.json();
|
|
89
|
+
this.otp = new Array(this.config.inputLength).fill('');
|
|
90
|
+
this.isLoading = false;
|
|
91
|
+
this.showResendOtp = false;
|
|
92
|
+
this.expirationTime = this.config.expirationTime;
|
|
93
|
+
this.serverTime = this.config.serverTime;
|
|
94
|
+
this.calculateTimeLeft();
|
|
95
|
+
this.startCountdown();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
this.isLoading = false;
|
|
99
|
+
this.hasConfigErrors = true;
|
|
100
|
+
this.errorMessage = translate('configError', this.language);
|
|
101
|
+
console.error('Error loading 2FA config:', error);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Starts the countdown timer for OTP expiration.
|
|
106
|
+
* - Clears any existing timer to prevent duplicate intervals.
|
|
107
|
+
* - Decreases `timeLeft` every second.
|
|
108
|
+
* - Stops the countdown when time reaches 0.
|
|
109
|
+
* - Shows the "Resend OTP" option when time runs out.
|
|
110
|
+
*/
|
|
111
|
+
calculateTimeLeft() {
|
|
112
|
+
const expirationDate = new Date(this.expirationTime);
|
|
113
|
+
const serverTime = new Date(this.serverTime);
|
|
114
|
+
if (!this.currentTime) {
|
|
115
|
+
this.currentTime = new Date();
|
|
116
|
+
}
|
|
117
|
+
// Calculate the offset (difference between server time and local time)
|
|
118
|
+
const offset = serverTime.getTime() - this.currentTime.getTime();
|
|
119
|
+
// Adjust current time using the offset
|
|
120
|
+
const adjustedCurrentDate = new Date(this.currentTime.getTime() + offset);
|
|
121
|
+
// Calculate time left in seconds
|
|
122
|
+
this.timeLeft = Math.floor((expirationDate.getTime() - adjustedCurrentDate.getTime()) / 1000);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Starts a countdown timer for OTP expiration.
|
|
126
|
+
* Decreases `timeLeft` every second and closes the popup when time runs out.
|
|
127
|
+
*/
|
|
128
|
+
startCountdown() {
|
|
129
|
+
if (this.countdownTimer) {
|
|
130
|
+
clearInterval(this.countdownTimer); // Clear any existing timer
|
|
131
|
+
}
|
|
132
|
+
this.countdownTimer = setInterval(() => {
|
|
133
|
+
if (this.timeLeft > 0) {
|
|
134
|
+
this.timeLeft -= 1; // Update state correctly
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
clearInterval(this.countdownTimer);
|
|
138
|
+
this.countdownTimer = null;
|
|
139
|
+
this.showResendOtp = true;
|
|
140
|
+
}
|
|
141
|
+
}, 1000);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Formats time from seconds to MM:SS format.
|
|
145
|
+
*
|
|
146
|
+
* @param seconds - The time in seconds.
|
|
147
|
+
* @returns A formatted string representing minutes and seconds.
|
|
148
|
+
*/
|
|
149
|
+
formatTime(seconds) {
|
|
150
|
+
const minutes = Math.floor(seconds / 60);
|
|
151
|
+
const remainingSeconds = seconds % 60;
|
|
152
|
+
return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Sets a reference to the OTP input container.
|
|
156
|
+
*
|
|
157
|
+
* @param el - The OTP input container element.
|
|
158
|
+
*/
|
|
159
|
+
setOtpContainerRef(el) {
|
|
160
|
+
if (el)
|
|
161
|
+
this.otpContainer = el;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Sets a reference to the OTP inputs.
|
|
165
|
+
*
|
|
166
|
+
* @param el - The OTP input container element.
|
|
167
|
+
*/
|
|
168
|
+
setOtpInputRef(el, index) {
|
|
169
|
+
if (el) {
|
|
170
|
+
this.otpInputs[index] = el;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Handles pasting an OTP directly into the input fields.
|
|
175
|
+
* Extracts characters from the clipboard and populates the OTP fields.
|
|
176
|
+
*
|
|
177
|
+
* @param e - The clipboard event containing pasted data.
|
|
178
|
+
*/
|
|
179
|
+
handleOnPasteOtp(e) {
|
|
180
|
+
var _a;
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
const data = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text').trim();
|
|
183
|
+
if (!data)
|
|
184
|
+
return;
|
|
185
|
+
const value = data.slice(0, this.config.inputLength).split(""); // Limit to OTP length
|
|
186
|
+
this.otp = [...value, ...new Array(this.config.inputLength - value.length).fill('')];
|
|
187
|
+
const inputs = Array.from(this.otpContainer.children);
|
|
188
|
+
if (inputs) {
|
|
189
|
+
value.forEach((char, index) => {
|
|
190
|
+
inputs[index].value = char;
|
|
191
|
+
});
|
|
192
|
+
// Move focus to the last input or trigger submit
|
|
193
|
+
const lastInput = inputs[value.length - 1];
|
|
194
|
+
lastInput === null || lastInput === void 0 ? void 0 : lastInput.focus();
|
|
195
|
+
if (value.length === this.config.inputLength) {
|
|
196
|
+
this.submitOtp();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Handles OTP input changes.
|
|
202
|
+
* Allows only alphanumeric characters and moves focus to the next input field.
|
|
203
|
+
*
|
|
204
|
+
* @param e - The input event.
|
|
205
|
+
* @param index - The index of the input field being updated.
|
|
206
|
+
*/
|
|
207
|
+
handleOtpInput(e, index) {
|
|
208
|
+
const input = e.target;
|
|
209
|
+
let value = input.value.replace(/[^0-9a-zA-Z]/gi, '').toUpperCase();
|
|
210
|
+
input.value = value.charAt(0);
|
|
211
|
+
if (!value)
|
|
212
|
+
return;
|
|
213
|
+
this.otp[index] = value[0];
|
|
214
|
+
// Move focus using stored refs
|
|
215
|
+
const nextInput = this.otpInputs[index + 1];
|
|
216
|
+
nextInput === null || nextInput === void 0 ? void 0 : nextInput.focus();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Handles key press events for OTP inputs.
|
|
220
|
+
* Supports backspace for deleting characters and moving focus to the previous input field.
|
|
221
|
+
*
|
|
222
|
+
* @param e - The keyboard event.
|
|
223
|
+
* @param index - The index of the input field.
|
|
224
|
+
*/
|
|
225
|
+
handleKeyDown(e, index) {
|
|
226
|
+
if (e.key === "Backspace") {
|
|
227
|
+
this.otp[index] = '';
|
|
228
|
+
this.otpInputs[index].value = ''; // Clear input field
|
|
229
|
+
const prevInput = this.otpInputs[index - 1];
|
|
230
|
+
prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Handles resending the OTP when time expires.
|
|
235
|
+
*/
|
|
236
|
+
handleResendOtp() {
|
|
237
|
+
// Emit an event to notify the system that OTP should be resent
|
|
238
|
+
const event = new CustomEvent('otpResendRequested', {
|
|
239
|
+
detail: { message: 'User requested OTP resend' }
|
|
240
|
+
});
|
|
241
|
+
window.dispatchEvent(event);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Submits the entered OTP for validation.
|
|
245
|
+
* Sends a request to the endpoint with the OTP and handles the response.
|
|
246
|
+
*/
|
|
247
|
+
async submitOtp() {
|
|
248
|
+
if (this.otp.join('').length !== this.config.inputLength) {
|
|
249
|
+
this.hasErrors = true;
|
|
250
|
+
this.errorMessage = translate('invalidOtp', this.language);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this.isLoading = true; // Set loading state
|
|
254
|
+
this.hasErrors = false;
|
|
255
|
+
this.errorMessage = '';
|
|
256
|
+
const otpValue = this.otp.join('');
|
|
257
|
+
const url = new URL(`/api/v1/mfa/challenge/${this.token}/validate`, this.endpoint);
|
|
258
|
+
url.searchParams.append('input', otpValue);
|
|
259
|
+
try {
|
|
260
|
+
const response = await fetch(url.href, { method: 'POST' });
|
|
261
|
+
if (response.status === 200) {
|
|
262
|
+
this.handleSuccess();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const result = await response.json();
|
|
266
|
+
throw new Error(result.message);
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (error.message === 'gm.multifactorauthentication.challenge') {
|
|
270
|
+
if (this.config.numberOfValidateAttempts === (this.config.maxValidationAttempts - 1)) {
|
|
271
|
+
//Set timeout for 1h
|
|
272
|
+
const serverTime = new Date(this.serverTime);
|
|
273
|
+
serverTime.setHours(serverTime.getHours() + 1);
|
|
274
|
+
const timeoutExpiryDate = serverTime.toISOString().slice(0, 16).replace('T', ' ');
|
|
275
|
+
window.postMessage({
|
|
276
|
+
type: 'SetPlayerAccountTimeout',
|
|
277
|
+
timeoutSelected: 'CoolOffUntilSelectedDate',
|
|
278
|
+
timeoutExpiryDate
|
|
279
|
+
}, window.location.href);
|
|
280
|
+
//Trigger notification
|
|
281
|
+
window.postMessage({
|
|
282
|
+
type: 'WidgetNotification',
|
|
283
|
+
data: {
|
|
284
|
+
type: 'error',
|
|
285
|
+
message: translate('accountBlocked', this.language)
|
|
286
|
+
}
|
|
287
|
+
}, window.location.href);
|
|
288
|
+
this.closePopup();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
this.hasErrors = true;
|
|
292
|
+
this.errorMessage = translate('invalidOtp', this.language);
|
|
293
|
+
this.getConfig();
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
console.error('OTP submission failed:', error);
|
|
297
|
+
this.hasErrors = true;
|
|
298
|
+
this.errorMessage = translate('submissionError', this.language);
|
|
299
|
+
}
|
|
300
|
+
finally {
|
|
301
|
+
this.isLoading = false;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Handles successful OTP validation.
|
|
306
|
+
* Closes the popup upon successful authentication.
|
|
307
|
+
*/
|
|
308
|
+
handleSuccess() {
|
|
309
|
+
window.dispatchEvent(new CustomEvent('otpSuccess', {
|
|
310
|
+
detail: { message: 'User successfully authenticated' }
|
|
311
|
+
}));
|
|
312
|
+
this.closePopup();
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Closes the OTP popup.
|
|
316
|
+
* Resets the authentication UI state.
|
|
317
|
+
*/
|
|
318
|
+
closePopup() {
|
|
319
|
+
this.showPopup = false;
|
|
320
|
+
window.dispatchEvent(new CustomEvent('popupClosed', {
|
|
321
|
+
detail: { message: 'User closed the popup' }
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Lifecycle method: Clean up event listeners when the component is removed
|
|
326
|
+
*/
|
|
327
|
+
disconnectedCallback() {
|
|
328
|
+
var _a;
|
|
329
|
+
if (this.countdownTimer) {
|
|
330
|
+
clearInterval(this.countdownTimer);
|
|
331
|
+
}
|
|
332
|
+
(_a = this.stylingSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Lifecycle method: Fetch translations on component load
|
|
336
|
+
*/
|
|
337
|
+
async componentWillLoad() {
|
|
338
|
+
if (this.translationUrl.length > 2) {
|
|
339
|
+
await getTranslations(this.translationUrl);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Lifecycle method: Set up event listeners after the component is rendered
|
|
344
|
+
*/
|
|
345
|
+
componentDidLoad() {
|
|
346
|
+
if (this.stylingContainer) {
|
|
347
|
+
if (window.emMessageBuss != undefined) {
|
|
348
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
if (this.clientStyling)
|
|
352
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
353
|
+
if (this.clientStylingUrl)
|
|
354
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Renders the OTP authentication component.
|
|
360
|
+
* Displays the OTP popup, input fields, timer, and action buttons.
|
|
361
|
+
*/
|
|
362
|
+
render() {
|
|
363
|
+
return (h("div", { key: '2761de23ad41b4ead177d63931e7756584defd11' }, this.showPopup && (h("div", { key: '1d01dd47770c5190a5c5c3e0c6e2c4af9e71ae15', class: "OtpPopupOverlay" }, h("div", { key: '626dbc731ca03790bf9cae42e56919851928a36f', class: "OtpPopupContent" }, this.isLoading ? (h("div", { class: "OtpLoaderContainer" }, h("span", { class: "OtpLoader" }))) : (this.hasConfigErrors ? (h("div", { class: "OtpError" }, h("div", { class: "OtpErrorHeader" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 512 512" }, h("path", { d: "M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z" })), h("h2", null, translate('errorHeader', this.language))), h("p", null, this.errorMessage), h("button", { class: "OtpButton error", onClick: this.closePopup }, translate('close', this.language)))) : (h(Fragment, null, h("div", { class: "otp-description" }, h("p", null, translate('popupMessage', this.language)), this.hasErrors && h("p", { class: "OtpErrorMessage" }, this.errorMessage)), h("div", { class: "OtpFieldWrapper" }, h("h2", null, translate('otpHeading', this.language)), h("div", { class: "OtpField", ref: this.setOtpContainerRef }, this.otp.map((char, index) => {
|
|
364
|
+
const isHalfway = this.config.inputLength % 2 === 0 && index === (this.config.inputLength / 2) - 1;
|
|
365
|
+
return (h("input", { key: index, ref: el => this.setOtpInputRef(el, index), id: `otp-input-${index}`, type: "text", class: `otp-box ${isHalfway ? 'space' : ''}`, maxLength: 1, value: char, onInput: (event) => this.handleOtpInput(event, index), onKeyDown: (event) => this.handleKeyDown(event, index), onPaste: (event) => this.handleOnPasteOtp(event), disabled: this.timeLeft <= 0 }));
|
|
366
|
+
})), h("div", { class: "otp-timer" }, this.formatTime(this.timeLeft), " ", translate('minutes', this.language))), h("div", { class: "OtpActionButtons" }, this.showResendOtp ? (h("button", { class: "OtpButton", onClick: this.handleResendOtp }, translate('resendOtp', this.language))) : (h("button", { class: "OtpButton", onClick: this.submitOtp, disabled: this.otp.join('').length !== this.config.inputLength }, translate('submit', this.language))), h("button", { class: "OtpButton", onClick: this.closePopup }, translate('close', this.language)))))))))));
|
|
367
|
+
}
|
|
368
|
+
static get is() { return "player-step-up-auth"; }
|
|
369
|
+
static get encapsulation() { return "shadow"; }
|
|
370
|
+
static get originalStyleUrls() {
|
|
371
|
+
return {
|
|
372
|
+
"$": ["player-step-up-auth.scss"]
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
static get styleUrls() {
|
|
376
|
+
return {
|
|
377
|
+
"$": ["player-step-up-auth.css"]
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
static get properties() {
|
|
381
|
+
return {
|
|
382
|
+
"mbSource": {
|
|
383
|
+
"type": "string",
|
|
384
|
+
"mutable": false,
|
|
385
|
+
"complexType": {
|
|
386
|
+
"original": "string",
|
|
387
|
+
"resolved": "string",
|
|
388
|
+
"references": {}
|
|
389
|
+
},
|
|
390
|
+
"required": false,
|
|
391
|
+
"optional": false,
|
|
392
|
+
"docs": {
|
|
393
|
+
"tags": [],
|
|
394
|
+
"text": "Message bus source identifier, used for styling and communication."
|
|
395
|
+
},
|
|
396
|
+
"attribute": "mb-source",
|
|
397
|
+
"reflect": true
|
|
398
|
+
},
|
|
399
|
+
"clientStyling": {
|
|
400
|
+
"type": "string",
|
|
401
|
+
"mutable": false,
|
|
402
|
+
"complexType": {
|
|
403
|
+
"original": "string",
|
|
404
|
+
"resolved": "string",
|
|
405
|
+
"references": {}
|
|
406
|
+
},
|
|
407
|
+
"required": false,
|
|
408
|
+
"optional": false,
|
|
409
|
+
"docs": {
|
|
410
|
+
"tags": [],
|
|
411
|
+
"text": "Inline CSS styles applied to the component."
|
|
412
|
+
},
|
|
413
|
+
"attribute": "client-styling",
|
|
414
|
+
"reflect": true
|
|
415
|
+
},
|
|
416
|
+
"clientStylingUrl": {
|
|
417
|
+
"type": "string",
|
|
418
|
+
"mutable": false,
|
|
419
|
+
"complexType": {
|
|
420
|
+
"original": "string",
|
|
421
|
+
"resolved": "string",
|
|
422
|
+
"references": {}
|
|
423
|
+
},
|
|
424
|
+
"required": false,
|
|
425
|
+
"optional": false,
|
|
426
|
+
"docs": {
|
|
427
|
+
"tags": [],
|
|
428
|
+
"text": "URL to an external CSS file for styling the component."
|
|
429
|
+
},
|
|
430
|
+
"attribute": "client-styling-url",
|
|
431
|
+
"reflect": true
|
|
432
|
+
},
|
|
433
|
+
"language": {
|
|
434
|
+
"type": "string",
|
|
435
|
+
"mutable": false,
|
|
436
|
+
"complexType": {
|
|
437
|
+
"original": "string",
|
|
438
|
+
"resolved": "string",
|
|
439
|
+
"references": {}
|
|
440
|
+
},
|
|
441
|
+
"required": false,
|
|
442
|
+
"optional": false,
|
|
443
|
+
"docs": {
|
|
444
|
+
"tags": [],
|
|
445
|
+
"text": "Language setting for translations (default: 'en')."
|
|
446
|
+
},
|
|
447
|
+
"attribute": "language",
|
|
448
|
+
"reflect": true,
|
|
449
|
+
"defaultValue": "'en'"
|
|
450
|
+
},
|
|
451
|
+
"endpoint": {
|
|
452
|
+
"type": "string",
|
|
453
|
+
"mutable": false,
|
|
454
|
+
"complexType": {
|
|
455
|
+
"original": "string",
|
|
456
|
+
"resolved": "string",
|
|
457
|
+
"references": {}
|
|
458
|
+
},
|
|
459
|
+
"required": false,
|
|
460
|
+
"optional": false,
|
|
461
|
+
"docs": {
|
|
462
|
+
"tags": [],
|
|
463
|
+
"text": "Base API endpoint used for fetching OTP configuration and validation."
|
|
464
|
+
},
|
|
465
|
+
"attribute": "endpoint",
|
|
466
|
+
"reflect": true
|
|
467
|
+
},
|
|
468
|
+
"userSession": {
|
|
469
|
+
"type": "string",
|
|
470
|
+
"mutable": false,
|
|
471
|
+
"complexType": {
|
|
472
|
+
"original": "string",
|
|
473
|
+
"resolved": "string",
|
|
474
|
+
"references": {}
|
|
475
|
+
},
|
|
476
|
+
"required": false,
|
|
477
|
+
"optional": false,
|
|
478
|
+
"docs": {
|
|
479
|
+
"tags": [],
|
|
480
|
+
"text": "User session token, potentially used for authentication or tracking."
|
|
481
|
+
},
|
|
482
|
+
"attribute": "user-session",
|
|
483
|
+
"reflect": true
|
|
484
|
+
},
|
|
485
|
+
"translationUrl": {
|
|
486
|
+
"type": "string",
|
|
487
|
+
"mutable": false,
|
|
488
|
+
"complexType": {
|
|
489
|
+
"original": "string",
|
|
490
|
+
"resolved": "string",
|
|
491
|
+
"references": {}
|
|
492
|
+
},
|
|
493
|
+
"required": false,
|
|
494
|
+
"optional": false,
|
|
495
|
+
"docs": {
|
|
496
|
+
"tags": [],
|
|
497
|
+
"text": "URL for fetching translation files to support multiple languages."
|
|
498
|
+
},
|
|
499
|
+
"attribute": "translation-url",
|
|
500
|
+
"reflect": true,
|
|
501
|
+
"defaultValue": "''"
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
static get states() {
|
|
506
|
+
return {
|
|
507
|
+
"showPopup": {},
|
|
508
|
+
"otp": {},
|
|
509
|
+
"isLoading": {},
|
|
510
|
+
"config": {},
|
|
511
|
+
"timeLeft": {},
|
|
512
|
+
"expirationTime": {},
|
|
513
|
+
"serverTime": {},
|
|
514
|
+
"hasErrors": {},
|
|
515
|
+
"hasConfigErrors": {},
|
|
516
|
+
"errorMessage": {},
|
|
517
|
+
"token": {},
|
|
518
|
+
"showResendOtp": {}
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
static get elementRef() { return "el"; }
|
|
522
|
+
static get watchers() {
|
|
523
|
+
return [{
|
|
524
|
+
"propName": "translationUrl",
|
|
525
|
+
"methodName": "handleNewTranslations"
|
|
526
|
+
}, {
|
|
527
|
+
"propName": "clientStyling",
|
|
528
|
+
"methodName": "handleClientStylingChange"
|
|
529
|
+
}, {
|
|
530
|
+
"propName": "clientStylingUrl",
|
|
531
|
+
"methodName": "handleClientStylingUrlChange"
|
|
532
|
+
}];
|
|
533
|
+
}
|
|
534
|
+
static get listeners() {
|
|
535
|
+
return [{
|
|
536
|
+
"name": "stepUpAuthRequired",
|
|
537
|
+
"method": "handleStepUpAuthEvent",
|
|
538
|
+
"target": "window",
|
|
539
|
+
"capture": false,
|
|
540
|
+
"passive": false
|
|
541
|
+
}];
|
|
542
|
+
}
|
|
543
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/player-step-up-auth';
|
|
File without changes
|