@shellui/core 0.6.1 → 0.7.0-alpha.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.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/schemas/shellui.config.schema.json +116 -72
  4. package/src/app.tsx +2 -0
  5. package/src/components/ContentView.tsx +2 -22
  6. package/src/components/iframeUrlSafety.spec.ts +67 -0
  7. package/src/components/iframeUrlSafety.ts +50 -0
  8. package/src/features/admin/AdminView.tsx +18 -4
  9. package/src/features/auth/AuthProvider.tsx +42 -2
  10. package/src/features/auth/appBackend/AppBackendSessionHost.tsx +58 -0
  11. package/src/features/auth/appBackend/appBackendSessions.spec.ts +195 -0
  12. package/src/features/auth/appBackend/appBackendSessions.ts +292 -0
  13. package/src/features/auth/appBackend/configSchema.spec.ts +41 -0
  14. package/src/features/auth/appBackend/frameAuth.ts +167 -0
  15. package/src/features/auth/appBackend/identity.spec.ts +201 -0
  16. package/src/features/auth/appBackend/identity.ts +173 -0
  17. package/src/features/auth/appBackend/silentSignIn.spec.ts +207 -0
  18. package/src/features/auth/appBackend/silentSignIn.ts +240 -0
  19. package/src/features/auth/backends/shellui.spec.ts +51 -19
  20. package/src/features/auth/backends/shellui.ts +20 -5
  21. package/src/features/auth/backends/types.ts +7 -2
  22. package/src/features/auth/components/LoginView.tsx +40 -18
  23. package/src/features/auth/components/OAuthCallbackView.tsx +29 -2
  24. package/src/features/auth/utils/authRequestError.ts +3 -0
  25. package/src/features/auth/utils/desktopSignIn.spec.ts +41 -0
  26. package/src/features/auth/utils/desktopSignIn.ts +38 -0
  27. package/src/features/auth/utils/index.ts +9 -0
  28. package/src/features/auth/utils/loginCancelTarget.spec.ts +73 -0
  29. package/src/features/auth/utils/loginCancelTarget.ts +45 -0
  30. package/src/features/auth/utils/loginPanelFrame.spec.ts +24 -0
  31. package/src/features/auth/utils/loginPanelFrame.ts +14 -0
  32. package/src/features/auth/utils/webPkce.spec.ts +96 -0
  33. package/src/features/auth/utils/webPkce.ts +152 -0
  34. package/src/features/chromeActions/ChromeActionsHost.tsx +7 -1
  35. package/src/features/chromeActions/computeActionInsets.ts +6 -0
  36. package/src/features/config/types.ts +41 -0
  37. package/src/features/layouts/appbar/AppBarLayout.tsx +39 -9
  38. package/src/features/layouts/chrome/ContentDragOverlay.tsx +14 -7
  39. package/src/features/layouts/chrome/DesktopChrome.tsx +3 -1
  40. package/src/features/layouts/floating/FloatingLayout.tsx +4 -1
  41. package/src/features/layouts/floating/FloatingSidebar.tsx +84 -28
  42. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +19 -0
  43. package/src/features/layouts/floating/computeFloatingInsets.ts +40 -8
  44. package/src/features/layouts/floating/layoutChromeStore.ts +13 -0
  45. package/src/features/layouts/floating/useFloatingChrome.ts +11 -5
  46. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +3 -0
  47. package/src/features/layouts/sidebar/SidebarInner.tsx +5 -0
  48. package/src/features/layouts/sidebar/SidebarLayout.tsx +1 -0
  49. package/src/features/layouts/windows/WindowsLayout.tsx +106 -46
  50. package/src/features/security/trustedFrames.spec.ts +17 -1
  51. package/src/features/security/trustedFrames.ts +31 -9
  52. package/src/features/settings/SettingsProvider.tsx +48 -32
  53. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +374 -0
  54. package/src/features/settings/utils/buildSettingsForPropagation.ts +70 -35
  55. package/src/i18n/translations/en/common.json +2 -0
  56. package/src/i18n/translations/fr/common.json +2 -0
  57. package/src/index.css +16 -1
  58. package/src/index.ts +1 -0
  59. package/src/lib/z-index.ts +5 -0
package/README.md CHANGED
@@ -6,7 +6,7 @@ React runtime for the Shellui host. `@shellui/cli` depends on this package. Inst
6
6
  npm install @shellui/core
7
7
  ```
8
8
 
9
- Shellui **0.6.1** is the current stable release: `npm install @shellui/core@0.6.1`.
9
+ Shellui **0.6.2** is the current stable release: `npm install @shellui/core@0.6.2`.
10
10
 
11
11
  ```typescript
12
12
  import type { ShellUIConfig } from '@shellui/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellui/core",
3
- "version": "0.6.1",
3
+ "version": "0.7.0-alpha.1",
4
4
  "description": "Shellui Core - Core React application runtime",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -73,7 +73,7 @@
73
73
  "workbox-routing": "^7.4.0",
74
74
  "workbox-strategies": "^7.4.0",
75
75
  "workbox-window": "^7.4.0",
76
- "@shellui/sdk": "0.6.1"
76
+ "@shellui/sdk": "0.7.0-alpha.1"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "react": "^18.0.0 || ^19.0.0",
@@ -255,6 +255,22 @@
255
255
  "safeForAuthToken": {
256
256
  "type": "boolean",
257
257
  "description": "Trust control for auth token sharing to iframe apps.\n- undefined/false: untrusted (default), access token is not shared\n- true: trusted, access token can be shared (opt-in)"
258
+ },
259
+ "backend": {
260
+ "$ref": "#/definitions/AppBackendConfig",
261
+ "description": "Identity server for this embedded app when it is not the shell `backend`. The shell keeps a separate session and sends this URL plus that session's access token. Omit to use the shell backend and token. The shell token is never sent when this server differs."
262
+ },
263
+ "email": {
264
+ "$ref": "#/definitions/EmailConfig",
265
+ "description": "Email service for this app. Omit to use the shell `email` when the app uses the shell identity server. When `backend` names a different server and this is omitted, the app receives no email URL."
266
+ },
267
+ "storage": {
268
+ "$ref": "#/definitions/StorageConfig",
269
+ "description": "Storage service for this app. Same fallback as `email`."
270
+ },
271
+ "hosting": {
272
+ "$ref": "#/definitions/HostingConfig",
273
+ "description": "Hosting service for this app. Same fallback as `email`."
258
274
  }
259
275
  },
260
276
  "required": ["label", "path", "url"],
@@ -287,59 +303,53 @@
287
303
  "enum": ["top", "bottom", "left", "right"],
288
304
  "description": "Drawer position when opening a link in a drawer (optional, used when openIn === 'drawer')."
289
305
  },
290
- "NavigationGroup": {
306
+ "AppBackendConfig": {
291
307
  "type": "object",
292
308
  "properties": {
293
- "title": {
294
- "anyOf": [
295
- {
296
- "type": "string"
297
- },
298
- {
299
- "$ref": "#/definitions/LocalizedString"
300
- }
301
- ]
309
+ "type": {
310
+ "$ref": "#/definitions/BackendType",
311
+ "description": "`shellui` or `supabase`. When omitted, the shell backend type is used."
302
312
  },
303
- "items": {
304
- "type": "array",
305
- "items": {
306
- "$ref": "#/definitions/NavigationItem"
307
- }
313
+ "url": {
314
+ "type": "string",
315
+ "description": "Base URL of this app's identity server."
308
316
  },
309
- "position": {
317
+ "companyId": {
318
+ "type": ["string", "number"],
319
+ "description": "Tenant id for this server. Not taken from the shell `backend.companyId`."
320
+ },
321
+ "publishableKey": {
310
322
  "type": "string",
311
- "enum": ["start", "end"],
312
- "description": "Sidebar position: 'start' (default) or 'end'. End groups are rendered in the sidebar footer."
323
+ "description": "Public key when `type` is `supabase`."
324
+ },
325
+ "provider": {
326
+ "type": "string",
327
+ "description": "OAuth provider for silent sign-in, such as `google`. When omitted, the shell uses the first `backend.login.oauthProviders` entry."
313
328
  }
314
329
  },
315
- "required": ["title", "items"],
316
- "additionalProperties": false
330
+ "required": ["url"],
331
+ "additionalProperties": false,
332
+ "description": "Identity server for one embedded app when it differs from the shell `backend`. `type` defaults to the shell backend type. `companyId` is not copied from the shell."
317
333
  },
318
- "AdministrationConfig": {
334
+ "BackendType": {
335
+ "type": "string",
336
+ "enum": ["shellui", "supabase"],
337
+ "description": "Supported backend providers for auth/API communication."
338
+ },
339
+ "EmailConfig": {
319
340
  "type": "object",
320
341
  "properties": {
321
- "title": {
322
- "anyOf": [
323
- {
324
- "type": "string"
325
- },
326
- {
327
- "$ref": "#/definitions/LocalizedString"
328
- }
329
- ],
330
- "description": "Section title shown in the admin sidebar below Dashboard."
342
+ "url": {
343
+ "type": "string",
344
+ "description": "Base URL of email-service. Default: `https://email.shellui.com` when `email` is set and this is omitted. Local: `http://localhost:8003`."
331
345
  },
332
- "navigation": {
333
- "type": "array",
334
- "items": {
335
- "$ref": "#/definitions/NavigationItem"
336
- },
337
- "description": "Flat list of navigation items (same shape as top-level `navigation` items). Order is preserved in the admin sidebar."
346
+ "showInAdmin": {
347
+ "type": "boolean",
348
+ "description": "When false, hide Admin → Email. Default: true (shown) when `email` is set."
338
349
  }
339
350
  },
340
- "required": ["title", "navigation"],
341
351
  "additionalProperties": false,
342
- "description": "Custom navigation section for the staff administration panel. Admin app URL remains `backend.adminUrl` / `backend.adminPathname`. v1 is a flat list only (no nested groups)."
352
+ "description": "Optional email-service wiring for Admin → Email and iframe apps. When `email` is set and `url` is omitted, the shell uses `https://email.shellui.com`."
343
353
  },
344
354
  "StorageConfig": {
345
355
  "type": "object",
@@ -361,17 +371,6 @@
361
371
  "additionalProperties": false,
362
372
  "description": "Optional storage-service wiring for the shell and admin panel. When set, admin shows the Storage sidebar (files explorer, statistics, Django admin). Settings → Storage (quota) appears when `url` is set, unless `showInSettings` is false. Shellui will also use this for the SDK file API (`shellui.storage`)."
363
373
  },
364
- "AiConfig": {
365
- "type": "object",
366
- "properties": {
367
- "enabled": {
368
- "type": "boolean",
369
- "description": "Deploy-time opt-in for the whole AI feature. Default: false. Only `true` enables it. Otherwise: no AiBridge, no Settings → AI, SDK AI calls answer `unavailable`, and no WebLLM chunk/worker is loaded. Opt in with `\"ai\": { \"enabled\": true }`."
370
- }
371
- },
372
- "additionalProperties": false,
373
- "description": "On-device AI product feature (Ollama + browser / WebLLM). Distinct from the per-user Settings → AI “Allow apps to use AI” toggle."
374
- },
375
374
  "HostingConfig": {
376
375
  "type": "object",
377
376
  "properties": {
@@ -400,20 +399,70 @@
400
399
  "additionalProperties": false,
401
400
  "description": "Optional hosting-service wiring for `shellui deploy` preview uploads. Preview sites expire after 7 days unless redeployed to the same slug."
402
401
  },
403
- "EmailConfig": {
402
+ "NavigationGroup": {
404
403
  "type": "object",
405
404
  "properties": {
406
- "url": {
405
+ "title": {
406
+ "anyOf": [
407
+ {
408
+ "type": "string"
409
+ },
410
+ {
411
+ "$ref": "#/definitions/LocalizedString"
412
+ }
413
+ ]
414
+ },
415
+ "items": {
416
+ "type": "array",
417
+ "items": {
418
+ "$ref": "#/definitions/NavigationItem"
419
+ }
420
+ },
421
+ "position": {
407
422
  "type": "string",
408
- "description": "Base URL of email-service. Default: `https://email.shellui.com` when `email` is set and this is omitted. Local: `http://localhost:8003`."
423
+ "enum": ["start", "end"],
424
+ "description": "Sidebar position: 'start' (default) or 'end'. End groups are rendered in the sidebar footer."
425
+ }
426
+ },
427
+ "required": ["title", "items"],
428
+ "additionalProperties": false
429
+ },
430
+ "AdministrationConfig": {
431
+ "type": "object",
432
+ "properties": {
433
+ "title": {
434
+ "anyOf": [
435
+ {
436
+ "type": "string"
437
+ },
438
+ {
439
+ "$ref": "#/definitions/LocalizedString"
440
+ }
441
+ ],
442
+ "description": "Section title shown in the admin sidebar below Dashboard."
409
443
  },
410
- "showInAdmin": {
444
+ "navigation": {
445
+ "type": "array",
446
+ "items": {
447
+ "$ref": "#/definitions/NavigationItem"
448
+ },
449
+ "description": "Flat list of navigation items (same shape as top-level `navigation` items). Order is preserved in the admin sidebar."
450
+ }
451
+ },
452
+ "required": ["title", "navigation"],
453
+ "additionalProperties": false,
454
+ "description": "Custom navigation section for the staff administration panel. Admin app URL remains `backend.adminUrl` / `backend.adminPathname`. v1 is a flat list only (no nested groups)."
455
+ },
456
+ "AiConfig": {
457
+ "type": "object",
458
+ "properties": {
459
+ "enabled": {
411
460
  "type": "boolean",
412
- "description": "When false, hide Admin → Email. Default: true (shown) when `email` is set."
461
+ "description": "Deploy-time opt-in for the whole AI feature. Default: false. Only `true` enables it. Otherwise: no AiBridge, no Settings → AI, SDK AI calls answer `unavailable`, and no WebLLM chunk/worker is loaded. Opt in with `\"ai\": { \"enabled\": true }`."
413
462
  }
414
463
  },
415
464
  "additionalProperties": false,
416
- "description": "Optional email-service wiring for Admin → Email and iframe apps. When `email` is set and `url` is omitted, the shell uses `https://email.shellui.com`."
465
+ "description": "On-device AI product feature (Ollama + browser / WebLLM). Distinct from the per-user Settings → AI “Allow apps to use AI” toggle."
417
466
  },
418
467
  "ThemeRef": {
419
468
  "anyOf": [
@@ -896,17 +945,6 @@
896
945
  "additionalProperties": false,
897
946
  "description": "Sentry error reporting configuration. Only used in production; ignored in dev."
898
947
  },
899
- "AuthConfig": {
900
- "type": "object",
901
- "properties": {
902
- "desktopScheme": {
903
- "type": "string",
904
- "description": "Custom URL scheme for Tauri sign-in, such as `shellui-playground`. Lowercase. Not `http`, `https`, or another browser scheme."
905
- }
906
- },
907
- "additionalProperties": false,
908
- "description": "Desktop (Tauri) sign-in. Ignored in the browser, so the web OAuth redirect stays as it is. The scheme must match the OAuth application's `desktop_redirect_scheme`."
909
- },
910
948
  "BackendConfig": {
911
949
  "type": "object",
912
950
  "properties": {
@@ -947,11 +985,6 @@
947
985
  "additionalProperties": false,
948
986
  "description": "Backend API configuration."
949
987
  },
950
- "BackendType": {
951
- "type": "string",
952
- "enum": ["shellui", "supabase"],
953
- "description": "Supported backend providers for auth/API communication."
954
- },
955
988
  "BackendLoginConfig": {
956
989
  "type": "object",
957
990
  "properties": {
@@ -986,6 +1019,17 @@
986
1019
  "enum": ["password", "oauth", "magic_link", "web3"],
987
1020
  "description": "Supported auth login methods that can be declared in config."
988
1021
  },
1022
+ "AuthConfig": {
1023
+ "type": "object",
1024
+ "properties": {
1025
+ "desktopScheme": {
1026
+ "type": "string",
1027
+ "description": "Custom URL scheme for Tauri sign-in, such as `shellui-playground`. Lowercase. Not `http`, `https`, or another browser scheme."
1028
+ }
1029
+ },
1030
+ "additionalProperties": false,
1031
+ "description": "Desktop (Tauri) sign-in. Ignored in the browser, so the web OAuth redirect stays as it is. The scheme must match the OAuth application's `desktop_redirect_scheme`."
1032
+ },
989
1033
  "SecurityConfig": {
990
1034
  "type": "object",
991
1035
  "properties": {
package/src/app.tsx CHANGED
@@ -9,6 +9,7 @@ import { ThemeProvider } from './features/theme/ThemeProvider';
9
9
  import { I18nProvider } from './i18n/I18nProvider';
10
10
  import { DialogProvider } from './features/alertDialog/DialogContext';
11
11
  import { CookieConsentModal } from './features/cookieConsent/CookieConsentModal';
12
+ import { AppBackendSessionHost } from './features/auth/appBackend/AppBackendSessionHost';
12
13
  import { AuthProvider } from './features/auth/AuthProvider';
13
14
  import { StorageBridge } from './features/storage/StorageBridge';
14
15
  import { ShellAiHost } from './features/ai/ShellAiHost';
@@ -134,6 +135,7 @@ const App = () => {
134
135
  <ConfigProvider>
135
136
  <MessagingSecurityBootstrap />
136
137
  <AuthProvider>
138
+ <AppBackendSessionHost />
137
139
  <StorageBridge />
138
140
  <SettingsProvider>
139
141
  <ShellAiHost />
@@ -14,6 +14,7 @@ import { LoadingOverlay } from './LoadingOverlay';
14
14
  import { LOADING_OVERLAY_DURATION_MS } from '../constants/loading';
15
15
  import { IFRAME_FOREIGN_ATTR } from '../features/layouts/chrome/constants';
16
16
  import { resolveContentIframeSandbox } from './contentIframeSandbox';
17
+ import { isSafeIframeUrl, isSameOrigin } from './iframeUrlSafety';
17
18
 
18
19
  const logger = getLogger('shellcore');
19
20
 
@@ -30,29 +31,8 @@ function isSafeShellPath(path: string): boolean {
30
31
  return true;
31
32
  }
32
33
 
33
- function isSafeIframeUrl(url: string): boolean {
34
- try {
35
- const parsed = new URL(url, typeof window !== 'undefined' ? window.location.href : undefined);
36
- return parsed.protocol === 'http:' || parsed.protocol === 'https:';
37
- } catch {
38
- return false;
39
- }
40
- }
41
-
42
34
  function isSameOriginAsNavItem(targetUrl: string, navItem: NavigationItem): boolean {
43
- try {
44
- const target = new URL(
45
- targetUrl,
46
- typeof window !== 'undefined' ? window.location.href : undefined,
47
- );
48
- const allowed = new URL(
49
- navItem.url,
50
- typeof window !== 'undefined' ? window.location.href : undefined,
51
- );
52
- return target.origin === allowed.origin;
53
- } catch {
54
- return false;
55
- }
35
+ return isSameOrigin(targetUrl, navItem.url);
56
36
  }
57
37
 
58
38
  /** Apply a URL inside the iframe without adding a joint session-history entry. */
@@ -0,0 +1,67 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { isSafeIframeUrl, isSameOrigin } from './iframeUrlSafety';
3
+
4
+ const shellAt = (href: string) => {
5
+ const url = new URL(href);
6
+ return { href: url.href, protocol: url.protocol, host: url.host };
7
+ };
8
+
9
+ describe('isSafeIframeUrl', () => {
10
+ const tauriShell = shellAt('tauri://localhost/dialog');
11
+
12
+ test('accepts relative app URLs under a tauri://localhost shell', () => {
13
+ expect(isSafeIframeUrl('/app#/toaster', tauriShell)).toBe(true);
14
+ expect(isSafeIframeUrl('/app/#/dialog', tauriShell)).toBe(true);
15
+ expect(isSafeIframeUrl('tauri://localhost/app#/layout', tauriShell)).toBe(true);
16
+ });
17
+
18
+ test('accepts http(s) URLs from any shell', () => {
19
+ expect(isSafeIframeUrl('https://shellui.com/', tauriShell)).toBe(true);
20
+ expect(isSafeIframeUrl('/app#/toaster', shellAt('https://playground.shellui.com/dialog'))).toBe(
21
+ true,
22
+ );
23
+ });
24
+
25
+ test('refuses another custom-scheme host than the shell', () => {
26
+ expect(isSafeIframeUrl('tauri://evil/app', tauriShell)).toBe(false);
27
+ expect(isSafeIframeUrl('other://localhost/app', tauriShell)).toBe(false);
28
+ });
29
+
30
+ test('still refuses javascript:, data: and invalid URLs', () => {
31
+ for (const shell of [tauriShell, shellAt('https://playground.shellui.com/')]) {
32
+ expect(isSafeIframeUrl('javascript:alert(1)', shell)).toBe(false);
33
+ expect(isSafeIframeUrl('data:text/html,<script>alert(1)</script>', shell)).toBe(false);
34
+ expect(isSafeIframeUrl('blob:https://playground.shellui.com/x', shell)).toBe(false);
35
+ }
36
+ expect(isSafeIframeUrl('http://[bad', tauriShell)).toBe(false);
37
+ });
38
+ });
39
+
40
+ describe('isSameOrigin', () => {
41
+ const tauriShell = shellAt('tauri://localhost/dialog');
42
+
43
+ test('page-to-page under tauri://localhost stays on the nav item origin', () => {
44
+ // Shell at /dialog switches to the Toaster item: URL built from the nav item URL.
45
+ expect(isSameOrigin('/app#/toaster', '/app/#/toaster', tauriShell)).toBe(true);
46
+ expect(
47
+ isSafeIframeUrl('/app#/toaster', tauriShell) &&
48
+ isSameOrigin('/app#/toaster', '/app/#/toaster', tauriShell),
49
+ ).toBe(true);
50
+ });
51
+
52
+ test('different tauri hosts are not equal', () => {
53
+ expect(isSameOrigin('tauri://localhost/app', 'tauri://other/app', tauriShell)).toBe(false);
54
+ expect(isSameOrigin('tauri://localhost/app', 'other://localhost/app', tauriShell)).toBe(false);
55
+ });
56
+
57
+ test('compares http(s) origins as before', () => {
58
+ expect(isSameOrigin('https://shellui.com/docs', 'https://shellui.com/', tauriShell)).toBe(true);
59
+ expect(isSameOrigin('https://evil.com/', 'https://shellui.com/', tauriShell)).toBe(false);
60
+ expect(isSameOrigin('http://shellui.com/', 'https://shellui.com/', tauriShell)).toBe(false);
61
+ });
62
+
63
+ test('opaque URLs never match', () => {
64
+ expect(isSameOrigin('data:text/html,x', 'data:text/html,y', tauriShell)).toBe(false);
65
+ expect(isSameOrigin('javascript:void 0', 'javascript:void 0', tauriShell)).toBe(false);
66
+ });
67
+ });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * URL checks for content iframes driven by the shell.
3
+ *
4
+ * The desktop app serves the shell from a custom scheme (`tauri://localhost` on
5
+ * macOS and Linux), so relative nav URLs like `/app#/dialog` resolve to that
6
+ * scheme. Those are as safe as the shell itself. Anything else must be http(s).
7
+ * `javascript:`, `data:` and other schemes are always refused.
8
+ */
9
+
10
+ type ShellLocation = Pick<Location, 'href' | 'protocol' | 'host'>;
11
+
12
+ const currentShellLocation = (): ShellLocation | undefined =>
13
+ typeof window !== 'undefined' ? window.location : undefined;
14
+
15
+ const parse = (url: string, base?: string): URL | null => {
16
+ try {
17
+ return new URL(url, base);
18
+ } catch {
19
+ return null;
20
+ }
21
+ };
22
+
23
+ /** Protocol + host, which stays meaningful for custom schemes whose `.origin` is "null". */
24
+ const originKey = (url: URL): string => `${url.protocol}//${url.host}`;
25
+
26
+ const isShellOrigin = (url: URL, shell: ShellLocation): boolean =>
27
+ // Only hierarchical URLs with a host can match (`javascript:` and `data:` have none).
28
+ url.host !== '' && url.protocol === shell.protocol && url.host === shell.host;
29
+
30
+ export function isSafeIframeUrl(
31
+ url: string,
32
+ shell: ShellLocation | undefined = currentShellLocation(),
33
+ ): boolean {
34
+ const parsed = parse(url, shell?.href);
35
+ if (!parsed) return false;
36
+ if (parsed.protocol === 'http:' || parsed.protocol === 'https:') return true;
37
+ return shell ? isShellOrigin(parsed, shell) : false;
38
+ }
39
+
40
+ export function isSameOrigin(
41
+ targetUrl: string,
42
+ allowedUrl: string,
43
+ shell: ShellLocation | undefined = currentShellLocation(),
44
+ ): boolean {
45
+ const target = parse(targetUrl, shell?.href);
46
+ const allowed = parse(allowedUrl, shell?.href);
47
+ if (!target || !allowed) return false;
48
+ if (!target.host || !allowed.host) return false;
49
+ return originKey(target) === originKey(allowed);
50
+ }
@@ -10,10 +10,13 @@ import { useConfig } from '../config/useConfig';
10
10
  import type { NavigationItem } from '../config/types';
11
11
  import { AppLayout } from '../layouts/AppLayout';
12
12
  import {
13
+ MAC_TRAFFIC_LIGHTS_GAP_PX,
14
+ MAC_TRAFFIC_LIGHTS_WIDTH_PX,
13
15
  isShellUiRootWindow,
14
16
  SafeAreaTopbarOffset,
15
17
  SafeAreaTopbarStrip,
16
- } from '../layouts/chrome/SafeAreaTopbar';
18
+ useMacTrafficLights,
19
+ } from '../layouts/chrome';
17
20
  import { AdminForbiddenAccess } from './components/AdminForbiddenAccess';
18
21
  import { getAdminContentUrl, getAdminPath } from './config';
19
22
  import { buildAdminIframeSrc } from './utils';
@@ -70,8 +73,12 @@ export const AdminView = () => {
70
73
  }, [config?.title]);
71
74
 
72
75
  const showSafeAreaTopbar = isShellUiRootWindow();
76
+ const trafficLights = useMacTrafficLights();
77
+ const chromeInset = trafficLights
78
+ ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
79
+ : undefined;
73
80
  const headerStyle = {
74
- paddingLeft: 'max(0.5rem, var(--shellui-safe-area-left))',
81
+ paddingLeft: chromeInset ?? 'max(0.5rem, var(--shellui-safe-area-left))',
75
82
  paddingRight: 'max(0.75rem, var(--shellui-safe-area-right))',
76
83
  ...(isMobile && showSafeAreaTopbar
77
84
  ? {
@@ -90,13 +97,17 @@ export const AdminView = () => {
90
97
  <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
91
98
  <SafeAreaTopbarStrip enabled={showSafeAreaTopbar} />
92
99
  <header
93
- className="flex shrink-0 items-center justify-between border-b bg-card"
100
+ className="relative z-[46] flex shrink-0 items-center justify-between border-b bg-card select-none"
94
101
  style={headerStyle}
102
+ {...(trafficLights
103
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
104
+ : {})}
95
105
  >
96
106
  <Button
97
107
  type="button"
98
108
  variant="ghost"
99
109
  size="sm"
110
+ data-shellui-no-drag=""
100
111
  onClick={() => navigate('/')}
101
112
  >
102
113
  <svg
@@ -114,7 +125,10 @@ export const AdminView = () => {
114
125
  </svg>
115
126
  Back to home
116
127
  </Button>
117
- <div className="flex items-center gap-2">
128
+ <div
129
+ data-shellui-no-drag=""
130
+ className="flex items-center gap-2"
131
+ >
118
132
  <LoginButton
119
133
  variant="appbar"
120
134
  logoutOnly
@@ -11,6 +11,8 @@ import urls from '../../constants/urls';
11
11
  import { useConfig } from '../config/useConfig';
12
12
  import { useIsTauriRuntime } from '../layouts/chrome/runtime';
13
13
  import { isShellSettingsFrameMessage } from '../security/trustedFrames';
14
+ import { endAppBackendSessions } from './appBackend/appBackendSessions';
15
+ import { isSilentAuthCallbackFrame } from './appBackend/silentSignIn';
14
16
  import { createAuthBackend } from './backends';
15
17
  import { AuthContext, type AuthContextValue, type OAuthCallbackResult } from './hooks/useAuth';
16
18
  import type { AuthEvent, AuthSession, AuthUser, UserPreferences } from './types';
@@ -196,6 +198,16 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
196
198
  return;
197
199
  }
198
200
 
201
+ // The hidden frame that finishes sign-in for another identity server must
202
+ // not read or write the shell session (sessionStorage is shared).
203
+ if (isSilentAuthCallbackFrame()) {
204
+ if (!cancelled) {
205
+ setSession(null);
206
+ setIsLoading(false);
207
+ }
208
+ return;
209
+ }
210
+
199
211
  const isIframe = window.parent !== window;
200
212
  const now = Math.floor(Date.now() / 1000);
201
213
  const sessionFromHash = backend.readSessionFromCallback(window.location.hash, now);
@@ -391,7 +403,12 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
391
403
  });
392
404
  return true;
393
405
  }
394
- backend.startOAuth(provider, redirectPath, oauthClientId);
406
+ void Promise.resolve(backend.startOAuth(provider, redirectPath, oauthClientId)).catch(
407
+ (err) => {
408
+ setError(err instanceof Error ? err.message : 'Unable to start OAuth login.');
409
+ setErrorCode(err instanceof AuthRequestError ? err.code : null);
410
+ },
411
+ );
395
412
  return true;
396
413
  } catch (err) {
397
414
  setError(err instanceof Error ? err.message : 'Unable to start OAuth login.');
@@ -624,6 +641,12 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
624
641
  // Even if API sign-out fails, still clear local session.
625
642
  }
626
643
 
644
+ try {
645
+ await endAppBackendSessions();
646
+ } catch {
647
+ // App-server sign-out is best effort. The shell session still clears.
648
+ }
649
+
627
650
  clearStoredAuthSession();
628
651
  setSession(null);
629
652
  setAuthEvent(null);
@@ -632,23 +655,40 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
632
655
  }, [backend, bffAuthEnabled, session]);
633
656
 
634
657
  useEffect(() => {
658
+ if (typeof window === 'undefined' || window.parent !== window) return;
635
659
  const liveTauri = tauriRuntime || isLiveTauriRuntime();
636
660
  if (!shouldUseDesktopSignIn(config, liveTauri)) return;
637
661
  const scheme = normalizeDesktopScheme(config.auth?.desktopScheme);
638
662
  if (!scheme) return;
639
663
  setActiveDesktopScheme(scheme);
640
664
  let cancelled = false;
665
+
666
+ // The login page may sit in a modal or drawer iframe that cannot see this result.
667
+ const finishOverlayLogin = (failure: string | null) => {
668
+ postShellMessage({ type: 'SHELLUI_CLOSE_MODAL', payload: {} });
669
+ postShellMessage({ type: 'SHELLUI_CLOSE_DRAWER', payload: {} });
670
+ if (failure === null || window.location.pathname === urls.login) return;
671
+ shellui.toast({
672
+ type: 'error',
673
+ title: i18n.getFixedT(null, 'common')('loginPage.signInCouldNotContinue'),
674
+ description: failure || undefined,
675
+ });
676
+ };
677
+
641
678
  const unsubscribe = subscribeDesktopAuth((event) => {
642
679
  if (cancelled) return;
643
680
  if (event.type === 'error') {
644
681
  setError(event.message);
645
682
  setErrorCode(event.errorCode);
683
+ finishOverlayLogin(event.message);
646
684
  return;
647
685
  }
648
686
  void completeOAuthSessionCallback({
649
687
  authCode: event.authCode,
650
688
  redirectTo: event.redirectTo,
651
689
  codeVerifier: event.codeVerifier,
690
+ }).then((result) => {
691
+ if (!cancelled) finishOverlayLogin(result.ok ? null : (result.error ?? ''));
652
692
  });
653
693
  });
654
694
  void ensureDesktopDeepLinkListener({ replayLaunchUrl: true });
@@ -656,7 +696,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
656
696
  cancelled = true;
657
697
  unsubscribe();
658
698
  };
659
- }, [completeOAuthSessionCallback, config, tauriRuntime]);
699
+ }, [completeOAuthSessionCallback, config, i18n, tauriRuntime]);
660
700
 
661
701
  useEffect(() => {
662
702
  if (typeof window === 'undefined' || window.parent !== window) {