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.

Make self-hosted checkout return server-owned and recovery-only

rcourtmanb402563ef177
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
index 31a4a5d177..b21d5f3df3 100644
--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
@@ -472,9 +472,9 @@ Accepted as sufficient for RC and GA:
billing route automatically
5. `Pulse Account` must not render a second manual `Activate in Pulse Pro`
step after hosted checkout success; the portal must resolve a verified
- Pulse return template first and let checkout success flow straight into
- Pulse's activation bridge
-5. commercial surfaces are functional but still fragmented outside the owned
+ Pulse return template from a Pulse-owned purchase handoff record first and
+ let checkout success flow straight into Pulse's activation bridge
+6. commercial surfaces are functional but still fragmented outside the owned
checkout-return path
### Candidate lane target
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 19379cc2e2..af66f317ae 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -196,10 +196,11 @@ management, and fleet control surfaces.
or `internal/api/demo_mode_commercial.go` evolve public
`/auth/license-purchase-start`, `/auth/license-purchase-handoff`, or
`/auth/license-purchase-activate`, lifecycle-adjacent setup and fleet
- surfaces may rely on that public-route wiring but must not reinterpret
- purchase-return tokens, activation-bridge form state, or demo-hidden
- commercial route policy as installer credentials, registration state, or
- fleet enrollment authority.
+ surfaces may rely on that public-route wiring but must not reinterpret the
+ commercial-owned `purchase_handoff_id` record, the resolved
+ `activation_url_template`, purchase-return tokens, activation-bridge form
+ state, or demo-hidden commercial route policy as installer credentials,
+ registration state, or fleet enrollment authority.
## Forbidden Paths
@@ -336,6 +337,11 @@ Lifecycle-owned browser shells must also defer any commercial helper reads
until that presentation policy resolves so demo suppression stays fail-closed
during first render instead of racing hidden commercial endpoints from shared
setup or install surfaces.
+That same shared boundary now also owns the one-time checkout-return lookup:
+lifecycle-adjacent surfaces may initiate billing or account handoff through
+shared public routes, but they must never persist, derive, or replay the
+server-owned `purchase_handoff_id` or resolved activation template as lifecycle
+state.
Lifecycle-adjacent storage and fleet surfaces now also depend on one governed
physical-disk history transport. When agent-backed disk telemetry is rendered
through shared drawers or lifecycle-adjacent resource context, those reads
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 17e943111b..cf07234bde 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -518,19 +518,22 @@ hosted-only accounts do not render self-hosted license, refund, privacy, or
self-hosted escalation paths by default, and self-hosted-only accounts do not
front-load an empty hosted-billing block before the real self-hosted jobs.
That same runtime handoff contract now also covers product-originated
-self-hosted upgrade arrivals: `/portal?service=upgrade&purchase_return_token=...`
+self-hosted upgrade arrivals: `/portal?service=upgrade&purchase_handoff_url=...`
may open a portal-owned upgrade job inside `Billing`, but it must not
fabricate broader self-hosted commercial history or reveal
retrieve/refund/privacy panels for a hosted-only account that only arrived
through an upgrade CTA.
That same commercial contract now also includes the self-hosted purchase
return path. Product-originated upgrade handoffs must include a canonical
-signed `purchase_return_token` bound to the originating Pulse instance. The
-portal runtime must derive the originating Pulse origin from the browser
-referrer, resolve a verified `activation_url_template` through Pulse-owned
-`GET /auth/license-purchase-handoff`, and use that verified template as the
-checkout success target instead of trusting loose `feature` or `return_url`
-query parameters. Pulse's public `GET /auth/license-purchase-activate`
+server-owned `purchase_handoff_url` that points at a Pulse-owned handoff
+record. Pulse still binds checkout completion to a signed
+`purchase_return_token`, but that token must stay inside the Pulse-owned
+handoff record and verified activation template rather than leaking into the
+portal arrival URL. The portal runtime must resolve a verified
+`activation_url_template` through Pulse-owned `GET /auth/license-purchase-handoff`
+and use that verified template as the checkout success target instead of
+trusting browser referrer state or loose `feature` / `return_url` query
+parameters. Pulse's public `GET /auth/license-purchase-activate`
callback then serves an auto-submitting bridge into the owned POST activation
path, which redeems the completed checkout through the shared
license/commercial API before returning the browser to the owned billing plan
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index db1057f6b2..0907787d3c 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -64,7 +64,7 @@ agreement, and cloud-specific enforcement rules.
42. `frontend-modern/src/components/Settings/ProLicensePanel.tsx`
43. `frontend-modern/src/components/Settings/ProLicensePlanSection.tsx`
44. `frontend-modern/src/components/Settings/CommercialBillingSections.tsx`
-45. `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`
+45. `frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx`
46. `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`
47. `frontend-modern/src/components/Settings/RelayPairingSection.tsx`
48. `frontend-modern/src/components/Settings/useBillingAdminPanelState.ts`
@@ -109,7 +109,7 @@ agreement, and cloud-specific enforcement rules.
13. Add or change hosted billing-admin presentation through `frontend-modern/src/components/Settings/BillingAdminPanel.tsx`, `frontend-modern/src/components/Settings/BillingAdminOrganizationsTable.tsx`, and `frontend-modern/src/components/Settings/useBillingAdminPanelState.ts`
14. Add or change shared commercial plan/usage presentation through `frontend-modern/src/components/Settings/CommercialBillingSections.tsx` and `frontend-modern/src/utils/commercialBillingModel.ts`
15. Add or change organization billing and usage presentation through `frontend-modern/src/components/Settings/OrganizationBillingPanel.tsx`, `frontend-modern/src/components/Settings/OrganizationBillingLoadingState.tsx`, and `frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts`
-16. Add or change self-hosted Pro activation, trial, and entitlement actions through `frontend-modern/src/components/Settings/ProLicensePanel.tsx`, `frontend-modern/src/components/Settings/ProLicensePlanSection.tsx`, `frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx`, and `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
+16. Add or change self-hosted Pro plan, trial, recovery, and entitlement actions through `frontend-modern/src/components/Settings/ProLicensePanel.tsx`, `frontend-modern/src/components/Settings/ProLicensePlanSection.tsx`, `frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx`, and `frontend-modern/src/components/Settings/useProLicensePanelState.ts`
17. Add or change monitored-system ledger presentation through `frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx`, `frontend-modern/src/components/Commercial/MonitoredSystemDefinitionDisclosure.tsx`, and `frontend-modern/src/utils/monitoredSystemPresentation.ts`
18. Add or change paid relay settings and onboarding presentation through `frontend-modern/src/components/Settings/RelaySettingsPanel.tsx`, `frontend-modern/src/components/Settings/RelayPairingSection.tsx`, `frontend-modern/src/components/Settings/useRelaySettingsPanelState.ts`, `frontend-modern/src/components/Dashboard/RelayOnboardingCard.tsx`, and `frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts`
19. Add or change cloud plan presentation through `frontend-modern/src/pages/CloudPricing.tsx`
@@ -362,14 +362,15 @@ That same helper boundary also owns generic settings-paywall CTA labels such as
shared upgrade presentation owner instead of embedding those CTA strings
locally.
The same shared self-hosted commercial presentation boundary also owns the
-activation-surface copy for `SelfHostedCommercialActivationSection.tsx`,
-including the activation field label/help text, legacy-key exchange notice,
-and self-serve trial panel labels, so that activation wording does not drift
-separately from the rest of the Pro billing surface.
-That same activation boundary also owns the linked legal surface:
-`SelfHostedCommercialActivationSection.tsx` must route its Terms-of-Service
-link through the shipped `TERMS.md` docs asset instead of sending operators to
-GitHub `main`, so the activation trust surface stays version-matched and
+recovery-surface copy for `SelfHostedCommercialRecoverySection.tsx`,
+including the existing-key field label/help text and legacy-key exchange
+notice, while `selfHostedBillingPresentation.ts` owns the first-class plan and
+trial copy that belongs on the primary billing surface. That split prevents
+manual key redemption from drifting back into the main purchase or trial path.
+That same recovery boundary also owns the linked legal surface:
+`SelfHostedCommercialRecoverySection.tsx` must route its Terms-of-Service link
+through the shipped `TERMS.md` docs asset instead of sending operators to
+GitHub `main`, so the recovery trust surface stays version-matched and
available on restricted installs.
Hosted self-serve trial leases are also part of that same contract. A redeemed
hosted trial must carry the canonical Pro capability set and the authoritative
@@ -427,11 +428,14 @@ checkout-session creation, and the purchase return handoff back into Pulse via
public pricing surface inside the runtime, and the authenticated portal shell
must not collapse back into a public-site-only waystation for new-purchase
depth. That handoff now starts through Pulse-owned `GET /auth/license-purchase-start`,
-which mints a signed `purchase_return_token` for the local instance before the
-browser leaves for `Pulse Account`. `Pulse Account` must resolve that signed
-state through Pulse-owned `GET /auth/license-purchase-handoff` before it
-starts checkout, so the portal never trusts loose `feature` or `return_url`
-query parameters for self-hosted purchase completion. Stripe success now lands
+which mints a signed `purchase_return_token` for the local instance, wraps it
+inside a short-lived Pulse-owned purchase handoff record, and sends
+`Pulse Account` an absolute `purchase_handoff_url` before the browser leaves
+for the portal. `Pulse Account` must resolve that server-owned handoff record
+through Pulse-owned `GET /auth/license-purchase-handoff` before it starts
+checkout, so the portal never trusts browser referrer state or loose
+`feature` / `return_url` query parameters for self-hosted purchase completion.
+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. The owned
@@ -621,8 +625,8 @@ license status, usage, and activation state; `Pulse Account` owns the commerce
flow itself.
That same ownership split is explicit in the governed registry as well:
`CommercialBillingSections.tsx` is part of the shared commercial shell/model
-surface, while `SelfHostedCommercialActivationSection.tsx` stays on the
-self-hosted Pro activation surface with `ProLicensePanel.tsx` rather than
+surface, while `SelfHostedCommercialRecoverySection.tsx` stays on the
+self-hosted Pro recovery surface with `ProLicensePanel.tsx` rather than
floating as an unowned settings fragment.
Hosted tenant browser bootstrap is part of that same cloud-paid boundary as
well. After control-plane or magic-link handoff, the browser client must
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 144581e5fa..49913c1c04 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -1638,7 +1638,7 @@
"frontend-modern/src/components/Settings/ProLicensePlanSection.tsx",
"frontend-modern/src/components/Settings/RelayPairingSection.tsx",
"frontend-modern/src/components/Settings/RelaySettingsPanel.tsx",
- "frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx",
+ "frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx",
"frontend-modern/src/components/Settings/useBillingAdminPanelState.ts",
"frontend-modern/src/components/Settings/useOrganizationBillingPanelState.ts",
"frontend-modern/src/components/Settings/useProLicensePanelState.ts",
@@ -2126,7 +2126,7 @@
"frontend-modern/src/components/Settings/MonitoredSystemLedgerPanel.tsx",
"frontend-modern/src/components/Settings/ProLicensePanel.tsx",
"frontend-modern/src/components/Settings/ProLicensePlanSection.tsx",
- "frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx",
+ "frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx",
"frontend-modern/src/components/Settings/useProLicensePanelState.ts"
],
"allow_same_subsystem_tests": false,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 0f263d86ef..db34fd8808 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -165,10 +165,11 @@ querying, and the operator-facing storage health presentation layer.
or `internal/api/demo_mode_commercial.go` evolve
`/auth/license-purchase-start`, `/auth/license-purchase-handoff`, or
`/auth/license-purchase-activate`, storage and recovery may coexist with
- those shared public-route helpers but must not reuse purchase-return tokens,
- activation-bridge callbacks, or demo-hidden commercial route policy as
- recovery identity, restore proof, preview framing, or backup/recovery-local
- transport.
+ those shared public-route helpers but must not reuse the commercial-owned
+ `purchase_handoff_id` record, the resolved `activation_url_template`,
+ purchase-return tokens, activation-bridge callbacks, or demo-hidden
+ commercial route policy as recovery identity, restore proof, preview
+ framing, or backup/recovery-local transport.
## Forbidden Paths
@@ -346,6 +347,11 @@ reads for capability and history-retention truth, but
licensed identity, upgrade prompts, trial urgency, checkout handoff state, or
observed usage counts to remain present once the public-demo contract is
applied.
+That same adjacent commercial boundary also owns one-time checkout-return
+lookup. Storage and recovery may coexist with the shared purchase return routes
+in the app shell, but they must not cache, derive, or replay the
+server-resolved `purchase_handoff_id` or activation template as recovery route
+state, restore evidence, or storage-local navigation context.
Storage- or recovery-adjacent commercial helpers must therefore wait for the
shared presentation policy to resolve before attempting any read that could
otherwise hit a hidden commercial route during bootstrap.
diff --git a/frontend-modern/src/components/Settings/ProLicensePanel.tsx b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
index 71e0270acb..979d3968c7 100644
--- a/frontend-modern/src/components/Settings/ProLicensePanel.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePanel.tsx
@@ -4,7 +4,7 @@ import ShieldCheck from 'lucide-solid/icons/shield-check';
import { MonitoredSystemLedgerPanel } from './MonitoredSystemLedgerPanel';
import { CommercialBillingShell, CommercialSection } from './CommercialBillingSections';
import { ProLicensePlanSection } from './ProLicensePlanSection';
-import { SelfHostedCommercialActivationSection } from './SelfHostedCommercialActivationSection';
+import { SelfHostedCommercialRecoverySection } from './SelfHostedCommercialRecoverySection';
import { useProLicensePanelState } from './useProLicensePanelState';
import { SELF_HOSTED_PRO_BILLING_PRESENTATION } from './selfHostedBillingPresentation';
import { Subtabs } from '@/components/shared/Subtabs';
@@ -63,16 +63,19 @@ export const ProLicensePanel: Component = () => {
commercialPlanModel={state.commercialPlanModel()}
entitlements={state.entitlements()}
formattedFeatures={state.formattedFeatures()}
- grandfatheredPriceNotice={state.grandfatheredPriceNotice()}
- hasLicenseDetails={state.hasLicenseDetails()}
- hasPaidFeatures={state.hasPaidFeatures()}
- loading={state.loading()}
- onReload={() => void state.loadPanelData()}
- showMonitoredSystemUpgradeArrival={state.showMonitoredSystemUpgradeArrival()}
- statusPresentation={state.statusPresentation()}
- trialActivationNotice={state.trialActivationNotice()}
- trialEnded={state.trialEnded()}
- />
+ grandfatheredPriceNotice={state.grandfatheredPriceNotice()}
+ hasLicenseDetails={state.hasLicenseDetails()}
+ hasPaidFeatures={state.hasPaidFeatures()}
+ loading={state.loading()}
+ onReload={() => void state.loadPanelData()}
+ showMonitoredSystemUpgradeArrival={state.showMonitoredSystemUpgradeArrival()}
+ showTrialStart={state.showTrialStart()}
+ startingTrial={state.startingTrial()}
+ statusPresentation={state.statusPresentation()}
+ onStartTrial={() => void state.handleStartTrial()}
+ trialActivationNotice={state.trialActivationNotice()}
+ trialEnded={state.trialEnded()}
+ />
</CommercialSection>
</Show>
@@ -89,19 +92,16 @@ export const ProLicensePanel: Component = () => {
</CommercialSection>
</Show>
- <SelfHostedCommercialActivationSection
+ <SelfHostedCommercialRecoverySection
licenseKey={state.licenseKey()}
activating={state.activating()}
clearing={state.clearing()}
loading={state.loading()}
hasLicenseDetails={state.hasLicenseDetails()}
- showTrialStart={state.showTrialStart()}
- startingTrial={state.startingTrial()}
looksLikeLegacyLicenseKey={state.looksLikeLegacyLicenseKey()}
onLicenseKeyInput={state.setLicenseKey}
onActivate={state.handleActivate}
onClear={state.handleClear}
- onStartTrial={() => void state.handleStartTrial()}
/>
</div>
</CommercialBillingShell>
diff --git a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
index b1903e6ca2..edd060d9dd 100644
--- a/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
+++ b/frontend-modern/src/components/Settings/ProLicensePlanSection.tsx
@@ -35,11 +35,14 @@ interface ProLicensePlanSectionProps {
hasPaidFeatures: boolean;
loading: boolean;
onReload: () => void;
+ onStartTrial: () => void;
statusPresentation: {
badgeClass: string;
label: string;
};
showMonitoredSystemUpgradeArrival: boolean;
+ showTrialStart: boolean;
+ startingTrial: boolean;
trialActivationNotice: Notice | null;
trialEnded: boolean;
}
@@ -84,6 +87,26 @@ export const ProLicensePlanSection: Component<ProLicensePlanSectionProps> = (pro
</div>
)}
</Show>
+ <Show when={props.showTrialStart}>
+ <div class="mb-4 rounded-md border border-border bg-surface-alt p-3">
+ <p class="text-sm font-medium text-base-content">
+ {SELF_HOSTED_PRO_BILLING_PRESENTATION.trialStartTitle}
+ </p>
+ <p class="mt-1 text-xs text-muted">
+ {SELF_HOSTED_PRO_BILLING_PRESENTATION.trialStartBody}
+ </p>
+ <button
+ type="button"
+ class="mt-3 inline-flex min-h-10 sm:min-h-9 items-center justify-center px-4 py-2.5 text-sm font-medium rounded-md bg-emerald-600 text-white hover:bg-emerald-700 transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
+ disabled={props.startingTrial}
+ onClick={props.onStartTrial}
+ >
+ {props.startingTrial
+ ? SELF_HOSTED_PRO_BILLING_PRESENTATION.trialStartPendingActionLabel
+ : SELF_HOSTED_PRO_BILLING_PRESENTATION.trialStartIdleActionLabel}
+ </button>
+ </div>
+ </Show>
<Show when={props.commercialMigrationNotice}>
{(notice) => (
<div class={`mb-4 rounded-md border p-3 text-sm ${notice().tone}`}>
diff --git a/frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx b/frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx
deleted file mode 100644
index 405da8c934..0000000000
--- a/frontend-modern/src/components/Settings/SelfHostedCommercialActivationSection.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { Component, Show } from 'solid-js';
-import { formField, formHelpText, labelClass, controlClass } from '@/components/shared/Form';
-import { SELF_HOSTED_ACTIVATION_PRESENTATION } from '@/utils/licensePresentation';
-import { TERMS_DOC_URL } from '@/utils/docsLinks';
-import { CommercialSection } from './CommercialBillingSections';
-
-interface SelfHostedCommercialActivationSectionProps {
- licenseKey: string;
- activating: boolean;
- clearing: boolean;
- loading: boolean;
- hasLicenseDetails: boolean;
- showTrialStart: boolean;
- startingTrial: boolean;
- looksLikeLegacyLicenseKey: boolean;
- onLicenseKeyInput: (value: string) => void;
- onActivate: () => void;
- onClear: () => void;
- onStartTrial: () => void;
-}
-
-export const SelfHostedCommercialActivationSection: Component<
- SelfHostedCommercialActivationSectionProps
-> = (props) => (
- <CommercialSection
- title={SELF_HOSTED_ACTIVATION_PRESENTATION.sectionTitle}
- description={SELF_HOSTED_ACTIVATION_PRESENTATION.sectionDescription}
- >
- <div class={formField}>
- <label class={labelClass()} for="pulse-pro-license-key">
- {SELF_HOSTED_ACTIVATION_PRESENTATION.fieldLabel}
- </label>
- <textarea
- id="pulse-pro-license-key"
- class={controlClass('min-h-[120px] font-mono')}
- placeholder={SELF_HOSTED_ACTIVATION_PRESENTATION.fieldPlaceholder}
- value={props.licenseKey}
- onInput={(event) => props.onLicenseKeyInput(event.currentTarget.value)}
- />
- <p class={formHelpText}>
- {SELF_HOSTED_ACTIVATION_PRESENTATION.helpTextBeforeTerms}{' '}
- <a
- href={TERMS_DOC_URL}
- target="_blank"
- rel="noopener noreferrer"
- class="inline-flex min-h-10 sm:min-h-9 items-center rounded px-1 text-blue-600 hover:underline"
- >
- {SELF_HOSTED_ACTIVATION_PRESENTATION.termsLabel}
- </a>
- {SELF_HOSTED_ACTIVATION_PRESENTATION.helpTextAfterTerms}
- </p>
- <Show when={props.looksLikeLegacyLicenseKey}>
- <div class="mt-3 rounded-md border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900 p-3 text-sm text-amber-800 dark:text-amber-200">
- <p class="font-medium">{SELF_HOSTED_ACTIVATION_PRESENTATION.legacyNotice.title}</p>
- <p class="text-xs text-amber-700 dark:text-amber-300 mt-1">
- {SELF_HOSTED_ACTIVATION_PRESENTATION.legacyNotice.body}
- </p>
- </div>
- </Show>
- </div>
-
- <div class="flex flex-wrap items-center gap-2">
- <button
- class="min-h-10 sm:min-h-9 px-4 py-2.5 text-sm font-medium rounded-md bg-blue-600 text-white hover:bg-blue-700 transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
- onClick={props.onActivate}
- disabled={props.activating || !props.licenseKey.trim()}
- >
- {props.activating
- ? SELF_HOSTED_ACTIVATION_PRESENTATION.activatePendingLabel
- : SELF_HOSTED_ACTIVATION_PRESENTATION.activateIdleLabel}
- </button>
- <button
- class="min-h-10 sm:min-h-9 px-4 py-2.5 text-sm font-medium rounded-md border border-border text-base-content hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
- onClick={props.onClear}
- disabled={props.clearing || props.loading || !props.hasLicenseDetails}
- >
- {props.clearing
- ? SELF_HOSTED_ACTIVATION_PRESENTATION.clearPendingLabel
- : SELF_HOSTED_ACTIVATION_PRESENTATION.clearIdleLabel}
- </button>
- </div>
-
- <Show when={props.showTrialStart}>
- <div class="rounded-md border border-border bg-surface-alt p-3">
- <p class="text-sm font-medium text-base-content">
- {SELF_HOSTED_ACTIVATION_PRESENTATION.trial.title}
- </p>
- <p class="text-xs text-muted mt-1">{SELF_HOSTED_ACTIVATION_PRESENTATION.trial.body}</p>
- <button
- type="button"
- class="mt-3 inline-flex min-h-10 sm:min-h-9 items-center justify-center px-4 py-2.5 text-sm font-medium rounded-md bg-emerald-600 text-white hover:bg-emerald-700 transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
- disabled={props.startingTrial}
- onClick={props.onStartTrial}
- >
- {props.startingTrial
- ? SELF_HOSTED_ACTIVATION_PRESENTATION.trial.pendingActionLabel
- : SELF_HOSTED_ACTIVATION_PRESENTATION.trial.idleActionLabel}
- </button>
- </div>
- </Show>
- </CommercialSection>
-);
diff --git a/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx b/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx
new file mode 100644
index 0000000000..2856429916
--- /dev/null
+++ b/frontend-modern/src/components/Settings/SelfHostedCommercialRecoverySection.tsx
@@ -0,0 +1,100 @@
+import { Component, Show } from 'solid-js';
+import { formField, formHelpText, labelClass, controlClass } from '@/components/shared/Form';
+import { SELF_HOSTED_RECOVERY_PRESENTATION } from '@/utils/licensePresentation';
+import { TERMS_DOC_URL } from '@/utils/docsLinks';
+import { CommercialSection } from './CommercialBillingSections';
+import { SELF_HOSTED_PRO_BILLING_PRESENTATION } from './selfHostedBillingPresentation';
+
+interface SelfHostedCommercialRecoverySectionProps {
+ licenseKey: string;
+ activating: boolean;
+ clearing: boolean;
+ loading: boolean;
+ hasLicenseDetails: boolean;
+ looksLikeLegacyLicenseKey: boolean;
+ onLicenseKeyInput: (value: string) => void;
+ onActivate: () => void;
+ onClear: () => void;
+}
+
+export const SelfHostedCommercialRecoverySection: Component<
+ SelfHostedCommercialRecoverySectionProps
+> = (props) => (
+ <CommercialSection
+ title={SELF_HOSTED_PRO_BILLING_PRESENTATION.recoverySectionTitle}
+ description={SELF_HOSTED_PRO_BILLING_PRESENTATION.recoverySectionDescription}
+ >
+ <details class="group rounded-md border border-border bg-surface-alt p-4">
+ <summary class="cursor-pointer list-none">
+ <div class="flex items-start justify-between gap-3">
+ <div>
+ <p class="text-sm font-medium text-base-content">
+ {SELF_HOSTED_RECOVERY_PRESENTATION.disclosureLabel}
+ </p>
+ <p class="mt-1 text-xs text-muted">
+ {SELF_HOSTED_RECOVERY_PRESENTATION.disclosureDescription}
+ </p>
+ </div>
+ <span class="text-xs font-medium text-primary group-open:hidden">Show</span>
+ <span class="hidden text-xs font-medium text-primary group-open:inline">Hide</span>
+ </div>
+ </summary>
+
+ <div class="mt-4 space-y-4">
+ <div class={formField}>
+ <label class={labelClass()} for="pulse-pro-license-key">
+ {SELF_HOSTED_RECOVERY_PRESENTATION.fieldLabel}
+ </label>
+ <textarea
+ id="pulse-pro-license-key"
+ class={controlClass('min-h-[120px] font-mono')}
+ placeholder={SELF_HOSTED_RECOVERY_PRESENTATION.fieldPlaceholder}
+ value={props.licenseKey}
+ onInput={(event) => props.onLicenseKeyInput(event.currentTarget.value)}
+ />
+ <p class={formHelpText}>
+ {SELF_HOSTED_RECOVERY_PRESENTATION.helpTextBeforeTerms}{' '}
+ <a
+ href={TERMS_DOC_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="inline-flex min-h-10 sm:min-h-9 items-center rounded px-1 text-blue-600 hover:underline"
+ >
+ {SELF_HOSTED_RECOVERY_PRESENTATION.termsLabel}
+ </a>
+ {SELF_HOSTED_RECOVERY_PRESENTATION.helpTextAfterTerms}
+ </p>
+ <Show when={props.looksLikeLegacyLicenseKey}>
+ <div class="mt-3 rounded-md border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900 p-3 text-sm text-amber-800 dark:text-amber-200">
+ <p class="font-medium">{SELF_HOSTED_RECOVERY_PRESENTATION.legacyNotice.title}</p>
+ <p class="text-xs text-amber-700 dark:text-amber-300 mt-1">
+ {SELF_HOSTED_RECOVERY_PRESENTATION.legacyNotice.body}
+ </p>
+ </div>
+ </Show>
+ </div>
+
+ <div class="flex flex-wrap items-center gap-2">
+ <button
+ class="min-h-10 sm:min-h-9 px-4 py-2.5 text-sm font-medium rounded-md bg-blue-600 text-white hover:bg-blue-700 transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
+ onClick={props.onActivate}
+ disabled={props.activating || !props.licenseKey.trim()}
+ >
+ {props.activating
+ ? SELF_HOSTED_RECOVERY_PRESENTATION.activatePendingLabel
+ : SELF_HOSTED_RECOVERY_PRESENTATION.activateIdleLabel}
+ </button>
+ <button
+ class="min-h-10 sm:min-h-9 px-4 py-2.5 text-sm font-medium rounded-md border border-border text-base-content hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed"
+ onClick={props.onClear}
+ disabled={props.clearing || props.loading || !props.hasLicenseDetails}
+ >
+ {props.clearing
+ ? SELF_HOSTED_RECOVERY_PRESENTATION.clearPendingLabel
+ : SELF_HOSTED_RECOVERY_PRESENTATION.clearIdleLabel}
+ </button>
+ </div>
+ </div>
+ </details>
+ </CommercialSection>
+);
diff --git a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
index 09a4f5462f..15c4b458b7 100644
--- a/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ProLicensePanel.test.tsx
@@ -7,7 +7,7 @@ import { ProLicensePanel } from '../ProLicensePanel';
import proLicensePanelSource from '../ProLicensePanel.tsx?raw';
import proLicensePanelStateSource from '../useProLicensePanelState.ts?raw';
import proLicensePlanSectionSource from '../ProLicensePlanSection.tsx?raw';
-import selfHostedCommercialActivationSectionSource from '../SelfHostedCommercialActivationSection.tsx?raw';
+import selfHostedCommercialRecoverySectionSource from '../SelfHostedCommercialRecoverySection.tsx?raw';
import {
getPublicPricingUrl,
getSelfHostedPurchaseStartUrl,
@@ -332,7 +332,9 @@ describe('ProLicensePanel', () => {
it('shows migration guidance when the pasted key looks like a legacy v5 license', async () => {
renderPanel();
- fireEvent.input(screen.getByLabelText(/license \/ activation key/i), {
+ fireEvent.click(screen.getByText('Redeem existing key'));
+
+ fireEvent.input(screen.getByLabelText(/pulse pro key/i), {
target: { value: 'header.payload.signature' },
});
@@ -549,7 +551,7 @@ describe('ProLicensePanel', () => {
it('keeps Pro license split into shell, runtime, and plan owners', () => {
expect(proLicensePanelSource).toContain('./useProLicensePanelState');
expect(proLicensePanelSource).toContain('./ProLicensePlanSection');
- expect(proLicensePanelSource).toContain('SelfHostedCommercialActivationSection');
+ expect(proLicensePanelSource).toContain('SelfHostedCommercialRecoverySection');
expect(proLicensePanelSource).toContain('SELF_HOSTED_PRO_BILLING_PRESENTATION');
expect(proLicensePanelSource).toContain("value={state.activeSection()}");
expect(proLicensePanelSource).toContain('<Subtabs');
@@ -566,10 +568,13 @@ describe('ProLicensePanel', () => {
expect(proLicensePanelStateSource).toContain('buildSelfHostedCommercialPlanModel');
expect(proLicensePanelStateSource).toContain('runStartProTrialAction({');
expect(proLicensePanelStateSource).not.toContain('startProTrial()');
+ expect(proLicensePanelStateSource).toContain("'A Pulse Pro key is required'");
expect(proLicensePlanSectionSource).toContain('getLicenseStatusLoadingState');
expect(proLicensePlanSectionSource).toContain('getNoActiveProLicenseState');
expect(proLicensePlanSectionSource).toContain('getTrialEndedProLicenseNotice');
expect(proLicensePlanSectionSource).toContain('getInactiveProUpsellNotice');
+ expect(proLicensePlanSectionSource).toContain('trialStartTitle');
+ expect(proLicensePlanSectionSource).toContain('trialStartIdleActionLabel');
expect(proLicensePlanSectionSource).not.toContain(
'const trialEndedNotice = getTrialEndedProLicenseNotice();',
);
@@ -590,15 +595,17 @@ describe('ProLicensePanel', () => {
);
expect(proLicensePlanSectionSource).not.toContain('Your Pro trial has ended');
expect(proLicensePlanSectionSource).not.toContain('Unlock Pulse Patrol, alert analysis, auto-fix, and more.');
- expect(selfHostedCommercialActivationSectionSource).toContain(
- 'SELF_HOSTED_ACTIVATION_PRESENTATION',
+ expect(selfHostedCommercialRecoverySectionSource).toContain(
+ 'SELF_HOSTED_RECOVERY_PRESENTATION',
);
- expect(selfHostedCommercialActivationSectionSource).toContain('TERMS_DOC_URL');
- expect(selfHostedCommercialActivationSectionSource).not.toContain(
+ expect(selfHostedCommercialRecoverySectionSource).toContain('TERMS_DOC_URL');
+ expect(selfHostedCommercialRecoverySectionSource).toContain('disclosureLabel');
+ expect(selfHostedCommercialRecoverySectionSource).toContain('recoverySectionTitle');
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain(
'https://github.com/rcourtman/Pulse/blob/main/TERMS.md',
);
- expect(selfHostedCommercialActivationSectionSource).not.toContain('Start 14-day Pro Trial');
- expect(selfHostedCommercialActivationSectionSource).not.toContain(
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain('Start 14-day Pro Trial');
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain(
'Legacy v5 license detected',
);
expect(proLicensePanelSource).toContain('id={SELF_HOSTED_PRO_BILLING_PLAN_SECTION_ID}');
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 7710ff429b..e889113a3e 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -96,7 +96,7 @@ import proLicensePanelSource from '../ProLicensePanel.tsx?raw';
import monitoredSystemDefinitionDisclosureSource from '@/components/Commercial/MonitoredSystemDefinitionDisclosure.tsx?raw';
import proLicensePlanSectionSource from '../ProLicensePlanSection.tsx?raw';
import commercialBillingSectionsSource from '../CommercialBillingSections.tsx?raw';
-import selfHostedCommercialActivationSectionSource from '../SelfHostedCommercialActivationSection.tsx?raw';
+import selfHostedCommercialRecoverySectionSource from '../SelfHostedCommercialRecoverySection.tsx?raw';
import commercialBillingModelSource from '@/utils/commercialBillingModel.ts?raw';
import monitoredSystemPresentationSource from '@/utils/monitoredSystemPresentation.ts?raw';
import relaySettingsPanelStateSource from '../useRelaySettingsPanelState.ts?raw';
@@ -551,7 +551,7 @@ describe('Settings architecture guardrails', () => {
expect(proLicensePanelSource).toContain('./CommercialBillingSections');
expect(proLicensePanelSource).toContain('./useProLicensePanelState');
expect(proLicensePanelSource).toContain('./ProLicensePlanSection');
- expect(proLicensePanelSource).toContain('SelfHostedCommercialActivationSection');
+ expect(proLicensePanelSource).toContain('SelfHostedCommercialRecoverySection');
expect(proLicensePanelSource).toContain('MonitoredSystemLedgerPanel');
expect(proLicensePanelSource).toContain('CommercialBillingShell');
expect(proLicensePanelSource).toContain('CommercialSection');
@@ -609,12 +609,12 @@ describe('Settings architecture guardrails', () => {
expect(monitoredSystemPresentationSource).toContain(
'export function getMonitoredSystemDisclosureToggleLabel',
);
- expect(selfHostedCommercialActivationSectionSource).toContain('@/utils/licensePresentation');
- expect(selfHostedCommercialActivationSectionSource).toContain(
- 'SELF_HOSTED_ACTIVATION_PRESENTATION',
+ expect(selfHostedCommercialRecoverySectionSource).toContain('@/utils/licensePresentation');
+ expect(selfHostedCommercialRecoverySectionSource).toContain(
+ 'SELF_HOSTED_RECOVERY_PRESENTATION',
);
- expect(selfHostedCommercialActivationSectionSource).not.toContain('License / Activation Key');
- expect(selfHostedCommercialActivationSectionSource).not.toContain('Start 14-day Pro Trial');
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain('License / Activation Key');
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain('Start 14-day Pro Trial');
expect(organizationBillingPanelSource).toContain('./CommercialBillingSections');
expect(organizationBillingPanelSource).toContain('./OrganizationBillingLoadingState');
expect(organizationBillingPanelSource).toContain('./useOrganizationBillingPanelState');
@@ -1353,8 +1353,8 @@ describe('Settings architecture guardrails', () => {
expect(securityOverviewPanelSource).toContain("label: 'Open security guide'");
expect(securityOverviewPanelSource).toContain("tone={hardeningTone()}");
expect(securityOverviewPanelSource).toContain("criticalHardeningActions() > 0 ? 'danger' : 'info'");
- expect(selfHostedCommercialActivationSectionSource).toContain('@/utils/docsLinks');
- expect(selfHostedCommercialActivationSectionSource).toContain('TERMS_DOC_URL');
+ expect(selfHostedCommercialRecoverySectionSource).toContain('@/utils/docsLinks');
+ expect(selfHostedCommercialRecoverySectionSource).toContain('TERMS_DOC_URL');
expect(apiTokenManagerModelSource).toContain('@/utils/docsLinks');
expect(apiTokenManagerModelSource).toContain('API_TOKEN_SCOPES_DOC_URL');
expect(recoverySettingsPanelSource).toContain('@/utils/systemSettingsPresentation');
diff --git a/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts b/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
index 72ff458ba8..ff755aa392 100644
--- a/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
+++ b/frontend-modern/src/components/Settings/selfHostedBillingPresentation.ts
@@ -13,6 +13,12 @@ export interface SelfHostedProBillingPresentation {
monitoredSystemUpgradeArrivalTitle: string;
monitoredSystemUpgradeArrivalBody: string;
monitoredSystemUpgradeArrivalActionLabel: string;
+ trialStartTitle: string;
+ trialStartBody: string;
+ trialStartIdleActionLabel: string;
+ trialStartPendingActionLabel: string;
+ recoverySectionTitle: string;
+ recoverySectionDescription: string;
}
export const SELF_HOSTED_PRO_BILLING_PRESENTATION: SelfHostedProBillingPresentation = {
@@ -33,4 +39,11 @@ export const SELF_HOSTED_PRO_BILLING_PRESENTATION: SelfHostedProBillingPresentat
monitoredSystemUpgradeArrivalBody:
'Open Pulse Account to compare self-hosted plans, complete checkout, and return here with Pulse Pro activated automatically.',
monitoredSystemUpgradeArrivalActionLabel: 'Compare plans',
+ trialStartTitle: 'Try Pro for free',
+ trialStartBody: 'Start a 14-day Pro trial for this organization.',
+ trialStartIdleActionLabel: 'Start 14-day Pro Trial',
+ trialStartPendingActionLabel: 'Starting...',
+ recoverySectionTitle: 'Recovery',
+ recoverySectionDescription:
+ 'Use recovery tools only when you already have a Pulse Pro key or need to remove a local key from this instance.',
};
diff --git a/frontend-modern/src/components/Settings/useProLicensePanelState.ts b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
index 7f5e2e9790..ba51f11be4 100644
--- a/frontend-modern/src/components/Settings/useProLicensePanelState.ts
+++ b/frontend-modern/src/components/Settings/useProLicensePanelState.ts
@@ -258,7 +258,7 @@ export function useProLicensePanelState() {
const handleActivate = async () => {
const trimmedKey = licenseKey().trim();
if (!trimmedKey) {
- notificationStore.error('A license key or activation key is required');
+ notificationStore.error('A Pulse Pro key is required');
return;
}
setActivating(true);
diff --git a/frontend-modern/src/utils/__tests__/docsLinks.test.ts b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
index e75b82c5fa..0f7f2b438a 100644
--- a/frontend-modern/src/utils/__tests__/docsLinks.test.ts
+++ b/frontend-modern/src/utils/__tests__/docsLinks.test.ts
@@ -17,7 +17,7 @@ import apiAccessPanelSource from '@/components/Settings/APIAccessPanel.tsx?raw';
import aiRuntimeControlsSectionSource from '@/components/Settings/AIRuntimeControlsSection.tsx?raw';
import apiTokenManagerModelSource from '@/components/Settings/apiTokenManagerModel.ts?raw';
import securityOverviewPanelSource from '@/components/Settings/SecurityOverviewPanel.tsx?raw';
-import selfHostedCommercialActivationSectionSource from '@/components/Settings/SelfHostedCommercialActivationSection.tsx?raw';
+import selfHostedCommercialRecoverySectionSource from '@/components/Settings/SelfHostedCommercialRecoverySection.tsx?raw';
import securityWarningSource from '@/components/SecurityWarning.tsx?raw';
const __filename = fileURLToPath(import.meta.url);
@@ -109,8 +109,8 @@ describe('docsLinks', () => {
expect(aiRuntimeControlsSectionSource).not.toContain(
'https://github.com/rcourtman/Pulse/blob/main/TERMS.md',
);
- expect(selfHostedCommercialActivationSectionSource).toContain('TERMS_DOC_URL');
- expect(selfHostedCommercialActivationSectionSource).not.toContain(
+ expect(selfHostedCommercialRecoverySectionSource).toContain('TERMS_DOC_URL');
+ expect(selfHostedCommercialRecoverySectionSource).not.toContain(
'https://github.com/rcourtman/Pulse/blob/main/TERMS.md',
);
});
diff --git a/frontend-modern/src/utils/__tests__/licensePresentation.test.ts b/frontend-modern/src/utils/__tests__/licensePresentation.test.ts
index 17b7c4bfed..7bb7819608 100644
--- a/frontend-modern/src/utils/__tests__/licensePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/licensePresentation.test.ts
@@ -18,7 +18,7 @@ import {
getTrialEndedProLicenseNotice,
getTrialActivationNotice,
isDisplayableLicenseFeature,
- SELF_HOSTED_ACTIVATION_PRESENTATION,
+ SELF_HOSTED_RECOVERY_PRESENTATION,
} from '@/utils/licensePresentation';
import { SELF_HOSTED_PRO_BILLING_PRESENTATION } from '@/components/Settings/selfHostedBillingPresentation';
@@ -49,18 +49,14 @@ describe('licensePresentation', () => {
body: 'Unlock Pulse Patrol, alert analysis, auto-fix, and more.',
actionLabel: 'View Pro plans',
});
- expect(SELF_HOSTED_ACTIVATION_PRESENTATION).toMatchObject({
- sectionTitle: 'Activation',
- fieldLabel: 'License / Activation Key',
+ expect(SELF_HOSTED_RECOVERY_PRESENTATION).toMatchObject({
+ disclosureLabel: 'Redeem existing key',
+ fieldLabel: 'Pulse Pro Key',
activateIdleLabel: 'Activate License',
clearIdleLabel: 'Clear License',
legacyNotice: {
title: 'Legacy v5 license detected',
},
- trial: {
- title: 'Try Pro for free',
- idleActionLabel: 'Start 14-day Pro Trial',
- },
});
expect(SELF_HOSTED_PRO_BILLING_PRESENTATION).toEqual({
shellTitle: 'Pulse Pro',
@@ -77,6 +73,17 @@ describe('licensePresentation', () => {
planSectionDescription:
'Review your active plan, expiry, included limits, and paid capabilities.',
usageSectionTitle: 'Usage',
+ monitoredSystemUpgradeArrivalTitle: 'Need a higher monitored-system cap?',
+ monitoredSystemUpgradeArrivalBody:
+ 'Open Pulse Account to compare self-hosted plans, complete checkout, and return here with Pulse Pro activated automatically.',
+ monitoredSystemUpgradeArrivalActionLabel: 'Compare plans',
+ trialStartTitle: 'Try Pro for free',
+ trialStartBody: 'Start a 14-day Pro trial for this organization.',
+ trialStartIdleActionLabel: 'Start 14-day Pro Trial',
+ trialStartPendingActionLabel: 'Starting...',
+ recoverySectionTitle: 'Recovery',
+ recoverySectionDescription:
+ 'Use recovery tools only when you already have a Pulse Pro key or need to remove a local key from this instance.',
});
});
diff --git a/frontend-modern/src/utils/licensePresentation.ts b/frontend-modern/src/utils/licensePresentation.ts
index a11495aa44..0373d58fbc 100644
--- a/frontend-modern/src/utils/licensePresentation.ts
+++ b/frontend-modern/src/utils/licensePresentation.ts
@@ -79,16 +79,9 @@ export interface SelfHostedActivationNoticeCopy {
body: string;
}
-export interface SelfHostedActivationTrialCopy {
- title: string;
- body: string;
- idleActionLabel: string;
- pendingActionLabel: string;
-}
-
-export interface SelfHostedActivationPresentation {
- sectionTitle: string;
- sectionDescription: string;
+export interface SelfHostedRecoveryPresentation {
+ disclosureLabel: string;
+ disclosureDescription: string;
fieldLabel: string;
fieldPlaceholder: string;
helpTextBeforeTerms: string;
@@ -99,7 +92,6 @@ export interface SelfHostedActivationPresentation {
clearIdleLabel: string;
clearPendingLabel: string;
legacyNotice: SelfHostedActivationNoticeCopy;
- trial: SelfHostedActivationTrialCopy;
}
const GRANDFATHERED_V5_PLAN_LABELS: Record<string, string> = {
@@ -336,11 +328,11 @@ export const getInactiveProUpsellNotice = (): LicenseActionNotice => ({
actionLabel: 'View Pro plans',
});
-export const SELF_HOSTED_ACTIVATION_PRESENTATION: SelfHostedActivationPresentation = {
- sectionTitle: 'Activation',
- sectionDescription:
- 'Activate, clear, or start a trial for the self-hosted Pulse Pro entitlement that controls paid features on this instance.',
- fieldLabel: 'License / Activation Key',
+export const SELF_HOSTED_RECOVERY_PRESENTATION: SelfHostedRecoveryPresentation = {
+ disclosureLabel: 'Redeem existing key',
+ disclosureDescription:
+ 'Use this only if you already have a Pulse Pro key or need to recover a legacy self-hosted purchase on this instance.',
+ fieldLabel: 'Pulse Pro Key',
fieldPlaceholder: 'Paste your license key or activation key',
helpTextBeforeTerms:
'Paste the Pulse v6 activation key shown on the hosted checkout success page. A backup copy is also sent by email, but the hosted success page is the primary handoff. You can also paste a legacy Pulse v5 Pro/Lifetime license key and Pulse will exchange it automatically during activation when migration is available. By activating a license, you agree to the',
@@ -354,12 +346,6 @@ export const SELF_HOSTED_ACTIVATION_PRESENTATION: SelfHostedActivationPresentati
title: 'Legacy v5 license detected',
body: 'Pulse will try to exchange this key into the v6 activation model automatically. If the exchange cannot complete immediately, retry from this panel or use the self-serve retrieval flow to get the current v6 activation key.',
},
- trial: {
- title: 'Try Pro for free',
- body: 'Start a 14-day Pro trial for this organization.',
- idleActionLabel: 'Start 14-day Pro Trial',
- pendingActionLabel: 'Starting...',
- },
};
export const getOrganizationBillingLicenseStatusLabel = (
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index e1ffe46f34..61724813ea 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -4888,6 +4888,129 @@ func TestContract_SelfHostedPurchaseHandoffJSONSnapshot(t *testing.T) {
handler := createTestHandler(t)
handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
+ req := httptest.NewRequest(
+ http.MethodGet,
+ "https://pulse.example.com"+licensePurchaseStartPath+
+ "?feature=max_monitored_systems&utm_content=legacy-bookmark",
+ nil,
+ )
+ rec := httptest.NewRecorder()
+
+ handler.HandleCheckoutStart(rec, req)
+
+ if rec.Code != http.StatusSeeOther {
+ t.Fatalf("status=%d, want %d: %s", rec.Code, http.StatusSeeOther, rec.Body.String())
+ }
+
+ location := rec.Header().Get("Location")
+ redirectURL, err := url.Parse(location)
+ if err != nil {
+ t.Fatalf("parse redirect location: %v", err)
+ }
+ if redirectURL.Scheme != "https" || redirectURL.Host != "cloud.pulserelay.pro" || redirectURL.Path != "/portal" {
+ t.Fatalf("redirect location=%q, want Pulse Account portal", location)
+ }
+ if got := redirectURL.Query().Get("feature"); got != "" {
+ t.Fatalf("feature=%q, want omitted portal query", got)
+ }
+ if got := redirectURL.Query().Get("return_url"); got != "" {
+ t.Fatalf("return_url=%q, want omitted portal query", got)
+ }
+ if got := redirectURL.Query().Get("purchase_return_token"); got != "" {
+ t.Fatalf("purchase_return_token=%q, want omitted portal query", got)
+ }
+
+ handoffURL := strings.TrimSpace(redirectURL.Query().Get("purchase_handoff_url"))
+ if handoffURL == "" {
+ t.Fatal("expected purchase_handoff_url in Pulse Account redirect")
+ }
+
+ handoffReq := httptest.NewRequest(http.MethodGet, handoffURL, nil)
+ handoffRec := httptest.NewRecorder()
+ handler.HandleCheckoutHandoff(handoffRec, handoffReq)
+
+ if handoffRec.Code != http.StatusOK {
+ t.Fatalf("handoff status=%d, want %d: %s", handoffRec.Code, http.StatusOK, handoffRec.Body.String())
+ }
+
+ var handoffPayload struct {
+ Feature string `json:"feature"`
+ ActivationURLTemplate string `json:"activation_url_template"`
+ }
+ if err := json.NewDecoder(handoffRec.Body).Decode(&handoffPayload); err != nil {
+ t.Fatalf("decode handoff payload: %v", err)
+ }
+
+ handoffURLParsed, err := url.Parse(handoffURL)
+ if err != nil {
+ t.Fatalf("parse purchase_handoff_url: %v", err)
+ }
+ handoffID := strings.TrimSpace(handoffURLParsed.Query().Get(licensePurchaseHandoffIDField))
+ if handoffID == "" {
+ t.Fatal("expected purchase_handoff_id in purchase_handoff_url")
+ }
+ handoffQuery := handoffURLParsed.Query()
+ handoffQuery.Set(licensePurchaseHandoffIDField, "placeholder")
+ handoffURLParsed.RawQuery = handoffQuery.Encode()
+
+ activationURL, err := url.Parse(handoffPayload.ActivationURLTemplate)
+ if err != nil {
+ t.Fatalf("parse activation_url_template: %v", err)
+ }
+ returnToken := strings.TrimSpace(activationURL.Query().Get(licensePurchaseReturnTokenField))
+ if returnToken == "" {
+ t.Fatal("expected signed purchase_return_token in activation_url_template")
+ }
+ signingKey, err := handler.purchaseReturnSigningKey()
+ if err != nil {
+ t.Fatalf("purchaseReturnSigningKey: %v", err)
+ }
+ claims, err := verifyPurchaseReturnTokenFromLicensing(returnToken, signingKey, "pulse.example.com", time.Now().UTC())
+ if err != nil {
+ t.Fatalf("verifyPurchaseReturnTokenFromLicensing: %v", err)
+ }
+ if claims.Feature != "max_monitored_systems" {
+ t.Fatalf("claims.Feature=%q, want max_monitored_systems", claims.Feature)
+ }
+ if claims.OrgID != "default" {
+ t.Fatalf("claims.OrgID=%q, want default", claims.OrgID)
+ }
+ activationQuery := activationURL.Query()
+ activationQuery.Set(licensePurchaseReturnTokenField, "placeholder")
+ activationURL.RawQuery = activationQuery.Encode()
+
+ got, err := json.Marshal(struct {
+ PortalService string `json:"portal_service"`
+ PortalUtmContent string `json:"portal_utm_content"`
+ PortalHandoffURL string `json:"portal_handoff_url"`
+ HandoffFeature string `json:"handoff_feature"`
+ ActivationURLTemplate string `json:"activation_url_template"`
+ }{
+ PortalService: redirectURL.Query().Get("service"),
+ PortalUtmContent: redirectURL.Query().Get("utm_content"),
+ PortalHandoffURL: handoffURLParsed.String(),
+ HandoffFeature: handoffPayload.Feature,
+ ActivationURLTemplate: activationURL.String(),
+ })
+ if err != nil {
+ t.Fatalf("marshal normalized handoff snapshot: %v", err)
+ }
+
+ const want = `{
+ "portal_service":"upgrade",
+ "portal_utm_content":"legacy-bookmark",
+ "portal_handoff_url":"https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=placeholder",
+ "handoff_feature":"max_monitored_systems",
+ "activation_url_template":"https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=placeholder\u0026session_id=%7BCHECKOUT_SESSION_ID%7D"
+ }`
+
+ assertJSONSnapshot(t, got, want)
+}
+
+func TestContract_SelfHostedPurchaseLegacyHandoffJSONSnapshot(t *testing.T) {
+ handler := createTestHandler(t)
+ handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
+
returnToken := issuePurchaseReturnToken(t, handler, "default", "max_monitored_systems")
req := httptest.NewRequest(
http.MethodGet,
diff --git a/internal/api/license_handlers_test.go b/internal/api/license_handlers_test.go
index 4dbe7cd243..d90800e554 100644
--- a/internal/api/license_handlers_test.go
+++ b/internal/api/license_handlers_test.go
@@ -729,12 +729,53 @@ func TestHandleCheckoutStart_RedirectsToPulseAccountWithSignedReturnState(t *tes
if got := redirectURL.Query().Get("return_url"); got != "" {
t.Fatalf("return_url = %q, want omitted portal query", got)
}
+ handoffURL := redirectURL.Query().Get("purchase_handoff_url")
+ if strings.TrimSpace(handoffURL) == "" {
+ t.Fatal("expected purchase_handoff_url in redirect")
+ }
if got := redirectURL.Query().Get("utm_content"); got != "legacy-bookmark" {
t.Fatalf("utm_content = %q, want preserved query value", got)
}
- returnToken := redirectURL.Query().Get("purchase_return_token")
+ if got := redirectURL.Query().Get("purchase_return_token"); got != "" {
+ t.Fatalf("purchase_return_token = %q, want omitted portal query", got)
+ }
+
+ handoffURLParsed, err := url.Parse(handoffURL)
+ if err != nil {
+ t.Fatalf("parse purchase_handoff_url: %v", err)
+ }
+ if handoffURLParsed.Scheme != "https" || handoffURLParsed.Host != "pulse.example.com" || handoffURLParsed.Path != licensePurchaseHandoffPath {
+ t.Fatalf("purchase_handoff_url = %q, want Pulse handoff endpoint", handoffURL)
+ }
+ handoffID := handoffURLParsed.Query().Get(licensePurchaseHandoffIDField)
+ if strings.TrimSpace(handoffID) == "" {
+ t.Fatal("expected purchase_handoff_id in purchase_handoff_url")
+ }
+
+ handoffReq := httptest.NewRequest(http.MethodGet, handoffURL, nil)
+ handoffRec := httptest.NewRecorder()
+ handler.HandleCheckoutHandoff(handoffRec, handoffReq)
+ if handoffRec.Code != http.StatusOK {
+ t.Fatalf("handoff status = %d, want %d (body=%q)", handoffRec.Code, http.StatusOK, handoffRec.Body.String())
+ }
+ var handoffResp struct {
+ Feature string `json:"feature"`
+ ActivationURLTemplate string `json:"activation_url_template"`
+ }
+ if err := json.Unmarshal(handoffRec.Body.Bytes(), &handoffResp); err != nil {
+ t.Fatalf("unmarshal handoff response: %v", err)
+ }
+ if handoffResp.Feature != "relay" {
+ t.Fatalf("handoff feature = %q, want relay", handoffResp.Feature)
+ }
+
+ activationURL, err := url.Parse(handoffResp.ActivationURLTemplate)
+ if err != nil {
+ t.Fatalf("parse activation_url_template: %v", err)
+ }
+ returnToken := activationURL.Query().Get(licensePurchaseReturnTokenField)
if strings.TrimSpace(returnToken) == "" {
- t.Fatal("expected signed purchase_return_token in redirect")
+ t.Fatal("expected signed purchase_return_token in activation template")
}
signingKey, err := handler.purchaseReturnSigningKey()
if err != nil {
@@ -752,6 +793,50 @@ func TestHandleCheckoutStart_RedirectsToPulseAccountWithSignedReturnState(t *tes
}
}
+func TestHandleCheckoutHandoff_ResolvesServerOwnedPurchaseRecord(t *testing.T) {
+ handler := createTestHandler(t)
+ handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
+
+ store := handler.purchaseCheckoutHandoffStore()
+ if store == nil {
+ t.Fatal("expected purchase checkout handoff store")
+ }
+ handoffID, err := store.issue(
+ "max_monitored_systems",
+ "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
+ time.Now().UTC().Add(time.Hour),
+ )
+ if err != nil {
+ t.Fatalf("issue purchase handoff: %v", err)
+ }
+
+ req := httptest.NewRequest(
+ http.MethodGet,
+ "https://pulse.example.com"+licensePurchaseHandoffPath+"?purchase_handoff_id="+url.QueryEscape(handoffID),
+ nil,
+ )
+ rec := httptest.NewRecorder()
+
+ handler.HandleCheckoutHandoff(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status = %d, want %d (body=%q)", rec.Code, http.StatusOK, rec.Body.String())
+ }
+ var resp struct {
+ Feature string `json:"feature"`
+ ActivationURLTemplate string `json:"activation_url_template"`
+ }
+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
+ t.Fatalf("unmarshal response: %v", err)
+ }
+ if resp.Feature != "max_monitored_systems" {
+ t.Fatalf("feature = %q, want max_monitored_systems", resp.Feature)
+ }
+ if resp.ActivationURLTemplate != "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}" {
+ t.Fatalf("activation_url_template = %q", resp.ActivationURLTemplate)
+ }
+}
+
func TestHandleCheckoutHandoff_ReturnsVerifiedActivationTemplate(t *testing.T) {
handler := createTestHandler(t)
handler.SetConfig(&config.Config{PublicURL: "https://pulse.example.com"})
diff --git a/internal/api/licensing_handlers.go b/internal/api/licensing_handlers.go
index 6d6717f423..1d8ff44fe4 100644
--- a/internal/api/licensing_handlers.go
+++ b/internal/api/licensing_handlers.go
@@ -26,12 +26,14 @@ const (
trialStartRateLimitBurst = 6
trialStartRateLimitWindow = 15 * time.Minute
licensePurchaseHandoffPath = "/auth/license-purchase-handoff"
+ licensePurchaseHandoffIDField = "purchase_handoff_id"
licensePurchaseStartPath = "/auth/license-purchase-start"
licensePurchaseActivationPath = "/auth/license-purchase-activate"
licensePurchaseSessionIDField = "session_id"
licensePurchaseReturnTokenField = "purchase_return_token"
pulseAccountUpgradeService = "upgrade"
pulseAccountPortalFeatureQueryParam = "feature"
+ pulseAccountPortalHandoffURLQueryParam = "purchase_handoff_url"
pulseAccountPortalServiceQueryParam = "service"
pulseAccountPortalReturnTokenQueryParam = "purchase_return_token"
purchaseReturnKeyPurpose = "pulse-license-purchase-return"
@@ -52,6 +54,7 @@ type LicenseHandlers struct {
trialLimiter *RateLimiter
trialReplay *jtiReplayStore
trialInitiations *trialSignupInitiationStore
+ purchaseHandoffs *purchaseCheckoutHandoffStore
trialRedeemer func(token string) (*hostedTrialRedemptionResponse, error)
monitor *monitoring.Monitor
mtMonitor *monitoring.MultiTenantMonitor
@@ -70,9 +73,11 @@ func NewLicenseHandlers(mtp *config.MultiTenantPersistence, hostedMode bool, cfg
var trialReplay *jtiReplayStore
var trialInitiations *trialSignupInitiationStore
+ var purchaseHandoffs *purchaseCheckoutHandoffStore
if mtp != nil {
trialReplay = &jtiReplayStore{configDir: mtp.BaseDataDir()}
trialInitiations = &trialSignupInitiationStore{configDir: mtp.BaseDataDir()}
+ purchaseHandoffs = &purchaseCheckoutHandoffStore{configDir: mtp.BaseDataDir()}
}
return &LicenseHandlers{
@@ -82,6 +87,7 @@ func NewLicenseHandlers(mtp *config.MultiTenantPersistence, hostedMode bool, cfg
trialLimiter: NewRateLimiter(trialStartRateLimitBurst, trialStartRateLimitWindow),
trialReplay: trialReplay,
trialInitiations: trialInitiations,
+ purchaseHandoffs: purchaseHandoffs,
}
}
@@ -264,7 +270,22 @@ func (h *LicenseHandlers) purchaseReturnSigningKey() ([]byte, error) {
return signingKey, nil
}
-func pulseAccountUpgradeURLForRequest(returnToken string, query url.Values) (string, error) {
+func (h *LicenseHandlers) purchaseCheckoutHandoffStore() *purchaseCheckoutHandoffStore {
+ if h == nil {
+ return nil
+ }
+ if h.purchaseHandoffs != nil {
+ return h.purchaseHandoffs
+ }
+ dataDir := h.purchaseReturnDataDir()
+ if strings.TrimSpace(dataDir) == "" {
+ return nil
+ }
+ h.purchaseHandoffs = &purchaseCheckoutHandoffStore{configDir: dataDir}
+ return h.purchaseHandoffs
+}
+
+func pulseAccountUpgradeURLForRequest(handoffURL string, query url.Values) (string, error) {
portalURL := strings.TrimSpace(pulseAccountPortalURLFromLicensing(""))
if portalURL == "" {
return "", fmt.Errorf("pulse account portal url is unavailable")
@@ -279,6 +300,7 @@ func pulseAccountUpgradeURLForRequest(returnToken string, query url.Values) (str
for key, values := range query {
switch key {
case pulseAccountPortalFeatureQueryParam,
+ pulseAccountPortalHandoffURLQueryParam,
pulseAccountPortalServiceQueryParam,
pulseAccountPortalReturnTokenQueryParam,
"checkout",
@@ -295,11 +317,30 @@ func pulseAccountUpgradeURLForRequest(returnToken string, query url.Values) (str
}
params.Set(pulseAccountPortalServiceQueryParam, pulseAccountUpgradeService)
- params.Set(pulseAccountPortalReturnTokenQueryParam, strings.TrimSpace(returnToken))
+ params.Set(pulseAccountPortalHandoffURLQueryParam, strings.TrimSpace(handoffURL))
parsed.RawQuery = params.Encode()
return parsed.String(), nil
}
+func licensePurchaseHandoffURLForRequest(
+ r *http.Request,
+ cfg *config.Config,
+ handoffID string,
+) (string, error) {
+ baseURL := publicBaseURLForRequest(r, cfg)
+ if baseURL == "" {
+ return "", fmt.Errorf("purchase handoff base url is unavailable")
+ }
+ parsed, err := url.Parse(baseURL + licensePurchaseHandoffPath)
+ if err != nil || parsed == nil {
+ return "", fmt.Errorf("parse purchase handoff url: %w", err)
+ }
+ query := parsed.Query()
+ query.Set(licensePurchaseHandoffIDField, strings.TrimSpace(handoffID))
+ parsed.RawQuery = query.Encode()
+ return parsed.String(), nil
+}
+
func licensePurchaseActivationTemplateURL(returnURL, returnToken string) (string, error) {
parsed, err := url.Parse(strings.TrimSpace(returnURL))
if err != nil || parsed == nil {
@@ -1357,7 +1398,37 @@ func (h *LicenseHandlers) HandleCheckoutStart(w http.ResponseWriter, r *http.Req
return
}
- destination, err := pulseAccountUpgradeURLForRequest(returnToken, r.URL.Query())
+ activationURLTemplate, err := licensePurchaseActivationTemplateURL(returnURL, returnToken)
+ if err != nil {
+ log.Error().Err(err).Str("feature", feature).Msg("Failed to build Pulse Account activation template")
+ http.Error(w, "Pulse Account handoff unavailable", http.StatusServiceUnavailable)
+ return
+ }
+
+ handoffStore := h.purchaseCheckoutHandoffStore()
+ if handoffStore == nil {
+ http.Error(w, "Pulse Account handoff unavailable", http.StatusServiceUnavailable)
+ return
+ }
+ handoffID, err := handoffStore.issue(
+ feature,
+ activationURLTemplate,
+ time.Now().UTC().Add(purchaseCheckoutHandoffTTL),
+ )
+ if err != nil {
+ log.Error().Err(err).Str("feature", feature).Msg("Failed to issue Pulse Account handoff record")
+ http.Error(w, "Pulse Account handoff unavailable", http.StatusServiceUnavailable)
+ return
+ }
+
+ handoffURL, err := licensePurchaseHandoffURLForRequest(r, h.cfg, handoffID)
+ if err != nil {
+ log.Error().Err(err).Str("feature", feature).Msg("Failed to build Pulse Account handoff url")
+ http.Error(w, "Pulse Account handoff unavailable", http.StatusServiceUnavailable)
+ return
+ }
+
+ destination, err := pulseAccountUpgradeURLForRequest(handoffURL, r.URL.Query())
if err != nil {
log.Error().Err(err).Str("feature", feature).Msg("Failed to build Pulse Account upgrade destination")
http.Error(w, "Pulse Account handoff unavailable", http.StatusServiceUnavailable)
@@ -1380,9 +1451,34 @@ func (h *LicenseHandlers) HandleCheckoutHandoff(w http.ResponseWriter, r *http.R
return
}
+ if handoffID := strings.TrimSpace(r.URL.Query().Get(licensePurchaseHandoffIDField)); handoffID != "" {
+ handoffStore := h.purchaseCheckoutHandoffStore()
+ if handoffStore == nil {
+ http.Error(w, "purchase handoff is unavailable", http.StatusServiceUnavailable)
+ return
+ }
+ record, found, err := handoffStore.resolve(handoffID, time.Now().UTC())
+ if err != nil {
+ log.Warn().Err(err).Msg("Purchase handoff record lookup failed")
+ http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
+ return
+ }
+ if !found || record == nil {
+ http.Error(w, "purchase handoff is invalid", http.StatusBadRequest)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ _ = json.NewEncoder(w).Encode(map[string]string{
+ "activation_url_template": strings.TrimSpace(record.ActivationURLTemplate),
+ "feature": strings.TrimSpace(record.Feature),
+ })
+ return
+ }
+
returnToken := strings.TrimSpace(r.URL.Query().Get(licensePurchaseReturnTokenField))
if returnToken == "" {
- http.Error(w, "purchase return token is required", http.StatusBadRequest)
+ http.Error(w, "purchase handoff id or return token is required", http.StatusBadRequest)
return
}
claims, err := h.verifiedPurchaseReturnClaims(r, returnToken)
diff --git a/internal/api/purchase_checkout_handoff_store.go b/internal/api/purchase_checkout_handoff_store.go
new file mode 100644
index 0000000000..3c4c64d1f5
--- /dev/null
+++ b/internal/api/purchase_checkout_handoff_store.go
@@ -0,0 +1,219 @@
+package api
+
+import (
+ "crypto/rand"
+ "crypto/sha256"
+ "database/sql"
+ "encoding/base64"
+ "encoding/hex"
+ "fmt"
+ "net/url"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "time"
+
+ _ "modernc.org/sqlite"
+)
+
+const purchaseCheckoutHandoffTTL = 2 * time.Hour
+
+type purchaseCheckoutHandoffRecord struct {
+ Feature string
+ ActivationURLTemplate string
+}
+
+type purchaseCheckoutHandoffStore struct {
+ once sync.Once
+ db *sql.DB
+ mu sync.Mutex
+
+ configDir string
+ initErr error
+}
+
+func (s *purchaseCheckoutHandoffStore) init() {
+ s.once.Do(func() {
+ dir := filepath.Clean(s.configDir)
+ if strings.TrimSpace(dir) == "" {
+ s.initErr = fmt.Errorf("configDir is required")
+ return
+ }
+ secretsDir := filepath.Join(dir, "secrets")
+ if err := os.MkdirAll(secretsDir, handoffPrivateDirPerm); err != nil {
+ s.initErr = fmt.Errorf("create purchase handoff secrets dir: %w", err)
+ return
+ }
+ if err := os.Chmod(secretsDir, handoffPrivateDirPerm); err != nil {
+ s.initErr = fmt.Errorf("chmod purchase handoff secrets dir: %w", err)
+ return
+ }
+
+ dbPath := filepath.Join(secretsDir, "purchase_checkout_handoff.db")
+ dsn := dbPath + "?" + url.Values{
+ "_pragma": []string{
+ "busy_timeout(30000)",
+ "journal_mode(WAL)",
+ "synchronous(NORMAL)",
+ },
+ }.Encode()
+
+ db, err := sql.Open("sqlite", dsn)
+ if err != nil {
+ s.initErr = fmt.Errorf("open purchase handoff db: %w", err)
+ return
+ }
+ db.SetMaxOpenConns(1)
+ db.SetMaxIdleConns(1)
+ db.SetConnMaxLifetime(0)
+
+ schema := `
+ CREATE TABLE IF NOT EXISTS purchase_checkout_handoffs (
+ handoff_hash TEXT PRIMARY KEY,
+ feature TEXT NOT NULL,
+ activation_url_template TEXT NOT NULL,
+ expires_at INTEGER NOT NULL
+ );
+ CREATE INDEX IF NOT EXISTS idx_purchase_checkout_handoffs_expires_at
+ ON purchase_checkout_handoffs(expires_at);
+ `
+ if _, err := db.Exec(schema); err != nil {
+ _ = db.Close()
+ s.initErr = fmt.Errorf("init purchase handoff schema: %w", err)
+ return
+ }
+ for _, path := range []string{dbPath, dbPath + "-wal", dbPath + "-shm"} {
+ if err := hardenPrivateFile(path, handoffPrivateFilePerm); err != nil {
+ _ = db.Close()
+ s.initErr = fmt.Errorf("harden purchase handoff file permissions: %w", err)
+ return
+ }
+ }
+
+ s.db = db
+ })
+}
+
+func (s *purchaseCheckoutHandoffStore) issue(
+ feature string,
+ activationURLTemplate string,
+ expiresAt time.Time,
+) (string, error) {
+ s.init()
+ if s.initErr != nil {
+ return "", s.initErr
+ }
+ if s.db == nil {
+ return "", fmt.Errorf("purchase handoff store not initialized")
+ }
+ activationURLTemplate = strings.TrimSpace(activationURLTemplate)
+ if activationURLTemplate == "" {
+ return "", fmt.Errorf("activation_url_template is required")
+ }
+ expiresAt = expiresAt.UTC()
+ if expiresAt.IsZero() {
+ expiresAt = time.Now().UTC().Add(purchaseCheckoutHandoffTTL)
+ }
+
+ rawID, err := randomPurchaseCheckoutHandoffID()
+ if err != nil {
+ return "", err
+ }
+ handoffHash := hashPurchaseCheckoutHandoffID(rawID)
+
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ if err := s.cleanupExpiredLocked(time.Now().UTC()); err != nil {
+ return "", err
+ }
+ if _, err := s.db.Exec(
+ `INSERT INTO purchase_checkout_handoffs (handoff_hash, feature, activation_url_template, expires_at)
+ VALUES (?, ?, ?, ?)`,
+ handoffHash,
+ strings.TrimSpace(feature),
+ activationURLTemplate,
+ expiresAt.Unix(),
+ ); err != nil {
+ return "", fmt.Errorf("insert purchase handoff: %w", err)
+ }
+ return rawID, nil
+}
+
+func (s *purchaseCheckoutHandoffStore) resolve(
+ rawID string,
+ now time.Time,
+) (*purchaseCheckoutHandoffRecord, bool, error) {
+ s.init()
+ if s.initErr != nil {
+ return nil, false, s.initErr
+ }
+ if s.db == nil {
+ return nil, false, fmt.Errorf("purchase handoff store not initialized")
+ }
+ handoffHash := hashPurchaseCheckoutHandoffID(rawID)
+ if handoffHash == "" {
+ return nil, false, nil
+ }
+ now = now.UTC()
+
+ s.mu.Lock()
+ defer s.mu.Unlock()
+
+ if err := s.cleanupExpiredLocked(now); err != nil {
+ return nil, false, err
+ }
+
+ record := &purchaseCheckoutHandoffRecord{}
+ var expiresAt int64
+ err := s.db.QueryRow(
+ `SELECT feature, activation_url_template, expires_at
+ FROM purchase_checkout_handoffs
+ WHERE handoff_hash = ?`,
+ handoffHash,
+ ).Scan(&record.Feature, &record.ActivationURLTemplate, &expiresAt)
+ if err == sql.ErrNoRows {
+ return nil, false, nil
+ }
+ if err != nil {
+ return nil, false, fmt.Errorf("lookup purchase handoff: %w", err)
+ }
+ if expiresAt <= now.Unix() {
+ if _, deleteErr := s.db.Exec(
+ `DELETE FROM purchase_checkout_handoffs WHERE handoff_hash = ?`,
+ handoffHash,
+ ); deleteErr != nil {
+ return nil, false, fmt.Errorf("delete expired purchase handoff: %w", deleteErr)
+ }
+ return nil, false, nil
+ }
+ return record, true, nil
+}
+
+func (s *purchaseCheckoutHandoffStore) cleanupExpiredLocked(now time.Time) error {
+ if _, err := s.db.Exec(
+ `DELETE FROM purchase_checkout_handoffs WHERE expires_at <= ?`,
+ now.UTC().Unix(),
+ ); err != nil {
+ return fmt.Errorf("cleanup purchase handoffs: %w", err)
+ }
+ return nil
+}
+
+func hashPurchaseCheckoutHandoffID(raw string) string {
+ raw = strings.TrimSpace(raw)
+ if raw == "" {
+ return ""
+ }
+ sum := sha256.Sum256([]byte(raw))
+ return hex.EncodeToString(sum[:])
+}
+
+func randomPurchaseCheckoutHandoffID() (string, error) {
+ buf := make([]byte, 32)
+ if _, err := rand.Read(buf); err != nil {
+ return "", fmt.Errorf("generate purchase handoff id: %w", err)
+ }
+ return "pch1_" + base64.RawURLEncoding.EncodeToString(buf), nil
+}
diff --git a/internal/api/purchase_checkout_handoff_store_test.go b/internal/api/purchase_checkout_handoff_store_test.go
new file mode 100644
index 0000000000..105ee5597c
--- /dev/null
+++ b/internal/api/purchase_checkout_handoff_store_test.go
@@ -0,0 +1,56 @@
+package api
+
+import (
+ "testing"
+ "time"
+)
+
+func TestPurchaseCheckoutHandoffStore_IssueAndResolve(t *testing.T) {
+ store := &purchaseCheckoutHandoffStore{configDir: t.TempDir()}
+ expiresAt := time.Now().UTC().Add(time.Hour)
+
+ handoffID, err := store.issue(
+ "relay",
+ "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
+ expiresAt,
+ )
+ if err != nil {
+ t.Fatalf("issue: %v", err)
+ }
+ if handoffID == "" {
+ t.Fatal("expected opaque handoff id")
+ }
+
+ record, found, err := store.resolve(handoffID, time.Now().UTC())
+ if err != nil {
+ t.Fatalf("resolve: %v", err)
+ }
+ if !found || record == nil {
+ t.Fatal("expected stored handoff record")
+ }
+ if record.Feature != "relay" {
+ t.Fatalf("record.Feature = %q, want relay", record.Feature)
+ }
+}
+
+func TestPurchaseCheckoutHandoffStore_RejectsExpiredRecords(t *testing.T) {
+ store := &purchaseCheckoutHandoffStore{configDir: t.TempDir()}
+ expiresAt := time.Now().UTC().Add(5 * time.Minute)
+
+ handoffID, err := store.issue(
+ "relay",
+ "https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}",
+ expiresAt,
+ )
+ if err != nil {
+ t.Fatalf("issue: %v", err)
+ }
+
+ record, found, err := store.resolve(handoffID, expiresAt.Add(time.Second))
+ if err != nil {
+ t.Fatalf("resolve: %v", err)
+ }
+ if found || record != nil {
+ t.Fatal("expected expired handoff record to be unavailable")
+ }
+}
diff --git a/internal/cloudcp/portal/frontend/src/app.test.ts b/internal/cloudcp/portal/frontend/src/app.test.ts
index e8bdeac288..60d8594a2c 100644
--- a/internal/cloudcp/portal/frontend/src/app.test.ts
+++ b/internal/cloudcp/portal/frontend/src/app.test.ts
@@ -150,9 +150,8 @@ describe('portal app', function() {
{
openBillingPanelID: 'retrieve-billing-panel',
- upgradeInstanceOrigin: '',
+ upgradeHandoffURL: '',
upgradeFeatureKey: '',
- upgradePurchaseReturnToken: '',
upgradeCheckoutStatus: '',
}
);
diff --git a/internal/cloudcp/portal/frontend/src/billing.ts b/internal/cloudcp/portal/frontend/src/billing.ts
index 21157e56b3..641895d0ba 100644
--- a/internal/cloudcp/portal/frontend/src/billing.ts
+++ b/internal/cloudcp/portal/frontend/src/billing.ts
@@ -88,8 +88,7 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {
var nextState = createPortalBillingState();
billingState.openBillingPanelID = nextState.openBillingPanelID;
billingState.upgradeFeatureKey = nextState.upgradeFeatureKey;
- billingState.upgradeInstanceOrigin = nextState.upgradeInstanceOrigin;
- billingState.upgradePurchaseReturnToken = nextState.upgradePurchaseReturnToken;
+ billingState.upgradeHandoffURL = nextState.upgradeHandoffURL;
billingState.upgradeActivationURLTemplate = nextState.upgradeActivationURLTemplate;
billingState.upgradeHandoff = nextState.upgradeHandoff;
billingState.upgradeCheckoutStatus = nextState.upgradeCheckoutStatus;
@@ -186,8 +185,8 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {
if (billingState.flows.manage.emailValue) {
url.searchParams.set('email', billingState.flows.manage.emailValue);
}
- if (billingState.upgradePurchaseReturnToken) {
- url.searchParams.set('purchase_return_token', billingState.upgradePurchaseReturnToken);
+ if (billingState.upgradeHandoffURL) {
+ url.searchParams.set('purchase_handoff_url', billingState.upgradeHandoffURL);
}
url.searchParams.set('service', 'upgrade');
url.searchParams.set('checkout', 'cancelled');
@@ -220,29 +219,16 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {
async function resolveUpgradeHandoff(force: boolean) {
var billingState = getBillingState();
- var returnToken = billingState.upgradePurchaseReturnToken;
- if (!returnToken) return;
+ var handoffURL = String(billingState.upgradeHandoffURL || '').trim();
+ if (!handoffURL) return;
if (!force && (billingState.upgradeHandoff.status === 'loading' || billingState.upgradeHandoff.status === 'ready')) {
return;
}
- if (!billingState.upgradeInstanceOrigin) {
- updateBillingState(function(nextBillingState) {
- failQueryState(
- nextBillingState.upgradeHandoff,
- null,
- 'Reopen this upgrade from Pulse Pro billing so Pulse Account can verify the return path.',
- );
- nextBillingState.upgradeActivationURLTemplate = '';
- });
- return;
- }
updateBillingState(function(nextBillingState) {
beginQueryState(nextBillingState.upgradeHandoff, null);
});
try {
- var handoffURL = new URL('/auth/license-purchase-handoff', billingState.upgradeInstanceOrigin);
- handoffURL.searchParams.set('purchase_return_token', returnToken);
- var response = await fetch(handoffURL.toString(), {
+ var response = await fetch(handoffURL, {
headers: { Accept: 'application/json' },
});
if (!response.ok) {
@@ -606,7 +592,7 @@ export function installBillingRuntime(deps: BillingRuntimeDeps): void {
if (
billingState.openBillingPanelID === 'upgrade-billing-panel' ||
!!billingState.upgradeFeatureKey ||
- !!billingState.upgradePurchaseReturnToken
+ !!billingState.upgradeHandoffURL
) {
void loadUpgradePricing(false);
void resolveUpgradeHandoff(false);
diff --git a/internal/cloudcp/portal/frontend/src/billing_view.test.ts b/internal/cloudcp/portal/frontend/src/billing_view.test.ts
index 8f5deb3287..0c6d504bca 100644
--- a/internal/cloudcp/portal/frontend/src/billing_view.test.ts
+++ b/internal/cloudcp/portal/frontend/src/billing_view.test.ts
@@ -228,7 +228,8 @@ describe('services view', function() {
var billingState = createPortalBillingState();
billingState.upgradeFeatureKey = 'max_monitored_systems';
- billingState.upgradePurchaseReturnToken = 'prt_signed';
+ billingState.upgradeHandoffURL =
+ 'https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed';
billingState.upgradeActivationURLTemplate = 'https://pulse.example.com/auth/license-purchase-activate?purchase_return_token=prt_signed&session_id={CHECKOUT_SESSION_ID}';
billingState.upgradeHandoff.status = 'ready';
billingState.upgradeHandoff.data = {
@@ -279,7 +280,8 @@ describe('services view', function() {
document.body.innerHTML = '<div id="upgrade-billing-root"></div>';
var billingState = createPortalBillingState();
- billingState.upgradePurchaseReturnToken = 'prt_signed';
+ billingState.upgradeHandoffURL =
+ 'https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed';
billingState.upgradeHandoff.status = 'error';
billingState.upgradeHandoff.error = 'Pulse Account could not verify the secure return path.';
billingState.upgradePricing.status = 'ready';
diff --git a/internal/cloudcp/portal/frontend/src/billing_view.ts b/internal/cloudcp/portal/frontend/src/billing_view.ts
index 40761f8a60..0fc8b4b619 100644
--- a/internal/cloudcp/portal/frontend/src/billing_view.ts
+++ b/internal/cloudcp/portal/frontend/src/billing_view.ts
@@ -141,7 +141,7 @@ export function renderUpgradePanel(billingState: PortalBillingState, _bootstrap:
var pricingState = billingState.upgradePricing;
var handoffState = billingState.upgradeHandoff;
var activationURLTemplate = String(billingState.upgradeActivationURLTemplate || '').trim();
- var returnToken = String(billingState.upgradePurchaseReturnToken || '').trim();
+ var handoffURL = String(billingState.upgradeHandoffURL || '').trim();
var explainer = pricingState.data && pricingState.data.explainer ? pricingState.data.explainer : '';
var summaryItems = [] as string[];
@@ -154,7 +154,7 @@ export function renderUpgradePanel(billingState: PortalBillingState, _bootstrap:
if (billingState.upgradeCheckout.error) {
summaryItems.push('<div class="billing-status visible error">' + escapeText(billingState.upgradeCheckout.error) + '</div>');
}
- if (!returnToken) {
+ if (!handoffURL) {
summaryItems.push(
'<div class="billing-status visible error">Open this upgrade from Pulse Pro billing so Pulse Account can verify the return path before checkout.</div>',
);
diff --git a/internal/cloudcp/portal/frontend/src/runtime.test.ts b/internal/cloudcp/portal/frontend/src/runtime.test.ts
index fdb42295e4..f2b2d005cc 100644
--- a/internal/cloudcp/portal/frontend/src/runtime.test.ts
+++ b/internal/cloudcp/portal/frontend/src/runtime.test.ts
@@ -64,15 +64,17 @@ describe('portal runtime', function() {
it('derives canonical email and billing handoff from the portal URL', function() {
var handoff = readPortalRuntimeHandoff(
- 'https://cloud.pulserelay.pro/portal?email=buyer%40example.com&service=upgrade&purchase_return_token=prt_signed&checkout=cancelled',
- 'https://pulse.example.com/auth/license-purchase-start?feature=max_monitored_systems',
+ 'https://cloud.pulserelay.pro/portal?email=buyer%40example.com&service=upgrade&purchase_handoff_url=' +
+ encodeURIComponent('https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed') +
+ '&checkout=cancelled',
);
expect(handoff.email).toBe('[email protected]');
expect(handoff.openBillingPanelID).toBe('upgrade-billing-panel');
- expect(handoff.upgradeInstanceOrigin).toBe('https://pulse.example.com');
+ expect(handoff.upgradeHandoffURL).toBe(
+ 'https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed',
+ );
expect(handoff.upgradeFeatureKey).toBe('');
- expect(handoff.upgradePurchaseReturnToken).toBe('prt_signed');
expect(handoff.upgradeCheckoutStatus).toBe('cancelled');
});
@@ -87,9 +89,8 @@ describe('portal runtime', function() {
{
openBillingPanelID: 'refund-billing-panel',
- upgradeInstanceOrigin: '',
+ upgradeHandoffURL: '',
upgradeFeatureKey: '',
- upgradePurchaseReturnToken: '',
upgradeCheckoutStatus: '',
}
);
@@ -111,18 +112,19 @@ describe('portal runtime', function() {
{
email: '',
openBillingPanelID: 'upgrade-billing-panel',
- upgradeInstanceOrigin: 'https://pulse.example.com',
+ upgradeHandoffURL:
+ 'https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed',
upgradeFeatureKey: '',
- upgradePurchaseReturnToken: 'prt_signed',
upgradeCheckoutStatus: 'cancelled',
}
);
expect(runtime.store.getShellState().activeSection).toBe('billing');
expect(runtime.store.getBillingState().openBillingPanelID).toBe('upgrade-billing-panel');
- expect(runtime.store.getBillingState().upgradeInstanceOrigin).toBe('https://pulse.example.com');
+ expect(runtime.store.getBillingState().upgradeHandoffURL).toBe(
+ 'https://pulse.example.com/auth/license-purchase-handoff?purchase_handoff_id=pch1_signed',
+ );
expect(runtime.store.getBillingState().upgradeFeatureKey).toBe('');
- expect(runtime.store.getBillingState().upgradePurchaseReturnToken).toBe('prt_signed');
expect(runtime.store.getBillingState().upgradeCheckoutStatus).toBe('cancelled');
});
});
diff --git a/internal/cloudcp/portal/frontend/src/runtime.ts b/internal/cloudcp/portal/frontend/src/runtime.ts
index 18c582f3fd..4241550c62 100644
--- a/internal/cloudcp/portal/frontend/src/runtime.ts
+++ b/internal/cloudcp/portal/frontend/src/runtime.ts
@@ -5,9 +5,8 @@ import type { PortalBootstrapData } from './types';
export interface PortalRuntimeHandoff {
email: string;
openBillingPanelID: string;
- upgradeInstanceOrigin: string;
+ upgradeHandoffURL: string;
upgradeFeatureKey: string;
- upgradePurchaseReturnToken: string;
upgradeCheckoutStatus: '' | 'success' | 'cancelled';
}
@@ -34,13 +33,17 @@ function normalizeHandoffEmail(value: string | null): string {
return String(value || '').trim();
}
-function normalizeHandoffInstanceOrigin(
+function normalizeUpgradeHandoffURL(
value: string | null | undefined,
): string {
var trimmed = String(value || '').trim();
if (!trimmed) return '';
try {
- return new URL(trimmed).origin;
+ var parsed = new URL(trimmed);
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
+ return '';
+ }
+ return parsed.toString();
} catch {
return '';
}
@@ -67,10 +70,6 @@ function normalizeUpgradeFeatureKey(value: string | null): string {
return String(value || '').trim();
}
-function normalizeUpgradePurchaseReturnToken(value: string | null): string {
- return String(value || '').trim();
-}
-
function normalizeUpgradeCheckoutStatus(value: string | null): '' | 'success' | 'cancelled' {
switch (String(value || '').trim()) {
case 'success':
@@ -84,25 +83,22 @@ function normalizeUpgradeCheckoutStatus(value: string | null): '' | 'success' |
export function readPortalRuntimeHandoff(
locationHref: string | undefined = window.location.href,
- referrerHref: string | undefined = typeof document !== 'undefined' ? document.referrer : '',
): PortalRuntimeHandoff {
try {
var params = new URL(locationHref).searchParams;
return {
email: normalizeHandoffEmail(params.get('email')),
openBillingPanelID: normalizeHandoffBillingPanel(params.get('service')),
- upgradeInstanceOrigin: normalizeHandoffInstanceOrigin(referrerHref),
- upgradeFeatureKey: normalizeUpgradeFeatureKey(params.get('purchase_return_token') ? '' : params.get('feature')),
- upgradePurchaseReturnToken: normalizeUpgradePurchaseReturnToken(params.get('purchase_return_token')),
+ upgradeHandoffURL: normalizeUpgradeHandoffURL(params.get('purchase_handoff_url')),
+ upgradeFeatureKey: normalizeUpgradeFeatureKey(params.get('feature')),
upgradeCheckoutStatus: normalizeUpgradeCheckoutStatus(params.get('checkout')),
};
} catch {
return {
email: '',
openBillingPanelID: '',
- upgradeInstanceOrigin: '',
+ upgradeHandoffURL: '',
upgradeFeatureKey: '',
- upgradePurchaseReturnToken: '',
upgradeCheckoutStatus: '',
};
}
@@ -147,25 +143,23 @@ export function createPortalRuntime(
billingState.refund.emailValue = handoff.email;
}, { notify: false });
}
- if (handoff.openBillingPanelID) {
- store.setActiveShellSection('billing');
- store.updateBillingState(function(billingState) {
- billingState.openBillingPanelID = handoff.openBillingPanelID;
- billingState.upgradeInstanceOrigin = handoff.upgradeInstanceOrigin;
- billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
- billingState.upgradePurchaseReturnToken = handoff.upgradePurchaseReturnToken;
- billingState.upgradeActivationURLTemplate = '';
- billingState.upgradeCheckoutStatus = handoff.upgradeCheckoutStatus;
- }, { notify: false });
- } else if (handoff.upgradeFeatureKey || handoff.upgradePurchaseReturnToken) {
- store.setActiveShellSection('billing');
- store.updateBillingState(function(billingState) {
- billingState.upgradeInstanceOrigin = handoff.upgradeInstanceOrigin;
- billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
- billingState.upgradePurchaseReturnToken = handoff.upgradePurchaseReturnToken;
- billingState.upgradeActivationURLTemplate = '';
- billingState.upgradeCheckoutStatus = handoff.upgradeCheckoutStatus;
- }, { notify: false });
+ if (handoff.openBillingPanelID) {
+ store.setActiveShellSection('billing');
+ store.updateBillingState(function(billingState) {
+ billingState.openBillingPanelID = handoff.openBillingPanelID;
+ billingState.upgradeHandoffURL = handoff.upgradeHandoffURL;
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
+ billingState.upgradeActivationURLTemplate = '';
+ billingState.upgradeCheckoutStatus = handoff.upgradeCheckoutStatus;
+ }, { notify: false });
+ } else if (handoff.upgradeFeatureKey || handoff.upgradeHandoffURL) {
+ store.setActiveShellSection('billing');
+ store.updateBillingState(function(billingState) {
+ billingState.upgradeHandoffURL = handoff.upgradeHandoffURL;
+ billingState.upgradeFeatureKey = handoff.upgradeFeatureKey;
+ billingState.upgradeActivationURLTemplate = '';
+ billingState.upgradeCheckoutStatus = handoff.upgradeCheckoutStatus;
+ }, { notify: false });
}
return {
bootstrapDefaults: bootstrapDefaults,
diff --git a/internal/cloudcp/portal/frontend/src/shell_view.ts b/internal/cloudcp/portal/frontend/src/shell_view.ts
index e8067949bf..71c4f0eb1c 100644
--- a/internal/cloudcp/portal/frontend/src/shell_view.ts
+++ b/internal/cloudcp/portal/frontend/src/shell_view.ts
@@ -1233,7 +1233,10 @@ export function renderAuthenticatedPortalHTML(context: ShellViewContext): string
var accounts = Array.isArray(context.bootstrap.accounts) ? context.bootstrap.accounts : [];
var hosted = hasHostedAccounts(accounts);
var showSelfHostedCommercial = hasSelfHostedCommercial(context.bootstrap);
- var showSelfHostedUpgradeHandoff = !!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey);
+ var showSelfHostedUpgradeHandoff =
+ context.billingState.openBillingPanelID === 'upgrade-billing-panel' ||
+ !!normalizeUpgradeFeatureKey(context.billingState.upgradeFeatureKey) ||
+ !!String(context.billingState.upgradeHandoffURL || '').trim();
var showSelfHostedBillingShell = showSelfHostedCommercial || showSelfHostedUpgradeHandoff;
var shellSections = visibleShellSections(context.bootstrap);
var preferredSection = context.activeSection || preferredPortalShellSection(context.bootstrap);
diff --git a/internal/cloudcp/portal/frontend/src/state.test.ts b/internal/cloudcp/portal/frontend/src/state.test.ts
index 0c3b0bed47..a76e531260 100644
--- a/internal/cloudcp/portal/frontend/src/state.test.ts
+++ b/internal/cloudcp/portal/frontend/src/state.test.ts
@@ -35,8 +35,7 @@ describe('portal state', function() {
expect(billingState.flows.manage.confirm.pending).toBe(false);
expect(billingState.refund.submit.pending).toBe(false);
expect(billingState.upgradeFeatureKey).toBe('');
- expect(billingState.upgradeInstanceOrigin).toBe('');
- expect(billingState.upgradePurchaseReturnToken).toBe('');
+ expect(billingState.upgradeHandoffURL).toBe('');
expect(billingState.upgradeActivationURLTemplate).toBe('');
expect(billingState.upgradeHandoff.status).toBe('idle');
expect(billingState.upgradeCheckoutStatus).toBe('');
diff --git a/internal/cloudcp/portal/frontend/src/state.ts b/internal/cloudcp/portal/frontend/src/state.ts
index f45de9acf8..6d0e41ea83 100644
--- a/internal/cloudcp/portal/frontend/src/state.ts
+++ b/internal/cloudcp/portal/frontend/src/state.ts
@@ -118,8 +118,7 @@ export function createPortalBillingState(): PortalBillingState {
return {
openBillingPanelID: '',
upgradeFeatureKey: '',
- upgradeInstanceOrigin: '',
- upgradePurchaseReturnToken: '',
+ upgradeHandoffURL: '',
upgradeActivationURLTemplate: '',
upgradeHandoff: createQueryState(null),
upgradeCheckoutStatus: '',
diff --git a/internal/cloudcp/portal/frontend/src/types.ts b/internal/cloudcp/portal/frontend/src/types.ts
index d9e7608c44..fcf17e909b 100644
--- a/internal/cloudcp/portal/frontend/src/types.ts
+++ b/internal/cloudcp/portal/frontend/src/types.ts
@@ -165,8 +165,7 @@ export interface RefundState {
export interface PortalBillingState {
openBillingPanelID: string;
upgradeFeatureKey: string;
- upgradeInstanceOrigin: string;
- upgradePurchaseReturnToken: string;
+ upgradeHandoffURL: string;
upgradeActivationURLTemplate: string;
upgradeHandoff: PortalQueryState<PortalUpgradeHandoffModel | null>;
upgradeCheckoutStatus: PortalUpgradeCheckoutStatus;
diff --git a/tests/integration/tests/54-monitored-system-billing-focus.spec.ts b/tests/integration/tests/54-monitored-system-billing-focus.spec.ts
index b8cc894e2d..dd09813ccb 100644
--- a/tests/integration/tests/54-monitored-system-billing-focus.spec.ts
+++ b/tests/integration/tests/54-monitored-system-billing-focus.spec.ts
@@ -190,6 +190,8 @@ test.describe('Monitored-system billing focus', () => {
'true',
);
await expect(page.getByText('Need a higher monitored-system cap?')).toBeVisible();
+ await expect(page.getByText('Redeem existing key')).toBeVisible();
+ await expect(page.getByLabel('Pulse Pro Key')).toBeHidden();
await expect(page.getByRole('link', { name: 'Compare plans' })).toHaveAttribute(
'href',
'/auth/license-purchase-start?feature=max_monitored_systems',
diff --git a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts b/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts
index bd40010de4..0dc1ad8adb 100644
--- a/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts
+++ b/tests/integration/tests/55-self-hosted-upgrade-return.spec.ts
@@ -7,6 +7,8 @@ const PULSE_ACCOUNT_PORTAL_URL = 'https://cloud.pulserelay.pro/portal';
const PURCHASE_RETURN_URL = `${DEV_SERVER_URL}/auth/license-purchase-activate`;
const ACTIVATED_BILLING_URL = `${DEV_SERVER_URL}/settings/system/billing/plan?intent=max_monitored_systems`;
const PURCHASE_RETURN_TOKEN = 'prt_signed_checkout_return';
+const PURCHASE_HANDOFF_URL =
+ `${DEV_SERVER_URL}/auth/license-purchase-handoff?purchase_handoff_id=pch1_checkout_return`;
const MONITORED_SYSTEM_ENTITLEMENTS = {
capabilities: [],
@@ -169,7 +171,7 @@ test.describe('Self-hosted upgrade return flow', () => {
headers: {
location:
`${PULSE_ACCOUNT_PORTAL_URL}?service=upgrade` +
- `&purchase_return_token=${encodeURIComponent(PURCHASE_RETURN_TOKEN)}`,
+ `&purchase_handoff_url=${encodeURIComponent(PURCHASE_HANDOFF_URL)}`,
},
body: '',
});
@@ -180,7 +182,7 @@ test.describe('Self-hosted upgrade return flow', () => {
expect(requestUrl.searchParams.get('service')).toBe('upgrade');
expect(requestUrl.searchParams.get('feature')).toBeNull();
expect(requestUrl.searchParams.get('return_url')).toBeNull();
- expect(requestUrl.searchParams.get('purchase_return_token')).toBe(PURCHASE_RETURN_TOKEN);
+ expect(requestUrl.searchParams.get('purchase_handoff_url')).toBe(PURCHASE_HANDOFF_URL);
await route.fulfill({
status: 200,
@@ -248,7 +250,7 @@ test.describe('Self-hosted upgrade return flow', () => {
);
await page.goto(
- `${PULSE_ACCOUNT_PORTAL_URL}?service=upgrade&purchase_return_token=${encodeURIComponent(PURCHASE_RETURN_TOKEN)}`,
+ `${PULSE_ACCOUNT_PORTAL_URL}?service=upgrade&purchase_handoff_url=${encodeURIComponent(PURCHASE_HANDOFF_URL)}`,
{
waitUntil: 'domcontentloaded',
},