fix: passing ownership cookie during calculation - #220
Merged
Conversation
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
|
Beep boop 🤖 I noticed you didn't make any changes at the
In order to keep track, I'll create an issue if you decide now is not a good time
|
huandrey
approved these changes
Aug 10, 2026
huandrey
reviewed
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem is this solving?
Shoppers were seeing their own
clientProfileDataandshippingDatamasked(
"receiverName": "T***","postalCode": "***01") after they had alreadyentered that data. Once a cart reached this state it could not be recovered.
The cause is the
CheckoutOrderFormOwnershipcookie, which is the onlycredential that unmasks personal data in an order form — an admin token does
not work. Checkout mints it when personal data is written, and rotates it on
every subsequent write. We were losing it in three ways:
CheckoutOrderFormOwnership=(empty) whenever a cart is created, with thesame domain and path as a real token, so forwarding it erased the ownership
the shopper already held.
@withOwnerIdsnapshots the value from the incoming request, so any Checkoutcall after a rotation kept authenticating with the stale token and got masked
data back.
updateOrderFormShippingdiscarded the rotation entirely. It usedpost,which hides response headers, so the token minted by the
shippingDataattachment never reached the browser.
The
orderFormquery also skipped cookie forwarding wheneverenableOrderFormOptimizationwasfalse. That reasoning holds forcheckout.vtex.com(store-graphql sets it) but not for the ownership cookie,which no other app sets, so it is now always forwarded.
Verified against the published app for contrast: the same mutation on
mainemits zero ownership cookies and the cart stays masked permanently.
How should this be manually tested?
Workspace
In a normal browser session (the cookie is
httpOnly, so it is only visible inDevTools → Application → Cookies, never in
document.cookie):/checkout/cart/add/?sku=1&qty=1&seller=1&sc=1.CheckoutOrderFormOwnershipis present but empty — expected, Checkout blanksit on cart creation.
updateSelectedAddress(or set an address in checkout). The responseshould carry
set-cookie: CheckoutOrderFormOwnership=<non-empty>and thecookie should now hold a real value.
/api/checkout/pub/orderForm/{orderFormId}. Theaddress must come back unmasked.
updateOrderFormProfile; the token rotates and the profile staysunmasked.
Use a cart created after linking. Carts broken before the fix cannot be
recovered, because their token was minted and discarded.
Notes
Scope. Only
attachments/shippingDataandattachments/clientProfileDatarotate the ownership token; both are covered.
items,coupons,paymentData,checkIn,profile,marketingData,clientPreferencesData,openTextField,itemsOrdinationandmessages/clearecho the same value back, so there isnothing to relay for them. This is observed behaviour rather than a documented
contract — if Checkout starts rotating elsewhere, this would regress silently.
Client middleware.
keepOwnershipcaptures the token from every Checkoutresponse into
vtex.ownerId. This covers verbs with no raw variant — notablypatch, used byaddItem/updateItems— which cannot read their own responseheaders from the calling method. It updates the in-process context only; writing
to the browser remains
forwardCheckoutCookies's job.Dependency.
@vtex/apimoves 6.50.1 → 6.51.0 formiddlewaressupport inInstanceOptions.Out of scope. Checkout blanking the cookie on cart creation is unchanged —
when the browser calls
/api/checkout/pub/orderFormdirectly, this app is not inthe request path and cannot intercept it. Addressing that needs a Checkout-side
change. Reads also cannot mint ownership by design: an
orderFormIdis not asecret, so granting ownership on read would let anyone holding an ID unmask
another shopper's PII.
Follow-up.
replaceDomainderives the cookie domain fromx-forwarded-host.On a custom storefront domain this could diverge from the domain Checkout uses
and produce two cookies of the same name — and Checkout honours the last one,
which re-masks the data. Worth one test on a custom-domain account.