@uniformdev/canvas-next 19.60.1-alpha.6 → 19.61.1-alpha.10

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/dist/index.esm.js CHANGED
@@ -51,8 +51,7 @@ var UniformRichTextNode = ({
51
51
  // src/preview/previewHandlerGet.ts
52
52
  import {
53
53
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
54
- IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
55
- SECRET_QUERY_STRING_PARAM
54
+ IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
56
55
  } from "@uniformdev/canvas";
57
56
  import { isAllowedReferrer } from "@uniformdev/canvas";
58
57
  var BASE_URL_EXAMPLE = "https://example.com";
@@ -63,16 +62,10 @@ var getQueryParam = (req, paramName) => {
63
62
  }
64
63
  return Array.isArray(value) ? value[0] : value;
65
64
  };
66
- var contextualEditingQueryParams = [
65
+ var queryParamsToPreserve = [
67
66
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
68
67
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM
69
68
  ];
70
- var compositionQueryParam = {
71
- id: "id",
72
- slug: "slug",
73
- path: "path",
74
- locale: "locale"
75
- };
76
69
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
77
70
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
78
71
  if (isConfigCheck) {
@@ -89,10 +82,10 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
89
82
  if (isPlayground && playgroundPath) {
90
83
  pathToRedirectTo = playgroundPath;
91
84
  }
92
- const id = getQueryParam(req, compositionQueryParam.id);
93
- const slug = getQueryParam(req, compositionQueryParam.slug);
94
- const path = getQueryParam(req, compositionQueryParam.path);
95
- const locale = getQueryParam(req, compositionQueryParam.locale);
85
+ const id = getQueryParam(req, "id");
86
+ const slug = getQueryParam(req, "slug");
87
+ const path = getQueryParam(req, "path");
88
+ const locale = getQueryParam(req, "locale");
96
89
  if (typeof pathToRedirectTo === "undefined") {
97
90
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
98
91
  }
@@ -107,7 +100,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
107
100
  }
108
101
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
109
102
  const isUsingPreviewSecret = Boolean(previewSecret);
110
- if (isUsingPreviewSecret && req.query[SECRET_QUERY_STRING_PARAM] !== previewSecret) {
103
+ if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
111
104
  return res.status(401).json({ message: "Invalid token" });
112
105
  }
113
106
  const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && isAllowedReferrer(req.headers.referer);
@@ -134,10 +127,12 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
134
127
  cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
135
128
  );
136
129
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
137
- assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
138
- if (!isUniformContextualEditing) {
139
- contextualEditingQueryParams.forEach((param) => {
140
- redirectionUrl.searchParams.delete(param);
130
+ if (isUniformContextualEditing) {
131
+ queryParamsToPreserve.forEach((param) => {
132
+ const paramValue = req.query[param];
133
+ if (typeof paramValue === "string") {
134
+ redirectionUrl.searchParams.append(param, paramValue);
135
+ }
141
136
  });
142
137
  }
143
138
  const fullPathToRedirectTo = redirectionUrl.href.replace(BASE_URL_EXAMPLE, "");
@@ -151,25 +146,6 @@ function validateLocalRedirectUrl(pathToRedirectTo) {
151
146
  throw new Error("Tried to redirect to absolute URL with protocol. Disallowing open redirect.");
152
147
  }
153
148
  }
154
- var assignRequestQueryToSearchParams = (searchParams, query) => {
155
- const compositionQueryParamNames = Object.values(compositionQueryParam);
156
- Object.entries(query).forEach(([name, value]) => {
157
- if (name === SECRET_QUERY_STRING_PARAM) {
158
- return;
159
- }
160
- if (compositionQueryParamNames.includes(name)) {
161
- return;
162
- }
163
- if (typeof value === "undefined") {
164
- return;
165
- }
166
- if (typeof value === "object") {
167
- value.forEach((singleValue) => searchParams.append(name, singleValue));
168
- return;
169
- }
170
- searchParams.append(name, value);
171
- });
172
- };
173
149
 
174
150
  // src/preview/previewHandlerPost.ts
175
151
  import { generateHash } from "@uniformdev/canvas";
package/dist/index.js CHANGED
@@ -105,16 +105,10 @@ var getQueryParam = (req, paramName) => {
105
105
  }
106
106
  return Array.isArray(value) ? value[0] : value;
107
107
  };
108
- var contextualEditingQueryParams = [
108
+ var queryParamsToPreserve = [
109
109
  import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
110
110
  import_canvas.IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM
111
111
  ];
112
- var compositionQueryParam = {
113
- id: "id",
114
- slug: "slug",
115
- path: "path",
116
- locale: "locale"
117
- };
118
112
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
119
113
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
120
114
  if (isConfigCheck) {
@@ -131,10 +125,10 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
131
125
  if (isPlayground && playgroundPath) {
132
126
  pathToRedirectTo = playgroundPath;
133
127
  }
134
- const id = getQueryParam(req, compositionQueryParam.id);
135
- const slug = getQueryParam(req, compositionQueryParam.slug);
136
- const path = getQueryParam(req, compositionQueryParam.path);
137
- const locale = getQueryParam(req, compositionQueryParam.locale);
128
+ const id = getQueryParam(req, "id");
129
+ const slug = getQueryParam(req, "slug");
130
+ const path = getQueryParam(req, "path");
131
+ const locale = getQueryParam(req, "locale");
138
132
  if (typeof pathToRedirectTo === "undefined") {
139
133
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
140
134
  }
@@ -149,7 +143,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
149
143
  }
150
144
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
151
145
  const isUsingPreviewSecret = Boolean(previewSecret);
152
- if (isUsingPreviewSecret && req.query[import_canvas.SECRET_QUERY_STRING_PARAM] !== previewSecret) {
146
+ if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
153
147
  return res.status(401).json({ message: "Invalid token" });
154
148
  }
155
149
  const isUniformContextualEditing = req.query[import_canvas.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && (0, import_canvas2.isAllowedReferrer)(req.headers.referer);
@@ -176,10 +170,12 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
176
170
  cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
177
171
  );
178
172
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
179
- assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
180
- if (!isUniformContextualEditing) {
181
- contextualEditingQueryParams.forEach((param) => {
182
- redirectionUrl.searchParams.delete(param);
173
+ if (isUniformContextualEditing) {
174
+ queryParamsToPreserve.forEach((param) => {
175
+ const paramValue = req.query[param];
176
+ if (typeof paramValue === "string") {
177
+ redirectionUrl.searchParams.append(param, paramValue);
178
+ }
183
179
  });
184
180
  }
185
181
  const fullPathToRedirectTo = redirectionUrl.href.replace(BASE_URL_EXAMPLE, "");
@@ -193,25 +189,6 @@ function validateLocalRedirectUrl(pathToRedirectTo) {
193
189
  throw new Error("Tried to redirect to absolute URL with protocol. Disallowing open redirect.");
194
190
  }
195
191
  }
196
- var assignRequestQueryToSearchParams = (searchParams, query) => {
197
- const compositionQueryParamNames = Object.values(compositionQueryParam);
198
- Object.entries(query).forEach(([name, value]) => {
199
- if (name === import_canvas.SECRET_QUERY_STRING_PARAM) {
200
- return;
201
- }
202
- if (compositionQueryParamNames.includes(name)) {
203
- return;
204
- }
205
- if (typeof value === "undefined") {
206
- return;
207
- }
208
- if (typeof value === "object") {
209
- value.forEach((singleValue) => searchParams.append(name, singleValue));
210
- return;
211
- }
212
- searchParams.append(name, value);
213
- });
214
- };
215
192
 
216
193
  // src/preview/previewHandlerPost.ts
217
194
  var import_canvas3 = require("@uniformdev/canvas");
package/dist/index.mjs CHANGED
@@ -51,8 +51,7 @@ var UniformRichTextNode = ({
51
51
  // src/preview/previewHandlerGet.ts
52
52
  import {
53
53
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM,
54
- IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
55
- SECRET_QUERY_STRING_PARAM
54
+ IN_CONTEXT_EDITOR_QUERY_STRING_PARAM
56
55
  } from "@uniformdev/canvas";
57
56
  import { isAllowedReferrer } from "@uniformdev/canvas";
58
57
  var BASE_URL_EXAMPLE = "https://example.com";
@@ -63,16 +62,10 @@ var getQueryParam = (req, paramName) => {
63
62
  }
64
63
  return Array.isArray(value) ? value[0] : value;
65
64
  };
66
- var contextualEditingQueryParams = [
65
+ var queryParamsToPreserve = [
67
66
  IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,
68
67
  IN_CONTEXT_EDITOR_PLAYGROUND_QUERY_STRING_PARAM
69
68
  ];
70
- var compositionQueryParam = {
71
- id: "id",
72
- slug: "slug",
73
- path: "path",
74
- locale: "locale"
75
- };
76
69
  var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefault, playgroundPath } = {}) => async (req, res) => {
77
70
  const isConfigCheck = getQueryParam(req, "is_config_check") === "true";
78
71
  if (isConfigCheck) {
@@ -89,10 +82,10 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
89
82
  if (isPlayground && playgroundPath) {
90
83
  pathToRedirectTo = playgroundPath;
91
84
  }
92
- const id = getQueryParam(req, compositionQueryParam.id);
93
- const slug = getQueryParam(req, compositionQueryParam.slug);
94
- const path = getQueryParam(req, compositionQueryParam.path);
95
- const locale = getQueryParam(req, compositionQueryParam.locale);
85
+ const id = getQueryParam(req, "id");
86
+ const slug = getQueryParam(req, "slug");
87
+ const path = getQueryParam(req, "path");
88
+ const locale = getQueryParam(req, "locale");
96
89
  if (typeof pathToRedirectTo === "undefined") {
97
90
  pathToRedirectTo = resolveFullPath({ id, slug, path, locale });
98
91
  }
@@ -107,7 +100,7 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
107
100
  }
108
101
  const previewSecret = typeof secret === "function" ? secret == null ? void 0 : secret() : secret;
109
102
  const isUsingPreviewSecret = Boolean(previewSecret);
110
- if (isUsingPreviewSecret && req.query[SECRET_QUERY_STRING_PARAM] !== previewSecret) {
103
+ if (isUsingPreviewSecret && req.query.secret !== previewSecret) {
111
104
  return res.status(401).json({ message: "Invalid token" });
112
105
  }
113
106
  const isUniformContextualEditing = req.query[IN_CONTEXT_EDITOR_QUERY_STRING_PARAM] === "true" && isAllowedReferrer(req.headers.referer);
@@ -134,10 +127,12 @@ var createPreviewHandlerGet = ({ secret, resolveFullPath = resolveFullPathDefaul
134
127
  cookies == null ? void 0 : cookies.map((cookie) => cookie.replace("SameSite=Lax", "SameSite=None;Secure"))
135
128
  );
136
129
  const redirectionUrl = new URL(pathToRedirectTo, BASE_URL_EXAMPLE);
137
- assignRequestQueryToSearchParams(redirectionUrl.searchParams, req.query);
138
- if (!isUniformContextualEditing) {
139
- contextualEditingQueryParams.forEach((param) => {
140
- redirectionUrl.searchParams.delete(param);
130
+ if (isUniformContextualEditing) {
131
+ queryParamsToPreserve.forEach((param) => {
132
+ const paramValue = req.query[param];
133
+ if (typeof paramValue === "string") {
134
+ redirectionUrl.searchParams.append(param, paramValue);
135
+ }
141
136
  });
142
137
  }
143
138
  const fullPathToRedirectTo = redirectionUrl.href.replace(BASE_URL_EXAMPLE, "");
@@ -151,25 +146,6 @@ function validateLocalRedirectUrl(pathToRedirectTo) {
151
146
  throw new Error("Tried to redirect to absolute URL with protocol. Disallowing open redirect.");
152
147
  }
153
148
  }
154
- var assignRequestQueryToSearchParams = (searchParams, query) => {
155
- const compositionQueryParamNames = Object.values(compositionQueryParam);
156
- Object.entries(query).forEach(([name, value]) => {
157
- if (name === SECRET_QUERY_STRING_PARAM) {
158
- return;
159
- }
160
- if (compositionQueryParamNames.includes(name)) {
161
- return;
162
- }
163
- if (typeof value === "undefined") {
164
- return;
165
- }
166
- if (typeof value === "object") {
167
- value.forEach((singleValue) => searchParams.append(name, singleValue));
168
- return;
169
- }
170
- searchParams.append(name, value);
171
- });
172
- };
173
149
 
174
150
  // src/preview/previewHandlerPost.ts
175
151
  import { generateHash } from "@uniformdev/canvas";
@@ -141,7 +141,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
141
141
  } | undefined;
142
142
  _overridability?: {
143
143
  parameters?: {
144
- [key: string]: "no" | "yes";
144
+ [key: string]: "yes" | "no";
145
145
  } | undefined;
146
146
  variants?: boolean | undefined;
147
147
  } | undefined;
@@ -177,7 +177,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
177
177
  } | undefined;
178
178
  _overridability?: {
179
179
  parameters?: {
180
- [key: string]: "no" | "yes";
180
+ [key: string]: "yes" | "no";
181
181
  } | undefined;
182
182
  variants?: boolean | undefined;
183
183
  } | undefined;
@@ -265,7 +265,7 @@ declare const getStaticProps: next.GetStaticProps<{
265
265
  } | undefined;
266
266
  _overridability?: {
267
267
  parameters?: {
268
- [key: string]: "no" | "yes";
268
+ [key: string]: "yes" | "no";
269
269
  } | undefined;
270
270
  variants?: boolean | undefined;
271
271
  } | undefined;
@@ -301,7 +301,7 @@ declare const getStaticProps: next.GetStaticProps<{
301
301
  } | undefined;
302
302
  _overridability?: {
303
303
  parameters?: {
304
- [key: string]: "no" | "yes";
304
+ [key: string]: "yes" | "no";
305
305
  } | undefined;
306
306
  variants?: boolean | undefined;
307
307
  } | undefined;
@@ -141,7 +141,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
141
141
  } | undefined;
142
142
  _overridability?: {
143
143
  parameters?: {
144
- [key: string]: "no" | "yes";
144
+ [key: string]: "yes" | "no";
145
145
  } | undefined;
146
146
  variants?: boolean | undefined;
147
147
  } | undefined;
@@ -177,7 +177,7 @@ declare const getServerSideProps: next.GetServerSideProps<{
177
177
  } | undefined;
178
178
  _overridability?: {
179
179
  parameters?: {
180
- [key: string]: "no" | "yes";
180
+ [key: string]: "yes" | "no";
181
181
  } | undefined;
182
182
  variants?: boolean | undefined;
183
183
  } | undefined;
@@ -265,7 +265,7 @@ declare const getStaticProps: next.GetStaticProps<{
265
265
  } | undefined;
266
266
  _overridability?: {
267
267
  parameters?: {
268
- [key: string]: "no" | "yes";
268
+ [key: string]: "yes" | "no";
269
269
  } | undefined;
270
270
  variants?: boolean | undefined;
271
271
  } | undefined;
@@ -301,7 +301,7 @@ declare const getStaticProps: next.GetStaticProps<{
301
301
  } | undefined;
302
302
  _overridability?: {
303
303
  parameters?: {
304
- [key: string]: "no" | "yes";
304
+ [key: string]: "yes" | "no";
305
305
  } | undefined;
306
306
  variants?: boolean | undefined;
307
307
  } | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next",
3
- "version": "19.60.1-alpha.6+ac384b46c",
3
+ "version": "19.61.1-alpha.10+8aa257167",
4
4
  "description": "Next.js SDK for Uniform Canvas",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -67,11 +67,11 @@
67
67
  "document": "api-extractor run --local"
68
68
  },
69
69
  "dependencies": {
70
- "@uniformdev/canvas": "19.60.1-alpha.6+ac384b46c",
71
- "@uniformdev/canvas-react": "19.60.1-alpha.6+ac384b46c",
72
- "@uniformdev/project-map": "19.60.1-alpha.6+ac384b46c",
73
- "@uniformdev/redirect": "19.60.1-alpha.6+ac384b46c",
74
- "@uniformdev/richtext": "19.60.1-alpha.6+ac384b46c",
70
+ "@uniformdev/canvas": "19.61.1-alpha.10+8aa257167",
71
+ "@uniformdev/canvas-react": "19.61.1-alpha.10+8aa257167",
72
+ "@uniformdev/project-map": "19.61.1-alpha.10+8aa257167",
73
+ "@uniformdev/redirect": "19.61.1-alpha.10+8aa257167",
74
+ "@uniformdev/richtext": "19.61.1-alpha.10+8aa257167",
75
75
  "colorette": "2.0.20"
76
76
  },
77
77
  "peerDependencies": {
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "ac384b46c7694dbecf4983cb04cd66dc8904c5fa"
94
+ "gitHead": "8aa2571675505a90ba544863f87621dd90750c3a"
95
95
  }