@sneat/app 0.24.0 → 0.26.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 +1 -3
- package/esm2022/index.js.map +1 -1
- package/esm2022/lib/app-specific-providers.js +1 -7
- package/esm2022/lib/app-specific-providers.js.map +1 -1
- package/esm2022/lib/base-app.component.js +8 -49
- package/esm2022/lib/base-app.component.js.map +1 -1
- package/esm2022/lib/get-standard-sneat-providers.js +17 -60
- package/esm2022/lib/get-standard-sneat-providers.js.map +1 -1
- package/esm2022/lib/init-firebase.js +1 -84
- package/esm2022/lib/init-firebase.js.map +1 -1
- package/esm2022/lib/init-helpers.js +16 -7
- package/esm2022/lib/init-helpers.js.map +1 -1
- package/index.d.ts +1 -3
- package/lib/app-specific-providers.d.ts +1 -2
- package/lib/base-app.component.d.ts +1 -6
- package/lib/get-standard-sneat-providers.d.ts +2 -0
- package/lib/init-firebase.d.ts +1 -4
- package/lib/init-helpers.d.ts +7 -0
- package/package.json +20 -2
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
- package/esm2022/lib/page-title.service.js +0 -42
- package/esm2022/lib/page-title.service.js.map +0 -1
- package/esm2022/lib/register-posthog.js +0 -11
- package/esm2022/lib/register-posthog.js.map +0 -1
- package/esm2022/lib/route-title.js +0 -24
- package/esm2022/lib/route-title.js.map +0 -1
- package/esm2022/lib/sneat-title.strategy.js +0 -28
- package/esm2022/lib/sneat-title.strategy.js.map +0 -1
- package/lib/page-title.service.d.ts +0 -10
- package/lib/register-posthog.d.ts +0 -2
- package/lib/route-title.d.ts +0 -2
- package/lib/sneat-title.strategy.d.ts +0 -8
package/esm2022/index.js
CHANGED
|
@@ -10,7 +10,5 @@ export * from './lib/contact-extensions';
|
|
|
10
10
|
export * from './lib/get-standard-sneat-providers';
|
|
11
11
|
export * from './lib/app-specific-providers';
|
|
12
12
|
export * from './lib/capacitator-http.service';
|
|
13
|
-
export
|
|
14
|
-
export * from './lib/sneat-title.strategy';
|
|
15
|
-
export * from './lib/route-title';
|
|
13
|
+
export { PageTitleService, SneatTitleStrategy, SNEAT_AUTHENTICATED_LIFECYCLE, } from '@sneat/app-public';
|
|
16
14
|
//# sourceMappingURL=index.js.map
|
package/esm2022/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/app/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/app/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC","sourcesContent":["export * from './environments';\nexport * from './lib/base-app.component';\nexport * from './lib/sneat-base-app';\nexport * from './lib/get-standard-sneat-imports';\nexport * from './lib/app-component.service';\nexport * from './environments/environment.local';\nexport * from './lib/init-firebase';\nexport * from './lib/init-helpers';\nexport * from './lib/contact-extensions';\nexport * from './lib/get-standard-sneat-providers';\nexport * from './lib/app-specific-providers';\nexport * from './lib/capacitator-http.service';\nexport {\n PageTitleService,\n SneatTitleStrategy,\n SNEAT_AUTHENTICATED_LIFECYCLE,\n} from '@sneat/app-public';\n"]}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { CONTACT_ROLES_BY_TYPE, } from './contact-extensions';
|
|
2
|
-
|
|
3
|
-
export function provideAppInfo(appInfo) {
|
|
4
|
-
return {
|
|
5
|
-
provide: APP_INFO,
|
|
6
|
-
useValue: appInfo,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
2
|
+
export { provideAppInfo } from '@sneat/app-public';
|
|
9
3
|
export function provideRolesByType(contactRolesByType) {
|
|
10
4
|
return {
|
|
11
5
|
provide: CONTACT_ROLES_BY_TYPE, // at the moment this is supplied by Logistus app only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-specific-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/app-specific-providers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"app-specific-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/app-specific-providers.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAChC,kBAAkD;IAElD,OAAO;QACL,OAAO,EAAE,qBAAqB,EAAE,sDAAsD;QACtF,QAAQ,EAAE,kBAAkB;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["import { Provider } from '@angular/core';\nimport {\n CONTACT_ROLES_BY_TYPE,\n ContactRolesByType,\n} from './contact-extensions';\nexport { provideAppInfo } from '@sneat/app-public';\n\nexport function provideRolesByType(\n contactRolesByType: ContactRolesByType | undefined,\n): Provider {\n return {\n provide: CONTACT_ROLES_BY_TYPE, // at the moment this is supplied by Logistus app only\n useValue: contactRolesByType,\n };\n}\n"]}
|
|
@@ -1,55 +1,14 @@
|
|
|
1
1
|
import { inject } from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AnalyticsService, clearCurrentSpace, TopMenuService, } from '@sneat/core';
|
|
5
|
-
import { getRedirectResult } from 'firebase/auth';
|
|
6
|
-
import { filter } from 'rxjs';
|
|
7
|
-
import { getRouteTitle } from './route-title';
|
|
2
|
+
import { SNEAT_AUTHENTICATED_LIFECYCLE } from '@sneat/app-public';
|
|
3
|
+
import { TopMenuService } from '@sneat/core';
|
|
8
4
|
export class BaseAppComponent {
|
|
9
5
|
constructor() {
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
// Complete any pending signInWithRedirect when the app boots. The
|
|
17
|
-
// authStateService's onIdTokenChanged listener then propagates the
|
|
18
|
-
// signed-in user. Resolves to null (harmless) when sign-in used a popup or
|
|
19
|
-
// there is no pending redirect. Lives here so every app that extends
|
|
20
|
-
// BaseAppComponent gets redirect-based sign-in for free.
|
|
21
|
-
getRedirectResult(this.authStateService.fbAuth).catch((err) => console.error('getRedirectResult failed', err));
|
|
22
|
-
this.authStateService.authState.subscribe((s) => {
|
|
23
|
-
this.authStatus = s.status;
|
|
24
|
-
});
|
|
25
|
-
this.router.events
|
|
26
|
-
.pipe(filter((event) => event instanceof NavigationEnd))
|
|
27
|
-
.subscribe((event) => {
|
|
28
|
-
// The document title itself is owned by SneatTitleStrategy; here we only
|
|
29
|
-
// reuse the same derived page title for the analytics pageview event.
|
|
30
|
-
const title = getRouteTitle(this.router.routerState.snapshot);
|
|
31
|
-
this.analyticsService.logEvent('$pageview', {
|
|
32
|
-
page_path: event.urlAfterRedirects,
|
|
33
|
-
title,
|
|
34
|
-
});
|
|
35
|
-
this.forgetCurrentSpaceIfLeftSpaces(event.urlAfterRedirects);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
// Keep the persisted current space in sync with where an authenticated user is:
|
|
39
|
-
// once they navigate to a non-space page, forget it so login does not bounce them
|
|
40
|
-
// back to a space they had left. Auth routes are ignored so signing out from a
|
|
41
|
-
// space still restores it; the `authenticated` guard preserves the value during
|
|
42
|
-
// the logged-out login flow so the login page can still read it.
|
|
43
|
-
forgetCurrentSpaceIfLeftSpaces(url) {
|
|
44
|
-
if (this.authStatus !== 'authenticated') {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (url.startsWith('/space/') ||
|
|
48
|
-
url.startsWith('/login') ||
|
|
49
|
-
url.startsWith('/signed-out')) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
clearCurrentSpace();
|
|
6
|
+
// Kept protected for existing Ionic-shell templates that inherited it.
|
|
7
|
+
this.topMenuService = inject(TopMenuService);
|
|
8
|
+
this.authenticatedLifecycle = inject(SNEAT_AUTHENTICATED_LIFECYCLE, { optional: true });
|
|
9
|
+
// Legacy full shells install this at root. PrimeNG apps install it in the
|
|
10
|
+
// lazy authenticated route; its environment initializer starts it there.
|
|
11
|
+
this.authenticatedLifecycle?.start();
|
|
53
12
|
}
|
|
54
13
|
}
|
|
55
14
|
//# sourceMappingURL=base-app.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-app.component.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/base-app.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"base-app.component.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/base-app.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,OAAO,gBAAgB;IAQ3B;QAPA,uEAAuE;QACpD,mBAAc,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;QAC1C,2BAAsB,GAAG,MAAM,CAC9C,6BAA6B,EAC7B,EAAE,QAAQ,EAAE,IAAI,EAAE,CACnB,CAAC;QAGA,0EAA0E;QAC1E,yEAAyE;QACzE,IAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,CAAC;IACvC,CAAC;CACF","sourcesContent":["import { inject } from '@angular/core';\nimport { SNEAT_AUTHENTICATED_LIFECYCLE } from '@sneat/app-public';\nimport { TopMenuService } from '@sneat/core';\n\nexport class BaseAppComponent {\n // Kept protected for existing Ionic-shell templates that inherited it.\n protected readonly topMenuService = inject(TopMenuService);\n private readonly authenticatedLifecycle = inject(\n SNEAT_AUTHENTICATED_LIFECYCLE,\n { optional: true },\n );\n\n constructor() {\n // Legacy full shells install this at root. PrimeNG apps install it in the\n // lazy authenticated route; its environment initializer starts it there.\n this.authenticatedLifecycle?.start();\n }\n}\n"]}
|
|
@@ -1,69 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { provideIonicAngular } from '@ionic/angular/standalone';
|
|
6
|
-
import { DefaultSneatAppApiBaseUrl, SneatApiBaseUrl } from '@sneat/api';
|
|
7
|
-
import { TelegramAuthService } from '@sneat/auth-core';
|
|
8
|
-
import { LOGGER_FACTORY, loggerFactory, TopMenuService } from '@sneat/core';
|
|
9
|
-
import { provideChunkLoadErrorRecovery, provideErrorLogger, provideSentryAppInitializer, provideSneatAnalytics, } from '@sneat/logging';
|
|
1
|
+
import { provideSneatAuthenticatedProviders } from '@sneat/app-auth';
|
|
2
|
+
import { provideSneatIonicShell } from '@sneat/app-ionic';
|
|
3
|
+
import { provideSneatPublicBootstrap } from '@sneat/app-public';
|
|
4
|
+
import { EnvConfigToken, TopMenuService } from '@sneat/core';
|
|
10
5
|
import { RANDOM_ID_OPTIONS } from '@sneat/random';
|
|
11
6
|
import { AppComponentService } from './app-component.service';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { SneatTitleStrategy } from './sneat-title.strategy';
|
|
15
|
-
// import { getAngularFireImports } from './init-firebase';
|
|
16
|
-
import { registerPosthog } from './register-posthog';
|
|
7
|
+
/** Legacy all-in-one bootstrap. New PrimeNG public/cockpit apps should import
|
|
8
|
+
* @sneat/app-public and add @sneat/app-auth only to their lazy private routes. */
|
|
17
9
|
export function getStandardSneatProviders(environmentConfig) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// );
|
|
22
|
-
if (environmentConfig.posthog) {
|
|
23
|
-
registerPosthog(environmentConfig.posthog);
|
|
24
|
-
}
|
|
25
|
-
const providers = [
|
|
26
|
-
provideHttpClient(),
|
|
27
|
-
provideErrorLogger(),
|
|
28
|
-
// Auto-reload once on a stale lazy-chunk load after a deploy. Baseline for
|
|
29
|
-
// apps without Sentry; Sentry's own (chunk-aware) handler overrides it when
|
|
30
|
-
// configured (pushed later below).
|
|
31
|
-
provideChunkLoadErrorRecovery(),
|
|
32
|
-
provideIonicAngular(),
|
|
33
|
-
provideAnimationsAsync(),
|
|
34
|
-
{ provide: LOGGER_FACTORY, useValue: loggerFactory },
|
|
35
|
-
{ provide: EnvConfigToken, useValue: environmentConfig },
|
|
36
|
-
{
|
|
37
|
-
provide: RouteReuseStrategy,
|
|
38
|
-
useClass: IonicRouteStrategy,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
// Owns document.title for every app: composes the route's data.title
|
|
42
|
-
// with APP_INFO.appTitle, and lets pages override via PageTitleService.
|
|
43
|
-
provide: TitleStrategy,
|
|
44
|
-
useClass: SneatTitleStrategy,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
provide: SneatApiBaseUrl,
|
|
48
|
-
useValue: environmentConfig.useNgrok
|
|
10
|
+
return [
|
|
11
|
+
provideSneatPublicBootstrap({
|
|
12
|
+
apiBaseUrl: environmentConfig.useNgrok
|
|
49
13
|
? `//${location.host}/v0/`
|
|
50
14
|
: environmentConfig.firebaseConfig.emulator
|
|
51
|
-
? 'https://local-api.sneat.ws/v0/'
|
|
52
|
-
:
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
provideSneatAnalytics(environmentConfig),
|
|
60
|
-
AppComponentService, // TODO: check if it's used and probably remove
|
|
15
|
+
? 'https://local-api.sneat.ws/v0/'
|
|
16
|
+
: undefined,
|
|
17
|
+
}),
|
|
18
|
+
provideSneatAuthenticatedProviders(environmentConfig),
|
|
19
|
+
provideSneatIonicShell(),
|
|
20
|
+
{ provide: EnvConfigToken, useValue: environmentConfig },
|
|
21
|
+
{ provide: RANDOM_ID_OPTIONS, useValue: { len: 9 } },
|
|
22
|
+
AppComponentService,
|
|
61
23
|
TopMenuService,
|
|
62
|
-
TelegramAuthService,
|
|
63
24
|
];
|
|
64
|
-
if (environmentConfig.sentry) {
|
|
65
|
-
providers.push(provideSentryAppInitializer(environmentConfig.sentry));
|
|
66
|
-
}
|
|
67
|
-
return providers;
|
|
68
25
|
}
|
|
69
26
|
//# sourceMappingURL=get-standard-sneat-providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-standard-sneat-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/get-standard-sneat-providers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-standard-sneat-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/get-standard-sneat-providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAsB,cAAc,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;kFACkF;AAClF,MAAM,UAAU,yBAAyB,CACvC,iBAAqC;IAErC,OAAO;QACL,2BAA2B,CAAC;YAC1B,UAAU,EAAE,iBAAiB,CAAC,QAAQ;gBACpC,CAAC,CAAC,KAAK,QAAQ,CAAC,IAAI,MAAM;gBAC1B,CAAC,CAAC,iBAAiB,CAAC,cAAc,CAAC,QAAQ;oBACzC,CAAC,CAAC,gCAAgC;oBAClC,CAAC,CAAC,SAAS;SAChB,CAAC;QACF,kCAAkC,CAAC,iBAAiB,CAAC;QACrD,sBAAsB,EAAE;QACxB,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,EAAE;QACxD,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;QACpD,mBAAmB;QACnB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import { EnvironmentProviders, Provider } from '@angular/core';\nimport { provideSneatAuthenticatedProviders } from '@sneat/app-auth';\nimport { provideSneatIonicShell } from '@sneat/app-ionic';\nimport { provideSneatPublicBootstrap } from '@sneat/app-public';\nimport { EnvConfigToken, IEnvironmentConfig, TopMenuService } from '@sneat/core';\nimport { RANDOM_ID_OPTIONS } from '@sneat/random';\nimport { AppComponentService } from './app-component.service';\n\n/** Legacy all-in-one bootstrap. New PrimeNG public/cockpit apps should import\n * @sneat/app-public and add @sneat/app-auth only to their lazy private routes. */\nexport function getStandardSneatProviders(\n environmentConfig: IEnvironmentConfig,\n): readonly (Provider | EnvironmentProviders)[] {\n return [\n provideSneatPublicBootstrap({\n apiBaseUrl: environmentConfig.useNgrok\n ? `//${location.host}/v0/`\n : environmentConfig.firebaseConfig.emulator\n ? 'https://local-api.sneat.ws/v0/'\n : undefined,\n }),\n provideSneatAuthenticatedProviders(environmentConfig),\n provideSneatIonicShell(),\n { provide: EnvConfigToken, useValue: environmentConfig },\n { provide: RANDOM_ID_OPTIONS, useValue: { len: 9 } },\n AppComponentService,\n TopMenuService,\n ];\n}\n"]}
|
|
@@ -1,85 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { connectAuthEmulator, indexedDBLocalPersistence, initializeAuth, provideAuth, } from '@angular/fire/auth';
|
|
3
|
-
import { connectFirestoreEmulator } from '@angular/fire/firestore';
|
|
4
|
-
import { Capacitor } from '@capacitor/core';
|
|
5
|
-
import { provideFirebaseApp, initializeApp, FirebaseApp, } from '@angular/fire/app';
|
|
6
|
-
import { getAuth } from 'firebase/auth';
|
|
7
|
-
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
|
|
8
|
-
import { isLocalhost } from './init-helpers';
|
|
9
|
-
// Defense in depth: a production bundle should never carry emulator config
|
|
10
|
-
// (use appEnvironmentConfig()), but if one slips through, refuse to point real
|
|
11
|
-
// users at 127.0.0.1 — that just yields "refused to connect". Warn loudly so a
|
|
12
|
-
// post-deploy smoke test (and the console) surfaces the misconfiguration.
|
|
13
|
-
function emulatorAllowed(hasEmulator) {
|
|
14
|
-
if (!hasEmulator) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
if (isLocalhost()) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
console.error('[init-firebase] Emulator config present on a non-localhost host ' +
|
|
21
|
-
`("${typeof location !== 'undefined' ? location.hostname : '?'}") — ` +
|
|
22
|
-
'ignoring it. This is a build/deploy misconfiguration: a production ' +
|
|
23
|
-
'build shipped the emulator environment.');
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
export function provideFireApp(firebaseConfig) {
|
|
27
|
-
return provideFirebaseApp(() => initFirebase(firebaseConfig));
|
|
28
|
-
}
|
|
29
|
-
export function getAngularFireProviders(firebaseConfig) {
|
|
30
|
-
const providers = [
|
|
31
|
-
provideFirebaseApp(() => initFirebase(firebaseConfig)),
|
|
32
|
-
provideFirestore((injector) => {
|
|
33
|
-
// console.log('AngularFire: provideFirestore');
|
|
34
|
-
const fbApp = injector.get(FirebaseApp);
|
|
35
|
-
const firestore = getFirestore(fbApp);
|
|
36
|
-
const { emulator } = firebaseConfig;
|
|
37
|
-
if (emulator && emulatorAllowed(!!emulator)) {
|
|
38
|
-
connectFirestoreEmulator(firestore, emulator.firestoreHost || '127.0.0.1', emulator.firestorePort);
|
|
39
|
-
if (emulator.firestorePort === 443) {
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
firestore['_settings']['ssl'] = true;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return firestore;
|
|
46
|
-
}),
|
|
47
|
-
provideAuth((injector) => {
|
|
48
|
-
// console.log('AngularFire: provideAuth');
|
|
49
|
-
const fbApp = injector.get(FirebaseApp);
|
|
50
|
-
let auth;
|
|
51
|
-
if (Capacitor.isNativePlatform()) {
|
|
52
|
-
auth = initializeAuth(fbApp, {
|
|
53
|
-
persistence: indexedDBLocalPersistence,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
auth = getAuth(fbApp);
|
|
58
|
-
}
|
|
59
|
-
const { emulator } = firebaseConfig;
|
|
60
|
-
if (emulator?.authPort && emulatorAllowed(!!emulator)) {
|
|
61
|
-
// alert('Using firebase auth emulator');
|
|
62
|
-
const authUrl = `${emulator.authPort === 443 ? 'https' : 'http'}://${emulator.authHost || '127.0.0.1'}:${emulator.authPort}`;
|
|
63
|
-
// console.log('authUrl: ', authUrl);
|
|
64
|
-
// noinspection HttpUrlsUsage
|
|
65
|
-
connectAuthEmulator(auth, authUrl);
|
|
66
|
-
}
|
|
67
|
-
return auth;
|
|
68
|
-
}),
|
|
69
|
-
];
|
|
70
|
-
if (firebaseConfig?.measurementId !== 'G-PROVIDE_IF_NEEDED') {
|
|
71
|
-
providers.push(provideAnalytics(() => {
|
|
72
|
-
// const fbApp = injector.get<FirebaseApp>(
|
|
73
|
-
// FirebaseApp as Type<FirebaseApp>,
|
|
74
|
-
// );
|
|
75
|
-
// const fbAnalytics = getAnalytics(fbApp);
|
|
76
|
-
const fbAnalytics = getAnalytics();
|
|
77
|
-
return fbAnalytics;
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
80
|
-
return providers;
|
|
81
|
-
}
|
|
82
|
-
function initFirebase(firebaseConfig) {
|
|
83
|
-
return initializeApp(firebaseConfig);
|
|
84
|
-
}
|
|
1
|
+
export { getAngularFireProviders, provideFireApp, } from '@sneat/app-auth';
|
|
85
2
|
//# sourceMappingURL=init-firebase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-firebase.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/init-firebase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init-firebase.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/init-firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,cAAc,GACf,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n getAngularFireProviders,\n provideFireApp,\n} from '@sneat/app-auth';\n"]}
|
|
@@ -26,17 +26,26 @@ export function isLocalhost() {
|
|
|
26
26
|
// Apps should define a single environment.ts:
|
|
27
27
|
// export const fooEnvironmentConfig = appEnvironmentConfig({ ...prod config });
|
|
28
28
|
// and drop environment.prod.ts + the production fileReplacements entirely.
|
|
29
|
+
/**
|
|
30
|
+
* The shared, Firebase-hosted auth domain that serves Google OAuth's
|
|
31
|
+
* /__/auth/handler for every Sneat product (an authorized OAuth redirect
|
|
32
|
+
* domain). Used as the default authDomain so sign-in works on Cloudflare-served
|
|
33
|
+
* product domains, which do not serve /__/auth/handler themselves.
|
|
34
|
+
*/
|
|
35
|
+
export const SHARED_SNEAT_AUTH_DOMAIN = 'auth.sneat.co';
|
|
29
36
|
export function appEnvironmentConfig(prod) {
|
|
30
37
|
if (isLocalhost()) {
|
|
31
38
|
return appSpecificConfig(emulatorEnvironmentConfig);
|
|
32
39
|
}
|
|
33
|
-
// Default authDomain to the
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
// Default authDomain to the shared, Firebase-hosted auth.sneat.co so Google
|
|
41
|
+
// OAuth completes at /__/auth/handler no matter where the app is served. Most
|
|
42
|
+
// Sneat products run on Cloudflare Workers, which do NOT serve Firebase's
|
|
43
|
+
// /__/auth/handler, so the previous current-origin default sent the redirect
|
|
44
|
+
// to <app-domain>/__/auth/handler and the Angular SPA swallowed it (NG04002).
|
|
45
|
+
// auth.sneat.co is an authorized OAuth redirect domain shared across products.
|
|
46
|
+
// Apps on Firebase Hosting (or wanting a same-origin authDomain) override by
|
|
47
|
+
// setting firebaseConfig.authDomain.
|
|
48
|
+
const authDomain = prod.firebaseConfig.authDomain || SHARED_SNEAT_AUTH_DOMAIN;
|
|
40
49
|
return {
|
|
41
50
|
...prod,
|
|
42
51
|
firebaseConfig: { ...prod.firebaseConfig, authDomain },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-helpers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/init-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,6EAA6E;AAC7E,iEAAiE;AACjE,gCAAgC;AAChC,MAAM,UAAU,WAAW;IACzB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;IAC9B,4EAA4E;IAC5E,6EAA6E;IAC7E,8EAA8E;IAC9E,OAAO,CACL,CAAC,WAAW,EAAE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,CAAC,CAAC;IAC3E,MAAM,GAAG;QACP,GAAG,MAAM;QACT,cAAc,EAAE;YACd,GAAG,cAAc;YACjB,MAAM,EAAE,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC;YAC1D,SAAS,EAAE,SAAS;SACrB;KACF,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { IEnvironmentConfig } from '@sneat/core';\nimport { emulatorEnvironmentConfig } from '../environments/environment.base';\n\n// True only when the app is actually running on a developer machine. Used to\n// decide, at RUNTIME, whether to use the Firebase emulator — see\n// appEnvironmentConfig() below.\nexport function isLocalhost(): boolean {\n if (typeof location === 'undefined') {\n return false;\n }\n const { hostname } = location;\n // Any *.localhost host is loopback by spec (RFC 6761), so full-site-preview\n // domains like gameboard.localhost must use the emulator too — not just bare\n // localhost. Without the suffix check they fall through to production config.\n return (\n ['localhost', '127.0.0.1', '[::1]', '0.0.0.0'].includes(hostname) ||\n hostname.endsWith('.localhost')\n );\n}\n\n// Fail-safe environment selection. Use the Firebase emulator ONLY when running\n// on localhost; every deployed domain gets the production config passed in.\n//\n// Because the emulator-vs-production decision is made at runtime from the\n// hostname — NOT from a build-time `fileReplacements` swap — a mis-built or\n// mis-deployed bundle can never ship the emulator config to production. This\n// structurally eliminates the recurring \"127.0.0.1 refused to connect\" class of\n// bug: forgetting `--configuration production`, a stale `dist/`, an nx cache\n// hit, or deploying a dev build can no longer point real users at the emulator.\n//\n// Apps should define a single environment.ts:\n// export const fooEnvironmentConfig = appEnvironmentConfig({ ...prod config });\n// and drop environment.prod.ts + the production fileReplacements entirely.\n/**\n * The shared, Firebase-hosted auth domain that serves Google OAuth's\n * /__/auth/handler for every Sneat product (an authorized OAuth redirect\n * domain). Used as the default authDomain so sign-in works on Cloudflare-served\n * product domains, which do not serve /__/auth/handler themselves.\n */\nexport const SHARED_SNEAT_AUTH_DOMAIN = 'auth.sneat.co';\n\nexport function appEnvironmentConfig(\n prod: IEnvironmentConfig,\n): IEnvironmentConfig {\n if (isLocalhost()) {\n return appSpecificConfig(emulatorEnvironmentConfig);\n }\n // Default authDomain to the shared, Firebase-hosted auth.sneat.co so Google\n // OAuth completes at /__/auth/handler no matter where the app is served. Most\n // Sneat products run on Cloudflare Workers, which do NOT serve Firebase's\n // /__/auth/handler, so the previous current-origin default sent the redirect\n // to <app-domain>/__/auth/handler and the Angular SPA swallowed it (NG04002).\n // auth.sneat.co is an authorized OAuth redirect domain shared across products.\n // Apps on Firebase Hosting (or wanting a same-origin authDomain) override by\n // setting firebaseConfig.authDomain.\n const authDomain =\n prod.firebaseConfig.authDomain || SHARED_SNEAT_AUTH_DOMAIN;\n return {\n ...prod,\n firebaseConfig: { ...prod.firebaseConfig, authDomain },\n };\n}\n\nfunction firebaseApiKey(useEmulators: boolean, apiKey: string): string {\n return useEmulators ? 'emulator-does-not-need-api-key' : apiKey;\n}\n\nexport function firebaseProjectId(\n useEmulators: boolean,\n projectId: string,\n): string {\n return useEmulators ? 'demo-' + projectId : projectId;\n}\n\n// function firebaseDatabaseURL(useEmulators: boolean, projectId: string): string | undefined{\n// \t// noinspection SpellCheckingInspection\n// \treturn useEmulators\n// \t\t? undefined :\n// \t\t`https://${projectId}.firebaseio.com`;\n// }\n\n// TODO: document why needed\nexport function appSpecificConfig(\n envConfig: IEnvironmentConfig,\n // appConfig: IAppSpecificConfig,\n): IEnvironmentConfig {\n let config: IEnvironmentConfig = {\n ...envConfig,\n firebaseConfig: {\n ...envConfig.firebaseConfig,\n },\n };\n const { firebaseConfig } = config;\n const useEmulator = !!config.firebaseConfig.emulator;\n const projectId = firebaseProjectId(useEmulator, firebaseConfig.projectId);\n config = {\n ...config,\n firebaseConfig: {\n ...firebaseConfig,\n apiKey: firebaseApiKey(useEmulator, firebaseConfig.apiKey),\n projectId: projectId,\n },\n };\n return config;\n}\n"]}
|
package/index.d.ts
CHANGED
|
@@ -10,6 +10,4 @@ export * from './lib/contact-extensions';
|
|
|
10
10
|
export * from './lib/get-standard-sneat-providers';
|
|
11
11
|
export * from './lib/app-specific-providers';
|
|
12
12
|
export * from './lib/capacitator-http.service';
|
|
13
|
-
export
|
|
14
|
-
export * from './lib/sneat-title.strategy';
|
|
15
|
-
export * from './lib/route-title';
|
|
13
|
+
export { PageTitleService, SneatTitleStrategy, SNEAT_AUTHENTICATED_LIFECYCLE, } from '@sneat/app-public';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Provider } from '@angular/core';
|
|
2
2
|
import { ContactRolesByType } from './contact-extensions';
|
|
3
|
-
|
|
4
|
-
export declare function provideAppInfo(appInfo: IAppInfo): Provider;
|
|
3
|
+
export { provideAppInfo } from '@sneat/app-public';
|
|
5
4
|
export declare function provideRolesByType(contactRolesByType: ContactRolesByType | undefined): Provider;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { TopMenuService } from '@sneat/core';
|
|
2
2
|
export declare class BaseAppComponent {
|
|
3
|
-
private readonly telegramAuthService;
|
|
4
|
-
private readonly router;
|
|
5
|
-
private readonly analyticsService;
|
|
6
|
-
private readonly authStateService;
|
|
7
3
|
protected readonly topMenuService: TopMenuService;
|
|
8
|
-
private
|
|
4
|
+
private readonly authenticatedLifecycle;
|
|
9
5
|
constructor();
|
|
10
|
-
private forgetCurrentSpaceIfLeftSpaces;
|
|
11
6
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { EnvironmentProviders, Provider } from '@angular/core';
|
|
2
2
|
import { IEnvironmentConfig } from '@sneat/core';
|
|
3
|
+
/** Legacy all-in-one bootstrap. New PrimeNG public/cockpit apps should import
|
|
4
|
+
* @sneat/app-public and add @sneat/app-auth only to their lazy private routes. */
|
|
3
5
|
export declare function getStandardSneatProviders(environmentConfig: IEnvironmentConfig): readonly (Provider | EnvironmentProviders)[];
|
package/lib/init-firebase.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { IFirebaseConfig } from '@sneat/core';
|
|
3
|
-
export declare function provideFireApp(firebaseConfig: IFirebaseConfig): EnvironmentProviders;
|
|
4
|
-
export declare function getAngularFireProviders(firebaseConfig: IFirebaseConfig): EnvironmentProviders[];
|
|
1
|
+
export { getAngularFireProviders, provideFireApp, } from '@sneat/app-auth';
|
package/lib/init-helpers.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { IEnvironmentConfig } from '@sneat/core';
|
|
2
2
|
export declare function isLocalhost(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* The shared, Firebase-hosted auth domain that serves Google OAuth's
|
|
5
|
+
* /__/auth/handler for every Sneat product (an authorized OAuth redirect
|
|
6
|
+
* domain). Used as the default authDomain so sign-in works on Cloudflare-served
|
|
7
|
+
* product domains, which do not serve /__/auth/handler themselves.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SHARED_SNEAT_AUTH_DOMAIN = "auth.sneat.co";
|
|
3
10
|
export declare function appEnvironmentConfig(prod: IEnvironmentConfig): IEnvironmentConfig;
|
|
4
11
|
export declare function firebaseProjectId(useEmulators: boolean, projectId: string): string;
|
|
5
12
|
export declare function appSpecificConfig(envConfig: IEnvironmentConfig): IEnvironmentConfig;
|
package/package.json
CHANGED
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sneat/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"@angular/common": ">=21.0.0",
|
|
9
9
|
"@angular/core": ">=21.0.0",
|
|
10
|
-
"@
|
|
10
|
+
"@angular/fire": ">=20",
|
|
11
|
+
"@angular/platform-browser": ">=21.0.0",
|
|
12
|
+
"@angular/router": ">=21.0.0",
|
|
13
|
+
"@capacitor/core": ">=8.0.0",
|
|
14
|
+
"@ionic-native/splash-screen": "^5.36.0",
|
|
15
|
+
"@ionic-native/status-bar": "^5.36.0",
|
|
16
|
+
"@ionic/angular": ">=8.0.0",
|
|
17
|
+
"@sneat/app-auth": "^0.26.0",
|
|
18
|
+
"@sneat/app-ionic": "^0.26.0",
|
|
19
|
+
"@sneat/app-public": "^0.26.0",
|
|
20
|
+
"@sneat/auth-core": "^0.26.0",
|
|
21
|
+
"@sneat/core": "^0.26.0",
|
|
22
|
+
"@sneat/extension-contactus-contract": "^0.12.0",
|
|
23
|
+
"@sneat/logging": "^0.26.0",
|
|
24
|
+
"@sneat/random": "*",
|
|
25
|
+
"@sneat/space-services": "^0.26.0",
|
|
26
|
+
"firebase": "*",
|
|
27
|
+
"rxjs": ">=7.8.0",
|
|
28
|
+
"zone.js": ">=0.16.0"
|
|
11
29
|
},
|
|
12
30
|
"dependencies": {
|
|
13
31
|
"tslib": "2.8.1"
|