@di-framework/cli-plugin-platform 6.1.2 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +154 -12
  2. package/dist/args.d.ts +8 -0
  3. package/dist/args.js +73 -28
  4. package/dist/assets/http-adapter.js +4 -1
  5. package/dist/assets/platform/README.md +68 -19
  6. package/dist/assets/platform/index.ts.tmpl +1 -1
  7. package/dist/assets/platform/tsconfig.json +2 -2
  8. package/dist/assets/sqlite/BUILD-INFO.txt +1 -1
  9. package/dist/build.d.ts +27 -4
  10. package/dist/build.js +159 -18
  11. package/dist/bundle.d.ts +85 -0
  12. package/dist/bundle.js +608 -0
  13. package/dist/command.js +85 -3
  14. package/dist/console/catalog.js +2 -1
  15. package/dist/console/cluster.d.ts +4 -2
  16. package/dist/console/cluster.js +38 -40
  17. package/dist/control/auth.js +14 -2
  18. package/dist/controller/client.d.ts +47 -0
  19. package/dist/controller/client.js +157 -0
  20. package/dist/controller/commands.d.ts +48 -0
  21. package/dist/controller/commands.js +584 -0
  22. package/dist/controller/credentials.d.ts +63 -0
  23. package/dist/controller/credentials.js +156 -0
  24. package/dist/controller/index.d.ts +6 -0
  25. package/dist/controller/index.js +6 -0
  26. package/dist/controller/oidc.d.ts +54 -0
  27. package/dist/controller/oidc.js +121 -0
  28. package/dist/controller/registry.d.ts +15 -0
  29. package/dist/controller/registry.js +47 -0
  30. package/dist/controller/schema.d.ts +157 -0
  31. package/dist/controller/schema.js +1 -0
  32. package/dist/controller/sse.d.ts +12 -0
  33. package/dist/controller/sse.js +61 -0
  34. package/dist/controller/trust.d.ts +14 -0
  35. package/dist/controller/trust.js +39 -0
  36. package/dist/deploy.d.ts +14 -7
  37. package/dist/deploy.js +96 -5
  38. package/dist/deps.d.ts +4 -0
  39. package/dist/destroy.js +26 -2
  40. package/dist/environment-names.d.ts +6 -0
  41. package/dist/environment-names.js +10 -0
  42. package/dist/index.d.ts +5 -3
  43. package/dist/index.js +5 -3
  44. package/dist/manifest.d.ts +45 -1
  45. package/dist/manifest.js +197 -4
  46. package/dist/pglite-encryption.d.ts +79 -0
  47. package/dist/pglite-encryption.js +196 -0
  48. package/dist/pglite.d.ts +61 -4
  49. package/dist/pglite.js +124 -40
  50. package/dist/project.d.ts +7 -0
  51. package/dist/project.js +35 -0
  52. package/dist/publish.d.ts +7 -1
  53. package/dist/publish.js +33 -1
  54. package/dist/service.d.ts +34 -0
  55. package/dist/service.js +156 -145
  56. package/dist/target.d.ts +7 -1
  57. package/dist/target.js +19 -0
  58. package/dist/workload.d.ts +50 -12
  59. package/dist/workload.js +239 -44
  60. package/package.json +1 -1
package/README.md CHANGED
@@ -306,18 +306,79 @@ Application `destroy` never runs `pulumi destroy`.
306
306
  ### Control Secret
307
307
 
308
308
  An application that serves HTTP, cron, queues or actors gets a Secret
309
- `<deployment>-control` holding `DI_CONTROL_TOKEN` and `DI_CONTROL_IDENTITY`. Tenant
310
- developers may create, update and delete Secrets but not read, list, watch or patch them,
311
- so the CLI never reads it back:
312
-
313
- - `deploy` writes a new random token every time: it creates the Secret and, if it already
314
- exists, replaces the whole Secret with an unconditional update. If keys were added to it
315
- by hand, the platform's `tenant-secret-update` admission policy denies that update (it
316
- refuses any update that drops a key), and deploy stops with "the control Secret
317
- `<deployment>-control` has keys this CLI didn't write"; delete it with
318
- `kubectl delete secret <deployment>-control` and redeploy. Other failed writes show
319
- kubectl's reason, scrubbed of the token.
320
- - The token rotates at that Secret write, before `kubectl apply`. The WorkloadDeployment
309
+ `<deployment>-control` holding `DI_CONTROL_TOKEN` and `DI_CONTROL_IDENTITY`. The workload gets
310
+ the whole Secret as environment variables, and a workload without an environment label may
311
+ reference no other Secret, so it is also where an app keeps its own runtime secrets. Declare
312
+ those keys in `di-framework.config.json`:
313
+
314
+ ```json
315
+ {
316
+ "controlSecretKeys": ["ISSUER_URL", "AUTH_ACTIVE_PRIVATE_JWK", "DI_PGLITE_KEY"]
317
+ }
318
+ ```
319
+
320
+ A declared key must be an environment variable name. `DI_*` names belong to the framework, so
321
+ of those only `DI_PGLITE_KEY` and `DI_PGLITE_KEY_PREVIOUS` may be declared, and so may none of
322
+ the names the CLI renders into the workload's environment (`ACTOR_STORAGE_DIR`,
323
+ `QUEUE_DB_PATH`, `MIGRATION_DB_PATH`). Deploy never writes or reads values for these keys, and
324
+ refuses any key that is neither the CLI's nor declared.
325
+
326
+ **Once app keys exist, the app's tooling owns the control token.** A tenant developer cannot
327
+ read the Secret, so the tooling cannot keep the CLI's token value. It replaces the whole Secret
328
+ with:
329
+ - its own values;
330
+ - a freshly minted, non-empty `DI_CONTROL_TOKEN` (for example 32 random bytes, base64url);
331
+ - `DI_CONTROL_IDENTITY` set to the workload name.
332
+
333
+ It then rolls the workload, for example by setting a revision entry in the WorkloadDeployment's
334
+ environment config, as identity-server's `runtime-secrets.ts apply` does. From then on deploy
335
+ keeps that Secret, and token included, never rotates it. Rotate by re-running the tooling. The
336
+ platform issue
337
+ [di-framework/platform#203](https://github.com/di-framework/platform/issues/203) proposes a
338
+ separate `<workload>-secrets` so the control Secret can go back to being CLI-owned and rotated
339
+ on every deploy.
340
+
341
+ - A new Secret is created with the CLI's keys and a new random token.
342
+ - Tenant developers may create, update and delete Secrets but not read, list, watch or patch
343
+ them. The CLI never reads the Secret back for them; `kubectl auth can-i get` decides this
344
+ without sending a read. Every check below is a dry-run update (`?dryRun=All`, nothing
345
+ stored). It asks the platform's `tenant-secret-update` admission policy, which refuses an
346
+ update that drops a key, about key names only. With app keys declared, deploy:
347
+ 1. Checks that the policy protects the Secret. A dry run keeping only `DI_CONTROL_IDENTITY`
348
+ must be refused. If it is accepted, the policy does not apply to this caller (a write-only
349
+ identity that is not `di-user-*`, or a namespace outside the policy), or the Secret has no
350
+ token. A blind replace could then drop the app keys for good, so deploy stops with
351
+ `WASMCLOUD_CONTROL_SECRET_UNGUARDED` and writes nothing. As a result, a write-only caller
352
+ outside `di-user-*` (for example a CI ServiceAccount bound to the developer role) cannot
353
+ deploy a project that declares app keys. Deploy it as a tenant developer, or with an
354
+ identity that may read Secrets.
355
+ 2. Replaces the whole Secret with the CLI's keys and a new token. That succeeds, and rotates
356
+ the token, only while the Secret holds nothing else.
357
+ 3. If the replace is refused, sends a dry run with the CLI's keys and every declared key. If
358
+ the policy refuses that too, an undeclared key exists: deploy stops with "the control
359
+ Secret `<deployment>-control` has keys this CLI didn't write". Declare the keys, or
360
+ delete the Secret with `kubectl delete secret <deployment>-control` and redeploy.
361
+ 4. Leaves out `DI_CONTROL_TOKEN`, then `DI_CONTROL_IDENTITY`, in two more dry runs. Each must
362
+ be refused, which proves the key is stored. Otherwise the app tooling dropped it, and
363
+ deploy stops with `WASMCLOUD_CONTROL_SECRET_INCOMPLETE` rather than run a workload
364
+ without control credentials. The checks see key names only, so a present but empty
365
+ `DI_CONTROL_TOKEN` passes them. The deployed workload then has no usable token and
366
+ answers every control request (cron, queue and actor endpoints) with 401; it never falls
367
+ back to unauthenticated access. Make sure the tooling writes a non-empty token.
368
+ 5. Keeps the Secret as it is, token included, says "Kept control Secret
369
+ `<deployment>-control`", and renders no `DI_CONTROL_TOKEN_REVISION`.
370
+
371
+ These checks rely on `tenant-secret-update` having no dry-run exemption
372
+ ([di-framework/platform#204](https://github.com/di-framework/platform/issues/204)). Without
373
+ declared keys, deploy only replaces, as before.
374
+ - A caller who may read Secrets (a cluster admin) gets the Secret read. Deploy stops, naming
375
+ the keys, when one is neither the CLI's nor declared, instead of dropping it. Otherwise it
376
+ writes a new token with the declared keys carried over, conditional on the version it read,
377
+ and a concurrent change stops deploy with "changed while deploy was updating it; re-run
378
+ deploy". Nothing read is printed. Failures are scrubbed of every value read: values of four
379
+ characters or more wherever they appear, and shorter ones as whole tokens.
380
+ - Other failed writes show kubectl's reason, scrubbed of the token.
381
+ - When deploy writes a token, it rotates at that Secret write, before `kubectl apply`. The WorkloadDeployment
321
382
  carries `DI_CONTROL_TOKEN_REVISION` (a digest of the token), so the deploy rolls the
322
383
  workload onto the new token, but not at the same moment as its cron invokers: a CronJob
323
384
  pod reads the Secret when it starts, so the invokers switch first and can get 401 from
@@ -579,6 +640,7 @@ const db = open(process.env.DI_PGLITE_DATA_DIR ?? '/data/pglite', undefined);
579
640
  | `wasm` | none | A local provider build inside the project (symlinks resolved), used instead of `image` for offline development. Unverified; see below. |
580
641
  | `storageMount` | `/data` | Guest preopen of the workload's persistent directory. Tenant targets accept `/data` or `/data/actors`. |
581
642
  | `dataDir` | `<storageMount>/pglite` | Database root, at or under `storageMount`. The guest receives it as `DI_PGLITE_DATA_DIR`. |
643
+ | `encryption` | none | `{ "image": "ghcr.io/di-framework/pglite-encfs@sha256:<digest>" }` (or a local `wasm`): encrypt the data directory at rest; see [Encryption at rest](#encryption-at-rest). |
582
644
 
583
645
  The build pulls the provider with `oras`: `oras manifest fetch`, then `oras blob fetch` of the
584
646
  manifest's single `application/wasm` layer. It checks that the manifest hashes to the pinned
@@ -615,6 +677,76 @@ entry has no matching import, because the deploy renders the following from the
615
677
  when `storageMount` is not `/data`. Other targets get a host path volume on the `storage` pool.
616
678
  - `replicas: 1` and `deployPolicy: Recreate`. Other replica counts are refused.
617
679
 
680
+ #### Encryption at rest
681
+
682
+ `pglite.encryption` plugs an encrypting `wasi:filesystem` layer between the provider and the
683
+ host, so the data directory holds only ciphertext. The layer is composed into the provider
684
+ first, with an explicit `wac compose` (see below). That result is then plugged into the guest
685
+ exactly as an unencrypted provider is. The guest's own WASI imports still go straight to the
686
+ host.
687
+
688
+ ```json
689
+ {
690
+ "controlSecretKeys": ["DI_PGLITE_KEY"],
691
+ "pglite": {
692
+ "image": "ghcr.io/di-framework/pglite-component@sha256:<64 hex>",
693
+ "encryption": { "image": "ghcr.io/di-framework/pglite-encfs@sha256:<64 hex>" }
694
+ }
695
+ }
696
+ ```
697
+
698
+ - `encryption.image` is pinned by digest and pulled, verified and cached like the provider
699
+ (`oci/sha256/<digest>/di-framework-pglite-encfs.wasm`); the build plugs a private copy,
700
+ `.di-framework/di-framework-pglite-encfs.wasm`. `encryption.wasm` (a local build inside the
701
+ project) and `DI_FRAMEWORK_PGLITE_ENCFS_WASM` override it under the same rules as a local
702
+ provider: unverified, warned about, and refused by `platform deploy` and on CI unless
703
+ `DI_FRAMEWORK_ALLOW_LOCAL_PGLITE=1`.
704
+ - The layer reads its master key from `DI_PGLITE_KEY` (and, while rotating,
705
+ `DI_PGLITE_KEY_PREVIOUS`). The key reaches the guest only through the workload's control
706
+ Secret, so the build fails with `WASMCLOUD_PGLITE_KEY_UNDECLARED` unless `DI_PGLITE_KEY` is in
707
+ `controlSecretKeys` (see [Control Secret](#control-secret)). That check runs first, before
708
+ bundling or any pull. The CLI never writes or reads the
709
+ key: put it in `<deployment>-control` with your own tooling, and keep a copy, since losing it
710
+ loses the database.
711
+ - The layer must sit between the provider and the host, and `wac plug` cannot prove that.
712
+ `wac plug` silently skips an export whose type does not fit, and it exits 0 as long as
713
+ anything plugged. So the build does this instead:
714
+ 1. Reads both worlds with `jco wit`.
715
+ 2. Takes, for each provider import the layer exports, the export with the same name and
716
+ version, or else one on the same semver track the way `wac` matches them. That means the
717
+ same major from 1.0 on, the same minor for 0.x, and an exact match for 0.0.z and
718
+ pre-releases. Every `wasi:filesystem/*` import must get one.
719
+ 3. Writes `.di-framework/pglite-encryption.wac`. It instantiates the layer against the host
720
+ and passes each of those exports to the provider as a named instantiation argument.
721
+ 4. Composes it with `wac compose`, which type-checks every argument.
722
+
723
+ The build stops with `WASMCLOUD_PGLITE_ENCRYPTION_NOT_INTERPOSED`, carrying `wac`'s message
724
+ when there is one, if any of these holds:
725
+ - the layer misses a filesystem interface, is on another version track, or exports a type
726
+ the provider cannot use;
727
+ - the provider's world has an item the build cannot read as a versioned interface (such as a
728
+ plain-named `import fs: interface { … }`);
729
+ - the provider imports something that is neither wired to the layer nor on the host
730
+ pass-through allowlist (`wasi:io/*`, `wasi:clocks/*`, `wasi:random/*`, `wasi:cli/*`).
731
+
732
+ Build the layer for the WASI versions the pinned provider imports (`wasi:filesystem/*@0.2.9`
733
+ for provider 6.0.11). A missing `wac` or `jco` fails with `WASMCLOUD_WAC_REQUIRED` or
734
+ `WASMCLOUD_JCO_REQUIRED`.
735
+ - The layer must carry the platform's `di-framework:pglite-encfs` custom section
736
+ (`format=1 codec=aes-256-xts`). Without it the build stops with
737
+ `WASMCLOUD_PGLITE_ENCRYPTION_LAYER_UNMARKED`, which catches a no-op or debug layer pinned by
738
+ mistake or a stale local build. The build proves the wiring and the layer's identity, not the
739
+ cipher: the marker can be forged, so trust in what the layer actually does comes from the
740
+ digest pin of `encryption.image`.
741
+ - Only the engine has `DI_PGLITE_KEY` hidden. The layer filters it from the provider's
742
+ environment, but the guest's own `wasi:cli/environment` still comes from the host, so your
743
+ application code can read the key.
744
+ - The composed provider is `.di-framework/di-framework-pglite.encrypted.wasm`. The deployment
745
+ digest hashes the raw provider and layer bytes, not `wac`'s output, so changing either one
746
+ redeploys. The build and deploy results report the layer
747
+ (`PGlite: <image>, encrypted at rest by <layer>`).
748
+ - `encryption.image` must not pin the provider's repository or digest.
749
+
618
750
  Give each database one owner. Members of one implicit workload share one storage directory,
619
751
  mounted at each member's own `storageMount`. So `/data/pglite` under a `/data` mount and
620
752
  `/data/actors/pglite` under a `/data/actors` mount are the same database. Members that both embed
@@ -636,6 +768,16 @@ ServiceBindings before applying the workload. Successful updates and workload
636
768
  deletion remove obsolete deployment-owned associations. Shared projections stay
637
769
  while other workloads use them.
638
770
 
771
+ `wasmcloud:postgres@0.2.0` has no transaction handle, and a `serviceName` binding
772
+ is a named import served from a connection pool with no connection affinity:
773
+ `BEGIN` sent as one call does not cover the next. Do not wrap the binding with
774
+ `createSqlDatabase`, which sends `BEGIN` and `COMMIT` as separate calls and leaves
775
+ a poisoned pool connection that fails subsequent overlapping requests. Statements
776
+ execute as independent transactions and row locks last one statement; keep atomic
777
+ work in single statements (conditional `UPDATE … RETURNING`, data-modifying CTEs)
778
+ or `query-batch` scripts, and use an autocommit adapter such as `identity-server`'s
779
+ (`apps/guest/src/database.ts`, `pg.ts`) or `@di-framework/repo/postgres`.
780
+
639
781
  See [PostgreSQL storage, deletion, and recovery](../di-framework-platform/README.md#dedicated-postgresql-upcoming-release).
640
782
 
641
783
  ### Blobstore services
package/dist/args.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ import type { DeployEnvironment } from './manifest.js';
1
2
  export type AppCommandOptions = {
2
3
  name?: string;
3
4
  target?: string;
5
+ env?: DeployEnvironment;
6
+ preview?: boolean;
4
7
  yes: boolean;
5
8
  };
6
9
  export type PlatformCommandOptions = {
@@ -8,6 +11,11 @@ export type PlatformCommandOptions = {
8
11
  target?: string;
9
12
  yes: boolean;
10
13
  };
14
+ export declare function readStringFlag<K extends string>(args: readonly string[], position: number, token: string, flags: Readonly<Record<string, K>>, values: Partial<Record<K, string>>): number | undefined;
15
+ export declare function readEnvFlag(args: readonly string[], position: number, token: string, current: DeployEnvironment | undefined, command: string): {
16
+ value: DeployEnvironment;
17
+ nextPosition: number;
18
+ } | undefined;
11
19
  export declare function parseAppCommandArgs(args: readonly string[], command: string): AppCommandOptions;
12
20
  export type PlatformInitOptions = {
13
21
  force: boolean;
package/dist/args.js CHANGED
@@ -1,32 +1,73 @@
1
- import { invalidUsage, readOptionValue } from './support.js';
1
+ import { invalidUsage, matchOption, readOptionValue } from './support.js';
2
+ export function readStringFlag(args, position, token, flags, values) {
3
+ for (const [flag, key] of Object.entries(flags)) {
4
+ const matched = matchOption(args, position, token, flag);
5
+ if (matched) {
6
+ if (values[key] !== undefined) {
7
+ invalidUsage(`Option may be provided only once: ${flag}`, flag);
8
+ }
9
+ values[key] = matched.value;
10
+ return matched.consumedThrough + 1;
11
+ }
12
+ }
13
+ return undefined;
14
+ }
15
+ export function readEnvFlag(args, position, token, current, command) {
16
+ const matched = matchOption(args, position, token, '--env');
17
+ if (!matched)
18
+ return undefined;
19
+ if (current !== undefined) {
20
+ invalidUsage('Option may be provided only once: --env', '--env');
21
+ }
22
+ if (matched.value !== 'prod' && matched.value !== 'staging') {
23
+ invalidUsage('--env must be prod or staging', matched.value, { command });
24
+ }
25
+ return { value: matched.value, nextPosition: matched.consumedThrough + 1 };
26
+ }
27
+ const APP_STRING_FLAGS = { '--target': 'target' };
2
28
  export function parseAppCommandArgs(args, command) {
3
29
  let name;
4
- let target;
5
- let yes = false;
6
- for (let position = 0; position < args.length; position++) {
7
- const token = args[position] ?? '';
8
- switch (token) {
9
- case '--target':
10
- if (target !== undefined)
11
- invalidUsage(`Option may be provided only once: ${token}`, token);
12
- target = readOptionValue(args, ++position, token);
13
- break;
14
- case '--yes':
15
- if (yes)
16
- invalidUsage(`Option may be provided only once: ${token}`, token);
17
- yes = true;
18
- break;
19
- default:
20
- if (token.startsWith('--')) {
21
- invalidUsage(`Unknown option: ${token}`, token, { command });
22
- }
23
- if (name !== undefined) {
24
- invalidUsage(`Unexpected argument: ${token}`, token, { command });
25
- }
26
- name = token;
30
+ const values = {};
31
+ let env;
32
+ const flags = { preview: false, yes: false };
33
+ let position = 0;
34
+ while (position < args.length) {
35
+ const token = args[position];
36
+ const nextPos = readStringFlag(args, position, token, APP_STRING_FLAGS, values);
37
+ if (nextPos !== undefined) {
38
+ position = nextPos;
39
+ continue;
40
+ }
41
+ const envOpt = readEnvFlag(args, position, token, env, command);
42
+ if (envOpt) {
43
+ env = envOpt.value;
44
+ position = envOpt.nextPosition;
45
+ continue;
46
+ }
47
+ if (token === '--preview' || token === '--yes') {
48
+ const key = token === '--preview' ? 'preview' : 'yes';
49
+ if (flags[key])
50
+ invalidUsage(`Option may be provided only once: ${token}`, token);
51
+ flags[key] = true;
52
+ position += 1;
53
+ continue;
54
+ }
55
+ if (token.startsWith('--')) {
56
+ invalidUsage(`Unknown option: ${token}`, token, { command });
57
+ }
58
+ if (name !== undefined) {
59
+ invalidUsage(`Unexpected argument: ${token}`, token, { command });
27
60
  }
61
+ name = token;
62
+ position += 1;
28
63
  }
29
- return { name, target, yes };
64
+ return {
65
+ name,
66
+ target: values.target,
67
+ ...(env ? { env } : {}),
68
+ ...(flags.preview ? { preview: true } : {}),
69
+ yes: flags.yes,
70
+ };
30
71
  }
31
72
  export function parsePlatformInitArgs(args) {
32
73
  let force = false;
@@ -44,18 +85,21 @@ export function parsePlatformInitArgs(args) {
44
85
  export function parsePlatformCommandArgs(args, command) {
45
86
  let target;
46
87
  let yes = false;
47
- for (let position = 0; position < args.length; position++) {
48
- const token = args[position] ?? '';
88
+ let position = 0;
89
+ while (position < args.length) {
90
+ const token = args[position];
49
91
  if (token === '--yes') {
50
92
  if (yes)
51
93
  invalidUsage(`Option may be provided only once: ${token}`, token);
52
94
  yes = true;
95
+ position += 1;
53
96
  continue;
54
97
  }
55
98
  if (token === '--target') {
56
99
  if (target !== undefined)
57
100
  invalidUsage(`Option may be provided only once: ${token}`, token);
58
- target = readOptionValue(args, ++position, token);
101
+ target = readOptionValue(args, position + 1, token);
102
+ position += 2;
59
103
  continue;
60
104
  }
61
105
  if (token.startsWith('--')) {
@@ -65,6 +109,7 @@ export function parsePlatformCommandArgs(args, command) {
65
109
  invalidUsage(`Unexpected argument: ${token}`, token, { command });
66
110
  }
67
111
  target = token;
112
+ position += 1;
68
113
  }
69
114
  return { ...(target === undefined ? {} : { target }), yes };
70
115
  }
@@ -34,7 +34,10 @@ function parseIdentities() {
34
34
  return { identities: singleTokenIdentities(), configured: true };
35
35
  }
36
36
  const identities = singleTokenIdentities();
37
- return { identities, configured: identities.length > 0 };
37
+ return { identities, configured: identities.length > 0 || isDeployed() };
38
+ }
39
+ function isDeployed() {
40
+ return process.env.DI_CONTROL_REJECT_FORWARDED === "1" || (process.env.DI_CONTROL_HTTP_HOST ?? "").trim() !== "" || process.env.DI_CONTROL_IDENTITY !== undefined || process.env.DI_CONTROL_TOKEN !== undefined;
38
41
  }
39
42
  function hasRequiredRole(identity, requiredRoles) {
40
43
  return !requiredRoles.some((role) => !identity.roles.includes(role) && !identity.roles.includes("admin"));
@@ -2,8 +2,8 @@
2
2
 
3
3
  This generated Pulumi project provisions platform resources only:
4
4
 
5
- - a pinned k0s controller/worker in a stack- and workspace-scoped Docker network;
6
- - stack-scoped Docker volumes for k0s state and pod logs;
5
+ - a pinned k0s controller/worker in a stack- and workspace-scoped container network;
6
+ - stack-scoped container volumes for k0s state and pod logs;
7
7
  - an in-cluster, pinned OCI registry exposed to the host only through loopback;
8
8
  - wasmCloud runtime operator 2.8.0 and its default HTTP host group;
9
9
  - a generic loopback HTTP entrypoint.
@@ -37,6 +37,33 @@ push address (`http://127.0.0.1:25000` by default) and cluster pull address
37
37
  (`di-framework-registry.wasmcloud.svc.cluster.local:5000`) reach the same
38
38
  registry content.
39
39
 
40
+ ## Container engine
41
+
42
+ Docker is the default. To run the k0s container with Podman (or another
43
+ Docker-compatible CLI on `PATH`), set `containerCli` before the first deployment:
44
+
45
+ ```sh
46
+ pulumi config set containerCli podman
47
+ ```
48
+
49
+ The value must be a plain command name or path. Resources stay owned by the
50
+ engine that created them, so to switch engines destroy the platform first and
51
+ deploy again; that removes cluster state.
52
+
53
+ ## Registry mirrors
54
+
55
+ To pull images through a mirror (for example when Docker Hub is rate limited or
56
+ unreachable from the container engine), set `registryMirrors` before the first
57
+ deployment. It maps a registry host to an ordered list of mirror URLs; containerd
58
+ tries each mirror and then the registry itself:
59
+
60
+ ```sh
61
+ pulumi config set --path 'registryMirrors["docker.io"][0]' https://mirror.gcr.io
62
+ ```
63
+
64
+ Unset means no mirrors. The `@di-framework/platform` README lists the accepted
65
+ values. Changing mirrors later requires destroying and redeploying the platform.
66
+
40
67
  ## Output contract
41
68
 
42
69
  | Output | Meaning |
@@ -50,6 +77,7 @@ registry content.
50
77
  | `endpoints.kubernetes` | loopback API server URL |
51
78
  | `endpoints.registry` | loopback registry URL |
52
79
  | `endpoints.http` | loopback HTTP URL |
80
+ | `kubeconfigs` | secret: `{ [tenant]: { [user]: kubeconfig } }`, one per user membership |
53
81
 
54
82
  ## Lifecycle
55
83
 
@@ -71,9 +99,14 @@ Send the configured project name as the HTTP `Host` header, for example:
71
99
  curl -H 'Host: greeter' http://127.0.0.1:28180/
72
100
  ```
73
101
 
74
- Platform destroy removes only Docker and Kubernetes resources bearing this
102
+ `pulumi up` checks the platform configuration (tenants, users, route aliases,
103
+ tenant auth, runtime NATS, insecure registries, the tenant host image) before it
104
+ creates anything, so invalid configuration fails without creating the k0s
105
+ container, network, or volumes.
106
+
107
+ Platform destroy removes only container-engine and Kubernetes resources bearing this
75
108
  project/stack scope, along with the generated kubeconfig. It refuses to adopt
76
- or replace an already-existing Docker resource with the same name. Teardown
109
+ or replace an already-existing container, network, or volume with the same name. Teardown
77
110
  uses the `kubectl` bundled in the scoped k0s container, so no host-side
78
111
  `kubectl` installation is needed for platform lifecycle commands.
79
112
 
@@ -107,8 +140,8 @@ are no additional platform CLI subcommands. Controller TypeScript is compiled to
107
140
  JavaScript when Pulumi builds its ConfigMap; no custom container build is needed.
108
141
  Run `bun run check` in this directory to check all generated TypeScript.
109
142
 
110
- Each tenant gets `di-tenant-<name>` for workloads and `di-runtime-<name>` for its
111
- host pool, Redis, and NATS. Host environments match the workload namespace, and
143
+ Each tenant gets `di-tenant-<name>` for workloads, `di-runtime-<name>` for its
144
+ host pool, Redis, and NATS, and `di-apikeys-<name>` for its API keys (no pods). Host environments match the workload namespace, and
112
145
  `allowSharedHosts` is false. Runtime certificates remain in the runtime namespace.
113
146
  Pulumi seeds these namespaces before Helm so the wasmCloud operator can watch
114
147
  host pods there; the controller then manages their resources and lifecycle.
@@ -119,7 +152,8 @@ objects. Increase `resources.cpu` and `resources.memory` when increasing
119
152
  `runtime.replicas`; these quotas cover runtime pods and aggregate
120
153
  `requests.storage` (50Gi hard) for stock and future `di-bs-*` backends, not
121
154
  individual Wasm invocations. Override concurrent service/binding counts with
122
- `resources.backingServices` / `resources.serviceBindings`.
155
+ `resources.backingServices` / `resources.serviceBindings`. A tenant may hold
156
+ 1000 API keys; override with `resources.apiKeys` (1–10000).
123
157
 
124
158
  Users get a ServiceAccount in `wasmcloud` and tenant RoleBindings. Developers
125
159
  can manage WorkloadDeployments, `BackingService`, `ServiceBinding`, ConfigMaps,
@@ -135,19 +169,22 @@ tenant; the platform does **not** claim finer credential isolation. Admission
135
169
  still blocks CLI/API bypass for forged hostInterfaces and mutation of
136
170
  controller-managed config (see `@di-framework/platform` README).
137
171
 
138
- As administrator, use the platform kubeconfig to issue an expiring user token:
172
+ Each membership gets a kubeconfig built from a controller-managed ServiceAccount
173
+ token Secret (`di-user-<user>-<tenant>-token` in `wasmcloud`), with the loopback API
174
+ server, the cluster CA, and the tenant workload namespace selected. Pulumi reads it
175
+ once the User is Ready and exports it in the secret `kubeconfigs` output:
139
176
 
140
177
  ```sh
141
- export KUBECONFIG="$(pulumi stack output kubeconfig)"
142
- kubectl create token di-user-alice -n wasmcloud --duration=8h
178
+ pulumi stack output kubeconfigs --show-secrets | jq -r '.warehouse.alice' > alice.kubeconfig
179
+ chmod 600 alice.kubeconfig
143
180
  ```
144
181
 
145
- Build the user's kubeconfig with the same cluster server and CA from the admin
146
- kubeconfig, this token as its **only** credential, and the tenant workload namespace
147
- as its context namespace. Do not distribute the admin kubeconfig or its client
148
- certificate/key. Kubernetes may shorten the requested token lifetime. Tokens are
149
- never stored in User status or Pulumi outputs. The `users` output identifies the
150
- ServiceAccount; `tenants` identifies the namespaces and host group.
182
+ The token is the kubeconfig's **only** credential; do not distribute the admin
183
+ kubeconfig or its client certificate/key. `viewer` users get read-only access.
184
+ The token does not expire: removing the membership or suspending the user deletes
185
+ its Secret and invalidates it. Tokens are never stored in User status. The `users`
186
+ output identifies the ServiceAccount; `tenants` identifies the namespaces and host
187
+ group.
151
188
 
152
189
  Configure a deployment target with the user's kubeconfig and `tenant = "warehouse"`,
153
190
  which selects `namespace = "di-tenant-warehouse"` and `hostgroup = "tenant-warehouse"`:
@@ -171,8 +208,11 @@ For shared tenant keyvalue storage, reference the controller-managed ConfigMap
171
208
  services use ConfigMaps named `di-bs-*` and binding-projected Secrets/ConfigMaps
172
209
  named `di-binding-*` (#450/#451). The warehouse's HTTP, Redis, and NATS sync flow
173
210
  has been verified on wash 2.8.0. The platform default host image is
174
- `ghcr.io/di-framework/wash:2.8.0-wasi-tls@sha256:ee89fd4bce4f9f35f4cd09c63d3cbdd07bea3071b5d372f82c9f49b9741c3669`,
175
- which links `wasi:tls`. Native keyvalue needs no custom image. The warehouse uses this same ConfigMap reference
211
+ `ghcr.io/di-framework/wash:2.8.0-wasi-tls@sha256:d88158b0b09edd9fc3e79d787762697c60f65baf134d895529e85d6c47cd80ad`,
212
+ which links `wasi:tls` (and `ghcr.io/di-framework/wash:2.8.0-wasi-tls-exclusive@sha256:0ee414e9db4b0d4fc923eb477f1b1afd20f707b8ab3e552957575ff4f8e6a528`
213
+ adds the exclusive-instance patch); the tenant host pin PR moves it with each canonical host publish, so an
214
+ install without `tenantHostImage` moves its tenant hosts on the first deploy of a release that
215
+ contains that pin (set `tenantHostImage` to a digest to hold a build). Native keyvalue needs no custom image. The warehouse uses this same ConfigMap reference
176
216
  in its external-cluster setup. Messaging uses the tenant's dedicated NATS backend.
177
217
  Tenant admission restricts native interfaces, forbids host volumes and guest
178
218
  network capabilities, and reserves `di-tenant-stock`, `di-bs-*`, and
@@ -202,6 +242,15 @@ registries, production storage, and stronger resource accounting are separate
202
242
  work. Namespace NetworkPolicies require an enforcing CNI (the generated k0s
203
243
  cluster uses kube-router). `tenantHostImage` and `tenantHostImagePullPolicy`
204
244
  override the default wasi-tls host image when a stack needs a different runtime.
245
+ `insecureRegistry` gives only the platform host group `--allow-insecure-registries`;
246
+ tenant hosts never run `--allow-insecure-registries` and instead get
247
+ `--insecure-registry <host:port>` for the local platform registry (and each
248
+ `insecureRegistries` entry on existing-cluster installs when `insecureRegistry`
249
+ is enabled), so their other pulls stay TLS: an override image must be built
250
+ with wash patch 0002 (see `platform/tenant-host/README.md` in the platform
251
+ repository). `createPlatform` refuses the one published pre-0002 digest up front;
252
+ other older builds (for example locally built images) reject that argument and
253
+ the tenant hosts crash-loop.
205
254
 
206
255
  ## Shared implementation
207
256
 
@@ -213,7 +262,7 @@ changes belong in the shared package rather than copied tenancy files.
213
262
  Backing-service CRD contracts (`BackingServiceClass`, `BackingService`,
214
263
  `ServiceBinding`), authorization boundaries, and runtime feasibility notes live in
215
264
  the `@di-framework/platform` package README. Platform install seeds the approved
216
- default classes (`keyvalue-redis`, `messaging-nats`), retains CRDs on stack destroy,
265
+ default classes (`keyvalue-redis`, `messaging-nats`, `blobstore-nats`, `postgres-dedicated`, `egress-public`), retains CRDs on stack destroy,
217
266
  ships compiled controller scripts including `backing-services.js`, and enforces
218
267
  tenant RBAC / admission / quotas / backend NetworkPolicy isolation (#452).
219
268
 
@@ -1,2 +1,2 @@
1
1
  // Platform implementation is shared with di-framework-kube.
2
- export { schemaVersion, kubeconfig, namespace, registry, endpoints, tenants, users } from '@di-framework/platform/local';
2
+ export { schemaVersion, kubeconfig, namespace, registry, endpoints, tenants, users, kubeconfigs } from '@di-framework/platform/local';
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
- "module": "commonjs",
5
- "moduleResolution": "node",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
6
6
  "strict": true,
7
7
  "esModuleInterop": true,
8
8
  "skipLibCheck": true
@@ -1,6 +1,6 @@
1
1
  component: di-framework:sqlite@0.1.0
2
2
  profile: release
3
- built: 2026-10-12T03:40:28Z
3
+ built: 2026-11-06T23:16:01Z
4
4
  rustc: rustc 1.97.1 (8bab26f4f 2026-07-14)
5
5
  target: wasm32-wasip2
6
6
  wasi-sdk: 34.0
package/dist/build.d.ts CHANGED
@@ -17,13 +17,36 @@ export type BuildSummary = {
17
17
  profile: string;
18
18
  actors?: string[];
19
19
  /** The composed PGlite provider: where it came from and, when pulled, its pinned image. */
20
- pglite?: {
21
- source: ResolvedPglite['source'];
22
- image?: string;
23
- path?: string;
20
+ pglite?: ComponentOrigin & {
21
+ /** The encryption layer plugged into the provider, from `pglite.encryption`. */
22
+ encryption?: ComponentOrigin;
24
23
  };
25
24
  };
25
+ /** Where a composed component came from: a digest pin (pulled or cached) or a local file. */
26
+ export type ComponentOrigin = {
27
+ source: ResolvedPglite['source'];
28
+ image?: string;
29
+ path?: string;
30
+ };
26
31
  export declare function requirementsForProject(project: WasmcloudProject, deps?: WasmcloudDeps): WitRequirement[];
32
+ /**
33
+ * Composes the encryption layer into the provider and writes the result to `output`, which the
34
+ * build then plugs into the guest instead of the provider.
35
+ *
36
+ * `wac plug` silently skips a layer export whose name matches but whose type is not a subtype of
37
+ * the provider's import, and exits 0 when anything else plugged, so it cannot prove the layer is
38
+ * in the path. Instead the build reads both worlds with `jco wit`, plans which layer export each
39
+ * provider import takes (every `wasi:filesystem/*` import must have one), and composes a WAC
40
+ * document that passes each of them as a named instantiation argument (`wac compose`). wac
41
+ * type-checks every argument, so a layer that does not fit fails the build here rather than
42
+ * being bypassed. The document is kept at `.di-framework/pglite-encryption.wac`.
43
+ *
44
+ * Wiring cannot show that the layer encrypts: a pass-through layer wires the same way. So the
45
+ * layer must also carry the platform's `di-framework:pglite-encfs` custom section. That marker
46
+ * catches the wrong artifact (a no-op or debug layer, a stale local build); it is forgeable, so
47
+ * what the layer actually does rests on the digest pin.
48
+ */
49
+ export declare function encryptProvider(project: Pick<WasmcloudProject, 'projectRoot' | 'applicationName'>, deps: WasmcloudDeps, io: CliIo, provider: string, layer: string, output: string): Promise<void>;
27
50
  /** The disposable `.di-framework/` build directory: WIT world, bundle, and manifests. */
28
51
  export declare function buildComponent(project: WasmcloudProject, io: CliIo, deps: WasmcloudDeps, options?: {
29
52
  guestLogging?: boolean;