Desktop-served prototype
-Paired host
-This workspace list is rendered by web code delivered through the paired Orca connection.
-Performance lab
Synthetic terminal churn and a large diff, isolated from host data.
cached
') - await saveMobileWebPrototypePackage('secret-host-identity', cached) - - const writes = vi.mocked(AsyncStorage.setItem).mock.calls - expect(writes).toHaveLength(2) - expect(writes[0]?.[0]).toContain(':package:') - expect(writes[1]?.[0]).toContain(':active') - expect(writes.some(([key]) => key.includes('secret-host-identity'))).toBe(false) - await expect(loadCachedMobileWebPrototypePackage('secret-host-identity')).resolves.toEqual( - cached - ) - }) - - it('rejects a cached document modified after verification', async () => { - const cached = prototypePackage('trusted
') - await saveMobileWebPrototypePackage('host', cached) - const packageEntry = [...values.entries()].find(([key]) => key.includes(':package:')) - expect(packageEntry).toBeDefined() - values.set( - packageEntry![0], - JSON.stringify({ ...cached, html: 'modified after caching
' }) - ) - - await expect(loadCachedMobileWebPrototypePackage('host')).resolves.toBeNull() - }) - - it('keeps the previous package if publishing the new pointer fails', async () => { - const previous = prototypePackage('previous
') - const next = prototypePackage('next
') - await saveMobileWebPrototypePackage('host', previous) - vi.mocked(AsyncStorage.setItem).mockImplementation(async (key, value) => { - if (key.endsWith(':active')) { - throw new Error('storage failure') - } - values.set(key, value) - }) - - await expect(saveMobileWebPrototypePackage('host', next)).rejects.toThrow('storage failure') - await expect(loadCachedMobileWebPrototypePackage('host')).resolves.toEqual(previous) - }) -}) diff --git a/mobile/src/hybrid-prototype/mobile-web-prototype-cache.ts b/mobile/src/hybrid-prototype/mobile-web-prototype-cache.ts deleted file mode 100644 index a08d30a6283..00000000000 --- a/mobile/src/hybrid-prototype/mobile-web-prototype-cache.ts +++ /dev/null @@ -1,65 +0,0 @@ -import AsyncStorage from '@react-native-async-storage/async-storage' -import { Buffer } from 'buffer' -import { sha256 } from '@noble/hashes/sha256' -import { - verifyMobileWebPrototypePackage, - type VerifiedMobileWebPrototypePackage -} from './mobile-web-prototype-package' - -const CACHE_PREFIX = 'orca:mobile-web-prototype' - -function hostCacheId(hostId: string): string { - return Buffer.from(sha256(new TextEncoder().encode(hostId))).toString('hex') -} - -function activeKey(hostId: string): string { - return `${CACHE_PREFIX}:${hostCacheId(hostId)}:active` -} - -function packageKey(hostId: string, buildId: string): string { - return `${CACHE_PREFIX}:${hostCacheId(hostId)}:package:${buildId}` -} - -export async function loadCachedMobileWebPrototypePackage( - hostId: string -): Promisetamper test
', true)) - ).rejects.toThrow('chunk integrity') - }) - - it('rejects oversized and unsupported manifests before requesting chunks', async () => { - const request = async (): PromiseDesktop-served prototype
-This workspace list is rendered by web code delivered through the paired Orca connection.
-Performance lab
Synthetic terminal churn and a large diff, isolated from host data.