@ng-vagabond-lab/ng-dsv 0.0.17 → 0.0.20
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthService } from '../public-api';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class AuthComponent {
|
|
4
|
+
private readonly authGoogleService;
|
|
5
|
+
protected authService: AuthService;
|
|
6
|
+
private readonly environmentService;
|
|
7
|
+
constructor();
|
|
8
|
+
logout(): void;
|
|
9
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AuthComponent, never>;
|
|
10
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AuthComponent, "app-auth", never, {}, {}, never, never, true, never>;
|
|
11
|
+
}
|
package/auth/public-api.d.ts
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, Injectable
|
|
3
|
-
import
|
|
3
|
+
import { inject, effect, Component, signal, Injectable } from '@angular/core';
|
|
4
|
+
import { DsvButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/button';
|
|
4
5
|
import * as i1$1 from '@ng-vagabond-lab/ng-dsv/environment';
|
|
6
|
+
import { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';
|
|
7
|
+
import * as i1 from '@ng-vagabond-lab/ng-dsv/api';
|
|
8
|
+
|
|
9
|
+
class AuthComponent {
|
|
10
|
+
authGoogleService = inject(AuthGoogleService);
|
|
11
|
+
authService = inject(AuthService);
|
|
12
|
+
environmentService = inject(EnvironmentService);
|
|
13
|
+
constructor() {
|
|
14
|
+
effect(() => {
|
|
15
|
+
if (this.authService.userConnected() === null) {
|
|
16
|
+
this.authGoogleService.loginWithGoogle();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
//this.memberService.initMember(
|
|
20
|
+
// this.authService.userConnected()?.user?.id
|
|
21
|
+
//);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
effect(() => {
|
|
25
|
+
if (this.environmentService.env()) {
|
|
26
|
+
this.authService.loginFromCache();
|
|
27
|
+
this.authGoogleService.initGoogleAuth();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
logout() {
|
|
32
|
+
this.authService.logout();
|
|
33
|
+
}
|
|
34
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AuthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
35
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.10", type: AuthComponent, isStandalone: true, selector: "app-auth", ngImport: i0, template: "<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [style]=\"authService.userConnected() === null ? '' : 'display: none;'\"\n ></button>\n</div>\n\n@if(authService.userConnected()) {\n<div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <dsv-button\n (callback)=\"logout()\"\n icon=\"ri-logout-box-line\"\n color=\"inherit\"\n ></dsv-button>\n</div>\n}\n", styles: [".auth-button button{margin:0;padding:0;background:transparent;border:0px}.profile{display:flex;gap:.5rem;flex-flow:nowrap;align-items:center}.profile img{width:30px;height:30px;border-radius:50%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: DsvButtonComponent, selector: "dsv-button", inputs: ["libelle", "color", "icon", "iconEnd", "width", "variant", "fullwidth", "show", "disabled"], outputs: ["callback"] }] });
|
|
36
|
+
}
|
|
37
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AuthComponent, decorators: [{
|
|
38
|
+
type: Component,
|
|
39
|
+
args: [{ selector: 'app-auth', imports: [CommonModule, DsvButtonComponent], standalone: true, template: "<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [style]=\"authService.userConnected() === null ? '' : 'display: none;'\"\n ></button>\n</div>\n\n@if(authService.userConnected()) {\n<div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <dsv-button\n (callback)=\"logout()\"\n icon=\"ri-logout-box-line\"\n color=\"inherit\"\n ></dsv-button>\n</div>\n}\n", styles: [".auth-button button{margin:0;padding:0;background:transparent;border:0px}.profile{display:flex;gap:.5rem;flex-flow:nowrap;align-items:center}.profile img{width:30px;height:30px;border-radius:50%}\n"] }]
|
|
40
|
+
}], ctorParameters: () => [] });
|
|
5
41
|
|
|
6
42
|
class AuthService {
|
|
7
43
|
apiService;
|
|
@@ -82,5 +118,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImpo
|
|
|
82
118
|
* Generated bundle index. Do not edit.
|
|
83
119
|
*/
|
|
84
120
|
|
|
85
|
-
export { AuthGoogleService, AuthService };
|
|
121
|
+
export { AuthComponent, AuthGoogleService, AuthService };
|
|
86
122
|
//# sourceMappingURL=ng-vagabond-lab-ng-dsv-auth.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-vagabond-lab-ng-dsv-auth.mjs","sources":["../../../projects/ng-dsv/auth/service/auth.service.ts","../../../projects/ng-dsv/auth/service/auth.google.service.ts","../../../projects/ng-dsv/auth/ng-vagabond-lab-ng-dsv-auth.ts"],"sourcesContent":["import { Injectable, signal, WritableSignal } from '@angular/core';\nimport { ApiService } from '@ng-vagabond-lab/ng-dsv/api';\nimport { IUserConnectedDto } from '../dto/user.dto';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n userConnected: WritableSignal<IUserConnectedDto | null> = signal(null);\n\n constructor(private readonly apiService: ApiService) {}\n\n googleLogin(credential: string) {\n this.apiService.post<IUserConnectedDto>(\n 'auth/google-identity-connect',\n {\n googleToken: credential,\n },\n (data) => {\n localStorage?.setItem('user-connected', JSON.stringify(data));\n this.userConnected.set(data);\n }\n );\n }\n\n loginFromCache() {\n const userConnected =\n typeof window !== 'undefined' &&\n JSON.parse(localStorage?.getItem('user-connected')!);\n this.userConnected.set(userConnected);\n console.info('userConnected', userConnected);\n return userConnected;\n }\n\n logout() {\n localStorage?.removeItem('user-connected');\n this.userConnected.set(null);\n }\n}\n","import { inject, Injectable } 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 private readonly authService = inject(AuthService);\n\n constructor(private readonly environmentService: EnvironmentService) {}\n\n initGoogleAuth() {\n google.accounts.id.initialize({\n client_id: this.environmentService.env()?.GOOGLE_CLIENT_ID,\n callback: this.handleCredentialResponse.bind(this),\n });\n google.accounts.id.renderButton(\n document.getElementById('google-signin-button')!,\n { theme: 'outline', size: 'medium' }\n );\n }\n\n handleCredentialResponse(response: { credential: string }) {\n this.authService.googleLogin(response.credential);\n }\n\n decodeJwtToken(token: string) {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split('')\n .map(function (c) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join('')\n );\n return JSON.parse(jsonPayload);\n }\n\n loginWithGoogle() {\n google?.accounts.id.prompt();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"ng-vagabond-lab-ng-dsv-auth.mjs","sources":["../../../projects/ng-dsv/auth/component/auth.component.ts","../../../projects/ng-dsv/auth/component/auth.component.html","../../../projects/ng-dsv/auth/service/auth.service.ts","../../../projects/ng-dsv/auth/service/auth.google.service.ts","../../../projects/ng-dsv/auth/ng-vagabond-lab-ng-dsv-auth.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { Component, effect, inject } from '@angular/core';\nimport { DsvButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/button';\nimport { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';\nimport { AuthGoogleService, AuthService } from '../public-api';\n\n@Component({\n selector: 'app-auth',\n imports: [CommonModule, DsvButtonComponent],\n standalone: true,\n templateUrl: './auth.component.html',\n styleUrls: ['./auth.component.scss'],\n})\nexport class AuthComponent {\n private readonly authGoogleService = inject(AuthGoogleService);\n protected authService = inject(AuthService);\n private readonly environmentService = inject(EnvironmentService);\n\n constructor() {\n effect(() => {\n if (this.authService.userConnected() === null) {\n this.authGoogleService.loginWithGoogle();\n } else {\n //this.memberService.initMember(\n // this.authService.userConnected()?.user?.id\n //);\n }\n });\n effect(() => {\n if (this.environmentService.env()) {\n this.authService.loginFromCache();\n this.authGoogleService.initGoogleAuth();\n }\n });\n }\n\n logout() {\n this.authService.logout();\n }\n}\n","<div class=\"auth-button\">\n <button\n id=\"google-signin-button\"\n [style]=\"authService.userConnected() === null ? '' : 'display: none;'\"\n ></button>\n</div>\n\n@if(authService.userConnected()) {\n<div class=\"profile\">\n <img [src]=\"authService.userConnected()?.user?.avatar\" alt=\"profile\" />\n <dsv-button\n (callback)=\"logout()\"\n icon=\"ri-logout-box-line\"\n color=\"inherit\"\n ></dsv-button>\n</div>\n}\n","import { Injectable, signal, WritableSignal } from '@angular/core';\nimport { ApiService } from '@ng-vagabond-lab/ng-dsv/api';\nimport { IUserConnectedDto } from '../dto/user.dto';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class AuthService {\n userConnected: WritableSignal<IUserConnectedDto | null> = signal(null);\n\n constructor(private readonly apiService: ApiService) {}\n\n googleLogin(credential: string) {\n this.apiService.post<IUserConnectedDto>(\n 'auth/google-identity-connect',\n {\n googleToken: credential,\n },\n (data) => {\n localStorage?.setItem('user-connected', JSON.stringify(data));\n this.userConnected.set(data);\n }\n );\n }\n\n loginFromCache() {\n const userConnected =\n typeof window !== 'undefined' &&\n JSON.parse(localStorage?.getItem('user-connected')!);\n this.userConnected.set(userConnected);\n console.info('userConnected', userConnected);\n return userConnected;\n }\n\n logout() {\n localStorage?.removeItem('user-connected');\n this.userConnected.set(null);\n }\n}\n","import { inject, Injectable } 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 private readonly authService = inject(AuthService);\n\n constructor(private readonly environmentService: EnvironmentService) {}\n\n initGoogleAuth() {\n google.accounts.id.initialize({\n client_id: this.environmentService.env()?.GOOGLE_CLIENT_ID,\n callback: this.handleCredentialResponse.bind(this),\n });\n google.accounts.id.renderButton(\n document.getElementById('google-signin-button')!,\n { theme: 'outline', size: 'medium' }\n );\n }\n\n handleCredentialResponse(response: { credential: string }) {\n this.authService.googleLogin(response.credential);\n }\n\n decodeJwtToken(token: string) {\n const base64Url = token.split('.')[1];\n const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');\n const jsonPayload = decodeURIComponent(\n atob(base64)\n .split('')\n .map(function (c) {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);\n })\n .join('')\n );\n return JSON.parse(jsonPayload);\n }\n\n loginWithGoogle() {\n google?.accounts.id.prompt();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1"],"mappings":";;;;;;;;MAaa,aAAa,CAAA;AACP,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACpD,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAC1B,IAAA,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;AAEhE,IAAA,WAAA,GAAA;QACE,MAAM,CAAC,MAAK;YACV,IAAI,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;AAC7C,gBAAA,IAAI,CAAC,iBAAiB,CAAC,eAAe,EA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