@odx/auth 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +38 -0
  2. package/esm2020/index.mjs +10 -0
  3. package/esm2020/lib/auth.component.mjs +50 -0
  4. package/esm2020/lib/auth.config.mjs +8 -0
  5. package/esm2020/lib/auth.interceptor.mjs +25 -0
  6. package/esm2020/lib/auth.module.mjs +28 -0
  7. package/esm2020/lib/auth.providers.mjs +50 -0
  8. package/esm2020/lib/auth.service.mjs +37 -0
  9. package/esm2020/lib/directives/index.mjs +3 -0
  10. package/esm2020/lib/directives/sign-in.directive.mjs +38 -0
  11. package/esm2020/lib/directives/sign-out.directive.mjs +38 -0
  12. package/esm2020/lib/helpers/get-user-initials.mjs +12 -0
  13. package/esm2020/lib/helpers/index.mjs +3 -0
  14. package/esm2020/lib/helpers/resolve-issuer.mjs +13 -0
  15. package/esm2020/lib/models/auth-environment.mjs +2 -0
  16. package/esm2020/lib/models/index.mjs +3 -0
  17. package/esm2020/lib/models/user.mjs +2 -0
  18. package/esm2020/odx-auth.mjs +5 -0
  19. package/fesm2015/odx-auth.mjs +283 -0
  20. package/fesm2015/odx-auth.mjs.map +1 -0
  21. package/fesm2020/odx-auth.mjs +273 -0
  22. package/fesm2020/odx-auth.mjs.map +1 -0
  23. package/index.d.ts +9 -0
  24. package/lib/auth.component.d.ts +12 -0
  25. package/lib/auth.config.d.ts +12 -0
  26. package/lib/auth.interceptor.d.ts +11 -0
  27. package/lib/auth.module.d.ts +14 -0
  28. package/lib/auth.providers.d.ts +6 -0
  29. package/lib/auth.service.d.ts +19 -0
  30. package/lib/directives/index.d.ts +2 -0
  31. package/lib/directives/sign-in.directive.d.ts +12 -0
  32. package/lib/directives/sign-out.directive.d.ts +12 -0
  33. package/lib/helpers/get-user-initials.d.ts +2 -0
  34. package/lib/helpers/index.d.ts +2 -0
  35. package/lib/helpers/resolve-issuer.d.ts +2 -0
  36. package/lib/models/auth-environment.d.ts +1 -0
  37. package/lib/models/index.d.ts +2 -0
  38. package/lib/models/user.d.ts +4 -0
  39. package/package.json +37 -0
@@ -0,0 +1,283 @@
1
+ import { OKTA_AUTH, OktaAuthStateService, OktaCallbackComponent, OKTA_CONFIG, OktaAuthModule } from '@okta/okta-angular';
2
+ export { OktaAuthGuard as AuthGuard } from '@okta/okta-angular';
3
+ import { __awaiter, __decorate, __metadata } from 'tslib';
4
+ import * as i0 from '@angular/core';
5
+ import { inject, Injectable, EventEmitter, Directive, Output, HostListener, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, APP_INITIALIZER, NgModule } from '@angular/core';
6
+ import * as i2 from '@odx/angular';
7
+ import { CoreModule, WindowRef } from '@odx/angular';
8
+ import * as i3 from '@odx/angular/components/area-header';
9
+ import { AreaHeaderModule } from '@odx/angular/components/area-header';
10
+ import * as i8 from '@odx/angular/components/dropdown';
11
+ import { DropdownModule } from '@odx/angular/components/dropdown';
12
+ import * as i9 from '@odx/angular/components/header';
13
+ import { HeaderModule } from '@odx/angular/components/header';
14
+ import { LogoDirective } from '@odx/angular/components/logo';
15
+ import { createModuleConfigTokens, Pure, buildUrl, provideModuleConfig } from '@odx/angular/utils';
16
+ import { map, shareReplay } from 'rxjs';
17
+ import * as i1 from '@odx/angular/components/loading-spinner';
18
+ import { LoadingSpinnerDirective } from '@odx/angular/components/loading-spinner';
19
+ import * as i1$1 from '@angular/common';
20
+ import * as i4 from '@odx/angular/components/avatar';
21
+ import * as i5 from '@odx/angular/components/action-group';
22
+ import * as i6 from '@odx/angular/components/button';
23
+ import * as i7 from '@odx/angular/components/icon';
24
+ import { HTTP_INTERCEPTORS } from '@angular/common/http';
25
+ import { Router } from '@angular/router';
26
+ import { OktaAuth } from '@okta/okta-auth-js';
27
+
28
+ const DEFAULT_AUTH_SCOPES = ['openid', 'profile'];
29
+ const { AuthDefaultModuleConfig, AuthModuleConfig, injectAuthModuleConfig } = createModuleConfigTokens('Auth', '@odx/auth', {
30
+ environment: 'prod',
31
+ redirectPath: 'login/callback',
32
+ disallowedOrigins: [],
33
+ });
34
+
35
+ class AuthService {
36
+ constructor() {
37
+ this.auth = inject(OKTA_AUTH);
38
+ this.authState = inject(OktaAuthStateService);
39
+ this.isAuthenticated$ = this.authState.authState$.pipe(map(({ isAuthenticated }) => !!isAuthenticated), shareReplay({ refCount: true }));
40
+ this.user$ = this.authState.authState$.pipe(map(({ idToken }) => { var _a; return (_a = idToken === null || idToken === void 0 ? void 0 : idToken.claims) !== null && _a !== void 0 ? _a : null; }), shareReplay({ refCount: true }));
41
+ }
42
+ signIn() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ yield this.auth.signInWithRedirect();
45
+ });
46
+ }
47
+ signOut() {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ yield this.auth.signOut();
50
+ });
51
+ }
52
+ getAccessToken() {
53
+ var _a;
54
+ return (_a = this.auth.getAccessToken()) !== null && _a !== void 0 ? _a : null;
55
+ }
56
+ getRefreshToken() {
57
+ var _a;
58
+ return (_a = this.auth.getRefreshToken()) !== null && _a !== void 0 ? _a : null;
59
+ }
60
+ getAuthHeader() {
61
+ return { Authorization: `Bearer ${this.getAccessToken()}` };
62
+ }
63
+ hasAnyGroups$(groups) {
64
+ return this.authState.hasAnyGroups(groups);
65
+ }
66
+ }
67
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
68
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, providedIn: 'root' });
69
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, decorators: [{
70
+ type: Injectable,
71
+ args: [{ providedIn: 'root' }]
72
+ }] });
73
+
74
+ class SignInDirective {
75
+ constructor() {
76
+ this.authService = inject(AuthService);
77
+ this.loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });
78
+ // eslint-disable-next-line @angular-eslint/no-output-rename
79
+ this.afterSignIn = new EventEmitter();
80
+ }
81
+ ngOnInit() {
82
+ this.loadingSpinnerDirective.autoColor = true;
83
+ }
84
+ signIn() {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ this.loadingSpinnerDirective.isLoading = true;
87
+ yield this.authService.signIn();
88
+ this.afterSignIn.emit();
89
+ });
90
+ }
91
+ }
92
+ SignInDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignInDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
93
+ SignInDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: SignInDirective, isStandalone: true, selector: "[odxButton][odxAuthSignIn]", outputs: { afterSignIn: "odxAuthSignIn" }, host: { listeners: { "click": "signIn()" } }, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
94
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignInDirective, decorators: [{
95
+ type: Directive,
96
+ args: [{
97
+ standalone: true,
98
+ selector: '[odxButton][odxAuthSignIn]',
99
+ hostDirectives: [LoadingSpinnerDirective],
100
+ }]
101
+ }], propDecorators: { afterSignIn: [{
102
+ type: Output,
103
+ args: ['odxAuthSignIn']
104
+ }], signIn: [{
105
+ type: HostListener,
106
+ args: ['click']
107
+ }] } });
108
+
109
+ class SignOutDirective {
110
+ constructor() {
111
+ this.authService = inject(AuthService);
112
+ this.loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });
113
+ // eslint-disable-next-line @angular-eslint/no-output-rename
114
+ this.afterSignOut = new EventEmitter();
115
+ }
116
+ ngOnInit() {
117
+ this.loadingSpinnerDirective.autoColor = true;
118
+ }
119
+ signIn() {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ this.loadingSpinnerDirective.isLoading = true;
122
+ yield this.authService.signOut();
123
+ this.afterSignOut.emit();
124
+ });
125
+ }
126
+ }
127
+ SignOutDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignOutDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
128
+ SignOutDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: SignOutDirective, isStandalone: true, selector: "[odxButton][odxAuthSignOut]", outputs: { afterSignOut: "odxAuthSignOut" }, host: { listeners: { "click": "signIn()" } }, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
129
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignOutDirective, decorators: [{
130
+ type: Directive,
131
+ args: [{
132
+ standalone: true,
133
+ selector: '[odxButton][odxAuthSignOut]',
134
+ hostDirectives: [LoadingSpinnerDirective],
135
+ }]
136
+ }], propDecorators: { afterSignOut: [{
137
+ type: Output,
138
+ args: ['odxAuthSignOut']
139
+ }], signIn: [{
140
+ type: HostListener,
141
+ args: ['click']
142
+ }] } });
143
+
144
+ function getUserInitials(user) {
145
+ if (!(user === null || user === void 0 ? void 0 : user.name))
146
+ return '';
147
+ const names = user.name.trim().split(' ');
148
+ return names.reduce((initials, curr, index) => {
149
+ if (index === 0 || index === names.length - 1) {
150
+ initials = `${initials}${curr.charAt(0).toUpperCase()}`;
151
+ }
152
+ return initials;
153
+ }, '');
154
+ }
155
+
156
+ function resolveIssuer(environment, issuerOverride) {
157
+ if (issuerOverride)
158
+ return issuerOverride;
159
+ switch (environment) {
160
+ case 'dev':
161
+ return 'https://dev.login.draeger.com/oauth2/default';
162
+ case 'stage':
163
+ return 'https://test.login.draeger.com/oauth2/default';
164
+ default:
165
+ return 'https://login.draeger.com/oauth2/default';
166
+ }
167
+ }
168
+
169
+ class AuthComponent {
170
+ constructor() {
171
+ this.config = injectAuthModuleConfig();
172
+ this.authService = inject(AuthService);
173
+ this.signInButtonText = 'Sign in';
174
+ this.signOutButtonText = 'Sign out';
175
+ }
176
+ getInitials(user) {
177
+ return getUserInitials(user);
178
+ }
179
+ }
180
+ AuthComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
181
+ AuthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: AuthComponent, isStandalone: true, selector: "odx-auth", inputs: { signInButtonText: "signInButtonText", signOutButtonText: "signOutButtonText" }, ngImport: i0, template: "<odx-action-group *odxLet=\"authService.user$ | async as user\">\n <ng-template [ngIf]=\"authService.isAuthenticated$ | async\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton odxHeaderAvatar [odxDropdown]=\"userProfileMenu\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n </button>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"primary\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ signInButtonText }}\n </button>\n </ng-template>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n <h2 class=\"odx-title\">{{ user?.name }}</h2>\n <h5 class=\"odx-subtitle\">{{ user?.email_address }}</h5>\n </odx-area-header>\n <ng-content></ng-content>\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\">\n {{ signOutButtonText }}\n <odx-icon name=\"arrow-right\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n</odx-action-group>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.AsyncPipe, name: "async" }, { kind: "directive", type: i2.LetDirective, selector: "ng-template[odxLet]", inputs: ["odxLet"] }, { kind: "ngmodule", type: AreaHeaderModule }, { kind: "component", type: i3.AreaHeaderComponent, selector: "odx-area-header", inputs: ["size"] }, { 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: i7.IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name"] }, { kind: "ngmodule", type: DropdownModule }, { kind: "directive", type: i8.DropdownDirective, selector: "[odxDropdown]", inputs: ["odxDropdown", "odxDropdownDisabled", "odxDropdownShowLoader", "odxDropdownOptions", "odxDropdownReferenceElement", "odxDropdownTriggerElement", "odxDropdownHost", "odxDropdownOpenTrigger", "odxDropdownCloseTrigger"], outputs: ["odxDropdownBeforeOpen", "odxDropdownAfterOpen", "odxDropdownBeforeClose", "odxDropdownAfterClose"], exportAs: ["odxDropdown"] }, { kind: "ngmodule", type: HeaderModule }, { kind: "directive", type: i9.HeaderAvatarDirective, selector: "button[odxButton][odxHeaderAvatar]" }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
182
+ __decorate([
183
+ Pure,
184
+ __metadata("design:type", Function),
185
+ __metadata("design:paramtypes", [Object]),
186
+ __metadata("design:returntype", String)
187
+ ], AuthComponent.prototype, "getInitials", null);
188
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthComponent, decorators: [{
189
+ type: Component,
190
+ args: [{ standalone: true, selector: 'odx-auth', imports: [CoreModule, AreaHeaderModule, DropdownModule, HeaderModule, LogoDirective, SignInDirective, SignOutDirective], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<odx-action-group *odxLet=\"authService.user$ | async as user\">\n <ng-template [ngIf]=\"authService.isAuthenticated$ | async\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton odxHeaderAvatar [odxDropdown]=\"userProfileMenu\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n </button>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"primary\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ signInButtonText }}\n </button>\n </ng-template>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n <h2 class=\"odx-title\">{{ user?.name }}</h2>\n <h5 class=\"odx-subtitle\">{{ user?.email_address }}</h5>\n </odx-area-header>\n <ng-content></ng-content>\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\">\n {{ signOutButtonText }}\n <odx-icon name=\"arrow-right\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n</odx-action-group>\n" }]
191
+ }], propDecorators: { signInButtonText: [{
192
+ type: Input
193
+ }], signOutButtonText: [{
194
+ type: Input
195
+ }], getInitials: [] } });
196
+
197
+ class AuthInterceptor {
198
+ constructor() {
199
+ this.config = injectAuthModuleConfig();
200
+ this.authService = inject(AuthService);
201
+ }
202
+ intercept(request, next) {
203
+ return next.handle(this.addAuthHeader(request));
204
+ }
205
+ addAuthHeader(request) {
206
+ if (!this.config.disallowedOrigins.find((origin) => !!request.url.match(origin))) {
207
+ return request.clone({ setHeaders: this.authService.getAuthHeader() });
208
+ }
209
+ return request;
210
+ }
211
+ }
212
+ AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
213
+ AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor });
214
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor, decorators: [{
215
+ type: Injectable
216
+ }] });
217
+
218
+ function registerAuthCallbackRoute() {
219
+ const { redirectPath } = injectAuthModuleConfig();
220
+ const router = inject(Router);
221
+ return () => {
222
+ router.config.unshift({ path: redirectPath, component: OktaCallbackComponent });
223
+ };
224
+ }
225
+ function initalizeAuthConfig() {
226
+ const { clientId, scopes, redirectPath, environment, postLogoutRedirectPath, issuerOverride } = injectAuthModuleConfig();
227
+ const origin = inject(WindowRef).getOrigin();
228
+ const postLogoutRedirectUri = postLogoutRedirectPath ? buildUrl(origin, postLogoutRedirectPath) : undefined;
229
+ return {
230
+ oktaAuth: new OktaAuth({
231
+ issuer: resolveIssuer(environment, issuerOverride),
232
+ clientId,
233
+ redirectUri: buildUrl(origin, redirectPath),
234
+ scopes: Array.from(new Set(DEFAULT_AUTH_SCOPES.concat(scopes !== null && scopes !== void 0 ? scopes : []))),
235
+ pkce: true,
236
+ devMode: environment === 'dev',
237
+ postLogoutRedirectUri,
238
+ }),
239
+ };
240
+ }
241
+ var authProviders = [
242
+ {
243
+ provide: APP_INITIALIZER,
244
+ useFactory: registerAuthCallbackRoute,
245
+ multi: true,
246
+ },
247
+ {
248
+ provide: OKTA_CONFIG,
249
+ useFactory: initalizeAuthConfig,
250
+ },
251
+ {
252
+ provide: HTTP_INTERCEPTORS,
253
+ useClass: AuthInterceptor,
254
+ multi: true,
255
+ },
256
+ ];
257
+
258
+ const modules = [AuthComponent, SignInDirective, SignOutDirective];
259
+ class AuthModule {
260
+ static forRoot(config) {
261
+ return {
262
+ ngModule: AuthModule,
263
+ providers: [provideModuleConfig(AuthModuleConfig, config), ...authProviders],
264
+ };
265
+ }
266
+ }
267
+ AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
268
+ AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, imports: [AuthComponent, SignInDirective, SignOutDirective], exports: [OktaAuthModule, AuthComponent, SignInDirective, SignOutDirective] });
269
+ AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, imports: [AuthComponent, OktaAuthModule] });
270
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, decorators: [{
271
+ type: NgModule,
272
+ args: [{
273
+ imports: [...modules],
274
+ exports: [OktaAuthModule, ...modules],
275
+ }]
276
+ }] });
277
+
278
+ /**
279
+ * Generated bundle index. Do not edit.
280
+ */
281
+
282
+ export { AuthComponent, AuthDefaultModuleConfig, AuthInterceptor, AuthModule, AuthModuleConfig, AuthService, DEFAULT_AUTH_SCOPES, SignInDirective, SignOutDirective, getUserInitials, initalizeAuthConfig, injectAuthModuleConfig, registerAuthCallbackRoute, resolveIssuer };
283
+ //# sourceMappingURL=odx-auth.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"odx-auth.mjs","sources":["../../../../libs/auth/src/lib/auth.config.ts","../../../../libs/auth/src/lib/auth.service.ts","../../../../libs/auth/src/lib/directives/sign-in.directive.ts","../../../../libs/auth/src/lib/directives/sign-out.directive.ts","../../../../libs/auth/src/lib/helpers/get-user-initials.ts","../../../../libs/auth/src/lib/helpers/resolve-issuer.ts","../../../../libs/auth/src/lib/auth.component.ts","../../../../libs/auth/src/lib/auth.component.html","../../../../libs/auth/src/lib/auth.interceptor.ts","../../../../libs/auth/src/lib/auth.providers.ts","../../../../libs/auth/src/lib/auth.module.ts","../../../../libs/auth/src/odx-auth.ts"],"sourcesContent":["import { createModuleConfigTokens } from '@odx/angular/utils';\n\nimport { OktaAuthOptions } from '@okta/okta-auth-js';\nimport { AuthEnvironment } from './models';\n\nexport const DEFAULT_AUTH_SCOPES = ['openid', 'profile'];\n\nexport interface AuthModuleConfig extends Pick<OktaAuthOptions, 'clientId' | 'scopes'> {\n environment: AuthEnvironment;\n redirectPath: string;\n signUpUrl?: string;\n disallowedOrigins: string[];\n postLogoutRedirectPath?: string;\n issuerOverride?: string;\n}\n\nexport const { AuthDefaultModuleConfig, AuthModuleConfig, injectAuthModuleConfig } = createModuleConfigTokens('Auth', '@odx/auth', {\n environment: 'prod',\n redirectPath: 'login/callback',\n disallowedOrigins: [],\n} as AuthModuleConfig);\n","import { inject, Injectable } from '@angular/core';\nimport { OktaAuthStateService, OKTA_AUTH } from '@okta/okta-angular';\nimport { map, Observable, shareReplay } from 'rxjs';\nimport { User } from './models';\n\n@Injectable({ providedIn: 'root' })\nexport class AuthService {\n private readonly auth = inject(OKTA_AUTH);\n private readonly authState = inject(OktaAuthStateService);\n\n public readonly isAuthenticated$ = this.authState.authState$.pipe(\n map(({ isAuthenticated }) => !!isAuthenticated),\n shareReplay({ refCount: true })\n );\n public readonly user$: Observable<User | null> = this.authState.authState$.pipe(\n map(({ idToken }) => idToken?.claims ?? null),\n shareReplay({ refCount: true })\n );\n\n public async signIn(): Promise<void> {\n await this.auth.signInWithRedirect();\n }\n\n public async signOut(): Promise<void> {\n await this.auth.signOut();\n }\n\n public getAccessToken(): string | null {\n return this.auth.getAccessToken() ?? null;\n }\n\n public getRefreshToken(): string | null {\n return this.auth.getRefreshToken() ?? null;\n }\n\n public getAuthHeader(): { Authorization: `Bearer ${string}` } {\n return { Authorization: `Bearer ${this.getAccessToken()}` };\n }\n\n public hasAnyGroups$(groups: string | string[] | Record<string, string[]>): Observable<boolean> {\n return this.authState.hasAnyGroups(groups);\n }\n}\n","import { Directive, EventEmitter, HostListener, inject, OnInit, Output } from '@angular/core';\nimport { LoadingSpinnerDirective } from '@odx/angular/components/loading-spinner';\nimport { AuthService } from '../auth.service';\n\n@Directive({\n standalone: true,\n selector: '[odxButton][odxAuthSignIn]',\n hostDirectives: [LoadingSpinnerDirective],\n})\nexport class SignInDirective implements OnInit {\n private readonly authService = inject(AuthService);\n private readonly loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });\n\n // eslint-disable-next-line @angular-eslint/no-output-rename\n @Output('odxAuthSignIn')\n public afterSignIn = new EventEmitter<void>();\n\n public ngOnInit(): void {\n this.loadingSpinnerDirective.autoColor = true;\n }\n\n @HostListener('click')\n protected async signIn(): Promise<void> {\n this.loadingSpinnerDirective.isLoading = true;\n await this.authService.signIn();\n this.afterSignIn.emit();\n }\n}\n","import { Directive, EventEmitter, HostListener, inject, OnInit, Output } from '@angular/core';\nimport { LoadingSpinnerDirective } from '@odx/angular/components/loading-spinner';\nimport { AuthService } from '../auth.service';\n\n@Directive({\n standalone: true,\n selector: '[odxButton][odxAuthSignOut]',\n hostDirectives: [LoadingSpinnerDirective],\n})\nexport class SignOutDirective implements OnInit {\n private readonly authService = inject(AuthService);\n private readonly loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });\n\n // eslint-disable-next-line @angular-eslint/no-output-rename\n @Output('odxAuthSignOut')\n public afterSignOut = new EventEmitter<void>();\n\n public ngOnInit(): void {\n this.loadingSpinnerDirective.autoColor = true;\n }\n\n @HostListener('click')\n protected async signIn(): Promise<void> {\n this.loadingSpinnerDirective.isLoading = true;\n await this.authService.signOut();\n this.afterSignOut.emit();\n }\n}\n","import { User } from '../models';\n\nexport function getUserInitials(user?: User | null): string {\n if (!user?.name) return '';\n const names = user.name.trim().split(' ');\n\n return names.reduce((initials, curr, index) => {\n if (index === 0 || index === names.length - 1) {\n initials = `${initials}${curr.charAt(0).toUpperCase()}`;\n }\n return initials;\n }, '');\n}\n","import { AuthEnvironment } from '../models';\n\nexport function resolveIssuer(environment: AuthEnvironment, issuerOverride?: string | null): string {\n if (issuerOverride) return issuerOverride;\n switch (environment) {\n case 'dev':\n return 'https://dev.login.draeger.com/oauth2/default';\n case 'stage':\n return 'https://test.login.draeger.com/oauth2/default';\n default:\n return 'https://login.draeger.com/oauth2/default';\n }\n}\n","import { ChangeDetectionStrategy, Component, inject, Input, ViewEncapsulation } from '@angular/core';\nimport { CoreModule } from '@odx/angular';\nimport { AreaHeaderModule } from '@odx/angular/components/area-header';\nimport { DropdownModule } from '@odx/angular/components/dropdown';\nimport { HeaderModule } from '@odx/angular/components/header';\nimport { LogoDirective } from '@odx/angular/components/logo';\nimport { Pure } from '@odx/angular/utils';\nimport { injectAuthModuleConfig } from './auth.config';\nimport { AuthService } from './auth.service';\nimport { SignInDirective, SignOutDirective } from './directives';\nimport { getUserInitials } from './helpers';\nimport { User } from './models';\n\n@Component({\n standalone: true,\n selector: 'odx-auth',\n imports: [CoreModule, AreaHeaderModule, DropdownModule, HeaderModule, LogoDirective, SignInDirective, SignOutDirective],\n templateUrl: './auth.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n})\nexport class AuthComponent {\n protected readonly config = injectAuthModuleConfig();\n protected readonly authService = inject(AuthService);\n\n @Input()\n public signInButtonText = 'Sign in';\n\n @Input()\n public signOutButtonText = 'Sign out';\n\n @Pure\n public getInitials(user?: User | null): string {\n return getUserInitials(user);\n }\n}\n","<odx-action-group *odxLet=\"authService.user$ | async as user\">\n <ng-template [ngIf]=\"authService.isAuthenticated$ | async\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton odxHeaderAvatar [odxDropdown]=\"userProfileMenu\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n </button>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"primary\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ signInButtonText }}\n </button>\n </ng-template>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n <h2 class=\"odx-title\">{{ user?.name }}</h2>\n <h5 class=\"odx-subtitle\">{{ user?.email_address }}</h5>\n </odx-area-header>\n <ng-content></ng-content>\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\">\n {{ signOutButtonText }}\n <odx-icon name=\"arrow-right\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n</odx-action-group>\n","import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { injectAuthModuleConfig } from './auth.config';\nimport { AuthService } from './auth.service';\n\n@Injectable()\nexport class AuthInterceptor implements HttpInterceptor {\n private readonly config = injectAuthModuleConfig();\n private readonly authService = inject(AuthService);\n\n public intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {\n return next.handle(this.addAuthHeader(request));\n }\n\n private addAuthHeader(request: HttpRequest<unknown>): HttpRequest<unknown> {\n if (!this.config.disallowedOrigins.find((origin) => !!request.url.match(origin))) {\n return request.clone({ setHeaders: this.authService.getAuthHeader() });\n }\n return request;\n }\n}\n","import { HTTP_INTERCEPTORS } from '@angular/common/http';\nimport { APP_INITIALIZER, inject, Provider } from '@angular/core';\nimport {} from '@angular/platform-browser';\nimport { Router } from '@angular/router';\nimport { WindowRef } from '@odx/angular';\nimport { buildUrl } from '@odx/angular/utils';\nimport { OktaCallbackComponent, OktaConfig, OKTA_CONFIG } from '@okta/okta-angular';\nimport { OktaAuth } from '@okta/okta-auth-js';\nimport { DEFAULT_AUTH_SCOPES, injectAuthModuleConfig } from './auth.config';\nimport { AuthInterceptor } from './auth.interceptor';\nimport { resolveIssuer } from './helpers';\n\nexport function registerAuthCallbackRoute(): () => void {\n const { redirectPath } = injectAuthModuleConfig();\n const router = inject(Router);\n\n return () => {\n router.config.unshift({ path: redirectPath, component: OktaCallbackComponent });\n };\n}\n\nexport function initalizeAuthConfig(): OktaConfig {\n const { clientId, scopes, redirectPath, environment, postLogoutRedirectPath, issuerOverride } = injectAuthModuleConfig();\n const origin = inject(WindowRef).getOrigin();\n const postLogoutRedirectUri = postLogoutRedirectPath ? buildUrl(origin, postLogoutRedirectPath) : undefined;\n\n return {\n oktaAuth: new OktaAuth({\n issuer: resolveIssuer(environment, issuerOverride),\n clientId,\n redirectUri: buildUrl(origin, redirectPath),\n scopes: Array.from(new Set(DEFAULT_AUTH_SCOPES.concat(scopes ?? []))),\n pkce: true,\n devMode: environment === 'dev',\n postLogoutRedirectUri,\n }),\n };\n}\n\nexport default [\n {\n provide: APP_INITIALIZER,\n useFactory: registerAuthCallbackRoute,\n multi: true,\n },\n {\n provide: OKTA_CONFIG,\n useFactory: initalizeAuthConfig,\n },\n {\n provide: HTTP_INTERCEPTORS,\n useClass: AuthInterceptor,\n multi: true,\n },\n] as Provider[];\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { ModuleConfigDependencies, ModuleConfigProvider, provideModuleConfig } from '@odx/angular/utils';\nimport { OktaAuthModule } from '@okta/okta-angular';\nimport { AuthComponent } from './auth.component';\nimport { AuthModuleConfig } from './auth.config';\nimport authProviders from './auth.providers';\nimport { SignInDirective, SignOutDirective } from './directives';\n\nconst modules = [AuthComponent, SignInDirective, SignOutDirective];\n\n@NgModule({\n imports: [...modules],\n exports: [OktaAuthModule, ...modules],\n})\nexport class AuthModule {\n public static forRoot<D extends ModuleConfigDependencies>(config: ModuleConfigProvider<Partial<AuthModuleConfig>, D>): ModuleWithProviders<AuthModule> {\n return {\n ngModule: AuthModule,\n providers: [provideModuleConfig(AuthModuleConfig, config), ...authProviders],\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;MAKa,mBAAmB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE;AAWlD,MAAM,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,CAAC,MAAM,EAAE,WAAW,EAAE;AACjI,IAAA,WAAW,EAAE,MAAM;AACnB,IAAA,YAAY,EAAE,gBAAgB;AAC9B,IAAA,iBAAiB,EAAE,EAAE;AACF,CAAA;;MCdR,WAAW,CAAA;AADxB,IAAA,WAAA,GAAA;AAEmB,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AACzB,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAE1C,QAAA,IAAA,CAAA,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAC/D,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC,eAAe,CAAC,EAC/C,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAChC,CAAC;QACc,IAAA,CAAA,KAAK,GAA4B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAC7E,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,eAAK,OAAA,CAAA,EAAA,GAAA,OAAO,KAAP,IAAA,IAAA,OAAO,uBAAP,OAAO,CAAE,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,IAAI,CAAA,EAAA,CAAC,EAC7C,WAAW,CAAC,EAAE,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,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;AACrB,oBAAA,OAAO,EAAE,CAAC,cAAc,EAAE,GAAG,OAAO,CAAC;iBACtC,CAAA;;;ACbD;;AAEG;;;;"}
@@ -0,0 +1,273 @@
1
+ import { OKTA_AUTH, OktaAuthStateService, OktaCallbackComponent, OKTA_CONFIG, OktaAuthModule } from '@okta/okta-angular';
2
+ export { OktaAuthGuard as AuthGuard } from '@okta/okta-angular';
3
+ import { __decorate, __metadata } from 'tslib';
4
+ import * as i0 from '@angular/core';
5
+ import { inject, Injectable, EventEmitter, Directive, Output, HostListener, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, APP_INITIALIZER, NgModule } from '@angular/core';
6
+ import * as i2 from '@odx/angular';
7
+ import { CoreModule, WindowRef } from '@odx/angular';
8
+ import * as i3 from '@odx/angular/components/area-header';
9
+ import { AreaHeaderModule } from '@odx/angular/components/area-header';
10
+ import * as i8 from '@odx/angular/components/dropdown';
11
+ import { DropdownModule } from '@odx/angular/components/dropdown';
12
+ import * as i9 from '@odx/angular/components/header';
13
+ import { HeaderModule } from '@odx/angular/components/header';
14
+ import { LogoDirective } from '@odx/angular/components/logo';
15
+ import { createModuleConfigTokens, Pure, buildUrl, provideModuleConfig } from '@odx/angular/utils';
16
+ import { map, shareReplay } from 'rxjs';
17
+ import * as i1 from '@odx/angular/components/loading-spinner';
18
+ import { LoadingSpinnerDirective } from '@odx/angular/components/loading-spinner';
19
+ import * as i1$1 from '@angular/common';
20
+ import * as i4 from '@odx/angular/components/avatar';
21
+ import * as i5 from '@odx/angular/components/action-group';
22
+ import * as i6 from '@odx/angular/components/button';
23
+ import * as i7 from '@odx/angular/components/icon';
24
+ import { HTTP_INTERCEPTORS } from '@angular/common/http';
25
+ import { Router } from '@angular/router';
26
+ import { OktaAuth } from '@okta/okta-auth-js';
27
+
28
+ const DEFAULT_AUTH_SCOPES = ['openid', 'profile'];
29
+ const { AuthDefaultModuleConfig, AuthModuleConfig, injectAuthModuleConfig } = createModuleConfigTokens('Auth', '@odx/auth', {
30
+ environment: 'prod',
31
+ redirectPath: 'login/callback',
32
+ disallowedOrigins: [],
33
+ });
34
+
35
+ class AuthService {
36
+ constructor() {
37
+ this.auth = inject(OKTA_AUTH);
38
+ this.authState = inject(OktaAuthStateService);
39
+ this.isAuthenticated$ = this.authState.authState$.pipe(map(({ isAuthenticated }) => !!isAuthenticated), shareReplay({ refCount: true }));
40
+ this.user$ = this.authState.authState$.pipe(map(({ idToken }) => idToken?.claims ?? null), shareReplay({ refCount: true }));
41
+ }
42
+ async signIn() {
43
+ await this.auth.signInWithRedirect();
44
+ }
45
+ async signOut() {
46
+ await this.auth.signOut();
47
+ }
48
+ getAccessToken() {
49
+ return this.auth.getAccessToken() ?? null;
50
+ }
51
+ getRefreshToken() {
52
+ return this.auth.getRefreshToken() ?? null;
53
+ }
54
+ getAuthHeader() {
55
+ return { Authorization: `Bearer ${this.getAccessToken()}` };
56
+ }
57
+ hasAnyGroups$(groups) {
58
+ return this.authState.hasAnyGroups(groups);
59
+ }
60
+ }
61
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
62
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, providedIn: 'root' });
63
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthService, decorators: [{
64
+ type: Injectable,
65
+ args: [{ providedIn: 'root' }]
66
+ }] });
67
+
68
+ class SignInDirective {
69
+ constructor() {
70
+ this.authService = inject(AuthService);
71
+ this.loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });
72
+ // eslint-disable-next-line @angular-eslint/no-output-rename
73
+ this.afterSignIn = new EventEmitter();
74
+ }
75
+ ngOnInit() {
76
+ this.loadingSpinnerDirective.autoColor = true;
77
+ }
78
+ async signIn() {
79
+ this.loadingSpinnerDirective.isLoading = true;
80
+ await this.authService.signIn();
81
+ this.afterSignIn.emit();
82
+ }
83
+ }
84
+ SignInDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignInDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
85
+ SignInDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: SignInDirective, isStandalone: true, selector: "[odxButton][odxAuthSignIn]", outputs: { afterSignIn: "odxAuthSignIn" }, host: { listeners: { "click": "signIn()" } }, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
86
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignInDirective, decorators: [{
87
+ type: Directive,
88
+ args: [{
89
+ standalone: true,
90
+ selector: '[odxButton][odxAuthSignIn]',
91
+ hostDirectives: [LoadingSpinnerDirective],
92
+ }]
93
+ }], propDecorators: { afterSignIn: [{
94
+ type: Output,
95
+ args: ['odxAuthSignIn']
96
+ }], signIn: [{
97
+ type: HostListener,
98
+ args: ['click']
99
+ }] } });
100
+
101
+ class SignOutDirective {
102
+ constructor() {
103
+ this.authService = inject(AuthService);
104
+ this.loadingSpinnerDirective = inject(LoadingSpinnerDirective, { self: true });
105
+ // eslint-disable-next-line @angular-eslint/no-output-rename
106
+ this.afterSignOut = new EventEmitter();
107
+ }
108
+ ngOnInit() {
109
+ this.loadingSpinnerDirective.autoColor = true;
110
+ }
111
+ async signIn() {
112
+ this.loadingSpinnerDirective.isLoading = true;
113
+ await this.authService.signOut();
114
+ this.afterSignOut.emit();
115
+ }
116
+ }
117
+ SignOutDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignOutDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
118
+ SignOutDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.0", type: SignOutDirective, isStandalone: true, selector: "[odxButton][odxAuthSignOut]", outputs: { afterSignOut: "odxAuthSignOut" }, host: { listeners: { "click": "signIn()" } }, hostDirectives: [{ directive: i1.LoadingSpinnerDirective }], ngImport: i0 });
119
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: SignOutDirective, decorators: [{
120
+ type: Directive,
121
+ args: [{
122
+ standalone: true,
123
+ selector: '[odxButton][odxAuthSignOut]',
124
+ hostDirectives: [LoadingSpinnerDirective],
125
+ }]
126
+ }], propDecorators: { afterSignOut: [{
127
+ type: Output,
128
+ args: ['odxAuthSignOut']
129
+ }], signIn: [{
130
+ type: HostListener,
131
+ args: ['click']
132
+ }] } });
133
+
134
+ function getUserInitials(user) {
135
+ if (!user?.name)
136
+ return '';
137
+ const names = user.name.trim().split(' ');
138
+ return names.reduce((initials, curr, index) => {
139
+ if (index === 0 || index === names.length - 1) {
140
+ initials = `${initials}${curr.charAt(0).toUpperCase()}`;
141
+ }
142
+ return initials;
143
+ }, '');
144
+ }
145
+
146
+ function resolveIssuer(environment, issuerOverride) {
147
+ if (issuerOverride)
148
+ return issuerOverride;
149
+ switch (environment) {
150
+ case 'dev':
151
+ return 'https://dev.login.draeger.com/oauth2/default';
152
+ case 'stage':
153
+ return 'https://test.login.draeger.com/oauth2/default';
154
+ default:
155
+ return 'https://login.draeger.com/oauth2/default';
156
+ }
157
+ }
158
+
159
+ class AuthComponent {
160
+ constructor() {
161
+ this.config = injectAuthModuleConfig();
162
+ this.authService = inject(AuthService);
163
+ this.signInButtonText = 'Sign in';
164
+ this.signOutButtonText = 'Sign out';
165
+ }
166
+ getInitials(user) {
167
+ return getUserInitials(user);
168
+ }
169
+ }
170
+ AuthComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
171
+ AuthComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.0", type: AuthComponent, isStandalone: true, selector: "odx-auth", inputs: { signInButtonText: "signInButtonText", signOutButtonText: "signOutButtonText" }, ngImport: i0, template: "<odx-action-group *odxLet=\"authService.user$ | async as user\">\n <ng-template [ngIf]=\"authService.isAuthenticated$ | async\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton odxHeaderAvatar [odxDropdown]=\"userProfileMenu\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n </button>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"primary\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ signInButtonText }}\n </button>\n </ng-template>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n <h2 class=\"odx-title\">{{ user?.name }}</h2>\n <h5 class=\"odx-subtitle\">{{ user?.email_address }}</h5>\n </odx-area-header>\n <ng-content></ng-content>\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\">\n {{ signOutButtonText }}\n <odx-icon name=\"arrow-right\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n</odx-action-group>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1$1.AsyncPipe, name: "async" }, { kind: "directive", type: i2.LetDirective, selector: "ng-template[odxLet]", inputs: ["odxLet"] }, { kind: "ngmodule", type: AreaHeaderModule }, { kind: "component", type: i3.AreaHeaderComponent, selector: "odx-area-header", inputs: ["size"] }, { 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: i7.IconComponent, selector: "odx-icon", inputs: ["inline", "size", "name"] }, { kind: "ngmodule", type: DropdownModule }, { kind: "directive", type: i8.DropdownDirective, selector: "[odxDropdown]", inputs: ["odxDropdown", "odxDropdownDisabled", "odxDropdownShowLoader", "odxDropdownOptions", "odxDropdownReferenceElement", "odxDropdownTriggerElement", "odxDropdownHost", "odxDropdownOpenTrigger", "odxDropdownCloseTrigger"], outputs: ["odxDropdownBeforeOpen", "odxDropdownAfterOpen", "odxDropdownBeforeClose", "odxDropdownAfterClose"], exportAs: ["odxDropdown"] }, { kind: "ngmodule", type: HeaderModule }, { kind: "directive", type: i9.HeaderAvatarDirective, selector: "button[odxButton][odxHeaderAvatar]" }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
172
+ __decorate([
173
+ Pure,
174
+ __metadata("design:type", Function),
175
+ __metadata("design:paramtypes", [Object]),
176
+ __metadata("design:returntype", String)
177
+ ], AuthComponent.prototype, "getInitials", null);
178
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthComponent, decorators: [{
179
+ type: Component,
180
+ args: [{ standalone: true, selector: 'odx-auth', imports: [CoreModule, AreaHeaderModule, DropdownModule, HeaderModule, LogoDirective, SignInDirective, SignOutDirective], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<odx-action-group *odxLet=\"authService.user$ | async as user\">\n <ng-template [ngIf]=\"authService.isAuthenticated$ | async\" [ngIfElse]=\"notAuthenticated\">\n <button odxButton odxHeaderAvatar [odxDropdown]=\"userProfileMenu\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n </button>\n </ng-template>\n <ng-template #notAuthenticated>\n <button class=\"odx-auth-sign-in\" odxButton odxAuthSignIn variant=\"primary\">\n <odx-icon name=\"user\" alignLeft></odx-icon>\n {{ signInButtonText }}\n </button>\n </ng-template>\n <ng-template #userProfileMenu>\n <odx-area-header class=\"odx-padding-x-12\" size=\"small\">\n <odx-avatar>\n {{ getInitials(user) }}\n </odx-avatar>\n <h2 class=\"odx-title\">{{ user?.name }}</h2>\n <h5 class=\"odx-subtitle\">{{ user?.email_address }}</h5>\n </odx-area-header>\n <ng-content></ng-content>\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\">\n {{ signOutButtonText }}\n <odx-icon name=\"arrow-right\" alignRight></odx-icon>\n </button>\n </div>\n </ng-template>\n</odx-action-group>\n" }]
181
+ }], propDecorators: { signInButtonText: [{
182
+ type: Input
183
+ }], signOutButtonText: [{
184
+ type: Input
185
+ }], getInitials: [] } });
186
+
187
+ class AuthInterceptor {
188
+ constructor() {
189
+ this.config = injectAuthModuleConfig();
190
+ this.authService = inject(AuthService);
191
+ }
192
+ intercept(request, next) {
193
+ return next.handle(this.addAuthHeader(request));
194
+ }
195
+ addAuthHeader(request) {
196
+ if (!this.config.disallowedOrigins.find((origin) => !!request.url.match(origin))) {
197
+ return request.clone({ setHeaders: this.authService.getAuthHeader() });
198
+ }
199
+ return request;
200
+ }
201
+ }
202
+ AuthInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
203
+ AuthInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor });
204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthInterceptor, decorators: [{
205
+ type: Injectable
206
+ }] });
207
+
208
+ function registerAuthCallbackRoute() {
209
+ const { redirectPath } = injectAuthModuleConfig();
210
+ const router = inject(Router);
211
+ return () => {
212
+ router.config.unshift({ path: redirectPath, component: OktaCallbackComponent });
213
+ };
214
+ }
215
+ function initalizeAuthConfig() {
216
+ const { clientId, scopes, redirectPath, environment, postLogoutRedirectPath, issuerOverride } = injectAuthModuleConfig();
217
+ const origin = inject(WindowRef).getOrigin();
218
+ const postLogoutRedirectUri = postLogoutRedirectPath ? buildUrl(origin, postLogoutRedirectPath) : undefined;
219
+ return {
220
+ oktaAuth: new OktaAuth({
221
+ issuer: resolveIssuer(environment, issuerOverride),
222
+ clientId,
223
+ redirectUri: buildUrl(origin, redirectPath),
224
+ scopes: Array.from(new Set(DEFAULT_AUTH_SCOPES.concat(scopes ?? []))),
225
+ pkce: true,
226
+ devMode: environment === 'dev',
227
+ postLogoutRedirectUri,
228
+ }),
229
+ };
230
+ }
231
+ var authProviders = [
232
+ {
233
+ provide: APP_INITIALIZER,
234
+ useFactory: registerAuthCallbackRoute,
235
+ multi: true,
236
+ },
237
+ {
238
+ provide: OKTA_CONFIG,
239
+ useFactory: initalizeAuthConfig,
240
+ },
241
+ {
242
+ provide: HTTP_INTERCEPTORS,
243
+ useClass: AuthInterceptor,
244
+ multi: true,
245
+ },
246
+ ];
247
+
248
+ const modules = [AuthComponent, SignInDirective, SignOutDirective];
249
+ class AuthModule {
250
+ static forRoot(config) {
251
+ return {
252
+ ngModule: AuthModule,
253
+ providers: [provideModuleConfig(AuthModuleConfig, config), ...authProviders],
254
+ };
255
+ }
256
+ }
257
+ AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
258
+ AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, imports: [AuthComponent, SignInDirective, SignOutDirective], exports: [OktaAuthModule, AuthComponent, SignInDirective, SignOutDirective] });
259
+ AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, imports: [AuthComponent, OktaAuthModule] });
260
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.0", ngImport: i0, type: AuthModule, decorators: [{
261
+ type: NgModule,
262
+ args: [{
263
+ imports: [...modules],
264
+ exports: [OktaAuthModule, ...modules],
265
+ }]
266
+ }] });
267
+
268
+ /**
269
+ * Generated bundle index. Do not edit.
270
+ */
271
+
272
+ export { AuthComponent, AuthDefaultModuleConfig, AuthInterceptor, AuthModule, AuthModuleConfig, AuthService, DEFAULT_AUTH_SCOPES, SignInDirective, SignOutDirective, getUserInitials, initalizeAuthConfig, injectAuthModuleConfig, registerAuthCallbackRoute, resolveIssuer };
273
+ //# sourceMappingURL=odx-auth.mjs.map