@akinon/next 2.0.10-rc.0 → 2.0.11-beta.0
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/CHANGELOG.md +8 -22
- package/bin/pz-generate-routes.js +1 -4
- package/components/plugin-module.tsx +1 -0
- package/data/client/checkout.ts +1 -0
- package/data/server/category.ts +2 -14
- package/data/server/list.ts +1 -13
- package/data/server/product.ts +0 -10
- package/data/server/special-page.ts +1 -14
- package/data/server/widget.ts +1 -14
- package/data/urls.ts +1 -5
- package/hooks/use-captcha.tsx +1 -1
- package/middlewares/default.ts +1 -2
- package/middlewares/masterpass-rest-callback.ts +147 -34
- package/package.json +3 -4
- package/plugins.d.ts +0 -10
- package/plugins.js +0 -1
- package/redux/middlewares/checkout.ts +3 -45
- package/redux/middlewares/pre-order/installment-option.ts +1 -9
- package/types/index.ts +0 -7
- package/with-pz-config.js +1 -2
- package/bin/pz-migrate-eslint.js +0 -6
- package/codemods/migrate-eslint-flat.js +0 -247
- package/utils/payload-optimizer.ts +0 -481
package/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 2.0.
|
|
3
|
+
## 2.0.11-beta.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- 7889b08f: ZERO-4276: Enhance route generation by adding .env loading and custom skip segments support
|
|
15
|
-
- 9f8cd3bc5: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
|
|
16
|
-
- bfafa3f4: ZERO-4160: Refactor oauth-login middleware to use fetchCommerce for API calls and improve cookie handling
|
|
17
|
-
- 57d7eb30: ZERO-4276: Refactor route generation logic by removing environment loading and simplifying skip segments handling
|
|
18
|
-
- d99a6a7d5: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
|
|
19
|
-
- 9db81a71: ZERO-4365: Remove brand `@theme/*` alias imports from library packages
|
|
20
|
-
- 591e345e: ZERO-3855: Enhance credit card payment handling in checkout middlewares
|
|
21
|
-
- 4de5303c5: ZERO-2504: add cookie filter to api client request
|
|
22
|
-
- 95b139dc1: ZERO-3795: Remove duplicate entry for SavedCard in PluginComponents map
|
|
23
|
-
- 1d00f2d0: BRDG-16664: Set secure flag for CSRF token cookies in useCaptcha and default middleware
|
|
24
|
-
- 4ac7b2a1: ZERO-4219: fix masterpass-rest callback route format and double-encoded error cookie
|
|
25
|
-
- 4998a963: ZERO-4168: Add server-side payload optimization
|
|
26
|
-
- 3909d322: Edit the duplicate Plugin.SimilarProducts in the plugin-module.
|
|
27
|
-
- e18836b2: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
|
|
7
|
+
- cbbbfd75: ZERO-4376: Bootstrap beta cycle (next-main pre-release motor)
|
|
8
|
+
|
|
9
|
+
## 2.0.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 31f07bd7: ZERO-4459: Move migrate-eslint codemod into @akinon/projectzero and integrate into upgrade-to-2
|
|
28
14
|
|
|
29
15
|
## 2.0.9
|
|
30
16
|
|
|
@@ -6,7 +6,6 @@ const findBaseDir = require('../utils/find-base-dir');
|
|
|
6
6
|
|
|
7
7
|
const generateRoutes = () => {
|
|
8
8
|
const baseDir = findBaseDir();
|
|
9
|
-
|
|
10
9
|
const srcDir = path.join(baseDir, 'src');
|
|
11
10
|
const appDir = path.join(srcDir, 'app');
|
|
12
11
|
|
|
@@ -35,10 +34,8 @@ const generateRoutes = () => {
|
|
|
35
34
|
'[segment]',
|
|
36
35
|
'[url]',
|
|
37
36
|
'[theme]',
|
|
38
|
-
'[member_type]'
|
|
39
|
-
'[clienttype]'
|
|
37
|
+
'[member_type]'
|
|
40
38
|
];
|
|
41
|
-
|
|
42
39
|
const skipCatchAllRoutes = ['[...prettyurl]', '[...not_found]'];
|
|
43
40
|
|
|
44
41
|
const walkDirectory = (dir, basePath = '') => {
|
package/data/client/checkout.ts
CHANGED
|
@@ -738,6 +738,7 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
738
738
|
},
|
|
739
739
|
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
|
|
740
740
|
dispatch(setPaymentStepBusy(true));
|
|
741
|
+
dispatch(setCardType(arg));
|
|
741
742
|
await queryFulfilled;
|
|
742
743
|
dispatch(setPaymentStepBusy(false));
|
|
743
744
|
}
|
package/data/server/category.ts
CHANGED
|
@@ -7,8 +7,6 @@ import { parse } from 'lossless-json';
|
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
import { headers as nHeaders } from 'next/headers';
|
|
9
9
|
import { ServerVariables } from '../../utils/server-variables';
|
|
10
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
11
|
-
import settings from 'settings';
|
|
12
10
|
|
|
13
11
|
function getCategoryDataHandler(
|
|
14
12
|
pk: number,
|
|
@@ -82,7 +80,7 @@ function getCategoryDataHandler(
|
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
export const getCategoryData =
|
|
83
|
+
export const getCategoryData = ({
|
|
86
84
|
pk,
|
|
87
85
|
searchParams,
|
|
88
86
|
headers,
|
|
@@ -95,7 +93,7 @@ export const getCategoryData = async ({
|
|
|
95
93
|
searchParams?: SearchParams;
|
|
96
94
|
headers?: Record<string, string>;
|
|
97
95
|
}) => {
|
|
98
|
-
|
|
96
|
+
return Cache.wrap(
|
|
99
97
|
CacheKey.Category(pk, searchParams, headers),
|
|
100
98
|
locale,
|
|
101
99
|
getCategoryDataHandler(pk, locale, currency, searchParams, headers),
|
|
@@ -104,16 +102,6 @@ export const getCategoryData = async ({
|
|
|
104
102
|
compressed: true
|
|
105
103
|
}
|
|
106
104
|
);
|
|
107
|
-
|
|
108
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
109
|
-
try {
|
|
110
|
-
return { ...result, data: optimizeCategoryResponse(result.data, settings.payloadOptimization) };
|
|
111
|
-
} catch (e) {
|
|
112
|
-
logger.error('Payload optimization failed for category', { pk, error: (e as Error).message });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return result;
|
|
117
105
|
};
|
|
118
106
|
|
|
119
107
|
function getCategoryBySlugDataHandler(
|
package/data/server/list.ts
CHANGED
|
@@ -6,8 +6,6 @@ import appFetch, { FetchResponseType } from '../../utils/app-fetch';
|
|
|
6
6
|
import { parse } from 'lossless-json';
|
|
7
7
|
import logger from '../../utils/log';
|
|
8
8
|
import { ServerVariables } from '../../utils/server-variables';
|
|
9
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
10
|
-
import settings from 'settings';
|
|
11
9
|
|
|
12
10
|
const getListDataHandler = (
|
|
13
11
|
locale,
|
|
@@ -68,7 +66,7 @@ export const getListData = async ({
|
|
|
68
66
|
searchParams: SearchParams;
|
|
69
67
|
headers?: Record<string, string>;
|
|
70
68
|
}) => {
|
|
71
|
-
|
|
69
|
+
return Cache.wrap(
|
|
72
70
|
CacheKey.List(searchParams, headers),
|
|
73
71
|
locale,
|
|
74
72
|
getListDataHandler(locale, currency, searchParams, headers),
|
|
@@ -77,14 +75,4 @@ export const getListData = async ({
|
|
|
77
75
|
compressed: true
|
|
78
76
|
}
|
|
79
77
|
);
|
|
80
|
-
|
|
81
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
82
|
-
try {
|
|
83
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
logger.error('Payload optimization failed for list', { error: (e as Error).message });
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return result;
|
|
90
78
|
};
|
package/data/server/product.ts
CHANGED
|
@@ -4,8 +4,6 @@ import { ProductCategoryResult, ProductResult, SearchParams } from '../../types'
|
|
|
4
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
5
|
import { ServerVariables } from '../../utils/server-variables';
|
|
6
6
|
import logger from '../../utils/log';
|
|
7
|
-
import { optimizeProductResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import settings from 'settings';
|
|
9
7
|
|
|
10
8
|
type GetProduct = {
|
|
11
9
|
pk: number | string;
|
|
@@ -165,13 +163,5 @@ export const getProductData = async ({
|
|
|
165
163
|
throw error;
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
if (settings.payloadOptimization?.enabled && result?.data) {
|
|
169
|
-
try {
|
|
170
|
-
return { ...result, data: optimizeProductResponse(result.data, settings.payloadOptimization) };
|
|
171
|
-
} catch (e) {
|
|
172
|
-
logger.error('Payload optimization failed for product', { pk, error: (e as Error).message });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
166
|
return result;
|
|
177
167
|
};
|
|
@@ -4,9 +4,6 @@ import { GetCategoryResponse, SearchParams } from '../../types';
|
|
|
4
4
|
import { generateCommerceSearchParams } from '../../utils';
|
|
5
5
|
import appFetch from '../../utils/app-fetch';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
|
-
import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import logger from '../../utils/log';
|
|
9
|
-
import settings from 'settings';
|
|
10
7
|
|
|
11
8
|
const getSpecialPageDataHandler = (
|
|
12
9
|
pk: number,
|
|
@@ -48,7 +45,7 @@ export const getSpecialPageData = async ({
|
|
|
48
45
|
searchParams: SearchParams;
|
|
49
46
|
headers?: Record<string, string>;
|
|
50
47
|
}) => {
|
|
51
|
-
|
|
48
|
+
return Cache.wrap(
|
|
52
49
|
CacheKey.SpecialPage(pk, searchParams, headers),
|
|
53
50
|
locale,
|
|
54
51
|
getSpecialPageDataHandler(pk, locale, currency, searchParams, headers),
|
|
@@ -57,14 +54,4 @@ export const getSpecialPageData = async ({
|
|
|
57
54
|
compressed: true
|
|
58
55
|
}
|
|
59
56
|
);
|
|
60
|
-
|
|
61
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
62
|
-
try {
|
|
63
|
-
return optimizeCategoryResponse(result, settings.payloadOptimization);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
logger.error('Payload optimization failed for special-page', { pk, error: (e as Error).message });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return result;
|
|
70
57
|
};
|
package/data/server/widget.ts
CHANGED
|
@@ -4,9 +4,6 @@ import { CacheOptions, WidgetResultType, WidgetSchemaType } from '../../types';
|
|
|
4
4
|
import appFetch from '../../utils/app-fetch';
|
|
5
5
|
import { widgets } from '../urls';
|
|
6
6
|
import { ServerVariables } from '../../utils/server-variables';
|
|
7
|
-
import { optimizeWidgetResponse } from '../../utils/payload-optimizer';
|
|
8
|
-
import logger from '../../utils/log';
|
|
9
|
-
import settings from 'settings';
|
|
10
7
|
|
|
11
8
|
const getWidgetDataHandler =
|
|
12
9
|
(
|
|
@@ -56,7 +53,7 @@ export const getWidgetData = async <T>({
|
|
|
56
53
|
cacheOptions?: CacheOptions;
|
|
57
54
|
headers?: Record<string, string>;
|
|
58
55
|
}): Promise<WidgetResultType<T>> => {
|
|
59
|
-
|
|
56
|
+
return Cache.wrap(
|
|
60
57
|
CacheKey.Widget(slug),
|
|
61
58
|
locale,
|
|
62
59
|
getWidgetDataHandler(slug, locale, currency, headers),
|
|
@@ -65,16 +62,6 @@ export const getWidgetData = async <T>({
|
|
|
65
62
|
...cacheOptions
|
|
66
63
|
}
|
|
67
64
|
);
|
|
68
|
-
|
|
69
|
-
if (settings.payloadOptimization?.enabled && result) {
|
|
70
|
-
try {
|
|
71
|
-
return optimizeWidgetResponse(result, settings.payloadOptimization) as WidgetResultType<T>;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
logger.error('Payload optimization failed for widget', { slug, error: (e as Error).message });
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return result as WidgetResultType<T>;
|
|
78
65
|
};
|
|
79
66
|
|
|
80
67
|
const getCollectionWidgetDataHandler =
|
package/data/urls.ts
CHANGED
|
@@ -183,11 +183,7 @@ export const product = {
|
|
|
183
183
|
breadcrumbUrl: (menuitemmodel: string) =>
|
|
184
184
|
`/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
|
|
185
185
|
bundleProduct: (productPk: string, queryString: string) =>
|
|
186
|
-
`/bundle-product/${productPk}/?${queryString}
|
|
187
|
-
similarProducts: (params?: string) =>
|
|
188
|
-
`/similar-products${params ? `?${params}` : ''}`,
|
|
189
|
-
similarProductsList: (params?: string) =>
|
|
190
|
-
`/similar-product-list${params ? `?${params}` : ''}`
|
|
186
|
+
`/bundle-product/${productPk}/?${queryString}`
|
|
191
187
|
};
|
|
192
188
|
|
|
193
189
|
export const wishlist = {
|
package/hooks/use-captcha.tsx
CHANGED
package/middlewares/default.ts
CHANGED
|
@@ -10,23 +10,49 @@ const withMasterpassRestCallback =
|
|
|
10
10
|
async (req: PzNextRequest, event: NextFetchEvent) => {
|
|
11
11
|
const url = req.nextUrl.clone();
|
|
12
12
|
const ip = req.headers.get('x-forwarded-for') ?? '';
|
|
13
|
+
const sessionId = req.cookies.get('osessionid');
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
url.pathname.includes('/orders/checkout') &&
|
|
16
|
-
url.searchParams.get('page') === 'MasterpassRestCompletePage';
|
|
17
|
-
|
|
18
|
-
if (!isMasterpassCompletePage) {
|
|
15
|
+
if (!url.pathname.includes('/orders/masterpass-rest-callback')) {
|
|
19
16
|
return middleware(req, event);
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
if (req.method !== 'POST') {
|
|
20
|
+
logger.warn('Invalid request method for masterpass REST callback', {
|
|
21
|
+
middleware: 'masterpass-rest-callback',
|
|
22
|
+
method: req.method,
|
|
23
|
+
ip
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return NextResponse.redirect(
|
|
27
|
+
`${url.origin}${getUrlPathWithLocale(
|
|
28
|
+
'/orders/checkout/',
|
|
29
|
+
req.cookies.get('pz-locale')?.value
|
|
30
|
+
)}`,
|
|
31
|
+
303
|
|
32
|
+
);
|
|
33
|
+
}
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
const responseCode = url.searchParams.get('responseCode');
|
|
36
|
+
const token = url.searchParams.get('token');
|
|
37
|
+
|
|
38
|
+
if (!responseCode || !token) {
|
|
39
|
+
logger.warn('Missing required parameters for masterpass REST callback', {
|
|
40
|
+
middleware: 'masterpass-rest-callback',
|
|
41
|
+
responseCode,
|
|
42
|
+
token,
|
|
43
|
+
ip
|
|
28
44
|
});
|
|
29
45
|
|
|
46
|
+
return NextResponse.redirect(
|
|
47
|
+
`${url.origin}${getUrlPathWithLocale(
|
|
48
|
+
'/orders/checkout/',
|
|
49
|
+
req.cookies.get('pz-locale')?.value
|
|
50
|
+
)}`,
|
|
51
|
+
303
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
30
56
|
const formData = await req.formData();
|
|
31
57
|
const body: Record<string, string> = {};
|
|
32
58
|
|
|
@@ -34,6 +60,38 @@ const withMasterpassRestCallback =
|
|
|
34
60
|
body[key] = value.toString();
|
|
35
61
|
});
|
|
36
62
|
|
|
63
|
+
if (!sessionId) {
|
|
64
|
+
logger.warn(
|
|
65
|
+
'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
|
|
66
|
+
{
|
|
67
|
+
middleware: 'masterpass-rest-callback',
|
|
68
|
+
ip
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return NextResponse.redirect(
|
|
73
|
+
`${url.origin}${getUrlPathWithLocale(
|
|
74
|
+
'/orders/checkout/',
|
|
75
|
+
req.cookies.get('pz-locale')?.value
|
|
76
|
+
)}`,
|
|
77
|
+
303
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const isPostCheckout = req.cookies.get('pz-post-checkout-flow')?.value === 'true';
|
|
82
|
+
const requestUrl = new URL(getCheckoutPath(isPostCheckout), Settings.commerceUrl);
|
|
83
|
+
requestUrl.searchParams.set('page', 'MasterpassRestCompletePage');
|
|
84
|
+
requestUrl.searchParams.set('responseCode', responseCode);
|
|
85
|
+
requestUrl.searchParams.set('token', token);
|
|
86
|
+
requestUrl.searchParams.set(
|
|
87
|
+
'three_d_secure',
|
|
88
|
+
body.transactionType?.includes('3D') ? 'true' : 'false'
|
|
89
|
+
);
|
|
90
|
+
requestUrl.searchParams.set(
|
|
91
|
+
'transactionType',
|
|
92
|
+
body.transactionType || ''
|
|
93
|
+
);
|
|
94
|
+
|
|
37
95
|
const requestHeaders = {
|
|
38
96
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
39
97
|
'X-Requested-With': 'XMLHttpRequest',
|
|
@@ -49,13 +107,33 @@ const withMasterpassRestCallback =
|
|
|
49
107
|
body: new URLSearchParams(body)
|
|
50
108
|
});
|
|
51
109
|
|
|
110
|
+
logger.info('Masterpass REST callback request', {
|
|
111
|
+
requestUrl: requestUrl.toString(),
|
|
112
|
+
status: request.status,
|
|
113
|
+
requestHeaders,
|
|
114
|
+
ip
|
|
115
|
+
});
|
|
116
|
+
|
|
52
117
|
const response = await request.json();
|
|
53
|
-
|
|
118
|
+
|
|
119
|
+
const { context_list: contextList, errors } = response;
|
|
120
|
+
|
|
121
|
+
let redirectUrl = response.redirect_url;
|
|
122
|
+
|
|
123
|
+
if (!redirectUrl && contextList && contextList.length > 0) {
|
|
124
|
+
for (const context of contextList) {
|
|
125
|
+
if (context.page_context && context.page_context.redirect_url) {
|
|
126
|
+
redirectUrl = context.page_context.redirect_url;
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
54
131
|
|
|
55
132
|
if (errors && Object.keys(errors).length) {
|
|
56
|
-
logger.error('Error while processing
|
|
133
|
+
logger.error('Error while processing masterpass REST callback', {
|
|
57
134
|
middleware: 'masterpass-rest-callback',
|
|
58
135
|
errors,
|
|
136
|
+
requestHeaders,
|
|
59
137
|
ip
|
|
60
138
|
});
|
|
61
139
|
|
|
@@ -64,7 +142,12 @@ const withMasterpassRestCallback =
|
|
|
64
142
|
'/orders/checkout/',
|
|
65
143
|
req.cookies.get('pz-locale')?.value
|
|
66
144
|
)}`,
|
|
67
|
-
|
|
145
|
+
{
|
|
146
|
+
status: 303,
|
|
147
|
+
headers: {
|
|
148
|
+
'Set-Cookie': `pz-pos-error=${encodeURIComponent(JSON.stringify(errors))}; path=/;`
|
|
149
|
+
}
|
|
150
|
+
}
|
|
68
151
|
);
|
|
69
152
|
|
|
70
153
|
// Add error cookie
|
|
@@ -75,40 +158,70 @@ const withMasterpassRestCallback =
|
|
|
75
158
|
return errorResponse;
|
|
76
159
|
}
|
|
77
160
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
161
|
+
logger.info('Masterpass REST callback response', {
|
|
162
|
+
middleware: 'masterpass-rest-callback',
|
|
163
|
+
contextList,
|
|
164
|
+
redirectUrl,
|
|
165
|
+
ip
|
|
166
|
+
});
|
|
81
167
|
|
|
82
|
-
if (redirectUrl) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
168
|
+
if (!redirectUrl) {
|
|
169
|
+
logger.warn(
|
|
170
|
+
'No redirection url found in response. Redirecting to checkout page.',
|
|
171
|
+
{
|
|
172
|
+
middleware: 'masterpass-rest-callback',
|
|
173
|
+
requestHeaders,
|
|
174
|
+
response: JSON.stringify(response),
|
|
175
|
+
ip
|
|
176
|
+
}
|
|
86
177
|
);
|
|
87
178
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
nextResponse.headers.append('Set-Cookie', cookie.trim());
|
|
93
|
-
});
|
|
94
|
-
}
|
|
179
|
+
const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
|
|
180
|
+
'/orders/checkout/',
|
|
181
|
+
req.cookies.get('pz-locale')?.value
|
|
182
|
+
)}`;
|
|
95
183
|
|
|
96
|
-
return
|
|
184
|
+
return NextResponse.redirect(redirectUrlWithLocale, 303);
|
|
97
185
|
}
|
|
98
186
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)
|
|
187
|
+
const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
|
|
188
|
+
redirectUrl,
|
|
189
|
+
req.cookies.get('pz-locale')?.value
|
|
190
|
+
)}`;
|
|
191
|
+
|
|
192
|
+
logger.info('Redirecting after masterpass REST callback', {
|
|
193
|
+
middleware: 'masterpass-rest-callback',
|
|
194
|
+
redirectUrl: redirectUrlWithLocale,
|
|
195
|
+
ip
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const nextResponse = NextResponse.redirect(redirectUrlWithLocale, 303);
|
|
199
|
+
|
|
200
|
+
// Forward set-cookie headers from the upstream response
|
|
201
|
+
const setCookieHeader = request.headers.get('set-cookie');
|
|
202
|
+
if (setCookieHeader) {
|
|
203
|
+
setCookieHeader.split(',').forEach((cookie) => {
|
|
204
|
+
nextResponse.headers.append('Set-Cookie', cookie.trim());
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return nextResponse;
|
|
103
209
|
} catch (error) {
|
|
104
|
-
logger.error('Error while processing
|
|
210
|
+
logger.error('Error while processing masterpass REST callback', {
|
|
105
211
|
middleware: 'masterpass-rest-callback',
|
|
106
212
|
error,
|
|
213
|
+
requestHeaders: {
|
|
214
|
+
Cookie: req.headers.get('cookie') ?? '',
|
|
215
|
+
'x-currency': req.cookies.get('pz-currency')?.value ?? ''
|
|
216
|
+
},
|
|
107
217
|
ip
|
|
108
218
|
});
|
|
109
219
|
|
|
110
220
|
return NextResponse.redirect(
|
|
111
|
-
`${url.origin}${getUrlPathWithLocale(
|
|
221
|
+
`${url.origin}${getUrlPathWithLocale(
|
|
222
|
+
'/orders/checkout/',
|
|
223
|
+
req.cookies.get('pz-locale')?.value
|
|
224
|
+
)}`,
|
|
112
225
|
303
|
|
113
226
|
);
|
|
114
227
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.11-beta.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"pz-prestart": "bin/pz-prestart.js",
|
|
12
12
|
"pz-poststart": "bin/pz-poststart.js",
|
|
13
13
|
"pz-predev": "bin/pz-predev.js",
|
|
14
|
-
"pz-postdev": "bin/pz-postdev.js"
|
|
15
|
-
"pz-migrate-eslint": "bin/pz-migrate-eslint.js"
|
|
14
|
+
"pz-postdev": "bin/pz-postdev.js"
|
|
16
15
|
},
|
|
17
16
|
"scripts": {
|
|
18
17
|
"test": "jest"
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"set-cookie-parser": "2.6.0"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@akinon/eslint-plugin-projectzero": "2.0.
|
|
39
|
+
"@akinon/eslint-plugin-projectzero": "2.0.11-beta.0",
|
|
41
40
|
"@babel/core": "7.26.10",
|
|
42
41
|
"@babel/preset-env": "7.26.9",
|
|
43
42
|
"@babel/preset-typescript": "7.27.0",
|
package/plugins.d.ts
CHANGED
|
@@ -37,16 +37,6 @@ declare module '@akinon/pz-cybersource-uc/src/redux/middleware' {
|
|
|
37
37
|
export default middleware as any;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
declare module '@akinon/pz-apple-pay' {}
|
|
41
|
-
|
|
42
|
-
declare module '@akinon/pz-similar-products' {
|
|
43
|
-
export const SimilarProductsModal: any;
|
|
44
|
-
export const SimilarProductsFilterSidebar: any;
|
|
45
|
-
export const SimilarProductsResultsGrid: any;
|
|
46
|
-
export const SimilarProductsPlugin: any;
|
|
47
|
-
export const SimilarProductsButtonPlugin: any;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
40
|
declare module '@akinon/pz-cybersource-uc/src/redux/reducer' {
|
|
51
41
|
export default reducer as any;
|
|
52
42
|
}
|