@zitadel/testing 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,12 +99,19 @@ var ApiError = class extends Error {
99
99
  status;
100
100
  url;
101
101
  body;
102
- constructor(status, url, body, message) {
102
+ /**
103
+ * The server's ID for the request, from its `X-Request-Id` header: the
104
+ * reference that finds the request in the server's logs, to show beside the
105
+ * error. `undefined` when the response carried none, as from a proxy.
106
+ */
107
+ requestId;
108
+ constructor(status, url, body, message, requestId) {
103
109
  super(message);
104
110
  this.name = "ApiError";
105
111
  this.status = status;
106
112
  this.url = url;
107
113
  this.body = body;
114
+ this.requestId = requestId;
108
115
  }
109
116
  };
110
117
  /**
@@ -181,7 +188,7 @@ async function customFetch(url, options) {
181
188
  }
182
189
  if (!res.ok) {
183
190
  const message = `${options.method ?? "GET"} ${url} returned ${res.status}`;
184
- throw new ApiError(res.status, url, parsed, message);
191
+ throw new ApiError(res.status, url, parsed, message, res.headers.get("x-request-id") || void 0);
185
192
  }
186
193
  return parsed;
187
194
  }
@@ -328,6 +335,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
328
335
  deleteTeam: () => deleteTeam,
329
336
  deleteUserByID: () => deleteUserByID,
330
337
  deleteVariable: () => deleteVariable,
338
+ evaluatePolicy: () => evaluatePolicy,
331
339
  exchangeHandoff: () => exchangeHandoff,
332
340
  finishUserPasskeyRegistration: () => finishUserPasskeyRegistration,
333
341
  getAddOriginUrl: () => getAddOriginUrl,
@@ -358,6 +366,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
358
366
  getDeleteVariableUrl: () => getDeleteVariableUrl,
359
367
  getDeploymentById: () => getDeploymentById,
360
368
  getDeploymentVariables: () => getDeploymentVariables,
369
+ getEvaluatePolicyUrl: () => getEvaluatePolicyUrl,
361
370
  getEvent: () => getEvent,
362
371
  getExchangeHandoffUrl: () => getExchangeHandoffUrl,
363
372
  getFinishUserPasskeyRegistrationUrl: () => getFinishUserPasskeyRegistrationUrl,
@@ -373,7 +382,6 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
373
382
  getGetFlowDefinitionUrl: () => getGetFlowDefinitionUrl,
374
383
  getGetFlowStepUrl: () => getGetFlowStepUrl,
375
384
  getGetGrantUrl: () => getGetGrantUrl,
376
- getGetHealthUrl: () => getGetHealthUrl,
377
385
  getGetIdpByIdUrl: () => getGetIdpByIdUrl,
378
386
  getGetIdpRevisionByIdUrl: () => getGetIdpRevisionByIdUrl,
379
387
  getGetLiveUrl: () => getGetLiveUrl,
@@ -382,6 +390,8 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
382
390
  getGetMySessionUrl: () => getGetMySessionUrl,
383
391
  getGetMyUserSchemaUrl: () => getGetMyUserSchemaUrl,
384
392
  getGetMyUserUrl: () => getGetMyUserUrl,
393
+ getGetPolicyRevisionUrl: () => getGetPolicyRevisionUrl,
394
+ getGetPolicyUrl: () => getGetPolicyUrl,
385
395
  getGetProjectUrl: () => getGetProjectUrl,
386
396
  getGetReadyUrl: () => getGetReadyUrl,
387
397
  getGetReleaseByIdUrl: () => getGetReleaseByIdUrl,
@@ -393,7 +403,6 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
393
403
  getGetVariableUrl: () => getGetVariableUrl,
394
404
  getGetVariablesUrl: () => getGetVariablesUrl,
395
405
  getGrant: () => getGrant,
396
- getHealth: () => getHealth,
397
406
  getIdpById: () => getIdpById,
398
407
  getIdpRevisionById: () => getIdpRevisionById,
399
408
  getInitClaimUrl: () => getInitClaimUrl,
@@ -407,7 +416,10 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
407
416
  getListMyPasskeysUrl: () => getListMyPasskeysUrl,
408
417
  getListMyProjectsUrl: () => getListMyProjectsUrl,
409
418
  getListMyTeamsUrl: () => getListMyTeamsUrl,
419
+ getListPoliciesUrl: () => getListPoliciesUrl,
420
+ getListPolicyRevisionsUrl: () => getListPolicyRevisionsUrl,
410
421
  getListPreviewsUrl: () => getListPreviewsUrl,
422
+ getListProjectAdminsUrl: () => getListProjectAdminsUrl,
411
423
  getListReleasesUrl: () => getListReleasesUrl,
412
424
  getListSchemasUrl: () => getListSchemasUrl,
413
425
  getListUserIdentityLinksUrl: () => getListUserIdentityLinksUrl,
@@ -422,7 +434,10 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
422
434
  getPatchMyUserUrl: () => getPatchMyUserUrl,
423
435
  getPatchProjectUrl: () => getPatchProjectUrl,
424
436
  getPatchUserByIDUrl: () => getPatchUserByIDUrl,
437
+ getPolicy: () => getPolicy,
438
+ getPolicyRevision: () => getPolicyRevision,
425
439
  getProject: () => getProject,
440
+ getPublishPolicyUrl: () => getPublishPolicyUrl,
426
441
  getQueryGrantsUrl: () => getQueryGrantsUrl,
427
442
  getQueryIdpsUrl: () => getQueryIdpsUrl,
428
443
  getQueryProjectsUrl: () => getQueryProjectsUrl,
@@ -460,7 +475,10 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
460
475
  listMyPasskeys: () => listMyPasskeys,
461
476
  listMyProjects: () => listMyProjects,
462
477
  listMyTeams: () => listMyTeams,
478
+ listPolicies: () => listPolicies,
479
+ listPolicyRevisions: () => listPolicyRevisions,
463
480
  listPreviews: () => listPreviews,
481
+ listProjectAdmins: () => listProjectAdmins,
464
482
  listReleases: () => listReleases,
465
483
  listSchemas: () => listSchemas,
466
484
  listUserIdentityLinks: () => listUserIdentityLinks,
@@ -469,6 +487,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
469
487
  patchMyUser: () => patchMyUser,
470
488
  patchProject: () => patchProject,
471
489
  patchUserByID: () => patchUserByID,
490
+ publishPolicy: () => publishPolicy,
472
491
  queryGrants: () => queryGrants,
473
492
  queryIdps: () => queryIdps,
474
493
  queryProjects: () => queryProjects,
@@ -487,24 +506,15 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
487
506
  updateVariables: () => updateVariables,
488
507
  verifyChallengeProof: () => verifyChallengeProof
489
508
  });
490
- const getGetHealthUrl = () => {
491
- return `${getProxyPath()}/healthz`;
492
- };
493
- /**
494
- * Check whether the server is healthy
495
- * @summary Check server health
496
- */
497
- const getHealth = async (options) => {
498
- return customFetch(getGetHealthUrl(), {
499
- ...options,
500
- method: "GET"
501
- });
502
- };
503
509
  const getGetLiveUrl = () => {
504
510
  return `${getProxyPath()}/livez`;
505
511
  };
506
512
  /**
507
- * Check whether the server is started
513
+ * Answers `ok` while the server process serves HTTP, and checks nothing behind it.
514
+ *
515
+ * Point a liveness probe here. It never checks the database, so an outage
516
+ * of the database does not restart every instance; `GET /readyz` takes an
517
+ * instance out of rotation instead.
508
518
  * @summary Check server liveness
509
519
  */
510
520
  const getLive = async (options) => {
@@ -517,7 +527,11 @@ const getGetReadyUrl = () => {
517
527
  return `${getProxyPath()}/readyz`;
518
528
  };
519
529
  /**
520
- * Check whether the server is ready to accept requests
530
+ * Answers whether the server can serve requests, which takes its database answering within a second.
531
+ *
532
+ * Point a readiness probe here, so that a server whose database does not
533
+ * answer gets no requests until it does. The check is one round trip to the
534
+ * database.
521
535
  * @summary Check server readiness
522
536
  */
523
537
  const getReady = async (options) => {
@@ -653,9 +667,11 @@ const getDeleteUserByIDUrl = (userId) => {
653
667
  return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
654
668
  };
655
669
  /**
656
- * Deletes a user and removes them from every team they belong to.
670
+ * Deletes a user, removes them from every team they belong to, and revokes
671
+ * every grant they hold, on any project.
657
672
  *
658
- * The user is removed, not deactivated, and the deletion emits `user.deleted`.
673
+ * The user is removed, not deactivated, and the deletion emits `user.deleted`,
674
+ * plus `authz.revoked` for each grant on that grant's project.
659
675
  * With a project secret the request is idempotent: deleting a user that exists
660
676
  * in no project succeeds without changing anything.
661
677
  * @summary Delete user by ID
@@ -974,14 +990,20 @@ const getListMyProjectsUrl = (params) => {
974
990
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me/projects?${stringifiedParams}` : `${getProxyPath()}/users/me/projects`;
975
991
  };
976
992
  /**
977
- * The projects the signed-in user holds an active grant on, either directly or
978
- * through a team they are a member of. Ordered by project id and paged with an
979
- * opaque cursor.
993
+ * The projects the signed-in user can act on: those they hold an active grant
994
+ * on, either directly or through a team they are a member of. For a platform
995
+ * operator (ADR 075) that is every project of the deployment. Ordered by
996
+ * project id and paged with an opaque cursor.
980
997
  *
981
998
  * This is not the same question as `queryProjects`, which answers with the one
982
999
  * project the calling credential is bound to. Here the session is the caller
983
1000
  * and the grants are the answer, so the list spans projects.
984
1001
  *
1002
+ * With `name_contains`, only the projects whose name contains that text are
1003
+ * listed. The search runs on the server together with the grants, so it
1004
+ * reaches every project the user can act on, however many there are, and
1005
+ * pages like the full list.
1006
+ *
985
1007
  * With `project_id`, the projects are listed only when the session belongs to
986
1008
  * that project. It names the project the session was signed in to, not one to
987
1009
  * list.
@@ -1054,7 +1076,10 @@ const getCreateFlowUrl = () => {
1054
1076
  * pattern with no live preview answers `403` with `proj.preview_not_live`;
1055
1077
  * nothing deployed to the target answers `409` with `rel.not_deployed`; a
1056
1078
  * revoked release answers `409` with `rel.revoked`. A request with no
1057
- * `Origin` passes the gate and still needs a deployment target.
1079
+ * `Origin` passes the gate and still needs a deployment target. A loopback
1080
+ * origin passes it too, and so does the server's own origin, from which its
1081
+ * console previews a project's login; a step submitted from the server's
1082
+ * own origin is still refused unless the project lists it.
1058
1083
  *
1059
1084
  * The response contains an `id` field — the flow handle. Use it as the path
1060
1085
  * parameter for all subsequent `/flow/{id}/submit` calls.
@@ -1192,10 +1217,10 @@ const getCreateAuthAttemptUrl = () => {
1192
1217
  * also include session_id and that session's session_token to add factors to an existing session.
1193
1218
  *
1194
1219
  * The project comes from the project secret. A body `project_id` that disagrees
1195
- * answers `403` with `proj.mismatch`. The attempt resolves a deployment the
1196
- * same way as other runtime operations and seals it; with no browser `Origin`
1197
- * and nothing deployed to the resolved target the response is `409` with
1198
- * `rel.not_deployed`. A revoked release answers `409` with `rel.revoked`.
1220
+ * answers `403` with `proj.mismatch`. Sealed `deployment_id` / `release_id` are
1221
+ * filled only when create runs with a runtime resolution already on the
1222
+ * context (the flow create path); this HTTP entry point does not resolve
1223
+ * Origin or refuse a revoked release itself.
1199
1224
  * @summary Create a new authentication attempt
1200
1225
  */
1201
1226
  const createAuthAttempt = async (createAuthAttemptBody, options) => {
@@ -1228,9 +1253,6 @@ const getGetAuthAttemptUrl = (attemptId) => {
1228
1253
  *
1229
1254
  * Use this for polling during long-running factor verifications (e.g., waiting for
1230
1255
  * a federated IdP callback or a device flow).
1231
- *
1232
- * Reuses the deployment sealed when the attempt was created. If that release
1233
- * was revoked since, the response is `409` with `rel.revoked`.
1234
1256
  * @summary Get authentication attempt state
1235
1257
  */
1236
1258
  const getAuthAttempt = async (attemptId, options) => {
@@ -1249,9 +1271,6 @@ const getIssueChallengeUrl = (attemptId) => {
1249
1271
  * (password, passkey, TOTP, OTP via SMS, etc.). The server responds with challenge details
1250
1272
  * including method, metadata, and any UI hints. The client then verifies the proof
1251
1273
  * by calling POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify.
1252
- *
1253
- * Reuses the deployment sealed when the attempt was created. If that release
1254
- * was revoked since, the response is `409` with `rel.revoked`.
1255
1274
  * @summary Issue a factor challenge
1256
1275
  */
1257
1276
  const issueChallenge = async (attemptId, issueChallengeBody, options) => {
@@ -1287,9 +1306,6 @@ const getVerifyChallengeProofUrl = (attemptId, challengeId) => {
1287
1306
  *
1288
1307
  * On successful verification, the factor is written to the auth attempt.
1289
1308
  * The attempt moves to the next pending challenge or completes if all required factors are verified.
1290
- *
1291
- * Reuses the deployment sealed when the attempt was created. If that release
1292
- * was revoked since, the response is `409` with `rel.revoked`.
1293
1309
  * @summary Verify a factor proof
1294
1310
  */
1295
1311
  const verifyChallengeProof = async (attemptId, challengeId, verifyChallengeProofBody, options) => {
@@ -1326,8 +1342,7 @@ const getCreateHandoffUrl = (attemptId) => {
1326
1342
  * - Audience-bound (requires matching project key for exchange)
1327
1343
  * - Idempotency-safe within a 5-minute window (see conventions)
1328
1344
  *
1329
- * Reuses the deployment sealed when the attempt was created. If that release
1330
- * was revoked since, the response is `409` with `rel.revoked`.
1345
+ * Revoke refusal for a sealed release happens at handoff exchange, not here.
1331
1346
  * @summary Complete authentication and create handoff token
1332
1347
  */
1333
1348
  const createHandoff = async (attemptId, options) => {
@@ -1437,6 +1452,51 @@ const patchProject = async (projectId, patchProjectBody, options) => {
1437
1452
  body: JSON.stringify(patchProjectBody)
1438
1453
  });
1439
1454
  };
1455
+ const getListProjectAdminsUrl = (projectId, params) => {
1456
+ const normalizedParams = new URLSearchParams();
1457
+ Object.entries(params || {}).forEach(([key, value]) => {
1458
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1459
+ });
1460
+ const stringifiedParams = normalizedParams.toString();
1461
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/admins?${stringifiedParams}` : `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/admins`;
1462
+ };
1463
+ /**
1464
+ * Lists the people who can administer the project, and how each of them
1465
+ * gets that access. A person appears once, with one entry in `sources` per
1466
+ * way they hold it:
1467
+ *
1468
+ * - `owning_team`: an active member of the team that owns the project
1469
+ * (ADR 054 §2). Removing a grant does not remove this access; it ends
1470
+ * only when the person leaves the team or the project changes owner.
1471
+ * - `grant`: an unexpired `admin` grant on the project, either to the
1472
+ * person (`grant_id` only) or to a team they are an active member of
1473
+ * (`grant_id` and `team`). Revoking that grant removes this source.
1474
+ *
1475
+ * The list follows the authorization check: team membership is read from
1476
+ * the same membership projection the check expands, so a person who left a
1477
+ * team, or whose team or user was deactivated, is not listed through it.
1478
+ * Grants that expired or carry a lower role are left out. A person whose
1479
+ * only access is a `viewer` or `editor` grant is not an admin and is not
1480
+ * listed. Like the check, the list does not look at a person's user status
1481
+ * beyond that, so a direct grant to a suspended person is listed.
1482
+ *
1483
+ * A person whose access comes only through teams the caller is not a
1484
+ * member of is left out, and a team the caller is not in is named by
1485
+ * `team_id` only. The grant to such a team still shows in the project's
1486
+ * grants.
1487
+ *
1488
+ * Ordered by `user_id` and paginated with `page_token`.
1489
+ *
1490
+ * Accepts either a project secret (`oauth2`) or a user-bound Console
1491
+ * session cookie (`nextgenSession`) that can read the project.
1492
+ * @summary List project admins
1493
+ */
1494
+ const listProjectAdmins = async (projectId, params, options) => {
1495
+ return customFetch(getListProjectAdminsUrl(projectId, params), {
1496
+ ...options,
1497
+ method: "GET"
1498
+ });
1499
+ };
1440
1500
  const getInitClaimUrl = (projectId) => {
1441
1501
  return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/init`;
1442
1502
  };
@@ -1936,6 +1996,12 @@ const createSchema = async (createSchemaBody, params, options) => {
1936
1996
  const getListSchemasUrl = (params) => {
1937
1997
  const normalizedParams = new URLSearchParams();
1938
1998
  Object.entries(params || {}).forEach(([key, value]) => {
1999
+ if (Array.isArray(value) && ["expand"].includes(key)) {
2000
+ value.forEach((v) => {
2001
+ normalizedParams.append(key, v === null ? "null" : String(v));
2002
+ });
2003
+ return;
2004
+ }
1939
2005
  if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1940
2006
  });
1941
2007
  const stringifiedParams = normalizedParams.toString();
@@ -2412,6 +2478,192 @@ const getIdpRevisionById = async (revisionId, params, options) => {
2412
2478
  method: "GET"
2413
2479
  });
2414
2480
  };
2481
+ const getListPoliciesUrl = (params) => {
2482
+ const normalizedParams = new URLSearchParams();
2483
+ Object.entries(params || {}).forEach(([key, value]) => {
2484
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2485
+ });
2486
+ const stringifiedParams = normalizedParams.toString();
2487
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies?${stringifiedParams}` : `${getProxyPath()}/policies`;
2488
+ };
2489
+ /**
2490
+ * Lists the project's policies, one per operation, each as its newest
2491
+ * revision, ordered by `created_at` (first publish) and then `id`. Filter
2492
+ * by `operation` to read the policy of one operation; a project that never
2493
+ * published one gets an empty list.
2494
+ *
2495
+ * The lookup is scoped to the project in `project_id`.
2496
+ * @summary List policies
2497
+ */
2498
+ const listPolicies = async (params, options) => {
2499
+ return customFetch(getListPoliciesUrl(params), {
2500
+ ...options,
2501
+ method: "GET"
2502
+ });
2503
+ };
2504
+ const getPublishPolicyUrl = (params) => {
2505
+ const normalizedParams = new URLSearchParams();
2506
+ Object.entries(params || {}).forEach(([key, value]) => {
2507
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2508
+ });
2509
+ const stringifiedParams = normalizedParams.toString();
2510
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies?${stringifiedParams}` : `${getProxyPath()}/policies`;
2511
+ };
2512
+ /**
2513
+ * Publishes the project's policy for an operation as a new immutable
2514
+ * revision, creating the policy on its first publish. The newest revision
2515
+ * applies to the next time the operation runs; nothing already stored is
2516
+ * re-evaluated, so a stricter password policy applies the next time a
2517
+ * password is set.
2518
+ *
2519
+ * The request is typed by `operation`: an unknown operation or setting, or
2520
+ * a value of the wrong type or outside its bounds, answers `req.invalid`
2521
+ * like any malformed request. The operation's template then checks the
2522
+ * config again, together with the rules that relate settings to each other
2523
+ * (a `min_length` above `max_length`), and answers `pol.invalid`. Its
2524
+ * `details.details.violations` lists everything that failed, settings
2525
+ * first, then rules: `{"setting": "min_length"}` for one setting, or
2526
+ * `{"config_rule": "min_length_not_above_max_length", "settings":
2527
+ * ["min_length", "max_length"]}` for a rule across settings, with the
2528
+ * settings it reads. A setting left out is off, and `{}` switches every
2529
+ * rule off; there are no defaults.
2530
+ * @summary Publish a policy
2531
+ */
2532
+ const publishPolicy = async (publishPolicyBody, params, options) => {
2533
+ const getHeaders = (h) => {
2534
+ if (!h) return {};
2535
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2536
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2537
+ const headers = {};
2538
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2539
+ return headers;
2540
+ };
2541
+ return customFetch(getPublishPolicyUrl(params), {
2542
+ ...options,
2543
+ method: "POST",
2544
+ headers: {
2545
+ "Content-Type": "application/json",
2546
+ ...getHeaders(options?.headers)
2547
+ },
2548
+ body: JSON.stringify(publishPolicyBody)
2549
+ });
2550
+ };
2551
+ const getEvaluatePolicyUrl = (params) => {
2552
+ const normalizedParams = new URLSearchParams();
2553
+ Object.entries(params || {}).forEach(([key, value]) => {
2554
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2555
+ });
2556
+ const stringifiedParams = normalizedParams.toString();
2557
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies/evaluate?${stringifiedParams}` : `${getProxyPath()}/policies/evaluate`;
2558
+ };
2559
+ /**
2560
+ * Evaluates a policy config against one request, without side effects, and
2561
+ * answers the decision the operation would reach. Nothing is read from or
2562
+ * written to the project: the config is the one in the body, checked
2563
+ * exactly as a publish checks it, so an invalid config answers `pol.invalid`
2564
+ * with the same violations.
2565
+ *
2566
+ * `input` is what the operation's request carries, in the operation's own
2567
+ * terms (a password, not its length): the server derives what the policy
2568
+ * checks with the code the live operation runs, guards included. `facts`
2569
+ * states what the operation would look up at runtime, such as whether the
2570
+ * candidate matches one of the user's kept passwords.
2571
+ *
2572
+ * The decision and the names of the failed rules hold wherever the
2573
+ * operation runs. `code` and `violations` are what an API call answers; a
2574
+ * login flow shows the same rules as field errors on the password field
2575
+ * (`error.x-auth-methods#password_<rule>` in `step.error`).
2576
+ *
2577
+ * Which policy a project or release applies is not decided here: read it
2578
+ * and pass its config.
2579
+ *
2580
+ * The caller needs read access to the project in `project_id`.
2581
+ * @summary Evaluate a policy
2582
+ */
2583
+ const evaluatePolicy = async (evaluatePolicyBody, params, options) => {
2584
+ const getHeaders = (h) => {
2585
+ if (!h) return {};
2586
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2587
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2588
+ const headers = {};
2589
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2590
+ return headers;
2591
+ };
2592
+ return customFetch(getEvaluatePolicyUrl(params), {
2593
+ ...options,
2594
+ method: "POST",
2595
+ headers: {
2596
+ "Content-Type": "application/json",
2597
+ ...getHeaders(options?.headers)
2598
+ },
2599
+ body: JSON.stringify(evaluatePolicyBody)
2600
+ });
2601
+ };
2602
+ const getGetPolicyUrl = (policyId, params) => {
2603
+ const normalizedParams = new URLSearchParams();
2604
+ Object.entries(params || {}).forEach(([key, value]) => {
2605
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2606
+ });
2607
+ const stringifiedParams = normalizedParams.toString();
2608
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies/${encodeURIComponent(String(policyId))}?${stringifiedParams}` : `${getProxyPath()}/policies/${encodeURIComponent(String(policyId))}`;
2609
+ };
2610
+ /**
2611
+ * Reads a policy as its newest revision, the one that applies the next time
2612
+ * its operation runs.
2613
+ *
2614
+ * The lookup is scoped to the project in `project_id`: a policy of another
2615
+ * project answers not found exactly as an unknown id does.
2616
+ * @summary Get a policy
2617
+ */
2618
+ const getPolicy = async (policyId, params, options) => {
2619
+ return customFetch(getGetPolicyUrl(policyId, params), {
2620
+ ...options,
2621
+ method: "GET"
2622
+ });
2623
+ };
2624
+ const getListPolicyRevisionsUrl = (policyId, params) => {
2625
+ const normalizedParams = new URLSearchParams();
2626
+ Object.entries(params || {}).forEach(([key, value]) => {
2627
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2628
+ });
2629
+ const stringifiedParams = normalizedParams.toString();
2630
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies/${encodeURIComponent(String(policyId))}/revisions?${stringifiedParams}` : `${getProxyPath()}/policies/${encodeURIComponent(String(policyId))}/revisions`;
2631
+ };
2632
+ /**
2633
+ * Returns every revision of one policy, newest first, paginated with a
2634
+ * cursor. The order is fixed, so there is no `sorting`.
2635
+ *
2636
+ * The lookup is scoped to the project in `project_id`: a policy of another
2637
+ * project answers not found exactly as an unknown id does.
2638
+ * @summary List the revisions of a policy
2639
+ */
2640
+ const listPolicyRevisions = async (policyId, params, options) => {
2641
+ return customFetch(getListPolicyRevisionsUrl(policyId, params), {
2642
+ ...options,
2643
+ method: "GET"
2644
+ });
2645
+ };
2646
+ const getGetPolicyRevisionUrl = (revisionId, params) => {
2647
+ const normalizedParams = new URLSearchParams();
2648
+ Object.entries(params || {}).forEach(([key, value]) => {
2649
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2650
+ });
2651
+ const stringifiedParams = normalizedParams.toString();
2652
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/policies/revisions/${encodeURIComponent(String(revisionId))}?${stringifiedParams}` : `${getProxyPath()}/policies/revisions/${encodeURIComponent(String(revisionId))}`;
2653
+ };
2654
+ /**
2655
+ * Reads one revision of a policy, newest or not.
2656
+ *
2657
+ * The lookup is scoped to the project in `project_id`: a revision of another
2658
+ * project answers not found exactly as an unknown id does.
2659
+ * @summary Get a policy revision
2660
+ */
2661
+ const getPolicyRevision = async (revisionId, params, options) => {
2662
+ return customFetch(getGetPolicyRevisionUrl(revisionId, params), {
2663
+ ...options,
2664
+ method: "GET"
2665
+ });
2666
+ };
2415
2667
  const getCreateReleaseUrl = (params) => {
2416
2668
  const normalizedParams = new URLSearchParams();
2417
2669
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -2507,7 +2759,9 @@ const getBuildReleaseUrl = (params) => {
2507
2759
  * allocates nothing, however long ago it was built. Otherwise every resource is compared against the
2508
2760
  * project's newest revision of the same handle: unchanged content reuses
2509
2761
  * that revision, changed content allocates a new one, and the request
2510
- * answers `201` with the new release. Metadata is excluded from the
2762
+ * answers `201` with the new release. A policy whose config matches only an
2763
+ * older revision allocates a new one too, so a request that resolves no
2764
+ * release, which reads the newest revision, applies it as well. Metadata is excluded from the
2511
2765
  * comparison, so the same content under a different `message` is the same
2512
2766
  * release.
2513
2767
  *
@@ -2521,8 +2775,8 @@ const getBuildReleaseUrl = (params) => {
2521
2775
  *
2522
2776
  * Building writes revisions, so besides `release.write` it needs the write
2523
2777
  * scope of every kind the bundle carries a resource of: `schema.write`,
2524
- * `flow_definition.write`, `branding.write` and `idp.write`, as the
2525
- * per-kind create endpoints do. A missing scope answers `403` with `rel.permission_denied`,
2778
+ * `flow_definition.write`, `branding.write`, `idp.write` and
2779
+ * `policy.write`, as the per-kind create endpoints do. A missing scope answers `403` with `rel.permission_denied`,
2526
2780
  * naming the kind. An empty kind needs no scope.
2527
2781
  *
2528
2782
  * Building a release does not deploy it. A release is not tied to an
@@ -2968,11 +3222,11 @@ const getCreateDeploymentUrl = (params) => {
2968
3222
  * - `400 dep.invalid`: both or neither of `release_id` and `content_hash`;
2969
3223
  * a primary origin named exactly; `primary` mixed with preview URLs;
2970
3224
  * `primary` on a project with no primary origin; `ttl` with `primary`;
2971
- * `ttl` above the project's maximum.
3225
+ * `ttl` above 365 days (`P365D`).
2972
3226
  * - `400 dep.variables_missing`: a referenced variable has no value for
2973
3227
  * the kind; `details` names the kind and every missing variable.
2974
3228
  * - `403 proj.origin_not_allowed`: a preview URL matches no preview
2975
- * pattern.
3229
+ * pattern, or is a loopback URL.
2976
3230
  * - `404 rel.not_found`: the release id or digest names no release here.
2977
3231
  * - `409 dep.conflict`: `expected_deployment_id` is not the deployment
2978
3232
  * this write replaces; `details.deployment` is that deployment.
@@ -3170,7 +3424,7 @@ function createZitadelClient(opts) {
3170
3424
  } });
3171
3425
  }
3172
3426
  //#endregion
3173
- //#region ../config/dist/defaults-B3SfaQPb.mjs
3427
+ //#region ../config/dist/defaults-Cuaveyma.mjs
3174
3428
  var default_human_user_default = {
3175
3429
  title: "DefaultHumanUserSchema",
3176
3430
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -3556,18 +3810,28 @@ function fieldBody(field, templateProps) {
3556
3810
  };
3557
3811
  }
3558
3812
  /**
3813
+ * The fields a user's display name is made of, in order. A schema designates
3814
+ * those its use case collects as `x-display`, so a session names the user
3815
+ * ("Ada Lovelace") rather than leaving the app only their email.
3816
+ */
3817
+ const DISPLAY_FIELDS = ["givenName", "familyName"];
3818
+ /**
3559
3819
  * Narrow a rendered schema to the chosen use case: keep the preset-owned
3560
3820
  * header and `x-auth-methods`, but replace `properties`/`required` with the
3561
- * use case's field set. `email` is the sole required property.
3821
+ * use case's field set, and designate its name fields as `x-display`. `email`
3822
+ * is the sole required property.
3562
3823
  */
3563
3824
  function applyUseCaseToSchema(schema, useCase) {
3564
3825
  const templateProps = schema.properties ?? {};
3826
+ const fields = useCaseFields(useCase);
3565
3827
  const properties = {};
3566
- for (const field of useCaseFields(useCase)) properties[field] = fieldBody(field, templateProps);
3828
+ for (const field of fields) properties[field] = fieldBody(field, templateProps);
3829
+ const display = DISPLAY_FIELDS.filter((field) => fields.includes(field));
3567
3830
  return {
3568
3831
  ...schema,
3569
3832
  required: ["email"],
3570
- properties
3833
+ properties,
3834
+ ...display.length > 0 ? { "x-display": display } : {}
3571
3835
  };
3572
3836
  }
3573
3837
  /**
@@ -4184,4 +4448,4 @@ Object.defineProperty(exports, "startLocalZitadel", {
4184
4448
  }
4185
4449
  });
4186
4450
 
4187
- //# sourceMappingURL=src-CUvV1OWp.cjs.map
4451
+ //# sourceMappingURL=src-BxDa7FSy.cjs.map