@akinon/next 1.26.0-rc.8 → 1.26.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 CHANGED
@@ -1,91 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.26.0-rc.8
3
+ ## 1.26.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - f0c23bc: ZERO-2135: add custom not found page
8
-
9
- ### Patch Changes
10
-
11
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.8
12
-
13
- ## 1.26.0-rc.7
14
-
15
- ### Patch Changes
16
-
17
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.7
18
-
19
- ## 1.26.0-rc.6
20
-
21
- ### Minor Changes
22
-
23
- - 40ad73e: ZERO-2504: add cookie filter to api client request
24
-
25
- ### Patch Changes
26
-
27
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.6
28
-
29
- ## 1.26.0-rc.5
30
-
31
- ### Patch Changes
32
-
33
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.5
34
-
35
- ## 1.26.0-rc.4
36
-
37
- ### Patch Changes
38
-
39
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.4
40
-
41
- ## 1.26.0-rc.3
42
-
43
- ### Minor Changes
44
-
45
- - d6d2533: ZERO-2560: Add installment count to masterpass payment forms
46
- - ff89630: ZERO-2498: Add script for env control
47
-
48
- ### Patch Changes
49
-
50
- - 073fbd2: ZERO-2503: Add check changeset control script
51
- - Updated dependencies [073fbd2]
52
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.3
53
-
54
- ## 1.26.0-rc.2
55
-
56
- ### Patch Changes
57
-
58
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.2
59
-
60
- ## 1.26.0-rc.1
61
-
62
- ### Minor Changes
63
-
64
- - a7e432f: ZERO-2534: Fix for recapthca regex for replacing the special chars.
65
-
66
- ### Patch Changes
67
-
68
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.1
69
-
70
- ## 1.26.0-rc.0
71
-
72
- ### Minor Changes
73
-
74
- - 6d4aadb: ZERO-2476: Auto install recommendenent extension
75
- - 7e41bdc: BRDG-9158: Remove redirect-three-d page endpoint
76
- - 1289982: ZERO-2521: Add x-forwarded-for header to requests
77
- - 3690d3b: ZERO-2485: Check ESLint peerDependency version
78
- - b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
79
- - b2da5e4: Revert ZERO-2435
80
- - f76f079: ZERO-2493: Add redirect util function
81
-
82
- ### Patch Changes
83
-
84
- - da1e501: ZERO-2296: Fix ROUTES import
85
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
86
- - 183674f: BRDG-9158: Handle locale prefix
87
- - 8c7f5bc: ZERO-2440: Pipeline test
88
- - @akinon/eslint-plugin-projectzero@1.26.0-rc.0
7
+ - 02fa342: ZERO-2507: Add web vitals endpoint
89
8
 
90
9
  ## 1.25.0
91
10
 
@@ -104,83 +23,7 @@
104
23
 
105
24
  ### Patch Changes
106
25
 
107
- - da1e501: ZERO-2296: Fix ROUTES import
108
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
109
- - 183674f: BRDG-9158: Handle locale prefix
110
- - 8c7f5bc: ZERO-2440: Pipeline test
111
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.5
112
-
113
- ## 1.25.0-rc.4
114
-
115
- ### Patch Changes
116
-
117
- - 183674f: BRDG-9158: Handle locale prefix
118
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.4
119
-
120
- ## 1.25.0-rc.3
121
-
122
- ### Minor Changes
123
-
124
- - 1289982: ZERO-2521: Add x-forwarded-for header to requests
125
-
126
- ### Patch Changes
127
-
128
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.3
129
-
130
- ## 1.25.0-rc.2
131
-
132
- ### Minor Changes
133
-
134
- - 7e41bdc: BRDG-9158: Remove redirect-three-d page endpoint
135
-
136
- ### Patch Changes
137
-
138
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.2
139
-
140
- ## 1.25.0-rc.1
141
-
142
- ### Minor Changes
143
-
144
- - 6d4aadb: ZERO-2476: Auto install recommendenent extension
145
- - e20b27f: ZERO-2454:add otp login
146
- - e0a945e: ZERO-2494:Add LiveCommerce for managing basket and product actions
147
- - a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
148
- - 1ec9775: ZERO-2462:add custom span to logs
149
- - ab5a493: ZERO-2475:add types [key: string]: any; for unknown attributes
150
- - 3690d3b: ZERO-2485: Check ESLint peerDependency version
151
- - 92094d4: ZERO-2477: Update Sentry version and add hideSourceMaps option
152
- - b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
153
- - b2da5e4: Revert ZERO-2435
154
- - d3edd3a: ZERO-2499:add style prop in link component
155
- - f76f079: ZERO-2493: Add redirect util function
156
-
157
- ### Patch Changes
158
-
159
- - da1e501: ZERO-2296: Fix ROUTES import
160
26
  - 95510c7: ZERO-2508: Enable rc branch pipeline and add check-publish-version step
161
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
162
- - 8c7f5bc: ZERO-2440: Pipeline test
163
- - Updated dependencies [95510c7]
164
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.1
165
-
166
- ## 1.25.0-rc.0
167
-
168
- ### Minor Changes
169
-
170
- - 6d4aadb: ZERO-2476: Auto install recommendenent extension
171
- - e20b27f: ZERO-2454:add otp login
172
- - a4674c6: ZERO-2461: add optional chaining for referrer header and add locale value for redirect url
173
- - 1ec9775: ZERO-2462:add custom span to logs
174
- - 3690d3b: ZERO-2485: Check ESLint peerDependency version
175
- - b4452e9: ZERO-2463: Refactor Sentry initialization and add Sentry DSN option to settings
176
- - b2da5e4: Revert ZERO-2435
177
-
178
- ### Patch Changes
179
-
180
- - da1e501: ZERO-2296: Fix ROUTES import
181
- - 2e44646: ZERO-2434: Fix category URL in getCategoryDataHandler function
182
- - 8c7f5bc: ZERO-2440: Pipeline test
183
- - @akinon/eslint-plugin-projectzero@1.25.0-rc.0
184
27
 
185
28
  ## 1.24.0
186
29
 
package/api/auth.ts CHANGED
@@ -80,21 +80,14 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
80
80
  const language = Settings.localization.locales.find(
81
81
  (item) => item.value === credentials.locale
82
82
  ).apiValue;
83
- const userIp = req.headers['x-forwarded-for']?.toString() ?? '';
84
83
 
85
84
  headers.set('Content-Type', 'application/json');
86
85
  headers.set('cookie', `${req.headers.cookie}`);
87
86
  headers.set('Accept-Language', `${language}`);
88
87
  headers.set('x-currency', req.cookies['pz-currency'] ?? '');
89
- headers.set('x-forwarded-for', userIp);
90
- headers.set(
91
- 'x-app-device',
92
- req.headers['x-app-device']?.toString() ?? ''
93
- );
94
88
 
95
89
  logger.debug('Trying to login/register', {
96
- formType: credentials.formType,
97
- userIp
90
+ formType: credentials.formType
98
91
  });
99
92
 
100
93
  const apiRequest = await fetch(
@@ -106,9 +99,7 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
106
99
  }
107
100
  );
108
101
 
109
- logger.info(`Login/Register request result: ${apiRequest.status}`, {
110
- userIp
111
- });
102
+ logger.info(`Login/Register request result: ${apiRequest.status}`);
112
103
 
113
104
  const response = (await apiRequest.json()) as {
114
105
  key: string;
@@ -229,17 +220,6 @@ const nextAuthOptions = (req: NextApiRequest, res: NextApiResponse) => {
229
220
  pages: {
230
221
  signIn: ROUTES.AUTH,
231
222
  error: ROUTES.AUTH
232
- },
233
- cookies: {
234
- sessionToken: {
235
- name: `__Secure-next-auth.session-token`,
236
- options: {
237
- httpOnly: true,
238
- sameSite: 'none',
239
- path: '/',
240
- secure: true
241
- }
242
- }
243
223
  }
244
224
  };
245
225
  };
package/api/client.ts CHANGED
@@ -2,8 +2,6 @@ import { ClientRequestOptions } from '../types';
2
2
  import { NextResponse } from 'next/server';
3
3
  import settings from 'settings';
4
4
  import logger from '../utils/log';
5
- import formatCookieString from '../utils/format-cookie-string';
6
- import cookieParser from 'set-cookie-parser';
7
5
 
8
6
  interface RouteParams {
9
7
  params: {
@@ -53,6 +51,7 @@ async function proxyRequest(...args) {
53
51
 
54
52
  [
55
53
  'x-forwarded-host',
54
+ 'x-forwarded-for',
56
55
  'x-forwarded-proto',
57
56
  'x-forwarded-port',
58
57
  'x-requested-with',
@@ -133,21 +132,11 @@ async function proxyRequest(...args) {
133
132
  );
134
133
  }
135
134
 
136
- const setCookieHeaders = req.headers.getSetCookie();
137
- const exceptCookieKeys = ['pz-locale', 'pz-currency'];
138
-
139
- const isExcludedCookie = (name: string) => exceptCookieKeys.includes(name);
140
-
141
- const filteredCookies = cookieParser
142
- .parse(setCookieHeaders)
143
- .filter((cookie) => !isExcludedCookie(cookie.name));
144
-
135
+ const setCookieHeader = request.headers.get('set-cookie');
145
136
  const responseHeaders: any = {};
146
137
 
147
- if (filteredCookies.length > 0) {
148
- responseHeaders['set-cookie'] = filteredCookies
149
- .map(formatCookieString)
150
- .join(', ');
138
+ if (setCookieHeader) {
139
+ responseHeaders['set-cookie'] = setCookieHeader;
151
140
  }
152
141
 
153
142
  const statusCode = new RegExp(/^20./).test(request.status.toString())
@@ -0,0 +1,15 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { trace, context } from '@opentelemetry/api';
3
+
4
+ export async function POST(req: Request) {
5
+ const { name, value, rating, page, pathname } = await req.json();
6
+ const span = trace.getSpan(context.active());
7
+
8
+ span?.setAttribute('page', page);
9
+ span?.setAttribute(name, value);
10
+ span?.setAttribute('rating', rating);
11
+ span?.setAttribute('pathname', pathname);
12
+ span?.end();
13
+
14
+ return NextResponse.json({ success: true });
15
+ }
@@ -23,21 +23,6 @@ function checkDir() {
23
23
 
24
24
  const BASE_DIR = checkDir();
25
25
 
26
- function getProjectZeroNextPackagePath() {
27
- const possiblePaths = [
28
- path.join(BASE_DIR, 'apps/projectzeronext/package.json'),
29
- path.join(BASE_DIR, 'package.json')
30
- ];
31
-
32
- for (const packagePath of possiblePaths) {
33
- if (fs.existsSync(packagePath)) {
34
- return packagePath;
35
- }
36
- }
37
-
38
- throw new Error('Unable to find package.json in expected locations.');
39
- }
40
-
41
26
  try {
42
27
  const akinonNextPackagePath = fs.existsSync(
43
28
  path.join(BASE_DIR, 'packages/akinon-next/package.json')
@@ -49,7 +34,7 @@ try {
49
34
  fs.readFileSync(akinonNextPackagePath, 'utf8')
50
35
  );
51
36
 
52
- const projectZeroNextPackagePath = getProjectZeroNextPackagePath();
37
+ const projectZeroNextPackagePath = path.join(BASE_DIR, 'package.json');
53
38
 
54
39
  const projectZeroNextPackage = JSON.parse(
55
40
  fs.readFileSync(projectZeroNextPackagePath, 'utf8')
package/bin/pz-predev.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const runScript = require('./run-script');
4
- runScript('pz-check-env.js');
5
4
  runScript('pz-install-theme.js');
@@ -2,6 +2,7 @@ import 'server-only';
2
2
  import ClientRoot from './client-root';
3
3
  import { cookies } from 'next/headers';
4
4
  import PzProviders from './pz-providers';
5
+ import { WebVitals } from './web-vitals';
5
6
 
6
7
  export default function PzRoot({
7
8
  translations,
@@ -15,6 +16,7 @@ export default function PzRoot({
15
16
 
16
17
  return (
17
18
  <PzProviders translations={translations}>
19
+ <WebVitals />
18
20
  <ClientRoot sessionId={sessionid}>{children}</ClientRoot>
19
21
  </PzProviders>
20
22
  );
@@ -0,0 +1,74 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { ROUTES } from 'routes';
5
+ import { useGet3dRedirectFormQuery } from '@akinon/next/data/client/checkout';
6
+ import { LoaderSpinner } from 'components';
7
+ import { useLocalization } from '../../../hooks/use-localization';
8
+ import { getUrlPathWithLocale } from '../../../utils/localization';
9
+ import { useSearchParams } from 'next/navigation';
10
+
11
+ interface RedirectThreeDContentProps {
12
+ sessionId: string;
13
+ }
14
+
15
+ export default function RedirectThreeDContent({
16
+ sessionId
17
+ }: RedirectThreeDContentProps) {
18
+ const searchParams = useSearchParams();
19
+ const { data } = useGet3dRedirectFormQuery();
20
+ const [error, setError] = useState(null);
21
+ const { locale } = useLocalization();
22
+
23
+ useEffect(() => {
24
+ if (data) {
25
+ const fragment = document.createElement('fragment');
26
+ fragment.innerHTML = data.result;
27
+
28
+ const form = fragment.querySelector('form');
29
+
30
+ // a way to determine if response includes a redirection form or not
31
+ if (fragment.querySelector('link[rel="canonical"]') || !form) {
32
+ setError('Redirecting to checkout page. Please wait...');
33
+
34
+ setTimeout(() => {
35
+ let checkoutUrl = `${ROUTES.CHECKOUT}`;
36
+
37
+ // iframe param is used to prevent header and footer rendering
38
+ if (searchParams.get('iframe') === 'true') {
39
+ checkoutUrl = `${checkoutUrl}?iframe=true`;
40
+ }
41
+
42
+ // Use `window.location.href` instead of `router.push`
43
+ // to capture the url change event in iframe
44
+ location.href = getUrlPathWithLocale(checkoutUrl, locale);
45
+ }, 3000);
46
+ return;
47
+ }
48
+
49
+ const pzParamsInput = document.createElement('input');
50
+ pzParamsInput.setAttribute('type', 'hidden');
51
+ pzParamsInput.setAttribute('name', 'pzparams');
52
+ pzParamsInput.setAttribute(
53
+ 'value',
54
+ encodeURIComponent(
55
+ JSON.stringify({
56
+ session: sessionId,
57
+ locale
58
+ })
59
+ )
60
+ );
61
+ form.appendChild(pzParamsInput);
62
+
63
+ form.style.display = 'none';
64
+ document.body.appendChild(form);
65
+ form.submit();
66
+ }
67
+ }, [data]);
68
+
69
+ return (
70
+ <div className="flex items-center justify-center py-20">
71
+ {error ?? <LoaderSpinner />}
72
+ </div>
73
+ );
74
+ }
@@ -0,0 +1,17 @@
1
+ import { cookies } from 'next/headers';
2
+ import { redirect } from 'next/navigation';
3
+ import RedirectThreeDContent from './content';
4
+ import { ROUTES } from 'routes';
5
+
6
+ const RedirectThreeD = async () => {
7
+ const nextCookies = cookies();
8
+ const sessionId = await nextCookies.get('osessionid')?.value;
9
+
10
+ if (!sessionId) {
11
+ return redirect(ROUTES.CHECKOUT);
12
+ }
13
+
14
+ return <RedirectThreeDContent sessionId={sessionId} />;
15
+ };
16
+
17
+ export default RedirectThreeD;
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+
3
+ import { useReportWebVitals } from 'next/web-vitals';
4
+ import { useSelectedLayoutSegment } from 'next/navigation';
5
+ import { usePathname } from 'next/navigation';
6
+
7
+ export function WebVitals() {
8
+ let layoutSegment = useSelectedLayoutSegment();
9
+ const pathname = usePathname();
10
+
11
+ if (pathname === '/' && layoutSegment === null) {
12
+ layoutSegment = 'home';
13
+ }
14
+
15
+ useReportWebVitals((metric) => {
16
+ if (process.env.NODE_ENV !== 'development') {
17
+ return;
18
+ }
19
+
20
+ const { name, value, rating } = metric;
21
+ const page = layoutSegment || 'unknown';
22
+
23
+ fetch(`${process.env.NEXT_PUBLIC_URL}/api/web-vitals`, {
24
+ method: 'POST',
25
+ headers: {
26
+ 'Content-Type': 'application/json'
27
+ },
28
+ body: JSON.stringify({ name, value, rating, page, pathname })
29
+ });
30
+ });
31
+
32
+ return null;
33
+ }
@@ -103,8 +103,7 @@ const completeMasterpassPayment = async (
103
103
  merchantId: credentials?.merchant_id ?? null,
104
104
  msisdn,
105
105
  amount: preOrder?.unpaid_amount?.replace('.', '') ?? '',
106
- additionalParams: additionalParams ?? extras?.additionalParams,
107
- installmentCount: preOrder?.installment?.installment_count ?? 1
106
+ additionalParams: additionalParams ?? extras?.additionalParams
108
107
  };
109
108
 
110
109
  const form = isDirectPurchase
@@ -22,9 +22,9 @@ const userApi = api.injectEndpoints({
22
22
  getCaptcha: build.query<GetCaptchaResponse, void>({
23
23
  query: () => buildClientRequestUrl(user.captcha),
24
24
  transformResponse: (response: { html: string }) => {
25
- const siteKeyMatch = response.html.match(/sitekey=["|'][^"']+/gi);
25
+ const siteKeyMatch = response.html.match(/sitekey=["|']\w+/gi);
26
26
  const csrfTokenMatch = response.html.match(
27
- /name=['|"]csrfmiddlewaretoken['|"] value=['|"][^'"]+/gi
27
+ /name=['|"]csrfmiddlewaretoken['|"] value=['|"]\w+/gi
28
28
  );
29
29
  const siteKey = siteKeyMatch?.[0].replace(/sitekey=["|']/, '') || '';
30
30
  const csrfToken =
@@ -43,8 +43,7 @@ const withCompleteGpay =
43
43
  'X-Requested-With': 'XMLHttpRequest',
44
44
  'Content-Type': 'application/x-www-form-urlencoded',
45
45
  Cookie: `osessionid=${req.cookies.get('osessionid')?.value ?? ''}`,
46
- 'x-currency': req.cookies.get('pz-currency')?.value ?? '',
47
- 'x-forwarded-for': ip
46
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
48
47
  };
49
48
 
50
49
  try {
@@ -43,8 +43,7 @@ const withCompleteMasterpass =
43
43
  'X-Requested-With': 'XMLHttpRequest',
44
44
  'Content-Type': 'application/x-www-form-urlencoded',
45
45
  Cookie: `osessionid=${req.cookies.get('osessionid')?.value ?? ''}`,
46
- 'x-currency': req.cookies.get('pz-currency')?.value ?? '',
47
- 'x-forwarded-for': ip
46
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
48
47
  };
49
48
 
50
49
  try {
@@ -97,12 +97,6 @@ const withPzDefault =
97
97
  );
98
98
  }
99
99
 
100
- if (req.nextUrl.pathname.includes('/orders/redirect-three-d')) {
101
- return NextResponse.rewrite(
102
- new URL(`${encodeURI(Settings.commerceUrl)}/orders/redirect-three-d/`)
103
- );
104
- }
105
-
106
100
  // If commerce redirects to /orders/checkout/ without locale
107
101
  if (
108
102
  req.nextUrl.pathname.match(new RegExp('^/orders/checkout/$')) &&
@@ -139,8 +133,7 @@ const withPzDefault =
139
133
  Cookie: req.headers.get('cookie') || '',
140
134
  Accept: 'application/json',
141
135
  'Content-Type': 'application/json',
142
- 'X-Requested-With': 'XMLHttpRequest',
143
- 'x-forwarded-for': ip
136
+ 'X-Requested-With': 'XMLHttpRequest'
144
137
  }
145
138
  }
146
139
  );
@@ -153,7 +146,6 @@ const withPzDefault =
153
146
 
154
147
  req.middlewareParams = {
155
148
  commerceUrl,
156
- found: true,
157
149
  rewrites: {}
158
150
  };
159
151
 
@@ -187,19 +179,6 @@ const withPzDefault =
187
179
  locale.length ? `${locale}/` : ''
188
180
  }${currency}${prettyUrl ?? pathnameWithoutLocale}`;
189
181
 
190
- if (
191
- !req.middlewareParams.found &&
192
- Settings.customNotFoundEnabled
193
- ) {
194
- let pathname = url.pathname
195
- .replace(/\/+$/, '')
196
- .split('/');
197
- url.pathname = url.pathname.replace(
198
- pathname.pop(),
199
- 'pz-not-found'
200
- );
201
- }
202
-
203
182
  Settings.rewrites.forEach((rewrite) => {
204
183
  url.pathname = url.pathname.replace(
205
184
  rewrite.source,
@@ -26,7 +26,6 @@ export {
26
26
  export interface PzNextRequest extends NextRequest {
27
27
  middlewareParams: {
28
28
  commerceUrl: string;
29
- found: boolean;
30
29
  rewrites: {
31
30
  locale?: string;
32
31
  prettyUrl?: string;
@@ -15,13 +15,11 @@ const withOauthLogin =
15
15
  const loginCallbackUrlMatcherRegex = new RegExp(
16
16
  /^\/(\w+)\/login\/callback\/?$/
17
17
  );
18
- const ip = req.headers.get('x-forwarded-for') ?? '';
19
18
 
20
19
  const headers = {
21
20
  'x-forwarded-host':
22
21
  req.headers.get('x-forwarded-host') || req.headers.get('host') || '',
23
- 'x-currency': req.cookies.get('pz-currency')?.value ?? '',
24
- 'x-forwarded-for': ip
22
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
25
23
  };
26
24
 
27
25
  if (loginUrlMatcherRegex.test(url.pathname)) {
@@ -98,8 +98,6 @@ const withPrettyUrl =
98
98
  return middleware(req, event);
99
99
  }
100
100
 
101
- req.middlewareParams.found = false;
102
-
103
101
  return middleware(req, event);
104
102
  };
105
103
 
@@ -44,9 +44,7 @@ const withRedirectionPayment =
44
44
  'X-Requested-With': 'XMLHttpRequest',
45
45
  'Content-Type': 'application/x-www-form-urlencoded',
46
46
  Cookie: req.headers.get('cookie') ?? '',
47
- 'x-currency': req.cookies.get('pz-currency')?.value ?? '',
48
- 'x-forwarded-for': ip
49
-
47
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
50
48
  };
51
49
 
52
50
  try {
@@ -43,8 +43,7 @@ const withThreeDRedirection =
43
43
  'X-Requested-With': 'XMLHttpRequest',
44
44
  'Content-Type': 'application/x-www-form-urlencoded',
45
45
  Cookie: `osessionid=${req.cookies.get('osessionid')?.value ?? ''}`,
46
- 'x-currency': req.cookies.get('pz-currency')?.value ?? '',
47
- 'x-forwarded-for': ip
46
+ 'x-currency': req.cookies.get('pz-currency')?.value ?? ''
48
47
  };
49
48
 
50
49
  try {
@@ -31,9 +31,6 @@ const withUrlRedirection =
31
31
  const request = await fetch(
32
32
  `${settings.commerceUrl}${pathnameWithoutLocale}${url.search}`,
33
33
  {
34
- headers: {
35
- 'x-forwarded-for': ip
36
- },
37
34
  redirect: 'manual',
38
35
  next: {
39
36
  revalidate: 0
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.26.0-rc.8",
4
+ "version": "1.26.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -25,19 +25,14 @@
25
25
  "react-redux": "8.1.3",
26
26
  "react-string-replace": "1.1.1",
27
27
  "redis": "4.5.1",
28
- "semver": "7.5.4",
29
- "set-cookie-parser": "2.6.0"
28
+ "semver": "7.5.4"
30
29
  },
31
30
  "devDependencies": {
32
- "@akinon/eslint-plugin-projectzero": "1.24.0",
33
31
  "@types/react-redux": "7.1.30",
34
- "@types/set-cookie-parser": "2.4.7",
35
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
36
33
  "@typescript-eslint/parser": "6.7.4",
37
34
  "eslint": "^8.14.0",
35
+ "@akinon/eslint-plugin-projectzero": "1.24.0",
38
36
  "eslint-config-prettier": "8.5.0"
39
- },
40
- "peerDependencies": {
41
- "@akinon/eslint-plugin-projectzero": "1.24.0"
42
37
  }
43
38
  }
package/sentry/index.ts CHANGED
@@ -1,33 +1,27 @@
1
1
  import * as Sentry from '@sentry/nextjs';
2
- import settings from 'settings';
3
2
 
4
3
  const SENTRY_DSN: string =
5
- settings.sentryDsn ||
6
- process.env.SENTRY_DSN ||
7
- process.env.NEXT_PUBLIC_SENTRY_DSN;
4
+ process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN;
8
5
 
9
6
  export const initSentry = (
10
7
  type: 'Server' | 'Client' | 'Edge',
11
- options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {
12
- dsn: SENTRY_DSN,
13
- integrations: [],
14
- tracesSampleRate: 1.0
15
- }
8
+ options: Sentry.BrowserOptions | Sentry.NodeOptions | Sentry.EdgeOptions = {}
16
9
  ) => {
17
- const initOptions = {
18
- ...options,
10
+ // TODO: Handle options with ESLint rules
11
+
12
+ // TODO: Remove Zero Project DSN
13
+
14
+ Sentry.init({
15
+ dsn:
16
+ SENTRY_DSN ||
17
+ 'https://d8558ef8997543deacf376c7d8d7cf4b@o64293.ingest.sentry.io/4504338423742464',
19
18
  initialScope: {
20
19
  tags: {
21
- ...((
22
- options.initialScope as {
23
- tags?: Record<string, string>;
24
- }
25
- )?.tags ?? {}),
26
20
  APP_TYPE: 'ProjectZeroNext',
27
21
  TYPE: type
28
22
  }
29
- }
30
- };
31
-
32
- Sentry.init(initOptions);
23
+ },
24
+ tracesSampleRate: 1.0,
25
+ integrations: []
26
+ });
33
27
  };
package/types/index.ts CHANGED
@@ -71,12 +71,6 @@ export interface Currency {
71
71
 
72
72
  export interface Settings {
73
73
  commerceUrl: string;
74
- /**
75
- * This option allows you to track Sentry events on the client side, in addition to server and edge environments.
76
- *
77
- * It overrides process.env.NEXT_PUBLIC_SENTRY_DSN and process.env.SENTRY_DSN.
78
- */
79
- sentryDsn?: string;
80
74
  redis: {
81
75
  defaultExpirationTime: number;
82
76
  };
@@ -187,7 +181,6 @@ export interface Settings {
187
181
  extraPaymentTypes?: string[];
188
182
  masterpassJsUrl?: string;
189
183
  };
190
- customNotFoundEnabled: boolean;
191
184
  }
192
185
 
193
186
  export interface CacheOptions {
@@ -36,8 +36,7 @@ const appFetch = async <T>(
36
36
  init.headers = {
37
37
  ...(init.headers ?? {}),
38
38
  'Accept-Language': currentLocale.apiValue,
39
- 'x-currency': ServerVariables.currency,
40
- 'x-forwarded-for': ip
39
+ 'x-currency': ServerVariables.currency
41
40
  };
42
41
 
43
42
  init.next = {
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
-
5
- const invalidEnvList = [
6
- { key: 'NEXT_TELEMETRY_DISABLED', value: 1 },
7
- { key: 'OTEL_SDK_DISABLED', value: true }
8
- ];
9
-
10
- function checkEnv(invalidEnvList) {
11
- if (!fs.existsSync('.env')) {
12
- return false;
13
- }
14
-
15
- const envContent = fs.readFileSync('.env', 'utf8');
16
-
17
- invalidEnvList.forEach(({ key, value }) => {
18
- const env = `${key}=${value}`;
19
-
20
- if (envContent.includes(env)) {
21
- console.error(`Remove the ${key} environment variable`);
22
- process.exit(1);
23
- }
24
- });
25
- }
26
-
27
- checkEnv(invalidEnvList);
@@ -1,27 +0,0 @@
1
- const { execSync } = require('child_process');
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- function findBaseDir() {
6
- let currentDir = __dirname;
7
- while (currentDir !== path.resolve(currentDir, '..')) {
8
- if (fs.existsSync(path.join(currentDir, 'turbo.json'))) {
9
- return currentDir;
10
- }
11
- currentDir = path.resolve(currentDir, '..');
12
- }
13
- return null;
14
- }
15
-
16
- const BASE_DIR = findBaseDir();
17
-
18
- if (BASE_DIR) {
19
- const extensions = ['bilal-akinon.pznext'];
20
- extensions.forEach((extension) => {
21
- try {
22
- execSync(`code --install-extension ${extension}`, { stdio: 'inherit' });
23
- } catch (error) {
24
- console.error(`Error installing ${extension}:`);
25
- }
26
- });
27
- }
@@ -1,27 +0,0 @@
1
- export default function formatCookieString(cookieObj: Record<string, any>) {
2
- const cookieParts = [`${cookieObj.name}=${cookieObj.value}`];
3
-
4
- if (cookieObj.expires) {
5
- cookieParts.push(`Expires=${cookieObj.expires.toUTCString()}`);
6
- }
7
- if (cookieObj.maxAge) {
8
- cookieParts.push(`Max-Age=${cookieObj.maxAge}`);
9
- }
10
- if (cookieObj.path) {
11
- cookieParts.push(`Path=${cookieObj.path}`);
12
- }
13
- if (cookieObj.domain) {
14
- cookieParts.push(`Domain=${cookieObj.domain}`);
15
- }
16
- if (cookieObj.secure) {
17
- cookieParts.push('Secure');
18
- }
19
- if (cookieObj.httpOnly) {
20
- cookieParts.push('HttpOnly');
21
- }
22
- if (cookieObj.sameSite) {
23
- cookieParts.push(`SameSite=${cookieObj.sameSite}`);
24
- }
25
-
26
- return cookieParts.join('; ');
27
- }
package/utils/redirect.ts DELETED
@@ -1,30 +0,0 @@
1
- import { redirect as nextRedirect, RedirectType } from 'next/navigation';
2
- import Settings from 'settings';
3
- import { headers } from 'next/headers';
4
- import { ServerVariables } from '@akinon/next/utils/server-variables';
5
- import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
6
-
7
- export const redirect = (path: string, type?: RedirectType) => {
8
- const nextHeaders = headers();
9
- const pageUrl = new URL(
10
- nextHeaders.get('pz-url') ?? process.env.NEXT_PUBLIC_URL
11
- );
12
-
13
- const currentLocale = Settings.localization.locales.find(
14
- (locale) => locale.value === ServerVariables.locale
15
- );
16
-
17
- const callbackUrl = pageUrl.pathname;
18
- const redirectUrlWithLocale = getUrlPathWithLocale(
19
- path,
20
- currentLocale.localePath ?? currentLocale.value
21
- );
22
-
23
- const redirectUrl = `${redirectUrlWithLocale}?callbackUrl=${callbackUrl}`;
24
-
25
- if (type) {
26
- return nextRedirect(redirectUrl, type);
27
- } else {
28
- return nextRedirect(redirectUrl);
29
- }
30
- };