@sneat/app-auth 0.27.50 → 0.27.51
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.
|
@@ -25,12 +25,16 @@ export class SneatAuthenticatedLifecycle {
|
|
|
25
25
|
return;
|
|
26
26
|
this.started = true;
|
|
27
27
|
this.telegram.authenticateIfTelegramWebApp();
|
|
28
|
-
getRedirectResult(this.authState.fbAuth).
|
|
28
|
+
getRedirectResult(this.authState.fbAuth).then(
|
|
29
|
+
// An empty result after a redirect this app started is a silent
|
|
30
|
+
// failure; the auth state service tells the login page.
|
|
31
|
+
(credential) => this.authState.onRedirectSignInResult(credential), (error) => {
|
|
29
32
|
// An email that already has an account surfaces here after a redirect
|
|
30
33
|
// sign-in: keep the credential so it links on the next sign-in.
|
|
31
|
-
|
|
34
|
+
const handled = !!this.authState.rememberPendingCredentialLink(error);
|
|
35
|
+
if (!handled)
|
|
32
36
|
console.error('getRedirectResult failed', error);
|
|
33
|
-
|
|
37
|
+
this.authState.onRedirectSignInError(error, handled);
|
|
34
38
|
});
|
|
35
39
|
this.authState.authState
|
|
36
40
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
@@ -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,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,UAAU,EAEV,UAAU,EACV,WAAW,EAEX,MAAM,EACN,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EACL,aAAa,EACb,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EAEd,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,EAC7B,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;;AAGhE,MAAM,OAAO,2BAA2B;IADxC;QAEU,YAAO,GAAG,KAAK,CAAC;QAEP,aAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACvC,cAAS,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAC1C,WAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,cAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACrC,eAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;
|
|
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,EACN,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,E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AAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC;8GA/CU,2BAA2B;kHAA3B,2BAA2B;;2FAA3B,2BAA2B;kBADvC,UAAU;;AAmDX;oFACoF;AACpF,MAAM,UAAU,kCAAkC,CAChD,MAA0B;IAE1B,MAAM,SAAS,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).then(\n // An empty result after a redirect this app started is a silent\n // failure; the auth state service tells the login page.\n (credential) => this.authState.onRedirectSignInResult(credential),\n (error) => {\n // An email that already has an account surfaces here after a redirect\n // sign-in: keep the credential so it links on the next sign-in.\n const handled = !!this.authState.rememberPendingCredentialLink(error);\n if (!handled) console.error('getRedirectResult failed', error);\n this.authState.onRedirectSignInError(error, handled);\n },\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":"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;
|
|
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;CAgDvC;AAED;oFACoF;AACpF,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CA4BtB"}
|