@plitzi/sdk-kernel 0.39.4 → 0.39.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @plitzi/sdk-kernel
2
2
 
3
+ ## 0.39.6
4
+
5
+ ### Patch Changes
6
+
7
+ - @plitzi/sdk-shared@0.39.6
8
+
9
+ ## 0.39.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 4427674: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
14
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
15
+ - Updated dependencies [4427674]
16
+ - @plitzi/sdk-shared@0.39.5
17
+
3
18
  ## 0.39.4
4
19
 
5
20
  ### Patch Changes
@@ -1,5 +1,5 @@
1
+ import { t as isRecord } from "./isRecord-jspv0BWl.mjs";
1
2
  // src/http/fleet/channel.ts
2
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
3
3
  /** The channel is shared with `node:cluster` and anything else the deployment sends: only these are ours. */
4
4
  var isFleetMessage = (value) => {
5
5
  if (!isRecord(value)) return false;
@@ -0,0 +1,4 @@
1
+ // src/data/isRecord.ts
2
+ /** A plain object, read field by field: not null, not an array. */
3
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4
+ export { isRecord as t };
@@ -1,4 +1,4 @@
1
- import { i as createStoreHost, n as createFleetHub, o as isFleetMessage, r as createListeners, t as createFleetClient } from "./channel-DnVf7PJB.mjs";
1
+ import { i as createStoreHost, n as createFleetHub, o as isFleetMessage, r as createListeners, t as createFleetClient } from "./channel-b11VTzOp.mjs";
2
2
  import { c as serverLog } from "./serverLog-BWNOjPMV.mjs";
3
3
  import cluster from "node:cluster";
4
4
  import { availableParallelism } from "node:os";
@@ -1,4 +1,4 @@
1
- import { a as startHub, s as fleetWorkerEnv } from "./link-CFSynFKL.mjs";
1
+ import { a as startHub, s as fleetWorkerEnv } from "./link-BbsYAg_x.mjs";
2
2
  import { c as serverLog } from "./serverLog-BWNOjPMV.mjs";
3
3
  import cluster from "node:cluster";
4
4
  // src/http/fleet/supervisor.ts
@@ -0,0 +1,2 @@
1
+ /** A plain object, read field by field: not null, not an array. */
2
+ export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
@@ -2,9 +2,10 @@ import { a as isLogged, c as serverLog, d as keepLogEvent, l as traceField, s as
2
2
  import { a as bearerMatches, f as SHUTDOWN_ANNOUNCE_MS, h as shutdownOf, m as markStopping, n as statsConfigProblem, p as isStopping } from "../chunks/stage-C62Zvzw_.mjs";
3
3
  import { i as hstsFor, n as applySecurityHeaders, r as frameAncestorsOf, t as spaceDeploymentMiddleware } from "../chunks/spaceDeployment-J2IMLfij.mjs";
4
4
  import { TRACEPARENT, readTraceparent, runInTrace, spanOf, traceparentOf } from "../trace/index.mjs";
5
- import { a as hostable, i as createStoreHost, n as createFleetHub, o as isFleetMessage, r as createListeners, t as createFleetClient } from "../chunks/channel-DnVf7PJB.mjs";
6
- import { a as startHub, c as isFleetWorker, i as onBroadcast, l as resolveWorkers, n as channelName, o as fleetRole, r as fleetStore, s as fleetWorkerEnv, t as broadcast, u as runsFleetJobs } from "../chunks/link-CFSynFKL.mjs";
5
+ import { a as hostable, i as createStoreHost, n as createFleetHub, o as isFleetMessage, r as createListeners, t as createFleetClient } from "../chunks/channel-b11VTzOp.mjs";
6
+ import { a as startHub, c as isFleetWorker, i as onBroadcast, l as resolveWorkers, n as channelName, o as fleetRole, r as fleetStore, s as fleetWorkerEnv, t as broadcast, u as runsFleetJobs } from "../chunks/link-BbsYAg_x.mjs";
7
7
  import { n as CompressedFileCache, t as TtlCache } from "../chunks/TtlCache-J_jG9oL9.mjs";
8
+ import { t as isRecord } from "../chunks/isRecord-jspv0BWl.mjs";
8
9
  import { r as crossSiteRequest, t as carrierOf } from "../chunks/csrf-DMP4dVjc.mjs";
9
10
  import crypto from "node:crypto";
10
11
  import path from "node:path";
@@ -670,17 +671,23 @@ var basicAuthMiddleware = (options = {}) => {
670
671
  const { realm = "Restricted Area", cacheTtlMs = CREDENTIAL_TTL_MS } = options;
671
672
  const authCache = new TtlCache(cacheTtlMs, 1e4);
672
673
  return async (req, res, next) => {
673
- const credential = req.ctx.spaceDeployment?.credential;
674
- if (!credential || credential.provider !== "ssr") {
674
+ const passwords = (req.ctx.spaceDeployment?.credentials ?? []).filter((credential) => credential.provider === "ssr");
675
+ if (passwords.length === 0) {
675
676
  await next();
676
677
  return;
677
678
  }
678
- const { data: credentials } = credential;
679
- if (credentials.type !== "basic") {
680
- await next();
679
+ const hostname = req.hostname;
680
+ const expected = passwords.flatMap(({ data }) => {
681
+ const pair = isRecord(data) ? data : {};
682
+ return typeof pair.user === "string" && pair.user !== "" && typeof pair.pass === "string" && pair.pass !== "" ? [{
683
+ user: pair.user,
684
+ pass: pair.pass
685
+ }] : [];
686
+ });
687
+ if (expected.length === 0) {
688
+ sendChallenge(res, hostname, realm);
681
689
  return;
682
690
  }
683
- const hostname = req.hostname;
684
691
  const authHeader = req.headers["authorization"];
685
692
  if (!authHeader || !authHeader.startsWith("Basic ")) {
686
693
  sendChallenge(res, hostname, realm);
@@ -695,7 +702,11 @@ var basicAuthMiddleware = (options = {}) => {
695
702
  sendChallenge(res, hostname, realm);
696
703
  return;
697
704
  }
698
- const cacheKey = `${hostname}:${crypto.createHash("sha256").update(token).digest("hex")}`;
705
+ const cacheKey = crypto.createHash("sha256").update([
706
+ hostname,
707
+ ...expected.flatMap(({ user, pass }) => [user, pass]),
708
+ token
709
+ ].join("\0")).digest("hex");
699
710
  if (authCache.get(cacheKey)) {
700
711
  await next();
701
712
  return;
@@ -705,15 +716,13 @@ var basicAuthMiddleware = (options = {}) => {
705
716
  sendChallenge(res, hostname, realm);
706
717
  return;
707
718
  }
708
- const user = decoded.slice(0, colonIdx);
709
- const pass = decoded.slice(colonIdx + 1);
710
- const expectedUser = Buffer.from(credentials.user);
711
- const expectedPass = Buffer.from(credentials.pass);
712
- const actualUser = Buffer.from(user);
713
- const actualPass = Buffer.from(pass);
714
- const userMatch = actualUser.length === expectedUser.length && crypto.timingSafeEqual(actualUser, expectedUser);
715
- const passMatch = actualPass.length === expectedPass.length && crypto.timingSafeEqual(actualPass, expectedPass);
716
- if (!userMatch || !passMatch) {
719
+ const actualUser = Buffer.from(decoded.slice(0, colonIdx));
720
+ const actualPass = Buffer.from(decoded.slice(colonIdx + 1));
721
+ const sameAs = (actual, wanted) => {
722
+ const expectedBytes = Buffer.from(wanted);
723
+ return actual.length === expectedBytes.length && crypto.timingSafeEqual(actual, expectedBytes);
724
+ };
725
+ if (!expected.map(({ user, pass }) => sameAs(actualUser, user) && sameAs(actualPass, pass)).includes(true)) {
717
726
  sendChallenge(res, hostname, realm);
718
727
  return;
719
728
  }
@@ -916,7 +925,7 @@ var createHttpServer = (config, makeHandlerForPort, parts) => {
916
925
  if (plan.requested !== void 0 && role !== "worker") serverLog.warn(label, `${plan.requested} workers asked for, ${plan.count} cores to run them on: starting ${plan.count}`);
917
926
  if (role === "primary") return new Promise((resolve) => {
918
927
  (parts.beforeFork?.() ?? Promise.resolve()).catch((error) => serverLog.error(label, "preparing for the workers failed", error)).then(async () => {
919
- const { startFleet } = await import("../chunks/supervisor-D1gAW3nL.mjs");
928
+ const { startFleet } = await import("../chunks/supervisor-BodaVb-s.mjs");
920
929
  if (closed) return;
921
930
  fleet = startFleet(plan.count, label, parts.fleetStores ?? {});
922
931
  serverLog.info(label, `${plan.count} workers on ${host}:${port}`);
@@ -1,4 +1,4 @@
1
- import { i as onBroadcast, n as channelName, t as broadcast } from "../chunks/link-CFSynFKL.mjs";
1
+ import { i as onBroadcast, n as channelName, t as broadcast } from "../chunks/link-BbsYAg_x.mjs";
2
2
  // src/pubsub/memoryPubSub.ts
3
3
  var isRelayed = (value) => typeof value === "object" && value !== null && "topic" in value && typeof value.topic === "string" && "message" in value && typeof value.message === "string";
4
4
  /**
@@ -1,10 +1,10 @@
1
1
  import { _ as STATS_METRICS_PATH, c as METRICS_CONTENT_TYPE, d as processGauges, g as STATS_LOGS_PATH, i as withStopping, l as gaugesText, n as statsConfigProblem, o as createStatsRecorder, r as statsStage, s as statsRecorderFor, t as deploymentGauges, u as metricsText, v as STATS_PATH } from "../chunks/stage-C62Zvzw_.mjs";
2
+ import { t as isRecord } from "../chunks/isRecord-jspv0BWl.mjs";
2
3
  import { availableParallelism } from "node:os";
3
4
  import { readFileSync } from "node:fs";
4
5
  import { monitorEventLoopDelay, performance as performance$1 } from "node:perf_hooks";
5
6
  import { getHeapStatistics } from "node:v8";
6
7
  // src/stats/pools.ts
7
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  var isStats = (value) => isRecord(value) && typeof value.pool === "string" && isRecord(value.health) && isRecord(value.load);
9
9
  /** What a status means, said where nothing more particular is known. */
10
10
  var MEANING = {
@@ -1,4 +1,4 @@
1
- import { i as createStoreHost, n as createFleetHub, r as createListeners, t as createFleetClient } from "../chunks/channel-DnVf7PJB.mjs";
1
+ import { i as createStoreHost, n as createFleetHub, r as createListeners, t as createFleetClient } from "../chunks/channel-b11VTzOp.mjs";
2
2
  import { r as selectRows, t as execute } from "../chunks/query-DGbrN3mN.mjs";
3
3
  import { r as generateTokenKeys } from "../chunks/tokens-BAV5YeT9.mjs";
4
4
  // src/testing/certificates.ts
@@ -1,5 +1,5 @@
1
1
  import { SSRChangePage, SSRChangeQuery, SSRCredential, SSRGrant, SSRRequest, SSRResponseHelpers, SSRSession, SSRTemplateProps, SSRWriteContext } from './pipeline';
2
- import { BadgeLinks, ActionEntry, ActionRunReport, ActionTaskDescriptor, AnalyticsConfig, ConnectorEntry, DataDraft, DataSaveResult, Environment, FunctionsDraft, FunctionsSaveResult, OfflineDataRaw, PluginSource, SSRRscData, SSRUser, Schema, SessionScope, Style } from '@plitzi/sdk-shared';
2
+ import { BadgeLinks, ActionEntry, ActionRunReport, ActionTaskDescriptor, AnalyticsConfig, ConnectorEntry, DataDraft, DataSaveResult, Environment, FunctionsDraft, FunctionsSaveResult, OfflineDataRaw, PluginSource, SSRRscData, SSRUser, Schema, SessionScope, SpaceDomainRelease, SpaceReleaseOutcome, SpaceReleases, Style } from '@plitzi/sdk-shared';
3
3
  import { ActivityReader, SpaceActivityPage, SpaceActivityQuery } from '@plitzi/sdk-shared/activity';
4
4
  import { FlagOverrides } from '@plitzi/sdk-shared/flags';
5
5
  import { TSpaceEntitlements } from '@plitzi/sdk-shared/network';
@@ -28,7 +28,11 @@ export type SSRSpaceDeployment = {
28
28
  /** What this host's pages are held to, for a deployment that lets each domain say: absent, the server's own. */
29
29
  security?: SSRDeploymentSecurity;
30
30
  environment?: Environment;
31
- credential?: SSRCredential;
31
+ /**
32
+ * The Site passwords that open this host, any one of them (the basic-auth stage): a domain's own, or — a version's
33
+ * preview — every one its space's addresses ask. None, or empty, and the host is open.
34
+ */
35
+ credentials?: SSRCredential[];
32
36
  spaceId?: number | null;
33
37
  revision?: number;
34
38
  /**
@@ -48,6 +52,11 @@ export type SSRSpaceDeployment = {
48
52
  * which is why it says so here.
49
53
  */
50
54
  authoring?: boolean;
55
+ /**
56
+ * This address is never for search — a snapshot's preview, made for people to look at before any domain serves it:
57
+ * every page answered on it says `X-Robots-Tag: noindex, nofollow`, whatever the plan or the page's own robots say.
58
+ */
59
+ noindex?: boolean;
51
60
  /**
52
61
  * The origins of the credential that chose this space — set only when one did rather than the host (`renderGrant`):
53
62
  * a page of one of them renders the space itself and is answered its document across origins.
@@ -214,6 +223,28 @@ export type SSRAdapters = {
214
223
  * to `query.wait` seconds when nothing has yet. `reader` is who asks, so their own writes can be left out; `signal`
215
224
  * ends the wait when the client goes. When omitted, the MCP offers no `plitzi_activity`. */
216
225
  getActivity?: (spaceId: number, query: SpaceActivityQuery, reader: ActivityReader, signal?: AbortSignal) => Promise<SpaceActivityPage>;
226
+ /**
227
+ * A space's releases: every domain with what it serves, one domain's history, a publish and a rollback —
228
+ * each held to the deployment's own rules (who may publish, the plan, the revision's tests), a refusal answered as
229
+ * data in its words. When omitted, the MCP offers no `plitzi_releases`, `plitzi_publish` nor `plitzi_rollback`.
230
+ */
231
+ releases?: {
232
+ domains: (spaceId: number) => Promise<SpaceDomainRelease[]>;
233
+ history: (spaceId: number, domain: string) => Promise<SpaceReleases>;
234
+ publish: (spaceId: number, asked: {
235
+ domain: string;
236
+ environment: Environment;
237
+ revision?: number;
238
+ deploy?: boolean;
239
+ }, write: SSRWriteContext) => Promise<SpaceReleaseOutcome>;
240
+ rollback: (spaceId: number, asked: {
241
+ domain: string;
242
+ to?: {
243
+ environment: Environment;
244
+ revision: number;
245
+ };
246
+ }, write: SSRWriteContext) => Promise<SpaceReleaseOutcome>;
247
+ };
217
248
  /**
218
249
  * Who this request carries, if anyone. The adapter reads the credential and resolves it; the cookie it arrived in
219
250
  * was written by the server, from {@link SSRAuthCookie}.
@@ -68,6 +68,11 @@ export type SSRCredential = {
68
68
  export type SSRTemplateProps = {
69
69
  /** The render's script nonce, written on each of the template's own scripts (`SSRServerConfig.scriptPolicy`). */
70
70
  nonce?: string;
71
+ /**
72
+ * What the page's elements asked to run as it is parsed, before it paints, by name (`SSRRenderResult.prePaint`): each
73
+ * a script of the template's own, under its nonce.
74
+ */
75
+ prePaint?: Record<string, string>;
71
76
  /**
72
77
  * The page's script policy, said on `<html data-plitzi-script-policy>`: what every copy of the SDK's shared code a page
73
78
  * loads — the builder's, a plugin's own — reads to hold itself to it (`startMarkupPolicies`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-kernel",
3
- "version": "0.39.4",
3
+ "version": "0.39.6",
4
4
  "license": "AGPL-3.0",
5
5
  "description": "What every Plitzi server process is built on: the HTTP pipeline, health and shutdown, the host → deployment resolution, and verifying who a request is.",
6
6
  "files": [
@@ -37,10 +37,10 @@
37
37
  "build:prod": "vite build"
38
38
  },
39
39
  "dependencies": {
40
- "@plitzi/sdk-shared": "0.39.4",
40
+ "@plitzi/sdk-shared": "0.39.6",
41
41
  "jsonwebtoken": "^9.0.3",
42
42
  "undici": "^8.12.4",
43
- "ws": "^8.22.2"
43
+ "ws": "^8.23.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "esbuild": "^0.28.2",
@@ -63,7 +63,7 @@
63
63
  "eslint-plugin-import": "^2.32.0",
64
64
  "mysql2": "^3.24.6",
65
65
  "typescript": "^6.0.3",
66
- "vite": "^8.3.7",
66
+ "vite": "^8.3.8",
67
67
  "vite-plugin-dts": "^5.1.2",
68
68
  "vitest": "^5.1.0"
69
69
  }