@sambath999/localize-token 12.2.3 → 12.2.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 (57) hide show
  1. package/bundles/sambath999-localize-token.umd.js +1156 -0
  2. package/bundles/sambath999-localize-token.umd.js.map +1 -0
  3. package/esm2015/localize-logindlg/localize-logindlg.component.js +391 -0
  4. package/esm2015/localize-logindlg/localize-logindlg.module.js +28 -0
  5. package/esm2015/localize-logindlg/localize-logindlg.service.js +37 -0
  6. package/esm2015/localize-logindlg/public-api.js +4 -0
  7. package/esm2015/localize-token/localize.api.service.js +159 -0
  8. package/esm2015/localize-token/localize.token.js +67 -0
  9. package/esm2015/localize-token/localize.token.module.js +16 -0
  10. package/esm2015/localize-token/localize.token.service.js +72 -0
  11. package/esm2015/localize-token/localize.token.storage.js +107 -0
  12. package/esm2015/localize-token/public-api.js +6 -0
  13. package/esm2015/public-api.js +3 -0
  14. package/esm2015/sambath999-localize-token.js +5 -0
  15. package/fesm2015/sambath999-localize-token.js +854 -0
  16. package/fesm2015/sambath999-localize-token.js.map +1 -0
  17. package/localize-logindlg/localize-logindlg.component.d.ts +33 -0
  18. package/localize-logindlg/localize-logindlg.module.d.ts +2 -0
  19. package/localize-logindlg/localize-logindlg.service.d.ts +16 -0
  20. package/localize-logindlg/public-api.d.ts +3 -0
  21. package/localize-token/localize.api.service.d.ts +69 -0
  22. package/localize-token/localize.token.d.ts +46 -0
  23. package/localize-token/localize.token.module.d.ts +2 -0
  24. package/localize-token/localize.token.service.d.ts +29 -0
  25. package/localize-token/localize.token.storage.d.ts +61 -0
  26. package/{src/localize-token/public-api.ts → localize-token/public-api.d.ts} +1 -1
  27. package/package.json +38 -49
  28. package/sambath999-localize-token.d.ts +4 -0
  29. package/sambath999-localize-token.metadata.json +1 -0
  30. package/angular.json +0 -119
  31. package/ng-package.json +0 -19
  32. package/release.ps1 +0 -30
  33. package/release.sh +0 -26
  34. package/src/app/app.component.html +0 -11
  35. package/src/app/app.component.scss +0 -0
  36. package/src/app/app.component.ts +0 -26
  37. package/src/app/app.module.ts +0 -32
  38. package/src/assets/.gitkeep +0 -0
  39. package/src/assets/images/logo-300px.png +0 -0
  40. package/src/index.html +0 -103
  41. package/src/localize-logindlg/localize-logindlg.component.ts +0 -400
  42. package/src/localize-logindlg/localize-logindlg.module.ts +0 -25
  43. package/src/localize-logindlg/localize-logindlg.service.ts +0 -38
  44. package/src/localize-logindlg/public-api.ts +0 -3
  45. package/src/localize-token/localize.api.service.ts +0 -177
  46. package/src/localize-token/localize.token.module.ts +0 -13
  47. package/src/localize-token/localize.token.service.ts +0 -84
  48. package/src/localize-token/localize.token.storage.ts +0 -132
  49. package/src/localize-token/localize.token.ts +0 -86
  50. package/src/main.ts +0 -7
  51. package/src/polyfills.ts +0 -53
  52. package/src/styles.css +0 -0
  53. package/src/types/index.ts +0 -0
  54. package/tsconfig.app.json +0 -14
  55. package/tsconfig.json +0 -38
  56. /package/{README.MD → README.md} +0 -0
  57. /package/{src/public-api.ts → public-api.d.ts} +0 -0
@@ -0,0 +1,1156 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('jwt-decode'), require('@angular/common/http'), require('primeng/api'), require('primeng/dynamicdialog'), require('@angular/common'), require('primeng/toast'), require('primeng/inputtext'), require('primeng/button'), require('@angular/platform-browser'), require('@angular/forms')) :
3
+ typeof define === 'function' && define.amd ? define('@sambath999/localize-token', ['exports', '@angular/core', 'rxjs', 'jwt-decode', '@angular/common/http', 'primeng/api', 'primeng/dynamicdialog', '@angular/common', 'primeng/toast', 'primeng/inputtext', 'primeng/button', '@angular/platform-browser', '@angular/forms'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.sambath999 = global.sambath999 || {}, global.sambath999["localize-token"] = {}), global.ng.core, global.rxjs, global.jwt_decode, global.ng.common.http, global.api, global.dynamicdialog, global.ng.common, global.toast, global.inputtext, global.button, global.ng.platformBrowser, global.ng.forms));
5
+ })(this, (function (exports, i0, rxjs, jwt_decode, i1, api, dynamicdialog, common, toast, inputtext, button, platformBrowser, forms) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
+ var jwt_decode__namespace = /*#__PURE__*/_interopNamespace(jwt_decode);
27
+ var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
+
29
+ /*! *****************************************************************************
30
+ Copyright (c) Microsoft Corporation.
31
+
32
+ Permission to use, copy, modify, and/or distribute this software for any
33
+ purpose with or without fee is hereby granted.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
+ PERFORMANCE OF THIS SOFTWARE.
42
+ ***************************************************************************** */
43
+ /* global Reflect, Promise */
44
+ var extendStatics = function (d, b) {
45
+ extendStatics = Object.setPrototypeOf ||
46
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
+ function (d, b) { for (var p in b)
48
+ if (Object.prototype.hasOwnProperty.call(b, p))
49
+ d[p] = b[p]; };
50
+ return extendStatics(d, b);
51
+ };
52
+ function __extends(d, b) {
53
+ if (typeof b !== "function" && b !== null)
54
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
+ extendStatics(d, b);
56
+ function __() { this.constructor = d; }
57
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
+ }
59
+ var __assign = function () {
60
+ __assign = Object.assign || function __assign(t) {
61
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
62
+ s = arguments[i];
63
+ for (var p in s)
64
+ if (Object.prototype.hasOwnProperty.call(s, p))
65
+ t[p] = s[p];
66
+ }
67
+ return t;
68
+ };
69
+ return __assign.apply(this, arguments);
70
+ };
71
+ function __rest(s, e) {
72
+ var t = {};
73
+ for (var p in s)
74
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
+ t[p] = s[p];
76
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
+ t[p[i]] = s[p[i]];
80
+ }
81
+ return t;
82
+ }
83
+ function __decorate(decorators, target, key, desc) {
84
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
+ r = Reflect.decorate(decorators, target, key, desc);
87
+ else
88
+ for (var i = decorators.length - 1; i >= 0; i--)
89
+ if (d = decorators[i])
90
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
92
+ }
93
+ function __param(paramIndex, decorator) {
94
+ return function (target, key) { decorator(target, key, paramIndex); };
95
+ }
96
+ function __metadata(metadataKey, metadataValue) {
97
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
+ return Reflect.metadata(metadataKey, metadataValue);
99
+ }
100
+ function __awaiter(thisArg, _arguments, P, generator) {
101
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
+ return new (P || (P = Promise))(function (resolve, reject) {
103
+ function fulfilled(value) { try {
104
+ step(generator.next(value));
105
+ }
106
+ catch (e) {
107
+ reject(e);
108
+ } }
109
+ function rejected(value) { try {
110
+ step(generator["throw"](value));
111
+ }
112
+ catch (e) {
113
+ reject(e);
114
+ } }
115
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
117
+ });
118
+ }
119
+ function __generator(thisArg, body) {
120
+ var _ = { label: 0, sent: function () { if (t[0] & 1)
121
+ throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
+ function verb(n) { return function (v) { return step([n, v]); }; }
124
+ function step(op) {
125
+ if (f)
126
+ throw new TypeError("Generator is already executing.");
127
+ while (_)
128
+ try {
129
+ 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)
130
+ return t;
131
+ if (y = 0, t)
132
+ op = [op[0] & 2, t.value];
133
+ switch (op[0]) {
134
+ case 0:
135
+ case 1:
136
+ t = op;
137
+ break;
138
+ case 4:
139
+ _.label++;
140
+ return { value: op[1], done: false };
141
+ case 5:
142
+ _.label++;
143
+ y = op[1];
144
+ op = [0];
145
+ continue;
146
+ case 7:
147
+ op = _.ops.pop();
148
+ _.trys.pop();
149
+ continue;
150
+ default:
151
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
+ _ = 0;
153
+ continue;
154
+ }
155
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
+ _.label = op[1];
157
+ break;
158
+ }
159
+ if (op[0] === 6 && _.label < t[1]) {
160
+ _.label = t[1];
161
+ t = op;
162
+ break;
163
+ }
164
+ if (t && _.label < t[2]) {
165
+ _.label = t[2];
166
+ _.ops.push(op);
167
+ break;
168
+ }
169
+ if (t[2])
170
+ _.ops.pop();
171
+ _.trys.pop();
172
+ continue;
173
+ }
174
+ op = body.call(thisArg, _);
175
+ }
176
+ catch (e) {
177
+ op = [6, e];
178
+ y = 0;
179
+ }
180
+ finally {
181
+ f = t = 0;
182
+ }
183
+ if (op[0] & 5)
184
+ throw op[1];
185
+ return { value: op[0] ? op[1] : void 0, done: true };
186
+ }
187
+ }
188
+ var __createBinding = Object.create ? (function (o, m, k, k2) {
189
+ if (k2 === undefined)
190
+ k2 = k;
191
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
+ }) : (function (o, m, k, k2) {
193
+ if (k2 === undefined)
194
+ k2 = k;
195
+ o[k2] = m[k];
196
+ });
197
+ function __exportStar(m, o) {
198
+ for (var p in m)
199
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
+ __createBinding(o, m, p);
201
+ }
202
+ function __values(o) {
203
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
+ if (m)
205
+ return m.call(o);
206
+ if (o && typeof o.length === "number")
207
+ return {
208
+ next: function () {
209
+ if (o && i >= o.length)
210
+ o = void 0;
211
+ return { value: o && o[i++], done: !o };
212
+ }
213
+ };
214
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
+ }
216
+ function __read(o, n) {
217
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
218
+ if (!m)
219
+ return o;
220
+ var i = m.call(o), r, ar = [], e;
221
+ try {
222
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
+ ar.push(r.value);
224
+ }
225
+ catch (error) {
226
+ e = { error: error };
227
+ }
228
+ finally {
229
+ try {
230
+ if (r && !r.done && (m = i["return"]))
231
+ m.call(i);
232
+ }
233
+ finally {
234
+ if (e)
235
+ throw e.error;
236
+ }
237
+ }
238
+ return ar;
239
+ }
240
+ /** @deprecated */
241
+ function __spread() {
242
+ for (var ar = [], i = 0; i < arguments.length; i++)
243
+ ar = ar.concat(__read(arguments[i]));
244
+ return ar;
245
+ }
246
+ /** @deprecated */
247
+ function __spreadArrays() {
248
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
+ s += arguments[i].length;
250
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
+ r[k] = a[j];
253
+ return r;
254
+ }
255
+ function __spreadArray(to, from, pack) {
256
+ if (pack || arguments.length === 2)
257
+ for (var i = 0, l = from.length, ar; i < l; i++) {
258
+ if (ar || !(i in from)) {
259
+ if (!ar)
260
+ ar = Array.prototype.slice.call(from, 0, i);
261
+ ar[i] = from[i];
262
+ }
263
+ }
264
+ return to.concat(ar || from);
265
+ }
266
+ function __await(v) {
267
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
268
+ }
269
+ function __asyncGenerator(thisArg, _arguments, generator) {
270
+ if (!Symbol.asyncIterator)
271
+ throw new TypeError("Symbol.asyncIterator is not defined.");
272
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
+ function verb(n) { if (g[n])
275
+ i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
+ function resume(n, v) { try {
277
+ step(g[n](v));
278
+ }
279
+ catch (e) {
280
+ settle(q[0][3], e);
281
+ } }
282
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
+ function fulfill(value) { resume("next", value); }
284
+ function reject(value) { resume("throw", value); }
285
+ function settle(f, v) { if (f(v), q.shift(), q.length)
286
+ resume(q[0][0], q[0][1]); }
287
+ }
288
+ function __asyncDelegator(o) {
289
+ var i, p;
290
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
+ }
293
+ function __asyncValues(o) {
294
+ if (!Symbol.asyncIterator)
295
+ throw new TypeError("Symbol.asyncIterator is not defined.");
296
+ var m = o[Symbol.asyncIterator], i;
297
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
+ }
301
+ function __makeTemplateObject(cooked, raw) {
302
+ if (Object.defineProperty) {
303
+ Object.defineProperty(cooked, "raw", { value: raw });
304
+ }
305
+ else {
306
+ cooked.raw = raw;
307
+ }
308
+ return cooked;
309
+ }
310
+ ;
311
+ var __setModuleDefault = Object.create ? (function (o, v) {
312
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
313
+ }) : function (o, v) {
314
+ o["default"] = v;
315
+ };
316
+ function __importStar(mod) {
317
+ if (mod && mod.__esModule)
318
+ return mod;
319
+ var result = {};
320
+ if (mod != null)
321
+ for (var k in mod)
322
+ if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
+ __createBinding(result, mod, k);
324
+ __setModuleDefault(result, mod);
325
+ return result;
326
+ }
327
+ function __importDefault(mod) {
328
+ return (mod && mod.__esModule) ? mod : { default: mod };
329
+ }
330
+ function __classPrivateFieldGet(receiver, state, kind, f) {
331
+ if (kind === "a" && !f)
332
+ throw new TypeError("Private accessor was defined without a getter");
333
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
+ }
337
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
+ if (kind === "m")
339
+ throw new TypeError("Private method is not writable");
340
+ if (kind === "a" && !f)
341
+ throw new TypeError("Private accessor was defined without a setter");
342
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
+ }
346
+
347
+ /**
348
+ * Assembly of @package ng2-cookies @see https://www.npmjs.com/package/ng2-cookies
349
+ *
350
+ * Reassembled by
351
+ * @author sambath999
352
+ * @date_29_09_2021
353
+ * Updated from raw parameters to
354
+ * @param {ICookieOptions} options and added another newer cookie flag
355
+ * @param {string} samesite
356
+ * @param {constant} SameSiteTypes, @param {string} strict "strict", @param {string} lax "lax", @param {string} none "none"
357
+ *
358
+ * @enum
359
+ */
360
+ var LocalizeTokenStorage = /** @class */ (function () {
361
+ function LocalizeTokenStorage(_defaultOptions) {
362
+ this.defaultOptions = _defaultOptions !== null && _defaultOptions !== void 0 ? _defaultOptions : this.getDefaultOptions;
363
+ }
364
+ Object.defineProperty(LocalizeTokenStorage.prototype, "getDefaultOptions", {
365
+ get: function () {
366
+ var mainDomain = extractMainDomain(window.location.hostname);
367
+ return {
368
+ path: '/',
369
+ domain: mainDomain,
370
+ secure: true,
371
+ // samesite: SameSiteType.strict,
372
+ expires: 1
373
+ };
374
+ },
375
+ enumerable: false,
376
+ configurable: true
377
+ });
378
+ /**
379
+ * Checks the existence of a single cookie by it's name
380
+ *
381
+ * @param {string} name Identification of the cookie
382
+ * @returns existence of the cookie
383
+ */
384
+ LocalizeTokenStorage.prototype.check = function (name) {
385
+ if (typeof document === "undefined")
386
+ return false;
387
+ name = encodeURIComponent(name);
388
+ var regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
389
+ return regexp.test(document.cookie);
390
+ };
391
+ /**
392
+ * Retrieves a single cookie by it's name
393
+ *
394
+ * @param {string} name Identification of the Cookie
395
+ * @returns The Cookie's value
396
+ */
397
+ LocalizeTokenStorage.prototype.get = function (name) {
398
+ if (!this.check(name))
399
+ return undefined;
400
+ name = encodeURIComponent(name);
401
+ var regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
402
+ var result = regexp.exec(document.cookie);
403
+ return result ? decodeURIComponent(result[1]) : undefined;
404
+ };
405
+ /**
406
+ * Retrieves a a list of all cookie avaiable
407
+ *
408
+ * @returns Object with all Cookies
409
+ */
410
+ LocalizeTokenStorage.prototype.getAll = function () {
411
+ var e_1, _a;
412
+ var cookies = {};
413
+ if (document.cookie) {
414
+ var split = document.cookie.split(';');
415
+ try {
416
+ for (var split_1 = __values(split), split_1_1 = split_1.next(); !split_1_1.done; split_1_1 = split_1.next()) {
417
+ var s = split_1_1.value;
418
+ var currCookie = s.split('=');
419
+ currCookie[0] = currCookie[0].trim();
420
+ cookies[decodeURIComponent(currCookie[0])] = decodeURIComponent(currCookie[1]);
421
+ }
422
+ }
423
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
424
+ finally {
425
+ try {
426
+ if (split_1_1 && !split_1_1.done && (_a = split_1.return)) _a.call(split_1);
427
+ }
428
+ finally { if (e_1) throw e_1.error; }
429
+ }
430
+ }
431
+ return cookies;
432
+ };
433
+ LocalizeTokenStorage.prototype.set = function (name, value, options) {
434
+ options !== null && options !== void 0 ? options : (options = this.defaultOptions);
435
+ var _a = Object.assign(Object.assign({}, this.defaultOptions), options), expires = _a.expires, path = _a.path, domain = _a.domain, secure = _a.secure, samesite = _a.samesite;
436
+ var cookieStr = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";";
437
+ if (expires) {
438
+ var dtExpires = typeof expires === 'number' ? new Date(Date.now() + expires * 864e5) : expires;
439
+ cookieStr += "expires=" + dtExpires.toUTCString() + ";";
440
+ }
441
+ cookieStr += path ? "path=" + path + ";" : '';
442
+ cookieStr += domain ? "domain=" + domain + ";" : '';
443
+ cookieStr += secure ? 'secure;' : '';
444
+ cookieStr += samesite ? "samesite=" + samesite + ";" : '';
445
+ document.cookie = cookieStr;
446
+ };
447
+ /**
448
+ * Removes specified Cookie
449
+ *
450
+ * @param {string} name Cookie's identification
451
+ * @param {string} path Path relative to the domain where the cookie should be avaiable. Default /
452
+ * @param {string} domain Domain where the cookie should be avaiable. Default current domain
453
+ */
454
+ LocalizeTokenStorage.prototype.delete = function (name, path, domain) {
455
+ if (path === void 0) { path = '/'; }
456
+ if (domain === void 0) { domain = window.location.hostname; }
457
+ this.set(name, '', { path: path, domain: domain, expires: -1 });
458
+ };
459
+ /**
460
+ * Delete all cookie avaiable
461
+ */
462
+ LocalizeTokenStorage.prototype.deleteAll = function (path, domain) {
463
+ var e_2, _a;
464
+ var cookies = this.getAll();
465
+ try {
466
+ for (var _b = __values(Object.keys(cookies)), _c = _b.next(); !_c.done; _c = _b.next()) {
467
+ var cookieName = _c.value;
468
+ this.delete(cookieName, path, domain);
469
+ }
470
+ }
471
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
472
+ finally {
473
+ try {
474
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
475
+ }
476
+ finally { if (e_2) throw e_2.error; }
477
+ }
478
+ };
479
+ return LocalizeTokenStorage;
480
+ }());
481
+
482
+ var LocalizeToken = /** @class */ (function () {
483
+ function LocalizeToken() {
484
+ this.configSubject = new rxjs.BehaviorSubject(LocalizeToken.config);
485
+ }
486
+ Object.defineProperty(LocalizeToken.prototype, "getConfig", {
487
+ get: function () { return this.configSubject.value; },
488
+ enumerable: false,
489
+ configurable: true
490
+ });
491
+ LocalizeToken.init = function (config) {
492
+ var lConfig = new LocalizeToken();
493
+ LocalizeToken.config = Object.assign(Object.assign({}, LocalizeToken.config), config);
494
+ lConfig.configSubject.next(LocalizeToken.config);
495
+ };
496
+ return LocalizeToken;
497
+ }());
498
+ LocalizeToken.config = {
499
+ mainDomain: extractMainDomain(),
500
+ authTokenName: 'auth-token',
501
+ refreshTokenName: '_lze_rftkp_',
502
+ needTenant: false,
503
+ isProduction: false,
504
+ revokeTokenUrl: ''
505
+ };
506
+ LocalizeToken.storage = new LocalizeTokenStorage();
507
+ LocalizeToken.httpHeaders = {
508
+ AUTHORIZATION: 'Authorization',
509
+ X_TENANT: 'X-Tenant',
510
+ X_REFRESH_TOKEN: 'X-RefreshToken',
511
+ CONTENT_TYPE: 'Content-Type',
512
+ };
513
+ /**
514
+ * Waits for a specified amount of time.
515
+ * @param milliseconds - The milliseconds to wait.
516
+ * @param when - The condition to wait for. Default is true.
517
+ * @returns - Promise<void>
518
+ */
519
+ function waitFor(milliseconds, when) {
520
+ if (when === void 0) { when = true; }
521
+ return __awaiter(this, void 0, void 0, function () {
522
+ return __generator(this, function (_a) {
523
+ switch (_a.label) {
524
+ case 0:
525
+ if (!when)
526
+ return [2 /*return*/];
527
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, milliseconds); })];
528
+ case 1:
529
+ _a.sent();
530
+ return [2 /*return*/];
531
+ }
532
+ });
533
+ });
534
+ }
535
+ /**
536
+ * Waits until the condition is met.
537
+ * @param when - The condition to wait for.
538
+ * @param intervalNumber - The interval number in milliseconds to check the condition. Default is 50.
539
+ */
540
+ function waitUntil(when, intervalNumber) {
541
+ if (intervalNumber === void 0) { intervalNumber = 50; }
542
+ return __awaiter(this, void 0, void 0, function () {
543
+ var _this = this;
544
+ return __generator(this, function (_a) {
545
+ switch (_a.label) {
546
+ case 0: return [4 /*yield*/, new Promise(function (resolve) {
547
+ var interval = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
548
+ var cond, result, _a;
549
+ return __generator(this, function (_b) {
550
+ switch (_b.label) {
551
+ case 0:
552
+ cond = when();
553
+ if (!(cond instanceof Promise)) return [3 /*break*/, 2];
554
+ return [4 /*yield*/, cond];
555
+ case 1:
556
+ _a = _b.sent();
557
+ return [3 /*break*/, 3];
558
+ case 2:
559
+ _a = cond;
560
+ _b.label = 3;
561
+ case 3:
562
+ result = _a;
563
+ if (result) {
564
+ clearInterval(interval);
565
+ resolve(true);
566
+ }
567
+ return [2 /*return*/];
568
+ }
569
+ });
570
+ }); }, intervalNumber);
571
+ })];
572
+ case 1:
573
+ _a.sent();
574
+ return [2 /*return*/];
575
+ }
576
+ });
577
+ });
578
+ }
579
+ function extractMainDomain(subdomain) {
580
+ subdomain !== null && subdomain !== void 0 ? subdomain : (subdomain = window.location.hostname);
581
+ var parts = subdomain.split('.');
582
+ return parts.length > 2 ? parts.slice(-2).join('.') : subdomain;
583
+ }
584
+
585
+ var LocalizeTokenService = /** @class */ (function () {
586
+ function LocalizeTokenService(tokenConfig) {
587
+ this.tokenConfig = tokenConfig;
588
+ this.isRevokingTokenSubject = new rxjs.BehaviorSubject(false);
589
+ this.decodeToken = function (token) { return jwt_decode__namespace.jwtDecode(token); };
590
+ // if (!this.tokenConfig.getConfig.authTokenName || !this.tokenConfig.getConfig.refreshTokenName || !this.tokenConfig.getConfig.tenantTokenName) {
591
+ // throw new Error('authTokenName, refreshTokenName, and tenantTokenName must be defined in LocalizeToken.config')
592
+ // }
593
+ // this.config = this.tokenConfig.getConfig;
594
+ }
595
+ Object.defineProperty(LocalizeTokenService.prototype, "config", {
596
+ // private readonly config: ILocalizeTokenConfig
597
+ get: function () { return this.tokenConfig.getConfig; },
598
+ enumerable: false,
599
+ configurable: true
600
+ });
601
+ Object.defineProperty(LocalizeTokenService.prototype, "authToken", {
602
+ get: function () { return this.storageGet(); },
603
+ set: function (value) {
604
+ value
605
+ ? this.storageSet(value)
606
+ : LocalizeToken.storage.delete(this.config.authTokenName);
607
+ },
608
+ enumerable: false,
609
+ configurable: true
610
+ });
611
+ Object.defineProperty(LocalizeTokenService.prototype, "refreshToken", {
612
+ get: function () { return LocalizeToken.storage.get(this.config.refreshTokenName); },
613
+ enumerable: false,
614
+ configurable: true
615
+ });
616
+ Object.defineProperty(LocalizeTokenService.prototype, "accessToken", {
617
+ get: function () { var _a; return (_a = this.authToken) === null || _a === void 0 ? void 0 : _a.token; },
618
+ set: function (value) {
619
+ if (value) {
620
+ this.authToken = { token: value, revoke: false };
621
+ }
622
+ },
623
+ enumerable: false,
624
+ configurable: true
625
+ });
626
+ Object.defineProperty(LocalizeTokenService.prototype, "isRevokingToken", {
627
+ get: function () { return this.isRevokingTokenSubject.value; /* this.authToken?.revoke ?? false */ },
628
+ set: function (value) {
629
+ this.isRevokingTokenSubject.next(value);
630
+ if (this.authToken) {
631
+ this.authToken = Object.assign(Object.assign({}, this.authToken), { revoke: value });
632
+ }
633
+ },
634
+ enumerable: false,
635
+ configurable: true
636
+ });
637
+ LocalizeTokenService.prototype.tenantToken = function () { return LocalizeToken.storage.get(this.config.tenantTokenName); };
638
+ LocalizeTokenService.prototype.storageGet = function () {
639
+ try {
640
+ var encoded = LocalizeToken.storage.get(this.config.authTokenName);
641
+ var decoded = atob(encoded || '');
642
+ return JSON.parse(decoded);
643
+ }
644
+ catch (_a) {
645
+ return undefined;
646
+ }
647
+ };
648
+ LocalizeTokenService.prototype.storageSet = function (value) {
649
+ var base64 = btoa(JSON.stringify(value));
650
+ LocalizeToken.storage.set(this.config.authTokenName, base64);
651
+ };
652
+ LocalizeTokenService.prototype.tokensValid = function () {
653
+ var _a, _b;
654
+ 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));
655
+ };
656
+ Object.defineProperty(LocalizeTokenService.prototype, "decodeRefreshToken", {
657
+ get: function () {
658
+ var token = LocalizeToken.storage.get(this.config.refreshTokenName);
659
+ if (!token)
660
+ return null;
661
+ return this.decodeToken(token);
662
+ },
663
+ enumerable: false,
664
+ configurable: true
665
+ });
666
+ return LocalizeTokenService;
667
+ }());
668
+ LocalizeTokenService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeTokenService_Factory() { return new LocalizeTokenService(i0__namespace.ɵɵinject(LocalizeToken)); }, token: LocalizeTokenService, providedIn: "root" });
669
+ LocalizeTokenService.decorators = [
670
+ { type: i0.Injectable, args: [{ providedIn: 'root' },] }
671
+ ];
672
+ LocalizeTokenService.ctorParameters = function () { return [
673
+ { type: LocalizeToken }
674
+ ]; };
675
+
676
+ /**
677
+ * Http method options
678
+ */
679
+ exports.EMethod = void 0;
680
+ (function (EMethod) {
681
+ EMethod[EMethod["POST"] = 1] = "POST";
682
+ EMethod[EMethod["GET"] = 2] = "GET";
683
+ EMethod[EMethod["PUT"] = 3] = "PUT";
684
+ EMethod[EMethod["DELETE"] = 4] = "DELETE";
685
+ EMethod[EMethod["PATCH"] = 5] = "PATCH";
686
+ })(exports.EMethod || (exports.EMethod = {}));
687
+ var LocalizeApiService = /** @class */ (function () {
688
+ function LocalizeApiService(httpClient, tokenConfig, localizeTokenService) {
689
+ var _this = this;
690
+ this.httpClient = httpClient;
691
+ this.tokenConfig = tokenConfig;
692
+ this.localizeTokenService = localizeTokenService;
693
+ this.isRequestingSubject = new rxjs.BehaviorSubject(false);
694
+ this.isResolvedStartupSubject = new rxjs.BehaviorSubject(false);
695
+ this.apiConfigs = {};
696
+ /**
697
+ * A higher-order function that returns a curried function for making API requests.
698
+ *
699
+ * @param baseUrl - The base URL of the API.
700
+ * @returns A curried function that can be used to make API requests.
701
+ */
702
+ this.func = function (baseUrl) { return function (path, method, value, isFormData, headers) {
703
+ if (method === void 0) { method = exports.EMethod.GET; }
704
+ if (value === void 0) { value = null; }
705
+ if (isFormData === void 0) { isFormData = false; }
706
+ return _this.base(baseUrl, path, method, value, isFormData, headers);
707
+ }; };
708
+ }
709
+ Object.defineProperty(LocalizeApiService.prototype, "isRequesting", {
710
+ get: function () { return this.isRequestingSubject.value; },
711
+ enumerable: false,
712
+ configurable: true
713
+ });
714
+ Object.defineProperty(LocalizeApiService.prototype, "isResolvedStartup", {
715
+ get: function () { return this.isResolvedStartupSubject.value; },
716
+ enumerable: false,
717
+ configurable: true
718
+ });
719
+ Object.defineProperty(LocalizeApiService.prototype, "config", {
720
+ get: function () { return this.tokenConfig.getConfig; },
721
+ enumerable: false,
722
+ configurable: true
723
+ });
724
+ /**
725
+ * Initialize the API service.
726
+ * @param apiConfigs - The API configurations.
727
+ */
728
+ LocalizeApiService.prototype.init = function (apiConfigs) {
729
+ this.apiConfigs = apiConfigs;
730
+ };
731
+ LocalizeApiService.prototype.base = function (baseUrl, path, method, value, isFormData, headers) {
732
+ if (method === void 0) { method = exports.EMethod.GET; }
733
+ if (value === void 0) { value = null; }
734
+ if (isFormData === void 0) { isFormData = false; }
735
+ return __awaiter(this, void 0, void 0, function () {
736
+ var url, httpMethod, request, error_1;
737
+ var _this = this;
738
+ return __generator(this, function (_b) {
739
+ switch (_b.label) {
740
+ case 0: return [4 /*yield*/, this.ifPromise(this.apiConfigs.onPrepareRequest)];
741
+ case 1:
742
+ _b.sent();
743
+ url = "" + baseUrl.trim().replace(/\/?$/, '/') + path.trim().replace(/^\//, '');
744
+ httpMethod = exports.EMethod[method].toLowerCase();
745
+ request = function () { return { body: value, headers: _this.options(isFormData, headers) }; };
746
+ // Wait for previous request to complete
747
+ return [4 /*yield*/, this.toWaitForPreviousRequest()];
748
+ case 2:
749
+ // Wait for previous request to complete
750
+ _b.sent();
751
+ _b.label = 3;
752
+ case 3:
753
+ _b.trys.push([3, 5, , 7]);
754
+ return [4 /*yield*/, this.processRequest(httpMethod, url, request())];
755
+ case 4: return [2 /*return*/, _b.sent()];
756
+ case 5:
757
+ error_1 = _b.sent();
758
+ if (error_1.status !== 401) {
759
+ throw error_1;
760
+ }
761
+ return [4 /*yield*/, this.onUnauthorizedError(httpMethod, url, request)];
762
+ case 6: return [2 /*return*/, _b.sent()];
763
+ case 7: return [2 /*return*/];
764
+ }
765
+ });
766
+ });
767
+ };
768
+ LocalizeApiService.prototype.onUnauthorizedError = function (httpMethod, url, request) {
769
+ return __awaiter(this, void 0, void 0, function () {
770
+ return __generator(this, function (_b) {
771
+ switch (_b.label) {
772
+ case 0: return [4 /*yield*/, this.revokeToken()];
773
+ case 1:
774
+ _b.sent();
775
+ if (!!this.isResolvedStartup) return [3 /*break*/, 3];
776
+ return [4 /*yield*/, this.processRequest(httpMethod, url, request())];
777
+ case 2: return [2 /*return*/, _b.sent()];
778
+ case 3: return [2 /*return*/];
779
+ }
780
+ });
781
+ });
782
+ };
783
+ LocalizeApiService.prototype.toWaitForPreviousRequest = function () {
784
+ var _a;
785
+ return __awaiter(this, void 0, void 0, function () {
786
+ var _this = this;
787
+ return __generator(this, function (_b) {
788
+ switch (_b.label) {
789
+ case 0:
790
+ if (!this.localizeTokenService.isRevokingToken) return [3 /*break*/, 2];
791
+ return [4 /*yield*/, waitUntil(function () { return !_this.localizeTokenService.isRevokingToken; })];
792
+ case 1:
793
+ _b.sent();
794
+ _b.label = 2;
795
+ case 2:
796
+ if (!((_a = this.apiConfigs.waitEachRequest) === null || _a === void 0 ? void 0 : _a.milliseconds)) return [3 /*break*/, 4];
797
+ return [4 /*yield*/, waitFor(this.apiConfigs.waitEachRequest.milliseconds, this.isRequesting)];
798
+ case 3:
799
+ _b.sent();
800
+ _b.label = 4;
801
+ case 4: return [2 /*return*/];
802
+ }
803
+ });
804
+ });
805
+ };
806
+ LocalizeApiService.prototype.processRequest = function (method, url, options) {
807
+ return __awaiter(this, void 0, void 0, function () {
808
+ var result;
809
+ var _this = this;
810
+ return __generator(this, function (_b) {
811
+ switch (_b.label) {
812
+ case 0:
813
+ this.isRequestingSubject.next(true);
814
+ return [4 /*yield*/, new Promise(function (resolve, reject) { return _this.httpClient.request(method, url, options).subscribe({ next: resolve, error: reject }); })];
815
+ case 1:
816
+ result = _b.sent();
817
+ this.isRequestingSubject.next(false);
818
+ return [2 /*return*/, result];
819
+ }
820
+ });
821
+ });
822
+ };
823
+ LocalizeApiService.prototype.revokeToken = function (force) {
824
+ if (force === void 0) { force = false; }
825
+ return __awaiter(this, void 0, void 0, function () {
826
+ var reqUrl_1, reqHeaders_1, revokeToken;
827
+ var _this = this;
828
+ return __generator(this, function (_b) {
829
+ switch (_b.label) {
830
+ case 0:
831
+ if (!(this.localizeTokenService.isRevokingToken && !force)) return [3 /*break*/, 2];
832
+ return [4 /*yield*/, waitUntil(function () { return !_this.localizeTokenService.isRevokingToken; })];
833
+ case 1:
834
+ _b.sent();
835
+ return [2 /*return*/];
836
+ case 2:
837
+ _b.trys.push([2, , 10, 11]);
838
+ this.localizeTokenService.isRevokingToken = true;
839
+ reqUrl_1 = this.config.revokeTokenUrl;
840
+ reqHeaders_1 = this.options().append(LocalizeToken.httpHeaders.X_REFRESH_TOKEN, "" + this.localizeTokenService.refreshToken);
841
+ return [4 /*yield*/, new Promise(function (resolve, reject) { return _this.httpClient.get(reqUrl_1, { headers: reqHeaders_1 }).subscribe({ next: resolve, error: reject }); })];
842
+ case 3:
843
+ revokeToken = _b.sent();
844
+ if (!(revokeToken === null || revokeToken === void 0 ? void 0 : revokeToken.status)) return [3 /*break*/, 4];
845
+ this.localizeTokenService.accessToken = revokeToken.message;
846
+ return [3 /*break*/, 9];
847
+ case 4:
848
+ if (!!this.localizeTokenService.refreshToken) return [3 /*break*/, 6];
849
+ return [4 /*yield*/, this.ifPromise(this.apiConfigs.onAutoLogout)];
850
+ case 5:
851
+ _b.sent();
852
+ return [3 /*break*/, 9];
853
+ case 6:
854
+ if (!this.apiConfigs.onRevokeUnauthorized) return [3 /*break*/, 9];
855
+ return [4 /*yield*/, this.ifPromise(this.apiConfigs.onRevokeUnauthorized)];
856
+ case 7:
857
+ _b.sent();
858
+ return [4 /*yield*/, this.revokeToken(true)];
859
+ case 8:
860
+ _b.sent();
861
+ _b.label = 9;
862
+ case 9: return [3 /*break*/, 11];
863
+ case 10:
864
+ this.localizeTokenService.isRevokingToken = false;
865
+ return [7 /*endfinally*/];
866
+ case 11: return [2 /*return*/];
867
+ }
868
+ });
869
+ });
870
+ };
871
+ /** default http request options */
872
+ LocalizeApiService.prototype.options = function (isFormData, headers) {
873
+ var _b;
874
+ if (isFormData === void 0) { isFormData = false; }
875
+ if (headers === void 0) { headers = {}; }
876
+ var defaultHeaders = (_b = {}, _b[LocalizeToken.httpHeaders.AUTHORIZATION] = "Bearer " + this.localizeTokenService.accessToken, _b);
877
+ if (this.config.needTenant) {
878
+ defaultHeaders[LocalizeToken.httpHeaders.X_TENANT] = "" + this.localizeTokenService.tenantToken();
879
+ }
880
+ if (!isFormData) {
881
+ defaultHeaders[LocalizeToken.httpHeaders.CONTENT_TYPE] = 'application/json';
882
+ }
883
+ var filteredHeaders = Object.keys(defaultHeaders).filter(function (key) { return !Object.keys(headers).includes(key); })
884
+ .reduce(function (acc, key) {
885
+ var _b;
886
+ return (Object.assign(Object.assign({}, acc), (_b = {}, _b[key] = defaultHeaders[key], _b)));
887
+ }, {});
888
+ var mergedHeaders = Object.assign(Object.assign({}, filteredHeaders), headers);
889
+ return new i1.HttpHeaders(mergedHeaders);
890
+ };
891
+ LocalizeApiService.prototype.ifPromise = function (fn) {
892
+ return __awaiter(this, void 0, void 0, function () {
893
+ var _b;
894
+ return __generator(this, function (_c) {
895
+ switch (_c.label) {
896
+ case 0:
897
+ if (!fn)
898
+ return [2 /*return*/];
899
+ if (!(fn instanceof Promise)) return [3 /*break*/, 2];
900
+ return [4 /*yield*/, fn()];
901
+ case 1:
902
+ _b = _c.sent();
903
+ return [3 /*break*/, 3];
904
+ case 2:
905
+ _b = fn();
906
+ _c.label = 3;
907
+ case 3: return [2 /*return*/, _b];
908
+ }
909
+ });
910
+ });
911
+ };
912
+ return LocalizeApiService;
913
+ }()); //class
914
+ LocalizeApiService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeApiService_Factory() { return new LocalizeApiService(i0__namespace.ɵɵinject(i1__namespace.HttpClient), i0__namespace.ɵɵinject(LocalizeToken), i0__namespace.ɵɵinject(LocalizeTokenService)); }, token: LocalizeApiService, providedIn: "root" });
915
+ LocalizeApiService.decorators = [
916
+ { type: i0.Injectable, args: [{
917
+ providedIn: 'root'
918
+ },] }
919
+ ];
920
+ LocalizeApiService.ctorParameters = function () { return [
921
+ { type: i1.HttpClient },
922
+ { type: LocalizeToken },
923
+ { type: LocalizeTokenService }
924
+ ]; };
925
+
926
+ var LocalizeTokenModule = /** @class */ (function () {
927
+ function LocalizeTokenModule() {
928
+ }
929
+ return LocalizeTokenModule;
930
+ }());
931
+ LocalizeTokenModule.decorators = [
932
+ { type: i0.NgModule, args: [{
933
+ providers: [
934
+ LocalizeTokenService,
935
+ LocalizeApiService,
936
+ LocalizeToken
937
+ ],
938
+ },] }
939
+ ];
940
+
941
+ var LocalizeLogindlgComponent = /** @class */ (function () {
942
+ function LocalizeLogindlgComponent(messageService, cdt, dlgRef, dlgConfig, tokenService, httpClient, tokenConfig) {
943
+ var _this = this;
944
+ this.messageService = messageService;
945
+ this.cdt = cdt;
946
+ this.dlgRef = dlgRef;
947
+ this.dlgConfig = dlgConfig;
948
+ this.tokenService = tokenService;
949
+ this.httpClient = httpClient;
950
+ this.tokenConfig = tokenConfig;
951
+ this.messageKey = "$login-dlg";
952
+ this.loading = false;
953
+ this.success = false;
954
+ this.clickLogout = function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); };
955
+ this.decodeToken = this.tokenService.decodeRefreshToken;
956
+ this.loginConfig = this.dlgConfig.data.loginConfig;
957
+ }
958
+ Object.defineProperty(LocalizeLogindlgComponent.prototype, "config", {
959
+ get: function () { return this.tokenConfig.getConfig; },
960
+ enumerable: false,
961
+ configurable: true
962
+ });
963
+ LocalizeLogindlgComponent.prototype.ngOnInit = function () {
964
+ var _this = this;
965
+ this.dlgConfig.closable = false;
966
+ this.logout = this.loginConfig.logoutFunc;
967
+ this.loginUrl = this.loginConfig.loginUrl;
968
+ if (!this.decodeToken) {
969
+ this.showMessage("error", "Token is invalid");
970
+ setTimeout(function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); }, 2000);
971
+ }
972
+ };
973
+ LocalizeLogindlgComponent.prototype.ngAfterViewInit = function () {
974
+ this.cdt.detectChanges();
975
+ };
976
+ LocalizeLogindlgComponent.prototype.clickLogin = function () {
977
+ var _a, _b;
978
+ return __awaiter(this, void 0, void 0, function () {
979
+ var loginRes, cookieOptions;
980
+ var _this = this;
981
+ return __generator(this, function (_c) {
982
+ switch (_c.label) {
983
+ case 0:
984
+ if (!this.isValidPassword) {
985
+ this.showMessage("error", "Password is required and must be at least 6 characters");
986
+ return [2 /*return*/];
987
+ }
988
+ this.loading = true;
989
+ return [4 /*yield*/, this.login()];
990
+ case 1:
991
+ loginRes = _c.sent();
992
+ if (!(loginRes === null || loginRes === void 0 ? void 0 : loginRes.status)) {
993
+ this.showMessage("error", (_a = loginRes.message) !== null && _a !== void 0 ? _a : "An error occurred");
994
+ return [2 /*return*/];
995
+ }
996
+ this.tokenService.accessToken = loginRes.tokens.accessToken;
997
+ cookieOptions = { expires: (_b = this.loginConfig.expire) !== null && _b !== void 0 ? _b : 5 };
998
+ LocalizeToken.storage.set(this.config.refreshTokenName, loginRes.tokens.refreshToken, cookieOptions);
999
+ this.success = true;
1000
+ setTimeout(function () { return _this.dlgRef.close(true); }, 2000);
1001
+ return [2 /*return*/];
1002
+ }
1003
+ });
1004
+ });
1005
+ };
1006
+ LocalizeLogindlgComponent.prototype.login = function () {
1007
+ return __awaiter(this, void 0, void 0, function () {
1008
+ var e_1;
1009
+ var _this = this;
1010
+ return __generator(this, function (_c) {
1011
+ switch (_c.label) {
1012
+ case 0:
1013
+ if (!this.loginUrl || !this.loginUrl.trim().length) {
1014
+ this.showMessage("error", "Login url is required");
1015
+ throw new Error("Login url is required");
1016
+ }
1017
+ _c.label = 1;
1018
+ case 1:
1019
+ _c.trys.push([1, 3, , 4]);
1020
+ return [4 /*yield*/, new Promise(function (resolve, reject) { return _this.httpClient.post(_this.loginUrl, { password: _this.password.trim() }, { headers: _this.getHeaders() })
1021
+ .subscribe({ next: resolve, error: reject }); })];
1022
+ case 2: return [2 /*return*/, _c.sent()];
1023
+ case 3:
1024
+ e_1 = _c.sent();
1025
+ this.showMessage("error", e_1.message);
1026
+ return [2 /*return*/, null];
1027
+ case 4: return [2 /*return*/];
1028
+ }
1029
+ });
1030
+ });
1031
+ };
1032
+ LocalizeLogindlgComponent.prototype.getHeaders = function () {
1033
+ var _c;
1034
+ var _a, _b;
1035
+ return _c = {},
1036
+ _c[LocalizeToken.httpHeaders.X_REFRESH_TOKEN] = (_a = LocalizeToken.storage.get(this.config.refreshTokenName)) !== null && _a !== void 0 ? _a : "",
1037
+ _c[LocalizeToken.httpHeaders.X_TENANT] = (_b = LocalizeToken.storage.get(this.config.tenantTokenName)) !== null && _b !== void 0 ? _b : "",
1038
+ _c;
1039
+ };
1040
+ Object.defineProperty(LocalizeLogindlgComponent.prototype, "isValidPassword", {
1041
+ get: function () {
1042
+ this.loading = false;
1043
+ return this.password && this.password.trim().length >= 6 && this.password.trim().length <= 16;
1044
+ },
1045
+ enumerable: false,
1046
+ configurable: true
1047
+ });
1048
+ LocalizeLogindlgComponent.prototype.showMessage = function (severity, summary) {
1049
+ this.messageService.add({ key: this.messageKey, severity: severity, summary: summary });
1050
+ this.loading = false;
1051
+ };
1052
+ return LocalizeLogindlgComponent;
1053
+ }());
1054
+ LocalizeLogindlgComponent.decorators = [
1055
+ { type: i0.Component, args: [{
1056
+ template: "<p-toast key=\"$login-dlg\" position=\"top-center\"></p-toast>\n <div id=\"login-dlg-wrap\">\n <div id=\"login-dlg-header\">\n <div id=\"login-logo\" class=\"p-mb-2\"></div>\n <h3 *ngIf=\"!success\">Your session is expired! <br> Please login again to continue.</h3>\n <h3 *ngIf=\"success\" style=\"color:green !important;\">You haved successfully logged in.</h3>\n </div>\n <div id=\"login-dlg-content\">\n <ng-container *ngIf=\"!success\">\n <div *ngIf=\"loading\" class=\"loader-wrap\">\n <div class=\"login-dlg-loader\"></div>\n </div>\n <div class=\"login-dlg-elm\">\n <div class=\"p-inputgroup\">\n <span class=\"p-inputgroup-addon\">\n <i class=\"material-icons-round\">person</i>\n </span>\n <input disabled pInputText type=\"text\" placeholder=\"Username\" [value]=\"decodeToken?.email\" />\n </div>\n </div>\n \n <div class=\"login-dlg-elm\">\n <div class=\"p-inputgroup\">\n <span class=\"p-inputgroup-addon\">\n <i class=\"material-icons-round\">lock</i>\n </span>\n <input [disabled]=\"loading\" (keydown.enter)=\"clickLogin()\" pInputText type=\"password\" placeholder=\"Password\" [(ngModel)]=\"password\"\n autofocus />\n </div>\n </div>\n <div class=\"login-dlg-elm\">\n <button style=\"width: 100%;\" pButton type=\"button\" label=\"Login\" (click)=\"clickLogin()\"\n [disabled]=\"!password || loading\"></button>\n </div>\n \n <div class=\"login-dlg-elm\" style=\"display:flex;align-items: center;user-select: none;\">\n <span>No, I want to login with another user.</span>\n <button class=\"p-button-text\" pButton type=\"button\" label=\"Logout\" (click)=\"clickLogout()\"></button>\n </div>\n </ng-container>\n \n <ng-container *ngIf=\"success\">\n <div style=\"margin-top:35px;\"></div>\n <div class=\"check-animation-wrap\">\n <div class=\"check-main-container\">\n <div class=\"check-container\">\n <div class=\"check-background\">\n <svg viewBox=\"0 0 65 51\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M7 25L27.3077 44L58.5 7\" stroke=\"white\" stroke-width=\"13\" stroke-linecap=\"round\"\n stroke-linejoin=\"round\"></path>\n </svg>\n </div>\n </div>\n </div>\n </div>\n </ng-container>\n </div>\n </div>",
1057
+ selector: "app-localize-logindlg",
1058
+ providers: [api.MessageService],
1059
+ encapsulation: i0.ViewEncapsulation.None,
1060
+ styles: ["\n #login-dlg-wrap {\n width: 100%;\n max-width: 400px;\n margin: 0 auto;\n padding: 30px;\n }\n \n .login-dlg-elm {\n margin-top: 1rem;\n }\n \n #login-dlg-header {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n \n #login-dlg-header h3 {\n font-weight: bold;\n font-size: 0.9rem;\n color: orange;\n text-align: center;\n }\n \n #login-logo {\n height: 40px;\n width: 40px;\n background: url(\"/assets/images/logo-300px.png\") no-repeat;\n background-size: contain;\n }\n \n #login-dlg-content .p-inputgroup {\n height: 45px;\n }\n \n #login-dlg-content .p-inputgroup .p-inputgroup-addon {\n height: 45px;\n border-radius: 15px 0 0 15px;\n width: 50px;\n }\n \n #login-dlg-content .p-inputgroup .p-inputgroup-addon * {\n font-size: 1rem;\n }\n \n #login-dlg-content .p-inputgroup input {\n height: 45px;\n border-radius: 0 15px 15px 0;\n }\n \n #login-dlg-content button {\n height: 45px;\n border-radius: 15px;\n }\n \n /*check animation block*/\n \n .check-animation-wrap {\n top: 0;\n left: 0;\n position: absolute;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: calc(100% - 200px);\n min-height: 400px;\n }\n \n .check-main-container {\n width: 100%;\n height: 100vh;\n display: flex;\n flex-flow: column;\n justify-content: center;\n align-items: center;\n }\n \n .check-container {\n width: 6.25rem;\n height: 7.5rem;\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: space-between;\n }\n \n .check-container .check-background {\n width: 100%;\n height: calc(100% - 1.25rem);\n background: linear-gradient(to bottom right, #5de593, #41d67c);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n transform: scale(0.84);\n border-radius: 50%;\n animation: animateContainer 0.75s ease-out forwards 0.75s;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n }\n \n .check-container .check-background svg {\n width: 65%;\n transform: translateY(0.25rem);\n stroke-dasharray: 80;\n stroke-dashoffset: 80;\n animation: animateCheck 0.35s forwards 1.25s ease-out;\n min-width: auto !important;\n }\n \n .check-container .check-shadow {\n bottom: calc(-15% - 5px);\n left: 0;\n border-radius: 50%;\n background: radial-gradient(closest-side, rgba(73, 218, 131, 1), transparent);\n animation: animateShadow 0.75s ease-out forwards 0.75s;\n }\n \n @keyframes animateContainer {\n 0% {\n opacity: 0;\n transform: scale(0);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n }\n \n 25% {\n opacity: 1;\n transform: scale(0.9);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n }\n \n 43.75% {\n transform: scale(1.15);\n 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;\n }\n \n 62.5% {\n transform: scale(1);\n 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;\n }\n \n 81.25% {\n box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;\n }\n \n 100% {\n opacity: 1;\n box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;\n }\n }\n \n @keyframes animateCheck {\n from {\n stroke-dashoffset: 80;\n }\n \n to {\n stroke-dashoffset: 0;\n }\n }\n \n @keyframes animateShadow {\n 0% {\n opacity: 0;\n width: 100%;\n height: 15%;\n }\n \n 25% {\n opacity: 0.25;\n }\n \n 43.75% {\n width: 40%;\n height: 7%;\n opacity: 0.35;\n }\n \n 100% {\n width: 85%;\n height: 15%;\n opacity: 0.25;\n }\n }\n #login-dlg-wrap .loader-wrap {\n display: flex;\n justify-content: center;\n align-items: center;\n height:100%;\n width:100%;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 100;\n background: #ffffff42;\n backdrop-filter: blur(1px);\n }\n\n #login-dlg-wrap .login-dlg-loader {\n border: 15px solid #e7e7e7;\n border-top: 15px solid #52dba1;\n border-radius: 50%;\n width: 100px;\n height: 100px;\n animation: spinloader 2s linear infinite;\n }\n\n #login-dlg-wrap .loader-wrap::before {\n content: \"\";\n position: absolute;\n width: 70px;\n height: 70px;\n transform: translate(-50%, -50%);\n z-index: 1;\n border: 15px solid #e7e7e700;\n border-top: 15px solid #52dba1c9;\n border-radius: 50%;\n animation: spinloader .75s linear infinite;\n }\n\n @keyframes spinloader {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "]
1061
+ },] }
1062
+ ];
1063
+ LocalizeLogindlgComponent.ctorParameters = function () { return [
1064
+ { type: api.MessageService },
1065
+ { type: i0.ChangeDetectorRef },
1066
+ { type: dynamicdialog.DynamicDialogRef },
1067
+ { type: dynamicdialog.DynamicDialogConfig },
1068
+ { type: LocalizeTokenService },
1069
+ { type: i1.HttpClient },
1070
+ { type: LocalizeToken }
1071
+ ]; };
1072
+
1073
+ var LocalizeLogindlgService = /** @class */ (function () {
1074
+ function LocalizeLogindlgService(injector) {
1075
+ this.injector = injector;
1076
+ }
1077
+ LocalizeLogindlgService.prototype.openLoginDialog = function (loginConfig, config) {
1078
+ return __awaiter(this, void 0, void 0, function () {
1079
+ var dialogService, dialog;
1080
+ return __generator(this, function (_a) {
1081
+ switch (_a.label) {
1082
+ case 0:
1083
+ config !== null && config !== void 0 ? config : (config = {
1084
+ header: 'Login',
1085
+ height: '650px',
1086
+ style: { 'max-width': '400px', width: '100%', 'height': '650px' },
1087
+ });
1088
+ config.data = Object.assign(Object.assign({}, config.data || {}), { loginConfig: loginConfig });
1089
+ dialogService = this.injector.get(dynamicdialog.DialogService);
1090
+ dialog = dialogService.open(LocalizeLogindlgComponent, config);
1091
+ return [4 /*yield*/, new Promise(function (resolve) { return dialog.onClose.subscribe(function (res) {
1092
+ if (res) {
1093
+ resolve();
1094
+ }
1095
+ }); })];
1096
+ case 1:
1097
+ _a.sent();
1098
+ return [2 /*return*/];
1099
+ }
1100
+ });
1101
+ });
1102
+ };
1103
+ return LocalizeLogindlgService;
1104
+ }());
1105
+ LocalizeLogindlgService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeLogindlgService_Factory() { return new LocalizeLogindlgService(i0__namespace.ɵɵinject(i0__namespace.INJECTOR)); }, token: LocalizeLogindlgService, providedIn: "root" });
1106
+ LocalizeLogindlgService.decorators = [
1107
+ { type: i0.Injectable, args: [{
1108
+ providedIn: 'root'
1109
+ },] }
1110
+ ];
1111
+ LocalizeLogindlgService.ctorParameters = function () { return [
1112
+ { type: i0.Injector }
1113
+ ]; };
1114
+
1115
+ var LocalizeLogindlgModule = /** @class */ (function () {
1116
+ function LocalizeLogindlgModule() {
1117
+ }
1118
+ return LocalizeLogindlgModule;
1119
+ }());
1120
+ LocalizeLogindlgModule.decorators = [
1121
+ { type: i0.NgModule, args: [{
1122
+ declarations: [LocalizeLogindlgComponent],
1123
+ exports: [LocalizeLogindlgComponent],
1124
+ imports: [
1125
+ common.CommonModule,
1126
+ toast.ToastModule,
1127
+ inputtext.InputTextModule,
1128
+ platformBrowser.BrowserModule,
1129
+ forms.FormsModule,
1130
+ button.ButtonModule,
1131
+ ],
1132
+ providers: [LocalizeLogindlgService],
1133
+ schemas: [i0.CUSTOM_ELEMENTS_SCHEMA],
1134
+ },] }
1135
+ ];
1136
+
1137
+ /**
1138
+ * Generated bundle index. Do not edit.
1139
+ */
1140
+
1141
+ exports.LocalizeApiService = LocalizeApiService;
1142
+ exports.LocalizeLogindlgComponent = LocalizeLogindlgComponent;
1143
+ exports.LocalizeLogindlgModule = LocalizeLogindlgModule;
1144
+ exports.LocalizeLogindlgService = LocalizeLogindlgService;
1145
+ exports.LocalizeToken = LocalizeToken;
1146
+ exports.LocalizeTokenModule = LocalizeTokenModule;
1147
+ exports.LocalizeTokenService = LocalizeTokenService;
1148
+ exports.LocalizeTokenStorage = LocalizeTokenStorage;
1149
+ exports.extractMainDomain = extractMainDomain;
1150
+ exports.waitFor = waitFor;
1151
+ exports.waitUntil = waitUntil;
1152
+
1153
+ Object.defineProperty(exports, '__esModule', { value: true });
1154
+
1155
+ }));
1156
+ //# sourceMappingURL=sambath999-localize-token.umd.js.map