forked from boos/BoosAPI
Refactor code structure for improved readability and maintainability
This commit is contained in:
Generated
+9653
File diff suppressed because it is too large
Load Diff
@@ -229,6 +229,19 @@ export class NewApiAdapter extends BasePlatformAdapter {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isTokenListResponse(payload: any): boolean {
|
||||||
|
if (!payload || typeof payload !== 'object') return false;
|
||||||
|
if (payload?.success === true) return true;
|
||||||
|
return (
|
||||||
|
Array.isArray(payload?.data)
|
||||||
|
|| Array.isArray(payload?.data?.items)
|
||||||
|
|| Array.isArray(payload?.data?.data)
|
||||||
|
|| Array.isArray(payload?.items)
|
||||||
|
|| Array.isArray(payload?.list)
|
||||||
|
|| Array.isArray(payload?.data?.list)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private normalizeTokenKeyForCompare(value?: string | null): string {
|
private normalizeTokenKeyForCompare(value?: string | null): string {
|
||||||
const trimmed = (value || '').trim();
|
const trimmed = (value || '').trim();
|
||||||
return trimmed.startsWith('Bearer ') ? trimmed.slice(7).trim() : trimmed;
|
return trimmed.startsWith('Bearer ') ? trimmed.slice(7).trim() : trimmed;
|
||||||
@@ -1236,6 +1249,7 @@ export class NewApiAdapter extends BasePlatformAdapter {
|
|||||||
});
|
});
|
||||||
const normalized = this.normalizeTokenItems(this.parseTokenItems(res));
|
const normalized = this.normalizeTokenItems(this.parseTokenItems(res));
|
||||||
if (normalized.length > 0) return normalized;
|
if (normalized.length > 0) return normalized;
|
||||||
|
if (this.isTokenListResponse(res)) return [];
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
const cookieTokens = await this.getApiTokensByCookie(baseUrl, accessToken, userId);
|
const cookieTokens = await this.getApiTokensByCookie(baseUrl, accessToken, userId);
|
||||||
|
|||||||
Reference in New Issue
Block a user