@cmssy/next 0.5.5 → 0.6.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 CHANGED
@@ -26,11 +26,10 @@ export default createCmssyPage(cmssy, blocks, { editor: CmssyEditor });
26
26
  import type { CmssyNextConfig } from "@cmssy/next";
27
27
 
28
28
  export const cmssy: CmssyNextConfig = {
29
- apiUrl: process.env.CMSSY_API_URL ?? "", // public GraphQL delivery endpoint
30
29
  workspaceSlug: process.env.CMSSY_WORKSPACE_SLUG ?? "",
31
30
  draftSecret: process.env.CMSSY_DRAFT_SECRET ?? "", // edit-mode preview handshake
32
- editorOrigin: process.env.CMSSY_EDITOR_ORIGIN ?? "", // only needed in edit mode
33
31
  defaultLocale: "en",
32
+ // apiUrl + editorOrigin default to cmssy cloud; set them only for self-host/staging.
34
33
  };
35
34
  ```
36
35
 
package/dist/index.cjs CHANGED
@@ -71,6 +71,30 @@ function sessionCookieOptions() {
71
71
  }
72
72
 
73
73
  // src/config.ts
74
+ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
75
+ "https://cmssy.io",
76
+ "https://www.cmssy.io"
77
+ ];
78
+ function parseEditorOriginEnv(raw) {
79
+ if (!raw) return void 0;
80
+ const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
81
+ if (parts.length === 0) return void 0;
82
+ return parts.length === 1 ? parts[0] : parts;
83
+ }
84
+ function isDevelopment() {
85
+ return typeof process !== "undefined" && process.env.NODE_ENV === "development";
86
+ }
87
+ function resolveEditorOrigin(editorOrigin) {
88
+ const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
89
+ if (value === void 0) {
90
+ return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
91
+ }
92
+ if (Array.isArray(value)) {
93
+ const cleaned = value.filter((o) => o && o.trim().length > 0);
94
+ return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
95
+ }
96
+ return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
97
+ }
74
98
  function assertAuthConfig(config) {
75
99
  const auth = config.auth;
76
100
  if (!auth || typeof auth.modelSlug !== "string" || !auth.modelSlug) {
@@ -122,7 +146,8 @@ function toCspOrigin(origin) {
122
146
  return parsed.origin;
123
147
  }
124
148
  function frameAncestors(editorOrigin) {
125
- const origins = Array.isArray(editorOrigin) ? editorOrigin : [editorOrigin];
149
+ const resolved = resolveEditorOrigin(editorOrigin);
150
+ const origins = Array.isArray(resolved) ? resolved : [resolved];
126
151
  if (origins.length === 0) {
127
152
  throw new Error(
128
153
  "cmssy: editorOrigin must contain at least one valid origin"
@@ -265,7 +290,8 @@ function createCmssyPage(config, blocks, options) {
265
290
  };
266
291
  }
267
292
  function resolveBridgeOrigin(editorOrigin) {
268
- const origins = Array.isArray(editorOrigin) ? editorOrigin : [editorOrigin];
293
+ const resolved = resolveEditorOrigin(editorOrigin);
294
+ const origins = Array.isArray(resolved) ? resolved : [resolved];
269
295
  if (origins.length === 0) {
270
296
  throw new Error("cmssy: editorOrigin must be set to frame the editor");
271
297
  }
@@ -275,9 +301,9 @@ function resolveBridgeOrigin(editorOrigin) {
275
301
  );
276
302
  }
277
303
  const origin = toCspOrigin(origins[0].trim());
278
- if (origin === "*") {
304
+ if (origin === "*" && !isDevelopment()) {
279
305
  throw new Error(
280
- "cmssy: editorOrigin '*' is not allowed for the live-edit bridge; set the concrete editor origin (e.g. https://app.cmssy.io)"
306
+ "cmssy: editorOrigin '*' is only allowed in development; set a concrete editor origin (e.g. https://cmssy.io) for production"
281
307
  );
282
308
  }
283
309
  return origin;
@@ -659,7 +685,7 @@ var VERIFY_MUTATION = `mutation SiteMemberVerifyEmail($token: String!) {
659
685
  }`;
660
686
  var workspaceIdCache = /* @__PURE__ */ new Map();
661
687
  function workspaceIdFor(config) {
662
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
688
+ const key = `${react.resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
663
689
  const existing = workspaceIdCache.get(key);
664
690
  if (existing) return existing;
665
691
  const fresh = react.resolveWorkspaceId(config).catch((err) => {
@@ -1046,7 +1072,7 @@ var PRODUCT = `query Product($workspaceId: String!, $modelSlug: String!, $filter
1046
1072
  }`;
1047
1073
  var workspaceIdCache2 = /* @__PURE__ */ new Map();
1048
1074
  function workspaceIdFor2(config) {
1049
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
1075
+ const key = `${react.resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
1050
1076
  const existing = workspaceIdCache2.get(key);
1051
1077
  if (existing) return existing;
1052
1078
  const fresh = react.resolveWorkspaceId(config).catch((err) => {
@@ -1454,7 +1480,7 @@ var MY_ORDER = `query MyOrder($workspaceId: ID!, $id: ID!) {
1454
1480
  }`;
1455
1481
  var workspaceIdCache3 = /* @__PURE__ */ new Map();
1456
1482
  function workspaceIdFor3(config) {
1457
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
1483
+ const key = `${react.resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
1458
1484
  const existing = workspaceIdCache3.get(key);
1459
1485
  if (existing) return existing;
1460
1486
  const fresh = react.resolveWorkspaceId(config).catch((err) => {
@@ -1607,11 +1633,20 @@ function verifyCmssyWebhook(options) {
1607
1633
  return parsed;
1608
1634
  }
1609
1635
 
1636
+ Object.defineProperty(exports, "DEFAULT_CMSSY_API_URL", {
1637
+ enumerable: true,
1638
+ get: function () { return react.DEFAULT_CMSSY_API_URL; }
1639
+ });
1640
+ Object.defineProperty(exports, "resolveApiUrl", {
1641
+ enumerable: true,
1642
+ get: function () { return react.resolveApiUrl; }
1643
+ });
1610
1644
  exports.CMSSY_CART_COOKIE = CMSSY_CART_COOKIE;
1611
1645
  exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
1612
1646
  exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
1613
1647
  exports.CMSSY_SESSION_COOKIE = CMSSY_SESSION_COOKIE;
1614
1648
  exports.CmssyWebhookError = CmssyWebhookError;
1649
+ exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
1615
1650
  exports.SESSION_MAX_AGE_SECONDS = SESSION_MAX_AGE_SECONDS;
1616
1651
  exports.applyCmssyCsp = applyCmssyCsp;
1617
1652
  exports.assertAuthConfig = assertAuthConfig;
@@ -1637,6 +1672,7 @@ exports.isCmssyEditMode = isCmssyEditMode;
1637
1672
  exports.isCmssyEditRequest = isCmssyEditRequest;
1638
1673
  exports.localeForPathname = localeForPathname;
1639
1674
  exports.openSession = openSession;
1675
+ exports.resolveEditorOrigin = resolveEditorOrigin;
1640
1676
  exports.resolveLocaleFromPathname = resolveLocaleFromPathname;
1641
1677
  exports.sealSession = sealSession;
1642
1678
  exports.sessionCookieOptions = sessionCookieOptions;
package/dist/index.d.cts CHANGED
@@ -1,19 +1,30 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType, ReactNode } from 'react';
3
3
  import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig, CmssyProduct, CmssyOrder } from '@cmssy/react';
4
+ export { DEFAULT_CMSSY_API_URL, resolveApiUrl } from '@cmssy/react';
4
5
  import { EditBridgeConfig } from '@cmssy/react/client';
5
6
  import { MetadataRoute, Metadata } from 'next';
6
7
  import { NextRequest, NextResponse } from 'next/server';
7
8
 
9
+ declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
10
+ declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
8
11
  interface CmssyAuthConfig {
9
12
  modelSlug: string;
10
13
  sessionSecret: string;
11
14
  }
12
15
  interface CmssyNextConfig {
13
- apiUrl: string;
16
+ /**
17
+ * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
18
+ * (`https://api.cmssy.io/graphql`); set it only for self-hosted / staging.
19
+ */
20
+ apiUrl?: string;
14
21
  workspaceSlug: string;
15
22
  draftSecret: string;
16
- editorOrigin: string | string[];
23
+ /**
24
+ * Origin allowed to frame your app in the editor. Defaults to
25
+ * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
26
+ */
27
+ editorOrigin?: string | string[];
17
28
  /**
18
29
  * Canonical absolute site URL (e.g. https://cmssy.com), used by
19
30
  * createCmssyRobots / createCmssySitemap. When omitted the helpers derive the
@@ -141,7 +152,8 @@ type CmssyDraftRouteConfig = Pick<CmssyNextConfig, "draftSecret"> & {
141
152
  declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
142
153
 
143
154
  interface CmssyCspOptions {
144
- editorOrigin: string | string[];
155
+ /** Defaults to the cmssy cloud admin origin when unset. */
156
+ editorOrigin?: string | string[];
145
157
  }
146
158
  interface MutableHeaders {
147
159
  headers: {
@@ -328,4 +340,4 @@ declare class CmssyWebhookError extends Error {
328
340
  */
329
341
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
330
342
 
331
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
343
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,30 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ComponentType, ReactNode } from 'react';
3
3
  import { CmssyPageData, CmssyFormDefinition, BlockDefinition, CmssyClientConfig, CmssyProduct, CmssyOrder } from '@cmssy/react';
4
+ export { DEFAULT_CMSSY_API_URL, resolveApiUrl } from '@cmssy/react';
4
5
  import { EditBridgeConfig } from '@cmssy/react/client';
5
6
  import { MetadataRoute, Metadata } from 'next';
6
7
  import { NextRequest, NextResponse } from 'next/server';
7
8
 
9
+ declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
10
+ declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
8
11
  interface CmssyAuthConfig {
9
12
  modelSlug: string;
10
13
  sessionSecret: string;
11
14
  }
12
15
  interface CmssyNextConfig {
13
- apiUrl: string;
16
+ /**
17
+ * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
18
+ * (`https://api.cmssy.io/graphql`); set it only for self-hosted / staging.
19
+ */
20
+ apiUrl?: string;
14
21
  workspaceSlug: string;
15
22
  draftSecret: string;
16
- editorOrigin: string | string[];
23
+ /**
24
+ * Origin allowed to frame your app in the editor. Defaults to
25
+ * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
26
+ */
27
+ editorOrigin?: string | string[];
17
28
  /**
18
29
  * Canonical absolute site URL (e.g. https://cmssy.com), used by
19
30
  * createCmssyRobots / createCmssySitemap. When omitted the helpers derive the
@@ -141,7 +152,8 @@ type CmssyDraftRouteConfig = Pick<CmssyNextConfig, "draftSecret"> & {
141
152
  declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
142
153
 
143
154
  interface CmssyCspOptions {
144
- editorOrigin: string | string[];
155
+ /** Defaults to the cmssy cloud admin origin when unset. */
156
+ editorOrigin?: string | string[];
145
157
  }
146
158
  interface MutableHeaders {
147
159
  headers: {
@@ -328,4 +340,4 @@ declare class CmssyWebhookError extends Error {
328
340
  */
329
341
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
330
342
 
331
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
343
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { draftMode, headers, cookies } from 'next/headers';
2
2
  import { notFound, redirect } from 'next/navigation';
3
- import { createCmssyClient, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, CmssyServerPage, fetchSiteConfig, fetchPageById, fetchPages, fetchPageMeta, normalizeSlug as normalizeSlug$1, resolveWorkspaceId, graphqlRequest } from '@cmssy/react';
3
+ import { createCmssyClient, resolveSiteLocales, splitLocaleFromPath, fetchPage, resolveForms, CmssyServerPage, fetchSiteConfig, fetchPageById, fetchPages, fetchPageMeta, normalizeSlug as normalizeSlug$1, resolveWorkspaceId, graphqlRequest, resolveApiUrl } from '@cmssy/react';
4
+ export { DEFAULT_CMSSY_API_URL, resolveApiUrl } from '@cmssy/react';
4
5
  import { CmssyLocaleProvider } from '@cmssy/react/client';
5
6
  import { EncryptJWT, jwtDecrypt } from 'jose';
6
7
  import { jsx, jsxs } from 'react/jsx-runtime';
@@ -69,6 +70,30 @@ function sessionCookieOptions() {
69
70
  }
70
71
 
71
72
  // src/config.ts
73
+ var DEFAULT_CMSSY_EDITOR_ORIGINS = [
74
+ "https://cmssy.io",
75
+ "https://www.cmssy.io"
76
+ ];
77
+ function parseEditorOriginEnv(raw) {
78
+ if (!raw) return void 0;
79
+ const parts = raw.split(",").map((o) => o.trim()).filter((o) => o.length > 0);
80
+ if (parts.length === 0) return void 0;
81
+ return parts.length === 1 ? parts[0] : parts;
82
+ }
83
+ function isDevelopment() {
84
+ return typeof process !== "undefined" && process.env.NODE_ENV === "development";
85
+ }
86
+ function resolveEditorOrigin(editorOrigin) {
87
+ const value = editorOrigin ?? (typeof process !== "undefined" ? parseEditorOriginEnv(process.env.CMSSY_EDITOR_ORIGIN) : void 0);
88
+ if (value === void 0) {
89
+ return isDevelopment() ? "*" : DEFAULT_CMSSY_EDITOR_ORIGINS;
90
+ }
91
+ if (Array.isArray(value)) {
92
+ const cleaned = value.filter((o) => o && o.trim().length > 0);
93
+ return cleaned.length > 0 ? cleaned : DEFAULT_CMSSY_EDITOR_ORIGINS;
94
+ }
95
+ return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
96
+ }
72
97
  function assertAuthConfig(config) {
73
98
  const auth = config.auth;
74
99
  if (!auth || typeof auth.modelSlug !== "string" || !auth.modelSlug) {
@@ -120,7 +145,8 @@ function toCspOrigin(origin) {
120
145
  return parsed.origin;
121
146
  }
122
147
  function frameAncestors(editorOrigin) {
123
- const origins = Array.isArray(editorOrigin) ? editorOrigin : [editorOrigin];
148
+ const resolved = resolveEditorOrigin(editorOrigin);
149
+ const origins = Array.isArray(resolved) ? resolved : [resolved];
124
150
  if (origins.length === 0) {
125
151
  throw new Error(
126
152
  "cmssy: editorOrigin must contain at least one valid origin"
@@ -263,7 +289,8 @@ function createCmssyPage(config, blocks, options) {
263
289
  };
264
290
  }
265
291
  function resolveBridgeOrigin(editorOrigin) {
266
- const origins = Array.isArray(editorOrigin) ? editorOrigin : [editorOrigin];
292
+ const resolved = resolveEditorOrigin(editorOrigin);
293
+ const origins = Array.isArray(resolved) ? resolved : [resolved];
267
294
  if (origins.length === 0) {
268
295
  throw new Error("cmssy: editorOrigin must be set to frame the editor");
269
296
  }
@@ -273,9 +300,9 @@ function resolveBridgeOrigin(editorOrigin) {
273
300
  );
274
301
  }
275
302
  const origin = toCspOrigin(origins[0].trim());
276
- if (origin === "*") {
303
+ if (origin === "*" && !isDevelopment()) {
277
304
  throw new Error(
278
- "cmssy: editorOrigin '*' is not allowed for the live-edit bridge; set the concrete editor origin (e.g. https://app.cmssy.io)"
305
+ "cmssy: editorOrigin '*' is only allowed in development; set a concrete editor origin (e.g. https://cmssy.io) for production"
279
306
  );
280
307
  }
281
308
  return origin;
@@ -657,7 +684,7 @@ var VERIFY_MUTATION = `mutation SiteMemberVerifyEmail($token: String!) {
657
684
  }`;
658
685
  var workspaceIdCache = /* @__PURE__ */ new Map();
659
686
  function workspaceIdFor(config) {
660
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
687
+ const key = `${resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
661
688
  const existing = workspaceIdCache.get(key);
662
689
  if (existing) return existing;
663
690
  const fresh = resolveWorkspaceId(config).catch((err) => {
@@ -1044,7 +1071,7 @@ var PRODUCT = `query Product($workspaceId: String!, $modelSlug: String!, $filter
1044
1071
  }`;
1045
1072
  var workspaceIdCache2 = /* @__PURE__ */ new Map();
1046
1073
  function workspaceIdFor2(config) {
1047
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
1074
+ const key = `${resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
1048
1075
  const existing = workspaceIdCache2.get(key);
1049
1076
  if (existing) return existing;
1050
1077
  const fresh = resolveWorkspaceId(config).catch((err) => {
@@ -1452,7 +1479,7 @@ var MY_ORDER = `query MyOrder($workspaceId: ID!, $id: ID!) {
1452
1479
  }`;
1453
1480
  var workspaceIdCache3 = /* @__PURE__ */ new Map();
1454
1481
  function workspaceIdFor3(config) {
1455
- const key = `${config.apiUrl}::${config.workspaceSlug}`;
1482
+ const key = `${resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
1456
1483
  const existing = workspaceIdCache3.get(key);
1457
1484
  if (existing) return existing;
1458
1485
  const fresh = resolveWorkspaceId(config).catch((err) => {
@@ -1605,4 +1632,4 @@ function verifyCmssyWebhook(options) {
1605
1632
  return parsed;
1606
1633
  }
1607
1634
 
1608
- export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, CmssyWebhookError, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
1635
+ export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.5.5",
3
+ "version": "0.6.0",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -41,7 +41,7 @@
41
41
  "dist"
42
42
  ],
43
43
  "peerDependencies": {
44
- "@cmssy/react": "^0.5.5",
44
+ "@cmssy/react": "^0.5.6",
45
45
  "next": ">=15",
46
46
  "react": "^18.2.0 || ^19.0.0",
47
47
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -54,7 +54,7 @@
54
54
  "tsup": "^8.3.0",
55
55
  "typescript": "^5.6.0",
56
56
  "vitest": "^2.1.0",
57
- "@cmssy/react": "0.5.5"
57
+ "@cmssy/react": "0.6.0"
58
58
  },
59
59
  "dependencies": {
60
60
  "jose": "^6.2.3"