@frontera-sdk/core 1.45.14 → 1.46.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/package.json +1 -1
- package/src/app-session.ts +14 -1
- package/src/bridge-client.ts +8 -4
- package/src/create-frontera-app.tsx +4 -0
package/package.json
CHANGED
package/src/app-session.ts
CHANGED
|
@@ -4,11 +4,24 @@ import type { FronteraRuntimeGlobal } from './config'
|
|
|
4
4
|
|
|
5
5
|
export type FronteraAppMode = 'embedded' | 'standalone' | 'local'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Which transport this App should use.
|
|
9
|
+
*
|
|
10
|
+
* `framed` alone decides embedding — it is the only fact that answers "is there
|
|
11
|
+
* a parent to talk to". `platformOrigin` is an INPUT to that conversation, not
|
|
12
|
+
* evidence of it: `connectToHost` resolves the origin itself and falls back to
|
|
13
|
+
* `document.referrer` when the host injected nothing.
|
|
14
|
+
*
|
|
15
|
+
* Requiring `platformOrigin` here made a framed App fall through to `null` and
|
|
16
|
+
* report "not configured" — while the deployment was fine and only its
|
|
17
|
+
* `CORS_ORIGIN` was `*`, which is the default. The App then hung before issuing
|
|
18
|
+
* a single request, so nothing in the browser named the cause.
|
|
19
|
+
*/
|
|
7
20
|
export function detectAppMode(
|
|
8
21
|
runtime: FronteraRuntimeGlobal,
|
|
9
22
|
framed: boolean,
|
|
10
23
|
): FronteraAppMode | null {
|
|
11
|
-
if (framed
|
|
24
|
+
if (framed) return 'embedded'
|
|
12
25
|
if (runtime.sessionEndpoint) return 'standalone'
|
|
13
26
|
if (runtime.devSessionEndpoint) return 'local'
|
|
14
27
|
return null
|
package/src/bridge-client.ts
CHANGED
|
@@ -38,10 +38,14 @@ export interface ConnectOptions {
|
|
|
38
38
|
* Who is framing us.
|
|
39
39
|
*
|
|
40
40
|
* The injected runtime config comes FIRST and `document.referrer` is only a
|
|
41
|
-
* fallback
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* fallback. The injected value is preferred because it is exact and, when it
|
|
42
|
+
* comes from the signed per-mount claim, unforgeable — not because the
|
|
43
|
+
* referrer is empty. (An earlier version of this comment blamed the
|
|
44
|
+
* `referrer-policy: no-referrer` these responses carry; that header governs
|
|
45
|
+
* the referrer this document SENDS on its own requests, not the
|
|
46
|
+
* `document.referrer` its parent handed it, which is set by the embedding
|
|
47
|
+
* page's policy — the platform frame does populate it, and pre-1.45 Apps
|
|
48
|
+
* mounted through exactly this fallback for months.)
|
|
45
49
|
*/
|
|
46
50
|
function resolveParentOrigin(explicit?: string): string | null {
|
|
47
51
|
if (explicit) return explicit
|
|
@@ -232,6 +232,10 @@ export function FronteraAppProvider({
|
|
|
232
232
|
const framed = typeof window !== 'undefined' && window.parent !== window
|
|
233
233
|
const mode = detectAppMode(runtime, framed)
|
|
234
234
|
if (!mode) {
|
|
235
|
+
// Reachable only when NOT framed: `detectAppMode` returns 'embedded' for
|
|
236
|
+
// any framed document, so a null mode means there is no parent and no
|
|
237
|
+
// session endpoint either. A framed App that cannot resolve a parent
|
|
238
|
+
// origin fails later and more precisely, inside `connectToHost`.
|
|
235
239
|
setError(
|
|
236
240
|
new Error(
|
|
237
241
|
'Frontera App is not configured: no embedded host, standalone session endpoint, or local development session endpoint was provided.',
|