@huntsman-cancer-institute/user 12.3.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/authorization/role-check-unless-null.directive.d.ts +1 -1
  2. package/authorization/role-check.directive.d.ts +1 -1
  3. package/esm2020/authorization/permission.entity.mjs +45 -0
  4. package/esm2020/authorization/role-check-unless-null.directive.mjs +62 -0
  5. package/esm2020/authorization/role-check.directive.mjs +66 -0
  6. package/{esm5/authorization/role.entity.js → esm2020/authorization/role.entity.mjs} +23 -33
  7. package/esm2020/huntsman-cancer-institute-user.mjs +5 -0
  8. package/esm2020/index.mjs +20 -0
  9. package/esm2020/user.entity.mjs +70 -0
  10. package/esm2020/user.module.mjs +53 -0
  11. package/esm2020/user.service.mjs +98 -0
  12. package/fesm2015/huntsman-cancer-institute-user.mjs +427 -0
  13. package/fesm2015/huntsman-cancer-institute-user.mjs.map +1 -0
  14. package/{fesm2015/huntsman-cancer-institute-user.js → fesm2020/huntsman-cancer-institute-user.mjs} +27 -23
  15. package/fesm2020/huntsman-cancer-institute-user.mjs.map +1 -0
  16. package/package.json +24 -16
  17. package/CHANGELOG.md +0 -4
  18. package/bundles/huntsman-cancer-institute-user.umd.js +0 -500
  19. package/bundles/huntsman-cancer-institute-user.umd.js.map +0 -1
  20. package/bundles/huntsman-cancer-institute-user.umd.min.js +0 -2
  21. package/bundles/huntsman-cancer-institute-user.umd.min.js.map +0 -1
  22. package/esm2015/authorization/permission.entity.js +0 -45
  23. package/esm2015/authorization/role-check-unless-null.directive.js +0 -62
  24. package/esm2015/authorization/role-check.directive.js +0 -66
  25. package/esm2015/authorization/role.entity.js +0 -32
  26. package/esm2015/huntsman-cancer-institute-user.js +0 -5
  27. package/esm2015/index.js +0 -20
  28. package/esm2015/user.entity.js +0 -70
  29. package/esm2015/user.module.js +0 -55
  30. package/esm2015/user.service.js +0 -98
  31. package/esm5/authorization/permission.entity.js +0 -59
  32. package/esm5/authorization/role-check-unless-null.directive.js +0 -87
  33. package/esm5/authorization/role-check.directive.js +0 -73
  34. package/esm5/huntsman-cancer-institute-user.js +0 -5
  35. package/esm5/index.js +0 -20
  36. package/esm5/user.entity.js +0 -96
  37. package/esm5/user.module.js +0 -59
  38. package/esm5/user.service.js +0 -101
  39. package/fesm2015/huntsman-cancer-institute-user.js.map +0 -1
  40. package/fesm5/huntsman-cancer-institute-user.js +0 -499
  41. package/fesm5/huntsman-cancer-institute-user.js.map +0 -1
  42. package/huntsman-cancer-institute-user.d.ts +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huntsman-cancer-institute/user",
3
- "version": "12.3.0",
3
+ "version": "15.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@gitlab.com:huntsman-cancer-institute/risr/ng/hci-ng-lib.git"
@@ -10,22 +10,30 @@
10
10
  "access": "public"
11
11
  },
12
12
  "peerDependencies": {
13
- "@angular/common": ">=12.2.0",
14
- "@angular/core": ">=12.2.0"
13
+ "@angular/common": "^14.3.0",
14
+ "@angular/core": "^14.3.0"
15
+ },
16
+ "module": "fesm2015/huntsman-cancer-institute-user.mjs",
17
+ "es2020": "fesm2020/huntsman-cancer-institute-user.mjs",
18
+ "esm2020": "esm2020/huntsman-cancer-institute-user.mjs",
19
+ "fesm2020": "fesm2020/huntsman-cancer-institute-user.mjs",
20
+ "fesm2015": "fesm2015/huntsman-cancer-institute-user.mjs",
21
+ "typings": "index.d.ts",
22
+ "exports": {
23
+ "./package.json": {
24
+ "default": "./package.json"
25
+ },
26
+ ".": {
27
+ "types": "./index.d.ts",
28
+ "esm2020": "./esm2020/huntsman-cancer-institute-user.mjs",
29
+ "es2020": "./fesm2020/huntsman-cancer-institute-user.mjs",
30
+ "es2015": "./fesm2015/huntsman-cancer-institute-user.mjs",
31
+ "node": "./fesm2015/huntsman-cancer-institute-user.mjs",
32
+ "default": "./fesm2020/huntsman-cancer-institute-user.mjs"
33
+ }
15
34
  },
16
- "main": "bundles/huntsman-cancer-institute-user.umd.js",
17
- "module": "fesm5/huntsman-cancer-institute-user.js",
18
- "es2015": "fesm2015/huntsman-cancer-institute-user.js",
19
- "esm5": "esm5/huntsman-cancer-institute-user.js",
20
- "esm2015": "esm2015/huntsman-cancer-institute-user.js",
21
- "fesm5": "fesm5/huntsman-cancer-institute-user.js",
22
- "fesm2015": "fesm2015/huntsman-cancer-institute-user.js",
23
- "typings": "huntsman-cancer-institute-user.d.ts",
24
35
  "sideEffects": false,
25
36
  "dependencies": {
26
- "tslib": "^2.2.0"
27
- },
28
- "scripts": {
29
- "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\\nPlease delete and rebuild the package, without compiling with Ivy, before attempting to publish.\\n')\" && exit 1"
37
+ "tslib": "^2.3.0"
30
38
  }
31
- }
39
+ }
package/CHANGELOG.md DELETED
@@ -1,4 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
@@ -1,500 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@huntsman-cancer-institute/user', ['exports', '@angular/core', '@angular/common', '@angular/forms', '@angular/common/http', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = global || self, factory((global['huntsman-cancer-institute'] = global['huntsman-cancer-institute'] || {}, global['huntsman-cancer-institute'].user = {}), global.ng.core, global.ng.common, global.ng.forms, global.ng.common.http, global.rxjs, global.rxjs.operators));
5
- }(this, (function (exports, i0, common, forms, http, rxjs, operators) { 'use strict';
6
-
7
- /**
8
- * An immutable representation of an HCI user entity.
9
- *
10
- * @since 1.0.0
11
- */
12
- var UserEntity = /** @class */ (function () {
13
- function UserEntity(id, username, roles, firstname, lastname, href) {
14
- this.id = id;
15
- this.username = username;
16
- this.roles = roles;
17
- this.firstname = firstname;
18
- this.lastname = lastname;
19
- this.href = href;
20
- }
21
- Object.defineProperty(UserEntity.prototype, "Id", {
22
- /**
23
- * An accessor for the users system id.
24
- *
25
- * @returns {string} the system id
26
- * @constructor
27
- */
28
- get: function () {
29
- return this.id;
30
- },
31
- enumerable: false,
32
- configurable: true
33
- });
34
- Object.defineProperty(UserEntity.prototype, "Username", {
35
- /**
36
- * An accessor for the users application identifier/username.
37
- *
38
- * @returns {string} the application id/username
39
- * @constructor
40
- */
41
- get: function () {
42
- return this.username;
43
- },
44
- enumerable: false,
45
- configurable: true
46
- });
47
- Object.defineProperty(UserEntity.prototype, "Roles", {
48
- /**
49
- * An accessor for the users assigned role authorization claims.
50
- *
51
- * @returns {@code RoleEntity[]} the role authorization claims
52
- * @constructor
53
- */
54
- get: function () {
55
- return this.roles;
56
- },
57
- enumerable: false,
58
- configurable: true
59
- });
60
- Object.defineProperty(UserEntity.prototype, "Firstname", {
61
- /**
62
- * An accessor for the users firstname.
63
- *
64
- * @return {string} the firstname
65
- * @constructor
66
- */
67
- get: function () {
68
- return this.firstname;
69
- },
70
- enumerable: false,
71
- configurable: true
72
- });
73
- Object.defineProperty(UserEntity.prototype, "Lastname", {
74
- /**
75
- * A accessor for the users lastname.
76
- *
77
- * @return {string} the lastname
78
- * @constructor
79
- */
80
- get: function () {
81
- return this.lastname;
82
- },
83
- enumerable: false,
84
- configurable: true
85
- });
86
- Object.defineProperty(UserEntity.prototype, "Href", {
87
- /**
88
- * A access for the users fully qualified href location on the system.
89
- *
90
- * @return {string} the href location
91
- * @constructor
92
- */
93
- get: function () {
94
- return this.href;
95
- },
96
- enumerable: false,
97
- configurable: true
98
- });
99
- return UserEntity;
100
- }());
101
-
102
- /**
103
- * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated
104
- * subject.
105
- *
106
- * @since 1.0.0
107
- */
108
- var RoleEntity = /** @class */ (function () {
109
- function RoleEntity(roleName, permissions) {
110
- this.roleName = roleName;
111
- this.permissions = permissions;
112
- }
113
- Object.defineProperty(RoleEntity.prototype, "RoleName", {
114
- /**
115
- * An accessor for the name of this role.
116
- *
117
- * @returns {string} the role name
118
- * @constructor
119
- */
120
- get: function () {
121
- return this.roleName;
122
- },
123
- enumerable: false,
124
- configurable: true
125
- });
126
- Object.defineProperty(RoleEntity.prototype, "Permissions", {
127
- /**
128
- * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions
129
- * provide a finer grained authorization claim description and are not required.
130
- *
131
- * @returns {PermissionEntity[]} a collection of permission entities
132
- * @constructor
133
- */
134
- get: function () {
135
- return this.permissions;
136
- },
137
- enumerable: false,
138
- configurable: true
139
- });
140
- return RoleEntity;
141
- }());
142
-
143
- /*
144
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
145
- */
146
- /**
147
- * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can
148
- * define a {@link RoleEntity}.
149
- *
150
- * @since 1.0.0
151
- */
152
- var PermissionEntity = /** @class */ (function () {
153
- function PermissionEntity(domain, actions, instances) {
154
- this.domain = domain;
155
- this.actions = actions;
156
- this.instances = instances;
157
- }
158
- Object.defineProperty(PermissionEntity.prototype, "Domain", {
159
- /**
160
- * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).
161
- *
162
- * @returns {string} the domain of this permission
163
- * @constructor
164
- */
165
- get: function () {
166
- return this.domain;
167
- },
168
- enumerable: false,
169
- configurable: true
170
- });
171
- Object.defineProperty(PermissionEntity.prototype, "Actions", {
172
- /**
173
- * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage
174
- * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
175
- *
176
- * @returns {string[]} an array of actions for the specified domain
177
- * @constructor
178
- */
179
- get: function () {
180
- return this.actions;
181
- },
182
- enumerable: false,
183
- configurable: true
184
- });
185
- Object.defineProperty(PermissionEntity.prototype, "Instances", {
186
- /**
187
- * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,
188
- * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.
189
- * @returns {string[]}
190
- * @constructor
191
- */
192
- get: function () {
193
- return this.instances;
194
- },
195
- enumerable: false,
196
- configurable: true
197
- });
198
- return PermissionEntity;
199
- }());
200
-
201
- /*
202
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
203
- */
204
- var AUTHENTICATED_USER_ENDPOINT = new i0.InjectionToken("authenticated_user_url");
205
- /**
206
- * @since 1.0.0
207
- */
208
- var UserService = /** @class */ (function () {
209
- function UserService(_http, _authenticationUserEndpoint) {
210
- this._http = _http;
211
- this._authenticationUserEndpoint = _authenticationUserEndpoint;
212
- this._authenticatedUser = null;
213
- }
214
- /**
215
- * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is
216
- * available, the appropriate response status should be returned from the server to indicate that condition
217
- * (i.e. 404 - Not Found).
218
- *
219
- * @returns {Observable<UserEntity>} the currently authenticated user representation
220
- */
221
- UserService.prototype.getAuthenticatedUser = function () {
222
- var _this = this;
223
- if (i0.isDevMode() && console && console.debug) {
224
- console.debug("getAuthenticatedUser");
225
- }
226
- if (!this._authenticatedUser) {
227
- if (i0.isDevMode() && console && console.debug) {
228
- console.debug("_authenticationUserEndpoint: " + this._authenticationUserEndpoint);
229
- }
230
- return this._http.get(this._authenticationUserEndpoint, { observe: "response" }).pipe(operators.map(function (resp) {
231
- if (resp.status === 200) {
232
- _this._authenticatedUser = _this.buildUserEntity(resp.body);
233
- return _this._authenticatedUser;
234
- }
235
- else {
236
- throw new Error("Get authenticated user failed. " + resp.status + ": " + resp.statusText);
237
- }
238
- }), operators.catchError(this.handleError));
239
- }
240
- else {
241
- return rxjs.of(this._authenticatedUser);
242
- }
243
- };
244
- UserService.prototype.handleError = function (error) {
245
- var errMsg = (error.message) ? error.message : UserService.GENERIC_ERR_MSG;
246
- return rxjs.Observable.throw(errMsg);
247
- };
248
- /**
249
- * TODO: Add in a deserializer into the entity.
250
- *
251
- * @param userJson
252
- * @returns {UserEntity}
253
- */
254
- UserService.prototype.buildUserEntity = function (userJson) {
255
- var roles = [];
256
- if (userJson.roles) {
257
- userJson.roles.map(function (role) {
258
- var permissions;
259
- if (role.permissions) {
260
- /* TODO: JEH (10/27/16) - Revisit when we determine how permission are communicated to the client, if necessary */
261
- permissions = role.permissions.map(function (permission) {
262
- return new PermissionEntity(permission.domain, permission.actions, permission.instances);
263
- });
264
- }
265
- roles.push(new RoleEntity(role.roleName, permissions));
266
- });
267
- }
268
- return new UserEntity(userJson.idUser, userJson.username, roles, userJson.firstname, userJson.lastname, userJson.href);
269
- };
270
- UserService.prototype.getPermissions = function (governorClass, governorId, governedClass) {
271
- var headers = new http.HttpHeaders()
272
- .set("SecurityGovernorClass", governorClass).set("SecurityGovernorId", String(governorId));
273
- return this._http.get("/core/api/user/permissions/" + governedClass, { headers: headers });
274
- };
275
- /**
276
- * The generic error message used when a server error is thrown without a status.
277
- *
278
- * @type {string}
279
- */
280
- UserService.GENERIC_ERR_MSG = "Server error";
281
- UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserService, deps: [{ token: http.HttpClient }, { token: AUTHENTICATED_USER_ENDPOINT }], target: i0.ɵɵFactoryTarget.Injectable });
282
- UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserService });
283
- return UserService;
284
- }());
285
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserService, decorators: [{
286
- type: i0.Injectable
287
- }], ctorParameters: function () { return [{ type: http.HttpClient }, { type: undefined, decorators: [{
288
- type: i0.Inject,
289
- args: [AUTHENTICATED_USER_ENDPOINT]
290
- }] }]; } });
291
-
292
- /*
293
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
294
- */
295
- /**
296
- * A structural directive for adding and removing elements of the client application based on a users <em>role</em>
297
- * authorization claims.
298
- *
299
- * This directive requires the {@link UserService} as a provider.
300
- *
301
- * @since 1.0.0
302
- */
303
- var RoleCheckDirective = /** @class */ (function () {
304
- function RoleCheckDirective(_viewContainer, _templateRef, _usrSvc) {
305
- this._viewContainer = _viewContainer;
306
- this._templateRef = _templateRef;
307
- this._usrSvc = _usrSvc;
308
- this._lastCheck = null;
309
- }
310
- Object.defineProperty(RoleCheckDirective.prototype, "hciHasRole", {
311
- /**
312
- * Calculates the availability of a decorated element based on the authenticated users available roles.
313
- *
314
- * @param roleName for the role required to make the decorated element available
315
- */
316
- set: function (roleName) {
317
- var _this = this;
318
- if (i0.isDevMode() && console && console.debug) {
319
- console.debug("hciHasRole");
320
- }
321
- this._usrSvc.getAuthenticatedUser().subscribe(function (authUser) {
322
- var found;
323
- if (authUser && authUser.Roles) {
324
- found = authUser.Roles.some(function (role) {
325
- return role.RoleName === roleName;
326
- });
327
- }
328
- else {
329
- found = false;
330
- }
331
- if (found && (_this._lastCheck === null || !_this._lastCheck)) {
332
- _this._viewContainer.createEmbeddedView(_this._templateRef);
333
- }
334
- else if (!found && (_this._lastCheck === null || _this._lastCheck)) {
335
- _this._viewContainer.clear();
336
- }
337
- }, function (error) {
338
- // TODO: BHY (08/19/16) - Determine requirements around errors and then REMOVE CONSOLE LOGGING. Display to user,
339
- // log to external source, gobble?
340
- // Gobble up the error.
341
- });
342
- },
343
- enumerable: false,
344
- configurable: true
345
- });
346
- RoleCheckDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RoleCheckDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive });
347
- RoleCheckDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: RoleCheckDirective, selector: "[hciHasRole]", inputs: { hciHasRole: "hciHasRole" }, providers: [UserService], ngImport: i0 });
348
- return RoleCheckDirective;
349
- }());
350
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RoleCheckDirective, decorators: [{
351
- type: i0.Directive,
352
- args: [{
353
- selector: "[hciHasRole]",
354
- providers: [UserService]
355
- }]
356
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }]; }, propDecorators: { hciHasRole: [{
357
- type: i0.Input
358
- }] } });
359
-
360
- var __extends = (this && this.__extends) || (function () {
361
- var extendStatics = function (d, b) {
362
- extendStatics = Object.setPrototypeOf ||
363
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
364
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
365
- return extendStatics(d, b);
366
- };
367
- return function (d, b) {
368
- if (typeof b !== "function" && b !== null)
369
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
370
- extendStatics(d, b);
371
- function __() { this.constructor = d; }
372
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
373
- };
374
- })();
375
- /**
376
- * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.
377
- *
378
- * This directive requires the {@link UserService} as a provider.
379
- *
380
- * @since 1.0.0
381
- */
382
- var RoleCheckUnlessNullDirective = /** @class */ (function (_super) {
383
- __extends(RoleCheckUnlessNullDirective, _super);
384
- function RoleCheckUnlessNullDirective(_viewContainer, _templateRef, _usrSvc) {
385
- var _this = _super.call(this, _viewContainer, _templateRef, _usrSvc) || this;
386
- _this._context = new HciHasRoleUnlessNullContext();
387
- return _this;
388
- }
389
- Object.defineProperty(RoleCheckUnlessNullDirective.prototype, "hciHasRoleUnlessNull", {
390
- set: function (roleName) {
391
- if (!roleName) {
392
- // if the roleName is undefined or null then render
393
- if (this._context._condition !== true) {
394
- this._context._condition = true;
395
- this._updateView();
396
- }
397
- }
398
- else {
399
- // otherwise delegate the check to RoleCheckDirective
400
- this.hciHasRole = roleName;
401
- }
402
- },
403
- enumerable: false,
404
- configurable: true
405
- });
406
- RoleCheckUnlessNullDirective.prototype._updateView = function () {
407
- this._viewContainer.clear();
408
- if (this._context._condition) {
409
- this._viewContainer.createEmbeddedView(this._templateRef, this._context);
410
- }
411
- else {
412
- this._viewContainer.createEmbeddedView(this._templateRef, this._context);
413
- }
414
- };
415
- RoleCheckUnlessNullDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RoleCheckUnlessNullDirective, deps: [{ token: i0.ViewContainerRef }, { token: i0.TemplateRef }, { token: UserService }], target: i0.ɵɵFactoryTarget.Directive });
416
- RoleCheckUnlessNullDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: RoleCheckUnlessNullDirective, selector: "[hciHasRoleUnlessNull]", inputs: { hciHasRoleUnlessNull: "hciHasRoleUnlessNull" }, usesInheritance: true, ngImport: i0 });
417
- return RoleCheckUnlessNullDirective;
418
- }(RoleCheckDirective));
419
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RoleCheckUnlessNullDirective, decorators: [{
420
- type: i0.Directive,
421
- args: [{
422
- selector: "[hciHasRoleUnlessNull]"
423
- }]
424
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: UserService }]; }, propDecorators: { hciHasRoleUnlessNull: [{
425
- type: i0.Input
426
- }] } });
427
- /**
428
- * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.
429
- */
430
- var HciHasRoleUnlessNullContext = /** @class */ (function () {
431
- function HciHasRoleUnlessNullContext() {
432
- this._condition = false;
433
- }
434
- return HciHasRoleUnlessNullContext;
435
- }());
436
-
437
- /*
438
- * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
439
- */
440
- /**
441
- * A feature module for user related services, directives, pipes, etc...
442
- *
443
- * @since 1.0.0
444
- */
445
- var UserModule = /** @class */ (function () {
446
- function UserModule() {
447
- }
448
- UserModule.forRoot = function () {
449
- return {
450
- providers: [
451
- UserService
452
- ],
453
- ngModule: UserModule
454
- };
455
- };
456
- UserModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
457
- UserModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserModule, declarations: [RoleCheckDirective,
458
- RoleCheckUnlessNullDirective], imports: [common.CommonModule,
459
- forms.ReactiveFormsModule,
460
- forms.FormsModule], exports: [RoleCheckDirective,
461
- RoleCheckUnlessNullDirective] });
462
- UserModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserModule, imports: [[
463
- common.CommonModule,
464
- forms.ReactiveFormsModule,
465
- forms.FormsModule
466
- ]] });
467
- return UserModule;
468
- }());
469
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: UserModule, decorators: [{
470
- type: i0.NgModule,
471
- args: [{
472
- imports: [
473
- common.CommonModule,
474
- forms.ReactiveFormsModule,
475
- forms.FormsModule
476
- ],
477
- declarations: [
478
- RoleCheckDirective,
479
- RoleCheckUnlessNullDirective
480
- ],
481
- exports: [
482
- RoleCheckDirective,
483
- RoleCheckUnlessNullDirective
484
- ]
485
- }]
486
- }] });
487
-
488
- exports.AUTHENTICATED_USER_ENDPOINT = AUTHENTICATED_USER_ENDPOINT;
489
- exports.PermissionEntity = PermissionEntity;
490
- exports.RoleCheckDirective = RoleCheckDirective;
491
- exports.RoleCheckUnlessNullDirective = RoleCheckUnlessNullDirective;
492
- exports.RoleEntity = RoleEntity;
493
- exports.UserEntity = UserEntity;
494
- exports.UserModule = UserModule;
495
- exports.UserService = UserService;
496
-
497
- Object.defineProperty(exports, '__esModule', { value: true });
498
-
499
- })));
500
- //# sourceMappingURL=huntsman-cancer-institute-user.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"huntsman-cancer-institute-user.umd.js","sources":["ng://@huntsman-cancer-institute/user/user.entity.ts","ng://@huntsman-cancer-institute/user/authorization/role.entity.ts","ng://@huntsman-cancer-institute/user/authorization/permission.entity.ts","ng://@huntsman-cancer-institute/user/user.service.ts","ng://@huntsman-cancer-institute/user/authorization/role-check.directive.ts","ng://@huntsman-cancer-institute/user/authorization/role-check-unless-null.directive.ts","ng://@huntsman-cancer-institute/user/user.module.ts"],"sourcesContent":["/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {RoleEntity} from \"./authorization/role.entity\";\r\n\r\n/**\r\n * An immutable representation of an HCI user entity.\r\n *\r\n * @since 1.0.0\r\n */\r\nexport class UserEntity {\r\n constructor(private id: string,\r\n private username: string,\r\n private roles?: RoleEntity[],\r\n private firstname?: string,\r\n private lastname?: string,\r\n private href?: string) {\r\n }\r\n\r\n /**\r\n * An accessor for the users system id.\r\n *\r\n * @returns {string} the system id\r\n * @constructor\r\n */\r\n get Id(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * An accessor for the users application identifier/username.\r\n *\r\n * @returns {string} the application id/username\r\n * @constructor\r\n */\r\n get Username(): string {\r\n return this.username;\r\n }\r\n\r\n /**\r\n * An accessor for the users assigned role authorization claims.\r\n *\r\n * @returns {@code RoleEntity[]} the role authorization claims\r\n * @constructor\r\n */\r\n get Roles(): RoleEntity[] {\r\n return this.roles;\r\n }\r\n\r\n /**\r\n * An accessor for the users firstname.\r\n *\r\n * @return {string} the firstname\r\n * @constructor\r\n */\r\n get Firstname(): string {\r\n return this.firstname;\r\n }\r\n\r\n /**\r\n * A accessor for the users lastname.\r\n *\r\n * @return {string} the lastname\r\n * @constructor\r\n */\r\n get Lastname(): string {\r\n return this.lastname;\r\n }\r\n\r\n /**\r\n * A access for the users fully qualified href location on the system.\r\n *\r\n * @return {string} the href location\r\n * @constructor\r\n */\r\n get Href(): string {\r\n return this.href;\r\n }\r\n\r\n}\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {PermissionEntity} from \"./permission.entity\";\r\n\r\n/**\r\n * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated\r\n * subject.\r\n *\r\n * @since 1.0.0\r\n */\r\nexport class RoleEntity {\r\n constructor( private roleName: string, private permissions?: PermissionEntity[]) {}\r\n\r\n /**\r\n * An accessor for the name of this role.\r\n *\r\n * @returns {string} the role name\r\n * @constructor\r\n */\r\n get RoleName(): string {\r\n return this.roleName;\r\n }\r\n\r\n /**\r\n * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions\r\n * provide a finer grained authorization claim description and are not required.\r\n *\r\n * @returns {PermissionEntity[]} a collection of permission entities\r\n * @constructor\r\n */\r\n get Permissions(): PermissionEntity[] {\r\n return this.permissions;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\n/**\r\n * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can\r\n * define a {@link RoleEntity}.\r\n *\r\n * @since 1.0.0\r\n */\r\nexport class PermissionEntity {\r\n constructor(private domain: string, private actions?: string[], private instances?: string[]) {\r\n }\r\n\r\n /**\r\n * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).\r\n *\r\n * @returns {string} the domain of this permission\r\n * @constructor\r\n */\r\n get Domain(): string {\r\n return this.domain;\r\n }\r\n\r\n /**\r\n * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage\r\n * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.\r\n *\r\n * @returns {string[]} an array of actions for the specified domain\r\n * @constructor\r\n */\r\n get Actions(): string[] {\r\n return this.actions;\r\n }\r\n\r\n /**\r\n * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,\r\n * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.\r\n * @returns {string[]}\r\n * @constructor\r\n */\r\n get Instances(): string[] {\r\n return this.instances;\r\n }\r\n}\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {Injectable, InjectionToken, Inject, isDevMode} from \"@angular/core\";\r\nimport {HttpClient, HttpResponse, HttpHeaders} from \"@angular/common/http\";\r\n\r\nimport {Observable, of} from \"rxjs\";\r\nimport {catchError, map} from \"rxjs/operators\";\r\n\r\nimport {UserEntity} from \"./user.entity\";\r\nimport {RoleEntity} from \"./authorization/role.entity\";\r\nimport {PermissionEntity} from \"./authorization/permission.entity\";\r\n\r\nexport let AUTHENTICATED_USER_ENDPOINT = new InjectionToken<string>(\"authenticated_user_url\");\r\n\r\n/**\r\n * @since 1.0.0\r\n */\r\n@Injectable()\r\nexport class UserService {\r\n /**\r\n * The generic error message used when a server error is thrown without a status.\r\n *\r\n * @type {string}\r\n */\r\n public static GENERIC_ERR_MSG: string = \"Server error\";\r\n\r\n private _authenticatedUser: UserEntity = null;\r\n\r\n constructor(private _http: HttpClient, @Inject(AUTHENTICATED_USER_ENDPOINT) private _authenticationUserEndpoint: string) {}\r\n\r\n /**\r\n * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is\r\n * available, the appropriate response status should be returned from the server to indicate that condition\r\n * (i.e. 404 - Not Found).\r\n *\r\n * @returns {Observable<UserEntity>} the currently authenticated user representation\r\n */\r\n public getAuthenticatedUser(): Observable<UserEntity> {\r\n if (isDevMode() && <any>console && <any>console.debug) {\r\n console.debug(\"getAuthenticatedUser\");\r\n }\r\n\r\n if (!this._authenticatedUser) {\r\n if (isDevMode() && <any>console && <any>console.debug) {\r\n console.debug(\"_authenticationUserEndpoint: \" + this._authenticationUserEndpoint);\r\n }\r\n\r\n return this._http.get(this._authenticationUserEndpoint, { observe: \"response\" }).pipe(map((resp: HttpResponse<any>) => {\r\n if (resp.status === 200) {\r\n this._authenticatedUser = this.buildUserEntity(resp.body);\r\n return this._authenticatedUser;\r\n } else {\r\n throw new Error(\"Get authenticated user failed. \" + resp.status + \": \" + resp.statusText);\r\n }\r\n }),\r\n catchError(this.handleError));\r\n } else {\r\n return of(this._authenticatedUser);\r\n }\r\n }\r\n\r\n private handleError(error: any) {\r\n let errMsg = (error.message) ? error.message : UserService.GENERIC_ERR_MSG;\r\n\r\n return Observable.throw(errMsg);\r\n }\r\n\r\n /**\r\n * TODO: Add in a deserializer into the entity.\r\n *\r\n * @param userJson\r\n * @returns {UserEntity}\r\n */\r\n private buildUserEntity(userJson: any): UserEntity {\r\n let roles: RoleEntity[] = [];\r\n if (userJson.roles) {\r\n userJson.roles.map((role: any) => {\r\n let permissions: PermissionEntity[];\r\n if (role.permissions) {\r\n /* TODO: JEH (10/27/16) - Revisit when we determine how permission are communicated to the client, if necessary */\r\n permissions = role.permissions.map((permission: any) => {\r\n return new PermissionEntity(permission.domain, permission.actions, permission.instances);\r\n });\r\n }\r\n roles.push(new RoleEntity(role.roleName, permissions));\r\n });\r\n }\r\n\r\n return new UserEntity(userJson.idUser, userJson.username, roles, userJson.firstname, userJson.lastname, userJson.href);\r\n }\r\n \r\n public getPermissions(governorClass: string, governorId: number, governedClass: string): Observable<any> {\r\n let headers = new HttpHeaders()\r\n .set(\"SecurityGovernorClass\", governorClass).set(\"SecurityGovernorId\", String(governorId));\r\n return this._http.get(\"/core/api/user/permissions/\" + governedClass, {headers: headers});\r\n }\r\n}\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {Directive, Input, TemplateRef, ViewContainerRef, isDevMode} from \"@angular/core\";\r\n\r\nimport {UserService} from \"../user.service\";\r\nimport {UserEntity} from \"../user.entity\";\r\n\r\n/**\r\n * A structural directive for adding and removing elements of the client application based on a users <em>role</em>\r\n * authorization claims.\r\n *\r\n * This directive requires the {@link UserService} as a provider.\r\n *\r\n * @since 1.0.0\r\n */\r\n@Directive({\r\n selector: \"[hciHasRole]\",\r\n providers: [UserService]\r\n})\r\nexport class RoleCheckDirective {\r\n protected _lastCheck: boolean = null;\r\n\r\n constructor(protected _viewContainer: ViewContainerRef,\r\n protected _templateRef: TemplateRef<Object>,\r\n protected _usrSvc: UserService) {\r\n }\r\n\r\n /**\r\n * Calculates the availability of a decorated element based on the authenticated users available roles.\r\n *\r\n * @param roleName for the role required to make the decorated element available\r\n */\r\n @Input()\r\n set hciHasRole(roleName: string) {\r\n if (isDevMode() && <any>console && <any>console.debug) {\r\n console.debug(\"hciHasRole\");\r\n }\r\n\r\n this._usrSvc.getAuthenticatedUser().subscribe((authUser: UserEntity) => {\r\n let found: boolean;\r\n\r\n if (authUser && authUser.Roles) {\r\n found = authUser.Roles.some((role) => {\r\n return role.RoleName === roleName;\r\n });\r\n } else {\r\n found = false;\r\n }\r\n\r\n if (found && (this._lastCheck === null || !this._lastCheck)) {\r\n this._viewContainer.createEmbeddedView(this._templateRef);\r\n } else if (!found && (this._lastCheck === null || this._lastCheck)) {\r\n this._viewContainer.clear();\r\n }\r\n }, (error) => {\r\n // TODO: BHY (08/19/16) - Determine requirements around errors and then REMOVE CONSOLE LOGGING. Display to user,\r\n // log to external source, gobble?\r\n // Gobble up the error.\r\n });\r\n }\r\n}\r\n\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {Directive, Input, ViewContainerRef, TemplateRef} from \"@angular/core\";\r\nimport {RoleCheckDirective} from \"./role-check.directive\";\r\nimport {UserService} from \"../user.service\";\r\n\r\n/**\r\n * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.\r\n *\r\n * This directive requires the {@link UserService} as a provider.\r\n *\r\n * @since 1.0.0\r\n */\r\n@Directive({\r\n selector: \"[hciHasRoleUnlessNull]\"\r\n})\r\nexport class RoleCheckUnlessNullDirective extends RoleCheckDirective {\r\n\r\n private _context: HciHasRoleUnlessNullContext = new HciHasRoleUnlessNullContext();\r\n\r\n constructor(\r\n _viewContainer: ViewContainerRef,\r\n _templateRef: TemplateRef<Object>,\r\n _usrSvc: UserService) {\r\n super(_viewContainer, _templateRef, _usrSvc);\r\n }\r\n\r\n @Input()\r\n set hciHasRoleUnlessNull(roleName: string) {\r\n if (!roleName) {\r\n // if the roleName is undefined or null then render\r\n if (this._context._condition !== true) {\r\n this._context._condition = true;\r\n this._updateView();\r\n }\r\n } else {\r\n // otherwise delegate the check to RoleCheckDirective\r\n this.hciHasRole = roleName;\r\n }\r\n }\r\n\r\n private _updateView() {\r\n this._viewContainer.clear();\r\n if (this._context._condition) {\r\n this._viewContainer.createEmbeddedView(this._templateRef, this._context);\r\n } else {\r\n this._viewContainer.createEmbeddedView(this._templateRef, this._context);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.\r\n */\r\nexport class HciHasRoleUnlessNullContext {\r\n public _condition: boolean = false;\r\n}\r\n","/*\r\n * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary\r\n */\r\nimport {ModuleWithProviders, NgModule} from \"@angular/core\";\r\nimport {CommonModule} from \"@angular/common\";\r\nimport {ReactiveFormsModule, FormsModule} from \"@angular/forms\";\r\n\r\nimport {UserService} from \"./user.service\";\r\nimport {RoleCheckDirective} from \"./authorization/role-check.directive\";\r\nimport {RoleCheckUnlessNullDirective} from \"./authorization/role-check-unless-null.directive\";\r\n\r\n/**\r\n * A feature module for user related services, directives, pipes, etc...\r\n *\r\n * @since 1.0.0\r\n */\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n ReactiveFormsModule,\r\n FormsModule\r\n ],\r\n declarations: [\r\n RoleCheckDirective,\r\n RoleCheckUnlessNullDirective\r\n ],\r\n exports: [\r\n RoleCheckDirective,\r\n RoleCheckUnlessNullDirective\r\n ]\r\n})\r\nexport class UserModule {\r\n static forRoot(): ModuleWithProviders<UserModule> {\r\n return {\r\n providers: [\r\n UserService\r\n ],\r\n ngModule: UserModule\r\n };\r\n }\r\n}\r\n"],"names":["InjectionToken","isDevMode","map","catchError","of","Observable","HttpHeaders","Injectable","Inject","Directive","Input","CommonModule","ReactiveFormsModule","FormsModule","NgModule"],"mappings":";;;;;;IAKA;;;;;;QAME,oBAAoB,EAAU,EACV,QAAgB,EAChB,KAAoB,EACpB,SAAkB,EAClB,QAAiB,EACjB,IAAa;YALb,OAAE,GAAF,EAAE,CAAQ;YACV,aAAQ,GAAR,QAAQ,CAAQ;YAChB,UAAK,GAAL,KAAK,CAAe;YACpB,cAAS,GAAT,SAAS,CAAS;YAClB,aAAQ,GAAR,QAAQ,CAAS;YACjB,SAAI,GAAJ,IAAI,CAAS;SAChC;QAQD,sBAAI,0BAAE;;;;;;;iBAAN;gBACE,OAAO,IAAI,CAAC,EAAE,CAAC;aAChB;;;WAAA;QAQD,sBAAI,gCAAQ;;;;;;;iBAAZ;gBACE,OAAO,IAAI,CAAC,QAAQ,CAAC;aACtB;;;WAAA;QAQD,sBAAI,6BAAK;;;;;;;iBAAT;gBACE,OAAO,IAAI,CAAC,KAAK,CAAC;aACnB;;;WAAA;QAQD,sBAAI,iCAAS;;;;;;;iBAAb;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC;aACvB;;;WAAA;QAQD,sBAAI,gCAAQ;;;;;;;iBAAZ;gBACE,OAAO,IAAI,CAAC,QAAQ,CAAC;aACtB;;;WAAA;QAQD,sBAAI,4BAAI;;;;;;;iBAAR;gBACE,OAAO,IAAI,CAAC,IAAI,CAAC;aAClB;;;WAAA;QAEH,iBAAC;IAAD,CAAC;;IC1ED;;;;;;;QAOE,oBAAqB,QAAgB,EAAU,WAAgC;YAA1D,aAAQ,GAAR,QAAQ,CAAQ;YAAU,gBAAW,GAAX,WAAW,CAA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Y;oBACZC,yBAAmB;oBACnBC,iBAAW;iBACZ;yBArBH;KAgBA,IAwBC;gGATY,UAAU;sBAftBC,WAAQ;uBAAC;wBACR,OAAO,EAAE;4BACPH,mBAAY;4BACZC,yBAAmB;4BACnBC,iBAAW;yBACZ;wBACD,YAAY,EAAE;4BACZ,kBAAkB;4BAClB,4BAA4B;yBAC7B;wBACD,OAAO,EAAE;4BACP,kBAAkB;4BAClB,4BAA4B;yBAC7B;qBACF;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("@angular/common/http"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@huntsman-cancer-institute/user",["exports","@angular/core","@angular/common","@angular/forms","@angular/common/http","rxjs","rxjs/operators"],t):t(((e=e||self)["huntsman-cancer-institute"]=e["huntsman-cancer-institute"]||{},e["huntsman-cancer-institute"].user={}),e.ng.core,e.ng.common,e.ng.forms,e.ng.common.http,e.rxjs,e.rxjs.operators)}(this,(function(e,t,n,r,o,i,s){"use strict";var a=function(){function e(e,t,n,r,o,i){this.id=e,this.username=t,this.roles=n,this.firstname=r,this.lastname=o,this.href=i}return Object.defineProperty(e.prototype,"Id",{get:function(){return this.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Username",{get:function(){return this.username},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Roles",{get:function(){return this.roles},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Firstname",{get:function(){return this.firstname},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Lastname",{get:function(){return this.lastname},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Href",{get:function(){return this.href},enumerable:!1,configurable:!0}),e}(),c=function(){function e(e,t){this.roleName=e,this.permissions=t}return Object.defineProperty(e.prototype,"RoleName",{get:function(){return this.roleName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Permissions",{get:function(){return this.permissions},enumerable:!1,configurable:!0}),e}(),u=function(){function e(e,t,n){this.domain=e,this.actions=t,this.instances=n}return Object.defineProperty(e.prototype,"Domain",{get:function(){return this.domain},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Actions",{get:function(){return this.actions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"Instances",{get:function(){return this.instances},enumerable:!1,configurable:!0}),e}(),l=new t.InjectionToken("authenticated_user_url"),p=function(){function e(e,t){this._http=e,this._authenticationUserEndpoint=t,this._authenticatedUser=null}return e.prototype.getAuthenticatedUser=function(){var e=this;return t.isDevMode()&&console&&console.debug&&console.debug("getAuthenticatedUser"),this._authenticatedUser?i.of(this._authenticatedUser):(t.isDevMode()&&console&&console.debug&&console.debug("_authenticationUserEndpoint: "+this._authenticationUserEndpoint),this._http.get(this._authenticationUserEndpoint,{observe:"response"}).pipe(s.map((function(t){if(200===t.status)return e._authenticatedUser=e.buildUserEntity(t.body),e._authenticatedUser;throw new Error("Get authenticated user failed. "+t.status+": "+t.statusText)})),s.catchError(this.handleError)))},e.prototype.handleError=function(t){var n=t.message?t.message:e.GENERIC_ERR_MSG;return i.Observable.throw(n)},e.prototype.buildUserEntity=function(e){var t=[];return e.roles&&e.roles.map((function(e){var n;e.permissions&&(n=e.permissions.map((function(e){return new u(e.domain,e.actions,e.instances)}))),t.push(new c(e.roleName,n))})),new a(e.idUser,e.username,t,e.firstname,e.lastname,e.href)},e.prototype.getPermissions=function(e,t,n){var r=(new o.HttpHeaders).set("SecurityGovernorClass",e).set("SecurityGovernorId",String(t));return this._http.get("/core/api/user/permissions/"+n,{headers:r})},e.GENERIC_ERR_MSG="Server error",e.ɵfac=t.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e,deps:[{token:o.HttpClient},{token:l}],target:t.ɵɵFactoryTarget.Injectable}),e.ɵprov=t.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e}),e}();t.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:p,decorators:[{type:t.Injectable}],ctorParameters:function(){return[{type:o.HttpClient},{type:void 0,decorators:[{type:t.Inject,args:[l]}]}]}});var m=function(){function e(e,t,n){this._viewContainer=e,this._templateRef=t,this._usrSvc=n,this._lastCheck=null}return Object.defineProperty(e.prototype,"hciHasRole",{set:function(e){var n=this;t.isDevMode()&&console&&console.debug&&console.debug("hciHasRole"),this._usrSvc.getAuthenticatedUser().subscribe((function(t){var r;!(r=!(!t||!t.Roles)&&t.Roles.some((function(t){return t.RoleName===e})))||null!==n._lastCheck&&n._lastCheck?r||null!==n._lastCheck&&!n._lastCheck||n._viewContainer.clear():n._viewContainer.createEmbeddedView(n._templateRef)}),(function(e){}))},enumerable:!1,configurable:!0}),e.ɵfac=t.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e,deps:[{token:t.ViewContainerRef},{token:t.TemplateRef},{token:p}],target:t.ɵɵFactoryTarget.Directive}),e.ɵdir=t.ɵɵngDeclareDirective({minVersion:"12.0.0",version:"12.2.17",type:e,selector:"[hciHasRole]",inputs:{hciHasRole:"hciHasRole"},providers:[p],ngImport:t}),e}();t.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:m,decorators:[{type:t.Directive,args:[{selector:"[hciHasRole]",providers:[p]}]}],ctorParameters:function(){return[{type:t.ViewContainerRef},{type:t.TemplateRef},{type:p}]},propDecorators:{hciHasRole:[{type:t.Input}]}});var f,h=this&&this.__extends||(f=function(e,t){return(f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),d=function(e){function n(t,n,r){var o=e.call(this,t,n,r)||this;return o._context=new g,o}return h(n,e),Object.defineProperty(n.prototype,"hciHasRoleUnlessNull",{set:function(e){e?this.hciHasRole=e:!0!==this._context._condition&&(this._context._condition=!0,this._updateView())},enumerable:!1,configurable:!0}),n.prototype._updateView=function(){this._viewContainer.clear(),this._context._condition,this._viewContainer.createEmbeddedView(this._templateRef,this._context)},n.ɵfac=t.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:n,deps:[{token:t.ViewContainerRef},{token:t.TemplateRef},{token:p}],target:t.ɵɵFactoryTarget.Directive}),n.ɵdir=t.ɵɵngDeclareDirective({minVersion:"12.0.0",version:"12.2.17",type:n,selector:"[hciHasRoleUnlessNull]",inputs:{hciHasRoleUnlessNull:"hciHasRoleUnlessNull"},usesInheritance:!0,ngImport:t}),n}(m);t.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:d,decorators:[{type:t.Directive,args:[{selector:"[hciHasRoleUnlessNull]"}]}],ctorParameters:function(){return[{type:t.ViewContainerRef},{type:t.TemplateRef},{type:p}]},propDecorators:{hciHasRoleUnlessNull:[{type:t.Input}]}});var g=function(){this._condition=!1},y=function(){function e(){}return e.forRoot=function(){return{providers:[p],ngModule:e}},e.ɵfac=t.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e,deps:[],target:t.ɵɵFactoryTarget.NgModule}),e.ɵmod=t.ɵɵngDeclareNgModule({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e,declarations:[m,d],imports:[n.CommonModule,r.ReactiveFormsModule,r.FormsModule],exports:[m,d]}),e.ɵinj=t.ɵɵngDeclareInjector({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:e,imports:[[n.CommonModule,r.ReactiveFormsModule,r.FormsModule]]}),e}();t.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.17",ngImport:t,type:y,decorators:[{type:t.NgModule,args:[{imports:[n.CommonModule,r.ReactiveFormsModule,r.FormsModule],declarations:[m,d],exports:[m,d]}]}]}),e.AUTHENTICATED_USER_ENDPOINT=l,e.PermissionEntity=u,e.RoleCheckDirective=m,e.RoleCheckUnlessNullDirective=d,e.RoleEntity=c,e.UserEntity=a,e.UserModule=y,e.UserService=p,Object.defineProperty(e,"__esModule",{value:!0})}));
2
- //# sourceMappingURL=huntsman-cancer-institute-user.umd.min.js.map