Some checks failed
Test / test (push) Has been cancelled
Cross-platform vectors / TypeScript vectors (bun) (push) Has been cancelled
Cross-platform vectors / Kotlin vectors (gradle) (push) Has been cancelled
Docker build and publish / docker (push) Has been cancelled
Publish / publish (push) Has been cancelled
V3.1 → V3.12 consolidated and tagged for the first GA release. Wire format unchanged from 0.4.x — 4.0 peers interoperate with 0.4.x peers byte-for-byte. The version bump is semantic: audit-cycle complete, opt-in surface fully exposed, threat model refreshed for every new surface. Highlights: - All 24 @shade/* packages bumped to 4.0.0 in lockstep. - CHANGELOG 4.0.0 section is the canonical manifest of what landed. - THREAT-MODEL extended (§10 fingerprint gates, §11 WebRTC P2P, §12 Web-Worker boundary) + residual-risks table refreshed. - OpenAPI now covers all 27 routes: prekey, transfer, KT, inbox, bridge, observer, /metrics, /healthz, /ready. - MIGRATION 0.3.x → 4.0 documented + smoke-tested against shade migrate-storage on a real SQLite DB. - docs/audit/REVIEW-BUNDLE.md + SCOPE.md ready for external reviewer. - scripts/soak.ts harness for the GA-stable 2-week soak window. - All V*.md plans archived under docs/archive/ with Status: Done. - Voice/Video carved out into V5.0; 4.0 audit focuses on the frozen non-realtime stack. Tests: TS 1000/1000 + Kotlin 11/11 cross-platform vectors green. Docker: gt.zyon.no/stian/shade-prekey:4.0.0 builds and reports version 4.0.0 on /health. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
import { describe, expect, it } from 'bun:test';
|
|
import {
|
|
MemoryShadeBridge,
|
|
WebRtcSignalingChannel,
|
|
} from '../src/signaling.js';
|
|
|
|
describe('WebRtcSignalingChannel', () => {
|
|
it('routes typed signaling messages through the bridge', async () => {
|
|
const { a, b } = MemoryShadeBridge.linked('alice', 'bob');
|
|
const aliceSig = new WebRtcSignalingChannel(a);
|
|
const bobSig = new WebRtcSignalingChannel(b);
|
|
|
|
const received: Array<{ from: string; kind: string }> = [];
|
|
bobSig.onSignal((from, msg) => {
|
|
received.push({ from, kind: msg.kind });
|
|
});
|
|
|
|
await aliceSig.sendOffer('bob', 'sess-1', 'v=0\nfake-sdp');
|
|
await aliceSig.sendIce('bob', 'sess-1', {
|
|
candidate: 'candidate:1 1 udp 0 1.2.3.4 1234 typ host',
|
|
sdpMid: '0',
|
|
sdpMLineIndex: 0,
|
|
});
|
|
await aliceSig.sendBye('bob', 'sess-1', 'no longer needed');
|
|
|
|
expect(received).toEqual([
|
|
{ from: 'alice', kind: 'shade.webrtc-offer/v1' },
|
|
{ from: 'alice', kind: 'shade.webrtc-ice/v1' },
|
|
{ from: 'alice', kind: 'shade.webrtc-bye/v1' },
|
|
]);
|
|
|
|
aliceSig.destroy();
|
|
bobSig.destroy();
|
|
});
|
|
|
|
it('passes non-signaling messages through to the passthrough hook', async () => {
|
|
const { a, b } = MemoryShadeBridge.linked('alice', 'bob');
|
|
const passthrough: string[] = [];
|
|
const bobSig = new WebRtcSignalingChannel(b, {
|
|
passthrough: (_from, plaintext) => passthrough.push(plaintext),
|
|
});
|
|
const seen: string[] = [];
|
|
bobSig.onSignal((_from, msg) => seen.push(msg.kind));
|
|
|
|
await a.send('bob', 'hello world (not signaling)');
|
|
await a.send('bob', JSON.stringify({ kind: 'shade.fs.cancel/v1' }));
|
|
|
|
expect(passthrough).toContain('hello world (not signaling)');
|
|
expect(seen).toEqual([]);
|
|
bobSig.destroy();
|
|
});
|
|
|
|
it('preserves causal order — offer awaited before ICE handler runs', async () => {
|
|
const { a, b } = MemoryShadeBridge.linked('alice', 'bob');
|
|
const aliceSig = new WebRtcSignalingChannel(a);
|
|
const bobSig = new WebRtcSignalingChannel(b);
|
|
const order: string[] = [];
|
|
|
|
bobSig.onSignal(async (_from, msg) => {
|
|
if (msg.kind === 'shade.webrtc-offer/v1') {
|
|
// Slow handler — must complete before ICE arrives.
|
|
await new Promise<void>((resolve) => setTimeout(resolve, 25));
|
|
order.push('offer-done');
|
|
} else if (msg.kind === 'shade.webrtc-ice/v1') {
|
|
order.push('ice');
|
|
}
|
|
});
|
|
|
|
await aliceSig.sendOffer('bob', 's', 'sdp');
|
|
await aliceSig.sendIce('bob', 's', null);
|
|
|
|
expect(order).toEqual(['offer-done', 'ice']);
|
|
aliceSig.destroy();
|
|
bobSig.destroy();
|
|
});
|
|
});
|