@suveren/gateway 0.3.17 → 0.4.1
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/bin/suveren-gateway.js +419 -28
- package/content/integrations/calendar.json +20 -8
- package/content/integrations/crm.json +97 -23
- package/content/integrations/gmail.json +166 -29
- package/content/integrations/linkedin.json +15 -3
- package/content/integrations/mollie.json +2 -2
- package/dist/control-plane/index.mjs +341 -42
- package/dist/mcp-server/http.mjs +880 -210
- package/dist/ui/assets/index-Cog54HOo.js +105 -0
- package/dist/ui/assets/{index-DOt3SNnl.css → index-JHaCddDE.css} +1 -1
- package/dist/ui/index.html +2 -2
- package/lib/autostart-templates.d.mts +37 -0
- package/lib/autostart-templates.mjs +208 -0
- package/node_modules/@hap/core/dist/index.d.mts +27 -0
- package/node_modules/@hap/core/dist/index.d.ts +27 -0
- package/node_modules/@hap/core/dist/index.js +13 -1
- package/node_modules/@hap/core/dist/index.mjs +13 -1
- package/node_modules/@hap/core/package.json +1 -1
- package/node_modules/@hap/core/src/gatekeeper.ts +47 -1
- package/node_modules/@hap/core/src/types.ts +27 -0
- package/node_modules/@hono/node-server/README.md +58 -25
- package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
- package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
- package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
- package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
- package/node_modules/@hono/node-server/dist/index.cjs +1173 -0
- package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
- package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
- package/node_modules/@hono/node-server/dist/index.mjs +1143 -637
- package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
- package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
- package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
- package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
- package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
- package/node_modules/@hono/node-server/package.json +65 -54
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/README.md +15 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/index.js +0 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/media-typer/package.json +16 -12
- package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/crypto.d.ts +1 -1
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/body-parser/HISTORY.md +7 -1
- package/node_modules/body-parser/lib/types/json.js +7 -3
- package/node_modules/body-parser/lib/types/raw.js +7 -3
- package/node_modules/body-parser/lib/types/text.js +7 -3
- package/node_modules/body-parser/lib/types/urlencoded.js +7 -3
- package/node_modules/body-parser/package.json +1 -1
- package/node_modules/express-rate-limit/dist/index.cjs +69 -5
- package/node_modules/express-rate-limit/dist/index.d.cts +16 -0
- package/node_modules/express-rate-limit/dist/index.d.mts +16 -0
- package/node_modules/express-rate-limit/dist/index.d.ts +16 -0
- package/node_modules/express-rate-limit/dist/index.mjs +55 -5
- package/node_modules/express-rate-limit/node_modules/debug/LICENSE +20 -0
- package/node_modules/express-rate-limit/node_modules/debug/README.md +481 -0
- package/node_modules/express-rate-limit/node_modules/debug/package.json +64 -0
- package/node_modules/express-rate-limit/node_modules/debug/src/browser.js +272 -0
- package/node_modules/express-rate-limit/node_modules/debug/src/common.js +292 -0
- package/node_modules/express-rate-limit/node_modules/debug/src/index.js +10 -0
- package/node_modules/express-rate-limit/node_modules/debug/src/node.js +263 -0
- package/node_modules/express-rate-limit/node_modules/ms/index.js +162 -0
- package/node_modules/express-rate-limit/node_modules/ms/license.md +21 -0
- package/node_modules/express-rate-limit/node_modules/ms/package.json +38 -0
- package/node_modules/express-rate-limit/node_modules/ms/readme.md +59 -0
- package/node_modules/express-rate-limit/package.json +12 -9
- package/node_modules/fast-uri/index.js +17 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +62 -0
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -4
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +12 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -4
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +12 -2
- package/node_modules/hono/dist/cjs/client/client.js +10 -1
- package/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/hono/dist/cjs/helper/streaming/sse.js +5 -4
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
- package/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
- package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +10 -4
- package/node_modules/hono/dist/cjs/request.js +8 -3
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
- package/node_modules/hono/dist/cjs/utils/accept.js +1 -1
- package/node_modules/hono/dist/cjs/utils/body.js +6 -0
- package/node_modules/hono/dist/cjs/utils/url.js +1 -1
- package/node_modules/hono/dist/client/client.js +10 -1
- package/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/hono/dist/helper/streaming/sse.js +5 -4
- package/node_modules/hono/dist/middleware/cache/index.js +1 -1
- package/node_modules/hono/dist/middleware/compress/index.js +2 -1
- package/node_modules/hono/dist/middleware/etag/index.js +2 -1
- package/node_modules/hono/dist/middleware/method-override/index.js +5 -3
- package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +10 -4
- package/node_modules/hono/dist/request.js +8 -3
- package/node_modules/hono/dist/router/trie-router/node.js +9 -0
- package/node_modules/hono/dist/types/adapter/aws-lambda/types.d.ts +9 -0
- package/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/combine/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
- package/node_modules/hono/dist/types/utils/types.d.ts +1 -1
- package/node_modules/hono/dist/utils/accept.js +1 -1
- package/node_modules/hono/dist/utils/body.js +6 -0
- package/node_modules/hono/dist/utils/url.js +1 -1
- package/node_modules/hono/package.json +4 -4
- package/node_modules/ip-address/README.md +102 -96
- package/node_modules/ip-address/dist/common.d.ts +23 -0
- package/node_modules/ip-address/dist/common.js +27 -4
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +8 -1
- package/node_modules/ip-address/dist/ipv4.js +21 -8
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +59 -1
- package/node_modules/ip-address/dist/ipv6.js +149 -41
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/dist/v4/constants.js +5 -1
- package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
- package/node_modules/ip-address/dist/v6/constants.js +3 -2
- package/node_modules/ip-address/dist/v6/constants.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -2
- package/node_modules/jose/README.md +1 -4
- package/node_modules/jose/dist/types/jwks/remote.d.ts +3 -3
- package/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/jose/dist/webapi/lib/key_to_jwk.js +4 -1
- package/node_modules/jose/package.json +1 -1
- package/package.json +3 -2
- package/profiles/customers/0.4.profile.json +7 -4
- package/profiles/customers/0.5.profile.json +131 -0
- package/profiles/customers/0.6.profile.json +153 -0
- package/profiles/email/0.4.profile.json +8 -4
- package/profiles/index.json +2 -0
- package/server.js +10 -0
- package/dist/ui/assets/index-CTmWS7W4.js +0 -105
- package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
- package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
- package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
- package/node_modules/@hono/node-server/dist/globals.js +0 -29
- package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
- package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
- package/node_modules/@hono/node-server/dist/index.js +0 -702
- package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
- package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
- package/node_modules/@hono/node-server/dist/listener.js +0 -670
- package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
- package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
- package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
- package/node_modules/@hono/node-server/dist/request.js +0 -238
- package/node_modules/@hono/node-server/dist/request.mjs +0 -206
- package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
- package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
- package/node_modules/@hono/node-server/dist/response.js +0 -112
- package/node_modules/@hono/node-server/dist/response.mjs +0 -85
- package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
- package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
- package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
- package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
- package/node_modules/@hono/node-server/dist/server.js +0 -696
- package/node_modules/@hono/node-server/dist/server.mjs +0 -660
- package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
- package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
- package/node_modules/@hono/node-server/dist/types.js +0 -18
- package/node_modules/@hono/node-server/dist/types.mjs +0 -0
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
- package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
- package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
- package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
- package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
- package/node_modules/@hono/node-server/dist/utils.js +0 -99
- package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
- package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.js +0 -677
- package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
|
@@ -555,12 +555,23 @@ function checkBoundsFromFrameSchema(request, profile) {
|
|
|
555
555
|
}
|
|
556
556
|
return errors;
|
|
557
557
|
}
|
|
558
|
+
function boundGovernsAction(fieldName, fieldDef, bt, actionType) {
|
|
559
|
+
if (fieldDef.appliesTo) {
|
|
560
|
+
return actionType ? fieldDef.appliesTo.includes(actionType) : true;
|
|
561
|
+
}
|
|
562
|
+
if (bt.kind !== "cumulative_count" || !actionType) return true;
|
|
563
|
+
const prefix = fieldName.replace(/_(?:daily|monthly|weekly)_max$/, "");
|
|
564
|
+
const namedForAnAction = prefix !== fieldName;
|
|
565
|
+
const matches = prefix === actionType || prefix.startsWith("transaction");
|
|
566
|
+
return !namedForAnAction || matches;
|
|
567
|
+
}
|
|
558
568
|
function checkBoundsV4(request, profile, executionLog, now) {
|
|
559
569
|
const errors = [];
|
|
560
570
|
if (!profile.boundsSchema) return errors;
|
|
561
571
|
const bounds = request.frame;
|
|
562
572
|
const profileId = String(bounds.profile ?? profile.id);
|
|
563
|
-
const
|
|
573
|
+
const actionType = typeof request.execution.action_type === "string" ? request.execution.action_type : void 0;
|
|
574
|
+
const path = request.path ?? (bounds.path ? String(bounds.path) : "");
|
|
564
575
|
for (const [fieldName, fieldDef] of Object.entries(profile.boundsSchema.fields)) {
|
|
565
576
|
if (fieldName === "profile" || fieldName === "path") continue;
|
|
566
577
|
const boundValue = bounds[fieldName];
|
|
@@ -576,6 +587,7 @@ function checkBoundsV4(request, profile, executionLog, now) {
|
|
|
576
587
|
});
|
|
577
588
|
continue;
|
|
578
589
|
}
|
|
590
|
+
if (!boundGovernsAction(fieldName, fieldDef, bt, actionType)) continue;
|
|
579
591
|
switch (bt.kind) {
|
|
580
592
|
case "per_transaction": {
|
|
581
593
|
const actual = request.execution[bt.of];
|
|
@@ -40,6 +40,8 @@ import type {
|
|
|
40
40
|
AgentContextParams,
|
|
41
41
|
ExecutionLogQuery,
|
|
42
42
|
CumulativeFieldDef,
|
|
43
|
+
ProfileBoundsField,
|
|
44
|
+
BoundType,
|
|
43
45
|
} from './types';
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -406,6 +408,41 @@ function checkBoundsFromFrameSchema(request: GatekeeperRequest, profile: AgentPr
|
|
|
406
408
|
* enum — bound value must be in the allowed set (attest-time
|
|
407
409
|
* validation; not an execution-time check)
|
|
408
410
|
*/
|
|
411
|
+
/**
|
|
412
|
+
* Does this bound govern the action being attempted?
|
|
413
|
+
*
|
|
414
|
+
* Cumulative totals are scoped by (profileId, path) only, so without this every
|
|
415
|
+
* cumulative_count bound on a profile sees the same running count. On customers
|
|
416
|
+
* — which declares both write_daily_max and delete_daily_max — the smaller
|
|
417
|
+
* delete limit would count writes and block them.
|
|
418
|
+
*
|
|
419
|
+
* Preferred answer is the profile's declared `appliesTo`. Absent that, fall back
|
|
420
|
+
* to the field-name convention (`delete_daily_max` → `delete`), matching how the
|
|
421
|
+
* Authority Server selects bounds so the two enforcement points cannot disagree.
|
|
422
|
+
*
|
|
423
|
+
* Fails CLOSED: when the action type is unknown, or the bound's name implies no
|
|
424
|
+
* particular action, the bound is enforced.
|
|
425
|
+
*/
|
|
426
|
+
function boundGovernsAction(
|
|
427
|
+
fieldName: string,
|
|
428
|
+
fieldDef: ProfileBoundsField,
|
|
429
|
+
bt: BoundType,
|
|
430
|
+
actionType: string | undefined,
|
|
431
|
+
): boolean {
|
|
432
|
+
if (fieldDef.appliesTo) {
|
|
433
|
+
return actionType ? fieldDef.appliesTo.includes(actionType) : true;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// The name convention only ever disambiguated count bounds; sums are governed
|
|
437
|
+
// by their `of` field and stay unfiltered, as at the Authority Server.
|
|
438
|
+
if (bt.kind !== 'cumulative_count' || !actionType) return true;
|
|
439
|
+
|
|
440
|
+
const prefix = fieldName.replace(/_(?:daily|monthly|weekly)_max$/, '');
|
|
441
|
+
const namedForAnAction = prefix !== fieldName;
|
|
442
|
+
const matches = prefix === actionType || prefix.startsWith('transaction');
|
|
443
|
+
return !namedForAnAction || matches;
|
|
444
|
+
}
|
|
445
|
+
|
|
409
446
|
function checkBoundsV4(
|
|
410
447
|
request: GatekeeperRequest,
|
|
411
448
|
profile: AgentProfile,
|
|
@@ -417,7 +454,14 @@ function checkBoundsV4(
|
|
|
417
454
|
|
|
418
455
|
const bounds = request.frame as AgentBoundsParams;
|
|
419
456
|
const profileId = String(bounds.profile ?? profile.id);
|
|
420
|
-
const
|
|
457
|
+
const actionType = typeof request.execution.action_type === 'string'
|
|
458
|
+
? request.execution.action_type
|
|
459
|
+
: undefined;
|
|
460
|
+
// Prefer the explicit request path. `frame.path` is retained only as a
|
|
461
|
+
// fallback for callers that legitimately declare `path` in their profile's
|
|
462
|
+
// boundsSchema; for every shipped profile it is absent, which is exactly why
|
|
463
|
+
// this silently resolved to "" and disabled the cumulative gate entirely.
|
|
464
|
+
const path = request.path ?? (bounds.path ? String(bounds.path) : '');
|
|
421
465
|
|
|
422
466
|
for (const [fieldName, fieldDef] of Object.entries(profile.boundsSchema.fields)) {
|
|
423
467
|
if (fieldName === 'profile' || fieldName === 'path') continue;
|
|
@@ -441,6 +485,8 @@ function checkBoundsV4(
|
|
|
441
485
|
continue;
|
|
442
486
|
}
|
|
443
487
|
|
|
488
|
+
if (!boundGovernsAction(fieldName, fieldDef, bt, actionType)) continue;
|
|
489
|
+
|
|
444
490
|
switch (bt.kind) {
|
|
445
491
|
case 'per_transaction': {
|
|
446
492
|
const actual = request.execution[bt.of];
|
|
@@ -213,6 +213,21 @@ export interface ProfileBoundsField {
|
|
|
213
213
|
* treat a missing boundType as an error when running in v0.4 mode.
|
|
214
214
|
*/
|
|
215
215
|
boundType?: BoundType;
|
|
216
|
+
/**
|
|
217
|
+
* Which execution action types this bound governs, e.g. `["write"]`.
|
|
218
|
+
*
|
|
219
|
+
* When present, this is authoritative. When absent, enforcement falls back to
|
|
220
|
+
* inferring the action type from the FIELD NAME (`send_daily_max` → `send`),
|
|
221
|
+
* which is a convention rather than a contract: a profile that names a bound
|
|
222
|
+
* after the domain concept instead of the action — calendar's
|
|
223
|
+
* `booking_daily_max` against an action type of `write` — matches nothing and
|
|
224
|
+
* is skipped, so a limit the user set is never applied and nothing says so.
|
|
225
|
+
*
|
|
226
|
+
* Declaring it removes the guess. Deliberately additive: profiles migrate one
|
|
227
|
+
* at a time, and every remaining fallback is logged, so the cases still
|
|
228
|
+
* relying on the naming convention become visible instead of staying silent.
|
|
229
|
+
*/
|
|
230
|
+
appliesTo?: string[];
|
|
216
231
|
/**
|
|
217
232
|
* The measurement dimension of the bound's value. UI renders the unit
|
|
218
233
|
* inline next to the input (e.g. `4 min`, `100 EUR`). Independent from
|
|
@@ -502,6 +517,18 @@ export interface GatekeeperRequest {
|
|
|
502
517
|
execution: Record<string, string | number>;
|
|
503
518
|
/** v0.4: context parameters (currency, action_type, etc.) */
|
|
504
519
|
context?: AgentContextParams;
|
|
520
|
+
/**
|
|
521
|
+
* Authorization path used to scope cumulative lookups in the execution log.
|
|
522
|
+
*
|
|
523
|
+
* Deliberately OUTSIDE `frame`: the frame is hashed and validated against the
|
|
524
|
+
* profile's boundsSchema, so an extra key there is rejected as an unknown
|
|
525
|
+
* field and breaks attestation verification outright. Cumulative checks
|
|
526
|
+
* previously read the path from the frame, where callers cannot legally put
|
|
527
|
+
* it — so it resolved to "" while the log stored real paths, no entry ever
|
|
528
|
+
* matched, and every running total read zero. The local gate existed but
|
|
529
|
+
* could never fire.
|
|
530
|
+
*/
|
|
531
|
+
path?: string;
|
|
505
532
|
}
|
|
506
533
|
|
|
507
534
|
/**
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# Node.js Adapter for Hono
|
|
2
2
|
|
|
3
3
|
This adapter `@hono/node-server` allows you to run your Hono application on Node.js.
|
|
4
|
-
Initially, Hono wasn't designed for Node.js, but with this adapter, you can now use Hono on Node.js.
|
|
5
|
-
It utilizes web standard APIs implemented in Node.js version 18 or higher.
|
|
4
|
+
Initially, Hono wasn't designed for Node.js, but with this adapter, you can now use Hono on Node.js. It utilizes web standard APIs implemented in Node.js.
|
|
6
5
|
|
|
7
6
|
## Benchmarks
|
|
8
7
|
|
|
9
|
-
Hono is
|
|
8
|
+
Hono is 4.1 times faster than Express.
|
|
10
9
|
|
|
11
10
|
Express:
|
|
12
11
|
|
|
@@ -14,12 +13,12 @@ Express:
|
|
|
14
13
|
$ bombardier -d 10s --fasthttp http://localhost:3000/
|
|
15
14
|
|
|
16
15
|
Statistics Avg Stdev Max
|
|
17
|
-
Reqs/sec
|
|
18
|
-
Latency
|
|
16
|
+
Reqs/sec 20803.37 1713.06 24910.85
|
|
17
|
+
Latency 6.01ms 5.21ms 451.37ms
|
|
19
18
|
HTTP codes:
|
|
20
|
-
1xx - 0, 2xx -
|
|
19
|
+
1xx - 0, 2xx - 208131, 3xx - 0, 4xx - 0, 5xx - 0
|
|
21
20
|
others - 0
|
|
22
|
-
Throughput:
|
|
21
|
+
Throughput: 5.75MB/s
|
|
23
22
|
```
|
|
24
23
|
|
|
25
24
|
Hono + `@hono/node-server`:
|
|
@@ -28,36 +27,25 @@ Hono + `@hono/node-server`:
|
|
|
28
27
|
$ bombardier -d 10s --fasthttp http://localhost:3000/
|
|
29
28
|
|
|
30
29
|
Statistics Avg Stdev Max
|
|
31
|
-
Reqs/sec
|
|
32
|
-
Latency
|
|
30
|
+
Reqs/sec 85405.51 7250.65 102658.51
|
|
31
|
+
Latency 1.46ms 1.00ms 149.95ms
|
|
33
32
|
HTTP codes:
|
|
34
|
-
1xx - 0, 2xx -
|
|
33
|
+
1xx - 0, 2xx - 854120, 3xx - 0, 4xx - 0, 5xx - 0
|
|
35
34
|
others - 0
|
|
36
|
-
Throughput:
|
|
35
|
+
Throughput: 18.49MB/s
|
|
37
36
|
```
|
|
38
37
|
|
|
39
38
|
## Requirements
|
|
40
39
|
|
|
41
|
-
It works on Node.js versions greater than
|
|
42
|
-
|
|
43
|
-
- 18.x => 18.14.1+
|
|
44
|
-
- 19.x => 19.7.0+
|
|
45
|
-
- 20.x => 20.0.0+
|
|
46
|
-
|
|
47
|
-
Essentially, you can simply use the latest version of each major release.
|
|
40
|
+
It works on Node.js versions greater than 20.x.
|
|
48
41
|
|
|
49
42
|
## Installation
|
|
50
43
|
|
|
51
|
-
You can install it from the npm registry
|
|
44
|
+
You can install it from the npm registry:
|
|
52
45
|
|
|
53
46
|
```sh
|
|
54
47
|
npm install @hono/node-server
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Or use `yarn`:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
yarn add @hono/node-server
|
|
48
|
+
pnpm add @hono/node-server
|
|
61
49
|
```
|
|
62
50
|
|
|
63
51
|
## Usage
|
|
@@ -77,6 +65,34 @@ serve(app, (info) => {
|
|
|
77
65
|
})
|
|
78
66
|
```
|
|
79
67
|
|
|
68
|
+
## WebSocket
|
|
69
|
+
|
|
70
|
+
You can upgrade WebSocket connections with `upgradeWebSocket` from `@hono/node-server`.
|
|
71
|
+
To enable this, install `ws` (and `@types/ws`) in your project, then create and provide a `WebSocketServer` as shown in the example below.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { serve, upgradeWebSocket } from '@hono/node-server'
|
|
75
|
+
import { WebSocketServer } from 'ws'
|
|
76
|
+
import { Hono } from 'hono'
|
|
77
|
+
|
|
78
|
+
const app = new Hono()
|
|
79
|
+
|
|
80
|
+
app.get(
|
|
81
|
+
'/ws',
|
|
82
|
+
upgradeWebSocket(() => ({
|
|
83
|
+
onMessage(event, ws) {
|
|
84
|
+
ws.send(event.data)
|
|
85
|
+
},
|
|
86
|
+
}))
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
const wss = new WebSocketServer({ noServer: true }) // important to create with `noServer: true`
|
|
90
|
+
serve({
|
|
91
|
+
fetch: app.fetch,
|
|
92
|
+
websocket: { server: wss },
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
80
96
|
For example, run it using `ts-node`. Then an HTTP server will be launched. The default port is `3000`.
|
|
81
97
|
|
|
82
98
|
```sh
|
|
@@ -138,6 +154,23 @@ serve({
|
|
|
138
154
|
})
|
|
139
155
|
```
|
|
140
156
|
|
|
157
|
+
### `websocket`
|
|
158
|
+
|
|
159
|
+
provide a websocket server to enable websocket support.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { serve, upgradeWebSocket } from '@hono/node-server'
|
|
163
|
+
import { WebSocketServer } from 'ws'
|
|
164
|
+
|
|
165
|
+
// ...
|
|
166
|
+
const wss = new WebSocketServer({ noServer: true })
|
|
167
|
+
|
|
168
|
+
serve({
|
|
169
|
+
fetch: app.fetch,
|
|
170
|
+
websocket: { server: wss },
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
141
174
|
## Middleware
|
|
142
175
|
|
|
143
176
|
Most built-in middleware also works with Node.js.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/conninfo.ts
|
|
4
|
+
/**
|
|
5
|
+
* ConnInfo Helper for Node.js
|
|
6
|
+
* @param c Context
|
|
7
|
+
* @returns ConnInfo
|
|
8
|
+
*/
|
|
9
|
+
const getConnInfo = (c) => {
|
|
10
|
+
const bindings = c.env.server ? c.env.server : c.env;
|
|
11
|
+
const address = bindings.incoming.socket.remoteAddress;
|
|
12
|
+
const port = bindings.incoming.socket.remotePort;
|
|
13
|
+
const family = bindings.incoming.socket.remoteFamily;
|
|
14
|
+
return { remote: {
|
|
15
|
+
address,
|
|
16
|
+
port,
|
|
17
|
+
addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
|
|
18
|
+
} };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.getConnInfo = getConnInfo;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { GetConnInfo } from
|
|
1
|
+
import { GetConnInfo } from "hono/conninfo";
|
|
2
2
|
|
|
3
|
+
//#region src/conninfo.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* ConnInfo Helper for Node.js
|
|
5
6
|
* @param c Context
|
|
6
7
|
* @returns ConnInfo
|
|
7
8
|
*/
|
|
8
9
|
declare const getConnInfo: GetConnInfo;
|
|
9
|
-
|
|
10
|
-
export { getConnInfo };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getConnInfo };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { GetConnInfo } from
|
|
1
|
+
import { GetConnInfo } from "hono/conninfo";
|
|
2
2
|
|
|
3
|
+
//#region src/conninfo.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* ConnInfo Helper for Node.js
|
|
5
6
|
* @param c Context
|
|
6
7
|
* @returns ConnInfo
|
|
7
8
|
*/
|
|
8
9
|
declare const getConnInfo: GetConnInfo;
|
|
9
|
-
|
|
10
|
-
export { getConnInfo };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getConnInfo };
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
//#region src/conninfo.ts
|
|
2
|
+
/**
|
|
3
|
+
* ConnInfo Helper for Node.js
|
|
4
|
+
* @param c Context
|
|
5
|
+
* @returns ConnInfo
|
|
6
|
+
*/
|
|
7
|
+
const getConnInfo = (c) => {
|
|
8
|
+
const bindings = c.env.server ? c.env.server : c.env;
|
|
9
|
+
const address = bindings.incoming.socket.remoteAddress;
|
|
10
|
+
const port = bindings.incoming.socket.remotePort;
|
|
11
|
+
const family = bindings.incoming.socket.remoteFamily;
|
|
12
|
+
return { remote: {
|
|
13
|
+
address,
|
|
14
|
+
port,
|
|
15
|
+
addressType: family === "IPv4" ? "IPv4" : family === "IPv6" ? "IPv6" : void 0
|
|
16
|
+
} };
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getConnInfo };
|