@zitadel/testing 1.0.0-alpha.22 → 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,20 +133,22 @@ 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,
139
140
  createHandoff: () => createHandoff,
141
+ createIdp: () => createIdp,
140
142
  createProject: () => createProject,
141
143
  createRelease: () => createRelease,
142
144
  createSchema: () => createSchema,
143
145
  createSession: () => createSession,
144
146
  createTeam: () => createTeam,
145
147
  createUser: () => createUser,
146
- deleteFlowDefinition: () => deleteFlowDefinition,
147
148
  deleteGrant: () => deleteGrant,
148
149
  deleteTeam: () => deleteTeam,
149
150
  deleteUserByID: () => deleteUserByID,
151
+ deleteVariable: () => deleteVariable,
150
152
  exchangeHandoff: () => exchangeHandoff,
151
153
  finishUserPasskeyRegistration: () => finishUserPasskeyRegistration,
152
154
  getAuthAttempt: () => getAuthAttempt,
@@ -157,20 +159,23 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
157
159
  getCompleteClaimUrl: () => getCompleteClaimUrl,
158
160
  getCreateAuthAttemptUrl: () => getCreateAuthAttemptUrl,
159
161
  getCreateBrandingUrl: () => getCreateBrandingUrl,
162
+ getCreateDeploymentUrl: () => getCreateDeploymentUrl,
160
163
  getCreateFlowDefinitionUrl: () => getCreateFlowDefinitionUrl,
161
164
  getCreateFlowUrl: () => getCreateFlowUrl,
162
165
  getCreateGrantUrl: () => getCreateGrantUrl,
163
166
  getCreateHandoffUrl: () => getCreateHandoffUrl,
167
+ getCreateIdpUrl: () => getCreateIdpUrl,
164
168
  getCreateProjectUrl: () => getCreateProjectUrl,
165
169
  getCreateReleaseUrl: () => getCreateReleaseUrl,
166
170
  getCreateSchemaUrl: () => getCreateSchemaUrl,
167
171
  getCreateSessionUrl: () => getCreateSessionUrl,
168
172
  getCreateTeamUrl: () => getCreateTeamUrl,
169
173
  getCreateUserUrl: () => getCreateUserUrl,
170
- getDeleteFlowDefinitionUrl: () => getDeleteFlowDefinitionUrl,
171
174
  getDeleteGrantUrl: () => getDeleteGrantUrl,
172
175
  getDeleteTeamUrl: () => getDeleteTeamUrl,
173
176
  getDeleteUserByIDUrl: () => getDeleteUserByIDUrl,
177
+ getDeleteVariableUrl: () => getDeleteVariableUrl,
178
+ getDeploymentById: () => getDeploymentById,
174
179
  getEnvironmentByName: () => getEnvironmentByName,
175
180
  getEvent: () => getEvent,
176
181
  getExchangeHandoffUrl: () => getExchangeHandoffUrl,
@@ -181,12 +186,15 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
181
186
  getGetBrandingByIdUrl: () => getGetBrandingByIdUrl,
182
187
  getGetClaimStatusUrl: () => getGetClaimStatusUrl,
183
188
  getGetClaimWindowUrl: () => getGetClaimWindowUrl,
189
+ getGetDeploymentByIdUrl: () => getGetDeploymentByIdUrl,
184
190
  getGetEnvironmentByNameUrl: () => getGetEnvironmentByNameUrl,
185
191
  getGetEventUrl: () => getGetEventUrl,
186
192
  getGetFlowDefinitionUrl: () => getGetFlowDefinitionUrl,
187
193
  getGetFlowStepUrl: () => getGetFlowStepUrl,
188
194
  getGetGrantUrl: () => getGetGrantUrl,
189
195
  getGetHealthUrl: () => getGetHealthUrl,
196
+ getGetIdpByIdUrl: () => getGetIdpByIdUrl,
197
+ getGetIdpRevisionByIdUrl: () => getGetIdpRevisionByIdUrl,
190
198
  getGetLiveUrl: () => getGetLiveUrl,
191
199
  getGetMySessionUrl: () => getGetMySessionUrl,
192
200
  getGetMyUserUrl: () => getGetMyUserUrl,
@@ -197,14 +205,21 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
197
205
  getGetSessionUrl: () => getGetSessionUrl,
198
206
  getGetTeamUrl: () => getGetTeamUrl,
199
207
  getGetUserByIDUrl: () => getGetUserByIDUrl,
208
+ getGetVariableUrl: () => getGetVariableUrl,
209
+ getGetVariablesUrl: () => getGetVariablesUrl,
200
210
  getGrant: () => getGrant,
201
211
  getHealth: () => getHealth,
212
+ getIdpById: () => getIdpById,
213
+ getIdpRevisionById: () => getIdpRevisionById,
202
214
  getInitClaimUrl: () => getInitClaimUrl,
203
215
  getIssueChallengeUrl: () => getIssueChallengeUrl,
204
216
  getListBrandingUrl: () => getListBrandingUrl,
217
+ getListDeploymentsUrl: () => getListDeploymentsUrl,
205
218
  getListEnvironmentsUrl: () => getListEnvironmentsUrl,
206
219
  getListEventsUrl: () => getListEventsUrl,
207
220
  getListFlowDefinitionsUrl: () => getListFlowDefinitionsUrl,
221
+ getListIdpRevisionsUrl: () => getListIdpRevisionsUrl,
222
+ getListMyProjectsUrl: () => getListMyProjectsUrl,
208
223
  getListReleasesUrl: () => getListReleasesUrl,
209
224
  getListSchemasUrl: () => getListSchemasUrl,
210
225
  getListUserPasskeysUrl: () => getListUserPasskeysUrl,
@@ -212,9 +227,12 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
212
227
  getLive: () => getLive,
213
228
  getMySession: () => getMySession,
214
229
  getMyUser: () => getMyUser,
230
+ getPatchMyUserUrl: () => getPatchMyUserUrl,
215
231
  getPatchProjectUrl: () => getPatchProjectUrl,
232
+ getPatchUserByIDUrl: () => getPatchUserByIDUrl,
216
233
  getProject: () => getProject,
217
234
  getQueryGrantsUrl: () => getQueryGrantsUrl,
235
+ getQueryIdpsUrl: () => getQueryIdpsUrl,
218
236
  getQueryProjectsUrl: () => getQueryProjectsUrl,
219
237
  getQuerySessionsUrl: () => getQuerySessionsUrl,
220
238
  getQueryTeamsUrl: () => getQueryTeamsUrl,
@@ -228,22 +246,30 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
228
246
  getSetUserPasswordUrl: () => getSetUserPasswordUrl,
229
247
  getSubmitFlowStepUrl: () => getSubmitFlowStepUrl,
230
248
  getTeam: () => getTeam,
231
- getUpdateFlowDefinitionUrl: () => getUpdateFlowDefinitionUrl,
232
249
  getUpdateTeamUrl: () => getUpdateTeamUrl,
250
+ getUpdateVariablesUrl: () => getUpdateVariablesUrl,
233
251
  getUserByID: () => getUserByID,
252
+ getVariable: () => getVariable,
253
+ getVariables: () => getVariables,
234
254
  getVerifyChallengeProofUrl: () => getVerifyChallengeProofUrl,
235
255
  initClaim: () => initClaim,
236
256
  issueChallenge: () => issueChallenge,
237
257
  listBranding: () => listBranding,
258
+ listDeployments: () => listDeployments,
238
259
  listEnvironments: () => listEnvironments,
239
260
  listEvents: () => listEvents,
240
261
  listFlowDefinitions: () => listFlowDefinitions,
262
+ listIdpRevisions: () => listIdpRevisions,
263
+ listMyProjects: () => listMyProjects,
241
264
  listReleases: () => listReleases,
242
265
  listSchemas: () => listSchemas,
243
266
  listUserPasskeys: () => listUserPasskeys,
244
267
  listUserTeams: () => listUserTeams,
268
+ patchMyUser: () => patchMyUser,
245
269
  patchProject: () => patchProject,
270
+ patchUserByID: () => patchUserByID,
246
271
  queryGrants: () => queryGrants,
272
+ queryIdps: () => queryIdps,
247
273
  queryProjects: () => queryProjects,
248
274
  querySessions: () => querySessions,
249
275
  queryTeams: () => queryTeams,
@@ -252,8 +278,8 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
252
278
  revokeSession: () => revokeSession,
253
279
  setUserPassword: () => setUserPassword,
254
280
  submitFlowStep: () => submitFlowStep,
255
- updateFlowDefinition: () => updateFlowDefinition,
256
281
  updateTeam: () => updateTeam,
282
+ updateVariables: () => updateVariables,
257
283
  verifyChallengeProof: () => verifyChallengeProof
258
284
  });
259
285
  const getGetHealthUrl = () => {
@@ -298,7 +324,7 @@ const getReady = async (options) => {
298
324
  const getCreateUserUrl = (params) => {
299
325
  const normalizedParams = new URLSearchParams();
300
326
  Object.entries(params || {}).forEach(([key, value]) => {
301
- 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));
302
328
  });
303
329
  const stringifiedParams = normalizedParams.toString();
304
330
  return stringifiedParams.length > 0 ? `${getProxyPath()}/users?${stringifiedParams}` : `${getProxyPath()}/users`;
@@ -307,35 +333,58 @@ const getCreateUserUrl = (params) => {
307
333
  * @summary Create user
308
334
  */
309
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
+ };
310
344
  return customFetch(getCreateUserUrl(params), {
311
345
  ...options,
312
346
  method: "POST",
313
347
  headers: {
314
348
  "Content-Type": "application/json",
315
- ...options?.headers
349
+ ...getHeaders(options?.headers)
316
350
  },
317
351
  body: JSON.stringify(createUserBody)
318
352
  });
319
353
  };
320
- const getQueryUsersUrl = () => {
321
- 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`;
322
361
  };
323
362
  /**
324
363
  * Returns the users of a project, paginated with a cursor.
325
-
326
- The project comes from the credential, not from a parameter: the operation
327
- is bound to the token's own project by construction. This is why it takes
328
- no `project_id`, unlike the other query endpoints.
329
-
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).
330
371
  * @summary Query users
331
372
  */
332
- const queryUsers = async (queryUsersBody, options) => {
333
- 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), {
334
383
  ...options,
335
384
  method: "POST",
336
385
  headers: {
337
386
  "Content-Type": "application/json",
338
- ...options?.headers
387
+ ...getHeaders(options?.headers)
339
388
  },
340
389
  body: JSON.stringify(queryUsersBody)
341
390
  });
@@ -343,10 +392,10 @@ const queryUsers = async (queryUsersBody, options) => {
343
392
  const getGetUserByIDUrl = (userId, params) => {
344
393
  const normalizedParams = new URLSearchParams();
345
394
  Object.entries(params || {}).forEach(([key, value]) => {
346
- 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));
347
396
  });
348
397
  const stringifiedParams = normalizedParams.toString();
349
- 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))}`;
350
399
  };
351
400
  /**
352
401
  * @summary Get user by ID
@@ -357,8 +406,37 @@ const getUserByID = async (userId, params, options) => {
357
406
  method: "GET"
358
407
  });
359
408
  };
409
+ const getPatchUserByIDUrl = (userId) => {
410
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
411
+ };
412
+ /**
413
+ * Partially updates a user's schema-defined attributes, and optionally
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.
417
+ * @summary Update user by ID
418
+ */
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
+ };
428
+ return customFetch(getPatchUserByIDUrl(userId), {
429
+ ...options,
430
+ method: "PATCH",
431
+ headers: {
432
+ "Content-Type": "application/json",
433
+ ...getHeaders(options?.headers)
434
+ },
435
+ body: JSON.stringify(patchUserByIDBody)
436
+ });
437
+ };
360
438
  const getDeleteUserByIDUrl = (userId) => {
361
- return `${getProxyPath()}/users/${userId}`;
439
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}`;
362
440
  };
363
441
  /**
364
442
  * @summary Delete user by ID
@@ -372,10 +450,10 @@ const deleteUserByID = async (userId, options) => {
372
450
  const getListUserPasskeysUrl = (userId, params) => {
373
451
  const normalizedParams = new URLSearchParams();
374
452
  Object.entries(params || {}).forEach(([key, value]) => {
375
- 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));
376
454
  });
377
455
  const stringifiedParams = normalizedParams.toString();
378
- 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`;
379
457
  };
380
458
  /**
381
459
  * @summary List user passkeys
@@ -387,65 +465,87 @@ const listUserPasskeys = async (userId, params, options) => {
387
465
  });
388
466
  };
389
467
  const getBeginUserPasskeyRegistrationUrl = (userId) => {
390
- return `${getProxyPath()}/users/${userId}/passkeys/registrations`;
468
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys/registrations`;
391
469
  };
392
470
  /**
393
471
  * Starts a WebAuthn registration ceremony for the user and returns the
394
- creation options for `navigator.credentials.create()`. Complete the
395
- ceremony with `POST /users/{user_id}/passkeys/registrations/{registration_id}` within
396
- five minutes. Credentials already registered for the user are excluded
397
- automatically.
398
-
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.
399
476
  * @summary Begin passkey registration
400
477
  */
401
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
+ };
402
487
  return customFetch(getBeginUserPasskeyRegistrationUrl(userId), {
403
488
  ...options,
404
489
  method: "POST",
405
490
  headers: {
406
491
  "Content-Type": "application/json",
407
- ...options?.headers
492
+ ...getHeaders(options?.headers)
408
493
  },
409
494
  body: JSON.stringify(beginUserPasskeyRegistrationBody)
410
495
  });
411
496
  };
412
497
  const getFinishUserPasskeyRegistrationUrl = (userId, registrationId) => {
413
- return `${getProxyPath()}/users/${userId}/passkeys/registrations/${registrationId}`;
498
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/passkeys/registrations/${encodeURIComponent(String(registrationId))}`;
414
499
  };
415
500
  /**
416
501
  * Verifies the attestation against the ceremony started by
417
- `POST /users/{user_id}/passkeys/registrations` and persists the new credential. A
418
- rejected attestation counts against the ceremony's failure budget and the
419
- ceremony stays open for a retry. An expired ceremony surfaces as
420
- `att.stale_challenge`; an unknown or already-consumed registration id
421
- surfaces as `att.not_found`.
422
-
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`.
423
507
  * @summary Finish passkey registration
424
508
  */
425
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
+ };
426
518
  return customFetch(getFinishUserPasskeyRegistrationUrl(userId, registrationId), {
427
519
  ...options,
428
520
  method: "POST",
429
521
  headers: {
430
522
  "Content-Type": "application/json",
431
- ...options?.headers
523
+ ...getHeaders(options?.headers)
432
524
  },
433
525
  body: JSON.stringify(finishUserPasskeyRegistrationBody)
434
526
  });
435
527
  };
436
528
  const getSetUserPasswordUrl = (userId) => {
437
- return `${getProxyPath()}/users/${userId}/password`;
529
+ return `${getProxyPath()}/users/${encodeURIComponent(String(userId))}/password`;
438
530
  };
439
531
  /**
440
532
  * @summary Set user password
441
533
  */
442
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
+ };
443
543
  return customFetch(getSetUserPasswordUrl(userId), {
444
544
  ...options,
445
545
  method: "PUT",
446
546
  headers: {
447
547
  "Content-Type": "application/json",
448
- ...options?.headers
548
+ ...getHeaders(options?.headers)
449
549
  },
450
550
  body: JSON.stringify(setUserPasswordBody)
451
551
  });
@@ -453,20 +553,19 @@ const setUserPassword = async (userId, setUserPasswordBody, options) => {
453
553
  const getListUserTeamsUrl = (userId, params) => {
454
554
  const normalizedParams = new URLSearchParams();
455
555
  Object.entries(params || {}).forEach(([key, value]) => {
456
- 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));
457
557
  });
458
558
  const stringifiedParams = normalizedParams.toString();
459
- 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`;
460
560
  };
461
561
  /**
462
562
  * The user's team roster, ordered by team name. Each entry carries the
463
- team's name, so a client renders a page without resolving ids one by one.
464
-
465
- This is the N:N roster and it is not lifecycle ownership: the single team
466
- that owns the user's lifecycle is reported as `metadata.lifecycle_owner_team_id`
467
- on the user read endpoints. Memberships the user was removed from are not
468
- returned.
469
-
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.
470
569
  * @summary List the teams a user belongs to
471
570
  */
472
571
  const listUserTeams = async (userId, params, options) => {
@@ -487,42 +586,100 @@ const getMyUser = async (options) => {
487
586
  method: "GET"
488
587
  });
489
588
  };
589
+ const getPatchMyUserUrl = () => {
590
+ return `${getProxyPath()}/users/me`;
591
+ };
592
+ /**
593
+ * Partially updates the caller's own schema-defined attributes. The merged
594
+ * result is validated against the user's schema before commit. Concurrent
595
+ * writes are last-write-wins.
596
+ * @summary Update my user information
597
+ */
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
+ };
607
+ return customFetch(getPatchMyUserUrl(), {
608
+ ...options,
609
+ method: "PATCH",
610
+ headers: {
611
+ "Content-Type": "application/json",
612
+ ...getHeaders(options?.headers)
613
+ },
614
+ body: JSON.stringify(patchMyUserBody)
615
+ });
616
+ };
617
+ const getListMyProjectsUrl = (params) => {
618
+ const normalizedParams = new URLSearchParams();
619
+ Object.entries(params || {}).forEach(([key, value]) => {
620
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
621
+ });
622
+ const stringifiedParams = normalizedParams.toString();
623
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/me/projects?${stringifiedParams}` : `${getProxyPath()}/users/me/projects`;
624
+ };
625
+ /**
626
+ * The projects the signed-in user holds an active grant on, either directly or
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.
633
+ * @summary List the projects I can act on
634
+ */
635
+ const listMyProjects = async (params, options) => {
636
+ return customFetch(getListMyProjectsUrl(params), {
637
+ ...options,
638
+ method: "GET"
639
+ });
640
+ };
490
641
  const getCreateFlowUrl = () => {
491
642
  return `${getProxyPath()}/flow`;
492
643
  };
493
644
  /**
494
645
  * Resolves a flow definition based on purpose + audience context and returns
495
- the first capability step. Creates a new session implicitly unless
496
- `session_id` is provided (for step-up / reauth on an existing session).
497
-
498
- The response contains an `id` field — the flow handle. Use it as the path
499
- parameter for all subsequent `/flow/{id}/submit` calls.
500
-
501
- The response also sets an encrypted `HttpOnly` cookie (`_zflow`) containing
502
- the flow's orchestration state (current step, collected data, history).
503
- The server is stateless between requests — all flow state lives in this
504
- cookie. The browser sends it automatically on subsequent requests.
505
-
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.
506
656
  * @summary Start a new flow
507
657
  */
508
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
+ };
509
667
  return customFetch(getCreateFlowUrl(), {
510
668
  ...options,
511
669
  method: "POST",
512
670
  headers: {
513
671
  "Content-Type": "application/json",
514
- ...options?.headers
672
+ ...getHeaders(options?.headers)
515
673
  },
516
674
  body: JSON.stringify(createFlowBody)
517
675
  });
518
676
  };
519
677
  const getGetFlowStepUrl = (id) => {
520
- return `${getProxyPath()}/flow/${id}`;
678
+ return `${getProxyPath()}/flow/${encodeURIComponent(String(id))}`;
521
679
  };
522
680
  /**
523
681
  * Returns the current capability step without advancing the state machine.
524
- Useful for page reloads or re-rendering after a network error.
525
-
682
+ * Useful for page reloads or re-rendering after a network error.
526
683
  * @summary Get current step (re-render)
527
684
  */
528
685
  const getFlowStep = async (id, options) => {
@@ -532,46 +689,53 @@ const getFlowStep = async (id, options) => {
532
689
  });
533
690
  };
534
691
  const getSubmitFlowStepUrl = (id) => {
535
- return `${getProxyPath()}/flow/${id}/submit`;
692
+ return `${getProxyPath()}/flow/${encodeURIComponent(String(id))}/submit`;
536
693
  };
537
694
  /**
538
695
  * Submits user input for the current step. The server validates,
539
- processes (e.g., verifies a credential), advances the state machine
540
- through any invisible steps, and returns the next visible step.
541
-
542
- The response sets an updated encrypted `HttpOnly` cookie (`_zflow`)
543
- with the new flow state. The server is stateless — all orchestration
544
- state is carried in this cookie between requests.
545
-
546
- **Important:** The `id` in the response may differ from the `id` used in
547
- the request. This happens when a flow pivots (pushes a new flow onto the
548
- stack) or when a stacked flow completes (auto-pops to the parent flow).
549
- Always use the `id` from the latest response for the next request.
550
-
551
- ## Flow completion
552
-
553
- When `step.type` is `complete`, the flow is terminal. The `step.behavior`
554
- field tells the frontend what to do:
555
-
556
- | `behavior` | Action |
557
- |------------- |------------------------------------------------------------|
558
- | `redirect` | Navigate to `redirect_uri` (OIDC/SAML auth request done). |
559
- | `show` | Render the step as a success screen (e.g., registration). |
560
-
561
- A `complete` step is only returned when the **entire flow stack** is done.
562
- If a stacked flow (e.g., recovery pivoted from login) finishes, the server
563
- auto-pops to the parent flow and returns the parent's next step — the
564
- frontend never sees a `complete` for intermediate flows.
565
-
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.
566
722
  * @summary Submit step data and advance
567
723
  */
568
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
+ };
569
733
  return customFetch(getSubmitFlowStepUrl(id), {
570
734
  ...options,
571
735
  method: "POST",
572
736
  headers: {
573
737
  "Content-Type": "application/json",
574
- ...options?.headers
738
+ ...getHeaders(options?.headers)
575
739
  },
576
740
  body: JSON.stringify(submitFlowStepBody)
577
741
  });
@@ -581,38 +745,44 @@ const getCreateAuthAttemptUrl = () => {
581
745
  };
582
746
  /**
583
747
  * Starts a new authentication attempt. This is the entry point for the auth_attempts state machine.
584
-
585
- An attempt is an ephemeral (15-minute TTL) state machine that drives a single authentication round.
586
- It accepts factor challenges, verifies proofs, and completes into a session or handoff token.
587
-
588
- Accepts a project_id and challenge_nonce (from POST /bootstrap/challenge). For step-up re-auth,
589
- also include session_id to add factors to an existing session.
590
-
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.
591
754
  * @summary Create a new authentication attempt
592
755
  */
593
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
+ };
594
765
  return customFetch(getCreateAuthAttemptUrl(), {
595
766
  ...options,
596
767
  method: "POST",
597
768
  headers: {
598
769
  "Content-Type": "application/json",
599
- ...options?.headers
770
+ ...getHeaders(options?.headers)
600
771
  },
601
772
  body: JSON.stringify(createAuthAttemptBody)
602
773
  });
603
774
  };
604
775
  const getGetAuthAttemptUrl = (attemptId) => {
605
- return `${getProxyPath()}/auth_attempts/${attemptId}`;
776
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}`;
606
777
  };
607
778
  /**
608
779
  * Polls the current state of an authentication attempt.
609
-
610
- Returns the attempt's state, available factors for the next challenge,
611
- challenges issued so far, and any errors preventing progress.
612
-
613
- Use this for polling during long-running factor verifications (e.g., waiting for
614
- a federated IdP callback or a device flow).
615
-
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).
616
786
  * @summary Get authentication attempt state
617
787
  */
618
788
  const getAuthAttempt = async (attemptId, options) => {
@@ -622,72 +792,85 @@ const getAuthAttempt = async (attemptId, options) => {
622
792
  });
623
793
  };
624
794
  const getIssueChallengeUrl = (attemptId) => {
625
- return `${getProxyPath()}/auth_attempts/${attemptId}/challenges`;
795
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/challenges`;
626
796
  };
627
797
  /**
628
798
  * Issues a single-factor verification challenge within an auth attempt.
629
-
630
- This advances the authentication state machine by requesting a specific factor method
631
- (password, passkey, TOTP, OTP via SMS, etc.). The server responds with challenge details
632
- including method, metadata, and any UI hints. The client then verifies the proof
633
- by calling POST /auth_attempts/{attempt_id}/challenges/{challenge_id}/verify.
634
-
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.
635
804
  * @summary Issue a factor challenge
636
805
  */
637
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
+ };
638
815
  return customFetch(getIssueChallengeUrl(attemptId), {
639
816
  ...options,
640
817
  method: "POST",
641
818
  headers: {
642
819
  "Content-Type": "application/json",
643
- ...options?.headers
820
+ ...getHeaders(options?.headers)
644
821
  },
645
822
  body: JSON.stringify(issueChallengeBody)
646
823
  });
647
824
  };
648
825
  const getVerifyChallengeProofUrl = (attemptId, challengeId) => {
649
- return `${getProxyPath()}/auth_attempts/${attemptId}/challenges/${challengeId}/verify`;
826
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/challenges/${encodeURIComponent(String(challengeId))}/verify`;
650
827
  };
651
828
  /**
652
829
  * Submits a proof (credential, code, assertion) to verify a factor challenge.
653
-
654
- The proof format depends on the challenge method. For example:
655
- - `password` method: { password: "…" }
656
- - `totp` method: { totp: { code: "123456" } }
657
- - `passkey` method: { passkey: { assertion: "…" } }
658
- - `recovery_code` method: { recovery_code: "…" }
659
-
660
- On successful verification, the factor is written to the auth attempt.
661
- The attempt moves to the next pending challenge or completes if all required factors are verified.
662
-
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.
663
839
  * @summary Verify a factor proof
664
840
  */
665
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
+ };
666
850
  return customFetch(getVerifyChallengeProofUrl(attemptId, challengeId), {
667
851
  ...options,
668
852
  method: "POST",
669
853
  headers: {
670
854
  "Content-Type": "application/json",
671
- ...options?.headers
855
+ ...getHeaders(options?.headers)
672
856
  },
673
857
  body: JSON.stringify(verifyChallengeProofBody)
674
858
  });
675
859
  };
676
860
  const getCreateHandoffUrl = (attemptId) => {
677
- return `${getProxyPath()}/auth_attempts/${attemptId}/handoff`;
861
+ return `${getProxyPath()}/auth_attempts/${encodeURIComponent(String(attemptId))}/handoff`;
678
862
  };
679
863
  /**
680
864
  * Completes the authentication attempt and mints a `handoff_token`.
681
-
682
- Call this after all required factors have been verified and the attempt is in `completed` state.
683
- The handoff token is short-lived (≤60 seconds) and must be exchanged at
684
- POST /sessions/exchange to receive the final session and session_token.
685
-
686
- The handoff token is:
687
- - Single-use (atomic exchange, no retry)
688
- - Audience-bound (requires matching project key for exchange)
689
- - Idempotency-safe within a 5-minute window (see conventions)
690
-
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)
691
874
  * @summary Complete authentication and create handoff token
692
875
  */
693
876
  const createHandoff = async (attemptId, options) => {
@@ -703,12 +886,20 @@ const getCreateProjectUrl = () => {
703
886
  * @summary Create project
704
887
  */
705
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
+ };
706
897
  return customFetch(getCreateProjectUrl(), {
707
898
  ...options,
708
899
  method: "POST",
709
900
  headers: {
710
901
  "Content-Type": "application/json",
711
- ...options?.headers
902
+ ...getHeaders(options?.headers)
712
903
  },
713
904
  body: JSON.stringify(createProjectBody)
714
905
  });
@@ -720,22 +911,29 @@ const getQueryProjectsUrl = () => {
720
911
  * @summary Query projects
721
912
  */
722
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
+ };
723
922
  return customFetch(getQueryProjectsUrl(), {
724
923
  ...options,
725
924
  method: "POST",
726
925
  headers: {
727
926
  "Content-Type": "application/json",
728
- ...options?.headers
927
+ ...getHeaders(options?.headers)
729
928
  },
730
929
  body: JSON.stringify(queryProjectsBody)
731
930
  });
732
931
  };
733
932
  const getGetProjectUrl = (projectId) => {
734
- return `${getProxyPath()}/projects/${projectId}`;
933
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}`;
735
934
  };
736
935
  /**
737
936
  * Returns the current state of a project.
738
-
739
937
  * @summary Get project
740
938
  */
741
939
  const getProject = async (projectId, options) => {
@@ -745,34 +943,40 @@ const getProject = async (projectId, options) => {
745
943
  });
746
944
  };
747
945
  const getPatchProjectUrl = (projectId) => {
748
- return `${getProxyPath()}/projects/${projectId}`;
946
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}`;
749
947
  };
750
948
  /**
751
949
  * Updates the state of a project.
752
-
753
950
  * @summary Update project
754
951
  */
755
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
+ };
756
961
  return customFetch(getPatchProjectUrl(projectId), {
757
962
  ...options,
758
963
  method: "PATCH",
759
964
  headers: {
760
965
  "Content-Type": "application/json",
761
- ...options?.headers
966
+ ...getHeaders(options?.headers)
762
967
  },
763
968
  body: JSON.stringify(patchProjectBody)
764
969
  });
765
970
  };
766
971
  const getInitClaimUrl = (projectId) => {
767
- return `${getProxyPath()}/projects/${projectId}/claim/init`;
972
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/init`;
768
973
  };
769
974
  /**
770
975
  * Starts a claim challenge for an unclaimed project. Authenticated by the
771
- project secret, this mints a single-use, short-lived challenge and returns
772
- the `claim_url` the developer opens in a browser to complete the claim,
773
- together with the `challenge_id` the CLI polls with. The exact expiry is
774
- carried by `expires_at` on the response.
775
-
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.
776
980
  * @summary Initialize a project claim
777
981
  */
778
982
  const initClaim = async (projectId, options) => {
@@ -784,21 +988,20 @@ const initClaim = async (projectId, options) => {
784
988
  const getGetClaimStatusUrl = (projectId, params) => {
785
989
  const normalizedParams = new URLSearchParams();
786
990
  Object.entries(params || {}).forEach(([key, value]) => {
787
- 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));
788
992
  });
789
993
  const stringifiedParams = normalizedParams.toString();
790
- 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`;
791
995
  };
792
996
  /**
793
997
  * Polled by the CLI while a browser completes the claim. Authorized by the
794
- project secret that initiated the challenge. Returns `pending`, or
795
- `completed` with the owning team, the claim timestamp, and the dashboard
796
- URL once the project is claimed. The claim grant, not the polled
797
- challenge, is the source of truth: a project claimed through another
798
- concurrent challenge also reports `completed`, and a completed claim
799
- keeps reporting `completed` past this challenge's expiry and past the
800
- project's claim window.
801
-
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.
802
1005
  * @summary Get claim status
803
1006
  */
804
1007
  const getClaimStatus = async (projectId, params, options) => {
@@ -808,23 +1011,30 @@ const getClaimStatus = async (projectId, params, options) => {
808
1011
  });
809
1012
  };
810
1013
  const getCompleteClaimUrl = (projectId) => {
811
- return `${getProxyPath()}/projects/${projectId}/claim/complete`;
1014
+ return `${getProxyPath()}/projects/${encodeURIComponent(String(projectId))}/claim/complete`;
812
1015
  };
813
1016
  /**
814
1017
  * Called by the browser after the developer authenticates on the claim page.
815
- Authenticated by the `__nextgen_session` cookie, it attaches the project to
816
- the developer's personal team using the `challenge_id` from the claim URL as
817
- its single-use, browser-safe authorization.
818
-
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.
819
1021
  * @summary Complete a project claim
820
1022
  */
821
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
+ };
822
1032
  return customFetch(getCompleteClaimUrl(projectId), {
823
1033
  ...options,
824
1034
  method: "POST",
825
1035
  headers: {
826
1036
  "Content-Type": "application/json",
827
- ...options?.headers
1037
+ ...getHeaders(options?.headers)
828
1038
  },
829
1039
  body: JSON.stringify(completeClaimBody)
830
1040
  });
@@ -832,19 +1042,18 @@ const completeClaim = async (projectId, completeClaimBody, options) => {
832
1042
  const getGetClaimWindowUrl = (projectId, params) => {
833
1043
  const normalizedParams = new URLSearchParams();
834
1044
  Object.entries(params || {}).forEach(([key, value]) => {
835
- 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));
836
1046
  });
837
1047
  const stringifiedParams = normalizedParams.toString();
838
- 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`;
839
1049
  };
840
1050
  /**
841
1051
  * Read by the claim page in the browser to show how long is left to claim the
842
- project. Unauthenticated by design: the claim page runs this before the
843
- developer has signed in, and holding the `challenge_id` from the claim URL
844
- is the authorization — the same capability `claim/complete` accepts. It
845
- reveals only the window, never the project itself, and unlike
846
- `claim/complete` it spends nothing, so a reload is free.
847
-
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.
848
1057
  * @summary Get the claim window for a project
849
1058
  */
850
1059
  const getClaimWindow = async (projectId, params, options) => {
@@ -858,36 +1067,43 @@ const getCreateSessionUrl = () => {
858
1067
  };
859
1068
  /**
860
1069
  * Creates an anonymous session shell with no user and no factors (`state: building`).
861
-
862
- This is optional — an `auth_attempt` will create a session implicitly if none is provided.
863
- Use this explicitly when you want to:
864
- - Pre-allocate a `session_id` before the user is known, so device/telemetry signals
865
- can be correlated with the eventual authenticated session from the start.
866
- - Track anonymous state (bot detection, device fingerprint) that survives until authentication.
867
-
868
- Creating a session is an app-plane operation on the project credential
869
- (`session.write`). The returned `session_token` is a session credential for the
870
- end-user client, not a management scope: it is delivered as the
871
- `__nextgen_session` cookie and authorises the self-service operations
872
- `GET /sessions/me` and `DELETE /sessions/me` (`nextgenSession` scheme). The
873
- by-id operations `GET /sessions/{session_id}` and `DELETE /sessions/{session_id}`
874
- are operator endpoints and require `session.read` / `session.delete` instead.
875
-
876
- The `session_token` is superseded when a handoff exchange completes — clients must
877
- replace it at that point.
878
-
879
- Anonymous sessions expire aggressively (10-minute TTL). The TTL resets to the configured
880
- full session TTL when the first authentication factor is written via a completing `auth_attempt`.
881
-
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`.
882
1090
  * @summary Create an anonymous session shell
883
1091
  */
884
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
+ };
885
1101
  return customFetch(getCreateSessionUrl(), {
886
1102
  ...options,
887
1103
  method: "POST",
888
1104
  headers: {
889
1105
  "Content-Type": "application/json",
890
- ...options?.headers
1106
+ ...getHeaders(options?.headers)
891
1107
  },
892
1108
  body: JSON.stringify(createSessionBody)
893
1109
  });
@@ -895,25 +1111,32 @@ const createSession = async (createSessionBody, options) => {
895
1111
  const getQuerySessionsUrl = (params) => {
896
1112
  const normalizedParams = new URLSearchParams();
897
1113
  Object.entries(params || {}).forEach(([key, value]) => {
898
- 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));
899
1115
  });
900
1116
  const stringifiedParams = normalizedParams.toString();
901
1117
  return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/query?${stringifiedParams}` : `${getProxyPath()}/sessions/query`;
902
1118
  };
903
1119
  /**
904
1120
  * Returns the sessions of a project, paginated with a cursor.
905
- Sessions of every lifecycle state are returned; each carries its `state`.
906
- Requires `session.read` permission.
907
-
1121
+ * Sessions of every lifecycle state are returned; each carries its `state`.
1122
+ * Requires `session.read` permission.
908
1123
  * @summary Query sessions
909
1124
  */
910
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
+ };
911
1134
  return customFetch(getQuerySessionsUrl(params), {
912
1135
  ...options,
913
1136
  method: "POST",
914
1137
  headers: {
915
1138
  "Content-Type": "application/json",
916
- ...options?.headers
1139
+ ...getHeaders(options?.headers)
917
1140
  },
918
1141
  body: JSON.stringify(querySessionsBody)
919
1142
  });
@@ -921,54 +1144,60 @@ const querySessions = async (querySessionsBody, params, options) => {
921
1144
  const getExchangeHandoffUrl = (params) => {
922
1145
  const normalizedParams = new URLSearchParams();
923
1146
  Object.entries(params || {}).forEach(([key, value]) => {
924
- 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));
925
1148
  });
926
1149
  const stringifiedParams = normalizedParams.toString();
927
1150
  return stringifiedParams.length > 0 ? `${getProxyPath()}/sessions/exchange?${stringifiedParams}` : `${getProxyPath()}/sessions/exchange`;
928
1151
  };
929
1152
  /**
930
1153
  * Consumes a one-time `handoff_token` minted by `POST /auth_attempts/{id}/handoff`
931
- and returns the resulting session and a `session_token`.
932
-
933
- The server resolves the originating `auth_attempt` from the token and then:
934
-
935
- | Originating auth_attempt | Outcome |
936
- |---|---|
937
- | No `session_id` | A new authenticated session is **created**. |
938
- | `session_id` points to an anonymous shell | Existing session is **upgraded** — user and factors written in, TTL reset to full session TTL. |
939
- | `session_id` points to an active session (step-up) | Existing session is **upgraded** — new factors merged, `assurance_levels[]` expanded. |
940
-
941
- The response shape is identical in all three cases.
942
-
943
- The `session_token` supersedes any previously issued `session_token` for the same session.
944
- Clients must replace their stored token at this point.
945
-
946
- Requires a project service key (OAuth2 client credentials).
947
-
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).
948
1170
  * @summary Exchange handoff token for a session
949
1171
  */
950
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
+ };
951
1181
  return customFetch(getExchangeHandoffUrl(params), {
952
1182
  ...options,
953
1183
  method: "POST",
954
1184
  headers: {
955
1185
  "Content-Type": "application/json",
956
- ...options?.headers
1186
+ ...getHeaders(options?.headers)
957
1187
  },
958
1188
  body: JSON.stringify(exchangeHandoffBody)
959
1189
  });
960
1190
  };
961
1191
  const getGetSessionUrl = (sessionId) => {
962
- return `${getProxyPath()}/sessions/${sessionId}`;
1192
+ return `${getProxyPath()}/sessions/${encodeURIComponent(String(sessionId))}`;
963
1193
  };
964
1194
  /**
965
1195
  * Returns the current state of a session including its factors and all currently
966
- satisfied assurance levels.
967
-
968
- `assurance_levels[]` may shrink over time as factor freshness windows expire,
969
- without the session itself expiring. Use step-up authentication (a new `auth_attempt`
970
- against the same `session_id`) to restore a dropped assurance level.
971
-
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.
972
1201
  * @summary Get session state
973
1202
  */
974
1203
  const getSession = async (sessionId, options) => {
@@ -978,19 +1207,18 @@ const getSession = async (sessionId, options) => {
978
1207
  });
979
1208
  };
980
1209
  const getRevokeSessionUrl = (sessionId) => {
981
- return `${getProxyPath()}/sessions/${sessionId}`;
1210
+ return `${getProxyPath()}/sessions/${encodeURIComponent(String(sessionId))}`;
982
1211
  };
983
1212
  /**
984
1213
  * Permanently deletes the session, terminating it immediately.
985
-
986
- This is the operator revoke path and requires the `session.delete` scope on a
987
- project-bound credential. End-user logout with the `__nextgen_session` cookie is
988
- `DELETE /sessions/me` (`nextgenSession` scheme).
989
-
990
- Idempotent: deleting a session that does not exist (or was already deleted)
991
- still returns 204. After deletion, any tokens derived from the session are
992
- invalidated.
993
-
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.
994
1222
  * @summary Revoke session
995
1223
  */
996
1224
  const revokeSession = async (sessionId, options) => {
@@ -1004,12 +1232,11 @@ const getGetMySessionUrl = () => {
1004
1232
  };
1005
1233
  /**
1006
1234
  * Returns the current state of the current session including its factors and all currently
1007
- satisfied assurance levels.
1008
-
1009
- `assurance_levels[]` may shrink over time as factor freshness windows expire,
1010
- without the session itself expiring. Use step-up authentication (a new `auth_attempt`
1011
- against the same `session_id`) to restore a dropped assurance level.
1012
-
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.
1013
1240
  * @summary Get my session state
1014
1241
  */
1015
1242
  const getMySession = async (options) => {
@@ -1023,12 +1250,11 @@ const getRevokeMySessionUrl = () => {
1023
1250
  };
1024
1251
  /**
1025
1252
  * Logs out by permanently deleting the session.
1026
-
1027
- The `__nextgen_session` cookie issued at creation (or superseded by a handoff
1028
- exchange) is required. Idempotent: if the session is already gone this still
1029
- returns 204. Any tokens derived from the session are invalidated, and the
1030
- cookie itself is cleared in the response.
1031
-
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.
1032
1258
  * @summary Revoke my session
1033
1259
  */
1034
1260
  const revokeMySession = async (options) => {
@@ -1040,31 +1266,38 @@ const revokeMySession = async (options) => {
1040
1266
  const getCreateSchemaUrl = (params) => {
1041
1267
  const normalizedParams = new URLSearchParams();
1042
1268
  Object.entries(params || {}).forEach(([key, value]) => {
1043
- 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));
1044
1270
  });
1045
1271
  const stringifiedParams = normalizedParams.toString();
1046
1272
  return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas?${stringifiedParams}` : `${getProxyPath()}/schemas`;
1047
1273
  };
1048
1274
  /**
1049
1275
  * Create a new schema. The optional `$id` field is the JSON Schema document
1050
- URI used to identify the schema in future requests (GitOps-stable identity,
1051
- not a free-form resource primary key). When `$id` is omitted, the server
1052
- generates a `sch_*` URL. When provided, `$id` must be unique within the
1053
- project and should ideally be a valid URI pointing at where the schema can
1054
- be accessed.
1055
-
1056
- The schema can either be a concrete schema, e.g. a user schema, or a
1057
- schema-url which will be resolved by the server.
1058
-
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.
1059
1284
  * @summary Create new schema
1060
1285
  */
1061
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
+ };
1062
1295
  return customFetch(getCreateSchemaUrl(params), {
1063
1296
  ...options,
1064
1297
  method: "POST",
1065
1298
  headers: {
1066
1299
  "Content-Type": "application/json",
1067
- ...options?.headers
1300
+ ...getHeaders(options?.headers)
1068
1301
  },
1069
1302
  body: JSON.stringify(createSchemaBody)
1070
1303
  });
@@ -1072,15 +1305,14 @@ const createSchema = async (createSchemaBody, params, options) => {
1072
1305
  const getListSchemasUrl = (params) => {
1073
1306
  const normalizedParams = new URLSearchParams();
1074
1307
  Object.entries(params || {}).forEach(([key, value]) => {
1075
- 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));
1076
1309
  });
1077
1310
  const stringifiedParams = normalizedParams.toString();
1078
1311
  return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas?${stringifiedParams}` : `${getProxyPath()}/schemas`;
1079
1312
  };
1080
1313
  /**
1081
1314
  * Retrieve a list of all schemas available in the system. This endpoint
1082
- supports pagination and filtering based on schema attributes.
1083
-
1315
+ * supports pagination and filtering based on schema attributes.
1084
1316
  * @summary List all schemas
1085
1317
  */
1086
1318
  const listSchemas = async (params, options) => {
@@ -1092,16 +1324,22 @@ const listSchemas = async (params, options) => {
1092
1324
  const getGetSchemaByIdUrl = (id, params) => {
1093
1325
  const normalizedParams = new URLSearchParams();
1094
1326
  Object.entries(params || {}).forEach(([key, value]) => {
1095
- 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));
1096
1328
  });
1097
1329
  const stringifiedParams = normalizedParams.toString();
1098
- 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))}`;
1099
1331
  };
1100
1332
  /**
1101
1333
  * Get a schema by its ID. A schema ID identifies one immutable revision, so
1102
- this returns exactly that revision. To find the current revision of an
1103
- object type, list with `revisions=latest`.
1104
-
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`.
1105
1343
  * @summary Get schema by ID
1106
1344
  */
1107
1345
  const getSchemaById = async (id, params, options) => {
@@ -1115,25 +1353,32 @@ const getCreateFlowDefinitionUrl = () => {
1115
1353
  };
1116
1354
  /**
1117
1355
  * Publishes a new flow definition revision.
1118
- Flow definitions are templates that define the sequence of steps (capabilities)
1119
- for a particular user journey (e.g., registration, login, password reset).
1120
-
1121
- Flow definitions are created based on the flow definition schema, which includes the flow's purpose, audience, and the steps involved.
1122
-
1123
- Every call allocates a new opaque id. Revisions of one flow share its
1124
- `name`; posting a definition under an existing `name` publishes a new
1125
- revision of that flow, it is not a conflict. List with `name` to see a
1126
- flow's revisions, newest by creation time first.
1127
-
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.
1128
1365
  * @summary Create a new flow definition
1129
1366
  */
1130
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
+ };
1131
1376
  return customFetch(getCreateFlowDefinitionUrl(), {
1132
1377
  ...options,
1133
1378
  method: "POST",
1134
1379
  headers: {
1135
1380
  "Content-Type": "application/json",
1136
- ...options?.headers
1381
+ ...getHeaders(options?.headers)
1137
1382
  },
1138
1383
  body: JSON.stringify(createFlowDefinitionBody)
1139
1384
  });
@@ -1141,16 +1386,21 @@ const createFlowDefinition = async (createFlowDefinitionBody, options) => {
1141
1386
  const getListFlowDefinitionsUrl = (params) => {
1142
1387
  const normalizedParams = new URLSearchParams();
1143
1388
  Object.entries(params || {}).forEach(([key, value]) => {
1144
- 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));
1145
1396
  });
1146
1397
  const stringifiedParams = normalizedParams.toString();
1147
1398
  return stringifiedParams.length > 0 ? `${getProxyPath()}/flow_definitions?${stringifiedParams}` : `${getProxyPath()}/flow_definitions`;
1148
1399
  };
1149
1400
  /**
1150
1401
  * Retrieves a list of all flow definitions, newest by creation time first.
1151
- This endpoint can be used to view existing flow definitions and their configurations.
1152
- Filter by `name` to list the revisions of one flow.
1153
-
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.
1154
1404
  * @summary List flow definitions
1155
1405
  */
1156
1406
  const listFlowDefinitions = async (params, options) => {
@@ -1160,7 +1410,7 @@ const listFlowDefinitions = async (params, options) => {
1160
1410
  });
1161
1411
  };
1162
1412
  const getGetFlowDefinitionUrl = (id) => {
1163
- return `${getProxyPath()}/flow_definitions/${id}`;
1413
+ return `${getProxyPath()}/flow_definitions/${encodeURIComponent(String(id))}`;
1164
1414
  };
1165
1415
  /**
1166
1416
  * Get a flow definition by id
@@ -1172,46 +1422,10 @@ const getFlowDefinition = async (id, options) => {
1172
1422
  method: "GET"
1173
1423
  });
1174
1424
  };
1175
- const getUpdateFlowDefinitionUrl = (id) => {
1176
- return `${getProxyPath()}/flow_definitions/${id}`;
1177
- };
1178
- /**
1179
- * Update a flow definition by id. This endpoint replaces the existing flow definition.
1180
- If `flow_definition.status` is omitted, the current status is preserved
1181
-
1182
- * @summary Update a flow definition by id
1183
- */
1184
- const updateFlowDefinition = async (id, updateFlowDefinitionBody, options) => {
1185
- return customFetch(getUpdateFlowDefinitionUrl(id), {
1186
- ...options,
1187
- method: "PUT",
1188
- headers: {
1189
- "Content-Type": "application/json",
1190
- ...options?.headers
1191
- },
1192
- body: JSON.stringify(updateFlowDefinitionBody)
1193
- });
1194
- };
1195
- const getDeleteFlowDefinitionUrl = (id) => {
1196
- return `${getProxyPath()}/flow_definitions/${id}`;
1197
- };
1198
- /**
1199
- * Delete a flow definition by id.
1200
- If the flow definition is currently being used by a flow, the deletion will fail.
1201
- If the flow definition is the last active flow definition for a given purpose, the deletion will fail to prevent disruption of new flows being started for that purpose.
1202
-
1203
- * @summary Delete a flow definition by id
1204
- */
1205
- const deleteFlowDefinition = async (id, options) => {
1206
- return customFetch(getDeleteFlowDefinitionUrl(id), {
1207
- ...options,
1208
- method: "DELETE"
1209
- });
1210
- };
1211
1425
  const getCreateTeamUrl = (params) => {
1212
1426
  const normalizedParams = new URLSearchParams();
1213
1427
  Object.entries(params || {}).forEach(([key, value]) => {
1214
- 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));
1215
1429
  });
1216
1430
  const stringifiedParams = normalizedParams.toString();
1217
1431
  return stringifiedParams.length > 0 ? `${getProxyPath()}/teams?${stringifiedParams}` : `${getProxyPath()}/teams`;
@@ -1220,12 +1434,20 @@ const getCreateTeamUrl = (params) => {
1220
1434
  * @summary Create team
1221
1435
  */
1222
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
+ };
1223
1445
  return customFetch(getCreateTeamUrl(params), {
1224
1446
  ...options,
1225
1447
  method: "POST",
1226
1448
  headers: {
1227
1449
  "Content-Type": "application/json",
1228
- ...options?.headers
1450
+ ...getHeaders(options?.headers)
1229
1451
  },
1230
1452
  body: JSON.stringify(createTeamBody)
1231
1453
  });
@@ -1233,33 +1455,39 @@ const createTeam = async (createTeamBody, params, options) => {
1233
1455
  const getQueryTeamsUrl = (params) => {
1234
1456
  const normalizedParams = new URLSearchParams();
1235
1457
  Object.entries(params || {}).forEach(([key, value]) => {
1236
- 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));
1237
1459
  });
1238
1460
  const stringifiedParams = normalizedParams.toString();
1239
1461
  return stringifiedParams.length > 0 ? `${getProxyPath()}/teams/query?${stringifiedParams}` : `${getProxyPath()}/teams/query`;
1240
1462
  };
1241
1463
  /**
1242
1464
  * Returns the teams of a project, paginated with a cursor.
1243
-
1244
1465
  * @summary Query teams
1245
1466
  */
1246
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
+ };
1247
1476
  return customFetch(getQueryTeamsUrl(params), {
1248
1477
  ...options,
1249
1478
  method: "POST",
1250
1479
  headers: {
1251
1480
  "Content-Type": "application/json",
1252
- ...options?.headers
1481
+ ...getHeaders(options?.headers)
1253
1482
  },
1254
1483
  body: JSON.stringify(queryTeamsBody)
1255
1484
  });
1256
1485
  };
1257
1486
  const getGetTeamUrl = (teamId) => {
1258
- return `${getProxyPath()}/teams/${teamId}`;
1487
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1259
1488
  };
1260
1489
  /**
1261
1490
  * Returns a Team by its id.
1262
-
1263
1491
  * @summary Get team
1264
1492
  */
1265
1493
  const getTeam = async (teamId, options) => {
@@ -1269,18 +1497,22 @@ const getTeam = async (teamId, options) => {
1269
1497
  });
1270
1498
  };
1271
1499
  const getDeleteTeamUrl = (teamId) => {
1272
- return `${getProxyPath()}/teams/${teamId}`;
1500
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1273
1501
  };
1274
1502
  /**
1275
1503
  * Deactivates the team.
1276
-
1277
- The team is tombstoned rather than erased: it stays readable through
1278
- getTeam with status `deactivated`. Its memberships are removed and the
1279
- users whose lifecycle it owns are deactivated with it.
1280
-
1281
- The request is idempotent. Deleting a team that is already deactivated
1282
- or doesn't exist succeeds without changing anything.
1283
-
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.
1284
1516
  * @summary Delete team
1285
1517
  */
1286
1518
  const deleteTeam = async (teamId, options) => {
@@ -1290,20 +1522,27 @@ const deleteTeam = async (teamId, options) => {
1290
1522
  });
1291
1523
  };
1292
1524
  const getUpdateTeamUrl = (teamId) => {
1293
- return `${getProxyPath()}/teams/${teamId}`;
1525
+ return `${getProxyPath()}/teams/${encodeURIComponent(String(teamId))}`;
1294
1526
  };
1295
1527
  /**
1296
1528
  * Update team. Only active teams can be updated.
1297
-
1298
1529
  * @summary Update team
1299
1530
  */
1300
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
+ };
1301
1540
  return customFetch(getUpdateTeamUrl(teamId), {
1302
1541
  ...options,
1303
1542
  method: "PATCH",
1304
1543
  headers: {
1305
1544
  "Content-Type": "application/json",
1306
- ...options?.headers
1545
+ ...getHeaders(options?.headers)
1307
1546
  },
1308
1547
  body: JSON.stringify(updateTeamBody)
1309
1548
  });
@@ -1311,14 +1550,13 @@ const updateTeam = async (teamId, updateTeamBody, options) => {
1311
1550
  const getListEnvironmentsUrl = (params) => {
1312
1551
  const normalizedParams = new URLSearchParams();
1313
1552
  Object.entries(params || {}).forEach(([key, value]) => {
1314
- 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));
1315
1554
  });
1316
1555
  const stringifiedParams = normalizedParams.toString();
1317
1556
  return stringifiedParams.length > 0 ? `${getProxyPath()}/environments?${stringifiedParams}` : `${getProxyPath()}/environments`;
1318
1557
  };
1319
1558
  /**
1320
1559
  * Lists the project's environments ordered by name.
1321
-
1322
1560
  * @summary List environments
1323
1561
  */
1324
1562
  const listEnvironments = async (params, options) => {
@@ -1330,17 +1568,16 @@ const listEnvironments = async (params, options) => {
1330
1568
  const getGetEnvironmentByNameUrl = (name, params) => {
1331
1569
  const normalizedParams = new URLSearchParams();
1332
1570
  Object.entries(params || {}).forEach(([key, value]) => {
1333
- 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));
1334
1572
  });
1335
1573
  const stringifiedParams = normalizedParams.toString();
1336
- 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))}`;
1337
1575
  };
1338
1576
  /**
1339
1577
  * Reads one environment of the project by its name.
1340
-
1341
- The lookup is scoped to the project in `project_id`: a name that exists in
1342
- another project answers `env.not_found` exactly as an unused name does.
1343
-
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.
1344
1581
  * @summary Get an environment by name
1345
1582
  */
1346
1583
  const getEnvironmentByName = async (name, params, options) => {
@@ -1352,31 +1589,37 @@ const getEnvironmentByName = async (name, params, options) => {
1352
1589
  const getCreateBrandingUrl = (params) => {
1353
1590
  const normalizedParams = new URLSearchParams();
1354
1591
  Object.entries(params || {}).forEach(([key, value]) => {
1355
- 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));
1356
1593
  });
1357
1594
  const stringifiedParams = normalizedParams.toString();
1358
1595
  return stringifiedParams.length > 0 ? `${getProxyPath()}/branding?${stringifiedParams}` : `${getProxyPath()}/branding`;
1359
1596
  };
1360
1597
  /**
1361
1598
  * Publishes a new immutable branding revision for the project. Branding
1362
- revisions cannot be updated or deleted; every edit publishes a new
1363
- revision, and flow responses resolve the latest revision per project
1364
- (see ADR 040).
1365
-
1366
- The `liquid_template` is validated lexically on save (size, encoding,
1367
- banned patterns such as `<script>` tags, inline event handlers, and the
1368
- `| raw` filter). Authoritative LiquidJS validation runs at authoring
1369
- time via `zitadel plan` / `zitadel apply`.
1370
-
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`.
1371
1606
  * @summary Publish a new branding revision
1372
1607
  */
1373
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
+ };
1374
1617
  return customFetch(getCreateBrandingUrl(params), {
1375
1618
  ...options,
1376
1619
  method: "POST",
1377
1620
  headers: {
1378
1621
  "Content-Type": "application/json",
1379
- ...options?.headers
1622
+ ...getHeaders(options?.headers)
1380
1623
  },
1381
1624
  body: JSON.stringify(createBrandingBody)
1382
1625
  });
@@ -1384,18 +1627,17 @@ const createBranding = async (createBrandingBody, params, options) => {
1384
1627
  const getListBrandingUrl = (params) => {
1385
1628
  const normalizedParams = new URLSearchParams();
1386
1629
  Object.entries(params || {}).forEach(([key, value]) => {
1387
- 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));
1388
1631
  });
1389
1632
  const stringifiedParams = normalizedParams.toString();
1390
1633
  return stringifiedParams.length > 0 ? `${getProxyPath()}/branding?${stringifiedParams}` : `${getProxyPath()}/branding`;
1391
1634
  };
1392
1635
  /**
1393
1636
  * Lists branding revisions for the project, newest first, capped at the
1394
- 100 most recent. The first entry is the revision flow responses
1395
- currently resolve. Deliberately unpaginated in v1 — list endpoints
1396
- gain a real query mechanism together (ADR 031); advertising pagination
1397
- parameters the server ignores would be worse than none.
1398
-
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.
1399
1641
  * @summary List branding revisions
1400
1642
  */
1401
1643
  const listBranding = async (params, options) => {
@@ -1405,7 +1647,7 @@ const listBranding = async (params, options) => {
1405
1647
  });
1406
1648
  };
1407
1649
  const getGetBrandingByIdUrl = (id) => {
1408
- return `${getProxyPath()}/branding/${id}`;
1650
+ return `${getProxyPath()}/branding/${encodeURIComponent(String(id))}`;
1409
1651
  };
1410
1652
  /**
1411
1653
  * Retrieves a single branding revision, including its stored configuration.
@@ -1417,40 +1659,194 @@ const getBrandingById = async (id, options) => {
1417
1659
  method: "GET"
1418
1660
  });
1419
1661
  };
1662
+ const getCreateIdpUrl = (params) => {
1663
+ const normalizedParams = new URLSearchParams();
1664
+ Object.entries(params || {}).forEach(([key, value]) => {
1665
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1666
+ });
1667
+ const stringifiedParams = normalizedParams.toString();
1668
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps?${stringifiedParams}` : `${getProxyPath()}/idps`;
1669
+ };
1670
+ /**
1671
+ * Creates or revises a connection document. If the slug does not already
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.
1693
+ * @summary Create or revise an identity provider connection
1694
+ */
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
+ };
1704
+ return customFetch(getCreateIdpUrl(params), {
1705
+ ...options,
1706
+ method: "POST",
1707
+ headers: {
1708
+ "Content-Type": "application/json",
1709
+ ...getHeaders(options?.headers)
1710
+ },
1711
+ body: JSON.stringify(createIdpBody)
1712
+ });
1713
+ };
1714
+ const getQueryIdpsUrl = (params) => {
1715
+ const normalizedParams = new URLSearchParams();
1716
+ Object.entries(params || {}).forEach(([key, value]) => {
1717
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1718
+ });
1719
+ const stringifiedParams = normalizedParams.toString();
1720
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/query?${stringifiedParams}` : `${getProxyPath()}/idps/query`;
1721
+ };
1722
+ /**
1723
+ * Returns the identity provider connections of a project, paginated with a
1724
+ * cursor. One row per connection, carrying its newest revision.
1725
+ * @summary Query identity provider connections
1726
+ */
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
+ };
1736
+ return customFetch(getQueryIdpsUrl(params), {
1737
+ ...options,
1738
+ method: "POST",
1739
+ headers: {
1740
+ "Content-Type": "application/json",
1741
+ ...getHeaders(options?.headers)
1742
+ },
1743
+ body: JSON.stringify(queryIdpsBody)
1744
+ });
1745
+ };
1746
+ const getGetIdpByIdUrl = (id, params) => {
1747
+ const normalizedParams = new URLSearchParams();
1748
+ Object.entries(params || {}).forEach(([key, value]) => {
1749
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1750
+ });
1751
+ const stringifiedParams = normalizedParams.toString();
1752
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${encodeURIComponent(String(id))}?${stringifiedParams}` : `${getProxyPath()}/idps/${encodeURIComponent(String(id))}`;
1753
+ };
1754
+ /**
1755
+ * Reads a connection by its id, at its newest revision.
1756
+ * `GET /idps/{id}/revisions` lists every revision of the connection.
1757
+ *
1758
+ * The lookup is scoped to the project in `project_id`.
1759
+ * @summary Get an identity provider connection by id
1760
+ */
1761
+ const getIdpById = async (id, params, options) => {
1762
+ return customFetch(getGetIdpByIdUrl(id, params), {
1763
+ ...options,
1764
+ method: "GET"
1765
+ });
1766
+ };
1767
+ const getListIdpRevisionsUrl = (id, params) => {
1768
+ const normalizedParams = new URLSearchParams();
1769
+ Object.entries(params || {}).forEach(([key, value]) => {
1770
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1771
+ });
1772
+ const stringifiedParams = normalizedParams.toString();
1773
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/${encodeURIComponent(String(id))}/revisions?${stringifiedParams}` : `${getProxyPath()}/idps/${encodeURIComponent(String(id))}/revisions`;
1774
+ };
1775
+ /**
1776
+ * Returns every revision of one connection, newest first, paginated with a
1777
+ * cursor. The order is fixed, so there is no `sorting`.
1778
+ *
1779
+ * The lookup is scoped to the project in `project_id`.
1780
+ * @summary List the revisions of an identity provider connection
1781
+ */
1782
+ const listIdpRevisions = async (id, params, options) => {
1783
+ return customFetch(getListIdpRevisionsUrl(id, params), {
1784
+ ...options,
1785
+ method: "GET"
1786
+ });
1787
+ };
1788
+ const getGetIdpRevisionByIdUrl = (revisionId, params) => {
1789
+ const normalizedParams = new URLSearchParams();
1790
+ Object.entries(params || {}).forEach(([key, value]) => {
1791
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
1792
+ });
1793
+ const stringifiedParams = normalizedParams.toString();
1794
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/idps/revisions/${encodeURIComponent(String(revisionId))}?${stringifiedParams}` : `${getProxyPath()}/idps/revisions/${encodeURIComponent(String(revisionId))}`;
1795
+ };
1796
+ /**
1797
+ * Reads one revision of a connection by its `revision_id`, the value an auth
1798
+ * attempt or a release pins.
1799
+ *
1800
+ * The lookup is scoped to the project in `project_id`.
1801
+ * @summary Get one revision of an identity provider connection
1802
+ */
1803
+ const getIdpRevisionById = async (revisionId, params, options) => {
1804
+ return customFetch(getGetIdpRevisionByIdUrl(revisionId, params), {
1805
+ ...options,
1806
+ method: "GET"
1807
+ });
1808
+ };
1420
1809
  const getCreateReleaseUrl = (params) => {
1421
1810
  const normalizedParams = new URLSearchParams();
1422
1811
  Object.entries(params || {}).forEach(([key, value]) => {
1423
- 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));
1424
1813
  });
1425
1814
  const stringifiedParams = normalizedParams.toString();
1426
1815
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases?${stringifiedParams}` : `${getProxyPath()}/releases`;
1427
1816
  };
1428
1817
  /**
1429
1818
  * Bundles a release from revisions that already exist, supplied as
1430
- `(kind, revision_id)` pairs. No new revisions are allocated — use the
1431
- per-kind create endpoints for that, then pin the ids here.
1432
-
1433
- Every referenced `revision_id` must exist in the project. Each one's handle
1434
- is read from the revision itself and recorded on the release, so a resource
1435
- is always pinned under the identity it declares.
1436
-
1437
- Creating a release does not deploy it. A release is environment-agnostic
1438
- and the same release can later be deployed to any number of environments
1439
- unchanged.
1440
-
1441
- Idempotent on the pinned set: metadata is excluded from the comparison, so
1442
- re-submitting the same revisions with a different `message` returns the
1443
- release that already pins them rather than creating a second one.
1444
-
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.
1445
1833
  * @summary Create a release
1446
1834
  */
1447
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
+ };
1448
1844
  return customFetch(getCreateReleaseUrl(params), {
1449
1845
  ...options,
1450
1846
  method: "POST",
1451
1847
  headers: {
1452
1848
  "Content-Type": "application/json",
1453
- ...options?.headers
1849
+ ...getHeaders(options?.headers)
1454
1850
  },
1455
1851
  body: JSON.stringify(createReleaseBody)
1456
1852
  });
@@ -1458,17 +1854,16 @@ const createRelease = async (createReleaseBody, params, options) => {
1458
1854
  const getListReleasesUrl = (params) => {
1459
1855
  const normalizedParams = new URLSearchParams();
1460
1856
  Object.entries(params || {}).forEach(([key, value]) => {
1461
- 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));
1462
1858
  });
1463
1859
  const stringifiedParams = normalizedParams.toString();
1464
1860
  return stringifiedParams.length > 0 ? `${getProxyPath()}/releases?${stringifiedParams}` : `${getProxyPath()}/releases`;
1465
1861
  };
1466
1862
  /**
1467
1863
  * Lists the project's releases, newest first.
1468
-
1469
- Entries carry metadata only — the pinned set is omitted. Read one release
1470
- with `GET /releases/{release_id}` to get its pointers.
1471
-
1864
+ *
1865
+ * Entries carry metadata only — the pinned set is omitted. Read one release
1866
+ * with `GET /releases/{release_id}` to get its pointers.
1472
1867
  * @summary List releases
1473
1868
  */
1474
1869
  const listReleases = async (params, options) => {
@@ -1480,23 +1875,22 @@ const listReleases = async (params, options) => {
1480
1875
  const getGetReleaseByIdUrl = (releaseId, params) => {
1481
1876
  const normalizedParams = new URLSearchParams();
1482
1877
  Object.entries(params || {}).forEach(([key, value]) => {
1483
- 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));
1484
1879
  });
1485
1880
  const stringifiedParams = normalizedParams.toString();
1486
- 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))}`;
1487
1882
  };
1488
1883
  /**
1489
1884
  * Reads one release: its metadata and the `(kind, handle, revision_id)`
1490
- tuples it pins.
1491
-
1492
- Does not embed resource content. Resolve each `revision_id` through the
1493
- per-kind read endpoints when the bytes are needed.
1494
-
1495
- The lookup is scoped to the project in `project_id`: a release id belonging
1496
- to another project answers not found exactly as an unknown id does, so the
1497
- endpoint cannot be used to probe for releases in projects the caller cannot
1498
- read.
1499
-
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.
1500
1894
  * @summary Get a release by id
1501
1895
  */
1502
1896
  const getReleaseById = async (releaseId, params, options) => {
@@ -1508,28 +1902,48 @@ const getReleaseById = async (releaseId, params, options) => {
1508
1902
  const getCreateGrantUrl = (params) => {
1509
1903
  const normalizedParams = new URLSearchParams();
1510
1904
  Object.entries(params || {}).forEach(([key, value]) => {
1511
- 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));
1512
1906
  });
1513
1907
  const stringifiedParams = normalizedParams.toString();
1514
1908
  return stringifiedParams.length > 0 ? `${getProxyPath()}/grants?${stringifiedParams}` : `${getProxyPath()}/grants`;
1515
1909
  };
1516
1910
  /**
1517
1911
  * Bind a user or team to `project.viewer`, `project.editor`, or
1518
- `project.admin` on the project identified by the `project-id` header.
1519
- IDs are `asgn_<opaque>`. Owning-team (`project.team`) grants are not
1520
- created here — claim owns that path. An unrevoked grant with the same
1521
- principal and relation occupies the unique key even after `expires_at`;
1522
- DELETE it before re-creating.
1523
-
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).
1524
1930
  * @summary Create grant
1525
1931
  */
1526
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
+ };
1527
1941
  return customFetch(getCreateGrantUrl(params), {
1528
1942
  ...options,
1529
1943
  method: "POST",
1530
1944
  headers: {
1531
1945
  "Content-Type": "application/json",
1532
- ...options?.headers
1946
+ ...getHeaders(options?.headers)
1533
1947
  },
1534
1948
  body: JSON.stringify(createGrantBody)
1535
1949
  });
@@ -1537,32 +1951,45 @@ const createGrant = async (createGrantBody, params, options) => {
1537
1951
  const getQueryGrantsUrl = (params) => {
1538
1952
  const normalizedParams = new URLSearchParams();
1539
1953
  Object.entries(params || {}).forEach(([key, value]) => {
1540
- 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));
1541
1955
  });
1542
1956
  const stringifiedParams = normalizedParams.toString();
1543
1957
  return stringifiedParams.length > 0 ? `${getProxyPath()}/grants/query?${stringifiedParams}` : `${getProxyPath()}/grants/query`;
1544
1958
  };
1545
1959
  /**
1546
1960
  * Returns the collaboration grants of a project, paginated with a cursor.
1547
- Only unrevoked grants this API manages are listed (user or team bound to
1548
- viewer, editor, or admin), including expired grants so a client can
1549
- DELETE before re-granting. Project-secret setup (`sk_proj`) and
1550
- owning-team (`relation=team`) rows are not returned. Grants are not in
1551
- `resource_scope_index`; project scope is required on the query (same as
1552
- get). Requires `project.read`. `expand: ["principal"]` additionally
1553
- requires `user.read` and `team.read` (documented on the expand enum;
1554
- those scopes cannot be ANDed onto this security block because they are
1555
- body-conditional).
1556
-
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).
1557
1976
  * @summary Query grants
1558
1977
  */
1559
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
+ };
1560
1987
  return customFetch(getQueryGrantsUrl(params), {
1561
1988
  ...options,
1562
1989
  method: "POST",
1563
1990
  headers: {
1564
1991
  "Content-Type": "application/json",
1565
- ...options?.headers
1992
+ ...getHeaders(options?.headers)
1566
1993
  },
1567
1994
  body: JSON.stringify(queryGrantsBody)
1568
1995
  });
@@ -1570,21 +1997,34 @@ const queryGrants = async (queryGrantsBody, params, options) => {
1570
1997
  const getGetGrantUrl = (id, params) => {
1571
1998
  const normalizedParams = new URLSearchParams();
1572
1999
  Object.entries(params || {}).forEach(([key, value]) => {
1573
- 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));
1574
2007
  });
1575
2008
  const stringifiedParams = normalizedParams.toString();
1576
- 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))}`;
1577
2010
  };
1578
2011
  /**
1579
2012
  * Loads a grant by `(project_id, id)` that this API manages (user or team
1580
- bound to viewer, editor, or admin) and that has not been revoked.
1581
- "Active" here means not revoked: expired grants stay visible so the
1582
- client can DELETE before re-granting the same binding. Authorization
1583
- still ignores expired grants. Grants are not registered in
1584
- `resource_scope_index`; project scope is required on the query (same as
1585
- events). Misses, revoked rows, project-secret setup (`sk_proj`),
1586
- owning-team (`relation=team`) rows, and cross-project ids return 404.
1587
-
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).
1588
2028
  * @summary Get grant
1589
2029
  */
1590
2030
  const getGrant = async (id, params, options) => {
@@ -1596,17 +2036,20 @@ const getGrant = async (id, params, options) => {
1596
2036
  const getDeleteGrantUrl = (id, params) => {
1597
2037
  const normalizedParams = new URLSearchParams();
1598
2038
  Object.entries(params || {}).forEach(([key, value]) => {
1599
- 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));
1600
2040
  });
1601
2041
  const stringifiedParams = normalizedParams.toString();
1602
- 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))}`;
1603
2043
  };
1604
2044
  /**
1605
2045
  * Soft-revokes a grant this API manages and emits `authz.revoked`.
1606
- Already-revoked, missing, project-secret setup, and owning-team grants
1607
- return 404. The row is not un-revoked. Expired grants can still be
1608
- revoked so the unique binding can be reused.
1609
-
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).
1610
2053
  * @summary Revoke grant
1611
2054
  */
1612
2055
  const deleteGrant = async (id, params, options) => {
@@ -1620,28 +2063,27 @@ const getListEventsUrl = (params) => {
1620
2063
  Object.entries(params || {}).forEach(([key, value]) => {
1621
2064
  if (Array.isArray(value) && ["category", "event_type"].includes(key)) {
1622
2065
  value.forEach((v) => {
1623
- normalizedParams.append(key, v === null ? "null" : v.toString());
2066
+ normalizedParams.append(key, v === null ? "null" : String(v));
1624
2067
  });
1625
2068
  return;
1626
2069
  }
1627
- 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));
1628
2071
  });
1629
2072
  const stringifiedParams = normalizedParams.toString();
1630
2073
  return stringifiedParams.length > 0 ? `${getProxyPath()}/events?${stringifiedParams}` : `${getProxyPath()}/events`;
1631
2074
  };
1632
2075
  /**
1633
2076
  * Returns project-scoped audit events, newest-first by keyset on
1634
- `(created_at, id)` (ADR 027 / ADR 049). Pass `order=asc` for oldest-first.
1635
- Requires `events.read`.
1636
-
1637
- Pre-claim projects return an empty list (events are stored but not
1638
- visible until claim succeeds). Team-scoped credentials see only events
1639
- whose emit-time `team_id` matches the credential team (enforced when
1640
- team-scoped tokens exist).
1641
-
1642
- Clients discriminate each item via `event_type` (OpenAPI Event oneOf) —
1643
- see docs/design/api/events-catalog.md.
1644
-
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.
1645
2087
  * @summary List events
1646
2088
  */
1647
2089
  const listEvents = async (params, options) => {
@@ -1653,18 +2095,17 @@ const listEvents = async (params, options) => {
1653
2095
  const getGetEventUrl = (id, params) => {
1654
2096
  const normalizedParams = new URLSearchParams();
1655
2097
  Object.entries(params || {}).forEach(([key, value]) => {
1656
- 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));
1657
2099
  });
1658
2100
  const stringifiedParams = normalizedParams.toString();
1659
- 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))}`;
1660
2102
  };
1661
2103
  /**
1662
2104
  * Loads a single event by `(project_id, id)`. Requires `events.read`.
1663
- Events are not registered in `resource_scope_index`; project scope is
1664
- required on the query (ADR 049). Misses and cross-project ids return 404.
1665
-
1666
- Pre-claim projects return 404 (stored events stay invisible until claim).
1667
-
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).
1668
2109
  * @summary Get event by ID
1669
2110
  */
1670
2111
  const getEvent = async (id, params, options) => {
@@ -1673,6 +2114,235 @@ const getEvent = async (id, params, options) => {
1673
2114
  method: "GET"
1674
2115
  });
1675
2116
  };
2117
+ const getGetVariablesUrl = (params) => {
2118
+ const normalizedParams = new URLSearchParams();
2119
+ Object.entries(params || {}).forEach(([key, value]) => {
2120
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2121
+ });
2122
+ const stringifiedParams = normalizedParams.toString();
2123
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
2124
+ };
2125
+ /**
2126
+ * Returns the variables entered at the owner this request addresses, keyed by
2127
+ * name — one environment of the project with `environment_name`, the project
2128
+ * level itself without it.
2129
+ *
2130
+ * Owners are separate, not a ladder: an environment does not inherit the
2131
+ * project's variables and the project does not see its environments'. Reading
2132
+ * everything a project holds therefore means reading each owner in turn.
2133
+ *
2134
+ * Secret values are not returned. A secret appears as `{"secret": true}`,
2135
+ * which says a value is held without disclosing it.
2136
+ * @summary Get variables
2137
+ */
2138
+ const getVariables = async (params, options) => {
2139
+ return customFetch(getGetVariablesUrl(params), {
2140
+ ...options,
2141
+ method: "GET"
2142
+ });
2143
+ };
2144
+ const getUpdateVariablesUrl = (params) => {
2145
+ const normalizedParams = new URLSearchParams();
2146
+ Object.entries(params || {}).forEach(([key, value]) => {
2147
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2148
+ });
2149
+ const stringifiedParams = normalizedParams.toString();
2150
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables?${stringifiedParams}` : `${getProxyPath()}/variables`;
2151
+ };
2152
+ /**
2153
+ * Enters, replaces and removes variables at the owner this request
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.
2170
+ * @summary Update variables
2171
+ */
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
+ };
2181
+ return customFetch(getUpdateVariablesUrl(params), {
2182
+ ...options,
2183
+ method: "PATCH",
2184
+ headers: {
2185
+ "Content-Type": "application/json",
2186
+ ...getHeaders(options?.headers)
2187
+ },
2188
+ body: JSON.stringify(updateVariablesBody)
2189
+ });
2190
+ };
2191
+ const getGetVariableUrl = (variableName, params) => {
2192
+ const normalizedParams = new URLSearchParams();
2193
+ Object.entries(params || {}).forEach(([key, value]) => {
2194
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2195
+ });
2196
+ const stringifiedParams = normalizedParams.toString();
2197
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
2198
+ };
2199
+ /**
2200
+ * Reads one variable by name from the owner this request addresses — one
2201
+ * environment of the project with `environment_name`, the project level
2202
+ * itself without it.
2203
+ *
2204
+ * A name that owner has not entered answers `var.not_found`, even when
2205
+ * another owner of the same project holds it: nothing is inherited. A secret
2206
+ * is found but not disclosed: the response is `{"secret": true}`.
2207
+ * @summary Get a variable
2208
+ */
2209
+ const getVariable = async (variableName, params, options) => {
2210
+ return customFetch(getGetVariableUrl(variableName, params), {
2211
+ ...options,
2212
+ method: "GET"
2213
+ });
2214
+ };
2215
+ const getDeleteVariableUrl = (variableName, params) => {
2216
+ const normalizedParams = new URLSearchParams();
2217
+ Object.entries(params || {}).forEach(([key, value]) => {
2218
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
2219
+ });
2220
+ const stringifiedParams = normalizedParams.toString();
2221
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}?${stringifiedParams}` : `${getProxyPath()}/variables/${encodeURIComponent(String(variableName))}`;
2222
+ };
2223
+ /**
2224
+ * Removes the variable this owner entered under this name.
2225
+ *
2226
+ * A variable is deletable only by the owner that entered it. Deleting a name
2227
+ * another owner of the same project holds answers `var.not_found` and leaves
2228
+ * that owner's value standing.
2229
+ * @summary Delete a variable
2230
+ */
2231
+ const deleteVariable = async (variableName, params, options) => {
2232
+ return customFetch(getDeleteVariableUrl(variableName, params), {
2233
+ ...options,
2234
+ method: "DELETE"
2235
+ });
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
+ };
1676
2346
  //#endregion
1677
2347
  //#region ../api/dist/runtime/api-factory.mjs
1678
2348
  /**
@@ -1716,7 +2386,7 @@ function createZitadelClient(opts) {
1716
2386
  } });
1717
2387
  }
1718
2388
  //#endregion
1719
- //#region ../config/dist/defaults-DHEYFHlz.mjs
2389
+ //#region ../config/dist/defaults-BnRHT7RQ.mjs
1720
2390
  var default_human_user_default = {
1721
2391
  title: "DefaultHumanUserSchema",
1722
2392
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -2698,4 +3368,4 @@ Object.defineProperty(exports, "startLocalZitadel", {
2698
3368
  }
2699
3369
  });
2700
3370
 
2701
- //# sourceMappingURL=src-pZyQN7qD.cjs.map
3371
+ //# sourceMappingURL=src-3iEZwMxn.cjs.map