@plitzi/sdk-kernel 0.39.8 → 0.39.9

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,14 @@
1
1
  # @plitzi/sdk-kernel
2
2
 
3
+ ## 0.39.9
4
+
5
+ ### Patch Changes
6
+
7
+ - f04c646: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
8
+ `@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
9
+ - Updated dependencies [f04c646]
10
+ - @plitzi/sdk-shared@0.39.9
11
+
3
12
  ## 0.39.8
4
13
 
5
14
  ### Patch Changes
@@ -107,10 +107,13 @@ var buildResponseHelpers = (raw, acceptEncoding, compression = DEFAULT_COMPRESSI
107
107
  * all, where a credential travels beside a value the caller chose (the `scope` it echoes back). Compressing the
108
108
  * two together is the shape a BREACH-style attack needs, and the stage that knows this is the one that has
109
109
  * already said so in a header.
110
+ *
111
+ * A stage that says it to the proxies alone — a page, whose HTML must not be rewritten on the way but is this
112
+ * server's to compress — sends with `ownEncoding`.
110
113
  */
111
- const transformable = () => !String(raw.getHeaders()["cache-control"]).includes("no-transform");
114
+ const transformable = (ownEncoding) => ownEncoding || !String(raw.getHeaders()["cache-control"]).includes("no-transform");
112
115
  /** A stored form this request can take as it is, without the body it was made from. */
113
- const storedFor = (store) => encoding === "identity" || !transformable() ? void 0 : store?.[encoding];
116
+ const storedFor = (store, ownEncoding) => encoding === "identity" || !transformable(ownEncoding) ? void 0 : store?.[encoding];
114
117
  const writeBody = (payload, encoded) => {
115
118
  if (encoded) {
116
119
  raw.setHeader("Content-Encoding", encoding);
@@ -120,8 +123,8 @@ var buildResponseHelpers = (raw, acceptEncoding, compression = DEFAULT_COMPRESSI
120
123
  if (!raw.headersSent) raw.writeHead(statusCode);
121
124
  raw.end(payload);
122
125
  };
123
- const writeSend = (content, store) => {
124
- const stored = typeof content === "function" ? storedFor(store) : void 0;
126
+ const writeSend = (content, store, ownEncoding = false) => {
127
+ const stored = typeof content === "function" ? storedFor(store, ownEncoding) : void 0;
125
128
  if (stored) {
126
129
  writeBody(stored, true);
127
130
  return;
@@ -135,7 +138,7 @@ var buildResponseHelpers = (raw, acceptEncoding, compression = DEFAULT_COMPRESSI
135
138
  * corrupts any font, image or archive served through it. What a Buffer holds is also compressed already
136
139
  * (woff2, png), so re-encoding it would cost CPU to make it bigger.
137
140
  */
138
- const compressed = typeof body === "string" && transformable() ? compressOnce(body, encoding, compression, store) : body;
141
+ const compressed = typeof body === "string" && transformable(ownEncoding) ? compressOnce(body, encoding, compression, store) : body;
139
142
  writeBody(compressed, compressed !== body);
140
143
  };
141
144
  return {
@@ -152,7 +155,7 @@ var buildResponseHelpers = (raw, acceptEncoding, compression = DEFAULT_COMPRESSI
152
155
  statusCode = code;
153
156
  },
154
157
  send(body, options) {
155
- writeSend(body, options?.compressed);
158
+ writeSend(body, options?.compressed, options?.ownEncoding);
156
159
  },
157
160
  write(chunk) {
158
161
  if (!raw.headersSent) raw.writeHead(statusCode);
@@ -49,9 +49,14 @@ export type SSRResponseHelpers = {
49
49
  *
50
50
  * A function is a body read only when it is needed: when the stored form for this request's encoding is missing, or
51
51
  * the client takes no compression. A static file is then read from disk once per encoding, not on every request.
52
+ *
53
+ * `ownEncoding` is for a body whose `Cache-Control: no-transform` is said to the proxies after this server, not to
54
+ * this server: it is still compressed here — that encoding is how the origin sends it — and nothing on the way may
55
+ * change it. Without it `no-transform` holds this server too, as a response carrying a credential needs.
52
56
  */
53
57
  send: (body: string | Buffer | (() => string), options?: {
54
58
  compressed?: CompressedBodies;
59
+ ownEncoding?: boolean;
55
60
  }) => void;
56
61
  write: (chunk: string | Buffer) => void;
57
62
  end: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-kernel",
3
- "version": "0.39.8",
3
+ "version": "0.39.9",
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,7 +37,7 @@
37
37
  "build:prod": "vite build"
38
38
  },
39
39
  "dependencies": {
40
- "@plitzi/sdk-shared": "0.39.8",
40
+ "@plitzi/sdk-shared": "0.39.9",
41
41
  "jsonwebtoken": "^9.0.3",
42
42
  "undici": "^8.12.4",
43
43
  "ws": "^8.23.0"