@shopify/remix-oxygen
Advanced tools
Comparing version 0.0.0-next-ec9cb2f-20240122090404 to 0.0.0-next-ed2657b-20240909175901
import { createCookieFactory, createCookieSessionStorageFactory, createSessionStorageFactory, createMemorySessionStorageFactory, createRequestHandler as createRequestHandler$1 } from '@remix-run/server-runtime'; | ||
export { MaxPartSizeExceededError, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
export { MaxPartSizeExceededError, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_defineAction, unstable_defineLoader, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
@@ -57,4 +57,3 @@ // src/implementations.ts | ||
const eventLoggerService = context?.env?.H2O_LOG_EVENT; | ||
if (typeof eventLoggerService?.fetch !== "function") | ||
return; | ||
if (typeof eventLoggerService?.fetch !== "function") return; | ||
return ({ | ||
@@ -99,5 +98,20 @@ url, | ||
return async (request) => { | ||
const method = request.method; | ||
if ((method === "GET" || method === "HEAD") && request.body) { | ||
return new Response(`${method} requests cannot have a body`, { | ||
status: 400 | ||
}); | ||
} | ||
const url = new URL(request.url); | ||
if (url.pathname.includes("//")) { | ||
return new Response(null, { | ||
status: 301, | ||
headers: { | ||
location: url.pathname.replace(/\/+/g, "/") | ||
} | ||
}); | ||
} | ||
const context = getLoadContext ? await getLoadContext(request) : void 0; | ||
if (context) { | ||
globalThis.__H2O_LOG_EVENT = createEventLogger(context); | ||
globalThis.__H2O_LOG_EVENT ??= createEventLogger(context); | ||
} | ||
@@ -104,0 +118,0 @@ const startTime = Date.now(); |
import * as _remix_run_server_runtime from '@remix-run/server-runtime'; | ||
import { ServerBuild } from '@remix-run/server-runtime'; | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, JsonFunction, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MaxPartSizeExceededError, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, ServerRuntimeMetaArgs as MetaArgs, ServerRuntimeMetaDescriptor as MetaDescriptor, ServerRuntimeMetaFunction as MetaFunction, PageLinkDescriptor, RequestHandler, SerializeFrom, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedDeferredData, TypedResponse, UnsignFunction, UploadHandler, UploadHandlerPart, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
export { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, JsonFunction, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MaxPartSizeExceededError, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, ServerRuntimeMetaArgs as MetaArgs, ServerRuntimeMetaDescriptor as MetaDescriptor, ServerRuntimeMetaFunction as MetaFunction, PageLinkDescriptor, RequestHandler, SerializeFrom, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedDeferredData, TypedResponse, UnsignFunction, UploadHandler, UploadHandlerPart, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_defineAction, unstable_defineLoader, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
@@ -10,24 +10,4 @@ declare const createCookie: _remix_run_server_runtime.CreateCookieFunction; | ||
type H2OEvent = { | ||
url: string; | ||
eventType: 'request' | 'subrequest'; | ||
requestId?: string | null; | ||
purpose?: string | null; | ||
startTime: number; | ||
endTime?: number; | ||
cacheStatus?: 'MISS' | 'HIT' | 'STALE' | 'PUT'; | ||
waitUntil?: ExecutionContext['waitUntil']; | ||
stackInfo?: { | ||
file?: string; | ||
func?: string; | ||
line?: number; | ||
column?: number; | ||
}; | ||
}; | ||
declare global { | ||
var __H2O_LOG_EVENT: undefined | ((event: H2OEvent) => void); | ||
} | ||
declare function createRequestHandler<Context = unknown>({ build, mode, poweredByHeader, getLoadContext, }: { | ||
build: Omit<ServerBuild, 'isSpaMode'>; | ||
build: ServerBuild; | ||
mode?: string; | ||
@@ -34,0 +14,0 @@ poweredByHeader?: boolean; |
import { createCookieFactory, createCookieSessionStorageFactory, createSessionStorageFactory, createMemorySessionStorageFactory, createRequestHandler } from '@remix-run/server-runtime'; | ||
export { MaxPartSizeExceededError, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
export { MaxPartSizeExceededError, createSession, defer, isCookie, isSession, json, redirect, redirectDocument, unstable_composeUploadHandlers, unstable_createMemoryUploadHandler, unstable_defineAction, unstable_defineLoader, unstable_parseMultipartFormData } from '@remix-run/server-runtime'; | ||
var c=new TextEncoder,d=async(e,t)=>{let r=await g(t,["sign"]),o=c.encode(e),s=await crypto.subtle.sign("HMAC",r,o),n=btoa(String.fromCharCode(...new Uint8Array(s))).replace(/=+$/,"");return e+"."+n},l=async(e,t)=>{let r=e.lastIndexOf("."),o=e.slice(0,r),s=e.slice(r+1),n=await g(t,["verify"]),a=c.encode(o),p=S(atob(s));return await crypto.subtle.verify("HMAC",n,p,a)?o:!1};async function g(e,t){return await crypto.subtle.importKey("raw",c.encode(e),{name:"HMAC",hash:"SHA-256"},!1,t)}function S(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var u=createCookieFactory({sign:d,unsign:l}),C=createCookieSessionStorageFactory(u),y=createSessionStorageFactory(u),F=createMemorySessionStorageFactory(y);var v=Error.prototype.toString;Error.prototype.toString=function(){return this.stack||v.call(this)};function E({build:e,mode:t,poweredByHeader:r=!0,getLoadContext:o}){let s=createRequestHandler(e,t);return async n=>{let a=o?await o(n):void 0,i=await s(n,a);return r&&i.headers.append("powered-by","Shopify, Hydrogen"),i}}function h(e){let t=e.headers;return {requestGroupId:t.get("request-id"),buyerIp:t.get("oxygen-buyer-ip"),cookie:t.get("cookie"),purpose:t.get("purpose")}} | ||
var c=new TextEncoder,l=async(e,t)=>{let r=await y(t,["sign"]),n=c.encode(e),s=await crypto.subtle.sign("HMAC",r,n),o=btoa(String.fromCharCode(...new Uint8Array(s))).replace(/=+$/,"");return e+"."+o},g=async(e,t)=>{let r=e.lastIndexOf("."),n=e.slice(0,r),s=e.slice(r+1),o=await y(t,["verify"]),a=c.encode(n),i=m(atob(s));return await crypto.subtle.verify("HMAC",o,i,a)?n:!1};async function y(e,t){return await crypto.subtle.importKey("raw",c.encode(e),{name:"HMAC",hash:"SHA-256"},!1,t)}function m(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var u=createCookieFactory({sign:l,unsign:g}),C=createCookieSessionStorageFactory(u),S=createSessionStorageFactory(u),F=createMemorySessionStorageFactory(S);var A=Error.prototype.toString;Error.prototype.toString=function(){return this.stack||A.call(this)};function E({build:e,mode:t,poweredByHeader:r=!0,getLoadContext:n}){let s=createRequestHandler(e,t);return async o=>{let a=o.method;if((a==="GET"||a==="HEAD")&&o.body)return new Response(`${a} requests cannot have a body`,{status:400});let i=new URL(o.url);if(i.pathname.includes("//"))return new Response(null,{status:301,headers:{location:i.pathname.replace(/\/+/g,"/")}});let p=n?await n(o):void 0,d=await s(o,p);return r&&d.headers.append("powered-by","Shopify, Hydrogen"),d}}function v(e){let t=e.headers;return {requestGroupId:t.get("request-id"),buyerIp:t.get("oxygen-buyer-ip"),cookie:t.get("cookie"),purpose:t.get("purpose")}} | ||
export { u as createCookie, C as createCookieSessionStorage, F as createMemorySessionStorage, E as createRequestHandler, y as createSessionStorage, h as getStorefrontHeaders }; | ||
export { u as createCookie, C as createCookieSessionStorage, F as createMemorySessionStorage, E as createRequestHandler, S as createSessionStorage, v as getStorefrontHeaders }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ { | ||
"type": "module", | ||
"version": "0.0.0-next-ec9cb2f-20240122090404", | ||
"version": "0.0.0-next-ed2657b-20240909175901", | ||
"license": "MIT", | ||
@@ -44,9 +44,9 @@ "main": "dist/index.cjs", | ||
"devDependencies": { | ||
"@remix-run/server-runtime": "^2.5.0", | ||
"@shopify/oxygen-workers-types": "^4.0.0" | ||
"@remix-run/server-runtime": "^2.10.1", | ||
"@shopify/oxygen-workers-types": "^4.1.2" | ||
}, | ||
"peerDependencies": { | ||
"@remix-run/server-runtime": "^2.1.0", | ||
"@shopify/oxygen-workers-types": "^3.17.3 || ^4.0.0" | ||
"@shopify/oxygen-workers-types": "^3.17.3 || ^4.1.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66886
447