Change warp options

This commit is contained in:
problematicconsumer
2024-02-20 22:16:47 +03:30
parent c279e3550e
commit dc1b342ff6
11 changed files with 82 additions and 68 deletions

View File

@@ -457,7 +457,7 @@ class FFISingboxService with InfraLogger implements SingboxService {
}
@override
TaskEither<String, WarpAccount> generateWarpConfig({
TaskEither<String, WarpResponse> generateWarpConfig({
required String licenseKey,
required String previousAccountId,
required String previousAccessToken,
@@ -477,20 +477,7 @@ class FFISingboxService with InfraLogger implements SingboxService {
if (response.startsWith("error:")) {
return left(response.replaceFirst('error:', ""));
}
if (jsonDecode(response)
case {
"account-id": final String newAccountId,
"access-token": final String newAccessToken,
}) {
return right(
WarpAccount(
licenseKey: licenseKey,
accountId: newAccountId,
accessToken: newAccessToken,
),
);
}
return left("invalid response");
return right(warpFromJson(jsonDecode(response)));
},
),
);

View File

@@ -266,7 +266,7 @@ class PlatformSingboxService with InfraLogger implements SingboxService {
}
@override
TaskEither<String, WarpAccount> generateWarpConfig({
TaskEither<String, WarpResponse> generateWarpConfig({
required String licenseKey,
required String previousAccountId,
required String previousAccessToken,
@@ -282,20 +282,7 @@ class PlatformSingboxService with InfraLogger implements SingboxService {
"previous-access-token": previousAccessToken,
},
);
if (jsonDecode(warpConfig as String)
case {
"account-id": final String newAccountId,
"access-token": final String newAccessToken,
}) {
return right(
WarpAccount(
licenseKey: licenseKey,
accountId: newAccountId,
accessToken: newAccessToken,
),
);
}
return left("invalid response");
return right(warpFromJson(jsonDecode(warpConfig as String)));
},
);
}

View File

@@ -87,7 +87,7 @@ abstract interface class SingboxService {
TaskEither<String, Unit> clearLogs();
TaskEither<String, WarpAccount> generateWarpConfig({
TaskEither<String, WarpResponse> generateWarpConfig({
required String licenseKey,
required String previousAccountId,
required String previousAccessToken,