@sneat/app-auth 0.27.1 → 0.27.3

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.
@@ -8,7 +8,6 @@ import { AnalyticsService, clearCurrentSpace, EnvConfigToken, LOGGER_FACTORY, lo
8
8
  import { provideChunkLoadErrorRecovery, provideErrorLogger, provideSentryAppInitializer, provideSneatAnalytics, } from '@sneat/logging';
9
9
  import { getRedirectResult } from 'firebase/auth';
10
10
  import { filter } from 'rxjs';
11
- import posthog from 'posthog-js';
12
11
  import { provideSneatFirebase } from './provide-sneat-firebase';
13
12
  import * as i0 from "@angular/core";
14
13
  export class SneatAuthenticatedLifecycle {
@@ -53,14 +52,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
53
52
  /** Install in the lazy authenticated route's `providers`. Firebase, analytics,
54
53
  * auth lifecycle and protected API transport are then absent from public routes. */
55
54
  export function provideSneatAuthenticatedProviders(config) {
56
- // Compatibility with getStandardSneatProviders(): start PostHog before the
57
- // analytics fan-out consumes it. This import is intentionally auth-only.
58
- if (config.posthog) {
59
- posthog.init(config.posthog.token, {
60
- ...config.posthog.config,
61
- capture_pageview: false,
62
- });
63
- }
64
55
  const providers = [
65
56
  provideErrorLogger(),
66
57
  provideChunkLoadErrorRecovery(),
@@ -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,EAEV,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,OA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SACxB,CAAC,CAAC;IACL,CAAC;IACD,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,CACjC,MAAM,CAAC,2BAA2B,CAAC,CAAC,KAAK,EAAE,CAC5C;KACF,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 {\n DestroyRef,\n EnvironmentProviders,\n Injectable,\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 posthog from 'posthog-js';\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 // Compatibility with getStandardSneatProviders(): start PostHog before the\n // analytics fan-out consumes it. This import is intentionally auth-only.\n if (config.posthog) {\n posthog.init(config.posthog.token, {\n ...config.posthog.config,\n capture_pageview: false,\n });\n }\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 inject(SneatAuthenticatedLifecycle).start(),\n ),\n ];\n if (config.sentry) providers.push(provideSentryAppInitializer(config.sentry));\n return makeEnvironmentProviders(providers);\n}\n"]}
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,EAEV,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,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M,CAAC,CAAC,CAAC;IAC9E,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import {\n DestroyRef,\n EnvironmentProviders,\n Injectable,\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 inject(SneatAuthenticatedLifecycle).start(),\n ),\n ];\n if (config.sentry) providers.push(provideSentryAppInitializer(config.sentry));\n return makeEnvironmentProviders(providers);\n}\n"]}
@@ -24,18 +24,20 @@ function emulatorAllowed(enabled) {
24
24
  if (!enabled)
25
25
  return false;
26
26
  const hostname = typeof location === 'undefined' ? '' : location.hostname;
27
- if (hostname === 'localhost' || hostname === '127.0.0.1')
27
+ if (hostname === 'localhost' ||
28
+ hostname.endsWith('.localhost') ||
29
+ hostname === '127.0.0.1') {
28
30
  return true;
31
+ }
29
32
  console.error('[provideSneatFirebase] Emulator config present on a non-localhost host ' +
30
33
  `("${hostname || '?'}") — ignoring it.`);
31
34
  return false;
32
35
  }
33
36
  /**
34
- * The single Firebase bootstrap for a Sneat app. Initializes the firebase
35
- * modular SDK directly (`initializeApp`/`getFirestore`/`getAuth`/
36
- * `getAnalytics`) and provides `FirebaseApp`, `Firestore`, `Auth` and
37
- * `Analytics` through Angular DI — `inject(Firestore)`,
38
- * `inject(SNEAT_FIREBASE_AUTH)`, etc.
37
+ * Firebase App + Auth boundary for an app shell that must know whether the
38
+ * visitor is signed in. It deliberately does not import or provide Firestore
39
+ * or Firebase Analytics: put those behind the authenticated route that needs
40
+ * data. `provideSneatFirebase()` remains the compatibility all-in-one API.
39
41
  *
40
42
  * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes
41
43
  * the Capacitor native-vs-web Auth persistence split and the
@@ -46,12 +48,31 @@ function emulatorAllowed(enabled) {
46
48
  * `provideSneatAuthenticatedProviders()` calls it for you; call it directly
47
49
  * only in an app that wires its own authenticated route providers.
48
50
  */
49
- export function provideSneatFirebase(firebaseConfig) {
51
+ export function provideSneatFirebaseAuth(firebaseConfig) {
50
52
  return makeEnvironmentProviders([
51
53
  {
52
54
  provide: SNEAT_FIREBASE_APP,
53
55
  useFactory: () => initializeApp(firebaseConfig),
54
56
  },
57
+ {
58
+ provide: SNEAT_FIREBASE_AUTH,
59
+ useFactory: () => {
60
+ const app = inject(SNEAT_FIREBASE_APP);
61
+ const auth = Capacitor.isNativePlatform()
62
+ ? initializeAuth(app, { persistence: indexedDBLocalPersistence })
63
+ : getAuth(app);
64
+ const emulator = firebaseConfig.emulator;
65
+ if (emulator?.authPort && emulatorAllowed(true)) {
66
+ connectAuthEmulator(auth, `${emulator.authPort === 443 ? 'https' : 'http'}://${emulator.authHost || '127.0.0.1'}:${emulator.authPort}`);
67
+ }
68
+ return auth;
69
+ },
70
+ },
71
+ ]);
72
+ }
73
+ /** Install only where a component actually reads or writes Firestore data. */
74
+ export function provideSneatFirestore(firebaseConfig) {
75
+ return makeEnvironmentProviders([
55
76
  {
56
77
  provide: Firestore,
57
78
  useFactory: () => {
@@ -67,20 +88,11 @@ export function provideSneatFirebase(firebaseConfig) {
67
88
  return firestore;
68
89
  },
69
90
  },
70
- {
71
- provide: SNEAT_FIREBASE_AUTH,
72
- useFactory: () => {
73
- const app = inject(SNEAT_FIREBASE_APP);
74
- const auth = Capacitor.isNativePlatform()
75
- ? initializeAuth(app, { persistence: indexedDBLocalPersistence })
76
- : getAuth(app);
77
- const emulator = firebaseConfig.emulator;
78
- if (emulator?.authPort && emulatorAllowed(true)) {
79
- connectAuthEmulator(auth, `${emulator.authPort === 443 ? 'https' : 'http'}://${emulator.authHost || '127.0.0.1'}:${emulator.authPort}`);
80
- }
81
- return auth;
82
- },
83
- },
91
+ ]);
92
+ }
93
+ /** Install only in the route that has elected to send Firebase Analytics. */
94
+ export function provideSneatFirebaseAnalytics(firebaseConfig) {
95
+ return makeEnvironmentProviders([
84
96
  {
85
97
  provide: SNEAT_FIREBASE_ANALYTICS,
86
98
  useFactory: () => {
@@ -100,4 +112,14 @@ export function provideSneatFirebase(firebaseConfig) {
100
112
  },
101
113
  ]);
102
114
  }
115
+ /** Compatibility bootstrap for existing app roots. New apps should compose
116
+ * `provideSneatFirebaseAuth()` at the shell and add Firestore/Analytics only
117
+ * to their lazy authenticated routes. */
118
+ export function provideSneatFirebase(firebaseConfig) {
119
+ return makeEnvironmentProviders([
120
+ provideSneatFirebaseAuth(firebaseConfig),
121
+ provideSneatFirestore(firebaseConfig),
122
+ provideSneatFirebaseAnalytics(firebaseConfig),
123
+ ]);
124
+ }
103
125
  //# sourceMappingURL=provide-sneat-firebase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"provide-sneat-firebase.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;A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AC;gBACD,IAAI,CAAC;oBACH,MAAM,GAAG,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;oBACvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;gBAC3B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CACX,8EAA8E,EAC9E,KAAK,CACN,CAAC;oBACF,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport { Capacitor } from '@capacitor/core';\nimport {\n IFirebaseConfig,\n SNEAT_FIREBASE_ANALYTICS,\n SNEAT_FIREBASE_APP,\n SNEAT_FIREBASE_AUTH,\n} from '@sneat/core';\nimport { FirebaseApp, initializeApp } from 'firebase/app';\nimport { Analytics, getAnalytics } from 'firebase/analytics';\nimport {\n Auth,\n connectAuthEmulator,\n getAuth,\n indexedDBLocalPersistence,\n initializeAuth,\n} from 'firebase/auth';\nimport {\n Firestore,\n connectFirestoreEmulator,\n getFirestore,\n} from 'firebase/firestore';\n\n/** Re-exported so `Firestore` (a real class in the modular SDK, usable\n * as-is as an Angular DI token) has one import source alongside the tokens\n * below — consumers never need to reach into `firebase/firestore` directly. */\nexport { Firestore } from 'firebase/firestore';\n\n/**\n * The three Firebase instance tokens now live in `@sneat/core` — every lib\n * that injects them (`@sneat/auth-core`, `@sneat/logging`,\n * `@sneat/api-firebase-auth`) sits *below* `@sneat/app-auth` in the graph, so\n * declaring them here would force a dependency cycle. They are re-exported so\n * `import { SNEAT_FIREBASE_AUTH } from '@sneat/app-auth'` — the path\n * documented when they shipped — keeps working unchanged.\n *\n * @see `@sneat/core`'s `firebase.tokens.ts` for the full rationale.\n */\nexport {\n SNEAT_FIREBASE_APP,\n SNEAT_FIREBASE_AUTH,\n SNEAT_FIREBASE_ANALYTICS,\n} from '@sneat/core';\n\nfunction emulatorAllowed(enabled: boolean): boolean {\n if (!enabled) return false;\n const hostname = typeof location === 'undefined' ? '' : location.hostname;\n if (hostname === 'localhost' || hostname === '127.0.0.1') return true;\n console.error(\n '[provideSneatFirebase] Emulator config present on a non-localhost host ' +\n `(\"${hostname || '?'}\") — ignoring it.`,\n );\n return false;\n}\n\n/**\n * The single Firebase bootstrap for a Sneat app. Initializes the firebase\n * modular SDK directly (`initializeApp`/`getFirestore`/`getAuth`/\n * `getAnalytics`) and provides `FirebaseApp`, `Firestore`, `Auth` and\n * `Analytics` through Angular DI — `inject(Firestore)`,\n * `inject(SNEAT_FIREBASE_AUTH)`, etc.\n *\n * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes\n * the Capacitor native-vs-web Auth persistence split and the\n * firestore-emulator-over-443 SSL flag flip.\n *\n * This replaced `getAngularFireProviders()`, removed in @sneat/app-auth\n * 0.27.0 along with the `@angular/fire` dependency itself.\n * `provideSneatAuthenticatedProviders()` calls it for you; call it directly\n * only in an app that wires its own authenticated route providers.\n */\nexport function provideSneatFirebase(\n firebaseConfig: IFirebaseConfig,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SNEAT_FIREBASE_APP,\n useFactory: (): FirebaseApp => initializeApp(firebaseConfig),\n },\n {\n provide: Firestore,\n useFactory: (): Firestore => {\n const app = inject(SNEAT_FIREBASE_APP);\n const firestore = getFirestore(app);\n const emulator = firebaseConfig.emulator;\n if (emulator && emulatorAllowed(true)) {\n connectFirestoreEmulator(\n firestore,\n emulator.firestoreHost || '127.0.0.1',\n emulator.firestorePort,\n );\n if (emulator.firestorePort === 443) {\n (\n firestore as unknown as { _settings: { ssl: boolean } }\n )._settings.ssl = true;\n }\n }\n return firestore;\n },\n },\n {\n provide: SNEAT_FIREBASE_AUTH,\n useFactory: (): Auth => {\n const app = inject(SNEAT_FIREBASE_APP);\n const auth: Auth = Capacitor.isNativePlatform()\n ? initializeAuth(app, { persistence: indexedDBLocalPersistence })\n : getAuth(app);\n const emulator = firebaseConfig.emulator;\n if (emulator?.authPort && emulatorAllowed(true)) {\n connectAuthEmulator(\n auth,\n `${emulator.authPort === 443 ? 'https' : 'http'}://${emulator.authHost || '127.0.0.1'}:${emulator.authPort}`,\n );\n }\n return auth;\n },\n },\n {\n provide: SNEAT_FIREBASE_ANALYTICS,\n useFactory: (): Analytics | null => {\n if (\n !firebaseConfig.measurementId ||\n firebaseConfig.measurementId === 'G-PROVIDE_IF_NEEDED'\n ) {\n return null;\n }\n try {\n const app = inject(SNEAT_FIREBASE_APP);\n return getAnalytics(app);\n } catch (error) {\n console.error(\n '[provideSneatFirebase] getAnalytics() failed — continuing without analytics.',\n error,\n );\n return null;\n }\n },\n },\n ]);\n}\n"]}
1
+ {"version":3,"file":"provide-sneat-firebase.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAe,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAa,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAEL,mBAAmB,EACnB,OAAO,EACP,yBAAyB,EACzB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B;;+EAE+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;GASG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,SAAS,eAAe,CAAC,OAAgB;IACvC,IAAI,CAAC,OAAO;QAAE,OAA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,EAC9E,KAAK,CACN,CAAC;oBACF,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED;;yCAEyC;AACzC,MAAM,UAAU,oBAAoB,CAClC,cAA+B;IAE/B,OAAO,wBAAwB,CAAC;QAC9B,wBAAwB,CAAC,cAAc,CAAC;QACxC,qBAAqB,CAAC,cAAc,CAAC;QACrC,6BAA6B,CAAC,cAAc,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport { Capacitor } from '@capacitor/core';\nimport {\n IFirebaseConfig,\n SNEAT_FIREBASE_ANALYTICS,\n SNEAT_FIREBASE_APP,\n SNEAT_FIREBASE_AUTH,\n} from '@sneat/core';\nimport { FirebaseApp, initializeApp } from 'firebase/app';\nimport { Analytics, getAnalytics } from 'firebase/analytics';\nimport {\n Auth,\n connectAuthEmulator,\n getAuth,\n indexedDBLocalPersistence,\n initializeAuth,\n} from 'firebase/auth';\nimport {\n Firestore,\n connectFirestoreEmulator,\n getFirestore,\n} from 'firebase/firestore';\n\n/** Re-exported so `Firestore` (a real class in the modular SDK, usable\n * as-is as an Angular DI token) has one import source alongside the tokens\n * below — consumers never need to reach into `firebase/firestore` directly. */\nexport { Firestore } from 'firebase/firestore';\n\n/**\n * The three Firebase instance tokens now live in `@sneat/core` — every lib\n * that injects them (`@sneat/auth-core`, `@sneat/logging`,\n * `@sneat/api-firebase-auth`) sits *below* `@sneat/app-auth` in the graph, so\n * declaring them here would force a dependency cycle. They are re-exported so\n * `import { SNEAT_FIREBASE_AUTH } from '@sneat/app-auth'` — the path\n * documented when they shipped — keeps working unchanged.\n *\n * @see `@sneat/core`'s `firebase.tokens.ts` for the full rationale.\n */\nexport {\n SNEAT_FIREBASE_APP,\n SNEAT_FIREBASE_AUTH,\n SNEAT_FIREBASE_ANALYTICS,\n} from '@sneat/core';\n\nfunction emulatorAllowed(enabled: boolean): boolean {\n if (!enabled) return false;\n const hostname = typeof location === 'undefined' ? '' : location.hostname;\n if (\n hostname === 'localhost' ||\n hostname.endsWith('.localhost') ||\n hostname === '127.0.0.1'\n ) {\n return true;\n }\n console.error(\n '[provideSneatFirebase] Emulator config present on a non-localhost host ' +\n `(\"${hostname || '?'}\") — ignoring it.`,\n );\n return false;\n}\n\n/**\n * Firebase App + Auth boundary for an app shell that must know whether the\n * visitor is signed in. It deliberately does not import or provide Firestore\n * or Firebase Analytics: put those behind the authenticated route that needs\n * data. `provideSneatFirebase()` remains the compatibility all-in-one API.\n *\n * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes\n * the Capacitor native-vs-web Auth persistence split and the\n * firestore-emulator-over-443 SSL flag flip.\n *\n * This replaced `getAngularFireProviders()`, removed in @sneat/app-auth\n * 0.27.0 along with the `@angular/fire` dependency itself.\n * `provideSneatAuthenticatedProviders()` calls it for you; call it directly\n * only in an app that wires its own authenticated route providers.\n */\nexport function provideSneatFirebaseAuth(\n firebaseConfig: IFirebaseConfig,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SNEAT_FIREBASE_APP,\n useFactory: (): FirebaseApp => initializeApp(firebaseConfig),\n },\n {\n provide: SNEAT_FIREBASE_AUTH,\n useFactory: (): Auth => {\n const app = inject(SNEAT_FIREBASE_APP);\n const auth: Auth = Capacitor.isNativePlatform()\n ? initializeAuth(app, { persistence: indexedDBLocalPersistence })\n : getAuth(app);\n const emulator = firebaseConfig.emulator;\n if (emulator?.authPort && emulatorAllowed(true)) {\n connectAuthEmulator(\n auth,\n `${emulator.authPort === 443 ? 'https' : 'http'}://${emulator.authHost || '127.0.0.1'}:${emulator.authPort}`,\n );\n }\n return auth;\n },\n },\n ]);\n}\n\n/** Install only where a component actually reads or writes Firestore data. */\nexport function provideSneatFirestore(\n firebaseConfig: IFirebaseConfig,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: Firestore,\n useFactory: (): Firestore => {\n const app = inject(SNEAT_FIREBASE_APP);\n const firestore = getFirestore(app);\n const emulator = firebaseConfig.emulator;\n if (emulator && emulatorAllowed(true)) {\n connectFirestoreEmulator(\n firestore,\n emulator.firestoreHost || '127.0.0.1',\n emulator.firestorePort,\n );\n if (emulator.firestorePort === 443) {\n (\n firestore as unknown as { _settings: { ssl: boolean } }\n )._settings.ssl = true;\n }\n }\n return firestore;\n },\n },\n ]);\n}\n\n/** Install only in the route that has elected to send Firebase Analytics. */\nexport function provideSneatFirebaseAnalytics(\n firebaseConfig: IFirebaseConfig,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SNEAT_FIREBASE_ANALYTICS,\n useFactory: (): Analytics | null => {\n if (\n !firebaseConfig.measurementId ||\n firebaseConfig.measurementId === 'G-PROVIDE_IF_NEEDED'\n ) {\n return null;\n }\n try {\n const app = inject(SNEAT_FIREBASE_APP);\n return getAnalytics(app);\n } catch (error) {\n console.error(\n '[provideSneatFirebase] getAnalytics() failed — continuing without analytics.',\n error,\n );\n return null;\n }\n },\n },\n ]);\n}\n\n/** Compatibility bootstrap for existing app roots. New apps should compose\n * `provideSneatFirebaseAuth()` at the shell and add Firestore/Analytics only\n * to their lazy authenticated routes. */\nexport function provideSneatFirebase(\n firebaseConfig: IFirebaseConfig,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideSneatFirebaseAuth(firebaseConfig),\n provideSneatFirestore(firebaseConfig),\n provideSneatFirebaseAnalytics(firebaseConfig),\n ]);\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":"AAAA,OAAO,EAEL,oBAAoB,EAMrB,MAAM,eAAe,CAAC;AAgBvB,OAAO,EAIL,kBAAkB,EAInB,MAAM,aAAa,CAAC;;AAYrB,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,CAkCtB"}
1
+ {"version":3,"file":"provide-sneat-authenticated-providers.d.ts","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-authenticated-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EAMrB,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,CA0BtB"}
@@ -16,11 +16,10 @@ export { Firestore } from 'firebase/firestore';
16
16
  */
17
17
  export { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, SNEAT_FIREBASE_ANALYTICS, } from '@sneat/core';
18
18
  /**
19
- * The single Firebase bootstrap for a Sneat app. Initializes the firebase
20
- * modular SDK directly (`initializeApp`/`getFirestore`/`getAuth`/
21
- * `getAnalytics`) and provides `FirebaseApp`, `Firestore`, `Auth` and
22
- * `Analytics` through Angular DI — `inject(Firestore)`,
23
- * `inject(SNEAT_FIREBASE_AUTH)`, etc.
19
+ * Firebase App + Auth boundary for an app shell that must know whether the
20
+ * visitor is signed in. It deliberately does not import or provide Firestore
21
+ * or Firebase Analytics: put those behind the authenticated route that needs
22
+ * data. `provideSneatFirebase()` remains the compatibility all-in-one API.
24
23
  *
25
24
  * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes
26
25
  * the Capacitor native-vs-web Auth persistence split and the
@@ -31,5 +30,13 @@ export { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, SNEAT_FIREBASE_ANALYTICS, } fr
31
30
  * `provideSneatAuthenticatedProviders()` calls it for you; call it directly
32
31
  * only in an app that wires its own authenticated route providers.
33
32
  */
33
+ export declare function provideSneatFirebaseAuth(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
34
+ /** Install only where a component actually reads or writes Firestore data. */
35
+ export declare function provideSneatFirestore(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
36
+ /** Install only in the route that has elected to send Firebase Analytics. */
37
+ export declare function provideSneatFirebaseAnalytics(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
38
+ /** Compatibility bootstrap for existing app roots. New apps should compose
39
+ * `provideSneatFirebaseAuth()` at the shell and add Firestore/Analytics only
40
+ * to their lazy authenticated routes. */
34
41
  export declare function provideSneatFirebase(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
35
42
  //# sourceMappingURL=provide-sneat-firebase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provide-sneat-firebase.d.ts","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EAIhB,MAAM,aAAa,CAAC;AAgBrB;;+EAE+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;GASG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAarB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAkEtB"}
1
+ {"version":3,"file":"provide-sneat-firebase.d.ts","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,eAAe,EAIhB,MAAM,aAAa,CAAC;AAgBrB;;+EAE+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;GASG;AACH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAmBrB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAwBtB;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAwBtB;AAED,6EAA6E;AAC7E,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAwBtB;AAED;;yCAEyC;AACzC,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAMtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sneat/app-auth",
3
- "version": "0.27.1",
3
+ "version": "0.27.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },