mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-18 22:54:33 +01:00
Moves the tutor app's generic relay client (RTDB REST/SSE, e2e sealing per an app layout, request hub, rev watcher, passphrase gate, Google->Firebase session, desktop credential adoption) into rtdb_relay/dart. The tutor vectors and a differential test against the tutor's frozen pre-extraction sealer pin the wire format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWYeKVg9WihaikbfDSe
29 lines
856 B
Dart
29 lines
856 B
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:crdt_sync/crdt_sync.dart' show Argon2Params, E2eCipher;
|
|
import 'package:rtdb_relay/src/rtdb_client.dart';
|
|
import 'package:rtdb_relay/src/sealer.dart';
|
|
|
|
import 'fake_rtdb.dart';
|
|
import 'tutor_layout.dart';
|
|
|
|
const fastArgon = Argon2Params(memoryKiB: 8, iterations: 1, parallelism: 1);
|
|
const testRid = '01J0000000000000000000000R';
|
|
|
|
final Map<String, dynamic> e2eVectors = jsonDecode(
|
|
File('test/data/e2e_vectors.json').readAsStringSync(),
|
|
) as Map<String, dynamic>;
|
|
|
|
RelaySealer vectorSealer() => RelaySealer(
|
|
E2eCipher(hexBytes(e2eVectors['key_hex'] as String)),
|
|
layout: tutorLayout,
|
|
);
|
|
|
|
List<int> hexBytes(String s) => [
|
|
for (var i = 0; i < s.length; i += 2)
|
|
int.parse(s.substring(i, i + 2), radix: 16),
|
|
];
|
|
|
|
RtdbClient sealedClient(FakeRtdb db) => db.client()..sealer = vectorSealer();
|