canopycms-next 0.0.68-int.96 → 0.0.68-int.97
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.
|
@@ -145,7 +145,8 @@ export interface NextCanopyContextResult {
|
|
|
145
145
|
*
|
|
146
146
|
* Each view is made by `withCanopyPreview` (`canopycms-next/client`) in a `'use client'` module.
|
|
147
147
|
* It renders each entry from the `?branch=` the editor names, through `views[entryType]` with
|
|
148
|
-
* the live draft. Reads are request-scoped and ACL-checked, and
|
|
148
|
+
* the live draft. Reads are request-scoped and ACL-checked, and an anonymous request or anything
|
|
149
|
+
* not readable is a 404.
|
|
149
150
|
* A view that needs more server reads is `previewView({ view, load })`: `load` runs after the
|
|
150
151
|
* entry is read and its result arrives as the view's `extras` prop.
|
|
151
152
|
*/
|
package/dist/preview-page.d.ts
CHANGED
|
@@ -63,7 +63,10 @@ export interface CreatePreviewPageOptions {
|
|
|
63
63
|
* type has no view is a 404.
|
|
64
64
|
*/
|
|
65
65
|
views: Record<string, PreviewView | ErasedPreviewViewWithLoader>;
|
|
66
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Editor origin to trust, for an editor on another origin. Defaults to the page's own. The
|
|
68
|
+
* viewer must still be signed in on this page's origin: an anonymous request is a 404.
|
|
69
|
+
*/
|
|
67
70
|
editorOrigin?: string;
|
|
68
71
|
}
|
|
69
72
|
/** The props Next passes a `[[...path]]` page. */
|
|
@@ -79,8 +82,8 @@ export interface PreviewPageProps {
|
|
|
79
82
|
*
|
|
80
83
|
* The read goes through the request-scoped `getCanopy()`, never the build context: it is
|
|
81
84
|
* authenticated and ACL-checked, and a branch other than the active one is only loaded, never
|
|
82
|
-
* created.
|
|
83
|
-
* 404, so a hidden branch looks the same as a missing one.
|
|
85
|
+
* created. An anonymous request, a missing, unreadable or malformed branch, and a path no entry
|
|
86
|
+
* publishes, are all a 404, so a hidden branch looks the same as a missing one.
|
|
84
87
|
*
|
|
85
88
|
* On a `deployedAs: 'static'` deployment every request is a 404: reads there skip access checks,
|
|
86
89
|
* so the route would show any branch to anyone.
|
package/dist/preview-page.js
CHANGED
|
@@ -19,8 +19,8 @@ function hasLoader(entry) {
|
|
|
19
19
|
*
|
|
20
20
|
* The read goes through the request-scoped `getCanopy()`, never the build context: it is
|
|
21
21
|
* authenticated and ACL-checked, and a branch other than the active one is only loaded, never
|
|
22
|
-
* created.
|
|
23
|
-
* 404, so a hidden branch looks the same as a missing one.
|
|
22
|
+
* created. An anonymous request, a missing, unreadable or malformed branch, and a path no entry
|
|
23
|
+
* publishes, are all a 404, so a hidden branch looks the same as a missing one.
|
|
24
24
|
*
|
|
25
25
|
* On a `deployedAs: 'static'` deployment every request is a 404: reads there skip access checks,
|
|
26
26
|
* so the route would show any branch to anyone.
|
|
@@ -35,6 +35,10 @@ export function createPreviewPageFor(getCanopy, options, deployedAs = 'server')
|
|
|
35
35
|
if (Array.isArray(branch))
|
|
36
36
|
notFound();
|
|
37
37
|
const canopy = await getCanopy();
|
|
38
|
+
// ACLs alone would let an anonymous user read the base branch, and this route sits under the
|
|
39
|
+
// editor's paths, which a site-wide gate exempts because the editor's sign-in guards them.
|
|
40
|
+
if (canopy.user.type === 'anonymous')
|
|
41
|
+
notFound();
|
|
38
42
|
const result = await canopy.readByUrlPath(`/${path.join('/')}`, { branch });
|
|
39
43
|
if (!result)
|
|
40
44
|
notFound();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canopycms-next",
|
|
3
|
-
"version": "0.0.68-int.
|
|
3
|
+
"version": "0.0.68-int.97",
|
|
4
4
|
"description": "Next.js adapter for CanopyCMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"next": "^13.5.7 || ^14.2.25 || ^15.5.21 || >=16.0.0 <16.2.0 || >=16.3.0 <17.0.0",
|
|
40
40
|
"react": "^18.0.0 || ^19.0.0",
|
|
41
|
-
"canopycms": "0.0.68-int.
|
|
41
|
+
"canopycms": "0.0.68-int.97"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "^22.9.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react": "^18.3.1",
|
|
49
49
|
"typescript": "^5.6.3",
|
|
50
50
|
"vitest": "^4.1.0",
|
|
51
|
-
"canopycms": "0.0.68-int.
|
|
51
|
+
"canopycms": "0.0.68-int.97"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/add-js-extensions.mjs dist && esbuild src/config.ts --bundle --platform=node --packages=external --external:next --format=cjs --outfile=dist/config.cjs && esbuild src/config.ts --bundle --platform=node --packages=external --external:next --format=esm --outfile=dist/config.mjs",
|