Ask for the password once and retry when a machine requires elevation
Carry the protocol error code, wrap each machine's gateway so an elevation_required refusal shows one native password dialog, elevates that connection and retries; send the upload token with file uploads; add a Settings sign-in security section with the weak-password warning and sign out everywhere; accept the __Host- session cookie.
This commit is contained in:
@@ -21,7 +21,14 @@ Future<ChatUploadReply> postChatUpload(
|
||||
required String name,
|
||||
required String mime,
|
||||
required Uint8List bytes,
|
||||
}) => platform.postChatUpload(uri, name: name, mime: mime, bytes: bytes);
|
||||
Map<String, String> headers = const {},
|
||||
}) => platform.postChatUpload(
|
||||
uri,
|
||||
name: name,
|
||||
mime: mime,
|
||||
bytes: bytes,
|
||||
headers: headers,
|
||||
);
|
||||
|
||||
/// The header that carries the file name; the server refuses a post without it.
|
||||
const chatUploadNameHeader = 'X-Pipelines-Upload-Name';
|
||||
|
||||
@@ -10,6 +10,7 @@ Future<ChatUploadReply> postChatUpload(
|
||||
required String name,
|
||||
required String mime,
|
||||
required Uint8List bytes,
|
||||
Map<String, String> headers = const {},
|
||||
}) async {
|
||||
final client = HttpClient()..connectionTimeout = const Duration(seconds: 15);
|
||||
try {
|
||||
@@ -21,6 +22,7 @@ Future<ChatUploadReply> postChatUpload(
|
||||
..set(chatUploadNameHeader, Uri.encodeComponent(name))
|
||||
..set(HttpHeaders.contentTypeHeader, mime)
|
||||
..contentLength = bytes.length;
|
||||
headers.forEach(request.headers.set);
|
||||
request.add(bytes);
|
||||
final response = await request.close();
|
||||
final body = await response.transform(utf8.decoder).join();
|
||||
|
||||
@@ -7,4 +7,5 @@ Future<ChatUploadReply> postChatUpload(
|
||||
required String name,
|
||||
required String mime,
|
||||
required Uint8List bytes,
|
||||
Map<String, String> headers = const {},
|
||||
}) => throw UnsupportedError('Uploads are not supported on this platform.');
|
||||
|
||||
@@ -28,6 +28,7 @@ Future<ChatUploadReply> postChatUpload(
|
||||
required String name,
|
||||
required String mime,
|
||||
required Uint8List bytes,
|
||||
Map<String, String> headers = const {},
|
||||
}) async {
|
||||
final response = await _fetch(
|
||||
uri.toString().toJS,
|
||||
@@ -36,6 +37,7 @@ Future<ChatUploadReply> postChatUpload(
|
||||
headers: {
|
||||
chatUploadNameHeader: Uri.encodeComponent(name),
|
||||
'Content-Type': mime,
|
||||
...headers,
|
||||
}.jsify()!,
|
||||
body: bytes.toJS,
|
||||
credentials: 'same-origin'.toJS,
|
||||
|
||||
Reference in New Issue
Block a user