@faststore/api 3.90.0 → 3.91.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/directives/auth.d.ts +4 -0
- package/dist/cjs/src/directives/auth.d.ts.map +1 -0
- package/dist/cjs/src/directives/auth.js +27 -0
- package/dist/cjs/src/directives/auth.js.map +1 -0
- package/dist/cjs/src/index.d.ts +3 -2
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/index.js +6 -2
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/index.d.ts +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/query.js +10 -20
- package/dist/cjs/src/platforms/vtex/resolvers/query.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js +23 -6
- package/dist/cjs/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/utils/auth.d.ts +6 -0
- package/dist/cjs/src/platforms/vtex/utils/auth.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/utils/auth.js +26 -1
- package/dist/cjs/src/platforms/vtex/utils/auth.js.map +1 -1
- package/dist/cjs/src/platforms/vtex/utils/cookies.d.ts.map +1 -1
- package/dist/cjs/src/platforms/vtex/utils/cookies.js +36 -3
- package/dist/cjs/src/platforms/vtex/utils/cookies.js.map +1 -1
- package/dist/cjs/src/typeDefs/query.graphql +21 -16
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/directives/auth.d.ts +4 -0
- package/dist/esm/src/directives/auth.d.ts.map +1 -0
- package/dist/esm/src/directives/auth.js +25 -0
- package/dist/esm/src/directives/auth.js.map +1 -0
- package/dist/esm/src/index.d.ts +3 -2
- package/dist/esm/src/index.d.ts.map +1 -1
- package/dist/esm/src/index.js +4 -2
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/platforms/vtex/index.d.ts +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/query.d.ts +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/query.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/query.js +10 -20
- package/dist/esm/src/platforms/vtex/resolvers/query.js.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.js +23 -6
- package/dist/esm/src/platforms/vtex/resolvers/validateSession.js.map +1 -1
- package/dist/esm/src/platforms/vtex/utils/auth.d.ts +6 -0
- package/dist/esm/src/platforms/vtex/utils/auth.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/utils/auth.js +25 -1
- package/dist/esm/src/platforms/vtex/utils/auth.js.map +1 -1
- package/dist/esm/src/platforms/vtex/utils/cookies.d.ts.map +1 -1
- package/dist/esm/src/platforms/vtex/utils/cookies.js +36 -3
- package/dist/esm/src/platforms/vtex/utils/cookies.js.map +1 -1
- package/dist/esm/src/typeDefs/query.graphql +21 -16
- package/package.json +2 -2
- package/src/directives/auth.ts +34 -0
- package/src/index.ts +7 -2
- package/src/platforms/vtex/resolvers/query.ts +14 -25
- package/src/platforms/vtex/resolvers/validateSession.ts +25 -6
- package/src/platforms/vtex/utils/auth.ts +35 -1
- package/src/platforms/vtex/utils/cookies.ts +42 -3
- package/src/typeDefs/query.graphql +21 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../../../../src/platforms/vtex/utils/cookies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAQ9B,MAAM,gCAAgC,GAAG,kBAAkB,CAAA;AAE3D;;;;;;;;;GASG;AACH,MAAM,CAAC,M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AAA;QAEF,MAAM,qBAAqB,GAAG,aAAa,CACzC,GAAG,EAAE,OAAO,EAAE,MAAM,IAAI,EAAE,EAC1B,OAAO,CACR,CAAA;QACD,OAAO,CAAC,uBAAuB,CAAC,GAAG,qBAAqB,CAAA;QAExD,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,eAAuB,EACvB,gBAAwB,EACxB,kBAA0B,EAC1B,EAAE;IACF,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,IAAI,gBAAgB,WAAW,CAAC,CAAA;IAC1E,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAEjE,4DAA4D;IAC5D,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,eAAe,CAAC,OAAO,CAC5B,WAAW,CAAC,CAAC,CAAC,EACd,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,kBAAkB,EAAE,CAC1C,CAAA;IACH,CAAC;IAED,yDAAyD;IACzD,OAAO,GAAG,eAAe,IAAI,gBAAgB,IAAI,kBAAkB,EAAE,CAAA;AACvE,CAAC,CAAA;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -216,7 +216,7 @@ type Query {
|
|
|
216
216
|
"""
|
|
217
217
|
locator: [IStoreSelectedFacet!]!
|
|
218
218
|
): StoreProduct!
|
|
219
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
219
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
220
220
|
|
|
221
221
|
"""
|
|
222
222
|
Returns the details of a collection based on the collection slug.
|
|
@@ -227,7 +227,7 @@ type Query {
|
|
|
227
227
|
"""
|
|
228
228
|
slug: String!
|
|
229
229
|
): StoreCollection!
|
|
230
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
230
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
231
231
|
|
|
232
232
|
"""
|
|
233
233
|
Returns the result of a product, facet, or suggestion search.
|
|
@@ -258,7 +258,7 @@ type Query {
|
|
|
258
258
|
"""
|
|
259
259
|
sponsoredCount: Int
|
|
260
260
|
): StoreSearchResult!
|
|
261
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
261
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
262
262
|
|
|
263
263
|
"""
|
|
264
264
|
Returns information about all products.
|
|
@@ -273,13 +273,13 @@ type Query {
|
|
|
273
273
|
"""
|
|
274
274
|
after: String
|
|
275
275
|
): StoreProductConnection!
|
|
276
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
276
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
277
277
|
|
|
278
278
|
"""
|
|
279
279
|
Returns information about selected products.
|
|
280
280
|
"""
|
|
281
281
|
products(productIds: [String!]!): [StoreProduct!]!
|
|
282
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
282
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
283
283
|
|
|
284
284
|
"""
|
|
285
285
|
Returns information about all collections.
|
|
@@ -294,7 +294,7 @@ type Query {
|
|
|
294
294
|
"""
|
|
295
295
|
after: String
|
|
296
296
|
): StoreCollectionConnection!
|
|
297
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
297
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
298
298
|
|
|
299
299
|
"""
|
|
300
300
|
Returns information about shipping simulation.
|
|
@@ -313,7 +313,7 @@ type Query {
|
|
|
313
313
|
"""
|
|
314
314
|
country: String!
|
|
315
315
|
): ShippingData
|
|
316
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
316
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
317
317
|
|
|
318
318
|
"""
|
|
319
319
|
Returns if there's a redirect for a search.
|
|
@@ -350,7 +350,7 @@ type Query {
|
|
|
350
350
|
"""
|
|
351
351
|
salesChannel: String
|
|
352
352
|
): SellersData
|
|
353
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
353
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
354
354
|
|
|
355
355
|
"""
|
|
356
356
|
Returns information about the profile.
|
|
@@ -361,7 +361,7 @@ type Query {
|
|
|
361
361
|
"""
|
|
362
362
|
id: String!
|
|
363
363
|
): Profile
|
|
364
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
364
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
365
365
|
|
|
366
366
|
"""
|
|
367
367
|
Returns the total product count information based on a specific location accessible through the VTEX segment cookie.
|
|
@@ -372,7 +372,7 @@ type Query {
|
|
|
372
372
|
"""
|
|
373
373
|
term: String
|
|
374
374
|
): ProductCountResult
|
|
375
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
375
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
376
376
|
|
|
377
377
|
"""
|
|
378
378
|
Returns information about the Details of an User Order.
|
|
@@ -383,7 +383,8 @@ type Query {
|
|
|
383
383
|
"""
|
|
384
384
|
orderId: String!
|
|
385
385
|
): UserOrderResult
|
|
386
|
-
@
|
|
386
|
+
@auth
|
|
387
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
387
388
|
|
|
388
389
|
"""
|
|
389
390
|
Returns information about the list of Orders that the User can view.
|
|
@@ -418,25 +419,29 @@ type Query {
|
|
|
418
419
|
"""
|
|
419
420
|
clientEmail: String
|
|
420
421
|
): UserOrderListMinimalResult
|
|
421
|
-
@
|
|
422
|
+
@auth
|
|
423
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
422
424
|
|
|
423
425
|
"""
|
|
424
426
|
Returns information about the current user details.
|
|
425
427
|
"""
|
|
426
428
|
userDetails: StoreUserDetails!
|
|
427
|
-
@
|
|
429
|
+
@auth
|
|
430
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
428
431
|
|
|
429
432
|
"""
|
|
430
433
|
Returns the account profile information for the current authenticated user (b2b or b2c user).
|
|
431
434
|
"""
|
|
432
435
|
accountProfile: StoreAccountProfile!
|
|
433
|
-
@
|
|
436
|
+
@auth
|
|
437
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
434
438
|
|
|
435
439
|
"""
|
|
436
440
|
Returns information about the user validation.
|
|
437
441
|
"""
|
|
438
442
|
validateUser: ValidateUserData
|
|
439
|
-
@
|
|
443
|
+
@auth
|
|
444
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
440
445
|
|
|
441
446
|
"""
|
|
442
447
|
Returns a list of pickup points near to the given geo coordinates.
|
|
@@ -447,7 +452,7 @@ type Query {
|
|
|
447
452
|
"""
|
|
448
453
|
geoCoordinates: IStoreGeoCoordinates
|
|
449
454
|
): PickupPoints
|
|
450
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
455
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
451
456
|
}
|
|
452
457
|
|
|
453
458
|
type ValidateUserData {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.91.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/src/index.js",
|
|
6
6
|
"typings": "dist/esm/src/index.d.ts",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"volta": {
|
|
74
74
|
"extends": "../../package.json"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "6fa73a4cd395be39afc7e376c45beb3201bc50a9"
|
|
77
77
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getDirective, MapperKind, mapSchema } from '@graphql-tools/utils'
|
|
2
|
+
import type { GraphQLSchema } from 'graphql'
|
|
3
|
+
|
|
4
|
+
import { validateUserAuthentication } from '../platforms/vtex/utils/auth'
|
|
5
|
+
import type { Directive } from './index'
|
|
6
|
+
|
|
7
|
+
const NAME = 'auth'
|
|
8
|
+
|
|
9
|
+
const directive: Directive = {
|
|
10
|
+
typeDefs: `directive @auth on FIELD_DEFINITION`,
|
|
11
|
+
transformer: (schema: GraphQLSchema) => {
|
|
12
|
+
return mapSchema(schema, {
|
|
13
|
+
[MapperKind.OBJECT_FIELD]: (fieldConfig) => {
|
|
14
|
+
const authDirective = getDirective(schema, fieldConfig, NAME)?.[0]
|
|
15
|
+
|
|
16
|
+
if (authDirective) {
|
|
17
|
+
const originalResolver = fieldConfig.resolve
|
|
18
|
+
|
|
19
|
+
fieldConfig.resolve = async (root, args, context, info) => {
|
|
20
|
+
// Validate user authentication before proceeding with the resolver
|
|
21
|
+
await validateUserAuthentication(context)
|
|
22
|
+
|
|
23
|
+
// Continue with the original resolver
|
|
24
|
+
return originalResolver?.(root, args, context, info)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return fieldConfig
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default directive
|
package/src/index.ts
CHANGED
|
@@ -5,13 +5,18 @@ import {
|
|
|
5
5
|
getResolvers as getResolversVTEX,
|
|
6
6
|
} from './platforms/vtex'
|
|
7
7
|
import { typeDefs } from './typeDefs'
|
|
8
|
+
import authDirective from './directives/auth'
|
|
8
9
|
import cacheControlDirective from './directives/cacheControl'
|
|
9
10
|
import type { Directive } from './directives'
|
|
10
11
|
import type { Options as OptionsVTEX } from './platforms/vtex'
|
|
11
12
|
|
|
12
13
|
export * from './__generated__/schema'
|
|
13
14
|
export * from './platforms/errors'
|
|
14
|
-
export {
|
|
15
|
+
export { default as authDirective } from './directives/auth'
|
|
16
|
+
export {
|
|
17
|
+
default as cacheControlDirective,
|
|
18
|
+
stringify as stringifyCacheControl,
|
|
19
|
+
} from './directives/cacheControl'
|
|
15
20
|
export type { CacheControl } from './directives/cacheControl'
|
|
16
21
|
|
|
17
22
|
export type Options = OptionsVTEX
|
|
@@ -23,7 +28,7 @@ const platforms = {
|
|
|
23
28
|
},
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
const directives: Directive[] = [cacheControlDirective]
|
|
31
|
+
const directives: Directive[] = [cacheControlDirective, authDirective]
|
|
27
32
|
|
|
28
33
|
export const getTypeDefs = () => [
|
|
29
34
|
typeDefs,
|
|
@@ -424,14 +424,15 @@ export const Query = {
|
|
|
424
424
|
{ orderId }: QueryUserOrderArgs,
|
|
425
425
|
ctx: Context
|
|
426
426
|
) => {
|
|
427
|
-
const {
|
|
428
|
-
clients: { commerce },
|
|
429
|
-
} = ctx
|
|
430
|
-
if (!orderId) {
|
|
431
|
-
throw new BadRequestError('Missing orderId')
|
|
432
|
-
}
|
|
433
|
-
|
|
434
427
|
try {
|
|
428
|
+
if (!orderId) {
|
|
429
|
+
throw new BadRequestError('Missing orderId')
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const {
|
|
433
|
+
clients: { commerce },
|
|
434
|
+
} = ctx
|
|
435
|
+
|
|
435
436
|
const order = await commerce.oms.userOrder({ orderId })
|
|
436
437
|
|
|
437
438
|
if (!order) {
|
|
@@ -530,6 +531,7 @@ export const Query = {
|
|
|
530
531
|
} = ctx
|
|
531
532
|
|
|
532
533
|
const orders = await commerce.oms.listUserOrders(filters)
|
|
534
|
+
|
|
533
535
|
return {
|
|
534
536
|
list: orders.list?.map((order: UserOrderFromList) => ({
|
|
535
537
|
orderId: order.orderId,
|
|
@@ -546,23 +548,11 @@ export const Query = {
|
|
|
546
548
|
paging: orders.paging,
|
|
547
549
|
}
|
|
548
550
|
},
|
|
549
|
-
validateUser: async (_: unknown, __: unknown,
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
// This resolver is used to validate if the user is logged in
|
|
555
|
-
// and has access to the account area.
|
|
556
|
-
// If the user is not logged in, it will throw an error.
|
|
557
|
-
// If the user is logged in, it will return true.
|
|
558
|
-
try {
|
|
559
|
-
const response = await commerce.vtexid.validate()
|
|
560
|
-
|
|
561
|
-
return {
|
|
562
|
-
isValid: response.authStatus === 'Success',
|
|
563
|
-
}
|
|
564
|
-
} catch (error) {
|
|
565
|
-
throw new ForbiddenError('You are not allowed to access this resource')
|
|
551
|
+
validateUser: async (_: unknown, __: unknown, _ctx: Context) => {
|
|
552
|
+
// Authentication is now handled by @auth directive
|
|
553
|
+
// If we reach here, validation was successful, otherwise an error would have been thrown
|
|
554
|
+
return {
|
|
555
|
+
isValid: true,
|
|
566
556
|
}
|
|
567
557
|
},
|
|
568
558
|
// only b2b users
|
|
@@ -571,7 +561,6 @@ export const Query = {
|
|
|
571
561
|
clients: { commerce },
|
|
572
562
|
} = ctx
|
|
573
563
|
|
|
574
|
-
// const params = new URLSearchParams()
|
|
575
564
|
const sessionData = await commerce.session('').catch(() => null)
|
|
576
565
|
|
|
577
566
|
const shopper = sessionData?.namespaces.shopper ?? null
|
|
@@ -97,9 +97,22 @@ export const validateSession = async (
|
|
|
97
97
|
|
|
98
98
|
const jwt = parseJwt(getAuthCookie(headers?.cookie ?? '', account))
|
|
99
99
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
// Validate JWT token if it exists
|
|
101
|
+
let isValidJwt = false
|
|
102
|
+
if (jwt) {
|
|
103
|
+
try {
|
|
104
|
+
const vtexIdResponse = await clients.commerce.vtexid.validate()
|
|
105
|
+
isValidJwt = vtexIdResponse?.authStatus?.toLowerCase() === 'success'
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.warn('JWT validation failed:', error)
|
|
108
|
+
isValidJwt = false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Only use JWT data if the token is valid
|
|
113
|
+
const isRepresentative = isValidJwt ? jwt?.isRepresentative : false
|
|
114
|
+
const customerId = isValidJwt ? jwt?.customerId : undefined
|
|
115
|
+
const unitId = isValidJwt ? jwt?.unitId : undefined
|
|
103
116
|
|
|
104
117
|
const sessionData = await clients.commerce
|
|
105
118
|
.session(params.toString())
|
|
@@ -164,10 +177,16 @@ export const validateSession = async (
|
|
|
164
177
|
customerId: authentication?.customerId?.value ?? customerId ?? '',
|
|
165
178
|
unitName: authentication?.unitName?.value ?? '',
|
|
166
179
|
unitId: authentication?.unitId?.value ?? unitId ?? '',
|
|
167
|
-
firstName:
|
|
168
|
-
|
|
180
|
+
firstName:
|
|
181
|
+
typeof shopper?.firstName?.value === 'string'
|
|
182
|
+
? shopper.firstName.value
|
|
183
|
+
: '',
|
|
184
|
+
lastName:
|
|
185
|
+
typeof shopper?.lastName?.value === 'string'
|
|
186
|
+
? shopper.lastName.value
|
|
187
|
+
: '',
|
|
169
188
|
userName:
|
|
170
|
-
`${shopper?.firstName?.value
|
|
189
|
+
`${typeof shopper?.firstName?.value === 'string' ? shopper.firstName.value : ''} ${typeof shopper?.lastName?.value === 'string' ? shopper.lastName.value : ''}`.trim(),
|
|
171
190
|
userEmail: authentication?.storeUserEmail.value ?? '',
|
|
172
191
|
savedPostalCode: publicData?.postalCode?.value ?? '',
|
|
173
192
|
contractName: contract?.corporateName ?? '',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ForbiddenError } from '../../..'
|
|
1
|
+
import { ForbiddenError, UnauthorizedError } from '../../..'
|
|
2
|
+
import type { Context } from '../index'
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Creates a function that adds VTEX API AppKey and AppToken headers to requests.
|
|
@@ -25,3 +26,36 @@ export const getWithAppKeyAndToken = () => {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Utility function to validate user authentication
|
|
32
|
+
* Centralized validation logic for all account-related resolvers
|
|
33
|
+
*/
|
|
34
|
+
export const validateUserAuthentication = async (
|
|
35
|
+
ctx: Context
|
|
36
|
+
): Promise<void> => {
|
|
37
|
+
const {
|
|
38
|
+
clients: { commerce },
|
|
39
|
+
} = ctx
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const validation = await commerce.vtexid.validate()
|
|
43
|
+
|
|
44
|
+
if (validation?.authStatus?.toLowerCase() !== 'success') {
|
|
45
|
+
throw new UnauthorizedError('Authentication required')
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const status = (error as any).extensions?.status ?? (error as any).status
|
|
49
|
+
|
|
50
|
+
if (status === 401) {
|
|
51
|
+
throw new UnauthorizedError('Authentication required')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (status === 403) {
|
|
55
|
+
throw new ForbiddenError('You are not allowed to access this resource')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// For any other error, throw UnauthorizedError as it likely needs token refresh
|
|
59
|
+
throw new UnauthorizedError('Authentication required')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -6,6 +6,42 @@ export interface ContextForCookies {
|
|
|
6
6
|
storage: Pick<Context['storage'], 'cookies'>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes cookie string by removing duplicates and keeping the last value for each key
|
|
11
|
+
* Example: "key1=value1; key2=value2; key1=value3" -> "key2=value2; key1=value3"
|
|
12
|
+
*/
|
|
13
|
+
const normalizeCookies = (cookieString: string): string => {
|
|
14
|
+
if (!cookieString) {
|
|
15
|
+
return cookieString
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cookieMap = new Map<string, string>()
|
|
19
|
+
const cookies = cookieString.split(';')
|
|
20
|
+
const processedKeys: string[] = []
|
|
21
|
+
|
|
22
|
+
// Process cookies to build map with last values and track order
|
|
23
|
+
cookies.forEach((cookie) => {
|
|
24
|
+
const trimmedCookie = cookie.trim()
|
|
25
|
+
if (trimmedCookie) {
|
|
26
|
+
const equalIndex = trimmedCookie.indexOf('=')
|
|
27
|
+
if (equalIndex > 0) {
|
|
28
|
+
const key = trimmedCookie.substring(0, equalIndex)
|
|
29
|
+
const value = trimmedCookie.substring(equalIndex + 1)
|
|
30
|
+
|
|
31
|
+
// If this is the first time we see this key, record its position
|
|
32
|
+
if (!cookieMap.has(key)) {
|
|
33
|
+
processedKeys.push(key)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
cookieMap.set(key, value)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
// Rebuild cookie string maintaining the order of first appearance
|
|
42
|
+
return processedKeys.map((key) => `${key}=${cookieMap.get(key)}`).join('; ')
|
|
43
|
+
}
|
|
44
|
+
|
|
9
45
|
const MATCH_FIRST_SET_COOKIE_KEY_VALUE = /^([^=]+)=([^;]*)/
|
|
10
46
|
|
|
11
47
|
/**
|
|
@@ -64,10 +100,12 @@ export const getUpdatedCookie = (ctx: ContextForCookies) => {
|
|
|
64
100
|
return null
|
|
65
101
|
}
|
|
66
102
|
|
|
103
|
+
// Normalize cookies to handle duplicates (keep last value)
|
|
104
|
+
const normalizedCookie = normalizeCookies(ctx.headers.cookie)
|
|
67
105
|
const contextStorageCookies = Array.from(ctx.storage.cookies.entries())
|
|
68
106
|
|
|
69
107
|
if (contextStorageCookies.length === 0) {
|
|
70
|
-
return
|
|
108
|
+
return normalizedCookie
|
|
71
109
|
}
|
|
72
110
|
|
|
73
111
|
return contextStorageCookies.reduce(
|
|
@@ -77,7 +115,7 @@ export const getUpdatedCookie = (ctx: ContextForCookies) => {
|
|
|
77
115
|
storageCookieKey,
|
|
78
116
|
storageCookieValue
|
|
79
117
|
),
|
|
80
|
-
|
|
118
|
+
normalizedCookie
|
|
81
119
|
)
|
|
82
120
|
}
|
|
83
121
|
|
|
@@ -98,7 +136,8 @@ export const getWithCookie = (ctx: ContextForCookies) =>
|
|
|
98
136
|
}
|
|
99
137
|
|
|
100
138
|
export const getAuthCookie = (cookies: string, account: string) => {
|
|
101
|
-
const
|
|
139
|
+
const normalizedCookies = normalizeCookies(cookies)
|
|
140
|
+
const parsedCookies = parse(normalizedCookies)
|
|
102
141
|
const authCookie = parsedCookies[`VtexIdclientAutCookie_${account}`]
|
|
103
142
|
return authCookie || ''
|
|
104
143
|
}
|
|
@@ -216,7 +216,7 @@ type Query {
|
|
|
216
216
|
"""
|
|
217
217
|
locator: [IStoreSelectedFacet!]!
|
|
218
218
|
): StoreProduct!
|
|
219
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
219
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
220
220
|
|
|
221
221
|
"""
|
|
222
222
|
Returns the details of a collection based on the collection slug.
|
|
@@ -227,7 +227,7 @@ type Query {
|
|
|
227
227
|
"""
|
|
228
228
|
slug: String!
|
|
229
229
|
): StoreCollection!
|
|
230
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
230
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
231
231
|
|
|
232
232
|
"""
|
|
233
233
|
Returns the result of a product, facet, or suggestion search.
|
|
@@ -258,7 +258,7 @@ type Query {
|
|
|
258
258
|
"""
|
|
259
259
|
sponsoredCount: Int
|
|
260
260
|
): StoreSearchResult!
|
|
261
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
261
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
262
262
|
|
|
263
263
|
"""
|
|
264
264
|
Returns information about all products.
|
|
@@ -273,13 +273,13 @@ type Query {
|
|
|
273
273
|
"""
|
|
274
274
|
after: String
|
|
275
275
|
): StoreProductConnection!
|
|
276
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
276
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
277
277
|
|
|
278
278
|
"""
|
|
279
279
|
Returns information about selected products.
|
|
280
280
|
"""
|
|
281
281
|
products(productIds: [String!]!): [StoreProduct!]!
|
|
282
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
282
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
283
283
|
|
|
284
284
|
"""
|
|
285
285
|
Returns information about all collections.
|
|
@@ -294,7 +294,7 @@ type Query {
|
|
|
294
294
|
"""
|
|
295
295
|
after: String
|
|
296
296
|
): StoreCollectionConnection!
|
|
297
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
297
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
298
298
|
|
|
299
299
|
"""
|
|
300
300
|
Returns information about shipping simulation.
|
|
@@ -313,7 +313,7 @@ type Query {
|
|
|
313
313
|
"""
|
|
314
314
|
country: String!
|
|
315
315
|
): ShippingData
|
|
316
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
316
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
317
317
|
|
|
318
318
|
"""
|
|
319
319
|
Returns if there's a redirect for a search.
|
|
@@ -350,7 +350,7 @@ type Query {
|
|
|
350
350
|
"""
|
|
351
351
|
salesChannel: String
|
|
352
352
|
): SellersData
|
|
353
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
353
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
354
354
|
|
|
355
355
|
"""
|
|
356
356
|
Returns information about the profile.
|
|
@@ -361,7 +361,7 @@ type Query {
|
|
|
361
361
|
"""
|
|
362
362
|
id: String!
|
|
363
363
|
): Profile
|
|
364
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
364
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
365
365
|
|
|
366
366
|
"""
|
|
367
367
|
Returns the total product count information based on a specific location accessible through the VTEX segment cookie.
|
|
@@ -372,7 +372,7 @@ type Query {
|
|
|
372
372
|
"""
|
|
373
373
|
term: String
|
|
374
374
|
): ProductCountResult
|
|
375
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
375
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
376
376
|
|
|
377
377
|
"""
|
|
378
378
|
Returns information about the Details of an User Order.
|
|
@@ -383,7 +383,8 @@ type Query {
|
|
|
383
383
|
"""
|
|
384
384
|
orderId: String!
|
|
385
385
|
): UserOrderResult
|
|
386
|
-
@
|
|
386
|
+
@auth
|
|
387
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
387
388
|
|
|
388
389
|
"""
|
|
389
390
|
Returns information about the list of Orders that the User can view.
|
|
@@ -418,25 +419,29 @@ type Query {
|
|
|
418
419
|
"""
|
|
419
420
|
clientEmail: String
|
|
420
421
|
): UserOrderListMinimalResult
|
|
421
|
-
@
|
|
422
|
+
@auth
|
|
423
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
422
424
|
|
|
423
425
|
"""
|
|
424
426
|
Returns information about the current user details.
|
|
425
427
|
"""
|
|
426
428
|
userDetails: StoreUserDetails!
|
|
427
|
-
@
|
|
429
|
+
@auth
|
|
430
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
428
431
|
|
|
429
432
|
"""
|
|
430
433
|
Returns the account profile information for the current authenticated user (b2b or b2c user).
|
|
431
434
|
"""
|
|
432
435
|
accountProfile: StoreAccountProfile!
|
|
433
|
-
@
|
|
436
|
+
@auth
|
|
437
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
434
438
|
|
|
435
439
|
"""
|
|
436
440
|
Returns information about the user validation.
|
|
437
441
|
"""
|
|
438
442
|
validateUser: ValidateUserData
|
|
439
|
-
@
|
|
443
|
+
@auth
|
|
444
|
+
@cacheControl(scope: "private", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
440
445
|
|
|
441
446
|
"""
|
|
442
447
|
Returns a list of pickup points near to the given geo coordinates.
|
|
@@ -447,7 +452,7 @@ type Query {
|
|
|
447
452
|
"""
|
|
448
453
|
geoCoordinates: IStoreGeoCoordinates
|
|
449
454
|
): PickupPoints
|
|
450
|
-
@cacheControl(scope: "public", sMaxAge:
|
|
455
|
+
@cacheControl(scope: "public", sMaxAge: 300, staleWhileRevalidate: 3600)
|
|
451
456
|
}
|
|
452
457
|
|
|
453
458
|
type ValidateUserData {
|