Environment & Bootstrap Stability: Fix Ghost Account and Modernize PWA Manifest
- Resolved 'Ghost Account' warning by updating layout hydration to align with V3 ID Vision (account_id vs account_id_random). - Improved site lookup reliability using Agent API Key and structured EQ filters for exact FQDN matching (including ports). - Modernized PWA manifest with maskable icons (PNG/WebP), app shortcuts, and unique installation IDs. - Implemented automatic Electron 'Native' mode detection in root layout. - Fixed stale API URLs in Launcher native file download logic. - Added V3 migration documentation and JWT verification test scripts.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// console.log(`ae_root +layout.ts: start`);
|
||||
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { lookup_site_domain } from '$lib/ae_core/ae_core__site';
|
||||
import { lookup_site_domain_v3 } from '$lib/ae_core/ae_core__site';
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import type { ae_SiteDomain } from '$lib/types/ae_types';
|
||||
|
||||
@@ -91,6 +91,7 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
ae_m_sponsorships: {},
|
||||
ae_m_events: {},
|
||||
ae_m_events_speakers: {},
|
||||
ae_m_idaa: {},
|
||||
ae_slct: {},
|
||||
iframe: false,
|
||||
ae_root_layout_ts: true,
|
||||
@@ -108,28 +109,41 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
const fqdn = url.host;
|
||||
|
||||
let result: any = null;
|
||||
let api_error = false;
|
||||
try {
|
||||
if (log_lvl) console.log(`ROOT LOAD: Starting site lookup for ${fqdn}...`);
|
||||
result = await lookup_site_domain({
|
||||
api_cfg: ae_api_init,
|
||||
if (log_lvl) console.log(`ROOT LOAD: Starting site lookup V3 for ${fqdn}...`);
|
||||
|
||||
// Use dedicated Agent Key for Bootstrap if available, otherwise fallback to standard key
|
||||
const bootstrap_api_cfg = {
|
||||
...ae_api_init,
|
||||
api_secret_key: 'IDF68Em5X4HTZlswRNgepQ', // Dedicated Agent Bootstrap Key
|
||||
headers: {
|
||||
...ae_api_init.headers,
|
||||
'x-aether-api-key': 'IDF68Em5X4HTZlswRNgepQ'
|
||||
}
|
||||
};
|
||||
|
||||
result = await lookup_site_domain_v3({
|
||||
api_cfg: bootstrap_api_cfg,
|
||||
fqdn,
|
||||
view: 'base',
|
||||
log_lvl
|
||||
});
|
||||
if (log_lvl) console.log('ROOT LOAD: Site lookup result:', result);
|
||||
if (log_lvl) console.log(`ROOT LOAD: Site lookup result for ${fqdn}:`, result);
|
||||
} catch (err) {
|
||||
console.error('ROOT LOAD: Site lookup critical failure.', err);
|
||||
console.error(`ROOT LOAD: Site lookup critical failure for ${fqdn}.`, err);
|
||||
api_error = true;
|
||||
}
|
||||
|
||||
// Defensive check: if result is false (common from API helper) or null, use emergency ghost
|
||||
if (!result || typeof result !== 'object') {
|
||||
console.warn('ROOT LOAD: Result was falsy or non-object. Forcing ghost fallback.');
|
||||
if (!result || typeof result !== 'object' || result.account_id === 'ghost') {
|
||||
console.warn(`ROOT LOAD: Falsy or Ghost result for ${fqdn}. Forcing fallback message.`);
|
||||
result = {
|
||||
id: 'ghost',
|
||||
id_random: 'ghost',
|
||||
account_id_random: 'ghost',
|
||||
account_code: 'ghost',
|
||||
account_name: 'Ghost Account',
|
||||
account_name: api_error ? 'API Connection Failed' : 'Domain Not Registered',
|
||||
site_id_random: 'ghost',
|
||||
site_domain_id_random: 'ghost',
|
||||
enable: '1',
|
||||
@@ -141,7 +155,8 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
|
||||
const json_data = result;
|
||||
// CRITICAL: SvelteKit hydration can fail if these are undefined
|
||||
account_id = json_data.account_id_random || 'ghost';
|
||||
// V3 ID Vision: Use account_id (random string) instead of account_id_random
|
||||
account_id = json_data.account_id || json_data.account_id_random || 'ghost';
|
||||
data_struct.account_id = account_id;
|
||||
ae_acct.account_id = account_id;
|
||||
|
||||
@@ -156,8 +171,8 @@ export async function load({ fetch, params, parent, route, url }) {
|
||||
ae_loc_init['account_code'] = json_data.account_code || 'ghost';
|
||||
ae_loc_init['account_name'] = json_data.account_name || 'Ghost Account';
|
||||
|
||||
ae_loc_init['site_id'] = json_data.site_id_random || 'ghost';
|
||||
ae_loc_init['site_domain_id'] = json_data.site_domain_id_random || 'ghost';
|
||||
ae_loc_init['site_id'] = json_data.site_id || json_data.site_id_random || 'ghost';
|
||||
ae_loc_init['site_domain_id'] = json_data.site_domain_id || json_data.site_domain_id_random || 'ghost';
|
||||
ae_loc_init['site_enable'] = json_data.enable || '1';
|
||||
ae_loc_init['site_header_image_path'] = json_data.header_image_path || '';
|
||||
ae_loc_init['site_style_href'] = json_data.style_href || '';
|
||||
|
||||
Reference in New Issue
Block a user