create project

This commit is contained in:
ismailsosic
2022-12-27 12:05:56 +01:00
parent 2a33a2d3de
commit cd2143287c
16035 changed files with 2489703 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import type { NextMiddleware, RequestData, FetchEventResult } from './types';
export declare function adapter(params: {
handler: NextMiddleware;
page: string;
request: RequestData;
}): Promise<FetchEventResult>;
export declare function enhanceGlobals(): void;

211
kitabcitab/node_modules/next/dist/server/web/adapter.js generated vendored Normal file
View File

@@ -0,0 +1,211 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.adapter = adapter;
exports.enhanceGlobals = enhanceGlobals;
var _error = require("./error");
var _utils = require("./utils");
var _fetchEvent = require("./spec-extension/fetch-event");
var _request = require("./spec-extension/request");
var _response = require("./spec-extension/response");
var _relativizeUrl = require("../../shared/lib/router/utils/relativize-url");
var _nextUrl = require("./next-url");
var _internalUtils = require("../internal-utils");
var _appPaths = require("../../shared/lib/router/utils/app-paths");
var _appRouterHeaders = require("../../client/components/app-router-headers");
class NextRequestHint extends _request.NextRequest {
constructor(params){
super(params.input, params.init);
this.sourcePage = params.page;
}
get request() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
respondWith() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
waitUntil() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
}
const FLIGHT_PARAMETERS = [
[
_appRouterHeaders.RSC
],
[
_appRouterHeaders.NEXT_ROUTER_STATE_TREE
],
[
_appRouterHeaders.NEXT_ROUTER_PREFETCH
],
[
_appRouterHeaders.FETCH_CACHE_HEADER
],
];
async function adapter(params) {
// TODO-APP: use explicit marker for this
const isEdgeRendering = typeof self.__BUILD_MANIFEST !== "undefined";
params.request.url = (0, _appPaths).normalizeRscPath(params.request.url, true);
const requestUrl = new _nextUrl.NextURL(params.request.url, {
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
// Ensure users only see page requests, never data requests.
const buildId = requestUrl.buildId;
requestUrl.buildId = "";
const isDataReq = params.request.headers["x-nextjs-data"];
if (isDataReq && requestUrl.pathname === "/index") {
requestUrl.pathname = "/";
}
const requestHeaders = (0, _utils).fromNodeHeaders(params.request.headers);
// Parameters should only be stripped for middleware
if (!isEdgeRendering) {
for (const param of FLIGHT_PARAMETERS){
requestHeaders.delete(param.toString().toLowerCase());
}
}
// Strip internal query parameters off the request.
(0, _internalUtils).stripInternalSearchParams(requestUrl.searchParams, true);
const request = new NextRequestHint({
page: params.page,
input: String(requestUrl),
init: {
body: params.request.body,
geo: params.request.geo,
headers: requestHeaders,
ip: params.request.ip,
method: params.request.method,
nextConfig: params.request.nextConfig
}
});
/**
* This allows to identify the request as a data request. The user doesn't
* need to know about this property neither use it. We add it for testing
* purposes.
*/ if (isDataReq) {
Object.defineProperty(request, "__isData", {
enumerable: false,
value: true
});
}
const event = new _fetchEvent.NextFetchEvent({
request,
page: params.page
});
let response = await params.handler(request, event);
// check if response is a Response object
if (response && !(response instanceof Response)) {
throw new TypeError("Expected an instance of Response to be returned");
}
/**
* For rewrites we must always include the locale in the final pathname
* so we re-create the NextURL forcing it to include it when the it is
* an internal rewrite. Also we make sure the outgoing rewrite URL is
* a data URL if the request was a data request.
*/ const rewrite = response == null ? void 0 : response.headers.get("x-middleware-rewrite");
if (response && rewrite) {
const rewriteUrl = new _nextUrl.NextURL(rewrite, {
forceLocale: true,
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {
if (rewriteUrl.host === request.nextUrl.host) {
rewriteUrl.buildId = buildId || rewriteUrl.buildId;
response.headers.set("x-middleware-rewrite", String(rewriteUrl));
}
}
/**
* When the request is a data request we must show if there was a rewrite
* with an internal header so the client knows which component to load
* from the data request.
*/ if (isDataReq) {
response.headers.set("x-nextjs-rewrite", (0, _relativizeUrl).relativizeURL(String(rewriteUrl), String(requestUrl)));
}
}
/**
* For redirects we will not include the locale in case when it is the
* default and we must also make sure the outgoing URL is a data one if
* the incoming request was a data request.
*/ const redirect = response == null ? void 0 : response.headers.get("Location");
if (response && redirect) {
const redirectURL = new _nextUrl.NextURL(redirect, {
forceLocale: false,
headers: params.request.headers,
nextConfig: params.request.nextConfig
});
/**
* Responses created from redirects have immutable headers so we have
* to clone the response to be able to modify it.
*/ response = new Response(response.body, response);
if (!process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE) {
if (redirectURL.host === request.nextUrl.host) {
redirectURL.buildId = buildId || redirectURL.buildId;
response.headers.set("Location", String(redirectURL));
}
}
/**
* When the request is a data request we can't use the location header as
* it may end up with CORS error. Instead we map to an internal header so
* the client knows the destination.
*/ if (isDataReq) {
response.headers.delete("Location");
response.headers.set("x-nextjs-redirect", (0, _relativizeUrl).relativizeURL(String(redirectURL), String(requestUrl)));
}
}
return {
response: response || _response.NextResponse.next(),
waitUntil: Promise.all(event[_fetchEvent.waitUntilSymbol])
};
}
function getUnsupportedModuleErrorMessage(module) {
// warning: if you change these messages, you must adjust how react-dev-overlay's middleware detects modules not found
return `The edge runtime does not support Node.js '${module}' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`;
}
function __import_unsupported(moduleName) {
const proxy = new Proxy(function() {}, {
get (_obj, prop) {
if (prop === "then") {
return {};
}
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
},
construct () {
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
},
apply (_target, _this, args) {
if (typeof args[0] === "function") {
return args[0](proxy);
}
throw new Error(getUnsupportedModuleErrorMessage(moduleName));
}
});
return new Proxy({}, {
get: ()=>proxy
});
}
function enhanceGlobals() {
// The condition is true when the "process" module is provided
if (process !== global.process) {
// prefer local process but global.process has correct "env"
process.env = global.process.env;
global.process = process;
}
// to allow building code that import but does not use node.js modules,
// webpack will expect this function to exist in global scope
Object.defineProperty(globalThis, "__import_unsupported", {
value: __import_unsupported,
enumerable: false,
configurable: false
});
}
//# sourceMappingURL=adapter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
export declare class PageSignatureError extends Error {
constructor({ page }: {
page: string;
});
}
export declare class RemovedPageError extends Error {
constructor();
}
export declare class RemovedUAError extends Error {
constructor();
}

35
kitabcitab/node_modules/next/dist/server/web/error.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
class PageSignatureError extends Error {
constructor({ page }){
super(`The middleware "${page}" accepts an async API directly with the form:
export function middleware(request, event) {
return NextResponse.redirect('/new-location')
}
Read more: https://nextjs.org/docs/messages/middleware-new-signature
`);
}
}
exports.PageSignatureError = PageSignatureError;
class RemovedPageError extends Error {
constructor(){
super(`The request.page has been deprecated in favour of \`URLPattern\`.
Read more: https://nextjs.org/docs/messages/middleware-request-page
`);
}
}
exports.RemovedPageError = RemovedPageError;
class RemovedUAError extends Error {
constructor(){
super(`The request.ua has been removed in favour of \`userAgent\` function.
Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
`);
}
}
exports.RemovedUAError = RemovedUAError;
//# sourceMappingURL=error.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../server/web/error.ts"],"names":["PageSignatureError","Error","constructor","page","RemovedPageError","RemovedUAError"],"mappings":"AAAA;;;;AAAO,MAAMA,kBAAkB,SAASC,KAAK;IAC3CC,YAAY,EAAEC,IAAI,CAAA,EAAoB,CAAE;QACtC,KAAK,CAAC,CAAC,gBAAgB,EAAEA,IAAI,CAAC;;;;;;;EAOhC,CAAC,CAAC;KACD;CACF;QAXYH,kBAAkB,GAAlBA,kBAAkB;AAaxB,MAAMI,gBAAgB,SAASH,KAAK;IACzCC,aAAc;QACZ,KAAK,CAAC,CAAC;;EAET,CAAC,CAAC;KACD;CACF;QANYE,gBAAgB,GAAhBA,gBAAgB;AAQtB,MAAMC,cAAc,SAASJ,KAAK;IACvCC,aAAc;QACZ,KAAK,CAAC,CAAC;;EAET,CAAC,CAAC;KACD;CACF;QANYG,cAAc,GAAdA,cAAc"}

View File

@@ -0,0 +1,66 @@
import type { DomainLocale, I18NConfig } from '../config-shared';
interface Options {
base?: string | URL;
headers?: {
[key: string]: string | string[] | undefined;
};
forceLocale?: boolean;
nextConfig?: {
basePath?: string;
i18n?: I18NConfig | null;
trailingSlash?: boolean;
};
}
declare const Internal: unique symbol;
export declare class NextURL {
[Internal]: {
basePath: string;
buildId?: string;
flightSearchParameters?: Record<string, string>;
defaultLocale?: string;
domainLocale?: DomainLocale;
locale?: string;
options: Options;
trailingSlash?: boolean;
url: URL;
};
constructor(input: string | URL, base?: string | URL, opts?: Options);
constructor(input: string | URL, opts?: Options);
private analyzeUrl;
private formatPathname;
private formatSearch;
get buildId(): string | undefined;
set buildId(buildId: string | undefined);
get locale(): string;
set locale(locale: string);
get defaultLocale(): string | undefined;
get domainLocale(): DomainLocale | undefined;
get searchParams(): URLSearchParams;
get host(): string;
set host(value: string);
get hostname(): string;
set hostname(value: string);
get port(): string;
set port(value: string);
get protocol(): string;
set protocol(value: string);
get href(): string;
set href(url: string);
get origin(): string;
get pathname(): string;
set pathname(value: string);
get hash(): string;
set hash(value: string);
get search(): string;
set search(value: string);
get password(): string;
set password(value: string);
get username(): string;
set username(value: string);
get basePath(): string;
set basePath(value: string);
toString(): string;
toJSON(): string;
clone(): NextURL;
}
export {};

View File

@@ -0,0 +1,184 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _detectDomainLocale = require("../../shared/lib/i18n/detect-domain-locale");
var _formatNextPathnameInfo = require("../../shared/lib/router/utils/format-next-pathname-info");
var _getHostname = require("../../shared/lib/get-hostname");
var _getNextPathnameInfo = require("../../shared/lib/router/utils/get-next-pathname-info");
const REGEX_LOCALHOST_HOSTNAME = /(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|::1|localhost)/;
function parseURL(url, base) {
return new URL(String(url).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"), base && String(base).replace(REGEX_LOCALHOST_HOSTNAME, "localhost"));
}
const Internal = Symbol("NextURLInternal");
class NextURL {
constructor(input, baseOrOpts, opts){
let base;
let options;
if (typeof baseOrOpts === "object" && "pathname" in baseOrOpts || typeof baseOrOpts === "string") {
base = baseOrOpts;
options = opts || {};
} else {
options = opts || baseOrOpts || {};
}
this[Internal] = {
url: parseURL(input, base ?? options.base),
options: options,
basePath: ""
};
this.analyzeUrl();
}
analyzeUrl() {
var ref, ref1, ref2, ref3, ref4;
const pathnameInfo = (0, _getNextPathnameInfo).getNextPathnameInfo(this[Internal].url.pathname, {
nextConfig: this[Internal].options.nextConfig,
parseData: !process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE
});
this[Internal].domainLocale = (0, _detectDomainLocale).detectDomainLocale((ref = this[Internal].options.nextConfig) == null ? void 0 : (ref1 = ref.i18n) == null ? void 0 : ref1.domains, (0, _getHostname).getHostname(this[Internal].url, this[Internal].options.headers));
const defaultLocale = ((ref2 = this[Internal].domainLocale) == null ? void 0 : ref2.defaultLocale) || ((ref3 = this[Internal].options.nextConfig) == null ? void 0 : (ref4 = ref3.i18n) == null ? void 0 : ref4.defaultLocale);
this[Internal].url.pathname = pathnameInfo.pathname;
this[Internal].defaultLocale = defaultLocale;
this[Internal].basePath = pathnameInfo.basePath ?? "";
this[Internal].buildId = pathnameInfo.buildId;
this[Internal].locale = pathnameInfo.locale ?? defaultLocale;
this[Internal].trailingSlash = pathnameInfo.trailingSlash;
}
formatPathname() {
return (0, _formatNextPathnameInfo).formatNextPathnameInfo({
basePath: this[Internal].basePath,
buildId: this[Internal].buildId,
defaultLocale: !this[Internal].options.forceLocale ? this[Internal].defaultLocale : undefined,
locale: this[Internal].locale,
pathname: this[Internal].url.pathname,
trailingSlash: this[Internal].trailingSlash
});
}
formatSearch() {
return this[Internal].url.search;
}
get buildId() {
return this[Internal].buildId;
}
set buildId(buildId) {
this[Internal].buildId = buildId;
}
get locale() {
return this[Internal].locale ?? "";
}
set locale(locale) {
var ref, ref5;
if (!this[Internal].locale || !((ref = this[Internal].options.nextConfig) == null ? void 0 : (ref5 = ref.i18n) == null ? void 0 : ref5.locales.includes(locale))) {
throw new TypeError(`The NextURL configuration includes no locale "${locale}"`);
}
this[Internal].locale = locale;
}
get defaultLocale() {
return this[Internal].defaultLocale;
}
get domainLocale() {
return this[Internal].domainLocale;
}
get searchParams() {
return this[Internal].url.searchParams;
}
get host() {
return this[Internal].url.host;
}
set host(value) {
this[Internal].url.host = value;
}
get hostname() {
return this[Internal].url.hostname;
}
set hostname(value) {
this[Internal].url.hostname = value;
}
get port() {
return this[Internal].url.port;
}
set port(value) {
this[Internal].url.port = value;
}
get protocol() {
return this[Internal].url.protocol;
}
set protocol(value) {
this[Internal].url.protocol = value;
}
get href() {
const pathname = this.formatPathname();
const search = this.formatSearch();
return `${this.protocol}//${this.host}${pathname}${search}${this.hash}`;
}
set href(url) {
this[Internal].url = parseURL(url);
this.analyzeUrl();
}
get origin() {
return this[Internal].url.origin;
}
get pathname() {
return this[Internal].url.pathname;
}
set pathname(value) {
this[Internal].url.pathname = value;
}
get hash() {
return this[Internal].url.hash;
}
set hash(value) {
this[Internal].url.hash = value;
}
get search() {
return this[Internal].url.search;
}
set search(value) {
this[Internal].url.search = value;
}
get password() {
return this[Internal].url.password;
}
set password(value) {
this[Internal].url.password = value;
}
get username() {
return this[Internal].url.username;
}
set username(value) {
this[Internal].url.username = value;
}
get basePath() {
return this[Internal].basePath;
}
set basePath(value) {
this[Internal].basePath = value.startsWith("/") ? value : `/${value}`;
}
toString() {
return this.href;
}
toJSON() {
return this.href;
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
href: this.href,
origin: this.origin,
protocol: this.protocol,
username: this.username,
password: this.password,
host: this.host,
hostname: this.hostname,
port: this.port,
pathname: this.pathname,
search: this.search,
searchParams: this.searchParams,
hash: this.hash
};
}
clone() {
return new NextURL(String(this), this[Internal].options);
}
}
exports.NextURL = NextURL;
//# sourceMappingURL=next-url.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,30 @@
/// <reference types="node" />
import { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
/**
* For a given path a context, this function checks if there is any module
* context that contains the path with an older content and, if that's the
* case, removes the context from the cache.
*/
export declare function clearModuleContext(path: string, content: Buffer | string): void;
interface ModuleContextOptions {
moduleName: string;
onWarning: (warn: Error) => void;
useCache: boolean;
env: string[];
distDir: string;
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'assets' | 'wasm'>;
}
/**
* For a given module name this function will get a cached module
* context or create it. It will return the module context along
* with a function that allows to run some code from a given
* filepath within the context.
*/
export declare function getModuleContext(options: ModuleContextOptions): Promise<{
evaluateInContext: (filepath: string) => void;
runtime: EdgeRuntime;
paths: Map<string, string>;
warnedEvals: Set<string>;
}>;
export {};

View File

@@ -0,0 +1,276 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.clearModuleContext = clearModuleContext;
exports.getModuleContext = getModuleContext;
var _asyncHooks = require("async_hooks");
var _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
var _constants = require("../../../shared/lib/constants");
var _edgeRuntime = require("next/dist/compiled/edge-runtime");
var _fs = require("fs");
var _utils = require("../utils");
var _pick = require("../../../lib/pick");
var _fetchInlineAssets = require("./fetch-inline-assets");
const WEBPACK_HASH_REGEX = /__webpack_require__\.h = function\(\) \{ return "[0-9a-f]+"; \}/g;
/**
* A Map of cached module contexts indexed by the module name. It allows
* to have a different cache scoped per module name or depending on the
* provided module key on creation.
*/ const moduleContexts = new Map();
function clearModuleContext(path, content) {
for (const [key, cache] of moduleContexts){
var ref;
const prev = (ref = cache == null ? void 0 : cache.paths.get(path)) == null ? void 0 : ref.replace(WEBPACK_HASH_REGEX, "");
if (typeof prev !== "undefined" && prev !== content.toString().replace(WEBPACK_HASH_REGEX, "")) {
moduleContexts.delete(key);
}
}
}
async function loadWasm(wasm) {
const modules = {};
await Promise.all(wasm.map(async (binding)=>{
const module = await WebAssembly.compile(await _fs.promises.readFile(binding.filePath));
modules[binding.name] = module;
}));
return modules;
}
function buildEnvironmentVariablesFrom(keys) {
const pairs = keys.map((key)=>[
key,
process.env[key]
]);
const env = Object.fromEntries(pairs);
env.NEXT_RUNTIME = "edge";
return env;
}
function throwUnsupportedAPIError(name) {
const error = new Error(`A Node.js API is used (${name}) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime`);
(0, _middleware).decorateServerError(error, _constants.COMPILER_NAMES.edgeServer);
throw error;
}
function createProcessPolyfill(options) {
const env = buildEnvironmentVariablesFrom(options.env);
const processPolyfill = {
env
};
const overridenValue = {};
for (const key of Object.keys(process)){
if (key === "env") continue;
Object.defineProperty(processPolyfill, key, {
get () {
if (overridenValue[key]) {
return overridenValue[key];
}
if (typeof process[key] === "function") {
return ()=>throwUnsupportedAPIError(`process.${key}`);
}
return undefined;
},
set (value) {
overridenValue[key] = value;
},
enumerable: false
});
}
return processPolyfill;
}
function addStub(context, name) {
Object.defineProperty(context, name, {
get () {
return function() {
throwUnsupportedAPIError(name);
};
},
enumerable: false
});
}
function getDecorateUnhandledError(runtime) {
const EdgeRuntimeError = runtime.evaluate(`Error`);
return (error)=>{
if (error instanceof EdgeRuntimeError) {
(0, _middleware).decorateServerError(error, _constants.COMPILER_NAMES.edgeServer);
}
};
}
function getDecorateUnhandledRejection(runtime) {
const EdgeRuntimeError = runtime.evaluate(`Error`);
return (rejected)=>{
if (rejected.reason instanceof EdgeRuntimeError) {
(0, _middleware).decorateServerError(rejected.reason, _constants.COMPILER_NAMES.edgeServer);
}
};
}
/**
* Create a module cache specific for the provided parameters. It includes
* a runtime context, require cache and paths cache.
*/ async function createModuleContext(options) {
const warnedEvals = new Set();
const warnedWasmCodegens = new Set();
const wasm = await loadWasm(options.edgeFunctionEntry.wasm ?? []);
const runtime = new _edgeRuntime.EdgeRuntime({
codeGeneration: process.env.NODE_ENV !== "production" ? {
strings: true,
wasm: true
} : undefined,
extend: (context)=>{
context.process = createProcessPolyfill(options);
context.__next_eval__ = function __next_eval__(fn) {
const key = fn.toString();
if (!warnedEvals.has(key)) {
const warning = (0, _middleware).getServerError(new Error(`Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Edge Runtime
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicCodeEvaluationWarning";
Error.captureStackTrace(warning, __next_eval__);
warnedEvals.add(key);
options.onWarning(warning);
}
return fn();
};
context.__next_webassembly_compile__ = function __next_webassembly_compile__(fn) {
const key = fn.toString();
if (!warnedWasmCodegens.has(key)) {
const warning = (0, _middleware).getServerError(new Error(`Dynamic WASM code generation (e. g. 'WebAssembly.compile') not allowed in Edge Runtime.
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicWasmCodeGenerationWarning";
Error.captureStackTrace(warning, __next_webassembly_compile__);
warnedWasmCodegens.add(key);
options.onWarning(warning);
}
return fn();
};
context.__next_webassembly_instantiate__ = async function __next_webassembly_instantiate__(fn) {
const result = await fn();
// If a buffer is given, WebAssembly.instantiate returns an object
// containing both a module and an instance while it returns only an
// instance if a WASM module is given. Utilize the fact to determine
// if the WASM code generation happens.
//
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate#primary_overload_%E2%80%94_taking_wasm_binary_code
const instantiatedFromBuffer = result.hasOwnProperty("module");
const key = fn.toString();
if (instantiatedFromBuffer && !warnedWasmCodegens.has(key)) {
const warning = (0, _middleware).getServerError(new Error(`Dynamic WASM code generation ('WebAssembly.instantiate' with a buffer parameter) not allowed in Edge Runtime.
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation`), _constants.COMPILER_NAMES.edgeServer);
warning.name = "DynamicWasmCodeGenerationWarning";
Error.captureStackTrace(warning, __next_webassembly_instantiate__);
warnedWasmCodegens.add(key);
options.onWarning(warning);
}
return result;
};
const __fetch = context.fetch;
context.fetch = async (input, init = {})=>{
var ref;
const assetResponse = await (0, _fetchInlineAssets).fetchInlineAsset({
input,
assets: options.edgeFunctionEntry.assets,
distDir: options.distDir,
context
});
if (assetResponse) {
return assetResponse;
}
init.headers = new Headers(init.headers ?? {});
const prevs = ((ref = init.headers.get(`x-middleware-subrequest`)) == null ? void 0 : ref.split(":")) || [];
const value = prevs.concat(options.moduleName).join(":");
init.headers.set("x-middleware-subrequest", value);
if (!init.headers.has("user-agent")) {
init.headers.set(`user-agent`, `Next.js Middleware`);
}
if (typeof input === "object" && "url" in input) {
return __fetch(input.url, {
...(0, _pick).pick(input, [
"method",
"body",
"cache",
"credentials",
"integrity",
"keepalive",
"mode",
"redirect",
"referrer",
"referrerPolicy",
"signal",
]),
...init,
headers: {
...Object.fromEntries(input.headers),
...Object.fromEntries(init.headers)
}
});
}
return __fetch(String(input), init);
};
const __Request = context.Request;
context.Request = class extends __Request {
constructor(input, init){
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
(0, _utils).validateURL(url);
super(url, init);
this.next = init == null ? void 0 : init.next;
}
};
const __redirect = context.Response.redirect.bind(context.Response);
context.Response.redirect = (...args)=>{
(0, _utils).validateURL(args[0]);
return __redirect(...args);
};
for (const name of _constants.EDGE_UNSUPPORTED_NODE_APIS){
addStub(context, name);
}
Object.assign(context, wasm);
context.AsyncLocalStorage = _asyncHooks.AsyncLocalStorage;
return context;
}
});
const decorateUnhandledError = getDecorateUnhandledError(runtime);
runtime.context.addEventListener("error", decorateUnhandledError);
const decorateUnhandledRejection = getDecorateUnhandledRejection(runtime);
runtime.context.addEventListener("unhandledrejection", decorateUnhandledRejection);
return {
runtime,
paths: new Map(),
warnedEvals: new Set()
};
}
const pendingModuleCaches = new Map();
function getModuleContextShared(options) {
let deferredModuleContext = pendingModuleCaches.get(options.moduleName);
if (!deferredModuleContext) {
deferredModuleContext = createModuleContext(options);
pendingModuleCaches.set(options.moduleName, deferredModuleContext);
}
return deferredModuleContext;
}
async function getModuleContext(options) {
let moduleContext;
if (options.useCache) {
moduleContext = moduleContexts.get(options.moduleName) || await getModuleContextShared(options);
}
if (!moduleContext) {
moduleContext = await createModuleContext(options);
moduleContexts.set(options.moduleName, moduleContext);
}
const evaluateInContext = (filepath)=>{
if (!moduleContext.paths.has(filepath)) {
const content = (0, _fs).readFileSync(filepath, "utf-8");
try {
moduleContext == null ? void 0 : moduleContext.runtime.evaluate(content);
moduleContext.paths.set(filepath, content);
} catch (error) {
if (options.useCache) {
moduleContext == null ? void 0 : moduleContext.paths.delete(options.moduleName);
}
throw error;
}
}
};
return {
...moduleContext,
evaluateInContext
};
}
//# sourceMappingURL=context.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import type { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
/**
* Short-circuits the `fetch` function
* to return a stream for a given asset, if a user used `new URL("file", import.meta.url)`.
* This allows to embed assets in Edge Runtime.
*/
export declare function fetchInlineAsset(options: {
input: RequestInfo | URL;
distDir: string;
assets: EdgeFunctionDefinition['assets'];
context: {
Response: typeof Response;
ReadableStream: typeof ReadableStream;
};
}): Promise<Response | undefined>;

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fetchInlineAsset = fetchInlineAsset;
var _fs = require("fs");
var _bodyStreams = require("../../body-streams");
var _path = require("path");
async function fetchInlineAsset(options) {
var ref;
const inputString = String(options.input);
if (!inputString.startsWith("blob:")) {
return;
}
const hash = inputString.replace("blob:", "");
const asset = (ref = options.assets) == null ? void 0 : ref.find((x)=>x.name === hash);
if (!asset) {
return;
}
const filePath = (0, _path).resolve(options.distDir, asset.filePath);
const fileIsReadable = await _fs.promises.access(filePath).then(()=>true, ()=>false);
if (fileIsReadable) {
const readStream = (0, _fs).createReadStream(filePath);
return new options.context.Response((0, _bodyStreams).requestToBodyStream(options.context, Uint8Array, readStream));
}
}
//# sourceMappingURL=fetch-inline-assets.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/sandbox/fetch-inline-assets.ts"],"names":["fetchInlineAsset","options","inputString","String","input","startsWith","hash","replace","asset","assets","find","x","name","filePath","resolve","distDir","fileIsReadable","fs","access","then","readStream","createReadStream","context","Response","requestToBodyStream","Uint8Array"],"mappings":"AAAA;;;;QAUsBA,gBAAgB,GAAhBA,gBAAgB;AATW,IAAA,GAAI,WAAJ,IAAI,CAAA;AACjB,IAAA,YAAoB,WAApB,oBAAoB,CAAA;AAChC,IAAA,KAAM,WAAN,MAAM,CAAA;AAOvB,eAAeA,gBAAgB,CAACC,OAKtC,EAAiC;QAOlBA,GAAc;IAN5B,MAAMC,WAAW,GAAGC,MAAM,CAACF,OAAO,CAACG,KAAK,CAAC;IACzC,IAAI,CAACF,WAAW,CAACG,UAAU,CAAC,OAAO,CAAC,EAAE;QACpC,OAAM;KACP;IAED,MAAMC,IAAI,GAAGJ,WAAW,CAACK,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;IAC7C,MAAMC,KAAK,GAAGP,CAAAA,GAAc,GAAdA,OAAO,CAACQ,MAAM,SAAM,GAApBR,KAAAA,CAAoB,GAApBA,GAAc,CAAES,IAAI,CAAC,CAACC,CAAC,GAAKA,CAAC,CAACC,IAAI,KAAKN,IAAI,CAAC;IAC1D,IAAI,CAACE,KAAK,EAAE;QACV,OAAM;KACP;IAED,MAAMK,QAAQ,GAAGC,CAAAA,GAAAA,KAAO,AAAiC,CAAA,QAAjC,CAACb,OAAO,CAACc,OAAO,EAAEP,KAAK,CAACK,QAAQ,CAAC;IACzD,MAAMG,cAAc,GAAG,MAAMC,GAAE,SAAA,CAACC,MAAM,CAACL,QAAQ,CAAC,CAACM,IAAI,CACnD,IAAM,IAAI,EACV,IAAM,KAAK,CACZ;IAED,IAAIH,cAAc,EAAE;QAClB,MAAMI,UAAU,GAAGC,CAAAA,GAAAA,GAAgB,AAAU,CAAA,iBAAV,CAACR,QAAQ,CAAC;QAC7C,OAAO,IAAIZ,OAAO,CAACqB,OAAO,CAACC,QAAQ,CACjCC,CAAAA,GAAAA,YAAmB,AAAyC,CAAA,oBAAzC,CAACvB,OAAO,CAACqB,OAAO,EAAEG,UAAU,EAAEL,UAAU,CAAC,CAC7D,CAAA;KACF;CACF"}

View File

@@ -0,0 +1,2 @@
export * from './sandbox';
export { clearModuleContext } from './context';

View File

@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
clearModuleContext: true
};
Object.defineProperty(exports, "clearModuleContext", {
enumerable: true,
get: function() {
return _context.clearModuleContext;
}
});
var _sandbox = _interopRequireWildcard(require("./sandbox"));
Object.keys(_sandbox).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _sandbox[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function() {
return _sandbox[key];
}
});
});
var _context = require("./context");
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function() {
return cache;
};
return cache;
}
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
}
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
return {
default: obj
};
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for(var key in obj){
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/sandbox/index.ts"],"names":["clearModuleContext"],"mappings":"AAAA;;;;;;;+BACSA,oBAAkB;;;wBAAlBA,kBAAkB;;;+CADb,WAAW;AAAzB,YAAA,QAAyB;;;2CAAzB,QAAyB;;;;mBAAzB,QAAyB;;;EAAA;uBACU,WAAW"}

View File

@@ -0,0 +1,25 @@
import type { NodejsRequestData, FetchEventResult } from '../types';
import { EdgeFunctionDefinition } from '../../../build/webpack/plugins/middleware-plugin';
import type { EdgeRuntime } from 'next/dist/compiled/edge-runtime';
export declare const ErrorSource: unique symbol;
declare type RunnerFn = (params: {
name: string;
env: string[];
onWarning?: (warn: Error) => void;
paths: string[];
request: NodejsRequestData;
useCache: boolean;
edgeFunctionEntry: Pick<EdgeFunctionDefinition, 'wasm' | 'assets'>;
distDir: string;
}) => Promise<FetchEventResult>;
export declare const getRuntimeContext: (params: {
name: string;
onWarning?: any;
useCache: boolean;
env: string[];
edgeFunctionEntry: any;
distDir: string;
paths: string[];
}) => Promise<EdgeRuntime<any>>;
export declare const run: RunnerFn;
export {};

View File

@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.run = exports.getRuntimeContext = exports.ErrorSource = void 0;
var _middleware = require("next/dist/compiled/@next/react-dev-overlay/dist/middleware");
var _context = require("./context");
var _bodyStreams = require("../../body-streams");
const ErrorSource = Symbol("SandboxError");
exports.ErrorSource = ErrorSource;
const FORBIDDEN_HEADERS = [
"content-length",
"content-encoding",
"transfer-encoding",
];
/**
* Decorates the runner function making sure all errors it can produce are
* tagged with `edge-server` so they can properly be rendered in dev.
*/ function withTaggedErrors(fn) {
return (params)=>{
return fn(params).then((result)=>{
var ref;
return {
...result,
waitUntil: result == null ? void 0 : (ref = result.waitUntil) == null ? void 0 : ref.catch((error)=>{
// TODO: used COMPILER_NAMES.edgeServer instead. Verify that it does not increase the runtime size.
throw (0, _middleware).getServerError(error, "edge-server");
})
};
}).catch((error)=>{
// TODO: used COMPILER_NAMES.edgeServer instead
throw (0, _middleware).getServerError(error, "edge-server");
});
};
}
const getRuntimeContext = async (params)=>{
const { runtime , evaluateInContext } = await (0, _context).getModuleContext({
moduleName: params.name,
onWarning: params.onWarning ?? (()=>{}),
useCache: params.useCache !== false,
env: params.env,
edgeFunctionEntry: params.edgeFunctionEntry,
distDir: params.distDir
});
for (const paramPath of params.paths){
evaluateInContext(paramPath);
}
return runtime;
};
exports.getRuntimeContext = getRuntimeContext;
const run = withTaggedErrors(async (params)=>{
var ref;
const runtime = await getRuntimeContext(params);
const subreq = params.request.headers[`x-middleware-subrequest`];
const subrequests = typeof subreq === "string" ? subreq.split(":") : [];
if (subrequests.includes(params.name)) {
return {
waitUntil: Promise.resolve(),
response: new runtime.context.Response(null, {
headers: {
"x-middleware-next": "1"
}
})
};
}
const edgeFunction = runtime.context._ENTRIES[`middleware_${params.name}`].default;
const cloned = ![
"HEAD",
"GET"
].includes(params.request.method) ? (ref = params.request.body) == null ? void 0 : ref.cloneBodyStream() : undefined;
const KUint8Array = runtime.evaluate("Uint8Array");
try {
const result = await edgeFunction({
request: {
...params.request,
body: cloned && (0, _bodyStreams).requestToBodyStream(runtime.context, KUint8Array, cloned)
}
});
for (const headerName of FORBIDDEN_HEADERS){
result.response.headers.delete(headerName);
}
return result;
} finally{
var ref1;
await ((ref1 = params.request.body) == null ? void 0 : ref1.finalize());
}
});
exports.run = run;
//# sourceMappingURL=sandbox.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/sandbox/sandbox.ts"],"names":["ErrorSource","Symbol","FORBIDDEN_HEADERS","withTaggedErrors","fn","params","then","result","waitUntil","catch","error","getServerError","getRuntimeContext","runtime","evaluateInContext","getModuleContext","moduleName","name","onWarning","useCache","env","edgeFunctionEntry","distDir","paramPath","paths","run","subreq","request","headers","subrequests","split","includes","Promise","resolve","response","context","Response","edgeFunction","_ENTRIES","default","cloned","method","body","cloneBodyStream","undefined","KUint8Array","evaluate","requestToBodyStream","headerName","delete","finalize"],"mappings":"AAAA;;;;;AAC+B,IAAA,WAA4D,WAA5D,4DA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,GAC3DpC,CAAAA,GAAmB,GAAnBA,MAAM,CAACsB,OAAO,CAACe,IAAI,SAAiB,GAApCrC,KAAAA,CAAoC,GAApCA,GAAmB,CAAEsC,eAAe,EAAE,GACtCC,SAAS;IAEb,MAAMC,WAAW,GAAGhC,OAAO,CAACiC,QAAQ,CAAC,YAAY,CAAC;IAElD,IAAI;QACF,MAAMvC,MAAM,GAAG,MAAM8B,YAAY,CAAC;YAChCV,OAAO,EAAE;gBACP,GAAGtB,MAAM,CAACsB,OAAO;gBACjBe,IAAI,EACFF,MAAM,IAAIO,CAAAA,GAAAA,YAAmB,AAAsC,CAAA,oBAAtC,CAAClC,OAAO,CAACsB,OAAO,EAAEU,WAAW,EAAEL,MAAM,CAAC;aACtE;SACF,CAAC;QACF,KAAK,MAAMQ,UAAU,IAAI9C,iBAAiB,CAAE;YAC1CK,MAAM,CAAC2B,QAAQ,CAACN,OAAO,CAACqB,MAAM,CAACD,UAAU,CAAC;SAC3C;QACD,OAAOzC,MAAM,CAAA;KACd,QAAS;YACFF,IAAmB;QAAzB,OAAMA,CAAAA,IAAmB,GAAnBA,MAAM,CAACsB,OAAO,CAACe,IAAI,SAAU,GAA7BrC,KAAAA,CAA6B,GAA7BA,IAAmB,CAAE6C,QAAQ,EAAE,CAAA;KACtC;CACF,CAAC;QAzCWzB,GAAG,GAAHA,GAAG"}

View File

@@ -0,0 +1,7 @@
/**
* A simple caching behavior.
* We cache the result based on the key `K`
* which uses referential equality, to avoid re-computing
* the result for the same key.
*/
export declare function cached<K, V>(generate: (key: K) => V): (key: K) => V;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cached = cached;
function cached(generate) {
let cache = undefined;
return (key)=>{
if ((cache == null ? void 0 : cache.key) !== key) {
cache = {
key,
value: generate(key)
};
}
return cache.value;
};
}
//# sourceMappingURL=cached.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/cached.ts"],"names":["cached","generate","cache","undefined","key","value"],"mappings":"AAMA;;;;QAAgBA,MAAM,GAANA,MAAM;AAAf,SAASA,MAAM,CAAOC,QAAuB,EAAE;IACpD,IAAIC,KAAK,GAAqCC,SAAS;IACvD,OAAO,CAACC,GAAM,GAAK;QACjB,IAAIF,CAAAA,KAAK,QAAK,GAAVA,KAAAA,CAAU,GAAVA,KAAK,CAAEE,GAAG,CAAA,KAAKA,GAAG,EAAE;YACtBF,KAAK,GAAG;gBAAEE,GAAG;gBAAEC,KAAK,EAAEJ,QAAQ,CAACG,GAAG,CAAC;aAAE;SACtC;QAED,OAAOF,KAAK,CAACG,KAAK,CAAA;KACnB,CAAA;CACF"}

View File

@@ -0,0 +1,3 @@
export type { CookieListItem, RequestCookie, ResponseCookie } from './types';
export { RequestCookies } from './request-cookies';
export { ResponseCookies } from './response-cookies';

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RequestCookies", {
enumerable: true,
get: function() {
return _requestCookies.RequestCookies;
}
});
Object.defineProperty(exports, "ResponseCookies", {
enumerable: true,
get: function() {
return _responseCookies.ResponseCookies;
}
});
var _requestCookies = require("./request-cookies");
var _responseCookies = require("./response-cookies");
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/index.ts"],"names":["RequestCookies","ResponseCookies"],"mappings":"AACA;;;;+BACSA,gBAAc;;;+BAAdA,cAAc;;;+BACdC,iBAAe;;;gCAAfA,eAAe;;;8BADO,mBAAmB;+BAClB,oBAAoB"}

View File

@@ -0,0 +1,28 @@
import type { RequestCookie } from './types';
/**
* A class for manipulating {@link Request} cookies (`Cookie` header).
*/
export declare class RequestCookies {
readonly _headers: Headers;
_parsed: Map<string, RequestCookie>;
constructor(requestHeaders: Headers);
[Symbol.iterator](): IterableIterator<[string, RequestCookie]>;
/**
* The amount of cookies received from the client
*/
get size(): number;
get(...args: [name: string] | [RequestCookie]): RequestCookie | undefined;
getAll(...args: [name: string] | [RequestCookie] | []): RequestCookie[];
has(name: string): boolean;
set(...args: [key: string, value: string] | [options: RequestCookie]): this;
/**
* Delete the cookies matching the passed name or names in the request.
*/
delete(
/** Name or names of the cookies to be deleted */
names: string | string[]): boolean | boolean[];
/**
* Delete all the cookies in the cookies in the request.
*/
clear(): this;
}

View File

@@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _serialize = require("./serialize");
class RequestCookies {
_parsed = new Map();
constructor(requestHeaders){
this._headers = requestHeaders;
const header = requestHeaders.get("cookie");
if (header) {
const parsed = (0, _serialize).parseCookieString(header);
for (const [name, value] of parsed){
this._parsed.set(name, {
name,
value
});
}
}
}
[Symbol.iterator]() {
return this._parsed[Symbol.iterator]();
}
/**
* The amount of cookies received from the client
*/ get size() {
return this._parsed.size;
}
get(...args) {
const name = typeof args[0] === "string" ? args[0] : args[0].name;
return this._parsed.get(name);
}
getAll(...args) {
var ref;
const all = Array.from(this._parsed);
if (!args.length) {
return all.map(([_, value])=>value);
}
const name = typeof args[0] === "string" ? args[0] : (ref = args[0]) == null ? void 0 : ref.name;
return all.filter(([n])=>n === name).map(([_, value])=>value);
}
has(name) {
return this._parsed.has(name);
}
set(...args) {
const [name, value] = args.length === 1 ? [
args[0].name,
args[0].value
] : args;
const map = this._parsed;
map.set(name, {
name,
value
});
this._headers.set("cookie", Array.from(map).map(([_, v])=>(0, _serialize).serialize(v)).join("; "));
return this;
}
/**
* Delete the cookies matching the passed name or names in the request.
*/ delete(/** Name or names of the cookies to be deleted */ names) {
const map = this._parsed;
const result = !Array.isArray(names) ? map.delete(names) : names.map((name)=>map.delete(name));
this._headers.set("cookie", Array.from(map).map(([_, value])=>(0, _serialize).serialize(value)).join("; "));
return result;
}
/**
* Delete all the cookies in the cookies in the request.
*/ clear() {
this.delete(Array.from(this._parsed.keys()));
return this;
}
/**
* Format the cookies in the request as a string for logging
*/ [Symbol.for("edge-runtime.inspect.custom")]() {
return `RequestCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
}
exports.RequestCookies = RequestCookies;
//# sourceMappingURL=request-cookies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/request-cookies.ts"],"names":["RequestCookies","_parsed","Map","constructor","requestHeaders","_headers","header","get","parsed","parseCookieString","name","value","set","Symbol","iterator","size","args","getAll","all","Array","from","length","map","_","filter","n","has","v","serialize","join","delete","names","result","isArray","clear","keys","for","JSON","stringify","Object","fromEntries"],"mappings":"AAAA;;;;AAC6C,IAAA,UAAa,WAAb,aAAa,CAAA;AAKnD,MAAMA,cAAc;IAEzBC,OAAO,GAA+B,IAAIC,GAAG,EAAE,CAAA;IAE/CC,YAAYC,cAAuB,CAAE;QACnC,IAAI,CAACC,QAAQ,GAAGD,cAAc;QAC9B,MAAME,MAAM,GAAGF,cAAc,CAACG,GAAG,CAAC,QAAQ,CAAC;QAC3C,IAAID,MAAM,EAAE;YACV,MAAME,MAAM,GAAGC,CAAAA,GAAAA,UAAiB,AAAQ,CAAA,kBAAR,CAACH,MAAM,CAAC;YACxC,KAAK,MAAM,CAACI,IAAI,EAAEC,KAAK,CAAC,IAAIH,MAAM,CAAE;gBAClC,IAAI,CAACP,OAAO,CAACW,GAAG,CAACF,IAAI,EAAE;oBAAEA,IAAI;oBAAEC,KAAK;iBAAE,CAAC;aACxC;SACF;KACF;IAED,CAACE,MAAM,CAACC,QAAQ,CAAC,GAAG;QAClB,OAAO,IAAI,CAACb,OAAO,CAACY,MAAM,CAACC,QAAQ,CAAC,EAAE,CAAA;KACvC;IAED;;KAEG,CACH,IAAIC,IAAI,GAAW;QACjB,OAAO,IAAI,CAACd,OAAO,CAACc,IAAI,CAAA;KACzB;IAEDR,GAAG,CAAC,GAAGS,IAAI,AAAkC,EAAE;QAC7C,MAAMN,IAAI,GAAG,OAAOM,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAGA,IAAI,CAA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M,CAACC,WAAW,CAAC,IAAI,CAACvC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;KAC5E;CACF;QA/FYD,cAAc,GAAdA,cAAc"}

View File

@@ -0,0 +1,27 @@
import type { ResponseCookie } from './types';
/**
* A class for manipulating {@link Response} cookies (`Set-Cookie` header).
* Loose implementation of the experimental [Cookie Store API](https://wicg.github.io/cookie-store/#dictdef-cookie)
* The main difference is `ResponseCookies` methods do not return a Promise.
*/
export declare class ResponseCookies {
readonly _headers: Headers;
_parsed: Map<string, ResponseCookie>;
constructor(responseHeaders: Headers);
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
*/
get(...args: [key: string] | [options: ResponseCookie]): ResponseCookie | undefined;
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
*/
getAll(...args: [key: string] | [options: ResponseCookie] | []): ResponseCookie[];
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
*/
set(...args: [key: string, value: string, cookie?: Partial<ResponseCookie>] | [options: ResponseCookie]): this;
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
*/
delete(...args: [key: string] | [options: ResponseCookie]): this;
}

View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _serialize = require("./serialize");
function replace(bag, headers) {
headers.delete("set-cookie");
for (const [, value] of bag){
const serialized = (0, _serialize).serialize(value);
headers.append("set-cookie", serialized);
}
}
function normalizeCookie(cookie = {
name: "",
value: ""
}) {
if (cookie.maxAge) {
cookie.expires = new Date(Date.now() + cookie.maxAge * 1000);
}
if (cookie.path === null || cookie.path === undefined) {
cookie.path = "/";
}
return cookie;
}
class ResponseCookies {
_parsed = new Map();
constructor(responseHeaders){
this._headers = responseHeaders;
// @ts-expect-error See https://github.com/whatwg/fetch/issues/973
const headers = this._headers.getAll("set-cookie");
for (const header of headers){
const parsed = (0, _serialize).parseSetCookieString(header);
if (parsed) {
this._parsed.set(parsed.name, parsed);
}
}
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-get CookieStore#get} without the Promise.
*/ get(...args) {
const key = typeof args[0] === "string" ? args[0] : args[0].name;
return this._parsed.get(key);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-getAll CookieStore#getAll} without the Promise.
*/ getAll(...args) {
var ref;
const all = Array.from(this._parsed.values());
if (!args.length) {
return all;
}
const key = typeof args[0] === "string" ? args[0] : (ref = args[0]) == null ? void 0 : ref.name;
return all.filter((c)=>c.name === key);
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-set CookieStore#set} without the Promise.
*/ set(...args) {
const [name, value, cookie] = args.length === 1 ? [
args[0].name,
args[0].value,
args[0]
] : args;
const map = this._parsed;
map.set(name, normalizeCookie({
name,
value,
...cookie
}));
replace(map, this._headers);
return this;
}
/**
* {@link https://wicg.github.io/cookie-store/#CookieStore-delete CookieStore#delete} without the Promise.
*/ delete(...args) {
const name = typeof args[0] === "string" ? args[0] : args[0].name;
return this.set({
name,
value: "",
expires: new Date(0)
});
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return `ResponseCookies ${JSON.stringify(Object.fromEntries(this._parsed))}`;
}
}
exports.ResponseCookies = ResponseCookies;
//# sourceMappingURL=response-cookies.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/response-cookies.ts"],"names":["replace","bag","headers","delete","value","serialized","serialize","append","normalizeCookie","cookie","name","maxAge","expires","Date","now","path","undefined","ResponseCookies","_parsed","Map","constructor","responseHeaders","_headers","getAll","header","parsed","parseSetCookieString","set","get","args","key","all","Array","from","values","length","filter","c","map","Symbol","for","JSON","stringify","Object","fromEntries"],"mappings":"AAAA;;;;AACgD,IAAA,UAAa,WAAb,aAAa,CAAA;AAE7D,SAASA,OAAO,CAACC,GAAgC,EAAEC,OAAgB,EAAE;IACnEA,OAAO,CAACC,MAAM,CAAC,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B,QAAQ,CAAC;QAE3B,OAAO,IAAI,CAAA;KACZ;IAED;;KAEG,CACHnB,MAAM,CAAC,GAAG0B,IAAI,AAA2C,EAAQ;QAC/D,MAAMnB,IAAI,GAAG,OAAOmB,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,CAACnB,IAAI;QACjE,OAAO,IAAI,CAACiB,GAAG,CAAC;YAAEjB,IAAI;YAAEN,KAAK,EAAE,EAAE;YAAEQ,OAAO,EAAE,IAAIC,IAAI,CAAC,CAAC,CAAC;SAAE,CAAC,CAAA;KAC3D;IAED,CAAC0B,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC,CAAC,GAAG;QAC5C,OAAO,CAAC,gBAAgB,EAAEC,IAAI,CAACC,SAAS,CAACC,MAAM,CAACC,WAAW,CAAC,IAAI,CAAC1B,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;KAC7E;CACF;QArEYD,eAAe,GAAfA,eAAe"}

View File

@@ -0,0 +1,10 @@
import type { RequestCookie, ResponseCookie } from './types';
export declare function serialize(c: ResponseCookie | RequestCookie): string;
/**
* Parse a `Cookie` or `Set-Cookie header value
*/
export declare function parseCookieString(cookie: string): Map<string, string>;
/**
* Parse a `Set-Cookie` header value
*/
export declare function parseSetCookieString(setCookie: string): undefined | ResponseCookie;

View File

@@ -0,0 +1,80 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.serialize = serialize;
exports.parseCookieString = parseCookieString;
exports.parseSetCookieString = parseSetCookieString;
const SAME_SITE = [
"strict",
"lax",
"none"
];
function parseSameSite(string) {
string = string.toLowerCase();
return SAME_SITE.includes(string) ? string : undefined;
}
function compact(t) {
const newT = {};
for(const key in t){
if (t[key]) {
newT[key] = t[key];
}
}
return newT;
}
function serialize(c) {
const attrs = [
"path" in c && c.path && `Path=${c.path}`,
"expires" in c && c.expires && `Expires=${c.expires.toUTCString()}`,
"maxAge" in c && c.maxAge && `Max-Age=${c.maxAge}`,
"domain" in c && c.domain && `Domain=${c.domain}`,
"secure" in c && c.secure && "Secure",
"httpOnly" in c && c.httpOnly && "HttpOnly",
"sameSite" in c && c.sameSite && `SameSite=${c.sameSite}`,
].filter(Boolean);
return `${c.name}=${encodeURIComponent(c.value ?? "")}; ${attrs.join("; ")}`;
}
function parseCookieString(cookie) {
const map = new Map();
for (const pair of cookie.split(/; */)){
if (!pair) continue;
const [key, value] = pair.split("=", 2);
map.set(key, decodeURIComponent(value ?? "true"));
}
return map;
}
function parseSetCookieString(setCookie) {
if (!setCookie) {
return undefined;
}
const [[name, value], ...attributes] = parseCookieString(setCookie);
const { domain , expires , httponly , maxage , path , samesite , secure } = Object.fromEntries(attributes.map(([key, v])=>[
key.toLowerCase(),
v
]));
const cookie = {
name,
value: decodeURIComponent(value),
domain,
...expires && {
expires: new Date(expires)
},
...httponly && {
httpOnly: true
},
...typeof maxage === "string" && {
maxAge: Number(maxage)
},
path,
...samesite && {
sameSite: parseSameSite(samesite)
},
...secure && {
secure: true
}
};
return compact(cookie);
}
//# sourceMappingURL=serialize.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/serialize.ts"],"names":["serialize","parseCookieString","parseSetCookieString","SAME_SITE","parseSameSite","string","toLowerCase","includes","undefined","compact","t","newT","key","c","attrs","path","expires","toUTCString","maxAge","domain","secure","httpOnly","sameSite","filter","Boolean","name","encodeURIComponent","value","join","cookie","map","Map","pair","split","set","decodeURIComponent","setCookie","attributes","httponly","maxage","samesite","Object","fromEntries","v","Date","Number"],"mappings":"AAAA;;;;QAoBgBA,SAAS,GAATA,SAAS;QAiBTC,iBAAiB,GAAjBA,iBAAiB;QAejBC,oBAAoB,GAApBA,oBAAoB;AAlDpC,MAAMC,SAAS,GAAiC;IAAC,QAAQ;IAAE,KAAK;IAAE,MAAM;CAAC;AACzE,SAASC,aAAa,CAACC,MAAc,EAA8B;IACjEA,MA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OAAO,EAAE,IAAI4B,IAAI,CAAC5B,OAAO,CAAC;SAAE;QAC7C,GAAIsB,QAAQ,IAAI;YAAEjB,QAAQ,EAAE,IAAI;SAAE;QAClC,GAAI,OAAOkB,MAAM,KAAK,QAAQ,IAAI;YAAErB,MAAM,EAAE2B,MAAM,CAACN,MAAM,CAAC;SAAE;QAC5DxB,IAAI;QACJ,GAAIyB,QAAQ,IAAI;YAAElB,QAAQ,EAAElB,aAAa,CAACoC,QAAQ,CAAC;SAAE;QACrD,GAAIpB,MAAM,IAAI;YAAEA,MAAM,EAAE,IAAI;SAAE;KAC/B;IAED,OAAOX,OAAO,CAACoB,MAAM,CAAC,CAAA;CACvB"}

View File

@@ -0,0 +1,101 @@
export interface CookieSerializeOptions {
/**
* Specifies the value for the Domain Set-Cookie attribute. By default, no
* domain is set, and most clients will consider the cookie to apply to only
* the current domain.
*/
domain?: string;
/**
* Specifies a function that will be used to encode a cookie's value. Since
* value of a cookie has a limited character set (and must be a simple
* string), this function can be used to encode a value into a string suited
* for a cookie's value.
*
* The default function is the global `encodeURIComponent`, which will
* encode a JavaScript string into UTF-8 byte sequences and then URL-encode
* any that fall outside of the cookie range.
*/
encode?(val: string): string;
/**
* Specifies the `Date` object to be the value for the `Expires`
* `Set-Cookie` attribute. By default, no expiration is set, and most
* clients will consider this a "non-persistent cookie" and will delete it
* on a condition like exiting a web browser application.
*
* *Note* the cookie storage model specification states that if both
* `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
* possible not all clients by obey this, so if both are set, they should
* point to the same date and time.
*/
expires?: Date;
/**
* Specifies the boolean value for the `HttpOnly` `Set-Cookie` attribute.
* When truthy, the `HttpOnly` attribute is set, otherwise it is not. By
* default, the `HttpOnly` attribute is not set.
*
* *Note* be careful when setting this to true, as compliant clients will
* not allow client-side JavaScript to see the cookie in `document.cookie`.
*/
httpOnly?: boolean;
/**
* Specifies the number (in seconds) to be the value for the `Max-Age`
* `Set-Cookie` attribute. The given number will be converted to an integer
* by rounding down. By default, no maximum age is set.
*
* *Note* the cookie storage model specification states that if both
* `expires` and `maxAge` are set, then `maxAge` takes precedence, but it is
* possible not all clients by obey this, so if both are set, they should
* point to the same date and time.
*/
maxAge?: number;
/**
* Specifies the value for the `Path` `Set-Cookie` attribute. By default,
* the path is considered the "default path".
*/
path?: string;
/**
* Specifies the boolean or string to be the value for the `SameSite`
* `Set-Cookie` attribute.
*
* - `true` will set the `SameSite` attribute to `Strict` for strict same
* site enforcement.
* - `false` will not set the `SameSite` attribute.
* - `'lax'` will set the `SameSite` attribute to Lax for lax same site
* enforcement.
* - `'strict'` will set the `SameSite` attribute to Strict for strict same
* site enforcement.
* - `'none'` will set the SameSite attribute to None for an explicit
* cross-site cookie.
*/
sameSite?: boolean | 'lax' | 'strict' | 'none';
/**
* Specifies the boolean value for the `Secure` `Set-Cookie` attribute. When
* truthy, the `Secure` attribute is set, otherwise it is not. By default,
* the `Secure` attribute is not set.
*
* *Note* be careful when setting this to `true`, as compliant clients will
* not send the cookie back to the server in the future if the browser does
* not have an HTTPS connection.
*/
secure?: boolean;
}
/**
* {@link https://wicg.github.io/cookie-store/#dictdef-cookielistitem CookieListItem}
* as specified by W3C.
*/
export interface CookieListItem extends Partial<Pick<CookieSerializeOptions, 'domain' | 'path' | 'expires' | 'secure' | 'sameSite'>> {
/** A string with the name of a cookie. */
name: string;
/** A string containing the value of the cookie. */
value: string;
}
/**
* Superset of {@link CookieListItem} extending it with
* the `httpOnly`, `maxAge` and `priority` properties.
*/
export declare type ResponseCookie = CookieListItem & Partial<Pick<CookieSerializeOptions, 'httpOnly' | 'maxAge'>>;
/**
* Subset of {@link CookieListItem}, only containing `name` and `value`
* since other cookie attributes aren't be available on a `Request`.
*/
export declare type RequestCookie = Pick<CookieListItem, 'name' | 'value'>;

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../../server/web/spec-extension/cookies/types.ts"],"names":[],"mappings":"AAAA"}

View File

@@ -0,0 +1,33 @@
import { NextRequest } from './request';
declare const responseSymbol: unique symbol;
declare const passThroughSymbol: unique symbol;
export declare const waitUntilSymbol: unique symbol;
declare class FetchEvent {
readonly [waitUntilSymbol]: Promise<any>[];
[responseSymbol]?: Promise<Response>;
[passThroughSymbol]: boolean;
constructor(_request: Request);
respondWith(response: Response | Promise<Response>): void;
passThroughOnException(): void;
waitUntil(promise: Promise<any>): void;
}
export declare class NextFetchEvent extends FetchEvent {
sourcePage: string;
constructor(params: {
request: NextRequest;
page: string;
});
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
get request(): void;
/**
* @deprecated Using `respondWith` is no longer needed.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/
respondWith(): void;
}
export {};

View File

@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.waitUntilSymbol = void 0;
var _error = require("../error");
const responseSymbol = Symbol("response");
const passThroughSymbol = Symbol("passThrough");
const waitUntilSymbol = Symbol("waitUntil");
exports.waitUntilSymbol = waitUntilSymbol;
class FetchEvent {
[waitUntilSymbol] = [];
[passThroughSymbol] = false;
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(_request){}
respondWith(response) {
if (!this[responseSymbol]) {
this[responseSymbol] = Promise.resolve(response);
}
}
passThroughOnException() {
this[passThroughSymbol] = true;
}
waitUntil(promise) {
this[waitUntilSymbol].push(promise);
}
}
class NextFetchEvent extends FetchEvent {
constructor(params){
super(params.request);
this.sourcePage = params.page;
}
/**
* @deprecated The `request` is now the first parameter and the API is now async.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/ get request() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
/**
* @deprecated Using `respondWith` is no longer needed.
*
* Read more: https://nextjs.org/docs/messages/middleware-new-signature
*/ respondWith() {
throw new _error.PageSignatureError({
page: this.sourcePage
});
}
}
exports.NextFetchEvent = NextFetchEvent;
//# sourceMappingURL=fetch-event.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/spec-extension/fetch-event.ts"],"names":["responseSymbol","Symbol","passThroughSymbol","waitUntilSymbol","FetchEvent","constructor","_request","respondWith","response","Promise","resolve","passThroughOnException","waitUntil","promise","push","NextFetchEvent","params","request","sourcePage","page","PageSignatureError"],"mappings":"AAAA;;;;;AAAmC,IAAA,MAAU,WAAV,UAAU,CAAA;AAG7C,MAAMA,cAAc,GAAGC,MAAM,CAAC,UAAU,CAAC;AACzC,MAAMC,iBAAiB,GAAGD,MAAM,CAAC,aAAa,CAAC;AACxC,MAAME,eAAe,GAAGF,MAAM,CAAC,WAAW,CAAC;QAArCE,eAAe,GAAfA,eAAe;AAE5B,MAAMC,UAAU;IACL,CAACD,eAAe,CAAC,GAAmB,EAAE,CAAC;IAEhD,CAACD,iBAAiB,CAAC,GAAG,KAAK,CAAA;IAE3B,qEAAqE;IACrEG,YAAYC,QAAiB,CAAE,EAAE;IAEjCC,WAAW,CAACC,QAAsC,EAAQ;QACxD,IAAI,CAAC,IAAI,CAACR,cAAc,CAAC,EAAE;YACzB,IAAI,CAACA,cAAc,CAAC,GAAGS,OAAO,CAACC,OAAO,CAACF,QAAQ,CAAC;SACjD;KACF;IAEDG,sBAAsB,GAAS;QAC7B,IAAI,CAACT,iBAAiB,CAAC,GAAG,IAAI;KAC/B;IAEDU,SAAS,CAACC,OAAqB,EAAQ;QACrC,IAAI,CAACV,eAAe,CAAC,CAACW,IAAI,CAACD,OAAO,CAAC;KACpC;CACF;AAEM,MAAME,cAAc,SAASX,UAAU;IAG5CC,YAAYW,MAA8C,CAAE;QAC1D,KAAK,CAACA,MAAM,CAACC,OAAO,CAAC;QACrB,IAAI,CAACC,UAAU,GAAGF,MAAM,CAACG,IAAI;KAC9B;IAED;;;;KAIG,CACH,IAAIF,OAAO,GAAG;QACZ,MAAM,IAAIG,MAAkB,mBAAA,CAAC;YAC3BD,IAAI,EAAE,IAAI,CAACD,UAAU;SACtB,CAAC,CAAA;KACH;IAED;;;;KAIG,CACHX,WAAW,GAAG;QACZ,MAAM,IAAIa,MAAkB,mBAAA,CAAC;YAC3BD,IAAI,EAAE,IAAI,CAACD,UAAU;SACtB,CAAC,CAAA;KACH;CACF;QA7BYH,cAAc,GAAdA,cAAc"}

View File

@@ -0,0 +1,50 @@
import type { I18NConfig } from '../../config-shared';
import type { RequestData } from '../types';
import { NextURL } from '../next-url';
import { RequestCookies } from './cookies';
export declare const INTERNALS: unique symbol;
export declare class NextRequest extends Request {
[INTERNALS]: {
cookies: RequestCookies;
geo: RequestData['geo'];
ip?: string;
url: NextURL;
};
constructor(input: URL | RequestInfo, init?: RequestInit);
get cookies(): RequestCookies;
get geo(): {
city?: string | undefined;
country?: string | undefined;
region?: string | undefined;
latitude?: string | undefined;
longitude?: string | undefined;
} | undefined;
get ip(): string | undefined;
get nextUrl(): NextURL;
/**
* @deprecated
* `page` has been deprecated in favour of `URLPattern`.
* Read more: https://nextjs.org/docs/messages/middleware-request-page
*/
get page(): void;
/**
* @deprecated
* `ua` has been removed in favour of \`userAgent\` function.
* Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
*/
get ua(): void;
get url(): string;
}
export interface RequestInit extends globalThis.RequestInit {
geo?: {
city?: string;
country?: string;
region?: string;
};
ip?: string;
nextConfig?: {
basePath?: string;
i18n?: I18NConfig | null;
trailingSlash?: boolean;
};
}

View File

@@ -0,0 +1,82 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.INTERNALS = void 0;
var _nextUrl = require("../next-url");
var _utils = require("../utils");
var _error = require("../error");
var _cookies = require("./cookies");
const INTERNALS = Symbol("internal request");
exports.INTERNALS = INTERNALS;
class NextRequest extends Request {
constructor(input, init = {}){
const url = typeof input !== "string" && "url" in input ? input.url : String(input);
(0, _utils).validateURL(url);
super(url, init);
this[INTERNALS] = {
cookies: new _cookies.RequestCookies(this.headers),
geo: init.geo || {},
ip: init.ip,
url: new _nextUrl.NextURL(url, {
headers: (0, _utils).toNodeHeaders(this.headers),
nextConfig: init.nextConfig
})
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
geo: this.geo,
ip: this.ip,
nextUrl: this.nextUrl,
url: this.url,
// rest of props come from Request
bodyUsed: this.bodyUsed,
cache: this.cache,
credentials: this.credentials,
destination: this.destination,
headers: Object.fromEntries(this.headers),
integrity: this.integrity,
keepalive: this.keepalive,
method: this.method,
mode: this.mode,
redirect: this.redirect,
referrer: this.referrer,
referrerPolicy: this.referrerPolicy,
signal: this.signal
};
}
get cookies() {
return this[INTERNALS].cookies;
}
get geo() {
return this[INTERNALS].geo;
}
get ip() {
return this[INTERNALS].ip;
}
get nextUrl() {
return this[INTERNALS].url;
}
/**
* @deprecated
* `page` has been deprecated in favour of `URLPattern`.
* Read more: https://nextjs.org/docs/messages/middleware-request-page
*/ get page() {
throw new _error.RemovedPageError();
}
/**
* @deprecated
* `ua` has been removed in favour of \`userAgent\` function.
* Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
*/ get ua() {
throw new _error.RemovedUAError();
}
get url() {
return this[INTERNALS].url.toString();
}
}
exports.NextRequest = NextRequest;
//# sourceMappingURL=request.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/spec-extension/request.ts"],"names":["INTERNALS","Symbol","NextRequest","Request","constructor","input","init","url","String","validateURL","cookies","RequestCookies","headers","geo","ip","NextURL","toNodeHeaders","nextConfig","for","nextUrl","bodyUsed","cache","credentials","destination","Object","fromEntries","integrity","keepalive","method","mode","redirect","referrer","referrerPolicy","signal","page","RemovedPageError","ua","RemovedUAError","toString"],"mappings":"AAAA;;;;;AAEwB,IAAA,QAAa,WAAb,aAAa,CAAA;AACM,IAAA,MAAU,WAAV,UAAU,CAAA;AACJ,IAAA,MAAU,WAAV,UAAU,CAAA;AAC5B,IAAA,QAAW,WAAX,WAAW,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AACA,WAAW;YAC7BX,OAAO,EAAEY,MAAM,CAACC,WAAW,CAAC,IAAI,CAACb,OAAO,CAAC;YACzCc,SAAS,EAAE,IAAI,CAACA,SAAS;YACzBC,SAAS,EAAE,IAAI,CAACA,SAAS;YACzBC,MAAM,EAAE,IAAI,CAACA,MAAM;YACnBC,IAAI,EAAE,IAAI,CAACA,IAAI;YACfC,QAAQ,EAAE,IAAI,CAACA,QAAQ;YACvBC,QAAQ,EAAE,IAAI,CAACA,QAAQ;YACvBC,cAAc,EAAE,IAAI,CAACA,cAAc;YACnCC,MAAM,EAAE,IAAI,CAACA,MAAM;SACpB,CAAA;KACF;IAED,IAAWvB,OAAO,GAAG;QACnB,OAAO,IAAI,CAACV,SAAS,CAAC,CAACU,OAAO,CAAA;KAC/B;IAED,IAAWG,GAAG,GAAG;QACf,OAAO,IAAI,CAACb,SAAS,CAAC,CAACa,GAAG,CAAA;KAC3B;IAED,IAAWC,EAAE,GAAG;QACd,OAAO,IAAI,CAACd,SAAS,CAAC,CAACc,EAAE,CAAA;KAC1B;IAED,IAAWK,OAAO,GAAG;QACnB,OAAO,IAAI,CAACnB,SAAS,CAAC,CAACO,GAAG,CAAA;KAC3B;IAED;;;;KAIG,CACH,IAAW2B,IAAI,GAAG;QAChB,MAAM,IAAIC,MAAgB,iBAAA,EAAE,CAAA;KAC7B;IAED;;;;KAIG,CACH,IAAWC,EAAE,GAAG;QACd,MAAM,IAAIC,MAAc,eAAA,EAAE,CAAA;KAC3B;IAED,IAAW9B,GAAG,GAAG;QACf,OAAO,IAAI,CAACP,SAAS,CAAC,CAACO,GAAG,CAAC+B,QAAQ,EAAE,CAAA;KACtC;CACF;QArFYpC,WAAW,GAAXA,WAAW"}

View File

@@ -0,0 +1,37 @@
import type { I18NConfig } from '../../config-shared';
import { NextURL } from '../next-url';
import { ResponseCookies } from './cookies';
declare const INTERNALS: unique symbol;
export declare class NextResponse extends Response {
[INTERNALS]: {
cookies: ResponseCookies;
url?: NextURL;
};
constructor(body?: BodyInit | null, init?: ResponseInit);
get cookies(): ResponseCookies;
static json(body: any, init?: ResponseInit): NextResponse;
static redirect(url: string | NextURL | URL, init?: number | ResponseInit): NextResponse;
static rewrite(destination: string | NextURL | URL, init?: MiddlewareResponseInit): NextResponse;
static next(init?: MiddlewareResponseInit): NextResponse;
}
interface ResponseInit extends globalThis.ResponseInit {
nextConfig?: {
basePath?: string;
i18n?: I18NConfig;
trailingSlash?: boolean;
};
url?: string;
}
interface ModifiedRequest {
/**
* If this is set, the request headers will be overridden with this value.
*/
headers?: Headers;
}
interface MiddlewareResponseInit extends globalThis.ResponseInit {
/**
* These fields will override the request from clients.
*/
request?: ModifiedRequest;
}
export {};

View File

@@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _nextUrl = require("../next-url");
var _utils = require("../utils");
var _cookies = require("./cookies");
const INTERNALS = Symbol("internal response");
const REDIRECTS = new Set([
301,
302,
303,
307,
308
]);
function handleMiddlewareField(init, headers) {
var ref;
if (init == null ? void 0 : (ref = init.request) == null ? void 0 : ref.headers) {
if (!(init.request.headers instanceof Headers)) {
throw new Error("request.headers must be an instance of Headers");
}
const keys = [];
for (const [key, value] of init.request.headers){
headers.set("x-middleware-request-" + key, value);
keys.push(key);
}
headers.set("x-middleware-override-headers", keys.join(","));
}
}
class NextResponse extends Response {
constructor(body, init = {}){
super(body, init);
this[INTERNALS] = {
cookies: new _cookies.ResponseCookies(this.headers),
url: init.url ? new _nextUrl.NextURL(init.url, {
headers: (0, _utils).toNodeHeaders(this.headers),
nextConfig: init.nextConfig
}) : undefined
};
}
[Symbol.for("edge-runtime.inspect.custom")]() {
return {
cookies: this.cookies,
url: this.url,
// rest of props come from Response
body: this.body,
bodyUsed: this.bodyUsed,
headers: Object.fromEntries(this.headers),
ok: this.ok,
redirected: this.redirected,
status: this.status,
statusText: this.statusText,
type: this.type
};
}
get cookies() {
return this[INTERNALS].cookies;
}
static json(body, init) {
// @ts-expect-error This is not in lib/dom right now, and we can't augment it.
const response = Response.json(body, init);
return new NextResponse(response.body, response);
}
static redirect(url, init) {
const status = typeof init === "number" ? init : (init == null ? void 0 : init.status) ?? 307;
if (!REDIRECTS.has(status)) {
throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
}
const initObj = typeof init === "object" ? init : {};
const headers = new Headers(initObj == null ? void 0 : initObj.headers);
headers.set("Location", (0, _utils).validateURL(url));
return new NextResponse(null, {
...initObj,
headers,
status
});
}
static rewrite(destination, init) {
const headers = new Headers(init == null ? void 0 : init.headers);
headers.set("x-middleware-rewrite", (0, _utils).validateURL(destination));
handleMiddlewareField(init, headers);
return new NextResponse(null, {
...init,
headers
});
}
static next(init) {
const headers = new Headers(init == null ? void 0 : init.headers);
headers.set("x-middleware-next", "1");
handleMiddlewareField(init, headers);
return new NextResponse(null, {
...init,
headers
});
}
}
exports.NextResponse = NextResponse;
//# sourceMappingURL=response.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/spec-extension/response.ts"],"names":["INTERNALS","Symbol","REDIRECTS","Set","handleMiddlewareField","init","headers","request","Headers","Error","keys","key","value","set","push","join","NextResponse","Response","constructor","body","cookies","ResponseCookies","url","NextURL","toNodeHeaders","nextConfig","undefined","for","bodyUsed","Object","fromEntries","ok","redirected","status","statusText","type","json","response","redirect","has","RangeError","initObj","validateURL","rewrite","destination","next"],"mappings":"AAAA;;;;AACwB,IAAA,QAAa,WAAb,aAAa,CAAA;AACM,IAAA,MAAU,WAAV,UAAU,CAAA;AAErB,IAAA,QAAW,WAAX,WAAW,CAAA;AAE3C,MAAMA,SAAS,GAAGC,MAAM,CAAC,mBAAmB,CAAC;AAC7C,MAAMC,SAAS,GAAG,IAAIC,GAAG,CAAC;AAAC,OAAG;AAAE,OAAG;AAAE,OAAG;AAAE,OAAG;AAAE,OAAG;CAAC,CAAC;AAEpD,SAASC,qBAAqB,CAC5BC,IAAwC,EACxCC,OAAgB,EAChB;QACID,GAAa;IAAjB,IAAIA,I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,KAAAA,CAAgB,GAAhBA,OAAO,CAAEnC,OAAO,CAAC;QAC7CA,OAAO,CAACO,GAAG,CAAC,UAAU,EAAE6B,CAAAA,GAAAA,MAAW,AAAK,CAAA,YAAL,CAACpB,GAAG,CAAC,CAAC;QAEzC,OAAO,IAAIN,YAAY,CAAC,IAAI,EAAE;YAC5B,GAAGyB,OAAO;YACVnC,OAAO;YACP2B,MAAM;SACP,CAAC,CAAA;KACH;IAED,OAAOU,OAAO,CACZC,WAAmC,EACnCvC,IAA6B,EAC7B;QACA,MAAMC,OAAO,GAAG,IAAIE,OAAO,CAACH,IAAI,QAAS,GAAbA,KAAAA,CAAa,GAAbA,IAAI,CAAEC,OAAO,CAAC;QAC1CA,OAAO,CAACO,GAAG,CAAC,sBAAsB,EAAE6B,CAAAA,GAAAA,MAAW,AAAa,CAAA,YAAb,CAACE,WAAW,CAAC,CAAC;QAE7DxC,qBAAqB,CAACC,IAAI,EAAEC,OAAO,CAAC;QACpC,OAAO,IAAIU,YAAY,CAAC,IAAI,EAAE;YAAE,GAAGX,IAAI;YAAEC,OAAO;SAAE,CAAC,CAAA;KACpD;IAED,OAAOuC,IAAI,CAACxC,IAA6B,EAAE;QACzC,MAAMC,OAAO,GAAG,IAAIE,OAAO,CAACH,IAAI,QAAS,GAAbA,KAAAA,CAAa,GAAbA,IAAI,CAAEC,OAAO,CAAC;QAC1CA,OAAO,CAACO,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC;QAErCT,qBAAqB,CAACC,IAAI,EAAEC,OAAO,CAAC;QACpC,OAAO,IAAIU,YAAY,CAAC,IAAI,EAAE;YAAE,GAAGX,IAAI;YAAEC,OAAO;SAAE,CAAC,CAAA;KACpD;CACF;QAlFYU,YAAY,GAAZA,YAAY"}

View File

@@ -0,0 +1,30 @@
interface UserAgent {
isBot: boolean;
ua: string;
browser: {
name?: string;
version?: string;
};
device: {
model?: string;
type?: string;
vendor?: string;
};
engine: {
name?: string;
version?: string;
};
os: {
name?: string;
version?: string;
};
cpu: {
architecture?: string;
};
}
export declare function isBot(input: string): boolean;
export declare function userAgentFromString(input: string | undefined): UserAgent;
export declare function userAgent({ headers }: {
headers: Headers;
}): UserAgent;
export {};

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isBot = isBot;
exports.userAgentFromString = userAgentFromString;
exports.userAgent = userAgent;
var _uaParserJs = _interopRequireDefault(require("next/dist/compiled/ua-parser-js"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function isBot(input) {
return /Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(input);
}
function userAgentFromString(input) {
return {
...(0, _uaParserJs).default(input),
isBot: input === undefined ? false : isBot(input)
};
}
function userAgent({ headers }) {
return userAgentFromString(headers.get("user-agent") || undefined);
}
//# sourceMappingURL=user-agent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../server/web/spec-extension/user-agent.ts"],"names":["isBot","userAgentFromString","userAgent","input","test","parseua","undefined","headers","get"],"mappings":"AAAA;;;;QA2BgBA,KAAK,GAALA,KAAK;QAMLC,mBAAmB,GAAnBA,mBAAmB;QAOnBC,SAAS,GAATA,SAAS;AAxCL,IAAA,WAAiC,kCAAjC,iCAAiC,EAAA;;;;;;AA2B9C,SAASF,KAAK,CAACG,KAAa,EAAW;IAC5C,OAAO,oVAAoVC,IAAI,CAC7VD,KAAK,CACN,CAAA;CACF;AAEM,SAASF,mBAAmB,CAACE,KAAyB,EAAa;IACxE,OAAO;QACL,GAAGE,CAAAA,GAAAA,WAAO,AAAO,CAAA,QAAP,CAACF,KAAK,CAAC;QACjBH,KAAK,EAAEG,KAAK,KAAKG,SAAS,GAAG,KAAK,GAAGN,KAAK,CAACG,KAAK,CAAC;KAClD,CAAA;CACF;AAEM,SAASD,SAAS,CAAC,EAAEK,OAAO,CAAA,EAAwB,EAAa;IACtE,OAAON,mBAAmB,CAACM,OAAO,CAACC,GAAG,CAAC,YAAY,CAAC,IAAIF,SAAS,CAAC,CAAA;CACnE"}

View File

@@ -0,0 +1,42 @@
import type { I18NConfig } from '../config-shared';
import type { NextRequest } from '../web/spec-extension/request';
import type { NextFetchEvent } from '../web/spec-extension/fetch-event';
import type { NextResponse } from './spec-extension/response';
import type { ClonableBody } from '../body-streams';
export interface NodeHeaders {
[header: string]: string | string[] | undefined;
}
export interface RequestData {
geo?: {
city?: string;
country?: string;
region?: string;
latitude?: string;
longitude?: string;
};
headers: NodeHeaders;
ip?: string;
method: string;
nextConfig?: {
basePath?: string;
i18n?: I18NConfig | null;
trailingSlash?: boolean;
};
page?: {
name?: string;
params?: {
[key: string]: string;
};
};
url: string;
body?: ReadableStream<Uint8Array>;
}
export declare type NodejsRequestData = Omit<RequestData, 'body'> & {
body?: ClonableBody;
};
export interface FetchEventResult {
response: Response;
waitUntil: Promise<any>;
}
export declare type NextMiddlewareResult = NextResponse | Response | null | undefined | void;
export declare type NextMiddleware = (request: NextRequest, event: NextFetchEvent) => NextMiddlewareResult | Promise<NextMiddlewareResult>;

View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../server/web/types.ts"],"names":[],"mappings":"AAAA"}

View File

@@ -0,0 +1,8 @@
import type { NodeHeaders } from './types';
export declare function fromNodeHeaders(object: NodeHeaders): Headers;
export declare function splitCookiesString(cookiesString: string): string[];
export declare function toNodeHeaders(headers?: Headers): NodeHeaders;
/**
* Validate the correctness of a user-provided URL.
*/
export declare function validateURL(url: string | URL): string;

100
kitabcitab/node_modules/next/dist/server/web/utils.js generated vendored Normal file
View File

@@ -0,0 +1,100 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fromNodeHeaders = fromNodeHeaders;
exports.splitCookiesString = splitCookiesString;
exports.toNodeHeaders = toNodeHeaders;
exports.validateURL = validateURL;
function fromNodeHeaders(object) {
const headers = new Headers();
for (let [key, value] of Object.entries(object)){
const values = Array.isArray(value) ? value : [
value
];
for (let v of values){
if (v !== undefined) {
headers.append(key, v);
}
}
}
return headers;
}
function splitCookiesString(cookiesString) {
var cookiesStrings = [];
var pos = 0;
var start;
var ch;
var lastComma;
var nextStart;
var cookiesSeparatorFound;
function skipWhitespace() {
while(pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))){
pos += 1;
}
return pos < cookiesString.length;
}
function notSpecialChar() {
ch = cookiesString.charAt(pos);
return ch !== "=" && ch !== ";" && ch !== ",";
}
while(pos < cookiesString.length){
start = pos;
cookiesSeparatorFound = false;
while(skipWhitespace()){
ch = cookiesString.charAt(pos);
if (ch === ",") {
// ',' is a cookie separator if we have later first '=', not ';' or ','
lastComma = pos;
pos += 1;
skipWhitespace();
nextStart = pos;
while(pos < cookiesString.length && notSpecialChar()){
pos += 1;
}
// currently special character
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
// we found cookies separator
cookiesSeparatorFound = true;
// pos is inside the next cookie, so back up and return it.
pos = nextStart;
cookiesStrings.push(cookiesString.substring(start, lastComma));
start = pos;
} else {
// in param ',' or param separator ';',
// we continue from that comma
pos = lastComma + 1;
}
} else {
pos += 1;
}
}
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
}
}
return cookiesStrings;
}
function toNodeHeaders(headers) {
const result = {};
if (headers) {
for (const [key, value] of headers.entries()){
result[key] = value;
if (key.toLowerCase() === "set-cookie") {
result[key] = splitCookiesString(value);
}
}
}
return result;
}
function validateURL(url) {
try {
return String(new URL(String(url)));
} catch (error) {
throw new Error(`URL is malformed "${String(url)}". Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls`, {
cause: error
});
}
}
//# sourceMappingURL=utils.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../server/web/utils.ts"],"names":["fromNodeHeaders","splitCookiesString","toNodeHeaders","validateURL","object","headers","Headers","key","value","Object","entries","values","Array","isArray","v","undefined","append","cookiesString","cookiesStrings","pos","start","ch","lastComma","nextStart","cookiesSeparatorFound","skipWhitespace","length","test","charAt","notSpecialChar","push","substring","result","toLowerCase","url","String","URL","error","Error","cause"],"mappings":"AAAA;;;;QAEgBA,eAAe,GAAfA,eAAe;QAuBfC,kBAAkB,GAAlBA,kBAAkB;QAkElBC,aAAa,GAAbA,aAAa;QAgBbC,WAAW,GAAXA,WAAW;AAzGpB,SAASH,eAAe,CAACI,MAAmB,EAAW;IAC5D,MAAMC,OAAO,GAAG,IAAIC,OAAO,EAAE;IAC7B,KAAK,IAAI,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,MAAM,CAAC,CAAE;QAC/C,MAAMO,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC,GAAGA,KAAK,GAAG;YAACA,KAAK;SAAC;QACrD,KAAK,IAAIM,CAAC,IAAIH,MAAM,CAAE;YACpB,IAAIG,CAAC,KAAKC,SAAS,EAAE;gBACnBV,OAAO,CAACW,MAAM,CAACT,GAAG,EAAEO,CAAC,CAAC;aACvB;SACF;KACF;IACD,OAAOT,OAAO,CAAA;CACf;AAYM,SAASJ,kBAAkB,CAACgB,aAAqB,EAAE;IACxD,IAAIC,cAAc,GAAG,EAAE;IACvB,IAAIC,GAAG,GAAG,CAAC;IACX,IAAIC,KAAK;IACT,IAAIC,EAAE;IACN,IAAIC,SAAS;IACb,IAAIC,SAAS;IACb,IAAIC,qBAAqB;IAEzB,SAASC,cAAc,GAAG;QACxB,MAAON,GAAG,GAAGF,aAAa,CAACS,MAAM,IAAI,KAAKC,IAAI,CAACV,aA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