@sneat/app-auth 0.27.5 → 0.27.6
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,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { DestroyRef, Injectable, PLATFORM_ID, inject, makeEnvironmentProviders, provideEnvironmentInitializer, } from '@angular/core';
|
|
2
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
3
4
|
import { NavigationEnd, Router } from '@angular/router';
|
|
4
5
|
import { provideFirebaseSneatApiAuth } from '@sneat/api-firebase-auth';
|
|
@@ -71,7 +72,11 @@ export function provideSneatAuthenticatedProviders(config) {
|
|
|
71
72
|
provide: SNEAT_AUTHENTICATED_LIFECYCLE,
|
|
72
73
|
useExisting: SneatAuthenticatedLifecycle,
|
|
73
74
|
},
|
|
74
|
-
provideEnvironmentInitializer(() =>
|
|
75
|
+
provideEnvironmentInitializer(() => {
|
|
76
|
+
if (isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
77
|
+
inject(SneatAuthenticatedLifecycle).start();
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
75
80
|
];
|
|
76
81
|
if (config.sentry)
|
|
77
82
|
providers.push(provideSentryAppInitializer(config.sentry));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provide-sneat-authenticated-providers.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-authenticated-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,UAAU,
|
|
1
|
+
{"version":3,"file":"provide-sneat-authenticated-providers.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-authenticated-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,UAAU,EAEV,UAAU,EACV,WAAW,EAEX,MAAM,E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AS,GAAwC;QACrD,kBAAkB,EAAE;QACpB,6BAA6B,EAAE;QAC/B,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE;QAC7C,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE;QACpD,oBAAoB,CAAC,MAAM,CAAC,cAAc,CAAC;QAC3C,2BAA2B,EAAE;QAC7B,qBAAqB,CAAC,MAAM,CAAC;QAC7B,qBAAqB;QACrB,cAAc;QACd,gBAAgB;QAChB,mBAAmB;QACnB,2BAA2B;QAC3B,cAAc;QACd,2BAA2B;QAC3B;YACE,OAAO,EAAE,6BAA6B;YACtC,WAAW,EAAE,2BAA2B;SACzC;QACD,6BAA6B,CAAC,GAAG,EAAE;YACjC,IAAI,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,2BAA2B,CAAC,CAAC,KAAK,EAAE,CAAC;YAC9C,CAAC;QACH,CAAC,CAAC;KACH,CAAC;IACF,IAAI,MAAM,CAAC,MAAM;QAAE,SAAS,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9E,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n EnvironmentProviders,\n Injectable,\n PLATFORM_ID,\n Provider,\n inject,\n makeEnvironmentProviders,\n provideEnvironmentInitializer,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { NavigationEnd, Router } from '@angular/router';\nimport { provideFirebaseSneatApiAuth } from '@sneat/api-firebase-auth';\nimport {\n getRouteTitle,\n SNEAT_AUTHENTICATED_LIFECYCLE,\n} from '@sneat/app-public';\nimport {\n AuthStatus,\n LoginRequiredServiceService,\n SneatAuthGuard,\n SneatAuthStateService,\n SneatUserService,\n TelegramAuthService,\n} from '@sneat/auth-core';\nimport {\n AnalyticsService,\n clearCurrentSpace,\n EnvConfigToken,\n IEnvironmentConfig,\n LOGGER_FACTORY,\n loggerFactory,\n TopMenuService,\n} from '@sneat/core';\nimport {\n provideChunkLoadErrorRecovery,\n provideErrorLogger,\n provideSentryAppInitializer,\n provideSneatAnalytics,\n} from '@sneat/logging';\nimport { getRedirectResult } from 'firebase/auth';\nimport { filter } from 'rxjs';\nimport { provideSneatFirebase } from './provide-sneat-firebase';\n\n@Injectable()\nexport class SneatAuthenticatedLifecycle {\n private started = false;\n private authStatus?: AuthStatus;\n private readonly telegram = inject(TelegramAuthService);\n private readonly authState = inject(SneatAuthStateService);\n private readonly router = inject(Router);\n private readonly analytics = inject(AnalyticsService);\n private readonly destroyRef = inject(DestroyRef);\n\n start(): void {\n if (this.started) return;\n this.started = true;\n this.telegram.authenticateIfTelegramWebApp();\n getRedirectResult(this.authState.fbAuth).catch((error) =>\n console.error('getRedirectResult failed', error),\n );\n this.authState.authState\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((state) => (this.authStatus = state.status));\n this.router.events\n .pipe(\n filter((event) => event instanceof NavigationEnd),\n takeUntilDestroyed(this.destroyRef),\n )\n .subscribe((event: NavigationEnd) => {\n this.analytics.logEvent('$pageview', {\n page_path: event.urlAfterRedirects,\n title: getRouteTitle(this.router.routerState.snapshot),\n });\n if (\n this.authStatus === 'authenticated' &&\n !event.urlAfterRedirects.startsWith('/space/') &&\n !event.urlAfterRedirects.startsWith('/login') &&\n !event.urlAfterRedirects.startsWith('/signed-out')\n ) {\n clearCurrentSpace();\n }\n });\n }\n}\n\n/** Install in the lazy authenticated route's `providers`. Firebase, analytics,\n * auth lifecycle and protected API transport are then absent from public routes. */\nexport function provideSneatAuthenticatedProviders(\n config: IEnvironmentConfig,\n): EnvironmentProviders {\n const providers: (Provider | EnvironmentProviders)[] = [\n provideErrorLogger(),\n provideChunkLoadErrorRecovery(),\n { provide: EnvConfigToken, useValue: config },\n { provide: LOGGER_FACTORY, useValue: loggerFactory },\n provideSneatFirebase(config.firebaseConfig),\n provideFirebaseSneatApiAuth(),\n provideSneatAnalytics(config),\n SneatAuthStateService,\n SneatAuthGuard,\n SneatUserService,\n TelegramAuthService,\n LoginRequiredServiceService,\n TopMenuService,\n SneatAuthenticatedLifecycle,\n {\n provide: SNEAT_AUTHENTICATED_LIFECYCLE,\n useExisting: SneatAuthenticatedLifecycle,\n },\n provideEnvironmentInitializer(() => {\n if (isPlatformBrowser(inject(PLATFORM_ID))) {\n inject(SneatAuthenticatedLifecycle).start();\n }\n }),\n ];\n if (config.sentry) providers.push(provideSentryAppInitializer(config.sentry));\n return makeEnvironmentProviders(providers);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provide-sneat-authenticated-providers.d.ts","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-authenticated-providers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provide-sneat-authenticated-providers.d.ts","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-authenticated-providers.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,oBAAoB,EAOrB,MAAM,eAAe,CAAC;AAgBvB,OAAO,EAIL,kBAAkB,EAInB,MAAM,aAAa,CAAC;;AAWrB,qBACa,2BAA2B;IACtC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+B;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAsB;IAEjD,KAAK,IAAI,IAAI;yCATF,2BAA2B;6CAA3B,2BAA2B;CAuCvC;AAED;oFACoF;AACpF,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CA4BtB"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sneat/app-auth",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
+
"@angular/common": ">=22.0.0 <23.0.0",
|
|
8
9
|
"@angular/core": ">=22.0.0 <23.0.0",
|
|
9
10
|
"@angular/router": ">=22.0.0 <23.0.0",
|
|
10
11
|
"@capacitor/core": ">=8.0.0 <9.0.0",
|