@zitadel/components 0.1.0-alpha.0 → 0.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +41 -36
  2. package/dist/atoms/index.d.mts +1 -1
  3. package/dist/atoms/index.mjs +1 -1
  4. package/dist/atoms/zl-alert.d.ts.map +1 -1
  5. package/dist/atoms/zl-button.d.ts +7 -1
  6. package/dist/atoms/zl-button.d.ts.map +1 -1
  7. package/dist/atoms/zl-card.d.ts +7 -0
  8. package/dist/atoms/zl-card.d.ts.map +1 -1
  9. package/dist/atoms/zl-field.d.ts +6 -0
  10. package/dist/atoms/zl-field.d.ts.map +1 -1
  11. package/dist/atoms/zl-icon.d.ts.map +1 -1
  12. package/dist/atoms/zl-page-shell.d.ts +6 -0
  13. package/dist/atoms/zl-page-shell.d.ts.map +1 -1
  14. package/dist/atoms/zl-pill.d.ts +0 -1
  15. package/dist/atoms/zl-pill.d.ts.map +1 -1
  16. package/dist/{atoms-B9yd0c-i.mjs → atoms-eOxuoGDq.mjs} +118 -73
  17. package/dist/atoms-eOxuoGDq.mjs.map +1 -0
  18. package/dist/{index-B74_igDN.d.mts → index-DjBsBWdg.d.mts} +82 -18
  19. package/dist/index-DjBsBWdg.d.mts.map +1 -0
  20. package/dist/{index-Dd8hfOWt.d.mts → index-DmtnqUIY.d.mts} +1223 -572
  21. package/dist/index-DmtnqUIY.d.mts.map +1 -0
  22. package/dist/index.d.mts +2 -2
  23. package/dist/index.mjs +2 -2
  24. package/dist/internal/emit.d.ts +12 -0
  25. package/dist/internal/emit.d.ts.map +1 -0
  26. package/dist/internal/escape-html.d.ts +10 -0
  27. package/dist/internal/escape-html.d.ts.map +1 -0
  28. package/dist/manifests.mjs +1 -1
  29. package/dist/orchestrator/index.d.mts +1 -1
  30. package/dist/orchestrator/index.mjs +1 -1
  31. package/dist/orchestrator/locales/en.d.ts.map +1 -1
  32. package/dist/orchestrator/resolve-api.d.ts +37 -0
  33. package/dist/orchestrator/resolve-api.d.ts.map +1 -0
  34. package/dist/orchestrator/zitadel-login.d.ts +27 -2
  35. package/dist/orchestrator/zitadel-login.d.ts.map +1 -1
  36. package/dist/orchestrator/zitadel-logout.d.ts +33 -5
  37. package/dist/orchestrator/zitadel-logout.d.ts.map +1 -1
  38. package/dist/{orchestrator-B8eXcPRi.mjs → orchestrator-Dds72XrU.mjs} +349 -125
  39. package/dist/orchestrator-Dds72XrU.mjs.map +1 -0
  40. package/dist/standalone.mjs +12002 -0
  41. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  42. package/package.json +8 -2
  43. package/dist/atoms-B9yd0c-i.mjs.map +0 -1
  44. package/dist/index-B74_igDN.d.mts.map +0 -1
  45. package/dist/index-Dd8hfOWt.d.mts.map +0 -1
  46. package/dist/orchestrator-B8eXcPRi.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { _ as __decorate, b as t, v as focusVisibleStyles, y as baseHostStyles } from "./atoms-B9yd0c-i.mjs";
1
+ import { _ as __decorate, b as t, v as focusVisibleStyles, x as emit, y as baseHostStyles } from "./atoms-eOxuoGDq.mjs";
2
2
  import { r as tokensCss } from "./tokens-TXmurodq.mjs";
3
3
  import { t as default_default } from "./default-DP74t2io.mjs";
4
4
  import { manifestRegistry } from "./manifests.mjs";
@@ -7,15 +7,6 @@ import { customElement, property, state } from "lit/decorators.js";
7
7
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
8
8
  import { Liquid } from "liquidjs";
9
9
  import DOMPurify from "dompurify";
10
- //#region ../api/dist/runtime/base-url.mjs
11
- let proxyPath = "";
12
- function getProxyPath() {
13
- return proxyPath;
14
- }
15
- function setProxyPath(path) {
16
- proxyPath = path;
17
- }
18
- //#endregion
19
10
  //#region ../api/dist/runtime/auth.mjs
20
11
  /**
21
12
  * Module-global bearer token used by the orval-generated client's
@@ -35,18 +26,6 @@ function setApiAuthToken(token) {
35
26
  apiAuthToken = token;
36
27
  }
37
28
  //#endregion
38
- //#region ../api/dist/chunk-CfYAbeIz.mjs
39
- var __defProp = Object.defineProperty;
40
- var __exportAll = (all, no_symbols) => {
41
- let target = {};
42
- for (var name in all) __defProp(target, name, {
43
- get: all[name],
44
- enumerable: true
45
- });
46
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
47
- return target;
48
- };
49
- //#endregion
50
29
  //#region ../api/dist/runtime/fetch.mjs
51
30
  /**
52
31
  * Framework-neutral failure type the orval-generated client throws on
@@ -119,6 +98,57 @@ function safeJsonParse(text) {
119
98
  }
120
99
  }
121
100
  //#endregion
101
+ //#region src/orchestrator/api-client.ts
102
+ const apiRequestInit = { credentials: "include" };
103
+ async function startFlow(api, input) {
104
+ return api.createFlow(input, apiRequestInit);
105
+ }
106
+ async function submitStep(api, id, body) {
107
+ try {
108
+ return await api.submitFlowStep(id, body, apiRequestInit);
109
+ } catch (error) {
110
+ if (error instanceof ApiError && error.status === 400 && isFlowResponse(error.body)) return error.body;
111
+ throw error;
112
+ }
113
+ }
114
+ function isFlowResponse(body) {
115
+ return typeof body === "object" && body !== null && "step" in body;
116
+ }
117
+ async function getCurrentStep(api, id) {
118
+ return api.getFlowStep(id, apiRequestInit);
119
+ }
120
+ /**
121
+ * Exchange a terminal-flow `handoff_token` for an authenticated session.
122
+ * The server sets the `__nextgen_session` HttpOnly cookie on success.
123
+ *
124
+ * Uses the generated `exchangeHandoff` client which handles the
125
+ * `project_id` query parameter via {@link ExchangeHandoffParams}.
126
+ */
127
+ async function exchangeSession(api, body, params) {
128
+ return api.exchangeHandoff(body, params, apiRequestInit);
129
+ }
130
+ //#endregion
131
+ //#region ../api/dist/runtime/base-url.mjs
132
+ let proxyPath = "";
133
+ function getProxyPath() {
134
+ return proxyPath;
135
+ }
136
+ function setProxyPath(path) {
137
+ proxyPath = path;
138
+ }
139
+ //#endregion
140
+ //#region ../api/dist/chunk-CfYAbeIz.mjs
141
+ var __defProp = Object.defineProperty;
142
+ var __exportAll = (all, no_symbols) => {
143
+ let target = {};
144
+ for (var name in all) __defProp(target, name, {
145
+ get: all[name],
146
+ enumerable: true
147
+ });
148
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
149
+ return target;
150
+ };
151
+ //#endregion
122
152
  //#region ../api/dist/generated/endpoints/zitadelNextGen.mjs
123
153
  /**
124
154
  * Generated by orval v8.10.0 🍺
@@ -166,6 +196,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
166
196
  getGetKeysUrl: () => getGetKeysUrl,
167
197
  getGetLiveUrl: () => getGetLiveUrl,
168
198
  getGetMySessionUrl: () => getGetMySessionUrl,
199
+ getGetMyUserUrl: () => getGetMyUserUrl,
169
200
  getGetOpenIDConfigurationUrl: () => getGetOpenIDConfigurationUrl,
170
201
  getGetProjectUrl: () => getGetProjectUrl,
171
202
  getGetReadyUrl: () => getGetReadyUrl,
@@ -184,6 +215,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
184
215
  getListUsersUrl: () => getListUsersUrl,
185
216
  getLive: () => getLive,
186
217
  getMySession: () => getMySession,
218
+ getMyUser: () => getMyUser,
187
219
  getOpenIDConfiguration: () => getOpenIDConfiguration,
188
220
  getProject: () => getProject,
189
221
  getReady: () => getReady,
@@ -192,6 +224,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
192
224
  getRevokeTokenUrl: () => getRevokeTokenUrl,
193
225
  getSchemaById: () => getSchemaById,
194
226
  getSession: () => getSession,
227
+ getSetUserPasswordUrl: () => getSetUserPasswordUrl,
195
228
  getSubmitFlowEventUrl: () => getSubmitFlowEventUrl,
196
229
  getSubmitFlowStepUrl: () => getSubmitFlowStepUrl,
197
230
  getTeam: () => getTeam,
@@ -208,6 +241,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
208
241
  revokeMySession: () => revokeMySession,
209
242
  revokeSession: () => revokeSession,
210
243
  revokeToken: () => revokeToken,
244
+ setUserPassword: () => setUserPassword,
211
245
  submitFlowEvent: () => submitFlowEvent,
212
246
  submitFlowStep: () => submitFlowStep,
213
247
  updateFlowDefinition: () => updateFlowDefinition,
@@ -412,7 +446,7 @@ const getCreateUserUrl = (params) => {
412
446
  if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
413
447
  });
414
448
  const stringifiedParams = normalizedParams.toString();
415
- return stringifiedParams.length > 0 ? `${getProxyPath()}/user?${stringifiedParams}` : `${getProxyPath()}/user`;
449
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users?${stringifiedParams}` : `${getProxyPath()}/users`;
416
450
  };
417
451
  /**
418
452
  * @summary Create user
@@ -434,7 +468,7 @@ const getListUsersUrl = (params) => {
434
468
  if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
435
469
  });
436
470
  const stringifiedParams = normalizedParams.toString();
437
- return stringifiedParams.length > 0 ? `${getProxyPath()}/user?${stringifiedParams}` : `${getProxyPath()}/user`;
471
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users?${stringifiedParams}` : `${getProxyPath()}/users`;
438
472
  };
439
473
  /**
440
474
  * @summary List users
@@ -451,7 +485,7 @@ const getGetUserByIDUrl = (userId, params) => {
451
485
  if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
452
486
  });
453
487
  const stringifiedParams = normalizedParams.toString();
454
- return stringifiedParams.length > 0 ? `${getProxyPath()}/user/${userId}?${stringifiedParams}` : `${getProxyPath()}/user/${userId}`;
488
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${userId}?${stringifiedParams}` : `${getProxyPath()}/users/${userId}`;
455
489
  };
456
490
  /**
457
491
  * @summary Get user by ID
@@ -462,6 +496,40 @@ const getUserByID = async (userId, params, options) => {
462
496
  method: "GET"
463
497
  });
464
498
  };
499
+ const getSetUserPasswordUrl = (userId, params) => {
500
+ const normalizedParams = new URLSearchParams();
501
+ Object.entries(params || {}).forEach(([key, value]) => {
502
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
503
+ });
504
+ const stringifiedParams = normalizedParams.toString();
505
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/users/${userId}/password?${stringifiedParams}` : `${getProxyPath()}/users/${userId}/password`;
506
+ };
507
+ /**
508
+ * @summary Set user password
509
+ */
510
+ const setUserPassword = async (userId, setUserPasswordBody, params, options) => {
511
+ return customFetch(getSetUserPasswordUrl(userId, params), {
512
+ ...options,
513
+ method: "PUT",
514
+ headers: {
515
+ "Content-Type": "application/json",
516
+ ...options?.headers
517
+ },
518
+ body: JSON.stringify(setUserPasswordBody)
519
+ });
520
+ };
521
+ const getGetMyUserUrl = () => {
522
+ return `${getProxyPath()}/users/me`;
523
+ };
524
+ /**
525
+ * @summary Get my user information
526
+ */
527
+ const getMyUser = async (options) => {
528
+ return customFetch(getGetMyUserUrl(), {
529
+ ...options,
530
+ method: "GET"
531
+ });
532
+ };
465
533
  const getCreateFlowUrl = () => {
466
534
  return `${getProxyPath()}/flow`;
467
535
  };
@@ -986,28 +1054,38 @@ const listFlowDefinitions = async (params, options) => {
986
1054
  method: "GET"
987
1055
  });
988
1056
  };
989
- const getGetFlowDefinitionUrl = (id) => {
990
- return `${getProxyPath()}/flow_definitions/${id}`;
1057
+ const getGetFlowDefinitionUrl = (id, params) => {
1058
+ const normalizedParams = new URLSearchParams();
1059
+ Object.entries(params || {}).forEach(([key, value]) => {
1060
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1061
+ });
1062
+ const stringifiedParams = normalizedParams.toString();
1063
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/flow_definitions/${id}?${stringifiedParams}` : `${getProxyPath()}/flow_definitions/${id}`;
991
1064
  };
992
1065
  /**
993
1066
  * Get a flow definition by id
994
1067
  * @summary Get a flow definition by id
995
1068
  */
996
- const getFlowDefinition = async (id, options) => {
997
- return customFetch(getGetFlowDefinitionUrl(id), {
1069
+ const getFlowDefinition = async (id, params, options) => {
1070
+ return customFetch(getGetFlowDefinitionUrl(id, params), {
998
1071
  ...options,
999
1072
  method: "GET"
1000
1073
  });
1001
1074
  };
1002
- const getUpdateFlowDefinitionUrl = (id) => {
1003
- return `${getProxyPath()}/flow_definitions/${id}`;
1075
+ const getUpdateFlowDefinitionUrl = (id, params) => {
1076
+ const normalizedParams = new URLSearchParams();
1077
+ Object.entries(params || {}).forEach(([key, value]) => {
1078
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1079
+ });
1080
+ const stringifiedParams = normalizedParams.toString();
1081
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/flow_definitions/${id}?${stringifiedParams}` : `${getProxyPath()}/flow_definitions/${id}`;
1004
1082
  };
1005
1083
  /**
1006
1084
  * Update a flow definition by id
1007
1085
  * @summary Update a flow definition by id
1008
1086
  */
1009
- const updateFlowDefinition = async (id, updateFlowDefinitionBody, options) => {
1010
- return customFetch(getUpdateFlowDefinitionUrl(id), {
1087
+ const updateFlowDefinition = async (id, updateFlowDefinitionBody, params, options) => {
1088
+ return customFetch(getUpdateFlowDefinitionUrl(id, params), {
1011
1089
  ...options,
1012
1090
  method: "PATCH",
1013
1091
  headers: {
@@ -1017,15 +1095,20 @@ const updateFlowDefinition = async (id, updateFlowDefinitionBody, options) => {
1017
1095
  body: JSON.stringify(updateFlowDefinitionBody)
1018
1096
  });
1019
1097
  };
1020
- const getDeleteFlowDefinitionUrl = (id) => {
1021
- return `${getProxyPath()}/flow_definitions/${id}`;
1098
+ const getDeleteFlowDefinitionUrl = (id, params) => {
1099
+ const normalizedParams = new URLSearchParams();
1100
+ Object.entries(params || {}).forEach(([key, value]) => {
1101
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
1102
+ });
1103
+ const stringifiedParams = normalizedParams.toString();
1104
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/flow_definitions/${id}?${stringifiedParams}` : `${getProxyPath()}/flow_definitions/${id}`;
1022
1105
  };
1023
1106
  /**
1024
1107
  * Delete a flow definition by id
1025
1108
  * @summary Delete a flow definition by id
1026
1109
  */
1027
- const deleteFlowDefinition = async (id, options) => {
1028
- return customFetch(getDeleteFlowDefinitionUrl(id), {
1110
+ const deleteFlowDefinition = async (id, params, options) => {
1111
+ return customFetch(getDeleteFlowDefinitionUrl(id, params), {
1029
1112
  ...options,
1030
1113
  method: "DELETE"
1031
1114
  });
@@ -1123,10 +1206,29 @@ function createApi(apiBase) {
1123
1206
  }
1124
1207
  //#endregion
1125
1208
  //#region ../api/dist/runtime/config.mjs
1126
- let currentProject = null;
1209
+ /**
1210
+ * Slot for the configured project, stored on `globalThis` under a
1211
+ * {@link Symbol.for} key. Every copy of this module evaluated in the
1212
+ * same JS realm resolves the symbol through the global symbol registry
1213
+ * to the same identity, so they all read and write a single slot —
1214
+ * needed because the standalone components bundle inlines its own copy
1215
+ * of this file, and dual-package hazards / monorepo duplicates can load
1216
+ * a second copy alongside the app's. With a module-local `let` each
1217
+ * instance kept its own singleton and `configureZitadel()` calls in one
1218
+ * were invisible to `getZitadelConfig()` calls in another. Sharing is
1219
+ * realm-scoped — separate realms (iframes, Node `vm` contexts, worker
1220
+ * threads) have their own registries and are not unified by this.
1221
+ */
1222
+ const PROJECT_SLOT = Symbol.for("@zitadel/api/config:currentProject");
1223
+ function readSlot() {
1224
+ return globalThis[PROJECT_SLOT] ?? null;
1225
+ }
1127
1226
  /**
1128
1227
  * Per-project API client cache. Ensures `getApi(project)` returns the
1129
1228
  * same instance for the same project handle — no re-wrapping on every call.
1229
+ * Module-local on purpose: keyed by the shared frozen `ZitadelProject`
1230
+ * object identity, so cross-instance reads still resolve through the
1231
+ * same key and at worst memoize once per module instance.
1130
1232
  */
1131
1233
  const apiCache = /* @__PURE__ */ new WeakMap();
1132
1234
  /**
@@ -1151,37 +1253,82 @@ function getApi(project) {
1151
1253
  * has not been called yet.
1152
1254
  */
1153
1255
  function getZitadelConfig() {
1154
- return currentProject;
1256
+ return readSlot();
1155
1257
  }
1156
1258
  //#endregion
1157
- //#region src/orchestrator/api-client.ts
1158
- const apiRequestInit = { credentials: "include" };
1159
- async function startFlow(api, input) {
1160
- return api.createFlow(input, apiRequestInit);
1161
- }
1162
- async function submitStep(api, id, body) {
1163
- try {
1164
- return await api.submitFlowStep(id, body, apiRequestInit);
1165
- } catch (error) {
1166
- if (error instanceof ApiError && error.status === 400 && isFlowResponse(error.body)) return error.body;
1167
- throw error;
1259
+ //#region src/orchestrator/resolve-api.ts
1260
+ /** Matches the `configureZitadel()` default so attribute and JS config agree. */
1261
+ const DEFAULT_PROXY_PATH = "/__nextgen";
1262
+ /**
1263
+ * Cache of project handles synthesized from attributes, keyed by their value
1264
+ * tuple. `getApi()` caches its client in a `WeakMap` keyed by the project's
1265
+ * identity, so the same attribute values must yield the *same* frozen object
1266
+ * across the several `resolveApi()` calls a single flow makes — otherwise
1267
+ * every call misses the cache and re-wraps a fresh client. A real page uses a
1268
+ * handful of distinct configs at most; the FIFO bound below is just a guard so
1269
+ * a pathological page that churns through unique configs can't leak memory.
1270
+ */
1271
+ const MAX_SYNTHETIC_PROJECTS = 32;
1272
+ const syntheticProjects = /* @__PURE__ */ new Map();
1273
+ /**
1274
+ * Builds a `ZitadelProject` from declarative attributes, or `undefined` when
1275
+ * no `project-id` was given (nothing to configure). Mirrors
1276
+ * `configureZitadel()`'s proxy-path defaulting so the two config paths are
1277
+ * interchangeable.
1278
+ */
1279
+ function projectFromAttrs({ projectId, proxyPath, url }) {
1280
+ if (!projectId) return void 0;
1281
+ const resolvedProxyPath = proxyPath || DEFAULT_PROXY_PATH;
1282
+ const resolvedUrl = url || void 0;
1283
+ const key = JSON.stringify([
1284
+ projectId,
1285
+ resolvedProxyPath,
1286
+ resolvedUrl ?? ""
1287
+ ]);
1288
+ let project = syntheticProjects.get(key);
1289
+ if (!project) {
1290
+ project = Object.freeze({
1291
+ projectId,
1292
+ proxyPath: resolvedProxyPath,
1293
+ url: resolvedUrl
1294
+ });
1295
+ if (syntheticProjects.size >= MAX_SYNTHETIC_PROJECTS) {
1296
+ const oldest = syntheticProjects.keys().next().value;
1297
+ if (oldest !== void 0) syntheticProjects.delete(oldest);
1298
+ }
1299
+ syntheticProjects.set(key, project);
1168
1300
  }
1169
- }
1170
- function isFlowResponse(body) {
1171
- return typeof body === "object" && body !== null && "step" in body;
1172
- }
1173
- async function getCurrentStep(api, id) {
1174
- return api.getFlowStep(id, apiRequestInit);
1301
+ return project;
1175
1302
  }
1176
1303
  /**
1177
- * Exchange a terminal-flow `handoff_token` for an authenticated session.
1178
- * The server sets the `__nextgen_session` HttpOnly cookie on success.
1304
+ * Resolves the effective SDK project handle and its typed API client for an
1305
+ * orchestrator element. Precedence, highest first:
1179
1306
  *
1180
- * Uses the generated `exchangeHandoff` client which handles the
1181
- * `project_id` query parameter via {@link ExchangeHandoffParams}.
1307
+ * 1. the element's `project` property (an SDK handle set from JS / a framework),
1308
+ * 2. the global handle from `configureZitadel()`,
1309
+ * 3. the `project-id` / `proxy-path` / `url` attributes set declaratively in HTML.
1310
+ *
1311
+ * Both JS paths (property and global) win over the declarative attributes, so a
1312
+ * deliberate `configureZitadel()` is never silently overridden by fallback or
1313
+ * stale HTML attributes; the attributes are the no-JS fallback.
1314
+ *
1315
+ * Both `<zitadel-login>` and `<zitadel-logout>` need the same resolution and
1316
+ * the same "no config" failure, so it lives here rather than being copied
1317
+ * into each element. Callers run this inside their try/catch so a missing
1318
+ * configuration surfaces through the element's normal error path rather than
1319
+ * as an unhandled rejection.
1320
+ *
1321
+ * @param project Optional per-element override handle.
1322
+ * @param attrs Declarative config read from the element's attributes.
1323
+ * @param element Tag name used in the thrown error (e.g. `<zitadel-login>`).
1182
1324
  */
1183
- async function exchangeSession(api, body, params) {
1184
- return api.exchangeHandoff(body, params, apiRequestInit);
1325
+ function resolveApi(project, attrs, element) {
1326
+ const cfg = project ?? getZitadelConfig() ?? projectFromAttrs(attrs);
1327
+ if (!cfg) throw new Error(`${element} requires a configured project: set the \`project-id\` attribute, set the \`project\` property, or call configureZitadel().`);
1328
+ return {
1329
+ project: cfg,
1330
+ api: getApi(cfg)
1331
+ };
1185
1332
  }
1186
1333
  //#endregion
1187
1334
  //#region src/orchestrator/branding-to-tokens.ts
@@ -1451,6 +1598,19 @@ function applyFontUrl(shadowRoot, fontUrl) {
1451
1598
  shadowRoot.prepend(link);
1452
1599
  }
1453
1600
  //#endregion
1601
+ //#region src/internal/escape-html.ts
1602
+ /**
1603
+ * Escapes the five HTML-significant characters so a string is safe to
1604
+ * interpolate into either element text or a double-quoted attribute value.
1605
+ *
1606
+ * Used for the orchestrator-owned attribution markup, which is appended after
1607
+ * the Liquid output has already been sanitised — so it can't rely on the
1608
+ * DOMPurify pass and must escape its own (tenant-supplied) values.
1609
+ */
1610
+ function escapeHtml(value) {
1611
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1612
+ }
1613
+ //#endregion
1454
1614
  //#region src/orchestrator/mandatory-gates.ts
1455
1615
  const MANDATORY_GATES_MARKER = "ZL_MANDATORY_GATES";
1456
1616
  const mandatoryGatesMarkerComment = `<!--${MANDATORY_GATES_MARKER}-->`;
@@ -1718,6 +1878,9 @@ const en = {
1718
1878
  "register.field.email.placeholder": "you@company.com",
1719
1879
  "register.field.password": "Password",
1720
1880
  "register.field.password.help": "At least 8 characters, including a symbol and number.",
1881
+ "register.field.givenName": "Given name",
1882
+ "register.field.familyName": "Family name",
1883
+ "register.field.dateOfBirth": "Date of birth",
1721
1884
  "register.action.password": "Continue with password",
1722
1885
  "register.action.passkey": "Register with a passkey",
1723
1886
  "register.action.submit": "Sign up",
@@ -2175,6 +2338,27 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2175
2338
  set project(value) {
2176
2339
  this.#_project_accessor_storage = value;
2177
2340
  }
2341
+ #_projectId_accessor_storage = "";
2342
+ get projectId() {
2343
+ return this.#_projectId_accessor_storage;
2344
+ }
2345
+ set projectId(value) {
2346
+ this.#_projectId_accessor_storage = value;
2347
+ }
2348
+ #_proxyPath_accessor_storage = "";
2349
+ get proxyPath() {
2350
+ return this.#_proxyPath_accessor_storage;
2351
+ }
2352
+ set proxyPath(value) {
2353
+ this.#_proxyPath_accessor_storage = value;
2354
+ }
2355
+ #_url_accessor_storage = "";
2356
+ get url() {
2357
+ return this.#_url_accessor_storage;
2358
+ }
2359
+ set url(value) {
2360
+ this.#_url_accessor_storage = value;
2361
+ }
2178
2362
  #_postSignInUrl_accessor_storage = "";
2179
2363
  get postSignInUrl() {
2180
2364
  return this.#_postSignInUrl_accessor_storage;
@@ -2307,10 +2491,21 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2307
2491
  }
2308
2492
  updated(changed) {
2309
2493
  if (!changed.has("response")) return;
2310
- requestAnimationFrame(() => {
2311
- this.applyValuesToFields();
2312
- this.moveFocusToFirstField();
2313
- });
2494
+ this.hydrateStepAfterRender();
2495
+ }
2496
+ /**
2497
+ * Apply captured values and move focus once the new step has fully
2498
+ * rendered. This commit produces the step's `zl-field`/`zl-button` atoms,
2499
+ * but those render their own shadow DOM on a later microtask — so await
2500
+ * this element's update *and* the child atoms' first render before touching
2501
+ * them, rather than guessing a frame with `requestAnimationFrame`.
2502
+ */
2503
+ async hydrateStepAfterRender() {
2504
+ await this.updateComplete;
2505
+ const atoms = this.shadowRoot?.querySelectorAll("zl-field, zl-button");
2506
+ if (atoms) await Promise.all(Array.from(atoms).map((atom) => atom.updateComplete));
2507
+ this.applyValuesToFields();
2508
+ this.moveFocusToFirstField();
2314
2509
  }
2315
2510
  render() {
2316
2511
  if (this.startupError) return html`<form class="zl-mount" novalidate>
@@ -2334,6 +2529,10 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2334
2529
  * Figma sign-in frame where the pill sits 24px below the card, both
2335
2530
  * centred on the page). It can't be a sibling of the page-shell because
2336
2531
  * the page-shell already occupies the full viewport height.
2532
+ *
2533
+ * This markup is appended AFTER `renderStep` has sanitised the Liquid
2534
+ * output, so it is not run through DOMPurify. It is orchestrator-owned and
2535
+ * any tenant-supplied values (`custom_link`) are escaped via `escapeHtml`.
2337
2536
  */
2338
2537
  injectAttribution(rendered) {
2339
2538
  const html = this.renderAttributionHtml();
@@ -2353,23 +2552,28 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2353
2552
  const show = attribution?.show_zitadel !== false;
2354
2553
  const custom = attribution?.custom_link;
2355
2554
  if (!show && !custom) return "";
2356
- if (custom) return `<div slot="footer" part="attribution" class="zl-attribution"><zl-pill tone="neutral" href="${String(custom.href).replace(/"/g, "&quot;")}">${String(custom.label).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</zl-pill></div>`;
2555
+ if (custom) return `<div slot="footer" part="attribution" class="zl-attribution"><zl-pill tone="neutral" href="${escapeHtml(String(custom.href))}">${escapeHtml(String(custom.label))}</zl-pill></div>`;
2357
2556
  return `<div slot="footer" part="attribution" class="zl-attribution"><zl-pill tone="neutral" href="https://zitadel.com" part="attribution-pill" aria-label="Secured with Zitadel">${zitadelAttributionPillInnerHtml()}</zl-pill></div>`;
2358
2557
  }
2558
+ /** Declarative config read from this element's attributes. */
2559
+ get projectAttrs() {
2560
+ return {
2561
+ projectId: this.projectId,
2562
+ proxyPath: this.proxyPath,
2563
+ url: this.url
2564
+ };
2565
+ }
2359
2566
  async startFlow() {
2360
- const cfg = this.project ?? getZitadelConfig();
2361
- const projectId = cfg?.projectId || "";
2362
- if (!cfg) throw new Error("<zitadel-login> requires a `config` prop (from configureZitadel()) or configureZitadel() must be called before use.");
2363
- const api = getApi(cfg);
2364
2567
  this.loading = true;
2365
2568
  this.startupError = null;
2366
2569
  try {
2570
+ const { project: cfg, api } = resolveApi(this.project, this.projectAttrs, "<zitadel-login>");
2367
2571
  let wire;
2368
2572
  if (this.resumeFlowId) wire = await getCurrentStep(api, this.resumeFlowId);
2369
2573
  else {
2370
- if (!projectId) throw new Error("<zitadel-login> requires a `project-id` attribute (or configureZitadel()) to start a flow.");
2574
+ if (!cfg.projectId) throw new Error("<zitadel-login> requires a project id (the `project-id` attribute, `configureZitadel({ projectId })`, or a `project` handle) to start a flow.");
2371
2575
  wire = await startFlow(api, {
2372
- project_id: projectId,
2576
+ project_id: cfg.projectId,
2373
2577
  purpose: this.purpose
2374
2578
  });
2375
2579
  }
@@ -2407,16 +2611,12 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2407
2611
  async maybeCompleteFlow(response) {
2408
2612
  const behavior = response.step.complete;
2409
2613
  if (!behavior) return;
2410
- this.dispatchEvent(new CustomEvent("zitadel-flow-complete", {
2411
- bubbles: true,
2412
- composed: true,
2413
- detail: {
2414
- behavior,
2415
- redirect_uri: response.redirect_uri,
2416
- handoff_token: response.handoff_token,
2417
- handoff_token_expires_at: response.handoff_token_expires_at
2418
- }
2419
- }));
2614
+ emit(this, "zitadel-flow-complete", {
2615
+ behavior,
2616
+ redirect_uri: response.redirect_uri,
2617
+ handoff_token: response.handoff_token,
2618
+ handoff_token_expires_at: response.handoff_token_expires_at
2619
+ });
2420
2620
  if (typeof window === "undefined") return;
2421
2621
  if (behavior === "redirect" && response.redirect_uri) {
2422
2622
  window.location.assign(response.redirect_uri);
@@ -2426,9 +2626,8 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2426
2626
  if (behavior === "show" && handoffToken && this.postSignInUrl) {
2427
2627
  this.loading = true;
2428
2628
  try {
2429
- const cfg = this.project ?? getZitadelConfig();
2430
- if (!cfg) throw new Error("<zitadel-login> config is required for exchange.");
2431
- await exchangeSession(getApi(cfg), { handoff_token: handoffToken }, { project_id: cfg.projectId });
2629
+ const { project: cfg, api } = resolveApi(this.project, this.projectAttrs, "<zitadel-login>");
2630
+ await exchangeSession(api, { handoff_token: handoffToken }, { project_id: cfg.projectId });
2432
2631
  window.location.assign(this.postSignInUrl);
2433
2632
  } catch (error) {
2434
2633
  this.handleTransportError(error);
@@ -2514,14 +2713,10 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2514
2713
  ...this.formValues,
2515
2714
  [name]: value
2516
2715
  };
2517
- this.dispatchEvent(new CustomEvent("zitadel-flow-input", {
2518
- bubbles: true,
2519
- composed: true,
2520
- detail: {
2521
- name,
2522
- value
2523
- }
2524
- }));
2716
+ emit(this, "zitadel-flow-input", {
2717
+ name,
2718
+ value
2719
+ });
2525
2720
  };
2526
2721
  handleAtomSubmit = (event) => {
2527
2722
  if (this.loading) return;
@@ -2592,10 +2787,8 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2592
2787
  moveFocusToFirstField() {
2593
2788
  const root = this.shadowRoot;
2594
2789
  if (!root) return;
2595
- requestAnimationFrame(() => {
2596
- const focusables = root.querySelectorAll("zl-field, zl-button");
2597
- Array.from(focusables).find((el) => !el.hasAttribute("disabled"))?.focus();
2598
- });
2790
+ const focusables = root.querySelectorAll("zl-field, zl-button");
2791
+ Array.from(focusables).find((el) => !el.hasAttribute("disabled"))?.focus();
2599
2792
  }
2600
2793
  async submit(action, challengeResponse) {
2601
2794
  if (!this.response || this.loading) return;
@@ -2614,15 +2807,10 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2614
2807
  fields,
2615
2808
  ...challengeResponse ? { challenge_response: challengeResponse } : {}
2616
2809
  };
2617
- const cfg = this.project ?? getZitadelConfig();
2618
- if (!cfg) throw new Error("<zitadel-login> config is required for submit.");
2619
- const wire = await submitStep(getApi(cfg), id, body);
2810
+ const { api } = resolveApi(this.project, this.projectAttrs, "<zitadel-login>");
2811
+ const wire = await submitStep(api, id, body);
2620
2812
  this.applyResponse(wire);
2621
- this.dispatchEvent(new CustomEvent("zitadel-flow-step", {
2622
- bubbles: true,
2623
- composed: true,
2624
- detail: { step: wire.step }
2625
- }));
2813
+ emit(this, "zitadel-flow-step", { step: wire.step });
2626
2814
  } catch (error) {
2627
2815
  this.handleTransportError(error);
2628
2816
  } finally {
@@ -2633,15 +2821,20 @@ let ZitadelLogin = class ZitadelLogin extends LitElement {
2633
2821
  const message = error instanceof Error ? error.message : "Unexpected error contacting the Flow API.";
2634
2822
  this.startupError = message;
2635
2823
  console.error("[zitadel-login]", error);
2636
- this.dispatchEvent(new CustomEvent("zitadel-flow-error", {
2637
- bubbles: true,
2638
- composed: true,
2639
- detail: { message }
2640
- }));
2824
+ emit(this, "zitadel-flow-error", { message });
2641
2825
  }
2642
2826
  };
2643
2827
  __decorate([property({ type: String })], ZitadelLogin.prototype, "purpose", null);
2644
2828
  __decorate([property({ attribute: false })], ZitadelLogin.prototype, "project", null);
2829
+ __decorate([property({
2830
+ type: String,
2831
+ attribute: "project-id"
2832
+ })], ZitadelLogin.prototype, "projectId", null);
2833
+ __decorate([property({
2834
+ type: String,
2835
+ attribute: "proxy-path"
2836
+ })], ZitadelLogin.prototype, "proxyPath", null);
2837
+ __decorate([property({ type: String })], ZitadelLogin.prototype, "url", null);
2645
2838
  __decorate([property({
2646
2839
  type: String,
2647
2840
  attribute: "post-sign-in-url"
@@ -2812,6 +3005,27 @@ let ZitadelLogout = class ZitadelLogout extends LitElement {
2812
3005
  set project(value) {
2813
3006
  this.#_project_accessor_storage = value;
2814
3007
  }
3008
+ #_projectId_accessor_storage = "";
3009
+ get projectId() {
3010
+ return this.#_projectId_accessor_storage;
3011
+ }
3012
+ set projectId(value) {
3013
+ this.#_projectId_accessor_storage = value;
3014
+ }
3015
+ #_proxyPath_accessor_storage = "";
3016
+ get proxyPath() {
3017
+ return this.#_proxyPath_accessor_storage;
3018
+ }
3019
+ set proxyPath(value) {
3020
+ this.#_proxyPath_accessor_storage = value;
3021
+ }
3022
+ #_url_accessor_storage = "";
3023
+ get url() {
3024
+ return this.#_url_accessor_storage;
3025
+ }
3026
+ set url(value) {
3027
+ this.#_url_accessor_storage = value;
3028
+ }
2815
3029
  #_postSignOutUrl_accessor_storage = "";
2816
3030
  get postSignOutUrl() {
2817
3031
  return this.#_postSignOutUrl_accessor_storage;
@@ -2943,13 +3157,20 @@ let ZitadelLogout = class ZitadelLogout extends LitElement {
2943
3157
  * clears the cookie via `Set-Cookie: Max-Age=0`. On success this element fires
2944
3158
  * `zitadel-signout` and optionally navigates to `postSignOutUrl`.
2945
3159
  */
3160
+ /** Declarative config read from this element's attributes. */
3161
+ get projectAttrs() {
3162
+ return {
3163
+ projectId: this.projectId,
3164
+ proxyPath: this.proxyPath,
3165
+ url: this.url
3166
+ };
3167
+ }
2946
3168
  async doLogout() {
2947
3169
  this.loading = true;
2948
3170
  this.errorMessage = "";
2949
3171
  try {
2950
- const cfg = this.project ?? getZitadelConfig();
2951
- if (!cfg) throw new Error("<zitadel-logout> requires a `config` prop (from configureZitadel()).");
2952
- await getApi(cfg).revokeMySession({ credentials: "include" });
3172
+ const { api } = resolveApi(this.project, this.projectAttrs, "<zitadel-logout>");
3173
+ await api.revokeMySession({ credentials: "include" });
2953
3174
  } catch (error) {
2954
3175
  const message = error instanceof Error ? error.message : "";
2955
3176
  this.errorMessage = message || "Sign-out failed. Please try again.";
@@ -2958,15 +3179,10 @@ let ZitadelLogout = class ZitadelLogout extends LitElement {
2958
3179
  }
2959
3180
  this.open = false;
2960
3181
  this.loading = false;
2961
- const detail = {
3182
+ emit(this, "zitadel-signout", {
2962
3183
  name: this.displayName,
2963
3184
  email: this.displayEmail
2964
- };
2965
- this.dispatchEvent(new CustomEvent("zitadel-signout", {
2966
- bubbles: true,
2967
- composed: true,
2968
- detail
2969
- }));
3185
+ });
2970
3186
  if (this.postSignOutUrl && typeof window !== "undefined") window.location.href = this.postSignOutUrl;
2971
3187
  }
2972
3188
  /**
@@ -2980,9 +3196,8 @@ let ZitadelLogout = class ZitadelLogout extends LitElement {
2980
3196
  ...this.clientId ? { client_id: this.clientId } : {},
2981
3197
  ...this.postSignOutUrl ? { post_logout_redirect_uri: this.postSignOutUrl } : {}
2982
3198
  };
2983
- const cfg = this.project ?? getZitadelConfig();
2984
- if (!cfg) throw new Error("<zitadel-logout> requires a `config` prop (from configureZitadel()).");
2985
- return getApi(cfg).getEndSessionUrl(params);
3199
+ const { api } = resolveApi(this.project, this.projectAttrs, "<zitadel-logout>");
3200
+ return api.getEndSessionUrl(params);
2986
3201
  }
2987
3202
  handleSignOutClick(event) {
2988
3203
  event.preventDefault();
@@ -3047,6 +3262,15 @@ let ZitadelLogout = class ZitadelLogout extends LitElement {
3047
3262
  }
3048
3263
  };
3049
3264
  __decorate([property({ attribute: false })], ZitadelLogout.prototype, "project", null);
3265
+ __decorate([property({
3266
+ type: String,
3267
+ attribute: "project-id"
3268
+ })], ZitadelLogout.prototype, "projectId", null);
3269
+ __decorate([property({
3270
+ type: String,
3271
+ attribute: "proxy-path"
3272
+ })], ZitadelLogout.prototype, "proxyPath", null);
3273
+ __decorate([property({ type: String })], ZitadelLogout.prototype, "url", null);
3050
3274
  __decorate([property({
3051
3275
  type: String,
3052
3276
  attribute: "post-sign-out-url"
@@ -3077,4 +3301,4 @@ function fillTemplateTokens(fragment, name, email, initial) {
3077
3301
  //#endregion
3078
3302
  export { buildBrandingStylesheet as _, createSanitiser as a, startFlow as b, de as c, MANDATORY_GATES_MARKER as d, mandatoryGatesMarkerComment as f, applyBrandingTokens as g, validateBranding as h, layout_chrome_default as i, en as l, applyFontUrl as m, ZitadelLogin as n, builtinLocales as o, patchMandatoryGates as p, ThemeController as r, it as s, ZitadelLogout as t, TEMPLATE_NAMES as u, resolveTheme as v, submitStep as x, getCurrentStep as y };
3079
3303
 
3080
- //# sourceMappingURL=orchestrator-B8eXcPRi.mjs.map
3304
+ //# sourceMappingURL=orchestrator-Dds72XrU.mjs.map