@akinon/next 1.32.0-rc.2 → 1.32.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,28 +1,8 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.32.0-rc.2
3
+ ## 1.32.0
4
4
 
5
- ## 1.32.0-rc.1
6
-
7
- ### Minor Changes
8
-
9
- - d09b677: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
10
- - 6d4aadb: ZERO-2476: Auto install recommendenent extension
11
- - 7cebe87: ZERO-2524: Add check monorepo utility function
12
- - f0c23bc: ZERO-2135: add custom not found page
13
- - 495d155: ZERO-2505: findBaseDir function is united and move on to the utils
14
- - 40ad73e: ZERO-2504: add cookie filter to api client request
15
- - 495d155: ZERO-2524: Zero-cli dist checks for changes and renders it to the terminal.
16
- - f046f8e: ZERO-2575: update version for react-number-format
17
- - 6b2972b: ZERO-2514: Fix handling of status 204 and return Commerce status code in client proxy API.
18
- - 3e68768: ZERO-2578: Add osessionid check in middleware
19
-
20
- ## 1.32.0-rc.0
21
-
22
- ### Minor Changes
23
-
24
- - 7cebe87: ZERO-2524: Add check monorepo utility function
25
- - 3e68768: ZERO-2578: Add osessionid check in middleware
5
+ ## 1.31.1
26
6
 
27
7
  ## 1.31.0
28
8
 
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: {
@@ -115,14 +113,6 @@ async function proxyRequest(...args) {
115
113
 
116
114
  try {
117
115
  const request = await fetch(url, fetchOptions);
118
-
119
- // Using NextResponse.json with status 204 will cause an error
120
- if (request.status === 204) {
121
- return new Response(null, {
122
- status: 204
123
- });
124
- }
125
-
126
116
  let response = {} as any;
127
117
 
128
118
  try {
@@ -141,26 +131,20 @@ async function proxyRequest(...args) {
141
131
  );
142
132
  }
143
133
 
144
- const setCookieHeaders = req.headers.getSetCookie();
145
- const exceptCookieKeys = ['pz-locale', 'pz-currency'];
146
-
147
- const isExcludedCookie = (name: string) => exceptCookieKeys.includes(name);
148
-
149
- const filteredCookies = cookieParser
150
- .parse(setCookieHeaders)
151
- .filter((cookie) => !isExcludedCookie(cookie.name));
152
-
134
+ const setCookieHeader = request.headers.get('set-cookie');
153
135
  const responseHeaders: any = {};
154
136
 
155
- if (filteredCookies.length > 0) {
156
- responseHeaders['set-cookie'] = filteredCookies
157
- .map(formatCookieString)
158
- .join(', ');
137
+ if (setCookieHeader) {
138
+ responseHeaders['set-cookie'] = setCookieHeader;
159
139
  }
160
140
 
141
+ const statusCode = new RegExp(/^20./).test(request.status.toString())
142
+ ? 200
143
+ : request.status;
144
+
161
145
  return NextResponse.json(
162
146
  options.responseType === 'text' ? { result: response } : response,
163
- { status: request.status, headers: responseHeaders }
147
+ { status: statusCode, headers: responseHeaders }
164
148
  );
165
149
  } catch (error) {
166
150
  logger.error('Client proxy request failed', error);
@@ -1,7 +1,13 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
- const findBaseDir = require('../utils/find-base-dir');
4
+
5
+ function findBaseDir() {
6
+ const insideNodeModules = __dirname.includes('node_modules');
7
+ return insideNodeModules
8
+ ? process.cwd()
9
+ : path.resolve(__dirname, '../../../apps/projectzeronext');
10
+ }
5
11
 
6
12
  const BASE_DIR = findBaseDir();
7
13
  const getFullPath = (relativePath) => path.join(BASE_DIR, relativePath);
@@ -3,7 +3,16 @@
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
5
  const spawn = require('cross-spawn');
6
- const findBaseDir = require('../utils/find-base-dir');
6
+
7
+ function findBaseDir() {
8
+ const insideNodeModules = __dirname.includes('node_modules');
9
+
10
+ if (insideNodeModules) {
11
+ return path.resolve(__dirname, '../../../../');
12
+ } else {
13
+ return path.resolve(__dirname, '../../../apps/projectzeronext');
14
+ }
15
+ }
7
16
 
8
17
  const BASE_DIR = findBaseDir();
9
18
 
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const runScript = require('./run-script');
4
-
5
4
  runScript('pz-install-theme.js');
6
- runScript('pz-pre-check-dist.js');
package/bin/pz-predev.js CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const runScript = require('./run-script');
4
-
5
- runScript('pz-install-extensions.js');
6
4
  runScript('pz-check-env.js');
7
5
  runScript('pz-install-theme.js');
@@ -1,28 +1,17 @@
1
1
  import clsx from 'clsx';
2
- import { forwardRef, FocusEvent, useState, Ref } from 'react';
2
+ import { forwardRef, FocusEvent, useState } from 'react';
3
3
  import { Controller } from 'react-hook-form';
4
- import { PatternFormat, PatternFormatProps } from 'react-number-format';
4
+ import NumberFormat, { NumberFormatProps } from 'react-number-format';
5
5
  import { InputProps } from '../types';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
 
8
- const PatternFormatWithRef = forwardRef(
9
- (props: PatternFormatProps, ref: Ref<HTMLInputElement>) => {
10
- return <PatternFormat {...props} getInputRef={ref} />;
11
- }
12
- );
13
- PatternFormatWithRef.displayName = 'PatternFormatWithRef';
14
-
15
8
  export const Input = forwardRef<
16
9
  HTMLInputElement,
17
10
  InputProps &
18
11
  Pick<
19
- PatternFormatProps,
20
- 'mask' | 'allowEmptyFormatting' | 'onValueChange'
21
- > & {
22
- format?: string;
23
- defaultValue?: string;
24
- type?: string;
25
- }
12
+ NumberFormatProps,
13
+ 'format' | 'mask' | 'allowEmptyFormatting' | 'onValueChange'
14
+ >
26
15
  >((props, ref) => {
27
16
  const [focused, setFocused] = useState(false);
28
17
  const [hasValue, setHasValue] = useState(false);
@@ -48,7 +37,6 @@ export const Input = forwardRef<
48
37
  ),
49
38
  props.className
50
39
  );
51
-
52
40
  const inputProps: any = {
53
41
  id,
54
42
  ref,
@@ -91,14 +79,14 @@ export const Input = forwardRef<
91
79
  <Controller
92
80
  name={props.name ?? ''}
93
81
  control={props.control}
82
+ defaultValue={false}
94
83
  render={({ field }) => (
95
- <PatternFormatWithRef
84
+ <NumberFormat
96
85
  format={format}
97
86
  mask={mask ?? ''}
98
87
  {...rest}
99
88
  {...field}
100
89
  {...inputProps}
101
- type={props.type as 'text' | 'password' | 'tel'}
102
90
  />
103
91
  )}
104
92
  />
@@ -1,11 +1,11 @@
1
1
  import { useMemo } from 'react';
2
- import { NumericFormat, NumericFormatProps } from 'react-number-format';
2
+ import NumberFormat, { NumberFormatProps } from 'react-number-format';
3
3
  import { getCurrency } from '@akinon/next/utils';
4
4
 
5
5
  import { useLocalization } from '@akinon/next/hooks';
6
6
  import { PriceProps } from '../types';
7
7
 
8
- export const Price = (props: NumericFormatProps & PriceProps) => {
8
+ export const Price = (props: NumberFormatProps & PriceProps) => {
9
9
  const {
10
10
  value,
11
11
  currencyCode,
@@ -39,7 +39,7 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
39
39
  );
40
40
 
41
41
  return (
42
- <NumericFormat
42
+ <NumberFormat
43
43
  value={useNegative ? `-${useNegativeSpace}${_value}` : _value}
44
44
  {...{
45
45
  [useCurrencyAfterPrice ? 'suffix' : 'prefix']: currency
@@ -28,11 +28,7 @@ function reducer(state: InitialState, action: ACTIONTYPE) {
28
28
  case 'setPage':
29
29
  return { ...state, page: action.payload };
30
30
  case 'setLimit':
31
- return {
32
- ...state,
33
- limit: action.payload,
34
- last: Math.ceil(state.total / action.payload)
35
- };
31
+ return { ...state, limit: action.payload };
36
32
  default:
37
33
  throw new Error();
38
34
  }
@@ -50,11 +46,10 @@ export default function usePagination(
50
46
  () => new URLSearchParams(searchParams.toString()),
51
47
  [searchParams]
52
48
  );
53
-
54
49
  const { page, limit } = useMemo(
55
50
  () => ({
56
51
  page: _page || Number(searchParams.get('page')) || 1,
57
- limit: _limit || Number(searchParams.get('limit')) || 12
52
+ limit: _limit || Number(searchParams.get('limit'))
58
53
  }),
59
54
  [searchParams, _page, _limit]
60
55
  );
@@ -65,7 +60,6 @@ export default function usePagination(
65
60
  last: _last || Math.ceil(_total / limit) || 1,
66
61
  total: _total
67
62
  };
68
-
69
63
  const [state, dispatch] = useReducer(reducer, initialState);
70
64
 
71
65
  useEffect(() => {
@@ -99,24 +93,23 @@ export default function usePagination(
99
93
  [dispatch]
100
94
  );
101
95
 
102
- const pageList = useMemo(
103
- () =>
104
- Array.from({ length: state.last }, (_, i) => {
105
- urlSearchParams.set('page', (i + 1).toString());
106
- return {
107
- page: i + 1,
108
- url: `${pathname}?${urlSearchParams.toString()}`
109
- };
110
- }),
111
- [state.last, pathname, urlSearchParams]
112
- );
96
+ const pageList = useMemo(() => {
97
+ return Array.from({ length: state.last }, (_, i) => {
98
+ urlSearchParams.set('page', (i + 1).toString());
99
+
100
+ return {
101
+ page: i + 1,
102
+ url: `${pathname}?${urlSearchParams.toString()}`
103
+ };
104
+ });
105
+ }, [state.last, pathname, urlSearchParams]);
113
106
 
114
107
  const prev = useMemo(() => {
115
108
  if (state.page > 1) {
116
109
  urlSearchParams.set('page', (Number(state.page) - 1).toString());
117
110
  return `${pathname}?${urlSearchParams.toString()}`;
118
111
  }
119
- return '#';
112
+ return null;
120
113
  }, [state.page, pathname, urlSearchParams]);
121
114
 
122
115
  const next = useMemo(() => {
@@ -124,7 +117,7 @@ export default function usePagination(
124
117
  urlSearchParams.set('page', (Number(state.page) + 1).toString());
125
118
  return `${pathname}?${urlSearchParams.toString()}`;
126
119
  }
127
- return '#';
120
+ return null;
128
121
  }, [state.page, state.last, pathname, urlSearchParams]);
129
122
 
130
123
  return {
@@ -33,7 +33,6 @@ const withCompleteGpay =
33
33
  async (req: PzNextRequest, event: NextFetchEvent) => {
34
34
  const url = req.nextUrl.clone();
35
35
  const ip = req.headers.get('x-forwarded-for') ?? '';
36
- const sessionId = req.cookies.get('osessionid');
37
36
 
38
37
  if (url.search.indexOf('GPayCompletePage') === -1) {
39
38
  return middleware(req, event);
@@ -51,24 +50,6 @@ const withCompleteGpay =
51
50
  try {
52
51
  const body = await streamToString(req.body);
53
52
 
54
- if (!sessionId) {
55
- logger.warn(
56
- 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
57
- {
58
- middleware: 'complete-masterpass',
59
- ip
60
- }
61
- );
62
-
63
- return NextResponse.redirect(
64
- `${url.origin}${getUrlPathWithLocale(
65
- '/orders/checkout/',
66
- req.cookies.get('pz-locale')?.value
67
- )}`,
68
- 303
69
- );
70
- }
71
-
72
53
  const request = await fetch(requestUrl, {
73
54
  method: 'POST',
74
55
  headers: requestHeaders,
@@ -33,7 +33,6 @@ const withCompleteMasterpass =
33
33
  async (req: PzNextRequest, event: NextFetchEvent) => {
34
34
  const url = req.nextUrl.clone();
35
35
  const ip = req.headers.get('x-forwarded-for') ?? '';
36
- const sessionId = req.cookies.get('osessionid');
37
36
 
38
37
  if (url.search.indexOf('MasterpassCompletePage') === -1) {
39
38
  return middleware(req, event);
@@ -51,24 +50,6 @@ const withCompleteMasterpass =
51
50
  try {
52
51
  const body = await streamToString(req.body);
53
52
 
54
- if (!sessionId) {
55
- logger.warn(
56
- 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
57
- {
58
- middleware: 'complete-masterpass',
59
- ip
60
- }
61
- );
62
-
63
- return NextResponse.redirect(
64
- `${url.origin}${getUrlPathWithLocale(
65
- '/orders/checkout/',
66
- req.cookies.get('pz-locale')?.value
67
- )}`,
68
- 303
69
- );
70
- }
71
-
72
53
  const request = await fetch(requestUrl, {
73
54
  method: 'POST',
74
55
  headers: requestHeaders,
@@ -153,7 +153,6 @@ const withPzDefault =
153
153
 
154
154
  req.middlewareParams = {
155
155
  commerceUrl,
156
- found: true,
157
156
  rewrites: {}
158
157
  };
159
158
 
@@ -187,19 +186,6 @@ const withPzDefault =
187
186
  locale.length ? `${locale}/` : ''
188
187
  }${currency}${prettyUrl ?? pathnameWithoutLocale}`;
189
188
 
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
189
  Settings.rewrites.forEach((rewrite) => {
204
190
  url.pathname = url.pathname.replace(
205
191
  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;
@@ -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
 
@@ -34,7 +34,6 @@ const withRedirectionPayment =
34
34
  const url = req.nextUrl.clone();
35
35
  const searchParams = new URLSearchParams(url.search);
36
36
  const ip = req.headers.get('x-forwarded-for') ?? '';
37
- const sessionId = req.cookies.get('osessionid');
38
37
 
39
38
  if (searchParams.get('page') !== 'RedirectionPageCompletePage') {
40
39
  return middleware(req, event);
@@ -47,29 +46,12 @@ const withRedirectionPayment =
47
46
  Cookie: req.headers.get('cookie') ?? '',
48
47
  'x-currency': req.cookies.get('pz-currency')?.value ?? '',
49
48
  'x-forwarded-for': ip
49
+
50
50
  };
51
51
 
52
52
  try {
53
53
  const body = await streamToString(req.body);
54
54
 
55
- if (!sessionId) {
56
- logger.warn(
57
- 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
58
- {
59
- middleware: 'redirection-payment',
60
- ip
61
- }
62
- );
63
-
64
- return NextResponse.redirect(
65
- `${url.origin}${getUrlPathWithLocale(
66
- '/orders/checkout/',
67
- req.cookies.get('pz-locale')?.value
68
- )}`,
69
- 303
70
- );
71
- }
72
-
73
55
  const request = await fetch(requestUrl, {
74
56
  method: 'POST',
75
57
  headers: requestHeaders,
@@ -33,7 +33,6 @@ const withThreeDRedirection =
33
33
  async (req: PzNextRequest, event: NextFetchEvent) => {
34
34
  const url = req.nextUrl.clone();
35
35
  const ip = req.headers.get('x-forwarded-for') ?? '';
36
- const sessionId = req.cookies.get('osessionid');
37
36
 
38
37
  if (url.search.indexOf('CreditCardThreeDSecurePage') === -1) {
39
38
  return middleware(req, event);
@@ -51,24 +50,6 @@ const withThreeDRedirection =
51
50
  try {
52
51
  const body = await streamToString(req.body);
53
52
 
54
- if (!sessionId) {
55
- logger.warn(
56
- 'Make sure that the SESSION_COOKIE_SAMESITE environment variable is set to None in Commerce.',
57
- {
58
- middleware: 'three-d-redirection',
59
- ip
60
- }
61
- );
62
-
63
- return NextResponse.redirect(
64
- `${url.origin}${getUrlPathWithLocale(
65
- '/orders/checkout/',
66
- req.cookies.get('pz-locale')?.value
67
- )}`,
68
- 303
69
- );
70
- }
71
-
72
53
  const request = await fetch(requestUrl, {
73
54
  method: 'POST',
74
55
  headers: requestHeaders,
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.32.0-rc.2",
4
+ "version": "1.32.0",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -25,16 +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
31
  "@types/react-redux": "7.1.30",
33
- "@types/set-cookie-parser": "2.4.7",
34
32
  "@typescript-eslint/eslint-plugin": "6.7.4",
35
33
  "@typescript-eslint/parser": "6.7.4",
36
34
  "eslint": "^8.14.0",
37
- "@akinon/eslint-plugin-projectzero": "1.32.0-rc.2",
35
+ "@akinon/eslint-plugin-projectzero": "1.32.0",
38
36
  "eslint-config-prettier": "8.5.0"
39
37
  }
40
38
  }
package/types/index.ts CHANGED
@@ -181,7 +181,6 @@ export interface Settings {
181
181
  extraPaymentTypes?: string[];
182
182
  masterpassJsUrl?: string;
183
183
  };
184
- customNotFoundEnabled: boolean;
185
184
  }
186
185
 
187
186
  export interface CacheOptions {
@@ -1,43 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const projectZeroNextDir = path.join(
4
- __dirname,
5
- '../../../apps/projectzeronext'
6
- );
7
-
8
- const templatesDir = path.join(
9
- __dirname,
10
- '../../../packages/projectzero-cli/app-template'
11
- );
12
-
13
- if (fs.existsSync(templatesDir)) {
14
- fs.rmdirSync(templatesDir, { recursive: true });
15
- }
16
-
17
- function copyRecursively(src, dest) {
18
- if (path.basename(src) === 'node_modules') {
19
- return;
20
- }
21
-
22
- if (fs.existsSync(src) && fs.statSync(src).isDirectory()) {
23
- fs.mkdirSync(dest, { recursive: true });
24
- fs.readdirSync(src).forEach((childItemName) => {
25
- const childSrcPath = path.join(src, childItemName);
26
- const childDestPath = path.join(dest, childItemName);
27
- copyRecursively(childSrcPath, childDestPath);
28
- });
29
- } else {
30
- fs.copyFileSync(src, dest);
31
- }
32
- }
33
-
34
- if (!fs.existsSync(templatesDir)) {
35
- fs.mkdirSync(templatesDir, { recursive: true });
36
- }
37
-
38
- copyRecursively(projectZeroNextDir, templatesDir);
39
-
40
- console.log(
41
- '\x1b[33m%s\x1b[0m',
42
- 'projectzeronext content has been copied to templates.'
43
- );
@@ -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,21 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const hashDirectory = require('../utils/hash-directory');
4
- const checkMonorepo = require('../utils/check-monorepo');
5
-
6
- const BASE_DIR = checkMonorepo();
7
-
8
- if (!BASE_DIR) {
9
- process.exit(0);
10
- }
11
-
12
- const packageDistPath = path.join(
13
- __dirname,
14
- '../../../packages/projectzero-cli/dist/commands'
15
- );
16
-
17
- const hash = hashDirectory(packageDistPath);
18
- fs.writeFileSync(
19
- path.join(__dirname, '../../../packages/projectzero-cli/dist/dist-hash.txt'),
20
- hash
21
- );
@@ -1,15 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- function checkMonorepo() {
5
- let currentDir = __dirname;
6
- while (currentDir !== path.resolve(currentDir, '..')) {
7
- if (fs.existsSync(path.join(currentDir, 'turbo.json'))) {
8
- return currentDir;
9
- }
10
- currentDir = path.resolve(currentDir, '..');
11
- }
12
- return null;
13
- }
14
-
15
- module.exports = checkMonorepo;
@@ -1,13 +0,0 @@
1
- const path = require('path');
2
-
3
- function findBaseDir() {
4
- const insideNodeModules = __dirname.includes('node_modules');
5
-
6
- if (insideNodeModules) {
7
- return path.resolve(__dirname, '../../../../');
8
- } else {
9
- return path.resolve(__dirname, '../../../apps/projectzeronext');
10
- }
11
- }
12
-
13
- module.exports = findBaseDir;
@@ -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
- }
@@ -1,18 +0,0 @@
1
- const { createHash } = require('crypto');
2
- const fs = require('fs');
3
- const path = require('path');
4
-
5
- function hashDirectory(directory) {
6
- const files = fs.readdirSync(directory).sort();
7
- const hash = createHash('sha256');
8
- files.forEach((file) => {
9
- const filePath = path.join(directory, file);
10
- if (fs.statSync(filePath).isFile()) {
11
- const fileBuffer = fs.readFileSync(filePath);
12
- hash.update(fileBuffer);
13
- }
14
- });
15
- return hash.digest('hex');
16
- }
17
-
18
- module.exports = hashDirectory;