@odx/auth 15.0.0 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/esm2022/lib/auth.component.mjs +6 -1
- package/esm2022/lib/auth.config.mjs +38 -1
- package/esm2022/lib/auth.directive.mjs +11 -1
- package/esm2022/lib/auth.guard.mjs +9 -1
- package/esm2022/lib/auth.interceptor.mjs +8 -1
- package/esm2022/lib/auth.providers.mjs +35 -1
- package/esm2022/lib/auth.service.mjs +159 -1
- package/esm2022/lib/components/auth-actions/auth-actions.component.mjs +10 -1
- package/esm2022/lib/components/auth-loading-screen/auth-loading-screen.component.mjs +15 -3
- package/esm2022/lib/directives/auth-action.directive.mjs +7 -1
- package/esm2022/lib/directives/sign-in.directive.mjs +20 -1
- package/esm2022/lib/directives/sign-out.directive.mjs +20 -1
- package/esm2022/lib/helpers/create-auth-host-url.mjs +13 -1
- package/esm2022/lib/helpers/create-inititals.mjs +18 -1
- package/esm2022/lib/helpers/handle-auth-error.mjs +13 -3
- package/esm2022/lib/helpers/handle-oauth-event.mjs +9 -1
- package/esm2022/lib/helpers/resolve-email.mjs +21 -1
- package/esm2022/lib/helpers/resolve-username.mjs +22 -1
- package/esm2022/lib/helpers/set-http-auth-header.mjs +10 -1
- package/esm2022/lib/helpers/user-language-loader.mjs +8 -1
- package/esm2022/lib/plugins/core-debug.plugin.mjs +10 -1
- package/esm2022/lib/plugins/core-identity.plugin.mjs +8 -1
- package/esm2022/lib/plugins/user-profile-link.plugin.mjs +10 -1
- package/esm2022/lib/unauth.guard.mjs +9 -1
- package/esm2022/plugins/service-connect/lib/helpers/build-service-connect-url.mjs +8 -1
- package/esm2022/plugins/service-connect/lib/helpers/has-roles-or-rights-handler.mjs +8 -1
- package/esm2022/plugins/service-connect/lib/helpers/has-roles-or-rights.mjs +8 -1
- package/esm2022/plugins/service-connect/lib/helpers/service-connect-plugin-factory.mjs +7 -1
- package/esm2022/plugins/service-connect/lib/service-connect-rights.directive.mjs +13 -1
- package/esm2022/plugins/service-connect/lib/service-connect-rights.guard.mjs +9 -1
- package/esm2022/plugins/service-connect/lib/service-connect-rights.plugin.mjs +9 -1
- package/esm2022/plugins/service-connect/lib/service-connect-user-language.plugin.mjs +15 -1
- package/esm2022/plugins/service-connect/lib/service-connect-user-profile.plugin.mjs +9 -1
- package/fesm2022/odx-auth-plugins-service-connect.mjs +77 -0
- package/fesm2022/odx-auth-plugins-service-connect.mjs.map +1 -1
- package/fesm2022/odx-auth.mjs +466 -5
- package/fesm2022/odx-auth.mjs.map +1 -1
- package/lib/auth.component.d.ts +5 -0
- package/lib/auth.config.d.ts +42 -0
- package/lib/auth.directive.d.ts +10 -0
- package/lib/auth.guard.d.ts +8 -0
- package/lib/auth.interceptor.d.ts +7 -0
- package/lib/auth.providers.d.ts +34 -0
- package/lib/auth.service.d.ts +156 -0
- package/lib/components/auth-actions/auth-actions.component.d.ts +9 -0
- package/lib/components/auth-loading-screen/auth-loading-screen.component.d.ts +13 -0
- package/lib/directives/auth-action.directive.d.ts +6 -0
- package/lib/directives/sign-in.directive.d.ts +19 -0
- package/lib/directives/sign-out.directive.d.ts +19 -0
- package/lib/helpers/create-auth-host-url.d.ts +12 -0
- package/lib/helpers/create-inititals.d.ts +17 -0
- package/lib/helpers/handle-auth-error.d.ts +10 -0
- package/lib/helpers/handle-oauth-event.d.ts +8 -0
- package/lib/helpers/resolve-email.d.ts +20 -0
- package/lib/helpers/resolve-username.d.ts +21 -0
- package/lib/helpers/set-http-auth-header.d.ts +9 -0
- package/lib/helpers/user-language-loader.d.ts +7 -0
- package/lib/plugins/core-debug.plugin.d.ts +9 -0
- package/lib/plugins/core-identity.plugin.d.ts +7 -0
- package/lib/plugins/user-profile-link.plugin.d.ts +9 -0
- package/lib/unauth.guard.d.ts +8 -0
- package/package.json +1 -1
- package/plugins/service-connect/lib/helpers/build-service-connect-url.d.ts +7 -0
- package/plugins/service-connect/lib/helpers/has-roles-or-rights-handler.d.ts +7 -0
- package/plugins/service-connect/lib/helpers/has-roles-or-rights.d.ts +7 -0
- package/plugins/service-connect/lib/helpers/service-connect-plugin-factory.d.ts +6 -0
- package/plugins/service-connect/lib/service-connect-rights.directive.d.ts +12 -0
- package/plugins/service-connect/lib/service-connect-rights.guard.d.ts +8 -0
- package/plugins/service-connect/lib/service-connect-rights.plugin.d.ts +8 -0
- package/plugins/service-connect/lib/service-connect-user-language.plugin.d.ts +14 -0
- package/plugins/service-connect/lib/service-connect-user-profile.plugin.d.ts +8 -0
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { serviceConnectPluginFactory } from './helpers';
|
|
2
2
|
import { getServiceConnectUserLanguage } from './service-connect-user-language.plugin';
|
|
3
3
|
import { ServiceConnectEndpoints } from './service-connect.config';
|
|
4
|
+
/**
|
|
5
|
+
* A plugin for fetching and parsing the user's profile from service connect.
|
|
6
|
+
*
|
|
7
|
+
* This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches the user's profile
|
|
8
|
+
* from the user endpoint and parses the response to extract the user's profile information.
|
|
9
|
+
*
|
|
10
|
+
* @see {serviceConnectPluginFactory}
|
|
11
|
+
*/
|
|
4
12
|
export const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
5
13
|
endpoint: [ServiceConnectEndpoints.user],
|
|
6
14
|
parseResponse: (res) => {
|
|
@@ -13,4 +21,4 @@ export const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
|
13
21
|
};
|
|
14
22
|
},
|
|
15
23
|
});
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS1jb25uZWN0LXVzZXItcHJvZmlsZS5wbHVnaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2F1dGgvcGx1Z2lucy9zZXJ2aW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vbnNlRHRvPih7XG4gIGVuZHBvaW50OiBbU2VydmljZUNvbm5lY3RFbmRwb2ludHMudXNlcl0sXG4gIHBhcnNlUmVzcG9uc2U6IChyZXMpID0+IHtcbiAgICByZXR1cm4ge1xuICAgICAgY291bnRyeTogcmVzPy5jb3VudHJ5LFxuICAgICAgaW5zdGl0dXRpb25JZDogcmVzPy5pbnN0aXR1dGlvbl9pZCxcbiAgICAgIGluc3RpdHV0aW9uTmFtZTogcmVzPy5pbnN0aXR1dGlvbl9uYW1lLFxuICAgICAgaW5zdGl0dXRpb25TaG9ydG5hbWU6IHJlcz8uaW5zdGl0dXRpb25fc2hvcnRuYW1lLFxuICAgICAgcHJlZmVycmVkTGFuZ3VhZ2U6IGdldFNlcnZpY2VDb25uZWN0VXNlckxhbmd1YWdlKHJlcyksXG4gICAgfTtcbiAgfSxcbn0pO1xuIl19
|
|
@@ -22,6 +22,13 @@ const ServiceConnectEndpoints = {
|
|
|
22
22
|
userRights: '/users/me/rights',
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Builds a service connect URL based on the provided environment and endpoints.
|
|
27
|
+
*
|
|
28
|
+
* @param {ServiceConnectEnvironment | AuthEnvironment} environment - The environment configuration which can be either a `ServiceConnectEnvironment` or `AuthEnvironment`.
|
|
29
|
+
* @param {string[]} endpoints - A list of endpoint strings to be appended to the base URL.
|
|
30
|
+
* @returns {string} - The constructed service connect URL as a string.
|
|
31
|
+
*/
|
|
25
32
|
function buildServiceConnectUrl(environment, ...endpoints) {
|
|
26
33
|
if (isString(environment)) {
|
|
27
34
|
return buildUrl(ServiceConnnectEnvironments[environment], ...endpoints);
|
|
@@ -29,14 +36,34 @@ function buildServiceConnectUrl(environment, ...endpoints) {
|
|
|
29
36
|
return buildUrl(environment.custom, ...endpoints);
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the user has any of the specified roles or rights.
|
|
41
|
+
*
|
|
42
|
+
* @param {Right[]} userRights - An array of rights that the user possesses.
|
|
43
|
+
* @param {RolesOrRights} rolesOrRights - An array of roles or rights to check against. A role is represented as an array of rights.
|
|
44
|
+
* @returns {boolean} - `true` if the user has any of the specified roles or rights, otherwise `false`.
|
|
45
|
+
*/
|
|
32
46
|
function hasRolesOrRights(userRights, rolesOrRights) {
|
|
33
47
|
return rolesOrRights.some((rights) => (Array.isArray(rights) ? rights : [rights])?.every((right) => userRights.includes(right)));
|
|
34
48
|
}
|
|
35
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Creates an authorized handler that checks if the user has the specified roles or rights.
|
|
52
|
+
*
|
|
53
|
+
* @param {RolesOrRights} rolesOrRights - The roles or rights to check against the user's claims.
|
|
54
|
+
* @returns {AuthorizedHandler} - An handler function that takes user claims and returns a boolean indicating
|
|
55
|
+
* whether the user has the required roles or rights.
|
|
56
|
+
*/
|
|
36
57
|
function hasRolesOrRightsHandler(rolesOrRights) {
|
|
37
58
|
return (claims) => hasRolesOrRights(claims?.rights ?? [], rolesOrRights);
|
|
38
59
|
}
|
|
39
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Creates a plugin factory for fetching and parsing service connect data.
|
|
63
|
+
*
|
|
64
|
+
* @param {ServiceConnectPluginFactoryOptions<Dto>} options - The options for the service connect plugin factory.
|
|
65
|
+
* @returns {ServiceConnectPluginFactory} - A function that creates an auth plugin factory for fetching and parsing service connect data.
|
|
66
|
+
*/
|
|
40
67
|
function serviceConnectPluginFactory(options) {
|
|
41
68
|
return (pluginOptions) => () => {
|
|
42
69
|
options.setup?.(pluginOptions);
|
|
@@ -50,10 +77,22 @@ function serviceConnectPluginFactory(options) {
|
|
|
50
77
|
};
|
|
51
78
|
}
|
|
52
79
|
|
|
80
|
+
/**
|
|
81
|
+
* A directive that extends the functionality of the `AuthDirective` to handle
|
|
82
|
+
* roles or rights for service connection authorization.
|
|
83
|
+
*
|
|
84
|
+
* @see AuthDirective
|
|
85
|
+
*
|
|
86
|
+
* This directive should be used on an `ng-template` element with the selector
|
|
87
|
+
* `odxAuthServiceConnectRights`.
|
|
88
|
+
*/
|
|
53
89
|
class ServiceConnectRightsDirective {
|
|
54
90
|
constructor() {
|
|
55
91
|
this.authDirective = inject(AuthDirective, { host: true });
|
|
56
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Sets the roles or rights that the user must have to display the content.
|
|
95
|
+
*/
|
|
57
96
|
set rolesOrRights(value) {
|
|
58
97
|
this.authDirective.authorizationHandler = hasRolesOrRightsHandler(value ?? []);
|
|
59
98
|
}
|
|
@@ -77,25 +116,63 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.12", ngImpo
|
|
|
77
116
|
args: ['odxAuthServiceConnectRights']
|
|
78
117
|
}] } });
|
|
79
118
|
|
|
119
|
+
/**
|
|
120
|
+
* A guard function to check if the user has the required roles or rights to access a route.
|
|
121
|
+
*
|
|
122
|
+
* @param {RolesOrRights} rolesOrRights - The roles or rights required to access the route.
|
|
123
|
+
* @param {string | any[]} redirectTo - (Optional) The route to redirect to if the user does not have the required roles or rights.
|
|
124
|
+
* @param {boolean} isExternal - (Optional) A flag indicating if the redirection is to an external URL. Defaults to `false`.
|
|
125
|
+
* @returns {CanActivateFn} - A function that checks the user's roles or rights and handles redirection if necessary.
|
|
126
|
+
*/
|
|
80
127
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
128
|
function serviceConnectRightsGuard(rolesOrRights, redirectTo, isExternal = false) {
|
|
82
129
|
return authGuard(hasRolesOrRightsHandler(rolesOrRights), redirectTo, isExternal);
|
|
83
130
|
}
|
|
84
131
|
|
|
132
|
+
/**
|
|
133
|
+
* A plugin for fetching and parsing service connect rights.
|
|
134
|
+
*
|
|
135
|
+
* This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches user rights
|
|
136
|
+
* from the specified endpoint and parses the response to extract the rights.
|
|
137
|
+
*
|
|
138
|
+
* @see {serviceConnectPluginFactory}
|
|
139
|
+
*/
|
|
85
140
|
const serviceConnectRightsPlugin = serviceConnectPluginFactory({
|
|
86
141
|
endpoint: [ServiceConnectEndpoints.userRights],
|
|
87
142
|
parseResponse: (res) => ({ rights: res?.rights ?? [] }),
|
|
88
143
|
defaultValue: { rights: [] },
|
|
89
144
|
});
|
|
90
145
|
|
|
146
|
+
/**
|
|
147
|
+
* Gets the language code from a service connect user response.
|
|
148
|
+
*
|
|
149
|
+
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
150
|
+
* @returns {string | undefined} - The language code or undefined.
|
|
151
|
+
*/
|
|
91
152
|
function getServiceConnectUserLanguage(res) {
|
|
92
153
|
return (res?.preferred_language ?? res?.language_code) ? getLanguageCode(res.preferred_language ?? res.language_code) : undefined;
|
|
93
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* A plugin for fetching and parsing the user's preferred language from service connect.
|
|
157
|
+
*
|
|
158
|
+
* This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches the user's preferred language
|
|
159
|
+
* from the user endpoint and parses the response to extract the preferred language.
|
|
160
|
+
*
|
|
161
|
+
* @see {serviceConnectPluginFactory}
|
|
162
|
+
*/
|
|
94
163
|
const serviceConnectUserLanguagePlugin = serviceConnectPluginFactory({
|
|
95
164
|
endpoint: [ServiceConnectEndpoints.user],
|
|
96
165
|
parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res) }),
|
|
97
166
|
});
|
|
98
167
|
|
|
168
|
+
/**
|
|
169
|
+
* A plugin for fetching and parsing the user's profile from service connect.
|
|
170
|
+
*
|
|
171
|
+
* This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches the user's profile
|
|
172
|
+
* from the user endpoint and parses the response to extract the user's profile information.
|
|
173
|
+
*
|
|
174
|
+
* @see {serviceConnectPluginFactory}
|
|
175
|
+
*/
|
|
99
176
|
const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
100
177
|
endpoint: [ServiceConnectEndpoints.user],
|
|
101
178
|
parseResponse: (res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odx-auth-plugins-service-connect.mjs","sources":["../../../../libs/auth/plugins/service-connect/src/lib/service-connect.config.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/build-service-connect-url.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights-handler.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/service-connect-plugin-factory.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.directive.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.guard.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.plugin.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-user-language.plugin.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-user-profile.plugin.ts","../../../../libs/auth/plugins/service-connect/src/odx-auth-plugins-service-connect.ts"],"sourcesContent":["import { AuthEnvironment } from '@odx/auth';\n\nexport type ServiceConnectEnvironment = { custom: string };\nexport const ServiceConnnectEnvironments: Record<AuthEnvironment, string> = {\n [AuthEnvironment.DEV]: 'https://api.test.connect.draeger.com',\n [AuthEnvironment.STAGE]: 'https://api.staging.connect.draeger.com',\n [AuthEnvironment.PROD]: 'https://api.connect.draeger.com',\n};\nexport const ServiceConnectScopes = {\n BASE: 'dcid',\n PROFILE: 'dcid.profile',\n RIGHTS: 'dcid.rights',\n INSTITUTION: 'dcid.institution',\n};\nexport const ServiceConnectEndpoints = {\n user: '/users/me',\n userRights: '/users/me/rights',\n};\n","import { buildUrl, isString } from '@odx/angular/utils';\nimport { AuthEnvironment } from '@odx/auth';\nimport { ServiceConnectEnvironment, ServiceConnnectEnvironments } from '../service-connect.config';\n\nexport function buildServiceConnectUrl(environment: ServiceConnectEnvironment | AuthEnvironment, ...endpoints: string[]): string {\n if (isString(environment)) {\n return buildUrl(ServiceConnnectEnvironments[environment], ...endpoints);\n }\n return buildUrl(environment.custom, ...endpoints);\n}\n","export type Right = string | number;\nexport type Role = Right[];\nexport type RolesOrRights = Array<Role | Right>;\n\nexport function hasRolesOrRights(userRights: Right[], rolesOrRights: RolesOrRights): boolean {\n return rolesOrRights.some((rights) => (Array.isArray(rights) ? rights : [rights])?.every((right) => userRights.includes(right)));\n}\n","import { AuthorizedHandler } from '@odx/auth';\nimport { hasRolesOrRights, RolesOrRights } from './has-roles-or-rights';\n\nexport function hasRolesOrRightsHandler(rolesOrRights: RolesOrRights): AuthorizedHandler {\n return (claims) => hasRolesOrRights(claims?.rights ?? [], rolesOrRights);\n}\n","import { HttpClient, HttpContext } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { AuthPluginFactory, injectAuthConfig, requireAuthentication } from '@odx/auth';\nimport { defer, map } from 'rxjs';\nimport { ServiceConnectEnvironment } from '../service-connect.config';\nimport { buildServiceConnectUrl } from './build-service-connect-url';\n\nexport interface ServiceConnectPluginOptions {\n environment?: ServiceConnectEnvironment;\n}\n\nexport interface ServiceConnectPluginFactoryOptions<Dto> {\n endpoint: string[];\n parseResponse: (res: Dto | null) => Partial<OdxAuth.AuthPluginResult>;\n defaultValue?: Partial<OdxAuth.AuthPluginResult>;\n setup?: (pluginOptions?: ServiceConnectPluginOptions) => void;\n}\n\nexport type ServiceConnectPluginFactory = (pluginOptions?: ServiceConnectPluginOptions) => AuthPluginFactory;\n\nexport function serviceConnectPluginFactory<Dto = unknown>(options: ServiceConnectPluginFactoryOptions<Dto>): ServiceConnectPluginFactory {\n return (pluginOptions) => () => {\n options.setup?.(pluginOptions);\n const { environment } = injectAuthConfig();\n const httpClient = inject(HttpClient);\n const url = buildServiceConnectUrl(pluginOptions?.environment ?? environment, ...options.endpoint);\n const parseResponse = (dto: Dto | null) => options.parseResponse(dto) ?? options.defaultValue ?? {};\n\n return () =>\n defer(() =>\n httpClient.get<Dto>(url, {\n context: new HttpContext().set(requireAuthentication, true),\n }),\n ).pipe(map((dto) => parseResponse(dto)));\n };\n}\n","import { Directive, inject, Input } from '@angular/core';\nimport { AuthDirective } from '@odx/auth';\nimport { hasRolesOrRightsHandler, RolesOrRights } from './helpers';\n\n@Directive({\n standalone: true,\n selector: 'ng-template[odxAuthServiceConnectRights]',\n hostDirectives: [\n {\n directive: AuthDirective,\n inputs: ['odxAuthElse:odxAuthServiceConnectRightsElse'],\n },\n ],\n})\nexport class ServiceConnectRightsDirective {\n private readonly authDirective = inject(AuthDirective, { host: true });\n\n @Input('odxAuthServiceConnectRights')\n public set rolesOrRights(value: RolesOrRights | null | undefined) {\n this.authDirective.authorizationHandler = hasRolesOrRightsHandler(value ?? []);\n }\n}\n","import { CanActivateFn } from '@angular/router';\nimport { authGuard } from '@odx/auth';\nimport { hasRolesOrRightsHandler, RolesOrRights } from './helpers';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function serviceConnectRightsGuard(rolesOrRights: RolesOrRights, redirectTo?: string | any[], isExternal = false): CanActivateFn {\n return authGuard(hasRolesOrRightsHandler(rolesOrRights), redirectTo, isExternal);\n}\n","import { GetServiceConnectRightsResponseDto } from './dtos';\nimport { Right, serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace OdxAuth {\n interface AuthPluginResult {\n rights: Right[];\n }\n }\n}\n\nexport const serviceConnectRightsPlugin = serviceConnectPluginFactory<GetServiceConnectRightsResponseDto>({\n endpoint: [ServiceConnectEndpoints.userRights],\n parseResponse: (res) => ({ rights: res?.rights ?? [] }),\n defaultValue: { rights: [] },\n});\n","import { getLanguageCode } from '@odx/angular/utils';\nimport { GetServiceConnectUserResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\nexport function getServiceConnectUserLanguage(res?: GetServiceConnectUserResponseDto | null): string | undefined {\n return (res?.preferred_language ?? res?.language_code) ? getLanguageCode(res.preferred_language ?? res.language_code) : undefined;\n}\n\nexport const serviceConnectUserLanguagePlugin = serviceConnectPluginFactory<GetServiceConnectUserResponseDto>({\n endpoint: [ServiceConnectEndpoints.user],\n parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res) }),\n});\n","import { GetServiceConnectUserResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { getServiceConnectUserLanguage } from './service-connect-user-language.plugin';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace OdxAuth {\n interface AuthPluginResult {\n country?: string;\n institutionId?: number;\n institutionName?: string;\n institutionShortname?: string;\n }\n }\n}\n\nexport const serviceConnectUserProfilePlugin = serviceConnectPluginFactory<GetServiceConnectUserResponseDto>({\n endpoint: [ServiceConnectEndpoints.user],\n parseResponse: (res) => {\n return {\n country: res?.country,\n institutionId: res?.institution_id,\n institutionName: res?.institution_name,\n institutionShortname: res?.institution_shortname,\n preferredLanguage: getServiceConnectUserLanguage(res),\n };\n },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAGa,MAAA,2BAA2B,GAAoC;AAC1E,IAAA,CAAC,eAAe,CAAC,GAAG,GAAG,sCAAsC;AAC7D,IAAA,CAAC,eAAe,CAAC,KAAK,GAAG,yCAAyC;AAClE,IAAA,CAAC,eAAe,CAAC,IAAI,GAAG,iCAAiC;;AAE9C,MAAA,oBAAoB,GAAG;AAClC,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,MAAM,EAAE,aAAa;AACrB,IAAA,WAAW,EAAE,kBAAkB;;AAEpB,MAAA,uBAAuB,GAAG;AACrC,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU,EAAE,kBAAkB;;;SCZhB,sBAAsB,CAAC,WAAwD,EAAE,GAAG,SAAmB,EAAA;AACrH,IAAA,IAAI,QAAQ,CA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sources":["../../../../libs/auth/plugins/service-connect/src/lib/service-connect.config.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/build-service-connect-url.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights-handler.ts","../../../../libs/auth/plugins/service-connect/src/lib/helpers/service-connect-plugin-factory.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.directive.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.guard.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-rights.plugin.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-user-language.plugin.ts","../../../../libs/auth/plugins/service-connect/src/lib/service-connect-user-profile.plugin.ts","../../../../libs/auth/plugins/service-connect/src/odx-auth-plugins-service-connect.ts"],"sourcesContent":["import { AuthEnvironment } from '@odx/auth';\n\nexport type ServiceConnectEnvironment = { custom: string };\nexport const ServiceConnnectEnvironments: Record<AuthEnvironment, string> = {\n [AuthEnvironment.DEV]: 'https://api.test.connect.draeger.com',\n [AuthEnvironment.STAGE]: 'https://api.staging.connect.draeger.com',\n [AuthEnvironment.PROD]: 'https://api.connect.draeger.com',\n};\nexport const ServiceConnectScopes = {\n BASE: 'dcid',\n PROFILE: 'dcid.profile',\n RIGHTS: 'dcid.rights',\n INSTITUTION: 'dcid.institution',\n};\nexport const ServiceConnectEndpoints = {\n user: '/users/me',\n userRights: '/users/me/rights',\n};\n","import { buildUrl, isString } from '@odx/angular/utils';\nimport { AuthEnvironment } from '@odx/auth';\nimport { ServiceConnectEnvironment, ServiceConnnectEnvironments } from '../service-connect.config';\n\n/**\n * Builds a service connect URL based on the provided environment and endpoints.\n *\n * @param {ServiceConnectEnvironment | AuthEnvironment} environment - The environment configuration which can be either a `ServiceConnectEnvironment` or `AuthEnvironment`.\n * @param {string[]} endpoints - A list of endpoint strings to be appended to the base URL.\n * @returns {string} - The constructed service connect URL as a string.\n */\nexport function buildServiceConnectUrl(environment: ServiceConnectEnvironment | AuthEnvironment, ...endpoints: string[]): string {\n if (isString(environment)) {\n return buildUrl(ServiceConnnectEnvironments[environment], ...endpoints);\n }\n return buildUrl(environment.custom, ...endpoints);\n}\n","export type Right = string | number;\nexport type Role = Right[];\nexport type RolesOrRights = Array<Role | Right>;\n\n/**\n * Checks if the user has any of the specified roles or rights.\n *\n * @param {Right[]} userRights - An array of rights that the user possesses.\n * @param {RolesOrRights} rolesOrRights - An array of roles or rights to check against. A role is represented as an array of rights.\n * @returns {boolean} - `true` if the user has any of the specified roles or rights, otherwise `false`.\n */\nexport function hasRolesOrRights(userRights: Right[], rolesOrRights: RolesOrRights): boolean {\n return rolesOrRights.some((rights) => (Array.isArray(rights) ? rights : [rights])?.every((right) => userRights.includes(right)));\n}\n","import { AuthorizedHandler } from '@odx/auth';\nimport { hasRolesOrRights, RolesOrRights } from './has-roles-or-rights';\n\n/**\n * Creates an authorized handler that checks if the user has the specified roles or rights.\n *\n * @param {RolesOrRights} rolesOrRights - The roles or rights to check against the user's claims.\n * @returns {AuthorizedHandler} - An handler function that takes user claims and returns a boolean indicating\n * whether the user has the required roles or rights.\n */\nexport function hasRolesOrRightsHandler(rolesOrRights: RolesOrRights): AuthorizedHandler {\n return (claims) => hasRolesOrRights(claims?.rights ?? [], rolesOrRights);\n}\n","import { HttpClient, HttpContext } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { AuthPluginFactory, injectAuthConfig, requireAuthentication } from '@odx/auth';\nimport { defer, map } from 'rxjs';\nimport { ServiceConnectEnvironment } from '../service-connect.config';\nimport { buildServiceConnectUrl } from './build-service-connect-url';\n\nexport interface ServiceConnectPluginOptions {\n environment?: ServiceConnectEnvironment;\n}\n\nexport interface ServiceConnectPluginFactoryOptions<Dto> {\n endpoint: string[];\n parseResponse: (res: Dto | null) => Partial<OdxAuth.AuthPluginResult>;\n defaultValue?: Partial<OdxAuth.AuthPluginResult>;\n setup?: (pluginOptions?: ServiceConnectPluginOptions) => void;\n}\n\nexport type ServiceConnectPluginFactory = (pluginOptions?: ServiceConnectPluginOptions) => AuthPluginFactory;\n\n/**\n * Creates a plugin factory for fetching and parsing service connect data.\n *\n * @param {ServiceConnectPluginFactoryOptions<Dto>} options - The options for the service connect plugin factory.\n * @returns {ServiceConnectPluginFactory} - A function that creates an auth plugin factory for fetching and parsing service connect data.\n */\nexport function serviceConnectPluginFactory<Dto = unknown>(options: ServiceConnectPluginFactoryOptions<Dto>): ServiceConnectPluginFactory {\n return (pluginOptions) => () => {\n options.setup?.(pluginOptions);\n const { environment } = injectAuthConfig();\n const httpClient = inject(HttpClient);\n const url = buildServiceConnectUrl(pluginOptions?.environment ?? environment, ...options.endpoint);\n const parseResponse = (dto: Dto | null) => options.parseResponse(dto) ?? options.defaultValue ?? {};\n\n return () =>\n defer(() =>\n httpClient.get<Dto>(url, {\n context: new HttpContext().set(requireAuthentication, true),\n }),\n ).pipe(map((dto) => parseResponse(dto)));\n };\n}\n","import { Directive, inject, Input } from '@angular/core';\nimport { AuthDirective } from '@odx/auth';\nimport { hasRolesOrRightsHandler, RolesOrRights } from './helpers';\n\n/**\n * A directive that extends the functionality of the `AuthDirective` to handle\n * roles or rights for service connection authorization.\n *\n * @see AuthDirective\n *\n * This directive should be used on an `ng-template` element with the selector\n * `odxAuthServiceConnectRights`.\n */\n@Directive({\n standalone: true,\n selector: 'ng-template[odxAuthServiceConnectRights]',\n hostDirectives: [\n {\n directive: AuthDirective,\n inputs: ['odxAuthElse:odxAuthServiceConnectRightsElse'],\n },\n ],\n})\nexport class ServiceConnectRightsDirective {\n private readonly authDirective = inject(AuthDirective, { host: true });\n\n /**\n * Sets the roles or rights that the user must have to display the content.\n */\n @Input('odxAuthServiceConnectRights')\n public set rolesOrRights(value: RolesOrRights | null | undefined) {\n this.authDirective.authorizationHandler = hasRolesOrRightsHandler(value ?? []);\n }\n}\n","import { CanActivateFn } from '@angular/router';\nimport { authGuard } from '@odx/auth';\nimport { hasRolesOrRightsHandler, RolesOrRights } from './helpers';\n\n/**\n * A guard function to check if the user has the required roles or rights to access a route.\n *\n * @param {RolesOrRights} rolesOrRights - The roles or rights required to access the route.\n * @param {string | any[]} redirectTo - (Optional) The route to redirect to if the user does not have the required roles or rights.\n * @param {boolean} isExternal - (Optional) A flag indicating if the redirection is to an external URL. Defaults to `false`.\n * @returns {CanActivateFn} - A function that checks the user's roles or rights and handles redirection if necessary.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function serviceConnectRightsGuard(rolesOrRights: RolesOrRights, redirectTo?: string | any[], isExternal = false): CanActivateFn {\n return authGuard(hasRolesOrRightsHandler(rolesOrRights), redirectTo, isExternal);\n}\n","import { GetServiceConnectRightsResponseDto } from './dtos';\nimport { Right, serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace OdxAuth {\n interface AuthPluginResult {\n rights: Right[];\n }\n }\n}\n\n/**\n * A plugin for fetching and parsing service connect rights.\n *\n * This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches user rights\n * from the specified endpoint and parses the response to extract the rights.\n *\n * @see {serviceConnectPluginFactory}\n */\nexport const serviceConnectRightsPlugin = serviceConnectPluginFactory<GetServiceConnectRightsResponseDto>({\n endpoint: [ServiceConnectEndpoints.userRights],\n parseResponse: (res) => ({ rights: res?.rights ?? [] }),\n defaultValue: { rights: [] },\n});\n","import { getLanguageCode } from '@odx/angular/utils';\nimport { GetServiceConnectUserResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\n/**\n * Gets the language code from a service connect user response.\n *\n * @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.\n * @returns {string | undefined} - The language code or undefined.\n */\nexport function getServiceConnectUserLanguage(res?: GetServiceConnectUserResponseDto | null): string | undefined {\n return (res?.preferred_language ?? res?.language_code) ? getLanguageCode(res.preferred_language ?? res.language_code) : undefined;\n}\n\n/**\n * A plugin for fetching and parsing the user's preferred language from service connect.\n *\n * This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches the user's preferred language\n * from the user endpoint and parses the response to extract the preferred language.\n *\n * @see {serviceConnectPluginFactory}\n */\nexport const serviceConnectUserLanguagePlugin = serviceConnectPluginFactory<GetServiceConnectUserResponseDto>({\n endpoint: [ServiceConnectEndpoints.user],\n parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res) }),\n});\n","import { GetServiceConnectUserResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { getServiceConnectUserLanguage } from './service-connect-user-language.plugin';\nimport { ServiceConnectEndpoints } from './service-connect.config';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace OdxAuth {\n interface AuthPluginResult {\n country?: string;\n institutionId?: number;\n institutionName?: string;\n institutionShortname?: string;\n }\n }\n}\n\n/**\n * A plugin for fetching and parsing the user's profile from service connect.\n *\n * This plugin uses the `serviceConnectPluginFactory` to create a plugin that fetches the user's profile\n * from the user endpoint and parses the response to extract the user's profile information.\n *\n * @see {serviceConnectPluginFactory}\n */\nexport const serviceConnectUserProfilePlugin = serviceConnectPluginFactory<GetServiceConnectUserResponseDto>({\n endpoint: [ServiceConnectEndpoints.user],\n parseResponse: (res) => {\n return {\n country: res?.country,\n institutionId: res?.institution_id,\n institutionName: res?.institution_name,\n institutionShortname: res?.institution_shortname,\n preferredLanguage: getServiceConnectUserLanguage(res),\n };\n },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAGa,MAAA,2BAA2B,GAAoC;AAC1E,IAAA,CAAC,eAAe,CAAC,GAAG,GAAG,sCAAsC;AAC7D,IAAA,CAAC,eAAe,CAAC,KAAK,GAAG,yCAAyC;AAClE,IAAA,CAAC,eAAe,CAAC,IAAI,GAAG,iCAAiC;;AAE9C,MAAA,oBAAo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