@akinon/next 1.111.0-snapshot-ZERO-3792-20251107072714 → 1.112.0-rc.17
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 +15 -2
- package/api/image-proxy.ts +75 -0
- package/api/similar-product-list.ts +63 -0
- package/api/similar-products.ts +111 -0
- package/api/virtual-try-on.ts +9 -83
- package/components/plugin-module.tsx +34 -13
- package/components/selected-payment-option-view.tsx +1 -0
- package/data/urls.ts +5 -1
- package/hooks/use-payment-options.ts +2 -1
- package/middlewares/default.ts +217 -208
- package/middlewares/index.ts +3 -1
- package/middlewares/masterpass-rest-callback.ts +218 -0
- package/package.json +2 -2
- package/plugins.d.ts +15 -0
- package/plugins.js +3 -1
- package/redux/middlewares/checkout.ts +4 -1
- package/redux/middlewares/pre-order/installment-option.ts +1 -0
- package/redux/reducers/index.ts +3 -1
- package/types/index.ts +6 -0
- package/utils/mobile-3d-iframe.ts +8 -2
- package/utils/redirection-iframe.ts +8 -2
package/middlewares/default.ts
CHANGED
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
withThreeDRedirection,
|
|
14
14
|
withUrlRedirection,
|
|
15
15
|
withCompleteWallet,
|
|
16
|
-
withWalletCompleteRedirection
|
|
16
|
+
withWalletCompleteRedirection,
|
|
17
|
+
withMasterpassRestCallback
|
|
17
18
|
} from '.';
|
|
18
19
|
import { urlLocaleMatcherRegex } from '../utils';
|
|
19
20
|
import withCurrency from './currency';
|
|
@@ -230,226 +231,235 @@ const withPzDefault =
|
|
|
230
231
|
withCompleteMasterpass(
|
|
231
232
|
withSavedCardRedirection(
|
|
232
233
|
withCompleteWallet(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
234
|
+
withWalletCompleteRedirection(
|
|
235
|
+
withMasterpassRestCallback(
|
|
236
|
+
async (
|
|
237
|
+
req: PzNextRequest,
|
|
238
|
+
event: NextFetchEvent
|
|
239
|
+
) => {
|
|
240
|
+
let middlewareResult: NextResponse | void =
|
|
241
|
+
NextResponse.next();
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
const { locale, prettyUrl, currency } =
|
|
245
|
+
req.middlewareParams.rewrites;
|
|
246
|
+
const { defaultLocaleValue } =
|
|
247
|
+
Settings.localization;
|
|
248
|
+
const url = req.nextUrl.clone();
|
|
249
|
+
const pathnameWithoutLocale =
|
|
250
|
+
url.pathname.replace(
|
|
251
|
+
urlLocaleMatcherRegex,
|
|
252
|
+
''
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
middlewareResult = (await middleware(
|
|
256
|
+
req,
|
|
257
|
+
event
|
|
258
|
+
)) as NextResponse | void;
|
|
259
|
+
|
|
260
|
+
let customRewriteUrlDiff = '';
|
|
261
|
+
|
|
262
|
+
if (
|
|
263
|
+
middlewareResult instanceof
|
|
264
|
+
NextResponse &&
|
|
265
|
+
middlewareResult.headers.get(
|
|
266
|
+
'pz-override-response'
|
|
267
|
+
) &&
|
|
268
|
+
middlewareResult.headers.get(
|
|
269
|
+
'x-middleware-rewrite'
|
|
270
|
+
)
|
|
271
|
+
) {
|
|
272
|
+
const rewriteUrl = new URL(
|
|
273
|
+
middlewareResult.headers.get(
|
|
274
|
+
'x-middleware-rewrite'
|
|
275
|
+
)
|
|
276
|
+
);
|
|
277
|
+
const originalUrl = new URL(req.url);
|
|
278
|
+
customRewriteUrlDiff =
|
|
279
|
+
rewriteUrl.pathname.replace(
|
|
280
|
+
originalUrl.pathname,
|
|
281
|
+
''
|
|
282
|
+
);
|
|
283
|
+
}
|
|
281
284
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
285
|
+
url.basePath = `/${commerceUrl}`;
|
|
286
|
+
url.pathname = `/${
|
|
287
|
+
locale.length ? `${locale}/` : ''
|
|
288
|
+
}${currency}/${customRewriteUrlDiff}${
|
|
289
|
+
prettyUrl ?? pathnameWithoutLocale
|
|
290
|
+
}`.replace(/\/+/g, '/');
|
|
291
|
+
|
|
292
|
+
if (
|
|
293
|
+
Settings.usePrettyUrlRoute &&
|
|
294
|
+
url.searchParams.toString().length > 0 &&
|
|
295
|
+
!Object.entries(ROUTES).find(
|
|
296
|
+
([, value]) =>
|
|
297
|
+
new RegExp(`^${value}/?$`).test(
|
|
298
|
+
pathnameWithoutLocale
|
|
299
|
+
)
|
|
300
|
+
)
|
|
301
|
+
) {
|
|
302
|
+
url.pathname =
|
|
303
|
+
url.pathname +
|
|
304
|
+
(/\/$/.test(url.pathname) ? '' : '/') +
|
|
305
|
+
`searchparams|${encodeURIComponent(
|
|
306
|
+
url.searchParams.toString()
|
|
307
|
+
)}`;
|
|
308
|
+
}
|
|
305
309
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
310
|
+
Settings.rewrites.forEach((rewrite) => {
|
|
311
|
+
url.pathname = url.pathname.replace(
|
|
312
|
+
rewrite.source,
|
|
313
|
+
rewrite.destination
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// if middleware.ts has a return value for current url
|
|
318
|
+
if (
|
|
319
|
+
middlewareResult instanceof NextResponse
|
|
320
|
+
) {
|
|
321
|
+
// pz-override-response header is used to prevent 404 page for custom responses.
|
|
322
|
+
if (
|
|
323
|
+
middlewareResult.headers.get(
|
|
324
|
+
'pz-override-response'
|
|
325
|
+
) !== 'true'
|
|
326
|
+
) {
|
|
327
|
+
middlewareResult.headers.set(
|
|
328
|
+
'x-middleware-rewrite',
|
|
329
|
+
url.href
|
|
330
|
+
);
|
|
331
|
+
} else if (
|
|
332
|
+
middlewareResult.headers.get(
|
|
333
|
+
'x-middleware-rewrite'
|
|
334
|
+
) &&
|
|
335
|
+
middlewareResult.headers.get(
|
|
336
|
+
'pz-override-response'
|
|
337
|
+
) === 'true'
|
|
338
|
+
) {
|
|
339
|
+
middlewareResult =
|
|
340
|
+
NextResponse.rewrite(url);
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
// if middleware.ts doesn't have a return value.
|
|
344
|
+
// e.g. NextResponse.next() doesn't exist in middleware.ts
|
|
339
345
|
|
|
340
|
-
|
|
341
|
-
|
|
346
|
+
middlewareResult =
|
|
347
|
+
NextResponse.rewrite(url);
|
|
348
|
+
}
|
|
342
349
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
350
|
+
const { localeUrlStrategy } =
|
|
351
|
+
Settings.localization;
|
|
352
|
+
|
|
353
|
+
const fallbackHost =
|
|
354
|
+
req.headers.get('x-forwarded-host') ||
|
|
355
|
+
req.headers.get('host');
|
|
356
|
+
const hostname =
|
|
357
|
+
process.env.NEXT_PUBLIC_URL ||
|
|
358
|
+
`https://${fallbackHost}`;
|
|
359
|
+
const rootHostname =
|
|
360
|
+
localeUrlStrategy ===
|
|
361
|
+
LocaleUrlStrategy.Subdomain
|
|
362
|
+
? getRootHostname(hostname)
|
|
363
|
+
: null;
|
|
364
|
+
|
|
365
|
+
if (
|
|
366
|
+
!url.pathname.startsWith(
|
|
367
|
+
`/${currency}/orders`
|
|
368
|
+
)
|
|
369
|
+
) {
|
|
370
|
+
middlewareResult.cookies.set(
|
|
371
|
+
'pz-locale',
|
|
372
|
+
locale?.length > 0
|
|
373
|
+
? locale
|
|
374
|
+
: defaultLocaleValue,
|
|
375
|
+
{
|
|
376
|
+
domain: rootHostname,
|
|
377
|
+
sameSite: 'none',
|
|
378
|
+
secure: true,
|
|
379
|
+
expires: new Date(
|
|
380
|
+
Date.now() + 1000 * 60 * 60 * 24 * 7
|
|
381
|
+
) // 7 days
|
|
382
|
+
}
|
|
383
|
+
);
|
|
375
384
|
}
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
385
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
if (
|
|
393
|
-
req.cookies.get('pz-locale') &&
|
|
394
|
-
req.cookies.get('pz-locale').value !== locale
|
|
395
|
-
) {
|
|
396
|
-
logger.debug('Locale changed', {
|
|
397
|
-
locale,
|
|
398
|
-
oldLocale:
|
|
399
|
-
req.cookies.get('pz-locale')?.value,
|
|
400
|
-
ip
|
|
401
|
-
});
|
|
402
|
-
}
|
|
386
|
+
middlewareResult.cookies.set(
|
|
387
|
+
'pz-currency',
|
|
388
|
+
currency,
|
|
389
|
+
{
|
|
390
|
+
domain: rootHostname,
|
|
391
|
+
sameSite: 'none',
|
|
392
|
+
secure: true,
|
|
393
|
+
expires: new Date(
|
|
394
|
+
Date.now() + 1000 * 60 * 60 * 24 * 7
|
|
395
|
+
) // 7 days
|
|
396
|
+
}
|
|
397
|
+
);
|
|
403
398
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
399
|
+
if (
|
|
400
|
+
req.cookies.get('pz-locale') &&
|
|
401
|
+
req.cookies.get('pz-locale').value !==
|
|
402
|
+
locale
|
|
403
|
+
) {
|
|
404
|
+
logger.debug('Locale changed', {
|
|
405
|
+
locale,
|
|
406
|
+
oldLocale:
|
|
407
|
+
req.cookies.get('pz-locale')?.value,
|
|
408
|
+
ip
|
|
409
|
+
});
|
|
410
|
+
}
|
|
408
411
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
412
|
+
middlewareResult.headers.set(
|
|
413
|
+
'pz-url',
|
|
414
|
+
req.nextUrl.toString()
|
|
415
|
+
);
|
|
414
416
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
417
|
+
if (req.cookies.get('pz-set-currency')) {
|
|
418
|
+
middlewareResult.cookies.delete(
|
|
419
|
+
'pz-set-currency'
|
|
420
|
+
);
|
|
421
|
+
}
|
|
421
422
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
423
|
+
if (process.env.ACC_APP_VERSION) {
|
|
424
|
+
middlewareResult.headers.set(
|
|
425
|
+
'acc-app-version',
|
|
426
|
+
process.env.ACC_APP_VERSION
|
|
427
|
+
);
|
|
428
|
+
}
|
|
425
429
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
430
|
+
// Set CSRF token if not set
|
|
431
|
+
try {
|
|
432
|
+
const url = `${Settings.commerceUrl}${user.csrfToken}`;
|
|
433
|
+
|
|
434
|
+
if (!req.cookies.get('csrftoken')) {
|
|
435
|
+
const { csrf_token } = await (
|
|
436
|
+
await fetch(url)
|
|
437
|
+
).json();
|
|
438
|
+
middlewareResult.cookies.set(
|
|
439
|
+
'csrftoken',
|
|
440
|
+
csrf_token,
|
|
441
|
+
{
|
|
442
|
+
domain: rootHostname
|
|
443
|
+
}
|
|
444
|
+
);
|
|
435
445
|
}
|
|
436
|
-
)
|
|
446
|
+
} catch (error) {
|
|
447
|
+
logger.error('CSRF Error', {
|
|
448
|
+
error,
|
|
449
|
+
ip
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
} catch (error) {
|
|
453
|
+
logger.error('withPzDefault Error', {
|
|
454
|
+
error,
|
|
455
|
+
ip
|
|
456
|
+
});
|
|
437
457
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
error,
|
|
441
|
-
ip
|
|
442
|
-
});
|
|
458
|
+
|
|
459
|
+
return middlewareResult;
|
|
443
460
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
error,
|
|
447
|
-
ip
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return middlewareResult;
|
|
452
|
-
}
|
|
461
|
+
)
|
|
462
|
+
)
|
|
453
463
|
)
|
|
454
464
|
)
|
|
455
465
|
)
|
|
@@ -461,7 +471,6 @@ const withPzDefault =
|
|
|
461
471
|
)
|
|
462
472
|
)
|
|
463
473
|
)
|
|
464
|
-
)
|
|
465
474
|
)(req, event);
|
|
466
475
|
};
|
|
467
476
|
|
package/middlewares/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import withCheckoutProvider from './checkout-provider';
|
|
|
11
11
|
import withSavedCardRedirection from './saved-card-redirection';
|
|
12
12
|
import withCompleteWallet from './complete-wallet';
|
|
13
13
|
import withWalletCompleteRedirection from './wallet-complete-redirection';
|
|
14
|
+
import withMasterpassRestCallback from './masterpass-rest-callback';
|
|
14
15
|
import { NextRequest } from 'next/server';
|
|
15
16
|
|
|
16
17
|
export {
|
|
@@ -26,7 +27,8 @@ export {
|
|
|
26
27
|
withCheckoutProvider,
|
|
27
28
|
withSavedCardRedirection,
|
|
28
29
|
withCompleteWallet,
|
|
29
|
-
withWalletCompleteRedirection
|
|
30
|
+
withWalletCompleteRedirection,
|
|
31
|
+
withMasterpassRestCallback
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export interface PzNextRequest extends NextRequest {
|