@hienlh/ppm 0.8.27 → 0.8.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -518,6 +518,10 @@ class AccountService {
|
|
|
518
518
|
async refreshAccessToken(accountId: string, disableOnFail = true): Promise<void> {
|
|
519
519
|
const account = this.getWithTokens(accountId);
|
|
520
520
|
if (!account) throw new Error(`Account ${accountId} not found`);
|
|
521
|
+
// Skip refresh for temporary accounts (no refresh token)
|
|
522
|
+
if (!account.refreshToken || account.refreshToken === "") {
|
|
523
|
+
throw new Error(`Account ${accountId} has no refresh token (temporary account)`);
|
|
524
|
+
}
|
|
521
525
|
const res = await fetch(OAUTH_TOKEN_URL, {
|
|
522
526
|
method: "POST",
|
|
523
527
|
headers: { "Content-Type": "application/json" },
|
|
@@ -530,8 +534,8 @@ class AccountService {
|
|
|
530
534
|
if (!res.ok) {
|
|
531
535
|
const errorBody = await res.text().catch(() => "");
|
|
532
536
|
console.error(`[accounts] Refresh failed for ${accountId}: ${res.status} ${errorBody}`);
|
|
533
|
-
// invalid_grant = refresh token permanently dead → clear it so account becomes temporary
|
|
534
|
-
if (errorBody.includes("invalid_grant")) {
|
|
537
|
+
// invalid_grant or invalid_request = refresh token permanently dead → clear it so account becomes temporary
|
|
538
|
+
if (errorBody.includes("invalid_grant") || errorBody.includes("invalid_request")) {
|
|
535
539
|
console.log(`[accounts] Clearing invalid refresh token for ${account.email ?? accountId} — account is now temporary`);
|
|
536
540
|
updateAccount(accountId, { refresh_token: encrypt("") });
|
|
537
541
|
}
|