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:
@@ -1,21 +1,19 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { lookup_site_domain } from '$lib/ae_core/ae_core__site';
|
||||
import { api } from '$lib/api/api';
|
||||
import * as public_env from '$env/static/public';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
/**
|
||||
* Dynamic Web Manifest Generator
|
||||
* Generates PWA metadata based on the requesting domain.
|
||||
* Modern Dynamic Web Manifest Generator
|
||||
* Reference: https://web.dev/articles/add-manifest
|
||||
*/
|
||||
export const GET: RequestHandler = async ({ url, fetch }) => {
|
||||
const fqdn = url.hostname;
|
||||
const fqdn = url.host;
|
||||
|
||||
// Construct api_cfg from public env vars for the server-side lookup
|
||||
const protocol = public_env.PUBLIC_AE_API_PROTOCOL || 'https';
|
||||
const server = public_env.PUBLIC_AE_API_SERVER || 'api.oneskyit.com';
|
||||
const port = public_env.PUBLIC_AE_API_PORT || '443';
|
||||
const path = public_env.PUBLIC_AE_API_PATH || '';
|
||||
|
||||
const api_base_url = `${protocol}://${server}${port === '443' || port === '80' ? '' : ':' + port}${path}`;
|
||||
|
||||
const api_cfg = {
|
||||
@@ -29,58 +27,86 @@ export const GET: RequestHandler = async ({ url, fetch }) => {
|
||||
|
||||
let site_domain = null;
|
||||
try {
|
||||
site_domain = await lookup_site_domain({
|
||||
// Use structured filter for exact matching
|
||||
const search_query = {
|
||||
and: [{ field: 'fqdn', op: 'eq', value: fqdn }]
|
||||
};
|
||||
|
||||
const result_li = await api.search_ae_obj_v3({
|
||||
api_cfg,
|
||||
fqdn,
|
||||
obj_type: 'site_domain',
|
||||
search_query,
|
||||
view: 'base',
|
||||
limit: 1,
|
||||
log_lvl: 0
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(`PWA Manifest: Lookup failed for domain ${fqdn}:`, e);
|
||||
}
|
||||
|
||||
// Default branding values (Fallback to OSIT Aether)
|
||||
let name = "One Sky IT - One Sky IT Aether PWA";
|
||||
let short_name = "Aether PWA";
|
||||
let background_color = "hsl(220, 65%, 31%)";
|
||||
let theme_color = "#3a5997";
|
||||
|
||||
if (site_domain) {
|
||||
// If site_domain has account_name like "Danger Zone", name becomes "One Sky IT - Danger Zone Aether PWA"
|
||||
const branding_name = site_domain.account_name || site_domain.name || "Aether";
|
||||
name = `One Sky IT - ${branding_name} Aether PWA`;
|
||||
short_name = `${site_domain.account_code || site_domain.code || 'Aether'} PWA`;
|
||||
|
||||
if (site_domain.cfg_json?.pwa_background_color) {
|
||||
background_color = site_domain.cfg_json.pwa_background_color;
|
||||
if (result_li && result_li.length > 0) {
|
||||
site_domain = result_li[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`PWA Manifest: Lookup failed for domain ${fqdn}`);
|
||||
}
|
||||
|
||||
// Default branding
|
||||
const branding_name = site_domain?.account_name || site_domain?.name || "Aether";
|
||||
const name = `One Sky IT - ${branding_name} Aether PWA`;
|
||||
const short_name = `${site_domain?.account_code || site_domain?.code || 'Aether'} PWA`;
|
||||
const background_color = site_domain?.cfg_json?.pwa_background_color || "hsl(220, 65%, 31%)";
|
||||
const theme_color = "#3a5997";
|
||||
|
||||
const manifest = {
|
||||
"background_color": background_color,
|
||||
"description": `The ${name} Progressive Web App`,
|
||||
"display": "fullscreen",
|
||||
"icons": [
|
||||
{ "sizes": "24x24", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_24px.png", "type": "image/png" },
|
||||
{ "sizes": "48x48", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_48px.png", "type": "image/png" },
|
||||
{ "sizes": "88x88", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_88px.webp", "type": "image/webp" },
|
||||
{ "sizes": "88x88", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_88px.png", "type": "image/png" },
|
||||
{ "sizes": "120x120", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_120px.png", "type": "image/png" },
|
||||
{ "sizes": "144x144", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_144px.png", "type": "image/png" },
|
||||
{ "sizes": "180x180", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_180px.png", "type": "image/png" },
|
||||
{ "sizes": "192x192", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.webp", "type": "image/webp" },
|
||||
{ "sizes": "192x192", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.png", "type": "image/png" },
|
||||
{ "sizes": "256x256", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_256px.webp", "type": "image/webp" },
|
||||
{ "sizes": "256x256", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_256px.png", "type": "image/png" },
|
||||
{ "sizes": "300x300", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_300px.png", "type": "image/png" },
|
||||
{ "sizes": "512x512", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_512px.webp", "type": "image/webp" },
|
||||
{ "sizes": "512x512", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_512px.png", "type": "image/png" },
|
||||
{ "sizes": "1024x1024", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_1024px.webp", "type": "image/webp" },
|
||||
{ "sizes": "1024x1024", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_1024px.png", "type": "image/png" }
|
||||
],
|
||||
"id": `ae-pwa-${fqdn}`, // Unique ID for this installation
|
||||
"name": name,
|
||||
"short_name": short_name,
|
||||
"description": `The ${name} platform for unified event and documentation management.`,
|
||||
"start_url": "/",
|
||||
"theme_color": theme_color
|
||||
"scope": "/",
|
||||
"display": "fullscreen",
|
||||
"background_color": background_color,
|
||||
"theme_color": theme_color,
|
||||
"orientation": "any",
|
||||
"categories": ["business", "productivity", "utilities"],
|
||||
"icons": [
|
||||
// Standard Icons (Small/Med)
|
||||
{ "sizes": "24x24", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_24px.png", "type": "image/png" },
|
||||
{ "sizes": "48x48", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_48px.png", "type": "image/png" },
|
||||
{ "sizes": "96x96", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_96px.png", "type": "image/png" },
|
||||
{ "sizes": "144x144", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_144px.png", "type": "image/png" },
|
||||
{ "sizes": "180x180", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_180px.png", "type": "image/png" },
|
||||
// High-res Maskable Icons (WebP preferred for efficiency)
|
||||
{ "sizes": "192x192", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.webp", "type": "image/webp", "purpose": "any maskable" },
|
||||
{ "sizes": "192x192", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.png", "type": "image/png", "purpose": "any maskable" },
|
||||
{ "sizes": "512x512", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_512px.webp", "type": "image/webp", "purpose": "any maskable" },
|
||||
{ "sizes": "512x512", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_512px.png", "type": "image/png", "purpose": "any maskable" },
|
||||
{ "sizes": "1024x1024", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_1024px.webp", "type": "image/webp", "purpose": "any maskable" },
|
||||
{ "sizes": "1024x1024", "src": "https://static.oneskyit.com/images/OSIT_logo_2022_1024px.png", "type": "image/png", "purpose": "any maskable" }
|
||||
],
|
||||
// App Shortcuts (Long-press icon features)
|
||||
"shortcuts": [
|
||||
{
|
||||
"name": "Journals",
|
||||
"short_name": "Journals",
|
||||
"description": "View and manage journal entries",
|
||||
"url": "/journals",
|
||||
"icons": [{ "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.png", "sizes": "192x192" }]
|
||||
},
|
||||
{
|
||||
"name": "Events",
|
||||
"short_name": "Events",
|
||||
"description": "Access active event management",
|
||||
"url": "/events",
|
||||
"icons": [{ "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.png", "sizes": "192x192" }]
|
||||
},
|
||||
{
|
||||
"name": "Testing",
|
||||
"short_name": "Testing",
|
||||
"description": "System diagnostic dashboard",
|
||||
"url": "/testing",
|
||||
"icons": [{ "src": "https://static.oneskyit.com/images/OSIT_logo_2022_192px.png", "sizes": "192x192" }]
|
||||
}
|
||||
],
|
||||
"testing": "One Sky IT"
|
||||
};
|
||||
|
||||
return json(manifest, {
|
||||
|
||||
Reference in New Issue
Block a user