fix: harden proxy auth and SSRF defenses
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { useAccountStore } from '@/stores/account-store';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
|
||||
export function getActiveAccountSlot(): number | null {
|
||||
const authState = useAuthStore.getState();
|
||||
const accountState = useAccountStore.getState();
|
||||
const activeAccountId = authState.activeAccountId ?? accountState.activeAccountId;
|
||||
const activeAccount = activeAccountId
|
||||
? accountState.getAccountById(activeAccountId)
|
||||
: accountState.getActiveAccount();
|
||||
|
||||
return typeof activeAccount?.cookieSlot === 'number' ? activeAccount.cookieSlot : null;
|
||||
}
|
||||
|
||||
export function getActiveAccountSlotHeaders(): Record<string, string> {
|
||||
const slot = getActiveAccountSlot();
|
||||
return slot === null ? {} : { 'X-JMAP-Cookie-Slot': String(slot) };
|
||||
}
|
||||
Reference in New Issue
Block a user