1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@angular/forms'), require('@nebular/theme'), require('rxjs'), require('rxjs/operators'), require('tslib'), require('@angular/common/http')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', '@angular/router', '@angular/forms', '@nebular/theme', 'rxjs', 'rxjs/operators', 'tslib', '@angular/common/http'], factory) :
|
4 | (factory((global.nb = global.nb || {}, global.nb.auth = global.nb.auth || {}),global.ng.core,global.ng.common,global.ng.router,global.ng.forms,global.nb.theme,global.Rx,global.Rx.operators,global.tslib,global.ng.common.http));
|
5 | }(this, (function (exports,_angular_core,_angular_common,_angular_router,_angular_forms,_nebular_theme,rxjs,rxjs_operators,tslib,_angular_common_http) { 'use strict';
|
6 |
|
7 | var socialLinks = [];
|
8 | var defaultAuthOptions = {
|
9 | strategies: [],
|
10 | forms: {
|
11 | login: {
|
12 | redirectDelay: 500,
|
13 | strategy: 'email',
|
14 | rememberMe: true,
|
15 | showMessages: {
|
16 | success: true,
|
17 | error: true,
|
18 | },
|
19 | socialLinks: socialLinks,
|
20 | },
|
21 | register: {
|
22 | redirectDelay: 500,
|
23 | strategy: 'email',
|
24 | showMessages: {
|
25 | success: true,
|
26 | error: true,
|
27 | },
|
28 | terms: true,
|
29 | socialLinks: socialLinks,
|
30 | },
|
31 | requestPassword: {
|
32 | redirectDelay: 500,
|
33 | strategy: 'email',
|
34 | showMessages: {
|
35 | success: true,
|
36 | error: true,
|
37 | },
|
38 | socialLinks: socialLinks,
|
39 | },
|
40 | resetPassword: {
|
41 | redirectDelay: 500,
|
42 | strategy: 'email',
|
43 | showMessages: {
|
44 | success: true,
|
45 | error: true,
|
46 | },
|
47 | socialLinks: socialLinks,
|
48 | },
|
49 | logout: {
|
50 | redirectDelay: 500,
|
51 | strategy: 'email',
|
52 | },
|
53 | validation: {
|
54 | password: {
|
55 | required: true,
|
56 | minLength: 4,
|
57 | maxLength: 50,
|
58 | },
|
59 | email: {
|
60 | required: true,
|
61 | },
|
62 | fullName: {
|
63 | required: false,
|
64 | minLength: 4,
|
65 | maxLength: 50,
|
66 | },
|
67 | },
|
68 | },
|
69 | };
|
70 | var NB_AUTH_OPTIONS = new _angular_core.InjectionToken('Nebular Auth Options');
|
71 | var NB_AUTH_USER_OPTIONS = new _angular_core.InjectionToken('Nebular User Auth Options');
|
72 | var NB_AUTH_STRATEGIES = new _angular_core.InjectionToken('Nebular Auth Strategies');
|
73 | var NB_AUTH_TOKENS = new _angular_core.InjectionToken('Nebular Auth Tokens');
|
74 | var NB_AUTH_INTERCEPTOR_HEADER = new _angular_core.InjectionToken('Nebular Simple Interceptor Header');
|
75 | var NB_AUTH_TOKEN_INTERCEPTOR_FILTER = new _angular_core.InjectionToken('Nebular Interceptor Filter');
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | var deepExtend = function () {
|
87 | var objects = [];
|
88 | for (var _i = 0; _i < arguments.length; _i++) {
|
89 | objects[_i] = arguments[_i];
|
90 | }
|
91 | if (arguments.length < 1 || typeof arguments[0] !== 'object') {
|
92 | return false;
|
93 | }
|
94 | if (arguments.length < 2) {
|
95 | return arguments[0];
|
96 | }
|
97 | var target = arguments[0];
|
98 |
|
99 | var args = Array.prototype.slice.call(arguments, 1);
|
100 | var val, src;
|
101 | args.forEach(function (obj) {
|
102 |
|
103 | if (typeof obj !== 'object' || Array.isArray(obj)) {
|
104 | return;
|
105 | }
|
106 | Object.keys(obj).forEach(function (key) {
|
107 | src = target[key];
|
108 | val = obj[key];
|
109 |
|
110 | if (val === target) {
|
111 | return;
|
112 | |
113 |
|
114 |
|
115 |
|
116 | }
|
117 | else if (typeof val !== 'object' || val === null) {
|
118 | target[key] = val;
|
119 | return;
|
120 |
|
121 | }
|
122 | else if (Array.isArray(val)) {
|
123 | target[key] = deepCloneArray(val);
|
124 | return;
|
125 |
|
126 | }
|
127 | else if (isSpecificValue(val)) {
|
128 | target[key] = cloneSpecificValue(val);
|
129 | return;
|
130 |
|
131 | }
|
132 | else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
|
133 | target[key] = deepExtend({}, val);
|
134 | return;
|
135 |
|
136 | }
|
137 | else {
|
138 | target[key] = deepExtend(src, val);
|
139 | return;
|
140 | }
|
141 | });
|
142 | });
|
143 | return target;
|
144 | };
|
145 | function isSpecificValue(val) {
|
146 | return (val instanceof Date
|
147 | || val instanceof RegExp) ? true : false;
|
148 | }
|
149 | function cloneSpecificValue(val) {
|
150 | if (val instanceof Date) {
|
151 | return new Date(val.getTime());
|
152 | }
|
153 | else if (val instanceof RegExp) {
|
154 | return new RegExp(val);
|
155 | }
|
156 | else {
|
157 | throw new Error('cloneSpecificValue: Unexpected situation');
|
158 | }
|
159 | }
|
160 |
|
161 |
|
162 |
|
163 | function deepCloneArray(arr) {
|
164 | var clone = [];
|
165 | arr.forEach(function (item, index) {
|
166 | if (typeof item === 'object' && item !== null) {
|
167 | if (Array.isArray(item)) {
|
168 | clone[index] = deepCloneArray(item);
|
169 | }
|
170 | else if (isSpecificValue(item)) {
|
171 | clone[index] = cloneSpecificValue(item);
|
172 | }
|
173 | else {
|
174 | clone[index] = deepExtend({}, item);
|
175 | }
|
176 | }
|
177 | else {
|
178 | clone[index] = item;
|
179 | }
|
180 | });
|
181 | return clone;
|
182 | }
|
183 |
|
184 | function getDeepFromObject(object, name, defaultValue) {
|
185 | if (object === void 0) { object = {}; }
|
186 | var keys = name.split('.');
|
187 |
|
188 | var level = deepExtend({}, object || {});
|
189 | keys.forEach(function (k) {
|
190 | if (level && typeof level[k] !== 'undefined') {
|
191 | level = level[k];
|
192 | }
|
193 | else {
|
194 | level = undefined;
|
195 | }
|
196 | });
|
197 | return typeof level === 'undefined' ? defaultValue : level;
|
198 | }
|
199 | function urlBase64Decode(str) {
|
200 | var output = str.replace(/-/g, '+').replace(/_/g, '/');
|
201 | switch (output.length % 4) {
|
202 | case 0: {
|
203 | break;
|
204 | }
|
205 | case 2: {
|
206 | output += '==';
|
207 | break;
|
208 | }
|
209 | case 3: {
|
210 | output += '=';
|
211 | break;
|
212 | }
|
213 | default: {
|
214 | throw new Error('Illegal base64url string!');
|
215 | }
|
216 | }
|
217 | return b64DecodeUnicode(output);
|
218 | }
|
219 | function b64decode(str) {
|
220 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
221 | var output = '';
|
222 | str = String(str).replace(/=+$/, '');
|
223 | if (str.length % 4 === 1) {
|
224 | throw new Error("'atob' failed: The string to be decoded is not correctly encoded.");
|
225 | }
|
226 | for (
|
227 |
|
228 | var bc = 0, bs = void 0, buffer = void 0, idx = 0;
|
229 |
|
230 | buffer = str.charAt(idx++);
|
231 |
|
232 | ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
233 |
|
234 |
|
235 | bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
|
236 |
|
237 | buffer = chars.indexOf(buffer);
|
238 | }
|
239 | return output;
|
240 | }
|
241 |
|
242 | function b64DecodeUnicode(str) {
|
243 | return decodeURIComponent(Array.prototype.map.call(b64decode(str), function (c) {
|
244 | return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
245 | }).join(''));
|
246 | }
|
247 |
|
248 | var NbAuthToken = (function () {
|
249 | function NbAuthToken() {
|
250 | this.payload = null;
|
251 | }
|
252 | NbAuthToken.prototype.getName = function () {
|
253 | return this.constructor.NAME;
|
254 | };
|
255 | NbAuthToken.prototype.getPayload = function () {
|
256 | return this.payload;
|
257 | };
|
258 | return NbAuthToken;
|
259 | }());
|
260 | var NbAuthTokenNotFoundError = (function (_super) {
|
261 | tslib.__extends(NbAuthTokenNotFoundError, _super);
|
262 | function NbAuthTokenNotFoundError(message) {
|
263 | var _newTarget = this.constructor;
|
264 | var _this = _super.call(this, message) || this;
|
265 | Object.setPrototypeOf(_this, _newTarget.prototype);
|
266 | return _this;
|
267 | }
|
268 | return NbAuthTokenNotFoundError;
|
269 | }(Error));
|
270 | var NbAuthIllegalTokenError = (function (_super) {
|
271 | tslib.__extends(NbAuthIllegalTokenError, _super);
|
272 | function NbAuthIllegalTokenError(message) {
|
273 | var _newTarget = this.constructor;
|
274 | var _this = _super.call(this, message) || this;
|
275 | Object.setPrototypeOf(_this, _newTarget.prototype);
|
276 | return _this;
|
277 | }
|
278 | return NbAuthIllegalTokenError;
|
279 | }(Error));
|
280 | var NbAuthEmptyTokenError = (function (_super) {
|
281 | tslib.__extends(NbAuthEmptyTokenError, _super);
|
282 | function NbAuthEmptyTokenError(message) {
|
283 | var _newTarget = this.constructor;
|
284 | var _this = _super.call(this, message) || this;
|
285 | Object.setPrototypeOf(_this, _newTarget.prototype);
|
286 | return _this;
|
287 | }
|
288 | return NbAuthEmptyTokenError;
|
289 | }(NbAuthIllegalTokenError));
|
290 | var NbAuthIllegalJWTTokenError = (function (_super) {
|
291 | tslib.__extends(NbAuthIllegalJWTTokenError, _super);
|
292 | function NbAuthIllegalJWTTokenError(message) {
|
293 | var _newTarget = this.constructor;
|
294 | var _this = _super.call(this, message) || this;
|
295 | Object.setPrototypeOf(_this, _newTarget.prototype);
|
296 | return _this;
|
297 | }
|
298 | return NbAuthIllegalJWTTokenError;
|
299 | }(NbAuthIllegalTokenError));
|
300 | function nbAuthCreateToken(tokenClass, token, ownerStrategyName, createdAt) {
|
301 | return new tokenClass(token, ownerStrategyName, createdAt);
|
302 | }
|
303 | function decodeJwtPayload(payload) {
|
304 | if (payload.length === 0) {
|
305 | throw new NbAuthEmptyTokenError('Cannot extract from an empty payload.');
|
306 | }
|
307 | var parts = payload.split('.');
|
308 | if (parts.length !== 3) {
|
309 | throw new NbAuthIllegalJWTTokenError("The payload " + payload + " is not valid JWT payload and must consist of three parts.");
|
310 | }
|
311 | var decoded;
|
312 | try {
|
313 | decoded = urlBase64Decode(parts[1]);
|
314 | }
|
315 | catch (e) {
|
316 | throw new NbAuthIllegalJWTTokenError("The payload " + payload + " is not valid JWT payload and cannot be parsed.");
|
317 | }
|
318 | if (!decoded) {
|
319 | throw new NbAuthIllegalJWTTokenError("The payload " + payload + " is not valid JWT payload and cannot be decoded.");
|
320 | }
|
321 | return JSON.parse(decoded);
|
322 | }
|
323 |
|
324 |
|
325 |
|
326 | var NbAuthSimpleToken = (function (_super) {
|
327 | tslib.__extends(NbAuthSimpleToken, _super);
|
328 | function NbAuthSimpleToken(token, ownerStrategyName, createdAt) {
|
329 | var _this = _super.call(this) || this;
|
330 | _this.token = token;
|
331 | _this.ownerStrategyName = ownerStrategyName;
|
332 | _this.createdAt = createdAt;
|
333 | try {
|
334 | _this.parsePayload();
|
335 | }
|
336 | catch (err) {
|
337 | if (!(err instanceof NbAuthTokenNotFoundError)) {
|
338 |
|
339 | throw err;
|
340 | }
|
341 | }
|
342 | _this.createdAt = _this.prepareCreatedAt(createdAt);
|
343 | return _this;
|
344 | }
|
345 | NbAuthSimpleToken.prototype.parsePayload = function () {
|
346 | this.payload = null;
|
347 | };
|
348 | NbAuthSimpleToken.prototype.prepareCreatedAt = function (date) {
|
349 | return date ? date : new Date();
|
350 | };
|
351 | |
352 |
|
353 |
|
354 |
|
355 | NbAuthSimpleToken.prototype.getCreatedAt = function () {
|
356 | return this.createdAt;
|
357 | };
|
358 | |
359 |
|
360 |
|
361 |
|
362 | NbAuthSimpleToken.prototype.getValue = function () {
|
363 | return this.token;
|
364 | };
|
365 | NbAuthSimpleToken.prototype.getOwnerStrategyName = function () {
|
366 | return this.ownerStrategyName;
|
367 | };
|
368 | |
369 |
|
370 |
|
371 |
|
372 | NbAuthSimpleToken.prototype.isValid = function () {
|
373 | return !!this.getValue();
|
374 | };
|
375 | |
376 |
|
377 |
|
378 |
|
379 | NbAuthSimpleToken.prototype.toString = function () {
|
380 | return !!this.token ? this.token : '';
|
381 | };
|
382 | NbAuthSimpleToken.NAME = 'nb:auth:simple:token';
|
383 | return NbAuthSimpleToken;
|
384 | }(NbAuthToken));
|
385 |
|
386 |
|
387 |
|
388 | var NbAuthJWTToken = (function (_super) {
|
389 | tslib.__extends(NbAuthJWTToken, _super);
|
390 | function NbAuthJWTToken() {
|
391 | return _super !== null && _super.apply(this, arguments) || this;
|
392 | }
|
393 | |
394 |
|
395 |
|
396 | NbAuthJWTToken.prototype.prepareCreatedAt = function (date) {
|
397 | var decoded = this.getPayload();
|
398 | return decoded && decoded.iat ? new Date(Number(decoded.iat) * 1000) : _super.prototype.prepareCreatedAt.call(this, date);
|
399 | };
|
400 | |
401 |
|
402 |
|
403 |
|
404 | NbAuthJWTToken.prototype.parsePayload = function () {
|
405 | if (!this.token) {
|
406 | throw new NbAuthTokenNotFoundError('Token not found. ');
|
407 | }
|
408 | this.payload = decodeJwtPayload(this.token);
|
409 | };
|
410 | |
411 |
|
412 |
|
413 |
|
414 | NbAuthJWTToken.prototype.getTokenExpDate = function () {
|
415 | var decoded = this.getPayload();
|
416 | if (decoded && !decoded.hasOwnProperty('exp')) {
|
417 | return null;
|
418 | }
|
419 | var date = new Date(0);
|
420 | date.setUTCSeconds(decoded.exp);
|
421 | return date;
|
422 | };
|
423 | |
424 |
|
425 |
|
426 |
|
427 | NbAuthJWTToken.prototype.isValid = function () {
|
428 | return _super.prototype.isValid.call(this) && (!this.getTokenExpDate() || new Date() < this.getTokenExpDate());
|
429 | };
|
430 | NbAuthJWTToken.NAME = 'nb:auth:jwt:token';
|
431 | return NbAuthJWTToken;
|
432 | }(NbAuthSimpleToken));
|
433 | var prepareOAuth2Token = function (data) {
|
434 | if (typeof data === 'string') {
|
435 | try {
|
436 | return JSON.parse(data);
|
437 | }
|
438 | catch (e) { }
|
439 | }
|
440 | return data;
|
441 | };
|
442 | var ɵ0 = prepareOAuth2Token;
|
443 |
|
444 |
|
445 |
|
446 | var NbAuthOAuth2Token = (function (_super) {
|
447 | tslib.__extends(NbAuthOAuth2Token, _super);
|
448 | function NbAuthOAuth2Token(data, ownerStrategyName, createdAt) {
|
449 | if (data === void 0) { data = {}; }
|
450 |
|
451 | return _super.call(this, prepareOAuth2Token(data), ownerStrategyName, createdAt) || this;
|
452 | }
|
453 | |
454 |
|
455 |
|
456 |
|
457 | NbAuthOAuth2Token.prototype.getValue = function () {
|
458 | return this.token.access_token;
|
459 | };
|
460 | |
461 |
|
462 |
|
463 |
|
464 | NbAuthOAuth2Token.prototype.getRefreshToken = function () {
|
465 | return this.token.refresh_token;
|
466 | };
|
467 | |
468 |
|
469 |
|
470 |
|
471 | NbAuthOAuth2Token.prototype.setRefreshToken = function (refreshToken) {
|
472 | this.token.refresh_token = refreshToken;
|
473 | };
|
474 | |
475 |
|
476 |
|
477 |
|
478 | NbAuthOAuth2Token.prototype.parsePayload = function () {
|
479 | if (!this.token) {
|
480 | throw new NbAuthTokenNotFoundError('Token not found.');
|
481 | }
|
482 | else {
|
483 | if (!Object.keys(this.token).length) {
|
484 | throw new NbAuthEmptyTokenError('Cannot extract payload from an empty token.');
|
485 | }
|
486 | }
|
487 | this.payload = this.token;
|
488 | };
|
489 | |
490 |
|
491 |
|
492 |
|
493 | NbAuthOAuth2Token.prototype.getType = function () {
|
494 | return this.token.token_type;
|
495 | };
|
496 | |
497 |
|
498 |
|
499 |
|
500 | NbAuthOAuth2Token.prototype.isValid = function () {
|
501 | return _super.prototype.isValid.call(this) && (!this.getTokenExpDate() || new Date() < this.getTokenExpDate());
|
502 | };
|
503 | |
504 |
|
505 |
|
506 |
|
507 | NbAuthOAuth2Token.prototype.getTokenExpDate = function () {
|
508 | if (!this.token.hasOwnProperty('expires_in')) {
|
509 | return null;
|
510 | }
|
511 | return new Date(this.createdAt.getTime() + Number(this.token.expires_in) * 1000);
|
512 | };
|
513 | |
514 |
|
515 |
|
516 |
|
517 | NbAuthOAuth2Token.prototype.toString = function () {
|
518 | return JSON.stringify(this.token);
|
519 | };
|
520 | NbAuthOAuth2Token.NAME = 'nb:auth:oauth2:token';
|
521 | return NbAuthOAuth2Token;
|
522 | }(NbAuthSimpleToken));
|
523 |
|
524 |
|
525 |
|
526 | var NbAuthOAuth2JWTToken = (function (_super) {
|
527 | tslib.__extends(NbAuthOAuth2JWTToken, _super);
|
528 | function NbAuthOAuth2JWTToken() {
|
529 | return _super !== null && _super.apply(this, arguments) || this;
|
530 | }
|
531 | NbAuthOAuth2JWTToken.prototype.parsePayload = function () {
|
532 | _super.prototype.parsePayload.call(this);
|
533 | this.parseAccessTokenPayload();
|
534 | };
|
535 | NbAuthOAuth2JWTToken.prototype.parseAccessTokenPayload = function () {
|
536 | var accessToken = this.getValue();
|
537 | if (!accessToken) {
|
538 | throw new NbAuthTokenNotFoundError('access_token key not found.');
|
539 | }
|
540 | this.accessTokenPayload = decodeJwtPayload(accessToken);
|
541 | };
|
542 | |
543 |
|
544 |
|
545 |
|
546 | NbAuthOAuth2JWTToken.prototype.getAccessTokenPayload = function () {
|
547 | return this.accessTokenPayload;
|
548 | };
|
549 | |
550 |
|
551 |
|
552 | NbAuthOAuth2JWTToken.prototype.prepareCreatedAt = function (date) {
|
553 | var payload = this.accessTokenPayload;
|
554 | return payload && payload.iat ? new Date(Number(payload.iat) * 1000) : _super.prototype.prepareCreatedAt.call(this, date);
|
555 | };
|
556 | |
557 |
|
558 |
|
559 |
|
560 | NbAuthOAuth2JWTToken.prototype.isValid = function () {
|
561 | return this.accessTokenPayload && _super.prototype.isValid.call(this);
|
562 | };
|
563 | |
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 | NbAuthOAuth2JWTToken.prototype.getTokenExpDate = function () {
|
570 | if (this.accessTokenPayload && this.accessTokenPayload.hasOwnProperty('exp')) {
|
571 | var date = new Date(0);
|
572 | date.setUTCSeconds(this.accessTokenPayload.exp);
|
573 | return date;
|
574 | }
|
575 | else {
|
576 | return _super.prototype.getTokenExpDate.call(this);
|
577 | }
|
578 | };
|
579 | NbAuthOAuth2JWTToken.NAME = 'nb:auth:oauth2:jwt:token';
|
580 | return NbAuthOAuth2JWTToken;
|
581 | }(NbAuthOAuth2Token));
|
582 |
|
583 | var NB_AUTH_FALLBACK_TOKEN = new _angular_core.InjectionToken('Nebular Auth Options');
|
584 |
|
585 |
|
586 |
|
587 | var NbAuthTokenParceler = (function () {
|
588 | function NbAuthTokenParceler(fallbackClass, tokenClasses) {
|
589 | this.fallbackClass = fallbackClass;
|
590 | this.tokenClasses = tokenClasses;
|
591 | }
|
592 | NbAuthTokenParceler.prototype.wrap = function (token) {
|
593 | return JSON.stringify({
|
594 | name: token.getName(),
|
595 | ownerStrategyName: token.getOwnerStrategyName(),
|
596 | createdAt: token.getCreatedAt().getTime(),
|
597 | value: token.toString(),
|
598 | });
|
599 | };
|
600 | NbAuthTokenParceler.prototype.unwrap = function (value) {
|
601 | var tokenClass = this.fallbackClass;
|
602 | var tokenValue = '';
|
603 | var tokenOwnerStrategyName = '';
|
604 | var tokenCreatedAt = null;
|
605 | var tokenPack = this.parseTokenPack(value);
|
606 | if (tokenPack) {
|
607 | tokenClass = this.getClassByName(tokenPack.name) || this.fallbackClass;
|
608 | tokenValue = tokenPack.value;
|
609 | tokenOwnerStrategyName = tokenPack.ownerStrategyName;
|
610 | tokenCreatedAt = new Date(Number(tokenPack.createdAt));
|
611 | }
|
612 | return nbAuthCreateToken(tokenClass, tokenValue, tokenOwnerStrategyName, tokenCreatedAt);
|
613 | };
|
614 |
|
615 | NbAuthTokenParceler.prototype.getClassByName = function (name) {
|
616 | return this.tokenClasses.find(function (tokenClass) { return tokenClass.NAME === name; });
|
617 | };
|
618 | NbAuthTokenParceler.prototype.parseTokenPack = function (value) {
|
619 | try {
|
620 | return JSON.parse(value);
|
621 | }
|
622 | catch (e) { }
|
623 | return null;
|
624 | };
|
625 | NbAuthTokenParceler.decorators = [
|
626 | { type: _angular_core.Injectable }
|
627 | ];
|
628 | NbAuthTokenParceler.ctorParameters = function () { return [
|
629 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_FALLBACK_TOKEN,] }] },
|
630 | { type: Array, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_TOKENS,] }] }
|
631 | ]; };
|
632 | return NbAuthTokenParceler;
|
633 | }());
|
634 |
|
635 | var NbTokenStorage = (function () {
|
636 | function NbTokenStorage() {
|
637 | }
|
638 | return NbTokenStorage;
|
639 | }());
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 | var NbTokenLocalStorage = (function (_super) {
|
656 | tslib.__extends(NbTokenLocalStorage, _super);
|
657 | function NbTokenLocalStorage(parceler) {
|
658 | var _this = _super.call(this) || this;
|
659 | _this.parceler = parceler;
|
660 | _this.key = 'auth_app_token';
|
661 | return _this;
|
662 | }
|
663 | |
664 |
|
665 |
|
666 |
|
667 | NbTokenLocalStorage.prototype.get = function () {
|
668 | var raw = localStorage.getItem(this.key);
|
669 | return this.parceler.unwrap(raw);
|
670 | };
|
671 | |
672 |
|
673 |
|
674 |
|
675 | NbTokenLocalStorage.prototype.set = function (token) {
|
676 | var raw = this.parceler.wrap(token);
|
677 | localStorage.setItem(this.key, raw);
|
678 | };
|
679 | |
680 |
|
681 |
|
682 | NbTokenLocalStorage.prototype.clear = function () {
|
683 | localStorage.removeItem(this.key);
|
684 | };
|
685 | NbTokenLocalStorage.decorators = [
|
686 | { type: _angular_core.Injectable }
|
687 | ];
|
688 | NbTokenLocalStorage.ctorParameters = function () { return [
|
689 | { type: NbAuthTokenParceler }
|
690 | ]; };
|
691 | return NbTokenLocalStorage;
|
692 | }(NbTokenStorage));
|
693 |
|
694 |
|
695 |
|
696 |
|
697 | var NbTokenService = (function () {
|
698 | function NbTokenService(tokenStorage) {
|
699 | this.tokenStorage = tokenStorage;
|
700 | this.token$ = new rxjs.BehaviorSubject(null);
|
701 | this.publishStoredToken();
|
702 | }
|
703 | |
704 |
|
705 |
|
706 |
|
707 | NbTokenService.prototype.tokenChange = function () {
|
708 | return this.token$
|
709 | .pipe(rxjs_operators.filter(function (value) { return !!value; }), rxjs_operators.share());
|
710 | };
|
711 | |
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 | NbTokenService.prototype.set = function (token) {
|
718 | this.tokenStorage.set(token);
|
719 | this.publishStoredToken();
|
720 | return rxjs.of(null);
|
721 | };
|
722 | |
723 |
|
724 |
|
725 |
|
726 | NbTokenService.prototype.get = function () {
|
727 | var token = this.tokenStorage.get();
|
728 | return rxjs.of(token);
|
729 | };
|
730 | |
731 |
|
732 |
|
733 |
|
734 |
|
735 | NbTokenService.prototype.clear = function () {
|
736 | this.tokenStorage.clear();
|
737 | this.publishStoredToken();
|
738 | return rxjs.of(null);
|
739 | };
|
740 | NbTokenService.prototype.publishStoredToken = function () {
|
741 | this.token$.next(this.tokenStorage.get());
|
742 | };
|
743 | NbTokenService.decorators = [
|
744 | { type: _angular_core.Injectable }
|
745 | ];
|
746 | NbTokenService.ctorParameters = function () { return [
|
747 | { type: NbTokenStorage }
|
748 | ]; };
|
749 | return NbTokenService;
|
750 | }());
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 | var NbAuthService = (function () {
|
762 | function NbAuthService(tokenService, strategies) {
|
763 | this.tokenService = tokenService;
|
764 | this.strategies = strategies;
|
765 | }
|
766 | |
767 |
|
768 |
|
769 |
|
770 | NbAuthService.prototype.getToken = function () {
|
771 | return this.tokenService.get();
|
772 | };
|
773 | |
774 |
|
775 |
|
776 |
|
777 | NbAuthService.prototype.isAuthenticated = function () {
|
778 | return this.getToken()
|
779 | .pipe(rxjs_operators.map(function (token) { return token.isValid(); }));
|
780 | };
|
781 | |
782 |
|
783 |
|
784 |
|
785 |
|
786 | NbAuthService.prototype.isAuthenticatedOrRefresh = function () {
|
787 | var _this = this;
|
788 | return this.getToken()
|
789 | .pipe(rxjs_operators.switchMap(function (token) {
|
790 | if (token.getValue() && !token.isValid()) {
|
791 | return _this.refreshToken(token.getOwnerStrategyName(), token)
|
792 | .pipe(rxjs_operators.switchMap(function (res) {
|
793 | if (res.isSuccess()) {
|
794 | return _this.isAuthenticated();
|
795 | }
|
796 | else {
|
797 | return rxjs.of(false);
|
798 | }
|
799 | }));
|
800 | }
|
801 | else {
|
802 | return rxjs.of(token.isValid());
|
803 | }
|
804 | }));
|
805 | };
|
806 | |
807 |
|
808 |
|
809 |
|
810 | NbAuthService.prototype.onTokenChange = function () {
|
811 | return this.tokenService.tokenChange();
|
812 | };
|
813 | |
814 |
|
815 |
|
816 |
|
817 | NbAuthService.prototype.onAuthenticationChange = function () {
|
818 | return this.onTokenChange()
|
819 | .pipe(rxjs_operators.map(function (token) { return token.isValid(); }));
|
820 | };
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 |
|
830 |
|
831 |
|
832 | NbAuthService.prototype.authenticate = function (strategyName, data) {
|
833 | var _this = this;
|
834 | return this.getStrategy(strategyName).authenticate(data)
|
835 | .pipe(rxjs_operators.switchMap(function (result) {
|
836 | return _this.processResultToken(result);
|
837 | }));
|
838 | };
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 | NbAuthService.prototype.register = function (strategyName, data) {
|
851 | var _this = this;
|
852 | return this.getStrategy(strategyName).register(data)
|
853 | .pipe(rxjs_operators.switchMap(function (result) {
|
854 | return _this.processResultToken(result);
|
855 | }));
|
856 | };
|
857 | |
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 | NbAuthService.prototype.logout = function (strategyName) {
|
868 | var _this = this;
|
869 | return this.getStrategy(strategyName).logout()
|
870 | .pipe(rxjs_operators.switchMap(function (result) {
|
871 | if (result.isSuccess()) {
|
872 | _this.tokenService.clear()
|
873 | .pipe(rxjs_operators.map(function () { return result; }));
|
874 | }
|
875 | return rxjs.of(result);
|
876 | }));
|
877 | };
|
878 | |
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 | NbAuthService.prototype.requestPassword = function (strategyName, data) {
|
889 | return this.getStrategy(strategyName).requestPassword(data);
|
890 | };
|
891 | |
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 | NbAuthService.prototype.resetPassword = function (strategyName, data) {
|
902 | return this.getStrategy(strategyName).resetPassword(data);
|
903 | };
|
904 | |
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 | NbAuthService.prototype.refreshToken = function (strategyName, data) {
|
916 | var _this = this;
|
917 | return this.getStrategy(strategyName).refreshToken(data)
|
918 | .pipe(rxjs_operators.switchMap(function (result) {
|
919 | return _this.processResultToken(result);
|
920 | }));
|
921 | };
|
922 | |
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 | NbAuthService.prototype.getStrategy = function (strategyName) {
|
932 | var found = this.strategies.find(function (strategy) { return strategy.getName() === strategyName; });
|
933 | if (!found) {
|
934 | throw new TypeError("There is no Auth Strategy registered under '" + strategyName + "' name");
|
935 | }
|
936 | return found;
|
937 | };
|
938 | NbAuthService.prototype.processResultToken = function (result) {
|
939 | if (result.isSuccess() && result.getToken()) {
|
940 | return this.tokenService.set(result.getToken())
|
941 | .pipe(rxjs_operators.map(function (token) {
|
942 | return result;
|
943 | }));
|
944 | }
|
945 | return rxjs.of(result);
|
946 | };
|
947 | NbAuthService.decorators = [
|
948 | { type: _angular_core.Injectable }
|
949 | ];
|
950 | NbAuthService.ctorParameters = function () { return [
|
951 | { type: NbTokenService },
|
952 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_STRATEGIES,] }] }
|
953 | ]; };
|
954 | return NbAuthService;
|
955 | }());
|
956 |
|
957 | var NbAuthStrategy = (function () {
|
958 | function NbAuthStrategy() {
|
959 | }
|
960 |
|
961 |
|
962 | NbAuthStrategy.prototype.setOptions = function (options) {
|
963 | this.options = deepExtend({}, this.defaultOptions, options);
|
964 | };
|
965 | NbAuthStrategy.prototype.getOption = function (key) {
|
966 | return getDeepFromObject(this.options, key, null);
|
967 | };
|
968 | NbAuthStrategy.prototype.createToken = function (value, failWhenInvalidToken) {
|
969 | var token = nbAuthCreateToken(this.getOption('token.class'), value, this.getName());
|
970 |
|
971 |
|
972 | if (failWhenInvalidToken && !token.isValid()) {
|
973 |
|
974 |
|
975 | throw new NbAuthIllegalTokenError('Token is empty or invalid.');
|
976 | }
|
977 | return token;
|
978 | };
|
979 | NbAuthStrategy.prototype.getName = function () {
|
980 | return this.getOption('name');
|
981 | };
|
982 | NbAuthStrategy.prototype.createFailResponse = function (data) {
|
983 | return new _angular_common_http.HttpResponse({ body: {}, status: 401 });
|
984 | };
|
985 | NbAuthStrategy.prototype.createSuccessResponse = function (data) {
|
986 | return new _angular_common_http.HttpResponse({ body: {}, status: 200 });
|
987 | };
|
988 | NbAuthStrategy.prototype.getActionEndpoint = function (action) {
|
989 | var actionEndpoint = this.getOption(action + ".endpoint");
|
990 | var baseEndpoint = this.getOption('baseEndpoint');
|
991 | return actionEndpoint ? baseEndpoint + actionEndpoint : '';
|
992 | };
|
993 | return NbAuthStrategy;
|
994 | }());
|
995 |
|
996 | var NbAuthResult = (function () {
|
997 |
|
998 | function NbAuthResult(success, response, redirect, errors, messages, token) {
|
999 | if (token === void 0) { token = null; }
|
1000 | this.success = success;
|
1001 | this.response = response;
|
1002 | this.redirect = redirect;
|
1003 | this.errors = [];
|
1004 | this.messages = [];
|
1005 | this.errors = this.errors.concat([errors]);
|
1006 | if (errors instanceof Array) {
|
1007 | this.errors = errors;
|
1008 | }
|
1009 | this.messages = this.messages.concat([messages]);
|
1010 | if (messages instanceof Array) {
|
1011 | this.messages = messages;
|
1012 | }
|
1013 | this.token = token;
|
1014 | }
|
1015 | NbAuthResult.prototype.getResponse = function () {
|
1016 | return this.response;
|
1017 | };
|
1018 | NbAuthResult.prototype.getToken = function () {
|
1019 | return this.token;
|
1020 | };
|
1021 | NbAuthResult.prototype.getRedirect = function () {
|
1022 | return this.redirect;
|
1023 | };
|
1024 | NbAuthResult.prototype.getErrors = function () {
|
1025 | return this.errors.filter(function (val) { return !!val; });
|
1026 | };
|
1027 | NbAuthResult.prototype.getMessages = function () {
|
1028 | return this.messages.filter(function (val) { return !!val; });
|
1029 | };
|
1030 | NbAuthResult.prototype.isSuccess = function () {
|
1031 | return this.success;
|
1032 | };
|
1033 | NbAuthResult.prototype.isFailure = function () {
|
1034 | return !this.success;
|
1035 | };
|
1036 | return NbAuthResult;
|
1037 | }());
|
1038 |
|
1039 | var NbAuthStrategyOptions = (function () {
|
1040 | function NbAuthStrategyOptions() {
|
1041 | }
|
1042 | return NbAuthStrategyOptions;
|
1043 | }());
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 | var NbDummyAuthStrategyOptions = (function (_super) {
|
1051 | tslib.__extends(NbDummyAuthStrategyOptions, _super);
|
1052 | function NbDummyAuthStrategyOptions() {
|
1053 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1054 | _this.token = {
|
1055 | class: NbAuthSimpleToken,
|
1056 | };
|
1057 | _this.delay = 1000;
|
1058 | _this.alwaysFail = false;
|
1059 | return _this;
|
1060 | }
|
1061 | return NbDummyAuthStrategyOptions;
|
1062 | }(NbAuthStrategyOptions));
|
1063 | var dummyStrategyOptions = new NbDummyAuthStrategyOptions();
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 | var NbDummyAuthStrategy = (function (_super) {
|
1083 | tslib.__extends(NbDummyAuthStrategy, _super);
|
1084 | function NbDummyAuthStrategy() {
|
1085 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1086 | _this.defaultOptions = dummyStrategyOptions;
|
1087 | return _this;
|
1088 | }
|
1089 | NbDummyAuthStrategy.setup = function (options) {
|
1090 | return [NbDummyAuthStrategy, options];
|
1091 | };
|
1092 | NbDummyAuthStrategy.prototype.authenticate = function (data) {
|
1093 | return rxjs.of(this.createDummyResult(data))
|
1094 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1095 | };
|
1096 | NbDummyAuthStrategy.prototype.register = function (data) {
|
1097 | return rxjs.of(this.createDummyResult(data))
|
1098 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1099 | };
|
1100 | NbDummyAuthStrategy.prototype.requestPassword = function (data) {
|
1101 | return rxjs.of(this.createDummyResult(data))
|
1102 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1103 | };
|
1104 | NbDummyAuthStrategy.prototype.resetPassword = function (data) {
|
1105 | return rxjs.of(this.createDummyResult(data))
|
1106 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1107 | };
|
1108 | NbDummyAuthStrategy.prototype.logout = function (data) {
|
1109 | return rxjs.of(this.createDummyResult(data))
|
1110 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1111 | };
|
1112 | NbDummyAuthStrategy.prototype.refreshToken = function (data) {
|
1113 | return rxjs.of(this.createDummyResult(data))
|
1114 | .pipe(rxjs_operators.delay(this.getOption('delay')));
|
1115 | };
|
1116 | NbDummyAuthStrategy.prototype.createDummyResult = function (data) {
|
1117 | if (this.getOption('alwaysFail')) {
|
1118 | return new NbAuthResult(false, this.createFailResponse(data), null, ['Something went wrong.']);
|
1119 | }
|
1120 | try {
|
1121 | var token = this.createToken('test token', true);
|
1122 | return new NbAuthResult(true, this.createSuccessResponse(data), '/', [], ['Successfully logged in.'], token);
|
1123 | }
|
1124 | catch (err) {
|
1125 | return new NbAuthResult(false, this.createFailResponse(data), null, [err.message]);
|
1126 | }
|
1127 | };
|
1128 | NbDummyAuthStrategy.decorators = [
|
1129 | { type: _angular_core.Injectable }
|
1130 | ];
|
1131 | return NbDummyAuthStrategy;
|
1132 | }(NbAuthStrategy));
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 | (function (NbOAuth2ResponseType) {
|
1141 | NbOAuth2ResponseType["CODE"] = "code";
|
1142 | NbOAuth2ResponseType["TOKEN"] = "token";
|
1143 | })(exports.NbOAuth2ResponseType || (exports.NbOAuth2ResponseType = {}));
|
1144 |
|
1145 |
|
1146 | (function (NbOAuth2GrantType) {
|
1147 | NbOAuth2GrantType["AUTHORIZATION_CODE"] = "authorization_code";
|
1148 | NbOAuth2GrantType["PASSWORD"] = "password";
|
1149 | NbOAuth2GrantType["REFRESH_TOKEN"] = "refresh_token";
|
1150 | })(exports.NbOAuth2GrantType || (exports.NbOAuth2GrantType = {}));
|
1151 |
|
1152 | (function (NbOAuth2ClientAuthMethod) {
|
1153 | NbOAuth2ClientAuthMethod["NONE"] = "none";
|
1154 | NbOAuth2ClientAuthMethod["BASIC"] = "basic";
|
1155 | NbOAuth2ClientAuthMethod["REQUEST_BODY"] = "request-body";
|
1156 | })(exports.NbOAuth2ClientAuthMethod || (exports.NbOAuth2ClientAuthMethod = {}));
|
1157 | var NbOAuth2AuthStrategyOptions = (function (_super) {
|
1158 | tslib.__extends(NbOAuth2AuthStrategyOptions, _super);
|
1159 | function NbOAuth2AuthStrategyOptions() {
|
1160 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1161 | _this.baseEndpoint = '';
|
1162 | _this.clientId = '';
|
1163 | _this.clientSecret = '';
|
1164 | _this.clientAuthMethod = exports.NbOAuth2ClientAuthMethod.NONE;
|
1165 | _this.redirect = {
|
1166 | success: '/',
|
1167 | failure: null,
|
1168 | };
|
1169 | _this.defaultErrors = ['Something went wrong, please try again.'];
|
1170 | _this.defaultMessages = ['You have been successfully authenticated.'];
|
1171 | _this.authorize = {
|
1172 | endpoint: 'authorize',
|
1173 | responseType: exports.NbOAuth2ResponseType.CODE,
|
1174 | requireValidToken: true,
|
1175 | };
|
1176 | _this.token = {
|
1177 | endpoint: 'token',
|
1178 | grantType: exports.NbOAuth2GrantType.AUTHORIZATION_CODE,
|
1179 | requireValidToken: true,
|
1180 | class: NbAuthOAuth2Token,
|
1181 | };
|
1182 | _this.refresh = {
|
1183 | endpoint: 'token',
|
1184 | grantType: exports.NbOAuth2GrantType.REFRESH_TOKEN,
|
1185 | requireValidToken: true,
|
1186 | };
|
1187 | return _this;
|
1188 | }
|
1189 | return NbOAuth2AuthStrategyOptions;
|
1190 | }(NbAuthStrategyOptions));
|
1191 | var auth2StrategyOptions = new NbOAuth2AuthStrategyOptions();
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 | var NbOAuth2AuthStrategy = (function (_super) {
|
1265 | tslib.__extends(NbOAuth2AuthStrategy, _super);
|
1266 | function NbOAuth2AuthStrategy(http, route, window) {
|
1267 | var _a, _b;
|
1268 | var _this = _super.call(this) || this;
|
1269 | _this.http = http;
|
1270 | _this.route = route;
|
1271 | _this.window = window;
|
1272 | _this.redirectResultHandlers = (_a = {},
|
1273 | _a[exports.NbOAuth2ResponseType.CODE] = function () {
|
1274 | return rxjs.of(_this.route.snapshot.queryParams).pipe(rxjs_operators.switchMap(function (params) {
|
1275 | if (params.code) {
|
1276 | return _this.requestToken(params.code);
|
1277 | }
|
1278 | return rxjs.of(new NbAuthResult(false, params, _this.getOption('redirect.failure'), _this.getOption('defaultErrors'), []));
|
1279 | }));
|
1280 | },
|
1281 | _a[exports.NbOAuth2ResponseType.TOKEN] = function () {
|
1282 | var module = 'authorize';
|
1283 | var requireValidToken = _this.getOption(module + ".requireValidToken");
|
1284 | return rxjs.of(_this.route.snapshot.fragment).pipe(rxjs_operators.map(function (fragment) { return _this.parseHashAsQueryParams(fragment); }), rxjs_operators.map(function (params) {
|
1285 | if (!params.error) {
|
1286 | return new NbAuthResult(true, params, _this.getOption('redirect.success'), [], _this.getOption('defaultMessages'), _this.createToken(params, requireValidToken));
|
1287 | }
|
1288 | return new NbAuthResult(false, params, _this.getOption('redirect.failure'), _this.getOption('defaultErrors'), []);
|
1289 | }), rxjs_operators.catchError(function (err) {
|
1290 | var errors = [];
|
1291 | if (err instanceof NbAuthIllegalTokenError) {
|
1292 | errors.push(err.message);
|
1293 | }
|
1294 | else {
|
1295 | errors.push('Something went wrong.');
|
1296 | }
|
1297 | return rxjs.of(new NbAuthResult(false, err, _this.getOption('redirect.failure'), errors));
|
1298 | }));
|
1299 | },
|
1300 | _a);
|
1301 | _this.redirectResults = (_b = {},
|
1302 | _b[exports.NbOAuth2ResponseType.CODE] = function () {
|
1303 | return rxjs.of(_this.route.snapshot.queryParams).pipe(rxjs_operators.map(function (params) { return !!(params && (params.code || params.error)); }));
|
1304 | },
|
1305 | _b[exports.NbOAuth2ResponseType.TOKEN] = function () {
|
1306 | return rxjs.of(_this.route.snapshot.fragment).pipe(rxjs_operators.map(function (fragment) { return _this.parseHashAsQueryParams(fragment); }), rxjs_operators.map(function (params) { return !!(params && (params.access_token || params.error)); }));
|
1307 | },
|
1308 | _b);
|
1309 | _this.defaultOptions = auth2StrategyOptions;
|
1310 | return _this;
|
1311 | }
|
1312 | NbOAuth2AuthStrategy.setup = function (options) {
|
1313 | return [NbOAuth2AuthStrategy, options];
|
1314 | };
|
1315 | Object.defineProperty(NbOAuth2AuthStrategy.prototype, "responseType", {
|
1316 | get: function () {
|
1317 | return this.getOption('authorize.responseType');
|
1318 | },
|
1319 | enumerable: false,
|
1320 | configurable: true
|
1321 | });
|
1322 | Object.defineProperty(NbOAuth2AuthStrategy.prototype, "clientAuthMethod", {
|
1323 | get: function () {
|
1324 | return this.getOption('clientAuthMethod');
|
1325 | },
|
1326 | enumerable: false,
|
1327 | configurable: true
|
1328 | });
|
1329 | NbOAuth2AuthStrategy.prototype.authenticate = function (data) {
|
1330 | var _this = this;
|
1331 | if (this.getOption('token.grantType') === exports.NbOAuth2GrantType.PASSWORD) {
|
1332 | return this.passwordToken(data.email, data.password);
|
1333 | }
|
1334 | else {
|
1335 | return this.isRedirectResult()
|
1336 | .pipe(rxjs_operators.switchMap(function (result) {
|
1337 | if (!result) {
|
1338 | _this.authorizeRedirect();
|
1339 | return rxjs.of(new NbAuthResult(true));
|
1340 | }
|
1341 | return _this.getAuthorizationResult();
|
1342 | }));
|
1343 | }
|
1344 | };
|
1345 | NbOAuth2AuthStrategy.prototype.getAuthorizationResult = function () {
|
1346 | var redirectResultHandler = this.redirectResultHandlers[this.responseType];
|
1347 | if (redirectResultHandler) {
|
1348 | return redirectResultHandler.call(this);
|
1349 | }
|
1350 | throw new Error("'" + this.responseType + "' responseType is not supported,\n only 'token' and 'code' are supported now");
|
1351 | };
|
1352 | NbOAuth2AuthStrategy.prototype.refreshToken = function (token) {
|
1353 | var _this = this;
|
1354 | var module = 'refresh';
|
1355 | var url = this.getActionEndpoint(module);
|
1356 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1357 | var headers = this.buildAuthHeader() || new _angular_common_http.HttpHeaders();
|
1358 | headers = headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
1359 | return this.http.post(url, this.buildRefreshRequestData(token), { headers: headers })
|
1360 | .pipe(rxjs_operators.map(function (res) {
|
1361 | return new NbAuthResult(true, res, _this.getOption('redirect.success'), [], _this.getOption('defaultMessages'), _this.createRefreshedToken(res, token, requireValidToken));
|
1362 | }), rxjs_operators.catchError(function (res) { return _this.handleResponseError(res); }));
|
1363 | };
|
1364 | NbOAuth2AuthStrategy.prototype.passwordToken = function (username, password) {
|
1365 | var _this = this;
|
1366 | var module = 'token';
|
1367 | var url = this.getActionEndpoint(module);
|
1368 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1369 | var headers = this.buildAuthHeader() || new _angular_common_http.HttpHeaders();
|
1370 | headers = headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
1371 | return this.http.post(url, this.buildPasswordRequestData(username, password), { headers: headers })
|
1372 | .pipe(rxjs_operators.map(function (res) {
|
1373 | return new NbAuthResult(true, res, _this.getOption('redirect.success'), [], _this.getOption('defaultMessages'), _this.createToken(res, requireValidToken));
|
1374 | }), rxjs_operators.catchError(function (res) { return _this.handleResponseError(res); }));
|
1375 | };
|
1376 | NbOAuth2AuthStrategy.prototype.authorizeRedirect = function () {
|
1377 | this.window.location.href = this.buildRedirectUrl();
|
1378 | };
|
1379 | NbOAuth2AuthStrategy.prototype.isRedirectResult = function () {
|
1380 | return this.redirectResults[this.responseType].call(this);
|
1381 | };
|
1382 | NbOAuth2AuthStrategy.prototype.requestToken = function (code) {
|
1383 | var _this = this;
|
1384 | var module = 'token';
|
1385 | var url = this.getActionEndpoint(module);
|
1386 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1387 | var headers = this.buildAuthHeader() || new _angular_common_http.HttpHeaders();
|
1388 | headers = headers.append('Content-Type', 'application/x-www-form-urlencoded');
|
1389 | return this.http.post(url, this.buildCodeRequestData(code), { headers: headers })
|
1390 | .pipe(rxjs_operators.map(function (res) {
|
1391 | return new NbAuthResult(true, res, _this.getOption('redirect.success'), [], _this.getOption('defaultMessages'), _this.createToken(res, requireValidToken));
|
1392 | }), rxjs_operators.catchError(function (res) { return _this.handleResponseError(res); }));
|
1393 | };
|
1394 | NbOAuth2AuthStrategy.prototype.buildCodeRequestData = function (code) {
|
1395 | var params = {
|
1396 | grant_type: this.getOption('token.grantType'),
|
1397 | code: code,
|
1398 | redirect_uri: this.getOption('token.redirectUri'),
|
1399 | client_id: this.getOption('clientId'),
|
1400 | };
|
1401 | return this.urlEncodeParameters(this.cleanParams(this.addCredentialsToParams(params)));
|
1402 | };
|
1403 | NbOAuth2AuthStrategy.prototype.buildRefreshRequestData = function (token) {
|
1404 | var params = {
|
1405 | grant_type: this.getOption('refresh.grantType'),
|
1406 | refresh_token: token.getRefreshToken(),
|
1407 | scope: this.getOption('refresh.scope'),
|
1408 | client_id: this.getOption('clientId'),
|
1409 | };
|
1410 | return this.urlEncodeParameters(this.cleanParams(this.addCredentialsToParams(params)));
|
1411 | };
|
1412 | NbOAuth2AuthStrategy.prototype.buildPasswordRequestData = function (username, password) {
|
1413 | var params = {
|
1414 | grant_type: this.getOption('token.grantType'),
|
1415 | username: username,
|
1416 | password: password,
|
1417 | scope: this.getOption('token.scope'),
|
1418 | };
|
1419 | return this.urlEncodeParameters(this.cleanParams(this.addCredentialsToParams(params)));
|
1420 | };
|
1421 | NbOAuth2AuthStrategy.prototype.buildAuthHeader = function () {
|
1422 | if (this.clientAuthMethod === exports.NbOAuth2ClientAuthMethod.BASIC) {
|
1423 | if (this.getOption('clientId') && this.getOption('clientSecret')) {
|
1424 | return new _angular_common_http.HttpHeaders({
|
1425 | 'Authorization': 'Basic ' + btoa(this.getOption('clientId') + ':' + this.getOption('clientSecret')),
|
1426 | });
|
1427 | }
|
1428 | else {
|
1429 | throw Error('For basic client authentication method, please provide both clientId & clientSecret.');
|
1430 | }
|
1431 | }
|
1432 | };
|
1433 | NbOAuth2AuthStrategy.prototype.cleanParams = function (params) {
|
1434 | Object.entries(params)
|
1435 | .forEach(function (_a) {
|
1436 | var key = _a[0], val = _a[1];
|
1437 | return !val && delete params[key];
|
1438 | });
|
1439 | return params;
|
1440 | };
|
1441 | NbOAuth2AuthStrategy.prototype.addCredentialsToParams = function (params) {
|
1442 | if (this.clientAuthMethod === exports.NbOAuth2ClientAuthMethod.REQUEST_BODY) {
|
1443 | if (this.getOption('clientId') && this.getOption('clientSecret')) {
|
1444 | return tslib.__assign(tslib.__assign({}, params), { client_id: this.getOption('clientId'), client_secret: this.getOption('clientSecret') });
|
1445 | }
|
1446 | else {
|
1447 | throw Error('For request body client authentication method, please provide both clientId & clientSecret.');
|
1448 | }
|
1449 | }
|
1450 | return params;
|
1451 | };
|
1452 | NbOAuth2AuthStrategy.prototype.handleResponseError = function (res) {
|
1453 | var errors = [];
|
1454 | if (res instanceof _angular_common_http.HttpErrorResponse) {
|
1455 | if (res.error.error_description) {
|
1456 | errors.push(res.error.error_description);
|
1457 | }
|
1458 | else {
|
1459 | errors = this.getOption('defaultErrors');
|
1460 | }
|
1461 | }
|
1462 | else if (res instanceof NbAuthIllegalTokenError) {
|
1463 | errors.push(res.message);
|
1464 | }
|
1465 | else {
|
1466 | errors.push('Something went wrong.');
|
1467 | }
|
1468 |
|
1469 | return rxjs.of(new NbAuthResult(false, res, this.getOption('redirect.failure'), errors, []));
|
1470 | };
|
1471 | NbOAuth2AuthStrategy.prototype.buildRedirectUrl = function () {
|
1472 | var params = tslib.__assign({ response_type: this.getOption('authorize.responseType'), client_id: this.getOption('clientId'), redirect_uri: this.getOption('authorize.redirectUri'), scope: this.getOption('authorize.scope'), state: this.getOption('authorize.state') }, this.getOption('authorize.params'));
|
1473 | var endpoint = this.getActionEndpoint('authorize');
|
1474 | var query = this.urlEncodeParameters(this.cleanParams(params));
|
1475 | return endpoint + "?" + query;
|
1476 | };
|
1477 | NbOAuth2AuthStrategy.prototype.parseHashAsQueryParams = function (hash) {
|
1478 | return hash ? hash.split('&').reduce(function (acc, part) {
|
1479 | var item = part.split('=');
|
1480 | acc[item[0]] = decodeURIComponent(item[1]);
|
1481 | return acc;
|
1482 | }, {}) : {};
|
1483 | };
|
1484 | NbOAuth2AuthStrategy.prototype.urlEncodeParameters = function (params) {
|
1485 | return Object.keys(params).map(function (k) {
|
1486 | return encodeURIComponent(k) + "=" + encodeURIComponent(params[k]);
|
1487 | }).join('&');
|
1488 | };
|
1489 | NbOAuth2AuthStrategy.prototype.createRefreshedToken = function (res, existingToken, requireValidToken) {
|
1490 | var refreshedToken = this.createToken(res, requireValidToken);
|
1491 | if (!refreshedToken.getRefreshToken() && existingToken.getRefreshToken()) {
|
1492 | refreshedToken.setRefreshToken(existingToken.getRefreshToken());
|
1493 | }
|
1494 | return refreshedToken;
|
1495 | };
|
1496 | NbOAuth2AuthStrategy.prototype.register = function (data) {
|
1497 | throw new Error('`register` is not supported by `NbOAuth2AuthStrategy`, use `authenticate`.');
|
1498 | };
|
1499 | NbOAuth2AuthStrategy.prototype.requestPassword = function (data) {
|
1500 | throw new Error('`requestPassword` is not supported by `NbOAuth2AuthStrategy`, use `authenticate`.');
|
1501 | };
|
1502 | NbOAuth2AuthStrategy.prototype.resetPassword = function (data) {
|
1503 | if (data === void 0) { data = {}; }
|
1504 | throw new Error('`resetPassword` is not supported by `NbOAuth2AuthStrategy`, use `authenticate`.');
|
1505 | };
|
1506 | NbOAuth2AuthStrategy.prototype.logout = function () {
|
1507 | return rxjs.of(new NbAuthResult(true));
|
1508 | };
|
1509 | NbOAuth2AuthStrategy.decorators = [
|
1510 | { type: _angular_core.Injectable }
|
1511 | ];
|
1512 | NbOAuth2AuthStrategy.ctorParameters = function () { return [
|
1513 | { type: _angular_common_http.HttpClient },
|
1514 | { type: _angular_router.ActivatedRoute },
|
1515 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_nebular_theme.NB_WINDOW,] }] }
|
1516 | ]; };
|
1517 | return NbOAuth2AuthStrategy;
|
1518 | }(NbAuthStrategy));
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 |
|
1525 | var NbPasswordAuthStrategyOptions = (function (_super) {
|
1526 | tslib.__extends(NbPasswordAuthStrategyOptions, _super);
|
1527 | function NbPasswordAuthStrategyOptions() {
|
1528 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
1529 | _this.baseEndpoint = '/api/auth/';
|
1530 | _this.login = {
|
1531 | alwaysFail: false,
|
1532 | endpoint: 'login',
|
1533 | method: 'post',
|
1534 | requireValidToken: true,
|
1535 | redirect: {
|
1536 | success: '/',
|
1537 | failure: null,
|
1538 | },
|
1539 | defaultErrors: ['Login/Email combination is not correct, please try again.'],
|
1540 | defaultMessages: ['You have been successfully logged in.'],
|
1541 | };
|
1542 | _this.register = {
|
1543 | alwaysFail: false,
|
1544 | endpoint: 'register',
|
1545 | method: 'post',
|
1546 | requireValidToken: true,
|
1547 | redirect: {
|
1548 | success: '/',
|
1549 | failure: null,
|
1550 | },
|
1551 | defaultErrors: ['Something went wrong, please try again.'],
|
1552 | defaultMessages: ['You have been successfully registered.'],
|
1553 | };
|
1554 | _this.requestPass = {
|
1555 | endpoint: 'request-pass',
|
1556 | method: 'post',
|
1557 | redirect: {
|
1558 | success: '/',
|
1559 | failure: null,
|
1560 | },
|
1561 | defaultErrors: ['Something went wrong, please try again.'],
|
1562 | defaultMessages: ['Reset password instructions have been sent to your email.'],
|
1563 | };
|
1564 | _this.resetPass = {
|
1565 | endpoint: 'reset-pass',
|
1566 | method: 'put',
|
1567 | redirect: {
|
1568 | success: '/',
|
1569 | failure: null,
|
1570 | },
|
1571 | resetPasswordTokenKey: 'reset_password_token',
|
1572 | defaultErrors: ['Something went wrong, please try again.'],
|
1573 | defaultMessages: ['Your password has been successfully changed.'],
|
1574 | };
|
1575 | _this.logout = {
|
1576 | alwaysFail: false,
|
1577 | endpoint: 'logout',
|
1578 | method: 'delete',
|
1579 | redirect: {
|
1580 | success: '/',
|
1581 | failure: null,
|
1582 | },
|
1583 | defaultErrors: ['Something went wrong, please try again.'],
|
1584 | defaultMessages: ['You have been successfully logged out.'],
|
1585 | };
|
1586 | _this.refreshToken = {
|
1587 | endpoint: 'refresh-token',
|
1588 | method: 'post',
|
1589 | requireValidToken: true,
|
1590 | redirect: {
|
1591 | success: null,
|
1592 | failure: null,
|
1593 | },
|
1594 | defaultErrors: ['Something went wrong, please try again.'],
|
1595 | defaultMessages: ['Your token has been successfully refreshed.'],
|
1596 | };
|
1597 | _this.token = {
|
1598 | class: NbAuthSimpleToken,
|
1599 | key: 'data.token',
|
1600 | getter: function (module, res, options) { return getDeepFromObject(res.body, options.token.key); },
|
1601 | };
|
1602 | _this.errors = {
|
1603 | key: 'data.errors',
|
1604 | getter: function (module, res, options) { return getDeepFromObject(res.error, options.errors.key, options[module].defaultErrors); },
|
1605 | };
|
1606 | _this.messages = {
|
1607 | key: 'data.messages',
|
1608 | getter: function (module, res, options) { return getDeepFromObject(res.body, options.messages.key, options[module].defaultMessages); },
|
1609 | };
|
1610 | return _this;
|
1611 | }
|
1612 | return NbPasswordAuthStrategyOptions;
|
1613 | }(NbAuthStrategyOptions));
|
1614 | var passwordStrategyOptions = new NbPasswordAuthStrategyOptions();
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 |
|
1635 |
|
1636 |
|
1637 |
|
1638 |
|
1639 |
|
1640 |
|
1641 |
|
1642 |
|
1643 |
|
1644 |
|
1645 |
|
1646 |
|
1647 |
|
1648 |
|
1649 |
|
1650 |
|
1651 |
|
1652 |
|
1653 |
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 |
|
1683 |
|
1684 |
|
1685 |
|
1686 |
|
1687 |
|
1688 |
|
1689 |
|
1690 |
|
1691 |
|
1692 |
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 |
|
1719 |
|
1720 |
|
1721 |
|
1722 |
|
1723 |
|
1724 |
|
1725 |
|
1726 |
|
1727 |
|
1728 |
|
1729 |
|
1730 |
|
1731 |
|
1732 |
|
1733 |
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 | var NbPasswordAuthStrategy = (function (_super) {
|
1746 | tslib.__extends(NbPasswordAuthStrategy, _super);
|
1747 | function NbPasswordAuthStrategy(http, route) {
|
1748 | var _this = _super.call(this) || this;
|
1749 | _this.http = http;
|
1750 | _this.route = route;
|
1751 | _this.defaultOptions = passwordStrategyOptions;
|
1752 | return _this;
|
1753 | }
|
1754 | NbPasswordAuthStrategy.setup = function (options) {
|
1755 | return [NbPasswordAuthStrategy, options];
|
1756 | };
|
1757 | NbPasswordAuthStrategy.prototype.authenticate = function (data) {
|
1758 | var _this = this;
|
1759 | var module = 'login';
|
1760 | var method = this.getOption(module + ".method");
|
1761 | var url = this.getActionEndpoint(module);
|
1762 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1763 | return this.http.request(method, url, { body: data, observe: 'response' })
|
1764 | .pipe(rxjs_operators.map(function (res) {
|
1765 | if (_this.getOption(module + ".alwaysFail")) {
|
1766 | throw _this.createFailResponse(data);
|
1767 | }
|
1768 | return res;
|
1769 | }), rxjs_operators.map(function (res) {
|
1770 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options), _this.createToken(_this.getOption('token.getter')(module, res, _this.options), requireValidToken));
|
1771 | }), rxjs_operators.catchError(function (res) {
|
1772 | return _this.handleResponseError(res, module);
|
1773 | }));
|
1774 | };
|
1775 | NbPasswordAuthStrategy.prototype.register = function (data) {
|
1776 | var _this = this;
|
1777 | var module = 'register';
|
1778 | var method = this.getOption(module + ".method");
|
1779 | var url = this.getActionEndpoint(module);
|
1780 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1781 | return this.http.request(method, url, { body: data, observe: 'response' })
|
1782 | .pipe(rxjs_operators.map(function (res) {
|
1783 | if (_this.getOption(module + ".alwaysFail")) {
|
1784 | throw _this.createFailResponse(data);
|
1785 | }
|
1786 | return res;
|
1787 | }), rxjs_operators.map(function (res) {
|
1788 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options), _this.createToken(_this.getOption('token.getter')('login', res, _this.options), requireValidToken));
|
1789 | }), rxjs_operators.catchError(function (res) {
|
1790 | return _this.handleResponseError(res, module);
|
1791 | }));
|
1792 | };
|
1793 | NbPasswordAuthStrategy.prototype.requestPassword = function (data) {
|
1794 | var _this = this;
|
1795 | var module = 'requestPass';
|
1796 | var method = this.getOption(module + ".method");
|
1797 | var url = this.getActionEndpoint(module);
|
1798 | return this.http.request(method, url, { body: data, observe: 'response' })
|
1799 | .pipe(rxjs_operators.map(function (res) {
|
1800 | if (_this.getOption(module + ".alwaysFail")) {
|
1801 | throw _this.createFailResponse();
|
1802 | }
|
1803 | return res;
|
1804 | }), rxjs_operators.map(function (res) {
|
1805 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
|
1806 | }), rxjs_operators.catchError(function (res) {
|
1807 | return _this.handleResponseError(res, module);
|
1808 | }));
|
1809 | };
|
1810 | NbPasswordAuthStrategy.prototype.resetPassword = function (data) {
|
1811 | var _this = this;
|
1812 | if (data === void 0) { data = {}; }
|
1813 | var module = 'resetPass';
|
1814 | var method = this.getOption(module + ".method");
|
1815 | var url = this.getActionEndpoint(module);
|
1816 | var tokenKey = this.getOption(module + ".resetPasswordTokenKey");
|
1817 | data[tokenKey] = this.route.snapshot.queryParams[tokenKey];
|
1818 | return this.http.request(method, url, { body: data, observe: 'response' })
|
1819 | .pipe(rxjs_operators.map(function (res) {
|
1820 | if (_this.getOption(module + ".alwaysFail")) {
|
1821 | throw _this.createFailResponse();
|
1822 | }
|
1823 | return res;
|
1824 | }), rxjs_operators.map(function (res) {
|
1825 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
|
1826 | }), rxjs_operators.catchError(function (res) {
|
1827 | return _this.handleResponseError(res, module);
|
1828 | }));
|
1829 | };
|
1830 | NbPasswordAuthStrategy.prototype.logout = function () {
|
1831 | var _this = this;
|
1832 | var module = 'logout';
|
1833 | var method = this.getOption(module + ".method");
|
1834 | var url = this.getActionEndpoint(module);
|
1835 | return rxjs.of({})
|
1836 | .pipe(rxjs_operators.switchMap(function (res) {
|
1837 | if (!url) {
|
1838 | return rxjs.of(res);
|
1839 | }
|
1840 | return _this.http.request(method, url, { observe: 'response' });
|
1841 | }), rxjs_operators.map(function (res) {
|
1842 | if (_this.getOption(module + ".alwaysFail")) {
|
1843 | throw _this.createFailResponse();
|
1844 | }
|
1845 | return res;
|
1846 | }), rxjs_operators.map(function (res) {
|
1847 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options));
|
1848 | }), rxjs_operators.catchError(function (res) {
|
1849 | return _this.handleResponseError(res, module);
|
1850 | }));
|
1851 | };
|
1852 | NbPasswordAuthStrategy.prototype.refreshToken = function (data) {
|
1853 | var _this = this;
|
1854 | var module = 'refreshToken';
|
1855 | var method = this.getOption(module + ".method");
|
1856 | var url = this.getActionEndpoint(module);
|
1857 | var requireValidToken = this.getOption(module + ".requireValidToken");
|
1858 | return this.http.request(method, url, { body: data, observe: 'response' })
|
1859 | .pipe(rxjs_operators.map(function (res) {
|
1860 | if (_this.getOption(module + ".alwaysFail")) {
|
1861 | throw _this.createFailResponse(data);
|
1862 | }
|
1863 | return res;
|
1864 | }), rxjs_operators.map(function (res) {
|
1865 | return new NbAuthResult(true, res, _this.getOption(module + ".redirect.success"), [], _this.getOption('messages.getter')(module, res, _this.options), _this.createToken(_this.getOption('token.getter')(module, res, _this.options), requireValidToken));
|
1866 | }), rxjs_operators.catchError(function (res) {
|
1867 | return _this.handleResponseError(res, module);
|
1868 | }));
|
1869 | };
|
1870 | NbPasswordAuthStrategy.prototype.handleResponseError = function (res, module) {
|
1871 | var errors = [];
|
1872 | if (res instanceof _angular_common_http.HttpErrorResponse) {
|
1873 | errors = this.getOption('errors.getter')(module, res, this.options);
|
1874 | }
|
1875 | else if (res instanceof NbAuthIllegalTokenError) {
|
1876 | errors.push(res.message);
|
1877 | }
|
1878 | else {
|
1879 | errors.push('Something went wrong.');
|
1880 | }
|
1881 | return rxjs.of(new NbAuthResult(false, res, this.getOption(module + ".redirect.failure"), errors));
|
1882 | };
|
1883 | NbPasswordAuthStrategy.decorators = [
|
1884 | { type: _angular_core.Injectable }
|
1885 | ];
|
1886 | NbPasswordAuthStrategy.ctorParameters = function () { return [
|
1887 | { type: _angular_common_http.HttpClient },
|
1888 | { type: _angular_router.ActivatedRoute }
|
1889 | ]; };
|
1890 | return NbPasswordAuthStrategy;
|
1891 | }(NbAuthStrategy));
|
1892 |
|
1893 |
|
1894 |
|
1895 |
|
1896 |
|
1897 |
|
1898 | var NbAuthComponent = (function () {
|
1899 |
|
1900 | function NbAuthComponent(auth, location) {
|
1901 | var _this = this;
|
1902 | this.auth = auth;
|
1903 | this.location = location;
|
1904 | this.destroy$ = new rxjs.Subject();
|
1905 | this.authenticated = false;
|
1906 | this.token = '';
|
1907 | this.subscription = auth.onAuthenticationChange()
|
1908 | .pipe(rxjs_operators.takeUntil(this.destroy$))
|
1909 | .subscribe(function (authenticated) {
|
1910 | _this.authenticated = authenticated;
|
1911 | });
|
1912 | }
|
1913 | NbAuthComponent.prototype.back = function () {
|
1914 | this.location.back();
|
1915 | return false;
|
1916 | };
|
1917 | NbAuthComponent.prototype.ngOnDestroy = function () {
|
1918 | this.destroy$.next();
|
1919 | this.destroy$.complete();
|
1920 | };
|
1921 | NbAuthComponent.decorators = [
|
1922 | { type: _angular_core.Component, args: [{
|
1923 | selector: 'nb-auth',
|
1924 | template: "\n <nb-layout>\n <nb-layout-column>\n <nb-card>\n <nb-card-header>\n <nav class=\"navigation\">\n <a href=\"#\" (click)=\"back()\" class=\"link back-link\" aria-label=\"Back\">\n <nb-icon icon=\"arrow-back\"></nb-icon>\n </a>\n </nav>\n </nb-card-header>\n <nb-card-body>\n <nb-auth-block>\n <router-outlet></router-outlet>\n </nb-auth-block>\n </nb-card-body>\n </nb-card>\n </nb-layout-column>\n </nb-layout>\n ",
|
1925 | styles: ["/*!\n * @license\n * Copyright Akveo. All Rights Reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n */:host nb-card{margin:0;height:calc(100vh - 2 * 2.5rem)}:host .navigation .link{display:inline-block;text-decoration:none}:host .navigation .link nb-icon{font-size:2rem;vertical-align:middle}:host .links nb-icon{font-size:2.5rem}:host nb-card-body{display:flex;width:100%}:host nb-auth-block{margin:auto}@media (max-width: 767.98px){:host nb-card{border-radius:0;height:100vh}}:host ::ng-deep nb-layout .layout .layout-container .content .columns nb-layout-column{padding:2.5rem}@media (max-width: 767.98px){:host ::ng-deep nb-layout .layout .layout-container .content .columns nb-layout-column{padding:0}}\n"]
|
1926 | },] }
|
1927 | ];
|
1928 | NbAuthComponent.ctorParameters = function () { return [
|
1929 | { type: NbAuthService },
|
1930 | { type: _angular_common.Location }
|
1931 | ]; };
|
1932 | return NbAuthComponent;
|
1933 | }());
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 | var NbAuthBlockComponent = (function () {
|
1941 | function NbAuthBlockComponent() {
|
1942 | }
|
1943 | NbAuthBlockComponent.decorators = [
|
1944 | { type: _angular_core.Component, args: [{
|
1945 | selector: 'nb-auth-block',
|
1946 | template: "\n <ng-content></ng-content>\n ",
|
1947 | styles: [":host{display:block;width:100%;max-width:35rem}:host ::ng-deep form{width:100%}:host ::ng-deep .label{display:block;margin-bottom:0.5rem}:host ::ng-deep .forgot-password{text-decoration:none;margin-bottom:0.5rem}:host ::ng-deep .caption{margin-top:0.5rem}:host ::ng-deep .alert{text-align:center}:host ::ng-deep .title{margin-top:0;margin-bottom:0.75rem;text-align:center}:host ::ng-deep .sub-title{margin-bottom:2rem;text-align:center}:host ::ng-deep .form-control-group{margin-bottom:2rem}:host ::ng-deep .form-control-group.accept-group{display:flex;justify-content:space-between;margin:2rem 0}:host ::ng-deep .label-with-link{display:flex;justify-content:space-between}:host ::ng-deep .links{text-align:center;margin-top:1.75rem}:host ::ng-deep .links .socials{margin-top:1.5rem}:host ::ng-deep .links .socials a{margin:0 1rem;text-decoration:none;vertical-align:middle}:host ::ng-deep .links .socials a.with-icon{font-size:2rem}:host ::ng-deep .another-action{margin-top:2rem;text-align:center}:host ::ng-deep .sign-in-or-up{margin-top:2rem;display:flex;justify-content:space-between}:host ::ng-deep nb-alert .alert-title,:host ::ng-deep nb-alert .alert-message{margin:0 0 0.5rem}:host ::ng-deep nb-alert .alert-message-list{list-style-type:none;padding:0;margin:0}\n"]
|
1948 | },] }
|
1949 | ];
|
1950 | return NbAuthBlockComponent;
|
1951 | }());
|
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 | var NbLoginComponent = (function () {
|
1959 | function NbLoginComponent(service, options, cd, router) {
|
1960 | if (options === void 0) { options = {}; }
|
1961 | this.service = service;
|
1962 | this.options = options;
|
1963 | this.cd = cd;
|
1964 | this.router = router;
|
1965 | this.redirectDelay = 0;
|
1966 | this.showMessages = {};
|
1967 | this.strategy = '';
|
1968 | this.errors = [];
|
1969 | this.messages = [];
|
1970 | this.user = {};
|
1971 | this.submitted = false;
|
1972 | this.socialLinks = [];
|
1973 | this.rememberMe = false;
|
1974 | this.redirectDelay = this.getConfigValue('forms.login.redirectDelay');
|
1975 | this.showMessages = this.getConfigValue('forms.login.showMessages');
|
1976 | this.strategy = this.getConfigValue('forms.login.strategy');
|
1977 | this.socialLinks = this.getConfigValue('forms.login.socialLinks');
|
1978 | this.rememberMe = this.getConfigValue('forms.login.rememberMe');
|
1979 | }
|
1980 | NbLoginComponent.prototype.login = function () {
|
1981 | var _this = this;
|
1982 | this.errors = [];
|
1983 | this.messages = [];
|
1984 | this.submitted = true;
|
1985 | this.service.authenticate(this.strategy, this.user).subscribe(function (result) {
|
1986 | _this.submitted = false;
|
1987 | if (result.isSuccess()) {
|
1988 | _this.messages = result.getMessages();
|
1989 | }
|
1990 | else {
|
1991 | _this.errors = result.getErrors();
|
1992 | }
|
1993 | var redirect = result.getRedirect();
|
1994 | if (redirect) {
|
1995 | setTimeout(function () {
|
1996 | return _this.router.navigateByUrl(redirect);
|
1997 | }, _this.redirectDelay);
|
1998 | }
|
1999 | _this.cd.detectChanges();
|
2000 | });
|
2001 | };
|
2002 | NbLoginComponent.prototype.getConfigValue = function (key) {
|
2003 | return getDeepFromObject(this.options, key, null);
|
2004 | };
|
2005 | NbLoginComponent.decorators = [
|
2006 | { type: _angular_core.Component, args: [{
|
2007 | selector: 'nb-login',
|
2008 | template: "<h1 id=\"title\" class=\"title\">Login</h1>\n<p class=\"sub-title\">Hello! Log in with your email.</p>\n\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\n <p class=\"alert-title\"><b>Oh snap!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\n </ul>\n</nb-alert>\n\n<nb-alert *ngIf=\"showMessages.success && messages?.length && !submitted\" outline=\"success\" role=\"alert\">\n <p class=\"alert-title\"><b>Hooray!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\n </ul>\n</nb-alert>\n\n<form (ngSubmit)=\"login()\" #form=\"ngForm\" aria-labelledby=\"title\">\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-email\">Email address:</label>\n <input nbInput\n fullWidth\n [(ngModel)]=\"user.email\"\n #email=\"ngModel\"\n name=\"email\"\n id=\"input-email\"\n pattern=\".+@.+\\..+\"\n placeholder=\"Email address\"\n fieldSize=\"large\"\n autofocus\n [status]=\"email.dirty ? (email.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.email.required')\"\n [attr.aria-invalid]=\"email.invalid && email.touched ? true : null\">\n <ng-container *ngIf=\"email.invalid && email.touched\">\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.required\">\n Email is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.pattern\">\n Email should be the real one!\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group\">\n <span class=\"label-with-link\">\n <label class=\"label\" for=\"input-password\">Password:</label>\n <a class=\"forgot-password caption-2\" routerLink=\"../request-password\">Forgot Password?</a>\n </span>\n <input nbInput\n fullWidth\n [(ngModel)]=\"user.password\"\n #password=\"ngModel\"\n name=\"password\"\n type=\"password\"\n id=\"input-password\"\n placeholder=\"Password\"\n fieldSize=\"large\"\n [status]=\"password.dirty ? (password.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.password.required')\"\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\n [attr.aria-invalid]=\"password.invalid && password.touched ? true : null\">\n <ng-container *ngIf=\"password.invalid && password.touched \">\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.required\">\n Password is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.minlength || password.errors?.maxlength\">\n Password should contain\n from {{ getConfigValue('forms.validation.password.minLength') }}\n to {{ getConfigValue('forms.validation.password.maxLength') }}\n characters\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group accept-group\">\n <nb-checkbox name=\"rememberMe\" [(ngModel)]=\"user.rememberMe\" *ngIf=\"rememberMe\">Remember me</nb-checkbox>\n </div>\n\n <button nbButton\n fullWidth\n status=\"primary\"\n size=\"large\"\n [disabled]=\"submitted || !form.valid\"\n [class.btn-pulse]=\"submitted\">\n Log In\n </button>\n</form>\n\n<section *ngIf=\"socialLinks && socialLinks.length > 0\" class=\"links\" aria-label=\"Social sign in\">\n or enter with:\n <div class=\"socials\">\n <ng-container *ngFor=\"let socialLink of socialLinks\">\n <a *ngIf=\"socialLink.link\"\n [routerLink]=\"socialLink.link\"\n [attr.target]=\"socialLink.target\"\n [attr.class]=\"socialLink.icon\"\n [class.with-icon]=\"socialLink.icon\">\n <nb-icon *ngIf=\"socialLink.icon; else title\" [icon]=\"socialLink.icon\"></nb-icon>\n <ng-template #title>{{ socialLink.title }}</ng-template>\n </a>\n <a *ngIf=\"socialLink.url\"\n [attr.href]=\"socialLink.url\"\n [attr.target]=\"socialLink.target\"\n [attr.class]=\"socialLink.icon\"\n [class.with-icon]=\"socialLink.icon\">\n <nb-icon *ngIf=\"socialLink.icon; else title\" [icon]=\"socialLink.icon\"></nb-icon>\n <ng-template #title>{{ socialLink.title }}</ng-template>\n </a>\n </ng-container>\n </div>\n</section>\n\n<section class=\"another-action\" aria-label=\"Register\">\n Don't have an account? <a class=\"text-link\" routerLink=\"../register\">Register</a>\n</section>\n",
|
2009 | changeDetection: _angular_core.ChangeDetectionStrategy.OnPush
|
2010 | },] }
|
2011 | ];
|
2012 | NbLoginComponent.ctorParameters = function () { return [
|
2013 | { type: NbAuthService },
|
2014 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_OPTIONS,] }] },
|
2015 | { type: _angular_core.ChangeDetectorRef },
|
2016 | { type: _angular_router.Router }
|
2017 | ]; };
|
2018 | return NbLoginComponent;
|
2019 | }());
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 | var NbRegisterComponent = (function () {
|
2027 | function NbRegisterComponent(service, options, cd, router) {
|
2028 | if (options === void 0) { options = {}; }
|
2029 | this.service = service;
|
2030 | this.options = options;
|
2031 | this.cd = cd;
|
2032 | this.router = router;
|
2033 | this.redirectDelay = 0;
|
2034 | this.showMessages = {};
|
2035 | this.strategy = '';
|
2036 | this.submitted = false;
|
2037 | this.errors = [];
|
2038 | this.messages = [];
|
2039 | this.user = {};
|
2040 | this.socialLinks = [];
|
2041 | this.redirectDelay = this.getConfigValue('forms.register.redirectDelay');
|
2042 | this.showMessages = this.getConfigValue('forms.register.showMessages');
|
2043 | this.strategy = this.getConfigValue('forms.register.strategy');
|
2044 | this.socialLinks = this.getConfigValue('forms.login.socialLinks');
|
2045 | }
|
2046 | NbRegisterComponent.prototype.register = function () {
|
2047 | var _this = this;
|
2048 | this.errors = this.messages = [];
|
2049 | this.submitted = true;
|
2050 | this.service.register(this.strategy, this.user).subscribe(function (result) {
|
2051 | _this.submitted = false;
|
2052 | if (result.isSuccess()) {
|
2053 | _this.messages = result.getMessages();
|
2054 | }
|
2055 | else {
|
2056 | _this.errors = result.getErrors();
|
2057 | }
|
2058 | var redirect = result.getRedirect();
|
2059 | if (redirect) {
|
2060 | setTimeout(function () {
|
2061 | return _this.router.navigateByUrl(redirect);
|
2062 | }, _this.redirectDelay);
|
2063 | }
|
2064 | _this.cd.detectChanges();
|
2065 | });
|
2066 | };
|
2067 | NbRegisterComponent.prototype.getConfigValue = function (key) {
|
2068 | return getDeepFromObject(this.options, key, null);
|
2069 | };
|
2070 | NbRegisterComponent.decorators = [
|
2071 | { type: _angular_core.Component, args: [{
|
2072 | selector: 'nb-register',
|
2073 | template: "<h1 id=\"title\" class=\"title\">Register</h1>\n\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\n <p class=\"alert-title\"><b>Oh snap!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\n </ul>\n</nb-alert>\n\n<nb-alert *ngIf=\"showMessages.success && messages?.length && !submitted\" outline=\"success\" role=\"alert\">\n <p class=\"alert-title\"><b>Hooray!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\n </ul>\n</nb-alert>\n\n<form (ngSubmit)=\"register()\" #form=\"ngForm\" aria-labelledby=\"title\">\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-name\">Full name:</label>\n <input nbInput\n [(ngModel)]=\"user.fullName\"\n #fullName=\"ngModel\"\n id=\"input-name\"\n name=\"fullName\"\n placeholder=\"Full name\"\n autofocus\n fullWidth\n fieldSize=\"large\"\n [status]=\"fullName.dirty ? (fullName.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.fullName.required')\"\n [minlength]=\"getConfigValue('forms.validation.fullName.minLength')\"\n [maxlength]=\"getConfigValue('forms.validation.fullName.maxLength')\"\n [attr.aria-invalid]=\"fullName.invalid && fullName.touched ? true : null\">\n <ng-container *ngIf=\"fullName.invalid && fullName.touched\">\n <p class=\"caption status-danger\" *ngIf=\"fullName.errors?.required\">\n Full name is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"fullName.errors?.minlength || fullName.errors?.maxlength\">\n Full name should contains\n from {{getConfigValue('forms.validation.fullName.minLength')}}\n to {{getConfigValue('forms.validation.fullName.maxLength')}}\n characters\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-email\">Email address:</label>\n <input nbInput\n [(ngModel)]=\"user.email\"\n #email=\"ngModel\"\n id=\"input-email\"\n name=\"email\"\n pattern=\".+@.+..+\"\n placeholder=\"Email address\"\n fullWidth\n fieldSize=\"large\"\n [status]=\"email.dirty ? (email.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.email.required')\"\n [attr.aria-invalid]=\"email.invalid && email.touched ? true : null\">\n <ng-container *ngIf=\"email.invalid && email.touched\">\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.required\">\n Email is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.pattern\">\n Email should be the real one!\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-password\">Password:</label>\n <input nbInput\n [(ngModel)]=\"user.password\"\n #password=\"ngModel\"\n type=\"password\"\n id=\"input-password\"\n name=\"password\"\n placeholder=\"Password\"\n fullWidth\n fieldSize=\"large\"\n [status]=\"password.dirty ? (password.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.password.required')\"\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\n [attr.aria-invalid]=\"password.invalid && password.touched ? true : null\">\n <ng-container *ngIf=\"password.invalid && password.touched\">\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.required\">\n Password is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.minlength || password.errors?.maxlength\">\n Password should contain\n from {{ getConfigValue('forms.validation.password.minLength') }}\n to {{ getConfigValue('forms.validation.password.maxLength') }}\n characters\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-re-password\">Repeat password:</label>\n <input nbInput\n [(ngModel)]=\"user.confirmPassword\"\n #rePass=\"ngModel\"\n type=\"password\"\n id=\"input-re-password\"\n name=\"rePass\"\n placeholder=\"Confirm Password\"\n fullWidth\n fieldSize=\"large\"\n [status]=\"rePass.dirty ? (rePass.invalid || password.value != rePass.value ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.password.required')\"\n [attr.aria-invalid]=\"rePass.invalid && rePass.touched ? true : null\">\n <ng-container *ngIf=\"rePass.invalid && rePass.touched\">\n <p class=\"caption status-danger\" *ngIf=\"rePass.errors?.required\">\n Password confirmation is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"password.value != rePass.value && !rePass.errors?.required\">\n Password does not match the confirm password.\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-control-group accept-group\" *ngIf=\"getConfigValue('forms.register.terms')\">\n <nb-checkbox name=\"terms\" [(ngModel)]=\"user.terms\" [required]=\"getConfigValue('forms.register.terms')\">\n Agree to <a href=\"#\" target=\"_blank\"><strong>Terms & Conditions</strong></a>\n </nb-checkbox>\n </div>\n\n <button nbButton\n fullWidth\n status=\"primary\"\n size=\"large\"\n [disabled]=\"submitted || !form.valid\"\n [class.btn-pulse]=\"submitted\">\n Register\n </button>\n</form>\n\n<section *ngIf=\"socialLinks && socialLinks.length > 0\" class=\"links\" aria-label=\"Social sign in\">\n or enter with:\n <div class=\"socials\">\n <ng-container *ngFor=\"let socialLink of socialLinks\">\n <a *ngIf=\"socialLink.link\"\n [routerLink]=\"socialLink.link\"\n [attr.target]=\"socialLink.target\"\n [attr.class]=\"socialLink.icon\"\n [class.with-icon]=\"socialLink.icon\">\n <nb-icon *ngIf=\"socialLink.icon; else title\" [icon]=\"socialLink.icon\"></nb-icon>\n <ng-template #title>{{ socialLink.title }}</ng-template>\n </a>\n <a *ngIf=\"socialLink.url\"\n [attr.href]=\"socialLink.url\"\n [attr.target]=\"socialLink.target\"\n [attr.class]=\"socialLink.icon\"\n [class.with-icon]=\"socialLink.icon\">\n <nb-icon *ngIf=\"socialLink.icon; else title\" [icon]=\"socialLink.icon\"></nb-icon>\n <ng-template #title>{{ socialLink.title }}</ng-template>\n </a>\n </ng-container>\n </div>\n</section>\n\n<section class=\"another-action\" aria-label=\"Sign in\">\n Already have an account? <a class=\"text-link\" routerLink=\"../login\">Log in</a>\n</section>\n",
|
2074 | changeDetection: _angular_core.ChangeDetectionStrategy.OnPush,
|
2075 | styles: [":host .title{margin-bottom:2rem}\n"]
|
2076 | },] }
|
2077 | ];
|
2078 | NbRegisterComponent.ctorParameters = function () { return [
|
2079 | { type: NbAuthService },
|
2080 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_OPTIONS,] }] },
|
2081 | { type: _angular_core.ChangeDetectorRef },
|
2082 | { type: _angular_router.Router }
|
2083 | ]; };
|
2084 | return NbRegisterComponent;
|
2085 | }());
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 | var NbLogoutComponent = (function () {
|
2093 | function NbLogoutComponent(service, options, router) {
|
2094 | if (options === void 0) { options = {}; }
|
2095 | this.service = service;
|
2096 | this.options = options;
|
2097 | this.router = router;
|
2098 | this.redirectDelay = 0;
|
2099 | this.strategy = '';
|
2100 | this.redirectDelay = this.getConfigValue('forms.logout.redirectDelay');
|
2101 | this.strategy = this.getConfigValue('forms.logout.strategy');
|
2102 | }
|
2103 | NbLogoutComponent.prototype.ngOnInit = function () {
|
2104 | this.logout(this.strategy);
|
2105 | };
|
2106 | NbLogoutComponent.prototype.logout = function (strategy) {
|
2107 | var _this = this;
|
2108 | this.service.logout(strategy).subscribe(function (result) {
|
2109 | var redirect = result.getRedirect();
|
2110 | if (redirect) {
|
2111 | setTimeout(function () {
|
2112 | return _this.router.navigateByUrl(redirect);
|
2113 | }, _this.redirectDelay);
|
2114 | }
|
2115 | });
|
2116 | };
|
2117 | NbLogoutComponent.prototype.getConfigValue = function (key) {
|
2118 | return getDeepFromObject(this.options, key, null);
|
2119 | };
|
2120 | NbLogoutComponent.decorators = [
|
2121 | { type: _angular_core.Component, args: [{
|
2122 | selector: 'nb-logout',
|
2123 | template: "<div>Logging out, please wait...</div>\n"
|
2124 | },] }
|
2125 | ];
|
2126 | NbLogoutComponent.ctorParameters = function () { return [
|
2127 | { type: NbAuthService },
|
2128 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_OPTIONS,] }] },
|
2129 | { type: _angular_router.Router }
|
2130 | ]; };
|
2131 | return NbLogoutComponent;
|
2132 | }());
|
2133 |
|
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 | var NbRequestPasswordComponent = (function () {
|
2140 | function NbRequestPasswordComponent(service, options, cd, router) {
|
2141 | if (options === void 0) { options = {}; }
|
2142 | this.service = service;
|
2143 | this.options = options;
|
2144 | this.cd = cd;
|
2145 | this.router = router;
|
2146 | this.redirectDelay = 0;
|
2147 | this.showMessages = {};
|
2148 | this.strategy = '';
|
2149 | this.submitted = false;
|
2150 | this.errors = [];
|
2151 | this.messages = [];
|
2152 | this.user = {};
|
2153 | this.redirectDelay = this.getConfigValue('forms.requestPassword.redirectDelay');
|
2154 | this.showMessages = this.getConfigValue('forms.requestPassword.showMessages');
|
2155 | this.strategy = this.getConfigValue('forms.requestPassword.strategy');
|
2156 | }
|
2157 | NbRequestPasswordComponent.prototype.requestPass = function () {
|
2158 | var _this = this;
|
2159 | this.errors = this.messages = [];
|
2160 | this.submitted = true;
|
2161 | this.service.requestPassword(this.strategy, this.user).subscribe(function (result) {
|
2162 | _this.submitted = false;
|
2163 | if (result.isSuccess()) {
|
2164 | _this.messages = result.getMessages();
|
2165 | }
|
2166 | else {
|
2167 | _this.errors = result.getErrors();
|
2168 | }
|
2169 | var redirect = result.getRedirect();
|
2170 | if (redirect) {
|
2171 | setTimeout(function () {
|
2172 | return _this.router.navigateByUrl(redirect);
|
2173 | }, _this.redirectDelay);
|
2174 | }
|
2175 | _this.cd.detectChanges();
|
2176 | });
|
2177 | };
|
2178 | NbRequestPasswordComponent.prototype.getConfigValue = function (key) {
|
2179 | return getDeepFromObject(this.options, key, null);
|
2180 | };
|
2181 | NbRequestPasswordComponent.decorators = [
|
2182 | { type: _angular_core.Component, args: [{
|
2183 | selector: 'nb-request-password-page',
|
2184 | template: "<h1 id=\"title\" class=\"title\">Forgot Password</h1>\n<p class=\"sub-title\">Enter your email address and we\u2019ll send a link to reset your password</p>\n\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\n <p class=\"alert-title\"><b>Oh snap!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\n </ul>\n</nb-alert>\n\n<nb-alert *ngIf=\"showMessages.success && messages?.length && !submitted\" outline=\"success\" role=\"alert\">\n <p class=\"alert-title\"><b>Hooray!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\n </ul>\n</nb-alert>\n\n<form (ngSubmit)=\"requestPass()\" #requestPassForm=\"ngForm\" aria-labelledby=\"title\">\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-email\">Enter your email address:</label>\n <input nbInput\n [(ngModel)]=\"user.email\"\n #email=\"ngModel\"\n id=\"input-email\"\n name=\"email\"\n pattern=\".+@.+\\..+\"\n placeholder=\"Email address\"\n autofocus\n fullWidth\n fieldSize=\"large\"\n [status]=\"email.dirty ? (email.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.email.required')\"\n [attr.aria-invalid]=\"email.invalid && email.touched ? true : null\">\n <ng-container *ngIf=\"email.invalid && email.touched\">\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.required\">\n Email is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"email.errors?.pattern\">\n Email should be the real one!\n </p>\n </ng-container>\n </div>\n\n <button nbButton\n fullWidth\n status=\"primary\"\n size=\"large\"\n [disabled]=\"submitted || !requestPassForm.valid\"\n [class.btn-pulse]=\"submitted\">\n Request password\n </button>\n</form>\n\n<section class=\"sign-in-or-up\" aria-label=\"Sign in or sign up\">\n <p><a class=\"text-link\" routerLink=\"../login\">Back to Log In</a></p>\n <p><a routerLink=\"../register\" class=\"text-link\">Register</a></p>\n</section>\n",
|
2185 | changeDetection: _angular_core.ChangeDetectionStrategy.OnPush,
|
2186 | styles: [":host .form-group:last-of-type{margin-bottom:3rem}\n"]
|
2187 | },] }
|
2188 | ];
|
2189 | NbRequestPasswordComponent.ctorParameters = function () { return [
|
2190 | { type: NbAuthService },
|
2191 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_OPTIONS,] }] },
|
2192 | { type: _angular_core.ChangeDetectorRef },
|
2193 | { type: _angular_router.Router }
|
2194 | ]; };
|
2195 | return NbRequestPasswordComponent;
|
2196 | }());
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 |
|
2203 | var NbResetPasswordComponent = (function () {
|
2204 | function NbResetPasswordComponent(service, options, cd, router) {
|
2205 | if (options === void 0) { options = {}; }
|
2206 | this.service = service;
|
2207 | this.options = options;
|
2208 | this.cd = cd;
|
2209 | this.router = router;
|
2210 | this.redirectDelay = 0;
|
2211 | this.showMessages = {};
|
2212 | this.strategy = '';
|
2213 | this.submitted = false;
|
2214 | this.errors = [];
|
2215 | this.messages = [];
|
2216 | this.user = {};
|
2217 | this.redirectDelay = this.getConfigValue('forms.resetPassword.redirectDelay');
|
2218 | this.showMessages = this.getConfigValue('forms.resetPassword.showMessages');
|
2219 | this.strategy = this.getConfigValue('forms.resetPassword.strategy');
|
2220 | }
|
2221 | NbResetPasswordComponent.prototype.resetPass = function () {
|
2222 | var _this = this;
|
2223 | this.errors = this.messages = [];
|
2224 | this.submitted = true;
|
2225 | this.service.resetPassword(this.strategy, this.user).subscribe(function (result) {
|
2226 | _this.submitted = false;
|
2227 | if (result.isSuccess()) {
|
2228 | _this.messages = result.getMessages();
|
2229 | }
|
2230 | else {
|
2231 | _this.errors = result.getErrors();
|
2232 | }
|
2233 | var redirect = result.getRedirect();
|
2234 | if (redirect) {
|
2235 | setTimeout(function () {
|
2236 | return _this.router.navigateByUrl(redirect);
|
2237 | }, _this.redirectDelay);
|
2238 | }
|
2239 | _this.cd.detectChanges();
|
2240 | });
|
2241 | };
|
2242 | NbResetPasswordComponent.prototype.getConfigValue = function (key) {
|
2243 | return getDeepFromObject(this.options, key, null);
|
2244 | };
|
2245 | NbResetPasswordComponent.decorators = [
|
2246 | { type: _angular_core.Component, args: [{
|
2247 | selector: 'nb-reset-password-page',
|
2248 | template: "<h1 id=\"title\" class=\"title\">Change password</h1>\n<p class=\"sub-title\">Please set a new password</p>\n\n<nb-alert *ngIf=\"showMessages.error && errors?.length && !submitted\" outline=\"danger\" role=\"alert\">\n <p class=\"alert-title\"><b>Oh snap!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let error of errors\" class=\"alert-message\">{{ error }}</li>\n </ul>\n</nb-alert>\n\n<nb-alert *ngIf=\"showMessages.success && messages?.length && !submitted\" outline=\"success\" role=\"alert\">\n <p class=\"alert-title\"><b>Hooray!</b></p>\n <ul class=\"alert-message-list\">\n <li *ngFor=\"let message of messages\" class=\"alert-message\">{{ message }}</li>\n </ul>\n</nb-alert>\n\n<form (ngSubmit)=\"resetPass()\" #resetPassForm=\"ngForm\" aria-labelledby=\"title\">\n\n <div class=\"form-control-group\">\n <label class=\"label\" for=\"input-password\">New Password:</label>\n <input nbInput\n [(ngModel)]=\"user.password\"\n #password=\"ngModel\"\n type=\"password\"\n id=\"input-password\"\n name=\"password\"\n class=\"first\"\n placeholder=\"New Password\"\n autofocus\n fullWidth\n fieldSize=\"large\"\n [status]=\"password.dirty ? (password.invalid ? 'danger' : 'success') : 'basic'\"\n [required]=\"getConfigValue('forms.validation.password.required')\"\n [minlength]=\"getConfigValue('forms.validation.password.minLength')\"\n [maxlength]=\"getConfigValue('forms.validation.password.maxLength')\"\n [attr.aria-invalid]=\"password.invalid && password.touched ? true : null\">\n <ng-container *ngIf=\"password.invalid && password.touched\">\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.required\">\n Password is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"password.errors?.minlength || password.errors?.maxlength\">\n Password should contains\n from {{getConfigValue('forms.validation.password.minLength')}}\n to {{getConfigValue('forms.validation.password.maxLength')}}\n characters\n </p>\n </ng-container>\n </div>\n\n <div class=\"form-group\">\n <label class=\"label\" for=\"input-re-password\">Confirm Password:</label>\n <input nbInput\n [(ngModel)]=\"user.confirmPassword\"\n #rePass=\"ngModel\"\n id=\"input-re-password\"\n name=\"rePass\"\n type=\"password\"\n class=\"last\"\n placeholder=\"Confirm Password\"\n fullWidth\n fieldSize=\"large\"\n [status]=\"rePass.touched\n ? (rePass.invalid || password.value != rePass.value ? 'danger' : 'success')\n : 'basic'\"\n [required]=\"getConfigValue('forms.validation.password.required')\"\n [attr.aria-invalid]=\"rePass.invalid && rePass.touched ? true : null\">\n <ng-container *ngIf=\"rePass.touched\">\n <p class=\"caption status-danger\" *ngIf=\"rePass.invalid && rePass.errors?.required\">\n Password confirmation is required!\n </p>\n <p class=\"caption status-danger\" *ngIf=\"password.value != rePass.value && !rePass.errors?.required\">\n Password does not match the confirm password.\n </p>\n </ng-container>\n </div>\n\n <button nbButton\n status=\"primary\"\n fullWidth\n size=\"large\"\n [disabled]=\"submitted || !resetPassForm.valid\"\n [class.btn-pulse]=\"submitted\">\n Change password\n </button>\n</form>\n\n<section class=\"sign-in-or-up\" aria-label=\"Sign in or sign up\">\n <p><a class=\"text-link\" routerLink=\"../login\">Back to Log In</a></p>\n <p><a class=\"text-link\" routerLink=\"../register\">Register</a></p>\n</section>\n",
|
2249 | changeDetection: _angular_core.ChangeDetectionStrategy.OnPush,
|
2250 | styles: [":host .form-group:last-of-type{margin-bottom:3rem}\n"]
|
2251 | },] }
|
2252 | ];
|
2253 | NbResetPasswordComponent.ctorParameters = function () { return [
|
2254 | { type: NbAuthService },
|
2255 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_OPTIONS,] }] },
|
2256 | { type: _angular_core.ChangeDetectorRef },
|
2257 | { type: _angular_router.Router }
|
2258 | ]; };
|
2259 | return NbResetPasswordComponent;
|
2260 | }());
|
2261 |
|
2262 | function nbStrategiesFactory(options, injector) {
|
2263 | var strategies = [];
|
2264 | options.strategies
|
2265 | .forEach(function (_a) {
|
2266 | var strategyClass = _a[0], strategyOptions = _a[1];
|
2267 | var strategy = injector.get(strategyClass);
|
2268 | strategy.setOptions(strategyOptions);
|
2269 | strategies.push(strategy);
|
2270 | });
|
2271 | return strategies;
|
2272 | }
|
2273 | function nbTokensFactory(strategies) {
|
2274 | var tokens = [];
|
2275 | strategies
|
2276 | .forEach(function (strategy) {
|
2277 | tokens.push(strategy.getOption('token.class'));
|
2278 | });
|
2279 | return tokens;
|
2280 | }
|
2281 | function nbOptionsFactory(options) {
|
2282 | return deepExtend(defaultAuthOptions, options);
|
2283 | }
|
2284 | function nbNoOpInterceptorFilter(req) {
|
2285 | return true;
|
2286 | }
|
2287 | var NbAuthModule = (function () {
|
2288 | function NbAuthModule() {
|
2289 | }
|
2290 | NbAuthModule.forRoot = function (nbAuthOptions) {
|
2291 | return {
|
2292 | ngModule: NbAuthModule,
|
2293 | providers: [
|
2294 | { provide: NB_AUTH_USER_OPTIONS, useValue: nbAuthOptions },
|
2295 | { provide: NB_AUTH_OPTIONS, useFactory: nbOptionsFactory, deps: [NB_AUTH_USER_OPTIONS] },
|
2296 | { provide: NB_AUTH_STRATEGIES, useFactory: nbStrategiesFactory, deps: [NB_AUTH_OPTIONS, _angular_core.Injector] },
|
2297 | { provide: NB_AUTH_TOKENS, useFactory: nbTokensFactory, deps: [NB_AUTH_STRATEGIES] },
|
2298 | { provide: NB_AUTH_FALLBACK_TOKEN, useValue: NbAuthSimpleToken },
|
2299 | { provide: NB_AUTH_INTERCEPTOR_HEADER, useValue: 'Authorization' },
|
2300 | { provide: NB_AUTH_TOKEN_INTERCEPTOR_FILTER, useValue: nbNoOpInterceptorFilter },
|
2301 | { provide: NbTokenStorage, useClass: NbTokenLocalStorage },
|
2302 | NbAuthTokenParceler,
|
2303 | NbAuthService,
|
2304 | NbTokenService,
|
2305 | NbDummyAuthStrategy,
|
2306 | NbPasswordAuthStrategy,
|
2307 | NbOAuth2AuthStrategy,
|
2308 | ],
|
2309 | };
|
2310 | };
|
2311 | NbAuthModule.decorators = [
|
2312 | { type: _angular_core.NgModule, args: [{
|
2313 | imports: [
|
2314 | _angular_common.CommonModule,
|
2315 | _nebular_theme.NbLayoutModule,
|
2316 | _nebular_theme.NbCardModule,
|
2317 | _nebular_theme.NbCheckboxModule,
|
2318 | _nebular_theme.NbAlertModule,
|
2319 | _nebular_theme.NbInputModule,
|
2320 | _nebular_theme.NbButtonModule,
|
2321 | _angular_router.RouterModule,
|
2322 | _angular_forms.FormsModule,
|
2323 | _nebular_theme.NbIconModule,
|
2324 | ],
|
2325 | declarations: [
|
2326 | NbAuthComponent,
|
2327 | NbAuthBlockComponent,
|
2328 | NbLoginComponent,
|
2329 | NbRegisterComponent,
|
2330 | NbRequestPasswordComponent,
|
2331 | NbResetPasswordComponent,
|
2332 | NbLogoutComponent,
|
2333 | ],
|
2334 | exports: [
|
2335 | NbAuthComponent,
|
2336 | NbAuthBlockComponent,
|
2337 | NbLoginComponent,
|
2338 | NbRegisterComponent,
|
2339 | NbRequestPasswordComponent,
|
2340 | NbResetPasswordComponent,
|
2341 | NbLogoutComponent,
|
2342 | ],
|
2343 | },] }
|
2344 | ];
|
2345 | return NbAuthModule;
|
2346 | }());
|
2347 |
|
2348 | var routes = [
|
2349 | {
|
2350 | path: 'auth',
|
2351 | component: NbAuthComponent,
|
2352 | children: [
|
2353 | {
|
2354 | path: '',
|
2355 | component: NbLoginComponent,
|
2356 | },
|
2357 | {
|
2358 | path: 'login',
|
2359 | component: NbLoginComponent,
|
2360 | },
|
2361 | {
|
2362 | path: 'register',
|
2363 | component: NbRegisterComponent,
|
2364 | },
|
2365 | {
|
2366 | path: 'logout',
|
2367 | component: NbLogoutComponent,
|
2368 | },
|
2369 | {
|
2370 | path: 'request-password',
|
2371 | component: NbRequestPasswordComponent,
|
2372 | },
|
2373 | {
|
2374 | path: 'reset-password',
|
2375 | component: NbResetPasswordComponent,
|
2376 | },
|
2377 | ],
|
2378 | },
|
2379 | ];
|
2380 |
|
2381 | var NbAuthJWTInterceptor = (function () {
|
2382 | function NbAuthJWTInterceptor(injector, filter$$1) {
|
2383 | this.injector = injector;
|
2384 | this.filter = filter$$1;
|
2385 | }
|
2386 | NbAuthJWTInterceptor.prototype.intercept = function (req, next) {
|
2387 | var _this = this;
|
2388 |
|
2389 | if (!this.filter(req)) {
|
2390 | return this.authService.isAuthenticatedOrRefresh()
|
2391 | .pipe(rxjs_operators.switchMap(function (authenticated) {
|
2392 | if (authenticated) {
|
2393 | return _this.authService.getToken().pipe(rxjs_operators.switchMap(function (token) {
|
2394 | var JWT = "Bearer " + token.getValue();
|
2395 | req = req.clone({
|
2396 | setHeaders: {
|
2397 | Authorization: JWT,
|
2398 | },
|
2399 | });
|
2400 | return next.handle(req);
|
2401 | }));
|
2402 | }
|
2403 | else {
|
2404 |
|
2405 |
|
2406 | return next.handle(req);
|
2407 | }
|
2408 | }));
|
2409 | }
|
2410 | else {
|
2411 | return next.handle(req);
|
2412 | }
|
2413 | };
|
2414 | Object.defineProperty(NbAuthJWTInterceptor.prototype, "authService", {
|
2415 | get: function () {
|
2416 | return this.injector.get(NbAuthService);
|
2417 | },
|
2418 | enumerable: false,
|
2419 | configurable: true
|
2420 | });
|
2421 | NbAuthJWTInterceptor.decorators = [
|
2422 | { type: _angular_core.Injectable }
|
2423 | ];
|
2424 | NbAuthJWTInterceptor.ctorParameters = function () { return [
|
2425 | { type: _angular_core.Injector },
|
2426 | { type: undefined, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_TOKEN_INTERCEPTOR_FILTER,] }] }
|
2427 | ]; };
|
2428 | return NbAuthJWTInterceptor;
|
2429 | }());
|
2430 |
|
2431 | var NbAuthSimpleInterceptor = (function () {
|
2432 | function NbAuthSimpleInterceptor(injector, headerName) {
|
2433 | if (headerName === void 0) { headerName = 'Authorization'; }
|
2434 | this.injector = injector;
|
2435 | this.headerName = headerName;
|
2436 | }
|
2437 | NbAuthSimpleInterceptor.prototype.intercept = function (req, next) {
|
2438 | var _this = this;
|
2439 | return this.authService.getToken()
|
2440 | .pipe(rxjs_operators.switchMap(function (token) {
|
2441 | var _a;
|
2442 | if (token && token.getValue()) {
|
2443 | req = req.clone({
|
2444 | setHeaders: (_a = {},
|
2445 | _a[_this.headerName] = token.getValue(),
|
2446 | _a),
|
2447 | });
|
2448 | }
|
2449 | return next.handle(req);
|
2450 | }));
|
2451 | };
|
2452 | Object.defineProperty(NbAuthSimpleInterceptor.prototype, "authService", {
|
2453 | get: function () {
|
2454 | return this.injector.get(NbAuthService);
|
2455 | },
|
2456 | enumerable: false,
|
2457 | configurable: true
|
2458 | });
|
2459 | NbAuthSimpleInterceptor.decorators = [
|
2460 | { type: _angular_core.Injectable }
|
2461 | ];
|
2462 | NbAuthSimpleInterceptor.ctorParameters = function () { return [
|
2463 | { type: _angular_core.Injector },
|
2464 | { type: String, decorators: [{ type: _angular_core.Inject, args: [NB_AUTH_INTERCEPTOR_HEADER,] }] }
|
2465 | ]; };
|
2466 | return NbAuthSimpleInterceptor;
|
2467 | }());
|
2468 |
|
2469 | var NbUser = (function () {
|
2470 | function NbUser(id, email, password, rememberMe, terms, confirmPassword, fullName) {
|
2471 | this.id = id;
|
2472 | this.email = email;
|
2473 | this.password = password;
|
2474 | this.rememberMe = rememberMe;
|
2475 | this.terms = terms;
|
2476 | this.confirmPassword = confirmPassword;
|
2477 | this.fullName = fullName;
|
2478 | }
|
2479 | return NbUser;
|
2480 | }());
|
2481 |
|
2482 |
|
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 |
|
2492 | exports.defaultAuthOptions = defaultAuthOptions;
|
2493 | exports.NB_AUTH_OPTIONS = NB_AUTH_OPTIONS;
|
2494 | exports.NB_AUTH_USER_OPTIONS = NB_AUTH_USER_OPTIONS;
|
2495 | exports.NB_AUTH_STRATEGIES = NB_AUTH_STRATEGIES;
|
2496 | exports.NB_AUTH_TOKENS = NB_AUTH_TOKENS;
|
2497 | exports.NB_AUTH_INTERCEPTOR_HEADER = NB_AUTH_INTERCEPTOR_HEADER;
|
2498 | exports.NB_AUTH_TOKEN_INTERCEPTOR_FILTER = NB_AUTH_TOKEN_INTERCEPTOR_FILTER;
|
2499 | exports.nbStrategiesFactory = nbStrategiesFactory;
|
2500 | exports.nbTokensFactory = nbTokensFactory;
|
2501 | exports.nbOptionsFactory = nbOptionsFactory;
|
2502 | exports.nbNoOpInterceptorFilter = nbNoOpInterceptorFilter;
|
2503 | exports.NbAuthModule = NbAuthModule;
|
2504 | exports.routes = routes;
|
2505 | exports.NbAuthComponent = NbAuthComponent;
|
2506 | exports.NbAuthBlockComponent = NbAuthBlockComponent;
|
2507 | exports.NbLoginComponent = NbLoginComponent;
|
2508 | exports.NbLogoutComponent = NbLogoutComponent;
|
2509 | exports.NbRegisterComponent = NbRegisterComponent;
|
2510 | exports.NbRequestPasswordComponent = NbRequestPasswordComponent;
|
2511 | exports.NbResetPasswordComponent = NbResetPasswordComponent;
|
2512 | exports.NbAuthService = NbAuthService;
|
2513 | exports.NbAuthResult = NbAuthResult;
|
2514 | exports.NbAuthJWTInterceptor = NbAuthJWTInterceptor;
|
2515 | exports.NbAuthSimpleInterceptor = NbAuthSimpleInterceptor;
|
2516 | exports.NbAuthToken = NbAuthToken;
|
2517 | exports.NbAuthTokenNotFoundError = NbAuthTokenNotFoundError;
|
2518 | exports.NbAuthIllegalTokenError = NbAuthIllegalTokenError;
|
2519 | exports.NbAuthEmptyTokenError = NbAuthEmptyTokenError;
|
2520 | exports.NbAuthIllegalJWTTokenError = NbAuthIllegalJWTTokenError;
|
2521 | exports.nbAuthCreateToken = nbAuthCreateToken;
|
2522 | exports.decodeJwtPayload = decodeJwtPayload;
|
2523 | exports.NbAuthSimpleToken = NbAuthSimpleToken;
|
2524 | exports.NbAuthJWTToken = NbAuthJWTToken;
|
2525 | exports.NbAuthOAuth2Token = NbAuthOAuth2Token;
|
2526 | exports.NbAuthOAuth2JWTToken = NbAuthOAuth2JWTToken;
|
2527 | exports.ɵ0 = ɵ0;
|
2528 | exports.NbTokenStorage = NbTokenStorage;
|
2529 | exports.NbTokenLocalStorage = NbTokenLocalStorage;
|
2530 | exports.NbTokenService = NbTokenService;
|
2531 | exports.NB_AUTH_FALLBACK_TOKEN = NB_AUTH_FALLBACK_TOKEN;
|
2532 | exports.NbAuthTokenParceler = NbAuthTokenParceler;
|
2533 | exports.NbAuthStrategy = NbAuthStrategy;
|
2534 | exports.NbAuthStrategyOptions = NbAuthStrategyOptions;
|
2535 | exports.NbDummyAuthStrategy = NbDummyAuthStrategy;
|
2536 | exports.NbDummyAuthStrategyOptions = NbDummyAuthStrategyOptions;
|
2537 | exports.dummyStrategyOptions = dummyStrategyOptions;
|
2538 | exports.NbPasswordAuthStrategy = NbPasswordAuthStrategy;
|
2539 | exports.NbPasswordAuthStrategyOptions = NbPasswordAuthStrategyOptions;
|
2540 | exports.passwordStrategyOptions = passwordStrategyOptions;
|
2541 | exports.NbOAuth2AuthStrategy = NbOAuth2AuthStrategy;
|
2542 | exports.NbOAuth2AuthStrategyOptions = NbOAuth2AuthStrategyOptions;
|
2543 | exports.auth2StrategyOptions = auth2StrategyOptions;
|
2544 | exports.NbUser = NbUser;
|
2545 | exports.deepExtend = deepExtend;
|
2546 | exports.getDeepFromObject = getDeepFromObject;
|
2547 | exports.urlBase64Decode = urlBase64Decode;
|
2548 | exports.b64decode = b64decode;
|
2549 | exports.b64DecodeUnicode = b64DecodeUnicode;
|
2550 |
|
2551 | Object.defineProperty(exports, '__esModule', { value: true });
|
2552 |
|
2553 | })));
|