@sambath999/localize-token 18.0.3 → 18.0.5

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.
Files changed (31) hide show
  1. package/esm2022/localize-logindlg/localize-logindlg.component.mjs +210 -0
  2. package/esm2022/localize-logindlg/localize-logindlg.module.mjs +39 -0
  3. package/esm2022/localize-logindlg/localize-logindlg.service.mjs +33 -0
  4. package/esm2022/localize-logindlg/public-api.mjs +4 -0
  5. package/esm2022/localize-token/localize.api.service.mjs +138 -0
  6. package/esm2022/localize-token/localize.token.mjs +54 -0
  7. package/esm2022/{lib → localize-token}/localize.token.module.mjs +1 -1
  8. package/esm2022/localize-token/localize.token.service.mjs +61 -0
  9. package/esm2022/localize-token/localize.token.storage.mjs +113 -0
  10. package/esm2022/localize-token/public-api.mjs +6 -0
  11. package/esm2022/public-api.mjs +3 -2
  12. package/fesm2022/sambath999-localize-token.mjs +342 -43
  13. package/fesm2022/sambath999-localize-token.mjs.map +1 -1
  14. package/localize-logindlg/localize-logindlg.component.d.ts +32 -0
  15. package/localize-logindlg/localize-logindlg.module.d.ts +12 -0
  16. package/localize-logindlg/localize-logindlg.service.d.ts +10 -0
  17. package/localize-logindlg/public-api.d.ts +3 -0
  18. package/{lib → localize-token}/localize.api.service.d.ts +25 -3
  19. package/{lib → localize-token}/localize.token.service.d.ts +9 -9
  20. package/localize-token/public-api.d.ts +5 -0
  21. package/package.json +6 -11
  22. package/public-api.d.ts +2 -1
  23. package/esm2022/lib/index.mjs +0 -6
  24. package/esm2022/lib/localize.api.service.mjs +0 -119
  25. package/esm2022/lib/localize.token.mjs +0 -54
  26. package/esm2022/lib/localize.token.service.mjs +0 -64
  27. package/esm2022/lib/localize.token.storage.mjs +0 -101
  28. package/lib/index.d.ts +0 -5
  29. /package/{lib → localize-token}/localize.token.d.ts +0 -0
  30. /package/{lib → localize-token}/localize.token.module.d.ts +0 -0
  31. /package/{lib → localize-token}/localize.token.storage.d.ts +0 -0
@@ -1,9 +1,22 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, NgModule } from '@angular/core';
2
+ import { Injectable, NgModule, Component, ViewEncapsulation, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3
3
  import { BehaviorSubject } from 'rxjs';
4
4
  import * as jwt_decode from 'jwt-decode';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpHeaders } from '@angular/common/http';
7
+ import * as i1$1 from 'primeng/api';
8
+ import { MessageService } from 'primeng/api';
9
+ import * as i2 from 'primeng/dynamicdialog';
10
+ import { DialogService } from 'primeng/dynamicdialog';
11
+ import * as i5 from '@angular/common';
12
+ import { CommonModule } from '@angular/common';
13
+ import * as i6 from 'primeng/toast';
14
+ import { ToastModule } from 'primeng/toast';
15
+ import * as i7 from 'primeng/inputtext';
16
+ import { InputTextModule } from 'primeng/inputtext';
17
+ import * as i8 from '@angular/forms';
18
+ import { FormsModule } from '@angular/forms';
19
+ import { BrowserModule } from '@angular/platform-browser';
7
20
 
8
21
  /**
9
22
  * Assembly of @package ng2-cookies @see https://www.npmjs.com/package/ng2-cookies
@@ -63,7 +76,20 @@ class LocalizeTokenStorageHelper {
63
76
  }
64
77
  return cookies;
65
78
  }
66
- get defaultOptions() { return LocalizeToken.cookieOptions; }
79
+ get defaultOptions() {
80
+ const getMainDomain = (subdomain) => {
81
+ const parts = subdomain.split('.');
82
+ return parts.length > 2 ? parts.slice(-2).join('.') : subdomain;
83
+ };
84
+ const mainDomain = getMainDomain(window.location.hostname);
85
+ return {
86
+ path: '/',
87
+ domain: mainDomain,
88
+ secure: true,
89
+ // samesite: SameSiteType.strict,
90
+ expires: 1
91
+ };
92
+ }
67
93
  set(name, value, options) {
68
94
  options ??= this.defaultOptions;
69
95
  const { expires, path, domain, secure, samesite } = options;
@@ -160,30 +186,27 @@ async function waitUntil(when, intervalNumber = 50) {
160
186
 
161
187
  class LocalizeTokenService {
162
188
  isRevokingTokenSubject = new BehaviorSubject(false);
163
- getAuthToken() { return this.storageGet(); }
164
- setAuthToken(value) {
189
+ get authToken() { return this.storageGet(); }
190
+ set authToken(value) {
165
191
  value
166
192
  ? this.storageSet(value)
167
193
  : LocalizeToken.storage.delete(LocalizeToken.config.authTokenName);
168
194
  }
169
- getRefreshToken() { return LocalizeToken.storage.get(LocalizeToken.config.refreshTokenName); }
170
- getAccessToken() { return this.getAuthToken()?.token; }
171
- setAccessToken(value) {
195
+ get refreshToken() { return LocalizeToken.storage.get(LocalizeToken.config.refreshTokenName); }
196
+ get accessToken() { return this.authToken?.token; }
197
+ set accessToken(value) {
172
198
  if (value) {
173
- this.setAuthToken({ token: value, revoke: false });
199
+ this.authToken = { token: value, revoke: false };
174
200
  }
175
201
  }
176
- getIsRevokingToken() { return this.isRevokingTokenSubject.value; }
177
- setIsRevokingToken(value) {
202
+ get isRevokingToken() { return this.isRevokingTokenSubject.value; /* this.authToken?.revoke ?? false */ }
203
+ set isRevokingToken(value) {
178
204
  this.isRevokingTokenSubject.next(value);
179
- if (this.getAuthToken()) {
180
- const authToken = this.getAuthToken();
181
- if (authToken) {
182
- this.setAuthToken({ ...authToken, revoke: value });
183
- }
205
+ if (this.authToken) {
206
+ this.authToken = { ...this.authToken, revoke: value };
184
207
  }
185
208
  }
186
- getTenantToken() { return LocalizeToken.storage.get(LocalizeToken.config.tenantTokenName); }
209
+ get tenantToken() { return LocalizeToken.storage.get(LocalizeToken.config.tenantTokenName); }
187
210
  constructor() { }
188
211
  storageGet() {
189
212
  try {
@@ -200,10 +223,10 @@ class LocalizeTokenService {
200
223
  LocalizeToken.storage.set(LocalizeToken.config.authTokenName, base64);
201
224
  }
202
225
  tokensValid() {
203
- return this.getRefreshToken()?.length && (!LocalizeToken.config.needTenant || this.getTenantToken()?.length);
226
+ return this.refreshToken?.length && (!LocalizeToken.config.needTenant || this.tenantToken?.length);
204
227
  }
205
228
  decodeToken = (token) => jwt_decode.jwtDecode(token);
206
- getDecodeRefreshToken() {
229
+ get decodeRefreshToken() {
207
230
  const token = LocalizeToken.storage.get(LocalizeToken.config.refreshTokenName);
208
231
  if (!token)
209
232
  return null;
@@ -217,6 +240,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
217
240
  args: [{ providedIn: 'root' }]
218
241
  }], ctorParameters: () => [] });
219
242
 
243
+ /**
244
+ * Http method options
245
+ */
220
246
  var EMethod;
221
247
  (function (EMethod) {
222
248
  EMethod[EMethod["POST"] = 1] = "POST";
@@ -230,42 +256,57 @@ class LocalizeApiService {
230
256
  localizeTokenService;
231
257
  isRequestingSubject = new BehaviorSubject(false);
232
258
  isResolvedStartupSubject = new BehaviorSubject(false);
259
+ get isRequesting() { return this.isRequestingSubject.value; }
260
+ get isResolvedStartup() { return this.isResolvedStartupSubject.value; }
233
261
  apiConfigs = {};
234
262
  constructor(httpClient, localizeTokenService) {
235
263
  this.httpClient = httpClient;
236
264
  this.localizeTokenService = localizeTokenService;
237
265
  }
238
- get isRequesting() { return this.isRequestingSubject.value; }
239
- get isResolvedStartup() { return this.isResolvedStartupSubject.value; }
266
+ /**
267
+ * Initialize the API service.
268
+ * @param apiConfigs - The API configurations.
269
+ */
240
270
  init(apiConfigs) {
241
271
  this.apiConfigs = apiConfigs;
242
272
  }
273
+ /**
274
+ * A higher-order function that returns a curried function for making API requests.
275
+ *
276
+ * @param baseUrl - The base URL of the API.
277
+ * @returns A curried function that can be used to make API requests.
278
+ */
243
279
  func = (baseUrl) => (path, method = EMethod.GET, value = null, isFormData = false, headers) => this.base(baseUrl, path, method, value, isFormData, headers);
244
280
  async base(baseUrl, path, method = EMethod.GET, value = null, isFormData = false, headers) {
245
281
  await this.ifPromise(this.apiConfigs.onPrepareRequest);
246
282
  const url = `${baseUrl.trim().replace(/\/?$/, '/')}${path.trim().replace(/^\//, '')}`;
247
283
  const httpMethod = EMethod[method].toLowerCase();
248
- const request = { body: value, headers: this.options(isFormData, headers) };
284
+ const request = () => { return { body: value, headers: this.options(isFormData, headers) }; };
285
+ // Wait for previous request to complete
249
286
  await this.toWaitForPreviousRequest();
287
+ // Process request
250
288
  try {
251
- return await this.processRequest(httpMethod, url, request);
289
+ return await this.processRequest(httpMethod, url, request());
252
290
  }
291
+ // Handle unauthorized error if any
253
292
  catch (error) {
254
- if (error.status !== 401)
293
+ if (error.status !== 401) {
255
294
  throw error;
295
+ }
256
296
  return await this.onUnauthorizedError(httpMethod, url, request);
257
297
  }
258
298
  }
259
299
  async onUnauthorizedError(httpMethod, url, request) {
260
300
  await this.revokeToken();
261
301
  if (!this.isResolvedStartup) {
262
- return await this.processRequest(httpMethod, url, request);
302
+ return await this.processRequest(httpMethod, url, request());
263
303
  }
264
304
  }
265
305
  async toWaitForPreviousRequest() {
266
- if (this.localizeTokenService.getIsRevokingToken()) {
267
- await waitUntil(() => !this.localizeTokenService.getIsRevokingToken());
306
+ if (this.localizeTokenService.isRevokingToken) {
307
+ await waitUntil(() => !this.localizeTokenService.isRevokingToken);
268
308
  }
309
+ // to wait for each request in 50ms, even if the request is not completed
269
310
  await waitFor(50, this.isRequesting);
270
311
  }
271
312
  async processRequest(method, url, options) {
@@ -275,19 +316,19 @@ class LocalizeApiService {
275
316
  return result;
276
317
  }
277
318
  async revokeToken(force = false) {
278
- if (this.localizeTokenService.getIsRevokingToken() && !force) {
279
- await waitUntil(() => !this.localizeTokenService.getIsRevokingToken());
319
+ if (this.localizeTokenService.isRevokingToken && !force) {
320
+ await waitUntil(() => !this.localizeTokenService.isRevokingToken);
280
321
  return;
281
322
  }
282
323
  try {
283
- this.localizeTokenService.setIsRevokingToken(true);
324
+ this.localizeTokenService.isRevokingToken = true;
284
325
  const reqUrl = LocalizeToken.config.revokeTokenUrl;
285
- const reqHeaders = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, `${this.localizeTokenService.getRefreshToken()}`);
326
+ const reqHeaders = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, `${this.localizeTokenService.refreshToken}`);
286
327
  const revokeToken = await new Promise((resolve, reject) => this.httpClient.get(reqUrl, { headers: reqHeaders }).subscribe({ next: resolve, error: reject }));
287
328
  if (revokeToken?.status) {
288
- this.localizeTokenService.setAccessToken(revokeToken.message);
329
+ this.localizeTokenService.accessToken = revokeToken.message;
289
330
  }
290
- else if (!this.localizeTokenService.getRefreshToken()) {
331
+ else if (!this.localizeTokenService.refreshToken) {
291
332
  await this.ifPromise(this.apiConfigs.onAutoLogout);
292
333
  }
293
334
  else {
@@ -298,30 +339,31 @@ class LocalizeApiService {
298
339
  }
299
340
  }
300
341
  finally {
301
- this.localizeTokenService.setIsRevokingToken(false);
342
+ this.localizeTokenService.isRevokingToken = false;
302
343
  }
303
344
  }
345
+ /** default http request options */
304
346
  options(isFormData = false, headers = {}) {
305
- const defaultHeaders = {
306
- [LocalizeToken.httpHeaders.AUTHORIZATION]: `Bearer ${this.localizeTokenService.getAccessToken()}`
307
- };
347
+ const defaultHeaders = { [LocalizeToken.httpHeaders.AUTHORIZATION]: `Bearer ${this.localizeTokenService.accessToken}`, };
308
348
  if (LocalizeToken.config.needTenant) {
309
- defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = `${this.localizeTokenService.getTenantToken()}`;
349
+ defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = `${this.localizeTokenService.tenantToken}`;
310
350
  }
311
351
  if (!isFormData) {
312
352
  defaultHeaders[LocalizeToken.httpHeaders.CONTENT_TYPE] = 'application/json';
313
353
  }
314
- const mergedHeaders = { ...defaultHeaders, ...headers };
354
+ const filteredHeaders = Object.keys(defaultHeaders).filter(key => !Object.keys(headers).includes(key))
355
+ .reduce((acc, key) => ({ ...acc, [key]: defaultHeaders[key] }), {});
356
+ const mergedHeaders = { ...filteredHeaders, ...headers };
315
357
  return new HttpHeaders(mergedHeaders);
316
358
  }
317
359
  async ifPromise(fn) {
318
- if (fn) {
319
- return fn instanceof Promise ? await fn() : fn();
320
- }
360
+ if (!fn)
361
+ return;
362
+ return fn instanceof Promise ? await fn() : fn();
321
363
  }
322
364
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeApiService, deps: [{ token: i1.HttpClient }, { token: LocalizeTokenService }], target: i0.ɵɵFactoryTarget.Injectable });
323
365
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeApiService, providedIn: 'root' });
324
- }
366
+ } //class
325
367
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeApiService, decorators: [{
326
368
  type: Injectable,
327
369
  args: [{
@@ -347,9 +389,266 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
347
389
  }]
348
390
  }] });
349
391
 
392
+ class LocalizeLogindlgComponent {
393
+ messageService;
394
+ cdt;
395
+ dlgRef;
396
+ dlgConfig;
397
+ tokenService;
398
+ httpClient;
399
+ messageKey = "$login-dlg";
400
+ password;
401
+ decodeToken;
402
+ loading = false;
403
+ success = false;
404
+ config;
405
+ logout;
406
+ loginUrl;
407
+ constructor(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient) {
408
+ this.messageService = messageService;
409
+ this.cdt = cdt;
410
+ this.dlgRef = dlgRef;
411
+ this.dlgConfig = dlgConfig;
412
+ this.tokenService = tokenService;
413
+ this.httpClient = httpClient;
414
+ this.decodeToken = this.tokenService.decodeRefreshToken;
415
+ this.config = LocalizeToken.config;
416
+ }
417
+ ngOnInit() {
418
+ this.dlgConfig.closable = false;
419
+ this.logout = this.dlgConfig.data?.logout;
420
+ this.loginUrl = this.dlgConfig.data?.loginUrl;
421
+ if (!this.decodeToken) {
422
+ this.messageService.add({
423
+ key: this.messageKey,
424
+ severity: "error",
425
+ summary: "Token is invalid",
426
+ });
427
+ setTimeout(() => this.logout?.(), 2000);
428
+ }
429
+ }
430
+ ngAfterViewInit() {
431
+ this.cdt.detectChanges();
432
+ }
433
+ async clickLogin() {
434
+ if (!this.isValidPassword) {
435
+ this.messageService.add({
436
+ key: this.messageKey,
437
+ severity: "error",
438
+ summary: "Password is required and must be at least 6 characters",
439
+ });
440
+ }
441
+ this.loading = true;
442
+ const loginRes = await this.login();
443
+ if (!loginRes?.status) {
444
+ this.messageService.add({
445
+ key: this.messageKey,
446
+ severity: "error",
447
+ summary: loginRes.message,
448
+ });
449
+ this.loading = false;
450
+ return;
451
+ }
452
+ this.tokenService.accessToken = loginRes.tokens.accessToken;
453
+ LocalizeToken.storage.set(this.config.refreshTokenName, loginRes.tokens.refreshToken);
454
+ this.success = true;
455
+ setTimeout(() => this.dlgRef.close(true), 2000);
456
+ }
457
+ async login() {
458
+ const path = this.loginUrl ?? "/api/auth/login";
459
+ const response = await new Promise((resolve, reject) => this.httpClient
460
+ .post(path, { password: this.password.trim() }, { headers: this.getHeaders() })
461
+ .subscribe({ next: resolve, error: reject }));
462
+ return response;
463
+ }
464
+ getHeaders() {
465
+ return {
466
+ [LocalizeToken.httpHeaders.X_REFRESH_TOKEN]: LocalizeToken.storage.get(this.config.refreshTokenName),
467
+ [LocalizeToken.httpHeaders.X_TENANT]: LocalizeToken.storage.get(this.config.tenantTokenName) ?? "",
468
+ };
469
+ }
470
+ get isValidPassword() {
471
+ return this.password && this.password.trim().length >= 6;
472
+ }
473
+ clickLogout = () => this.logout?.();
474
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgComponent, deps: [{ token: i1$1.MessageService }, { token: i0.ChangeDetectorRef }, { token: i2.DynamicDialogRef }, { token: i2.DynamicDialogConfig }, { token: LocalizeTokenService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
475
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.12", type: LocalizeLogindlgComponent, selector: "app-localize-logindlg", providers: [MessageService], ngImport: i0, template: `<p-toast key="$login-dlg" position="top-center"></p-toast>
476
+ <div id="login-dlg-wrap">
477
+ <div id="login-dlg-header">
478
+ <div id="login-logo" class="p-mb-2"></div>
479
+ <h3 *ngIf="!success">Your session is expired! <br> Please login again to continue.</h3>
480
+ <h3 *ngIf="success" style="color:green !important;">You haved successfully logged in.</h3>
481
+ </div>
482
+ <div id="login-dlg-content">
483
+ <ng-container *ngIf="!success">
484
+ <div class="login-dlg-elm">
485
+ <div class="p-inputgroup">
486
+ <span class="p-inputgroup-addon">
487
+ <i class="material-icons-round">person</i>
488
+ </span>
489
+ <input disabled pInputText type="text" placeholder="Username" [value]="decodeToken?.email" />
490
+ </div>
491
+ </div>
492
+
493
+ <div class="login-dlg-elm">
494
+ <div class="p-inputgroup">
495
+ <span class="p-inputgroup-addon">
496
+ <i class="material-icons-round">lock</i>
497
+ </span>
498
+ <input (keydown.enter)="clickLogin()" pInputText type="password" placeholder="Password" [(ngModel)]="password"
499
+ autofocus />
500
+ </div>
501
+ </div>
502
+ <div class="login-dlg-elm">
503
+ <button style="width: 100%;" pButton type="button" label="Login" (click)="clickLogin()"
504
+ [disabled]="!password || loading"></button>
505
+ </div>
506
+
507
+ <div class="login-dlg-elm" style="display:flex;align-items: center;user-select: none;">
508
+ <span>No, I want to login with another user.</span>
509
+ <button class="p-button-text" pButton type="button" label="Logout" (click)="clickLogout()"></button>
510
+ </div>
511
+ </ng-container>
512
+
513
+ <ng-container *ngIf="success">
514
+ <div style="margin-top:35px;"></div>
515
+ <div class="check-animation-wrap">
516
+ <div class="check-main-container">
517
+ <div class="check-container">
518
+ <div class="check-background">
519
+ <svg viewBox="0 0 65 51" fill="none" xmlns="http://www.w3.org/2000/svg">
520
+ <path d="M7 25L27.3077 44L58.5 7" stroke="white" stroke-width="13" stroke-linecap="round"
521
+ stroke-linejoin="round"></path>
522
+ </svg>
523
+ </div>
524
+ </div>
525
+ </div>
526
+ </div>
527
+ </ng-container>
528
+ </div>
529
+ </div>`, isInline: true, styles: ["#login-dlg-wrap{width:100%;max-width:400px;margin:0 auto;padding:30px}.login-dlg-elm{margin-top:1rem}#login-dlg-header{display:flex;flex-direction:column;align-items:center;justify-content:center}#login-dlg-header h3{font-weight:700;font-size:.9rem;color:orange;text-align:center}#login-logo{height:40px;width:40px;background:url(/assets/images/logo-300px.png) no-repeat;background-size:contain}#login-dlg-content .p-inputgroup{height:45px}#login-dlg-content .p-inputgroup .p-inputgroup-addon{height:45px;border-radius:15px 0 0 15px;width:50px}#login-dlg-content .p-inputgroup .p-inputgroup-addon *{font-size:1rem}#login-dlg-content .p-inputgroup input{height:45px;border-radius:0 15px 15px 0}#login-dlg-content button{height:45px;border-radius:15px}.check-animation-wrap{top:0;left:0;position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:calc(100% - 200px);min-height:400px}.check-main-container{width:100%;height:100vh;display:flex;flex-flow:column;justify-content:center;align-items:center}.check-container{width:6.25rem;height:7.5rem;display:flex;flex-flow:column;align-items:center;justify-content:space-between}.check-container .check-background{width:100%;height:calc(100% - 1.25rem);background:linear-gradient(to bottom right,#5de593,#41d67c);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset;transform:scale(.84);border-radius:50%;animation:animateContainer .75s ease-out forwards .75s;display:flex;align-items:center;justify-content:center;opacity:0}.check-container .check-background svg{width:65%;transform:translateY(.25rem);stroke-dasharray:80;stroke-dashoffset:80;animation:animateCheck .35s forwards 1.25s ease-out;min-width:auto!important}.check-container .check-shadow{bottom:calc(-15% - 5px);left:0;border-radius:50%;background:radial-gradient(closest-side,rgba(73,218,131,1),transparent);animation:animateShadow .75s ease-out forwards .75s}@keyframes animateContainer{0%{opacity:0;transform:scale(0);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset}25%{opacity:1;transform:scale(.9);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset}43.75%{transform:scale(1.15);box-shadow:0 0 0 43.334px #ffffff40 inset,0 0 0 65px #ffffff40 inset}62.5%{transform:scale(1);box-shadow:0 0 #ffffff40 inset,0 0 0 21.667px #ffffff40 inset}81.25%{box-shadow:0 0 #ffffff40 inset,0 0 #ffffff40 inset}to{opacity:1;box-shadow:0 0 #ffffff40 inset,0 0 #ffffff40 inset}}@keyframes animateCheck{0%{stroke-dashoffset:80}to{stroke-dashoffset:0}}@keyframes animateShadow{0%{opacity:0;width:100%;height:15%}25%{opacity:.25}43.75%{width:40%;height:7%;opacity:.35}to{width:85%;height:15%;opacity:.25}}\n"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i6.Toast, selector: "p-toast", inputs: ["key", "autoZIndex", "baseZIndex", "life", "style", "styleClass", "position", "preventOpenDuplicates", "preventDuplicates", "showTransformOptions", "hideTransformOptions", "showTransitionOptions", "hideTransitionOptions", "breakpoints"], outputs: ["onClose"] }, { kind: "directive", type: i7.InputText, selector: "[pInputText]", inputs: ["variant"] }, { kind: "directive", type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], encapsulation: i0.ViewEncapsulation.None });
530
+ }
531
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgComponent, decorators: [{
532
+ type: Component,
533
+ args: [{ template: `<p-toast key="$login-dlg" position="top-center"></p-toast>
534
+ <div id="login-dlg-wrap">
535
+ <div id="login-dlg-header">
536
+ <div id="login-logo" class="p-mb-2"></div>
537
+ <h3 *ngIf="!success">Your session is expired! <br> Please login again to continue.</h3>
538
+ <h3 *ngIf="success" style="color:green !important;">You haved successfully logged in.</h3>
539
+ </div>
540
+ <div id="login-dlg-content">
541
+ <ng-container *ngIf="!success">
542
+ <div class="login-dlg-elm">
543
+ <div class="p-inputgroup">
544
+ <span class="p-inputgroup-addon">
545
+ <i class="material-icons-round">person</i>
546
+ </span>
547
+ <input disabled pInputText type="text" placeholder="Username" [value]="decodeToken?.email" />
548
+ </div>
549
+ </div>
550
+
551
+ <div class="login-dlg-elm">
552
+ <div class="p-inputgroup">
553
+ <span class="p-inputgroup-addon">
554
+ <i class="material-icons-round">lock</i>
555
+ </span>
556
+ <input (keydown.enter)="clickLogin()" pInputText type="password" placeholder="Password" [(ngModel)]="password"
557
+ autofocus />
558
+ </div>
559
+ </div>
560
+ <div class="login-dlg-elm">
561
+ <button style="width: 100%;" pButton type="button" label="Login" (click)="clickLogin()"
562
+ [disabled]="!password || loading"></button>
563
+ </div>
564
+
565
+ <div class="login-dlg-elm" style="display:flex;align-items: center;user-select: none;">
566
+ <span>No, I want to login with another user.</span>
567
+ <button class="p-button-text" pButton type="button" label="Logout" (click)="clickLogout()"></button>
568
+ </div>
569
+ </ng-container>
570
+
571
+ <ng-container *ngIf="success">
572
+ <div style="margin-top:35px;"></div>
573
+ <div class="check-animation-wrap">
574
+ <div class="check-main-container">
575
+ <div class="check-container">
576
+ <div class="check-background">
577
+ <svg viewBox="0 0 65 51" fill="none" xmlns="http://www.w3.org/2000/svg">
578
+ <path d="M7 25L27.3077 44L58.5 7" stroke="white" stroke-width="13" stroke-linecap="round"
579
+ stroke-linejoin="round"></path>
580
+ </svg>
581
+ </div>
582
+ </div>
583
+ </div>
584
+ </div>
585
+ </ng-container>
586
+ </div>
587
+ </div>`, selector: "app-localize-logindlg", providers: [MessageService], encapsulation: ViewEncapsulation.None, styles: ["#login-dlg-wrap{width:100%;max-width:400px;margin:0 auto;padding:30px}.login-dlg-elm{margin-top:1rem}#login-dlg-header{display:flex;flex-direction:column;align-items:center;justify-content:center}#login-dlg-header h3{font-weight:700;font-size:.9rem;color:orange;text-align:center}#login-logo{height:40px;width:40px;background:url(/assets/images/logo-300px.png) no-repeat;background-size:contain}#login-dlg-content .p-inputgroup{height:45px}#login-dlg-content .p-inputgroup .p-inputgroup-addon{height:45px;border-radius:15px 0 0 15px;width:50px}#login-dlg-content .p-inputgroup .p-inputgroup-addon *{font-size:1rem}#login-dlg-content .p-inputgroup input{height:45px;border-radius:0 15px 15px 0}#login-dlg-content button{height:45px;border-radius:15px}.check-animation-wrap{top:0;left:0;position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:calc(100% - 200px);min-height:400px}.check-main-container{width:100%;height:100vh;display:flex;flex-flow:column;justify-content:center;align-items:center}.check-container{width:6.25rem;height:7.5rem;display:flex;flex-flow:column;align-items:center;justify-content:space-between}.check-container .check-background{width:100%;height:calc(100% - 1.25rem);background:linear-gradient(to bottom right,#5de593,#41d67c);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset;transform:scale(.84);border-radius:50%;animation:animateContainer .75s ease-out forwards .75s;display:flex;align-items:center;justify-content:center;opacity:0}.check-container .check-background svg{width:65%;transform:translateY(.25rem);stroke-dasharray:80;stroke-dashoffset:80;animation:animateCheck .35s forwards 1.25s ease-out;min-width:auto!important}.check-container .check-shadow{bottom:calc(-15% - 5px);left:0;border-radius:50%;background:radial-gradient(closest-side,rgba(73,218,131,1),transparent);animation:animateShadow .75s ease-out forwards .75s}@keyframes animateContainer{0%{opacity:0;transform:scale(0);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset}25%{opacity:1;transform:scale(.9);box-shadow:0 0 0 65px #ffffff40 inset,0 0 0 65px #ffffff40 inset}43.75%{transform:scale(1.15);box-shadow:0 0 0 43.334px #ffffff40 inset,0 0 0 65px #ffffff40 inset}62.5%{transform:scale(1);box-shadow:0 0 #ffffff40 inset,0 0 0 21.667px #ffffff40 inset}81.25%{box-shadow:0 0 #ffffff40 inset,0 0 #ffffff40 inset}to{opacity:1;box-shadow:0 0 #ffffff40 inset,0 0 #ffffff40 inset}}@keyframes animateCheck{0%{stroke-dashoffset:80}to{stroke-dashoffset:0}}@keyframes animateShadow{0%{opacity:0;width:100%;height:15%}25%{opacity:.25}43.75%{width:40%;height:7%;opacity:.35}to{width:85%;height:15%;opacity:.25}}\n"] }]
588
+ }], ctorParameters: () => [{ type: i1$1.MessageService }, { type: i0.ChangeDetectorRef }, { type: i2.DynamicDialogRef }, { type: i2.DynamicDialogConfig }, { type: LocalizeTokenService }, { type: i1.HttpClient }] });
589
+
590
+ class LocalizeLogindlgService {
591
+ injector;
592
+ constructor(injector) {
593
+ this.injector = injector;
594
+ }
595
+ async openLoginDialog(config) {
596
+ config ??= {
597
+ header: 'Login',
598
+ height: '650px',
599
+ style: { 'max-width': '400px', width: '100%', 'height': '650px' },
600
+ };
601
+ const dialogService = this.injector.get(DialogService);
602
+ const dialog = dialogService.open(LocalizeLogindlgComponent, config);
603
+ await new Promise((resolve) => dialog.onClose.subscribe(res => {
604
+ if (res) {
605
+ resolve();
606
+ }
607
+ }));
608
+ }
609
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
610
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgService, providedIn: 'root' });
611
+ }
612
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgService, decorators: [{
613
+ type: Injectable,
614
+ args: [{
615
+ providedIn: 'root'
616
+ }]
617
+ }], ctorParameters: () => [{ type: i0.Injector }] });
618
+
619
+ class LocalizeLogindlgModule {
620
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
621
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgModule, declarations: [LocalizeLogindlgComponent], imports: [CommonModule,
622
+ ToastModule,
623
+ InputTextModule,
624
+ BrowserModule,
625
+ FormsModule], exports: [LocalizeLogindlgComponent] });
626
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgModule, providers: [LocalizeLogindlgService], imports: [CommonModule,
627
+ ToastModule,
628
+ InputTextModule,
629
+ BrowserModule,
630
+ FormsModule] });
631
+ }
632
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImport: i0, type: LocalizeLogindlgModule, decorators: [{
633
+ type: NgModule,
634
+ args: [{
635
+ declarations: [LocalizeLogindlgComponent],
636
+ exports: [LocalizeLogindlgComponent],
637
+ imports: [
638
+ CommonModule,
639
+ ToastModule,
640
+ InputTextModule,
641
+ BrowserModule,
642
+ FormsModule,
643
+ ],
644
+ providers: [LocalizeLogindlgService],
645
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
646
+ }]
647
+ }] });
648
+
350
649
  /**
351
650
  * Generated bundle index. Do not edit.
352
651
  */
353
652
 
354
- export { EMethod, ISameSiteType, LocalizeApiService, LocalizeToken, LocalizeTokenModule, LocalizeTokenService, LocalizeTokenStorageHelper, waitFor, waitUntil };
653
+ export { EMethod, ISameSiteType, LocalizeApiService, LocalizeLogindlgComponent, LocalizeLogindlgModule, LocalizeLogindlgService, LocalizeToken, LocalizeTokenModule, LocalizeTokenService, LocalizeTokenStorageHelper, waitFor, waitUntil };
355
654
  //# sourceMappingURL=sambath999-localize-token.mjs.map