@sneat/app 0.27.8 → 0.27.10
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/lib/get-standard-sneat-providers.js +3 -6
- package/esm2022/lib/get-standard-sneat-providers.js.map +1 -1
- package/esm2022/lib/init-helpers.js +13 -0
- package/esm2022/lib/init-helpers.js.map +1 -1
- package/lib/init-helpers.d.ts +1 -0
- package/package.json +1 -1
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
|
@@ -2,20 +2,17 @@ import { provideZonelessChangeDetection, } from '@angular/core';
|
|
|
2
2
|
import { provideSneatAuthenticatedProviders } from '@sneat/app-auth';
|
|
3
3
|
import { provideSneatIonicShell } from '@sneat/app-ionic';
|
|
4
4
|
import { provideSneatPublicBootstrap } from '@sneat/app-public';
|
|
5
|
-
import { EnvConfigToken, TopMenuService } from '@sneat/core';
|
|
5
|
+
import { EnvConfigToken, TopMenuService, } from '@sneat/core';
|
|
6
6
|
import { RANDOM_ID_OPTIONS } from '@sneat/random';
|
|
7
7
|
import { AppComponentService } from './app-component.service';
|
|
8
|
+
import { standardSneatApiBaseUrl } from './init-helpers';
|
|
8
9
|
/** Legacy all-in-one bootstrap. New PrimeNG public/cockpit apps should import
|
|
9
10
|
* @sneat/app-public and add @sneat/app-auth only to their lazy private routes. */
|
|
10
11
|
export function getStandardSneatProviders(environmentConfig) {
|
|
11
12
|
return [
|
|
12
13
|
provideZonelessChangeDetection(),
|
|
13
14
|
provideSneatPublicBootstrap({
|
|
14
|
-
apiBaseUrl: environmentConfig
|
|
15
|
-
? `//${location.host}/v0/`
|
|
16
|
-
: environmentConfig.firebaseConfig.emulator
|
|
17
|
-
? 'https://local-api.sneat.ws/v0/'
|
|
18
|
-
: undefined,
|
|
15
|
+
apiBaseUrl: standardSneatApiBaseUrl(environmentConfig),
|
|
19
16
|
}),
|
|
20
17
|
provideSneatAuthenticatedProviders(environmentConfig),
|
|
21
18
|
provideSneatIonicShell(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-standard-sneat-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/get-standard-sneat-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AACvB,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,
|
|
1
|
+
{"version":3,"file":"get-standard-sneat-providers.js","sourceRoot":"","sources":["../../../../../libs/app/src/lib/get-standard-sneat-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,8BAA8B,GAC/B,MAAM,eAAe,CAAC;AACvB,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,EACL,cAAc,EAEd,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;kFACkF;AAClF,MAAM,UAAU,yBAAyB,CACvC,iBAAqC;IAErC,OAAO;QACL,8BAA8B,EAAE;QAChC,2BAA2B,CAAC;YAC1B,UAAU,EAAE,uBAAuB,CAAC,iBAAiB,CAAC;SACvD,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 {\n EnvironmentProviders,\n Provider,\n provideZonelessChangeDetection,\n} from '@angular/core';\nimport { provideSneatAuthenticatedProviders } from '@sneat/app-auth';\nimport { provideSneatIonicShell } from '@sneat/app-ionic';\nimport { provideSneatPublicBootstrap } from '@sneat/app-public';\nimport {\n EnvConfigToken,\n IEnvironmentConfig,\n TopMenuService,\n} from '@sneat/core';\nimport { RANDOM_ID_OPTIONS } from '@sneat/random';\nimport { AppComponentService } from './app-component.service';\nimport { standardSneatApiBaseUrl } from './init-helpers';\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 provideZonelessChangeDetection(),\n provideSneatPublicBootstrap({\n apiBaseUrl: standardSneatApiBaseUrl(environmentConfig),\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"]}
|
|
@@ -13,6 +13,19 @@ export function isLocalhost() {
|
|
|
13
13
|
return (['localhost', '127.0.0.1', '[::1]', '0.0.0.0'].includes(hostname) ||
|
|
14
14
|
hostname.endsWith('.localhost'));
|
|
15
15
|
}
|
|
16
|
+
// Match the shared backend's trusted local HTTPS listener. Tunnel users retain
|
|
17
|
+
// their same-origin routing; deployed apps retain the normal production API.
|
|
18
|
+
export function standardSneatApiBaseUrl(config) {
|
|
19
|
+
if (config.useNgrok) {
|
|
20
|
+
return `//${location.host}/v0/`;
|
|
21
|
+
}
|
|
22
|
+
if (!config.firebaseConfig.emulator) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return isLocalhost()
|
|
26
|
+
? 'https://sneat-api.dev.localhost:4300/v0/'
|
|
27
|
+
: 'https://local-api.sneat.ws/v0/';
|
|
28
|
+
}
|
|
16
29
|
// Fail-safe environment selection. Use the Firebase emulator ONLY when running
|
|
17
30
|
// on localhost; every deployed domain gets the production config passed in.
|
|
18
31
|
//
|
|
@@ -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,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjE,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,4EAA4E;AAC5E,EAAE;AACF,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,gFAAgF;AAChF,EAAE;AACF,8CAA8C;AAC9C,kFAAkF;AAClF,2EAA2E;AAC3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAClC,IAAwB;IAExB,IAAI,WAAW,EAAE,EAAE,CAAC;QAClB,OAAO,iBAAiB,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IACD,4EAA4E;IAC5E,8EAA8E;IAC9E,0EAA0E;IAC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,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// Match the shared backend's trusted local HTTPS listener. Tunnel users retain\n// their same-origin routing; deployed apps retain the normal production API.\nexport function standardSneatApiBaseUrl(\n config: IEnvironmentConfig,\n): string | undefined {\n if (config.useNgrok) {\n return `//${location.host}/v0/`;\n }\n if (!config.firebaseConfig.emulator) {\n return undefined;\n }\n return isLocalhost()\n ? 'https://sneat-api.dev.localhost:4300/v0/'\n : 'https://local-api.sneat.ws/v0/';\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 = 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/lib/init-helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IEnvironmentConfig } from '@sneat/core';
|
|
2
2
|
export declare function isLocalhost(): boolean;
|
|
3
|
+
export declare function standardSneatApiBaseUrl(config: IEnvironmentConfig): string | undefined;
|
|
3
4
|
/**
|
|
4
5
|
* The shared, Firebase-hosted auth domain that serves Google OAuth's
|
|
5
6
|
* /__/auth/handler for every Sneat product (an authorized OAuth redirect
|