@sambath999/localize-token 12.1.2 → 12.1.4

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