@sneat/app 0.25.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.
@@ -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 current origin so the OAuth redirect stays
34
- // same-origin / first-party. Serving an app at one domain (e.g. listus.app)
35
- // while authenticating against another (listus-app.web.app) triggers a
36
- // cross-domain redirect that browsers flag as a look-alike and that breaks
37
- // first-party auth storage. Apps override by setting firebaseConfig.authDomain.
38
- const authDomain = prod.firebaseConfig.authDomain ||
39
- (typeof location !== 'undefined' ? location.hostname : undefined);
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.firebaseConf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U,EAAE;KACvD,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,YAAqB,EAAE,MAAc;IAC3D,OAAO,YAAY,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,MAAM,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,YAAqB,EACrB,SAAiB;IAEjB,OAAO,YAAY,CAAC,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC;AAED,8FAA8F;AAC9F,2CAA2C;AAC3C,uBAAuB;AACvB,kBAAkB;AAClB,2CAA2C;AAC3C,IAAI;AAEJ,4BAA4B;AAC5B,MAAM,UAAU,iBAAiB,CAC/B,SAA6B;IAG7B,IAAI,MAAM,GAAuB;QAC/B,GAAG,SAAS;QACZ,cAAc,EAAE;YACd,GAAG,SAAS,CAAC,cAAc;SAC5B;KACF,CAAC;IACF,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;IAClC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;IACrD,MAAM,SAAS,GAAG,iBAAiB,CAAC,WAAW,EAAE,cAAc,CAAC,SAAS,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.\nexport function appEnvironmentConfig(\n prod: IEnvironmentConfig,\n): IEnvironmentConfig {\n if (isLocalhost()) {\n return appSpecificConfig(emulatorEnvironmentConfig);\n }\n // Default authDomain to the current origin so the OAuth redirect stays\n // same-origin / first-party. Serving an app at one domain (e.g. listus.app)\n // while authenticating against another (listus-app.web.app) triggers a\n // cross-domain redirect that browsers flag as a look-alike and that breaks\n // first-party auth storage. Apps override by setting firebaseConfig.authDomain.\n const authDomain =\n prod.firebaseConfig.authDomain ||\n (typeof location !== 'undefined' ? location.hostname : undefined);\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"]}
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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AW,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"]}
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sneat/app",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,15 +14,15 @@
14
14
  "@ionic-native/splash-screen": "^5.36.0",
15
15
  "@ionic-native/status-bar": "^5.36.0",
16
16
  "@ionic/angular": ">=8.0.0",
17
- "@sneat/app-auth": "^0.25.0",
18
- "@sneat/app-ionic": "^0.25.0",
19
- "@sneat/app-public": "^0.25.0",
20
- "@sneat/auth-core": "^0.25.0",
21
- "@sneat/core": "^0.25.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
22
  "@sneat/extension-contactus-contract": "^0.12.0",
23
- "@sneat/logging": "^0.25.0",
23
+ "@sneat/logging": "^0.26.0",
24
24
  "@sneat/random": "*",
25
- "@sneat/space-services": "^0.25.0",
25
+ "@sneat/space-services": "^0.26.0",
26
26
  "firebase": "*",
27
27
  "rxjs": ">=7.8.0",
28
28
  "zone.js": ">=0.16.0"