Files
OSIT-AE-App-Svelte/src/routes/idaa/(idaa)/archives/+layout.ts
Scott Idem b8e6bcaf03 fix(idaa): strip API calls from all +page.ts/+layout.ts, gate loading in $effect
SvelteKit load functions fire during link prefetch before Novi auth completes;
`if (browser)` guards do not prevent this. Moving all IDAA data fetching into
$effect hooks gated on `novi_verified || trusted_access` closes the IDB
pre-population race across archives, bb/[post_id], and recovery_meetings/[event_id].

Also documents the Auth-Before-Cache rule and per-route status in
AE__Permissions_and_Security.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 18:49:47 -04:00

29 lines
843 B
TypeScript

/** @type {import('./$types').LayoutLoad} */
// Data loading for IDAA Archives has been moved to the $effect in +page.svelte
// (gated on novi_verified / trusted_access). +layout.ts runs before layout effects and
// fires during SvelteKit link prefetch, making it unsafe for private IDAA content.
export async function load({ parent }) {
const log_lvl: number = 0;
const data = await parent();
data.log_lvl = log_lvl;
const account_id = data.account_id;
let ae_acct = data[account_id];
if (!ae_acct) {
console.warn(
`ae IDAA Archives +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.`
);
ae_acct = {
api: data.ae_api || {},
slct: { account_id: account_id }
};
}
data[account_id] = ae_acct;
return data;
}