@shellui/core 0.5.0-beta.3 → 0.5.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 +5 -5
- package/package.json +3 -2
- package/schemas/shellui.config.schema.json +98 -33
- package/src/app.tsx +10 -4
- package/src/components/ContentView.tsx +3 -5
- package/src/components/contentIframeSandbox.spec.ts +25 -0
- package/src/components/contentIframeSandbox.ts +43 -0
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu.tsx +39 -4
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +3 -2
- package/src/components/ui/tabs.tsx +52 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/auth/AuthProvider.tsx +169 -35
- package/src/features/auth/backends/index.ts +2 -0
- package/src/features/auth/backends/shellui.ts +43 -35
- package/src/features/auth/backends/supabase.ts +1 -0
- package/src/features/auth/backends/types.ts +5 -0
- package/src/features/auth/components/LoginView.tsx +5 -1
- package/src/features/auth/components/OAuthCallbackView.tsx +115 -44
- package/src/features/auth/constants/oauth.ts +2 -0
- package/src/features/auth/hooks/useAuth.tsx +4 -0
- package/src/features/auth/utils/authSessionPersistence.spec.ts +93 -0
- package/src/features/auth/utils/authSessionPersistence.ts +138 -0
- package/src/features/auth/utils/authStorageKeys.ts +8 -0
- package/src/features/auth/utils/bffAuthClient.ts +107 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +22 -0
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +17 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.spec.ts +29 -0
- package/src/features/auth/utils/buildSessionFromTokenPayload.ts +24 -0
- package/src/features/auth/utils/index.ts +18 -3
- package/src/features/auth/utils/isBffAuthEnabled.ts +12 -0
- package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
- package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
- package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
- package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
- package/src/features/chromeActions/chromeActionsStore.ts +77 -0
- package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
- package/src/features/chromeActions/computeActionInsets.ts +326 -0
- package/src/features/chromeActions/index.ts +26 -0
- package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
- package/src/features/config/types.ts +49 -2
- package/src/features/layouts/AppLayout.tsx +4 -4
- package/src/features/layouts/OverlayShell.tsx +60 -12
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
- package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
- package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
- package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/runtime.ts +73 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
- package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
- package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
- package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
- package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
- package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
- package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
- package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
- package/src/features/messaging/MessagingSecurityBootstrap.tsx +19 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.spec.ts +86 -0
- package/src/features/messaging/deriveAllowedMessageOrigins.ts +74 -0
- package/src/features/modal/ModalContext.spec.ts +13 -2
- package/src/features/modal/validateAndNormalizeUrl.ts +9 -23
- package/src/features/overlays/ResponsiveModal.tsx +201 -21
- package/src/features/overlays/overlaySize.spec.ts +18 -0
- package/src/features/overlays/overlaySize.ts +89 -0
- package/src/features/security/trustedFrames.spec.ts +129 -0
- package/src/features/security/trustedFrames.ts +79 -0
- package/src/features/security/urlAllowlist.spec.ts +99 -0
- package/src/features/security/urlAllowlist.ts +122 -0
- package/src/features/settings/SettingsProvider.tsx +38 -54
- package/src/features/settings/components/Develop.tsx +2 -0
- package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +23 -1
- package/src/features/settings/utils/buildSettingsForPropagation.ts +7 -0
- package/src/features/storage/StorageBridge.spec.ts +82 -0
- package/src/features/storage/StorageBridge.tsx +25 -3
- package/src/features/storage/StoragePickerContext.tsx +3 -4
- package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
- package/src/features/storage/uploads/uploadQueue.ts +44 -6
- package/src/features/theme/applyTheme.ts +23 -5
- package/src/hooks/use-mobile.tsx +21 -7
- package/src/i18n/translations/en/settings.json +9 -0
- package/src/i18n/translations/fr/settings.json +9 -0
- package/src/index.css +264 -124
- package/src/index.html +6 -4
- package/src/index.ts +8 -0
- package/src/routes/components/NavigationItemRoute.tsx +30 -15
- package/src/routes/components/RouteFallback.tsx +15 -0
- package/src/routes/routes.tsx +14 -0
- package/src/routes/utils/navigationRouteAccess.spec.ts +85 -0
- package/src/routes/utils/navigationRouteAccess.ts +43 -0
- package/src/features/auth/utils/clearStoredAuthSession.spec.ts +0 -23
- package/src/features/auth/utils/clearStoredAuthSession.ts +0 -10
- package/src/features/auth/utils/persistAuthSession.spec.ts +0 -35
- package/src/features/auth/utils/persistAuthSession.ts +0 -12
- package/src/features/auth/utils/readStoredAuthSession.spec.ts +0 -34
- package/src/features/auth/utils/readStoredAuthSession.ts +0 -14
- package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
- package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
- package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# @shellui/core
|
|
2
2
|
|
|
3
|
-
Shellui
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
3
|
+
React runtime for the Shellui host. `@shellui/cli` depends on this package. Install it yourself when you import config types or `useAuth` from host code.
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
6
|
npm install @shellui/core
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
```typescript
|
|
10
|
+
import type { ShellUIConfig } from '@shellui/core';
|
|
11
|
+
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Docs: [Core](https://docs.shellui.com/core), [CLI](https://docs.shellui.com/cli).
|
|
14
14
|
|
|
15
15
|
## License
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellui/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Shellui Core - Core React application runtime",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
51
51
|
"@radix-ui/react-separator": "^1.1.8",
|
|
52
52
|
"@radix-ui/react-slot": "^1.2.4",
|
|
53
|
+
"@radix-ui/react-tabs": "^1.1.21",
|
|
53
54
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
54
55
|
"@sentry/react": "^10.39.0",
|
|
55
56
|
"@supabase/supabase-js": "^2.99.3",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"workbox-routing": "^7.4.0",
|
|
72
73
|
"workbox-strategies": "^7.4.0",
|
|
73
74
|
"workbox-window": "^7.4.0",
|
|
74
|
-
"@shellui/sdk": "0.5.
|
|
75
|
+
"@shellui/sdk": "0.5.1"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
78
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"hosting": {
|
|
73
73
|
"$ref": "#/definitions/HostingConfig",
|
|
74
|
-
"description": "Hosting-service connection
|
|
74
|
+
"description": "Hosting-service connection. Propagated to iframes via SDK settings. Enables `shellui deploy` when `url` is set."
|
|
75
75
|
},
|
|
76
76
|
"theme": {
|
|
77
77
|
"$ref": "#/definitions/ThemeRef",
|
|
@@ -111,6 +111,10 @@
|
|
|
111
111
|
"$ref": "#/definitions/BackendConfig",
|
|
112
112
|
"description": "Backend communication config. Defaults to undefined (no backend integration)."
|
|
113
113
|
},
|
|
114
|
+
"security": {
|
|
115
|
+
"$ref": "#/definitions/SecurityConfig",
|
|
116
|
+
"description": "Host security (postMessage allowlist, BFF / HttpOnly refresh, shell CSP)."
|
|
117
|
+
},
|
|
114
118
|
"cookieConsent": {
|
|
115
119
|
"$ref": "#/definitions/CookieConsentConfig",
|
|
116
120
|
"description": "Cookie consent: list of cookies by category; accepted ids are stored in settings."
|
|
@@ -121,7 +125,7 @@
|
|
|
121
125
|
},
|
|
122
126
|
"dev": {
|
|
123
127
|
"$ref": "#/definitions/DevConfig",
|
|
124
|
-
"description": "CLI-only companion for `shellui start`
|
|
128
|
+
"description": "CLI-only companion for `shellui start`. Spawn `run` and/or follow `url`. Stripped before the config is sent to the browser."
|
|
125
129
|
},
|
|
126
130
|
"$schema": {
|
|
127
131
|
"type": "string",
|
|
@@ -130,25 +134,6 @@
|
|
|
130
134
|
},
|
|
131
135
|
"additionalProperties": false
|
|
132
136
|
},
|
|
133
|
-
"DevConfig": {
|
|
134
|
-
"type": "object",
|
|
135
|
-
"description": "CLI-only companion for `shellui start`. Not shipped to the browser.",
|
|
136
|
-
"properties": {
|
|
137
|
-
"run": {
|
|
138
|
-
"type": "string",
|
|
139
|
-
"description": "Command to spawn in the project root (e.g. `vite`)."
|
|
140
|
-
},
|
|
141
|
-
"url": {
|
|
142
|
-
"type": "string",
|
|
143
|
-
"description": "URL (or host:port) to wait for before the shell opens, and to follow in follow-only mode."
|
|
144
|
-
},
|
|
145
|
-
"name": {
|
|
146
|
-
"type": "string",
|
|
147
|
-
"description": "Log prefix for the companion (default: `app`)."
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
"additionalProperties": false
|
|
151
|
-
},
|
|
152
137
|
"ThemeAsset": {
|
|
153
138
|
"anyOf": [
|
|
154
139
|
{
|
|
@@ -181,7 +166,7 @@
|
|
|
181
166
|
"app-bar-inset",
|
|
182
167
|
"floating"
|
|
183
168
|
],
|
|
184
|
-
"description": "Layout mode: 'sidebar' (default) shows navigation sidebar; 'sidebar-inset' is sidebar with a padded, rounded main frame
|
|
169
|
+
"description": "Layout mode: 'sidebar' (default) shows navigation sidebar; 'sidebar-inset' is sidebar with a padded, rounded main frame; 'fullscreen' shows only content area; 'windows' shows a taskbar with start menu and multi-window desktop; 'app-bar' shows a compact top bar; 'app-bar-inset' is app-bar with the same padded, rounded main frame as sidebar-inset; 'floating' is glass chrome over full-bleed content (bottom tabs on phone/tablet, floating sidebar on desktop)."
|
|
185
170
|
},
|
|
186
171
|
"NavigationItem": {
|
|
187
172
|
"type": "object",
|
|
@@ -257,7 +242,7 @@
|
|
|
257
242
|
},
|
|
258
243
|
"safeForAuthToken": {
|
|
259
244
|
"type": "boolean",
|
|
260
|
-
"description": "Trust control for auth token sharing to iframe apps.\n- undefined/
|
|
245
|
+
"description": "Trust control for auth token sharing to iframe apps.\n- undefined/false: untrusted (default), access token is not shared\n- true: trusted (opt-in), access token can be shared to this companion"
|
|
261
246
|
}
|
|
262
247
|
},
|
|
263
248
|
"required": ["label", "path", "url"],
|
|
@@ -373,16 +358,15 @@
|
|
|
373
358
|
},
|
|
374
359
|
"publicUrl": {
|
|
375
360
|
"type": "string",
|
|
376
|
-
"description": "Optional public base for browsable
|
|
361
|
+
"description": "Optional public base for browsable app URLs when different from `url` (e.g. CDN or path-style gateway). The deploy API returns `urls` when possible."
|
|
377
362
|
},
|
|
378
|
-
"
|
|
363
|
+
"slug": {
|
|
379
364
|
"type": "string",
|
|
380
|
-
"
|
|
381
|
-
"description": "Deprecated. Use `slug` to redeploy to an existing preview site."
|
|
365
|
+
"description": "Optional preview site slug. When set, `shellui deploy` redeploys to this slug (must belong to your company and user). When omitted, each deploy gets a new slug."
|
|
382
366
|
},
|
|
383
|
-
"
|
|
367
|
+
"app": {
|
|
384
368
|
"type": "string",
|
|
385
|
-
"
|
|
369
|
+
"deprecated": "Use `slug` instead."
|
|
386
370
|
},
|
|
387
371
|
"showInAdmin": {
|
|
388
372
|
"type": "boolean",
|
|
@@ -391,7 +375,7 @@
|
|
|
391
375
|
},
|
|
392
376
|
"required": ["url"],
|
|
393
377
|
"additionalProperties": false,
|
|
394
|
-
"description": "Optional hosting-service wiring for `shellui deploy` preview uploads. Preview sites expire after 7 days unless redeployed
|
|
378
|
+
"description": "Optional hosting-service wiring for `shellui deploy` preview uploads. Preview sites expire after 7 days unless redeployed to the same slug."
|
|
395
379
|
},
|
|
396
380
|
"ThemeRef": {
|
|
397
381
|
"anyOf": [
|
|
@@ -874,6 +858,68 @@
|
|
|
874
858
|
"additionalProperties": false,
|
|
875
859
|
"description": "Sentry error reporting configuration. Only used in production; ignored in dev."
|
|
876
860
|
},
|
|
861
|
+
"SecurityConfig": {
|
|
862
|
+
"type": "object",
|
|
863
|
+
"properties": {
|
|
864
|
+
"allowedMessageOrigins": {
|
|
865
|
+
"type": "array",
|
|
866
|
+
"items": {
|
|
867
|
+
"type": "string"
|
|
868
|
+
},
|
|
869
|
+
"description": "Extra http(s) origins (or absolute URLs) allowed for Shellui postMessage traffic. Unioned with origins derived from navigation, storage, and admin URLs."
|
|
870
|
+
},
|
|
871
|
+
"bffAuth": {
|
|
872
|
+
"$ref": "#/definitions/BffAuthConfig"
|
|
873
|
+
},
|
|
874
|
+
"csp": {
|
|
875
|
+
"$ref": "#/definitions/CspConfig"
|
|
876
|
+
}
|
|
877
|
+
},
|
|
878
|
+
"additionalProperties": false,
|
|
879
|
+
"description": "Host security options. Additive namespace for postMessage, CSP, BFF auth, etc."
|
|
880
|
+
},
|
|
881
|
+
"BffAuthConfig": {
|
|
882
|
+
"type": "object",
|
|
883
|
+
"properties": {
|
|
884
|
+
"enabled": {
|
|
885
|
+
"type": "boolean",
|
|
886
|
+
"description": "When true, refresh tokens are stored in an HttpOnly cookie via same-origin /api/auth/* routes."
|
|
887
|
+
},
|
|
888
|
+
"cookieName": {
|
|
889
|
+
"type": "string",
|
|
890
|
+
"description": "HttpOnly refresh cookie name. Default: shellui_refresh."
|
|
891
|
+
}
|
|
892
|
+
},
|
|
893
|
+
"additionalProperties": false
|
|
894
|
+
},
|
|
895
|
+
"CspConfig": {
|
|
896
|
+
"type": "object",
|
|
897
|
+
"properties": {
|
|
898
|
+
"enforce": {
|
|
899
|
+
"type": "boolean",
|
|
900
|
+
"description": "Emit enforcing Content-Security-Policy. Default false (report-only rollout)."
|
|
901
|
+
},
|
|
902
|
+
"reportOnly": {
|
|
903
|
+
"type": "boolean",
|
|
904
|
+
"description": "Emit Content-Security-Policy-Report-Only. Default true when security.csp is set."
|
|
905
|
+
},
|
|
906
|
+
"reportUri": {
|
|
907
|
+
"type": "string",
|
|
908
|
+
"description": "Optional CSP violation report endpoint."
|
|
909
|
+
},
|
|
910
|
+
"connectSrc": {
|
|
911
|
+
"type": "array",
|
|
912
|
+
"items": { "type": "string" },
|
|
913
|
+
"description": "Extra connect-src hosts (companions, analytics)."
|
|
914
|
+
},
|
|
915
|
+
"frameSrc": {
|
|
916
|
+
"type": "array",
|
|
917
|
+
"items": { "type": "string" },
|
|
918
|
+
"description": "Extra frame-src hosts for companion iframes."
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
"additionalProperties": false
|
|
922
|
+
},
|
|
877
923
|
"BackendConfig": {
|
|
878
924
|
"type": "object",
|
|
879
925
|
"properties": {
|
|
@@ -895,7 +941,7 @@
|
|
|
895
941
|
},
|
|
896
942
|
"loginUrl": {
|
|
897
943
|
"type": "string",
|
|
898
|
-
"description": "Public origin (or URL) of this shell where
|
|
944
|
+
"description": "Public origin (or full URL) of this shell — where `/login` and OAuth `/login/callback` live. Used by `shellui login`. Not the iframe admin app (`adminUrl`). Example: `https://app.example.com` or `http://127.0.0.1:4000`."
|
|
899
945
|
},
|
|
900
946
|
"publishableKey": {
|
|
901
947
|
"type": "string",
|
|
@@ -938,11 +984,11 @@
|
|
|
938
984
|
},
|
|
939
985
|
"panelUrl": {
|
|
940
986
|
"type": "string",
|
|
941
|
-
"description": "Full-bleed iframe URL for the login left panel
|
|
987
|
+
"description": "Full-bleed iframe URL for the login left panel (wins over panelImage)."
|
|
942
988
|
},
|
|
943
989
|
"panelImage": {
|
|
944
990
|
"type": "string",
|
|
945
|
-
"description": "Centered, ratio-preserving image
|
|
991
|
+
"description": "Centered, ratio-preserving image for the login left panel."
|
|
946
992
|
}
|
|
947
993
|
},
|
|
948
994
|
"additionalProperties": false,
|
|
@@ -1022,6 +1068,25 @@
|
|
|
1022
1068
|
}
|
|
1023
1069
|
},
|
|
1024
1070
|
"additionalProperties": false
|
|
1071
|
+
},
|
|
1072
|
+
"DevConfig": {
|
|
1073
|
+
"type": "object",
|
|
1074
|
+
"properties": {
|
|
1075
|
+
"run": {
|
|
1076
|
+
"type": "string",
|
|
1077
|
+
"description": "Command to spawn in the project root (e.g. `vite`)."
|
|
1078
|
+
},
|
|
1079
|
+
"url": {
|
|
1080
|
+
"type": "string",
|
|
1081
|
+
"description": "URL (or host:port) to wait for / follow."
|
|
1082
|
+
},
|
|
1083
|
+
"name": {
|
|
1084
|
+
"type": "string",
|
|
1085
|
+
"description": "Log prefix name (default: `app`)."
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
"additionalProperties": false,
|
|
1089
|
+
"description": "Companion process for local `shellui start` (not used at runtime in the shell)."
|
|
1025
1090
|
}
|
|
1026
1091
|
},
|
|
1027
1092
|
"title": "ShellUIConfig",
|
package/src/app.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { CookieConsentModal } from './features/cookieConsent/CookieConsentModal'
|
|
|
12
12
|
import { AuthProvider } from './features/auth/AuthProvider';
|
|
13
13
|
import { StorageBridge } from './features/storage/StorageBridge';
|
|
14
14
|
import { SonnerProvider } from './features/sonner/SonnerContext';
|
|
15
|
+
import { ChromeActionsHost, ChromeActionsProvider } from './features/chromeActions';
|
|
15
16
|
import { Toaster } from './components/ui/sonner';
|
|
16
17
|
import { UploadToaster } from './features/storage/uploads/UploadToaster';
|
|
17
18
|
import './features/sentry/initSentry';
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
} from './service-worker/register';
|
|
27
28
|
import { useSettings } from './features/settings/hooks/useSettings';
|
|
28
29
|
import { DesktopChrome } from './features/layouts/chrome/DesktopChrome';
|
|
30
|
+
import { MessagingSecurityBootstrap } from './features/messaging/MessagingSecurityBootstrap';
|
|
29
31
|
|
|
30
32
|
const AppContent = () => {
|
|
31
33
|
const { config } = useConfig();
|
|
@@ -129,6 +131,7 @@ const App = () => {
|
|
|
129
131
|
|
|
130
132
|
return (
|
|
131
133
|
<ConfigProvider>
|
|
134
|
+
<MessagingSecurityBootstrap />
|
|
132
135
|
<AuthProvider>
|
|
133
136
|
<StorageBridge />
|
|
134
137
|
<SettingsProvider>
|
|
@@ -136,10 +139,13 @@ const App = () => {
|
|
|
136
139
|
<I18nProvider>
|
|
137
140
|
<DialogProvider>
|
|
138
141
|
<SonnerProvider>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
<ChromeActionsProvider>
|
|
143
|
+
{/* Toaster + upload progress live at Shellui root so they survive navigation. */}
|
|
144
|
+
<Toaster />
|
|
145
|
+
<UploadToaster />
|
|
146
|
+
<ChromeActionsHost />
|
|
147
|
+
<AppContent />
|
|
148
|
+
</ChromeActionsProvider>
|
|
143
149
|
</SonnerProvider>
|
|
144
150
|
</DialogProvider>
|
|
145
151
|
</I18nProvider>
|
|
@@ -13,6 +13,7 @@ import { useLocation, useNavigate } from 'react-router';
|
|
|
13
13
|
import { LOADING_OVERLAY_DURATION_MS } from '../constants/loading';
|
|
14
14
|
import { LoadingOverlay } from './LoadingOverlay';
|
|
15
15
|
import { IFRAME_FOREIGN_ATTR } from '../features/layouts/chrome/constants';
|
|
16
|
+
import { resolveContentIframeSandbox } from './contentIframeSandbox';
|
|
16
17
|
|
|
17
18
|
const logger = getLogger('shellcore');
|
|
18
19
|
|
|
@@ -347,10 +348,7 @@ export const ContentView = ({
|
|
|
347
348
|
style={{ width: '100%', height: '100%', display: 'flex', position: 'relative' }}
|
|
348
349
|
className="min-h-0 flex-1 bg-background"
|
|
349
350
|
>
|
|
350
|
-
{/*
|
|
351
|
-
While this allows the iframe to remove its own sandboxing, it's acceptable here because the iframe content
|
|
352
|
-
is trusted microfrontend content from the same application origin.
|
|
353
|
-
Browser security warnings about this combination cannot be suppressed programmatically. */}
|
|
351
|
+
{/* Sandbox policy: see contentIframeSandbox.ts and docs/features/companion-isolation.md */}
|
|
354
352
|
{/* Strategy to prevent browser deprioritizing iframe rendering:
|
|
355
353
|
- loading="eager" explicitly requests immediate loading (not deferred)
|
|
356
354
|
- opacity:0 hides the iframe during loading while keeping it in the rendering pipeline
|
|
@@ -368,7 +366,7 @@ export const ContentView = ({
|
|
|
368
366
|
display: 'block',
|
|
369
367
|
opacity: isLoading ? 0 : 1,
|
|
370
368
|
}}
|
|
371
|
-
sandbox=
|
|
369
|
+
sandbox={resolveContentIframeSandbox(iframeUrl)}
|
|
372
370
|
referrerPolicy="no-referrer-when-downgrade"
|
|
373
371
|
/>
|
|
374
372
|
{isLoading && <LoadingOverlay />}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { LEGACY_POPUP_ESCAPE_TOKEN, resolveContentIframeSandbox } from './contentIframeSandbox';
|
|
3
|
+
|
|
4
|
+
describe('resolveContentIframeSandbox', () => {
|
|
5
|
+
test('uses tightened sandbox without popup escape', () => {
|
|
6
|
+
const sandbox = resolveContentIframeSandbox('http://localhost:5173/', 'http://localhost:4000');
|
|
7
|
+
expect(sandbox).toContain('allow-scripts');
|
|
8
|
+
expect(sandbox).toContain('allow-same-origin');
|
|
9
|
+
expect(sandbox).not.toContain(LEGACY_POPUP_ESCAPE_TOKEN);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('same-origin production companion uses the same tightened set', () => {
|
|
13
|
+
const sandbox = resolveContentIframeSandbox('/app/', 'https://example.com');
|
|
14
|
+
expect(sandbox).not.toContain(LEGACY_POPUP_ESCAPE_TOKEN);
|
|
15
|
+
expect(sandbox.split(' ').sort()).toEqual(
|
|
16
|
+
['allow-forms', 'allow-popups', 'allow-same-origin', 'allow-scripts'].sort(),
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('falls back safely for invalid URLs', () => {
|
|
21
|
+
const sandbox = resolveContentIframeSandbox('not-a-valid-url', 'http://localhost:4000');
|
|
22
|
+
expect(sandbox).toContain('allow-scripts');
|
|
23
|
+
expect(sandbox).not.toContain(LEGACY_POPUP_ESCAPE_TOKEN);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion/content iframe sandbox tokens.
|
|
3
|
+
*
|
|
4
|
+
* Threat model (Track F / M-18):
|
|
5
|
+
* - Dev: shell (:4000) and companion (:5173, :3000, …) use distinct origins; templates
|
|
6
|
+
* set `frame-ancestors` so companions accept shell framing.
|
|
7
|
+
* - Prod: companion is served from the same origin as the shell (`/app/`), which keeps
|
|
8
|
+
* postMessage and cookies workable while avoiding cross-origin framing surprises.
|
|
9
|
+
* - `allow-same-origin` + `allow-scripts` lets embedded scripts remove the sandbox
|
|
10
|
+
* attribute when the iframe is same-origin to its document — acceptable only for
|
|
11
|
+
* trusted navigation URLs you configure. Residual risk is documented in
|
|
12
|
+
* docs/features/companion-isolation.md.
|
|
13
|
+
*
|
|
14
|
+
* Incremental tightening: drop `allow-popups-to-escape-sandbox` (popups stay sandboxed).
|
|
15
|
+
*/
|
|
16
|
+
const SANDBOX_CONTENT = 'allow-same-origin allow-scripts allow-forms allow-popups';
|
|
17
|
+
|
|
18
|
+
/** @deprecated use SANDBOX_CONTENT — kept for tests asserting legacy tokens are gone */
|
|
19
|
+
export const LEGACY_POPUP_ESCAPE_TOKEN = 'allow-popups-to-escape-sandbox';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the `sandbox` attribute for a main content iframe.
|
|
23
|
+
*
|
|
24
|
+
* @param iframeUrl - Absolute or relative URL loaded in the iframe
|
|
25
|
+
* @param shellOrigin - Optional shell origin (for unit tests without `window`)
|
|
26
|
+
*/
|
|
27
|
+
export function resolveContentIframeSandbox(iframeUrl: string, shellOrigin?: string): string {
|
|
28
|
+
try {
|
|
29
|
+
const base =
|
|
30
|
+
typeof window !== 'undefined' ? window.location.href : (shellOrigin ?? 'http://localhost/');
|
|
31
|
+
const iframeOrigin = new URL(iframeUrl, base).origin;
|
|
32
|
+
const parentOrigin =
|
|
33
|
+
shellOrigin ?? (typeof window !== 'undefined' ? window.location.origin : iframeOrigin);
|
|
34
|
+
// Same-origin vs cross-origin companions share the tightened token set today.
|
|
35
|
+
// Cross-origin dev companions still require `allow-same-origin` for companion
|
|
36
|
+
// cookies/localStorage on their own origin; distinct-origin framing is the isolation layer.
|
|
37
|
+
void iframeOrigin;
|
|
38
|
+
void parentOrigin;
|
|
39
|
+
return SANDBOX_CONTENT;
|
|
40
|
+
} catch {
|
|
41
|
+
return SANDBOX_CONTENT;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -74,7 +74,11 @@ const DialogContent = forwardRef<ElementRef<typeof DialogPrimitive.Content>, Dia
|
|
|
74
74
|
>[0],
|
|
75
75
|
) => {
|
|
76
76
|
const target = event?.target as Element | null;
|
|
77
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
target?.closest?.(
|
|
79
|
+
'[data-sonner-toaster], [data-upload-toast], [data-shellui-chrome-actions]',
|
|
80
|
+
)
|
|
81
|
+
) {
|
|
78
82
|
event.preventDefault();
|
|
79
83
|
}
|
|
80
84
|
onPointerDownOutside?.(event);
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
type ComponentPropsWithoutRef,
|
|
4
|
+
type ElementRef,
|
|
5
|
+
type PointerEvent as ReactPointerEvent,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
8
|
import { cn } from '../../lib/utils';
|
|
4
9
|
import { Z_INDEX } from '../../lib/z-index';
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Default `modal={false}`: Radix modal menus set `pointer-events: none` on `body`,
|
|
13
|
+
* which breaks Apple Pencil (and sometimes fine touch) on iPad — items never get
|
|
14
|
+
* a `click` / `onSelect`. Non-modal matches LoginButton and Radix #1027.
|
|
15
|
+
*/
|
|
16
|
+
function DropdownMenu({
|
|
17
|
+
modal = false,
|
|
18
|
+
...props
|
|
19
|
+
}: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root>) {
|
|
20
|
+
return (
|
|
21
|
+
<DropdownMenuPrimitive.Root
|
|
22
|
+
modal={modal}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
7
27
|
|
|
8
28
|
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
9
29
|
|
|
@@ -39,17 +59,32 @@ const DropdownMenuContent = forwardRef<
|
|
|
39
59
|
));
|
|
40
60
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
41
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Pencil taps often never synthesize a `click` under Radix layers (same class of
|
|
64
|
+
* bug as dialog close / toast actions). Fire click on pointerdown for pen only.
|
|
65
|
+
*/
|
|
66
|
+
function handlePenPointerDown(
|
|
67
|
+
e: ReactPointerEvent<HTMLDivElement>,
|
|
68
|
+
onPointerDown?: (event: ReactPointerEvent<HTMLDivElement>) => void,
|
|
69
|
+
) {
|
|
70
|
+
onPointerDown?.(e);
|
|
71
|
+
if (e.defaultPrevented) return;
|
|
72
|
+
if (e.pointerType !== 'pen') return;
|
|
73
|
+
e.currentTarget.click();
|
|
74
|
+
}
|
|
75
|
+
|
|
42
76
|
const DropdownMenuItem = forwardRef<
|
|
43
77
|
ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
44
78
|
ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item>
|
|
45
|
-
>(({ className, ...props }, ref) => (
|
|
79
|
+
>(({ className, onPointerDown, ...props }, ref) => (
|
|
46
80
|
<DropdownMenuPrimitive.Item
|
|
47
81
|
ref={ref}
|
|
48
82
|
className={cn(
|
|
49
|
-
'relative flex items-center gap-2 cursor-pointer select-none rounded-sm px-2 py-1.5 text-sm outline-none transition-colors',
|
|
83
|
+
'relative flex items-center gap-2 cursor-pointer select-none rounded-sm px-2 py-1.5 text-sm outline-none transition-colors [touch-action:manipulation]',
|
|
50
84
|
'focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
51
85
|
className,
|
|
52
86
|
)}
|
|
87
|
+
onPointerDown={(e) => handlePenPointerDown(e, onPointerDown)}
|
|
53
88
|
{...props}
|
|
54
89
|
/>
|
|
55
90
|
));
|
|
@@ -12,7 +12,7 @@ import { cn } from '../../lib/utils';
|
|
|
12
12
|
import { Z_INDEX } from '../../lib/z-index';
|
|
13
13
|
|
|
14
14
|
const PORTALED_OVERLAY_SELECTOR =
|
|
15
|
-
'[data-dropdown-menu-content], [data-auth-menu-content], [data-sonner-toaster], [data-upload-toast]';
|
|
15
|
+
'[data-dropdown-menu-content], [data-auth-menu-content], [data-sonner-toaster], [data-upload-toast], [data-shellui-chrome-actions]';
|
|
16
16
|
|
|
17
17
|
function isPortaledOverlayTarget(target: EventTarget | null): boolean {
|
|
18
18
|
const element = target instanceof Element ? target : (target as Node | null)?.parentElement;
|
|
@@ -534,8 +534,9 @@ function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
|
|
|
534
534
|
data-slot="sidebar-inset"
|
|
535
535
|
className={cn(
|
|
536
536
|
'relative flex w-full flex-1 flex-col bg-background',
|
|
537
|
-
// Inset layout: float the main frame on a darkened chrome tray.
|
|
538
|
-
//
|
|
537
|
+
// Inset layout: float the main frame on a darkened chrome tray (desktop).
|
|
538
|
+
// Mobile inset rounding lives on the content card in SidebarLayout so the
|
|
539
|
+
// header can sit on the chrome tray above a radiused iframe frame.
|
|
539
540
|
'md:peer-data-[variant=inset]:m-3 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-3',
|
|
540
541
|
className,
|
|
541
542
|
)}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'react';
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Tabs = TabsPrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const TabsList = forwardRef<
|
|
8
|
+
ElementRef<typeof TabsPrimitive.List>,
|
|
9
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<TabsPrimitive.List
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
));
|
|
20
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
21
|
+
|
|
22
|
+
const TabsTrigger = forwardRef<
|
|
23
|
+
ElementRef<typeof TabsPrimitive.Trigger>,
|
|
24
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
25
|
+
>(({ className, ...props }, ref) => (
|
|
26
|
+
<TabsPrimitive.Trigger
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn(
|
|
29
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
));
|
|
35
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
36
|
+
|
|
37
|
+
const TabsContent = forwardRef<
|
|
38
|
+
ElementRef<typeof TabsPrimitive.Content>,
|
|
39
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
40
|
+
>(({ className, ...props }, ref) => (
|
|
41
|
+
<TabsPrimitive.Content
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(
|
|
44
|
+
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
));
|
|
50
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
51
|
+
|
|
52
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
package/src/constants/urls.ts
CHANGED