@zitadel/testing 1.0.0-alpha.24 → 1.0.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +33 -19
  2. package/dist/app-runner.cjs +4 -3
  3. package/dist/app-runner.cjs.map +1 -1
  4. package/dist/app-runner.d.mts +1 -1
  5. package/dist/app-runner.mjs +4 -3
  6. package/dist/app-runner.mjs.map +1 -1
  7. package/dist/{handshake-BnAPXC6s.mjs → handshake-CwlxMjW0.mjs} +7 -4
  8. package/dist/handshake-CwlxMjW0.mjs.map +1 -0
  9. package/dist/{handshake-BOsVBPtn.cjs → handshake-D6MXSUcd.cjs} +7 -4
  10. package/dist/handshake-D6MXSUcd.cjs.map +1 -0
  11. package/dist/index.cjs +4 -2
  12. package/dist/index.d.mts +10 -16
  13. package/dist/index.d.mts.map +1 -1
  14. package/dist/index.mjs +3 -3
  15. package/dist/{orchestration-C640_1Lg.mjs → orchestration-Clldecyr.mjs} +1 -1
  16. package/dist/{orchestration-C640_1Lg.mjs.map → orchestration-Clldecyr.mjs.map} +1 -1
  17. package/dist/{orchestration-D7QBgQ0l.cjs → orchestration-gIDANMcF.cjs} +1 -1
  18. package/dist/{orchestration-D7QBgQ0l.cjs.map → orchestration-gIDANMcF.cjs.map} +1 -1
  19. package/dist/playwright.cjs +12 -5
  20. package/dist/playwright.cjs.map +1 -1
  21. package/dist/playwright.d.mts +42 -41
  22. package/dist/playwright.d.mts.map +1 -1
  23. package/dist/playwright.mjs +10 -6
  24. package/dist/playwright.mjs.map +1 -1
  25. package/dist/{app-env-DlrV_ePR.d.mts → session-BrSkzPpy.d.mts} +37 -7
  26. package/dist/session-BrSkzPpy.d.mts.map +1 -0
  27. package/dist/{src-3iEZwMxn.cjs → src-BbHs0YmP.cjs} +918 -201
  28. package/dist/src-BbHs0YmP.cjs.map +1 -0
  29. package/dist/{src-Dkt0HHu8.mjs → src-DKJ1hMV8.mjs} +37 -14
  30. package/dist/src-DKJ1hMV8.mjs.map +1 -0
  31. package/dist/supervisor.cjs +3 -3
  32. package/dist/supervisor.cjs.map +1 -1
  33. package/dist/supervisor.d.mts +1 -1
  34. package/dist/supervisor.mjs +3 -3
  35. package/dist/supervisor.mjs.map +1 -1
  36. package/package.json +11 -8
  37. package/dist/app-env-DlrV_ePR.d.mts.map +0 -1
  38. package/dist/handshake-BOsVBPtn.cjs.map +0 -1
  39. package/dist/handshake-BnAPXC6s.mjs.map +0 -1
  40. package/dist/src-3iEZwMxn.cjs.map +0 -1
  41. package/dist/src-Dkt0HHu8.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- const require_handshake = require("./handshake-BOsVBPtn.cjs");
1
+ const require_handshake = require("./handshake-D6MXSUcd.cjs");
2
2
  require("node:fs");
3
3
  require("node:url");
4
4
  let node_fs_promises = require("node:fs/promises");
@@ -35,20 +35,55 @@ function getApiAuthToken() {
35
35
  function setApiAuthToken(token) {
36
36
  apiAuthToken = token;
37
37
  }
38
- //#endregion
39
- //#region ../api/dist/chunk-CfYAbeIz.mjs
40
- var __defProp = Object.defineProperty;
41
- var __exportAll = (all, no_symbols) => {
42
- let target = {};
43
- for (var name in all) __defProp(target, name, {
44
- get: all[name],
45
- enumerable: true
46
- });
47
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
48
- return target;
49
- };
38
+ /**
39
+ * The CSRF token for the first-party browser surfaces (ADR 053 §5). A
40
+ * state-changing request that the `__nextgen_session` cookie authenticates must
41
+ * carry the session's token — `csrf_token` from `GET /sessions/me/csrf` — in the
42
+ * `X-Zitadel-CSRF` header. The app sets it once it has loaded its session;
43
+ * `runtime/fetch.ts` then adds the header to unsafe requests. Unset (every
44
+ * other caller), nothing is added.
45
+ *
46
+ * The token belongs to the server that issued it, so it is stored with that
47
+ * server's origin and only sent there: another client on the same page, with
48
+ * another base URL, never carries it to a different host. The origin defaults
49
+ * to the page's own, which is where a same-origin app's API lives; with no
50
+ * origin to go by (no page, or an unparsable request URL), nothing is sent.
51
+ *
52
+ * Unlike the bearer slot, the app sets this one rather than the client, so it
53
+ * lives on `globalThis` under a {@link Symbol.for} key, like the project slot in
54
+ * `config.ts`: a second copy of this module (an SDK pinning another version)
55
+ * must read the token the app's copy wrote.
56
+ */
57
+ const CSRF_SLOT = Symbol.for("@zitadel/api/auth:csrf");
58
+ function csrfSlot() {
59
+ const global = globalThis;
60
+ const existing = global[CSRF_SLOT];
61
+ if (existing) return existing;
62
+ const slot = {};
63
+ global[CSRF_SLOT] = slot;
64
+ return slot;
65
+ }
66
+ /** The token to send to `origin`, if it was issued there. */
67
+ function apiCsrfTokenFor(origin) {
68
+ const slot = csrfSlot();
69
+ return origin !== void 0 && slot.tokenOrigin === origin ? slot.token : void 0;
70
+ }
71
+ /** The rejection handler for a refusal from `origin`, if it was registered for it. */
72
+ function apiCsrfRejectionHandlerFor(origin) {
73
+ const slot = csrfSlot();
74
+ return origin !== void 0 && slot.handlerOrigin === origin ? slot.onRejected : void 0;
75
+ }
50
76
  //#endregion
51
77
  //#region ../api/dist/runtime/fetch.mjs
78
+ /** The header the session-bound CSRF token travels in (ADR 053 §5). */
79
+ const CSRF_HEADER = "X-Zitadel-CSRF";
80
+ const SAFE_METHODS = /* @__PURE__ */ new Set([
81
+ "GET",
82
+ "HEAD",
83
+ "OPTIONS"
84
+ ]);
85
+ /** The code the server answers a refused CSRF check with. */
86
+ const CSRF_INVALID = "auth.csrf_invalid";
52
87
  /**
53
88
  * Framework-neutral failure type the orval-generated client throws on
54
89
  * any non-2xx response. Carries the HTTP status, the parsed error body
@@ -73,39 +108,157 @@ var ApiError = class extends Error {
73
108
  }
74
109
  };
75
110
  /**
111
+ * Thrown when a request got no response at all: the connection was refused or
112
+ * reset, the host did not resolve, or the server accepted the connection but
113
+ * did not answer in time. The counterpart to {@link ApiError}, which is a
114
+ * response that came back with a failing status.
115
+ *
116
+ * `fetch` only rejects when no response arrived, so this is decided by the
117
+ * fact that it rejected, never by how a runtime words the failure. The
118
+ * runtime's own error stays on `cause` for debugging.
119
+ */
120
+ var NetworkError = class extends Error {
121
+ url;
122
+ /** `timeout` when a deadline cut the request off, `unreachable` otherwise. */
123
+ reason;
124
+ constructor(url, reason, message, options) {
125
+ super(message, options);
126
+ this.name = "NetworkError";
127
+ this.url = url;
128
+ this.reason = reason;
129
+ }
130
+ };
131
+ let requestPolicy = {};
132
+ function setRequestPolicy(policy) {
133
+ requestPolicy = policy;
134
+ }
135
+ /**
76
136
  * The orval `mutator` for the fetch client. Every generated operation
77
137
  * routes its request through this function instead of the global
78
138
  * `fetch`. We pin three concerns here so generated call sites stay
79
139
  * focused on the shape of one HTTP call:
80
140
  *
81
141
  * - bearer auth — read from `runtime/auth.ts` and attached automatically;
142
+ * - the CSRF header — the session-bound token from `runtime/auth.ts`, on
143
+ * unsafe methods to the origin it was issued for, when a first-party surface
144
+ * has set one; an unsafe request to that origin refused with
145
+ * `403 auth.csrf_invalid` asks the registered rejection handler for a fresh
146
+ * token and is retried once with it, only if the handler returns one (the
147
+ * session still belongs to the same person);
82
148
  * - non-2xx → throw — orval's stock client parses the body regardless
83
149
  * of status, so callers would have to inspect every response. Throw
84
150
  * `ApiError` on `!res.ok` so failures interrupt control flow;
85
151
  * - body parsing — return the parsed JSON typed as `T` (the operation's
86
152
  * return type, threaded through by orval), or `undefined` for the
87
- * spec's `204`/`205`/`304` no-body responses.
153
+ * spec's `204`/`205`/`304` no-body responses;
154
+ * - no response → throw {@link NetworkError}, or the abort reason when the
155
+ * caller cancelled (see {@link request}).
88
156
  */
89
157
  async function customFetch(url, options) {
158
+ const policy = requestPolicy;
90
159
  const token = getApiAuthToken();
91
160
  const headers = new Headers(options.headers);
92
161
  if (token && !headers.has("authorization")) headers.set("authorization", `Bearer ${token}`);
93
- const res = await fetch(url, {
162
+ const method = (options.method ?? "GET").toUpperCase();
163
+ const unsafe = !SAFE_METHODS.has(method) && !headers.has("X-Zitadel-CSRF");
164
+ const target = originOf(url);
165
+ const csrfToken = apiCsrfTokenFor(target);
166
+ if (unsafe && csrfToken) headers.set(CSRF_HEADER, csrfToken);
167
+ let { res, rawBody: parsed } = await request(url, {
94
168
  ...options,
95
169
  headers
96
- });
97
- const rawBody = [
98
- 204,
99
- 205,
100
- 304
101
- ].includes(res.status) ? "" : await res.text();
102
- const parsed = rawBody ? safeJsonParse(rawBody) : void 0;
170
+ }, policy, readBody);
171
+ const onRejected = apiCsrfRejectionHandlerFor(target);
172
+ if (unsafe && onRejected && res.status === 403 && apiErrorCode(parsed) === CSRF_INVALID && !isStream(options.body)) {
173
+ const fresh = await onRejected().catch(() => void 0);
174
+ if (fresh && fresh !== csrfToken) {
175
+ headers.set(CSRF_HEADER, fresh);
176
+ ({res, rawBody: parsed} = await request(url, {
177
+ ...options,
178
+ headers
179
+ }, policy, readBody));
180
+ }
181
+ }
103
182
  if (!res.ok) {
104
183
  const message = `${options.method ?? "GET"} ${url} returned ${res.status}`;
105
184
  throw new ApiError(res.status, url, parsed, message);
106
185
  }
107
186
  return parsed;
108
187
  }
188
+ /** The parsed body, or `undefined` for the spec's no-body responses. */
189
+ async function readBody(res) {
190
+ if ([
191
+ 204,
192
+ 205,
193
+ 304
194
+ ].includes(res.status)) return void 0;
195
+ const rawBody = await res.text();
196
+ return rawBody ? safeJsonParse(rawBody) : void 0;
197
+ }
198
+ /** The request's origin, resolved against the page for a relative URL. */
199
+ function originOf(url) {
200
+ try {
201
+ return new URL(url, globalThis.location?.href).origin;
202
+ } catch {
203
+ return;
204
+ }
205
+ }
206
+ function isStream(body) {
207
+ return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
208
+ }
209
+ /**
210
+ * `fetch` bound by a {@link RequestPolicy}, with its failures typed.
211
+ *
212
+ * The policy's signal, its deadline and any signal on `init` are combined, and
213
+ * `read` runs under them too, so a server that sends headers and then stalls
214
+ * mid-body is cut off as well. When the request does not complete:
215
+ *
216
+ * - a deadline fired → {@link NetworkError} with reason `timeout`;
217
+ * - any other abort → the signal's own reason, rethrown untouched, because a
218
+ * cancellation is the caller's decision and the caller knows what it means;
219
+ * - anything else → {@link NetworkError} with reason `unreachable`.
220
+ *
221
+ * Exported for the few callers that need the raw {@link Response} (a
222
+ * `Set-Cookie` header the generated client does not expose).
223
+ */
224
+ async function request(url, init, policy = {}, read) {
225
+ const signals = [init.signal, policy.signal].filter((signal) => signal != null);
226
+ if (policy.timeoutMs !== void 0) signals.push(AbortSignal.timeout(policy.timeoutMs));
227
+ const signal = signals.length > 0 ? AbortSignal.any(signals) : void 0;
228
+ const method = init.method ?? "GET";
229
+ try {
230
+ const res = await fetch(url, {
231
+ ...init,
232
+ signal
233
+ });
234
+ return {
235
+ res,
236
+ rawBody: read ? await read(res) : void 0
237
+ };
238
+ } catch (error) {
239
+ if (signal?.aborted) {
240
+ const reason = signal.reason;
241
+ if (reason instanceof DOMException && reason.name === "TimeoutError") throw new NetworkError(url, "timeout", `${method} ${url} timed out`, { cause: reason });
242
+ throw reason;
243
+ }
244
+ const code = errnoOf(error);
245
+ throw new NetworkError(url, "unreachable", `${method} ${url} got no response${code ? ` (${code})` : ""}`, { cause: error });
246
+ }
247
+ }
248
+ /**
249
+ * The errno a runtime attached to a failed request, if any, for the message.
250
+ * Undici nests it on `cause`, inside an `AggregateError` when it tried more
251
+ * than one address. Only ever used to describe the failure, never to decide
252
+ * that it was one.
253
+ */
254
+ function errnoOf(error) {
255
+ let node = error;
256
+ for (let depth = 0; depth < 4 && typeof node === "object" && node !== null; depth += 1) {
257
+ const { code, errors } = node;
258
+ if (typeof code === "string") return code;
259
+ node = Array.isArray(errors) ? errors[0] : node.cause;
260
+ }
261
+ }
109
262
  /**
110
263
  * `JSON.parse` wrapped so a non-JSON body (e.g. an HTML 502 from a
111
264
  * proxy) becomes `{ raw: "<text>" }` instead of throwing inside
@@ -119,6 +272,30 @@ function safeJsonParse(text) {
119
272
  return { raw: text };
120
273
  }
121
274
  }
275
+ /**
276
+ * The `code` of the server's `{code, message, details}` error envelope: from an
277
+ * {@link ApiError}, or from a parsed response body. `undefined` when there is
278
+ * none, e.g. an HTML error page from a proxy.
279
+ */
280
+ function apiErrorCode(errorOrBody) {
281
+ const body = errorOrBody instanceof ApiError ? errorOrBody.body : errorOrBody;
282
+ return isRecord(body) && typeof body.code === "string" ? body.code : void 0;
283
+ }
284
+ function isRecord(value) {
285
+ return typeof value === "object" && value !== null && !Array.isArray(value);
286
+ }
287
+ //#endregion
288
+ //#region ../api/dist/rolldown-runtime-D7D4PA-g.mjs
289
+ var __defProp = Object.defineProperty;
290
+ var __exportAll = (all, no_symbols) => {
291
+ let target = {};
292
+ for (var name in all) __defProp(target, name, {
293
+ get: all[name],
294
+ enumerable: true
295
+ });
296
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
297
+ return target;
298
+ };
122
299
  //#endregion
123
300
  //#region ../api/dist/generated/endpoints/zitadelNextGen.mjs
124
301
  /**
@@ -129,7 +306,9 @@ function safeJsonParse(text) {
129
306
  * OpenAPI spec version: 0.0.1
130
307
  */
131
308
  var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
309
+ addOrigin: () => addOrigin,
132
310
  beginUserPasskeyRegistration: () => beginUserPasskeyRegistration,
311
+ buildRelease: () => buildRelease,
133
312
  completeClaim: () => completeClaim,
134
313
  createAuthAttempt: () => createAuthAttempt,
135
314
  createBranding: () => createBranding,
@@ -151,9 +330,11 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
151
330
  deleteVariable: () => deleteVariable,
152
331
  exchangeHandoff: () => exchangeHandoff,
153
332
  finishUserPasskeyRegistration: () => finishUserPasskeyRegistration,
333
+ getAddOriginUrl: () => getAddOriginUrl,
154
334
  getAuthAttempt: () => getAuthAttempt,
155
335
  getBeginUserPasskeyRegistrationUrl: () => getBeginUserPasskeyRegistrationUrl,
156
336
  getBrandingById: () => getBrandingById,
337
+ getBuildReleaseUrl: () => getBuildReleaseUrl,
157
338
  getClaimStatus: () => getClaimStatus,
158
339
  getClaimWindow: () => getClaimWindow,
159
340
  getCompleteClaimUrl: () => getCompleteClaimUrl,
@@ -176,7 +357,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
176
357
  getDeleteUserByIDUrl: () => getDeleteUserByIDUrl,
177
358
  getDeleteVariableUrl: () => getDeleteVariableUrl,
178
359
  getDeploymentById: () => getDeploymentById,
179
- getEnvironmentByName: () => getEnvironmentByName,
360
+ getDeploymentVariables: () => getDeploymentVariables,
180
361
  getEvent: () => getEvent,
181
362
  getExchangeHandoffUrl: () => getExchangeHandoffUrl,
182
363
  getFinishUserPasskeyRegistrationUrl: () => getFinishUserPasskeyRegistrationUrl,
@@ -187,7 +368,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
187
368
  getGetClaimStatusUrl: () => getGetClaimStatusUrl,
188
369
  getGetClaimWindowUrl: () => getGetClaimWindowUrl,
189
370
  getGetDeploymentByIdUrl: () => getGetDeploymentByIdUrl,
190
- getGetEnvironmentByNameUrl: () => getGetEnvironmentByNameUrl,
371
+ getGetDeploymentVariablesUrl: () => getGetDeploymentVariablesUrl,
191
372
  getGetEventUrl: () => getGetEventUrl,
192
373
  getGetFlowDefinitionUrl: () => getGetFlowDefinitionUrl,
193
374
  getGetFlowStepUrl: () => getGetFlowStepUrl,
@@ -196,7 +377,9 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
196
377
  getGetIdpByIdUrl: () => getGetIdpByIdUrl,
197
378
  getGetIdpRevisionByIdUrl: () => getGetIdpRevisionByIdUrl,
198
379
  getGetLiveUrl: () => getGetLiveUrl,
380
+ getGetMySessionCsrfTokenUrl: () => getGetMySessionCsrfTokenUrl,
199
381
  getGetMySessionUrl: () => getGetMySessionUrl,
382
+ getGetMyUserSchemaUrl: () => getGetMyUserSchemaUrl,
200
383
  getGetMyUserUrl: () => getGetMyUserUrl,
201
384
  getGetProjectUrl: () => getGetProjectUrl,
202
385
  getGetReadyUrl: () => getGetReadyUrl,
@@ -215,18 +398,22 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
215
398
  getIssueChallengeUrl: () => getIssueChallengeUrl,
216
399
  getListBrandingUrl: () => getListBrandingUrl,
217
400
  getListDeploymentsUrl: () => getListDeploymentsUrl,
218
- getListEnvironmentsUrl: () => getListEnvironmentsUrl,
219
401
  getListEventsUrl: () => getListEventsUrl,
220
402
  getListFlowDefinitionsUrl: () => getListFlowDefinitionsUrl,
221
403
  getListIdpRevisionsUrl: () => getListIdpRevisionsUrl,
222
404
  getListMyProjectsUrl: () => getListMyProjectsUrl,
405
+ getListMyTeamsUrl: () => getListMyTeamsUrl,
406
+ getListPreviewsUrl: () => getListPreviewsUrl,
223
407
  getListReleasesUrl: () => getListReleasesUrl,
224
408
  getListSchemasUrl: () => getListSchemasUrl,
409
+ getListUserIdentityLinksUrl: () => getListUserIdentityLinksUrl,
225
410
  getListUserPasskeysUrl: () => getListUserPasskeysUrl,
226
411
  getListUserTeamsUrl: () => getListUserTeamsUrl,
227
412
  getLive: () => getLive,
228
413
  getMySession: () => getMySession,
414
+ getMySessionCsrfToken: () => getMySessionCsrfToken,
229
415
  getMyUser: () => getMyUser,
416
+ getMyUserSchema: () => getMyUserSchema,
230
417
  getPatchMyUserUrl: () => getPatchMyUserUrl,
231
418
  getPatchProjectUrl: () => getPatchProjectUrl,
232
419
  getPatchUserByIDUrl: () => getPatchUserByIDUrl,
@@ -239,8 +426,12 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
239
426
  getQueryUsersUrl: () => getQueryUsersUrl,
240
427
  getReady: () => getReady,
241
428
  getReleaseById: () => getReleaseById,
429
+ getRemoveOriginUrl: () => getRemoveOriginUrl,
430
+ getRemovePreviewUrl: () => getRemovePreviewUrl,
242
431
  getRevokeMySessionUrl: () => getRevokeMySessionUrl,
432
+ getRevokeReleaseUrl: () => getRevokeReleaseUrl,
243
433
  getRevokeSessionUrl: () => getRevokeSessionUrl,
434
+ getRollbackDeploymentUrl: () => getRollbackDeploymentUrl,
244
435
  getSchemaById: () => getSchemaById,
245
436
  getSession: () => getSession,
246
437
  getSetUserPasswordUrl: () => getSetUserPasswordUrl,
@@ -256,13 +447,15 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
256
447
  issueChallenge: () => issueChallenge,
257
448
  listBranding: () => listBranding,
258
449
  listDeployments: () => listDeployments,
259
- listEnvironments: () => listEnvironments,
260
450
  listEvents: () => listEvents,
261
451
  listFlowDefinitions: () => listFlowDefinitions,
262
452
  listIdpRevisions: () => listIdpRevisions,
263
453
  listMyProjects: () => listMyProjects,
454
+ listMyTeams: () => listMyTeams,
455
+ listPreviews: () => listPreviews,
264
456
  listReleases: () => listReleases,
265
457
  listSchemas: () => listSchemas,
458
+ listUserIdentityLinks: () => listUserIdentityLinks,
266
459
  listUserPasskeys: () => listUserPasskeys,
267
460
  listUserTeams: () => listUserTeams,
268
461
  patchMyUser: () => patchMyUser,
@@ -274,8 +467,12 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
274
467
  querySessions: () => querySessions,
275
468
  queryTeams: () => queryTeams,
276
469
  queryUsers: () => queryUsers,
470
+ removeOrigin: () => removeOrigin,
471
+ removePreview: () => removePreview,
277
472
  revokeMySession: () => revokeMySession,
473
+ revokeRelease: () => revokeRelease,
278
474
  revokeSession: () => revokeSession,
475
+ rollbackDeployment: () => rollbackDeployment,
279
476
  setUserPassword: () => setUserPassword,
280
477
  submitFlowStep: () => submitFlowStep,
281
478
  updateTeam: () => updateTeam,
@@ -330,6 +527,11 @@ const getCreateUserUrl = (params) => {
330
527
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users?${stringifiedParams}` : `${getProxyPath()}/users`;
331
528
  };
332
529
  /**
530
+ * Creates a user whose attributes satisfy the user schema the request names.
531
+ *
532
+ * The server assigns the user's id. With `team_id`, the user also becomes an
533
+ * active member of that team. A value the schema marks unique that another
534
+ * user already holds is refused with `409`.
333
535
  * @summary Create user
334
536
  */
335
537
  const createUser = async (createUserBody, params, options) => {
@@ -366,8 +568,8 @@ const getQueryUsersUrl = (params) => {
366
568
  * project is listed.
367
569
  *
368
570
  * Accepts either a project secret (`oauth2`) or a user-bound Console
369
- * session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
370
- * is a follow-up (#1140).
571
+ * session cookie (`nextgenSession`). Cookie-authenticated requests
572
+ * follow the scheme's CSRF rules (`nextgenSession`).
371
573
  * @summary Query users
372
574
  */
373
575
  const queryUsers = async (queryUsersBody, params, options) => {
@@ -398,6 +600,10 @@ const getGetUserByIDUrl = (userId, params) => {
398
600
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
399
601
  };
400
602
  /**
603
+ * Returns a user by its id, with the attributes its schema defines.
604
+ *
605
+ * With `team_id`, the user is returned only while they are an active member of
606
+ * that team.
401
607
  * @summary Get user by ID
402
608
  */
403
609
  const getUserByID = async (userId, params, options) => {
@@ -439,6 +645,11 @@ const getDeleteUserByIDUrl = (userId) => {
439
645
  return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
440
646
  };
441
647
  /**
648
+ * Deletes a user and removes them from every team they belong to.
649
+ *
650
+ * The user is removed, not deactivated, and the deletion emits `user.deleted`.
651
+ * With a project secret the request is idempotent: deleting a user that exists
652
+ * in no project succeeds without changing anything.
442
653
  * @summary Delete user by ID
443
654
  */
444
655
  const deleteUserByID = async (userId, options) => {
@@ -447,6 +658,25 @@ const deleteUserByID = async (userId, options) => {
447
658
  method: "DELETE"
448
659
  });
449
660
  };
661
+ const getListUserIdentityLinksUrl = (userId, params) => {
662
+ const normalizedParams = new URLSearchParams();
663
+ Object.entries(params || {}).forEach(([key, value]) => {
664
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
665
+ });
666
+ const stringifiedParams = normalizedParams.toString();
667
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/identity_links?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/identity_links`;
668
+ };
669
+ /**
670
+ * The identity provider accounts a sign-in linked to the user, oldest first.
671
+ * The provider's subject and claims are never returned.
672
+ * @summary List the provider accounts linked to a user
673
+ */
674
+ const listUserIdentityLinks = async (userId, params, options) => {
675
+ return customFetch(getListUserIdentityLinksUrl(userId, params), {
676
+ ...options,
677
+ method: "GET"
678
+ });
679
+ };
450
680
  const getListUserPasskeysUrl = (userId, params) => {
451
681
  const normalizedParams = new URLSearchParams();
452
682
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -456,6 +686,11 @@ const getListUserPasskeysUrl = (userId, params) => {
456
686
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys`;
457
687
  };
458
688
  /**
689
+ * Returns the passkeys registered for a user, newest first, paginated with a
690
+ * cursor.
691
+ *
692
+ * Each passkey carries its id, its name and when it was registered, never the
693
+ * credential itself.
459
694
  * @summary List user passkeys
460
695
  */
461
696
  const listUserPasskeys = async (userId, params, options) => {
@@ -529,6 +764,11 @@ const getSetUserPasswordUrl = (userId) => {
529
764
  return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/password`;
530
765
  };
531
766
  /**
767
+ * Sets a user's password, hashed with the project's current password hashing
768
+ * policy.
769
+ *
770
+ * The new password replaces the current one, and setting it emits
771
+ * `auth.factor.password.set`.
532
772
  * @summary Set user password
533
773
  */
534
774
  const setUserPassword = async (userId, setUserPasswordBody, options) => {
@@ -574,28 +814,48 @@ const listUserTeams = async (userId, params, options) => {
574
814
  method: "GET"
575
815
  });
576
816
  };
577
- const getGetMyUserUrl = () => {
578
- return `${getProxyPath()}/users/me`;
817
+ const getGetMyUserUrl = (params) => {
818
+ const normalizedParams = new URLSearchParams();
819
+ Object.entries(params || {}).forEach(([key, value]) => {
820
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
821
+ });
822
+ const stringifiedParams = normalizedParams.toString();
823
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me?${stringifiedParams}` : `${getProxyPath()}/users/me`;
579
824
  };
580
825
  /**
826
+ * Returns the user signed in to the session that authenticates the request.
827
+ *
828
+ * The project and the user both come from the session cookie, so a caller only
829
+ * ever reads their own user.
830
+ *
831
+ * With `project_id`, the user is returned only when the session belongs to
832
+ * that project.
581
833
  * @summary Get my user information
582
834
  */
583
- const getMyUser = async (options) => {
584
- return customFetch(getGetMyUserUrl(), {
835
+ const getMyUser = async (params, options) => {
836
+ return customFetch(getGetMyUserUrl(params), {
585
837
  ...options,
586
838
  method: "GET"
587
839
  });
588
840
  };
589
- const getPatchMyUserUrl = () => {
590
- return `${getProxyPath()}/users/me`;
841
+ const getPatchMyUserUrl = (params) => {
842
+ const normalizedParams = new URLSearchParams();
843
+ Object.entries(params || {}).forEach(([key, value]) => {
844
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
845
+ });
846
+ const stringifiedParams = normalizedParams.toString();
847
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me?${stringifiedParams}` : `${getProxyPath()}/users/me`;
591
848
  };
592
849
  /**
593
850
  * Partially updates the caller's own schema-defined attributes. The merged
594
851
  * result is validated against the user's schema before commit. Concurrent
595
852
  * writes are last-write-wins.
853
+ *
854
+ * With `project_id`, the user is updated only when the session belongs to
855
+ * that project.
596
856
  * @summary Update my user information
597
857
  */
598
- const patchMyUser = async (patchMyUserBody, options) => {
858
+ const patchMyUser = async (patchMyUserBody, params, options) => {
599
859
  const getHeaders = (h) => {
600
860
  if (!h) return {};
601
861
  if (h instanceof Headers) return Object.fromEntries(h.entries());
@@ -604,7 +864,7 @@ const patchMyUser = async (patchMyUserBody, options) => {
604
864
  for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
605
865
  return headers;
606
866
  };
607
- return customFetch(getPatchMyUserUrl(), {
867
+ return customFetch(getPatchMyUserUrl(params), {
608
868
  ...options,
609
869
  method: "PATCH",
610
870
  headers: {
@@ -630,6 +890,10 @@ const getListMyProjectsUrl = (params) => {
630
890
  * This is not the same question as `queryProjects`, which answers with the one
631
891
  * project the calling credential is bound to. Here the session is the caller
632
892
  * and the grants are the answer, so the list spans projects.
893
+ *
894
+ * With `project_id`, the projects are listed only when the session belongs to
895
+ * that project. It names the project the session was signed in to, not one to
896
+ * list.
633
897
  * @summary List the projects I can act on
634
898
  */
635
899
  const listMyProjects = async (params, options) => {
@@ -638,6 +902,48 @@ const listMyProjects = async (params, options) => {
638
902
  method: "GET"
639
903
  });
640
904
  };
905
+ const getGetMyUserSchemaUrl = (params) => {
906
+ const normalizedParams = new URLSearchParams();
907
+ Object.entries(params || {}).forEach(([key, value]) => {
908
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
909
+ });
910
+ const stringifiedParams = normalizedParams.toString();
911
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me/schema?${stringifiedParams}` : `${getProxyPath()}/users/me/schema`;
912
+ };
913
+ /**
914
+ * The schema the signed-in user's own record is validated against.
915
+ *
916
+ * With `project_id`, the schema is returned only when the session belongs to
917
+ * that project.
918
+ * @summary Get my user schema
919
+ */
920
+ const getMyUserSchema = async (params, options) => {
921
+ return customFetch(getGetMyUserSchemaUrl(params), {
922
+ ...options,
923
+ method: "GET"
924
+ });
925
+ };
926
+ const getListMyTeamsUrl = (params) => {
927
+ const normalizedParams = new URLSearchParams();
928
+ Object.entries(params || {}).forEach(([key, value]) => {
929
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
930
+ });
931
+ const stringifiedParams = normalizedParams.toString();
932
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me/teams?${stringifiedParams}` : `${getProxyPath()}/users/me/teams`;
933
+ };
934
+ /**
935
+ * The signed-in user's own team roster, ordered by team name.
936
+ *
937
+ * With `project_id`, the teams are listed only when the session belongs to
938
+ * that project.
939
+ * @summary List the teams I belong to
940
+ */
941
+ const listMyTeams = async (params, options) => {
942
+ return customFetch(getListMyTeamsUrl(params), {
943
+ ...options,
944
+ method: "GET"
945
+ });
946
+ };
641
947
  const getCreateFlowUrl = () => {
642
948
  return `${getProxyPath()}/flow`;
643
949
  };
@@ -719,6 +1025,27 @@ const getSubmitFlowStepUrl = (id) => {
719
1025
  * If a stacked flow (e.g., recovery pivoted from login) finishes, the server
720
1026
  * auto-pops to the parent flow and returns the parent's next step — the
721
1027
  * frontend never sees a `complete` for intermediate flows.
1028
+ *
1029
+ * ## External sign-in
1030
+ *
1031
+ * `{action: "sso", sso_provider_id, return_target}` on a step that offers
1032
+ * `sso_providers` returns the engine-emitted `sso-redirect` step, whose
1033
+ * `redirect_url` the frontend navigates to.
1034
+ *
1035
+ * - The flow state does not change, but `_zflow` is re-sealed like on
1036
+ * every response, so its ten-minute window restarts at this submission;
1037
+ * the external sign-in and the return must complete within it.
1038
+ * - A second `Set-Cookie` line carries the browser-binding cookie the
1039
+ * callback checks: `HttpOnly`, `Path=/`, `SameSite=Lax`.
1040
+ * - On every host except http loopback it is `__Host-_zsso` with `Secure`.
1041
+ * - When the request host is http loopback (local development, where
1042
+ * Safari rejects `Secure`), it is `_zsso` with no `Secure`; the
1043
+ * `__Host-` prefix is dropped because it requires `Secure`.
1044
+ *
1045
+ * A connection whose `client_id` is a `${{ NAME }}` reference has it filled
1046
+ * from the project's variables. A provider the engine cannot start a
1047
+ * sign-in with, including a reference with no variable behind it,
1048
+ * re-renders the step with `error.sso_unavailable`.
722
1049
  * @summary Submit step data and advance
723
1050
  */
724
1051
  const submitFlowStep = async (id, submitFlowStepBody, options) => {
@@ -883,6 +1210,12 @@ const getCreateProjectUrl = () => {
883
1210
  return `${getProxyPath()}/projects`;
884
1211
  };
885
1212
  /**
1213
+ * Creates a project and returns its project secret and preview secret, which no
1214
+ * other endpoint returns.
1215
+ *
1216
+ * The request needs no credential and is rate-limited. Unless `seed_defaults` is
1217
+ * `false`, the project starts with a default user schema and flow; the CLI turns
1218
+ * that off and uploads its own from `.zitadel/`.
886
1219
  * @summary Create project
887
1220
  */
888
1221
  const createProject = async (createProjectBody, options) => {
@@ -908,6 +1241,12 @@ const getQueryProjectsUrl = () => {
908
1241
  return `${getProxyPath()}/projects/query`;
909
1242
  };
910
1243
  /**
1244
+ * Returns the project the project secret belongs to, as a page of at most one
1245
+ * project.
1246
+ *
1247
+ * A credential is scoped to one project until ADR 036 widens it, so the filters
1248
+ * and sorting apply to that project alone. The projects a signed-in person can
1249
+ * act on are listed by `GET /users/me/projects`.
911
1250
  * @summary Query projects
912
1251
  */
913
1252
  const queryProjects = async (queryProjectsBody, options) => {
@@ -1062,6 +1401,118 @@ const getClaimWindow = async (projectId, params, options) => {
1062
1401
  method: "GET"
1063
1402
  });
1064
1403
  };
1404
+ const getAddOriginUrl = (projectId) => {
1405
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/origins`;
1406
+ };
1407
+ /**
1408
+ * Adds one `{pattern, kind}` to the project's origins. A primary pattern
1409
+ * must be an exact URL (no wildcard). Preview patterns may include a single
1410
+ * DNS-label wildcard. Adding a pattern that already exists with the same
1411
+ * kind is idempotent and answers 201 with the stored origin.
1412
+ * @summary Add an origin pattern
1413
+ */
1414
+ const addOrigin = async (projectId, addOriginBody, options) => {
1415
+ const getHeaders = (h) => {
1416
+ if (!h) return {};
1417
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1418
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1419
+ const headers = {};
1420
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1421
+ return headers;
1422
+ };
1423
+ return customFetch(getAddOriginUrl(projectId), {
1424
+ ...options,
1425
+ method: "POST",
1426
+ headers: {
1427
+ "Content-Type": "application/json",
1428
+ ...getHeaders(options?.headers)
1429
+ },
1430
+ body: JSON.stringify(addOriginBody)
1431
+ });
1432
+ };
1433
+ const getRemoveOriginUrl = (projectId) => {
1434
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/origins/remove`;
1435
+ };
1436
+ /**
1437
+ * Removes one pattern from the project's origins. Requests from URLs only
1438
+ * that pattern admitted are refused from then on; live previews and
1439
+ * deployment history are untouched. Removing a pattern that is already
1440
+ * absent is idempotent and answers 204.
1441
+ * @summary Remove an origin pattern
1442
+ */
1443
+ const removeOrigin = async (projectId, removeOriginBody, options) => {
1444
+ const getHeaders = (h) => {
1445
+ if (!h) return {};
1446
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1447
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1448
+ const headers = {};
1449
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1450
+ return headers;
1451
+ };
1452
+ return customFetch(getRemoveOriginUrl(projectId), {
1453
+ ...options,
1454
+ method: "POST",
1455
+ headers: {
1456
+ "Content-Type": "application/json",
1457
+ ...getHeaders(options?.headers)
1458
+ },
1459
+ body: JSON.stringify(removeOriginBody)
1460
+ });
1461
+ };
1462
+ const getListPreviewsUrl = (projectId, params) => {
1463
+ const normalizedParams = new URLSearchParams();
1464
+ Object.entries(params || {}).forEach(([key, value]) => {
1465
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1466
+ });
1467
+ const stringifiedParams = normalizedParams.toString();
1468
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/previews?${stringifiedParams}` : `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/previews`;
1469
+ };
1470
+ /**
1471
+ * Lists the project's live previews, newest first by `created_at`. An
1472
+ * expired or removed preview is not listed; what was deployed to it stays
1473
+ * in `GET /deployments`.
1474
+ * @summary List previews
1475
+ */
1476
+ const listPreviews = async (projectId, params, options) => {
1477
+ return customFetch(getListPreviewsUrl(projectId, params), {
1478
+ ...options,
1479
+ method: "GET"
1480
+ });
1481
+ };
1482
+ const getRemovePreviewUrl = (projectId) => {
1483
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/previews/remove`;
1484
+ };
1485
+ /**
1486
+ * Ends a preview before it expires: the URL stops being served at once.
1487
+ * The deployments to it stay in the history.
1488
+ *
1489
+ * Idempotent: a URL with no live preview, including one that has already
1490
+ * expired or was removed before, answers `204` too, so a cleanup that
1491
+ * races the expiry still succeeds.
1492
+ *
1493
+ * The URL travels in the body rather than the path because an origin
1494
+ * contains `/`.
1495
+ * @summary Remove a preview
1496
+ */
1497
+ const removePreview = async (projectId, removePreviewBody, options) => {
1498
+ const getHeaders = (h) => {
1499
+ if (!h) return {};
1500
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1501
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1502
+ const headers = {};
1503
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1504
+ return headers;
1505
+ };
1506
+ return customFetch(getRemovePreviewUrl(projectId), {
1507
+ ...options,
1508
+ method: "POST",
1509
+ headers: {
1510
+ "Content-Type": "application/json",
1511
+ ...getHeaders(options?.headers)
1512
+ },
1513
+ body: JSON.stringify(removePreviewBody)
1514
+ });
1515
+ };
1065
1516
  const getCreateSessionUrl = () => {
1066
1517
  return `${getProxyPath()}/sessions`;
1067
1518
  };
@@ -1227,42 +1678,85 @@ const revokeSession = async (sessionId, options) => {
1227
1678
  method: "DELETE"
1228
1679
  });
1229
1680
  };
1230
- const getGetMySessionUrl = () => {
1231
- return `${getProxyPath()}/sessions/me`;
1681
+ const getGetMySessionUrl = (params) => {
1682
+ const normalizedParams = new URLSearchParams();
1683
+ Object.entries(params || {}).forEach(([key, value]) => {
1684
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1685
+ });
1686
+ const stringifiedParams = normalizedParams.toString();
1687
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/me?${stringifiedParams}` : `${getProxyPath()}/sessions/me`;
1232
1688
  };
1233
1689
  /**
1234
1690
  * Returns the current state of the current session including its factors and all currently
1235
1691
  * satisfied assurance levels.
1236
1692
  *
1693
+ * With `project_id`, the session is returned only when it belongs to that project.
1694
+ *
1237
1695
  * `assurance_levels[]` may shrink over time as factor freshness windows expire,
1238
1696
  * without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1239
1697
  * against the same `session_id`) to restore a dropped assurance level.
1240
1698
  * @summary Get my session state
1241
1699
  */
1242
- const getMySession = async (options) => {
1243
- return customFetch(getGetMySessionUrl(), {
1700
+ const getMySession = async (params, options) => {
1701
+ return customFetch(getGetMySessionUrl(params), {
1244
1702
  ...options,
1245
1703
  method: "GET"
1246
1704
  });
1247
1705
  };
1248
- const getRevokeMySessionUrl = () => {
1249
- return `${getProxyPath()}/sessions/me`;
1706
+ const getRevokeMySessionUrl = (params) => {
1707
+ const normalizedParams = new URLSearchParams();
1708
+ Object.entries(params || {}).forEach(([key, value]) => {
1709
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1710
+ });
1711
+ const stringifiedParams = normalizedParams.toString();
1712
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/me?${stringifiedParams}` : `${getProxyPath()}/sessions/me`;
1250
1713
  };
1251
1714
  /**
1252
1715
  * Logs out by permanently deleting the session.
1253
1716
  *
1254
1717
  * The `__nextgen_session` cookie issued at creation (or superseded by a handoff
1255
- * exchange) is required. Idempotent: if the session is already gone this still
1256
- * returns 204. Any tokens derived from the session are invalidated, and the
1257
- * cookie itself is cleared in the response.
1718
+ * exchange) is required, with the session's token from `GET /sessions/me/csrf`
1719
+ * in the `X-Zitadel-CSRF` header. Idempotent: if the session is already gone
1720
+ * this still returns 204. Any tokens derived from the session are invalidated,
1721
+ * and the cookie itself is cleared in the response.
1722
+ *
1723
+ * With `project_id`, only a session of that project is deleted. A session of
1724
+ * another project is left alone, and so is its cookie.
1258
1725
  * @summary Revoke my session
1259
1726
  */
1260
- const revokeMySession = async (options) => {
1261
- return customFetch(getRevokeMySessionUrl(), {
1727
+ const revokeMySession = async (params, options) => {
1728
+ return customFetch(getRevokeMySessionUrl(params), {
1262
1729
  ...options,
1263
1730
  method: "DELETE"
1264
1731
  });
1265
1732
  };
1733
+ const getGetMySessionCsrfTokenUrl = (params) => {
1734
+ const normalizedParams = new URLSearchParams();
1735
+ Object.entries(params || {}).forEach(([key, value]) => {
1736
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1737
+ });
1738
+ const stringifiedParams = normalizedParams.toString();
1739
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/me/csrf?${stringifiedParams}` : `${getProxyPath()}/sessions/me/csrf`;
1740
+ };
1741
+ /**
1742
+ * Returns the session-bound token for cross-site request forgery protection
1743
+ * (ADR 053 §5). Browser code sends it in the `X-Zitadel-CSRF` header on the
1744
+ * state-changing requests the session cookie authenticates that require it
1745
+ * — see the `nextgenSession` scheme. It authorizes nothing on its own: the
1746
+ * HttpOnly cookie is still the credential, and a cross-site page cannot
1747
+ * read this response. It stays the same for the life of the session, so a
1748
+ * client fetches it once per session.
1749
+ *
1750
+ * With `project_id`, the token is returned only when the session belongs to
1751
+ * that project.
1752
+ * @summary Get my session's CSRF token
1753
+ */
1754
+ const getMySessionCsrfToken = async (params, options) => {
1755
+ return customFetch(getGetMySessionCsrfTokenUrl(params), {
1756
+ ...options,
1757
+ method: "GET"
1758
+ });
1759
+ };
1266
1760
  const getCreateSchemaUrl = (params) => {
1267
1761
  const normalizedParams = new URLSearchParams();
1268
1762
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -1431,6 +1925,10 @@ const getCreateTeamUrl = (params) => {
1431
1925
  return stringifiedParams.length > 0 ? `${getProxyPath()}/teams?${stringifiedParams}` : `${getProxyPath()}/teams`;
1432
1926
  };
1433
1927
  /**
1928
+ * Creates a team in the project, with a name no other team in the project has.
1929
+ *
1930
+ * A taken name is refused with `409 team.already_exists`. The new team has no
1931
+ * members yet.
1434
1932
  * @summary Create team
1435
1933
  */
1436
1934
  const createTeam = async (createTeamBody, params, options) => {
@@ -1547,45 +2045,6 @@ const updateTeam = async (teamId, updateTeamBody, options) => {
1547
2045
  body: JSON.stringify(updateTeamBody)
1548
2046
  });
1549
2047
  };
1550
- const getListEnvironmentsUrl = (params) => {
1551
- const normalizedParams = new URLSearchParams();
1552
- Object.entries(params || {}).forEach(([key, value]) => {
1553
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1554
- });
1555
- const stringifiedParams = normalizedParams.toString();
1556
- return stringifiedParams.length > 0 ? `${getProxyPath()}/environments?${stringifiedParams}` : `${getProxyPath()}/environments`;
1557
- };
1558
- /**
1559
- * Lists the project's environments ordered by name.
1560
- * @summary List environments
1561
- */
1562
- const listEnvironments = async (params, options) => {
1563
- return customFetch(getListEnvironmentsUrl(params), {
1564
- ...options,
1565
- method: "GET"
1566
- });
1567
- };
1568
- const getGetEnvironmentByNameUrl = (name, params) => {
1569
- const normalizedParams = new URLSearchParams();
1570
- Object.entries(params || {}).forEach(([key, value]) => {
1571
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1572
- });
1573
- const stringifiedParams = normalizedParams.toString();
1574
- return stringifiedParams.length > 0 ? `${getProxyPath()}/environments/${encodeURIComponent(String(name))}?${stringifiedParams}` : `${getProxyPath()}/environments/${encodeURIComponent(String(name))}`;
1575
- };
1576
- /**
1577
- * Reads one environment of the project by its name.
1578
- *
1579
- * The lookup is scoped to the project in `project_id`: a name that exists in
1580
- * another project answers `env.not_found` exactly as an unused name does.
1581
- * @summary Get an environment by name
1582
- */
1583
- const getEnvironmentByName = async (name, params, options) => {
1584
- return customFetch(getGetEnvironmentByNameUrl(name, params), {
1585
- ...options,
1586
- method: "GET"
1587
- });
1588
- };
1589
2048
  const getCreateBrandingUrl = (params) => {
1590
2049
  const normalizedParams = new URLSearchParams();
1591
2050
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -1677,19 +2136,29 @@ const getCreateIdpUrl = (params) => {
1677
2136
  * releases and auth attempts stay pinned to the revision they captured.
1678
2137
  *
1679
2138
  * Identity fields are fixed for the life of the connection and a revision
1680
- * that changes one is rejected: `protocol`, `subject_claim`, and the
1681
- * endpoints that name the authority (`issuer` for OIDC, `token_endpoint`
1682
- * and `userinfo_endpoint` for OAuth 2.0). Their values decide which provider
2139
+ * that changes one is rejected: `protocol`, `subject_claim`, and `issuer`,
2140
+ * the field that names the authority. Their values decide which provider
1683
2141
  * account a stored subject belongs to, so changing one would silently
1684
2142
  * repoint existing identities at a different provider.
1685
2143
  *
1686
- * `subject_claim` is optional for OIDC and required for OAuth 2.0. For an
1687
- * OIDC connection, `sub` is used as the default value. If a revision updates
1688
- * `subject_claim` to a different value than the one set during creation, the
1689
- * request is rejected.
2144
+ * `subject_claim` is optional, and `sub` is used as the default value. If a
2145
+ * revision updates `subject_claim` to a different value than the one set
2146
+ * during creation, the request is rejected.
2147
+ *
2148
+ * OIDC is the only protocol.
1690
2149
  *
1691
2150
  * The document is validated against the `idp-connection.json` schema before
1692
- * anything is stored.
2151
+ * anything is stored. The rules the engine applies when it starts a sign-in
2152
+ * then run on the document, so a connection that could never start one is
2153
+ * refused here instead with `idp.endpoints_partial`: the OIDC block sets an
2154
+ * endpoint without the others. It either sets no endpoint, and discovery
2155
+ * fills them, or sets `authorization_endpoint`, `token_endpoint`, `jwks_uri`,
2156
+ * and `userinfo_endpoint`. `userinfo_endpoint` may be left out when
2157
+ * `id_token_mapping` is on, but setting it alone still counts as setting an
2158
+ * endpoint. The details list the missing endpoints.
2159
+ *
2160
+ * A refused document stores nothing, and on a revise the current revision
2161
+ * stays unchanged.
1693
2162
  * @summary Create or revise an identity provider connection
1694
2163
  */
1695
2164
  const createIdp = async (createIdpBody, params, options) => {
@@ -1815,21 +2284,25 @@ const getCreateReleaseUrl = (params) => {
1815
2284
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases?${stringifiedParams}` : `${getProxyPath()}/releases`;
1816
2285
  };
1817
2286
  /**
1818
- * Bundles a release from revisions that already exist, supplied as
1819
- * `(kind, revision_id)` pairs. No new revisions are allocated — use the
1820
- * per-kind create endpoints for that, then pin the ids here.
2287
+ * Assembles a release from existing revisions, given as
2288
+ * `(kind, revision_id)` pairs. To build one from files on disk, use
2289
+ * `POST /releases/build`.
1821
2290
  *
1822
- * Every referenced `revision_id` must exist in the project. Each one's handle
1823
- * is read from the revision itself and recorded on the release, so a resource
1824
- * is always pinned under the identity it declares.
2291
+ * Each revision must exist in the project and is recorded under the handle
2292
+ * it declares. The release must be complete and consistent:
1825
2293
  *
1826
- * Creating a release does not deploy it. A release is environment-agnostic
1827
- * and the same release can later be deployed to any number of environments
1828
- * unchanged.
2294
+ * - Every handle its revisions name must be in the release: a flow's
2295
+ * `user_schema`, and the IDP connections named by a flow step's
2296
+ * `sso_providers` or a schema's `x-auth-methods.sso.providers`. A missing
2297
+ * one answers `rel.unresolved_reference`, naming the resource and the
2298
+ * handle, e.g. `flow_definition default-login: user_schema human-user not found`.
2299
+ * - Every flow is validated as on save, against the user schema revision
2300
+ * in the release. A flow that fails answers `rel.invalid`, with the
2301
+ * reason in `details`.
1829
2302
  *
1830
- * Idempotent on the pinned set: metadata is excluded from the comparison, so
1831
- * re-submitting the same revisions with a different `message` returns the
1832
- * release that already pins them rather than creating a second one.
2303
+ * Idempotent on the set of revisions: the same revisions with a different
2304
+ * `message` answer `200` with the existing release. A new release answers
2305
+ * `201`. Creating a release does not deploy it.
1833
2306
  * @summary Create a release
1834
2307
  */
1835
2308
  const createRelease = async (createReleaseBody, params, options) => {
@@ -1862,8 +2335,15 @@ const getListReleasesUrl = (params) => {
1862
2335
  /**
1863
2336
  * Lists the project's releases, newest first.
1864
2337
  *
1865
- * Entries carry metadata only — the pinned set is omitted. Read one release
1866
- * with `GET /releases/{release_id}` to get its pointers.
2338
+ * Entries carry the digest, the metadata and `revoked_at` — the pinned set
2339
+ * is omitted.
2340
+ * Read one release with `GET /releases/{release_id}` to get its pointers.
2341
+ *
2342
+ * `content_hash` looks a release up by its content, as the CLI does when a
2343
+ * person types the digest a transcript printed. The project holds at most
2344
+ * one release per digest, so the filtered list has one entry or none, and
2345
+ * an unknown digest is an empty list rather than an error. Paths take the
2346
+ * `rel_` id only; the matched entry's `id` is what to use there.
1867
2347
  * @summary List releases
1868
2348
  */
1869
2349
  const listReleases = async (params, options) => {
@@ -1872,6 +2352,66 @@ const listReleases = async (params, options) => {
1872
2352
  method: "GET"
1873
2353
  });
1874
2354
  };
2355
+ const getBuildReleaseUrl = (params) => {
2356
+ const normalizedParams = new URLSearchParams();
2357
+ Object.entries(params || {}).forEach(([key, value]) => {
2358
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2359
+ });
2360
+ const stringifiedParams = normalizedParams.toString();
2361
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/releases/build?${stringifiedParams}` : `${getProxyPath()}/releases/build`;
2362
+ };
2363
+ /**
2364
+ * Builds a release from the resources of `.zitadel/` as authored on disk,
2365
+ * grouped by kind, in one transaction: a failure anywhere leaves no
2366
+ * revision and no release. The caller records nothing.
2367
+ *
2368
+ * If the project already holds a release with the same content, the same
2369
+ * `content_hash`, the request answers `200` with that release and
2370
+ * allocates nothing, however long ago it was built. Otherwise every resource is compared against the
2371
+ * project's newest revision of the same handle: unchanged content reuses
2372
+ * that revision, changed content allocates a new one, and the request
2373
+ * answers `201` with the new release. Metadata is excluded from the
2374
+ * comparison, so the same content under a different `message` is the same
2375
+ * release.
2376
+ *
2377
+ * A structurally malformed request is refused while decoding with
2378
+ * `req.invalid`, naming the offending fields. A well-formed bundle is then
2379
+ * checked resource by resource, as each kind's create endpoint checks it,
2380
+ * and every failure is reported at once: the request answers `400` with
2381
+ * `rel.invalid`, and `details.resources` lists each resource that failed.
2382
+ * A handle that resolves neither in the bundle nor in the project answers
2383
+ * `rel.unresolved_reference`, naming the pointer and the handle.
2384
+ *
2385
+ * Building writes revisions, so besides `release.write` it needs the write
2386
+ * scope of every kind the bundle carries a resource of: `schema.write`,
2387
+ * `flow_definition.write`, `branding.write` and `idp.write`, as the
2388
+ * per-kind create endpoints do. A missing scope answers `403` with `rel.permission_denied`,
2389
+ * naming the kind. An empty kind needs no scope.
2390
+ *
2391
+ * Building a release does not deploy it. A release is not tied to an
2392
+ * origin, and the same release can later be deployed to any number of
2393
+ * origins unchanged.
2394
+ * @summary Build a release from files
2395
+ */
2396
+ const buildRelease = async (buildReleaseBody, params, options) => {
2397
+ const getHeaders = (h) => {
2398
+ if (!h) return {};
2399
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2400
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2401
+ const headers = {};
2402
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2403
+ return headers;
2404
+ };
2405
+ return customFetch(getBuildReleaseUrl(params), {
2406
+ ...options,
2407
+ method: "POST",
2408
+ headers: {
2409
+ "Content-Type": "application/json",
2410
+ ...getHeaders(options?.headers)
2411
+ },
2412
+ body: JSON.stringify(buildReleaseBody)
2413
+ });
2414
+ };
1875
2415
  const getGetReleaseByIdUrl = (releaseId, params) => {
1876
2416
  const normalizedParams = new URLSearchParams();
1877
2417
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -1881,8 +2421,11 @@ const getGetReleaseByIdUrl = (releaseId, params) => {
1881
2421
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}?${stringifiedParams}` : `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}`;
1882
2422
  };
1883
2423
  /**
1884
- * Reads one release: its metadata and the `(kind, handle, revision_id)`
1885
- * tuples it pins.
2424
+ * Reads one release: its digest, its metadata, whether it was revoked, and
2425
+ * the `(kind, handle, revision_id)` tuples it pins.
2426
+ *
2427
+ * The path takes the `rel_` id only. To find a release from its digest,
2428
+ * list with the `content_hash` filter and read the matched entry's `id`.
1886
2429
  *
1887
2430
  * Does not embed resource content. Resolve each `revision_id` through the
1888
2431
  * per-kind read endpoints when the bytes are needed.
@@ -1899,6 +2442,42 @@ const getReleaseById = async (releaseId, params, options) => {
1899
2442
  method: "GET"
1900
2443
  });
1901
2444
  };
2445
+ const getRevokeReleaseUrl = (releaseId, params) => {
2446
+ const normalizedParams = new URLSearchParams();
2447
+ Object.entries(params || {}).forEach(([key, value]) => {
2448
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2449
+ });
2450
+ const stringifiedParams = normalizedParams.toString();
2451
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}/revoke?${stringifiedParams}` : `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}/revoke`;
2452
+ };
2453
+ /**
2454
+ * Marks the release revoked, so that its content is never served again.
2455
+ * From then on the release cannot be deployed and is refused on every path
2456
+ * that would serve it, including to a build that pins its digest, with
2457
+ * `rel.revoked`.
2458
+ *
2459
+ * A release that any origin still serves cannot be revoked. An origin
2460
+ * serves the release of the newest deployment to it, so the call answers
2461
+ * `409` with `rel.in_use`, naming each such origin and that deployment.
2462
+ * Deploy another release there or roll back first, then revoke. Revoking
2463
+ * therefore never takes an origin down. Deployments that named the release
2464
+ * earlier stay in the history.
2465
+ *
2466
+ * Idempotent: revoking a release that is already revoked answers `200`
2467
+ * with the release unchanged, `revoked_at` still naming the first
2468
+ * revocation. There is no un-revoke; build a new release instead.
2469
+ *
2470
+ * Takes no body. The lookup is scoped to the project in `project_id`, so a
2471
+ * release id of another project answers not found exactly as an unknown id
2472
+ * does.
2473
+ * @summary Revoke a release
2474
+ */
2475
+ const revokeRelease = async (releaseId, params, options) => {
2476
+ return customFetch(getRevokeReleaseUrl(releaseId, params), {
2477
+ ...options,
2478
+ method: "POST"
2479
+ });
2480
+ };
1902
2481
  const getCreateGrantUrl = (params) => {
1903
2482
  const normalizedParams = new URLSearchParams();
1904
2483
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -1925,8 +2504,8 @@ const getCreateGrantUrl = (params) => {
1925
2504
  *
1926
2505
  * Accepts either a project secret (`oauth2`) or a user-bound Console
1927
2506
  * session cookie (`nextgenSession`). Session callers are authorized as
1928
- * the human against the target project (home may differ). CSRF/Origin
1929
- * for cookie mutations is a follow-up (#1140).
2507
+ * the human against the target project (home may differ). Cookie-authenticated
2508
+ * requests follow the scheme's CSRF rules (`nextgenSession`).
1930
2509
  * @summary Create grant
1931
2510
  */
1932
2511
  const createGrant = async (createGrantBody, params, options) => {
@@ -1971,8 +2550,8 @@ const getQueryGrantsUrl = (params) => {
1971
2550
  * the project Check may expand without those scopes.
1972
2551
  *
1973
2552
  * Accepts either a project secret (`oauth2`) or a user-bound Console
1974
- * session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
1975
- * is a follow-up (#1140).
2553
+ * session cookie (`nextgenSession`). Cookie-authenticated requests
2554
+ * follow the scheme's CSRF rules (`nextgenSession`).
1976
2555
  * @summary Query grants
1977
2556
  */
1978
2557
  const queryGrants = async (queryGrantsBody, params, options) => {
@@ -2023,8 +2602,8 @@ const getGetGrantUrl = (id, params) => {
2023
2602
  * Check may expand without those scopes.
2024
2603
  *
2025
2604
  * Accepts either a project secret (`oauth2`) or a user-bound Console
2026
- * session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
2027
- * is a follow-up (#1140).
2605
+ * session cookie (`nextgenSession`). Cookie-authenticated requests
2606
+ * follow the scheme's CSRF rules (`nextgenSession`).
2028
2607
  * @summary Get grant
2029
2608
  */
2030
2609
  const getGrant = async (id, params, options) => {
@@ -2048,8 +2627,8 @@ const getDeleteGrantUrl = (id, params) => {
2048
2627
  * revoked so the unique binding can be reused.
2049
2628
  *
2050
2629
  * Accepts either a project secret (`oauth2`) or a user-bound Console
2051
- * session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
2052
- * is a follow-up (#1140).
2630
+ * session cookie (`nextgenSession`). Cookie-authenticated requests
2631
+ * follow the scheme's CSRF rules (`nextgenSession`).
2053
2632
  * @summary Revoke grant
2054
2633
  */
2055
2634
  const deleteGrant = async (id, params, options) => {
@@ -2123,13 +2702,8 @@ const getGetVariablesUrl = (params) => {
2123
2702
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
2124
2703
  };
2125
2704
  /**
2126
- * Returns the variables entered at the owner this request addresses, keyed by
2127
- * name — one environment of the project with `environment_name`, the project
2128
- * level itself without it.
2129
- *
2130
- * Owners are separate, not a ladder: an environment does not inherit the
2131
- * project's variables and the project does not see its environments'. Reading
2132
- * everything a project holds therefore means reading each owner in turn.
2705
+ * Returns the project's variables, keyed by name, each with its value per
2706
+ * kind. With `kind`, only that kind's values are returned.
2133
2707
  *
2134
2708
  * Secret values are not returned. A secret appears as `{"secret": true}`,
2135
2709
  * which says a value is held without disclosing it.
@@ -2150,23 +2724,24 @@ const getUpdateVariablesUrl = (params) => {
2150
2724
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
2151
2725
  };
2152
2726
  /**
2153
- * Enters, replaces and removes variables at the owner this request
2154
- * addresses.
2727
+ * Enters, replaces and removes the project's variables for the requested
2728
+ * kind. Names not in the body are untouched. Existing deployments keep the
2729
+ * values they froze.
2155
2730
  *
2156
- * Every name in the body is applied at exactly that owner — the project, or
2157
- * the environment named by `environment_name` — and reaches no other. Names
2158
- * not in the body are untouched.
2731
+ * Without `kind`, a plain value is written for both kinds. A secret is
2732
+ * written for `primary` only and removes the name's `preview` value, so a
2733
+ * preview never keeps a plaintext copy; set a preview secret with
2734
+ * `kind=preview`. `null` removes the name from both.
2159
2735
  *
2160
2736
  * A bare scalar enters a non-secret value. `{"value": …, "secret": true}`
2161
2737
  * stores the value encrypted under the project's active `secret` key, after
2162
- * which it can be referenced but not read back. `null` removes the name from
2163
- * this owner (RFC 7386), which is how several variables are removed in one
2164
- * request; removing a name this owner does not hold is a no-op rather than an
2165
- * error.
2738
+ * which it can be referenced but not read back. `null` removes the name
2739
+ * (RFC 7386), which is how several variables are removed in one request;
2740
+ * removing a name the project does not hold is a no-op rather than an error.
2166
2741
  *
2167
2742
  * The body is applied whole or not at all, so a rejected request leaves the
2168
- * owner exactly as it was. Writing the same name and owner twice replaces the
2169
- * value rather than duplicating it, which makes a retry safe.
2743
+ * project's variables exactly as they were. Writing the same name twice
2744
+ * replaces the value rather than duplicating it, which makes a retry safe.
2170
2745
  * @summary Update variables
2171
2746
  */
2172
2747
  const updateVariables = async (updateVariablesBody, params, options) => {
@@ -2197,13 +2772,9 @@ const getGetVariableUrl = (variableName, params) => {
2197
2772
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
2198
2773
  };
2199
2774
  /**
2200
- * Reads one variable by name from the owner this request addresses — one
2201
- * environment of the project with `environment_name`, the project level
2202
- * itself without it.
2203
- *
2204
- * A name that owner has not entered answers `var.not_found`, even when
2205
- * another owner of the same project holds it: nothing is inherited. A secret
2206
- * is found but not disclosed: the response is `{"secret": true}`.
2775
+ * Reads one variable by name, with its value per kind. A name with no
2776
+ * value for the requested kind answers `var.not_found`. A secret reads
2777
+ * back as `{"secret": true}`.
2207
2778
  * @summary Get a variable
2208
2779
  */
2209
2780
  const getVariable = async (variableName, params, options) => {
@@ -2221,11 +2792,9 @@ const getDeleteVariableUrl = (variableName, params) => {
2221
2792
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
2222
2793
  };
2223
2794
  /**
2224
- * Removes the variable this owner entered under this name.
2225
- *
2226
- * A variable is deletable only by the owner that entered it. Deleting a name
2227
- * another owner of the same project holds answers `var.not_found` and leaves
2228
- * that owner's value standing.
2795
+ * Removes a variable for the requested kind, or for both kinds without
2796
+ * `kind`. A name with no value for that kind answers `var.not_found`.
2797
+ * Existing deployments keep the values they froze.
2229
2798
  * @summary Delete a variable
2230
2799
  */
2231
2800
  const deleteVariable = async (variableName, params, options) => {
@@ -2243,28 +2812,54 @@ const getCreateDeploymentUrl = (params) => {
2243
2812
  return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments?${stringifiedParams}` : `${getProxyPath()}/deployments`;
2244
2813
  };
2245
2814
  /**
2246
- * Makes a release live on an environment by recording a deployment. The two
2247
- * happen atomically: when the call returns, the environment runs the named
2248
- * release and the record exists; on any failure the environment keeps
2249
- * running what it ran and no record is written.
2250
- *
2251
- * Deploying, promoting and rolling back are all this call — `reason` says
2252
- * which. None of them assembles a release: the release must already exist,
2253
- * and rolling back means deploying a release the environment ran earlier,
2254
- * chosen from its deployment history.
2255
- *
2256
- * Idempotent on the running release: deploying the release the environment
2257
- * already runs changes nothing and answers `200` with the deployment that
2258
- * made it live, so a re-run of `zitadel deploy` on unchanged content is a
2259
- * no-op end to end — matching `POST /releases`, which resolves the same
2260
- * content to the same release first. Anything else writes a new record,
2261
- * including the same release returning after something else ran in between:
2262
- * the log is append-only, and each row is one act of making a release live.
2263
- *
2264
- * `expected_current_deployment_id` guards against racing another deploy:
2265
- * when present, the swap only happens if the environment's current
2266
- * deployment still is the one named, and a mismatch answers `409` with the
2267
- * actual `current_deployment_id` and `current_release_id` in the details.
2815
+ * Makes a release live on a set of targets by recording a deployment. The
2816
+ * two happen atomically: when the call returns, every target serves the
2817
+ * named release and the record exists; on any failure every target keeps
2818
+ * serving what it served and no record is written.
2819
+ *
2820
+ * The release is named by exactly one of `release_id` or `content_hash`
2821
+ * (both or neither answers `400` with `dep.invalid`), and must already
2822
+ * exist in the project: deploying never assembles a release. An
2823
+ * unknown release id or digest answers `404` with `rel.not_found`, and a
2824
+ * revoked release answers `409` with `rel.revoked`.
2825
+ *
2826
+ * `targets` lists `primary`, which expands to every primary origin of the
2827
+ * project, and exact origins. An origin that is neither a primary origin
2828
+ * of the project nor matches one of its preview patterns answers `403`
2829
+ * with `proj.origin_not_allowed`, and `primary` on a project with no
2830
+ * primary origin answers `400` with `dep.invalid`. The deployment records
2831
+ * the resolved origins, sorted, never the keyword.
2832
+ *
2833
+ * A deployment to preview URLs creates the preview for each of them, or
2834
+ * renews it when it exists, in the same transaction, with the expiry set
2835
+ * from `ttl`; each target in the response carries that expiry. It always
2836
+ * writes a new deployment, answering `201`, even when the URLs already
2837
+ * serve the release: that record is the renewal. Primary origins and
2838
+ * preview URLs cannot be mixed in one deployment: that answers `400` with
2839
+ * `dep.invalid`.
2840
+ *
2841
+ * A deployment freezes the variable values the project stores for its
2842
+ * kind: primary origins use the primary values, preview URLs the preview
2843
+ * values, with no fallback from one to the other. A release that
2844
+ * references a variable with no value for that kind answers `400` with
2845
+ * `dep.variables_missing`, naming the kind and every missing variable, and
2846
+ * nothing is written.
2847
+ *
2848
+ * A deployment to primary origins is idempotent on what is served: when
2849
+ * every resolved target already serves the release with the same frozen
2850
+ * variable values, nothing changes and the call answers `200` with the
2851
+ * newest deployment to those targets, so a re-run of `zitadel deploy` on
2852
+ * unchanged content is a no-op end to end. The same release with a
2853
+ * changed variable value is a new deployment.
2854
+ * Anything else writes a new record covering all of the resolved targets,
2855
+ * including the same release returning after something else was served in
2856
+ * between: the log is append-only, and each record is one act of making a
2857
+ * release live.
2858
+ *
2859
+ * `expected_deployment_id` guards against racing another deploy: when
2860
+ * present, the write only happens if the newest deployment to any of the
2861
+ * resolved targets still is the one named, and a mismatch answers `409`
2862
+ * with `dep.conflict`, carrying the actual newest deployment.
2268
2863
  * @summary Create a deployment
2269
2864
  */
2270
2865
  const createDeployment = async (createDeploymentBody, params, options) => {
@@ -2303,10 +2898,19 @@ const getListDeploymentsUrl = (params) => {
2303
2898
  /**
2304
2899
  * Lists deployments newest first: what ran where, and when.
2305
2900
  *
2306
- * With `environment_name`, the list is that environment's history and its
2307
- * first row is the environment's current deployment. Without it, the list
2308
- * interleaves every environment of the project — a project-wide audit view
2309
- * in which the first row is only the most recent deployment anywhere.
2901
+ * By default the list is the history: every deployment of the project, each
2902
+ * with every target it made the release live on. With `origin`, it is the
2903
+ * history of that origin alone, and its first row is the deployment the
2904
+ * origin serves.
2905
+ *
2906
+ * With `live=true`, the list is what is served now: the newest deployment
2907
+ * to each target, each carrying only the targets it still serves. A
2908
+ * preview URL is served only while its preview is live, and its
2909
+ * `expires_at` is the expiry its newest deployment set, which is the
2910
+ * preview's current one. A deployment every target of which has since
2911
+ * been replaced, or whose previews have all expired or been removed, does
2912
+ * not appear. Combined with `origin`, the live view is the one deployment
2913
+ * that origin serves, or empty.
2310
2914
  *
2311
2915
  * `expand: ["release"]` embeds the release each deployment made live, so a
2312
2916
  * history renders with each entry's content without resolving `release_id`
@@ -2343,6 +2947,83 @@ const getDeploymentById = async (deploymentId, params, options) => {
2343
2947
  method: "GET"
2344
2948
  });
2345
2949
  };
2950
+ const getRollbackDeploymentUrl = (deploymentId, params) => {
2951
+ const normalizedParams = new URLSearchParams();
2952
+ Object.entries(params || {}).forEach(([key, value]) => {
2953
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2954
+ });
2955
+ const stringifiedParams = normalizedParams.toString();
2956
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}/rollback?${stringifiedParams}` : `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}/rollback`;
2957
+ };
2958
+ /**
2959
+ * Re-deploys the deployment named in the path: a new deployment with the
2960
+ * same `release_id` and the same `targets`, `reason: rollback`, and
2961
+ * `rollback_to` in its metadata naming the deployment it re-applied. The
2962
+ * variable values that deployment resolved are re-applied with it, so the
2963
+ * targets serve exactly what they served then. The history is append-only,
2964
+ * so the deployments in between stay in it.
2965
+ *
2966
+ * Only a deployment to primary origins can be rolled back. One whose
2967
+ * targets were preview URLs answers `400` with `dep.invalid`; deploy to
2968
+ * the preview again instead. Every target must still be a primary origin
2969
+ * of the project, as `POST /deployments` requires of an exact origin:
2970
+ * when one is not, the request answers `403` with
2971
+ * `proj.origin_not_allowed` naming it, and nothing changes. There is no
2972
+ * narrowing to some of the targets: to roll back one origin, deploy the
2973
+ * earlier release to it with `POST /deployments`.
2974
+ *
2975
+ * When every target already serves the deployment's release, nothing
2976
+ * changes and the call answers `200` with the newest deployment to the
2977
+ * targets.
2978
+ *
2979
+ * The release must not be revoked: a revoked one answers `409` with
2980
+ * `rel.revoked`. An unknown deployment id, or one of another project,
2981
+ * answers `404` with `dep.not_found`.
2982
+ *
2983
+ * A rollback never answers `dep.variables_missing`: the release and the
2984
+ * frozen values it re-applies passed that check together when the named
2985
+ * deployment was made.
2986
+ * @summary Roll back to a deployment
2987
+ */
2988
+ const rollbackDeployment = async (deploymentId, params, rollbackDeploymentBody, options) => {
2989
+ const getHeaders = (h) => {
2990
+ if (!h) return {};
2991
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2992
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2993
+ const headers = {};
2994
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2995
+ return headers;
2996
+ };
2997
+ return customFetch(getRollbackDeploymentUrl(deploymentId, params), {
2998
+ ...options,
2999
+ method: "POST",
3000
+ headers: {
3001
+ "Content-Type": "application/json",
3002
+ ...getHeaders(options?.headers)
3003
+ },
3004
+ body: JSON.stringify(rollbackDeploymentBody)
3005
+ });
3006
+ };
3007
+ const getGetDeploymentVariablesUrl = (deploymentId, params) => {
3008
+ const normalizedParams = new URLSearchParams();
3009
+ Object.entries(params || {}).forEach(([key, value]) => {
3010
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
3011
+ });
3012
+ const stringifiedParams = normalizedParams.toString();
3013
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}/variables?${stringifiedParams}` : `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}/variables`;
3014
+ };
3015
+ /**
3016
+ * Returns the variable values the deployment froze when it was made. Later
3017
+ * changes to the project's variables do not affect them. A secret reads
3018
+ * back as `{"secret": true}`.
3019
+ * @summary Get a deployment's variables
3020
+ */
3021
+ const getDeploymentVariables = async (deploymentId, params, options) => {
3022
+ return customFetch(getGetDeploymentVariablesUrl(deploymentId, params), {
3023
+ ...options,
3024
+ method: "GET"
3025
+ });
3026
+ };
2346
3027
  //#endregion
2347
3028
  //#region ../api/dist/runtime/api-factory.mjs
2348
3029
  /**
@@ -2369,7 +3050,7 @@ const getDeploymentById = async (deploymentId, params, options) => {
2369
3050
  * generated orval function:
2370
3051
  *
2371
3052
  * const client = createZitadelClient({ baseUrl, token });
2372
- * await client.createProject({ preview_origins: [] });
3053
+ * await client.createProject({ origins: [] });
2373
3054
  * await client.createSchema(body, { project_id });
2374
3055
  */
2375
3056
  function createZitadelClient(opts) {
@@ -2381,12 +3062,16 @@ function createZitadelClient(opts) {
2381
3062
  return (...args) => {
2382
3063
  setProxyPath(baseUrl);
2383
3064
  setApiAuthToken(opts.token);
3065
+ setRequestPolicy({
3066
+ signal: opts.signal,
3067
+ timeoutMs: opts.timeoutMs
3068
+ });
2384
3069
  return value(...args);
2385
3070
  };
2386
3071
  } });
2387
3072
  }
2388
3073
  //#endregion
2389
- //#region ../config/dist/defaults-BnRHT7RQ.mjs
3074
+ //#region ../config/dist/defaults-B3SfaQPb.mjs
2390
3075
  var default_human_user_default = {
2391
3076
  title: "DefaultHumanUserSchema",
2392
3077
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -2413,7 +3098,7 @@ var default_login_default = {
2413
3098
  $schema: "../meta/flow-definition.json",
2414
3099
  name: "default-login",
2415
3100
  status: "active",
2416
- user_schema: "${USER_SCHEMA_URL}",
3101
+ user_schema: "human-user",
2417
3102
  purposes: {
2418
3103
  "login": "identifier",
2419
3104
  "register": "register"
@@ -2523,7 +3208,7 @@ var login_default = {
2523
3208
  $schema: "../meta/flow-definition.json",
2524
3209
  name: "default-login",
2525
3210
  status: "active",
2526
- user_schema: "${USER_SCHEMA_URL}",
3211
+ user_schema: "human-user",
2527
3212
  purposes: {
2528
3213
  "login": "passkey-first",
2529
3214
  "register": "register"
@@ -2668,8 +3353,8 @@ var login_default = {
2668
3353
  }
2669
3354
  ]
2670
3355
  };
2671
- const DEFAULT_BUILTIN_SCHEMA_BASE = "https://nextgen.com/api/schemas";
2672
- const DEFAULT_FLOW_SCHEMA_URI = "https://nextgen.com/flow-definition.json";
3356
+ const DEFAULT_BUILTIN_SCHEMA_BASE = "https://zitadel.com/schemas/v1";
3357
+ const DEFAULT_FLOW_SCHEMA_URI = `${DEFAULT_BUILTIN_SCHEMA_BASE}/flow-definition.json`;
2673
3358
  /**
2674
3359
  * Named schema+flow bundles `zitadel setup` can scaffold (#448: the prompt
2675
3360
  * fires before any `.zitadel/` file is written; each preset maps to a
@@ -2806,18 +3491,15 @@ function defaultHumanUserSchemaUrl(builtinSchemaBase = DEFAULT_BUILTIN_SCHEMA_BA
2806
3491
  return `${trimTrailingSlash(builtinSchemaBase)}/default-human-user.json`;
2807
3492
  }
2808
3493
  function getDefaultHumanUserSchema(options = {}) {
2809
- const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://nextgen.com/api/schemas");
3494
+ const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://zitadel.com/schemas/v1");
2810
3495
  return applyUseCaseToSchema(renderTemplate(presetTemplates(options.preset ?? "password-first").schema, {
2811
3496
  SERVER_URL: builtinSchemaBase,
2812
3497
  USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase)
2813
3498
  }), options.useCase ?? "minimal");
2814
3499
  }
2815
3500
  function getDefaultLoginFlow(options = {}) {
2816
- const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://nextgen.com/api/schemas");
2817
- return applyUseCaseToFlow(renderTemplate(presetTemplates(options.preset ?? "password-first").flow, {
2818
- SERVER_URL: builtinSchemaBase,
2819
- USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase)
2820
- }), options.useCase ?? "minimal");
3501
+ const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://zitadel.com/schemas/v1");
3502
+ return applyUseCaseToFlow(renderTemplate(presetTemplates(options.preset ?? "password-first").flow, { SERVER_URL: builtinSchemaBase }), options.useCase ?? "minimal");
2821
3503
  }
2822
3504
  function renderTemplate(value, replacements) {
2823
3505
  if (Array.isArray(value)) return value.map((item) => renderTemplate(item, replacements));
@@ -2845,7 +3527,10 @@ async function bootstrapProject(options) {
2845
3527
  const { baseUrl } = options;
2846
3528
  const project = await createZitadelClient({ baseUrl }).createProject({
2847
3529
  name: options.projectName ?? DEFAULT_PROJECT_NAME,
2848
- preview_origins: options.appOrigins ?? [],
3530
+ origins: (options.appOrigins ?? []).map((pattern) => ({
3531
+ pattern,
3532
+ kind: "preview"
3533
+ })),
2849
3534
  seed_defaults: false
2850
3535
  });
2851
3536
  const projectId = requireString(project.id, "project id");
@@ -2861,7 +3546,6 @@ async function bootstrapProject(options) {
2861
3546
  });
2862
3547
  const schemaId = requireString((await client.createSchema(schemaBody, { project_id: projectId })).id, "schema id");
2863
3548
  const flowBody = getDefaultLoginFlow({
2864
- userSchemaUrl: schemaId,
2865
3549
  preset: options.preset,
2866
3550
  useCase: options.useCase
2867
3551
  });
@@ -2885,9 +3569,9 @@ function requireString(value, label) {
2885
3569
  //#region src/cli.ts
2886
3570
  const DEFAULT_TIMEOUT_MS = 12e4;
2887
3571
  function resolveCliBin() {
2888
- const require = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
2889
- const pkgPath = require.resolve("@zitadel/cli/package.json");
2890
- const rel = require(pkgPath).bin?.zitadel;
3572
+ const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
3573
+ const pkgPath = require$1.resolve("@zitadel/cli/package.json");
3574
+ const rel = require$1(pkgPath).bin?.zitadel;
2891
3575
  if (!rel) throw new Error("@zitadel/cli does not declare a `zitadel` bin entry");
2892
3576
  return (0, node_path.join)((0, node_path.dirname)(pkgPath), rel);
2893
3577
  }
@@ -3097,7 +3781,9 @@ function failureDetail(result) {
3097
3781
  /**
3098
3782
  * A unique unused email + password. Nothing is created on the instance —
3099
3783
  * this is the input for registration-flow specs, which must prove the flow
3100
- * creates the user.
3784
+ * creates the user. It needs no instance either, so both entry points export
3785
+ * it for specs that run without `withZitadel()`; `seed.identity()` and
3786
+ * `zitadel.identity()` call this function.
3101
3787
  */
3102
3788
  function identity() {
3103
3789
  return {
@@ -3108,8 +3794,7 @@ function identity() {
3108
3794
  /**
3109
3795
  * Create a user that can immediately complete the password login flow:
3110
3796
  * `POST /users` (the body carries `schema: <schema id>` and the schema-defined
3111
- * content under `attributes`) followed by `PUT /users/{id}/password` with
3112
- * `is_change_required: false`.
3797
+ * content under `attributes`) followed by `PUT /users/{id}/password`.
3113
3798
  *
3114
3799
  * Defaults mint a unique email per call (email is x-unique per project), which
3115
3800
  * is what makes per-test seeding parallel-safe on a shared instance.
@@ -3125,10 +3810,7 @@ async function seedUser(client, context, input = {}) {
3125
3810
  email
3126
3811
  }
3127
3812
  }, { project_id: context.projectId })).id, "user id");
3128
- await client.setUserPassword(id, {
3129
- password,
3130
- is_change_required: false
3131
- });
3813
+ await client.setUserPassword(id, { password });
3132
3814
  return {
3133
3815
  id,
3134
3816
  email,
@@ -3153,8 +3835,30 @@ async function seedUsers(client, context, count, template = {}) {
3153
3835
  }
3154
3836
  //#endregion
3155
3837
  //#region src/session.ts
3156
- /** Mirrors the server's session cookie (internal/api/session.go). */
3838
+ /**
3839
+ * Mirrors the server's session cookie (internal/api/session.go): the name a
3840
+ * direct call to the server sends, and the one an app keeps behind a proxy that
3841
+ * passes the server's cookie through, such as an SPA's in production.
3842
+ */
3157
3843
  const SESSION_COOKIE_NAME = "__nextgen_session";
3844
+ /**
3845
+ * The cookie an app keeps its session in on its own origin behind a server SDK
3846
+ * (Next.js, Nuxt, SvelteKit, SolidStart, TanStack Start, Qwik Router) or the dev
3847
+ * proxy `zitadel setup` writes for an SPA: `__nextgen_session_<projectId>`. The
3848
+ * proxy renames the server's cookie, so the apps and the Console on one host
3849
+ * keep a session each (ADR 073).
3850
+ *
3851
+ * Mirrors `sessionCookieName` in `@zitadel/sdk-core`, including the
3852
+ * percent-encoding of every byte outside `[A-Za-z0-9_-]`.
3853
+ */
3854
+ function sessionCookieName(projectId) {
3855
+ let name = `${SESSION_COOKIE_NAME}_`;
3856
+ for (const byte of new TextEncoder().encode(projectId)) {
3857
+ const char = String.fromCharCode(byte);
3858
+ name += /[A-Za-z0-9_-]/.test(char) ? char : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
3859
+ }
3860
+ return name;
3861
+ }
3158
3862
  const MAX_FLOW_STEPS = 6;
3159
3863
  /**
3160
3864
  * Drive the real login flow headlessly for a seeded password user and
@@ -3291,7 +3995,8 @@ function connectZitadel(handle) {
3291
3995
  identity,
3292
3996
  seedSession: async (input = {}) => {
3293
3997
  const { user: existing, flowDefinitionName, origin, ...userInput } = input;
3294
- return mintSession(api, handle, context, existing ?? await seedUser(api, context, userInput), {
3998
+ const user = existing ?? await seedUser(api, context, userInput);
3999
+ return mintSession(api, handle, context, user, {
3295
4000
  flowDefinitionName,
3296
4001
  origin: origin ?? handle.appOrigin
3297
4002
  });
@@ -3361,6 +4066,18 @@ Object.defineProperty(exports, "connectZitadel", {
3361
4066
  return connectZitadel;
3362
4067
  }
3363
4068
  });
4069
+ Object.defineProperty(exports, "identity", {
4070
+ enumerable: true,
4071
+ get: function() {
4072
+ return identity;
4073
+ }
4074
+ });
4075
+ Object.defineProperty(exports, "sessionCookieName", {
4076
+ enumerable: true,
4077
+ get: function() {
4078
+ return sessionCookieName;
4079
+ }
4080
+ });
3364
4081
  Object.defineProperty(exports, "startLocalZitadel", {
3365
4082
  enumerable: true,
3366
4083
  get: function() {
@@ -3368,4 +4085,4 @@ Object.defineProperty(exports, "startLocalZitadel", {
3368
4085
  }
3369
4086
  });
3370
4087
 
3371
- //# sourceMappingURL=src-3iEZwMxn.cjs.map
4088
+ //# sourceMappingURL=src-BbHs0YmP.cjs.map