@powerhousedao/switchboard 6.2.3 → 6.3.0-dev.2
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/.tsbuild/test/ai-gateway.test.d.ts +2 -0
- package/.tsbuild/test/ai-gateway.test.d.ts.map +1 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts +2 -0
- package/.tsbuild/test/attachments/reserve-metadata-parity.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts +2 -0
- package/.tsbuild/test/boot-auth-config.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-desktop-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts +2 -0
- package/.tsbuild/test/boot-env-isolation.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-helpers.d.ts +5 -0
- package/.tsbuild/test/boot-helpers.d.ts.map +1 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts +2 -0
- package/.tsbuild/test/boot-inspection-enabled.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts +2 -0
- package/.tsbuild/test/boot-mcp-auth.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts +2 -0
- package/.tsbuild/test/boot-port-zero.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts +2 -0
- package/.tsbuild/test/boot-preconditions.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-privacy.test.d.ts +2 -0
- package/.tsbuild/test/boot-privacy.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts +2 -0
- package/.tsbuild/test/boot-ready-drives.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts +2 -0
- package/.tsbuild/test/boot-undo-v3-flag.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-conflict.test.d.ts.map +1 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts +2 -0
- package/.tsbuild/test/boot-workflow-singleton-retry.test.d.ts.map +1 -0
- package/.tsbuild/test/config-from-env.test.d.ts +2 -0
- package/.tsbuild/test/config-from-env.test.d.ts.map +1 -0
- package/.tsbuild/test/config-merge.test.d.ts +2 -0
- package/.tsbuild/test/config-merge.test.d.ts.map +1 -0
- package/.tsbuild/test/config-schema.test.d.ts +2 -0
- package/.tsbuild/test/config-schema.test.d.ts.map +1 -0
- package/.tsbuild/test/default-composition.test.d.ts +2 -0
- package/.tsbuild/test/default-composition.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-protocol-versions.test.d.ts.map +1 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts +2 -0
- package/.tsbuild/test/default-drive-slug.test.d.ts.map +1 -0
- package/.tsbuild/test/delegated-publish.test.d.ts +2 -0
- package/.tsbuild/test/delegated-publish.test.d.ts.map +1 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts +2 -0
- package/.tsbuild/test/durable-node-fs-pg16.test.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts +13 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts +3 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/index.d.ts.map +1 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts +7 -0
- package/.tsbuild/test/fixtures/mixed-subgraphs/subgraphs/tally/index.d.ts.map +1 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts +2 -0
- package/.tsbuild/test/inspection-throttle.test.d.ts.map +1 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts +2 -0
- package/.tsbuild/test/keyframe-reclaim-store.test.d.ts.map +1 -0
- package/.tsbuild/test/observability-signals.test.d.ts +2 -0
- package/.tsbuild/test/observability-signals.test.d.ts.map +1 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts +2 -0
- package/.tsbuild/test/permissions-backfill.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts +2 -0
- package/.tsbuild/test/pglite-preflight.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts +2 -0
- package/.tsbuild/test/pglite-storage-dirs.test.d.ts.map +1 -0
- package/.tsbuild/test/pglite-store.test.d.ts +2 -0
- package/.tsbuild/test/pglite-store.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts +2 -0
- package/.tsbuild/test/plugin-config-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/plugin-presence.test.d.ts +2 -0
- package/.tsbuild/test/plugin-presence.test.d.ts.map +1 -0
- package/.tsbuild/test/port-probe.test.d.ts +2 -0
- package/.tsbuild/test/port-probe.test.d.ts.map +1 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts +2 -0
- package/.tsbuild/test/processor-timing-log.test.d.ts.map +1 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts +2 -0
- package/.tsbuild/test/renown-storage-path.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas-mixed-package.test.d.ts.map +1 -0
- package/.tsbuild/test/served-schemas.test.d.ts +2 -0
- package/.tsbuild/test/served-schemas.test.d.ts.map +1 -0
- package/.tsbuild/test/shutdown.test.d.ts +2 -0
- package/.tsbuild/test/shutdown.test.d.ts.map +1 -0
- package/.tsbuild/test/snapshot-writer.d.ts +18 -0
- package/.tsbuild/test/snapshot-writer.d.ts.map +1 -0
- package/.tsbuild/test/store-lock.test.d.ts +2 -0
- package/.tsbuild/test/store-lock.test.d.ts.map +1 -0
- package/.tsbuild/test/two-switchboards.test.d.ts +2 -0
- package/.tsbuild/test/two-switchboards.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts +2 -0
- package/.tsbuild/test/workflow/oauth-apps-config.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts +2 -0
- package/.tsbuild/test/workflow/runtime-host.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-routes.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts +2 -0
- package/.tsbuild/test/workflow/waitpoint-runtime.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-access.test.d.ts.map +1 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts +2 -0
- package/.tsbuild/test/workflow-reactor-enforcement.test.d.ts.map +1 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts +2 -0
- package/.tsbuild/test/workflows-plugin-config.test.d.ts.map +1 -0
- package/.tsbuild/tsconfig.tsbuildinfo +1 -1
- package/Auth.md +108 -2
- package/CHANGELOG.md +1066 -2
- package/README.md +69 -24
- package/dist/boot.d.mts +46 -0
- package/dist/boot.d.mts.map +1 -0
- package/dist/boot.mjs +67 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/config/from-env.d.mts +15 -0
- package/dist/config/from-env.d.mts.map +1 -0
- package/dist/config/from-env.mjs +4 -0
- package/dist/config/schema.d.mts +3 -0
- package/dist/config/schema.mjs +4 -0
- package/dist/from-env-DKK_wPrO.mjs +497 -0
- package/dist/from-env-DKK_wPrO.mjs.map +1 -0
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +40 -219
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-VW52B8KD.mjs +32 -0
- package/dist/mcp-VW52B8KD.mjs.map +1 -0
- package/dist/migrate.mjs +5 -4
- package/dist/migrate.mjs.map +1 -1
- package/dist/observability-CldagyT_.mjs +224 -0
- package/dist/observability-CldagyT_.mjs.map +1 -0
- package/dist/observability.d.mts +30 -0
- package/dist/observability.d.mts.map +1 -0
- package/dist/observability.mjs +4 -0
- package/dist/plugin-host-tTjDTNz0.d.mts +46 -0
- package/dist/plugin-host-tTjDTNz0.d.mts.map +1 -0
- package/dist/plugins/ai.d.mts +37 -0
- package/dist/plugins/ai.d.mts.map +1 -0
- package/dist/plugins/ai.mjs +400 -0
- package/dist/plugins/ai.mjs.map +1 -0
- package/dist/plugins/attachments.d.mts +33 -0
- package/dist/plugins/attachments.d.mts.map +1 -0
- package/dist/plugins/attachments.mjs +4 -0
- package/dist/plugins/mcp.d.mts +31 -0
- package/dist/plugins/mcp.d.mts.map +1 -0
- package/dist/plugins/mcp.mjs +4 -0
- package/dist/plugins/privacy.d.mts +22 -0
- package/dist/plugins/privacy.d.mts.map +1 -0
- package/dist/plugins/privacy.mjs +4 -0
- package/dist/plugins/workflows.d.mts +80 -0
- package/dist/plugins/workflows.d.mts.map +1 -0
- package/dist/plugins/workflows.mjs +4 -0
- package/dist/postgres-url-DTDhBjXX.mjs +11 -0
- package/dist/postgres-url-DTDhBjXX.mjs.map +1 -0
- package/dist/privacy-HQnhqf2H.mjs +91 -0
- package/dist/privacy-HQnhqf2H.mjs.map +1 -0
- package/dist/privacy-UodgY0i_.mjs +44 -0
- package/dist/privacy-UodgY0i_.mjs.map +1 -0
- package/dist/renown-layers-DmbWLt46.mjs +42 -0
- package/dist/renown-layers-DmbWLt46.mjs.map +1 -0
- package/dist/schema-BJ-OFAox.mjs +359 -0
- package/dist/schema-BJ-OFAox.mjs.map +1 -0
- package/dist/schema-w1lShimw.d.mts +258 -0
- package/dist/schema-w1lShimw.d.mts.map +1 -0
- package/dist/server-BS-PFzoK.mjs +2752 -0
- package/dist/server-BS-PFzoK.mjs.map +1 -0
- package/dist/server.d.mts +94 -228
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +5 -4
- package/dist/types-Bk4T4D9F.d.mts +318 -0
- package/dist/types-Bk4T4D9F.d.mts.map +1 -0
- package/dist/utils-Cm0TE6dP.mjs +148 -0
- package/dist/utils-Cm0TE6dP.mjs.map +1 -0
- package/dist/utils.d.mts +29 -3
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +5 -4
- package/dist/worker-pool-gyxJnCxA.mjs +304 -0
- package/dist/worker-pool-gyxJnCxA.mjs.map +1 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts +33 -0
- package/dist/workflow-runtime-CF5pc8mt.d.mts.map +1 -0
- package/dist/workflows-mdYUh3Us.mjs +1947 -0
- package/dist/workflows-mdYUh3Us.mjs.map +1 -0
- package/package.json +86 -24
- package/scripts/install-packages.sh +0 -0
- package/test/ai-gateway.test.ts +612 -0
- package/test/attachment-reference-read-model.test.ts +28 -20
- package/test/attachments/byte-grants.test.ts +4 -1
- package/test/attachments/download-target.test.ts +36 -20
- package/test/attachments/index.test.ts +13 -1
- package/test/attachments/reserve-metadata-parity.test.ts +96 -0
- package/test/attachments/routes-integration.test.ts +1 -0
- package/test/attachments/routes.test.ts +132 -12
- package/test/attachments/service-config.test.ts +28 -16
- package/test/boot-auth-config.test.ts +146 -0
- package/test/boot-create-signature-policy.test.ts +15 -13
- package/test/boot-desktop-auth.test.ts +278 -0
- package/test/boot-env-isolation.test.ts +26 -0
- package/test/boot-helpers.ts +19 -0
- package/test/boot-inspection-enabled.test.ts +140 -0
- package/test/boot-mcp-auth.test.ts +449 -0
- package/test/boot-mcp-enabled.test.ts +27 -27
- package/test/boot-port-zero.test.ts +101 -0
- package/test/boot-preconditions.test.ts +213 -0
- package/test/boot-privacy.test.ts +232 -0
- package/test/boot-ready-drives.test.ts +141 -0
- package/test/boot-undo-v3-flag.test.ts +120 -0
- package/test/boot-unsupported-stored-documents.test.ts +23 -19
- package/test/boot-without-renown.test.ts +11 -9
- package/test/boot-without-require-signatures.test.ts +12 -10
- package/test/boot-worker-trust-policy.test.ts +11 -10
- package/test/boot-workflow-singleton-conflict.test.ts +109 -0
- package/test/boot-workflow-singleton-retry.test.ts +122 -0
- package/test/config-from-env.test.ts +968 -0
- package/test/config-merge.test.ts +351 -0
- package/test/config-schema.test.ts +183 -0
- package/test/default-composition.test.ts +290 -0
- package/test/default-drive-protocol-versions.test.ts +79 -0
- package/test/default-drive-slug.test.ts +265 -0
- package/test/delegated-publish.test.ts +435 -0
- package/test/durable-node-fs-pg16.test.ts +80 -0
- package/test/fatal-shutdown.test.ts +104 -1
- package/test/fixtures/mixed-subgraphs/subgraphs/greetings/index.ts +16 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/index.ts +3 -0
- package/test/fixtures/mixed-subgraphs/subgraphs/tally/index.ts +73 -0
- package/test/goldens/packages.graphql +797 -0
- package/test/goldens/privacy.graphql +853 -0
- package/test/goldens/reactor-drive-nodes.graphql +827 -0
- package/test/goldens/resolvers.json +327 -0
- package/test/goldens/supergraph.graphql +5918 -0
- package/test/goldens/workflow-runtime.graphql +1548 -0
- package/test/inspection-throttle.test.ts +23 -0
- package/test/keyframe-reclaim-store.test.ts +156 -0
- package/test/observability-signals.test.ts +131 -0
- package/test/permissions-backfill.test.ts +486 -0
- package/test/pglite-dialect.test.ts +237 -2
- package/test/pglite-preflight.test.ts +313 -0
- package/test/pglite-storage-dirs.test.ts +113 -0
- package/test/pglite-store.test.ts +441 -0
- package/test/pglite-version.test.ts +9 -1
- package/test/plugin-config-schemas.test.ts +83 -0
- package/test/plugin-presence.test.ts +262 -0
- package/test/port-probe.test.ts +45 -0
- package/test/processor-timing-log.test.ts +109 -0
- package/test/reactor-feature-flags.test.ts +20 -0
- package/test/redact-webhook-path.test.ts +9 -0
- package/test/renown-storage-path.test.ts +40 -0
- package/test/renown-trust-policy.test.ts +7 -9
- package/test/served-schemas-mixed-package.test.ts +251 -0
- package/test/served-schemas.test.ts +134 -0
- package/test/shutdown.test.ts +278 -0
- package/test/snapshot-writer.ts +94 -0
- package/test/store-lock.test.ts +65 -0
- package/test/two-switchboards.test.ts +146 -0
- package/test/worker-pool.test.ts +27 -1
- package/test/workflow/oauth-apps-config.test.ts +66 -0
- package/test/workflow/oauth.test.ts +82 -10
- package/test/workflow/resolvers.test.ts +230 -38
- package/test/workflow/runtime-host.test.ts +19 -0
- package/test/workflow/waitpoint-routes.test.ts +306 -0
- package/test/workflow/waitpoint-runtime.test.ts +204 -0
- package/test/workflow/webhook-trigger-test.test.ts +8 -0
- package/test/workflow-reactor-access.test.ts +384 -0
- package/test/workflow-reactor-enforcement.test.ts +808 -0
- package/test/workflow-read-gate.test.ts +128 -60
- package/test/workflow-runtime.test.ts +1005 -237
- package/test/workflows-plugin-config.test.ts +77 -0
- package/tsconfig.json +5 -2
- package/tsdown.config.ts +12 -0
- package/vitest.config.ts +66 -1
- package/.tsbuild/test/mcp-flag.test.d.ts +0 -2
- package/.tsbuild/test/mcp-flag.test.d.ts.map +0 -1
- package/dist/server-sQoWp21G.mjs +0 -2939
- package/dist/server-sQoWp21G.mjs.map +0 -1
- package/dist/utils-uaBlzyjS.mjs +0 -86
- package/dist/utils-uaBlzyjS.mjs.map +0 -1
- package/test/mcp-flag.test.ts +0 -56
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t as SwitchboardHostContext } from "../plugin-host-tTjDTNz0.mjs";
|
|
2
|
+
import { t as ComposedWorkflowRuntime } from "../workflow-runtime-CF5pc8mt.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { HostPlugin } from "@powerhousedao/host-core";
|
|
5
|
+
//#region src/plugins/workflows.d.mts
|
|
6
|
+
/**
|
|
7
|
+
* R2.5 — the workflows subsystem as a built-in plugin. Presence is activation
|
|
8
|
+
* (an explicit options.workflows.enabled === false still wins, mirroring the
|
|
9
|
+
* mcp carve, and PH_WORKFLOWS_ENABLED=false is one). Turning workflows on from
|
|
10
|
+
* the env or the config file works without a declared composition only: the
|
|
11
|
+
* default composition then lists this plugin.
|
|
12
|
+
*
|
|
13
|
+
* The plugin also DECLARES the drive the runtime serves — the Workflows drive
|
|
14
|
+
* that opens in Workflow Studio — as a drive contribution (workflow-plugins
|
|
15
|
+
* plan). The switchboard runner merges it into the host's drive plan (a host
|
|
16
|
+
* declaration with the same slug wins), seeds it, reports it on the handle so
|
|
17
|
+
* a compound can hand it to its connect member, and `--explain drives` lists
|
|
18
|
+
* it with this plugin as provenance. Before, the runner seeded that drive as
|
|
19
|
+
* an implicit side effect of the workflows flag; now the entry's `config.drive`
|
|
20
|
+
* names it (`drive: false` serves the runtime without seeding a drive).
|
|
21
|
+
*
|
|
22
|
+
* The orchestration (compose, singleton-conflict retry, subgraph
|
|
23
|
+
* registration, start, inspection fact) moves here VERBATIM from the inline
|
|
24
|
+
* block; the dependency-heavy wiring closures (composeWorkflows,
|
|
25
|
+
* registerWorkflowSubgraph) stay in server.mts and travel via ctx — same
|
|
26
|
+
* realm, code moved not redesigned. Carve-map constraints preserved: the
|
|
27
|
+
* retry path's onComposed registers + updates the router ITSELF (it may fire
|
|
28
|
+
* after the readiness drain); teardown stops retry then runtime, and runs
|
|
29
|
+
* AFTER privacy's (sequential onShutdown, registration order).
|
|
30
|
+
*/
|
|
31
|
+
export interface WorkflowsOrchestration {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
composeWorkflows: () => Promise<ComposedWorkflowRuntime>;
|
|
34
|
+
registerWorkflowSubgraph: (composed: ComposedWorkflowRuntime) => Promise<void>;
|
|
35
|
+
updateRouter: () => Promise<void>;
|
|
36
|
+
reportMountFailure: (error: unknown) => void;
|
|
37
|
+
setWorkflowsFact: () => void;
|
|
38
|
+
}
|
|
39
|
+
/** The drive app Workflow Studio registers under (packages/workflow). */
|
|
40
|
+
export declare const WORKFLOW_STUDIO_EDITOR_ID = "workflow-studio";
|
|
41
|
+
/** The drive the plugin seeds unless the entry says otherwise. */
|
|
42
|
+
export declare const DEFAULT_WORKFLOWS_DRIVE: {
|
|
43
|
+
readonly slug: "workflows";
|
|
44
|
+
readonly name: "Workflows";
|
|
45
|
+
};
|
|
46
|
+
export declare const workflowsPluginConfigSchema: z.ZodObject<{
|
|
47
|
+
drive: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
48
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
49
|
+
name: z.ZodOptional<z.ZodString>;
|
|
50
|
+
id: z.ZodOptional<z.ZodString>;
|
|
51
|
+
projectHash: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodLiteral<"id">]>>;
|
|
52
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strict>, z.ZodLiteral<false>]>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export type WorkflowsPluginConfig = z.infer<typeof workflowsPluginConfigSchema>;
|
|
56
|
+
/** What a host.js entry writes (typed-host-configs 1.4). Kept a type alias,
|
|
57
|
+
* not an interface, so it stays assignable to the runtime `PluginEntryData`
|
|
58
|
+
* config record. */
|
|
59
|
+
export type WorkflowsPluginConfigInput = z.input<typeof workflowsPluginConfigSchema>;
|
|
60
|
+
declare global {
|
|
61
|
+
interface PHPluginConfigs {
|
|
62
|
+
"@powerhousedao/switchboard/plugins/workflows": WorkflowsPluginConfigInput;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export type WorkflowsPlugin = HostPlugin<{
|
|
66
|
+
transformServerOptions: (options: Record<string, unknown>, ctx: SwitchboardHostContext) => Record<string, unknown>;
|
|
67
|
+
onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;
|
|
68
|
+
onShutdown: (ctx: SwitchboardHostContext) => Promise<void>;
|
|
69
|
+
}, WorkflowsPluginConfig>;
|
|
70
|
+
/** The drive declaration the entry config amounts to (host-core's
|
|
71
|
+
* DriveDeclaration shape; kept structural here to avoid the import cycle the
|
|
72
|
+
* Contributions type documents). `undefined` when `drive: false`. */
|
|
73
|
+
export declare function workflowsDriveDeclaration(config: WorkflowsPluginConfig): Record<string, unknown> | undefined;
|
|
74
|
+
export declare function createWorkflowsPlugin(rawConfig?: unknown): WorkflowsPlugin;
|
|
75
|
+
/** The default-config instance: the built-in composition's entry. */
|
|
76
|
+
export declare const workflowsPlugin: WorkflowsPlugin;
|
|
77
|
+
//#endregion
|
|
78
|
+
export { createWorkflowsPlugin as default };
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=workflows.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows.d.mts","names":[],"sources":["../../src/plugins/workflows.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCiB;EACf;EACA,wBAAwB,QAAQ;EAChC,2BACE,UAAU,4BACP;EACL,oBAAoB;EACpB,qBAAqB;EACrB;;;qBAQW;;qBAGA;WACX;WACA;;qBAgBW,6BAA2B,EAAA;;;;;;;;GAGtC,EAAA,KAAA;YAEU,wBAAwB,EAAE,aAAa;;;;YAKvC,6BAA6B,EAAE,aAClC;QAGD;YACI;IACR,gDAAgD;;;YAIxC,kBAAkB;EAE1B,yBACE,SAAS,yBACT,KAAK,2BACF;EACL,yBAAyB,KAAK,2BAA2B;EACzD,aAAa,KAAK,2BAA2B;GAE/C;;;;wBAMc,0BACd,QAAQ,wBACP;wBAca,sBACd,sBACC;;qBA+FU,iBAAiB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as workflowsPlugin, i as workflowsDriveDeclaration, n as WORKFLOW_STUDIO_EDITOR_ID, o as workflowsPluginConfigSchema, r as createWorkflowsPlugin, t as DEFAULT_WORKFLOWS_DRIVE } from "../workflows-mdYUh3Us.mjs";
|
|
2
|
+
export { DEFAULT_WORKFLOWS_DRIVE, WORKFLOW_STUDIO_EDITOR_ID, createWorkflowsPlugin, createWorkflowsPlugin as default, workflowsDriveDeclaration, workflowsPlugin, workflowsPluginConfigSchema };
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0190a089-9d76-502d-a0ae-fb5b0a771426")}catch(e){}}();
|
|
4
|
+
//# debugId=0190a089-9d76-502d-a0ae-fb5b0a771426
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/postgres-url.mts
|
|
2
|
+
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="62405293-bd24-5a14-8f37-5ecc6739f9c6")}catch(e){}}();
|
|
4
|
+
function isPostgresUrl(url) {
|
|
5
|
+
return url.startsWith("postgresql") || url.startsWith("postgres");
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isPostgresUrl as t };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=postgres-url-DTDhBjXX.mjs.map
|
|
11
|
+
//# debugId=62405293-bd24-5a14-8f37-5ecc6739f9c6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-url-DTDhBjXX.mjs","sources":["../src/postgres-url.mts"],"sourcesContent":["export function isPostgresUrl(url: string) {\n return url.startsWith(\"postgresql\") || url.startsWith(\"postgres\");\n}\n"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,KAAa;CACzC,OAAO,IAAI,WAAW,YAAY,KAAK,IAAI,WAAW,UAAU;AAClE","debug_id":"62405293-bd24-5a14-8f37-5ecc6739f9c6"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5304d939-0e11-5ae3-b9e1-046bd0759d36")}catch(e){}}();
|
|
3
|
+
import { AuthorizationPolicy, PrivacyPermissionAdapter } from "@powerhousedao/reactor-api";
|
|
4
|
+
import { DisclosureService, MIN_DEPLOYMENT_SECRET_BYTES, createModuleErasure, createPrivacySubgraph, registerSubjectDocumentsReadModel } from "@powerhousedao/reactor-privacy";
|
|
5
|
+
//#region src/privacy.mts
|
|
6
|
+
const DAY_MS = 864e5;
|
|
7
|
+
/** Enabling privacy on a switchboard that cannot run it safely. */
|
|
8
|
+
var PrivacyBootError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "PrivacyBootError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function positive(env, name, unitMs) {
|
|
15
|
+
const raw = env[name];
|
|
16
|
+
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
17
|
+
const value = Number(raw);
|
|
18
|
+
if (!Number.isFinite(value) || value <= 0) throw new PrivacyBootError(`${name} must be a positive number, got "${raw}"`);
|
|
19
|
+
return value * unitMs;
|
|
20
|
+
}
|
|
21
|
+
function resolvePrivacy(options, env) {
|
|
22
|
+
if (!(options?.enabled ?? env.PH_PRIVACY_ENABLED === "true")) return { enabled: false };
|
|
23
|
+
const deploymentSecret = options?.deploymentSecret ?? env.PH_PRIVACY_DEPLOYMENT_SECRET;
|
|
24
|
+
if (!deploymentSecret || Buffer.byteLength(deploymentSecret, "utf8") < MIN_DEPLOYMENT_SECRET_BYTES) throw new PrivacyBootError(`PH_PRIVACY_ENABLED needs PH_PRIVACY_DEPLOYMENT_SECRET of at least ${MIN_DEPLOYMENT_SECRET_BYTES} bytes`);
|
|
25
|
+
const fromEnv = privacyTimingsFromEnv(env);
|
|
26
|
+
return {
|
|
27
|
+
enabled: true,
|
|
28
|
+
deploymentSecret,
|
|
29
|
+
intervalMs: options?.intervalMs ?? fromEnv.intervalMs,
|
|
30
|
+
deadlineMs: options?.deadlineMs ?? fromEnv.deadlineMs,
|
|
31
|
+
markerGraceMs: options?.markerGraceMs ?? fromEnv.markerGraceMs,
|
|
32
|
+
purgeTimeoutMs: options?.purgeTimeoutMs ?? fromEnv.purgeTimeoutMs
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The erasure timings from PH_PRIVACY_*, in ms; each unset one is undefined. */
|
|
36
|
+
function privacyTimingsFromEnv(env) {
|
|
37
|
+
return {
|
|
38
|
+
intervalMs: positive(env, "PH_PRIVACY_INTERVAL_MS", 1),
|
|
39
|
+
deadlineMs: positive(env, "PH_PRIVACY_DEADLINE_DAYS", DAY_MS),
|
|
40
|
+
markerGraceMs: positive(env, "PH_PRIVACY_MARKER_GRACE_DAYS", DAY_MS),
|
|
41
|
+
purgeTimeoutMs: positive(env, "PH_PRIVACY_PURGE_TIMEOUT_MINUTES", 6e4)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Subject index, erasure scheduler and admin subgraph on a built reactor. */
|
|
45
|
+
async function startPrivacy(deps) {
|
|
46
|
+
const { config, reactorModule, authorizationService } = deps;
|
|
47
|
+
if (authorizationService.config.policy === AuthorizationPolicy.OPEN) throw new PrivacyBootError("PH_PRIVACY_ENABLED is refused under the OPEN authorization policy: every caller, anonymous included, would administer erasure. Enable authentication (AUTH_ENABLED=true with ADMINS) first.");
|
|
48
|
+
if (!reactorModule) throw new PrivacyBootError("PH_PRIVACY_ENABLED needs an in-process reactor module");
|
|
49
|
+
if (!deps.signer?.app?.key) throw new PrivacyBootError("PH_PRIVACY_ENABLED needs a reactor signer (a Renown identity): every receiver refuses an unsigned purge marker");
|
|
50
|
+
const permissions = deps.documentPermissionService ? new PrivacyPermissionAdapter(deps.documentPermissionService) : void 0;
|
|
51
|
+
const { service, scheduler } = createModuleErasure(reactorModule, {
|
|
52
|
+
deploymentSecret: config.deploymentSecret,
|
|
53
|
+
signer: deps.signer,
|
|
54
|
+
permissions,
|
|
55
|
+
intervalMs: config.intervalMs,
|
|
56
|
+
deadlineMs: config.deadlineMs,
|
|
57
|
+
markerGraceMs: config.markerGraceMs,
|
|
58
|
+
purgeTimeoutMs: config.purgeTimeoutMs,
|
|
59
|
+
logger: deps.logger
|
|
60
|
+
});
|
|
61
|
+
const disclosure = new DisclosureService(reactorModule.database, config.deploymentSecret, permissions);
|
|
62
|
+
let subgraph;
|
|
63
|
+
try {
|
|
64
|
+
subgraph = createPrivacySubgraph({
|
|
65
|
+
authorizationService,
|
|
66
|
+
erasure: service,
|
|
67
|
+
disclosure
|
|
68
|
+
});
|
|
69
|
+
} catch (error) {
|
|
70
|
+
throw new PrivacyBootError(error instanceof Error ? error.message : String(error));
|
|
71
|
+
}
|
|
72
|
+
await registerSubjectDocumentsReadModel(reactorModule, { deploymentSecret: config.deploymentSecret });
|
|
73
|
+
await deps.graphqlManager.registerSubgraphInstance({
|
|
74
|
+
...subgraph,
|
|
75
|
+
path: deps.graphqlManager.getBasePath(),
|
|
76
|
+
readClient: deps.readClient,
|
|
77
|
+
relationalDb: void 0
|
|
78
|
+
}, "graphql", false);
|
|
79
|
+
scheduler.start();
|
|
80
|
+
deps.logger.info("Privacy add-on started: subject index, erasure scheduler");
|
|
81
|
+
return {
|
|
82
|
+
erasure: service,
|
|
83
|
+
scheduler,
|
|
84
|
+
stop: () => scheduler.stop()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { resolvePrivacy as n, startPrivacy as r, privacyTimingsFromEnv as t };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=privacy-HQnhqf2H.mjs.map
|
|
91
|
+
//# debugId=5304d939-0e11-5ae3-b9e1-046bd0759d36
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-HQnhqf2H.mjs","sources":["../src/privacy.mts"],"sourcesContent":["import type {\n InProcessReactorModule,\n IReactorReadClient,\n} from \"@powerhousedao/reactor\";\nimport {\n AuthorizationPolicy,\n PrivacyPermissionAdapter,\n type DocumentPermissionService,\n type GraphQLManager,\n type IAuthorizationService,\n} from \"@powerhousedao/reactor-api\";\nimport {\n createModuleErasure,\n createPrivacySubgraph,\n DisclosureService,\n MIN_DEPLOYMENT_SECRET_BYTES,\n registerSubjectDocumentsReadModel,\n type ErasureScheduler,\n type IErasureService,\n} from \"@powerhousedao/reactor-privacy\";\nimport type { ISigner } from \"@powerhousedao/shared/document-model\";\nimport type { ILogger } from \"document-model\";\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\n\nexport type PrivacyOptions = {\n /** Wins over PH_PRIVACY_ENABLED. */\n enabled?: boolean;\n /** Wins over PH_PRIVACY_DEPLOYMENT_SECRET. */\n deploymentSecret?: string;\n /** The reactor's signer, for a caller-provided reactor. */\n signer?: ISigner;\n /** Each wins over its PH_PRIVACY_* env var. */\n intervalMs?: number;\n deadlineMs?: number;\n markerGraceMs?: number;\n purgeTimeoutMs?: number;\n};\n\nexport type ResolvedPrivacy =\n | { enabled: false }\n | {\n enabled: true;\n deploymentSecret: string;\n intervalMs?: number;\n deadlineMs?: number;\n markerGraceMs?: number;\n purgeTimeoutMs?: number;\n };\n\n/** Enabling privacy on a switchboard that cannot run it safely. */\nexport class PrivacyBootError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"PrivacyBootError\";\n }\n}\n\nfunction positive(\n env: NodeJS.ProcessEnv,\n name: string,\n unitMs: number,\n): number | undefined {\n const raw = env[name];\n if (raw === undefined || raw.trim() === \"\") return undefined;\n const value = Number(raw);\n if (!Number.isFinite(value) || value <= 0) {\n throw new PrivacyBootError(\n `${name} must be a positive number, got \"${raw}\"`,\n );\n }\n return value * unitMs;\n}\n\nexport function resolvePrivacy(\n options: PrivacyOptions | undefined,\n env: NodeJS.ProcessEnv,\n): ResolvedPrivacy {\n const enabled = options?.enabled ?? env.PH_PRIVACY_ENABLED === \"true\";\n if (!enabled) return { enabled: false };\n const deploymentSecret =\n options?.deploymentSecret ?? env.PH_PRIVACY_DEPLOYMENT_SECRET;\n if (\n !deploymentSecret ||\n Buffer.byteLength(deploymentSecret, \"utf8\") < MIN_DEPLOYMENT_SECRET_BYTES\n ) {\n throw new PrivacyBootError(\n `PH_PRIVACY_ENABLED needs PH_PRIVACY_DEPLOYMENT_SECRET of at least ${MIN_DEPLOYMENT_SECRET_BYTES} bytes`,\n );\n }\n const fromEnv = privacyTimingsFromEnv(env);\n return {\n enabled: true,\n deploymentSecret,\n intervalMs: options?.intervalMs ?? fromEnv.intervalMs,\n deadlineMs: options?.deadlineMs ?? fromEnv.deadlineMs,\n markerGraceMs: options?.markerGraceMs ?? fromEnv.markerGraceMs,\n purgeTimeoutMs: options?.purgeTimeoutMs ?? fromEnv.purgeTimeoutMs,\n };\n}\n\n/** The erasure timings from PH_PRIVACY_*, in ms; each unset one is undefined. */\nexport function privacyTimingsFromEnv(env: NodeJS.ProcessEnv) {\n return {\n intervalMs: positive(env, \"PH_PRIVACY_INTERVAL_MS\", 1),\n deadlineMs: positive(env, \"PH_PRIVACY_DEADLINE_DAYS\", DAY_MS),\n markerGraceMs: positive(env, \"PH_PRIVACY_MARKER_GRACE_DAYS\", DAY_MS),\n purgeTimeoutMs: positive(env, \"PH_PRIVACY_PURGE_TIMEOUT_MINUTES\", 60_000),\n };\n}\n\nexport type RunningPrivacy = {\n erasure: IErasureService;\n scheduler: ErasureScheduler;\n stop(): Promise<void>;\n};\n\n/** Subject index, erasure scheduler and admin subgraph on a built reactor. */\nexport async function startPrivacy(deps: {\n config: Extract<ResolvedPrivacy, { enabled: true }>;\n reactorModule: InProcessReactorModule | undefined;\n signer: ISigner | undefined;\n authorizationService: IAuthorizationService;\n documentPermissionService: DocumentPermissionService | undefined;\n graphqlManager: GraphQLManager;\n readClient: IReactorReadClient;\n logger: ILogger;\n}): Promise<RunningPrivacy> {\n const { config, reactorModule, authorizationService } = deps;\n if (authorizationService.config.policy === AuthorizationPolicy.OPEN) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED is refused under the OPEN authorization policy: every caller, anonymous included, would administer erasure. Enable authentication (AUTH_ENABLED=true with ADMINS) first.\",\n );\n }\n if (!reactorModule) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs an in-process reactor module\",\n );\n }\n if (!deps.signer?.app?.key) {\n throw new PrivacyBootError(\n \"PH_PRIVACY_ENABLED needs a reactor signer (a Renown identity): every receiver refuses an unsigned purge marker\",\n );\n }\n\n const permissions = deps.documentPermissionService\n ? new PrivacyPermissionAdapter(deps.documentPermissionService)\n : undefined;\n const { service, scheduler } = createModuleErasure(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n signer: deps.signer,\n permissions,\n intervalMs: config.intervalMs,\n deadlineMs: config.deadlineMs,\n markerGraceMs: config.markerGraceMs,\n purgeTimeoutMs: config.purgeTimeoutMs,\n logger: deps.logger,\n });\n\n const disclosure = new DisclosureService(\n reactorModule.database,\n config.deploymentSecret,\n permissions,\n );\n let subgraph;\n try {\n subgraph = createPrivacySubgraph({\n authorizationService,\n erasure: service,\n disclosure,\n });\n } catch (error) {\n throw new PrivacyBootError(\n error instanceof Error ? error.message : String(error),\n );\n }\n\n await registerSubjectDocumentsReadModel(reactorModule, {\n deploymentSecret: config.deploymentSecret,\n });\n await deps.graphqlManager.registerSubgraphInstance(\n {\n ...subgraph,\n path: deps.graphqlManager.getBasePath(),\n readClient: deps.readClient,\n relationalDb: undefined as never,\n },\n \"graphql\",\n false,\n );\n\n scheduler.start();\n deps.logger.info(\"Privacy add-on started: subject index, erasure scheduler\");\n return {\n erasure: service,\n scheduler,\n stop: () => scheduler.stop(),\n };\n}\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,SAAS;;AA4Bf,IAAa,mBAAb,cAAsC,MAAM;CAC1C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,SAAS,SACP,KACA,MACA,QACoB;CACpB,MAAM,MAAM,IAAI;CAChB,IAAI,QAAQ,KAAA,KAAa,IAAI,KAAK,MAAM,IAAI,OAAO,KAAA;CACnD,MAAM,QAAQ,OAAO,GAAG;CACxB,IAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS,GACtC,MAAM,IAAI,iBACR,GAAG,KAAK,mCAAmC,IAAI,EACjD;CAEF,OAAO,QAAQ;AACjB;AAEA,SAAgB,eACd,SACA,KACiB;CAEjB,IAAI,EADY,SAAS,WAAW,IAAI,uBAAuB,SACjD,OAAO,EAAE,SAAS,MAAM;CACtC,MAAM,mBACJ,SAAS,oBAAoB,IAAI;CACnC,IACE,CAAC,oBACD,OAAO,WAAW,kBAAkB,MAAM,IAAI,6BAE9C,MAAM,IAAI,iBACR,qEAAqE,4BAA4B,OACnG;CAEF,MAAM,UAAU,sBAAsB,GAAG;CACzC,OAAO;EACL,SAAS;EACT;EACA,YAAY,SAAS,cAAc,QAAQ;EAC3C,YAAY,SAAS,cAAc,QAAQ;EAC3C,eAAe,SAAS,iBAAiB,QAAQ;EACjD,gBAAgB,SAAS,kBAAkB,QAAQ;CACrD;AACF;;AAGA,SAAgB,sBAAsB,KAAwB;CAC5D,OAAO;EACL,YAAY,SAAS,KAAK,0BAA0B,CAAC;EACrD,YAAY,SAAS,KAAK,4BAA4B,MAAM;EAC5D,eAAe,SAAS,KAAK,gCAAgC,MAAM;EACnE,gBAAgB,SAAS,KAAK,oCAAoC,GAAM;CAC1E;AACF;;AASA,eAAsB,aAAa,MASP;CAC1B,MAAM,EAAE,QAAQ,eAAe,yBAAyB;CACxD,IAAI,qBAAqB,OAAO,WAAW,oBAAoB,MAC7D,MAAM,IAAI,iBACR,6LACF;CAEF,IAAI,CAAC,eACH,MAAM,IAAI,iBACR,uDACF;CAEF,IAAI,CAAC,KAAK,QAAQ,KAAK,KACrB,MAAM,IAAI,iBACR,gHACF;CAGF,MAAM,cAAc,KAAK,4BACrB,IAAI,yBAAyB,KAAK,yBAAyB,IAC3D,KAAA;CACJ,MAAM,EAAE,SAAS,cAAc,oBAAoB,eAAe;EAChE,kBAAkB,OAAO;EACzB,QAAQ,KAAK;EACb;EACA,YAAY,OAAO;EACnB,YAAY,OAAO;EACnB,eAAe,OAAO;EACtB,gBAAgB,OAAO;EACvB,QAAQ,KAAK;CACf,CAAC;CAED,MAAM,aAAa,IAAI,kBACrB,cAAc,UACd,OAAO,kBACP,WACF;CACA,IAAI;CACJ,IAAI;EACF,WAAW,sBAAsB;GAC/B;GACA,SAAS;GACT;EACF,CAAC;CACH,SAAS,OAAO;EACd,MAAM,IAAI,iBACR,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CACvD;CACF;CAEA,MAAM,kCAAkC,eAAe,EACrD,kBAAkB,OAAO,iBAC3B,CAAC;CACD,MAAM,KAAK,eAAe,yBACxB;EACE,GAAG;EACH,MAAM,KAAK,eAAe,YAAY;EACtC,YAAY,KAAK;EACjB,cAAc,KAAA;CAChB,GACA,WACA,KACF;CAEA,UAAU,MAAM;CAChB,KAAK,OAAO,KAAK,0DAA0D;CAC3E,OAAO;EACL,SAAS;EACT;EACA,YAAY,UAAU,KAAK;CAC7B;AACF","debug_id":"5304d939-0e11-5ae3-b9e1-046bd0759d36"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6e239805-34d1-53b4-81ad-9420ea97c4df")}catch(e){}}();
|
|
3
|
+
import { n as resolvePrivacy, r as startPrivacy } from "./privacy-HQnhqf2H.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/plugins/privacy.mts
|
|
6
|
+
/** No entry config: presence is the whole activation. A typo'd config key
|
|
7
|
+
* fails at resolution instead of being silently ignored. */
|
|
8
|
+
const privacyPluginConfigSchema = z.strictObject({});
|
|
9
|
+
const privacyPlugin = {
|
|
10
|
+
name: "switchboard-privacy",
|
|
11
|
+
appliesTo: "switchboard",
|
|
12
|
+
configSchema: privacyPluginConfigSchema,
|
|
13
|
+
hooks: {
|
|
14
|
+
transformServerOptions: (options, ctx) => {
|
|
15
|
+
ctx.privacyConfig = resolvePrivacy(options.privacy, {});
|
|
16
|
+
return options;
|
|
17
|
+
},
|
|
18
|
+
onSubgraphsRegistering: async (ctx) => {
|
|
19
|
+
const config = ctx.privacyConfig;
|
|
20
|
+
if (!config.enabled) return;
|
|
21
|
+
const options = ctx.options;
|
|
22
|
+
const signer = options.reactor ? options.privacy?.signer : options.privacy?.signer ?? ctx.renown?.signer;
|
|
23
|
+
const api = ctx.api;
|
|
24
|
+
ctx.privacy = await startPrivacy({
|
|
25
|
+
config,
|
|
26
|
+
reactorModule: ctx.reactorClientModule?.reactorModule,
|
|
27
|
+
signer,
|
|
28
|
+
authorizationService: api.authorizationService,
|
|
29
|
+
documentPermissionService: api.documentPermissionService,
|
|
30
|
+
graphqlManager: ctx.graphqlManager,
|
|
31
|
+
readClient: ctx.read,
|
|
32
|
+
logger: ctx.logger.child(["privacy"])
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
onShutdown: async (ctx) => {
|
|
36
|
+
await ctx.privacy?.stop();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { privacyPluginConfigSchema as n, privacyPlugin as t };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=privacy-UodgY0i_.mjs.map
|
|
44
|
+
//# debugId=6e239805-34d1-53b4-81ad-9420ea97c4df
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy-UodgY0i_.mjs","sources":["../src/plugins/privacy.mts"],"sourcesContent":["import type { IRenown } from \"@renown/sdk\";\nimport type { HostPlugin } from \"@powerhousedao/host-core\";\nimport type { ILogger } from \"document-model\";\nimport {\n resolvePrivacy,\n startPrivacy,\n type PrivacyOptions,\n type ResolvedPrivacy,\n type RunningPrivacy,\n} from \"../privacy.mjs\";\nimport type { SwitchboardHostContext } from \"../plugin-host.mjs\";\nimport { z } from \"zod\";\n\n/** No entry config: presence is the whole activation. A typo'd config key\n * fails at resolution instead of being silently ignored. */\nexport const privacyPluginConfigSchema = z.strictObject({});\n\nexport type PrivacyPluginConfig = z.input<typeof privacyPluginConfigSchema>;\n\ndeclare global {\n interface PHPluginConfigs {\n \"@powerhousedao/switchboard/plugins/privacy\": PrivacyPluginConfig;\n }\n}\n\n/**\n * R2.4 — the privacy subsystem as a built-in plugin. Presence is activation\n * of the SUBSYSTEM; whether privacy enforcement runs still requires its\n * config (enabled + deploymentSecret — A SECRET, env-only:\n * PH_PRIVACY_DEPLOYMENT_SECRET never enters host files).\n *\n * Timing preserved from the inline path (carve map): config resolves EARLY at\n * transformServerOptions (a bad secret fails the boot before any resource\n * opens — same fail-fast property as the inline line-571 resolve); the mount\n * runs at onSubgraphsRegistering, whose server-side call site carries the\n * inline failure semantics (stop workflows, abortBoot, rethrow); teardown is\n * first in shutdown via onShutdown.\n */\n\ntype PrivacyCapableOptions = Record<string, unknown> & {\n privacy?: PrivacyOptions & { signer?: unknown };\n reactor?: unknown;\n};\n\nexport const privacyPlugin: HostPlugin<{\n transformServerOptions: (\n options: Record<string, unknown>,\n ctx: SwitchboardHostContext,\n ) => Record<string, unknown>;\n onSubgraphsRegistering: (ctx: SwitchboardHostContext) => Promise<void>;\n onShutdown: (ctx: SwitchboardHostContext) => Promise<void>;\n}> = {\n name: \"switchboard-privacy\",\n appliesTo: \"switchboard\",\n configSchema: privacyPluginConfigSchema,\n hooks: {\n transformServerOptions: (options, ctx) => {\n // Fail-fast resolve, before the reactor is built.\n ctx.privacyConfig = resolvePrivacy(\n (options as PrivacyCapableOptions).privacy,\n {},\n );\n return options;\n },\n onSubgraphsRegistering: async (ctx) => {\n const config = ctx.privacyConfig as ResolvedPrivacy;\n if (!config.enabled) return;\n const options = ctx.options as PrivacyCapableOptions;\n // The caller's reactor signs with a signer only the caller knows.\n const signer = options.reactor\n ? options.privacy?.signer\n : (options.privacy?.signer ?? (ctx.renown as IRenown | null)?.signer);\n const api = ctx.api as {\n authorizationService: never;\n documentPermissionService: never;\n };\n ctx.privacy = await startPrivacy({\n config,\n reactorModule: (\n ctx.reactorClientModule as { reactorModule?: never } | undefined\n )?.reactorModule,\n signer: signer as never,\n authorizationService: api.authorizationService,\n documentPermissionService: api.documentPermissionService,\n graphqlManager: ctx.graphqlManager as never,\n readClient: ctx.read as never,\n logger: (ctx.logger as ILogger).child([\"privacy\"]),\n });\n },\n onShutdown: async (ctx) => {\n await (ctx.privacy as RunningPrivacy | undefined)?.stop();\n },\n },\n};\n\n// resolveHostPlugins consumes the DEFAULT export (plugin object or factory).\nexport default privacyPlugin;\n"],"names":[],"mappings":";;;;;;;AAeA,MAAa,4BAA4B,EAAE,aAAa,CAAC,CAAC;AA6B1D,MAAa,gBAOR;CACH,MAAM;CACN,WAAW;CACX,cAAc;CACd,OAAO;EACL,yBAAyB,SAAS,QAAQ;GAExC,IAAI,gBAAgB,eACjB,QAAkC,SACnC,CAAC,CACH;GACA,OAAO;EACT;EACA,wBAAwB,OAAO,QAAQ;GACrC,MAAM,SAAS,IAAI;GACnB,IAAI,CAAC,OAAO,SAAS;GACrB,MAAM,UAAU,IAAI;GAEpB,MAAM,SAAS,QAAQ,UACnB,QAAQ,SAAS,SAChB,QAAQ,SAAS,UAAW,IAAI,QAA2B;GAChE,MAAM,MAAM,IAAI;GAIhB,IAAI,UAAU,MAAM,aAAa;IAC/B;IACA,eACE,IAAI,qBACH;IACK;IACR,sBAAsB,IAAI;IAC1B,2BAA2B,IAAI;IAC/B,gBAAgB,IAAI;IACpB,YAAY,IAAI;IAChB,QAAS,IAAI,OAAmB,MAAM,CAAC,SAAS,CAAC;GACnD,CAAC;EACH;EACA,YAAY,OAAO,QAAQ;GACzB,MAAO,IAAI,SAAwC,KAAK;EAC1D;CACF;AACF","debug_id":"6e239805-34d1-53b4-81ad-9420ea97c4df"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/reactor-feature-flags.mts
|
|
2
|
+
/**
|
|
3
|
+
* Feature flags from the REACTOR_* env vars. Each enforcement flag requires the
|
|
4
|
+
* ones before it and is on only at the literal "true"; the reactor rejects an
|
|
5
|
+
* inconsistent set rather than enforcing less than the operator asked for, so
|
|
6
|
+
* this reports what was asked without correcting it. undoV3 has no
|
|
7
|
+
* prerequisites; once set it is on unless it is the literal "false".
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="725e13e5-a133-5cc4-af5d-469f9fac61ac")}catch(e){}}();
|
|
11
|
+
function resolveReactorFeatureFlags(env) {
|
|
12
|
+
return reactorFeatureFlagsOf({
|
|
13
|
+
documentDecisions: env.REACTOR_DOCUMENT_DECISIONS === "true",
|
|
14
|
+
authEnforcement: env.REACTOR_AUTH_ENFORCEMENT === "true",
|
|
15
|
+
authGroups: env.REACTOR_AUTH_GROUPS === "true",
|
|
16
|
+
authConditions: env.REACTOR_AUTH_CONDITIONS === "true",
|
|
17
|
+
...env.REACTOR_UNDO_V3 === void 0 ? {} : { undoV3: env.REACTOR_UNDO_V3 !== "false" }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** The flags as configured, with the names of those set to true. */
|
|
21
|
+
function reactorFeatureFlagsOf(flags) {
|
|
22
|
+
return {
|
|
23
|
+
flags,
|
|
24
|
+
enabled: Object.entries(flags).filter(([, isEnabled]) => isEnabled).map(([name]) => name)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/renown-layers.mts
|
|
29
|
+
/** The config file's `auth.renown`, with the config's set keys over it. */
|
|
30
|
+
function renownLayers(file, config) {
|
|
31
|
+
return {
|
|
32
|
+
...file,
|
|
33
|
+
...config.source !== void 0 ? { source: config.source } : {},
|
|
34
|
+
...config.url !== void 0 ? { url: config.url } : {},
|
|
35
|
+
...config.switchboardUrl !== void 0 ? { switchboardUrl: config.switchboardUrl } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { reactorFeatureFlagsOf as n, resolveReactorFeatureFlags as r, renownLayers as t };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=renown-layers-DmbWLt46.mjs.map
|
|
42
|
+
//# debugId=725e13e5-a133-5cc4-af5d-469f9fac61ac
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renown-layers-DmbWLt46.mjs","sources":["../src/reactor-feature-flags.mts","../src/renown-layers.mts"],"sourcesContent":["import type { ReactorFeatureFlags } from \"@powerhousedao/reactor\";\n\nexport type ResolvedReactorFeatureFlags = {\n flags: Partial<ReactorFeatureFlags>;\n /** Names of the flags set to true, in prerequisite order. */\n enabled: string[];\n};\n\n/**\n * Feature flags from the REACTOR_* env vars. Each enforcement flag requires the\n * ones before it and is on only at the literal \"true\"; the reactor rejects an\n * inconsistent set rather than enforcing less than the operator asked for, so\n * this reports what was asked without correcting it. undoV3 has no\n * prerequisites; once set it is on unless it is the literal \"false\".\n */\nexport function resolveReactorFeatureFlags(\n env: NodeJS.ProcessEnv,\n): ResolvedReactorFeatureFlags {\n return reactorFeatureFlagsOf({\n documentDecisions: env.REACTOR_DOCUMENT_DECISIONS === \"true\",\n authEnforcement: env.REACTOR_AUTH_ENFORCEMENT === \"true\",\n authGroups: env.REACTOR_AUTH_GROUPS === \"true\",\n authConditions: env.REACTOR_AUTH_CONDITIONS === \"true\",\n ...(env.REACTOR_UNDO_V3 === undefined\n ? {}\n : { undoV3: env.REACTOR_UNDO_V3 !== \"false\" }),\n });\n}\n\n/** The flags as configured, with the names of those set to true. */\nexport function reactorFeatureFlagsOf(\n flags: Partial<ReactorFeatureFlags>,\n): ResolvedReactorFeatureFlags {\n const enabled = Object.entries(flags)\n .filter(([, isEnabled]) => isEnabled)\n .map(([name]) => name);\n\n return { flags, enabled };\n}\n","import type { RenownConfig } from \"@powerhousedao/reactor-api\";\nimport type { SwitchboardConfig } from \"./config/schema.js\";\n\n/** The config file's `auth.renown`, with the config's set keys over it. */\nexport function renownLayers(\n file: RenownConfig | undefined,\n config: SwitchboardConfig[\"auth\"][\"renown\"],\n): RenownConfig {\n return {\n ...file,\n ...(config.source !== undefined ? { source: config.source } : {}),\n ...(config.url !== undefined ? { url: config.url } : {}),\n ...(config.switchboardUrl !== undefined\n ? { switchboardUrl: config.switchboardUrl }\n : {}),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;AAeA,SAAgB,2BACd,KAC6B;CAC7B,OAAO,sBAAsB;EAC3B,mBAAmB,IAAI,+BAA+B;EACtD,iBAAiB,IAAI,6BAA6B;EAClD,YAAY,IAAI,wBAAwB;EACxC,gBAAgB,IAAI,4BAA4B;EAChD,GAAI,IAAI,oBAAoB,KAAA,IACxB,CAAC,IACD,EAAE,QAAQ,IAAI,oBAAoB,QAAQ;CAChD,CAAC;AACH;;AAGA,SAAgB,sBACd,OAC6B;CAK7B,OAAO;EAAE;EAAO,SAJA,OAAO,QAAQ,KAAK,CAAC,CAClC,QAAQ,GAAG,eAAe,SAAS,CAAC,CACpC,KAAK,CAAC,UAAU,IAEG;CAAE;AAC1B;;;;AClCA,SAAgB,aACd,MACA,QACc;CACd,OAAO;EACL,GAAG;EACH,GAAI,OAAO,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,QAAQ,KAAA,IAAY,EAAE,KAAK,OAAO,IAAI,IAAI,CAAC;EACtD,GAAI,OAAO,mBAAmB,KAAA,IAC1B,EAAE,gBAAgB,OAAO,eAAe,IACxC,CAAC;CACP;AACF","debug_id":"725e13e5-a133-5cc4-af5d-469f9fac61ac"}
|