File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
88## [ Unreleased]
99
10+ ## [ 3.77.3] - 2021-10-22
11+ ### Fixed
12+ - Extract session cookie in a safe manner
13+
14+ ## [ 3.77.2] - 2021-08-26
15+ ### Fixed
16+ - Extract session cookie in a safe manner
17+
1018## [ 3.77.1] - 2021-02-05
1119- Increase HTTP agents connection pools freeSockets and lifetime
1220
Original file line number Diff line number Diff line change 11{
22 "name" : " @vtex/api" ,
3- "version" : " 3.77.2 " ,
3+ "version" : " 3.77.3 " ,
44 "description" : " VTEX I/O API client" ,
55 "main" : " lib/index.js" ,
66 "typings" : " lib/index.d.ts" ,
Original file line number Diff line number Diff line change 1- import parseCookie from 'cookie'
21import { prop } from 'ramda'
32
43import { PRODUCT_HEADER } from '../constants'
54import { inflightUrlWithQuery , JanusClient } from '../HttpClient'
5+ import { extractSessionCookie } from './Session'
66
77export interface SegmentData {
88 campaigns ?: any
@@ -19,7 +19,6 @@ export interface SegmentData {
1919 [ key : string ] : any
2020}
2121
22- const SEGMENT_COOKIE = 'vtex_segment'
2322const SEGMENT_MAX_AGE_S = 60 * 60 // 60 minutes - segment is actually immutable
2423const ALLOWED_QUERY_PREFIXES = [ 'utm' , 'cultureInfo' , 'supportedLocales' ]
2524
@@ -71,15 +70,11 @@ export class Segment extends JanusClient {
7170 public getOrCreateSegment = async ( query ?: Record < string , string > , token ?: string ) => {
7271 const {
7372 data : segmentData ,
74- headers : {
75- 'set-cookie' : [ setCookies ] ,
76- } ,
73+ headers,
7774 } = await this . rawSegment ( token , query )
78- const parsedCookie = parseCookie . parse ( setCookies )
79- const segmentToken = prop ( SEGMENT_COOKIE , parsedCookie )
8075 return {
8176 segmentData,
82- segmentToken,
77+ segmentToken : extractSessionCookie ( headers ) || token ,
8378 }
8479 }
8580
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export class Session extends JanusClient {
5151 }
5252}
5353
54- function extractSessionCookie ( headers : Record < string , string > ) {
54+ export function extractSessionCookie ( headers : Record < string , string > ) {
5555 for ( const setCookie of headers [ 'set-cookie' ] || [ ] ) {
5656 const parsedCookie = parseCookie . parse ( setCookie )
5757 const sessionCookie = parsedCookie [ SESSION_COOKIE ]
You can’t perform that action at this time.
0 commit comments