@thecla/b2c-angular 4.0.0 → 5.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/esm2020/lib/actions/auth.actions.mjs +10 -0
- package/{esm2015/lib/auth-config.js → esm2020/lib/auth-config.mjs} +0 -0
- package/esm2020/lib/auth.guard.mjs +29 -0
- package/esm2020/lib/auth.module.mjs +42 -0
- package/esm2020/lib/auth.service.mjs +68 -0
- package/esm2020/lib/effects/auth.effects.mjs +59 -0
- package/esm2020/lib/jwt.interceptor.mjs +32 -0
- package/esm2020/lib/reducers/auth.reducer.mjs +20 -0
- package/{esm2015/lib/state/auth.state.js → esm2020/lib/state/auth.state.mjs} +0 -0
- package/esm2020/lib/store/index.mjs +8 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/esm2020/thecla-b2c-angular.mjs +5 -0
- package/fesm2015/{thecla-b2c-angular.js → thecla-b2c-angular.mjs} +57 -65
- package/fesm2015/thecla-b2c-angular.mjs.map +1 -0
- package/fesm2020/thecla-b2c-angular.mjs +240 -0
- package/fesm2020/thecla-b2c-angular.mjs.map +1 -0
- package/lib/actions/auth.actions.d.ts +16 -12
- package/lib/auth.guard.d.ts +4 -1
- package/lib/auth.module.d.ts +6 -0
- package/lib/auth.service.d.ts +3 -0
- package/lib/effects/auth.effects.d.ts +19 -12
- package/lib/jwt.interceptor.d.ts +3 -0
- package/package.json +24 -12
- package/thecla-b2c-angular.d.ts +1 -7
- package/bundles/thecla-b2c-angular.umd.js +0 -603
- package/bundles/thecla-b2c-angular.umd.js.map +0 -1
- package/esm2015/lib/actions/auth.actions.js +0 -10
- package/esm2015/lib/auth.guard.js +0 -30
- package/esm2015/lib/auth.module.js +0 -35
- package/esm2015/lib/auth.service.js +0 -70
- package/esm2015/lib/effects/auth.effects.js +0 -58
- package/esm2015/lib/jwt.interceptor.js +0 -31
- package/esm2015/lib/reducers/auth.reducer.js +0 -21
- package/esm2015/lib/store/index.js +0 -11
- package/esm2015/thecla-b2c-angular.js +0 -12
- package/fesm2015/thecla-b2c-angular.js.map +0 -1
- package/thecla-b2c-angular.metadata.json +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thecla-b2c-angular.mjs","sources":["../../../projects/b2c-angular/src/lib/auth-config.ts","../../../projects/b2c-angular/src/lib/actions/auth.actions.ts","../../../projects/b2c-angular/src/lib/auth.service.ts","../../../projects/b2c-angular/src/lib/effects/auth.effects.ts","../../../projects/b2c-angular/src/lib/jwt.interceptor.ts","../../../projects/b2c-angular/src/lib/reducers/auth.reducer.ts","../../../projects/b2c-angular/src/lib/store/index.ts","../../../projects/b2c-angular/src/lib/auth.module.ts","../../../projects/b2c-angular/src/lib/auth.guard.ts","../../../projects/b2c-angular/src/thecla-b2c-angular.ts"],"sourcesContent":["export abstract class AuthConfig {\n public abstract clientId: string;\n public abstract authority: string;\n public abstract signInPolicy: string;\n public abstract resetPasswordPolicy: string;\n public abstract knownAuthorities: string[];\n public abstract scopes: string[];\n public abstract redirectUri?: string;\n}\n","import { createAction, props } from '@ngrx/store';\nimport { Profile } from '../state/auth.state';\n\nexport const signIn = createAction('[@thecla/b2c-angular] sign-in', props<{ returnUrl: string }>());\n\nexport const signInRedirected = createAction('[@thecla/b2c-angular] sign in redirected');\n\nexport const signInCompleted = createAction(\n '[@thecla/b2c-angular] sign in completed',\n props<{ state: { target: string; passwordReset: boolean }; user: Profile }>()\n);\n\nexport const signedIn = createAction('[@thecla/b2c-angular] signed in', props<{ user: Profile }>());\n\nexport const signInFailed = createAction('[@thecla/b2c-angular] sign in failed', props<{ error: Error }>());\n\nexport const signOut = createAction('[@thecla/b2c-angular] sign out');\n\nexport const signedOut = createAction('[@thecla/b2c-angular] signed out');\n\nexport const resetPassword = createAction('[@thecla/b2c-angular] reset password', props<{ returnUrl: string }>());\n","import { Injectable } from '@angular/core';\nimport {\n AuthenticationResult,\n Configuration,\n InteractionRequiredAuthError,\n PublicClientApplication,\n} from '@azure/msal-browser';\nimport { from, of, throwError } from 'rxjs';\nimport { catchError, filter, map } from 'rxjs/operators';\nimport { AuthConfig } from './auth-config';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n private readonly clientApplication: PublicClientApplication;\n\n public constructor(private readonly config: AuthConfig) {\n const msalConfig: Configuration = {\n auth: {\n clientId: config.clientId,\n authority: `${config.authority}/${config.signInPolicy}`,\n knownAuthorities: config.knownAuthorities,\n redirectUri: config.redirectUri ?? location.origin,\n },\n };\n\n this.clientApplication = new PublicClientApplication(msalConfig);\n }\n\n public loginWithRedirect(state: { target: string }) {\n return from(\n this.clientApplication.loginRedirect({\n scopes: this.config.scopes,\n state: JSON.stringify({ ...state, passwordReset: false }),\n })\n );\n }\n\n public resetPasswordWithRedirect(state: { target: string }) {\n return from(\n this.clientApplication.loginRedirect({\n authority: `${this.config.authority}/${this.config.resetPasswordPolicy}`,\n scopes: this.config.scopes,\n state: JSON.stringify({ ...state, passwordReset: true }),\n prompt: 'login',\n })\n );\n }\n\n public handleRedirectCallback() {\n return from(this.clientApplication.handleRedirectPromise()).pipe(\n filter((result): result is AuthenticationResult => result !== null),\n map(result => ({\n state: result.state ? JSON.parse(result.state) : undefined,\n user: { sub: result.uniqueId, ...result.idTokenClaims },\n }))\n );\n }\n\n public getAccessToken() {\n const account = this.clientApplication.getAllAccounts()[0];\n const scopes = this.config.scopes;\n\n return from(this.clientApplication.acquireTokenSilent({ account, scopes })).pipe(map(result => result.accessToken));\n }\n\n public logout() {\n return from(this.clientApplication.logoutRedirect({ postLogoutRedirectUri: location.origin }));\n }\n\n public checkSession() {\n const accounts = this.clientApplication.getAllAccounts();\n const scopes = this.config.scopes;\n\n if (accounts.length === 1) {\n return from(this.clientApplication.acquireTokenSilent({ account: accounts[0], scopes })).pipe(\n map(result => ({ sub: result.uniqueId, ...result.idTokenClaims })),\n catchError(error => (error instanceof InteractionRequiredAuthError ? of(undefined) : throwError(error)))\n );\n } else {\n return of(undefined);\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { AuthError, BrowserAuthErrorMessage } from '@azure/msal-browser';\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { asyncScheduler, of, SchedulerLike } from 'rxjs';\nimport { catchError, filter, map, observeOn, switchMap, tap } from 'rxjs/operators';\nimport {\n resetPassword,\n signedIn,\n signedOut,\n signIn,\n signInCompleted,\n signInFailed,\n signInRedirected,\n signOut,\n} from '../actions/auth.actions';\nimport { AuthService } from '../auth.service';\n\n@Injectable()\nexport class AuthEffects {\n public readonly signIn$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signIn),\n switchMap(action =>\n this.auth.loginWithRedirect({ target: action.returnUrl }).pipe(\n map(() => signInRedirected()),\n catchError(error => of(signInFailed({ error })))\n )\n )\n )\n );\n\n public readonly passwordReset$ = createEffect(() =>\n this.actions$.pipe(\n ofType(resetPassword),\n switchMap(action =>\n this.auth.resetPasswordWithRedirect({ target: action.returnUrl }).pipe(\n map(() => signInRedirected()),\n catchError(error => of(signInFailed({ error })))\n )\n )\n )\n );\n\n public readonly signInCompleted$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInCompleted),\n map(({ state, user }) => (state.passwordReset ? signOut() : signedIn({ user })))\n )\n );\n\n public readonly redirect$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(signInCompleted),\n switchMap(action => this.router.navigateByUrl(action.state.target, { replaceUrl: true }))\n ),\n { dispatch: false }\n );\n\n public readonly signOut$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signOut),\n switchMap(_ =>\n this.auth.logout().pipe(\n map(() => signedOut()),\n catchError(() => of(signedOut()))\n )\n )\n )\n );\n\n public readonly init$ = createEffect(() => ({ scheduler = asyncScheduler } = {}) => {\n const params = window.location.hash;\n\n if (\n (params.includes('code=') && params.includes('state=')) ||\n (params.includes('error=') && params.includes('error_description='))\n ) {\n return this.completeSignIn(scheduler);\n } else {\n return this.auth.checkSession().pipe(\n map(user => this.getAuthResult(user)),\n catchError(error => of(signInFailed({ error }))),\n observeOn(scheduler)\n );\n }\n });\n\n public readonly resetPassword$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInFailed),\n filter(action => action.error instanceof AuthError),\n map(action => action.error as AuthError),\n filter(AuthEffects.isForgotPasswordError),\n map(() => resetPassword({ returnUrl: '/' }))\n )\n );\n\n public readonly failed$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInFailed),\n filter(action => action.error instanceof AuthError),\n map(action => action.error as AuthError),\n filter(AuthEffects.isInteractionInProgress),\n map(() => signOut())\n )\n );\n\n public constructor(\n private readonly actions$: Actions,\n private readonly auth: AuthService,\n private readonly router: Router\n ) {}\n\n private static isForgotPasswordError(error: AuthError) {\n return error.errorCode === 'access_denied' && error.errorMessage.indexOf('AADB2C90118') !== -1;\n }\n\n private static isInteractionInProgress(error: AuthError) {\n return error.errorCode === BrowserAuthErrorMessage.interactionInProgress.code;\n }\n\n private getAuthResult(user: { sub: string } | undefined) {\n if (user) {\n return signedIn({ user });\n } else {\n return signedOut();\n }\n }\n\n private completeSignIn(scheduler: SchedulerLike) {\n return this.auth.handleRedirectCallback().pipe(\n map(result => signInCompleted({ state: result.state, user: result.user })),\n catchError(error => of(signInFailed({ error }))),\n observeOn(scheduler)\n );\n }\n}\n","import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { map, mergeMap } from 'rxjs/operators';\nimport { AuthService } from './auth.service';\n\n@Injectable()\nexport class JwtInterceptor implements HttpInterceptor {\n public constructor(private readonly auth: AuthService) {}\n\n public intercept(request: HttpRequest<any>, next: HttpHandler) {\n if (this.isSameDomain(request)) {\n return this.authorize(request).pipe(mergeMap(authorizedRequest => next.handle(authorizedRequest)));\n } else {\n return next.handle(request);\n }\n }\n\n private isSameDomain(request: HttpRequest<any>) {\n const isAbsolute = /^https?:\\/\\//i.test(request.url);\n\n return !isAbsolute;\n }\n\n private authorize(request: HttpRequest<any>) {\n const token$ = this.auth.getAccessToken();\n\n return token$.pipe(map(token => request.clone({ setHeaders: { Authorization: `Bearer ${token}` } })));\n }\n}\n","import { Action, createReducer, on } from '@ngrx/store';\nimport { signedIn, signedOut, signInFailed } from '../actions/auth.actions';\nimport { State } from '../state/auth.state';\n\nexport const noAuthentication: State = {\n authenticating: false,\n authenticated: false,\n};\n\nexport const startAuthentication: State = {\n authenticating: true,\n authenticated: false,\n};\n\nconst authReducer = createReducer(\n startAuthentication,\n on(signedIn, (state, { user }) => ({\n ...state,\n authenticating: false,\n authenticated: true,\n user,\n })),\n on(signedOut, _ => noAuthentication),\n on(signInFailed, _ => noAuthentication)\n);\n\nexport function reducer(state: State | undefined, action: Action) {\n return authReducer(state, action);\n}\n","import { createFeatureSelector, select } from '@ngrx/store';\nimport { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\nimport { State } from '../state/auth.state';\n\nexport const featureKey = 'auth';\n\nexport const selectState = createFeatureSelector<State>(featureKey);\n\nexport const isAuthenticated = pipe(\n select(selectState),\n filter(state => !state.authenticating),\n map(state => state.authenticated)\n);\n\nexport const getUser = pipe(\n select(selectState),\n filter(state => !state.authenticating),\n map(state => state.user)\n);\n","import { HTTP_INTERCEPTORS } from '@angular/common/http';\nimport { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EffectsModule } from '@ngrx/effects';\nimport { StoreModule } from '@ngrx/store';\nimport { AuthConfig } from './auth-config';\nimport { AuthEffects } from './effects/auth.effects';\nimport { JwtInterceptor } from './jwt.interceptor';\nimport { reducer } from './reducers/auth.reducer';\nimport { featureKey } from './store';\n\n@NgModule({\n declarations: [],\n imports: [StoreModule.forFeature(featureKey, reducer), EffectsModule.forFeature([AuthEffects])],\n exports: [],\n})\nexport class AuthModule {\n public static forRoot(config: AuthConfig): ModuleWithProviders<AuthModule> {\n return {\n ngModule: AuthModule,\n providers: [\n {\n provide: AuthConfig,\n useValue: config,\n },\n {\n provide: HTTP_INTERCEPTORS,\n useClass: JwtInterceptor,\n multi: true,\n },\n ],\n };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport { first, tap } from 'rxjs/operators';\nimport { signIn } from './actions/auth.actions';\nimport { isAuthenticated } from './store';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthGuard implements CanActivate {\n private readonly authenticated$ = this.store.pipe(isAuthenticated);\n\n public constructor(private readonly store: Store) {}\n\n public canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {\n return this.authenticated$.pipe(\n tap(auth => {\n if (!auth) {\n this.store.dispatch(signIn({ returnUrl: state.url }));\n }\n }),\n first()\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MAAsB,UAAU;;;MCGnB,MAAM,GAAG,YAAY,CAAC,+BAA+B,EAAE,KAAK,EAAyB,EAAE;AAE7F,MAAM,gBAAgB,GAAG,YAAY,CAAC,0CAA0C,CAAC,CAAC;AAElF,MAAM,eAAe,GAAG,YAAY,CACzC,yCAAyC,EACzC,KAAK,EAAwE,CAC9E,CAAC;MAEW,QAAQ,GAAG,YAAY,CAAC,iCAAiC,EAAE,KAAK,EAAqB,EAAE;AAE7F,MAAM,YAAY,GAAG,YAAY,CAAC,sCAAsC,EAAE,KAAK,EAAoB,CAAC,CAAC;MAE/F,OAAO,GAAG,YAAY,CAAC,gCAAgC,EAAE;MAEzD,SAAS,GAAG,YAAY,CAAC,kCAAkC,EAAE;AAEnE,MAAM,aAAa,GAAG,YAAY,CAAC,sCAAsC,EAAE,KAAK,EAAyB,CAAC;;MCNpG,WAAW;IAGtB,YAAoC,MAAkB;;QAAlB,WAAM,GAAN,MAAM,CAAY;QACpD,MAAM,UAAU,GAAkB;YAChC,IAAI,EAAE;gBACJ,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,SAAS,EAAE,GAA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|
+
import * as i1 from '@ngrx/effects';
|
|
5
|
+
import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
6
|
+
import * as i1$1 from '@ngrx/store';
|
|
7
|
+
import { createAction, props, createReducer, on, createFeatureSelector, select, StoreModule } from '@ngrx/store';
|
|
8
|
+
import * as i3 from '@angular/router';
|
|
9
|
+
import { PublicClientApplication, InteractionRequiredAuthError, AuthError, BrowserAuthErrorMessage } from '@azure/msal-browser';
|
|
10
|
+
import { from, of, throwError, asyncScheduler, pipe } from 'rxjs';
|
|
11
|
+
import { filter, map, catchError, switchMap, observeOn, mergeMap, tap, first } from 'rxjs/operators';
|
|
12
|
+
|
|
13
|
+
class AuthConfig {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const signIn = createAction('[@thecla/b2c-angular] sign-in', props());
|
|
17
|
+
const signInRedirected = createAction('[@thecla/b2c-angular] sign in redirected');
|
|
18
|
+
const signInCompleted = createAction('[@thecla/b2c-angular] sign in completed', props());
|
|
19
|
+
const signedIn = createAction('[@thecla/b2c-angular] signed in', props());
|
|
20
|
+
const signInFailed = createAction('[@thecla/b2c-angular] sign in failed', props());
|
|
21
|
+
const signOut = createAction('[@thecla/b2c-angular] sign out');
|
|
22
|
+
const signedOut = createAction('[@thecla/b2c-angular] signed out');
|
|
23
|
+
const resetPassword = createAction('[@thecla/b2c-angular] reset password', props());
|
|
24
|
+
|
|
25
|
+
class AuthService {
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.config = config;
|
|
28
|
+
const msalConfig = {
|
|
29
|
+
auth: {
|
|
30
|
+
clientId: config.clientId,
|
|
31
|
+
authority: `${config.authority}/${config.signInPolicy}`,
|
|
32
|
+
knownAuthorities: config.knownAuthorities,
|
|
33
|
+
redirectUri: config.redirectUri ?? location.origin,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
this.clientApplication = new PublicClientApplication(msalConfig);
|
|
37
|
+
}
|
|
38
|
+
loginWithRedirect(state) {
|
|
39
|
+
return from(this.clientApplication.loginRedirect({
|
|
40
|
+
scopes: this.config.scopes,
|
|
41
|
+
state: JSON.stringify({ ...state, passwordReset: false }),
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
resetPasswordWithRedirect(state) {
|
|
45
|
+
return from(this.clientApplication.loginRedirect({
|
|
46
|
+
authority: `${this.config.authority}/${this.config.resetPasswordPolicy}`,
|
|
47
|
+
scopes: this.config.scopes,
|
|
48
|
+
state: JSON.stringify({ ...state, passwordReset: true }),
|
|
49
|
+
prompt: 'login',
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
handleRedirectCallback() {
|
|
53
|
+
return from(this.clientApplication.handleRedirectPromise()).pipe(filter((result) => result !== null), map(result => ({
|
|
54
|
+
state: result.state ? JSON.parse(result.state) : undefined,
|
|
55
|
+
user: { sub: result.uniqueId, ...result.idTokenClaims },
|
|
56
|
+
})));
|
|
57
|
+
}
|
|
58
|
+
getAccessToken() {
|
|
59
|
+
const account = this.clientApplication.getAllAccounts()[0];
|
|
60
|
+
const scopes = this.config.scopes;
|
|
61
|
+
return from(this.clientApplication.acquireTokenSilent({ account, scopes })).pipe(map(result => result.accessToken));
|
|
62
|
+
}
|
|
63
|
+
logout() {
|
|
64
|
+
return from(this.clientApplication.logoutRedirect({ postLogoutRedirectUri: location.origin }));
|
|
65
|
+
}
|
|
66
|
+
checkSession() {
|
|
67
|
+
const accounts = this.clientApplication.getAllAccounts();
|
|
68
|
+
const scopes = this.config.scopes;
|
|
69
|
+
if (accounts.length === 1) {
|
|
70
|
+
return from(this.clientApplication.acquireTokenSilent({ account: accounts[0], scopes })).pipe(map(result => ({ sub: result.uniqueId, ...result.idTokenClaims })), catchError(error => (error instanceof InteractionRequiredAuthError ? of(undefined) : throwError(error))));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return of(undefined);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, deps: [{ token: AuthConfig }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
79
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthService, decorators: [{
|
|
80
|
+
type: Injectable,
|
|
81
|
+
args: [{
|
|
82
|
+
providedIn: 'root',
|
|
83
|
+
}]
|
|
84
|
+
}], ctorParameters: function () { return [{ type: AuthConfig }]; } });
|
|
85
|
+
|
|
86
|
+
class AuthEffects {
|
|
87
|
+
constructor(actions$, auth, router) {
|
|
88
|
+
this.actions$ = actions$;
|
|
89
|
+
this.auth = auth;
|
|
90
|
+
this.router = router;
|
|
91
|
+
this.signIn$ = createEffect(() => this.actions$.pipe(ofType(signIn), switchMap(action => this.auth.loginWithRedirect({ target: action.returnUrl }).pipe(map(() => signInRedirected()), catchError(error => of(signInFailed({ error })))))));
|
|
92
|
+
this.passwordReset$ = createEffect(() => this.actions$.pipe(ofType(resetPassword), switchMap(action => this.auth.resetPasswordWithRedirect({ target: action.returnUrl }).pipe(map(() => signInRedirected()), catchError(error => of(signInFailed({ error })))))));
|
|
93
|
+
this.signInCompleted$ = createEffect(() => this.actions$.pipe(ofType(signInCompleted), map(({ state, user }) => (state.passwordReset ? signOut() : signedIn({ user })))));
|
|
94
|
+
this.redirect$ = createEffect(() => this.actions$.pipe(ofType(signInCompleted), switchMap(action => this.router.navigateByUrl(action.state.target, { replaceUrl: true }))), { dispatch: false });
|
|
95
|
+
this.signOut$ = createEffect(() => this.actions$.pipe(ofType(signOut), switchMap(_ => this.auth.logout().pipe(map(() => signedOut()), catchError(() => of(signedOut()))))));
|
|
96
|
+
this.init$ = createEffect(() => ({ scheduler = asyncScheduler } = {}) => {
|
|
97
|
+
const params = window.location.hash;
|
|
98
|
+
if ((params.includes('code=') && params.includes('state=')) ||
|
|
99
|
+
(params.includes('error=') && params.includes('error_description='))) {
|
|
100
|
+
return this.completeSignIn(scheduler);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return this.auth.checkSession().pipe(map(user => this.getAuthResult(user)), catchError(error => of(signInFailed({ error }))), observeOn(scheduler));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
this.resetPassword$ = createEffect(() => this.actions$.pipe(ofType(signInFailed), filter(action => action.error instanceof AuthError), map(action => action.error), filter(AuthEffects.isForgotPasswordError), map(() => resetPassword({ returnUrl: '/' }))));
|
|
107
|
+
this.failed$ = createEffect(() => this.actions$.pipe(ofType(signInFailed), filter(action => action.error instanceof AuthError), map(action => action.error), filter(AuthEffects.isInteractionInProgress), map(() => signOut())));
|
|
108
|
+
}
|
|
109
|
+
static isForgotPasswordError(error) {
|
|
110
|
+
return error.errorCode === 'access_denied' && error.errorMessage.indexOf('AADB2C90118') !== -1;
|
|
111
|
+
}
|
|
112
|
+
static isInteractionInProgress(error) {
|
|
113
|
+
return error.errorCode === BrowserAuthErrorMessage.interactionInProgress.code;
|
|
114
|
+
}
|
|
115
|
+
getAuthResult(user) {
|
|
116
|
+
if (user) {
|
|
117
|
+
return signedIn({ user });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
return signedOut();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
completeSignIn(scheduler) {
|
|
124
|
+
return this.auth.handleRedirectCallback().pipe(map(result => signInCompleted({ state: result.state, user: result.user })), catchError(error => of(signInFailed({ error }))), observeOn(scheduler));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
AuthEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthEffects, deps: [{ token: i1.Actions }, { token: AuthService }, { token: i3.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
128
|
+
AuthEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthEffects });
|
|
129
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthEffects, decorators: [{
|
|
130
|
+
type: Injectable
|
|
131
|
+
}], ctorParameters: function () { return [{ type: i1.Actions }, { type: AuthService }, { type: i3.Router }]; } });
|
|
132
|
+
|
|
133
|
+
class JwtInterceptor {
|
|
134
|
+
constructor(auth) {
|
|
135
|
+
this.auth = auth;
|
|
136
|
+
}
|
|
137
|
+
intercept(request, next) {
|
|
138
|
+
if (this.isSameDomain(request)) {
|
|
139
|
+
return this.authorize(request).pipe(mergeMap(authorizedRequest => next.handle(authorizedRequest)));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return next.handle(request);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
isSameDomain(request) {
|
|
146
|
+
const isAbsolute = /^https?:\/\//i.test(request.url);
|
|
147
|
+
return !isAbsolute;
|
|
148
|
+
}
|
|
149
|
+
authorize(request) {
|
|
150
|
+
const token$ = this.auth.getAccessToken();
|
|
151
|
+
return token$.pipe(map(token => request.clone({ setHeaders: { Authorization: `Bearer ${token}` } })));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
JwtInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: JwtInterceptor, deps: [{ token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
155
|
+
JwtInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: JwtInterceptor });
|
|
156
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: JwtInterceptor, decorators: [{
|
|
157
|
+
type: Injectable
|
|
158
|
+
}], ctorParameters: function () { return [{ type: AuthService }]; } });
|
|
159
|
+
|
|
160
|
+
const noAuthentication = {
|
|
161
|
+
authenticating: false,
|
|
162
|
+
authenticated: false,
|
|
163
|
+
};
|
|
164
|
+
const startAuthentication = {
|
|
165
|
+
authenticating: true,
|
|
166
|
+
authenticated: false,
|
|
167
|
+
};
|
|
168
|
+
const authReducer = createReducer(startAuthentication, on(signedIn, (state, { user }) => ({
|
|
169
|
+
...state,
|
|
170
|
+
authenticating: false,
|
|
171
|
+
authenticated: true,
|
|
172
|
+
user,
|
|
173
|
+
})), on(signedOut, _ => noAuthentication), on(signInFailed, _ => noAuthentication));
|
|
174
|
+
function reducer(state, action) {
|
|
175
|
+
return authReducer(state, action);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const featureKey = 'auth';
|
|
179
|
+
const selectState = createFeatureSelector(featureKey);
|
|
180
|
+
const isAuthenticated = pipe(select(selectState), filter(state => !state.authenticating), map(state => state.authenticated));
|
|
181
|
+
const getUser = pipe(select(selectState), filter(state => !state.authenticating), map(state => state.user));
|
|
182
|
+
|
|
183
|
+
class AuthModule {
|
|
184
|
+
static forRoot(config) {
|
|
185
|
+
return {
|
|
186
|
+
ngModule: AuthModule,
|
|
187
|
+
providers: [
|
|
188
|
+
{
|
|
189
|
+
provide: AuthConfig,
|
|
190
|
+
useValue: config,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
provide: HTTP_INTERCEPTORS,
|
|
194
|
+
useClass: JwtInterceptor,
|
|
195
|
+
multi: true,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
AuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
202
|
+
AuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthModule, imports: [i1$1.StoreFeatureModule, i1.EffectsFeatureModule] });
|
|
203
|
+
AuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthModule, imports: [[StoreModule.forFeature(featureKey, reducer), EffectsModule.forFeature([AuthEffects])]] });
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthModule, decorators: [{
|
|
205
|
+
type: NgModule,
|
|
206
|
+
args: [{
|
|
207
|
+
declarations: [],
|
|
208
|
+
imports: [StoreModule.forFeature(featureKey, reducer), EffectsModule.forFeature([AuthEffects])],
|
|
209
|
+
exports: [],
|
|
210
|
+
}]
|
|
211
|
+
}] });
|
|
212
|
+
|
|
213
|
+
class AuthGuard {
|
|
214
|
+
constructor(store) {
|
|
215
|
+
this.store = store;
|
|
216
|
+
this.authenticated$ = this.store.pipe(isAuthenticated);
|
|
217
|
+
}
|
|
218
|
+
canActivate(next, state) {
|
|
219
|
+
return this.authenticated$.pipe(tap(auth => {
|
|
220
|
+
if (!auth) {
|
|
221
|
+
this.store.dispatch(signIn({ returnUrl: state.url }));
|
|
222
|
+
}
|
|
223
|
+
}), first());
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
227
|
+
AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthGuard, providedIn: 'root' });
|
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: AuthGuard, decorators: [{
|
|
229
|
+
type: Injectable,
|
|
230
|
+
args: [{
|
|
231
|
+
providedIn: 'root',
|
|
232
|
+
}]
|
|
233
|
+
}], ctorParameters: function () { return [{ type: i1$1.Store }]; } });
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Generated bundle index. Do not edit.
|
|
237
|
+
*/
|
|
238
|
+
|
|
239
|
+
export { AuthGuard, AuthModule, getUser, isAuthenticated, signIn, signOut, signedIn, signedOut };
|
|
240
|
+
//# sourceMappingURL=thecla-b2c-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thecla-b2c-angular.mjs","sources":["../../../projects/b2c-angular/src/lib/auth-config.ts","../../../projects/b2c-angular/src/lib/actions/auth.actions.ts","../../../projects/b2c-angular/src/lib/auth.service.ts","../../../projects/b2c-angular/src/lib/effects/auth.effects.ts","../../../projects/b2c-angular/src/lib/jwt.interceptor.ts","../../../projects/b2c-angular/src/lib/reducers/auth.reducer.ts","../../../projects/b2c-angular/src/lib/store/index.ts","../../../projects/b2c-angular/src/lib/auth.module.ts","../../../projects/b2c-angular/src/lib/auth.guard.ts","../../../projects/b2c-angular/src/thecla-b2c-angular.ts"],"sourcesContent":["export abstract class AuthConfig {\n public abstract clientId: string;\n public abstract authority: string;\n public abstract signInPolicy: string;\n public abstract resetPasswordPolicy: string;\n public abstract knownAuthorities: string[];\n public abstract scopes: string[];\n public abstract redirectUri?: string;\n}\n","import { createAction, props } from '@ngrx/store';\nimport { Profile } from '../state/auth.state';\n\nexport const signIn = createAction('[@thecla/b2c-angular] sign-in', props<{ returnUrl: string }>());\n\nexport const signInRedirected = createAction('[@thecla/b2c-angular] sign in redirected');\n\nexport const signInCompleted = createAction(\n '[@thecla/b2c-angular] sign in completed',\n props<{ state: { target: string; passwordReset: boolean }; user: Profile }>()\n);\n\nexport const signedIn = createAction('[@thecla/b2c-angular] signed in', props<{ user: Profile }>());\n\nexport const signInFailed = createAction('[@thecla/b2c-angular] sign in failed', props<{ error: Error }>());\n\nexport const signOut = createAction('[@thecla/b2c-angular] sign out');\n\nexport const signedOut = createAction('[@thecla/b2c-angular] signed out');\n\nexport const resetPassword = createAction('[@thecla/b2c-angular] reset password', props<{ returnUrl: string }>());\n","import { Injectable } from '@angular/core';\nimport {\n AuthenticationResult,\n Configuration,\n InteractionRequiredAuthError,\n PublicClientApplication,\n} from '@azure/msal-browser';\nimport { from, of, throwError } from 'rxjs';\nimport { catchError, filter, map } from 'rxjs/operators';\nimport { AuthConfig } from './auth-config';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n private readonly clientApplication: PublicClientApplication;\n\n public constructor(private readonly config: AuthConfig) {\n const msalConfig: Configuration = {\n auth: {\n clientId: config.clientId,\n authority: `${config.authority}/${config.signInPolicy}`,\n knownAuthorities: config.knownAuthorities,\n redirectUri: config.redirectUri ?? location.origin,\n },\n };\n\n this.clientApplication = new PublicClientApplication(msalConfig);\n }\n\n public loginWithRedirect(state: { target: string }) {\n return from(\n this.clientApplication.loginRedirect({\n scopes: this.config.scopes,\n state: JSON.stringify({ ...state, passwordReset: false }),\n })\n );\n }\n\n public resetPasswordWithRedirect(state: { target: string }) {\n return from(\n this.clientApplication.loginRedirect({\n authority: `${this.config.authority}/${this.config.resetPasswordPolicy}`,\n scopes: this.config.scopes,\n state: JSON.stringify({ ...state, passwordReset: true }),\n prompt: 'login',\n })\n );\n }\n\n public handleRedirectCallback() {\n return from(this.clientApplication.handleRedirectPromise()).pipe(\n filter((result): result is AuthenticationResult => result !== null),\n map(result => ({\n state: result.state ? JSON.parse(result.state) : undefined,\n user: { sub: result.uniqueId, ...result.idTokenClaims },\n }))\n );\n }\n\n public getAccessToken() {\n const account = this.clientApplication.getAllAccounts()[0];\n const scopes = this.config.scopes;\n\n return from(this.clientApplication.acquireTokenSilent({ account, scopes })).pipe(map(result => result.accessToken));\n }\n\n public logout() {\n return from(this.clientApplication.logoutRedirect({ postLogoutRedirectUri: location.origin }));\n }\n\n public checkSession() {\n const accounts = this.clientApplication.getAllAccounts();\n const scopes = this.config.scopes;\n\n if (accounts.length === 1) {\n return from(this.clientApplication.acquireTokenSilent({ account: accounts[0], scopes })).pipe(\n map(result => ({ sub: result.uniqueId, ...result.idTokenClaims })),\n catchError(error => (error instanceof InteractionRequiredAuthError ? of(undefined) : throwError(error)))\n );\n } else {\n return of(undefined);\n }\n }\n}\n","import { Injectable } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { AuthError, BrowserAuthErrorMessage } from '@azure/msal-browser';\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { asyncScheduler, of, SchedulerLike } from 'rxjs';\nimport { catchError, filter, map, observeOn, switchMap, tap } from 'rxjs/operators';\nimport {\n resetPassword,\n signedIn,\n signedOut,\n signIn,\n signInCompleted,\n signInFailed,\n signInRedirected,\n signOut,\n} from '../actions/auth.actions';\nimport { AuthService } from '../auth.service';\n\n@Injectable()\nexport class AuthEffects {\n public readonly signIn$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signIn),\n switchMap(action =>\n this.auth.loginWithRedirect({ target: action.returnUrl }).pipe(\n map(() => signInRedirected()),\n catchError(error => of(signInFailed({ error })))\n )\n )\n )\n );\n\n public readonly passwordReset$ = createEffect(() =>\n this.actions$.pipe(\n ofType(resetPassword),\n switchMap(action =>\n this.auth.resetPasswordWithRedirect({ target: action.returnUrl }).pipe(\n map(() => signInRedirected()),\n catchError(error => of(signInFailed({ error })))\n )\n )\n )\n );\n\n public readonly signInCompleted$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInCompleted),\n map(({ state, user }) => (state.passwordReset ? signOut() : signedIn({ user })))\n )\n );\n\n public readonly redirect$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(signInCompleted),\n switchMap(action => this.router.navigateByUrl(action.state.target, { replaceUrl: true }))\n ),\n { dispatch: false }\n );\n\n public readonly signOut$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signOut),\n switchMap(_ =>\n this.auth.logout().pipe(\n map(() => signedOut()),\n catchError(() => of(signedOut()))\n )\n )\n )\n );\n\n public readonly init$ = createEffect(() => ({ scheduler = asyncScheduler } = {}) => {\n const params = window.location.hash;\n\n if (\n (params.includes('code=') && params.includes('state=')) ||\n (params.includes('error=') && params.includes('error_description='))\n ) {\n return this.completeSignIn(scheduler);\n } else {\n return this.auth.checkSession().pipe(\n map(user => this.getAuthResult(user)),\n catchError(error => of(signInFailed({ error }))),\n observeOn(scheduler)\n );\n }\n });\n\n public readonly resetPassword$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInFailed),\n filter(action => action.error instanceof AuthError),\n map(action => action.error as AuthError),\n filter(AuthEffects.isForgotPasswordError),\n map(() => resetPassword({ returnUrl: '/' }))\n )\n );\n\n public readonly failed$ = createEffect(() =>\n this.actions$.pipe(\n ofType(signInFailed),\n filter(action => action.error instanceof AuthError),\n map(action => action.error as AuthError),\n filter(AuthEffects.isInteractionInProgress),\n map(() => signOut())\n )\n );\n\n public constructor(\n private readonly actions$: Actions,\n private readonly auth: AuthService,\n private readonly router: Router\n ) {}\n\n private static isForgotPasswordError(error: AuthError) {\n return error.errorCode === 'access_denied' && error.errorMessage.indexOf('AADB2C90118') !== -1;\n }\n\n private static isInteractionInProgress(error: AuthError) {\n return error.errorCode === BrowserAuthErrorMessage.interactionInProgress.code;\n }\n\n private getAuthResult(user: { sub: string } | undefined) {\n if (user) {\n return signedIn({ user });\n } else {\n return signedOut();\n }\n }\n\n private completeSignIn(scheduler: SchedulerLike) {\n return this.auth.handleRedirectCallback().pipe(\n map(result => signInCompleted({ state: result.state, user: result.user })),\n catchError(error => of(signInFailed({ error }))),\n observeOn(scheduler)\n );\n }\n}\n","import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { Injectable } from '@angular/core';\nimport { map, mergeMap } from 'rxjs/operators';\nimport { AuthService } from './auth.service';\n\n@Injectable()\nexport class JwtInterceptor implements HttpInterceptor {\n public constructor(private readonly auth: AuthService) {}\n\n public intercept(request: HttpRequest<any>, next: HttpHandler) {\n if (this.isSameDomain(request)) {\n return this.authorize(request).pipe(mergeMap(authorizedRequest => next.handle(authorizedRequest)));\n } else {\n return next.handle(request);\n }\n }\n\n private isSameDomain(request: HttpRequest<any>) {\n const isAbsolute = /^https?:\\/\\//i.test(request.url);\n\n return !isAbsolute;\n }\n\n private authorize(request: HttpRequest<any>) {\n const token$ = this.auth.getAccessToken();\n\n return token$.pipe(map(token => request.clone({ setHeaders: { Authorization: `Bearer ${token}` } })));\n }\n}\n","import { Action, createReducer, on } from '@ngrx/store';\nimport { signedIn, signedOut, signInFailed } from '../actions/auth.actions';\nimport { State } from '../state/auth.state';\n\nexport const noAuthentication: State = {\n authenticating: false,\n authenticated: false,\n};\n\nexport const startAuthentication: State = {\n authenticating: true,\n authenticated: false,\n};\n\nconst authReducer = createReducer(\n startAuthentication,\n on(signedIn, (state, { user }) => ({\n ...state,\n authenticating: false,\n authenticated: true,\n user,\n })),\n on(signedOut, _ => noAuthentication),\n on(signInFailed, _ => noAuthentication)\n);\n\nexport function reducer(state: State | undefined, action: Action) {\n return authReducer(state, action);\n}\n","import { createFeatureSelector, select } from '@ngrx/store';\nimport { pipe } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\nimport { State } from '../state/auth.state';\n\nexport const featureKey = 'auth';\n\nexport const selectState = createFeatureSelector<State>(featureKey);\n\nexport const isAuthenticated = pipe(\n select(selectState),\n filter(state => !state.authenticating),\n map(state => state.authenticated)\n);\n\nexport const getUser = pipe(\n select(selectState),\n filter(state => !state.authenticating),\n map(state => state.user)\n);\n","import { HTTP_INTERCEPTORS } from '@angular/common/http';\nimport { ModuleWithProviders, NgModule } from '@angular/core';\nimport { EffectsModule } from '@ngrx/effects';\nimport { StoreModule } from '@ngrx/store';\nimport { AuthConfig } from './auth-config';\nimport { AuthEffects } from './effects/auth.effects';\nimport { JwtInterceptor } from './jwt.interceptor';\nimport { reducer } from './reducers/auth.reducer';\nimport { featureKey } from './store';\n\n@NgModule({\n declarations: [],\n imports: [StoreModule.forFeature(featureKey, reducer), EffectsModule.forFeature([AuthEffects])],\n exports: [],\n})\nexport class AuthModule {\n public static forRoot(config: AuthConfig): ModuleWithProviders<AuthModule> {\n return {\n ngModule: AuthModule,\n providers: [\n {\n provide: AuthConfig,\n useValue: config,\n },\n {\n provide: HTTP_INTERCEPTORS,\n useClass: JwtInterceptor,\n multi: true,\n },\n ],\n };\n }\n}\n","import { Injectable } from '@angular/core';\nimport { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';\nimport { Store } from '@ngrx/store';\nimport { first, tap } from 'rxjs/operators';\nimport { signIn } from './actions/auth.actions';\nimport { isAuthenticated } from './store';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthGuard implements CanActivate {\n private readonly authenticated$ = this.store.pipe(isAuthenticated);\n\n public constructor(private readonly store: Store) {}\n\n public canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {\n return this.authenticated$.pipe(\n tap(auth => {\n if (!auth) {\n this.store.dispatch(signIn({ returnUrl: state.url }));\n }\n }),\n first()\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MAAsB,UAAU;;;MCGnB,MAAM,GAAG,YAAY,CAAC,+BAA+B,EAAE,KAAK,EAAyB,EAAE;AAE7F,MAAM,gBAAgB,GAAG,YAAY,CAAC,0CAA0C,CAAC,CAAC;AAElF,MAAM,eAAe,GAAG,YAAY,CACzC,yCAAyC,EACzC,KAAK,EAAwE,CAC9E,CAAC;MAEW,QAAQ,GAAG,YAAY,CAAC,iCAAiC,EAAE,KAAK,EAAqB,EAAE;AAE7F,MAAM,YAAY,GAAG,YAAY,CAAC,sCAAsC,EAAE,KAAK,EAAoB,CAAC,CAAC;MAE/F,OAAO,GAAG,YAAY,CAAC,gCAAgC,EAAE;MAEzD,SAAS,GAAG,YAAY,CAAC,kCAAkC,EAAE;AAEnE,MAAM,aAAa,GAAG,YAAY,CAAC,sCAAsC,EAAE,KAAK,EAAyB,CAAC;;MCNpG,WAAW;IAGtB,YAAoC,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;QACpD,MAAM,UAAU,GA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;;;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Profile } from '../state/auth.state';
|
|
2
|
-
export declare const signIn: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
2
|
+
export declare const signIn: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] sign-in", (props: {
|
|
3
3
|
returnUrl: string;
|
|
4
4
|
}) => {
|
|
5
5
|
returnUrl: string;
|
|
6
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
7
|
-
export declare const signInRedirected: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
8
|
-
export declare const signInCompleted: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
6
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign-in">>;
|
|
7
|
+
export declare const signInRedirected: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] sign in redirected", () => import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in redirected">>;
|
|
8
|
+
export declare const signInCompleted: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] sign in completed", (props: {
|
|
9
9
|
state: {
|
|
10
10
|
target: string;
|
|
11
11
|
passwordReset: boolean;
|
|
@@ -17,17 +17,21 @@ export declare const signInCompleted: import("@ngrx/store").ActionCreator<"@thec
|
|
|
17
17
|
passwordReset: boolean;
|
|
18
18
|
};
|
|
19
19
|
user: Profile;
|
|
20
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
21
|
-
export declare const signedIn: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
22
|
-
|
|
20
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in completed">>;
|
|
21
|
+
export declare const signedIn: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] signed in", (props: {
|
|
22
|
+
user: Profile;
|
|
23
|
+
}) => {
|
|
24
|
+
user: Profile;
|
|
25
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed in">>;
|
|
26
|
+
export declare const signInFailed: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] sign in failed", (props: {
|
|
23
27
|
error: Error;
|
|
24
28
|
}) => {
|
|
25
29
|
error: Error;
|
|
26
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
27
|
-
export declare const signOut: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
28
|
-
export declare const signedOut: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
29
|
-
export declare const resetPassword: import("@ngrx/store").ActionCreator<"@thecla/b2c-angular
|
|
30
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in failed">>;
|
|
31
|
+
export declare const signOut: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] sign out", () => import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign out">>;
|
|
32
|
+
export declare const signedOut: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] signed out", () => import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed out">>;
|
|
33
|
+
export declare const resetPassword: import("@ngrx/store").ActionCreator<"[@thecla/b2c-angular] reset password", (props: {
|
|
30
34
|
returnUrl: string;
|
|
31
35
|
}) => {
|
|
32
36
|
returnUrl: string;
|
|
33
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
37
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] reset password">>;
|
package/lib/auth.guard.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot } from '@angular/router';
|
|
2
2
|
import { Store } from '@ngrx/store';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
export declare class AuthGuard implements CanActivate {
|
|
4
5
|
private readonly store;
|
|
5
6
|
private readonly authenticated$;
|
|
6
|
-
constructor(store: Store
|
|
7
|
+
constructor(store: Store);
|
|
7
8
|
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): import("rxjs").Observable<boolean>;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthGuard, never>;
|
|
10
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthGuard>;
|
|
8
11
|
}
|
package/lib/auth.module.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { AuthConfig } from './auth-config';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import * as i1 from "@ngrx/store";
|
|
5
|
+
import * as i2 from "@ngrx/effects";
|
|
3
6
|
export declare class AuthModule {
|
|
4
7
|
static forRoot(config: AuthConfig): ModuleWithProviders<AuthModule>;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthModule, never>;
|
|
9
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<AuthModule, never, [typeof i1.StoreFeatureModule, typeof i2.EffectsFeatureModule], never>;
|
|
10
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<AuthModule>;
|
|
5
11
|
}
|
package/lib/auth.service.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthConfig } from './auth-config';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
2
3
|
export declare class AuthService {
|
|
3
4
|
private readonly config;
|
|
4
5
|
private readonly clientApplication;
|
|
@@ -20,4 +21,6 @@ export declare class AuthService {
|
|
|
20
21
|
checkSession(): import("rxjs").Observable<{
|
|
21
22
|
sub: string;
|
|
22
23
|
} | undefined>;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, never>;
|
|
25
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
|
|
23
26
|
}
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
import { Router } from '@angular/router';
|
|
2
2
|
import { Actions } from '@ngrx/effects';
|
|
3
3
|
import { AuthService } from '../auth.service';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
4
5
|
export declare class AuthEffects {
|
|
5
6
|
private readonly actions$;
|
|
6
7
|
private readonly auth;
|
|
7
8
|
private readonly router;
|
|
8
|
-
readonly signIn$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
9
|
+
readonly signIn$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in redirected"> | ({
|
|
9
10
|
error: Error;
|
|
10
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
11
|
-
readonly passwordReset$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
11
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in failed">)> & import("@ngrx/effects").CreateEffectMetadata;
|
|
12
|
+
readonly passwordReset$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in redirected"> | ({
|
|
12
13
|
error: Error;
|
|
13
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
14
|
-
readonly signInCompleted$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
14
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in failed">)> & import("@ngrx/effects").CreateEffectMetadata;
|
|
15
|
+
readonly signInCompleted$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign out"> | ({
|
|
16
|
+
user: import("@thecla/b2c-angular").Profile;
|
|
17
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed in">)> & import("@ngrx/effects").CreateEffectMetadata;
|
|
15
18
|
readonly redirect$: import("rxjs").Observable<boolean> & import("@ngrx/effects").CreateEffectMetadata;
|
|
16
|
-
readonly signOut$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
19
|
+
readonly signOut$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed out">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
17
20
|
readonly init$: (({ scheduler }?: any) => import("rxjs").Observable<({
|
|
18
21
|
error: Error;
|
|
19
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
22
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in failed">) | ({
|
|
20
23
|
state: {
|
|
21
24
|
target: string;
|
|
22
25
|
passwordReset: boolean;
|
|
23
26
|
};
|
|
24
|
-
user: import("
|
|
25
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
27
|
+
user: import("@thecla/b2c-angular").Profile;
|
|
28
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in completed">)> | import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed out"> | ({
|
|
26
29
|
error: Error;
|
|
27
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
30
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign in failed">) | ({
|
|
31
|
+
user: import("@thecla/b2c-angular").Profile;
|
|
32
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] signed in">)>) & import("@ngrx/effects").CreateEffectMetadata;
|
|
28
33
|
readonly resetPassword$: import("rxjs").Observable<{
|
|
29
34
|
returnUrl: string;
|
|
30
|
-
} & import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
31
|
-
readonly failed$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"@thecla/b2c-angular
|
|
35
|
+
} & import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] reset password">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
36
|
+
readonly failed$: import("rxjs").Observable<import("@ngrx/store/src/models").TypedAction<"[@thecla/b2c-angular] sign out">> & import("@ngrx/effects").CreateEffectMetadata;
|
|
32
37
|
constructor(actions$: Actions, auth: AuthService, router: Router);
|
|
33
38
|
private static isForgotPasswordError;
|
|
34
39
|
private static isInteractionInProgress;
|
|
35
40
|
private getAuthResult;
|
|
36
41
|
private completeSignIn;
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthEffects, never>;
|
|
43
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<AuthEffects>;
|
|
37
44
|
}
|
package/lib/jwt.interceptor.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
|
|
2
2
|
import { AuthService } from './auth.service';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
3
4
|
export declare class JwtInterceptor implements HttpInterceptor {
|
|
4
5
|
private readonly auth;
|
|
5
6
|
constructor(auth: AuthService);
|
|
6
7
|
intercept(request: HttpRequest<any>, next: HttpHandler): import("rxjs").Observable<import("@angular/common/http").HttpEvent<any>>;
|
|
7
8
|
private isSameDomain;
|
|
8
9
|
private authorize;
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<JwtInterceptor, never>;
|
|
11
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<JwtInterceptor>;
|
|
9
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thecla/b2c-angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"author": "Hendrik Wouters",
|
|
5
5
|
"description": "Angular module using NGRX to authenticate with Azure AD B2C",
|
|
6
6
|
"repository": {
|
|
@@ -19,23 +19,35 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://github.com/hwouters/auth0-angular#readme",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@angular/common": "^
|
|
23
|
-
"@angular/core": "^
|
|
24
|
-
"@angular/router": "^
|
|
22
|
+
"@angular/common": "^13.0.0",
|
|
23
|
+
"@angular/core": "^13.0.0",
|
|
24
|
+
"@angular/router": "^13.0.0",
|
|
25
25
|
"@azure/msal-browser": "^2.7.0",
|
|
26
|
-
"@ngrx/effects": "^
|
|
27
|
-
"@ngrx/store": "^
|
|
26
|
+
"@ngrx/effects": "^13.0.0",
|
|
27
|
+
"@ngrx/store": "^13.0.0",
|
|
28
28
|
"rxjs": "^6.5.4"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"tslib": "^2.0.0"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"fesm2015": "fesm2015/thecla-b2c-angular.
|
|
33
|
+
"module": "fesm2015/thecla-b2c-angular.mjs",
|
|
34
|
+
"es2020": "fesm2020/thecla-b2c-angular.mjs",
|
|
35
|
+
"esm2020": "esm2020/thecla-b2c-angular.mjs",
|
|
36
|
+
"fesm2020": "fesm2020/thecla-b2c-angular.mjs",
|
|
37
|
+
"fesm2015": "fesm2015/thecla-b2c-angular.mjs",
|
|
38
38
|
"typings": "thecla-b2c-angular.d.ts",
|
|
39
|
-
"
|
|
39
|
+
"exports": {
|
|
40
|
+
"./package.json": {
|
|
41
|
+
"default": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./thecla-b2c-angular.d.ts",
|
|
45
|
+
"esm2020": "./esm2020/thecla-b2c-angular.mjs",
|
|
46
|
+
"es2020": "./fesm2020/thecla-b2c-angular.mjs",
|
|
47
|
+
"es2015": "./fesm2015/thecla-b2c-angular.mjs",
|
|
48
|
+
"node": "./fesm2015/thecla-b2c-angular.mjs",
|
|
49
|
+
"default": "./fesm2020/thecla-b2c-angular.mjs"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
40
52
|
"sideEffects": false
|
|
41
53
|
}
|
package/thecla-b2c-angular.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generated bundle index. Do not edit.
|
|
3
3
|
*/
|
|
4
|
+
/// <amd-module name="@thecla/b2c-angular" />
|
|
4
5
|
export * from './public-api';
|
|
5
|
-
export { signInFailed as ɵa } from './lib/actions/auth.actions';
|
|
6
|
-
export { AuthConfig as ɵh } from './lib/auth-config';
|
|
7
|
-
export { AuthService as ɵg } from './lib/auth.service';
|
|
8
|
-
export { AuthEffects as ɵf } from './lib/effects/auth.effects';
|
|
9
|
-
export { JwtInterceptor as ɵi } from './lib/jwt.interceptor';
|
|
10
|
-
export { reducer as ɵe, startAuthentication as ɵd } from './lib/reducers/auth.reducer';
|
|
11
|
-
export { featureKey as ɵb, selectState as ɵc } from './lib/store';
|