@faststore/core 3.100.2 → 3.100.3
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +47 -47
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +2 -2
- package/.next/server/pages/api/fs/password-protection/unlock.js +1 -0
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/{fs-auth-login.html → password-protection.html} +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages-manifest.json +1 -1
- package/.next/server/src/middleware.js +33 -33
- package/.next/server/src/middleware.js.map +1 -1
- package/.next/static/0OKcQtIHO8diwBsczup15/_buildManifest.js +1 -0
- package/.next/static/chunks/main-a2d1cfe626f2fef1.js +1 -0
- package/.next/static/chunks/pages/password-protection-8dece47ea041d372.js +1 -0
- package/.next/static/chunks/{webpack-95c583fdc5f7d468.js → webpack-25c67512e1907efd.js} +1 -1
- package/.next/static/css/033b9397a0c0cf71.css +1 -0
- package/.next/trace +156 -156
- package/.turbo/turbo-build.log +18 -18
- package/.turbo/turbo-test.log +8 -8
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/middleware.ts +14 -13
- package/src/pages/api/fs/{auth/login.ts → password-protection/unlock.ts} +4 -4
- package/src/pages/{fs-auth-login → password-protection}/index.tsx +10 -7
- package/src/pages/{fs-auth-login/fs-auth-login.module.scss → password-protection/password-protection.module.scss} +1 -1
- package/src/server/{authentication-service.ts → password-protection-service.ts} +22 -18
- package/src/utils/{loginResponse.ts → unlockResponse.ts} +7 -2
- package/test/server/{authentication-service.test.ts → password-protection-service.test.ts} +71 -59
- package/.next/server/pages/api/fs/auth/login.js +0 -1
- package/.next/static/chunks/main-083a618181bb5fbb.js +0 -1
- package/.next/static/chunks/pages/fs-auth-login-ba2d1b3ef0ef0415.js +0 -1
- package/.next/static/css/3bd4edd425711792.css +0 -1
- package/.next/static/qnFvdN4P3Em9yV6nJ1gX8/_buildManifest.js +0 -1
- /package/.next/server/pages/api/fs/{auth/login.js.nft.json → password-protection/unlock.js.nft.json} +0 -0
- /package/.next/server/pages/{fs-auth-login.js.nft.json → password-protection.js.nft.json} +0 -0
- /package/.next/static/{qnFvdN4P3Em9yV6nJ1gX8 → 0OKcQtIHO8diwBsczup15}/_ssgManifest.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// runtime can't be in strict mode because a global variable is assign and maybe created.
|
|
2
2
|
(self["webpackChunk_N_E"] = self["webpackChunk_N_E"] || []).push([[727],{
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 665:
|
|
5
5
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
@@ -4290,8 +4290,8 @@ function renewUrl() {
|
|
|
4290
4290
|
defaultMs: 10000
|
|
4291
4291
|
};
|
|
4292
4292
|
|
|
4293
|
-
;// CONCATENATED MODULE: ./src/server/
|
|
4294
|
-
function
|
|
4293
|
+
;// CONCATENATED MODULE: ./src/server/password-protection-service.ts
|
|
4294
|
+
function password_protection_service_defineProperty(obj, key, value) {
|
|
4295
4295
|
if (key in obj) {
|
|
4296
4296
|
Object.defineProperty(obj, key, {
|
|
4297
4297
|
value: value,
|
|
@@ -4308,7 +4308,7 @@ function authentication_service_defineProperty(obj, key, value) {
|
|
|
4308
4308
|
|
|
4309
4309
|
|
|
4310
4310
|
|
|
4311
|
-
const COOKIE_NAME = "
|
|
4311
|
+
const COOKIE_NAME = "__fs_password_protection";
|
|
4312
4312
|
const TOKEN_TTL_SECONDS = 10 * 60;
|
|
4313
4313
|
/** How long to reuse the RSA public key fetched from WebOps */ const PUBLIC_KEY_CACHE_MS = 60 * 60 * 1000;
|
|
4314
4314
|
let publicKeyCache = null;
|
|
@@ -4343,16 +4343,16 @@ async function getPublicVerificationKey() {
|
|
|
4343
4343
|
/** Clears the cached WebOps public key (for unit tests only). */ function resetPasswordProtectionPublicKeyCacheForTests() {
|
|
4344
4344
|
publicKeyCache = null;
|
|
4345
4345
|
}
|
|
4346
|
-
class
|
|
4346
|
+
class PasswordProtectionService {
|
|
4347
4347
|
constructor(){
|
|
4348
|
-
|
|
4348
|
+
password_protection_service_defineProperty(this, "storeId", void 0);
|
|
4349
4349
|
this.storeId = (discovery_config_default()).api.storeId;
|
|
4350
4350
|
}
|
|
4351
4351
|
getNormalizedHost(request) {
|
|
4352
4352
|
const host = request.headers.get("host") || "";
|
|
4353
4353
|
return host.split(":")[0].toLowerCase();
|
|
4354
4354
|
}
|
|
4355
|
-
async
|
|
4355
|
+
async checkStoreProtection(request) {
|
|
4356
4356
|
if (!this.shouldCheckProtection(request)) {
|
|
4357
4357
|
return {
|
|
4358
4358
|
response: NextResponse.next()
|
|
@@ -4370,7 +4370,7 @@ class AuthenticationService {
|
|
|
4370
4370
|
return await this.tryRenewSession(request, token, verification.payload);
|
|
4371
4371
|
}
|
|
4372
4372
|
}
|
|
4373
|
-
return await this.
|
|
4373
|
+
return await this.handleProtectionCheck(request);
|
|
4374
4374
|
}
|
|
4375
4375
|
shouldCheckProtection(request) {
|
|
4376
4376
|
if (false) {}
|
|
@@ -4446,7 +4446,7 @@ class AuthenticationService {
|
|
|
4446
4446
|
const data = await res.json();
|
|
4447
4447
|
if (data.valid && data.token) {
|
|
4448
4448
|
const response = NextResponse.next();
|
|
4449
|
-
this.
|
|
4449
|
+
this.setProtectionCookie(response, data.token);
|
|
4450
4450
|
return {
|
|
4451
4451
|
response
|
|
4452
4452
|
};
|
|
@@ -4459,24 +4459,24 @@ class AuthenticationService {
|
|
|
4459
4459
|
};
|
|
4460
4460
|
}
|
|
4461
4461
|
return {
|
|
4462
|
-
response: this.
|
|
4462
|
+
response: this.redirectToUnlockPage(request)
|
|
4463
4463
|
};
|
|
4464
4464
|
}
|
|
4465
|
-
async
|
|
4465
|
+
async handleProtectionCheck(request) {
|
|
4466
4466
|
try {
|
|
4467
4467
|
const res = await fetch(protectionStatusUrl(), {
|
|
4468
4468
|
signal: AbortSignal.timeout(passwordProtectionTimeouts.defaultMs)
|
|
4469
4469
|
});
|
|
4470
4470
|
if (!res.ok) {
|
|
4471
4471
|
return {
|
|
4472
|
-
response: this.
|
|
4472
|
+
response: this.redirectToUnlockPage(request)
|
|
4473
4473
|
};
|
|
4474
4474
|
}
|
|
4475
4475
|
const status = await res.json();
|
|
4476
4476
|
if (!status.protected) {
|
|
4477
4477
|
const response = NextResponse.next();
|
|
4478
4478
|
if (status.token) {
|
|
4479
|
-
this.
|
|
4479
|
+
this.setProtectionCookie(response, status.token);
|
|
4480
4480
|
}
|
|
4481
4481
|
return {
|
|
4482
4482
|
response
|
|
@@ -4488,15 +4488,15 @@ class AuthenticationService {
|
|
|
4488
4488
|
};
|
|
4489
4489
|
}
|
|
4490
4490
|
return {
|
|
4491
|
-
response: this.
|
|
4491
|
+
response: this.redirectToUnlockPage(request)
|
|
4492
4492
|
};
|
|
4493
4493
|
} catch {
|
|
4494
4494
|
return {
|
|
4495
|
-
response: this.
|
|
4495
|
+
response: this.redirectToUnlockPage(request)
|
|
4496
4496
|
};
|
|
4497
4497
|
}
|
|
4498
4498
|
}
|
|
4499
|
-
|
|
4499
|
+
setProtectionCookie(response, token) {
|
|
4500
4500
|
response.cookies.set(COOKIE_NAME, token, {
|
|
4501
4501
|
httpOnly: true,
|
|
4502
4502
|
secure: true,
|
|
@@ -4505,11 +4505,11 @@ class AuthenticationService {
|
|
|
4505
4505
|
maxAge: TOKEN_TTL_SECONDS
|
|
4506
4506
|
});
|
|
4507
4507
|
}
|
|
4508
|
-
|
|
4509
|
-
const
|
|
4508
|
+
redirectToUnlockPage(request) {
|
|
4509
|
+
const unlockUrl = new URL("/password-protection", request.url);
|
|
4510
4510
|
const returnTo = `${request.nextUrl.pathname}${request.nextUrl.search}`;
|
|
4511
|
-
|
|
4512
|
-
const response = NextResponse.redirect(
|
|
4511
|
+
unlockUrl.searchParams.set("returnTo", returnTo);
|
|
4512
|
+
const response = NextResponse.redirect(unlockUrl);
|
|
4513
4513
|
response.headers.set("Cache-Control", "no-store");
|
|
4514
4514
|
return response;
|
|
4515
4515
|
}
|
|
@@ -4518,7 +4518,7 @@ class AuthenticationService {
|
|
|
4518
4518
|
;// CONCATENATED MODULE: ./src/middleware.ts
|
|
4519
4519
|
/*
|
|
4520
4520
|
* Middleware is always active. It runs:
|
|
4521
|
-
* 1. Password protection (
|
|
4521
|
+
* 1. Password protection (PasswordProtectionService) — when applicable (default/custom domains per env).
|
|
4522
4522
|
* 2. Redirects — only when ENABLE_REDIRECTS_MIDDLEWARE is set at runtime.
|
|
4523
4523
|
*/
|
|
4524
4524
|
|
|
@@ -4532,15 +4532,15 @@ class DynamoRedirectsClient {
|
|
|
4532
4532
|
const redirectsClient = new DynamoRedirectsClient();
|
|
4533
4533
|
async function middleware(request) {
|
|
4534
4534
|
const path = request.nextUrl.pathname;
|
|
4535
|
-
let
|
|
4535
|
+
let storeProtectionResult;
|
|
4536
4536
|
try {
|
|
4537
|
-
const
|
|
4538
|
-
|
|
4537
|
+
const protectionService = new PasswordProtectionService();
|
|
4538
|
+
storeProtectionResult = await protectionService.checkStoreProtection(request);
|
|
4539
4539
|
} catch {
|
|
4540
4540
|
return NextResponse.error();
|
|
4541
4541
|
}
|
|
4542
|
-
if (
|
|
4543
|
-
return
|
|
4542
|
+
if (storeProtectionResult.response.status !== 200) {
|
|
4543
|
+
return storeProtectionResult.response;
|
|
4544
4544
|
}
|
|
4545
4545
|
if (process.env.ENABLE_REDIRECTS_MIDDLEWARE === "true") {
|
|
4546
4546
|
const redirect = await redirectsClient.get(path);
|
|
@@ -4548,31 +4548,31 @@ async function middleware(request) {
|
|
|
4548
4548
|
const redirectUrl = new URL(redirect.to, (discovery_config_default()).storeUrl);
|
|
4549
4549
|
const redirectStatusCode = redirect.type === "permanent" ? 301 : 302;
|
|
4550
4550
|
const response = NextResponse.redirect(redirectUrl, redirectStatusCode);
|
|
4551
|
-
for (const cookie of
|
|
4551
|
+
for (const cookie of storeProtectionResult.response.cookies.getAll()){
|
|
4552
4552
|
response.cookies.set(cookie);
|
|
4553
4553
|
}
|
|
4554
4554
|
response.headers.set("Cache-Control", "public, max-age=300, stale-while-revalidate=31536000");
|
|
4555
4555
|
return response;
|
|
4556
4556
|
}
|
|
4557
4557
|
}
|
|
4558
|
-
return
|
|
4558
|
+
return storeProtectionResult.response;
|
|
4559
4559
|
}
|
|
4560
4560
|
const config = {
|
|
4561
4561
|
matcher: [
|
|
4562
4562
|
/*
|
|
4563
4563
|
* Match all paths including `/`
|
|
4564
4564
|
* Exclude:
|
|
4565
|
-
* - api (e.g. api/fs/
|
|
4565
|
+
* - api (e.g. api/fs/password-protection/unlock)
|
|
4566
4566
|
* - _next/static, _next/image
|
|
4567
4567
|
* - favicon.ico
|
|
4568
|
-
* -
|
|
4568
|
+
* - password-protection (unlock page)
|
|
4569
4569
|
* - ~partytown (partytown scripts)
|
|
4570
4570
|
*/ "/",
|
|
4571
|
-
"/((?!api|_next/static|_next/image|favicon.ico|
|
|
4571
|
+
"/((?!api|_next/static|_next/image|favicon.ico|password-protection|~partytown).*)"
|
|
4572
4572
|
]
|
|
4573
4573
|
};
|
|
4574
4574
|
|
|
4575
|
-
;// CONCATENATED MODULE: ../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fsrc%2Fmiddleware.ts&page=%2Fsrc%2Fmiddleware&rootDir=%2Fhome%2Frunner%2Fwork%2Ffaststore%2Ffaststore%2Fpackages%2Fcore&matchers=W3sicmVnZXhwIjoiXig%2FOlxcLyhfbmV4dFxcL2RhdGFcXC9bXi9dezEsfSkpPyg%2FOlxcLygoPyFfbmV4dFxcLylbXi8uXXsxLH0pKSh8XFwuanNvbnxcXC8%2FaW5kZXh8XFwvP2luZGV4XFwuanNvbik%
|
|
4575
|
+
;// CONCATENATED MODULE: ../../node_modules/.pnpm/next@13.5.11_@babel+core@7.26.7_@opentelemetry+api@1.4.1_react-dom@18.3.1_react@18.3.1__react@18.3.1_sass@1.83.4/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js?absolutePagePath=private-next-root-dir%2Fsrc%2Fmiddleware.ts&page=%2Fsrc%2Fmiddleware&rootDir=%2Fhome%2Frunner%2Fwork%2Ffaststore%2Ffaststore%2Fpackages%2Fcore&matchers=W3sicmVnZXhwIjoiXig%2FOlxcLyhfbmV4dFxcL2RhdGFcXC9bXi9dezEsfSkpPyg%2FOlxcLygoPyFfbmV4dFxcLylbXi8uXXsxLH0pKSh8XFwuanNvbnxcXC8%2FaW5kZXh8XFwvP2luZGV4XFwuanNvbik%2FW1xcLyNcXD9dPyQiLCJvcmlnaW5hbFNvdXJjZSI6Ii8ifSx7InJlZ2V4cCI6Il4oPzpcXC8oX25leHRcXC9kYXRhXFwvW14vXXsxLH0pKT8oPzpcXC8oKD8hX25leHRcXC8pW14vLl17MSx9KSkoPzpcXC8oKD8hYXBpfF9uZXh0XFwvc3RhdGljfF9uZXh0XFwvaW1hZ2V8ZmF2aWNvbi5pY298cGFzc3dvcmQtcHJvdGVjdGlvbnx%2BcGFydHl0b3duKS4qKSkoLmpzb24pP1tcXC8jXFw%2FXT8kIiwib3JpZ2luYWxTb3VyY2UiOiIvKCg%2FIWFwaXxfbmV4dC9zdGF0aWN8X25leHQvaW1hZ2V8ZmF2aWNvbi5pY298cGFzc3dvcmQtcHJvdGVjdGlvbnx%2BcGFydHl0b3duKS4qKSJ9XQ%3D%3D&preferredRegion=&middlewareConfig=eyJtYXRjaGVycyI6W3sicmVnZXhwIjoiXig%2FOlxcLyhfbmV4dFxcL2RhdGFcXC9bXi9dezEsfSkpPyg%2FOlxcLygoPyFfbmV4dFxcLylbXi8uXXsxLH0pKSh8XFwuanNvbnxcXC8%2FaW5kZXh8XFwvP2luZGV4XFwuanNvbik%2FW1xcLyNcXD9dPyQiLCJvcmlnaW5hbFNvdXJjZSI6Ii8ifSx7InJlZ2V4cCI6Il4oPzpcXC8oX25leHRcXC9kYXRhXFwvW14vXXsxLH0pKT8oPzpcXC8oKD8hX25leHRcXC8pW14vLl17MSx9KSkoPzpcXC8oKD8hYXBpfF9uZXh0XFwvc3RhdGljfF9uZXh0XFwvaW1hZ2V8ZmF2aWNvbi5pY298cGFzc3dvcmQtcHJvdGVjdGlvbnx%2BcGFydHl0b3duKS4qKSkoLmpzb24pP1tcXC8jXFw%2FXT8kIiwib3JpZ2luYWxTb3VyY2UiOiIvKCg%2FIWFwaXxfbmV4dC9zdGF0aWN8X25leHQvaW1hZ2V8ZmF2aWNvbi5pY298cGFzc3dvcmQtcHJvdGVjdGlvbnx%2BcGFydHl0b3duKS4qKSJ9XX0%3D!
|
|
4576
4576
|
|
|
4577
4577
|
|
|
4578
4578
|
// Import the userland code.
|
|
@@ -5410,7 +5410,7 @@ module.exports = {};
|
|
|
5410
5410
|
},
|
|
5411
5411
|
/******/ __webpack_require__ => { // webpackRuntimeModules
|
|
5412
5412
|
/******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
|
5413
|
-
/******/ var __webpack_exports__ = (__webpack_exec__(
|
|
5413
|
+
/******/ var __webpack_exports__ = (__webpack_exec__(665));
|
|
5414
5414
|
/******/ (_ENTRIES = typeof _ENTRIES === "undefined" ? {} : _ENTRIES)["middleware_src/middleware"] = __webpack_exports__;
|
|
5415
5415
|
/******/ }
|
|
5416
5416
|
]);
|