Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Track self-hosted portal handoff lifecycle
rcourtman1d867a70ade1
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex bde0416738..0df82022e4 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -574,7 +574,12 @@ browser-facing `GET /v1/checkout/portal-handoff` response must not expose thebound `checkout_intent_id`, and `POST /v1/checkout/session` must accept only`portal_handoff_id` for product-originated upgrade arrivals so the licenseserver resolves the private checkout intent internally before Stripe session-creation. That same owned contract also retires the old compatibility+creation. That handoff response is now intentionally narrowly stateful: first+resolution must stamp `resolved_at`, the portal-facing lifecycle must stay+derived from the owned handoff plus the private checkout intent+(`created`, `resolved`, `checkout_started`, `completed`), and completed+handoffs must refuse browser checkout replay instead of silently reopening+commercial state. That same owned contract also retires the old compatibilitybootstrap surfaces: Pulse must not expose a separate public`GET /auth/license-purchase-handoff` resolver, and the commercial server mustnot expose a direct browser bootstrap through `GET /v1/checkout/intent` oncediff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 5e8430424b..d6988298e0 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -478,10 +478,17 @@ loose `feature` / `return_url` query parameters, or a raw browser-suppliedmust expose `GET /v1/checkout/portal-handoff` as the canonical browserbootstrap, and the retired `GET /v1/checkout/intent` bootstrap must stayremoved once `portal_handoff_id` is the owned contract. The browser-facing-portal handoff response must reveal only `portal_handoff_id`, feature, and-expiry metadata; it must not disclose the bound `checkout_intent_id`, and-browser checkout creation must post only `portal_handoff_id` so Pulse Account+portal handoff response must reveal only portal-owned bootstrap metadata such+as `portal_handoff_id`, feature, handoff lifecycle state, resolve timestamp,+and expiry; it must not disclose the bound `checkout_intent_id`, and browser+checkout creation must post only `portal_handoff_id` so Pulse Accountresolves the private checkout intent server-side before contacting Stripe.+That portal handoff is now intentionally narrowly stateful rather than a bare+lookup row: lookup must stamp a first `resolved_at`, and the reported handoff+lifecycle must stay derived from the owned portal handoff plus the bound+checkout intent (`created`, `resolved`, `checkout_started`, `completed`) so+Pulse Account can distinguish a fresh upgrade bootstrap from a resumed or+already-completed checkout without reviving browser-owned commercial state.Stripe success now lands on Pulse's public`frontend-modern/src/utils/pricingHandoff.ts` and`frontend-modern/src/pages/PricingHandoff.tsx` may only hand operators intodiff --git a/internal/cloudcp/portal/dist/build_manifest.json b/internal/cloudcp/portal/dist/build_manifest.jsonindex 530154ff4d..05a43712ef 100644--- a/internal/cloudcp/portal/dist/build_manifest.json+++ b/internal/cloudcp/portal/dist/build_manifest.json@@ -1,5 +1,5 @@{- "source_hash": "0ce9d9355a418e4b8ac13262b21ca4ff14aefcde955bb018d246840453aaa72c",+ "source_hash": "791f928f75e431f8302b3d3c435ed49de18d60737c2d0e4c6521e4286ff6d626","build_inputs": ["package.json","tsconfig.json",diff --git a/internal/cloudcp/portal/dist/portal_app.js b/internal/cloudcp/portal/dist/portal_app.jsindex 63628ab51a..dc0afadfe9 100644--- a/internal/cloudcp/portal/dist/portal_app.js+++ b/internal/cloudcp/portal/dist/portal_app.js@@ -1411,7 +1411,10 @@return "";}var portalHandoffID = String(billingState.upgradePortalHandoffID || "").trim();- var checkoutDisabled = billingState.upgradeCheckout.pending || !portalHandoffID || billingState.upgradePortalHandoff.status === "loading" || billingState.upgradePortalHandoff.status !== "ready";+ var handoffLifecycle = String(+ billingState.upgradePortalHandoff.data && billingState.upgradePortalHandoff.data.status || ""+ ).trim();+ var checkoutDisabled = billingState.upgradeCheckout.pending || !portalHandoffID || billingState.upgradePortalHandoff.status === "loading" || billingState.upgradePortalHandoff.status !== "ready" || handoffLifecycle === "completed";return '<div class="billing-upgrade-plan-grid">' + plans.map(function(plan) {var buttons = Array.isArray(plan.buttons) ? plan.buttons : [];var checkoutButtons = buttons.filter(function(button) {@@ -1431,6 +1434,7 @@var portalHandoffID = String(billingState.upgradePortalHandoffID || "").trim();var pricingState = billingState.upgradePricing;var handoffState = billingState.upgradePortalHandoff;+ var handoffLifecycle = String(handoffState.data && handoffState.data.status || "").trim();var explainer = pricingState.data && pricingState.data.explainer ? pricingState.data.explainer : "";var summaryItems = [];if (billingState.upgradeCheckout.pending) {@@ -1448,7 +1452,13 @@} else if (handoffState.status === "error") {summaryItems.push('<div class="billing-status visible error">' + escapeText(handoffState.error || "Failed to verify the secure Pulse Pro upgrade handoff.") + "</div>");} else if (handoffState.status === "ready") {- summaryItems.push('<div class="billing-status visible success">Pulse Account will return completed checkout directly to Pulse Pro billing.</div>');+ if (handoffLifecycle === "completed") {+ summaryItems.push('<div class="billing-status visible success">This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.</div>');+ } else if (handoffLifecycle === "checkout_started") {+ summaryItems.push('<div class="billing-status visible">Secure checkout is already prepared for this upgrade. Continue below if you still need to reopen it.</div>');+ } else {+ summaryItems.push('<div class="billing-status visible success">Pulse Account will return completed checkout directly to Pulse Pro billing.</div>');+ }}if (pricingState.status === "loading" && !pricingState.data) {summaryItems.push("<p>Loading self-hosted plan options...</p>");@@ -1801,8 +1811,12 @@}async function startUpgradeCheckout(planKey, tier, billingCycle) {if (!planKey || !tier || !billingCycle) return;- var portalHandoffID = String(getBillingState().upgradePortalHandoffID || "").trim();- if (!portalHandoffID || getBillingState().upgradePortalHandoff.status !== "ready") {+ var billingState = getBillingState();+ var portalHandoffID = String(billingState.upgradePortalHandoffID || "").trim();+ var handoffLifecycle = String(+ billingState.upgradePortalHandoff.data && billingState.upgradePortalHandoff.data.status || ""+ ).trim();+ if (!portalHandoffID || billingState.upgradePortalHandoff.status !== "ready") {updateBillingState(function(nextBillingState) {failMutationState(nextBillingState.upgradeCheckout,@@ -1811,6 +1825,15 @@});return;}+ if (handoffLifecycle === "completed") {+ updateBillingState(function(nextBillingState) {+ failMutationState(+ nextBillingState.upgradeCheckout,+ "This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state."+ );+ });+ return;+ }updateBillingState(function(nextBillingState) {beginMutationState(nextBillingState.upgradeCheckout);});diff --git a/internal/cloudcp/portal/frontend/dev.mjs b/internal/cloudcp/portal/frontend/dev.mjsindex 36db6c7372..55babea065 100644--- a/internal/cloudcp/portal/frontend/dev.mjs+++ b/internal/cloudcp/portal/frontend/dev.mjs@@ -539,13 +539,18 @@ function routeCommercialAPI(request, response, url, scenario) {if (request.method === 'GET' && route === '/v1/checkout/portal-handoff') {const portalHandoffID = String(url.searchParams.get('portal_handoff_id') || '').trim();- if (portalHandoffID !== 'cph_preview_upgrade') {+ if (+ portalHandoffID !== 'cph_preview_upgrade' &&+ portalHandoffID !== 'cph_preview_completed'+ ) {sendJSON(response, 400, { error: 'portal_handoff_id is invalid' });return;}sendJSON(response, 200, {portal_handoff_id: portalHandoffID,feature: 'max_monitored_systems',+ status: portalHandoffID === 'cph_preview_completed' ? 'completed' : 'resolved',+ resolved_at: Math.floor(Date.now() / 1000) - 30,expires_at: Math.floor(Date.now() / 1000) + 3600,});return;@@ -626,7 +631,12 @@ function routeCommercialAPI(request, response, url, scenario) {if (route === '/v1/checkout/session') {readJSONBody(request).then(function(body) {- if (String(body.portal_handoff_id || '').trim() !== 'cph_preview_upgrade') {+ const portalHandoffID = String(body.portal_handoff_id || '').trim();+ if (portalHandoffID === 'cph_preview_completed') {+ sendJSON(response, 409, { error: 'This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.' });+ return;+ }+ if (portalHandoffID !== 'cph_preview_upgrade') {sendJSON(response, 400, { error: 'Pulse Account could not verify the secure Pulse Pro upgrade handoff.' });return;}diff --git a/internal/cloudcp/portal/frontend/src/billing.ts b/internal/cloudcp/portal/frontend/src/billing.tsindex bd4e749234..b56bb50e0e 100644--- a/internal/cloudcp/portal/frontend/src/billing.ts+++ b/internal/cloudcp/portal/frontend/src/billing.ts@@ -221,8 +221,12 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {async function startUpgradeCheckout(planKey: string, tier: string, billingCycle: string) {if (!planKey || !tier || !billingCycle) return;- var portalHandoffID = String(getBillingState().upgradePortalHandoffID || '').trim();- if (!portalHandoffID || getBillingState().upgradePortalHandoff.status !== 'ready') {+ var billingState = getBillingState();+ var portalHandoffID = String(billingState.upgradePortalHandoffID || '').trim();+ var handoffLifecycle = String(+ (billingState.upgradePortalHandoff.data && billingState.upgradePortalHandoff.data.status) || '',+ ).trim();+ if (!portalHandoffID || billingState.upgradePortalHandoff.status !== 'ready') {updateBillingState(function(nextBillingState) {failMutationState(nextBillingState.upgradeCheckout,@@ -231,6 +235,15 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {});return;}+ if (handoffLifecycle === 'completed') {+ updateBillingState(function(nextBillingState) {+ failMutationState(+ nextBillingState.upgradeCheckout,+ 'This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.',+ );+ });+ return;+ }updateBillingState(function(nextBillingState) {beginMutationState(nextBillingState.upgradeCheckout);});diff --git a/internal/cloudcp/portal/frontend/src/billing_view.test.ts b/internal/cloudcp/portal/frontend/src/billing_view.test.tsindex 73f89c900f..0d829ba0a0 100644--- a/internal/cloudcp/portal/frontend/src/billing_view.test.ts+++ b/internal/cloudcp/portal/frontend/src/billing_view.test.ts@@ -233,6 +233,7 @@ describe('services view', function() {billingState.upgradePortalHandoff.data = {portal_handoff_id: 'cph_signed',feature: 'max_monitored_systems',+ status: 'resolved',};billingState.upgradePricing.status = 'ready';billingState.upgradePricing.data = {@@ -317,6 +318,53 @@ describe('services view', function() {).toBe(true);});+ it('blocks a completed secure upgrade handoff from starting checkout again', function() {+ document.body.innerHTML = '<div id="upgrade-billing-root"></div>';++ var billingState = createPortalBillingState();+ billingState.upgradePortalHandoffID = 'cph_completed';+ billingState.upgradePortalHandoff.status = 'ready';+ billingState.upgradePortalHandoff.data = {+ portal_handoff_id: 'cph_completed',+ feature: 'max_monitored_systems',+ status: 'completed',+ };+ billingState.upgradePricing.status = 'ready';+ billingState.upgradePricing.data = {+ title: 'Pricing',+ description: 'Canonical pricing model',+ plans: [+ {+ tierKicker: 'Pro+',+ title: 'Pro+',+ price: '$14.99',+ period: '$129/year available too',+ blurb: 'More room.',+ features: [{ tone: 'check', html: 'Up to <strong>50 monitored systems</strong>' }],+ buttons: [+ {+ kind: 'checkout',+ className: 'btn btn-primary',+ tier: 'pro_plus',+ planKey: 'price_pro_plus_annual',+ billingCycle: 'annual',+ label: 'Buy Annual',+ },+ ],+ },+ ],+ };++ renderUpgradePanel(billingState, createBootstrap());++ expect(document.getElementById('upgrade-billing-root')?.innerHTML).toContain(+ 'This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.',+ );+ expect(+ (document.querySelector('[data-account-billing-action="upgrade-start-checkout"]') as HTMLButtonElement).disabled,+ ).toBe(true);+ });+it('blocks legacy checkout-intent arrivals without a verified portal handoff', function() {document.body.innerHTML = '<div id="upgrade-billing-root"></div>';diff --git a/internal/cloudcp/portal/frontend/src/billing_view.ts b/internal/cloudcp/portal/frontend/src/billing_view.tsindex 0a4d09c8e7..72e1eb983c 100644--- a/internal/cloudcp/portal/frontend/src/billing_view.ts+++ b/internal/cloudcp/portal/frontend/src/billing_view.ts@@ -89,10 +89,14 @@ function renderUpgradePlansHTML(billingState: PortalBillingState): string {}var portalHandoffID = String(billingState.upgradePortalHandoffID || '').trim();+ var handoffLifecycle = String(+ (billingState.upgradePortalHandoff.data && billingState.upgradePortalHandoff.data.status) || '',+ ).trim();var checkoutDisabled = billingState.upgradeCheckout.pending ||!portalHandoffID ||billingState.upgradePortalHandoff.status === 'loading' ||- billingState.upgradePortalHandoff.status !== 'ready';+ billingState.upgradePortalHandoff.status !== 'ready' ||+ handoffLifecycle === 'completed';return '<div class="billing-upgrade-plan-grid">' + plans.map(function(plan) {var buttons = Array.isArray(plan.buttons) ? plan.buttons : [];@@ -143,6 +147,7 @@ export function renderUpgradePanel(billingState: PortalBillingState, _bootstrap:var portalHandoffID = String(billingState.upgradePortalHandoffID || '').trim();var pricingState = billingState.upgradePricing;var handoffState = billingState.upgradePortalHandoff;+ var handoffLifecycle = String((handoffState.data && handoffState.data.status) || '').trim();var explainer = pricingState.data && pricingState.data.explainer ? pricingState.data.explainer : '';var summaryItems = [] as string[];@@ -161,7 +166,13 @@ export function renderUpgradePanel(billingState: PortalBillingState, _bootstrap:} else if (handoffState.status === 'error') {summaryItems.push('<div class="billing-status visible error">' + escapeText(handoffState.error || 'Failed to verify the secure Pulse Pro upgrade handoff.') + '</div>');} else if (handoffState.status === 'ready') {- summaryItems.push('<div class="billing-status visible success">Pulse Account will return completed checkout directly to Pulse Pro billing.</div>');+ if (handoffLifecycle === 'completed') {+ summaryItems.push('<div class="billing-status visible success">This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.</div>');+ } else if (handoffLifecycle === 'checkout_started') {+ summaryItems.push('<div class="billing-status visible">Secure checkout is already prepared for this upgrade. Continue below if you still need to reopen it.</div>');+ } else {+ summaryItems.push('<div class="billing-status visible success">Pulse Account will return completed checkout directly to Pulse Pro billing.</div>');+ }}if (pricingState.status === 'loading' && !pricingState.data) {summaryItems.push('<p>Loading self-hosted plan options...</p>');diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.tsindex 5e060bb59a..c27ef52dd9 100644--- a/internal/cloudcp/portal/frontend/src/types.ts+++ b/internal/cloudcp/portal/frontend/src/types.ts@@ -82,6 +82,8 @@ export interface PortalUpgradePricingModel {export interface PortalUpgradePortalHandoffModel {portal_handoff_id: string;feature?: string;+ status?: string;+ resolved_at?: number;expires_at?: number;}diff --git a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts b/tests/integration/tests/55-self-hosted-upgrade-return.spec.tsindex 43494bb956..6172a3680d 100644--- a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts+++ b/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts@@ -13,6 +13,7 @@ const PULSE_ACCOUNT_PORTAL_URL = "https://cloud.pulserelay.pro/portal";const PURCHASE_RETURN_URL = `${DEV_SERVER_URL}/auth/license-purchase-activate`;const PORTAL_HANDOFF_ID = "cph_checkout_return";const ACTIVATED_BILLING_URL = `${DEV_SERVER_URL}/settings/system/billing/plan?intent=max_monitored_systems&purchase=activated`;+const CANCELLED_BILLING_URL = `${DEV_SERVER_URL}/settings/system/billing/plan?intent=max_monitored_systems&purchase=cancelled`;const FINAL_BILLING_URL = `${DEV_SERVER_URL}/settings/system/billing/plan?intent=max_monitored_systems`;const PURCHASE_RETURN_TOKEN = "prt_signed_checkout_return";@@ -300,4 +301,56 @@ test.describe("Self-hosted upgrade return flow", () => {page.getByText("Pulse Pro activated", { exact: true }),).toBeVisible();});++ test("returns cancelled checkout directly to the owned billing plan route", async ({+ page,+ }, testInfo) => {+ test.skip(+ testInfo.project.name.startsWith("mobile-"),+ "Desktop-only billing continuity",+ );++ const context = page.context();+ await configureBillingFixtures(context, page);++ await context.route(`${PURCHASE_START_URL}**`, async (route) => {+ await route.fulfill({+ status: 303,+ headers: {+ location: `${PULSE_ACCOUNT_PORTAL_URL}?portal_handoff_id=${PORTAL_HANDOFF_ID}`,+ },+ body: "",+ });+ });++ await context.route(`${PULSE_ACCOUNT_PORTAL_URL}**`, async (route) => {+ await route.fulfill({+ status: 200,+ contentType: "text/html",+ body:+ "<!doctype html><html><body>" ++ "<h1>Pulse Account</h1>" ++ "<p>Checkout cancelled. Returning to Pulse Pro.</p>" ++ `<script>setTimeout(function(){window.location.replace(${JSON.stringify(+ CANCELLED_BILLING_URL,+ )});},150);</script>` ++ "</body></html>",+ });+ });++ await openMonitoredSystemUpgradeArrival(page);++ const comparePlansLink = page.getByRole("link", { name: "Compare plans" });+ await comparePlansLink.click();++ await page.goto(+ `${PULSE_ACCOUNT_PORTAL_URL}?portal_handoff_id=${PORTAL_HANDOFF_ID}`,+ {+ waitUntil: "domcontentloaded",+ },+ );++ await expect(page).toHaveURL(CANCELLED_BILLING_URL);+ await expect(page.getByText("Checkout cancelled", { exact: true })).toBeVisible();+ });});diff --git a/tests/integration/tests/56-pulse-account-upgrade-bootstrap.spec.ts b/tests/integration/tests/56-pulse-account-upgrade-bootstrap.spec.tsindex a4a5035d72..1ccec3eaf7 100644--- a/tests/integration/tests/56-pulse-account-upgrade-bootstrap.spec.ts+++ b/tests/integration/tests/56-pulse-account-upgrade-bootstrap.spec.ts@@ -119,4 +119,23 @@ test.describe("Pulse Account upgrade bootstrap", () => {).toBeVisible();await expect(page.getByRole("button", { name: "Buy Annual" }).first()).toBeDisabled();});++ test("blocks a completed secure portal handoff from reopening checkout", async ({ page }, testInfo) => {+ test.skip(+ testInfo.project.name.startsWith("mobile-"),+ "Desktop-only billing continuity",+ );++ await page.goto(+ `${PORTAL_PREVIEW_URL}/?scenario=managed&portal_handoff_id=cph_preview_completed`,+ { waitUntil: "domcontentloaded" },+ );++ await expect(+ page.getByText(+ "This secure upgrade handoff already completed. Return to Pulse Pro billing to review the live plan state.",+ ),+ ).toBeVisible();+ await expect(page.getByRole("button", { name: "Buy Annual" }).first()).toBeDisabled();+ });});