File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
apps/backend/src/shared/infra/http Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,20 @@ async function authenticateWithApiKey(
15
15
res : MedusaResponse ,
16
16
next : NextFunction
17
17
) {
18
+ const service = req . scope . resolve < SellerModuleService > ( SELLER_MODULE )
18
19
const token = req . headers . authorization ?. split ( ' ' ) [ 1 ] || ''
19
20
20
- const service = req . scope . resolve < SellerModuleService > ( SELLER_MODULE )
21
+ let normalizedToken = token
22
+ if ( ! token . startsWith ( 'ssk_' ) ) {
23
+ normalizedToken = Buffer . from ( token , 'base64' ) . toString ( 'utf-8' )
24
+ }
25
+
26
+ if ( normalizedToken . endsWith ( ':' ) ) {
27
+ normalizedToken = normalizedToken . slice ( 0 , - 1 )
28
+ }
21
29
22
30
const [ api_key ] = await service . listSellerApiKeys ( {
23
- token : service . calculateHash ( token )
31
+ token : service . calculateHash ( normalizedToken )
24
32
} )
25
33
26
34
if ( ! api_key || api_key . revoked_at !== null || api_key . deleted_at !== null ) {
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export const fetchSellerByAuthContext = async (
38
38
return fetchSellerByAuthActorId ( ctx . actor_id , scope , fields )
39
39
}
40
40
41
- if ( ctx . actor_type === 'seller_api_key ' ) {
41
+ if ( ctx . actor_type === 'seller-api-key ' ) {
42
42
const {
43
43
data : [ api_key ]
44
44
} = await query . graph ( {
You can’t perform that action at this time.
0 commit comments