@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
@@ -1,15 +1,24 @@
1
- import type { Settings, SettingsEmail, SettingsNavigationItem } from '@shellui/sdk';
2
- import type { ShellUIConfig } from '../../config/types';
1
+ import type {
2
+ Settings,
3
+ SettingsEmail,
4
+ SettingsHosting,
5
+ SettingsNavigationItem,
6
+ SettingsStorage,
7
+ } from '@shellui/sdk';
8
+ import type { EmailConfig, HostingConfig, ShellUIConfig, StorageConfig } from '../../config/types';
3
9
  import { flattenNavigationItems } from './flattenNavigationItems';
4
10
  import { getAvailableThemesForSettings } from './getAvailableThemesForSettings';
5
11
  import { getResolvedAppearanceForSettings } from './getResolvedAppearanceForSettings';
6
12
  import { resolveLabel } from './resolveLabel';
7
- import { getPublishedLayoutChrome } from '../../layouts/floating/layoutChromeStore';
13
+ import {
14
+ getLayoutChromeForFrame,
15
+ getPublishedLayoutChrome,
16
+ } from '../../layouts/floating/layoutChromeStore';
8
17
 
9
18
  /** Production email-service origin. No trailing slash. */
10
19
  const DEFAULT_EMAIL_SERVICE_URL = 'https://email.shellui.com';
11
20
 
12
- const propagateEmail = (email: ShellUIConfig['email']): SettingsEmail | null => {
21
+ const propagateEmail = (email: EmailConfig | null | undefined): SettingsEmail | null => {
13
22
  if (!email) return null;
14
23
  const url = email.url?.trim().replace(/\/+$/, '') || DEFAULT_EMAIL_SERVICE_URL;
15
24
  return {
@@ -18,6 +27,27 @@ const propagateEmail = (email: ShellUIConfig['email']): SettingsEmail | null =>
18
27
  };
19
28
  };
20
29
 
30
+ const propagateStorage = (storage: StorageConfig | null | undefined): SettingsStorage | null => {
31
+ const storageUrl = storage?.url?.trim().replace(/\/+$/, '') || null;
32
+ if (!storageUrl) return null;
33
+ const filesUrl = storage?.filesUrl?.trim() || null;
34
+ return {
35
+ url: storageUrl,
36
+ ...(filesUrl ? { filesUrl } : {}),
37
+ };
38
+ };
39
+
40
+ const propagateHosting = (hosting: HostingConfig | null | undefined): SettingsHosting | null => {
41
+ const hostingUrl = hosting?.url?.trim().replace(/\/+$/, '') || null;
42
+ if (!hostingUrl) return null;
43
+ const app = hosting?.app?.trim() || null;
44
+ return {
45
+ url: hostingUrl,
46
+ ...(app ? { app } : {}),
47
+ ...(hosting?.showInAdmin === false ? { showInAdmin: false } : {}),
48
+ };
49
+ };
50
+
21
51
  /**
22
52
  * Build settings for propagation to iframes: inject navigation, full theme object,
23
53
  * and list of available themes so apps can render theme pickers.
@@ -29,18 +59,39 @@ export const buildSettingsForPropagation = (
29
59
  options?: {
30
60
  includeAuthAccessToken?: boolean;
31
61
  accessToken?: string | null;
62
+ /**
63
+ * Identity base URL for this frame. When the key is set, it replaces the shell
64
+ * `backend` URL (`null` when that server is not a Shellui identity backend).
65
+ */
66
+ authBackendBaseUrl?: string | null;
67
+ /** User for this frame's identity server. When the key is set, it replaces `settings.user`. */
68
+ settingsUser?: Settings['user'];
69
+ /**
70
+ * Storage for this frame. When the key is set, it replaces the shell `storage`
71
+ * (`null` sends no storage URL).
72
+ */
73
+ storage?: StorageConfig | null;
74
+ /** Email for this frame. When the key is set, it replaces the shell `email`. */
75
+ email?: EmailConfig | null;
76
+ /** Hosting for this frame. When the key is set, it replaces the shell `hosting`. */
77
+ hosting?: HostingConfig | null;
32
78
  /** When false, omit layoutChrome (modal / drawer frames). Default true. */
33
79
  includeLayoutChrome?: boolean;
80
+ /** Merge this frame's action-bar insets into layoutChrome. */
81
+ frameUuid?: string;
34
82
  },
35
83
  ): Settings => {
36
84
  const appearance = getResolvedAppearanceForSettings(settings, config);
37
85
  let result: Settings = {
38
86
  ...settings,
39
87
  appearance: appearance ?? settings.appearance,
88
+ ...(options && 'settingsUser' in options ? { user: options.settingsUser ?? null } : {}),
40
89
  };
41
90
 
42
91
  if (options?.includeLayoutChrome !== false) {
43
- const layoutChrome = getPublishedLayoutChrome();
92
+ const layoutChrome = options?.frameUuid
93
+ ? getLayoutChromeForFrame(options.frameUuid)
94
+ : getPublishedLayoutChrome();
44
95
  if (layoutChrome) {
45
96
  result = { ...result, layoutChrome };
46
97
  } else if ('layoutChrome' in result) {
@@ -94,41 +145,25 @@ export const buildSettingsForPropagation = (
94
145
  result = { ...result, administration: null };
95
146
  }
96
147
 
97
- const storageUrl = config?.storage?.url?.trim().replace(/\/+$/, '') || null;
98
- if (storageUrl) {
99
- const filesUrl = config.storage?.filesUrl?.trim() || null;
100
- result = {
101
- ...result,
102
- storage: {
103
- url: storageUrl,
104
- ...(filesUrl ? { filesUrl } : {}),
105
- },
106
- };
107
- } else {
108
- result = { ...result, storage: null };
109
- }
110
-
111
- const hostingUrl = config?.hosting?.url?.trim().replace(/\/+$/, '') || null;
112
- if (hostingUrl) {
113
- const app = config.hosting?.app?.trim() || null;
114
- result = {
115
- ...result,
116
- hosting: {
117
- url: hostingUrl,
118
- ...(app ? { app } : {}),
119
- ...(config.hosting?.showInAdmin === false ? { showInAdmin: false } : {}),
120
- },
121
- };
122
- } else {
123
- result = { ...result, hosting: null };
124
- }
148
+ const storageSource = options && 'storage' in options ? options.storage : config?.storage;
149
+ const hostingSource = options && 'hosting' in options ? options.hosting : config?.hosting;
150
+ const emailSource = options && 'email' in options ? options.email : config?.email;
125
151
 
126
- result = { ...result, email: propagateEmail(config?.email) };
152
+ result = {
153
+ ...result,
154
+ storage: propagateStorage(storageSource),
155
+ hosting: propagateHosting(hostingSource),
156
+ email: propagateEmail(emailSource),
157
+ };
127
158
 
128
- const authBackendBaseUrl =
159
+ const shellAuthBackendBaseUrl =
129
160
  config?.backend?.type === 'shellui' && config.backend.url?.trim()
130
161
  ? config.backend.url.trim().replace(/\/+$/, '')
131
162
  : null;
163
+ const authBackendBaseUrl =
164
+ options && 'authBackendBaseUrl' in options
165
+ ? (options.authBackendBaseUrl ?? null)
166
+ : shellAuthBackendBaseUrl;
132
167
 
133
168
  result = {
134
169
  ...result,
@@ -63,6 +63,8 @@
63
63
  "walletLoginFailed": "Unable to complete Ethereum wallet login.",
64
64
  "signInCouldNotContinue": "Sign-in could not continue.",
65
65
  "magicLinkStaffDisabled": "Staff accounts can't sign in with an email link. Sign in with your usual sign-in method instead.",
66
+ "magicLinkOtherBrowser": "Open this link in the browser where you requested it, or request a new one.",
67
+ "pkceFailed": "Sign-in could not be verified. Start signing in again from this browser.",
66
68
  "magicLinkMethod": "magic link",
67
69
  "redirectNotAllowedHint": " Add this origin in shellui-auth (Django admin or shellui-admin → Company → Login redirect URLs), for example: {{origin}}."
68
70
  },
@@ -63,6 +63,8 @@
63
63
  "walletLoginFailed": "Impossible de terminer la connexion au portefeuille Ethereum.",
64
64
  "signInCouldNotContinue": "La connexion n'a pas pu se poursuivre.",
65
65
  "magicLinkStaffDisabled": "Les comptes staff ne peuvent pas se connecter avec un lien envoyé par e-mail. Connectez-vous avec votre méthode de connexion habituelle.",
66
+ "magicLinkOtherBrowser": "Ouvrez ce lien dans le navigateur où vous l'avez demandé, ou demandez-en un nouveau.",
67
+ "pkceFailed": "La connexion n'a pas pu être vérifiée. Recommencez la connexion depuis ce navigateur.",
66
68
  "magicLinkMethod": "lien magique",
67
69
  "redirectNotAllowedHint": " Ajoutez cette origine dans shellui-auth (admin Django ou shellui-admin → Company → Login redirect URLs), par exemple : {{origin}}."
68
70
  },
package/src/index.css CHANGED
@@ -169,6 +169,11 @@
169
169
  border-radius: var(--shellui-floating-sidebar-radius);
170
170
  }
171
171
 
172
+ /* Tauri floating sidebar is flush to the window, so the frame itself is square. */
173
+ .shellui-floating-sidebar-panel .shellui-floating-glass[data-shellui-tauri-flush] {
174
+ border-radius: 0;
175
+ }
176
+
172
177
  .dark .shellui-floating-glass {
173
178
  background:
174
179
  linear-gradient(
@@ -1369,12 +1374,22 @@ html[data-shellui-collapsed-titlebar][data-shellui-safe-area-topbar]
1369
1374
  }
1370
1375
 
1371
1376
  html[data-shellui-collapsed-titlebar]
1372
- [data-shellui-sidebar-layout]
1377
+ [data-shellui-sidebar-layout]:not([data-shellui-layout-variant='inset'])
1373
1378
  > [data-slot='sidebar-wrapper']
1374
1379
  > [data-slot='sidebar-inset'] {
1375
1380
  padding-top: var(--shellui-titlebar-height, 42px);
1376
1381
  }
1377
1382
 
1383
+ /* Inset card keeps its own radius: sit the frame under the titlebar instead of
1384
+ padding inside the rounded border (that left the top corners covered). */
1385
+ html[data-shellui-collapsed-titlebar]
1386
+ [data-shellui-layout-variant='inset']
1387
+ > [data-slot='sidebar-wrapper']
1388
+ > [data-slot='sidebar-inset'] {
1389
+ margin-top: var(--shellui-titlebar-height, 42px);
1390
+ padding-top: 0;
1391
+ }
1392
+
1378
1393
  /* Root safe-area topbar: collapsed chrome sits below the status band. */
1379
1394
  html[data-shellui-safe-area-topbar] [data-shellui-collapsed-titlebar] {
1380
1395
  top: var(--shellui-safe-area-top);
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export type {
26
26
  LayoutType,
27
27
  BackendType,
28
28
  BackendConfig,
29
+ AppBackendConfig,
29
30
  AuthConfig,
30
31
  AdministrationConfig,
31
32
  StorageConfig,
@@ -35,6 +35,11 @@ export const Z_INDEX = {
35
35
  WINDOWS_TASKBAR: 9000,
36
36
  /** Base z-index for windows; each window gets base + order */
37
37
  WINDOWS_WINDOW_BASE: 9001,
38
+ /**
39
+ * Tauri overlay titlebar in the windows layout. Above any window so a
40
+ * maximized title bar cannot slide under the drag strip, below modals.
41
+ */
42
+ WINDOWS_TITLEBAR: 9500,
38
43
  } as const;
39
44
 
40
45
  export type ZIndexLayer = keyof typeof Z_INDEX;