@shellui/core 0.7.0-alpha.6 → 0.7.0-alpha.8
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellui/core",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.8",
|
|
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.7.0-alpha.
|
|
76
|
+
"@shellui/sdk": "0.7.0-alpha.8"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -362,7 +362,7 @@
|
|
|
362
362
|
"items": {
|
|
363
363
|
"type": "string"
|
|
364
364
|
},
|
|
365
|
-
"description": "Exact origins of service URLs (email, storage, hosting) a host may pass to a child with `ShelluiFrame` or `createAppFrame`, such as `https://storage.eu.shellui.com`. No wildcards. A URL outside this list, or a missing one, reaches the child as `null`. Omit to send children no service URLs."
|
|
365
|
+
"description": "Exact origins of service URLs (email, storage, files, hosting) a host may pass to a child with `ShelluiFrame` or `createAppFrame`, such as `https://storage.eu.shellui.com`. No wildcards. A URL outside this list, or a missing one, reaches the child as `null`. Omit to send children no service URLs."
|
|
366
366
|
}
|
|
367
367
|
},
|
|
368
368
|
"required": ["origins"],
|
|
@@ -73,8 +73,10 @@ export const ContentView = ({
|
|
|
73
73
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
74
74
|
const cancelRevealRef = useRef<(() => void) | null>(null);
|
|
75
75
|
const mountTimeRef = useRef(Date.now());
|
|
76
|
-
/** Shell path last
|
|
76
|
+
/** Shell path last synced with the iframe. */
|
|
77
77
|
const lastShellPathFromIframeRef = useRef<string | null>(null);
|
|
78
|
+
/** Iframe reports not rendered back yet: their echo must not drive the iframe. */
|
|
79
|
+
const pendingFromIframeRef = useRef<string[]>([]);
|
|
78
80
|
const skipInitialShellSyncRef = useRef(true);
|
|
79
81
|
const prevNavPathRef = useRef(navItem?.path ?? '');
|
|
80
82
|
|
|
@@ -119,9 +121,16 @@ export const ContentView = ({
|
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
const echo = pendingFromIframeRef.current.indexOf(currentShellPath);
|
|
125
|
+
if (echo >= 0 && !navItemChanged) {
|
|
126
|
+
pendingFromIframeRef.current = pendingFromIframeRef.current.slice(echo + 1);
|
|
127
|
+
lastShellPathFromIframeRef.current = currentShellPath;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
122
130
|
if (lastShellPathFromIframeRef.current === currentShellPath && !navItemChanged) {
|
|
123
131
|
return;
|
|
124
132
|
}
|
|
133
|
+
pendingFromIframeRef.current = [];
|
|
125
134
|
|
|
126
135
|
lastShellPathFromIframeRef.current = currentShellPath;
|
|
127
136
|
mountTimeRef.current = Date.now();
|
|
@@ -173,7 +182,7 @@ export const ContentView = ({
|
|
|
173
182
|
return;
|
|
174
183
|
}
|
|
175
184
|
|
|
176
|
-
const { pathname, search, hash } = data.payload as ShellUIUrlPayload;
|
|
185
|
+
const { pathname, search, hash, replace } = data.payload as ShellUIUrlPayload;
|
|
177
186
|
// Shell URL is always path + search only (no hash) so it's transparent whether the sub-app uses hash routing or not
|
|
178
187
|
let pathSegment: string;
|
|
179
188
|
if (isHashRouterNavItem(navItem) && hash) {
|
|
@@ -223,17 +232,19 @@ export const ContentView = ({
|
|
|
223
232
|
const normalizedNewPathname = newPathParts?.[1]?.replace(/\/+$/, '') || '/';
|
|
224
233
|
const normalizedNewPath = normalizedNewPathname + (newPathParts?.[2] || '');
|
|
225
234
|
|
|
226
|
-
// Mark before navigate so the shell-sync effect does not reload the iframe
|
|
227
|
-
lastShellPathFromIframeRef.current = normalizedNewPath;
|
|
228
|
-
|
|
229
235
|
if (currentPath !== normalizedNewPath) {
|
|
230
236
|
if (!isSafeShellPath(normalizedNewPath)) {
|
|
231
237
|
logger.warn('ContentView: refused unsafe shell path from iframe', normalizedNewPath);
|
|
232
238
|
return;
|
|
233
239
|
}
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
240
|
+
// Mark before navigate so the shell-sync effect does not drive the iframe back.
|
|
241
|
+
pendingFromIframeRef.current = [
|
|
242
|
+
...pendingFromIframeRef.current.slice(-19),
|
|
243
|
+
normalizedNewPath,
|
|
244
|
+
];
|
|
245
|
+
// Iframe pushState is replace-only when embedded, so the shell owns back and
|
|
246
|
+
// forward. A child redirect replaces, so it never adds an entry.
|
|
247
|
+
navigate(newShellPath, { replace: replace === true });
|
|
237
248
|
}
|
|
238
249
|
},
|
|
239
250
|
);
|
|
@@ -185,6 +185,7 @@ describe('child frame service URLs', () => {
|
|
|
185
185
|
serviceOrigins: [
|
|
186
186
|
'https://email.eu.example.com',
|
|
187
187
|
'https://storage.eu.example.com',
|
|
188
|
+
'https://files.example.com',
|
|
188
189
|
'https://*.example.com',
|
|
189
190
|
'*',
|
|
190
191
|
],
|
|
@@ -210,6 +211,7 @@ describe('child frame service URLs', () => {
|
|
|
210
211
|
expect(result.entry.services).toEqual({
|
|
211
212
|
email: 'https://email.eu.example.com',
|
|
212
213
|
storage: 'https://storage.eu.example.com',
|
|
214
|
+
files: null,
|
|
213
215
|
hosting: null,
|
|
214
216
|
});
|
|
215
217
|
expect(result.entry.rejectedServices).toEqual([]);
|
|
@@ -230,10 +232,60 @@ describe('child frame service URLs', () => {
|
|
|
230
232
|
});
|
|
231
233
|
expect(result.ok).toBe(true);
|
|
232
234
|
if (!result.ok) return;
|
|
233
|
-
expect(result.entry.services).toEqual({
|
|
235
|
+
expect(result.entry.services).toEqual({
|
|
236
|
+
email: null,
|
|
237
|
+
storage: null,
|
|
238
|
+
files: null,
|
|
239
|
+
hosting: null,
|
|
240
|
+
});
|
|
234
241
|
expect(result.entry.rejectedServices).toEqual(['storage', 'hosting']);
|
|
235
242
|
});
|
|
236
243
|
|
|
244
|
+
it('forwards an allowed files URL as storage.filesUrl', () => {
|
|
245
|
+
const result = register({
|
|
246
|
+
storage: 'https://storage.eu.example.com',
|
|
247
|
+
files: 'https://files.example.com/',
|
|
248
|
+
});
|
|
249
|
+
expect(result.ok).toBe(true);
|
|
250
|
+
if (!result.ok) return;
|
|
251
|
+
expect(result.entry.services.files).toBe('https://files.example.com');
|
|
252
|
+
const options = childFrameAuthPropagationOptions({
|
|
253
|
+
identity: result.entry.identity,
|
|
254
|
+
getAppSession: () => null,
|
|
255
|
+
services: result.entry.services,
|
|
256
|
+
});
|
|
257
|
+
expect(options.storage).toEqual({
|
|
258
|
+
url: 'https://storage.eu.example.com',
|
|
259
|
+
filesUrl: 'https://files.example.com',
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('drops a files URL whose origin is not allowed, or without storage', () => {
|
|
264
|
+
const rejected = register({
|
|
265
|
+
storage: 'https://storage.eu.example.com',
|
|
266
|
+
files: 'https://files.evil.example.org',
|
|
267
|
+
});
|
|
268
|
+
expect(rejected.ok).toBe(true);
|
|
269
|
+
if (!rejected.ok) return;
|
|
270
|
+
expect(rejected.entry.rejectedServices).toEqual(['files']);
|
|
271
|
+
expect(
|
|
272
|
+
childFrameAuthPropagationOptions({
|
|
273
|
+
identity: null,
|
|
274
|
+
getAppSession: () => null,
|
|
275
|
+
services: rejected.entry.services,
|
|
276
|
+
}).storage,
|
|
277
|
+
).toEqual({ url: 'https://storage.eu.example.com' });
|
|
278
|
+
const alone = register({ files: 'https://files.example.com' });
|
|
279
|
+
if (!alone.ok) throw new Error('expected ok');
|
|
280
|
+
expect(
|
|
281
|
+
childFrameAuthPropagationOptions({
|
|
282
|
+
identity: null,
|
|
283
|
+
getAppSession: () => null,
|
|
284
|
+
services: alone.entry.services,
|
|
285
|
+
}).storage,
|
|
286
|
+
).toBeNull();
|
|
287
|
+
});
|
|
288
|
+
|
|
237
289
|
it('never matches a wildcard entry', () => {
|
|
238
290
|
const result = register({ hosting: 'https://hosting.example.com' });
|
|
239
291
|
expect(result.ok).toBe(true);
|
|
@@ -252,7 +304,12 @@ describe('child frame service URLs', () => {
|
|
|
252
304
|
const result = register(undefined, shellWithServices);
|
|
253
305
|
expect(result.ok).toBe(true);
|
|
254
306
|
if (!result.ok) return;
|
|
255
|
-
expect(result.entry.services).toEqual({
|
|
307
|
+
expect(result.entry.services).toEqual({
|
|
308
|
+
email: null,
|
|
309
|
+
storage: null,
|
|
310
|
+
files: null,
|
|
311
|
+
hosting: null,
|
|
312
|
+
});
|
|
256
313
|
const options = childFrameAuthPropagationOptions({
|
|
257
314
|
identity: result.entry.identity,
|
|
258
315
|
getAppSession: () => null,
|
|
@@ -17,9 +17,9 @@ export type ChildFrameEntry = {
|
|
|
17
17
|
rejectedServices: ChildFrameServiceKey[];
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type ChildFrameServiceKey = 'email' | 'storage' | 'hosting';
|
|
20
|
+
export type ChildFrameServiceKey = 'email' | 'storage' | 'files' | 'hosting';
|
|
21
21
|
export type ChildFrameServices = Record<ChildFrameServiceKey, string | null>;
|
|
22
|
-
const SERVICE_KEYS: readonly ChildFrameServiceKey[] = ['email', 'storage', 'hosting'];
|
|
22
|
+
const SERVICE_KEYS: readonly ChildFrameServiceKey[] = ['email', 'storage', 'files', 'hosting'];
|
|
23
23
|
|
|
24
24
|
export type ChildFrameRegistration =
|
|
25
25
|
| { ok: true; entry: ChildFrameEntry }
|
|
@@ -64,7 +64,7 @@ export function resolveChildFrameServices(
|
|
|
64
64
|
): { services: ChildFrameServices; rejected: ChildFrameServiceKey[] } {
|
|
65
65
|
const allowed = originList(allowedOrigins);
|
|
66
66
|
const raw = (input && typeof input === 'object' ? input : {}) as Record<string, unknown>;
|
|
67
|
-
const services: ChildFrameServices = { email: null, storage: null, hosting: null };
|
|
67
|
+
const services: ChildFrameServices = { email: null, storage: null, files: null, hosting: null };
|
|
68
68
|
const rejected: ChildFrameServiceKey[] = [];
|
|
69
69
|
for (const key of SERVICE_KEYS) {
|
|
70
70
|
const value = raw[key];
|
|
@@ -180,7 +180,7 @@ export function frameAuthPropagationOptions(input: {
|
|
|
180
180
|
export function childFrameAuthPropagationOptions(input: {
|
|
181
181
|
identity: ResolvedAppBackend | null;
|
|
182
182
|
getAppSession: (key: string) => AuthSession | null;
|
|
183
|
-
services?: Partial<Record<'email' | 'storage' | 'hosting', string | null>> | null;
|
|
183
|
+
services?: Partial<Record<'email' | 'storage' | 'files' | 'hosting', string | null>> | null;
|
|
184
184
|
}): FrameAuthPropagationOptions {
|
|
185
185
|
const { identity, getAppSession } = input;
|
|
186
186
|
const allowed = input.services ?? {};
|
|
@@ -194,7 +194,10 @@ export function childFrameAuthPropagationOptions(input: {
|
|
|
194
194
|
settingsUser: settingsUserFromSession(session),
|
|
195
195
|
services: {
|
|
196
196
|
email: allowed.email ? { url: allowed.email } : null,
|
|
197
|
-
|
|
197
|
+
// The files app URL rides on storage and is dropped when storage is not allowed.
|
|
198
|
+
storage: allowed.storage
|
|
199
|
+
? { url: allowed.storage, ...(allowed.files ? { filesUrl: allowed.files } : {}) }
|
|
200
|
+
: null,
|
|
198
201
|
hosting: allowed.hosting ? { url: allowed.hosting } : null,
|
|
199
202
|
},
|
|
200
203
|
});
|