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

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.
@@ -122,7 +122,7 @@ function safeJsonParse(text) {
122
122
  //#endregion
123
123
  //#region ../api/dist/generated/endpoints/zitadelNextGen.mjs
124
124
  /**
125
- * Generated by orval v8.10.0 🍺
125
+ * Generated by orval 🍺
126
126
  * Do not edit manually.
127
127
  * Zitadel NextGen
128
128
  * This is the next generation of the Zitadel identity platform.
@@ -133,6 +133,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
133
133
  completeClaim: () => completeClaim,
134
134
  createAuthAttempt: () => createAuthAttempt,
135
135
  createBranding: () => createBranding,
136
+ createDeployment: () => createDeployment,
136
137
  createFlow: () => createFlow,
137
138
  createFlowDefinition: () => createFlowDefinition,
138
139
  createGrant: () => createGrant,
@@ -158,6 +159,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
158
159
  getCompleteClaimUrl: () => getCompleteClaimUrl,
159
160
  getCreateAuthAttemptUrl: () => getCreateAuthAttemptUrl,
160
161
  getCreateBrandingUrl: () => getCreateBrandingUrl,
162
+ getCreateDeploymentUrl: () => getCreateDeploymentUrl,
161
163
  getCreateFlowDefinitionUrl: () => getCreateFlowDefinitionUrl,
162
164
  getCreateFlowUrl: () => getCreateFlowUrl,
163
165
  getCreateGrantUrl: () => getCreateGrantUrl,
@@ -173,6 +175,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
173
175
  getDeleteTeamUrl: () => getDeleteTeamUrl,
174
176
  getDeleteUserByIDUrl: () => getDeleteUserByIDUrl,
175
177
  getDeleteVariableUrl: () => getDeleteVariableUrl,
178
+ getDeploymentById: () => getDeploymentById,
176
179
  getEnvironmentByName: () => getEnvironmentByName,
177
180
  getEvent: () => getEvent,
178
181
  getExchangeHandoffUrl: () => getExchangeHandoffUrl,
@@ -183,6 +186,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
183
186
  getGetBrandingByIdUrl: () => getGetBrandingByIdUrl,
184
187
  getGetClaimStatusUrl: () => getGetClaimStatusUrl,
185
188
  getGetClaimWindowUrl: () => getGetClaimWindowUrl,
189
+ getGetDeploymentByIdUrl: () => getGetDeploymentByIdUrl,
186
190
  getGetEnvironmentByNameUrl: () => getGetEnvironmentByNameUrl,
187
191
  getGetEventUrl: () => getGetEventUrl,
188
192
  getGetFlowDefinitionUrl: () => getGetFlowDefinitionUrl,
@@ -210,6 +214,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
210
214
  getInitClaimUrl: () => getInitClaimUrl,
211
215
  getIssueChallengeUrl: () => getIssueChallengeUrl,
212
216
  getListBrandingUrl: () => getListBrandingUrl,
217
+ getListDeploymentsUrl: () => getListDeploymentsUrl,
213
218
  getListEnvironmentsUrl: () => getListEnvironmentsUrl,
214
219
  getListEventsUrl: () => getListEventsUrl,
215
220
  getListFlowDefinitionsUrl: () => getListFlowDefinitionsUrl,
@@ -250,6 +255,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
250
255
  initClaim: () => initClaim,
251
256
  issueChallenge: () => issueChallenge,
252
257
  listBranding: () => listBranding,
258
+ listDeployments: () => listDeployments,
253
259
  listEnvironments: () => listEnvironments,
254
260
  listEvents: () => listEvents,
255
261
  listFlowDefinitions: () => listFlowDefinitions,
@@ -318,7 +324,7 @@ const getReady = async (options) => {
318
324
  const getCreateUserUrl = (params) => {
319
325
  const normalizedParams = new URLSearchParams();
320
326
  Object.entries(params || {}).forEach(([key, value]) => {
321
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
327
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
322
328
  });
323
329
  const stringifiedParams = normalizedParams.toString();
324
330
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users?${stringifiedParams}` : `${getProxyPath()}/users`;
@@ -327,40 +333,58 @@ const getCreateUserUrl = (params) => {
327
333
  * @summary Create user
328
334
  */
329
335
  const createUser = async (createUserBody, params, options) => {
336
+ const getHeaders = (h) => {
337
+ if (!h) return {};
338
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
339
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
340
+ const headers = {};
341
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
342
+ return headers;
343
+ };
330
344
  return customFetch(getCreateUserUrl(params), {
331
345
  ...options,
332
346
  method: "POST",
333
347
  headers: {
334
348
  "Content-Type": "application/json",
335
- ...options?.headers
349
+ ...getHeaders(options?.headers)
336
350
  },
337
351
  body: JSON.stringify(createUserBody)
338
352
  });
339
353
  };
340
- const getQueryUsersUrl = () => {
341
- return `${getProxyPath()}/users/query`;
354
+ const getQueryUsersUrl = (params) => {
355
+ const normalizedParams = new URLSearchParams();
356
+ Object.entries(params || {}).forEach(([key, value]) => {
357
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
358
+ });
359
+ const stringifiedParams = normalizedParams.toString();
360
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/query?${stringifiedParams}` : `${getProxyPath()}/users/query`;
342
361
  };
343
362
  /**
344
363
  * Returns the users of a project, paginated with a cursor.
345
-
346
- The project comes from the credential, not from a parameter: the
347
- operation is bound to the credential's home project by construction
348
- (oauth2 secret or user-bound session). This is why it takes no
349
- `project_id`, unlike the other query endpoints.
350
-
351
- Accepts either a project secret (`oauth2`) or a user-bound Console
352
- session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
353
- is a follow-up (#1140).
354
-
364
+ *
365
+ * `project_id` names the project to list; without it, the credential's own
366
+ * project is listed.
367
+ *
368
+ * 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).
355
371
  * @summary Query users
356
372
  */
357
- const queryUsers = async (queryUsersBody, options) => {
358
- return customFetch(getQueryUsersUrl(), {
373
+ const queryUsers = async (queryUsersBody, params, options) => {
374
+ const getHeaders = (h) => {
375
+ if (!h) return {};
376
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
377
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
378
+ const headers = {};
379
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
380
+ return headers;
381
+ };
382
+ return customFetch(getQueryUsersUrl(params), {
359
383
  ...options,
360
384
  method: "POST",
361
385
  headers: {
362
386
  "Content-Type": "application/json",
363
- ...options?.headers
387
+ ...getHeaders(options?.headers)
364
388
  },
365
389
  body: JSON.stringify(queryUsersBody)
366
390
  });
@@ -368,10 +392,10 @@ const queryUsers = async (queryUsersBody, options) => {
368
392
  const getGetUserByIDUrl = (userId, params) => {
369
393
  const normalizedParams = new URLSearchParams();
370
394
  Object.entries(params || {}).forEach(([key, value]) => {
371
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
395
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
372
396
  });
373
397
  const stringifiedParams = normalizedParams.toString();
374
- return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${userId}?${stringifiedParams}` : `${getProxyPath()}/users/${userId}`;
398
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
375
399
  };
376
400
  /**
377
401
  * @summary Get user by ID
@@ -383,29 +407,36 @@ const getUserByID = async (userId, params, options) => {
383
407
  });
384
408
  };
385
409
  const getPatchUserByIDUrl = (userId) => {
386
- return `${getProxyPath()}/users/${userId}`;
410
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
387
411
  };
388
412
  /**
389
413
  * Partially updates a user's schema-defined attributes, and optionally
390
- moves the user to another registered schema. The merged result is
391
- validated against the schema before commit. Concurrent writes are
392
- last-write-wins.
393
-
414
+ * moves the user to another registered schema. The merged result is
415
+ * validated against the schema before commit. Concurrent writes are
416
+ * last-write-wins.
394
417
  * @summary Update user by ID
395
418
  */
396
419
  const patchUserByID = async (userId, patchUserByIDBody, options) => {
420
+ const getHeaders = (h) => {
421
+ if (!h) return {};
422
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
423
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
424
+ const headers = {};
425
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
426
+ return headers;
427
+ };
397
428
  return customFetch(getPatchUserByIDUrl(userId), {
398
429
  ...options,
399
430
  method: "PATCH",
400
431
  headers: {
401
432
  "Content-Type": "application/json",
402
- ...options?.headers
433
+ ...getHeaders(options?.headers)
403
434
  },
404
435
  body: JSON.stringify(patchUserByIDBody)
405
436
  });
406
437
  };
407
438
  const getDeleteUserByIDUrl = (userId) => {
408
- return `${getProxyPath()}/users/${userId}`;
439
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
409
440
  };
410
441
  /**
411
442
  * @summary Delete user by ID
@@ -419,10 +450,10 @@ const deleteUserByID = async (userId, options) => {
419
450
  const getListUserPasskeysUrl = (userId, params) => {
420
451
  const normalizedParams = new URLSearchParams();
421
452
  Object.entries(params || {}).forEach(([key, value]) => {
422
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
453
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
423
454
  });
424
455
  const stringifiedParams = normalizedParams.toString();
425
- return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${userId}/passkeys?${stringifiedParams}` : `${getProxyPath()}/users/${userId}/passkeys`;
456
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys`;
426
457
  };
427
458
  /**
428
459
  * @summary List user passkeys
@@ -434,65 +465,87 @@ const listUserPasskeys = async (userId, params, options) => {
434
465
  });
435
466
  };
436
467
  const getBeginUserPasskeyRegistrationUrl = (userId) => {
437
- return `${getProxyPath()}/users/${userId}/passkeys/registrations`;
468
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys/registrations`;
438
469
  };
439
470
  /**
440
471
  * Starts a WebAuthn registration ceremony for the user and returns the
441
- creation options for `navigator.credentials.create()`. Complete the
442
- ceremony with `POST /users/{user_id}/passkeys/registrations/{registration_id}` within
443
- five minutes. Credentials already registered for the user are excluded
444
- automatically.
445
-
472
+ * creation options for `navigator.credentials.create()`. Complete the
473
+ * ceremony with `POST /users/{user_id}/passkeys/registrations/{registration_id}` within
474
+ * five minutes. Credentials already registered for the user are excluded
475
+ * automatically.
446
476
  * @summary Begin passkey registration
447
477
  */
448
478
  const beginUserPasskeyRegistration = async (userId, beginUserPasskeyRegistrationBody, options) => {
479
+ const getHeaders = (h) => {
480
+ if (!h) return {};
481
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
482
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
483
+ const headers = {};
484
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
485
+ return headers;
486
+ };
449
487
  return customFetch(getBeginUserPasskeyRegistrationUrl(userId), {
450
488
  ...options,
451
489
  method: "POST",
452
490
  headers: {
453
491
  "Content-Type": "application/json",
454
- ...options?.headers
492
+ ...getHeaders(options?.headers)
455
493
  },
456
494
  body: JSON.stringify(beginUserPasskeyRegistrationBody)
457
495
  });
458
496
  };
459
497
  const getFinishUserPasskeyRegistrationUrl = (userId, registrationId) => {
460
- return `${getProxyPath()}/users/${userId}/passkeys/registrations/${registrationId}`;
498
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys/registrations/${encodeURIComponent(String(registrationId))}`;
461
499
  };
462
500
  /**
463
501
  * Verifies the attestation against the ceremony started by
464
- `POST /users/{user_id}/passkeys/registrations` and persists the new credential. A
465
- rejected attestation counts against the ceremony's failure budget and the
466
- ceremony stays open for a retry. An expired ceremony surfaces as
467
- `att.stale_challenge`; an unknown or already-consumed registration id
468
- surfaces as `att.not_found`.
469
-
502
+ * `POST /users/{user_id}/passkeys/registrations` and persists the new credential. A
503
+ * rejected attestation counts against the ceremony's failure budget and the
504
+ * ceremony stays open for a retry. An expired ceremony surfaces as
505
+ * `att.stale_challenge`; an unknown or already-consumed registration id
506
+ * surfaces as `att.not_found`.
470
507
  * @summary Finish passkey registration
471
508
  */
472
509
  const finishUserPasskeyRegistration = async (userId, registrationId, finishUserPasskeyRegistrationBody, options) => {
510
+ const getHeaders = (h) => {
511
+ if (!h) return {};
512
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
513
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
514
+ const headers = {};
515
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
516
+ return headers;
517
+ };
473
518
  return customFetch(getFinishUserPasskeyRegistrationUrl(userId, registrationId), {
474
519
  ...options,
475
520
  method: "POST",
476
521
  headers: {
477
522
  "Content-Type": "application/json",
478
- ...options?.headers
523
+ ...getHeaders(options?.headers)
479
524
  },
480
525
  body: JSON.stringify(finishUserPasskeyRegistrationBody)
481
526
  });
482
527
  };
483
528
  const getSetUserPasswordUrl = (userId) => {
484
- return `${getProxyPath()}/users/${userId}/password`;
529
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/password`;
485
530
  };
486
531
  /**
487
532
  * @summary Set user password
488
533
  */
489
534
  const setUserPassword = async (userId, setUserPasswordBody, options) => {
535
+ const getHeaders = (h) => {
536
+ if (!h) return {};
537
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
538
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
539
+ const headers = {};
540
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
541
+ return headers;
542
+ };
490
543
  return customFetch(getSetUserPasswordUrl(userId), {
491
544
  ...options,
492
545
  method: "PUT",
493
546
  headers: {
494
547
  "Content-Type": "application/json",
495
- ...options?.headers
548
+ ...getHeaders(options?.headers)
496
549
  },
497
550
  body: JSON.stringify(setUserPasswordBody)
498
551
  });
@@ -500,20 +553,19 @@ const setUserPassword = async (userId, setUserPasswordBody, options) => {
500
553
  const getListUserTeamsUrl = (userId, params) => {
501
554
  const normalizedParams = new URLSearchParams();
502
555
  Object.entries(params || {}).forEach(([key, value]) => {
503
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
556
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
504
557
  });
505
558
  const stringifiedParams = normalizedParams.toString();
506
- return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${userId}/teams?${stringifiedParams}` : `${getProxyPath()}/users/${userId}/teams`;
559
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/teams?${stringifiedParams}` : `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/teams`;
507
560
  };
508
561
  /**
509
562
  * The user's team roster, ordered by team name. Each entry carries the
510
- team's name, so a client renders a page without resolving ids one by one.
511
-
512
- This is the N:N roster and it is not lifecycle ownership: the single team
513
- that owns the user's lifecycle is reported as `metadata.lifecycle_owner_team_id`
514
- on the user read endpoints. Memberships the user was removed from are not
515
- returned.
516
-
563
+ * team's name, so a client renders a page without resolving ids one by one.
564
+ *
565
+ * This is the N:N roster and it is not lifecycle ownership: the single team
566
+ * that owns the user's lifecycle is reported as `metadata.lifecycle_owner_team_id`
567
+ * on the user read endpoints. Memberships the user was removed from are not
568
+ * returned.
517
569
  * @summary List the teams a user belongs to
518
570
  */
519
571
  const listUserTeams = async (userId, params, options) => {
@@ -539,18 +591,25 @@ const getPatchMyUserUrl = () => {
539
591
  };
540
592
  /**
541
593
  * Partially updates the caller's own schema-defined attributes. The merged
542
- result is validated against the user's schema before commit. Concurrent
543
- writes are last-write-wins.
544
-
594
+ * result is validated against the user's schema before commit. Concurrent
595
+ * writes are last-write-wins.
545
596
  * @summary Update my user information
546
597
  */
547
598
  const patchMyUser = async (patchMyUserBody, options) => {
599
+ const getHeaders = (h) => {
600
+ if (!h) return {};
601
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
602
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
603
+ const headers = {};
604
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
605
+ return headers;
606
+ };
548
607
  return customFetch(getPatchMyUserUrl(), {
549
608
  ...options,
550
609
  method: "PATCH",
551
610
  headers: {
552
611
  "Content-Type": "application/json",
553
- ...options?.headers
612
+ ...getHeaders(options?.headers)
554
613
  },
555
614
  body: JSON.stringify(patchMyUserBody)
556
615
  });
@@ -558,20 +617,19 @@ const patchMyUser = async (patchMyUserBody, options) => {
558
617
  const getListMyProjectsUrl = (params) => {
559
618
  const normalizedParams = new URLSearchParams();
560
619
  Object.entries(params || {}).forEach(([key, value]) => {
561
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
620
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
562
621
  });
563
622
  const stringifiedParams = normalizedParams.toString();
564
623
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me/projects?${stringifiedParams}` : `${getProxyPath()}/users/me/projects`;
565
624
  };
566
625
  /**
567
626
  * The projects the signed-in user holds an active grant on, either directly or
568
- through a team they are a member of. Ordered by project id and paged with an
569
- opaque cursor.
570
-
571
- This is not the same question as `queryProjects`, which answers with the one
572
- project the calling credential is bound to. Here the session is the caller
573
- and the grants are the answer, so the list spans projects.
574
-
627
+ * through a team they are a member of. Ordered by project id and paged with an
628
+ * opaque cursor.
629
+ *
630
+ * This is not the same question as `queryProjects`, which answers with the one
631
+ * project the calling credential is bound to. Here the session is the caller
632
+ * and the grants are the answer, so the list spans projects.
575
633
  * @summary List the projects I can act on
576
634
  */
577
635
  const listMyProjects = async (params, options) => {
@@ -585,37 +643,43 @@ const getCreateFlowUrl = () => {
585
643
  };
586
644
  /**
587
645
  * Resolves a flow definition based on purpose + audience context and returns
588
- the first capability step. Creates a new session implicitly unless
589
- `session_id` is provided (for step-up / reauth on an existing session).
590
-
591
- The response contains an `id` field — the flow handle. Use it as the path
592
- parameter for all subsequent `/flow/{id}/submit` calls.
593
-
594
- The response also sets an encrypted `HttpOnly` cookie (`_zflow`) containing
595
- the flow's orchestration state (current step, collected data, history).
596
- The server is stateless between requests — all flow state lives in this
597
- cookie. The browser sends it automatically on subsequent requests.
598
-
646
+ * the first capability step. Creates a new session implicitly unless
647
+ * `session_id` is provided (for step-up / reauth on an existing session).
648
+ *
649
+ * The response contains an `id` field — the flow handle. Use it as the path
650
+ * parameter for all subsequent `/flow/{id}/submit` calls.
651
+ *
652
+ * The response also sets an encrypted `HttpOnly` cookie (`_zflow`) containing
653
+ * the flow's orchestration state (current step, collected data, history).
654
+ * The server is stateless between requests — all flow state lives in this
655
+ * cookie. The browser sends it automatically on subsequent requests.
599
656
  * @summary Start a new flow
600
657
  */
601
658
  const createFlow = async (createFlowBody, options) => {
659
+ const getHeaders = (h) => {
660
+ if (!h) return {};
661
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
662
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
663
+ const headers = {};
664
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
665
+ return headers;
666
+ };
602
667
  return customFetch(getCreateFlowUrl(), {
603
668
  ...options,
604
669
  method: "POST",
605
670
  headers: {
606
671
  "Content-Type": "application/json",
607
- ...options?.headers
672
+ ...getHeaders(options?.headers)
608
673
  },
609
674
  body: JSON.stringify(createFlowBody)
610
675
  });
611
676
  };
612
677
  const getGetFlowStepUrl = (id) => {
613
- return `${getProxyPath()}/flow/${id}`;
678
+ return `${getProxyPath()}/flow/${encodeURIComponent(String(id))}`;
614
679
  };
615
680
  /**
616
681
  * Returns the current capability step without advancing the state machine.
617
- Useful for page reloads or re-rendering after a network error.
618
-
682
+ * Useful for page reloads or re-rendering after a network error.
619
683
  * @summary Get current step (re-render)
620
684
  */
621
685
  const getFlowStep = async (id, options) => {
@@ -625,46 +689,53 @@ const getFlowStep = async (id, options) => {
625
689
  });
626
690
  };
627
691
  const getSubmitFlowStepUrl = (id) => {
628
- return `${getProxyPath()}/flow/${id}/submit`;
692
+ return `${getProxyPath()}/flow/${encodeURIComponent(String(id))}/submit`;
629
693
  };
630
694
  /**
631
695
  * Submits user input for the current step. The server validates,
632
- processes (e.g., verifies a credential), advances the state machine
633
- through any invisible steps, and returns the next visible step.
634
-
635
- The response sets an updated encrypted `HttpOnly` cookie (`_zflow`)
636
- with the new flow state. The server is stateless — all orchestration
637
- state is carried in this cookie between requests.
638
-
639
- **Important:** The `id` in the response may differ from the `id` used in
640
- the request. This happens when a flow pivots (pushes a new flow onto the
641
- stack) or when a stacked flow completes (auto-pops to the parent flow).
642
- Always use the `id` from the latest response for the next request.
643
-
644
- ## Flow completion
645
-
646
- When `step.type` is `complete`, the flow is terminal. The `step.behavior`
647
- field tells the frontend what to do:
648
-
649
- | `behavior` | Action |
650
- |------------- |------------------------------------------------------------|
651
- | `redirect` | Navigate to `redirect_uri` (OIDC/SAML auth request done). |
652
- | `show` | Render the step as a success screen (e.g., registration). |
653
-
654
- A `complete` step is only returned when the **entire flow stack** is done.
655
- If a stacked flow (e.g., recovery pivoted from login) finishes, the server
656
- auto-pops to the parent flow and returns the parent's next step — the
657
- frontend never sees a `complete` for intermediate flows.
658
-
696
+ * processes (e.g., verifies a credential), advances the state machine
697
+ * through any invisible steps, and returns the next visible step.
698
+ *
699
+ * The response sets an updated encrypted `HttpOnly` cookie (`_zflow`)
700
+ * with the new flow state. The server is stateless — all orchestration
701
+ * state is carried in this cookie between requests.
702
+ *
703
+ * **Important:** The `id` in the response may differ from the `id` used in
704
+ * the request. This happens when a flow pivots (pushes a new flow onto the
705
+ * stack) or when a stacked flow completes (auto-pops to the parent flow).
706
+ * Always use the `id` from the latest response for the next request.
707
+ *
708
+ * ## Flow completion
709
+ *
710
+ * When `step.type` is `complete`, the flow is terminal. The `step.behavior`
711
+ * field tells the frontend what to do:
712
+ *
713
+ * | `behavior` | Action |
714
+ * |------------- |------------------------------------------------------------|
715
+ * | `redirect` | Navigate to `redirect_uri` (OIDC/SAML auth request done). |
716
+ * | `show` | Render the step as a success screen (e.g., registration). |
717
+ *
718
+ * A `complete` step is only returned when the **entire flow stack** is done.
719
+ * If a stacked flow (e.g., recovery pivoted from login) finishes, the server
720
+ * auto-pops to the parent flow and returns the parent's next step — the
721
+ * frontend never sees a `complete` for intermediate flows.
659
722
  * @summary Submit step data and advance
660
723
  */
661
724
  const submitFlowStep = async (id, submitFlowStepBody, options) => {
725
+ const getHeaders = (h) => {
726
+ if (!h) return {};
727
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
728
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
729
+ const headers = {};
730
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
731
+ return headers;
732
+ };
662
733
  return customFetch(getSubmitFlowStepUrl(id), {
663
734
  ...options,
664
735
  method: "POST",
665
736
  headers: {
666
737
  "Content-Type": "application/json",
667
- ...options?.headers
738
+ ...getHeaders(options?.headers)
668
739
  },
669
740
  body: JSON.stringify(submitFlowStepBody)
670
741
  });
@@ -674,38 +745,44 @@ const getCreateAuthAttemptUrl = () => {
674
745
  };
675
746
  /**
676
747
  * Starts a new authentication attempt. This is the entry point for the auth_attempts state machine.
677
-
678
- An attempt is an ephemeral (15-minute TTL) state machine that drives a single authentication round.
679
- It accepts factor challenges, verifies proofs, and completes into a session or handoff token.
680
-
681
- Accepts a project_id and challenge_nonce (from POST /bootstrap/challenge). For step-up re-auth,
682
- also include session_id to add factors to an existing session.
683
-
748
+ *
749
+ * An attempt is an ephemeral (15-minute TTL) state machine that drives a single authentication round.
750
+ * It accepts factor challenges, verifies proofs, and completes into a session or handoff token.
751
+ *
752
+ * Accepts a project_id and challenge_nonce (from POST /bootstrap/challenge). For step-up re-auth,
753
+ * also include session_id to add factors to an existing session.
684
754
  * @summary Create a new authentication attempt
685
755
  */
686
756
  const createAuthAttempt = async (createAuthAttemptBody, options) => {
757
+ const getHeaders = (h) => {
758
+ if (!h) return {};
759
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
760
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
761
+ const headers = {};
762
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
763
+ return headers;
764
+ };
687
765
  return customFetch(getCreateAuthAttemptUrl(), {
688
766
  ...options,
689
767
  method: "POST",
690
768
  headers: {
691
769
  "Content-Type": "application/json",
692
- ...options?.headers
770
+ ...getHeaders(options?.headers)
693
771
  },
694
772
  body: JSON.stringify(createAuthAttemptBody)
695
773
  });
696
774
  };
697
775
  const getGetAuthAttemptUrl = (attemptId) => {
698
- return `${getProxyPath()}/auth_attempts/${attemptId}`;
776
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}`;
699
777
  };
700
778
  /**
701
779
  * Polls the current state of an authentication attempt.
702
-
703
- Returns the attempt's state, available factors for the next challenge,
704
- challenges issued so far, and any errors preventing progress.
705
-
706
- Use this for polling during long-running factor verifications (e.g., waiting for
707
- a federated IdP callback or a device flow).
708
-
780
+ *
781
+ * Returns the attempt's state, available factors for the next challenge,
782
+ * challenges issued so far, and any errors preventing progress.
783
+ *
784
+ * Use this for polling during long-running factor verifications (e.g., waiting for
785
+ * a federated IdP callback or a device flow).
709
786
  * @summary Get authentication attempt state
710
787
  */
711
788
  const getAuthAttempt = async (attemptId, options) => {
@@ -715,72 +792,85 @@ const getAuthAttempt = async (attemptId, options) => {
715
792
  });
716
793
  };
717
794
  const getIssueChallengeUrl = (attemptId) => {
718
- return `${getProxyPath()}/auth_attempts/${attemptId}/challenges`;
795
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/challenges`;
719
796
  };
720
797
  /**
721
798
  * Issues a single-factor verification challenge within an auth attempt.
722
-
723
- This advances the authentication state machine by requesting a specific factor method
724
- (password, passkey, TOTP, OTP via SMS, etc.). The server responds with challenge details
725
- including method, metadata, and any UI hints. The client then verifies the proof
726
- by calling POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify.
727
-
799
+ *
800
+ * This advances the authentication state machine by requesting a specific factor method
801
+ * (password, passkey, TOTP, OTP via SMS, etc.). The server responds with challenge details
802
+ * including method, metadata, and any UI hints. The client then verifies the proof
803
+ * by calling POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify.
728
804
  * @summary Issue a factor challenge
729
805
  */
730
806
  const issueChallenge = async (attemptId, issueChallengeBody, options) => {
807
+ const getHeaders = (h) => {
808
+ if (!h) return {};
809
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
810
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
811
+ const headers = {};
812
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
813
+ return headers;
814
+ };
731
815
  return customFetch(getIssueChallengeUrl(attemptId), {
732
816
  ...options,
733
817
  method: "POST",
734
818
  headers: {
735
819
  "Content-Type": "application/json",
736
- ...options?.headers
820
+ ...getHeaders(options?.headers)
737
821
  },
738
822
  body: JSON.stringify(issueChallengeBody)
739
823
  });
740
824
  };
741
825
  const getVerifyChallengeProofUrl = (attemptId, challengeId) => {
742
- return `${getProxyPath()}/auth_attempts/${attemptId}/challenges/${challengeId}/verify`;
826
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/challenges/${encodeURIComponent(String(challengeId))}/verify`;
743
827
  };
744
828
  /**
745
829
  * Submits a proof (credential, code, assertion) to verify a factor challenge.
746
-
747
- The proof format depends on the challenge method. For example:
748
- - `password` method: { password: "…" }
749
- - `totp` method: { totp: { code: "123456" } }
750
- - `passkey` method: { passkey: { assertion: "…" } }
751
- - `recovery_code` method: { recovery_code: "…" }
752
-
753
- On successful verification, the factor is written to the auth attempt.
754
- The attempt moves to the next pending challenge or completes if all required factors are verified.
755
-
830
+ *
831
+ * The proof format depends on the challenge method. For example:
832
+ * - `password` method: { password: "…" }
833
+ * - `totp` method: { totp: { code: "123456" } }
834
+ * - `passkey` method: { passkey: { assertion: "…" } }
835
+ * - `recovery_code` method: { recovery_code: "…" }
836
+ *
837
+ * On successful verification, the factor is written to the auth attempt.
838
+ * The attempt moves to the next pending challenge or completes if all required factors are verified.
756
839
  * @summary Verify a factor proof
757
840
  */
758
841
  const verifyChallengeProof = async (attemptId, challengeId, verifyChallengeProofBody, options) => {
842
+ const getHeaders = (h) => {
843
+ if (!h) return {};
844
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
845
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
846
+ const headers = {};
847
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
848
+ return headers;
849
+ };
759
850
  return customFetch(getVerifyChallengeProofUrl(attemptId, challengeId), {
760
851
  ...options,
761
852
  method: "POST",
762
853
  headers: {
763
854
  "Content-Type": "application/json",
764
- ...options?.headers
855
+ ...getHeaders(options?.headers)
765
856
  },
766
857
  body: JSON.stringify(verifyChallengeProofBody)
767
858
  });
768
859
  };
769
860
  const getCreateHandoffUrl = (attemptId) => {
770
- return `${getProxyPath()}/auth_attempts/${attemptId}/handoff`;
861
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/handoff`;
771
862
  };
772
863
  /**
773
864
  * Completes the authentication attempt and mints a `handoff_token`.
774
-
775
- Call this after all required factors have been verified and the attempt is in `completed` state.
776
- The handoff token is short-lived (≤60 seconds) and must be exchanged at
777
- POST /sessions/exchange to receive the final session and session_token.
778
-
779
- The handoff token is:
780
- - Single-use (atomic exchange, no retry)
781
- - Audience-bound (requires matching project key for exchange)
782
- - Idempotency-safe within a 5-minute window (see conventions)
783
-
865
+ *
866
+ * Call this after all required factors have been verified and the attempt is in `completed` state.
867
+ * The handoff token is short-lived (≤60 seconds) and must be exchanged at
868
+ * POST /sessions/exchange to receive the final session and session_token.
869
+ *
870
+ * The handoff token is:
871
+ * - Single-use (atomic exchange, no retry)
872
+ * - Audience-bound (requires matching project key for exchange)
873
+ * - Idempotency-safe within a 5-minute window (see conventions)
784
874
  * @summary Complete authentication and create handoff token
785
875
  */
786
876
  const createHandoff = async (attemptId, options) => {
@@ -796,12 +886,20 @@ const getCreateProjectUrl = () => {
796
886
  * @summary Create project
797
887
  */
798
888
  const createProject = async (createProjectBody, options) => {
889
+ const getHeaders = (h) => {
890
+ if (!h) return {};
891
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
892
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
893
+ const headers = {};
894
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
895
+ return headers;
896
+ };
799
897
  return customFetch(getCreateProjectUrl(), {
800
898
  ...options,
801
899
  method: "POST",
802
900
  headers: {
803
901
  "Content-Type": "application/json",
804
- ...options?.headers
902
+ ...getHeaders(options?.headers)
805
903
  },
806
904
  body: JSON.stringify(createProjectBody)
807
905
  });
@@ -813,22 +911,29 @@ const getQueryProjectsUrl = () => {
813
911
  * @summary Query projects
814
912
  */
815
913
  const queryProjects = async (queryProjectsBody, options) => {
914
+ const getHeaders = (h) => {
915
+ if (!h) return {};
916
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
917
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
918
+ const headers = {};
919
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
920
+ return headers;
921
+ };
816
922
  return customFetch(getQueryProjectsUrl(), {
817
923
  ...options,
818
924
  method: "POST",
819
925
  headers: {
820
926
  "Content-Type": "application/json",
821
- ...options?.headers
927
+ ...getHeaders(options?.headers)
822
928
  },
823
929
  body: JSON.stringify(queryProjectsBody)
824
930
  });
825
931
  };
826
932
  const getGetProjectUrl = (projectId) => {
827
- return `${getProxyPath()}/projects/${projectId}`;
933
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}`;
828
934
  };
829
935
  /**
830
936
  * Returns the current state of a project.
831
-
832
937
  * @summary Get project
833
938
  */
834
939
  const getProject = async (projectId, options) => {
@@ -838,34 +943,40 @@ const getProject = async (projectId, options) => {
838
943
  });
839
944
  };
840
945
  const getPatchProjectUrl = (projectId) => {
841
- return `${getProxyPath()}/projects/${projectId}`;
946
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}`;
842
947
  };
843
948
  /**
844
949
  * Updates the state of a project.
845
-
846
950
  * @summary Update project
847
951
  */
848
952
  const patchProject = async (projectId, patchProjectBody, options) => {
953
+ const getHeaders = (h) => {
954
+ if (!h) return {};
955
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
956
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
957
+ const headers = {};
958
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
959
+ return headers;
960
+ };
849
961
  return customFetch(getPatchProjectUrl(projectId), {
850
962
  ...options,
851
963
  method: "PATCH",
852
964
  headers: {
853
965
  "Content-Type": "application/json",
854
- ...options?.headers
966
+ ...getHeaders(options?.headers)
855
967
  },
856
968
  body: JSON.stringify(patchProjectBody)
857
969
  });
858
970
  };
859
971
  const getInitClaimUrl = (projectId) => {
860
- return `${getProxyPath()}/projects/${projectId}/claim/init`;
972
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/init`;
861
973
  };
862
974
  /**
863
975
  * Starts a claim challenge for an unclaimed project. Authenticated by the
864
- project secret, this mints a single-use, short-lived challenge and returns
865
- the `claim_url` the developer opens in a browser to complete the claim,
866
- together with the `challenge_id` the CLI polls with. The exact expiry is
867
- carried by `expires_at` on the response.
868
-
976
+ * project secret, this mints a single-use, short-lived challenge and returns
977
+ * the `claim_url` the developer opens in a browser to complete the claim,
978
+ * together with the `challenge_id` the CLI polls with. The exact expiry is
979
+ * carried by `expires_at` on the response.
869
980
  * @summary Initialize a project claim
870
981
  */
871
982
  const initClaim = async (projectId, options) => {
@@ -877,21 +988,20 @@ const initClaim = async (projectId, options) => {
877
988
  const getGetClaimStatusUrl = (projectId, params) => {
878
989
  const normalizedParams = new URLSearchParams();
879
990
  Object.entries(params || {}).forEach(([key, value]) => {
880
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
991
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
881
992
  });
882
993
  const stringifiedParams = normalizedParams.toString();
883
- return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${projectId}/claim/status?${stringifiedParams}` : `${getProxyPath()}/projects/${projectId}/claim/status`;
994
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/status?${stringifiedParams}` : `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/status`;
884
995
  };
885
996
  /**
886
997
  * Polled by the CLI while a browser completes the claim. Authorized by the
887
- project secret that initiated the challenge. Returns `pending`, or
888
- `completed` with the owning team, the claim timestamp, and the dashboard
889
- URL once the project is claimed. The claim grant, not the polled
890
- challenge, is the source of truth: a project claimed through another
891
- concurrent challenge also reports `completed`, and a completed claim
892
- keeps reporting `completed` past this challenge's expiry and past the
893
- project's claim window.
894
-
998
+ * project secret that initiated the challenge. Returns `pending`, or
999
+ * `completed` with the owning team, the claim timestamp, and the dashboard
1000
+ * URL once the project is claimed. The claim grant, not the polled
1001
+ * challenge, is the source of truth: a project claimed through another
1002
+ * concurrent challenge also reports `completed`, and a completed claim
1003
+ * keeps reporting `completed` past this challenge's expiry and past the
1004
+ * project's claim window.
895
1005
  * @summary Get claim status
896
1006
  */
897
1007
  const getClaimStatus = async (projectId, params, options) => {
@@ -901,23 +1011,30 @@ const getClaimStatus = async (projectId, params, options) => {
901
1011
  });
902
1012
  };
903
1013
  const getCompleteClaimUrl = (projectId) => {
904
- return `${getProxyPath()}/projects/${projectId}/claim/complete`;
1014
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/complete`;
905
1015
  };
906
1016
  /**
907
1017
  * Called by the browser after the developer authenticates on the claim page.
908
- Authenticated by the `__nextgen_session` cookie, it attaches the project to
909
- the developer's personal team using the `challenge_id` from the claim URL as
910
- its single-use, browser-safe authorization.
911
-
1018
+ * Authenticated by the `__nextgen_session` cookie, it attaches the project to
1019
+ * the developer's personal team using the `challenge_id` from the claim URL as
1020
+ * its single-use, browser-safe authorization.
912
1021
  * @summary Complete a project claim
913
1022
  */
914
1023
  const completeClaim = async (projectId, completeClaimBody, options) => {
1024
+ const getHeaders = (h) => {
1025
+ if (!h) return {};
1026
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1027
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1028
+ const headers = {};
1029
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1030
+ return headers;
1031
+ };
915
1032
  return customFetch(getCompleteClaimUrl(projectId), {
916
1033
  ...options,
917
1034
  method: "POST",
918
1035
  headers: {
919
1036
  "Content-Type": "application/json",
920
- ...options?.headers
1037
+ ...getHeaders(options?.headers)
921
1038
  },
922
1039
  body: JSON.stringify(completeClaimBody)
923
1040
  });
@@ -925,19 +1042,18 @@ const completeClaim = async (projectId, completeClaimBody, options) => {
925
1042
  const getGetClaimWindowUrl = (projectId, params) => {
926
1043
  const normalizedParams = new URLSearchParams();
927
1044
  Object.entries(params || {}).forEach(([key, value]) => {
928
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1045
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
929
1046
  });
930
1047
  const stringifiedParams = normalizedParams.toString();
931
- return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${projectId}/claim/window?${stringifiedParams}` : `${getProxyPath()}/projects/${projectId}/claim/window`;
1048
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/window?${stringifiedParams}` : `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/window`;
932
1049
  };
933
1050
  /**
934
1051
  * Read by the claim page in the browser to show how long is left to claim the
935
- project. Unauthenticated by design: the claim page runs this before the
936
- developer has signed in, and holding the `challenge_id` from the claim URL
937
- is the authorization — the same capability `claim/complete` accepts. It
938
- reveals only the window, never the project itself, and unlike
939
- `claim/complete` it spends nothing, so a reload is free.
940
-
1052
+ * project. Unauthenticated by design: the claim page runs this before the
1053
+ * developer has signed in, and holding the `challenge_id` from the claim URL
1054
+ * is the authorization — the same capability `claim/complete` accepts. It
1055
+ * reveals only the window, never the project itself, and unlike
1056
+ * `claim/complete` it spends nothing, so a reload is free.
941
1057
  * @summary Get the claim window for a project
942
1058
  */
943
1059
  const getClaimWindow = async (projectId, params, options) => {
@@ -951,36 +1067,43 @@ const getCreateSessionUrl = () => {
951
1067
  };
952
1068
  /**
953
1069
  * Creates an anonymous session shell with no user and no factors (`state: building`).
954
-
955
- This is optional — an `auth_attempt` will create a session implicitly if none is provided.
956
- Use this explicitly when you want to:
957
- - Pre-allocate a `session_id` before the user is known, so device/telemetry signals
958
- can be correlated with the eventual authenticated session from the start.
959
- - Track anonymous state (bot detection, device fingerprint) that survives until authentication.
960
-
961
- Creating a session is an app-plane operation on the project credential
962
- (`session.write`). The returned `session_token` is a session credential for the
963
- end-user client, not a management scope: it is delivered as the
964
- `__nextgen_session` cookie and authorises the self-service operations
965
- `GET /sessions/me` and `DELETE /sessions/me` (`nextgenSession` scheme). The
966
- by-id operations `GET /sessions/{session_id}` and `DELETE /sessions/{session_id}`
967
- are operator endpoints and require `session.read` / `session.delete` instead.
968
-
969
- The `session_token` is superseded when a handoff exchange completes — clients must
970
- replace it at that point.
971
-
972
- Anonymous sessions expire aggressively (10-minute TTL). The TTL resets to the configured
973
- full session TTL when the first authentication factor is written via a completing `auth_attempt`.
974
-
1070
+ *
1071
+ * This is optional — an `auth_attempt` will create a session implicitly if none is provided.
1072
+ * Use this explicitly when you want to:
1073
+ * - Pre-allocate a `session_id` before the user is known, so device/telemetry signals
1074
+ * can be correlated with the eventual authenticated session from the start.
1075
+ * - Track anonymous state (bot detection, device fingerprint) that survives until authentication.
1076
+ *
1077
+ * Creating a session is an app-plane operation on the project credential
1078
+ * (`session.write`). The returned `session_token` is a session credential for the
1079
+ * end-user client, not a management scope: it is delivered as the
1080
+ * `__nextgen_session` cookie and authorises the self-service operations
1081
+ * `GET /sessions/me` and `DELETE /sessions/me` (`nextgenSession` scheme). The
1082
+ * by-id operations `GET /sessions/{session_id}` and `DELETE /sessions/{session_id}`
1083
+ * are operator endpoints and require `session.read` / `session.delete` instead.
1084
+ *
1085
+ * The `session_token` is superseded when a handoff exchange completes — clients must
1086
+ * replace it at that point.
1087
+ *
1088
+ * Anonymous sessions expire aggressively (10-minute TTL). The TTL resets to the configured
1089
+ * full session TTL when the first authentication factor is written via a completing `auth_attempt`.
975
1090
  * @summary Create an anonymous session shell
976
1091
  */
977
1092
  const createSession = async (createSessionBody, options) => {
1093
+ const getHeaders = (h) => {
1094
+ if (!h) return {};
1095
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1096
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1097
+ const headers = {};
1098
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1099
+ return headers;
1100
+ };
978
1101
  return customFetch(getCreateSessionUrl(), {
979
1102
  ...options,
980
1103
  method: "POST",
981
1104
  headers: {
982
1105
  "Content-Type": "application/json",
983
- ...options?.headers
1106
+ ...getHeaders(options?.headers)
984
1107
  },
985
1108
  body: JSON.stringify(createSessionBody)
986
1109
  });
@@ -988,25 +1111,32 @@ const createSession = async (createSessionBody, options) => {
988
1111
  const getQuerySessionsUrl = (params) => {
989
1112
  const normalizedParams = new URLSearchParams();
990
1113
  Object.entries(params || {}).forEach(([key, value]) => {
991
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1114
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
992
1115
  });
993
1116
  const stringifiedParams = normalizedParams.toString();
994
1117
  return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/query?${stringifiedParams}` : `${getProxyPath()}/sessions/query`;
995
1118
  };
996
1119
  /**
997
1120
  * Returns the sessions of a project, paginated with a cursor.
998
- Sessions of every lifecycle state are returned; each carries its `state`.
999
- Requires `session.read` permission.
1000
-
1121
+ * Sessions of every lifecycle state are returned; each carries its `state`.
1122
+ * Requires `session.read` permission.
1001
1123
  * @summary Query sessions
1002
1124
  */
1003
1125
  const querySessions = async (querySessionsBody, params, options) => {
1126
+ const getHeaders = (h) => {
1127
+ if (!h) return {};
1128
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1129
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1130
+ const headers = {};
1131
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1132
+ return headers;
1133
+ };
1004
1134
  return customFetch(getQuerySessionsUrl(params), {
1005
1135
  ...options,
1006
1136
  method: "POST",
1007
1137
  headers: {
1008
1138
  "Content-Type": "application/json",
1009
- ...options?.headers
1139
+ ...getHeaders(options?.headers)
1010
1140
  },
1011
1141
  body: JSON.stringify(querySessionsBody)
1012
1142
  });
@@ -1014,54 +1144,60 @@ const querySessions = async (querySessionsBody, params, options) => {
1014
1144
  const getExchangeHandoffUrl = (params) => {
1015
1145
  const normalizedParams = new URLSearchParams();
1016
1146
  Object.entries(params || {}).forEach(([key, value]) => {
1017
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1147
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1018
1148
  });
1019
1149
  const stringifiedParams = normalizedParams.toString();
1020
1150
  return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/exchange?${stringifiedParams}` : `${getProxyPath()}/sessions/exchange`;
1021
1151
  };
1022
1152
  /**
1023
1153
  * Consumes a one-time `handoff_token` minted by `POST /auth_attempts/{id}/handoff`
1024
- and returns the resulting session and a `session_token`.
1025
-
1026
- The server resolves the originating `auth_attempt` from the token and then:
1027
-
1028
- | Originating auth_attempt | Outcome |
1029
- |---|---|
1030
- | No `session_id` | A new authenticated session is **created**. |
1031
- | `session_id` points to an anonymous shell | Existing session is **upgraded** — user and factors written in, TTL reset to full session TTL. |
1032
- | `session_id` points to an active session (step-up) | Existing session is **upgraded** — new factors merged, `assurance_levels[]` expanded. |
1033
-
1034
- The response shape is identical in all three cases.
1035
-
1036
- The `session_token` supersedes any previously issued `session_token` for the same session.
1037
- Clients must replace their stored token at this point.
1038
-
1039
- Requires a project service key (OAuth2 client credentials).
1040
-
1154
+ * and returns the resulting session and a `session_token`.
1155
+ *
1156
+ * The server resolves the originating `auth_attempt` from the token and then:
1157
+ *
1158
+ * | Originating auth_attempt | Outcome |
1159
+ * |---|---|
1160
+ * | No `session_id` | A new authenticated session is **created**. |
1161
+ * | `session_id` points to an anonymous shell | Existing session is **upgraded** — user and factors written in, TTL reset to full session TTL. |
1162
+ * | `session_id` points to an active session (step-up) | Existing session is **upgraded** — new factors merged, `assurance_levels[]` expanded. |
1163
+ *
1164
+ * The response shape is identical in all three cases.
1165
+ *
1166
+ * The `session_token` supersedes any previously issued `session_token` for the same session.
1167
+ * Clients must replace their stored token at this point.
1168
+ *
1169
+ * Requires a project service key (OAuth2 client credentials).
1041
1170
  * @summary Exchange handoff token for a session
1042
1171
  */
1043
1172
  const exchangeHandoff = async (exchangeHandoffBody, params, options) => {
1173
+ const getHeaders = (h) => {
1174
+ if (!h) return {};
1175
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1176
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1177
+ const headers = {};
1178
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1179
+ return headers;
1180
+ };
1044
1181
  return customFetch(getExchangeHandoffUrl(params), {
1045
1182
  ...options,
1046
1183
  method: "POST",
1047
1184
  headers: {
1048
1185
  "Content-Type": "application/json",
1049
- ...options?.headers
1186
+ ...getHeaders(options?.headers)
1050
1187
  },
1051
1188
  body: JSON.stringify(exchangeHandoffBody)
1052
1189
  });
1053
1190
  };
1054
1191
  const getGetSessionUrl = (sessionId) => {
1055
- return `${getProxyPath()}/sessions/${sessionId}`;
1192
+ return `${getProxyPath()}/sessions/${encodeURIComponent(String(sessionId))}`;
1056
1193
  };
1057
1194
  /**
1058
1195
  * Returns the current state of a session including its factors and all currently
1059
- satisfied assurance levels.
1060
-
1061
- `assurance_levels[]` may shrink over time as factor freshness windows expire,
1062
- without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1063
- against the same `session_id`) to restore a dropped assurance level.
1064
-
1196
+ * satisfied assurance levels.
1197
+ *
1198
+ * `assurance_levels[]` may shrink over time as factor freshness windows expire,
1199
+ * without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1200
+ * against the same `session_id`) to restore a dropped assurance level.
1065
1201
  * @summary Get session state
1066
1202
  */
1067
1203
  const getSession = async (sessionId, options) => {
@@ -1071,19 +1207,18 @@ const getSession = async (sessionId, options) => {
1071
1207
  });
1072
1208
  };
1073
1209
  const getRevokeSessionUrl = (sessionId) => {
1074
- return `${getProxyPath()}/sessions/${sessionId}`;
1210
+ return `${getProxyPath()}/sessions/${encodeURIComponent(String(sessionId))}`;
1075
1211
  };
1076
1212
  /**
1077
1213
  * Permanently deletes the session, terminating it immediately.
1078
-
1079
- This is the operator revoke path and requires the `session.delete` scope on a
1080
- project-bound credential. End-user logout with the `__nextgen_session` cookie is
1081
- `DELETE /sessions/me` (`nextgenSession` scheme).
1082
-
1083
- Idempotent: deleting a session that does not exist (or was already deleted)
1084
- still returns 204. After deletion, any tokens derived from the session are
1085
- invalidated.
1086
-
1214
+ *
1215
+ * This is the operator revoke path and requires the `session.delete` scope on a
1216
+ * project-bound credential. End-user logout with the `__nextgen_session` cookie is
1217
+ * `DELETE /sessions/me` (`nextgenSession` scheme).
1218
+ *
1219
+ * Idempotent: deleting a session that does not exist (or was already deleted)
1220
+ * still returns 204. After deletion, any tokens derived from the session are
1221
+ * invalidated.
1087
1222
  * @summary Revoke session
1088
1223
  */
1089
1224
  const revokeSession = async (sessionId, options) => {
@@ -1097,12 +1232,11 @@ const getGetMySessionUrl = () => {
1097
1232
  };
1098
1233
  /**
1099
1234
  * Returns the current state of the current session including its factors and all currently
1100
- satisfied assurance levels.
1101
-
1102
- `assurance_levels[]` may shrink over time as factor freshness windows expire,
1103
- without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1104
- against the same `session_id`) to restore a dropped assurance level.
1105
-
1235
+ * satisfied assurance levels.
1236
+ *
1237
+ * `assurance_levels[]` may shrink over time as factor freshness windows expire,
1238
+ * without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1239
+ * against the same `session_id`) to restore a dropped assurance level.
1106
1240
  * @summary Get my session state
1107
1241
  */
1108
1242
  const getMySession = async (options) => {
@@ -1116,12 +1250,11 @@ const getRevokeMySessionUrl = () => {
1116
1250
  };
1117
1251
  /**
1118
1252
  * Logs out by permanently deleting the session.
1119
-
1120
- The `__nextgen_session` cookie issued at creation (or superseded by a handoff
1121
- exchange) is required. Idempotent: if the session is already gone this still
1122
- returns 204. Any tokens derived from the session are invalidated, and the
1123
- cookie itself is cleared in the response.
1124
-
1253
+ *
1254
+ * 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.
1125
1258
  * @summary Revoke my session
1126
1259
  */
1127
1260
  const revokeMySession = async (options) => {
@@ -1133,31 +1266,38 @@ const revokeMySession = async (options) => {
1133
1266
  const getCreateSchemaUrl = (params) => {
1134
1267
  const normalizedParams = new URLSearchParams();
1135
1268
  Object.entries(params || {}).forEach(([key, value]) => {
1136
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1269
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1137
1270
  });
1138
1271
  const stringifiedParams = normalizedParams.toString();
1139
1272
  return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas?${stringifiedParams}` : `${getProxyPath()}/schemas`;
1140
1273
  };
1141
1274
  /**
1142
1275
  * Create a new schema. The optional `$id` field is the JSON Schema document
1143
- URI used to identify the schema in future requests (GitOps-stable identity,
1144
- not a free-form resource primary key). When `$id` is omitted, the server
1145
- generates a `sch_*` URL. When provided, `$id` must be unique within the
1146
- project and should ideally be a valid URI pointing at where the schema can
1147
- be accessed.
1148
-
1149
- The schema can either be a concrete schema, e.g. a user schema, or a
1150
- schema-url which will be resolved by the server.
1151
-
1276
+ * URI used to identify the schema in future requests (GitOps-stable identity,
1277
+ * not a free-form resource primary key). When `$id` is omitted, the server
1278
+ * generates a `sch_*` URL. When provided, `$id` must be unique within the
1279
+ * project and should ideally be a valid URI pointing at where the schema can
1280
+ * be accessed.
1281
+ *
1282
+ * The schema can either be a concrete schema, e.g. a user schema, or a
1283
+ * schema-url which will be resolved by the server.
1152
1284
  * @summary Create new schema
1153
1285
  */
1154
1286
  const createSchema = async (createSchemaBody, params, options) => {
1287
+ const getHeaders = (h) => {
1288
+ if (!h) return {};
1289
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1290
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1291
+ const headers = {};
1292
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1293
+ return headers;
1294
+ };
1155
1295
  return customFetch(getCreateSchemaUrl(params), {
1156
1296
  ...options,
1157
1297
  method: "POST",
1158
1298
  headers: {
1159
1299
  "Content-Type": "application/json",
1160
- ...options?.headers
1300
+ ...getHeaders(options?.headers)
1161
1301
  },
1162
1302
  body: JSON.stringify(createSchemaBody)
1163
1303
  });
@@ -1165,15 +1305,14 @@ const createSchema = async (createSchemaBody, params, options) => {
1165
1305
  const getListSchemasUrl = (params) => {
1166
1306
  const normalizedParams = new URLSearchParams();
1167
1307
  Object.entries(params || {}).forEach(([key, value]) => {
1168
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1308
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1169
1309
  });
1170
1310
  const stringifiedParams = normalizedParams.toString();
1171
1311
  return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas?${stringifiedParams}` : `${getProxyPath()}/schemas`;
1172
1312
  };
1173
1313
  /**
1174
1314
  * Retrieve a list of all schemas available in the system. This endpoint
1175
- supports pagination and filtering based on schema attributes.
1176
-
1315
+ * supports pagination and filtering based on schema attributes.
1177
1316
  * @summary List all schemas
1178
1317
  */
1179
1318
  const listSchemas = async (params, options) => {
@@ -1185,16 +1324,22 @@ const listSchemas = async (params, options) => {
1185
1324
  const getGetSchemaByIdUrl = (id, params) => {
1186
1325
  const normalizedParams = new URLSearchParams();
1187
1326
  Object.entries(params || {}).forEach(([key, value]) => {
1188
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1327
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1189
1328
  });
1190
1329
  const stringifiedParams = normalizedParams.toString();
1191
- return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas/${id}?${stringifiedParams}` : `${getProxyPath()}/schemas/${id}`;
1330
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/schemas/${encodeURIComponent(String(id))}`;
1192
1331
  };
1193
1332
  /**
1194
1333
  * Get a schema by its ID. A schema ID identifies one immutable revision, so
1195
- this returns exactly that revision. To find the current revision of an
1196
- object type, list with `revisions=latest`.
1197
-
1334
+ * this returns exactly that revision. To find the current revision of an
1335
+ * object type, list with `revisions=latest`.
1336
+ *
1337
+ * Schema IDs are unique within a project, not across projects (the seeded
1338
+ * default schema carries the same `$id` in every project). A Console
1339
+ * session that manages more than one project names the project with
1340
+ * `project_id`; without it, the ID is resolved in the credential's own
1341
+ * project when it is ambiguous. A project secret always resolves in its
1342
+ * own project and ignores `project_id`.
1198
1343
  * @summary Get schema by ID
1199
1344
  */
1200
1345
  const getSchemaById = async (id, params, options) => {
@@ -1208,25 +1353,32 @@ const getCreateFlowDefinitionUrl = () => {
1208
1353
  };
1209
1354
  /**
1210
1355
  * Publishes a new flow definition revision.
1211
- Flow definitions are templates that define the sequence of steps (capabilities)
1212
- for a particular user journey (e.g., registration, login, password reset).
1213
-
1214
- Flow definitions are created based on the flow definition schema, which includes the flow's purpose, audience, and the steps involved.
1215
-
1216
- Every call allocates a new opaque id. Revisions of one flow share its
1217
- `name`; posting a definition under an existing `name` publishes a new
1218
- revision of that flow, it is not a conflict. List with `name` to see a
1219
- flow's revisions, newest by creation time first.
1220
-
1356
+ * Flow definitions are templates that define the sequence of steps (capabilities)
1357
+ * for a particular user journey (e.g., registration, login, password reset).
1358
+ *
1359
+ * Flow definitions are created based on the flow definition schema, which includes the flow's purpose, audience, and the steps involved.
1360
+ *
1361
+ * Every call allocates a new opaque id. Revisions of one flow share its
1362
+ * `name`; posting a definition under an existing `name` publishes a new
1363
+ * revision of that flow, it is not a conflict. List with `name` to see a
1364
+ * flow's revisions, newest by creation time first.
1221
1365
  * @summary Create a new flow definition
1222
1366
  */
1223
1367
  const createFlowDefinition = async (createFlowDefinitionBody, options) => {
1368
+ const getHeaders = (h) => {
1369
+ if (!h) return {};
1370
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1371
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1372
+ const headers = {};
1373
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1374
+ return headers;
1375
+ };
1224
1376
  return customFetch(getCreateFlowDefinitionUrl(), {
1225
1377
  ...options,
1226
1378
  method: "POST",
1227
1379
  headers: {
1228
1380
  "Content-Type": "application/json",
1229
- ...options?.headers
1381
+ ...getHeaders(options?.headers)
1230
1382
  },
1231
1383
  body: JSON.stringify(createFlowDefinitionBody)
1232
1384
  });
@@ -1234,16 +1386,21 @@ const createFlowDefinition = async (createFlowDefinitionBody, options) => {
1234
1386
  const getListFlowDefinitionsUrl = (params) => {
1235
1387
  const normalizedParams = new URLSearchParams();
1236
1388
  Object.entries(params || {}).forEach(([key, value]) => {
1237
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1389
+ if (Array.isArray(value) && ["expand"].includes(key)) {
1390
+ value.forEach((v) => {
1391
+ normalizedParams.append(key, v === null ? "null" : String(v));
1392
+ });
1393
+ return;
1394
+ }
1395
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1238
1396
  });
1239
1397
  const stringifiedParams = normalizedParams.toString();
1240
1398
  return stringifiedParams.length > 0 ? `${getProxyPath()}/flow_definitions?${stringifiedParams}` : `${getProxyPath()}/flow_definitions`;
1241
1399
  };
1242
1400
  /**
1243
1401
  * Retrieves a list of all flow definitions, newest by creation time first.
1244
- This endpoint can be used to view existing flow definitions and their configurations.
1245
- Filter by `name` to list the revisions of one flow.
1246
-
1402
+ * This endpoint can be used to view existing flow definitions and their configurations.
1403
+ * Filter by `name` to list the revisions of one flow.
1247
1404
  * @summary List flow definitions
1248
1405
  */
1249
1406
  const listFlowDefinitions = async (params, options) => {
@@ -1253,7 +1410,7 @@ const listFlowDefinitions = async (params, options) => {
1253
1410
  });
1254
1411
  };
1255
1412
  const getGetFlowDefinitionUrl = (id) => {
1256
- return `${getProxyPath()}/flow_definitions/${id}`;
1413
+ return `${getProxyPath()}/flow_definitions/${encodeURIComponent(String(id))}`;
1257
1414
  };
1258
1415
  /**
1259
1416
  * Get a flow definition by id
@@ -1268,7 +1425,7 @@ const getFlowDefinition = async (id, options) => {
1268
1425
  const getCreateTeamUrl = (params) => {
1269
1426
  const normalizedParams = new URLSearchParams();
1270
1427
  Object.entries(params || {}).forEach(([key, value]) => {
1271
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1428
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1272
1429
  });
1273
1430
  const stringifiedParams = normalizedParams.toString();
1274
1431
  return stringifiedParams.length > 0 ? `${getProxyPath()}/teams?${stringifiedParams}` : `${getProxyPath()}/teams`;
@@ -1277,12 +1434,20 @@ const getCreateTeamUrl = (params) => {
1277
1434
  * @summary Create team
1278
1435
  */
1279
1436
  const createTeam = async (createTeamBody, params, options) => {
1437
+ const getHeaders = (h) => {
1438
+ if (!h) return {};
1439
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1440
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1441
+ const headers = {};
1442
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1443
+ return headers;
1444
+ };
1280
1445
  return customFetch(getCreateTeamUrl(params), {
1281
1446
  ...options,
1282
1447
  method: "POST",
1283
1448
  headers: {
1284
1449
  "Content-Type": "application/json",
1285
- ...options?.headers
1450
+ ...getHeaders(options?.headers)
1286
1451
  },
1287
1452
  body: JSON.stringify(createTeamBody)
1288
1453
  });
@@ -1290,33 +1455,39 @@ const createTeam = async (createTeamBody, params, options) => {
1290
1455
  const getQueryTeamsUrl = (params) => {
1291
1456
  const normalizedParams = new URLSearchParams();
1292
1457
  Object.entries(params || {}).forEach(([key, value]) => {
1293
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1458
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1294
1459
  });
1295
1460
  const stringifiedParams = normalizedParams.toString();
1296
1461
  return stringifiedParams.length > 0 ? `${getProxyPath()}/teams/query?${stringifiedParams}` : `${getProxyPath()}/teams/query`;
1297
1462
  };
1298
1463
  /**
1299
1464
  * Returns the teams of a project, paginated with a cursor.
1300
-
1301
1465
  * @summary Query teams
1302
1466
  */
1303
1467
  const queryTeams = async (queryTeamsBody, params, options) => {
1468
+ const getHeaders = (h) => {
1469
+ if (!h) return {};
1470
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1471
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1472
+ const headers = {};
1473
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1474
+ return headers;
1475
+ };
1304
1476
  return customFetch(getQueryTeamsUrl(params), {
1305
1477
  ...options,
1306
1478
  method: "POST",
1307
1479
  headers: {
1308
1480
  "Content-Type": "application/json",
1309
- ...options?.headers
1481
+ ...getHeaders(options?.headers)
1310
1482
  },
1311
1483
  body: JSON.stringify(queryTeamsBody)
1312
1484
  });
1313
1485
  };
1314
1486
  const getGetTeamUrl = (teamId) => {
1315
- return `${getProxyPath()}/teams/${teamId}`;
1487
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1316
1488
  };
1317
1489
  /**
1318
1490
  * Returns a Team by its id.
1319
-
1320
1491
  * @summary Get team
1321
1492
  */
1322
1493
  const getTeam = async (teamId, options) => {
@@ -1326,23 +1497,22 @@ const getTeam = async (teamId, options) => {
1326
1497
  });
1327
1498
  };
1328
1499
  const getDeleteTeamUrl = (teamId) => {
1329
- return `${getProxyPath()}/teams/${teamId}`;
1500
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1330
1501
  };
1331
1502
  /**
1332
1503
  * Deactivates the team.
1333
-
1334
- The team is tombstoned rather than erased: it stays readable through
1335
- getTeam with status `deactivated`. Its memberships are removed and the
1336
- users whose lifecycle it owns are deactivated with it.
1337
-
1338
- The request is idempotent. Deleting a team that is already deactivated
1339
- or doesn't exist succeeds without changing anything.
1340
-
1341
- A team that still owns a project is refused with `409
1342
- team.owns_project`: deactivating it would leave the project owned by a
1343
- dead team and so unmanageable. No endpoint releases that ownership yet,
1344
- so such a team cannot currently be deactivated through the API.
1345
-
1504
+ *
1505
+ * The team is tombstoned rather than erased: it stays readable through
1506
+ * getTeam with status `deactivated`. Its memberships are removed and the
1507
+ * users whose lifecycle it owns are deactivated with it.
1508
+ *
1509
+ * The request is idempotent. Deleting a team that is already deactivated
1510
+ * or doesn't exist succeeds without changing anything.
1511
+ *
1512
+ * A team that still owns a project is refused with `409
1513
+ * team.owns_project`: deactivating it would leave the project owned by a
1514
+ * dead team and so unmanageable. No endpoint releases that ownership yet,
1515
+ * so such a team cannot currently be deactivated through the API.
1346
1516
  * @summary Delete team
1347
1517
  */
1348
1518
  const deleteTeam = async (teamId, options) => {
@@ -1352,20 +1522,27 @@ const deleteTeam = async (teamId, options) => {
1352
1522
  });
1353
1523
  };
1354
1524
  const getUpdateTeamUrl = (teamId) => {
1355
- return `${getProxyPath()}/teams/${teamId}`;
1525
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1356
1526
  };
1357
1527
  /**
1358
1528
  * Update team. Only active teams can be updated.
1359
-
1360
1529
  * @summary Update team
1361
1530
  */
1362
1531
  const updateTeam = async (teamId, updateTeamBody, options) => {
1532
+ const getHeaders = (h) => {
1533
+ if (!h) return {};
1534
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1535
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1536
+ const headers = {};
1537
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1538
+ return headers;
1539
+ };
1363
1540
  return customFetch(getUpdateTeamUrl(teamId), {
1364
1541
  ...options,
1365
1542
  method: "PATCH",
1366
1543
  headers: {
1367
1544
  "Content-Type": "application/json",
1368
- ...options?.headers
1545
+ ...getHeaders(options?.headers)
1369
1546
  },
1370
1547
  body: JSON.stringify(updateTeamBody)
1371
1548
  });
@@ -1373,14 +1550,13 @@ const updateTeam = async (teamId, updateTeamBody, options) => {
1373
1550
  const getListEnvironmentsUrl = (params) => {
1374
1551
  const normalizedParams = new URLSearchParams();
1375
1552
  Object.entries(params || {}).forEach(([key, value]) => {
1376
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1553
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1377
1554
  });
1378
1555
  const stringifiedParams = normalizedParams.toString();
1379
1556
  return stringifiedParams.length > 0 ? `${getProxyPath()}/environments?${stringifiedParams}` : `${getProxyPath()}/environments`;
1380
1557
  };
1381
1558
  /**
1382
1559
  * Lists the project's environments ordered by name.
1383
-
1384
1560
  * @summary List environments
1385
1561
  */
1386
1562
  const listEnvironments = async (params, options) => {
@@ -1392,17 +1568,16 @@ const listEnvironments = async (params, options) => {
1392
1568
  const getGetEnvironmentByNameUrl = (name, params) => {
1393
1569
  const normalizedParams = new URLSearchParams();
1394
1570
  Object.entries(params || {}).forEach(([key, value]) => {
1395
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1571
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1396
1572
  });
1397
1573
  const stringifiedParams = normalizedParams.toString();
1398
- return stringifiedParams.length > 0 ? `${getProxyPath()}/environments/${name}?${stringifiedParams}` : `${getProxyPath()}/environments/${name}`;
1574
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/environments/${encodeURIComponent(String(name))}?${stringifiedParams}` : `${getProxyPath()}/environments/${encodeURIComponent(String(name))}`;
1399
1575
  };
1400
1576
  /**
1401
1577
  * Reads one environment of the project by its name.
1402
-
1403
- The lookup is scoped to the project in `project_id`: a name that exists in
1404
- another project answers `env.not_found` exactly as an unused name does.
1405
-
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.
1406
1581
  * @summary Get an environment by name
1407
1582
  */
1408
1583
  const getEnvironmentByName = async (name, params, options) => {
@@ -1414,30 +1589,37 @@ const getEnvironmentByName = async (name, params, options) => {
1414
1589
  const getCreateBrandingUrl = (params) => {
1415
1590
  const normalizedParams = new URLSearchParams();
1416
1591
  Object.entries(params || {}).forEach(([key, value]) => {
1417
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1592
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1418
1593
  });
1419
1594
  const stringifiedParams = normalizedParams.toString();
1420
1595
  return stringifiedParams.length > 0 ? `${getProxyPath()}/branding?${stringifiedParams}` : `${getProxyPath()}/branding`;
1421
1596
  };
1422
1597
  /**
1423
1598
  * Publishes a new immutable branding revision for the project. Branding
1424
- revisions cannot be updated or deleted; every edit publishes a new
1425
- revision, and flow responses resolve the latest revision per project.
1426
-
1427
- The `liquid_template` is validated lexically on save (size, encoding,
1428
- banned patterns such as `<script>` tags, inline event handlers, and the
1429
- `| raw` filter). Authoritative LiquidJS validation runs at authoring
1430
- time via `zitadel plan` / `zitadel apply`.
1431
-
1599
+ * revisions cannot be updated or deleted; every edit publishes a new
1600
+ * revision, and flow responses resolve the latest revision per project.
1601
+ *
1602
+ * The `liquid_template` is validated lexically on save (size, encoding,
1603
+ * banned patterns such as `<script>` tags, inline event handlers, and the
1604
+ * `| raw` filter). Authoritative LiquidJS validation runs at authoring
1605
+ * time via `zitadel plan` / `zitadel apply`.
1432
1606
  * @summary Publish a new branding revision
1433
1607
  */
1434
1608
  const createBranding = async (createBrandingBody, params, options) => {
1609
+ const getHeaders = (h) => {
1610
+ if (!h) return {};
1611
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1612
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1613
+ const headers = {};
1614
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1615
+ return headers;
1616
+ };
1435
1617
  return customFetch(getCreateBrandingUrl(params), {
1436
1618
  ...options,
1437
1619
  method: "POST",
1438
1620
  headers: {
1439
1621
  "Content-Type": "application/json",
1440
- ...options?.headers
1622
+ ...getHeaders(options?.headers)
1441
1623
  },
1442
1624
  body: JSON.stringify(createBrandingBody)
1443
1625
  });
@@ -1445,18 +1627,17 @@ const createBranding = async (createBrandingBody, params, options) => {
1445
1627
  const getListBrandingUrl = (params) => {
1446
1628
  const normalizedParams = new URLSearchParams();
1447
1629
  Object.entries(params || {}).forEach(([key, value]) => {
1448
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1630
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1449
1631
  });
1450
1632
  const stringifiedParams = normalizedParams.toString();
1451
1633
  return stringifiedParams.length > 0 ? `${getProxyPath()}/branding?${stringifiedParams}` : `${getProxyPath()}/branding`;
1452
1634
  };
1453
1635
  /**
1454
1636
  * Lists branding revisions for the project, newest first, capped at the
1455
- 100 most recent. The first entry is the revision flow responses
1456
- currently resolve. Deliberately unpaginated in v1 — list endpoints gain a
1457
- real query mechanism together; advertising pagination parameters the
1458
- server ignores would be worse than none.
1459
-
1637
+ * 100 most recent. The first entry is the revision flow responses
1638
+ * currently resolve. Deliberately unpaginated in v1 — list endpoints gain a
1639
+ * real query mechanism together; advertising pagination parameters the
1640
+ * server ignores would be worse than none.
1460
1641
  * @summary List branding revisions
1461
1642
  */
1462
1643
  const listBranding = async (params, options) => {
@@ -1466,7 +1647,7 @@ const listBranding = async (params, options) => {
1466
1647
  });
1467
1648
  };
1468
1649
  const getGetBrandingByIdUrl = (id) => {
1469
- return `${getProxyPath()}/branding/${id}`;
1650
+ return `${getProxyPath()}/branding/${encodeURIComponent(String(id))}`;
1470
1651
  };
1471
1652
  /**
1472
1653
  * Retrieves a single branding revision, including its stored configuration.
@@ -1481,44 +1662,51 @@ const getBrandingById = async (id, options) => {
1481
1662
  const getCreateIdpUrl = (params) => {
1482
1663
  const normalizedParams = new URLSearchParams();
1483
1664
  Object.entries(params || {}).forEach(([key, value]) => {
1484
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1665
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1485
1666
  });
1486
1667
  const stringifiedParams = normalizedParams.toString();
1487
1668
  return stringifiedParams.length > 0 ? `${getProxyPath()}/idps?${stringifiedParams}` : `${getProxyPath()}/idps`;
1488
1669
  };
1489
1670
  /**
1490
1671
  * Creates or revises a connection document. If the slug does not already
1491
- exist, a new connection is created. If a connection with that slug already
1492
- exists, a revision is created.
1493
-
1494
- A revision gets a new `revision_id` and does not modify the connection
1495
- `id`, so identity links that reference the connection keep resolving while
1496
- releases and auth attempts stay pinned to the revision they captured.
1497
-
1498
- Identity fields are fixed for the life of the connection and a revision
1499
- that changes one is rejected: `protocol`, `subject_claim`, and the
1500
- endpoints that name the authority (`issuer` for OIDC, `token_endpoint`
1501
- and `userinfo_endpoint` for OAuth 2.0). Their values decide which provider
1502
- account a stored subject belongs to, so changing one would silently
1503
- repoint existing identities at a different provider.
1504
-
1505
- `subject_claim` is optional for OIDC and required for OAuth 2.0. For an
1506
- OIDC connection, `sub` is used as the default value. If a revision updates
1507
- `subject_claim` to a different value than the one set during creation, the
1508
- request is rejected.
1509
-
1510
- The document is validated against the `idp-connection.json` schema before
1511
- anything is stored.
1512
-
1672
+ * exist, a new connection is created. If a connection with that slug already
1673
+ * exists, a revision is created.
1674
+ *
1675
+ * A revision gets a new `revision_id` and does not modify the connection
1676
+ * `id`, so identity links that reference the connection keep resolving while
1677
+ * releases and auth attempts stay pinned to the revision they captured.
1678
+ *
1679
+ * 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
1683
+ * account a stored subject belongs to, so changing one would silently
1684
+ * repoint existing identities at a different provider.
1685
+ *
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.
1690
+ *
1691
+ * The document is validated against the `idp-connection.json` schema before
1692
+ * anything is stored.
1513
1693
  * @summary Create or revise an identity provider connection
1514
1694
  */
1515
1695
  const createIdp = async (createIdpBody, params, options) => {
1696
+ const getHeaders = (h) => {
1697
+ if (!h) return {};
1698
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1699
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1700
+ const headers = {};
1701
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1702
+ return headers;
1703
+ };
1516
1704
  return customFetch(getCreateIdpUrl(params), {
1517
1705
  ...options,
1518
1706
  method: "POST",
1519
1707
  headers: {
1520
1708
  "Content-Type": "application/json",
1521
- ...options?.headers
1709
+ ...getHeaders(options?.headers)
1522
1710
  },
1523
1711
  body: JSON.stringify(createIdpBody)
1524
1712
  });
@@ -1526,24 +1714,31 @@ const createIdp = async (createIdpBody, params, options) => {
1526
1714
  const getQueryIdpsUrl = (params) => {
1527
1715
  const normalizedParams = new URLSearchParams();
1528
1716
  Object.entries(params || {}).forEach(([key, value]) => {
1529
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1717
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1530
1718
  });
1531
1719
  const stringifiedParams = normalizedParams.toString();
1532
1720
  return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/query?${stringifiedParams}` : `${getProxyPath()}/idps/query`;
1533
1721
  };
1534
1722
  /**
1535
1723
  * Returns the identity provider connections of a project, paginated with a
1536
- cursor. One row per connection, carrying its newest revision.
1537
-
1724
+ * cursor. One row per connection, carrying its newest revision.
1538
1725
  * @summary Query identity provider connections
1539
1726
  */
1540
1727
  const queryIdps = async (queryIdpsBody, params, options) => {
1728
+ const getHeaders = (h) => {
1729
+ if (!h) return {};
1730
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1731
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1732
+ const headers = {};
1733
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1734
+ return headers;
1735
+ };
1541
1736
  return customFetch(getQueryIdpsUrl(params), {
1542
1737
  ...options,
1543
1738
  method: "POST",
1544
1739
  headers: {
1545
1740
  "Content-Type": "application/json",
1546
- ...options?.headers
1741
+ ...getHeaders(options?.headers)
1547
1742
  },
1548
1743
  body: JSON.stringify(queryIdpsBody)
1549
1744
  });
@@ -1551,17 +1746,16 @@ const queryIdps = async (queryIdpsBody, params, options) => {
1551
1746
  const getGetIdpByIdUrl = (id, params) => {
1552
1747
  const normalizedParams = new URLSearchParams();
1553
1748
  Object.entries(params || {}).forEach(([key, value]) => {
1554
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1749
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1555
1750
  });
1556
1751
  const stringifiedParams = normalizedParams.toString();
1557
- return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${id}?${stringifiedParams}` : `${getProxyPath()}/idps/${id}`;
1752
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/idps/${encodeURIComponent(String(id))}`;
1558
1753
  };
1559
1754
  /**
1560
1755
  * Reads a connection by its id, at its newest revision.
1561
- `GET /idps/{id}/revisions` lists every revision of the connection.
1562
-
1563
- The lookup is scoped to the project in `project_id`.
1564
-
1756
+ * `GET /idps/{id}/revisions` lists every revision of the connection.
1757
+ *
1758
+ * The lookup is scoped to the project in `project_id`.
1565
1759
  * @summary Get an identity provider connection by id
1566
1760
  */
1567
1761
  const getIdpById = async (id, params, options) => {
@@ -1573,17 +1767,16 @@ const getIdpById = async (id, params, options) => {
1573
1767
  const getListIdpRevisionsUrl = (id, params) => {
1574
1768
  const normalizedParams = new URLSearchParams();
1575
1769
  Object.entries(params || {}).forEach(([key, value]) => {
1576
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1770
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1577
1771
  });
1578
1772
  const stringifiedParams = normalizedParams.toString();
1579
- return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${id}/revisions?${stringifiedParams}` : `${getProxyPath()}/idps/${id}/revisions`;
1773
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${encodeURIComponent(String(id))}/revisions?${stringifiedParams}` : `${getProxyPath()}/idps/${encodeURIComponent(String(id))}/revisions`;
1580
1774
  };
1581
1775
  /**
1582
1776
  * Returns every revision of one connection, newest first, paginated with a
1583
- cursor. The order is fixed, so there is no `sorting`.
1584
-
1585
- The lookup is scoped to the project in `project_id`.
1586
-
1777
+ * cursor. The order is fixed, so there is no `sorting`.
1778
+ *
1779
+ * The lookup is scoped to the project in `project_id`.
1587
1780
  * @summary List the revisions of an identity provider connection
1588
1781
  */
1589
1782
  const listIdpRevisions = async (id, params, options) => {
@@ -1595,17 +1788,16 @@ const listIdpRevisions = async (id, params, options) => {
1595
1788
  const getGetIdpRevisionByIdUrl = (revisionId, params) => {
1596
1789
  const normalizedParams = new URLSearchParams();
1597
1790
  Object.entries(params || {}).forEach(([key, value]) => {
1598
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1791
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1599
1792
  });
1600
1793
  const stringifiedParams = normalizedParams.toString();
1601
- return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/revisions/${revisionId}?${stringifiedParams}` : `${getProxyPath()}/idps/revisions/${revisionId}`;
1794
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/revisions/${encodeURIComponent(String(revisionId))}?${stringifiedParams}` : `${getProxyPath()}/idps/revisions/${encodeURIComponent(String(revisionId))}`;
1602
1795
  };
1603
1796
  /**
1604
1797
  * Reads one revision of a connection by its `revision_id`, the value an auth
1605
- attempt or a release pins.
1606
-
1607
- The lookup is scoped to the project in `project_id`.
1608
-
1798
+ * attempt or a release pins.
1799
+ *
1800
+ * The lookup is scoped to the project in `project_id`.
1609
1801
  * @summary Get one revision of an identity provider connection
1610
1802
  */
1611
1803
  const getIdpRevisionById = async (revisionId, params, options) => {
@@ -1617,37 +1809,44 @@ const getIdpRevisionById = async (revisionId, params, options) => {
1617
1809
  const getCreateReleaseUrl = (params) => {
1618
1810
  const normalizedParams = new URLSearchParams();
1619
1811
  Object.entries(params || {}).forEach(([key, value]) => {
1620
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1812
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1621
1813
  });
1622
1814
  const stringifiedParams = normalizedParams.toString();
1623
1815
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases?${stringifiedParams}` : `${getProxyPath()}/releases`;
1624
1816
  };
1625
1817
  /**
1626
1818
  * Bundles a release from revisions that already exist, supplied as
1627
- `(kind, revision_id)` pairs. No new revisions are allocated — use the
1628
- per-kind create endpoints for that, then pin the ids here.
1629
-
1630
- Every referenced `revision_id` must exist in the project. Each one's handle
1631
- is read from the revision itself and recorded on the release, so a resource
1632
- is always pinned under the identity it declares.
1633
-
1634
- Creating a release does not deploy it. A release is environment-agnostic
1635
- and the same release can later be deployed to any number of environments
1636
- unchanged.
1637
-
1638
- Idempotent on the pinned set: metadata is excluded from the comparison, so
1639
- re-submitting the same revisions with a different `message` returns the
1640
- release that already pins them rather than creating a second one.
1641
-
1819
+ * `(kind, revision_id)` pairs. No new revisions are allocated — use the
1820
+ * per-kind create endpoints for that, then pin the ids here.
1821
+ *
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.
1825
+ *
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.
1829
+ *
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.
1642
1833
  * @summary Create a release
1643
1834
  */
1644
1835
  const createRelease = async (createReleaseBody, params, options) => {
1836
+ const getHeaders = (h) => {
1837
+ if (!h) return {};
1838
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1839
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1840
+ const headers = {};
1841
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1842
+ return headers;
1843
+ };
1645
1844
  return customFetch(getCreateReleaseUrl(params), {
1646
1845
  ...options,
1647
1846
  method: "POST",
1648
1847
  headers: {
1649
1848
  "Content-Type": "application/json",
1650
- ...options?.headers
1849
+ ...getHeaders(options?.headers)
1651
1850
  },
1652
1851
  body: JSON.stringify(createReleaseBody)
1653
1852
  });
@@ -1655,17 +1854,16 @@ const createRelease = async (createReleaseBody, params, options) => {
1655
1854
  const getListReleasesUrl = (params) => {
1656
1855
  const normalizedParams = new URLSearchParams();
1657
1856
  Object.entries(params || {}).forEach(([key, value]) => {
1658
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1857
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1659
1858
  });
1660
1859
  const stringifiedParams = normalizedParams.toString();
1661
1860
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases?${stringifiedParams}` : `${getProxyPath()}/releases`;
1662
1861
  };
1663
1862
  /**
1664
1863
  * Lists the project's releases, newest first.
1665
-
1666
- Entries carry metadata only — the pinned set is omitted. Read one release
1667
- with `GET /releases/{release_id}` to get its pointers.
1668
-
1864
+ *
1865
+ * Entries carry metadata only — the pinned set is omitted. Read one release
1866
+ * with `GET /releases/{release_id}` to get its pointers.
1669
1867
  * @summary List releases
1670
1868
  */
1671
1869
  const listReleases = async (params, options) => {
@@ -1677,23 +1875,22 @@ const listReleases = async (params, options) => {
1677
1875
  const getGetReleaseByIdUrl = (releaseId, params) => {
1678
1876
  const normalizedParams = new URLSearchParams();
1679
1877
  Object.entries(params || {}).forEach(([key, value]) => {
1680
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1878
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1681
1879
  });
1682
1880
  const stringifiedParams = normalizedParams.toString();
1683
- return stringifiedParams.length > 0 ? `${getProxyPath()}/releases/${releaseId}?${stringifiedParams}` : `${getProxyPath()}/releases/${releaseId}`;
1881
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}?${stringifiedParams}` : `${getProxyPath()}/releases/${encodeURIComponent(String(releaseId))}`;
1684
1882
  };
1685
1883
  /**
1686
1884
  * Reads one release: its metadata and the `(kind, handle, revision_id)`
1687
- tuples it pins.
1688
-
1689
- Does not embed resource content. Resolve each `revision_id` through the
1690
- per-kind read endpoints when the bytes are needed.
1691
-
1692
- The lookup is scoped to the project in `project_id`: a release id belonging
1693
- to another project answers not found exactly as an unknown id does, so the
1694
- endpoint cannot be used to probe for releases in projects the caller cannot
1695
- read.
1696
-
1885
+ * tuples it pins.
1886
+ *
1887
+ * Does not embed resource content. Resolve each `revision_id` through the
1888
+ * per-kind read endpoints when the bytes are needed.
1889
+ *
1890
+ * The lookup is scoped to the project in `project_id`: a release id belonging
1891
+ * to another project answers not found exactly as an unknown id does, so the
1892
+ * endpoint cannot be used to probe for releases in projects the caller cannot
1893
+ * read.
1697
1894
  * @summary Get a release by id
1698
1895
  */
1699
1896
  const getReleaseById = async (releaseId, params, options) => {
@@ -1705,41 +1902,48 @@ const getReleaseById = async (releaseId, params, options) => {
1705
1902
  const getCreateGrantUrl = (params) => {
1706
1903
  const normalizedParams = new URLSearchParams();
1707
1904
  Object.entries(params || {}).forEach(([key, value]) => {
1708
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1905
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1709
1906
  });
1710
1907
  const stringifiedParams = normalizedParams.toString();
1711
1908
  return stringifiedParams.length > 0 ? `${getProxyPath()}/grants?${stringifiedParams}` : `${getProxyPath()}/grants`;
1712
1909
  };
1713
1910
  /**
1714
1911
  * Bind a user or team to `project.viewer`, `project.editor`, or
1715
- `project.admin` on the project identified by the `project-id` header.
1716
- Name the principal with `user` (`user_id` or `identifier`) or `team`
1717
- (`team_id` or `name`). IDs are `asgn_<opaque>`. Owning-team
1718
- (`project.team`) grants are not created here — claim owns that path. An
1719
- unrevoked grant with the same principal and relation occupies the unique
1720
- key even after `expires_at`; DELETE it before re-creating.
1721
- Create does not accept `expand`. The `user_id` and team locators
1722
- return 201, whose `user` / `team` carry only `user_id` / `team_id`,
1723
- and still 404 / 409 when the principal is missing or the tuple
1724
- already exists. Creating by `user.identifier` answers 202 with no
1725
- body on every outcome. Granting the session caller's own user is
1726
- `grant.invalid` on either user locator. Read the grant back for
1727
- identifier and display.
1728
-
1729
- Accepts either a project secret (`oauth2`) or a user-bound Console
1730
- session cookie (`nextgenSession`). Session callers are authorized as
1731
- the human against the target project (home may differ). CSRF/Origin
1732
- for cookie mutations is a follow-up (#1140).
1733
-
1912
+ * `project.admin` on the project identified by the `project-id` header.
1913
+ * Name the principal with `user` (`user_id` or `identifier`) or `team`
1914
+ * (`team_id` or `name`). IDs are `asgn_<opaque>`. Owning-team
1915
+ * (`project.team`) grants are not created here — claim owns that path. An
1916
+ * unrevoked grant with the same principal and relation occupies the unique
1917
+ * key even after `expires_at`; DELETE it before re-creating.
1918
+ * Create does not accept `expand`. The `user_id` and team locators
1919
+ * return 201, whose `user` / `team` carry only `user_id` / `team_id`,
1920
+ * and still 404 / 409 when the principal is missing or the tuple
1921
+ * already exists. Creating by `user.identifier` answers 202 with no
1922
+ * body on every outcome. Granting the session caller's own user is
1923
+ * `grant.invalid` on either user locator. Read the grant back for
1924
+ * identifier and display.
1925
+ *
1926
+ * Accepts either a project secret (`oauth2`) or a user-bound Console
1927
+ * 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).
1734
1930
  * @summary Create grant
1735
1931
  */
1736
1932
  const createGrant = async (createGrantBody, params, options) => {
1933
+ const getHeaders = (h) => {
1934
+ if (!h) return {};
1935
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1936
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1937
+ const headers = {};
1938
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1939
+ return headers;
1940
+ };
1737
1941
  return customFetch(getCreateGrantUrl(params), {
1738
1942
  ...options,
1739
1943
  method: "POST",
1740
1944
  headers: {
1741
1945
  "Content-Type": "application/json",
1742
- ...options?.headers
1946
+ ...getHeaders(options?.headers)
1743
1947
  },
1744
1948
  body: JSON.stringify(createGrantBody)
1745
1949
  });
@@ -1747,38 +1951,45 @@ const createGrant = async (createGrantBody, params, options) => {
1747
1951
  const getQueryGrantsUrl = (params) => {
1748
1952
  const normalizedParams = new URLSearchParams();
1749
1953
  Object.entries(params || {}).forEach(([key, value]) => {
1750
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1954
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1751
1955
  });
1752
1956
  const stringifiedParams = normalizedParams.toString();
1753
1957
  return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/query?${stringifiedParams}` : `${getProxyPath()}/grants/query`;
1754
1958
  };
1755
1959
  /**
1756
1960
  * Returns the collaboration grants of a project, paginated with a cursor.
1757
- Only unrevoked grants this API manages are listed (user or team bound to
1758
- viewer, editor, or admin), including expired grants so a client can
1759
- DELETE before re-granting. Project-secret setup (`sk_proj`) and
1760
- owning-team (`relation=team`) rows are not returned. Grants are not in
1761
- `resource_scope_index`; project scope is required on the query (same as
1762
- get). Requires `project.read`. `expand: ["principal"]` adds envelope
1763
- fields on `user` / `team` and additionally requires `user.read` and
1764
- `team.read` for project secrets (documented on the expand enum; those
1765
- scopes cannot be ANDed onto this security block because they are
1766
- body-conditional). A user-bound Console session that already passed
1767
- the project Check may expand without those scopes.
1768
-
1769
- Accepts either a project secret (`oauth2`) or a user-bound Console
1770
- session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
1771
- is a follow-up (#1140).
1772
-
1961
+ * Only unrevoked grants this API manages are listed (user or team bound to
1962
+ * viewer, editor, or admin), including expired grants so a client can
1963
+ * DELETE before re-granting. Project-secret setup (`sk_proj`) and
1964
+ * owning-team (`relation=team`) rows are not returned. Grants are not in
1965
+ * `resource_scope_index`; project scope is required on the query (same as
1966
+ * get). Requires `project.read`. `expand: ["principal"]` adds envelope
1967
+ * fields on `user` / `team` and additionally requires `user.read` and
1968
+ * `team.read` for project secrets (documented on the expand enum; those
1969
+ * scopes cannot be ANDed onto this security block because they are
1970
+ * body-conditional). A user-bound Console session that already passed
1971
+ * the project Check may expand without those scopes.
1972
+ *
1973
+ * 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).
1773
1976
  * @summary Query grants
1774
1977
  */
1775
1978
  const queryGrants = async (queryGrantsBody, params, options) => {
1979
+ const getHeaders = (h) => {
1980
+ if (!h) return {};
1981
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1982
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1983
+ const headers = {};
1984
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
1985
+ return headers;
1986
+ };
1776
1987
  return customFetch(getQueryGrantsUrl(params), {
1777
1988
  ...options,
1778
1989
  method: "POST",
1779
1990
  headers: {
1780
1991
  "Content-Type": "application/json",
1781
- ...options?.headers
1992
+ ...getHeaders(options?.headers)
1782
1993
  },
1783
1994
  body: JSON.stringify(queryGrantsBody)
1784
1995
  });
@@ -1786,29 +1997,34 @@ const queryGrants = async (queryGrantsBody, params, options) => {
1786
1997
  const getGetGrantUrl = (id, params) => {
1787
1998
  const normalizedParams = new URLSearchParams();
1788
1999
  Object.entries(params || {}).forEach(([key, value]) => {
1789
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2000
+ if (Array.isArray(value) && ["expand"].includes(key)) {
2001
+ value.forEach((v) => {
2002
+ normalizedParams.append(key, v === null ? "null" : String(v));
2003
+ });
2004
+ return;
2005
+ }
2006
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1790
2007
  });
1791
2008
  const stringifiedParams = normalizedParams.toString();
1792
- return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/${id}?${stringifiedParams}` : `${getProxyPath()}/grants/${id}`;
2009
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/grants/${encodeURIComponent(String(id))}`;
1793
2010
  };
1794
2011
  /**
1795
2012
  * Loads a grant by `(project_id, id)` that this API manages (user or team
1796
- bound to viewer, editor, or admin) and that has not been revoked.
1797
- "Active" here means not revoked: expired grants stay visible so the
1798
- client can DELETE before re-granting the same binding. Authorization
1799
- still ignores expired grants. Grants are not registered in
1800
- `resource_scope_index`; project scope is required on the query (same as
1801
- events). Misses, revoked rows, project-secret setup (`sk_proj`),
1802
- owning-team (`relation=team`) rows, and cross-project ids return 404.
1803
- `expand=principal` adds envelope fields on `user` or `team` and requires
1804
- `user.read` and `team.read` in addition to `project.read` for project
1805
- secrets. A user-bound Console session that already passed the project
1806
- Check may expand without those scopes.
1807
-
1808
- Accepts either a project secret (`oauth2`) or a user-bound Console
1809
- session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
1810
- is a follow-up (#1140).
1811
-
2013
+ * bound to viewer, editor, or admin) and that has not been revoked.
2014
+ * "Active" here means not revoked: expired grants stay visible so the
2015
+ * client can DELETE before re-granting the same binding. Authorization
2016
+ * still ignores expired grants. Grants are not registered in
2017
+ * `resource_scope_index`; project scope is required on the query (same as
2018
+ * events). Misses, revoked rows, project-secret setup (`sk_proj`),
2019
+ * owning-team (`relation=team`) rows, and cross-project ids return 404.
2020
+ * `expand=principal` adds envelope fields on `user` or `team` and requires
2021
+ * `user.read` and `team.read` in addition to `project.read` for project
2022
+ * secrets. A user-bound Console session that already passed the project
2023
+ * Check may expand without those scopes.
2024
+ *
2025
+ * 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).
1812
2028
  * @summary Get grant
1813
2029
  */
1814
2030
  const getGrant = async (id, params, options) => {
@@ -1820,21 +2036,20 @@ const getGrant = async (id, params, options) => {
1820
2036
  const getDeleteGrantUrl = (id, params) => {
1821
2037
  const normalizedParams = new URLSearchParams();
1822
2038
  Object.entries(params || {}).forEach(([key, value]) => {
1823
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2039
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1824
2040
  });
1825
2041
  const stringifiedParams = normalizedParams.toString();
1826
- return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/${id}?${stringifiedParams}` : `${getProxyPath()}/grants/${id}`;
2042
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/grants/${encodeURIComponent(String(id))}`;
1827
2043
  };
1828
2044
  /**
1829
2045
  * Soft-revokes a grant this API manages and emits `authz.revoked`.
1830
- Already-revoked, missing, project-secret setup, and owning-team grants
1831
- return 404. The row is not un-revoked. Expired grants can still be
1832
- revoked so the unique binding can be reused.
1833
-
1834
- Accepts either a project secret (`oauth2`) or a user-bound Console
1835
- session cookie (`nextgenSession`). CSRF/Origin for cookie mutations
1836
- is a follow-up (#1140).
1837
-
2046
+ * Already-revoked, missing, project-secret setup, and owning-team grants
2047
+ * return 404. The row is not un-revoked. Expired grants can still be
2048
+ * revoked so the unique binding can be reused.
2049
+ *
2050
+ * 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).
1838
2053
  * @summary Revoke grant
1839
2054
  */
1840
2055
  const deleteGrant = async (id, params, options) => {
@@ -1848,28 +2063,27 @@ const getListEventsUrl = (params) => {
1848
2063
  Object.entries(params || {}).forEach(([key, value]) => {
1849
2064
  if (Array.isArray(value) && ["category", "event_type"].includes(key)) {
1850
2065
  value.forEach((v) => {
1851
- normalizedParams.append(key, v === null ? "null" : v.toString());
2066
+ normalizedParams.append(key, v === null ? "null" : String(v));
1852
2067
  });
1853
2068
  return;
1854
2069
  }
1855
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2070
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1856
2071
  });
1857
2072
  const stringifiedParams = normalizedParams.toString();
1858
2073
  return stringifiedParams.length > 0 ? `${getProxyPath()}/events?${stringifiedParams}` : `${getProxyPath()}/events`;
1859
2074
  };
1860
2075
  /**
1861
2076
  * Returns project-scoped audit events, newest-first by keyset on
1862
- `(created_at, id)` (ADR 027 / ADR 049). Pass `order=asc` for oldest-first.
1863
- Requires `events.read`.
1864
-
1865
- Pre-claim projects return an empty list (events are stored but not
1866
- visible until claim succeeds). Team-scoped credentials see only events
1867
- whose emit-time `team_id` matches the credential team (enforced when
1868
- team-scoped tokens exist).
1869
-
1870
- Clients discriminate each item via `event_type` (OpenAPI Event oneOf) —
1871
- see docs/design/api/events-catalog.md.
1872
-
2077
+ * `(created_at, id)` (ADR 027 / ADR 049). Pass `order=asc` for oldest-first.
2078
+ * Requires `events.read`.
2079
+ *
2080
+ * Pre-claim projects return an empty list (events are stored but not
2081
+ * visible until claim succeeds). Team-scoped credentials see only events
2082
+ * whose emit-time `team_id` matches the credential team (enforced when
2083
+ * team-scoped tokens exist).
2084
+ *
2085
+ * Clients discriminate each item via `event_type` (OpenAPI Event oneOf) —
2086
+ * see docs/design/api/events-catalog.md.
1873
2087
  * @summary List events
1874
2088
  */
1875
2089
  const listEvents = async (params, options) => {
@@ -1881,18 +2095,17 @@ const listEvents = async (params, options) => {
1881
2095
  const getGetEventUrl = (id, params) => {
1882
2096
  const normalizedParams = new URLSearchParams();
1883
2097
  Object.entries(params || {}).forEach(([key, value]) => {
1884
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2098
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1885
2099
  });
1886
2100
  const stringifiedParams = normalizedParams.toString();
1887
- return stringifiedParams.length > 0 ? `${getProxyPath()}/events/${id}?${stringifiedParams}` : `${getProxyPath()}/events/${id}`;
2101
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/events/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/events/${encodeURIComponent(String(id))}`;
1888
2102
  };
1889
2103
  /**
1890
2104
  * Loads a single event by `(project_id, id)`. Requires `events.read`.
1891
- Events are not registered in `resource_scope_index`; project scope is
1892
- required on the query (ADR 049). Misses and cross-project ids return 404.
1893
-
1894
- Pre-claim projects return 404 (stored events stay invisible until claim).
1895
-
2105
+ * Events are not registered in `resource_scope_index`; project scope is
2106
+ * required on the query (ADR 049). Misses and cross-project ids return 404.
2107
+ *
2108
+ * Pre-claim projects return 404 (stored events stay invisible until claim).
1896
2109
  * @summary Get event by ID
1897
2110
  */
1898
2111
  const getEvent = async (id, params, options) => {
@@ -1904,23 +2117,22 @@ const getEvent = async (id, params, options) => {
1904
2117
  const getGetVariablesUrl = (params) => {
1905
2118
  const normalizedParams = new URLSearchParams();
1906
2119
  Object.entries(params || {}).forEach(([key, value]) => {
1907
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2120
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1908
2121
  });
1909
2122
  const stringifiedParams = normalizedParams.toString();
1910
2123
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
1911
2124
  };
1912
2125
  /**
1913
2126
  * Returns the variables entered at the owner this request addresses, keyed by
1914
- name — one environment of the project with `environment_name`, the project
1915
- level itself without it.
1916
-
1917
- Owners are separate, not a ladder: an environment does not inherit the
1918
- project's variables and the project does not see its environments'. Reading
1919
- everything a project holds therefore means reading each owner in turn.
1920
-
1921
- Secret values are not returned. A secret appears as `{"secret": true}`,
1922
- which says a value is held without disclosing it.
1923
-
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.
2133
+ *
2134
+ * Secret values are not returned. A secret appears as `{"secret": true}`,
2135
+ * which says a value is held without disclosing it.
1924
2136
  * @summary Get variables
1925
2137
  */
1926
2138
  const getVariables = async (params, options) => {
@@ -1932,39 +2144,46 @@ const getVariables = async (params, options) => {
1932
2144
  const getUpdateVariablesUrl = (params) => {
1933
2145
  const normalizedParams = new URLSearchParams();
1934
2146
  Object.entries(params || {}).forEach(([key, value]) => {
1935
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2147
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1936
2148
  });
1937
2149
  const stringifiedParams = normalizedParams.toString();
1938
2150
  return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
1939
2151
  };
1940
2152
  /**
1941
2153
  * Enters, replaces and removes variables at the owner this request
1942
- addresses.
1943
-
1944
- Every name in the body is applied at exactly that owner — the project, or
1945
- the environment named by `environment_name` — and reaches no other. Names
1946
- not in the body are untouched.
1947
-
1948
- A bare scalar enters a non-secret value. `{"value": …, "secret": true}`
1949
- stores the value encrypted under the project's active `secret` key, after
1950
- which it can be referenced but not read back. `null` removes the name from
1951
- this owner (RFC 7386), which is how several variables are removed in one
1952
- request; removing a name this owner does not hold is a no-op rather than an
1953
- error.
1954
-
1955
- The body is applied whole or not at all, so a rejected request leaves the
1956
- owner exactly as it was. Writing the same name and owner twice replaces the
1957
- value rather than duplicating it, which makes a retry safe.
1958
-
2154
+ * addresses.
2155
+ *
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.
2159
+ *
2160
+ * A bare scalar enters a non-secret value. `{"value": …, "secret": true}`
2161
+ * 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.
2166
+ *
2167
+ * 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.
1959
2170
  * @summary Update variables
1960
2171
  */
1961
2172
  const updateVariables = async (updateVariablesBody, params, options) => {
2173
+ const getHeaders = (h) => {
2174
+ if (!h) return {};
2175
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2176
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2177
+ const headers = {};
2178
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2179
+ return headers;
2180
+ };
1962
2181
  return customFetch(getUpdateVariablesUrl(params), {
1963
2182
  ...options,
1964
2183
  method: "PATCH",
1965
2184
  headers: {
1966
2185
  "Content-Type": "application/json",
1967
- ...options?.headers
2186
+ ...getHeaders(options?.headers)
1968
2187
  },
1969
2188
  body: JSON.stringify(updateVariablesBody)
1970
2189
  });
@@ -1972,20 +2191,19 @@ const updateVariables = async (updateVariablesBody, params, options) => {
1972
2191
  const getGetVariableUrl = (variableName, params) => {
1973
2192
  const normalizedParams = new URLSearchParams();
1974
2193
  Object.entries(params || {}).forEach(([key, value]) => {
1975
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2194
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1976
2195
  });
1977
2196
  const stringifiedParams = normalizedParams.toString();
1978
- return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${variableName}?${stringifiedParams}` : `${getProxyPath()}/variables/${variableName}`;
2197
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
1979
2198
  };
1980
2199
  /**
1981
2200
  * Reads one variable by name from the owner this request addresses — one
1982
- environment of the project with `environment_name`, the project level
1983
- itself without it.
1984
-
1985
- A name that owner has not entered answers `var.not_found`, even when
1986
- another owner of the same project holds it: nothing is inherited. A secret
1987
- is found but not disclosed: the response is `{"secret": true}`.
1988
-
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}`.
1989
2207
  * @summary Get a variable
1990
2208
  */
1991
2209
  const getVariable = async (variableName, params, options) => {
@@ -1997,18 +2215,17 @@ const getVariable = async (variableName, params, options) => {
1997
2215
  const getDeleteVariableUrl = (variableName, params) => {
1998
2216
  const normalizedParams = new URLSearchParams();
1999
2217
  Object.entries(params || {}).forEach(([key, value]) => {
2000
- if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
2218
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2001
2219
  });
2002
2220
  const stringifiedParams = normalizedParams.toString();
2003
- return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${variableName}?${stringifiedParams}` : `${getProxyPath()}/variables/${variableName}`;
2221
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
2004
2222
  };
2005
2223
  /**
2006
2224
  * Removes the variable this owner entered under this name.
2007
-
2008
- A variable is deletable only by the owner that entered it. Deleting a name
2009
- another owner of the same project holds answers `var.not_found` and leaves
2010
- that owner's value standing.
2011
-
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.
2012
2229
  * @summary Delete a variable
2013
2230
  */
2014
2231
  const deleteVariable = async (variableName, params, options) => {
@@ -2017,6 +2234,115 @@ const deleteVariable = async (variableName, params, options) => {
2017
2234
  method: "DELETE"
2018
2235
  });
2019
2236
  };
2237
+ const getCreateDeploymentUrl = (params) => {
2238
+ const normalizedParams = new URLSearchParams();
2239
+ Object.entries(params || {}).forEach(([key, value]) => {
2240
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2241
+ });
2242
+ const stringifiedParams = normalizedParams.toString();
2243
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments?${stringifiedParams}` : `${getProxyPath()}/deployments`;
2244
+ };
2245
+ /**
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.
2268
+ * @summary Create a deployment
2269
+ */
2270
+ const createDeployment = async (createDeploymentBody, params, options) => {
2271
+ const getHeaders = (h) => {
2272
+ if (!h) return {};
2273
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
2274
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
2275
+ const headers = {};
2276
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
2277
+ return headers;
2278
+ };
2279
+ return customFetch(getCreateDeploymentUrl(params), {
2280
+ ...options,
2281
+ method: "POST",
2282
+ headers: {
2283
+ "Content-Type": "application/json",
2284
+ ...getHeaders(options?.headers)
2285
+ },
2286
+ body: JSON.stringify(createDeploymentBody)
2287
+ });
2288
+ };
2289
+ const getListDeploymentsUrl = (params) => {
2290
+ const normalizedParams = new URLSearchParams();
2291
+ Object.entries(params || {}).forEach(([key, value]) => {
2292
+ if (Array.isArray(value) && ["expand"].includes(key)) {
2293
+ value.forEach((v) => {
2294
+ normalizedParams.append(key, v === null ? "null" : String(v));
2295
+ });
2296
+ return;
2297
+ }
2298
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2299
+ });
2300
+ const stringifiedParams = normalizedParams.toString();
2301
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments?${stringifiedParams}` : `${getProxyPath()}/deployments`;
2302
+ };
2303
+ /**
2304
+ * Lists deployments newest first: what ran where, and when.
2305
+ *
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.
2310
+ *
2311
+ * `expand: ["release"]` embeds the release each deployment made live, so a
2312
+ * history renders with each entry's content without resolving `release_id`
2313
+ * one by one. Expanding requires `release.read` and does not affect the
2314
+ * ordering or the page tokens.
2315
+ * @summary List deployments
2316
+ */
2317
+ const listDeployments = async (params, options) => {
2318
+ return customFetch(getListDeploymentsUrl(params), {
2319
+ ...options,
2320
+ method: "GET"
2321
+ });
2322
+ };
2323
+ const getGetDeploymentByIdUrl = (deploymentId, params) => {
2324
+ const normalizedParams = new URLSearchParams();
2325
+ Object.entries(params || {}).forEach(([key, value]) => {
2326
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2327
+ });
2328
+ const stringifiedParams = normalizedParams.toString();
2329
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}?${stringifiedParams}` : `${getProxyPath()}/deployments/${encodeURIComponent(String(deploymentId))}`;
2330
+ };
2331
+ /**
2332
+ * Reads one deployment record.
2333
+ *
2334
+ * The lookup is scoped to the project in `project_id`: a deployment id
2335
+ * belonging to another project answers not found exactly as an unknown id
2336
+ * does, so the endpoint cannot be used to probe for deployments in projects
2337
+ * the caller cannot read.
2338
+ * @summary Get a deployment by id
2339
+ */
2340
+ const getDeploymentById = async (deploymentId, params, options) => {
2341
+ return customFetch(getGetDeploymentByIdUrl(deploymentId, params), {
2342
+ ...options,
2343
+ method: "GET"
2344
+ });
2345
+ };
2020
2346
  //#endregion
2021
2347
  //#region ../api/dist/runtime/api-factory.mjs
2022
2348
  /**
@@ -2060,7 +2386,7 @@ function createZitadelClient(opts) {
2060
2386
  } });
2061
2387
  }
2062
2388
  //#endregion
2063
- //#region ../config/dist/defaults-DV6hY2KT.mjs
2389
+ //#region ../config/dist/defaults-BnRHT7RQ.mjs
2064
2390
  var default_human_user_default = {
2065
2391
  title: "DefaultHumanUserSchema",
2066
2392
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -3042,4 +3368,4 @@ Object.defineProperty(exports, "startLocalZitadel", {
3042
3368
  }
3043
3369
  });
3044
3370
 
3045
- //# sourceMappingURL=src-CFX_ayWr.cjs.map
3371
+ //# sourceMappingURL=src-3iEZwMxn.cjs.map