@zitadel/testing 0.2.0 → 0.4.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.
- package/README.md +18 -11
- package/dist/index.cjs +2 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -2
- package/dist/playwright.cjs +7 -2
- package/dist/playwright.cjs.map +1 -1
- package/dist/playwright.d.mts +5 -4
- package/dist/playwright.mjs +7 -3
- package/dist/playwright.mjs.map +1 -1
- package/dist/{session-BrSkzPpy.d.mts → session-B84nOEiv.d.mts} +28 -13
- package/dist/src-BKgcVBVj.cjs +19604 -0
- package/dist/src-BKgcVBVj.cjs.map +1 -0
- package/dist/{src-DKJ1hMV8.mjs → src-BeovWhmR.mjs} +62 -36
- package/dist/src-BeovWhmR.mjs.map +1 -0
- package/dist/supervisor.cjs +1 -1
- package/dist/supervisor.mjs +1 -1
- package/package.json +7 -5
- package/dist/src-CaG3NNMx.cjs +0 -4390
- package/dist/src-CaG3NNMx.cjs.map +0 -1
- package/dist/src-DKJ1hMV8.mjs.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { a as nextAppEnv, i as applyAppEnvTemplate } from "./handshake-CwlxMjW0.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { createZitadelClient } from "@zitadel/api/client";
|
|
4
|
-
import { DEFAULT_FLOW_SCHEMA_URI,
|
|
4
|
+
import { DEFAULT_FLOW_SCHEMA_URI, getDefaultHumanUserSchemaBody, getDefaultLoginFlow } from "@zitadel/config/defaults";
|
|
5
5
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { dirname, join } from "node:path";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { createServer } from "node:net";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
+
import { apiBaseUrl } from "@zitadel/api/runtime/base-url";
|
|
11
12
|
//#region src/bootstrap.ts
|
|
12
13
|
const DEFAULT_PROJECT_NAME = "zitadel-testing";
|
|
13
14
|
/**
|
|
@@ -26,38 +27,32 @@ async function bootstrapProject(options) {
|
|
|
26
27
|
})),
|
|
27
28
|
seed_defaults: false
|
|
28
29
|
});
|
|
29
|
-
const projectId = requireString(project.id, "project id");
|
|
30
|
-
const projectSecret = requireString(project.project_secret, "project secret");
|
|
31
|
-
const previewSecret = typeof project.preview_secret === "string" ? project.preview_secret : void 0;
|
|
32
30
|
const client = createZitadelClient({
|
|
33
31
|
baseUrl,
|
|
34
|
-
token:
|
|
32
|
+
token: project.project_secret
|
|
35
33
|
});
|
|
36
|
-
const
|
|
34
|
+
const schemaBody = getDefaultHumanUserSchemaBody({
|
|
37
35
|
preset: options.preset,
|
|
38
36
|
useCase: options.useCase
|
|
39
37
|
});
|
|
40
|
-
const
|
|
38
|
+
const schema = await client.createSchema(schemaBody, { project_id: project.id });
|
|
41
39
|
const flowBody = getDefaultLoginFlow({
|
|
42
40
|
preset: options.preset,
|
|
43
41
|
useCase: options.useCase
|
|
44
42
|
});
|
|
43
|
+
const flow = await client.createFlowDefinition({
|
|
44
|
+
project_id: project.id,
|
|
45
|
+
schema_uri: DEFAULT_FLOW_SCHEMA_URI,
|
|
46
|
+
flow_definition: flowBody
|
|
47
|
+
});
|
|
45
48
|
return {
|
|
46
|
-
projectId,
|
|
47
|
-
projectSecret,
|
|
48
|
-
previewSecret,
|
|
49
|
-
schemaId,
|
|
50
|
-
flowId:
|
|
51
|
-
project_id: projectId,
|
|
52
|
-
schema_uri: DEFAULT_FLOW_SCHEMA_URI,
|
|
53
|
-
flow_definition: flowBody
|
|
54
|
-
})).id, "flow definition id")
|
|
49
|
+
projectId: project.id,
|
|
50
|
+
projectSecret: project.project_secret,
|
|
51
|
+
previewSecret: project.preview_secret,
|
|
52
|
+
schemaId: schema.id,
|
|
53
|
+
flowId: flow.id
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
|
-
function requireString(value, label) {
|
|
58
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
59
|
-
throw new Error(`Missing ${label} in server response.`);
|
|
60
|
-
}
|
|
61
56
|
//#endregion
|
|
62
57
|
//#region src/cli.ts
|
|
63
58
|
const DEFAULT_TIMEOUT_MS = 12e4;
|
|
@@ -296,13 +291,13 @@ async function seedUser(client, context, input = {}) {
|
|
|
296
291
|
const fresh = identity();
|
|
297
292
|
const email = input.email ?? fresh.email;
|
|
298
293
|
const password = input.password ?? fresh.password;
|
|
299
|
-
const id =
|
|
294
|
+
const { id } = await client.createUser({
|
|
300
295
|
schema: context.schemaId,
|
|
301
296
|
attributes: {
|
|
302
297
|
...input.attributes,
|
|
303
298
|
email
|
|
304
299
|
}
|
|
305
|
-
}, { project_id: context.projectId })
|
|
300
|
+
}, { project_id: context.projectId });
|
|
306
301
|
await client.setUserPassword(id, { password });
|
|
307
302
|
return {
|
|
308
303
|
id,
|
|
@@ -329,23 +324,54 @@ async function seedUsers(client, context, count, template = {}) {
|
|
|
329
324
|
//#endregion
|
|
330
325
|
//#region src/session.ts
|
|
331
326
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
327
|
+
* The server's session cookie under its canonical name
|
|
328
|
+
* (internal/api/session.go, ADR 083): the name a direct call to the server
|
|
329
|
+
* sends, over any transport. A browser holds it under
|
|
330
|
+
* {@link browserSessionCookieName}.
|
|
331
|
+
*/
|
|
332
|
+
const SESSION_COOKIE_NAME = "__Host-zitadel_session";
|
|
333
|
+
/**
|
|
334
|
+
* Whether a session cookie a browser holds for `url` is `Secure`, and so
|
|
335
|
+
* carries the `__Host-` prefix: always, but over plain http to a loopback host,
|
|
336
|
+
* where the server leaves `Secure` out for Safari. Without a URL, a local dev
|
|
337
|
+
* server's answer: no.
|
|
335
338
|
*/
|
|
336
|
-
|
|
339
|
+
function secureSessionCookie(url) {
|
|
340
|
+
if (url === void 0) return false;
|
|
341
|
+
let parsed;
|
|
342
|
+
try {
|
|
343
|
+
parsed = new URL(url);
|
|
344
|
+
} catch {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
const host = parsed.hostname.toLowerCase();
|
|
348
|
+
return parsed.protocol !== "http:" || !(host === "localhost" || host === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(host));
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* The server's session cookie as a browser at `url` holds it: the canonical
|
|
352
|
+
* `__Host-zitadel_session`, or `zitadel_session` over plain http to a loopback
|
|
353
|
+
* host (ADR 083). Without a URL, the loopback name. An app behind a proxy that
|
|
354
|
+
* passes the server's cookie through, such as an SPA's in production, keeps
|
|
355
|
+
* its session under this name.
|
|
356
|
+
*/
|
|
357
|
+
function browserSessionCookieName(url) {
|
|
358
|
+
return secureSessionCookie(url) ? SESSION_COOKIE_NAME : "zitadel_session";
|
|
359
|
+
}
|
|
337
360
|
/**
|
|
338
|
-
* The cookie an app keeps its session in on its own origin behind a
|
|
339
|
-
* (Next.js, Nuxt, SvelteKit, SolidStart, TanStack Start, Qwik
|
|
340
|
-
* proxy `zitadel setup` writes for an SPA:
|
|
341
|
-
*
|
|
342
|
-
*
|
|
361
|
+
* The cookie an app at `url` keeps its session in on its own origin behind a
|
|
362
|
+
* server SDK (Next.js, Nuxt, SvelteKit, SolidStart, TanStack Start, Qwik
|
|
363
|
+
* Router) or the dev proxy `zitadel setup` writes for an SPA: the browser's
|
|
364
|
+
* name of the server's cookie with the project id appended,
|
|
365
|
+
* `zitadel_session_<projectId>` over plain http to a loopback host and
|
|
366
|
+
* `__Host-zitadel_session_<projectId>` otherwise. Without a URL, the loopback
|
|
367
|
+
* name. The proxy renames the server's cookie, so the apps and the Console on
|
|
368
|
+
* one host keep a session each (ADR 073, ADR 083).
|
|
343
369
|
*
|
|
344
370
|
* Mirrors `sessionCookieName` in `@zitadel/sdk-core`, including the
|
|
345
371
|
* percent-encoding of every byte outside `[A-Za-z0-9_-]`.
|
|
346
372
|
*/
|
|
347
|
-
function sessionCookieName(projectId) {
|
|
348
|
-
let name = `${
|
|
373
|
+
function sessionCookieName(projectId, url) {
|
|
374
|
+
let name = `${browserSessionCookieName(url)}_`;
|
|
349
375
|
for (const byte of new TextEncoder().encode(projectId)) {
|
|
350
376
|
const char = String.fromCharCode(byte);
|
|
351
377
|
name += /[A-Za-z0-9_-]/.test(char) ? char : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
@@ -416,7 +442,7 @@ var FlowCookieJar = class {
|
|
|
416
442
|
}
|
|
417
443
|
};
|
|
418
444
|
async function flowFetch(handle, jar, origin, path, body) {
|
|
419
|
-
const response = await fetch(`${handle.baseUrl}${path}`, {
|
|
445
|
+
const response = await fetch(`${apiBaseUrl(handle.baseUrl)}${path}`, {
|
|
420
446
|
method: "POST",
|
|
421
447
|
headers: {
|
|
422
448
|
"content-type": "application/json",
|
|
@@ -535,6 +561,6 @@ async function startLocalZitadel(options = {}) {
|
|
|
535
561
|
};
|
|
536
562
|
}
|
|
537
563
|
//#endregion
|
|
538
|
-
export {
|
|
564
|
+
export { secureSessionCookie as a, bootLocalServer as c, browserSessionCookieName as i, bootstrapProject as l, startLocalZitadel as n, sessionCookieName as o, SESSION_COOKIE_NAME as r, identity as s, connectZitadel as t };
|
|
539
565
|
|
|
540
|
-
//# sourceMappingURL=src-
|
|
566
|
+
//# sourceMappingURL=src-BeovWhmR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"src-BeovWhmR.mjs","names":[],"sources":["../src/bootstrap.ts","../src/cli.ts","../src/envelope.ts","../src/ports.ts","../src/lifecycle.ts","../src/seed.ts","../src/session.ts","../src/index.ts"],"sourcesContent":["import { createZitadelClient } from \"@zitadel/api/client\";\nimport {\n DEFAULT_FLOW_SCHEMA_URI,\n getDefaultHumanUserSchemaBody,\n getDefaultLoginFlow,\n type SetupPreset,\n type SetupUseCase,\n} from \"@zitadel/config/defaults\";\n\nexport interface BootstrapProjectOptions {\n baseUrl: string;\n projectName?: string;\n /**\n * Origins of the apps that will proxy to this instance. The backend's\n * origin check rejects forwarded requests from unregistered origins.\n */\n appOrigins?: string[];\n preset?: SetupPreset;\n useCase?: SetupUseCase;\n}\n\nexport interface BootstrappedProject {\n projectId: string;\n projectSecret: string;\n /** The browser-plane credential the server issues with every project. */\n previewSecret: string;\n schemaId: string;\n flowId: string;\n}\n\nconst DEFAULT_PROJECT_NAME = \"zitadel-testing\";\n\n/**\n * Server-side half of `zitadel setup`, without any file scaffolding:\n * `POST /projects` is unauthenticated and mints the projectSecret used as the\n * bearer for everything else; the schema is uploaded without `$id` so the\n * server assigns an opaque id, which the flow must then reference.\n */\nexport async function bootstrapProject(\n options: BootstrapProjectOptions,\n): Promise<BootstrappedProject> {\n const { baseUrl } = options;\n const unauthenticated = createZitadelClient({ baseUrl });\n const project = await unauthenticated.createProject({\n name: options.projectName ?? DEFAULT_PROJECT_NAME,\n origins: (options.appOrigins ?? []).map((pattern) => ({\n pattern,\n kind: \"preview\" as const,\n })),\n seed_defaults: false,\n });\n const client = createZitadelClient({ baseUrl, token: project.project_secret });\n\n const schemaBody = getDefaultHumanUserSchemaBody({\n preset: options.preset,\n useCase: options.useCase,\n });\n const schema = await client.createSchema(schemaBody, { project_id: project.id });\n\n const flowBody = getDefaultLoginFlow({\n preset: options.preset,\n useCase: options.useCase,\n });\n const flow = await client.createFlowDefinition({\n project_id: project.id,\n schema_uri: DEFAULT_FLOW_SCHEMA_URI,\n flow_definition: flowBody,\n });\n\n return {\n projectId: project.id,\n projectSecret: project.project_secret,\n previewSecret: project.preview_secret,\n schemaId: schema.id,\n flowId: flow.id,\n };\n}\n","import { spawn } from \"node:child_process\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\nexport interface RunCliOptions {\n args: string[];\n env?: NodeJS.ProcessEnv;\n /** Test seam / escape hatch: alternative CLI entry script. */\n bin?: string;\n timeoutMs?: number;\n}\n\nexport interface RunCliResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nconst DEFAULT_TIMEOUT_MS = 120_000;\n\nexport function resolveCliBin(): string {\n const require = createRequire(import.meta.url);\n const pkgPath = require.resolve(\"@zitadel/cli/package.json\");\n const pkg = require(pkgPath) as { bin?: Record<string, string> };\n const rel = pkg.bin?.zitadel;\n if (!rel) {\n throw new Error(\"@zitadel/cli does not declare a `zitadel` bin entry\");\n }\n return join(dirname(pkgPath), rel);\n}\n\nexport function runCli(options: RunCliOptions): Promise<RunCliResult> {\n const bin = options.bin ?? resolveCliBin();\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n return new Promise((resolve, reject) => {\n const child = spawn(process.execPath, [bin, ...options.args], {\n env: { ...process.env, ...options.env },\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let stdout = \"\";\n let stderr = \"\";\n child.stdout.setEncoding(\"utf8\");\n child.stdout.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr.setEncoding(\"utf8\");\n child.stderr.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n const timer = setTimeout(() => {\n child.kill(\"SIGKILL\");\n reject(\n new Error(\n `zitadel ${options.args[0] ?? \"\"} timed out after ${timeoutMs}ms\\n${tail(stderr)}`,\n ),\n );\n }, timeoutMs);\n timer.unref();\n child.on(\"error\", (error) => {\n clearTimeout(timer);\n reject(error);\n });\n child.on(\"close\", (code) => {\n clearTimeout(timer);\n resolve({ exitCode: code ?? -1, stdout, stderr });\n });\n });\n}\n\nexport function tail(text: string, lines = 20): string {\n return text.split(\"\\n\").slice(-lines).join(\"\\n\").trim();\n}\n","export interface CliEnvelope<TData> {\n cli_version?: string;\n command?: string;\n source?: string;\n status: string;\n data: TData;\n warnings?: string[];\n /** Error envelopes (`status: \"error\"`) carry remediation guidance. */\n code?: string;\n message?: string;\n hint?: string;\n next_commands?: string[];\n}\n\n/**\n * Render an error envelope's remediation fields for humans — the CLI's\n * `hint`/`next_commands` are the actionable part of a failure (e.g. \"Reinstall\n * @zitadel/cli so npm can install @zitadel/server\"), so surface them instead\n * of a raw stdout dump. Returns undefined when the envelope has no message.\n */\nexport function describeEnvelopeError(envelope: CliEnvelope<unknown>): string | undefined {\n if (typeof envelope.message !== \"string\" || envelope.message.length === 0) {\n return undefined;\n }\n const lines = [envelope.code ? `${envelope.code}: ${envelope.message}` : envelope.message];\n if (envelope.hint) {\n lines.push(`hint: ${envelope.hint}`);\n }\n if (envelope.next_commands && envelope.next_commands.length > 0) {\n lines.push(`next: ${envelope.next_commands.join(\" | \")}`);\n }\n return lines.join(\"\\n\");\n}\n\nexport interface StartEnvelopeData {\n runtime: {\n backend: string;\n pid: number;\n port: number;\n data_dir: string;\n log_path: string;\n };\n urls: {\n api: string;\n console: string;\n };\n}\n\nexport function parseCliEnvelope<TData>(stdout: string, context: string): CliEnvelope<TData> {\n const start = stdout.indexOf(\"{\");\n const end = stdout.lastIndexOf(\"}\");\n if (start === -1 || end <= start) {\n throw new Error(\n `${context}: expected a JSON envelope on stdout, got:\\n${stdout.trim() || \"(empty)\"}`,\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(stdout.slice(start, end + 1));\n } catch (error) {\n throw new Error(\n `${context}: failed to parse JSON envelope: ${(error as Error).message}\\n${stdout.trim()}`,\n { cause: error },\n );\n }\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n typeof (parsed as { status?: unknown }).status !== \"string\"\n ) {\n throw new Error(`${context}: stdout JSON is not a CLI envelope:\\n${stdout.trim()}`);\n }\n return parsed as CliEnvelope<TData>;\n}\n","import { createServer } from \"node:net\";\n\n/**\n * Ask the OS for a free TCP port. The port is released before returning, so a\n * racing process could grab it; the CLI's own preflight surfaces that as\n * E_PORT_IN_USE, which is loud rather than corrupting.\n */\nexport function getFreePort(): Promise<number> {\n return new Promise((resolve, reject) => {\n const server = createServer();\n server.unref();\n server.on(\"error\", reject);\n server.listen(0, \"127.0.0.1\", () => {\n const address = server.address();\n if (address === null || typeof address === \"string\") {\n server.close();\n reject(new Error(\"could not determine a free port\"));\n return;\n }\n const { port } = address;\n server.close((err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(port);\n });\n });\n });\n}\n","import { mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\n\nimport { runCli, tail, type RunCliResult } from \"./cli\";\nimport {\n describeEnvelopeError,\n parseCliEnvelope,\n type CliEnvelope,\n type StartEnvelopeData,\n} from \"./envelope\";\nimport { getFreePort } from \"./ports\";\nimport type { LocalZitadelRuntime } from \"./types\";\n\nexport interface BootServerOptions {\n /** TCP port for the instance; defaults to an OS-assigned free port. */\n port?: number;\n /**\n * State directory. Defaults to a fresh temp dir that is removed on stop;\n * a caller-provided dir is never removed.\n */\n dir?: string;\n /** Forwarded as ZITADEL_SERVER_BINARY (in-repo runs use dist/server/nextgen). */\n serverBinary?: string;\n /** Keep the owned temp dir after stop (debugging). */\n keep?: boolean;\n /** Test seam: alternative CLI entry script. */\n cliBin?: string;\n timeoutMs?: number;\n}\n\nexport interface BootedServer {\n baseUrl: string;\n runtime: LocalZitadelRuntime;\n stop(): Promise<void>;\n}\n\n/**\n * Boot an ephemeral local server by shelling out to `zitadel start` and parse\n * its JSON envelope. The CLI owns the subtle parts (port preflight, health\n * wait, process-group stop), so this module stays a thin adapter; swapping it\n * for direct library calls later must not change the shape returned here.\n */\nexport async function bootLocalServer(options: BootServerOptions = {}): Promise<BootedServer> {\n const ownsDir = options.dir === undefined;\n const dir = options.dir ?? (await mkdtemp(join(tmpdir(), \"zitadel-testing-\")));\n const port = options.port ?? (await getFreePort());\n const env: NodeJS.ProcessEnv = {};\n if (options.serverBinary) {\n env.ZITADEL_SERVER_BINARY = options.serverBinary;\n }\n\n const result = await runCli({\n args: [\"start\", \"--port\", String(port), \"--non-interactive\", \"--json\", \"-c\", dir],\n bin: options.cliBin,\n env,\n timeoutMs: options.timeoutMs,\n });\n if (result.exitCode !== 0) {\n // Keep the dir on failure: server.log inside it is the diagnostic.\n throw new Error(\n `zitadel start exited with code ${result.exitCode}.\\n` +\n `${failureDetail(result)}\\n` +\n `state dir kept for inspection: ${dir}`,\n );\n }\n const stopViaCli = async (): Promise<void> => {\n const stopResult = await runCli({\n args: [\"stop\", \"--non-interactive\", \"--json\", \"-c\", dir],\n bin: options.cliBin,\n env,\n timeoutMs: options.timeoutMs,\n });\n if (stopResult.exitCode !== 0) {\n throw new Error(\n `zitadel stop exited with code ${stopResult.exitCode}.\\n` +\n `${failureDetail(stopResult)}\\n` +\n `state dir kept for inspection: ${dir}`,\n );\n }\n };\n\n let envelope: CliEnvelope<StartEnvelopeData>;\n try {\n envelope = parseCliEnvelope<StartEnvelopeData>(result.stdout, \"zitadel start\");\n if (envelope.status !== \"ok\") {\n throw new Error(\n `zitadel start reported status \"${envelope.status}\":\\n` +\n `${describeEnvelopeError(envelope) ?? tail(result.stdout)}`,\n );\n }\n } catch (error) {\n const startError = new Error(\n `zitadel start produced unusable output.\\n` +\n `reason: ${error instanceof Error ? error.message : String(error)}\\n` +\n `stdout: ${tail(result.stdout) || \"(empty)\"}\\n` +\n `stderr: ${tail(result.stderr) || \"(empty)\"}\\n` +\n `state dir kept for inspection: ${dir}`,\n { cause: error },\n );\n // start exited 0, so a server may well be running despite the unusable\n // output — stop it instead of orphaning it.\n try {\n await stopViaCli();\n } catch (stopError) {\n // Both errors are preserved in AggregateError.errors, which the rule\n // below cannot model.\n throw new AggregateError(\n [startError, stopError],\n `${startError.message}\\nStopping the possibly-running instance also failed: ${\n stopError instanceof Error ? stopError.message : String(stopError)\n }`,\n );\n }\n throw startError;\n }\n\n const { runtime, urls } = envelope.data;\n const runStop = async (): Promise<void> => {\n await stopViaCli();\n if (ownsDir && !options.keep) {\n await rm(dir, { recursive: true, force: true });\n }\n };\n // Memoize the in-flight stop so concurrent callers await the same cleanup,\n // and reset on failure so a failed stop can be retried instead of silently\n // leaving the server behind.\n let stopPromise: Promise<void> | undefined;\n const stop = (): Promise<void> => {\n stopPromise ??= runStop().catch((error: unknown) => {\n stopPromise = undefined;\n throw error;\n });\n return stopPromise;\n };\n\n return {\n baseUrl: urls.api,\n runtime: {\n port: runtime.port,\n pid: runtime.pid,\n dir,\n logPath: runtime.log_path,\n },\n stop,\n };\n}\n\n/**\n * A failed CLI run usually still prints an error envelope; its\n * message/hint/next_commands beat raw output tails (e.g. a fresh install\n * missing @zitadel/server gets \"Reinstall @zitadel/cli\" instead of a stack).\n */\nfunction failureDetail(result: RunCliResult): string {\n try {\n const described = describeEnvelopeError(parseCliEnvelope<unknown>(result.stdout, \"zitadel\"));\n if (described) {\n return described;\n }\n } catch {\n // stdout carried no envelope; fall back to the raw tails.\n }\n return `stdout: ${tail(result.stdout) || \"(empty)\"}\\nstderr: ${tail(result.stderr) || \"(empty)\"}`;\n}\n","import { randomUUID } from \"node:crypto\";\n\nimport type { ZitadelClient } from \"@zitadel/api/client\";\n\nimport type { Identity, SeededUser, SeedUserInput, SeedUsersTemplate } from \"./types\";\n\nexport interface SeedContext {\n projectId: string;\n schemaId: string;\n}\n\n/**\n * A unique unused email + password. Nothing is created on the instance —\n * this is the input for registration-flow specs, which must prove the flow\n * creates the user. It needs no instance either, so both entry points export\n * it for specs that run without `withZitadel()`; `seed.identity()` and\n * `zitadel.identity()` call this function.\n */\nexport function identity(): Identity {\n return {\n email: `e2e-${randomUUID().slice(0, 8)}@example.com`,\n password: `Pw!${randomUUID()}`,\n };\n}\n\n/**\n * Create a user that can immediately complete the password login flow:\n * `POST /users` (the body carries `schema: <schema id>` and the schema-defined\n * content under `attributes`) followed by `PUT /users/{id}/password`.\n *\n * Defaults mint a unique email per call (email is x-unique per project), which\n * is what makes per-test seeding parallel-safe on a shared instance.\n */\nexport async function seedUser(\n client: ZitadelClient,\n context: SeedContext,\n input: SeedUserInput = {},\n): Promise<SeededUser> {\n const fresh = identity();\n const email = input.email ?? fresh.email;\n const password = input.password ?? fresh.password;\n // `email` wins over the templated attributes: the returned SeededUser must\n // never disagree with what was actually created, since a silently overridden\n // email would yield credentials that cannot log in.\n const { id } = await client.createUser(\n {\n schema: context.schemaId,\n attributes: { ...input.attributes, email },\n },\n { project_id: context.projectId },\n );\n await client.setUserPassword(id, { password });\n return { id, email, password };\n}\n\n/**\n * Seed `count` users sequentially. The template makes fixture data\n * deterministic per index (stable emails/names keep screenshot diffs about\n * code, not reshuffled data — the `console:dev-real` pattern); untemplated\n * fields fall back to the unique defaults. Name-like attributes need a\n * schema that declares them (`useCase: \"consumer\"` or wider).\n */\nexport async function seedUsers(\n client: ZitadelClient,\n context: SeedContext,\n count: number,\n template: SeedUsersTemplate = {},\n): Promise<SeededUser[]> {\n const users: SeededUser[] = [];\n for (let index = 0; index < count; index += 1) {\n users.push(\n await seedUser(client, context, {\n email: template.email?.(index),\n password: template.password?.(index),\n attributes: template.attributes?.(index),\n }),\n );\n }\n return users;\n}\n","import type { ZitadelClient } from \"@zitadel/api/client\";\nimport type { CreateFlow201, CreateFlow201StepFieldsItem } from \"@zitadel/api/generated/model\";\n\nimport { apiBaseUrl } from \"@zitadel/api/runtime/base-url\";\n\nimport type { SeedContext } from \"./seed\";\nimport type { InstanceHandle, MintedSession, SeededUser } from \"./types\";\n\n/**\n * The server's session cookie under its canonical name\n * (internal/api/session.go, ADR 083): the name a direct call to the server\n * sends, over any transport. A browser holds it under\n * {@link browserSessionCookieName}.\n */\nexport const SESSION_COOKIE_NAME = \"__Host-zitadel_session\";\n\n/**\n * Whether a session cookie a browser holds for `url` is `Secure`, and so\n * carries the `__Host-` prefix: always, but over plain http to a loopback host,\n * where the server leaves `Secure` out for Safari. Without a URL, a local dev\n * server's answer: no.\n */\nexport function secureSessionCookie(url?: string | URL): boolean {\n if (url === undefined) {\n return false;\n }\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return true;\n }\n const host = parsed.hostname.toLowerCase();\n return (\n parsed.protocol !== \"http:\" ||\n !(host === \"localhost\" || host === \"[::1]\" || /^127(?:\\.\\d{1,3}){3}$/.test(host))\n );\n}\n\n/**\n * The server's session cookie as a browser at `url` holds it: the canonical\n * `__Host-zitadel_session`, or `zitadel_session` over plain http to a loopback\n * host (ADR 083). Without a URL, the loopback name. An app behind a proxy that\n * passes the server's cookie through, such as an SPA's in production, keeps\n * its session under this name.\n */\nexport function browserSessionCookieName(url?: string | URL): string {\n return secureSessionCookie(url) ? SESSION_COOKIE_NAME : \"zitadel_session\";\n}\n\n/**\n * The cookie an app at `url` keeps its session in on its own origin behind a\n * server SDK (Next.js, Nuxt, SvelteKit, SolidStart, TanStack Start, Qwik\n * Router) or the dev proxy `zitadel setup` writes for an SPA: the browser's\n * name of the server's cookie with the project id appended,\n * `zitadel_session_<projectId>` over plain http to a loopback host and\n * `__Host-zitadel_session_<projectId>` otherwise. Without a URL, the loopback\n * name. The proxy renames the server's cookie, so the apps and the Console on\n * one host keep a session each (ADR 073, ADR 083).\n *\n * Mirrors `sessionCookieName` in `@zitadel/sdk-core`, including the\n * percent-encoding of every byte outside `[A-Za-z0-9_-]`.\n */\nexport function sessionCookieName(projectId: string, url?: string | URL): string {\n let name = `${browserSessionCookieName(url)}_`;\n for (const byte of new TextEncoder().encode(projectId)) {\n const char = String.fromCharCode(byte);\n name += /[A-Za-z0-9_-]/.test(char)\n ? char\n : `%${byte.toString(16).toUpperCase().padStart(2, \"0\")}`;\n }\n return name;\n}\n\nconst MAX_FLOW_STEPS = 6;\n\nexport interface MintSessionOptions {\n /** Forwarded to `POST /flow`; the project's default flow when omitted. */\n flowDefinitionName?: string;\n /** Origin header for flow calls (the project's origin check enforces it). */\n origin?: string;\n}\n\n/**\n * Drive the real login flow headlessly for a seeded password user and\n * exchange the terminal handoff for a session: exactly what `<zitadel-login>`\n * does, minus the rendering. Supports flows whose steps only ask for the\n * user's email and password (the shipped `password-first` presets); any step\n * demanding more — a challenge, an unknown field — fails loudly by design.\n *\n * Flow calls use raw fetch instead of the typed client because the flow is\n * stateless through the sealed `_zflow` cookie (internal/api/flow.go): every\n * response re-seals the flow state into Set-Cookie, and submits are rejected\n * without it. Browsers round-trip it implicitly; here a one-cookie jar does.\n */\nexport async function mintSession(\n client: ZitadelClient,\n handle: Pick<InstanceHandle, \"baseUrl\" | \"projectSecret\">,\n context: SeedContext,\n user: SeededUser,\n options: MintSessionOptions = {},\n): Promise<MintedSession> {\n const values: Record<string, string> = { email: user.email, password: user.password };\n const jar = new FlowCookieJar();\n const origin = options.origin;\n\n let response = await flowFetch(handle, jar, origin, \"/flow\", {\n project_id: context.projectId,\n purpose: \"login\",\n ...(options.flowDefinitionName ? { flow_definition_name: options.flowDefinitionName } : {}),\n });\n\n for (let hop = 0; hop < MAX_FLOW_STEPS; hop += 1) {\n if (response.handoff_token) {\n const exchanged = await client.exchangeHandoff(\n { handoff_token: response.handoff_token },\n { project_id: context.projectId },\n );\n return {\n user,\n sessionToken: exchanged.session_token,\n expiresAt: exchanged.session.expires_at,\n cookie: {\n name: SESSION_COOKIE_NAME,\n value: exchanged.session_token,\n httpOnly: true,\n secure: true,\n sameSite: \"Lax\",\n path: \"/\",\n },\n };\n }\n response = await flowFetch(\n handle,\n jar,\n origin,\n `/flow/${encodeURIComponent(response.id)}/submit`,\n {\n session_token: response.session_token,\n action: \"submit\",\n fields: collectFields(response, values),\n },\n );\n }\n\n throw new Error(\n `seed.session: flow did not complete within ${MAX_FLOW_STEPS} steps ` +\n `(last step: ${describeStep(response)}).`,\n );\n}\n\n/** One-cookie jar for the sealed `_zflow` flow-state cookie. */\nclass FlowCookieJar {\n private cookie: string | undefined;\n\n absorb(response: Response): void {\n for (const raw of response.headers.getSetCookie()) {\n const [pair] = raw.split(\";\", 1);\n if (pair?.startsWith(\"_zflow=\")) {\n this.cookie = pair;\n }\n }\n }\n\n header(): Record<string, string> {\n return this.cookie ? { cookie: this.cookie } : {};\n }\n}\n\nasync function flowFetch(\n handle: Pick<InstanceHandle, \"baseUrl\" | \"projectSecret\">,\n jar: FlowCookieJar,\n origin: string | undefined,\n path: string,\n body: Record<string, unknown>,\n): Promise<CreateFlow201> {\n const response = await fetch(`${apiBaseUrl(handle.baseUrl)}${path}`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n authorization: `Bearer ${handle.projectSecret}`,\n // The project's origin allowlist applies to flow calls; send the app\n // origin the way a browser request through the app would carry it.\n ...(origin ? { origin } : {}),\n ...jar.header(),\n },\n body: JSON.stringify(body),\n });\n jar.absorb(response);\n const parsed = (await response.json().catch(() => undefined)) as CreateFlow201 | undefined;\n if (!response.ok || !parsed) {\n const detail = parsed && typeof parsed === \"object\" ? ` — ${JSON.stringify(parsed)}` : \"\";\n // An origin-allowlist rejection without an Origin header is a\n // configuration gap, not a flow problem — say how to close it. (No eager\n // check: a project with an empty allowlist may accept originless calls.)\n const hint =\n !origin && /origin/i.test(detail)\n ? \"\\nNo Origin header was sent: pass `origin` to seedSession() (the Playwright \" +\n \"fixtures pass the suite's baseURL) or `appOrigins` to startLocalZitadel().\"\n : \"\";\n throw new Error(`seed.session: POST ${path} returned ${response.status}${detail}${hint}`);\n }\n return parsed;\n}\n\n/**\n * Fill exactly the fields the current step declares — the orchestrator's\n * convention — from the known email/password values. An unknown required\n * field means this flow needs more than a password login can provide.\n */\nfunction collectFields(\n response: CreateFlow201,\n values: Record<string, string>,\n): Record<string, string> {\n const fields: Record<string, string> = {};\n for (const field of response.step.fields ?? []) {\n const value = values[fieldKey(field)];\n if (value === undefined) {\n throw new Error(\n `seed.session supports password flows only; step ${describeStep(response)} ` +\n `declares field \"${field.name}\", which the kit cannot fill. ` +\n `Log in through the UI for flows with additional factors.`,\n );\n }\n fields[field.name] = value;\n }\n return fields;\n}\n\n/**\n * Steps name credential fields with schema pointers (e.g.\n * `x-auth-methods#password`); match on the trailing segment so the value map\n * stays the plain `{ email, password }` a caller thinks in.\n */\nfunction fieldKey(field: CreateFlow201StepFieldsItem): string {\n const name = field.name;\n const tail = name.split(/[#/.]/).at(-1) ?? name;\n return tail.toLowerCase();\n}\n\nfunction describeStep(response: CreateFlow201): string {\n const name = response.step.name ?? \"(unnamed)\";\n const declared = (response.step.fields ?? []).map((field) => field.name).join(\", \");\n return `\"${name}\"${declared ? ` [fields: ${declared}]` : \"\"}`;\n}\n","import { createZitadelClient } from \"@zitadel/api/client\";\n\nimport { applyAppEnvTemplate, nextAppEnv } from \"./app-env\";\nimport { bootstrapProject, type BootstrapProjectOptions } from \"./bootstrap\";\nimport { bootLocalServer, type BootServerOptions } from \"./lifecycle\";\nimport { identity, seedUser, seedUsers } from \"./seed\";\nimport { mintSession } from \"./session\";\nimport type { ConnectedZitadel, InstanceHandle, LocalZitadel } from \"./types\";\n\nexport type StartLocalZitadelOptions = BootServerOptions & Omit<BootstrapProjectOptions, \"baseUrl\">;\n\n/**\n * Attach to an already-bootstrapped instance/project. Lifecycle-free on\n * purpose: this is the entry point for Playwright workers (via the handshake\n * file) and, later, for seeding remote instances.\n */\nexport function connectZitadel(handle: InstanceHandle): ConnectedZitadel {\n const api = createZitadelClient({ baseUrl: handle.baseUrl, token: handle.projectSecret });\n const context = { projectId: handle.projectId, schemaId: handle.schemaId };\n const connected: ConnectedZitadel = {\n handle,\n api,\n // The Next-shaped convenience view; other frameworks apply their own\n // template to `handle` (see AppEnvTemplate).\n appEnv: applyAppEnvTemplate(nextAppEnv, handle),\n seedUser: (input) => seedUser(api, context, input),\n seedUsers: (count, template) => seedUsers(api, context, count, template),\n identity,\n seedSession: async (input = {}) => {\n const { user: existing, flowDefinitionName, origin, ...userInput } = input;\n const user = existing ?? (await seedUser(api, context, userInput));\n return mintSession(api, handle, context, user, {\n flowDefinitionName,\n origin: origin ?? handle.appOrigin,\n });\n },\n };\n return connected;\n}\n\n/**\n * Boot an ephemeral local instance (binary runtime + SQLite by default, no\n * Docker) and bootstrap a project + default schema + login flow on it. The\n * result can seed loginable password users immediately.\n */\nexport async function startLocalZitadel(\n options: StartLocalZitadelOptions = {},\n): Promise<LocalZitadel> {\n const server = await bootLocalServer(options);\n let bootstrapped: Awaited<ReturnType<typeof bootstrapProject>>;\n try {\n bootstrapped = await bootstrapProject({\n baseUrl: server.baseUrl,\n projectName: options.projectName,\n appOrigins: options.appOrigins,\n preset: options.preset,\n useCase: options.useCase,\n });\n } catch (error) {\n try {\n await server.stop();\n } catch (stopError) {\n // Both errors are preserved in AggregateError.errors, which the rule\n // below cannot model.\n throw new AggregateError(\n [error, stopError],\n \"bootstrap failed, and stopping the booted instance also failed\",\n );\n }\n throw error;\n }\n const handle: InstanceHandle = {\n baseUrl: server.baseUrl,\n projectId: bootstrapped.projectId,\n projectSecret: bootstrapped.projectSecret,\n schemaId: bootstrapped.schemaId,\n previewSecret: bootstrapped.previewSecret,\n appOrigin: options.appOrigins?.[0],\n };\n return {\n ...connectZitadel(handle),\n runtime: server.runtime,\n stop: server.stop,\n [Symbol.asyncDispose]: server.stop,\n };\n}\n\nexport { applyAppEnvTemplate, nextAppEnv } from \"./app-env\";\nexport type { AppEnvTemplate } from \"./app-env\";\nexport { bootstrapProject } from \"./bootstrap\";\nexport type { BootstrapProjectOptions, BootstrappedProject } from \"./bootstrap\";\nexport { readHandshakeSync, waitForHandshake, writeHandshake } from \"./handshake\";\nexport { bootLocalServer } from \"./lifecycle\";\nexport type { BootedServer, BootServerOptions } from \"./lifecycle\";\nexport { identity } from \"./seed\";\nexport { browserSessionCookieName, SESSION_COOKIE_NAME, sessionCookieName } from \"./session\";\nexport type {\n ConnectedZitadel,\n Identity,\n InstanceHandle,\n LocalZitadel,\n LocalZitadelRuntime,\n MintedSession,\n PlatformCredentials,\n SeededUser,\n SeedSessionInput,\n SeedUserInput,\n SeedUsersTemplate,\n SessionCookie,\n} from \"./types\";\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,uBAAuB;;;;;;;AAQ7B,eAAsB,iBACpB,SAC8B;CAC9B,MAAM,EAAE,YAAY;CAEpB,MAAM,UAAU,MADQ,oBAAoB,EAAE,QAAQ,CAClB,CAAC,CAAC,cAAc;EAClD,MAAM,QAAQ,eAAe;EAC7B,UAAU,QAAQ,cAAc,CAAC,EAAA,CAAG,KAAK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EACvE;EACA,aAAa,OAAO,QAAQ,CAAC,MAAM;GACjC,MAAM,EAAE,MAAM,UAAU,oBAAoB,QAAQ,GAAG,cAAc;GACrE,MAAM,OAAO,YAAa,MAAM,SAAS,KAAK,SAAS,SAAS;GAChE,OAAO,YAAY,KAAK,QAAQ,SAAS,MAAM;IAC7C;IACA,QAAQ,UAAU,OAAO;GAC3B,CAAC;EACH;CAEa;AACjB;;;;;;AAOA,eAAsB,kBACpB,UAAoC,CAAC,GACd;CACvB,MAAM,SAAS,MAAM,gBAAgB,OAAO;CAC5C,IAAI;CACJ,IAAI;EACF,eAAe,MAAM,iBAAiB;GACpC,SAAS,OAAO;GAChB,aAAa,QAAQ;GACrB,YAAY,QAAQ;GACpB,QAAQ,QAAQ;GAChB,SAAS,QAAQ;EACnB,CAAC;CACH,SAAS,OAAO;EACd,IAAI;GACF,MAAM,OAAO,KAAK;EACpB,SAAS,WAAW;GAGlB,MAAM,IAAI,eACR,CAAC,OAAO,SAAS,GACjB,gEACF;EACF;EACA,MAAM;CACR;CASA,OAAO;EACL,GAAG,eAAe;GARlB,SAAS,OAAO;GAChB,WAAW,aAAa;GACxB,eAAe,aAAa;GAC5B,UAAU,aAAa;GACvB,eAAe,aAAa;GAC5B,WAAW,QAAQ,aAAa;EAGT,CAAC;EACxB,SAAS,OAAO;EAChB,MAAM,OAAO;GACZ,OAAO,eAAe,OAAO;CAChC;AACF"}
|
package/dist/supervisor.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_src = require("./src-
|
|
1
|
+
const require_src = require("./src-BKgcVBVj.cjs");
|
|
2
2
|
const require_handshake = require("./handshake-D6MXSUcd.cjs");
|
|
3
3
|
const require_orchestration = require("./orchestration-gIDANMcF.cjs");
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
package/dist/supervisor.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as writeHandshake } from "./handshake-CwlxMjW0.mjs";
|
|
2
|
-
import { n as startLocalZitadel } from "./src-
|
|
2
|
+
import { n as startLocalZitadel } from "./src-BeovWhmR.mjs";
|
|
3
3
|
import { a as parseSupervisorConfig, o as requireHandshakePath, r as SUPERVISOR_CONFIG_ENV } from "./orchestration-Clldecyr.mjs";
|
|
4
4
|
import { access, rm } from "node:fs/promises";
|
|
5
5
|
//#region src/supervisor.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zitadel/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Test-kit for seeded ephemeral local Zitadel instances",
|
|
5
5
|
"homepage": "https://github.com/zitadel/nextgen/tree/main/packages/testing#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"./package.json": "./package.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@zitadel/api": "0.
|
|
41
|
-
"@zitadel/cli": "0.
|
|
42
|
-
"@zitadel/config": "0.
|
|
40
|
+
"@zitadel/api": "0.4.0",
|
|
41
|
+
"@zitadel/cli": "0.4.0",
|
|
42
|
+
"@zitadel/config": "0.4.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@playwright/test": ">=1.60"
|
|
@@ -50,8 +50,9 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@playwright/test": "^1.
|
|
53
|
+
"@playwright/test": "^1.64.1",
|
|
54
54
|
"@types/node": "^24.19.1",
|
|
55
|
+
"@zitadel/vitest-config": "0.0.0",
|
|
55
56
|
"msw": "^2.14.6",
|
|
56
57
|
"tsdown": "^0.23.0",
|
|
57
58
|
"tslib": "^2.8.1",
|
|
@@ -64,6 +65,7 @@
|
|
|
64
65
|
"test": "vitest run",
|
|
65
66
|
"test:all": "pnpm run test",
|
|
66
67
|
"test:integration": "ZITADEL_SERVER_BINARY=${ZITADEL_SERVER_BINARY-$PWD/../../dist/server/nextgen} NEXTGEN_SERVER_CONSOLE_ENABLED=${NEXTGEN_SERVER_CONSOLE_ENABLED-false} vitest run --config vitest.integration.config.ts",
|
|
68
|
+
"install-browsers": "playwright install chromium",
|
|
67
69
|
"lint": "biome check .",
|
|
68
70
|
"build-release": "node ../../scripts/release-clean.mjs local-dist && pnpm run build"
|
|
69
71
|
}
|