@zitadel/components 0.1.0-alpha.12 → 0.1.0-alpha.14

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.
@@ -3395,6 +3395,21 @@ async function getCurrentStep(api, id) {
3395
3395
  async function exchangeSession(api, body, params) {
3396
3396
  return api.exchangeHandoff(body, params, apiRequestInit);
3397
3397
  }
3398
+ /**
3399
+ * Reads the current session (`GET /sessions/me`) with credentials so the
3400
+ * `__nextgen_session` cookie authenticates the request. Used by the
3401
+ * orchestrator's signed-in surfaces to render the user's identity.
3402
+ */
3403
+ async function getSession$1(api) {
3404
+ return await api.getMySession(apiRequestInit);
3405
+ }
3406
+ /**
3407
+ * Revokes the current session (`DELETE /sessions/me`) with credentials. The
3408
+ * server deletes the session and clears the cookie via `Set-Cookie: Max-Age=0`.
3409
+ */
3410
+ async function revokeSession$1(api) {
3411
+ await api.revokeMySession(apiRequestInit);
3412
+ }
3398
3413
  //#endregion
3399
3414
  //#region ../api/dist/runtime/base-url.mjs
3400
3415
  let proxyPath = "";
@@ -3483,6 +3498,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
3483
3498
  getIssueChallengeUrl: () => getIssueChallengeUrl,
3484
3499
  getKeys: () => getKeys,
3485
3500
  getListFlowDefinitionsUrl: () => getListFlowDefinitionsUrl,
3501
+ getListSchemasUrl: () => getListSchemasUrl,
3486
3502
  getListSessionsUrl: () => getListSessionsUrl,
3487
3503
  getListUsersUrl: () => getListUsersUrl,
3488
3504
  getLive: () => getLive,
@@ -3508,6 +3524,7 @@ var zitadelNextGen_exports = /* @__PURE__ */ __exportAll({
3508
3524
  introspect: () => introspect,
3509
3525
  issueChallenge: () => issueChallenge,
3510
3526
  listFlowDefinitions: () => listFlowDefinitions,
3527
+ listSchemas: () => listSchemas,
3511
3528
  listSessions: () => listSessions,
3512
3529
  listUsers: () => listUsers,
3513
3530
  revokeMySession: () => revokeMySession,
@@ -4265,6 +4282,26 @@ const createSchema = async (createSchemaBody, params, options) => {
4265
4282
  body: JSON.stringify(createSchemaBody)
4266
4283
  });
4267
4284
  };
4285
+ const getListSchemasUrl = (params) => {
4286
+ const normalizedParams = new URLSearchParams();
4287
+ Object.entries(params || {}).forEach(([key, value]) => {
4288
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
4289
+ });
4290
+ const stringifiedParams = normalizedParams.toString();
4291
+ return stringifiedParams.length > 0 ? `${getProxyPath()}/schemas?${stringifiedParams}` : `${getProxyPath()}/schemas`;
4292
+ };
4293
+ /**
4294
+ * Retrieve a list of all schemas available in the system. This endpoint
4295
+ supports pagination and filtering based on schema attributes.
4296
+
4297
+ * @summary List all schemas
4298
+ */
4299
+ const listSchemas = async (params, options) => {
4300
+ return customFetch(getListSchemasUrl(params), {
4301
+ ...options,
4302
+ method: "GET"
4303
+ });
4304
+ };
4268
4305
  const getGetSchemaByIdUrl = (id, params) => {
4269
4306
  const normalizedParams = new URLSearchParams();
4270
4307
  Object.entries(params || {}).forEach(([key, value]) => {
@@ -9469,7 +9506,7 @@ function lookup(locale, key) {
9469
9506
  }
9470
9507
  //#endregion
9471
9508
  //#region src/orchestrator/templates/default.liquid
9472
- var default_default = "<zl-page-shell data-zl-template-root>\n {% if branding.logo_url %}\n <img slot=\"header\" class=\"zl-card-logo\" src=\"{{ branding.logo_url }}\" alt=\"\" />\n {% endif %}\n <zl-card>\n <h1 slot=\"header\" class=\"zl-card-title\">{{ step.texts.title_key | t: identity.display_name }}</h1>\n {% if step.texts.description_key %}\n {% assign card_subtitle = step.texts.description_key | t: identity.display_name %}\n {% if card_subtitle != \"\" %}\n <p slot=\"header\" class=\"zl-card-subtitle\">{{ card_subtitle }}</p>\n {% endif %}\n {% endif %}\n\n {% if errors and errors.size > 0 %}\n {% for err in errors %}\n {% if err | formLevelError %}\n {% assign alert_heading = err.text_key | alertHeading %}\n {% assign alert_body = err.text_key | alertBody %}\n <zl-alert severity=\"error\"{% if alert_heading != \"\" %} heading=\"{{ alert_heading | t }}\"{% endif %}>\n {% if alert_body != \"\" %}{{ alert_body | t }}{% elsif err.text_key %}{{ err.text_key | t }}{% else %}{{ err.message }}{% endif %}\n </zl-alert>\n {% endif %}\n {% endfor %}\n {% endif %}\n\n {% for f in fields %}\n {% assign field_placeholder = f.text_key | fieldPlaceholder %}\n {% assign field_help = f.text_key | fieldHelp %}\n {% assign field_err = f.name | fieldError: errors %}\n {% case f.type %}\n {% when 'checkbox' %}\n <zl-checkbox\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n value=\"true\"\n {% if f.value %}checked{% endif %}\n {% if f.required %}required{% endif %}\n ></zl-checkbox>\n {% when 'select' %}\n <zl-select\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n value=\"{{ f.value }}\"\n options='{{ f.validation.enum | selectOptions | json }}'\n {% if f.required %}required{% endif %}\n {% if field_placeholder != \"\" %}placeholder=\"{{ field_placeholder }}\"{% endif %}\n ></zl-select>\n {% else %}\n {% assign autocomplete_val = '' %}\n {% if f.name == 'email' %}\n {% assign autocomplete_val = 'email' %}\n {% elsif f.type == 'password' and step.name contains 'register' %}\n {% assign autocomplete_val = 'new-password' %}\n {% elsif f.type == 'password' %}\n {% assign autocomplete_val = 'current-password' %}\n {% endif %}\n <zl-field\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n type=\"{{ f.type }}\"\n value=\"{{ f.value }}\"\n {% if autocomplete_val != '' %}autocomplete=\"{{ autocomplete_val }}\"{% endif %}\n {% if f.required %}required{% endif %}\n {% if field_placeholder != \"\" %}placeholder=\"{{ field_placeholder }}\"{% endif %}\n {% if field_err != \"\" %}invalid error=\"{{ field_err }}\"{% endif %}\n >\n {% if field_help != \"\" %}\n <span slot=\"help\">{{ field_help }}</span>\n {% endif %}\n </zl-field>\n {% endcase %}\n {% endfor %}\n\n {% assign recover = actions | where: \"name\", \"recover\" | first %}\n {% if recover %}\n <p class=\"zl-card-forgot\">\n <a href=\"#\" class=\"zl-card-forgot__link\" data-action=\"recover\">{{ recover.text_key | t }}</a>\n </p>\n {% endif %}\n\n {% for a in actions %}\n {% if a.primary %}\n <zl-button\n hierarchy=\"primary\"\n size=\"medium\"\n type=\"submit\"\n block\n action=\"{{ a.name }}\"\n data-testid=\"zitadel-action-{{ a.name }}\"\n label=\"{{ a.text_key | t }}\"\n {% if loading %}loading{% endif %}\n ></zl-button>\n {% endif %}\n {% endfor %}\n\n {% for a in actions %}\n {% unless a.primary or a.name == 'passkey' or a.name == 'register' or a.name == 'sign_in' or a.name == 'recover' %}\n <zl-button\n hierarchy=\"secondary\"\n size=\"medium\"\n type=\"button\"\n block\n action=\"{{ a.name }}\"\n data-testid=\"zitadel-action-{{ a.name }}\"\n label=\"{{ a.text_key | t }}\"\n ></zl-button>\n {% endunless %}\n {% endfor %}\n\n {% assign passkey = actions | where: \"name\", \"passkey\" | first %}\n {% if passkey %}\n <zl-button\n hierarchy=\"secondary\"\n size=\"medium\"\n block\n action=\"passkey\"\n data-testid=\"zitadel-action-passkey\"\n label=\"{{ passkey.text_key | t }}\"\n ></zl-button>\n {% endif %}\n\n\n {% assign register = actions | where: \"name\", \"register\" | first %}\n {% if register %}\n <p class=\"zl-card-nav\">\n {{ 'identifier.action.register.lead' | t }}<a href=\"#\" class=\"zl-card-nav__link\" data-action=\"register\" data-testid=\"zitadel-action-register-link\">{{ 'identifier.action.register.link' | t }}</a>\n </p>\n {% endif %}\n\n {% assign sign_in = actions | where: \"name\", \"sign_in\" | first %}\n {% if sign_in %}\n <p class=\"zl-card-nav\">\n {{ 'register.action.sign_in.lead' | t }}<a href=\"#\" class=\"zl-card-nav__link\" data-action=\"sign_in\" data-testid=\"zitadel-action-sign_in-link\">{{ 'register.action.sign_in.link' | t }}</a>\n </p>\n {% endif %}\n\n {% if challenge %}\n {% if challenge.method == \"passkey\" or challenge.method == \"passkey_register\" %}\n {% assign ceremony = \"authenticate\" %}\n {% if challenge.method == \"passkey_register\" %}{% assign ceremony = \"register\" %}{% endif %}\n <zl-passkey\n ceremony=\"{{ ceremony }}\"\n method=\"{{ challenge.method }}\"\n challenge-id=\"{{ challenge.challenge_id }}\"\n options='{{ challenge.options | json }}'\n ></zl-passkey>\n {% endif %}\n {% endif %}\n\n {% mandatory_gates %}\n </zl-card>\n</zl-page-shell>\n";
9509
+ var default_default = "<zl-page-shell data-zl-template-root>\n {% if branding.logo_url %}\n <img slot=\"header\" class=\"zl-card-logo\" src=\"{{ branding.logo_url }}\" alt=\"\" />\n {% endif %}\n <zl-card>\n <h1 slot=\"header\" class=\"zl-card-title\">{{ step.texts.title_key | t: identity.display_name }}</h1>\n {% if step.texts.description_key %}\n {% assign card_subtitle = step.texts.description_key | t: identity.display_name %}\n {% if card_subtitle != \"\" %}\n <p slot=\"header\" class=\"zl-card-subtitle\">{{ card_subtitle }}</p>\n {% endif %}\n {% endif %}\n\n {% if errors and errors.size > 0 %}\n {% for err in errors %}\n {% if err | formLevelError %}\n {% assign alert_heading = err.text_key | alertHeading %}\n {% assign alert_body = err.text_key | alertBody %}\n <zl-alert severity=\"error\"{% if alert_heading != \"\" %} heading=\"{{ alert_heading | t }}\"{% endif %}>\n {% if alert_body != \"\" %}{{ alert_body | t }}{% elsif err.text_key %}{{ err.text_key | t }}{% else %}{{ err.message }}{% endif %}\n </zl-alert>\n {% endif %}\n {% endfor %}\n {% endif %}\n\n {% for f in fields %}\n {% assign field_placeholder = f.text_key | fieldPlaceholder %}\n {% assign field_help = f.text_key | fieldHelp %}\n {% assign field_err = f.name | fieldError: errors %}\n {% case f.type %}\n {% when 'checkbox' %}\n <zl-checkbox\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n value=\"true\"\n {% if f.value %}checked{% endif %}\n {% if f.required %}required{% endif %}\n ></zl-checkbox>\n {% when 'select' %}\n <zl-select\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n value=\"{{ f.value }}\"\n options='{{ f.validation.enum | selectOptions | json }}'\n {% if f.required %}required{% endif %}\n {% if field_placeholder != \"\" %}placeholder=\"{{ field_placeholder }}\"{% endif %}\n ></zl-select>\n {% else %}\n {% assign autocomplete_val = '' %}\n {% if f.name == 'email' %}\n {% assign autocomplete_val = 'email' %}\n {% elsif f.type == 'password' and step.name contains 'register' %}\n {% assign autocomplete_val = 'new-password' %}\n {% elsif f.type == 'password' %}\n {% assign autocomplete_val = 'current-password' %}\n {% endif %}\n <zl-field\n name=\"{{ f.name }}\"\n data-testid=\"zitadel-field-{{ f.name }}\"\n label=\"{{ f.text_key | t }}\"\n type=\"{{ f.type }}\"\n value=\"{{ f.value }}\"\n {% if autocomplete_val != '' %}autocomplete=\"{{ autocomplete_val }}\"{% endif %}\n {% if f.required %}required{% endif %}\n {% if field_placeholder != \"\" %}placeholder=\"{{ field_placeholder }}\"{% endif %}\n {% if field_err != \"\" %}invalid error=\"{{ field_err }}\"{% endif %}\n >\n {% if field_help != \"\" %}\n <span slot=\"help\">{{ field_help }}</span>\n {% endif %}\n </zl-field>\n {% endcase %}\n {% endfor %}\n\n {% assign recover = actions | where: \"name\", \"recover\" | first %}\n {% if recover %}\n <p class=\"zl-card-forgot\">\n <a href=\"#\" class=\"zl-card-forgot__link\" data-action=\"recover\">{{ recover.text_key | t }}</a>\n </p>\n {% endif %}\n\n {% for a in actions %}\n {% if a.primary %}\n <zl-button\n hierarchy=\"primary\"\n size=\"medium\"\n type=\"submit\"\n block\n action=\"{{ a.name }}\"\n data-testid=\"zitadel-action-{{ a.name }}\"\n label=\"{{ a.text_key | t }}\"\n {% if loading %}loading{% endif %}\n ></zl-button>\n {% endif %}\n {% endfor %}\n\n {% for a in actions %}\n {% unless a.primary or a.name == 'passkey' or a.name == 'register' or a.name == 'sign_in' or a.name == 'recover' %}\n <zl-button\n hierarchy=\"secondary\"\n size=\"medium\"\n type=\"button\"\n block\n action=\"{{ a.name }}\"\n data-testid=\"zitadel-action-{{ a.name }}\"\n label=\"{{ a.text_key | t }}\"\n ></zl-button>\n {% endunless %}\n {% endfor %}\n\n {% assign passkey = actions | where: \"name\", \"passkey\" | first %}\n {% if passkey %}\n <zl-button\n hierarchy=\"secondary\"\n size=\"medium\"\n block\n action=\"passkey\"\n data-testid=\"zitadel-action-passkey\"\n label=\"{{ passkey.text_key | t }}\"\n ></zl-button>\n {% endif %}\n\n\n {% assign register = actions | where: \"name\", \"register\" | first %}\n {% if register %}\n <p class=\"zl-card-nav\">\n {{ 'identifier.action.register.lead' | t }}<a href=\"#\" class=\"zl-card-nav__link\" data-action=\"register\" data-testid=\"zitadel-action-register-link\">{{ 'identifier.action.register.link' | t }}</a>\n </p>\n {% endif %}\n\n {% assign sign_in = actions | where: \"name\", \"sign_in\" | first %}\n {% if sign_in %}\n <p class=\"zl-card-nav\">\n {{ 'register.action.sign_in.lead' | t }}<a href=\"#\" class=\"zl-card-nav__link\" data-action=\"sign_in\" data-testid=\"zitadel-action-sign_in-link\">{{ 'register.action.sign_in.link' | t }}</a>\n </p>\n {% endif %}\n\n {% if challenge %}\n {% if challenge.method == \"passkey\" or challenge.method == \"passkey_register\" %}\n {% assign ceremony = \"authenticate\" %}\n {% assign submit_method = challenge.method %}\n {% if challenge.method == \"passkey_register\" or challenge.options.user %}\n {% assign ceremony = \"register\" %}\n {% assign submit_method = \"passkey_register\" %}\n {% endif %}\n <zl-passkey\n ceremony=\"{{ ceremony }}\"\n method=\"{{ submit_method }}\"\n challenge-id=\"{{ challenge.challenge_id }}\"\n options='{{ challenge.options | json }}'\n ></zl-passkey>\n {% endif %}\n {% endif %}\n\n {% mandatory_gates %}\n </zl-card>\n</zl-page-shell>\n";
9473
9510
  //#endregion
9474
9511
  //#region src/orchestrator/liquid.ts
9475
9512
  /**
@@ -9654,6 +9691,7 @@ const en = {
9654
9691
  "register-password.description": "Choose a secure password for your account",
9655
9692
  "register-password.field.password": "Password",
9656
9693
  "register-password.action.submit": "Sign up",
9694
+ "register-password.action.back": "Back",
9657
9695
  "passkey-upsell.title": "Sign in faster next time",
9658
9696
  "passkey-upsell.description": "No password needed ever again.",
9659
9697
  "passkey-upsell.description.line1": "No password needed ever again.",
@@ -9676,6 +9714,7 @@ const en = {
9676
9714
  "password.field.password": "Password",
9677
9715
  "password.action.signin": "Sign in",
9678
9716
  "password.action.passkey": "Sign in with a passkey",
9717
+ "password.action.back": "Back",
9679
9718
  "password.action.register.lead": "Don't have an account? ",
9680
9719
  "password.action.register.link": "Sign up",
9681
9720
  "register.title": "Create your account",
@@ -9692,11 +9731,12 @@ const en = {
9692
9731
  "register.action.password": "Continue with password",
9693
9732
  "register.action.passkey": "Continue with a passkey",
9694
9733
  "register.action.submit": "Sign up",
9734
+ "register.action.back": "Back",
9695
9735
  "register.action.sign_in.lead": "Already have an account? ",
9696
9736
  "register.action.sign_in.link": "Sign in",
9697
9737
  "complete.title": "You're signed in as",
9698
9738
  "signed-in.continue": "Continue",
9699
- "signed-in.logout": "Logout",
9739
+ "signed-in.logout": "Sign out",
9700
9740
  "passkey-login.title": "Sign in with your passkey",
9701
9741
  "recover.title": "Check your email",
9702
9742
  "recover.description": "We sent a password reset link to your email address.",
@@ -9753,6 +9793,7 @@ const de = {
9753
9793
  "register-password.description": "Wähle ein sicheres Passwort für dein Konto",
9754
9794
  "register-password.field.password": "Passwort",
9755
9795
  "register-password.action.submit": "Registrieren",
9796
+ "register-password.action.back": "Zurück",
9756
9797
  "passkey-upsell.title": "Nächstes Mal schneller anmelden",
9757
9798
  "passkey-upsell.description": "Kein Passwort mehr nötig.",
9758
9799
  "passkey-upsell.description.line1": "Kein Passwort mehr nötig.",
@@ -9775,6 +9816,7 @@ const de = {
9775
9816
  "password.field.password": "Passwort",
9776
9817
  "password.action.signin": "Anmelden",
9777
9818
  "password.action.passkey": "Mit Passkey anmelden",
9819
+ "password.action.back": "Zurück",
9778
9820
  "password.action.register.lead": "Noch kein Konto? ",
9779
9821
  "password.action.register.link": "Registrieren",
9780
9822
  "register.title": "Konto erstellen",
@@ -9791,6 +9833,7 @@ const de = {
9791
9833
  "register.action.password": "Mit Passwort fortfahren",
9792
9834
  "register.action.passkey": "Weiter mit Passkey",
9793
9835
  "register.action.submit": "Registrieren",
9836
+ "register.action.back": "Zurück",
9794
9837
  "register.action.sign_in.lead": "Bereits ein Konto? ",
9795
9838
  "register.action.sign_in.link": "Anmelden",
9796
9839
  "complete.title": "Du bist angemeldet als",
@@ -9854,6 +9897,7 @@ const builtinLocales = {
9854
9897
  "register-password.description": "Scegli una password sicura per il tuo account",
9855
9898
  "register-password.field.password": "Password",
9856
9899
  "register-password.action.submit": "Registrati",
9900
+ "register-password.action.back": "Indietro",
9857
9901
  "passkey-upsell.title": "Accedi più velocemente la prossima volta",
9858
9902
  "passkey-upsell.description": "Nessuna password necessaria.",
9859
9903
  "passkey-upsell.description.line1": "Nessuna password necessaria.",
@@ -9876,6 +9920,7 @@ const builtinLocales = {
9876
9920
  "password.field.password": "Password",
9877
9921
  "password.action.signin": "Accedi",
9878
9922
  "password.action.passkey": "Accedi con passkey",
9923
+ "password.action.back": "Indietro",
9879
9924
  "password.action.register.lead": "Non hai un account? ",
9880
9925
  "password.action.register.link": "Registrati",
9881
9926
  "register.title": "Crea il tuo account",
@@ -9892,6 +9937,7 @@ const builtinLocales = {
9892
9937
  "register.action.password": "Continua con password",
9893
9938
  "register.action.passkey": "Continua con passkey",
9894
9939
  "register.action.submit": "Registrati",
9940
+ "register.action.back": "Indietro",
9895
9941
  "register.action.sign_in.lead": "Hai già un account? ",
9896
9942
  "register.action.sign_in.link": "Accedi",
9897
9943
  "complete.title": "Sei connesso come",
@@ -12173,7 +12219,7 @@ let ZitadelLogin = class ZitadelLogin extends i$2 {
12173
12219
  actions,
12174
12220
  gates: step.gates ?? {},
12175
12221
  sso_providers: step.sso_providers ?? [],
12176
- challenge: step.challenge ?? null,
12222
+ challenge: this.loading ? null : step.challenge ?? null,
12177
12223
  messages: [],
12178
12224
  identity: this.deriveIdentity(),
12179
12225
  errors,
@@ -12421,7 +12467,6 @@ function collectInitialValues(step) {
12421
12467
  }
12422
12468
  //#endregion
12423
12469
  //#region src/orchestrator/zitadel-logout.ts
12424
- const DISPLAY_COOKIE_NAME = "__nextgen_display";
12425
12470
  let ZitadelLogout = class ZitadelLogout extends i$2 {
12426
12471
  static styles = [baseHostStyles, i$5`
12427
12472
  :host {
@@ -12616,6 +12661,13 @@ let ZitadelLogout = class ZitadelLogout extends i$2 {
12616
12661
  set displayEmail(value) {
12617
12662
  this.#_displayEmail_accessor_storage = value;
12618
12663
  }
12664
+ #_displayUserId_accessor_storage = "";
12665
+ get displayUserId() {
12666
+ return this.#_displayUserId_accessor_storage;
12667
+ }
12668
+ set displayUserId(value) {
12669
+ this.#_displayUserId_accessor_storage = value;
12670
+ }
12619
12671
  #_open_accessor_storage = false;
12620
12672
  get open() {
12621
12673
  return this.#_open_accessor_storage;
@@ -12638,17 +12690,21 @@ let ZitadelLogout = class ZitadelLogout extends i$2 {
12638
12690
  this.#_errorMessage_accessor_storage = value;
12639
12691
  }
12640
12692
  templateMode = false;
12693
+ pendingTemplate = null;
12694
+ projectedContainer = null;
12695
+ identityRequested = false;
12641
12696
  connectedCallback() {
12642
12697
  super.connectedCallback();
12643
12698
  this.dataset.theme = "dark";
12644
- this.readDisplayCookie();
12645
12699
  const tmpl = this.querySelector("template");
12646
12700
  if (tmpl instanceof HTMLTemplateElement) {
12647
12701
  this.templateMode = true;
12648
- this.renderTemplate(tmpl);
12702
+ this.pendingTemplate = tmpl;
12703
+ this.projectTemplate();
12649
12704
  }
12650
12705
  document.addEventListener("click", this.handleDocumentClick);
12651
12706
  document.addEventListener("keydown", this.handleDocumentKeydown);
12707
+ this.maybeLoadIdentity();
12652
12708
  }
12653
12709
  disconnectedCallback() {
12654
12710
  super.disconnectedCallback();
@@ -12658,38 +12714,67 @@ let ZitadelLogout = class ZitadelLogout extends i$2 {
12658
12714
  updated() {
12659
12715
  const root = this.shadowRoot;
12660
12716
  if (root && !this.templateMode) applyBaseTokens(root);
12717
+ this.maybeLoadIdentity();
12718
+ }
12719
+ /** Declarative config read from this element's attributes. */
12720
+ get projectAttrs() {
12721
+ return {
12722
+ projectId: this.projectId,
12723
+ proxyPath: this.proxyPath,
12724
+ url: this.url
12725
+ };
12661
12726
  }
12662
12727
  /**
12663
- * Decodes the `__nextgen_display` cookie (base64-encoded JSON, set by the
12664
- * auth backend on sign-in) and populates `displayName` / `displayEmail`.
12665
- * A missing or malformed cookie is intentionally non-fatal the dropdown
12666
- * still renders, just with empty values.
12728
+ * Fetches the signed-in identity from `GET /sessions/me` once a project is
12729
+ * resolvable. No-ops until then (and on repeat calls) so framework property
12730
+ * timing doesn't matter and we never fire the request twice. A pending
12731
+ * `<template>` is already projected in `connectedCallback`, so when no config
12732
+ * is available yet the logout control still renders; it is re-projected with
12733
+ * the real identity once a later request succeeds.
12667
12734
  */
12668
- readDisplayCookie() {
12669
- if (typeof document === "undefined") return;
12670
- const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${DISPLAY_COOKIE_NAME}=([^;]+)`));
12671
- if (!match || !match[1]) return;
12735
+ maybeLoadIdentity() {
12736
+ if (this.identityRequested) return;
12737
+ let api;
12672
12738
  try {
12673
- const data = JSON.parse(atob(match[1]));
12674
- this.displayName = typeof data.name === "string" ? data.name : "";
12675
- this.displayEmail = typeof data.email === "string" ? data.email : "";
12676
- } catch {}
12739
+ ({api} = resolveApi(this.project, this.projectAttrs, "<zitadel-logout>"));
12740
+ } catch {
12741
+ return;
12742
+ }
12743
+ this.identityRequested = true;
12744
+ this.loadIdentity(api);
12745
+ }
12746
+ async loadIdentity(api) {
12747
+ try {
12748
+ const session = await getSession$1(api);
12749
+ this.displayName = session.name ?? "";
12750
+ this.displayEmail = session.email ?? "";
12751
+ this.displayUserId = session.user_id ?? "";
12752
+ } catch {} finally {
12753
+ this.projectTemplate();
12754
+ }
12677
12755
  }
12678
12756
  get initial() {
12679
- const source = this.displayName || this.displayEmail;
12757
+ const source = this.displayName || this.displayEmail || this.displayUserId;
12680
12758
  return source ? source.charAt(0).toUpperCase() : "?";
12681
12759
  }
12682
12760
  /**
12683
- * Clones a consumer-supplied `<template>` into the light DOM, fills the
12761
+ * Clones the consumer-supplied `<template>` into the light DOM, fills the
12684
12762
  * `{{name}}`, `{{email}}`, and `{{initial}}` tokens via a TreeWalker, and
12685
12763
  * wires every element with `data-action="logout"` to trigger sign-out.
12686
12764
  * Light-DOM mounting is deliberate so the consumer's existing CSS applies.
12765
+ *
12766
+ * Re-runnable: each call replaces the previously projected clone, so a late
12767
+ * identity fetch (or a `project` assigned post-mount) updates the rendered
12768
+ * markup instead of leaving the placeholders stuck on their initial values.
12687
12769
  */
12688
- renderTemplate(tmpl) {
12689
- const clone = tmpl.content.cloneNode(true);
12770
+ projectTemplate() {
12771
+ if (!this.templateMode || !this.pendingTemplate) return;
12772
+ const clone = this.pendingTemplate.content.cloneNode(true);
12690
12773
  fillTemplateTokens(clone, this.displayName, this.displayEmail, this.initial);
12691
12774
  const container = document.createElement("span");
12692
12775
  container.appendChild(clone);
12776
+ this.projectedContainer?.remove();
12777
+ this.projectedContainer = container;
12693
12778
  this.appendChild(container);
12694
12779
  container.querySelectorAll("[data-action=\"logout\"]").forEach((el) => {
12695
12780
  el.addEventListener("click", (event) => {
@@ -12719,20 +12804,12 @@ let ZitadelLogout = class ZitadelLogout extends i$2 {
12719
12804
  * clears the cookie via `Set-Cookie: Max-Age=0`. On success this element fires
12720
12805
  * `zitadel-signout` and optionally navigates to `postSignOutUrl`.
12721
12806
  */
12722
- /** Declarative config read from this element's attributes. */
12723
- get projectAttrs() {
12724
- return {
12725
- projectId: this.projectId,
12726
- proxyPath: this.proxyPath,
12727
- url: this.url
12728
- };
12729
- }
12730
12807
  async doLogout() {
12731
12808
  this.loading = true;
12732
12809
  this.errorMessage = "";
12733
12810
  try {
12734
12811
  const { api } = resolveApi(this.project, this.projectAttrs, "<zitadel-logout>");
12735
- await api.revokeMySession({ credentials: "include" });
12812
+ await revokeSession$1(api);
12736
12813
  } catch (error) {
12737
12814
  const message = error instanceof Error ? error.message : "";
12738
12815
  this.errorMessage = message || "Sign-out failed. Please try again.";
@@ -12784,8 +12861,10 @@ let ZitadelLogout = class ZitadelLogout extends i$2 {
12784
12861
  <div class="preview">
12785
12862
  <div class="preview-avatar" aria-hidden="true">${this.initial}</div>
12786
12863
  <div class="preview-info">
12787
- <div class="preview-name">${this.displayName || this.displayEmail}</div>
12788
- ${this.displayName ? b`<div class="preview-email">${this.displayEmail}</div>` : A}
12864
+ <div class="preview-name">
12865
+ ${this.displayName || this.displayEmail || this.displayUserId}
12866
+ </div>
12867
+ ${this.displayName && this.displayEmail ? b`<div class="preview-email">${this.displayEmail}</div>` : A}
12789
12868
  </div>
12790
12869
  </div>
12791
12870
 
@@ -12843,6 +12922,7 @@ __decorate([n$1({
12843
12922
  })], ZitadelLogout.prototype, "clientId", null);
12844
12923
  __decorate([r$1()], ZitadelLogout.prototype, "displayName", null);
12845
12924
  __decorate([r$1()], ZitadelLogout.prototype, "displayEmail", null);
12925
+ __decorate([r$1()], ZitadelLogout.prototype, "displayUserId", null);
12846
12926
  __decorate([r$1()], ZitadelLogout.prototype, "open", null);
12847
12927
  __decorate([r$1()], ZitadelLogout.prototype, "loading", null);
12848
12928
  __decorate([r$1()], ZitadelLogout.prototype, "errorMessage", null);
@@ -12861,4 +12941,248 @@ function fillTemplateTokens(fragment, name, email, initial) {
12861
12941
  }
12862
12942
  }
12863
12943
  //#endregion
12864
- export { TEMPLATE_NAMES, ThemeController, ZitadelLogin, ZitadelLogout, ZlAlert, ZlButton, ZlCard, ZlCheckbox, ZlField, ZlIcon, ZlPageShell, ZlPill, ZlSelect, applyBrandingTokens, applyFontUrl, baseHostStyles, buildBrandingStylesheet, builtinLocales, createSanitiser, cssVars, de, default_default as defaultTemplate, en, findManifest, focusVisibleStyles, getCurrentStep, layout_chrome_default as layoutChromeCss, listKnownTags, manifestRegistry, patchMandatoryGates, resolveTheme, startFlow, submitStep, t, tokens, validateBranding, zlAlertManifest, zlButtonManifest, zlCardManifest, zlCheckboxManifest, zlFieldManifest, zlIconManifest, zlPageShellManifest, zlPillManifest, zlSelectManifest };
12944
+ //#region src/orchestrator/zitadel-session.ts
12945
+ let ZitadelSession = class ZitadelSession extends i$2 {
12946
+ static styles = [baseHostStyles, i$5`
12947
+ :host {
12948
+ display: block;
12949
+ min-height: 100vh;
12950
+ background: ${t.color.surface.defaultBlack};
12951
+ color: ${t.color.text.primaryWhite};
12952
+ }
12953
+ .title {
12954
+ margin: 0;
12955
+ font-family: ${t.font.family.heading};
12956
+ font-size: 2rem;
12957
+ font-weight: 700;
12958
+ line-height: 2.5rem;
12959
+ letter-spacing: -0.02em;
12960
+ color: ${t.color.text.primaryWhite};
12961
+ text-align: left;
12962
+ }
12963
+ .identity {
12964
+ margin: 0;
12965
+ font-family: ${t.font.family.sans};
12966
+ font-size: 0.875rem;
12967
+ line-height: 1.25rem;
12968
+ font-weight: 400;
12969
+ color: ${t.color.text.secondaryGray};
12970
+ text-align: left;
12971
+ overflow-wrap: anywhere;
12972
+ }
12973
+ .error {
12974
+ margin: 0;
12975
+ font-size: 0.875rem;
12976
+ line-height: 1.25rem;
12977
+ color: ${t.color.text.error};
12978
+ }
12979
+ `];
12980
+ #_project_accessor_storage;
12981
+ get project() {
12982
+ return this.#_project_accessor_storage;
12983
+ }
12984
+ set project(value) {
12985
+ this.#_project_accessor_storage = value;
12986
+ }
12987
+ #_projectId_accessor_storage = "";
12988
+ get projectId() {
12989
+ return this.#_projectId_accessor_storage;
12990
+ }
12991
+ set projectId(value) {
12992
+ this.#_projectId_accessor_storage = value;
12993
+ }
12994
+ #_proxyPath_accessor_storage = "";
12995
+ get proxyPath() {
12996
+ return this.#_proxyPath_accessor_storage;
12997
+ }
12998
+ set proxyPath(value) {
12999
+ this.#_proxyPath_accessor_storage = value;
13000
+ }
13001
+ #_url_accessor_storage = "";
13002
+ get url() {
13003
+ return this.#_url_accessor_storage;
13004
+ }
13005
+ set url(value) {
13006
+ this.#_url_accessor_storage = value;
13007
+ }
13008
+ #_postSignOutUrl_accessor_storage = "";
13009
+ get postSignOutUrl() {
13010
+ return this.#_postSignOutUrl_accessor_storage;
13011
+ }
13012
+ set postSignOutUrl(value) {
13013
+ this.#_postSignOutUrl_accessor_storage = value;
13014
+ }
13015
+ #_heading_accessor_storage = "Signed in as";
13016
+ get heading() {
13017
+ return this.#_heading_accessor_storage;
13018
+ }
13019
+ set heading(value) {
13020
+ this.#_heading_accessor_storage = value;
13021
+ }
13022
+ #_logoutLabel_accessor_storage = "Sign out";
13023
+ get logoutLabel() {
13024
+ return this.#_logoutLabel_accessor_storage;
13025
+ }
13026
+ set logoutLabel(value) {
13027
+ this.#_logoutLabel_accessor_storage = value;
13028
+ }
13029
+ #_displayName_accessor_storage = "";
13030
+ get displayName() {
13031
+ return this.#_displayName_accessor_storage;
13032
+ }
13033
+ set displayName(value) {
13034
+ this.#_displayName_accessor_storage = value;
13035
+ }
13036
+ #_displayEmail_accessor_storage = "";
13037
+ get displayEmail() {
13038
+ return this.#_displayEmail_accessor_storage;
13039
+ }
13040
+ set displayEmail(value) {
13041
+ this.#_displayEmail_accessor_storage = value;
13042
+ }
13043
+ #_displayUserId_accessor_storage = "";
13044
+ get displayUserId() {
13045
+ return this.#_displayUserId_accessor_storage;
13046
+ }
13047
+ set displayUserId(value) {
13048
+ this.#_displayUserId_accessor_storage = value;
13049
+ }
13050
+ #_loading_accessor_storage = false;
13051
+ get loading() {
13052
+ return this.#_loading_accessor_storage;
13053
+ }
13054
+ set loading(value) {
13055
+ this.#_loading_accessor_storage = value;
13056
+ }
13057
+ #_errorMessage_accessor_storage = "";
13058
+ get errorMessage() {
13059
+ return this.#_errorMessage_accessor_storage;
13060
+ }
13061
+ set errorMessage(value) {
13062
+ this.#_errorMessage_accessor_storage = value;
13063
+ }
13064
+ identityRequested = false;
13065
+ connectedCallback() {
13066
+ super.connectedCallback();
13067
+ this.dataset.theme = "dark";
13068
+ this.maybeLoadIdentity();
13069
+ }
13070
+ /** Single identity line: human-readable name, then email, then user_id. */
13071
+ get identityLabel() {
13072
+ return this.displayName || this.displayEmail || this.displayUserId;
13073
+ }
13074
+ updated() {
13075
+ const root = this.shadowRoot;
13076
+ if (root) applyBaseTokens(root);
13077
+ this.maybeLoadIdentity();
13078
+ }
13079
+ /** Declarative config read from this element's attributes. */
13080
+ get projectAttrs() {
13081
+ return {
13082
+ projectId: this.projectId,
13083
+ proxyPath: this.proxyPath,
13084
+ url: this.url
13085
+ };
13086
+ }
13087
+ /**
13088
+ * Fetches the signed-in identity from `GET /sessions/me` once a project is
13089
+ * resolvable. No-ops until then (and on repeat calls) so framework property
13090
+ * timing doesn't matter and we never fire the request twice.
13091
+ */
13092
+ maybeLoadIdentity() {
13093
+ if (this.identityRequested) return;
13094
+ let api;
13095
+ try {
13096
+ ({api} = resolveApi(this.project, this.projectAttrs, "<zitadel-session>"));
13097
+ } catch {
13098
+ return;
13099
+ }
13100
+ this.identityRequested = true;
13101
+ this.fetchIdentity(api);
13102
+ }
13103
+ async fetchIdentity(api) {
13104
+ try {
13105
+ const session = await getSession$1(api);
13106
+ this.displayName = session.name ?? "";
13107
+ this.displayEmail = session.email ?? "";
13108
+ this.displayUserId = session.user_id ?? "";
13109
+ } catch {}
13110
+ }
13111
+ /**
13112
+ * Calls `DELETE /sessions/me` (`revokeMySession`) with credentials. On
13113
+ * success fires `zitadel-signout` and optionally navigates to
13114
+ * `postSignOutUrl`; on failure surfaces an inline error and stays put.
13115
+ */
13116
+ async doLogout() {
13117
+ this.loading = true;
13118
+ this.errorMessage = "";
13119
+ try {
13120
+ const { api } = resolveApi(this.project, this.projectAttrs, "<zitadel-session>");
13121
+ await revokeSession$1(api);
13122
+ } catch (error) {
13123
+ const message = error instanceof Error ? error.message : "";
13124
+ this.errorMessage = message || "Sign-out failed. Please try again.";
13125
+ this.loading = false;
13126
+ return;
13127
+ }
13128
+ this.loading = false;
13129
+ emit(this, "zitadel-signout", {
13130
+ name: this.displayName,
13131
+ email: this.displayEmail
13132
+ });
13133
+ if (this.postSignOutUrl && typeof window !== "undefined") window.location.assign(this.postSignOutUrl);
13134
+ }
13135
+ handleLogout(event) {
13136
+ event.preventDefault();
13137
+ this.doLogout();
13138
+ }
13139
+ render() {
13140
+ return b`
13141
+ <zl-page-shell>
13142
+ <zl-card>
13143
+ <h1 slot="header" class="title">${this.heading}</h1>
13144
+ ${this.identityLabel ? b`<p slot="header" class="identity">${this.identityLabel}</p>` : A}
13145
+
13146
+ <zl-button
13147
+ hierarchy="primary"
13148
+ size="medium"
13149
+ block
13150
+ ?loading=${this.loading}
13151
+ data-testid="zitadel-session-logout"
13152
+ label=${this.logoutLabel}
13153
+ @zl-submit=${this.handleLogout}
13154
+ ></zl-button>
13155
+
13156
+ ${this.errorMessage ? b`<p class="error" role="alert">${this.errorMessage}</p>` : A}
13157
+ </zl-card>
13158
+ </zl-page-shell>
13159
+ `;
13160
+ }
13161
+ };
13162
+ __decorate([n$1({ attribute: false })], ZitadelSession.prototype, "project", null);
13163
+ __decorate([n$1({
13164
+ type: String,
13165
+ attribute: "project-id"
13166
+ })], ZitadelSession.prototype, "projectId", null);
13167
+ __decorate([n$1({
13168
+ type: String,
13169
+ attribute: "proxy-path"
13170
+ })], ZitadelSession.prototype, "proxyPath", null);
13171
+ __decorate([n$1({ type: String })], ZitadelSession.prototype, "url", null);
13172
+ __decorate([n$1({
13173
+ type: String,
13174
+ attribute: "post-sign-out-url"
13175
+ })], ZitadelSession.prototype, "postSignOutUrl", null);
13176
+ __decorate([n$1({ type: String })], ZitadelSession.prototype, "heading", null);
13177
+ __decorate([n$1({
13178
+ type: String,
13179
+ attribute: "logout-label"
13180
+ })], ZitadelSession.prototype, "logoutLabel", null);
13181
+ __decorate([r$1()], ZitadelSession.prototype, "displayName", null);
13182
+ __decorate([r$1()], ZitadelSession.prototype, "displayEmail", null);
13183
+ __decorate([r$1()], ZitadelSession.prototype, "displayUserId", null);
13184
+ __decorate([r$1()], ZitadelSession.prototype, "loading", null);
13185
+ __decorate([r$1()], ZitadelSession.prototype, "errorMessage", null);
13186
+ ZitadelSession = __decorate([t$4("zitadel-session")], ZitadelSession);
13187
+ //#endregion
13188
+ export { TEMPLATE_NAMES, ThemeController, ZitadelLogin, ZitadelLogout, ZitadelSession, ZlAlert, ZlButton, ZlCard, ZlCheckbox, ZlField, ZlIcon, ZlPageShell, ZlPill, ZlSelect, applyBrandingTokens, applyFontUrl, baseHostStyles, buildBrandingStylesheet, builtinLocales, createSanitiser, cssVars, de, default_default as defaultTemplate, en, findManifest, focusVisibleStyles, getCurrentStep, layout_chrome_default as layoutChromeCss, listKnownTags, manifestRegistry, patchMandatoryGates, resolveTheme, startFlow, submitStep, t, tokens, validateBranding, zlAlertManifest, zlButtonManifest, zlCardManifest, zlCheckboxManifest, zlFieldManifest, zlIconManifest, zlPageShellManifest, zlPillManifest, zlSelectManifest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zitadel/components",
3
- "version": "0.1.0-alpha.12",
3
+ "version": "0.1.0-alpha.14",
4
4
  "description": "Lit-based atomic web components and the <zitadel-login> orchestrator for the Zitadel auth UI.",
5
5
  "homepage": "https://github.com/zitadel/nextgen/tree/main/packages/components#readme",
6
6
  "bugs": {
@@ -69,10 +69,10 @@
69
69
  "lightningcss": "^1.30.1",
70
70
  "tsdown": "^0.21.10",
71
71
  "tslib": "^2.8.1",
72
- "@zitadel/api-mock": "0.0.0",
73
- "@zitadel/api": "0.1.0-alpha.12",
74
72
  "@zitadel/design-tokens": "0.1.0-alpha.0",
75
- "@zitadel/shared-component-styles": "0.0.0"
73
+ "@zitadel/api": "0.1.0-alpha.14",
74
+ "@zitadel/shared-component-styles": "0.0.0",
75
+ "@zitadel/api-mock": "0.0.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsdown",