@ng-vagabond-lab/ng-dsv 0.0.20 → 0.0.22
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonModule } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, effect, Component, signal, Injectable } from '@angular/core';
|
|
3
|
+
import { inject, effect, afterNextRender, Component, signal, Injectable } from '@angular/core';
|
|
4
4
|
import { DsvButtonComponent } from '@ng-vagabond-lab/ng-dsv/ds/button';
|
|
5
5
|
import * as i1$1 from '@ng-vagabond-lab/ng-dsv/environment';
|
|
6
6
|
import { EnvironmentService } from '@ng-vagabond-lab/ng-dsv/environment';
|
|
@@ -13,7 +13,9 @@ class AuthComponent {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
effect(() => {
|
|
15
15
|
if (this.authService.userConnected() === null) {
|
|
16
|
-
|
|
16
|
+
afterNextRender(() => {
|
|
17
|
+
this.authGoogleService.loginWithGoogle();
|
|
18
|
+
});
|
|
17
19
|
}
|
|
18
20
|
else {
|
|
19
21
|
//this.memberService.initMember(
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 { afterNextRender, 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 afterNextRender(() => {\n this.authGoogleService.loginWithGoogle();\n });\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;gBA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,CAAC,UAAU,CAAC,EAAA;YACd,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9D,SAAC;AACA,aAAA,IAAI,CAAC,EAAE,CAAC,CACZ;AACD,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;;IAGhC,eAAe,GAAA;AACb,QAAA,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;;wGAnCnB,iBAAiB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAAA,IAAA,CAAA,kBAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAjB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cAFhB,MAAM,EAAA,CAAA;;4FAEP,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAH7B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACRD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-vagabond-lab/ng-dsv",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^19.1.7",
|
|
6
6
|
"@angular/core": "^19.1.7"
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"types": "./api/index.d.ts",
|
|
24
24
|
"default": "./fesm2022/ng-vagabond-lab-ng-dsv-api.mjs"
|
|
25
25
|
},
|
|
26
|
-
"./auth": {
|
|
27
|
-
"types": "./auth/index.d.ts",
|
|
28
|
-
"default": "./fesm2022/ng-vagabond-lab-ng-dsv-auth.mjs"
|
|
29
|
-
},
|
|
30
26
|
"./base": {
|
|
31
27
|
"types": "./base/index.d.ts",
|
|
32
28
|
"default": "./fesm2022/ng-vagabond-lab-ng-dsv-base.mjs"
|
|
33
29
|
},
|
|
30
|
+
"./auth": {
|
|
31
|
+
"types": "./auth/index.d.ts",
|
|
32
|
+
"default": "./fesm2022/ng-vagabond-lab-ng-dsv-auth.mjs"
|
|
33
|
+
},
|
|
34
34
|
"./environment": {
|
|
35
35
|
"types": "./environment/index.d.ts",
|
|
36
36
|
"default": "./fesm2022/ng-vagabond-lab-ng-dsv-environment.mjs"
|