@huntsman-cancer-institute/user 11.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 (68) hide show
  1. package/README.md +74 -0
  2. package/index.d.ts +16 -0
  3. package/index.js +20 -0
  4. package/index.js.map +1 -0
  5. package/package.json +84 -0
  6. package/src/authorization/permission.entity.d.ts +34 -0
  7. package/src/authorization/permission.entity.js +45 -0
  8. package/src/authorization/permission.entity.js.map +1 -0
  9. package/src/authorization/permission.entity.ngfactory.d.ts +1 -0
  10. package/src/authorization/permission.entity.ngfactory.js +2 -0
  11. package/src/authorization/permission.entity.ngfactory.js.map +1 -0
  12. package/src/authorization/permission.entity.ngsummary.d.ts +1 -0
  13. package/src/authorization/permission.entity.ngsummary.js +2 -0
  14. package/src/authorization/permission.entity.ngsummary.js.map +1 -0
  15. package/src/authorization/role-check-unless-null.directive.d.ts +22 -0
  16. package/src/authorization/role-check-unless-null.directive.js +62 -0
  17. package/src/authorization/role-check-unless-null.directive.js.map +1 -0
  18. package/src/authorization/role-check-unless-null.directive.ngfactory.d.ts +3 -0
  19. package/src/authorization/role-check-unless-null.directive.ngfactory.js +4 -0
  20. package/src/authorization/role-check-unless-null.directive.ngfactory.js.map +1 -0
  21. package/src/authorization/role-check-unless-null.directive.ngsummary.d.ts +1 -0
  22. package/src/authorization/role-check-unless-null.directive.ngsummary.js +2 -0
  23. package/src/authorization/role-check-unless-null.directive.ngsummary.js.map +1 -0
  24. package/src/authorization/role-check.directive.d.ts +23 -0
  25. package/src/authorization/role-check.directive.js +66 -0
  26. package/src/authorization/role-check.directive.js.map +1 -0
  27. package/src/authorization/role-check.directive.ngfactory.d.ts +3 -0
  28. package/src/authorization/role-check.directive.ngfactory.js +4 -0
  29. package/src/authorization/role-check.directive.ngfactory.js.map +1 -0
  30. package/src/authorization/role-check.directive.ngsummary.d.ts +1 -0
  31. package/src/authorization/role-check.directive.ngsummary.js +2 -0
  32. package/src/authorization/role-check.directive.ngsummary.js.map +1 -0
  33. package/src/authorization/role.entity.d.ts +27 -0
  34. package/src/authorization/role.entity.js +32 -0
  35. package/src/authorization/role.entity.js.map +1 -0
  36. package/src/authorization/role.entity.ngfactory.d.ts +1 -0
  37. package/src/authorization/role.entity.ngfactory.js +2 -0
  38. package/src/authorization/role.entity.ngfactory.js.map +1 -0
  39. package/src/authorization/role.entity.ngsummary.d.ts +1 -0
  40. package/src/authorization/role.entity.ngsummary.js +2 -0
  41. package/src/authorization/role.entity.ngsummary.js.map +1 -0
  42. package/src/user.entity.d.ts +57 -0
  43. package/src/user.entity.js +70 -0
  44. package/src/user.entity.js.map +1 -0
  45. package/src/user.entity.ngfactory.d.ts +1 -0
  46. package/src/user.entity.ngfactory.js +2 -0
  47. package/src/user.entity.ngfactory.js.map +1 -0
  48. package/src/user.entity.ngsummary.d.ts +1 -0
  49. package/src/user.entity.ngsummary.js +2 -0
  50. package/src/user.entity.ngsummary.js.map +1 -0
  51. package/src/user.module.d.ts +17 -0
  52. package/src/user.module.js +56 -0
  53. package/src/user.module.js.map +1 -0
  54. package/src/user.module.ngfactory.d.ts +3 -0
  55. package/src/user.module.ngfactory.js +4 -0
  56. package/src/user.module.ngfactory.js.map +1 -0
  57. package/src/user.module.ngsummary.d.ts +1 -0
  58. package/src/user.module.ngsummary.js +2 -0
  59. package/src/user.module.ngsummary.js.map +1 -0
  60. package/src/user.service.d.ts +37 -0
  61. package/src/user.service.js +98 -0
  62. package/src/user.service.js.map +1 -0
  63. package/src/user.service.ngfactory.d.ts +3 -0
  64. package/src/user.service.ngfactory.js +4 -0
  65. package/src/user.service.ngfactory.js.map +1 -0
  66. package/src/user.service.ngsummary.d.ts +1 -0
  67. package/src/user.service.ngsummary.js +2 -0
  68. package/src/user.service.ngsummary.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Angular User Module
2
+
3
+ TODO: Separate out the parts moved to @huntsman-cancer-institute/authentication.
4
+
5
+ This library provides elements for authenticating the user, protecting routes, getting user information from the a server,
6
+ defining that user representation in the client application, directives for controlling the UI based on aspects of the
7
+ user like authorization claims and destroying the user session (logout).
8
+
9
+ A component can be imported directly though the main index.ts barrel file which groups all components in this library for
10
+ easy importing.
11
+
12
+ ## Usage
13
+
14
+ This package provides a configurable service to interact with a server-side REST api. It is designed to be configurable
15
+ through the Angular injection framework and the usage of OpaqueTokens. See the development harnesses application module
16
+ for details or review the jsDocs on the `UserService` class.
17
+
18
+ ### Features
19
+ - Configurable user service for interactions with server-side REST api
20
+ - A route protection service that implements `CanActivate`
21
+ - Immutable entities to represent the user representation in the client application
22
+ - Directive to control the UI based on a users authorization claims (roles, permissions, etc...)
23
+
24
+ ### API
25
+
26
+ #### User Service
27
+ The user service is configured through module injection. The tokens that must be defined are:
28
+ - AUTHENTICATED_USER_ENDPOINT: the url to the endpoint for the currently authenticated subject
29
+ - DEFAULT_SUCCESS_URL: the url to navigate the user to after a successful authentication attempt, if another location wasn't declared in the request
30
+ - USER_SESSION_ENDPOINT: a user session endpoint configuration (e.g. https://localhost/core/api/user-session)
31
+ - SERVER_URL: a url to define the base server api, if a variable login/logout api configuration is necessary (e.g. https://localhost/core/api)
32
+ - LOGIN_PATH: a variable path for login that extends SERVER_URL (e.g. /login)
33
+ - LOGOUT_PATH: a variable path for logout that extends SERVER_URL (e.g. /logout)
34
+
35
+ When configuring the user service it must include either USER_SESSION_ENDPOINT or SERVER_URL, LOGIN_PATH and LOGOUT_PATH,
36
+ depending on the type of API to be supported (consistent vs. variable). The service will fail to instantiate if all
37
+ opaque tokens are provided with values other than null. See the UserService jsdocs for details about configuring this aspect
38
+ of the user feature module.
39
+
40
+ ##### Login Callbacks
41
+ The user service also supports login success callbacks. Components may add one or more callback functions that are invoked
42
+ in the order they were added upon successful authentication. This is useful when you require something special to happen after
43
+ authentication, but outside of the scope of component initialization and creation.
44
+
45
+ #### Route Guard Service
46
+ A service to enable secured endpoints to force authentication. The tokens that must be defined are:
47
+ - LOGIN_ROUTE: the configured login component path
48
+
49
+ #### User Entities
50
+ The immutable entities defining the representation of a user in the client application that are to be used when marshalling
51
+ the user to and from the server (see JSON.stringify() for an easy approach)
52
+
53
+ **UserEntity:**
54
+ - **id:** the system identifier of the user
55
+ - **username:** the users application identifier
56
+ - **roles:** (optional) a collection of authorization claims optionally defined by finer grained permissions
57
+
58
+ **RoleEntity**
59
+ - **roleName:** the name of the role associated with the server-side subject
60
+ - **permissions:** (optional) a collection of fine grained authorization claims that can defined a role
61
+
62
+ **PermissionEntity**
63
+ - **domain:** the domain a permission is defined for (i.e. user, study, specimen, etc...)
64
+ - **actions:** a string array of actions that this permission allows in the specified domain (i.e. create, read,
65
+ activate, manage etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
66
+ - **instances:** a string array of instances that this permission is applicable to in the specified domain (i.e. joe,
67
+ 1234, study-foo, etc...). If no instances are defined, this permission claims applicability to all instances of the
68
+ specified domain.
69
+
70
+ #### Structural Directive for UI Control
71
+ **hciHasRole** directive allows for the decoration of UI elements that should be included or removed from the DOM as dictated
72
+ by a users role authorization claims
73
+ **hciHasRoleUnlessNull** extends the **hciHasRole** directive but will only check the user authorization if the give role
74
+ value is not null or is not undefined.
package/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A barrel file for the HCI ng2 user package.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+ export { UserModule } from "./src/user.module";
7
+ export { UserEntity } from "./src/user.entity";
8
+ export { RoleEntity } from "./src/authorization/role.entity";
9
+ export { PermissionEntity } from "./src/authorization/permission.entity";
10
+ /**
11
+ * The opaque tokens for service configuration.
12
+ */
13
+ export { AUTHENTICATED_USER_ENDPOINT } from "./src/user.service";
14
+ export { UserService } from "./src/user.service";
15
+ export { RoleCheckDirective } from "./src/authorization/role-check.directive";
16
+ export { RoleCheckUnlessNullDirective } from "./src/authorization/role-check-unless-null.directive";
package/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ /**
5
+ * A barrel file for the HCI ng2 user package.
6
+ *
7
+ * @since 1.0.0
8
+ */
9
+ export { UserModule } from "./src/user.module";
10
+ export { UserEntity } from "./src/user.entity";
11
+ export { RoleEntity } from "./src/authorization/role.entity";
12
+ export { PermissionEntity } from "./src/authorization/permission.entity";
13
+ /**
14
+ * The opaque tokens for service configuration.
15
+ */
16
+ export { AUTHENTICATED_USER_ENDPOINT } from "./src/user.service";
17
+ export { UserService } from "./src/user.service";
18
+ export { RoleCheckDirective } from "./src/authorization/role-check.directive";
19
+ export { RoleCheckUnlessNullDirective } from "./src/authorization/role-check-unless-null.directive";
20
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAC,gBAAgB,EAAC,MAAM,uCAAuC,CAAA;AAEtE;;GAEG;AACH,OAAO,EACL,2BAA2B,EAC5B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAC,4BAA4B,EAAC,MAAM,sDAAsD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@huntsman-cancer-institute/user",
3
+ "version": "11.0.0",
4
+ "description": "The user library. This component is expected to provide user specific component and services to any HCI ng application",
5
+ "contributors": ["Michael Byrne", "Abhishek Mukherjee"],
6
+ "publishConfig": {
7
+ "registry": "https://registry.npmjs.org",
8
+ "access": "public"
9
+ },
10
+ "repository": "https://ri-source.hci.utah.edu/hcidevs/hci-ng.git",
11
+ "scripts": {
12
+ "build": "npm run clean && npm run ngc && npm run doc && npm run karma start && npm run copyfiles package.json dist/",
13
+ "clean": "npm run rimraf dist/ index.js index.d.ts index.ngsummary.json index.metadata.json index.js.map src/**/*.js src/**/*.ngfactory.ts src/**/*.d.ts src/**/*.js.map src/**/*.ngsummary.json src/**/*.metadata.json code-coverage",
14
+ "compodoc": "compodoc",
15
+ "copyfiles": "copyfiles",
16
+ "copyToDist": "npm run copyfiles -- package.json README.md dist/",
17
+ "doc": "npm run compodoc -- src -p ./tsconfig.json -d docs -n '@huntsman-cancer-institute/user'",
18
+ "karma": "karma",
19
+ "ngc": "ngc",
20
+ "npmPack": "npm run build && npm run copyToDist && cd dist && npm pack",
21
+ "npmPublish": "npm run build && npm run copyToDist && cd dist && npm publish",
22
+ "rimraf": "rimraf",
23
+ "postinstall": ""
24
+ },
25
+ "main": "index.js",
26
+ "module": "index.js",
27
+ "typings": "index.d.ts",
28
+ "files": ["index.+(js|d.ts|js.map|metadata.json)", "src/**/!(*spec).+(js|d.ts|js.map|metadata.json)"],
29
+ "dependencies": {
30
+ "@huntsman-cancer-institute/authentication": "11.0.0"
31
+ },
32
+ "optionalDependencies": {},
33
+ "peerDependencies": {
34
+ "@angular/common": "^11.0.0",
35
+ "@angular/core": "^11.0.0",
36
+ "@huntsman-cancer-institute/authentication": "11.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@angular/animations": "^11.0.0",
40
+ "@angular/common": "^11.0.0",
41
+ "@angular/compiler": "^11.0.0",
42
+ "@angular/compiler-cli": "^11.0.0",
43
+ "@angular/core": "^11.0.0",
44
+ "@angular/forms": "^11.0.0",
45
+ "@angular/platform-browser": "^11.0.0",
46
+ "@angular/platform-browser-dynamic": "^11.0.0",
47
+ "@angular/router": "^11.0.0",
48
+ "@compodoc/compodoc": "^1.1.11",
49
+ "@types/jasmine": "^2.5.53",
50
+ "@types/node": "^7.0.22",
51
+ "@types/webpack": "4.1.2",
52
+ "@angular-cool/storage": "12.0.0",
53
+ "awesome-typescript-loader": "^3.2.3",
54
+ "angular2-template-loader": "^0.6.2",
55
+ "copyfiles": "^1.2.0",
56
+ "core-js": "^2.4.1",
57
+ "del": "^2.2.1",
58
+ "fs": "^0.0.2",
59
+ "immutable": "^3.8.1",
60
+ "inline-source-map": "^0.6.2",
61
+ "istanbul-instrumenter-loader": "2.0.0",
62
+ "jasmine-core": "^2.6.2",
63
+ "karma": "^1.7.0",
64
+ "karma-chrome-launcher": "^2.1.1",
65
+ "karma-coverage": "^1.1.1",
66
+ "karma-jasmine": "^1.1.0",
67
+ "karma-mocha-reporter": "^2.2.3",
68
+ "karma-remap-coverage": "^0.1.4",
69
+ "karma-sourcemap-loader": "^0.3.7",
70
+ "karma-webpack": "^2.0.3",
71
+ "minimist": "^1.2.0",
72
+ "reflect-metadata": "^0.1.3",
73
+ "rimraf": "^2.6.1",
74
+ "rxjs": "6.4.x",
75
+ "source-map-loader": "^0.2.1",
76
+ "tslint": "^4.5.1",
77
+ "typescript": "4.0.x",
78
+ "webpack": "3.11.0",
79
+ "webpack-dev-middleware": "1.12.0",
80
+ "webpack-dev-server": "2.7.1",
81
+ "webpack-merge": "4.1.0",
82
+ "zone.js": "^0.11.4"
83
+ }
84
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can
3
+ * define a {@link RoleEntity}.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export declare class PermissionEntity {
8
+ private domain;
9
+ private actions?;
10
+ private instances?;
11
+ constructor(domain: string, actions?: string[], instances?: string[]);
12
+ /**
13
+ * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).
14
+ *
15
+ * @returns {string} the domain of this permission
16
+ * @constructor
17
+ */
18
+ get Domain(): string;
19
+ /**
20
+ * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage
21
+ * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
22
+ *
23
+ * @returns {string[]} an array of actions for the specified domain
24
+ * @constructor
25
+ */
26
+ get Actions(): string[];
27
+ /**
28
+ * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,
29
+ * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.
30
+ * @returns {string[]}
31
+ * @constructor
32
+ */
33
+ get Instances(): string[];
34
+ }
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ /**
5
+ * An immutable representation of an HCI permission entity, which represents a fine grained authorization claim that can
6
+ * define a {@link RoleEntity}.
7
+ *
8
+ * @since 1.0.0
9
+ */
10
+ export class PermissionEntity {
11
+ constructor(domain, actions, instances) {
12
+ this.domain = domain;
13
+ this.actions = actions;
14
+ this.instances = instances;
15
+ }
16
+ /**
17
+ * An accessor for the domain this permission is defined for (i.e. user, study, specimen, etc...).
18
+ *
19
+ * @returns {string} the domain of this permission
20
+ * @constructor
21
+ */
22
+ get Domain() {
23
+ return this.domain;
24
+ }
25
+ /**
26
+ * An accessor for the actions that this permission allows in the specified domain (i.e. create, read, activate, manage
27
+ * etc...). If no actions are defined, this permission claims access to all actions of the specified domain.
28
+ *
29
+ * @returns {string[]} an array of actions for the specified domain
30
+ * @constructor
31
+ */
32
+ get Actions() {
33
+ return this.actions;
34
+ }
35
+ /**
36
+ * An accessor for the instances that this permission is applicable to in the specified domain (i.e. joe, 1234, study-foo,
37
+ * etc...). If no instances are defined, this permission claims applicability to all instances of the specified domain.
38
+ * @returns {string[]}
39
+ * @constructor
40
+ */
41
+ get Instances() {
42
+ return this.instances;
43
+ }
44
+ }
45
+ //# sourceMappingURL=permission.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.entity.js","sourceRoot":"","sources":["../../../src/authorization/permission.entity.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAC3B,YAAoB,MAAc,EAAU,OAAkB,EAAU,SAAoB;QAAxE,WAAM,GAAN,MAAM,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAW;QAAU,cAAS,GAAT,SAAS,CAAW;IAC5F,CAAC;IAED;;;;;OAKG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,2 @@
1
+ export const ɵNonEmptyModule = true;
2
+ //# sourceMappingURL=permission.entity.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.entity.ngfactory.js","sourceRoot":"","sources":["../../../src/authorization/permission.entity.ngfactory.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const ɵempty: any;
@@ -0,0 +1,2 @@
1
+ export const ɵempty = null;
2
+ //# sourceMappingURL=permission.entity.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.entity.ngsummary.js","sourceRoot":"","sources":["../../../src/authorization/permission.entity.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ViewContainerRef, TemplateRef } from "@angular/core";
2
+ import { RoleCheckDirective } from "./role-check.directive";
3
+ import { UserService } from "../user.service";
4
+ /**
5
+ * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.
6
+ *
7
+ * This directive requires the {@link UserService} as a provider.
8
+ *
9
+ * @since 1.0.0
10
+ */
11
+ export declare class RoleCheckUnlessNullDirective extends RoleCheckDirective {
12
+ private _context;
13
+ constructor(_viewContainer: ViewContainerRef, _templateRef: TemplateRef<Object>, _usrSvc: UserService);
14
+ set hciHasRoleUnlessNull(roleName: string);
15
+ private _updateView;
16
+ }
17
+ /**
18
+ * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.
19
+ */
20
+ export declare class HciHasRoleUnlessNullContext {
21
+ _condition: boolean;
22
+ }
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ import { Directive, Input, ViewContainerRef, TemplateRef } from "@angular/core";
5
+ import { RoleCheckDirective } from "./role-check.directive";
6
+ import { UserService } from "../user.service";
7
+ import * as i0 from "@angular/core";
8
+ import * as i1 from "../user.service";
9
+ /**
10
+ * An extension of the {@link RoleCheckDirective} the only evaluates the role if is it not null or undefined.
11
+ *
12
+ * This directive requires the {@link UserService} as a provider.
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ export class RoleCheckUnlessNullDirective extends RoleCheckDirective {
17
+ constructor(_viewContainer, _templateRef, _usrSvc) {
18
+ super(_viewContainer, _templateRef, _usrSvc);
19
+ this._context = new HciHasRoleUnlessNullContext();
20
+ }
21
+ set hciHasRoleUnlessNull(roleName) {
22
+ if (!roleName) {
23
+ // if the roleName is undefined or null then render
24
+ if (this._context._condition !== true) {
25
+ this._context._condition = true;
26
+ this._updateView();
27
+ }
28
+ }
29
+ else {
30
+ // otherwise delegate the check to RoleCheckDirective
31
+ this.hciHasRole = roleName;
32
+ }
33
+ }
34
+ _updateView() {
35
+ this._viewContainer.clear();
36
+ if (this._context._condition) {
37
+ this._viewContainer.createEmbeddedView(this._templateRef, this._context);
38
+ }
39
+ else {
40
+ this._viewContainer.createEmbeddedView(this._templateRef, this._context);
41
+ }
42
+ }
43
+ }
44
+ RoleCheckUnlessNullDirective.ɵfac = function RoleCheckUnlessNullDirective_Factory(t) { return new (t || RoleCheckUnlessNullDirective)(i0.ɵɵdirectiveInject(i0.ViewContainerRef), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i1.UserService)); };
45
+ RoleCheckUnlessNullDirective.ɵdir = i0.ɵɵdefineDirective({ type: RoleCheckUnlessNullDirective, selectors: [["", "hciHasRoleUnlessNull", ""]], inputs: { hciHasRoleUnlessNull: "hciHasRoleUnlessNull" }, features: [i0.ɵɵInheritDefinitionFeature] });
46
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RoleCheckUnlessNullDirective, [{
47
+ type: Directive,
48
+ args: [{
49
+ selector: "[hciHasRoleUnlessNull]"
50
+ }]
51
+ }], function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i1.UserService }]; }, { hciHasRoleUnlessNull: [{
52
+ type: Input
53
+ }] }); })();
54
+ /**
55
+ * I totally ripped off *ngIf source to get this to work correctly to prevent infinit loop rendering.
56
+ */
57
+ export class HciHasRoleUnlessNullContext {
58
+ constructor() {
59
+ this._condition = false;
60
+ }
61
+ }
62
+ //# sourceMappingURL=role-check-unless-null.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check-unless-null.directive.js","sourceRoot":"","sources":["../../../src/authorization/role-check-unless-null.directive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAC,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;;;AAE5C;;;;;;GAMG;AAIH,MAAM,OAAO,4BAA6B,SAAQ,kBAAkB;IAIlE,YACE,cAAgC,EAChC,YAAiC,EACjC,OAAoB;QACpB,KAAK,CAAC,cAAc,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QANvC,aAAQ,GAAgC,IAAI,2BAA2B,EAAE,CAAC;IAOlF,CAAC;IAED,IACI,oBAAoB,CAAC,QAAgB;QACvC,IAAI,CAAC,QAAQ,EAAE;YACb,mDAAmD;YACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,IAAI,EAAE;gBACrC,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC;gBAChC,IAAI,CAAC,WAAW,EAAE,CAAC;aACpB;SACF;aAAM;YACL,qDAAqD;YACrD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;SAC5B;IACH,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC5B,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1E;aAAM;YACL,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1E;IACH,CAAC;;wGAhCU,4BAA4B;iEAA5B,4BAA4B;uFAA5B,4BAA4B;cAHxC,SAAS;eAAC;gBACR,QAAQ,EAAE,wBAAwB;aACpC;uHAaK,oBAAoB;kBADvB,KAAK;;AAwBR;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAAxC;QACS,eAAU,GAAY,KAAK,CAAC;IACrC,CAAC;CAAA"}
@@ -0,0 +1,3 @@
1
+ import * as i0 from '@angular/core';
2
+ export declare const RoleCheckUnlessNullDirectiveNgFactory: i0.ɵNgModuleFactory<any>;
3
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,4 @@
1
+ import * as i0 from '@angular/core';
2
+ import { RoleCheckUnlessNullDirective } from './role-check-unless-null.directive';
3
+ export const ɵNonEmptyModule = true;
4
+ //# sourceMappingURL=role-check-unless-null.directive.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check-unless-null.directive.ngfactory.js","sourceRoot":"","sources":["../../../src/authorization/role-check-unless-null.directive.ngfactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const RoleCheckUnlessNullDirectiveNgSummary: any;
@@ -0,0 +1,2 @@
1
+ export const RoleCheckUnlessNullDirectiveNgSummary = null;
2
+ //# sourceMappingURL=role-check-unless-null.directive.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check-unless-null.directive.ngsummary.js","sourceRoot":"","sources":["../../../src/authorization/role-check-unless-null.directive.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qCAAqC,GAAQ,IAAI,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { TemplateRef, ViewContainerRef } from "@angular/core";
2
+ import { UserService } from "../user.service";
3
+ /**
4
+ * A structural directive for adding and removing elements of the client application based on a users <em>role</em>
5
+ * authorization claims.
6
+ *
7
+ * This directive requires the {@link UserService} as a provider.
8
+ *
9
+ * @since 1.0.0
10
+ */
11
+ export declare class RoleCheckDirective {
12
+ protected _viewContainer: ViewContainerRef;
13
+ protected _templateRef: TemplateRef<Object>;
14
+ protected _usrSvc: UserService;
15
+ protected _lastCheck: boolean;
16
+ constructor(_viewContainer: ViewContainerRef, _templateRef: TemplateRef<Object>, _usrSvc: UserService);
17
+ /**
18
+ * Calculates the availability of a decorated element based on the authenticated users available roles.
19
+ *
20
+ * @param roleName for the role required to make the decorated element available
21
+ */
22
+ set hciHasRole(roleName: string);
23
+ }
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ import { Directive, Input, TemplateRef, ViewContainerRef, isDevMode } from "@angular/core";
5
+ import { UserService } from "../user.service";
6
+ import * as i0 from "@angular/core";
7
+ import * as i1 from "../user.service";
8
+ /**
9
+ * A structural directive for adding and removing elements of the client application based on a users <em>role</em>
10
+ * authorization claims.
11
+ *
12
+ * This directive requires the {@link UserService} as a provider.
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ export class RoleCheckDirective {
17
+ constructor(_viewContainer, _templateRef, _usrSvc) {
18
+ this._viewContainer = _viewContainer;
19
+ this._templateRef = _templateRef;
20
+ this._usrSvc = _usrSvc;
21
+ this._lastCheck = null;
22
+ }
23
+ /**
24
+ * Calculates the availability of a decorated element based on the authenticated users available roles.
25
+ *
26
+ * @param roleName for the role required to make the decorated element available
27
+ */
28
+ set hciHasRole(roleName) {
29
+ if (isDevMode() && console && console.debug) {
30
+ console.debug("hciHasRole");
31
+ }
32
+ this._usrSvc.getAuthenticatedUser().subscribe((authUser) => {
33
+ let found;
34
+ if (authUser && authUser.Roles) {
35
+ found = authUser.Roles.some((role) => {
36
+ return role.RoleName === roleName;
37
+ });
38
+ }
39
+ else {
40
+ found = false;
41
+ }
42
+ if (found && (this._lastCheck === null || !this._lastCheck)) {
43
+ this._viewContainer.createEmbeddedView(this._templateRef);
44
+ }
45
+ else if (!found && (this._lastCheck === null || this._lastCheck)) {
46
+ this._viewContainer.clear();
47
+ }
48
+ }, (error) => {
49
+ // TODO: BHY (08/19/16) - Determine requirements around errors and then REMOVE CONSOLE LOGGING. Display to user,
50
+ // log to external source, gobble?
51
+ // Gobble up the error.
52
+ });
53
+ }
54
+ }
55
+ RoleCheckDirective.ɵfac = function RoleCheckDirective_Factory(t) { return new (t || RoleCheckDirective)(i0.ɵɵdirectiveInject(i0.ViewContainerRef), i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i1.UserService)); };
56
+ RoleCheckDirective.ɵdir = i0.ɵɵdefineDirective({ type: RoleCheckDirective, selectors: [["", "hciHasRole", ""]], inputs: { hciHasRole: "hciHasRole" }, features: [i0.ɵɵProvidersFeature([UserService])] });
57
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RoleCheckDirective, [{
58
+ type: Directive,
59
+ args: [{
60
+ selector: "[hciHasRole]",
61
+ providers: [UserService]
62
+ }]
63
+ }], function () { return [{ type: i0.ViewContainerRef }, { type: i0.TemplateRef }, { type: i1.UserService }]; }, { hciHasRole: [{
64
+ type: Input
65
+ }] }); })();
66
+ //# sourceMappingURL=role-check.directive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check.directive.js","sourceRoot":"","sources":["../../../src/authorization/role-check.directive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAC,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;;;AAG5C;;;;;;;GAOG;AAKH,MAAM,OAAO,kBAAkB;IAG7B,YAAsB,cAAgC,EAChC,YAAiC,EACjC,OAAoB;QAFpB,mBAAc,GAAd,cAAc,CAAkB;QAChC,iBAAY,GAAZ,YAAY,CAAqB;QACjC,YAAO,GAAP,OAAO,CAAa;QAJhC,eAAU,GAAY,IAAI,CAAC;IAKrC,CAAC;IAED;;;;OAIG;IACH,IACI,UAAU,CAAC,QAAgB;QAC7B,IAAI,SAAS,EAAE,IAAS,OAAO,IAAS,OAAO,CAAC,KAAK,EAAE;YACrD,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;SAC7B;QAED,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,SAAS,CAAC,CAAC,QAAoB,EAAE,EAAE;YACrE,IAAI,KAAc,CAAC;YAEnB,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAC9B,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;oBACnC,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC;gBACpC,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,KAAK,GAAG,KAAK,CAAC;aACf;YAED,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBAC3D,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;aAC3D;iBAAM,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE;gBAClE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;aAC7B;QACH,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;YACX,gHAAgH;YAChH,kCAAkC;YAClC,uBAAuB;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;;oFAxCU,kBAAkB;uDAAlB,kBAAkB,8GAFlB,CAAC,WAAW,CAAC;uFAEb,kBAAkB;cAJ9B,SAAS;eAAC;gBACT,QAAQ,EAAE,cAAc;gBACxB,SAAS,EAAE,CAAC,WAAW,CAAC;aACzB;uHAeK,UAAU;kBADb,KAAK"}
@@ -0,0 +1,3 @@
1
+ import * as i0 from '@angular/core';
2
+ export declare const RoleCheckDirectiveNgFactory: i0.ɵNgModuleFactory<any>;
3
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,4 @@
1
+ import * as i0 from '@angular/core';
2
+ import { RoleCheckDirective } from './role-check.directive';
3
+ export const ɵNonEmptyModule = true;
4
+ //# sourceMappingURL=role-check.directive.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check.directive.ngfactory.js","sourceRoot":"","sources":["../../../src/authorization/role-check.directive.ngfactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const RoleCheckDirectiveNgSummary: any;
@@ -0,0 +1,2 @@
1
+ export const RoleCheckDirectiveNgSummary = null;
2
+ //# sourceMappingURL=role-check.directive.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role-check.directive.ngsummary.js","sourceRoot":"","sources":["../../../src/authorization/role-check.directive.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAQ,IAAI,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { PermissionEntity } from "./permission.entity";
2
+ /**
3
+ * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated
4
+ * subject.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+ export declare class RoleEntity {
9
+ private roleName;
10
+ private permissions?;
11
+ constructor(roleName: string, permissions?: PermissionEntity[]);
12
+ /**
13
+ * An accessor for the name of this role.
14
+ *
15
+ * @returns {string} the role name
16
+ * @constructor
17
+ */
18
+ get RoleName(): string;
19
+ /**
20
+ * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions
21
+ * provide a finer grained authorization claim description and are not required.
22
+ *
23
+ * @returns {PermissionEntity[]} a collection of permission entities
24
+ * @constructor
25
+ */
26
+ get Permissions(): PermissionEntity[];
27
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * An immutable representation of an HCI role entity, which represents an authorization claim associated with an authenticated
3
+ * subject.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export class RoleEntity {
8
+ constructor(roleName, permissions) {
9
+ this.roleName = roleName;
10
+ this.permissions = permissions;
11
+ }
12
+ /**
13
+ * An accessor for the name of this role.
14
+ *
15
+ * @returns {string} the role name
16
+ * @constructor
17
+ */
18
+ get RoleName() {
19
+ return this.roleName;
20
+ }
21
+ /**
22
+ * An accessor for a collection of {@link PermissionEntity} authorization claims that define this role. Permissions
23
+ * provide a finer grained authorization claim description and are not required.
24
+ *
25
+ * @returns {PermissionEntity[]} a collection of permission entities
26
+ * @constructor
27
+ */
28
+ get Permissions() {
29
+ return this.permissions;
30
+ }
31
+ }
32
+ //# sourceMappingURL=role.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.entity.js","sourceRoot":"","sources":["../../../src/authorization/role.entity.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACrB,YAAqB,QAAgB,EAAU,WAAgC;QAA1D,aAAQ,GAAR,QAAQ,CAAQ;QAAU,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;IAEnF;;;;;OAKG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,2 @@
1
+ export const ɵNonEmptyModule = true;
2
+ //# sourceMappingURL=role.entity.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.entity.ngfactory.js","sourceRoot":"","sources":["../../../src/authorization/role.entity.ngfactory.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const ɵempty: any;
@@ -0,0 +1,2 @@
1
+ export const ɵempty = null;
2
+ //# sourceMappingURL=role.entity.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.entity.ngsummary.js","sourceRoot":"","sources":["../../../src/authorization/role.entity.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { RoleEntity } from "./authorization/role.entity";
2
+ /**
3
+ * An immutable representation of an HCI user entity.
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ export declare class UserEntity {
8
+ private id;
9
+ private username;
10
+ private roles?;
11
+ private firstname?;
12
+ private lastname?;
13
+ private href?;
14
+ constructor(id: string, username: string, roles?: RoleEntity[], firstname?: string, lastname?: string, href?: string);
15
+ /**
16
+ * An accessor for the users system id.
17
+ *
18
+ * @returns {string} the system id
19
+ * @constructor
20
+ */
21
+ get Id(): string;
22
+ /**
23
+ * An accessor for the users application identifier/username.
24
+ *
25
+ * @returns {string} the application id/username
26
+ * @constructor
27
+ */
28
+ get Username(): string;
29
+ /**
30
+ * An accessor for the users assigned role authorization claims.
31
+ *
32
+ * @returns {@code RoleEntity[]} the role authorization claims
33
+ * @constructor
34
+ */
35
+ get Roles(): RoleEntity[];
36
+ /**
37
+ * An accessor for the users firstname.
38
+ *
39
+ * @return {string} the firstname
40
+ * @constructor
41
+ */
42
+ get Firstname(): string;
43
+ /**
44
+ * A accessor for the users lastname.
45
+ *
46
+ * @return {string} the lastname
47
+ * @constructor
48
+ */
49
+ get Lastname(): string;
50
+ /**
51
+ * A access for the users fully qualified href location on the system.
52
+ *
53
+ * @return {string} the href location
54
+ * @constructor
55
+ */
56
+ get Href(): string;
57
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * An immutable representation of an HCI user entity.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+ export class UserEntity {
7
+ constructor(id, username, roles, firstname, lastname, href) {
8
+ this.id = id;
9
+ this.username = username;
10
+ this.roles = roles;
11
+ this.firstname = firstname;
12
+ this.lastname = lastname;
13
+ this.href = href;
14
+ }
15
+ /**
16
+ * An accessor for the users system id.
17
+ *
18
+ * @returns {string} the system id
19
+ * @constructor
20
+ */
21
+ get Id() {
22
+ return this.id;
23
+ }
24
+ /**
25
+ * An accessor for the users application identifier/username.
26
+ *
27
+ * @returns {string} the application id/username
28
+ * @constructor
29
+ */
30
+ get Username() {
31
+ return this.username;
32
+ }
33
+ /**
34
+ * An accessor for the users assigned role authorization claims.
35
+ *
36
+ * @returns {@code RoleEntity[]} the role authorization claims
37
+ * @constructor
38
+ */
39
+ get Roles() {
40
+ return this.roles;
41
+ }
42
+ /**
43
+ * An accessor for the users firstname.
44
+ *
45
+ * @return {string} the firstname
46
+ * @constructor
47
+ */
48
+ get Firstname() {
49
+ return this.firstname;
50
+ }
51
+ /**
52
+ * A accessor for the users lastname.
53
+ *
54
+ * @return {string} the lastname
55
+ * @constructor
56
+ */
57
+ get Lastname() {
58
+ return this.lastname;
59
+ }
60
+ /**
61
+ * A access for the users fully qualified href location on the system.
62
+ *
63
+ * @return {string} the href location
64
+ * @constructor
65
+ */
66
+ get Href() {
67
+ return this.href;
68
+ }
69
+ }
70
+ //# sourceMappingURL=user.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/user.entity.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACrB,YAAoB,EAAU,EACV,QAAgB,EAChB,KAAoB,EACpB,SAAkB,EAClB,QAAiB,EACjB,IAAa;QALb,OAAE,GAAF,EAAE,CAAQ;QACV,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAe;QACpB,cAAS,GAAT,SAAS,CAAS;QAClB,aAAQ,GAAR,QAAQ,CAAS;QACjB,SAAI,GAAJ,IAAI,CAAS;IACjC,CAAC;IAED;;;;;OAKG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CAEF"}
@@ -0,0 +1 @@
1
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,2 @@
1
+ export const ɵNonEmptyModule = true;
2
+ //# sourceMappingURL=user.entity.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.entity.ngfactory.js","sourceRoot":"","sources":["../../src/user.entity.ngfactory.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const ɵempty: any;
@@ -0,0 +1,2 @@
1
+ export const ɵempty = null;
2
+ //# sourceMappingURL=user.entity.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.entity.ngsummary.js","sourceRoot":"","sources":["../../src/user.entity.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { ModuleWithProviders } from "@angular/core";
2
+ import * as i0 from "@angular/core";
3
+ import * as i1 from "./authorization/role-check.directive";
4
+ import * as i2 from "./authorization/role-check-unless-null.directive";
5
+ import * as i3 from "@angular/common";
6
+ import * as i4 from "@angular/forms";
7
+ /**
8
+ * A feature module for user related services, directives, pipes, etc...
9
+ *
10
+ * @since 1.0.0
11
+ */
12
+ export declare class UserModule {
13
+ static forRoot(): ModuleWithProviders<UserModule>;
14
+ static ɵfac: i0.ɵɵFactoryDef<UserModule, never>;
15
+ static ɵmod: i0.ɵɵNgModuleDefWithMeta<UserModule, [typeof i1.RoleCheckDirective, typeof i2.RoleCheckUnlessNullDirective], [typeof i3.CommonModule, typeof i4.ReactiveFormsModule, typeof i4.FormsModule], [typeof i1.RoleCheckDirective, typeof i2.RoleCheckUnlessNullDirective]>;
16
+ static ɵinj: i0.ɵɵInjectorDef<UserModule>;
17
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ import { NgModule } from "@angular/core";
5
+ import { CommonModule } from "@angular/common";
6
+ import { ReactiveFormsModule, FormsModule } from "@angular/forms";
7
+ import { UserService } from "./user.service";
8
+ import { RoleCheckDirective } from "./authorization/role-check.directive";
9
+ import { RoleCheckUnlessNullDirective } from "./authorization/role-check-unless-null.directive";
10
+ import * as i0 from "@angular/core";
11
+ /**
12
+ * A feature module for user related services, directives, pipes, etc...
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ export class UserModule {
17
+ static forRoot() {
18
+ return {
19
+ providers: [
20
+ UserService
21
+ ],
22
+ ngModule: UserModule
23
+ };
24
+ }
25
+ }
26
+ UserModule.ɵfac = function UserModule_Factory(t) { return new (t || UserModule)(); };
27
+ UserModule.ɵmod = i0.ɵɵdefineNgModule({ type: UserModule });
28
+ UserModule.ɵinj = i0.ɵɵdefineInjector({ imports: [[
29
+ CommonModule,
30
+ ReactiveFormsModule,
31
+ FormsModule
32
+ ]] });
33
+ (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(UserModule, { declarations: [RoleCheckDirective,
34
+ RoleCheckUnlessNullDirective], imports: [CommonModule,
35
+ ReactiveFormsModule,
36
+ FormsModule], exports: [RoleCheckDirective,
37
+ RoleCheckUnlessNullDirective] }); })();
38
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserModule, [{
39
+ type: NgModule,
40
+ args: [{
41
+ imports: [
42
+ CommonModule,
43
+ ReactiveFormsModule,
44
+ FormsModule
45
+ ],
46
+ declarations: [
47
+ RoleCheckDirective,
48
+ RoleCheckUnlessNullDirective
49
+ ],
50
+ exports: [
51
+ RoleCheckDirective,
52
+ RoleCheckUnlessNullDirective
53
+ ]
54
+ }]
55
+ }], null, null); })();
56
+ //# sourceMappingURL=user.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../src/user.module.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAsB,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhE,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,4BAA4B,EAAC,MAAM,kDAAkD,CAAC;;AAE9F;;;;GAIG;AAgBH,MAAM,OAAO,UAAU;IACrB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,SAAS,EAAE;gBACT,WAAW;aACZ;YACD,QAAQ,EAAE,UAAU;SACrB,CAAC;IACJ,CAAC;;oEARU,UAAU;8CAAV,UAAU;kDAdZ;YACP,YAAY;YACZ,mBAAmB;YACnB,WAAW;SACZ;wFAUU,UAAU,mBARnB,kBAAkB;QAClB,4BAA4B,aAN5B,YAAY;QACZ,mBAAmB;QACnB,WAAW,aAOX,kBAAkB;QAClB,4BAA4B;uFAGnB,UAAU;cAftB,QAAQ;eAAC;gBACR,OAAO,EAAE;oBACP,YAAY;oBACZ,mBAAmB;oBACnB,WAAW;iBACZ;gBACD,YAAY,EAAE;oBACZ,kBAAkB;oBAClB,4BAA4B;iBAC7B;gBACD,OAAO,EAAE;oBACP,kBAAkB;oBAClB,4BAA4B;iBAC7B;aACF"}
@@ -0,0 +1,3 @@
1
+ import * as i0 from '@angular/core';
2
+ export declare const UserModuleNgFactory: i0.ɵNgModuleFactory<any>;
3
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,4 @@
1
+ import * as i0 from '@angular/core';
2
+ import { UserModule } from './user.module';
3
+ export const UserModuleNgFactory = i0.ɵnoSideEffects(function () { return new i0.ɵNgModuleFactory(UserModule); });
4
+ //# sourceMappingURL=user.module.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.module.ngfactory.js","sourceRoot":"","sources":["../../src/user.module.ngfactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,0CAA6B,IAAI,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAA,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const UserModuleNgSummary: any;
@@ -0,0 +1,2 @@
1
+ export const UserModuleNgSummary = null;
2
+ //# sourceMappingURL=user.module.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.module.ngsummary.js","sourceRoot":"","sources":["../../src/user.module.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAQ,IAAI,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ import { HttpClient } from "@angular/common/http";
3
+ import { Observable } from "rxjs";
4
+ import { UserEntity } from "./user.entity";
5
+ export declare let AUTHENTICATED_USER_ENDPOINT: InjectionToken<string>;
6
+ /**
7
+ * @since 1.0.0
8
+ */
9
+ export declare class UserService {
10
+ private _http;
11
+ private _authenticationUserEndpoint;
12
+ /**
13
+ * The generic error message used when a server error is thrown without a status.
14
+ *
15
+ * @type {string}
16
+ */
17
+ static GENERIC_ERR_MSG: string;
18
+ private _authenticatedUser;
19
+ constructor(_http: HttpClient, _authenticationUserEndpoint: string);
20
+ /**
21
+ * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is
22
+ * available, the appropriate response status should be returned from the server to indicate that condition
23
+ * (i.e. 404 - Not Found).
24
+ *
25
+ * @returns {Observable<UserEntity>} the currently authenticated user representation
26
+ */
27
+ getAuthenticatedUser(): Observable<UserEntity>;
28
+ private handleError;
29
+ /**
30
+ * TODO: Add in a deserializer into the entity.
31
+ *
32
+ * @param userJson
33
+ * @returns {UserEntity}
34
+ */
35
+ private buildUserEntity;
36
+ getPermissions(governorClass: string, governorId: number, governedClass: string): Observable<any>;
37
+ }
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Copyright (c) 2016 Huntsman Cancer Institute at the University of Utah, Confidential and Proprietary
3
+ */
4
+ import { Injectable, InjectionToken, Inject, isDevMode } from "@angular/core";
5
+ import { HttpClient, HttpHeaders } from "@angular/common/http";
6
+ import { Observable, of } from "rxjs";
7
+ import { catchError, map } from "rxjs/operators";
8
+ import { UserEntity } from "./user.entity";
9
+ import { RoleEntity } from "./authorization/role.entity";
10
+ import { PermissionEntity } from "./authorization/permission.entity";
11
+ import * as i0 from "@angular/core";
12
+ import * as i1 from "@angular/common/http";
13
+ export let AUTHENTICATED_USER_ENDPOINT = new InjectionToken("authenticated_user_url");
14
+ /**
15
+ * @since 1.0.0
16
+ */
17
+ export class UserService {
18
+ constructor(_http, _authenticationUserEndpoint) {
19
+ this._http = _http;
20
+ this._authenticationUserEndpoint = _authenticationUserEndpoint;
21
+ this._authenticatedUser = null;
22
+ }
23
+ /**
24
+ * An accessor for an {@code Observable<UserEntity>} reflecting the currently authenticated user. If no subject is
25
+ * available, the appropriate response status should be returned from the server to indicate that condition
26
+ * (i.e. 404 - Not Found).
27
+ *
28
+ * @returns {Observable<UserEntity>} the currently authenticated user representation
29
+ */
30
+ getAuthenticatedUser() {
31
+ if (isDevMode() && console && console.debug) {
32
+ console.debug("getAuthenticatedUser");
33
+ }
34
+ if (!this._authenticatedUser) {
35
+ if (isDevMode() && console && console.debug) {
36
+ console.debug("_authenticationUserEndpoint: " + this._authenticationUserEndpoint);
37
+ }
38
+ return this._http.get(this._authenticationUserEndpoint, { observe: "response" }).pipe(map((resp) => {
39
+ if (resp.status === 200) {
40
+ this._authenticatedUser = this.buildUserEntity(resp.body);
41
+ return this._authenticatedUser;
42
+ }
43
+ else {
44
+ throw new Error("Get authenticated user failed. " + resp.status + ": " + resp.statusText);
45
+ }
46
+ }), catchError(this.handleError));
47
+ }
48
+ else {
49
+ return of(this._authenticatedUser);
50
+ }
51
+ }
52
+ handleError(error) {
53
+ let errMsg = (error.message) ? error.message : UserService.GENERIC_ERR_MSG;
54
+ return Observable.throw(errMsg);
55
+ }
56
+ /**
57
+ * TODO: Add in a deserializer into the entity.
58
+ *
59
+ * @param userJson
60
+ * @returns {UserEntity}
61
+ */
62
+ buildUserEntity(userJson) {
63
+ let roles = [];
64
+ if (userJson.roles) {
65
+ userJson.roles.map((role) => {
66
+ let permissions;
67
+ if (role.permissions) {
68
+ /* TODO: JEH (10/27/16) - Revisit when we determine how permission are communicated to the client, if necessary */
69
+ permissions = role.permissions.map((permission) => {
70
+ return new PermissionEntity(permission.domain, permission.actions, permission.instances);
71
+ });
72
+ }
73
+ roles.push(new RoleEntity(role.roleName, permissions));
74
+ });
75
+ }
76
+ return new UserEntity(userJson.idUser, userJson.username, roles, userJson.firstname, userJson.lastname, userJson.href);
77
+ }
78
+ getPermissions(governorClass, governorId, governedClass) {
79
+ let headers = new HttpHeaders()
80
+ .set("SecurityGovernorClass", governorClass).set("SecurityGovernorId", String(governorId));
81
+ return this._http.get("/core/api/user/permissions/" + governedClass, { headers: headers });
82
+ }
83
+ }
84
+ /**
85
+ * The generic error message used when a server error is thrown without a status.
86
+ *
87
+ * @type {string}
88
+ */
89
+ UserService.GENERIC_ERR_MSG = "Server error";
90
+ UserService.ɵfac = function UserService_Factory(t) { return new (t || UserService)(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(AUTHENTICATED_USER_ENDPOINT)); };
91
+ UserService.ɵprov = i0.ɵɵdefineInjectable({ token: UserService, factory: UserService.ɵfac });
92
+ (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UserService, [{
93
+ type: Injectable
94
+ }], function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
95
+ type: Inject,
96
+ args: [AUTHENTICATED_USER_ENDPOINT]
97
+ }] }]; }, null); })();
98
+ //# sourceMappingURL=user.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user.service.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ import * as i0 from '@angular/core';
2
+ export declare const UserServiceNgFactory: i0.ɵNgModuleFactory<any>;
3
+ export declare const ɵNonEmptyModule = true;
@@ -0,0 +1,4 @@
1
+ import * as i0 from '@angular/core';
2
+ import { UserService } from './user.service';
3
+ export const ɵNonEmptyModule = true;
4
+ //# sourceMappingURL=user.service.ngfactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.ngfactory.js","sourceRoot":"","sources":["../../src/user.service.ngfactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const UserServiceNgSummary: any;
@@ -0,0 +1,2 @@
1
+ export const UserServiceNgSummary = null;
2
+ //# sourceMappingURL=user.service.ngsummary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.service.ngsummary.js","sourceRoot":"","sources":["../../src/user.service.ngsummary.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAQ,IAAI,CAAC"}