@arsedizioni/ars-utils 21.2.270 → 21.2.272

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.
@@ -155,7 +155,7 @@ class LoginOAuthComponent {
155
155
  "api://6b2c080f-6ab0-4511-a9df-0bce69db5833/AngularSPAAuthScope"
156
156
  ],
157
157
  account: r.account
158
- }).subscribe({
158
+ }).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
159
159
  next: (tokenResult) => {
160
160
  console.log("Token acquired!");
161
161
  this.success.emit({ type: 1, token: tokenResult.accessToken });
@@ -1 +1 @@
1
- {"version":3,"file":"arsedizioni-ars-utils-ui.oauth.mjs","sources":["../../../projects/ars-utils/ui.oauth/ui/definitions.ts","../../../projects/ars-utils/ui.oauth/ui/ui.module.ts","../../../projects/ars-utils/ui.oauth/ui/components/login/login-oauth.component.ts","../../../projects/ars-utils/ui.oauth/ui/components/login/login-oauth.component.html","../../../projects/ars-utils/ui.oauth/ui/components/login-ok/ms/login-oauth-ok-ms.component.ts","../../../projects/ars-utils/ui.oauth/ui/components/login-ok/ms/login-oauth-ok-ms.component.html","../../../projects/ars-utils/ui.oauth/public_api.ts","../../../projects/ars-utils/ui.oauth/arsedizioni-ars-utils-ui.oauth.ts"],"sourcesContent":["export enum LoginOAuthType {\r\n None = 0,\r\n Microsoft = 1,\r\n Google = 2\r\n}\r\n\r\nexport interface LoginOAuthResult {\r\n type: number,\r\n token: string\r\n}","import { NgModule } from \"@angular/core\";\r\n\r\n\r\n@NgModule()\r\nexport class ArsUIOAuthModule { }\r\n\r\nexport * from \"./definitions\";\r\n\r\n\r\n","import { ChangeDetectionStrategy, Component, DestroyRef, NgZone, inject, input, output, signal } from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { EnvironmentService } from '@arsedizioni/ars-utils/core';\r\nimport { DialogService } from '@arsedizioni/ars-utils/ui';\r\nimport { MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalBroadcastService, MsalGuardConfiguration, MsalInterceptorConfiguration, MsalService } from '@azure/msal-angular';\r\nimport { AuthenticationResult, BrowserCacheLocation, EventMessage, EventType, IPublicClientApplication, InteractionType, PublicClientApplication } from '@azure/msal-browser';\r\nimport { filter } from 'rxjs';\r\nimport { LoginOAuthResult } from '../../definitions';\r\n\r\nexport function MSALInstanceFactory(environment: EnvironmentService): IPublicClientApplication {\r\n return new PublicClientApplication({\r\n auth: {\r\n clientId: \"6b2c080f-6ab0-4511-a9df-0bce69db5833\",\r\n authority: \"https://login.microsoftonline.com/common\",\r\n redirectUri: environment.appLoginRedirectUri,\r\n },\r\n cache: {\r\n cacheLocation: BrowserCacheLocation.LocalStorage\r\n }\r\n });\r\n}\r\n\r\nexport function MSALInterceptorConfigFactory(environment: EnvironmentService): MsalInterceptorConfiguration {\r\n\r\n return {\r\n interactionType: InteractionType.Popup,\r\n protectedResourceMap: new Map([\r\n [environment.appServiceLoginUri, [\"api://6b2c080f-6ab0-4511-a9df-0bce69db5833/AngularSPAAuthScope\"]],\r\n [\"https://graph.microsoft.com/v2.0/me\", [\"user.read\"]],\r\n ])\r\n };\r\n}\r\n\r\nexport function MSALGuardConfigFactory(): MsalGuardConfiguration {\r\n return {\r\n interactionType: InteractionType.Popup,\r\n authRequest: {\r\n scopes: [\"user.read\"]\r\n }\r\n };\r\n}\r\n\r\n@Component({\r\n selector: 'login-oauth',\r\n templateUrl: './login-oauth.component.html',\r\n styleUrls: ['./login-oauth.component.scss'],\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n providers: [\r\n {\r\n provide: MSAL_INSTANCE,\r\n deps: [EnvironmentService],\r\n useFactory: MSALInstanceFactory\r\n },\r\n {\r\n provide: MSAL_GUARD_CONFIG,\r\n useFactory: MSALGuardConfigFactory\r\n },\r\n {\r\n provide: MSAL_INTERCEPTOR_CONFIG,\r\n deps: [EnvironmentService],\r\n useFactory: MSALInterceptorConfigFactory\r\n },\r\n MsalService,\r\n MsalBroadcastService],\r\n imports: [\r\n MatButtonModule\r\n ]\r\n})\r\nexport class LoginOAuthComponent {\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly msalBroadcastService = inject(MsalBroadcastService);\r\n private readonly msaLService = inject(MsalService);\r\n private readonly dialogService = inject(DialogService);\r\n private readonly ngZone = inject(NgZone);\r\n /** Emitted when OAuth authentication succeeds. */\r\n readonly success = output<LoginOAuthResult>();\r\n /** Whether to show the introductory info panel. */\r\n readonly showInfo = input<boolean>(true);\r\n /** Application name displayed in the info panel. */\r\n readonly applicationName = input<string>();\r\n /** Whether to trigger `initialize()` automatically on mount. */\r\n readonly autoInitialize = input<boolean>(false);\r\n /** Whether the Microsoft login button is shown. */\r\n readonly allowMicrosoft = input<boolean>(true);\r\n /** Whether the Google login button is shown. */\r\n readonly allowGoogle = input<boolean>(true);\r\n protected readonly oauthReady = signal<boolean>(false);\r\n protected readonly oauthMicrosoftReady = signal<boolean>(false);\r\n protected readonly oauthGoogleReady = signal<boolean>(false);\r\n\r\n constructor() {\r\n if (this.autoInitialize()) {\r\n this.initialize();\r\n }\r\n this.msalBroadcastService.msalSubject$\r\n .pipe(\r\n filter((msg: EventMessage) =>\r\n msg.eventType === EventType.LOGOUT_FAILURE ||\r\n msg.eventType === EventType.ACQUIRE_TOKEN_FAILURE),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe((r: EventMessage) => {\r\n if (r?.payload) {\r\n const error = r.payload as any;\r\n this.dialogService.error(error?.message ?? 'Errore di autenticazione Microsoft');\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Initialize OAuth providers (Microsoft MSAL and Google GSI).\r\n * Safe to call multiple times — already-initialized providers are skipped.\r\n * Must be public so the host component can trigger it manually when `autoInitialize` is false.\r\n */\r\n initialize() {\r\n if (this.oauthMicrosoftReady() && this.oauthGoogleReady()) {\r\n return; // Both already loaded\r\n }\r\n this.oauthReady.set(true);\r\n\r\n // Load MS stack only if not already initialized\r\n if (!this.oauthMicrosoftReady()) {\r\n this.msaLService.initialize()\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe(() => {\r\n this.oauthMicrosoftReady.set(true);\r\n });\r\n }\r\n\r\n // Load Google script only if not already initialized\r\n if (!this.oauthGoogleReady()) {\r\n const DSLScript = document.createElement('script');\r\n DSLScript.src = 'https://accounts.google.com/gsi/client';\r\n DSLScript.type = 'text/javascript';\r\n document.body.appendChild(DSLScript);\r\n document.body.removeChild(DSLScript);\r\n\r\n // @ts-ignore\r\n window.onGoogleLibraryLoad = () => {\r\n // initialize google account\r\n // @ts-ignore\r\n google.accounts.id.initialize({\r\n client_id: '71204983077-ag31h3bgt2udcbfr9nn84r9rni2k3snp.apps.googleusercontent.com',\r\n cancel_on_tap_outside: true,\r\n auto_select: false,\r\n callback: (r: any) => {\r\n this.ngZone.run(() => {\r\n this.success.emit({ type: 2, token: r.credential });\r\n });\r\n }\r\n });\r\n\r\n googleButtonWrapper = createFakeGoogleWrapper();\r\n\r\n this.oauthGoogleReady.set(true);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Trigger a Microsoft (MSAL) login popup and acquire an access token on success.\r\n */\r\n protected loginMSAL() {\r\n // Clear any in-progress interaction flag that may have been left by a previous incomplete popup\r\n sessionStorage.removeItem('msal.interaction.status');\r\n\r\n this.msaLService.loginPopup()\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe({\r\n next: (r: AuthenticationResult) => {\r\n try {\r\n this.msaLService.instance.setActiveAccount(r.account);\r\n this.msaLService.acquireTokenSilent({\r\n scopes: [\r\n \"api://6b2c080f-6ab0-4511-a9df-0bce69db5833/AngularSPAAuthScope\"\r\n ],\r\n account: r.account\r\n }).subscribe({\r\n next: (tokenResult: AuthenticationResult) => {\r\n console.log(\"Token acquired!\");\r\n this.success.emit({ type: 1, token: tokenResult.accessToken });\r\n },\r\n error: (error: any) => {\r\n this.dialogService.error(error.message);\r\n }\r\n });\r\n } catch (error: any) {\r\n this.dialogService.error(error.message);\r\n }\r\n },\r\n error: (error: any) => {\r\n this.dialogService.error(error.message);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Trigger the hidden Google GSI button to open the Google sign-in flow.\r\n */\r\n protected loginGoogle() {\r\n // Use wrapper click to prevent Illegal invocation exception\r\n googleButtonWrapper.click();\r\n }\r\n}\r\n\r\nconst createFakeGoogleWrapper = () => {\r\n const googleLoginWrapper = document.createElement(\"div\");\r\n // Or you can simple hide it in CSS rule for custom-google-button\r\n googleLoginWrapper.style.display = \"none\";\r\n googleLoginWrapper.classList.add(\"custom-google-button\");\r\n\r\n // Add the wrapper to body\r\n document.body.appendChild(googleLoginWrapper);\r\n\r\n // Use GSI javascript api to render the button inside our wrapper\r\n // You can ignore the properties because this button will not appear\r\n // @ts-ignore\r\n window.google.accounts.id.renderButton(googleLoginWrapper, {\r\n type: \"icon\",\r\n width: \"200\",\r\n });\r\n\r\n const googleLoginWrapperButton =\r\n googleLoginWrapper.querySelector(\"div[role=button]\");\r\n\r\n return {\r\n click: () => {\r\n // @ts-ignore\r\n googleLoginWrapperButton.click();\r\n },\r\n };\r\n};\r\nvar googleButtonWrapper: any;\r\n\r\n","<div class=\"login-oauth\">\r\n @if(showInfo()) {\r\n <div class=\"message\">\r\n <p>Questa sezione consente di accedere al servizio utilizzando un provider OAuth2.</p>\r\n @if(applicationName()) {\r\n <p>La email utilizzata deve essere collegata ad un utente valido di {{applicationName()}} e dei servizi ad esso\r\n connessi.</p>\r\n }\r\n </div>\r\n }\r\n @if (allowMicrosoft()) {\r\n <div class=\"button\">\r\n <button mat-flat-button (click)=\"loginMSAL()\" aria-label=\"Effettua accesso\"\r\n [disabled]=\"!oauthMicrosoftReady()\" style=\"width: 100%;\">\r\n Accedi con Microsoft</button>\r\n </div>\r\n }\r\n @if (allowGoogle()) {\r\n <div class=\"button\">\r\n <button mat-flat-button (click)=\"loginGoogle()\" style=\"width: 100%;\"\r\n aria-label=\"Effettua accesso\" [disabled]=\"!oauthGoogleReady()\">\r\n Accedi con Google</button>\r\n </div>\r\n }\r\n</div>\r\n","import { ChangeDetectionStrategy, Component, input } from '@angular/core';\r\nimport { broadcastResponseToMainFrame } from '@azure/msal-browser/redirect-bridge';\r\nimport { FlexModule } from '@ngbracket/ngx-layout/flex';\r\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\r\n\r\n\r\n@Component({\r\n selector: 'app-login-oauth-ok-ms',\r\n styleUrls: ['./login-oauth-ok-ms.component.scss'],\r\n templateUrl: './login-oauth-ok-ms.component.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [FlexModule, MatProgressBarModule]\r\n})\r\nexport class LoginOAuthOkMSComponent {\r\n\r\n /** Message displayed while the popup is completing authentication. */\r\n readonly message = input<string>('Accesso in corso...');\r\n\r\n constructor() {\r\n // MSAL v5 popup flow: parse the auth response from the URL and send\r\n // it back to the opener window via BroadcastChannel, then close the popup.\r\n broadcastResponseToMainFrame();\r\n }\r\n}\r\n","<div fxLayout=\"column\" fxLayoutAlign=\"center center\" fxFill>\r\n <div class=\"login-auto fade-in\">\r\n <div class=\"message\">\r\n Autenticazione in corso...\r\n </div>\r\n <mat-progress-bar mode=\"indeterminate\" color=\"primary\"></mat-progress-bar>\r\n </div>\r\n</div>\r\n","/*\r\n * Public API Surface of ars-utils\r\n */\r\nexport * from './ui/ui.module';\r\nexport * from './ui/components/index';\r\n\r\n\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;IAAY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,cAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,cAAA,CAAA,cAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAa;AACb,IAAA,cAAA,CAAA,cAAA,CAAA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AA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,uBAAuB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,uBAAA,EAAA,MAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,QAAA,ECbpC,2SAQA,EAAA,MAAA,EAAA,CAAA,+KAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,UAAA,EAAA,IAAA,EDGc,UAAU,80CAAE,oBAAoB,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,cAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,aAAA,EAAA,MAAA,CAAA,EAAA,OAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAEjC,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAPnC,SAAS;+BACI,uBAAuB,EAAA,eAAA,EAGhB,uBAAuB,CAAC,MAAM,WACtC,CAAC,UAAU,EAAE,oBAAoB,CAAC,EAAA,QAAA,EAAA,2SAAA,EAAA,MAAA,EAAA,CAAA,+KAAA,CAAA,EAAA;;;AEX/C;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"arsedizioni-ars-utils-ui.oauth.mjs","sources":["../../../projects/ars-utils/ui.oauth/ui/definitions.ts","../../../projects/ars-utils/ui.oauth/ui/ui.module.ts","../../../projects/ars-utils/ui.oauth/ui/components/login/login-oauth.component.ts","../../../projects/ars-utils/ui.oauth/ui/components/login/login-oauth.component.html","../../../projects/ars-utils/ui.oauth/ui/components/login-ok/ms/login-oauth-ok-ms.component.ts","../../../projects/ars-utils/ui.oauth/ui/components/login-ok/ms/login-oauth-ok-ms.component.html","../../../projects/ars-utils/ui.oauth/public_api.ts","../../../projects/ars-utils/ui.oauth/arsedizioni-ars-utils-ui.oauth.ts"],"sourcesContent":["export enum LoginOAuthType {\r\n None = 0,\r\n Microsoft = 1,\r\n Google = 2\r\n}\r\n\r\nexport interface LoginOAuthResult {\r\n type: number,\r\n token: string\r\n}","import { NgModule } from \"@angular/core\";\r\n\r\n\r\n@NgModule()\r\nexport class ArsUIOAuthModule { }\r\n\r\nexport * from \"./definitions\";\r\n\r\n\r\n","import { ChangeDetectionStrategy, Component, DestroyRef, NgZone, inject, input, output, signal } from '@angular/core';\r\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { EnvironmentService } from '@arsedizioni/ars-utils/core';\r\nimport { DialogService } from '@arsedizioni/ars-utils/ui';\r\nimport { MSAL_GUARD_CONFIG, MSAL_INSTANCE, MSAL_INTERCEPTOR_CONFIG, MsalBroadcastService, MsalGuardConfiguration, MsalInterceptorConfiguration, MsalService } from '@azure/msal-angular';\r\nimport { AuthenticationResult, BrowserCacheLocation, EventMessage, EventType, IPublicClientApplication, InteractionType, PublicClientApplication } from '@azure/msal-browser';\r\nimport { filter } from 'rxjs';\r\nimport { LoginOAuthResult } from '../../definitions';\r\n\r\nexport function MSALInstanceFactory(environment: EnvironmentService): IPublicClientApplication {\r\n return new PublicClientApplication({\r\n auth: {\r\n clientId: \"6b2c080f-6ab0-4511-a9df-0bce69db5833\",\r\n authority: \"https://login.microsoftonline.com/common\",\r\n redirectUri: environment.appLoginRedirectUri,\r\n },\r\n cache: {\r\n cacheLocation: BrowserCacheLocation.LocalStorage\r\n }\r\n });\r\n}\r\n\r\nexport function MSALInterceptorConfigFactory(environment: EnvironmentService): MsalInterceptorConfiguration {\r\n\r\n return {\r\n interactionType: InteractionType.Popup,\r\n protectedResourceMap: new Map([\r\n [environment.appServiceLoginUri, [\"api://6b2c080f-6ab0-4511-a9df-0bce69db5833/AngularSPAAuthScope\"]],\r\n [\"https://graph.microsoft.com/v2.0/me\", [\"user.read\"]],\r\n ])\r\n };\r\n}\r\n\r\nexport function MSALGuardConfigFactory(): MsalGuardConfiguration {\r\n return {\r\n interactionType: InteractionType.Popup,\r\n authRequest: {\r\n scopes: [\"user.read\"]\r\n }\r\n };\r\n}\r\n\r\n@Component({\r\n selector: 'login-oauth',\r\n templateUrl: './login-oauth.component.html',\r\n styleUrls: ['./login-oauth.component.scss'],\r\n standalone: true,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n providers: [\r\n {\r\n provide: MSAL_INSTANCE,\r\n deps: [EnvironmentService],\r\n useFactory: MSALInstanceFactory\r\n },\r\n {\r\n provide: MSAL_GUARD_CONFIG,\r\n useFactory: MSALGuardConfigFactory\r\n },\r\n {\r\n provide: MSAL_INTERCEPTOR_CONFIG,\r\n deps: [EnvironmentService],\r\n useFactory: MSALInterceptorConfigFactory\r\n },\r\n MsalService,\r\n MsalBroadcastService],\r\n imports: [\r\n MatButtonModule\r\n ]\r\n})\r\nexport class LoginOAuthComponent {\r\n private readonly destroyRef = inject(DestroyRef);\r\n private readonly msalBroadcastService = inject(MsalBroadcastService);\r\n private readonly msaLService = inject(MsalService);\r\n private readonly dialogService = inject(DialogService);\r\n private readonly ngZone = inject(NgZone);\r\n /** Emitted when OAuth authentication succeeds. */\r\n readonly success = output<LoginOAuthResult>();\r\n /** Whether to show the introductory info panel. */\r\n readonly showInfo = input<boolean>(true);\r\n /** Application name displayed in the info panel. */\r\n readonly applicationName = input<string>();\r\n /** Whether to trigger `initialize()` automatically on mount. */\r\n readonly autoInitialize = input<boolean>(false);\r\n /** Whether the Microsoft login button is shown. */\r\n readonly allowMicrosoft = input<boolean>(true);\r\n /** Whether the Google login button is shown. */\r\n readonly allowGoogle = input<boolean>(true);\r\n protected readonly oauthReady = signal<boolean>(false);\r\n protected readonly oauthMicrosoftReady = signal<boolean>(false);\r\n protected readonly oauthGoogleReady = signal<boolean>(false);\r\n\r\n constructor() {\r\n if (this.autoInitialize()) {\r\n this.initialize();\r\n }\r\n this.msalBroadcastService.msalSubject$\r\n .pipe(\r\n filter((msg: EventMessage) =>\r\n msg.eventType === EventType.LOGOUT_FAILURE ||\r\n msg.eventType === EventType.ACQUIRE_TOKEN_FAILURE),\r\n takeUntilDestroyed(this.destroyRef),\r\n )\r\n .subscribe((r: EventMessage) => {\r\n if (r?.payload) {\r\n const error = r.payload as any;\r\n this.dialogService.error(error?.message ?? 'Errore di autenticazione Microsoft');\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Initialize OAuth providers (Microsoft MSAL and Google GSI).\r\n * Safe to call multiple times — already-initialized providers are skipped.\r\n * Must be public so the host component can trigger it manually when `autoInitialize` is false.\r\n */\r\n initialize() {\r\n if (this.oauthMicrosoftReady() && this.oauthGoogleReady()) {\r\n return; // Both already loaded\r\n }\r\n this.oauthReady.set(true);\r\n\r\n // Load MS stack only if not already initialized\r\n if (!this.oauthMicrosoftReady()) {\r\n this.msaLService.initialize()\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe(() => {\r\n this.oauthMicrosoftReady.set(true);\r\n });\r\n }\r\n\r\n // Load Google script only if not already initialized\r\n if (!this.oauthGoogleReady()) {\r\n const DSLScript = document.createElement('script');\r\n DSLScript.src = 'https://accounts.google.com/gsi/client';\r\n DSLScript.type = 'text/javascript';\r\n document.body.appendChild(DSLScript);\r\n document.body.removeChild(DSLScript);\r\n\r\n // @ts-ignore\r\n window.onGoogleLibraryLoad = () => {\r\n // initialize google account\r\n // @ts-ignore\r\n google.accounts.id.initialize({\r\n client_id: '71204983077-ag31h3bgt2udcbfr9nn84r9rni2k3snp.apps.googleusercontent.com',\r\n cancel_on_tap_outside: true,\r\n auto_select: false,\r\n callback: (r: any) => {\r\n this.ngZone.run(() => {\r\n this.success.emit({ type: 2, token: r.credential });\r\n });\r\n }\r\n });\r\n\r\n googleButtonWrapper = createFakeGoogleWrapper();\r\n\r\n this.oauthGoogleReady.set(true);\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Trigger a Microsoft (MSAL) login popup and acquire an access token on success.\r\n */\r\n protected loginMSAL() {\r\n // Clear any in-progress interaction flag that may have been left by a previous incomplete popup\r\n sessionStorage.removeItem('msal.interaction.status');\r\n\r\n this.msaLService.loginPopup()\r\n .pipe(takeUntilDestroyed(this.destroyRef))\r\n .subscribe({\r\n next: (r: AuthenticationResult) => {\r\n try {\r\n this.msaLService.instance.setActiveAccount(r.account);\r\n this.msaLService.acquireTokenSilent({\r\n scopes: [\r\n \"api://6b2c080f-6ab0-4511-a9df-0bce69db5833/AngularSPAAuthScope\"\r\n ],\r\n account: r.account\r\n }).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({\r\n next: (tokenResult: AuthenticationResult) => {\r\n console.log(\"Token acquired!\");\r\n this.success.emit({ type: 1, token: tokenResult.accessToken });\r\n },\r\n error: (error: any) => {\r\n this.dialogService.error(error.message);\r\n }\r\n });\r\n } catch (error: any) {\r\n this.dialogService.error(error.message);\r\n }\r\n },\r\n error: (error: any) => {\r\n this.dialogService.error(error.message);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Trigger the hidden Google GSI button to open the Google sign-in flow.\r\n */\r\n protected loginGoogle() {\r\n // Use wrapper click to prevent Illegal invocation exception\r\n googleButtonWrapper.click();\r\n }\r\n}\r\n\r\nconst createFakeGoogleWrapper = () => {\r\n const googleLoginWrapper = document.createElement(\"div\");\r\n // Or you can simple hide it in CSS rule for custom-google-button\r\n googleLoginWrapper.style.display = \"none\";\r\n googleLoginWrapper.classList.add(\"custom-google-button\");\r\n\r\n // Add the wrapper to body\r\n document.body.appendChild(googleLoginWrapper);\r\n\r\n // Use GSI javascript api to render the button inside our wrapper\r\n // You can ignore the properties because this button will not appear\r\n // @ts-ignore\r\n window.google.accounts.id.renderButton(googleLoginWrapper, {\r\n type: \"icon\",\r\n width: \"200\",\r\n });\r\n\r\n const googleLoginWrapperButton =\r\n googleLoginWrapper.querySelector(\"div[role=button]\");\r\n\r\n return {\r\n click: () => {\r\n // @ts-ignore\r\n googleLoginWrapperButton.click();\r\n },\r\n };\r\n};\r\nvar googleButtonWrapper: any;\r\n\r\n","<div class=\"login-oauth\">\r\n @if(showInfo()) {\r\n <div class=\"message\">\r\n <p>Questa sezione consente di accedere al servizio utilizzando un provider OAuth2.</p>\r\n @if(applicationName()) {\r\n <p>La email utilizzata deve essere collegata ad un utente valido di {{applicationName()}} e dei servizi ad esso\r\n connessi.</p>\r\n }\r\n </div>\r\n }\r\n @if (allowMicrosoft()) {\r\n <div class=\"button\">\r\n <button mat-flat-button (click)=\"loginMSAL()\" aria-label=\"Effettua accesso\"\r\n [disabled]=\"!oauthMicrosoftReady()\" style=\"width: 100%;\">\r\n Accedi con Microsoft</button>\r\n </div>\r\n }\r\n @if (allowGoogle()) {\r\n <div class=\"button\">\r\n <button mat-flat-button (click)=\"loginGoogle()\" style=\"width: 100%;\"\r\n aria-label=\"Effettua accesso\" [disabled]=\"!oauthGoogleReady()\">\r\n Accedi con Google</button>\r\n </div>\r\n }\r\n</div>\r\n","import { ChangeDetectionStrategy, Component, input } from '@angular/core';\r\nimport { broadcastResponseToMainFrame } from '@azure/msal-browser/redirect-bridge';\r\nimport { FlexModule } from '@ngbracket/ngx-layout/flex';\r\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\r\n\r\n\r\n@Component({\r\n selector: 'app-login-oauth-ok-ms',\r\n styleUrls: ['./login-oauth-ok-ms.component.scss'],\r\n templateUrl: './login-oauth-ok-ms.component.html',\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [FlexModule, MatProgressBarModule]\r\n})\r\nexport class LoginOAuthOkMSComponent {\r\n\r\n /** Message displayed while the popup is completing authentication. */\r\n readonly message = input<string>('Accesso in corso...');\r\n\r\n constructor() {\r\n // MSAL v5 popup flow: parse the auth response from the URL and send\r\n // it back to the opener window via BroadcastChannel, then close the popup.\r\n broadcastResponseToMainFrame();\r\n }\r\n}\r\n","<div fxLayout=\"column\" fxLayoutAlign=\"center center\" fxFill>\r\n <div class=\"login-auto fade-in\">\r\n <div class=\"message\">\r\n Autenticazione in corso...\r\n </div>\r\n <mat-progress-bar mode=\"indeterminate\" color=\"primary\"></mat-progress-bar>\r\n </div>\r\n</div>\r\n","/*\r\n * Public API Surface of ars-utils\r\n */\r\nexport * from './ui/ui.module';\r\nexport * from './ui/components/index';\r\n\r\n\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;IAAY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,cAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,cAAA,CAAA,cAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAa;AACb,IAAA,cAAA,CAAA,cAAA,CAAA,QAAA,CAAA,GAAA,CAAA,CAAA,GAAA,QAAU;AACZ,CAAC,EAJW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;MCIb,gBAAgB,CAAA;+GAAhB,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;gHAAhB,gBAAgB,EAAA,CAAA,CAAA;gHAAhB,gBAAgB,EAAA,CAAA,CAAA;;4FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAD5B;;;ACOK,SAAU,mBAAmB,CAAC,WAA+B,EAAA;IACjE,OAAO,IAAI,uBAAuB,CAAC;AACjC,QAAA,IAAI,EAAE;AACJ,YAAA,QAAQ,EAAE,sCAAsC;AAChD,YAAA,SAAS,EAAE,0CA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AAA,UAAA,EAAA,IAAA,EDGc,UAAU,80CAAE,oBAAoB,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,EAAA,CAAA,cAAA,EAAA,QAAA,EAAA,kBAAA,EAAA,MAAA,EAAA,CAAA,OAAA,EAAA,OAAA,EAAA,aAAA,EAAA,MAAA,CAAA,EAAA,OAAA,EAAA,CAAA,cAAA,CAAA,EAAA,QAAA,EAAA,CAAA,gBAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA,CAAA;;4FAEjC,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBAPnC,SAAS;+BACI,uBAAuB,EAAA,eAAA,EAGhB,uBAAuB,CAAC,MAAM,WACtC,CAAC,UAAU,EAAE,oBAAoB,CAAC,EAAA,QAAA,EAAA,2SAAA,EAAA,MAAA,EAAA,CAAA,+KAAA,CAAA,EAAA;;;AEX/C;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arsedizioni/ars-utils",
3
- "version": "21.2.270",
3
+ "version": "21.2.272",
4
4
  "author": {
5
5
  "email": "software@arsedizioni.it",
6
6
  "name": "Fabio Buscaroli, Alberto Doria"
@@ -741,6 +741,7 @@ declare class ClipperBrowserDialogComponent {
741
741
  }
742
742
 
743
743
  declare class ClipperContactEditComponent {
744
+ private readonly destroyRef;
744
745
  private clipperService;
745
746
  private dialogService;
746
747
  private dialogRef;
@@ -1196,6 +1197,7 @@ declare class ClipperNoteBadgeComponent {
1196
1197
 
1197
1198
  declare class ClipperNoteEditComponent {
1198
1199
  readonly done: _angular_core.OutputEmitterRef<ClipperDocumentNote>;
1200
+ private readonly destroyRef;
1199
1201
  private readonly dialogService;
1200
1202
  protected readonly dialogData: EditDialogData<ClipperDocumentNote>;
1201
1203
  protected readonly dialogTitle: _angular_core.WritableSignal<string>;
@@ -382,18 +382,22 @@ declare class SelectTreeDialogComponent implements OnInit {
382
382
  /** Dialog configuration, injected and exposed as a signal. */
383
383
  protected readonly dialogData: _angular_core.WritableSignal<SelectTreeDialogData>;
384
384
  private readonly tree;
385
- protected matTree: MatTree<SelectableNode>;
386
- /** Provides the level of a flat node to the tree component. */
387
- protected readonly levelAccessor: (node: SelectableNode) => number;
388
- /** Flat list of all tree nodes used as the tree data source. */
389
- protected readonly flatNodes: _angular_core.WritableSignal<SelectableNode[]>;
385
+ /** Reference to the Material tree component. */
386
+ protected readonly matTree: _angular_core.Signal<MatTree<ItemNode, ItemNode>>;
387
+ /** Provides children of a tree node to the tree component. */
388
+ protected readonly childrenAccessor: (node: ItemNode) => ItemNode[];
389
+ /** Root nodes used as the tree data source. */
390
+ protected readonly treeNodes: _angular_core.WritableSignal<ItemNode[]>;
390
391
  /** Currently selected tree node. */
391
- protected readonly currentNode: _angular_core.WritableSignal<SelectableNode>;
392
+ protected readonly currentNode: _angular_core.WritableSignal<ItemNode>;
393
+ /** Current filter text, bound via ngModel. */
392
394
  protected filterText: string;
393
- protected filteredItems: SelectableNode[];
394
- protected filterIndex: number;
395
+ /** Nodes matching the current filter text. */
396
+ protected readonly filteredItems: _angular_core.WritableSignal<ItemNode[]>;
397
+ /** Index of the currently highlighted filtered node. */
398
+ protected readonly filterIndex: _angular_core.WritableSignal<number>;
395
399
  protected readonly canAppend: _angular_core.WritableSignal<boolean>;
396
- protected hasChild: (_: number, _node: SelectableNode) => boolean;
400
+ protected hasChild: (_: number, node: ItemNode) => boolean;
397
401
  ngOnInit(): void;
398
402
  /**
399
403
  * Confirm the current selection and close the dialog.
@@ -404,7 +408,7 @@ declare class SelectTreeDialogComponent implements OnInit {
404
408
  * @param e - The mouse event (propagation is stopped).
405
409
  * @param node - The node that was clicked.
406
410
  */
407
- protected select(e: MouseEvent, node: SelectableNode): void;
411
+ protected select(e: MouseEvent, node: ItemNode): void;
408
412
  /**
409
413
  * Clear the active filter text.
410
414
  */
@@ -420,15 +424,22 @@ declare class SelectTreeDialogComponent implements OnInit {
420
424
  protected nextFiltered(): void;
421
425
  /**
422
426
  * Expand a node and all of its parent nodes.
423
- * @param node - The selectable node to expand.
427
+ * @param node - The node to expand.
428
+ * @returns Always false.
424
429
  */
425
- expand(node: SelectableNode): boolean;
430
+ expand(node: ItemNode): boolean;
426
431
  /**
427
- * Recursively flatten a nested ItemNode tree into a depth-first ordered array of SelectableNodes.
428
- * @param items - Root-level nodes to flatten.
429
- * @param level - Current depth level.
432
+ * Recursively get all nodes in depth-first order.
433
+ * @param nodes - Root nodes to traverse.
434
+ * @param result - Accumulator array.
430
435
  */
431
- private flattenNodes;
436
+ private getAllNodes;
437
+ /**
438
+ * Recursively find a node by id.
439
+ * @param nodes - Nodes to search.
440
+ * @param id - The id to find.
441
+ */
442
+ private findInTree;
432
443
  /**
433
444
  * Append a new node to the tree.
434
445
  * @param node - The node to insert.