@redocly/realm 0.131.2 → 0.131.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/server/config/env-config.js +1 -1
- package/dist/server/web-server/routes/cors-proxy.d.ts +1 -0
- package/dist/server/web-server/routes/cors-proxy.js +2 -2
- package/package.json +6 -6
- package/dist/client/runtime/generated/browser-plugins.js +0 -12
- package/dist/client/runtime/generated/package.json +0 -1
- package/dist/client/runtime/generated/routes.js +0 -7
- package/dist/client/runtime/generated/templates.js +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @redocly/realm
|
|
2
2
|
|
|
3
|
+
## 0.131.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4afca06580: Fixed a Realm CORS proxy security issue that could allow requests to private network addresses and unsafe direct navigation to proxied HTML or JavaScript content.
|
|
8
|
+
|
|
3
9
|
## 0.131.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readEnvVariable as
|
|
1
|
+
import{readEnvVariable as c}from"../utils/envs/read-env-variable.js";import{envSchema as s}from"./env-schema.js";function r(){const n=Object.fromEntries(Object.keys(process.env).map(e=>[e,c(e)]));return n.REDOCLY_PORTAL_VERSION=process.env.REDOCLY_PORTAL_VERSION,s.parse(n)}function o(){return r().REDOCLY_ENV??"development"}function i(){const n=process.env.REDOCLY_EXECUTION_MODE;return n==="build"||n==="develop"||n==="runtime"?n:"develop"}function v(){const e=r().REDOCLY_INTERNAL_DEV;return e==="true"||e==="1"}function d(n){switch(n){case"redoclyEnv":return o();case"executionMode":return i();case"isProductionEnv":return o()==="production";case"isPreviewEnv":return o()==="preview";case"isReunite":{const e=o(),t=v(),u=r().REDOCLY_ORG_ID;return e==="production"||e==="preview"||e==="development"&&!t&&!!u}case"isBuildMode":return i()==="build";case"isDevelopMode":return i()==="develop";case"isRuntimeMode":return i()==="runtime";default:return n}}const a=new Set(["redoclyEnv","executionMode","isProductionEnv","isPreviewEnv","isReunite","isBuildMode","isDevelopMode","isRuntimeMode"]),p=Object.freeze(new Proxy({},{get(n,e){if(typeof e!="string")return;const t=e;return a.has(t)?d(t):r()[e]}}));export{p as envConfig};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
2
|
export declare function corsProxyHandler(proxyBasePath?: string): (ctx: Context) => Promise<Response>;
|
|
3
|
+
export declare function isPrivateIp(ip: string): boolean;
|
|
3
4
|
export declare function resolveCorsProxyTarget(requestUrl: string, proxyBasePath: string): URL | null;
|
|
4
5
|
export declare const CORS_PROXY_STREAM_HEADER = "x-redocly-proxy-streaming";
|
|
5
6
|
//# sourceMappingURL=cors-proxy.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{withPathPrefix as
|
|
2
|
-
Usage: ${
|
|
1
|
+
import _ from"node:dns";import{isIP as T}from"node:net";import{withPathPrefix as D}from"@redocly/theme/core/utils";import{ServerRoutes as $}from"../../../constants/common.js";import{envConfig as w}from"../../config/env-config.js";import{getRequestOrigin as k}from"../utils/get-request-origin.js";const I=new Set(["connection","keep-alive","proxy-authenticate","proxy-connection","proxy-authorization","te","trailer","transfer-encoding","upgrade","host"]),L=new Set(["cookie","cookie2","accept-encoding"]),A=new Set(["set-cookie","set-cookie2","content-encoding","content-length"]),E="x-redocly-proxy-streaming",H="x-http-method-override",y="x-redocly-cookie";function Q(t=D($.CORS_PROXY)){return async e=>{const o=new URL(e.req.url).pathname;if(o===t||o===`${t}/`)return e.text(`Realm CORS proxy endpoint.
|
|
2
|
+
Usage: ${t}/https://api.example.com/path`);const n=F(e.req.url,t);if(!n)return e.text("Invalid proxied URL",400);const i=k(e),d=n.origin===i,f=n.pathname===t||n.pathname.startsWith(`${t}/`);if(d&&!f)return new Response("Please use a direct request",{status:308,headers:{Location:n.toString(),Vary:"origin","Cache-Control":"private"}});const u=await z(n.hostname);if((!w.isDevelopMode||w.isReunite)&&u&&N(u))return e.text("Requests to private network addresses are not allowed",403);const s=new Headers,h=S(e.req.raw.headers);for(const[r,g]of e.req.raw.headers)h.has(r.toLowerCase())||L.has(r.toLowerCase())||s.append(r,g);const a=s.get(y);if(a){const r=e.req.raw.headers.get("cookie")||"";s.set("cookie",r?`${r}; ${a}`:a),s.delete(y)}const C=e.req.raw.headers.get("origin")||"";W(C)&&s.delete("origin");let p=e.req.method;const R=s.get(H);R&&(p=R.toUpperCase(),s.delete(H));const m={method:p,headers:s,redirect:"manual"};p!=="GET"&&p!=="HEAD"&&e.req.raw.body&&(m.body=e.req.raw.body,m.duplex="half");let c;try{c=await fetch(n,m)}catch(r){const g=r instanceof Error?r.message:"unknown error",P=r instanceof Error&&r.cause instanceof Error?`: ${r.cause.message}`:"";return e.text(`Failed to proxy request: ${g}${P}`,502)}const O=c.headers.get("content-type")||"";if(Y(O)&&e.req.raw.headers.get("sec-fetch-mode")==="navigate")return e.text("Direct browser navigation to proxied HTML or JavaScript content is not allowed",403);const l=new Headers(c.headers),q=S(c.headers);for(const r of q)l.delete(r);for(const r of A)l.delete(r);return l.set(E,"1"),new Response(c.body,{status:c.status,statusText:c.statusText,headers:l})}}function x(t){try{return decodeURIComponent(t)}catch{return t}}function M(t){return t.replace(/^(https?):\/(?!\/)/i,"$1://")}function b(t,e){return e?t.includes("?")?e==="?"?t:`${t.endsWith("?")||t.endsWith("&")?t:`${t}&`}${e.slice(1)}`:`${t}${e}`:t}function S(t){const e=new Set(I),o=t.get("connection");if(!o)return e;for(const n of o.split(",")){const i=n.trim().toLowerCase();i&&e.add(i)}return e}function W(t){const e=t.toLowerCase();return e.includes(".redocly.app")||e.includes("localhost")}async function z(t){if(T(t))return t;try{const{address:e}=await _.promises.lookup(t);return e}catch{return null}}function N(t){const e=t.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i);return e?v(e[1]):t.includes(":")?U(t):v(t)}function v(t){const e=t.split(".").map(Number);if(e.length!==4||e.some(i=>isNaN(i)))return!0;const[o,n]=e;return o===0||o===10||o===127||o===172&&n>=16&&n<=31||o===192&&n===168||o===169&&n===254||o===100&&n>=64&&n<=127}function U(t){const e=t.toLowerCase();return e==="::1"||e==="::"||e.startsWith("fc")||e.startsWith("fd")||e.startsWith("fe80")}function Y(t){const e=t.toLowerCase();return e.includes("text/html")||e.includes("javascript")||e.includes("application/xhtml")||e.includes("application/xml")||e.includes("image/svg")}function F(t,e){const o=new URL(t),n=o.pathname===e,i=o.pathname.startsWith(`${e}/`);if(!n&&!i)return null;const d=o.pathname.slice(e.length).replace(/^\/+/,"");if(!d)return null;const f=[d,x(d)];for(const u of f){const s=M(u),h=b(s,o.search);try{const a=new URL(h);if(a.protocol==="http:"||a.protocol==="https:")return a}catch{continue}}return null}const Z=E;export{Z as CORS_PROXY_STREAM_HEADER,Q as corsProxyHandler,N as isPrivateIp,F as resolveCorsProxyTarget};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/realm",
|
|
3
|
-
"version": "0.131.
|
|
3
|
+
"version": "0.131.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -91,14 +91,14 @@
|
|
|
91
91
|
"xpath": "0.0.34",
|
|
92
92
|
"yaml-ast-parser": "0.0.43",
|
|
93
93
|
"zod": "^3.25.76",
|
|
94
|
-
"@redocly/
|
|
94
|
+
"@redocly/asyncapi-docs": "1.8.1",
|
|
95
95
|
"@redocly/graphql-docs": "1.8.0",
|
|
96
|
-
"@redocly/portal-legacy-ui": "0.14.0",
|
|
97
|
-
"@redocly/portal-plugin-mock-server": "0.16.1",
|
|
98
96
|
"@redocly/openapi-docs": "3.19.1",
|
|
97
|
+
"@redocly/portal-legacy-ui": "0.14.0",
|
|
99
98
|
"@redocly/realm-asyncapi-sdk": "0.9.0",
|
|
100
|
-
"@redocly/
|
|
101
|
-
"@redocly/
|
|
99
|
+
"@redocly/portal-plugin-mock-server": "0.16.1",
|
|
100
|
+
"@redocly/config": "0.44.1",
|
|
101
|
+
"@redocly/theme": "0.63.0"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"@redocly/portal/ssr-entry"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const templates = {
|
|
2
|
-
"scorecardClassic": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/server/plugins/scorecard-classic/template/index.js"),
|
|
3
|
-
|
|
4
|
-
"openapi_docs": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/templates/openapi-docs/template.js"),
|
|
5
|
-
|
|
6
|
-
"markdown": () => import("@redocly/theme/core/templates/Markdown"),
|
|
7
|
-
|
|
8
|
-
"invite": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/pages/Invite/Invite.js"),
|
|
9
|
-
|
|
10
|
-
"graphql_docs": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/server/plugins/graphql-docs/template/GraphQLDocs.js"),
|
|
11
|
-
|
|
12
|
-
"error": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/Error/ErrorDetails.js"),
|
|
13
|
-
|
|
14
|
-
"compilation-error": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/pages/CompilationError/CompilationError.js"),
|
|
15
|
-
|
|
16
|
-
"changelog.page.tsx": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/docs/realm/changelog.page.tsx"),
|
|
17
|
-
|
|
18
|
-
"catalogClassic": () => import("@redocly/theme/components/CatalogClassic/CatalogClassic"),
|
|
19
|
-
|
|
20
|
-
"asyncapi_docs": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/templates/asyncapi-docs/template.js"),
|
|
21
|
-
|
|
22
|
-
"404": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/pages/404/404.js"),
|
|
23
|
-
|
|
24
|
-
"403OIDC": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/pages/403/403OIDC.js"),
|
|
25
|
-
|
|
26
|
-
"403": () => import("/Users/volodymyrrutskyi/repos/redocly/what-about-second-redocly/packages/portal/products/realm/dist/client/app/pages/403/403.js"),
|
|
27
|
-
}
|