feat(blog): add file-based blog with dynamic slugs, MDX content and layout shell
- Introduced blog routing using Next.js App Router - Implemented dynamic [slug] pages for blog posts - Added MDX-based content loading via lib/posts - Integrated shared TopBar layout with navigation - Established clear content, lib and component separation
This commit is contained in:
8
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.d.ts
generated
vendored
Normal file
8
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { NextApiRequestCookies } from '.';
|
||||
/**
|
||||
* Parse cookies from the `headers` of request
|
||||
* @param req request object
|
||||
*/
|
||||
export declare function getCookieParser(headers: {
|
||||
[key: string]: string | string[] | null | undefined;
|
||||
}): () => NextApiRequestCookies;
|
||||
22
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.js
generated
vendored
Normal file
22
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "getCookieParser", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return getCookieParser;
|
||||
}
|
||||
});
|
||||
function getCookieParser(headers) {
|
||||
return function parseCookie() {
|
||||
const { cookie } = headers;
|
||||
if (!cookie) {
|
||||
return {};
|
||||
}
|
||||
const { parse: parseCookieFn } = require('next/dist/compiled/cookie');
|
||||
return parseCookieFn(Array.isArray(cookie) ? cookie.join('; ') : cookie);
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-cookie-parser.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/get-cookie-parser.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/api-utils/get-cookie-parser.ts"],"sourcesContent":["import type { NextApiRequestCookies } from '.'\n\n/**\n * Parse cookies from the `headers` of request\n * @param req request object\n */\n\nexport function getCookieParser(headers: {\n [key: string]: string | string[] | null | undefined\n}): () => NextApiRequestCookies {\n return function parseCookie(): NextApiRequestCookies {\n const { cookie } = headers\n\n if (!cookie) {\n return {}\n }\n\n const { parse: parseCookieFn } =\n require('next/dist/compiled/cookie') as typeof import('next/dist/compiled/cookie')\n return parseCookieFn(Array.isArray(cookie) ? cookie.join('; ') : cookie)\n }\n}\n"],"names":["getCookieParser","headers","parseCookie","cookie","parse","parseCookieFn","require","Array","isArray","join"],"mappings":";;;;+BAOgBA;;;eAAAA;;;AAAT,SAASA,gBAAgBC,OAE/B;IACC,OAAO,SAASC;QACd,MAAM,EAAEC,MAAM,EAAE,GAAGF;QAEnB,IAAI,CAACE,QAAQ;YACX,OAAO,CAAC;QACV;QAEA,MAAM,EAAEC,OAAOC,aAAa,EAAE,GAC5BC,QAAQ;QACV,OAAOD,cAAcE,MAAMC,OAAO,CAACL,UAAUA,OAAOM,IAAI,CAAC,QAAQN;IACnE;AACF","ignoreList":[0]}
|
||||
65
apps/public-web/node_modules/next/dist/server/api-utils/index.d.ts
generated
vendored
Normal file
65
apps/public-web/node_modules/next/dist/server/api-utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import type { IncomingMessage } from 'http';
|
||||
import type { BaseNextRequest } from '../base-http';
|
||||
import type { NextApiResponse } from '../../shared/lib/utils';
|
||||
export type NextApiRequestCookies = Partial<{
|
||||
[key: string]: string;
|
||||
}>;
|
||||
export type NextApiRequestQuery = Partial<{
|
||||
[key: string]: string | string[];
|
||||
}>;
|
||||
export type __ApiPreviewProps = {
|
||||
previewModeId: string;
|
||||
previewModeEncryptionKey: string;
|
||||
previewModeSigningKey: string;
|
||||
};
|
||||
export declare function wrapApiHandler<T extends (...args: any[]) => any>(page: string, handler: T): T;
|
||||
/**
|
||||
*
|
||||
* @param res response object
|
||||
* @param statusCode `HTTP` status code of response
|
||||
*/
|
||||
export declare function sendStatusCode(res: NextApiResponse, statusCode: number): NextApiResponse<any>;
|
||||
/**
|
||||
*
|
||||
* @param res response object
|
||||
* @param [statusOrUrl] `HTTP` status code of redirect
|
||||
* @param url URL of redirect
|
||||
*/
|
||||
export declare function redirect(res: NextApiResponse, statusOrUrl: string | number, url?: string): NextApiResponse<any>;
|
||||
export declare function checkIsOnDemandRevalidate(req: Request | IncomingMessage | BaseNextRequest, previewProps: __ApiPreviewProps): {
|
||||
isOnDemandRevalidate: boolean;
|
||||
revalidateOnlyGenerated: boolean;
|
||||
};
|
||||
export declare const COOKIE_NAME_PRERENDER_BYPASS = "__prerender_bypass";
|
||||
export declare const COOKIE_NAME_PRERENDER_DATA = "__next_preview_data";
|
||||
export declare const RESPONSE_LIMIT_DEFAULT: number;
|
||||
export declare const SYMBOL_PREVIEW_DATA: unique symbol;
|
||||
export declare const SYMBOL_CLEARED_COOKIES: unique symbol;
|
||||
export declare function clearPreviewData<T>(res: NextApiResponse<T>, options?: {
|
||||
path?: string;
|
||||
}): NextApiResponse<T>;
|
||||
/**
|
||||
* Custom error class
|
||||
*/
|
||||
export declare class ApiError extends Error {
|
||||
readonly statusCode: number;
|
||||
constructor(statusCode: number, message: string);
|
||||
}
|
||||
/**
|
||||
* Sends error in `response`
|
||||
* @param res response object
|
||||
* @param statusCode of response
|
||||
* @param message of response
|
||||
*/
|
||||
export declare function sendError(res: NextApiResponse, statusCode: number, message: string): void;
|
||||
interface LazyProps {
|
||||
req: IncomingMessage;
|
||||
}
|
||||
/**
|
||||
* Execute getter function only if its needed
|
||||
* @param LazyProps `req` and `params` for lazyProp
|
||||
* @param prop name of property
|
||||
* @param getter function to get data
|
||||
*/
|
||||
export declare function setLazyProp<T>({ req }: LazyProps, prop: string, getter: () => T): void;
|
||||
export {};
|
||||
201
apps/public-web/node_modules/next/dist/server/api-utils/index.js
generated
vendored
Normal file
201
apps/public-web/node_modules/next/dist/server/api-utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
ApiError: null,
|
||||
COOKIE_NAME_PRERENDER_BYPASS: null,
|
||||
COOKIE_NAME_PRERENDER_DATA: null,
|
||||
RESPONSE_LIMIT_DEFAULT: null,
|
||||
SYMBOL_CLEARED_COOKIES: null,
|
||||
SYMBOL_PREVIEW_DATA: null,
|
||||
checkIsOnDemandRevalidate: null,
|
||||
clearPreviewData: null,
|
||||
redirect: null,
|
||||
sendError: null,
|
||||
sendStatusCode: null,
|
||||
setLazyProp: null,
|
||||
wrapApiHandler: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
ApiError: function() {
|
||||
return ApiError;
|
||||
},
|
||||
COOKIE_NAME_PRERENDER_BYPASS: function() {
|
||||
return COOKIE_NAME_PRERENDER_BYPASS;
|
||||
},
|
||||
COOKIE_NAME_PRERENDER_DATA: function() {
|
||||
return COOKIE_NAME_PRERENDER_DATA;
|
||||
},
|
||||
RESPONSE_LIMIT_DEFAULT: function() {
|
||||
return RESPONSE_LIMIT_DEFAULT;
|
||||
},
|
||||
SYMBOL_CLEARED_COOKIES: function() {
|
||||
return SYMBOL_CLEARED_COOKIES;
|
||||
},
|
||||
SYMBOL_PREVIEW_DATA: function() {
|
||||
return SYMBOL_PREVIEW_DATA;
|
||||
},
|
||||
checkIsOnDemandRevalidate: function() {
|
||||
return checkIsOnDemandRevalidate;
|
||||
},
|
||||
clearPreviewData: function() {
|
||||
return clearPreviewData;
|
||||
},
|
||||
redirect: function() {
|
||||
return redirect;
|
||||
},
|
||||
sendError: function() {
|
||||
return sendError;
|
||||
},
|
||||
sendStatusCode: function() {
|
||||
return sendStatusCode;
|
||||
},
|
||||
setLazyProp: function() {
|
||||
return setLazyProp;
|
||||
},
|
||||
wrapApiHandler: function() {
|
||||
return wrapApiHandler;
|
||||
}
|
||||
});
|
||||
const _headers = require("../web/spec-extension/adapters/headers");
|
||||
const _constants = require("../../lib/constants");
|
||||
const _tracer = require("../lib/trace/tracer");
|
||||
const _constants1 = require("../lib/trace/constants");
|
||||
function wrapApiHandler(page, handler) {
|
||||
return (...args)=>{
|
||||
(0, _tracer.getTracer)().setRootSpanAttribute('next.route', page);
|
||||
// Call API route method
|
||||
return (0, _tracer.getTracer)().trace(_constants1.NodeSpan.runHandler, {
|
||||
spanName: `executing api route (pages) ${page}`
|
||||
}, ()=>handler(...args));
|
||||
};
|
||||
}
|
||||
function sendStatusCode(res, statusCode) {
|
||||
res.statusCode = statusCode;
|
||||
return res;
|
||||
}
|
||||
function redirect(res, statusOrUrl, url) {
|
||||
if (typeof statusOrUrl === 'string') {
|
||||
url = statusOrUrl;
|
||||
statusOrUrl = 307;
|
||||
}
|
||||
if (typeof statusOrUrl !== 'number' || typeof url !== 'string') {
|
||||
throw Object.defineProperty(new Error(`Invalid redirect arguments. Please use a single argument URL, e.g. res.redirect('/destination') or use a status code and URL, e.g. res.redirect(307, '/destination').`), "__NEXT_ERROR_CODE", {
|
||||
value: "E389",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
res.writeHead(statusOrUrl, {
|
||||
Location: url
|
||||
});
|
||||
res.write(url);
|
||||
res.end();
|
||||
return res;
|
||||
}
|
||||
function checkIsOnDemandRevalidate(req, previewProps) {
|
||||
const headers = _headers.HeadersAdapter.from(req.headers);
|
||||
const previewModeId = headers.get(_constants.PRERENDER_REVALIDATE_HEADER);
|
||||
const isOnDemandRevalidate = previewModeId === previewProps.previewModeId;
|
||||
const revalidateOnlyGenerated = headers.has(_constants.PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER);
|
||||
return {
|
||||
isOnDemandRevalidate,
|
||||
revalidateOnlyGenerated
|
||||
};
|
||||
}
|
||||
const COOKIE_NAME_PRERENDER_BYPASS = `__prerender_bypass`;
|
||||
const COOKIE_NAME_PRERENDER_DATA = `__next_preview_data`;
|
||||
const RESPONSE_LIMIT_DEFAULT = 4 * 1024 * 1024;
|
||||
const SYMBOL_PREVIEW_DATA = Symbol(COOKIE_NAME_PRERENDER_DATA);
|
||||
const SYMBOL_CLEARED_COOKIES = Symbol(COOKIE_NAME_PRERENDER_BYPASS);
|
||||
function clearPreviewData(res, options = {}) {
|
||||
if (SYMBOL_CLEARED_COOKIES in res) {
|
||||
return res;
|
||||
}
|
||||
const { serialize } = require('next/dist/compiled/cookie');
|
||||
const previous = res.getHeader('Set-Cookie');
|
||||
res.setHeader(`Set-Cookie`, [
|
||||
...typeof previous === 'string' ? [
|
||||
previous
|
||||
] : Array.isArray(previous) ? previous : [],
|
||||
serialize(COOKIE_NAME_PRERENDER_BYPASS, '', {
|
||||
// To delete a cookie, set `expires` to a date in the past:
|
||||
// https://tools.ietf.org/html/rfc6265#section-4.1.1
|
||||
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
|
||||
expires: new Date(0),
|
||||
httpOnly: true,
|
||||
sameSite: process.env.NODE_ENV !== 'development' ? 'none' : 'lax',
|
||||
secure: process.env.NODE_ENV !== 'development',
|
||||
path: '/',
|
||||
...options.path !== undefined ? {
|
||||
path: options.path
|
||||
} : undefined
|
||||
}),
|
||||
serialize(COOKIE_NAME_PRERENDER_DATA, '', {
|
||||
// To delete a cookie, set `expires` to a date in the past:
|
||||
// https://tools.ietf.org/html/rfc6265#section-4.1.1
|
||||
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
|
||||
expires: new Date(0),
|
||||
httpOnly: true,
|
||||
sameSite: process.env.NODE_ENV !== 'development' ? 'none' : 'lax',
|
||||
secure: process.env.NODE_ENV !== 'development',
|
||||
path: '/',
|
||||
...options.path !== undefined ? {
|
||||
path: options.path
|
||||
} : undefined
|
||||
})
|
||||
]);
|
||||
Object.defineProperty(res, SYMBOL_CLEARED_COOKIES, {
|
||||
value: true,
|
||||
enumerable: false
|
||||
});
|
||||
return res;
|
||||
}
|
||||
class ApiError extends Error {
|
||||
constructor(statusCode, message){
|
||||
super(message);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
function sendError(res, statusCode, message) {
|
||||
res.statusCode = statusCode;
|
||||
res.statusMessage = message;
|
||||
res.end(message);
|
||||
}
|
||||
function setLazyProp({ req }, prop, getter) {
|
||||
const opts = {
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
};
|
||||
const optsReset = {
|
||||
...opts,
|
||||
writable: true
|
||||
};
|
||||
Object.defineProperty(req, prop, {
|
||||
...opts,
|
||||
get: ()=>{
|
||||
const value = getter();
|
||||
// we set the property on the object to avoid recalculating it
|
||||
Object.defineProperty(req, prop, {
|
||||
...optsReset,
|
||||
value
|
||||
});
|
||||
return value;
|
||||
},
|
||||
set: (value)=>{
|
||||
Object.defineProperty(req, prop, {
|
||||
...optsReset,
|
||||
value
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/index.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.d.ts
generated
vendored
Normal file
14
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { __ApiPreviewProps } from '../.';
|
||||
import type { RevalidateFn } from '../../lib/router-utils/router-server-context';
|
||||
import type { InstrumentationOnRequestError } from '../../instrumentation/types';
|
||||
type ApiContext = __ApiPreviewProps & {
|
||||
trustHostHeader?: boolean;
|
||||
allowedRevalidateHeaderKeys?: string[];
|
||||
hostname?: string;
|
||||
multiZoneDraftMode?: boolean;
|
||||
dev: boolean;
|
||||
internalRevalidate?: RevalidateFn;
|
||||
};
|
||||
export declare function apiResolver(req: IncomingMessage, res: ServerResponse, query: any, resolverModule: any, apiContext: ApiContext, propagateError: boolean, dev?: boolean, page?: string, onError?: InstrumentationOnRequestError): Promise<void>;
|
||||
export {};
|
||||
395
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.js
generated
vendored
Normal file
395
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.js
generated
vendored
Normal file
@@ -0,0 +1,395 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "apiResolver", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return apiResolver;
|
||||
}
|
||||
});
|
||||
const _bytes = /*#__PURE__*/ _interop_require_default(require("next/dist/compiled/bytes"));
|
||||
const _etag = require("../../lib/etag");
|
||||
const _sendpayload = require("../../send-payload");
|
||||
const _stream = require("stream");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../lib/is-error"));
|
||||
const _utils = require("../../../shared/lib/utils");
|
||||
const _interopdefault = require("../../../lib/interop-default");
|
||||
const _index = require("./../index");
|
||||
const _getcookieparser = require("./../get-cookie-parser");
|
||||
const _constants = require("../../../lib/constants");
|
||||
const _trygetpreviewdata = require("./try-get-preview-data");
|
||||
const _parsebody = require("./parse-body");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function getMaxContentLength(responseLimit) {
|
||||
if (responseLimit && typeof responseLimit !== 'boolean') {
|
||||
return _bytes.default.parse(responseLimit);
|
||||
}
|
||||
return _index.RESPONSE_LIMIT_DEFAULT;
|
||||
}
|
||||
/**
|
||||
* Send `any` body to response
|
||||
* @param req request object
|
||||
* @param res response object
|
||||
* @param body of response
|
||||
*/ function sendData(req, res, body) {
|
||||
if (body === null || body === undefined) {
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
// strip irrelevant headers/body
|
||||
if (res.statusCode === 204 || res.statusCode === 304) {
|
||||
res.removeHeader('Content-Type');
|
||||
res.removeHeader('Content-Length');
|
||||
res.removeHeader('Transfer-Encoding');
|
||||
if (process.env.NODE_ENV === 'development' && body) {
|
||||
console.warn(`A body was attempted to be set with a 204 statusCode for ${req.url}, this is invalid and the body was ignored.\n` + `See more info here https://nextjs.org/docs/messages/invalid-api-status-body`);
|
||||
}
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
const contentType = res.getHeader('Content-Type');
|
||||
if (body instanceof _stream.Stream) {
|
||||
if (!contentType) {
|
||||
res.setHeader('Content-Type', 'application/octet-stream');
|
||||
}
|
||||
body.pipe(res);
|
||||
return;
|
||||
}
|
||||
const isJSONLike = [
|
||||
'object',
|
||||
'number',
|
||||
'boolean'
|
||||
].includes(typeof body);
|
||||
const stringifiedBody = isJSONLike ? JSON.stringify(body) : body;
|
||||
const etag = (0, _etag.generateETag)(stringifiedBody);
|
||||
if ((0, _sendpayload.sendEtagResponse)(req, res, etag)) {
|
||||
return;
|
||||
}
|
||||
if (Buffer.isBuffer(body)) {
|
||||
if (!contentType) {
|
||||
res.setHeader('Content-Type', 'application/octet-stream');
|
||||
}
|
||||
res.setHeader('Content-Length', body.length);
|
||||
res.end(body);
|
||||
return;
|
||||
}
|
||||
if (isJSONLike) {
|
||||
res.setHeader('Content-Type', _constants.JSON_CONTENT_TYPE_HEADER);
|
||||
}
|
||||
res.setHeader('Content-Length', Buffer.byteLength(stringifiedBody));
|
||||
res.end(stringifiedBody);
|
||||
}
|
||||
/**
|
||||
* Send `JSON` object
|
||||
* @param res response object
|
||||
* @param jsonBody of data
|
||||
*/ function sendJson(res, jsonBody) {
|
||||
// Set header to application/json
|
||||
res.setHeader('Content-Type', _constants.JSON_CONTENT_TYPE_HEADER);
|
||||
// Use send to handle request
|
||||
res.send(JSON.stringify(jsonBody));
|
||||
}
|
||||
function isValidData(str) {
|
||||
return typeof str === 'string' && str.length >= 16;
|
||||
}
|
||||
function setDraftMode(res, options) {
|
||||
if (!isValidData(options.previewModeId)) {
|
||||
throw Object.defineProperty(new Error('invariant: invalid previewModeId'), "__NEXT_ERROR_CODE", {
|
||||
value: "E169",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const expires = options.enable ? undefined : new Date(0);
|
||||
// To delete a cookie, set `expires` to a date in the past:
|
||||
// https://tools.ietf.org/html/rfc6265#section-4.1.1
|
||||
// `Max-Age: 0` is not valid, thus ignored, and the cookie is persisted.
|
||||
const { serialize } = require('next/dist/compiled/cookie');
|
||||
const previous = res.getHeader('Set-Cookie');
|
||||
res.setHeader(`Set-Cookie`, [
|
||||
...typeof previous === 'string' ? [
|
||||
previous
|
||||
] : Array.isArray(previous) ? previous : [],
|
||||
serialize(_index.COOKIE_NAME_PRERENDER_BYPASS, options.previewModeId, {
|
||||
httpOnly: true,
|
||||
sameSite: process.env.NODE_ENV !== 'development' ? 'none' : 'lax',
|
||||
secure: process.env.NODE_ENV !== 'development',
|
||||
path: '/',
|
||||
expires
|
||||
})
|
||||
]);
|
||||
return res;
|
||||
}
|
||||
function setPreviewData(res, data, options) {
|
||||
if (!isValidData(options.previewModeId)) {
|
||||
throw Object.defineProperty(new Error('invariant: invalid previewModeId'), "__NEXT_ERROR_CODE", {
|
||||
value: "E169",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (!isValidData(options.previewModeEncryptionKey)) {
|
||||
throw Object.defineProperty(new Error('invariant: invalid previewModeEncryptionKey'), "__NEXT_ERROR_CODE", {
|
||||
value: "E334",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (!isValidData(options.previewModeSigningKey)) {
|
||||
throw Object.defineProperty(new Error('invariant: invalid previewModeSigningKey'), "__NEXT_ERROR_CODE", {
|
||||
value: "E436",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const jsonwebtoken = require('next/dist/compiled/jsonwebtoken');
|
||||
const { encryptWithSecret } = require('../../crypto-utils');
|
||||
const payload = jsonwebtoken.sign({
|
||||
data: encryptWithSecret(Buffer.from(options.previewModeEncryptionKey), JSON.stringify(data))
|
||||
}, options.previewModeSigningKey, {
|
||||
algorithm: 'HS256',
|
||||
...options.maxAge !== undefined ? {
|
||||
expiresIn: options.maxAge
|
||||
} : undefined
|
||||
});
|
||||
// limit preview mode cookie to 2KB since we shouldn't store too much
|
||||
// data here and browsers drop cookies over 4KB
|
||||
if (payload.length > 2048) {
|
||||
throw Object.defineProperty(new Error(`Preview data is limited to 2KB currently, reduce how much data you are storing as preview data to continue`), "__NEXT_ERROR_CODE", {
|
||||
value: "E465",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const { serialize } = require('next/dist/compiled/cookie');
|
||||
const previous = res.getHeader('Set-Cookie');
|
||||
res.setHeader(`Set-Cookie`, [
|
||||
...typeof previous === 'string' ? [
|
||||
previous
|
||||
] : Array.isArray(previous) ? previous : [],
|
||||
serialize(_index.COOKIE_NAME_PRERENDER_BYPASS, options.previewModeId, {
|
||||
httpOnly: true,
|
||||
sameSite: process.env.NODE_ENV !== 'development' ? 'none' : 'lax',
|
||||
secure: process.env.NODE_ENV !== 'development',
|
||||
path: '/',
|
||||
...options.maxAge !== undefined ? {
|
||||
maxAge: options.maxAge
|
||||
} : undefined,
|
||||
...options.path !== undefined ? {
|
||||
path: options.path
|
||||
} : undefined
|
||||
}),
|
||||
serialize(_index.COOKIE_NAME_PRERENDER_DATA, payload, {
|
||||
httpOnly: true,
|
||||
sameSite: process.env.NODE_ENV !== 'development' ? 'none' : 'lax',
|
||||
secure: process.env.NODE_ENV !== 'development',
|
||||
path: '/',
|
||||
...options.maxAge !== undefined ? {
|
||||
maxAge: options.maxAge
|
||||
} : undefined,
|
||||
...options.path !== undefined ? {
|
||||
path: options.path
|
||||
} : undefined
|
||||
})
|
||||
]);
|
||||
return res;
|
||||
}
|
||||
async function revalidate(urlPath, opts, req, context) {
|
||||
if (typeof urlPath !== 'string' || !urlPath.startsWith('/')) {
|
||||
throw Object.defineProperty(new Error(`Invalid urlPath provided to revalidate(), must be a path e.g. /blog/post-1, received ${urlPath}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E153",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const revalidateHeaders = {
|
||||
[_constants.PRERENDER_REVALIDATE_HEADER]: context.previewModeId,
|
||||
...opts.unstable_onlyGenerated ? {
|
||||
[_constants.PRERENDER_REVALIDATE_ONLY_GENERATED_HEADER]: '1'
|
||||
} : {}
|
||||
};
|
||||
const allowedRevalidateHeaderKeys = [
|
||||
...context.allowedRevalidateHeaderKeys || []
|
||||
];
|
||||
if (context.trustHostHeader || context.dev) {
|
||||
allowedRevalidateHeaderKeys.push('cookie');
|
||||
}
|
||||
if (context.trustHostHeader) {
|
||||
allowedRevalidateHeaderKeys.push('x-vercel-protection-bypass');
|
||||
}
|
||||
for (const key of Object.keys(req.headers)){
|
||||
if (allowedRevalidateHeaderKeys.includes(key)) {
|
||||
revalidateHeaders[key] = req.headers[key];
|
||||
}
|
||||
}
|
||||
const internalRevalidate = context.internalRevalidate;
|
||||
try {
|
||||
// We use the revalidate in router-server if available.
|
||||
// If we are operating without router-server (serverless)
|
||||
// we must go through network layer with fetch request
|
||||
if (internalRevalidate) {
|
||||
return await internalRevalidate({
|
||||
urlPath,
|
||||
revalidateHeaders,
|
||||
opts
|
||||
});
|
||||
}
|
||||
if (context.trustHostHeader) {
|
||||
const res = await fetch(`https://${req.headers.host}${urlPath}`, {
|
||||
method: 'HEAD',
|
||||
headers: revalidateHeaders
|
||||
});
|
||||
// we use the cache header to determine successful revalidate as
|
||||
// a non-200 status code can be returned from a successful revalidate
|
||||
// e.g. notFound: true returns 404 status code but is successful
|
||||
const cacheHeader = res.headers.get('x-vercel-cache') || res.headers.get('x-nextjs-cache');
|
||||
if ((cacheHeader == null ? void 0 : cacheHeader.toUpperCase()) !== 'REVALIDATED' && res.status !== 200 && !(res.status === 404 && opts.unstable_onlyGenerated)) {
|
||||
throw Object.defineProperty(new Error(`Invalid response ${res.status}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E175",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw Object.defineProperty(new Error(`Invariant: missing internal router-server-methods this is an internal bug`), "__NEXT_ERROR_CODE", {
|
||||
value: "E676",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
throw Object.defineProperty(new Error(`Failed to revalidate ${urlPath}: ${(0, _iserror.default)(err) ? err.message : err}`), "__NEXT_ERROR_CODE", {
|
||||
value: "E240",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
async function apiResolver(req, res, query, resolverModule, apiContext, propagateError, dev, page, onError) {
|
||||
const apiReq = req;
|
||||
const apiRes = res;
|
||||
try {
|
||||
var _config_api, _config_api1, _config_api2;
|
||||
if (!resolverModule) {
|
||||
res.statusCode = 404;
|
||||
res.end('Not Found');
|
||||
return;
|
||||
}
|
||||
const config = resolverModule.config || {};
|
||||
const bodyParser = ((_config_api = config.api) == null ? void 0 : _config_api.bodyParser) !== false;
|
||||
const responseLimit = ((_config_api1 = config.api) == null ? void 0 : _config_api1.responseLimit) ?? true;
|
||||
const externalResolver = ((_config_api2 = config.api) == null ? void 0 : _config_api2.externalResolver) || false;
|
||||
// Parsing of cookies
|
||||
(0, _index.setLazyProp)({
|
||||
req: apiReq
|
||||
}, 'cookies', (0, _getcookieparser.getCookieParser)(req.headers));
|
||||
// Ensure req.query is a writable, enumerable property by using Object.defineProperty.
|
||||
// This addresses Express 5.x, which defines query as a getter only (read-only).
|
||||
Object.defineProperty(apiReq, 'query', {
|
||||
value: {
|
||||
...query
|
||||
},
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
// Parsing preview data
|
||||
(0, _index.setLazyProp)({
|
||||
req: apiReq
|
||||
}, 'previewData', ()=>(0, _trygetpreviewdata.tryGetPreviewData)(req, res, apiContext, !!apiContext.multiZoneDraftMode));
|
||||
// Checking if preview mode is enabled
|
||||
(0, _index.setLazyProp)({
|
||||
req: apiReq
|
||||
}, 'preview', ()=>apiReq.previewData !== false ? true : undefined);
|
||||
// Set draftMode to the same value as preview
|
||||
(0, _index.setLazyProp)({
|
||||
req: apiReq
|
||||
}, 'draftMode', ()=>apiReq.preview);
|
||||
// Parsing of body
|
||||
if (bodyParser && !apiReq.body) {
|
||||
apiReq.body = await (0, _parsebody.parseBody)(apiReq, config.api && config.api.bodyParser && config.api.bodyParser.sizeLimit ? config.api.bodyParser.sizeLimit : '1mb');
|
||||
}
|
||||
let contentLength = 0;
|
||||
const maxContentLength = getMaxContentLength(responseLimit);
|
||||
const writeData = apiRes.write;
|
||||
const endResponse = apiRes.end;
|
||||
apiRes.write = (...args)=>{
|
||||
contentLength += Buffer.byteLength(args[0] || '');
|
||||
return writeData.apply(apiRes, args);
|
||||
};
|
||||
apiRes.end = (...args)=>{
|
||||
if (args.length && typeof args[0] !== 'function') {
|
||||
contentLength += Buffer.byteLength(args[0] || '');
|
||||
}
|
||||
if (responseLimit && contentLength >= maxContentLength) {
|
||||
console.warn(`API response for ${req.url} exceeds ${_bytes.default.format(maxContentLength)}. API Routes are meant to respond quickly. https://nextjs.org/docs/messages/api-routes-response-size-limit`);
|
||||
}
|
||||
return endResponse.apply(apiRes, args);
|
||||
};
|
||||
apiRes.status = (statusCode)=>(0, _index.sendStatusCode)(apiRes, statusCode);
|
||||
apiRes.send = (data)=>sendData(apiReq, apiRes, data);
|
||||
apiRes.json = (data)=>sendJson(apiRes, data);
|
||||
apiRes.redirect = (statusOrUrl, url)=>(0, _index.redirect)(apiRes, statusOrUrl, url);
|
||||
apiRes.setDraftMode = (options = {
|
||||
enable: true
|
||||
})=>setDraftMode(apiRes, Object.assign({}, apiContext, options));
|
||||
apiRes.setPreviewData = (data, options = {})=>setPreviewData(apiRes, data, Object.assign({}, apiContext, options));
|
||||
apiRes.clearPreviewData = (options = {})=>(0, _index.clearPreviewData)(apiRes, options);
|
||||
apiRes.revalidate = (urlPath, opts)=>revalidate(urlPath, opts || {}, req, apiContext);
|
||||
const resolver = (0, _interopdefault.interopDefault)(resolverModule);
|
||||
let wasPiped = false;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// listen for pipe event and don't show resolve warning
|
||||
res.once('pipe', ()=>wasPiped = true);
|
||||
}
|
||||
const apiRouteResult = await resolver(req, res);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof apiRouteResult !== 'undefined') {
|
||||
if (apiRouteResult instanceof Response) {
|
||||
throw Object.defineProperty(new Error('API route returned a Response object in the Node.js runtime, this is not supported. Please use `runtime: "edge"` instead: https://nextjs.org/docs/api-routes/edge-api-routes'), "__NEXT_ERROR_CODE", {
|
||||
value: "E36",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
console.warn(`API handler should not return a value, received ${typeof apiRouteResult}.`);
|
||||
}
|
||||
if (!externalResolver && !(0, _utils.isResSent)(res) && !wasPiped) {
|
||||
console.warn(`API resolved without sending a response for ${req.url}, this may result in stalled requests.`);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
await (onError == null ? void 0 : onError(err, {
|
||||
method: req.method || 'GET',
|
||||
headers: req.headers,
|
||||
path: req.url || '/'
|
||||
}, {
|
||||
routerKind: 'Pages Router',
|
||||
routePath: page || '',
|
||||
routeType: 'route',
|
||||
revalidateReason: undefined
|
||||
}));
|
||||
if (err instanceof _index.ApiError) {
|
||||
(0, _index.sendError)(apiRes, err.statusCode, err.message);
|
||||
} else {
|
||||
if (dev) {
|
||||
if ((0, _iserror.default)(err)) {
|
||||
err.page = page;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
console.error(err);
|
||||
if (propagateError) {
|
||||
throw err;
|
||||
}
|
||||
(0, _index.sendError)(apiRes, 500, 'Internal Server Error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=api-resolver.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/node/api-resolver.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
7
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.d.ts
generated
vendored
Normal file
7
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { IncomingMessage } from 'http';
|
||||
import type { SizeLimit } from '../../../types';
|
||||
/**
|
||||
* Parse incoming message like `json` or `urlencoded`
|
||||
* @param req request object
|
||||
*/
|
||||
export declare function parseBody(req: IncomingMessage, limit: SizeLimit): Promise<any>;
|
||||
79
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.js
generated
vendored
Normal file
79
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseBody", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return parseBody;
|
||||
}
|
||||
});
|
||||
const _contenttype = require("next/dist/compiled/content-type");
|
||||
const _iserror = /*#__PURE__*/ _interop_require_default(require("../../../lib/is-error"));
|
||||
const _index = require("../index");
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Parse `JSON` and handles invalid `JSON` strings
|
||||
* @param str `JSON` string
|
||||
*/ function parseJson(str) {
|
||||
if (str.length === 0) {
|
||||
// special-case empty json body, as it's a common client-side mistake
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch (e) {
|
||||
throw Object.defineProperty(new _index.ApiError(400, 'Invalid JSON'), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
async function parseBody(req, limit) {
|
||||
let contentType;
|
||||
try {
|
||||
contentType = (0, _contenttype.parse)(req.headers['content-type'] || 'text/plain');
|
||||
} catch {
|
||||
contentType = (0, _contenttype.parse)('text/plain');
|
||||
}
|
||||
const { type, parameters } = contentType;
|
||||
const encoding = parameters.charset || 'utf-8';
|
||||
let buffer;
|
||||
try {
|
||||
const getRawBody = require('next/dist/compiled/raw-body');
|
||||
buffer = await getRawBody(req, {
|
||||
encoding,
|
||||
limit
|
||||
});
|
||||
} catch (e) {
|
||||
if ((0, _iserror.default)(e) && e.type === 'entity.too.large') {
|
||||
throw Object.defineProperty(new _index.ApiError(413, `Body exceeded ${limit} limit`), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else {
|
||||
throw Object.defineProperty(new _index.ApiError(400, 'Invalid body'), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
const body = buffer.toString();
|
||||
if (type === 'application/json' || type === 'application/ld+json') {
|
||||
return parseJson(body);
|
||||
} else if (type === 'application/x-www-form-urlencoded') {
|
||||
const qs = require('querystring');
|
||||
return qs.decode(body);
|
||||
} else {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-body.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/node/parse-body.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/server/api-utils/node/parse-body.ts"],"sourcesContent":["import type { IncomingMessage } from 'http'\n\nimport { parse } from 'next/dist/compiled/content-type'\nimport isError from '../../../lib/is-error'\nimport type { SizeLimit } from '../../../types'\nimport { ApiError } from '../index'\n\n/**\n * Parse `JSON` and handles invalid `JSON` strings\n * @param str `JSON` string\n */\nfunction parseJson(str: string): object {\n if (str.length === 0) {\n // special-case empty json body, as it's a common client-side mistake\n return {}\n }\n\n try {\n return JSON.parse(str)\n } catch (e) {\n throw new ApiError(400, 'Invalid JSON')\n }\n}\n\n/**\n * Parse incoming message like `json` or `urlencoded`\n * @param req request object\n */\nexport async function parseBody(\n req: IncomingMessage,\n limit: SizeLimit\n): Promise<any> {\n let contentType\n try {\n contentType = parse(req.headers['content-type'] || 'text/plain')\n } catch {\n contentType = parse('text/plain')\n }\n const { type, parameters } = contentType\n const encoding = parameters.charset || 'utf-8'\n\n let buffer\n\n try {\n const getRawBody =\n require('next/dist/compiled/raw-body') as typeof import('next/dist/compiled/raw-body')\n buffer = await getRawBody(req, { encoding, limit })\n } catch (e) {\n if (isError(e) && e.type === 'entity.too.large') {\n throw new ApiError(413, `Body exceeded ${limit} limit`)\n } else {\n throw new ApiError(400, 'Invalid body')\n }\n }\n\n const body = buffer.toString()\n\n if (type === 'application/json' || type === 'application/ld+json') {\n return parseJson(body)\n } else if (type === 'application/x-www-form-urlencoded') {\n const qs = require('querystring') as typeof import('querystring')\n return qs.decode(body)\n } else {\n return body\n }\n}\n"],"names":["parseBody","parseJson","str","length","JSON","parse","e","ApiError","req","limit","contentType","headers","type","parameters","encoding","charset","buffer","getRawBody","require","isError","body","toString","qs","decode"],"mappings":";;;;+BA4BsBA;;;eAAAA;;;6BA1BA;gEACF;uBAEK;;;;;;AAEzB;;;CAGC,GACD,SAASC,UAAUC,GAAW;IAC5B,IAAIA,IAAIC,MAAM,KAAK,GAAG;QACpB,qEAAqE;QACrE,OAAO,CAAC;IACV;IAEA,IAAI;QACF,OAAOC,KAAKC,KAAK,CAACH;IACpB,EAAE,OAAOI,GAAG;QACV,MAAM,qBAAiC,CAAjC,IAAIC,eAAQ,CAAC,KAAK,iBAAlB,qBAAA;mBAAA;wBAAA;0BAAA;QAAgC;IACxC;AACF;AAMO,eAAeP,UACpBQ,GAAoB,EACpBC,KAAgB;IAEhB,IAAIC;IACJ,IAAI;QACFA,cAAcL,IAAAA,kBAAK,EAACG,IAAIG,OAAO,CAAC,eAAe,IAAI;IACrD,EAAE,OAAM;QACND,cAAcL,IAAAA,kBAAK,EAAC;IACtB;IACA,MAAM,EAAEO,IAAI,EAAEC,UAAU,EAAE,GAAGH;IAC7B,MAAMI,WAAWD,WAAWE,OAAO,IAAI;IAEvC,IAAIC;IAEJ,IAAI;QACF,MAAMC,aACJC,QAAQ;QACVF,SAAS,MAAMC,WAAWT,KAAK;YAAEM;YAAUL;QAAM;IACnD,EAAE,OAAOH,GAAG;QACV,IAAIa,IAAAA,gBAAO,EAACb,MAAMA,EAAEM,IAAI,KAAK,oBAAoB;YAC/C,MAAM,qBAAiD,CAAjD,IAAIL,eAAQ,CAAC,KAAK,CAAC,cAAc,EAAEE,MAAM,MAAM,CAAC,GAAhD,qBAAA;uBAAA;4BAAA;8BAAA;YAAgD;QACxD,OAAO;YACL,MAAM,qBAAiC,CAAjC,IAAIF,eAAQ,CAAC,KAAK,iBAAlB,qBAAA;uBAAA;4BAAA;8BAAA;YAAgC;QACxC;IACF;IAEA,MAAMa,OAAOJ,OAAOK,QAAQ;IAE5B,IAAIT,SAAS,sBAAsBA,SAAS,uBAAuB;QACjE,OAAOX,UAAUmB;IACnB,OAAO,IAAIR,SAAS,qCAAqC;QACvD,MAAMU,KAAKJ,QAAQ;QACnB,OAAOI,GAAGC,MAAM,CAACH;IACnB,OAAO;QACL,OAAOA;IACT;AACF","ignoreList":[0]}
|
||||
5
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.d.ts
generated
vendored
Normal file
5
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { __ApiPreviewProps } from '../.';
|
||||
import type { BaseNextRequest, BaseNextResponse } from '../../base-http';
|
||||
import type { PreviewData } from '../../../types';
|
||||
export declare function tryGetPreviewData(req: IncomingMessage | BaseNextRequest | Request, res: ServerResponse | BaseNextResponse, options: __ApiPreviewProps, multiZoneDraftMode: boolean): PreviewData;
|
||||
86
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js
generated
vendored
Normal file
86
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "tryGetPreviewData", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return tryGetPreviewData;
|
||||
}
|
||||
});
|
||||
const _ = require("../.");
|
||||
const _index = require("../index");
|
||||
const _cookies = require("../../web/spec-extension/cookies");
|
||||
const _headers = require("../../web/spec-extension/adapters/headers");
|
||||
function tryGetPreviewData(req, res, options, multiZoneDraftMode) {
|
||||
var _cookies_get, _cookies_get1;
|
||||
// if an On-Demand revalidation is being done preview mode
|
||||
// is disabled
|
||||
if (options && (0, _.checkIsOnDemandRevalidate)(req, options).isOnDemandRevalidate) {
|
||||
return false;
|
||||
}
|
||||
// Read cached preview data if present
|
||||
// TODO: use request metadata instead of a symbol
|
||||
if (_index.SYMBOL_PREVIEW_DATA in req) {
|
||||
return req[_index.SYMBOL_PREVIEW_DATA];
|
||||
}
|
||||
const headers = _headers.HeadersAdapter.from(req.headers);
|
||||
const cookies = new _cookies.RequestCookies(headers);
|
||||
const previewModeId = (_cookies_get = cookies.get(_index.COOKIE_NAME_PRERENDER_BYPASS)) == null ? void 0 : _cookies_get.value;
|
||||
const tokenPreviewData = (_cookies_get1 = cookies.get(_index.COOKIE_NAME_PRERENDER_DATA)) == null ? void 0 : _cookies_get1.value;
|
||||
// Case: preview mode cookie set but data cookie is not set
|
||||
if (previewModeId && !tokenPreviewData && previewModeId === options.previewModeId) {
|
||||
// This is "Draft Mode" which doesn't use
|
||||
// previewData, so we return an empty object
|
||||
// for backwards compat with "Preview Mode".
|
||||
const data = {};
|
||||
Object.defineProperty(req, _index.SYMBOL_PREVIEW_DATA, {
|
||||
value: data,
|
||||
enumerable: false
|
||||
});
|
||||
return data;
|
||||
}
|
||||
// Case: neither cookie is set.
|
||||
if (!previewModeId && !tokenPreviewData) {
|
||||
return false;
|
||||
}
|
||||
// Case: one cookie is set, but not the other.
|
||||
if (!previewModeId || !tokenPreviewData) {
|
||||
if (!multiZoneDraftMode) {
|
||||
(0, _index.clearPreviewData)(res);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Case: preview session is for an old build.
|
||||
if (previewModeId !== options.previewModeId) {
|
||||
if (!multiZoneDraftMode) {
|
||||
(0, _index.clearPreviewData)(res);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
let encryptedPreviewData;
|
||||
try {
|
||||
const jsonwebtoken = require('next/dist/compiled/jsonwebtoken');
|
||||
encryptedPreviewData = jsonwebtoken.verify(tokenPreviewData, options.previewModeSigningKey);
|
||||
} catch {
|
||||
// TODO: warn
|
||||
(0, _index.clearPreviewData)(res);
|
||||
return false;
|
||||
}
|
||||
const { decryptWithSecret } = require('../../crypto-utils');
|
||||
const decryptedPreviewData = decryptWithSecret(Buffer.from(options.previewModeEncryptionKey), encryptedPreviewData.data);
|
||||
try {
|
||||
// TODO: strict runtime type checking
|
||||
const data = JSON.parse(decryptedPreviewData);
|
||||
// Cache lookup
|
||||
Object.defineProperty(req, _index.SYMBOL_PREVIEW_DATA, {
|
||||
value: data,
|
||||
enumerable: false
|
||||
});
|
||||
return data;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=try-get-preview-data.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/node/try-get-preview-data.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
apps/public-web/node_modules/next/dist/server/api-utils/web.d.ts
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/web.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function byteLength(payload: string): number;
|
||||
17
apps/public-web/node_modules/next/dist/server/api-utils/web.js
generated
vendored
Normal file
17
apps/public-web/node_modules/next/dist/server/api-utils/web.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Buffer.byteLength polyfill in the Edge runtime, with only utf8 strings
|
||||
// supported at the moment.
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "byteLength", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return byteLength;
|
||||
}
|
||||
});
|
||||
function byteLength(payload) {
|
||||
return new TextEncoder().encode(payload).buffer.byteLength;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=web.js.map
|
||||
1
apps/public-web/node_modules/next/dist/server/api-utils/web.js.map
generated
vendored
Normal file
1
apps/public-web/node_modules/next/dist/server/api-utils/web.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/server/api-utils/web.ts"],"sourcesContent":["// Buffer.byteLength polyfill in the Edge runtime, with only utf8 strings\n// supported at the moment.\nexport function byteLength(payload: string): number {\n return new TextEncoder().encode(payload).buffer.byteLength\n}\n"],"names":["byteLength","payload","TextEncoder","encode","buffer"],"mappings":"AAAA,yEAAyE;AACzE,2BAA2B;;;;;+BACXA;;;eAAAA;;;AAAT,SAASA,WAAWC,OAAe;IACxC,OAAO,IAAIC,cAAcC,MAAM,CAACF,SAASG,MAAM,CAACJ,UAAU;AAC5D","ignoreList":[0]}
|
||||
Reference in New Issue
Block a user