Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: addressed codex review
=02378cb53928
diff --git a/backend/src/ee/routes/v1/license-v2-router.ts b/backend/src/ee/routes/v1/license-v2-router.tsindex 099a03489d..c2d0b6538a 100644--- a/backend/src/ee/routes/v1/license-v2-router.ts+++ b/backend/src/ee/routes/v1/license-v2-router.ts@@ -376,8 +376,7 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {plan: z.string().trim().optional(),cadence: z.enum(["monthly", "annual"]).optional(),quantities: BillingV2QuantitiesSchema.optional(),- returnPath: ReturnPathSchema,- prorationDate: z.number().optional()+ returnPath: ReturnPathSchema}),response: {200: z.object({@@ -400,8 +399,7 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {cadence: req.body.cadence,quantities: req.body.quantities,email,- returnPath: req.body.returnPath,- prorationDate: req.body.prorationDate+ returnPath: req.body.returnPath});}});@@ -439,8 +437,7 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {schema: {params: z.object({ organizationId: z.string().trim() }),body: z.object({- changes: BillingV2CommitmentChangeSchema.array().min(1).max(20),- prorationDate: z.number().optional()+ changes: BillingV2CommitmentChangeSchema.array().min(1).max(20)}),response: {200: BillingV2MutationResultSchema@@ -451,8 +448,7 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {return server.services.licenseV2.changeCommitments({orgId: req.params.organizationId,actor: buildActor(req.permission),- changes: req.body.changes,- prorationDate: req.body.prorationDate+ changes: req.body.changes});}});diff --git a/backend/src/ee/services/license-v2/license-v2-service.ts b/backend/src/ee/services/license-v2/license-v2-service.tsindex 0f0b6257e3..4b33ebc0e7 100644--- a/backend/src/ee/services/license-v2/license-v2-service.ts+++ b/backend/src/ee/services/license-v2/license-v2-service.ts@@ -836,8 +836,7 @@ export const licenseV2ServiceFactory = ({cadence,quantities,email,- returnPath,- prorationDate+ returnPath}: TBuyBillingV2ProductDTO) => {await ensureManageBilling(orgId, actor);@@ -860,8 +859,7 @@ export const licenseV2ServiceFactory = ({quantities: resolved.quantities,declaredUsage: resolved.declaredUsage,email,- returnUrl: buildReturnUrl(orgId, returnPath),- prorationDate+ returnUrl: buildReturnUrl(orgId, returnPath)});if (result.outcome === "subscription_updated") {@@ -943,14 +941,13 @@ export const licenseV2ServiceFactory = ({};};- const changeCommitments = async ({ orgId, actor, changes, prorationDate }: TChangeBillingV2CommitmentDTO) => {+ const changeCommitments = async ({ orgId, actor, changes }: TChangeBillingV2CommitmentDTO) => {await ensureManageBilling(orgId, actor);if (!changes.length) {throw new BadRequestError({ message: "Provide at least one commitment change" });}const result = await licenseClient.changeCommitments(orgId, {- dimensions: changes.map((change) => ({ dimensionKey: change.dimensionKey, quantity: change.quantity })),- prorationDate+ dimensions: changes.map((change) => ({ dimensionKey: change.dimensionKey, quantity: change.quantity }))});await licenseClient.invalidateEntitlements(orgId);return { subscriptionId: result.subscriptionId };diff --git a/backend/src/ee/services/license-v2/license-v2-types.ts b/backend/src/ee/services/license-v2/license-v2-types.tsindex f1a3d46abe..f2e3bb21a0 100644--- a/backend/src/ee/services/license-v2/license-v2-types.ts+++ b/backend/src/ee/services/license-v2/license-v2-types.ts@@ -222,8 +222,6 @@ export type TBuyBillingV2ProductDTO = {quantities?: Record<string, number>;email?: string;returnPath?: string;- // Echoed from a prior preview so the applied charge matches the previewed one.- prorationDate?: number;};export type TAddBillingV2PaymentMethodDTO = {@@ -275,13 +273,12 @@ export type TRemoveBillingV2ProductDTO = {};// Start / change annual commitments across dimensions in one atomic call. Increase is charged now; a-// decrease is rejected by the server unless the dimension's decrease window is open. prorationDate is-// echoed from a prior preview for dimensions that already have a commit item.+// decrease is rejected by the server unless the dimension's decrease window is open. The change always+// prices at the current server time; a client-supplied proration instant is never accepted.export type TChangeBillingV2CommitmentDTO = {orgId: string;actor: OrgServiceActor;changes: BillingV2CommitmentChange[];- prorationDate?: number;};export type TStartBillingV2TrialDTO = {diff --git a/backend/src/services/license-client/license-client-backends.ts b/backend/src/services/license-client/license-client-backends.tsindex 098c64cac3..3687426abe 100644--- a/backend/src/services/license-client/license-client-backends.ts+++ b/backend/src/services/license-client/license-client-backends.ts@@ -271,8 +271,8 @@ export const licenseServerBackend = (return checkoutResultSchema.parse(body);},- // Start / change annual commitments across dimensions, all-or-nothing. prorationDate (echoed from a- // prior preview) applies to dimensions that already have a commit item.+ // Start / change annual commitments across dimensions, all-or-nothing. The license server prices at+ // its current time; no client-supplied proration instant is forwarded.changeCommitments: async (orgId: string, payload: TChangeCommitmentsPayload): Promise<TCheckoutResult> => {const url = new URL(orgScoped(orgId, "/subscription/commitments"), serverUrl);const res = await fetch(url, {diff --git a/backend/src/services/license-client/license-client-types.ts b/backend/src/services/license-client/license-client-types.tsindex d930d8a526..be7bfef1da 100644--- a/backend/src/services/license-client/license-client-types.ts+++ b/backend/src/services/license-client/license-client-types.ts@@ -382,7 +382,6 @@ export type TBuyProductPayload = {// Absolute return URL; its origin must be in the license server's CUSTOMER_PORTAL_ORIGINS allowlist// (the multi-region fix).returnUrl?: string;- prorationDate?: number;};export type TCreatePortalPayload = {@@ -391,10 +390,9 @@ export type TCreatePortalPayload = {};// Start / change annual commitments across dimensions (PUT /subscription/commitments), all-or-nothing.-// prorationDate is echoed from a prior preview for dimensions that already have a commit item.+// The license server prices at its current time; the app never forwards a client-supplied instant.export type TChangeCommitmentsPayload = {dimensions: TCommitmentChange[];- prorationDate?: number;};export type TStartTrialPayload = {diff --git a/frontend/src/hooks/api/billingV2/mutations.tsx b/frontend/src/hooks/api/billingV2/mutations.tsxindex b6cc1585d2..a56b470da1 100644--- a/frontend/src/hooks/api/billingV2/mutations.tsx+++ b/frontend/src/hooks/api/billingV2/mutations.tsx@@ -47,12 +47,11 @@ export const useBuyBillingV2Product = () => {plan,cadence,quantities,- returnPath,- prorationDate+ returnPath}: TBuyBillingV2ProductDTO) => {const { data } = await apiRequest.post<BillingV2CheckoutResult>(`/api/v1/organizations/${orgId}/billing/v2/subscription/products`,- { productId, plan, cadence, quantities, returnPath, prorationDate }+ { productId, plan, cadence, quantities, returnPath });return data;@@ -107,10 +106,10 @@ export const usePreviewBillingV2Change = () => {export const useChangeBillingV2Commitment = () => {const queryClient = useQueryClient();return useMutation({- mutationFn: async ({ orgId, changes, prorationDate }: TChangeBillingV2CommitmentDTO) => {+ mutationFn: async ({ orgId, changes }: TChangeBillingV2CommitmentDTO) => {const { data } = await apiRequest.put<BillingV2MutationResult>(`/api/v1/organizations/${orgId}/billing/v2/subscription/commitments`,- { changes, prorationDate }+ { changes });return data;diff --git a/frontend/src/hooks/api/billingV2/types.ts b/frontend/src/hooks/api/billingV2/types.tsindex f80814b219..83c446c971 100644--- a/frontend/src/hooks/api/billingV2/types.ts+++ b/frontend/src/hooks/api/billingV2/types.ts@@ -204,7 +204,7 @@ export type TCreateBillingV2PortalSessionDTO = {// Buy/add one product. The server self-selects append vs Checkout. quantities are buyer-entered// per-dimension values; the server fills any non-entered per_resource dim. Commitment is a separate-// step (useChangeBillingV2Commitment). prorationDate is echoed from a prior preview.+// step (useChangeBillingV2Commitment).export type TBuyBillingV2ProductDTO = {orgId: string;productId: string;@@ -212,7 +212,6 @@ export type TBuyBillingV2ProductDTO = {cadence?: BillingV2Cadence;quantities?: Record<string, number>;returnPath?: string;- prorationDate?: number;};export type TAddBillingV2PaymentMethodDTO = {@@ -229,8 +228,7 @@ export type BillingV2PreviewLine = {// prorationAmount is this change's cost (signed: positive is charged now, negative a credit).// additionalCharges are earlier mid-cycle changes still unbilled that an invoice-now apply settles in// the same charge; totalDueNow (= prorationAmount + additionalCharges) is what actually hits the card-// and is the figure to show as "charged now". prorationDate is echoed into the apply so the applied-// charge matches the preview.+// and is the figure to show as "charged now".export type BillingV2Preview = {currency: string;prorationAmount: number;@@ -238,7 +236,6 @@ export type BillingV2Preview = {totalDueNow: number;nextInvoiceTotal: number;nextRecurringTotal: number;- prorationDate?: number | null;lines: BillingV2PreviewLine[];};@@ -271,12 +268,11 @@ export type TRemoveBillingV2ProductDTO = {};// Start / change annual commitments across dimensions in one atomic call. An increase is charged now;-// a decrease is rejected server-side unless the dimension's window is open. prorationDate is echoed-// from a prior preview.+// a decrease is rejected server-side unless the dimension's window is open. The change always prices+// at the current server time.export type TChangeBillingV2CommitmentDTO = {orgId: string;changes: BillingV2CommitmentChange[];- prorationDate?: number;};export type TStartBillingV2TrialDTO = {diff --git a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.tsindex 689c94f121..2dfb373155 100644--- a/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts+++ b/frontend/src/pages/organization/BillingV2Page/billing-v2-format.ts@@ -147,8 +147,13 @@ export const productAnnualCommitted = (entitlement?: BillingV2Entitlement): numbexport const dimCommittable = (dim: BillingV2EntitlementDim): boolean =>dim.commitAvailable && !dim.metered;-export const canStartCommitment = (entitlement?: BillingV2Entitlement): boolean =>- (entitlement?.dimensions ?? []).some((dim) => dimCommittable(dim) && dim.committed === null);+// A dimension the commitment sheet should manage: one the customer is currently eligible to commit+// (dimCommittable), OR one that already carries a commitment (dimCommitted) even if it is no longer+// commit-eligible (e.g. a grandfathered dimension, or an older license server that omits+// commitAvailable and so defaults it to false). This is the single predicate the "Change commitment"+// action AND the commitment view share, so the action never opens onto an empty sheet.+export const dimCommitManageable = (dim: BillingV2EntitlementDim): boolean =>+ dimCommittable(dim) || dimCommitted(dim);export type BillingV2CommitNudge = {label: string;diff --git a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsxindex a5cc781b56..3650284aa2 100644--- a/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/ActivateView.tsx@@ -191,8 +191,6 @@ export const ActivateView = ({plan: plan.tier,cadence,quantities: quantitiesForCadence,- // The preview echoes the proration instant so the applied charge matches what was shown.- prorationDate: preview.data?.prorationDate ?? undefined,returnPath});if (result.outcome === "subscription_updated") {diff --git a/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx b/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsxindex 70d1226782..d0a0b84811 100644--- a/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/CommitmentView.tsx@@ -18,7 +18,7 @@ import {usePreviewBillingV2Change} from "@app/hooks/api";-import { dimCommittable, fmtMoney } from "../billing-v2-format";+import { dimCommitManageable, fmtMoney } from "../billing-v2-format";import { ChargeBreakdown } from "./ChargeBreakdown";import { CommitmentTerms } from "./CommitmentTerms";import { CostSummary, CostSummaryRow, ProductIcon, Stepper } from "./shared";@@ -36,14 +36,16 @@ type Props = {// committed quantity per dimension; the preview endpoint (commitmentChanges) prices the change and the// apply endpoint commits it. Usage above the commitment is billed monthly on-demand.export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onDone }: Props) => {- // Commit-eligible dimensions come from the subscription read's per-dimension commitAvailable (this- // customer's pinned plan version), NOT the catalog, so a later catalog price never lights up commit- // for a grandfathered customer. An eligible dimension with committed === null starts from zero (e.g.- // a monthly subscriber committing annually). committed is normalized to a number so the stepper and- // cost math handle the not-yet-committed case.+ // Dimensions this sheet manages: commit-eligible per the subscription read's per-dimension+ // commitAvailable (this customer's pinned plan version, NOT the catalog, so a later catalog price+ // never lights up commit for a grandfathered customer), OR already carrying a commitment even if it+ // is no longer commit-eligible, so an existing commitment is always inspectable. This is the same+ // predicate that gates the "Change commitment" action, so the sheet is never empty when opened. An+ // eligible dimension with committed === null starts from zero (e.g. a monthly subscriber committing+ // annually); committed is normalized to a number so the stepper and cost math handle that case.const committable = useMemo(() =>- (entitlement.dimensions ?? []).filter(dimCommittable).map((dim) => ({+ (entitlement.dimensions ?? []).filter(dimCommitManageable).map((dim) => ({key: dim.key,label: dim.label,noun: dim.noun,@@ -146,9 +148,7 @@ export const CommitmentView = ({ orgId, prod, entitlement, renewsOn, onBack, onDtry {await applyCommitment.mutateAsync({orgId,- changes,- // Echo the previewed proration instant so the applied charge matches what was shown.- prorationDate: preview.data?.prorationDate ?? undefined+ changes});createNotification({type: "success",diff --git a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsxindex 64fe7bde21..d42b656ee9 100644--- a/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx+++ b/frontend/src/pages/organization/BillingV2Page/components/ProductSheet.tsx@@ -43,7 +43,7 @@ import {cadencePeriod,cadenceWord,cadenceWordShort,- canStartCommitment,+ dimCommitManageable,dimCommitted,fmtMoney,isMeteredCadence,@@ -402,9 +402,10 @@ export const ProductSheet = ({entitlement?.cadence ?? (trialAvailable ? "monthly" : "annual");// Offer the commitment flow when the org already has a commitment (to change it) OR its pinned plan// version lets it commit a dimension it hasn't set yet (start from zero, e.g. a monthly subscriber- // committing annually). Eligibility is the subscription read's per-dimension commitAvailable.+ // committing annually). Uses the SAME predicate the commitment view filters on (dimCommitManageable),+ // so the action never opens onto an empty sheet. hasCommitment only drives the CTA label.const hasCommitment = (entitlement?.dimensions ?? []).some(dimCommitted);- const canChangeCommitment = hasCommitment || canStartCommitment(entitlement);+ const showChangeCommitment = (entitlement?.dimensions ?? []).some(dimCommitManageable);// Render plan cards in the catalog's displayOrder (already sorted server-side). A deprecated plan is// closed to new customers, so hide it unless the org is already entitled (e.g. currently on it).@@ -529,7 +530,7 @@ export const ProductSheet = ({entitled={entitled}trialUsed={trialUsed}isCurrent={entitled && plan.tier === currentTier}- canChangeCommitment={canChangeCommitment}+ canChangeCommitment={showChangeCommitment}hasCommitment={hasCommitment}onActivate={openActivate}onStartTrial={setTrialConfirmTier}