@lensmcp/cluster 1.26.21 → 1.26.23
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var i=(e,r)=>d(e,"name",{value:r,configurable:!0});var p=Object.defineProperty,s=i((e,r)=>p(e,"name",{value:r,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.PREFLIGHT_METHODS_ROUTED=exports.PREFLIGHT_METHODS_NOROUTE=exports.corsPreflight=exports.PREFLIGHT_MAX_AGE=exports.cors=exports.isRoutedOrigin=exports.callerContextOf=exports.claimedCallerIdOf=exports.CLAIMED_CALLER_ID=exports.CALLER_CONTEXT=exports.CALLER_CONTEXT_HEADERS=exports.GATEWAY_OWNED_HEADERS=exports.sendError=exports.stampForwardingHeaders=exports.clientIpOf=exports.resolveClientIp=exports.CLIENT_IP=exports.rememberRawTarget=exports.rawTargetOf=exports.RAW_TARGET=exports.canonicalPath=exports.canonicalize=exports.ENCODED_STRUCTURE=void 0,exports.stripOwnedHeaders=stripOwnedHeaders;const registration_guards_1=require("./registration-guards"),gateway_errors_1=require("ringwall/gateway-errors"),client_ip_1=require("ringwall/client-ip"),manifest_1=require("ringwall/manifest"),act_1=require("./act");var canonical_path_1=require("ringwall/canonical-path");Object.defineProperty(exports,"ENCODED_STRUCTURE",{enumerable:!0,get:s(function(){return canonical_path_1.ENCODED_STRUCTURE},"get")}),Object.defineProperty(exports,"canonicalize",{enumerable:!0,get:s(function(){return canonical_path_1.canonicalize},"get")}),Object.defineProperty(exports,"canonicalPath",{enumerable:!0,get:s(function(){return canonical_path_1.canonicalPath},"get")}),Object.defineProperty(exports,"RAW_TARGET",{enumerable:!0,get:s(function(){return canonical_path_1.RAW_TARGET},"get")}),Object.defineProperty(exports,"rawTargetOf",{enumerable:!0,get:s(function(){return canonical_path_1.rawTargetOf},"get")}),Object.defineProperty(exports,"rememberRawTarget",{enumerable:!0,get:s(function(){return canonical_path_1.rememberRawTarget},"get")}),exports.CLIENT_IP=Symbol.for("lensmcp.gateway.clientIp");const FORWARDED=Symbol.for("lensmcp.gateway.forwarded"),peerOnly=(0,client_ip_1.createClientIpResolver)({}),resolverOf=s(e=>e.clientIp??peerOnly,"resolverOf"),peerOf=s(e=>e.socket?.remoteAddress??"","peerOf"),resolveClientIp=s((e,r)=>{const t=resolverOf(e).clientIpOf(r,peerOf(r));return r[exports.CLIENT_IP]=t,t},"resolveClientIp");exports.resolveClientIp=resolveClientIp;const clientIpOf=s(e=>e[exports.CLIENT_IP]??peerOf(e),"clientIpOf");exports.clientIpOf=clientIpOf;const stampForwardingHeaders=s((e,r)=>{const t=r;if(t[FORWARDED])return;t[FORWARDED]=!0;const o=peerOf(r);r.headers["x-forwarded-for"]=resolverOf(e).forwardedFor(r,o),r.headers["x-forwarded-proto"]=resolverOf(e).forwardedProto(r,o,e.https?"https":"http");const n=r.headers.host;(resolverOf(e).trustProxyHops===0||!r.headers["x-forwarded-host"])&&(n?r.headers["x-forwarded-host"]=n:delete r.headers["x-forwarded-host"])},"stampForwardingHeaders");exports.stampForwardingHeaders=stampForwardingHeaders;const sendError=s((e,r,t,o,n,c,l)=>{const a=(0,gateway_errors_1.ensureRequestId)(r);return e.headersSent||e.writeHead(t,{"content-type":gateway_errors_1.GATEWAY_ERROR_CONTENT_TYPE,"x-request-id":a,...l??{}}),e.end((0,gateway_errors_1.gatewayErrorBody)(t,o,a,n,c)),a},"sendError");exports.sendError=sendError,exports.GATEWAY_OWNED_HEADERS=["x-internal-token","x-api-key-id","x-api-key-workspace","x-user-id","x-tenant-id","x-user-roles","x-user-permissions",act_1.ACT_HEADER],exports.CALLER_CONTEXT_HEADERS=["x-tenant-id","x-user-id"],exports.CALLER_CONTEXT=Symbol.for("lensmcp.gateway.callerContext"),exports.CLAIMED_CALLER_ID=Symbol.for("lensmcp.gateway.claimedCallerId");const CALLER_ID_VALUE=/^[a-z0-9][a-z0-9._-]{0,63}$/i,CALLER_CONTEXT_VALUE=/^[\x21-\x2b\x2d-\x7e]{1,128}$/;function stripOwnedHeaders(e){const r={};for(const o of exports.CALLER_CONTEXT_HEADERS){const n=e.headers[o];typeof n=="string"&&CALLER_CONTEXT_VALUE.test(n)&&(r[o]=n)}e[exports.CALLER_CONTEXT]=r;const t=e.headers["x-api-key-id"];typeof t=="string"&&CALLER_ID_VALUE.test(t)&&(e[exports.CLAIMED_CALLER_ID]=t),(0,act_1.setActTicketAside)(e);for(const o of exports.GATEWAY_OWNED_HEADERS)delete e.headers[o]}i(stripOwnedHeaders,"stripOwnedHeaders"),s(stripOwnedHeaders,"stripOwnedHeaders");const claimedCallerIdOf=s(e=>e[exports.CLAIMED_CALLER_ID],"claimedCallerIdOf");exports.claimedCallerIdOf=claimedCallerIdOf;const callerContextOf=s(e=>e[exports.CALLER_CONTEXT]??{},"callerContextOf");exports.callerContextOf=callerContextOf;const isRoutedOrigin=s((e,r)=>{if(!e||e==="null")return!1;let t;try{t=new URL(e).hostname.toLowerCase()}catch{return!1}return t?t==="localhost"||t==="127.0.0.1"||t==="::1"?!0:(0,registration_guards_1.reservedHostOf)(t)||r.some(o=>!!o.run&&o.host?.toLowerCase()===t)||r.some(o=>!!o.remote&&!!o.host&&(0,manifest_1.hostMatches)(o.host,t))?!1:r.some(o=>!!o.host&&(0,manifest_1.hostMatches)(o.host,t)):!1},"isRoutedOrigin");exports.isRoutedOrigin=isRoutedOrigin;const cors=s((e,r,t)=>{const o=e.headers.origin;typeof o!="string"||o===""||(r.setHeader("vary","Origin"),(0,exports.isRoutedOrigin)(o,t)&&(r.setHeader("access-control-allow-origin",o),r.setHeader("access-control-allow-credentials","true")))},"cors");exports.cors=cors,exports.PREFLIGHT_MAX_AGE="7200";const corsPreflight=s((e,r,t,o)=>{(0,exports.cors)(e,r,o),r.writeHead(204,{"access-control-allow-methods":t,"access-control-allow-headers":String(e.headers["access-control-request-headers"]??"*"),"access-control-max-age":exports.PREFLIGHT_MAX_AGE}),r.end()},"corsPreflight");exports.corsPreflight=corsPreflight,exports.PREFLIGHT_METHODS_NOROUTE="GET,HEAD,OPTIONS",exports.PREFLIGHT_METHODS_ROUTED="GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS";
|
|
@@ -10,7 +10,7 @@ export interface HostConflict {
|
|
|
10
10
|
heldByRoot: string;
|
|
11
11
|
}
|
|
12
12
|
export interface Refusal {
|
|
13
|
-
error: 'key-in-use' | 'host-conflict' | 'not-your-registration' | 'daemon-workspace';
|
|
13
|
+
error: 'key-in-use' | 'host-conflict' | 'not-your-registration' | 'daemon-workspace' | 'reserved-host';
|
|
14
14
|
/** One sentence a person can act on. The CLI prints it as is. */
|
|
15
15
|
message: string;
|
|
16
16
|
heldByRoot?: string;
|
|
@@ -18,6 +18,15 @@ export interface Refusal {
|
|
|
18
18
|
}
|
|
19
19
|
/** Claims of `fragment` that ANOTHER workspace already holds. Re-registering yourself is not a conflict. */
|
|
20
20
|
export declare function hostConflicts(registry: RouteRegistry, fragment: WorkspaceFragment): HostConflict[];
|
|
21
|
+
/**
|
|
22
|
+
* Host names LensMCP keeps for itself (planning/canvas D9): its dashboard's (`lensmcp.localhost`, and `lensmcp.local`
|
|
23
|
+
* while the old name is still answered) and the canvas frame host's whole subtree (`canvas.localhost` — the frame is a
|
|
24
|
+
* site of its own, and a routed app under it would share that site with every canvas). A workspace may not route any of
|
|
25
|
+
* them, as a host or as an apex; only LensMCP's own dashboard routes do.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RESERVED_HOSTS: readonly string[];
|
|
28
|
+
/** The reserved name a host or apex falls under, if any. */
|
|
29
|
+
export declare function reservedHostOf(name: string | undefined): string | undefined;
|
|
21
30
|
/** Why this registration must not go in — or `undefined` when it may. */
|
|
22
31
|
export declare function refuseRegistration(registry: RouteRegistry, fragment: WorkspaceFragment): Refusal | undefined;
|
|
23
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.defineProperty;var a=(o,e)=>f(o,"name",{value:e,configurable:!0});var u=Object.defineProperty,i=a((o,e)=>u(o,"name",{value:e,configurable:!0}),"i");Object.defineProperty(exports,"__esModule",{value:!0}),exports.RESERVED_HOSTS=exports.sameRoot=void 0,exports.canonicalRoot=canonicalRoot,exports.hostConflicts=hostConflicts,exports.reservedHostOf=reservedHostOf,exports.refuseRegistration=refuseRegistration,exports.refuseUnregistration=refuseUnregistration;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path"));function canonicalRoot(o){try{return fs.realpathSync(o)}catch{return path.resolve(o)}}a(canonicalRoot,"canonicalRoot"),i(canonicalRoot,"canonicalRoot");const sameRoot=i((o,e)=>canonicalRoot(o)===canonicalRoot(e),"sameRoot");exports.sameRoot=sameRoot;function claim(o){return o.host?`${o.host.toLowerCase()} ${o.prefix??""}`:o.apex?`* ${o.apex.toLowerCase()}`:void 0}a(claim,"claim"),i(claim,"claim");function hostConflicts(o,e){const n=[],t=new Set;for(const r of o.keys()){if(r===e.wsKey)continue;const s=o.get(r);if(!s)continue;const c=new Set(s.routes.map(claim));for(const h of e.routes){const l=claim(h);!l||!c.has(l)||t.has(l)||(t.add(l),n.push({host:h.host??`(default for ${h.apex})`,...h.prefix?{prefix:h.prefix}:{},heldBy:r,heldByRoot:s.root}))}}return n}a(hostConflicts,"hostConflicts"),i(hostConflicts,"hostConflicts");const describeConflict=i(o=>`${o.host}${o.prefix??""} (served by '${o.heldBy}')`,"describeConflict");exports.RESERVED_HOSTS=["lensmcp.localhost","canvas.localhost","lensmcp.local"];const DASHBOARD_PROJECT="(lens-dashboard)";function reservedHostOf(o){const e=(o??"").trim().toLowerCase().replace(/\.$/,"");if(e)return exports.RESERVED_HOSTS.find(n=>e===n||e.endsWith(`.${n}`))}a(reservedHostOf,"reservedHostOf"),i(reservedHostOf,"reservedHostOf");function refuseRegistration(o,e){const n=e.routes.filter(s=>s.project!==DASHBOARD_PROJECT).map(s=>({route:s,name:reservedHostOf(s.host)??reservedHostOf(s.apex)})).filter(s=>s.name!==void 0);if(n.length>0){const s=[...new Set(n.map(c=>c.route.host??`*.${c.route.apex}`))].slice(0,6).join(", ");return{error:"reserved-host",message:`'${e.wsKey}' declares ${s}, under a name LensMCP keeps for itself (${exports.RESERVED_HOSTS.join(", ")} and every name below them): its dashboard and the canvas frame live there. Give the app hosts of its own (an apex like \`${e.wsKey}.localhost\`).`}}const t=o.get(e.wsKey);if(t&&!(0,exports.sameRoot)(t.root,e.root))return{error:"key-in-use",heldByRoot:t.root,message:`'${e.wsKey}' is already served from ${t.root}. ${e.root} is another checkout that derives the same key, and two checkouts cannot share a key or hosts behind one gateway: registering this one would replace the other's routes. To serve it beside the other under hosts of its own, run \`lensmcp instance start\` in ${e.root}; otherwise run \`lensmcp gateway stop\` in ${t.root} first.`};const r=hostConflicts(o,e);if(r.length>0){const s=r.slice(0,6).map(describeConflict).join(", "),c=r.length>6?`, and ${r.length-6} more`:"";return{error:"host-conflict",conflicts:r,message:`'${e.wsKey}' declares ${r.length===1?"a host":`${r.length} hosts`} another workspace already serves: ${s}${c}. The workspace registered first would win every request to ${r.length===1?"it":"them"}, so this registration is refused. Two workspaces behind one gateway need different hosts \u2014 for a second checkout of a workspace, \`lensmcp instance start\` in it serves it under hosts named after it.`}}}a(refuseRegistration,"refuseRegistration"),i(refuseRegistration,"refuseRegistration");function refuseUnregistration(o,e,n){const t=o.get(e.wsKey);if(t&&e.root&&!(0,exports.sameRoot)(t.root,e.root))return{error:"not-your-registration",heldByRoot:t.root,message:`'${e.wsKey}' is served from ${t.root}, not from ${e.root} \u2014 nothing of this checkout is registered, so nothing was removed.`};if(t&&n!==void 0&&e.wsKey===n)return{error:"daemon-workspace",heldByRoot:t.root,message:`'${e.wsKey}' is the workspace that owns the gateway \u2014 unregistering it would leave :443 serving without it. Stop the gateway instead: \`lensmcp gateway stop\` in ${t.root}.`}}a(refuseUnregistration,"refuseUnregistration"),i(refuseUnregistration,"refuseUnregistration");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/cluster",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.23",
|
|
4
4
|
"description": "Run your Nx workspace as a local production cluster: pods on unix sockets with true HMR, one https gateway with per-project domains, scale-from-zero, autoscale, idle-kill, local-CA TLS — observed by the LensMCP lens.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"typescript": ">=5.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lensmcp/core": "1.26.
|
|
36
|
-
"@lensmcp/node-instrumentation": "1.26.
|
|
37
|
-
"@lensmcp/nx-plugin": "1.26.
|
|
35
|
+
"@lensmcp/core": "1.26.23",
|
|
36
|
+
"@lensmcp/node-instrumentation": "1.26.23",
|
|
37
|
+
"@lensmcp/nx-plugin": "1.26.23",
|
|
38
38
|
"ringwall": "1.0.2",
|
|
39
39
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
|
40
40
|
"fork-ts-checker-webpack-plugin": "^9.0.0",
|