@sockethub/server 5.0.0-alpha.14 → 5.0.0-alpha.16
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/dist/config-schema.d.ts +58 -0
- package/dist/cors.d.ts +30 -0
- package/dist/http/actions.d.ts +0 -8
- package/dist/index.js +154831 -154598
- package/dist/index.js.map +45 -41
- package/dist/platform-instance.d.ts +10 -1
- package/dist/platform.js +284 -229
- package/dist/platform.js.map +8 -6
- package/dist/process-manager.d.ts +10 -1
- package/dist/write-config.d.ts +18 -0
- package/package.json +13 -13
- package/res/sockethub-client.js +91 -8
- package/res/sockethub-client.min.js +19 -19
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import convict from "convict";
|
|
2
|
+
/**
|
|
3
|
+
* The convict configuration schema, derived from the canonical JSON schema in
|
|
4
|
+
* `@sockethub/schemas` so defaults, types and enums have a single source of
|
|
5
|
+
* truth. This module only layers on the server-specific concerns the JSON
|
|
6
|
+
* schema cannot express: environment variable and command-line argument
|
|
7
|
+
* bindings, and convict format refinements ("nat", "port").
|
|
8
|
+
*/
|
|
9
|
+
type JsonSchemaNode = {
|
|
10
|
+
type?: string | Array<string>;
|
|
11
|
+
enum?: Array<unknown>;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
description?: string;
|
|
14
|
+
properties?: Record<string, JsonSchemaNode>;
|
|
15
|
+
};
|
|
16
|
+
type OverlayEntry = {
|
|
17
|
+
/** Convict format override (e.g. "nat", "port", "*"). */
|
|
18
|
+
format?: unknown;
|
|
19
|
+
/** Environment variable bound to this key. */
|
|
20
|
+
env?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Treat an empty-string value of `env` as unset so it falls back to the
|
|
23
|
+
* config file / default, preserving the historical `process.env.X || ...`
|
|
24
|
+
* behavior (convict would otherwise apply the empty string as an
|
|
25
|
+
* override). Deliberately NOT set for SOCKETHUB_CORS_ORIGIN, where an
|
|
26
|
+
* empty string must stay applied so CORS fails closed.
|
|
27
|
+
*/
|
|
28
|
+
emptyEnvIsUnset?: boolean;
|
|
29
|
+
/** Command-line argument bound to this key. */
|
|
30
|
+
arg?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Treat this object node as a single convict leaf (validated as a whole
|
|
33
|
+
* by the JSON schema pass) instead of recursing into its properties.
|
|
34
|
+
*/
|
|
35
|
+
leaf?: boolean;
|
|
36
|
+
/** Default for leaves the JSON schema declares no default for. */
|
|
37
|
+
default?: unknown;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Build the convict schema definition from a JSON schema plus a server
|
|
41
|
+
* overlay. Exported for tests; production code uses {@link buildSchema}.
|
|
42
|
+
* Throws when an overlay entry references a path the JSON schema does not
|
|
43
|
+
* declare, or when a leaf ends up without a default.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildConvictDefinition(jsonSchema: JsonSchemaNode, overlays: Record<string, OverlayEntry>): Record<string, unknown>;
|
|
46
|
+
export declare function buildSchema(): convict.Config<Record<string, unknown>>;
|
|
47
|
+
/**
|
|
48
|
+
* Environment variables where an empty-string value means "unset" rather
|
|
49
|
+
* than an override (historical `process.env.X || <config>` semantics).
|
|
50
|
+
*/
|
|
51
|
+
export declare const EMPTY_ENV_IS_UNSET_VARS: ReadonlyArray<string>;
|
|
52
|
+
/**
|
|
53
|
+
* The fully materialized default configuration tree, straight from the JSON
|
|
54
|
+
* schema (no environment or command-line overrides applied). The `$schema`
|
|
55
|
+
* key is omitted; callers stamp their own reference.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getDefaultConfig(): Record<string, unknown>;
|
|
58
|
+
export {};
|
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;
|
package/dist/http/actions.d.ts
CHANGED
|
@@ -24,14 +24,6 @@ interface HttpActionsDependencies {
|
|
|
24
24
|
createCredentialsStore?: (parentId: string, sessionId: string, secret: string, redisConfig: RedisConfig) => CredentialsStoreInterface;
|
|
25
25
|
getIdempotencyRedisConnection?: () => ReturnType<typeof getIdempotencyRedisConnection>;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Resolve the `Access-Control-Allow-Origin` value for a request, using the same
|
|
29
|
-
* `sockethub:cors:origin` config that governs socket.io. Returns `"*"` when any
|
|
30
|
-
* origin is allowed, the request's own origin when it is in a configured
|
|
31
|
-
* allow-list, or `undefined` when the origin is not allowed (the browser then
|
|
32
|
-
* blocks the response).
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveAllowedOrigin(configuredOrigin: string | undefined, requestOrigin: string | undefined): string | undefined;
|
|
35
27
|
declare function getIdempotencyRedisConnection(): import("ioredis").default;
|
|
36
28
|
export declare function registerHttpActionsRoutes(app: Express, options: HttpActionsOptions, deps?: HttpActionsDependencies): void;
|
|
37
29
|
export {};
|