@odx/auth 16.2.0 → 17.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.
- package/CHANGELOG.md +8 -0
- package/esm2022/lib/auth.typings.mjs +1 -1
- package/esm2022/plugins/service-connect/lib/helpers/build-service-connect-url.mjs +3 -3
- package/esm2022/plugins/service-connect/lib/service-connect-user-language.plugin.mjs +13 -4
- package/esm2022/plugins/service-connect/lib/service-connect-user-profile.plugin.mjs +3 -2
- package/esm2022/plugins/service-connect/lib/service-connect.config.mjs +2 -2
- package/fesm2022/odx-auth-plugins-service-connect.mjs +16 -6
- package/fesm2022/odx-auth-plugins-service-connect.mjs.map +1 -1
- package/lib/auth.typings.d.ts +1 -0
- package/package.json +1 -1
- package/plugins/service-connect/lib/service-connect-user-language.plugin.d.ts +8 -1
- package/plugins/service-connect/lib/service-connect.config.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @odx/auth
|
|
2
2
|
|
|
3
|
+
## 17.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 3ce938e: Removed language code parser for `preferredLanguage` identity claim in serviceConnectUserProfulePlugin and serviceconnectUserLanguagePlugin.
|
|
8
|
+
The old behavior is know used for the added `languageCode` identity claim.
|
|
9
|
+
- f8c591d: Fix typo in ServiceConnectEnvironments enum name (was ServiceConnnectEnvironments)
|
|
10
|
+
|
|
3
11
|
## 16.2.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aC50eXBpbmdzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vbGlicy9hdXRoL3NyYy9saWIvYXV0aC50eXBpbmdzLnRzIl0sI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,5 @@
|
|
|
1
1
|
import { buildUrl, isString } from '@odx/angular/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { ServiceConnectEnvironments } from '../service-connect.config';
|
|
3
3
|
/**
|
|
4
4
|
* Builds a service connect URL based on the provided environment and endpoints.
|
|
5
5
|
*
|
|
@@ -9,8 +9,8 @@ import { ServiceConnnectEnvironments } from '../service-connect.config';
|
|
|
9
9
|
*/
|
|
10
10
|
export function buildServiceConnectUrl(environment, ...endpoints) {
|
|
11
11
|
if (isString(environment)) {
|
|
12
|
-
return buildUrl(
|
|
12
|
+
return buildUrl(ServiceConnectEnvironments[environment], ...endpoints);
|
|
13
13
|
}
|
|
14
14
|
return buildUrl(environment.custom, ...endpoints);
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQtc2VydmljZS1jb25uZWN0LXVybC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYXV0aC9wbHVnaW5zL3NlcnZpY2UtY29ubmVjdC9zcmMvbGliL2hlbHBlcnMvYnVpbGQtc2VydmljZS1jb25uZWN0LXVybC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLFFBQVEsRUFBRSxNQUFNLG9CQUFvQixDQUFDO0FBRXhELE9BQU8sRUFBNkIsMEJBQTBCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUVsRzs7Ozs7O0dBTUc7QUFDSCxNQUFNLFVBQVUsc0JBQXNCLENBQUMsV0FBd0QsRUFBRSxHQUFHLFNBQW1CO0lBQ3JILElBQUksUUFBUSxDQUFDLFdBQVcsQ0FBQyxFQUFFLENBQUM7UUFDMUIsT0FBTyxRQUFRLENBQUMsMEJBQTBCLENBQUMsV0FBVy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uZWN0VXJsKGVudmlyb25tZW50OiBTZXJ2aWNlQ29ubmVjdEVudmlyb25tZW50IHwgQXV0aEVudmlyb25tZW50LCAuLi5lbmRwb2ludHM6IHN0cmluZ1tdKTogc3RyaW5nIHtcbiAgaWYgKGlzU3RyaW5nKGVudmlyb25tZW50KSkge1xuICAgIHJldHVybiBidWlsZFVybChTZXJ2aWNlQ29ubmVjdEVudmlyb25tZW50c1tlbnZpcm9ubWVudF0sIC4uLmVuZHBvaW50cyk7XG4gIH1cbiAgcmV0dXJuIGJ1aWxkVXJsKGVudmlyb25tZW50LmN1c3RvbSwgLi4uZW5kcG9pbnRzKTtcbn1cbiJdfQ==
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { getLanguageCode } from '@odx/angular/utils';
|
|
2
2
|
import { serviceConnectPluginFactory } from './helpers';
|
|
3
3
|
import { ServiceConnectEndpoints } from './service-connect.config';
|
|
4
|
+
/**
|
|
5
|
+
* Gets the preferred language from a service connect user response.
|
|
6
|
+
*
|
|
7
|
+
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
8
|
+
* @returns {string | undefined} - The language or undefined.
|
|
9
|
+
*/
|
|
10
|
+
export function getServiceConnectUserLanguage(res) {
|
|
11
|
+
return res?.preferred_language || res?.language_code;
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* Gets the language code from a service connect user response.
|
|
6
15
|
*
|
|
7
16
|
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
8
17
|
* @returns {string | undefined} - The language code or undefined.
|
|
9
18
|
*/
|
|
10
|
-
export function
|
|
11
|
-
return
|
|
19
|
+
export function getServiceConnectUserLanguageCode(res) {
|
|
20
|
+
return res?.language_code ? getLanguageCode(res.language_code) : undefined;
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* A plugin for fetching and parsing the user's preferred language from service connect.
|
|
@@ -20,6 +29,6 @@ export function getServiceConnectUserLanguage(res) {
|
|
|
20
29
|
*/
|
|
21
30
|
export const serviceConnectUserLanguagePlugin = serviceConnectPluginFactory({
|
|
22
31
|
endpoint: [ServiceConnectEndpoints.user],
|
|
23
|
-
parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res) }),
|
|
32
|
+
parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res), languageCode: getServiceConnectUserLanguageCode(res) }),
|
|
24
33
|
});
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS1jb25uZWN0LXVzZXItbGFuZ3VhZ2UucGx1Z2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vbGlicy9hdXRoL3BsdWdpbnMvc2VydmljZS1jb25uZWN0L3NyYy9saWIvc2VydmljZS1jb25uZWN0LXVzZXItbGFuZ3VhZ2UucGx1Z2luLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxlQUFlLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVyRCxPQUFPLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFDeEQsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFbkU7Ozs7O0dBS0c7QUFDSCxNQUFNLFVBQVUsNkJBQTZCLENBQUMsR0FBNkM7SUFDekYsT0FBTyxHQUFHLEVBQUUsa0JBQWtCLElBQUksR0FBRyxFQUFFLGFBQWEsQ0FBQztBQUN2RCxDQUFDO0FBRUQ7Ozs7O0dBS0c7QUFDSCxNQUFNLFVBQVUsaUNBQWlDLENBQUMsR0FBNkM7SUFDN0YsT0FBTyxHQUFHLEVBQUUsYUFBYSxDQUFDLENBQUMsQ0FBQyxlQUFlLENBQUMsR0FBRyxDQUFDLGFBQWEsQ0FBQyxDQUF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zIHRoZSB1c2VyJ3MgcHJlZmVycmVkIGxhbmd1YWdlXG4gKiBmcm9tIHRoZSB1c2VyIGVuZHBvaW50IGFuZCBwYXJzZXMgdGhlIHJlc3BvbnNlIHRvIGV4dHJhY3QgdGhlIHByZWZlcnJlZCBsYW5ndWFnZS5cbiAqXG4gKiBAc2VlIHtzZXJ2aWNlQ29ubmVjdFBsdWdpbkZhY3Rvcnl9XG4gKi9cbmV4cG9ydCBjb25zdCBzZXJ2aWNlQ29ubmVjdFVzZXJMYW5ndWFnZVBsdWdpbiA9IHNlcnZpY2VDb25uZWN0UGx1Z2luRmFjdG9yeTxHZXRTZXJ2aWNlQ29ubmVjdFVzZXJSZXNwb25zZUR0bz4oe1xuICBlbmRwb2ludDogW1NlcnZpY2VDb25uZWN0RW5kcG9pbnRzLnVzZXJdLFxuICBwYXJzZVJlc3BvbnNlOiAocmVzKSA9PiAoeyBwcmVmZXJyZWRMYW5ndWFnZTogZ2V0U2VydmljZUNvbm5lY3RVc2VyTGFuZ3VhZ2UocmVzKSwgbGFuZ3VhZ2VDb2RlOiBnZXRTZXJ2aWNlQ29ubmVjdFVzZXJMYW5ndWFnZUNvZGUocmVzKSB9KSxcbn0pO1xuIl19
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { serviceConnectPluginFactory } from './helpers';
|
|
2
|
-
import { getServiceConnectUserLanguage } from './service-connect-user-language.plugin';
|
|
2
|
+
import { getServiceConnectUserLanguage, getServiceConnectUserLanguageCode } from './service-connect-user-language.plugin';
|
|
3
3
|
import { ServiceConnectEndpoints } from './service-connect.config';
|
|
4
4
|
/**
|
|
5
5
|
* A plugin for fetching and parsing the user's profile from service connect.
|
|
@@ -20,8 +20,9 @@ export const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
|
20
20
|
institutionName3: res?.institution_name_3 ?? undefined,
|
|
21
21
|
accountNumber: res?.account_number ?? undefined,
|
|
22
22
|
institutionShortname: res?.institution_shortname,
|
|
23
|
+
languageCode: getServiceConnectUserLanguageCode(res),
|
|
23
24
|
preferredLanguage: getServiceConnectUserLanguage(res),
|
|
24
25
|
};
|
|
25
26
|
},
|
|
26
27
|
});
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS1jb25uZWN0LXVzZXItcHJvZmlsZS5wbHVnaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9saWJzL2F1dGgvcGx1Z2lucy9zZXJ2aWNlLWNvbm5lY3Qvc3JjL2xpYi9zZXJ2aWNlLWNvbm5lY3QtdXNlci1wcm9maWxlLnBsdWdpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsMkJBQTJCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFDeEQsT0FBTyxFQUFFLDZCQUE2QixFQUFFLGlDQUFpQyxFQUFFLE1BQU0sd0NBQXdDLENBQUM7QUFDMUgsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFpQm5FOzs7Ozs7O0dBT0c7QUFDSCxNQUFNLENBQUMsTUFBTSwrQkFBK0IsR0FBRywyQkFBMkIsQ0FBbUM7SUFDM0csUUFBUSxFQUFFLENBQUMsdUJBQXVCLENBQUMsSUFBSSxDQUFDO0lBQ3hDLGFBQWEsRUFBRSxDQUFDLEdBQUcsRUFBRSxFQUFFO1FBQ3JCLE9BQU87WUFDTCxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU87WUFDckIsYUFBYSxFQUFFLEdBQUcsRUFBRSxjQUFjO1lBQ2xDLGVBQWUsRUFBRSxHQUFHLEVBQUUsZ0JBQWdCO1lBQ3RDLGdCQUFnQixFQUFFLEdBQUcsRUFBRSxrQkFBa0IsSUFBSSxTQUFTO1lBQ3RELGdCQUFnQixFQUFFL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FtZTI6IHJlcz8uaW5zdGl0dXRpb25fbmFtZV8yID8/IHVuZGVmaW5lZCxcbiAgICAgIGluc3RpdHV0aW9uTmFtZTM6IHJlcz8uaW5zdGl0dXRpb25fbmFtZV8zID8/IHVuZGVmaW5lZCxcbiAgICAgIGFjY291bnROdW1iZXI6IHJlcz8uYWNjb3VudF9udW1iZXIgPz8gdW5kZWZpbmVkLFxuICAgICAgaW5zdGl0dXRpb25TaG9ydG5hbWU6IHJlcz8uaW5zdGl0dXRpb25fc2hvcnRuYW1lLFxuICAgICAgbGFuZ3VhZ2VDb2RlOiBnZXRTZXJ2aWNlQ29ubmVjdFVzZXJMYW5ndWFnZUNvZGUocmVzKSxcbiAgICAgIHByZWZlcnJlZExhbmd1YWdlOiBnZXRTZXJ2aWNlQ29ubmVjdFVzZXJMYW5ndWFnZShyZXMpLFxuICAgIH07XG4gIH0sXG59KTtcbiJdfQ==
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthEnvironment } from '@odx/auth';
|
|
2
|
-
export const
|
|
2
|
+
export const ServiceConnectEnvironments = {
|
|
3
3
|
[AuthEnvironment.DEV]: 'https://api.test.connect.draeger.com',
|
|
4
4
|
[AuthEnvironment.STAGE]: 'https://api.staging.connect.draeger.com',
|
|
5
5
|
[AuthEnvironment.PROD]: 'https://api.connect.draeger.com',
|
|
@@ -14,4 +14,4 @@ export const ServiceConnectEndpoints = {
|
|
|
14
14
|
user: '/users/me',
|
|
15
15
|
userRights: '/users/me/rights',
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS1jb25uZWN0LmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvYXV0aC9wbHVnaW5zL3NlcnZpY2UtY29ubmVjdC9zcmMvbGli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naW5nLmNvbm5lY3QuZHJhZWdlci5jb20nLFxuICBbQXV0aEVudmlyb25tZW50LlBST0RdOiAnaHR0cHM6Ly9hcGkuY29ubmVjdC5kcmFlZ2VyLmNvbScsXG59O1xuZXhwb3J0IGNvbnN0IFNlcnZpY2VDb25uZWN0U2NvcGVzID0ge1xuICBCQVNFOiAnZGNpZCcsXG4gIFBST0ZJTEU6ICdkY2lkLnByb2ZpbGUnLFxuICBSSUdIVFM6ICdkY2lkLnJpZ2h0cycsXG4gIElOU1RJVFVUSU9OOiAnZGNpZC5pbnN0aXR1dGlvbicsXG59O1xuZXhwb3J0IGNvbnN0IFNlcnZpY2VDb25uZWN0RW5kcG9pbnRzID0ge1xuICB1c2VyOiAnL3VzZXJzL21lJyxcbiAgdXNlclJpZ2h0czogJy91c2Vycy9tZS9yaWdodHMnLFxufTtcbiJdfQ==
|
|
@@ -6,7 +6,7 @@ import * as i0 from '@angular/core';
|
|
|
6
6
|
import { inject, Directive, Input } from '@angular/core';
|
|
7
7
|
import { defer, map } from 'rxjs';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const ServiceConnectEnvironments = {
|
|
10
10
|
[AuthEnvironment.DEV]: 'https://api.test.connect.draeger.com',
|
|
11
11
|
[AuthEnvironment.STAGE]: 'https://api.staging.connect.draeger.com',
|
|
12
12
|
[AuthEnvironment.PROD]: 'https://api.connect.draeger.com',
|
|
@@ -31,7 +31,7 @@ const ServiceConnectEndpoints = {
|
|
|
31
31
|
*/
|
|
32
32
|
function buildServiceConnectUrl(environment, ...endpoints) {
|
|
33
33
|
if (isString(environment)) {
|
|
34
|
-
return buildUrl(
|
|
34
|
+
return buildUrl(ServiceConnectEnvironments[environment], ...endpoints);
|
|
35
35
|
}
|
|
36
36
|
return buildUrl(environment.custom, ...endpoints);
|
|
37
37
|
}
|
|
@@ -144,14 +144,23 @@ const serviceConnectRightsPlugin = serviceConnectPluginFactory({
|
|
|
144
144
|
defaultValue: { rights: [] },
|
|
145
145
|
});
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Gets the preferred language from a service connect user response.
|
|
149
|
+
*
|
|
150
|
+
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
151
|
+
* @returns {string | undefined} - The language or undefined.
|
|
152
|
+
*/
|
|
153
|
+
function getServiceConnectUserLanguage(res) {
|
|
154
|
+
return res?.preferred_language || res?.language_code;
|
|
155
|
+
}
|
|
147
156
|
/**
|
|
148
157
|
* Gets the language code from a service connect user response.
|
|
149
158
|
*
|
|
150
159
|
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
151
160
|
* @returns {string | undefined} - The language code or undefined.
|
|
152
161
|
*/
|
|
153
|
-
function
|
|
154
|
-
return
|
|
162
|
+
function getServiceConnectUserLanguageCode(res) {
|
|
163
|
+
return res?.language_code ? getLanguageCode(res.language_code) : undefined;
|
|
155
164
|
}
|
|
156
165
|
/**
|
|
157
166
|
* A plugin for fetching and parsing the user's preferred language from service connect.
|
|
@@ -163,7 +172,7 @@ function getServiceConnectUserLanguage(res) {
|
|
|
163
172
|
*/
|
|
164
173
|
const serviceConnectUserLanguagePlugin = serviceConnectPluginFactory({
|
|
165
174
|
endpoint: [ServiceConnectEndpoints.user],
|
|
166
|
-
parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res) }),
|
|
175
|
+
parseResponse: (res) => ({ preferredLanguage: getServiceConnectUserLanguage(res), languageCode: getServiceConnectUserLanguageCode(res) }),
|
|
167
176
|
});
|
|
168
177
|
|
|
169
178
|
/**
|
|
@@ -185,6 +194,7 @@ const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
|
185
194
|
institutionName3: res?.institution_name_3 ?? undefined,
|
|
186
195
|
accountNumber: res?.account_number ?? undefined,
|
|
187
196
|
institutionShortname: res?.institution_shortname,
|
|
197
|
+
languageCode: getServiceConnectUserLanguageCode(res),
|
|
188
198
|
preferredLanguage: getServiceConnectUserLanguage(res),
|
|
189
199
|
};
|
|
190
200
|
},
|
|
@@ -194,5 +204,5 @@ const serviceConnectUserProfilePlugin = serviceConnectPluginFactory({
|
|
|
194
204
|
* Generated bundle index. Do not edit.
|
|
195
205
|
*/
|
|
196
206
|
|
|
197
|
-
export { ServiceConnectEndpoints, ServiceConnectRightsDirective, ServiceConnectScopes,
|
|
207
|
+
export { ServiceConnectEndpoints, ServiceConnectEnvironments, ServiceConnectRightsDirective, ServiceConnectScopes, buildServiceConnectUrl, getServiceConnectUserLanguage, getServiceConnectUserLanguageCode, hasRolesOrRights, hasRolesOrRightsHandler, serviceConnectPluginFactory, serviceConnectRightsGuard, serviceConnectRightsPlugin, serviceConnectUserLanguagePlugin, serviceConnectUserProfilePlugin };
|
|
198
208
|
//# sourceMappingURL=odx-auth-plugins-service-connect.mjs.map
|
|
@@ -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\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<Dto = unknown> {\n environment?: ServiceConnectEnvironment;\n additionalClaims?: (dto: (Dto & Record<string, unknown>) | null) => Partial<OdxAuth.AuthPluginResult>;\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<Dto>) => void;\n}\n\nexport type ServiceConnectPluginFactory<Dto = unknown> = (pluginOptions?: ServiceConnectPluginOptions<Dto>) => 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<Dto> {\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 = (res: Dto | null) => ({\n ...(options.parseResponse(res) ?? options.defaultValue ?? {}),\n ...(pluginOptions?.additionalClaims?.(res as Dto & Record<string, unknown>) ?? {}),\n });\n\n return () => defer(() => httpClient.get<Dto>(url, { context: new HttpContext().set(requireAuthentication, true) })).pipe(map((res) => parseResponse(res)));\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 institutionName2?: string;\n institutionName3?: string;\n institutionShortname?: string;\n accountNumber?: 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 institutionName2: res?.institution_name_2 ?? undefined,\n institutionName3: res?.institution_name_3 ?? undefined,\n accountNumber: res?.account_number ?? undefined,\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;EACzD;AACW,MAAA,oBAAoB,GAAG;AAClC,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,MAAM,EAAE,aAAa;AACrB,IAAA,WAAW,EAAE,kBAAkB;EAC/B;AACW,MAAA,uBAAuB,GAAG;AACrC,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU,EAAE,kBAAkB;;;ACZhC;;;;;;AAMG;SACa,sBAAsB,CAAC,WAAwD,EAAE,GAAG,SAAmB,EAAA;AACrH,IAAA,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;QACzB,OAAO,QAAQ,CAAC,2BAA2B,CAAC,WAAW,C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Aa,EAAE,CAAC,GAAG,KAAI;QACrB,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,OAAO;YACrB,aAAa,EAAE,GAAG,EAAE,cAAc;YAClC,eAAe,EAAE,GAAG,EAAE,gBAAgB;AACtC,YAAA,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,IAAI,SAAS;AACtD,YAAA,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,IAAI,SAAS;AACtD,YAAA,aAAa,EAAE,GAAG,EAAE,cAAc,IAAI,SAAS;YAC/C,oBAAoB,EAAE,GAAG,EAAE,qBAAqB;AAChD,YAAA,iBAAiB,EAAE,6BAA6B,CAAC,GAAG,CAAC;SACtD,CAAC;KACH;AACF,CAAA;;AC1CD;;AAEG;;;;"}
|
|
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 ServiceConnectEnvironments: 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, ServiceConnectEnvironments } 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(ServiceConnectEnvironments[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<Dto = unknown> {\n environment?: ServiceConnectEnvironment;\n additionalClaims?: (dto: (Dto & Record<string, unknown>) | null) => Partial<OdxAuth.AuthPluginResult>;\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<Dto>) => void;\n}\n\nexport type ServiceConnectPluginFactory<Dto = unknown> = (pluginOptions?: ServiceConnectPluginOptions<Dto>) => 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<Dto> {\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 = (res: Dto | null) => ({\n ...(options.parseResponse(res) ?? options.defaultValue ?? {}),\n ...(pluginOptions?.additionalClaims?.(res as Dto & Record<string, unknown>) ?? {}),\n });\n\n return () => defer(() => httpClient.get<Dto>(url, { context: new HttpContext().set(requireAuthentication, true) })).pipe(map((res) => parseResponse(res)));\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 preferred language from a service connect user response.\n *\n * @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.\n * @returns {string | undefined} - The language or undefined.\n */\nexport function getServiceConnectUserLanguage(res?: GetServiceConnectUserResponseDto | null): string | undefined {\n return res?.preferred_language || res?.language_code;\n}\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 getServiceConnectUserLanguageCode(res?: GetServiceConnectUserResponseDto | null): string | undefined {\n return res?.language_code ? getLanguageCode(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), languageCode: getServiceConnectUserLanguageCode(res) }),\n});\n","import { GetServiceConnectUserResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { getServiceConnectUserLanguage, getServiceConnectUserLanguageCode } 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 institutionName2?: string;\n institutionName3?: string;\n institutionShortname?: string;\n accountNumber?: 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 institutionName2: res?.institution_name_2 ?? undefined,\n institutionName3: res?.institution_name_3 ?? undefined,\n accountNumber: res?.account_number ?? undefined,\n institutionShortname: res?.institution_shortname,\n languageCode: getServiceConnectUserLanguageCode(res),\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,0BAA0B,GAAoC;AACzE,IAAA,CAAC,eAAe,CAAC,GAAG,GAAG,sCAAsC;AAC7D,IAAA,CAAC,eAAe,CAAC,KAAK,GAAG,yCAAyC;AAClE,IAAA,CAAC,eAAe,CAAC,IAAI,GAAG,iCAAiC;EACzD;AACW,MAAA,oBAAoB,GAAG;AAClC,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,OAAO,EAAE,cAAc;AACvB,IAAA,MAAM,EAAE,aAAa;AACrB,IAAA,WAAW,EAAE,kBAAkB;EAC/B;AACW,MAAA,uBAAuB,GAAG;AACrC,IAAA,IAAI,EAAE,WAAW;AACjB,IAAA,UAAU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AuB,CAAC,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,GAAG,MAAM,EAAE,iBAAiB,EAAE,6BAA6B,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,iCAAiC,CAAC,GAAG,CAAC,EAAE,CAAC;AAC1I,CAAA;;AChBD;;;;;;;AAOG;AACI,MAAM,+BAA+B,GAAG,2BAA2B,CAAmC;AAC3G,IAAA,QAAQ,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC;AACxC,IAAA,aAAa,EAAE,CAAC,GAAG,KAAI;QACrB,OAAO;YACL,OAAO,EAAE,GAAG,EAAE,OAAO;YACrB,aAAa,EAAE,GAAG,EAAE,cAAc;YAClC,eAAe,EAAE,GAAG,EAAE,gBAAgB;AACtC,YAAA,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,IAAI,SAAS;AACtD,YAAA,gBAAgB,EAAE,GAAG,EAAE,kBAAkB,IAAI,SAAS;AACtD,YAAA,aAAa,EAAE,GAAG,EAAE,cAAc,IAAI,SAAS;YAC/C,oBAAoB,EAAE,GAAG,EAAE,qBAAqB;AAChD,YAAA,YAAY,EAAE,iCAAiC,CAAC,GAAG,CAAC;AACpD,YAAA,iBAAiB,EAAE,6BAA6B,CAAC,GAAG,CAAC;SACtD,CAAC;KACH;AACF,CAAA;;AC3CD;;AAEG;;;;"}
|
package/lib/auth.typings.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { GetServiceConnectUserResponseDto } from './dtos';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the preferred language from a service connect user response.
|
|
4
|
+
*
|
|
5
|
+
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
6
|
+
* @returns {string | undefined} - The language or undefined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getServiceConnectUserLanguage(res?: GetServiceConnectUserResponseDto | null): string | undefined;
|
|
2
9
|
/**
|
|
3
10
|
* Gets the language code from a service connect user response.
|
|
4
11
|
*
|
|
5
12
|
* @param {GetServiceConnectUserResponseDto | null} res - The service connect user response.
|
|
6
13
|
* @returns {string | undefined} - The language code or undefined.
|
|
7
14
|
*/
|
|
8
|
-
export declare function
|
|
15
|
+
export declare function getServiceConnectUserLanguageCode(res?: GetServiceConnectUserResponseDto | null): string | undefined;
|
|
9
16
|
/**
|
|
10
17
|
* A plugin for fetching and parsing the user's preferred language from service connect.
|
|
11
18
|
*
|
|
@@ -2,7 +2,7 @@ import { AuthEnvironment } from '@odx/auth';
|
|
|
2
2
|
export type ServiceConnectEnvironment = {
|
|
3
3
|
custom: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const ServiceConnectEnvironments: Record<AuthEnvironment, string>;
|
|
6
6
|
export declare const ServiceConnectScopes: {
|
|
7
7
|
BASE: string;
|
|
8
8
|
PROFILE: string;
|