Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Remove app-side Pulse Account URL construction

rcourtman7be2301a9bc3
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 6658a8394f..3bf2ebd3ff 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -475,6 +475,12 @@ checkout intent through the shared commercial API before it starts checkout,
so the portal never trusts browser referrer state, loose `feature` /
`return_url` query parameters, or a Pulse-local handoff URL for self-hosted
purchase completion. 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 into
+Pulse-owned `GET /auth/license-purchase-start`; they must not construct
+Pulse Account portal URLs, `return_url` parameters, or other portal-entry
+contract state in the browser once the server owns that handoff boundary.
+Stripe success now lands on Pulse's public
`GET /auth/license-purchase-activate` bridge, which auto-submits into the
owned POST activation path; the portal must not render a second manual
`Activate in Pulse Pro` step after checkout. Stripe cancel must return
diff --git a/frontend-modern/src/pages/PricingHandoff.tsx b/frontend-modern/src/pages/PricingHandoff.tsx
index 2acbc22a00..3f47e83246 100644
--- a/frontend-modern/src/pages/PricingHandoff.tsx
+++ b/frontend-modern/src/pages/PricingHandoff.tsx
@@ -6,7 +6,6 @@ import {
handoffToExternalPricing,
isExternalPricingDestination,
isSelfHostedPurchaseStartDestination,
- isPulseAccountPortalDestination,
} from '@/utils/pricingHandoff';
export default function PricingHandoff() {
@@ -16,9 +15,7 @@ export default function PricingHandoff() {
const selfHostedPurchaseStartDestination = createMemo(() =>
isSelfHostedPurchaseStartDestination(destination()),
);
- const pulseAccountDestination = createMemo(() =>
- isPulseAccountPortalDestination(destination()) || selfHostedPurchaseStartDestination(),
- );
+ const pulseAccountDestination = createMemo(() => selfHostedPurchaseStartDestination());
const handoffLabel = createMemo(() =>
pulseAccountDestination() ? 'Pulse Account' : 'pricing',
);
diff --git a/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts b/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
index d0892a1baf..632333409c 100644
--- a/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
+++ b/frontend-modern/src/utils/__tests__/pricingHandoff.test.ts
@@ -1,12 +1,10 @@
import { describe, expect, it } from 'vitest';
import {
getSelfHostedPurchaseStartUrl,
- getSelfHostedPurchaseReturnUrl,
getSelfHostedBillingHref,
getSelfHostedBillingPlanIntent,
getSelfHostedBillingPurchaseArrival,
getSelfHostedBillingUsageDetail,
- getPulseAccountPortalUpgradeUrl,
getPricingRouteDestination,
getPublicPricingUrl,
getUpgradeFallbackDestination,
@@ -25,7 +23,6 @@ import {
SELF_HOSTED_PRO_BILLING_USAGE_HREF,
SELF_HOSTED_PRO_BILLING_MONITORED_SYSTEM_INTENT,
SELF_HOSTED_PURCHASE_START_PATH,
- SELF_HOSTED_PURCHASE_RETURN_PATH,
} from '@/utils/pricingHandoff';
describe('pricingHandoff', () => {
@@ -43,12 +40,6 @@ describe('pricingHandoff', () => {
expect(getUpgradeFallbackDestination('relay')).toBe(getSelfHostedPurchaseStartUrl('relay'));
});
- it('derives the canonical self-hosted purchase return URL from the app origin', () => {
- expect(
- getSelfHostedPurchaseReturnUrl('https://pulse.example.com/settings/system/billing/plan'),
- ).toBe(`https://pulse.example.com${SELF_HOSTED_PURCHASE_RETURN_PATH}`);
- });
-
it('returns the canonical public pricing URL when no feature is provided', () => {
expect(getPublicPricingUrl()).toBe(
'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade',
@@ -148,7 +139,7 @@ describe('pricingHandoff', () => {
});
it('detects external pricing destinations', () => {
- expect(isExternalPricingDestination(getPulseAccountPortalUpgradeUrl('relay'))).toBe(true);
+ expect(isExternalPricingDestination(getPublicPricingUrl('relay'))).toBe(true);
expect(isExternalPricingDestination(getSelfHostedPurchaseStartUrl('relay'))).toBe(false);
expect(isExternalPricingDestination('/cloud')).toBe(false);
});
@@ -156,22 +147,6 @@ describe('pricingHandoff', () => {
it('detects the internal self-hosted purchase start destination', () => {
expect(isSelfHostedPurchaseStartDestination(getSelfHostedPurchaseStartUrl('relay'))).toBe(true);
expect(isSelfHostedPurchaseStartDestination(SELF_HOSTED_PURCHASE_START_PATH)).toBe(true);
- expect(isSelfHostedPurchaseStartDestination(getPulseAccountPortalUpgradeUrl('relay'))).toBe(
- false,
- );
- });
-
- it('adds the product return URL to Pulse Account upgrade links when the app origin is known', () => {
- const withOrigin = getPulseAccountPortalUpgradeUrl(
- 'relay',
- undefined,
- 'https://pulse.example.com/settings/system/billing/plan',
- );
- expect(withOrigin).toContain('feature=relay');
- expect(withOrigin).toContain('service=upgrade');
- expect(withOrigin).toContain(
- 'return_url=' +
- encodeURIComponent(`https://pulse.example.com${SELF_HOSTED_PURCHASE_RETURN_PATH}`),
- );
+ expect(isSelfHostedPurchaseStartDestination(getPublicPricingUrl('relay'))).toBe(false);
});
});
diff --git a/frontend-modern/src/utils/pricingHandoff.ts b/frontend-modern/src/utils/pricingHandoff.ts
index 9dfd4b1ea4..530f9397b1 100644
--- a/frontend-modern/src/utils/pricingHandoff.ts
+++ b/frontend-modern/src/utils/pricingHandoff.ts
@@ -6,12 +6,7 @@ import {
const DEFAULT_PUBLIC_PRICING_URL =
'https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade';
-const DEFAULT_PULSE_ACCOUNT_PORTAL_URL = 'https://cloud.pulserelay.pro/portal';
-const PULSE_ACCOUNT_PORTAL_UPGRADE_SERVICE = 'upgrade';
export const SELF_HOSTED_PURCHASE_START_PATH = '/auth/license-purchase-start';
-export const SELF_HOSTED_PURCHASE_RETURN_PATH = '/auth/license-purchase-activate';
-export const PULSE_ACCOUNT_PORTAL_RETURN_URL_QUERY_PARAM = 'return_url';
-export const PULSE_ACCOUNT_PORTAL_RETURN_TOKEN_QUERY_PARAM = 'purchase_return_token';
export const SELF_HOSTED_PRO_BILLING_ROUTE = '/settings/system/billing';
export const SELF_HOSTED_PRO_BILLING_PLAN_ROUTE = `${SELF_HOSTED_PRO_BILLING_ROUTE}/plan`;
@@ -85,33 +80,6 @@ function normalizeFeatureKey(feature: string | null | undefined): string | undef
return normalized ? normalized : undefined;
}
-function resolvePulseProductOrigin(locationHref?: string): string | undefined {
- const candidateHref =
- typeof locationHref === 'string' && locationHref.trim()
- ? locationHref
- : typeof window !== 'undefined'
- ? window.location.href
- : undefined;
- if (!candidateHref) return undefined;
-
- try {
- return new URL(candidateHref).origin;
- } catch {
- return undefined;
- }
-}
-
-export function getSelfHostedPurchaseReturnUrl(locationHref?: string): string | undefined {
- const origin = resolvePulseProductOrigin(locationHref);
- if (!origin) return undefined;
-
- try {
- return new URL(SELF_HOSTED_PURCHASE_RETURN_PATH, origin).toString();
- } catch {
- return undefined;
- }
-}
-
export function getSelfHostedPurchaseStartUrl(
feature?: string | null,
searchParams?: URLSearchParams,
@@ -161,63 +129,6 @@ export function getPublicPricingUrl(feature?: string | null): string {
return url.toString();
}
-export function getPulseAccountPortalUrl(
- options: {
- email?: string | null;
- feature?: string | null;
- locationHref?: string;
- returnUrl?: string | null;
- service?: string | null;
- searchParams?: URLSearchParams;
- } = {},
-): string {
- const url = new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL);
- if (options.searchParams) {
- for (const [key, value] of options.searchParams.entries()) {
- const normalizedValue = value.trim();
- if (normalizedValue) {
- url.searchParams.set(key, normalizedValue);
- }
- }
- }
-
- const normalizedEmail = options.email?.trim();
- if (normalizedEmail) {
- url.searchParams.set('email', normalizedEmail);
- }
-
- const normalizedFeature = normalizeFeatureKey(options.feature);
- if (normalizedFeature) {
- url.searchParams.set('feature', normalizedFeature);
- }
-
- const normalizedService = options.service?.trim();
- if (normalizedService) {
- url.searchParams.set('service', normalizedService);
- }
-
- const normalizedReturnUrl =
- options.returnUrl?.trim() || getSelfHostedPurchaseReturnUrl(options.locationHref);
- if (normalizedReturnUrl) {
- url.searchParams.set(PULSE_ACCOUNT_PORTAL_RETURN_URL_QUERY_PARAM, normalizedReturnUrl);
- }
-
- return url.toString();
-}
-
-export function getPulseAccountPortalUpgradeUrl(
- feature?: string | null,
- searchParams?: URLSearchParams,
- locationHref?: string,
-): string {
- return getPulseAccountPortalUrl({
- feature,
- locationHref,
- searchParams,
- service: PULSE_ACCOUNT_PORTAL_UPGRADE_SERVICE,
- });
-}
-
export function getUpgradeFallbackDestination(feature?: string | null): string {
return getInProductPricingDestination(feature) || getSelfHostedPurchaseStartUrl(feature);
}
@@ -395,22 +306,6 @@ export function isSelfHostedPurchaseStartDestination(destination: string): boole
}
}
-export function isPulseAccountPortalDestination(destination: string): boolean {
- if (!isExternalUpgradeHref(destination)) {
- return false;
- }
-
- try {
- const url = new URL(destination);
- return (
- url.origin === new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL).origin &&
- url.pathname === new URL(DEFAULT_PULSE_ACCOUNT_PORTAL_URL).pathname
- );
- } catch {
- return false;
- }
-}
-
export function handoffToExternalPricing(destination: string): void {
window.location.replace(destination);
}