mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: update grpc headers
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -51,8 +51,8 @@ class GrpcUrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GrpcRepo {
|
class GrpcRepo {
|
||||||
static final String? _accessKey = Accounts.main.accessKey;
|
static String? _accessKey = Accounts.main.accessKey;
|
||||||
static const _build = 1462100;
|
static const _build = 2001100;
|
||||||
static const _biliChannel = 'bili';
|
static const _biliChannel = 'bili';
|
||||||
static const _mobiApp = 'android_hd';
|
static const _mobiApp = 'android_hd';
|
||||||
static const _phone = 'phone';
|
static const _phone = 'phone';
|
||||||
@@ -61,6 +61,24 @@ class GrpcRepo {
|
|||||||
static final _traceId = Utils.genTraceId();
|
static final _traceId = Utils.genTraceId();
|
||||||
static final _sessionId = Utils.generateRandomString(8);
|
static final _sessionId = Utils.generateRandomString(8);
|
||||||
|
|
||||||
|
static void updateHeaders(String? accessKey) {
|
||||||
|
_accessKey = accessKey;
|
||||||
|
if (_accessKey != null) {
|
||||||
|
headers['authorization'] = 'identify_v1 $_accessKey';
|
||||||
|
} else {
|
||||||
|
headers.remove('authorization');
|
||||||
|
}
|
||||||
|
headers['x-bili-metadata-bin'] = base64Encode(Metadata(
|
||||||
|
accessKey: _accessKey ?? '',
|
||||||
|
mobiApp: _mobiApp,
|
||||||
|
device: _phone,
|
||||||
|
build: _build,
|
||||||
|
channel: _biliChannel,
|
||||||
|
buvid: _buvid,
|
||||||
|
platform: _mobiApp,
|
||||||
|
).writeToBuffer());
|
||||||
|
}
|
||||||
|
|
||||||
static final Map<String, String> headers = {
|
static final Map<String, String> headers = {
|
||||||
Headers.contentTypeHeader: 'application/grpc',
|
Headers.contentTypeHeader: 'application/grpc',
|
||||||
'grpc-encoding': 'gzip',
|
'grpc-encoding': 'gzip',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||||
import 'package:PiliPlus/http/loading_state.dart';
|
import 'package:PiliPlus/http/loading_state.dart';
|
||||||
import 'package:PiliPlus/http/user.dart';
|
import 'package:PiliPlus/http/user.dart';
|
||||||
import 'package:PiliPlus/models/common/dynamics_type.dart';
|
import 'package:PiliPlus/models/common/dynamics_type.dart';
|
||||||
@@ -26,6 +27,7 @@ class LoginUtils {
|
|||||||
|
|
||||||
static Future onLoginMain() async {
|
static Future onLoginMain() async {
|
||||||
final account = Accounts.main;
|
final account = Accounts.main;
|
||||||
|
GrpcRepo.updateHeaders(account.accessKey);
|
||||||
try {
|
try {
|
||||||
final cookies = account.cookieJar.toList();
|
final cookies = account.cookieJar.toList();
|
||||||
final webManager = web.CookieManager();
|
final webManager = web.CookieManager();
|
||||||
@@ -111,6 +113,8 @@ class LoginUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future onLogoutMain() async {
|
static Future onLogoutMain() async {
|
||||||
|
GrpcRepo.updateHeaders(null);
|
||||||
|
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
web.CookieManager().deleteAllCookies(),
|
web.CookieManager().deleteAllCookies(),
|
||||||
GStorage.userInfo.delete('userInfoCache'),
|
GStorage.userInfo.delete('userInfoCache'),
|
||||||
|
|||||||
Reference in New Issue
Block a user