@cmssy/next 9.10.0 → 10.0.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/dist/client.cjs CHANGED
@@ -2,8 +2,8 @@
2
2
  'use strict';
3
3
 
4
4
  var Link = require('next/link');
5
- var react = require('@cmssy/react');
6
- var client = require('@cmssy/react/client');
5
+ var internal$1 = require('@cmssy/core/internal');
6
+ var internal = require('@cmssy/react/internal');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -12,18 +12,10 @@ var Link__default = /*#__PURE__*/_interopDefault(Link);
12
12
 
13
13
  // src/cmssy-link.tsx
14
14
  function CmssyLink({ href, locale, ...rest }) {
15
- const fromContext = client.useCmssyLocale();
15
+ const fromContext = internal.useCmssyLocale();
16
16
  const active = locale ?? fromContext;
17
- const resolved = active ? react.localizeHref(href, active) : href;
17
+ const resolved = active ? internal$1.localizeHref(href, active) : href;
18
18
  return /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: resolved, ...rest });
19
19
  }
20
20
 
21
- Object.defineProperty(exports, "CmssyLocaleProvider", {
22
- enumerable: true,
23
- get: function () { return client.CmssyLocaleProvider; }
24
- });
25
- Object.defineProperty(exports, "useCmssyLocale", {
26
- enumerable: true,
27
- get: function () { return client.useCmssyLocale; }
28
- });
29
21
  exports.CmssyLink = CmssyLink;
package/dist/client.d.cts CHANGED
@@ -2,7 +2,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import Link from 'next/link';
3
3
  import { ComponentProps } from 'react';
4
4
  import { CmssyLocaleContext } from '@cmssy/react';
5
- export { CmssyLocaleProvider, CmssyLocaleProviderProps, useCmssyLocale } from '@cmssy/react/client';
6
5
 
7
6
  interface CmssyLinkProps extends Omit<ComponentProps<typeof Link>, "href" | "locale"> {
8
7
  href: string;
package/dist/client.d.ts CHANGED
@@ -2,7 +2,6 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import Link from 'next/link';
3
3
  import { ComponentProps } from 'react';
4
4
  import { CmssyLocaleContext } from '@cmssy/react';
5
- export { CmssyLocaleProvider, CmssyLocaleProviderProps, useCmssyLocale } from '@cmssy/react/client';
6
5
 
7
6
  interface CmssyLinkProps extends Omit<ComponentProps<typeof Link>, "href" | "locale"> {
8
7
  href: string;
package/dist/client.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import Link from 'next/link';
3
- import { localizeHref } from '@cmssy/react';
4
- import { useCmssyLocale } from '@cmssy/react/client';
5
- export { CmssyLocaleProvider, useCmssyLocale } from '@cmssy/react/client';
3
+ import { localizeHref } from '@cmssy/core/internal';
4
+ import { useCmssyLocale } from '@cmssy/react/internal';
6
5
  import { jsx } from 'react/jsx-runtime';
7
6
 
8
7
  // src/cmssy-link.tsx
package/dist/index.cjs CHANGED
@@ -12,26 +12,14 @@ Object.defineProperty(exports, "CMSSY_EDIT_QUERY_PARAM", {
12
12
  enumerable: true,
13
13
  get: function () { return core.CMSSY_EDIT_QUERY_PARAM; }
14
14
  });
15
- Object.defineProperty(exports, "CMSSY_LOCALE_HEADER", {
16
- enumerable: true,
17
- get: function () { return core.CMSSY_LOCALE_HEADER; }
18
- });
19
15
  Object.defineProperty(exports, "CMSSY_SECRET_QUERY_PARAM", {
20
16
  enumerable: true,
21
17
  get: function () { return core.CMSSY_SECRET_QUERY_PARAM; }
22
18
  });
23
- Object.defineProperty(exports, "CMSSY_SESSION_COOKIE", {
24
- enumerable: true,
25
- get: function () { return core.CMSSY_SESSION_COOKIE; }
26
- });
27
19
  Object.defineProperty(exports, "DEFAULT_CMSSY_EDITOR_ORIGINS", {
28
20
  enumerable: true,
29
21
  get: function () { return core.DEFAULT_CMSSY_EDITOR_ORIGINS; }
30
22
  });
31
- Object.defineProperty(exports, "assertAuthConfig", {
32
- enumerable: true,
33
- get: function () { return core.assertAuthConfig; }
34
- });
35
23
  Object.defineProperty(exports, "defineCmssyConfig", {
36
24
  enumerable: true,
37
25
  get: function () { return core.defineCmssyConfig; }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyAuthConfig, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, assertAuthConfig, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
1
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
2
2
  export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-C4vUxDkk.cjs';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyAuthConfig, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, assertAuthConfig, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
1
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyConfig, CmssyEnvConfig, CmssyPageData, CmssyPageMeta, CmssyPageSummary, DEFAULT_CMSSY_EDITOR_ORIGINS, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
2
2
  export { C as CmssyEditorProps, a as CreateCmssyPageOptions } from './index-C4vUxDkk.js';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, DEFAULT_CMSSY_EDITOR_ORIGINS, assertAuthConfig, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
1
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, DEFAULT_CMSSY_EDITOR_ORIGINS, defineCmssyConfig, resolveEditorOrigin } from '@cmssy/core';
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var server = require('next/server');
4
- var react = require('@cmssy/react');
4
+ var locale = require('@cmssy/core/internal/locale');
5
5
  var core = require('@cmssy/core');
6
+ var internal = require('@cmssy/core/internal');
6
7
 
7
8
  // src/preset/proxy.ts
8
9
  var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
@@ -12,7 +13,7 @@ async function cmssyEditRewrite(request, config, options = {}) {
12
13
  if (!searchParams.getAll(core.CMSSY_EDIT_QUERY_PARAM).includes("1")) return null;
13
14
  const provided = searchParams.get(core.CMSSY_SECRET_QUERY_PARAM);
14
15
  if (!provided || !config.draftSecret) return null;
15
- if (!await core.cmssySecretsMatch(provided, config.draftSecret)) return null;
16
+ if (!await internal.cmssySecretsMatch(provided, config.draftSecret)) return null;
16
17
  const url = request.nextUrl.clone();
17
18
  url.pathname = `${CMSSY_EDIT_PATH_PREFIX}${pathname === "/" ? "" : pathname}`;
18
19
  warnIfEditRouteMissing(url);
@@ -49,9 +50,9 @@ function createCmssyProxy(config, options = {}) {
49
50
  const { pathname } = request.nextUrl;
50
51
  const requestHeaders = new Headers(request.headers);
51
52
  requestHeaders.delete(core.CMSSY_EDIT_HEADER);
52
- requestHeaders.delete(core.CMSSY_LOCALE_HEADER);
53
- const locale = await core.localeForPathname(config, pathname);
54
- requestHeaders.set(core.CMSSY_LOCALE_HEADER, locale);
53
+ requestHeaders.delete(locale.CMSSY_LOCALE_HEADER);
54
+ const locale$1 = await locale.localeForPathname(config, pathname);
55
+ requestHeaders.set(locale.CMSSY_LOCALE_HEADER, locale$1);
55
56
  const editHeaders = new Headers(requestHeaders);
56
57
  editHeaders.set(core.CMSSY_EDIT_HEADER, "1");
57
58
  const editRewrite = await cmssyEditRewrite(request, config, {
@@ -61,11 +62,11 @@ function createCmssyProxy(config, options = {}) {
61
62
  core.applyCmssyCsp(editRewrite, { editorOrigin: config.editorOrigin });
62
63
  return editRewrite;
63
64
  }
64
- if (options.stripLocalePrefix && pathname.startsWith(`/${locale}`)) {
65
- const { defaultLocale } = await react.resolveSiteLocales(config);
66
- if (locale !== defaultLocale) {
65
+ if (options.stripLocalePrefix && pathname.startsWith(`/${locale$1}`)) {
66
+ const { defaultLocale } = await locale.resolveSiteLocales(config);
67
+ if (locale$1 !== defaultLocale) {
67
68
  const url = request.nextUrl.clone();
68
- url.pathname = pathname.slice(locale.length + 1) || "/";
69
+ url.pathname = pathname.slice(locale$1.length + 1) || "/";
69
70
  return server.NextResponse.rewrite(url, {
70
71
  request: { headers: requestHeaders }
71
72
  });
@@ -75,75 +76,6 @@ function createCmssyProxy(config, options = {}) {
75
76
  };
76
77
  }
77
78
  var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
78
- async function resolveLocaleFromPathname(config, pathname) {
79
- const segments = pathname.split("/").filter(Boolean);
80
- const siteLocales = await react.resolveSiteLocales({
81
- apiUrl: config.apiUrl,
82
- org: config.org,
83
- workspaceSlug: config.workspaceSlug
84
- });
85
- return react.splitLocaleFromPath(segments, siteLocales).locale;
86
- }
87
- function createCmssyLocaleMiddleware(config) {
88
- return async function cmssyLocaleMiddleware(request) {
89
- const locale = await resolveLocaleFromPathname(
90
- config,
91
- request.nextUrl.pathname
92
- );
93
- const headers = new Headers(request.headers);
94
- headers.set(core.CMSSY_LOCALE_HEADER, locale);
95
- return server.NextResponse.next({ request: { headers } });
96
- };
97
- }
98
- function isPrefetch(request) {
99
- return request.headers.get("next-router-prefetch") !== null || request.headers.get("purpose") === "prefetch" || (request.headers.get("sec-purpose") ?? "").includes("prefetch");
100
- }
101
- function createCmssyAuthMiddleware(config) {
102
- const auth = core.assertAuthConfig(config);
103
- return async function cmssyAuthMiddleware(request) {
104
- const raw = request.cookies.get(core.CMSSY_SESSION_COOKIE)?.value;
105
- if (!raw) return server.NextResponse.next();
106
- const session = await core.openSession(
107
- raw,
108
- auth.sessionSecret,
109
- config.workspaceSlug
110
- );
111
- if (!session) {
112
- const response = server.NextResponse.next();
113
- response.cookies.set(core.CMSSY_SESSION_COOKIE, "", {
114
- ...core.sessionCookieOptions(),
115
- maxAge: 0
116
- });
117
- return response;
118
- }
119
- if (!core.isAccessExpired(session)) return server.NextResponse.next();
120
- if (isPrefetch(request)) return server.NextResponse.next();
121
- let payload = null;
122
- try {
123
- const result = await core.backendRefresh(config, session.refreshToken);
124
- payload = core.toSessionPayload(result);
125
- } catch {
126
- return server.NextResponse.next();
127
- }
128
- if (!payload) {
129
- const cleared = server.NextResponse.next();
130
- cleared.cookies.set(core.CMSSY_SESSION_COOKIE, "", {
131
- ...core.sessionCookieOptions(),
132
- maxAge: 0
133
- });
134
- return cleared;
135
- }
136
- const sealed = await core.sealSession(
137
- payload,
138
- auth.sessionSecret,
139
- config.workspaceSlug
140
- );
141
- request.cookies.set(core.CMSSY_SESSION_COOKIE, sealed);
142
- const refreshed = server.NextResponse.next({ request });
143
- refreshed.cookies.set(core.CMSSY_SESSION_COOKIE, sealed, core.sessionCookieOptions());
144
- return refreshed;
145
- };
146
- }
147
79
  async function isCmssyEditRequest(request, config) {
148
80
  if (request.cookies.has("__prerender_bypass")) return true;
149
81
  return core.isVerifiedEditUrl(request.nextUrl, config);
@@ -153,28 +85,13 @@ Object.defineProperty(exports, "CMSSY_EDIT_HEADER", {
153
85
  enumerable: true,
154
86
  get: function () { return core.CMSSY_EDIT_HEADER; }
155
87
  });
156
- Object.defineProperty(exports, "CMSSY_LOCALE_HEADER", {
157
- enumerable: true,
158
- get: function () { return core.CMSSY_LOCALE_HEADER; }
159
- });
160
88
  Object.defineProperty(exports, "applyCmssyCsp", {
161
89
  enumerable: true,
162
90
  get: function () { return core.applyCmssyCsp; }
163
91
  });
164
- Object.defineProperty(exports, "cmssyCspHeaders", {
165
- enumerable: true,
166
- get: function () { return core.cmssyCspHeaders; }
167
- });
168
- Object.defineProperty(exports, "localeForPathname", {
169
- enumerable: true,
170
- get: function () { return core.localeForPathname; }
171
- });
172
92
  exports.CMSSY_EDIT_PATH_PREFIX = CMSSY_EDIT_PATH_PREFIX;
173
93
  exports.cmssyEditRewrite = cmssyEditRewrite;
174
94
  exports.cmssyProxyMatcher = cmssyProxyMatcher;
175
- exports.createCmssyAuthMiddleware = createCmssyAuthMiddleware;
176
95
  exports.createCmssyEditMiddleware = createCmssyEditMiddleware;
177
- exports.createCmssyLocaleMiddleware = createCmssyLocaleMiddleware;
178
96
  exports.createCmssyProxy = createCmssyProxy;
179
97
  exports.isCmssyEditRequest = isCmssyEditRequest;
180
- exports.resolveLocaleFromPathname = resolveLocaleFromPathname;
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
  import { CmssyConfig } from '@cmssy/core';
3
- export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CmssyCspOptions, applyCmssyCsp, cmssyCspHeaders, localeForPathname } from '@cmssy/core';
3
+ export { CMSSY_EDIT_HEADER, CmssyCspOptions, applyCmssyCsp } from '@cmssy/core';
4
4
 
5
5
  interface CmssyProxyOptions {
6
6
  /**
@@ -72,21 +72,6 @@ declare function createCmssyEditMiddleware(config: {
72
72
  draftSecret: string;
73
73
  }): (request: NextRequest) => Promise<NextResponse>;
74
74
 
75
- /**
76
- * Resolves the active locale from a pathname's leading segment, against the
77
- * workspace locales (fetched, cached 60s).
78
- */
79
- declare function resolveLocaleFromPathname(config: CmssyConfig, pathname: string): Promise<string>;
80
- /**
81
- * Middleware that derives the locale from the URL path prefix and forwards it as
82
- * the `x-cmssy-locale` request header, so server components that can't read the
83
- * path (root layout) resolve the right locale via `getCmssyLocale`.
84
- */
85
- declare function createCmssyLocaleMiddleware(config: CmssyConfig): (request: NextRequest) => Promise<NextResponse>;
86
-
87
- type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
88
- declare function createCmssyAuthMiddleware(config: CmssyConfig): CmssyAuthMiddleware;
89
-
90
75
  interface EditRequestLike {
91
76
  cookies: {
92
77
  has: (name: string) => boolean;
@@ -102,4 +87,4 @@ declare function isCmssyEditRequest(request: EditRequestLike, config: {
102
87
  draftSecret: string;
103
88
  }): Promise<boolean>;
104
89
 
105
- export { CMSSY_EDIT_PATH_PREFIX, type CmssyAuthMiddleware, type CmssyProxyOptions, cmssyEditRewrite, cmssyProxyMatcher, createCmssyAuthMiddleware, createCmssyEditMiddleware, createCmssyLocaleMiddleware, createCmssyProxy, isCmssyEditRequest, resolveLocaleFromPathname };
90
+ export { CMSSY_EDIT_PATH_PREFIX, type CmssyProxyOptions, cmssyEditRewrite, cmssyProxyMatcher, createCmssyEditMiddleware, createCmssyProxy, isCmssyEditRequest };
@@ -1,6 +1,6 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
2
  import { CmssyConfig } from '@cmssy/core';
3
- export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CmssyCspOptions, applyCmssyCsp, cmssyCspHeaders, localeForPathname } from '@cmssy/core';
3
+ export { CMSSY_EDIT_HEADER, CmssyCspOptions, applyCmssyCsp } from '@cmssy/core';
4
4
 
5
5
  interface CmssyProxyOptions {
6
6
  /**
@@ -72,21 +72,6 @@ declare function createCmssyEditMiddleware(config: {
72
72
  draftSecret: string;
73
73
  }): (request: NextRequest) => Promise<NextResponse>;
74
74
 
75
- /**
76
- * Resolves the active locale from a pathname's leading segment, against the
77
- * workspace locales (fetched, cached 60s).
78
- */
79
- declare function resolveLocaleFromPathname(config: CmssyConfig, pathname: string): Promise<string>;
80
- /**
81
- * Middleware that derives the locale from the URL path prefix and forwards it as
82
- * the `x-cmssy-locale` request header, so server components that can't read the
83
- * path (root layout) resolve the right locale via `getCmssyLocale`.
84
- */
85
- declare function createCmssyLocaleMiddleware(config: CmssyConfig): (request: NextRequest) => Promise<NextResponse>;
86
-
87
- type CmssyAuthMiddleware = (request: NextRequest) => Promise<NextResponse>;
88
- declare function createCmssyAuthMiddleware(config: CmssyConfig): CmssyAuthMiddleware;
89
-
90
75
  interface EditRequestLike {
91
76
  cookies: {
92
77
  has: (name: string) => boolean;
@@ -102,4 +87,4 @@ declare function isCmssyEditRequest(request: EditRequestLike, config: {
102
87
  draftSecret: string;
103
88
  }): Promise<boolean>;
104
89
 
105
- export { CMSSY_EDIT_PATH_PREFIX, type CmssyAuthMiddleware, type CmssyProxyOptions, cmssyEditRewrite, cmssyProxyMatcher, createCmssyAuthMiddleware, createCmssyEditMiddleware, createCmssyLocaleMiddleware, createCmssyProxy, isCmssyEditRequest, resolveLocaleFromPathname };
90
+ export { CMSSY_EDIT_PATH_PREFIX, type CmssyProxyOptions, cmssyEditRewrite, cmssyProxyMatcher, createCmssyEditMiddleware, createCmssyProxy, isCmssyEditRequest };
@@ -1,7 +1,8 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { resolveSiteLocales, splitLocaleFromPath } from '@cmssy/react';
3
- import { CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, cmssySecretsMatch, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, localeForPathname, applyCmssyCsp, assertAuthConfig, CMSSY_SESSION_COOKIE, openSession, sessionCookieOptions, isAccessExpired, backendRefresh, toSessionPayload, sealSession, isVerifiedEditUrl } from '@cmssy/core';
4
- export { CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, applyCmssyCsp, cmssyCspHeaders, localeForPathname } from '@cmssy/core';
2
+ import { CMSSY_LOCALE_HEADER, localeForPathname, resolveSiteLocales } from '@cmssy/core/internal/locale';
3
+ import { CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CMSSY_EDIT_HEADER, applyCmssyCsp, isVerifiedEditUrl } from '@cmssy/core';
4
+ export { CMSSY_EDIT_HEADER, applyCmssyCsp } from '@cmssy/core';
5
+ import { cmssySecretsMatch } from '@cmssy/core/internal';
5
6
 
6
7
  // src/preset/proxy.ts
7
8
  var CMSSY_EDIT_PATH_PREFIX = "/cmssy-edit";
@@ -74,78 +75,9 @@ function createCmssyProxy(config, options = {}) {
74
75
  };
75
76
  }
76
77
  var cmssyProxyMatcher = ["/((?!_next/|api/|.*\\..*).*)"];
77
- async function resolveLocaleFromPathname(config, pathname) {
78
- const segments = pathname.split("/").filter(Boolean);
79
- const siteLocales = await resolveSiteLocales({
80
- apiUrl: config.apiUrl,
81
- org: config.org,
82
- workspaceSlug: config.workspaceSlug
83
- });
84
- return splitLocaleFromPath(segments, siteLocales).locale;
85
- }
86
- function createCmssyLocaleMiddleware(config) {
87
- return async function cmssyLocaleMiddleware(request) {
88
- const locale = await resolveLocaleFromPathname(
89
- config,
90
- request.nextUrl.pathname
91
- );
92
- const headers = new Headers(request.headers);
93
- headers.set(CMSSY_LOCALE_HEADER, locale);
94
- return NextResponse.next({ request: { headers } });
95
- };
96
- }
97
- function isPrefetch(request) {
98
- return request.headers.get("next-router-prefetch") !== null || request.headers.get("purpose") === "prefetch" || (request.headers.get("sec-purpose") ?? "").includes("prefetch");
99
- }
100
- function createCmssyAuthMiddleware(config) {
101
- const auth = assertAuthConfig(config);
102
- return async function cmssyAuthMiddleware(request) {
103
- const raw = request.cookies.get(CMSSY_SESSION_COOKIE)?.value;
104
- if (!raw) return NextResponse.next();
105
- const session = await openSession(
106
- raw,
107
- auth.sessionSecret,
108
- config.workspaceSlug
109
- );
110
- if (!session) {
111
- const response = NextResponse.next();
112
- response.cookies.set(CMSSY_SESSION_COOKIE, "", {
113
- ...sessionCookieOptions(),
114
- maxAge: 0
115
- });
116
- return response;
117
- }
118
- if (!isAccessExpired(session)) return NextResponse.next();
119
- if (isPrefetch(request)) return NextResponse.next();
120
- let payload = null;
121
- try {
122
- const result = await backendRefresh(config, session.refreshToken);
123
- payload = toSessionPayload(result);
124
- } catch {
125
- return NextResponse.next();
126
- }
127
- if (!payload) {
128
- const cleared = NextResponse.next();
129
- cleared.cookies.set(CMSSY_SESSION_COOKIE, "", {
130
- ...sessionCookieOptions(),
131
- maxAge: 0
132
- });
133
- return cleared;
134
- }
135
- const sealed = await sealSession(
136
- payload,
137
- auth.sessionSecret,
138
- config.workspaceSlug
139
- );
140
- request.cookies.set(CMSSY_SESSION_COOKIE, sealed);
141
- const refreshed = NextResponse.next({ request });
142
- refreshed.cookies.set(CMSSY_SESSION_COOKIE, sealed, sessionCookieOptions());
143
- return refreshed;
144
- };
145
- }
146
78
  async function isCmssyEditRequest(request, config) {
147
79
  if (request.cookies.has("__prerender_bypass")) return true;
148
80
  return isVerifiedEditUrl(request.nextUrl, config);
149
81
  }
150
82
 
151
- export { CMSSY_EDIT_PATH_PREFIX, cmssyEditRewrite, cmssyProxyMatcher, createCmssyAuthMiddleware, createCmssyEditMiddleware, createCmssyLocaleMiddleware, createCmssyProxy, isCmssyEditRequest, resolveLocaleFromPathname };
83
+ export { CMSSY_EDIT_PATH_PREFIX, cmssyEditRewrite, cmssyProxyMatcher, createCmssyEditMiddleware, createCmssyProxy, isCmssyEditRequest };