@sneat/app-auth 0.26.5 → 0.27.0

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.
package/esm2022/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './lib/provide-sneat-authenticated-providers';
2
- export * from './lib/init-firebase';
3
2
  export * from './lib/provide-sneat-firebase';
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/app-auth/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC","sourcesContent":["export * from './lib/provide-sneat-authenticated-providers';\nexport * from './lib/init-firebase';\nexport * from './lib/provide-sneat-firebase';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/app-auth/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC","sourcesContent":["export * from './lib/provide-sneat-authenticated-providers';\nexport * from './lib/provide-sneat-firebase';\n"]}
@@ -9,7 +9,7 @@ import { provideChunkLoadErrorRecovery, provideErrorLogger, provideSentryAppInit
9
9
  import { getRedirectResult } from 'firebase/auth';
10
10
  import { filter } from 'rxjs';
11
11
  import posthog from 'posthog-js';
12
- import { getAngularFireProviders } from './init-firebase';
12
+ import { provideSneatFirebase } from './provide-sneat-firebase';
13
13
  import * as i0 from "@angular/core";
14
14
  export class SneatAuthenticatedLifecycle {
15
15
  constructor() {
@@ -66,7 +66,7 @@ export function provideSneatAuthenticatedProviders(config) {
66
66
  provideChunkLoadErrorRecovery(),
67
67
  { provide: EnvConfigToken, useValue: config },
68
68
  { provide: LOGGER_FACTORY, useValue: loggerFactory },
69
- ...getAngularFireProviders(config.firebaseConfig),
69
+ provideSneatFirebase(config.firebaseConfig),
70
70
  provideFirebaseSneatApiAuth(),
71
71
  provideSneatAnalytics(config),
72
72
  SneatAuthStateService,
@@ -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,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,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;;AAG1D,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,CA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ider,\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 { getAngularFireProviders } from './init-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 ...getAngularFireProviders(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,EAA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AAM;YACxB,gBAAgB,EAAE,KAAK;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,7 +1,8 @@
1
- import { InjectionToken, inject, makeEnvironmentProviders, } from '@angular/core';
1
+ import { inject, makeEnvironmentProviders, } from '@angular/core';
2
2
  import { Capacitor } from '@capacitor/core';
3
+ import { SNEAT_FIREBASE_ANALYTICS, SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, } from '@sneat/core';
3
4
  import { initializeApp } from 'firebase/app';
4
- import { getAnalytics, } from 'firebase/analytics';
5
+ import { getAnalytics } from 'firebase/analytics';
5
6
  import { connectAuthEmulator, getAuth, indexedDBLocalPersistence, initializeAuth, } from 'firebase/auth';
6
7
  import { Firestore, connectFirestoreEmulator, getFirestore, } from 'firebase/firestore';
7
8
  /** Re-exported so `Firestore` (a real class in the modular SDK, usable
@@ -9,30 +10,16 @@ import { Firestore, connectFirestoreEmulator, getFirestore, } from 'firebase/fir
9
10
  * below — consumers never need to reach into `firebase/firestore` directly. */
10
11
  export { Firestore } from 'firebase/firestore';
11
12
  /**
12
- * DI token for the app's initialized `firebase/app` `FirebaseApp` instance.
13
+ * The three Firebase instance tokens now live in `@sneat/core` — every lib
14
+ * that injects them (`@sneat/auth-core`, `@sneat/logging`,
15
+ * `@sneat/api-firebase-auth`) sits *below* `@sneat/app-auth` in the graph, so
16
+ * declaring them here would force a dependency cycle. They are re-exported so
17
+ * `import { SNEAT_FIREBASE_AUTH } from '@sneat/app-auth'` — the path
18
+ * documented when they shipped — keeps working unchanged.
13
19
  *
14
- * `FirebaseApp` is a plain interface in the modular SDK (no runtime class),
15
- * so — unlike `Firestore` — it cannot be used as an injection token by
16
- * itself; inject this token instead, e.g. `inject(SNEAT_FIREBASE_APP)`.
20
+ * @see `@sneat/core`'s `firebase.tokens.ts` for the full rationale.
17
21
  */
18
- export const SNEAT_FIREBASE_APP = new InjectionToken('SNEAT_FIREBASE_APP');
19
- /**
20
- * DI token for the app's initialized `firebase/auth` `Auth` instance.
21
- * Same rationale as `SNEAT_FIREBASE_APP`: `Auth` is interface-only upstream.
22
- */
23
- export const SNEAT_FIREBASE_AUTH = new InjectionToken('SNEAT_FIREBASE_AUTH');
24
- /**
25
- * DI token for the app's `firebase/analytics` `Analytics` instance.
26
- *
27
- * Resolves to `null` — never throws — when analytics isn't configured (no
28
- * real `measurementId`, using the fleet's `'G-PROVIDE_IF_NEEDED'` sentinel)
29
- * or when `getAnalytics()` throws in an environment that doesn't support it
30
- * (SSR, some webviews, privacy-hardened browsers). The factory only runs the
31
- * first time something actually injects this token, so an app that never
32
- * injects it never pays for Analytics initialization at all — consumers must
33
- * treat the value as optional either way.
34
- */
35
- export const SNEAT_FIREBASE_ANALYTICS = new InjectionToken('SNEAT_FIREBASE_ANALYTICS');
22
+ export { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, SNEAT_FIREBASE_ANALYTICS, } from '@sneat/core';
36
23
  function emulatorAllowed(enabled) {
37
24
  if (!enabled)
38
25
  return false;
@@ -44,24 +31,20 @@ function emulatorAllowed(enabled) {
44
31
  return false;
45
32
  }
46
33
  /**
47
- * `@angular/fire`-free replacement for `getAngularFireProviders()` (see
48
- * `./init-firebase`). Initializes the firebase modular SDK directly
49
- * (`initializeApp`/`getFirestore`/`getAuth`/`getAnalytics`) and provides
50
- * `FirebaseApp`, `Firestore`, `Auth`, and `Analytics` through Angular DI —
51
- * `inject(Firestore)`, `inject(SNEAT_FIREBASE_AUTH)`, etc. — with no
52
- * `@angular/fire` import anywhere in this file or its call graph.
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.
53
39
  *
54
- * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) mirrors
55
- * `getAngularFireProviders()` exactly, including the Capacitor native-vs-web
56
- * Auth persistence split and the firestore-emulator-over-443 SSL flag flip.
40
+ * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes
41
+ * the Capacitor native-vs-web Auth persistence split and the
42
+ * firestore-emulator-over-443 SSL flag flip.
57
43
  *
58
- * NOT YET wired into `provideSneatAuthenticatedProviders()` / the fleet's
59
- * bootstrap chain. sneat-libs' own internals (`SneatAuthStateService`,
60
- * `FirebaseSneatApiAuthAdapter`, the analytics fan-out, …) still depend on
61
- * `@angular/fire`'s `Auth`/`Firestore`/`Analytics` tokens, and cutting them
62
- * over is a separate, larger pass — see the Step 1 PR description. This
63
- * function exists standalone so it can be adopted incrementally, and so its
64
- * own DI wiring is exercised and tested ahead of that cutover.
44
+ * This replaced `getAngularFireProviders()`, removed in @sneat/app-auth
45
+ * 0.27.0 along with the `@angular/fire` dependency itself.
46
+ * `provideSneatAuthenticatedProviders()` calls it for you; call it directly
47
+ * only in an app that wires its own authenticated route providers.
65
48
  */
66
49
  export function provideSneatFirebase(firebaseConfig) {
67
50
  return makeEnvironmentProviders([
@@ -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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AAQ,IAAI,WAAW,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAC7G,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;SACF;QACD;YACE,OAAO,EAAE,wBAAwB;YACjC,UAAU,EAAE,GAAqB,EAAE;gBACjC,IACE,CAAC,cAAc,CAAC,aAAa;oBAC7B,cAAc,CAAC,aAAa,KAAK,qBAAqB,EACtD,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;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 InjectionToken,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport { Capacitor } from '@capacitor/core';\nimport { IFirebaseConfig } from '@sneat/core';\nimport { FirebaseApp, initializeApp } from 'firebase/app';\nimport {\n Analytics,\n getAnalytics,\n} 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 * DI token for the app's initialized `firebase/app` `FirebaseApp` instance.\n *\n * `FirebaseApp` is a plain interface in the modular SDK (no runtime class),\n * so — unlike `Firestore` — it cannot be used as an injection token by\n * itself; inject this token instead, e.g. `inject(SNEAT_FIREBASE_APP)`.\n */\nexport const SNEAT_FIREBASE_APP = new InjectionToken<FirebaseApp>(\n 'SNEAT_FIREBASE_APP',\n);\n\n/**\n * DI token for the app's initialized `firebase/auth` `Auth` instance.\n * Same rationale as `SNEAT_FIREBASE_APP`: `Auth` is interface-only upstream.\n */\nexport const SNEAT_FIREBASE_AUTH = new InjectionToken<Auth>(\n 'SNEAT_FIREBASE_AUTH',\n);\n\n/**\n * DI token for the app's `firebase/analytics` `Analytics` instance.\n *\n * Resolves to `null` — never throws — when analytics isn't configured (no\n * real `measurementId`, using the fleet's `'G-PROVIDE_IF_NEEDED'` sentinel)\n * or when `getAnalytics()` throws in an environment that doesn't support it\n * (SSR, some webviews, privacy-hardened browsers). The factory only runs the\n * first time something actually injects this token, so an app that never\n * injects it never pays for Analytics initialization at all — consumers must\n * treat the value as optional either way.\n */\nexport const SNEAT_FIREBASE_ANALYTICS = new InjectionToken<Analytics | null>(\n 'SNEAT_FIREBASE_ANALYTICS',\n);\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 * `@angular/fire`-free replacement for `getAngularFireProviders()` (see\n * `./init-firebase`). Initializes the firebase modular SDK directly\n * (`initializeApp`/`getFirestore`/`getAuth`/`getAnalytics`) and provides\n * `FirebaseApp`, `Firestore`, `Auth`, and `Analytics` through Angular DI —\n * `inject(Firestore)`, `inject(SNEAT_FIREBASE_AUTH)`, etc. — with no\n * `@angular/fire` import anywhere in this file or its call graph.\n *\n * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) mirrors\n * `getAngularFireProviders()` exactly, including the Capacitor native-vs-web\n * Auth persistence split and the firestore-emulator-over-443 SSL flag flip.\n *\n * NOT YET wired into `provideSneatAuthenticatedProviders()` / the fleet's\n * bootstrap chain. sneat-libs' own internals (`SneatAuthStateService`,\n * `FirebaseSneatApiAuthAdapter`, the analytics fan-out, …) still depend on\n * `@angular/fire`'s `Auth`/`Firestore`/`Analytics` tokens, and cutting them\n * over is a separate, larger pass — see the Step 1 PR description. This\n * function exists standalone so it can be adopted incrementally, and so its\n * own DI wiring is exercised and tested ahead of that cutover.\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,OAAO,KAAK,CAAC;IAC3B,MAAM,QAAQ,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1E,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACtE,OAAO,CAAC,KAAK,CACX,yEAAyE;QACvE,KAAK,QAAQ,IAAI,GAAG,mBAAmB,CAC1C,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU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CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,QAAQ,CAAC,QAAQ,IAAI,WAAW,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAC7G,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;SACF;QACD;YACE,OAAO,EAAE,wBAAwB;YACjC,UAAU,EAAE,GAAqB,EAAE;gBACjC,IACE,CAAC,cAAc,CAAC,aAAa;oBAC7B,cAAc,CAAC,aAAa,KAAK,qBAAqB,EACtD,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;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"]}
package/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './lib/provide-sneat-authenticated-providers';
2
- export * from './lib/init-firebase';
3
2
  export * from './lib/provide-sneat-firebase';
4
3
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/app-auth/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/app-auth/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6CAA6C,CAAC;AAC5D,cAAc,8BAA8B,CAAC"}
@@ -1,56 +1,35 @@
1
- import { EnvironmentProviders, InjectionToken } from '@angular/core';
1
+ import { EnvironmentProviders } from '@angular/core';
2
2
  import { IFirebaseConfig } from '@sneat/core';
3
- import { FirebaseApp } from 'firebase/app';
4
- import { Analytics } from 'firebase/analytics';
5
- import { Auth } from 'firebase/auth';
6
3
  /** Re-exported so `Firestore` (a real class in the modular SDK, usable
7
4
  * as-is as an Angular DI token) has one import source alongside the tokens
8
5
  * below — consumers never need to reach into `firebase/firestore` directly. */
9
6
  export { Firestore } from 'firebase/firestore';
10
7
  /**
11
- * DI token for the app's initialized `firebase/app` `FirebaseApp` instance.
8
+ * The three Firebase instance tokens now live in `@sneat/core` — every lib
9
+ * that injects them (`@sneat/auth-core`, `@sneat/logging`,
10
+ * `@sneat/api-firebase-auth`) sits *below* `@sneat/app-auth` in the graph, so
11
+ * declaring them here would force a dependency cycle. They are re-exported so
12
+ * `import { SNEAT_FIREBASE_AUTH } from '@sneat/app-auth'` — the path
13
+ * documented when they shipped — keeps working unchanged.
12
14
  *
13
- * `FirebaseApp` is a plain interface in the modular SDK (no runtime class),
14
- * so — unlike `Firestore` — it cannot be used as an injection token by
15
- * itself; inject this token instead, e.g. `inject(SNEAT_FIREBASE_APP)`.
15
+ * @see `@sneat/core`'s `firebase.tokens.ts` for the full rationale.
16
16
  */
17
- export declare const SNEAT_FIREBASE_APP: InjectionToken<FirebaseApp>;
17
+ export { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, SNEAT_FIREBASE_ANALYTICS, } from '@sneat/core';
18
18
  /**
19
- * DI token for the app's initialized `firebase/auth` `Auth` instance.
20
- * Same rationale as `SNEAT_FIREBASE_APP`: `Auth` is interface-only upstream.
21
- */
22
- export declare const SNEAT_FIREBASE_AUTH: InjectionToken<Auth>;
23
- /**
24
- * DI token for the app's `firebase/analytics` `Analytics` instance.
25
- *
26
- * Resolves to `null` — never throws — when analytics isn't configured (no
27
- * real `measurementId`, using the fleet's `'G-PROVIDE_IF_NEEDED'` sentinel)
28
- * or when `getAnalytics()` throws in an environment that doesn't support it
29
- * (SSR, some webviews, privacy-hardened browsers). The factory only runs the
30
- * first time something actually injects this token, so an app that never
31
- * injects it never pays for Analytics initialization at all — consumers must
32
- * treat the value as optional either way.
33
- */
34
- export declare const SNEAT_FIREBASE_ANALYTICS: InjectionToken<Analytics | null>;
35
- /**
36
- * `@angular/fire`-free replacement for `getAngularFireProviders()` (see
37
- * `./init-firebase`). Initializes the firebase modular SDK directly
38
- * (`initializeApp`/`getFirestore`/`getAuth`/`getAnalytics`) and provides
39
- * `FirebaseApp`, `Firestore`, `Auth`, and `Analytics` through Angular DI —
40
- * `inject(Firestore)`, `inject(SNEAT_FIREBASE_AUTH)`, etc. — with no
41
- * `@angular/fire` import anywhere in this file or its call graph.
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.
42
24
  *
43
- * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) mirrors
44
- * `getAngularFireProviders()` exactly, including the Capacitor native-vs-web
45
- * Auth persistence split and the firestore-emulator-over-443 SSL flag flip.
25
+ * Emulator wiring (`connectFirestoreEmulator`/`connectAuthEmulator`) includes
26
+ * the Capacitor native-vs-web Auth persistence split and the
27
+ * firestore-emulator-over-443 SSL flag flip.
46
28
  *
47
- * NOT YET wired into `provideSneatAuthenticatedProviders()` / the fleet's
48
- * bootstrap chain. sneat-libs' own internals (`SneatAuthStateService`,
49
- * `FirebaseSneatApiAuthAdapter`, the analytics fan-out, …) still depend on
50
- * `@angular/fire`'s `Auth`/`Firestore`/`Analytics` tokens, and cutting them
51
- * over is a separate, larger pass — see the Step 1 PR description. This
52
- * function exists standalone so it can be adopted incrementally, and so its
53
- * own DI wiring is exercised and tested ahead of that cutover.
29
+ * This replaced `getAngularFireProviders()`, removed in @sneat/app-auth
30
+ * 0.27.0 along with the `@angular/fire` dependency itself.
31
+ * `provideSneatAuthenticatedProviders()` calls it for you; call it directly
32
+ * only in an app that wires its own authenticated route providers.
54
33
  */
55
34
  export declare function provideSneatFirebase(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
56
35
  //# 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,EACpB,cAAc,EAGf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAiB,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,SAAS,EAEV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,IAAI,EAKL,MAAM,eAAe,CAAC;AAOvB;;+EAE+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,6BAE9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,sBAE/B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,kCAEpC,CAAC;AAaF;;;;;;;;;;;;;;;;;;;GAmBG;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;AAarB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAkEtB"}
package/package.json CHANGED
@@ -1,20 +1,19 @@
1
1
  {
2
2
  "name": "@sneat/app-auth",
3
- "version": "0.26.5",
3
+ "version": "0.27.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "peerDependencies": {
8
8
  "@angular/core": ">=22.0.0 <23.0.0",
9
9
  "@angular/router": ">=22.0.0 <23.0.0",
10
- "@angular/fire": ">=20",
11
10
  "@capacitor/core": ">=8.0.0 <9.0.0",
12
11
  "firebase": "*",
13
- "@sneat/api-firebase-auth": "^0.26.0",
14
- "@sneat/app-public": "^0.26.0",
15
- "@sneat/auth-core": "^0.26.0",
16
- "@sneat/core": "^0.26.0",
17
- "@sneat/logging": "^0.26.0",
12
+ "@sneat/api-firebase-auth": "^0.27.0",
13
+ "@sneat/app-public": "^0.27.0",
14
+ "@sneat/auth-core": "^0.27.0",
15
+ "@sneat/core": "^0.27.0",
16
+ "@sneat/logging": "^0.27.0",
18
17
  "rxjs": ">=7.8.0",
19
18
  "posthog-js": "*"
20
19
  },