Compare commits

..
Author SHA1 Message Date
Antigravity AI eccf952e6b fix(auth): add sessionVersion migration and harden login error handling
- Add missing ALTER TABLE migration for sessionVersion column; fresh
  self-hosted installs were failing with "column users.sessionVersion
  does not exist" because the column was in schema.prisma but had no
  migration file, so prisma migrate deploy never created it
- loginAction now catches all errors instead of re-throwing non-AuthError
  exceptions, preventing raw server errors reaching the client
- LoginForm wraps loginAction in try/catch so the loading state always
  resets and an error message is shown even on unexpected server failures
  (previously the button froze on "Signing in..." with no feedback)
2026-06-05 23:05:26 +12:00
Antigravity AI 673f4ec0b1 chore: add Tier 2+3 plugin smoke test script
Adds scripts/ci-plugin-smoke/smoke.mjs — a Node.js smoke test that loads
a plugin bundle and validates its WorldPlugin contract without a browser,
network, or Docker image.

Tier 2: verifies the bundle loads and the default export has all required
fields (id, name, description, category, version) and methods (initialize,
destroy, fetch, getPollingInterval, getLayerConfig, renderEntity).

Tier 3: calls the pure synchronous methods — getLayerConfig(), renderEntity(),
getPollingInterval() — and validates their return shapes. Also exercises
mapWebsocketPayload() when present, checking it returns a GeoEntity[].

Bundles expose externals via globalThis.__WWV_HOST__ (per wwvPluginGlobals()
Vite plugin), so no Node.js module hooks are needed — the mock host is set
up in a single assignment before import().
2026-06-05 19:42:23 +12:00
Antigravity AI f4e33f6588 fix(libs): pin SDK peer dep to workspace:* to fix stale nested resolution
wwv-lib-aviation and wwv-lib-incidents declared the SDK peer dep as
"^1.4.10" (registry version), causing pnpm to install 1.5.0 nested
inside each lib's node_modules. TypeScript resolved PluginContext from
the nested 1.5.0 (which lacked getEngineUrl), not the workspace version,
breaking CI type-checks for aviation and conflict-events plugins.

Also includes docs: add property tag helper examples to local-plugins/README.md.
2026-06-05 14:42:45 +12:00
Silvertakana cc3902cbbd fix(sdk): export prop helpers + add npm repository field (#244)
* fix(libs): add repository field so npm provenance validates on publish

Publishing wwv-lib-incidents/aviation with --provenance failed E422: the
sigstore bundle requires package.json repository.url to match the building repo,
and these two libs had none. Added the same repository block the SDK already
uses (which published fine). The SDK (1.7.1) is already live; this unblocks the
two libs.

* fix(sdk): export dtProp, urlProp, imageProp, videoProp from virtual module

The wwvPluginGlobals virtual module for @worldwideview/wwv-plugin-sdk only
destructured the original four exports (WorldPlugin, PluginManifest,
createSvgIconUrl, DEFAULT_ICON_SIZE). Plugins importing the newer prop
utility helpers (dtProp, urlProp, imageProp, videoProp) got a Rolldown
[MISSING_EXPORT] error at build time, failing CI for civil-unrest,
cyber-attacks, earthquakes, wildfire, and iranwarlive.

All four helpers are already present on globalThis.__WWV_HOST__.WWVPluginSDK
(the host does import * as WWVPluginSDK) so no host changes are needed.
2026-06-05 14:24:34 +12:00
9 changed files with 1150 additions and 11 deletions

No files matched your search

+26
View File
@@ -20,6 +20,32 @@ pnpm dev
4. The marketplace load API auto-discovers them in dev mode
5. Everything in this directory is gitignored
## Property Conventions
Use the SDK property tag helpers to give the Intel panel rich rendering for dates, URLs, images, and video. Without them, values display as plain text.
```ts
import { dtProp, urlProp, imageProp, videoProp } from "@worldwideview/wwv-plugin-sdk";
properties: {
// Dates — pass ISO 8601 strings
updated_at: dtProp(item.timestamp ?? null),
// External links
source_url: urlProp(item.url ?? null),
// Images
preview: imageProp(item.image_url ?? null),
// Video/streams
live_stream: videoProp(item.stream_url ?? null),
// Plain values — no helper needed
name: item.name,
count: item.count,
}
```
All helpers are null-safe — passing `null` or `undefined` returns `null`, which the panel skips.
See the [SDK README](../worldwideview/packages/wwv-plugin-sdk/README.md) for the full reference.
## Publishing to NPM
When your plugin is ready to share, you can publish it directly to NPM from the root directory:
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "worldwideview",
"version": "2.48.27",
"version": "2.48.30",
"private": true,
"type": "module",
"packageManager": "[email protected]",
+1 -1
View File
@@ -21,6 +21,6 @@
"author": "WorldWideView",
"license": "ISC",
"peerDependencies": {
"@worldwideview/wwv-plugin-sdk": "^1.4.10"
"@worldwideview/wwv-plugin-sdk": "workspace:*"
}
}
+1 -1
View File
@@ -21,6 +21,6 @@
"author": "WorldWideView",
"license": "ISC",
"peerDependencies": {
"@worldwideview/wwv-plugin-sdk": "^1.4.10"
"@worldwideview/wwv-plugin-sdk": "workspace:*"
}
}
+856 -6
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,5 @@
-- Add sessionVersion to users table.
-- Existing rows default to 0, which matches the @default(0) in schema.prisma.
-- This column is embedded in every JWT at sign-in; bumping it invalidates all
-- existing sessions for that user (logout-everywhere / credential rotation).
ALTER TABLE "users" ADD COLUMN "sessionVersion" INTEGER NOT NULL DEFAULT 0;
+247
View File
@@ -0,0 +1,247 @@
/**
* ci-plugin-smoke/smoke.mjs
* Tier 2: Load the bundle and verify WorldPlugin interface shape.
* Tier 3: Exercise pure methods — getLayerConfig, renderEntity, mapWebsocketPayload.
*
* Plugin bundles reference globalThis.__WWV_HOST__ for all externals (React, Cesium,
* wwv-plugin-sdk, etc.) via the wwvPluginGlobals() Vite plugin. No Node.js module
* hooks are needed — setting up __WWV_HOST__ before import() is sufficient.
*
* Usage: node scripts/ci-plugin-smoke/smoke.mjs <path-to-dist/frontend.mjs>
*/
import { pathToFileURL } from "node:url";
import path from "node:path";
// ── Args ─────────────────────────────────────────────────────────────────────
const [, , bundleArg] = process.argv;
if (!bundleArg) {
console.error("Usage: node scripts/ci-plugin-smoke/smoke.mjs <path-to-dist/frontend.mjs>");
process.exit(2);
}
const bundleAbs = path.resolve(bundleArg);
const bundleUrl = pathToFileURL(bundleAbs).href;
// ── Mock host globals ─────────────────────────────────────────────────────────
// Mirrors what the host app injects at runtime. All externals in the bundle
// resolve to these via globalThis.__WWV_HOST__.<name>.
const noop = () => {};
globalThis.__WWV_HOST__ = {
React: new Proxy(
{
createElement: () => null,
Fragment: Symbol("Fragment"),
memo: (c) => c,
forwardRef: (fn) => fn,
lazy: () => null,
createContext: () => ({ Provider: null, Consumer: null, _currentValue: null }),
Component: class Component {},
PureComponent: class PureComponent {},
},
{
get(target, key) {
if (key in target) return target[key];
if (["useState", "useRef", "useContext", "useReducer"].includes(key)) return () => [null, noop];
if (["useEffect", "useLayoutEffect", "useInsertionEffect"].includes(key)) return noop;
if (["useMemo", "useCallback"].includes(key)) return (fn) => (typeof fn === "function" ? fn() : fn);
return noop;
},
}
),
ReactDOM: { createPortal: () => null, flushSync: (fn) => fn(), render: noop },
jsxRuntime: { jsx: () => null, jsxs: () => null, Fragment: null },
Cesium: new Proxy(
{},
{
get(_, key) {
if (key === "Math") return Math;
if (key === Symbol.toPrimitive) return undefined;
return function MockCesium() {};
},
}
),
Resium: new Proxy({}, { get: () => function MockResium() {} }),
WWVPluginSDK: {
createSvgIconUrl: () => "data:image/svg+xml;base64,PHN2Zy8+",
DEFAULT_ICON_SIZE: 32,
dtProp: (v) => (v ? `datetime:${v}` : null),
urlProp: (v) => (v ? `url:${v}` : null),
imageProp: (v) => (v ? `image:${v}` : null),
videoProp: (v) => (v ? `video:${v}` : null),
},
zustand: {
create: () => Object.assign(() => ({}), { getState: () => ({}), setState: noop, subscribe: () => noop }),
createStore: () => ({ getState: () => ({}), setState: noop, subscribe: () => noop }),
},
useStore: () => ({}),
pluginManager: { getPlugin: () => null, registerPlugin: noop },
CameraStream: null,
};
// No-op fetch so any top-level module code that calls fetch() does not throw.
globalThis.fetch ??= async () => ({ ok: true, status: 200, json: async () => [], text: async () => "[]" });
// ── Load the bundle ───────────────────────────────────────────────────────────
let mod;
try {
mod = await import(bundleUrl);
} catch (err) {
console.error(`FAIL [Tier 2] Bundle failed to load: ${err.message}`);
process.exit(1);
}
// ── Instantiate (mirrors loadBundlePlugin logic) ──────────────────────────────
function tryInstantiate(maybeExport) {
if (!maybeExport) return null;
if (typeof maybeExport === "function") {
try {
const inst = new maybeExport();
if (inst && typeof inst.initialize === "function") return inst;
} catch {
return null;
}
}
if (typeof maybeExport === "object" && typeof maybeExport.initialize === "function") return maybeExport;
return null;
}
let plugin = null;
if (mod.default) {
plugin = typeof mod.default === "function"
? (tryInstantiate(mod.default) ?? new mod.default())
: mod.default;
}
if (!plugin) {
for (const k of Object.keys(mod)) {
plugin = tryInstantiate(mod[k]);
if (plugin) break;
}
}
if (!plugin) {
console.error("FAIL [Tier 2] No valid WorldPlugin export found in bundle.");
process.exit(1);
}
console.log("OK [Tier 2] Bundle loaded and plugin instantiated");
// ── Tier 2: Required interface fields ────────────────────────────────────────
const REQUIRED_STRINGS = ["id", "name", "description", "category", "version"];
const REQUIRED_METHODS = ["initialize", "destroy", "fetch", "getPollingInterval", "getLayerConfig", "renderEntity"];
let passed = true;
for (const field of REQUIRED_STRINGS) {
if (typeof plugin[field] !== "string" || !plugin[field]) {
console.error(`FAIL [Tier 2] Missing or empty string field: "${field}" (got ${JSON.stringify(plugin[field])})`);
passed = false;
} else {
console.log(` ok ${field} = ${JSON.stringify(plugin[field])}`);
}
}
for (const method of REQUIRED_METHODS) {
if (typeof plugin[method] !== "function") {
console.error(`FAIL [Tier 2] Missing required method: ${method}()`);
passed = false;
} else {
console.log(` ok ${method}()`);
}
}
if (!passed) {
console.error("FAIL [Tier 2] WorldPlugin shape validation failed — see above");
process.exit(1);
}
console.log("OK [Tier 2] WorldPlugin interface shape validated");
// ── Tier 3: Exercise pure methods ─────────────────────────────────────────────
// These methods must be callable without a real engine or network.
// getPollingInterval()
try {
const interval = plugin.getPollingInterval();
if (typeof interval !== "number" || interval < 0) {
console.error(`FAIL [Tier 3] getPollingInterval() returned invalid value: ${JSON.stringify(interval)}`);
passed = false;
} else {
console.log(` ok getPollingInterval() = ${interval}`);
}
} catch (err) {
console.error(`FAIL [Tier 3] getPollingInterval() threw: ${err.message}`);
passed = false;
}
// getLayerConfig()
let layerConfig;
try {
layerConfig = plugin.getLayerConfig();
if (!layerConfig || typeof layerConfig !== "object") {
console.error(`FAIL [Tier 3] getLayerConfig() returned non-object: ${JSON.stringify(layerConfig)}`);
passed = false;
} else if (typeof layerConfig.color !== "string") {
console.error(`FAIL [Tier 3] getLayerConfig().color is not a string: ${JSON.stringify(layerConfig.color)}`);
passed = false;
} else {
console.log(` ok getLayerConfig() color=${layerConfig.color}`);
}
} catch (err) {
console.error(`FAIL [Tier 3] getLayerConfig() threw: ${err.message}`);
passed = false;
}
// renderEntity() with a mock GeoEntity
const mockEntity = {
id: "ci-smoke-001",
pluginId: plugin.id,
latitude: 37.7749,
longitude: -122.4194,
altitude: 0,
timestamp: new Date(),
label: "Smoke Test",
properties: {},
};
try {
const opts = plugin.renderEntity(mockEntity);
if (!opts || typeof opts !== "object") {
console.error(`FAIL [Tier 3] renderEntity() returned non-object: ${JSON.stringify(opts)}`);
passed = false;
} else if (typeof opts.type !== "string") {
console.error(`FAIL [Tier 3] renderEntity().type is not a string (got ${JSON.stringify(opts.type)})`);
passed = false;
} else {
console.log(` ok renderEntity() type=${opts.type}`);
}
} catch (err) {
console.error(`FAIL [Tier 3] renderEntity() threw: ${err.message}`);
passed = false;
}
// mapWebsocketPayload() — optional but validated when present
if (typeof plugin.mapWebsocketPayload === "function") {
// A flat GeoEntity[] is the simplest payload shape. Plugins that receive
// object payloads from the seeder (e.g. { items: [...] }) must implement
// this method to map to GeoEntity[]. We test with the flat-array case first.
const mockPayload = [mockEntity];
try {
const result = plugin.mapWebsocketPayload(mockPayload, []);
if (!Array.isArray(result)) {
console.error(
`FAIL [Tier 3] mapWebsocketPayload([entity]) returned non-array: ${JSON.stringify(typeof result)}`
);
passed = false;
} else {
console.log(` ok mapWebsocketPayload([1 entity]) -> ${result.length} entities`);
}
} catch (err) {
console.error(`FAIL [Tier 3] mapWebsocketPayload() threw: ${err.message}`);
passed = false;
}
} else {
console.log(" -- mapWebsocketPayload not implemented (flat GeoEntity[] assumed — OK)");
}
if (!passed) {
console.error("FAIL [Tier 3] Method contract violations — see above");
process.exit(1);
}
console.log("OK [Tier 3] Method contracts validated");
console.log("PASS smoke test complete");
+8 -1
View File
@@ -30,7 +30,14 @@ export default function LoginForm() {
setLoading(true);
const formData = new FormData(e.currentTarget);
const result = await loginAction(formData);
let result;
try {
result = await loginAction(formData);
} catch {
setError("Something went wrong. Please try again.");
setLoading(false);
return;
}
if (result.success) {
const target = getSafeRedirect(next);
+5 -1
View File
@@ -28,6 +28,10 @@ export async function loginAction(formData: FormData): Promise<LoginResult> {
: "Something went wrong.",
};
}
throw error;
// Non-AuthError (e.g. DB unavailable, missing column, network issue):
// log server-side and return a safe generic message so the client
// never receives raw stack traces and loading state always resets.
console.error("[loginAction] unexpected error:", error);
return { success: false, error: "Something went wrong. Please try again." };
}
}