@akinon/next 1.116.0-rc.8 → 1.116.0-snapshot-ZERO-3959-20260106131052

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 CHANGED
@@ -1,40 +1,6 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.116.0-rc.8
4
-
5
- ## 1.116.0-rc.7
6
-
7
- ### Minor Changes
8
-
9
- - 729fe756: ZERO-3895: improve non-3D payment handling and error display
10
-
11
- ## 1.116.0-rc.6
12
-
13
- ## 1.116.0-rc.5
14
-
15
- ## 1.116.0-rc.4
16
-
17
- ## 1.116.0-rc.3
18
-
19
- ## 1.116.0-rc.2
20
-
21
- ### Minor Changes
22
-
23
- - 3909d322: Edit the duplicate Plugin.SimilarProducts in the plugin-module.
24
-
25
- ## 1.116.0-rc.1
26
-
27
- ## 1.116.0-rc.0
28
-
29
- ### Minor Changes
30
-
31
- - d2c0e759: ZERO-3684: Handle cross-origin iframe access in iframeURLChange function
32
- - b55acb76: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
33
- - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
34
- - 9f8cd3bc: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
35
- - d99a6a7d: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
36
- - 4de5303c: ZERO-2504: add cookie filter to api client request
37
- - 95b139dc: ZERO-3795: Remove duplicate entry for SavedCard in PluginComponents map
3
+ ## 1.116.0-snapshot-ZERO-3959-20260106131052
38
4
 
39
5
  ## 1.115.0
40
6
 
@@ -111,6 +111,7 @@ const PluginComponents = new Map([
111
111
  ]
112
112
  ],
113
113
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
114
+ [Plugin.SavedCard, [Component.SavedCard]],
114
115
  [Plugin.FlowPayment, [Component.FlowPayment]],
115
116
  [
116
117
  Plugin.VirtualTryOn,
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 = {
@@ -9,21 +9,49 @@ const withMasterpassRestCallback =
9
9
  async (req: PzNextRequest, event: NextFetchEvent) => {
10
10
  const url = req.nextUrl.clone();
11
11
  const ip = req.headers.get('x-forwarded-for') ?? '';
12
+ const sessionId = req.cookies.get('osessionid');
12
13
 
13
- const isMasterpassCompletePage =
14
- url.pathname.includes('/orders/checkout') &&
15
- url.searchParams.get('page') === 'MasterpassRestCompletePage';
16
-
17
- if (!isMasterpassCompletePage) {
14
+ if (!url.pathname.includes('/orders/masterpass-rest-callback')) {
18
15
  return middleware(req, event);
19
16
  }
20
17
 
21
- try {
22
- const requestUrl = new URL('/orders/checkout/', Settings.commerceUrl);
23
- url.searchParams.forEach((value, key) => {
24
- requestUrl.searchParams.set(key, value);
18
+ if (req.method !== 'POST') {
19
+ logger.warn('Invalid request method for masterpass REST callback', {
20
+ middleware: 'masterpass-rest-callback',
21
+ method: req.method,
22
+ ip
25
23
  });
26
24
 
25
+ return NextResponse.redirect(
26
+ `${url.origin}${getUrlPathWithLocale(
27
+ '/orders/checkout/',
28
+ req.cookies.get('pz-locale')?.value
29
+ )}`,
30
+ 303
31
+ );
32
+ }
33
+
34
+ const responseCode = url.searchParams.get('responseCode');
35
+ const token = url.searchParams.get('token');
36
+
37
+ if (!responseCode || !token) {
38
+ logger.warn('Missing required parameters for masterpass REST callback', {
39
+ middleware: 'masterpass-rest-callback',
40
+ responseCode,
41
+ token,
42
+ ip
43
+ });
44
+
45
+ return NextResponse.redirect(
46
+ `${url.origin}${getUrlPathWithLocale(
47
+ '/orders/checkout/',
48
+ req.cookies.get('pz-locale')?.value
49
+ )}`,
50
+ 303
51
+ );
52
+ }
53
+
54
+ try {
27
55
  const formData = await req.formData();
28
56
  const body: Record<string, string> = {};
29
57
 
@@ -31,6 +59,37 @@ const withMasterpassRestCallback =
31
59
  body[key] = value.toString();
32
60
  });
33
61
 
62
+ if (!sessionId) {
63
+ logger.warn(
64
+ 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
65
+ {
66
+ middleware: 'masterpass-rest-callback',
67
+ ip
68
+ }
69
+ );
70
+
71
+ return NextResponse.redirect(
72
+ `${url.origin}${getUrlPathWithLocale(
73
+ '/orders/checkout/',
74
+ req.cookies.get('pz-locale')?.value
75
+ )}`,
76
+ 303
77
+ );
78
+ }
79
+
80
+ const requestUrl = new URL('/orders/checkout/', Settings.commerceUrl);
81
+ requestUrl.searchParams.set('page', 'MasterpassRestCompletePage');
82
+ requestUrl.searchParams.set('responseCode', responseCode);
83
+ requestUrl.searchParams.set('token', token);
84
+ requestUrl.searchParams.set(
85
+ 'three_d_secure',
86
+ body.transactionType?.includes('3D') ? 'true' : 'false'
87
+ );
88
+ requestUrl.searchParams.set(
89
+ 'transactionType',
90
+ body.transactionType || ''
91
+ );
92
+
34
93
  const requestHeaders = {
35
94
  'Content-Type': 'application/x-www-form-urlencoded',
36
95
  'X-Requested-With': 'XMLHttpRequest',
@@ -46,13 +105,33 @@ const withMasterpassRestCallback =
46
105
  body: new URLSearchParams(body)
47
106
  });
48
107
 
108
+ logger.info('Masterpass REST callback request', {
109
+ requestUrl: requestUrl.toString(),
110
+ status: request.status,
111
+ requestHeaders,
112
+ ip
113
+ });
114
+
49
115
  const response = await request.json();
50
- const { errors } = response;
116
+
117
+ const { context_list: contextList, errors } = response;
118
+
119
+ let redirectUrl = response.redirect_url;
120
+
121
+ if (!redirectUrl && contextList && contextList.length > 0) {
122
+ for (const context of contextList) {
123
+ if (context.page_context && context.page_context.redirect_url) {
124
+ redirectUrl = context.page_context.redirect_url;
125
+ break;
126
+ }
127
+ }
128
+ }
51
129
 
52
130
  if (errors && Object.keys(errors).length) {
53
- logger.error('Error while processing MasterpassRestCompletePage', {
54
- middleware: 'masterpass-rest-complete',
131
+ logger.error('Error while processing masterpass REST callback', {
132
+ middleware: 'masterpass-rest-callback',
55
133
  errors,
134
+ requestHeaders,
56
135
  ip
57
136
  });
58
137
 
@@ -64,36 +143,73 @@ const withMasterpassRestCallback =
64
143
  {
65
144
  status: 303,
66
145
  headers: {
67
- 'Set-Cookie': `pz-pos-error=${encodeURIComponent(JSON.stringify(errors))}; path=/;`
146
+ 'Set-Cookie': `pz-pos-error=${JSON.stringify(errors)}; path=/;`
68
147
  }
69
148
  }
70
149
  );
71
150
  }
72
151
 
73
- const redirectUrl =
74
- response.redirect_url ||
75
- response.context_list?.[0]?.page_context?.redirect_url;
152
+ logger.info('Masterpass REST callback response', {
153
+ middleware: 'masterpass-rest-callback',
154
+ contextList,
155
+ redirectUrl,
156
+ ip
157
+ });
76
158
 
77
- if (redirectUrl) {
78
- return NextResponse.redirect(
79
- `${url.origin}${getUrlPathWithLocale(redirectUrl, req.cookies.get('pz-locale')?.value)}`,
80
- 303
159
+ if (!redirectUrl) {
160
+ logger.warn(
161
+ 'No redirection url found in response. Redirecting to checkout page.',
162
+ {
163
+ middleware: 'masterpass-rest-callback',
164
+ requestHeaders,
165
+ response: JSON.stringify(response),
166
+ ip
167
+ }
81
168
  );
169
+
170
+ const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
171
+ '/orders/checkout/',
172
+ req.cookies.get('pz-locale')?.value
173
+ )}`;
174
+
175
+ return NextResponse.redirect(redirectUrlWithLocale, 303);
82
176
  }
83
177
 
84
- return NextResponse.redirect(
85
- `${url.origin}${getUrlPathWithLocale('/orders/checkout/', req.cookies.get('pz-locale')?.value)}`,
86
- 303
178
+ const redirectUrlWithLocale = `${url.origin}${getUrlPathWithLocale(
179
+ redirectUrl,
180
+ req.cookies.get('pz-locale')?.value
181
+ )}`;
182
+
183
+ logger.info('Redirecting after masterpass REST callback', {
184
+ middleware: 'masterpass-rest-callback',
185
+ redirectUrlWithLocale,
186
+ ip
187
+ });
188
+
189
+ const nextResponse = NextResponse.redirect(redirectUrlWithLocale, 303);
190
+
191
+ nextResponse.headers.set(
192
+ 'Set-Cookie',
193
+ request.headers.get('set-cookie') ?? ''
87
194
  );
195
+
196
+ return nextResponse;
88
197
  } catch (error) {
89
- logger.error('Error while processing MasterpassRestCompletePage', {
90
- middleware: 'masterpass-rest-complete',
198
+ logger.error('Error while processing masterpass REST callback', {
199
+ middleware: 'masterpass-rest-callback',
91
200
  error,
201
+ requestHeaders: {
202
+ Cookie: req.headers.get('cookie') ?? '',
203
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
204
+ },
92
205
  ip
93
206
  });
94
207
 
95
208
  return NextResponse.redirect(
96
- `${url.origin}${getUrlPathWithLocale('/orders/checkout/', req.cookies.get('pz-locale')?.value)}`,
209
+ `${url.origin}${getUrlPathWithLocale(
210
+ '/orders/checkout/',
211
+ req.cookies.get('pz-locale')?.value
212
+ )}`,
97
213
  303
98
214
  );
99
215
  }
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": "1.116.0-rc.8",
4
+ "version": "1.116.0-snapshot-ZERO-3959-20260106131052",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -35,7 +35,7 @@
35
35
  "set-cookie-parser": "2.6.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.116.0-rc.8",
38
+ "@akinon/eslint-plugin-projectzero": "1.116.0-snapshot-ZERO-3959-20260106131052",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@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
  }
package/plugins.js CHANGED
@@ -16,7 +16,6 @@ module.exports = [
16
16
  'pz-tabby-extension',
17
17
  'pz-apple-pay',
18
18
  'pz-tamara-extension',
19
- 'pz-similar-products',
20
19
  'pz-cybersource-uc',
21
20
  'pz-hepsipay',
22
21
  'pz-flow-payment',
package/types/index.ts CHANGED
@@ -83,12 +83,6 @@ export interface Settings {
83
83
  };
84
84
  usePrettyUrlRoute?: boolean;
85
85
  commerceUrl: string;
86
- /**
87
- * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
88
- *
89
- * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
90
- */
91
- sentryDsn?: string;
92
86
  redis: {
93
87
  defaultExpirationTime: number;
94
88
  };
package/utils/index.ts CHANGED
@@ -193,8 +193,7 @@ export const urlLocaleMatcherRegex = new RegExp(
193
193
  );
194
194
 
195
195
  export const getPosError = () => {
196
- const cookieValue = getCookie('pz-pos-error');
197
- const error = JSON.parse(cookieValue ? decodeURIComponent(cookieValue) : '{}');
196
+ const error = JSON.parse(getCookie('pz-pos-error') ?? '{}');
198
197
 
199
198
  // delete 'pz-pos-error' cookie when refreshing or closing page
200
199
  window.addEventListener('beforeunload', () => {
@@ -1,14 +1,8 @@
1
1
  const iframeURLChange = (iframe, callback) => {
2
2
  iframe.addEventListener('load', () => {
3
3
  setTimeout(() => {
4
- try {
5
- if (iframe?.contentWindow?.location) {
6
- const iframeLocation = iframe.contentWindow.location;
7
-
8
- callback(iframeLocation);
9
- }
10
- } catch (error) {
11
- // Expected: browser blocks cross-origin iframe access for security
4
+ if (iframe?.contentWindow?.location) {
5
+ callback(iframe.contentWindow.location);
12
6
  }
13
7
  }, 0);
14
8
  });
@@ -1,14 +1,8 @@
1
1
  const iframeURLChange = (iframe, callback) => {
2
2
  iframe.addEventListener('load', () => {
3
3
  setTimeout(() => {
4
- try {
5
- if (iframe?.contentWindow?.location) {
6
- const iframeLocation = iframe.contentWindow.location;
7
-
8
- callback(iframeLocation);
9
- }
10
- } catch (error) {
11
- // Expected: browser blocks cross-origin iframe access for security
4
+ if (iframe?.contentWindow?.location) {
5
+ callback(iframe.contentWindow.location);
12
6
  }
13
7
  }, 0);
14
8
  });