@sneat/app-auth 0.27.51 → 0.27.52

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,3 +1,4 @@
1
1
  export * from './lib/provide-sneat-authenticated-providers';
2
2
  export * from './lib/provide-sneat-firebase';
3
+ export * from './lib/provide-sneat-firebase-analytics';
3
4
  //# 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,8BAA8B,CAAC","sourcesContent":["export * from './lib/provide-sneat-authenticated-providers';\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;AAC7C,cAAc,wCAAwC,CAAC","sourcesContent":["export * from './lib/provide-sneat-authenticated-providers';\nexport * from './lib/provide-sneat-firebase';\nexport * from './lib/provide-sneat-firebase-analytics';\n"]}
@@ -9,7 +9,7 @@ import { AnalyticsService, clearCurrentSpace, EnvConfigToken, LOGGER_FACTORY, lo
9
9
  import { provideChunkLoadErrorRecovery, provideErrorLogger, provideSentryAppInitializer, provideSneatAnalytics, } from '@sneat/logging';
10
10
  import { getRedirectResult } from 'firebase/auth';
11
11
  import { filter } from 'rxjs';
12
- import { provideSneatFirebase } from './provide-sneat-firebase';
12
+ import { provideSneatFirebase } from './provide-sneat-firebase-analytics';
13
13
  import * as i0 from "@angular/core";
14
14
  export class SneatAuthenticatedLifecycle {
15
15
  constructor() {
@@ -54,10 +54,10 @@ export class SneatAuthenticatedLifecycle {
54
54
  }
55
55
  });
56
56
  }
57
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SneatAuthenticatedLifecycle, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
58
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SneatAuthenticatedLifecycle }); }
57
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: SneatAuthenticatedLifecycle, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
58
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: SneatAuthenticatedLifecycle }); }
59
59
  }
60
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SneatAuthenticatedLifecycle, decorators: [{
60
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: SneatAuthenticatedLifecycle, decorators: [{
61
61
  type: Injectable
62
62
  }] });
63
63
  /** Install in the lazy authenticated route's `providers`. Firebase, analytics,
@@ -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,gBA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AAM,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
+ {"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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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-analytics';\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"]}
@@ -0,0 +1,45 @@
1
+ // Firebase Analytics lives in its own module, apart from the App/Auth/Firestore
2
+ // providers in ./provide-sneat-firebase. `firebase/analytics` registers its
3
+ // component when the module loads, so a bundler keeps it whenever the module
4
+ // that imports it is kept. With the import here, an app that only uses
5
+ // provideSneatFirebaseAuth()/provideSneatFirestore() (AskStage, for one) no
6
+ // longer ships Firebase Analytics in its main bundle; apps that install
7
+ // provideSneatFirebaseAnalytics() or provideSneatFirebase() get it as before.
8
+ // Keep every `firebase/analytics` import of this library in this file.
9
+ import { inject, makeEnvironmentProviders, } from '@angular/core';
10
+ import { SNEAT_FIREBASE_ANALYTICS, SNEAT_FIREBASE_APP, } from '@sneat/core';
11
+ import { getAnalytics } from 'firebase/analytics';
12
+ import { provideSneatFirebaseAuth, provideSneatFirestore, } from './provide-sneat-firebase';
13
+ /** Install only in the route that has elected to send Firebase Analytics. */
14
+ export function provideSneatFirebaseAnalytics(firebaseConfig) {
15
+ return makeEnvironmentProviders([
16
+ {
17
+ provide: SNEAT_FIREBASE_ANALYTICS,
18
+ useFactory: () => {
19
+ if (!firebaseConfig.measurementId ||
20
+ firebaseConfig.measurementId === 'G-PROVIDE_IF_NEEDED') {
21
+ return null;
22
+ }
23
+ try {
24
+ const app = inject(SNEAT_FIREBASE_APP);
25
+ return getAnalytics(app);
26
+ }
27
+ catch (error) {
28
+ console.error('[provideSneatFirebase] getAnalytics() failed — continuing without analytics.', error);
29
+ return null;
30
+ }
31
+ },
32
+ },
33
+ ]);
34
+ }
35
+ /** Compatibility bootstrap for existing app roots. New apps should compose
36
+ * `provideSneatFirebaseAuth()` at the shell and add Firestore/Analytics only
37
+ * to their lazy authenticated routes. */
38
+ export function provideSneatFirebase(firebaseConfig) {
39
+ return makeEnvironmentProviders([
40
+ provideSneatFirebaseAuth(firebaseConfig),
41
+ provideSneatFirestore(firebaseConfig),
42
+ provideSneatFirebaseAnalytics(firebaseConfig),
43
+ ]);
44
+ }
45
+ //# sourceMappingURL=provide-sneat-firebase-analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provide-sneat-firebase-analytics.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase-analytics.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,6EAA6E;AAC7E,uEAAuE;AACvE,4EAA4E;AAC5E,wEAAwE;AACxE,8EAA8E;AAC9E,uEAAuE;AAEvE,OAAO,EAEL,MAAM,EACN,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAa,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,6EAA6E;AAC7E,MAAM,UAAU,6BAA6B,CAC3C,cAA+B;IAE/B,OAAO,wBAAwB,CAAC;QAC9B;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;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":["// Firebase Analytics lives in its own module, apart from the App/Auth/Firestore\n// providers in ./provide-sneat-firebase. `firebase/analytics` registers its\n// component when the module loads, so a bundler keeps it whenever the module\n// that imports it is kept. With the import here, an app that only uses\n// provideSneatFirebaseAuth()/provideSneatFirestore() (AskStage, for one) no\n// longer ships Firebase Analytics in its main bundle; apps that install\n// provideSneatFirebaseAnalytics() or provideSneatFirebase() get it as before.\n// Keep every `firebase/analytics` import of this library in this file.\n\nimport {\n EnvironmentProviders,\n inject,\n makeEnvironmentProviders,\n} from '@angular/core';\nimport {\n IFirebaseConfig,\n SNEAT_FIREBASE_ANALYTICS,\n SNEAT_FIREBASE_APP,\n} from '@sneat/core';\nimport { Analytics, getAnalytics } from 'firebase/analytics';\nimport {\n provideSneatFirebaseAuth,\n provideSneatFirestore,\n} from './provide-sneat-firebase';\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,8 +1,7 @@
1
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
+ import { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, } from '@sneat/core';
4
4
  import { initializeApp } from 'firebase/app';
5
- import { getAnalytics } from 'firebase/analytics';
6
5
  import { connectAuthEmulator, getAuth, indexedDBLocalPersistence, initializeAuth, } from 'firebase/auth';
7
6
  import { Firestore, connectFirestoreEmulator, getFirestore, } from 'firebase/firestore';
8
7
  /** Re-exported so `Firestore` (a real class in the modular SDK, usable
@@ -90,36 +89,4 @@ export function provideSneatFirestore(firebaseConfig) {
90
89
  },
91
90
  ]);
92
91
  }
93
- /** Install only in the route that has elected to send Firebase Analytics. */
94
- export function provideSneatFirebaseAnalytics(firebaseConfig) {
95
- return makeEnvironmentProviders([
96
- {
97
- provide: SNEAT_FIREBASE_ANALYTICS,
98
- useFactory: () => {
99
- if (!firebaseConfig.measurementId ||
100
- firebaseConfig.measurementId === 'G-PROVIDE_IF_NEEDED') {
101
- return null;
102
- }
103
- try {
104
- const app = inject(SNEAT_FIREBASE_APP);
105
- return getAnalytics(app);
106
- }
107
- catch (error) {
108
- console.error('[provideSneatFirebase] getAnalytics() failed — continuing without analytics.', error);
109
- return null;
110
- }
111
- },
112
- },
113
- ]);
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
- }
125
92
  //# 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;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,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C;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;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
+ {"version":3,"file":"provide-sneat-firebase.js","sourceRoot":"","sources":["../../../../../libs/app-auth/src/lib/provide-sneat-firebase.ts"],"names":[],"mappings":"A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AEjC,SACD,CAAC,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC;oBACzB,CAAC;gBACH,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,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_APP,\n SNEAT_FIREBASE_AUTH,\n} from '@sneat/core';\nimport { FirebaseApp, initializeApp } from 'firebase/app';\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"]}
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './lib/provide-sneat-authenticated-providers';
2
2
  export * from './lib/provide-sneat-firebase';
3
+ export * from './lib/provide-sneat-firebase-analytics';
3
4
  //# 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,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;AAC7C,cAAc,wCAAwC,CAAC"}
@@ -11,7 +11,7 @@ export declare class SneatAuthenticatedLifecycle {
11
11
  private readonly destroyRef;
12
12
  start(): void;
13
13
  static ɵfac: i0.ɵɵFactoryDeclaration<SneatAuthenticatedLifecycle, never>;
14
- static ɵprov: i0.ɵɵInjectableDeclaration<SneatAuthenticatedLifecycle>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
15
15
  }
16
16
  /** Install in the lazy authenticated route's `providers`. Firebase, analytics,
17
17
  * auth lifecycle and protected API transport are then absent from public routes. */
@@ -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;CAgDvC;AAED;oFACoF;AACpF,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CA4BtB"}
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;;CAgDvC;AAED;oFACoF;AACpF,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CA4BtB"}
@@ -0,0 +1,9 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { IFirebaseConfig } from '@sneat/core';
3
+ /** Install only in the route that has elected to send Firebase Analytics. */
4
+ export declare function provideSneatFirebaseAnalytics(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
5
+ /** Compatibility bootstrap for existing app roots. New apps should compose
6
+ * `provideSneatFirebaseAuth()` at the shell and add Firestore/Analytics only
7
+ * to their lazy authenticated routes. */
8
+ export declare function provideSneatFirebase(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
9
+ //# sourceMappingURL=provide-sneat-firebase-analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provide-sneat-firebase-analytics.d.ts","sourceRoot":"","sources":["../../../../libs/app-auth/src/lib/provide-sneat-firebase-analytics.ts"],"names":[],"mappings":"AASA,OAAO,EACL,oBAAoB,EAGrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EAGhB,MAAM,aAAa,CAAC;AAOrB,6EAA6E;AAC7E,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAwBtB;AAED;;yCAEyC;AACzC,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,eAAe,GAC9B,oBAAoB,CAMtB"}
@@ -33,10 +33,4 @@ export { SNEAT_FIREBASE_APP, SNEAT_FIREBASE_AUTH, SNEAT_FIREBASE_ANALYTICS, } fr
33
33
  export declare function provideSneatFirebaseAuth(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
34
34
  /** Install only where a component actually reads or writes Firestore data. */
35
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. */
41
- export declare function provideSneatFirebase(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
42
36
  //# 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;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"}
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,EAGhB,MAAM,aAAa,CAAC;AAerB;;+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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sneat/app-auth",
3
- "version": "0.27.51",
3
+ "version": "0.27.52",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,7 +19,7 @@
19
19
  "posthog-js": "*"
20
20
  },
21
21
  "dependencies": {
22
- "tslib": "2.8.1"
22
+ "tslib": "2.9.1"
23
23
  },
24
24
  "sideEffects": false,
25
25
  "module": "esm2022/sneat-app-auth.js",
@@ -3,4 +3,3 @@
3
3
  */
4
4
  /// <amd-module name="@sneat/app-auth" />
5
5
  export * from './index';
6
- //# sourceMappingURL=sneat-app-auth.d.ts.map