@sambath999/localize-token 12.2.1 → 12.2.3

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 (57) hide show
  1. package/angular.json +119 -0
  2. package/ng-package.json +19 -0
  3. package/package.json +49 -38
  4. package/release.ps1 +30 -0
  5. package/release.sh +26 -0
  6. package/src/app/app.component.html +11 -0
  7. package/src/app/app.component.scss +0 -0
  8. package/src/app/app.component.ts +26 -0
  9. package/src/app/app.module.ts +32 -0
  10. package/src/assets/.gitkeep +0 -0
  11. package/src/assets/images/logo-300px.png +0 -0
  12. package/src/index.html +103 -0
  13. package/src/localize-logindlg/localize-logindlg.component.ts +400 -0
  14. package/src/localize-logindlg/localize-logindlg.module.ts +25 -0
  15. package/src/localize-logindlg/localize-logindlg.service.ts +38 -0
  16. package/src/localize-logindlg/public-api.ts +3 -0
  17. package/src/localize-token/localize.api.service.ts +177 -0
  18. package/src/localize-token/localize.token.module.ts +13 -0
  19. package/src/localize-token/localize.token.service.ts +84 -0
  20. package/src/localize-token/localize.token.storage.ts +132 -0
  21. package/src/localize-token/localize.token.ts +86 -0
  22. package/{localize-token/public-api.d.ts → src/localize-token/public-api.ts} +1 -1
  23. package/src/main.ts +7 -0
  24. package/src/polyfills.ts +53 -0
  25. package/src/styles.css +0 -0
  26. package/src/types/index.ts +0 -0
  27. package/tsconfig.app.json +14 -0
  28. package/tsconfig.json +38 -0
  29. package/bundles/sambath999-localize-token.umd.js +0 -1125
  30. package/bundles/sambath999-localize-token.umd.js.map +0 -1
  31. package/esm2015/localize-logindlg/localize-logindlg.component.js +0 -389
  32. package/esm2015/localize-logindlg/localize-logindlg.module.js +0 -28
  33. package/esm2015/localize-logindlg/localize-logindlg.service.js +0 -37
  34. package/esm2015/localize-logindlg/public-api.js +0 -4
  35. package/esm2015/localize-token/localize.api.service.js +0 -155
  36. package/esm2015/localize-token/localize.token.js +0 -60
  37. package/esm2015/localize-token/localize.token.module.js +0 -14
  38. package/esm2015/localize-token/localize.token.service.js +0 -66
  39. package/esm2015/localize-token/localize.token.storage.js +0 -107
  40. package/esm2015/localize-token/public-api.js +0 -6
  41. package/esm2015/public-api.js +0 -3
  42. package/esm2015/sambath999-localize-token.js +0 -5
  43. package/fesm2015/sambath999-localize-token.js +0 -837
  44. package/fesm2015/sambath999-localize-token.js.map +0 -1
  45. package/localize-logindlg/localize-logindlg.component.d.ts +0 -31
  46. package/localize-logindlg/localize-logindlg.module.d.ts +0 -2
  47. package/localize-logindlg/localize-logindlg.service.d.ts +0 -16
  48. package/localize-logindlg/public-api.d.ts +0 -3
  49. package/localize-token/localize.api.service.d.ts +0 -66
  50. package/localize-token/localize.token.d.ts +0 -43
  51. package/localize-token/localize.token.module.d.ts +0 -2
  52. package/localize-token/localize.token.service.d.ts +0 -27
  53. package/localize-token/localize.token.storage.d.ts +0 -61
  54. package/sambath999-localize-token.d.ts +0 -4
  55. package/sambath999-localize-token.metadata.json +0 -1
  56. /package/{README.md → README.MD} +0 -0
  57. /package/{public-api.d.ts → src/public-api.ts} +0 -0
@@ -1,837 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, NgModule, Component, ViewEncapsulation, ChangeDetectorRef, Injector, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3
- import { __awaiter } from 'tslib';
4
- import { BehaviorSubject } from 'rxjs';
5
- import * as jwt_decode from 'jwt-decode';
6
- import * as i1 from '@angular/common/http';
7
- import { HttpHeaders, HttpClient } from '@angular/common/http';
8
- import { MessageService } from 'primeng/api';
9
- import { DynamicDialogRef, DynamicDialogConfig, DialogService } from 'primeng/dynamicdialog';
10
- import { CommonModule } from '@angular/common';
11
- import { ToastModule } from 'primeng/toast';
12
- import { InputTextModule } from 'primeng/inputtext';
13
- import { ButtonModule } from 'primeng/button';
14
- import { BrowserModule } from '@angular/platform-browser';
15
- import { FormsModule } from '@angular/forms';
16
-
17
- /**
18
- * Assembly of @package ng2-cookies @see https://www.npmjs.com/package/ng2-cookies
19
- *
20
- * Reassembled by
21
- * @author sambath999
22
- * @date_29_09_2021
23
- * Updated from raw parameters to
24
- * @param {ICookieOptions} options and added another newer cookie flag
25
- * @param {string} samesite
26
- * @param {constant} SameSiteTypes, @param {string} strict "strict", @param {string} lax "lax", @param {string} none "none"
27
- *
28
- * @enum
29
- */
30
- class LocalizeTokenStorage {
31
- constructor(_defaultOptions) {
32
- this.defaultOptions = _defaultOptions !== null && _defaultOptions !== void 0 ? _defaultOptions : this.getDefaultOptions;
33
- }
34
- get getDefaultOptions() {
35
- const mainDomain = extractMainDomain(window.location.hostname);
36
- return {
37
- path: '/',
38
- domain: mainDomain,
39
- secure: true,
40
- // samesite: SameSiteType.strict,
41
- expires: 1
42
- };
43
- }
44
- /**
45
- * Checks the existence of a single cookie by it's name
46
- *
47
- * @param {string} name Identification of the cookie
48
- * @returns existence of the cookie
49
- */
50
- check(name) {
51
- if (typeof document === "undefined")
52
- return false;
53
- name = encodeURIComponent(name);
54
- const regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
55
- return regexp.test(document.cookie);
56
- }
57
- /**
58
- * Retrieves a single cookie by it's name
59
- *
60
- * @param {string} name Identification of the Cookie
61
- * @returns The Cookie's value
62
- */
63
- get(name) {
64
- if (!this.check(name))
65
- return undefined;
66
- name = encodeURIComponent(name);
67
- const regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
68
- const result = regexp.exec(document.cookie);
69
- return result ? decodeURIComponent(result[1]) : undefined;
70
- }
71
- /**
72
- * Retrieves a a list of all cookie avaiable
73
- *
74
- * @returns Object with all Cookies
75
- */
76
- getAll() {
77
- const cookies = {};
78
- if (document.cookie) {
79
- const split = document.cookie.split(';');
80
- for (const s of split) {
81
- const currCookie = s.split('=');
82
- currCookie[0] = currCookie[0].trim();
83
- cookies[decodeURIComponent(currCookie[0])] = decodeURIComponent(currCookie[1]);
84
- }
85
- }
86
- return cookies;
87
- }
88
- set(name, value, options) {
89
- options !== null && options !== void 0 ? options : (options = this.defaultOptions);
90
- const { expires, path, domain, secure, samesite } = Object.assign(Object.assign({}, this.defaultOptions), options);
91
- let cookieStr = `${encodeURIComponent(name)}=${encodeURIComponent(value)};`;
92
- if (expires) {
93
- const dtExpires = typeof expires === 'number' ? new Date(Date.now() + expires * 864e5) : expires;
94
- cookieStr += `expires=${dtExpires.toUTCString()};`;
95
- }
96
- cookieStr += path ? `path=${path};` : '';
97
- cookieStr += domain ? `domain=${domain};` : '';
98
- cookieStr += secure ? 'secure;' : '';
99
- cookieStr += samesite ? `samesite=${samesite};` : '';
100
- document.cookie = cookieStr;
101
- }
102
- /**
103
- * Removes specified Cookie
104
- *
105
- * @param {string} name Cookie's identification
106
- * @param {string} path Path relative to the domain where the cookie should be avaiable. Default /
107
- * @param {string} domain Domain where the cookie should be avaiable. Default current domain
108
- */
109
- delete(name, path = '/', domain = window.location.hostname) {
110
- this.set(name, '', { path, domain, expires: -1 });
111
- }
112
- /**
113
- * Delete all cookie avaiable
114
- */
115
- deleteAll(path, domain) {
116
- const cookies = this.getAll();
117
- for (const cookieName of Object.keys(cookies)) {
118
- this.delete(cookieName, path, domain);
119
- }
120
- }
121
- }
122
-
123
- class LocalizeToken {
124
- static init(config) {
125
- LocalizeToken.config = Object.assign(Object.assign({}, LocalizeToken.config), config);
126
- }
127
- }
128
- LocalizeToken.config = {
129
- mainDomain: extractMainDomain(),
130
- authTokenName: 'auth-token',
131
- refreshTokenName: '_lze_rftkp_',
132
- needTenant: false,
133
- isProduction: false,
134
- revokeTokenUrl: ''
135
- };
136
- LocalizeToken.storage = new LocalizeTokenStorage();
137
- LocalizeToken.httpHeaders = {
138
- AUTHORIZATION: 'Authorization',
139
- X_TENANT: 'X-Tenant',
140
- X_REFRESH_TOKEN: 'X-RefreshToken',
141
- CONTENT_TYPE: 'Content-Type',
142
- };
143
- /**
144
- * Waits for a specified amount of time.
145
- * @param milliseconds - The milliseconds to wait.
146
- * @param when - The condition to wait for. Default is true.
147
- * @returns - Promise<void>
148
- */
149
- function waitFor(milliseconds, when = true) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (!when)
152
- return;
153
- yield new Promise(resolve => setTimeout(resolve, milliseconds));
154
- });
155
- }
156
- /**
157
- * Waits until the condition is met.
158
- * @param when - The condition to wait for.
159
- * @param intervalNumber - The interval number in milliseconds to check the condition. Default is 50.
160
- */
161
- function waitUntil(when, intervalNumber = 50) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- yield new Promise(resolve => {
164
- const interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
165
- const cond = when();
166
- const result = cond instanceof Promise ? yield cond : cond;
167
- if (result) {
168
- clearInterval(interval);
169
- resolve(true);
170
- }
171
- }), intervalNumber);
172
- });
173
- });
174
- }
175
- function extractMainDomain(subdomain) {
176
- subdomain !== null && subdomain !== void 0 ? subdomain : (subdomain = window.location.hostname);
177
- const parts = subdomain.split('.');
178
- return parts.length > 2 ? parts.slice(-2).join('.') : subdomain;
179
- }
180
-
181
- class LocalizeTokenService {
182
- constructor() {
183
- this.isRevokingTokenSubject = new BehaviorSubject(false);
184
- this.decodeToken = (token) => jwt_decode.jwtDecode(token);
185
- if (!LocalizeToken.config.authTokenName || !LocalizeToken.config.refreshTokenName || !LocalizeToken.config.tenantTokenName) {
186
- throw new Error('authTokenName, refreshTokenName, and tenantTokenName must be defined in LocalizeToken.config');
187
- }
188
- this.config = LocalizeToken.config;
189
- }
190
- get authToken() { return this.storageGet(); }
191
- set authToken(value) {
192
- value
193
- ? this.storageSet(value)
194
- : LocalizeToken.storage.delete(this.config.authTokenName);
195
- }
196
- get refreshToken() { return LocalizeToken.storage.get(this.config.refreshTokenName); }
197
- get accessToken() { var _a; return (_a = this.authToken) === null || _a === void 0 ? void 0 : _a.token; }
198
- set accessToken(value) {
199
- if (value) {
200
- this.authToken = { token: value, revoke: false };
201
- }
202
- }
203
- get isRevokingToken() { return this.isRevokingTokenSubject.value; /* this.authToken?.revoke ?? false */ }
204
- set isRevokingToken(value) {
205
- this.isRevokingTokenSubject.next(value);
206
- if (this.authToken) {
207
- this.authToken = Object.assign(Object.assign({}, this.authToken), { revoke: value });
208
- }
209
- }
210
- tenantToken() { return LocalizeToken.storage.get(this.config.tenantTokenName); }
211
- storageGet() {
212
- try {
213
- const encoded = LocalizeToken.storage.get(this.config.authTokenName);
214
- const decoded = atob(encoded || '');
215
- return JSON.parse(decoded);
216
- }
217
- catch (_a) {
218
- return undefined;
219
- }
220
- }
221
- storageSet(value) {
222
- const base64 = btoa(JSON.stringify(value));
223
- LocalizeToken.storage.set(this.config.authTokenName, base64);
224
- }
225
- tokensValid() {
226
- var _a, _b;
227
- return ((_a = this.refreshToken) === null || _a === void 0 ? void 0 : _a.length) && (!this.config.needTenant || ((_b = this.tenantToken()) === null || _b === void 0 ? void 0 : _b.length));
228
- }
229
- get decodeRefreshToken() {
230
- const token = LocalizeToken.storage.get(this.config.refreshTokenName);
231
- if (!token)
232
- return null;
233
- return this.decodeToken(token);
234
- }
235
- }
236
- LocalizeTokenService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LocalizeTokenService_Factory() { return new LocalizeTokenService(); }, token: LocalizeTokenService, providedIn: "root" });
237
- LocalizeTokenService.decorators = [
238
- { type: Injectable, args: [{ providedIn: 'root' },] }
239
- ];
240
- LocalizeTokenService.ctorParameters = () => [];
241
-
242
- /**
243
- * Http method options
244
- */
245
- var EMethod;
246
- (function (EMethod) {
247
- EMethod[EMethod["POST"] = 1] = "POST";
248
- EMethod[EMethod["GET"] = 2] = "GET";
249
- EMethod[EMethod["PUT"] = 3] = "PUT";
250
- EMethod[EMethod["DELETE"] = 4] = "DELETE";
251
- EMethod[EMethod["PATCH"] = 5] = "PATCH";
252
- })(EMethod || (EMethod = {}));
253
- class LocalizeApiService {
254
- constructor(httpClient, localizeTokenService) {
255
- this.httpClient = httpClient;
256
- this.localizeTokenService = localizeTokenService;
257
- this.isRequestingSubject = new BehaviorSubject(false);
258
- this.isResolvedStartupSubject = new BehaviorSubject(false);
259
- this.apiConfigs = {};
260
- /**
261
- * A higher-order function that returns a curried function for making API requests.
262
- *
263
- * @param baseUrl - The base URL of the API.
264
- * @returns A curried function that can be used to make API requests.
265
- */
266
- this.func = (baseUrl) => (path, method = EMethod.GET, value = null, isFormData = false, headers) => this.base(baseUrl, path, method, value, isFormData, headers);
267
- }
268
- get isRequesting() { return this.isRequestingSubject.value; }
269
- get isResolvedStartup() { return this.isResolvedStartupSubject.value; }
270
- /**
271
- * Initialize the API service.
272
- * @param apiConfigs - The API configurations.
273
- */
274
- init(apiConfigs) {
275
- this.apiConfigs = apiConfigs;
276
- }
277
- base(baseUrl, path, method = EMethod.GET, value = null, isFormData = false, headers) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- yield this.ifPromise(this.apiConfigs.onPrepareRequest);
280
- const url = `${baseUrl.trim().replace(/\/?$/, '/')}${path.trim().replace(/^\//, '')}`;
281
- const httpMethod = EMethod[method].toLowerCase();
282
- const request = () => { return { body: value, headers: this.options(isFormData, headers) }; };
283
- // Wait for previous request to complete
284
- yield this.toWaitForPreviousRequest();
285
- // Process request
286
- try {
287
- return yield this.processRequest(httpMethod, url, request());
288
- }
289
- // Handle unauthorized error if any
290
- catch (error) {
291
- if (error.status !== 401) {
292
- throw error;
293
- }
294
- return yield this.onUnauthorizedError(httpMethod, url, request);
295
- }
296
- });
297
- }
298
- onUnauthorizedError(httpMethod, url, request) {
299
- return __awaiter(this, void 0, void 0, function* () {
300
- yield this.revokeToken();
301
- if (!this.isResolvedStartup) {
302
- return yield this.processRequest(httpMethod, url, request());
303
- }
304
- });
305
- }
306
- toWaitForPreviousRequest() {
307
- var _a;
308
- return __awaiter(this, void 0, void 0, function* () {
309
- if (this.localizeTokenService.isRevokingToken) {
310
- yield waitUntil(() => !this.localizeTokenService.isRevokingToken);
311
- }
312
- // to wait for each request in 50ms, even if the request is not completed
313
- if ((_a = this.apiConfigs.waitEachRequest) === null || _a === void 0 ? void 0 : _a.milliseconds) {
314
- yield waitFor(this.apiConfigs.waitEachRequest.milliseconds, this.isRequesting);
315
- }
316
- });
317
- }
318
- processRequest(method, url, options) {
319
- return __awaiter(this, void 0, void 0, function* () {
320
- this.isRequestingSubject.next(true);
321
- const result = yield new Promise((resolve, reject) => this.httpClient.request(method, url, options).subscribe({ next: resolve, error: reject }));
322
- this.isRequestingSubject.next(false);
323
- return result;
324
- });
325
- }
326
- revokeToken(force = false) {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- if (this.localizeTokenService.isRevokingToken && !force) {
329
- yield waitUntil(() => !this.localizeTokenService.isRevokingToken);
330
- return;
331
- }
332
- try {
333
- this.localizeTokenService.isRevokingToken = true;
334
- const reqUrl = LocalizeToken.config.revokeTokenUrl;
335
- const reqHeaders = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, `${this.localizeTokenService.refreshToken}`);
336
- const revokeToken = yield new Promise((resolve, reject) => this.httpClient.get(reqUrl, { headers: reqHeaders }).subscribe({ next: resolve, error: reject }));
337
- if (revokeToken === null || revokeToken === void 0 ? void 0 : revokeToken.status) {
338
- this.localizeTokenService.accessToken = revokeToken.message;
339
- }
340
- else if (!this.localizeTokenService.refreshToken) {
341
- yield this.ifPromise(this.apiConfigs.onAutoLogout);
342
- }
343
- else {
344
- if (this.apiConfigs.onRevokeUnauthorized) {
345
- yield this.ifPromise(this.apiConfigs.onRevokeUnauthorized);
346
- yield this.revokeToken(true);
347
- }
348
- }
349
- }
350
- finally {
351
- this.localizeTokenService.isRevokingToken = false;
352
- }
353
- });
354
- }
355
- /** default http request options */
356
- options(isFormData = false, headers = {}) {
357
- const defaultHeaders = { [LocalizeToken.httpHeaders.AUTHORIZATION]: `Bearer ${this.localizeTokenService.accessToken}`, };
358
- if (LocalizeToken.config.needTenant) {
359
- defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = `${this.localizeTokenService.tenantToken()}`;
360
- }
361
- if (!isFormData) {
362
- defaultHeaders[LocalizeToken.httpHeaders.CONTENT_TYPE] = 'application/json';
363
- }
364
- const filteredHeaders = Object.keys(defaultHeaders).filter(key => !Object.keys(headers).includes(key))
365
- .reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: defaultHeaders[key] })), {});
366
- const mergedHeaders = Object.assign(Object.assign({}, filteredHeaders), headers);
367
- return new HttpHeaders(mergedHeaders);
368
- }
369
- ifPromise(fn) {
370
- return __awaiter(this, void 0, void 0, function* () {
371
- if (!fn)
372
- return;
373
- return fn instanceof Promise ? yield fn() : fn();
374
- });
375
- }
376
- } //class
377
- LocalizeApiService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LocalizeApiService_Factory() { return new LocalizeApiService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(LocalizeTokenService)); }, token: LocalizeApiService, providedIn: "root" });
378
- LocalizeApiService.decorators = [
379
- { type: Injectable, args: [{
380
- providedIn: 'root'
381
- },] }
382
- ];
383
- LocalizeApiService.ctorParameters = () => [
384
- { type: HttpClient },
385
- { type: LocalizeTokenService }
386
- ];
387
-
388
- class LocalizeTokenModule {
389
- }
390
- LocalizeTokenModule.decorators = [
391
- { type: NgModule, args: [{
392
- providers: [
393
- LocalizeTokenService,
394
- LocalizeApiService
395
- ],
396
- },] }
397
- ];
398
-
399
- class LocalizeLogindlgComponent {
400
- constructor(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient) {
401
- this.messageService = messageService;
402
- this.cdt = cdt;
403
- this.dlgRef = dlgRef;
404
- this.dlgConfig = dlgConfig;
405
- this.tokenService = tokenService;
406
- this.httpClient = httpClient;
407
- this.messageKey = "$login-dlg";
408
- this.loading = false;
409
- this.success = false;
410
- this.config = LocalizeToken.config;
411
- this.clickLogout = () => { var _a; return (_a = this.logout) === null || _a === void 0 ? void 0 : _a.call(this); };
412
- this.decodeToken = this.tokenService.decodeRefreshToken;
413
- this.loginConfig = this.dlgConfig.data.loginConfig;
414
- }
415
- ngOnInit() {
416
- this.dlgConfig.closable = false;
417
- this.logout = this.loginConfig.logoutFunc;
418
- this.loginUrl = this.loginConfig.loginUrl;
419
- if (!this.decodeToken) {
420
- this.showMessage("error", "Token is invalid");
421
- setTimeout(() => { var _a; return (_a = this.logout) === null || _a === void 0 ? void 0 : _a.call(this); }, 2000);
422
- }
423
- }
424
- ngAfterViewInit() {
425
- this.cdt.detectChanges();
426
- }
427
- clickLogin() {
428
- var _a, _b;
429
- return __awaiter(this, void 0, void 0, function* () {
430
- if (!this.isValidPassword) {
431
- this.showMessage("error", "Password is required and must be at least 6 characters");
432
- return;
433
- }
434
- this.loading = true;
435
- const loginRes = yield this.login();
436
- if (!(loginRes === null || loginRes === void 0 ? void 0 : loginRes.status)) {
437
- this.showMessage("error", (_a = loginRes.message) !== null && _a !== void 0 ? _a : "An error occurred");
438
- return;
439
- }
440
- this.tokenService.accessToken = loginRes.tokens.accessToken;
441
- const cookieOptions = { expires: (_b = this.loginConfig.expire) !== null && _b !== void 0 ? _b : 5 };
442
- LocalizeToken.storage.set(this.config.refreshTokenName, loginRes.tokens.refreshToken, cookieOptions);
443
- this.success = true;
444
- setTimeout(() => this.dlgRef.close(true), 2000);
445
- });
446
- }
447
- login() {
448
- return __awaiter(this, void 0, void 0, function* () {
449
- if (!this.loginUrl || !this.loginUrl.trim().length) {
450
- this.showMessage("error", "Login url is required");
451
- throw new Error("Login url is required");
452
- }
453
- try {
454
- return yield new Promise((resolve, reject) => this.httpClient.post(this.loginUrl, { password: this.password.trim() }, { headers: this.getHeaders() })
455
- .subscribe({ next: resolve, error: reject }));
456
- }
457
- catch (e) {
458
- this.showMessage("error", e.message);
459
- return null;
460
- }
461
- });
462
- }
463
- getHeaders() {
464
- var _a, _b;
465
- return {
466
- [LocalizeToken.httpHeaders.X_REFRESH_TOKEN]: (_a = LocalizeToken.storage.get(this.config.refreshTokenName)) !== null && _a !== void 0 ? _a : "",
467
- [LocalizeToken.httpHeaders.X_TENANT]: (_b = LocalizeToken.storage.get(this.config.tenantTokenName)) !== null && _b !== void 0 ? _b : "",
468
- };
469
- }
470
- get isValidPassword() {
471
- this.loading = false;
472
- return this.password && this.password.trim().length >= 6 && this.password.trim().length <= 16;
473
- }
474
- showMessage(severity, summary) {
475
- this.messageService.add({ key: this.messageKey, severity, summary });
476
- this.loading = false;
477
- }
478
- }
479
- LocalizeLogindlgComponent.decorators = [
480
- { type: Component, args: [{
481
- template: `<p-toast key="$login-dlg" position="top-center"></p-toast>
482
- <div id="login-dlg-wrap">
483
- <div id="login-dlg-header">
484
- <div id="login-logo" class="p-mb-2"></div>
485
- <h3 *ngIf="!success">Your session is expired! <br> Please login again to continue.</h3>
486
- <h3 *ngIf="success" style="color:green !important;">You haved successfully logged in.</h3>
487
- </div>
488
- <div id="login-dlg-content">
489
- <ng-container *ngIf="!success">
490
- <div *ngIf="loading" class="loader-wrap">
491
- <div class="login-dlg-loader"></div>
492
- </div>
493
- <div class="login-dlg-elm">
494
- <div class="p-inputgroup">
495
- <span class="p-inputgroup-addon">
496
- <i class="material-icons-round">person</i>
497
- </span>
498
- <input disabled pInputText type="text" placeholder="Username" [value]="decodeToken?.email" />
499
- </div>
500
- </div>
501
-
502
- <div class="login-dlg-elm">
503
- <div class="p-inputgroup">
504
- <span class="p-inputgroup-addon">
505
- <i class="material-icons-round">lock</i>
506
- </span>
507
- <input [disabled]="loading" (keydown.enter)="clickLogin()" pInputText type="password" placeholder="Password" [(ngModel)]="password"
508
- autofocus />
509
- </div>
510
- </div>
511
- <div class="login-dlg-elm">
512
- <button style="width: 100%;" pButton type="button" label="Login" (click)="clickLogin()"
513
- [disabled]="!password || loading"></button>
514
- </div>
515
-
516
- <div class="login-dlg-elm" style="display:flex;align-items: center;user-select: none;">
517
- <span>No, I want to login with another user.</span>
518
- <button class="p-button-text" pButton type="button" label="Logout" (click)="clickLogout()"></button>
519
- </div>
520
- </ng-container>
521
-
522
- <ng-container *ngIf="success">
523
- <div style="margin-top:35px;"></div>
524
- <div class="check-animation-wrap">
525
- <div class="check-main-container">
526
- <div class="check-container">
527
- <div class="check-background">
528
- <svg viewBox="0 0 65 51" fill="none" xmlns="http://www.w3.org/2000/svg">
529
- <path d="M7 25L27.3077 44L58.5 7" stroke="white" stroke-width="13" stroke-linecap="round"
530
- stroke-linejoin="round"></path>
531
- </svg>
532
- </div>
533
- </div>
534
- </div>
535
- </div>
536
- </ng-container>
537
- </div>
538
- </div>`,
539
- selector: "app-localize-logindlg",
540
- providers: [MessageService],
541
- encapsulation: ViewEncapsulation.None,
542
- styles: [`
543
- #login-dlg-wrap {
544
- width: 100%;
545
- max-width: 400px;
546
- margin: 0 auto;
547
- padding: 30px;
548
- }
549
-
550
- .login-dlg-elm {
551
- margin-top: 1rem;
552
- }
553
-
554
- #login-dlg-header {
555
- display: flex;
556
- flex-direction: column;
557
- align-items: center;
558
- justify-content: center;
559
- }
560
-
561
- #login-dlg-header h3 {
562
- font-weight: bold;
563
- font-size: 0.9rem;
564
- color: orange;
565
- text-align: center;
566
- }
567
-
568
- #login-logo {
569
- height: 40px;
570
- width: 40px;
571
- background: url("/assets/images/logo-300px.png") no-repeat;
572
- background-size: contain;
573
- }
574
-
575
- #login-dlg-content .p-inputgroup {
576
- height: 45px;
577
- }
578
-
579
- #login-dlg-content .p-inputgroup .p-inputgroup-addon {
580
- height: 45px;
581
- border-radius: 15px 0 0 15px;
582
- width: 50px;
583
- }
584
-
585
- #login-dlg-content .p-inputgroup .p-inputgroup-addon * {
586
- font-size: 1rem;
587
- }
588
-
589
- #login-dlg-content .p-inputgroup input {
590
- height: 45px;
591
- border-radius: 0 15px 15px 0;
592
- }
593
-
594
- #login-dlg-content button {
595
- height: 45px;
596
- border-radius: 15px;
597
- }
598
-
599
- /*check animation block*/
600
-
601
- .check-animation-wrap {
602
- top: 0;
603
- left: 0;
604
- position: absolute;
605
- display: flex;
606
- flex-direction: column;
607
- align-items: center;
608
- justify-content: center;
609
- width: 100%;
610
- height: calc(100% - 200px);
611
- min-height: 400px;
612
- }
613
-
614
- .check-main-container {
615
- width: 100%;
616
- height: 100vh;
617
- display: flex;
618
- flex-flow: column;
619
- justify-content: center;
620
- align-items: center;
621
- }
622
-
623
- .check-container {
624
- width: 6.25rem;
625
- height: 7.5rem;
626
- display: flex;
627
- flex-flow: column;
628
- align-items: center;
629
- justify-content: space-between;
630
- }
631
-
632
- .check-container .check-background {
633
- width: 100%;
634
- height: calc(100% - 1.25rem);
635
- background: linear-gradient(to bottom right, #5de593, #41d67c);
636
- box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;
637
- transform: scale(0.84);
638
- border-radius: 50%;
639
- animation: animateContainer 0.75s ease-out forwards 0.75s;
640
- display: flex;
641
- align-items: center;
642
- justify-content: center;
643
- opacity: 0;
644
- }
645
-
646
- .check-container .check-background svg {
647
- width: 65%;
648
- transform: translateY(0.25rem);
649
- stroke-dasharray: 80;
650
- stroke-dashoffset: 80;
651
- animation: animateCheck 0.35s forwards 1.25s ease-out;
652
- min-width: auto !important;
653
- }
654
-
655
- .check-container .check-shadow {
656
- bottom: calc(-15% - 5px);
657
- left: 0;
658
- border-radius: 50%;
659
- background: radial-gradient(closest-side, rgba(73, 218, 131, 1), transparent);
660
- animation: animateShadow 0.75s ease-out forwards 0.75s;
661
- }
662
-
663
- @keyframes animateContainer {
664
- 0% {
665
- opacity: 0;
666
- transform: scale(0);
667
- box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;
668
- }
669
-
670
- 25% {
671
- opacity: 1;
672
- transform: scale(0.9);
673
- box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;
674
- }
675
-
676
- 43.75% {
677
- transform: scale(1.15);
678
- box-shadow: 0px 0px 0px 43.334px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;
679
- }
680
-
681
- 62.5% {
682
- transform: scale(1);
683
- box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 21.667px rgba(255, 255, 255, 0.25) inset;
684
- }
685
-
686
- 81.25% {
687
- box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;
688
- }
689
-
690
- 100% {
691
- opacity: 1;
692
- box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;
693
- }
694
- }
695
-
696
- @keyframes animateCheck {
697
- from {
698
- stroke-dashoffset: 80;
699
- }
700
-
701
- to {
702
- stroke-dashoffset: 0;
703
- }
704
- }
705
-
706
- @keyframes animateShadow {
707
- 0% {
708
- opacity: 0;
709
- width: 100%;
710
- height: 15%;
711
- }
712
-
713
- 25% {
714
- opacity: 0.25;
715
- }
716
-
717
- 43.75% {
718
- width: 40%;
719
- height: 7%;
720
- opacity: 0.35;
721
- }
722
-
723
- 100% {
724
- width: 85%;
725
- height: 15%;
726
- opacity: 0.25;
727
- }
728
- }
729
- #login-dlg-wrap .loader-wrap {
730
- display: flex;
731
- justify-content: center;
732
- align-items: center;
733
- height:100%;
734
- width:100%;
735
- position: absolute;
736
- top: 0;
737
- left: 0;
738
- z-index: 100;
739
- background: #ffffff42;
740
- backdrop-filter: blur(1px);
741
- }
742
-
743
- #login-dlg-wrap .login-dlg-loader {
744
- border: 15px solid #e7e7e7;
745
- border-top: 15px solid #52dba1;
746
- border-radius: 50%;
747
- width: 100px;
748
- height: 100px;
749
- animation: spinloader 2s linear infinite;
750
- }
751
-
752
- #login-dlg-wrap .loader-wrap::before {
753
- content: "";
754
- position: absolute;
755
- width: 70px;
756
- height: 70px;
757
- transform: translate(-50%, -50%);
758
- z-index: 1;
759
- border: 15px solid #e7e7e700;
760
- border-top: 15px solid #52dba1c9;
761
- border-radius: 50%;
762
- animation: spinloader .75s linear infinite;
763
- }
764
-
765
- @keyframes spinloader {
766
- 0% { transform: rotate(0deg); }
767
- 100% { transform: rotate(360deg); }
768
- }
769
- `]
770
- },] }
771
- ];
772
- LocalizeLogindlgComponent.ctorParameters = () => [
773
- { type: MessageService },
774
- { type: ChangeDetectorRef },
775
- { type: DynamicDialogRef },
776
- { type: DynamicDialogConfig },
777
- { type: LocalizeTokenService },
778
- { type: HttpClient }
779
- ];
780
-
781
- class LocalizeLogindlgService {
782
- constructor(injector) {
783
- this.injector = injector;
784
- }
785
- openLoginDialog(loginConfig, config) {
786
- return __awaiter(this, void 0, void 0, function* () {
787
- config !== null && config !== void 0 ? config : (config = {
788
- header: 'Login',
789
- height: '650px',
790
- style: { 'max-width': '400px', width: '100%', 'height': '650px' },
791
- });
792
- config.data = Object.assign(Object.assign({}, config.data || {}), { loginConfig });
793
- const dialogService = this.injector.get(DialogService);
794
- const dialog = dialogService.open(LocalizeLogindlgComponent, config);
795
- yield new Promise((resolve) => dialog.onClose.subscribe(res => {
796
- if (res) {
797
- resolve();
798
- }
799
- }));
800
- });
801
- }
802
- }
803
- LocalizeLogindlgService.ɵprov = i0.ɵɵdefineInjectable({ factory: function LocalizeLogindlgService_Factory() { return new LocalizeLogindlgService(i0.ɵɵinject(i0.INJECTOR)); }, token: LocalizeLogindlgService, providedIn: "root" });
804
- LocalizeLogindlgService.decorators = [
805
- { type: Injectable, args: [{
806
- providedIn: 'root'
807
- },] }
808
- ];
809
- LocalizeLogindlgService.ctorParameters = () => [
810
- { type: Injector }
811
- ];
812
-
813
- class LocalizeLogindlgModule {
814
- }
815
- LocalizeLogindlgModule.decorators = [
816
- { type: NgModule, args: [{
817
- declarations: [LocalizeLogindlgComponent],
818
- exports: [LocalizeLogindlgComponent],
819
- imports: [
820
- CommonModule,
821
- ToastModule,
822
- InputTextModule,
823
- BrowserModule,
824
- FormsModule,
825
- ButtonModule,
826
- ],
827
- providers: [LocalizeLogindlgService],
828
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
829
- },] }
830
- ];
831
-
832
- /**
833
- * Generated bundle index. Do not edit.
834
- */
835
-
836
- export { EMethod, LocalizeApiService, LocalizeLogindlgComponent, LocalizeLogindlgModule, LocalizeLogindlgService, LocalizeToken, LocalizeTokenModule, LocalizeTokenService, LocalizeTokenStorage, extractMainDomain, waitFor, waitUntil };
837
- //# sourceMappingURL=sambath999-localize-token.js.map