@zuplo/cli 7.13.9 → 7.13.13

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 (120) hide show
  1. package/node_modules/@hono/node-server/dist/index.cjs +31 -6
  2. package/node_modules/@hono/node-server/dist/index.mjs +31 -6
  3. package/node_modules/@hono/node-server/package.json +1 -1
  4. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
  5. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  6. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
  7. package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
  8. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
  9. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  10. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  12. package/node_modules/@posthog/core/dist/cookie.d.ts +4 -0
  13. package/node_modules/@posthog/core/dist/cookie.d.ts.map +1 -1
  14. package/node_modules/@posthog/core/dist/cookie.js +8 -2
  15. package/node_modules/@posthog/core/dist/cookie.mjs +8 -2
  16. package/node_modules/@posthog/core/dist/utils/bot-detection.d.ts.map +1 -1
  17. package/node_modules/@posthog/core/dist/utils/bot-detection.js +1 -0
  18. package/node_modules/@posthog/core/dist/utils/bot-detection.mjs +1 -0
  19. package/node_modules/@posthog/core/package.json +2 -2
  20. package/node_modules/@posthog/core/src/cookie.ts +13 -2
  21. package/node_modules/@posthog/core/src/utils/bot-detection.spec.ts +7 -0
  22. package/node_modules/@posthog/core/src/utils/bot-detection.ts +1 -0
  23. package/node_modules/@zuplo/core/customer.cli.minified.js +332 -332
  24. package/node_modules/@zuplo/core/index.minified.js +320 -320
  25. package/node_modules/@zuplo/core/package.json +1 -1
  26. package/node_modules/@zuplo/graphql/package.json +1 -1
  27. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  28. package/node_modules/@zuplo/otel/package.json +1 -1
  29. package/node_modules/@zuplo/runtime/out/esm/{chunk-D4D3WYPP.js → chunk-3DWWKPBI.js} +85 -85
  30. package/node_modules/@zuplo/runtime/out/esm/chunk-3DWWKPBI.js.map +1 -0
  31. package/node_modules/@zuplo/runtime/out/esm/{chunk-PXS4NOKU.js → chunk-KA4STQE7.js} +17 -17
  32. package/node_modules/@zuplo/runtime/out/esm/chunk-KA4STQE7.js.map +1 -0
  33. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js +26 -0
  34. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js.map +1 -0
  35. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  36. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
  37. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  38. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  39. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
  40. package/node_modules/@zuplo/runtime/out/types/index.d.ts +60 -0
  41. package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +119 -0
  42. package/node_modules/@zuplo/runtime/package.json +1 -1
  43. package/node_modules/express-rate-limit/dist/index.cjs +1 -1
  44. package/node_modules/express-rate-limit/dist/index.mjs +1 -1
  45. package/node_modules/express-rate-limit/package.json +1 -1
  46. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  47. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  48. package/node_modules/hono/dist/cjs/context.js +1 -1
  49. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -5
  50. package/node_modules/hono/dist/cjs/hono-base.js +4 -10
  51. package/node_modules/hono/dist/cjs/hono.js +0 -1
  52. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
  53. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
  54. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  55. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  56. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  57. package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
  58. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  59. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  60. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  61. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  62. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
  63. package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
  64. package/node_modules/hono/dist/cjs/utils/url.js +10 -0
  65. package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
  66. package/node_modules/hono/dist/context.js +1 -1
  67. package/node_modules/hono/dist/helper/css/common.js +3 -5
  68. package/node_modules/hono/dist/hono-base.js +4 -10
  69. package/node_modules/hono/dist/hono.js +0 -1
  70. package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
  71. package/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
  72. package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  73. package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  74. package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  75. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  76. package/node_modules/hono/dist/middleware/mount/index.js +4 -4
  77. package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  78. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  79. package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  80. package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  81. package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
  82. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  83. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  84. package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  85. package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
  86. package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
  87. package/node_modules/hono/dist/utils/mount.js +34 -0
  88. package/node_modules/hono/dist/utils/url.js +10 -1
  89. package/node_modules/hono/dist/validator/validator.js +1 -1
  90. package/node_modules/hono/package.json +1 -1
  91. package/node_modules/ip-address/README.md +39 -39
  92. package/node_modules/ip-address/dist/ipv6.js +1 -1
  93. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  94. package/node_modules/ip-address/package.json +1 -1
  95. package/node_modules/thread-stream/.github/workflows/ci.yml +1 -1
  96. package/node_modules/thread-stream/SECURITY.md +77 -0
  97. package/node_modules/thread-stream/index.d.ts +2 -1
  98. package/node_modules/thread-stream/index.js +65 -7
  99. package/node_modules/thread-stream/lib/wait.js +23 -5
  100. package/node_modules/thread-stream/package.json +10 -5
  101. package/node_modules/thread-stream/test/create-and-exit.js +1 -1
  102. package/node_modules/thread-stream/test/end.test.js +35 -0
  103. package/node_modules/thread-stream/test/error-flush.test.js +96 -0
  104. package/node_modules/thread-stream/test/error-immediate.js +17 -0
  105. package/node_modules/thread-stream/test/flush-ref-keeps-alive.js +23 -0
  106. package/node_modules/thread-stream/test/flush-unref-exit.js +23 -0
  107. package/node_modules/thread-stream/test/ready-race-worker.js +22 -0
  108. package/node_modules/thread-stream/test/ready.test.js +46 -0
  109. package/node_modules/thread-stream/test/thread-management.test.js +68 -0
  110. package/node_modules/thread-stream/test/to-file-sync.js +23 -0
  111. package/node_modules/thread-stream/test/types/index.test-d.ts +26 -0
  112. package/node_modules/thread-stream/test/wait.test.js +131 -0
  113. package/package.json +11 -11
  114. package/node_modules/@zuplo/runtime/out/esm/chunk-D4D3WYPP.js.map +0 -1
  115. package/node_modules/@zuplo/runtime/out/esm/chunk-PXS4NOKU.js.map +0 -1
  116. package/node_modules/@zuplo/runtime/out/esm/chunk-ZCJ5QBVD.js +0 -26
  117. package/node_modules/@zuplo/runtime/out/esm/chunk-ZCJ5QBVD.js.map +0 -1
  118. package/node_modules/thread-stream/.claude/settings.local.json +0 -15
  119. /package/node_modules/@zuplo/runtime/out/esm/{chunk-D4D3WYPP.js.LEGAL.txt → chunk-3DWWKPBI.js.LEGAL.txt} +0 -0
  120. /package/node_modules/@zuplo/runtime/out/esm/{chunk-PXS4NOKU.js.LEGAL.txt → chunk-KA4STQE7.js.LEGAL.txt} +0 -0
@@ -169,16 +169,27 @@ const newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeader
169
169
  const reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
170
170
  const reDotSegment = /\/\.\.?(?:[/?#]|$)/;
171
171
  const reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
172
+ const validateRequestTarget = (target) => {
173
+ const backslash = target.indexOf("\\");
174
+ if (backslash !== -1) {
175
+ const query = target.indexOf("?");
176
+ if (query === -1 || backslash < query) throw new RequestError("Backslash in request path");
177
+ }
178
+ };
172
179
  const buildUrl = (scheme, host, incomingUrl) => {
173
180
  const url = `${scheme}://${host}${incomingUrl}`;
174
181
  if (!reValidHost.test(host)) {
182
+ validateRequestTarget(incomingUrl);
175
183
  const urlObj = new URL(url);
176
184
  if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
177
185
  return urlObj.href;
178
186
  } else if (incomingUrl.length === 0) return url + "/";
179
187
  else {
180
188
  if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
181
- if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
189
+ if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) {
190
+ validateRequestTarget(incomingUrl);
191
+ return new URL(url).href;
192
+ }
182
193
  return url;
183
194
  }
184
195
  };
@@ -591,6 +602,7 @@ const newRequest = (incoming, defaultHostname) => {
591
602
  if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
592
603
  if (incoming instanceof node_http2.Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
593
604
  try {
605
+ validateRequestTarget(incomingUrl);
594
606
  req[urlKey] = new URL(incomingUrl).href;
595
607
  } catch (e) {
596
608
  throw new RequestError("Invalid absolute URL", { cause: e });
@@ -1143,6 +1155,7 @@ const appendResponseHeaders = (headers, responseHeaders) => {
1143
1155
  });
1144
1156
  };
1145
1157
  const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1158
+ if (socket.destroyed) return;
1146
1159
  const responseLines = ["Connection: close", "Content-Length: 0"];
1147
1160
  appendResponseHeaders(responseLines, responseHeaders);
1148
1161
  socket.end(`HTTP/1.1 ${status.toString()} ${node_http.STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
@@ -1150,7 +1163,12 @@ const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1150
1163
  };
1151
1164
  const createUpgradeRequest = (request) => {
1152
1165
  const protocol = request.socket.encrypted ? "https" : "http";
1153
- const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
1166
+ const incomingUrl = request.url ?? "/";
1167
+ let url;
1168
+ if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
1169
+ validateRequestTarget(incomingUrl);
1170
+ url = new URL(incomingUrl).href;
1171
+ } else url = buildUrl(protocol, request.headers.host ?? "localhost", incomingUrl);
1154
1172
  const headers = new Headers();
1155
1173
  for (const key in request.headers) {
1156
1174
  const value = request.headers[key];
@@ -1187,6 +1205,10 @@ const setupWebSocket = (options) => {
1187
1205
  };
1188
1206
  server.on("upgrade", async (request, socket, head) => {
1189
1207
  if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
1208
+ const ignoreSocketError = () => {};
1209
+ const reclaimWaiterOnClose = () => rejectWaiter(request);
1210
+ socket.on("error", ignoreSocketError);
1211
+ socket.once("close", reclaimWaiterOnClose);
1190
1212
  const env = {
1191
1213
  incoming: request,
1192
1214
  outgoing: void 0,
@@ -1201,8 +1223,12 @@ const setupWebSocket = (options) => {
1201
1223
  status = response.status;
1202
1224
  responseHeaders = response.headers;
1203
1225
  }
1204
- } catch {
1205
- if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
1226
+ } catch (error) {
1227
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, error instanceof RequestError ? 400 : 500);
1228
+ return;
1229
+ }
1230
+ if (socket.destroyed) {
1231
+ rejectWaiter(request);
1206
1232
  return;
1207
1233
  }
1208
1234
  const waiter = waiterMap.get(request);
@@ -1214,12 +1240,11 @@ const setupWebSocket = (options) => {
1214
1240
  const addResponseHeaders = (headers) => {
1215
1241
  appendResponseHeaders(headers, responseHeaders);
1216
1242
  };
1217
- const reclaimWaiterOnClose = () => rejectWaiter(request);
1218
- socket.once("close", reclaimWaiterOnClose);
1219
1243
  wss.on("headers", addResponseHeaders);
1220
1244
  try {
1221
1245
  wss.handleUpgrade(request, socket, head, (ws) => {
1222
1246
  socket.off("close", reclaimWaiterOnClose);
1247
+ socket.off("error", ignoreSocketError);
1223
1248
  wss.emit("connection", ws, request);
1224
1249
  });
1225
1250
  } finally {
@@ -168,16 +168,27 @@ const newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeader
168
168
  const reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
169
169
  const reDotSegment = /\/\.\.?(?:[/?#]|$)/;
170
170
  const reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
171
+ const validateRequestTarget = (target) => {
172
+ const backslash = target.indexOf("\\");
173
+ if (backslash !== -1) {
174
+ const query = target.indexOf("?");
175
+ if (query === -1 || backslash < query) throw new RequestError("Backslash in request path");
176
+ }
177
+ };
171
178
  const buildUrl = (scheme, host, incomingUrl) => {
172
179
  const url = `${scheme}://${host}${incomingUrl}`;
173
180
  if (!reValidHost.test(host)) {
181
+ validateRequestTarget(incomingUrl);
174
182
  const urlObj = new URL(url);
175
183
  if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
176
184
  return urlObj.href;
177
185
  } else if (incomingUrl.length === 0) return url + "/";
178
186
  else {
179
187
  if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
180
- if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
188
+ if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) {
189
+ validateRequestTarget(incomingUrl);
190
+ return new URL(url).href;
191
+ }
181
192
  return url;
182
193
  }
183
194
  };
@@ -590,6 +601,7 @@ const newRequest = (incoming, defaultHostname) => {
590
601
  if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
591
602
  if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
592
603
  try {
604
+ validateRequestTarget(incomingUrl);
593
605
  req[urlKey] = new URL(incomingUrl).href;
594
606
  } catch (e) {
595
607
  throw new RequestError("Invalid absolute URL", { cause: e });
@@ -1142,6 +1154,7 @@ const appendResponseHeaders = (headers, responseHeaders) => {
1142
1154
  });
1143
1155
  };
1144
1156
  const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1157
+ if (socket.destroyed) return;
1145
1158
  const responseLines = ["Connection: close", "Content-Length: 0"];
1146
1159
  appendResponseHeaders(responseLines, responseHeaders);
1147
1160
  socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\n${responseLines.join("\r\n")}\r\n\r
@@ -1149,7 +1162,12 @@ const rejectUpgradeRequest = (socket, status, responseHeaders) => {
1149
1162
  };
1150
1163
  const createUpgradeRequest = (request) => {
1151
1164
  const protocol = request.socket.encrypted ? "https" : "http";
1152
- const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
1165
+ const incomingUrl = request.url ?? "/";
1166
+ let url;
1167
+ if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
1168
+ validateRequestTarget(incomingUrl);
1169
+ url = new URL(incomingUrl).href;
1170
+ } else url = buildUrl(protocol, request.headers.host ?? "localhost", incomingUrl);
1153
1171
  const headers = new Headers();
1154
1172
  for (const key in request.headers) {
1155
1173
  const value = request.headers[key];
@@ -1186,6 +1204,10 @@ const setupWebSocket = (options) => {
1186
1204
  };
1187
1205
  server.on("upgrade", async (request, socket, head) => {
1188
1206
  if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
1207
+ const ignoreSocketError = () => {};
1208
+ const reclaimWaiterOnClose = () => rejectWaiter(request);
1209
+ socket.on("error", ignoreSocketError);
1210
+ socket.once("close", reclaimWaiterOnClose);
1189
1211
  const env = {
1190
1212
  incoming: request,
1191
1213
  outgoing: void 0,
@@ -1200,8 +1222,12 @@ const setupWebSocket = (options) => {
1200
1222
  status = response.status;
1201
1223
  responseHeaders = response.headers;
1202
1224
  }
1203
- } catch {
1204
- if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
1225
+ } catch (error) {
1226
+ if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, error instanceof RequestError ? 400 : 500);
1227
+ return;
1228
+ }
1229
+ if (socket.destroyed) {
1230
+ rejectWaiter(request);
1205
1231
  return;
1206
1232
  }
1207
1233
  const waiter = waiterMap.get(request);
@@ -1213,12 +1239,11 @@ const setupWebSocket = (options) => {
1213
1239
  const addResponseHeaders = (headers) => {
1214
1240
  appendResponseHeaders(headers, responseHeaders);
1215
1241
  };
1216
- const reclaimWaiterOnClose = () => rejectWaiter(request);
1217
- socket.once("close", reclaimWaiterOnClose);
1218
1242
  wss.on("headers", addResponseHeaders);
1219
1243
  try {
1220
1244
  wss.handleUpgrade(request, socket, head, (ws) => {
1221
1245
  socket.off("close", reclaimWaiterOnClose);
1246
+ socket.off("error", ignoreSocketError);
1222
1247
  wss.emit("connection", ws, request);
1223
1248
  });
1224
1249
  } finally {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hono/node-server",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "description": "Node.js Adapter for Hono",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -5,7 +5,7 @@ function isCloudflareWorkers() {
5
5
  return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
6
6
  }
7
7
  let USER_AGENT;
8
- (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.14");
8
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.15");
9
9
  const customFetch = /* @__PURE__ */ Symbol();
10
10
  async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
11
11
  const response = await fetchImpl(url, {
@@ -31,6 +31,8 @@ function isFreshFor(timestamp, duration) {
31
31
  function validateDuration(value, fallback, option) {
32
32
  if (Number.isNaN(value))
33
33
  throw new TypeError(`"${option}" option must not be NaN`);
34
+ if (typeof value == "number" && value < 0)
35
+ throw new TypeError(`"${option}" option must not be negative`);
34
36
  return typeof value == "number" ? value : fallback;
35
37
  }
36
38
  function createRemoteJWKSet(url, options) {
@@ -23,7 +23,8 @@ async function transform(stream, input, maxLength = 1 / 0) {
23
23
  if (done)
24
24
  break;
25
25
  if (chunks.push(value), length += value.byteLength, maxLength !== 1 / 0 && length > maxLength)
26
- throw new JWEInvalid("Decompressed plaintext exceeded the configured limit");
26
+ throw await reader.cancel().catch(() => {
27
+ }), new JWEInvalid("Decompressed plaintext exceeded the configured limit");
27
28
  }
28
29
  return concat(...chunks);
29
30
  }
@@ -77,7 +77,8 @@ function validateClaimsSet(protectedHeader, claimsSetBytes, options = {}) {
77
77
  throw new TypeError("Invalid clockTolerance option type");
78
78
  tolerance = clockTolerance;
79
79
  }
80
- validateInput("clockTolerance option", tolerance);
80
+ if (validateInput("clockTolerance option", tolerance), tolerance < 0)
81
+ throw new TypeError("Invalid clockTolerance option input");
81
82
  const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(claimsSet, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(claimsSet, "nbf");
82
83
  if (nbf !== void 0 && nbf > now + tolerance)
83
84
  throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', claimsSet, "nbf", checkFailed);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.14",
3
+ "version": "6.2.15",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -5,7 +5,7 @@ function isCloudflareWorkers() {
5
5
  return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
6
6
  }
7
7
  let USER_AGENT;
8
- (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.14");
8
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.15");
9
9
  const customFetch = /* @__PURE__ */ Symbol();
10
10
  async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
11
11
  const response = await fetchImpl(url, {
@@ -31,6 +31,8 @@ function isFreshFor(timestamp, duration) {
31
31
  function validateDuration(value, fallback, option) {
32
32
  if (Number.isNaN(value))
33
33
  throw new TypeError(`"${option}" option must not be NaN`);
34
+ if (typeof value == "number" && value < 0)
35
+ throw new TypeError(`"${option}" option must not be negative`);
34
36
  return typeof value == "number" ? value : fallback;
35
37
  }
36
38
  function createRemoteJWKSet(url, options) {
@@ -23,7 +23,8 @@ async function transform(stream, input, maxLength = 1 / 0) {
23
23
  if (done)
24
24
  break;
25
25
  if (chunks.push(value), length += value.byteLength, maxLength !== 1 / 0 && length > maxLength)
26
- throw new JWEInvalid("Decompressed plaintext exceeded the configured limit");
26
+ throw await reader.cancel().catch(() => {
27
+ }), new JWEInvalid("Decompressed plaintext exceeded the configured limit");
27
28
  }
28
29
  return concat(...chunks);
29
30
  }
@@ -77,7 +77,8 @@ function validateClaimsSet(protectedHeader, claimsSetBytes, options = {}) {
77
77
  throw new TypeError("Invalid clockTolerance option type");
78
78
  tolerance = clockTolerance;
79
79
  }
80
- validateInput("clockTolerance option", tolerance);
80
+ if (validateInput("clockTolerance option", tolerance), tolerance < 0)
81
+ throw new TypeError("Invalid clockTolerance option input");
81
82
  const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(claimsSet, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(claimsSet, "nbf");
82
83
  if (nbf !== void 0 && nbf > now + tolerance)
83
84
  throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', claimsSet, "nbf", checkFailed);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jose",
3
- "version": "6.2.14",
3
+ "version": "6.2.15",
4
4
  "description": "JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes",
5
5
  "keywords": [
6
6
  "akp",
@@ -15,6 +15,10 @@ export interface PostHogCookieState {
15
15
  distinctId: string;
16
16
  isIdentified: boolean;
17
17
  sessionId?: string;
18
+ /** When the session last had activity (`$sesid[0]`), in milliseconds since the Unix epoch. */
19
+ sessionLastActivityTimestamp?: number;
20
+ /** When the session started (`$sesid[2]`), in milliseconds since the Unix epoch. */
21
+ sessionStartTimestamp?: number;
18
22
  deviceId?: string;
19
23
  }
20
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../src/cookie.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;CACjD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAmBvE;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CASlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAIjG;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAY5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAuBjF;AAED,MAAM,WAAW,mBAAmB;IAClC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,+BAA+B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChD;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAQzF;AAED,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,4BAA4B,CAAC,EAAE,OAAO,CAAA;CACvC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAUhG"}
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../src/cookie.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAA;CACjD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAmBvE;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8FAA8F;IAC9F,4BAA4B,CAAC,EAAE,MAAM,CAAA;IACrC,oFAAoF;IACpF,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CASlE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAIjG;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAY5G;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CA0BjF;AAMD,MAAM,WAAW,mBAAmB;IAClC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxC,+BAA+B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChD;AAID,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAQzF;AAED,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,4BAA4B,CAAC,EAAE,OAAO,CAAA;CACvC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAUhG"}
@@ -95,17 +95,23 @@ function parsePostHogCookie(cookieValue) {
95
95
  try {
96
96
  const parsed = JSON.parse(cookieValue);
97
97
  if (!parsed || 'object' != typeof parsed || !parsed.distinct_id) return null;
98
- const sesid = (0, index_js_namespaceObject.isArray)(parsed.$sesid) ? parsed.$sesid[1] : void 0;
98
+ const sesid = (0, index_js_namespaceObject.isArray)(parsed.$sesid) ? parsed.$sesid : [];
99
+ const sessionId = sesid[1];
99
100
  return {
100
101
  distinctId: String(parsed.distinct_id),
101
102
  isIdentified: 'identified' === parsed.$user_state,
102
- sessionId: 'string' == typeof sesid ? sesid : void 0,
103
+ sessionId: 'string' == typeof sessionId ? sessionId : void 0,
104
+ sessionLastActivityTimestamp: toTimestamp(sesid[0]),
105
+ sessionStartTimestamp: toTimestamp(sesid[2]),
103
106
  deviceId: 'string' == typeof parsed.$device_id ? parsed.$device_id : void 0
104
107
  };
105
108
  } catch {
106
109
  return null;
107
110
  }
108
111
  }
112
+ function toTimestamp(value) {
113
+ return 'number' == typeof value && Number.isFinite(value) ? value : void 0;
114
+ }
109
115
  const CONSENT_PREFIX = '__ph_opt_in_out_';
110
116
  function getConsentCookieName(apiKey, config) {
111
117
  if (config?.consent_persistence_name) return config.consent_persistence_name;
@@ -56,17 +56,23 @@ function parsePostHogCookie(cookieValue) {
56
56
  try {
57
57
  const parsed = JSON.parse(cookieValue);
58
58
  if (!parsed || 'object' != typeof parsed || !parsed.distinct_id) return null;
59
- const sesid = isArray(parsed.$sesid) ? parsed.$sesid[1] : void 0;
59
+ const sesid = isArray(parsed.$sesid) ? parsed.$sesid : [];
60
+ const sessionId = sesid[1];
60
61
  return {
61
62
  distinctId: String(parsed.distinct_id),
62
63
  isIdentified: 'identified' === parsed.$user_state,
63
- sessionId: 'string' == typeof sesid ? sesid : void 0,
64
+ sessionId: 'string' == typeof sessionId ? sessionId : void 0,
65
+ sessionLastActivityTimestamp: toTimestamp(sesid[0]),
66
+ sessionStartTimestamp: toTimestamp(sesid[2]),
64
67
  deviceId: 'string' == typeof parsed.$device_id ? parsed.$device_id : void 0
65
68
  };
66
69
  } catch {
67
70
  return null;
68
71
  }
69
72
  }
73
+ function toTimestamp(value) {
74
+ return 'number' == typeof value && Number.isFinite(value) ? value : void 0;
75
+ }
70
76
  const CONSENT_PREFIX = '__ph_opt_in_out_';
71
77
  function getConsentCookieName(apiKey, config) {
72
78
  if (config?.consent_persistence_name) return config.consent_persistence_name;
@@ -1 +1 @@
1
- {"version":3,"file":"bot-detection.d.ts","sourceRoot":"","sources":["../../src/utils/bot-detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,UAmGnC,CAAA;AAeD,0DAA0D;AAC1D,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAaD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,OAAiB,MAAM,GAAG,SAAS,4BAA2B,MAAM,EAAE,KAAQ,OAsBrG,CAAA"}
1
+ {"version":3,"file":"bot-detection.d.ts","sourceRoot":"","sources":["../../src/utils/bot-detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,UAoGnC,CAAA;AAeD,0DAA0D;AAC1D,wBAAgB,gCAAgC,IAAI,IAAI,CAEvD;AAaD;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,OAAiB,MAAM,GAAG,SAAS,4BAA2B,MAAM,EAAE,KAAQ,OAsBrG,CAAA"}
@@ -88,6 +88,7 @@ const DEFAULT_BLOCKED_UA_STRS = [
88
88
  'sentryuptimebot',
89
89
  'uptimerobot',
90
90
  'headlesschrome',
91
+ 'lightpanda',
91
92
  'cypress',
92
93
  'google-hoteladsverifier',
93
94
  'adsbot-google',
@@ -59,6 +59,7 @@ const DEFAULT_BLOCKED_UA_STRS = [
59
59
  'sentryuptimebot',
60
60
  'uptimerobot',
61
61
  'headlesschrome',
62
+ 'lightpanda',
62
63
  'cypress',
63
64
  'google-hoteladsverifier',
64
65
  'adsbot-google',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.62.0",
3
+ "version": "1.63.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -72,7 +72,7 @@
72
72
  }
73
73
  },
74
74
  "dependencies": {
75
- "@posthog/types": "^1.418.0"
75
+ "@posthog/types": "^1.419.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@rslib/core": "0.23.2",
@@ -40,6 +40,10 @@ export interface PostHogCookieState {
40
40
  distinctId: string
41
41
  isIdentified: boolean
42
42
  sessionId?: string
43
+ /** When the session last had activity (`$sesid[0]`), in milliseconds since the Unix epoch. */
44
+ sessionLastActivityTimestamp?: number
45
+ /** When the session started (`$sesid[2]`), in milliseconds since the Unix epoch. */
46
+ sessionStartTimestamp?: number
43
47
  deviceId?: string
44
48
  }
45
49
 
@@ -126,12 +130,15 @@ export function parsePostHogCookie(cookieValue: string): PostHogCookieState | nu
126
130
  }
127
131
 
128
132
  // $sesid is stored as [lastActivityTimestamp, sessionId, sessionStartTimestamp]
129
- const sesid = isArray(parsed.$sesid) ? parsed.$sesid[1] : undefined
133
+ const sesid: unknown[] = isArray(parsed.$sesid) ? parsed.$sesid : []
134
+ const sessionId = sesid[1]
130
135
 
131
136
  return {
132
137
  distinctId: String(parsed.distinct_id),
133
138
  isIdentified: parsed.$user_state === 'identified',
134
- sessionId: typeof sesid === 'string' ? sesid : undefined,
139
+ sessionId: typeof sessionId === 'string' ? sessionId : undefined,
140
+ sessionLastActivityTimestamp: toTimestamp(sesid[0]),
141
+ sessionStartTimestamp: toTimestamp(sesid[2]),
135
142
  deviceId: typeof parsed.$device_id === 'string' ? parsed.$device_id : undefined,
136
143
  }
137
144
  } catch {
@@ -139,6 +146,10 @@ export function parsePostHogCookie(cookieValue: string): PostHogCookieState | nu
139
146
  }
140
147
  }
141
148
 
149
+ function toTimestamp(value: unknown): number | undefined {
150
+ return typeof value === 'number' && Number.isFinite(value) ? value : undefined
151
+ }
152
+
142
153
  export interface ConsentCookieConfig {
143
154
  consent_persistence_name?: string | null
144
155
  opt_out_capturing_cookie_prefix?: string | null
@@ -43,6 +43,13 @@ describe('isBlockedUA', () => {
43
43
  expect(isBlockedUA('headlessChrome/119.0')).toBe(true)
44
44
  })
45
45
 
46
+ it.each(['Lightpanda/1.0', 'lightpanda/2.3.4', 'LIGHTPANDA/10.0', 'Mozilla/5.0 (compatible; Lightpanda/1.0)'])(
47
+ 'blocks the self-declared headless browser %s',
48
+ (ua) => {
49
+ expect(isBlockedUA(ua)).toBe(true)
50
+ }
51
+ )
52
+
46
53
  it('is case-insensitive on the UA input', () => {
47
54
  const bot = 'Mozilla/5.0 (compatible; Googlebot/2.1)'
48
55
  expect(isBlockedUA(bot)).toBe(true)
@@ -78,6 +78,7 @@ export const DEFAULT_BLOCKED_UA_STRS = [
78
78
 
79
79
  // headless browsers
80
80
  'headlesschrome',
81
+ 'lightpanda',
81
82
  'cypress',
82
83
  // we don't block electron here, as many customers use posthog-js in electron apps
83
84