@ng-vagabond-lab/ng-dsv 0.2.35 → 0.2.37
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/fesm2022/ng-vagabond-lab-ng-dsv-base-service.mjs +3 -2
- package/fesm2022/ng-vagabond-lab-ng-dsv-base-service.mjs.map +1 -1
- package/fesm2022/ng-vagabond-lab-ng-dsv-module-auth.mjs +2 -1
- package/fesm2022/ng-vagabond-lab-ng-dsv-module-auth.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ng-vagabond-lab-ng-dsv-base-service.d.ts +3 -3
- package/types/ng-vagabond-lab-ng-dsv-base.d.ts +3 -3
|
@@ -108,7 +108,8 @@ class BaseSearchService extends BaseFetchService {
|
|
|
108
108
|
this.lasturl.set(url);
|
|
109
109
|
const data = this.getDataFromState(url);
|
|
110
110
|
if (data) {
|
|
111
|
-
this.
|
|
111
|
+
this.total.set(data.totalElements);
|
|
112
|
+
this.updateData(page, data.content);
|
|
112
113
|
this.isLoading.set(false);
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
@@ -116,7 +117,7 @@ class BaseSearchService extends BaseFetchService {
|
|
|
116
117
|
this.apiService.get(url, (data) => {
|
|
117
118
|
this.page.set(page + 1);
|
|
118
119
|
this.total.set(data.totalElements);
|
|
119
|
-
this.setDataToState(url, data
|
|
120
|
+
this.setDataToState(url, data);
|
|
120
121
|
this.isLoading.set(false);
|
|
121
122
|
this.updateData(page, data.content);
|
|
122
123
|
}, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-vagabond-lab-ng-dsv-base-service.mjs","sources":["../../../projects/ng-dsv/base/service/base/base.service.ts","../../../projects/ng-dsv/base/service/base/base-api.service.ts","../../../projects/ng-dsv/base/service/fetch/base-fetch.service.ts","../../../projects/ng-dsv/base/service/search/base-search.service.ts","../../../projects/ng-dsv/base/service/ng-vagabond-lab-ng-dsv-base-service.ts"],"sourcesContent":["import { Directive, inject, signal, TransferState } from '@angular/core';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { I18nService } from '@ng-vagabond-lab/ng-dsv/i18n';\nimport { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';\n\n@Directive()\nexport abstract class BaseService {\n readonly toastService = inject(ToastService);\n readonly transferState = inject(TransferState);\n readonly platformService = inject(PlatformService);\n readonly i18nService = inject(I18nService);\n readonly translateService = this.i18nService.translateService;\n\n readonly loaded = signal<boolean>(true);\n\n isPlatformBrowser(): boolean {\n return this.platformService.isPlatformBrowser();\n }\n}\n","import { Directive, inject } from '@angular/core';\nimport { ApiService } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseService } from './base.service';\n\n@Directive()\nexport abstract class BaseApiService extends BaseService {\n readonly apiService = inject(ApiService);\n}\n","import { Directive, makeStateKey, signal, StateKey } from '@angular/core';\nimport { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseApiService } from '../base/base-api.service';\n\n@Directive()\nexport abstract class BaseFetchService
|
|
1
|
+
{"version":3,"file":"ng-vagabond-lab-ng-dsv-base-service.mjs","sources":["../../../projects/ng-dsv/base/service/base/base.service.ts","../../../projects/ng-dsv/base/service/base/base-api.service.ts","../../../projects/ng-dsv/base/service/fetch/base-fetch.service.ts","../../../projects/ng-dsv/base/service/search/base-search.service.ts","../../../projects/ng-dsv/base/service/ng-vagabond-lab-ng-dsv-base-service.ts"],"sourcesContent":["import { Directive, inject, signal, TransferState } from '@angular/core';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { I18nService } from '@ng-vagabond-lab/ng-dsv/i18n';\nimport { PlatformService } from '@ng-vagabond-lab/ng-dsv/platform';\n\n@Directive()\nexport abstract class BaseService {\n readonly toastService = inject(ToastService);\n readonly transferState = inject(TransferState);\n readonly platformService = inject(PlatformService);\n readonly i18nService = inject(I18nService);\n readonly translateService = this.i18nService.translateService;\n\n readonly loaded = signal<boolean>(true);\n\n isPlatformBrowser(): boolean {\n return this.platformService.isPlatformBrowser();\n }\n}\n","import { Directive, inject } from '@angular/core';\nimport { ApiService } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseService } from './base.service';\n\n@Directive()\nexport abstract class BaseApiService extends BaseService {\n readonly apiService = inject(ApiService);\n}\n","import { Directive, makeStateKey, signal, StateKey } from '@angular/core';\nimport { ApiDto, JSONObject, PageableDto } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseApiService } from '../base/base-api.service';\n\n@Directive()\nexport abstract class BaseFetchService<\n A extends ApiDto | ApiDto[] | PageableDto<ApiDto[]>,\n> extends BaseApiService {\n readonly ssr = signal<boolean>(true);\n\n getStateKey(url: string): StateKey<A> {\n return makeStateKey<A>(url);\n }\n\n getDataFromState(url: string): A | null {\n const key = this.getStateKey(url);\n let data = null;\n if (this.transferState.hasKey(key)) {\n data = this.transferState.get(key, null);\n this.transferState.remove(key);\n this.apiService.info('load state', data as JSONObject);\n }\n return data;\n }\n\n setDataToState(url: string, data: A | null): void {\n if (!this.isPlatformBrowser()) {\n const key = this.getStateKey(url);\n this.transferState.set(key, data);\n }\n }\n}\n","import { Directive, signal } from '@angular/core';\nimport { ApiDto, PageableDto } from '@ng-vagabond-lab/ng-dsv/api';\nimport { removeDuplicate } from '@ng-vagabond-lab/ng-dsv/storage';\nimport { BaseFetchService } from '../fetch/base-fetch.service';\n\n@Directive()\nexport abstract class BaseSearchService<T extends ApiDto> extends BaseFetchService<PageableDto<T[]>> {\n readonly datas = signal<T[]>([]);\n readonly total = signal<number | undefined>(undefined);\n\n readonly page = signal<number>(1);\n readonly search = signal<string>('');\n readonly lastSearch = signal<string>('');\n readonly lasturl = signal<string>('');\n readonly isLoading = signal<boolean>(false);\n readonly stopFetch = signal<boolean>(false);\n\n getUrl(): string {\n let url = this.getEndPoint();\n const params = this.getParams();\n url += '?page=' + this.page() + params + '&search=';\n return url;\n }\n\n abstract getEndPoint(): string;\n\n getParams(): string {\n return '';\n }\n\n fetchByPage(search: string, page: number, force: boolean = false): void {\n this.search.set(search);\n if (search !== this.lastSearch()) {\n this.lastSearch.set(search);\n page = 1;\n }\n if (page === 1) {\n this.stopFetch.set(false);\n }\n if (this.stopFetch()) {\n return;\n }\n this.page.set(page);\n const url = this.getUrl() + search;\n\n if (this.lasturl() === url && !force) {\n return;\n }\n this.lasturl.set(url);\n\n const data = this.getDataFromState(url);\n if (data) {\n this.total.set(data.totalElements);\n this.updateData(page, data.content);\n this.isLoading.set(false);\n return;\n }\n this.isLoading.set(true);\n\n this.apiService.get<PageableDto<T[]>>(\n url,\n (data) => {\n this.page.set(page + 1);\n this.total.set(data.totalElements);\n this.setDataToState(url, data);\n this.isLoading.set(false);\n this.updateData(page, data.content);\n },\n () => {\n this.isLoading.set(false);\n this.stopFetch.set(true);\n },\n );\n }\n\n updateData(page: number, datas: T[]): void {\n if (page === 1) {\n this.datas.set([]);\n }\n this.datas.update((current) => removeDuplicate([...current, ...datas]));\n if (datas?.length === 0) {\n this.stopFetch.set(true);\n }\n this.afterFetch(datas);\n }\n\n afterFetch(data: T[]): void {\n return;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAMsB,WAAW,CAAA;AACpB,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AACnC,IAAA,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;AACrC,IAAA,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AACzC,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,gBAAgB;IAEpD,MAAM,GAAG,MAAM,CAAU,IAAI;+EAAC;IAEvC,iBAAiB,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,iBAAiB,EAAE;IACnD;uGAXkB,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,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QACvC,CAAC,EACD,MAAK;AACD,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;AACzB,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;AAC5B,QAAA,CAAC,CACJ;IACL;IAEA,UAAU,CAAC,IAAY,EAAE,KAAU,EAAA;AAC/B,QAAA,IAAI,IAAI,KAAK,CAAC,EAAE;AACZ,YAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB;QACA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,KAAK,eAAe,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;AACvE,QAAA,IAAI,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE;AACrB,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;QAC5B;AACA,QAAA,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC1B;AAEA,IAAA,UAAU,CAAC,IAAS,EAAA;QAChB;IACJ;uGAlFkB,iBAAiB,EAAA,IAAA,EAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAjB,iBAAiB,EAAA,YAAA,EAAA,IAAA,EAAA,eAAA,EAAA,IAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAjB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBADtC;;;ACLD;;AAEG;;;;"}
|
|
@@ -190,10 +190,11 @@ class AuthGoogleService {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
initGoogleAuth(googleButtonid = crypto.randomUUID()) {
|
|
193
|
-
if (
|
|
193
|
+
if (!this.authService.isPlatformBrowser()) {
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
const element = document.getElementById(googleButtonid);
|
|
197
|
+
console.log('dsqdlskqdjlkqs', element);
|
|
197
198
|
if (element) {
|
|
198
199
|
this.googleIds.update((ids) => {
|
|
199
200
|
ids.set(googleButtonid, true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-vagabond-lab-ng-dsv-module-auth.mjs","sources":["../../../projects/ng-dsv/module/auth/component/auth.component.ts","../../../projects/ng-dsv/module/auth/component/auth.component.html","../../../projects/ng-dsv/module/auth/guard/auth.guard.ts","../../../projects/ng-dsv/module/auth/interceptor/auth.interceptor.ts","../../../projects/ng-dsv/module/auth/service/auth.service.ts","../../../projects/ng-dsv/module/auth/service/auth-google.service.ts","../../../projects/ng-dsv/module/auth/utils/auth.utils.ts","../../../projects/ng-dsv/module/auth/ng-vagabond-lab-ng-dsv-module-auth.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, effect, inject, output } from '@angular/core';\nimport { ID } from '@ng-vagabond-lab/ng-dsv/api';\nimport { DsvModalAlertComponent, DsvModalButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/modal';\nimport { RouterInternalPipe } from '@ng-vagabond-lab/ng-dsv/router';\nimport { AuthGoogleService, AuthService } from '../public-api';\n\n@Component({\n selector: 'dsv-auth',\n imports: [CommonModule, DsvModalButtonComponent, DsvModalAlertComponent, RouterInternalPipe],\n templateUrl: './auth.component.html',\n styleUrls: ['./auth.component.scss'],\n})\nexport class AuthComponent {\n readonly authService = inject(AuthService);\n readonly authGoogleService = inject(AuthGoogleService);\n\n readonly callbackInitMember = output<ID>();\n readonly callbackLogout = output<void>();\n\n constructor() {\n effect(() => {\n if (this.authService.isRefreshTokenLoaded()) {\n this.authGoogleService.initGoogleAuth('google-signin-button');\n }\n });\n effect(() => {\n if (this.authService.userConnected() === null) {\n this.authGoogleService.loginWithGoogle();\n } else {\n this.callbackInitMember.emit(this.authService.userConnected()?.id);\n }\n });\n }\n\n logout(): void {\n this.authService.logout();\n this.callbackLogout.emit();\n }\n}\n","<button\n id=\"google-signin-button\"\n [class.hidden]=\"!authService.isRefreshTokenLoaded() || authService.userConnected() !== null\"\n></button>\n\n@if (authService.userConnected()) {\n <ng-content />\n <a href=\"/profil\" dsvLink>\n <img [src]=\"authService.userConnected()?.avatar\" alt=\"Profile\" referrerpolicy=\"no-referrer\" />\n </a>\n <dsv-modal-button modalName=\"logout\" color=\"secondary\" variant=\"outlined\" icon=\"ri-logout-box-line\" />\n <dsv-modal-alert\n id=\"logout\"\n titleText=\"Déconnexion\"\n text=\"Voulez-vous vraiment vous déconnecter ?\"\n button=\"Oui\"\n buttonClose=\"Non\"\n (callback)=\"logout()\"\n ></dsv-modal-alert>\n}\n","import { inject } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { CanActivateFn } from '@angular/router';\nimport { RouterService } from '@ng-vagabond-lab/ng-dsv/router';\nimport { filter, map, take } from 'rxjs';\nimport { AuthService } from '../public-api';\n\nexport const authGuard = (role: string): CanActivateFn => {\n return () => {\n const authService = inject(AuthService);\n const router = inject(RouterService).router;\n\n if (!authService.isPlatformBrowser()) {\n return true;\n }\n\n const requiredRole = role.toUpperCase();\n\n return toObservable(authService.isRefreshTokenLoaded).pipe(\n filter((loaded) => loaded),\n take(1),\n map(() => {\n if (authService.hasRole(requiredRole)) {\n return true;\n }\n return router.createUrlTree(['/access-denied']);\n }),\n );\n };\n};\n","import { HttpClient, HttpErrorResponse, HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { BehaviorSubject, catchError, filter, Observable, switchMap, take, throwError } from 'rxjs';\nimport { AuthService } from '../public-api';\n\nlet isRefreshing = false;\nconst refreshSubject$ = new BehaviorSubject<string | null>(null);\n\nexport const authInterceptor = (\n req: HttpRequest<unknown>,\n next: HttpHandlerFn,\n): Observable<HttpEvent<unknown>> => {\n const httpClient = inject(HttpClient);\n const authService = inject(AuthService);\n const toastService = inject(ToastService);\n\n return next(getToken(req, authService)).pipe(\n catchError((error) => {\n if (\n error instanceof HttpErrorResponse &&\n !req.url.includes('auth/') &&\n req.url.includes(authService.apiService.baseUrl()) &&\n error.status === 401\n ) {\n return handle401Error(httpClient, authService, req, next);\n }\n\n let errorMessage = error.error?.debugMessage ?? error.error?.message ?? error.message;\n\n if (\n errorMessage === 'fetch failed' ||\n errorMessage === 'Failed to fetch' ||\n errorMessage.endsWith(': 500 Internal Server Error')\n ) {\n errorMessage = 'Api indisponible';\n }\n if (errorMessage === 'NO_REFRESH_TOKEN') {\n authService.logout(false);\n } else {\n toastService.showToast({ type: 'error', text: errorMessage, closeAll: true });\n }\n\n return throwError(() => error);\n }),\n );\n};\n\nconst getToken = <T>(req: HttpRequest<T>, authService: AuthService) => {\n const jwt = authService.userToken();\n if (!req.url.includes('/auth/') && req.url.includes(authService.apiService.baseUrl()) && jwt) {\n return req.clone({ headers: req.headers.set('Authorization', `Bearer ${jwt}`) });\n }\n return req;\n};\n\nconst handle401Error = <T>(\n httpClient: HttpClient,\n authService: AuthService,\n request: HttpRequest<T>,\n next: HttpHandlerFn,\n) => {\n if (isRefreshing) {\n return refreshSubject$.pipe(\n filter((token) => token !== null),\n take(1),\n switchMap(() => next(getToken(request, authService))),\n );\n }\n\n isRefreshing = true;\n refreshSubject$.next(null);\n\n return httpClient\n .post(authService.apiService.baseUrl() + '/auth/refresh-token', {}, { withCredentials: true })\n .pipe(\n switchMap((response) => {\n authService.initUser(response);\n isRefreshing = false;\n refreshSubject$.next(authService.userToken());\n return next(getToken(request, authService));\n }),\n catchError((error) => {\n isRefreshing = false;\n refreshSubject$.next(null);\n authService.logout(false);\n return throwError(() => error);\n }),\n );\n};\n","import { computed, Injectable, signal } from '@angular/core';\nimport { JSONValue } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseApiService } from '@ng-vagabond-lab/ng-dsv/base/service';\nimport { UserDto, UserSigninDto } from '../dto/auth.dto';\nimport { hasRole } from '../public-api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService extends BaseApiService {\n readonly userConnected = signal<UserDto | null>(null);\n readonly userToken = signal<string>('');\n readonly isRefreshTokenLoaded = signal<boolean>(false);\n\n readonly isAdmin = computed<boolean>(() => this.hasRole('ADMIN'));\n\n initUser(user: UserSigninDto | null = null): void {\n this.userConnected.set(user?.user ?? null);\n this.userToken.set(user?.jwt ?? '');\n this.isRefreshTokenLoaded.set(true);\n }\n\n googleLogin(credential: string): void {\n this.apiService.post<JSONValue, UserSigninDto>(\n '/auth/google-identity-connect',\n {\n googleToken: credential,\n },\n (data) => {\n this.initUser(data);\n this.apiService.toastService.showToast({\n type: 'success',\n text: 'Connexion réussie',\n });\n },\n true,\n );\n }\n\n refreshToken(): void {\n this.apiService.post<UserSigninDto>(\n '/auth/refresh-token',\n {},\n (data) => this.initUser(data),\n true,\n () => this.initUser(),\n );\n }\n\n logout(showToast: boolean = true): void {\n this.apiService.post<UserSigninDto>(\n '/auth/logout',\n {},\n () => {\n this.initUser();\n if (showToast) {\n this.apiService.toastService.showToast({\n type: 'success',\n text: 'Déconnexion réussie',\n });\n }\n },\n true,\n );\n }\n\n hasRole(role: string): boolean {\n const user = this.userConnected() ?? null;\n return !!user && hasRole(role, user.profiles);\n }\n\n canFetch(ssr: boolean = true): boolean {\n return (\n (ssr && !this.isPlatformBrowser()) || (this.isPlatformBrowser() && this.isRefreshTokenLoaded())\n );\n }\n}\n","import { effect, inject, Injectable, signal } from '@angular/core';\nimport { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';\nimport { AuthService } from './auth.service';\n\ndeclare const google: any;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthGoogleService {\n readonly authService = inject(AuthService);\n readonly environmentService = inject(EnvironmentService);\n\n readonly googleIds = signal<Map<string, boolean>>(new Map());\n\n readonly init = signal<boolean>(false);\n\n constructor() {\n effect(() => {\n if (!this.init() && this.authService.isPlatformBrowser() && this.environmentService.config()) {\n this.init.set(true);\n google.accounts.id.initialize({\n client_id: this.environmentService.config()?.GOOGLE_CLIENT_ID,\n callback: this.handleCredentialResponse.bind(this),\n });\n }\n });\n }\n\n initGoogleAuth(googleButtonid: string = crypto.randomUUID()): void {\n if (this.googleIds().get(googleButtonid) || !this.authService.isPlatformBrowser()) {\n return;\n }\n const element = document.getElementById(googleButtonid);\n if (element) {\n this.googleIds.update((ids) => {\n ids.set(googleButtonid, true);\n return ids;\n });\n google.accounts.id.renderButton(document.getElementById(googleButtonid)!, {\n theme: 'outline',\n size: 'medium',\n type: 'icon',\n });\n }\n }\n\n handleCredentialResponse(response: { credential: string }): void {\n this.authService.googleLogin(response.credential);\n }\n\n loginWithGoogle(): void {\n if (\n this.authService.isRefreshTokenLoaded() &&\n this.authService.userConnected() === null &&\n this.authService.isPlatformBrowser()\n ) {\n google.accounts.id.prompt();\n }\n }\n}\n","import { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';\n\nexport const hasRole = (roles: string, userRoles?: ApiDto[]): boolean => {\n const roleSplit = roles.split(',');\n let find = false;\n roleSplit.forEach((role) => {\n if (\n userRoles?.find(\n (userRole) =>\n userRole['roles' as keyof ApiDto]?.toString().includes(role) ||\n userRole['name' as keyof ApiDto] === role,\n )\n ) {\n find = true;\n }\n });\n return find;\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MAaa,aAAa,CAAA;AACb,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAE7C,kBAAkB,GAAG,MAAM,EAAM;IACjC,cAAc,GAAG,MAAM,EAAQ;AAExC,IAAA,WAAA,GAAA;QACI,MAAM,CAAC,MAAK;AACR,YAAA,IAAI,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,EAAE;AACzC,gBAAA,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,sBAAsB,CAAC;YACjE;AACJ,QAAA,CAAC,CAAC;QACF,MAAM,CAAC,MAAK;YACR,IAA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KAAK,IAAI,CAChD,EACH;YACE,IAAI,GAAG,IAAI;QACf;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,IAAI;AACf;;ACjBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-vagabond-lab-ng-dsv-module-auth.mjs","sources":["../../../projects/ng-dsv/module/auth/component/auth.component.ts","../../../projects/ng-dsv/module/auth/component/auth.component.html","../../../projects/ng-dsv/module/auth/guard/auth.guard.ts","../../../projects/ng-dsv/module/auth/interceptor/auth.interceptor.ts","../../../projects/ng-dsv/module/auth/service/auth.service.ts","../../../projects/ng-dsv/module/auth/service/auth-google.service.ts","../../../projects/ng-dsv/module/auth/utils/auth.utils.ts","../../../projects/ng-dsv/module/auth/ng-vagabond-lab-ng-dsv-module-auth.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, effect, inject, output } from '@angular/core';\nimport { ID } from '@ng-vagabond-lab/ng-dsv/api';\nimport { DsvModalAlertComponent, DsvModalButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/modal';\nimport { RouterInternalPipe } from '@ng-vagabond-lab/ng-dsv/router';\nimport { AuthGoogleService, AuthService } from '../public-api';\n\n@Component({\n selector: 'dsv-auth',\n imports: [CommonModule, DsvModalButtonComponent, DsvModalAlertComponent, RouterInternalPipe],\n templateUrl: './auth.component.html',\n styleUrls: ['./auth.component.scss'],\n})\nexport class AuthComponent {\n readonly authService = inject(AuthService);\n readonly authGoogleService = inject(AuthGoogleService);\n\n readonly callbackInitMember = output<ID>();\n readonly callbackLogout = output<void>();\n\n constructor() {\n effect(() => {\n if (this.authService.isRefreshTokenLoaded()) {\n this.authGoogleService.initGoogleAuth('google-signin-button');\n }\n });\n effect(() => {\n if (this.authService.userConnected() === null) {\n this.authGoogleService.loginWithGoogle();\n } else {\n this.callbackInitMember.emit(this.authService.userConnected()?.id);\n }\n });\n }\n\n logout(): void {\n this.authService.logout();\n this.callbackLogout.emit();\n }\n}\n","<button\n id=\"google-signin-button\"\n [class.hidden]=\"!authService.isRefreshTokenLoaded() || authService.userConnected() !== null\"\n></button>\n\n@if (authService.userConnected()) {\n <ng-content />\n <a href=\"/profil\" dsvLink>\n <img [src]=\"authService.userConnected()?.avatar\" alt=\"Profile\" referrerpolicy=\"no-referrer\" />\n </a>\n <dsv-modal-button modalName=\"logout\" color=\"secondary\" variant=\"outlined\" icon=\"ri-logout-box-line\" />\n <dsv-modal-alert\n id=\"logout\"\n titleText=\"Déconnexion\"\n text=\"Voulez-vous vraiment vous déconnecter ?\"\n button=\"Oui\"\n buttonClose=\"Non\"\n (callback)=\"logout()\"\n ></dsv-modal-alert>\n}\n","import { inject } from '@angular/core';\nimport { toObservable } from '@angular/core/rxjs-interop';\nimport { CanActivateFn } from '@angular/router';\nimport { RouterService } from '@ng-vagabond-lab/ng-dsv/router';\nimport { filter, map, take } from 'rxjs';\nimport { AuthService } from '../public-api';\n\nexport const authGuard = (role: string): CanActivateFn => {\n return () => {\n const authService = inject(AuthService);\n const router = inject(RouterService).router;\n\n if (!authService.isPlatformBrowser()) {\n return true;\n }\n\n const requiredRole = role.toUpperCase();\n\n return toObservable(authService.isRefreshTokenLoaded).pipe(\n filter((loaded) => loaded),\n take(1),\n map(() => {\n if (authService.hasRole(requiredRole)) {\n return true;\n }\n return router.createUrlTree(['/access-denied']);\n }),\n );\n };\n};\n","import { HttpClient, HttpErrorResponse, HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';\nimport { BehaviorSubject, catchError, filter, Observable, switchMap, take, throwError } from 'rxjs';\nimport { AuthService } from '../public-api';\n\nlet isRefreshing = false;\nconst refreshSubject$ = new BehaviorSubject<string | null>(null);\n\nexport const authInterceptor = (\n req: HttpRequest<unknown>,\n next: HttpHandlerFn,\n): Observable<HttpEvent<unknown>> => {\n const httpClient = inject(HttpClient);\n const authService = inject(AuthService);\n const toastService = inject(ToastService);\n\n return next(getToken(req, authService)).pipe(\n catchError((error) => {\n if (\n error instanceof HttpErrorResponse &&\n !req.url.includes('auth/') &&\n req.url.includes(authService.apiService.baseUrl()) &&\n error.status === 401\n ) {\n return handle401Error(httpClient, authService, req, next);\n }\n\n let errorMessage = error.error?.debugMessage ?? error.error?.message ?? error.message;\n\n if (\n errorMessage === 'fetch failed' ||\n errorMessage === 'Failed to fetch' ||\n errorMessage.endsWith(': 500 Internal Server Error')\n ) {\n errorMessage = 'Api indisponible';\n }\n if (errorMessage === 'NO_REFRESH_TOKEN') {\n authService.logout(false);\n } else {\n toastService.showToast({ type: 'error', text: errorMessage, closeAll: true });\n }\n\n return throwError(() => error);\n }),\n );\n};\n\nconst getToken = <T>(req: HttpRequest<T>, authService: AuthService) => {\n const jwt = authService.userToken();\n if (!req.url.includes('/auth/') && req.url.includes(authService.apiService.baseUrl()) && jwt) {\n return req.clone({ headers: req.headers.set('Authorization', `Bearer ${jwt}`) });\n }\n return req;\n};\n\nconst handle401Error = <T>(\n httpClient: HttpClient,\n authService: AuthService,\n request: HttpRequest<T>,\n next: HttpHandlerFn,\n) => {\n if (isRefreshing) {\n return refreshSubject$.pipe(\n filter((token) => token !== null),\n take(1),\n switchMap(() => next(getToken(request, authService))),\n );\n }\n\n isRefreshing = true;\n refreshSubject$.next(null);\n\n return httpClient\n .post(authService.apiService.baseUrl() + '/auth/refresh-token', {}, { withCredentials: true })\n .pipe(\n switchMap((response) => {\n authService.initUser(response);\n isRefreshing = false;\n refreshSubject$.next(authService.userToken());\n return next(getToken(request, authService));\n }),\n catchError((error) => {\n isRefreshing = false;\n refreshSubject$.next(null);\n authService.logout(false);\n return throwError(() => error);\n }),\n );\n};\n","import { computed, Injectable, signal } from '@angular/core';\nimport { JSONValue } from '@ng-vagabond-lab/ng-dsv/api';\nimport { BaseApiService } from '@ng-vagabond-lab/ng-dsv/base/service';\nimport { UserDto, UserSigninDto } from '../dto/auth.dto';\nimport { hasRole } from '../public-api';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService extends BaseApiService {\n readonly userConnected = signal<UserDto | null>(null);\n readonly userToken = signal<string>('');\n readonly isRefreshTokenLoaded = signal<boolean>(false);\n\n readonly isAdmin = computed<boolean>(() => this.hasRole('ADMIN'));\n\n initUser(user: UserSigninDto | null = null): void {\n this.userConnected.set(user?.user ?? null);\n this.userToken.set(user?.jwt ?? '');\n this.isRefreshTokenLoaded.set(true);\n }\n\n googleLogin(credential: string): void {\n this.apiService.post<JSONValue, UserSigninDto>(\n '/auth/google-identity-connect',\n {\n googleToken: credential,\n },\n (data) => {\n this.initUser(data);\n this.apiService.toastService.showToast({\n type: 'success',\n text: 'Connexion réussie',\n });\n },\n true,\n );\n }\n\n refreshToken(): void {\n this.apiService.post<UserSigninDto>(\n '/auth/refresh-token',\n {},\n (data) => this.initUser(data),\n true,\n () => this.initUser(),\n );\n }\n\n logout(showToast: boolean = true): void {\n this.apiService.post<UserSigninDto>(\n '/auth/logout',\n {},\n () => {\n this.initUser();\n if (showToast) {\n this.apiService.toastService.showToast({\n type: 'success',\n text: 'Déconnexion réussie',\n });\n }\n },\n true,\n );\n }\n\n hasRole(role: string): boolean {\n const user = this.userConnected() ?? null;\n return !!user && hasRole(role, user.profiles);\n }\n\n canFetch(ssr: boolean = true): boolean {\n return (\n (ssr && !this.isPlatformBrowser()) || (this.isPlatformBrowser() && this.isRefreshTokenLoaded())\n );\n }\n}\n","import { effect, inject, Injectable, signal } from '@angular/core';\nimport { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';\nimport { AuthService } from './auth.service';\n\ndeclare const google: any;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthGoogleService {\n readonly authService = inject(AuthService);\n readonly environmentService = inject(EnvironmentService);\n\n readonly googleIds = signal<Map<string, boolean>>(new Map());\n\n readonly init = signal<boolean>(false);\n\n constructor() {\n effect(() => {\n if (!this.init() && this.authService.isPlatformBrowser() && this.environmentService.config()) {\n this.init.set(true);\n google.accounts.id.initialize({\n client_id: this.environmentService.config()?.GOOGLE_CLIENT_ID,\n callback: this.handleCredentialResponse.bind(this),\n });\n }\n });\n }\n\n initGoogleAuth(googleButtonid: string = crypto.randomUUID()): void {\n if (!this.authService.isPlatformBrowser()) {\n return;\n }\n const element = document.getElementById(googleButtonid);\n console.log('dsqdlskqdjlkqs', element);\n if (element) {\n this.googleIds.update((ids) => {\n ids.set(googleButtonid, true);\n return ids;\n });\n google.accounts.id.renderButton(document.getElementById(googleButtonid)!, {\n theme: 'outline',\n size: 'medium',\n type: 'icon',\n });\n }\n }\n\n handleCredentialResponse(response: { credential: string }): void {\n this.authService.googleLogin(response.credential);\n }\n\n loginWithGoogle(): void {\n if (\n this.authService.isRefreshTokenLoaded() &&\n this.authService.userConnected() === null &&\n this.authService.isPlatformBrowser()\n ) {\n google.accounts.id.prompt();\n }\n }\n}\n","import { ApiDto } from '@ng-vagabond-lab/ng-dsv/api';\n\nexport const hasRole = (roles: string, userRoles?: ApiDto[]): boolean => {\n const roleSplit = roles.split(',');\n let find = false;\n roleSplit.forEach((role) => {\n if (\n userRoles?.find(\n (userRole) =>\n userRole['roles' as keyof ApiDto]?.toString().includes(role) ||\n userRole['name' as keyof ApiDto] === role,\n )\n ) {\n find = true;\n }\n });\n return find;\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MAaa,aAAa,CAAA;AACb,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACjC,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAE7C,kBAAkB,GAAG,MAAM,EAAM;IACjC,cAAc,GAAG,MAAM,EAAQ;AAExC,IAAA,WAAA,GAAA;QACI,MAAM,CAAC,MAAK;AACR,YAAA,IAAI,IAAI,CAAC,WAAW,CAAC,oBAAoB,EAAE,EAAE;AACzC,gBAAA,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,sBAAsB,CAAC;YACjE;AACJ,QAAA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AAC5D,YAAA,QAAQ,CAAC,MAAsB,CAAC,KAAK,IAAI,CAChD,EACH;YACE,IAAI,GAAG,IAAI;QACf;AACJ,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,IAAI;AACf;;ACjBA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiService, ApiDto } from '@ng-vagabond-lab/ng-dsv/api';
|
|
1
|
+
import { ApiService, ApiDto, PageableDto } from '@ng-vagabond-lab/ng-dsv/api';
|
|
2
2
|
import * as _angular_core from '@angular/core';
|
|
3
3
|
import { TransferState, StateKey } from '@angular/core';
|
|
4
4
|
import * as _ngx_translate_core from '@ngx-translate/core';
|
|
@@ -24,7 +24,7 @@ declare abstract class BaseApiService extends BaseService {
|
|
|
24
24
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BaseApiService, never, never, {}, {}, never, never, true, never>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
declare abstract class BaseFetchService<A extends ApiDto | ApiDto[]
|
|
27
|
+
declare abstract class BaseFetchService<A extends ApiDto | ApiDto[] | PageableDto<ApiDto[]>> extends BaseApiService {
|
|
28
28
|
readonly ssr: _angular_core.WritableSignal<boolean>;
|
|
29
29
|
getStateKey(url: string): StateKey<A>;
|
|
30
30
|
getDataFromState(url: string): A | null;
|
|
@@ -33,7 +33,7 @@ declare abstract class BaseFetchService<A extends ApiDto | ApiDto[]> extends Bas
|
|
|
33
33
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<BaseFetchService<any>, never, never, {}, {}, never, never, true, never>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
declare abstract class BaseSearchService<T extends ApiDto> extends BaseFetchService<T[]
|
|
36
|
+
declare abstract class BaseSearchService<T extends ApiDto> extends BaseFetchService<PageableDto<T[]>> {
|
|
37
37
|
readonly datas: _angular_core.WritableSignal<T[]>;
|
|
38
38
|
readonly total: _angular_core.WritableSignal<number | undefined>;
|
|
39
39
|
readonly page: _angular_core.WritableSignal<number>;
|
|
@@ -4,7 +4,7 @@ import { AuthService } from '@ng-vagabond-lab/ng-dsv/module/auth';
|
|
|
4
4
|
import { RouterService } from '@ng-vagabond-lab/ng-dsv/router';
|
|
5
5
|
import { Title, Meta } from '@angular/platform-browser';
|
|
6
6
|
import { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';
|
|
7
|
-
import { ApiService, ApiDto } from '@ng-vagabond-lab/ng-dsv/api';
|
|
7
|
+
import { ApiService, ApiDto, PageableDto } from '@ng-vagabond-lab/ng-dsv/api';
|
|
8
8
|
import * as _ngx_translate_core from '@ngx-translate/core';
|
|
9
9
|
import { ToastService } from '@ng-vagabond-lab/ng-dsv/ds/toast';
|
|
10
10
|
import { I18nService } from '@ng-vagabond-lab/ng-dsv/i18n';
|
|
@@ -75,7 +75,7 @@ declare abstract class BaseRouteContainer extends BaseContainer {
|
|
|
75
75
|
static ɵdir: i0.ɵɵDirectiveDeclaration<BaseRouteContainer, never, never, {}, {}, never, never, true, never>;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
declare abstract class BaseFetchService<A extends ApiDto | ApiDto[]
|
|
78
|
+
declare abstract class BaseFetchService<A extends ApiDto | ApiDto[] | PageableDto<ApiDto[]>> extends BaseApiService {
|
|
79
79
|
readonly ssr: i0.WritableSignal<boolean>;
|
|
80
80
|
getStateKey(url: string): StateKey<A>;
|
|
81
81
|
getDataFromState(url: string): A | null;
|
|
@@ -84,7 +84,7 @@ declare abstract class BaseFetchService<A extends ApiDto | ApiDto[]> extends Bas
|
|
|
84
84
|
static ɵdir: i0.ɵɵDirectiveDeclaration<BaseFetchService<any>, never, never, {}, {}, never, never, true, never>;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
declare abstract class BaseSearchService<T extends ApiDto> extends BaseFetchService<T[]
|
|
87
|
+
declare abstract class BaseSearchService<T extends ApiDto> extends BaseFetchService<PageableDto<T[]>> {
|
|
88
88
|
readonly datas: i0.WritableSignal<T[]>;
|
|
89
89
|
readonly total: i0.WritableSignal<number | undefined>;
|
|
90
90
|
readonly page: i0.WritableSignal<number>;
|