Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Forward `VtexRCSessionIdv7` and `VtexRCMacIdv7` cookies to the Checkout API

## [2.177.0] - 2026-05-07

### Changed
Expand Down
7 changes: 5 additions & 2 deletions node/clients/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Checkout extends JanusClient {
}

private getCommonHeaders = () => {
const { orderFormId, ownerId, segmentToken, sessionToken } = this
const { orderFormId, ownerId, segmentToken, sessionToken, rcSessionIdv7, rcMacIdv7 } = this
.context as CustomIOContext

const checkoutCookie = orderFormId ? checkoutCookieFormat(orderFormId) : ''
Expand All @@ -43,8 +43,11 @@ export class Checkout extends JanusClient {
? `vtex_session=${sessionToken};`
: ''

const rcSessionCookie = rcSessionIdv7 ? `VtexRCSessionIdv7=${rcSessionIdv7};` : ''
const rcMacCookie = rcMacIdv7 ? `VtexRCMacIdv7=${rcMacIdv7};` : ''

return {
Cookie: `${checkoutCookie}${ownershipCookie}${segmentTokenCookie}${sessionTokenCookie}`,
Cookie: `${checkoutCookie}${ownershipCookie}${segmentTokenCookie}${sessionTokenCookie}${rcSessionCookie}${rcMacCookie}`,
}
}

Expand Down
8 changes: 4 additions & 4 deletions node/directives/withOwnerId.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { defaultFieldResolver, GraphQLField } from 'graphql'
import { SchemaDirectiveVisitor } from 'graphql-tools'

import { getOwnerIdFromCookie } from '../utils'
import { getOwnerIdFromCookie, getRcSessionIdFromCookie, getRcMacIdFromCookie } from '../utils'

export class WithOwnerId extends SchemaDirectiveVisitor {
public visitFieldDefinition(field: GraphQLField<any, any>) {
const { resolve = defaultFieldResolver } = field

field.resolve = async (root: any, args: any, ctx: Context, info: any) => {
const checkoutOwnerId = getOwnerIdFromCookie(ctx.cookies)

ctx.vtex.ownerId = checkoutOwnerId
ctx.vtex.ownerId = getOwnerIdFromCookie(ctx.cookies)
ctx.vtex.rcSessionIdv7 = getRcSessionIdFromCookie(ctx.cookies)
ctx.vtex.rcMacIdv7 = getRcMacIdFromCookie(ctx.cookies)

return resolve(root, args, ctx, info)
}
Expand Down
2 changes: 2 additions & 0 deletions node/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ declare global {
segment?: SegmentData
orderFormId?: string
ownerId?: string
rcSessionIdv7?: string
rcMacIdv7?: string
}

interface UserAddress {
Expand Down
13 changes: 13 additions & 0 deletions node/utils/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,24 @@ export function getOwnerIdFromCookie(cookies: Context['cookies']) {
return cookies.get(OWNERSHIP_COOKIE)
}

const RC_SESSION_COOKIE = 'VtexRCSessionIdv7'
const RC_MAC_COOKIE = 'VtexRCMacIdv7'

export function getRcSessionIdFromCookie(cookies: Context['cookies']) {
return cookies.get(RC_SESSION_COOKIE)
}

export function getRcMacIdFromCookie(cookies: Context['cookies']) {
return cookies.get(RC_MAC_COOKIE)
}

export {
isUserLoggedIn,
CHECKOUT_COOKIE,
ASPXAUTH_COOKIE,
OWNERSHIP_COOKIE,
RC_SESSION_COOKIE,
RC_MAC_COOKIE,
checkoutCookieFormat,
getOrderFormIdFromCookie,
parseCookie,
Expand Down
Loading