收紧原生壳载荷边界门禁

导出 HostBridge 文件和通知载荷边界常量
校验移动壳文件大小和 MIME 清单与共享契约一致
校验桌面壳载荷限制和 MIME 清单与共享契约一致
更新原生壳方案和共享决策记录
This commit is contained in:
2026-06-19 00:26:18 +08:00
parent 1f5c752302
commit 759b2cb388
5 changed files with 369 additions and 9 deletions
+30 -2
View File
@@ -329,6 +329,13 @@ export type HostBridgeTextMimeType =
| 'text/csv'
| 'application/json';
export const HOST_BRIDGE_TEXT_MIME_TYPES = [
'text/plain',
'text/markdown',
'text/csv',
'application/json',
] as const satisfies readonly HostBridgeTextMimeType[];
export type FileImportTextResult = {
action: 'selected';
fileName: string;
@@ -354,6 +361,12 @@ export type HostBridgeImageMimeType =
| 'image/jpeg'
| 'image/webp';
export const HOST_BRIDGE_IMAGE_MIME_TYPES = [
'image/png',
'image/jpeg',
'image/webp',
] as const satisfies readonly HostBridgeImageMimeType[];
export type FileImportImageResult = {
action: 'selected' | 'dropped' | 'captured';
fileName: string;
@@ -373,6 +386,14 @@ export type HostBridgeAudioMimeType =
| 'audio/ogg'
| 'audio/webm';
export const HOST_BRIDGE_AUDIO_MIME_TYPES = [
'audio/mpeg',
'audio/mp4',
'audio/wav',
'audio/ogg',
'audio/webm',
] as const satisfies readonly HostBridgeAudioMimeType[];
export type FileImportAudioResult = {
action: 'selected';
fileName: string;
@@ -393,6 +414,13 @@ export type FileExportAudioResult = {
bytes: number;
};
export const HOST_BRIDGE_EXPORT_TEXT_MAX_BYTES = 5 * 1024 * 1024;
export const HOST_BRIDGE_IMPORT_TEXT_MAX_BYTES = 5 * 1024 * 1024;
export const HOST_BRIDGE_EXPORT_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
export const HOST_BRIDGE_IMPORT_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
export const HOST_BRIDGE_EXPORT_AUDIO_MAX_BYTES = 20 * 1024 * 1024;
export const HOST_BRIDGE_IMPORT_AUDIO_MAX_BYTES = 20 * 1024 * 1024;
export const HOST_BRIDGE_HAPTICS_IMPACT_STYLES = [
'light',
'medium',
@@ -486,8 +514,8 @@ export type ShareOpenPayload = {
url?: string;
};
const HOST_BRIDGE_FILE_NAME_FALLBACK = 'genarrative-export.txt';
const HOST_BRIDGE_FILE_NAME_MAX_LENGTH = 120;
export const HOST_BRIDGE_FILE_NAME_FALLBACK = 'genarrative-export.txt';
export const HOST_BRIDGE_FILE_NAME_MAX_LENGTH = 120;
function isHostBridgeInvalidFileNameCharacter(value: string) {
if (hasHostBridgeControlCharacter(value)) {