* feat(mobile): define relay protocol groundwork Co-authored-by: Orca <help@stably.ai> * feat(mobile): implement replay-safe E2EE v2 sessions Co-authored-by: Orca <help@stably.ai> * test(auth): lock cloud refresh single-flight Co-authored-by: Orca <help@stably.ai> * test(mobile): complete E2EE v2 adversarial coverage Co-authored-by: Orca <help@stably.ai> * refactor(runtime): unify mobile socket wiring Co-authored-by: Orca <help@stably.ai> * feat(runtime): add relay control and data clients Co-authored-by: Orca <help@stably.ai> * feat(runtime): coordinate desktop relay sessions Co-authored-by: Orca <help@stably.ai> * fix(auth): fence stale cloud session mutations Co-authored-by: Orca <help@stably.ai> * feat(runtime): add relay pairing and durable revoke Co-authored-by: Orca <help@stably.ai> * feat(runtime): add relay credential pairing RPCs Co-authored-by: Orca <help@stably.ai> * feat(settings): show Orca Relay sign-in status Co-authored-by: Orca <help@stably.ai> * test(relay): prove desktop lifecycle and E2EE splice Co-authored-by: Orca <help@stably.ai> * feat(mobile): persist relay pairing state Co-authored-by: Orca <help@stably.ai> * feat(mobile): race direct and relay pairing Co-authored-by: Orca <help@stably.ai> * feat(mobile): recover pairing through relay director Co-authored-by: Orca <help@stably.ai> * fix(relay): preserve origin controls during drain Co-authored-by: Orca <help@stably.ai> * feat(mobile): recover interrupted relay pairing Co-authored-by: Orca <help@stably.ai> * feat(mobile): add stable relay RPC sessions Co-authored-by: Orca <help@stably.ai> * feat(mobile): supervise direct and relay endpoints Co-authored-by: Orca <help@stably.ai> * Cover mobile relay director fallback matrix Co-authored-by: Orca <help@stably.ai> * Fix relay settings component test isolation Co-authored-by: Orca <help@stably.ai> * Remove unrelated merge formatting drift Co-authored-by: Orca <help@stably.ai> * Update runtime connection count integration assertion Co-authored-by: Orca <help@stably.ai> * Run mobile typecheck through pnpm Co-authored-by: Orca <help@stably.ai> * feat(relay): gate desktop controls on mobile demand Co-authored-by: Orca <help@stably.ai> * test(mobile): cover served relay recovery Co-authored-by: Orca <help@stably.ai> * feat(mobile): upgrade direct pairings to relay Co-authored-by: Orca <help@stably.ai> * fix(relay): harden mobile reconnect and teardown Co-authored-by: Orca <help@stably.ai> * fix(auth): clarify account sign-in state Co-authored-by: Orca <help@stably.ai> * fix(auth): polish sign-in completion flow Co-authored-by: Orca <help@stably.ai> * fix(auth): clarify sign-out confirmation Co-authored-by: Orca <help@stably.ai> * fix(auth): simplify sign-in completion page Co-authored-by: Orca <help@stably.ai> * feat(mobile): add per-device pairing connection mode Co-authored-by: Orca <help@stably.ai> * fix(mobile): stabilize pairing option layout Co-authored-by: Orca <help@stably.ai> * fix(mobile): give pairing choices stable space Co-authored-by: Orca <help@stably.ai> * fix(mobile): stabilize pairing QR regeneration Co-authored-by: Orca <help@stably.ai> * Animate mobile pairing flow height Co-authored-by: Orca <help@stably.ai> * Configure auth in packaged builds Co-authored-by: Orca <help@stably.ai> * Make Orca Relay pairing an opt-in beta Co-authored-by: Orca <help@stably.ai> * Show Relay beta details on hover Co-authored-by: Orca <help@stably.ai> * Refine mobile relay pairing choice Co-authored-by: Orca <help@stably.ai> * Polish Orca Relay pairing controls Co-authored-by: Orca <help@stably.ai> * Keep mobile contract fallback test additive Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import { createHash } from 'node:crypto'
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
encodeMobileE2EEV2Transcript,
|
|
validateMobileE2EEV2Handshake
|
|
} from './mobile-e2ee-v2-contract'
|
|
import { createMobileE2EEV2Fixture, MOBILE_E2EE_V2_VECTOR } from './mobile-e2ee-v2-fixtures'
|
|
|
|
describe('mobile E2EE v2 contract', () => {
|
|
it('validates the exact relay handshake and canonical encodings', () => {
|
|
const { hello, ready } = createMobileE2EEV2Fixture()
|
|
expect(validateMobileE2EEV2Handshake(hello, ready)).not.toBeNull()
|
|
})
|
|
|
|
it('rejects unknown fields, noncanonical base64, and an unechoed nonce', () => {
|
|
const { hello, ready } = createMobileE2EEV2Fixture()
|
|
expect(validateMobileE2EEV2Handshake({ ...hello, extra: true }, ready)).toBeNull()
|
|
expect(
|
|
validateMobileE2EEV2Handshake(
|
|
{ ...hello, clientPublicKeyB64: hello.clientPublicKeyB64.replace(/=$/, '') },
|
|
ready
|
|
)
|
|
).toBeNull()
|
|
expect(
|
|
validateMobileE2EEV2Handshake(hello, {
|
|
...ready,
|
|
clientNonceB64: btoa(String.fromCharCode(...new Uint8Array(32).fill(9)))
|
|
})
|
|
).toBeNull()
|
|
})
|
|
|
|
it('rejects context and capability-selection changes', () => {
|
|
const { hello, ready } = createMobileE2EEV2Fixture()
|
|
expect(
|
|
validateMobileE2EEV2Handshake(hello, {
|
|
...ready,
|
|
context: { ...ready.context, relayHostId: 'ZbCdEf0123_-xyZ9' }
|
|
})
|
|
).toBeNull()
|
|
expect(
|
|
validateMobileE2EEV2Handshake(
|
|
{ ...hello, capabilities: { framing: [2], payloadKinds: ['binary', 'text'] } },
|
|
ready
|
|
)
|
|
).toBeNull()
|
|
})
|
|
|
|
it('requires relayHostId only for relay context', () => {
|
|
const { hello, ready } = createMobileE2EEV2Fixture()
|
|
const relayWithoutId = { ...hello.context }
|
|
delete (relayWithoutId as { relayHostId?: string }).relayHostId
|
|
expect(validateMobileE2EEV2Handshake({ ...hello, context: relayWithoutId }, ready)).toBeNull()
|
|
|
|
const directContext = {
|
|
protocol: 'orca-mobile-e2ee' as const,
|
|
initiator: 'mobile' as const,
|
|
responder: 'desktop' as const,
|
|
transport: 'direct' as const
|
|
}
|
|
expect(
|
|
validateMobileE2EEV2Handshake(
|
|
{ ...hello, context: directContext },
|
|
{ ...ready, context: directContext }
|
|
)
|
|
).not.toBeNull()
|
|
})
|
|
|
|
it('locks the canonical length-prefixed transcript bytes', () => {
|
|
const { hello, ready } = createMobileE2EEV2Fixture()
|
|
const handshake = validateMobileE2EEV2Handshake(hello, ready)
|
|
expect(handshake).not.toBeNull()
|
|
const transcript = encodeMobileE2EEV2Transcript(handshake!)
|
|
|
|
expect(transcript).toHaveLength(MOBILE_E2EE_V2_VECTOR.transcriptLength)
|
|
expect(createHash('sha256').update(transcript).digest('hex')).toBe(
|
|
MOBILE_E2EE_V2_VECTOR.transcriptHashHex
|
|
)
|
|
})
|
|
})
|