@odx/auth 3.4.0 → 4.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/README.md +16 -2
- package/esm2020/lib/auth.component.mjs +19 -11
- package/esm2020/lib/auth.config.mjs +10 -1
- package/esm2020/lib/auth.i18n.mjs +13 -0
- package/esm2020/lib/auth.providers.mjs +16 -11
- package/esm2020/lib/components/auth-actions/auth-actions.component.mjs +30 -0
- package/esm2020/lib/components/index.mjs +2 -1
- package/esm2020/lib/helpers/handle-auth-error.mjs +21 -0
- package/esm2020/lib/helpers/index.mjs +2 -1
- package/esm2020/lib/models/auth-http-cache.mjs +15 -6
- package/esm2020/lib/models/index.mjs +2 -1
- package/esm2020/lib/models/offline-auth-error-handler.mjs +7 -0
- package/esm2020/lib/plugins/index.mjs +2 -1
- package/esm2020/lib/plugins/user-profile-link.plugin.mjs +9 -0
- package/esm2020/plugins/service-connect/lib/helpers/service-connect-plugin-factory.mjs +5 -17
- package/esm2020/plugins/service-connect/lib/service-connect-rights.plugin.mjs +1 -2
- package/esm2020/plugins/service-connect/lib/service-connect.config.mjs +4 -3
- package/fesm2015/odx-auth-plugins-service-connect.mjs +7 -21
- package/fesm2015/odx-auth-plugins-service-connect.mjs.map +1 -1
- package/fesm2015/odx-auth.mjs +162 -68
- package/fesm2015/odx-auth.mjs.map +1 -1
- package/fesm2020/odx-auth-plugins-service-connect.mjs +7 -19
- package/fesm2020/odx-auth-plugins-service-connect.mjs.map +1 -1
- package/fesm2020/odx-auth.mjs +160 -66
- package/fesm2020/odx-auth.mjs.map +1 -1
- package/lib/auth.component.d.ts +1 -3
- package/lib/auth.config.d.ts +3 -0
- package/lib/auth.i18n.d.ts +3 -0
- package/lib/auth.providers.d.ts +1 -1
- package/lib/components/auth-actions/auth-actions.component.d.ts +7 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/helpers/handle-auth-error.d.ts +3 -0
- package/lib/helpers/index.d.ts +1 -0
- package/lib/models/auth-http-cache.d.ts +2 -1
- package/lib/models/index.d.ts +1 -0
- package/lib/models/offline-auth-error-handler.d.ts +2 -0
- package/lib/plugins/index.d.ts +1 -0
- package/lib/plugins/user-profile-link.plugin.d.ts +9 -0
- package/package.json +2 -2
- package/plugins/service-connect/lib/helpers/service-connect-plugin-factory.d.ts +3 -2
- package/plugins/service-connect/lib/service-connect-rights.plugin.d.ts +1 -1
- package/plugins/service-connect/lib/service-connect.config.d.ts +3 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { isString, buildUrl } from '@odx/angular/utils';
|
|
2
|
-
import { __awaiter } from 'tslib';
|
|
3
2
|
import * as i0 from '@angular/core';
|
|
4
3
|
import { inject, Directive, Input } from '@angular/core';
|
|
5
4
|
import * as i1 from '@odx/auth';
|
|
6
5
|
import { injectAuthConfig, AuthHttpCache, AuthDirective, authGuard } from '@odx/auth';
|
|
7
|
-
import { defer } from 'rxjs';
|
|
6
|
+
import { defer, map } from 'rxjs';
|
|
8
7
|
|
|
9
8
|
const ServiceConnnectEnvironments = {
|
|
10
9
|
dev: 'https://api.test.connect.draeger.com',
|
|
@@ -13,8 +12,9 @@ const ServiceConnnectEnvironments = {
|
|
|
13
12
|
};
|
|
14
13
|
const ServiceConnectScopes = {
|
|
15
14
|
BASE: 'dcid',
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
PROFILE: 'dcid.profile',
|
|
16
|
+
RIGHTS: 'dcid.rights',
|
|
17
|
+
INSTITUTION: 'dcid.instiution',
|
|
18
18
|
};
|
|
19
19
|
const ServiceConnectEndpoints = {
|
|
20
20
|
userRights: '/users/me/rights',
|
|
@@ -38,25 +38,12 @@ function hasRolesOrRightsHandler(rolesOrRights) {
|
|
|
38
38
|
function serviceConnectPluginFactory(options) {
|
|
39
39
|
return (pluginOptions) => () => {
|
|
40
40
|
var _a, _b;
|
|
41
|
+
(_a = options.setup) === null || _a === void 0 ? void 0 : _a.call(options, pluginOptions);
|
|
41
42
|
const { environment } = injectAuthConfig();
|
|
42
43
|
const httpCache = inject(AuthHttpCache);
|
|
43
|
-
(_a = options.setup) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
44
44
|
const url = buildServiceConnectUrl((_b = pluginOptions === null || pluginOptions === void 0 ? void 0 : pluginOptions.environment) !== null && _b !== void 0 ? _b : environment, ...options.endpoint);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const request = new Request(url);
|
|
48
|
-
const token = authService.getAccessToken();
|
|
49
|
-
let result = null;
|
|
50
|
-
if (token) {
|
|
51
|
-
request.headers.set('Authorization', `Bearer ${token}`);
|
|
52
|
-
result = yield httpCache.request(request).then((res) => options.parseResponse(res));
|
|
53
|
-
}
|
|
54
|
-
else if (!authService.isAuthenticated()) {
|
|
55
|
-
yield httpCache.delete(request);
|
|
56
|
-
}
|
|
57
|
-
return (_c = result !== null && result !== void 0 ? result : options.defaultValue) !== null && _c !== void 0 ? _c : {};
|
|
58
|
-
}));
|
|
59
|
-
return plugin;
|
|
45
|
+
const parseResponse = (dto) => { var _a, _b; return (_b = (_a = options.parseResponse(dto)) !== null && _a !== void 0 ? _a : options.defaultValue) !== null && _b !== void 0 ? _b : {}; };
|
|
46
|
+
return () => defer(() => httpCache.request(url, true)).pipe(map((dto) => parseResponse(dto)));
|
|
60
47
|
};
|
|
61
48
|
}
|
|
62
49
|
|
|
@@ -96,7 +83,6 @@ const serviceConnectRightsPlugin = serviceConnectPluginFactory({
|
|
|
96
83
|
endpoint: [ServiceConnectEndpoints.userRights],
|
|
97
84
|
parseResponse: (res) => { var _a; return ({ rights: (_a = res === null || res === void 0 ? void 0 : res.rights) !== null && _a !== void 0 ? _a : [] }); },
|
|
98
85
|
defaultValue: { rights: [] },
|
|
99
|
-
// setup: () => inject(AuthConfig).scopes?.push(ServiceConnectScopes.RIGHTS); // TODO: enable scope when supported by the CSI team
|
|
100
86
|
});
|
|
101
87
|
|
|
102
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odx-auth-plugins-service-connect.mjs","sources":["../../../../packages/auth/plugins/service-connect/src/lib/service-connect.config.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/build-service-connect-url.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights-handler.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/service-connect-plugin-factory.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.directive.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.guard.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.plugin.ts","../../../../packages/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 dev: 'https://api.test.connect.draeger.com',\n stage: 'https://api.staging.connect.draeger.com',\n prod: 'https://api.connect.draeger.com',\n};\nexport const ServiceConnectScopes = {\n BASE: 'dcid',\n // RIGHTS: 'dcid-rights', // TODO: enable scope when supported by the CSI team\n // INSTITUTION: 'dcid-instiution', // TODO: enable scope when supported by the CSI team\n};\nexport const ServiceConnectEndpoints = {\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 { inject } from '@angular/core';\nimport { AuthHttpCache, AuthPlugin, AuthPluginFactory, injectAuthConfig } from '@odx/auth';\nimport { defer } 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?: () => void;\n}\n\nexport function serviceConnectPluginFactory<Dto = unknown>(\n options: ServiceConnectPluginFactoryOptions<Dto>,\n): (pluginOptions?: ServiceConnectPluginOptions) => AuthPluginFactory {\n return (pluginOptions) => () => {\n const { environment } = injectAuthConfig();\n const httpCache = inject(AuthHttpCache);\n options.setup?.();\n const url = buildServiceConnectUrl(pluginOptions?.environment ?? environment, ...options.endpoint);\n\n const plugin: AuthPlugin = (authService) =>\n defer(async () => {\n const request = new Request(url);\n const token = authService.getAccessToken();\n let result = null;\n if (token) {\n request.headers.set('Authorization', `Bearer ${token}`);\n\n result = await httpCache.request<Dto>(request).then((res) => options.parseResponse(res));\n } else if (!authService.isAuthenticated()) {\n await httpCache.delete(request);\n }\n\n return result ?? options.defaultValue ?? {};\n });\n\n return plugin;\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[]): CanActivateFn {\n return authGuard(hasRolesOrRightsHandler(rolesOrRights), redirectTo);\n}\n","import { GetServiceConnectRightsResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\nimport './service-connect.typings';\n\nexport const serviceConnectRightsPlugin = serviceConnectPluginFactory<GetServiceConnectRightsResponseDto>({\n endpoint: [ServiceConnectEndpoints.userRights],\n parseResponse: (res) => ({ rights: res?.rights ?? [] }),\n defaultValue: { rights: [] },\n // setup: () => inject(AuthConfig).scopes?.push(ServiceConnectScopes.RIGHTS); // TODO: enable scope when supported by the CSI team\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAGa,MAAA,2BAA2B,GAAoC;AAC1E,IAAA,GAAG,EAAE,sCAAsC;AAC3C,IAAA,KAAK,EAAE,yCAAyC;AAChD,IAAA,IAAI,EAAE,iCAAiC;EACvC;AACW,MAAA,oBAAoB,GAAG;AAClC,IAAA,IAAI,EAAE,MAAM;;;EAGZ;AACW,MAAA,uBAAuB,GAAG;AACrC,IAAA,UAAU,EAAE,kBAAkB;;;SCVhB,sBAAsB,CAAC,WAAwD,EAAE,GAAG,SAAmB,EAAA;AACrH,IAAA,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;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GAAG,2BAA2B,CAAqC;AACxG,IAAA,QAAQ,EAAE,CAAC,uBAAuB,CAAC,UAAU,CAAC;IAC9C,aAAa,EAAE,CAAC,GAAG,eAAK,QAAC,EAAE,MAAM,EAAE,CAAA,EAAA,GAAA,GAAG,KAAH,IAAA,IAAA,GAAG,KAAH,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,GAAG,CAAE,MAAM,mCAAI,EAAE,EAAE,EAAC,EAAA;AACvD,IAAA,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;;AAE7B,CAAA;;ACVD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"odx-auth-plugins-service-connect.mjs","sources":["../../../../packages/auth/plugins/service-connect/src/lib/service-connect.config.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/build-service-connect-url.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/has-roles-or-rights-handler.ts","../../../../packages/auth/plugins/service-connect/src/lib/helpers/service-connect-plugin-factory.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.directive.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.guard.ts","../../../../packages/auth/plugins/service-connect/src/lib/service-connect-rights.plugin.ts","../../../../packages/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 dev: 'https://api.test.connect.draeger.com',\n stage: 'https://api.staging.connect.draeger.com',\n prod: 'https://api.connect.draeger.com',\n};\nexport const ServiceConnectScopes = {\n BASE: 'dcid',\n PROFILE: 'dcid.profile',\n RIGHTS: 'dcid.rights',\n INSTITUTION: 'dcid.instiution',\n};\nexport const ServiceConnectEndpoints = {\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 { inject } from '@angular/core';\nimport { AuthHttpCache, AuthPluginFactory, injectAuthConfig } 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 httpCache = inject(AuthHttpCache);\n const url = buildServiceConnectUrl(pluginOptions?.environment ?? environment, ...options.endpoint);\n const parseResponse = (dto: Dto | null) => options.parseResponse(dto) ?? options.defaultValue ?? {};\n\n return () => defer(() => httpCache.request<Dto>(url, true)).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[]): CanActivateFn {\n return authGuard(hasRolesOrRightsHandler(rolesOrRights), redirectTo);\n}\n","import { GetServiceConnectRightsResponseDto } from './dtos';\nimport { serviceConnectPluginFactory } from './helpers';\nimport { ServiceConnectEndpoints } from './service-connect.config';\nimport './service-connect.typings';\n\nexport const serviceConnectRightsPlugin = serviceConnectPluginFactory<GetServiceConnectRightsResponseDto>({\n endpoint: [ServiceConnectEndpoints.userRights],\n parseResponse: (res) => ({ rights: res?.rights ?? [] }),\n defaultValue: { rights: [] },\n});\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAGa,MAAA,2BAA2B,GAAoC;AAC1E,IAAA,GAAG,EAAE,sCAAsC;AAC3C,IAAA,KAAK,EAAE,yCAAyC;AAChD,IAAA,IAAI,EAAE,iCAAiC;EACvC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K,QAAC,EAAE,MAAM,EAAE,CAAA,EAAA,GAAA,GAAG,KAAH,IAAA,IAAA,GAAG,KAAH,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,GAAG,CAAE,MAAM,mCAAI,EAAE,EAAE,EAAC,EAAA;AACvD,IAAA,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;AAC7B,CAAA;;ACTD;;AAEG;;;;"}
|
package/fesm2015/odx-auth.mjs
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { inject, EnvironmentInjector, InjectionToken, Injectable, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Directive, EventEmitter, Output, HostListener, NgModule, makeEnvironmentProviders, ENVIRONMENT_INITIALIZER, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import { WindowRef, CoreModule } from '@odx/angular';
|
|
4
|
-
import * as i3 from '@odx/angular/components/area-header';
|
|
4
|
+
import * as i3$1 from '@odx/angular/components/area-header';
|
|
5
5
|
import { AreaHeaderModule } from '@odx/angular/components/area-header';
|
|
6
6
|
import * as i8 from '@odx/angular/components/dropdown';
|
|
7
7
|
import { DropdownModule } from '@odx/angular/components/dropdown';
|
|
8
8
|
import { HeaderModule } from '@odx/angular/components/header';
|
|
9
|
-
import * as i1 from '@odx/angular/components/loading-spinner';
|
|
9
|
+
import * as i1$1 from '@odx/angular/components/loading-spinner';
|
|
10
10
|
import { LoadingSpinnerDirective, LoadingSpinnerModule } from '@odx/angular/components/loading-spinner';
|
|
11
11
|
import { LogoDirective } from '@odx/angular/components/logo';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { TranslatePipe, provideTranslations } from '@odx/angular/internal/translate';
|
|
13
|
+
import { isString, createConfigTokens, injectElement, untilDestroyed, Position, buildUrl } from '@odx/angular/utils';
|
|
14
|
+
import { OAuthErrorEvent, OAuthService, provideOAuthClient, OAuthModuleConfig, OAuthStorage } from 'angular-oauth2-oidc';
|
|
15
|
+
import { __awaiter, __decorate } from 'tslib';
|
|
14
16
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
15
17
|
import { Router } from '@angular/router';
|
|
16
|
-
import { OAuthService, OAuthErrorEvent, provideOAuthClient, OAuthModuleConfig, OAuthStorage } from 'angular-oauth2-oidc';
|
|
17
18
|
import { deepmerge } from 'deepmerge-ts';
|
|
18
19
|
import jwtDecode from 'jwt-decode';
|
|
19
20
|
import { BehaviorSubject, filter, map, distinctUntilChanged, share, of, switchMap, combineLatest, tap, take, fromEvent, startWith, merge, shareReplay, EMPTY } from 'rxjs';
|
|
20
|
-
import * as
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import * as
|
|
24
|
-
import
|
|
25
|
-
import * as
|
|
26
|
-
import { ButtonComponent } from '@odx/angular/components/button';
|
|
27
|
-
import * as i7 from '@odx/angular/components/icon';
|
|
21
|
+
import * as i2 from '@odx/angular/components/list';
|
|
22
|
+
import { ListModule } from '@odx/angular/components/list';
|
|
23
|
+
import { CSSComponent } from '@odx/angular/internal';
|
|
24
|
+
import * as i1 from '@angular/common';
|
|
25
|
+
import { CommonModule, NgIf } from '@angular/common';
|
|
26
|
+
import * as i3 from '@odx/angular/components/icon';
|
|
28
27
|
import { IconComponent } from '@odx/angular/components/icon';
|
|
29
|
-
import { DynamicViewDirective, DynamicViewService } from '@odx/angular/cdk/dynamic-view';
|
|
30
28
|
import { trigger, transition, useAnimation } from '@angular/animations';
|
|
31
29
|
import { fadeOut } from '@odx/angular/animations';
|
|
30
|
+
import { DynamicViewDirective, DynamicViewService } from '@odx/angular/cdk/dynamic-view';
|
|
31
|
+
import * as i6 from '@odx/angular/components/button';
|
|
32
|
+
import { ButtonComponent } from '@odx/angular/components/button';
|
|
32
33
|
import { CircularProgressComponent } from '@odx/angular/components/circular-progress';
|
|
34
|
+
import * as i2$1 from '@ngrx/component';
|
|
35
|
+
import * as i4 from '@odx/angular/components/avatar';
|
|
36
|
+
import * as i5 from '@odx/angular/components/action-group';
|
|
33
37
|
|
|
34
38
|
function createInitials(value) {
|
|
35
39
|
if (!value)
|
|
@@ -46,6 +50,25 @@ function createInitials(value) {
|
|
|
46
50
|
}, '');
|
|
47
51
|
}
|
|
48
52
|
|
|
53
|
+
function handleAuthError(handlers) {
|
|
54
|
+
const injector = inject(EnvironmentInjector);
|
|
55
|
+
return (error) => {
|
|
56
|
+
injector.runInContext(() => {
|
|
57
|
+
for (const handler of handlers) {
|
|
58
|
+
try {
|
|
59
|
+
handler(error);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
catch (unhandledError) {
|
|
63
|
+
if (!(unhandledError instanceof OAuthErrorEvent))
|
|
64
|
+
throw error;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
49
72
|
function resolveEmail(claims) {
|
|
50
73
|
if (isString(claims['email'])) {
|
|
51
74
|
return claims['email'];
|
|
@@ -81,10 +104,19 @@ const DEFAULT_ISSUERS = {
|
|
|
81
104
|
stage: 'https://test.login.draeger.com/oauth2/default',
|
|
82
105
|
prod: 'https://login.draeger.com/oauth2/default',
|
|
83
106
|
};
|
|
107
|
+
const DEFAULT_USER_PROFILE_URLS = {
|
|
108
|
+
dev: 'https://lemon-ocean-04a922703.3.azurestaticapps.net',
|
|
109
|
+
stage: 'https://purple-cliff-0e61c5703.3.azurestaticapps.net',
|
|
110
|
+
prod: 'https://id.draeger.com',
|
|
111
|
+
};
|
|
84
112
|
const ODX_AUTH_CORE_PLUGINS = new InjectionToken('@odx/auth::CorePlugins', {
|
|
85
113
|
providedIn: 'root',
|
|
86
114
|
factory: () => [],
|
|
87
115
|
});
|
|
116
|
+
const ODX_AUTH_ERROR_HANDLERS = new InjectionToken('@odx/auth::ErrorHandlers', {
|
|
117
|
+
providedIn: 'root',
|
|
118
|
+
factory: () => [],
|
|
119
|
+
});
|
|
88
120
|
const ODX_AUTH_PLUGINS = new InjectionToken('@odx/auth::Plugins', {
|
|
89
121
|
providedIn: 'root',
|
|
90
122
|
factory: () => {
|
|
@@ -113,6 +145,19 @@ const { AuthDefaultConfig, AuthConfig, injectAuthConfig, provideAuthConfig } = c
|
|
|
113
145
|
loadingScreenMessage: null,
|
|
114
146
|
});
|
|
115
147
|
|
|
148
|
+
var translations = {
|
|
149
|
+
en: {
|
|
150
|
+
userProfileLink: 'My profile',
|
|
151
|
+
signInButtonText: 'Sign in',
|
|
152
|
+
signOutButtonText: 'Sign out',
|
|
153
|
+
},
|
|
154
|
+
de: {
|
|
155
|
+
userProfileLink: 'Mein Profil',
|
|
156
|
+
signInButtonText: 'Einloggen',
|
|
157
|
+
signOutButtonText: 'Ausloggen',
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
|
|
116
161
|
const ODX_AUTH_HTTP_CACHE_STORAGE = new InjectionToken('@odx/auth::AuthHttpCacheStorage', {
|
|
117
162
|
providedIn: 'root',
|
|
118
163
|
factory: () => inject(WindowRef).nativeWindow.caches,
|
|
@@ -120,6 +165,7 @@ const ODX_AUTH_HTTP_CACHE_STORAGE = new InjectionToken('@odx/auth::AuthHttpCache
|
|
|
120
165
|
class AuthHttpCache {
|
|
121
166
|
constructor() {
|
|
122
167
|
this.cacheStorage = inject(ODX_AUTH_HTTP_CACHE_STORAGE);
|
|
168
|
+
this.oauthService = inject(OAuthService);
|
|
123
169
|
}
|
|
124
170
|
delete(request) {
|
|
125
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -127,14 +173,21 @@ class AuthHttpCache {
|
|
|
127
173
|
return cache.delete(request);
|
|
128
174
|
});
|
|
129
175
|
}
|
|
130
|
-
request(
|
|
176
|
+
request(requestInfo, authentication = false) {
|
|
131
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
const request = new Request(requestInfo);
|
|
179
|
+
const authorizationHeader = authentication ? this.oauthService.authorizationHeader() : null;
|
|
180
|
+
if (authorizationHeader) {
|
|
181
|
+
request.headers.set('Authorization', authorizationHeader);
|
|
182
|
+
}
|
|
132
183
|
const cache = yield this.cacheStorage.open(AuthHttpCache.CACHE_KEY);
|
|
133
|
-
|
|
134
|
-
|
|
184
|
+
const response = yield fetch(request).catch(() => null);
|
|
185
|
+
if (response === null || response === void 0 ? void 0 : response.ok) {
|
|
186
|
+
yield cache.put(request, response);
|
|
135
187
|
}
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
if (authorizationHeader && (response === null || response === void 0 ? void 0 : response.status) === 401) {
|
|
189
|
+
yield cache.delete(request);
|
|
190
|
+
yield this.oauthService.refreshToken().catch(() => null);
|
|
138
191
|
}
|
|
139
192
|
return cache.match(request).then((res) => { var _a; return (_a = res === null || res === void 0 ? void 0 : res.json()) !== null && _a !== void 0 ? _a : null; });
|
|
140
193
|
});
|
|
@@ -173,6 +226,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
173
226
|
args: [{ providedIn: 'root' }]
|
|
174
227
|
}] });
|
|
175
228
|
|
|
229
|
+
const offlineAuthErrorHandler = (error) => {
|
|
230
|
+
var _a;
|
|
231
|
+
if (error.type === 'discovery_document_load_error' && ((_a = error.reason) === null || _a === void 0 ? void 0 : _a.status) === 504) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
throw error;
|
|
235
|
+
};
|
|
236
|
+
|
|
176
237
|
class AuthService {
|
|
177
238
|
constructor() {
|
|
178
239
|
this.authConfig = injectAuthConfig();
|
|
@@ -312,6 +373,52 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
|
312
373
|
args: [{ providedIn: 'root' }]
|
|
313
374
|
}], ctorParameters: function () { return []; } });
|
|
314
375
|
|
|
376
|
+
let AuthActionsComponent = class AuthActionsComponent {
|
|
377
|
+
constructor() {
|
|
378
|
+
this.element = injectElement();
|
|
379
|
+
this.claims = null;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
AuthActionsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthActionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
383
|
+
AuthActionsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: AuthActionsComponent, isStandalone: true, selector: "odx-auth-actions", inputs: { claims: "claims" }, ngImport: i0, template: "<odx-list>\n <a data-testid=\"odx-auth-user-profile-link\" odxListItem [href]=\"url\" rel=\"noopener\" target=\"_blank\" *ngIf=\"claims?.userProfileUrl as url\">\n <odx-icon name=\"user-administration\" iconSet=\"core\" odxListPrefix></odx-icon>\n {{ 'userProfileLink' | odxTranslate | async }}\n </a>\n</odx-list>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "ngmodule", type: ListModule }, { kind: "component", type: i2.ListComponent, selector: "odx-list", inputs: ["multiple"] }, { kind: "component", type: i2.ListItemComponent, selector: "[odxListItem]", inputs: ["danger", "selected"] }, { kind: "component", type: i3.IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name", "iconSet"] }, { kind: "pipe", type: TranslatePipe, name: "odxTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
384
|
+
AuthActionsComponent = __decorate([
|
|
385
|
+
CSSComponent('auth-actions')
|
|
386
|
+
], AuthActionsComponent);
|
|
387
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthActionsComponent, decorators: [{
|
|
388
|
+
type: Component,
|
|
389
|
+
args: [{ standalone: true, selector: 'odx-auth-actions', imports: [CoreModule, ListModule, TranslatePipe], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<odx-list>\n <a data-testid=\"odx-auth-user-profile-link\" odxListItem [href]=\"url\" rel=\"noopener\" target=\"_blank\" *ngIf=\"claims?.userProfileUrl as url\">\n <odx-icon name=\"user-administration\" iconSet=\"core\" odxListPrefix></odx-icon>\n {{ 'userProfileLink' | odxTranslate | async }}\n </a>\n</odx-list>\n" }]
|
|
390
|
+
}], propDecorators: { claims: [{
|
|
391
|
+
type: Input
|
|
392
|
+
}] } });
|
|
393
|
+
|
|
394
|
+
class AuthLoadingScreenComponent {
|
|
395
|
+
constructor() {
|
|
396
|
+
this.authConfig = injectAuthConfig();
|
|
397
|
+
this.icon$ = inject(AuthService).isRedirecting$.pipe(startWith(false), distinctUntilChanged(), map((isRedirecting) => (isRedirecting ? 'link-external' : 'user')));
|
|
398
|
+
}
|
|
399
|
+
static initialize(authService, dynamicViewService) {
|
|
400
|
+
authService.isLoading$.subscribe((isLoading) => {
|
|
401
|
+
var _a, _b;
|
|
402
|
+
if (isLoading) {
|
|
403
|
+
(_a = AuthLoadingScreenComponent.instance) !== null && _a !== void 0 ? _a : (AuthLoadingScreenComponent.instance = dynamicViewService.createView(AuthLoadingScreenComponent));
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
(_b = AuthLoadingScreenComponent.instance) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
407
|
+
AuthLoadingScreenComponent.instance = null;
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
AuthLoadingScreenComponent.instance = null;
|
|
413
|
+
AuthLoadingScreenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthLoadingScreenComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
414
|
+
AuthLoadingScreenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: AuthLoadingScreenComponent, isStandalone: true, selector: "div.odx-auth-loading-screen", host: { properties: { "@hostAnimation": "true" } }, ngImport: i0, template: "<div class=\"odx-auth-loading-screen__content\" odxLayout=\"grid 12 horizontal-center vertical-center gap-small\">\n <odx-logo size=\"large\"></odx-logo>\n <odx-circular-progress class=\"odx-auth-loading-screen__spinner\" value=\"-1\" size=\"medium\" stroke=\"3\">\n <odx-icon [name]=\"icon$ | async\" iconSet=\"core\"></odx-icon>\n </odx-circular-progress>\n <p class=\"odx-auth-loading-screen__message\" *ngIf=\"authConfig.loadingScreenMessage as content\">\n <ng-template [odxDynamicView]=\"content\"></ng-template>\n </p>\n</div>\n", styles: ["@keyframes odx-auth-loading-screen-animation{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%)}}.odx-auth-loading-screen{--odx-c-highlight: var(--odx-c-primary);background-color:var(--odx-c-background-content);position:fixed;z-index:var(--odx-v-layer-5);inset:0}.odx-auth-loading-screen__content{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;animation:odx-auth-loading-screen-animation .75s ease}.odx-auth-loading-screen__message{text-align:center}.odx-auth-loading-screen__spinner{position:relative}.odx-auth-loading-screen__spinner .odx-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "component", type: IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name", "iconSet"] }, { kind: "directive", type: LogoDirective, selector: "odx-logo", inputs: ["size", "variant"] }, { kind: "component", type: CircularProgressComponent, selector: "odx-circular-progress", inputs: ["stroke", "size", "value"] }, { kind: "directive", type: DynamicViewDirective, selector: "ng-template[odxDynamicView]", inputs: ["odxDynamicView", "odxDynamicViewInjector", "odxDynamicViewContext"] }], animations: [trigger('hostAnimation', [transition(':leave', useAnimation(fadeOut()))])], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
415
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthLoadingScreenComponent, decorators: [{
|
|
416
|
+
type: Component,
|
|
417
|
+
args: [{ standalone: true, selector: 'div.odx-auth-loading-screen', imports: [CommonModule, ButtonComponent, IconComponent, LogoDirective, CircularProgressComponent, DynamicViewDirective], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
418
|
+
'[@hostAnimation]': 'true',
|
|
419
|
+
}, animations: [trigger('hostAnimation', [transition(':leave', useAnimation(fadeOut()))])], template: "<div class=\"odx-auth-loading-screen__content\" odxLayout=\"grid 12 horizontal-center vertical-center gap-small\">\n <odx-logo size=\"large\"></odx-logo>\n <odx-circular-progress class=\"odx-auth-loading-screen__spinner\" value=\"-1\" size=\"medium\" stroke=\"3\">\n <odx-icon [name]=\"icon$ | async\" iconSet=\"core\"></odx-icon>\n </odx-circular-progress>\n <p class=\"odx-auth-loading-screen__message\" *ngIf=\"authConfig.loadingScreenMessage as content\">\n <ng-template [odxDynamicView]=\"content\"></ng-template>\n </p>\n</div>\n", styles: ["@keyframes odx-auth-loading-screen-animation{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%)}}.odx-auth-loading-screen{--odx-c-highlight: var(--odx-c-primary);background-color:var(--odx-c-background-content);position:fixed;z-index:var(--odx-v-layer-5);inset:0}.odx-auth-loading-screen__content{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;animation:odx-auth-loading-screen-animation .75s ease}.odx-auth-loading-screen__message{text-align:center}.odx-auth-loading-screen__spinner{position:relative}.odx-auth-loading-screen__spinner .odx-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}\n"] }]
|
|
420
|
+
}] });
|
|
421
|
+
|
|
315
422
|
class AuthActionDirective {
|
|
316
423
|
constructor() {
|
|
317
424
|
this.takeUntilDestroyed = untilDestroyed();
|
|
@@ -343,7 +450,7 @@ class SignInDirective extends AuthActionDirective {
|
|
|
343
450
|
}
|
|
344
451
|
}
|
|
345
452
|
SignInDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SignInDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
346
|
-
SignInDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: SignInDirective, isStandalone: true, selector: "[odxButton][odxAuthSignIn]", outputs: { afterSignIn: "odxAuthSignIn" }, host: { listeners: { "click": "handleClick()" } }, usesInheritance: true, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
|
|
453
|
+
SignInDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: SignInDirective, isStandalone: true, selector: "[odxButton][odxAuthSignIn]", outputs: { afterSignIn: "odxAuthSignIn" }, host: { listeners: { "click": "handleClick()" } }, usesInheritance: true, hostDirectives: [{ directive: i1$1.LoadingSpinnerDirective }], ngImport: i0 });
|
|
347
454
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SignInDirective, decorators: [{
|
|
348
455
|
type: Directive,
|
|
349
456
|
args: [{
|
|
@@ -371,7 +478,7 @@ class SignOutDirective extends AuthActionDirective {
|
|
|
371
478
|
}
|
|
372
479
|
}
|
|
373
480
|
SignOutDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SignOutDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
|
|
374
|
-
SignOutDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: SignOutDirective, isStandalone: true, selector: "[odxButton][odxAuthSignOut]", outputs: { afterSignOut: "odxAuthSignOut" }, host: { listeners: { "click": "handleClick()" } }, usesInheritance: true, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
|
|
481
|
+
SignOutDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: SignOutDirective, isStandalone: true, selector: "[odxButton][odxAuthSignOut]", outputs: { afterSignOut: "odxAuthSignOut" }, host: { listeners: { "click": "handleClick()" } }, usesInheritance: true, hostDirectives: [{ directive: i1$1.LoadingSpinnerDirective }], ngImport: i0 });
|
|
375
482
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SignOutDirective, decorators: [{
|
|
376
483
|
type: Directive,
|
|
377
484
|
args: [{
|
|
@@ -396,20 +503,25 @@ class AuthComponent {
|
|
|
396
503
|
enableFallback: false,
|
|
397
504
|
containerClass: 'odx-auth-user-profile',
|
|
398
505
|
};
|
|
399
|
-
this.signInButtonText = 'Sign in';
|
|
400
|
-
this.signOutButtonText = 'Sign out';
|
|
401
506
|
}
|
|
402
507
|
}
|
|
403
508
|
AuthComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
404
|
-
AuthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: AuthComponent, isStandalone: true, selector: "odx-auth",
|
|
509
|
+
AuthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: AuthComponent, isStandalone: true, selector: "odx-auth", providers: [provideTranslations(translations)], ngImport: i0, template: "<odx-action-group>\n <ng-template [ngrxLet]=\"{ idClaims: authService.identityClaims$, isAuthenticated: authService.isAuthenticated$ }\" let-vm>\n <ng-template [ngIf]=\"vm.isAuthenticated\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton [odxDropdown]=\"userProfileMenu\" [odxDropdownOptions]=\"dropdownOptions\" data-testid=\"odx-auth-user-profile-button\">\n <ng-template [ngTemplateOutlet]=\"userAvatar\"></ng-template>\n </button>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <ng-template [ngTemplateOutlet]=\"userAvatar\" ngProjectAs=\"odx-avatar\"></ng-template>\n {{ vm.idClaims?.username }}\n <odx-area-header-subtitle>\n {{ vm.idClaims?.email }}\n </odx-area-header-subtitle>\n </odx-area-header>\n <ng-content></ng-content>\n <odx-auth-actions [claims]=\"vm.idClaims\"></odx-auth-actions>\n <div class=\"odx-margin-top-12\" odxLayout=\"flex vertical-center\">\n <odx-logo odxLayout=\"auto\" class=\"odx-margin-left-12 odx-margin-right-auto\"></odx-logo>\n <button odxButton odxAuthSignOut variant=\"ghost\" data-testid=\"odx-auth-sign-out-button\">\n {{ 'signOutButtonText' | odxTranslate | async }}\n <odx-icon name=\"logout\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"secondary\" data-testid=\"odx-auth-sign-in-button\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ 'signInButtonText' | odxTranslate | async }}\n </button>\n </ng-template>\n <ng-template #userAvatar>\n <odx-avatar class=\"odx-auth-user-avatar\">\n {{ vm.idClaims?.initials ?? '' }}\n </odx-avatar>\n </ng-template>\n </ng-template>\n</odx-action-group>\n", styles: [".odx-auth-user-profile .odx-dropdown__inner>.odx-area-header{max-width:max(360px,25vw);min-width:296px}.odx-auth-actions{display:block;margin-top:calc(var(--odx-vertical-rythm-base-size) * .5);margin-bottom:calc(var(--odx-vertical-rythm-base-size) * .5);margin-right:calc(var(--odx-vertical-rythm-base-size) * .25);margin-left:calc(var(--odx-vertical-rythm-base-size) * .25)}\n"], dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "directive", type: i2$1.LetDirective, selector: "[ngrxLet]", inputs: ["ngrxLet", "ngrxLetSuspenseTpl"] }, { kind: "ngmodule", type: AreaHeaderModule }, { kind: "component", type: i3$1.AreaHeaderComponent, selector: "odx-area-header", inputs: ["size"] }, { kind: "directive", type: i3$1.AreaHeaderSubtitleDirective, selector: "odx-area-header-subtitle" }, { kind: "component", type: i4.AvatarComponent, selector: "odx-avatar", inputs: ["size", "variant"] }, { kind: "component", type: i5.ActionGroupComponent, selector: "odx-action-group", inputs: ["reverse"] }, { kind: "component", type: i6.ButtonComponent, selector: "button[odxButton], a[odxButton]", inputs: ["variant", "size"] }, { kind: "component", type: i3.IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name", "iconSet"] }, { kind: "ngmodule", type: DropdownModule }, { kind: "directive", type: i8.DropdownDirective, selector: "[odxDropdown]", inputs: ["odxDropdown", "odxDropdownDisabled", "odxDropdownShowLoader", "odxDropdownClickOutsideActive", "odxDropdownOptions", "odxDropdownReferenceElement", "odxDropdownTriggerElement", "odxDropdownHost", "odxDropdownOpenTrigger", "odxDropdownCloseTrigger"], outputs: ["odxDropdownBeforeOpen", "odxDropdownAfterOpen", "odxDropdownBeforeClose", "odxDropdownAfterClose"], exportAs: ["odxDropdown"] }, { kind: "ngmodule", type: HeaderModule }, { kind: "directive", type: LogoDirective, selector: "odx-logo", inputs: ["size", "variant"] }, { kind: "directive", type: SignInDirective, selector: "[odxButton][odxAuthSignIn]", outputs: ["odxAuthSignIn"] }, { kind: "directive", type: SignOutDirective, selector: "[odxButton][odxAuthSignOut]", outputs: ["odxAuthSignOut"] }, { kind: "ngmodule", type: LoadingSpinnerModule }, { kind: "component", type: AuthActionsComponent, selector: "odx-auth-actions", inputs: ["claims"] }, { kind: "pipe", type: TranslatePipe, name: "odxTranslate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
405
510
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthComponent, decorators: [{
|
|
406
511
|
type: Component,
|
|
407
|
-
args: [{ standalone: true, selector: 'odx-auth', imports: [
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
512
|
+
args: [{ standalone: true, selector: 'odx-auth', imports: [
|
|
513
|
+
CoreModule,
|
|
514
|
+
AreaHeaderModule,
|
|
515
|
+
DropdownModule,
|
|
516
|
+
HeaderModule,
|
|
517
|
+
LogoDirective,
|
|
518
|
+
SignInDirective,
|
|
519
|
+
SignOutDirective,
|
|
520
|
+
LoadingSpinnerModule,
|
|
521
|
+
AuthActionsComponent,
|
|
522
|
+
TranslatePipe,
|
|
523
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [provideTranslations(translations)], template: "<odx-action-group>\n <ng-template [ngrxLet]=\"{ idClaims: authService.identityClaims$, isAuthenticated: authService.isAuthenticated$ }\" let-vm>\n <ng-template [ngIf]=\"vm.isAuthenticated\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton [odxDropdown]=\"userProfileMenu\" [odxDropdownOptions]=\"dropdownOptions\" data-testid=\"odx-auth-user-profile-button\">\n <ng-template [ngTemplateOutlet]=\"userAvatar\"></ng-template>\n </button>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <ng-template [ngTemplateOutlet]=\"userAvatar\" ngProjectAs=\"odx-avatar\"></ng-template>\n {{ vm.idClaims?.username }}\n <odx-area-header-subtitle>\n {{ vm.idClaims?.email }}\n </odx-area-header-subtitle>\n </odx-area-header>\n <ng-content></ng-content>\n <odx-auth-actions [claims]=\"vm.idClaims\"></odx-auth-actions>\n <div class=\"odx-margin-top-12\" odxLayout=\"flex vertical-center\">\n <odx-logo odxLayout=\"auto\" class=\"odx-margin-left-12 odx-margin-right-auto\"></odx-logo>\n <button odxButton odxAuthSignOut variant=\"ghost\" data-testid=\"odx-auth-sign-out-button\">\n {{ 'signOutButtonText' | odxTranslate | async }}\n <odx-icon name=\"logout\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"secondary\" data-testid=\"odx-auth-sign-in-button\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ 'signInButtonText' | odxTranslate | async }}\n </button>\n </ng-template>\n <ng-template #userAvatar>\n <odx-avatar class=\"odx-auth-user-avatar\">\n {{ vm.idClaims?.initials ?? '' }}\n </odx-avatar>\n </ng-template>\n </ng-template>\n</odx-action-group>\n", styles: [".odx-auth-user-profile .odx-dropdown__inner>.odx-area-header{max-width:max(360px,25vw);min-width:296px}.odx-auth-actions{display:block;margin-top:calc(var(--odx-vertical-rythm-base-size) * .5);margin-bottom:calc(var(--odx-vertical-rythm-base-size) * .5);margin-right:calc(var(--odx-vertical-rythm-base-size) * .25);margin-left:calc(var(--odx-vertical-rythm-base-size) * .25)}\n"] }]
|
|
524
|
+
}] });
|
|
413
525
|
|
|
414
526
|
class AuthDirective {
|
|
415
527
|
constructor() {
|
|
@@ -430,7 +542,7 @@ class AuthDirective {
|
|
|
430
542
|
}
|
|
431
543
|
}
|
|
432
544
|
AuthDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
433
|
-
AuthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: AuthDirective, isStandalone: true, selector: "ng-template[odxAuth]", inputs: { authorizationHandler: ["odxAuth", "authorizationHandler"], elseTemplate: ["odxAuthElse", "elseTemplate"] }, hostDirectives: [{ directive: i1
|
|
545
|
+
AuthDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: AuthDirective, isStandalone: true, selector: "ng-template[odxAuth]", inputs: { authorizationHandler: ["odxAuth", "authorizationHandler"], elseTemplate: ["odxAuthElse", "elseTemplate"] }, hostDirectives: [{ directive: i1.NgIf }], ngImport: i0 });
|
|
434
546
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthDirective, decorators: [{
|
|
435
547
|
type: Directive,
|
|
436
548
|
args: [{
|
|
@@ -495,34 +607,6 @@ const coreIdentityPlugin = () => {
|
|
|
495
607
|
};
|
|
496
608
|
};
|
|
497
609
|
|
|
498
|
-
class AuthLoadingScreenComponent {
|
|
499
|
-
constructor() {
|
|
500
|
-
this.authConfig = injectAuthConfig();
|
|
501
|
-
this.icon$ = inject(AuthService).isRedirecting$.pipe(startWith(false), distinctUntilChanged(), map((isRedirecting) => (isRedirecting ? 'link-external' : 'user')));
|
|
502
|
-
}
|
|
503
|
-
static initialize(authService, dynamicViewService) {
|
|
504
|
-
authService.isLoading$.subscribe((isLoading) => {
|
|
505
|
-
var _a, _b;
|
|
506
|
-
if (isLoading) {
|
|
507
|
-
(_a = AuthLoadingScreenComponent.instance) !== null && _a !== void 0 ? _a : (AuthLoadingScreenComponent.instance = dynamicViewService.createView(AuthLoadingScreenComponent));
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
(_b = AuthLoadingScreenComponent.instance) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
511
|
-
AuthLoadingScreenComponent.instance = null;
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
AuthLoadingScreenComponent.instance = null;
|
|
517
|
-
AuthLoadingScreenComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthLoadingScreenComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
518
|
-
AuthLoadingScreenComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: AuthLoadingScreenComponent, isStandalone: true, selector: "div.odx-auth-loading-screen", host: { properties: { "@hostAnimation": "true" } }, ngImport: i0, template: "<div class=\"odx-auth-loading-screen__content\" odxLayout=\"grid 12 horizontal-center vertical-center gap-small\">\n <odx-logo size=\"large\"></odx-logo>\n <odx-circular-progress class=\"odx-auth-loading-screen__spinner\" value=\"-1\" size=\"medium\" stroke=\"3\">\n <odx-icon [name]=\"icon$ | async\" iconSet=\"core\"></odx-icon>\n </odx-circular-progress>\n <p class=\"odx-auth-loading-screen__message\" *ngIf=\"authConfig.loadingScreenMessage as content\">\n <ng-template [odxDynamicView]=\"content\"></ng-template>\n </p>\n</div>\n", styles: ["@keyframes odx-auth-loading-screen-animation{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%)}}.odx-auth-loading-screen{--odx-c-highlight: var(--odx-c-primary);background-color:var(--odx-c-background-content);position:fixed;z-index:var(--odx-v-layer-5);inset:0}.odx-auth-loading-screen__content{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;animation:odx-auth-loading-screen-animation .75s ease}.odx-auth-loading-screen__message{text-align:center}.odx-auth-loading-screen__spinner{position:relative}.odx-auth-loading-screen__spinner .odx-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.AsyncPipe, name: "async" }, { kind: "component", type: IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name", "iconSet"] }, { kind: "directive", type: LogoDirective, selector: "odx-logo", inputs: ["size", "variant"] }, { kind: "component", type: CircularProgressComponent, selector: "odx-circular-progress", inputs: ["stroke", "size", "value"] }, { kind: "directive", type: DynamicViewDirective, selector: "ng-template[odxDynamicView]", inputs: ["odxDynamicView", "odxDynamicViewInjector", "odxDynamicViewContext"] }], animations: [trigger('hostAnimation', [transition(':leave', useAnimation(fadeOut()))])], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
519
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AuthLoadingScreenComponent, decorators: [{
|
|
520
|
-
type: Component,
|
|
521
|
-
args: [{ standalone: true, selector: 'div.odx-auth-loading-screen', imports: [CommonModule, ButtonComponent, IconComponent, LogoDirective, CircularProgressComponent, DynamicViewDirective], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
522
|
-
'[@hostAnimation]': 'true',
|
|
523
|
-
}, animations: [trigger('hostAnimation', [transition(':leave', useAnimation(fadeOut()))])], template: "<div class=\"odx-auth-loading-screen__content\" odxLayout=\"grid 12 horizontal-center vertical-center gap-small\">\n <odx-logo size=\"large\"></odx-logo>\n <odx-circular-progress class=\"odx-auth-loading-screen__spinner\" value=\"-1\" size=\"medium\" stroke=\"3\">\n <odx-icon [name]=\"icon$ | async\" iconSet=\"core\"></odx-icon>\n </odx-circular-progress>\n <p class=\"odx-auth-loading-screen__message\" *ngIf=\"authConfig.loadingScreenMessage as content\">\n <ng-template [odxDynamicView]=\"content\"></ng-template>\n </p>\n</div>\n", styles: ["@keyframes odx-auth-loading-screen-animation{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%)}}.odx-auth-loading-screen{--odx-c-highlight: var(--odx-c-primary);background-color:var(--odx-c-background-content);position:fixed;z-index:var(--odx-v-layer-5);inset:0}.odx-auth-loading-screen__content{top:50%;left:50%;transform:translate(-50%,-50%);position:absolute;animation:odx-auth-loading-screen-animation .75s ease}.odx-auth-loading-screen__message{text-align:center}.odx-auth-loading-screen__spinner{position:relative}.odx-auth-loading-screen__spinner .odx-icon{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}\n"] }]
|
|
524
|
-
}] });
|
|
525
|
-
|
|
526
610
|
const loadingScreenPlugin = () => {
|
|
527
611
|
const { enableLoadingScreen, showRedirectOverlay } = injectAuthConfig();
|
|
528
612
|
const dynamicViewService = inject(DynamicViewService);
|
|
@@ -534,6 +618,13 @@ const loadingScreenPlugin = () => {
|
|
|
534
618
|
};
|
|
535
619
|
};
|
|
536
620
|
|
|
621
|
+
const userProfileUrlPlugin = () => {
|
|
622
|
+
const { environment, userProfileUrl } = injectAuthConfig();
|
|
623
|
+
return () => {
|
|
624
|
+
return of({ userProfileUrl: userProfileUrl !== null && userProfileUrl !== void 0 ? userProfileUrl : DEFAULT_USER_PROFILE_URLS[environment] });
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
|
|
537
628
|
function configureInterceptor() {
|
|
538
629
|
const { allowedUrls } = injectAuthConfig();
|
|
539
630
|
return {
|
|
@@ -543,11 +634,10 @@ function configureInterceptor() {
|
|
|
543
634
|
},
|
|
544
635
|
};
|
|
545
636
|
}
|
|
546
|
-
function
|
|
637
|
+
function initializeAuthErrorHandlers() {
|
|
547
638
|
const authService = inject(AuthService);
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
authService.errors$.pipe(tap((error) => injector.runInContext(() => errorHandler(error)))).subscribe();
|
|
639
|
+
const handler = handleAuthError(inject(ODX_AUTH_ERROR_HANDLERS));
|
|
640
|
+
authService.errors$.pipe(tap((error) => handler(error))).subscribe();
|
|
551
641
|
}
|
|
552
642
|
function initalizeAuthConfig() {
|
|
553
643
|
const { clientId, scopes, redirectPath, environment, postLogoutRedirectUrl, issuer, timeoutFactor, discoveryUrl } = injectAuthConfig();
|
|
@@ -577,9 +667,13 @@ function provideAuth(config) {
|
|
|
577
667
|
},
|
|
578
668
|
{
|
|
579
669
|
provide: ENVIRONMENT_INITIALIZER,
|
|
580
|
-
useValue:
|
|
670
|
+
useValue: initializeAuthErrorHandlers,
|
|
581
671
|
multi: true,
|
|
582
672
|
},
|
|
673
|
+
{
|
|
674
|
+
provide: ODX_AUTH_ERROR_HANDLERS,
|
|
675
|
+
useFactory: () => [offlineAuthErrorHandler, injectAuthConfig().errorHandler],
|
|
676
|
+
},
|
|
583
677
|
{
|
|
584
678
|
provide: APP_INITIALIZER,
|
|
585
679
|
useFactory: initalizeAuthConfig,
|
|
@@ -587,11 +681,11 @@ function provideAuth(config) {
|
|
|
587
681
|
},
|
|
588
682
|
{
|
|
589
683
|
provide: OAuthStorage,
|
|
590
|
-
useFactory: () => { var _a; return (_a =
|
|
684
|
+
useFactory: () => { var _a; return (_a = injectAuthConfig().storage) !== null && _a !== void 0 ? _a : inject(WindowRef).nativeWindow.localStorage; },
|
|
591
685
|
},
|
|
592
686
|
{
|
|
593
687
|
provide: ODX_AUTH_CORE_PLUGINS,
|
|
594
|
-
useValue: [coreIdentityPlugin, loadingScreenPlugin],
|
|
688
|
+
useValue: [coreIdentityPlugin, loadingScreenPlugin, userProfileUrlPlugin],
|
|
595
689
|
},
|
|
596
690
|
]);
|
|
597
691
|
}
|
|
@@ -618,5 +712,5 @@ function unauthGuard(authorizedHandler, redirectTo) {
|
|
|
618
712
|
* Generated bundle index. Do not edit.
|
|
619
713
|
*/
|
|
620
714
|
|
|
621
|
-
export { AuthActionDirective, AuthComponent, AuthConfig, AuthDefaultConfig, AuthDirective, AuthHttpCache, AuthLoadingScreenComponent, AuthModule, AuthPluginManager, AuthService, DEFAULT_AUTH_SCOPES, DEFAULT_ISSUERS, ODX_AUTH_CORE_PLUGINS, ODX_AUTH_HTTP_CACHE_STORAGE, ODX_AUTH_PLUGINS, SignInDirective, SignOutDirective, authGuard, configureInterceptor, coreIdentityPlugin, createInitials, initalizeAuthConfig,
|
|
715
|
+
export { AuthActionDirective, AuthActionsComponent, AuthComponent, AuthConfig, AuthDefaultConfig, AuthDirective, AuthHttpCache, AuthLoadingScreenComponent, AuthModule, AuthPluginManager, AuthService, DEFAULT_AUTH_SCOPES, DEFAULT_ISSUERS, DEFAULT_USER_PROFILE_URLS, ODX_AUTH_CORE_PLUGINS, ODX_AUTH_ERROR_HANDLERS, ODX_AUTH_HTTP_CACHE_STORAGE, ODX_AUTH_PLUGINS, SignInDirective, SignOutDirective, authGuard, configureInterceptor, coreIdentityPlugin, createInitials, handleAuthError, initalizeAuthConfig, initializeAuthErrorHandlers, injectAuthConfig, loadingScreenPlugin, offlineAuthErrorHandler, provideAuth, provideAuthConfig, resolveEmail, resolveUsername, unauthGuard, userProfileUrlPlugin };
|
|
622
716
|
//# sourceMappingURL=odx-auth.mjs.map
|