@cmssy/next 19.38.0 → 19.39.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/README.md +2 -1
- package/dist/middleware.cjs +1 -2
- package/dist/middleware.d.cts +0 -3
- package/dist/middleware.d.ts +0 -3
- package/dist/middleware.js +2 -3
- package/dist/server.cjs +4 -2
- package/dist/server.js +5 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -45,7 +45,8 @@ the edit route and proxy below. A published build does **not** require
|
|
|
45
45
|
## Let the editor frame your site
|
|
46
46
|
|
|
47
47
|
The cmssy editor frames the page's own URL with
|
|
48
|
-
`?cmssyEdit=1&cmssySecret=<
|
|
48
|
+
`?cmssyEdit=1&cmssySecret=<credential>`, where the credential is the draft
|
|
49
|
+
secret or a short-lived edit token minted from it. The proxy verifies it and
|
|
49
50
|
rewrites that request to `/cmssy-edit/...`, which renders draft content with
|
|
50
51
|
your `editor`. Both files are required; without them the editor reports that
|
|
51
52
|
the preview did not respond.
|
package/dist/middleware.cjs
CHANGED
|
@@ -13,7 +13,7 @@ async function cmssyEditRewrite(request, config, options = {}) {
|
|
|
13
13
|
if (!searchParams.getAll(core.CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
|
|
14
14
|
const provided = searchParams.get(core.CMSSY_SECRET_QUERY_PARAM);
|
|
15
15
|
if (!provided || !config.draftSecret) return null;
|
|
16
|
-
if (!await internal.
|
|
16
|
+
if (!await internal.cmssyEditCredentialMatches(provided, config.draftSecret)) return null;
|
|
17
17
|
const url = request.nextUrl.clone();
|
|
18
18
|
url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
|
|
19
19
|
warnIfEditRouteMissing(url);
|
|
@@ -106,7 +106,6 @@ function createCmssyProxy(config, options = {}) {
|
|
|
106
106
|
}
|
|
107
107
|
var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
|
|
108
108
|
async function isCmssyEditRequest(request, config) {
|
|
109
|
-
if (request.cookies.has("__prerender_bypass")) return true;
|
|
110
109
|
return core.isVerifiedEditUrl(request.nextUrl, config);
|
|
111
110
|
}
|
|
112
111
|
|
package/dist/middleware.d.cts
CHANGED
|
@@ -25,9 +25,6 @@ declare function createCmssyEditMiddleware(config: {
|
|
|
25
25
|
}): (request: NextRequest) => Promise<NextResponse>;
|
|
26
26
|
|
|
27
27
|
interface EditRequestLike {
|
|
28
|
-
cookies: {
|
|
29
|
-
has: (name: string) => boolean;
|
|
30
|
-
};
|
|
31
28
|
nextUrl: {
|
|
32
29
|
searchParams: {
|
|
33
30
|
getAll: (name: string) => string[];
|
package/dist/middleware.d.ts
CHANGED
|
@@ -25,9 +25,6 @@ declare function createCmssyEditMiddleware(config: {
|
|
|
25
25
|
}): (request: NextRequest) => Promise<NextResponse>;
|
|
26
26
|
|
|
27
27
|
interface EditRequestLike {
|
|
28
|
-
cookies: {
|
|
29
|
-
has: (name: string) => boolean;
|
|
30
|
-
};
|
|
31
28
|
nextUrl: {
|
|
32
29
|
searchParams: {
|
|
33
30
|
getAll: (name: string) => string[];
|
package/dist/middleware.js
CHANGED
|
@@ -2,7 +2,7 @@ import { NextResponse } from 'next/server';
|
|
|
2
2
|
import { CMSSY_LOCALE_HEADER, localeForPathname, resolveSiteLocales } from '@cmssy/core/internal/locale';
|
|
3
3
|
import { CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CMSSY_EDIT_HEADER, applyCmssyCsp, isVerifiedEditUrl } from '@cmssy/core';
|
|
4
4
|
export { CMSSY_EDIT_HEADER, applyCmssyCsp } from '@cmssy/core';
|
|
5
|
-
import {
|
|
5
|
+
import { cmssyEditCredentialMatches } from '@cmssy/core/internal';
|
|
6
6
|
|
|
7
7
|
// src/preset/proxy.ts
|
|
8
8
|
var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
|
|
@@ -12,7 +12,7 @@ async function cmssyEditRewrite(request, config, options = {}) {
|
|
|
12
12
|
if (!searchParams.getAll(CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
|
|
13
13
|
const provided = searchParams.get(CMSSY_SECRET_QUERY_PARAM);
|
|
14
14
|
if (!provided || !config.draftSecret) return null;
|
|
15
|
-
if (!await
|
|
15
|
+
if (!await cmssyEditCredentialMatches(provided, config.draftSecret)) return null;
|
|
16
16
|
const url = request.nextUrl.clone();
|
|
17
17
|
url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
|
|
18
18
|
warnIfEditRouteMissing(url);
|
|
@@ -105,7 +105,6 @@ function createCmssyProxy(config, options = {}) {
|
|
|
105
105
|
}
|
|
106
106
|
var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
|
|
107
107
|
async function isCmssyEditRequest(request, config) {
|
|
108
|
-
if (request.cookies.has("__prerender_bypass")) return true;
|
|
109
108
|
return isVerifiedEditUrl(request.nextUrl, config);
|
|
110
109
|
}
|
|
111
110
|
|
package/dist/server.cjs
CHANGED
|
@@ -63,7 +63,7 @@ async function resolveEditorRequest(query, draftSecret) {
|
|
|
63
63
|
if (!hasEditFlag(query[core.CMSSY_EDIT_QUERY_PARAM])) return false;
|
|
64
64
|
const provided = firstValue(query[core.CMSSY_SECRET_QUERY_PARAM]);
|
|
65
65
|
if (!provided || !draftSecret) return false;
|
|
66
|
-
return internal.
|
|
66
|
+
return internal.cmssyEditCredentialMatches(provided, draftSecret);
|
|
67
67
|
}
|
|
68
68
|
function createCmssyPage(config, blocks, options) {
|
|
69
69
|
return buildCmssyPageRenderer(config, blocks, options, false);
|
|
@@ -171,6 +171,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
171
171
|
enabledLocales,
|
|
172
172
|
edit: {
|
|
173
173
|
editorOrigin: bridgeOrigin,
|
|
174
|
+
acceptsEditToken: true,
|
|
175
|
+
acceptsDraftToken: true,
|
|
174
176
|
...config.layout ? { layoutRegions: config.layout.regions } : {},
|
|
175
177
|
...config.draftSecret ? {
|
|
176
178
|
blockDataToken: await core.mintCmssyEditToken(
|
|
@@ -324,7 +326,7 @@ function createDraftRoute(config) {
|
|
|
324
326
|
);
|
|
325
327
|
}
|
|
326
328
|
const secret = url.searchParams.get("secret");
|
|
327
|
-
if (!secret || !await internal.
|
|
329
|
+
if (!secret || !await internal.cmssyEditCredentialMatches(secret, config.draftSecret)) {
|
|
328
330
|
return new Response("Invalid draft secret", { status: 401 });
|
|
329
331
|
}
|
|
330
332
|
const location = safeRedirect(
|
package/dist/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createCmssyClient, CmssyServerPage, resolveCmssyLayout as resolveCmssyL
|
|
|
5
5
|
import { mintCmssyEditToken, CMSSY_SECRET_QUERY_PARAM, resolveEditorOrigin, verifyCmssyWebhook, CmssyWebhookError, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM } from '@cmssy/core';
|
|
6
6
|
import { CmssyLocaleProvider } from '@cmssy/react/internal';
|
|
7
7
|
import { blocksToSchemas, resolveEditorBlockData } from '@cmssy/react/internal-server';
|
|
8
|
-
import { createCmssyLayoutStore, isDevelopment, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, toCspOrigin,
|
|
8
|
+
import { createCmssyLayoutStore, isDevelopment, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, toCspOrigin, cmssyEditCredentialMatches } from '@cmssy/core/internal';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import { revalidateTag } from 'next/cache';
|
|
11
11
|
import * as React from 'react';
|
|
@@ -41,7 +41,7 @@ async function resolveEditorRequest(query, draftSecret) {
|
|
|
41
41
|
if (!hasEditFlag(query[CMSSY_EDIT_QUERY_PARAM])) return false;
|
|
42
42
|
const provided = firstValue(query[CMSSY_SECRET_QUERY_PARAM]);
|
|
43
43
|
if (!provided || !draftSecret) return false;
|
|
44
|
-
return
|
|
44
|
+
return cmssyEditCredentialMatches(provided, draftSecret);
|
|
45
45
|
}
|
|
46
46
|
function createCmssyPage(config, blocks, options) {
|
|
47
47
|
return buildCmssyPageRenderer(config, blocks, options, false);
|
|
@@ -149,6 +149,8 @@ function buildCmssyPageRenderer(config, blocks, options, editRoute) {
|
|
|
149
149
|
enabledLocales,
|
|
150
150
|
edit: {
|
|
151
151
|
editorOrigin: bridgeOrigin,
|
|
152
|
+
acceptsEditToken: true,
|
|
153
|
+
acceptsDraftToken: true,
|
|
152
154
|
...config.layout ? { layoutRegions: config.layout.regions } : {},
|
|
153
155
|
...config.draftSecret ? {
|
|
154
156
|
blockDataToken: await mintCmssyEditToken(
|
|
@@ -302,7 +304,7 @@ function createDraftRoute(config) {
|
|
|
302
304
|
);
|
|
303
305
|
}
|
|
304
306
|
const secret = url.searchParams.get("secret");
|
|
305
|
-
if (!secret || !await
|
|
307
|
+
if (!secret || !await cmssyEditCredentialMatches(secret, config.draftSecret)) {
|
|
306
308
|
return new Response("Invalid draft secret", { status: 401 });
|
|
307
309
|
}
|
|
308
310
|
const location = safeRedirect(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/next",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.39.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"dist"
|
|
75
75
|
],
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@cmssy/react": "^19.
|
|
77
|
+
"@cmssy/react": "^19.39.0",
|
|
78
78
|
"next": ">=15",
|
|
79
79
|
"react": "^18.2.0 || ^19.0.0",
|
|
80
80
|
"react-dom": "^18.2.0 || ^19.0.0"
|
|
@@ -88,12 +88,12 @@
|
|
|
88
88
|
"tsup": "^8.3.0",
|
|
89
89
|
"typescript": "^5.6.0",
|
|
90
90
|
"vitest": "^2.1.0",
|
|
91
|
-
"@cmssy/react": "19.
|
|
91
|
+
"@cmssy/react": "19.39.0"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
94
|
"@cmssy/types": "0.78.0",
|
|
95
95
|
"server-only": "^0.0.1",
|
|
96
|
-
"@cmssy/core": "19.
|
|
96
|
+
"@cmssy/core": "19.39.0"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"build": "tsup",
|