@botmanor/fe-sdk 2026.1204.4 β 2026.1205.1
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/README.md +12 -4
- package/dist/index.d.ts +8 -0
- package/dist/index.js +17 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Embed BotManor **Stewards** (πΊοΈ in development β BOFF-15352).
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
StewardsSdkProvider,
|
|
8
|
+
StewardConsole,
|
|
9
|
+
useStewardsEvent,
|
|
10
|
+
} from "@botmanor/fe-sdk";
|
|
7
11
|
|
|
8
12
|
<StewardsSdkProvider
|
|
9
13
|
gatewayUrl={gatewayUrl}
|
|
@@ -12,10 +16,10 @@ import { StewardsSdkProvider, StewardConsole, useStewardsEvent } from '@botmanor
|
|
|
12
16
|
getWorkspaceToken={() => auth.currentWorkspaceToken()} // app shells only
|
|
13
17
|
onTokenExpired={() => auth.refresh()}
|
|
14
18
|
onEvent={(e) => analytics.track(e.type)}
|
|
15
|
-
theme={{ accent:
|
|
19
|
+
theme={{ accent: "var(--my-brand)" }}
|
|
16
20
|
>
|
|
17
21
|
<StewardConsole stewardId={stewardId} />
|
|
18
|
-
</StewardsSdkProvider
|
|
22
|
+
</StewardsSdkProvider>;
|
|
19
23
|
```
|
|
20
24
|
|
|
21
25
|
Theme variables are scoped to the SDK's wrapper; the SDK never styles your page.
|
|
@@ -32,7 +36,11 @@ cookies, no referrer. Inside a Burdenoff app shell, also pass
|
|
|
32
36
|
(sent as `X-Workspace-Authorization`) beside the access token for
|
|
33
37
|
workspace-scoped fields. An embed on a third-party page leaves it out. A 401 or
|
|
34
38
|
`UNAUTHENTICATED` (or a `getWorkspaceToken` that throws) raises `onTokenExpired`
|
|
35
|
-
and the `auth.expired` event.
|
|
39
|
+
and the `auth.expired` event. Requests never follow a redirect. An app
|
|
40
|
+
shell behind Cloudflare Access that serves the gateway through a same-origin
|
|
41
|
+
proxy sets `sameOriginCredentials` so the Access session cookie reaches it;
|
|
42
|
+
cookies then go only to the page's own origin, never to a cross-origin
|
|
43
|
+
gateway. Operations match `@burdenoff/microfe-stewards` and use the
|
|
36
44
|
`Botmanor*` schema; the SDK does not depend on that package because it pulls in
|
|
37
45
|
Apollo and the fe-libs shell.
|
|
38
46
|
|
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,14 @@ interface StewardsSdkConfig {
|
|
|
129
129
|
* it: its single embed session token already names the workspace.
|
|
130
130
|
*/
|
|
131
131
|
getWorkspaceToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Send the browser's cookies when `gatewayUrl` is on the page's own origin
|
|
134
|
+
* (`credentials: "same-origin"`). Off by default: requests carry no cookies.
|
|
135
|
+
* A Burdenoff app shell behind Cloudflare Access (alpha) turns it on, because
|
|
136
|
+
* it serves the gateway through a same-origin proxy and the Access session
|
|
137
|
+
* cookie must reach it. A cross-origin gateway never gets cookies.
|
|
138
|
+
*/
|
|
139
|
+
sameOriginCredentials?: boolean;
|
|
132
140
|
/** Called when the token getter throws or the gateway answers 401. */
|
|
133
141
|
onTokenExpired?: (reason: string) => void;
|
|
134
142
|
/** Every SDK event, for hosts that prefer one callback to `useStewardsEvent`. */
|
package/dist/index.js
CHANGED
|
@@ -55,8 +55,18 @@ async function resolveWorkspaceToken(config, options) {
|
|
|
55
55
|
/**
|
|
56
56
|
* GraphQL transport over the public workspace gateway. The access token goes
|
|
57
57
|
* in the `Authorization` header only (never in the URL or body), the host's
|
|
58
|
-
* workspace token, when it gives one, in `X-Workspace-Authorization
|
|
59
|
-
*
|
|
58
|
+
* workspace token, when it gives one, in `X-Workspace-Authorization`, and no
|
|
59
|
+
* referrer leaks the embedding page.
|
|
60
|
+
*
|
|
61
|
+
* Cookies are not sent (`credentials: "omit"`) unless the host sets
|
|
62
|
+
* `sameOriginCredentials`; then they go only to the page's own origin
|
|
63
|
+
* (`credentials: "same-origin"`). An app shell behind Cloudflare Access on
|
|
64
|
+
* alpha serves the gateway through a same-origin proxy, and the Access session
|
|
65
|
+
* cookie must reach it (BOFF-18393).
|
|
66
|
+
*
|
|
67
|
+
* Redirects are refused (`redirect: "error"`). Fetch drops `Authorization` on a
|
|
68
|
+
* cross-origin redirect but keeps custom headers, so following one could carry
|
|
69
|
+
* the workspace token past the configured gateway (BOFF-18393).
|
|
60
70
|
*/
|
|
61
71
|
function createStewardsClient(options) {
|
|
62
72
|
const send = async (document, variables, signal) => {
|
|
@@ -79,7 +89,8 @@ function createStewardsClient(options) {
|
|
|
79
89
|
query: document,
|
|
80
90
|
variables
|
|
81
91
|
}),
|
|
82
|
-
credentials: "omit",
|
|
92
|
+
credentials: config.sameOriginCredentials ? "same-origin" : "omit",
|
|
93
|
+
redirect: "error",
|
|
83
94
|
referrerPolicy: "no-referrer",
|
|
84
95
|
signal
|
|
85
96
|
});
|
|
@@ -207,13 +218,14 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
207
218
|
})
|
|
208
219
|
};
|
|
209
220
|
});
|
|
210
|
-
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, onTokenExpired, theme } = config;
|
|
221
|
+
const { gatewayUrl, workspaceId, getAccessToken, getWorkspaceToken, sameOriginCredentials, onTokenExpired, theme } = config;
|
|
211
222
|
const value = useMemo(() => ({
|
|
212
223
|
config: {
|
|
213
224
|
gatewayUrl,
|
|
214
225
|
workspaceId,
|
|
215
226
|
getAccessToken,
|
|
216
227
|
...getWorkspaceToken ? { getWorkspaceToken } : {},
|
|
228
|
+
...sameOriginCredentials ? { sameOriginCredentials } : {},
|
|
217
229
|
...onTokenExpired ? { onTokenExpired } : {},
|
|
218
230
|
...onEvent ? { onEvent } : {},
|
|
219
231
|
...theme ? { theme } : {}
|
|
@@ -225,6 +237,7 @@ function StewardsSdkProvider({ children, ...config }) {
|
|
|
225
237
|
workspaceId,
|
|
226
238
|
getAccessToken,
|
|
227
239
|
getWorkspaceToken,
|
|
240
|
+
sameOriginCredentials,
|
|
228
241
|
onTokenExpired,
|
|
229
242
|
onEvent,
|
|
230
243
|
theme,
|