@kubun/plugin-http 0.17.0 → 0.18.0

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/lib/index.d.ts CHANGED
@@ -69,3 +69,4 @@ export declare function createGraphApp(options: GraphAppOptions): GraphApp;
69
69
  * Other plugins can register additional routes via the API.
70
70
  */
71
71
  export declare function createHTTPPlugin(options?: HTTPPluginOptions): (params: PluginFactoryParams) => KubunPlugin;
72
+ export { isLoopbackSocketPair } from '@kubun/http-util';
package/lib/index.js CHANGED
@@ -14,10 +14,18 @@ const DEFAULT_PORT = 4321;
14
14
  * `bodyLimit` option to admit larger binary-state graph mutations, or lower it
15
15
  * to tighten the cap.
16
16
  */ const DEFAULT_BODY_LIMIT_BYTES = 1024 * 1024;
17
- // ---- Helpers ----
17
+ function socketContext(c) {
18
+ const env = c.env;
19
+ const socket = env?.incoming?.socket;
20
+ return {
21
+ localAddress: socket?.localAddress ?? null,
22
+ remoteAddress: socket?.remoteAddress ?? null,
23
+ secure: socket?.encrypted === true
24
+ };
25
+ }
18
26
  function createProtocolHandler(fetch) {
19
27
  return async (c)=>{
20
- return fetch(c.req.raw);
28
+ return fetch(c.req.raw, socketContext(c));
21
29
  };
22
30
  }
23
31
  /**
@@ -102,7 +110,7 @@ function createProtocolHandler(fetch) {
102
110
  registerRoute (method, path, handler) {
103
111
  const m = method.toLowerCase();
104
112
  // Hono handler type is deeply generic — cast through never to avoid `any`
105
- app[m](path, handler);
113
+ app[m](path, (c)=>handler(c, socketContext(c)));
106
114
  },
107
115
  registerProtocol (name, fetch) {
108
116
  const resolvedPath = `${normalizedPrefix}/${name}`;
@@ -178,3 +186,4 @@ function createProtocolHandler(fetch) {
178
186
  };
179
187
  };
180
188
  }
189
+ export { isLoopbackSocketPair } from '@kubun/http-util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/plugin-http",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "license": "see LICENSE.md",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -14,24 +14,24 @@
14
14
  "LICENSE.md"
15
15
  ],
16
16
  "dependencies": {
17
- "@enkaku/http-serve": "^0.21.0",
18
- "@enkaku/protocol": "^0.21.1",
19
- "@enkaku/server": "^0.21.2",
20
- "@hono/node-server": "^2.1.1",
21
- "@kubun/engine": "^0.17.0",
22
- "@kubun/http-util": "^0.17.0",
23
- "@kubun/plugin-http-api": "^0.17.0",
24
- "@sozai/async": "^0.2.1",
17
+ "@enkaku/http-serve": "^0.21.5",
18
+ "@enkaku/protocol": "^0.21.5",
19
+ "@enkaku/server": "^0.21.5",
20
+ "@hono/node-server": "^2.1.5",
21
+ "@kubun/engine": "^0.18.0",
22
+ "@kubun/http-util": "^0.18.0",
23
+ "@kubun/plugin-http-api": "^0.18.0",
24
+ "@sozai/async": "^0.4.1",
25
25
  "get-port": "^7.2.0",
26
- "hono": "^4.13.7"
26
+ "hono": "^4.13.13"
27
27
  },
28
28
  "devDependencies": {
29
- "@enkaku/http-fetch": "^0.21.0",
30
- "@kubun/client": "^0.17.0",
31
- "@kubun/plugin-service-api": "^0.17.0",
32
- "@kubun/plugin-service-server": "^0.17.0",
33
- "@kubun/protocol": "^0.17.0",
34
- "@kubun/service-graph-api": "^0.17.0",
29
+ "@enkaku/http-fetch": "^0.21.5",
30
+ "@kubun/client": "^0.18.0",
31
+ "@kubun/plugin-service-api": "^0.18.0",
32
+ "@kubun/plugin-service-server": "^0.18.0",
33
+ "@kubun/protocol": "^0.18.0",
34
+ "@kubun/service-graph-api": "^0.18.0",
35
35
  "@kubun/test-utils": "^0.0.0"
36
36
  },
37
37
  "publishConfig": {