@thunderid/vue 1.9.1 → 1.10.1

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 (28) hide show
  1. package/dist/__tests__/helpers/managementContext.d.ts +3 -1
  2. package/dist/__tests__/helpers/managementContext.d.ts.map +1 -1
  3. package/dist/cjs/index.cjs +624 -20
  4. package/dist/components/auth/device-grant/BaseDeviceGrant.css.d.ts +3 -0
  5. package/dist/components/auth/device-grant/BaseDeviceGrant.css.d.ts.map +1 -0
  6. package/dist/components/auth/device-grant/BaseDeviceGrant.d.ts +21 -0
  7. package/dist/components/auth/device-grant/BaseDeviceGrant.d.ts.map +1 -0
  8. package/dist/components/auth/device-grant/DeviceGrant.d.ts +7 -0
  9. package/dist/components/auth/device-grant/DeviceGrant.d.ts.map +1 -0
  10. package/dist/components/auth/flow/AuthOptionFactoryCore.d.ts.map +1 -1
  11. package/dist/components/auth/flow/Consent.css.d.ts +3 -0
  12. package/dist/components/auth/flow/Consent.css.d.ts.map +1 -0
  13. package/dist/components/auth/flow/Consent.d.ts +20 -0
  14. package/dist/components/auth/flow/Consent.d.ts.map +1 -0
  15. package/dist/components/auth/sign-in/BaseSignIn.d.ts +3 -1
  16. package/dist/components/auth/sign-in/BaseSignIn.d.ts.map +1 -1
  17. package/dist/components/auth/sign-in/SignIn.d.ts.map +1 -1
  18. package/dist/components/primitives/Typography/Typography.d.ts.map +1 -1
  19. package/dist/composables/management/useGrantedPermissions.d.ts +2 -1
  20. package/dist/composables/management/useGrantedPermissions.d.ts.map +1 -1
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +623 -22
  24. package/dist/models/contexts.d.ts +2 -0
  25. package/dist/models/contexts.d.ts.map +1 -1
  26. package/dist/providers/ThunderIDProvider.d.ts.map +1 -1
  27. package/dist/styles/injectStyles.d.ts.map +1 -1
  28. package/package.json +2 -2
@@ -1162,6 +1162,7 @@ const ThunderIDProvider = (0, vue.defineComponent)({
1162
1162
  scopes: props.scopes,
1163
1163
  exchangeToken: (config) => client.exchangeToken(config),
1164
1164
  getAccessToken: () => client.getAccessToken(),
1165
+ getGrantedPermissions: () => client.getGrantedPermissions(),
1165
1166
  getDecodedIdToken: () => client.getDecodedIdToken(),
1166
1167
  getIdToken: () => client.getIdToken(),
1167
1168
  getStorageManager: () => client.getStorageManager(),
@@ -2452,6 +2453,171 @@ const ADMIN_CSS = `
2452
2453
  `;
2453
2454
  var Admin_css_default = ADMIN_CSS;
2454
2455
 
2456
+ //#endregion
2457
+ //#region src/components/auth/device-grant/BaseDeviceGrant.css.ts
2458
+ const BASE_DEVICE_GRANT_CSS = `
2459
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal")} {
2460
+ box-sizing: border-box;
2461
+ width: 100%;
2462
+ max-width: calc(var(--thunderid-spacing-unit) * 60);
2463
+ margin: 0 auto;
2464
+ gap: var(--thunderid-spacing-unit);
2465
+ }
2466
+
2467
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-title")} {
2468
+ margin: 0;
2469
+ }
2470
+
2471
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-title--success")} {
2472
+ color: var(--thunderid-color-success-main);
2473
+ }
2474
+
2475
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-title--failure")} {
2476
+ color: var(--thunderid-color-error-main);
2477
+ }
2478
+
2479
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-description")} {
2480
+ margin: 0;
2481
+ }
2482
+ `;
2483
+ var BaseDeviceGrant_css_default = BASE_DEVICE_GRANT_CSS;
2484
+
2485
+ //#endregion
2486
+ //#region src/components/auth/flow/Consent.css.ts
2487
+ const CONSENT_CSS = `
2488
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent")} {
2489
+ display: flex;
2490
+ flex-direction: column;
2491
+ gap: calc(var(--thunderid-spacing-unit) * 2);
2492
+ margin-top: calc(var(--thunderid-spacing-unit) * 0.5);
2493
+ }
2494
+
2495
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__purpose")} {
2496
+ padding-bottom: calc(var(--thunderid-spacing-unit) * 2);
2497
+ }
2498
+
2499
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__section")} {
2500
+ margin-top: var(--thunderid-spacing-unit);
2501
+ }
2502
+
2503
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__header")} {
2504
+ display: flex;
2505
+ align-items: center;
2506
+ gap: calc(var(--thunderid-spacing-unit) * 0.5);
2507
+ margin-bottom: calc(var(--thunderid-spacing-unit) * 1.25);
2508
+ }
2509
+
2510
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__optional-header")} {
2511
+ display: flex;
2512
+ align-items: center;
2513
+ justify-content: space-between;
2514
+ gap: var(--thunderid-spacing-unit);
2515
+ padding-right: calc(var(--thunderid-spacing-unit) * 0.5);
2516
+ }
2517
+
2518
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__title")} {
2519
+ color: var(--thunderid-color-text-primary);
2520
+ font-weight: var(--thunderid-typography-fontWeight-bold);
2521
+ }
2522
+
2523
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__info")} {
2524
+ display: inline-flex;
2525
+ color: var(--thunderid-color-text-secondary);
2526
+ cursor: help;
2527
+ }
2528
+
2529
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__optional-header")} > .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__header")} {
2530
+ margin-bottom: calc(var(--thunderid-spacing-unit) * 1.25);
2531
+ }
2532
+
2533
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__items")} {
2534
+ display: flex;
2535
+ flex-direction: column;
2536
+ gap: calc(var(--thunderid-spacing-unit) * 1.25);
2537
+ }
2538
+
2539
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__item")} {
2540
+ display: flex;
2541
+ align-items: center;
2542
+ justify-content: space-between;
2543
+ gap: var(--thunderid-spacing-unit);
2544
+ min-height: 20px;
2545
+ }
2546
+
2547
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__item-label")} {
2548
+ display: flex;
2549
+ align-items: center;
2550
+ gap: calc(var(--thunderid-spacing-unit) * 0.75);
2551
+ }
2552
+
2553
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__bullet")} {
2554
+ width: 4px;
2555
+ height: 4px;
2556
+ flex: 0 0 4px;
2557
+ border-radius: 50%;
2558
+ background: var(--thunderid-color-text-secondary);
2559
+ }
2560
+
2561
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-container")} {
2562
+ position: relative;
2563
+ display: inline-flex;
2564
+ align-items: center;
2565
+ cursor: pointer;
2566
+ }
2567
+
2568
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input")} {
2569
+ position: absolute;
2570
+ width: 1px;
2571
+ height: 1px;
2572
+ margin: -1px;
2573
+ overflow: hidden;
2574
+ clip: rect(0 0 0 0);
2575
+ white-space: nowrap;
2576
+ }
2577
+
2578
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track")} {
2579
+ position: relative;
2580
+ display: inline-flex;
2581
+ align-items: center;
2582
+ width: 36px;
2583
+ height: 20px;
2584
+ border-radius: 9999px;
2585
+ background: var(--thunderid-color-text-secondary);
2586
+ opacity: 0.25;
2587
+ transition: background-color 0.2s ease, opacity 0.2s ease;
2588
+ }
2589
+
2590
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input")}:checked + .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track")} {
2591
+ background: var(--thunderid-color-primary-main);
2592
+ opacity: 1;
2593
+ }
2594
+
2595
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input")}:focus-visible + .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track")} {
2596
+ outline: 2px solid var(--thunderid-color-border-focus);
2597
+ outline-offset: 2px;
2598
+ }
2599
+
2600
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-thumb")} {
2601
+ position: absolute;
2602
+ left: 2px;
2603
+ width: 16px;
2604
+ height: 16px;
2605
+ border-radius: 50%;
2606
+ background: var(--thunderid-color-background-surface);
2607
+ transition: transform 0.2s ease;
2608
+ }
2609
+
2610
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input")}:checked + .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track")} .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-thumb")} {
2611
+ transform: translateX(16px);
2612
+ }
2613
+
2614
+ .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input")}:disabled + .${(0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track")} {
2615
+ cursor: not-allowed;
2616
+ opacity: 0.4;
2617
+ }
2618
+ `;
2619
+ var Consent_css_default = CONSENT_CSS;
2620
+
2455
2621
  //#endregion
2456
2622
  //#region src/components/auth/sign-in/BaseSignIn.css.ts
2457
2623
  /**
@@ -4168,6 +4334,8 @@ const STYLES = [
4168
4334
  Spinner_css_default,
4169
4335
  DataTable_css_default,
4170
4336
  BaseSignIn_css_default,
4337
+ Consent_css_default,
4338
+ BaseDeviceGrant_css_default,
4171
4339
  ChangeCredential_css_default,
4172
4340
  LanguageSwitcher_css_default,
4173
4341
  UserDropdown_css_default,
@@ -4828,7 +4996,8 @@ var useManagementRequestConfig_default = useManagementRequestConfig;
4828
4996
  //#region src/composables/management/useGrantedPermissions.ts
4829
4997
  /**
4830
4998
  * Reads the permissions the signed-in user's access token grants, for example to hide a page the
4831
- * user cannot use.
4999
+ * user cannot use. In backend mode they come from the backend's session, so the token stays on the
5000
+ * backend.
4832
5001
  *
4833
5002
  * @returns The granted permissions and a `can` check.
4834
5003
  *
@@ -4844,7 +5013,7 @@ var useManagementRequestConfig_default = useManagementRequestConfig;
4844
5013
  * ```
4845
5014
  */
4846
5015
  const useGrantedPermissions = () => {
4847
- const { getAccessToken, isSignedIn } = useThunderID_default();
5016
+ const { getGrantedPermissions, isSignedIn } = useThunderID_default();
4848
5017
  const granted = (0, vue.shallowRef)(null);
4849
5018
  let generation = 0;
4850
5019
  (0, vue.watch)(() => isSignedIn.value, (signedIn) => {
@@ -4854,8 +5023,8 @@ const useGrantedPermissions = () => {
4854
5023
  granted.value = null;
4855
5024
  return;
4856
5025
  }
4857
- getAccessToken().then((token) => (0, __thunderid_browser.getTokenPermissions)(token)).catch(() => []).then((tokenPermissions) => {
4858
- if (current === generation) granted.value = tokenPermissions;
5026
+ getGrantedPermissions().catch(() => []).then((grantedPermissions) => {
5027
+ if (current === generation) granted.value = grantedPermissions;
4859
5028
  });
4860
5029
  }, { immediate: true });
4861
5030
  if ((0, vue.getCurrentScope)()) (0, vue.onScopeDispose)(() => {
@@ -6172,6 +6341,10 @@ var OtpField_default = OtpField;
6172
6341
  const Typography = (0, vue.defineComponent)({
6173
6342
  name: "Typography",
6174
6343
  props: {
6344
+ color: {
6345
+ default: void 0,
6346
+ type: String
6347
+ },
6175
6348
  component: {
6176
6349
  default: void 0,
6177
6350
  type: String
@@ -6183,7 +6356,7 @@ const Typography = (0, vue.defineComponent)({
6183
6356
  },
6184
6357
  setup(props, { slots, attrs }) {
6185
6358
  return () => {
6186
- return (0, vue.h)(props.component || {
6359
+ const tag = props.component ?? {
6187
6360
  body1: "p",
6188
6361
  body2: "p",
6189
6362
  caption: "span",
@@ -6196,13 +6369,29 @@ const Typography = (0, vue.defineComponent)({
6196
6369
  overline: "span",
6197
6370
  subtitle1: "h6",
6198
6371
  subtitle2: "h6"
6199
- }[props.variant] || "p", {
6372
+ }[props.variant] ?? "p";
6373
+ const colorVar = {
6374
+ error: "var(--thunderid-color-error-main)",
6375
+ info: "var(--thunderid-color-info-main)",
6376
+ inherit: "inherit",
6377
+ primary: "var(--thunderid-color-primary-main)",
6378
+ secondary: "var(--thunderid-color-secondary-main)",
6379
+ success: "var(--thunderid-color-success-main)",
6380
+ textPrimary: "var(--thunderid-color-text-primary)",
6381
+ textSecondary: "var(--thunderid-color-text-secondary)",
6382
+ warning: "var(--thunderid-color-warning-main)"
6383
+ };
6384
+ const style = {
6385
+ ...attrs.style,
6386
+ ...props.color ? { color: colorVar[props.color] } : {}
6387
+ };
6388
+ return (0, vue.h)(tag, {
6200
6389
  class: [
6201
6390
  (0, __thunderid_browser.withVendorCSSClassPrefix)("typography"),
6202
6391
  (0, __thunderid_browser.withVendorCSSClassPrefix)(`typography--${props.variant}`),
6203
6392
  attrs.class || ""
6204
6393
  ].filter(Boolean).join(" "),
6205
- style: attrs.style
6394
+ style
6206
6395
  }, slots["default"]?.());
6207
6396
  };
6208
6397
  }
@@ -7052,6 +7241,111 @@ const normalizeFlowResponse = (response, t, options = {}, meta) => {
7052
7241
  };
7053
7242
  };
7054
7243
 
7244
+ //#endregion
7245
+ //#region src/components/auth/flow/Consent.ts
7246
+ const getConsentOptionalKey = (purposeId, attrName) => `__consent_opt__${purposeId}__${attrName}`;
7247
+ const isObject = (value) => typeof value === "object" && value !== null;
7248
+ const parsePurposes = (consentData) => {
7249
+ if (!consentData) return [];
7250
+ let parsed = consentData;
7251
+ if (typeof consentData === "string") try {
7252
+ parsed = JSON.parse(consentData);
7253
+ } catch {
7254
+ return [];
7255
+ }
7256
+ const rawPurposes = Array.isArray(parsed) ? parsed : parsed?.purposes;
7257
+ if (!Array.isArray(rawPurposes)) return [];
7258
+ return rawPurposes.filter((purpose) => isObject(purpose) && typeof purpose["purposeId"] === "string").map((purpose) => ({
7259
+ ...purpose,
7260
+ essential: Array.isArray(purpose["essential"]) ? purpose["essential"].filter((element) => isObject(element) && typeof element["name"] === "string") : [],
7261
+ optional: Array.isArray(purpose["optional"]) ? purpose["optional"].filter((element) => isObject(element) && typeof element["name"] === "string") : []
7262
+ })).sort((a, b) => Number(b.type === "permissions") - Number(a.type === "permissions"));
7263
+ };
7264
+ const Consent = (0, vue.defineComponent)({
7265
+ name: "Consent",
7266
+ props: {
7267
+ consentData: {
7268
+ default: void 0,
7269
+ type: [
7270
+ String,
7271
+ Array,
7272
+ Object
7273
+ ]
7274
+ },
7275
+ formValues: {
7276
+ required: true,
7277
+ type: Object
7278
+ },
7279
+ onInputChange: {
7280
+ required: true,
7281
+ type: Function
7282
+ },
7283
+ t: {
7284
+ default: void 0,
7285
+ type: Function
7286
+ }
7287
+ },
7288
+ setup(props, { slots }) {
7289
+ const translate = (key, fallback = "") => {
7290
+ const value = props.t?.(key);
7291
+ return value && value !== key ? value : fallback;
7292
+ };
7293
+ const toggle = (id, checked, label, onChange) => (0, vue.h)("label", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-container") }, [(0, vue.h)("input", {
7294
+ "aria-label": label,
7295
+ checked,
7296
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-input"),
7297
+ id,
7298
+ onChange: (event) => onChange(event.target.checked),
7299
+ role: "switch",
7300
+ type: "checkbox"
7301
+ }), (0, vue.h)("span", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-track") }, [(0, vue.h)("span", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__toggle-thumb") })])]);
7302
+ const sectionTitle = (label, info) => [(0, vue.h)(Typography_default, {
7303
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__title"),
7304
+ component: "span",
7305
+ variant: "subtitle2"
7306
+ }, () => label), info ? (0, vue.h)("span", {
7307
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__info"),
7308
+ title: info,
7309
+ "aria-label": info,
7310
+ role: "img"
7311
+ }, [(0, vue.h)(InfoIcon)]) : null].filter((node) => node !== null);
7312
+ return () => {
7313
+ const purposes = parsePurposes(props.consentData);
7314
+ if (purposes.length === 0) return null;
7315
+ if (slots["default"]) return (0, vue.h)("div", slots["default"]({
7316
+ formValues: props.formValues,
7317
+ onInputChange: props.onInputChange,
7318
+ purposes
7319
+ }));
7320
+ return (0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent") }, purposes.map((purpose) => {
7321
+ const permission = purpose.type === "permissions";
7322
+ const optionalName = permission ? translate("consent.optional_scope", "Optional Permissions") : translate("consent.optional_claims", "Optional Attributes");
7323
+ const essentialName = permission ? translate("consent.essential_scope", "Essential Permissions") : translate("consent.essential_claims", "Essential Attributes");
7324
+ const allSelected = purpose.optional.length > 0 && purpose.optional.every((element) => props.formValues[getConsentOptionalKey(purpose.purposeId, element.name)] === "true");
7325
+ const itemList = (elements, essential) => (0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__items") }, elements.map((element) => {
7326
+ const key = getConsentOptionalKey(purpose.purposeId, element.name);
7327
+ const label = translate(`consent.${element.name}`, element.name);
7328
+ return (0, vue.h)("div", {
7329
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__item"),
7330
+ key: element.name
7331
+ }, [(0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__item-label") }, [(0, vue.h)("span", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__bullet") }), (0, vue.h)(Typography_default, {
7332
+ component: "span",
7333
+ variant: "body2"
7334
+ }, () => label)]), essential ? (0, vue.h)(Typography_default, {
7335
+ component: "span",
7336
+ variant: "body2"
7337
+ }, () => translate("consent.required", "Required")) : toggle(`consent_opt_${purpose.purposeId}_${element.name}`, props.formValues[key] === "true", label, (value) => props.onInputChange(key, value ? "true" : "false"))]);
7338
+ }));
7339
+ return (0, vue.h)("section", {
7340
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__purpose"),
7341
+ key: purpose.purposeId
7342
+ }, [purpose.essential.length > 0 ? (0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__section") }, [(0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__header") }, sectionTitle(essentialName, translate(permission ? "consent.essential_scope.info" : "consent.essential_claims.info", permission ? "" : "These attributes are required for the service to function properly."))), itemList(purpose.essential, true)]) : null, purpose.optional.length > 0 ? (0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__section") }, [(0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__optional-header") }, [(0, vue.h)("div", { class: (0, __thunderid_browser.withVendorCSSClassPrefix)("consent__header") }, sectionTitle(optionalName, translate(permission ? "consent.optional_scope.info" : "consent.optional_claims.info", permission ? "" : "These attributes are optional and can be provided at your discretion."))), toggle(`consent_opt_${purpose.purposeId}_all`, allSelected, optionalName, (checked) => purpose.optional.forEach((element) => props.onInputChange(getConsentOptionalKey(purpose.purposeId, element.name), checked ? "true" : "false")))]), itemList(purpose.optional, false)]) : null]);
7343
+ }));
7344
+ };
7345
+ }
7346
+ });
7347
+ var Consent_default = Consent;
7348
+
7055
7349
  //#endregion
7056
7350
  //#region src/components/auth/flow/FieldFactory.ts
7057
7351
  /**
@@ -7788,10 +8082,6 @@ var MicrosoftButton_default = MicrosoftButton;
7788
8082
  //#region src/components/auth/flow/AuthOptionFactoryCore.ts
7789
8083
  const logger$2 = createVueLogger("AuthOptionFactory");
7790
8084
  /**
7791
- * Inline helper for consent optional attribute key (mirrors ConsentCheckboxList.getConsentOptionalKey).
7792
- */
7793
- const getConsentOptionalKey = (purposeId, attr) => `consent_${purposeId}_${attr}`;
7794
- /**
7795
8085
  * Replaces `emoji:` URIs embedded in HTML before DOMPurify sanitization.
7796
8086
  *
7797
8087
  * DOMPurify strips unknown URI schemes from attributes (e.g. `src="emoji:🦊"` → `src=""`).
@@ -7841,6 +8131,17 @@ const getTypographyVariant = (variant) => {
7841
8131
  SUBTITLE_2: "subtitle2"
7842
8132
  }[variant] || "h3";
7843
8133
  };
8134
+ const getTypographyColor = (color) => {
8135
+ switch (color?.toUpperCase()) {
8136
+ case "ERROR": return "error";
8137
+ case "INFO": return "info";
8138
+ case "PRIMARY": return "primary";
8139
+ case "SECONDARY": return "secondary";
8140
+ case "SUCCESS": return "success";
8141
+ case "WARNING": return "warning";
8142
+ default: return;
8143
+ }
8144
+ };
7844
8145
  /**
7845
8146
  * Check if a button text or action matches a social provider.
7846
8147
  */
@@ -8028,11 +8329,15 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
8028
8329
  }
8029
8330
  case __thunderid_browser.EmbeddedFlowComponentType.Text: {
8030
8331
  const variant = getTypographyVariant(component.variant ?? "");
8332
+ const align = typeof component.align === "string" ? component.align : "left";
8333
+ const color = getTypographyColor(component.color);
8031
8334
  return (0, vue.h)(Typography_default, {
8335
+ id: component.id,
8032
8336
  key,
8337
+ color,
8033
8338
  style: {
8034
8339
  marginBottom: "0.5rem",
8035
- textAlign: typeof component.align === "string" ? component.align : "left"
8340
+ textAlign: align
8036
8341
  },
8037
8342
  variant
8038
8343
  }, { default: () => resolve(component.label) });
@@ -8155,9 +8460,13 @@ const createAuthComponentFromFlow = (component, formValues, touchedFields, formE
8155
8460
  style: stackStyle
8156
8461
  }, stackChildren.filter(Boolean));
8157
8462
  }
8158
- case __thunderid_browser.EmbeddedFlowComponentType.Consent:
8159
- logger$2.warn(`Consent component type is not yet fully supported in the Vue SDK.`);
8160
- return null;
8463
+ case __thunderid_browser.EmbeddedFlowComponentType.Consent: return (0, vue.h)(Consent_default, {
8464
+ consentData: options.additionalData?.["consentPrompt"],
8465
+ formValues,
8466
+ key,
8467
+ onInputChange,
8468
+ t: options.t
8469
+ });
8161
8470
  case __thunderid_browser.EmbeddedFlowComponentType.Timer: {
8162
8471
  const textTemplate = resolve(component.label) || "Time remaining: {time}";
8163
8472
  const timeoutMs = Number(options.additionalData?.["stepTimeout"]) || 0;
@@ -8288,6 +8597,10 @@ const BaseSignIn = (0, vue.defineComponent)({
8288
8597
  default: "",
8289
8598
  type: String
8290
8599
  },
8600
+ initialValues: {
8601
+ default: () => ({}),
8602
+ type: Object
8603
+ },
8291
8604
  isLoading: {
8292
8605
  default: false,
8293
8606
  type: Boolean
@@ -8304,6 +8617,10 @@ const BaseSignIn = (0, vue.defineComponent)({
8304
8617
  default: void 0,
8305
8618
  type: Function
8306
8619
  },
8620
+ serverFieldErrors: {
8621
+ default: null,
8622
+ type: Array
8623
+ },
8307
8624
  size: {
8308
8625
  default: "medium",
8309
8626
  type: String
@@ -8325,9 +8642,9 @@ const BaseSignIn = (0, vue.defineComponent)({
8325
8642
  const touchedFields = (0, vue.ref)({});
8326
8643
  (0, vue.watch)(() => props.components, (newComponents) => {
8327
8644
  const fields = extractFormFields$1(newComponents || []);
8328
- const freshValues = {};
8645
+ const freshValues = { ...props.initialValues };
8329
8646
  fields.forEach((f) => {
8330
- freshValues[f.name] = "";
8647
+ freshValues[f.name] = props.initialValues[f.name] ?? "";
8331
8648
  });
8332
8649
  formValues.value = freshValues;
8333
8650
  touchedFields.value = {};
@@ -8335,14 +8652,23 @@ const BaseSignIn = (0, vue.defineComponent)({
8335
8652
  deep: false,
8336
8653
  immediate: true
8337
8654
  });
8655
+ (0, vue.watch)(() => props.initialValues, (initialValues) => {
8656
+ formValues.value = {
8657
+ ...formValues.value,
8658
+ ...initialValues
8659
+ };
8660
+ }, { deep: true });
8338
8661
  const formErrors = (0, vue.computed)(() => {
8339
8662
  const fields = extractFormFields$1(props.components || []);
8340
8663
  const errors = {};
8664
+ (props.serverFieldErrors ?? []).forEach((fieldError) => {
8665
+ if (!(fieldError.identifier in errors)) errors[fieldError.identifier] = fieldError.message;
8666
+ });
8341
8667
  fields.forEach((field) => {
8342
8668
  const value = formValues.value[field.name] || "";
8343
8669
  const isTouched = touchedFields.value[field.name] || false;
8344
- if (field.required && isTouched && (!value || value.trim() === "")) errors[field.name] = t("validations.required.field.error") || "This field is required";
8345
- if (field.type === "EMAIL_INPUT" && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) errors[field.name] = t("field.email.invalid") || "Invalid email address";
8670
+ if (!(field.name in errors) && field.required && isTouched && (!value || value.trim() === "")) errors[field.name] = t("validations.required.field.error") || "This field is required";
8671
+ if (!(field.name in errors) && field.type === "EMAIL_INPUT" && value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) errors[field.name] = t("field.email.invalid") || "Invalid email address";
8346
8672
  });
8347
8673
  return errors;
8348
8674
  });
@@ -8805,7 +9131,7 @@ const SignIn = (0, vue.defineComponent)({
8805
9131
  approved: !isDeny,
8806
9132
  name: e.name
8807
9133
  })), ...(p.optional ?? []).map((e) => {
8808
- const key = `__consent_opt__${p.purposeId}__${e.name}`;
9134
+ const key = getConsentOptionalKey(p.purposeId, e.name);
8809
9135
  return (0, __thunderid_browser.getConsentElementDecision)(p.purposeId, e, !isDeny && processedInputs[key] === "true", processedInputs);
8810
9136
  })],
8811
9137
  purposeName: p.purposeName
@@ -9045,6 +9371,281 @@ const SignIn = (0, vue.defineComponent)({
9045
9371
  });
9046
9372
  var SignIn_default = SignIn;
9047
9373
 
9374
+ //#endregion
9375
+ //#region src/components/auth/device-grant/BaseDeviceGrant.ts
9376
+ /** Renders Device Grant flow steps and terminal status without owning flow execution. */
9377
+ const BaseDeviceGrant = (0, vue.defineComponent)({
9378
+ name: "BaseDeviceGrant",
9379
+ props: {
9380
+ components: {
9381
+ default: () => [],
9382
+ type: Array
9383
+ },
9384
+ additionalData: {
9385
+ default: () => ({}),
9386
+ type: Object
9387
+ },
9388
+ initialValues: {
9389
+ default: () => ({}),
9390
+ type: Object
9391
+ },
9392
+ onSubmit: {
9393
+ required: true,
9394
+ type: Function
9395
+ },
9396
+ result: {
9397
+ default: null,
9398
+ type: String
9399
+ },
9400
+ className: {
9401
+ default: "",
9402
+ type: String
9403
+ },
9404
+ variant: {
9405
+ default: "flat",
9406
+ type: String
9407
+ },
9408
+ size: {
9409
+ default: "medium",
9410
+ type: String
9411
+ },
9412
+ isLoading: {
9413
+ default: false,
9414
+ type: Boolean
9415
+ },
9416
+ error: {
9417
+ default: null,
9418
+ type: Object
9419
+ },
9420
+ serverFieldErrors: {
9421
+ default: null,
9422
+ type: Array
9423
+ },
9424
+ completeMessage: {
9425
+ default: void 0,
9426
+ type: String
9427
+ },
9428
+ completeDescription: {
9429
+ default: void 0,
9430
+ type: String
9431
+ },
9432
+ failedMessage: {
9433
+ default: void 0,
9434
+ type: String
9435
+ },
9436
+ failedDescription: {
9437
+ default: void 0,
9438
+ type: String
9439
+ }
9440
+ },
9441
+ setup(props, { slots, attrs }) {
9442
+ const { t } = useI18n_default();
9443
+ return () => {
9444
+ if (props.result && props.components.length === 0) {
9445
+ const success = props.result === "success" && !props.error;
9446
+ const failedMessage = props.failedMessage ?? t("deviceGrant.messages.failed");
9447
+ const title = success ? props.completeMessage ?? t("deviceGrant.messages.complete") : failedMessage;
9448
+ const description = success ? props.completeDescription ?? t("deviceGrant.messages.completeDescription") : !props.error || props.error.message === failedMessage ? props.failedDescription ?? t("deviceGrant.messages.failedDescription") : props.error.message;
9449
+ return (0, vue.h)(Card_default, {
9450
+ ...attrs,
9451
+ class: [(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal"), props.className].filter(Boolean).join(" "),
9452
+ "data-testid": "device-grant-result",
9453
+ variant: props.variant
9454
+ }, () => [(0, vue.h)(Typography_default, {
9455
+ class: [(0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-title"), (0, __thunderid_browser.withVendorCSSClassPrefix)(`devicegrant__terminal-title--${success ? "success" : "failure"}`)].join(" "),
9456
+ component: "h2",
9457
+ variant: "h6"
9458
+ }, () => title), (0, vue.h)(Typography_default, {
9459
+ class: (0, __thunderid_browser.withVendorCSSClassPrefix)("devicegrant__terminal-description"),
9460
+ component: "p",
9461
+ variant: "caption"
9462
+ }, () => description)]);
9463
+ }
9464
+ return (0, vue.h)(BaseSignIn_default, {
9465
+ ...attrs,
9466
+ className: props.className,
9467
+ components: props.components,
9468
+ additionalData: props.additionalData,
9469
+ error: props.error,
9470
+ initialValues: props.initialValues,
9471
+ isLoading: props.isLoading,
9472
+ onSubmit: props.onSubmit,
9473
+ serverFieldErrors: props.serverFieldErrors,
9474
+ size: props.size,
9475
+ variant: props.variant
9476
+ }, slots["default"] ? { default: (renderProps) => slots["default"]?.({
9477
+ ...renderProps,
9478
+ result: props.result
9479
+ }) } : void 0);
9480
+ };
9481
+ }
9482
+ });
9483
+ var BaseDeviceGrant_default = BaseDeviceGrant;
9484
+
9485
+ //#endregion
9486
+ //#region src/components/auth/device-grant/DeviceGrant.ts
9487
+ const hasUserCodeInput = (components) => components.some((component) => component.ref === "user_code" || Array.isArray(component.components) && hasUserCodeInput(component.components));
9488
+ /** Runs the application's configured Device Grant flow and exposes its state for custom renderers. */
9489
+ const DeviceGrant = (0, vue.defineComponent)({
9490
+ name: "DeviceGrant",
9491
+ props: {
9492
+ className: {
9493
+ default: "",
9494
+ type: String
9495
+ },
9496
+ size: {
9497
+ default: "medium",
9498
+ type: String
9499
+ },
9500
+ variant: {
9501
+ default: "flat",
9502
+ type: String
9503
+ },
9504
+ onComplete: {
9505
+ default: void 0,
9506
+ type: Function
9507
+ },
9508
+ onError: {
9509
+ default: void 0,
9510
+ type: Function
9511
+ }
9512
+ },
9513
+ emits: ["complete", "error"],
9514
+ setup(props, { emit, slots }) {
9515
+ const { applicationId, baseUrl } = useThunderID_default();
9516
+ const { meta } = useFlowMeta_default();
9517
+ const { t } = useI18n_default();
9518
+ const components = (0, vue.ref)([]);
9519
+ const initialValues = (0, vue.ref)({});
9520
+ const additionalData = (0, vue.ref)({});
9521
+ const serverFieldErrors = (0, vue.ref)(null);
9522
+ const executionId = (0, vue.ref)("");
9523
+ const challengeToken = (0, vue.ref)("");
9524
+ const error = (0, vue.ref)(null);
9525
+ const isLoading = (0, vue.ref)(false);
9526
+ const result = (0, vue.ref)(null);
9527
+ const flowStartAttempted = (0, vue.ref)(false);
9528
+ const applyResponse = (response) => {
9529
+ const normalized = normalizeFlowResponse(response, t, { resolveTranslations: false }, meta.value);
9530
+ executionId.value = response.executionId ?? "";
9531
+ challengeToken.value = response.challengeToken ?? "";
9532
+ components.value = normalized.components ?? [];
9533
+ additionalData.value = normalized.additionalData ?? {};
9534
+ serverFieldErrors.value = response.data?.fieldErrors ?? null;
9535
+ error.value = response.error ? new Error(extractErrorMessage(response, t)) : null;
9536
+ if (response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Complete) {
9537
+ result.value = "success";
9538
+ props.onComplete?.(response);
9539
+ emit("complete", response);
9540
+ return;
9541
+ }
9542
+ if (response.flowStatus === __thunderid_browser.EmbeddedSignInFlowStatus.Error) {
9543
+ error.value = new Error(extractErrorMessage(response, t, "deviceGrant.messages.failed"));
9544
+ result.value = "failure";
9545
+ props.onError?.(error.value);
9546
+ emit("error", error.value);
9547
+ return;
9548
+ }
9549
+ result.value = null;
9550
+ };
9551
+ const clearVerificationParameters = () => {
9552
+ const url = new URL(window.location.href);
9553
+ url.searchParams.delete("user_code");
9554
+ url.searchParams.delete("applicationId");
9555
+ window.history.replaceState(window.history.state, "", url.toString());
9556
+ };
9557
+ const startFlow = async (appId) => {
9558
+ isLoading.value = true;
9559
+ error.value = null;
9560
+ try {
9561
+ const response = await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9562
+ baseUrl,
9563
+ payload: {
9564
+ applicationId: appId,
9565
+ flowType: __thunderid_browser.EmbeddedFlowType.DeviceGrant,
9566
+ inputs: {}
9567
+ }
9568
+ });
9569
+ clearVerificationParameters();
9570
+ applyResponse(response);
9571
+ } catch (cause) {
9572
+ const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9573
+ components.value = [];
9574
+ additionalData.value = {};
9575
+ serverFieldErrors.value = null;
9576
+ error.value = flowError;
9577
+ result.value = "failure";
9578
+ props.onError?.(flowError);
9579
+ emit("error", flowError);
9580
+ } finally {
9581
+ isLoading.value = false;
9582
+ }
9583
+ };
9584
+ const submit = async (payload, actionId) => {
9585
+ isLoading.value = true;
9586
+ error.value = null;
9587
+ result.value = null;
9588
+ try {
9589
+ if (!executionId.value) return;
9590
+ const inputs = Object.fromEntries(Object.entries(payload.inputs ?? {}).filter(([key]) => !key.startsWith("__consent_opt__")));
9591
+ if (!hasUserCodeInput(components.value)) delete inputs["user_code"];
9592
+ applyResponse(await (0, __thunderid_browser.executeEmbeddedDeviceGrantFlow)({
9593
+ baseUrl,
9594
+ payload: {
9595
+ action: payload.action ?? actionId,
9596
+ challengeToken: challengeToken.value,
9597
+ executionId: executionId.value,
9598
+ inputs
9599
+ }
9600
+ }));
9601
+ } catch (cause) {
9602
+ const flowError = cause instanceof Error ? cause : new Error(t("deviceGrant.errors.continue"));
9603
+ components.value = [];
9604
+ additionalData.value = {};
9605
+ serverFieldErrors.value = null;
9606
+ error.value = flowError;
9607
+ result.value = "failure";
9608
+ props.onError?.(flowError);
9609
+ emit("error", flowError);
9610
+ } finally {
9611
+ isLoading.value = false;
9612
+ }
9613
+ };
9614
+ (0, vue.onMounted)(() => {
9615
+ const url = new URL(window.location.href);
9616
+ const code = url.searchParams.get("user_code");
9617
+ if (code) initialValues.value = { user_code: code };
9618
+ const applicationIdFromUrl = url.searchParams.get("applicationId");
9619
+ const appId = applicationIdFromUrl?.trim() ? applicationIdFromUrl : applicationId;
9620
+ if (!appId) {
9621
+ const flowError = new Error(t("deviceGrant.errors.start"));
9622
+ error.value = flowError;
9623
+ result.value = "failure";
9624
+ props.onError?.(flowError);
9625
+ emit("error", flowError);
9626
+ return;
9627
+ }
9628
+ if (flowStartAttempted.value) return;
9629
+ flowStartAttempted.value = true;
9630
+ startFlow(appId);
9631
+ });
9632
+ return () => (0, vue.h)(BaseDeviceGrant_default, {
9633
+ className: props.className,
9634
+ components: components.value,
9635
+ additionalData: additionalData.value,
9636
+ error: error.value,
9637
+ initialValues: initialValues.value,
9638
+ isLoading: isLoading.value,
9639
+ onSubmit: (payload, component) => submit(payload, component.id),
9640
+ result: result.value,
9641
+ serverFieldErrors: serverFieldErrors.value,
9642
+ size: props.size,
9643
+ variant: props.variant
9644
+ }, slots["default"] ? { default: slots["default"] } : void 0);
9645
+ }
9646
+ });
9647
+ var DeviceGrant_default = DeviceGrant;
9648
+
9048
9649
  //#endregion
9049
9650
  //#region src/utils/getAuthComponentHeadings.ts
9050
9651
  /**
@@ -16851,6 +17452,7 @@ exports.BaseApplicationDetails = BaseApplicationDetails_default;
16851
17452
  exports.BaseApplicationList = BaseApplicationList_default;
16852
17453
  exports.BaseAuthFlowSelect = BaseAuthFlowSelect_default;
16853
17454
  exports.BaseChangeCredential = BaseChangeCredential_default;
17455
+ exports.BaseDeviceGrant = BaseDeviceGrant_default;
16854
17456
  exports.BaseGroupCreate = BaseGroupCreate_default;
16855
17457
  exports.BaseGroupList = BaseGroupList_default;
16856
17458
  exports.BaseGroupMembers = BaseGroupMembers_default;
@@ -16882,10 +17484,12 @@ exports.Checkbox = Checkbox_default;
16882
17484
  exports.ChevronDownIcon = ChevronDownIcon;
16883
17485
  exports.CircleAlertIcon = CircleAlertIcon;
16884
17486
  exports.CircleCheckIcon = CircleCheckIcon;
17487
+ exports.Consent = Consent_default;
16885
17488
  exports.CopyableText = CopyableText_default;
16886
17489
  exports.DEFAULT_USER_CREATE_FIELDS = DEFAULT_USER_CREATE_FIELDS;
16887
17490
  exports.DataTable = DataTable_default;
16888
17491
  exports.DatePicker = DatePicker_default;
17492
+ exports.DeviceGrant = DeviceGrant_default;
16889
17493
  exports.Divider = Divider_default;
16890
17494
  Object.defineProperty(exports, 'EmbeddedFlowActionVariant', {
16891
17495
  enumerable: true,