@sambath999/localize-token 12.4.11 → 12.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/sambath999-localize-token.umd.js +436 -1067
- package/bundles/sambath999-localize-token.umd.js.map +1 -1
- package/{localize-logindlg/localize-logindlg.component.d.ts → components/localize-token-login-dialog.component.d.ts} +15 -6
- package/esm2015/components/localize-token-login-dialog.component.js +474 -0
- package/esm2015/models/localize-token-models.js +2 -0
- package/esm2015/models/localize-token.module.js +26 -0
- package/esm2015/public-api.js +6 -15
- package/esm2015/sambath999-localize-token.js +1 -1
- package/esm2015/services/localize-token-configure.service.js +32 -0
- package/esm2015/services/localize-token-dialog.service.js +64 -0
- package/fesm2015/sambath999-localize-token.js +93 -856
- package/fesm2015/sambath999-localize-token.js.map +1 -1
- package/{localize-logindlg/localize-logindlg.service.d.ts → models/localize-token-models.d.ts} +0 -9
- package/package.json +2 -2
- package/public-api.d.ts +5 -13
- package/sambath999-localize-token.metadata.json +1 -1
- package/services/localize-token-configure.service.d.ts +9 -0
- package/services/localize-token-dialog.service.d.ts +10 -0
- package/README.md +0 -57
- package/esm2015/localize-api-token/localize-api-token.module.js +0 -21
- package/esm2015/localize-api-token/localize-api-token.service.js +0 -34
- package/esm2015/localize-logindlg/localize-logindlg.component.js +0 -423
- package/esm2015/localize-logindlg/localize-logindlg.module.js +0 -28
- package/esm2015/localize-logindlg/localize-logindlg.service.js +0 -64
- package/esm2015/localize-token/helpers/interfaces.js +0 -19
- package/esm2015/localize-token/helpers/localize.api.assets.js +0 -20
- package/esm2015/localize-token/helpers/loccalize.api.helper.js +0 -267
- package/esm2015/localize-token/localize.api.service.js +0 -242
- package/esm2015/localize-token/localize.token.js +0 -60
- package/esm2015/localize-token/localize.token.module.js +0 -14
- package/esm2015/localize-token/localize.token.service.js +0 -94
- package/esm2015/localize-token/localize.token.storage.js +0 -107
- package/localize-api-token/localize-api-token.module.d.ts +0 -2
- package/localize-api-token/localize-api-token.service.d.ts +0 -12
- package/localize-logindlg/localize-logindlg.module.d.ts +0 -2
- package/localize-token/helpers/interfaces.d.ts +0 -89
- package/localize-token/helpers/localize.api.assets.d.ts +0 -5
- package/localize-token/helpers/loccalize.api.helper.d.ts +0 -32
- package/localize-token/localize.api.service.d.ts +0 -55
- package/localize-token/localize.token.d.ts +0 -55
- package/localize-token/localize.token.service.d.ts +0 -36
- package/localize-token/localize.token.storage.d.ts +0 -61
- /package/{localize-token/localize.token.module.d.ts → models/localize-token.module.d.ts} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@sambath999/localize-token', ['exports', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.sambath999 = global.sambath999 || {}, global.sambath999["localize-token"] = {}), global.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common/http'), require('@angular/core'), require('primeng/api'), require('primeng/dynamicdialog'), require('@angular/platform-browser'), require('@sambath999/localize-api'), require('@angular/common'), require('primeng/toast'), require('primeng/inputtext'), require('primeng/button'), require('@angular/forms')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@sambath999/localize-token', ['exports', '@angular/common/http', '@angular/core', 'primeng/api', 'primeng/dynamicdialog', '@angular/platform-browser', '@sambath999/localize-api', '@angular/common', 'primeng/toast', 'primeng/inputtext', 'primeng/button', '@angular/forms'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.sambath999 = global.sambath999 || {}, global.sambath999["localize-token"] = {}), global.ng.common.http, global.ng.core, global.api, global.dynamicdialog, global.ng.platformBrowser, global.i1, global.ng.common, global.toast, global.inputtext, global.button, global.ng.forms));
|
|
5
|
+
})(this, (function (exports, http, i0, api, dynamicdialog, platformBrowser, i1, common, toast, inputtext, button, forms) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -22,398 +22,386 @@
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
26
25
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
27
|
-
var
|
|
26
|
+
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
LocalizeTokenStorage.prototype.check = function (name) {
|
|
67
|
-
if (typeof document === "undefined")
|
|
68
|
-
return false;
|
|
69
|
-
name = encodeURIComponent(name);
|
|
70
|
-
var regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
|
|
71
|
-
return regexp.test(document.cookie);
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Retrieves a single cookie by it's name
|
|
75
|
-
*
|
|
76
|
-
* @param {string} name Identification of the Cookie
|
|
77
|
-
* @returns The Cookie's value
|
|
78
|
-
*/
|
|
79
|
-
LocalizeTokenStorage.prototype.get = function (name) {
|
|
80
|
-
if (!this.check(name))
|
|
81
|
-
return undefined;
|
|
82
|
-
name = encodeURIComponent(name);
|
|
83
|
-
var regexp = new RegExp('(?:^' + name + '|;\\s*' + name + ')=(.*?)(?:;|$)', 'g');
|
|
84
|
-
var result = regexp.exec(document.cookie);
|
|
85
|
-
return result ? decodeURIComponent(result[1]) : undefined;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Retrieves a a list of all cookie avaiable
|
|
89
|
-
*
|
|
90
|
-
* @returns Object with all Cookies
|
|
91
|
-
*/
|
|
92
|
-
LocalizeTokenStorage.prototype.getAll = function () {
|
|
93
|
-
var e_1, _a;
|
|
94
|
-
var cookies = {};
|
|
95
|
-
if (document.cookie) {
|
|
96
|
-
var split = document.cookie.split(';');
|
|
97
|
-
try {
|
|
98
|
-
for (var split_1 = tslib.__values(split), split_1_1 = split_1.next(); !split_1_1.done; split_1_1 = split_1.next()) {
|
|
99
|
-
var s = split_1_1.value;
|
|
100
|
-
var currCookie = s.split('=');
|
|
101
|
-
currCookie[0] = currCookie[0].trim();
|
|
102
|
-
cookies[decodeURIComponent(currCookie[0])] = decodeURIComponent(currCookie[1]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
106
|
-
finally {
|
|
107
|
-
try {
|
|
108
|
-
if (split_1_1 && !split_1_1.done && (_a = split_1.return)) _a.call(split_1);
|
|
109
|
-
}
|
|
110
|
-
finally { if (e_1) throw e_1.error; }
|
|
111
|
-
}
|
|
28
|
+
/*! *****************************************************************************
|
|
29
|
+
Copyright (c) Microsoft Corporation.
|
|
30
|
+
|
|
31
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
32
|
+
purpose with or without fee is hereby granted.
|
|
33
|
+
|
|
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 */
|
|
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];
|
|
112
65
|
}
|
|
113
|
-
return
|
|
66
|
+
return t;
|
|
114
67
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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]];
|
|
122
79
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
for (var _b = tslib.__values(Object.keys(cookies)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
149
|
-
var cookieName = _c.value;
|
|
150
|
-
this.delete(cookieName, path, domain);
|
|
151
|
-
}
|
|
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 __metadata(metadataKey, metadataValue) {
|
|
96
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
97
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
98
|
+
}
|
|
99
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
100
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
101
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
102
|
+
function fulfilled(value) { try {
|
|
103
|
+
step(generator.next(value));
|
|
152
104
|
}
|
|
153
|
-
catch (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
finally { if (e_2) throw e_2.error; }
|
|
105
|
+
catch (e) {
|
|
106
|
+
reject(e);
|
|
107
|
+
} }
|
|
108
|
+
function rejected(value) { try {
|
|
109
|
+
step(generator["throw"](value));
|
|
159
110
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
function LocalizeToken() {
|
|
166
|
-
}
|
|
167
|
-
return LocalizeToken;
|
|
168
|
-
}());
|
|
169
|
-
LocalizeToken.storage = new LocalizeTokenStorage();
|
|
170
|
-
LocalizeToken.httpHeaders = {
|
|
171
|
-
AUTHORIZATION: 'Authorization',
|
|
172
|
-
X_TENANT: 'X-Tenant',
|
|
173
|
-
X_REFRESH_TOKEN: 'X-RefreshToken',
|
|
174
|
-
CONTENT_TYPE: 'Content-Type',
|
|
175
|
-
X_CLIENT: 'X-Client',
|
|
176
|
-
X_SECRET: 'X-Secret'
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Waits for a specified amount of time.
|
|
180
|
-
* @param milliseconds - The milliseconds to wait.
|
|
181
|
-
* @param when - The condition to wait for. Default is true.
|
|
182
|
-
* @returns - Promise<void>
|
|
183
|
-
*/
|
|
184
|
-
function waitFor(milliseconds, when) {
|
|
185
|
-
if (when === void 0) { when = true; }
|
|
186
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
187
|
-
return tslib.__generator(this, function (_a) {
|
|
188
|
-
switch (_a.label) {
|
|
189
|
-
case 0:
|
|
190
|
-
if (!when)
|
|
191
|
-
return [2 /*return*/];
|
|
192
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, milliseconds); })];
|
|
193
|
-
case 1:
|
|
194
|
-
_a.sent();
|
|
195
|
-
return [2 /*return*/];
|
|
196
|
-
}
|
|
197
|
-
});
|
|
111
|
+
catch (e) {
|
|
112
|
+
reject(e);
|
|
113
|
+
} }
|
|
114
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
115
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
198
116
|
});
|
|
199
117
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
118
|
+
function __generator(thisArg, body) {
|
|
119
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
120
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
121
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
122
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
123
|
+
function step(op) {
|
|
124
|
+
if (f)
|
|
125
|
+
throw new TypeError("Generator is already executing.");
|
|
126
|
+
while (_)
|
|
127
|
+
try {
|
|
128
|
+
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)
|
|
129
|
+
return t;
|
|
130
|
+
if (y = 0, t)
|
|
131
|
+
op = [op[0] & 2, t.value];
|
|
132
|
+
switch (op[0]) {
|
|
133
|
+
case 0:
|
|
134
|
+
case 1:
|
|
135
|
+
t = op;
|
|
136
|
+
break;
|
|
137
|
+
case 4:
|
|
138
|
+
_.label++;
|
|
139
|
+
return { value: op[1], done: false };
|
|
140
|
+
case 5:
|
|
141
|
+
_.label++;
|
|
142
|
+
y = op[1];
|
|
143
|
+
op = [0];
|
|
144
|
+
continue;
|
|
145
|
+
case 7:
|
|
146
|
+
op = _.ops.pop();
|
|
147
|
+
_.trys.pop();
|
|
148
|
+
continue;
|
|
149
|
+
default:
|
|
150
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
151
|
+
_ = 0;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
155
|
+
_.label = op[1];
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
159
|
+
_.label = t[1];
|
|
160
|
+
t = op;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
if (t && _.label < t[2]) {
|
|
164
|
+
_.label = t[2];
|
|
165
|
+
_.ops.push(op);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
if (t[2])
|
|
169
|
+
_.ops.pop();
|
|
170
|
+
_.trys.pop();
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
op = body.call(thisArg, _);
|
|
255
174
|
}
|
|
256
|
-
|
|
257
|
-
|
|
175
|
+
catch (e) {
|
|
176
|
+
op = [6, e];
|
|
177
|
+
y = 0;
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
f = t = 0;
|
|
181
|
+
}
|
|
182
|
+
if (op[0] & 5)
|
|
183
|
+
throw op[1];
|
|
184
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
185
|
+
}
|
|
258
186
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
187
|
+
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
188
|
+
if (k2 === undefined)
|
|
189
|
+
k2 = k;
|
|
190
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
|
191
|
+
}) : (function (o, m, k, k2) {
|
|
192
|
+
if (k2 === undefined)
|
|
193
|
+
k2 = k;
|
|
194
|
+
o[k2] = m[k];
|
|
195
|
+
});
|
|
196
|
+
function __exportStar(m, o) {
|
|
197
|
+
for (var p in m)
|
|
198
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
|
199
|
+
__createBinding(o, m, p);
|
|
200
|
+
}
|
|
201
|
+
function __values(o) {
|
|
202
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
203
|
+
if (m)
|
|
204
|
+
return m.call(o);
|
|
205
|
+
if (o && typeof o.length === "number")
|
|
206
|
+
return {
|
|
207
|
+
next: function () {
|
|
208
|
+
if (o && i >= o.length)
|
|
209
|
+
o = void 0;
|
|
210
|
+
return { value: o && o[i++], done: !o };
|
|
277
211
|
}
|
|
278
212
|
};
|
|
279
|
-
|
|
280
|
-
|
|
213
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
214
|
+
}
|
|
215
|
+
function __read(o, n) {
|
|
216
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
217
|
+
if (!m)
|
|
218
|
+
return o;
|
|
219
|
+
var i = m.call(o), r, ar = [], e;
|
|
220
|
+
try {
|
|
221
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
222
|
+
ar.push(r.value);
|
|
281
223
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
enumerable: false,
|
|
288
|
-
configurable: true
|
|
289
|
-
});
|
|
290
|
-
LocalizeTokenService.prototype.init = function (config) {
|
|
291
|
-
console.log('LocalizeTokenService is initialized.');
|
|
292
|
-
this.configSubject.next(Object.assign(Object.assign({}, this.defaultConfig), config));
|
|
293
|
-
this.isInitialized = true;
|
|
294
|
-
};
|
|
295
|
-
LocalizeTokenService.prototype.ngOnDestroy = function () {
|
|
296
|
-
// this.configSubject.complete();
|
|
297
|
-
// this.isRevokingTokenSubject.complete();
|
|
298
|
-
};
|
|
299
|
-
Object.defineProperty(LocalizeTokenService.prototype, "authToken", {
|
|
300
|
-
get: function () { return this.storageGet(); },
|
|
301
|
-
set: function (value) {
|
|
302
|
-
var _a;
|
|
303
|
-
value
|
|
304
|
-
? this.storageSet(value)
|
|
305
|
-
: LocalizeToken.storage.delete((_a = this.config.authToken) === null || _a === void 0 ? void 0 : _a.name);
|
|
306
|
-
},
|
|
307
|
-
enumerable: false,
|
|
308
|
-
configurable: true
|
|
309
|
-
});
|
|
310
|
-
Object.defineProperty(LocalizeTokenService.prototype, "tenantToken", {
|
|
311
|
-
get: function () { var _a; return LocalizeToken.storage.get(((_a = this.config.tenantToken) === null || _a === void 0 ? void 0 : _a.name) || ''); },
|
|
312
|
-
enumerable: false,
|
|
313
|
-
configurable: true
|
|
314
|
-
});
|
|
315
|
-
Object.defineProperty(LocalizeTokenService.prototype, "refreshToken", {
|
|
316
|
-
get: function () { var _a; return LocalizeToken.storage.get(((_a = this.config.refreshToken) === null || _a === void 0 ? void 0 : _a.name) || ''); },
|
|
317
|
-
enumerable: false,
|
|
318
|
-
configurable: true
|
|
319
|
-
});
|
|
320
|
-
Object.defineProperty(LocalizeTokenService.prototype, "accessToken", {
|
|
321
|
-
get: function () { var _a; return (_a = this.authToken) === null || _a === void 0 ? void 0 : _a.token; },
|
|
322
|
-
set: function (value) {
|
|
323
|
-
value && (this.authToken = { token: value, revoke: false });
|
|
324
|
-
},
|
|
325
|
-
enumerable: false,
|
|
326
|
-
configurable: true
|
|
327
|
-
});
|
|
328
|
-
Object.defineProperty(LocalizeTokenService.prototype, "isRevokingToken", {
|
|
329
|
-
get: function () { return this.isRevokingTokenSubject.value; /* this.authToken?.revoke ?? false */ },
|
|
330
|
-
set: function (value) {
|
|
331
|
-
this.isRevokingTokenSubject.next(value);
|
|
332
|
-
this.authToken && (this.authToken = Object.assign(Object.assign({}, this.authToken), { revoke: value }));
|
|
333
|
-
},
|
|
334
|
-
enumerable: false,
|
|
335
|
-
configurable: true
|
|
336
|
-
});
|
|
337
|
-
Object.defineProperty(LocalizeTokenService.prototype, "clientId", {
|
|
338
|
-
get: function () { var _a; return LocalizeToken.storage.get(((_a = this.config.thirdPartyConfig) === null || _a === void 0 ? void 0 : _a.clientId) || ''); },
|
|
339
|
-
enumerable: false,
|
|
340
|
-
configurable: true
|
|
341
|
-
});
|
|
342
|
-
Object.defineProperty(LocalizeTokenService.prototype, "clientSecret", {
|
|
343
|
-
get: function () { var _a; return LocalizeToken.storage.get(((_a = this.config.thirdPartyConfig) === null || _a === void 0 ? void 0 : _a.clientSecret) || ''); },
|
|
344
|
-
enumerable: false,
|
|
345
|
-
configurable: true
|
|
346
|
-
});
|
|
347
|
-
LocalizeTokenService.prototype.storageGet = function () {
|
|
348
|
-
var _a;
|
|
224
|
+
catch (error) {
|
|
225
|
+
e = { error: error };
|
|
226
|
+
}
|
|
227
|
+
finally {
|
|
349
228
|
try {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return JSON.parse(decoded);
|
|
229
|
+
if (r && !r.done && (m = i["return"]))
|
|
230
|
+
m.call(i);
|
|
353
231
|
}
|
|
354
|
-
|
|
355
|
-
|
|
232
|
+
finally {
|
|
233
|
+
if (e)
|
|
234
|
+
throw e.error;
|
|
356
235
|
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
236
|
+
}
|
|
237
|
+
return ar;
|
|
238
|
+
}
|
|
239
|
+
/** @deprecated */
|
|
240
|
+
function __spread() {
|
|
241
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
242
|
+
ar = ar.concat(__read(arguments[i]));
|
|
243
|
+
return ar;
|
|
244
|
+
}
|
|
245
|
+
/** @deprecated */
|
|
246
|
+
function __spreadArrays() {
|
|
247
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
248
|
+
s += arguments[i].length;
|
|
249
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
250
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
251
|
+
r[k] = a[j];
|
|
252
|
+
return r;
|
|
253
|
+
}
|
|
254
|
+
function __spreadArray(to, from, pack) {
|
|
255
|
+
if (pack || arguments.length === 2)
|
|
256
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
257
|
+
if (ar || !(i in from)) {
|
|
258
|
+
if (!ar)
|
|
259
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
260
|
+
ar[i] = from[i];
|
|
261
|
+
}
|
|
382
262
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
263
|
+
return to.concat(ar || from);
|
|
264
|
+
}
|
|
265
|
+
function __await(v) {
|
|
266
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
267
|
+
}
|
|
268
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
269
|
+
if (!Symbol.asyncIterator)
|
|
270
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
271
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
272
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
273
|
+
function verb(n) { if (g[n])
|
|
274
|
+
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
275
|
+
function resume(n, v) { try {
|
|
276
|
+
step(g[n](v));
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
settle(q[0][3], e);
|
|
280
|
+
} }
|
|
281
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
282
|
+
function fulfill(value) { resume("next", value); }
|
|
283
|
+
function reject(value) { resume("throw", value); }
|
|
284
|
+
function settle(f, v) { if (f(v), q.shift(), q.length)
|
|
285
|
+
resume(q[0][0], q[0][1]); }
|
|
286
|
+
}
|
|
287
|
+
function __asyncDelegator(o) {
|
|
288
|
+
var i, p;
|
|
289
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
290
|
+
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; }
|
|
291
|
+
}
|
|
292
|
+
function __asyncValues(o) {
|
|
293
|
+
if (!Symbol.asyncIterator)
|
|
294
|
+
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
295
|
+
var m = o[Symbol.asyncIterator], i;
|
|
296
|
+
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);
|
|
297
|
+
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); }); }; }
|
|
298
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
|
299
|
+
}
|
|
300
|
+
function __makeTemplateObject(cooked, raw) {
|
|
301
|
+
if (Object.defineProperty) {
|
|
302
|
+
Object.defineProperty(cooked, "raw", { value: raw });
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
cooked.raw = raw;
|
|
306
|
+
}
|
|
307
|
+
return cooked;
|
|
308
|
+
}
|
|
309
|
+
;
|
|
310
|
+
var __setModuleDefault = Object.create ? (function (o, v) {
|
|
311
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
312
|
+
}) : function (o, v) {
|
|
313
|
+
o["default"] = v;
|
|
314
|
+
};
|
|
315
|
+
function __importStar(mod) {
|
|
316
|
+
if (mod && mod.__esModule)
|
|
317
|
+
return mod;
|
|
318
|
+
var result = {};
|
|
319
|
+
if (mod != null)
|
|
320
|
+
for (var k in mod)
|
|
321
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
322
|
+
__createBinding(result, mod, k);
|
|
323
|
+
__setModuleDefault(result, mod);
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
function __importDefault(mod) {
|
|
327
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
328
|
+
}
|
|
329
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
330
|
+
if (kind === "a" && !f)
|
|
331
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
332
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
333
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
334
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
335
|
+
}
|
|
336
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
337
|
+
if (kind === "m")
|
|
338
|
+
throw new TypeError("Private method is not writable");
|
|
339
|
+
if (kind === "a" && !f)
|
|
340
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
341
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
342
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
343
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
344
|
+
}
|
|
390
345
|
|
|
391
|
-
var
|
|
392
|
-
|
|
346
|
+
var ELoginState;
|
|
347
|
+
(function (ELoginState) {
|
|
348
|
+
ELoginState[ELoginState["Requesting"] = 0] = "Requesting";
|
|
349
|
+
ELoginState[ELoginState["Success"] = 1] = "Success";
|
|
350
|
+
ELoginState[ELoginState["Error"] = 2] = "Error";
|
|
351
|
+
})(ELoginState || (ELoginState = {}));
|
|
352
|
+
var LocalizeTokenLoginDialogComponent = /** @class */ (function () {
|
|
353
|
+
function LocalizeTokenLoginDialogComponent(messageService, cdt, dlgRef, dlgConfig, httpClient, sanitizer, injector) {
|
|
393
354
|
var _this = this;
|
|
394
355
|
this.messageService = messageService;
|
|
395
356
|
this.cdt = cdt;
|
|
396
357
|
this.dlgRef = dlgRef;
|
|
397
358
|
this.dlgConfig = dlgConfig;
|
|
398
|
-
this.tokenService = tokenService;
|
|
399
359
|
this.httpClient = httpClient;
|
|
400
360
|
this.sanitizer = sanitizer;
|
|
361
|
+
this.injector = injector;
|
|
401
362
|
this.messageKey = "$login-dlg";
|
|
402
363
|
this.loading = false;
|
|
403
364
|
this.success = false;
|
|
365
|
+
this.loginBroadcastChannel = "bc-localize-login";
|
|
366
|
+
this.sourceId = Date.now() + "-" + Math.random().toString(36).slice(2);
|
|
404
367
|
this.clickLogout = function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); };
|
|
368
|
+
this.tokenService = this.injector.get(i1.LocalizeApiTokenService);
|
|
369
|
+
this.broadcastService = this.injector.get(i1.LocalizeApiBroadcastService);
|
|
370
|
+
this.apiService = this.injector.get(i1.LocalizeApiService);
|
|
405
371
|
this.decodeToken = this.tokenService.decodeRefreshToken;
|
|
406
372
|
this.loginConfig = this.dlgConfig.data.loginConfig;
|
|
407
373
|
this.properties = this.loginConfig.properties;
|
|
374
|
+
this.removeLoginListener = this.broadcastService.listen(this.loginBroadcastChannel, function (payload) {
|
|
375
|
+
var _a;
|
|
376
|
+
if (!payload || payload.sourceId === _this.sourceId) {
|
|
377
|
+
console.warn('Ignoring login state message with invalid payload or from same source', payload);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
switch (payload.state) {
|
|
381
|
+
case ELoginState.Requesting:
|
|
382
|
+
_this.loading = true;
|
|
383
|
+
_this.success = false;
|
|
384
|
+
break;
|
|
385
|
+
case ELoginState.Success:
|
|
386
|
+
_this.apiService.clearRequiredLoginStateAfterLogin();
|
|
387
|
+
_this.loginSuccess();
|
|
388
|
+
break;
|
|
389
|
+
case ELoginState.Error:
|
|
390
|
+
_this.showMessage("error", (_a = payload.message) !== null && _a !== void 0 ? _a : "Login failed");
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
408
394
|
}
|
|
409
|
-
Object.defineProperty(
|
|
395
|
+
Object.defineProperty(LocalizeTokenLoginDialogComponent.prototype, "config", {
|
|
410
396
|
get: function () { return this.tokenService.config; },
|
|
411
397
|
enumerable: false,
|
|
412
398
|
configurable: true
|
|
413
399
|
});
|
|
414
|
-
|
|
400
|
+
LocalizeTokenLoginDialogComponent.prototype.ngOnInit = function () {
|
|
415
401
|
var _this = this;
|
|
416
402
|
this.dlgConfig.closable = false;
|
|
403
|
+
this.dlgConfig.dismissableMask = false;
|
|
404
|
+
this.dlgConfig.modal = true;
|
|
417
405
|
this.logout = this.loginConfig.logoutFunc;
|
|
418
406
|
this.loginUrl = this.loginConfig.loginUrl;
|
|
419
407
|
if (!this.decodeToken) {
|
|
@@ -421,47 +409,71 @@
|
|
|
421
409
|
setTimeout(function () { var _a; return (_a = _this.logout) === null || _a === void 0 ? void 0 : _a.call(_this); }, 2000);
|
|
422
410
|
}
|
|
423
411
|
};
|
|
424
|
-
|
|
412
|
+
LocalizeTokenLoginDialogComponent.prototype.ngAfterViewInit = function () {
|
|
425
413
|
this.cdt.detectChanges();
|
|
426
414
|
};
|
|
427
|
-
|
|
415
|
+
LocalizeTokenLoginDialogComponent.prototype.loginSuccess = function () {
|
|
416
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
417
|
+
return __generator(this, function (_d) {
|
|
418
|
+
switch (_d.label) {
|
|
419
|
+
case 0:
|
|
420
|
+
this.success = true;
|
|
421
|
+
return [4 /*yield*/, i1.waitFor(2000)];
|
|
422
|
+
case 1:
|
|
423
|
+
_d.sent();
|
|
424
|
+
this.dlgRef.close(true);
|
|
425
|
+
return [2 /*return*/];
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
LocalizeTokenLoginDialogComponent.prototype.clickLogin = function () {
|
|
428
431
|
var _a, _b, _c;
|
|
429
|
-
return
|
|
430
|
-
var loginRes, cookieOptions;
|
|
431
|
-
|
|
432
|
-
return tslib.__generator(this, function (_d) {
|
|
432
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
433
|
+
var loginRes, message, cookieOptions;
|
|
434
|
+
return __generator(this, function (_d) {
|
|
433
435
|
switch (_d.label) {
|
|
434
436
|
case 0:
|
|
435
437
|
if (!this.isValidPassword) {
|
|
436
438
|
return [2 /*return*/, this.showMessage("error", "Password is required and must be at least 6 characters")];
|
|
437
439
|
}
|
|
440
|
+
this.publishLoginState(ELoginState.Requesting);
|
|
441
|
+
return [4 /*yield*/, i1.waitFor(300)];
|
|
442
|
+
case 1:
|
|
443
|
+
_d.sent();
|
|
438
444
|
this.loading = true;
|
|
439
445
|
return [4 /*yield*/, this.login()];
|
|
440
|
-
case
|
|
446
|
+
case 2:
|
|
441
447
|
loginRes = _d.sent();
|
|
442
448
|
if (!(loginRes === null || loginRes === void 0 ? void 0 : loginRes.status)) {
|
|
443
|
-
|
|
449
|
+
message = (_a = loginRes === null || loginRes === void 0 ? void 0 : loginRes.message) !== null && _a !== void 0 ? _a : "An error occurred";
|
|
450
|
+
this.publishLoginState(ELoginState.Error, message);
|
|
451
|
+
return [2 /*return*/, this.showMessage("error", message)];
|
|
444
452
|
}
|
|
445
453
|
this.tokenService.accessToken = loginRes.tokens.accessToken;
|
|
446
454
|
cookieOptions = { expires: (_b = this.loginConfig.expire) !== null && _b !== void 0 ? _b : 365 };
|
|
447
|
-
|
|
448
|
-
this.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
_this.dlgConfig.modal = false;
|
|
452
|
-
_this.dlgRef.close(true);
|
|
453
|
-
}, 2000);
|
|
455
|
+
i1.LocalizeApiToken.storage.set(((_c = this.config.refreshToken) === null || _c === void 0 ? void 0 : _c.name) || '', loginRes.tokens.refreshToken, cookieOptions);
|
|
456
|
+
this.apiService.clearRequiredLoginStateAfterLogin();
|
|
457
|
+
this.publishLoginState(ELoginState.Success);
|
|
458
|
+
this.loginSuccess();
|
|
454
459
|
return [2 /*return*/];
|
|
455
460
|
}
|
|
456
461
|
});
|
|
457
462
|
});
|
|
458
463
|
};
|
|
459
|
-
|
|
464
|
+
LocalizeTokenLoginDialogComponent.prototype.publishLoginState = function (state, message) {
|
|
465
|
+
this.broadcastService.publish(this.loginBroadcastChannel, {
|
|
466
|
+
state: state,
|
|
467
|
+
sourceId: this.sourceId,
|
|
468
|
+
message: message,
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
LocalizeTokenLoginDialogComponent.prototype.login = function () {
|
|
460
472
|
var _a, _b, _c;
|
|
461
|
-
return
|
|
473
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
462
474
|
var e_1;
|
|
463
475
|
var _this = this;
|
|
464
|
-
return
|
|
476
|
+
return __generator(this, function (_d) {
|
|
465
477
|
switch (_d.label) {
|
|
466
478
|
case 0:
|
|
467
479
|
if (!((_a = this.loginUrl) === null || _a === void 0 ? void 0 : _a.trim().length)) {
|
|
@@ -486,15 +498,15 @@
|
|
|
486
498
|
});
|
|
487
499
|
});
|
|
488
500
|
};
|
|
489
|
-
|
|
501
|
+
LocalizeTokenLoginDialogComponent.prototype.getHeaders = function () {
|
|
490
502
|
var _d;
|
|
491
503
|
var _a, _b;
|
|
492
504
|
return _d = {},
|
|
493
|
-
_d[
|
|
494
|
-
_d[
|
|
505
|
+
_d[i1.LocalizeApiToken.httpHeaders.X_REFRESH_TOKEN] = (_a = this.tokenService.refreshToken) !== null && _a !== void 0 ? _a : "",
|
|
506
|
+
_d[i1.LocalizeApiToken.httpHeaders.X_TENANT] = (_b = this.tokenService.tenantToken) !== null && _b !== void 0 ? _b : "",
|
|
495
507
|
_d;
|
|
496
508
|
};
|
|
497
|
-
Object.defineProperty(
|
|
509
|
+
Object.defineProperty(LocalizeTokenLoginDialogComponent.prototype, "isValidPassword", {
|
|
498
510
|
get: function () {
|
|
499
511
|
this.loading = false;
|
|
500
512
|
return this.properties.passwordValidator
|
|
@@ -504,11 +516,11 @@
|
|
|
504
516
|
enumerable: false,
|
|
505
517
|
configurable: true
|
|
506
518
|
});
|
|
507
|
-
|
|
519
|
+
LocalizeTokenLoginDialogComponent.prototype.showMessage = function (severity, summary) {
|
|
508
520
|
this.messageService.add({ key: this.messageKey, severity: severity, summary: summary });
|
|
509
521
|
this.loading = false;
|
|
510
522
|
};
|
|
511
|
-
Object.defineProperty(
|
|
523
|
+
Object.defineProperty(LocalizeTokenLoginDialogComponent.prototype, "sanitizedTitle", {
|
|
512
524
|
get: function () {
|
|
513
525
|
var _a;
|
|
514
526
|
return this.sanitizer.bypassSecurityTrustHtml((_a = this.properties.title) !== null && _a !== void 0 ? _a : '');
|
|
@@ -516,9 +528,13 @@
|
|
|
516
528
|
enumerable: false,
|
|
517
529
|
configurable: true
|
|
518
530
|
});
|
|
519
|
-
|
|
531
|
+
LocalizeTokenLoginDialogComponent.prototype.ngOnDestroy = function () {
|
|
532
|
+
var _a;
|
|
533
|
+
(_a = this.removeLoginListener) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
534
|
+
};
|
|
535
|
+
return LocalizeTokenLoginDialogComponent;
|
|
520
536
|
}());
|
|
521
|
-
|
|
537
|
+
LocalizeTokenLoginDialogComponent.decorators = [
|
|
522
538
|
{ type: i0.Component, args: [{
|
|
523
539
|
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\" style=\"background: url('{{properties.logoImage}}') no-repeat\"></div>\n <h3 *ngIf=\"!success\" [innerHTML]=\"sanitizedTitle\"></h3>\n <h3 *ngIf=\"success\" style=\"color:green !important;\">{{properties.loginSuccessMessage}}</h3>\n </div>\n <div id=\"login-dlg-content\">\n <ng-container *ngIf=\"!success\">\n <div *ngIf=\"loading\" class=\"loader-wrap\">\n <div class=\"login-dlg-loader\"></div>\n </div>\n <div class=\"login-dlg-elm\">\n <div class=\"p-inputgroup\">\n <span class=\"p-inputgroup-addon\">\n <i class=\"material-icons-round\">person</i>\n </span>\n <input disabled pInputText type=\"text\" placeholder=\"{{properties.username?.placeHolder}}\" [value]=\"decodeToken?.email\" />\n </div>\n </div>\n \n <div class=\"login-dlg-elm\">\n <div class=\"p-inputgroup\">\n <span class=\"p-inputgroup-addon\">\n <i class=\"material-icons-round\">lock</i>\n </span>\n <input [disabled]=\"loading\" (keydown.enter)=\"clickLogin()\" pInputText type=\"password\" \n placeholder=\"{{properties.password?.placeHolder}}\" [(ngModel)]=\"password\"\n autofocus />\n </div>\n </div>\n <div class=\"login-dlg-elm\">\n <button style=\"width: 100%;\" pButton type=\"button\" label=\"{{properties.loginButton?.placeHolder}}\" (click)=\"clickLogin()\"\n [disabled]=\"!password || loading\"></button>\n </div>\n \n <div class=\"login-dlg-elm login-dlg-suggest\" style=\"display:flex;align-items: center;user-select: none;\">\n <span>{{properties.logoutButton?.message}}</span>\n <button class=\"p-button-text\" pButton type=\"button\" label=\"{{properties.logoutButton?.placeHolder}}\" \n (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>",
|
|
524
540
|
selector: "app-localize-logindlg",
|
|
@@ -527,31 +543,31 @@
|
|
|
527
543
|
styles: ["\n #login-dlg-wrap {\n width: 100%;\n max-width: 400px;\n margin: 0 auto;\n padding: 30px;\n height: 100%;\n }\n \n .login-dlg-elm {\n margin-top: 1rem;\n }\n\n .login-dlg-elm.login-dlg-suggest {\n display: flex ;\n align-items: center;\n user-select: none;\n border-bottom: solid 1px #ddd;\n border-radius: 5px;\n padding: 5px 10px;\n background: #f9f9f9;\n box-shadow: 1px 5px 10px -12px #000;\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: 55px;\n width: 55px;\n /* background: url(\"/assets/images/logo-300px.png\") no-repeat; */\n background-size: contain !important;\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 #login-dlg-content *{\n font-size: .9rem;\n /* font-family: 'Lexend', 'Roboto', sans-serif, 'material-icons-round'; */\n }\n \n #login-dlg-content .p-inputgroup .p-inputgroup-addon * {\n font-size: 1rem;\n }\n \n #login-dlg-content .p-inputgroup input {\n height: 45px;\n border-radius: 0 15px 15px 0;\n }\n \n #login-dlg-content button {\n height: 45px;\n border-radius: 15px;\n }\n \n /*check animation block*/\n \n .check-animation-wrap {\n top: 0;\n left: 0;\n position: absolute;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: calc(100% - 200px);\n min-height: 400px;\n }\n \n .check-main-container {\n width: 100%;\n height: 100vh;\n display: flex;\n flex-flow: column;\n justify-content: center;\n align-items: center;\n }\n \n .check-container {\n width: 6.25rem;\n height: 7.5rem;\n display: flex;\n flex-flow: column;\n align-items: center;\n justify-content: space-between;\n }\n \n .check-container .check-background {\n width: 100%;\n height: calc(100% - 1.25rem);\n background: linear-gradient(to bottom right, #5de593, #41d67c);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n transform: scale(0.84);\n border-radius: 50%;\n animation: animateContainer 0.75s ease-out forwards 0.75s;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n }\n \n .check-container .check-background svg {\n width: 65%;\n transform: translateY(0.25rem);\n stroke-dasharray: 80;\n stroke-dashoffset: 80;\n animation: animateCheck 0.35s forwards 1.25s ease-out;\n min-width: auto !important;\n }\n \n .check-container .check-shadow {\n bottom: calc(-15% - 5px);\n left: 0;\n border-radius: 50%;\n background: radial-gradient(closest-side, rgba(73, 218, 131, 1), transparent);\n animation: animateShadow 0.75s ease-out forwards 0.75s;\n }\n \n @keyframes animateContainer {\n 0% {\n opacity: 0;\n transform: scale(0);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n }\n \n 25% {\n opacity: 1;\n transform: scale(0.9);\n box-shadow: 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n }\n \n 43.75% {\n transform: scale(1.15);\n box-shadow: 0px 0px 0px 43.334px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 65px rgba(255, 255, 255, 0.25) inset;\n }\n \n 62.5% {\n transform: scale(1);\n box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 21.667px rgba(255, 255, 255, 0.25) inset;\n }\n \n 81.25% {\n box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;\n }\n \n 100% {\n opacity: 1;\n box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset, 0px 0px 0px 0px rgba(255, 255, 255, 0.25) inset;\n }\n }\n \n @keyframes animateCheck {\n from {\n stroke-dashoffset: 80;\n }\n \n to {\n stroke-dashoffset: 0;\n }\n }\n \n @keyframes animateShadow {\n 0% {\n opacity: 0;\n width: 100%;\n height: 15%;\n }\n \n 25% {\n opacity: 0.25;\n }\n \n 43.75% {\n width: 40%;\n height: 7%;\n opacity: 0.35;\n }\n \n 100% {\n width: 85%;\n height: 15%;\n opacity: 0.25;\n }\n }\n #login-dlg-wrap .loader-wrap {\n display: flex;\n justify-content: center;\n align-items: center;\n height:100%;\n width:100%;\n position: absolute;\n top: 0;\n left: 0;\n z-index: 100;\n background: #ffffff42;\n backdrop-filter: blur(1px);\n }\n\n #login-dlg-wrap .login-dlg-loader {\n border: 15px solid #e7e7e7;\n border-top: 15px solid #52dba1;\n border-radius: 50%;\n width: 100px;\n height: 100px;\n animation: spinloader 2s linear infinite;\n }\n\n #login-dlg-wrap .loader-wrap::before {\n content: \"\";\n position: absolute;\n width: 70px;\n height: 70px;\n transform: translate(-50%, -50%);\n z-index: 1;\n border: 15px solid #e7e7e700;\n border-top: 15px solid #52dba1c9;\n border-radius: 50%;\n animation: spinloader .75s linear infinite;\n }\n\n @keyframes spinloader {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "]
|
|
528
544
|
},] }
|
|
529
545
|
];
|
|
530
|
-
|
|
546
|
+
LocalizeTokenLoginDialogComponent.ctorParameters = function () { return [
|
|
531
547
|
{ type: api.MessageService },
|
|
532
548
|
{ type: i0.ChangeDetectorRef },
|
|
533
549
|
{ type: dynamicdialog.DynamicDialogRef },
|
|
534
550
|
{ type: dynamicdialog.DynamicDialogConfig },
|
|
535
|
-
{ type:
|
|
536
|
-
{ type:
|
|
537
|
-
{ type:
|
|
551
|
+
{ type: http.HttpClient },
|
|
552
|
+
{ type: platformBrowser.DomSanitizer },
|
|
553
|
+
{ type: i0.Injector }
|
|
538
554
|
]; };
|
|
539
555
|
|
|
540
|
-
var
|
|
541
|
-
function
|
|
556
|
+
var LocalizeTokenDialogService = /** @class */ (function () {
|
|
557
|
+
function LocalizeTokenDialogService(injector) {
|
|
542
558
|
this.injector = injector;
|
|
543
559
|
}
|
|
544
|
-
|
|
545
|
-
return
|
|
560
|
+
LocalizeTokenDialogService.prototype.openLoginDialog = function (loginConfig, config) {
|
|
561
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
546
562
|
var dialogService, dialog;
|
|
547
|
-
return
|
|
563
|
+
return __generator(this, function (_b) {
|
|
548
564
|
switch (_b.label) {
|
|
549
565
|
case 0:
|
|
550
566
|
config = this.intercepDialogConfig(config);
|
|
551
567
|
this.initConfig(loginConfig);
|
|
552
568
|
config.data = Object.assign(Object.assign({}, (config.data || {})), { loginConfig: loginConfig });
|
|
553
569
|
dialogService = this.injector.get(dynamicdialog.DialogService);
|
|
554
|
-
dialog = dialogService.open(
|
|
570
|
+
dialog = dialogService.open(LocalizeTokenLoginDialogComponent, config);
|
|
555
571
|
return [4 /*yield*/, new Promise(function (resolve) { return dialog.onClose.subscribe(function (res) {
|
|
556
572
|
if (res) {
|
|
557
573
|
resolve();
|
|
@@ -564,7 +580,7 @@
|
|
|
564
580
|
});
|
|
565
581
|
});
|
|
566
582
|
};
|
|
567
|
-
|
|
583
|
+
LocalizeTokenDialogService.prototype.intercepDialogConfig = function (config) {
|
|
568
584
|
config !== null && config !== void 0 ? config : (config = {
|
|
569
585
|
header: 'Login',
|
|
570
586
|
style: { 'max-width': '400px', width: '100%', 'height': '650px' },
|
|
@@ -578,7 +594,7 @@
|
|
|
578
594
|
config.style = Object.assign(Object.assign({}, config.style), { 'border-radius': '20px' });
|
|
579
595
|
return config;
|
|
580
596
|
};
|
|
581
|
-
|
|
597
|
+
LocalizeTokenDialogService.prototype.initConfig = function (loginConfig) {
|
|
582
598
|
var _a;
|
|
583
599
|
loginConfig !== null && loginConfig !== void 0 ? loginConfig : (loginConfig = {});
|
|
584
600
|
(_a = loginConfig.properties) !== null && _a !== void 0 ? _a : (loginConfig.properties = {
|
|
@@ -594,723 +610,76 @@
|
|
|
594
610
|
}
|
|
595
611
|
});
|
|
596
612
|
};
|
|
597
|
-
return
|
|
613
|
+
return LocalizeTokenDialogService;
|
|
598
614
|
}());
|
|
599
|
-
|
|
600
|
-
|
|
615
|
+
LocalizeTokenDialogService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeTokenDialogService_Factory() { return new LocalizeTokenDialogService(i0__namespace.ɵɵinject(i0__namespace.INJECTOR)); }, token: LocalizeTokenDialogService, providedIn: "root" });
|
|
616
|
+
LocalizeTokenDialogService.decorators = [
|
|
601
617
|
{ type: i0.Injectable, args: [{
|
|
602
618
|
providedIn: 'root'
|
|
603
619
|
},] }
|
|
604
620
|
];
|
|
605
|
-
|
|
621
|
+
LocalizeTokenDialogService.ctorParameters = function () { return [
|
|
606
622
|
{ type: i0.Injector }
|
|
607
623
|
]; };
|
|
608
624
|
|
|
609
|
-
var
|
|
610
|
-
function
|
|
625
|
+
var LocalizeTokenModule = /** @class */ (function () {
|
|
626
|
+
function LocalizeTokenModule() {
|
|
611
627
|
}
|
|
612
|
-
return
|
|
628
|
+
return LocalizeTokenModule;
|
|
613
629
|
}());
|
|
614
|
-
|
|
630
|
+
LocalizeTokenModule.decorators = [
|
|
615
631
|
{ type: i0.NgModule, args: [{
|
|
616
|
-
declarations: [
|
|
617
|
-
exports: [
|
|
632
|
+
declarations: [LocalizeTokenLoginDialogComponent],
|
|
633
|
+
exports: [LocalizeTokenLoginDialogComponent],
|
|
618
634
|
imports: [
|
|
619
635
|
common.CommonModule,
|
|
620
636
|
toast.ToastModule,
|
|
621
637
|
inputtext.InputTextModule,
|
|
622
|
-
platformBrowser.BrowserModule,
|
|
623
638
|
forms.FormsModule,
|
|
624
639
|
button.ButtonModule,
|
|
625
640
|
],
|
|
626
|
-
providers: [
|
|
641
|
+
providers: [LocalizeTokenDialogService],
|
|
627
642
|
schemas: [i0.CUSTOM_ELEMENTS_SCHEMA],
|
|
628
643
|
},] }
|
|
629
644
|
];
|
|
630
645
|
|
|
631
|
-
var
|
|
632
|
-
|
|
633
|
-
noConnection: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <svg id=\"lze-no-connection\" data-name=\"Layer 2\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 77.29 70.98\">\n <defs>\n <style> .cls-1 { fill: #fff; } .cls-2, .cls-3 { fill: #e30613; } .cls-3 { stroke: #e30613; stroke-miterlimit: 10; stroke-width: .25px; } </style>\n </defs>\n <g id=\"Layer_3\" data-name=\"Layer 3\">\n <g>\n <path class=\"cls-1\" d=\"m73.29,35c-1.2,0-2.33-.53-3.09-1.46-.48-.57-11.23-13.2-31.55-13.2s-31.11,12.66-31.56,13.2c-1.4,1.71-3.92,1.95-5.63.55-1.71-1.4-1.95-3.92-.55-5.63.54-.66,13.47-16.12,37.74-16.12s37.2,15.46,37.74,16.12c1.4,1.71,1.15,4.23-.56,5.62-.71.58-1.61.9-2.53.9Z\"/>\n <path class=\"cls-1\" d=\"m63.96,45.66c-1.19,0-2.32-.53-3.08-1.44-5.79-6.05-13.86-9.39-22.24-9.21-8.38-.18-16.45,3.16-22.24,9.22-1.46,1.65-3.99,1.81-5.64.35-1.57-1.39-1.8-3.77-.52-5.43,7.32-7.89,17.64-12.29,28.4-12.12,10.76-.17,21.08,4.24,28.4,12.12,1.4,1.71,1.15,4.23-.56,5.62-.71.58-1.6.9-2.53.9Z\"/>\n <path class=\"cls-1\" d=\"m53.3,56.32c-1.24,0-2.41-.57-3.16-1.55-5.73-6.35-15.52-6.85-21.87-1.13-.4.36-.77.73-1.13,1.13-1.36,1.73-3.88,2.03-5.61.67-1.71-1.34-2.03-3.8-.73-5.54,8.39-9.85,23.18-11.04,33.03-2.65.95.81,1.84,1.69,2.65,2.65,1.34,1.75,1,4.26-.75,5.6-.7.53-1.55.82-2.43.82Z\"/>\n </g>\n <path class=\"cls-2\" d=\"m47.21,9.45l-4.06,41.36c-.64,5.42-8.39,5.39-9.01,0,0,0-4.06-41.36-4.06-41.36-.46-4.73,2.99-8.94,7.72-9.4,5.33-.58,9.97,4.09,9.4,9.4h0Z\"/>\n <circle class=\"cls-3\" cx=\"38.64\" cy=\"64.79\" r=\"6.07\"/>\n </g>\n </svg>"
|
|
634
|
-
}
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* Http method options
|
|
639
|
-
*/
|
|
640
|
-
exports.EMethod = void 0;
|
|
641
|
-
(function (EMethod) {
|
|
642
|
-
EMethod["POST"] = "post";
|
|
643
|
-
EMethod["GET"] = "get";
|
|
644
|
-
EMethod["PUT"] = "put";
|
|
645
|
-
EMethod["DELETE"] = "delete";
|
|
646
|
-
EMethod["PATCH"] = "patch";
|
|
647
|
-
})(exports.EMethod || (exports.EMethod = {}));
|
|
648
|
-
// export interface INormalizedError {
|
|
649
|
-
// error: any;
|
|
650
|
-
// code: string;
|
|
651
|
-
// message: string;
|
|
652
|
-
// details?: any;
|
|
653
|
-
// status: number;
|
|
654
|
-
// }
|
|
655
|
-
|
|
656
|
-
var LocalizeApiHelper = /** @class */ (function () {
|
|
657
|
-
function LocalizeApiHelper() {
|
|
658
|
-
this.defaultRetryOptions = {
|
|
659
|
-
connectionError: {
|
|
660
|
-
message: 'Connection error occurred. Please wait',
|
|
661
|
-
blockScreen: true,
|
|
662
|
-
blockScreenZIndex: 10000
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
LocalizeApiHelper.prototype.performRetry = function (options) {
|
|
667
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
668
|
-
var attempts, lastError, consoleCount, styleElement, result, error_1;
|
|
669
|
-
return tslib.__generator(this, function (_f) {
|
|
670
|
-
switch (_f.label) {
|
|
671
|
-
case 0:
|
|
672
|
-
attempts = 0;
|
|
673
|
-
consoleCount = 0;
|
|
674
|
-
// Merge default retry options with provided options
|
|
675
|
-
options = Object.assign(Object.assign({}, this.defaultRetryOptions), options);
|
|
676
|
-
_f.label = 1;
|
|
677
|
-
case 1:
|
|
678
|
-
if (!(attempts < options.maxRetries())) return [3 /*break*/, 10];
|
|
679
|
-
_f.label = 2;
|
|
680
|
-
case 2:
|
|
681
|
-
_f.trys.push([2, 4, , 9]);
|
|
682
|
-
return [4 /*yield*/, options.callback()];
|
|
683
|
-
case 3:
|
|
684
|
-
result = _f.sent();
|
|
685
|
-
this.removeBlocker(styleElement);
|
|
686
|
-
return [2 /*return*/, result];
|
|
687
|
-
case 4:
|
|
688
|
-
error_1 = _f.sent();
|
|
689
|
-
lastError = error_1;
|
|
690
|
-
if (consoleCount >= 7) {
|
|
691
|
-
console.clear();
|
|
692
|
-
consoleCount = 0;
|
|
693
|
-
}
|
|
694
|
-
if (options.retryUnless && !options.retryUnless(error_1))
|
|
695
|
-
throw error_1; // If the error should not be retried, rethrow it
|
|
696
|
-
return [4 /*yield*/, this.onConnectionError(options, error_1)];
|
|
697
|
-
case 5:
|
|
698
|
-
// Handle connection error
|
|
699
|
-
styleElement = _f.sent();
|
|
700
|
-
if (!options.onError) return [3 /*break*/, 7];
|
|
701
|
-
return [4 /*yield*/, this.invokeHook(options.onError.bind(this, error_1))];
|
|
702
|
-
case 6:
|
|
703
|
-
_f.sent();
|
|
704
|
-
_f.label = 7;
|
|
705
|
-
case 7:
|
|
706
|
-
if (attempts >= options.maxRetries() - 1)
|
|
707
|
-
throw error_1;
|
|
708
|
-
attempts++;
|
|
709
|
-
consoleCount++;
|
|
710
|
-
console.warn("Attempt " + attempts + " failed. Retrying...", error_1);
|
|
711
|
-
return [4 /*yield*/, waitFor(options.delay)];
|
|
712
|
-
case 8:
|
|
713
|
-
_f.sent();
|
|
714
|
-
return [3 /*break*/, 9];
|
|
715
|
-
case 9: return [3 /*break*/, 1];
|
|
716
|
-
case 10:
|
|
717
|
-
console.warn("Failed after " + options.maxRetries() + " attempts");
|
|
718
|
-
throw lastError;
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
});
|
|
722
|
-
};
|
|
723
|
-
LocalizeApiHelper.prototype.performRequestWithRetry = function (options, config, performRequest) {
|
|
724
|
-
var _a, _b, _c, _d;
|
|
725
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
726
|
-
var retryUnless;
|
|
727
|
-
return tslib.__generator(this, function (_f) {
|
|
728
|
-
switch (_f.label) {
|
|
729
|
-
case 0:
|
|
730
|
-
retryUnless = ((_a = config.retryOptions) === null || _a === void 0 ? void 0 : _a.retryFunction)
|
|
731
|
-
|| this.isConnectionError;
|
|
732
|
-
return [4 /*yield*/, this.performRetry({
|
|
733
|
-
connectionError: (_b = config.retryOptions) === null || _b === void 0 ? void 0 : _b.onConnectionError,
|
|
734
|
-
maxRetries: function () { var _a, _b; return (_b = (_a = config.retryOptions) === null || _a === void 0 ? void 0 : _a.maxRetries) !== null && _b !== void 0 ? _b : 1000; },
|
|
735
|
-
delay: (_d = (_c = config.retryOptions) === null || _c === void 0 ? void 0 : _c.delay) !== null && _d !== void 0 ? _d : 500,
|
|
736
|
-
callback: function () { return performRequest(options); },
|
|
737
|
-
retryUnless: retryUnless,
|
|
738
|
-
})];
|
|
739
|
-
case 1: return [2 /*return*/, _f.sent()];
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
});
|
|
743
|
-
};
|
|
744
|
-
LocalizeApiHelper.prototype.buildUrl = function (baseUrl, path) {
|
|
745
|
-
var normalizedUrl = "" + baseUrl.trim().replace(/\/?$/, '/') + path.trim().replace(/^\//, '');
|
|
746
|
-
return normalizedUrl.endsWith('/')
|
|
747
|
-
? normalizedUrl.slice(0, -1)
|
|
748
|
-
: normalizedUrl;
|
|
749
|
-
};
|
|
750
|
-
LocalizeApiHelper.prototype.invokeHook = function (callback) {
|
|
751
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
752
|
-
var result;
|
|
753
|
-
return tslib.__generator(this, function (_f) {
|
|
754
|
-
switch (_f.label) {
|
|
755
|
-
case 0:
|
|
756
|
-
if (!callback)
|
|
757
|
-
return [2 /*return*/];
|
|
758
|
-
result = callback();
|
|
759
|
-
if (!(result instanceof Promise)) return [3 /*break*/, 2];
|
|
760
|
-
return [4 /*yield*/, result];
|
|
761
|
-
case 1:
|
|
762
|
-
_f.sent();
|
|
763
|
-
_f.label = 2;
|
|
764
|
-
case 2: return [2 /*return*/];
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
});
|
|
768
|
-
};
|
|
769
|
-
LocalizeApiHelper.prototype.createRequest = function (instance, method, url, body, options, onInvalidResponseBody) {
|
|
770
|
-
var request$ = instance.client.request(method, url, Object.assign(Object.assign({}, options), { body: body })).pipe(rxjs.takeUntil(instance.destroy$()), rxjs.map(function (body) { return extractJsonFromResponse(body, onInvalidResponseBody); }), rxjs.catchError(function (error) {
|
|
771
|
-
// Convert to a non-observable error to handle in the promise
|
|
772
|
-
return rxjs.throwError(function () { return error; });
|
|
773
|
-
}));
|
|
774
|
-
return request$;
|
|
775
|
-
};
|
|
776
|
-
LocalizeApiHelper.prototype.defaultRetryFunction = function (error) {
|
|
777
|
-
// Don't retry for other errors (like 400, 401, 403, etc.)
|
|
778
|
-
if (!this.isConnectionError(error))
|
|
779
|
-
throw error;
|
|
780
|
-
return true;
|
|
781
|
-
};
|
|
782
|
-
LocalizeApiHelper.prototype.isConnectionError = function (error) {
|
|
783
|
-
var isNetworkError = error.status === 0;
|
|
784
|
-
var isServerError = error.status >= 1000 && error.status < 600;
|
|
785
|
-
return isNetworkError || isServerError;
|
|
786
|
-
};
|
|
787
|
-
LocalizeApiHelper.prototype.onConnectionError = function (options, error) {
|
|
788
|
-
var _a;
|
|
789
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
790
|
-
var styleElement;
|
|
791
|
-
return tslib.__generator(this, function (_f) {
|
|
792
|
-
switch (_f.label) {
|
|
793
|
-
case 0:
|
|
794
|
-
if (!options.connectionError)
|
|
795
|
-
return [2 /*return*/];
|
|
796
|
-
if (!this.isConnectionError(error)) return [3 /*break*/, 2];
|
|
797
|
-
styleElement = this.screenBlocker(options, error, true);
|
|
798
|
-
return [4 /*yield*/, this.invokeHook((_a = options.connectionError.callback) === null || _a === void 0 ? void 0 : _a.bind(this, error))];
|
|
799
|
-
case 1:
|
|
800
|
-
_f.sent();
|
|
801
|
-
return [2 /*return*/, styleElement];
|
|
802
|
-
case 2:
|
|
803
|
-
this.screenBlocker(options, error, false);
|
|
804
|
-
styleElement === null || styleElement === void 0 ? void 0 : styleElement.remove();
|
|
805
|
-
_f.label = 3;
|
|
806
|
-
case 3: return [2 /*return*/];
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
});
|
|
810
|
-
};
|
|
811
|
-
LocalizeApiHelper.prototype.screenBlocker = function (optons, error, add) {
|
|
812
|
-
if (add === void 0) { add = true; }
|
|
813
|
-
var _a, _b, _c, _d, _e;
|
|
814
|
-
if (!((_a = optons.connectionError) === null || _a === void 0 ? void 0 : _a.blockScreen))
|
|
815
|
-
return;
|
|
816
|
-
var message = ((_b = optons.connectionError) === null || _b === void 0 ? void 0 : _b.message)
|
|
817
|
-
|| 'Connection error occurred. Please wait';
|
|
818
|
-
var errorMessage = ((_c = error === null || error === void 0 ? void 0 : error.error) === null || _c === void 0 ? void 0 : _c.message) || 'An error occurred';
|
|
819
|
-
var suggestinMessage = ((_d = optons.connectionError) === null || _d === void 0 ? void 0 : _d.suggestionMessage)
|
|
820
|
-
|| 'Please check your internet connection or the server status.';
|
|
821
|
-
var zIndex = ((_e = optons.connectionError) === null || _e === void 0 ? void 0 : _e.blockScreenZIndex) || 10000;
|
|
822
|
-
var body = document.body;
|
|
823
|
-
var blcokerHtml = "\n <div class=\"lze-blocker\">\n " + LOCALIZE_API_ASSETS.network.noConnection + "\n <div class=\"lze-blocker__message\">\n " + message + "\n <span class=\"lze-blocker__dotting\">\n <span class=\"lze-blocker__dot\"></span>\n <span class=\"lze-blocker__dot\"></span>\n <span class=\"lze-blocker__dot\"></span>\n </span>\n </div>\n <div class=\"lze-blocker__error\">" + errorMessage + "</div>\n <div class=\"lze-blocker__error_suggestion\">" + suggestinMessage + "</div>\n </div>\n ";
|
|
824
|
-
var style = "\n div.lze-blocker {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.85) !important;\n z-index: " + zIndex + ";\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n color: #fff !important;\n font-family: Arial, sans-serif;\n text-align: center;\n padding: 20px;\n box-sizing: border-box;\n overflow: hidden;\n user-select: none;\n }\n\n svg#lze-no-connection {\n width: 75px;\n height: 75px;\n margin-bottom: 20px;\n }\n \n div.lze-blocker__message {\n color: #fff !important;\n font-size: 18px !important;\n margin-bottom: 10px;\n }\n \n .lze-blocker__dotting {\n display: inline-block;\n vertical-align: middle;\n }\n span.lze-blocker__dot {\n display: inline-block;\n width: 7px;\n height: 7px;\n background-color: #ffffff !important;\n border-radius: 50%;\n margin-left: 3px;\n opacity: 0.3;\n animation: dotting 1s infinite;\n }\n .lze-blocker__dot:nth-child(1) {\n animation-delay: 0s;\n opacity: 1;\n }\n .lze-blocker__dot:nth-child(2) {\n animation-delay: 0.2s;\n }\n .lze-blocker__dot:nth-child(3) {\n animation-delay: 0.4s;\n }\n\n @keyframes dotting {\n 0%, 80%, 100% { opacity: 0.3; }\n 40% { opacity: 1; }\n }\n\n div.lze-blocker__error {\n color: #f00;\n font-size: 14px !important;\n margin-bottom: 10px;\n text-shadow: 0 0 1px #ff5f5f !important;\n }\n\n div.lze-blocker__error_suggestion {\n color: #ccc !important;\n font-size: 14px !important;\n margin-top: 10px;\n }\n \n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ";
|
|
825
|
-
var styleElement = document.createElement('style');
|
|
826
|
-
if (add) {
|
|
827
|
-
if (!document.querySelector('.lze-blocker')) {
|
|
828
|
-
styleElement.innerHTML = style;
|
|
829
|
-
document.head.appendChild(styleElement);
|
|
830
|
-
body.insertAdjacentHTML('beforeend', blcokerHtml);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
else {
|
|
834
|
-
this.removeBlocker(styleElement);
|
|
835
|
-
}
|
|
836
|
-
return styleElement;
|
|
837
|
-
};
|
|
838
|
-
LocalizeApiHelper.prototype.removeBlocker = function (styleElement) {
|
|
839
|
-
var blocker = document.querySelector('.lze-blocker');
|
|
840
|
-
blocker === null || blocker === void 0 ? void 0 : blocker.remove();
|
|
841
|
-
styleElement === null || styleElement === void 0 ? void 0 : styleElement.remove();
|
|
842
|
-
};
|
|
843
|
-
return LocalizeApiHelper;
|
|
844
|
-
}());
|
|
845
|
-
function extractJsonFromResponse(body, onError) {
|
|
846
|
-
// If already an object, just return
|
|
847
|
-
if (typeof body === 'object' && body !== null)
|
|
848
|
-
return body;
|
|
849
|
-
// If it's a string, try to extract JSON portion
|
|
850
|
-
if (typeof body === 'string') {
|
|
851
|
-
var firstBrace = body.indexOf('{');
|
|
852
|
-
if (firstBrace !== -1) {
|
|
853
|
-
var jsonString = body.substring(firstBrace);
|
|
854
|
-
try {
|
|
855
|
-
return JSON.parse(jsonString);
|
|
856
|
-
}
|
|
857
|
-
catch (e) {
|
|
858
|
-
// If parsing fails, return original string
|
|
859
|
-
onError === null || onError === void 0 ? void 0 : onError(body);
|
|
860
|
-
return body;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
return body;
|
|
865
|
-
}
|
|
866
|
-
var ApiHelper = new LocalizeApiHelper();
|
|
867
|
-
|
|
868
|
-
var SCHEMES = LocalizeToken.httpHeaders;
|
|
869
|
-
var LocalizeApiService = /** @class */ (function () {
|
|
870
|
-
function LocalizeApiService(httpClient, localizeTokenService) {
|
|
871
|
-
var _this = this;
|
|
872
|
-
this.httpClient = httpClient;
|
|
873
|
-
this.localizeTokenService = localizeTokenService;
|
|
874
|
-
this.destroy$ = new rxjs.Subject();
|
|
875
|
-
this.configSubject = new rxjs.BehaviorSubject({});
|
|
876
|
-
this.isRequestingSubject = new rxjs.BehaviorSubject(false);
|
|
877
|
-
this.isResolvingStartupSubject = new rxjs.BehaviorSubject(false);
|
|
878
|
-
this.defaultConfig = {
|
|
879
|
-
waitEachRequest: { milliseconds: 0 },
|
|
880
|
-
enableRequestCancellation: true,
|
|
881
|
-
retryOptions: {
|
|
882
|
-
maxRetries: 1000,
|
|
883
|
-
delay: 1000,
|
|
884
|
-
retryFunction: ApiHelper.defaultRetryFunction.bind(this),
|
|
885
|
-
},
|
|
886
|
-
};
|
|
887
|
-
this.apiOptions = {
|
|
888
|
-
method: exports.EMethod.GET,
|
|
889
|
-
requestBody: null,
|
|
890
|
-
};
|
|
891
|
-
/**
|
|
892
|
-
* A higher-order function that returns a curried function for making API requests.
|
|
893
|
-
*
|
|
894
|
-
* @param baseUrl - The base URL of the API.
|
|
895
|
-
* @returns A curried function that can be used to make API requests.
|
|
896
|
-
*/
|
|
897
|
-
this.func = function (baseUrl) { return function (path, method, reqBody, reqHeaders) {
|
|
898
|
-
if (method === void 0) { method = exports.EMethod.GET; }
|
|
899
|
-
if (reqBody === void 0) { reqBody = null; }
|
|
900
|
-
return _this.request(baseUrl, path, method, reqBody, reqHeaders);
|
|
901
|
-
}; };
|
|
902
|
-
}
|
|
903
|
-
Object.defineProperty(LocalizeApiService.prototype, "isResolvingStartup", {
|
|
904
|
-
get: function () { return this.isResolvingStartupSubject.value; },
|
|
905
|
-
enumerable: false,
|
|
906
|
-
configurable: true
|
|
907
|
-
});
|
|
908
|
-
Object.defineProperty(LocalizeApiService.prototype, "needTenant", {
|
|
909
|
-
get: function () { return this.localizeTokenService.config.tenantToken !== undefined; },
|
|
910
|
-
enumerable: false,
|
|
911
|
-
configurable: true
|
|
912
|
-
});
|
|
913
|
-
Object.defineProperty(LocalizeApiService.prototype, "isRequesting", {
|
|
914
|
-
get: function () { return this.isRequestingSubject.value; },
|
|
915
|
-
enumerable: false,
|
|
916
|
-
configurable: true
|
|
917
|
-
});
|
|
918
|
-
Object.defineProperty(LocalizeApiService.prototype, "isRevokingToken", {
|
|
919
|
-
get: function () { return this.localizeTokenService.isRevokingToken; },
|
|
920
|
-
set: function (value) { this.localizeTokenService.isRevokingToken = value; },
|
|
921
|
-
enumerable: false,
|
|
922
|
-
configurable: true
|
|
923
|
-
});
|
|
924
|
-
Object.defineProperty(LocalizeApiService.prototype, "accessToken", {
|
|
925
|
-
get: function () { return this.localizeTokenService.accessToken; },
|
|
926
|
-
set: function (value) { this.localizeTokenService.accessToken = value; },
|
|
927
|
-
enumerable: false,
|
|
928
|
-
configurable: true
|
|
929
|
-
});
|
|
930
|
-
Object.defineProperty(LocalizeApiService.prototype, "refreshToken", {
|
|
931
|
-
get: function () { return this.localizeTokenService.refreshToken; },
|
|
932
|
-
enumerable: false,
|
|
933
|
-
configurable: true
|
|
934
|
-
});
|
|
935
|
-
Object.defineProperty(LocalizeApiService.prototype, "tenantToken", {
|
|
936
|
-
get: function () { return this.localizeTokenService.tenantToken; },
|
|
937
|
-
enumerable: false,
|
|
938
|
-
configurable: true
|
|
939
|
-
});
|
|
940
|
-
Object.defineProperty(LocalizeApiService.prototype, "thirdPartyConfig", {
|
|
941
|
-
get: function () { var _a; return (_a = this.localizeTokenService.config) === null || _a === void 0 ? void 0 : _a.thirdPartyConfig; },
|
|
942
|
-
enumerable: false,
|
|
943
|
-
configurable: true
|
|
944
|
-
});
|
|
945
|
-
Object.defineProperty(LocalizeApiService.prototype, "config", {
|
|
946
|
-
get: function () {
|
|
947
|
-
this.validateConfig();
|
|
948
|
-
return this.configSubject.value;
|
|
949
|
-
},
|
|
950
|
-
enumerable: false,
|
|
951
|
-
configurable: true
|
|
952
|
-
});
|
|
953
|
-
/**
|
|
954
|
-
* Initialize the API service.
|
|
955
|
-
* @param apiConfigs - The API configurations.
|
|
956
|
-
*/
|
|
957
|
-
LocalizeApiService.prototype.init = function (apiConfigs) {
|
|
958
|
-
console.log('LocalizeApiService is initialized.');
|
|
959
|
-
this.configSubject.next(Object.assign(Object.assign({}, this.defaultConfig), apiConfigs));
|
|
960
|
-
};
|
|
961
|
-
LocalizeApiService.prototype.cancelPendingRequests = function () {
|
|
962
|
-
this.config.enableRequestCancellation
|
|
963
|
-
&& this.destroy$.next();
|
|
964
|
-
};
|
|
965
|
-
LocalizeApiService.prototype.ngOnDestroy = function () {
|
|
966
|
-
this.destroy$.next();
|
|
967
|
-
this.destroy$.complete();
|
|
968
|
-
};
|
|
969
|
-
LocalizeApiService.prototype.request = function (baseUrl, path, method, reqBody, reqHeaders) {
|
|
970
|
-
if (method === void 0) { method = exports.EMethod.GET; }
|
|
971
|
-
if (reqBody === void 0) { reqBody = null; }
|
|
972
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
973
|
-
var apiOptions, error_1;
|
|
974
|
-
var _this = this;
|
|
975
|
-
return tslib.__generator(this, function (_e) {
|
|
976
|
-
switch (_e.label) {
|
|
977
|
-
case 0: return [4 /*yield*/, waitUntil(function () { return !_this.isResolvingStartup; }, 500)];
|
|
978
|
-
case 1:
|
|
979
|
-
_e.sent();
|
|
980
|
-
return [4 /*yield*/, ApiHelper.invokeHook(this.config.onPrepareRequest)];
|
|
981
|
-
case 2:
|
|
982
|
-
_e.sent();
|
|
983
|
-
apiOptions = this.buildApiOptions(baseUrl, path, method, reqBody, reqHeaders);
|
|
984
|
-
_e.label = 3;
|
|
985
|
-
case 3:
|
|
986
|
-
_e.trys.push([3, 6, , 8]);
|
|
987
|
-
return [4 /*yield*/, this.toWaitForPreviousRequest()];
|
|
988
|
-
case 4:
|
|
989
|
-
_e.sent();
|
|
990
|
-
return [4 /*yield*/, ApiHelper.performRequestWithRetry(apiOptions, this.config, this.performRequest.bind(this))];
|
|
991
|
-
case 5: return [2 /*return*/, _e.sent()];
|
|
992
|
-
case 6:
|
|
993
|
-
error_1 = _e.sent();
|
|
994
|
-
return [4 /*yield*/, this.handleOnRequestError(error_1, apiOptions)];
|
|
995
|
-
case 7: return [2 /*return*/, _e.sent()];
|
|
996
|
-
case 8: return [2 /*return*/];
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
};
|
|
1001
|
-
LocalizeApiService.prototype.handleOnRequestError = function (error, options) {
|
|
1002
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1003
|
-
var _this = this;
|
|
1004
|
-
return tslib.__generator(this, function (_e) {
|
|
1005
|
-
switch (_e.label) {
|
|
1006
|
-
case 0:
|
|
1007
|
-
if (error.status !== 401)
|
|
1008
|
-
throw error;
|
|
1009
|
-
return [4 /*yield*/, waitUntil(function () { return !_this.isResolvingStartup; }, 50)];
|
|
1010
|
-
case 1:
|
|
1011
|
-
_e.sent();
|
|
1012
|
-
return [4 /*yield*/, ApiHelper.performRetry({
|
|
1013
|
-
maxRetries: function () { return 1000; },
|
|
1014
|
-
delay: 10,
|
|
1015
|
-
retryUnless: function (error) { return error.status === 401 || ApiHelper.isConnectionError(error); },
|
|
1016
|
-
callback: function () { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
1017
|
-
return tslib.__generator(this, function (_e) {
|
|
1018
|
-
switch (_e.label) {
|
|
1019
|
-
case 0:
|
|
1020
|
-
// Handle third party API unauthorized error when request
|
|
1021
|
-
this.handleThirdPartyAuthError(error, options.requestUrl);
|
|
1022
|
-
// Only handle 401 Unauthorized errors
|
|
1023
|
-
return [4 /*yield*/, this.revokeToken()];
|
|
1024
|
-
case 1:
|
|
1025
|
-
// Only handle 401 Unauthorized errors
|
|
1026
|
-
_e.sent();
|
|
1027
|
-
return [4 /*yield*/, this.performRequest(options)];
|
|
1028
|
-
case 2:
|
|
1029
|
-
// Retry the request with the new access token
|
|
1030
|
-
return [2 /*return*/, _e.sent()];
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
}); }
|
|
1034
|
-
})];
|
|
1035
|
-
case 2: return [2 /*return*/, _e.sent()];
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
});
|
|
1039
|
-
};
|
|
1040
|
-
LocalizeApiService.prototype.handleThirdPartyAuthError = function (error, requestUrl) {
|
|
1041
|
-
var _a, _b, _c;
|
|
1042
|
-
if (!((_a = this.thirdPartyConfig) === null || _a === void 0 ? void 0 : _a.isThirdPartyMode))
|
|
1043
|
-
return;
|
|
1044
|
-
if (error.status === 401) {
|
|
1045
|
-
if (this.thirdPartyConfig.lastUnauthorizedUrl === requestUrl) {
|
|
1046
|
-
this.thirdPartyConfig.lastUnauthorizedUrl = "";
|
|
1047
|
-
throw (_c = (_b = this.config).onException) === null || _c === void 0 ? void 0 : _c.call(_b, Object.assign(Object.assign({}, error), { status: 405, message: "Unauthorized request url " + requestUrl + ". Please contact administrator." }));
|
|
1048
|
-
}
|
|
1049
|
-
this.thirdPartyConfig.lastUnauthorizedUrl = requestUrl;
|
|
1050
|
-
}
|
|
1051
|
-
else {
|
|
1052
|
-
this.thirdPartyConfig.lastUnauthorizedUrl = "";
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
LocalizeApiService.prototype.performRequest = function (options) {
|
|
1056
|
-
var _a;
|
|
1057
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1058
|
-
var buildOptions, request$, response;
|
|
1059
|
-
var _this = this;
|
|
1060
|
-
return tslib.__generator(this, function (_e) {
|
|
1061
|
-
switch (_e.label) {
|
|
1062
|
-
case 0:
|
|
1063
|
-
buildOptions = { headers: this.buildHeaderOptions(options) };
|
|
1064
|
-
request$ = ApiHelper.createRequest({
|
|
1065
|
-
client: this.httpClient,
|
|
1066
|
-
destroy$: function () { return _this.destroy$; }
|
|
1067
|
-
}, options.method, options.requestUrl, options.requestBody, buildOptions, (_a = this.config.onResponseBodyInvalid) === null || _a === void 0 ? void 0 : _a.bind(this));
|
|
1068
|
-
// Set the isRequesting state to true before making the request
|
|
1069
|
-
this.isRequestingSubject.next(true);
|
|
1070
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) { return request$.subscribe({ next: resolve, error: reject }); })];
|
|
1071
|
-
case 1:
|
|
1072
|
-
response = _e.sent();
|
|
1073
|
-
// Reset the isRequesting state after the request completes
|
|
1074
|
-
this.isRequestingSubject.next(false);
|
|
1075
|
-
return [2 /*return*/, response];
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
});
|
|
1079
|
-
};
|
|
1080
|
-
LocalizeApiService.prototype.revokeToken = function () {
|
|
1081
|
-
var _a, _b;
|
|
1082
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1083
|
-
var defaultApiOptions, thirdParyApiOptions, apiOptions, revokeToken, error_2;
|
|
1084
|
-
return tslib.__generator(this, function (_e) {
|
|
1085
|
-
switch (_e.label) {
|
|
1086
|
-
case 0:
|
|
1087
|
-
_e.trys.push([0, 4, 6, 7]);
|
|
1088
|
-
return [4 /*yield*/, this.interceptRevokeToken()];
|
|
1089
|
-
case 1:
|
|
1090
|
-
if (_e.sent())
|
|
1091
|
-
return [2 /*return*/];
|
|
1092
|
-
this.isRevokingToken = true;
|
|
1093
|
-
defaultApiOptions = Object.assign(Object.assign({}, this.buildApiOptions(((_a = this.localizeTokenService.config.refreshToken) === null || _a === void 0 ? void 0 : _a.requestUrl) || '')), { refreshToken: true });
|
|
1094
|
-
thirdParyApiOptions = this.buildThirdPartyApiOption(defaultApiOptions);
|
|
1095
|
-
apiOptions = ((_b = this.thirdPartyConfig) === null || _b === void 0 ? void 0 : _b.isThirdPartyMode) ? thirdParyApiOptions : defaultApiOptions;
|
|
1096
|
-
return [4 /*yield*/, ApiHelper.performRequestWithRetry(apiOptions, this.config, this.performRequest.bind(this))];
|
|
1097
|
-
case 2:
|
|
1098
|
-
revokeToken = _e.sent();
|
|
1099
|
-
return [4 /*yield*/, this.handleOnTokenRevoked(revokeToken)];
|
|
1100
|
-
case 3:
|
|
1101
|
-
_e.sent();
|
|
1102
|
-
return [3 /*break*/, 7];
|
|
1103
|
-
case 4:
|
|
1104
|
-
error_2 = _e.sent();
|
|
1105
|
-
// Handle the error, log it
|
|
1106
|
-
return [4 /*yield*/, ApiHelper.invokeHook(this.config.onAutoLogout)];
|
|
1107
|
-
case 5:
|
|
1108
|
-
// Handle the error, log it
|
|
1109
|
-
_e.sent();
|
|
1110
|
-
throw error_2;
|
|
1111
|
-
case 6:
|
|
1112
|
-
// Reset the revoking token state
|
|
1113
|
-
this.isRevokingToken = false;
|
|
1114
|
-
return [7 /*endfinally*/];
|
|
1115
|
-
case 7: return [2 /*return*/];
|
|
1116
|
-
}
|
|
1117
|
-
});
|
|
1118
|
-
});
|
|
1119
|
-
};
|
|
1120
|
-
LocalizeApiService.prototype.buildThirdPartyApiOption = function (apiOptions) {
|
|
1121
|
-
var _e;
|
|
1122
|
-
var _a, _b, _c;
|
|
1123
|
-
return Object.assign(Object.assign({}, apiOptions), { requestUrl: ((_a = this.thirdPartyConfig) === null || _a === void 0 ? void 0 : _a.refreshToken.requestUrl) || '', method: ((_b = this.thirdPartyConfig) === null || _b === void 0 ? void 0 : _b.refreshToken.method) || exports.EMethod.GET, requestBody: ((_c = this.thirdPartyConfig) === null || _c === void 0 ? void 0 : _c.refreshToken.body) || {}, headers: Object.assign(Object.assign({}, apiOptions.headers), (_e = {}, _e[SCHEMES.X_SECRET] = "" + this.localizeTokenService.clientSecret, _e)) });
|
|
1124
|
-
};
|
|
1125
|
-
/** default http request options */
|
|
1126
|
-
LocalizeApiService.prototype.buildHeaderOptions = function (options) {
|
|
1127
|
-
var _e, _f, _g, _h, _j;
|
|
1128
|
-
var _a;
|
|
1129
|
-
var headers = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.refreshToken && (_e = {}, _e[SCHEMES.X_REFRESH_TOKEN] = "" + this.refreshToken, _e))), (!options.isFormData && (_f = {}, _f[SCHEMES.CONTENT_TYPE] = 'application/json', _f))), (_g = {}, _g[SCHEMES.AUTHORIZATION] = "Bearer " + this.accessToken, _g)), (this.needTenant && (_h = {}, _h[SCHEMES.X_TENANT] = "" + this.tenantToken, _h))), (((_a = this.thirdPartyConfig) === null || _a === void 0 ? void 0 : _a.isThirdPartyMode) && (_j = {}, _j[SCHEMES.X_CLIENT] = "" + this.localizeTokenService.clientId, _j)));
|
|
1130
|
-
return new i1.HttpHeaders(Object.assign(Object.assign({}, headers), options.headers));
|
|
1131
|
-
};
|
|
1132
|
-
LocalizeApiService.prototype.buildApiOptions = function (baseUrl, path, method, requestBody, headers) {
|
|
1133
|
-
if (path === void 0) { path = ''; }
|
|
1134
|
-
if (method === void 0) { method = exports.EMethod.GET; }
|
|
1135
|
-
if (requestBody === void 0) { requestBody = null; }
|
|
1136
|
-
var requestUrl = ApiHelper.buildUrl(baseUrl, path);
|
|
1137
|
-
var isFormData = requestBody && requestBody instanceof FormData;
|
|
1138
|
-
return Object.assign(Object.assign({}, this.apiOptions), { headers: headers, method: method, requestUrl: requestUrl, requestBody: requestBody, isFormData: isFormData });
|
|
1139
|
-
};
|
|
1140
|
-
LocalizeApiService.prototype.toWaitForPreviousRequest = function () {
|
|
1141
|
-
var _a;
|
|
1142
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1143
|
-
var waitMilliseconds;
|
|
1144
|
-
var _this = this;
|
|
1145
|
-
return tslib.__generator(this, function (_e) {
|
|
1146
|
-
switch (_e.label) {
|
|
1147
|
-
case 0:
|
|
1148
|
-
if (!this.isRevokingToken) return [3 /*break*/, 2];
|
|
1149
|
-
return [4 /*yield*/, waitUntil(function () { return !_this.isRevokingToken; })];
|
|
1150
|
-
case 1:
|
|
1151
|
-
_e.sent();
|
|
1152
|
-
_e.label = 2;
|
|
1153
|
-
case 2:
|
|
1154
|
-
waitMilliseconds = (_a = this.config.waitEachRequest) === null || _a === void 0 ? void 0 : _a.milliseconds;
|
|
1155
|
-
if (!(waitMilliseconds && this.isRequesting)) return [3 /*break*/, 4];
|
|
1156
|
-
// console.warn(`Request throttling: Another request is in progress. Waiting for ${waitMilliseconds}ms.`);
|
|
1157
|
-
return [4 /*yield*/, waitFor(waitMilliseconds, this.isRequesting)];
|
|
1158
|
-
case 3:
|
|
1159
|
-
// console.warn(`Request throttling: Another request is in progress. Waiting for ${waitMilliseconds}ms.`);
|
|
1160
|
-
_e.sent();
|
|
1161
|
-
_e.label = 4;
|
|
1162
|
-
case 4: return [2 /*return*/];
|
|
1163
|
-
}
|
|
1164
|
-
});
|
|
1165
|
-
});
|
|
1166
|
-
};
|
|
1167
|
-
LocalizeApiService.prototype.handleOnTokenRevoked = function (response) {
|
|
1168
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1169
|
-
return tslib.__generator(this, function (_e) {
|
|
1170
|
-
switch (_e.label) {
|
|
1171
|
-
case 0:
|
|
1172
|
-
if (!((response === null || response === void 0 ? void 0 : response.status) || (response === null || response === void 0 ? void 0 : response.token))) return [3 /*break*/, 1];
|
|
1173
|
-
// If the response is successful, update the access token
|
|
1174
|
-
this.accessToken = response.message || response.token; // response.token for third party revoke
|
|
1175
|
-
return [3 /*break*/, 3];
|
|
1176
|
-
case 1:
|
|
1177
|
-
// If the response indicates an error, invoke the onRevokeUnauthorized hook
|
|
1178
|
-
console.warn('Token revocation failed, refresh token is expired.', response.message);
|
|
1179
|
-
return [4 /*yield*/, ApiHelper.invokeHook(this.config.onRevokeUnauthorized)];
|
|
1180
|
-
case 2:
|
|
1181
|
-
_e.sent();
|
|
1182
|
-
_e.label = 3;
|
|
1183
|
-
case 3: return [2 /*return*/];
|
|
1184
|
-
}
|
|
1185
|
-
});
|
|
1186
|
-
});
|
|
1187
|
-
};
|
|
1188
|
-
LocalizeApiService.prototype.interceptRevokeToken = function () {
|
|
1189
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1190
|
-
var _this = this;
|
|
1191
|
-
return tslib.__generator(this, function (_e) {
|
|
1192
|
-
switch (_e.label) {
|
|
1193
|
-
case 0:
|
|
1194
|
-
if (!this.isRevokingToken) return [3 /*break*/, 2];
|
|
1195
|
-
console.warn('Token is already being revoked. Waiting for the current operation to complete...');
|
|
1196
|
-
return [4 /*yield*/, waitUntil(function () { return !_this.isRevokingToken; })];
|
|
1197
|
-
case 1:
|
|
1198
|
-
_e.sent();
|
|
1199
|
-
return [2 /*return*/, true];
|
|
1200
|
-
case 2:
|
|
1201
|
-
if (!this.refreshToken) {
|
|
1202
|
-
// await ApiHelper.invokeHook(this.apiConfigs.onAutoLogout);
|
|
1203
|
-
throw new Error('Refresh token is missing. Please login again.');
|
|
1204
|
-
}
|
|
1205
|
-
return [2 /*return*/, false];
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
});
|
|
1209
|
-
};
|
|
1210
|
-
LocalizeApiService.prototype.validateConfig = function () {
|
|
1211
|
-
var _a, _b, _c, _d;
|
|
1212
|
-
if (this.localizeTokenService.config.requiredTenant
|
|
1213
|
-
&& !((_b = (_a = this.localizeTokenService.config.tenantToken) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.trim().length)) {
|
|
1214
|
-
throw Error('Tenant token is required but tenantTokenName is not configured');
|
|
1215
|
-
}
|
|
1216
|
-
if (!((_d = (_c = this.localizeTokenService.config.refreshToken) === null || _c === void 0 ? void 0 : _c.requestUrl) === null || _d === void 0 ? void 0 : _d.trim().length)) {
|
|
1217
|
-
throw Error('Revoke token URL is not configured - token refresh will not work');
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
return LocalizeApiService;
|
|
1221
|
-
}());
|
|
1222
|
-
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" });
|
|
1223
|
-
LocalizeApiService.decorators = [
|
|
1224
|
-
{ type: i0.Injectable, args: [{
|
|
1225
|
-
providedIn: 'root'
|
|
1226
|
-
},] }
|
|
1227
|
-
];
|
|
1228
|
-
LocalizeApiService.ctorParameters = function () { return [
|
|
1229
|
-
{ type: i1.HttpClient },
|
|
1230
|
-
{ type: LocalizeTokenService }
|
|
1231
|
-
]; };
|
|
1232
|
-
|
|
1233
|
-
var LocalizeTokenModule = /** @class */ (function () {
|
|
1234
|
-
function LocalizeTokenModule() {
|
|
1235
|
-
}
|
|
1236
|
-
return LocalizeTokenModule;
|
|
1237
|
-
}());
|
|
1238
|
-
LocalizeTokenModule.decorators = [
|
|
1239
|
-
{ type: i0.NgModule, args: [{
|
|
1240
|
-
providers: [
|
|
1241
|
-
LocalizeTokenService,
|
|
1242
|
-
LocalizeApiService
|
|
1243
|
-
]
|
|
1244
|
-
},] }
|
|
1245
|
-
];
|
|
1246
|
-
|
|
1247
|
-
var LocalizeApiTokenService = /** @class */ (function () {
|
|
1248
|
-
function LocalizeApiTokenService(tokenService, apiService, loginDialogService) {
|
|
646
|
+
var LocalizeTokenConfigureService = /** @class */ (function () {
|
|
647
|
+
function LocalizeTokenConfigureService(tokenService, apiService, loginDialogService) {
|
|
1249
648
|
this.api = apiService;
|
|
1250
649
|
this.token = tokenService;
|
|
1251
650
|
this.loginDialog = loginDialogService;
|
|
1252
651
|
}
|
|
1253
|
-
|
|
1254
|
-
// Initialize the
|
|
652
|
+
LocalizeTokenConfigureService.prototype.initialize = function (tokenConfig, apiConfig) {
|
|
653
|
+
// Initialize the LocalizeApiTokenService with the provided token configuration
|
|
1255
654
|
this.token.init(tokenConfig);
|
|
1256
655
|
// Initialize the LocalizeApiService with the provided API configuration
|
|
1257
656
|
this.api.init(apiConfig);
|
|
1258
|
-
console.log('
|
|
657
|
+
console.log('LocalizeTokenConfigureService initialized with token and API configurations.');
|
|
1259
658
|
};
|
|
1260
|
-
return
|
|
659
|
+
return LocalizeTokenConfigureService;
|
|
1261
660
|
}());
|
|
1262
|
-
|
|
1263
|
-
|
|
661
|
+
LocalizeTokenConfigureService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalizeTokenConfigureService_Factory() { return new LocalizeTokenConfigureService(i0__namespace.ɵɵinject(i1__namespace.LocalizeApiTokenService), i0__namespace.ɵɵinject(i1__namespace.LocalizeApiService), i0__namespace.ɵɵinject(LocalizeTokenDialogService)); }, token: LocalizeTokenConfigureService, providedIn: "root" });
|
|
662
|
+
LocalizeTokenConfigureService.decorators = [
|
|
1264
663
|
{ type: i0.Injectable, args: [{
|
|
1265
664
|
providedIn: 'root'
|
|
1266
665
|
},] }
|
|
1267
666
|
];
|
|
1268
|
-
|
|
1269
|
-
{ type:
|
|
1270
|
-
{ type: LocalizeApiService },
|
|
1271
|
-
{ type:
|
|
667
|
+
LocalizeTokenConfigureService.ctorParameters = function () { return [
|
|
668
|
+
{ type: i1.LocalizeApiTokenService },
|
|
669
|
+
{ type: i1.LocalizeApiService },
|
|
670
|
+
{ type: LocalizeTokenDialogService }
|
|
1272
671
|
]; };
|
|
1273
672
|
|
|
1274
|
-
var LocalizeApiTokenModule = /** @class */ (function () {
|
|
1275
|
-
function LocalizeApiTokenModule() {
|
|
1276
|
-
}
|
|
1277
|
-
return LocalizeApiTokenModule;
|
|
1278
|
-
}());
|
|
1279
|
-
LocalizeApiTokenModule.decorators = [
|
|
1280
|
-
{ type: i0.NgModule, args: [{
|
|
1281
|
-
declarations: [],
|
|
1282
|
-
imports: [
|
|
1283
|
-
common.CommonModule,
|
|
1284
|
-
LocalizeTokenModule,
|
|
1285
|
-
LocalizeLogindlgModule
|
|
1286
|
-
],
|
|
1287
|
-
providers: [
|
|
1288
|
-
LocalizeApiTokenService
|
|
1289
|
-
]
|
|
1290
|
-
},] }
|
|
1291
|
-
];
|
|
1292
|
-
|
|
1293
673
|
//#region login dialog
|
|
1294
674
|
|
|
1295
675
|
/**
|
|
1296
676
|
* Generated bundle index. Do not edit.
|
|
1297
677
|
*/
|
|
1298
678
|
|
|
1299
|
-
exports.
|
|
1300
|
-
exports.
|
|
1301
|
-
exports.
|
|
1302
|
-
exports.LocalizeApiTokenModule = LocalizeApiTokenModule;
|
|
1303
|
-
exports.LocalizeApiTokenService = LocalizeApiTokenService;
|
|
1304
|
-
exports.LocalizeLogindlgComponent = LocalizeLogindlgComponent;
|
|
1305
|
-
exports.LocalizeLogindlgModule = LocalizeLogindlgModule;
|
|
1306
|
-
exports.LocalizeLogindlgService = LocalizeLogindlgService;
|
|
1307
|
-
exports.LocalizeToken = LocalizeToken;
|
|
679
|
+
exports.LocalizeTokenConfigureService = LocalizeTokenConfigureService;
|
|
680
|
+
exports.LocalizeTokenDialogService = LocalizeTokenDialogService;
|
|
681
|
+
exports.LocalizeTokenLoginDialogComponent = LocalizeTokenLoginDialogComponent;
|
|
1308
682
|
exports.LocalizeTokenModule = LocalizeTokenModule;
|
|
1309
|
-
exports.LocalizeTokenService = LocalizeTokenService;
|
|
1310
|
-
exports.LocalizeTokenStorage = LocalizeTokenStorage;
|
|
1311
|
-
exports.extractMainDomain = extractMainDomain;
|
|
1312
|
-
exports.waitFor = waitFor;
|
|
1313
|
-
exports.waitUntil = waitUntil;
|
|
1314
683
|
|
|
1315
684
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1316
685
|
|