@wildo-ai/wildo-cli 1.1.3 → 1.1.4
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/src/commands/context/__tests__/assurance-basis.command.test.d.ts +2 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.d.ts.map +1 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.js +63 -0
- package/dist/src/commands/context/__tests__/assurance-basis.command.test.js.map +1 -0
- package/dist/src/commands/context/assurance-basis.command.d.ts +61 -0
- package/dist/src/commands/context/assurance-basis.command.d.ts.map +1 -0
- package/dist/src/commands/context/assurance-basis.command.js +166 -0
- package/dist/src/commands/context/assurance-basis.command.js.map +1 -0
- package/dist/src/commands/dev/charts-audit.command.d.ts +5 -3
- package/dist/src/commands/dev/charts-audit.command.d.ts.map +1 -1
- package/dist/src/commands/dev/charts-audit.command.js +35 -6
- package/dist/src/commands/dev/charts-audit.command.js.map +1 -1
- package/dist/src/commands/fwk/generate-providers.command.d.ts.map +1 -1
- package/dist/src/commands/fwk/generate-providers.command.js +18 -2
- package/dist/src/commands/fwk/generate-providers.command.js.map +1 -1
- package/dist/src/commands/generate/email-preview.command.d.ts +8 -0
- package/dist/src/commands/generate/email-preview.command.d.ts.map +1 -1
- package/dist/src/commands/generate/email-preview.command.js +57 -0
- package/dist/src/commands/generate/email-preview.command.js.map +1 -1
- package/dist/src/commands/init.command.d.ts.map +1 -1
- package/dist/src/commands/init.command.js +32 -0
- package/dist/src/commands/init.command.js.map +1 -1
- package/dist/src/commands/lock/check.command.d.ts.map +1 -1
- package/dist/src/commands/lock/check.command.js +3 -2
- package/dist/src/commands/lock/check.command.js.map +1 -1
- package/dist/src/commands/registry/login.command.d.ts.map +1 -1
- package/dist/src/commands/registry/login.command.js +2 -0
- package/dist/src/commands/registry/login.command.js.map +1 -1
- package/dist/src/commands/registry/publish.command.d.ts.map +1 -1
- package/dist/src/commands/registry/publish.command.js +2 -0
- package/dist/src/commands/registry/publish.command.js.map +1 -1
- package/dist/src/commands/registry/registry-transport.constants.d.ts +33 -0
- package/dist/src/commands/registry/registry-transport.constants.d.ts.map +1 -0
- package/dist/src/commands/registry/registry-transport.constants.js +33 -0
- package/dist/src/commands/registry/registry-transport.constants.js.map +1 -0
- package/dist/src/commands/registry/whoami.command.d.ts.map +1 -1
- package/dist/src/commands/registry/whoami.command.js +2 -0
- package/dist/src/commands/registry/whoami.command.js.map +1 -1
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts +2 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.d.ts.map +1 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js +146 -0
- package/dist/src/modules/domain/credentials/__tests__/approver-user.module.test.js.map +1 -0
- package/dist/src/modules/domain/credentials/approver-user.module.d.ts +85 -0
- package/dist/src/modules/domain/credentials/approver-user.module.d.ts.map +1 -0
- package/dist/src/modules/domain/credentials/approver-user.module.js +92 -0
- package/dist/src/modules/domain/credentials/approver-user.module.js.map +1 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts +2 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.d.ts.map +1 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js +111 -0
- package/dist/src/services/application/__tests__/app-bootstrap.approving-administrator.test.js.map +1 -0
- package/dist/src/services/application/__tests__/provider-package-links.service.test.js +68 -0
- package/dist/src/services/application/__tests__/provider-package-links.service.test.js.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.d.ts +9 -0
- package/dist/src/services/application/app-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/app-bootstrap.service.js +30 -1
- package/dist/src/services/application/app-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts +6 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/application/application-runtime-bootstrap.service.js +41 -0
- package/dist/src/services/application/application-runtime-bootstrap.service.js.map +1 -1
- package/dist/src/services/application/provider-package-links.service.d.ts +30 -0
- package/dist/src/services/application/provider-package-links.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-package-links.service.js +35 -3
- package/dist/src/services/application/provider-package-links.service.js.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.d.ts.map +1 -1
- package/dist/src/services/application/provider-runtime-sync.service.js +4 -3
- package/dist/src/services/application/provider-runtime-sync.service.js.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.d.ts.map +1 -1
- package/dist/src/services/application/saas-skeleton.service.js +22 -2
- package/dist/src/services/application/saas-skeleton.service.js.map +1 -1
- package/dist/src/services/companion/workbench-cli.service.js +10 -1
- package/dist/src/services/companion/workbench-cli.service.js.map +1 -1
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts +2 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.d.ts.map +1 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js +94 -0
- package/dist/src/services/credentials/__tests__/provider-contribution-registration.guard.test.js.map +1 -0
- package/dist/src/services/credentials/ci-secrets-adapter.service.d.ts.map +1 -1
- package/dist/src/services/credentials/ci-secrets-adapter.service.js +16 -0
- package/dist/src/services/credentials/ci-secrets-adapter.service.js.map +1 -1
- package/dist/src/services/credentials/composed-provider-catalogue.d.ts +34 -0
- package/dist/src/services/credentials/composed-provider-catalogue.d.ts.map +1 -1
- package/dist/src/services/credentials/composed-provider-catalogue.js +35 -0
- package/dist/src/services/credentials/composed-provider-catalogue.js.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.d.ts +27 -0
- package/dist/src/services/credentials/credentials.schemas.d.ts.map +1 -1
- package/dist/src/services/credentials/credentials.schemas.js +50 -0
- package/dist/src/services/credentials/credentials.schemas.js.map +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.d.ts +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.d.ts.map +1 -1
- package/dist/src/services/credentials/framework-managed-secrets.js +49 -8
- package/dist/src/services/credentials/framework-managed-secrets.js.map +1 -1
- package/dist/src/services/deployment/infra-writer.service.d.ts.map +1 -1
- package/dist/src/services/deployment/infra-writer.service.js +23 -4
- package/dist/src/services/deployment/infra-writer.service.js.map +1 -1
- package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js +45 -2
- package/dist/src/services/deployment/k8s/__tests__/k8s-bootstrap.service.test.js.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts +23 -0
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.d.ts.map +1 -1
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js +49 -6
- package/dist/src/services/deployment/k8s/k8s-bootstrap.service.js.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.d.ts.map +1 -1
- package/dist/src/services/environment/env-vars-builder.service.js +19 -0
- package/dist/src/services/environment/env-vars-builder.service.js.map +1 -1
- package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js +8 -0
- package/dist/src/services/framework/__tests__/engine-provider-specifications.reconciliation.test.js.map +1 -1
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js +17 -0
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.live.contract.test.js.map +1 -1
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js +51 -0
- package/dist/src/services/framework/__tests__/framework-knowledge-audit.service.test.js.map +1 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.d.ts +41 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.d.ts.map +1 -1
- package/dist/src/services/framework/framework-knowledge-audit.service.js +90 -0
- package/dist/src/services/framework/framework-knowledge-audit.service.js.map +1 -1
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts +2 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.d.ts.map +1 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js +100 -0
- package/dist/src/services/framework/provider-transposition/__tests__/base-url-is-a-declared-env-slot.test.js.map +1 -0
- package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js +55 -2
- package/dist/src/services/framework/provider-transposition/__tests__/plan-matches-emit.test.js.map +1 -1
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts +9 -0
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.d.ts.map +1 -1
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.js +139 -19
- package/dist/src/services/framework/provider-transposition/provider-package.emitter.js.map +1 -1
- package/dist/src/services/frontend/cloudflare-cdn.service.d.ts.map +1 -1
- package/dist/src/services/frontend/cloudflare-cdn.service.js +33 -2
- package/dist/src/services/frontend/cloudflare-cdn.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -17
- package/scripts/app-dependency-alignment/propagated-engine-overrides.json +13 -0
- package/templates/infra/docker-compose/docker-compose.wildo-platform.yml.hbs +64 -16
- package/templates/saas/engine-peer-closure.json +12 -0
- package/templates/saas/scenarios/add-provider/scenario.json +11 -11
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/docusaurus.config.ts.hbs +34 -0
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/pages/auth/exchange.tsx +24 -1
- package/templates/saas/scenarios/add-technical-doc/files/technical-doc/src/theme/Root.tsx +22 -2
- package/templates/saas/skeleton/backend-api/package.json.hbs +1 -1
- package/templates/saas/skeleton/backend-api/src/companion-exports.ts +13 -2
- package/wildo-framework.info.json +1 -1
- package/templates/saas/scenarios/add-backend-provider/scenario.json +0 -17
- package/templates/saas/skeleton/backend-api/src/provider-contributions.ts +0 -44
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.command.js","sourceRoot":"","sources":["../../../../../../src/commands/registry/publish.command.ts"],"names":[],"m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C,MAAM,IAAI,GAAG,CAAC,UAAU,QAAQ,UAAU,GAAG;SAC9E,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * `wildo registry publish [--manifest <path>]` — package the local\n * SaaS app's module source and publish it to a registry. Aliased as\n * `wildo publish`.\n *\n * Pipeline:\n * 1. Read the module manifest from `<saasRoot>/wildo.module.json`\n * (or the path supplied via `--manifest`); validates against\n * `ModuleManifestSchema`.\n * 2. `ModulePackagerService.stageFresh(saasRoot, manifest.id)` —\n * wipes + recreates the per-module staging root.\n * 3. For each declared `boundaries.<layer>` directory, walk the\n * app source tree and `ModulePackagerService.copyFile` every\n * file into staging (KD-12 boundary enforcement happens here —\n * a file outside any declared boundary is rejected).\n * 4. `ModulePackagerService.writeManifest` — drops the validated\n * manifest at `wildo.module.json` inside the staging root.\n * 5. `createZipFromDir(stagingRoot)` — yazl-built deterministic\n * zip (sorted file order, epoch mtime so byte output is\n * reproducible across machines).\n * 6. POST the bytes (base64 in JSON) to\n * `<registry>/v1/registry/:domain/modules/:moduleId/:version`.\n * Auth via the per-machine credential for the resolved registry\n * URL — publishing requires an `ORG_ADMIN`-roled api-key.\n *\n * The registry server's controller computes its own `sha256:<hex>`\n * over the received bytes and stores it as the version's integrity;\n * future `wildo registry add` invocations verify against that digest\n * (KD-9, non-negotiable).\n */\n\nimport { promises as fs } from 'node:fs';\nimport type { Dirent } from 'node:fs';\nimport * as path from 'node:path';\nimport { BaseCommand } from '~wildo-cli/kernel/base-command';\nimport { CommandCategory } from '~wildo-cli/kernel/types';\nimport type { CommandMeta, CommandContext, CommandResult } from '~wildo-cli/kernel/types';\nimport {\n ModulePackagerService,\n} from '@wildo-ai/wildo-module-client';\nimport {\n ModuleManifestSchema,\n type ModuleManifest,\n type ModuleManifestBoundaries,\n} from '@wildo-ai/platform-config-lib';\nimport { RegistryCredentialsService } from '~wildo-cli/services/registry/registry-credentials.service';\nimport {\n requireSaasRoot,\n resolveRegistryUrlForCommand,\n} from '~wildo-cli/services/registry/registry-command.utils';\nimport { createZipFromDir } from '~wildo-cli/services/registry/artifact-extractor.utils';\n\nconst DEFAULT_MANIFEST_FILE = 'wildo.module.json';\n\nasync function readManifest(manifestPath: string): Promise<ModuleManifest> {\n const raw = await fs.readFile(manifestPath, 'utf8');\n const parsed = JSON.parse(raw) as unknown;\n return ModuleManifestSchema.parse(parsed);\n}\n\nasync function walkFiles(rootAbs: string, prefix = ''): Promise<string[]> {\n // Pin the entry type to `Dirent` (non-generic — @types/node aliases this\n // to `Dirent<string>`) rather than `Awaited<ReturnType<typeof fs.readdir>>`\n // which resolves to the broadest overload (`Dirent<NonSharedBuffer>[]`)\n // and breaks `entry.name`-as-string consumers below.\n let entries: Dirent[];\n try {\n entries = await fs.readdir(path.join(rootAbs, prefix), { withFileTypes: true });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw err;\n }\n const out: string[] = [];\n for (const entry of entries) {\n const rel = path.join(prefix, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await walkFiles(rootAbs, rel)));\n } else if (entry.isFile()) {\n out.push(rel);\n }\n }\n return out;\n}\n\nfunction flattenBoundaries(boundaries: ModuleManifestBoundaries | undefined): string[] {\n if (!boundaries) return [];\n return [\n ...boundaries.specifications,\n ...boundaries.shared,\n ...boundaries.frontend,\n ...boundaries.backend,\n ...boundaries.minions,\n ...boundaries.workers,\n ];\n}\n\nfunction extractDomain(moduleId: string): { domain: string; localId: string } {\n const slashIdx = moduleId.indexOf('/');\n if (slashIdx <= 0 || slashIdx === moduleId.length - 1) {\n throw new Error(\n `manifest.id \"${moduleId}\" must be in <domain>/<name> form (e.g. \"acme/billing\").`,\n );\n }\n return { domain: moduleId.slice(0, slashIdx), localId: moduleId };\n}\n\nexport default class RegistryPublishCommand extends BaseCommand {\n readonly meta: CommandMeta = {\n name: 'registry publish',\n description: 'Package the local module source and publish it to a registry.',\n category: CommandCategory.Registry,\n aliases: ['publish'],\n flags: {\n registry: {\n type: 'string',\n description: 'Registry id, URL, or alias. Default resolved like `wildo registry login`.',\n },\n manifest: {\n type: 'string',\n description: `Path to the module manifest. Default: \\`<saasRoot>/${DEFAULT_MANIFEST_FILE}\\`.`,\n },\n domain: {\n type: 'string',\n description:\n 'Override the domain segment used in the publish URL. Default: derived from `manifest.id` (`<domain>/<name>`).',\n },\n },\n };\n\n async run(ctx: CommandContext): Promise<CommandResult> {\n const saasRoot = requireSaasRoot(ctx, 'publish');\n const manifestPath = path.resolve(\n saasRoot,\n (ctx.flags.manifest as string | undefined) ?? DEFAULT_MANIFEST_FILE,\n );\n\n let manifest: ModuleManifest;\n try {\n manifest = await readManifest(manifestPath);\n } catch (err) {\n return {\n success: false,\n message: `Failed to read manifest at ${manifestPath}: ${(err as Error).message}`,\n };\n }\n ctx.log.info(`[registry publish] manifest → ${manifest.id}@${manifest.version}`);\n\n const flag = ctx.flags.registry as string | undefined;\n const resolved = await resolveRegistryUrlForCommand(ctx, { flag, saasRoot });\n const credential = await RegistryCredentialsService.get(resolved.url);\n if (!credential) {\n return {\n success: false,\n message: `Not logged in to ${resolved.url}. Run \\`wildo registry login --registry ${flag ?? resolved.url}\\` (publishing requires an ORG_ADMIN api-key).`,\n };\n }\n\n // Stage fresh + collect every file under each declared boundary.\n const stagingPaths = await ModulePackagerService.stageFresh(saasRoot, manifest.id);\n const boundaryDirs = flattenBoundaries(manifest.boundaries);\n if (boundaryDirs.length === 0) {\n return {\n success: false,\n message: 'manifest.boundaries declares no directories — nothing to publish.',\n };\n }\n // Dedupe overlapping boundary dirs: if `boundaries.frontend` and\n // `boundaries.shared` overlap (e.g. `app/src` + `app/src/shared`),\n // a naive walk visits the inner-tree files twice and inflates the\n // staging-tree byte ordering. Collect unique app-relative paths\n // first, then call `copyFile` once per unique path.\n const uniquePaths = new Set<string>();\n for (const boundaryDir of boundaryDirs) {\n const filesUnder = await walkFiles(path.resolve(saasRoot, boundaryDir));\n for (const rel of filesUnder) {\n uniquePaths.add(path.posix.join(\n boundaryDir.split(path.sep).join(path.posix.sep),\n rel.split(path.sep).join(path.posix.sep),\n ));\n }\n }\n let copiedCount = 0;\n for (const appRelativePath of uniquePaths) {\n await ModulePackagerService.copyFile({\n saasRoot,\n moduleId: manifest.id,\n appRelativePath,\n manifest,\n });\n copiedCount += 1;\n }\n ctx.log.success(` staged ${copiedCount} file(s) → ${path.relative(saasRoot, stagingPaths.stagingRoot)}/`);\n\n await ModulePackagerService.writeManifest({ saasRoot, manifest });\n\n // Build the deterministic zip.\n const zipBytes = await createZipFromDir(stagingPaths.stagingRoot);\n ctx.log.info(` zipped → ${zipBytes.byteLength} bytes`);\n\n // POST to the registry's publish endpoint.\n const explicitDomain = (ctx.flags.domain as string | undefined) ?? extractDomain(manifest.id).domain;\n const publishUrl =\n `${resolved.url.replace(/\\/+$/, '')}/v1/registry/${encodeURIComponent(explicitDomain)}` +\n `/modules/${encodeURIComponent(manifest.id)}/${encodeURIComponent(manifest.version)}`;\n const res = await fetch(publishUrl, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n authorization: `Bearer ${credential.rawToken}`,\n },\n body: JSON.stringify({\n manifest,\n artifactBase64: Buffer.from(zipBytes).toString('base64'),\n }),\n });\n\n if (res.status === 201) {\n const body = (await res.json()) as { version?: string; integrity?: string };\n await RegistryCredentialsService.touch(resolved.url);\n ctx.log.success(\n `Published ${manifest.id}@${body.version ?? manifest.version} (integrity ${body.integrity ?? '?'})`,\n );\n return { success: true, message: 'Publish successful.' };\n }\n if (res.status === 409) {\n const body = (await res.json().catch(() => ({}))) as { detail?: string };\n return {\n success: false,\n message: `Version is immutable — refusing to republish (${body.detail ?? '409'}). Bump \\`manifest.version\\` and try again.`,\n };\n }\n if (res.status === 401 || res.status === 403) {\n return {\n success: false,\n message: `Auth rejected (${res.status}). The api-key may lack the ORG_ADMIN role required to publish into this domain.`,\n };\n }\n return {\n success: false,\n message: `Publish failed (${res.status} ${res.statusText}) at ${publishUrl}.`,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3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O;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,kBAAkB,GAAG,CAAC,MAAM,kFAAkF;aACxH,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,mBAAmB,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,UAAU,QAAQ,UAAU,GAAG;SAC9E,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * `wildo registry publish [--manifest <path>]` — package the local\n * SaaS app's module source and publish it to a registry. Aliased as\n * `wildo publish`.\n *\n * Pipeline:\n * 1. Read the module manifest from `<saasRoot>/wildo.module.json`\n * (or the path supplied via `--manifest`); validates against\n * `ModuleManifestSchema`.\n * 2. `ModulePackagerService.stageFresh(saasRoot, manifest.id)` —\n * wipes + recreates the per-module staging root.\n * 3. For each declared `boundaries.<layer>` directory, walk the\n * app source tree and `ModulePackagerService.copyFile` every\n * file into staging (KD-12 boundary enforcement happens here —\n * a file outside any declared boundary is rejected).\n * 4. `ModulePackagerService.writeManifest` — drops the validated\n * manifest at `wildo.module.json` inside the staging root.\n * 5. `createZipFromDir(stagingRoot)` — yazl-built deterministic\n * zip (sorted file order, epoch mtime so byte output is\n * reproducible across machines).\n * 6. POST the bytes (base64 in JSON) to\n * `<registry>/v1/registry/:domain/modules/:moduleId/:version`.\n * Auth via the per-machine credential for the resolved registry\n * URL — publishing requires an `ORG_ADMIN`-roled api-key.\n *\n * The registry server's controller computes its own `sha256:<hex>`\n * over the received bytes and stores it as the version's integrity;\n * future `wildo registry add` invocations verify against that digest\n * (KD-9, non-negotiable).\n */\n\nimport { promises as fs } from 'node:fs';\nimport type { Dirent } from 'node:fs';\nimport * as path from 'node:path';\nimport { BaseCommand } from '~wildo-cli/kernel/base-command';\nimport { CommandCategory } from '~wildo-cli/kernel/types';\nimport type { CommandMeta, CommandContext, CommandResult } from '~wildo-cli/kernel/types';\nimport {\n ModulePackagerService,\n} from '@wildo-ai/wildo-module-client';\nimport {\n ModuleManifestSchema,\n type ModuleManifest,\n type ModuleManifestBoundaries,\n} from '@wildo-ai/platform-config-lib';\nimport { RegistryCredentialsService } from '~wildo-cli/services/registry/registry-credentials.service';\nimport {\n requireSaasRoot,\n resolveRegistryUrlForCommand,\n} from '~wildo-cli/services/registry/registry-command.utils';\nimport { createZipFromDir } from '~wildo-cli/services/registry/artifact-extractor.utils';\nimport { REGISTRY_PUBLISH_REQUEST_TIMEOUT_MS } from './registry-transport.constants';\n\nconst DEFAULT_MANIFEST_FILE = 'wildo.module.json';\n\nasync function readManifest(manifestPath: string): Promise<ModuleManifest> {\n const raw = await fs.readFile(manifestPath, 'utf8');\n const parsed = JSON.parse(raw) as unknown;\n return ModuleManifestSchema.parse(parsed);\n}\n\nasync function walkFiles(rootAbs: string, prefix = ''): Promise<string[]> {\n // Pin the entry type to `Dirent` (non-generic — @types/node aliases this\n // to `Dirent<string>`) rather than `Awaited<ReturnType<typeof fs.readdir>>`\n // which resolves to the broadest overload (`Dirent<NonSharedBuffer>[]`)\n // and breaks `entry.name`-as-string consumers below.\n let entries: Dirent[];\n try {\n entries = await fs.readdir(path.join(rootAbs, prefix), { withFileTypes: true });\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];\n throw err;\n }\n const out: string[] = [];\n for (const entry of entries) {\n const rel = path.join(prefix, entry.name);\n if (entry.isDirectory()) {\n out.push(...(await walkFiles(rootAbs, rel)));\n } else if (entry.isFile()) {\n out.push(rel);\n }\n }\n return out;\n}\n\nfunction flattenBoundaries(boundaries: ModuleManifestBoundaries | undefined): string[] {\n if (!boundaries) return [];\n return [\n ...boundaries.specifications,\n ...boundaries.shared,\n ...boundaries.frontend,\n ...boundaries.backend,\n ...boundaries.minions,\n ...boundaries.workers,\n ];\n}\n\nfunction extractDomain(moduleId: string): { domain: string; localId: string } {\n const slashIdx = moduleId.indexOf('/');\n if (slashIdx <= 0 || slashIdx === moduleId.length - 1) {\n throw new Error(\n `manifest.id \"${moduleId}\" must be in <domain>/<name> form (e.g. \"acme/billing\").`,\n );\n }\n return { domain: moduleId.slice(0, slashIdx), localId: moduleId };\n}\n\nexport default class RegistryPublishCommand extends BaseCommand {\n readonly meta: CommandMeta = {\n name: 'registry publish',\n description: 'Package the local module source and publish it to a registry.',\n category: CommandCategory.Registry,\n aliases: ['publish'],\n flags: {\n registry: {\n type: 'string',\n description: 'Registry id, URL, or alias. Default resolved like `wildo registry login`.',\n },\n manifest: {\n type: 'string',\n description: `Path to the module manifest. Default: \\`<saasRoot>/${DEFAULT_MANIFEST_FILE}\\`.`,\n },\n domain: {\n type: 'string',\n description:\n 'Override the domain segment used in the publish URL. Default: derived from `manifest.id` (`<domain>/<name>`).',\n },\n },\n };\n\n async run(ctx: CommandContext): Promise<CommandResult> {\n const saasRoot = requireSaasRoot(ctx, 'publish');\n const manifestPath = path.resolve(\n saasRoot,\n (ctx.flags.manifest as string | undefined) ?? DEFAULT_MANIFEST_FILE,\n );\n\n let manifest: ModuleManifest;\n try {\n manifest = await readManifest(manifestPath);\n } catch (err) {\n return {\n success: false,\n message: `Failed to read manifest at ${manifestPath}: ${(err as Error).message}`,\n };\n }\n ctx.log.info(`[registry publish] manifest → ${manifest.id}@${manifest.version}`);\n\n const flag = ctx.flags.registry as string | undefined;\n const resolved = await resolveRegistryUrlForCommand(ctx, { flag, saasRoot });\n const credential = await RegistryCredentialsService.get(resolved.url);\n if (!credential) {\n return {\n success: false,\n message: `Not logged in to ${resolved.url}. Run \\`wildo registry login --registry ${flag ?? resolved.url}\\` (publishing requires an ORG_ADMIN api-key).`,\n };\n }\n\n // Stage fresh + collect every file under each declared boundary.\n const stagingPaths = await ModulePackagerService.stageFresh(saasRoot, manifest.id);\n const boundaryDirs = flattenBoundaries(manifest.boundaries);\n if (boundaryDirs.length === 0) {\n return {\n success: false,\n message: 'manifest.boundaries declares no directories — nothing to publish.',\n };\n }\n // Dedupe overlapping boundary dirs: if `boundaries.frontend` and\n // `boundaries.shared` overlap (e.g. `app/src` + `app/src/shared`),\n // a naive walk visits the inner-tree files twice and inflates the\n // staging-tree byte ordering. Collect unique app-relative paths\n // first, then call `copyFile` once per unique path.\n const uniquePaths = new Set<string>();\n for (const boundaryDir of boundaryDirs) {\n const filesUnder = await walkFiles(path.resolve(saasRoot, boundaryDir));\n for (const rel of filesUnder) {\n uniquePaths.add(path.posix.join(\n boundaryDir.split(path.sep).join(path.posix.sep),\n rel.split(path.sep).join(path.posix.sep),\n ));\n }\n }\n let copiedCount = 0;\n for (const appRelativePath of uniquePaths) {\n await ModulePackagerService.copyFile({\n saasRoot,\n moduleId: manifest.id,\n appRelativePath,\n manifest,\n });\n copiedCount += 1;\n }\n ctx.log.success(` staged ${copiedCount} file(s) → ${path.relative(saasRoot, stagingPaths.stagingRoot)}/`);\n\n await ModulePackagerService.writeManifest({ saasRoot, manifest });\n\n // Build the deterministic zip.\n const zipBytes = await createZipFromDir(stagingPaths.stagingRoot);\n ctx.log.info(` zipped → ${zipBytes.byteLength} bytes`);\n\n // POST to the registry's publish endpoint.\n const explicitDomain = (ctx.flags.domain as string | undefined) ?? extractDomain(manifest.id).domain;\n const publishUrl =\n `${resolved.url.replace(/\\/+$/, '')}/v1/registry/${encodeURIComponent(explicitDomain)}` +\n `/modules/${encodeURIComponent(manifest.id)}/${encodeURIComponent(manifest.version)}`;\n const res = await fetch(publishUrl, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n authorization: `Bearer ${credential.rawToken}`,\n },\n body: JSON.stringify({\n manifest,\n artifactBase64: Buffer.from(zipBytes).toString('base64'),\n }),\n signal: AbortSignal.timeout(REGISTRY_PUBLISH_REQUEST_TIMEOUT_MS),\n });\n\n if (res.status === 201) {\n const body = (await res.json()) as { version?: string; integrity?: string };\n await RegistryCredentialsService.touch(resolved.url);\n ctx.log.success(\n `Published ${manifest.id}@${body.version ?? manifest.version} (integrity ${body.integrity ?? '?'})`,\n );\n return { success: true, message: 'Publish successful.' };\n }\n if (res.status === 409) {\n const body = (await res.json().catch(() => ({}))) as { detail?: string };\n return {\n success: false,\n message: `Version is immutable — refusing to republish (${body.detail ?? '409'}). Bump \\`manifest.version\\` and try again.`,\n };\n }\n if (res.status === 401 || res.status === 403) {\n return {\n success: false,\n message: `Auth rejected (${res.status}). The api-key may lack the ORG_ADMIN role required to publish into this domain.`,\n };\n }\n return {\n success: false,\n message: `Publish failed (${res.status} ${res.statusText}) at ${publishUrl}.`,\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadlines for the CLI's requests to a module REGISTRY.
|
|
3
|
+
*
|
|
4
|
+
* ## Why the CLI is bounded at all, since a person can press Ctrl-C
|
|
5
|
+
*
|
|
6
|
+
* That is a real difference from a server process and it makes the invariant weaker here, not
|
|
7
|
+
* absent. A registry is reached over the public internet, which is the one network in this system
|
|
8
|
+
* nobody operates: a peer that accepts the socket and stops talking is not a hypothetical there,
|
|
9
|
+
* it is a captive-portal, a proxy, a load balancer draining. The cost of no deadline is a command
|
|
10
|
+
* that appears to be working, so the operator waits — and the longer they have waited, the more it
|
|
11
|
+
* feels like progress they would lose by interrupting. A deadline is what turns that into a
|
|
12
|
+
* sentence they can act on.
|
|
13
|
+
*
|
|
14
|
+
* ## Two budgets, because these are not the same operation
|
|
15
|
+
*
|
|
16
|
+
* Splitting them is the point. One number for both would either cut a legitimate upload short or
|
|
17
|
+
* make an auth check feel broken, and it is exactly the "who is waiting, and for what work" question
|
|
18
|
+
* a single shared constant cannot answer.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* An auth or metadata call — `whoami`, `login`'s token check. Small JSON in both directions, so
|
|
22
|
+
* 15s is already generous; past that the registry is not answering rather than thinking, and the
|
|
23
|
+
* operator is better served by being told so.
|
|
24
|
+
*/
|
|
25
|
+
export declare const REGISTRY_AUTH_REQUEST_TIMEOUT_MS = 15000;
|
|
26
|
+
/**
|
|
27
|
+
* A PUBLISH. This carries the module's whole artifact as base64 in the request body, so unlike
|
|
28
|
+
* every other call here it spends real time moving bytes over a link whose speed we do not know —
|
|
29
|
+
* and it is the one operation where a premature abort costs the operator a rebuild rather than a
|
|
30
|
+
* retry. 5 minutes, sized for the upload rather than for the round trip.
|
|
31
|
+
*/
|
|
32
|
+
export declare const REGISTRY_PUBLISH_REQUEST_TIMEOUT_MS: number;
|
|
33
|
+
//# sourceMappingURL=registry-transport.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-transport.constants.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/registry-transport.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,gCAAgC,QAAS,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,QAAa,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deadlines for the CLI's requests to a module REGISTRY.
|
|
3
|
+
*
|
|
4
|
+
* ## Why the CLI is bounded at all, since a person can press Ctrl-C
|
|
5
|
+
*
|
|
6
|
+
* That is a real difference from a server process and it makes the invariant weaker here, not
|
|
7
|
+
* absent. A registry is reached over the public internet, which is the one network in this system
|
|
8
|
+
* nobody operates: a peer that accepts the socket and stops talking is not a hypothetical there,
|
|
9
|
+
* it is a captive-portal, a proxy, a load balancer draining. The cost of no deadline is a command
|
|
10
|
+
* that appears to be working, so the operator waits — and the longer they have waited, the more it
|
|
11
|
+
* feels like progress they would lose by interrupting. A deadline is what turns that into a
|
|
12
|
+
* sentence they can act on.
|
|
13
|
+
*
|
|
14
|
+
* ## Two budgets, because these are not the same operation
|
|
15
|
+
*
|
|
16
|
+
* Splitting them is the point. One number for both would either cut a legitimate upload short or
|
|
17
|
+
* make an auth check feel broken, and it is exactly the "who is waiting, and for what work" question
|
|
18
|
+
* a single shared constant cannot answer.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* An auth or metadata call — `whoami`, `login`'s token check. Small JSON in both directions, so
|
|
22
|
+
* 15s is already generous; past that the registry is not answering rather than thinking, and the
|
|
23
|
+
* operator is better served by being told so.
|
|
24
|
+
*/
|
|
25
|
+
export const REGISTRY_AUTH_REQUEST_TIMEOUT_MS = 15_000;
|
|
26
|
+
/**
|
|
27
|
+
* A PUBLISH. This carries the module's whole artifact as base64 in the request body, so unlike
|
|
28
|
+
* every other call here it spends real time moving bytes over a link whose speed we do not know —
|
|
29
|
+
* and it is the one operation where a premature abort costs the operator a rebuild rather than a
|
|
30
|
+
* retry. 5 minutes, sized for the upload rather than for the round trip.
|
|
31
|
+
*/
|
|
32
|
+
export const REGISTRY_PUBLISH_REQUEST_TIMEOUT_MS = 5 * 60_000;
|
|
33
|
+
//# sourceMappingURL=registry-transport.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-transport.constants.js","sourceRoot":"","sources":["../../../../src/commands/registry/registry-transport.constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,GAAG,MAAM,CAAC","sourcesContent":["/**\n * Deadlines for the CLI's requests to a module REGISTRY.\n *\n * ## Why the CLI is bounded at all, since a person can press Ctrl-C\n *\n * That is a real difference from a server process and it makes the invariant weaker here, not\n * absent. A registry is reached over the public internet, which is the one network in this system\n * nobody operates: a peer that accepts the socket and stops talking is not a hypothetical there,\n * it is a captive-portal, a proxy, a load balancer draining. The cost of no deadline is a command\n * that appears to be working, so the operator waits — and the longer they have waited, the more it\n * feels like progress they would lose by interrupting. A deadline is what turns that into a\n * sentence they can act on.\n *\n * ## Two budgets, because these are not the same operation\n *\n * Splitting them is the point. One number for both would either cut a legitimate upload short or\n * make an auth check feel broken, and it is exactly the \"who is waiting, and for what work\" question\n * a single shared constant cannot answer.\n */\n\n/**\n * An auth or metadata call — `whoami`, `login`'s token check. Small JSON in both directions, so\n * 15s is already generous; past that the registry is not answering rather than thinking, and the\n * operator is better served by being told so.\n */\nexport const REGISTRY_AUTH_REQUEST_TIMEOUT_MS = 15_000;\n\n/**\n * A PUBLISH. This carries the module's whole artifact as base64 in the request body, so unlike\n * every other call here it spends real time moving bytes over a link whose speed we do not know —\n * and it is the one operation where a premature abort costs the operator a rebuild rather than a\n * retry. 5 minutes, sized for the upload rather than for the round trip.\n */\nexport const REGISTRY_PUBLISH_REQUEST_TIMEOUT_MS = 5 * 60_000;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.command.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/whoami.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"whoami.command.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/whoami.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAS1F,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IAC5D,QAAQ,CAAC,IAAI,EAAE,WAAW,CAuBxB;IAEI,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAoFvD"}
|
|
@@ -11,6 +11,7 @@ import { BaseCommand } from '../../kernel/base-command.js';
|
|
|
11
11
|
import { CommandCategory } from '../../kernel/types.js';
|
|
12
12
|
import { RegistryWhoamiResponseSchema, WorkspaceScope } from '@wildo-ai/platform-config-lib';
|
|
13
13
|
import { RegistryCredentialsService } from '../../services/registry/registry-credentials.service.js';
|
|
14
|
+
import { REGISTRY_AUTH_REQUEST_TIMEOUT_MS } from './registry-transport.constants.js';
|
|
14
15
|
import { getSaasRootIfAvailable, resolveRegistryUrlForCommand, } from '../../services/registry/registry-command.utils.js';
|
|
15
16
|
export default class RegistryWhoamiCommand extends BaseCommand {
|
|
16
17
|
meta = {
|
|
@@ -74,6 +75,7 @@ export default class RegistryWhoamiCommand extends BaseCommand {
|
|
|
74
75
|
const res = await fetch(whoamiUrl, {
|
|
75
76
|
method: 'GET',
|
|
76
77
|
headers: { Authorization: `Bearer ${credential.rawToken}` },
|
|
78
|
+
signal: AbortSignal.timeout(REGISTRY_AUTH_REQUEST_TIMEOUT_MS),
|
|
77
79
|
});
|
|
78
80
|
if (res.status === 401) {
|
|
79
81
|
return { success: false, message: 'Stored token was rejected (401). Re-run `wildo registry login`.' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.command.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"whoami.command.js","sourceRoot":"","sources":["../../../../src/commands/registry/whoami.command.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AACvG,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,qDAAqD,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,WAAW;IACnD,IAAI,GAAgB;QAC3B,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,8DAA8D;QAC3E,QAAQ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n * Reads the per-machine credentials store, then optionally re-confirms\n * the bearer token by hitting `/v1/auth/whoami` (so the user knows the\n * token still works against the live server). Pass `--all` to list\n * every stored credential; useful when working across multiple\n * registries (per-developer local + Wildo official).\n */\n\nimport { BaseCommand } from '~wildo-cli/kernel/base-command';\nimport { CommandCategory } from '~wildo-cli/kernel/types';\nimport type { CommandMeta, CommandContext, CommandResult } from '~wildo-cli/kernel/types';\nimport { RegistryWhoamiResponseSchema, WorkspaceScope } from '@wildo-ai/platform-config-lib';\nimport { RegistryCredentialsService } from '~wildo-cli/services/registry/registry-credentials.service';\nimport { REGISTRY_AUTH_REQUEST_TIMEOUT_MS } from './registry-transport.constants';\nimport {\n getSaasRootIfAvailable,\n resolveRegistryUrlForCommand,\n} from '~wildo-cli/services/registry/registry-command.utils';\n\nexport default class RegistryWhoamiCommand extends BaseCommand {\n readonly meta: CommandMeta = {\n name: 'registry whoami',\n description: 'Show the active registry credential (org + api-key + roles).',\n category: CommandCategory.Registry,\n // H2 + 5th-pass H1: auth verb — reads the per-machine credential\n // store; no app needed and no machine-prefs file required either,\n // so `UNINITIALIZED` is the right floor (an existing credential\n // file is the only state `whoami` actually depends on).\n minimumScope: WorkspaceScope.UNINITIALIZED,\n flags: {\n registry: {\n type: 'string',\n description: 'Registry id, URL, or alias. Default resolved like `wildo registry login`.',\n },\n all: {\n type: 'boolean',\n description: 'List every stored credential.',\n },\n verify: {\n type: 'boolean',\n description: 'Re-confirm the credential against `/v1/auth/whoami` on the registry server.',\n },\n },\n };\n\n async run(ctx: CommandContext): Promise<CommandResult> {\n if (ctx.flags.all) {\n const all = await RegistryCredentialsService.list();\n if (all.length === 0) {\n return { success: false, message: 'No credentials stored.' };\n }\n for (const c of all) {\n ctx.log.info(\n `${c.registryUrl} → org=${c.organizationId ?? '?'} ` +\n `apiKey=${c.apiKeyName ?? c.apiKeyId ?? '?'} ` +\n `(lastUsedAt=${c.lastUsedAt ?? 'never'})`,\n );\n }\n return { success: true, message: `${all.length} credential(s) stored.` };\n }\n\n const flag = ctx.flags.registry as string | undefined;\n const resolved = await resolveRegistryUrlForCommand(ctx, {\n flag,\n saasRoot: getSaasRootIfAvailable(ctx),\n });\n const credential = await RegistryCredentialsService.get(resolved.url);\n if (!credential) {\n return {\n success: false,\n message: `Not logged in to ${resolved.url}. Run \\`wildo registry login --registry ${flag ?? resolved.url}\\`.`,\n };\n }\n\n if (!ctx.flags.verify) {\n ctx.log.info(`${resolved.url} → org=${credential.organizationId ?? '?'} apiKey=${credential.apiKeyName ?? credential.apiKeyId ?? '?'}`);\n // Touch lastUsedAt so the staleness UX (`whoami --all`) reflects\n // even read-only credential lookups.\n await RegistryCredentialsService.touch(resolved.url);\n return { success: true };\n }\n\n // Live verification.\n const whoamiUrl = `${resolved.url.replace(/\\/+$/, '')}/v1/auth/whoami`;\n const res = await fetch(whoamiUrl, {\n method: 'GET',\n headers: { Authorization: `Bearer ${credential.rawToken}` },\n signal: AbortSignal.timeout(REGISTRY_AUTH_REQUEST_TIMEOUT_MS),\n });\n if (res.status === 401) {\n return { success: false, message: 'Stored token was rejected (401). Re-run `wildo registry login`.' };\n }\n if (!res.ok) {\n return {\n success: false,\n message: `Registry whoami failed (${res.status} ${res.statusText}) at ${whoamiUrl}.`,\n };\n }\n // M11: same Zod-parse guard as `login.command.ts`.\n const parsedBody = RegistryWhoamiResponseSchema.safeParse(await res.json());\n if (!parsedBody.success) {\n return {\n success: false,\n message:\n `Registry whoami at ${whoamiUrl} returned an unexpected payload shape: ${parsedBody.error.message}.`,\n };\n }\n const body = parsedBody.data;\n // M6 (4th-pass review): the prior `touch()` call here was redundant\n // — `set()` below writes the file with a fresh `lastUsedAt` already\n // (it's an idempotent rebuild from the input — same `rawToken`\n // produces the same on-disk content modulo the timestamp). Dropped\n // the double-write.\n // L12 carry-over: refresh the cached label/roles on `--verify` so\n // the per-machine credential reflects the latest server-side\n // identity (api-key rename, role grant/revoke).\n await RegistryCredentialsService.set({\n registryUrl: resolved.url,\n rawToken: credential.rawToken,\n organizationId: body.organizationId,\n apiKeyId: body.apiKeyId,\n apiKeyName: body.apiKeyName,\n });\n ctx.log.success(\n `Verified: org=${body.organizationId} apiKey=${body.apiKeyName ?? body.apiKeyId} ` +\n `(roles: ${(body.roles ?? []).join(', ') || 'none'})`,\n );\n return { success: true };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approver-user.module.test.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/domain/credentials/__tests__/approver-user.module.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { WildoCliInitApproverEnvKeys } from '../../../../services/credentials/credentials.schemas.js';
|
|
3
|
+
import { ApproverIdentityProvenance, deriveLocalApproverIdentity, resolveApproverIdentity, } from '../../../../modules/domain/credentials/approver-user.module.js';
|
|
4
|
+
/**
|
|
5
|
+
* The SECOND administrator, and the two-person rule that makes it mandatory (#575).
|
|
6
|
+
*
|
|
7
|
+
* An application-wide access grant is approved by a platform administrator who is NOT its requester
|
|
8
|
+
* — `applicationAccessGrantApproverIsDistinct` refuses `operator === approver` and refuses an absent
|
|
9
|
+
* approver, and there is deliberately no auto-approval branch. So a platform provisioned with one
|
|
10
|
+
* administrator cannot read any application-wide surface at all, and provisioning has to produce
|
|
11
|
+
* two.
|
|
12
|
+
*
|
|
13
|
+
* What these pin is the PROVENANCE rule, because that is the part that is dangerous to get wrong:
|
|
14
|
+
* a local environment may DERIVE the second identity from the first (one developer, two accounts,
|
|
15
|
+
* one password — the two-person rule is ceremonial there and that is the accepted trade), and a
|
|
16
|
+
* remote environment must STATE it. A derivation that leaked into a remote deployment would ship a
|
|
17
|
+
* two-person control that one person satisfies, which is worse than no control because it reads as
|
|
18
|
+
* one.
|
|
19
|
+
*/
|
|
20
|
+
const ADMIN = {
|
|
21
|
+
email: 'ada@example.com',
|
|
22
|
+
firstName: 'Ada',
|
|
23
|
+
lastName: 'Lovelace',
|
|
24
|
+
password: 'operator-typed-password',
|
|
25
|
+
};
|
|
26
|
+
const log = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), success: vi.fn() };
|
|
27
|
+
function clearApproverEnv() {
|
|
28
|
+
for (const key of Object.values(WildoCliInitApproverEnvKeys))
|
|
29
|
+
delete process.env[key];
|
|
30
|
+
}
|
|
31
|
+
function stateApprover(overrides = {}) {
|
|
32
|
+
process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL] = 'grace@example.com';
|
|
33
|
+
process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_FIRSTNAME] = 'Grace';
|
|
34
|
+
process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME] = 'Hopper';
|
|
35
|
+
process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_PASSWORD] = 'grace-password';
|
|
36
|
+
for (const [key, value] of Object.entries(overrides))
|
|
37
|
+
process.env[key] = value;
|
|
38
|
+
}
|
|
39
|
+
beforeEach(clearApproverEnv);
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
clearApproverEnv();
|
|
42
|
+
vi.clearAllMocks();
|
|
43
|
+
});
|
|
44
|
+
describe('deriveLocalApproverIdentity', () => {
|
|
45
|
+
it('sub-addresses the administrator so both accounts share one mailbox', () => {
|
|
46
|
+
expect(deriveLocalApproverIdentity(ADMIN)).toEqual({
|
|
47
|
+
email: 'ada+approver@example.com',
|
|
48
|
+
firstName: 'Ada',
|
|
49
|
+
lastName: 'Lovelace',
|
|
50
|
+
password: 'operator-typed-password',
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
/*
|
|
54
|
+
* REPLACES an existing tag rather than appending. `ada+ci@x` and `ada@x` must derive the SAME
|
|
55
|
+
* approver, or a CI environment and a laptop would disagree about who the approver is while both
|
|
56
|
+
* believing they had derived one — and `ada+ci+approver@x` is a third mailbox nobody asked for.
|
|
57
|
+
*/
|
|
58
|
+
it('replaces an existing sub-address tag instead of stacking a second one', () => {
|
|
59
|
+
expect(deriveLocalApproverIdentity({ ...ADMIN, email: 'ada+ci@example.com' }).email)
|
|
60
|
+
.toBe('ada+approver@example.com');
|
|
61
|
+
});
|
|
62
|
+
/*
|
|
63
|
+
* A domain may contain `+` in no legal form, but a LOCAL part may contain `@` in a quoted string,
|
|
64
|
+
* so the split has to be on the LAST `@`. Pinned because splitting on the first is the obvious
|
|
65
|
+
* implementation and produces a domain of `example.com` from a local part that still contains one.
|
|
66
|
+
*/
|
|
67
|
+
it('splits on the last @, so a quoted local part does not corrupt the domain', () => {
|
|
68
|
+
expect(deriveLocalApproverIdentity({ ...ADMIN, email: '"ada@home"@example.com' }).email)
|
|
69
|
+
.toBe('"ada@home"+approver@example.com');
|
|
70
|
+
});
|
|
71
|
+
it('carries the administrator name through, because it is the same human', () => {
|
|
72
|
+
const derived = deriveLocalApproverIdentity(ADMIN);
|
|
73
|
+
expect([derived.firstName, derived.lastName]).toEqual([ADMIN.firstName, ADMIN.lastName]);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('resolveApproverIdentity', () => {
|
|
77
|
+
it('derives for a local environment when nothing is stated', () => {
|
|
78
|
+
const result = resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log });
|
|
79
|
+
expect(result.provenance).toBe(ApproverIdentityProvenance.DERIVED_FROM_ADMINISTRATOR);
|
|
80
|
+
expect(result.approver.email).toBe('ada+approver@example.com');
|
|
81
|
+
});
|
|
82
|
+
/*
|
|
83
|
+
* THE PIN THIS FILE EXISTS FOR. A remote deployment must never acquire the derivation, because the
|
|
84
|
+
* derived approver shares the administrator's password — so one person would hold both signatures
|
|
85
|
+
* of a two-person rule. Refusing at setup is the only place the cause is visible; discovered later
|
|
86
|
+
* it looks like a working control.
|
|
87
|
+
*/
|
|
88
|
+
it('REFUSES a non-local environment that states no approver', () => {
|
|
89
|
+
expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: false, log }))
|
|
90
|
+
.toThrow(/states no approving administrator/i);
|
|
91
|
+
});
|
|
92
|
+
it('accepts a fully stated approver in any environment', () => {
|
|
93
|
+
stateApprover();
|
|
94
|
+
for (const isLocalEnvironment of [true, false]) {
|
|
95
|
+
const result = resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment, log });
|
|
96
|
+
expect(result.provenance).toBe(ApproverIdentityProvenance.STATED);
|
|
97
|
+
expect(result.approver.email).toBe('grace@example.com');
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
/*
|
|
101
|
+
* A stated identity WINS over the derivation locally. Without this, a developer who states a real
|
|
102
|
+
* second person would silently get the sub-addressed one instead — the values would be accepted
|
|
103
|
+
* and ignored, which is the shape #566 calls "collects a change and drops it silently".
|
|
104
|
+
*/
|
|
105
|
+
it('prefers a stated approver over the local derivation', () => {
|
|
106
|
+
stateApprover();
|
|
107
|
+
expect(resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }).approver.email)
|
|
108
|
+
.toBe('grace@example.com');
|
|
109
|
+
});
|
|
110
|
+
/*
|
|
111
|
+
* A PARTIAL set is an operator mistake, never a request to fall back — the reading
|
|
112
|
+
* `init.command.ts` already applies to a partial `--admin-*` flag set. Falling through to the
|
|
113
|
+
* derivation would discard the fields that WERE supplied and hand back a different person.
|
|
114
|
+
*/
|
|
115
|
+
it('refuses a partially stated approver rather than falling back to the derivation', () => {
|
|
116
|
+
stateApprover();
|
|
117
|
+
delete process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME];
|
|
118
|
+
expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }))
|
|
119
|
+
.toThrow(/partially stated.*WILDO_INIT_APPROVER_LASTNAME/is);
|
|
120
|
+
});
|
|
121
|
+
/*
|
|
122
|
+
* Two identical identities provision ONE account and then refuse every approval, because the
|
|
123
|
+
* two-person rule compares user ids at approval time. That failure surfaces weeks later and reads
|
|
124
|
+
* as a permissions bug, so it is caught where the cause is legible.
|
|
125
|
+
*/
|
|
126
|
+
it('refuses an approver stated as the administrator themselves', () => {
|
|
127
|
+
stateApprover({ [WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL]: ADMIN.email });
|
|
128
|
+
expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }))
|
|
129
|
+
.toThrow(/must be a DIFFERENT person/i);
|
|
130
|
+
});
|
|
131
|
+
/*
|
|
132
|
+
* The administrator's password is OPTIONAL at this point — the framework mints one when the
|
|
133
|
+
* operator typed none — and the derived approver inherits that absence rather than acquiring a
|
|
134
|
+
* password of its own. That is what keeps "the same password as the administrator" true after the
|
|
135
|
+
* ADMIN_PASSWORD material fills both, instead of producing two different generated passwords.
|
|
136
|
+
*/
|
|
137
|
+
it('carries an absent administrator password through rather than minting a second one', () => {
|
|
138
|
+
const result = resolveApproverIdentity({
|
|
139
|
+
admin: { ...ADMIN, password: undefined },
|
|
140
|
+
isLocalEnvironment: true,
|
|
141
|
+
log,
|
|
142
|
+
});
|
|
143
|
+
expect(result.approver.password).toBeUndefined();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
//# sourceMappingURL=approver-user.module.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approver-user.module.test.js","sourceRoot":"","sources":["../../../../../../src/modules/domain/credentials/__tests__/approver-user.module.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,4DAA4D,CAAC;AAEpE;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,iBAAiB;IACx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aAAa,EAAE,CAAC;QAChB,OAAO,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;QAC7E,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;aACnF,OAAO,CAAC,kDAAkD,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH;;;;OAIG;IACH,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QACpE,aAAa,CAAC,EAAE,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACxF,MAAM,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;aACnF,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH;;;;;OAKG;IACH,EAAE,CAAC,mFAAmF,EAAE,GAAG,EAAE;QAC3F,MAAM,MAAM,GAAG,uBAAuB,CAAC;YACrC,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE;YACxC,kBAAkB,EAAE,IAAI;YACxB,GAAG;SACJ,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\n\nimport { WildoCliInitApproverEnvKeys } from '~wildo-cli/services/credentials/credentials.schemas';\nimport {\n ApproverIdentityProvenance,\n deriveLocalApproverIdentity,\n resolveApproverIdentity,\n} from '~wildo-cli/modules/domain/credentials/approver-user.module';\n\n/**\n * The SECOND administrator, and the two-person rule that makes it mandatory (#575).\n *\n * An application-wide access grant is approved by a platform administrator who is NOT its requester\n * — `applicationAccessGrantApproverIsDistinct` refuses `operator === approver` and refuses an absent\n * approver, and there is deliberately no auto-approval branch. So a platform provisioned with one\n * administrator cannot read any application-wide surface at all, and provisioning has to produce\n * two.\n *\n * What these pin is the PROVENANCE rule, because that is the part that is dangerous to get wrong:\n * a local environment may DERIVE the second identity from the first (one developer, two accounts,\n * one password — the two-person rule is ceremonial there and that is the accepted trade), and a\n * remote environment must STATE it. A derivation that leaked into a remote deployment would ship a\n * two-person control that one person satisfies, which is worse than no control because it reads as\n * one.\n */\n\nconst ADMIN = {\n email: 'ada@example.com',\n firstName: 'Ada',\n lastName: 'Lovelace',\n password: 'operator-typed-password',\n};\n\nconst log = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), success: vi.fn() } as never;\n\nfunction clearApproverEnv(): void {\n for (const key of Object.values(WildoCliInitApproverEnvKeys)) delete process.env[key];\n}\n\nfunction stateApprover(overrides: Partial<Record<WildoCliInitApproverEnvKeys, string>> = {}): void {\n process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL] = 'grace@example.com';\n process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_FIRSTNAME] = 'Grace';\n process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME] = 'Hopper';\n process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_PASSWORD] = 'grace-password';\n for (const [key, value] of Object.entries(overrides)) process.env[key] = value;\n}\n\nbeforeEach(clearApproverEnv);\nafterEach(() => {\n clearApproverEnv();\n vi.clearAllMocks();\n});\n\ndescribe('deriveLocalApproverIdentity', () => {\n it('sub-addresses the administrator so both accounts share one mailbox', () => {\n expect(deriveLocalApproverIdentity(ADMIN)).toEqual({\n email: 'ada+approver@example.com',\n firstName: 'Ada',\n lastName: 'Lovelace',\n password: 'operator-typed-password',\n });\n });\n\n /*\n * REPLACES an existing tag rather than appending. `ada+ci@x` and `ada@x` must derive the SAME\n * approver, or a CI environment and a laptop would disagree about who the approver is while both\n * believing they had derived one — and `ada+ci+approver@x` is a third mailbox nobody asked for.\n */\n it('replaces an existing sub-address tag instead of stacking a second one', () => {\n expect(deriveLocalApproverIdentity({ ...ADMIN, email: 'ada+ci@example.com' }).email)\n .toBe('ada+approver@example.com');\n });\n\n /*\n * A domain may contain `+` in no legal form, but a LOCAL part may contain `@` in a quoted string,\n * so the split has to be on the LAST `@`. Pinned because splitting on the first is the obvious\n * implementation and produces a domain of `example.com` from a local part that still contains one.\n */\n it('splits on the last @, so a quoted local part does not corrupt the domain', () => {\n expect(deriveLocalApproverIdentity({ ...ADMIN, email: '\"ada@home\"@example.com' }).email)\n .toBe('\"ada@home\"+approver@example.com');\n });\n\n it('carries the administrator name through, because it is the same human', () => {\n const derived = deriveLocalApproverIdentity(ADMIN);\n expect([derived.firstName, derived.lastName]).toEqual([ADMIN.firstName, ADMIN.lastName]);\n });\n});\n\ndescribe('resolveApproverIdentity', () => {\n it('derives for a local environment when nothing is stated', () => {\n const result = resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log });\n expect(result.provenance).toBe(ApproverIdentityProvenance.DERIVED_FROM_ADMINISTRATOR);\n expect(result.approver.email).toBe('ada+approver@example.com');\n });\n\n /*\n * THE PIN THIS FILE EXISTS FOR. A remote deployment must never acquire the derivation, because the\n * derived approver shares the administrator's password — so one person would hold both signatures\n * of a two-person rule. Refusing at setup is the only place the cause is visible; discovered later\n * it looks like a working control.\n */\n it('REFUSES a non-local environment that states no approver', () => {\n expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: false, log }))\n .toThrow(/states no approving administrator/i);\n });\n\n it('accepts a fully stated approver in any environment', () => {\n stateApprover();\n for (const isLocalEnvironment of [true, false]) {\n const result = resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment, log });\n expect(result.provenance).toBe(ApproverIdentityProvenance.STATED);\n expect(result.approver.email).toBe('grace@example.com');\n }\n });\n\n /*\n * A stated identity WINS over the derivation locally. Without this, a developer who states a real\n * second person would silently get the sub-addressed one instead — the values would be accepted\n * and ignored, which is the shape #566 calls \"collects a change and drops it silently\".\n */\n it('prefers a stated approver over the local derivation', () => {\n stateApprover();\n expect(resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }).approver.email)\n .toBe('grace@example.com');\n });\n\n /*\n * A PARTIAL set is an operator mistake, never a request to fall back — the reading\n * `init.command.ts` already applies to a partial `--admin-*` flag set. Falling through to the\n * derivation would discard the fields that WERE supplied and hand back a different person.\n */\n it('refuses a partially stated approver rather than falling back to the derivation', () => {\n stateApprover();\n delete process.env[WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME];\n expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }))\n .toThrow(/partially stated.*WILDO_INIT_APPROVER_LASTNAME/is);\n });\n\n /*\n * Two identical identities provision ONE account and then refuse every approval, because the\n * two-person rule compares user ids at approval time. That failure surfaces weeks later and reads\n * as a permissions bug, so it is caught where the cause is legible.\n */\n it('refuses an approver stated as the administrator themselves', () => {\n stateApprover({ [WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL]: ADMIN.email });\n expect(() => resolveApproverIdentity({ admin: ADMIN, isLocalEnvironment: true, log }))\n .toThrow(/must be a DIFFERENT person/i);\n });\n\n /*\n * The administrator's password is OPTIONAL at this point — the framework mints one when the\n * operator typed none — and the derived approver inherits that absence rather than acquiring a\n * password of its own. That is what keeps \"the same password as the administrator\" true after the\n * ADMIN_PASSWORD material fills both, instead of producing two different generated passwords.\n */\n it('carries an absent administrator password through rather than minting a second one', () => {\n const result = resolveApproverIdentity({\n admin: { ...ADMIN, password: undefined },\n isLocalEnvironment: true,\n log,\n });\n expect(result.approver.password).toBeUndefined();\n });\n});\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { AdminUserInput } from '../../../modules/domain/credentials/module.types';
|
|
2
|
+
import type { Logger } from '../../../kernel/types';
|
|
3
|
+
/**
|
|
4
|
+
* The SECOND platform administrator — the one who approves an application-wide access grant (#575).
|
|
5
|
+
*
|
|
6
|
+
* ## Why a second identity is not optional
|
|
7
|
+
*
|
|
8
|
+
* `applicationAccessGrantApproverIsDistinct` refuses `operator === approver`, and refuses an ABSENT
|
|
9
|
+
* approver too, so no system context can stand in. The application-scoped grant has deliberately no
|
|
10
|
+
* auto-approval branch — the schema explains that the per-tenant grant may auto-approve because a
|
|
11
|
+
* named tenant can opt in above it, while an application-wide grant names no tenant, so *"a grant
|
|
12
|
+
* that could approve itself would make the two-person rule ceremonial"*.
|
|
13
|
+
*
|
|
14
|
+
* A platform with one administrator therefore cannot use the widest read it offers. Not "is
|
|
15
|
+
* discouraged from" — cannot. The refusal was built and the party who discharges it never was, which
|
|
16
|
+
* is the shape `.claude/rules/administrative-continuity-floors.md` exists to catch: a block shipped
|
|
17
|
+
* without the paired path.
|
|
18
|
+
*
|
|
19
|
+
* ## Stated, or derived — never invented
|
|
20
|
+
*
|
|
21
|
+
* `admin-user.module.ts` documents at length why the administrator's identity is never a
|
|
22
|
+
* placeholder: a literal `Admin` / `User` / `noreply@example.com` silently seeds the platform-admin
|
|
23
|
+
* USER RECORD with non-meaningful identity, regressing audit trails, password-reset email and the
|
|
24
|
+
* bootstrap email-confirm flow. That doctrine binds here too, and it is why there are exactly two
|
|
25
|
+
* doors and no third:
|
|
26
|
+
*
|
|
27
|
+
* 1. **STATED** — `WILDO_INIT_APPROVER_*`, all four together. Available in every environment, and
|
|
28
|
+
* the only door for a real second person.
|
|
29
|
+
* 2. **DERIVED** — sub-addressed from the administrator the operator already supplied, for a LOCAL
|
|
30
|
+
* environment only.
|
|
31
|
+
*
|
|
32
|
+
* The derived form is not a placeholder: every field of it comes from a real identity the operator
|
|
33
|
+
* authored moments earlier. `ada@example.com` becomes `ada+approver@example.com`, which RFC 5233
|
|
34
|
+
* sub-addressing delivers to the same mailbox — so one developer can complete both legs of the
|
|
35
|
+
* ceremony without a second inbox, which is the whole point of deriving rather than prompting again.
|
|
36
|
+
*
|
|
37
|
+
* ## The local property that must never travel
|
|
38
|
+
*
|
|
39
|
+
* The derived approver shares the administrator's password, so locally ONE PERSON HOLDS BOTH
|
|
40
|
+
* SIGNATURES and the two-person rule is ceremonial there. That is the accepted trade — the
|
|
41
|
+
* alternative is a developer who cannot exercise an application-wide read at all — and it is exactly
|
|
42
|
+
* why {@link resolveApproverIdentity} takes `isLocalEnvironment` as an argument it cannot infer.
|
|
43
|
+
* A caller must SAY that it is local; nothing here guesses, and no environment acquires the
|
|
44
|
+
* derivation by default.
|
|
45
|
+
*/
|
|
46
|
+
export interface ApproverIdentityResolution {
|
|
47
|
+
readonly approver: AdminUserInput;
|
|
48
|
+
/** How the identity was obtained — reported to the operator, because the two differ in strength. */
|
|
49
|
+
readonly provenance: ApproverIdentityProvenance;
|
|
50
|
+
}
|
|
51
|
+
export declare enum ApproverIdentityProvenance {
|
|
52
|
+
/** Every field came from `WILDO_INIT_APPROVER_*`. A real second person. */
|
|
53
|
+
STATED = "stated",
|
|
54
|
+
/** Sub-addressed from the administrator, local only. One human, two accounts. */
|
|
55
|
+
DERIVED_FROM_ADMINISTRATOR = "derived-from-administrator"
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sub-address a local approver from the administrator's own identity.
|
|
59
|
+
*
|
|
60
|
+
* Exported for its own pin. The rule is the whole contract and is easy to get subtly wrong: the tag
|
|
61
|
+
* goes before the `@`, an address that ALREADY carries a `+tag` must not grow a second one (that
|
|
62
|
+
* produces `ada+ci+approver@…`, a third mailbox nobody asked for), and the name fields carry through
|
|
63
|
+
* unchanged because they describe the same human.
|
|
64
|
+
*/
|
|
65
|
+
export declare function deriveLocalApproverIdentity(admin: AdminUserInput): AdminUserInput;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the approver identity for an environment, or refuse.
|
|
68
|
+
*
|
|
69
|
+
* `isLocalEnvironment` is a required argument rather than something read from the ambient
|
|
70
|
+
* environment, so that no caller acquires the derivation by omission. A remote deployment states its
|
|
71
|
+
* approver or gets nothing — and "nothing" here is a thrown error, because an approver silently
|
|
72
|
+
* absent is a platform whose widest read stops working weeks later, at a moment nobody connects to
|
|
73
|
+
* setup.
|
|
74
|
+
*
|
|
75
|
+
* `admin.password` may be `undefined` at this point (the secrets writer mints one when the operator
|
|
76
|
+
* typed none), and the derived approver inherits that. The caller resolves both passwords from the
|
|
77
|
+
* same place afterwards, which is what keeps "same password as the administrator" true rather than
|
|
78
|
+
* approximately true.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveApproverIdentity(params: {
|
|
81
|
+
readonly admin: AdminUserInput;
|
|
82
|
+
readonly isLocalEnvironment: boolean;
|
|
83
|
+
readonly log: Logger;
|
|
84
|
+
}): ApproverIdentityResolution;
|
|
85
|
+
//# sourceMappingURL=approver-user.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approver-user.module.d.ts","sourceRoot":"","sources":["../../../../../src/modules/domain/credentials/approver-user.module.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,oGAAoG;IACpG,QAAQ,CAAC,UAAU,EAAE,0BAA0B,CAAC;CACjD;AAED,oBAAY,0BAA0B;IACpC,2EAA2E;IAC3E,MAAM,WAAW;IACjB,iFAAiF;IACjF,0BAA0B,+BAA+B;CAC1D;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAejF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC9C,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,GAAG,0BAA0B,CAmD7B"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { WildoCliInitApproverEnvKeys } from '../../../services/credentials/credentials.schemas.js';
|
|
3
|
+
export var ApproverIdentityProvenance;
|
|
4
|
+
(function (ApproverIdentityProvenance) {
|
|
5
|
+
/** Every field came from `WILDO_INIT_APPROVER_*`. A real second person. */
|
|
6
|
+
ApproverIdentityProvenance["STATED"] = "stated";
|
|
7
|
+
/** Sub-addressed from the administrator, local only. One human, two accounts. */
|
|
8
|
+
ApproverIdentityProvenance["DERIVED_FROM_ADMINISTRATOR"] = "derived-from-administrator";
|
|
9
|
+
})(ApproverIdentityProvenance || (ApproverIdentityProvenance = {}));
|
|
10
|
+
/**
|
|
11
|
+
* Sub-address a local approver from the administrator's own identity.
|
|
12
|
+
*
|
|
13
|
+
* Exported for its own pin. The rule is the whole contract and is easy to get subtly wrong: the tag
|
|
14
|
+
* goes before the `@`, an address that ALREADY carries a `+tag` must not grow a second one (that
|
|
15
|
+
* produces `ada+ci+approver@…`, a third mailbox nobody asked for), and the name fields carry through
|
|
16
|
+
* unchanged because they describe the same human.
|
|
17
|
+
*/
|
|
18
|
+
export function deriveLocalApproverIdentity(admin) {
|
|
19
|
+
const separatorIndex = admin.email.lastIndexOf('@');
|
|
20
|
+
const localPart = admin.email.slice(0, separatorIndex);
|
|
21
|
+
const domain = admin.email.slice(separatorIndex + 1);
|
|
22
|
+
// An existing `+tag` is REPLACED, not appended to: `ada+ci@x` and `ada@x` must both derive
|
|
23
|
+
// `ada+approver@x`, or a CI environment and a laptop would disagree about who the approver is
|
|
24
|
+
// while both believing they had derived one.
|
|
25
|
+
const baseLocalPart = localPart.includes('+') ? localPart.slice(0, localPart.indexOf('+')) : localPart;
|
|
26
|
+
return {
|
|
27
|
+
email: `${baseLocalPart}+approver@${domain}`,
|
|
28
|
+
firstName: admin.firstName,
|
|
29
|
+
lastName: admin.lastName,
|
|
30
|
+
password: admin.password,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve the approver identity for an environment, or refuse.
|
|
35
|
+
*
|
|
36
|
+
* `isLocalEnvironment` is a required argument rather than something read from the ambient
|
|
37
|
+
* environment, so that no caller acquires the derivation by omission. A remote deployment states its
|
|
38
|
+
* approver or gets nothing — and "nothing" here is a thrown error, because an approver silently
|
|
39
|
+
* absent is a platform whose widest read stops working weeks later, at a moment nobody connects to
|
|
40
|
+
* setup.
|
|
41
|
+
*
|
|
42
|
+
* `admin.password` may be `undefined` at this point (the secrets writer mints one when the operator
|
|
43
|
+
* typed none), and the derived approver inherits that. The caller resolves both passwords from the
|
|
44
|
+
* same place afterwards, which is what keeps "same password as the administrator" true rather than
|
|
45
|
+
* approximately true.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveApproverIdentity(params) {
|
|
48
|
+
const stated = {
|
|
49
|
+
email: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL),
|
|
50
|
+
firstName: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_FIRSTNAME),
|
|
51
|
+
lastName: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_LASTNAME),
|
|
52
|
+
password: readEnv(WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_PASSWORD),
|
|
53
|
+
};
|
|
54
|
+
const statedKeys = Object.entries(stated).filter(([, value]) => Boolean(value));
|
|
55
|
+
// A PARTIAL set is an operator mistake, never a request to fall back — the same reading
|
|
56
|
+
// `init.command.ts` applies to a partial `--admin-*` flag set. Falling through to the derivation
|
|
57
|
+
// here would silently discard the fields that WERE supplied and hand back a different person.
|
|
58
|
+
if (statedKeys.length > 0 && statedKeys.length < 4) {
|
|
59
|
+
const missing = Object.values(WildoCliInitApproverEnvKeys).filter((key) => !process.env[key]?.trim());
|
|
60
|
+
throw new Error(`The approving administrator is partially stated. Missing: ${missing.join(', ')}. `
|
|
61
|
+
+ `Set all four, or set none — a partial set would silently produce a different identity than the one intended.`);
|
|
62
|
+
}
|
|
63
|
+
if (statedKeys.length === 4) {
|
|
64
|
+
if (stated.email === params.admin.email) {
|
|
65
|
+
// The two-person rule compares USER IDs at the moment of approval, so two identical identities
|
|
66
|
+
// would provision one account and refuse every approval — a failure that surfaces far from
|
|
67
|
+
// here and reads as a permissions bug. Refuse where the cause is visible.
|
|
68
|
+
throw new Error(`${WildoCliInitApproverEnvKeys.WILDO_INIT_APPROVER_EMAIL} is the same address as the administrator's. `
|
|
69
|
+
+ `The approving administrator must be a DIFFERENT person: an application-wide access grant refuses an approver who is its own requester.`);
|
|
70
|
+
}
|
|
71
|
+
params.log.info(chalk.dim(` Approving administrator from env seeds: ${stated.email}`));
|
|
72
|
+
return {
|
|
73
|
+
approver: { email: stated.email, firstName: stated.firstName, lastName: stated.lastName, password: stated.password },
|
|
74
|
+
provenance: ApproverIdentityProvenance.STATED,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (!params.isLocalEnvironment) {
|
|
78
|
+
throw new Error(`This environment states no approving administrator. Set ${Object.values(WildoCliInitApproverEnvKeys).join(', ')}. `
|
|
79
|
+
+ `An application-wide access grant is approved by a SECOND platform administrator and refuses an approver who is its own requester, `
|
|
80
|
+
+ `so a platform with one administrator cannot read any application-wide surface. `
|
|
81
|
+
+ `Only a local environment may derive the second identity from the first, and it does so only because one developer holds both — `
|
|
82
|
+
+ `which is precisely what a real deployment must not do.`);
|
|
83
|
+
}
|
|
84
|
+
const approver = deriveLocalApproverIdentity(params.admin);
|
|
85
|
+
params.log.info(chalk.dim(` Approving administrator derived for local use: ${approver.email} (same mailbox, same password)`));
|
|
86
|
+
return { approver, provenance: ApproverIdentityProvenance.DERIVED_FROM_ADMINISTRATOR };
|
|
87
|
+
}
|
|
88
|
+
function readEnv(key) {
|
|
89
|
+
const value = process.env[key]?.trim();
|
|
90
|
+
return value && value.length > 0 ? value : undefined;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=approver-user.module.js.map
|