@sockethub/server 5.0.0-alpha.13 → 5.0.0-alpha.15

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/README.md CHANGED
@@ -87,6 +87,32 @@ Default: `localhost`
87
87
  Overrides `REDIS_HOST` and `REDIS_PORT`, can specify a full redis connect URL
88
88
  (e.g. `redis://username:password@host:port`)
89
89
 
90
+ #### HTTP Actions
91
+
92
+ Enable the HTTP streaming endpoint and tune limits:
93
+
94
+ - SOCKETHUB_HTTP_ACTIONS_ENABLED
95
+ - SOCKETHUB_HTTP_ACTIONS_PATH
96
+ - SOCKETHUB_HTTP_ACTIONS_REQUIRE_REQUEST_ID
97
+ - SOCKETHUB_HTTP_ACTIONS_MAX_MESSAGES_PER_REQUEST
98
+ - SOCKETHUB_HTTP_ACTIONS_MAX_PAYLOAD_BYTES
99
+ - SOCKETHUB_HTTP_ACTIONS_IDEMPOTENCY_TTL_MS
100
+ - SOCKETHUB_HTTP_ACTIONS_REQUEST_TIMEOUT_MS
101
+ - SOCKETHUB_HTTP_ACTIONS_IDLE_TIMEOUT_MS
102
+
103
+ Request handling stays on Sockethub's existing core path:
104
+
105
+ - validate message shape
106
+ - store credentials (when applicable)
107
+ - enqueue to Redis
108
+ - process in platform child process
109
+ - stream each result line back to the HTTP client
110
+
111
+ HTTP actions only change transport and replay behavior. They do not create a
112
+ separate platform routing model.
113
+
114
+ See [`docs/configuration.md`](../../docs/configuration.md) for details and examples.
115
+
90
116
  #### Sentry Configuration
91
117
 
92
118
  Sentry error reporting can be configured via environment variable or config file:
package/dist/cors.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Parse the `sockethub:cors:origin` config value into either `"*"` (any
3
+ * origin) or a normalized origin allow-list. Both the socket.io listener and
4
+ * the HTTP actions routes resolve their CORS policy through this single
5
+ * parser so the two transports can never drift apart.
6
+ *
7
+ * Browsers serialize the `Origin` request header as a lowercase
8
+ * `scheme://host[:port]` with default ports omitted and no trailing slash or
9
+ * path. Configured entries are normalized to that same serialization before
10
+ * matching, so values like `https://App.example.com/` still match what the
11
+ * browser actually sends. Entries that cannot yield a usable origin are
12
+ * dropped with a warning rather than left in the list where they would
13
+ * silently never match.
14
+ *
15
+ * A restrictive config that yields no valid origins returns an empty list
16
+ * (blocking all cross-origin requests) instead of falling back to `"*"`:
17
+ * when an operator attempted to restrict origins, failing closed is the only
18
+ * safe interpretation.
19
+ */
20
+ export declare function parseCorsOrigins(configured: unknown): "*" | Array<string>;
21
+ /**
22
+ * Resolve the `Access-Control-Allow-Origin` value for a request against an
23
+ * allow-list already parsed by `parseCorsOrigins`. Returns `"*"` when any
24
+ * origin is allowed, the request's own origin when it is in the allow-list,
25
+ * or `undefined` when it is not allowed (the browser then blocks the
26
+ * response). The request origin is run through the same URL normalization as
27
+ * the configured entries, so matching never depends on the client sending
28
+ * the canonical serialization.
29
+ */
30
+ export declare function resolveAllowedOrigin(allowedOrigins: "*" | Array<string>, requestOrigin: string | undefined): string | undefined;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * HTTP actions endpoint.
3
+ *
4
+ * Accepts ActivityStreams via POST, streams NDJSON results as jobs complete,
5
+ * and optionally caches results in Redis for idempotent replay + GET retrieval.
6
+ */
7
+ import type { RedisConfig } from "@sockethub/data-layer";
8
+ import { type CredentialsStoreInterface } from "@sockethub/data-layer";
9
+ import { type Express, type RequestHandler } from "express";
10
+ import { createMessageHandlers } from "../message-handlers.js";
11
+ import type ProcessManager from "../process-manager.js";
12
+ interface HttpActionsOptions {
13
+ processManager: ProcessManager;
14
+ parentId: string;
15
+ parentSecret1: string;
16
+ }
17
+ interface HttpActionsDependencies {
18
+ getConfig?: (key: string) => unknown;
19
+ createRateLimiter?: (opts: {
20
+ windowMs: number;
21
+ max: number;
22
+ }) => RequestHandler;
23
+ createMessageHandlers?: typeof createMessageHandlers;
24
+ createCredentialsStore?: (parentId: string, sessionId: string, secret: string, redisConfig: RedisConfig) => CredentialsStoreInterface;
25
+ getIdempotencyRedisConnection?: () => ReturnType<typeof getIdempotencyRedisConnection>;
26
+ }
27
+ declare function getIdempotencyRedisConnection(): import("ioredis").default;
28
+ export declare function registerHttpActionsRoutes(app: Express, options: HttpActionsOptions, deps?: HttpActionsDependencies): void;
29
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function registerHttpSession(platformId: string): void;
2
+ export declare function unregisterHttpSession(platformId: string): void;
3
+ export declare function hasHttpSessions(platformId: string): boolean;