test(mobile): reuse pointycastle for WebSocket handshake

Co-authored-by: Tom Brow <tomb@block.xyz>
Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
npub1tquskdu6yc4h8l7xxtceculxw600grekeq0xg2ukqfrwl7vrzg3quz3gmp
2026-08-02 19:57:14 -07:00
parent 0f442a8f3b
commit db60eaacaf
3 changed files with 10 additions and 10 deletions

View File

@@ -274,7 +274,7 @@ packages:
source: hosted
version: "0.3.5+2"
crypto:
dependency: "direct dev"
dependency: transitive
description:
name: crypto
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf

View File

@@ -47,7 +47,6 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^6.0.0
crypto: ^3.0.7
custom_lint: ^0.8.0
riverpod_lint: ^3.1.0
mocktail: ^1.0.4

View File

@@ -1,10 +1,11 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';
import 'package:buzz/shared/relay/relay_socket.dart';
import 'package:crypto/crypto.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pointycastle/digests/sha1.dart';
/// A server that completes the WS handshake then never speaks again: no pongs,
/// no close frame. Only a client-side ping timeout can notice.
@@ -19,13 +20,13 @@ Future<ServerSocket> _silentAfterHandshakeServer() async {
).firstMatch(String.fromCharCodes(data));
if (match == null) return;
final accept = base64.encode(
sha1
.convert(
utf8.encode(
'${match.group(1)!.trim()}258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
),
)
.bytes,
SHA1Digest().process(
Uint8List.fromList(
utf8.encode(
'${match.group(1)!.trim()}258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
),
),
),
);
client.write(
'HTTP/1.1 101 Switching Protocols\r\n'