@lensmcp/cluster 1.25.75 → 1.25.76

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.
Files changed (158) hide show
  1. package/README.md +5 -4
  2. package/basic-ssl.js +1 -1
  3. package/build-host.js +1 -1
  4. package/build-scope-patterns.js +1 -1
  5. package/bundle-parent.js +1 -1
  6. package/checkout-cache.js +1 -1
  7. package/child-process-env.js +1 -1
  8. package/compile-retry.js +1 -1
  9. package/config-files.js +1 -1
  10. package/create-webpack-dev.js +1 -1
  11. package/create-webpack-prod.js +1 -1
  12. package/dev-devtool.js +1 -1
  13. package/devserver-host.js +1 -1
  14. package/devserver-notifier.js +1 -1
  15. package/devserver-transport.js +1 -1
  16. package/error-stack-release.js +1 -1
  17. package/executors/build/build.impl.js +1 -1
  18. package/executors/gateway/body-stall.js +1 -1
  19. package/executors/gateway/canonical-path.js +1 -1
  20. package/executors/gateway/client-ip.d.ts +14 -0
  21. package/executors/gateway/client-ip.js +1 -1
  22. package/executors/gateway/gateway-errors.d.ts +8 -0
  23. package/executors/gateway/gateway-errors.js +1 -1
  24. package/executors/gateway/gateway.impl.js +1 -1
  25. package/executors/gateway/gateway.lib.js +1 -1
  26. package/executors/gateway/health-check.js +1 -1
  27. package/executors/gateway/jwks-verify.d.ts +2 -0
  28. package/executors/gateway/jwks-verify.js +1 -1
  29. package/executors/gateway/jwt-claims.d.ts +6 -2
  30. package/executors/gateway/jwt-claims.js +1 -1
  31. package/executors/gateway/main.prod-gateway.js +2 -2
  32. package/executors/gateway/main.rollout.js +4 -4
  33. package/executors/gateway/manifest.d.ts +48 -1
  34. package/executors/gateway/manifest.js +1 -1
  35. package/executors/gateway/metrics.js +1 -1
  36. package/executors/gateway/otel-tracing.js +1 -1
  37. package/executors/gateway/prod-config.d.ts +19 -0
  38. package/executors/gateway/prod-config.js +1 -1
  39. package/executors/gateway/prod-gateway.lib.js +1 -1
  40. package/executors/gateway/prod-runtime/access-log.js +1 -1
  41. package/executors/gateway/prod-runtime/app.js +1 -1
  42. package/executors/gateway/prod-runtime/auth.js +1 -1
  43. package/executors/gateway/prod-runtime/body-stall.js +1 -1
  44. package/executors/gateway/prod-runtime/cors.js +1 -1
  45. package/executors/gateway/prod-runtime/edge.js +1 -1
  46. package/executors/gateway/prod-runtime/handler.js +1 -1
  47. package/executors/gateway/prod-runtime/hooks.js +1 -1
  48. package/executors/gateway/prod-runtime/observability.js +1 -1
  49. package/executors/gateway/prod-runtime/rollout.d.ts +4 -2
  50. package/executors/gateway/prod-runtime/rollout.js +1 -1
  51. package/executors/gateway/prod-runtime/routing.js +1 -1
  52. package/executors/gateway/prod-runtime/server.d.ts +15 -0
  53. package/executors/gateway/prod-runtime/server.js +1 -1
  54. package/executors/gateway/prod-runtime/trust.d.ts +22 -0
  55. package/executors/gateway/prod-runtime/trust.js +1 -1
  56. package/executors/gateway/prod-runtime/types.d.ts +31 -2
  57. package/executors/gateway/prod-runtime/upgrade.d.ts +4 -1
  58. package/executors/gateway/prod-runtime/upgrade.js +8 -6
  59. package/executors/gateway/prod-runtime/upstream-errors.d.ts +24 -0
  60. package/executors/gateway/prod-runtime/upstream-errors.js +1 -0
  61. package/executors/gateway/prod-runtime/upstream.js +1 -1
  62. package/executors/gateway/providers-prod.js +1 -1
  63. package/executors/gateway/rate-limit.js +2 -2
  64. package/executors/gateway/registry-source.js +1 -1
  65. package/executors/gateway/rollout-ops.js +2 -2
  66. package/executors/gateway/runtime/act.js +1 -1
  67. package/executors/gateway/runtime/auth.js +1 -1
  68. package/executors/gateway/runtime/awake.js +1 -1
  69. package/executors/gateway/runtime/chooser.js +12 -12
  70. package/executors/gateway/runtime/control.js +2 -2
  71. package/executors/gateway/runtime/dev-auth.js +1 -1
  72. package/executors/gateway/runtime/discovery.js +1 -1
  73. package/executors/gateway/runtime/edge.js +1 -1
  74. package/executors/gateway/runtime/guest-graph.js +2 -2
  75. package/executors/gateway/runtime/guest-replay.js +2 -2
  76. package/executors/gateway/runtime/handler.js +1 -1
  77. package/executors/gateway/runtime/hmr-reload.js +1 -1
  78. package/executors/gateway/runtime/hooks.js +1 -1
  79. package/executors/gateway/runtime/hosted-dashboard.js +1 -1
  80. package/executors/gateway/runtime/instance.js +3 -3
  81. package/executors/gateway/runtime/internal-fetch.js +1 -1
  82. package/executors/gateway/runtime/lens-children.js +1 -1
  83. package/executors/gateway/runtime/lifecycle.js +4 -4
  84. package/executors/gateway/runtime/observability.js +3 -3
  85. package/executors/gateway/runtime/on-demand.js +7 -7
  86. package/executors/gateway/runtime/orphan-reaper.js +2 -2
  87. package/executors/gateway/runtime/own-log.js +6 -6
  88. package/executors/gateway/runtime/parked-dashboards.js +1 -1
  89. package/executors/gateway/runtime/pod-env.js +2 -2
  90. package/executors/gateway/runtime/pod-output.js +1 -1
  91. package/executors/gateway/runtime/pod-probe.js +1 -1
  92. package/executors/gateway/runtime/process-names.js +1 -1
  93. package/executors/gateway/runtime/project-graph-store.js +1 -1
  94. package/executors/gateway/runtime/proxy.js +1 -1
  95. package/executors/gateway/runtime/registration-guards.js +1 -1
  96. package/executors/gateway/runtime/route-registry.js +1 -1
  97. package/executors/gateway/runtime/scope.js +1 -1
  98. package/executors/gateway/runtime/serve-launch.js +3 -3
  99. package/executors/gateway/runtime/server.js +2 -2
  100. package/executors/gateway/runtime/service-keys.js +1 -1
  101. package/executors/gateway/runtime/shared-build.js +3 -3
  102. package/executors/gateway/runtime/source-poller.js +1 -1
  103. package/executors/gateway/runtime/types.js +1 -1
  104. package/executors/gateway/runtime/upgrade.js +1 -1
  105. package/executors/gateway/runtime/warm-start.js +1 -1
  106. package/executors/gateway/runtime/workspace-auth.js +1 -1
  107. package/executors/gateway/runtime/workspace-log.js +1 -1
  108. package/executors/gateway/runtime/workspace-middleware.js +1 -1
  109. package/executors/gateway/runtime/workspace-registry.js +1 -1
  110. package/executors/gateway/ssrf-guard.js +1 -1
  111. package/executors/gateway/workspace-auth.js +1 -1
  112. package/executors/serve/serve.impl.js +1 -1
  113. package/executors/serve/stop-on-signal.js +1 -1
  114. package/executors/trust/hostname.js +1 -1
  115. package/executors/trust/trust.impl.js +3 -3
  116. package/exit-reason.js +2 -2
  117. package/fork-ts-check-reporter.js +1 -1
  118. package/gateway.js +1 -1
  119. package/gc-notice.js +1 -1
  120. package/graph-snapshot.js +1 -1
  121. package/handoff-retire.js +1 -1
  122. package/heap-snapshot.js +1 -1
  123. package/hot-swap-registries.js +1 -1
  124. package/index.js +1 -1
  125. package/inspector-secret.js +1 -1
  126. package/main.devserver.js +11 -11
  127. package/notice-generation.js +1 -1
  128. package/package.json +4 -4
  129. package/perf/heavy-barrel-import.js +1 -1
  130. package/perf/perf-config.js +1 -1
  131. package/perf/perf-rule-events.js +2 -2
  132. package/perf/perf-rules-analysis.js +1 -1
  133. package/perf/perf-rules-plugin.js +1 -1
  134. package/perf/source-scan.js +5 -5
  135. package/perf/workspace-libraries.js +2 -2
  136. package/pod-memory-events.js +2 -2
  137. package/pod-memory.js +1 -1
  138. package/pod-sock.js +1 -1
  139. package/process-name.js +1 -1
  140. package/redis-disconnect-fix.js +1 -1
  141. package/schema-first-instance.js +1 -1
  142. package/serve-runner.js +1 -1
  143. package/service-build-events.js +2 -2
  144. package/shared-build/attach.js +2 -2
  145. package/shared-build/host.js +3 -3
  146. package/shared-build/protocol.js +1 -1
  147. package/shared-build/shared-compilation.js +3 -3
  148. package/shared-build/signature.js +1 -1
  149. package/stdio-guard.js +1 -1
  150. package/swap-mode.js +1 -1
  151. package/swap-recycle.js +1 -1
  152. package/tsgo-check-plugin.js +4 -4
  153. package/typecheck-bus.js +3 -3
  154. package/typecheck-queue.js +1 -1
  155. package/worker-guard.js +1 -1
  156. package/worker-retire.js +1 -1
  157. package/worker-supervisor.js +2 -2
  158. package/workspace-paths.js +1 -1
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  `@lensmcp/cluster` is the Nx plugin behind [LensMCP](https://github.com/kiwiapps-ltd/lensmcp), an observability lens for coding agents. It turns a monorepo of NestJS services and frontend apps into a cluster that behaves like production *on your laptop*: each backend service runs N hot-swappable child processes ("pods") on unix sockets with real NestJS HMR (20–100ms edit loop, in-memory state preserved), and a single HTTPS gateway routes traffic to them by hostname — `app.tetros.ai.local`, `api.tetros.ai.local`, and so on — over a locally-trusted CA so HTTPS *just works*.
6
6
 
7
- The point is parity. The same gateway routing core (`matchRoute` / `buildRouteTable`) runs in dev and in production, so what you exercise locally — per-domain routing, path-mounted microservices, scale-from-zero, edge JWT verification + ABAC, and weighted / attribute-based rollout — is the same shape that ships. In dev the gateway runs on `node:http` + `http-proxy` (it owns the unix-socket pods and their lifecycle); in production the same routing brain is composed over a **Fastify + [@fastify/reply-from](https://github.com/fastify/fastify-reply-from) (undici)** transport, shipped as a **Node 26 distroless** image for the high-RPS edge. Throughout, the cluster publishes to the LensMCP event bus (service up/down, cold starts, autoscale, idle kills, request-derived traffic edges) so the dashboard can draw your live topology.
7
+ The point is parity. The same gateway routing core (`matchRoute` / `buildRouteTable`) runs in dev and in production, so what you exercise locally — per-domain routing, path-mounted microservices, scale-from-zero, edge JWT verification + ABAC, and weighted / attribute-based rollout — is the same shape that ships. In dev the gateway runs on `node:http` + `http-proxy` (it owns the unix-socket pods and their lifecycle); in production the same routing brain is composed over a **Fastify + [@fastify/reply-from](https://github.com/fastify/fastify-reply-from) (undici)** transport, shipped as a **Node 24 distroless (nonroot)** image for the high-RPS edge. Throughout, the cluster publishes to the LensMCP event bus (service up/down, cold starts, autoscale, idle kills, request-derived traffic edges) so the dashboard can draw your live topology.
8
8
 
9
9
  ## Install
10
10
 
@@ -118,10 +118,11 @@ A declaration must route *somewhere*: either a pod `service` or a TCP `upstream`
118
118
 
119
119
  One front door, two transports sharing one routing brain:
120
120
 
121
- - **Routing** — every `cluster` declaration becomes a route; requests match by hostname (exact beats `*.suffix` wildcard) then by most-specific path prefix. A *claimed* host's unmatched root is served by the gateway itself (`/health` aggregate, `/.well-known/...`, CORS + preflights); an *unclaimed* host can only reach the `default` route or 404.
121
+ - **Routing** — every `cluster` declaration becomes a route; requests match by hostname (case-insensitive; exact beats `*.suffix` wildcard in any case spelling) then by most-specific path prefix. A *claimed* host's unmatched root is served by the gateway itself (`/health` aggregate, `/.well-known/...`, CORS + preflights); an *unclaimed* host can only reach the `default` route or 404.
122
122
  - **Dev transport** — `node:http` + `http-proxy`. It owns the unix-socket pods: **scale-from-zero** on first request, autoscale while requests overlap, idle-kill, supervised reforks, and ghost-socket sweeping.
123
- - **Prod transport** — the same `matchRoute` composed over **Fastify + @fastify/reply-from (undici)** (connection-reusing, HTTP/1.1 pipelined; benchmarks materially lower CPU/req than http-proxy), shipped as a **Node 26 distroless** image. No process management — prod pods are always-on (k8s keeps them up).
124
- - **Edge auth + identity** — for `jwt` routes the gateway verifies the end-user token (dev: HS256 shared secret; prod: RS256 via JWKS) and stamps trusted identity headers (`x-user-id`, `x-tenant-id`, roles, perms) onto the forwarded request; `internal.<host>` routes require the CALLER's own `x-api-key`, stamp `x-api-key-id` with the caller's project (or an identity it declares in `callerIds` and named itself), and once the key is validated the `x-tenant-id` and `x-user-id` the caller named are forwarded to the callee — production's service-to-service path is direct, so the callee reads them there too; roles, permissions and every other owned header stay the gateway's. Per-path **ABAC** rules (a `permission` or full predicate over verified claims + IP/headers, scoped by HTTP method) are enforced at the edge → 403.
123
+ - **Prod transport** — the same `matchRoute` composed over **Fastify + @fastify/reply-from (undici)** (connection-reusing, HTTP/1.1 pipelined; benchmarks materially lower CPU/req than http-proxy), shipped as a **Node 24 distroless `nonroot`** image whose runtime dependencies install from a committed lockfile pinned to the versions this repository's suites run (`docker/package-lock.json`). No process management — prod pods are always-on (k8s keeps them up).
124
+ - **Edge auth + identity** — for `jwt` routes the gateway verifies the end-user token (dev: HS256 shared secret; prod: RS256 via JWKS) and stamps trusted identity headers (`x-user-id`, `x-tenant-id`, roles, perms) onto the forwarded request; `internal.<host>` routes require the CALLER's own `x-api-key`, stamp `x-api-key-id` with the caller's project (or an identity it declares in `callerIds` and named itself), and once the key is validated the `x-tenant-id` and `x-user-id` the caller named are forwarded to the callee — production's service-to-service path is direct, so the callee reads them there too; roles, permissions and every other owned header stay the gateway's. Per-path **ABAC** rules (a `permission` or full predicate over verified claims + IP/headers, scoped by HTTP method — a `GET` scope also judges `HEAD`) are enforced at the edge → 403. Each route is judged by its own manifest's policy.
125
+ - **Route kinds vs auth modes** — `internal` is a route **kind** (`internal: true` → `internal.<host>`, x-api-key), never an auth **mode**: on a host route the mode is `jwt` or `public`, and a manifest that writes `internal` (or any unknown string) there gets **401** on that route — never an open route (the production gateway also names it at load, event kind `gateway-config-error`). `docs/lensmcp/concepts/prod-gateway-config.mdx` lists the rest of the edge contract (trusted-proxy `X-Forwarded-Proto`, attribute headers from trusted peers only, the decoded `path` attribute, regex limits, WebSocket handshake ordering and caps).
125
126
  - **Rollout** — per-request upstream selection supports **weighted** cohorts (smooth nginx-style split for canary / blue-green) and **attribute-based targeting** (route by user / tenant / IP / header / sticky device key, consistent-hashed so a ramp moves a key across the boundary at most once). The serving version rides on `x-lensmcp-version` and the trace.
126
127
 
127
128
  ## Worktree instances
package/basic-ssl.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var c=(e,r)=>f(e,"name",{value:r,configurable:!0});var p=Object.defineProperty,a=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CA_CERT_FILE=void 0,exports.caDir=caDir,exports.caCertPath=caCertPath,exports.getCertificateSync=getCertificateSync,exports.ensureCaSync=ensureCaSync;const tslib_1=require("tslib"),crypto=tslib_1.__importStar(require("node:crypto")),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),LEAF_MAX_AGE_MS=600*60*60*1e3,CA_TTL_DAYS=3650,CA_MIN_REMAINING_MS=720*60*60*1e3;exports.CA_CERT_FILE="lensmcp-local-ca.crt";const LEGACY_CA_CERT_FILE="davnx-local-ca.crt",CA_KEY_FILE="_ca-key.pem";function caDir(){const e=process.env.LENSMCP_HOME||os.homedir();return path.join(e,".lensmcp","ca")}c(caDir,"caDir"),a(caDir,"caDir");function caCertPath(){return path.join(caDir(),exports.CA_CERT_FILE)}c(caCertPath,"caCertPath"),a(caCertPath,"caCertPath");function getCertificateSync(e,r="lensmcp.dev",t=[]){const n=require("node-forge");fs.mkdirSync(e,{recursive:!0});const l=loadOrCreateCa(n,e),o=n.pki.certificateToPem(l.cert),i=crypto.createHash("sha256").update([r,...[...t].sort()].join("|")).digest("hex").slice(0,12),s=path.join(e,`_leaf-${i}.pem`);try{const u=fs.statSync(s);if(Date.now()-u.ctimeMs<LEAF_MAX_AGE_MS){const m=fs.readFileSync(s,"utf8");if(m.includes(o))return m}}catch{}const y=createLeafCertificate(n,l,r,t);fs.writeFileSync(s,y);for(const u of fs.readdirSync(e))if(/^_leaf-.*\.pem$/.test(u)&&u!==`_leaf-${i}.pem`||/^_cert.*\.pem$/.test(u)||/-dev\.crt$/.test(u)||u===LEGACY_CA_CERT_FILE)try{fs.unlinkSync(path.join(e,u))}catch{}return y}c(getCertificateSync,"getCertificateSync"),a(getCertificateSync,"getCertificateSync");function ensureCaSync(e){const r=require("node-forge");return loadOrCreateCa(r,e),caCertPath()}c(ensureCaSync,"ensureCaSync"),a(ensureCaSync,"ensureCaSync");function readCaPair(e,r){try{const t=r.pki.certificateFromPem(fs.readFileSync(path.join(e,exports.CA_CERT_FILE),"utf8")),n=r.pki.privateKeyFromPem(fs.readFileSync(path.join(e,CA_KEY_FILE),"utf8"));if(t.validity.notAfter.getTime()-Date.now()>CA_MIN_REMAINING_MS)return{cert:t,key:n}}catch{}}c(readCaPair,"readCaPair"),a(readCaPair,"readCaPair");function loadOrCreateCa(e,r){const t=caDir();fs.mkdirSync(t,{recursive:!0});const n=readCaPair(t,e);if(n)return n;for(const i of[CA_KEY_FILE,exports.CA_CERT_FILE])try{fs.unlinkSync(path.join(t,i))}catch{}const l=r&&r!==t?readCaPair(r,e):void 0,o=l??mintCa(e);try{fs.writeFileSync(path.join(t,CA_KEY_FILE),e.pki.privateKeyToPem(o.key),{mode:384,flag:"wx"})}catch(i){if(i.code!=="EEXIST")throw i;const s=spinReadCaPair(t,e);if(s)return s;throw new Error(`machine dev CA at ${t} is claimed but unreadable \u2014 remove the directory and retry`,{cause:i})}return fs.writeFileSync(path.join(t,exports.CA_CERT_FILE),e.pki.certificateToPem(o.cert)),l&&console.log(`[ssl] promoted the existing workspace dev CA to the machine store (${t}) \u2014 keychain trust carries over.`),o}c(loadOrCreateCa,"loadOrCreateCa"),a(loadOrCreateCa,"loadOrCreateCa");function spinReadCaPair(e,r){const t=Date.now()+2e3;for(;;){const n=readCaPair(e,r);if(n||Date.now()>=t)return n;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}c(spinReadCaPair,"spinReadCaPair"),a(spinReadCaPair,"spinReadCaPair");function mintCa(e){const r=e.pki.rsa.generateKeyPair(2048),t=e.pki.createCertificate();t.publicKey=r.publicKey,t.serialNumber=`00${Date.now().toString(16)}`,t.validity.notBefore=new Date(Date.now()-1440*60*1e3),t.validity.notAfter=new Date,t.validity.notAfter.setDate(t.validity.notAfter.getDate()+CA_TTL_DAYS);const n=[{name:"commonName",value:"lensmcp local dev CA"},{name:"organizationName",value:"lensmcp"},{shortName:"OU",value:"dev"}];return t.setSubject(n),t.setIssuer(n),t.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),t.sign(r.privateKey,e.md.sha256.create()),{cert:t,key:r.privateKey}}c(mintCa,"mintCa"),a(mintCa,"mintCa");function createLeafCertificate(e,r,t,n,l=30){const o=e.pki.rsa.generateKeyPair(2048),i=e.pki.createCertificate();i.publicKey=o.publicKey,i.serialNumber=`00${Date.now().toString(16)}`,i.validity.notBefore=new Date(Date.now()-1440*60*1e3),i.validity.notAfter=new Date,i.validity.notAfter.setDate(i.validity.notAfter.getDate()+l),i.setSubject([{name:"commonName",value:t},{name:"organizationName",value:"lensmcp"},{shortName:"OU",value:"dev"}]),i.setIssuer(r.cert.subject.attributes);const s=[{type:2,value:"localhost"},{type:2,value:"*.localhost"},{type:7,ip:"127.0.0.1"},{type:7,ip:"::1"},...[...new Set(n)].filter(y=>y&&y!=="localhost").map(y=>({type:2,value:y}))];return i.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0,critical:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:s},{name:"subjectKeyIdentifier"}]),i.sign(r.key,e.md.sha256.create()),e.pki.privateKeyToPem(o.privateKey)+e.pki.certificateToPem(i)+e.pki.certificateToPem(r.cert)}c(createLeafCertificate,"createLeafCertificate"),a(createLeafCertificate,"createLeafCertificate");
1
+ "use strict";var C=Object.defineProperty;var o=(e,r)=>C(e,"name",{value:r,configurable:!0});var f=Object.defineProperty,c=o((e,r)=>f(e,"name",{value:r,configurable:!0}),"c"),p=Object.defineProperty,a=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CA_CERT_FILE=void 0,exports.caDir=caDir,exports.caCertPath=caCertPath,exports.getCertificateSync=getCertificateSync,exports.ensureCaSync=ensureCaSync;const tslib_1=require("tslib"),crypto=tslib_1.__importStar(require("node:crypto")),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),LEAF_MAX_AGE_MS=600*60*60*1e3,CA_TTL_DAYS=3650,CA_MIN_REMAINING_MS=720*60*60*1e3;exports.CA_CERT_FILE="lensmcp-local-ca.crt";const LEGACY_CA_CERT_FILE="davnx-local-ca.crt",CA_KEY_FILE="_ca-key.pem";function caDir(){const e=process.env.LENSMCP_HOME||os.homedir();return path.join(e,".lensmcp","ca")}o(caDir,"caDir"),c(caDir,"caDir"),a(caDir,"caDir");function caCertPath(){return path.join(caDir(),exports.CA_CERT_FILE)}o(caCertPath,"caCertPath"),c(caCertPath,"caCertPath"),a(caCertPath,"caCertPath");function getCertificateSync(e,r="lensmcp.dev",t=[]){const n=require("node-forge");fs.mkdirSync(e,{recursive:!0});const m=loadOrCreateCa(n,e),s=n.pki.certificateToPem(m.cert),i=crypto.createHash("sha256").update([r,...[...t].sort()].join("|")).digest("hex").slice(0,12),u=path.join(e,`_leaf-${i}.pem`);try{const l=fs.statSync(u);if(Date.now()-l.ctimeMs<LEAF_MAX_AGE_MS){const d=fs.readFileSync(u,"utf8");if(d.includes(s))return d}}catch{}const y=createLeafCertificate(n,m,r,t);fs.writeFileSync(u,y);for(const l of fs.readdirSync(e))if(/^_leaf-.*\.pem$/.test(l)&&l!==`_leaf-${i}.pem`||/^_cert.*\.pem$/.test(l)||/-dev\.crt$/.test(l)||l===LEGACY_CA_CERT_FILE)try{fs.unlinkSync(path.join(e,l))}catch{}return y}o(getCertificateSync,"getCertificateSync"),c(getCertificateSync,"getCertificateSync"),a(getCertificateSync,"getCertificateSync");function ensureCaSync(e){const r=require("node-forge");return loadOrCreateCa(r,e),caCertPath()}o(ensureCaSync,"ensureCaSync"),c(ensureCaSync,"ensureCaSync"),a(ensureCaSync,"ensureCaSync");function readCaPair(e,r){try{const t=r.pki.certificateFromPem(fs.readFileSync(path.join(e,exports.CA_CERT_FILE),"utf8")),n=r.pki.privateKeyFromPem(fs.readFileSync(path.join(e,CA_KEY_FILE),"utf8"));if(t.validity.notAfter.getTime()-Date.now()>CA_MIN_REMAINING_MS)return{cert:t,key:n}}catch{}}o(readCaPair,"readCaPair"),c(readCaPair,"readCaPair"),a(readCaPair,"readCaPair");function loadOrCreateCa(e,r){const t=caDir();fs.mkdirSync(t,{recursive:!0});const n=readCaPair(t,e);if(n)return n;for(const i of[CA_KEY_FILE,exports.CA_CERT_FILE])try{fs.unlinkSync(path.join(t,i))}catch{}const m=r&&r!==t?readCaPair(r,e):void 0,s=m??mintCa(e);try{fs.writeFileSync(path.join(t,CA_KEY_FILE),e.pki.privateKeyToPem(s.key),{mode:384,flag:"wx"})}catch(i){if(i.code!=="EEXIST")throw i;const u=spinReadCaPair(t,e);if(u)return u;throw new Error(`machine dev CA at ${t} is claimed but unreadable \u2014 remove the directory and retry`,{cause:i})}return fs.writeFileSync(path.join(t,exports.CA_CERT_FILE),e.pki.certificateToPem(s.cert)),m&&console.log(`[ssl] promoted the existing workspace dev CA to the machine store (${t}) \u2014 keychain trust carries over.`),s}o(loadOrCreateCa,"loadOrCreateCa"),c(loadOrCreateCa,"loadOrCreateCa"),a(loadOrCreateCa,"loadOrCreateCa");function spinReadCaPair(e,r){const t=Date.now()+2e3;for(;;){const n=readCaPair(e,r);if(n||Date.now()>=t)return n;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}o(spinReadCaPair,"spinReadCaPair"),c(spinReadCaPair,"spinReadCaPair"),a(spinReadCaPair,"spinReadCaPair");function mintCa(e){const r=e.pki.rsa.generateKeyPair(2048),t=e.pki.createCertificate();t.publicKey=r.publicKey,t.serialNumber=`00${Date.now().toString(16)}`,t.validity.notBefore=new Date(Date.now()-1440*60*1e3),t.validity.notAfter=new Date,t.validity.notAfter.setDate(t.validity.notAfter.getDate()+CA_TTL_DAYS);const n=[{name:"commonName",value:"lensmcp local dev CA"},{name:"organizationName",value:"lensmcp"},{shortName:"OU",value:"dev"}];return t.setSubject(n),t.setIssuer(n),t.setExtensions([{name:"basicConstraints",cA:!0,critical:!0},{name:"keyUsage",keyCertSign:!0,cRLSign:!0,critical:!0},{name:"subjectKeyIdentifier"}]),t.sign(r.privateKey,e.md.sha256.create()),{cert:t,key:r.privateKey}}o(mintCa,"mintCa"),c(mintCa,"mintCa"),a(mintCa,"mintCa");function createLeafCertificate(e,r,t,n,m=30){const s=e.pki.rsa.generateKeyPair(2048),i=e.pki.createCertificate();i.publicKey=s.publicKey,i.serialNumber=`00${Date.now().toString(16)}`,i.validity.notBefore=new Date(Date.now()-1440*60*1e3),i.validity.notAfter=new Date,i.validity.notAfter.setDate(i.validity.notAfter.getDate()+m),i.setSubject([{name:"commonName",value:t},{name:"organizationName",value:"lensmcp"},{shortName:"OU",value:"dev"}]),i.setIssuer(r.cert.subject.attributes);const u=[{type:2,value:"localhost"},{type:2,value:"*.localhost"},{type:7,ip:"127.0.0.1"},{type:7,ip:"::1"},...[...new Set(n)].filter(y=>y&&y!=="localhost").map(y=>({type:2,value:y}))];return i.setExtensions([{name:"basicConstraints",cA:!1},{name:"keyUsage",digitalSignature:!0,keyEncipherment:!0,critical:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0},{name:"subjectAltName",altNames:u},{name:"subjectKeyIdentifier"}]),i.sign(r.key,e.md.sha256.create()),e.pki.privateKeyToPem(s.privateKey)+e.pki.certificateToPem(i)+e.pki.certificateToPem(r.cert)}o(createLeafCertificate,"createLeafCertificate"),c(createLeafCertificate,"createLeafCertificate"),a(createLeafCertificate,"createLeafCertificate");
package/build-host.js CHANGED
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var p=(s,t)=>u(s,"name",{value:t,configurable:!0});var d=Object.defineProperty,o=p((s,t)=>d(s,"name",{value:t,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0});const host_1=require("./shared-build/host"),protocol_1=require("./shared-build/protocol"),STOP_SIGNALS=["SIGTERM","SIGINT","SIGHUP"],GATEWAY_POLL_MS=5e3;function main(){const s=process.argv.find(e=>e.startsWith(protocol_1.BUILD_HOST_ROOT_FLAG))?.slice(protocol_1.BUILD_HOST_ROOT_FLAG.length);(!s||typeof process.send!="function")&&(console.error("[build-host] started without a workspace root or a gateway channel \u2014 only the dev gateway starts this process"),process.exit(1)),process.env.NODE_ENV="development";const t=o(e=>{if(process.connected)try{process.send(e,void 0,void 0,()=>{})}catch{}},"send"),n=Number(process.env.LENSMCP_BUILD_HOST_PAUSE_MS),c=new host_1.BuildHost({root:s,send:t,log:o(e=>console.log(e),"log"),...Number.isFinite(n)&&n>=0&&process.env.LENSMCP_BUILD_HOST_PAUSE_MS?{pauseMs:n}:{}});let i=!1;const a=o((e,l=0)=>{i||(i=!0,console.log(`stopping (${e})`),c.stop().finally(()=>process.exit(l)),setTimeout(()=>process.exit(l),8e3).unref())},"stop");for(const e of STOP_SIGNALS)process.on(e,()=>a(e));process.on("disconnect",()=>a("the gateway is gone"));const r=Number(process.env.LENSMCP_GATEWAY_PID??0);Number.isInteger(r)&&r>0&&setInterval(()=>{try{process.kill(r,0)}catch(e){e.code!=="EPERM"&&a(`gateway pid ${r} is gone`)}},GATEWAY_POLL_MS).unref(),process.on("message",e=>{i||!e||typeof e!="object"||(e.type==="join"?c.join(e.member,e.join):e.type==="leave"&&c.leave(e.member))}),t({type:"ready",pid:process.pid})}p(main,"main"),o(main,"main"),require.main===module&&main();
1
+ "use strict";var m=Object.defineProperty;var l=(s,t)=>m(s,"name",{value:t,configurable:!0});var u=Object.defineProperty,p=l((s,t)=>u(s,"name",{value:t,configurable:!0}),"p"),d=Object.defineProperty,o=p((s,t)=>d(s,"name",{value:t,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0});const host_1=require("./shared-build/host"),protocol_1=require("./shared-build/protocol"),STOP_SIGNALS=["SIGTERM","SIGINT","SIGHUP"],GATEWAY_POLL_MS=5e3;function main(){const s=process.argv.find(e=>e.startsWith(protocol_1.BUILD_HOST_ROOT_FLAG))?.slice(protocol_1.BUILD_HOST_ROOT_FLAG.length);(!s||typeof process.send!="function")&&(console.error("[build-host] started without a workspace root or a gateway channel \u2014 only the dev gateway starts this process"),process.exit(1)),process.env.NODE_ENV="development";const t=o(e=>{if(process.connected)try{process.send(e,void 0,void 0,()=>{})}catch{}},"send"),n=Number(process.env.LENSMCP_BUILD_HOST_PAUSE_MS),c=new host_1.BuildHost({root:s,send:t,log:o(e=>console.log(e),"log"),...Number.isFinite(n)&&n>=0&&process.env.LENSMCP_BUILD_HOST_PAUSE_MS?{pauseMs:n}:{}});let i=!1;const a=o((e,_=0)=>{i||(i=!0,console.log(`stopping (${e})`),c.stop().finally(()=>process.exit(_)),setTimeout(()=>process.exit(_),8e3).unref())},"stop");for(const e of STOP_SIGNALS)process.on(e,()=>a(e));process.on("disconnect",()=>a("the gateway is gone"));const r=Number(process.env.LENSMCP_GATEWAY_PID??0);Number.isInteger(r)&&r>0&&setInterval(()=>{try{process.kill(r,0)}catch(e){e.code!=="EPERM"&&a(`gateway pid ${r} is gone`)}},GATEWAY_POLL_MS).unref(),process.on("message",e=>{i||!e||typeof e!="object"||(e.type==="join"?c.join(e.member,e.join):e.type==="leave"&&c.leave(e.member))}),t({type:"ready",pid:process.pid})}l(main,"main"),p(main,"main"),o(main,"main"),require.main===module&&main();
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var i=(n,s)=>l(n,"name",{value:s,configurable:!0});var a=Object.defineProperty,u=i((n,s)=>a(n,"name",{value:s,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildScopePatterns=buildScopePatterns;function buildScopePatterns(n){const s=[],p=[],r=[];for(const e of n){if(!e)continue;const o=e.match(/^\/(.+)\/([gimsuy]*)$/);if(o){const t=o[2].replace("g",""),c=new RegExp(o[1],t);s.push(c),r.push(c)}else if(e.includes("/")){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s.push(new RegExp(`^${t}`)),p.push(e)}else if(e.startsWith("@")){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");s.push(new RegExp(`^${t}/`)),p.push(e.endsWith("/")?e:`${e}/`)}else{const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),c=new RegExp(`^${t}(/|$)`);s.push(c),r.push(c)}}return{allowlistPatterns:s,scopePrefixes:p,scopePatterns:r}}i(buildScopePatterns,"buildScopePatterns"),u(buildScopePatterns,"buildScopePatterns");
1
+ "use strict";var $=Object.defineProperty;var f=(s,e)=>$(s,"name",{value:e,configurable:!0});var l=Object.defineProperty,i=f((s,e)=>l(s,"name",{value:e,configurable:!0}),"i"),a=Object.defineProperty,u=i((s,e)=>a(s,"name",{value:e,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildScopePatterns=buildScopePatterns;function buildScopePatterns(s){const e=[],c=[],p=[];for(const t of s){if(!t)continue;const o=t.match(/^\/(.+)\/([gimsuy]*)$/);if(o){const n=o[2].replace("g",""),r=new RegExp(o[1],n);e.push(r),p.push(r)}else if(t.includes("/")){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e.push(new RegExp(`^${n}`)),c.push(t)}else if(t.startsWith("@")){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e.push(new RegExp(`^${n}/`)),c.push(t.endsWith("/")?t:`${t}/`)}else{const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=new RegExp(`^${n}(/|$)`);e.push(r),p.push(r)}}return{allowlistPatterns:e,scopePrefixes:c,scopePatterns:p}}f(buildScopePatterns,"buildScopePatterns"),i(buildScopePatterns,"buildScopePatterns"),u(buildScopePatterns,"buildScopePatterns");
package/bundle-parent.js CHANGED
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var o=(e,t)=>l(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,n=o((e,t)=>d(e,"name",{value:t,configurable:!0}),"n");Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadParentFor=loadParentFor,exports.routeBundleRequires=routeBundleRequires;const tslib_1=require("tslib"),nodeModule=tslib_1.__importStar(require("node:module")),path=tslib_1.__importStar(require("node:path")),ModuleCtor=nodeModule.Module,standIns=new Map,isStandIn=new WeakSet;let wrapped=!1;function standInFor(e){const t=standIns.get(e);if(t)return t;const r=new ModuleCtor(e,null);return r.filename=e,r.paths=ModuleCtor._nodeModulePaths(path.dirname(e)),r.loaded=!0,standIns.set(e,r),isStandIn.add(r),r}o(standInFor,"standInFor"),n(standInFor,"standInFor");function loadParentFor(e){if(!e||typeof e!="object"||isStandIn.has(e))return e;const t=e.filename;return typeof t=="string"?standIns.get(t)??e:e}o(loadParentFor,"loadParentFor"),n(loadParentFor,"loadParentFor");function routeBundleRequires(...e){for(const r of e)standInFor(r);if(wrapped)return;wrapped=!0;const t=ModuleCtor._load;ModuleCtor._load=n(function(r,a,...u){return t.call(this,r,loadParentFor(a),...u)},"lensmcpBundleParent")}o(routeBundleRequires,"routeBundleRequires"),n(routeBundleRequires,"routeBundleRequires");
1
+ "use strict";var i=Object.defineProperty;var a=(e,t)=>i(e,"name",{value:t,configurable:!0});var l=Object.defineProperty,o=a((e,t)=>l(e,"name",{value:t,configurable:!0}),"o"),d=Object.defineProperty,n=o((e,t)=>d(e,"name",{value:t,configurable:!0}),"n");Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadParentFor=loadParentFor,exports.routeBundleRequires=routeBundleRequires;const tslib_1=require("tslib"),nodeModule=tslib_1.__importStar(require("node:module")),path=tslib_1.__importStar(require("node:path")),ModuleCtor=nodeModule.Module,standIns=new Map,isStandIn=new WeakSet;let wrapped=!1;function standInFor(e){const t=standIns.get(e);if(t)return t;const r=new ModuleCtor(e,null);return r.filename=e,r.paths=ModuleCtor._nodeModulePaths(path.dirname(e)),r.loaded=!0,standIns.set(e,r),isStandIn.add(r),r}a(standInFor,"standInFor"),o(standInFor,"standInFor"),n(standInFor,"standInFor");function loadParentFor(e){if(!e||typeof e!="object"||isStandIn.has(e))return e;const t=e.filename;return typeof t=="string"?standIns.get(t)??e:e}a(loadParentFor,"loadParentFor"),o(loadParentFor,"loadParentFor"),n(loadParentFor,"loadParentFor");function routeBundleRequires(...e){for(const r of e)standInFor(r);if(wrapped)return;wrapped=!0;const t=ModuleCtor._load;ModuleCtor._load=n(function(r,u,...s){return t.call(this,r,loadParentFor(u),...s)},"lensmcpBundleParent")}a(routeBundleRequires,"routeBundleRequires"),o(routeBundleRequires,"routeBundleRequires"),n(routeBundleRequires,"routeBundleRequires");
package/checkout-cache.js CHANGED
@@ -1 +1 @@
1
- "use strict";var a=Object.defineProperty;var t=(e,r)=>a(e,"name",{value:r,configurable:!0});var u=Object.defineProperty,o=t((e,r)=>u(e,"name",{value:r,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ownsNodeModules=ownsNodeModules,exports.checkoutCacheDir=checkoutCacheDir;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path"));function ownsNodeModules(e){let r;try{r=fs.realpathSync(e)}catch{return!0}const n=path.join(r,"node_modules");for(const[s,i]of[[path.join(e,"node_modules"),n],[path.join(e,"node_modules",".cache"),path.join(n,".cache")]]){let c;try{c=fs.realpathSync(s)}catch{continue}if(c!==i)return!1}return!0}t(ownsNodeModules,"ownsNodeModules"),o(ownsNodeModules,"ownsNodeModules");function checkoutCacheDir(e,r){return ownsNodeModules(e)?path.join(e,"node_modules",".cache",r):path.join(e,".lensmcp","cache",r)}t(checkoutCacheDir,"checkoutCacheDir"),o(checkoutCacheDir,"checkoutCacheDir");
1
+ "use strict";var l=Object.defineProperty;var c=(e,r)=>l(e,"name",{value:r,configurable:!0});var a=Object.defineProperty,t=c((e,r)=>a(e,"name",{value:r,configurable:!0}),"t"),u=Object.defineProperty,o=t((e,r)=>u(e,"name",{value:r,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.ownsNodeModules=ownsNodeModules,exports.checkoutCacheDir=checkoutCacheDir;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path"));function ownsNodeModules(e){let r;try{r=fs.realpathSync(e)}catch{return!0}const n=path.join(r,"node_modules");for(const[s,d]of[[path.join(e,"node_modules"),n],[path.join(e,"node_modules",".cache"),path.join(n,".cache")]]){let i;try{i=fs.realpathSync(s)}catch{continue}if(i!==d)return!1}return!0}c(ownsNodeModules,"ownsNodeModules"),t(ownsNodeModules,"ownsNodeModules"),o(ownsNodeModules,"ownsNodeModules");function checkoutCacheDir(e,r){return ownsNodeModules(e)?path.join(e,"node_modules",".cache",r):path.join(e,".lensmcp","cache",r)}c(checkoutCacheDir,"checkoutCacheDir"),t(checkoutCacheDir,"checkoutCacheDir"),o(checkoutCacheDir,"checkoutCacheDir");
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var c=(t,e)=>o(t,"name",{value:e,configurable:!0});var r=Object.defineProperty,n=c((t,e)=>r(t,"name",{value:e,configurable:!0}),"n");Object.defineProperty(exports,"__esModule",{value:!0}),exports.childProcessEnv=childProcessEnv;function childProcessEnv(t){const e={...t};return e.FORCE_COLOR!==void 0&&(delete e.NO_COLOR,delete e.NODE_DISABLE_COLORS),e}c(childProcessEnv,"childProcessEnv"),n(childProcessEnv,"childProcessEnv");
1
+ "use strict";var i=Object.defineProperty;var s=(t,e)=>i(t,"name",{value:e,configurable:!0});var o=Object.defineProperty,c=s((t,e)=>o(t,"name",{value:e,configurable:!0}),"c"),r=Object.defineProperty,n=c((t,e)=>r(t,"name",{value:e,configurable:!0}),"n");Object.defineProperty(exports,"__esModule",{value:!0}),exports.childProcessEnv=childProcessEnv;function childProcessEnv(t){const e={...t};return e.FORCE_COLOR!==void 0&&(delete e.NO_COLOR,delete e.NODE_DISABLE_COLORS),e}s(childProcessEnv,"childProcessEnv"),c(childProcessEnv,"childProcessEnv"),n(childProcessEnv,"childProcessEnv");
package/compile-retry.js CHANGED
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var u=(t,r)=>c(t,"name",{value:r,configurable:!0});var d=Object.defineProperty,s=u((t,r)=>d(t,"name",{value:r,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.RETRY_AFTER_FAILURE_MS=void 0,exports.createFailureRetry=createFailureRetry,exports.RETRY_AFTER_FAILURE_MS=[2e3,5e3,15e3,3e4,6e4];function createFailureRetry(t,r=exports.RETRY_AFTER_FAILURE_MS){let i=0,e,a=!1;return{failed(){i+=1;const o=r[Math.min(i,r.length)-1]??6e4;return e&&clearTimeout(e),a||(e=setTimeout(()=>{e=void 0,a||t()},o),e.unref?.()),{delayMs:o,retry:i}},succeeded(){const o=i;return i=0,e&&(clearTimeout(e),e=void 0),o},dispose(){a=!0,e&&(clearTimeout(e),e=void 0)}}}u(createFailureRetry,"createFailureRetry"),s(createFailureRetry,"createFailureRetry");
1
+ "use strict";var n=Object.defineProperty;var l=(t,r)=>n(t,"name",{value:r,configurable:!0});var c=Object.defineProperty,u=l((t,r)=>c(t,"name",{value:r,configurable:!0}),"u"),d=Object.defineProperty,s=u((t,r)=>d(t,"name",{value:r,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.RETRY_AFTER_FAILURE_MS=void 0,exports.createFailureRetry=createFailureRetry,exports.RETRY_AFTER_FAILURE_MS=[2e3,5e3,15e3,3e4,6e4];function createFailureRetry(t,r=exports.RETRY_AFTER_FAILURE_MS){let a=0,e,i=!1;return{failed(){a+=1;const o=r[Math.min(a,r.length)-1]??6e4;return e&&clearTimeout(e),i||(e=setTimeout(()=>{e=void 0,i||t()},o),e.unref?.()),{delayMs:o,retry:a}},succeeded(){const o=a;return a=0,e&&(clearTimeout(e),e=void 0),o},dispose(){i=!0,e&&(clearTimeout(e),e=void 0)}}}l(createFailureRetry,"createFailureRetry"),u(createFailureRetry,"createFailureRetry"),s(createFailureRetry,"createFailureRetry");
package/config-files.js CHANGED
@@ -1 +1 @@
1
- "use strict";var F=Object.defineProperty;var c=(e,i)=>F(e,"name",{value:i,configurable:!0});var d=Object.defineProperty,l=c((e,i)=>d(e,"name",{value:i,configurable:!0}),"l");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CONFIG_POLL_MS=exports.ConfigFilesPlugin=void 0,exports.configFilesOf=configFilesOf,exports.watchConfigFiles=watchConfigFiles;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),workspace_paths_1=require("./workspace-paths");function configFilesOf(e){const i=((0,workspace_paths_1.readWorkspacePaths)(e.tsConfig,e.workspaceRoot)?.configFiles??[path.resolve(e.workspaceRoot,e.tsConfig)]).filter(s=>!s.split(path.sep).includes("node_modules"));return e.webpackConfigPath&&i.push(path.resolve(e.appRoot,e.webpackConfigPath)),[...new Set(i)]}c(configFilesOf,"configFilesOf"),l(configFilesOf,"configFilesOf");class ConfigFilesPlugin{static{c(this,"ConfigFilesPlugin")}static{l(this,"ConfigFilesPlugin")}constructor(i){this.options=i}apply(i){i.hooks.afterCompile.tap("LensmcpConfigFiles",s=>{for(const n of this.options.files())s.fileDependencies.add(n)}),i.hooks.watchRun.tap("LensmcpConfigFiles",s=>{if(!s.modifiedFiles&&!s.removedFiles)return;const n=new Set(this.options.files()),t=[...s.modifiedFiles??[],...s.removedFiles??[]].filter(f=>n.has(f));t.length>0&&this.options.changed([...new Set(t)])})}}exports.ConfigFilesPlugin=ConfigFilesPlugin,exports.CONFIG_POLL_MS=1e3;const CONFIG_SETTLE_MS=100;function watchConfigFiles(e){const i=e.intervalMs??exports.CONFIG_POLL_MS,s=new Map,n=new Set;let t,f=!1;const g=l(()=>{if(t=void 0,f||n.size===0)return;const r=[...n].sort();n.clear(),h(),e.changed(r)},"flush"),h=l(()=>{let r;try{r=new Set(e.files())}catch{return}for(const[o,a]of s)r.has(o)||(fs.unwatchFile(o,a),s.delete(o));for(const o of r){if(s.has(o))continue;const a=l((p,u)=>{p.mtimeMs===u.mtimeMs&&p.size===u.size&&p.ino===u.ino||(n.add(o),t||(t=setTimeout(g,CONFIG_SETTLE_MS),t.unref?.()))},"listener");fs.watchFile(o,{persistent:!1,interval:i},a),s.set(o,a)}},"sync");return h(),{close(){f=!0,t&&clearTimeout(t);for(const[r,o]of s)fs.unwatchFile(r,o);s.clear()}}}c(watchConfigFiles,"watchConfigFiles"),l(watchConfigFiles,"watchConfigFiles");
1
+ "use strict";var C=Object.defineProperty;var a=(e,i)=>C(e,"name",{value:i,configurable:!0});var F=Object.defineProperty,c=a((e,i)=>F(e,"name",{value:i,configurable:!0}),"c"),d=Object.defineProperty,l=c((e,i)=>d(e,"name",{value:i,configurable:!0}),"l");Object.defineProperty(exports,"__esModule",{value:!0}),exports.CONFIG_POLL_MS=exports.ConfigFilesPlugin=void 0,exports.configFilesOf=configFilesOf,exports.watchConfigFiles=watchConfigFiles;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),workspace_paths_1=require("./workspace-paths");function configFilesOf(e){const i=((0,workspace_paths_1.readWorkspacePaths)(e.tsConfig,e.workspaceRoot)?.configFiles??[path.resolve(e.workspaceRoot,e.tsConfig)]).filter(t=>!t.split(path.sep).includes("node_modules"));return e.webpackConfigPath&&i.push(path.resolve(e.appRoot,e.webpackConfigPath)),[...new Set(i)]}a(configFilesOf,"configFilesOf"),c(configFilesOf,"configFilesOf"),l(configFilesOf,"configFilesOf");class ConfigFilesPlugin{static{a(this,"ConfigFilesPlugin")}static{c(this,"ConfigFilesPlugin")}static{l(this,"ConfigFilesPlugin")}constructor(i){this.options=i}apply(i){i.hooks.afterCompile.tap("LensmcpConfigFiles",t=>{for(const n of this.options.files())t.fileDependencies.add(n)}),i.hooks.watchRun.tap("LensmcpConfigFiles",t=>{if(!t.modifiedFiles&&!t.removedFiles)return;const n=new Set(this.options.files()),s=[...t.modifiedFiles??[],...t.removedFiles??[]].filter(f=>n.has(f));s.length>0&&this.options.changed([...new Set(s)])})}}exports.ConfigFilesPlugin=ConfigFilesPlugin,exports.CONFIG_POLL_MS=1e3;const CONFIG_SETTLE_MS=100;function watchConfigFiles(e){const i=e.intervalMs??exports.CONFIG_POLL_MS,t=new Map,n=new Set;let s,f=!1;const w=l(()=>{if(s=void 0,f||n.size===0)return;const r=[...n].sort();n.clear(),g(),e.changed(r)},"flush"),g=l(()=>{let r;try{r=new Set(e.files())}catch{return}for(const[o,p]of t)r.has(o)||(fs.unwatchFile(o,p),t.delete(o));for(const o of r){if(t.has(o))continue;const p=l((h,u)=>{h.mtimeMs===u.mtimeMs&&h.size===u.size&&h.ino===u.ino||(n.add(o),s||(s=setTimeout(w,CONFIG_SETTLE_MS),s.unref?.()))},"listener");fs.watchFile(o,{persistent:!1,interval:i},p),t.set(o,p)}},"sync");return g(),{close(){f=!0,s&&clearTimeout(s);for(const[r,o]of t)fs.unwatchFile(r,o);t.clear()}}}a(watchConfigFiles,"watchConfigFiles"),c(watchConfigFiles,"watchConfigFiles"),l(watchConfigFiles,"watchConfigFiles");
@@ -1 +1 @@
1
- "use strict";var j=Object.defineProperty;var p=(r,e)=>j(r,"name",{value:e,configurable:!0});var O=Object.defineProperty,c=p((r,e)=>O(r,"name",{value:e,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DevBuildFinalizePlugin=exports.DevServerReloadPlugin=exports.devserverControlSock=exports.DevserverNotifier=void 0,exports.devCacheOptions=devCacheOptions,exports.devModuleFilename=devModuleFilename,exports.createDevWebpackConfig=createDevWebpackConfig;const tslib_1=require("tslib"),app_plugin_1=require("@nx/webpack/app-plugin"),node_crypto_1=require("node:crypto"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),webpack_node_externals_1=tslib_1.__importDefault(require("webpack-node-externals")),build_scope_patterns_1=require("./build-scope-patterns"),checkout_cache_1=require("./checkout-cache"),dev_devtool_1=require("./dev-devtool"),tsgo_check_plugin_1=require("./tsgo-check-plugin"),fork_ts_check_reporter_1=require("./fork-ts-check-reporter"),perf_rules_plugin_1=require("./perf/perf-rules-plugin"),devserver_notifier_1=require("./devserver-notifier"),workspace_paths_1=require("./workspace-paths");var devserver_notifier_2=require("./devserver-notifier");Object.defineProperty(exports,"DevserverNotifier",{enumerable:!0,get:c(function(){return devserver_notifier_2.DevserverNotifier},"get")}),Object.defineProperty(exports,"devserverControlSock",{enumerable:!0,get:c(function(){return devserver_notifier_2.devserverControlSock},"get")});const webpack=require("webpack");class DevServerReloadPlugin{static{p(this,"DevServerReloadPlugin")}static{c(this,"DevServerReloadPlugin")}constructor(e,i=!1,a,o=Number(process.env.LENSMCP_GATEWAY_PID??0)>0){this.notifier=new devserver_notifier_1.DevserverNotifier(e,i,a,o)}snapshot(){return this.notifier.snapshot()}apply(e){const i="DevServerReloadPlugin";let a=!1;e.hooks.watchRun?.tap(i,o=>{const s=[...o?.modifiedFiles??[],...o?.removedFiles??[]].filter(n=>typeof n=="string");if(!a){const n=o?.watchFileSystem?.watcher;n&&typeof n.on=="function"&&(a=!0,n.on("error",l=>this.notifier.degrade(`watcher error: ${l?.message??String(l)}`)))}this.notifier.watchRun(s)}),e.hooks.watchClose?.tap(i,()=>this.notifier.degrade("watch closed")),e.hooks.failed?.tap(i,o=>this.notifier.failed(`compiler failed: ${o?.message??String(o)}`)),e.hooks.done.tap(i,async o=>{if(o.hasErrors()){this.notifier.failed();return}await this.notifier.built()})}}exports.DevServerReloadPlugin=DevServerReloadPlugin;const DEV_CACHE_MEMORY_GENERATIONS=5,DEV_CACHE_MAX_AGE_MS=10080*60*1e3,LOCKFILES=["yarn.lock","package-lock.json","pnpm-lock.yaml","bun.lock"];function clusterVersion(){for(const r of[path.join(__dirname,"package.json"),path.join(__dirname,"..","package.json")])try{const e=JSON.parse(fs.readFileSync(r,"utf8"));if(e.name==="@lensmcp/cluster"&&e.version)return e.version}catch{}return"unknown"}p(clusterVersion,"clusterVersion"),c(clusterVersion,"clusterVersion");function devCacheOptions(r,e){const{appName:i,appRoot:a,workspaceRoot:o,tsConfig:s,webpackConfigPath:n}=r,l=clusterVersion(),_=JSON.stringify({lensmcp:l,devtool:e,buildLibsFromSource:r.buildLibsFromSource??!0,orgScopes:r.orgScopes??[],bundlePackages:r.bundlePackages??[],nodeExternalsConfig:r.nodeExternalsConfig??null}),f=c(g=>g.filter(d=>fs.existsSync(d)),"existing"),k=(0,workspace_paths_1.readWorkspacePaths)(s,o)?.configFiles??[path.resolve(o,s)],v={lensmcp:[__filename],lockfile:f(LOCKFILES.map(g=>path.join(o,g))),tsconfig:f([...new Set([...k,path.join(o,"tsconfig.base.json")])])};return n&&(v.overrides=[path.resolve(a,n)]),{type:"filesystem",cacheDirectory:(0,checkout_cache_1.checkoutCacheDir)(o,"lensmcp-webpack"),name:i.replace(/[^\w.-]+/g,"_"),version:`${l}-${(0,node_crypto_1.createHash)("sha256").update(_).digest("hex").slice(0,16)}`,buildDependencies:v,maxMemoryGenerations:DEV_CACHE_MEMORY_GENERATIONS,maxAge:DEV_CACHE_MAX_AGE_MS}}p(devCacheOptions,"devCacheOptions"),c(devCacheOptions,"devCacheOptions");function devModuleFilename(r){const e=r.absoluteResourcePath;return path.isAbsolute(e)?`file://${e}`:e}p(devModuleFilename,"devModuleFilename"),c(devModuleFilename,"devModuleFilename");class DevBuildFinalizePlugin{static{p(this,"DevBuildFinalizePlugin")}static{c(this,"DevBuildFinalizePlugin")}constructor(e){this.options=e}apply(e){const{cache:i}=this.options;e.options.cache={...i,buildDependencies:{...i.buildDependencies}},e.options.context&&(e.context=e.options.context);const a=e.options.resolve?.plugins??[];if(a.some(o=>o instanceof workspace_paths_1.WorkspacePathsResolverPlugin)){const o=new Set(a);e.hooks.afterPlugins.tap("DevBuildFinalizePlugin",()=>{const s=e.options.resolve;s.plugins=s.plugins.filter(n=>o.has(n)||n?.constructor?.name!=="TsconfigPathsPlugin")})}if(this.options.tsSourceMaps)for(const o of e.options.module?.rules??[])typeof o?.loader!="string"||!/[\\/]ts-loader[\\/]/.test(o.loader)||(o.options={...o.options,compilerOptions:{...o.options?.compilerOptions,sourceMap:!0,inlineSourceMap:!1}})}}exports.DevBuildFinalizePlugin=DevBuildFinalizePlugin;function createDevWebpackConfig(r){const{appRoot:e,outputDir:i,main:a,tsConfig:o,workspaceRoot:s,assets:n=[],port:l,memoryLimit:_=8192,buildLibsFromSource:f=!0,orgScopes:k=[],bundlePackages:v=[],additionalEntryPoints:g=[],nodeExternalsConfig:d,webpackConfigPath:b}=r,{allowlistPatterns:N,scopePrefixes:x,scopePatterns:M}=(0,build_scope_patterns_1.buildScopePatterns)(k),w=(0,tsgo_check_plugin_1.typecheckMode)(process.env),S=w==="tsgo"?(0,tsgo_check_plugin_1.resolveTsgoBin)(s,process.env.LENSMCP_TSGO_BIN):null;if(w==="tsgo"&&!S){const t=`${tsgo_check_plugin_1.TSGO_MISSING_CAUSE}. Fell back to fork-ts-checker, which reports to the console only \u2014 so typecheck:// has no producer for this project until it is fixed`;console.warn(`[serve] ${r.appName}: the type checker is tsgo but ${t}.`),(0,tsgo_check_plugin_1.reportTsgoUnavailable)({appName:r.appName,tsConfig:o,workspaceRoot:s,detail:t})}const C=!!S,P=(0,dev_devtool_1.resolveDevDevtool)(r.devtool);P.rejected&&console.warn(`[serve] ${r.appName}: '${P.rejected}' (devtool / ${dev_devtool_1.DEV_DEVTOOL_ENV}) is not a webpack devtool \u2014 building with '${dev_devtool_1.DEFAULT_DEV_DEVTOOL}'.`);const h=P.devtool,D=f?(0,workspace_paths_1.readWorkspacePaths)(o,s):null,E=v.map(t=>new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(/|$)`)),R=[/webpack\/hot\/poll\?100/,...N,...E,...d?.allowlist||[]],y={output:{path:i,...process.env.NODE_ENV!=="production"&&{devtoolModuleFilenameTemplate:devModuleFilename},clean:!0},externals:[(0,webpack_node_externals_1.default)({allowlist:R,additionalModuleDirs:d?.additionalModuleDirs||[],...d?.importType&&{importType:d.importType}}),({request:t},m)=>{if(t&&path.isAbsolute(t)&&t.startsWith(s)&&!t.includes("node_modules")||t&&(t.startsWith(path.join(s,"apps"))||t.startsWith(path.join(s,"libs")))||t&&x.some(u=>t.startsWith(u))||t&&M.some(u=>u.test(t))||t&&E.some(u=>u.test(t)))return m();if(t&&!(t.startsWith("./")||t.startsWith(".."))){const u=t.startsWith("@")?t.split("/").slice(0,2).join("/"):t.split("/")[0];return fs.existsSync(path.join(s,"node_modules",u))?m(null,`commonjs ${t}`):m()}return m()}],mode:"development",devtool:h,...(0,workspace_paths_1.hasPathMappings)(D)&&{resolve:{plugins:[new workspace_paths_1.WorkspacePathsResolverPlugin(D)]}},plugins:[new webpack.HotModuleReplacementPlugin,new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:a,additionalEntryPoints:g,verbose:!0,sourceMap:h,mergeExternals:!0,externalDependencies:[],memoryLimit:_,tsConfig:o,assets:n,optimization:!1,progress:!1,outputHashing:"none",generatePackageJson:!1,watchDependencies:!0,typeCheckOptions:process.env.LENSMCP_TYPECHECK==="off"||C?!1:{async:!0},buildLibsFromSource:f}),new DevBuildFinalizePlugin({cache:devCacheOptions(r,h),tsSourceMaps:(0,dev_devtool_1.bundleCarriesSourceMaps)(h)}),new DevServerReloadPlugin(l,r.httpsReload===!0,(0,devserver_notifier_1.devserverControlSock)(r.serviceName)),new perf_rules_plugin_1.PerfRulesPlugin({project:process.env.LENSMCP_PROJECT||r.appName,workspaceRoot:s,tsConfig:o}),...C?[new tsgo_check_plugin_1.TsgoCheckPlugin({appName:r.appName,tsConfig:o,workspaceRoot:s,...process.env.LENSMCP_TSGO_BIN?{binPath:process.env.LENSMCP_TSGO_BIN}:{}})]:process.env.LENSMCP_TYPECHECK==="off"?[]:[new fork_ts_check_reporter_1.ForkTsCheckReporterPlugin({appName:r.appName,tsConfig:o,workspaceRoot:s})]],snapshot:{managedPaths:[/^(.+?[\\/])?node_modules[\\/]/]},watch:!0,watchOptions:{ignored:["**/*.env.template","**/config.template.json","**/*.md","**/dist/**","**/migrations/**"]}};if(b){const t=require(path.resolve(e,b));return(t.default||t)(y)}return y}p(createDevWebpackConfig,"createDevWebpackConfig"),c(createDevWebpackConfig,"createDevWebpackConfig");
1
+ "use strict";var T=Object.defineProperty;var l=(t,e)=>T(t,"name",{value:e,configurable:!0});var j=Object.defineProperty,p=l((t,e)=>j(t,"name",{value:e,configurable:!0}),"p"),O=Object.defineProperty,c=p((t,e)=>O(t,"name",{value:e,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DevBuildFinalizePlugin=exports.DevServerReloadPlugin=exports.devserverControlSock=exports.DevserverNotifier=void 0,exports.devCacheOptions=devCacheOptions,exports.devModuleFilename=devModuleFilename,exports.createDevWebpackConfig=createDevWebpackConfig;const tslib_1=require("tslib"),app_plugin_1=require("@nx/webpack/app-plugin"),node_crypto_1=require("node:crypto"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),webpack_node_externals_1=tslib_1.__importDefault(require("webpack-node-externals")),build_scope_patterns_1=require("./build-scope-patterns"),checkout_cache_1=require("./checkout-cache"),dev_devtool_1=require("./dev-devtool"),tsgo_check_plugin_1=require("./tsgo-check-plugin"),fork_ts_check_reporter_1=require("./fork-ts-check-reporter"),perf_rules_plugin_1=require("./perf/perf-rules-plugin"),devserver_notifier_1=require("./devserver-notifier"),workspace_paths_1=require("./workspace-paths");var devserver_notifier_2=require("./devserver-notifier");Object.defineProperty(exports,"DevserverNotifier",{enumerable:!0,get:c(function(){return devserver_notifier_2.DevserverNotifier},"get")}),Object.defineProperty(exports,"devserverControlSock",{enumerable:!0,get:c(function(){return devserver_notifier_2.devserverControlSock},"get")});const webpack=require("webpack");class DevServerReloadPlugin{static{l(this,"DevServerReloadPlugin")}static{p(this,"DevServerReloadPlugin")}static{c(this,"DevServerReloadPlugin")}constructor(e,r=!1,a,o=Number(process.env.LENSMCP_GATEWAY_PID??0)>0){this.notifier=new devserver_notifier_1.DevserverNotifier(e,r,a,o)}snapshot(){return this.notifier.snapshot()}apply(e){const r="DevServerReloadPlugin";let a=!1;e.hooks.watchRun?.tap(r,o=>{const i=[...o?.modifiedFiles??[],...o?.removedFiles??[]].filter(n=>typeof n=="string");if(!a){const n=o?.watchFileSystem?.watcher;n&&typeof n.on=="function"&&(a=!0,n.on("error",u=>this.notifier.degrade(`watcher error: ${u?.message??String(u)}`)))}this.notifier.watchRun(i)}),e.hooks.watchClose?.tap(r,()=>this.notifier.degrade("watch closed")),e.hooks.failed?.tap(r,o=>this.notifier.failed(`compiler failed: ${o?.message??String(o)}`)),e.hooks.done.tap(r,async o=>{if(o.hasErrors()){this.notifier.failed();return}await this.notifier.built()})}}exports.DevServerReloadPlugin=DevServerReloadPlugin;const DEV_CACHE_MEMORY_GENERATIONS=5,DEV_CACHE_MAX_AGE_MS=10080*60*1e3,LOCKFILES=["yarn.lock","package-lock.json","pnpm-lock.yaml","bun.lock"];function clusterVersion(){for(const t of[path.join(__dirname,"package.json"),path.join(__dirname,"..","package.json")])try{const e=JSON.parse(fs.readFileSync(t,"utf8"));if(e.name==="@lensmcp/cluster"&&e.version)return e.version}catch{}return"unknown"}l(clusterVersion,"clusterVersion"),p(clusterVersion,"clusterVersion"),c(clusterVersion,"clusterVersion");function devCacheOptions(t,e){const{appName:r,appRoot:a,workspaceRoot:o,tsConfig:i,webpackConfigPath:n}=t,u=clusterVersion(),k=JSON.stringify({lensmcp:u,devtool:e,buildLibsFromSource:t.buildLibsFromSource??!0,orgScopes:t.orgScopes??[],bundlePackages:t.bundlePackages??[],nodeExternalsConfig:t.nodeExternalsConfig??null}),f=c(g=>g.filter(v=>fs.existsSync(v)),"existing"),P=(0,workspace_paths_1.readWorkspacePaths)(i,o)?.configFiles??[path.resolve(o,i)],h={lensmcp:[__filename],lockfile:f(LOCKFILES.map(g=>path.join(o,g))),tsconfig:f([...new Set([...P,path.join(o,"tsconfig.base.json")])])};return n&&(h.overrides=[path.resolve(a,n)]),{type:"filesystem",cacheDirectory:(0,checkout_cache_1.checkoutCacheDir)(o,"lensmcp-webpack"),name:r.replace(/[^\w.-]+/g,"_"),version:`${u}-${(0,node_crypto_1.createHash)("sha256").update(k).digest("hex").slice(0,16)}`,buildDependencies:h,maxMemoryGenerations:DEV_CACHE_MEMORY_GENERATIONS,maxAge:DEV_CACHE_MAX_AGE_MS}}l(devCacheOptions,"devCacheOptions"),p(devCacheOptions,"devCacheOptions"),c(devCacheOptions,"devCacheOptions");function devModuleFilename(t){const e=t.absoluteResourcePath;return path.isAbsolute(e)?`file://${e}`:e}l(devModuleFilename,"devModuleFilename"),p(devModuleFilename,"devModuleFilename"),c(devModuleFilename,"devModuleFilename");class DevBuildFinalizePlugin{static{l(this,"DevBuildFinalizePlugin")}static{p(this,"DevBuildFinalizePlugin")}static{c(this,"DevBuildFinalizePlugin")}constructor(e){this.options=e}apply(e){const{cache:r}=this.options;e.options.cache={...r,buildDependencies:{...r.buildDependencies}},e.options.context&&(e.context=e.options.context);const a=e.options.resolve?.plugins??[];if(a.some(o=>o instanceof workspace_paths_1.WorkspacePathsResolverPlugin)){const o=new Set(a);e.hooks.afterPlugins.tap("DevBuildFinalizePlugin",()=>{const i=e.options.resolve;i.plugins=i.plugins.filter(n=>o.has(n)||n?.constructor?.name!=="TsconfigPathsPlugin")})}if(this.options.tsSourceMaps)for(const o of e.options.module?.rules??[])typeof o?.loader!="string"||!/[\\/]ts-loader[\\/]/.test(o.loader)||(o.options={...o.options,compilerOptions:{...o.options?.compilerOptions,sourceMap:!0,inlineSourceMap:!1}})}}exports.DevBuildFinalizePlugin=DevBuildFinalizePlugin;function createDevWebpackConfig(t){const{appRoot:e,outputDir:r,main:a,tsConfig:o,workspaceRoot:i,assets:n=[],port:u,memoryLimit:k=8192,buildLibsFromSource:f=!0,orgScopes:P=[],bundlePackages:h=[],additionalEntryPoints:g=[],nodeExternalsConfig:v,webpackConfigPath:S}=t,{allowlistPatterns:x,scopePrefixes:M,scopePatterns:R}=(0,build_scope_patterns_1.buildScopePatterns)(P),w=(0,tsgo_check_plugin_1.typecheckMode)(process.env),C=w==="tsgo"?(0,tsgo_check_plugin_1.resolveTsgoBin)(i,process.env.LENSMCP_TSGO_BIN):null;if(w==="tsgo"&&!C){const s=`${tsgo_check_plugin_1.TSGO_MISSING_CAUSE}. Fell back to fork-ts-checker, which reports to the console only \u2014 so typecheck:// has no producer for this project until it is fixed`;console.warn(`[serve] ${t.appName}: the type checker is tsgo but ${s}.`),(0,tsgo_check_plugin_1.reportTsgoUnavailable)({appName:t.appName,tsConfig:o,workspaceRoot:i,detail:s})}const D=!!C,b=(0,dev_devtool_1.resolveDevDevtool)(t.devtool);b.rejected&&console.warn(`[serve] ${t.appName}: '${b.rejected}' (devtool / ${dev_devtool_1.DEV_DEVTOOL_ENV}) is not a webpack devtool \u2014 building with '${dev_devtool_1.DEFAULT_DEV_DEVTOOL}'.`);const m=b.devtool,E=f?(0,workspace_paths_1.readWorkspacePaths)(o,i):null,y=h.map(s=>new RegExp(`^${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(/|$)`)),F=[/webpack\/hot\/poll\?100/,...x,...y,...v?.allowlist||[]],N={output:{path:r,...process.env.NODE_ENV!=="production"&&{devtoolModuleFilenameTemplate:devModuleFilename},clean:!0},externals:[(0,webpack_node_externals_1.default)({allowlist:F,additionalModuleDirs:v?.additionalModuleDirs||[],...v?.importType&&{importType:v.importType}}),({request:s},_)=>{if(s&&path.isAbsolute(s)&&s.startsWith(i)&&!s.includes("node_modules")||s&&(s.startsWith(path.join(i,"apps"))||s.startsWith(path.join(i,"libs")))||s&&M.some(d=>s.startsWith(d))||s&&R.some(d=>d.test(s))||s&&y.some(d=>d.test(s)))return _();if(s&&!(s.startsWith("./")||s.startsWith(".."))){const d=s.startsWith("@")?s.split("/").slice(0,2).join("/"):s.split("/")[0];return fs.existsSync(path.join(i,"node_modules",d))?_(null,`commonjs ${s}`):_()}return _()}],mode:"development",devtool:m,...(0,workspace_paths_1.hasPathMappings)(E)&&{resolve:{plugins:[new workspace_paths_1.WorkspacePathsResolverPlugin(E)]}},plugins:[new webpack.HotModuleReplacementPlugin,new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:a,additionalEntryPoints:g,verbose:!0,sourceMap:m,mergeExternals:!0,externalDependencies:[],memoryLimit:k,tsConfig:o,assets:n,optimization:!1,progress:!1,outputHashing:"none",generatePackageJson:!1,watchDependencies:!0,typeCheckOptions:process.env.LENSMCP_TYPECHECK==="off"||D?!1:{async:!0},buildLibsFromSource:f}),new DevBuildFinalizePlugin({cache:devCacheOptions(t,m),tsSourceMaps:(0,dev_devtool_1.bundleCarriesSourceMaps)(m)}),new DevServerReloadPlugin(u,t.httpsReload===!0,(0,devserver_notifier_1.devserverControlSock)(t.serviceName)),new perf_rules_plugin_1.PerfRulesPlugin({project:process.env.LENSMCP_PROJECT||t.appName,workspaceRoot:i,tsConfig:o}),...D?[new tsgo_check_plugin_1.TsgoCheckPlugin({appName:t.appName,tsConfig:o,workspaceRoot:i,...process.env.LENSMCP_TSGO_BIN?{binPath:process.env.LENSMCP_TSGO_BIN}:{}})]:process.env.LENSMCP_TYPECHECK==="off"?[]:[new fork_ts_check_reporter_1.ForkTsCheckReporterPlugin({appName:t.appName,tsConfig:o,workspaceRoot:i})]],snapshot:{managedPaths:[/^(.+?[\\/])?node_modules[\\/]/]},watch:!0,watchOptions:{ignored:["**/*.env.template","**/config.template.json","**/*.md","**/dist/**","**/migrations/**"]}};if(S){const s=require(path.resolve(e,S));return(s.default||s)(N)}return N}l(createDevWebpackConfig,"createDevWebpackConfig"),p(createDevWebpackConfig,"createDevWebpackConfig"),c(createDevWebpackConfig,"createDevWebpackConfig");
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var d=(o,n)=>A(o,"name",{value:n,configurable:!0});var F=Object.defineProperty,m=d((o,n)=>F(o,"name",{value:n,configurable:!0}),"m");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createProdWebpackConfig=createProdWebpackConfig;const tslib_1=require("tslib"),app_plugin_1=require("@nx/webpack/app-plugin"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),glob_1=require("glob"),webpack_node_externals_1=tslib_1.__importDefault(require("webpack-node-externals")),build_scope_patterns_1=require("./build-scope-patterns");function createProdWebpackConfig(o){const{appRoot:n,outputDir:P,main:_,tsConfig:g,workspaceRoot:r,assets:k=[],additionalEntryPoints:x=[],runtimeDependencies:C=[],memoryLimit:b=8192,generatePackageJson:j=!0,buildLibsFromSource:f=!1,ormConfigPath:c,migrationsDir:W="./src/migrations",orgScopes:w=[],bundlePackages:S=[],nodeExternalsConfig:a,webpackConfigPath:h}=o,{allowlistPatterns:v,scopePrefixes:D,scopePatterns:q}=(0,build_scope_patterns_1.buildScopePatterns)(w),y=S.map(e=>new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(/|$)`)),E=[...v,...y,...a?.allowlist||[]];let s;if(c!==void 0)s=c?path.join(n,c):null;else{const e=path.join(n,"./src/ormconfig.ts");s=fs.existsSync(e)?e:null}const $=s&&fs.existsSync(s),p=[],u={externals:[(0,webpack_node_externals_1.default)({allowlist:E,additionalModuleDirs:a?.additionalModuleDirs||[],...a?.importType&&{importType:a.importType}}),({request:e},i)=>{if(e&&path.isAbsolute(e)&&e.startsWith(r)&&!e.includes("node_modules")||e&&(e.startsWith(path.join(r,"apps"))||e.startsWith(path.join(r,"libs")))||e&&D.some(t=>e.startsWith(t))||e&&q.some(t=>t.test(e))||e&&y.some(t=>t.test(e)))return i();if(e&&!(e.startsWith("./")||e.startsWith(".."))){const t=e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0];return fs.existsSync(path.join(r,"node_modules",t))?i(null,`commonjs ${e}`):i()}return i()}],output:{path:P,clean:!1},devtool:"inline-source-map",mode:"production",plugins:[new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:_,additionalEntryPoints:x,externalDependencies:[],mergeExternals:!0,memoryLimit:b,tsConfig:g,assets:k,namedChunks:!0,optimization:!0,outputHashing:"none",generatePackageJson:j,runtimeDependencies:C,buildLibsFromSource:f,typeCheckOptions:{async:!1},sourceMap:"inline-source-map",progress:!1})]};if(p.push(u),$&&s){const e=[],i=path.join(n,W,"*.ts");(0,glob_1.globSync)(i).forEach(l=>{const M=path.basename(l,".ts");e.push({entryName:`migrations/${M}`,entryPath:l})});const t="./"+path.relative(n,s),L={...u,output:{...u.output,filename:m(l=>l.runtime==="main"?"ormconfig.js":"[name].js","filename"),library:{type:"commonjs"},clean:!1},devtool:!1,plugins:[new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:t,externalDependencies:[],additionalEntryPoints:e,mergeExternals:!0,tsConfig:g,assets:[],namedChunks:!0,memoryLimit:b,optimization:!1,outputHashing:"none",generatePackageJson:!1,buildLibsFromSource:f,skipTypeChecking:!0,sourceMap:!1,progress:!process.env.CI})]};p.push(L)}if(h){const e=require(path.resolve(n,h)),i=e.default||e;return p.map(t=>i(t))}return p}d(createProdWebpackConfig,"createProdWebpackConfig"),m(createProdWebpackConfig,"createProdWebpackConfig");
1
+ "use strict";var T=Object.defineProperty;var g=(o,t)=>T(o,"name",{value:t,configurable:!0});var A=Object.defineProperty,d=g((o,t)=>A(o,"name",{value:t,configurable:!0}),"d"),F=Object.defineProperty,m=d((o,t)=>F(o,"name",{value:t,configurable:!0}),"m");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createProdWebpackConfig=createProdWebpackConfig;const tslib_1=require("tslib"),app_plugin_1=require("@nx/webpack/app-plugin"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),glob_1=require("glob"),webpack_node_externals_1=tslib_1.__importDefault(require("webpack-node-externals")),build_scope_patterns_1=require("./build-scope-patterns");function createProdWebpackConfig(o){const{appRoot:t,outputDir:k,main:_,tsConfig:b,workspaceRoot:r,assets:x=[],additionalEntryPoints:C=[],runtimeDependencies:j=[],memoryLimit:f=8192,generatePackageJson:W=!0,buildLibsFromSource:h=!1,ormConfigPath:c,migrationsDir:v="./src/migrations",orgScopes:w=[],bundlePackages:S=[],nodeExternalsConfig:a,webpackConfigPath:y}=o,{allowlistPatterns:q,scopePrefixes:D,scopePatterns:E}=(0,build_scope_patterns_1.buildScopePatterns)(w),P=S.map(e=>new RegExp(`^${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(/|$)`)),L=[...q,...P,...a?.allowlist||[]];let s;if(c!==void 0)s=c?path.join(t,c):null;else{const e=path.join(t,"./src/ormconfig.ts");s=fs.existsSync(e)?e:null}const $=s&&fs.existsSync(s),p=[],u={externals:[(0,webpack_node_externals_1.default)({allowlist:L,additionalModuleDirs:a?.additionalModuleDirs||[],...a?.importType&&{importType:a.importType}}),({request:e},i)=>{if(e&&path.isAbsolute(e)&&e.startsWith(r)&&!e.includes("node_modules")||e&&(e.startsWith(path.join(r,"apps"))||e.startsWith(path.join(r,"libs")))||e&&D.some(n=>e.startsWith(n))||e&&E.some(n=>n.test(e))||e&&P.some(n=>n.test(e)))return i();if(e&&!(e.startsWith("./")||e.startsWith(".."))){const n=e.startsWith("@")?e.split("/").slice(0,2).join("/"):e.split("/")[0];return fs.existsSync(path.join(r,"node_modules",n))?i(null,`commonjs ${e}`):i()}return i()}],output:{path:k,clean:!1},devtool:"inline-source-map",mode:"production",plugins:[new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:_,additionalEntryPoints:C,externalDependencies:[],mergeExternals:!0,memoryLimit:f,tsConfig:b,assets:x,namedChunks:!0,optimization:!0,outputHashing:"none",generatePackageJson:W,runtimeDependencies:j,buildLibsFromSource:h,typeCheckOptions:{async:!1},sourceMap:"inline-source-map",progress:!1})]};if(p.push(u),$&&s){const e=[],i=path.join(t,v,"*.ts");(0,glob_1.globSync)(i).forEach(l=>{const O=path.basename(l,".ts");e.push({entryName:`migrations/${O}`,entryPath:l})});const n="./"+path.relative(t,s),M={...u,output:{...u.output,filename:m(l=>l.runtime==="main"?"ormconfig.js":"[name].js","filename"),library:{type:"commonjs"},clean:!1},devtool:!1,plugins:[new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:n,externalDependencies:[],additionalEntryPoints:e,mergeExternals:!0,tsConfig:b,assets:[],namedChunks:!0,memoryLimit:f,optimization:!1,outputHashing:"none",generatePackageJson:!1,buildLibsFromSource:h,skipTypeChecking:!0,sourceMap:!1,progress:!process.env.CI})]};p.push(M)}if(y){const e=require(path.resolve(t,y)),i=e.default||e;return p.map(n=>i(n))}return p}g(createProdWebpackConfig,"createProdWebpackConfig"),d(createProdWebpackConfig,"createProdWebpackConfig"),m(createProdWebpackConfig,"createProdWebpackConfig");
package/dev-devtool.js CHANGED
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty;var E=(e,o)=>D(e,"name",{value:o,configurable:!0});var t=Object.defineProperty,s=E((e,o)=>t(e,"name",{value:o,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEV_SOURCE_MAPS_ENV=exports.DEV_DEVTOOL_ENV=exports.DEFAULT_DEV_DEVTOOL=void 0,exports.resolveDevDevtool=resolveDevDevtool,exports.bundleCarriesSourceMaps=bundleCarriesSourceMaps,exports.sourceMapExecArgv=sourceMapExecArgv,exports.DEFAULT_DEV_DEVTOOL="eval",exports.DEV_DEVTOOL_ENV="LENSMCP_DEV_DEVTOOL",exports.DEV_SOURCE_MAPS_ENV="LENSMCP_DEV_SOURCE_MAPS";const DEVTOOL_PATTERN=/^(?:eval|(?:inline-|hidden-|eval-)?(?:nosources-)?(?:cheap-(?:module-)?)?source-map(?:-debugids)?)$/,NO_DEVTOOL=/^(?:false|off|none|0)$/i;function resolveDevDevtool(e,o=process.env){const r=e===!1?"false":(e??o[exports.DEV_DEVTOOL_ENV]??"").trim();return r?NO_DEVTOOL.test(r)?{devtool:!1}:DEVTOOL_PATTERN.test(r)?{devtool:r}:{devtool:exports.DEFAULT_DEV_DEVTOOL,rejected:r}:{devtool:exports.DEFAULT_DEV_DEVTOOL}}E(resolveDevDevtool,"resolveDevDevtool"),s(resolveDevDevtool,"resolveDevDevtool");function bundleCarriesSourceMaps(e){return typeof e=="string"&&e.includes("source-map")&&!e.startsWith("hidden-")}E(bundleCarriesSourceMaps,"bundleCarriesSourceMaps"),s(bundleCarriesSourceMaps,"bundleCarriesSourceMaps");function sourceMapExecArgv(e=process.env){return e[exports.DEV_SOURCE_MAPS_ENV]==="1"?["--enable-source-maps"]:[]}E(sourceMapExecArgv,"sourceMapExecArgv"),s(sourceMapExecArgv,"sourceMapExecArgv");
1
+ "use strict";var a=Object.defineProperty;var n=(e,r)=>a(e,"name",{value:r,configurable:!0});var D=Object.defineProperty,E=n((e,r)=>D(e,"name",{value:r,configurable:!0}),"E"),t=Object.defineProperty,s=E((e,r)=>t(e,"name",{value:r,configurable:!0}),"s");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEV_SOURCE_MAPS_ENV=exports.DEV_DEVTOOL_ENV=exports.DEFAULT_DEV_DEVTOOL=void 0,exports.resolveDevDevtool=resolveDevDevtool,exports.bundleCarriesSourceMaps=bundleCarriesSourceMaps,exports.sourceMapExecArgv=sourceMapExecArgv,exports.DEFAULT_DEV_DEVTOOL="eval",exports.DEV_DEVTOOL_ENV="LENSMCP_DEV_DEVTOOL",exports.DEV_SOURCE_MAPS_ENV="LENSMCP_DEV_SOURCE_MAPS";const DEVTOOL_PATTERN=/^(?:eval|(?:inline-|hidden-|eval-)?(?:nosources-)?(?:cheap-(?:module-)?)?source-map(?:-debugids)?)$/,NO_DEVTOOL=/^(?:false|off|none|0)$/i;function resolveDevDevtool(e,r=process.env){const o=e===!1?"false":(e??r[exports.DEV_DEVTOOL_ENV]??"").trim();return o?NO_DEVTOOL.test(o)?{devtool:!1}:DEVTOOL_PATTERN.test(o)?{devtool:o}:{devtool:exports.DEFAULT_DEV_DEVTOOL,rejected:o}:{devtool:exports.DEFAULT_DEV_DEVTOOL}}n(resolveDevDevtool,"resolveDevDevtool"),E(resolveDevDevtool,"resolveDevDevtool"),s(resolveDevDevtool,"resolveDevDevtool");function bundleCarriesSourceMaps(e){return typeof e=="string"&&e.includes("source-map")&&!e.startsWith("hidden-")}n(bundleCarriesSourceMaps,"bundleCarriesSourceMaps"),E(bundleCarriesSourceMaps,"bundleCarriesSourceMaps"),s(bundleCarriesSourceMaps,"bundleCarriesSourceMaps");function sourceMapExecArgv(e=process.env){return e[exports.DEV_SOURCE_MAPS_ENV]==="1"?["--enable-source-maps"]:[]}n(sourceMapExecArgv,"sourceMapExecArgv"),E(sourceMapExecArgv,"sourceMapExecArgv"),s(sourceMapExecArgv,"sourceMapExecArgv");
package/devserver-host.js CHANGED
@@ -1 +1 @@
1
- "use strict";var n=Object.defineProperty;var s=(r,o)=>n(r,"name",{value:o,configurable:!0});var t=Object.defineProperty,e=s((r,o)=>t(r,"name",{value:o,configurable:!0}),"e");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEVSERVER_IN_PROCESS_ENV=void 0,exports.exitCodeForSignal=exitCodeForSignal,exports.markServeRunner=markServeRunner,exports.devserverInProcessOffered=devserverInProcessOffered,exports.markDevserverInProcess=markDevserverInProcess,exports.devserverOwnsExit=devserverOwnsExit,exports.devserverStopExitCode=devserverStopExitCode,exports.resetDevserverHostForTests=resetDevserverHostForTests;const tslib_1=require("tslib"),os=tslib_1.__importStar(require("node:os"));exports.DEVSERVER_IN_PROCESS_ENV="LENSMCP_DEVSERVER_IN_PROCESS";const RUNNER_KEY="__lensmcpServeRunner",IN_PROCESS_KEY="__lensmcpDevserverInProcess",flags=globalThis;function exitCodeForSignal(r){return 128+(os.constants.signals[r]??0)}s(exitCodeForSignal,"exitCodeForSignal"),e(exitCodeForSignal,"exitCodeForSignal");function markServeRunner(){flags[RUNNER_KEY]=!0}s(markServeRunner,"markServeRunner"),e(markServeRunner,"markServeRunner");function devserverInProcessOffered(r=process.env){return flags[RUNNER_KEY]===!0&&r[exports.DEVSERVER_IN_PROCESS_ENV]?.trim()!=="0"}s(devserverInProcessOffered,"devserverInProcessOffered"),e(devserverInProcessOffered,"devserverInProcessOffered");function markDevserverInProcess(){flags[IN_PROCESS_KEY]=!0}s(markDevserverInProcess,"markDevserverInProcess"),e(markDevserverInProcess,"markDevserverInProcess");function devserverOwnsExit(){return flags[IN_PROCESS_KEY]===!0}s(devserverOwnsExit,"devserverOwnsExit"),e(devserverOwnsExit,"devserverOwnsExit");function devserverStopExitCode(r){if(!devserverOwnsExit())return 0;const o=os.constants.signals[r];return o===void 0?0:128+o}s(devserverStopExitCode,"devserverStopExitCode"),e(devserverStopExitCode,"devserverStopExitCode");function resetDevserverHostForTests(){delete flags[RUNNER_KEY],delete flags[IN_PROCESS_KEY]}s(resetDevserverHostForTests,"resetDevserverHostForTests"),e(resetDevserverHostForTests,"resetDevserverHostForTests");
1
+ "use strict";var i=Object.defineProperty;var o=(r,v)=>i(r,"name",{value:v,configurable:!0});var n=Object.defineProperty,s=o((r,v)=>n(r,"name",{value:v,configurable:!0}),"s"),t=Object.defineProperty,e=s((r,v)=>t(r,"name",{value:v,configurable:!0}),"e");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEVSERVER_IN_PROCESS_ENV=void 0,exports.exitCodeForSignal=exitCodeForSignal,exports.markServeRunner=markServeRunner,exports.devserverInProcessOffered=devserverInProcessOffered,exports.markDevserverInProcess=markDevserverInProcess,exports.devserverOwnsExit=devserverOwnsExit,exports.devserverStopExitCode=devserverStopExitCode,exports.resetDevserverHostForTests=resetDevserverHostForTests;const tslib_1=require("tslib"),os=tslib_1.__importStar(require("node:os"));exports.DEVSERVER_IN_PROCESS_ENV="LENSMCP_DEVSERVER_IN_PROCESS";const RUNNER_KEY="__lensmcpServeRunner",IN_PROCESS_KEY="__lensmcpDevserverInProcess",flags=globalThis;function exitCodeForSignal(r){return 128+(os.constants.signals[r]??0)}o(exitCodeForSignal,"exitCodeForSignal"),s(exitCodeForSignal,"exitCodeForSignal"),e(exitCodeForSignal,"exitCodeForSignal");function markServeRunner(){flags[RUNNER_KEY]=!0}o(markServeRunner,"markServeRunner"),s(markServeRunner,"markServeRunner"),e(markServeRunner,"markServeRunner");function devserverInProcessOffered(r=process.env){return flags[RUNNER_KEY]===!0&&r[exports.DEVSERVER_IN_PROCESS_ENV]?.trim()!=="0"}o(devserverInProcessOffered,"devserverInProcessOffered"),s(devserverInProcessOffered,"devserverInProcessOffered"),e(devserverInProcessOffered,"devserverInProcessOffered");function markDevserverInProcess(){flags[IN_PROCESS_KEY]=!0}o(markDevserverInProcess,"markDevserverInProcess"),s(markDevserverInProcess,"markDevserverInProcess"),e(markDevserverInProcess,"markDevserverInProcess");function devserverOwnsExit(){return flags[IN_PROCESS_KEY]===!0}o(devserverOwnsExit,"devserverOwnsExit"),s(devserverOwnsExit,"devserverOwnsExit"),e(devserverOwnsExit,"devserverOwnsExit");function devserverStopExitCode(r){if(!devserverOwnsExit())return 0;const v=os.constants.signals[r];return v===void 0?0:128+v}o(devserverStopExitCode,"devserverStopExitCode"),s(devserverStopExitCode,"devserverStopExitCode"),e(devserverStopExitCode,"devserverStopExitCode");function resetDevserverHostForTests(){delete flags[RUNNER_KEY],delete flags[IN_PROCESS_KEY]}o(resetDevserverHostForTests,"resetDevserverHostForTests"),s(resetDevserverHostForTests,"resetDevserverHostForTests"),e(resetDevserverHostForTests,"resetDevserverHostForTests");
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var g=(a,t)=>v(a,"name",{value:t,configurable:!0});var m=Object.defineProperty,h=g((a,t)=>m(a,"name",{value:t,configurable:!0}),"h");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DevserverNotifier=void 0,exports.devserverControlSock=devserverControlSock;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),notice_generation_1=require("./notice-generation");class DevserverNotifier{static{g(this,"DevserverNotifier")}static{h(this,"DevserverNotifier")}static{this.RECENT_PATH_CAP=32}static{this.BUILD_PATH_CAP=50}constructor(t,e=!1,i,o=Number(process.env.LENSMCP_GATEWAY_PID??0)>0,c=(0,notice_generation_1.generationFromEnv)(),l={}){this.testimony={schemaVersion:1,lastWatchRunAt:0,lastBuildAt:0,buildsSinceSpawn:0,degraded:!1,recentPaths:[]},this.owedUntil=0,this.managed=o,this.owedPollMs=l.pollMs??OWED_POLL_MS,this.owedForMs=l.forMs??OWED_FOR_MS,this.secure=e,this.base=`${e?"https":"http"}://localhost:${t}`,this.controlSock=i,this.generation=c}post(t,e){const i=JSON.stringify(e),o={"content-type":"application/json",...this.generation!==void 0?{[notice_generation_1.NOTICE_GENERATION_HEADER]:String(this.generation)}:{}},c=h((s,n,r)=>{if(s.statusCode!==409||this.generation===void 0){s.resume(),s.on("end",n);return}let d="";s.setEncoding("utf8"),s.on("data",u=>{d+=u}),s.on("end",()=>{let u;try{u=JSON.parse(d).generation}catch{}r(new notice_generation_1.NotThisGeneration(this.generation,u))})},"answered"),l=h(()=>new Promise((s,n)=>{const r=(this.secure?require("node:https"):require("node:http")).request(`${this.base}${t}`,{method:"POST",headers:o,rejectUnauthorized:!1},d=>c(d,s,n));r.on("error",n),r.end(i)}),"viaTcp"),w=this.controlSock;return!w||!fs.existsSync(w)?this.managed?Promise.reject(new Error("the devserver control socket is not up yet")):l():new Promise((s,n)=>{const r=require("node:http").request({socketPath:w,path:t,method:"POST",headers:o},d=>c(d,s,n));r.on("error",n),r.end(i)}).catch(s=>{if(this.managed||s instanceof notice_generation_1.NotThisGeneration)throw s;return l()})}tell(t,e){return this.post(t,e).then(()=>{this.paid()},i=>{throw this.managed&&this.owe(),i})}owe(){process.env.LENSMCP_FREEZE==="1"||!this.controlSock||(this.owedUntil=Date.now()+this.owedForMs,!this.owedTimer&&(this.owedTimer=setTimeout(()=>this.payOwed(),this.owedPollMs),this.owedTimer.unref?.()))}paid(){this.owedUntil=0,this.owedTimer&&clearTimeout(this.owedTimer),this.owedTimer=void 0}payOwed(){if(this.owedTimer=void 0,!this.owedUntil)return;const t=h(()=>{if(Date.now()>=this.owedUntil){this.owedUntil=0;return}this.owedTimer=setTimeout(()=>this.payOwed(),this.owedPollMs),this.owedTimer.unref?.()},"again");if(!this.controlSock||!fs.existsSync(this.controlSock)){t();return}this.post("/webpack/watching",this.snapshot()).then(()=>{this.owedUntil&&(this.paid(),console.log("[DevServerReloadPlugin] the devserver is up \u2014 sent it the watcher testimony it missed while it was starting"))},t)}snapshot(){return{...this.testimony,recentPaths:[...this.testimony.recentPaths]}}watchRun(t){if(this.testimony.lastWatchRunAt=Date.now(),t.length){const e=[...this.testimony.recentPaths,...t];this.testimony.recentPaths=e.slice(-DevserverNotifier.RECENT_PATH_CAP)}this.building??={startedAt:this.testimony.lastWatchRunAt,changed:new Set,more:0};for(const e of t)this.building.changed.has(e)||(this.building.changed.size>=DevserverNotifier.BUILD_PATH_CAP?this.building.more+=1:this.building.changed.add(e));this.testimony.building=this.buildAccount(),this.tellWatching()}buildAccount(){if(this.building)return{startedAt:this.building.startedAt,changedFiles:[...this.building.changed],...this.building.more>0?{moreChanged:this.building.more}:{}}}failed(t){const e=Date.now(),i=this.buildAccount()??(t!==void 0?{startedAt:e,changedFiles:[]}:void 0);this.building=void 0,delete this.testimony.building,this.testimony.lastFailedAt=e;const o=i?{...i,endedAt:e,...t?{error:t.slice(0,FAILURE_TEXT_CAP)}:{}}:void 0;this.tell("/webpack/watching",{...this.testimony,...o?{failed:o}:{}}).catch(()=>{})}degrade(t){this.testimony.degraded=t,this.tellWatching()}tellWatching(){this.tell("/webpack/watching",this.testimony).catch(()=>{})}async built(t=!0){this.testimony.lastBuildAt=Date.now(),this.testimony.buildsSinceSpawn+=1;const e=this.buildAccount();if(this.building=void 0,delete this.testimony.building,!t){const i=e?{...e,endedAt:this.testimony.lastBuildAt}:void 0;this.tell("/webpack/watching",{...this.testimony,...i?{unchanged:i}:{}}).catch(()=>{});return}try{await this.tell("/webpack/reload",{watcher:this.testimony,...e?{build:{...e,endedAt:this.testimony.lastBuildAt}}:{}}),console.log("[DevServerReloadPlugin] notified devserver to reload")}catch(i){i instanceof notice_generation_1.NotThisGeneration?console.log(`[DevServerReloadPlugin] not this generation's devserver (${i.message}) \u2014 not reloaded; this generation's devserver loads the build when it starts`):console.log("[DevServerReloadPlugin] devserver not running yet")}}}exports.DevserverNotifier=DevserverNotifier;const FAILURE_TEXT_CAP=500,OWED_POLL_MS=500,OWED_FOR_MS=3*6e4;function devserverControlSock(a,t=process.env){const e=t.LENSMCP_SOCK_NS||t.LENSMCP_WS_KEY||"",i=e?path.join(os.tmpdir(),e,`${a}-devserver`):path.join(os.tmpdir(),`${a}-devserver`);return path.join(i,"parent.sock")}g(devserverControlSock,"devserverControlSock"),h(devserverControlSock,"devserverControlSock");
1
+ "use strict";var b=Object.defineProperty;var w=(o,e)=>b(o,"name",{value:e,configurable:!0});var v=Object.defineProperty,g=w((o,e)=>v(o,"name",{value:e,configurable:!0}),"g"),m=Object.defineProperty,h=g((o,e)=>m(o,"name",{value:e,configurable:!0}),"h");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DevserverNotifier=void 0,exports.devserverControlSock=devserverControlSock;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),notice_generation_1=require("./notice-generation");class DevserverNotifier{static{w(this,"DevserverNotifier")}static{g(this,"DevserverNotifier")}static{h(this,"DevserverNotifier")}static{this.RECENT_PATH_CAP=32}static{this.BUILD_PATH_CAP=50}constructor(e,t=!1,i,n=Number(process.env.LENSMCP_GATEWAY_PID??0)>0,l=(0,notice_generation_1.generationFromEnv)(),c={}){this.testimony={schemaVersion:1,lastWatchRunAt:0,lastBuildAt:0,buildsSinceSpawn:0,degraded:!1,recentPaths:[]},this.owedUntil=0,this.managed=n,this.owedPollMs=c.pollMs??OWED_POLL_MS,this.owedForMs=c.forMs??OWED_FOR_MS,this.secure=t,this.base=`${t?"https":"http"}://localhost:${e}`,this.controlSock=i,this.generation=l}post(e,t){const i=JSON.stringify(t),n={"content-type":"application/json",...this.generation!==void 0?{[notice_generation_1.NOTICE_GENERATION_HEADER]:String(this.generation)}:{}},l=h((s,r,a)=>{if(s.statusCode!==409||this.generation===void 0){s.resume(),s.on("end",r);return}let d="";s.setEncoding("utf8"),s.on("data",u=>{d+=u}),s.on("end",()=>{let u;try{u=JSON.parse(d).generation}catch{}a(new notice_generation_1.NotThisGeneration(this.generation,u))})},"answered"),c=h(()=>new Promise((s,r)=>{const a=(this.secure?require("node:https"):require("node:http")).request(`${this.base}${e}`,{method:"POST",headers:n,rejectUnauthorized:!1},d=>l(d,s,r));a.on("error",r),a.end(i)}),"viaTcp"),p=this.controlSock;return!p||!fs.existsSync(p)?this.managed?Promise.reject(new Error("the devserver control socket is not up yet")):c():new Promise((s,r)=>{const a=require("node:http").request({socketPath:p,path:e,method:"POST",headers:n},d=>l(d,s,r));a.on("error",r),a.end(i)}).catch(s=>{if(this.managed||s instanceof notice_generation_1.NotThisGeneration)throw s;return c()})}tell(e,t){return this.post(e,t).then(()=>{this.paid()},i=>{throw this.managed&&this.owe(),i})}owe(){process.env.LENSMCP_FREEZE==="1"||!this.controlSock||(this.owedUntil=Date.now()+this.owedForMs,!this.owedTimer&&(this.owedTimer=setTimeout(()=>this.payOwed(),this.owedPollMs),this.owedTimer.unref?.()))}paid(){this.owedUntil=0,this.owedTimer&&clearTimeout(this.owedTimer),this.owedTimer=void 0}payOwed(){if(this.owedTimer=void 0,!this.owedUntil)return;const e=h(()=>{if(Date.now()>=this.owedUntil){this.owedUntil=0;return}this.owedTimer=setTimeout(()=>this.payOwed(),this.owedPollMs),this.owedTimer.unref?.()},"again");if(!this.controlSock||!fs.existsSync(this.controlSock)){e();return}this.post("/webpack/watching",this.snapshot()).then(()=>{this.owedUntil&&(this.paid(),console.log("[DevServerReloadPlugin] the devserver is up \u2014 sent it the watcher testimony it missed while it was starting"))},e)}snapshot(){return{...this.testimony,recentPaths:[...this.testimony.recentPaths]}}watchRun(e){if(this.testimony.lastWatchRunAt=Date.now(),e.length){const t=[...this.testimony.recentPaths,...e];this.testimony.recentPaths=t.slice(-DevserverNotifier.RECENT_PATH_CAP)}this.building??={startedAt:this.testimony.lastWatchRunAt,changed:new Set,more:0};for(const t of e)this.building.changed.has(t)||(this.building.changed.size>=DevserverNotifier.BUILD_PATH_CAP?this.building.more+=1:this.building.changed.add(t));this.testimony.building=this.buildAccount(),this.tellWatching()}buildAccount(){if(this.building)return{startedAt:this.building.startedAt,changedFiles:[...this.building.changed],...this.building.more>0?{moreChanged:this.building.more}:{}}}failed(e){const t=Date.now(),i=this.buildAccount()??(e!==void 0?{startedAt:t,changedFiles:[]}:void 0);this.building=void 0,delete this.testimony.building,this.testimony.lastFailedAt=t;const n=i?{...i,endedAt:t,...e?{error:e.slice(0,FAILURE_TEXT_CAP)}:{}}:void 0;this.tell("/webpack/watching",{...this.testimony,...n?{failed:n}:{}}).catch(()=>{})}degrade(e){this.testimony.degraded=e,this.tellWatching()}tellWatching(){this.tell("/webpack/watching",this.testimony).catch(()=>{})}async built(e=!0){this.testimony.lastBuildAt=Date.now(),this.testimony.buildsSinceSpawn+=1;const t=this.buildAccount();if(this.building=void 0,delete this.testimony.building,!e){const i=t?{...t,endedAt:this.testimony.lastBuildAt}:void 0;this.tell("/webpack/watching",{...this.testimony,...i?{unchanged:i}:{}}).catch(()=>{});return}try{await this.tell("/webpack/reload",{watcher:this.testimony,...t?{build:{...t,endedAt:this.testimony.lastBuildAt}}:{}}),console.log("[DevServerReloadPlugin] notified devserver to reload")}catch(i){i instanceof notice_generation_1.NotThisGeneration?console.log(`[DevServerReloadPlugin] not this generation's devserver (${i.message}) \u2014 not reloaded; this generation's devserver loads the build when it starts`):console.log("[DevServerReloadPlugin] devserver not running yet")}}}exports.DevserverNotifier=DevserverNotifier;const FAILURE_TEXT_CAP=500,OWED_POLL_MS=500,OWED_FOR_MS=3*6e4;function devserverControlSock(o,e=process.env){const t=e.LENSMCP_SOCK_NS||e.LENSMCP_WS_KEY||"",i=t?path.join(os.tmpdir(),t,`${o}-devserver`):path.join(os.tmpdir(),`${o}-devserver`);return path.join(i,"parent.sock")}w(devserverControlSock,"devserverControlSock"),g(devserverControlSock,"devserverControlSock"),h(devserverControlSock,"devserverControlSock");
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var a=(e,r)=>o(e,"name",{value:r,configurable:!0});var n=Object.defineProperty,t=a((e,r)=>n(e,"name",{value:r,configurable:!0}),"t");Object.defineProperty(exports,"__esModule",{value:!0}),exports.isOwnerOnlyTransport=isOwnerOnlyTransport,exports.gatewayManaged=gatewayManaged,exports.mayDriveThePool=mayDriveThePool;function isOwnerOnlyTransport(e){try{return typeof e.socket?.server?.address?.()=="string"}catch{return!1}}a(isOwnerOnlyTransport,"isOwnerOnlyTransport"),t(isOwnerOnlyTransport,"isOwnerOnlyTransport");function gatewayManaged(e=process.env){return Number(e.LENSMCP_GATEWAY_PID??0)>0}a(gatewayManaged,"gatewayManaged"),t(gatewayManaged,"gatewayManaged");function mayDriveThePool(e,r=gatewayManaged()){return!r||isOwnerOnlyTransport(e)}a(mayDriveThePool,"mayDriveThePool"),t(mayDriveThePool,"mayDriveThePool");
1
+ "use strict";var i=Object.defineProperty;var s=(e,r)=>i(e,"name",{value:r,configurable:!0});var o=Object.defineProperty,a=s((e,r)=>o(e,"name",{value:r,configurable:!0}),"a"),n=Object.defineProperty,t=a((e,r)=>n(e,"name",{value:r,configurable:!0}),"t");Object.defineProperty(exports,"__esModule",{value:!0}),exports.isOwnerOnlyTransport=isOwnerOnlyTransport,exports.gatewayManaged=gatewayManaged,exports.mayDriveThePool=mayDriveThePool;function isOwnerOnlyTransport(e){try{return typeof e.socket?.server?.address?.()=="string"}catch{return!1}}s(isOwnerOnlyTransport,"isOwnerOnlyTransport"),a(isOwnerOnlyTransport,"isOwnerOnlyTransport"),t(isOwnerOnlyTransport,"isOwnerOnlyTransport");function gatewayManaged(e=process.env){return Number(e.LENSMCP_GATEWAY_PID??0)>0}s(gatewayManaged,"gatewayManaged"),a(gatewayManaged,"gatewayManaged"),t(gatewayManaged,"gatewayManaged");function mayDriveThePool(e,r=gatewayManaged()){return!r||isOwnerOnlyTransport(e)}s(mayDriveThePool,"mayDriveThePool"),a(mayDriveThePool,"mayDriveThePool"),t(mayDriveThePool,"mayDriveThePool");
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var l=(t,r)=>A(t,"name",{value:r,configurable:!0});var k=Object.defineProperty,y=l((t,r)=>k(t,"name",{value:r,configurable:!0}),"y");Object.defineProperty(exports,"__esModule",{value:!0}),exports.errorFrameReleaseEnabled=errorFrameReleaseEnabled,exports.readStacksReachableFrom=readStacksReachableFrom,exports.createErrorFrameReleaser=createErrorFrameReleaser;const node_util_1=require("node:util");function errorFrameReleaseEnabled(t=process.env){const r=(t.LENSMCP_SWAP_RELEASE_ERROR_FRAMES??"").trim().toLowerCase();return!(r==="0"||r==="false"||r==="no"||r==="off")}l(errorFrameReleaseEnabled,"errorFrameReleaseEnabled"),y(errorFrameReleaseEnabled,"errorFrameReleaseEnabled");const BUILTINS=new Set([Object.prototype,Function.prototype,Array.prototype,Error.prototype,TypeError.prototype,RangeError.prototype,SyntaxError.prototype,ReferenceError.prototype,EvalError.prototype,URIError.prototype,AggregateError.prototype,Promise.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,RegExp.prototype,Date.prototype,Symbol.prototype,String.prototype,Number.prototype,Boolean.prototype,BigInt.prototype,Object,Function,Array,Error,Promise,Map,Set,Symbol,globalThis,process]),MAX_KEYS_PER_OBJECT=512,MAX_ARRAY_ITEMS=64,walkable=y(t=>typeof t=="object"&&t!==null||typeof t=="function","walkable");function readStacksReachableFrom(t,r={},p=new WeakSet){const f=r.maxDepth??5,u=r.maxPerRoot??4e3,E=r.maxNodes??4e5;let a=0,o=0;for(const n of t){if(a>=E)break;if(!walkable(n))continue;let S=0;const c=[[n,0]];for(let b=0;b<c.length&&S<u&&a<E;b++){const[e,R]=c[b];if(!(p.has(e)||BUILTINS.has(e))){p.add(e),a+=1,S+=1;try{if(node_util_1.types.isNativeError(e)){e.stack,o+=1;continue}if(node_util_1.types.isProxy(e)||node_util_1.types.isModuleNamespaceObject(e)||node_util_1.types.isPromise(e)||ArrayBuffer.isView(e)||node_util_1.types.isAnyArrayBuffer(e)||node_util_1.types.isMap(e)||node_util_1.types.isSet(e)||node_util_1.types.isWeakMap(e)||node_util_1.types.isWeakSet(e)||R>=f)continue;const m=Object.getPrototypeOf(e);if(walkable(m)&&c.push([m,R+1]),Array.isArray(e)){const i=Math.min(e.length,MAX_ARRAY_ITEMS);for(let s=0;s<i;s++){const d=e[s];walkable(d)&&c.push([d,R+1])}continue}const h=Reflect.ownKeys(e),g=Math.min(h.length,MAX_KEYS_PER_OBJECT);for(let i=0;i<g;i++){const s=Reflect.getOwnPropertyDescriptor(e,h[i]);s&&"value"in s&&walkable(s.value)&&c.push([s.value,R+1])}}catch{}}}}return{visited:a,errors:o}}l(readStacksReachableFrom,"readStacksReachableFrom"),y(readStacksReachableFrom,"readStacksReachableFrom");function createErrorFrameReleaser(t,r={}){const p=r.global??globalThis,f=new Set,u=new Set(Reflect.ownKeys(p)),E=new WeakSet;return()=>{const a=[];for(const o of Object.keys(t))if(!f.has(o)&&(f.add(o),!r.skip?.(o)))try{a.push(t[o]?.exports)}catch{}for(const o of Reflect.ownKeys(p)){if(u.has(o))continue;u.add(o);const n=Reflect.getOwnPropertyDescriptor(p,o);n&&"value"in n&&a.push(n.value)}return readStacksReachableFrom(a,r,E)}}l(createErrorFrameReleaser,"createErrorFrameReleaser"),y(createErrorFrameReleaser,"createErrorFrameReleaser");
1
+ "use strict";var F=Object.defineProperty;var f=(t,r)=>F(t,"name",{value:r,configurable:!0});var A=Object.defineProperty,l=f((t,r)=>A(t,"name",{value:r,configurable:!0}),"l"),k=Object.defineProperty,y=l((t,r)=>k(t,"name",{value:r,configurable:!0}),"y");Object.defineProperty(exports,"__esModule",{value:!0}),exports.errorFrameReleaseEnabled=errorFrameReleaseEnabled,exports.readStacksReachableFrom=readStacksReachableFrom,exports.createErrorFrameReleaser=createErrorFrameReleaser;const node_util_1=require("node:util");function errorFrameReleaseEnabled(t=process.env){const r=(t.LENSMCP_SWAP_RELEASE_ERROR_FRAMES??"").trim().toLowerCase();return!(r==="0"||r==="false"||r==="no"||r==="off")}f(errorFrameReleaseEnabled,"errorFrameReleaseEnabled"),l(errorFrameReleaseEnabled,"errorFrameReleaseEnabled"),y(errorFrameReleaseEnabled,"errorFrameReleaseEnabled");const BUILTINS=new Set([Object.prototype,Function.prototype,Array.prototype,Error.prototype,TypeError.prototype,RangeError.prototype,SyntaxError.prototype,ReferenceError.prototype,EvalError.prototype,URIError.prototype,AggregateError.prototype,Promise.prototype,Map.prototype,Set.prototype,WeakMap.prototype,WeakSet.prototype,RegExp.prototype,Date.prototype,Symbol.prototype,String.prototype,Number.prototype,Boolean.prototype,BigInt.prototype,Object,Function,Array,Error,Promise,Map,Set,Symbol,globalThis,process]),MAX_KEYS_PER_OBJECT=512,MAX_ARRAY_ITEMS=64,walkable=y(t=>typeof t=="object"&&t!==null||typeof t=="function","walkable");function readStacksReachableFrom(t,r={},p=new WeakSet){const u=r.maxDepth??5,E=r.maxPerRoot??4e3,R=r.maxNodes??4e5;let a=0,o=0;for(const n of t){if(a>=R)break;if(!walkable(n))continue;let S=0;const c=[[n,0]];for(let m=0;m<c.length&&S<E&&a<R;m++){const[e,b]=c[m];if(!(p.has(e)||BUILTINS.has(e))){p.add(e),a+=1,S+=1;try{if(node_util_1.types.isNativeError(e)){e.stack,o+=1;continue}if(node_util_1.types.isProxy(e)||node_util_1.types.isModuleNamespaceObject(e)||node_util_1.types.isPromise(e)||ArrayBuffer.isView(e)||node_util_1.types.isAnyArrayBuffer(e)||node_util_1.types.isMap(e)||node_util_1.types.isSet(e)||node_util_1.types.isWeakMap(e)||node_util_1.types.isWeakSet(e)||b>=u)continue;const d=Object.getPrototypeOf(e);if(walkable(d)&&c.push([d,b+1]),Array.isArray(e)){const i=Math.min(e.length,MAX_ARRAY_ITEMS);for(let s=0;s<i;s++){const g=e[s];walkable(g)&&c.push([g,b+1])}continue}const h=Reflect.ownKeys(e),v=Math.min(h.length,MAX_KEYS_PER_OBJECT);for(let i=0;i<v;i++){const s=Reflect.getOwnPropertyDescriptor(e,h[i]);s&&"value"in s&&walkable(s.value)&&c.push([s.value,b+1])}}catch{}}}}return{visited:a,errors:o}}f(readStacksReachableFrom,"readStacksReachableFrom"),l(readStacksReachableFrom,"readStacksReachableFrom"),y(readStacksReachableFrom,"readStacksReachableFrom");function createErrorFrameReleaser(t,r={}){const p=r.global??globalThis,u=new Set,E=new Set(Reflect.ownKeys(p)),R=new WeakSet;return()=>{const a=[];for(const o of Object.keys(t))if(!u.has(o)&&(u.add(o),!r.skip?.(o)))try{a.push(t[o]?.exports)}catch{}for(const o of Reflect.ownKeys(p)){if(E.has(o))continue;E.add(o);const n=Reflect.getOwnPropertyDescriptor(p,o);n&&"value"in n&&a.push(n.value)}return readStacksReachableFrom(a,r,R)}}f(createErrorFrameReleaser,"createErrorFrameReleaser"),l(createErrorFrameReleaser,"createErrorFrameReleaser"),y(createErrorFrameReleaser,"createErrorFrameReleaser");
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var d=(e,o)=>x(e,"name",{value:o,configurable:!0});var _=Object.defineProperty,p=d((e,o)=>_(e,"name",{value:o,configurable:!0}),"p");Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),create_webpack_prod_1=require("../../create-webpack-prod"),webpack=require("webpack");async function*buildExecutor(e,o){process.env.NODE_ENV="production";const m=o.projectsConfigurations.projects[o.projectName],n=o.root,a=path.join(n,m.root),c=e.outputPath?path.join(n,e.outputPath):path.join(n,"dist",m.root),y=e.entryFile||"./src/deployments/service/main.ts",P=e.tsConfigFile||"./tsconfig.app.json",k=path.resolve(a,y),h=path.resolve(a,P),u=(0,create_webpack_prod_1.createProdWebpackConfig)({appName:o.projectName,appRoot:a,outputDir:c,main:k,tsConfig:h,assets:e.assets||[],additionalEntryPoints:[...(e.workers||[]).map(r=>({entryName:r.name,entryPath:r.entryPath})),...e.additionalEntryPoints||[]],runtimeDependencies:e.runtimeDependencies||[],memoryLimit:e.memoryLimit||8192,generatePackageJson:e.generatePackageJson!==!1,buildLibsFromSource:e.buildLibsFromSource||!1,ormConfigPath:e.ormConfigPath,migrationsDir:e.migrationsDir||"./src/migrations",workspaceRoot:n,orgScopes:e.orgScopes||[],bundlePackages:e.bundlePackages||[],nodeExternalsConfig:e.nodeExternalsConfig,webpackConfigPath:e.webpackConfigPath}),j=Array.isArray(u)?u:[u];for(const r of j){const{watch:l,...t}=r,s=webpack(t),i=await new Promise((w,C)=>{s.run((b,S)=>{if(b)return C(b);s.close(g=>{g&&console.error("[build] webpack close error:",g)}),w(S)})});if(console.info(i.toString(r.stats||{colors:!0,chunks:!1})),i.hasErrors()){yield{success:!1};return}}const f=e.workers||[];if(f.length>0){const{minify:r}=require("terser");for(const l of f){const t=path.join(c,`${l.name}.js`);if(fs.existsSync(t)){const s=fs.readFileSync(t,"utf-8"),i=await r(s,{keep_classnames:!0,sourceMap:{content:"inline",url:"inline"}});i.code&&(fs.writeFileSync(t,i.code),console.info(`[build] minified ${l.name}.js`))}}}yield{success:!0,outfile:path.join(c,"main.js")}}d(buildExecutor,"buildExecutor"),p(buildExecutor,"buildExecutor"),exports.default=buildExecutor,module.exports=buildExecutor,module.exports.default=buildExecutor;
1
+ "use strict";var S=Object.defineProperty;var m=(e,o)=>S(e,"name",{value:o,configurable:!0});var x=Object.defineProperty,d=m((e,o)=>x(e,"name",{value:o,configurable:!0}),"d"),_=Object.defineProperty,p=d((e,o)=>_(e,"name",{value:o,configurable:!0}),"p");Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),create_webpack_prod_1=require("../../create-webpack-prod"),webpack=require("webpack");async function*buildExecutor(e,o){process.env.NODE_ENV="production";const f=o.projectsConfigurations.projects[o.projectName],n=o.root,a=path.join(n,f.root),c=e.outputPath?path.join(n,e.outputPath):path.join(n,"dist",f.root),P=e.entryFile||"./src/deployments/service/main.ts",k=e.tsConfigFile||"./tsconfig.app.json",j=path.resolve(a,P),h=path.resolve(a,k),u=(0,create_webpack_prod_1.createProdWebpackConfig)({appName:o.projectName,appRoot:a,outputDir:c,main:j,tsConfig:h,assets:e.assets||[],additionalEntryPoints:[...(e.workers||[]).map(r=>({entryName:r.name,entryPath:r.entryPath})),...e.additionalEntryPoints||[]],runtimeDependencies:e.runtimeDependencies||[],memoryLimit:e.memoryLimit||8192,generatePackageJson:e.generatePackageJson!==!1,buildLibsFromSource:e.buildLibsFromSource||!1,ormConfigPath:e.ormConfigPath,migrationsDir:e.migrationsDir||"./src/migrations",workspaceRoot:n,orgScopes:e.orgScopes||[],bundlePackages:e.bundlePackages||[],nodeExternalsConfig:e.nodeExternalsConfig,webpackConfigPath:e.webpackConfigPath}),w=Array.isArray(u)?u:[u];for(const r of w){const{watch:l,...t}=r,s=webpack(t),i=await new Promise((v,C)=>{s.run((g,E)=>{if(g)return C(g);s.close(y=>{y&&console.error("[build] webpack close error:",y)}),v(E)})});if(console.info(i.toString(r.stats||{colors:!0,chunks:!1})),i.hasErrors()){yield{success:!1};return}}const b=e.workers||[];if(b.length>0){const{minify:r}=require("terser");for(const l of b){const t=path.join(c,`${l.name}.js`);if(fs.existsSync(t)){const s=fs.readFileSync(t,"utf-8"),i=await r(s,{keep_classnames:!0,sourceMap:{content:"inline",url:"inline"}});i.code&&(fs.writeFileSync(t,i.code),console.info(`[build] minified ${l.name}.js`))}}}yield{success:!0,outfile:path.join(c,"main.js")}}m(buildExecutor,"buildExecutor"),d(buildExecutor,"buildExecutor"),p(buildExecutor,"buildExecutor"),exports.default=buildExecutor,module.exports=buildExecutor,module.exports.default=buildExecutor;
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var d=(s,o)=>l(s,"name",{value:o,configurable:!0});var u=Object.defineProperty,r=d((s,o)=>u(s,"name",{value:o,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.requestCarriesBody=requestCarriesBody,exports.requestBodyArriving=requestBodyArriving,exports.createBodyStallGuard=createBodyStallGuard;const OFF={arm:r(()=>{},"arm"),armResponse:r(()=>{},"armResponse"),stop:r(()=>{},"stop")};function requestCarriesBody(s){const o=s.headers["content-length"];return String(s.headers["transfer-encoding"]??"").toLowerCase().includes("chunked")||typeof o=="string"&&Number(o)>0}d(requestCarriesBody,"requestCarriesBody"),r(requestCarriesBody,"requestCarriesBody");function requestBodyArriving(s){return requestCarriesBody(s)&&!s.complete&&!s.destroyed}d(requestBodyArriving,"requestBodyArriving"),r(requestBodyArriving,"requestBodyArriving");function createBodyStallGuard(s){if(!Number.isFinite(s)||s<=0)return OFF;const o=new Map,c=new Map,y=Math.max(500,Math.min(s,5e3)),a=setInterval(r(()=>{if(o.size===0&&c.size===0)return;const e=Date.now();for(const[t,n]of o){if(t.complete||t.destroyed||!t.socket||t.socket.destroyed){o.delete(t);continue}const i=t.socket.bytesRead;if(i!==n.bytes){n.bytes=i,n.since=e;continue}e-n.since>=s&&(o.delete(t),t.socket.destroy())}for(const[t,n]of c){const i=t.socket;if(t.writableEnded||t.destroyed||!i||i.destroyed){c.delete(t);continue}if(i.writableLength===0){n.bytes=i.bytesWritten,n.since=e;continue}if(i.bytesWritten!==n.bytes){n.bytes=i.bytesWritten,n.since=e;continue}e-n.since>=s&&(c.delete(t),i.destroy())}},"tick"),y);return a.unref?.(),{arm(e){if(!requestCarriesBody(e)||e.complete||!e.socket)return;o.set(e,{bytes:e.socket.bytesRead,since:Date.now()});const t=r(()=>{o.delete(e)},"done");e.on("end",t),e.on("close",t),e.on("aborted",t)},armResponse(e){const t=e.socket;if(!t||e.writableEnded||e.destroyed)return;c.set(e,{bytes:t.bytesWritten,since:Date.now()});const n=r(()=>{c.delete(e)},"done");e.on("finish",n),e.on("close",n)},stop(){clearInterval(a),o.clear(),c.clear()}}}d(createBodyStallGuard,"createBodyStallGuard"),r(createBodyStallGuard,"createBodyStallGuard");
1
+ "use strict";var b=Object.defineProperty;var a=(n,o)=>b(n,"name",{value:o,configurable:!0});var l=Object.defineProperty,d=a((n,o)=>l(n,"name",{value:o,configurable:!0}),"d"),u=Object.defineProperty,r=d((n,o)=>u(n,"name",{value:o,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.requestCarriesBody=requestCarriesBody,exports.requestBodyArriving=requestBodyArriving,exports.createBodyStallGuard=createBodyStallGuard;const OFF={arm:r(()=>{},"arm"),armResponse:r(()=>{},"armResponse"),stop:r(()=>{},"stop")};function requestCarriesBody(n){const o=n.headers["content-length"];return String(n.headers["transfer-encoding"]??"").toLowerCase().includes("chunked")||typeof o=="string"&&Number(o)>0}a(requestCarriesBody,"requestCarriesBody"),d(requestCarriesBody,"requestCarriesBody"),r(requestCarriesBody,"requestCarriesBody");function requestBodyArriving(n){return requestCarriesBody(n)&&!n.complete&&!n.destroyed}a(requestBodyArriving,"requestBodyArriving"),d(requestBodyArriving,"requestBodyArriving"),r(requestBodyArriving,"requestBodyArriving");function createBodyStallGuard(n){if(!Number.isFinite(n)||n<=0)return OFF;const o=new Map,c=new Map,f=Math.max(500,Math.min(n,5e3)),y=setInterval(r(()=>{if(o.size===0&&c.size===0)return;const e=Date.now();for(const[t,s]of o){if(t.complete||t.destroyed||!t.socket||t.socket.destroyed){o.delete(t);continue}const i=t.socket.bytesRead;if(i!==s.bytes){s.bytes=i,s.since=e;continue}e-s.since>=n&&(o.delete(t),t.socket.destroy())}for(const[t,s]of c){const i=t.socket;if(t.writableEnded||t.destroyed||!i||i.destroyed){c.delete(t);continue}if(i.writableLength===0){s.bytes=i.bytesWritten,s.since=e;continue}if(i.bytesWritten!==s.bytes){s.bytes=i.bytesWritten,s.since=e;continue}e-s.since>=n&&(c.delete(t),i.destroy())}},"tick"),f);return y.unref?.(),{arm(e){if(!requestCarriesBody(e)||e.complete||!e.socket)return;o.set(e,{bytes:e.socket.bytesRead,since:Date.now()});const t=r(()=>{o.delete(e)},"done");e.on("end",t),e.on("close",t),e.on("aborted",t)},armResponse(e){const t=e.socket;if(!t||e.writableEnded||e.destroyed)return;c.set(e,{bytes:t.bytesWritten,since:Date.now()});const s=r(()=>{c.delete(e)},"done");e.on("finish",s),e.on("close",s)},stop(){clearInterval(y),o.clear(),c.clear()}}}a(createBodyStallGuard,"createBodyStallGuard"),d(createBodyStallGuard,"createBodyStallGuard"),r(createBodyStallGuard,"createBodyStallGuard");
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var f=(e,t)=>x(e,"name",{value:t,configurable:!0});var u=Object.defineProperty,r=f((e,t)=>u(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.canonicalPath=exports.rememberRawTarget=exports.rawTargetOf=exports.RAW_TARGET=exports.canonicalize=exports.ENCODED_STRUCTURE=void 0,exports.ENCODED_STRUCTURE=/%2e|%2f|%5c|%00|\\/i;const NEEDS_NORMALIZE=/[%;#\\]|\/\/|(?:^|\/)\.{1,2}(?:\/|$)/,canonicalize=r(e=>{if(e.charCodeAt(0)!==47)return;const t=e.indexOf("?"),a=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t);if(a.indexOf("\0")!==-1)return;if(!NEEDS_NORMALIZE.test(a))return{path:a,policy:a,query:s};if(exports.ENCODED_STRUCTURE.test(a))return;const c=a.split("#")[0].split("/").map(n=>n.split(";")[0]),i=[],p=[];for(const n of c){let o;try{o=decodeURIComponent(n)}catch{return}if(o.indexOf("\0")!==-1)return;if(!(o===""||o===".")){if(o==="..")return;i.push(n),p.push(o)}}const l=c[c.length-1],T=i.length>0&&(l===""||l===".")?"/":"";return{path:"/"+i.join("/")+T,policy:"/"+p.join("/")+T,query:s}},"canonicalize");exports.canonicalize=canonicalize,exports.RAW_TARGET=Symbol.for("lensmcp.gateway.rawTarget");const rawTargetOf=r(e=>e[exports.RAW_TARGET],"rawTargetOf");exports.rawTargetOf=rawTargetOf;const rememberRawTarget=r((e,t)=>{e[exports.RAW_TARGET]=t},"rememberRawTarget");exports.rememberRawTarget=rememberRawTarget;const canonicalPath=r(e=>(0,exports.canonicalize)(e)?.policy,"canonicalPath");exports.canonicalPath=canonicalPath;
1
+ "use strict";var E=Object.defineProperty;var R=(e,t)=>E(e,"name",{value:t,configurable:!0});var x=Object.defineProperty,f=R((e,t)=>x(e,"name",{value:t,configurable:!0}),"f"),u=Object.defineProperty,r=f((e,t)=>u(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.canonicalPath=exports.rememberRawTarget=exports.rawTargetOf=exports.RAW_TARGET=exports.canonicalize=exports.ENCODED_STRUCTURE=void 0,exports.ENCODED_STRUCTURE=/%2e|%2f|%5c|%00|\\/i;const NEEDS_NORMALIZE=/[%;#\\]|\/\/|(?:^|\/)\.{1,2}(?:\/|$)/,canonicalize=r(e=>{if(e.charCodeAt(0)!==47)return;const t=e.indexOf("?"),a=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t);if(a.indexOf("\0")!==-1)return;if(!NEEDS_NORMALIZE.test(a))return{path:a,policy:a,query:s};if(exports.ENCODED_STRUCTURE.test(a))return;const c=a.split("#")[0].split("/").map(n=>n.split(";")[0]),i=[],p=[];for(const n of c){let o;try{o=decodeURIComponent(n)}catch{return}if(o.indexOf("\0")!==-1)return;if(!(o===""||o===".")){if(o==="..")return;i.push(n),p.push(o)}}const l=c[c.length-1],T=i.length>0&&(l===""||l===".")?"/":"";return{path:"/"+i.join("/")+T,policy:"/"+p.join("/")+T,query:s}},"canonicalize");exports.canonicalize=canonicalize,exports.RAW_TARGET=Symbol.for("lensmcp.gateway.rawTarget");const rawTargetOf=r(e=>e[exports.RAW_TARGET],"rawTargetOf");exports.rawTargetOf=rawTargetOf;const rememberRawTarget=r((e,t)=>{e[exports.RAW_TARGET]=t},"rememberRawTarget");exports.rememberRawTarget=rememberRawTarget;const canonicalPath=r(e=>(0,exports.canonicalize)(e)?.policy,"canonicalPath");exports.canonicalPath=canonicalPath;
@@ -28,10 +28,24 @@ export interface ClientIpResolver {
28
28
  forwardedFor(req: http.IncomingMessage, peer: string): string;
29
29
  /** Is this peer address a trusted front proxy? */
30
30
  peerTrusted(peer?: string): boolean;
31
+ /**
32
+ * Is a forwarding header from this peer evidence (PG3-05)? True behind a counted trusted hop chain, or when the
33
+ * peer itself is trusted (`clientIpTrustedProxies`, default loopback). Used for request headers a rule may read.
34
+ */
35
+ peerAsserts(peer?: string): boolean;
36
+ /**
37
+ * The `X-Forwarded-Proto` to send upstream (PG3-04). A trusted front proxy terminated the user's TLS, so ITS
38
+ * statement of the scheme is kept (`X-Forwarded-Proto`, else Cloudflare's `CF-Visitor` when the client address
39
+ * comes from `cf-connecting-ip`); anyone else gets the gateway's own listener scheme. Trust is the forwarding
40
+ * chain's: the same condition {@link forwardedFor} appends to a chain under.
41
+ */
42
+ forwardedProto(req: http.IncomingMessage, peer: string, ownScheme: 'http' | 'https'): 'http' | 'https';
31
43
  readonly trustProxyHops: number;
32
44
  }
33
45
  /** An IPv4-mapped IPv6 peer (`::ffff:127.0.0.1`, what a dual-stack listener reports) → its IPv4 form. */
34
46
  export declare const normalizePeer: (addr: string) => string;
47
+ /** Is `addr` in `list` — IPv4 CIDRs (`10.0.0.0/8`) or exact addresses (`::1`, `10.1.2.3`)? Mapped IPv6 folds first. */
48
+ export declare const addressIn: (addr: string, list: readonly string[]) => boolean;
35
49
  /** `1.2.3.4:51234` (an X-Forwarded-For port suffix) → `1.2.3.4`. IPv6 keeps its colons unless bracketed. */
36
50
  export declare const stripPort: (v: string) => string;
37
51
  export declare function createClientIpResolver(opts?: ClientIpOptions): ClientIpResolver;
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var f=(e,r)=>u(e,"name",{value:r,configurable:!0});var a=Object.defineProperty,o=f((e,r)=>a(e,"name",{value:r,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.stripPort=exports.normalizePeer=void 0,exports.createClientIpResolver=createClientIpResolver,exports.clientIpOptionsFromEnv=clientIpOptionsFromEnv;const manifest_1=require("./manifest"),first=o(e=>{const r=Array.isArray(e)?e[0]:e;return typeof r=="string"&&r.length>0?r:void 0},"first"),normalizePeer=o(e=>e.startsWith("::ffff:")&&e.indexOf(":",7)===-1?e.slice(7):e,"normalizePeer");exports.normalizePeer=normalizePeer;const stripPort=o(e=>{if(e.startsWith("[")){const p=e.indexOf("]");return p===-1?e:e.slice(1,p)}const r=e.indexOf(":");return r!==-1&&e.indexOf(":",r+1)===-1?e.slice(0,r):e},"stripPort");exports.stripPort=stripPort;function createClientIpResolver(e={}){const r=e.clientIpHeader?.toLowerCase(),p=e.clientIpTrustedProxies??[],l=Math.max(0,Math.floor(e.trustProxyHops??0)),c=o(t=>{if(!t)return!1;const s=t.startsWith("::ffff:")?t.slice(7):t;return p.length===0?s==="127.0.0.1"||t==="::1":p.some(i=>(0,manifest_1.matchCidr)(s,i))},"peerTrusted"),d=o(t=>String(t.headers["x-forwarded-for"]??"").split(",").map(s=>s.trim()).filter(Boolean),"forwardedChain");return{clientIpOf:o((t,s)=>{if(r&&c(t.socket?.remoteAddress??void 0)){const i=first(t.headers[r]);if(i){const n=(0,exports.stripPort)(i.split(",")[0].trim());if(n)return n}}if(l>0){const i=d(t),n=i.length-l;if(n>=0&&i[n])return(0,exports.stripPort)(i[n])}return(0,exports.normalizePeer)(s)},"clientIpOf"),forwardedFor:o((t,s)=>{const i=(0,exports.normalizePeer)(s);if(l>0||r&&c(s)){const n=d(t);return n.length?`${n.join(", ")}, ${i}`:i}return i},"forwardedFor"),peerTrusted:c,trustProxyHops:l}}f(createClientIpResolver,"createClientIpResolver"),o(createClientIpResolver,"createClientIpResolver");function clientIpOptionsFromEnv(e=process.env){const r=Number(e.LENSMCP_TRUST_PROXY),p=String(e.LENSMCP_CLIENT_IP_TRUSTED_PROXIES??"").split(",").map(l=>l.trim()).filter(Boolean);return{...Number.isFinite(r)&&r>0?{trustProxyHops:Math.floor(r)}:{},...e.LENSMCP_CLIENT_IP_HEADER?{clientIpHeader:e.LENSMCP_CLIENT_IP_HEADER}:{},...p.length?{clientIpTrustedProxies:p}:{}}}f(clientIpOptionsFromEnv,"clientIpOptionsFromEnv"),o(clientIpOptionsFromEnv,"clientIpOptionsFromEnv");
1
+ "use strict";var v=Object.defineProperty;var l=(e,r)=>v(e,"name",{value:r,configurable:!0});var h=Object.defineProperty,f=l((e,r)=>h(e,"name",{value:r,configurable:!0}),"f"),P=Object.defineProperty,o=f((e,r)=>P(e,"name",{value:r,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.stripPort=exports.addressIn=exports.normalizePeer=void 0,exports.createClientIpResolver=createClientIpResolver,exports.clientIpOptionsFromEnv=clientIpOptionsFromEnv;const manifest_1=require("./manifest"),first=o(e=>{const r=Array.isArray(e)?e[0]:e;return typeof r=="string"&&r.length>0?r:void 0},"first"),normalizePeer=o(e=>e.startsWith("::ffff:")&&e.indexOf(":",7)===-1?e.slice(7):e,"normalizePeer");exports.normalizePeer=normalizePeer;const addressIn=o((e,r)=>{const i=(0,exports.normalizePeer)(e);return r.some(p=>p.includes("/")?(0,manifest_1.matchCidr)(i,p):(0,exports.normalizePeer)(p)===i)},"addressIn");exports.addressIn=addressIn;const stripPort=o(e=>{if(e.startsWith("[")){const i=e.indexOf("]");return i===-1?e:e.slice(1,i)}const r=e.indexOf(":");return r!==-1&&e.indexOf(":",r+1)===-1?e.slice(0,r):e},"stripPort");exports.stripPort=stripPort;function createClientIpResolver(e={}){const r=e.clientIpHeader?.toLowerCase(),i=e.clientIpTrustedProxies??[],p=Math.max(0,Math.floor(e.trustProxyHops??0)),c=o(t=>{if(!t)return!1;const a=t.startsWith("::ffff:")?t.slice(7):t;return i.length===0?a==="127.0.0.1"||t==="::1":i.some(s=>(0,manifest_1.matchCidr)(a,s))},"peerTrusted"),u=o(t=>String(t.headers["x-forwarded-for"]??"").split(",").map(a=>a.trim()).filter(Boolean),"forwardedChain"),I=o((t,a)=>{if(r&&c(t.socket?.remoteAddress??void 0)){const s=first(t.headers[r]);if(s){const n=(0,exports.stripPort)(s.split(",")[0].trim());if(n)return n}}if(p>0){const s=u(t),n=s.length-p;if(n>=0&&s[n])return(0,exports.stripPort)(s[n])}return(0,exports.normalizePeer)(a)},"clientIpOf"),m=o(t=>p>0||!!r&&c(t),"chainTrusted");return{clientIpOf:I,forwardedFor:o((t,a)=>{const s=(0,exports.normalizePeer)(a);if(m(a)){const n=u(t);return n.length?`${n.join(", ")}, ${s}`:s}return s},"forwardedFor"),peerTrusted:c,peerAsserts:o(t=>p>0||c(t),"peerAsserts"),forwardedProto:o((t,a,s)=>{if(!m(a))return s;const n=first(t.headers["x-forwarded-proto"])?.split(",")[0].trim().toLowerCase();if(n==="https"||n==="http")return n;if(r==="cf-connecting-ip"){const x=first(t.headers["cf-visitor"]);if(x)try{const d=JSON.parse(x).scheme;if(d==="https"||d==="http")return d}catch{}}return s},"forwardedProto"),trustProxyHops:p}}l(createClientIpResolver,"createClientIpResolver"),f(createClientIpResolver,"createClientIpResolver"),o(createClientIpResolver,"createClientIpResolver");function clientIpOptionsFromEnv(e=process.env){const r=Number(e.LENSMCP_TRUST_PROXY),i=String(e.LENSMCP_CLIENT_IP_TRUSTED_PROXIES??"").split(",").map(p=>p.trim()).filter(Boolean);return{...Number.isFinite(r)&&r>0?{trustProxyHops:Math.floor(r)}:{},...e.LENSMCP_CLIENT_IP_HEADER?{clientIpHeader:e.LENSMCP_CLIENT_IP_HEADER}:{},...i.length?{clientIpTrustedProxies:i}:{}}}l(clientIpOptionsFromEnv,"clientIpOptionsFromEnv"),f(clientIpOptionsFromEnv,"clientIpOptionsFromEnv"),o(clientIpOptionsFromEnv,"clientIpOptionsFromEnv");
@@ -27,6 +27,14 @@ export declare const GATEWAY_ERROR_KEY: Record<GatewayErrorReason, string>;
27
27
  * `traceId`, and the gateway returns it on the response — one id, end-to-end, for ANY request.
28
28
  */
29
29
  export declare function ensureRequestId(req: http.IncomingMessage): string;
30
+ /**
31
+ * The grammar a CLIENT's `x-request-id` must match to be adopted as the edge trace id: a short token. Anything else
32
+ * — 4 KB of markup, non-ASCII bytes, a CR the parser let through as obs-text — is replaced by a minted id (PG3-26):
33
+ * the id is forwarded to every upstream, echoed to the client and indexed by every log and trace store downstream,
34
+ * so adopting it verbatim was log/trace injection and a free 16 KB header per request.
35
+ */
36
+ export declare const REQUEST_ID_GRAMMAR: RegExp;
37
+ export declare const validRequestId: (v: string) => boolean;
30
38
  /**
31
39
  * Build the JSON edge-error body `{ key, status, traceId, message? }`. `detail` becomes the dev-facing
32
40
  * `message` (e.g. the old plain-text reason), never surfaced to end users.
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var n=(e,t)=>d(e,"name",{value:t,configurable:!0});var s=Object.defineProperty,r=n((e,t)=>s(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.GATEWAY_ERROR_CONTENT_TYPE=exports.GATEWAY_ERROR_KEY=void 0,exports.ensureRequestId=ensureRequestId,exports.gatewayErrorBody=gatewayErrorBody,exports.GATEWAY_ERROR_KEY={bad_request:"gateway.badRequest",unauthorized:"gateway.unauthorized",forbidden:"gateway.forbidden",not_found:"gateway.notFound",rate_limited:"gateway.rateLimited",starting:"gateway.starting",unavailable:"gateway.unavailable",internal:"gateway.internal"};const headerValue=r(e=>typeof e=="string"&&e!==""?e:Array.isArray(e)?e[0]:void 0,"headerValue"),mintId=r(()=>Date.now().toString(36)+Math.random().toString(36).slice(2,12),"mintId");function ensureRequestId(e){const t=headerValue(e.headers["x-request-id"]);if(t)return t;const a=mintId();return e.headers["x-request-id"]=a,a}n(ensureRequestId,"ensureRequestId"),r(ensureRequestId,"ensureRequestId");function gatewayErrorBody(e,t,a,o,i){return JSON.stringify({...i??{},key:exports.GATEWAY_ERROR_KEY[t],status:e,traceId:a,...o?{message:o}:{}})}n(gatewayErrorBody,"gatewayErrorBody"),r(gatewayErrorBody,"gatewayErrorBody"),exports.GATEWAY_ERROR_CONTENT_TYPE="application/json; charset=utf-8";
1
+ "use strict";var R=Object.defineProperty;var n=(e,t)=>R(e,"name",{value:t,configurable:!0});var i=Object.defineProperty,s=n((e,t)=>i(e,"name",{value:t,configurable:!0}),"s"),o=Object.defineProperty,r=s((e,t)=>o(e,"name",{value:t,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.GATEWAY_ERROR_CONTENT_TYPE=exports.validRequestId=exports.REQUEST_ID_GRAMMAR=exports.GATEWAY_ERROR_KEY=void 0,exports.ensureRequestId=ensureRequestId,exports.gatewayErrorBody=gatewayErrorBody,exports.GATEWAY_ERROR_KEY={bad_request:"gateway.badRequest",unauthorized:"gateway.unauthorized",forbidden:"gateway.forbidden",not_found:"gateway.notFound",rate_limited:"gateway.rateLimited",starting:"gateway.starting",unavailable:"gateway.unavailable",internal:"gateway.internal"};const headerValue=r(e=>typeof e=="string"&&e!==""?e:Array.isArray(e)?e[0]:void 0,"headerValue"),mintId=r(()=>Date.now().toString(36)+Math.random().toString(36).slice(2,12),"mintId");function ensureRequestId(e){const t=headerValue(e.headers["x-request-id"]);if(t&&(0,exports.validRequestId)(t))return t;const a=mintId();return e.headers["x-request-id"]=a,a}n(ensureRequestId,"ensureRequestId"),s(ensureRequestId,"ensureRequestId"),r(ensureRequestId,"ensureRequestId"),exports.REQUEST_ID_GRAMMAR=/^[A-Za-z0-9._-]{1,128}$/;const validRequestId=r(e=>exports.REQUEST_ID_GRAMMAR.test(e),"validRequestId");exports.validRequestId=validRequestId;function gatewayErrorBody(e,t,a,d,u){return JSON.stringify({...u??{},key:exports.GATEWAY_ERROR_KEY[t],status:e,traceId:a,...d?{message:d}:{}})}n(gatewayErrorBody,"gatewayErrorBody"),s(gatewayErrorBody,"gatewayErrorBody"),r(gatewayErrorBody,"gatewayErrorBody"),exports.GATEWAY_ERROR_CONTENT_TYPE="application/json; charset=utf-8";
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var i=(r,t)=>g(r,"name",{value:t,configurable:!0});var u=Object.defineProperty,c=i((r,t)=>u(r,"name",{value:t,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=gatewayExecutor;const kept_settings_1=require("./runtime/kept-settings"),gateway_lib_1=require("./gateway.lib"),own_log_1=require("./runtime/own-log"),project_graph_store_1=require("./runtime/project-graph-store"),server_1=require("./runtime/server");async function gatewayExecutor(r,t){const p=(0,own_log_1.takeOverGatewayLog)();p&&console.log(`[gateway] ${new Date().toISOString()} writing ${p.file} itself (pid ${process.pid}) \u2014 a line a full disk refuses is counted, and the next line that lands says how many were lost`),kept_settings_1.KEPT_AT_START.length&&console.log(`[gateway] settings kept for this checkout and this machine: ${kept_settings_1.KEPT_AT_START.map(e=>`${e}=${process.env[e]}`).join(" ")} (Settings; a variable set in the environment wins)`),process.on("uncaughtException",e=>{if((e.syscall==="read"||e.syscall==="write")&&server_1.BENIGN_SOCKET_ERRNOS.has(e.code??"")){console.warn(`[gateway] survived a stray socket ${e.syscall} error (${e.code}) \u2014 one connection dropped, the daemon lives`);return}console.error(e),process.exit(1)});let l;try{const e=(0,project_graph_store_1.createProjectGraphStore)(t.root,()=>(0,project_graph_store_1.computeProjectGraphInProcess)(t.root)),o=(await e.refresh())?.projectGraph,s=o?Object.fromEntries(Object.entries(o.dependencies).map(([n,a])=>[n,a.map(d=>d.target)])):void 0;l=await(0,gateway_lib_1.startGateway)(r,{...t,...s?{projectDependencies:s}:{},projectGraphStore:e})}catch(e){return console.error(e.message),{success:!1}}return new Promise(e=>{let o=!1;const s=c(n=>{if(o)return;o=!0;let a=!0;try{process.kill(process.ppid,0)}catch{a=!1}console.log(`[gateway] received ${n} (pid ${process.pid}, parent ${process.ppid} ${a?"alive":"gone \u2014 orphaned"}) \u2014 shutting down`),l.stop().then(()=>e({success:!0}))},"stop");process.on("SIGINT",()=>s("SIGINT")),process.on("SIGTERM",()=>s("SIGTERM"))})}i(gatewayExecutor,"gatewayExecutor"),c(gatewayExecutor,"gatewayExecutor"),module.exports=gatewayExecutor,module.exports.default=gatewayExecutor,module.exports.startGateway=gateway_lib_1.startGateway;
1
+ "use strict";var y=Object.defineProperty;var p=(r,t)=>y(r,"name",{value:t,configurable:!0});var g=Object.defineProperty,i=p((r,t)=>g(r,"name",{value:t,configurable:!0}),"i"),u=Object.defineProperty,c=i((r,t)=>u(r,"name",{value:t,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=gatewayExecutor;const kept_settings_1=require("./runtime/kept-settings"),gateway_lib_1=require("./gateway.lib"),own_log_1=require("./runtime/own-log"),project_graph_store_1=require("./runtime/project-graph-store"),server_1=require("./runtime/server");async function gatewayExecutor(r,t){const l=(0,own_log_1.takeOverGatewayLog)();l&&console.log(`[gateway] ${new Date().toISOString()} writing ${l.file} itself (pid ${process.pid}) \u2014 a line a full disk refuses is counted, and the next line that lands says how many were lost`),kept_settings_1.KEPT_AT_START.length&&console.log(`[gateway] settings kept for this checkout and this machine: ${kept_settings_1.KEPT_AT_START.map(e=>`${e}=${process.env[e]}`).join(" ")} (Settings; a variable set in the environment wins)`),process.on("uncaughtException",e=>{if((e.syscall==="read"||e.syscall==="write")&&server_1.BENIGN_SOCKET_ERRNOS.has(e.code??"")){console.warn(`[gateway] survived a stray socket ${e.syscall} error (${e.code}) \u2014 one connection dropped, the daemon lives`);return}console.error(e),process.exit(1)});let d;try{const e=(0,project_graph_store_1.createProjectGraphStore)(t.root,()=>(0,project_graph_store_1.computeProjectGraphInProcess)(t.root)),o=(await e.refresh())?.projectGraph,s=o?Object.fromEntries(Object.entries(o.dependencies).map(([n,a])=>[n,a.map(w=>w.target)])):void 0;d=await(0,gateway_lib_1.startGateway)(r,{...t,...s?{projectDependencies:s}:{},projectGraphStore:e})}catch(e){return console.error(e.message),{success:!1}}return new Promise(e=>{let o=!1;const s=c(n=>{if(o)return;o=!0;let a=!0;try{process.kill(process.ppid,0)}catch{a=!1}console.log(`[gateway] received ${n} (pid ${process.pid}, parent ${process.ppid} ${a?"alive":"gone \u2014 orphaned"}) \u2014 shutting down`),d.stop().then(()=>e({success:!0}))},"stop");process.on("SIGINT",()=>s("SIGINT")),process.on("SIGTERM",()=>s("SIGTERM"))})}p(gatewayExecutor,"gatewayExecutor"),i(gatewayExecutor,"gatewayExecutor"),c(gatewayExecutor,"gatewayExecutor"),module.exports=gatewayExecutor,module.exports.default=gatewayExecutor,module.exports.startGateway=gateway_lib_1.startGateway;
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var n=(t,r)=>s(t,"name",{value:r,configurable:!0});var o=Object.defineProperty,e=n((t,r)=>o(t,"name",{value:r,configurable:!0}),"e");Object.defineProperty(exports,"__esModule",{value:!0}),exports.projectSourceRoots=exports.discoverRoutes=exports.pickSock=exports.readLensScope=exports.deriveMcpHttpPort=exports.baseDomainOf=exports.stampIdentity=exports.verifyDevJwt=exports.startGateway=exports.hostMatches=void 0;var manifest_1=require("./manifest");Object.defineProperty(exports,"hostMatches",{enumerable:!0,get:e(function(){return manifest_1.hostMatches},"get")});var server_1=require("./runtime/server");Object.defineProperty(exports,"startGateway",{enumerable:!0,get:e(function(){return server_1.startGateway},"get")});var dev_auth_1=require("./runtime/dev-auth");Object.defineProperty(exports,"verifyDevJwt",{enumerable:!0,get:e(function(){return dev_auth_1.verifyDevJwt},"get")}),Object.defineProperty(exports,"stampIdentity",{enumerable:!0,get:e(function(){return dev_auth_1.stampIdentity},"get")});var scope_1=require("./runtime/scope");Object.defineProperty(exports,"baseDomainOf",{enumerable:!0,get:e(function(){return scope_1.baseDomainOf},"get")}),Object.defineProperty(exports,"deriveMcpHttpPort",{enumerable:!0,get:e(function(){return scope_1.deriveMcpHttpPort},"get")}),Object.defineProperty(exports,"readLensScope",{enumerable:!0,get:e(function(){return scope_1.readLensScope},"get")});var discovery_1=require("./runtime/discovery");Object.defineProperty(exports,"pickSock",{enumerable:!0,get:e(function(){return discovery_1.pickSock},"get")}),Object.defineProperty(exports,"discoverRoutes",{enumerable:!0,get:e(function(){return discovery_1.discoverRoutes},"get")}),Object.defineProperty(exports,"projectSourceRoots",{enumerable:!0,get:e(function(){return discovery_1.projectSourceRoots},"get")});
1
+ "use strict";var c=Object.defineProperty;var i=(t,r)=>c(t,"name",{value:r,configurable:!0});var s=Object.defineProperty,n=i((t,r)=>s(t,"name",{value:r,configurable:!0}),"n"),o=Object.defineProperty,e=n((t,r)=>o(t,"name",{value:r,configurable:!0}),"e");Object.defineProperty(exports,"__esModule",{value:!0}),exports.projectSourceRoots=exports.discoverRoutes=exports.pickSock=exports.readLensScope=exports.deriveMcpHttpPort=exports.baseDomainOf=exports.stampIdentity=exports.verifyDevJwt=exports.startGateway=exports.hostMatches=void 0;var manifest_1=require("./manifest");Object.defineProperty(exports,"hostMatches",{enumerable:!0,get:e(function(){return manifest_1.hostMatches},"get")});var server_1=require("./runtime/server");Object.defineProperty(exports,"startGateway",{enumerable:!0,get:e(function(){return server_1.startGateway},"get")});var dev_auth_1=require("./runtime/dev-auth");Object.defineProperty(exports,"verifyDevJwt",{enumerable:!0,get:e(function(){return dev_auth_1.verifyDevJwt},"get")}),Object.defineProperty(exports,"stampIdentity",{enumerable:!0,get:e(function(){return dev_auth_1.stampIdentity},"get")});var scope_1=require("./runtime/scope");Object.defineProperty(exports,"baseDomainOf",{enumerable:!0,get:e(function(){return scope_1.baseDomainOf},"get")}),Object.defineProperty(exports,"deriveMcpHttpPort",{enumerable:!0,get:e(function(){return scope_1.deriveMcpHttpPort},"get")}),Object.defineProperty(exports,"readLensScope",{enumerable:!0,get:e(function(){return scope_1.readLensScope},"get")});var discovery_1=require("./runtime/discovery");Object.defineProperty(exports,"pickSock",{enumerable:!0,get:e(function(){return discovery_1.pickSock},"get")}),Object.defineProperty(exports,"discoverRoutes",{enumerable:!0,get:e(function(){return discovery_1.discoverRoutes},"get")}),Object.defineProperty(exports,"projectSourceRoots",{enumerable:!0,get:e(function(){return discovery_1.projectSourceRoots},"get")});
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var c=(a,h)=>g(a,"name",{value:h,configurable:!0});var C=Object.defineProperty,n=c((a,h)=>C(a,"name",{value:h,configurable:!0}),"n");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createHealthChecker=createHealthChecker;function createHealthChecker(a={}){const h=a.path??"/healthz",f=a.intervalMs??5e3,y=a.timeoutMs??2e3,p=Math.max(1,a.unhealthyThreshold??2),u=Math.max(1,a.healthyThreshold??1),d=a.fetchImpl??globalThis.fetch,l=new Map;let r;const k=n(t=>t.replace(/\/+$/,"")+(h.startsWith("/")?h:"/"+h),"probeUrl"),m=n(async t=>{const e=l.get(t);if(!e)return;let s=!1;const i=new AbortController,b=setTimeout(()=>i.abort(),y);try{s=(await d(k(t),{method:"GET",signal:i.signal,redirect:"manual"})).status<500}catch{}finally{clearTimeout(b)}e.lastCheckedAt=Date.now(),s?(e.oks+=1,e.fails=0,!e.healthy&&e.oks>=u&&(e.healthy=!0,a.onChange?.(t,!0))):(e.fails+=1,e.oks=0,e.healthy&&e.fails>=p&&(e.healthy=!1,a.onChange?.(t,!1)))},"probe"),o=n(()=>Promise.allSettled([...l.keys()].map(m)).then(()=>{}),"probeOnce");return{track(t){const e=new Set(t);for(const s of t)l.has(s)||l.set(s,{healthy:!0,fails:0,oks:0,lastCheckedAt:null});for(const s of[...l.keys()])e.has(s)||l.delete(s)},isHealthy:n(t=>l.get(t)?.healthy??!0,"isHealthy"),snapshot:n(()=>[...l.entries()].map(([t,e])=>({url:t,healthy:e.healthy,fails:e.fails,lastCheckedAt:e.lastCheckedAt})),"snapshot"),probeOnce:o,start(){r||(r=setInterval(()=>{o()},f),r.unref?.(),o())},stop(){r&&clearInterval(r),r=void 0}}}c(createHealthChecker,"createHealthChecker"),n(createHealthChecker,"createHealthChecker");
1
+ "use strict";var H=Object.defineProperty;var i=(t,h)=>H(t,"name",{value:h,configurable:!0});var g=Object.defineProperty,c=i((t,h)=>g(t,"name",{value:h,configurable:!0}),"c"),C=Object.defineProperty,l=c((t,h)=>C(t,"name",{value:h,configurable:!0}),"l");Object.defineProperty(exports,"__esModule",{value:!0}),exports.createHealthChecker=createHealthChecker;function createHealthChecker(t={}){const h=t.path??"/healthz",y=t.intervalMs??5e3,p=t.timeoutMs??2e3,u=Math.max(1,t.unhealthyThreshold??2),d=Math.max(1,t.healthyThreshold??1),k=t.fetchImpl??globalThis.fetch,r=new Map;let o;const m=l(a=>a.replace(/\/+$/,"")+(h.startsWith("/")?h:"/"+h),"probeUrl"),b=l(async a=>{const e=r.get(a);if(!e)return;let s=!1;const f=new AbortController,v=setTimeout(()=>f.abort(),p);try{s=(await k(m(a),{method:"GET",signal:f.signal,redirect:"manual",headers:{"accept-encoding":"identity"}})).status<500}catch{}finally{clearTimeout(v)}e.lastCheckedAt=Date.now(),s?(e.oks+=1,e.fails=0,!e.healthy&&e.oks>=d&&(e.healthy=!0,t.onChange?.(a,!0))):(e.fails+=1,e.oks=0,e.healthy&&e.fails>=u&&(e.healthy=!1,t.onChange?.(a,!1)))},"probe"),n=l(()=>Promise.allSettled([...r.keys()].map(b)).then(()=>{}),"probeOnce");return{track(a){const e=new Set(a);for(const s of a)r.has(s)||r.set(s,{healthy:!0,fails:0,oks:0,lastCheckedAt:null});for(const s of[...r.keys()])e.has(s)||r.delete(s)},isHealthy:l(a=>r.get(a)?.healthy??!0,"isHealthy"),snapshot:l(()=>[...r.entries()].map(([a,e])=>({url:a,healthy:e.healthy,fails:e.fails,lastCheckedAt:e.lastCheckedAt})),"snapshot"),probeOnce:n,start(){o||(o=setInterval(()=>{n()},y),o.unref?.(),n())},stop(){o&&clearInterval(o),o=void 0}}}i(createHealthChecker,"createHealthChecker"),c(createHealthChecker,"createHealthChecker"),l(createHealthChecker,"createHealthChecker");
@@ -18,6 +18,8 @@ export interface JwksVerifierOptions {
18
18
  fetchTimeoutMs?: number;
19
19
  /** Clock skew tolerance for exp/nbf (seconds). Default 60. */
20
20
  clockToleranceSec?: number;
21
+ /** Refuse tokens with no numeric `exp` (default true — see `checkStandardClaims`). */
22
+ requireExp?: boolean;
21
23
  /** Injectable fetch (tests). Defaults to global fetch. */
22
24
  fetchImpl?: typeof fetch;
23
25
  }
@@ -1 +1 @@
1
- "use strict";var D=Object.defineProperty;var w=(a,o)=>D(a,"name",{value:o,configurable:!0});var W=Object.defineProperty,i=w((a,o)=>W(a,"name",{value:o,configurable:!0}),"i");Object.defineProperty(exports,"__esModule",{value:!0}),exports.bearerIdentify=bearerIdentify,exports.createJwksVerifier=createJwksVerifier;const node_crypto_1=require("node:crypto"),jwt_claims_js_1=require("./jwt-claims.js");function bearerIdentify(a){return o=>{const d=String(o.headers.authorization??"");return d.startsWith("Bearer ")?a.verifyOrAwait(d.slice(7)):void 0}}w(bearerIdentify,"bearerIdentify"),i(bearerIdentify,"bearerIdentify");const ALG_TO_HASH={RS256:"sha256",RS384:"sha384",RS512:"sha512"},b64urlJsonSafe=i(a=>JSON.parse(Buffer.from(a,"base64url").toString("utf8")),"b64urlJsonSafe");function createJwksVerifier(a){const o=(a.algorithms??["RS256"]).filter(r=>r in ALG_TO_HASH),d=a.cacheMaxAgeMs??6e5,A=a.missRefreshMs??3e4,J=a.missWaitMs??2e3,S=a.fetchTimeoutMs??1e4,O=a.clockToleranceSec??60,P=a.fetchImpl??globalThis.fetch,b=a.audience===void 0?void 0:Array.isArray(a.audience)?a.audience:[a.audience];let c=new Map,u,f,M=0,m=!1;const h=new Map,x=i(async r=>{const e=await P(a.jwksUrl,{headers:{accept:"application/json"},signal:r});if(!e.ok)throw new Error(`JWKS ${a.jwksUrl} \u2192 HTTP ${e.status}`);const t=await e.json(),n=new Map;for(const s of t.keys??[])if(!(s.kty!=="RSA"||!s.n||!s.e)&&!(s.use&&s.use!=="sig"))try{const g=(0,node_crypto_1.createPublicKey)({key:s,format:"jwk"});n.set(s.kid??"__single__",g)}catch{}n.size>0&&(c=n)},"load"),y=i(()=>{if(!u){const r=new AbortController;u=new Promise((e,t)=>{const n=setTimeout(()=>{r.abort(),t(new Error(`JWKS ${a.jwksUrl} \u2192 no answer in ${S} ms`))},S);n.unref?.(),x(r.signal).then(()=>{clearTimeout(n),e()},s=>{clearTimeout(n),t(s)})}).finally(()=>{u=void 0})}return u},"refresh"),v=i(()=>{if(f)return f;if(!(!u&&Date.now()<M))return f=y().catch(()=>{}).finally(()=>{f=void 0,M=Date.now()+A}),f},"refreshOnMiss"),T=setInterval(()=>{y().catch(()=>{})},d);T.unref?.();const p=i(r=>{const e=r.split(".");if(e.length!==3)return;let t;try{t=b64urlJsonSafe(e[0])}catch{return}if(!(!t.alg||!o.includes(t.alg)))return{parts:e,header:t}},"parse"),l=i(r=>r.kid!==void 0?c.get(r.kid):c.get("__single__")??(c.size===1?[...c.values()][0]:void 0),"keyFor"),k=i(({parts:r,header:e},t)=>{let n;try{n=(0,node_crypto_1.verify)(ALG_TO_HASH[e.alg],Buffer.from(`${r[0]}.${r[1]}`),t,Buffer.from(r[2],"base64url"))}catch{return}if(!n)return;let s;try{s=b64urlJsonSafe(r[1])}catch{return}if((0,jwt_claims_js_1.checkStandardClaims)(s,{...a.issuer?{issuer:a.issuer}:{},...b?{audience:b}:{},clockToleranceS:O}))return s},"verifyWith"),I=i(r=>{const e=p(r);if(!e)return;const t=l(e.header);if(!t){v();return}return k(e,t)},"verify"),j=i(async r=>{let e;await Promise.race([r,new Promise(t=>{e=setTimeout(t,J),e.unref?.()})]),clearTimeout(e)},"waitBounded"),R=i(async r=>{const e=p(r);if(!e)return!1;if(l(e.header))return!0;const t=v();return t?(await j(t),l(e.header)!==void 0):!1},"awaitKey"),$=i(r=>{const e=p(r);if(!e)return;const t=l(e.header);if(t)return k(e,t);const n=v();if(n)return j(n).then(()=>{const s=l(e.header);return s?k(e,s):void 0})},"verifyOrAwait"),B=i(r=>new Promise(e=>{const t=setTimeout(()=>{h.delete(t),e()},r);t.unref?.(),h.set(t,e)}),"sleep");return{verify:I,refresh:y,awaitKey:R,verifyOrAwait:$,warm:i(async(r={})=>{const e=Math.max(1,r.attempts??8),t=r.baseDelayMs??1e3,n=r.maxDelayMs??3e4;for(let s=1;!m;s++)try{return await y(),!0}catch(g){if(m)return!1;const _=s<e?Math.min(n,t*2**(s-1)):void 0;try{r.onError?.(g,s,_)}catch{}if(_===void 0)return!1;await B(_)}return!1},"warm"),stop:i(()=>{m=!0,clearInterval(T);for(const[r,e]of h)clearTimeout(r),e();h.clear()},"stop")}}w(createJwksVerifier,"createJwksVerifier"),i(createJwksVerifier,"createJwksVerifier");
1
+ "use strict";var K=Object.defineProperty;var m=(n,o)=>K(n,"name",{value:o,configurable:!0});var D=Object.defineProperty,w=m((n,o)=>D(n,"name",{value:o,configurable:!0}),"w"),W=Object.defineProperty,i=w((n,o)=>W(n,"name",{value:o,configurable:!0}),"i");Object.defineProperty(exports,"__esModule",{value:!0}),exports.bearerIdentify=bearerIdentify,exports.createJwksVerifier=createJwksVerifier;const node_crypto_1=require("node:crypto"),jwt_claims_js_1=require("./jwt-claims.js");function bearerIdentify(n){return o=>{const d=String(o.headers.authorization??"");return d.startsWith("Bearer ")?n.verifyOrAwait(d.slice(7)):void 0}}m(bearerIdentify,"bearerIdentify"),w(bearerIdentify,"bearerIdentify"),i(bearerIdentify,"bearerIdentify");const ALG_TO_HASH={RS256:"sha256",RS384:"sha384",RS512:"sha512"},b64urlJsonSafe=i(n=>JSON.parse(Buffer.from(n,"base64url").toString("utf8")),"b64urlJsonSafe");function createJwksVerifier(n){const o=(n.algorithms??["RS256"]).filter(r=>r in ALG_TO_HASH),d=n.cacheMaxAgeMs??6e5,J=n.missRefreshMs??3e4,O=n.missWaitMs??2e3,S=n.fetchTimeoutMs??1e4,P=n.clockToleranceSec??60,x=n.fetchImpl??globalThis.fetch,M=n.audience===void 0?void 0:Array.isArray(n.audience)?n.audience:[n.audience];let c=new Map,u,f,T=0,p=!1;const h=new Map,I=i(async r=>{const e=await x(n.jwksUrl,{headers:{accept:"application/json","accept-encoding":"identity"},signal:r});if(!e.ok)throw new Error(`JWKS ${n.jwksUrl} \u2192 HTTP ${e.status}`);const t=await e.json(),a=new Map;for(const s of t.keys??[])if(!(s.kty!=="RSA"||!s.n||!s.e)&&!(s.use&&s.use!=="sig"))try{const b=(0,node_crypto_1.createPublicKey)({key:s,format:"jwk"});a.set(s.kid??"__single__",b)}catch{}a.size>0&&(c=a)},"load"),y=i(()=>{if(!u){const r=new AbortController;u=new Promise((e,t)=>{const a=setTimeout(()=>{r.abort(),t(new Error(`JWKS ${n.jwksUrl} \u2192 no answer in ${S} ms`))},S);a.unref?.(),I(r.signal).then(()=>{clearTimeout(a),e()},s=>{clearTimeout(a),t(s)})}).finally(()=>{u=void 0})}return u},"refresh"),v=i(()=>{if(f)return f;if(!(!u&&Date.now()<T))return f=y().catch(()=>{}).finally(()=>{f=void 0,T=Date.now()+J}),f},"refreshOnMiss"),j=setInterval(()=>{y().catch(()=>{})},d);j.unref?.();const k=i(r=>{const e=r.split(".");if(e.length!==3)return;let t;try{t=b64urlJsonSafe(e[0])}catch{return}if(!(!t.alg||!o.includes(t.alg)))return{parts:e,header:t}},"parse"),l=i(r=>r.kid!==void 0?c.get(r.kid):c.get("__single__")??(c.size===1?[...c.values()][0]:void 0),"keyFor"),g=i(({parts:r,header:e},t)=>{let a;try{a=(0,node_crypto_1.verify)(ALG_TO_HASH[e.alg],Buffer.from(`${r[0]}.${r[1]}`),t,Buffer.from(r[2],"base64url"))}catch{return}if(!a)return;let s;try{s=b64urlJsonSafe(r[1])}catch{return}if((0,jwt_claims_js_1.checkStandardClaims)(s,{...n.issuer?{issuer:n.issuer}:{},...M?{audience:M}:{},clockToleranceS:P,...n.requireExp===!1?{requireExp:!1}:{}}))return s},"verifyWith"),R=i(r=>{const e=k(r);if(!e)return;const t=l(e.header);if(!t){v();return}return g(e,t)},"verify"),A=i(async r=>{let e;await Promise.race([r,new Promise(t=>{e=setTimeout(t,O),e.unref?.()})]),clearTimeout(e)},"waitBounded"),$=i(async r=>{const e=k(r);if(!e)return!1;if(l(e.header))return!0;const t=v();return t?(await A(t),l(e.header)!==void 0):!1},"awaitKey"),B=i(r=>{const e=k(r);if(!e)return;const t=l(e.header);if(t)return g(e,t);const a=v();if(a)return A(a).then(()=>{const s=l(e.header);return s?g(e,s):void 0})},"verifyOrAwait"),E=i(r=>new Promise(e=>{const t=setTimeout(()=>{h.delete(t),e()},r);t.unref?.(),h.set(t,e)}),"sleep");return{verify:R,refresh:y,awaitKey:$,verifyOrAwait:B,warm:i(async(r={})=>{const e=Math.max(1,r.attempts??8),t=r.baseDelayMs??1e3,a=r.maxDelayMs??3e4;for(let s=1;!p;s++)try{return await y(),!0}catch(b){if(p)return!1;const _=s<e?Math.min(a,t*2**(s-1)):void 0;try{r.onError?.(b,s,_)}catch{}if(_===void 0)return!1;await E(_)}return!1},"warm"),stop:i(()=>{p=!0,clearInterval(j);for(const[r,e]of h)clearTimeout(r),e();h.clear()},"stop")}}m(createJwksVerifier,"createJwksVerifier"),w(createJwksVerifier,"createJwksVerifier"),i(createJwksVerifier,"createJwksVerifier");
@@ -20,6 +20,9 @@ export interface StandardClaimOptions {
20
20
  audience?: readonly string[];
21
21
  /** Clock skew allowance in seconds. Defaults to {@link DEFAULT_CLOCK_TOLERANCE_S}. */
22
22
  clockToleranceS?: number;
23
+ /** Refuse a token with no numeric `exp`. Default TRUE: a token that never expires is valid forever once leaked
24
+ * (PG3-06). Pass `false` only for an issuer known to mint expiry-less tokens on purpose. */
25
+ requireExp?: boolean;
23
26
  }
24
27
  /**
25
28
  * Are a verified token's registered claims acceptable?
@@ -28,7 +31,8 @@ export interface StandardClaimOptions {
28
31
  * about whether an authentic token is one this gateway should accept.
29
32
  *
30
33
  * A configured restriction fails closed: with an `issuer` configured, a token carrying no `iss` is
31
- * rejected rather than treated as unrestricted. A restriction the operator did not configure is not
32
- * enforced, which is what keeps this backwards-compatible for a deployment that sets neither.
34
+ * rejected rather than treated as unrestricted. `iss`/`aud` the operator did not configure are not enforced here —
35
+ * the production entry refuses to BOOT a verifier without an audience instead (`jwtBootProblems`, PG3-06). A numeric
36
+ * `exp` is required unless `requireExp: false`.
33
37
  */
34
38
  export declare function checkStandardClaims(payload: Record<string, unknown>, opts: StandardClaimOptions): boolean;
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var t=(e,n)=>o(e,"name",{value:n,configurable:!0});var c=Object.defineProperty,u=t((e,n)=>c(e,"name",{value:n,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CLOCK_TOLERANCE_S=void 0,exports.checkStandardClaims=checkStandardClaims,exports.DEFAULT_CLOCK_TOLERANCE_S=60;function checkStandardClaims(e,n){const s=n.clockToleranceS??exports.DEFAULT_CLOCK_TOLERANCE_S,a=Date.now()/1e3;if(typeof e.exp=="number"&&a>e.exp+s||typeof e.nbf=="number"&&a<e.nbf-s||n.issuer&&e.iss!==n.issuer)return!1;if(n.audience&&n.audience.length>0){const r=e.aud;if(!(Array.isArray(r)?r:[r]).some(i=>typeof i=="string"&&n.audience.includes(i)))return!1}return!0}t(checkStandardClaims,"checkStandardClaims"),u(checkStandardClaims,"checkStandardClaims");
1
+ "use strict";var d=Object.defineProperty;var a=(r,e)=>d(r,"name",{value:e,configurable:!0});var c=Object.defineProperty,t=a((r,e)=>c(r,"name",{value:e,configurable:!0}),"t"),f=Object.defineProperty,u=t((r,e)=>f(r,"name",{value:e,configurable:!0}),"u");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_CLOCK_TOLERANCE_S=void 0,exports.checkStandardClaims=checkStandardClaims,exports.DEFAULT_CLOCK_TOLERANCE_S=60;function checkStandardClaims(r,e){const i=e.clockToleranceS??exports.DEFAULT_CLOCK_TOLERANCE_S,s=Date.now()/1e3;if(typeof r.exp!="number"){if(e.requireExp!==!1)return!1}else if(s>r.exp+i)return!1;if(typeof r.nbf=="number"&&s<r.nbf-i||e.issuer&&r.iss!==e.issuer)return!1;if(e.audience&&e.audience.length>0){const n=r.aud;if(!(Array.isArray(n)?n:[n]).some(o=>typeof o=="string"&&e.audience.includes(o)))return!1}return!0}a(checkStandardClaims,"checkStandardClaims"),t(checkStandardClaims,"checkStandardClaims"),u(checkStandardClaims,"checkStandardClaims");